54 #include "contiki-conf.h"
65 #define CTK_WIDGET_SEPARATOR 1
67 #define CTK_WIDGET_LABEL 2
69 #define CTK_WIDGET_BUTTON 3
71 #define CTK_WIDGET_HYPERLINK 4
73 #define CTK_WIDGET_TEXTENTRY 5
75 #define CTK_WIDGET_BITMAP 6
77 #define CTK_WIDGET_ICON 7
83 #if CTK_CONF_WIDGET_FLAGS
84 #define CTK_WIDGET_FLAG_INITIALIZER(x) x,
86 #define CTK_WIDGET_FLAG_INITIALIZER(x)
112 #define CTK_SEPARATOR(x, y, w) \
113 NULL, NULL, x, y, CTK_WIDGET_SEPARATOR, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0)
114 struct ctk_separator {
120 #if CTK_CONF_WIDGET_FLAGS
141 #define CTK_BUTTON(x, y, w, text) \
142 NULL, NULL, x, y, CTK_WIDGET_BUTTON, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) text
149 #if CTK_CONF_WIDGET_FLAGS
172 #define CTK_LABEL(x, y, w, h, text) \
173 NULL, NULL, x, y, CTK_WIDGET_LABEL, w, h, CTK_WIDGET_FLAG_INITIALIZER(0) text,
180 #if CTK_CONF_WIDGET_FLAGS
203 #define CTK_HYPERLINK(x, y, w, text, url) \
204 NULL, NULL, x, y, CTK_WIDGET_HYPERLINK, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) text, url
205 struct ctk_hyperlink {
211 #if CTK_CONF_WIDGET_FLAGS
219 #define CTK_TEXTENTRY_NORMAL 0
221 #define CTK_TEXTENTRY_EDIT 1
230 #define CTK_TEXTENTRY_CLEAR(e) \
231 do { memset((e)->text, 0, (e)->h * ((e)->len + 1)); \
232 (e)->xpos = 0; (e)->ypos = 0; } while(0)
234 #ifdef CTK_ARCH_KEY_T
241 #define CH_ENTER '\n'
244 struct ctk_textentry;
246 struct ctk_textentry *t);
270 #define CTK_TEXTENTRY(x, y, w, h, text, len) \
271 NULL, NULL, x, y, CTK_WIDGET_TEXTENTRY, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) text, len, \
272 CTK_TEXTENTRY_NORMAL, 0, 0, ctk_textentry_input_null
274 #define CTK_TEXTENTRY(x, y, w, h, text, len) \
275 NULL, NULL, x, y, CTK_WIDGET_TEXTENTRY, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) text, len, \
276 CTK_TEXTENTRY_NORMAL, 0, 0, NULL
278 #define CTK_TEXTENTRY_INPUT(x, y, w, h, text, len, input) \
279 NULL, NULL, x, y, CTK_WIDGET_TEXTENTRY, w, h, CTK_WIDGET_FLAG_INITIALIZER(0) text, len, \
280 CTK_TEXTENTRY_NORMAL, 0, 0, input
281 struct ctk_textentry {
287 #if CTK_CONF_WIDGET_FLAGS
293 unsigned char xpos, ypos;
294 ctk_textentry_input input;
300 unsigned char ctk_textentry_input_null(
ctk_arch_key_t c,
struct ctk_textentry *t);
303 #if CTK_CONF_ICON_BITMAPS
304 #define CTK_ICON_BITMAP(bitmap) bitmap
306 #define CTK_ICON_BITMAP(bitmap) NULL
309 #if CTK_CONF_ICON_TEXTMAPS
310 #define CTK_ICON_TEXTMAP(textmap) textmap
312 #define CTK_ICON_TEXTMAP(textmap) NULL
329 #define CTK_ICON(title, bitmap, textmap) \
330 NULL, NULL, 0, 0, CTK_WIDGET_ICON, 2, 4, CTK_WIDGET_FLAG_INITIALIZER(0) \
331 title, PROCESS_NONE, \
332 CTK_ICON_BITMAP(bitmap), CTK_ICON_TEXTMAP(textmap)
339 #if CTK_CONF_WIDGET_FLAGS
343 struct process *owner;
344 unsigned char *bitmap;
348 #define CTK_BITMAP(x, y, w, h, bitmap, bitmap_width, bitmap_height) \
349 NULL, NULL, x, y, CTK_WIDGET_BITMAP, w, h, \
350 CTK_WIDGET_FLAG_INITIALIZER(0) bitmap, bitmap_width, bitmap_height
357 #if CTK_CONF_WIDGET_FLAGS
360 unsigned char *bitmap;
361 unsigned short bw, bh;
364 #define CTK_TEXTMAP_NORMAL 0
365 #define CTK_TEXTMAP_ACTIVE 1
367 #define CTK_TEXTMAP(x, y, w, h, textmap) \
368 NULL, NULL, x, y, CTK_WIDGET_LABEL, w, h, CTK_WIDGET_FLAG_INITIALIZER(0) text, CTK_TEXTMAP_NORMAL
375 #if CTK_CONF_WIDGET_FLAGS
393 struct ctk_widget_label {
400 struct ctk_widget_hyperlink {
405 struct ctk_widget_textentry {
409 unsigned char xpos, ypos;
410 ctk_textentry_input input;
413 struct ctk_widget_icon {
415 struct process *owner;
416 unsigned char *bitmap;
420 struct ctk_widget_bitmap {
421 unsigned char *bitmap;
422 unsigned short bw, bh;
466 #if CTK_CONF_WIDGET_FLAGS
471 struct ctk_widget_label label;
473 struct ctk_widget_hyperlink hyperlink;
474 struct ctk_widget_textentry textentry;
475 struct ctk_widget_icon icon;
476 struct ctk_widget_bitmap bitmap;
485 #define CTK_WIDGET_FLAG_NONE 0
486 #define CTK_WIDGET_FLAG_MONOSPACE 1
487 #define CTK_WIDGET_FLAG_CENTER 2
489 #if CTK_CONF_WIDGET_FLAGS
490 #define CTK_WIDGET_SET_FLAG(w, f) ((struct ctk_widget *)(w))->flags = (f)
492 #define CTK_WIDGET_SET_FLAG(w, f)
514 struct process *
owner;
524 #if CTK_CONF_WINDOWCLOSE
525 struct ctk_button closebutton;
529 struct ctk_label closebutton;
532 #if CTK_CONF_WINDOWMOVE
533 struct ctk_button titlebutton;
538 struct ctk_label titlebutton;
576 #ifdef CTK_CONF_MAXMENUITEMS
577 #define CTK_MAXMENUITEMS CTK_CONF_MAXMENUITEMS
579 #define CTK_MAXMENUITEMS 8
594 #if CC_UNSIGNED_CHAR_BUGS
645 unsigned char height,
649 #define CTK_REDRAW_NONE 0
651 #define CTK_REDRAW_ALL 1
653 #define CTK_REDRAW_WINDOWS 2
655 #define CTK_REDRAW_WIDGETS 4
657 #define CTK_REDRAW_MENUS 8
659 #define CTK_REDRAW_PART 16
662 #ifndef CTK_CONF_MAX_REDRAWWIDGETS
663 #define CTK_CONF_MAX_REDRAWWIDGETS 8
665 #ifndef CTK_CONF_MAX_REDRAWWINDOWS
666 #define CTK_CONF_MAX_REDRAWWINDOWS 8
669 unsigned char redraw;
671 struct ctk_widget *redraw_widgets[CTK_CONF_MAX_REDRAWWIDGETS];
672 unsigned char redraw_widgetptr;
674 struct ctk_window *redraw_windows[CTK_CONF_MAX_REDRAWWINDOWS];
675 unsigned char redraw_windowptr;
677 unsigned char redraw_y1,
683 #define CTK_MODE_NORMAL 0
684 #define CTK_MODE_WINDOWMOVE 1
685 #define CTK_MODE_SCREENSAVER 2
686 #define CTK_MODE_EXTERNAL 3
691 void ctk_restore(
void);
699 unsigned char w,
unsigned char h,
703 #define ctk_window_move(w,xpos,ypos) do { (w)->x=xpos; (w)->y=ypos; } while(0)
706 #define ctk_window_isopen(w) ((w)->next != NULL)
710 CCIF
void ctk_dialog_new(
struct ctk_window *window,
711 unsigned char w,
unsigned char h);
712 CCIF
void ctk_dialog_open(
struct ctk_window *d);
713 CCIF
void ctk_dialog_close(
void);
734 #define CTK_ICON_ADD(icon, p) ctk_icon_add((struct ctk_widget *)icon, p)
745 #define CTK_WIDGET_ADD(win, widg) \
746 ctk_widget_add(win, (struct ctk_widget *)widg)
756 #define CTK_WIDGET_FOCUS(win, widg) \
757 (win)->focused = (struct ctk_widget *)(widg)
764 #define CTK_WIDGET_REDRAW(widg) \
765 ctk_widget_redraw((struct ctk_widget *)widg)
773 #define CTK_WIDGET_TYPE(w) ((w)->type)
782 #define CTK_WIDGET_SET_WIDTH(widget, width) do { \
783 ((struct ctk_widget *)(widget))->w = (width); } while(0)
792 #define CTK_WIDGET_XPOS(w) (((struct ctk_widget *)(w))->x)
801 #define CTK_WIDGET_SET_XPOS(w, xpos) \
802 ((struct ctk_widget *)(w))->x = (xpos)
810 #define CTK_WIDGET_YPOS(w) (((struct ctk_widget *)(w))->y)
819 #define CTK_WIDGET_SET_YPOS(w, ypos) \
820 ((struct ctk_widget *)(w))->y = (ypos)
833 #define ctk_label_set_height(w, height) \
834 (w)->widget.label.h = (height)
842 #define ctk_label_set_text(l, t) (l)->text = (t)
850 #define ctk_button_set_text(b, t) (b)->text = (t)
852 #define ctk_bitmap_set_bitmap(b, m) (b)->bitmap = (m)
854 #define CTK_BUTTON_NEW(widg, xpos, ypos, width, buttontext) \
855 do { (widg)->window = NULL; \
856 (widg)->next = NULL; \
857 (widg)->type = CTK_WIDGET_BUTTON; \
858 (widg)->x = (xpos); \
859 (widg)->y = (ypos); \
860 (widg)->w = (width); \
862 (widg)->text = (buttontext); \
865 #define CTK_LABEL_NEW(widg, xpos, ypos, width, height, labeltext) \
866 do { (widg)->window = NULL; \
867 (widg)->next = NULL; \
868 (widg)->type = CTK_WIDGET_LABEL; \
869 (widg)->x = (xpos); \
870 (widg)->y = (ypos); \
871 (widg)->w = (width); \
872 (widg)->h = (height); \
873 (widg)->text = (labeltext); \
876 #define CTK_BITMAP_NEW(widg, xpos, ypos, width, height, bmap) \
877 do { (widg)->window = NULL; \
878 (widg)->next = NULL; \
879 (widg)->type = CTK_WIDGET_BITMAP; \
880 (widg)->x = (xpos); \
881 (widg)->y = (ypos); \
882 (widg)->w = (width); \
883 (widg)->h = (height); \
884 (widg)->bitmap = (bmap); \
887 #define CTK_TEXTENTRY_NEW(widg, xxpos, yypos, width, height, textptr, textlen) \
888 do { (widg)->window = NULL; \
889 (widg)->next = NULL; \
890 (widg)->type = CTK_WIDGET_TEXTENTRY; \
891 (widg)->x = (xxpos); \
892 (widg)->y = (yypos); \
893 (widg)->w = (width); \
895 (widg)->text = (textptr); \
896 (widg)->len = (textlen); \
897 (widg)->state = CTK_TEXTENTRY_NORMAL; \
900 (widg)->input = NULL; \
903 #define CTK_TEXTENTRY_INPUT_NEW(widg, xxpos, yypos, width, height, textptr, textlen, iinput) \
904 do { (widg)->window = NULL; \
905 (widg)->next = NULL; \
906 (widg)->type = CTK_WIDGET_TEXTENTRY; \
907 (widg)->x = (xxpos); \
908 (widg)->y = (yypos); \
909 (widg)->w = (width); \
910 (widg)->h = (height); \
911 (widg)->text = (textptr); \
912 (widg)->len = (textlen); \
913 (widg)->state = CTK_TEXTENTRY_NORMAL; \
916 (widg)->input = (ctk_textentry_input)(iinput); \
919 #define CTK_HYPERLINK_NEW(widg, xpos, ypos, width, linktext, linkurl) \
920 do { (widg)->window = NULL; \
921 (widg)->next = NULL; \
922 (widg)->type = CTK_WIDGET_HYPERLINK; \
923 (widg)->x = (xpos); \
924 (widg)->y = (ypos); \
925 (widg)->w = (width); \
927 (widg)->text = (linktext); \
928 (widg)->url = (linkurl); \
932 void ctk_desktop_redraw(
struct ctk_desktop *d);
943 ctk_signal_pointer_move,
944 ctk_signal_pointer_button;
946 #if CTK_CONF_SCREENSAVER
947 extern process_event_t ctk_signal_screensaver_stop,
948 ctk_signal_screensaver_start;
950 extern unsigned short ctk_screensaver_timeout;
956 #define CTK_SCREENSAVER_SET_TIMEOUT(t) ctk_screensaver_timeout = (t)
962 #define CTK_SCREENSAVER_TIMEOUT() ctk_screensaver_timeout
979 #define CTK_FOCUS_NONE 0
981 #define CTK_FOCUS_WIDGET 1
983 #define CTK_FOCUS_WINDOW 2
985 #define CTK_FOCUS_DIALOG 4