PageRenderTime 60ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/a00141_source.html

https://github.com/krackeroda/contiki-doxygen
HTML | 1970 lines | 1969 code | 0 blank | 1 comment | 0 complexity | e1c74512710d8e8a77fb962b5c2a917f MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <title>Contiki 2.5: core/ctk/ctk.c Source File</title>
  6. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  7. <link href="doxygen.css" rel="stylesheet" type="text/css"/>
  8. </head>
  9. <body>
  10. <!-- Generated by Doxygen 1.6.1 -->
  11. <div class="navigation" id="top">
  12. <div class="tabs">
  13. <ul>
  14. <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
  15. <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
  16. <li><a href="modules.html"><span>Modules</span></a></li>
  17. <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
  18. <li class="current"><a href="files.html"><span>Files</span></a></li>
  19. <li><a href="dirs.html"><span>Directories</span></a></li>
  20. <li><a href="examples.html"><span>Examples</span></a></li>
  21. </ul>
  22. </div>
  23. <div class="tabs">
  24. <ul>
  25. <li><a href="files.html"><span>File&nbsp;List</span></a></li>
  26. <li><a href="globals.html"><span>Globals</span></a></li>
  27. </ul>
  28. </div>
  29. <div class="navpath"><a class="el" href="dir_783dcb2b4bcfa12326370fa26c216025.html">core</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_fd6a4b2b6bc2ad2ec9e2fc822895906b.html">ctk</a>
  30. </div>
  31. </div>
  32. <div class="contents">
  33. <h1>ctk.c</h1><a href="a00141.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/**</span>
  34. <a name="l00002"></a>00002 <span class="comment"> * \defgroup ctk CTK graphical user interface</span>
  35. <a name="l00003"></a>00003 <span class="comment"> *</span>
  36. <a name="l00004"></a>00004 <span class="comment"> * The Contiki Toolkit (CTK) provides the graphical user interface for</span>
  37. <a name="l00005"></a>00005 <span class="comment"> * the Contiki system.</span>
  38. <a name="l00006"></a>00006 <span class="comment"> *</span>
  39. <a name="l00007"></a>00007 <span class="comment"> * @{</span>
  40. <a name="l00008"></a>00008 <span class="comment"> */</span>
  41. <a name="l00009"></a>00009 <span class="comment"></span>
  42. <a name="l00010"></a>00010 <span class="comment">/**</span>
  43. <a name="l00011"></a>00011 <span class="comment"> * \file</span>
  44. <a name="l00012"></a>00012 <span class="comment"> * The Contiki Toolkit CTK, the Contiki GUI.</span>
  45. <a name="l00013"></a>00013 <span class="comment"> * \author Adam Dunkels &lt;adam@dunkels.com&gt;</span>
  46. <a name="l00014"></a>00014 <span class="comment"> */</span>
  47. <a name="l00015"></a>00015
  48. <a name="l00016"></a>00016 <span class="comment">/*</span>
  49. <a name="l00017"></a>00017 <span class="comment"> * Copyright (c) 2002-2003, Adam Dunkels.</span>
  50. <a name="l00018"></a>00018 <span class="comment"> * All rights reserved.</span>
  51. <a name="l00019"></a>00019 <span class="comment"> *</span>
  52. <a name="l00020"></a>00020 <span class="comment"> * Redistribution and use in source and binary forms, with or without</span>
  53. <a name="l00021"></a>00021 <span class="comment"> * modification, are permitted provided that the following conditions</span>
  54. <a name="l00022"></a>00022 <span class="comment"> * are met:</span>
  55. <a name="l00023"></a>00023 <span class="comment"> * 1. Redistributions of source code must retain the above copyright</span>
  56. <a name="l00024"></a>00024 <span class="comment"> * notice, this list of conditions and the following disclaimer.</span>
  57. <a name="l00025"></a>00025 <span class="comment"> * 2. Redistributions in binary form must reproduce the above</span>
  58. <a name="l00026"></a>00026 <span class="comment"> * copyright notice, this list of conditions and the following</span>
  59. <a name="l00027"></a>00027 <span class="comment"> * disclaimer in the documentation and/or other materials provided</span>
  60. <a name="l00028"></a>00028 <span class="comment"> * with the distribution.</span>
  61. <a name="l00029"></a>00029 <span class="comment"> * 3. The name of the author may not be used to endorse or promote</span>
  62. <a name="l00030"></a>00030 <span class="comment"> * products derived from this software without specific prior</span>
  63. <a name="l00031"></a>00031 <span class="comment"> * written permission.</span>
  64. <a name="l00032"></a>00032 <span class="comment"> *</span>
  65. <a name="l00033"></a>00033 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS&apos;&apos; AND ANY EXPRESS</span>
  66. <a name="l00034"></a>00034 <span class="comment"> * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED</span>
  67. <a name="l00035"></a>00035 <span class="comment"> * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span>
  68. <a name="l00036"></a>00036 <span class="comment"> * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY</span>
  69. <a name="l00037"></a>00037 <span class="comment"> * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL</span>
  70. <a name="l00038"></a>00038 <span class="comment"> * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE</span>
  71. <a name="l00039"></a>00039 <span class="comment"> * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS</span>
  72. <a name="l00040"></a>00040 <span class="comment"> * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,</span>
  73. <a name="l00041"></a>00041 <span class="comment"> * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING</span>
  74. <a name="l00042"></a>00042 <span class="comment"> * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS</span>
  75. <a name="l00043"></a>00043 <span class="comment"> * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
  76. <a name="l00044"></a>00044 <span class="comment"> *</span>
  77. <a name="l00045"></a>00045 <span class="comment"> * This file is part of the Contiki operating system.</span>
  78. <a name="l00046"></a>00046 <span class="comment"> *</span>
  79. <a name="l00047"></a>00047 <span class="comment"> * $Id: ctk.c,v 1.26 2010/09/09 20:21:26 oliverschmidt Exp $</span>
  80. <a name="l00048"></a>00048 <span class="comment"> *</span>
  81. <a name="l00049"></a>00049 <span class="comment"> */</span>
  82. <a name="l00050"></a>00050
  83. <a name="l00051"></a>00051 <span class="preprocessor">#include &lt;string.h&gt;</span>
  84. <a name="l00052"></a>00052
  85. <a name="l00053"></a>00053 <span class="preprocessor">#include &quot;contiki.h&quot;</span>
  86. <a name="l00054"></a>00054
  87. <a name="l00055"></a>00055 <span class="preprocessor">#include &quot;<a class="code" href="a00142.html" title="CTK header file.">ctk/ctk.h</a>&quot;</span>
  88. <a name="l00056"></a>00056 <span class="preprocessor">#include &quot;<a class="code" href="a00134.html" title="CTK screen drawing module interface, ctk-draw.">ctk/ctk-draw.h</a>&quot;</span>
  89. <a name="l00057"></a>00057 <span class="preprocessor">#include &quot;ctk/ctk-mouse.h&quot;</span>
  90. <a name="l00058"></a>00058
  91. <a name="l00059"></a>00059 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> height, width;
  92. <a name="l00060"></a>00060
  93. <a name="l00061"></a>00061 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> mode;
  94. <a name="l00062"></a>00062
  95. <a name="l00063"></a>00063 <span class="preprocessor">#if CTK_CONF_WINDOWS</span>
  96. <a name="l00064"></a>00064 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keyword">struct </span><a class="code" href="a00038.html" title="Representation of a CTK window.">ctk_window</a> desktop_window;
  97. <a name="l00065"></a>00065 <span class="keyword">static</span> <span class="keyword">struct </span><a class="code" href="a00038.html" title="Representation of a CTK window.">ctk_window</a> *windows;
  98. <a name="l00066"></a>00066 <span class="keyword">static</span> <span class="keyword">struct </span><a class="code" href="a00038.html" title="Representation of a CTK window.">ctk_window</a> *dialog;
  99. <a name="l00067"></a>00067 <span class="preprocessor">#else </span><span class="comment">/* CTK_CONF_WINDOWS */</span>
  100. <a name="l00068"></a>00068 <span class="keyword">static</span> <span class="keyword">struct </span><a class="code" href="a00038.html" title="Representation of a CTK window.">ctk_window</a> *window;
  101. <a name="l00069"></a>00069 <span class="preprocessor">#endif </span><span class="comment">/* CTK_CONF_WINDOWS */</span>
  102. <a name="l00070"></a>00070
  103. <a name="l00071"></a>00071 <span class="preprocessor">#if CTK_CONF_MENUS</span>
  104. <a name="l00072"></a>00072 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keyword">struct </span><a class="code" href="a00035.html" title="Representation of the menu bar.">ctk_menus</a> <a class="code" href="a00035.html#a3107c61dcb9ef9256a0a4052c4c21351" title="A pointer to a linked list of all menus, including the open menu and the desktop...">menus</a>;
  105. <a name="l00073"></a>00073 <span class="keyword">static</span> <span class="keyword">struct </span><a class="code" href="a00033.html" title="Representation of an individual menu.">ctk_menu</a> *lastmenu;
  106. <a name="l00074"></a>00074 <span class="keyword">static</span> <span class="keyword">struct </span><a class="code" href="a00033.html" title="Representation of an individual menu.">ctk_menu</a> desktopmenu;
  107. <a name="l00075"></a>00075 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> maxnitems;
  108. <a name="l00076"></a>00076 <span class="preprocessor">#endif </span><span class="comment">/* CTK_CONF_MENUS */</span>
  109. <a name="l00077"></a>00077
  110. <a name="l00078"></a>00078 <span class="preprocessor">#ifndef NULL</span>
  111. <a name="l00079"></a>00079 <span class="preprocessor"></span><span class="preprocessor">#define NULL (void *)0</span>
  112. <a name="l00080"></a>00080 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* NULL */</span>
  113. <a name="l00081"></a>00081
  114. <a name="l00082"></a>00082 <span class="preprocessor">#define REDRAW_NONE 0</span>
  115. <a name="l00083"></a>00083 <span class="preprocessor"></span><span class="preprocessor">#define REDRAW_ALL 1</span>
  116. <a name="l00084"></a>00084 <span class="preprocessor"></span><span class="preprocessor">#define REDRAW_FOCUS 2</span>
  117. <a name="l00085"></a>00085 <span class="preprocessor"></span><span class="preprocessor">#define REDRAW_WIDGETS 4</span>
  118. <a name="l00086"></a>00086 <span class="preprocessor"></span><span class="preprocessor">#define REDRAW_MENUS 8</span>
  119. <a name="l00087"></a>00087 <span class="preprocessor"></span><span class="preprocessor">#define REDRAW_MENUPART 16</span>
  120. <a name="l00088"></a>00088 <span class="preprocessor"></span>
  121. <a name="l00089"></a>00089 <span class="preprocessor">#define MAX_REDRAWWIDGETS 4</span>
  122. <a name="l00090"></a>00090 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> redraw;
  123. <a name="l00091"></a>00091 <span class="keyword">static</span> <span class="keyword">struct </span><a class="code" href="a00036.html" title="The generic CTK widget structure that contains all other widget structures.">ctk_widget</a> *redraw_widgets[MAX_REDRAWWIDGETS];
  124. <a name="l00092"></a>00092 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> redraw_widgetptr;
  125. <a name="l00093"></a>00093
  126. <a name="l00094"></a>00094 <span class="preprocessor">#if CTK_CONF_ICONS</span>
  127. <a name="l00095"></a>00095 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> iconx, icony;
  128. <a name="l00096"></a>00096 <span class="preprocessor">#define ICONX_START (width - 6)</span>
  129. <a name="l00097"></a>00097 <span class="preprocessor"></span><span class="preprocessor">#define ICONY_START (height - 6 - CTK_CONF_MENUS)</span>
  130. <a name="l00098"></a>00098 <span class="preprocessor"></span><span class="preprocessor">#define ICONX_DELTA -16</span>
  131. <a name="l00099"></a>00099 <span class="preprocessor"></span><span class="preprocessor">#define ICONY_DELTA -5</span>
  132. <a name="l00100"></a>00100 <span class="preprocessor"></span><span class="preprocessor">#define ICONY_MAX height</span>
  133. <a name="l00101"></a>00101 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* CTK_CONF_ICONS */</span>
  134. <a name="l00102"></a>00102
  135. <a name="l00103"></a>00103 <span class="preprocessor">#ifndef ctk_arch_keyavail</span>
  136. <a name="l00104"></a>00104 <span class="preprocessor"></span><span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="a00020.html#ga54b6b0ef960adb9dd53af7c5b1af0968" title="Check if there is a keypress in the keyboard input queue.">ctk_arch_keyavail</a>(<span class="keywordtype">void</span>);
  137. <a name="l00105"></a>00105 <span class="preprocessor">#endif </span><span class="comment">/* ctk_arch_keyavail */</span>
  138. <a name="l00106"></a>00106
  139. <a name="l00107"></a>00107 <span class="preprocessor">#ifndef ctk_arch_getkey</span>
  140. <a name="l00108"></a>00108 <span class="preprocessor"></span><a class="code" href="a00020.html#gaa6eb41324497b3d828d208c0efa6fa90" title="The keyboard character type of the system.">ctk_arch_key_t</a> <a class="code" href="a00020.html#gaba3ae4d2b9baa5953b47eeef61927398" title="Get a keypress from the keyboard input queue.">ctk_arch_getkey</a>(<span class="keywordtype">void</span>);
  141. <a name="l00109"></a>00109 <span class="preprocessor">#endif </span><span class="comment">/* ctk_arch_getkey */</span>
  142. <a name="l00110"></a>00110
  143. <a name="l00111"></a>00111 <span class="preprocessor">#ifndef ctk_arch_isprint</span>
  144. <a name="l00112"></a>00112 <span class="preprocessor"></span><span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> ctk_arch_isprint(<a class="code" href="a00020.html#gaa6eb41324497b3d828d208c0efa6fa90" title="The keyboard character type of the system.">ctk_arch_key_t</a> key);
  145. <a name="l00113"></a>00113 <span class="preprocessor">#endif </span><span class="comment">/* ctk_arch_isprint */</span>
  146. <a name="l00114"></a>00114
  147. <a name="l00115"></a>00115 <a class="code" href="a01627.html#ga27e9b6fc13f0438e37a198f69b38b4cf" title="Declare a process.">PROCESS</a>(ctk_process, <span class="stringliteral">&quot;CTK Contiki GUI&quot;</span>);
  148. <a name="l00116"></a>00116 <span class="comment"></span>
  149. <a name="l00117"></a>00117 <span class="comment">/**</span>
  150. <a name="l00118"></a>00118 <span class="comment"> * \defgroup ctkevents CTK events</span>
  151. <a name="l00119"></a>00119 <span class="comment"> * @{</span>
  152. <a name="l00120"></a>00120 <span class="comment"> */</span>
  153. <a name="l00121"></a>00121 process_event_t
  154. <a name="l00122"></a>00122 <span class="comment"></span>
  155. <a name="l00123"></a>00123 <span class="comment"> /**</span>
  156. <a name="l00124"></a>00124 <span class="comment"> * Emitted for every key being pressed.</span>
  157. <a name="l00125"></a>00125 <span class="comment"> *</span>
  158. <a name="l00126"></a>00126 <span class="comment"> * The key is passed as signal data.*/</span>
  159. <a name="l00127"></a><a class="code" href="a01551.html#ga6d9f0f4b1f9361038433a4201fa1959e">00127</a> <a class="code" href="a01550.html#ga516fdcf33758900be278d0e448635b9d" title="Emitted for every key being pressed.">ctk_signal_keypress</a>,
  160. <a name="l00128"></a>00128 <span class="comment"></span>
  161. <a name="l00129"></a>00129 <span class="comment"> /** Emitted when a widget is activated (pressed). A pointer to the</span>
  162. <a name="l00130"></a>00130 <span class="comment"> widget is passed as signal data. */</span>
  163. <a name="l00131"></a>00131 <a class="code" href="a01550.html#gaf2f104ce01e5e229f9eba8e2f367c591" title="Emitted when a widget is activated (pressed).">ctk_signal_widget_activate</a>,
  164. <a name="l00132"></a>00132 <span class="comment"></span>
  165. <a name="l00133"></a>00133 <span class="comment"> /** Same as ctk_signal_widget_activate. */</span>
  166. <a name="l00134"></a>00134 <a class="code" href="a01550.html#ga73b4f7cc9f9fd72c23ea9b24b3492e01" title="Same as ctk_signal_widget_activate.">ctk_signal_button_activate</a>,
  167. <a name="l00135"></a>00135 <span class="comment"></span>
  168. <a name="l00136"></a>00136 <span class="comment"> /** Emitted when a widget is selected. A pointer to the widget is</span>
  169. <a name="l00137"></a>00137 <span class="comment"> passed as signal data. */</span>
  170. <a name="l00138"></a>00138 <a class="code" href="a01550.html#ga84a8111d8df809f10e8ad81bc47edc3a" title="Emitted when a widget is selected.">ctk_signal_widget_select</a>,
  171. <a name="l00139"></a>00139 <span class="comment"></span>
  172. <a name="l00140"></a>00140 <span class="comment"> /** Same as ctk_signal_widget_select. */</span>
  173. <a name="l00141"></a>00141 <a class="code" href="a01550.html#ga18b0bcdb7d4ba13f8f692ffd8d54a690" title="Same as ctk_signal_widget_select.">ctk_signal_button_hover</a>,
  174. <a name="l00142"></a>00142 <span class="comment"></span>
  175. <a name="l00143"></a>00143 <span class="comment"> /** Emitted when a hyperlink is activated. The signal is broadcast</span>
  176. <a name="l00144"></a>00144 <span class="comment"> to all listeners. */</span>
  177. <a name="l00145"></a>00145 <a class="code" href="a01550.html#gab927db233b2469345094ba7b9e1c769a" title="Emitted when a hyperlink is activated.">ctk_signal_hyperlink_activate</a>,
  178. <a name="l00146"></a>00146 <span class="comment"></span>
  179. <a name="l00147"></a>00147 <span class="comment"> /** Same as ctk_signal_widget_select. */</span>
  180. <a name="l00148"></a>00148 <a class="code" href="a01550.html#ga9e08a17ead01c3ae4ac4e96b40cae885" title="Same as ctk_signal_widget_select.">ctk_signal_hyperlink_hover</a>;
  181. <a name="l00149"></a>00149 <span class="comment"></span>
  182. <a name="l00150"></a>00150 <span class="comment"> /** Emitted when a menu item is activated. The number of the menu</span>
  183. <a name="l00151"></a>00151 <span class="comment"> item is passed as signal data. */</span>
  184. <a name="l00152"></a><a class="code" href="a01551.html#gab42f0dd069d79854b05a7da8390b8e6f">00152</a> process_event_t <a class="code" href="a01550.html#gaa56be046241082d23581812190f2bef5" title="Emitted when a menu item is activated.">ctk_signal_menu_activate</a>;
  185. <a name="l00153"></a>00153 <span class="comment"></span>
  186. <a name="l00154"></a>00154 <span class="comment"> /** Emitted when a window is closed. A pointer to the window is</span>
  187. <a name="l00155"></a>00155 <span class="comment"> passed as signal data. */</span>
  188. <a name="l00156"></a><a class="code" href="a01551.html#ga8d7e716617b14bdd39c9bc3580c9cf4f">00156</a> process_event_t <a class="code" href="a01550.html#gab92e76646299dbab7216ab1f9dcef9e5" title="Emitted when a window is closed.">ctk_signal_window_close</a>;
  189. <a name="l00157"></a>00157
  190. <a name="l00158"></a>00158 <span class="preprocessor">#if CTK_CONF_MOUSE_SUPPORT</span>
  191. <a name="l00159"></a>00159 <span class="preprocessor"></span><span class="comment"> /** Emitted when the mouse pointer is moved. A NULL pointer is</span>
  192. <a name="l00160"></a>00160 <span class="comment"> passed as signal data and it is up to the listening process to</span>
  193. <a name="l00161"></a>00161 <span class="comment"> check the position of the mouse using the CTK mouse API.*/</span>
  194. <a name="l00162"></a>00162 process_event_t ctk_signal_pointer_move,<span class="comment"></span>
  195. <a name="l00163"></a>00163 <span class="comment"> /** Emitted when a mouse button is pressed. The button is passed as</span>
  196. <a name="l00164"></a>00164 <span class="comment"> signal data to the listening process. */</span>
  197. <a name="l00165"></a>00165 ctk_signal_pointer_button;
  198. <a name="l00166"></a>00166 <span class="preprocessor">#endif </span><span class="comment">/* CTK_CONF_MOUSE_SUPPORT */</span>
  199. <a name="l00167"></a>00167
  200. <a name="l00168"></a>00168 <span class="preprocessor">#if CTK_CONF_SCREENSAVER</span>
  201. <a name="l00169"></a>00169 <span class="preprocessor"></span><span class="comment">/** Emitted when the user has been idle long enough for the</span>
  202. <a name="l00170"></a>00170 <span class="comment"> screensaver to start. */</span>
  203. <a name="l00171"></a>00171 process_event_t ctk_signal_screensaver_stop,<span class="comment"></span>
  204. <a name="l00172"></a>00172 <span class="comment"> /** Emitted when the user presses a key or moves the mouse when the</span>
  205. <a name="l00173"></a>00173 <span class="comment"> screensaver is active. */</span>
  206. <a name="l00174"></a>00174 ctk_signal_screensaver_start;
  207. <a name="l00175"></a>00175 <span class="preprocessor">#endif </span><span class="comment">/* CTK_CONF_SCREENSAVER */</span>
  208. <a name="l00176"></a>00176 <span class="comment"></span>
  209. <a name="l00177"></a>00177 <span class="comment">/** @} */</span>
  210. <a name="l00178"></a>00178
  211. <a name="l00179"></a>00179 <span class="preprocessor">#if CTK_CONF_MOUSE_SUPPORT</span>
  212. <a name="l00180"></a>00180 <span class="preprocessor"></span><span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> mouse_x, mouse_y, mouse_button;
  213. <a name="l00181"></a>00181 <span class="preprocessor">#endif </span><span class="comment">/* CTK_CONF_MOUSE_SUPPORT */</span>
  214. <a name="l00182"></a>00182
  215. <a name="l00183"></a>00183 <span class="preprocessor">#if CTK_CONF_SCREENSAVER</span>
  216. <a name="l00184"></a>00184 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> screensaver_timer = 0;
  217. <a name="l00185"></a>00185 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> ctk_screensaver_timeout = (5*60);
  218. <a name="l00186"></a>00186 <span class="keyword">static</span> <span class="keyword">struct </span><a class="code" href="a00086.html" title="A timer.">timer</a> <a class="code" href="a00086.html" title="A timer.">timer</a>;
  219. <a name="l00187"></a>00187 <span class="preprocessor">#endif </span><span class="comment">/* CTK_CONF_SCREENSAVER */</span>
  220. <a name="l00188"></a>00188
  221. <a name="l00189"></a>00189 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="a00436.html#ab81105e5bb440a5f17579e7abf3415f5" title="Configure if the C compiler supports fastcall function declarations.">CC_FASTCALL</a>
  222. <a name="l00190"></a>00190 textentry_input(<a class="code" href="a00020.html#gaa6eb41324497b3d828d208c0efa6fa90" title="The keyboard character type of the system.">ctk_arch_key_t</a> c,
  223. <a name="l00191"></a>00191 <a class="code" href="a00436.html#a556f2735307ab9c1272eae4e2f891012" title="Configure if the C compiler supports the &amp;quot;register&amp;quot; keyword for function...">CC_REGISTER_ARG</a> <span class="keyword">struct</span> ctk_textentry *t);
  224. <a name="l00192"></a>00192
  225. <a name="l00193"></a>00193 <span class="preprocessor">#if CTK_CONF_MENUS</span>
  226. <a name="l00194"></a>00194 <span class="preprocessor"></span><span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
  227. <a name="l00195"></a>00195 <span class="comment">/**</span>
  228. <a name="l00196"></a>00196 <span class="comment"> * \internal Creates the Desktop menu.</span>
  229. <a name="l00197"></a>00197 <span class="comment"> *</span>
  230. <a name="l00198"></a>00198 <span class="comment"> * Creates the leftmost menu, &quot;Desktop&quot;. Since the desktop menu</span>
  231. <a name="l00199"></a>00199 <span class="comment"> * contains the list of all open windows, this function will be called</span>
  232. <a name="l00200"></a>00200 <span class="comment"> * whenever a window is opened or closed.</span>
  233. <a name="l00201"></a>00201 <span class="comment"> */</span>
  234. <a name="l00202"></a>00202 <span class="comment">/*---------------------------------------------------------------------------*/</span>
  235. <a name="l00203"></a>00203 <span class="keyword">static</span> <span class="keywordtype">void</span>
  236. <a name="l00204"></a>00204 make_desktopmenu(<span class="keywordtype">void</span>)
  237. <a name="l00205"></a>00205 {
  238. <a name="l00206"></a>00206 <span class="keyword">struct </span><a class="code" href="a00038.html" title="Representation of a CTK window.">ctk_window</a> *<a class="code" href="a00038.html#ae28cceb9e11fde55afc3abe1c29688b8" title="The width of the window, excluding window borders.">w</a>;
  239. <a name="l00207"></a>00207
  240. <a name="l00208"></a>00208 desktopmenu.nitems = 0;
  241. <a name="l00209"></a>00209
  242. <a name="l00210"></a>00210 <span class="keywordflow">if</span>(windows == NULL) {
  243. <a name="l00211"></a>00211 <a class="code" href="a01551.html#gaaa8b54ce437af6b62eea13012ef6b83c" title="Adds a menu item to a menu.">ctk_menuitem_add</a>(&amp;desktopmenu, <span class="stringliteral">&quot;(No windows)&quot;</span>);
  244. <a name="l00212"></a>00212 } <span class="keywordflow">else</span> {
  245. <a name="l00213"></a>00213 <span class="keywordflow">for</span>(w = windows; w != NULL; w = w-&gt;<a class="code" href="a00038.html#a92e81d0f1ffd6a52ce0fa29caedaca3c" title="The next window in the doubly linked list of open windows.">next</a>) {
  246. <a name="l00214"></a>00214 <a class="code" href="a01551.html#gaaa8b54ce437af6b62eea13012ef6b83c" title="Adds a menu item to a menu.">ctk_menuitem_add</a>(&amp;desktopmenu, w-&gt;<a class="code" href="a00038.html#a88d87bdebfbac969714162a150325eb9" title="The title of the window.">title</a>);
  247. <a name="l00215"></a>00215 }
  248. <a name="l00216"></a>00216 }
  249. <a name="l00217"></a>00217 }
  250. <a name="l00218"></a>00218 <span class="preprocessor">#endif </span><span class="comment">/* CTK_CONF_MENUS */</span>
  251. <a name="l00219"></a>00219 <span class="comment">/*---------------------------------------------------------------------------*/</span>
  252. <a name="l00220"></a>00220 <span class="preprocessor">#if CTK_CONF_ICONS</span>
  253. <a name="l00221"></a>00221 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keywordtype">void</span>
  254. <a name="l00222"></a>00222 arrange_icons(<span class="keywordtype">void</span>)
  255. <a name="l00223"></a>00223 {
  256. <a name="l00224"></a>00224 <span class="keyword">struct </span><a class="code" href="a00036.html" title="The generic CTK widget structure that contains all other widget structures.">ctk_widget</a> *icon;
  257. <a name="l00225"></a>00225
  258. <a name="l00226"></a>00226 iconx = ICONX_START;
  259. <a name="l00227"></a>00227 icony = ICONY_START;
  260. <a name="l00228"></a>00228
  261. <a name="l00229"></a>00229 <span class="keywordflow">for</span>(icon = desktop_window.active; icon != NULL; icon = icon-&gt;<a class="code" href="a00036.html#a3621ec9de98f2b90ec42cb2833d88423" title="The next widget in the linked list of widgets that is contained in the ctk_window...">next</a>) {
  262. <a name="l00230"></a>00230
  263. <a name="l00231"></a>00231 icon-&gt;<a class="code" href="a00036.html#a58125a019e53600eae696dac334c6b82" title="The x position of the widget within the containing window, in character coordinates...">x</a> = iconx;
  264. <a name="l00232"></a>00232 icon-&gt;<a class="code" href="a00036.html#a64d6f0d7568e491e7f5cd0d38f40d1af" title="The y position of the widget within the containing window, in character coordinates...">y</a> = icony;
  265. <a name="l00233"></a>00233
  266. <a name="l00234"></a>00234 icony += ICONY_DELTA;
  267. <a name="l00235"></a>00235 <span class="keywordflow">if</span>(icony &gt;= ICONY_MAX) {
  268. <a name="l00236"></a>00236 icony = ICONY_START;
  269. <a name="l00237"></a>00237 iconx += ICONX_DELTA;
  270. <a name="l00238"></a>00238 }
  271. <a name="l00239"></a>00239 }
  272. <a name="l00240"></a>00240 }
  273. <a name="l00241"></a>00241 <span class="preprocessor">#endif </span><span class="comment">/* CTK_CONF_ICONS */</span>
  274. <a name="l00242"></a>00242 <span class="comment">/*---------------------------------------------------------------------------*/</span>
  275. <a name="l00243"></a>00243 <span class="keywordtype">void</span>
  276. <a name="l00244"></a>00244 ctk_restore(<span class="keywordtype">void</span>)
  277. <a name="l00245"></a>00245 {
  278. <a name="l00246"></a>00246 <a class="code" href="a00020.html#ga271a33b474a94da63244e94c84127303" title="The initialization function.">ctk_draw_init</a>();
  279. <a name="l00247"></a>00247
  280. <a name="l00248"></a>00248 height = ctk_draw_height();
  281. <a name="l00249"></a>00249 width = ctk_draw_width();
  282. <a name="l00250"></a>00250
  283. <a name="l00251"></a>00251 <span class="preprocessor">#if CTK_CONF_ICONS</span>
  284. <a name="l00252"></a>00252 <span class="preprocessor"></span> arrange_icons();
  285. <a name="l00253"></a>00253 <span class="preprocessor">#endif </span><span class="comment">/* CTK_CONF_ICONS */</span>
  286. <a name="l00254"></a>00254
  287. <a name="l00255"></a>00255 redraw = REDRAW_ALL;
  288. <a name="l00256"></a>00256 }
  289. <a name="l00257"></a>00257 <span class="comment">/*---------------------------------------------------------------------------*/</span>
  290. <a name="l00258"></a>00258 <span class="comment"></span>
  291. <a name="l00259"></a>00259 <span class="comment">/**</span>
  292. <a name="l00260"></a>00260 <span class="comment"> * \addtogroup ctkappfunc</span>
  293. <a name="l00261"></a>00261 <span class="comment"> * @{</span>
  294. <a name="l00262"></a>00262 <span class="comment"> */</span>
  295. <a name="l00263"></a>00263
  296. <a name="l00264"></a>00264 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
  297. <a name="l00265"></a>00265 <span class="comment">/**</span>
  298. <a name="l00266"></a>00266 <span class="comment"> * Sets the current CTK mode.</span>
  299. <a name="l00267"></a>00267 <span class="comment"> *</span>
  300. <a name="l00268"></a>00268 <span class="comment"> * The CTK mode can be either CTK_MODE_NORMAL, CTK_MODE_SCREENSAVER or</span>
  301. <a name="l00269"></a>00269 <span class="comment"> * CTK_MODE_EXTERNAL. CTK_MODE_NORMAL is the normal mode, in which</span>
  302. <a name="l00270"></a>00270 <span class="comment"> * keypresses and mouse pointer movements are processed and the screen</span>
  303. <a name="l00271"></a>00271 <span class="comment"> * is redrawn. In CTK_MODE_SCREENSAVER, no screen redraws are</span>
  304. <a name="l00272"></a>00272 <span class="comment"> * performed and the first key press or pointer movement will cause</span>
  305. <a name="l00273"></a>00273 <span class="comment"> * the ctk_signal_screensaver_stop to be emitted. In the</span>
  306. <a name="l00274"></a>00274 <span class="comment"> * CTK_MODE_EXTERNAL mode, key presses and pointer movements are</span>
  307. <a name="l00275"></a>00275 <span class="comment"> * ignored and no screen redraws are made.</span>
  308. <a name="l00276"></a>00276 <span class="comment"> *</span>
  309. <a name="l00277"></a>00277 <span class="comment"> * \param m The mode.</span>
  310. <a name="l00278"></a>00278 <span class="comment"> */</span>
  311. <a name="l00279"></a>00279 <span class="comment">/*---------------------------------------------------------------------------*/</span>
  312. <a name="l00280"></a>00280 <span class="keywordtype">void</span>
  313. <a name="l00281"></a><a class="code" href="a01549.html#ga076ec13a5d4d6f0eec67e885278180c2">00281</a> <a class="code" href="a01551.html#ga3ccdff3684bb5a499cafd4baa184a10e" title="Sets the current CTK mode.">ctk_mode_set</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> m) {
  314. <a name="l00282"></a>00282 mode = m;
  315. <a name="l00283"></a>00283 }
  316. <a name="l00284"></a>00284 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
  317. <a name="l00285"></a>00285 <span class="comment">/**</span>
  318. <a name="l00286"></a>00286 <span class="comment"> * Retrieves the current CTK mode.</span>
  319. <a name="l00287"></a>00287 <span class="comment"> *</span>
  320. <a name="l00288"></a>00288 <span class="comment"> * \return The current CTK mode.</span>
  321. <a name="l00289"></a>00289 <span class="comment"> */</span>
  322. <a name="l00290"></a>00290 <span class="comment">/*---------------------------------------------------------------------------*/</span>
  323. <a name="l00291"></a>00291 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>
  324. <a name="l00292"></a><a class="code" href="a01549.html#ga26d7427d7f920ce4e3293f1a8dd959f3">00292</a> <a class="code" href="a01551.html#ga26d7427d7f920ce4e3293f1a8dd959f3" title="Retrieves the current CTK mode.">ctk_mode_get</a>(<span class="keywordtype">void</span>) {
  325. <a name="l00293"></a>00293 <span class="keywordflow">return</span> mode;
  326. <a name="l00294"></a>00294 }
  327. <a name="l00295"></a>00295 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
  328. <a name="l00296"></a>00296 <span class="comment">/**</span>
  329. <a name="l00297"></a>00297 <span class="comment"> * Add an icon to the desktop.</span>
  330. <a name="l00298"></a>00298 <span class="comment"> *</span>
  331. <a name="l00299"></a>00299 <span class="comment"> * \param icon The icon to be added.</span>
  332. <a name="l00300"></a>00300 <span class="comment"> *</span>
  333. <a name="l00301"></a>00301 <span class="comment"> * \param p The process that owns the icon.</span>
  334. <a name="l00302"></a>00302 <span class="comment"> */</span>
  335. <a name="l00303"></a>00303 <span class="comment">/*---------------------------------------------------------------------------*/</span>
  336. <a name="l00304"></a>00304 <span class="keywordtype">void</span>
  337. <a name="l00305"></a><a class="code" href="a01551.html#gafd7f717de0f57e23d03c13497b41efe4">00305</a> <a class="code" href="a01551.html#gafd7f717de0f57e23d03c13497b41efe4" title="Add an icon to the desktop.">ctk_icon_add</a>(<a class="code" href="a00436.html#a556f2735307ab9c1272eae4e2f891012" title="Configure if the C compiler supports the &amp;quot;register&amp;quot; keyword for function...">CC_REGISTER_ARG</a> <span class="keyword">struct</span> <a class="code" href="a00036.html" title="The generic CTK widget structure that contains all other widget structures.">ctk_widget</a> *icon, <span class="keyword">struct</span> process *p)
  338. <a name="l00306"></a>00306 {
  339. <a name="l00307"></a>00307 <span class="preprocessor">#if CTK_CONF_ICONS</span>
  340. <a name="l00308"></a>00308 <span class="preprocessor"></span> icon-&gt;widget.icon.owner = p;
  341. <a name="l00309"></a>00309 <a class="code" href="a01551.html#gafdd6e4493fc97e7051d39ea806ee280f" title="Adds a widget to a window.">ctk_widget_add</a>(&amp;desktop_window, icon);
  342. <a name="l00310"></a>00310 arrange_icons();
  343. <a name="l00311"></a>00311 <span class="preprocessor">#endif </span><span class="comment">/* CTK_CONF_ICONS */</span>
  344. <a name="l00312"></a>00312 }
  345. <a name="l00313"></a>00313 <span class="preprocessor">#if CTK_CONF_WINDOWS</span>
  346. <a name="l00314"></a>00314 <span class="preprocessor"></span><span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
  347. <a name="l00315"></a>00315 <span class="comment">/**</span>
  348. <a name="l00316"></a>00316 <span class="comment"> * Open a dialog box.</span>
  349. <a name="l00317"></a>00317 <span class="comment"> *</span>
  350. <a name="l00318"></a>00318 <span class="comment"> * \param d The dialog to be opened.</span>
  351. <a name="l00319"></a>00319 <span class="comment"> */</span>
  352. <a name="l00320"></a>00320 <span class="comment">/*---------------------------------------------------------------------------*/</span>
  353. <a name="l00321"></a>00321 <span class="keywordtype">void</span>
  354. <a name="l00322"></a>00322 ctk_dialog_open(<span class="keyword">struct</span> <a class="code" href="a00038.html" title="Representation of a CTK window.">ctk_window</a> *d)
  355. <a name="l00323"></a>00323 {
  356. <a name="l00324"></a>00324 dialog = d;
  357. <a name="l00325"></a>00325 redraw |= REDRAW_FOCUS;
  358. <a name="l00326"></a>00326 }
  359. <a name="l00327"></a>00327 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
  360. <a name="l00328"></a>00328 <span class="comment">/**</span>
  361. <a name="l00329"></a>00329 <span class="comment"> * Close the dialog box, if one is open.</span>
  362. <a name="l00330"></a>00330 <span class="comment"> *</span>
  363. <a name="l00331"></a>00331 <span class="comment"> */</span>
  364. <a name="l00332"></a>00332 <span class="comment">/*---------------------------------------------------------------------------*/</span>
  365. <a name="l00333"></a>00333 <span class="keywordtype">void</span>
  366. <a name="l00334"></a>00334 ctk_dialog_close(<span class="keywordtype">void</span>)
  367. <a name="l00335"></a>00335 {
  368. <a name="l00336"></a>00336 dialog = NULL;
  369. <a name="l00337"></a>00337 redraw |= REDRAW_ALL;
  370. <a name="l00338"></a>00338 }
  371. <a name="l00339"></a>00339 <span class="preprocessor">#endif </span><span class="comment">/* CTK_CONF_WINDOWS */</span>
  372. <a name="l00340"></a>00340 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
  373. <a name="l00341"></a>00341 <span class="comment">/**</span>
  374. <a name="l00342"></a>00342 <span class="comment"> * Open a window, or bring window to front if already open.</span>
  375. <a name="l00343"></a>00343 <span class="comment"> *</span>
  376. <a name="l00344"></a>00344 <span class="comment"> * \param w The window to be opened.</span>
  377. <a name="l00345"></a>00345 <span class="comment"> */</span>
  378. <a name="l00346"></a>00346 <span class="comment">/*---------------------------------------------------------------------------*/</span>
  379. <a name="l00347"></a>00347 <span class="keywordtype">void</span>
  380. <a name="l00348"></a><a class="code" href="a01551.html#ga2e85117f2716017f1ceaa83af221740d">00348</a> <a class="code" href="a01551.html#ga2e85117f2716017f1ceaa83af221740d" title="Open a window, or bring window to front if already open.">ctk_window_open</a>(<a class="code" href="a00436.html#a556f2735307ab9c1272eae4e2f891012" title="Configure if the C compiler supports the &amp;quot;register&amp;quot; keyword for function...">CC_REGISTER_ARG</a> <span class="keyword">struct</span> <a class="code" href="a00038.html" title="Representation of a CTK window.">ctk_window</a> *w)
  381. <a name="l00349"></a>00349 {
  382. <a name="l00350"></a>00350 <span class="preprocessor">#if CTK_CONF_WINDOWS</span>
  383. <a name="l00351"></a>00351 <span class="preprocessor"></span> <span class="keyword">struct </span><a class="code" href="a00038.html" title="Representation of a CTK window.">ctk_window</a> *w2;
  384. <a name="l00352"></a>00352
  385. <a name="l00353"></a>00353 <span class="comment">/* Check if already open. */</span>
  386. <a name="l00354"></a>00354 <span class="keywordflow">for</span>(w2 = windows; w2 != w &amp;&amp; w2 != NULL; w2 = w2-&gt;<a class="code" href="a00038.html#a92e81d0f1ffd6a52ce0fa29caedaca3c" title="The next window in the doubly linked list of open windows.">next</a>);
  387. <a name="l00355"></a>00355 <span class="keywordflow">if</span>(w2 == NULL) {
  388. <a name="l00356"></a>00356 <span class="comment">/* Not open, so we add it at the head of the list of open</span>
  389. <a name="l00357"></a>00357 <span class="comment"> windows. */</span>
  390. <a name="l00358"></a>00358 w-&gt;next = windows;
  391. <a name="l00359"></a>00359 <span class="keywordflow">if</span>(windows != NULL) {
  392. <a name="l00360"></a>00360 windows-&gt;<a class="code" href="a00038.html#a5c2fbd8367afa325aaf22c6bbf3c634f" title="The previous window in the doubly linked list of open windows.">prev</a> = w;
  393. <a name="l00361"></a>00361 }
  394. <a name="l00362"></a>00362 windows = w;
  395. <a name="l00363"></a>00363 w-&gt;<a class="code" href="a00038.html#a5c2fbd8367afa325aaf22c6bbf3c634f" title="The previous window in the doubly linked list of open windows.">prev</a> = NULL;
  396. <a name="l00364"></a>00364 } <span class="keywordflow">else</span> {
  397. <a name="l00365"></a>00365 <span class="comment">/* Window already open, so we move it to the front of the windows</span>
  398. <a name="l00366"></a>00366 <span class="comment"> list. */</span>
  399. <a name="l00367"></a>00367 <span class="keywordflow">if</span>(w != windows) {
  400. <a name="l00368"></a>00368 <span class="keywordflow">if</span>(w-&gt;next != NULL) {
  401. <a name="l00369"></a>00369 w-&gt;next-&gt;prev = w-&gt;prev;
  402. <a name="l00370"></a>00370 }
  403. <a name="l00371"></a>00371 <span class="keywordflow">if</span>(w-&gt;prev != NULL) {
  404. <a name="l00372"></a>00372 w-&gt;prev-&gt;next = w-&gt;next;
  405. <a name="l00373"></a>00373 }
  406. <a name="l00374"></a>00374 w-&gt;next = windows;
  407. <a name="l00375"></a>00375 windows-&gt;<a class="code" href="a00038.html#a5c2fbd8367afa325aaf22c6bbf3c634f" title="The previous window in the doubly linked list of open windows.">prev</a> = w;
  408. <a name="l00376"></a>00376 windows = w;
  409. <a name="l00377"></a>00377 w-&gt;<a class="code" href="a00038.html#a5c2fbd8367afa325aaf22c6bbf3c634f" title="The previous window in the doubly linked list of open windows.">prev</a> = NULL;
  410. <a name="l00378"></a>00378 }
  411. <a name="l00379"></a>00379 }
  412. <a name="l00380"></a>00380 <span class="preprocessor">#else </span><span class="comment">/* CTK_CONF_WINDOWS */</span>
  413. <a name="l00381"></a>00381 window = w;
  414. <a name="l00382"></a>00382 <span class="preprocessor">#endif </span><span class="comment">/* CTK_CONF_WINDOWS */</span>
  415. <a name="l00383"></a>00383
  416. <a name="l00384"></a>00384 <span class="preprocessor">#if CTK_CONF_MENUS</span>
  417. <a name="l00385"></a>00385 <span class="preprocessor"></span> <span class="comment">/* Recreate the Desktop menu&apos;s window entries.*/</span>
  418. <a name="l00386"></a>00386 make_desktopmenu();
  419. <a name="l00387"></a>00387 <span class="preprocessor">#endif </span><span class="comment">/* CTK_CONF_MENUS */</span>
  420. <a name="l00388"></a>00388
  421. <a name="l00389"></a>00389 redraw |= REDRAW_ALL;
  422. <a name="l00390"></a>00390 }
  423. <a name="l00391"></a>00391 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
  424. <a name="l00392"></a>00392 <span class="comment">/**</span>
  425. <a name="l00393"></a>00393 <span class="comment"> * Close a window if it is open.</span>
  426. <a name="l00394"></a>00394 <span class="comment"> *</span>
  427. <a name="l00395"></a>00395 <span class="comment"> * If the window is not open, this function does nothing.</span>
  428. <a name="l00396"></a>00396 <span class="comment"> *</span>
  429. <a name="l00397"></a>00397 <span class="comment"> * \param w The window to be closed.</span>
  430. <a name="l00398"></a>00398 <span class="comment"> */</span>
  431. <a name="l00399"></a>00399 <span class="comment">/*---------------------------------------------------------------------------*/</span>
  432. <a name="l00400"></a>00400 <span class="keywordtype">void</span>
  433. <a name="l00401"></a><a class="code" href="a01549.html#gac6884a9059b5b49128d1c12f222ba13a">00401</a> <a class="code" href="a01551.html#ga6c19434a7d375ada9e59646f0fce3223" title="Close a window if it is open.">ctk_window_close</a>(<span class="keyword">struct</span> <a class="code" href="a00038.html" title="Representation of a CTK window.">ctk_window</a> *w)
  434. <a name="l00402"></a>00402 {
  435. <a name="l00403"></a>00403 <span class="preprocessor">#if CTK_CONF_WINDOWCLOSE</span>
  436. <a name="l00404"></a>00404 <span class="preprocessor"></span> <span class="keyword">static</span> <span class="keyword">struct </span><a class="code" href="a00038.html" title="Representation of a CTK window.">ctk_window</a> *w2;
  437. <a name="l00405"></a>00405
  438. <a name="l00406"></a>00406 <span class="keywordflow">if</span>(w == NULL) {
  439. <a name="l00407"></a>00407 <span class="keywordflow">return</span>;
  440. <a name="l00408"></a>00408 }
  441. <a name="l00409"></a>00409
  442. <a name="l00410"></a>00410 <span class="comment">/* Check if the window to be closed is the first window on the list. */</span>
  443. <a name="l00411"></a>00411 <span class="keywordflow">if</span>(w == windows) {
  444. <a name="l00412"></a>00412 windows = w-&gt;<a class="code" href="a00038.html#a92e81d0f1ffd6a52ce0fa29caedaca3c" title="The next window in the doubly linked list of open windows.">next</a>;
  445. <a name="l00413"></a>00413 <span class="keywordflow">if</span>(windows != NULL) {
  446. <a name="l00414"></a>00414 windows-&gt;<a class="code" href="a00038.html#a5c2fbd8367afa325aaf22c6bbf3c634f" title="The previous window in the doubly linked list of open windows.">prev</a> = NULL;
  447. <a name="l00415"></a>00415 }
  448. <a name="l00416"></a>00416 w-&gt;<a class="code" href="a00038.html#a92e81d0f1ffd6a52ce0fa29caedaca3c" title="The next window in the doubly linked list of open windows.">next</a> = w-&gt;<a class="code" href="a00038.html#a5c2fbd8367afa325aaf22c6bbf3c634f" title="The previous window in the doubly linked list of open windows.">prev</a> = NULL;
  449. <a name="l00417"></a>00417 } <span class="keywordflow">else</span> {
  450. <a name="l00418"></a>00418 <span class="comment">/* Otherwise we step through the list until we find the window</span>
  451. <a name="l00419"></a>00419 <span class="comment"> before the one to be closed. We then redirect its -&gt;next</span>
  452. <a name="l00420"></a>00420 <span class="comment"> pointer and its -&gt;next-&gt;prev. */</span>
  453. <a name="l00421"></a>00421 <span class="keywordflow">for</span>(w2 = windows; w2 != NULL &amp;&amp; w2-&gt;<a class="code" href="a00038.html#a92e81d0f1ffd6a52ce0fa29caedaca3c" title="The next window in the doubly linked list of open windows.">next</a> != w; w2 = w2-&gt;<a class="code" href="a00038.html#a92e81d0f1ffd6a52ce0fa29caedaca3c" title="The next window in the doubly linked list of open windows.">next</a>);
  454. <a name="l00422"></a>00422
  455. <a name="l00423"></a>00423 <span class="keywordflow">if</span>(w2 == NULL) {
  456. <a name="l00424"></a>00424 <span class="comment">/* The window wasn&apos;t open, so there is nothing more for us to do. */</span>
  457. <a name="l00425"></a>00425 <span class="keywordflow">return</span>;
  458. <a name="l00426"></a>00426 }
  459. <a name="l00427"></a>00427
  460. <a name="l00428"></a>00428 <span class="keywordflow">if</span>(w-&gt;<a class="code" href="a00038.html#a92e81d0f1ffd6a52ce0fa29caedaca3c" title="The next window in the doubly linked list of open windows.">next</a> != NULL) {
  461. <a name="l00429"></a>00429 w-&gt;<a class="code" href="a00038.html#a92e81d0f1ffd6a52ce0fa29caedaca3c" title="The next window in the doubly linked list of open windows.">next</a>-&gt;<a class="code" href="a00038.html#a5c2fbd8367afa325aaf22c6bbf3c634f" title="The previous window in the doubly linked list of open windows.">prev</a> = w-&gt;<a class="code" href="a00038.html#a5c2fbd8367afa325aaf22c6bbf3c634f" title="The previous window in the doubly linked list of open windows.">prev</a>;
  462. <a name="l00430"></a>00430 }
  463. <a name="l00431"></a>00431 w2-&gt;<a class="code" href="a00038.html#a92e81d0f1ffd6a52ce0fa29caedaca3c" title="The next window in the doubly linked list of open windows.">next</a> = w-&gt;<a class="code" href="a00038.html#a92e81d0f1ffd6a52ce0fa29caedaca3c" title="The next window in the doubly linked list of open windows.">next</a>;
  464. <a name="l00432"></a>00432
  465. <a name="l00433"></a>00433 w-&gt;<a class="code" href="a00038.html#a92e81d0f1ffd6a52ce0fa29caedaca3c" title="The next window in the doubly linked list of open windows.">next</a> = w-&gt;<a class="code" href="a00038.html#a5c2fbd8367afa325aaf22c6bbf3c634f" title="The previous window in the doubly linked list of open windows.">prev</a> = NULL;
  466. <a name="l00434"></a>00434 }
  467. <a name="l00435"></a>00435
  468. <a name="l00436"></a>00436 <span class="preprocessor">#if CTK_CONF_MENUS</span>
  469. <a name="l00437"></a>00437 <span class="preprocessor"></span> <span class="comment">/* Recreate the Desktop menu&apos;s window entries.*/</span>
  470. <a name="l00438"></a>00438 make_desktopmenu();
  471. <a name="l00439"></a>00439 <span class="preprocessor">#endif </span><span class="comment">/* CTK_CONF_MENUS */</span>
  472. <a name="l00440"></a>00440 redraw |= REDRAW_ALL;
  473. <a name="l00441"></a>00441 <span class="preprocessor">#endif </span><span class="comment">/* CTK_CONF_WINDOWCLOSE */</span>
  474. <a name="l00442"></a>00442 }
  475. <a name="l00443"></a>00443 <span class="preprocessor">#if CTK_CONF_WINDOWS</span>
  476. <a name="l00444"></a>00444 <span class="preprocessor"></span><span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
  477. <a name="l00445"></a>00445 <span class="comment">/**</span>
  478. <a name="l00446"></a>00446 <span class="comment"> * \internal Create the move and close buttons on the window titlebar.</span>
  479. <a name="l00447"></a>00447 <span class="comment"> */</span>
  480. <a name="l00448"></a>00448 <span class="comment">/*---------------------------------------------------------------------------*/</span>
  481. <a name="l00449"></a>00449 <span class="keyword">static</span> <span class="keywordtype">void</span>
  482. <a name="l00450"></a>00450 make_windowbuttons(<a class="code" href="a00436.html#a556f2735307ab9c1272eae4e2f891012" title="Configure if the C compiler supports the &amp;quot;register&amp;quot; keyword for function...">CC_REGISTER_ARG</a> <span class="keyword">struct</span> <a class="code" href="a00038.html" title="Representation of a CTK window.">ctk_window</a> *window)
  483. <a name="l00451"></a>00451 {
  484. <a name="l00452"></a>00452 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> placement;
  485. <a name="l00453"></a>00453
  486. <a name="l00454"></a>00454 <span class="keywordflow">if</span>(ctk_draw_windowtitle_height &gt;= 2) {
  487. <a name="l00455"></a>00455 placement = -1 - ctk_draw_windowtitle_height/2;
  488. <a name="l00456"></a>00456 } <span class="keywordflow">else</span> {
  489. <a name="l00457"></a>00457 placement = -1;
  490. <a name="l00458"></a>00458 }
  491. <a name="l00459"></a>00459 <span class="preprocessor">#if CTK_CONF_WINDOWMOVE</span>
  492. <a name="l00460"></a>00460 <span class="preprocessor"></span> CTK_BUTTON_NEW(&amp;window-&gt;titlebutton, 0, placement,
  493. <a name="l00461"></a>00461 window-&

Large files files are truncated, but you can click here to view the full file