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 | |
Adrien Destugues | 4786780 | 2017-06-05 13:43:16 +0200 | [diff] [blame] | 236 | struct ctk_textentry; |
oliverschmidt | 0096f6a | 2005-05-04 21:50:17 +0000 | [diff] [blame] | 237 | typedef unsigned char (* ctk_textentry_input)(ctk_arch_key_t c, |
| 238 | struct ctk_textentry *t); |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 239 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 240 | /** |
| 241 | * Instantiating macro for the ctk_textentry widget. |
| 242 | * |
| 243 | * This macro is used when instantiating a ctk_textentry widget and is |
| 244 | * intended to be used together with a struct assignment like this: |
| 245 | \code |
| 246 | struct ctk_textentry tentry = |
| 247 | {CTK_TEXTENTRY(0, 0, 30, 1, textbuffer, 50)}; |
| 248 | \endcode |
| 249 | * \note The height of the text entry widget is obsolete and not |
| 250 | * intended to be used. |
| 251 | * |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 252 | * \param x The x position of the widget, relative to the widget's |
| 253 | * window. |
| 254 | * \param y The y position of the widget, relative to the widget's |
| 255 | * window. |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 256 | * \param w The widget's width. |
| 257 | * \param h The text entry height (obsolete). |
| 258 | * \param text A pointer to the buffer that should be edited. |
| 259 | * \param len The length of the text buffer |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 260 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 261 | #define CTK_TEXTENTRY(x, y, w, h, text, len) \ |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 262 | 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] | 263 | CTK_TEXTENTRY_NORMAL, 0, 0, NULL |
| 264 | #define CTK_TEXTENTRY_INPUT(x, y, w, h, text, len, input) \ |
| 265 | NULL, NULL, x, y, CTK_WIDGET_TEXTENTRY, w, h, CTK_WIDGET_FLAG_INITIALIZER(0) text, len, \ |
| 266 | CTK_TEXTENTRY_NORMAL, 0, 0, (ctk_textentry_input)input |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 267 | struct ctk_textentry { |
| 268 | struct ctk_widget *next; |
| 269 | struct ctk_window *window; |
| 270 | unsigned char x, y; |
| 271 | unsigned char type; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 272 | unsigned char w, h; |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 273 | #if CTK_CONF_WIDGET_FLAGS |
| 274 | unsigned char flags; |
| 275 | #endif /* CTK_CONF_WIDGET_FLAGS */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 276 | char *text; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 277 | unsigned char len; |
| 278 | unsigned char state; |
| 279 | unsigned char xpos, ypos; |
oliverschmidt | 0096f6a | 2005-05-04 21:50:17 +0000 | [diff] [blame] | 280 | ctk_textentry_input input; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 281 | }; |
| 282 | |
| 283 | |
oliverschmidt | 84b3084 | 2004-06-27 12:32:16 +0000 | [diff] [blame] | 284 | #if CTK_CONF_ICON_BITMAPS |
| 285 | #define CTK_ICON_BITMAP(bitmap) bitmap |
| 286 | #else |
| 287 | #define CTK_ICON_BITMAP(bitmap) NULL |
| 288 | #endif |
| 289 | |
| 290 | #if CTK_CONF_ICON_TEXTMAPS |
| 291 | #define CTK_ICON_TEXTMAP(textmap) textmap |
| 292 | #else |
| 293 | #define CTK_ICON_TEXTMAP(textmap) NULL |
| 294 | #endif |
| 295 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 296 | /** |
| 297 | * Instantiating macro for the ctk_icon widget. |
| 298 | * |
| 299 | * This macro is used when instantiating a ctk_icon widget and is |
| 300 | * intended to be used together with a struct assignment like this: |
| 301 | \code |
| 302 | struct ctk_icon icon = |
| 303 | {CTK_ICON("An icon", bitmapptr, textmapptr)}; |
| 304 | \endcode |
| 305 | * \param title The icon's text. |
| 306 | * \param bitmap A pointer to the icon's bitmap image. |
| 307 | * \param textmap A pointer to the icon's text version of the bitmap. |
| 308 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 309 | #define CTK_ICON(title, bitmap, textmap) \ |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 310 | NULL, NULL, 0, 0, CTK_WIDGET_ICON, 2, 4, CTK_WIDGET_FLAG_INITIALIZER(0) \ |
| 311 | title, EK_ID_NONE, \ |
oliverschmidt | 84b3084 | 2004-06-27 12:32:16 +0000 | [diff] [blame] | 312 | CTK_ICON_BITMAP(bitmap), CTK_ICON_TEXTMAP(textmap) |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 313 | struct ctk_icon { |
| 314 | struct ctk_widget *next; |
| 315 | struct ctk_window *window; |
| 316 | unsigned char x, y; |
| 317 | unsigned char type; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 318 | unsigned char w, h; |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 319 | #if CTK_CONF_WIDGET_FLAGS |
| 320 | unsigned char flags; |
| 321 | #endif /* CTK_CONF_WIDGET_FLAGS */ |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame] | 322 | const char *title; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 323 | ek_id_t owner; |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame] | 324 | const unsigned char *bitmap; |
| 325 | const char *textmap; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 326 | }; |
| 327 | |
adamdunkels | 3eac04f | 2004-09-12 07:22:39 +0000 | [diff] [blame] | 328 | #define CTK_BITMAP(x, y, w, h, bitmap, bitmap_width, bitmap_height) \ |
| 329 | NULL, NULL, x, y, CTK_WIDGET_BITMAP, w, h, \ |
| 330 | CTK_WIDGET_FLAG_INITIALIZER(0) bitmap, bitmap_width, bitmap_height |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 331 | struct ctk_bitmap { |
| 332 | struct ctk_widget *next; |
| 333 | struct ctk_window *window; |
| 334 | unsigned char x, y; |
| 335 | unsigned char type; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 336 | unsigned char w, h; |
adamdunkels | 3eac04f | 2004-09-12 07:22:39 +0000 | [diff] [blame] | 337 | #if CTK_CONF_WIDGET_FLAGS |
| 338 | unsigned char flags; |
| 339 | #endif /* CTK_CONF_WIDGET_FLAGS */ |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame] | 340 | const unsigned char *bitmap; |
adamdunkels | 3eac04f | 2004-09-12 07:22:39 +0000 | [diff] [blame] | 341 | unsigned short bw, bh; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 342 | }; |
| 343 | |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 344 | #define CTK_TEXTMAP_NORMAL 0 |
| 345 | #define CTK_TEXTMAP_ACTIVE 1 |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 346 | |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 347 | #define CTK_TEXTMAP(x, y, w, h, textmap) \ |
| 348 | 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] | 349 | struct ctk_textmap { |
| 350 | struct ctk_widget *next; |
| 351 | struct ctk_window *window; |
| 352 | unsigned char x, y; |
| 353 | unsigned char type; |
| 354 | unsigned char w, h; |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 355 | #if CTK_CONF_WIDGET_FLAGS |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 356 | unsigned char flags; |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 357 | #endif /* CTK_CONF_WIDGET_FLAGS */ |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame] | 358 | const char *textmap; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 359 | unsigned char state; |
| 360 | }; |
| 361 | |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 362 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 363 | /** |
| 364 | * \internal The CTK button widget structure. |
| 365 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 366 | struct ctk_widget_button { |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame] | 367 | const char *text; /**< The button text. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 368 | }; |
| 369 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 370 | /** |
| 371 | * \internal The CTK label widget structure. |
| 372 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 373 | struct ctk_widget_label { |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame] | 374 | const char *text; /**< The label text. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 375 | }; |
| 376 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 377 | /** |
| 378 | * \internal The CTK hyperlink widget structure. |
| 379 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 380 | struct ctk_widget_hyperlink { |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame] | 381 | const char *text; /**< The text of the hyperlink. */ |
| 382 | const char *url; /**< The hyperlink's URL. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 383 | }; |
| 384 | |
| 385 | struct ctk_widget_textentry { |
| 386 | char *text; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 387 | unsigned char len; |
| 388 | unsigned char state; |
| 389 | unsigned char xpos, ypos; |
oliverschmidt | 0096f6a | 2005-05-04 21:50:17 +0000 | [diff] [blame] | 390 | ctk_textentry_input input; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 391 | }; |
| 392 | |
| 393 | struct ctk_widget_icon { |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame] | 394 | const char *title; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 395 | ek_id_t owner; |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame] | 396 | const unsigned char *bitmap; |
| 397 | const char *textmap; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 398 | }; |
| 399 | |
| 400 | struct ctk_widget_bitmap { |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame] | 401 | const unsigned char *bitmap; |
adamdunkels | 3eac04f | 2004-09-12 07:22:39 +0000 | [diff] [blame] | 402 | unsigned short bw, bh; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 403 | }; |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 404 | /** @} */ |
| 405 | |
| 406 | /** |
| 407 | * \addtogroup ctkdraw |
| 408 | * @{ |
| 409 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 410 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 411 | /** |
| 412 | * The generic CTK widget structure that contains all other widget |
| 413 | * structures. |
| 414 | * |
| 415 | * Since the widgets of a window are arranged on a linked list, the |
| 416 | * widget structure contains a next pointer which is used for this |
| 417 | * purpose. The widget structure also contains the placement and the |
| 418 | * size of the widget. |
| 419 | * |
| 420 | * Finally, the actual per-widget structure is contained in this |
| 421 | * top-level widget structure. |
| 422 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 423 | struct ctk_widget { |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 424 | struct ctk_widget *next; /**< The next widget in the linked list |
| 425 | of widgets that is contained in the |
| 426 | ctk_window structure. */ |
| 427 | struct ctk_window *window; /**< The window in which the widget is |
| 428 | contained. */ |
| 429 | unsigned char x, /**< The x position of the widget within |
| 430 | the containing window, in character |
| 431 | coordinates. */ |
| 432 | y; /**< The y position of the widget within |
| 433 | the containing window, in character |
| 434 | coordinates. */ |
| 435 | unsigned char type; /**< The type of the widget: |
| 436 | CTK_WIDGET_SEPARATOR, |
| 437 | CTK_WIDGET_LABEL, CTK_WIDGET_BUTTON, |
| 438 | CTK_WIDGET_HYPERLINK, |
| 439 | CTK_WIDGET_TEXTENTRY, |
| 440 | CTK_WIDGET_BITMAP or |
| 441 | CTK_WIDGET_ICON. */ |
| 442 | unsigned char w, /**< The width of the widget in character |
| 443 | coordinates. */ |
| 444 | h; /**< The height of the widget in |
| 445 | character coordinates. */ |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 446 | #if CTK_CONF_WIDGET_FLAGS |
| 447 | unsigned char flags; |
| 448 | #endif /* CTK_CONF_WIDGET_FLAGS */ |
| 449 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 450 | union { |
| 451 | struct ctk_widget_label label; |
| 452 | struct ctk_widget_button button; |
| 453 | struct ctk_widget_hyperlink hyperlink; |
| 454 | struct ctk_widget_textentry textentry; |
| 455 | struct ctk_widget_icon icon; |
adamdunkels | 1d5eb5e | 2003-03-28 12:10:39 +0000 | [diff] [blame] | 456 | struct ctk_widget_bitmap bitmap; |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 457 | } widget; /**< The union which contains the actual |
| 458 | widget structure, as determined by the |
| 459 | type field. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 460 | }; |
| 461 | |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 462 | |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 463 | struct ctk_desktop; |
| 464 | |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 465 | #define CTK_WIDGET_FLAG_NONE 0 |
| 466 | #define CTK_WIDGET_FLAG_MONOSPACE 1 |
| 467 | #define CTK_WIDGET_FLAG_CENTER 2 |
| 468 | |
| 469 | #if CTK_CONF_WIDGET_FLAGS |
| 470 | #define CTK_WIDGET_SET_FLAG(w, f) ((struct ctk_widget *)(w))->flags = (f) |
| 471 | #else /* CTK_CONF_WIDGET_FLAGS */ |
| 472 | #define CTK_WIDGET_SET_FLAG(w, f) |
| 473 | #endif /* CTK_CONF_WIDGET_FLAGS */ |
| 474 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 475 | /** |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 476 | * Representation of a CTK window. |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 477 | * |
| 478 | * For the CTK, each window is repessented by a ctk_window |
| 479 | * structure. All open windows are kept on a doubly linked list, |
| 480 | * linked by the next and prev fields in the ctk_window struct. The |
| 481 | * window structure holds all widgets that is contained in the window |
| 482 | * as well as a pointer to the currently selected widget. |
| 483 | * |
| 484 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 485 | struct ctk_window { |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 486 | struct ctk_window *next, /**< The next window in the doubly linked |
| 487 | list of open windows. */ |
| 488 | |
| 489 | *prev; /**< The previous window in the doubly |
| 490 | linked list of open windows. */ |
| 491 | struct ctk_desktop *desktop;/**< The desktop on which this window is |
| 492 | open. */ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 493 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 494 | ek_id_t owner; /**< The process that owns the |
| 495 | window. This process will be the |
| 496 | receiver of all CTK signals that |
| 497 | pertain to this window. */ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 498 | |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame] | 499 | const char *title; /**< The title of the window. Used for |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 500 | constructing the "Dekstop" menu. */ |
| 501 | unsigned char titlelen; /**< The length of the title, cached for |
| 502 | speed reasons. */ |
adamdunkels | 1d5eb5e | 2003-03-28 12:10:39 +0000 | [diff] [blame] | 503 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 504 | #if CTK_CONF_WINDOWCLOSE |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 505 | struct ctk_button closebutton; /**< The closebutton. This is also |
| 506 | present in the list of active |
| 507 | widgets. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 508 | #else /* CTK_CONF_WINDOWCLOSE */ |
| 509 | struct ctk_label closebutton; |
| 510 | #endif /* CTK_CONF_WINDOWCLOSE */ |
| 511 | |
| 512 | #if CTK_CONF_WINDOWMOVE |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 513 | struct ctk_button titlebutton;/**< The titlebutton which is used for |
| 514 | moving the window. This is also |
| 515 | present in the list of active |
| 516 | widgets. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 517 | #else /* CTK_CONF_WINDOWMOVE */ |
| 518 | struct ctk_label titlebutton; |
| 519 | #endif /* CTK_CONF_WINDOWMOVE */ |
| 520 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 521 | unsigned char x, /**< The x coordinate of the window, in |
| 522 | characters. */ |
| 523 | y; /**< The y coordinate of the window, in |
| 524 | characters. */ |
| 525 | unsigned char w, /**< The width of the window, excluding |
| 526 | window borders. */ |
| 527 | h; /**< The height of the window, |
| 528 | excluding window borders. */ |
adamdunkels | 1d5eb5e | 2003-03-28 12:10:39 +0000 | [diff] [blame] | 529 | |
| 530 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 531 | struct ctk_widget *inactive; /**< The list if widgets that cannot be |
| 532 | selected by the user. Labels and |
| 533 | separator widgets are placed on this |
| 534 | list. */ |
| 535 | struct ctk_widget *active; /**< The list of widgets that can be |
| 536 | selected by the user. Buttons, |
| 537 | hyperlinks, text entry fields, etc., |
| 538 | are placed on this list. */ |
| 539 | struct ctk_widget *focused; /**< A pointer to the widget on the |
| 540 | active list that is currently |
| 541 | selected, or NULL if no widget is |
| 542 | selected. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 543 | }; |
| 544 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 545 | /** |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 546 | * Representation of an individual menu item. |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 547 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 548 | struct ctk_menuitem { |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame] | 549 | const char *title; /**< The menu items text. */ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 550 | unsigned char titlelen;/**< The length of the item text, cached for |
| 551 | speed. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 552 | }; |
| 553 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 554 | /** |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 555 | * Representation of an individual menu. |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 556 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 557 | struct ctk_menu { |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 558 | struct ctk_menu *next; /**< Apointer to the next menu, or is NULL if |
| 559 | this is the last menu, and should be used |
| 560 | by the ctk-draw module when stepping |
| 561 | through the menus when drawing them on |
| 562 | screen. */ |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame] | 563 | const char *title; /**< The menu title. */ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 564 | unsigned char titlelen;/**< The length of the title in |
| 565 | characters. Cached for speed reasons. */ |
adamdunkels | 78c03dc | 2003-04-09 13:45:05 +0000 | [diff] [blame] | 566 | #if CC_UNSIGNED_CHAR_BUGS |
adamdunkels | 6ccf721 | 2003-04-10 07:04:45 +0000 | [diff] [blame] | 567 | unsigned int nitems; |
| 568 | unsigned int active; |
adamdunkels | 78c03dc | 2003-04-09 13:45:05 +0000 | [diff] [blame] | 569 | #else /* CC_UNSIGNED_CHAR_BUGS */ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 570 | unsigned char nitems; /**< The total number of menu items in the |
| 571 | menu. */ |
| 572 | unsigned char active; /**< The currently active menu item. */ |
adamdunkels | 78c03dc | 2003-04-09 13:45:05 +0000 | [diff] [blame] | 573 | #endif /* CC_UNSIGNED_CHAR_BUGS */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 574 | struct ctk_menuitem items[CTK_CONF_MAXMENUITEMS]; |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 575 | /**< The array which contains all the menu |
| 576 | items. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 577 | }; |
| 578 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 579 | /** |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 580 | * Representation of the menu bar. |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 581 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 582 | struct ctk_menus { |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 583 | struct ctk_menu *menus; /**< A pointer to a linked list of all |
| 584 | menus, including the open menu and |
| 585 | the desktop menu.*/ |
| 586 | struct ctk_menu *open; /**< The currently open menu, if |
| 587 | any. If all menus are closed, this |
| 588 | item is NULL: */ |
| 589 | struct ctk_menu *desktopmenu; /**< A pointer to the "Desktop" menu |
| 590 | that can be used for drawing the |
| 591 | desktop menu in a special way (such |
| 592 | as drawing it at the rightmost |
| 593 | position). */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 594 | }; |
| 595 | |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 596 | /** @} */ |
| 597 | |
| 598 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 599 | /** |
| 600 | * \internal The structure describing a Contiki desktop. |
| 601 | */ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 602 | struct ctk_desktop { |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame] | 603 | const char *name; /**< The name of the desktop. */ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 604 | |
| 605 | struct ctk_window desktop_window; /**< The background window which |
| 606 | contains tha desktop icons. */ |
| 607 | struct ctk_window *windows; /**< The list of open windows. */ |
| 608 | struct ctk_window *dialog; /**< A pointer to the open dialog, or |
| 609 | NULL if no dialog is open. */ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 610 | |
| 611 | #if CTK_CONF_MENUS |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 612 | struct ctk_menus menus; /**< The list of desktop menus. */ |
| 613 | struct ctk_menu *lastmenu; /**< Pointer to the menu that was last open. */ |
| 614 | struct ctk_menu desktopmenu;/**< The desktop menu. */ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 615 | #endif /* CTK_CONF_MENUS */ |
| 616 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 617 | unsigned char height, /**< The height of the desktop, in characters. */ |
| 618 | width; /**< The width of the desktop, in characters. */ |
| 619 | |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 620 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 621 | #define CTK_REDRAW_NONE 0 /**< \internal Redraw flag: nothing |
| 622 | to be redrawn. */ |
| 623 | #define CTK_REDRAW_ALL 1 /**< \internal Redraw flag: |
| 624 | everything should be redrawn. */ |
| 625 | #define CTK_REDRAW_WINDOWS 2 /**< \internal Redraw flag: redraw |
| 626 | windows in queue.*/ |
| 627 | #define CTK_REDRAW_WIDGETS 4 /**< \internal Redraw flag: redraw |
| 628 | widgets in queue. */ |
| 629 | #define CTK_REDRAW_MENUS 8 /**< \internal Redraw flag: redraw |
| 630 | menus. */ |
| 631 | #define CTK_REDRAW_PART 16 /**< \internal Redraw flag: redraw |
| 632 | parts of the desktop. */ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 633 | |
| 634 | #ifndef CTK_CONF_MAX_REDRAWWIDGETS |
| 635 | #define CTK_CONF_MAX_REDRAWWIDGETS 8 |
| 636 | #endif /* CTK_CONF_MAX_REDRAWWIDGETS */ |
| 637 | #ifndef CTK_CONF_MAX_REDRAWWINDOWS |
| 638 | #define CTK_CONF_MAX_REDRAWWINDOWS 8 |
| 639 | #endif /* CTK_CONF_MAX_REDRAWWINDOWS */ |
| 640 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 641 | unsigned char redraw; /**< The redraw flag. */ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 642 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 643 | struct ctk_widget *redraw_widgets[CTK_CONF_MAX_REDRAWWIDGETS]; /**< The list of widgets to be redrawn. */ |
| 644 | 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] | 645 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 646 | struct ctk_window *redraw_windows[CTK_CONF_MAX_REDRAWWINDOWS]; /**< The list of windows to be redrawn. */ |
| 647 | 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] | 648 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 649 | unsigned char redraw_y1, /**< The lower y bound of the area to be redrawn if CTK_REDRAW_PART is flagged. */ |
| 650 | 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] | 651 | }; |
| 652 | |
| 653 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 654 | /* Global CTK modes. */ |
| 655 | #define CTK_MODE_NORMAL 0 |
| 656 | #define CTK_MODE_WINDOWMOVE 1 |
| 657 | #define CTK_MODE_SCREENSAVER 2 |
| 658 | #define CTK_MODE_EXTERNAL 3 |
| 659 | |
| 660 | /* General ctk functions. */ |
| 661 | void ctk_init(void); |
adamdunkels | 28ad2b3 | 2004-08-09 20:30:50 +0000 | [diff] [blame] | 662 | void ctk_restore(void); |
| 663 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 664 | void ctk_mode_set(unsigned char mode); |
| 665 | unsigned char ctk_mode_get(void); |
adamdunkels | 9795b2e | 2003-08-09 23:32:37 +0000 | [diff] [blame] | 666 | /*void ctk_redraw(void);*/ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 667 | |
| 668 | /* Functions for manipulating windows. */ |
| 669 | void ctk_window_new(struct ctk_window *window, |
| 670 | unsigned char w, unsigned char h, |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame] | 671 | const char *title); |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 672 | void ctk_window_clear(struct ctk_window *w); |
| 673 | void ctk_window_open(struct ctk_window *w); |
oliverschmidt | cd6c30b | 2005-05-05 20:54:16 +0000 | [diff] [blame] | 674 | #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] | 675 | void ctk_window_close(struct ctk_window *w); |
| 676 | void ctk_window_redraw(struct ctk_window *w); |
| 677 | #define ctk_window_isopen(w) ((w)->next != NULL) |
| 678 | |
| 679 | |
| 680 | /* Functions for manipulating dialogs. */ |
| 681 | void ctk_dialog_new(struct ctk_window *window, |
| 682 | unsigned char w, unsigned char h); |
| 683 | void ctk_dialog_open(struct ctk_window *d); |
| 684 | void ctk_dialog_close(void); |
| 685 | |
| 686 | /* Functions for manipulating menus. */ |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame] | 687 | void ctk_menu_new(struct ctk_menu *menu, const char *title); |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 688 | void ctk_menu_add(struct ctk_menu *menu); |
| 689 | void ctk_menu_remove(struct ctk_menu *menu); |
Adrien Destugues | 69a6e72 | 2017-06-03 10:17:17 +0200 | [diff] [blame] | 690 | unsigned char ctk_menuitem_add(struct ctk_menu *menu, const char *name); |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 691 | |
| 692 | /* Functions for icons. */ |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 693 | |
| 694 | /** |
| 695 | * \addtogroup ctkappfunc |
| 696 | * @{ |
| 697 | */ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 698 | /** |
| 699 | * Add an icon to the desktop. |
| 700 | * |
| 701 | * \param icon The icon to be added. |
adamdunkels | 0404ef1 | 2003-09-04 19:36:04 +0000 | [diff] [blame] | 702 | * |
| 703 | * \param id The process ID of the process that owns the icon. |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 704 | */ |
adamdunkels | 0404ef1 | 2003-09-04 19:36:04 +0000 | [diff] [blame] | 705 | #define CTK_ICON_ADD(icon, id) ctk_icon_add((struct ctk_widget *)icon, id) |
| 706 | void ctk_icon_add(struct ctk_widget *icon, ek_id_t id); |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 707 | |
| 708 | /* Functions for manipulating widgets. */ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 709 | |
| 710 | /** |
| 711 | * Add a widget to a window. |
| 712 | * |
| 713 | * \param win The window to which the widget should be added. |
| 714 | * \param widg The widget to be added. |
| 715 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 716 | #define CTK_WIDGET_ADD(win, widg) \ |
| 717 | ctk_widget_add(win, (struct ctk_widget *)widg) |
adamdunkels | a6557e4 | 2003-08-11 22:27:51 +0000 | [diff] [blame] | 718 | void CC_FASTCALL ctk_widget_add(struct ctk_window *window, |
| 719 | struct ctk_widget *widget); |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 720 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 721 | /** |
| 722 | * Set focus to a widget. |
| 723 | * |
| 724 | * \param win The widget's window. |
| 725 | * \param widg The widget |
| 726 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 727 | #define CTK_WIDGET_FOCUS(win, widg) \ |
| 728 | (win)->focused = (struct ctk_widget *)(widg) |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 729 | |
| 730 | /** |
| 731 | * Add a widget to the redraw queue. |
| 732 | * |
| 733 | * \param widg The widget to be redrawn. |
| 734 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 735 | #define CTK_WIDGET_REDRAW(widg) \ |
| 736 | ctk_widget_redraw((struct ctk_widget *)widg) |
| 737 | void ctk_widget_redraw(struct ctk_widget *w); |
| 738 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 739 | /** |
| 740 | * Obtain the type of a widget. |
| 741 | * |
| 742 | * \param w The widget. |
| 743 | */ |
adamdunkels | 3a08a49 | 2003-04-11 20:16:02 +0000 | [diff] [blame] | 744 | #define CTK_WIDGET_TYPE(w) ((w)->type) |
| 745 | |
adamdunkels | e8b21d0 | 2003-04-24 17:18:27 +0000 | [diff] [blame] | 746 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 747 | /** |
| 748 | * Sets the width of a widget. |
| 749 | * |
| 750 | * \param widget The widget. |
| 751 | * \param width The width of the widget, in characters. |
| 752 | */ |
adamdunkels | e8b21d0 | 2003-04-24 17:18:27 +0000 | [diff] [blame] | 753 | #define CTK_WIDGET_SET_WIDTH(widget, width) do { \ |
| 754 | ((struct ctk_widget *)(widget))->w = (width); } while(0) |
| 755 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 756 | /** |
| 757 | * Retrieves the x position of a widget, relative to the window in |
| 758 | * which the widget is contained. |
| 759 | * |
| 760 | * \param w The widget. |
| 761 | * \return The x position of the widget. |
| 762 | */ |
adamdunkels | e8b21d0 | 2003-04-24 17:18:27 +0000 | [diff] [blame] | 763 | #define CTK_WIDGET_XPOS(w) (((struct ctk_widget *)(w))->x) |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 764 | |
| 765 | /** |
| 766 | * Sets the x position of a widget, relative to the window in |
| 767 | * which the widget is contained. |
| 768 | * |
| 769 | * \param w The widget. |
| 770 | * \param xpos The x position of the widget. |
| 771 | */ |
| 772 | #define CTK_WIDGET_SET_XPOS(w, xpos) \ |
| 773 | ((struct ctk_widget *)(w))->x = (xpos) |
| 774 | /** |
| 775 | * Retrieves the y position of a widget, relative to the window in |
| 776 | * which the widget is contained. |
| 777 | * |
| 778 | * \param w The widget. |
| 779 | * \return The y position of the widget. |
| 780 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 781 | #define CTK_WIDGET_YPOS(w) (((struct ctk_widget *)(w))->y) |
| 782 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 783 | /** |
| 784 | * Sets the y position of a widget, relative to the window in |
| 785 | * which the widget is contained. |
| 786 | * |
| 787 | * \param w The widget. |
| 788 | * \param ypos The y position of the widget. |
| 789 | */ |
| 790 | #define CTK_WIDGET_SET_YPOS(w, ypos) \ |
| 791 | ((struct ctk_widget *)(w))->y = (ypos) |
| 792 | |
| 793 | /* XXX: should be removed. |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 794 | #define ctk_textentry_set_height(w, height) \ |
| 795 | (w)->widget.textentry.h = (height) |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 796 | */ |
| 797 | |
| 798 | /** \def ctk_label_set_height(w, height) |
| 799 | * \brief Set the height of a label. |
| 800 | * |
| 801 | * \param w The CTK label widget. |
| 802 | * \param height The new height of the label. |
| 803 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 804 | #define ctk_label_set_height(w, height) \ |
| 805 | (w)->widget.label.h = (height) |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 806 | |
| 807 | /** |
| 808 | * Set the text of a label. |
| 809 | * |
| 810 | * \param l The CTK label widget. |
| 811 | * \param t The new text of the label. |
| 812 | */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 813 | #define ctk_label_set_text(l, t) (l)->text = (t) |
| 814 | |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 815 | /** |
| 816 | * Set the text of a button. |
| 817 | * |
| 818 | * \param b The CTK button widget. |
| 819 | * \param t The new text of the button. |
| 820 | */ |
adamdunkels | 1d5eb5e | 2003-03-28 12:10:39 +0000 | [diff] [blame] | 821 | #define ctk_button_set_text(b, t) (b)->text = (t) |
| 822 | |
adamdunkels | 58917a8 | 2003-04-18 00:18:38 +0000 | [diff] [blame] | 823 | #define ctk_bitmap_set_bitmap(b, m) (b)->bitmap = (m) |
| 824 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 825 | #define CTK_BUTTON_NEW(widg, xpos, ypos, width, buttontext) \ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 826 | do { (widg)->window = NULL; \ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 827 | (widg)->next = NULL; \ |
| 828 | (widg)->type = CTK_WIDGET_BUTTON; \ |
| 829 | (widg)->x = (xpos); \ |
| 830 | (widg)->y = (ypos); \ |
| 831 | (widg)->w = (width); \ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 832 | (widg)->h = 1; \ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 833 | (widg)->text = (buttontext); \ |
| 834 | } while(0) |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 835 | |
| 836 | #define CTK_LABEL_NEW(widg, xpos, ypos, width, height, labeltext) \ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 837 | do { (widg)->window = NULL; \ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 838 | (widg)->next = NULL; \ |
| 839 | (widg)->type = CTK_WIDGET_LABEL; \ |
| 840 | (widg)->x = (xpos); \ |
| 841 | (widg)->y = (ypos); \ |
| 842 | (widg)->w = (width); \ |
| 843 | (widg)->h = (height); \ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 844 | (widg)->text = (labeltext); \ |
| 845 | } while(0) |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 846 | |
adamdunkels | 58917a8 | 2003-04-18 00:18:38 +0000 | [diff] [blame] | 847 | #define CTK_BITMAP_NEW(widg, xpos, ypos, width, height, bmap) \ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 848 | do { (widg)->window = NULL; \ |
adamdunkels | 58917a8 | 2003-04-18 00:18:38 +0000 | [diff] [blame] | 849 | (widg)->next = NULL; \ |
| 850 | (widg)->type = CTK_WIDGET_BITMAP; \ |
| 851 | (widg)->x = (xpos); \ |
| 852 | (widg)->y = (ypos); \ |
| 853 | (widg)->w = (width); \ |
| 854 | (widg)->h = (height); \ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 855 | (widg)->bitmap = (bmap); \ |
| 856 | } while(0) |
adamdunkels | 58917a8 | 2003-04-18 00:18:38 +0000 | [diff] [blame] | 857 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 858 | #define CTK_TEXTENTRY_NEW(widg, xxpos, yypos, width, height, textptr, textlen) \ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 859 | do { (widg)->window = NULL; \ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 860 | (widg)->next = NULL; \ |
| 861 | (widg)->type = CTK_WIDGET_TEXTENTRY; \ |
| 862 | (widg)->x = (xxpos); \ |
| 863 | (widg)->y = (yypos); \ |
| 864 | (widg)->w = (width); \ |
oliverschmidt | 0096f6a | 2005-05-04 21:50:17 +0000 | [diff] [blame] | 865 | (widg)->h = 1; \ |
| 866 | (widg)->text = (textptr); \ |
| 867 | (widg)->len = (textlen); \ |
| 868 | (widg)->state = CTK_TEXTENTRY_NORMAL; \ |
| 869 | (widg)->xpos = 0; \ |
| 870 | (widg)->ypos = 0; \ |
| 871 | (widg)->input = NULL; \ |
| 872 | } while(0) |
| 873 | |
| 874 | #define CTK_TEXTENTRY_INPUT_NEW(widg, xxpos, yypos, width, height, textptr, textlen, iinput) \ |
| 875 | do { (widg)->window = NULL; \ |
| 876 | (widg)->next = NULL; \ |
| 877 | (widg)->type = CTK_WIDGET_TEXTENTRY; \ |
| 878 | (widg)->x = (xxpos); \ |
| 879 | (widg)->y = (yypos); \ |
| 880 | (widg)->w = (width); \ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 881 | (widg)->h = (height); \ |
| 882 | (widg)->text = (textptr); \ |
| 883 | (widg)->len = (textlen); \ |
| 884 | (widg)->state = CTK_TEXTENTRY_NORMAL; \ |
| 885 | (widg)->xpos = 0; \ |
adamdunkels | 28ad2b3 | 2004-08-09 20:30:50 +0000 | [diff] [blame] | 886 | (widg)->ypos = 0; \ |
oliverschmidt | 0096f6a | 2005-05-04 21:50:17 +0000 | [diff] [blame] | 887 | (widg)->input = (ctk_textentry_input)(iinput); \ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 888 | } while(0) |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 889 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 890 | #define CTK_HYPERLINK_NEW(widg, xpos, ypos, width, linktext, linkurl) \ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 891 | do { (widg)->window = NULL; \ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 892 | (widg)->next = NULL; \ |
| 893 | (widg)->type = CTK_WIDGET_HYPERLINK; \ |
| 894 | (widg)->x = (xpos); \ |
| 895 | (widg)->y = (ypos); \ |
| 896 | (widg)->w = (width); \ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 897 | (widg)->h = 1; \ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 898 | (widg)->text = (linktext); \ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 899 | (widg)->url = (linkurl); \ |
| 900 | } while(0) |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 901 | |
adamdunkels | e2f4d2a | 2003-04-28 23:21:42 +0000 | [diff] [blame] | 902 | /* Desktop interface. */ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 903 | void ctk_desktop_redraw(struct ctk_desktop *d); |
| 904 | unsigned char ctk_desktop_width(struct ctk_desktop *d); |
| 905 | unsigned char ctk_desktop_height(struct ctk_desktop *d); |
adamdunkels | e2f4d2a | 2003-04-28 23:21:42 +0000 | [diff] [blame] | 906 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 907 | /* Signals. */ |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 908 | extern ek_event_t ctk_signal_keypress, |
adamdunkels | 3a08a49 | 2003-04-11 20:16:02 +0000 | [diff] [blame] | 909 | ctk_signal_widget_activate, |
| 910 | ctk_signal_widget_select, |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 911 | ctk_signal_timer, |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 912 | ctk_signal_menu_activate, |
adamdunkels | c490286 | 2003-04-09 00:30:45 +0000 | [diff] [blame] | 913 | ctk_signal_window_close, |
| 914 | ctk_signal_pointer_move, |
adamdunkels | 3a08a49 | 2003-04-11 20:16:02 +0000 | [diff] [blame] | 915 | ctk_signal_pointer_button; |
| 916 | |
adamdunkels | e8b21d0 | 2003-04-24 17:18:27 +0000 | [diff] [blame] | 917 | #if CTK_CONF_SCREENSAVER |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 918 | extern ek_event_t ctk_signal_screensaver_stop, |
adamdunkels | 9795b2e | 2003-08-09 23:32:37 +0000 | [diff] [blame] | 919 | ctk_signal_screensaver_start; |
adamdunkels | e2f4d2a | 2003-04-28 23:21:42 +0000 | [diff] [blame] | 920 | |
| 921 | extern unsigned short ctk_screensaver_timeout; |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 922 | /** |
| 923 | * Set the screensaver timeout, in seconds. |
| 924 | * |
| 925 | * \param t The timeout in seconds. |
| 926 | */ |
adamdunkels | e2f4d2a | 2003-04-28 23:21:42 +0000 | [diff] [blame] | 927 | #define CTK_SCREENSAVER_SET_TIMEOUT(t) ctk_screensaver_timeout = (t) |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 928 | /** |
| 929 | * Obtain the screensaver timeout, in seconds. |
| 930 | * |
| 931 | * \raturn The timeout in seconds. |
| 932 | */ |
adamdunkels | e2f4d2a | 2003-04-28 23:21:42 +0000 | [diff] [blame] | 933 | #define CTK_SCREENSAVER_TIMEOUT() ctk_screensaver_timeout |
adamdunkels | e8b21d0 | 2003-04-24 17:18:27 +0000 | [diff] [blame] | 934 | #endif /* CTK_CONF_SCREENSAVER */ |
| 935 | |
adamdunkels | 3a08a49 | 2003-04-11 20:16:02 +0000 | [diff] [blame] | 936 | /* These should no longer be used: */ |
adamdunkels | 1f9a9a1 | 2004-07-04 11:42:47 +0000 | [diff] [blame] | 937 | extern ek_event_t ctk_signal_button_activate, |
adamdunkels | 3a08a49 | 2003-04-11 20:16:02 +0000 | [diff] [blame] | 938 | ctk_signal_button_hover, |
| 939 | ctk_signal_hyperlink_activate, |
| 940 | ctk_signal_hyperlink_hover; |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 941 | /** @} */ |
| 942 | |
| 943 | /** |
| 944 | * \addtogroup ctkdraw |
| 945 | * @{ |
| 946 | */ |
adamdunkels | 3a08a49 | 2003-04-11 20:16:02 +0000 | [diff] [blame] | 947 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 948 | /* Focus flags */ |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 949 | /** Widget focus flag: no focus. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 950 | #define CTK_FOCUS_NONE 0 |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 951 | /** Widget focus flag: widget has focus. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 952 | #define CTK_FOCUS_WIDGET 1 |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 953 | /** Widget focus flag: widget's window is the foremost one. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 954 | #define CTK_FOCUS_WINDOW 2 |
adamdunkels | b27d85a | 2003-09-01 22:23:26 +0000 | [diff] [blame] | 955 | /** Widget focus flag: widget is in a dialog. */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 956 | #define CTK_FOCUS_DIALOG 4 |
| 957 | |
adamdunkels | e937ded | 2003-10-01 07:53:57 +0000 | [diff] [blame] | 958 | /** @} */ |
| 959 | /** @} */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 960 | #endif /* __CTK_H__ */ |