The CTK functions used by an application program. More...
Data Structures | |
struct | ctk_widget_button |
Instantiating macro for the ctk_icon widget. More... | |
Defines | |
#define | CTK_SEPARATOR(x, y, w) NULL, NULL, x, y, CTK_WIDGET_SEPARATOR, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) |
Instantiating macro for the ctk_separator widget. | |
#define | CTK_BUTTON(x, y, w, text) NULL, NULL, x, y, CTK_WIDGET_BUTTON, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) text |
Instantiating macro for the ctk_button widget. | |
#define | CTK_LABEL(x, y, w, h, text) NULL, NULL, x, y, CTK_WIDGET_LABEL, w, h, CTK_WIDGET_FLAG_INITIALIZER(0) text, |
Instantiating macro for the ctk_label widget. | |
#define | CTK_HYPERLINK(x, y, w, text, url) NULL, NULL, x, y, CTK_WIDGET_HYPERLINK, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) text, url |
Instantiating macro for the ctk_hyperlink widget. | |
#define | CTK_TEXTENTRY_CLEAR(e) |
Clears a text entry widget and sets the cursor to the start of the text line. | |
#define | CTK_TEXTENTRY(x, y, w, h, text, len) |
Instantiating macro for the ctk_textentry widget. | |
#define | CTK_ICON_ADD(icon, p) ctk_icon_add((struct ctk_widget *)icon, p) |
Add an icon to the desktop. | |
#define | CTK_WIDGET_ADD(win, widg) ctk_widget_add(win, (struct ctk_widget *)widg) |
Add a widget to a window. | |
#define | CTK_WIDGET_FOCUS(win, widg) (win)->focused = (struct ctk_widget *)(widg) |
Set focus to a widget. | |
#define | CTK_WIDGET_REDRAW(widg) ctk_widget_redraw((struct ctk_widget *)widg) |
Add a widget to the redraw queue. | |
#define | CTK_WIDGET_TYPE(w) ((w)->type) |
Obtain the type of a widget. | |
#define | CTK_WIDGET_SET_WIDTH(widget, width) |
Sets the width of a widget. | |
#define | CTK_WIDGET_XPOS(w) (((struct ctk_widget *)(w))->x) |
Retrieves the x position of a widget, relative to the window in which the widget is contained. | |
#define | CTK_WIDGET_SET_XPOS(w, xpos) ((struct ctk_widget *)(w))->x = (xpos) |
Sets the x position of a widget, relative to the window in which the widget is contained. | |
#define | CTK_WIDGET_YPOS(w) (((struct ctk_widget *)(w))->y) |
Retrieves the y position of a widget, relative to the window in which the widget is contained. | |
#define | CTK_WIDGET_SET_YPOS(w, ypos) ((struct ctk_widget *)(w))->y = (ypos) |
Sets the y position of a widget, relative to the window in which the widget is contained. | |
#define | ctk_label_set_height(w, height) (w)->widget.label.h = (height) |
Set the height of a label. | |
#define | ctk_label_set_text(l, t) (l)->text = (t) |
Set the text of a label. | |
#define | ctk_button_set_text(b, t) (b)->text = (t) |
Set the text of a button. | |
Functions | |
void | ctk_mode_set (unsigned char m) |
Sets the current CTK mode. | |
unsigned char | ctk_mode_get (void) |
Retrieves the current CTK mode. | |
void | ctk_icon_add (CC_REGISTER_ARG struct ctk_widget *icon, struct process *p) |
Add an icon to the desktop. | |
void | ctk_window_open (CC_REGISTER_ARG struct ctk_window *w) |
Open a window, or bring window to front if already open. | |
void | ctk_window_close (struct ctk_window *w) |
Close a window if it is open. | |
void | ctk_window_clear (struct ctk_window *w) |
Remove all widgets from a window. | |
void | ctk_menu_add (struct ctk_menu *menu) |
Add a menu to the menu bar. | |
void | ctk_menu_remove (struct ctk_menu *menu) |
Remove a menu from the menu bar. | |
void | ctk_window_redraw (struct ctk_window *w) |
Redraw a window. | |
void | ctk_window_new (struct ctk_window *window, unsigned char w, unsigned char h, char *title) |
Create a new window. | |
void | ctk_menu_new (CC_REGISTER_ARG struct ctk_menu *menu, char *title) |
Creates a new menu. | |
unsigned char | ctk_menuitem_add (CC_REGISTER_ARG struct ctk_menu *menu, char *name) |
Adds a menu item to a menu. | |
void | ctk_widget_redraw (struct ctk_widget *widget) |
Redraws a widget. | |
void CC_FASTCALL | ctk_widget_add (CC_REGISTER_ARG struct ctk_window *window, CC_REGISTER_ARG struct ctk_widget *widget) |
Adds a widget to a window. | |
unsigned char | ctk_desktop_width (struct ctk_desktop *d) |
Gets the width of the desktop. | |
unsigned char | ctk_desktop_height (struct ctk_desktop *d) |
Gets the height of the desktop. | |
Variables | |
CCIF process_event_t | ctk_signal_keypress |
Emitted for every key being pressed. | |
CCIF process_event_t | ctk_signal_widget_activate |
Emitted when a widget is activated (pressed). | |
CCIF process_event_t | ctk_signal_widget_select |
Emitted when a widget is selected. | |
CCIF process_event_t | ctk_signal_menu_activate |
Emitted when a menu item is activated. | |
CCIF process_event_t | ctk_signal_window_close |
Emitted when a window is closed. | |
CCIF process_event_t | ctk_signal_button_activate |
Same as ctk_signal_widget_activate. | |
CCIF process_event_t | ctk_signal_button_hover |
Same as ctk_signal_widget_select. | |
CCIF process_event_t | ctk_signal_hyperlink_activate |
Emitted when a hyperlink is activated. | |
CCIF process_event_t | ctk_signal_hyperlink_hover |
Same as ctk_signal_widget_select. |
The CTK functions used by an application program.
#define CTK_BUTTON | ( | x, | |||
y, | |||||
w, | |||||
text | ) | NULL, NULL, x, y, CTK_WIDGET_BUTTON, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) text |
Instantiating macro for the ctk_button widget.
This macro is used when instantiating a ctk_button widget and is intended to be used together with a struct assignment like this:
struct ctk_button but = {CTK_BUTTON(0, 0, 2, "Ok")};
x | The x position of the widget, relative to the widget's window. | |
y | The y position of the widget, relative to the widget's window. | |
w | The widget's width. | |
text | The button text. |
#define ctk_button_set_text | ( | b, | |||
t | ) | (b)->text = (t) |
#define CTK_HYPERLINK | ( | x, | |||
y, | |||||
w, | |||||
text, | |||||
url | ) | NULL, NULL, x, y, CTK_WIDGET_HYPERLINK, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) text, url |
Instantiating macro for the ctk_hyperlink widget.
This macro is used when instantiating a ctk_hyperlink widget and is intended to be used together with a struct assignment like this:
struct ctk_hyperlink hlink = {CTK_HYPERLINK(0, 0, 7, "Contiki", "http://dunkels.com/adam/contiki/")};
x | The x position of the widget, relative to the widget's window. | |
y | The y position of the widget, relative to the widget's window. | |
w | The widget's width. | |
text | The hyperlink text. | |
url | The hyperlink URL. |
#define CTK_ICON_ADD | ( | icon, | |||
p | ) | ctk_icon_add((struct ctk_widget *)icon, p) |
#define CTK_LABEL | ( | x, | |||
y, | |||||
w, | |||||
h, | |||||
text | ) | NULL, NULL, x, y, CTK_WIDGET_LABEL, w, h, CTK_WIDGET_FLAG_INITIALIZER(0) text, |
Instantiating macro for the ctk_label widget.
This macro is used when instantiating a ctk_label widget and is intended to be used together with a struct assignment like this:
struct ctk_label lab = {CTK_LABEL(0, 0, 5, 1, "Label")};
x | The x position of the widget, relative to the widget's window. | |
y | The y position of the widget, relative to the widget's window. | |
w | The widget's width. | |
h | The height of the label. | |
text | The label text. |
#define ctk_label_set_height | ( | w, | |||
height | ) | (w)->widget.label.h = (height) |
#define ctk_label_set_text | ( | l, | |||
t | ) | (l)->text = (t) |
#define CTK_SEPARATOR | ( | x, | |||
y, | |||||
w | ) | NULL, NULL, x, y, CTK_WIDGET_SEPARATOR, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) |
Instantiating macro for the ctk_separator widget.
This macro is used when instantiating a ctk_separator widget and is intended to be used together with a struct assignment like this:
struct ctk_separator sep = {CTK_SEPARATOR(0, 0, 23)};
x | The x position of the widget, relative to the widget's window. | |
y | The y position of the widget, relative to the widget's window. | |
w | The widget's width. |
#define CTK_TEXTENTRY | ( | x, | |||
y, | |||||
w, | |||||
h, | |||||
text, | |||||
len | ) |
NULL, NULL, x, y, CTK_WIDGET_TEXTENTRY, w, 1, CTK_WIDGET_FLAG_INITIALIZER(0) text, len, \ CTK_TEXTENTRY_NORMAL, 0, 0, NULL
Instantiating macro for the ctk_textentry widget.
This macro is used when instantiating a ctk_textentry widget and is intended to be used together with a struct assignment like this:
struct ctk_textentry tentry = {CTK_TEXTENTRY(0, 0, 30, 1, textbuffer, 50)};
x | The x position of the widget, relative to the widget's window. | |
y | The y position of the widget, relative to the widget's window. | |
w | The widget's width. | |
h | The text entry height (obsolete). | |
text | A pointer to the buffer that should be edited. | |
len | The length of the text buffer |
#define CTK_TEXTENTRY_CLEAR | ( | e | ) |
#define CTK_WIDGET_ADD | ( | win, | |||
widg | ) | ctk_widget_add(win, (struct ctk_widget *)widg) |
#define CTK_WIDGET_FOCUS | ( | win, | |||
widg | ) | (win)->focused = (struct ctk_widget *)(widg) |
#define CTK_WIDGET_REDRAW | ( | widg | ) | ctk_widget_redraw((struct ctk_widget *)widg) |
#define CTK_WIDGET_SET_WIDTH | ( | widget, | |||
width | ) |
do { \ ((struct ctk_widget *)(widget))->w = (width); } while(0)
Sets the width of a widget.
widget | The widget. | |
width | The width of the widget, in characters. |
#define CTK_WIDGET_SET_XPOS | ( | w, | |||
xpos | ) | ((struct ctk_widget *)(w))->x = (xpos) |
#define CTK_WIDGET_SET_YPOS | ( | w, | |||
ypos | ) | ((struct ctk_widget *)(w))->y = (ypos) |
#define CTK_WIDGET_TYPE | ( | w | ) | ((w)->type) |
#define CTK_WIDGET_XPOS | ( | w | ) | (((struct ctk_widget *)(w))->x) |
#define CTK_WIDGET_YPOS | ( | w | ) | (((struct ctk_widget *)(w))->y) |
unsigned char ctk_desktop_height | ( | struct ctk_desktop * | d | ) |
Gets the height of the desktop.
d | The desktop. |
CCIF unsigned char ctk_desktop_width | ( | struct ctk_desktop * | d | ) |
Gets the width of the desktop.
d | The desktop. |
void ctk_icon_add | ( | CC_REGISTER_ARG struct ctk_widget * | icon, | |
struct process * | p | |||
) |
Add an icon to the desktop.
icon | The icon to be added. | |
p | The process that owns the icon. |
Definition at line 305 of file ctk.c.
References ctk_widget_add().
void ctk_menu_add | ( | struct ctk_menu * | menu | ) |
Add a menu to the menu bar.
menu | The menu to be added. |
Definition at line 505 of file ctk.c.
References ctk_menu::next.
void ctk_menu_new | ( | CC_REGISTER_ARG struct ctk_menu * | menu, | |
char * | title | |||
) |
Creates a new menu.
This function sets up the internal structure of the menu, but does not add it to the menubar. Use the function ctk_menu_add() for that purpose.
menu | The menu to be created. | |
title | The title of the menu. |
void ctk_menu_remove | ( | struct ctk_menu * | menu | ) |
Remove a menu from the menu bar.
menu | The menu to be removed. |
Definition at line 533 of file ctk.c.
References ctk_menu::next.
unsigned char ctk_menuitem_add | ( | CC_REGISTER_ARG struct ctk_menu * | menu, | |
char * | name | |||
) |
Adds a menu item to a menu.
In CTK, each menu item is identified by a number which is unique within each menu. When a menu item is selected, a ctk_menuitem_activated signal is emitted and the menu item number is passed as signal data with the signal.
menu | The menu to which the menu item should be added. | |
name | The name of the menu item. |
unsigned char ctk_mode_get | ( | void | ) |
void ctk_mode_set | ( | unsigned char | m | ) |
Sets the current CTK mode.
The CTK mode can be either CTK_MODE_NORMAL, CTK_MODE_SCREENSAVER or CTK_MODE_EXTERNAL. CTK_MODE_NORMAL is the normal mode, in which keypresses and mouse pointer movements are processed and the screen is redrawn. In CTK_MODE_SCREENSAVER, no screen redraws are performed and the first key press or pointer movement will cause the ctk_signal_screensaver_stop to be emitted. In the CTK_MODE_EXTERNAL mode, key presses and pointer movements are ignored and no screen redraws are made.
m | The mode. |
void CC_FASTCALL ctk_widget_add | ( | CC_REGISTER_ARG struct ctk_window * | window, | |
CC_REGISTER_ARG struct ctk_widget * | widget | |||
) |
Adds a widget to a window.
This function adds a widget to a window. The order of which the widgets are added is important, as it sets the order to which widgets are cycled with the widget selection keys.
window | The window to which the widhet should be added. | |
widget | The widget to be added. |
Definition at line 926 of file ctk.c.
References CTK_WIDGET_LABEL, and CTK_WIDGET_SEPARATOR.
Referenced by ctk_icon_add().
CCIF void ctk_widget_redraw | ( | struct ctk_widget * | widget | ) |
Redraws a widget.
This function will set a flag which causes the widget to be redrawn next time the CTK process is scheduled.
widget | The widget that is to be redrawn. |
void ctk_window_clear | ( | struct ctk_window * | w | ) |
Remove all widgets from a window.
w | The window to be cleared. |
Definition at line 486 of file ctk.c.
References ctk_window::active, ctk_window::focused, and ctk_window::inactive.
void ctk_window_close | ( | struct ctk_window * | w | ) |
Close a window if it is open.
If the window is not open, this function does nothing.
w | The window to be closed. |
Definition at line 401 of file ctk.c.
References ctk_window::next, and ctk_window::prev.
void ctk_window_new | ( | struct ctk_window * | window, | |
unsigned char | w, | |||
unsigned char | h, | |||
char * | title | |||
) |
Create a new window.
Creates a new window. The memory for the window structure must already be allocated by the caller, and is usually done with a static declaration.
This function sets up the internal structure of the ctk_window struct and creates the move and close buttons, but it does not open the window. The window must be explicitly opened by calling the ctk_window_open() function.
window | The window to be created. | |
w | The width of the new window. | |
h | The height of the new window. | |
title | The title of the new window. |
void ctk_window_open | ( | CC_REGISTER_ARG struct ctk_window * | w | ) |
Open a window, or bring window to front if already open.
w | The window to be opened. |
Definition at line 348 of file ctk.c.
References ctk_window::next, and ctk_window::prev.
void ctk_window_redraw | ( | struct ctk_window * | w | ) |
Redraw a window.
This function redraws the window, but only if it is the foremost one on the desktop.
w | The window to be redrawn. |
Definition at line 653 of file ctk.c.
References ctk_draw_dialog(), ctk_draw_window(), and CTK_FOCUS_WINDOW.
CCIF process_event_t ctk_signal_button_activate |
CCIF process_event_t ctk_signal_button_hover |
CCIF process_event_t ctk_signal_hyperlink_activate |
CCIF process_event_t ctk_signal_hyperlink_hover |
CCIF process_event_t ctk_signal_keypress |
CCIF process_event_t ctk_signal_menu_activate |
CCIF process_event_t ctk_signal_widget_activate |
CCIF process_event_t ctk_signal_widget_select |
CCIF process_event_t ctk_signal_window_close |