adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 1 | /** |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 2 | * \addtogroup ctk |
| 3 | * @{ |
| 4 | */ |
| 5 | |
| 6 | /** |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 7 | * \file |
| 8 | * CTK header file. |
| 9 | * \author Adam Dunkels <adam@dunkels.com> |
| 10 | * |
| 11 | * The CTK header file contains functioin declarations and definitions |
| 12 | * of CTK structures and macros. |
| 13 | */ |
| 14 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 15 | /* |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 16 | * Copyright (c) 2002-2003, Adam Dunkels. |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 17 | * All rights reserved. |
| 18 | * |
| 19 | * Redistribution and use in source and binary forms, with or without |
| 20 | * modification, are permitted provided that the following conditions |
| 21 | * are met: |
| 22 | * 1. Redistributions of source code must retain the above copyright |
| 23 | * notice, this list of conditions and the following disclaimer. |
| 24 | * 2. Redistributions in binary form must reproduce the above |
| 25 | * copyright notice, this list of conditions and the following |
| 26 | * disclaimer in the documentation and/or other materials provided |
| 27 | * with the distribution. |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 28 | * 3. The name of the author may not be used to endorse or promote |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 29 | * products derived from this software without specific prior |
| 30 | * written permission. |
| 31 | * |
| 32 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS |
| 33 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 35 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 36 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
| 38 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 39 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 40 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 41 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 42 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 43 | * |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 44 | * This file is part of the Contiki desktop OS. |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 45 | * |
oliverschmidt | cd6c30b | 2005-05-05 20:54:16 +0000 | [diff] [blame] | 46 | * $Id: ctk.h,v 1.24 2005/05/05 20:54:16 oliverschmidt Exp $ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 47 | * |
| 48 | */ |
| 49 | |
| 50 | #ifndef __CTK_H__ |
| 51 | #define __CTK_H__ |
| 52 | |
adamdunkels | a6557e4 | 2003-08-11 22:27:51 +0000 | [diff] [blame] | 53 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 54 | #include "ctk-conf.h" |
adamdunkels | a6557e4 | 2003-08-11 22:27:51 +0000 | [diff] [blame] | 55 | #include "ctk-arch.h" |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 56 | #include "ek.h" |
| 57 | |
adamdunkels | 78c03dc | 2003-04-09 13:45:05 +0000 | [diff] [blame] | 58 | #include "cc.h" |
| 59 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 60 | /* Defintions for the CTK widget types. */ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 61 | |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 62 | /** |
| 63 | * \addtogroup ctkdraw |
| 64 | * @{ |
| 65 | */ |
| 66 | |
| 67 | /** Widget number: The CTK separator widget. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 68 | #define CTK_WIDGET_SEPARATOR 1 |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 69 | /** Widget number: The CTK label widget. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 70 | #define CTK_WIDGET_LABEL 2 |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 71 | /** Widget number: The CTK button widget. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 72 | #define CTK_WIDGET_BUTTON 3 |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 73 | /** Widget number: The CTK hyperlink widget. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 74 | #define CTK_WIDGET_HYPERLINK 4 |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 75 | /** Widget number: The CTK textentry widget. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 76 | #define CTK_WIDGET_TEXTENTRY 5 |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 77 | /** Widget number: The CTK bitmap widget. */ |
adamdunkels | 1d5eb5e | 2003-03-28 12:10:39 +0000 | [diff] [blame] | 78 | #define CTK_WIDGET_BITMAP 6 |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 79 | /** Widget number: The CTK icon widget. */ |
adamdunkels | 1d5eb5e | 2003-03-28 12:10:39 +0000 | [diff] [blame] | 80 | #define CTK_WIDGET_ICON 7 |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 81 | |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 82 | /** @} */ |
| 83 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 84 | struct ctk_widget; |
| 85 | |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 86 | #if CTK_CONF_WIDGET_FLAGS |
| 87 | #define CTK_WIDGET_FLAG_INITIALIZER(x) x, |
| 88 | #else |
| 89 | #define CTK_WIDGET_FLAG_INITIALIZER(x) |
| 90 | #endif |
| 91 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 92 | /** |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 93 | * \defgroup ctkappfunc CTK application functions |
| 94 | * @{ |
| 95 | * |
| 96 | * The CTK functions used by an application program. |
| 97 | */ |
| 98 | |
| 99 | /** |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 100 | * Instantiating macro for the ctk_separator widget. |
| 101 | * |
| 102 | * This macro is used when instantiating a ctk_separator widget and is |
| 103 | * intended to be used together with a struct assignment like this: |
| 104 | \code |
| 105 | struct ctk_separator sep = |
| 106 | {CTK_SEPARATOR(0, 0, 23)}; |
| 107 | \endcode |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 108 | * \param x The x position of the widget, relative to the widget's |
| 109 | * window. |
| 110 | * \param y The y position of the widget, relative to the widget's |
| 111 | * window. |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 112 | * \param w The widget's width. |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 113 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 114 | #define CTK_SEPARATOR(x, y, w) \ |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 115 | NULL, NULL, x, y, CTK_WIDGET_SEPARATOR, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 116 | struct ctk_separator { |
| 117 | struct ctk_widget *next; |
| 118 | struct ctk_window *window; |
| 119 | unsigned char x, y; |
| 120 | unsigned char type; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 121 | unsigned char w, h; |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 122 | #if CTK_CONF_WIDGET_FLAGS |
| 123 | unsigned char flags; |
| 124 | #endif /* CTK_CONF_WIDGET_FLAGS */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 125 | }; |
| 126 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 127 | /** |
| 128 | * Instantiating macro for the ctk_button widget. |
| 129 | * |
| 130 | * This macro is used when instantiating a ctk_button widget and is |
| 131 | * intended to be used together with a struct assignment like this: |
| 132 | \code |
| 133 | struct ctk_button but = |
| 134 | {CTK_BUTTON(0, 0, 2, "Ok")}; |
| 135 | \endcode |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 136 | * \param x The x position of the widget, relative to the widget's |
| 137 | * window. |
| 138 | * \param y The y position of the widget, relative to the widget's |
| 139 | * window. |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 140 | * \param w The widget's width. |
| 141 | * \param text The button text. |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 142 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 143 | #define CTK_BUTTON(x, y, w, text) \ |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 144 | NULL, NULL, x, y, CTK_WIDGET_BUTTON, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) text |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 145 | struct ctk_button { |
| 146 | struct ctk_widget *next; |
| 147 | struct ctk_window *window; |
| 148 | unsigned char x, y; |
| 149 | unsigned char type; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 150 | unsigned char w, h; |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 151 | #if CTK_CONF_WIDGET_FLAGS |
| 152 | unsigned char flags; |
| 153 | #endif /* CTK_CONF_WIDGET_FLAGS */ |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame^] | 154 | const char *text; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 155 | }; |
| 156 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 157 | /** |
| 158 | * Instantiating macro for the ctk_label widget. |
| 159 | * |
| 160 | * This macro is used when instantiating a ctk_label widget and is |
| 161 | * intended to be used together with a struct assignment like this: |
| 162 | \code |
| 163 | struct ctk_label lab = |
| 164 | {CTK_LABEL(0, 0, 5, 1, "Label")}; |
| 165 | \endcode |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 166 | * \param x The x position of the widget, relative to the widget's |
| 167 | * window. |
| 168 | * \param y The y position of the widget, relative to the widget's |
| 169 | * window. |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 170 | * \param w The widget's width. |
| 171 | * \param h The height of the label. |
| 172 | * \param text The label text. |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 173 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 174 | #define CTK_LABEL(x, y, w, h, text) \ |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 175 | NULL, NULL, x, y, CTK_WIDGET_LABEL, w, h, CTK_WIDGET_FLAG_INITIALIZER(0) text, |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 176 | struct ctk_label { |
| 177 | struct ctk_widget *next; |
| 178 | struct ctk_window *window; |
| 179 | unsigned char x, y; |
| 180 | unsigned char type; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 181 | unsigned char w, h; |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 182 | #if CTK_CONF_WIDGET_FLAGS |
| 183 | unsigned char flags; |
| 184 | #endif /* CTK_CONF_WIDGET_FLAGS */ |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame^] | 185 | const char *text; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 186 | }; |
| 187 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 188 | /** |
| 189 | * Instantiating macro for the ctk_hyperlink widget. |
| 190 | * |
| 191 | * This macro is used when instantiating a ctk_hyperlink widget and is |
| 192 | * intended to be used together with a struct assignment like this: |
| 193 | \code |
| 194 | struct ctk_hyperlink hlink = |
| 195 | {CTK_HYPERLINK(0, 0, 7, "Contiki", "http://dunkels.com/adam/contiki/")}; |
| 196 | \endcode |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 197 | * \param x The x position of the widget, relative to the widget's |
| 198 | * window. |
| 199 | * \param y The y position of the widget, relative to the widget's |
| 200 | * window. |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 201 | * \param w The widget's width. |
| 202 | * \param text The hyperlink text. |
| 203 | * \param url The hyperlink URL. |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 204 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 205 | #define CTK_HYPERLINK(x, y, w, text, url) \ |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 206 | NULL, NULL, x, y, CTK_WIDGET_HYPERLINK, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) text, url |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 207 | struct ctk_hyperlink { |
| 208 | struct ctk_widget *next; |
| 209 | struct ctk_window *window; |
| 210 | unsigned char x, y; |
| 211 | unsigned char type; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 212 | unsigned char w, h; |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 213 | #if CTK_CONF_WIDGET_FLAGS |
| 214 | unsigned char flags; |
| 215 | #endif /* CTK_CONF_WIDGET_FLAGS */ |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame^] | 216 | const char *text; |
| 217 | const char *url; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 218 | }; |
| 219 | |
| 220 | /* Editing modes of the CTK textentry widget. */ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 221 | #define CTK_TEXTENTRY_NORMAL 0 /**< \internal Textentry state: not |
| 222 | edited. */ |
| 223 | #define CTK_TEXTENTRY_EDIT 1 /**< \internal Textentry state: |
| 224 | currenly being edited. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 225 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 226 | /** |
| 227 | * Clears a text entry widget and sets the cursor to the start of the |
| 228 | * text line. |
| 229 | * |
| 230 | * \param e The text entry widget to be cleared. |
| 231 | */ |
oliverschmidt | cd6c30b | 2005-05-05 20:54:16 +0000 | [diff] [blame] | 232 | #define CTK_TEXTENTRY_CLEAR(e) \ |
| 233 | do { memset((e)->text, 0, (e)->h * ((e)->len + 1)); \ |
| 234 | (e)->xpos = 0; (e)->ypos = 0; } while(0) |
oliverschmidt | 0096f6a | 2005-05-04 21:50:17 +0000 | [diff] [blame] | 235 | |
| 236 | typedef unsigned char (* ctk_textentry_input)(ctk_arch_key_t c, |
| 237 | struct ctk_textentry *t); |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 238 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 239 | /** |
| 240 | * Instantiating macro for the ctk_textentry widget. |
| 241 | * |
| 242 | * This macro is used when instantiating a ctk_textentry widget and is |
| 243 | * intended to be used together with a struct assignment like this: |
| 244 | \code |
| 245 | struct ctk_textentry tentry = |
| 246 | {CTK_TEXTENTRY(0, 0, 30, 1, textbuffer, 50)}; |
| 247 | \endcode |
| 248 | * \note The height of the text entry widget is obsolete and not |
| 249 | * intended to be used. |
| 250 | * |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 251 | * \param x The x position of the widget, relative to the widget's |
| 252 | * window. |
| 253 | * \param y The y position of the widget, relative to the widget's |
| 254 | * window. |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 255 | * \param w The widget's width. |
| 256 | * \param h The text entry height (obsolete). |
| 257 | * \param text A pointer to the buffer that should be edited. |
| 258 | * \param len The length of the text buffer |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 259 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 260 | #define CTK_TEXTENTRY(x, y, w, h, text, len) \ |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 261 | NULL, NULL, x, y, CTK_WIDGET_TEXTENTRY, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) text, len, \ |
oliverschmidt | 0096f6a | 2005-05-04 21:50:17 +0000 | [diff] [blame] | 262 | CTK_TEXTENTRY_NORMAL, 0, 0, NULL |
| 263 | #define CTK_TEXTENTRY_INPUT(x, y, w, h, text, len, input) \ |
| 264 | NULL, NULL, x, y, CTK_WIDGET_TEXTENTRY, w, h, CTK_WIDGET_FLAG_INITIALIZER(0) text, len, \ |
| 265 | CTK_TEXTENTRY_NORMAL, 0, 0, (ctk_textentry_input)input |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 266 | struct ctk_textentry { |
| 267 | struct ctk_widget *next; |
| 268 | struct ctk_window *window; |
| 269 | unsigned char x, y; |
| 270 | unsigned char type; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 271 | unsigned char w, h; |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 272 | #if CTK_CONF_WIDGET_FLAGS |
| 273 | unsigned char flags; |
| 274 | #endif /* CTK_CONF_WIDGET_FLAGS */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 275 | char *text; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 276 | unsigned char len; |
| 277 | unsigned char state; |
| 278 | unsigned char xpos, ypos; |
oliverschmidt | 0096f6a | 2005-05-04 21:50:17 +0000 | [diff] [blame] | 279 | ctk_textentry_input input; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 280 | }; |
| 281 | |
| 282 | |
oliverschmidt | 84b3084 | 2004-06-27 12:32:16 +0000 | [diff] [blame] | 283 | #if CTK_CONF_ICON_BITMAPS |
| 284 | #define CTK_ICON_BITMAP(bitmap) bitmap |
| 285 | #else |
| 286 | #define CTK_ICON_BITMAP(bitmap) NULL |
| 287 | #endif |
| 288 | |
| 289 | #if CTK_CONF_ICON_TEXTMAPS |
| 290 | #define CTK_ICON_TEXTMAP(textmap) textmap |
| 291 | #else |
| 292 | #define CTK_ICON_TEXTMAP(textmap) NULL |
| 293 | #endif |
| 294 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 295 | /** |
| 296 | * Instantiating macro for the ctk_icon widget. |
| 297 | * |
| 298 | * This macro is used when instantiating a ctk_icon widget and is |
| 299 | * intended to be used together with a struct assignment like this: |
| 300 | \code |
| 301 | struct ctk_icon icon = |
| 302 | {CTK_ICON("An icon", bitmapptr, textmapptr)}; |
| 303 | \endcode |
| 304 | * \param title The icon's text. |
| 305 | * \param bitmap A pointer to the icon's bitmap image. |
| 306 | * \param textmap A pointer to the icon's text version of the bitmap. |
| 307 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 308 | #define CTK_ICON(title, bitmap, textmap) \ |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 309 | NULL, NULL, 0, 0, CTK_WIDGET_ICON, 2, 4, CTK_WIDGET_FLAG_INITIALIZER(0) \ |
| 310 | title, EK_ID_NONE, \ |
oliverschmidt | 84b3084 | 2004-06-27 12:32:16 +0000 | [diff] [blame] | 311 | CTK_ICON_BITMAP(bitmap), CTK_ICON_TEXTMAP(textmap) |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 312 | struct ctk_icon { |
| 313 | struct ctk_widget *next; |
| 314 | struct ctk_window *window; |
| 315 | unsigned char x, y; |
| 316 | unsigned char type; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 317 | unsigned char w, h; |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 318 | #if CTK_CONF_WIDGET_FLAGS |
| 319 | unsigned char flags; |
| 320 | #endif /* CTK_CONF_WIDGET_FLAGS */ |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame^] | 321 | const char *title; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 322 | ek_id_t owner; |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame^] | 323 | const unsigned char *bitmap; |
| 324 | const char *textmap; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 325 | }; |
| 326 | |
adamdunkels | 3eac04f | 2004-09-12 07:22:39 +0000 | [diff] [blame] | 327 | #define CTK_BITMAP(x, y, w, h, bitmap, bitmap_width, bitmap_height) \ |
| 328 | NULL, NULL, x, y, CTK_WIDGET_BITMAP, w, h, \ |
| 329 | CTK_WIDGET_FLAG_INITIALIZER(0) bitmap, bitmap_width, bitmap_height |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 330 | struct ctk_bitmap { |
| 331 | struct ctk_widget *next; |
| 332 | struct ctk_window *window; |
| 333 | unsigned char x, y; |
| 334 | unsigned char type; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 335 | unsigned char w, h; |
adamdunkels | 3eac04f | 2004-09-12 07:22:39 +0000 | [diff] [blame] | 336 | #if CTK_CONF_WIDGET_FLAGS |
| 337 | unsigned char flags; |
| 338 | #endif /* CTK_CONF_WIDGET_FLAGS */ |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame^] | 339 | const unsigned char *bitmap; |
adamdunkels | 3eac04f | 2004-09-12 07:22:39 +0000 | [diff] [blame] | 340 | unsigned short bw, bh; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 341 | }; |
| 342 | |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 343 | #define CTK_TEXTMAP_NORMAL 0 |
| 344 | #define CTK_TEXTMAP_ACTIVE 1 |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 345 | |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 346 | #define CTK_TEXTMAP(x, y, w, h, textmap) \ |
| 347 | NULL, NULL, x, y, CTK_WIDGET_LABEL, w, h, CTK_WIDGET_FLAG_INITIALIZER(0) text, CTK_TEXTMAP_NORMAL |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 348 | struct ctk_textmap { |
| 349 | struct ctk_widget *next; |
| 350 | struct ctk_window *window; |
| 351 | unsigned char x, y; |
| 352 | unsigned char type; |
| 353 | unsigned char w, h; |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 354 | #if CTK_CONF_WIDGET_FLAGS |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 355 | unsigned char flags; |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 356 | #endif /* CTK_CONF_WIDGET_FLAGS */ |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame^] | 357 | const char *textmap; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 358 | unsigned char state; |
| 359 | }; |
| 360 | |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 361 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 362 | /** |
| 363 | * \internal The CTK button widget structure. |
| 364 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 365 | struct ctk_widget_button { |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame^] | 366 | const char *text; /**< The button text. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 367 | }; |
| 368 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 369 | /** |
| 370 | * \internal The CTK label widget structure. |
| 371 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 372 | struct ctk_widget_label { |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame^] | 373 | const char *text; /**< The label text. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 374 | }; |
| 375 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 376 | /** |
| 377 | * \internal The CTK hyperlink widget structure. |
| 378 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 379 | struct ctk_widget_hyperlink { |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame^] | 380 | const char *text; /**< The text of the hyperlink. */ |
| 381 | const char *url; /**< The hyperlink's URL. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 382 | }; |
| 383 | |
| 384 | struct ctk_widget_textentry { |
| 385 | char *text; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 386 | unsigned char len; |
| 387 | unsigned char state; |
| 388 | unsigned char xpos, ypos; |
oliverschmidt | 0096f6a | 2005-05-04 21:50:17 +0000 | [diff] [blame] | 389 | ctk_textentry_input input; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 390 | }; |
| 391 | |
| 392 | struct ctk_widget_icon { |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame^] | 393 | const char *title; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 394 | ek_id_t owner; |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame^] | 395 | const unsigned char *bitmap; |
| 396 | const char *textmap; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 397 | }; |
| 398 | |
| 399 | struct ctk_widget_bitmap { |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame^] | 400 | const unsigned char *bitmap; |
adamdunkels | 3eac04f | 2004-09-12 07:22:39 +0000 | [diff] [blame] | 401 | unsigned short bw, bh; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 402 | }; |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 403 | /** @} */ |
| 404 | |
| 405 | /** |
| 406 | * \addtogroup ctkdraw |
| 407 | * @{ |
| 408 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 409 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 410 | /** |
| 411 | * The generic CTK widget structure that contains all other widget |
| 412 | * structures. |
| 413 | * |
| 414 | * Since the widgets of a window are arranged on a linked list, the |
| 415 | * widget structure contains a next pointer which is used for this |
| 416 | * purpose. The widget structure also contains the placement and the |
| 417 | * size of the widget. |
| 418 | * |
| 419 | * Finally, the actual per-widget structure is contained in this |
| 420 | * top-level widget structure. |
| 421 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 422 | struct ctk_widget { |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 423 | struct ctk_widget *next; /**< The next widget in the linked list |
| 424 | of widgets that is contained in the |
| 425 | ctk_window structure. */ |
| 426 | struct ctk_window *window; /**< The window in which the widget is |
| 427 | contained. */ |
| 428 | unsigned char x, /**< The x position of the widget within |
| 429 | the containing window, in character |
| 430 | coordinates. */ |
| 431 | y; /**< The y position of the widget within |
| 432 | the containing window, in character |
| 433 | coordinates. */ |
| 434 | unsigned char type; /**< The type of the widget: |
| 435 | CTK_WIDGET_SEPARATOR, |
| 436 | CTK_WIDGET_LABEL, CTK_WIDGET_BUTTON, |
| 437 | CTK_WIDGET_HYPERLINK, |
| 438 | CTK_WIDGET_TEXTENTRY, |
| 439 | CTK_WIDGET_BITMAP or |
| 440 | CTK_WIDGET_ICON. */ |
| 441 | unsigned char w, /**< The width of the widget in character |
| 442 | coordinates. */ |
| 443 | h; /**< The height of the widget in |
| 444 | character coordinates. */ |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 445 | #if CTK_CONF_WIDGET_FLAGS |
| 446 | unsigned char flags; |
| 447 | #endif /* CTK_CONF_WIDGET_FLAGS */ |
| 448 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 449 | union { |
| 450 | struct ctk_widget_label label; |
| 451 | struct ctk_widget_button button; |
| 452 | struct ctk_widget_hyperlink hyperlink; |
| 453 | struct ctk_widget_textentry textentry; |
| 454 | struct ctk_widget_icon icon; |
adamdunkels | 1d5eb5e | 2003-03-28 12:10:39 +0000 | [diff] [blame] | 455 | struct ctk_widget_bitmap bitmap; |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 456 | } widget; /**< The union which contains the actual |
| 457 | widget structure, as determined by the |
| 458 | type field. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 459 | }; |
| 460 | |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 461 | |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 462 | struct ctk_desktop; |
| 463 | |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 464 | #define CTK_WIDGET_FLAG_NONE 0 |
| 465 | #define CTK_WIDGET_FLAG_MONOSPACE 1 |
| 466 | #define CTK_WIDGET_FLAG_CENTER 2 |
| 467 | |
| 468 | #if CTK_CONF_WIDGET_FLAGS |
| 469 | #define CTK_WIDGET_SET_FLAG(w, f) ((struct ctk_widget *)(w))->flags = (f) |
| 470 | #else /* CTK_CONF_WIDGET_FLAGS */ |
| 471 | #define CTK_WIDGET_SET_FLAG(w, f) |
| 472 | #endif /* CTK_CONF_WIDGET_FLAGS */ |
| 473 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 474 | /** |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 475 | * Representation of a CTK window. |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 476 | * |
| 477 | * For the CTK, each window is repessented by a ctk_window |
| 478 | * structure. All open windows are kept on a doubly linked list, |
| 479 | * linked by the next and prev fields in the ctk_window struct. The |
| 480 | * window structure holds all widgets that is contained in the window |
| 481 | * as well as a pointer to the currently selected widget. |
| 482 | * |
| 483 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 484 | struct ctk_window { |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 485 | struct ctk_window *next, /**< The next window in the doubly linked |
| 486 | list of open windows. */ |
| 487 | |
| 488 | *prev; /**< The previous window in the doubly |
| 489 | linked list of open windows. */ |
| 490 | struct ctk_desktop *desktop;/**< The desktop on which this window is |
| 491 | open. */ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 492 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 493 | ek_id_t owner; /**< The process that owns the |
| 494 | window. This process will be the |
| 495 | receiver of all CTK signals that |
| 496 | pertain to this window. */ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 497 | |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame^] | 498 | const char *title; /**< The title of the window. Used for |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 499 | constructing the "Dekstop" menu. */ |
| 500 | unsigned char titlelen; /**< The length of the title, cached for |
| 501 | speed reasons. */ |
adamdunkels | 1d5eb5e | 2003-03-28 12:10:39 +0000 | [diff] [blame] | 502 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 503 | #if CTK_CONF_WINDOWCLOSE |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 504 | struct ctk_button closebutton; /**< The closebutton. This is also |
| 505 | present in the list of active |
| 506 | widgets. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 507 | #else /* CTK_CONF_WINDOWCLOSE */ |
| 508 | struct ctk_label closebutton; |
| 509 | #endif /* CTK_CONF_WINDOWCLOSE */ |
| 510 | |
| 511 | #if CTK_CONF_WINDOWMOVE |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 512 | struct ctk_button titlebutton;/**< The titlebutton which is used for |
| 513 | moving the window. This is also |
| 514 | present in the list of active |
| 515 | widgets. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 516 | #else /* CTK_CONF_WINDOWMOVE */ |
| 517 | struct ctk_label titlebutton; |
| 518 | #endif /* CTK_CONF_WINDOWMOVE */ |
| 519 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 520 | unsigned char x, /**< The x coordinate of the window, in |
| 521 | characters. */ |
| 522 | y; /**< The y coordinate of the window, in |
| 523 | characters. */ |
| 524 | unsigned char w, /**< The width of the window, excluding |
| 525 | window borders. */ |
| 526 | h; /**< The height of the window, |
| 527 | excluding window borders. */ |
adamdunkels | 1d5eb5e | 2003-03-28 12:10:39 +0000 | [diff] [blame] | 528 | |
| 529 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 530 | struct ctk_widget *inactive; /**< The list if widgets that cannot be |
| 531 | selected by the user. Labels and |
| 532 | separator widgets are placed on this |
| 533 | list. */ |
| 534 | struct ctk_widget *active; /**< The list of widgets that can be |
| 535 | selected by the user. Buttons, |
| 536 | hyperlinks, text entry fields, etc., |
| 537 | are placed on this list. */ |
| 538 | struct ctk_widget *focused; /**< A pointer to the widget on the |
| 539 | active list that is currently |
| 540 | selected, or NULL if no widget is |
| 541 | selected. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 542 | }; |
| 543 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 544 | /** |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 545 | * Representation of an individual menu item. |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 546 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 547 | struct ctk_menuitem { |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame^] | 548 | const char *title; /**< The menu items text. */ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 549 | unsigned char titlelen;/**< The length of the item text, cached for |
| 550 | speed. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 551 | }; |
| 552 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 553 | /** |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 554 | * Representation of an individual menu. |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 555 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 556 | struct ctk_menu { |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 557 | struct ctk_menu *next; /**< Apointer to the next menu, or is NULL if |
| 558 | this is the last menu, and should be used |
| 559 | by the ctk-draw module when stepping |
| 560 | through the menus when drawing them on |
| 561 | screen. */ |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame^] | 562 | const char *title; /**< The menu title. */ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 563 | unsigned char titlelen;/**< The length of the title in |
| 564 | characters. Cached for speed reasons. */ |
adamdunkels | 78c03dc | 2003-04-09 13:45:05 +0000 | [diff] [blame] | 565 | #if CC_UNSIGNED_CHAR_BUGS |
adamdunkels | 6ccf721 | 2003-04-10 07:04:45 +0000 | [diff] [blame] | 566 | unsigned int nitems; |
| 567 | unsigned int active; |
adamdunkels | 78c03dc | 2003-04-09 13:45:05 +0000 | [diff] [blame] | 568 | #else /* CC_UNSIGNED_CHAR_BUGS */ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 569 | unsigned char nitems; /**< The total number of menu items in the |
| 570 | menu. */ |
| 571 | unsigned char active; /**< The currently active menu item. */ |
adamdunkels | 78c03dc | 2003-04-09 13:45:05 +0000 | [diff] [blame] | 572 | #endif /* CC_UNSIGNED_CHAR_BUGS */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 573 | struct ctk_menuitem items[CTK_CONF_MAXMENUITEMS]; |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 574 | /**< The array which contains all the menu |
| 575 | items. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 576 | }; |
| 577 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 578 | /** |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 579 | * Representation of the menu bar. |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 580 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 581 | struct ctk_menus { |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 582 | struct ctk_menu *menus; /**< A pointer to a linked list of all |
| 583 | menus, including the open menu and |
| 584 | the desktop menu.*/ |
| 585 | struct ctk_menu *open; /**< The currently open menu, if |
| 586 | any. If all menus are closed, this |
| 587 | item is NULL: */ |
| 588 | struct ctk_menu *desktopmenu; /**< A pointer to the "Desktop" menu |
| 589 | that can be used for drawing the |
| 590 | desktop menu in a special way (such |
| 591 | as drawing it at the rightmost |
| 592 | position). */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 593 | }; |
| 594 | |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 595 | /** @} */ |
| 596 | |
| 597 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 598 | /** |
| 599 | * \internal The structure describing a Contiki desktop. |
| 600 | */ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 601 | struct ctk_desktop { |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame^] | 602 | const char *name; /**< The name of the desktop. */ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 603 | |
| 604 | struct ctk_window desktop_window; /**< The background window which |
| 605 | contains tha desktop icons. */ |
| 606 | struct ctk_window *windows; /**< The list of open windows. */ |
| 607 | struct ctk_window *dialog; /**< A pointer to the open dialog, or |
| 608 | NULL if no dialog is open. */ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 609 | |
| 610 | #if CTK_CONF_MENUS |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 611 | struct ctk_menus menus; /**< The list of desktop menus. */ |
| 612 | struct ctk_menu *lastmenu; /**< Pointer to the menu that was last open. */ |
| 613 | struct ctk_menu desktopmenu;/**< The desktop menu. */ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 614 | #endif /* CTK_CONF_MENUS */ |
| 615 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 616 | unsigned char height, /**< The height of the desktop, in characters. */ |
| 617 | width; /**< The width of the desktop, in characters. */ |
| 618 | |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 619 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 620 | #define CTK_REDRAW_NONE 0 /**< \internal Redraw flag: nothing |
| 621 | to be redrawn. */ |
| 622 | #define CTK_REDRAW_ALL 1 /**< \internal Redraw flag: |
| 623 | everything should be redrawn. */ |
| 624 | #define CTK_REDRAW_WINDOWS 2 /**< \internal Redraw flag: redraw |
| 625 | windows in queue.*/ |
| 626 | #define CTK_REDRAW_WIDGETS 4 /**< \internal Redraw flag: redraw |
| 627 | widgets in queue. */ |
| 628 | #define CTK_REDRAW_MENUS 8 /**< \internal Redraw flag: redraw |
| 629 | menus. */ |
| 630 | #define CTK_REDRAW_PART 16 /**< \internal Redraw flag: redraw |
| 631 | parts of the desktop. */ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 632 | |
| 633 | #ifndef CTK_CONF_MAX_REDRAWWIDGETS |
| 634 | #define CTK_CONF_MAX_REDRAWWIDGETS 8 |
| 635 | #endif /* CTK_CONF_MAX_REDRAWWIDGETS */ |
| 636 | #ifndef CTK_CONF_MAX_REDRAWWINDOWS |
| 637 | #define CTK_CONF_MAX_REDRAWWINDOWS 8 |
| 638 | #endif /* CTK_CONF_MAX_REDRAWWINDOWS */ |
| 639 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 640 | unsigned char redraw; /**< The redraw flag. */ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 641 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 642 | struct ctk_widget *redraw_widgets[CTK_CONF_MAX_REDRAWWIDGETS]; /**< The list of widgets to be redrawn. */ |
| 643 | unsigned char redraw_widgetptr; /**< Pointer to the last widget on the redraw_widgets list. */ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 644 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 645 | struct ctk_window *redraw_windows[CTK_CONF_MAX_REDRAWWINDOWS]; /**< The list of windows to be redrawn. */ |
| 646 | unsigned char redraw_windowptr; /**< Pointer to the last window on the redraw_windows list. */ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 647 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 648 | unsigned char redraw_y1, /**< The lower y bound of the area to be redrawn if CTK_REDRAW_PART is flagged. */ |
| 649 | redraw_y2; /**< The upper y bound of the area to be redrawn if CTK_REDRAW_PART is flagged. */ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 650 | }; |
| 651 | |
| 652 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 653 | /* Global CTK modes. */ |
| 654 | #define CTK_MODE_NORMAL 0 |
| 655 | #define CTK_MODE_WINDOWMOVE 1 |
| 656 | #define CTK_MODE_SCREENSAVER 2 |
| 657 | #define CTK_MODE_EXTERNAL 3 |
| 658 | |
| 659 | /* General ctk functions. */ |
| 660 | void ctk_init(void); |
adamdunkels | 28ad2b3 | 2004-08-09 20:30:50 +0000 | [diff] [blame] | 661 | void ctk_restore(void); |
| 662 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 663 | void ctk_mode_set(unsigned char mode); |
| 664 | unsigned char ctk_mode_get(void); |
adamdunkels | 9795b2e | 2003-08-09 23:32:37 +0000 | [diff] [blame] | 665 | /*void ctk_redraw(void);*/ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 666 | |
| 667 | /* Functions for manipulating windows. */ |
| 668 | void ctk_window_new(struct ctk_window *window, |
| 669 | unsigned char w, unsigned char h, |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame^] | 670 | const char *title); |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 671 | void ctk_window_clear(struct ctk_window *w); |
| 672 | void ctk_window_open(struct ctk_window *w); |
oliverschmidt | cd6c30b | 2005-05-05 20:54:16 +0000 | [diff] [blame] | 673 | #define ctk_window_move(w,xpos,ypos) do { (w)->x=xpos; (w)->y=ypos; } while(0) |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 674 | void ctk_window_close(struct ctk_window *w); |
| 675 | void ctk_window_redraw(struct ctk_window *w); |
| 676 | #define ctk_window_isopen(w) ((w)->next != NULL) |
| 677 | |
| 678 | |
| 679 | /* Functions for manipulating dialogs. */ |
| 680 | void ctk_dialog_new(struct ctk_window *window, |
| 681 | unsigned char w, unsigned char h); |
| 682 | void ctk_dialog_open(struct ctk_window *d); |
| 683 | void ctk_dialog_close(void); |
| 684 | |
| 685 | /* Functions for manipulating menus. */ |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame^] | 686 | void ctk_menu_new(struct ctk_menu *menu, const char *title); |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 687 | void ctk_menu_add(struct ctk_menu *menu); |
| 688 | void ctk_menu_remove(struct ctk_menu *menu); |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame^] | 689 | unsigned char ctk_menuitem_add(struct ctk_menu *menu, const char *name); |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 690 | |
| 691 | /* Functions for icons. */ |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 692 | |
| 693 | /** |
| 694 | * \addtogroup ctkappfunc |
| 695 | * @{ |
| 696 | */ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 697 | /** |
| 698 | * Add an icon to the desktop. |
| 699 | * |
| 700 | * \param icon The icon to be added. |
adamdunkels | 0404ef1 | 2003-09-04 19:36:04 +0000 | [diff] [blame] | 701 | * |
| 702 | * \param id The process ID of the process that owns the icon. |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 703 | */ |
adamdunkels | 0404ef1 | 2003-09-04 19:36:04 +0000 | [diff] [blame] | 704 | #define CTK_ICON_ADD(icon, id) ctk_icon_add((struct ctk_widget *)icon, id) |
| 705 | void ctk_icon_add(struct ctk_widget *icon, ek_id_t id); |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 706 | |
| 707 | /* Functions for manipulating widgets. */ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 708 | |
| 709 | /** |
| 710 | * Add a widget to a window. |
| 711 | * |
| 712 | * \param win The window to which the widget should be added. |
| 713 | * \param widg The widget to be added. |
| 714 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 715 | #define CTK_WIDGET_ADD(win, widg) \ |
| 716 | ctk_widget_add(win, (struct ctk_widget *)widg) |
adamdunkels | a6557e4 | 2003-08-11 22:27:51 +0000 | [diff] [blame] | 717 | void CC_FASTCALL ctk_widget_add(struct ctk_window *window, |
| 718 | struct ctk_widget *widget); |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 719 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 720 | /** |
| 721 | * Set focus to a widget. |
| 722 | * |
| 723 | * \param win The widget's window. |
| 724 | * \param widg The widget |
| 725 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 726 | #define CTK_WIDGET_FOCUS(win, widg) \ |
| 727 | (win)->focused = (struct ctk_widget *)(widg) |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 728 | |
| 729 | /** |
| 730 | * Add a widget to the redraw queue. |
| 731 | * |
| 732 | * \param widg The widget to be redrawn. |
| 733 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 734 | #define CTK_WIDGET_REDRAW(widg) \ |
| 735 | ctk_widget_redraw((struct ctk_widget *)widg) |
| 736 | void ctk_widget_redraw(struct ctk_widget *w); |
| 737 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 738 | /** |
| 739 | * Obtain the type of a widget. |
| 740 | * |
| 741 | * \param w The widget. |
| 742 | */ |
adamdunkels | 3a08a49 | 2003-04-11 20:16:02 +0000 | [diff] [blame] | 743 | #define CTK_WIDGET_TYPE(w) ((w)->type) |
| 744 | |
adamdunkels | e8b21d0 | 2003-04-24 17:18:27 +0000 | [diff] [blame] | 745 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 746 | /** |
| 747 | * Sets the width of a widget. |
| 748 | * |
| 749 | * \param widget The widget. |
| 750 | * \param width The width of the widget, in characters. |
| 751 | */ |
adamdunkels | e8b21d0 | 2003-04-24 17:18:27 +0000 | [diff] [blame] | 752 | #define CTK_WIDGET_SET_WIDTH(widget, width) do { \ |
| 753 | ((struct ctk_widget *)(widget))->w = (width); } while(0) |
| 754 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 755 | /** |
| 756 | * Retrieves the x position of a widget, relative to the window in |
| 757 | * which the widget is contained. |
| 758 | * |
| 759 | * \param w The widget. |
| 760 | * \return The x position of the widget. |
| 761 | */ |
adamdunkels | e8b21d0 | 2003-04-24 17:18:27 +0000 | [diff] [blame] | 762 | #define CTK_WIDGET_XPOS(w) (((struct ctk_widget *)(w))->x) |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 763 | |
| 764 | /** |
| 765 | * Sets the x position of a widget, relative to the window in |
| 766 | * which the widget is contained. |
| 767 | * |
| 768 | * \param w The widget. |
| 769 | * \param xpos The x position of the widget. |
| 770 | */ |
| 771 | #define CTK_WIDGET_SET_XPOS(w, xpos) \ |
| 772 | ((struct ctk_widget *)(w))->x = (xpos) |
| 773 | /** |
| 774 | * Retrieves the y position of a widget, relative to the window in |
| 775 | * which the widget is contained. |
| 776 | * |
| 777 | * \param w The widget. |
| 778 | * \return The y position of the widget. |
| 779 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 780 | #define CTK_WIDGET_YPOS(w) (((struct ctk_widget *)(w))->y) |
| 781 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 782 | /** |
| 783 | * Sets the y position of a widget, relative to the window in |
| 784 | * which the widget is contained. |
| 785 | * |
| 786 | * \param w The widget. |
| 787 | * \param ypos The y position of the widget. |
| 788 | */ |
| 789 | #define CTK_WIDGET_SET_YPOS(w, ypos) \ |
| 790 | ((struct ctk_widget *)(w))->y = (ypos) |
| 791 | |
| 792 | /* XXX: should be removed. |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 793 | #define ctk_textentry_set_height(w, height) \ |
| 794 | (w)->widget.textentry.h = (height) |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 795 | */ |
| 796 | |
| 797 | /** \def ctk_label_set_height(w, height) |
| 798 | * \brief Set the height of a label. |
| 799 | * |
| 800 | * \param w The CTK label widget. |
| 801 | * \param height The new height of the label. |
| 802 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 803 | #define ctk_label_set_height(w, height) \ |
| 804 | (w)->widget.label.h = (height) |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 805 | |
| 806 | /** |
| 807 | * Set the text of a label. |
| 808 | * |
| 809 | * \param l The CTK label widget. |
| 810 | * \param t The new text of the label. |
| 811 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 812 | #define ctk_label_set_text(l, t) (l)->text = (t) |
| 813 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 814 | /** |
| 815 | * Set the text of a button. |
| 816 | * |
| 817 | * \param b The CTK button widget. |
| 818 | * \param t The new text of the button. |
| 819 | */ |
adamdunkels | 1d5eb5e | 2003-03-28 12:10:39 +0000 | [diff] [blame] | 820 | #define ctk_button_set_text(b, t) (b)->text = (t) |
| 821 | |
adamdunkels | 58917a8 | 2003-04-18 00:18:38 +0000 | [diff] [blame] | 822 | #define ctk_bitmap_set_bitmap(b, m) (b)->bitmap = (m) |
| 823 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 824 | #define CTK_BUTTON_NEW(widg, xpos, ypos, width, buttontext) \ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 825 | do { (widg)->window = NULL; \ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 826 | (widg)->next = NULL; \ |
| 827 | (widg)->type = CTK_WIDGET_BUTTON; \ |
| 828 | (widg)->x = (xpos); \ |
| 829 | (widg)->y = (ypos); \ |
| 830 | (widg)->w = (width); \ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 831 | (widg)->h = 1; \ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 832 | (widg)->text = (buttontext); \ |
| 833 | } while(0) |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 834 | |
| 835 | #define CTK_LABEL_NEW(widg, xpos, ypos, width, height, labeltext) \ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 836 | do { (widg)->window = NULL; \ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 837 | (widg)->next = NULL; \ |
| 838 | (widg)->type = CTK_WIDGET_LABEL; \ |
| 839 | (widg)->x = (xpos); \ |
| 840 | (widg)->y = (ypos); \ |
| 841 | (widg)->w = (width); \ |
| 842 | (widg)->h = (height); \ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 843 | (widg)->text = (labeltext); \ |
| 844 | } while(0) |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 845 | |
adamdunkels | 58917a8 | 2003-04-18 00:18:38 +0000 | [diff] [blame] | 846 | #define CTK_BITMAP_NEW(widg, xpos, ypos, width, height, bmap) \ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 847 | do { (widg)->window = NULL; \ |
adamdunkels | 58917a8 | 2003-04-18 00:18:38 +0000 | [diff] [blame] | 848 | (widg)->next = NULL; \ |
| 849 | (widg)->type = CTK_WIDGET_BITMAP; \ |
| 850 | (widg)->x = (xpos); \ |
| 851 | (widg)->y = (ypos); \ |
| 852 | (widg)->w = (width); \ |
| 853 | (widg)->h = (height); \ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 854 | (widg)->bitmap = (bmap); \ |
| 855 | } while(0) |
adamdunkels | 58917a8 | 2003-04-18 00:18:38 +0000 | [diff] [blame] | 856 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 857 | #define CTK_TEXTENTRY_NEW(widg, xxpos, yypos, width, height, textptr, textlen) \ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 858 | do { (widg)->window = NULL; \ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 859 | (widg)->next = NULL; \ |
| 860 | (widg)->type = CTK_WIDGET_TEXTENTRY; \ |
| 861 | (widg)->x = (xxpos); \ |
| 862 | (widg)->y = (yypos); \ |
| 863 | (widg)->w = (width); \ |
oliverschmidt | 0096f6a | 2005-05-04 21:50:17 +0000 | [diff] [blame] | 864 | (widg)->h = 1; \ |
| 865 | (widg)->text = (textptr); \ |
| 866 | (widg)->len = (textlen); \ |
| 867 | (widg)->state = CTK_TEXTENTRY_NORMAL; \ |
| 868 | (widg)->xpos = 0; \ |
| 869 | (widg)->ypos = 0; \ |
| 870 | (widg)->input = NULL; \ |
| 871 | } while(0) |
| 872 | |
| 873 | #define CTK_TEXTENTRY_INPUT_NEW(widg, xxpos, yypos, width, height, textptr, textlen, iinput) \ |
| 874 | do { (widg)->window = NULL; \ |
| 875 | (widg)->next = NULL; \ |
| 876 | (widg)->type = CTK_WIDGET_TEXTENTRY; \ |
| 877 | (widg)->x = (xxpos); \ |
| 878 | (widg)->y = (yypos); \ |
| 879 | (widg)->w = (width); \ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 880 | (widg)->h = (height); \ |
| 881 | (widg)->text = (textptr); \ |
| 882 | (widg)->len = (textlen); \ |
| 883 | (widg)->state = CTK_TEXTENTRY_NORMAL; \ |
| 884 | (widg)->xpos = 0; \ |
adamdunkels | 28ad2b3 | 2004-08-09 20:30:50 +0000 | [diff] [blame] | 885 | (widg)->ypos = 0; \ |
oliverschmidt | 0096f6a | 2005-05-04 21:50:17 +0000 | [diff] [blame] | 886 | (widg)->input = (ctk_textentry_input)(iinput); \ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 887 | } while(0) |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 888 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 889 | #define CTK_HYPERLINK_NEW(widg, xpos, ypos, width, linktext, linkurl) \ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 890 | do { (widg)->window = NULL; \ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 891 | (widg)->next = NULL; \ |
| 892 | (widg)->type = CTK_WIDGET_HYPERLINK; \ |
| 893 | (widg)->x = (xpos); \ |
| 894 | (widg)->y = (ypos); \ |
| 895 | (widg)->w = (width); \ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 896 | (widg)->h = 1; \ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 897 | (widg)->text = (linktext); \ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 898 | (widg)->url = (linkurl); \ |
| 899 | } while(0) |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 900 | |
adamdunkels | e2f4d2a | 2003-04-28 23:21:42 +0000 | [diff] [blame] | 901 | /* Desktop interface. */ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 902 | void ctk_desktop_redraw(struct ctk_desktop *d); |
| 903 | unsigned char ctk_desktop_width(struct ctk_desktop *d); |
| 904 | unsigned char ctk_desktop_height(struct ctk_desktop *d); |
adamdunkels | e2f4d2a | 2003-04-28 23:21:42 +0000 | [diff] [blame] | 905 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 906 | /* Signals. */ |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 907 | extern ek_event_t ctk_signal_keypress, |
adamdunkels | 3a08a49 | 2003-04-11 20:16:02 +0000 | [diff] [blame] | 908 | ctk_signal_widget_activate, |
| 909 | ctk_signal_widget_select, |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 910 | ctk_signal_timer, |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 911 | ctk_signal_menu_activate, |
adamdunkels | c490286 | 2003-04-09 00:30:45 +0000 | [diff] [blame] | 912 | ctk_signal_window_close, |
| 913 | ctk_signal_pointer_move, |
adamdunkels | 3a08a49 | 2003-04-11 20:16:02 +0000 | [diff] [blame] | 914 | ctk_signal_pointer_button; |
| 915 | |
adamdunkels | e8b21d0 | 2003-04-24 17:18:27 +0000 | [diff] [blame] | 916 | #if CTK_CONF_SCREENSAVER |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 917 | extern ek_event_t ctk_signal_screensaver_stop, |
adamdunkels | 9795b2e | 2003-08-09 23:32:37 +0000 | [diff] [blame] | 918 | ctk_signal_screensaver_start; |
adamdunkels | e2f4d2a | 2003-04-28 23:21:42 +0000 | [diff] [blame] | 919 | |
| 920 | extern unsigned short ctk_screensaver_timeout; |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 921 | /** |
| 922 | * Set the screensaver timeout, in seconds. |
| 923 | * |
| 924 | * \param t The timeout in seconds. |
| 925 | */ |
adamdunkels | e2f4d2a | 2003-04-28 23:21:42 +0000 | [diff] [blame] | 926 | #define CTK_SCREENSAVER_SET_TIMEOUT(t) ctk_screensaver_timeout = (t) |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 927 | /** |
| 928 | * Obtain the screensaver timeout, in seconds. |
| 929 | * |
| 930 | * \raturn The timeout in seconds. |
| 931 | */ |
adamdunkels | e2f4d2a | 2003-04-28 23:21:42 +0000 | [diff] [blame] | 932 | #define CTK_SCREENSAVER_TIMEOUT() ctk_screensaver_timeout |
adamdunkels | e8b21d0 | 2003-04-24 17:18:27 +0000 | [diff] [blame] | 933 | #endif /* CTK_CONF_SCREENSAVER */ |
| 934 | |
adamdunkels | 3a08a49 | 2003-04-11 20:16:02 +0000 | [diff] [blame] | 935 | /* These should no longer be used: */ |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 936 | extern ek_event_t ctk_signal_button_activate, |
adamdunkels | 3a08a49 | 2003-04-11 20:16:02 +0000 | [diff] [blame] | 937 | ctk_signal_button_hover, |
| 938 | ctk_signal_hyperlink_activate, |
| 939 | ctk_signal_hyperlink_hover; |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 940 | /** @} */ |
| 941 | |
| 942 | /** |
| 943 | * \addtogroup ctkdraw |
| 944 | * @{ |
| 945 | */ |
adamdunkels | 3a08a49 | 2003-04-11 20:16:02 +0000 | [diff] [blame] | 946 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 947 | /* Focus flags */ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 948 | /** Widget focus flag: no focus. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 949 | #define CTK_FOCUS_NONE 0 |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 950 | /** Widget focus flag: widget has focus. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 951 | #define CTK_FOCUS_WIDGET 1 |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 952 | /** Widget focus flag: widget's window is the foremost one. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 953 | #define CTK_FOCUS_WINDOW 2 |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 954 | /** Widget focus flag: widget is in a dialog. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 955 | #define CTK_FOCUS_DIALOG 4 |
| 956 | |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 957 | /** @} */ |
| 958 | /** @} */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 959 | #endif /* __CTK_H__ */ |