diff options
| author | bernard.xiong <[email protected]> | 2009-10-04 02:56:38 +0000 |
|---|---|---|
| committer | bernard.xiong <[email protected]> | 2009-10-04 02:56:38 +0000 |
| commit | 90f9d0a2ab733f3930907693fceadba1d01c0df4 (patch) | |
| tree | 2fa88428f28ba4fb071afcd98c585d30176ef674 /rtgui/include | |
| parent | e3248a5045bd59b32c0b97a05c771928316f3aff (diff) | |
add basic files of RTGUI
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@69 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'rtgui/include')
| -rw-r--r-- | rtgui/include/rtgui/driver.h | 58 | ||||
| -rw-r--r-- | rtgui/include/rtgui/event.h | 425 | ||||
| -rw-r--r-- | rtgui/include/rtgui/rtgui.h | 103 | ||||
| -rw-r--r-- | rtgui/include/rtgui/rtgui_object.h | 109 | ||||
| -rw-r--r-- | rtgui/include/rtgui/rtgui_server.h | 70 | ||||
| -rw-r--r-- | rtgui/include/rtgui/rtgui_system.h | 81 | ||||
| -rw-r--r-- | rtgui/include/rtgui/rtgui_theme.h | 38 | ||||
| -rw-r--r-- | rtgui/include/rtgui/widgets/widget.h | 197 | ||||
| -rw-r--r-- | rtgui/include/rtgui/widgets/window.h | 91 | ||||
| -rw-r--r-- | rtgui/include/rtgui/widgets/workbench.h | 77 |
10 files changed, 1249 insertions, 0 deletions
diff --git a/rtgui/include/rtgui/driver.h b/rtgui/include/rtgui/driver.h new file mode 100644 index 0000000000..859a51b79b --- /dev/null +++ b/rtgui/include/rtgui/driver.h @@ -0,0 +1,58 @@ +/*
+ * File : driver.h
+ * This file is part of RTGUI in RT-Thread RTOS
+ * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rt-thread.org/license/LICENSE
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2009-10-04 Bernard first version
+ */
+#ifndef __RTGUI_DRIVER_H__
+#define __RTGUI_DRIVER_H__
+
+#include <rtgui/list.h>
+#include <rtgui/color.h>
+
+struct rtgui_graphic_driver
+{
+ /* driver name */
+ char* name;
+
+ /* byte per pixel */
+ rt_uint16_t byte_per_pixel;
+
+ /* screen width and height */
+ rt_uint16_t width;
+ rt_uint16_t height;
+
+ /* screen update */
+ void (*screen_update)(rtgui_rect_t* rect);
+
+ /* get video frame buffer */
+ rt_uint8_t* (*get_framebuffer)(void);
+
+ /* set and get pixel in (x, y) */
+ void (*set_pixel) (rtgui_color_t *c, rt_base_t x, rt_base_t y);
+ void (*get_pixel) (rtgui_color_t *c, rt_base_t x, rt_base_t y);
+
+ void (*draw_hline)(rtgui_color_t *c, rt_base_t x1, rt_base_t x2, rt_base_t y);
+ void (*draw_vline)(rtgui_color_t *c, rt_base_t x , rt_base_t y1, rt_base_t y2);
+
+ /* the driver list */
+ rtgui_list_t list;
+};
+
+void rtgui_graphic_driver_add(struct rtgui_graphic_driver* driver);
+void rtgui_graphic_driver_remove(struct rtgui_graphic_driver* driver);
+
+struct rtgui_graphic_driver* rtgui_graphic_driver_find(char* name);
+struct rtgui_graphic_driver* rtgui_graphic_driver_get_default(void);
+
+void rtgui_graphic_driver_get_rect(struct rtgui_graphic_driver *driver, rtgui_rect_t *rect);
+void rtgui_graphic_driver_get_default_rect(rtgui_rect_t *rect);
+
+#endif
diff --git a/rtgui/include/rtgui/event.h b/rtgui/include/rtgui/event.h new file mode 100644 index 0000000000..5a94107ee9 --- /dev/null +++ b/rtgui/include/rtgui/event.h @@ -0,0 +1,425 @@ +/*
+ * File : event.h
+ * This file is part of RTGUI in RT-Thread RTOS
+ * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rt-thread.org/license/LICENSE
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2009-10-04 Bernard first version
+ */
+#ifndef __RTGUI_EVENT_H__
+#define __RTGUI_EVENT_H__
+
+#include <rtgui/rtgui.h>
+#include <rtgui/kbddef.h>
+
+enum _rtgui_event_type
+{
+ /* panel event */
+ RTGUI_EVENT_PANEL_ATTACH = 0, /* attach to a panel */
+ RTGUI_EVENT_PANEL_DETACH, /* detach from a panel */
+ RTGUI_EVENT_PANEL_SHOW, /* show in a panel */
+ RTGUI_EVENT_PANEL_HIDE, /* hide from a panel */
+ RTGUI_EVENT_PANEL_INFO, /* panel information */
+ RTGUI_EVENT_PANEL_RESIZE, /* resize panel */
+ RTGUI_EVENT_PANEL_FULLSCREEN, /* to full screen */
+ RTGUI_EVENT_PANEL_NORMAL, /* to normal screen */
+
+ /* window event */
+ RTGUI_EVENT_WIN_CREATE, /* create a window */
+ RTGUI_EVENT_WIN_DESTROY, /* destroy a window */
+ RTGUI_EVENT_WIN_SHOW, /* show a window */
+ RTGUI_EVENT_WIN_HIDE, /* hide a window */
+ RTGUI_EVENT_WIN_ACTIVATE, /* activate a window */
+ RTGUI_EVENT_WIN_DEACTIVATE, /* deactivate a window */
+ RTGUI_EVENT_WIN_CLOSE, /* close a window */
+ RTGUI_EVENT_WIN_MOVE, /* move a window */
+ RTGUI_EVENT_WIN_RESIZE, /* resize a window */
+
+ /* WM event */
+ RTGUI_EVENT_SET_WM, /* set window manager */
+
+ RTGUI_EVENT_UPDATE_BEGIN, /* update a rect */
+ RTGUI_EVENT_UPDATE_END, /* update a rect */
+ RTGUI_EVENT_MONITOR_ADD, /* add a monitor rect */
+ RTGUI_EVENT_MONITOR_REMOVE, /* remove a monitor rect*/
+ RTGUI_EVENT_PAINT, /* paint on screen */
+ RTGUI_EVENT_TIMER, /* timer */
+
+ /* clip rect information */
+ RTGUI_EVENT_CLIP_INFO, /* clip rect info */
+
+ /* mouse and keyboard event */
+ RTGUI_EVENT_MOUSE_MOTION, /* mouse motion */
+ RTGUI_EVENT_MOUSE_BUTTON, /* mouse button info */
+ RTGUI_EVENT_KBD, /* keyboard info */
+
+ /* user command event */
+ RTGUI_EVENT_COMMAND, /* user command */
+
+ /* widget event */
+ RTGUI_EVENT_FOCUSED, /* widget focused */
+ RTGUI_EVENT_SCROLLED, /* scroll bar scrolled */
+ RTGUI_EVENT_RESIZE, /* widget resize */
+};
+typedef enum _rtgui_event_type rtgui_event_type;
+
+enum {
+ RTGUI_STATUS_OK = 0, /* status ok */
+ RTGUI_STATUS_ERROR, /* generic error */
+ RTGUI_STATUS_NRC, /* no resource */
+};
+
+struct rtgui_event
+{
+ /* the event type */
+ rt_uint32_t type;
+
+ /* the event sender */
+ rt_thread_t sender;
+
+ /* mailbox to acknowledge request */
+ rt_mailbox_t ack;
+};
+typedef struct rtgui_event rtgui_event_t;
+#define RTGUI_EVENT(e) ((struct rtgui_event*)(e))
+
+#define RTGUI_EVENT_INIT(e, t) do \
+{ \
+ (e)->type = (t); \
+ (e)->sender = rt_thread_self(); \
+ (e)->ack = RT_NULL; \
+} while (0)
+
+/*
+ * RTGUI Panel Event
+ */
+struct rtgui_event_panel_attach
+{
+ struct rtgui_event parent;
+
+ /* the panel name to be attached */
+ char panel_name[RTGUI_NAME_MAX];
+
+ /* workbench, wm field */
+ rtgui_workbench_t* workbench;
+};
+
+struct rtgui_event_panel_detach
+{
+ struct rtgui_event parent;
+
+ /* the panel which thread belong to */
+ rtgui_panel_t* panel;
+
+ /* workbench, wm field */
+ rtgui_workbench_t* workbench;
+};
+
+struct rtgui_event_panel_show
+{
+ struct rtgui_event parent;
+
+ /* the panel which thread belong to */
+ rtgui_panel_t* panel;
+
+ /* workbench, wm field */
+ rtgui_workbench_t* workbench;
+};
+
+struct rtgui_event_panel_hide
+{
+ struct rtgui_event parent;
+
+ /* the panel which thread belong to */
+ rtgui_panel_t* panel;
+
+ /* workbench, wm field */
+ rtgui_workbench_t* workbench;
+};
+
+struct rtgui_event_panel_info
+{
+ struct rtgui_event parent;
+
+ /* panel info */
+ rtgui_panel_t* panel;
+ rtgui_rect_t extent;
+};
+
+#define RTGUI_EVENT_PANEL_ATTACH_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_PANEL_ATTACH)
+#define RTGUI_EVENT_PANEL_DETACH_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_PANEL_DETACH)
+#define RTGUI_EVENT_PANEL_SHOW_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_PANEL_SHOW)
+#define RTGUI_EVENT_PANEL_HIDE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_PANEL_HIDE)
+#define RTGUI_EVENT_PANEL_INFO_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_PANEL_INFO)
+
+/*
+ * RTGUI Window Event
+ */
+struct rtgui_event_win
+{
+ struct rtgui_event parent;
+
+ /* the window id */
+ rtgui_win_t* wid;
+};
+
+struct rtgui_event_win_create
+{
+ struct rtgui_event parent;
+
+ /* the window event mask */
+ rt_uint32_t mask;
+
+ /* the window flag */
+ rt_uint32_t flag;
+
+ /* the window title */
+ rt_uint8_t title[RTGUI_NAME_MAX];
+
+ /* the window id */
+ rtgui_win_t* wid;
+ /* the window extent */
+ struct rtgui_rect extent;
+};
+
+struct rtgui_event_win_move
+{
+ struct rtgui_event parent;
+
+ /* the window id */
+ rtgui_win_t* wid;
+
+ rt_int16_t x, y;
+};
+
+struct rtgui_event_win_resize
+{
+ struct rtgui_event parent;
+
+ /* the window id */
+ rtgui_win_t* wid;
+
+ rtgui_rect_t rect;
+};
+
+#define rtgui_event_win_destroy rtgui_event_win
+#define rtgui_event_win_show rtgui_event_win
+#define rtgui_event_win_hide rtgui_event_win
+#define rtgui_event_win_activate rtgui_event_win
+#define rtgui_event_win_deactivate rtgui_event_win
+#define rtgui_event_win_close rtgui_event_win
+ +/* window event init */
+#define RTGUI_EVENT_WIN_CREATE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_CREATE)
+#define RTGUI_EVENT_WIN_DESTROY_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_DESTROY)
+#define RTGUI_EVENT_WIN_SHOW_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_SHOW)
+#define RTGUI_EVENT_WIN_HIDE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_HIDE)
+#define RTGUI_EVENT_WIN_ACTIVATE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_ACTIVATE)
+#define RTGUI_EVENT_WIN_DEACTIVATE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_DEACTIVATE)
+#define RTGUI_EVENT_WIN_CLOSE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_CLOSE)
+#define RTGUI_EVENT_WIN_MOVE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_MOVE)
+#define RTGUI_EVENT_WIN_RESIZE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_RESIZE)
+
+/*
+ * RTGUI Workbench Manager Event
+ */
+struct rtgui_event_set_wm
+{
+ struct rtgui_event parent;
+
+ /* the panel name to be managed */
+ char panel_name[RTGUI_NAME_MAX];
+};
+/* window event init */
+#define RTGUI_EVENT_SET_WM_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_SET_WM)
+
+/*
+ * RTGUI Other Event
+ */
+struct rtgui_event_update_begin
+{
+ struct rtgui_event parent;
+
+ /* the update rect */
+ rtgui_rect_t rect;
+};
+
+struct rtgui_event_update_end
+{
+ struct rtgui_event parent;
+
+ /* the update rect */
+ rtgui_rect_t rect;
+};
+
+struct rtgui_event_monitor
+{
+ struct rtgui_event parent;
+
+ /* the monitor rect */
+ rtgui_rect_t rect;
+
+ /* under panel */
+ rtgui_panel_t* panel;
+
+ /* or under window */
+ rtgui_win_t* wid;
+};
+
+struct rtgui_event_paint
+{
+ struct rtgui_event parent;
+
+ rtgui_win_t* wid; /* destination window */
+};
+
+struct rtgui_timer;
+struct rtgui_event_timer
+{
+ struct rtgui_event parent;
+
+ void (*callback)(struct rtgui_timer* timer, void* parameter);
+ void *parameter;
+};
+
+struct rtgui_event_clip_info
+{
+ struct rtgui_event parent;
+
+ /* destination window */
+ rtgui_win_t* wid;
+
+ /* the number of rects */
+ rt_uint32_t num_rect;
+
+ struct rtgui_rect rects[0];
+};
+#define RTGUI_EVENT_GET_RECT(e, i) (&(e->rects[0]) + i)
+
+#define RTGUI_EVENT_UPDATE_BEGIN_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_UPDATE_BEGIN)
+#define RTGUI_EVENT_UPDATE_END_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_UPDATE_END)
+#define RTGUI_EVENT_MONITOR_ADD_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MONITOR_ADD)
+#define RTGUI_EVENT_MONITOR_REMOVE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MONITOR_REMOVE)
+#define RTGUI_EVENT_CLIP_INFO_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_CLIP_INFO)
+#define RTGUI_EVENT_PAINT_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_PAINT)
+#define RTGUI_EVENT_TIMER_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_TIMER)
+
+/*
+ * RTGUI Mouse and Keyboard Event
+ */
+struct rtgui_event_mouse
+{
+ struct rtgui_event parent;
+
+ rtgui_win_t* wid; /* destination window */
+
+ rt_uint16_t x, y;
+ rt_uint16_t button;
+};
+#define RTGUI_MOUSE_BUTTON_LEFT 0x01
+#define RTGUI_MOUSE_BUTTON_RIGHT 0x02
+#define RTGUI_MOUSE_BUTTON_MIDDLE 0x03
+#define RTGUI_MOUSE_BUTTON_WHEELUP 0x04
+#define RTGUI_MOUSE_BUTTON_WHEELDOWN 0x08
+
+#define RTGUI_MOUSE_BUTTON_DOWN 0x10
+#define RTGUI_MOUSE_BUTTON_UP 0x20
+
+struct rtgui_event_kbd
+{
+ struct rtgui_event parent;
+
+ rtgui_win_t* wid; /* destination window */
+
+ RTGUI_KBD_TYPE type; /* key down or up */
+ RTGUI_KBD_KEY key; /* current key */
+ RTGUI_KBD_MOD mod; /* current key modifiers */
+ rt_uint16_t unicode; /* translated character */
+};
+#define RTGUI_KBD_IS_SET_CTRL(e) ((e)->mod & (RTGUI_KMOD_LCTRL | RTGUI_KMOD_RCTRL)))
+#define RTGUI_KBD_IS_SET_ALT(e) ((e)->mod & (RTGUI_KMOD_LALT | RTGUI_KMOD_RALT))
+#define RTGUI_KBD_IS_SET_SHIFT(e) ((e)->mod & (RTGUI_KMOD_LSHIFT| RTGUI_KMOD_RSHIFT))
+#define RTGUI_KBD_IS_UP(e) ((e)->type == RTGUI_KEYUP)
+#define RTGUI_KBD_IS_DOWN(e) ((e)->flag == RTGUI_KEYDOWN)
+
+#define RTGUI_EVENT_MOUSE_MOTION_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MOUSE_MOTION)
+#define RTGUI_EVENT_MOUSE_BUTTON_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_MOUSE_BUTTON)
+#define RTGUI_EVENT_KBD_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_KBD)
+
+struct rtgui_event_command
+{
+ struct rtgui_event parent;
+
+ /* command type */
+ rt_int32_t type;
+
+ /* command id */
+ rt_int32_t command_id;
+
+ /* command integer */
+ rt_int32_t command_int;
+
+ /* command string */
+ char command_string[RTGUI_NAME_MAX];
+};
+#define RTGUI_EVENT_COMMAND_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_COMMAND)
+
+#define RTGUI_CMD_UNKNOWN 0x00
+#define RTGUI_CMD_WM_CLOSE 0x10
+
+#define RTGUI_CMD_USER_INT 0x20
+#define RTGUI_CMD_USER_STRING 0x21
+
+/************************************************************************/
+/* Widget Event */
+/************************************************************************/
+#define RTGUI_WIDGET_EVENT_INIT(e, t) do \
+{ \
+ (e)->type = (t); \
+ (e)->sender = RT_NULL; \
+ (e)->ack = RT_NULL; \
+} while (0)
+
+/*
+ * RTGUI Scrollbar Event
+ */
+struct rtgui_event_scrollbar
+{
+ struct rtgui_event parent;
+
+ rt_uint8_t event;
+};
+#define RTGUI_SCROLL_LINEUP 0x01
+#define RTGUI_SCROLL_LINEDOWN 0x02
+#define RTGUI_SCROLL_PAGEUP 0x03
+#define RTGUI_SCROLL_PAGEDOWN 0x04
+#define RTGUI_EVENT_SCROLLED_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_SCROLLED)
+
+/*
+ * RTGUI Widget Focused Event
+ */
+struct rtgui_event_focused
+{
+ struct rtgui_event parent;
+
+ struct rtgui_widget* widget;
+};
+#define RTGUI_EVENT_FOCUSED_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_FOCUSED)
+
+/*
+ * RTGUI Widget Resize Event
+ */
+struct rtgui_event_resize
+{
+ struct rtgui_event parent;
+ rt_int16_t x, y;
+ rt_int16_t w, h;
+};
+#define RTGUI_EVENT_RESIZE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_RESIZE)
+ +#endif
diff --git a/rtgui/include/rtgui/rtgui.h b/rtgui/include/rtgui/rtgui.h new file mode 100644 index 0000000000..bc820b76c0 --- /dev/null +++ b/rtgui/include/rtgui/rtgui.h @@ -0,0 +1,103 @@ +/* + * File : rtgui.h + * This file is part of RTGUI in RT-Thread RTOS + * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2009-10-04 Bernard first version + */ +#ifndef __RT_GUI_H__ +#define __RT_GUI_H__ + +#include <rtthread.h> + +/* RTGUI options */ +#define RTGUI_IMAGE_JPEG + +#define RTGUI_NAME_MAX 32 + +#define RT_INT16_MAX 32767 +#define RT_INT16_MIN (-RT_INT16_MAX-1) + +struct rtgui_panel; +struct rtgui_event; + +struct rtgui_widget; +struct rtgui_win; + +typedef struct rtgui_panel rtgui_panel_t; +typedef struct rtgui_win rtgui_win_t;
+typedef struct rtgui_workbench rtgui_workbench_t; +typedef rt_bool_t (*rtgui_event_handler_ptr)(struct rtgui_widget* widget, struct rtgui_event* event); + +struct rtgui_point +{ + rt_int16_t x, y; +}; +typedef struct rtgui_point rtgui_point_t; + +struct rtgui_rect +{ + rt_int16_t x1, y1, x2, y2; +}; +typedef struct rtgui_rect rtgui_rect_t; +#define rtgui_rect_width(r) ((r).x2 - (r).x1) +#define rtgui_rect_height(r) ((r).y2 - (r).y1) + +enum RTGUI_MARGIN_STYLE +{ + RTGUI_MARGIN_LEFT = 0x01, + RTGUI_MARGIN_RIGHT = 0x02, + RTGUI_MARGIN_TOP = 0x04, + RTGUI_MARGIN_BOTTOM = 0x08, + RTGUI_MARGIN_ALL = RTGUI_MARGIN_LEFT | RTGUI_MARGIN_RIGHT | RTGUI_MARGIN_TOP | RTGUI_MARGIN_BOTTOM +}; +enum RTGUI_BORDER_STYLE +{ + RTGUI_BORDER_NONE = 0, + RTGUI_BORDER_SIMPLE, + RTGUI_BORDER_RAISE, + RTGUI_BORDER_SUNKEN, + RTGUI_BORDER_BOX, + RTGUI_BORDER_STATIC, + RTGUI_BORDER_EXTRA +}; +#define RTGUI_BORDER_DEFAULT_WIDTH 2 +#define RTGUI_WIDGET_DEFAULT_MARGIN 3 + +enum RTGUI_ORIENTATION +{ + RTGUI_HORIZONTAL = 0x01, + RTGUI_VERTICAL = 0x02, + RTGUI_ORIENTATION_BOTH = RTGUI_HORIZONTAL | RTGUI_VERTICAL +}; + +enum RTGUI_ALIGN +{ + RTGUI_ALIGN_NOT = 0x00, + RTGUI_ALIGN_CENTER_HORIZONTAL = 0x01, + RTGUI_ALIGN_LEFT = RTGUI_ALIGN_NOT, + RTGUI_ALIGN_TOP = RTGUI_ALIGN_NOT, + RTGUI_ALIGN_RIGHT = 0x02, + RTGUI_ALIGN_BOTTOM = 0x04, + RTGUI_ALIGN_CENTER_VERTICAL = 0x08, + RTGUI_ALIGN_EXPAND = 0x10, + RTGUI_ALIGN_STRETCH = 0x20 +}; + +enum RTGUI_ARRAW +{ + RTGUI_ARRAW_UP = 0, + RTGUI_ARRAW_DOWN, + RTGUI_ARRAW_LEFT, + RTGUI_ARRAW_RIGHT +}; + +#include <rtgui/rtgui_object.h> + +#endif diff --git a/rtgui/include/rtgui/rtgui_object.h b/rtgui/include/rtgui/rtgui_object.h new file mode 100644 index 0000000000..9c06137701 --- /dev/null +++ b/rtgui/include/rtgui/rtgui_object.h @@ -0,0 +1,109 @@ +/*
+ * File : rtgui_object.h
+ * This file is part of RTGUI in RT-Thread RTOS
+ * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rt-thread.org/license/LICENSE
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2009-10-04 Bernard first version
+ */
+#ifndef __RTGUI_OBJECT_H__
+#define __RTGUI_OBJECT_H__
+
+
+#include <rtthread.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* rtgui object type */
+
+/** Casts the function pointer to an rtgui_constructor */
+#define RTGUI_CONSTRUCTOR(constructor) ((rtgui_constructor_t)(constructor))
+/** Casts the function pointer to an rtgui_constructor */
+#define RTGUI_DESTRUCTOR(destructor) ((rtgui_destructor_t)(destructor))
+
+/* pre-definetion */
+struct rtgui_object;
+typedef struct rtgui_object rtgui_object_t;
+typedef void (*rtgui_constructor_t)(rtgui_object_t *object);
+typedef void (*rtgui_destructor_t)(rtgui_object_t *object);
+
+/* rtgui type structure */
+struct rtgui_type
+{
+ /* type name */
+ char* name;
+
+ /* hierarchy and depth */
+ struct rtgui_type **hierarchy;
+ int hierarchy_depth;
+
+ /* constructor and destructor */
+ rtgui_constructor_t constructor;
+ rtgui_destructor_t destructor;
+
+ /* size of type */
+ int size;
+};
+typedef struct rtgui_type rtgui_type_t;
+
+rtgui_type_t *rtgui_type_create(const char *type_name, rtgui_type_t *parent_type,
+ int type_size, rtgui_constructor_t constructor,
+ rtgui_destructor_t destructor);
+void rtgui_type_destroy(rtgui_type_t *type);
+
+void rtgui_type_object_construct(rtgui_type_t *type, rtgui_object_t *object);
+void rtgui_type_destructors_call(rtgui_type_t *type, rtgui_object_t *object);
+rt_bool_t rtgui_type_inherits_from(rtgui_type_t *type, rtgui_type_t *parent);
+rtgui_type_t *rtgui_type_parent_type_get(rtgui_type_t *type);
+const char *rtgui_type_name_get(rtgui_type_t *type);
+rtgui_type_t *rtgui_type_get_from_name(const char *name);
+
+#ifdef RTGUI_USING_CAST_CHECK
+ #define RTGUI_OBJECT_CAST(obj, rtgui_type_t, c_type) \
+ ((c_type *)rtgui_object_check_cast((rtgui_object_t *)(obj), (rtgui_type_t)))
+#else
+ #define RTGUI_OBJECT_CAST(obj, rtgui_type_t, c_type) ((c_type *)(obj))
+#endif
+
+#define RTGUI_OBJECT_CHECK_TYPE(_obj, _type) \
+ (rtgui_type_inherits_from(((rtgui_object_t *)(_obj))->type, (_type)))
+
+/** Gets the type of an object */
+#define RTGUI_OBJECT_TYPE (rtgui_object_type_get())
+/** Casts the object to an rtgui_object_t */
+#define RTGUI_OBJECT(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_OBJECT_TYPE, rtgui_object_t))
+/** Checks if the object is an rtgui_Object */
+#define RTGUI_IS_OBJECT(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_OBJECT_TYPE))
+
+/* rtgui base object */
+struct rtgui_object
+{
+ /* object type */
+ rtgui_type_t* type;
+
+ char *name;
+ rt_bool_t is_static;
+};
+rtgui_type_t *rtgui_object_type_get(void);
+
+rtgui_object_t *rtgui_object_create(rtgui_type_t *object_type);
+void rtgui_object_destroy(rtgui_object_t *object);
+
+void rtgui_object_name_set(rtgui_object_t *object, const char *name);
+const char *rtgui_object_name_get(rtgui_object_t *object);
+
+rtgui_object_t *rtgui_object_check_cast(rtgui_object_t *object, rtgui_type_t *type);
+rtgui_type_t *rtk_object_object_type_get(rtgui_object_t *object);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/rtgui/include/rtgui/rtgui_server.h b/rtgui/include/rtgui/rtgui_server.h new file mode 100644 index 0000000000..a9463ecb38 --- /dev/null +++ b/rtgui/include/rtgui/rtgui_server.h @@ -0,0 +1,70 @@ +/*
+ * File : rtgui_server.h
+ * This file is part of RTGUI in RT-Thread RTOS
+ * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rt-thread.org/license/LICENSE
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2009-10-04 Bernard first version
+ */
+#ifndef __RTGUI_SERVER_H__
+#define __RTGUI_SERVER_H__
+
+#include <rtgui/list.h>
+
+/* RTGUI server definitions */
+
+/* top window definitions in server */
+enum
+{
+ WINTITLE_NO = 0x01,
+ WINTITLE_BORDER = 0x02,
+ WINTITLE_ACTIVATE = 0x04,
+ WINTITLE_CLOSEBOX = 0x08,
+ WINTITLE_MOVE = 0x0C,
+ WINTITLE_CB_PRESSED = 0x10,
+ WINTITLE_NOFOCUS = 0x20
+};
+
+#define WINTITLE_HEIGHT 20
+#define WINTITLE_BORDER_SIZE 1
+
+struct rtgui_topwin
+{
+ /* the window flag */
+ rt_uint32_t flag;
+ /* event mask */
+ rt_uint32_t mask;
+
+ struct rtgui_wintitle* title;
+
+ /* the window id */
+ struct rtgui_win* wid;
+
+ /* the thread id */
+ rt_thread_t tid;
+
+ /* the extent information */
+ rtgui_rect_t extent;
+
+ /* the top window list */
+ rtgui_list_t list;
+
+ /* the monitor rect list */
+ rtgui_list_t monitor_list;
+};
+typedef struct rtgui_topwin rtgui_topwin_t;
+
+/* top win manager init */
+void rtgui_topwin_init(void);
+void rtgui_panel_init (void);
+void rtgui_server_init(void);
+
+/* post an event to server */
+void rtgui_server_post_event(struct rtgui_event* event, rt_size_t size);
+
+#endif
diff --git a/rtgui/include/rtgui/rtgui_system.h b/rtgui/include/rtgui/rtgui_system.h new file mode 100644 index 0000000000..e0ceae6f2b --- /dev/null +++ b/rtgui/include/rtgui/rtgui_system.h @@ -0,0 +1,81 @@ +/*
+ * File : rtgui_system.h
+ * This file is part of RTGUI in RT-Thread RTOS
+ * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rt-thread.org/license/LICENSE
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2009-10-04 Bernard first version
+ */
+#ifndef __RTGUI_SYSTEM_H__
+#define __RTGUI_SYSTEM_H__
+
+#include <rtthread.h>
+#include <rtgui/rtgui.h>
+
+struct rtgui_dc;
+struct rtgui_event;
+struct rtgui_widget;
+
+struct rtgui_thread
+{
+ /* the thread id */
+ rt_thread_t tid;
+
+ /* the message queue of thread */
+ rt_mq_t mq;
+
+ /* the owner of thread */
+ struct rtgui_widget* widget;
+};
+typedef struct rtgui_thread rtgui_thread_t;
+struct rtgui_timer;
+typedef void (*rtgui_timeout_func)(struct rtgui_timer* timer, void* parameter);
+
+struct rtgui_timer
+{
+ /* context thread id */
+ rt_thread_t tid;
+ /* rt timer */
+ struct rt_timer timer;
+
+ /* timeout function and user data */
+ rtgui_timeout_func timeout;
+ void* user_data;
+};
+typedef struct rtgui_timer rtgui_timer_t;
+
+rtgui_timer_t* rtgui_timer_create(rt_int32_t time, rt_base_t flag, rtgui_timeout_func timeout, void* parameter);
+void rtgui_timer_destory(rtgui_timer_t* timer);
+
+void rtgui_timer_start(rtgui_timer_t* timer);
+void rtgui_timer_stop (rtgui_timer_t* timer);
+
+void rtgui_thread_system_init(void);
+rtgui_thread_t* rtgui_thread_register(rt_thread_t tid, rt_mq_t mq);
+void rtgui_thread_deregister(rt_thread_t tid);
+
+rt_thread_t rtgui_thread_get_server(void);
+
+void rtgui_thread_set_widget(struct rtgui_widget* widget);
+struct rtgui_widget* rtgui_thread_get_widget(void);
+
+rt_err_t rtgui_thread_send(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size);
+rt_err_t rtgui_thread_send_urgent(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size);
+rt_err_t rtgui_thread_send_sync(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size);
+rt_err_t rtgui_thread_recv(struct rtgui_event* event, rt_size_t event_size);
+rt_err_t rtgui_thread_recv_filter(rt_uint32_t type, struct rtgui_event* event, rt_size_t event_size);
+rt_err_t rtgui_thread_ack(struct rtgui_event* event, rt_int32_t status);
+
+/* rtgui system initialization function */
+void rtgui_system_server_init(void);
+void rtgui_system_app_init(void);
+
+void* rtgui_malloc(rt_size_t size);
+void rtgui_free(void* ptr);
+
+#endif
diff --git a/rtgui/include/rtgui/rtgui_theme.h b/rtgui/include/rtgui/rtgui_theme.h new file mode 100644 index 0000000000..eb6738d6b5 --- /dev/null +++ b/rtgui/include/rtgui/rtgui_theme.h @@ -0,0 +1,38 @@ +/*
+ * File : rtgui_theme.h
+ * This file is part of RTGUI in RT-Thread RTOS
+ * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rt-thread.org/license/LICENSE
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2009-10-04 Bernard first version
+ */
+#ifndef __RTGUI_THEME_H__
+#define __RTGUI_THEME_H__
+
+#include <rtgui/rtgui.h>
+
+#include <rtgui/widgets/label.h>
+#include <rtgui/widgets/button.h>
+#include <rtgui/widgets/textbox.h>
+#include <rtgui/widgets/iconbox.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void rtgui_theme_draw_win(struct rtgui_topwin* win);
+void rtgui_theme_draw_button(rtgui_button_t* btn);
+void rtgui_theme_draw_label(rtgui_label_t* label);
+void rtgui_theme_draw_textbox(rtgui_textbox_t* box);
+void rtgui_theme_draw_iconbox(rtgui_iconbox_t* iconbox);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/rtgui/include/rtgui/widgets/widget.h b/rtgui/include/rtgui/widgets/widget.h new file mode 100644 index 0000000000..9d0508390b --- /dev/null +++ b/rtgui/include/rtgui/widgets/widget.h @@ -0,0 +1,197 @@ +/* + * File : widget.h + * This file is part of RTGUI in RT-Thread RTOS + * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2009-10-04 Bernard first version + */ +#ifndef __RTGUI_WIDGET_H__ +#define __RTGUI_WIDGET_H__ + +#include <rtgui/rtgui.h> +#include <rtgui/list.h> +#include <rtgui/region.h> +#include <rtgui/event.h> +#include <rtgui/color.h> +#include <rtgui/font.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define RTGUI_WIDGET_FLAG_HIDE 0x01 +#define RTGUI_WIDGET_FLAG_DISABLE 0x02 +#define RTGUI_WIDGET_FLAG_FOCUS 0x04 +#define RTGUI_WIDGET_FLAG_TRANSPARENT 0x08 +#define RTGUI_WIDGET_FLAG_FOCUSABLE 0x10 +#define RTGUI_WIDGET_FLAG_DEFAULT 0x00 + +#define RTGUI_WIDGET_UNHIDE(w) (w)->flag &= ~RTGUI_WIDGET_FLAG_HIDE +#define RTGUI_WIDGET_HIDE(w) (w)->flag |= RTGUI_WIDGET_FLAG_HIDE +#define RTGUI_WIDGET_IS_HIDE(w) ((w)->flag & RTGUI_WIDGET_FLAG_HIDE) + +#define RTGUI_WIDGET_ENABLE(w) (w)->flag &= ~RTGUI_WIDGET_FLAG_DISABLE +#define RTGUI_WIDGET_DISABLE(w) (w)->flag |= RTGUI_WIDGET_FLAG_DISABLE +#define RTGUI_WIDGET_IS_ENABLE(w) !(w->flag & RTGUI_WIDGET_FLAG_DISABLE) + +#define RTGUI_WIDGET_UNFOCUS(w) (w)->flag &= ~RTGUI_WIDGET_FLAG_FOCUS +#define RTGUI_WIDGET_FOCUS(w) (w)->flag |= RTGUI_WIDGET_FLAG_FOCUS +#define RTGUI_WIDGET_IS_FOCUS(w) ((w)->flag & RTGUI_WIDGET_FLAG_FOCUS) + +#define RTGUI_WIDGET_IS_FOCUSABLE(w) ((w)->flag & RTGUI_WIDGET_FLAG_FOCUSABLE) + +/* get rtgui widget object */ +#define RTGUI_WIDGET_FOREGROUND(w) ((w)->gc.foreground) +#define RTGUI_WIDGET_BACKGROUND(w) ((w)->gc.background) +#define RTGUI_WIDGET_TEXTALIGN(w) ((w)->gc.textalign) +#define RTGUI_WIDGET_FONT(w) ((w)->gc.font) +#define RTGUI_WIDGET_FLAG(w) ((w)->flag) + +/** Gets the type of a widget */ +#define RTGUI_WIDGET_TYPE (rtgui_widget_type_get()) +/** Casts the object to a rtgui_widget */ +#define RTGUI_WIDGET(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_WIDGET_TYPE, rtgui_widget_t)) +/** Check if the object is a rtgui_widget */ +#define RTGUI_IS_WIDGET(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_WIDGET_TYPE)) + +struct rtgui_gc +{ + /* foreground and background color */ + rtgui_color_t foreground, background; + + /* text align */ + rt_base_t textalign; + + /* font */ + rtgui_font_t* font; +}; +typedef struct rtgui_gc rtgui_gc_t; + +/* + * the base widget object + */ +struct rtgui_widget +{ + /* inherit from rtgui_object */ + struct rtgui_object object; + + /* the parent and root widget */ + struct rtgui_widget *parent, *toplevel; + /* the widget children and sibling */ + rtgui_list_t sibling; + + /* widget flag */ + rt_int32_t flag; + /* widget align */ + rt_int32_t align; + + /* the graphic context of widget */ + rtgui_gc_t gc; + + /* the widget extent */ + rtgui_rect_t extent; + rt_int16_t mini_width, mini_height; + rt_int16_t margin, margin_style; + + /* the rect clip */ + rtgui_region_t clip; + rt_uint32_t clip_sync; + + /* the event handler */ + rt_bool_t (*event_handler) (struct rtgui_widget* widget, struct rtgui_event* event); + + /* call back */ + rt_bool_t (*on_draw) (struct rtgui_widget* widget, struct rtgui_event* event); + rt_bool_t (*on_focus_in) (struct rtgui_widget* widget, struct rtgui_event* event); + rt_bool_t (*on_focus_out) (struct rtgui_widget* widget, struct rtgui_event* event); + rt_bool_t (*on_mouseclick) (struct rtgui_widget* widget, struct rtgui_event* event); + rt_bool_t (*on_key) (struct rtgui_widget* widget, struct rtgui_event* event); + rt_bool_t (*on_size) (struct rtgui_widget* widget, struct rtgui_event* event); + rt_bool_t (*on_command) (struct rtgui_widget* widget, struct rtgui_event* event); +}; +typedef struct rtgui_widget rtgui_widget_t; + +rtgui_type_t *rtgui_widget_type_get(void); +rtgui_widget_t *rtgui_widget_create(rtgui_type_t *widget_type); +void rtgui_widget_destroy(rtgui_widget_t* widget); + +/* initial a widget */ +void rtgui_widget_init(rtgui_widget_t* widget, rtgui_type_t type, rtgui_rect_t* rect); +/* detach a widget */ +void rtgui_widget_detach(rtgui_widget_t* widget); + +/* update toplevel widget */ +void rtgui_widget_update_toplevel(rtgui_widget_t* widget); + +/* set the event handler of widget */ +void rtgui_widget_set_event_handler(rtgui_widget_t* widget, rtgui_event_handler_ptr handler); +/* widget default event handler */ +rt_bool_t rtgui_widget_event_handler(rtgui_widget_t* widget, rtgui_event_t* event); + +/* dispatch event to child widget */ +rt_bool_t rtgui_widget_dispatch_event(rtgui_widget_t* widget, rtgui_event_t* event); +rt_bool_t rtgui_widget_dispatch_mouse_event(rtgui_widget_t* widget, struct rtgui_event_mouse* event); + +/* set and get widget label */ +char* rtgui_widget_get_label(rtgui_widget_t* widget); +void rtgui_widget_set_label(rtgui_widget_t* widget, const char* label); + +/* focus and unfocus */ +void rtgui_widget_focus(rtgui_widget_t * widget); +void rtgui_widget_unfocus(rtgui_widget_t *widget); + +/* event handler for each command */ +void rtgui_widget_set_ondraw(rtgui_widget_t* widget, rtgui_event_handler_ptr handler); +void rtgui_widget_set_onfocus(rtgui_widget_t* widget, rtgui_event_handler_ptr handler); +void rtgui_widget_set_onunfocus(rtgui_widget_t* widget, rtgui_event_handler_ptr handler); +void rtgui_widget_set_onmouseclick(rtgui_widget_t* widget, rtgui_event_handler_ptr handler); +void rtgui_widget_set_onkey(rtgui_widget_t* widget, rtgui_event_handler_ptr handler); +void rtgui_widget_set_onsize(rtgui_widget_t* widget, rtgui_event_handler_ptr handler); +void rtgui_widget_set_oncommand(rtgui_widget_t* widget, rtgui_event_handler_ptr handler); + +/* get and set rect of widget */ +void rtgui_widget_get_rect(rtgui_widget_t* widget, rtgui_rect_t *rect); +void rtgui_widget_set_rect(rtgui_widget_t* widget, rtgui_rect_t* rect); + +void rtgui_widget_set_miniwidth(rtgui_widget_t* widget, int width); +void rtgui_widget_set_miniheight(rtgui_widget_t* widget, int height); + +/* get the physical position of a logic point on widget */ +void rtgui_widget_point_to_device(rtgui_widget_t * widget, rtgui_point_t * point); +/* get the physical position of a logic rect on widget */ +void rtgui_widget_rect_to_device(rtgui_widget_t * widget, rtgui_rect_t * rect); + +/* get the logic position of a physical point on widget */ +void rtgui_widget_point_to_logic(rtgui_widget_t* widget, rtgui_point_t * point); +/* get the logic position of a physical rect on widget */ +void rtgui_widget_rect_to_logic(rtgui_widget_t* widget, rtgui_rect_t* rect); + +/* move widget and its children to a logic point */ +void rtgui_widget_move_to_logic(rtgui_widget_t* widget, int dx, int dy); + +/* update the clip info of widget */ +void rtgui_widget_update_clip(rtgui_widget_t* widget); + +/* get the toplevel widget of widget */ +rtgui_widget_t* rtgui_widget_get_toplevel(rtgui_widget_t* widget); + +void rtgui_widget_show(rtgui_widget_t* widget); +void rtgui_widget_hide(rtgui_widget_t* widget); +void rtgui_widget_update(rtgui_widget_t* widget); + +/* get the next sibling of widget */ +rtgui_widget_t* rtgui_widget_get_next_sibling(rtgui_widget_t* widget); +/* get the prev sibling of widget */ +rtgui_widget_t* rtgui_widget_get_prev_sibling(rtgui_widget_t* widget); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/rtgui/include/rtgui/widgets/window.h b/rtgui/include/rtgui/widgets/window.h new file mode 100644 index 0000000000..ee7f8a6b66 --- /dev/null +++ b/rtgui/include/rtgui/widgets/window.h @@ -0,0 +1,91 @@ +/*
+ * File : window.h
+ * This file is part of RTGUI in RT-Thread RTOS
+ * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rt-thread.org/license/LICENSE
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2009-10-04 Bernard first version
+ */
+#ifndef __RTGUI_WINDOW_H__
+#define __RTGUI_WINDOW_H__
+
+#include <rtgui/rtgui.h>
+#include <rtgui/list.h>
+#include <rtgui/widgets/widget.h>
+#include <rtgui/widgets/toplevel.h>
+#include <rtgui/widgets/box.h>
+
+/** Gets the type of a win */
+#define RTGUI_WIN_TYPE (rtgui_win_type_get())
+/** Casts the object to an rtgui_win */
+#define RTGUI_WIN(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_WIN_TYPE, rtgui_win_t))
+/** Checks if the object is an rtgui_win */
+#define RTGUI_IS_WIN(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_WIN_TYPE))
+
+#define RTGUI_WIN_STYLE_MODAL 0x00
+#define RTGUI_WIN_STYLE_MODAL_LESS 0x01
+#define RTGUI_WIN_STYLE_NO_TITLE 0x02
+#define RTGUI_WIN_STYLE_NO_BORDER 0x04
+#define RTGUI_WIN_STYLE_SHOW 0x08
+#define RTGUI_WIN_STYLE_CLOSEBOX 0x10
+#define RTGUI_WIN_STYLE_MINIBOX 0x20
+#define RTGUI_WIN_STYLE_ACTIVATE 0x40
+#define RTGUI_WIN_STYLE_NO_FOCUS 0x80
+
+#define RTGUI_WIN_STYLE_DEFAULT (RTGUI_WIN_STYLE_CLOSEBOX | RTGUI_WIN_STYLE_MINIBOX)
+ +struct rtgui_win_title;
+struct rtgui_win_area;
+
+struct rtgui_win
+{
+ /* inherit from toplevel */
+ struct rtgui_toplevel parent;
+
+ /* top window style */
+ rt_uint32_t style;
+
+ /* window title */
+ char* title;
+
+ /* call back */
+ rt_bool_t (*on_activate) (struct rtgui_widget* widget, struct rtgui_event* event); + rt_bool_t (*on_deactivate) (struct rtgui_widget* widget, struct rtgui_event* event);
+ rt_bool_t (*on_close) (struct rtgui_widget* widget, struct rtgui_event* event);
+
+ /* reserved user data */
+ rt_uint32_t user_data; +};
+
+rtgui_type_t *rtgui_win_type_get(void);
+
+rtgui_win_t* rtgui_win_create(const char* title, rtgui_rect_t *rect, rt_uint32_t flag);
+void rtgui_win_destroy(rtgui_win_t* win);
+
+void rtgui_win_show(rtgui_win_t* win);
+void rtgui_win_hiden(rtgui_win_t* win);
+rt_bool_t rtgui_win_is_activated(struct rtgui_win* win);
+
+void rtgui_win_move(struct rtgui_win* win, int x, int y);
+
+/* reset extent of window */
+void rtgui_win_set_rect(rtgui_win_t* win, rtgui_rect_t* rect);
+void rtgui_win_set_box(rtgui_win_t* win, rtgui_box_t* box);
+
+void rtgui_win_set_onactivate(rtgui_win_t* win, rtgui_event_handler_ptr handler);
+void rtgui_win_set_ondeactivate(rtgui_win_t* win, rtgui_event_handler_ptr handler);
+void rtgui_win_set_onclose(rtgui_win_t* win, rtgui_event_handler_ptr handler);
+
+rt_bool_t rtgui_win_event_handler(rtgui_widget_t* win, struct rtgui_event* event);
+
+void rtgui_win_event_loop(rtgui_win_t* wnd);
+
+void rtgui_win_set_title(rtgui_win_t* win, const char *title);
+char* rtgui_win_get_title(rtgui_win_t* win);
+
+#endif
diff --git a/rtgui/include/rtgui/widgets/workbench.h b/rtgui/include/rtgui/widgets/workbench.h new file mode 100644 index 0000000000..354cc6b474 --- /dev/null +++ b/rtgui/include/rtgui/widgets/workbench.h @@ -0,0 +1,77 @@ +/*
+ * File : workbench.h
+ * This file is part of RTGUI in RT-Thread RTOS
+ * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rt-thread.org/license/LICENSE
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2009-10-04 Bernard first version
+ */
+#ifndef __RTGUI_WORKBENCH_H__
+#define __RTGUI_WORKBENCH_H__
+
+#include <rtgui/rtgui.h>
+#include <rtgui/list.h>
+#include <rtgui/region.h>
+#include <rtgui/dc.h>
+
+#include <rtgui/widgets/view.h>
+#include <rtgui/widgets/toplevel.h>
+
+#define RTGUI_WORKBENCH_FLAG_VISIBLE 0x00
+#define RTGUI_WORKBENCH_FLAG_INVISIBLE 0x01
+#define RTGUI_WORKBENCH_FLAG_FULLSCREEN 0x02
+
+#define RTGUI_WORKBENCH_FLAG_CLOSEBLE 0x00
+#define RTGUI_WORKBENCH_FLAG_UNCLOSEBLE 0x10
+
+#define RTGUI_WORKBENCH_FLAG_DEFAULT RTGUI_WORKBENCH_FLAG_VISIBLE | RTGUI_WORKBENCH_FLAG_CLOSEBLE
+
+/** Gets the type of a workbench */
+#define RTGUI_WORKBENCH_TYPE (rtgui_workbench_type_get())
+/** Casts the object to an rtgui_workbench */
+#define RTGUI_WORKBENCH(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_WORKBENCH_TYPE, rtgui_workbench_t))
+/** Checks if the object is an rtgui_workbench */
+#define RTGUI_IS_WORKBENCH(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_WORKBENCH_TYPE))
+
+struct rtgui_workbench
+{
+ /* inherit from toplevel */
+ struct rtgui_toplevel parent;
+
+ /* panel id */
+ rtgui_panel_t* panel;
+
+ /* workbench flag */
+ rt_uint8_t flag;
+
+ /* workbench title */
+ unsigned char* title;
+};
+
+rtgui_workbench_t *rtgui_workbench_create(const char* panel_name, const unsigned char* title);
+void rtgui_workbench_destroy(rtgui_workbench_t* workbench);
+
+rtgui_type_t* rtgui_workbench_type_get(void);
+
+rt_bool_t rtgui_workbench_event_handler(rtgui_widget_t* widget, rtgui_event_t* event);
+
+void rtgui_workbench_set_flag(rtgui_workbench_t* workbench, rt_uint8_t flag);
+
+void rtgui_workbench_event_loop(rtgui_workbench_t* workbench);
+
+rt_err_t rtgui_workbench_show (rtgui_workbench_t* workbench);
+rt_err_t rtgui_workbench_hide (rtgui_workbench_t* workbench);
+
+void rtgui_workbench_add_view(rtgui_workbench_t* workbench, rtgui_view_t* view);
+void rtgui_workbench_remove_view(rtgui_workbench_t* workbench, rtgui_view_t* view);
+void rtgui_workbench_show_view(rtgui_workbench_t* workbench, rtgui_view_t* view);
+void rtgui_workbench_hide_view(rtgui_workbench_t* workbench, rtgui_view_t* view);
+
+rtgui_view_t *rtgui_workbench_get_current_view(rtgui_workbench_t * workbench);
+
+#endif
|
