mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-06-13 12:43:56 +08:00
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
This commit is contained in:
+81
-83
@@ -1,83 +1,81 @@
|
||||
Import('RTT_ROOT')
|
||||
from building import *
|
||||
|
||||
common_src = Split("""
|
||||
common/blit.c
|
||||
common/color.c
|
||||
common/region.c
|
||||
common/rtgui_object.c
|
||||
common/rtgui_system.c
|
||||
common/rtgui_theme.c
|
||||
common/rtgui_xml.c
|
||||
common/dc.c
|
||||
common/dc_hw.c
|
||||
common/dc_buffer.c
|
||||
common/dc_client.c
|
||||
common/filerw.c
|
||||
common/image.c
|
||||
common/image_xpm.c
|
||||
common/image_hdc.c
|
||||
common/image_bmp.c
|
||||
common/image_png.c
|
||||
common/image_jpg.c
|
||||
common/image_container.c
|
||||
common/font.c
|
||||
common/font_bmp.c
|
||||
common/font_hz_file.c
|
||||
common/font_hz_bmp.c
|
||||
common/asc12font.c
|
||||
common/asc16font.c
|
||||
common/hz12font.c
|
||||
common/hz16font.c
|
||||
common/framebuffer_driver.c
|
||||
common/pixel_driver.c
|
||||
""")
|
||||
|
||||
server_src = Split("""
|
||||
server/driver.c
|
||||
server/mouse.c
|
||||
server/panel.c
|
||||
server/server.c
|
||||
server/topwin.c
|
||||
""")
|
||||
|
||||
widgets_src = Split("""
|
||||
widgets/box.c
|
||||
widgets/button.c
|
||||
widgets/checkbox.c
|
||||
widgets/container.c
|
||||
widgets/combobox.c
|
||||
widgets/iconbox.c
|
||||
widgets/label.c
|
||||
widgets/textview.c
|
||||
widgets/listctrl.c
|
||||
widgets/menu.c
|
||||
widgets/progressbar.c
|
||||
widgets/radiobox.c
|
||||
widgets/slider.c
|
||||
widgets/scrollbar.c
|
||||
widgets/staticline.c
|
||||
widgets/textbox.c
|
||||
widgets/listbox.c
|
||||
widgets/title.c
|
||||
widgets/toplevel.c
|
||||
widgets/notebook.c
|
||||
widgets/view.c
|
||||
widgets/list_view.c
|
||||
widgets/about_view.c
|
||||
widgets/filelist_view.c
|
||||
widgets/widget.c
|
||||
widgets/window.c
|
||||
widgets/workbench.c
|
||||
""")
|
||||
|
||||
# The set of source files associated with this SConscript file.
|
||||
src = common_src + server_src + widgets_src
|
||||
|
||||
path = [RTT_ROOT + '/components/rtgui/include',
|
||||
RTT_ROOT + '/components/rtgui/common',
|
||||
RTT_ROOT + '/components/rtgui/server',
|
||||
RTT_ROOT + '/components/rtgui/widgets']
|
||||
group = DefineGroup('RTGUI', src, depend = ['RT_USING_RTGUI'], CPPPATH = path)
|
||||
|
||||
Return('group')
|
||||
Import('RTT_ROOT')
|
||||
from building import *
|
||||
|
||||
common_src = Split("""
|
||||
common/blit.c
|
||||
common/color.c
|
||||
common/region.c
|
||||
common/rtgui_object.c
|
||||
common/rtgui_system.c
|
||||
common/rtgui_theme.c
|
||||
common/rtgui_xml.c
|
||||
common/dc.c
|
||||
common/dc_hw.c
|
||||
common/dc_buffer.c
|
||||
common/dc_client.c
|
||||
common/filerw.c
|
||||
common/image.c
|
||||
common/image_xpm.c
|
||||
common/image_hdc.c
|
||||
common/image_bmp.c
|
||||
common/image_png.c
|
||||
common/image_jpg.c
|
||||
common/image_container.c
|
||||
common/font.c
|
||||
common/font_bmp.c
|
||||
common/font_hz_file.c
|
||||
common/font_hz_bmp.c
|
||||
common/asc12font.c
|
||||
common/asc16font.c
|
||||
common/hz12font.c
|
||||
common/hz16font.c
|
||||
common/framebuffer_driver.c
|
||||
common/pixel_driver.c
|
||||
""")
|
||||
|
||||
server_src = Split("""
|
||||
server/rtgui_application.c
|
||||
server/driver.c
|
||||
server/mouse.c
|
||||
server/server.c
|
||||
server/topwin.c
|
||||
""")
|
||||
|
||||
widgets_src = Split("""
|
||||
widgets/box.c
|
||||
widgets/button.c
|
||||
widgets/checkbox.c
|
||||
widgets/combobox.c
|
||||
widgets/iconbox.c
|
||||
widgets/label.c
|
||||
widgets/textview.c
|
||||
widgets/listctrl.c
|
||||
widgets/menu.c
|
||||
widgets/progressbar.c
|
||||
widgets/radiobox.c
|
||||
widgets/slider.c
|
||||
widgets/scrollbar.c
|
||||
widgets/staticline.c
|
||||
widgets/textbox.c
|
||||
widgets/listbox.c
|
||||
widgets/title.c
|
||||
widgets/toplevel.c
|
||||
widgets/notebook.c
|
||||
widgets/container.c
|
||||
widgets/list_view.c
|
||||
widgets/about_view.c
|
||||
widgets/filelist_view.c
|
||||
widgets/widget.c
|
||||
widgets/window.c
|
||||
""")
|
||||
|
||||
# The set of source files associated with this SConscript file.
|
||||
src = common_src + server_src + widgets_src
|
||||
|
||||
path = [RTT_ROOT + '/components/rtgui/include',
|
||||
RTT_ROOT + '/components/rtgui/common',
|
||||
RTT_ROOT + '/components/rtgui/server',
|
||||
RTT_ROOT + '/components/rtgui/widgets']
|
||||
group = DefineGroup('RTGUI', src, depend = ['RT_USING_RTGUI'], CPPPATH = path)
|
||||
|
||||
Return('group')
|
||||
|
||||
+284
-284
File diff suppressed because it is too large
Load Diff
@@ -21,9 +21,10 @@
|
||||
|
||||
#include <rtgui/driver.h>
|
||||
#include <rtgui/rtgui_system.h>
|
||||
#include <rtgui/widgets/view.h>
|
||||
#include <rtgui/rtgui_application.h>
|
||||
#include <rtgui/rtgui_server.h>
|
||||
#include <rtgui/widgets/container.h>
|
||||
#include <rtgui/widgets/window.h>
|
||||
#include <rtgui/widgets/workbench.h>
|
||||
#include <rtgui/widgets/title.h>
|
||||
|
||||
static void rtgui_dc_client_draw_point(struct rtgui_dc* dc, int x, int y);
|
||||
@@ -48,14 +49,11 @@ struct rtgui_dc* rtgui_dc_begin_drawing(rtgui_widget_t* owner)
|
||||
{
|
||||
RT_ASSERT(owner != RT_NULL);
|
||||
|
||||
if ((rtgui_region_is_flat(&owner->clip) == RT_EOK) &&
|
||||
if ((rtgui_region_is_flat(&owner->clip) == RT_EOK) &&
|
||||
rtgui_rect_is_equal(&(owner->extent), &(owner->clip.extents)) == RT_EOK)
|
||||
{
|
||||
/* use hardware DC */
|
||||
return rtgui_dc_hw_create(owner);
|
||||
}
|
||||
|
||||
return rtgui_dc_client_create(owner);
|
||||
else
|
||||
return rtgui_dc_client_create(owner);
|
||||
}
|
||||
|
||||
void rtgui_dc_end_drawing(struct rtgui_dc* dc)
|
||||
@@ -63,7 +61,7 @@ void rtgui_dc_end_drawing(struct rtgui_dc* dc)
|
||||
dc->engine->fini(dc);
|
||||
}
|
||||
|
||||
const struct rtgui_dc_engine dc_client_engine =
|
||||
const struct rtgui_dc_engine dc_client_engine =
|
||||
{
|
||||
rtgui_dc_client_draw_point,
|
||||
rtgui_dc_client_draw_color_point,
|
||||
@@ -116,7 +114,7 @@ struct rtgui_dc* rtgui_dc_client_create(rtgui_widget_t* owner)
|
||||
if (RTGUI_WIDGET_IS_HIDE(widget))
|
||||
{
|
||||
RTGUI_WIDGET_DC_SET_UNVISIBLE(owner);
|
||||
break;
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
widget = widget->parent;
|
||||
@@ -130,7 +128,7 @@ struct rtgui_dc* rtgui_dc_client_create(rtgui_widget_t* owner)
|
||||
if (top->drawing == 1)
|
||||
{
|
||||
#ifdef RTGUI_USING_MOUSE_CURSOR
|
||||
#ifdef __WIN32__
|
||||
#ifdef _WIN32
|
||||
rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER);
|
||||
rt_kprintf("hide cursor\n");
|
||||
rtgui_mouse_hide_cursor();
|
||||
@@ -141,15 +139,18 @@ struct rtgui_dc* rtgui_dc_client_create(rtgui_widget_t* owner)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (RTGUI_IS_WORKBENCH(owner->toplevel) ||
|
||||
RTGUI_IS_WIN(owner->toplevel))
|
||||
else if (RTGUI_IS_APPLICATION(owner->toplevel))
|
||||
{
|
||||
RT_ASSERT(0);
|
||||
}
|
||||
else if (RTGUI_IS_WIN(owner->toplevel))
|
||||
{
|
||||
rtgui_toplevel_t* top = RTGUI_TOPLEVEL(owner->toplevel);
|
||||
top->drawing ++;
|
||||
|
||||
if (top->drawing == 1)
|
||||
{
|
||||
#ifdef __WIN32__
|
||||
#ifdef _WIN32
|
||||
#ifdef RTGUI_USING_MOUSE_CURSOR
|
||||
rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER);
|
||||
rt_kprintf("hide cursor\n");
|
||||
@@ -161,7 +162,7 @@ struct rtgui_dc* rtgui_dc_client_create(rtgui_widget_t* owner)
|
||||
RTGUI_EVENT_UPDATE_BEGIN_INIT(&(eupdate));
|
||||
eupdate.rect = RTGUI_WIDGET(top)->extent;
|
||||
|
||||
rtgui_thread_send(top->server, (struct rtgui_event*)&eupdate, sizeof(eupdate));
|
||||
rtgui_server_post_event((struct rtgui_event*)&eupdate, sizeof(eupdate));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -186,7 +187,7 @@ static rt_bool_t rtgui_dc_client_fini(struct rtgui_dc* dc)
|
||||
top->drawing --;
|
||||
if ((top->drawing == 0) && RTGUI_WIDGET_IS_DC_VISIBLE(owner))
|
||||
{
|
||||
#ifdef __WIN32__
|
||||
#ifdef _WIN32
|
||||
#ifdef RTGUI_USING_MOUSE_CURSOR
|
||||
rt_mutex_release(&cursor_mutex);
|
||||
/* show cursor */
|
||||
@@ -206,7 +207,7 @@ static rt_bool_t rtgui_dc_client_fini(struct rtgui_dc* dc)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (RTGUI_IS_WORKBENCH(owner->toplevel) ||
|
||||
else if (RTGUI_IS_APPLICATION(owner->toplevel) ||
|
||||
RTGUI_IS_WIN(owner->toplevel))
|
||||
{
|
||||
rtgui_toplevel_t* top = RTGUI_TOPLEVEL(owner->toplevel);
|
||||
@@ -214,7 +215,7 @@ static rt_bool_t rtgui_dc_client_fini(struct rtgui_dc* dc)
|
||||
|
||||
if ((top->drawing == 0) && RTGUI_WIDGET_IS_DC_VISIBLE(owner))
|
||||
{
|
||||
#ifdef __WIN32__
|
||||
#ifdef _WIN32
|
||||
#ifdef RTGUI_USING_MOUSE_CURSOR
|
||||
rt_mutex_release(&cursor_mutex);
|
||||
/* show cursor */
|
||||
@@ -229,7 +230,7 @@ static rt_bool_t rtgui_dc_client_fini(struct rtgui_dc* dc)
|
||||
RTGUI_EVENT_UPDATE_END_INIT(&(eupdate));
|
||||
eupdate.rect = owner->extent;
|
||||
|
||||
rtgui_thread_send(top->server, (struct rtgui_event*)&eupdate, sizeof(eupdate));
|
||||
rtgui_server_post_event((struct rtgui_event*)&eupdate, sizeof(eupdate));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
#include <rtgui/dc_hw.h>
|
||||
#include <rtgui/driver.h>
|
||||
#include <rtgui/rtgui_system.h>
|
||||
#include <rtgui/widgets/view.h>
|
||||
#include <rtgui/rtgui_application.h>
|
||||
#include <rtgui/rtgui_server.h>
|
||||
|
||||
#include <rtgui/widgets/container.h>
|
||||
#include <rtgui/widgets/window.h>
|
||||
#include <rtgui/widgets/workbench.h>
|
||||
#include <rtgui/widgets/title.h>
|
||||
|
||||
static void rtgui_dc_hw_draw_point(struct rtgui_dc* dc, int x, int y);
|
||||
@@ -81,7 +83,7 @@ struct rtgui_dc* rtgui_dc_hw_create(rtgui_widget_t* owner)
|
||||
if (RTGUI_WIDGET_IS_HIDE(widget))
|
||||
{
|
||||
RTGUI_WIDGET_DC_SET_UNVISIBLE(owner);
|
||||
break;
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
widget = widget->parent;
|
||||
@@ -104,7 +106,7 @@ struct rtgui_dc* rtgui_dc_hw_create(rtgui_widget_t* owner)
|
||||
if (top->drawing == 1)
|
||||
{
|
||||
#ifdef RTGUI_USING_MOUSE_CURSOR
|
||||
#ifdef __WIN32__
|
||||
#ifdef _WIN32
|
||||
rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER);
|
||||
rt_kprintf("hide cursor\n");
|
||||
rtgui_mouse_hide_cursor();
|
||||
@@ -115,7 +117,7 @@ struct rtgui_dc* rtgui_dc_hw_create(rtgui_widget_t* owner)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (RTGUI_IS_WORKBENCH(owner->toplevel) ||
|
||||
else if (RTGUI_IS_APPLICATION(owner->toplevel) ||
|
||||
RTGUI_IS_WIN(owner->toplevel))
|
||||
{
|
||||
rtgui_toplevel_t* top = RTGUI_TOPLEVEL(owner->toplevel);
|
||||
@@ -123,7 +125,7 @@ struct rtgui_dc* rtgui_dc_hw_create(rtgui_widget_t* owner)
|
||||
|
||||
if (top->drawing == 1)
|
||||
{
|
||||
#ifdef __WIN32__
|
||||
#ifdef _WIN32
|
||||
#ifdef RTGUI_USING_MOUSE_CURSOR
|
||||
rt_mutex_take(&cursor_mutex, RT_WAITING_FOREVER);
|
||||
rt_kprintf("hide cursor\n");
|
||||
@@ -135,7 +137,7 @@ struct rtgui_dc* rtgui_dc_hw_create(rtgui_widget_t* owner)
|
||||
RTGUI_EVENT_UPDATE_BEGIN_INIT(&(eupdate));
|
||||
eupdate.rect = RTGUI_WIDGET(top)->extent;
|
||||
|
||||
rtgui_thread_send(top->server, (struct rtgui_event*)&eupdate, sizeof(eupdate));
|
||||
rtgui_server_post_event((struct rtgui_event*)&eupdate, sizeof(eupdate));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -162,7 +164,7 @@ static rt_bool_t rtgui_dc_hw_fini(struct rtgui_dc* dc)
|
||||
top->drawing --;
|
||||
if ((top->drawing == 0) && RTGUI_WIDGET_IS_DC_VISIBLE(owner))
|
||||
{
|
||||
#ifdef __WIN32__
|
||||
#ifdef _WIN32
|
||||
#ifdef RTGUI_USING_MOUSE_CURSOR
|
||||
rt_mutex_release(&cursor_mutex);
|
||||
/* show cursor */
|
||||
@@ -182,7 +184,7 @@ static rt_bool_t rtgui_dc_hw_fini(struct rtgui_dc* dc)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (RTGUI_IS_WORKBENCH(owner->toplevel) ||
|
||||
else if (RTGUI_IS_APPLICATION(owner->toplevel) ||
|
||||
RTGUI_IS_WIN(owner->toplevel))
|
||||
{
|
||||
rtgui_toplevel_t* top = RTGUI_TOPLEVEL(owner->toplevel);
|
||||
@@ -190,7 +192,7 @@ static rt_bool_t rtgui_dc_hw_fini(struct rtgui_dc* dc)
|
||||
|
||||
if ((top->drawing == 0) && RTGUI_WIDGET_IS_DC_VISIBLE(owner))
|
||||
{
|
||||
#ifdef __WIN32__
|
||||
#ifdef _WIN32
|
||||
#ifdef RTGUI_USING_MOUSE_CURSOR
|
||||
rt_mutex_release(&cursor_mutex);
|
||||
/* show cursor */
|
||||
@@ -205,7 +207,7 @@ static rt_bool_t rtgui_dc_hw_fini(struct rtgui_dc* dc)
|
||||
RTGUI_EVENT_UPDATE_END_INIT(&(eupdate));
|
||||
eupdate.rect = owner->extent;
|
||||
|
||||
rtgui_thread_send(top->server, (struct rtgui_event*)&eupdate, sizeof(eupdate));
|
||||
rtgui_server_post_event((struct rtgui_event*)&eupdate, sizeof(eupdate));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
+463
-463
File diff suppressed because it is too large
Load Diff
@@ -1,237 +1,237 @@
|
||||
#include <rtgui/font_freetype.h>
|
||||
|
||||
#ifdef RTGUI_USING_TTF
|
||||
#include <ft2build.h>
|
||||
#include <freetype/freetype.h>
|
||||
#include <freetype/ftglyph.h>
|
||||
|
||||
static void rtgui_freetype_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect);
|
||||
static void rtgui_freetype_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect);
|
||||
|
||||
struct rtgui_font_engine freetype_font_engine =
|
||||
{
|
||||
RT_NULL,
|
||||
RT_NULL,
|
||||
rtgui_freetype_font_draw_text,
|
||||
rtgui_freetype_font_get_metrics
|
||||
};
|
||||
|
||||
struct rtgui_freetype_font
|
||||
{
|
||||
int bold;
|
||||
int italic;
|
||||
|
||||
FT_Face face;
|
||||
FT_Library library;
|
||||
};
|
||||
|
||||
static void gbk_to_unicode(rt_uint16_t *unicode, const unsigned char *text, int len)
|
||||
{
|
||||
int i;
|
||||
unsigned short wch;
|
||||
extern unsigned short ff_convert(unsigned short wch, int direction);
|
||||
|
||||
for (i = 0; i < len; )
|
||||
{
|
||||
if (*text < 0x80)
|
||||
{
|
||||
wch = *text;
|
||||
*unicode = ff_convert(wch, 1);
|
||||
text ++;
|
||||
i ++;
|
||||
}
|
||||
else
|
||||
{
|
||||
wch = wch = *(text + 1) | (*text << 8);
|
||||
*unicode = ff_convert(wch, 1);
|
||||
text += 2;
|
||||
i += 2;
|
||||
}
|
||||
|
||||
unicode ++;
|
||||
}
|
||||
|
||||
*unicode = '\0';
|
||||
}
|
||||
|
||||
static void rtgui_freetype_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect)
|
||||
{
|
||||
int index = 0;
|
||||
FT_Error err = 0;
|
||||
rt_uint16_t *text_short, *text_ptr;
|
||||
struct rtgui_freetype_font* freetype;
|
||||
|
||||
RT_ASSERT(font != RT_NULL);
|
||||
freetype = (struct rtgui_freetype_font*) font->data;
|
||||
RT_ASSERT(freetype != RT_NULL);
|
||||
|
||||
/* allocate unicode buffer */
|
||||
text_short = (rt_uint16_t*)rtgui_malloc((len + 1)* 2);
|
||||
if (text_short == RT_NULL) return ; /* out of memory */
|
||||
|
||||
/* convert gbk to unicode */
|
||||
gbk_to_unicode(text_short, text, len);
|
||||
text_ptr = text_short;
|
||||
|
||||
while (*text_ptr)
|
||||
{
|
||||
index = FT_Get_Char_Index(freetype->face, *text_ptr);
|
||||
err = FT_Load_Glyph(freetype->face, index, FT_LOAD_DEFAULT|FT_LOAD_RENDER);
|
||||
if (err == 0)
|
||||
{
|
||||
int rows, x;
|
||||
rt_uint8_t* ptr;
|
||||
|
||||
/* render font */
|
||||
ptr = (rt_uint8_t*)freetype->face->glyph->bitmap.buffer;
|
||||
|
||||
for (rows = 0; rows < freetype->face->glyph->bitmap.rows; rows ++)
|
||||
for (x = 0; x < freetype->face->glyph->bitmap.width; x++)
|
||||
{
|
||||
if (*ptr > 0)
|
||||
rtgui_dc_draw_color_point(dc, rect->x1 + x, rect->y1 + rows, RTGUI_RGB(0xff - *ptr, 0xff - *ptr, 0xff - *ptr));
|
||||
ptr ++;
|
||||
}
|
||||
}
|
||||
|
||||
text_ptr ++;
|
||||
rect->x1 += freetype->face->glyph->bitmap.width;
|
||||
}
|
||||
|
||||
/* release unicode buffer */
|
||||
rtgui_free(text_short);
|
||||
}
|
||||
|
||||
static void rtgui_freetype_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect)
|
||||
{
|
||||
int index = 0, len;
|
||||
FT_Error err = 0;
|
||||
rt_uint16_t w = 0, h = 0;
|
||||
rt_uint16_t *text_short, *text_ptr;
|
||||
struct rtgui_freetype_font* freetype;
|
||||
|
||||
RT_ASSERT(font != RT_NULL);
|
||||
RT_ASSERT(rect != RT_NULL);
|
||||
freetype = (struct rtgui_freetype_font*) font->data;
|
||||
RT_ASSERT(freetype != RT_NULL);
|
||||
|
||||
len = strlen(text);
|
||||
memset(rect, 0, sizeof(struct rtgui_rect));
|
||||
|
||||
/* allocate unicode buffer */
|
||||
text_short = (rt_uint16_t*)rtgui_malloc((len + 1)* 2);
|
||||
if (text_short == RT_NULL) return ; /* out of memory */
|
||||
|
||||
/* convert gbk to unicode */
|
||||
gbk_to_unicode(text_short, text, len);
|
||||
text_ptr = text_short;
|
||||
|
||||
while (*text_ptr)
|
||||
{
|
||||
index = FT_Get_Char_Index(freetype->face, *text_ptr);
|
||||
err = FT_Load_Glyph(freetype->face, index, FT_LOAD_DEFAULT);
|
||||
|
||||
if (err == 0)
|
||||
{
|
||||
w += freetype->face->glyph->bitmap.width;
|
||||
if (freetype->face->glyph->bitmap.rows > h)
|
||||
{
|
||||
h = freetype->face->glyph->bitmap.rows;
|
||||
}
|
||||
}
|
||||
|
||||
text_ptr ++;
|
||||
}
|
||||
|
||||
rect->x1 = 0; rect->y1 = 0;
|
||||
rect->x2 = w; rect->y2 = h;
|
||||
|
||||
/* release unicode buffer */
|
||||
rtgui_free(text_short);
|
||||
}
|
||||
|
||||
rtgui_font_t* rtgui_freetype_font_create(const char* filename, int bold, int italic, rt_size_t size)
|
||||
{
|
||||
FT_Error err = 0;
|
||||
struct rtgui_font* font;
|
||||
|
||||
font = (struct rtgui_font*) rtgui_malloc (sizeof(struct rtgui_font));
|
||||
if (font != RT_NULL)
|
||||
{
|
||||
struct rtgui_freetype_font* freetype;
|
||||
|
||||
freetype = (struct rtgui_freetype_font*) rtgui_malloc (sizeof(struct rtgui_freetype_font));
|
||||
if (freetype == RT_NULL)
|
||||
{
|
||||
rt_free(font);
|
||||
font = RT_NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
err = FT_Init_FreeType(&freetype->library);
|
||||
if((err = FT_New_Face(freetype->library, filename, 0, &freetype->face)))
|
||||
{
|
||||
FT_Done_FreeType(freetype->library);
|
||||
|
||||
rt_free(font);
|
||||
font = RT_NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
err = FT_Select_Charmap(freetype->face, ft_encoding_unicode);
|
||||
if(err)
|
||||
{
|
||||
err = FT_Select_Charmap(freetype->face, ft_encoding_latin_1 );
|
||||
}
|
||||
|
||||
err = FT_Set_Pixel_Sizes(freetype->face, 0, size);
|
||||
if (err != 0)
|
||||
{
|
||||
rtgui_free(font);
|
||||
font = RT_NULL;
|
||||
|
||||
FT_Done_FreeType(freetype->library);
|
||||
rtgui_free(freetype);
|
||||
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
freetype->bold = bold;
|
||||
freetype->italic = italic;
|
||||
|
||||
rt_kprintf("fonfile:%s\n", filename);
|
||||
rt_kprintf("font family_name:%s\n", freetype->face->family_name);
|
||||
rt_kprintf("font style_name:%s\n", freetype->face->style_name);
|
||||
|
||||
/* set user data */
|
||||
font->data = freetype;
|
||||
font->family = rt_strdup(freetype->face->family_name);
|
||||
font->height = (rt_uint16_t)size;
|
||||
font->refer_count = 0;
|
||||
font->engine = &freetype_font_engine;
|
||||
|
||||
/* add to system */
|
||||
rtgui_font_system_add_font(font);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
void rtgui_freetype_font_destroy(rtgui_font_t* font)
|
||||
{
|
||||
struct rtgui_freetype_font* freetype;
|
||||
|
||||
RT_ASSERT(font != RT_NULL);
|
||||
freetype = (struct rtgui_freetype_font*) font->data;
|
||||
RT_ASSERT(freetype != RT_NULL);
|
||||
|
||||
rtgui_font_system_remove_font(font);
|
||||
|
||||
FT_Done_Face (freetype->face);
|
||||
FT_Done_FreeType(freetype->library);
|
||||
rtgui_free(freetype);
|
||||
rtgui_free(font);
|
||||
}
|
||||
#endif
|
||||
#include <rtgui/font_freetype.h>
|
||||
|
||||
#ifdef RTGUI_USING_TTF
|
||||
#include <ft2build.h>
|
||||
#include <freetype/freetype.h>
|
||||
#include <freetype/ftglyph.h>
|
||||
|
||||
static void rtgui_freetype_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect);
|
||||
static void rtgui_freetype_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect);
|
||||
|
||||
struct rtgui_font_engine freetype_font_engine =
|
||||
{
|
||||
RT_NULL,
|
||||
RT_NULL,
|
||||
rtgui_freetype_font_draw_text,
|
||||
rtgui_freetype_font_get_metrics
|
||||
};
|
||||
|
||||
struct rtgui_freetype_font
|
||||
{
|
||||
int bold;
|
||||
int italic;
|
||||
|
||||
FT_Face face;
|
||||
FT_Library library;
|
||||
};
|
||||
|
||||
static void gbk_to_unicode(rt_uint16_t *unicode, const unsigned char *text, int len)
|
||||
{
|
||||
int i;
|
||||
unsigned short wch;
|
||||
extern unsigned short ff_convert(unsigned short wch, int direction);
|
||||
|
||||
for (i = 0; i < len; )
|
||||
{
|
||||
if (*text < 0x80)
|
||||
{
|
||||
wch = *text;
|
||||
*unicode = ff_convert(wch, 1);
|
||||
text ++;
|
||||
i ++;
|
||||
}
|
||||
else
|
||||
{
|
||||
wch = wch = *(text + 1) | (*text << 8);
|
||||
*unicode = ff_convert(wch, 1);
|
||||
text += 2;
|
||||
i += 2;
|
||||
}
|
||||
|
||||
unicode ++;
|
||||
}
|
||||
|
||||
*unicode = '\0';
|
||||
}
|
||||
|
||||
static void rtgui_freetype_font_draw_text(struct rtgui_font* font, struct rtgui_dc* dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect)
|
||||
{
|
||||
int index = 0;
|
||||
FT_Error err = 0;
|
||||
rt_uint16_t *text_short, *text_ptr;
|
||||
struct rtgui_freetype_font* freetype;
|
||||
|
||||
RT_ASSERT(font != RT_NULL);
|
||||
freetype = (struct rtgui_freetype_font*) font->data;
|
||||
RT_ASSERT(freetype != RT_NULL);
|
||||
|
||||
/* allocate unicode buffer */
|
||||
text_short = (rt_uint16_t*)rtgui_malloc((len + 1)* 2);
|
||||
if (text_short == RT_NULL) return ; /* out of memory */
|
||||
|
||||
/* convert gbk to unicode */
|
||||
gbk_to_unicode(text_short, text, len);
|
||||
text_ptr = text_short;
|
||||
|
||||
while (*text_ptr)
|
||||
{
|
||||
index = FT_Get_Char_Index(freetype->face, *text_ptr);
|
||||
err = FT_Load_Glyph(freetype->face, index, FT_LOAD_DEFAULT|FT_LOAD_RENDER);
|
||||
if (err == 0)
|
||||
{
|
||||
int rows, x;
|
||||
rt_uint8_t* ptr;
|
||||
|
||||
/* render font */
|
||||
ptr = (rt_uint8_t*)freetype->face->glyph->bitmap.buffer;
|
||||
|
||||
for (rows = 0; rows < freetype->face->glyph->bitmap.rows; rows ++)
|
||||
for (x = 0; x < freetype->face->glyph->bitmap.width; x++)
|
||||
{
|
||||
if (*ptr > 0)
|
||||
rtgui_dc_draw_color_point(dc, rect->x1 + x, rect->y1 + rows, RTGUI_RGB(0xff - *ptr, 0xff - *ptr, 0xff - *ptr));
|
||||
ptr ++;
|
||||
}
|
||||
}
|
||||
|
||||
text_ptr ++;
|
||||
rect->x1 += freetype->face->glyph->bitmap.width;
|
||||
}
|
||||
|
||||
/* release unicode buffer */
|
||||
rtgui_free(text_short);
|
||||
}
|
||||
|
||||
static void rtgui_freetype_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect)
|
||||
{
|
||||
int index = 0, len;
|
||||
FT_Error err = 0;
|
||||
rt_uint16_t w = 0, h = 0;
|
||||
rt_uint16_t *text_short, *text_ptr;
|
||||
struct rtgui_freetype_font* freetype;
|
||||
|
||||
RT_ASSERT(font != RT_NULL);
|
||||
RT_ASSERT(rect != RT_NULL);
|
||||
freetype = (struct rtgui_freetype_font*) font->data;
|
||||
RT_ASSERT(freetype != RT_NULL);
|
||||
|
||||
len = strlen(text);
|
||||
memset(rect, 0, sizeof(struct rtgui_rect));
|
||||
|
||||
/* allocate unicode buffer */
|
||||
text_short = (rt_uint16_t*)rtgui_malloc((len + 1)* 2);
|
||||
if (text_short == RT_NULL) return ; /* out of memory */
|
||||
|
||||
/* convert gbk to unicode */
|
||||
gbk_to_unicode(text_short, text, len);
|
||||
text_ptr = text_short;
|
||||
|
||||
while (*text_ptr)
|
||||
{
|
||||
index = FT_Get_Char_Index(freetype->face, *text_ptr);
|
||||
err = FT_Load_Glyph(freetype->face, index, FT_LOAD_DEFAULT);
|
||||
|
||||
if (err == 0)
|
||||
{
|
||||
w += freetype->face->glyph->bitmap.width;
|
||||
if (freetype->face->glyph->bitmap.rows > h)
|
||||
{
|
||||
h = freetype->face->glyph->bitmap.rows;
|
||||
}
|
||||
}
|
||||
|
||||
text_ptr ++;
|
||||
}
|
||||
|
||||
rect->x1 = 0; rect->y1 = 0;
|
||||
rect->x2 = w; rect->y2 = h;
|
||||
|
||||
/* release unicode buffer */
|
||||
rtgui_free(text_short);
|
||||
}
|
||||
|
||||
rtgui_font_t* rtgui_freetype_font_create(const char* filename, int bold, int italic, rt_size_t size)
|
||||
{
|
||||
FT_Error err = 0;
|
||||
struct rtgui_font* font;
|
||||
|
||||
font = (struct rtgui_font*) rtgui_malloc (sizeof(struct rtgui_font));
|
||||
if (font != RT_NULL)
|
||||
{
|
||||
struct rtgui_freetype_font* freetype;
|
||||
|
||||
freetype = (struct rtgui_freetype_font*) rtgui_malloc (sizeof(struct rtgui_freetype_font));
|
||||
if (freetype == RT_NULL)
|
||||
{
|
||||
rt_free(font);
|
||||
font = RT_NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
err = FT_Init_FreeType(&freetype->library);
|
||||
if((err = FT_New_Face(freetype->library, filename, 0, &freetype->face)))
|
||||
{
|
||||
FT_Done_FreeType(freetype->library);
|
||||
|
||||
rt_free(font);
|
||||
font = RT_NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
err = FT_Select_Charmap(freetype->face, ft_encoding_unicode);
|
||||
if(err)
|
||||
{
|
||||
err = FT_Select_Charmap(freetype->face, ft_encoding_latin_1 );
|
||||
}
|
||||
|
||||
err = FT_Set_Pixel_Sizes(freetype->face, 0, size);
|
||||
if (err != 0)
|
||||
{
|
||||
rtgui_free(font);
|
||||
font = RT_NULL;
|
||||
|
||||
FT_Done_FreeType(freetype->library);
|
||||
rtgui_free(freetype);
|
||||
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
freetype->bold = bold;
|
||||
freetype->italic = italic;
|
||||
|
||||
rt_kprintf("fonfile:%s\n", filename);
|
||||
rt_kprintf("font family_name:%s\n", freetype->face->family_name);
|
||||
rt_kprintf("font style_name:%s\n", freetype->face->style_name);
|
||||
|
||||
/* set user data */
|
||||
font->data = freetype;
|
||||
font->family = rt_strdup(freetype->face->family_name);
|
||||
font->height = (rt_uint16_t)size;
|
||||
font->refer_count = 0;
|
||||
font->engine = &freetype_font_engine;
|
||||
|
||||
/* add to system */
|
||||
rtgui_font_system_add_font(font);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
void rtgui_freetype_font_destroy(rtgui_font_t* font)
|
||||
{
|
||||
struct rtgui_freetype_font* freetype;
|
||||
|
||||
RT_ASSERT(font != RT_NULL);
|
||||
freetype = (struct rtgui_freetype_font*) font->data;
|
||||
RT_ASSERT(freetype != RT_NULL);
|
||||
|
||||
rtgui_font_system_remove_font(font);
|
||||
|
||||
FT_Done_Face (freetype->face);
|
||||
FT_Done_FreeType(freetype->library);
|
||||
rtgui_free(freetype);
|
||||
rtgui_free(font);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -86,7 +86,7 @@ static void rtgui_hz_bitmap_font_draw_text (struct rtgui_font* font, struct rtgu
|
||||
while (length > 0)
|
||||
{
|
||||
len = 0;
|
||||
while (((rt_uint8_t)*(text + len)) < 0x80 && *(text + len)) len ++;
|
||||
while (((rt_uint8_t)*(text + len)) < 0x80 && *(text + len) && len < length) len ++;
|
||||
/* draw text with English font */
|
||||
if (len > 0)
|
||||
{
|
||||
@@ -97,7 +97,7 @@ static void rtgui_hz_bitmap_font_draw_text (struct rtgui_font* font, struct rtgu
|
||||
}
|
||||
|
||||
len = 0;
|
||||
while (((rt_uint8_t)*(text + len)) >= 0x80) len ++;
|
||||
while (((rt_uint8_t)*(text + len)) >= 0x80 && len < length) len ++;
|
||||
if (len > 0)
|
||||
{
|
||||
_rtgui_hz_bitmap_font_draw_text(bmp_font, dc, text, len, rect);
|
||||
|
||||
@@ -177,7 +177,7 @@ static void rtgui_hz_file_font_draw_text(struct rtgui_font* font, struct rtgui_d
|
||||
while (length > 0)
|
||||
{
|
||||
len = 0;
|
||||
while (((rt_uint8_t)*(text + len)) < 0x80 && *(text + len)) len ++;
|
||||
while (((rt_uint8_t)*(text + len)) < 0x80 && *(text + len) && len < length) len ++;
|
||||
/* draw text with English font */
|
||||
if (len > 0)
|
||||
{
|
||||
@@ -188,7 +188,7 @@ static void rtgui_hz_file_font_draw_text(struct rtgui_font* font, struct rtgui_d
|
||||
}
|
||||
|
||||
len = 0;
|
||||
while (((rt_uint8_t)*(text + len)) >= 0x80) len ++;
|
||||
while (((rt_uint8_t)*(text + len)) >= 0x80 && len < length) len ++;
|
||||
if (len > 0)
|
||||
{
|
||||
_rtgui_hz_file_font_draw_text(hz_file_font, dc, text, len, rect);
|
||||
|
||||
@@ -1,225 +1,225 @@
|
||||
#include <rtgui/rtgui_system.h>
|
||||
#include <rtgui/driver.h>
|
||||
|
||||
#define GET_PIXEL(dst, x, y, type) \
|
||||
(type *)((rt_uint8_t*)((dst)->framebuffer) + (y) * (dst)->pitch + (x) * ((dst)->bits_per_pixel/8))
|
||||
|
||||
static void _rgb565_set_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
*GET_PIXEL(rtgui_graphic_get_device(), x, y, rt_uint16_t) = rtgui_color_to_565(*c);
|
||||
}
|
||||
|
||||
static void _rgb565_get_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
|
||||
pixel = *GET_PIXEL(rtgui_graphic_get_device(), x, y, rt_uint16_t);
|
||||
|
||||
/* get pixel from color */
|
||||
*c = rtgui_color_from_565(pixel);
|
||||
}
|
||||
|
||||
static void _rgb565_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
|
||||
{
|
||||
rt_ubase_t index;
|
||||
rt_uint16_t pixel;
|
||||
rt_uint16_t *pixel_ptr;
|
||||
|
||||
/* get pixel from color */
|
||||
pixel = rtgui_color_to_565(*c);
|
||||
|
||||
/* get pixel pointer in framebuffer */
|
||||
pixel_ptr = GET_PIXEL(rtgui_graphic_get_device(), x1, y, rt_uint16_t);
|
||||
|
||||
for (index = x1; index < x2; index ++)
|
||||
{
|
||||
*pixel_ptr = pixel;
|
||||
pixel_ptr ++;
|
||||
}
|
||||
}
|
||||
|
||||
static void _rgb565_draw_vline(rtgui_color_t *c, int x , int y1, int y2)
|
||||
{
|
||||
rt_uint8_t *dst;
|
||||
rt_uint16_t pixel;
|
||||
rt_ubase_t index;
|
||||
|
||||
pixel = rtgui_color_to_565(*c);
|
||||
dst = GET_PIXEL(rtgui_graphic_get_device(), x, y1, rt_uint8_t);
|
||||
for (index = y1; index < y2; index ++)
|
||||
{
|
||||
*(rt_uint16_t*)dst = pixel;
|
||||
dst += rtgui_graphic_get_device()->pitch;
|
||||
}
|
||||
}
|
||||
|
||||
static void _rgb565p_set_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
*GET_PIXEL(rtgui_graphic_get_device(), x, y, rt_uint16_t) = rtgui_color_to_565p(*c);
|
||||
}
|
||||
|
||||
static void _rgb565p_get_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
|
||||
pixel = *GET_PIXEL(rtgui_graphic_get_device(), x, y, rt_uint16_t);
|
||||
|
||||
/* get pixel from color */
|
||||
*c = rtgui_color_from_565p(pixel);
|
||||
}
|
||||
|
||||
static void _rgb565p_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
|
||||
{
|
||||
rt_ubase_t index;
|
||||
rt_uint16_t pixel;
|
||||
rt_uint16_t *pixel_ptr;
|
||||
|
||||
/* get pixel from color */
|
||||
pixel = rtgui_color_to_565p(*c);
|
||||
|
||||
/* get pixel pointer in framebuffer */
|
||||
pixel_ptr = GET_PIXEL(rtgui_graphic_get_device(), x1, y, rt_uint16_t);
|
||||
|
||||
for (index = x1; index < x2; index ++)
|
||||
{
|
||||
*pixel_ptr = pixel;
|
||||
pixel_ptr ++;
|
||||
}
|
||||
}
|
||||
|
||||
static void _rgb565p_draw_vline(rtgui_color_t *c, int x , int y1, int y2)
|
||||
{
|
||||
rt_uint8_t *dst;
|
||||
rt_uint16_t pixel;
|
||||
rt_ubase_t index;
|
||||
|
||||
pixel = rtgui_color_to_565p(*c);
|
||||
dst = GET_PIXEL(rtgui_graphic_get_device(), x, y1, rt_uint8_t);
|
||||
for (index = y1; index < y2; index ++)
|
||||
{
|
||||
*(rt_uint16_t*)dst = pixel;
|
||||
dst += rtgui_graphic_get_device()->pitch;
|
||||
}
|
||||
}
|
||||
|
||||
/* draw raw hline */
|
||||
static void framebuffer_draw_raw_hline(rt_uint8_t *pixels, int x1, int x2, int y)
|
||||
{
|
||||
rt_uint8_t *dst;
|
||||
|
||||
dst = GET_PIXEL(rtgui_graphic_get_device(), x1, y, rt_uint8_t);
|
||||
rt_memcpy(dst, pixels, (x2 - x1) * (rtgui_graphic_get_device()->bits_per_pixel/8));
|
||||
}
|
||||
|
||||
const struct rtgui_graphic_driver_ops _framebuffer_rgb565_ops =
|
||||
{
|
||||
_rgb565_set_pixel,
|
||||
_rgb565_get_pixel,
|
||||
_rgb565_draw_hline,
|
||||
_rgb565_draw_vline,
|
||||
framebuffer_draw_raw_hline,
|
||||
};
|
||||
|
||||
const struct rtgui_graphic_driver_ops _framebuffer_rgb565p_ops =
|
||||
{
|
||||
_rgb565p_set_pixel,
|
||||
_rgb565p_get_pixel,
|
||||
_rgb565p_draw_hline,
|
||||
_rgb565p_draw_vline,
|
||||
framebuffer_draw_raw_hline,
|
||||
};
|
||||
|
||||
#define FRAMEBUFFER (rtgui_graphic_get_device()->framebuffer)
|
||||
#define MONO_PIXEL(framebuffer, x, y) \
|
||||
((rt_uint8_t**)(framebuffer))[y/8][x]
|
||||
|
||||
static void _mono_set_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
if (*c == white)
|
||||
MONO_PIXEL(FRAMEBUFFER, x, y) &= ~(1 << (y%8));
|
||||
else
|
||||
MONO_PIXEL(FRAMEBUFFER, x, y) |= (1 << (y%8));
|
||||
}
|
||||
|
||||
static void _mono_get_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
if (MONO_PIXEL(FRAMEBUFFER, x, y) & (1 << (y%8)))
|
||||
*c = black;
|
||||
else
|
||||
*c = white;
|
||||
}
|
||||
|
||||
static void _mono_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
|
||||
{
|
||||
rt_ubase_t index;
|
||||
|
||||
if (*c == white)
|
||||
for (index = x1; index < x2; index ++)
|
||||
{
|
||||
MONO_PIXEL(FRAMEBUFFER, index, y) &= ~(1 << (y%8));
|
||||
}
|
||||
else
|
||||
for (index = x1; index < x2; index ++)
|
||||
{
|
||||
MONO_PIXEL(FRAMEBUFFER, index, y) |= (1 << (y%8));
|
||||
}
|
||||
}
|
||||
|
||||
static void _mono_draw_vline(rtgui_color_t *c, int x , int y1, int y2)
|
||||
{
|
||||
rt_ubase_t index;
|
||||
|
||||
if (*c == white)
|
||||
for (index = y1; index < y2; index ++)
|
||||
{
|
||||
MONO_PIXEL(FRAMEBUFFER, x, index) &= ~(1 << (index%8));
|
||||
}
|
||||
else
|
||||
for (index = y1; index < y2; index ++)
|
||||
{
|
||||
MONO_PIXEL(FRAMEBUFFER, x, index) |= (1 << (index%8));
|
||||
}
|
||||
}
|
||||
|
||||
/* draw raw hline */
|
||||
static void _mono_draw_raw_hline(rt_uint8_t *pixels, int x1, int x2, int y)
|
||||
{
|
||||
rt_ubase_t index;
|
||||
|
||||
for (index = x1; index < x2; index ++)
|
||||
{
|
||||
if (pixels[index/8] && (1 << (index % 8)))
|
||||
MONO_PIXEL(FRAMEBUFFER, index, y) |= (1 << (y%8));
|
||||
else
|
||||
MONO_PIXEL(FRAMEBUFFER, index, y) &= ~(1 << (y%8));
|
||||
}
|
||||
}
|
||||
|
||||
const struct rtgui_graphic_driver_ops _framebuffer_mono_ops =
|
||||
{
|
||||
_mono_set_pixel,
|
||||
_mono_get_pixel,
|
||||
_mono_draw_hline,
|
||||
_mono_draw_vline,
|
||||
_mono_draw_raw_hline,
|
||||
};
|
||||
|
||||
const struct rtgui_graphic_driver_ops *rtgui_framebuffer_get_ops(int pixel_format)
|
||||
{
|
||||
switch (pixel_format)
|
||||
{
|
||||
case RTGRAPHIC_PIXEL_FORMAT_MONO:
|
||||
return &_framebuffer_mono_ops;
|
||||
case RTGRAPHIC_PIXEL_FORMAT_GRAY4:
|
||||
break;
|
||||
case RTGRAPHIC_PIXEL_FORMAT_GRAY16:
|
||||
break;
|
||||
case RTGRAPHIC_PIXEL_FORMAT_RGB565:
|
||||
return &_framebuffer_rgb565_ops;
|
||||
case RTGRAPHIC_PIXEL_FORMAT_RGB565P:
|
||||
return &_framebuffer_rgb565p_ops;
|
||||
}
|
||||
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
#include <rtgui/rtgui_system.h>
|
||||
#include <rtgui/driver.h>
|
||||
|
||||
#define GET_PIXEL(dst, x, y, type) \
|
||||
(type *)((rt_uint8_t*)((dst)->framebuffer) + (y) * (dst)->pitch + (x) * ((dst)->bits_per_pixel/8))
|
||||
|
||||
static void _rgb565_set_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
*GET_PIXEL(rtgui_graphic_get_device(), x, y, rt_uint16_t) = rtgui_color_to_565(*c);
|
||||
}
|
||||
|
||||
static void _rgb565_get_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
|
||||
pixel = *GET_PIXEL(rtgui_graphic_get_device(), x, y, rt_uint16_t);
|
||||
|
||||
/* get pixel from color */
|
||||
*c = rtgui_color_from_565(pixel);
|
||||
}
|
||||
|
||||
static void _rgb565_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
|
||||
{
|
||||
rt_ubase_t index;
|
||||
rt_uint16_t pixel;
|
||||
rt_uint16_t *pixel_ptr;
|
||||
|
||||
/* get pixel from color */
|
||||
pixel = rtgui_color_to_565(*c);
|
||||
|
||||
/* get pixel pointer in framebuffer */
|
||||
pixel_ptr = GET_PIXEL(rtgui_graphic_get_device(), x1, y, rt_uint16_t);
|
||||
|
||||
for (index = x1; index < x2; index ++)
|
||||
{
|
||||
*pixel_ptr = pixel;
|
||||
pixel_ptr ++;
|
||||
}
|
||||
}
|
||||
|
||||
static void _rgb565_draw_vline(rtgui_color_t *c, int x , int y1, int y2)
|
||||
{
|
||||
rt_uint8_t *dst;
|
||||
rt_uint16_t pixel;
|
||||
rt_ubase_t index;
|
||||
|
||||
pixel = rtgui_color_to_565(*c);
|
||||
dst = GET_PIXEL(rtgui_graphic_get_device(), x, y1, rt_uint8_t);
|
||||
for (index = y1; index < y2; index ++)
|
||||
{
|
||||
*(rt_uint16_t*)dst = pixel;
|
||||
dst += rtgui_graphic_get_device()->pitch;
|
||||
}
|
||||
}
|
||||
|
||||
static void _rgb565p_set_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
*GET_PIXEL(rtgui_graphic_get_device(), x, y, rt_uint16_t) = rtgui_color_to_565p(*c);
|
||||
}
|
||||
|
||||
static void _rgb565p_get_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
|
||||
pixel = *GET_PIXEL(rtgui_graphic_get_device(), x, y, rt_uint16_t);
|
||||
|
||||
/* get pixel from color */
|
||||
*c = rtgui_color_from_565p(pixel);
|
||||
}
|
||||
|
||||
static void _rgb565p_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
|
||||
{
|
||||
rt_ubase_t index;
|
||||
rt_uint16_t pixel;
|
||||
rt_uint16_t *pixel_ptr;
|
||||
|
||||
/* get pixel from color */
|
||||
pixel = rtgui_color_to_565p(*c);
|
||||
|
||||
/* get pixel pointer in framebuffer */
|
||||
pixel_ptr = GET_PIXEL(rtgui_graphic_get_device(), x1, y, rt_uint16_t);
|
||||
|
||||
for (index = x1; index < x2; index ++)
|
||||
{
|
||||
*pixel_ptr = pixel;
|
||||
pixel_ptr ++;
|
||||
}
|
||||
}
|
||||
|
||||
static void _rgb565p_draw_vline(rtgui_color_t *c, int x , int y1, int y2)
|
||||
{
|
||||
rt_uint8_t *dst;
|
||||
rt_uint16_t pixel;
|
||||
rt_ubase_t index;
|
||||
|
||||
pixel = rtgui_color_to_565p(*c);
|
||||
dst = GET_PIXEL(rtgui_graphic_get_device(), x, y1, rt_uint8_t);
|
||||
for (index = y1; index < y2; index ++)
|
||||
{
|
||||
*(rt_uint16_t*)dst = pixel;
|
||||
dst += rtgui_graphic_get_device()->pitch;
|
||||
}
|
||||
}
|
||||
|
||||
/* draw raw hline */
|
||||
static void framebuffer_draw_raw_hline(rt_uint8_t *pixels, int x1, int x2, int y)
|
||||
{
|
||||
rt_uint8_t *dst;
|
||||
|
||||
dst = GET_PIXEL(rtgui_graphic_get_device(), x1, y, rt_uint8_t);
|
||||
rt_memcpy(dst, pixels, (x2 - x1) * (rtgui_graphic_get_device()->bits_per_pixel/8));
|
||||
}
|
||||
|
||||
const struct rtgui_graphic_driver_ops _framebuffer_rgb565_ops =
|
||||
{
|
||||
_rgb565_set_pixel,
|
||||
_rgb565_get_pixel,
|
||||
_rgb565_draw_hline,
|
||||
_rgb565_draw_vline,
|
||||
framebuffer_draw_raw_hline,
|
||||
};
|
||||
|
||||
const struct rtgui_graphic_driver_ops _framebuffer_rgb565p_ops =
|
||||
{
|
||||
_rgb565p_set_pixel,
|
||||
_rgb565p_get_pixel,
|
||||
_rgb565p_draw_hline,
|
||||
_rgb565p_draw_vline,
|
||||
framebuffer_draw_raw_hline,
|
||||
};
|
||||
|
||||
#define FRAMEBUFFER (rtgui_graphic_get_device()->framebuffer)
|
||||
#define MONO_PIXEL(framebuffer, x, y) \
|
||||
((rt_uint8_t**)(framebuffer))[y/8][x]
|
||||
|
||||
static void _mono_set_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
if (*c == white)
|
||||
MONO_PIXEL(FRAMEBUFFER, x, y) &= ~(1 << (y%8));
|
||||
else
|
||||
MONO_PIXEL(FRAMEBUFFER, x, y) |= (1 << (y%8));
|
||||
}
|
||||
|
||||
static void _mono_get_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
if (MONO_PIXEL(FRAMEBUFFER, x, y) & (1 << (y%8)))
|
||||
*c = black;
|
||||
else
|
||||
*c = white;
|
||||
}
|
||||
|
||||
static void _mono_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
|
||||
{
|
||||
rt_ubase_t index;
|
||||
|
||||
if (*c == white)
|
||||
for (index = x1; index < x2; index ++)
|
||||
{
|
||||
MONO_PIXEL(FRAMEBUFFER, index, y) &= ~(1 << (y%8));
|
||||
}
|
||||
else
|
||||
for (index = x1; index < x2; index ++)
|
||||
{
|
||||
MONO_PIXEL(FRAMEBUFFER, index, y) |= (1 << (y%8));
|
||||
}
|
||||
}
|
||||
|
||||
static void _mono_draw_vline(rtgui_color_t *c, int x , int y1, int y2)
|
||||
{
|
||||
rt_ubase_t index;
|
||||
|
||||
if (*c == white)
|
||||
for (index = y1; index < y2; index ++)
|
||||
{
|
||||
MONO_PIXEL(FRAMEBUFFER, x, index) &= ~(1 << (index%8));
|
||||
}
|
||||
else
|
||||
for (index = y1; index < y2; index ++)
|
||||
{
|
||||
MONO_PIXEL(FRAMEBUFFER, x, index) |= (1 << (index%8));
|
||||
}
|
||||
}
|
||||
|
||||
/* draw raw hline */
|
||||
static void _mono_draw_raw_hline(rt_uint8_t *pixels, int x1, int x2, int y)
|
||||
{
|
||||
rt_ubase_t index;
|
||||
|
||||
for (index = x1; index < x2; index ++)
|
||||
{
|
||||
if (pixels[index/8] && (1 << (index % 8)))
|
||||
MONO_PIXEL(FRAMEBUFFER, index, y) |= (1 << (y%8));
|
||||
else
|
||||
MONO_PIXEL(FRAMEBUFFER, index, y) &= ~(1 << (y%8));
|
||||
}
|
||||
}
|
||||
|
||||
const struct rtgui_graphic_driver_ops _framebuffer_mono_ops =
|
||||
{
|
||||
_mono_set_pixel,
|
||||
_mono_get_pixel,
|
||||
_mono_draw_hline,
|
||||
_mono_draw_vline,
|
||||
_mono_draw_raw_hline,
|
||||
};
|
||||
|
||||
const struct rtgui_graphic_driver_ops *rtgui_framebuffer_get_ops(int pixel_format)
|
||||
{
|
||||
switch (pixel_format)
|
||||
{
|
||||
case RTGRAPHIC_PIXEL_FORMAT_MONO:
|
||||
return &_framebuffer_mono_ops;
|
||||
case RTGRAPHIC_PIXEL_FORMAT_GRAY4:
|
||||
break;
|
||||
case RTGRAPHIC_PIXEL_FORMAT_GRAY16:
|
||||
break;
|
||||
case RTGRAPHIC_PIXEL_FORMAT_RGB565:
|
||||
return &_framebuffer_rgb565_ops;
|
||||
case RTGRAPHIC_PIXEL_FORMAT_RGB565P:
|
||||
return &_framebuffer_rgb565p_ops;
|
||||
}
|
||||
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,23 +64,6 @@ void rtgui_system_image_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static struct rtgui_image_engine* rtgui_image_get_engine(const char* type)
|
||||
{
|
||||
struct rtgui_list_node *node;
|
||||
struct rtgui_image_engine *engine;
|
||||
|
||||
rtgui_list_foreach(node, &_rtgui_system_image_list)
|
||||
{
|
||||
engine = rtgui_list_entry(node, struct rtgui_image_engine, list);
|
||||
|
||||
if (strncasecmp(engine->name, type, strlen(engine->name)) ==0)
|
||||
return engine;
|
||||
}
|
||||
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
|
||||
static struct rtgui_image_engine* rtgui_image_get_engine_by_filename(const char* fn)
|
||||
{
|
||||
struct rtgui_list_node *node;
|
||||
@@ -105,6 +88,23 @@ static struct rtgui_image_engine* rtgui_image_get_engine_by_filename(const char*
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
static struct rtgui_image_engine* rtgui_image_get_engine(const char* type)
|
||||
{
|
||||
struct rtgui_list_node *node;
|
||||
struct rtgui_image_engine *engine;
|
||||
|
||||
rtgui_list_foreach(node, &_rtgui_system_image_list)
|
||||
{
|
||||
engine = rtgui_list_entry(node, struct rtgui_image_engine, list);
|
||||
|
||||
if (strncasecmp(engine->name, type, strlen(engine->name)) ==0)
|
||||
return engine;
|
||||
}
|
||||
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
#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_filerw* filerw;
|
||||
|
||||
+645
-645
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,154 +1,154 @@
|
||||
#include <rtgui/rtgui_system.h>
|
||||
#include <rtgui/driver.h>
|
||||
|
||||
#define gfx_device (rtgui_graphic_get_device()->device)
|
||||
#define gfx_device_ops rt_graphix_ops(gfx_device)
|
||||
|
||||
static void _pixel_rgb565p_set_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
|
||||
pixel = rtgui_color_to_565p(*c);
|
||||
gfx_device_ops->set_pixel((char*)&pixel, x, y);
|
||||
}
|
||||
|
||||
static void _pixel_rgb565_set_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
|
||||
pixel = rtgui_color_to_565(*c);
|
||||
gfx_device_ops->set_pixel((char*)&pixel, x, y);
|
||||
}
|
||||
|
||||
static void _pixel_rgb888_set_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
rt_uint32_t pixel;
|
||||
|
||||
pixel = rtgui_color_to_888(*c);
|
||||
gfx_device_ops->set_pixel((char*)&pixel, x, y);
|
||||
}
|
||||
|
||||
static void _pixel_rgb565p_get_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
|
||||
gfx_device_ops->get_pixel((char*)&pixel, x, y);
|
||||
*c = rtgui_color_from_565p(pixel);
|
||||
}
|
||||
|
||||
static void _pixel_rgb565_get_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
|
||||
gfx_device_ops->get_pixel((char*)&pixel, x, y);
|
||||
*c = rtgui_color_from_565(pixel);
|
||||
}
|
||||
|
||||
static void _pixel_rgb888_get_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
rt_uint32_t pixel;
|
||||
|
||||
gfx_device_ops->get_pixel((char*)&pixel, x, y);
|
||||
*c = rtgui_color_from_888(pixel);
|
||||
}
|
||||
|
||||
static void _pixel_rgb565p_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
|
||||
pixel = rtgui_color_to_565p(*c);
|
||||
gfx_device_ops->draw_hline((char*)&pixel, x1, x2, y);
|
||||
}
|
||||
|
||||
static void _pixel_rgb565_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
|
||||
pixel = rtgui_color_to_565(*c);
|
||||
gfx_device_ops->draw_hline((char*)&pixel, x1, x2, y);
|
||||
}
|
||||
|
||||
static void _pixel_rgb888_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
|
||||
{
|
||||
rt_uint32_t pixel;
|
||||
|
||||
pixel = rtgui_color_to_888(*c);
|
||||
gfx_device_ops->draw_hline((char*)&pixel, x1, x2, y);
|
||||
}
|
||||
|
||||
static void _pixel_rgb565p_draw_vline(rtgui_color_t *c, int x, int y1, int y2)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
|
||||
pixel = rtgui_color_to_565p(*c);
|
||||
gfx_device_ops->draw_vline((char*)&pixel, x, y1, y2);
|
||||
}
|
||||
|
||||
static void _pixel_rgb565_draw_vline(rtgui_color_t *c, int x, int y1, int y2)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
|
||||
pixel = rtgui_color_to_565(*c);
|
||||
gfx_device_ops->draw_vline((char*)&pixel, x, y1, y2);
|
||||
}
|
||||
|
||||
static void _pixel_rgb888_draw_vline(rtgui_color_t *c, int x, int y1, int y2)
|
||||
{
|
||||
rt_uint32_t pixel;
|
||||
|
||||
pixel = rtgui_color_to_888(*c);
|
||||
gfx_device_ops->draw_vline((char*)&pixel, x, y1, y2);
|
||||
}
|
||||
|
||||
static void _pixel_draw_raw_hline(rt_uint8_t *pixels, int x1, int x2, int y)
|
||||
{
|
||||
if (x2 > x1)
|
||||
gfx_device_ops->blit_line((char*)pixels, x1, y, (x2 - x1));
|
||||
else
|
||||
gfx_device_ops->blit_line((char*)pixels, x2, y, (x1 - x2));
|
||||
}
|
||||
|
||||
/* pixel device */
|
||||
const struct rtgui_graphic_driver_ops _pixel_rgb565p_ops =
|
||||
{
|
||||
_pixel_rgb565p_set_pixel,
|
||||
_pixel_rgb565p_get_pixel,
|
||||
_pixel_rgb565p_draw_hline,
|
||||
_pixel_rgb565p_draw_vline,
|
||||
_pixel_draw_raw_hline,
|
||||
};
|
||||
|
||||
const struct rtgui_graphic_driver_ops _pixel_rgb565_ops =
|
||||
{
|
||||
_pixel_rgb565_set_pixel,
|
||||
_pixel_rgb565_get_pixel,
|
||||
_pixel_rgb565_draw_hline,
|
||||
_pixel_rgb565_draw_vline,
|
||||
_pixel_draw_raw_hline,
|
||||
};
|
||||
|
||||
const struct rtgui_graphic_driver_ops _pixel_rgb888_ops =
|
||||
{
|
||||
_pixel_rgb888_set_pixel,
|
||||
_pixel_rgb888_get_pixel,
|
||||
_pixel_rgb888_draw_hline,
|
||||
_pixel_rgb888_draw_vline,
|
||||
_pixel_draw_raw_hline,
|
||||
};
|
||||
|
||||
const struct rtgui_graphic_driver_ops *rtgui_pixel_device_get_ops(int pixel_format)
|
||||
{
|
||||
switch (pixel_format)
|
||||
{
|
||||
case RTGRAPHIC_PIXEL_FORMAT_RGB565:
|
||||
return &_pixel_rgb565_ops;
|
||||
|
||||
case RTGRAPHIC_PIXEL_FORMAT_RGB565P:
|
||||
return &_pixel_rgb565p_ops;
|
||||
|
||||
case RTGRAPHIC_PIXEL_FORMAT_RGB888:
|
||||
return &_pixel_rgb888_ops;
|
||||
}
|
||||
|
||||
return RT_NULL;
|
||||
}
|
||||
#include <rtgui/rtgui_system.h>
|
||||
#include <rtgui/driver.h>
|
||||
|
||||
#define gfx_device (rtgui_graphic_get_device()->device)
|
||||
#define gfx_device_ops rt_graphix_ops(gfx_device)
|
||||
|
||||
static void _pixel_rgb565p_set_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
|
||||
pixel = rtgui_color_to_565p(*c);
|
||||
gfx_device_ops->set_pixel((char*)&pixel, x, y);
|
||||
}
|
||||
|
||||
static void _pixel_rgb565_set_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
|
||||
pixel = rtgui_color_to_565(*c);
|
||||
gfx_device_ops->set_pixel((char*)&pixel, x, y);
|
||||
}
|
||||
|
||||
static void _pixel_rgb888_set_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
rt_uint32_t pixel;
|
||||
|
||||
pixel = rtgui_color_to_888(*c);
|
||||
gfx_device_ops->set_pixel((char*)&pixel, x, y);
|
||||
}
|
||||
|
||||
static void _pixel_rgb565p_get_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
|
||||
gfx_device_ops->get_pixel((char*)&pixel, x, y);
|
||||
*c = rtgui_color_from_565p(pixel);
|
||||
}
|
||||
|
||||
static void _pixel_rgb565_get_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
|
||||
gfx_device_ops->get_pixel((char*)&pixel, x, y);
|
||||
*c = rtgui_color_from_565(pixel);
|
||||
}
|
||||
|
||||
static void _pixel_rgb888_get_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
rt_uint32_t pixel;
|
||||
|
||||
gfx_device_ops->get_pixel((char*)&pixel, x, y);
|
||||
*c = rtgui_color_from_888(pixel);
|
||||
}
|
||||
|
||||
static void _pixel_rgb565p_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
|
||||
pixel = rtgui_color_to_565p(*c);
|
||||
gfx_device_ops->draw_hline((char*)&pixel, x1, x2, y);
|
||||
}
|
||||
|
||||
static void _pixel_rgb565_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
|
||||
pixel = rtgui_color_to_565(*c);
|
||||
gfx_device_ops->draw_hline((char*)&pixel, x1, x2, y);
|
||||
}
|
||||
|
||||
static void _pixel_rgb888_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
|
||||
{
|
||||
rt_uint32_t pixel;
|
||||
|
||||
pixel = rtgui_color_to_888(*c);
|
||||
gfx_device_ops->draw_hline((char*)&pixel, x1, x2, y);
|
||||
}
|
||||
|
||||
static void _pixel_rgb565p_draw_vline(rtgui_color_t *c, int x, int y1, int y2)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
|
||||
pixel = rtgui_color_to_565p(*c);
|
||||
gfx_device_ops->draw_vline((char*)&pixel, x, y1, y2);
|
||||
}
|
||||
|
||||
static void _pixel_rgb565_draw_vline(rtgui_color_t *c, int x, int y1, int y2)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
|
||||
pixel = rtgui_color_to_565(*c);
|
||||
gfx_device_ops->draw_vline((char*)&pixel, x, y1, y2);
|
||||
}
|
||||
|
||||
static void _pixel_rgb888_draw_vline(rtgui_color_t *c, int x, int y1, int y2)
|
||||
{
|
||||
rt_uint32_t pixel;
|
||||
|
||||
pixel = rtgui_color_to_888(*c);
|
||||
gfx_device_ops->draw_vline((char*)&pixel, x, y1, y2);
|
||||
}
|
||||
|
||||
static void _pixel_draw_raw_hline(rt_uint8_t *pixels, int x1, int x2, int y)
|
||||
{
|
||||
if (x2 > x1)
|
||||
gfx_device_ops->blit_line((char*)pixels, x1, y, (x2 - x1));
|
||||
else
|
||||
gfx_device_ops->blit_line((char*)pixels, x2, y, (x1 - x2));
|
||||
}
|
||||
|
||||
/* pixel device */
|
||||
const struct rtgui_graphic_driver_ops _pixel_rgb565p_ops =
|
||||
{
|
||||
_pixel_rgb565p_set_pixel,
|
||||
_pixel_rgb565p_get_pixel,
|
||||
_pixel_rgb565p_draw_hline,
|
||||
_pixel_rgb565p_draw_vline,
|
||||
_pixel_draw_raw_hline,
|
||||
};
|
||||
|
||||
const struct rtgui_graphic_driver_ops _pixel_rgb565_ops =
|
||||
{
|
||||
_pixel_rgb565_set_pixel,
|
||||
_pixel_rgb565_get_pixel,
|
||||
_pixel_rgb565_draw_hline,
|
||||
_pixel_rgb565_draw_vline,
|
||||
_pixel_draw_raw_hline,
|
||||
};
|
||||
|
||||
const struct rtgui_graphic_driver_ops _pixel_rgb888_ops =
|
||||
{
|
||||
_pixel_rgb888_set_pixel,
|
||||
_pixel_rgb888_get_pixel,
|
||||
_pixel_rgb888_draw_hline,
|
||||
_pixel_rgb888_draw_vline,
|
||||
_pixel_draw_raw_hline,
|
||||
};
|
||||
|
||||
const struct rtgui_graphic_driver_ops *rtgui_pixel_device_get_ops(int pixel_format)
|
||||
{
|
||||
switch (pixel_format)
|
||||
{
|
||||
case RTGRAPHIC_PIXEL_FORMAT_RGB565:
|
||||
return &_pixel_rgb565_ops;
|
||||
|
||||
case RTGRAPHIC_PIXEL_FORMAT_RGB565P:
|
||||
return &_pixel_rgb565p_ops;
|
||||
|
||||
case RTGRAPHIC_PIXEL_FORMAT_RGB888:
|
||||
return &_pixel_rgb888_ops;
|
||||
}
|
||||
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
@@ -17,9 +17,10 @@
|
||||
|
||||
static void _rtgui_object_constructor(rtgui_object_t *object)
|
||||
{
|
||||
if (!object) return;
|
||||
if (!object)
|
||||
return;
|
||||
|
||||
object->is_static = RT_FALSE;
|
||||
object->flag = RTGUI_OBJECT_FLAG_NONE;
|
||||
}
|
||||
|
||||
/* Destroys the object */
|
||||
@@ -28,7 +29,7 @@ static void _rtgui_object_destructor(rtgui_object_t *object)
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
DEFINE_CLASS_TYPE(type, "object",
|
||||
DEFINE_CLASS_TYPE(type, "object",
|
||||
RT_NULL,
|
||||
_rtgui_object_constructor,
|
||||
_rtgui_object_destructor,
|
||||
@@ -44,9 +45,9 @@ void rtgui_type_object_construct(const rtgui_type_t *type, rtgui_object_t *objec
|
||||
}
|
||||
|
||||
void rtgui_type_destructors_call(const rtgui_type_t *type, rtgui_object_t *object)
|
||||
{
|
||||
const rtgui_type_t *t;
|
||||
|
||||
{
|
||||
const rtgui_type_t *t;
|
||||
|
||||
t = type;
|
||||
while (t)
|
||||
{
|
||||
@@ -56,9 +57,9 @@ void rtgui_type_destructors_call(const rtgui_type_t *type, rtgui_object_t *objec
|
||||
}
|
||||
|
||||
rt_bool_t rtgui_type_inherits_from(const rtgui_type_t *type, const rtgui_type_t *parent)
|
||||
{
|
||||
const rtgui_type_t *t;
|
||||
|
||||
{
|
||||
const rtgui_type_t *t;
|
||||
|
||||
t = type;
|
||||
while (t)
|
||||
{
|
||||
@@ -115,7 +116,6 @@ rtgui_object_t *rtgui_object_create(rtgui_type_t *object_type)
|
||||
#endif
|
||||
|
||||
new_object->type = object_type;
|
||||
new_object->is_static = RT_FALSE;
|
||||
|
||||
rtgui_type_object_construct(object_type, new_object);
|
||||
|
||||
@@ -131,7 +131,8 @@ rtgui_object_t *rtgui_object_create(rtgui_type_t *object_type)
|
||||
*/
|
||||
void rtgui_object_destroy(rtgui_object_t *object)
|
||||
{
|
||||
if (!object || object->is_static == RT_TRUE) return;
|
||||
if (!object || object->flag & RTGUI_OBJECT_FLAG_STATIC)
|
||||
return;
|
||||
|
||||
#ifdef RTGUI_OBJECT_TRACE
|
||||
obj_info.objs_number --;
|
||||
@@ -178,3 +179,15 @@ const rtgui_type_t *rtgui_object_object_type_get(rtgui_object_t *object)
|
||||
return object->type;
|
||||
}
|
||||
|
||||
void rtgui_object_set_event_handler(struct rtgui_object *object, rtgui_event_handler_ptr handler)
|
||||
{
|
||||
RT_ASSERT(object != RT_NULL);
|
||||
|
||||
object->event_handler = handler;
|
||||
}
|
||||
|
||||
rt_bool_t rtgui_object_event_handler(struct rtgui_object *object, struct rtgui_event* event)
|
||||
{
|
||||
return RT_FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,15 +16,13 @@
|
||||
#include <rtgui/image.h>
|
||||
#include <rtgui/font.h>
|
||||
#include <rtgui/event.h>
|
||||
#include <rtgui/rtgui_application.h>
|
||||
#include <rtgui/rtgui_server.h>
|
||||
#include <rtgui/rtgui_system.h>
|
||||
#include <rtgui/widgets/window.h>
|
||||
#include <rtgui/rtgui_theme.h>
|
||||
|
||||
#define RTGUI_EVENT_DEBUG
|
||||
|
||||
#ifdef _WIN32
|
||||
#define RTGUI_EVENT_DEBUG
|
||||
#define RTGUI_MEM_TRACE
|
||||
#endif
|
||||
|
||||
@@ -43,467 +41,6 @@ void rtgui_system_server_init()
|
||||
rtgui_system_theme_init();
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
/* RTGUI Thread Wrapper */
|
||||
/************************************************************************/
|
||||
#ifdef RTGUI_EVENT_DEBUG
|
||||
const char *event_string[] =
|
||||
{
|
||||
/* panel event */
|
||||
"PANEL_ATTACH", /* attach to a panel */
|
||||
"PANEL_DETACH", /* detach from a panel */
|
||||
"PANEL_SHOW", /* show in a panel */
|
||||
"PANEL_HIDE", /* hide from a panel */
|
||||
"PANEL_INFO", /* panel information */
|
||||
"PANEL_RESIZE", /* resize panel */
|
||||
"PANEL_FULLSCREEN", /* to full screen */
|
||||
"PANEL_NORMAL", /* to normal screen */
|
||||
|
||||
/* window event */
|
||||
"WIN_CREATE", /* create a window */
|
||||
"WIN_DESTROY", /* destroy a window */
|
||||
"WIN_SHOW", /* show a window */
|
||||
"WIN_HIDE", /* hide a window */
|
||||
"WIN_ACTIVATE", /* activate a window */
|
||||
"WIN_DEACTIVATE", /* deactivate a window */
|
||||
"WIN_CLOSE", /* close a window */
|
||||
"WIN_MOVE", /* move a window */
|
||||
"WIN_RESIZE", /* resize a window */
|
||||
|
||||
"SET_WM", /* set window manager */
|
||||
|
||||
"UPDATE_BEGIN", /* begin of update rect */
|
||||
"UPDATE_END", /* end of update rect */
|
||||
"MONITOR_ADD", /* add a monitor rect */
|
||||
"MONITOR_REMOVE", /* remove a monitor rect*/
|
||||
"PAINT", /* paint on screen */
|
||||
"TIMER", /* timer */
|
||||
|
||||
/* clip rect information */
|
||||
"CLIP_INFO", /* clip rect info */
|
||||
|
||||
/* mouse and keyboard event */
|
||||
"MOUSE_MOTION", /* mouse motion */
|
||||
"MOUSE_BUTTON", /* mouse button info */
|
||||
"KBD", /* keyboard info */
|
||||
|
||||
/* user command event */
|
||||
"COMMAND", /* user command */
|
||||
|
||||
/* request's status event */
|
||||
"STATUS", /* request result */
|
||||
"SCROLLED", /* scroll bar scrolled */
|
||||
"RESIZE", /* widget resize */
|
||||
};
|
||||
|
||||
#define DBG_MSG(x) rt_kprintf x
|
||||
|
||||
static void rtgui_event_dump(rt_thread_t tid, rtgui_event_t* event)
|
||||
{
|
||||
char* sender = "(unknown)";
|
||||
|
||||
if (event->sender != RT_NULL) sender = event->sender->name;
|
||||
|
||||
if ((event->type == RTGUI_EVENT_TIMER) ||
|
||||
(event->type == RTGUI_EVENT_UPDATE_BEGIN) ||
|
||||
(event->type == RTGUI_EVENT_UPDATE_END))
|
||||
{
|
||||
/* don't dump timer event */
|
||||
return ;
|
||||
}
|
||||
|
||||
rt_kprintf("%s -- %s --> %s ", sender, event_string[event->type], tid->name);
|
||||
switch (event->type)
|
||||
{
|
||||
case RTGUI_EVENT_PAINT:
|
||||
{
|
||||
struct rtgui_event_paint *paint = (struct rtgui_event_paint *)event;
|
||||
|
||||
if(paint->wid != RT_NULL)
|
||||
rt_kprintf("win: %s", paint->wid->title);
|
||||
}
|
||||
break;
|
||||
|
||||
case RTGUI_EVENT_KBD:
|
||||
{
|
||||
struct rtgui_event_kbd *ekbd = (struct rtgui_event_kbd*) event;
|
||||
if (ekbd->wid != RT_NULL)
|
||||
rt_kprintf("win: %s", ekbd->wid->title);
|
||||
if (RTGUI_KBD_IS_UP(ekbd)) rt_kprintf(", up");
|
||||
else rt_kprintf(", down");
|
||||
}
|
||||
break;
|
||||
|
||||
case RTGUI_EVENT_CLIP_INFO:
|
||||
{
|
||||
struct rtgui_event_clip_info *info = (struct rtgui_event_clip_info *)event;
|
||||
|
||||
if(info->wid != RT_NULL)
|
||||
rt_kprintf("win: %s", info->wid->title);
|
||||
}
|
||||
break;
|
||||
|
||||
case RTGUI_EVENT_WIN_CREATE:
|
||||
{
|
||||
struct rtgui_event_win_create *create = (struct rtgui_event_win_create*)event;
|
||||
|
||||
rt_kprintf(" win: %s at (x1:%d, y1:%d, x2:%d, y2:%d)",
|
||||
#ifdef RTGUI_USING_SMALL_SIZE
|
||||
create->wid->title,
|
||||
RTGUI_WIDGET(create->wid)->extent.x1,
|
||||
RTGUI_WIDGET(create->wid)->extent.y1,
|
||||
RTGUI_WIDGET(create->wid)->extent.x2,
|
||||
RTGUI_WIDGET(create->wid)->extent.y2);
|
||||
#else
|
||||
create->title,
|
||||
create->extent.x1,
|
||||
create->extent.y1,
|
||||
create->extent.x2,
|
||||
create->extent.y2);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case RTGUI_EVENT_UPDATE_END:
|
||||
{
|
||||
struct rtgui_event_update_end* update_end = (struct rtgui_event_update_end*)event;
|
||||
rt_kprintf("(x:%d, y1:%d, x2:%d, y2:%d)", update_end->rect.x1,
|
||||
update_end->rect.y1,
|
||||
update_end->rect.x2,
|
||||
update_end->rect.y2);
|
||||
}
|
||||
break;
|
||||
|
||||
case RTGUI_EVENT_WIN_ACTIVATE:
|
||||
case RTGUI_EVENT_WIN_DEACTIVATE:
|
||||
case RTGUI_EVENT_WIN_SHOW:
|
||||
{
|
||||
struct rtgui_event_win *win = (struct rtgui_event_win *)event;
|
||||
|
||||
if(win->wid != RT_NULL)
|
||||
rt_kprintf("win: %s", win->wid->title);
|
||||
}
|
||||
break;
|
||||
|
||||
case RTGUI_EVENT_WIN_MOVE:
|
||||
{
|
||||
struct rtgui_event_win_move *win = (struct rtgui_event_win_move *)event;
|
||||
|
||||
if(win->wid != RT_NULL)
|
||||
{
|
||||
rt_kprintf("win: %s", win->wid->title);
|
||||
rt_kprintf(" to (x:%d, y:%d)", win->x, win->y);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RTGUI_EVENT_WIN_RESIZE:
|
||||
{
|
||||
struct rtgui_event_win_resize* win = (struct rtgui_event_win_resize *)event;
|
||||
|
||||
if (win->wid != RT_NULL)
|
||||
{
|
||||
rt_kprintf("win: %s, rect(x1:%d, y1:%d, x2:%d, y2:%d)", win->wid->title,
|
||||
RTGUI_WIDGET(win->wid)->extent.x1,
|
||||
RTGUI_WIDGET(win->wid)->extent.y1,
|
||||
RTGUI_WIDGET(win->wid)->extent.x2,
|
||||
RTGUI_WIDGET(win->wid)->extent.y2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RTGUI_EVENT_MOUSE_BUTTON:
|
||||
case RTGUI_EVENT_MOUSE_MOTION:
|
||||
{
|
||||
struct rtgui_event_mouse *mouse = (struct rtgui_event_mouse*)event;
|
||||
|
||||
if (mouse->button & RTGUI_MOUSE_BUTTON_LEFT) rt_kprintf("left ");
|
||||
else rt_kprintf("right ");
|
||||
|
||||
if (mouse->button & RTGUI_MOUSE_BUTTON_DOWN) rt_kprintf("down ");
|
||||
else rt_kprintf("up ");
|
||||
|
||||
if (mouse->wid != RT_NULL)
|
||||
rt_kprintf("win: %s at (%d, %d)", mouse->wid->title,
|
||||
mouse->x, mouse->y);
|
||||
else
|
||||
rt_kprintf("(%d, %d)", mouse->x, mouse->y);
|
||||
}
|
||||
break;
|
||||
|
||||
case RTGUI_EVENT_MONITOR_ADD:
|
||||
{
|
||||
struct rtgui_event_monitor *monitor = (struct rtgui_event_monitor*)event;
|
||||
if (monitor->panel != RT_NULL)
|
||||
{
|
||||
rt_kprintf("the rect is:(%d, %d) - (%d, %d)",
|
||||
monitor->rect.x1, monitor->rect.y1,
|
||||
monitor->rect.x2, monitor->rect.y2);
|
||||
}
|
||||
else if (monitor->wid != RT_NULL)
|
||||
{
|
||||
rt_kprintf("win: %s, the rect is:(%d, %d) - (%d, %d)", monitor->wid->title,
|
||||
monitor->rect.x1, monitor->rect.y1,
|
||||
monitor->rect.x2, monitor->rect.y2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
rt_kprintf("\n");
|
||||
}
|
||||
#else
|
||||
#define DBG_MSG(x)
|
||||
#define rtgui_event_dump(tid, event)
|
||||
#endif
|
||||
|
||||
rtgui_thread_t* rtgui_thread_register(rt_thread_t tid, rt_mq_t mq)
|
||||
{
|
||||
rtgui_thread_t* thread = rtgui_malloc(sizeof(rtgui_thread_t));
|
||||
|
||||
if (thread != RT_NULL)
|
||||
{
|
||||
DBG_MSG(("register a rtgui thread: %s, tid: 0x%p\n", tid->name, tid));
|
||||
|
||||
/* set tid and mq */
|
||||
thread->tid = tid;
|
||||
thread->mq = mq;
|
||||
thread->widget = RT_NULL;
|
||||
thread->on_idle = RT_NULL;
|
||||
|
||||
/* set user thread */
|
||||
tid->user_data = (rt_uint32_t)thread;
|
||||
}
|
||||
|
||||
return thread;
|
||||
}
|
||||
|
||||
void rtgui_thread_deregister(rt_thread_t tid)
|
||||
{
|
||||
rtgui_thread_t* thread;
|
||||
|
||||
/* find rtgui_thread_t */
|
||||
thread = (rtgui_thread_t*) (tid->user_data);
|
||||
|
||||
if (thread != RT_NULL)
|
||||
{
|
||||
/* remove rtgui_thread_t */
|
||||
tid->user_data = 0;
|
||||
|
||||
/* free rtgui_thread_t */
|
||||
rtgui_free(thread);
|
||||
}
|
||||
}
|
||||
|
||||
/* get current gui thread */
|
||||
rtgui_thread_t* rtgui_thread_self()
|
||||
{
|
||||
rtgui_thread_t* thread;
|
||||
rt_thread_t self;
|
||||
|
||||
/* get current thread */
|
||||
self = rt_thread_self();
|
||||
thread = (rtgui_thread_t*)(self->user_data);
|
||||
|
||||
return thread;
|
||||
}
|
||||
|
||||
void rtgui_thread_set_onidle(rtgui_idle_func onidle)
|
||||
{
|
||||
rtgui_thread_t* thread;
|
||||
|
||||
thread = rtgui_thread_self();
|
||||
RT_ASSERT(thread != RT_NULL);
|
||||
|
||||
thread->on_idle = onidle;
|
||||
}
|
||||
|
||||
rtgui_idle_func rtgui_thread_get_onidle()
|
||||
{
|
||||
rtgui_thread_t* thread;
|
||||
|
||||
thread = rtgui_thread_self();
|
||||
RT_ASSERT(thread != RT_NULL);
|
||||
|
||||
return thread->on_idle;
|
||||
}
|
||||
|
||||
extern rt_thread_t rt_thread_find(char* name);
|
||||
rt_thread_t rtgui_thread_get_server()
|
||||
{
|
||||
return rt_thread_find("rtgui");
|
||||
}
|
||||
|
||||
void rtgui_thread_set_widget(rtgui_widget_t* widget)
|
||||
{
|
||||
rtgui_thread_t* thread;
|
||||
|
||||
/* get rtgui_thread */
|
||||
thread = (rtgui_thread_t*) (rt_thread_self()->user_data);
|
||||
|
||||
if (thread != RT_NULL) thread->widget = widget;
|
||||
}
|
||||
|
||||
rtgui_widget_t* rtgui_thread_get_widget()
|
||||
{
|
||||
rtgui_thread_t* thread;
|
||||
|
||||
/* get rtgui_thread_t */
|
||||
thread = (rtgui_thread_t*) (rt_thread_self()->user_data);
|
||||
|
||||
return thread == RT_NULL? RT_NULL : thread->widget;
|
||||
}
|
||||
|
||||
rt_err_t rtgui_thread_send(rt_thread_t tid, rtgui_event_t* event, rt_size_t event_size)
|
||||
{
|
||||
rt_err_t result;
|
||||
rtgui_thread_t* thread;
|
||||
|
||||
rtgui_event_dump(tid, event);
|
||||
|
||||
/* find rtgui_thread_t */
|
||||
thread = (rtgui_thread_t*) (tid->user_data);
|
||||
if (thread == RT_NULL) return -RT_ERROR;
|
||||
|
||||
result = rt_mq_send(thread->mq, event, event_size);
|
||||
if (result != RT_EOK)
|
||||
{
|
||||
if (event->type != RTGUI_EVENT_TIMER)
|
||||
rt_kprintf("send event to %s failed\n", thread->tid->name);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
rt_err_t rtgui_thread_send_urgent(rt_thread_t tid, rtgui_event_t* event, rt_size_t event_size)
|
||||
{
|
||||
rt_err_t result;
|
||||
rtgui_thread_t* thread;
|
||||
|
||||
rtgui_event_dump(tid, event);
|
||||
|
||||
/* find rtgui_thread_t */
|
||||
thread = (rtgui_thread_t*) (tid->user_data);
|
||||
if (thread == RT_NULL) return -RT_ERROR;
|
||||
|
||||
result = rt_mq_urgent(thread->mq, event, event_size);
|
||||
if (result != RT_EOK)
|
||||
rt_kprintf("send ergent event failed\n");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
rt_err_t rtgui_thread_send_sync(rt_thread_t tid, rtgui_event_t* event, rt_size_t event_size)
|
||||
{
|
||||
rt_err_t r;
|
||||
rtgui_thread_t* thread;
|
||||
rt_int32_t ack_buffer, ack_status;
|
||||
struct rt_mailbox ack_mb;
|
||||
|
||||
rtgui_event_dump(tid, event);
|
||||
|
||||
/* init ack mailbox */
|
||||
r = rt_mb_init(&ack_mb, "ack", &ack_buffer, 1, 0);
|
||||
if (r!= RT_EOK) goto __return;
|
||||
|
||||
/* find rtgui_thread_t */
|
||||
thread = (rtgui_thread_t*) (tid->user_data);
|
||||
if (thread == RT_NULL)
|
||||
{
|
||||
r = -RT_ERROR;
|
||||
goto __return;
|
||||
}
|
||||
|
||||
event->ack = &ack_mb;
|
||||
r = rt_mq_send(thread->mq, event, event_size);
|
||||
if (r != RT_EOK)
|
||||
{
|
||||
rt_kprintf("send sync event failed\n");
|
||||
goto __return;
|
||||
}
|
||||
|
||||
r = rt_mb_recv(&ack_mb, (rt_uint32_t*)&ack_status, RT_WAITING_FOREVER);
|
||||
if (r!= RT_EOK) goto __return;
|
||||
|
||||
if (ack_status != RTGUI_STATUS_OK)
|
||||
r = -RT_ERROR;
|
||||
else
|
||||
r = RT_EOK;
|
||||
|
||||
__return:
|
||||
/* fini ack mailbox */
|
||||
rt_mb_detach(&ack_mb);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
rt_err_t rtgui_thread_ack(rtgui_event_t* event, rt_int32_t status)
|
||||
{
|
||||
if (event != RT_NULL &&
|
||||
event->ack != RT_NULL)
|
||||
{
|
||||
rt_mb_send(event->ack, status);
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
rt_err_t rtgui_thread_recv(rtgui_event_t* event, rt_size_t event_size)
|
||||
{
|
||||
rtgui_thread_t* thread;
|
||||
rt_err_t r;
|
||||
|
||||
/* find rtgui_thread_t */
|
||||
thread = (rtgui_thread_t*) (rt_thread_self()->user_data);
|
||||
if (thread == RT_NULL) return -RT_ERROR;
|
||||
|
||||
r = rt_mq_recv(thread->mq, event, event_size, RT_WAITING_FOREVER);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
rt_err_t rtgui_thread_recv_nosuspend(rtgui_event_t* event, rt_size_t event_size)
|
||||
{
|
||||
rtgui_thread_t* thread;
|
||||
rt_err_t r;
|
||||
|
||||
/* find rtgui_thread */
|
||||
thread = (rtgui_thread_t*) (rt_thread_self()->user_data);
|
||||
if (thread == RT_NULL) return -RT_ERROR;
|
||||
|
||||
r = rt_mq_recv(thread->mq, event, event_size, 0);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
rt_err_t rtgui_thread_recv_filter(rt_uint32_t type, rtgui_event_t* event, rt_size_t event_size)
|
||||
{
|
||||
rtgui_thread_t* thread;
|
||||
|
||||
/* find rtgui_thread_t */
|
||||
thread = (rtgui_thread_t*) (rt_thread_self()->user_data);
|
||||
if (thread == RT_NULL) return -RT_ERROR;
|
||||
|
||||
while (rt_mq_recv(thread->mq, event, event_size, RT_WAITING_FOREVER) == RT_EOK)
|
||||
{
|
||||
if (event->type == type)
|
||||
{
|
||||
return RT_EOK;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* let widget to handle event */
|
||||
if (thread->widget != RT_NULL &&
|
||||
thread->widget->event_handler != RT_NULL)
|
||||
{
|
||||
thread->widget->event_handler(thread->widget, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
/* RTGUI Timer */
|
||||
/************************************************************************/
|
||||
@@ -522,7 +59,7 @@ static void rtgui_time_out(void* parameter)
|
||||
|
||||
event.timer = timer;
|
||||
|
||||
rtgui_thread_send(timer->tid, &(event.parent), sizeof(rtgui_event_timer_t));
|
||||
rtgui_application_send(timer->tid, &(event.parent), sizeof(rtgui_event_timer_t));
|
||||
}
|
||||
|
||||
rtgui_timer_t* rtgui_timer_create(rt_int32_t time, rt_int32_t flag, rtgui_timeout_func timeout, void* parameter)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <rtgui/rtgui_xml.h>
|
||||
#include <rtgui/rtgui_system.h>
|
||||
#include <rtgui/rtgui_system.h>
|
||||
|
||||
/* Internal states that the parser can be in at any given time. */
|
||||
enum {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
1, 对同一 window 销毁两次会引起 segfault。同时,如果在创建时设置了
|
||||
RTGUI_WIN_STYLE_DESTROY_ON_CLOSE,close 窗口之后不要再去销毁窗口。
|
||||
|
||||
2, 所有的 window 由 topwin 进行管理,用户不要在指定创建具有父窗口的子窗口之后在
|
||||
把这个窗口加为父窗口的 child。这可能会导致子窗口无法显示。
|
||||
|
||||
3, command 事件添加了 wid 参数,用于指定此事件需要传递的目标窗口。
|
||||
|
||||
4, 在 widget 中添加了 on_show 和 on_hide 事件回调函数。他们会在控件显示/隐藏的
|
||||
时候被调用。
|
||||
|
||||
5, slider 控件改为左键减小数值,右键增加数值。横向的 slider 处理左右键,纵向的
|
||||
slider 处理上下键,上面的值小,下面的值大。
|
||||
|
||||
6, view 不再提供 show 方法。如果想单独显示控件,请用 window 包含之。
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
RTGUI for 1.1 路线图(排名不分先后)
|
||||
1, 把 rtgui_thread 给去掉,变成 rtgui_application ,消除原来的 rtgui_thread +
|
||||
mq 的模式。rtgui_application 记录当前依附的 panel,和 panel 的 extent。(Done)
|
||||
1.1, rtgui_application_run 运行主事件循环(Done)
|
||||
1.2, rtgui_application 作为事件的接收者_和_事件派发者。(Done)
|
||||
|
||||
2, workbench,window并成一个,其事件主循环并合并到rtgui_application中。
|
||||
2.1, window 作为有标题栏的 workbench(Done)
|
||||
2.2, 将其事件主循环移至 application 中。(Done)
|
||||
2.3, 将 window 的父类 toplevel 合并进 window 中。所有直接与服务器打交道的从
|
||||
window 继承。(或者将 toplevel 合并进 application 中,因为只有 application 才
|
||||
会和服务器打交道。)
|
||||
2.4 在创建 window 的时候需要指定 parent,如果为 RT_NULL,则此 window 为 root
|
||||
窗口,parent 为当前 rtgui_application。每一个 application 必须有且只有一个根
|
||||
窗口。(Done)
|
||||
2.5 添加一个 FULL_PANEL 的 STYLE。指定此 STYLE 之后会自动填满整个 panel。其
|
||||
与 NO_TITLE 之类的合用可以达到之前 workbench 的效果。(Deprecated)
|
||||
2.6 event_loop 可以设定顶层控件,只会把事件传递给顶层控件。这样可以方便的实
|
||||
现模态窗口。event_loop 靠 object 的一个标志位来判断是否要退出当前循环。(Done)
|
||||
|
||||
3, 将 view 合并进 container,所有容器类继承 container。[note1](Done)
|
||||
|
||||
4, 事件循环完成后不主动销毁控件,销毁任务交由用户完成。但是有些自动销毁是必要的
|
||||
,比如 container 自动销毁其包含的控件(Done)
|
||||
4.1 对于 window 的 onclose事件,保证在其回调函数中可以(但不是必须)安全销毁窗
|
||||
口。这个功能不保证能够实现。(onclose 是在将要关闭窗口的时候触发的,调用它之
|
||||
后 RTGUI 还要进行其他的设置和清理工作,所以不能在 onclose 里销毁窗口)(Cannot
|
||||
Implement)
|
||||
4.2 对 window 添加 RTGUI_WIN_STYLE_DESTROY_ON_CLOSE 。使得其在被关闭时自动销
|
||||
毁。注意:对同一 window 销毁两次会引起 segfault。同时,如果在创建时设置了
|
||||
RTGUI_WIN_STYLE_DESTROY_ON_CLOSE,close 窗口之后不要再去销毁窗口。
|
||||
|
||||
5, API 清理。更详细的文档。
|
||||
|
||||
6, 使 panel 退化为无窗口标题的 window,这样 server 就只记录 window 一种东西的位
|
||||
置。(Done, 删除了 panel,使得整体以 window 为主)
|
||||
|
||||
7, 指定名称的时候不再自己拷贝一份。(我觉得 90% 的情况下名称都是静态的字符串,这
|
||||
时用 strdup其实并没有必要。)(Deprecated)
|
||||
|
||||
8, 添加一些工业控制当中用到的波形、仪表之类的控件。
|
||||
|
||||
9, 在 window 中记录焦点控件,键盘事件由 window 直接投送。各个控件不记录焦点控件
|
||||
。(Done)
|
||||
|
||||
10, 在 widget 中添加 on_show 和 on_hide 事件回调函数。(Done)
|
||||
|
||||
11, 添加 EVENT_WIN_MODAL_ENTER 和 EVENT_WIN_MODAL_EXIT 事件,用来通知窗口管理器
|
||||
(topwin)一个窗口进入模态。窗口管理器根据这个进行相应的设置。
|
||||
|
||||
12, rtgui_filelist_view 不必继承自 container。
|
||||
|
||||
13, 添加 desktop window 支持。(Done)
|
||||
概念与名词:
|
||||
13.1 desktop window:最底层的桌面窗口。它会在所有窗口下面显示,并且不会被它
|
||||
上面的窗口模态掉。它的子窗口是 root window。(继承关系由 RTGUI 管理,不
|
||||
用用户管理)它只有在启用 RTGUI_USING_DESKTOP_WINDOW 时才有此特性。
|
||||
13.2 root window:创建时父窗口为 RT_NULL 的窗口。是用户空间窗口继承树的根。
|
||||
13.3 normal window:创建时父窗口不为 RT_NULL 的窗口。它始终会在父窗口之上显
|
||||
示(它会 clip 父窗口)。normal windows 和 root window 组成一个窗口树。
|
||||
13.4 模态:当一个 normal window 模态显示时会会模态自己所在树的同级窗口
|
||||
和所有父级窗口,但不会影响别的窗口树。被模态的窗口不会接受到用户事
|
||||
件(按键,触摸等)
|
||||
|
||||
----
|
||||
[note1] 我们至少需要一种容器控件来盛放其他的控件,并且能把上层事件传递给被包含
|
||||
的控件。实现这样的功能有一个就好,container 可以担当这个责任。其他需要放多个控
|
||||
件的控件则可以继承/包含这个控件。然后多个容器控件轮换的,notebook 可以来做。
|
||||
notebook可以是有标签和无标签的,有标签的对应一般的 tab 控件,无标签的对应 rtgui
|
||||
for RTT 1.0 的 workbench+view。
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
+196
-196
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user