diff options
| author | [email protected] <[email protected]> | 2012-04-18 15:06:12 +0000 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2012-04-18 15:06:12 +0000 |
| commit | db0646020812efc16ff0beebe35f9049dcc2bfed (patch) | |
| tree | 5e949e9ba679a07b0198745853e900a016a3834e /components/rtgui/include | |
| parent | 06d45f0c42f2aa3678d509403fcf9cd82be106e6 (diff) | |
merge new RTGUI in to trunk
The full log is at https://github.com/RTGUI/RTGUI/commits/merge_1 and it's difficult to merge the new tree commit by commit. I also converted all the file into unix eol so there are many fake diff. Big changes are noted in rtgui/doc/road_map.txt and rtgui/doc/attention.txt. Keep an eye on them if you want to migrate your old code.
Note that the work is still in progress and the bsp is not prepared in trunk so far.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2092 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/rtgui/include')
47 files changed, 3373 insertions, 3330 deletions
diff --git a/components/rtgui/include/rtgui/blit.h b/components/rtgui/include/rtgui/blit.h index 615e5b6d7e..df0d2a5b32 100644 --- a/components/rtgui/include/rtgui/blit.h +++ b/components/rtgui/include/rtgui/blit.h @@ -1,9 +1,9 @@ -#ifndef __RTGUI_BLIT_H__
-#define __RTGUI_BLIT_H__
-
-#include <rtgui/rtgui.h>
-
-typedef void (*rtgui_blit_line_func)(rt_uint8_t* dst, rt_uint8_t* src, int line);
-rtgui_blit_line_func rtgui_blit_line_get(int dst_bpp, int src_bpp);
-
-#endif
+#ifndef __RTGUI_BLIT_H__ +#define __RTGUI_BLIT_H__ + +#include <rtgui/rtgui.h> + +typedef void (*rtgui_blit_line_func)(rt_uint8_t* dst, rt_uint8_t* src, int line); +rtgui_blit_line_func rtgui_blit_line_get(int dst_bpp, int src_bpp); + +#endif diff --git a/components/rtgui/include/rtgui/color.h b/components/rtgui/include/rtgui/color.h index 0e78bd0fd3..d8f5fce177 100644 --- a/components/rtgui/include/rtgui/color.h +++ b/components/rtgui/include/rtgui/color.h @@ -1,114 +1,114 @@ -/*
- * 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>
-
-#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 = (rt_uint16_t)(((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 = (rt_uint16_t)(((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;
-}
-
-/* convert rtgui color to RGB */
-rt_inline rt_uint32_t rtgui_color_to_888(rtgui_color_t c)
-{
- rt_uint32_t pixel;
-
- pixel = RTGUI_RGB_R(c) << 16 | RTGUI_RGB_G(c) << 8 | RTGUI_RGB_B(c);
- return pixel;
-}
-
-rt_inline rtgui_color_t rtgui_color_from_888(rt_uint32_t pixel)
-{
- rtgui_color_t color;
-
- color = RTGUI_RGB(((pixel >> 16) & 0xff), ((pixel >> 8) & 0xff), pixel & 0xff);
-
- return color;
-}
-
-#endif
-
+/* + * 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> + +#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 = (rt_uint16_t)(((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 = (rt_uint16_t)(((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; +} + +/* convert rtgui color to RGB */ +rt_inline rt_uint32_t rtgui_color_to_888(rtgui_color_t c) +{ + rt_uint32_t pixel; + + pixel = RTGUI_RGB_R(c) << 16 | RTGUI_RGB_G(c) << 8 | RTGUI_RGB_B(c); + return pixel; +} + +rt_inline rtgui_color_t rtgui_color_from_888(rt_uint32_t pixel) +{ + rtgui_color_t color; + + color = RTGUI_RGB(((pixel >> 16) & 0xff), ((pixel >> 8) & 0xff), pixel & 0xff); + + return color; +} + +#endif + diff --git a/components/rtgui/include/rtgui/dc.h b/components/rtgui/include/rtgui/dc.h index bca0a65015..15ae971cb0 100644 --- a/components/rtgui/include/rtgui/dc.h +++ b/components/rtgui/include/rtgui/dc.h @@ -1,196 +1,196 @@ -/*
- * 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_CLIENT,
- RTGUI_DC_BUFFER,
-};
-
-struct rtgui_dc_engine
-{
- /* interface */
- void (*draw_point)(struct rtgui_dc* dc, int x, int y);
- void (*draw_color_point)(struct rtgui_dc* dc, int x, int y, rtgui_color_t color);
- 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_line) (struct rtgui_dc* dc, int x1, int x2, int y, rt_uint8_t* line_data);
- void (*blit )(struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect);
-
- /* set and get graphic context */
- void (*set_gc)(struct rtgui_dc* dc, struct rtgui_gc *gc);
- struct rtgui_gc* (*get_gc)(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);
-};
-
-/* the abstract device context */
-struct rtgui_dc
-{
- /* type of device context */
- rt_uint32_t type;
-
- /* dc engine */
- const struct rtgui_dc_engine* engine;
-};
-
-#define RTGUI_DC_FC(dc) (rtgui_dc_get_gc(dc)->foreground)
-#define RTGUI_DC_BC(dc) (rtgui_dc_get_gc(dc)->background)
-#define RTGUI_DC_FONT(dc) (rtgui_dc_get_gc(dc)->font)
-#define RTGUI_DC_TEXTALIGN(dc) (rtgui_dc_get_gc(dc)->textalign)
-
-/* 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);
-
-/* begin and end a drawing */
-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_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_fill_rect_forecolor(struct rtgui_dc* dc, struct rtgui_rect* rect);
-void rtgui_dc_draw_round_rect(struct rtgui_dc* dc, struct rtgui_rect* rect, int r);
-void rtgui_dc_fill_round_rect(struct rtgui_dc* dc, struct rtgui_rect* rect, int r);
-void rtgui_dc_draw_annulus(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t r1, rt_int16_t r2, rt_int16_t start, rt_int16_t end);
-void rtgui_dc_draw_sector(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_fill_sector(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_text (struct rtgui_dc* dc, const char* text, struct rtgui_rect* rect);
-
-void rtgui_dc_draw_mono_bmp(struct rtgui_dc* dc, int x, int y, int w, int h, const rt_uint8_t* data);
-void rtgui_dc_draw_byte(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data);
-void rtgui_dc_draw_word(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data);
-
-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_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);
-
-/*
- * dc inline function
- *
- * Note:
- * In order to improve drawing speed, put most of common function of dc to inline
- */
-
-/*
- * draw a point on dc
- */
-rt_inline void rtgui_dc_draw_point(struct rtgui_dc* dc, int x, int y)
-{
- dc->engine->draw_point(dc, x, y);
-}
-
-/*
- * draw a color point on dc
- */
-rt_inline void rtgui_dc_draw_color_point(struct rtgui_dc* dc, int x, int y, rtgui_color_t color)
-{
- dc->engine->draw_color_point(dc, x, y, color);
-}
-
-/*
- * draw a vertical line on dc
- */
-rt_inline void rtgui_dc_draw_vline(struct rtgui_dc* dc, int x, int y1, int y2)
-{
- dc->engine->draw_vline(dc, x, y1, y2);
-}
-
-/*
- * draw a horizontal line on dc
- */
-rt_inline void rtgui_dc_draw_hline(struct rtgui_dc* dc, int x1, int x2, int y)
-{
- dc->engine->draw_hline(dc, x1, x2, y);
-}
-
-/*
- * fill a rect with background color
- */
-rt_inline void rtgui_dc_fill_rect (struct rtgui_dc* dc, struct rtgui_rect* rect)
-{
- dc->engine->fill_rect(dc, rect);
-}
-
-/*
- * blit a dc on hardware dc
- */
-rt_inline void rtgui_dc_blit(struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect)
-{
- dc->engine->blit(dc, dc_point, dest, rect);
-}
-
-/*
- * set gc of dc
- */
-rt_inline void rtgui_dc_set_gc(struct rtgui_dc* dc, rtgui_gc_t* gc)
-{
- dc->engine->set_gc(dc, gc);
-}
-
-/*
- * get gc of dc
- */
-rt_inline rtgui_gc_t *rtgui_dc_get_gc(struct rtgui_dc* dc)
-{
- return dc->engine->get_gc(dc);
-}
-
-/*
- * get visible status of dc
- */
-rt_inline rt_bool_t rtgui_dc_get_visible(struct rtgui_dc* dc)
-{
- return dc->engine->get_visible(dc);
-}
-
-/*
- * get rect of dc
- */
-rt_inline void rtgui_dc_get_rect(struct rtgui_dc*dc, rtgui_rect_t* rect)
-{
- dc->engine->get_rect(dc, rect);
-}
-
-#endif
+/* + * 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_CLIENT, + RTGUI_DC_BUFFER, +}; + +struct rtgui_dc_engine +{ + /* interface */ + void (*draw_point)(struct rtgui_dc* dc, int x, int y); + void (*draw_color_point)(struct rtgui_dc* dc, int x, int y, rtgui_color_t color); + 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_line) (struct rtgui_dc* dc, int x1, int x2, int y, rt_uint8_t* line_data); + void (*blit )(struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect); + + /* set and get graphic context */ + void (*set_gc)(struct rtgui_dc* dc, struct rtgui_gc *gc); + struct rtgui_gc* (*get_gc)(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); +}; + +/* the abstract device context */ +struct rtgui_dc +{ + /* type of device context */ + rt_uint32_t type; + + /* dc engine */ + const struct rtgui_dc_engine* engine; +}; + +#define RTGUI_DC_FC(dc) (rtgui_dc_get_gc(dc)->foreground) +#define RTGUI_DC_BC(dc) (rtgui_dc_get_gc(dc)->background) +#define RTGUI_DC_FONT(dc) (rtgui_dc_get_gc(dc)->font) +#define RTGUI_DC_TEXTALIGN(dc) (rtgui_dc_get_gc(dc)->textalign) + +/* 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); + +/* begin and end a drawing */ +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_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_fill_rect_forecolor(struct rtgui_dc* dc, struct rtgui_rect* rect); +void rtgui_dc_draw_round_rect(struct rtgui_dc* dc, struct rtgui_rect* rect, int r); +void rtgui_dc_fill_round_rect(struct rtgui_dc* dc, struct rtgui_rect* rect, int r); +void rtgui_dc_draw_annulus(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t r1, rt_int16_t r2, rt_int16_t start, rt_int16_t end); +void rtgui_dc_draw_sector(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_fill_sector(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_text (struct rtgui_dc* dc, const char* text, struct rtgui_rect* rect); + +void rtgui_dc_draw_mono_bmp(struct rtgui_dc* dc, int x, int y, int w, int h, const rt_uint8_t* data); +void rtgui_dc_draw_byte(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data); +void rtgui_dc_draw_word(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data); + +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_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); + +/* + * dc inline function + * + * Note: + * In order to improve drawing speed, put most of common function of dc to inline + */ + +/* + * draw a point on dc + */ +rt_inline void rtgui_dc_draw_point(struct rtgui_dc* dc, int x, int y) +{ + dc->engine->draw_point(dc, x, y); +} + +/* + * draw a color point on dc + */ +rt_inline void rtgui_dc_draw_color_point(struct rtgui_dc* dc, int x, int y, rtgui_color_t color) +{ + dc->engine->draw_color_point(dc, x, y, color); +} + +/* + * draw a vertical line on dc + */ +rt_inline void rtgui_dc_draw_vline(struct rtgui_dc* dc, int x, int y1, int y2) +{ + dc->engine->draw_vline(dc, x, y1, y2); +} + +/* + * draw a horizontal line on dc + */ +rt_inline void rtgui_dc_draw_hline(struct rtgui_dc* dc, int x1, int x2, int y) +{ + dc->engine->draw_hline(dc, x1, x2, y); +} + +/* + * fill a rect with background color + */ +rt_inline void rtgui_dc_fill_rect (struct rtgui_dc* dc, struct rtgui_rect* rect) +{ + dc->engine->fill_rect(dc, rect); +} + +/* + * blit a dc on hardware dc + */ +rt_inline void rtgui_dc_blit(struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect) +{ + dc->engine->blit(dc, dc_point, dest, rect); +} + +/* + * set gc of dc + */ +rt_inline void rtgui_dc_set_gc(struct rtgui_dc* dc, rtgui_gc_t* gc) +{ + dc->engine->set_gc(dc, gc); +} + +/* + * get gc of dc + */ +rt_inline rtgui_gc_t *rtgui_dc_get_gc(struct rtgui_dc* dc) +{ + return dc->engine->get_gc(dc); +} + +/* + * get visible status of dc + */ +rt_inline rt_bool_t rtgui_dc_get_visible(struct rtgui_dc* dc) +{ + return dc->engine->get_visible(dc); +} + +/* + * get rect of dc + */ +rt_inline void rtgui_dc_get_rect(struct rtgui_dc*dc, rtgui_rect_t* rect) +{ + dc->engine->get_rect(dc, rect); +} + +#endif diff --git a/components/rtgui/include/rtgui/dc_client.h b/components/rtgui/include/rtgui/dc_client.h index 297307c875..1a1de04851 100644 --- a/components/rtgui/include/rtgui/dc_client.h +++ b/components/rtgui/include/rtgui/dc_client.h @@ -1,27 +1,27 @@ -/*
- * File : dc_buffer.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, 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
- * 2010-04-10 Bernard first version
- * 2010-06-14 Bernard embedded hardware dc to each widget
- * 2010-08-09 Bernard rename hardware dc to client dc
- */
-
-#ifndef __RTGUI_DC_CLIENT_H__
-#define __RTGUI_DC_CLIENT_H__
-
-#include <rtgui/dc.h>
-
-/* create a hardware dc */
-struct rtgui_dc* rtgui_dc_client_create(rtgui_widget_t* owner);
-void rtgui_dc_client_init(rtgui_widget_t* owner);
-
-#endif
-
+/* + * File : dc_buffer.h + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2006 - 2010, 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 + * 2010-04-10 Bernard first version + * 2010-06-14 Bernard embedded hardware dc to each widget + * 2010-08-09 Bernard rename hardware dc to client dc + */ + +#ifndef __RTGUI_DC_CLIENT_H__ +#define __RTGUI_DC_CLIENT_H__ + +#include <rtgui/dc.h> + +/* create a hardware dc */ +struct rtgui_dc* rtgui_dc_client_create(rtgui_widget_t* owner); +void rtgui_dc_client_init(rtgui_widget_t* owner); + +#endif + diff --git a/components/rtgui/include/rtgui/dc_hw.h b/components/rtgui/include/rtgui/dc_hw.h index f4c84dd755..a9eca07aa1 100644 --- a/components/rtgui/include/rtgui/dc_hw.h +++ b/components/rtgui/include/rtgui/dc_hw.h @@ -1,24 +1,24 @@ -/*
- * File : dc_buffer.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, 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
- * 2010-04-10 Bernard first version
- * 2010-06-14 Bernard embedded hardware dc to each widget
- */
-#ifndef __RTGUI_DC_HW_H__
-#define __RTGUI_DC_HW_H__
-
-#include <rtgui/dc.h>
-
-/* create a hardware dc */
-struct rtgui_dc* rtgui_dc_hw_create(rtgui_widget_t* owner);
-
-#endif
-
+/* + * File : dc_buffer.h + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2006 - 2010, 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 + * 2010-04-10 Bernard first version + * 2010-06-14 Bernard embedded hardware dc to each widget + */ +#ifndef __RTGUI_DC_HW_H__ +#define __RTGUI_DC_HW_H__ + +#include <rtgui/dc.h> + +/* create a hardware dc */ +struct rtgui_dc* rtgui_dc_hw_create(rtgui_widget_t* owner); + +#endif + diff --git a/components/rtgui/include/rtgui/dlist.h b/components/rtgui/include/rtgui/dlist.h new file mode 100644 index 0000000000..5491daca0c --- /dev/null +++ b/components/rtgui/include/rtgui/dlist.h @@ -0,0 +1,119 @@ +/* + * File : dlist.h + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2006 - 2011, 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 + * 2006-03-16 Bernard the first version + * 2006-09-07 Bernard move the kservice APIs to rtthread.h + * 2007-06-27 Bernard fix the rt_list_remove bug + * 2012-02-25 Grissiom move to rtgui/include/rtgui and some misc changes + */ + +#ifndef __RTGUI_DLIST_H__ +#define __RTGUI_DLIST_H__ + +/* This file is copied from kservice.h in RTT kernel. There are some differences: + * 1, naming. Use rtgui_dlist_ prefix instead of rt_list. + * 2, add rtgui_dlist_foreach for convenience. + * 3, move the definition of list node into this file. + * + * Please keep both of the files synchronized when fixing bugs. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct rtgui_dlist_node +{ + struct rtgui_dlist_node *next; /* point to next node. */ + struct rtgui_dlist_node *prev; /* point to prev node. */ +}; + +/** + * @brief initialize a list + * + * @param l list to be initialized + */ +rt_inline void rtgui_dlist_init(struct rtgui_dlist_node *l) +{ + l->next = l->prev = l; +} + +/** + * @brief insert a node after a list + * + * @param l list to insert it + * @param n new node to be inserted + */ +rt_inline void rtgui_dlist_insert_after(struct rtgui_dlist_node *l, struct rtgui_dlist_node *n) +{ + l->next->prev = n; + n->next = l->next; + + l->next = n; + n->prev = l; +} + +/** + * @brief insert a node before a list + * + * @param n new node to be inserted + * @param l list to insert it + */ +rt_inline void rtgui_dlist_insert_before(struct rtgui_dlist_node *l, struct rtgui_dlist_node *n) +{ + l->prev->next = n; + n->prev = l->prev; + + l->prev = n; + n->next = l; +} + +/** + * @brief remove node from list. + * @param n the node to remove from the list. + */ +rt_inline void rtgui_dlist_remove(struct rtgui_dlist_node *n) +{ + n->next->prev = n->prev; + n->prev->next = n->next; + + rtgui_dlist_init(n); +} + +/** + * @brief tests whether a list is empty + * @param l the list to test. + */ +rt_inline int rtgui_dlist_isempty(const struct rtgui_dlist_node *l) +{ + return l->next == l; +} + +/** + * @brief get the struct for this entry + * @param node the entry point + * @param type the type of structure + * @param member the name of list in structure + */ +#define rtgui_dlist_entry(node, type, member) \ + ((type *)((char *)(node) - (unsigned long)(&((type *)0)->member))) + +/* the direction can only be next or prev. If you want to iterate the list in + * normal order, use next. If you want to iterate the list with reverse order, + * use prev.*/ +#define rtgui_dlist_foreach(node, list, direction) \ + for ((node) = (list)->direction; (node) != list; (node) = (node)->direction) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/components/rtgui/include/rtgui/driver.h b/components/rtgui/include/rtgui/driver.h index 052fc137b1..664d9183f3 100644 --- a/components/rtgui/include/rtgui/driver.h +++ b/components/rtgui/include/rtgui/driver.h @@ -1,67 +1,67 @@ -/*
- * 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_ops
-{
- /* set and get pixel in (x, y) */
- void (*set_pixel) (rtgui_color_t *c, int x, int y);
- void (*get_pixel) (rtgui_color_t *c, int x, int y);
-
- void (*draw_hline)(rtgui_color_t *c, int x1, int x2, int y);
- void (*draw_vline)(rtgui_color_t *c, int x , int y1, int y2);
-
- /* draw raw hline */
- void (*draw_raw_hline)(rt_uint8_t *pixels, int x1, int x2, int y);
-};
-
-struct rtgui_graphic_driver
-{
- /* pixel format and byte per pixel */
- rt_uint8_t pixel_format;
- rt_uint8_t bits_per_pixel;
- rt_uint16_t pitch;
-
- /* screen width and height */
- rt_uint16_t width;
- rt_uint16_t height;
-
- /* framebuffer address and ops */
- volatile rt_uint8_t *framebuffer;
- rt_device_t device;
- const struct rtgui_graphic_driver_ops *ops;
-};
-
-void rtgui_graphic_driver_add(const struct rtgui_graphic_driver* driver);
-
-struct rtgui_graphic_driver* rtgui_graphic_driver_get_default(void);
-
-void rtgui_graphic_driver_get_rect(const struct rtgui_graphic_driver *driver, rtgui_rect_t *rect);
-void rtgui_graphic_driver_screen_update(const struct rtgui_graphic_driver* driver, rtgui_rect_t *rect);
-rt_uint8_t* rtgui_graphic_driver_get_framebuffer(const struct rtgui_graphic_driver* driver);
-
-rt_err_t rtgui_graphic_set_device(rt_device_t device);
-
-rt_inline struct rtgui_graphic_driver* rtgui_graphic_get_device()
-{
- extern struct rtgui_graphic_driver _driver;
- return &_driver;
-}
-
-#endif
-
+/* + * 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_ops +{ + /* set and get pixel in (x, y) */ + void (*set_pixel) (rtgui_color_t *c, int x, int y); + void (*get_pixel) (rtgui_color_t *c, int x, int y); + + void (*draw_hline)(rtgui_color_t *c, int x1, int x2, int y); + void (*draw_vline)(rtgui_color_t *c, int x , int y1, int y2); + + /* draw raw hline */ + void (*draw_raw_hline)(rt_uint8_t *pixels, int x1, int x2, int y); +}; + +struct rtgui_graphic_driver +{ + /* pixel format and byte per pixel */ + rt_uint8_t pixel_format; + rt_uint8_t bits_per_pixel; + rt_uint16_t pitch; + + /* screen width and height */ + rt_uint16_t width; + rt_uint16_t height; + + /* framebuffer address and ops */ + volatile rt_uint8_t *framebuffer; + rt_device_t device; + const struct rtgui_graphic_driver_ops *ops; +}; + +void rtgui_graphic_driver_add(const struct rtgui_graphic_driver* driver); + +struct rtgui_graphic_driver* rtgui_graphic_driver_get_default(void); + +void rtgui_graphic_driver_get_rect(const struct rtgui_graphic_driver *driver, rtgui_rect_t *rect); +void rtgui_graphic_driver_screen_update(const struct rtgui_graphic_driver* driver, rtgui_rect_t *rect); +rt_uint8_t* rtgui_graphic_driver_get_framebuffer(const struct rtgui_graphic_driver* driver); + +rt_err_t rtgui_graphic_set_device(rt_device_t device); + +rt_inline struct rtgui_graphic_driver* rtgui_graphic_get_device() +{ + extern struct rtgui_graphic_driver _driver; + return &_driver; +} + +#endif + diff --git a/components/rtgui/include/rtgui/event.h b/components/rtgui/include/rtgui/event.h index 231263d5fe..e20b5cabee 100644 --- a/components/rtgui/include/rtgui/event.h +++ b/components/rtgui/include/rtgui/event.h @@ -1,423 +1,352 @@ -/*
- * 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_uint16_t type;
- /* user field of event */
- rt_uint16_t user;
-
- /* 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)->user = 0; \
- (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;
-
-#ifndef RTGUI_USING_SMALL_SIZE
- /* the window title */
- rt_uint8_t title[RTGUI_NAME_MAX];
- /* the window extent */
- struct rtgui_rect extent;
-#endif
-
- /* the window id */
- rtgui_win_t* wid;
-};
-
-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 */
- rtgui_rect_t rect; /* rect to be updated */
-};
-
-struct rtgui_timer;
-struct rtgui_event_timer
-{
- struct rtgui_event parent;
-
- struct rtgui_timer *timer;
-};
-typedef struct rtgui_event_timer rtgui_event_timer_t;
-
-
-struct rtgui_event_clip_info
-{
- struct rtgui_event parent;
-
- /* destination window */
- rtgui_win_t* wid;
-
- /* the number of rects */
- rt_uint32_t num_rect;
-
- /* rtgui_rect_t *rects */
-};
-#define RTGUI_EVENT_GET_RECT(e, i) &(((rtgui_rect_t*)(e + 1))[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 */
-
- rt_uint16_t type; /* key down or up */
- rt_uint16_t key; /* current key */
- rt_uint16_t 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)->type == 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 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
+/* + * 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> + +/* NOTE: if you create a new event type, remember to add it into the union + * rtgui_event_generic */ +enum _rtgui_event_type +{ + /* 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 */ + RTGUI_EVENT_WIN_MODAL_ENTER, /* the window is entering modal mode. + This event should be sent after the + window got setup and before the + application got setup. */ + + /* 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_uint16_t type; + /* user field of event */ + rt_uint16_t user; + + /* 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)->user = 0; \ + (e)->sender = rt_thread_self(); \ + (e)->ack = RT_NULL; \ +} while (0) + +#define _RTGUI_EVENT_WIN_ELEMENTS \ + struct rtgui_event parent; \ + struct rtgui_win *wid; + +/* + * RTGUI Window Event + */ +struct rtgui_event_win +{ + _RTGUI_EVENT_WIN_ELEMENTS +}; + +struct rtgui_event_win_create +{ + _RTGUI_EVENT_WIN_ELEMENTS + struct rtgui_win *parent_window; +#ifndef RTGUI_USING_SMALL_SIZE + /* the window title */ + rt_uint8_t title[RTGUI_NAME_MAX]; + /* the window extent */ + struct rtgui_rect extent; +#endif +}; + +struct rtgui_event_win_move +{ + _RTGUI_EVENT_WIN_ELEMENTS + rt_int16_t x, y; +}; + +struct rtgui_event_win_resize +{ + _RTGUI_EVENT_WIN_ELEMENTS + + 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 +#define rtgui_event_win_modal_enter 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) +#define RTGUI_EVENT_WIN_MODAL_ENTER_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_MODAL_ENTER) + +/* + * 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 +{ + _RTGUI_EVENT_WIN_ELEMENTS + + /* the monitor rect */ + rtgui_rect_t rect; +}; + +struct rtgui_event_paint +{ + _RTGUI_EVENT_WIN_ELEMENTS + + rtgui_rect_t rect; /* rect to be updated */ +}; + +struct rtgui_timer; +struct rtgui_event_timer +{ + struct rtgui_event parent; + + struct rtgui_timer *timer; +}; +typedef struct rtgui_event_timer rtgui_event_timer_t; + + +struct rtgui_event_clip_info +{ + _RTGUI_EVENT_WIN_ELEMENTS + + /* the number of rects */ + //rt_uint32_t num_rect; + + /* rtgui_rect_t *rects */ +}; +#define RTGUI_EVENT_GET_RECT(e, i) &(((rtgui_rect_t*)(e + 1))[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 +{ + _RTGUI_EVENT_WIN_ELEMENTS + + 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 +{ + _RTGUI_EVENT_WIN_ELEMENTS + + rt_uint16_t type; /* key down or up */ + rt_uint16_t key; /* current key */ + rt_uint16_t 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)->type == 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 +{ + _RTGUI_EVENT_WIN_ELEMENTS + + /* command type */ + rt_int32_t type; + + /* command id */ + rt_int32_t command_id; + + /* 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) + +#undef _RTGUI_EVENT_WIN_ELEMENTS + +union rtgui_event_generic +{ + struct rtgui_event base; + struct rtgui_event_win win_base; + struct rtgui_event_win_create win_create; + struct rtgui_event_win_move win_move; + struct rtgui_event_win_resize win_resize; + struct rtgui_event_win_destroy win_destroy; + struct rtgui_event_win_show win_show; + struct rtgui_event_win_hide win_hide; + struct rtgui_event_win_activate win_activate; + struct rtgui_event_win_deactivate win_deactivate; + struct rtgui_event_win_close win_close; + struct rtgui_event_win_modal_enter win_modal_enter; + struct rtgui_event_update_begin update_begin; + struct rtgui_event_update_end update_end; + struct rtgui_event_monitor monitor; + struct rtgui_event_paint paint; + struct rtgui_event_timer timer; + struct rtgui_event_clip_info clip_info; + struct rtgui_event_mouse mouse; + struct rtgui_event_kbd kbd; + struct rtgui_event_command command; + struct rtgui_event_scrollbar scrollbar; + struct rtgui_event_focused focused; + struct rtgui_event_resize resize; +}; +#endif diff --git a/components/rtgui/include/rtgui/filerw.h b/components/rtgui/include/rtgui/filerw.h index b05ce3f8e9..c254d51afa 100644 --- a/components/rtgui/include/rtgui/filerw.h +++ b/components/rtgui/include/rtgui/filerw.h @@ -1,47 +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(const 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 */
-const rt_uint8_t* rtgui_filerw_mem_getdata(struct rtgui_filerw* context);
-
-#endif
+/* + * 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(const 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 */ +const rt_uint8_t* rtgui_filerw_mem_getdata(struct rtgui_filerw* context); + +#endif diff --git a/components/rtgui/include/rtgui/font.h b/components/rtgui/include/rtgui/font.h index 177d6a6ec6..f3bf5ef464 100644 --- a/components/rtgui/include/rtgui/font.h +++ b/components/rtgui/include/rtgui/font.h @@ -1,40 +1,40 @@ -/*
- * 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 char* text,
- rt_ubase_t len, struct rtgui_rect* rect);
- void (*font_get_metrics)(struct rtgui_font* font, const char* text, struct rtgui_rect* rect);
-};
-
-/*
- * bitmap font engine
- */
+/* + * 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 char* text, + rt_ubase_t len, struct rtgui_rect* rect); + void (*font_get_metrics)(struct rtgui_font* font, const char* text, struct rtgui_rect* rect); +}; + +/* + * bitmap font engine + */ struct rtgui_font_bitmap { const rt_uint8_t* bmp; /* bitmap font data */ @@ -46,69 +46,69 @@ struct rtgui_font_bitmap rt_uint8_t first_char; rt_uint8_t last_char; -};
-extern const struct rtgui_font_engine bmp_font_engine;
-
-#include <rtgui/tree.h>
-SPLAY_HEAD(cache_tree, hz_cache);
-struct hz_cache
-{
- SPLAY_ENTRY(hz_cache) hz_node;
-
- rt_uint16_t hz_id;
-};
-
-struct rtgui_hz_file_font
-{
- struct cache_tree cache_root;
- rt_uint16_t cache_size;
-
- /* font size */
- rt_uint16_t font_size;
- rt_uint16_t font_data_size;
-
- /* file descriptor */
- int fd;
-
- /* font file name */
- const char* font_fn;
-};
-extern const struct rtgui_font_engine rtgui_hz_file_font_engine;
-
-struct rtgui_font
-{
- /* font name */
- char* family;
-
- /* font height */
- rt_uint16_t height;
-
- /* refer count */
- rt_uint32_t refer_count;
-
- /* font engine */
- const 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 char* text, rt_ubase_t len, struct rtgui_rect* rect);
-int rtgui_font_get_string_width(struct rtgui_font* font, const char* text);
-void rtgui_font_get_metrics(struct rtgui_font* font, const char* text, struct rtgui_rect* rect);
-
-#endif
+}; +extern const struct rtgui_font_engine bmp_font_engine; + +#include <rtgui/tree.h> +SPLAY_HEAD(cache_tree, hz_cache); +struct hz_cache +{ + SPLAY_ENTRY(hz_cache) hz_node; + + rt_uint16_t hz_id; +}; + +struct rtgui_hz_file_font +{ + struct cache_tree cache_root; + rt_uint16_t cache_size; + + /* font size */ + rt_uint16_t font_size; + rt_uint16_t font_data_size; + + /* file descriptor */ + int fd; + + /* font file name */ + const char* font_fn; +}; +extern const struct rtgui_font_engine rtgui_hz_file_font_engine; + +struct rtgui_font +{ + /* font name */ + char* family; + + /* font height */ + rt_uint16_t height; + + /* refer count */ + rt_uint32_t refer_count; + + /* font engine */ + const 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 char* text, rt_ubase_t len, struct rtgui_rect* rect); +int rtgui_font_get_string_width(struct rtgui_font* font, const char* text); +void rtgui_font_get_metrics(struct rtgui_font* font, const char* text, struct rtgui_rect* rect); + +#endif diff --git a/components/rtgui/include/rtgui/font_freetype.h b/components/rtgui/include/rtgui/font_freetype.h index ced143ff07..b99108e7c4 100644 --- a/components/rtgui/include/rtgui/font_freetype.h +++ b/components/rtgui/include/rtgui/font_freetype.h @@ -1,10 +1,10 @@ -#ifndef __RTGUI_FONT_TTF_H__
-#define __RTGUI_FONT_TTF_H__
-
-#include <rtgui/dc.h>
-#include <rtgui/font.h>
-
-rtgui_font_t* rtgui_freetype_font_create(const char* filename, int bold, int italic, rt_size_t size);
-void rtgui_freetype_font_destroy(rtgui_font_t* font);
-
-#endif
+#ifndef __RTGUI_FONT_TTF_H__ +#define __RTGUI_FONT_TTF_H__ + +#include <rtgui/dc.h> +#include <rtgui/font.h> + +rtgui_font_t* rtgui_freetype_font_create(const char* filename, int bold, int italic, rt_size_t size); +void rtgui_freetype_font_destroy(rtgui_font_t* font); + +#endif diff --git a/components/rtgui/include/rtgui/image.h b/components/rtgui/include/rtgui/image.h index 45030dec40..e876354286 100644 --- a/components/rtgui/include/rtgui/image.h +++ b/components/rtgui/include/rtgui/image.h @@ -1,80 +1,80 @@ -/*
- * 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_palette
-{
- rtgui_color_t* colors;
- rt_uint32_t ncolors;
-};
-typedef struct rtgui_image_palette rtgui_image_palette_t;
-
-struct rtgui_image
-{
- /* image metrics */
- rt_uint16_t w, h;
-
- /* image engine */
- const struct rtgui_image_engine* engine;
-
- /* image palette */
- rtgui_image_palette_t* palette;
-
- /* image private data */
- void* data;
-};
-typedef struct rtgui_image rtgui_image_t;
-
-/* init rtgui image system */
-void rtgui_system_image_init(void);
-
-#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
-struct rtgui_image* rtgui_image_create_from_file(const char* type, const char* filename, rt_bool_t load);
-struct rtgui_image* rtgui_image_create(const char* filename, rt_bool_t load);
-#endif
-struct rtgui_image* rtgui_image_create_from_mem(const char* type, const rt_uint8_t* data, rt_size_t length, rt_bool_t load);
-void rtgui_image_destroy(struct rtgui_image* image);
-
-/* get image's rect */
-void rtgui_image_get_rect(struct rtgui_image* image, struct rtgui_rect* rect);
-
-/* 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);
-struct rtgui_image_palette* rtgui_image_palette_create(rt_uint32_t ncolors);
-
-#endif
-
+/* + * 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_palette +{ + rtgui_color_t* colors; + rt_uint32_t ncolors; +}; +typedef struct rtgui_image_palette rtgui_image_palette_t; + +struct rtgui_image +{ + /* image metrics */ + rt_uint16_t w, h; + + /* image engine */ + const struct rtgui_image_engine* engine; + + /* image palette */ + rtgui_image_palette_t* palette; + + /* image private data */ + void* data; +}; +typedef struct rtgui_image rtgui_image_t; + +/* init rtgui image system */ +void rtgui_system_image_init(void); + +#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) +struct rtgui_image* rtgui_image_create_from_file(const char* type, const char* filename, rt_bool_t load); +struct rtgui_image* rtgui_image_create(const char* filename, rt_bool_t load); +#endif +struct rtgui_image* rtgui_image_create_from_mem(const char* type, const rt_uint8_t* data, rt_size_t length, rt_bool_t load); +void rtgui_image_destroy(struct rtgui_image* image); + +/* get image's rect */ +void rtgui_image_get_rect(struct rtgui_image* image, struct rtgui_rect* rect); + +/* 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); +struct rtgui_image_palette* rtgui_image_palette_create(rt_uint32_t ncolors); + +#endif + diff --git a/components/rtgui/include/rtgui/kbddef.h b/components/rtgui/include/rtgui/kbddef.h index c078404c60..7a97e7f990 100644 --- a/components/rtgui/include/rtgui/kbddef.h +++ b/components/rtgui/include/rtgui/kbddef.h @@ -1,293 +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
+/* + * 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/components/rtgui/include/rtgui/list.h b/components/rtgui/include/rtgui/list.h index a58f689984..bead36be39 100644 --- a/components/rtgui/include/rtgui/list.h +++ b/components/rtgui/include/rtgui/list.h @@ -1,66 +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
+/* + * 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/components/rtgui/include/rtgui/rtgui.h b/components/rtgui/include/rtgui/rtgui.h index 5fb795b481..b473b9d794 100644 --- a/components/rtgui/include/rtgui/rtgui.h +++ b/components/rtgui/include/rtgui/rtgui.h @@ -21,17 +21,16 @@ #define RT_INT16_MIN (-RT_INT16_MAX-1) #define RTGUI_NOT_FOUND (-1) -struct rtgui_panel; struct rtgui_event; +struct rtgui_object; struct rtgui_widget; struct rtgui_win; struct rtgui_font; -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); +typedef rt_bool_t (*rtgui_event_handler_ptr)(struct rtgui_object* widget, struct rtgui_event* event); typedef void (*rtgui_onbutton_func_t)(struct rtgui_widget* widget, struct rtgui_event* event); struct rtgui_point diff --git a/components/rtgui/include/rtgui/rtgui_application.h b/components/rtgui/include/rtgui/rtgui_application.h new file mode 100644 index 0000000000..83c13aaff5 --- /dev/null +++ b/components/rtgui/include/rtgui/rtgui_application.h @@ -0,0 +1,99 @@ +/* + * File : rtgui_application.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 + * 2012-01-13 Grissiom first version + */ +#ifndef __RTGUI_APPLICATION_H__ +#define __RTGUI_APPLICATION_H__ + +#include <rtthread.h> +#include <rtgui/rtgui.h> +#include <rtgui/event.h> +#include <rtgui/rtgui_system.h> + +DECLARE_CLASS_TYPE(application); + +/** Gets the type of a application */ +#define RTGUI_APPLICATION_TYPE (RTGUI_TYPE(application)) +/** Casts the object to an rtgui_workbench */ +#define RTGUI_APPLICATION(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_APPLICATION_TYPE, struct rtgui_application)) +/** Checks if the object is an rtgui_workbench */ +#define RTGUI_IS_APPLICATION(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_APPLICATION_TYPE)) + +enum rtgui_application_flag +{ + RTGUI_APPLICATION_FLAG_EXITED = 0x04, + RTGUI_APPLICATION_FLAG_SHOWN = 0x08 +}; + +typedef void (*rtgui_idle_func)(struct rtgui_object* obj, struct rtgui_event *event); + +struct rtgui_application +{ + struct rtgui_object parent; + + /* application name */ + unsigned char *name; + + enum rtgui_application_flag state_flag; + + rt_uint16_t ref_count; + rt_uint16_t exit_code; + + /* the thread id */ + rt_thread_t tid; + rt_thread_t server; + + /* the message queue of thread */ + rt_mq_t mq; + /* event buffer */ + rt_uint8_t event_buffer[sizeof(union rtgui_event_generic)]; + + /* if not RT_NULL, the application is modaled by modal_object. If is + * RT_NULL, nothing modals. */ + struct rtgui_object *modal_object; + + /* on idle event handler */ + rtgui_idle_func on_idle; +}; + +/** + * create an application named @myname on thread @param tid + */ +struct rtgui_application* rtgui_application_create( + rt_thread_t tid, + const char *myname); +void rtgui_application_destroy(struct rtgui_application *app); +rt_err_t rtgui_application_show(struct rtgui_application *app); +rt_err_t rtgui_application_hide(struct rtgui_application *app); + +rt_base_t rtgui_application_run(struct rtgui_application *app); +void rtgui_application_exit(struct rtgui_application *app, rt_uint16_t code); + +void rtgui_application_set_onidle(rtgui_idle_func onidle); +rtgui_idle_func rtgui_application_get_onidle(void); +struct rtgui_application* rtgui_application_self(void); + +rt_thread_t rtgui_application_get_server(void); + +void rtgui_application_set_root_object(struct rtgui_object* object); +struct rtgui_object* rtgui_application_get_root_object(void); + +struct rtgui_event; +rt_err_t rtgui_application_send(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size); +rt_err_t rtgui_application_send_urgent(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size); +rt_err_t rtgui_application_send_sync(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size); +rt_err_t rtgui_application_ack(struct rtgui_event* event, rt_int32_t status); +rt_err_t rtgui_application_recv(struct rtgui_event* event, rt_size_t event_size); +rt_err_t rtgui_application_recv_nosuspend(struct rtgui_event* event, rt_size_t event_size); +rt_err_t rtgui_application_recv_filter(rt_uint32_t type, struct rtgui_event* event, rt_size_t event_size); + +#endif /* end of include guard: RTGUI_APPLICATION_H */ diff --git a/components/rtgui/include/rtgui/rtgui_config.h b/components/rtgui/include/rtgui/rtgui_config.h index 2bd82a7b74..f1dae17ca8 100644 --- a/components/rtgui/include/rtgui/rtgui_config.h +++ b/components/rtgui/include/rtgui/rtgui_config.h @@ -1,75 +1,81 @@ -/*
- * 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
- * 2010-02-08 Bernard move some RTGUI options to bsp
- */
-
-#ifndef __RTGUI_CONFIG_H__
-#define __RTGUI_CONFIG_H__
-
-/* RTGUI options */
-
-#ifdef _WIN32
- /* name length of RTGUI object */
- #define RTGUI_NAME_MAX 12
- /* support 16 weight font */
- #define RTGUI_USING_FONT16
- /* support Chinese font */
- #define RTGUI_USING_FONTHZ
- /* support FreeType TTF font */
- // #define RTGUI_USING_TTF
- /* use small size in RTGUI */
- #define RTGUI_USING_SMALL_SIZE
- /* use mouse cursor */
- /* #define RTGUI_USING_MOUSE_CURSOR */
- /* default font size in RTGUI */
- #define RTGUI_DEFAULT_FONT_SIZE 12
-
- #define RTGUI_USING_STDIO_FILERW
- #define RTGUI_IMAGE_CONTAINER
- #define RTGUI_IMAGE_XPM
- #define RTGUI_IMAGE_BMP
- #define RTGUI_IMAGE_PNG
- #define RTGUI_IMAGE_JPEG
- #define RTGUI_USING_FONT12
- #define RTGUI_USING_HZ_BMP
- #define RTGUI_MEM_TRACE
- #define RTGUI_USING_WINMOVE
-#else
- /* native running under RT-Thread */
- #ifndef RT_USING_DFS
- #undef RTGUI_USING_DFS_FILERW
- #undef RTGUI_USING_HZ_FILE
- #endif
-#endif
-
-#if RTGUI_DEFAULT_FONT_SIZE == 0
-#define RTGUI_DEFAULT_FONT_SIZE 12
-#endif
-
-#define RTGUI_SVR_THREAD_PRIORITY 15
-#define RTGUI_SVR_THREAD_TIMESLICE 5
-#ifdef RTGUI_USING_SMALL_SIZE
-#define RTGUI_SVR_THREAD_STACK_SIZE 1024
-#else
-#define RTGUI_SVR_THREAD_STACK_SIZE 2048
-#endif
-
-#define RTGUI_APP_THREAD_PRIORITY 25
-#define RTGUI_APP_THREAD_TIMESLICE 5
-#ifdef RTGUI_USING_SMALL_SIZE
-#define RTGUI_APP_THREAD_STACK_SIZE 1024
-#else
-#define RTGUI_APP_THREAD_STACK_SIZE 2048
-#endif
-
-#endif
+/* + * 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 + * 2010-02-08 Bernard move some RTGUI options to bsp + */ + +#ifndef __RTGUI_CONFIG_H__ +#define __RTGUI_CONFIG_H__ + +/* RTGUI options */ + +#ifdef _WIN32 + /* name length of RTGUI object */ + #define RTGUI_NAME_MAX 12 + /* support 16 weight font */ + #define RTGUI_USING_FONT16 + /* support Chinese font */ + #define RTGUI_USING_FONTHZ + /* support FreeType TTF font */ + //#define RTGUI_USING_TTF + /* use small size in RTGUI */ + #define RTGUI_USING_SMALL_SIZE + /* use mouse cursor */ + /* #define RTGUI_USING_MOUSE_CURSOR */ + /* default font size in RTGUI */ + #define RTGUI_DEFAULT_FONT_SIZE 12 + + #define RTGUI_USING_STDIO_FILERW + #define RTGUI_IMAGE_CONTAINER + #define RTGUI_IMAGE_XPM + #define RTGUI_IMAGE_BMP + #define RTGUI_IMAGE_PNG + #define RTGUI_IMAGE_JPEG + #define RTGUI_USING_FONT12 + #define RTGUI_USING_HZ_BMP + #define RTGUI_MEM_TRACE + #define RTGUI_USING_WINMOVE +#else + /* native running under RT-Thread */ + #ifndef RT_USING_DFS + #undef RTGUI_USING_DFS_FILERW + #undef RTGUI_USING_HZ_FILE + #endif +#endif + +#if RTGUI_DEFAULT_FONT_SIZE == 0 +#define RTGUI_DEFAULT_FONT_SIZE 12 +#endif + +#define RTGUI_SVR_THREAD_PRIORITY 15 +#define RTGUI_SVR_THREAD_TIMESLICE 5 +#ifdef RTGUI_USING_SMALL_SIZE +#define RTGUI_SVR_THREAD_STACK_SIZE 1024 +#else +#define RTGUI_SVR_THREAD_STACK_SIZE 2048 +#endif + +#define RTGUI_APP_THREAD_PRIORITY 25 +#define RTGUI_APP_THREAD_TIMESLICE 5 +#ifdef RTGUI_USING_SMALL_SIZE +#define RTGUI_APP_THREAD_STACK_SIZE 1024 +#else +#define RTGUI_APP_THREAD_STACK_SIZE 2048 +#endif + +#define RTGUI_USING_CAST_CHECK + +//#define RTGUI_USING_DESKTOP_WINDOW + +#define RTGUI_EVENT_DEBUG + +#endif diff --git a/components/rtgui/include/rtgui/rtgui_object.h b/components/rtgui/include/rtgui/rtgui_object.h index f385246b71..f89bfbf1b2 100644 --- a/components/rtgui/include/rtgui/rtgui_object.h +++ b/components/rtgui/include/rtgui/rtgui_object.h @@ -16,6 +16,7 @@ #include <rtthread.h> +#include <rtgui/rtgui.h> #ifdef __cplusplus extern "C" { @@ -85,25 +86,47 @@ DECLARE_CLASS_TYPE(type); /** Gets the type of an object */ #define RTGUI_OBJECT_TYPE RTGUI_TYPE(type) /** Casts the object to an rtgui_object_t */ -#define RTGUI_OBJECT(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_OBJECT_TYPE, rtgui_object_t)) +#define RTGUI_OBJECT(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_OBJECT_TYPE, struct rtgui_object)) /** Checks if the object is an rtgui_Object */ #define RTGUI_IS_OBJECT(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_OBJECT_TYPE)) +enum rtgui_object_flag +{ + RTGUI_OBJECT_FLAG_NONE = 0x00, + RTGUI_OBJECT_FLAG_STATIC = 0x01, + RTGUI_OBJECT_FLAG_DISABLED = 0x02 +}; + /* rtgui base object */ struct rtgui_object { /* object type */ const rtgui_type_t* type; - rt_bool_t is_static; + /* the event handler */ + rtgui_event_handler_ptr event_handler; + + enum rtgui_object_flag flag; }; -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); +/* set the event handler of object */ +void rtgui_object_set_event_handler(struct rtgui_object *object, rtgui_event_handler_ptr handler); +/* object default event handler */ +rt_bool_t rtgui_object_event_handler(struct rtgui_object *object, struct rtgui_event* event); +/* helper micro. widget event handlers could use this. */ +#define RTGUI_WIDGET_EVENT_HANDLER_PREPARE \ + struct rtgui_widget *widget; \ + RT_ASSERT(object != RT_NULL); \ + RT_ASSERT(event != RT_NULL); \ + widget = RTGUI_WIDGET(object); \ + /* supress compiler warning */ \ + widget = widget; + +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); diff --git a/components/rtgui/include/rtgui/rtgui_server.h b/components/rtgui/include/rtgui/rtgui_server.h index f5c798fbee..8d1c57a6c4 100644 --- a/components/rtgui/include/rtgui/rtgui_server.h +++ b/components/rtgui/include/rtgui/rtgui_server.h @@ -1,79 +1,84 @@ -/*
- * 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_CB_WIDTH 16 -#define WINTITLE_CB_HEIGHT 16 -#define WINTITLE_BORDER_SIZE 2
-
-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_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);
-
-void rtgui_panel_set_default_focused(char* name);
-void rtgui_panel_set_nofocused(char* name);
-
-#endif
-
+/* + * 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> +#include <rtgui/dlist.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, + /* window is hidden by default */ + WINTITLE_SHOWN = 0x40, + /* window is modaled by other window */ + WINTITLE_MODALED = 0x80, + /* window is modaling other window */ + WINTITLE_MODALING = 0x100 +}; + +#define WINTITLE_HEIGHT 20 +#define WINTITLE_CB_WIDTH 16 +#define WINTITLE_CB_HEIGHT 16 +#define WINTITLE_BORDER_SIZE 2 + +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; + + struct rtgui_topwin *parent; + + /* we need to iterate the topwin list with usual order(get target window) + * or reversely(painting). So it's better to use a double linked list */ + struct rtgui_dlist_node list; + struct rtgui_dlist_node child_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_server_init(void); + +/* post an event to server */ +void rtgui_server_post_event(struct rtgui_event* event, rt_size_t size); +rt_err_t rtgui_server_post_event_sync(struct rtgui_event* event, rt_size_t size); + +#endif + diff --git a/components/rtgui/include/rtgui/rtgui_system.h b/components/rtgui/include/rtgui/rtgui_system.h index 6577f38b67..4f94ab83d1 100644 --- a/components/rtgui/include/rtgui/rtgui_system.h +++ b/components/rtgui/include/rtgui/rtgui_system.h @@ -1,100 +1,57 @@ -/*
- * 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;
-
-#ifdef RTGUI_USING_SMALL_SIZE
-#define RTGUI_EVENT_BUFFER_SIZE 64
-#else
-#define RTGUI_EVENT_BUFFER_SIZE 256
-#endif
-
-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;
- /* event buffer */
- rt_uint8_t event_buffer[RTGUI_EVENT_BUFFER_SIZE];
-
- /* on idle event handler */
- void (*on_idle)(struct rtgui_widget* widget, struct rtgui_event *event);
-};
-typedef struct rtgui_thread rtgui_thread_t;
-struct rtgui_timer;
-typedef void (*rtgui_timeout_func)(struct rtgui_timer* timer, void* parameter);
-typedef void (*rtgui_idle_func)(struct rtgui_widget* widget, struct rtgui_event *event);
-
-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);
-
-rtgui_thread_t* rtgui_thread_register(rt_thread_t tid, rt_mq_t mq);
-void rtgui_thread_deregister(rt_thread_t tid);
-void rtgui_thread_set_onidle(rtgui_idle_func onidle);
-rtgui_idle_func rtgui_thread_get_onidle(void);
-rtgui_thread_t* rtgui_thread_self(void);
-
-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_nosuspend(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_malloc(rt_size_t size);
-void rtgui_free(void* ptr);
-void* rtgui_realloc(void* ptr, rt_size_t size);
-
-#define rtgui_enter_critical rt_enter_critical
-#define rtgui_exit_critical rt_exit_critical
-
-#endif
-
+/* + * 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_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); + +/* rtgui system initialization function */ +void rtgui_system_server_init(void); + +void* rtgui_malloc(rt_size_t size); +void rtgui_free(void* ptr); +void* rtgui_realloc(void* ptr, rt_size_t size); + +#define rtgui_enter_critical rt_enter_critical +#define rtgui_exit_critical rt_exit_critical + +#endif + diff --git a/components/rtgui/include/rtgui/widgets/about_view.h b/components/rtgui/include/rtgui/widgets/about_view.h index 9058d84bb7..510796edf3 100644 --- a/components/rtgui/include/rtgui/widgets/about_view.h +++ b/components/rtgui/include/rtgui/widgets/about_view.h @@ -1,46 +1,44 @@ -/*
- * File : list_view.h
- * This file is part of RTGUI in RT-Thread RTOS
- * COPYRIGHT (C) 2010, 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
- * 2010-01-06 Bernard first version
- */
-
-#ifndef __RTGUI_ABOUT_VIEW_H__
-#define __RTGUI_ABOUT_VIEW_H__
-
-#include <rtgui/rtgui.h>
-#include <rtgui/image.h>
-#include <rtgui/rtgui_system.h>
-#include <rtgui/widgets/view.h>
-
-DECLARE_CLASS_TYPE(aboutview);
-/** Gets the type of a about view */
-#define RTGUI_ABOUT_VIEW_TYPE (RTGUI_TYPE(aboutview))
-/** Casts the object to a about view */
-#define RTGUI_ABOUT_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_ABOUT_VIEW_TYPE, rtgui_about_view_t))
-/** Checks if the object is a about view */
-#define RTGUI_IS_ABOUT_VIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_ABOUT_VIEW_TYPE))
-
-struct rtgui_about_view
-{
- struct rtgui_view parent;
-
- /* widget private data */
- rtgui_image_t* logo;
- const char* description;
-};
-typedef struct rtgui_about_view rtgui_about_view_t;
-
-rtgui_type_t *rtgui_about_view_type_get(void);
-
-rtgui_about_view_t* rtgui_about_view_create(rtgui_image_t *logo, const char* description);
-rt_bool_t rtgui_about_view_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
-
-#endif
+/* + * File : list_view.h + * This file is part of RTGUI in RT-Thread RTOS + * COPYRIGHT (C) 2010, 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 + * 2010-01-06 Bernard first version + */ + +#ifndef __RTGUI_ABOUT_VIEW_H__ +#define __RTGUI_ABOUT_VIEW_H__ + +#include <rtgui/rtgui.h> +#include <rtgui/image.h> +#include <rtgui/rtgui_system.h> +#include <rtgui/widgets/container.h> + +DECLARE_CLASS_TYPE(aboutview); +/** Gets the type of a about view */ +#define RTGUI_ABOUT_VIEW_TYPE (RTGUI_TYPE(aboutview)) +/** Casts the object to a about view */ +#define RTGUI_ABOUT_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_ABOUT_VIEW_TYPE, rtgui_about_view_t)) +/** Checks if the object is a about view */ +#define RTGUI_IS_ABOUT_VIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_ABOUT_VIEW_TYPE)) + +struct rtgui_about_view +{ + struct rtgui_container parent; + + /* widget private data */ + rtgui_image_t* logo; + const char* description; +}; +typedef struct rtgui_about_view rtgui_about_view_t; + +rtgui_about_view_t* rtgui_about_view_create(rtgui_image_t *logo, const char* description); +rt_bool_t rtgui_about_view_event_handler(struct rtgui_object* widget, struct rtgui_event* event); + +#endif diff --git a/components/rtgui/include/rtgui/widgets/box.h b/components/rtgui/include/rtgui/widgets/box.h index a58f07568e..0e0b814e8b 100644 --- a/components/rtgui/include/rtgui/widgets/box.h +++ b/components/rtgui/include/rtgui/widgets/box.h @@ -1,58 +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
-
-DECLARE_CLASS_TYPE(box);
-
-/** Gets the type of a box */
-#define RTGUI_BOX_TYPE (RTGUI_TYPE(box))
-/** 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 orient;
- rt_uint16_t border_size;
-};
-typedef struct rtgui_box rtgui_box_t;
-
-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
+/* + * 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 + +DECLARE_CLASS_TYPE(box); + +/** Gets the type of a box */ +#define RTGUI_BOX_TYPE (RTGUI_TYPE(box)) +/** 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 orient; + rt_uint16_t border_size; +}; +typedef struct rtgui_box rtgui_box_t; + +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/components/rtgui/include/rtgui/widgets/button.h b/components/rtgui/include/rtgui/widgets/button.h index cab0fcaf01..0d7678d358 100644 --- a/components/rtgui/include/rtgui/widgets/button.h +++ b/components/rtgui/include/rtgui/widgets/button.h @@ -1,81 +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
- * @{
- */
-
-DECLARE_CLASS_TYPE(button);
-
-/** Gets the type of a button */
-#define RTGUI_BUTTON_TYPE (RTGUI_TYPE(button))
-/** 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_button_t* rtgui_button_create(const char* text);
-rtgui_button_t* rtgui_pushbutton_create(const 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_set_onbutton(rtgui_button_t* btn, rtgui_onbutton_func_t func);
-
-rt_bool_t rtgui_button_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
-
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+/* + * 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 + * @{ + */ + +DECLARE_CLASS_TYPE(button); + +/** Gets the type of a button */ +#define RTGUI_BUTTON_TYPE (RTGUI_TYPE(button)) +/** 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_button_t* rtgui_button_create(const char* text); +rtgui_button_t* rtgui_pushbutton_create(const 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_set_onbutton(rtgui_button_t* btn, rtgui_onbutton_func_t func); + +rt_bool_t rtgui_button_event_handler(struct rtgui_object* object, struct rtgui_event* event); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/components/rtgui/include/rtgui/widgets/checkbox.h b/components/rtgui/include/rtgui/widgets/checkbox.h index 554a00d9f9..bf226e061e 100644 --- a/components/rtgui/include/rtgui/widgets/checkbox.h +++ b/components/rtgui/include/rtgui/widgets/checkbox.h @@ -1,43 +1,43 @@ -#ifndef __RTGUI_CHECKBOX_H__
-#define __RTGUI_CHECKBOX_H__
-
-#include <rtgui/rtgui.h>
-#include <rtgui/widgets/widget.h>
-#include <rtgui/widgets/label.h>
-
-DECLARE_CLASS_TYPE(checkbox);
-
-/** Gets the type of a checkbox */
-#define RTGUI_CHECKBOX_TYPE (RTGUI_TYPE(checkbox))
-/** Casts the object to an rtgui_button */
-#define RTGUI_CHECKBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_CHECKBOX_TYPE, rtgui_checkbox))
-/** Checks if the object is an rtgui_button */
-#define RTGUI_IS_CHECKBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_CHECKBOX_TYPE))
-
-#define RTGUI_CHECKBOX_STATUS_CHECKED 0
-#define RTGUI_CHECKBOX_STATUS_UNCHECKED 1
-
-struct rtgui_checkbox
-{
- /* inherit from label */
- struct rtgui_label parent;
-
- /* check box status */
- rt_uint8_t status_down;
-
- /* click button event handler */
- void (*on_button)(struct rtgui_widget* widget, rtgui_event_t *event);
-};
-typedef struct rtgui_checkbox rtgui_checkbox_t;
-
-rtgui_checkbox_t* rtgui_checkbox_create(const char* text, rt_bool_t checked);
-void rtgui_checkbox_destroy(rtgui_checkbox_t* checkbox);
-
-void rtgui_checkbox_set_checked(rtgui_checkbox_t* checkbox, rt_bool_t checked);
-rt_bool_t rtgui_checkbox_get_checked(rtgui_checkbox_t* checkbox);
-
-void rtgui_checkbox_set_onbutton(rtgui_checkbox_t* checkbox, rtgui_onbutton_func_t func);
-
-rt_bool_t rtgui_checkbox_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
-
-#endif
+#ifndef __RTGUI_CHECKBOX_H__ +#define __RTGUI_CHECKBOX_H__ + +#include <rtgui/rtgui.h> +#include <rtgui/widgets/widget.h> +#include <rtgui/widgets/label.h> + +DECLARE_CLASS_TYPE(checkbox); + +/** Gets the type of a checkbox */ +#define RTGUI_CHECKBOX_TYPE (RTGUI_TYPE(checkbox)) +/** Casts the object to an rtgui_button */ +#define RTGUI_CHECKBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_CHECKBOX_TYPE, struct rtgui_checkbox)) +/** Checks if the object is an rtgui_button */ +#define RTGUI_IS_CHECKBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_CHECKBOX_TYPE)) + +#define RTGUI_CHECKBOX_STATUS_CHECKED 0 +#define RTGUI_CHECKBOX_STATUS_UNCHECKED 1 + +struct rtgui_checkbox +{ + /* inherit from label */ + struct rtgui_label parent; + + /* check box status */ + rt_uint8_t status_down; + + /* click button event handler */ + void (*on_button)(struct rtgui_widget* widget, rtgui_event_t *event); +}; +typedef struct rtgui_checkbox rtgui_checkbox_t; + +rtgui_checkbox_t* rtgui_checkbox_create(const char* text, rt_bool_t checked); +void rtgui_checkbox_destroy(rtgui_checkbox_t* checkbox); + +void rtgui_checkbox_set_checked(rtgui_checkbox_t* checkbox, rt_bool_t checked); +rt_bool_t rtgui_checkbox_get_checked(rtgui_checkbox_t* checkbox); + +void rtgui_checkbox_set_onbutton(rtgui_checkbox_t* checkbox, rtgui_onbutton_func_t func); + +rt_bool_t rtgui_checkbox_event_handler(struct rtgui_object* object, struct rtgui_event* event); + +#endif diff --git a/components/rtgui/include/rtgui/widgets/combobox.h b/components/rtgui/include/rtgui/widgets/combobox.h index 2409d7fb5c..6be860b76b 100644 --- a/components/rtgui/include/rtgui/widgets/combobox.h +++ b/components/rtgui/include/rtgui/widgets/combobox.h @@ -1,49 +1,49 @@ -#ifndef __RTGUI_COMBOBOX_H__
-#define __RTGUI_COMBOBOX_H__
-
-#include <rtgui/rtgui.h>
-#include <rtgui/image.h>
-#include <rtgui/widgets/window.h>
-#include <rtgui/widgets/listbox.h>
-
-DECLARE_CLASS_TYPE(combobox);
-/** Gets the type of a combobox */
-#define RTGUI_COMBOBOX_TYPE (RTGUI_TYPE(combobox))
-/** Casts the object to a rtgui_combobox */
-#define RTGUI_COMBOBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_COMBOBOX_TYPE, rtgui_combobox_t))
-/** Checks if the object is a rtgui_combobox */
-#define RTGUI_IS_COMBOBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_COMBOBOX_TYPE))
-
-#define RTGUI_COMBOBOX_WIDTH 75
-#define RTGUI_COMBOBOX_HEIGHT 20
-#define RTGUI_COMBOBOX_BUTTON_WIDTH 18
-
-struct rtgui_combobox
-{
- struct rtgui_widget parent;
-
- /* widget private data */
-
- /* pull down window */
- struct rtgui_win* pd_win;
- rt_bool_t pd_pressed;
-
- /* combobox items */
- struct rtgui_listbox_item* items;
- rt_uint16_t items_count;
- rt_uint16_t current_item;
-
- /* call back */
- void (*on_selected) (struct rtgui_widget* widget, struct rtgui_event* event);
-};
-typedef struct rtgui_combobox rtgui_combobox_t;
-
-rtgui_combobox_t *rtgui_combobox_create(struct rtgui_listbox_item* items, rt_uint16_t counter, struct rtgui_rect* rect);
-void rtgui_combobox_destroy(rtgui_combobox_t* box);
-
-rt_bool_t rtgui_combobox_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
-struct rtgui_listbox_item* rtgui_combox_get_select(struct rtgui_combobox* box);
-
-void rtgui_combobox_set_onselected(struct rtgui_combobox* box, rtgui_onitem_func_t func);
-
-#endif
+#ifndef __RTGUI_COMBOBOX_H__ +#define __RTGUI_COMBOBOX_H__ + +#include <rtgui/rtgui.h> +#include <rtgui/image.h> +#include <rtgui/widgets/window.h> +#include <rtgui/widgets/listbox.h> + +DECLARE_CLASS_TYPE(combobox); +/** Gets the type of a combobox */ +#define RTGUI_COMBOBOX_TYPE (RTGUI_TYPE(combobox)) +/** Casts the object to a rtgui_combobox */ +#define RTGUI_COMBOBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_COMBOBOX_TYPE, rtgui_combobox_t)) +/** Checks if the object is a rtgui_combobox */ +#define RTGUI_IS_COMBOBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_COMBOBOX_TYPE)) + +#define RTGUI_COMBOBOX_WIDTH 75 +#define RTGUI_COMBOBOX_HEIGHT 20 +#define RTGUI_COMBOBOX_BUTTON_WIDTH 18 + +struct rtgui_combobox +{ + struct rtgui_widget parent; + + /* widget private data */ + + /* pull down window */ + struct rtgui_win* pd_win; + rt_bool_t pd_pressed; + + /* combobox items */ + struct rtgui_listbox_item* items; + rt_uint16_t items_count; + rt_uint16_t current_item; + + /* call back */ + rtgui_event_handler_ptr on_selected; +}; +typedef struct rtgui_combobox rtgui_combobox_t; + +rtgui_combobox_t *rtgui_combobox_create(struct rtgui_listbox_item* items, rt_uint16_t counter, struct rtgui_rect* rect); +void rtgui_combobox_destroy(rtgui_combobox_t* box); + +rt_bool_t rtgui_combobox_event_handler(struct rtgui_object* object, struct rtgui_event* event); +struct rtgui_listbox_item* rtgui_combox_get_select(struct rtgui_combobox* box); + +void rtgui_combobox_set_onselected(struct rtgui_combobox* box, rtgui_event_handler_ptr func); + +#endif diff --git a/components/rtgui/include/rtgui/widgets/container.h b/components/rtgui/include/rtgui/widgets/container.h index 09a79d71d6..57a92b432c 100644 --- a/components/rtgui/include/rtgui/widgets/container.h +++ b/components/rtgui/include/rtgui/widgets/container.h @@ -1,47 +1,68 @@ -/*
- * 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>
-
-DECLARE_CLASS_TYPE(container);
-/** Gets the type of a container */
-#define RTGUI_CONTAINER_TYPE (RTGUI_TYPE(container))
-/** 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;
-
- struct rtgui_widget* focused;
- rtgui_list_t children;
-};
-typedef struct rtgui_container rtgui_container_t;
-
-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
+/* + * 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> + +#ifdef __cplusplus +extern "C" { +#endif + +DECLARE_CLASS_TYPE(container); +/** Gets the type of a container */ +#define RTGUI_CONTAINER_TYPE (RTGUI_TYPE(container)) +/** Casts the object to an rtgui_container */ +#define RTGUI_CONTAINER(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_CONTAINER_TYPE, rtgui_container_t)) +/** Checks if the object is an rtgui_container */ +#define RTGUI_IS_CONTAINER(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_CONTAINER_TYPE)) + +/* + * the container widget + */ +struct rtgui_container +{ + struct rtgui_widget parent; + + rtgui_list_t children; +}; +typedef struct rtgui_container rtgui_container_t; + +rtgui_container_t* rtgui_container_create(void); +void rtgui_container_destroy(rtgui_container_t* container); + +rt_bool_t rtgui_container_event_handler(struct rtgui_object* widget, struct rtgui_event* event); + +#ifndef RTGUI_USING_SMALL_SIZE +struct rtgui_box; +void rtgui_container_set_box(struct rtgui_container* container, struct rtgui_box* box); +#endif + +void rtgui_container_hide(rtgui_container_t* container); + +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(struct rtgui_object* 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); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/components/rtgui/include/rtgui/widgets/filelist_view.h b/components/rtgui/include/rtgui/widgets/filelist_view.h index 6be873efc9..3ce9bbb195 100644 --- a/components/rtgui/include/rtgui/widgets/filelist_view.h +++ b/components/rtgui/include/rtgui/widgets/filelist_view.h @@ -1,57 +1,58 @@ -#ifndef __RTGUI_FILELIST_VIEW_H__
-#define __RTGUI_FILELIST_VIEW_H__
-
-#include <rtgui/widgets/view.h>
-
-#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
-#define RTGUI_FITEM_FILE 0x0
-#define RTGUI_FITEM_DIR 0x1
-struct rtgui_file_item
-{
- char* name;
-
- rt_uint32_t type;
- rt_uint32_t size;
-};
-
-DECLARE_CLASS_TYPE(filelist);
-/** Gets the type of a filelist view */
-#define RTGUI_FILELIST_VIEW_TYPE (RTGUI_TYPE(filelist))
-/** Casts the object to a filelist */
-#define RTGUI_FILELIST_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_FILELIST_VIEW_TYPE, rtgui_filelist_view_t))
-/** Checks if the object is a filelist view */
-#define RTGUI_IS_FILELIST_VIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_FILELIST_VIEW_TYPE))
-
-struct rtgui_filelist_view
-{
- struct rtgui_view parent;
-
- /* widget private data */
-
- /* current directory */
- char* current_directory;
- char* pattern;
-
- /* the number of item in a page */
- rt_uint16_t page_items;
- rt_uint16_t items_count;
-
- /* the selected item */
- rt_uint16_t current_item;
-
- /* items array */
- struct rtgui_file_item *items;
-};
-typedef struct rtgui_filelist_view rtgui_filelist_view_t;
-
-rtgui_filelist_view_t* rtgui_filelist_view_create(rtgui_workbench_t* workbench,
- const char* directory, const char* pattern, const rtgui_rect_t* rect);
-void rtgui_filelist_view_destroy(rtgui_filelist_view_t* view);
-
-rt_bool_t rtgui_filelist_view_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
-void rtgui_filelist_view_set_directory(rtgui_filelist_view_t* view, const char* directory);
-
-void rtgui_filelist_view_get_fullpath(rtgui_filelist_view_t* view, char* path, rt_size_t len);
-#endif
-
-#endif
+#ifndef __RTGUI_FILELIST_VIEW_H__ +#define __RTGUI_FILELIST_VIEW_H__ + +#include <rtgui/widgets/container.h> + +#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) +#define RTGUI_FITEM_FILE 0x0 +#define RTGUI_FITEM_DIR 0x1 +struct rtgui_file_item +{ + char* name; + + rt_uint32_t type; + rt_uint32_t size; +}; + +DECLARE_CLASS_TYPE(filelist); +/** Gets the type of a filelist view */ +#define RTGUI_FILELIST_VIEW_TYPE (RTGUI_TYPE(filelist)) +/** Casts the object to a filelist */ +#define RTGUI_FILELIST_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_FILELIST_VIEW_TYPE, rtgui_filelist_view_t)) +/** Checks if the object is a filelist view */ +#define RTGUI_IS_FILELIST_VIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_FILELIST_VIEW_TYPE)) + +struct rtgui_filelist_view +{ + struct rtgui_container parent; + + /* widget private data */ + + /* current directory */ + char* current_directory; + char* pattern; + + /* the number of item in a page */ + rt_uint16_t page_items; + rt_uint16_t items_count; + + /* the selected item */ + rt_uint16_t current_item; + + /* items array */ + struct rtgui_file_item *items; +}; +typedef struct rtgui_filelist_view rtgui_filelist_view_t; + +rtgui_filelist_view_t* rtgui_filelist_view_create(const char* directory, + const char* pattern, + const rtgui_rect_t* rect); +void rtgui_filelist_view_destroy(rtgui_filelist_view_t* view); + +rt_bool_t rtgui_filelist_view_event_handler(struct rtgui_widget* widget, struct rtgui_event* event); +void rtgui_filelist_view_set_directory(rtgui_filelist_view_t* view, const char* directory); + +void rtgui_filelist_view_get_fullpath(rtgui_filelist_view_t* view, char* path, rt_size_t len); +#endif + +#endif diff --git a/components/rtgui/include/rtgui/widgets/iconbox.h b/components/rtgui/include/rtgui/widgets/iconbox.h index 9ce5fee57c..17545951d5 100644 --- a/components/rtgui/include/rtgui/widgets/iconbox.h +++ b/components/rtgui/include/rtgui/widgets/iconbox.h @@ -1,55 +1,55 @@ -/*
- * 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>
-
-DECLARE_CLASS_TYPE(iconbox);
-/** Gets the type of a iconbox */
-#define RTGUI_ICONBOX_TYPE (RTGUI_TYPE(iconbox))
-/** 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;
-
- char *text;
- rt_ubase_t text_position;
-
- rt_bool_t selected;
-};
-typedef struct rtgui_iconbox rtgui_iconbox_t;
-
-struct rtgui_iconbox* rtgui_iconbox_create(struct rtgui_image* image, const 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
+/* + * 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> + +DECLARE_CLASS_TYPE(iconbox); +/** Gets the type of a iconbox */ +#define RTGUI_ICONBOX_TYPE (RTGUI_TYPE(iconbox)) +/** 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; + + char *text; + rt_ubase_t text_position; + + rt_bool_t selected; +}; +typedef struct rtgui_iconbox rtgui_iconbox_t; + +struct rtgui_iconbox* rtgui_iconbox_create(struct rtgui_image* image, const char* text, int position); +void rtgui_iconbox_destroy(struct rtgui_iconbox* iconbox); + +rt_bool_t rtgui_iconbox_event_handler(struct rtgui_object* object, struct rtgui_event* event); + +void rtgui_iconbox_set_text_position(struct rtgui_iconbox* iconbox, int position); + +#endif diff --git a/components/rtgui/include/rtgui/widgets/label.h b/components/rtgui/include/rtgui/widgets/label.h index e19c15984d..be75e3957d 100644 --- a/components/rtgui/include/rtgui/widgets/label.h +++ b/components/rtgui/include/rtgui/widgets/label.h @@ -1,49 +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>
-
-DECLARE_CLASS_TYPE(label);
-
-/** Gets the type of a button */
-#define RTGUI_LABEL_TYPE (RTGUI_TYPE(label))
-/** 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 */
- char* text;
-};
-typedef struct rtgui_label rtgui_label_t;
-
-rtgui_label_t* rtgui_label_create(const 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 char* text);
-char* rtgui_label_get_text(rtgui_label_t* label);
-
-#endif
+/* + * 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> + +DECLARE_CLASS_TYPE(label); + +/** Gets the type of a button */ +#define RTGUI_LABEL_TYPE (RTGUI_TYPE(label)) +/** 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 */ + char* text; +}; +typedef struct rtgui_label rtgui_label_t; + +rtgui_label_t* rtgui_label_create(const char* text); +void rtgui_label_destroy(rtgui_label_t* label); + +rt_bool_t rtgui_label_event_handler(struct rtgui_object* object, struct rtgui_event* event); + +void rtgui_label_set_text(rtgui_label_t* label, const char* text); +char* rtgui_label_get_text(rtgui_label_t* label); + +#endif diff --git a/components/rtgui/include/rtgui/widgets/list_view.h b/components/rtgui/include/rtgui/widgets/list_view.h index 28792366c8..7f03098bc2 100644 --- a/components/rtgui/include/rtgui/widgets/list_view.h +++ b/components/rtgui/include/rtgui/widgets/list_view.h @@ -1,78 +1,76 @@ -/*
- * File : list_view.h
- * This file is part of RTGUI in RT-Thread RTOS
- * COPYRIGHT (C) 2010, 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
- * 2010-01-06 Bernard first version
- */
-
-#ifndef __RTGUI_LIST_VIEW_H__
-#define __RTGUI_LIST_VIEW_H__
-
-#include <rtgui/rtgui.h>
-#include <rtgui/image.h>
-#include <rtgui/rtgui_system.h>
-
-#include <rtgui/widgets/view.h>
-
-typedef void (*item_action)(struct rtgui_widget* widget, void* parameter);
-struct rtgui_list_item
-{
- char* name;
- rtgui_image_t *image;
-
- item_action action;
- void *parameter;
-};
-
-DECLARE_CLASS_TYPE(listview);
-/** Gets the type of a list view */
-#define RTGUI_LIST_VIEW_TYPE (RTGUI_TYPE(listview))
-/** Casts the object to a filelist */
-#define RTGUI_LIST_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LIST_VIEW_TYPE, rtgui_list_view_t))
-/** Checks if the object is a filelist view */
-#define RTGUI_IS_LIST_VIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LIST_VIEW_TYPE))
-
-#define RTGUI_LIST_VIEW_LIST 0x00
-#define RTGUI_LIST_VIEW_ICON 0x01
-#define RTGUI_LIST_VIEW_REPORT 0x02
-
-struct rtgui_list_view
-{
- struct rtgui_view parent;
-
- /* widget private data */
- /* list item */
- const struct rtgui_list_item* items;
-
- /* layout flag */
- rt_uint16_t flag;
-
- /* total number of items */
- rt_uint16_t items_count;
- /* the number of item in a page */
- rt_uint16_t page_items;
- /* current item */
- rt_int16_t current_item;
-
- /* icon layout */
- rt_uint8_t row_items, col_items;
-};
-typedef struct rtgui_list_view rtgui_list_view_t;
-
-rtgui_type_t *rtgui_list_view_type_get(void);
-
-rtgui_list_view_t* rtgui_list_view_create(const struct rtgui_list_item* items, rt_uint16_t count,
- rtgui_rect_t *rect, rt_uint16_t flag);
-void rtgui_list_view_destroy(rtgui_list_view_t* view);
-
-rt_bool_t rtgui_list_view_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
-
-#endif
-
+/* + * File : list_view.h + * This file is part of RTGUI in RT-Thread RTOS + * COPYRIGHT (C) 2010, 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 + * 2010-01-06 Bernard first version + */ + +#ifndef __RTGUI_LIST_VIEW_H__ +#define __RTGUI_LIST_VIEW_H__ + +#include <rtgui/rtgui.h> +#include <rtgui/image.h> +#include <rtgui/rtgui_system.h> + +#include <rtgui/widgets/container.h> + +typedef void (*item_action)(struct rtgui_widget* widget, void* parameter); +struct rtgui_list_item +{ + char* name; + rtgui_image_t *image; + + item_action action; + void *parameter; +}; + +DECLARE_CLASS_TYPE(listview); +/** Gets the type of a list view */ +#define RTGUI_LIST_VIEW_TYPE (RTGUI_TYPE(listview)) +/** Casts the object to a filelist */ +#define RTGUI_LIST_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LIST_VIEW_TYPE, rtgui_list_view_t)) +/** Checks if the object is a filelist view */ +#define RTGUI_IS_LIST_VIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LIST_VIEW_TYPE)) + +#define RTGUI_LIST_VIEW_LIST 0x00 +#define RTGUI_LIST_VIEW_ICON 0x01 +#define RTGUI_LIST_VIEW_REPORT 0x02 + +struct rtgui_list_view +{ + struct rtgui_container parent; + + /* widget private data */ + /* list item */ + const struct rtgui_list_item* items; + + /* layout flag */ + rt_uint16_t flag; + + /* total number of items */ + rt_uint16_t items_count; + /* the number of item in a page */ + rt_uint16_t page_items; + /* current item */ + rt_uint16_t current_item; + + /* icon layout */ + rt_uint8_t row_items, col_items; +}; +typedef struct rtgui_list_view rtgui_list_view_t; + +rtgui_list_view_t* rtgui_list_view_create(const struct rtgui_list_item* items, rt_uint16_t count, + rtgui_rect_t *rect, rt_uint16_t flag); +void rtgui_list_view_destroy(rtgui_list_view_t* view); + +rt_bool_t rtgui_list_view_event_handler(struct rtgui_object* widget, struct rtgui_event* event); + +#endif + diff --git a/components/rtgui/include/rtgui/widgets/listbox.h b/components/rtgui/include/rtgui/widgets/listbox.h index 8eb10206c7..cb38802d53 100644 --- a/components/rtgui/include/rtgui/widgets/listbox.h +++ b/components/rtgui/include/rtgui/widgets/listbox.h @@ -1,68 +1,67 @@ -/*
- * File : listbox.h
- * This file is part of RTGUI in RT-Thread RTOS
- * COPYRIGHT (C) 2010, 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
- * 2010-01-06 Bernard first version
- */
-
-#ifndef __RTGUI_LISTBOX_H__
-#define __RTGUI_LISTBOX_H__
-
-#include <rtgui/rtgui.h>
-#include <rtgui/image.h>
-#include <rtgui/rtgui_system.h>
-#include <rtgui/widgets/widget.h>
-
-struct rtgui_listbox_item
-{
- char* name;
- rtgui_image_t *image;
-};
-
-DECLARE_CLASS_TYPE(listbox);
-/** Gets the type of a list box */
-#define RTGUI_LISTBOX_TYPE (RTGUI_TYPE(listbox))
-/** Casts the object to a filelist */
-#define RTGUI_LISTBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LISTBOX_TYPE, rtgui_listbox_t))
-/** Checks if the object is a filelist box */
-#define RTGUI_IS_LISTBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LISTBOX_TYPE))
-
-struct rtgui_listbox
-{
- struct rtgui_widget parent;
-
- /* widget private data */
- /* listbox item */
- const struct rtgui_listbox_item* items;
-
- /* item event handler */
- void (*on_item)(rtgui_widget_t *widgets, struct rtgui_event* event);
-
- /* total number of items */
- rt_uint16_t items_count;
- /* the number of item in a page */
- rt_uint16_t page_items;
- /* current item */
- rt_int16_t current_item;
-};
-typedef struct rtgui_listbox rtgui_listbox_t;
-typedef void (*rtgui_onitem_func_t)(struct rtgui_widget* widget, rtgui_event_t *event);
-
-rtgui_listbox_t* rtgui_listbox_create(const struct rtgui_listbox_item* items, rt_uint16_t count,
- rtgui_rect_t *rect);
-void rtgui_listbox_destroy(rtgui_listbox_t* box);
-
-rt_bool_t rtgui_listbox_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
-void rtgui_listbox_set_onitem(rtgui_listbox_t* box, rtgui_onitem_func_t func);
-void rtgui_listbox_set_items(rtgui_listbox_t* box, struct rtgui_listbox_item* items, rt_uint16_t count);
-void rtgui_listbox_set_current_item(rtgui_listbox_t* box, int index);
-
-#endif
-
+/* + * File : listbox.h + * This file is part of RTGUI in RT-Thread RTOS + * COPYRIGHT (C) 2010, 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 + * 2010-01-06 Bernard first version + */ + +#ifndef __RTGUI_LISTBOX_H__ +#define __RTGUI_LISTBOX_H__ + +#include <rtgui/rtgui.h> +#include <rtgui/image.h> +#include <rtgui/rtgui_system.h> +#include <rtgui/widgets/widget.h> + +struct rtgui_listbox_item +{ + char* name; + rtgui_image_t *image; +}; + +DECLARE_CLASS_TYPE(listbox); +/** Gets the type of a list box */ +#define RTGUI_LISTBOX_TYPE (RTGUI_TYPE(listbox)) +/** Casts the object to a filelist */ +#define RTGUI_LISTBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LISTBOX_TYPE, rtgui_listbox_t)) +/** Checks if the object is a filelist box */ +#define RTGUI_IS_LISTBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LISTBOX_TYPE)) + +struct rtgui_listbox +{ + struct rtgui_widget parent; + + /* widget private data */ + /* listbox item */ + const struct rtgui_listbox_item* items; + + /* item event handler */ + rtgui_event_handler_ptr on_item; + + /* total number of items */ + rt_uint16_t items_count; + /* the number of item in a page */ + rt_uint16_t page_items; + /* current item */ + rt_int16_t current_item; +}; +typedef struct rtgui_listbox rtgui_listbox_t; + +rtgui_listbox_t* rtgui_listbox_create(const struct rtgui_listbox_item* items, rt_uint16_t count, + rtgui_rect_t *rect); +void rtgui_listbox_destroy(rtgui_listbox_t* box); + +rt_bool_t rtgui_listbox_event_handler(struct rtgui_object* object, struct rtgui_event* event); +void rtgui_listbox_set_onitem(rtgui_listbox_t* box, rtgui_event_handler_ptr func); +void rtgui_listbox_set_items(rtgui_listbox_t* box, struct rtgui_listbox_item* items, rt_uint16_t count); +void rtgui_listbox_set_current_item(rtgui_listbox_t* box, int index); + +#endif + diff --git a/components/rtgui/include/rtgui/widgets/listctrl.h b/components/rtgui/include/rtgui/widgets/listctrl.h index ad3bb924cb..d3f9ce703d 100644 --- a/components/rtgui/include/rtgui/widgets/listctrl.h +++ b/components/rtgui/include/rtgui/widgets/listctrl.h @@ -1,66 +1,63 @@ -/*
- * File : listctrl.h
- * This file is part of RTGUI in RT-Thread RTOS
- * COPYRIGHT (C) 2010, 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
- * 2010-12-06 Bernard first version
- */
-
-#ifndef __RTGUI_LISTCTRL_H__
-#define __RTGUI_LISTCTRL_H__
-
-#include <rtgui/rtgui.h>
-#include <rtgui/image.h>
-#include <rtgui/rtgui_system.h>
-#include <rtgui/widgets/widget.h>
-
-DECLARE_CLASS_TYPE(listctrl);
-/** Gets the type of a listctrl */
-#define RTGUI_LISTCTRL_TYPE (RTGUI_TYPE(listctrl))
-/** Casts the object to a listctrl */
-#define RTGUI_LISTCTRL(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LISTCTRL_TYPE, rtgui_listctrl_t))
-/** Checks if the object is a listctrl */
-#define RTGUI_IS_LISTCTRL(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LISTCTRL_TYPE))
-
-struct rtgui_listctrl
-{
- struct rtgui_widget parent;
-
- /* widget private data */
- /* listctrl items */
- rt_uint32_t items;
-
- /* total number of items */
- rt_uint16_t items_count;
- /* the number of item in a page */
- rt_uint16_t page_items;
- /* current item */
- rt_int16_t current_item;
-
- /* item event handler */
- void (*on_item)(rtgui_widget_t *widget, struct rtgui_event* event);
- void (*on_item_draw)(struct rtgui_listctrl *list, struct rtgui_dc* dc, rtgui_rect_t* rect, rt_uint16_t index);
-};
-typedef struct rtgui_listctrl rtgui_listctrl_t;
-
-typedef void (*rtgui_onitem_func_t)(struct rtgui_widget* widget, rtgui_event_t *event);
-typedef void (*rtgui_onitem_draw_t)(struct rtgui_listctrl *list, struct rtgui_dc* dc, rtgui_rect_t* rect, rt_uint16_t index);
-
-rtgui_type_t *rtgui_listctrl_type_get(void);
-
-rtgui_listctrl_t* rtgui_listctrl_create(rt_uint32_t items, rt_uint16_t count,
- rtgui_rect_t *rect, rtgui_onitem_draw_t ondraw);
-void rtgui_listctrl_destroy(rtgui_listctrl_t* ctrl);
-
-rt_bool_t rtgui_listctrl_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
-void rtgui_listctrl_set_onitem(rtgui_listctrl_t* ctrl, rtgui_onitem_func_t func);
-void rtgui_listctrl_set_items(rtgui_listctrl_t* ctrl, rt_uint32_t items, rt_uint16_t count);
-rt_bool_t rtgui_listctrl_get_item_rect(rtgui_listctrl_t* ctrl, rt_uint16_t item, rtgui_rect_t* item_rect);
-
-#endif
+/* + * File : listctrl.h + * This file is part of RTGUI in RT-Thread RTOS + * COPYRIGHT (C) 2010, 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 + * 2010-12-06 Bernard first version + */ + +#ifndef __RTGUI_LISTCTRL_H__ +#define __RTGUI_LISTCTRL_H__ + +#include <rtgui/rtgui.h> +#include <rtgui/image.h> +#include <rtgui/rtgui_system.h> +#include <rtgui/widgets/widget.h> + +DECLARE_CLASS_TYPE(listctrl); +/** Gets the type of a listctrl */ +#define RTGUI_LISTCTRL_TYPE (RTGUI_TYPE(listctrl)) +/** Casts the object to a listctrl */ +#define RTGUI_LISTCTRL(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LISTCTRL_TYPE, rtgui_listctrl_t)) +/** Checks if the object is a listctrl */ +#define RTGUI_IS_LISTCTRL(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LISTCTRL_TYPE)) + +struct rtgui_listctrl +{ + struct rtgui_widget parent; + + /* widget private data */ + /* listctrl items */ + rt_uint32_t items; + + /* total number of items */ + rt_uint16_t items_count; + /* the number of item in a page */ + rt_uint16_t page_items; + /* current item */ + rt_int16_t current_item; + + /* item event handler */ + rtgui_event_handler_ptr on_item; + void (*on_item_draw)(struct rtgui_listctrl *list, struct rtgui_dc* dc, rtgui_rect_t* rect, rt_uint16_t index); +}; +typedef struct rtgui_listctrl rtgui_listctrl_t; + +typedef void (*rtgui_onitem_draw_t)(struct rtgui_listctrl *list, struct rtgui_dc* dc, rtgui_rect_t* rect, rt_uint16_t index); + +rtgui_listctrl_t* rtgui_listctrl_create(rt_uint32_t items, rt_uint16_t count, + rtgui_rect_t *rect, rtgui_onitem_draw_t ondraw); +void rtgui_listctrl_destroy(rtgui_listctrl_t* ctrl); + +rt_bool_t rtgui_listctrl_event_handler(struct rtgui_object* object, struct rtgui_event* event); +void rtgui_listctrl_set_onitem(rtgui_listctrl_t* ctrl, rtgui_event_handler_ptr func); +void rtgui_listctrl_set_items(rtgui_listctrl_t* ctrl, rt_uint32_t items, rt_uint16_t count); +rt_bool_t rtgui_listctrl_get_item_rect(rtgui_listctrl_t* ctrl, rt_uint16_t item, rtgui_rect_t* item_rect); + +#endif diff --git a/components/rtgui/include/rtgui/widgets/menu.h b/components/rtgui/include/rtgui/widgets/menu.h index 629fb84e46..ba620d3c74 100644 --- a/components/rtgui/include/rtgui/widgets/menu.h +++ b/components/rtgui/include/rtgui/widgets/menu.h @@ -1,80 +1,78 @@ -#ifndef __RTGUI_MENU_H__
-#define __RTGUI_MENU_H__
-
-#include <rtgui/image.h>
-#include <rtgui/widgets/window.h>
-#include <rtgui/widgets/listctrl.h>
-
-/* rtgui menu item */
-enum rtgui_menu_item_type
-{
- RTGUI_ITEM_NORMAL,
- RTGUI_ITEM_CHECK,
- RTGUI_ITEM_SUBMENU,
- RTGUI_ITEM_SEPARATOR
-};
-typedef enum rtgui_menu_item_type rtgui_menu_item_type_t;
-
-struct rtgui_menu_item
-{
- rtgui_menu_item_type_t type;
-
- /* menu text label */
- const char* label;
- /* menu image */
- rtgui_image_t *image;
-
- /* sub-menu item */
- const struct rtgui_menu_item_t *submenu;
- rt_uint16_t submenu_count;
-
- /* menu action */
- rt_bool_t (*on_menuaction)(rtgui_widget_t* widget, rtgui_event_t* event);
-};
-typedef struct rtgui_menu_item rtgui_menu_item_t;
-
-DECLARE_CLASS_TYPE(menu);
-/** Gets the type of a menu */
-#define RTGUI_MENU_TYPE (RTGUI_TYPE(menu))
-/** Casts the object to an rtgui_menu */
-#define RTGUI_MENU(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_MENU_TYPE, rtgui_menu_t))
-/** Checks if the object is an rtgui_menu */
-#define RTGUI_IS_MENU(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_MENU_TYPE))
-
-#define RTGUI_MENU_DEFAULT_WIDTH 100
-struct rtgui_menu
-{
- /* inherited from window */
- struct rtgui_win parent;
-
- /* menu items */
- const struct rtgui_menu_item *items;
- rt_uint16_t items_count;
-
- /* parent menu */
- struct rtgui_menu *parent_menu;
- struct rtgui_menu *sub_menu;
-
- /* menu item list control */
- struct rtgui_listctrl *items_list;
-
- /* pop event handle */
- rt_bool_t (*on_menupop)(rtgui_widget_t* widget, rtgui_event_t* event);
- rt_bool_t (*on_menuhide)(rtgui_widget_t* widget, rtgui_event_t* event);
-};
-typedef struct rtgui_menu rtgui_menu_t;
-
-rtgui_type_t *rtgui_menu_type_get(void);
-
-struct rtgui_menu* rtgui_menu_create(const char* title, struct rtgui_menu* parent_menu,
- const struct rtgui_menu_item* items, rt_uint16_t count);
-void rtgui_menu_destroy(struct rtgui_menu* menu);
-
-void rtgui_menu_set_onmenupop(struct rtgui_menu* menu, rtgui_event_handler_ptr handler);
-void rtgui_menu_set_onmenuhide(struct rtgui_menu* menu, rtgui_event_handler_ptr handler);
-
-void rtgui_menu_pop(struct rtgui_menu* menu, int x, int y);
-void rtgui_menu_hiden(struct rtgui_menu* menu);
-
-#endif
-
+#ifndef __RTGUI_MENU_H__ +#define __RTGUI_MENU_H__ + +#include <rtgui/image.h> +#include <rtgui/widgets/window.h> +#include <rtgui/widgets/listctrl.h> + +/* rtgui menu item */ +enum rtgui_menu_item_type +{ + RTGUI_ITEM_NORMAL, + RTGUI_ITEM_CHECK, + RTGUI_ITEM_SUBMENU, + RTGUI_ITEM_SEPARATOR +}; +typedef enum rtgui_menu_item_type rtgui_menu_item_type_t; + +struct rtgui_menu_item +{ + rtgui_menu_item_type_t type; + + /* menu text label */ + const char* label; + /* menu image */ + rtgui_image_t *image; + + /* sub-menu item */ + const struct rtgui_menu_item_t *submenu; + rt_uint16_t submenu_count; + + /* menu action */ + rt_bool_t (*on_menuaction)(rtgui_widget_t* widget, rtgui_event_t* event); +}; +typedef struct rtgui_menu_item rtgui_menu_item_t; + +DECLARE_CLASS_TYPE(menu); +/** Gets the type of a menu */ +#define RTGUI_MENU_TYPE (RTGUI_TYPE(menu)) +/** Casts the object to an rtgui_menu */ +#define RTGUI_MENU(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_MENU_TYPE, rtgui_menu_t)) +/** Checks if the object is an rtgui_menu */ +#define RTGUI_IS_MENU(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_MENU_TYPE)) + +#define RTGUI_MENU_DEFAULT_WIDTH 100 +struct rtgui_menu +{ + /* inherited from window */ + struct rtgui_win parent; + + /* menu items */ + const struct rtgui_menu_item *items; + rt_uint16_t items_count; + + /* parent menu */ + struct rtgui_menu *parent_menu; + struct rtgui_menu *sub_menu; + + /* menu item list control */ + struct rtgui_listctrl *items_list; + + /* pop event handle */ + rtgui_event_handler_ptr on_menupop; + rtgui_event_handler_ptr on_menuhide; +}; +typedef struct rtgui_menu rtgui_menu_t; + +struct rtgui_menu* rtgui_menu_create(const char* title, struct rtgui_menu* parent_menu, + const struct rtgui_menu_item* items, rt_uint16_t count); +void rtgui_menu_destroy(struct rtgui_menu* menu); + +void rtgui_menu_set_onmenupop(struct rtgui_menu* menu, rtgui_event_handler_ptr handler); +void rtgui_menu_set_onmenuhide(struct rtgui_menu* menu, rtgui_event_handler_ptr handler); + +void rtgui_menu_pop(struct rtgui_menu* menu, int x, int y); +void rtgui_menu_hiden(struct rtgui_menu* menu); + +#endif + diff --git a/components/rtgui/include/rtgui/widgets/notebook.h b/components/rtgui/include/rtgui/widgets/notebook.h index e14c895647..92fb9e6c4d 100644 --- a/components/rtgui/include/rtgui/widgets/notebook.h +++ b/components/rtgui/include/rtgui/widgets/notebook.h @@ -1,53 +1,49 @@ -#ifndef __RTGUI_NOTEBOOK_H__
-#define __RTGUI_NOTEBOOK_H__
-
-#include <rtgui/rtgui.h>
-#include <rtgui/widgets/container.h>
-
-DECLARE_CLASS_TYPE(notebook);
-/** Gets the type of a notebook */
-#define RTGUI_NOTEBOOK_TYPE (RTGUI_TYPE(notebook))
-/** Casts the object to a notebook control */
-#define RTGUI_NOTEBOOK(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_NOTEBOOK_TYPE, rtgui_notebook_t))
-/** Checks if the object is a notebook control */
-#define RTGUI_IS_NOTEBOOK(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_NOTEBOOK_TYPE))
-
-#define RTGUI_NOTEBOOK_TOP 0x00
-#define RTGUI_NOTEBOOK_BOTTOM 0x01
-#define RTGUI_NOTEBOOK_NOTAB 0x02
-
-struct rtgui_notebook_tab
-{
- char* title;
- struct rtgui_widget* widget;
-};
-typedef struct rtgui_notebook_tab rtgui_notebook_tab_t;
-
-struct rtgui_notebook
-{
- struct rtgui_container parent;
-
- rt_uint8_t flag;
-
- /* widget private data */
- rtgui_notebook_tab_t* childs;
- rt_uint16_t count;
- rt_int16_t current;
-};
-typedef struct rtgui_notebook rtgui_notebook_t;
-
-rtgui_type_t *rtgui_notebook_type_get(void);
-
-rtgui_notebook_t* rtgui_notebook_create(const rtgui_rect_t* rect, rt_uint8_t style);
-void rtgui_notebook_destroy(rtgui_notebook_t* notebook);
-
-void rtgui_notebook_add(rtgui_notebook_t* notebook, const char* label, rtgui_widget_t* child);
-int rtgui_notebook_get_count(rtgui_notebook_t* notebook);
-rtgui_widget_t* rtgui_notebook_get_current(rtgui_notebook_t* notebook);
-void rtgui_notebook_set_current(rtgui_notebook_t* notebook, rtgui_widget_t* widget);
-void rtgui_notebook_set_current_by_index(rtgui_notebook_t* notebook, rt_uint16_t index);
-rtgui_widget_t* rtgui_notebook_get_index(rtgui_notebook_t* notebook, rt_uint16_t index);
-
-rt_bool_t rtgui_notebook_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
-
-#endif
+#ifndef __RTGUI_NOTEBOOK_H__ +#define __RTGUI_NOTEBOOK_H__ + +#include <rtgui/rtgui.h> +#include <rtgui/widgets/widget.h> + +DECLARE_CLASS_TYPE(notebook); +/** Gets the type of a notebook */ +#define RTGUI_NOTEBOOK_TYPE (RTGUI_TYPE(notebook)) +/** Casts the object to a notebook control */ +#define RTGUI_NOTEBOOK(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_NOTEBOOK_TYPE, struct rtgui_notebook)) +/** Checks if the object is a notebook control */ +#define RTGUI_IS_NOTEBOOK(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_NOTEBOOK_TYPE)) + +#define RTGUI_NOTEBOOK_TOP 0x00 +#define RTGUI_NOTEBOOK_BOTTOM 0x01 +#define RTGUI_NOTEBOOK_NOTAB 0x02 + +struct rtgui_notebook_tab; + +struct rtgui_notebook +{ + struct rtgui_widget parent; + + rt_uint8_t flag; + + /* widget private data */ + struct rtgui_notebook_tab *childs; + rt_uint16_t count; + rt_int16_t current; +}; + +struct rtgui_notebook* rtgui_notebook_create(const rtgui_rect_t* rect, rt_uint8_t style); +void rtgui_notebook_destroy(struct rtgui_notebook* notebook); + +void rtgui_notebook_add(struct rtgui_notebook* notebook, const char* label, struct rtgui_widget* child); +struct rtgui_widget* rtgui_notebook_get_current(struct rtgui_notebook* notebook); +rt_int16_t rtgui_notebook_get_current_index(struct rtgui_notebook* notebook); + +int rtgui_notebook_get_count(struct rtgui_notebook* notebook); + +void rtgui_notebook_set_current(struct rtgui_notebook* notebook, struct rtgui_widget* child); +void rtgui_notebook_set_current_by_index(struct rtgui_notebook* notebook, rt_uint16_t index); + +struct rtgui_widget* rtgui_notebook_get_widget_at(struct rtgui_notebook* notebook, rt_uint16_t index); + +rt_bool_t rtgui_notebook_event_handler(struct rtgui_object* widget, struct rtgui_event* event); + +#endif diff --git a/components/rtgui/include/rtgui/widgets/progressbar.h b/components/rtgui/include/rtgui/widgets/progressbar.h index ef2ccc9db5..08733c3496 100644 --- a/components/rtgui/include/rtgui/widgets/progressbar.h +++ b/components/rtgui/include/rtgui/widgets/progressbar.h @@ -1,40 +1,40 @@ -#ifndef __RTGUI_PROGRESSBAR_H__
-#define __RTGUI_PROGRESSBAR_H__
-
-#include <rtgui/rtgui.h>
-#include <rtgui/widgets/widget.h>
-
-DECLARE_CLASS_TYPE(progressbar);
-/** Gets the type of a progressbar */
-#define RTGUI_PROGRESSBAR_TYPE (RTGUI_TYPE(progressbar))
-/** Casts the object to a rtgui_progressbar */
-#define RTGUI_PROGRESSBAR(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_PROGRESSBAR_TYPE, rtgui_progressbar_t))
-/** Checks if the object is a rtgui_progressbar */
-#define RTGUI_IS_PROGRESSBAR(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_PROGRESSBAR_TYPE))
-
-#define DEFAULT_WIDTH 100
-#define DEFAULT_HEIGHT 20
-
-struct rtgui_progressbar
-{
- struct rtgui_widget parent;
-
- int orient;
-
- int range;
- int position;
-};
-typedef struct rtgui_progressbar rtgui_progressbar_t;
-
-struct rtgui_progressbar* rtgui_progressbar_create(int orientation, int range, rtgui_rect_t* r);
-void rtgui_progressbar_destroy(struct rtgui_progressbar* p_bar);
-
-rt_bool_t rtgui_progressbar_event_handler(struct rtgui_widget* widget,
- struct rtgui_event* event);
-
-void rtgui_progressbar_set_value(struct rtgui_progressbar *p_bar, int value);
-int rtgui_progressbar_get_value(struct rtgui_progressbar *p_bar);
-void rtgui_progressbar_set_range(struct rtgui_progressbar *p_bar, int range);
-int rtgui_progressbar_get_range(struct rtgui_progressbar *p_bar);
-
-#endif
+#ifndef __RTGUI_PROGRESSBAR_H__ +#define __RTGUI_PROGRESSBAR_H__ + +#include <rtgui/rtgui.h> +#include <rtgui/widgets/widget.h> + +DECLARE_CLASS_TYPE(progressbar); +/** Gets the type of a progressbar */ +#define RTGUI_PROGRESSBAR_TYPE (RTGUI_TYPE(progressbar)) +/** Casts the object to a rtgui_progressbar */ +#define RTGUI_PROGRESSBAR(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_PROGRESSBAR_TYPE, rtgui_progressbar_t)) +/** Checks if the object is a rtgui_progressbar */ +#define RTGUI_IS_PROGRESSBAR(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_PROGRESSBAR_TYPE)) + +#define DEFAULT_WIDTH 100 +#define DEFAULT_HEIGHT 20 + +struct rtgui_progressbar +{ + struct rtgui_widget parent; + + int orient; + + int range; + int position; +}; +typedef struct rtgui_progressbar rtgui_progressbar_t; + +struct rtgui_progressbar* rtgui_progressbar_create(int orientation, int range, rtgui_rect_t* r); +void rtgui_progressbar_destroy(struct rtgui_progressbar* p_bar); + +rt_bool_t rtgui_progressbar_event_handler(struct rtgui_object* object, + struct rtgui_event* event); + +void rtgui_progressbar_set_value(struct rtgui_progressbar *p_bar, int value); +int rtgui_progressbar_get_value(struct rtgui_progressbar *p_bar); +void rtgui_progressbar_set_range(struct rtgui_progressbar *p_bar, int range); +int rtgui_progressbar_get_range(struct rtgui_progressbar *p_bar); + +#endif diff --git a/components/rtgui/include/rtgui/widgets/radiobox.h b/components/rtgui/include/rtgui/widgets/radiobox.h index e0f68bfca0..2a53daa477 100644 --- a/components/rtgui/include/rtgui/widgets/radiobox.h +++ b/components/rtgui/include/rtgui/widgets/radiobox.h @@ -1,45 +1,45 @@ -#ifndef __RTGUI_RADIOBOX_H__
-#define __RTGUI_RADIOBOX_H__
-
-#include <rtgui/rtgui.h>
-#include <rtgui/widgets/widget.h>
-
-DECLARE_CLASS_TYPE(radiobox);
-/** Gets the type of a radiobox */
-#define RTGUI_RADIOBOX_TYPE (RTGUI_TYPE(radiobox))
-/** Casts the object to an rtgui_radiobox */
-#define RTGUI_RADIOBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_RADIOBOX_TYPE, rtgui_radiobox_t))
-/** Checks if the object is an rtgui_radiobox */
-#define RTGUI_IS_RADIOBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_RADIOBOX_TYPE))
-
-struct rtgui_radiobox
-{
- struct rtgui_widget parent;
-
- /* widget private data */
- char* text; /* radio box label */
-
- /* box orient */
- rt_uint8_t orient;
-
- /* item size */
- rt_uint8_t item_size;
-
- char** items;
- rt_uint16_t item_count;
- rt_int16_t item_selection;
-};
-typedef struct rtgui_radiobox rtgui_radiobox_t;
-
-struct rtgui_radiobox* rtgui_radiobox_create(const char* label, int orient, char** radio_items, int number);
-void rtgui_radiobox_destroy(struct rtgui_radiobox* radiobox);
-
-void rtgui_radiobox_set_selection(struct rtgui_radiobox* radiobox, int selection);
-int rtgui_radiobox_get_selection(struct rtgui_radiobox* radiobox);
-
-rt_bool_t rtgui_radiobox_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
-
-void rtgui_radiobox_set_orientation(struct rtgui_radiobox* radiobox, int orientation);
-
-#endif
-
+#ifndef __RTGUI_RADIOBOX_H__ +#define __RTGUI_RADIOBOX_H__ + +#include <rtgui/rtgui.h> +#include <rtgui/widgets/widget.h> + +DECLARE_CLASS_TYPE(radiobox); +/** Gets the type of a radiobox */ +#define RTGUI_RADIOBOX_TYPE (RTGUI_TYPE(radiobox)) +/** Casts the object to an rtgui_radiobox */ +#define RTGUI_RADIOBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_RADIOBOX_TYPE, rtgui_radiobox_t)) +/** Checks if the object is an rtgui_radiobox */ +#define RTGUI_IS_RADIOBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_RADIOBOX_TYPE)) + +struct rtgui_radiobox +{ + struct rtgui_widget parent; + + /* widget private data */ + char* text; /* radio box label */ + + /* box orient */ + rt_uint8_t orient; + + /* item size */ + rt_uint8_t item_size; + + char** items; + rt_uint16_t item_count; + rt_int16_t item_selection; +}; +typedef struct rtgui_radiobox rtgui_radiobox_t; + +struct rtgui_radiobox* rtgui_radiobox_create(const char* label, int orient, char** radio_items, int number); +void rtgui_radiobox_destroy(struct rtgui_radiobox* radiobox); + +void rtgui_radiobox_set_selection(struct rtgui_radiobox* radiobox, int selection); +int rtgui_radiobox_get_selection(struct rtgui_radiobox* radiobox); + +rt_bool_t rtgui_radiobox_event_handler(struct rtgui_object* object, struct rtgui_event* event); + +void rtgui_radiobox_set_orientation(struct rtgui_radiobox* radiobox, int orientation); + +#endif + diff --git a/components/rtgui/include/rtgui/widgets/scrollbar.h b/components/rtgui/include/rtgui/widgets/scrollbar.h index 8ae56aa8b1..a4e57b7204 100644 --- a/components/rtgui/include/rtgui/widgets/scrollbar.h +++ b/components/rtgui/include/rtgui/widgets/scrollbar.h @@ -1,89 +1,89 @@ -/*
- * File : scrollbar.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2010, 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
- * 2010-08-09 Bernard first version
- */
-#ifndef __RTGUI_SCROLLBAR_H__
-#define __RTGUI_SCROLLBAR_H__
-
-#include <rtgui/rtgui.h>
-#include <rtgui/widgets/widget.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-DECLARE_CLASS_TYPE(scrollbar);
-/** Gets the type of a scrollbar */
-#define RTGUI_SCROLLBAR_TYPE (RTGUI_TYPE(scrollbar))
-/** Casts the object to an rtgui_scrollbar */
-#define RTGUI_SCROLLBAR(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_SCROLLBAR_TYPE, rtgui_scrollbar_t))
-/** Checks if the object is an rtgui_scrollbar */
-#define RTGUI_IS_SCROLLBAR(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_SCROLLBAR_TYPE))
-
-#define RTGUI_DEFAULT_SB_WIDTH 100
-#define RTGUI_DEFAULT_SB_HEIGHT 16
-
-/* scrollbar status/positions*/
-#define SBS_UNKNOWN 0x0000
-#define SBS_LEFTARROW 0x0001
-#define SBS_RIGHTARROW 0x0002
-#define SBS_LEFTSPACE 0x0004
-#define SBS_RIGHTSPACE 0x0008
-#define SBS_HORZTHUMB 0x0010
-#define SBS_UPARROW 0x0020
-#define SBS_DOWNARROW 0x0040
-#define SBS_UPSPACE 0x0080
-#define SBS_DOWNSPACE 0x0100
-#define SBS_VERTTHUMB 0x0200
-
-struct rtgui_scrollbar
-{
- /* inherit from widget */
- struct rtgui_widget parent;
-
- rt_uint8_t orient;
- rt_uint8_t status;
-
- /* page_step = width of scrollbar */
- /* thumb size = line_step * page_step / (page_step - (button width * 2)) */
- rt_int16_t line_step, page_step;
-
- rt_int16_t thumb_position, thumb_size;
-
- /* position 1:1 width of scrollbar */
- rt_int16_t min_position, max_position;
-
- rt_bool_t (*on_scroll) (struct rtgui_widget* widget, struct rtgui_event* event);
-};
-typedef struct rtgui_scrollbar rtgui_scrollbar_t;
-
-struct rtgui_scrollbar* rtgui_scrollbar_create(int orient, rtgui_rect_t* r);
-void rtgui_scrollbar_destroy(struct rtgui_scrollbar* bar);
-
-void rtgui_scrollbar_get_thumb_rect(rtgui_scrollbar_t *bar, rtgui_rect_t *rect);
-
-void rtgui_scrollbar_set_range(struct rtgui_scrollbar* bar, int min, int max);
-rt_int16_t rtgui_scrollbar_get_value(struct rtgui_scrollbar* bar);
-void rtgui_scrollbar_set_value(struct rtgui_scrollbar* bar, rt_int16_t position);
-
-void rtgui_scrollbar_set_onscroll(struct rtgui_scrollbar* bar, rtgui_event_handler_ptr handler);
-void rtgui_scrollbar_set_orientation(struct rtgui_scrollbar* bar, int orientation);
-void rtgui_scrollbar_set_page_step(struct rtgui_scrollbar* bar, int step);
-void rtgui_scrollbar_set_line_step(struct rtgui_scrollbar* bar, int step);
-
-rt_bool_t rtgui_scrollbar_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+/* + * File : scrollbar.h + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2006 - 2010, 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 + * 2010-08-09 Bernard first version + */ +#ifndef __RTGUI_SCROLLBAR_H__ +#define __RTGUI_SCROLLBAR_H__ + +#include <rtgui/rtgui.h> +#include <rtgui/widgets/widget.h> + +#ifdef __cplusplus +extern "C" { +#endif + +DECLARE_CLASS_TYPE(scrollbar); +/** Gets the type of a scrollbar */ +#define RTGUI_SCROLLBAR_TYPE (RTGUI_TYPE(scrollbar)) +/** Casts the object to an rtgui_scrollbar */ +#define RTGUI_SCROLLBAR(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_SCROLLBAR_TYPE, rtgui_scrollbar_t)) +/** Checks if the object is an rtgui_scrollbar */ +#define RTGUI_IS_SCROLLBAR(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_SCROLLBAR_TYPE)) + +#define RTGUI_DEFAULT_SB_WIDTH 100 +#define RTGUI_DEFAULT_SB_HEIGHT 16 + +/* scrollbar status/positions*/ +#define SBS_UNKNOWN 0x0000 +#define SBS_LEFTARROW 0x0001 +#define SBS_RIGHTARROW 0x0002 +#define SBS_LEFTSPACE 0x0004 +#define SBS_RIGHTSPACE 0x0008 +#define SBS_HORZTHUMB 0x0010 +#define SBS_UPARROW 0x0020 +#define SBS_DOWNARROW 0x0040 +#define SBS_UPSPACE 0x0080 +#define SBS_DOWNSPACE 0x0100 +#define SBS_VERTTHUMB 0x0200 + +struct rtgui_scrollbar +{ + /* inherit from widget */ + struct rtgui_widget parent; + + rt_uint8_t orient; + rt_uint8_t status; + + /* page_step = width of scrollbar */ + /* thumb size = line_step * page_step / (page_step - (button width * 2)) */ + rt_int16_t line_step, page_step; + + rt_int16_t thumb_position, thumb_size; + + /* position 1:1 width of scrollbar */ + rt_int16_t min_position, max_position; + + rtgui_event_handler_ptr on_scroll; +}; +typedef struct rtgui_scrollbar rtgui_scrollbar_t; + +struct rtgui_scrollbar* rtgui_scrollbar_create(int orient, rtgui_rect_t* r); +void rtgui_scrollbar_destroy(struct rtgui_scrollbar* bar); + +void rtgui_scrollbar_get_thumb_rect(rtgui_scrollbar_t *bar, rtgui_rect_t *rect); + +void rtgui_scrollbar_set_range(struct rtgui_scrollbar* bar, int min, int max); +rt_int16_t rtgui_scrollbar_get_value(struct rtgui_scrollbar* bar); +void rtgui_scrollbar_set_value(struct rtgui_scrollbar* bar, rt_int16_t position); + +void rtgui_scrollbar_set_onscroll(struct rtgui_scrollbar* bar, rtgui_event_handler_ptr handler); +void rtgui_scrollbar_set_orientation(struct rtgui_scrollbar* bar, int orientation); +void rtgui_scrollbar_set_page_step(struct rtgui_scrollbar* bar, int step); +void rtgui_scrollbar_set_line_step(struct rtgui_scrollbar* bar, int step); + +rt_bool_t rtgui_scrollbar_event_handler(struct rtgui_object* object, struct rtgui_event* event); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/components/rtgui/include/rtgui/widgets/slider.h b/components/rtgui/include/rtgui/widgets/slider.h index 6b3bee28e2..2273177acc 100644 --- a/components/rtgui/include/rtgui/widgets/slider.h +++ b/components/rtgui/include/rtgui/widgets/slider.h @@ -1,53 +1,53 @@ -/*
- * File : slider.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_SLIDER_H__
-#define __RTGUI_SLIDER_H__
-
-#include <rtgui/rtgui.h>
-#include <rtgui/widgets/widget.h>
-
-DECLARE_CLASS_TYPE(slider);
-/** Gets the type of a slider */
-#define RTGUI_SLIDER_TYPE (RTGUI_TYPE(slider))
-/** Casts the object to an rtgui_slider */
-#define RTGUI_SLIDER(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_SLIDER_TYPE, rtgui_slider_t))
-/** Checks if the object is an rtgui_slider */
-#define RTGUI_IS_SLIDER(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_SLIDER_TYPE))
-
-struct rtgui_slider
-{
- struct rtgui_widget parent;
-
- /* widget private data */
- rt_size_t min, max, value, ticks;
- rt_size_t thumb_width;
-
- int orient;
-
- void (*on_changed)(struct rtgui_widget* widget, struct rtgui_event *event);
-};
-typedef struct rtgui_slider rtgui_slider_t;
-
-struct rtgui_slider* rtgui_slider_create(rt_size_t min, rt_size_t max, int orient);
-void rtgui_slider_destroy(struct rtgui_slider* slider);
-
-rt_bool_t rtgui_slider_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
-
-void rtgui_slider_set_range(struct rtgui_slider* slider, rt_size_t min, rt_size_t max);
-void rtgui_slider_set_value(struct rtgui_slider* slider, rt_size_t value);
-void rtgui_slider_set_orientation(struct rtgui_slider* slider, int orientation);
-
-rt_size_t rtgui_slider_get_value(struct rtgui_slider* slider);
-
-#endif
+/* + * File : slider.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_SLIDER_H__ +#define __RTGUI_SLIDER_H__ + +#include <rtgui/rtgui.h> +#include <rtgui/widgets/widget.h> + +DECLARE_CLASS_TYPE(slider); +/** Gets the type of a slider */ +#define RTGUI_SLIDER_TYPE (RTGUI_TYPE(slider)) +/** Casts the object to an rtgui_slider */ +#define RTGUI_SLIDER(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_SLIDER_TYPE, rtgui_slider_t)) +/** Checks if the object is an rtgui_slider */ +#define RTGUI_IS_SLIDER(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_SLIDER_TYPE)) + +struct rtgui_slider +{ + struct rtgui_widget parent; + + /* widget private data */ + rt_size_t min, max, value, ticks; + rt_size_t thumb_width; + + int orient; + + void (*on_changed)(struct rtgui_widget* widget, struct rtgui_event *event); +}; +typedef struct rtgui_slider rtgui_slider_t; + +struct rtgui_slider* rtgui_slider_create(rt_size_t min, rt_size_t max, int orient); +void rtgui_slider_destroy(struct rtgui_slider* slider); + +rt_bool_t rtgui_slider_event_handler(struct rtgui_object* object, struct rtgui_event* event); + +void rtgui_slider_set_range(struct rtgui_slider* slider, rt_size_t min, rt_size_t max); +void rtgui_slider_set_value(struct rtgui_slider* slider, rt_size_t value); +void rtgui_slider_set_orientation(struct rtgui_slider* slider, int orientation); + +rt_size_t rtgui_slider_get_value(struct rtgui_slider* slider); + +#endif diff --git a/components/rtgui/include/rtgui/widgets/staticline.h b/components/rtgui/include/rtgui/widgets/staticline.h index 481c8da306..67ccfa4dec 100644 --- a/components/rtgui/include/rtgui/widgets/staticline.h +++ b/components/rtgui/include/rtgui/widgets/staticline.h @@ -1,35 +1,35 @@ -#ifndef __RTGUI_STATICLINE__H__
-#define __RTGUI_STATICLINE__H__
-
-#include <rtgui/rtgui.h>
-#include <rtgui/widgets/widget.h>
-
-/*
- * the static line widget
- */
-
-DECLARE_CLASS_TYPE(staticline);
-/** Gets the type of a staticline */
-#define RTGUI_STATICLINE_TYPE (RTGUI_TYPE(staticline))
-/** Casts the object to an rtgui_staticline */
-#define RTGUI_STATICLINE(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_STATICLINE_TYPE, rtgui_staticline_t))
-/** Checks if the object is an rtgui_staticline */
-#define RTGUI_IS_STATICLINE(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_STATICLINE_TYPE))
-
-struct rtgui_staticline
-{
- /* inherit from widget */
- struct rtgui_widget parent;
-
- int orient;
-};
-typedef struct rtgui_staticline rtgui_staticline_t;
-
-rtgui_staticline_t *rtgui_staticline_create(int orientation);
-void rtgui_staticline_destroy(rtgui_staticline_t* staticline);
-
-rt_bool_t rtgui_staticline_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
-void rtgui_staticline_set_orientation(rtgui_staticline_t* staticline, int orientation);
-
-#endif
-
+#ifndef __RTGUI_STATICLINE__H__ +#define __RTGUI_STATICLINE__H__ + +#include <rtgui/rtgui.h> +#include <rtgui/widgets/widget.h> + +/* + * the static line widget + */ + +DECLARE_CLASS_TYPE(staticline); +/** Gets the type of a staticline */ +#define RTGUI_STATICLINE_TYPE (RTGUI_TYPE(staticline)) +/** Casts the object to an rtgui_staticline */ +#define RTGUI_STATICLINE(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_STATICLINE_TYPE, rtgui_staticline_t)) +/** Checks if the object is an rtgui_staticline */ +#define RTGUI_IS_STATICLINE(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_STATICLINE_TYPE)) + +struct rtgui_staticline +{ + /* inherit from widget */ + struct rtgui_widget parent; + + int orient; +}; +typedef struct rtgui_staticline rtgui_staticline_t; + +rtgui_staticline_t *rtgui_staticline_create(int orientation); +void rtgui_staticline_destroy(rtgui_staticline_t* staticline); + +rt_bool_t rtgui_staticline_event_handler(struct rtgui_object* object, struct rtgui_event* event); +void rtgui_staticline_set_orientation(rtgui_staticline_t* staticline, int orientation); + +#endif + diff --git a/components/rtgui/include/rtgui/widgets/textbox.h b/components/rtgui/include/rtgui/widgets/textbox.h index 912da4ca84..972e80a579 100644 --- a/components/rtgui/include/rtgui/widgets/textbox.h +++ b/components/rtgui/include/rtgui/widgets/textbox.h @@ -1,75 +1,75 @@ -/*
- * 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/widgets/widget.h>
-
-DECLARE_CLASS_TYPE(textbox);
-/** Gets the type of a textbox */
-#define RTGUI_TEXTBOX_TYPE (RTGUI_TYPE(textbox))
-/** 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 0x01
-#define RTGUI_TEXTBOX_MASK 0x02
-#define RTGUI_TEXTBOX_CARET_SHOW 0x10
-#define RTGUI_TEXTBOX_CARET_HIDE 0x00
-
-struct rtgui_textbox_line
-{
- char* line_text;
-
- struct rtgui_textbox_line *prev, *next;
-};
-
-struct rtgui_textbox
-{
- /* inherit from widget */
- struct rtgui_widget parent;
-
- /* text box flag */
- rt_uint8_t flag;
-
- /* current line and position */
- rt_uint16_t line, line_begin, position, line_length;
-
- char* text;
- rt_size_t font_width;
-
- struct rtgui_timer* caret_timer;
-
- /* 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, rt_uint8_t flag);
-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_textbox_set_line_length(struct rtgui_textbox* box, rt_size_t length);
-
-#endif
+/* + * 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/widgets/widget.h> + +DECLARE_CLASS_TYPE(textbox); +/** Gets the type of a textbox */ +#define RTGUI_TEXTBOX_TYPE (RTGUI_TYPE(textbox)) +/** 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 0x01 +#define RTGUI_TEXTBOX_MASK 0x02 +#define RTGUI_TEXTBOX_CARET_SHOW 0x10 +#define RTGUI_TEXTBOX_CARET_HIDE 0x00 + +struct rtgui_textbox_line +{ + char* line_text; + + struct rtgui_textbox_line *prev, *next; +}; + +struct rtgui_textbox +{ + /* inherit from widget */ + struct rtgui_widget parent; + + /* text box flag */ + rt_uint8_t flag; + + /* current line and position */ + rt_uint16_t line, line_begin, position, line_length; + + char* text; + rt_size_t font_width; + + struct rtgui_timer* caret_timer; + + /* 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, rt_uint8_t flag); +void rtgui_textbox_destroy(struct rtgui_textbox* box); + +rt_bool_t rtgui_textbox_event_handler(struct rtgui_object* object, 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_textbox_set_line_length(struct rtgui_textbox* box, rt_size_t length); + +#endif diff --git a/components/rtgui/include/rtgui/widgets/textview.h b/components/rtgui/include/rtgui/widgets/textview.h index 523b5ee9c1..49024207cf 100644 --- a/components/rtgui/include/rtgui/widgets/textview.h +++ b/components/rtgui/include/rtgui/widgets/textview.h @@ -1,67 +1,67 @@ -/*
- * File : textview.h
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2011, 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
- * 2011-03-05 Bernard first version
- */
-#ifndef __RTGUI_TEXTVIEW_H__
-#define __RTGUI_TEXTVIEW_H__
-
-#include <rtgui/widgets/widget.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @defgroup rtgui_textview
- * @{
- */
-
-DECLARE_CLASS_TYPE(textview);
-
-/** Gets the type of a textview */
-#define RTGUI_TEXTVIEW_TYPE (RTGUI_TYPE(textview))
-/** Casts the object to an rtgui_textview */
-#define RTGUI_TEXTVIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_TEXTVIEW_TYPE, rtgui_textview_t))
-/** Checks if the object is an rtgui_textview */
-#define RTGUI_IS_TEXTVIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_TEXTVIEW_TYPE))
-
-/*
- * the textview widget
- */
-struct rtgui_textview
-{
- /* inherit from widget */
- struct rtgui_widget parent;
-
- rt_uint16_t line_width;
- rt_uint16_t line_count;
-
- char* lines;
-
- rt_int16_t line_current;
- rt_uint16_t line_page_count;
-};
-typedef struct rtgui_textview rtgui_textview_t;
-
-rtgui_textview_t* rtgui_textview_create(const char* text, const rtgui_rect_t *rect);
-void rtgui_textview_destroy(rtgui_textview_t* textview);
-
-rt_bool_t rtgui_textview_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
-void rtgui_textview_set_text(rtgui_textview_t* textview, const char* text);
-
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+/* + * File : textview.h + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2006 - 2011, 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 + * 2011-03-05 Bernard first version + */ +#ifndef __RTGUI_TEXTVIEW_H__ +#define __RTGUI_TEXTVIEW_H__ + +#include <rtgui/widgets/widget.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup rtgui_textview + * @{ + */ + +DECLARE_CLASS_TYPE(textview); + +/** Gets the type of a textview */ +#define RTGUI_TEXTVIEW_TYPE (RTGUI_TYPE(textview)) +/** Casts the object to an rtgui_textview */ +#define RTGUI_TEXTVIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_TEXTVIEW_TYPE, rtgui_textview_t)) +/** Checks if the object is an rtgui_textview */ +#define RTGUI_IS_TEXTVIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_TEXTVIEW_TYPE)) + +/* + * the textview widget + */ +struct rtgui_textview +{ + /* inherit from widget */ + struct rtgui_widget parent; + + rt_uint16_t line_width; + rt_uint16_t line_count; + + char* lines; + + rt_int16_t line_current; + rt_uint16_t line_page_count; +}; +typedef struct rtgui_textview rtgui_textview_t; + +rtgui_textview_t* rtgui_textview_create(const char* text, const rtgui_rect_t *rect); +void rtgui_textview_destroy(rtgui_textview_t* textview); + +rt_bool_t rtgui_textview_event_handler(struct rtgui_object* object, struct rtgui_event* event); +void rtgui_textview_set_text(rtgui_textview_t* textview, const char* text); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/components/rtgui/include/rtgui/widgets/title.h b/components/rtgui/include/rtgui/widgets/title.h index ee6ac2c824..09a67ea2ba 100644 --- a/components/rtgui/include/rtgui/widgets/title.h +++ b/components/rtgui/include/rtgui/widgets/title.h @@ -1,44 +1,44 @@ -/*
- * 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>
-
-DECLARE_CLASS_TYPE(wintitle);
-/** Gets the type of a title */
-#define RTGUI_WINTITLE_TYPE (RTGUI_TYPE(wintitle))
-/** 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 */
- char* title;
-};
-typedef struct rtgui_wintitle rtgui_wintitle_t;
-
-rtgui_wintitle_t* rtgui_wintitle_create(const char* 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 char* title);
-char *rtgui_wintitle_get_title(rtgui_wintitle_t* wintitle);
-
-#endif
+/* + * 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> + +DECLARE_CLASS_TYPE(wintitle); +/** Gets the type of a title */ +#define RTGUI_WINTITLE_TYPE (RTGUI_TYPE(wintitle)) +/** 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 */ + char* title; +}; +typedef struct rtgui_wintitle rtgui_wintitle_t; + +rtgui_wintitle_t* rtgui_wintitle_create(const char* 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 char* title); +char *rtgui_wintitle_get_title(rtgui_wintitle_t* wintitle); + +#endif diff --git a/components/rtgui/include/rtgui/widgets/toplevel.h b/components/rtgui/include/rtgui/widgets/toplevel.h index 3b46aeaa5c..9b4b5573d2 100644 --- a/components/rtgui/include/rtgui/widgets/toplevel.h +++ b/components/rtgui/include/rtgui/widgets/toplevel.h @@ -1,53 +1,44 @@ -/*
- * 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>
-
-DECLARE_CLASS_TYPE(toplevel);
-/** Gets the type of a toplevel */
-#define RTGUI_TOPLEVEL_TYPE (RTGUI_TYPE(toplevel))
-/** 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))
-
-/* last mouse event handled widget */
-#define RTGUI_TOPLEVEL_LAST_MEVENT_WIDGET(obj) (RTGUI_TOPLEVEL(obj)->last_mevent_widget)
-
-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;
-
- /* last mouse event handled widget */
- rtgui_widget_t* last_mevent_widget;
-};
-typedef struct rtgui_toplevel rtgui_toplevel_t;
-
-rt_bool_t rtgui_toplevel_event_handler(rtgui_widget_t* widget, rtgui_event_t* event);
-void rtgui_toplevel_update_clip(rtgui_toplevel_t* top);
-
-#endif
+/* + * 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> + +DECLARE_CLASS_TYPE(toplevel); +/** Gets the type of a toplevel */ +#define RTGUI_TOPLEVEL_TYPE (RTGUI_TYPE(toplevel)) +/** 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 view */ + 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; +}; +typedef struct rtgui_toplevel rtgui_toplevel_t; + +rt_bool_t rtgui_toplevel_event_handler(struct rtgui_object* widget, struct rtgui_event* event); +void rtgui_toplevel_update_clip(rtgui_toplevel_t* top); + +#endif diff --git a/components/rtgui/include/rtgui/widgets/view.h b/components/rtgui/include/rtgui/widgets/view.h deleted file mode 100644 index a35095cf30..0000000000 --- a/components/rtgui/include/rtgui/widgets/view.h +++ /dev/null @@ -1,66 +0,0 @@ -/*
- * 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
-
-DECLARE_CLASS_TYPE(view);
-/** Gets the type of a view */
-#define RTGUI_VIEW_TYPE (RTGUI_TYPE(view))
-/** 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;
- rt_bool_t modal_show;
-};
-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);
-
-#ifndef RTGUI_USING_SMALL_SIZE
-void rtgui_view_set_box(rtgui_view_t* view, rtgui_box_t* box);
-#endif
-
-rtgui_modal_code_t rtgui_view_show(rtgui_view_t* view, rt_bool_t is_modal);
-void rtgui_view_hide(rtgui_view_t* view);
-void rtgui_view_end_modal(rtgui_view_t* view, rtgui_modal_code_t modal_code);
-
-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
diff --git a/components/rtgui/include/rtgui/widgets/widget.h b/components/rtgui/include/rtgui/widgets/widget.h index ab44d23b39..7d747e677c 100644 --- a/components/rtgui/include/rtgui/widgets/widget.h +++ b/components/rtgui/include/rtgui/widgets/widget.h @@ -76,8 +76,10 @@ struct rtgui_widget /* inherit from rtgui_object */ struct rtgui_object object; - /* the parent and root widget */ - struct rtgui_widget *parent, *toplevel; + /* the widget that contains this widget */ + struct rtgui_widget *parent; + /* the window that contains this widget */ + struct rtgui_win *toplevel; /* the widget children and sibling */ rtgui_list_t sibling; @@ -106,18 +108,25 @@ struct rtgui_widget /* the rect clip */ rtgui_region_t clip; - /* the event handler */ - rt_bool_t (*event_handler) (struct rtgui_widget* widget, struct rtgui_event* event); - /* call back */ - 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_focus_in) (struct rtgui_object* widget, struct rtgui_event* event); + rt_bool_t (*on_focus_out) (struct rtgui_object* widget, struct rtgui_event* event); + /* will be called just before the widget is shown. You can setup your + * widget in this call back. It's return value is ignored. The @param event + * will always be RT_NULL + */ + rt_bool_t (*on_show) (struct rtgui_object* widget, struct rtgui_event* event); + /* will be called just before the widget is hiden. You can setup your + * widget in this call back. It's return value is ignored. The @param event + * will always be RT_NULL + */ + rt_bool_t (*on_hide) (struct rtgui_object* widget, struct rtgui_event* event); #ifndef RTGUI_USING_SMALL_SIZE - rt_bool_t (*on_draw) (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); + rt_bool_t (*on_draw) (struct rtgui_object* widget, struct rtgui_event* event); + rt_bool_t (*on_mouseclick) (struct rtgui_object* widget, struct rtgui_event* event); + rt_bool_t (*on_key) (struct rtgui_object* widget, struct rtgui_event* event); + rt_bool_t (*on_size) (struct rtgui_object* widget, struct rtgui_event* event); + rt_bool_t (*on_command) (struct rtgui_object* widget, struct rtgui_event* event); #endif /* user private data */ @@ -125,14 +134,10 @@ struct rtgui_widget }; 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); -/* 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); +rt_bool_t rtgui_widget_event_handler(struct rtgui_object* object, rtgui_event_t* event); /* focus and unfocus */ void rtgui_widget_focus(rtgui_widget_t * widget); @@ -141,6 +146,8 @@ void rtgui_widget_unfocus(rtgui_widget_t *widget); /* event handler for each command */ 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_onshow(rtgui_widget_t* widget, rtgui_event_handler_ptr handler); +void rtgui_widget_set_onhide(rtgui_widget_t* widget, rtgui_event_handler_ptr handler); #ifndef RTGUI_USING_SMALL_SIZE void rtgui_widget_set_ondraw(rtgui_widget_t* widget, rtgui_event_handler_ptr handler); void rtgui_widget_set_onmouseclick(rtgui_widget_t* widget, rtgui_event_handler_ptr handler); @@ -179,7 +186,7 @@ void rtgui_widget_move_to_logic(rtgui_widget_t* widget, int dx, int dy); 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); +struct rtgui_win* rtgui_widget_get_toplevel(rtgui_widget_t* widget); void rtgui_widget_show(rtgui_widget_t* widget); void rtgui_widget_hide(rtgui_widget_t* widget); diff --git a/components/rtgui/include/rtgui/widgets/window.h b/components/rtgui/include/rtgui/widgets/window.h index 4807407b00..deb4378a36 100644 --- a/components/rtgui/include/rtgui/widgets/window.h +++ b/components/rtgui/include/rtgui/widgets/window.h @@ -1,107 +1,160 @@ -/*
- * 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
- * 2010-05-03 Bernard add win close function
- */
-#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>
-
-DECLARE_CLASS_TYPE(win);
-/** Gets the type of a win */
-#define RTGUI_WIN_TYPE (RTGUI_TYPE(win))
-/** 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 0x001 /* modal mode window */
-#define RTGUI_WIN_STYLE_CLOSED 0x002 /* window is closed */
-#define RTGUI_WIN_STYLE_ACTIVATE 0x004 /* window is activated */
-#define RTGUI_WIN_STYLE_NO_FOCUS 0x008 /* non-focused window */
-
-#define RTGUI_WIN_STYLE_NO_TITLE 0x010 /* no title window */
-#define RTGUI_WIN_STYLE_NO_BORDER 0x020 /* no border window */
-#define RTGUI_WIN_STYLE_CLOSEBOX 0x040 /* window has the close button */
-#define RTGUI_WIN_STYLE_MINIBOX 0x080 /* window has the mini button */
-
-#define RTGUI_WIN_STYLE_UNDER_MODAL 0x100 /* window is under modal show (show
- * sub-win as modal window) */
-
-#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;
-
- /* parent toplevel */
- rtgui_toplevel_t* parent_toplevel;
-
- /* top window style */
- rt_uint16_t style;
-
- rtgui_modal_code_t modal_code;
- rtgui_widget_t* modal_widget;
-
- /* 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_win_t* rtgui_win_create(rtgui_toplevel_t* parent_toplevel, const char* title,
- rtgui_rect_t *rect, rt_uint8_t flag);
-void rtgui_win_destroy(rtgui_win_t* win);
-void rtgui_win_close(struct rtgui_win* win);
-
-rtgui_modal_code_t rtgui_win_show(rtgui_win_t* win, rt_bool_t is_modal);
-void rtgui_win_hiden(rtgui_win_t* win);
-void rtgui_win_end_modal(rtgui_win_t* win, rtgui_modal_code_t modal_code);
-
-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);
-
-#ifndef RTGUI_USING_SMALL_SIZE
-void rtgui_win_set_box(rtgui_win_t* win, rtgui_box_t* box);
-#endif
-
-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
+/* + * 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 + * 2010-05-03 Bernard add win close function + */ +#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> + +DECLARE_CLASS_TYPE(win); +/** Gets the type of a win */ +#define RTGUI_WIN_TYPE (RTGUI_TYPE(win)) +/** 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_NO_FOCUS 0x001 /* non-focused window */ + +#define RTGUI_WIN_STYLE_NO_TITLE 0x002 /* no title window */ +#define RTGUI_WIN_STYLE_NO_BORDER 0x004 /* no border window */ +#define RTGUI_WIN_STYLE_CLOSEBOX 0x008 /* window has the close button */ +#define RTGUI_WIN_STYLE_MINIBOX 0x010 /* window has the mini button */ + +#define RTGUI_WIN_STYLE_DESTROY_ON_CLOSE 0x020 /* window is destroyed when closed */ +#ifdef RTGUI_USING_DESKTOP_WINDOW +/* A desktop window is a full screen window which will beneath all other windows. + * There will be only one desktop window in a system. And this window should be + * created _before_ any other windows. + */ +#define RTGUI_WIN_STYLE_DESKTOP 0x8000 +#define RTGUI_WIN_STYLE_DESKTOP_DEFAULT RTGUI_WIN_STYLE_DESKTOP |\ + RTGUI_WIN_STYLE_NO_BORDER |\ + RTGUI_WIN_STYLE_NO_TITLE +#endif + +#define RTGUI_WIN_STYLE_DEFAULT (RTGUI_WIN_STYLE_CLOSEBOX | RTGUI_WIN_STYLE_MINIBOX) + +enum rtgui_win_flag +{ + RTGUI_WIN_FLAG_INIT = 0x00, /* init state */ + RTGUI_WIN_FLAG_MODAL = 0x01, /* modal mode window */ + RTGUI_WIN_FLAG_CLOSED = 0x02, /* window is closed */ + RTGUI_WIN_FLAG_ACTIVATE = 0x04, /* window is activated */ + RTGUI_WIN_FLAG_UNDER_MODAL = 0x08, /* window is under modal + show(modaled by other) */ + RTGUI_WIN_FLAG_CONNECTED = 0x10, /* connected to server */ + /* window is event_key dispatcher(dispatch it to the focused widget in + * current window) _and_ a key handler(it should be able to handle keys + * such as ESC). Both of dispatching and handling are in the same + * function(rtgui_win_event_handler). So we have to distinguish between the + * two modes. + * + * If this flag is set, we are in key-handling mode. + */ + RTGUI_WIN_FLAG_HANDLE_KEY = 0x20 +}; + +struct rtgui_win_title; +struct rtgui_win_area; + +struct rtgui_win +{ + /* inherit from toplevel */ + struct rtgui_toplevel parent; + + /* parent window. RT_NULL if the window is a top level window */ + struct rtgui_win *parent_window; + + /* the widget that will grab the focus in current window */ + struct rtgui_widget *focused_widget; + + /* top window style */ + rt_uint16_t style; + + /* window state flag */ + enum rtgui_win_flag flag; + + rtgui_modal_code_t modal_code; + + /* last mouse event handled widget */ + rtgui_widget_t* last_mevent_widget; + + /* window title */ + char* title; + + /* call back */ + rt_bool_t (*on_activate) (struct rtgui_object* widget, struct rtgui_event* event); + rt_bool_t (*on_deactivate) (struct rtgui_object* widget, struct rtgui_event* event); + rt_bool_t (*on_close) (struct rtgui_object* widget, struct rtgui_event* event); + /* the key is sent to the focused widget by default. If the focused widget + * and all of it's parents didn't handle the key event, it will be handled + * by @func on_key + * + * If you want to handle key event on your own, it's better to overload + * this function other than handle EVENT_KBD in event_handler. + */ + rt_bool_t (*on_key) (struct rtgui_object* widget, struct rtgui_event* event); + + /* reserved user data */ + rt_uint32_t user_data; +}; + +rtgui_win_t* rtgui_win_create(struct rtgui_win *parent_window, const char* title, + rtgui_rect_t *rect, rt_uint16_t style); +void rtgui_win_destroy(rtgui_win_t* win); + +/** Close window. + * + * @param win the window you want to close + * + * @return RT_TRUE if the window is closed. RT_FALSE if not. If the onclose + * callback returns RT_FALSE, the window won't be closed. + * + * \sa rtgui_win_set_onclose . + */ +rt_bool_t rtgui_win_close(struct rtgui_win* win); + +rt_base_t rtgui_win_show(struct rtgui_win *win, rt_bool_t is_modal); +void rtgui_win_hiden(rtgui_win_t* win); +void rtgui_win_end_modal(rtgui_win_t* win, rtgui_modal_code_t modal_code); + +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); + +#ifndef RTGUI_USING_SMALL_SIZE +void rtgui_win_set_box(rtgui_win_t* win, rtgui_box_t* box); +#endif + +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); +void rtgui_win_set_onkey(rtgui_win_t* win, rtgui_event_handler_ptr handler); + +rt_bool_t rtgui_win_event_handler(struct rtgui_object* 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/components/rtgui/include/rtgui/widgets/workbench.h b/components/rtgui/include/rtgui/widgets/workbench.h deleted file mode 100644 index 3ec089f345..0000000000 --- a/components/rtgui/include/rtgui/widgets/workbench.h +++ /dev/null @@ -1,87 +0,0 @@ -/*
- * 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 /* workbench is visible */
-#define RTGUI_WORKBENCH_FLAG_INVISIBLE 0x01 /* workbench is invisible */
-#define RTGUI_WORKBENCH_FLAG_FULLSCREEN 0x02 /* workbench is full screen */
-#define RTGUI_WORKBENCH_FLAG_MODAL_MODE 0x04 /* workbench is modal mode showing */
-
-#define RTGUI_WORKBENCH_FLAG_CLOSEBLE 0x00
-#define RTGUI_WORKBENCH_FLAG_UNCLOSEBLE 0x10
-#define RTGUI_WORKBENCH_FLAG_CLOSED 0x20
-
-#define RTGUI_WORKBENCH_FLAG_DEFAULT RTGUI_WORKBENCH_FLAG_VISIBLE | RTGUI_WORKBENCH_FLAG_CLOSEBLE
-
-#define RTGUI_WORKBENCH_IS_MODAL_MODE(w) ((w)->flag & RTGUI_WORKBENCH_FLAG_MODAL_MODE)
-
-DECLARE_CLASS_TYPE(workbench);
-
-/** Gets the type of a workbench */
-#define RTGUI_WORKBENCH_TYPE (RTGUI_TYPE(workbench))
-/** 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;
- rtgui_modal_code_t modal_code;
- rtgui_widget_t *modal_widget;
-
- /* workbench title */
- unsigned char* title;
- rtgui_view_t* current_view;
-};
-
-rtgui_type_t* rtgui_workbench_type_get(void);
-
-rtgui_workbench_t *rtgui_workbench_create(const char* panel_name, const unsigned char* title);
-void rtgui_workbench_destroy(rtgui_workbench_t* workbench);
-void rtgui_workbench_close(rtgui_workbench_t* workbench);
-
-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);
-
-rt_bool_t 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
|
