53 #include "contiki-conf.h"
64 #define CTK_WIDGET_SEPARATOR 1
66 #define CTK_WIDGET_LABEL 2
68 #define CTK_WIDGET_BUTTON 3
70 #define CTK_WIDGET_HYPERLINK 4
72 #define CTK_WIDGET_TEXTENTRY 5
74 #define CTK_WIDGET_BITMAP 6
76 #define CTK_WIDGET_ICON 7
82 #if CTK_CONF_WIDGET_FLAGS
83 #define CTK_WIDGET_FLAG_INITIALIZER(x) x,
85 #define CTK_WIDGET_FLAG_INITIALIZER(x)
111 #define CTK_SEPARATOR(x, y, w) \
112 NULL, NULL, x, y, CTK_WIDGET_SEPARATOR, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0)
113 struct ctk_separator {
119 #if CTK_CONF_WIDGET_FLAGS
140 #define CTK_BUTTON(x, y, w, text) \
141 NULL, NULL, x, y, CTK_WIDGET_BUTTON, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) text
148 #if CTK_CONF_WIDGET_FLAGS
171 #define CTK_LABEL(x, y, w, h, text) \
172 NULL, NULL, x, y, CTK_WIDGET_LABEL, w, h, CTK_WIDGET_FLAG_INITIALIZER(0) text,
179 #if CTK_CONF_WIDGET_FLAGS
202 #define CTK_HYPERLINK(x, y, w, text, url) \
203 NULL, NULL, x, y, CTK_WIDGET_HYPERLINK, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) text, url
204 struct ctk_hyperlink {
210 #if CTK_CONF_WIDGET_FLAGS
218 #define CTK_TEXTENTRY_NORMAL 0
220 #define CTK_TEXTENTRY_EDIT 1
229 #define CTK_TEXTENTRY_CLEAR(e) \
230 do { memset((e)->text, 0, (e)->h * ((e)->len + 1)); \
231 (e)->xpos = 0; (e)->ypos = 0; } while(0)
233 #ifdef CTK_ARCH_KEY_T
240 #define CH_ENTER '\n'
243 struct ctk_textentry;
245 struct ctk_textentry *t);
269 #define CTK_TEXTENTRY(x, y, w, h, text, len) \
270 NULL, NULL, x, y, CTK_WIDGET_TEXTENTRY, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) text, len, \
271 CTK_TEXTENTRY_NORMAL, 0, 0, ctk_textentry_input_null
273 #define CTK_TEXTENTRY(x, y, w, h, text, len) \
274 NULL, NULL, x, y, CTK_WIDGET_TEXTENTRY, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) text, len, \
275 CTK_TEXTENTRY_NORMAL, 0, 0, NULL
277 #define CTK_TEXTENTRY_INPUT(x, y, w, h, text, len, input) \
278 NULL, NULL, x, y, CTK_WIDGET_TEXTENTRY, w, h, CTK_WIDGET_FLAG_INITIALIZER(0) text, len, \
279 CTK_TEXTENTRY_NORMAL, 0, 0, input
280 struct ctk_textentry {
286 #if CTK_CONF_WIDGET_FLAGS
292 unsigned char xpos, ypos;
293 ctk_textentry_input input;
299 unsigned char ctk_textentry_input_null(
ctk_arch_key_t c,
struct ctk_textentry *t);
302 #if CTK_CONF_ICON_BITMAPS
303 #define CTK_ICON_BITMAP(bitmap) bitmap
305 #define CTK_ICON_BITMAP(bitmap) NULL
308 #if CTK_CONF_ICON_TEXTMAPS
309 #define CTK_ICON_TEXTMAP(textmap) textmap
311 #define CTK_ICON_TEXTMAP(textmap) NULL
328 #define CTK_ICON(title, bitmap, textmap) \
329 NULL, NULL, 0, 0, CTK_WIDGET_ICON, 2, 4, CTK_WIDGET_FLAG_INITIALIZER(0) \
330 title, PROCESS_NONE, \
331 CTK_ICON_BITMAP(bitmap), CTK_ICON_TEXTMAP(textmap)
338 #if CTK_CONF_WIDGET_FLAGS
342 struct process *owner;
343 unsigned char *bitmap;
347 #define CTK_BITMAP(x, y, w, h, bitmap, bitmap_width, bitmap_height) \
348 NULL, NULL, x, y, CTK_WIDGET_BITMAP, w, h, \
349 CTK_WIDGET_FLAG_INITIALIZER(0) bitmap, bitmap_width, bitmap_height
356 #if CTK_CONF_WIDGET_FLAGS
359 unsigned char *bitmap;
360 unsigned short bw, bh;
363 #define CTK_TEXTMAP_NORMAL 0
364 #define CTK_TEXTMAP_ACTIVE 1
366 #define CTK_TEXTMAP(x, y, w, h, textmap) \
367 NULL, NULL, x, y, CTK_WIDGET_LABEL, w, h, CTK_WIDGET_FLAG_INITIALIZER(0) text, CTK_TEXTMAP_NORMAL
374 #if CTK_CONF_WIDGET_FLAGS
392 struct ctk_widget_label {
399 struct ctk_widget_hyperlink {
404 struct ctk_widget_textentry {
408 unsigned char xpos, ypos;
409 ctk_textentry_input input;
412 struct ctk_widget_icon {
414 struct process *owner;
415 unsigned char *bitmap;
419 struct ctk_widget_bitmap {
420 unsigned char *bitmap;
421 unsigned short bw, bh;
465 #if CTK_CONF_WIDGET_FLAGS
470 struct ctk_widget_label label;
472 struct ctk_widget_hyperlink hyperlink;
473 struct ctk_widget_textentry textentry;
474 struct ctk_widget_icon icon;
475 struct ctk_widget_bitmap bitmap;
484 #define CTK_WIDGET_FLAG_NONE 0
485 #define CTK_WIDGET_FLAG_MONOSPACE 1
486 #define CTK_WIDGET_FLAG_CENTER 2
488 #if CTK_CONF_WIDGET_FLAGS
489 #define CTK_WIDGET_SET_FLAG(w, f) ((struct ctk_widget *)(w))->flags = (f)
491 #define CTK_WIDGET_SET_FLAG(w, f)
513 struct process *
owner;
523 #if CTK_CONF_WINDOWCLOSE
524 struct ctk_button closebutton;
528 struct ctk_label closebutton;
531 #if CTK_CONF_WINDOWMOVE
532 struct ctk_button titlebutton;
537 struct ctk_label titlebutton;
575 #ifdef CTK_CONF_MAXMENUITEMS
576 #define CTK_MAXMENUITEMS CTK_CONF_MAXMENUITEMS
578 #define CTK_MAXMENUITEMS 8
593 #if CC_UNSIGNED_CHAR_BUGS
644 unsigned char height,
648 #define CTK_REDRAW_NONE 0
650 #define CTK_REDRAW_ALL 1
652 #define CTK_REDRAW_WINDOWS 2
654 #define CTK_REDRAW_WIDGETS 4
656 #define CTK_REDRAW_MENUS 8
658 #define CTK_REDRAW_PART 16
661 #ifndef CTK_CONF_MAX_REDRAWWIDGETS
662 #define CTK_CONF_MAX_REDRAWWIDGETS 8
664 #ifndef CTK_CONF_MAX_REDRAWWINDOWS
665 #define CTK_CONF_MAX_REDRAWWINDOWS 8
668 unsigned char redraw;
670 struct ctk_widget *redraw_widgets[CTK_CONF_MAX_REDRAWWIDGETS];
671 unsigned char redraw_widgetptr;
673 struct ctk_window *redraw_windows[CTK_CONF_MAX_REDRAWWINDOWS];
674 unsigned char redraw_windowptr;
676 unsigned char redraw_y1,
682 #define CTK_MODE_NORMAL 0
683 #define CTK_MODE_WINDOWMOVE 1
684 #define CTK_MODE_SCREENSAVER 2
685 #define CTK_MODE_EXTERNAL 3
690 void ctk_restore(
void);
698 unsigned char w,
unsigned char h,
702 #define ctk_window_move(w,xpos,ypos) do { (w)->x=xpos; (w)->y=ypos; } while(0)
705 #define ctk_window_isopen(w) ((w)->next != NULL)
710 unsigned char w,
unsigned char h);
712 CCIF void ctk_dialog_close(
void);
733 #define CTK_ICON_ADD(icon, p) ctk_icon_add((struct ctk_widget *)icon, p)
744 #define CTK_WIDGET_ADD(win, widg) \
745 ctk_widget_add(win, (struct ctk_widget *)widg)
755 #define CTK_WIDGET_FOCUS(win, widg) \
756 (win)->focused = (struct ctk_widget *)(widg)
763 #define CTK_WIDGET_REDRAW(widg) \
764 ctk_widget_redraw((struct ctk_widget *)widg)
772 #define CTK_WIDGET_TYPE(w) ((w)->type)
781 #define CTK_WIDGET_SET_WIDTH(widget, width) do { \
782 ((struct ctk_widget *)(widget))->w = (width); } while(0)
791 #define CTK_WIDGET_XPOS(w) (((struct ctk_widget *)(w))->x)
800 #define CTK_WIDGET_SET_XPOS(w, xpos) \
801 ((struct ctk_widget *)(w))->x = (xpos)
809 #define CTK_WIDGET_YPOS(w) (((struct ctk_widget *)(w))->y)
818 #define CTK_WIDGET_SET_YPOS(w, ypos) \
819 ((struct ctk_widget *)(w))->y = (ypos)
832 #define ctk_label_set_height(w, height) \
833 (w)->widget.label.h = (height)
841 #define ctk_label_set_text(l, t) (l)->text = (t)
849 #define ctk_button_set_text(b, t) (b)->text = (t)
851 #define ctk_bitmap_set_bitmap(b, m) (b)->bitmap = (m)
853 #define CTK_BUTTON_NEW(widg, xpos, ypos, width, buttontext) \
854 do { (widg)->window = NULL; \
855 (widg)->next = NULL; \
856 (widg)->type = CTK_WIDGET_BUTTON; \
857 (widg)->x = (xpos); \
858 (widg)->y = (ypos); \
859 (widg)->w = (width); \
861 (widg)->text = (buttontext); \
864 #define CTK_LABEL_NEW(widg, xpos, ypos, width, height, labeltext) \
865 do { (widg)->window = NULL; \
866 (widg)->next = NULL; \
867 (widg)->type = CTK_WIDGET_LABEL; \
868 (widg)->x = (xpos); \
869 (widg)->y = (ypos); \
870 (widg)->w = (width); \
871 (widg)->h = (height); \
872 (widg)->text = (labeltext); \
875 #define CTK_BITMAP_NEW(widg, xpos, ypos, width, height, bmap) \
876 do { (widg)->window = NULL; \
877 (widg)->next = NULL; \
878 (widg)->type = CTK_WIDGET_BITMAP; \
879 (widg)->x = (xpos); \
880 (widg)->y = (ypos); \
881 (widg)->w = (width); \
882 (widg)->h = (height); \
883 (widg)->bitmap = (bmap); \
886 #define CTK_TEXTENTRY_NEW(widg, xxpos, yypos, width, height, textptr, textlen) \
887 do { (widg)->window = NULL; \
888 (widg)->next = NULL; \
889 (widg)->type = CTK_WIDGET_TEXTENTRY; \
890 (widg)->x = (xxpos); \
891 (widg)->y = (yypos); \
892 (widg)->w = (width); \
894 (widg)->text = (textptr); \
895 (widg)->len = (textlen); \
896 (widg)->state = CTK_TEXTENTRY_NORMAL; \
899 (widg)->input = NULL; \
902 #define CTK_TEXTENTRY_INPUT_NEW(widg, xxpos, yypos, width, height, textptr, textlen, iinput) \
903 do { (widg)->window = NULL; \
904 (widg)->next = NULL; \
905 (widg)->type = CTK_WIDGET_TEXTENTRY; \
906 (widg)->x = (xxpos); \
907 (widg)->y = (yypos); \
908 (widg)->w = (width); \
909 (widg)->h = (height); \
910 (widg)->text = (textptr); \
911 (widg)->len = (textlen); \
912 (widg)->state = CTK_TEXTENTRY_NORMAL; \
915 (widg)->input = (ctk_textentry_input)(iinput); \
918 #define CTK_HYPERLINK_NEW(widg, xpos, ypos, width, linktext, linkurl) \
919 do { (widg)->window = NULL; \
920 (widg)->next = NULL; \
921 (widg)->type = CTK_WIDGET_HYPERLINK; \
922 (widg)->x = (xpos); \
923 (widg)->y = (ypos); \
924 (widg)->w = (width); \
926 (widg)->text = (linktext); \
927 (widg)->url = (linkurl); \
931 void ctk_desktop_redraw(
struct ctk_desktop *d);
942 ctk_signal_pointer_move,
943 ctk_signal_pointer_button;
945 #if CTK_CONF_SCREENSAVER
946 extern process_event_t ctk_signal_screensaver_stop,
947 ctk_signal_screensaver_start;
949 extern unsigned short ctk_screensaver_timeout;
955 #define CTK_SCREENSAVER_SET_TIMEOUT(t) ctk_screensaver_timeout = (t)
961 #define CTK_SCREENSAVER_TIMEOUT() ctk_screensaver_timeout
978 #define CTK_FOCUS_NONE 0
980 #define CTK_FOCUS_WIDGET 1
982 #define CTK_FOCUS_WINDOW 2
984 #define CTK_FOCUS_DIALOG 4