📄 ctk.h
字号:
moving the window. This is also present in the list of active widgets. */#else /* CTK_CONF_WINDOWMOVE */ struct ctk_label titlebutton;#endif /* CTK_CONF_WINDOWMOVE */ unsigned char x, /**< The x coordinate of the window, in characters. */ y; /**< The y coordinate of the window, in characters. */ unsigned char w, /**< The width of the window, excluding window borders. */ h; /**< The height of the window, excluding window borders. */ struct ctk_widget *inactive; /**< The list if widgets that cannot be selected by the user. Labels and separator widgets are placed on this list. */ struct ctk_widget *active; /**< The list of widgets that can be selected by the user. Buttons, hyperlinks, text entry fields, etc., are placed on this list. */ struct ctk_widget *focused; /**< A pointer to the widget on the active list that is currently selected, or NULL if no widget is selected. */};/** * Repressentation of an individual menu item. */struct ctk_menuitem { char *title; /**< The menu items text. */ unsigned char titlelen;/**< The length of the item text, cached for speed. */};/** * Repressentation of an individual menu. */struct ctk_menu { struct ctk_menu *next; /**< Apointer to the next menu, or is NULL if this is the last menu, and should be used by the ctk-draw module when stepping through the menus when drawing them on screen. */ char *title; /**< The menu title. */ unsigned char titlelen;/**< The length of the title in characters. Cached for speed reasons. */#if CC_UNSIGNED_CHAR_BUGS unsigned int nitems; unsigned int active;#else /* CC_UNSIGNED_CHAR_BUGS */ unsigned char nitems; /**< The total number of menu items in the menu. */ unsigned char active; /**< The currently active menu item. */#endif /* CC_UNSIGNED_CHAR_BUGS */ struct ctk_menuitem items[CTK_CONF_MAXMENUITEMS]; /**< The array which contains all the menu items. */};/** * Repressentation of the menu bar. */struct ctk_menus { struct ctk_menu *menus; /**< A pointer to a linked list of all menus, including the open menu and the desktop menu.*/ struct ctk_menu *open; /**< The currently open menu, if any. If all menus are closed, this item is NULL: */ struct ctk_menu *desktopmenu; /**< A pointer to the "Desktop" menu that can be used for drawing the desktop menu in a special way (such as drawing it at the rightmost position). */ };/** * \internal The structure describing a Contiki desktop. */struct ctk_desktop { char *name; /**< The name of the desktop. */ struct ctk_window desktop_window; /**< The background window which contains tha desktop icons. */ struct ctk_window *windows; /**< The list of open windows. */ struct ctk_window *dialog; /**< A pointer to the open dialog, or NULL if no dialog is open. */ #if CTK_CONF_MENUS struct ctk_menus menus; /**< The list of desktop menus. */ struct ctk_menu *lastmenu; /**< Pointer to the menu that was last open. */ struct ctk_menu desktopmenu;/**< The desktop menu. */#endif /* CTK_CONF_MENUS */ unsigned char height, /**< The height of the desktop, in characters. */ width; /**< The width of the desktop, in characters. */ #define CTK_REDRAW_NONE 0 /**< \internal Redraw flag: nothing to be redrawn. */#define CTK_REDRAW_ALL 1 /**< \internal Redraw flag: everything should be redrawn. */#define CTK_REDRAW_WINDOWS 2 /**< \internal Redraw flag: redraw windows in queue.*/#define CTK_REDRAW_WIDGETS 4 /**< \internal Redraw flag: redraw widgets in queue. */#define CTK_REDRAW_MENUS 8 /**< \internal Redraw flag: redraw menus. */#define CTK_REDRAW_PART 16 /**< \internal Redraw flag: redraw parts of the desktop. */#ifndef CTK_CONF_MAX_REDRAWWIDGETS#define CTK_CONF_MAX_REDRAWWIDGETS 8#endif /* CTK_CONF_MAX_REDRAWWIDGETS */#ifndef CTK_CONF_MAX_REDRAWWINDOWS#define CTK_CONF_MAX_REDRAWWINDOWS 8#endif /* CTK_CONF_MAX_REDRAWWINDOWS */ unsigned char redraw; /**< The redraw flag. */ struct ctk_widget *redraw_widgets[CTK_CONF_MAX_REDRAWWIDGETS]; /**< The list of widgets to be redrawn. */ unsigned char redraw_widgetptr; /**< Pointer to the last widget on the redraw_widgets list. */ struct ctk_window *redraw_windows[CTK_CONF_MAX_REDRAWWINDOWS]; /**< The list of windows to be redrawn. */ unsigned char redraw_windowptr; /**< Pointer to the last window on the redraw_windows list. */ unsigned char redraw_y1, /**< The lower y bound of the area to be redrawn if CTK_REDRAW_PART is flagged. */ redraw_y2; /**< The upper y bound of the area to be redrawn if CTK_REDRAW_PART is flagged. */};/* Global CTK modes. */#define CTK_MODE_NORMAL 0#define CTK_MODE_WINDOWMOVE 1#define CTK_MODE_SCREENSAVER 2#define CTK_MODE_EXTERNAL 3/* General ctk functions. */void ctk_init(void);void ctk_mode_set(unsigned char mode);unsigned char ctk_mode_get(void);/*void ctk_redraw(void);*//* Functions for manipulating windows. */void ctk_window_new(struct ctk_window *window, unsigned char w, unsigned char h, char *title);void ctk_window_clear(struct ctk_window *w);void ctk_window_open(struct ctk_window *w);#define ctk_window_move(w,xpos,ypos) do {(w)->x=xpos; (w)->y=ypos;}while(0)void ctk_window_close(struct ctk_window *w);void ctk_window_redraw(struct ctk_window *w);#define ctk_window_isopen(w) ((w)->next != NULL)/* Functions for manipulating dialogs. */void ctk_dialog_new(struct ctk_window *window, unsigned char w, unsigned char h);void ctk_dialog_open(struct ctk_window *d);void ctk_dialog_close(void);/* Functions for manipulating menus. */void ctk_menu_new(struct ctk_menu *menu, char *title);void ctk_menu_add(struct ctk_menu *menu);void ctk_menu_remove(struct ctk_menu *menu);unsigned char ctk_menuitem_add(struct ctk_menu *menu, char *name);/* Functions for icons. *//** * Add an icon to the desktop. * * \param icon The icon to be added. * * \param id The process ID of the process that owns the icon. */#define CTK_ICON_ADD(icon, id) ctk_icon_add((struct ctk_widget *)icon, id)void ctk_icon_add(struct ctk_widget *icon, ek_id_t id);/* Functions for manipulating widgets. *//** * Add a widget to a window. * * \param win The window to which the widget should be added. * \param widg The widget to be added. */#define CTK_WIDGET_ADD(win, widg) \ ctk_widget_add(win, (struct ctk_widget *)widg)void CC_FASTCALL ctk_widget_add(struct ctk_window *window, struct ctk_widget *widget);/** * Set focus to a widget. * * \param win The widget's window. * \param widg The widget */#define CTK_WIDGET_FOCUS(win, widg) \ (win)->focused = (struct ctk_widget *)(widg)/** * Add a widget to the redraw queue. * * \param widg The widget to be redrawn. */#define CTK_WIDGET_REDRAW(widg) \ ctk_widget_redraw((struct ctk_widget *)widg)void ctk_widget_redraw(struct ctk_widget *w);/** * Obtain the type of a widget. * * \param w The widget. */#define CTK_WIDGET_TYPE(w) ((w)->type)/** * Sets the width of a widget. * * \param widget The widget. * \param width The width of the widget, in characters. */#define CTK_WIDGET_SET_WIDTH(widget, width) do { \ ((struct ctk_widget *)(widget))->w = (width); } while(0)/** * Retrieves the x position of a widget, relative to the window in * which the widget is contained. * * \param w The widget. * \return The x position of the widget. */#define CTK_WIDGET_XPOS(w) (((struct ctk_widget *)(w))->x)/** * Sets the x position of a widget, relative to the window in * which the widget is contained. * * \param w The widget. * \param xpos The x position of the widget. */#define CTK_WIDGET_SET_XPOS(w, xpos) \ ((struct ctk_widget *)(w))->x = (xpos)/** * Retrieves the y position of a widget, relative to the window in * which the widget is contained. * * \param w The widget. * \return The y position of the widget. */#define CTK_WIDGET_YPOS(w) (((struct ctk_widget *)(w))->y)/** * Sets the y position of a widget, relative to the window in * which the widget is contained. * * \param w The widget. * \param ypos The y position of the widget. */#define CTK_WIDGET_SET_YPOS(w, ypos) \ ((struct ctk_widget *)(w))->y = (ypos)/* XXX: should be removed.#define ctk_textentry_set_height(w, height) \ (w)->widget.textentry.h = (height)*//** \def ctk_label_set_height(w, height) * \brief Set the height of a label. * * \param w The CTK label widget. * \param height The new height of the label. */#define ctk_label_set_height(w, height) \ (w)->widget.label.h = (height)/** * Set the text of a label. * * \param l The CTK label widget. * \param t The new text of the label. */#define ctk_label_set_text(l, t) (l)->text = (t)/** * Set the text of a button. * * \param b The CTK button widget. * \param t The new text of the button. */#define ctk_button_set_text(b, t) (b)->text = (t)#define ctk_bitmap_set_bitmap(b, m) (b)->bitmap = (m)#define CTK_BUTTON_NEW(widg, xpos, ypos, width, buttontext) \ do { (widg)->window = NULL; \ (widg)->next = NULL; \ (widg)->type = CTK_WIDGET_BUTTON; \ (widg)->x = (xpos); \ (widg)->y = (ypos); \ (widg)->w = (width); \ (widg)->h = 1; \ (widg)->text = (buttontext); \ } while(0)#define CTK_LABEL_NEW(widg, xpos, ypos, width, height, labeltext) \ do { (widg)->window = NULL; \ (widg)->next = NULL; \ (widg)->type = CTK_WIDGET_LABEL; \ (widg)->x = (xpos); \ (widg)->y = (ypos); \ (widg)->w = (width); \ (widg)->h = (height); \ (widg)->text = (labeltext); \ } while(0)#define CTK_BITMAP_NEW(widg, xpos, ypos, width, height, bmap) \ do { (widg)->window = NULL; \ (widg)->next = NULL; \ (widg)->type = CTK_WIDGET_BITMAP; \ (widg)->x = (xpos); \ (widg)->y = (ypos); \ (widg)->w = (width); \ (widg)->h = (height); \ (widg)->bitmap = (bmap); \ } while(0)#define CTK_TEXTENTRY_NEW(widg, xxpos, yypos, width, height, textptr, textlen) \ do { (widg)->window = NULL; \ (widg)->next = NULL; \ (widg)->type = CTK_WIDGET_TEXTENTRY; \ (widg)->x = (xxpos); \ (widg)->y = (yypos); \ (widg)->w = (width); \ (widg)->h = (height); \ (widg)->text = (textptr); \ (widg)->len = (textlen); \ (widg)->state = CTK_TEXTENTRY_NORMAL; \ (widg)->xpos = 0; \ } while(0)#define CTK_HYPERLINK_NEW(widg, xpos, ypos, width, linktext, linkurl) \ do { (widg)->window = NULL; \ (widg)->next = NULL; \ (widg)->type = CTK_WIDGET_HYPERLINK; \ (widg)->x = (xpos); \ (widg)->y = (ypos); \ (widg)->w = (width); \ (widg)->h = 1; \ (widg)->text = (linktext); \ (widg)->url = (linkurl); \ } while(0)/* Desktop interface. */void ctk_desktop_redraw(struct ctk_desktop *d);unsigned char ctk_desktop_width(struct ctk_desktop *d);unsigned char ctk_desktop_height(struct ctk_desktop *d);/* Signals. */extern ek_signal_t ctk_signal_keypress, ctk_signal_widget_activate, ctk_signal_widget_select, ctk_signal_timer, ctk_signal_menu_activate, ctk_signal_window_close, ctk_signal_pointer_move, ctk_signal_pointer_button;#if CTK_CONF_SCREENSAVERextern ek_signal_t ctk_signal_screensaver_stop, ctk_signal_screensaver_start;extern unsigned short ctk_screensaver_timeout;/** * Set the screensaver timeout, in seconds. * * \param t The timeout in seconds. */#define CTK_SCREENSAVER_SET_TIMEOUT(t) ctk_screensaver_timeout = (t)/** * Obtain the screensaver timeout, in seconds. * * \raturn The timeout in seconds. */#define CTK_SCREENSAVER_TIMEOUT() ctk_screensaver_timeout#endif /* CTK_CONF_SCREENSAVER *//* These should no longer be used: */extern ek_signal_t ctk_signal_button_activate, ctk_signal_button_hover, ctk_signal_hyperlink_activate, ctk_signal_hyperlink_hover;/* Focus flags *//** Widget focus flag: no focus. */#define CTK_FOCUS_NONE 0/** Widget focus flag: widget has focus. */#define CTK_FOCUS_WIDGET 1/** Widget focus flag: widget's window is the foremost one. */#define CTK_FOCUS_WINDOW 2/** Widget focus flag: widget is in a dialog. */#define CTK_FOCUS_DIALOG 4#endif /* __CTK_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -