📄 ctk.h
字号:
/** * \file * CTK header file. * \author Adam Dunkels <adam@dunkels.com> * * The CTK header file contains functioin declarations and definitions * of CTK structures and macros. *//* * Copyright (c) 2002-2003, Adam Dunkels. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of the Contiki desktop OS. * * $Id: ctk.h,v 1.17 2003/09/04 19:36:04 adamdunkels Exp $ * */#ifndef __CTK_H__#define __CTK_H__#include "ctk-conf.h"#include "ctk-arch.h"#include "ek.h"#include "cc.h"/* Defintions for the CTK widget types. *//** The CTK separator widget. */#define CTK_WIDGET_SEPARATOR 1/** The CTK label widget. */#define CTK_WIDGET_LABEL 2/** The CTK button widget. */#define CTK_WIDGET_BUTTON 3/** The CTK hyperlink widget. */#define CTK_WIDGET_HYPERLINK 4/** The CTK textentry widget. */#define CTK_WIDGET_TEXTENTRY 5/** The CTK bitmap widget. */#define CTK_WIDGET_BITMAP 6/** The CTK icon widget. */#define CTK_WIDGET_ICON 7struct ctk_widget;/** * 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: \code struct ctk_separator sep = {CTK_SEPARATOR(0, 0, 23)}; \endcode * \param w The widget's width. * \param x The x position of the widget, relative to the widget's * window. * \param y The y position of the widget, relative to the widget's * window. */#define CTK_SEPARATOR(x, y, w) \ NULL, NULL, x, y, CTK_WIDGET_SEPARATOR, w, 1struct ctk_separator { struct ctk_widget *next; struct ctk_window *window; unsigned char x, y; unsigned char type; unsigned char w, h;};/** * 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: \code struct ctk_button but = {CTK_BUTTON(0, 0, 2, "Ok")}; \endcode * \param text The button text. * \param w The widget's width. * \param x The x position of the widget, relative to the widget's * window. * \param y The y position of the widget, relative to the widget's * window. */#define CTK_BUTTON(x, y, w, text) \ NULL, NULL, x, y, CTK_WIDGET_BUTTON, w, 1, textstruct ctk_button { struct ctk_widget *next; struct ctk_window *window; unsigned char x, y; unsigned char type; unsigned char w, h; char *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: \code struct ctk_label lab = {CTK_LABEL(0, 0, 5, 1, "Label")}; \endcode * \param text The label text. * \param h The height of the label. * \param w The widget's width. * \param x The x position of the widget, relative to the widget's * window. * \param y The y position of the widget, relative to the widget's * window. */#define CTK_LABEL(x, y, w, h, text) \ NULL, NULL, x, y, CTK_WIDGET_LABEL, w, h, text,struct ctk_label { struct ctk_widget *next; struct ctk_window *window; unsigned char x, y; unsigned char type; unsigned char w, h; char *text;};/** * 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: \code struct ctk_hyperlink hlink = {CTK_HYPERLINK(0, 0, 7, "Contiki", "http://dunkels.com/adam/contiki/")}; \endcode * \param text The hyperlink text. * \param url The hyperlink URL. * \param w The widget's width. * \param x The x position of the widget, relative to the widget's * window. * \param y The y position of the widget, relative to the widget's * window. */#define CTK_HYPERLINK(x, y, w, text, url) \ NULL, NULL, x, y, CTK_WIDGET_HYPERLINK, w, 1, text, urlstruct ctk_hyperlink { struct ctk_widget *next; struct ctk_window *window; unsigned char x, y; unsigned char type; unsigned char w, h; char *text; char *url;};/* Editing modes of the CTK textentry widget. */#define CTK_TEXTENTRY_NORMAL 0 /**< \internal Textentry state: not edited. */#define CTK_TEXTENTRY_EDIT 1 /**< \internal Textentry state: currenly being edited. *//** * Clears a text entry widget and sets the cursor to the start of the * text line. * * \param e The text entry widget to be cleared. */#define CTK_TEXTENTRY_CLEAR(e) do {memset((e)->text, 0, (e)->len); (e)->xpos = 0;} while(0);/** * 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: \code struct ctk_textentry tentry = {CTK_TEXTENTRY(0, 0, 30, 1, textbuffer, 50)}; \endcode * \note The height of the text entry widget is obsolete and not * intended to be used. * * \param text A pointer to the buffer that should be edited. * \param len The length of the text buffer * \param h The text entry height (obsolete). * \param w The widget's width. * \param x The x position of the widget, relative to the widget's * window. * \param y The y position of the widget, relative to the widget's * window. */#define CTK_TEXTENTRY(x, y, w, h, text, len) \ NULL, NULL, x, y, CTK_WIDGET_TEXTENTRY, w, 1, text, len, \ CTK_TEXTENTRY_NORMAL, 0, 0struct ctk_textentry { struct ctk_widget *next; struct ctk_window *window; unsigned char x, y; unsigned char type; unsigned char w, h; char *text; unsigned char len; unsigned char state; unsigned char xpos, ypos;};/** * Instantiating macro for the ctk_icon widget. * * This macro is used when instantiating a ctk_icon widget and is * intended to be used together with a struct assignment like this: \code struct ctk_icon icon = {CTK_ICON("An icon", bitmapptr, textmapptr)}; \endcode * \param title The icon's text. * \param bitmap A pointer to the icon's bitmap image. * \param textmap A pointer to the icon's text version of the bitmap. */#define CTK_ICON(title, bitmap, textmap) \ NULL, NULL, 0, 0, CTK_WIDGET_ICON, 2, 4, title, 0, bitmap, textmapstruct ctk_icon { struct ctk_widget *next; struct ctk_window *window; unsigned char x, y; unsigned char type; unsigned char w, h; char *title; ek_id_t owner; unsigned char *bitmap; char *textmap;};#define CTK_BITMAP(x, y, w, h, bitmap) \ NULL, NULL, x, y, CTK_WIDGET_BITMAP, w, h, bitmap,struct ctk_bitmap { struct ctk_widget *next; struct ctk_window *window; unsigned char x, y; unsigned char type; unsigned char w, h; unsigned char *bitmap;};#define CTK_TEXTMAP_NORMAL 0#define CTK_TEXTMAP_ACTIVE 1#define CTK_TEXTMAP(x, y, w, h, textmap, flags) \ NULL, NULL, x, y, CTK_WIDGET_LABEL, w, h, text, flags, CTK_TEXTMAP_NORMALstruct ctk_textmap { struct ctk_widget *next; struct ctk_window *window; unsigned char x, y; unsigned char type; unsigned char w, h; char *textmap; unsigned char flags; unsigned char state;}; /** * \internal The CTK button widget structure. */struct ctk_widget_button { char *text; /**< The button text. */};/** * \internal The CTK label widget structure. */struct ctk_widget_label { char *text; /**< The label text. */};/** * \internal The CTK hyperlink widget structure. */struct ctk_widget_hyperlink { char *text; /**< The text of the hyperlink. */ char *url; /**< The hyperlink's URL. */};struct ctk_widget_textentry { char *text; unsigned char len; unsigned char state; unsigned char xpos, ypos;};struct ctk_widget_icon { char *title; ek_id_t owner; unsigned char *bitmap; char *textmap;};struct ctk_widget_bitmap { unsigned char *bitmap;};/** * The generic CTK widget structure that contains all other widget * structures. * * Since the widgets of a window are arranged on a linked list, the * widget structure contains a next pointer which is used for this * purpose. The widget structure also contains the placement and the * size of the widget. * * Finally, the actual per-widget structure is contained in this * top-level widget structure. */struct ctk_widget { struct ctk_widget *next; /**< The next widget in the linked list of widgets that is contained in the ctk_window structure. */ struct ctk_window *window; /**< The window in which the widget is contained. */ unsigned char x, /**< The x position of the widget within the containing window, in character coordinates. */ y; /**< The y position of the widget within the containing window, in character coordinates. */ unsigned char type; /**< The type of the widget: CTK_WIDGET_SEPARATOR, CTK_WIDGET_LABEL, CTK_WIDGET_BUTTON, CTK_WIDGET_HYPERLINK, CTK_WIDGET_TEXTENTRY, CTK_WIDGET_BITMAP or CTK_WIDGET_ICON. */ unsigned char w, /**< The width of the widget in character coordinates. */ h; /**< The height of the widget in character coordinates. */ union { struct ctk_widget_label label; struct ctk_widget_button button; struct ctk_widget_hyperlink hyperlink; struct ctk_widget_textentry textentry; struct ctk_widget_icon icon; struct ctk_widget_bitmap bitmap; } widget; /**< The union which contains the actual widget structure, as determined by the type field. */};struct ctk_desktop;/** * Repressentation of a CTK window. * * For the CTK, each window is repessented by a ctk_window * structure. All open windows are kept on a doubly linked list, * linked by the next and prev fields in the ctk_window struct. The * window structure holds all widgets that is contained in the window * as well as a pointer to the currently selected widget. * */struct ctk_window { struct ctk_window *next, /**< The next window in the doubly linked list of open windows. */ *prev; /**< The previous window in the doubly linked list of open windows. */ struct ctk_desktop *desktop;/**< The desktop on which this window is open. */ ek_id_t owner; /**< The process that owns the window. This process will be the receiver of all CTK signals that pertain to this window. */ char *title; /**< The title of the window. Used for constructing the "Dekstop" menu. */ unsigned char titlelen; /**< The length of the title, cached for speed reasons. */#if CTK_CONF_WINDOWCLOSE struct ctk_button closebutton; /**< The closebutton. This is also present in the list of active widgets. */#else /* CTK_CONF_WINDOWCLOSE */ struct ctk_label closebutton;#endif /* CTK_CONF_WINDOWCLOSE */ #if CTK_CONF_WINDOWMOVE struct ctk_button titlebutton;/**< The titlebutton which is used for
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -