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
This commit is contained in:
chaos.proton@gmail.com
2012-07-20 12:37:56 +00:00
parent c2868be90d
commit 92a50c838d
78 changed files with 3650 additions and 2263 deletions
+1
View File
@@ -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
+25
View File
@@ -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)
{
+1
View File
@@ -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);
+47
View File
@@ -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;
@@ -151,6 +176,16 @@ struct rtgui_event_win_resize
#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 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
*/
@@ -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;
+1 -1
View File
@@ -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
@@ -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 */
@@ -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 */
@@ -77,5 +77,6 @@
//#define RTGUI_USING_DESKTOP_WINDOW
#define RTGUI_EVENT_DEBUG
#undef RTGUI_USING_SMALL_SIZE
// #undef RTGUI_USING_SMALL_SIZE
#endif
@@ -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);
@@ -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;
@@ -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
@@ -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
+5 -8
View File
@@ -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
@@ -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);
@@ -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);
@@ -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;
@@ -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
@@ -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
#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
{
char* line_text;
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
+13 -14
View File
@@ -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 */
@@ -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);