diff options
| author | bernard.xiong <[email protected]> | 2009-10-16 00:03:50 +0000 |
|---|---|---|
| committer | bernard.xiong <[email protected]> | 2009-10-16 00:03:50 +0000 |
| commit | a0e99e8ad1a74e10d9de6b553ce8cb1b80aae48c (patch) | |
| tree | f47fc0a90b58670124c68ed77958666d3c061a51 /rtgui/include | |
| parent | 72adcb331c43798721d9a1e3516ae8df99c73bde (diff) | |
add RTGUI source code
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@104 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'rtgui/include')
25 files changed, 1609 insertions, 4 deletions
diff --git a/rtgui/include/rtgui/caret.h b/rtgui/include/rtgui/caret.h new file mode 100644 index 0000000000..241f6cc889 --- /dev/null +++ b/rtgui/include/rtgui/caret.h @@ -0,0 +1,53 @@ +/*
+ * File : caret.h
+ * This file is part of 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-16 Bernard first version
+ */
+#ifndef __RTGUI_CARET_H__
+#define __RTGUI_CARET_H__
+
+#include <rtgui/dc.h>
+#include <rtgui/rtgui_system.h> +#include <rtgui/widgets/widget.h>
+
+struct rtgui_caret
+{
+ /* show flag */
+ rt_bool_t is_show;
+ /* the show point of caret */
+ struct rtgui_point show_point;
+
+ /* widget owner */
+ struct rtgui_widget* owner;
+
+ /* caret buffer dc */
+ struct rtgui_dc *dc;
+
+ /* caret extent */
+ struct rtgui_rect extent;
+
+ /* the blink timer */
+ struct rtgui_timer* timer;
+ rt_int32_t timer_period;
+};
+typedef struct rtgui_caret rtgui_caret_t;
+
+struct rtgui_caret* rtgui_caret_create(struct rtgui_widget* owner);
+void rtgui_caret_destroy(struct rtgui_caret* caret);
+
+void rtgui_caret_show(struct rtgui_caret* caret, rt_base_t x, rt_base_t y);
+void rtgui_caret_hide(struct rtgui_caret* caret);
+void rtgui_caret_draw(struct rtgui_caret* caret);
+
+void rtgui_caret_set_point(struct rtgui_caret* caret, int x, int y);
+void rtgui_caret_set_box(struct rtgui_caret* caret, int w, int h);
+
+#endif
diff --git a/rtgui/include/rtgui/color.h b/rtgui/include/rtgui/color.h new file mode 100644 index 0000000000..af45664a16 --- /dev/null +++ b/rtgui/include/rtgui/color.h @@ -0,0 +1,97 @@ +/*
+ * File : color.h
+ * This file is part of 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-16 Bernard first version
+ */
+#ifndef __RTGUI_COLOR_H__
+#define __RTGUI_COLOR_H__
+
+#include <rtgui/rtgui.h>
+
+typedef unsigned long rtgui_color_t;
+#define RTGUI_ARGB(a, r, g, b) \
+ ((rtgui_color_t)(((rt_uint8_t)(r)|\ + (((unsigned)(rt_uint8_t)(g))<<8))|\ + (((unsigned long)(rt_uint8_t)(b))<<16)|\ + (((unsigned long)(rt_uint8_t)(a))<<24)))
+#define RTGUI_RGB(r, g, b) RTGUI_ARGB(255, (r), (g), (b))
+
+#define RTGUI_RGB_R(c) ((c) & 0xff)
+#define RTGUI_RGB_G(c) (((c) >> 8) & 0xff)
+#define RTGUI_RGB_B(c) (((c) >> 16) & 0xff)
+#define RTGUI_RGB_A(c) (((c) >> 24) & 0xff)
+
+extern const rtgui_color_t default_foreground;
+extern const rtgui_color_t default_background;
+
+extern const rtgui_color_t red;
+extern const rtgui_color_t green;
+extern const rtgui_color_t blue;
+extern const rtgui_color_t black;
+extern const rtgui_color_t white;
+extern const rtgui_color_t high_light;
+extern const rtgui_color_t dark_grey;
+extern const rtgui_color_t light_grey;
+
+/*
+ * RTGUI default color format
+ * BBBB BBBB GGGG GGGG RRRR RRRR
+ */
+
+/* convert rtgui color to BBBBBGGGGGGRRRRR */
+rt_inline rt_uint16_t rtgui_color_to_565(rtgui_color_t c)
+{
+ rt_uint16_t pixel;
+
+ pixel = ((RTGUI_RGB_B(c)>> 3) << 11) | ((RTGUI_RGB_G(c) >> 2) << 5) | (RTGUI_RGB_R(c) >> 3);
+
+ return pixel;
+}
+
+rt_inline rtgui_color_t rtgui_color_from_565(rt_uint16_t pixel)
+{
+ rt_uint16_t r, g, b;
+ rtgui_color_t color;
+
+ r = pixel & 0x1f;
+ g = (pixel >> 5) & 0x3f;
+ b = (pixel >> 11) & 0x1f;
+
+ color = r * 8225 / 1024 + ((g * 4047 / 1024) << 8) + ((b * 8225 / 1024) << 16);
+
+ return color;
+}
+
+/* convert rtgui color to RRRRRGGGGGGBBBBB */
+rt_inline rt_uint16_t rtgui_color_to_565p(rtgui_color_t c)
+{
+ rt_uint16_t pixel;
+
+ pixel = ((RTGUI_RGB_R(c) >> 3) << 11) | ((RTGUI_RGB_G(c) >> 2) << 5) | (RTGUI_RGB_B(c)>> 3);
+ return pixel;
+}
+
+rt_inline rtgui_color_t rtgui_color_from_565p(rt_uint16_t pixel)
+{
+ rt_uint8_t r, g, b;
+ rtgui_color_t color;
+
+ r = (pixel >> 11) & 0x1f;
+ g = (pixel >> 5) & 0x3f;
+ b = pixel & 0x1f;
+
+ color = r * 8225 / 1024 + ((g * 4047 / 1024) << 8) + ((b * 8225 / 1024) << 16);
+
+ return color;
+}
+
+#endif
+
diff --git a/rtgui/include/rtgui/dc.h b/rtgui/include/rtgui/dc.h new file mode 100644 index 0000000000..1bf7bc1ee3 --- /dev/null +++ b/rtgui/include/rtgui/dc.h @@ -0,0 +1,126 @@ +/*
+ * File : dc.h
+ * This file is part of 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-16 Bernard first version
+ */
+#ifndef __RTGUI_DC_H__
+#define __RTGUI_DC_H__
+
+#include <rtgui/rtgui.h>
+#include <rtgui/font.h>
+#include <rtgui/driver.h>
+#include <rtgui/widgets/widget.h>
+
+enum rtgui_dc_type
+{
+ RTGUI_DC_HW,
+ RTGUI_DC_BUFFER,
+};
+
+/* the abstract device context */
+struct rtgui_dc
+{
+ /* type of device context */
+ rt_uint32_t type;
+
+ /* interface */
+ void (*draw_point)(struct rtgui_dc* dc, int x, int y);
+ void (*draw_vline)(struct rtgui_dc* dc, int x, int y1, int y2);
+ void (*draw_hline)(struct rtgui_dc* dc, int x1, int x2, int y);
+ void (*fill_rect )(struct rtgui_dc* dc, rtgui_rect_t* rect);
+ void (*blit )(struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect);
+
+ /* set and get color */
+ void (*set_color )(struct rtgui_dc* dc, rtgui_color_t color);
+ rtgui_color_t (*get_color)(struct rtgui_dc* dc);
+
+ /* set and get font */
+ void (*set_font )(struct rtgui_dc* dc, rtgui_font_t* font);
+ rtgui_font_t* (*get_font)(struct rtgui_dc* dc);
+ void (*set_textalign)(struct rtgui_dc* dc, rt_int32_t align);
+ rt_int32_t (*get_textalign)(struct rtgui_dc* dc);
+
+ /* get dc visible */
+ rt_bool_t (*get_visible)(struct rtgui_dc* dc);
+
+ /* get dc rect */
+ void (*get_rect )(struct rtgui_dc* dc, rtgui_rect_t* rect);
+
+ rt_bool_t (*fini )(struct rtgui_dc* dc);
+};
+
+/* hardware device context */
+struct rtgui_dc_hw
+{
+ struct rtgui_dc parent;
+
+ /* widget owner */
+ rtgui_widget_t* owner;
+
+ /* visible */
+ rt_bool_t visible;
+
+ /* display driver */
+ struct rtgui_graphic_driver* device;
+};
+
+/* create a buffer dc */
+struct rtgui_dc* rtgui_dc_buffer_create(int width, int height);
+rt_uint8_t* rtgui_dc_buffer_get_pixel(struct rtgui_dc* dc); +
+/* create a hardware dc */
+struct rtgui_dc* rtgui_dc_hw_create(rtgui_widget_t* owner);
+struct rtgui_dc* rtgui_dc_begin_drawing(rtgui_widget_t* owner);
+void rtgui_dc_end_drawing(struct rtgui_dc* dc);
+
+/* destroy a dc */
+void rtgui_dc_destory(struct rtgui_dc* dc);
+
+void rtgui_dc_draw_point(struct rtgui_dc* dc, int x, int y);
+
+void rtgui_dc_draw_vline(struct rtgui_dc* dc, int x, int y1, int y2);
+void rtgui_dc_draw_hline(struct rtgui_dc* dc, int x1, int x2, int y);
+void rtgui_dc_fill_rect (struct rtgui_dc* dc, struct rtgui_rect* rect);
+void rtgui_dc_blit(struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect);
+
+void rtgui_dc_set_color(struct rtgui_dc* dc, rtgui_color_t color);
+rtgui_color_t rtgui_dc_get_color(struct rtgui_dc* dc);
+
+void rtgui_dc_set_font(struct rtgui_dc* dc, rtgui_font_t* font);
+rtgui_font_t* rtgui_dc_get_font(struct rtgui_dc* dc);
+void rtgui_dc_set_textalign(struct rtgui_dc* dc, rt_int32_t align);
+rt_int32_t rtgui_dc_get_textalign(struct rtgui_dc* dc);
+
+rt_bool_t rtgui_dc_get_visible(struct rtgui_dc* dc);
+void rtgui_dc_get_rect(struct rtgui_dc*dc, rtgui_rect_t* rect);
+
+void rtgui_dc_draw_line (struct rtgui_dc* dc, int x1, int y1, int x2, int y2);
+void rtgui_dc_draw_rect (struct rtgui_dc* dc, struct rtgui_rect* rect);
+
+void rtgui_dc_draw_text (struct rtgui_dc* dc, const rt_uint8_t* text, struct rtgui_rect* rect);
+
+void rtgui_dc_draw_border(struct rtgui_dc* dc, rtgui_rect_t* rect, int flag);
+void rtgui_dc_draw_horizontal_line(struct rtgui_dc* dc, int x1, int x2, int y);
+void rtgui_dc_draw_vertical_line(struct rtgui_dc* dc, int x, int y1, int y2);
+void rtgui_dc_draw_arrow(struct rtgui_dc* dc, rtgui_rect_t* rect, int kind);
+void rtgui_dc_draw_focus_rect(struct rtgui_dc* dc, rtgui_rect_t* rect);
+
+void rtgui_dc_draw_polygon(struct rtgui_dc* dc, const int *vx, const int *vy, int count);
+void rtgui_dc_fill_polygon(struct rtgui_dc* dc, const int* vx, const int* vy, int count);
+
+void rtgui_dc_draw_circle(struct rtgui_dc* dc, int x, int y, int r);
+void rtgui_dc_fill_circle(struct rtgui_dc* dc, rt_int16_t x, rt_int16_t y, rt_int16_t r);
+void rtgui_dc_draw_arc(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t r, rt_int16_t start, rt_int16_t end);
+
+void rtgui_dc_draw_ellipse(struct rtgui_dc* dc, rt_int16_t x, rt_int16_t y, rt_int16_t rx, rt_int16_t ry);
+void rtgui_dc_fill_ellipse(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t rx, rt_int16_t ry);
+
+#endif
diff --git a/rtgui/include/rtgui/filerw.h b/rtgui/include/rtgui/filerw.h new file mode 100644 index 0000000000..0a9395fbb6 --- /dev/null +++ b/rtgui/include/rtgui/filerw.h @@ -0,0 +1,47 @@ +/*
+ * File : filerw.h
+ * This file is part of 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-16 Bernard first version
+ */
+#ifndef __RTGUI_FILERW_H__
+#define __RTGUI_FILERW_H__
+
+#include <rtgui/rtgui.h>
+
+#define RTGUI_FILE_SEEK_SET 0
+#define RTGUI_FILE_SEEK_CUR 1
+#define RTGUI_FILE_SEEK_END 2
+
+struct rtgui_filerw
+{
+ int (*seek) (struct rtgui_filerw *context, rt_off_t offset, int whence);
+ int (*read) (struct rtgui_filerw *context, void *buffer, rt_size_t size, rt_size_t count);
+ int (*write)(struct rtgui_filerw *context, const void *buffer, rt_size_t size, rt_size_t count);
+ int (*tell) (struct rtgui_filerw *context);
+ int (*eof) (struct rtgui_filerw *context);
+ int (*close)(struct rtgui_filerw *context);
+};
+typedef struct rtgui_filerw rtgui_filerw_t;
+
+struct rtgui_filerw* rtgui_filerw_create_file(const char* filename, const char* mode);
+struct rtgui_filerw* rtgui_filerw_create_mem(rt_uint8_t* mem, rt_size_t size);
+
+int rtgui_filerw_seek (struct rtgui_filerw* context, rt_off_t offset, int whence);
+int rtgui_filerw_read (struct rtgui_filerw* context, void* buffer, rt_size_t size, rt_size_t count);
+int rtgui_filerw_write(struct rtgui_filerw* context, const void* buffer, rt_size_t size, rt_size_t count);
+int rtgui_filerw_tell (struct rtgui_filerw* context);
+int rtgui_filerw_eof (struct rtgui_filerw* context);
+int rtgui_filerw_close(struct rtgui_filerw* context);
+
+/* get memory data from filerw memory object */
+rt_uint8_t* rtgui_filerw_mem_getdata(struct rtgui_filerw* context);
+
+#endif
diff --git a/rtgui/include/rtgui/font.h b/rtgui/include/rtgui/font.h new file mode 100644 index 0000000000..db5b6857fc --- /dev/null +++ b/rtgui/include/rtgui/font.h @@ -0,0 +1,88 @@ +/*
+ * File : font.h
+ * This file is part of 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-16 Bernard first version
+ */
+#ifndef __RTGUI_FONT_H__
+#define __RTGUI_FONT_H__
+
+#include <rtgui/rtgui.h>
+#include <rtgui/list.h>
+
+struct rtgui_font;
+struct rtgui_dc;
+struct rtgui_rect;
+
+struct rtgui_font_engine
+{
+ /* font engine function */
+ void (*font_init)(struct rtgui_font* font);
+ void (*font_load)(struct rtgui_font* font);
+
+ void (*font_draw_text)(struct rtgui_font* font, struct rtgui_dc* dc, const rt_uint8_t* text,
+ rt_ubase_t len, struct rtgui_rect* rect);
+ void (*font_get_metrics)(struct rtgui_font* font, const rt_uint8_t* text, struct rtgui_rect* rect);
+};
+
+/*
+ * bitmap font engine
+ */
+/* bitmap font private data */
+struct rtgui_font_bitmap
+{
+ /* bitmap data */
+ const rt_uint8_t* bmp;
+
+ rt_uint16_t width;
+ rt_uint16_t height;
+
+ rt_uint8_t first_char;
+ rt_uint8_t last_char;
+};
+extern struct rtgui_font_engine bmp_font_engine;
+
+struct rtgui_font
+{
+ /* font name */
+ char* family;
+
+ /* font height */
+ rt_uint16_t height;
+
+ /* refer count */
+ rt_uint32_t refer_count;
+
+ /* font engine */
+ struct rtgui_font_engine* engine;
+
+ /* font private data */
+ void* data;
+
+ /* the font list */
+ rtgui_list_t list;
+};
+typedef struct rtgui_font rtgui_font_t;
+
+void rtgui_font_system_init(void);
+void rtgui_font_system_add_font(struct rtgui_font* font);
+void rtgui_font_system_remove_font(struct rtgui_font* font);
+struct rtgui_font* rtgui_font_default(void);
+void rtgui_font_set_defaut(struct rtgui_font* font);
+
+struct rtgui_font* rtgui_font_refer(const rt_uint8_t* family, rt_uint16_t height);
+void rtgui_font_derefer(struct rtgui_font* font);
+
+/* draw a text */
+void rtgui_font_draw(struct rtgui_font* font, struct rtgui_dc* dc, const rt_uint8_t* text, rt_ubase_t len, struct rtgui_rect* rect);
+int rtgui_font_get_string_width(struct rtgui_font* font, const rt_uint8_t* text);
+void rtgui_font_get_metrics(struct rtgui_font* font, const rt_uint8_t* text, struct rtgui_rect* rect);
+
+#endif
diff --git a/rtgui/include/rtgui/image.h b/rtgui/include/rtgui/image.h new file mode 100644 index 0000000000..68f6144ebe --- /dev/null +++ b/rtgui/include/rtgui/image.h @@ -0,0 +1,63 @@ +/*
+ * File : image.h
+ * This file is part of 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-16 Bernard first version
+ */
+#ifndef __RTGUI_IMAGE_H__
+#define __RTGUI_IMAGE_H__
+
+#include <rtgui/dc.h>
+#include <rtgui/filerw.h>
+#include <rtgui/region.h>
+
+struct rtgui_image;
+struct rtgui_image_engine
+{
+ const char* name;
+ struct rtgui_list_node list;
+
+ /* image engine function */
+ rt_bool_t (*image_check)(struct rtgui_filerw* file);
+
+ rt_bool_t (*image_load)(struct rtgui_image* image, struct rtgui_filerw* file, rt_bool_t load);
+ void (*image_unload)(struct rtgui_image* image);
+
+ void (*image_blit)(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect);
+};
+
+struct rtgui_image
+{
+ /* image metrics */
+ rt_uint16_t w, h;
+
+ /* image engine */
+ struct rtgui_image_engine* engine;
+
+ /* image private data */
+ void* data;
+};
+typedef struct rtgui_image rtgui_image_t;
+
+/* init rtgui image system */
+void rtgui_system_image_init(void);
+
+struct rtgui_image* rtgui_image_create_from_file(const char* type, const char* filename, rt_bool_t load);
+struct rtgui_image* rtgui_image_create_from_mem(const char* type, const rt_uint8_t* data, rt_size_t length);
+void rtgui_image_destroy(struct rtgui_image* image);
+
+/* register an image engine */
+void rtgui_image_register_engine(struct rtgui_image_engine* engine);
+
+/* blit an image on DC */
+void rtgui_image_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect);
+
+
+#endif
diff --git a/rtgui/include/rtgui/image_png.h b/rtgui/include/rtgui/image_png.h new file mode 100644 index 0000000000..13aff657f9 --- /dev/null +++ b/rtgui/include/rtgui/image_png.h @@ -0,0 +1,19 @@ +/*
+ * File : image_png.h
+ * This file is part of 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-16 Bernard first version
+ */
+#ifndef __RTGUI_IMAGE_PNG_H__
+#define __RTGUI_IMAGE_PNG_H__
+
+#include <rtgui/image.h>
+
+#endif
diff --git a/rtgui/include/rtgui/image_xpm.h b/rtgui/include/rtgui/image_xpm.h new file mode 100644 index 0000000000..e580327f6d --- /dev/null +++ b/rtgui/include/rtgui/image_xpm.h @@ -0,0 +1,21 @@ +/*
+ * File : image_xpm.h
+ * This file is part of 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-16 Bernard first version
+ */
+#ifndef __RTGUI_IMAGE_XPM_H__
+#define __RTGUI_IMAGE_XPM_H__
+
+#include <rtgui/image.h>
+
+void rtgui_image_xpm_init(void);
+
+#endif
diff --git a/rtgui/include/rtgui/kbddef.h b/rtgui/include/rtgui/kbddef.h new file mode 100644 index 0000000000..c078404c60 --- /dev/null +++ b/rtgui/include/rtgui/kbddef.h @@ -0,0 +1,293 @@ +/*
+ * File : kbddef.h
+ * This file is part of 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-16 Bernard first version
+ */
+#ifndef __KBD_DEF_H__
+#define __KBD_DEF_H__
+
+/* The keyboard key have been cleverly chosen to map to ASCII */
+typedef enum
+{
+ RTGUIK_UNKNOWN = 0,
+ RTGUIK_FIRST = 0,
+ RTGUIK_BACKSPACE = 8,
+ RTGUIK_TAB = 9,
+ RTGUIK_CLEAR = 12,
+ RTGUIK_RETURN = 13,
+ RTGUIK_PAUSE = 19,
+ RTGUIK_ESCAPE = 27,
+ RTGUIK_SPACE = 32,
+ RTGUIK_EXCLAIM = 33,
+ RTGUIK_QUOTEDBL = 34,
+ RTGUIK_HASH = 35,
+ RTGUIK_DOLLAR = 36,
+ RTGUIK_AMPERSAND = 38,
+ RTGUIK_QUOTE = 39,
+ RTGUIK_LEFTPAREN = 40,
+ RTGUIK_RIGHTPAREN = 41,
+ RTGUIK_ASTERISK = 42,
+ RTGUIK_PLUS = 43,
+ RTGUIK_COMMA = 44,
+ RTGUIK_MINUS = 45,
+ RTGUIK_PERIOD = 46,
+ RTGUIK_SLASH = 47,
+ RTGUIK_0 = 48,
+ RTGUIK_1 = 49,
+ RTGUIK_2 = 50,
+ RTGUIK_3 = 51,
+ RTGUIK_4 = 52,
+ RTGUIK_5 = 53,
+ RTGUIK_6 = 54,
+ RTGUIK_7 = 55,
+ RTGUIK_8 = 56,
+ RTGUIK_9 = 57,
+ RTGUIK_COLON = 58,
+ RTGUIK_SEMICOLON = 59,
+ RTGUIK_LESS = 60,
+ RTGUIK_EQUALS = 61,
+ RTGUIK_GREATER = 62,
+ RTGUIK_QUESTION = 63,
+ RTGUIK_AT = 64,
+
+ /*
+ Skip uppercase letters
+ */
+ RTGUIK_LEFTBRACKET = 91,
+ RTGUIK_BACKSLASH = 92,
+ RTGUIK_RIGHTBRACKET = 93,
+ RTGUIK_CARET = 94,
+ RTGUIK_UNDERSCORE = 95,
+ RTGUIK_BACKQUOTE = 96,
+ RTGUIK_a = 97,
+ RTGUIK_b = 98,
+ RTGUIK_c = 99,
+ RTGUIK_d = 100,
+ RTGUIK_e = 101,
+ RTGUIK_f = 102,
+ RTGUIK_g = 103,
+ RTGUIK_h = 104,
+ RTGUIK_i = 105,
+ RTGUIK_j = 106,
+ RTGUIK_k = 107,
+ RTGUIK_l = 108,
+ RTGUIK_m = 109,
+ RTGUIK_n = 110,
+ RTGUIK_o = 111,
+ RTGUIK_p = 112,
+ RTGUIK_q = 113,
+ RTGUIK_r = 114,
+ RTGUIK_s = 115,
+ RTGUIK_t = 116,
+ RTGUIK_u = 117,
+ RTGUIK_v = 118,
+ RTGUIK_w = 119,
+ RTGUIK_x = 120,
+ RTGUIK_y = 121,
+ RTGUIK_z = 122,
+ RTGUIK_DELETE = 127,
+
+ /* International keyboard */
+ RTGUIK_WORLD_0 = 160, /* 0xA0 */
+ RTGUIK_WORLD_1 = 161,
+ RTGUIK_WORLD_2 = 162,
+ RTGUIK_WORLD_3 = 163,
+ RTGUIK_WORLD_4 = 164,
+ RTGUIK_WORLD_5 = 165,
+ RTGUIK_WORLD_6 = 166,
+ RTGUIK_WORLD_7 = 167,
+ RTGUIK_WORLD_8 = 168,
+ RTGUIK_WORLD_9 = 169,
+ RTGUIK_WORLD_10 = 170,
+ RTGUIK_WORLD_11 = 171,
+ RTGUIK_WORLD_12 = 172,
+ RTGUIK_WORLD_13 = 173,
+ RTGUIK_WORLD_14 = 174,
+ RTGUIK_WORLD_15 = 175,
+ RTGUIK_WORLD_16 = 176,
+ RTGUIK_WORLD_17 = 177,
+ RTGUIK_WORLD_18 = 178,
+ RTGUIK_WORLD_19 = 179,
+ RTGUIK_WORLD_20 = 180,
+ RTGUIK_WORLD_21 = 181,
+ RTGUIK_WORLD_22 = 182,
+ RTGUIK_WORLD_23 = 183,
+ RTGUIK_WORLD_24 = 184,
+ RTGUIK_WORLD_25 = 185,
+ RTGUIK_WORLD_26 = 186,
+ RTGUIK_WORLD_27 = 187,
+ RTGUIK_WORLD_28 = 188,
+ RTGUIK_WORLD_29 = 189,
+ RTGUIK_WORLD_30 = 190,
+ RTGUIK_WORLD_31 = 191,
+ RTGUIK_WORLD_32 = 192,
+ RTGUIK_WORLD_33 = 193,
+ RTGUIK_WORLD_34 = 194,
+ RTGUIK_WORLD_35 = 195,
+ RTGUIK_WORLD_36 = 196,
+ RTGUIK_WORLD_37 = 197,
+ RTGUIK_WORLD_38 = 198,
+ RTGUIK_WORLD_39 = 199,
+ RTGUIK_WORLD_40 = 200,
+ RTGUIK_WORLD_41 = 201,
+ RTGUIK_WORLD_42 = 202,
+ RTGUIK_WORLD_43 = 203,
+ RTGUIK_WORLD_44 = 204,
+ RTGUIK_WORLD_45 = 205,
+ RTGUIK_WORLD_46 = 206,
+ RTGUIK_WORLD_47 = 207,
+ RTGUIK_WORLD_48 = 208,
+ RTGUIK_WORLD_49 = 209,
+ RTGUIK_WORLD_50 = 210,
+ RTGUIK_WORLD_51 = 211,
+ RTGUIK_WORLD_52 = 212,
+ RTGUIK_WORLD_53 = 213,
+ RTGUIK_WORLD_54 = 214,
+ RTGUIK_WORLD_55 = 215,
+ RTGUIK_WORLD_56 = 216,
+ RTGUIK_WORLD_57 = 217,
+ RTGUIK_WORLD_58 = 218,
+ RTGUIK_WORLD_59 = 219,
+ RTGUIK_WORLD_60 = 220,
+ RTGUIK_WORLD_61 = 221,
+ RTGUIK_WORLD_62 = 222,
+ RTGUIK_WORLD_63 = 223,
+ RTGUIK_WORLD_64 = 224,
+ RTGUIK_WORLD_65 = 225,
+ RTGUIK_WORLD_66 = 226,
+ RTGUIK_WORLD_67 = 227,
+ RTGUIK_WORLD_68 = 228,
+ RTGUIK_WORLD_69 = 229,
+ RTGUIK_WORLD_70 = 230,
+ RTGUIK_WORLD_71 = 231,
+ RTGUIK_WORLD_72 = 232,
+ RTGUIK_WORLD_73 = 233,
+ RTGUIK_WORLD_74 = 234,
+ RTGUIK_WORLD_75 = 235,
+ RTGUIK_WORLD_76 = 236,
+ RTGUIK_WORLD_77 = 237,
+ RTGUIK_WORLD_78 = 238,
+ RTGUIK_WORLD_79 = 239,
+ RTGUIK_WORLD_80 = 240,
+ RTGUIK_WORLD_81 = 241,
+ RTGUIK_WORLD_82 = 242,
+ RTGUIK_WORLD_83 = 243,
+ RTGUIK_WORLD_84 = 244,
+ RTGUIK_WORLD_85 = 245,
+ RTGUIK_WORLD_86 = 246,
+ RTGUIK_WORLD_87 = 247,
+ RTGUIK_WORLD_88 = 248,
+ RTGUIK_WORLD_89 = 249,
+ RTGUIK_WORLD_90 = 250,
+ RTGUIK_WORLD_91 = 251,
+ RTGUIK_WORLD_92 = 252,
+ RTGUIK_WORLD_93 = 253,
+ RTGUIK_WORLD_94 = 254,
+ RTGUIK_WORLD_95 = 255, /* 0xFF */
+
+ /* Numeric keypad */
+ RTGUIK_KP0 = 256,
+ RTGUIK_KP1 = 257,
+ RTGUIK_KP2 = 258,
+ RTGUIK_KP3 = 259,
+ RTGUIK_KP4 = 260,
+ RTGUIK_KP5 = 261,
+ RTGUIK_KP6 = 262,
+ RTGUIK_KP7 = 263,
+ RTGUIK_KP8 = 264,
+ RTGUIK_KP9 = 265,
+ RTGUIK_KP_PERIOD = 266,
+ RTGUIK_KP_DIVIDE = 267,
+ RTGUIK_KP_MULTIPLY = 268,
+ RTGUIK_KP_MINUS = 269,
+ RTGUIK_KP_PLUS = 270,
+ RTGUIK_KP_ENTER = 271,
+ RTGUIK_KP_EQUALS = 272,
+
+ /* Arrows + Home/End pad */
+ RTGUIK_UP = 273,
+ RTGUIK_DOWN = 274,
+ RTGUIK_RIGHT = 275,
+ RTGUIK_LEFT = 276,
+ RTGUIK_INSERT = 277,
+ RTGUIK_HOME = 278,
+ RTGUIK_END = 279,
+ RTGUIK_PAGEUP = 280,
+ RTGUIK_PAGEDOWN = 281,
+
+ /* Function keys */
+ RTGUIK_F1 = 282,
+ RTGUIK_F2 = 283,
+ RTGUIK_F3 = 284,
+ RTGUIK_F4 = 285,
+ RTGUIK_F5 = 286,
+ RTGUIK_F6 = 287,
+ RTGUIK_F7 = 288,
+ RTGUIK_F8 = 289,
+ RTGUIK_F9 = 290,
+ RTGUIK_F10 = 291,
+ RTGUIK_F11 = 292,
+ RTGUIK_F12 = 293,
+ RTGUIK_F13 = 294,
+ RTGUIK_F14 = 295,
+ RTGUIK_F15 = 296,
+
+ /* Key state modifier keys */
+ RTGUIK_NUMLOCK = 300,
+ RTGUIK_CAPSLOCK = 301,
+ RTGUIK_SCROLLOCK = 302,
+ RTGUIK_RSHIFT = 303,
+ RTGUIK_LSHIFT = 304,
+ RTGUIK_RCTRL = 305,
+ RTGUIK_LCTRL = 306,
+ RTGUIK_RALT = 307,
+ RTGUIK_LALT = 308,
+ RTGUIK_RMETA = 309,
+ RTGUIK_LMETA = 310,
+ RTGUIK_LSUPER = 311, /* Left "Windows" key */
+ RTGUIK_RSUPER = 312, /* Right "Windows" key */
+ RTGUIK_MODE = 313, /* "Alt Gr" key */
+ RTGUIK_COMPOSE = 314, /* Multi-key compose key */
+
+ /* Miscellaneous function keys */
+ RTGUIK_HELP = 315,
+ RTGUIK_PRINT = 316,
+ RTGUIK_SYSREQ = 317,
+ RTGUIK_BREAK = 318,
+ RTGUIK_MENU = 319,
+ RTGUIK_POWER = 320, /* Power key */
+
+ RTGUIK_LAST
+} RTGUI_KBD_KEY;
+
+/* Enumeration of valid key mods (possibly OR'd together) */
+typedef enum {
+ RTGUI_KMOD_NONE = 0x0000,
+ RTGUI_KMOD_LSHIFT = 0x0001,
+ RTGUI_KMOD_RSHIFT = 0x0002,
+ RTGUI_KMOD_LCTRL = 0x0040,
+ RTGUI_KMOD_RCTRL = 0x0080,
+ RTGUI_KMOD_LALT = 0x0100,
+ RTGUI_KMOD_RALT = 0x0200,
+ RTGUI_KMOD_LMETA = 0x0400,
+ RTGUI_KMOD_RMETA = 0x0800,
+ RTGUI_KMOD_NUM = 0x1000,
+ RTGUI_KMOD_CAPS = 0x2000,
+ RTGUI_KMOD_MODE = 0x4000,
+ RTGUI_KMOD_RESERVED = 0x8000
+} RTGUI_KBD_MOD;
+
+typedef enum {
+ RTGUI_KEYDOWN, /* Keys pressed */
+ RTGUI_KEYUP, /* Keys released */
+} RTGUI_KBD_TYPE;
+
+#endif
diff --git a/rtgui/include/rtgui/list.h b/rtgui/include/rtgui/list.h new file mode 100644 index 0000000000..4b3cf951e6 --- /dev/null +++ b/rtgui/include/rtgui/list.h @@ -0,0 +1,66 @@ +/* + * File : list.h + * This file is part of 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-16 Bernard first version + */ +#ifndef __RTGUI_LIST_H__ +#define __RTGUI_LIST_H__ + +#include <rtgui/rtgui.h> + +struct rtgui_list_node +{ + struct rtgui_list_node* next; +}; +typedef struct rtgui_list_node rtgui_list_t; + +rt_inline void rtgui_list_init(rtgui_list_t *l) +{ + l->next = (struct rtgui_list_node *)0; +} +
+rt_inline void rtgui_list_append(rtgui_list_t *l, rtgui_list_t *n) +{ + struct rtgui_list_node* node; + + node = l; + while (node->next) node = node->next; + + /* append the node to the tail */ + node->next = n; + n->next = (struct rtgui_list_node*) 0; +} + +rt_inline void rtgui_list_insert(rtgui_list_t *l, rtgui_list_t *n) +{ + n->next = l->next; + l->next = n; +} + +rt_inline rtgui_list_t* rtgui_list_remove(rtgui_list_t *l, rtgui_list_t *n) +{ + /* remove slist head */ + struct rtgui_list_node* node = l; + while (node->next && node->next != n) node = node->next; + + /* remove node */ + if (node->next != (rtgui_list_t *)0) node->next = node->next->next; + + return l; +} + +#define rtgui_list_entry(node, type, member) \ + ((type *)((char*)(node)-(unsigned long)(&((type *)0)->member))) + +#define rtgui_list_foreach(node, list) \ + for ((node) = (list)->next; (node) != RT_NULL; (node) = (node)->next) + +#endif diff --git a/rtgui/include/rtgui/region.h b/rtgui/include/rtgui/region.h new file mode 100644 index 0000000000..72c06653e3 --- /dev/null +++ b/rtgui/include/rtgui/region.h @@ -0,0 +1,100 @@ +/* + * File : region.h + * This file is part of 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-16 Bernard first version + */ +#ifndef __RTGUI_REGION_H__ +#define __RTGUI_REGION_H__ + +#include <rtgui/rtgui.h>
+ +#if defined(__cplusplus) || defined(c_plusplus) +extern "C" { +#endif + +typedef struct rtgui_region_data rtgui_region_data_t; + +struct rtgui_region_data +{ + rt_uint32_t size; + rt_uint32_t numRects; + /* XXX: And why, exactly, do we have this bogus struct definition? */ + /* rtgui_rect_t rects[size]; in memory but not explicitly declared */ +}; + +typedef struct rtgui_region +{ + rtgui_rect_t extents; + rtgui_region_data_t *data; +}rtgui_region_t; + +typedef enum +{ + RTGUI_REGION_STATUS_FAILURE, + RTGUI_REGION_STATUS_SUCCESS +}rtgui_region_status_t; + +/* creation/destruction */ + +void rtgui_region_init(rtgui_region_t *region); +void rtgui_region_init_rect(rtgui_region_t *region, + int x, int y, unsigned int width, unsigned int height); +void rtgui_region_init_with_extents(rtgui_region_t *region, rtgui_rect_t *extents); +void rtgui_region_fini (rtgui_region_t *region); + +void rtgui_region_translate (rtgui_region_t *region, int x, int y); + +rtgui_region_status_t rtgui_region_copy (rtgui_region_t *dest, rtgui_region_t *source); + +rtgui_region_status_t rtgui_region_intersect (rtgui_region_t *newReg, rtgui_region_t *reg1, rtgui_region_t *reg2); +rtgui_region_status_t rtgui_region_intersect_rect (rtgui_region_t *newReg, rtgui_region_t *reg1, rtgui_rect_t *rect); +rtgui_region_status_t rtgui_region_union (rtgui_region_t *newReg, rtgui_region_t *reg1, rtgui_region_t *reg2); +rtgui_region_status_t rtgui_region_union_rect(rtgui_region_t *dest, rtgui_region_t *source, rtgui_rect_t* rect); +rtgui_region_status_t rtgui_region_subtract (rtgui_region_t *regD, rtgui_region_t *regM, rtgui_region_t *regS); +rtgui_region_status_t rtgui_region_subtract_rect (rtgui_region_t *regD, rtgui_region_t *regM, rtgui_rect_t* rect); +rtgui_region_status_t rtgui_region_inverse (rtgui_region_t *newReg, rtgui_region_t *reg1, rtgui_rect_t *invRect); + +int rtgui_region_num_rects (rtgui_region_t *region); + +rtgui_rect_t* rtgui_region_rects (rtgui_region_t *region); + +#define RTGUI_REGION_OUT 0 +#define RTGUI_REGION_IN 1 +#define RTGUI_REGION_PART 2 + +int rtgui_region_contains_point (rtgui_region_t *region, int x, int y, rtgui_rect_t *box); +int rtgui_region_contains_rectangle (rtgui_region_t *rtgui_region_t, rtgui_rect_t *prect); + +int rtgui_region_not_empty (rtgui_region_t *region); +rtgui_rect_t *rtgui_region_extents (rtgui_region_t *region); + +rtgui_region_status_t rtgui_region_append (rtgui_region_t *dest, rtgui_region_t *region); +rtgui_region_status_t rtgui_region_validate (rtgui_region_t *badreg, int *pOverlap); + +void rtgui_region_reset(rtgui_region_t *region, rtgui_rect_t* rect); +void rtgui_region_empty (rtgui_region_t *region); +void rtgui_region_dump(rtgui_region_t* region); + +/* rect functions */
+extern rtgui_rect_t rtgui_empty_rect;
+
+void rtgui_rect_moveto(rtgui_rect_t *rect, int x, int y); +void rtgui_rect_moveto_align(rtgui_rect_t *rect, rtgui_rect_t *to, int align);
+void rtgui_rect_inflate(rtgui_rect_t *rect, int d);
+void rtgui_rect_intersect(rtgui_rect_t *src, rtgui_rect_t *dest);
+int rtgui_rect_contains_point(rtgui_rect_t *rect, int x, int y); +int rtgui_rect_is_intersect(rtgui_rect_t *rect1, rtgui_rect_t *rect2);
+ +#if defined(__cplusplus) || defined(c_plusplus) +} +#endif + +#endif /* _PIXMAN_H_ */ diff --git a/rtgui/include/rtgui/rtgui.h b/rtgui/include/rtgui/rtgui.h index bc820b76c0..dcc0741dba 100644 --- a/rtgui/include/rtgui/rtgui.h +++ b/rtgui/include/rtgui/rtgui.h @@ -16,10 +16,7 @@ #include <rtthread.h> -/* RTGUI options */ -#define RTGUI_IMAGE_JPEG - -#define RTGUI_NAME_MAX 32 +#include <rtgui/rtgui_config.h> #define RT_INT16_MAX 32767 #define RT_INT16_MIN (-RT_INT16_MAX-1) diff --git a/rtgui/include/rtgui/rtgui_config.h b/rtgui/include/rtgui/rtgui_config.h new file mode 100644 index 0000000000..72667c1342 --- /dev/null +++ b/rtgui/include/rtgui/rtgui_config.h @@ -0,0 +1,36 @@ +/*
+ * File : rtgui_config.h
+ * This file is part of 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-16 Bernard first version
+ */
+
+#ifndef __RTGUI_CONFIG_H__
+#define __RTGUI_CONFIG_H__
+
+/* RTGUI options */
+
+/* name length of RTGUI object */
+#define RTGUI_NAME_MAX 32
+
+/* #define RTGUI_USING_MOUSE_CURSOR */
+
+/* #define RTGUI_USING_FONT16 */
+
+#define RT_USING_STDIO_FILERW
+
+#define RTGUI_SVR_THREAD_PRIORITY 15
+#define RTGUI_SVR_THREAD_TIMESLICE 5
+
+#define RTGUI_APP_THREAD_PRIORITY 25
+#define RTGUI_APP_THREAD_TIMESLICE 8
+
+#endif
+
diff --git a/rtgui/include/rtgui/rtgui_server.h b/rtgui/include/rtgui/rtgui_server.h index a9463ecb38..738e60100e 100644 --- a/rtgui/include/rtgui/rtgui_server.h +++ b/rtgui/include/rtgui/rtgui_server.h @@ -67,4 +67,9 @@ void rtgui_server_init(void); /* post an event to server */
void rtgui_server_post_event(struct rtgui_event* event, rt_size_t size);
+/* register or deregister panel in server */
+void rtgui_panel_register(char* name, rtgui_rect_t* extent);
+void rtgui_panel_deregister(char* name);
+
#endif
+
diff --git a/rtgui/include/rtgui/rtgui_theme.h b/rtgui/include/rtgui/rtgui_theme.h index eb6738d6b5..60711dcaab 100644 --- a/rtgui/include/rtgui/rtgui_theme.h +++ b/rtgui/include/rtgui/rtgui_theme.h @@ -15,6 +15,7 @@ #define __RTGUI_THEME_H__
#include <rtgui/rtgui.h>
+#include <rtgui/rtgui_server.h>
#include <rtgui/widgets/label.h>
#include <rtgui/widgets/button.h>
diff --git a/rtgui/include/rtgui/widgets/box.h b/rtgui/include/rtgui/widgets/box.h new file mode 100644 index 0000000000..69a0a01a56 --- /dev/null +++ b/rtgui/include/rtgui/widgets/box.h @@ -0,0 +1,58 @@ +/*
+ * File : box.h
+ * This file is part of 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-16 Bernard first version
+ */
+#ifndef __RTGUI_BOX_H__
+#define __RTGUI_BOX_H__
+
+#include <rtgui/rtgui.h>
+#include <rtgui/widgets/widget.h>
+#include <rtgui/widgets/container.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Gets the type of a box */
+#define RTGUI_BOX_TYPE (rtgui_box_type_get())
+/** Casts the object to an rtgui_box */
+#define RTGUI_BOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_BOX_TYPE, rtgui_box_t))
+/** Checks if the object is an rtgui_box */
+#define RTGUI_IS_BOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_BOX_TYPE))
+
+struct rtgui_box
+{
+ struct rtgui_container parent;
+
+ rt_uint16_t orientation;
+ rt_uint16_t border_size;
+};
+typedef struct rtgui_box rtgui_box_t;
+
+rtgui_type_t *rtgui_box_type_get(void);
+
+struct rtgui_box* rtgui_box_create(int orientation, rtgui_rect_t* rect);
+void rtgui_box_destroy(struct rtgui_box* box);
+
+rt_bool_t rtgui_box_event_handler(rtgui_widget_t* widget, rtgui_event_t* event);
+
+void rtgui_box_append(rtgui_box_t* box, rtgui_widget_t* widget);
+void rtgui_box_layout(rtgui_box_t* box);
+
+rt_uint32_t rtgui_box_get_width(rtgui_box_t* box);
+rt_uint32_t rtgui_box_get_height(rtgui_box_t* box);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/rtgui/include/rtgui/widgets/button.h b/rtgui/include/rtgui/widgets/button.h new file mode 100644 index 0000000000..77e7fc4e03 --- /dev/null +++ b/rtgui/include/rtgui/widgets/button.h @@ -0,0 +1,81 @@ +/*
+ * File : button.h
+ * This file is part of 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-16 Bernard first version
+ */
+#ifndef __RTGUI_BUTTON_H__
+#define __RTGUI_BUTTON_H__
+
+#include <rtgui/image.h>
+#include <rtgui/widgets/widget.h>
+#include <rtgui/widgets/label.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup rtgui_button
+ * @{
+ */
+
+/** Gets the type of a button */
+#define RTGUI_BUTTON_TYPE (rtgui_button_type_get())
+/** Casts the object to an rtgui_button */
+#define RTGUI_BUTTON(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_BUTTON_TYPE, rtgui_button_t))
+/** Checks if the object is an rtgui_button */
+#define RTGUI_IS_BUTTON(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_BUTTON_TYPE))
+
+#define RTGUI_BUTTON_FLAG_PRESS 0x01
+#define RTGUI_BUTTON_FLAG_DEFAULT 0x02
+
+#define RTGUI_BUTTON_TYPE_NORMAL 0x00
+#define RTGUI_BUTTON_TYPE_PUSH 0x10
+
+/*
+ * the button widget
+ */
+struct rtgui_button
+{
+ /* inherit from label */
+ struct rtgui_label parent;
+
+ /* button flag */
+ rt_base_t flag;
+
+ /* pressed and unpressed image */
+ rtgui_image_t *pressed_image, *unpressed_image;
+
+ /* click button event handler */
+ void (*on_button)(struct rtgui_widget* widget, rtgui_event_t *event);
+};
+typedef struct rtgui_button rtgui_button_t;
+
+rtgui_type_t *rtgui_button_type_get(void);
+
+rtgui_button_t* rtgui_button_create(unsigned char* text);
+rtgui_button_t* rtgui_pushbutton_create(unsigned char* text);
+void rtgui_button_destroy(rtgui_button_t* btn);
+
+void rtgui_button_set_pressed_image(rtgui_button_t* btn, rtgui_image_t* image);
+void rtgui_button_set_unpressed_image(rtgui_button_t* btn, rtgui_image_t* image);
+
+void rtgui_button_ondraw(rtgui_button_t* btn);
+
+rt_bool_t rtgui_button_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/rtgui/include/rtgui/widgets/container.h b/rtgui/include/rtgui/widgets/container.h new file mode 100644 index 0000000000..7f1af7d3d2 --- /dev/null +++ b/rtgui/include/rtgui/widgets/container.h @@ -0,0 +1,47 @@ +/*
+ * File : container.h
+ * This file is part of 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-16 Bernard first version
+ */
+#ifndef __RTGUI_CONTAINER_H__
+#define __RTGUI_CONTAINER_H__
+
+#include <rtgui/widgets/widget.h>
+
+/** Gets the type of a container */
+#define RTGUI_CONTAINER_TYPE (rtgui_container_type_get())
+/** Casts the object to a rtgui_container */
+#define RTGUI_CONTAINER(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_CONTAINER_TYPE, rtgui_container_t))
+/** Checks if the object is a rtgui_container */
+#define RTGUI_IS_CONTAINER(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_CONTAINER_TYPE))
+
+struct rtgui_container
+{
+ /* inherit from widget */
+ struct rtgui_widget parent;
+
+ rtgui_list_t children;
+};
+typedef struct rtgui_container rtgui_container_t;
+
+rtgui_type_t *rtgui_container_type_get(void);
+
+void rtgui_container_add_child(rtgui_container_t *container, rtgui_widget_t* child);
+void rtgui_container_remove_child(rtgui_container_t *container, rtgui_widget_t* child);
+void rtgui_container_destroy_children(rtgui_container_t *container);
+rtgui_widget_t* rtgui_container_get_first_child(rtgui_container_t* container);
+
+rt_bool_t rtgui_container_event_handler(rtgui_widget_t* widget, rtgui_event_t* event);
+
+rt_bool_t rtgui_container_dispatch_event(rtgui_container_t *container, rtgui_event_t* event);
+rt_bool_t rtgui_container_dispatch_mouse_event(rtgui_container_t *container, struct rtgui_event_mouse* event);
+
+#endif
diff --git a/rtgui/include/rtgui/widgets/iconbox.h b/rtgui/include/rtgui/widgets/iconbox.h new file mode 100644 index 0000000000..73ebd682a6 --- /dev/null +++ b/rtgui/include/rtgui/widgets/iconbox.h @@ -0,0 +1,56 @@ +/*
+ * File : iconbox.h
+ * This file is part of 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-16 Bernard first version
+ */
+#ifndef __RTGUI_ICONBOX_H__
+#define __RTGUI_ICONBOX_H__
+
+#include <rtgui/rtgui.h>
+#include <rtgui/image.h>
+#include <rtgui/widgets/widget.h>
+
+/** Gets the type of a iconbox */
+#define RTGUI_ICONBOX_TYPE (rtgui_iconbox_type_get())
+/** Casts the object to a rtgui_iconbox */
+#define RTGUI_ICONBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_ICONBOX_TYPE, rtgui_iconbox_t))
+/** Checks if the object is a rtgui_iconbox */
+#define RTGUI_IS_ICONBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_ICONBOX_TYPE))
+
+#define RTGUI_ICONBOX_NOTEXT 0x00
+#define RTGUI_ICONBOX_TEXT_RIGHT 0x01
+#define RTGUI_ICONBOX_TEXT_BELOW 0x02
+
+struct rtgui_iconbox
+{
+ /* inherit from widget */
+ struct rtgui_widget parent;
+
+ /* widget private data */
+ struct rtgui_image* image;
+
+ unsigned char *text;
+ rt_ubase_t text_position;
+
+ rt_bool_t selected;
+};
+typedef struct rtgui_iconbox rtgui_iconbox_t;
+
+rtgui_type_t *rtgui_iconbox_type_get(void);
+
+struct rtgui_iconbox* rtgui_iconbox_create(struct rtgui_image* image, const unsigned char* text, int position);
+void rtgui_iconbox_destroy(struct rtgui_iconbox* iconbox);
+
+rt_bool_t rtgui_iconbox_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
+
+void rtgui_iconbox_set_text_position(struct rtgui_iconbox* iconbox, int position);
+
+#endif
diff --git a/rtgui/include/rtgui/widgets/label.h b/rtgui/include/rtgui/widgets/label.h new file mode 100644 index 0000000000..d9f87d9b88 --- /dev/null +++ b/rtgui/include/rtgui/widgets/label.h @@ -0,0 +1,49 @@ +/*
+ * File : label.h
+ * This file is part of 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-16 Bernard first version
+ */
+#ifndef __RTGUI_LABEL_H__
+#define __RTGUI_LABEL_H__
+
+#include <rtgui/rtgui.h>
+#include <rtgui/widgets/widget.h>
+
+/** Gets the type of a button */
+#define RTGUI_LABEL_TYPE (rtgui_label_type_get())
+/** Casts the object to an rtgui_button */
+#define RTGUI_LABEL(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LABEL_TYPE, rtgui_label_t))
+/** Checks if the object is an rtgui_button */
+#define RTGUI_IS_LABEL(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LABEL_TYPE))
+
+/*
+ * the label widget
+ */
+struct rtgui_label
+{
+ struct rtgui_widget parent;
+
+ /* label */
+ unsigned char* text;
+};
+typedef struct rtgui_label rtgui_label_t;
+
+rtgui_type_t *rtgui_label_type_get(void);
+
+rtgui_label_t* rtgui_label_create(const unsigned char* text);
+void rtgui_label_destroy(rtgui_label_t* label);
+
+rt_bool_t rtgui_label_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
+
+void rtgui_label_set_text(rtgui_label_t* label, const unsigned char* text);
+unsigned char* rtgui_label_get_text(rtgui_label_t* label);
+
+#endif
diff --git a/rtgui/include/rtgui/widgets/listbox.h b/rtgui/include/rtgui/widgets/listbox.h new file mode 100644 index 0000000000..1c201301da --- /dev/null +++ b/rtgui/include/rtgui/widgets/listbox.h @@ -0,0 +1,66 @@ +/*
+ * File : listbox.h
+ * This file is part of 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-16 Bernard first version
+ */
+#ifndef __RTGUI_LISTBOX_H__
+#define __RTGUI_LISTBOX_H__
+
+#include <rtgui/widgets/item.h>
+#include <rtgui/widgets/scrollview.h>
+
+#define RTGUI_LISTBOX_WIDTH 150
+#define RTGUI_LISTBOX_HEIGHT 200
+
+/** Gets the type of a listbox */
+#define RTGUI_LISTBOX_TYPE (rtgui_listbox_type_get())
+/** Casts the object to a rtgui_listbox */
+#define RTGUI_LISTBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LISTBOX_TYPE, rtgui_listbox_t))
+/** Checks if the object is a rtgui_listbox */
+#define RTGUI_IS_LISTBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LISTBOX_TYPE))
+
+/*
+* the listbox widget
+*/
+struct rtgui_listbox
+{
+ struct rtgui_scrollview parent;
+
+ /* widget private data */
+ int flag;
+
+ /* total number of items */
+ rt_uint32_t count;
+
+ /* the selected item */
+ struct rtgui_item* selected;
+
+ /* call back */
+ rt_bool_t (*on_selected) (struct rtgui_widget* widget, struct rtgui_event* event);
+ rt_bool_t (*on_activated) (struct rtgui_widget* widget, struct rtgui_event* event);
+};
+typedef struct rtgui_listbox rtgui_listbox_t;
+
+rtgui_type_t *rtgui_listbox_type_get(void);
+
+rtgui_listbox_t* rtgui_listbox_create(void);
+void rtgui_listbox_destroy(rtgui_listbox_t* listbox);
+
+rt_bool_t rtgui_listbox_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
+
+struct rtgui_item* rtgui_listbox_get_select(struct rtgui_listbox* box);
+void rtgui_listbox_set_select(struct rtgui_listbox* box, rt_uint32_t index);
+void rtgui_listbox_set_select_item(struct rtgui_listbox* box, struct rtgui_item* item);
+
+struct rtgui_item* rtgui_listbox_add_item_string(struct rtgui_listbox* box, const unsigned char* text);
+void rtgui_listbox_add_item(struct rtgui_listbox* list, struct rtgui_item* item);
+
+#endif
diff --git a/rtgui/include/rtgui/widgets/textbox.h b/rtgui/include/rtgui/widgets/textbox.h new file mode 100644 index 0000000000..709b35f76b --- /dev/null +++ b/rtgui/include/rtgui/widgets/textbox.h @@ -0,0 +1,73 @@ +/*
+ * File : textbox.h
+ * This file is part of 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-16 Bernard first version
+ */
+#ifndef __RTGUI_TEXTBOX_H__
+#define __RTGUI_TEXTBOX_H__
+
+#include <rtgui/rtgui.h>
+#include <rtgui/caret.h>
+#include <rtgui/widgets/widget.h>
+
+/** Gets the type of a textbox */
+#define RTGUI_TEXTBOX_TYPE (rtgui_textbox_type_get())
+/** Casts the object to a rtgui_textbox */
+#define RTGUI_TEXTBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_TEXTBOX_TYPE, rtgui_textbox_t))
+/** Checks if the object is a rtgui_textbox */
+#define RTGUI_IS_TEXTBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_TEXTBOX_TYPE))
+
+#define RTGUI_TEXTBOX_DEFAULT_WIDTH 80
+#define RTGUI_TEXTBOX_DEFAULT_HEIGHT 20
+
+#define RTGUI_TEXTBOX_SINGLE 0x00
+#define RTGUI_TEXTBOX_MULTI 0x00
+
+struct rtgui_textbox_line
+{
+ rt_uint8_t* line_text;
+
+ struct rtgui_textbox_line *prev, *next;
+};
+
+struct rtgui_textbox
+{
+ /* inherit from widget */
+ struct rtgui_widget parent;
+
+ /* text box type */
+ rt_ubase_t type;
+
+ /* current line and position */
+ rt_size_t line, line_begin, position, line_length;
+
+ rt_uint8_t* text;
+ rt_size_t font_width;
+
+ int caret_x, caret_y;
+ struct rtgui_caret* caret;
+
+ /* widget private data */
+ rt_bool_t (*on_enter) (struct rtgui_widget* widget, struct rtgui_event* event);
+};
+typedef struct rtgui_textbox rtgui_textbox_t;
+
+struct rtgui_textbox* rtgui_textbox_create(const char* text);
+void rtgui_textbox_destroy(struct rtgui_textbox* box);
+
+rt_bool_t rtgui_textbox_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
+
+void rtgui_textbox_set_value(struct rtgui_textbox* box, const char* text);
+const char* rtgui_textbox_get_value(struct rtgui_textbox* box);
+
+void rtgui_widget_set_line_length(struct rtgui_textbox* box, rt_size_t length);
+
+#endif
diff --git a/rtgui/include/rtgui/widgets/title.h b/rtgui/include/rtgui/widgets/title.h new file mode 100644 index 0000000000..0eda0f16a4 --- /dev/null +++ b/rtgui/include/rtgui/widgets/title.h @@ -0,0 +1,45 @@ +/*
+ * File : title.h
+ * This file is part of 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-16 Bernard first version
+ */
+#ifndef __RTGUI_TITLE__
+#define __RTGUI_TITLE__
+
+#include <rtgui/widgets/toplevel.h>
+
+/** Gets the type of a top win */
+#define RTGUI_WINTITLE_TYPE (rtgui_wintitle_type_get())
+/** Casts the object to an rtgui_wintitle */
+#define RTGUI_WINTITLE(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_WINTITLE_TYPE, rtgui_wintitle_t))
+/** Checks if the object is an rtgui_wintitle */
+#define RTGUI_IS_WINTITLE(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_WINTITLE_TYPE))
+
+struct rtgui_wintitle
+{
+ struct rtgui_toplevel parent;
+
+ /* title */
+ rt_uint8_t* title;
+};
+typedef struct rtgui_wintitle rtgui_wintitle_t;
+
+rtgui_type_t* rtgui_wintitle_type_get(void);
+
+rtgui_wintitle_t* rtgui_wintitle_create(const rt_uint8_t* title);
+void rtgui_wintitle_destroy(rtgui_wintitle_t* wintitle);
+
+rt_bool_t rtgui_wintile_event_handler(rtgui_widget_t* widget, rtgui_event_t* event);
+
+void rtgui_wintitle_set_title(rtgui_wintitle_t* wintitle, const rt_uint8_t* title);
+rt_uint8_t *rtgui_wintitle_get_title(rtgui_wintitle_t* wintitle);
+
+#endif
diff --git a/rtgui/include/rtgui/widgets/toplevel.h b/rtgui/include/rtgui/widgets/toplevel.h new file mode 100644 index 0000000000..044edf4058 --- /dev/null +++ b/rtgui/include/rtgui/widgets/toplevel.h @@ -0,0 +1,57 @@ +/*
+ * File : toplevel.h
+ * This file is part of 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-16 Bernard first version
+ */
+#ifndef __RTGUI_TOPLEVEL_H__
+#define __RTGUI_TOPLEVEL_H__
+
+#include <rtgui/widgets/container.h>
+
+/** Gets the type of a toplevel */
+#define RTGUI_TOPLEVEL_TYPE (rtgui_toplevel_type_get())
+/** Casts the object to an rtgui_toplevel */
+#define RTGUI_TOPLEVEL(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_TOPLEVEL_TYPE, rtgui_toplevel_t))
+/** Checks if the object is an rtgui_toplevel */
+#define RTGUI_IS_TOPLEVEL(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_TOPLEVEL_TYPE))
+
+struct rtgui_toplevel
+{
+ /* inherit from container */
+ rtgui_container_t parent;
+
+ /* drawing count */
+ rt_base_t drawing;
+
+ /* external clip info */
+ rtgui_rect_t* external_clip_rect;
+ rt_uint32_t external_clip_size;
+
+ /* server thread id */
+ rt_thread_t server;
+
+ /* current focus widget */
+ rtgui_widget_t* focus;
+};
+typedef struct rtgui_toplevel rtgui_toplevel_t;
+
+rtgui_type_t *rtgui_toplevel_type_get(void);
+
+rt_bool_t rtgui_toplevel_event_handler(rtgui_widget_t* widget, rtgui_event_t* event);
+
+void rtgui_toplevel_handle_clip(struct rtgui_toplevel* top,
+ struct rtgui_event_clip_info* info);
+void rtgui_toplevel_update_clip(rtgui_toplevel_t* top);
+
+void rtgui_toplevel_set_focus(struct rtgui_toplevel* top, rtgui_widget_t* focus);
+rtgui_widget_t* rtgui_toplevel_get_focus(struct rtgui_toplevel* top);
+
+#endif
diff --git a/rtgui/include/rtgui/widgets/view.h b/rtgui/include/rtgui/widgets/view.h new file mode 100644 index 0000000000..3dd6c43e63 --- /dev/null +++ b/rtgui/include/rtgui/widgets/view.h @@ -0,0 +1,61 @@ +/*
+ * File : view.h
+ * This file is part of 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-16 Bernard first version
+ */
+#ifndef __RTGUI_VIEW_H__
+#define __RTGUI_VIEW_H__
+
+#include <rtgui/widgets/box.h>
+#include <rtgui/widgets/container.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Gets the type of a view */
+#define RTGUI_VIEW_TYPE (rtgui_view_type_get())
+/** Casts the object to an rtgui_view */
+#define RTGUI_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_VIEW_TYPE, rtgui_view_t))
+/** Checks if the object is an rtgui_view */
+#define RTGUI_IS_VIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_VIEW_TYPE))
+
+/*
+ * the view widget
+ */
+struct rtgui_view
+{
+ /* inherit from container */
+ struct rtgui_container parent;
+
+ /* private field */
+ char* title;
+};
+typedef struct rtgui_view rtgui_view_t;
+
+rtgui_view_t* rtgui_view_create(const char* title);
+void rtgui_view_destroy(rtgui_view_t* view);
+
+rt_bool_t rtgui_view_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
+
+void rtgui_view_set_box(rtgui_view_t* view, rtgui_box_t* box);
+
+void rtgui_view_show(rtgui_view_t* view);
+void rtgui_view_hide(rtgui_view_t* view);
+
+char* rtgui_view_get_title(rtgui_view_t* view);
+void rtgui_view_set_title(rtgui_view_t* view, const char* title);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
|
