adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2002, Adam Dunkels. |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions |
| 7 | * are met: |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above |
| 11 | * copyright notice, this list of conditions and the following |
| 12 | * disclaimer in the documentation and/or other materials provided |
| 13 | * with the distribution. |
| 14 | * 3. All advertising materials mentioning features or use of this |
| 15 | * software must display the following acknowledgement: |
| 16 | * This product includes software developed by Adam Dunkels. |
| 17 | * 4. The name of the author may not be used to endorse or promote |
| 18 | * products derived from this software without specific prior |
| 19 | * written permission. |
| 20 | * |
| 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS |
| 22 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 25 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
| 27 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | * |
| 33 | * This file is part of the "ctk" console GUI toolkit for cc65 |
| 34 | * |
adamdunkels | a6557e4 | 2003-08-11 22:27:51 +0000 | [diff] [blame^] | 35 | * $Id: ctk.h,v 1.13 2003/08/11 22:27:51 adamdunkels Exp $ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 36 | * |
| 37 | */ |
| 38 | |
| 39 | #ifndef __CTK_H__ |
| 40 | #define __CTK_H__ |
| 41 | |
adamdunkels | a6557e4 | 2003-08-11 22:27:51 +0000 | [diff] [blame^] | 42 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 43 | #include "ctk-conf.h" |
adamdunkels | a6557e4 | 2003-08-11 22:27:51 +0000 | [diff] [blame^] | 44 | #include "ctk-arch.h" |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 45 | #include "ek.h" |
| 46 | |
adamdunkels | 78c03dc | 2003-04-09 13:45:05 +0000 | [diff] [blame] | 47 | #include "cc.h" |
| 48 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 49 | /* Defintions for the CTK widget types. */ |
| 50 | #define CTK_WIDGET_SEPARATOR 1 |
| 51 | #define CTK_WIDGET_LABEL 2 |
| 52 | #define CTK_WIDGET_BUTTON 3 |
| 53 | #define CTK_WIDGET_HYPERLINK 4 |
| 54 | #define CTK_WIDGET_TEXTENTRY 5 |
adamdunkels | 1d5eb5e | 2003-03-28 12:10:39 +0000 | [diff] [blame] | 55 | #define CTK_WIDGET_BITMAP 6 |
| 56 | #define CTK_WIDGET_ICON 7 |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 57 | |
| 58 | struct ctk_widget; |
| 59 | |
| 60 | #define CTK_SEPARATOR(x, y, w) \ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 61 | NULL, NULL, x, y, CTK_WIDGET_SEPARATOR, w, 1 |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 62 | struct ctk_separator { |
| 63 | struct ctk_widget *next; |
| 64 | struct ctk_window *window; |
| 65 | unsigned char x, y; |
| 66 | unsigned char type; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 67 | unsigned char w, h; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | #define CTK_BUTTON(x, y, w, text) \ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 71 | NULL, NULL, x, y, CTK_WIDGET_BUTTON, w, 1, text |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 72 | struct ctk_button { |
| 73 | struct ctk_widget *next; |
| 74 | struct ctk_window *window; |
| 75 | unsigned char x, y; |
| 76 | unsigned char type; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 77 | unsigned char w, h; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 78 | char *text; |
| 79 | }; |
| 80 | |
| 81 | #define CTK_LABEL(x, y, w, h, text) \ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 82 | NULL, NULL, x, y, CTK_WIDGET_LABEL, w, h, text, |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 83 | struct ctk_label { |
| 84 | struct ctk_widget *next; |
| 85 | struct ctk_window *window; |
| 86 | unsigned char x, y; |
| 87 | unsigned char type; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 88 | unsigned char w, h; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 89 | char *text; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | #define CTK_HYPERLINK(x, y, w, text, url) \ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 93 | NULL, NULL, x, y, CTK_WIDGET_HYPERLINK, w, 1, text, url |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 94 | struct ctk_hyperlink { |
| 95 | struct ctk_widget *next; |
| 96 | struct ctk_window *window; |
| 97 | unsigned char x, y; |
| 98 | unsigned char type; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 99 | unsigned char w, h; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 100 | char *text; |
| 101 | char *url; |
| 102 | }; |
| 103 | |
| 104 | /* Editing modes of the CTK textentry widget. */ |
| 105 | #define CTK_TEXTENTRY_NORMAL 0 |
| 106 | #define CTK_TEXTENTRY_EDIT 1 |
| 107 | |
| 108 | |
| 109 | #define CTK_TEXTENTRY(x, y, w, h, text, len) \ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 110 | NULL, NULL, x, y, CTK_WIDGET_TEXTENTRY, w, h, text, len, \ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 111 | CTK_TEXTENTRY_NORMAL, 0, 0 |
| 112 | struct ctk_textentry { |
| 113 | struct ctk_widget *next; |
| 114 | struct ctk_window *window; |
| 115 | unsigned char x, y; |
| 116 | unsigned char type; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 117 | unsigned char w, h; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 118 | char *text; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 119 | unsigned char len; |
| 120 | unsigned char state; |
| 121 | unsigned char xpos, ypos; |
| 122 | }; |
| 123 | |
| 124 | |
| 125 | #define CTK_ICON(title, bitmap, textmap) \ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 126 | NULL, NULL, 0, 0, CTK_WIDGET_ICON, 2, 4, title, 0, bitmap, textmap |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 127 | struct ctk_icon { |
| 128 | struct ctk_widget *next; |
| 129 | struct ctk_window *window; |
| 130 | unsigned char x, y; |
| 131 | unsigned char type; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 132 | unsigned char w, h; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 133 | char *title; |
| 134 | ek_id_t owner; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 135 | unsigned char *bitmap; |
| 136 | char *textmap; |
| 137 | }; |
| 138 | |
| 139 | #define CTK_BITMAP(x, y, w, h, bitmap) \ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 140 | NULL, NULL, x, y, CTK_WIDGET_BITMAP, w, h, bitmap, |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 141 | struct ctk_bitmap { |
| 142 | struct ctk_widget *next; |
| 143 | struct ctk_window *window; |
| 144 | unsigned char x, y; |
| 145 | unsigned char type; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 146 | unsigned char w, h; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 147 | unsigned char *bitmap; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 148 | }; |
| 149 | |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 150 | #define CTK_TEXTMAP_NORMAL 0 |
| 151 | #define CTK_TEXTMAP_ACTIVE 1 |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 152 | |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 153 | #define CTK_TEXTMAP(x, y, w, h, textmap, flags) \ |
| 154 | NULL, NULL, x, y, CTK_WIDGET_LABEL, w, h, text, flags, CTK_TEXTMAP_NORMAL |
| 155 | struct ctk_textmap { |
| 156 | struct ctk_widget *next; |
| 157 | struct ctk_window *window; |
| 158 | unsigned char x, y; |
| 159 | unsigned char type; |
| 160 | unsigned char w, h; |
| 161 | char *textmap; |
| 162 | unsigned char flags; |
| 163 | unsigned char state; |
| 164 | }; |
| 165 | |
| 166 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 167 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 168 | struct ctk_widget_button { |
| 169 | char *text; |
| 170 | }; |
| 171 | |
| 172 | struct ctk_widget_label { |
| 173 | char *text; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 174 | }; |
| 175 | |
| 176 | struct ctk_widget_hyperlink { |
| 177 | char *text; |
| 178 | char *url; |
| 179 | }; |
| 180 | |
| 181 | struct ctk_widget_textentry { |
| 182 | char *text; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 183 | unsigned char len; |
| 184 | unsigned char state; |
| 185 | unsigned char xpos, ypos; |
| 186 | }; |
| 187 | |
| 188 | struct ctk_widget_icon { |
| 189 | char *title; |
| 190 | ek_id_t owner; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 191 | unsigned char *bitmap; |
| 192 | char *textmap; |
| 193 | }; |
| 194 | |
| 195 | struct ctk_widget_bitmap { |
| 196 | unsigned char *bitmap; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 197 | }; |
| 198 | |
| 199 | struct ctk_widget { |
| 200 | struct ctk_widget *next; |
| 201 | struct ctk_window *window; |
| 202 | unsigned char x, y; |
| 203 | unsigned char type; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 204 | unsigned char w, h; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 205 | union { |
| 206 | struct ctk_widget_label label; |
| 207 | struct ctk_widget_button button; |
| 208 | struct ctk_widget_hyperlink hyperlink; |
| 209 | struct ctk_widget_textentry textentry; |
| 210 | struct ctk_widget_icon icon; |
adamdunkels | 1d5eb5e | 2003-03-28 12:10:39 +0000 | [diff] [blame] | 211 | struct ctk_widget_bitmap bitmap; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 212 | } widget; |
| 213 | }; |
| 214 | |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 215 | struct ctk_desktop; |
| 216 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 217 | /* Definition of the CTK window structure. */ |
| 218 | struct ctk_window { |
| 219 | struct ctk_window *next, *prev; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 220 | struct ctk_desktop *desktop; |
| 221 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 222 | ek_id_t owner; |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 223 | |
adamdunkels | 1d5eb5e | 2003-03-28 12:10:39 +0000 | [diff] [blame] | 224 | char *title; |
| 225 | unsigned char titlelen; |
| 226 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 227 | #if CTK_CONF_WINDOWCLOSE |
| 228 | struct ctk_button closebutton; |
| 229 | #else /* CTK_CONF_WINDOWCLOSE */ |
| 230 | struct ctk_label closebutton; |
| 231 | #endif /* CTK_CONF_WINDOWCLOSE */ |
| 232 | |
| 233 | #if CTK_CONF_WINDOWMOVE |
| 234 | struct ctk_button titlebutton; |
| 235 | #else /* CTK_CONF_WINDOWMOVE */ |
| 236 | struct ctk_label titlebutton; |
| 237 | #endif /* CTK_CONF_WINDOWMOVE */ |
| 238 | |
adamdunkels | 1d5eb5e | 2003-03-28 12:10:39 +0000 | [diff] [blame] | 239 | unsigned char x, y; |
| 240 | unsigned char w, h; |
| 241 | |
| 242 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 243 | struct ctk_widget *inactive; |
| 244 | struct ctk_widget *active; |
| 245 | struct ctk_widget *focused; |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 246 | }; |
| 247 | |
| 248 | struct ctk_menuitem { |
| 249 | char *title; |
| 250 | unsigned char titlelen; |
| 251 | }; |
| 252 | |
| 253 | struct ctk_menu { |
| 254 | struct ctk_menu *next; |
| 255 | char *title; |
| 256 | unsigned char titlelen; |
adamdunkels | 78c03dc | 2003-04-09 13:45:05 +0000 | [diff] [blame] | 257 | #if CC_UNSIGNED_CHAR_BUGS |
adamdunkels | 6ccf721 | 2003-04-10 07:04:45 +0000 | [diff] [blame] | 258 | unsigned int nitems; |
| 259 | unsigned int active; |
adamdunkels | 78c03dc | 2003-04-09 13:45:05 +0000 | [diff] [blame] | 260 | #else /* CC_UNSIGNED_CHAR_BUGS */ |
| 261 | unsigned char nitems; |
| 262 | unsigned char active; |
| 263 | #endif /* CC_UNSIGNED_CHAR_BUGS */ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 264 | struct ctk_menuitem items[CTK_CONF_MAXMENUITEMS]; |
| 265 | }; |
| 266 | |
| 267 | struct ctk_menus { |
| 268 | struct ctk_menu *menus; |
| 269 | struct ctk_menu *open; |
| 270 | struct ctk_menu *desktopmenu; |
| 271 | }; |
| 272 | |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 273 | /* Definition of the CTK desktop structure. */ |
| 274 | struct ctk_desktop { |
| 275 | char *name; |
| 276 | |
| 277 | struct ctk_window desktop_window; |
| 278 | struct ctk_window *windows; |
| 279 | struct ctk_window *dialog; |
| 280 | |
| 281 | #if CTK_CONF_MENUS |
| 282 | struct ctk_menus menus; |
| 283 | struct ctk_menu *lastmenu; |
| 284 | struct ctk_menu desktopmenu; |
| 285 | #endif /* CTK_CONF_MENUS */ |
| 286 | |
| 287 | unsigned char height, width; |
| 288 | |
| 289 | #define CTK_REDRAW_NONE 0 |
| 290 | #define CTK_REDRAW_ALL 1 |
| 291 | #define CTK_REDRAW_WINDOWS 2 |
| 292 | #define CTK_REDRAW_WIDGETS 4 |
| 293 | #define CTK_REDRAW_MENUS 8 |
| 294 | #define CTK_REDRAW_PART 16 |
| 295 | |
| 296 | #ifndef CTK_CONF_MAX_REDRAWWIDGETS |
| 297 | #define CTK_CONF_MAX_REDRAWWIDGETS 8 |
| 298 | #endif /* CTK_CONF_MAX_REDRAWWIDGETS */ |
| 299 | #ifndef CTK_CONF_MAX_REDRAWWINDOWS |
| 300 | #define CTK_CONF_MAX_REDRAWWINDOWS 8 |
| 301 | #endif /* CTK_CONF_MAX_REDRAWWINDOWS */ |
| 302 | |
| 303 | |
| 304 | |
| 305 | unsigned char redraw; |
| 306 | |
| 307 | struct ctk_widget *redraw_widgets[CTK_CONF_MAX_REDRAWWIDGETS]; |
| 308 | unsigned char redraw_widgetptr; |
| 309 | |
| 310 | struct ctk_window *redraw_windows[CTK_CONF_MAX_REDRAWWINDOWS]; |
| 311 | unsigned char redraw_windowptr; |
| 312 | |
| 313 | |
| 314 | unsigned char redraw_y1, redraw_y2; |
| 315 | }; |
| 316 | |
| 317 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 318 | /* Global CTK modes. */ |
| 319 | #define CTK_MODE_NORMAL 0 |
| 320 | #define CTK_MODE_WINDOWMOVE 1 |
| 321 | #define CTK_MODE_SCREENSAVER 2 |
| 322 | #define CTK_MODE_EXTERNAL 3 |
| 323 | |
| 324 | /* General ctk functions. */ |
| 325 | void ctk_init(void); |
| 326 | void ctk_mode_set(unsigned char mode); |
| 327 | unsigned char ctk_mode_get(void); |
adamdunkels | 9795b2e | 2003-08-09 23:32:37 +0000 | [diff] [blame] | 328 | /*void ctk_redraw(void);*/ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 329 | |
| 330 | /* Functions for manipulating windows. */ |
| 331 | void ctk_window_new(struct ctk_window *window, |
| 332 | unsigned char w, unsigned char h, |
| 333 | char *title); |
| 334 | void ctk_window_clear(struct ctk_window *w); |
| 335 | void ctk_window_open(struct ctk_window *w); |
| 336 | #define ctk_window_move(w,xpos,ypos) do {(w)->x=xpos; (w)->y=ypos;}while(0) |
| 337 | void ctk_window_close(struct ctk_window *w); |
| 338 | void ctk_window_redraw(struct ctk_window *w); |
| 339 | #define ctk_window_isopen(w) ((w)->next != NULL) |
| 340 | |
| 341 | |
| 342 | /* Functions for manipulating dialogs. */ |
| 343 | void ctk_dialog_new(struct ctk_window *window, |
| 344 | unsigned char w, unsigned char h); |
| 345 | void ctk_dialog_open(struct ctk_window *d); |
| 346 | void ctk_dialog_close(void); |
| 347 | |
| 348 | /* Functions for manipulating menus. */ |
| 349 | void ctk_menu_new(struct ctk_menu *menu, char *title); |
| 350 | void ctk_menu_add(struct ctk_menu *menu); |
| 351 | void ctk_menu_remove(struct ctk_menu *menu); |
| 352 | unsigned char ctk_menuitem_add(struct ctk_menu *menu, char *name); |
| 353 | |
| 354 | /* Functions for icons. */ |
| 355 | #define CTK_ICON_ADD(icon, id) ctk_icon_add((struct ctk_widget *)icon, id) |
| 356 | void ctk_icon_add(struct ctk_widget *icon, ek_id_t id); |
| 357 | |
| 358 | /* Functions for manipulating widgets. */ |
| 359 | #define CTK_WIDGET_ADD(win, widg) \ |
| 360 | ctk_widget_add(win, (struct ctk_widget *)widg) |
adamdunkels | a6557e4 | 2003-08-11 22:27:51 +0000 | [diff] [blame^] | 361 | void CC_FASTCALL ctk_widget_add(struct ctk_window *window, |
| 362 | struct ctk_widget *widget); |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 363 | |
| 364 | #define CTK_WIDGET_FOCUS(win, widg) \ |
| 365 | (win)->focused = (struct ctk_widget *)(widg) |
| 366 | #define CTK_WIDGET_REDRAW(widg) \ |
| 367 | ctk_widget_redraw((struct ctk_widget *)widg) |
| 368 | void ctk_widget_redraw(struct ctk_widget *w); |
| 369 | |
adamdunkels | 3a08a49 | 2003-04-11 20:16:02 +0000 | [diff] [blame] | 370 | #define CTK_WIDGET_TYPE(w) ((w)->type) |
| 371 | |
adamdunkels | e8b21d0 | 2003-04-24 17:18:27 +0000 | [diff] [blame] | 372 | #define CTK_WIDGET_SET_XPOS(w, xpos) ((struct ctk_widget *)(w))->x = (xpos) |
| 373 | #define CTK_WIDGET_SET_YPOS(w, ypos) ((struct ctk_widget *)(w))->y = (ypos) |
| 374 | |
| 375 | #define CTK_WIDGET_SET_WIDTH(widget, width) do { \ |
| 376 | ((struct ctk_widget *)(widget))->w = (width); } while(0) |
| 377 | |
| 378 | #define CTK_WIDGET_XPOS(w) (((struct ctk_widget *)(w))->x) |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 379 | #define CTK_WIDGET_YPOS(w) (((struct ctk_widget *)(w))->y) |
| 380 | |
| 381 | #define ctk_textentry_set_height(w, height) \ |
| 382 | (w)->widget.textentry.h = (height) |
| 383 | #define ctk_label_set_height(w, height) \ |
| 384 | (w)->widget.label.h = (height) |
| 385 | #define ctk_label_set_text(l, t) (l)->text = (t) |
| 386 | |
adamdunkels | 1d5eb5e | 2003-03-28 12:10:39 +0000 | [diff] [blame] | 387 | #define ctk_button_set_text(b, t) (b)->text = (t) |
| 388 | |
adamdunkels | 58917a8 | 2003-04-18 00:18:38 +0000 | [diff] [blame] | 389 | #define ctk_bitmap_set_bitmap(b, m) (b)->bitmap = (m) |
| 390 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 391 | #define CTK_BUTTON_NEW(widg, xpos, ypos, width, buttontext) \ |
| 392 | (widg)->window = NULL; \ |
| 393 | (widg)->next = NULL; \ |
| 394 | (widg)->type = CTK_WIDGET_BUTTON; \ |
| 395 | (widg)->x = (xpos); \ |
| 396 | (widg)->y = (ypos); \ |
| 397 | (widg)->w = (width); \ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 398 | (widg)->h = 1; \ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 399 | (widg)->text = (buttontext) |
| 400 | |
| 401 | #define CTK_LABEL_NEW(widg, xpos, ypos, width, height, labeltext) \ |
| 402 | (widg)->window = NULL; \ |
| 403 | (widg)->next = NULL; \ |
| 404 | (widg)->type = CTK_WIDGET_LABEL; \ |
| 405 | (widg)->x = (xpos); \ |
| 406 | (widg)->y = (ypos); \ |
| 407 | (widg)->w = (width); \ |
| 408 | (widg)->h = (height); \ |
| 409 | (widg)->text = (labeltext) |
| 410 | |
adamdunkels | 58917a8 | 2003-04-18 00:18:38 +0000 | [diff] [blame] | 411 | #define CTK_BITMAP_NEW(widg, xpos, ypos, width, height, bmap) \ |
| 412 | (widg)->window = NULL; \ |
| 413 | (widg)->next = NULL; \ |
| 414 | (widg)->type = CTK_WIDGET_BITMAP; \ |
| 415 | (widg)->x = (xpos); \ |
| 416 | (widg)->y = (ypos); \ |
| 417 | (widg)->w = (width); \ |
| 418 | (widg)->h = (height); \ |
| 419 | (widg)->bitmap = (bmap) |
| 420 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 421 | #define CTK_TEXTENTRY_NEW(widg, xxpos, yypos, width, height, textptr, textlen) \ |
| 422 | (widg)->window = NULL; \ |
| 423 | (widg)->next = NULL; \ |
| 424 | (widg)->type = CTK_WIDGET_TEXTENTRY; \ |
| 425 | (widg)->x = (xxpos); \ |
| 426 | (widg)->y = (yypos); \ |
| 427 | (widg)->w = (width); \ |
| 428 | (widg)->h = (height); \ |
| 429 | (widg)->text = (textptr); \ |
| 430 | (widg)->len = (textlen); \ |
| 431 | (widg)->state = CTK_TEXTENTRY_NORMAL; \ |
| 432 | (widg)->xpos = 0; \ |
| 433 | (widg)->ypos = 0 |
| 434 | |
| 435 | |
| 436 | |
| 437 | #define CTK_HYPERLINK_NEW(widg, xpos, ypos, width, linktext, linkurl) \ |
| 438 | (widg)->window = NULL; \ |
| 439 | (widg)->next = NULL; \ |
| 440 | (widg)->type = CTK_WIDGET_HYPERLINK; \ |
| 441 | (widg)->x = (xpos); \ |
| 442 | (widg)->y = (ypos); \ |
| 443 | (widg)->w = (width); \ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 444 | (widg)->h = 1; \ |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 445 | (widg)->text = (linktext); \ |
| 446 | (widg)->url = (linkurl) |
| 447 | |
adamdunkels | e2f4d2a | 2003-04-28 23:21:42 +0000 | [diff] [blame] | 448 | /* Desktop interface. */ |
adamdunkels | eb9bf6c | 2003-06-30 20:45:50 +0000 | [diff] [blame] | 449 | void ctk_desktop_redraw(struct ctk_desktop *d); |
| 450 | unsigned char ctk_desktop_width(struct ctk_desktop *d); |
| 451 | unsigned char ctk_desktop_height(struct ctk_desktop *d); |
adamdunkels | e2f4d2a | 2003-04-28 23:21:42 +0000 | [diff] [blame] | 452 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 453 | /* Signals. */ |
| 454 | extern ek_signal_t ctk_signal_keypress, |
adamdunkels | 3a08a49 | 2003-04-11 20:16:02 +0000 | [diff] [blame] | 455 | ctk_signal_widget_activate, |
| 456 | ctk_signal_widget_select, |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 457 | ctk_signal_timer, |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 458 | ctk_signal_menu_activate, |
adamdunkels | c490286 | 2003-04-09 00:30:45 +0000 | [diff] [blame] | 459 | ctk_signal_window_close, |
| 460 | ctk_signal_pointer_move, |
adamdunkels | 3a08a49 | 2003-04-11 20:16:02 +0000 | [diff] [blame] | 461 | ctk_signal_pointer_button; |
| 462 | |
adamdunkels | e8b21d0 | 2003-04-24 17:18:27 +0000 | [diff] [blame] | 463 | #if CTK_CONF_SCREENSAVER |
adamdunkels | 9795b2e | 2003-08-09 23:32:37 +0000 | [diff] [blame] | 464 | extern ek_signal_t ctk_signal_screensaver_stop, |
| 465 | ctk_signal_screensaver_start; |
adamdunkels | e2f4d2a | 2003-04-28 23:21:42 +0000 | [diff] [blame] | 466 | |
| 467 | extern unsigned short ctk_screensaver_timeout; |
| 468 | #define CTK_SCREENSAVER_SET_TIMEOUT(t) ctk_screensaver_timeout = (t) |
| 469 | #define CTK_SCREENSAVER_TIMEOUT() ctk_screensaver_timeout |
adamdunkels | e8b21d0 | 2003-04-24 17:18:27 +0000 | [diff] [blame] | 470 | #endif /* CTK_CONF_SCREENSAVER */ |
| 471 | |
adamdunkels | 3a08a49 | 2003-04-11 20:16:02 +0000 | [diff] [blame] | 472 | /* These should no longer be used: */ |
| 473 | extern ek_signal_t ctk_signal_button_activate, |
| 474 | ctk_signal_button_hover, |
| 475 | ctk_signal_hyperlink_activate, |
| 476 | ctk_signal_hyperlink_hover; |
| 477 | |
adamdunkels | ca9ddcb | 2003-03-19 14:13:31 +0000 | [diff] [blame] | 478 | /* Focus flags */ |
| 479 | #define CTK_FOCUS_NONE 0 |
| 480 | #define CTK_FOCUS_WIDGET 1 |
| 481 | #define CTK_FOCUS_WINDOW 2 |
| 482 | #define CTK_FOCUS_DIALOG 4 |
| 483 | |
| 484 | |
| 485 | |
| 486 | #endif /* __CTK_H__ */ |