CTK application functions
[CTK graphical user interface]

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.

Detailed Description

The CTK functions used by an application program.


Define Documentation

#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")};
Parameters:
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.

Definition at line 141 of file ctk.h.

#define ctk_button_set_text ( b,
 )     (b)->text = (t)

Set the text of a button.

Parameters:
b The CTK button widget.
t The new text of the button.

Definition at line 850 of file ctk.h.

#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/")};
Parameters:
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.

Definition at line 203 of file ctk.h.

#define CTK_ICON_ADD ( icon,
 )     ctk_icon_add((struct ctk_widget *)icon, p)

Add an icon to the desktop.

Parameters:
icon The icon to be added.
p The process ID of the process that owns the icon.

Definition at line 734 of file ctk.h.

#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")};
Parameters:
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.

Definition at line 172 of file ctk.h.

#define ctk_label_set_height ( w,
height   )     (w)->widget.label.h = (height)

Set the height of a label.

Parameters:
w The CTK label widget.
height The new height of the label.

Definition at line 833 of file ctk.h.

#define ctk_label_set_text ( l,
 )     (l)->text = (t)

Set the text of a label.

Parameters:
l The CTK label widget.
t The new text of the label.

Definition at line 842 of file ctk.h.

#define CTK_SEPARATOR ( x,
y,
 )     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)};
Parameters:
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.

Definition at line 112 of file ctk.h.

#define CTK_TEXTENTRY ( x,
y,
w,
h,
text,
len   ) 
Value:
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)};
Note:
The height of the text entry widget is obsolete and not intended to be used.
Parameters:
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

Definition at line 274 of file ctk.h.

#define CTK_TEXTENTRY_CLEAR (  ) 
Value:
do { memset((e)->text, 0, (e)->h * ((e)->len + 1)); \
             (e)->xpos = 0; (e)->ypos = 0; } while(0)

Clears a text entry widget and sets the cursor to the start of the text line.

Parameters:
e The text entry widget to be cleared.

Definition at line 230 of file ctk.h.

#define CTK_WIDGET_ADD ( win,
widg   )     ctk_widget_add(win, (struct ctk_widget *)widg)

Add a widget to a window.

Parameters:
win The window to which the widget should be added.
widg The widget to be added.

Definition at line 745 of file ctk.h.

#define CTK_WIDGET_FOCUS ( win,
widg   )     (win)->focused = (struct ctk_widget *)(widg)

Set focus to a widget.

Parameters:
win The widget's window.
widg The widget

Definition at line 756 of file ctk.h.

#define CTK_WIDGET_REDRAW ( widg   )     ctk_widget_redraw((struct ctk_widget *)widg)

Add a widget to the redraw queue.

Parameters:
widg The widget to be redrawn.

Definition at line 764 of file ctk.h.

#define CTK_WIDGET_SET_WIDTH ( widget,
width   ) 
Value:
do { \
    ((struct ctk_widget *)(widget))->w = (width); } while(0)

Sets the width of a widget.

Parameters:
widget The widget.
width The width of the widget, in characters.

Definition at line 782 of file ctk.h.

#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.

Parameters:
w The widget.
xpos The x position of the widget.

Definition at line 801 of file ctk.h.

#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.

Parameters:
w The widget.
ypos The y position of the widget.

Definition at line 819 of file ctk.h.

#define CTK_WIDGET_TYPE (  )     ((w)->type)

Obtain the type of a widget.

Parameters:
w The widget.

Definition at line 773 of file ctk.h.

#define CTK_WIDGET_XPOS (  )     (((struct ctk_widget *)(w))->x)

Retrieves the x position of a widget, relative to the window in which the widget is contained.

Parameters:
w The widget.
Returns:
The x position of the widget.

Definition at line 792 of file ctk.h.

#define CTK_WIDGET_YPOS (  )     (((struct ctk_widget *)(w))->y)

Retrieves the y position of a widget, relative to the window in which the widget is contained.

Parameters:
w The widget.
Returns:
The y position of the widget.

Definition at line 810 of file ctk.h.


Function Documentation

unsigned char ctk_desktop_height ( struct ctk_desktop *  d  ) 

Gets the height of the desktop.

Parameters:
d The desktop.
Returns:
The height of the desktop, in characters.
Note:
The d parameter is currently unused and must be set to NULL.
CCIF unsigned char ctk_desktop_width ( struct ctk_desktop *  d  ) 

Gets the width of the desktop.

Parameters:
d The desktop.
Returns:
The width of the desktop, in characters.
Note:
The d parameter is currently unused and must be set to NULL.
void ctk_icon_add ( CC_REGISTER_ARG struct ctk_widget icon,
struct process *  p 
)

Add an icon to the desktop.

Parameters:
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.

Parameters:
menu The menu to be added.
Note:
Do not call this function multiple times for the same menu, as no check is made to see if the menu already is in the menu bar.

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.

Parameters:
menu The menu to be created.
title The title of the menu.

Definition at line 776 of file ctk.c.

void ctk_menu_remove ( struct ctk_menu menu  ) 

Remove a menu from the menu bar.

Parameters:
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.

Parameters:
menu The menu to which the menu item should be added.
name The name of the menu item.
Returns:
The number of the menu item.

Definition at line 801 of file ctk.c.

unsigned char ctk_mode_get ( void   ) 

Retrieves the current CTK mode.

Returns:
The current CTK mode.

Definition at line 292 of file ctk.c.

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.

Parameters:
m The mode.

Definition at line 281 of file ctk.c.

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.

Parameters:
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.

Parameters:
widget The widget that is to be redrawn.
Note:
This function should usually not be called directly since it requires typecasting of the widget parameter. The wrapper macro CTK_WIDGET_REDRAW() does the required typecast and should be used instead.
void ctk_window_clear ( struct ctk_window w  ) 

Remove all widgets from a window.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Definition at line 733 of file ctk.c.

void ctk_window_open ( CC_REGISTER_ARG struct ctk_window w  ) 

Open a window, or bring window to front if already open.

Parameters:
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.

Parameters:
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.


Variable Documentation

CCIF process_event_t ctk_signal_button_activate

Same as ctk_signal_widget_activate.

Definition at line 127 of file ctk.c.

CCIF process_event_t ctk_signal_button_hover

Same as ctk_signal_widget_select.

Definition at line 127 of file ctk.c.

CCIF process_event_t ctk_signal_hyperlink_activate

Emitted when a hyperlink is activated.

The signal is broadcast to all listeners.

Definition at line 127 of file ctk.c.

CCIF process_event_t ctk_signal_hyperlink_hover

Same as ctk_signal_widget_select.

Definition at line 127 of file ctk.c.

CCIF process_event_t ctk_signal_keypress

Emitted for every key being pressed.

The key is passed as signal data.

Definition at line 127 of file ctk.c.

CCIF process_event_t ctk_signal_menu_activate

Emitted when a menu item is activated.

The number of the menu item is passed as signal data.

Definition at line 152 of file ctk.c.

CCIF process_event_t ctk_signal_widget_activate

Emitted when a widget is activated (pressed).

A pointer to the widget is passed as signal data.

Definition at line 127 of file ctk.c.

CCIF process_event_t ctk_signal_widget_select

Emitted when a widget is selected.

A pointer to the widget is passed as signal data.

Definition at line 127 of file ctk.c.

CCIF process_event_t ctk_signal_window_close

Emitted when a window is closed.

A pointer to the window is passed as signal data.

Definition at line 156 of file ctk.c.


Generated on Mon Apr 11 14:23:51 2011 for Contiki 2.5 by  doxygen 1.6.1