summaryrefslogtreecommitdiff
path: root/components/rtgui/include
diff options
context:
space:
mode:
author[email protected] <[email protected]>2012-07-20 12:37:56 +0000
committer[email protected] <[email protected]>2012-07-20 12:37:56 +0000
commit92a50c838d8ca2ae4027fd77b71db12fb52d86e3 (patch)
tree08cb5a9273c78c36df97f48eea17eb2e1034a497 /components/rtgui/include
parentc2868be90d0f1f43ee13bacdb1c0f55a9fe34276 (diff)
sync with RTGUI c074ff2898b9e
Full log is in GitHub. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2222 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/rtgui/include')
-rw-r--r--components/rtgui/include/rtgui/blit.h1
-rw-r--r--components/rtgui/include/rtgui/color.h25
-rw-r--r--components/rtgui/include/rtgui/driver.h1
-rw-r--r--components/rtgui/include/rtgui/event.h47
-rw-r--r--components/rtgui/include/rtgui/rtgui.h2
-rw-r--r--components/rtgui/include/rtgui/rtgui_app.h88
-rw-r--r--components/rtgui/include/rtgui/rtgui_application.h99
-rw-r--r--components/rtgui/include/rtgui/rtgui_config.h3
-rw-r--r--components/rtgui/include/rtgui/rtgui_object.h5
-rw-r--r--components/rtgui/include/rtgui/rtgui_server.h8
-rw-r--r--components/rtgui/include/rtgui/rtgui_system.h11
-rw-r--r--components/rtgui/include/rtgui/widgets/about_view.h44
-rw-r--r--components/rtgui/include/rtgui/widgets/box.h13
-rw-r--r--components/rtgui/include/rtgui/widgets/container.h11
-rw-r--r--components/rtgui/include/rtgui/widgets/filelist_view.h2
-rw-r--r--components/rtgui/include/rtgui/widgets/menu.h2
-rw-r--r--components/rtgui/include/rtgui/widgets/panel.h45
-rw-r--r--components/rtgui/include/rtgui/widgets/textbox.h53
-rw-r--r--components/rtgui/include/rtgui/widgets/widget.h27
-rw-r--r--components/rtgui/include/rtgui/widgets/window.h16
20 files changed, 289 insertions, 214 deletions
diff --git a/components/rtgui/include/rtgui/blit.h b/components/rtgui/include/rtgui/blit.h
index df0d2a5b32..fb4564e6bc 100644
--- a/components/rtgui/include/rtgui/blit.h
+++ b/components/rtgui/include/rtgui/blit.h
@@ -5,5 +5,6 @@
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);
+rtgui_blit_line_func rtgui_blit_line_get_inv(int dst_bpp, int src_bpp);
#endif
diff --git a/components/rtgui/include/rtgui/color.h b/components/rtgui/include/rtgui/color.h
index d8f5fce177..42eafbc96d 100644
--- a/components/rtgui/include/rtgui/color.h
+++ b/components/rtgui/include/rtgui/color.h
@@ -10,6 +10,7 @@
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
+ * 2012-01-24 onelife add mono color support
*/
#ifndef __RTGUI_COLOR_H__
#define __RTGUI_COLOR_H__
@@ -45,6 +46,30 @@ extern const rtgui_color_t light_grey;
* BBBB BBBB GGGG GGGG RRRR RRRR
*/
+/* convert rtgui color to mono */
+rt_inline rt_uint8_t rtgui_color_to_mono(rtgui_color_t c)
+{
+ rt_uint8_t pixel;
+
+ pixel = (RTGUI_RGB_R(c) | RTGUI_RGB_G(c) | RTGUI_RGB_B(c)) ? 0x01 : 0x00;
+ return pixel;
+}
+
+rt_inline rtgui_color_t rtgui_color_from_mono(rt_uint8_t pixel)
+{
+ rtgui_color_t color;
+
+ if (pixel)
+ {
+ color = white;
+ }
+ else
+ {
+ color = black;
+ }
+ return color;
+}
+
/* convert rtgui color to BBBBBGGGGGGRRRRR */
rt_inline rt_uint16_t rtgui_color_to_565(rtgui_color_t c)
{
diff --git a/components/rtgui/include/rtgui/driver.h b/components/rtgui/include/rtgui/driver.h
index 664d9183f3..b341661dfd 100644
--- a/components/rtgui/include/rtgui/driver.h
+++ b/components/rtgui/include/rtgui/driver.h
@@ -54,6 +54,7 @@ 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_uint8_t* rtgui_graphic_driver_get_default_framebuffer(void);
rt_err_t rtgui_graphic_set_device(rt_device_t device);
diff --git a/components/rtgui/include/rtgui/event.h b/components/rtgui/include/rtgui/event.h
index e20b5cabee..2a06f1850f 100644
--- a/components/rtgui/include/rtgui/event.h
+++ b/components/rtgui/include/rtgui/event.h
@@ -21,6 +21,11 @@
* rtgui_event_generic */
enum _rtgui_event_type
{
+ /* applications event */
+ RTGUI_EVENT_APP_CREATE, /* create an application */
+ RTGUI_EVENT_APP_DESTROY, /* destroy an application */
+ RTGUI_EVENT_APP_ACTIVATE, /* activate an application */
+
/* window event */
RTGUI_EVENT_WIN_CREATE, /* create a window */
RTGUI_EVENT_WIN_DESTROY, /* destroy a window */
@@ -43,6 +48,8 @@ enum _rtgui_event_type
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_SHOW, /* the widget is going to be shown */
+ RTGUI_EVENT_HIDE, /* the widget is going to be hidden */
RTGUI_EVENT_PAINT, /* paint on screen */
RTGUI_EVENT_TIMER, /* timer */
@@ -94,6 +101,24 @@ typedef struct rtgui_event rtgui_event_t;
(e)->ack = RT_NULL; \
} while (0)
+/*
+ * RTGUI Application Event
+ */
+struct rtgui_event_application
+{
+ struct rtgui_event parent;
+
+ struct rtgui_app* app;
+};
+
+/* gui application init */
+#define RTGUI_EVENT_APP_CREATE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_APP_CREATE)
+#define RTGUI_EVENT_APP_DESTROY_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_APP_DESTROY)
+#define RTGUI_EVENT_APP_ACTIVATE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_APP_ACTIVATE)
+
+/*
+ * RTGUI Window Event
+ */
#define _RTGUI_EVENT_WIN_ELEMENTS \
struct rtgui_event parent; \
struct rtgui_win *wid;
@@ -152,6 +177,16 @@ struct rtgui_event_win_resize
#define RTGUI_EVENT_WIN_MODAL_ENTER_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_MODAL_ENTER)
/*
+ * RTGUI set window manager
+ */
+struct rtgui_event_set_wm
+{
+ struct rtgui_event parent;
+ struct rtgui_app *app;
+};
+#define RTGUI_EVENT_SET_WM_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_SET_WM);
+
+/*
* RTGUI Other Event
*/
struct rtgui_event_update_begin
@@ -214,6 +249,12 @@ struct 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)
+#define rtgui_event_show rtgui_event
+#define rtgui_event_hide rtgui_event
+
+#define RTGUI_EVENT_SHOW_INIT(e) RTGUI_EVENT_INIT((e), RTGUI_EVENT_SHOW)
+#define RTGUI_EVENT_HIDE_INIT(e) RTGUI_EVENT_INIT((e), RTGUI_EVENT_HIDE)
+
/*
* RTGUI Mouse and Keyboard Event
*/
@@ -325,6 +366,12 @@ struct rtgui_event_resize
union rtgui_event_generic
{
struct rtgui_event base;
+
+ struct rtgui_event_application app_create;
+ struct rtgui_event_application app_destroy;
+ struct rtgui_event_application app_activate;
+
+ struct rtgui_event_set_wm set_wm;
struct rtgui_event_win win_base;
struct rtgui_event_win_create win_create;
struct rtgui_event_win_move win_move;
diff --git a/components/rtgui/include/rtgui/rtgui.h b/components/rtgui/include/rtgui/rtgui.h
index d35e17ec5e..188c354302 100644
--- a/components/rtgui/include/rtgui/rtgui.h
+++ b/components/rtgui/include/rtgui/rtgui.h
@@ -30,7 +30,7 @@ struct rtgui_font;
typedef struct rtgui_win rtgui_win_t;
typedef struct rtgui_workbench rtgui_workbench_t;
-typedef rt_bool_t (*rtgui_event_handler_ptr)(struct rtgui_object* widget, struct rtgui_event* event);
+typedef rt_bool_t (*rtgui_event_handler_ptr)(struct rtgui_object* object, struct rtgui_event* event);
typedef void (*rtgui_onbutton_func_t)(struct rtgui_object* object, struct rtgui_event* event);
struct rtgui_point
diff --git a/components/rtgui/include/rtgui/rtgui_app.h b/components/rtgui/include/rtgui/rtgui_app.h
new file mode 100644
index 0000000000..37bf77baec
--- /dev/null
+++ b/components/rtgui/include/rtgui/rtgui_app.h
@@ -0,0 +1,88 @@
+/*
+ * 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_APP_TYPE (RTGUI_TYPE(application))
+/** Casts the object to an rtgui_workbench */
+#define RTGUI_APP(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_APP_TYPE, struct rtgui_app))
+/** Checks if the object is an rtgui_workbench */
+#define RTGUI_IS_APP(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_APP_TYPE))
+
+enum rtgui_app_flag
+{
+ RTGUI_APP_FLAG_EXITED = 0x04,
+ RTGUI_APP_FLAG_SHOWN = 0x08
+};
+
+typedef void (*rtgui_idle_func_t)(struct rtgui_object* obj, struct rtgui_event *event);
+
+struct rtgui_app
+{
+ struct rtgui_object parent;
+
+ /* application name */
+ unsigned char *name;
+ struct rtgui_image* icon;
+
+ enum rtgui_app_flag state_flag;
+
+ rt_uint16_t ref_count;
+ rt_uint16_t exit_code;
+
+ /* the thread id */
+ rt_thread_t tid;
+ /* the RTGUI server id */
+ 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 in modal state by modal_object. If is
+ * RT_NULL, nothing modal windows. */
+ struct rtgui_object *modal_object;
+ struct rtgui_object *main_object;
+
+ /* on idle event handler */
+ rtgui_idle_func_t on_idle;
+};
+
+/**
+ * create an application named @myname on thread @param tid
+ */
+struct rtgui_app* rtgui_app_create(rt_thread_t tid, const char *title);
+void rtgui_app_destroy(struct rtgui_app *app);
+rt_bool_t rtgui_app_event_handler(struct rtgui_object* obj, rtgui_event_t* event);
+
+rt_base_t rtgui_app_run(struct rtgui_app *app);
+void rtgui_app_exit(struct rtgui_app *app, rt_uint16_t code);
+
+void rtgui_app_set_onidle(rtgui_idle_func_t onidle);
+rtgui_idle_func_t rtgui_app_get_onidle(void);
+struct rtgui_app* rtgui_app_self(void);
+
+rt_err_t rtgui_app_set_as_wm(void);
+void rtgui_app_set_main_win(struct rtgui_win* win);
+
+#endif /* end of include guard: RTGUI_APPLICATION_H */
diff --git a/components/rtgui/include/rtgui/rtgui_application.h b/components/rtgui/include/rtgui/rtgui_application.h
deleted file mode 100644
index 83c13aaff5..0000000000
--- a/components/rtgui/include/rtgui/rtgui_application.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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 33ae2ee061..e1e7e56112 100644
--- a/components/rtgui/include/rtgui/rtgui_config.h
+++ b/components/rtgui/include/rtgui/rtgui_config.h
@@ -77,5 +77,6 @@
//#define RTGUI_USING_DESKTOP_WINDOW
#define RTGUI_EVENT_DEBUG
-#undef RTGUI_USING_SMALL_SIZE
+// #undef RTGUI_USING_SMALL_SIZE
+
#endif
diff --git a/components/rtgui/include/rtgui/rtgui_object.h b/components/rtgui/include/rtgui/rtgui_object.h
index eb9c005c30..8f38909bbe 100644
--- a/components/rtgui/include/rtgui/rtgui_object.h
+++ b/components/rtgui/include/rtgui/rtgui_object.h
@@ -31,7 +31,7 @@ extern "C" {
/** Casts the function pointer to an rtgui_constructor */
#define RTGUI_DESTRUCTOR(destructor) ((rtgui_destructor_t)(destructor))
-/* pre-definetion */
+/* pre-definition */
struct rtgui_object;
typedef struct rtgui_object rtgui_object_t;
typedef void (*rtgui_constructor_t)(rtgui_object_t *object);
@@ -125,9 +125,6 @@ rt_bool_t rtgui_object_event_handler(struct rtgui_object *object, struct rtgui_e
/* 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, const char* func, int line);
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 8d1c57a6c4..f109f7297a 100644
--- a/components/rtgui/include/rtgui/rtgui_server.h
+++ b/components/rtgui/include/rtgui/rtgui_server.h
@@ -20,7 +20,7 @@
/* RTGUI server definitions */
/* top window definitions in server */
-enum
+enum rtgui_topwin_flag
{
WINTITLE_NO = 0x01,
WINTITLE_BORDER = 0x02,
@@ -34,7 +34,9 @@ enum
/* window is modaled by other window */
WINTITLE_MODALED = 0x80,
/* window is modaling other window */
- WINTITLE_MODALING = 0x100
+ WINTITLE_MODALING = 0x100,
+ WINTITLE_ONTOP = 0x200,
+ WINTITLE_ONBTM = 0x400,
};
#define WINTITLE_HEIGHT 20
@@ -45,7 +47,7 @@ enum
struct rtgui_topwin
{
/* the window flag */
- rt_uint32_t flag;
+ enum rtgui_topwin_flag flag;
/* event mask */
rt_uint32_t mask;
diff --git a/components/rtgui/include/rtgui/rtgui_system.h b/components/rtgui/include/rtgui/rtgui_system.h
index 4f94ab83d1..ff9f5e2b52 100644
--- a/components/rtgui/include/rtgui/rtgui_system.h
+++ b/components/rtgui/include/rtgui/rtgui_system.h
@@ -53,5 +53,16 @@ void* rtgui_realloc(void* ptr, rt_size_t size);
#define rtgui_enter_critical rt_enter_critical
#define rtgui_exit_critical rt_exit_critical
+rt_thread_t rtgui_get_server(void);
+
+struct rtgui_event;
+rt_err_t rtgui_send(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size);
+rt_err_t rtgui_send_urgent(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size);
+rt_err_t rtgui_send_sync(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size);
+rt_err_t rtgui_ack(struct rtgui_event* event, rt_int32_t status);
+rt_err_t rtgui_recv(struct rtgui_event* event, rt_size_t event_size);
+rt_err_t rtgui_recv_nosuspend(struct rtgui_event* event, rt_size_t event_size);
+rt_err_t rtgui_recv_filter(rt_uint32_t type, struct rtgui_event* event, rt_size_t event_size);
+
#endif
diff --git a/components/rtgui/include/rtgui/widgets/about_view.h b/components/rtgui/include/rtgui/widgets/about_view.h
deleted file mode 100644
index 510796edf3..0000000000
--- a/components/rtgui/include/rtgui/widgets/about_view.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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 370b9820d3..39d8e4dbca 100644
--- a/components/rtgui/include/rtgui/widgets/box.h
+++ b/components/rtgui/include/rtgui/widgets/box.h
@@ -33,26 +33,23 @@ DECLARE_CLASS_TYPE(box);
struct rtgui_box
{
- struct rtgui_container parent;
+ struct rtgui_object parent;
rt_uint16_t orient;
rt_uint16_t border_size;
+
+ struct rtgui_container* container;
};
typedef struct rtgui_box rtgui_box_t;
-struct rtgui_box* rtgui_box_create(int orientation, rtgui_rect_t* rect);
+struct rtgui_box* rtgui_box_create(int orientation, int border_size);
void rtgui_box_destroy(struct rtgui_box* box);
-rt_bool_t rtgui_box_event_handler(struct rtgui_object* object, 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/container.h b/components/rtgui/include/rtgui/widgets/container.h
index 57a92b432c..990876992b 100644
--- a/components/rtgui/include/rtgui/widgets/container.h
+++ b/components/rtgui/include/rtgui/widgets/container.h
@@ -15,6 +15,7 @@
#define __RTGUI_CONTAINER_H__
#include <rtgui/widgets/widget.h>
+#include <rtgui/widgets/box.h>
#ifdef __cplusplus
extern "C" {
@@ -35,6 +36,9 @@ struct rtgui_container
{
struct rtgui_widget parent;
+ /* layout box */
+ struct rtgui_box* layout_box;
+
rtgui_list_t children;
};
typedef struct rtgui_container rtgui_container_t;
@@ -44,12 +48,9 @@ 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;
+/* set layout 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_layout(struct rtgui_container* 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);
diff --git a/components/rtgui/include/rtgui/widgets/filelist_view.h b/components/rtgui/include/rtgui/widgets/filelist_view.h
index 3ce9bbb195..6fc3b0b9d7 100644
--- a/components/rtgui/include/rtgui/widgets/filelist_view.h
+++ b/components/rtgui/include/rtgui/widgets/filelist_view.h
@@ -49,7 +49,7 @@ rtgui_filelist_view_t* rtgui_filelist_view_create(const char* directory,
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);
+rt_bool_t rtgui_filelist_view_event_handler(struct rtgui_object* object, 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);
diff --git a/components/rtgui/include/rtgui/widgets/menu.h b/components/rtgui/include/rtgui/widgets/menu.h
index ba620d3c74..2a137d7009 100644
--- a/components/rtgui/include/rtgui/widgets/menu.h
+++ b/components/rtgui/include/rtgui/widgets/menu.h
@@ -29,7 +29,7 @@ struct rtgui_menu_item
rt_uint16_t submenu_count;
/* menu action */
- rt_bool_t (*on_menuaction)(rtgui_widget_t* widget, rtgui_event_t* event);
+ rt_bool_t (*on_menuaction)(struct rtgui_object* object, struct rtgui_event* event);
};
typedef struct rtgui_menu_item rtgui_menu_item_t;
diff --git a/components/rtgui/include/rtgui/widgets/panel.h b/components/rtgui/include/rtgui/widgets/panel.h
new file mode 100644
index 0000000000..4d4af5e021
--- /dev/null
+++ b/components/rtgui/include/rtgui/widgets/panel.h
@@ -0,0 +1,45 @@
+/*
+ * File : panel.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_PANEL_H__
+#define __RTGUI_PANEL_H__
+
+#include <rtgui/rtgui.h>
+#include <rtgui/widgets/container.h>
+
+DECLARE_CLASS_TYPE(panel);
+
+/** Gets the type of a panel */
+#define RTGUI_PANEL_TYPE (RTGUI_TYPE(panel))
+/** Casts the object to an panel */
+#define RTGUI_PANEL(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_PANEL_TYPE, rtgui_panel_t))
+/** Checks if the object is an rtgui_button */
+#define RTGUI_IS_PANEL(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_PANEL_TYPE))
+
+/*
+ * the panel widget
+ */
+struct rtgui_panel
+{
+ struct rtgui_container parent;
+
+ int border_style;
+};
+typedef struct rtgui_panel rtgui_panel_t;
+
+rtgui_panel_t* rtgui_panel_create(int border_style);
+void rtgui_panel_destroy(rtgui_panel_t* panel);
+
+rt_bool_t rtgui_panel_event_handler(struct rtgui_object* object, struct rtgui_event* event);
+
+#endif
diff --git a/components/rtgui/include/rtgui/widgets/textbox.h b/components/rtgui/include/rtgui/widgets/textbox.h
index 972e80a579..55d74bf109 100644
--- a/components/rtgui/include/rtgui/widgets/textbox.h
+++ b/components/rtgui/include/rtgui/widgets/textbox.h
@@ -14,32 +14,34 @@
#ifndef __RTGUI_TEXTBOX_H__
#define __RTGUI_TEXTBOX_H__
-#include <rtgui/rtgui.h>
+#include <rtgui/rtgui_system.h>
#include <rtgui/widgets/widget.h>
+#include <rtgui/widgets/container.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
DECLARE_CLASS_TYPE(textbox);
+
/** Gets the type of a textbox */
#define RTGUI_TEXTBOX_TYPE (RTGUI_TYPE(textbox))
-/** Casts the object to a rtgui_textbox */
+/** Casts the object to a rtgui_textbox_t */
#define RTGUI_TEXTBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_TEXTBOX_TYPE, rtgui_textbox_t))
-/** Checks if the object is a rtgui_textbox */
+/** Checks if the object is a rtgui_textbox_t */
#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_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;
+#define RTGUI_TEXTBOX_SINGLE 0x00
+#define RTGUI_TEXTBOX_MULTI 0x01 /* multiline */
+#define RTGUI_TEXTBOX_MASK 0x02 /* ciphertext */
+#define RTGUI_TEXTBOX_DIGIT 0x04 /* digit */
+#define RTGUI_TEXTBOX_CARET_SHOW 0x10
+#define RTGUI_TEXTBOX_CARET_STAT 0x20 /* unused */
- struct rtgui_textbox_line *prev, *next;
-};
+#define RTGUI_TEXTBOX_LINE_MAX 128 /* text line cache */
struct rtgui_textbox
{
@@ -47,22 +49,24 @@ struct rtgui_textbox
struct rtgui_widget parent;
/* text box flag */
- rt_uint8_t flag;
+ rt_uint32_t flag;
/* current line and position */
rt_uint16_t line, line_begin, position, line_length;
-
+ rt_uint16_t dis_length; /*may be display length.*/
char* text;
rt_size_t font_width;
- struct rtgui_timer* caret_timer;
+ rtgui_timer_t *caret_timer;
+ rtgui_color_t *caret;
+ rtgui_rect_t caret_rect;
- /* widget private data */
- rt_bool_t (*on_enter) (struct rtgui_widget* widget, struct rtgui_event* event);
+ /* textbox private data */
+ rt_bool_t (*on_enter) (struct rtgui_textbox *box, rtgui_event_t* event);
};
typedef struct rtgui_textbox rtgui_textbox_t;
-struct rtgui_textbox* rtgui_textbox_create(const char* text, rt_uint8_t flag);
+struct rtgui_textbox* rtgui_textbox_create(const char* text, rt_uint32_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);
@@ -72,4 +76,11 @@ const char* rtgui_textbox_get_value(struct rtgui_textbox* box);
void rtgui_textbox_set_line_length(struct rtgui_textbox* box, rt_size_t length);
+void rtgui_textbox_get_edit_rect(struct rtgui_textbox *box,rtgui_rect_t *rect);
+
+void rtgui_textbox_ondraw(rtgui_textbox_t* box);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/components/rtgui/include/rtgui/widgets/widget.h b/components/rtgui/include/rtgui/widgets/widget.h
index 7d747e677c..9b8fd439e9 100644
--- a/components/rtgui/include/rtgui/widgets/widget.h
+++ b/components/rtgui/include/rtgui/widgets/widget.h
@@ -26,16 +26,16 @@ extern "C" {
#endif
#define RTGUI_WIDGET_FLAG_DEFAULT 0x0000
-#define RTGUI_WIDGET_FLAG_HIDE 0x0001
+#define RTGUI_WIDGET_FLAG_SHOWN 0x0001
#define RTGUI_WIDGET_FLAG_DISABLE 0x0002
#define RTGUI_WIDGET_FLAG_FOCUS 0x0004
#define RTGUI_WIDGET_FLAG_TRANSPARENT 0x0008
#define RTGUI_WIDGET_FLAG_FOCUSABLE 0x0010
#define RTGUI_WIDGET_FLAG_DC_VISIBLE 0x0100
-#define RTGUI_WIDGET_UNHIDE(w) (w)->flag &= ~RTGUI_WIDGET_FLAG_HIDE
-#define RTGUI_WIDGET_HIDE(w) (w)->flag |= RTGUI_WIDGET_FLAG_HIDE
-#define RTGUI_WIDGET_IS_HIDE(w) ((w)->flag & RTGUI_WIDGET_FLAG_HIDE)
+#define RTGUI_WIDGET_UNHIDE(w) (w)->flag |= RTGUI_WIDGET_FLAG_SHOWN
+#define RTGUI_WIDGET_HIDE(w) (w)->flag &= ~RTGUI_WIDGET_FLAG_SHOWN
+#define RTGUI_WIDGET_IS_HIDE(w) (!((w)->flag & RTGUI_WIDGET_FLAG_SHOWN))
#define RTGUI_WIDGET_ENABLE(w) (w)->flag &= ~RTGUI_WIDGET_FLAG_DISABLE
#define RTGUI_WIDGET_DISABLE(w) (w)->flag |= RTGUI_WIDGET_FLAG_DISABLE
@@ -52,12 +52,13 @@ extern "C" {
#define RTGUI_WIDGET_DC_SET_UNVISIBLE(w) (w)->flag &= ~RTGUI_WIDGET_FLAG_DC_VISIBLE
#define RTGUI_WIDGET_DC(w) ((struct rtgui_dc*)&((w)->dc_type))
-/* get rtgui widget object */
-#define RTGUI_WIDGET_FOREGROUND(w) ((w)->gc.foreground)
-#define RTGUI_WIDGET_BACKGROUND(w) ((w)->gc.background)
-#define RTGUI_WIDGET_TEXTALIGN(w) ((w)->gc.textalign)
-#define RTGUI_WIDGET_FONT(w) ((w)->gc.font)
-#define RTGUI_WIDGET_FLAG(w) ((w)->flag)
+/* rtgui widget attribute */
+#define RTGUI_WIDGET_FOREGROUND(w) (RTGUI_WIDGET(w)->gc.foreground)
+#define RTGUI_WIDGET_BACKGROUND(w) (RTGUI_WIDGET(w)->gc.background)
+#define RTGUI_WIDGET_TEXTALIGN(w) (RTGUI_WIDGET(w)->gc.textalign)
+#define RTGUI_WIDGET_FONT(w) (RTGUI_WIDGET(w)->gc.font)
+#define RTGUI_WIDGET_FLAG(w) (RTGUI_WIDGET(w)->flag)
+#define RTGUI_WIDGET_ALIGN(w) (RTGUI_WIDGET(w)->align)
DECLARE_CLASS_TYPE(widget);
@@ -96,14 +97,10 @@ struct rtgui_widget
/* the widget extent */
rtgui_rect_t extent;
-#ifndef RTGUI_USING_SMALL_SIZE
/* minimal width and height of widget */
rt_int16_t mini_width, mini_height;
- rt_int16_t margin, margin_style;
-
/* widget align */
rt_int32_t align;
-#endif
/* the rect clip */
rtgui_region_t clip;
@@ -189,7 +186,9 @@ void rtgui_widget_update_clip(rtgui_widget_t* widget);
struct rtgui_win* rtgui_widget_get_toplevel(rtgui_widget_t* widget);
void rtgui_widget_show(rtgui_widget_t* widget);
+rt_bool_t rtgui_widget_onshow(struct rtgui_object *object, struct rtgui_event *event);
void rtgui_widget_hide(rtgui_widget_t* widget);
+rt_bool_t rtgui_widget_onhide(struct rtgui_object *object, struct rtgui_event *event);
void rtgui_widget_update(rtgui_widget_t* widget);
/* get parent color */
diff --git a/components/rtgui/include/rtgui/widgets/window.h b/components/rtgui/include/rtgui/widgets/window.h
index deb4378a36..ac3c2e7e36 100644
--- a/components/rtgui/include/rtgui/widgets/window.h
+++ b/components/rtgui/include/rtgui/widgets/window.h
@@ -37,16 +37,8 @@ DECLARE_CLASS_TYPE(win);
#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_ONTOP 0x040 /* window is in the top layer */
+#define RTGUI_WIN_STYLE_ONBTM 0x080 /* window is in the bottom layer */
#define RTGUI_WIN_STYLE_DEFAULT (RTGUI_WIN_STYLE_CLOSEBOX | RTGUI_WIN_STYLE_MINIBOX)
@@ -84,7 +76,7 @@ struct rtgui_win
/* the widget that will grab the focus in current window */
struct rtgui_widget *focused_widget;
- /* top window style */
+ /* window style */
rt_uint16_t style;
/* window state flag */
@@ -133,7 +125,7 @@ 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_err_t rtgui_win_activate(struct rtgui_win *win);
rt_bool_t rtgui_win_is_activated(struct rtgui_win* win);
void rtgui_win_move(struct rtgui_win* win, int x, int y);