mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-28 16:14:20 +08:00
sync with RTGUI c074ff2898b9e
Full log is in GitHub. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2222 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
@@ -9,6 +9,7 @@ common/rtgui_object.c
|
||||
common/rtgui_system.c
|
||||
common/rtgui_theme.c
|
||||
common/rtgui_xml.c
|
||||
common/rtgui_app.c
|
||||
common/dc.c
|
||||
common/dc_hw.c
|
||||
common/dc_buffer.c
|
||||
@@ -34,7 +35,6 @@ common/pixel_driver.c
|
||||
""")
|
||||
|
||||
server_src = Split("""
|
||||
server/rtgui_application.c
|
||||
server/driver.c
|
||||
server/mouse.c
|
||||
server/server.c
|
||||
@@ -63,10 +63,10 @@ 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
|
||||
widgets/panel.c
|
||||
""")
|
||||
|
||||
# The set of source files associated with this SConscript file.
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
/*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2012-01-24 onelife add one more blit table which exchanges the
|
||||
* positions of R and B color components in output
|
||||
*/
|
||||
#include <rtgui/rtgui.h>
|
||||
#include <rtgui/blit.h>
|
||||
|
||||
@@ -305,3 +311,63 @@ rtgui_blit_line_func rtgui_blit_line_get(int dst_bpp, int src_bpp)
|
||||
|
||||
return _blit_table[dst_bpp][src_bpp];
|
||||
}
|
||||
|
||||
|
||||
static void rtgui_blit_line_3_2_inv(rt_uint8_t* dst_ptr, rt_uint8_t* src_ptr, int line)
|
||||
{
|
||||
rt_uint16_t* dst;
|
||||
|
||||
dst = (rt_uint16_t*)dst_ptr;
|
||||
line = line / 3;
|
||||
while (line)
|
||||
{
|
||||
*dst = (((*src_ptr << 8) & 0x0000F800) |
|
||||
((*(src_ptr + 1) << 3) & 0x000007E0) |
|
||||
((*(src_ptr + 2) >> 3) & 0x0000001F));
|
||||
|
||||
src_ptr += 3;
|
||||
dst ++;
|
||||
line --;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void rtgui_blit_line_2_2_inv(rt_uint8_t* dst_ptr, rt_uint8_t* src_ptr, int line)
|
||||
{
|
||||
rt_uint16_t *dst, *src;
|
||||
|
||||
dst = (rt_uint16_t *)dst_ptr;
|
||||
src = (rt_uint16_t *)src_ptr;
|
||||
line = line / 2;
|
||||
while (line)
|
||||
{
|
||||
*dst = ((*src << 11) & 0xF800) | (*src & 0x07E0) | ((*src >> 11) & 0x001F);
|
||||
src ++;
|
||||
dst ++;
|
||||
line --;
|
||||
}
|
||||
}
|
||||
|
||||
static const rtgui_blit_line_func _blit_table_inv[5][5] =
|
||||
{
|
||||
/* 0_0, 1_0, 2_0, 3_0, 4_0 */
|
||||
{RT_NULL, RT_NULL, RT_NULL, RT_NULL, RT_NULL },
|
||||
/* 0_1, 1_1, 2_1, 3_1, 4_1 */
|
||||
{RT_NULL, rtgui_blit_line_direct, rtgui_blit_line_2_1, rtgui_blit_line_3_1, rtgui_blit_line_4_1 },
|
||||
/* 0_2, 1_2, 2_2, 3_2, 4_2 */
|
||||
{RT_NULL, rtgui_blit_line_1_2, rtgui_blit_line_2_2_inv, rtgui_blit_line_3_2_inv, rtgui_blit_line_4_2 },
|
||||
/* 0_3, 1_3, 2_3, 3_3, 4_3 */
|
||||
{RT_NULL, rtgui_blit_line_1_3, rtgui_blit_line_2_3, rtgui_blit_line_direct, rtgui_blit_line_4_3 },
|
||||
/* 0_4, 1_4, 2_4, 3_4, 4_4 */
|
||||
{RT_NULL, rtgui_blit_line_1_4, rtgui_blit_line_2_4, rtgui_blit_line_3_4, rtgui_blit_line_direct },
|
||||
};
|
||||
|
||||
rtgui_blit_line_func rtgui_blit_line_get_inv(int dst_bpp, int src_bpp)
|
||||
{
|
||||
RT_ASSERT(dst_bpp>0 && dst_bpp < 5);
|
||||
RT_ASSERT(src_bpp>0 && src_bpp < 5);
|
||||
|
||||
return _blit_table_inv[dst_bpp][src_bpp];
|
||||
}
|
||||
|
||||
|
||||
@@ -138,12 +138,12 @@ void rtgui_dc_draw_vertical_line(struct rtgui_dc* dc, int x, int y1, int y2)
|
||||
color = RTGUI_DC_FC(dc);
|
||||
|
||||
RTGUI_DC_FC(dc) = dark_grey;
|
||||
rtgui_dc_draw_hline(dc, x, y1, y2);
|
||||
rtgui_dc_draw_vline(dc, x, y1, y2);
|
||||
|
||||
x ++;
|
||||
|
||||
RTGUI_DC_FC(dc) = high_light;
|
||||
rtgui_dc_draw_hline(dc, x, y1, y2);
|
||||
rtgui_dc_draw_vline(dc, x, y1, y2);
|
||||
|
||||
/* restore color */
|
||||
RTGUI_DC_FC(dc) = color;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include <rtgui/driver.h>
|
||||
#include <rtgui/rtgui_system.h>
|
||||
#include <rtgui/rtgui_application.h>
|
||||
#include <rtgui/rtgui_app.h>
|
||||
#include <rtgui/rtgui_server.h>
|
||||
#include <rtgui/widgets/container.h>
|
||||
#include <rtgui/widgets/window.h>
|
||||
@@ -139,7 +139,7 @@ struct rtgui_dc* rtgui_dc_client_create(rtgui_widget_t* owner)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (RTGUI_IS_APPLICATION(owner->toplevel))
|
||||
else if (RTGUI_IS_APP(owner->toplevel))
|
||||
{
|
||||
RT_ASSERT(0);
|
||||
}
|
||||
@@ -207,7 +207,7 @@ static rt_bool_t rtgui_dc_client_fini(struct rtgui_dc* dc)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (RTGUI_IS_APPLICATION(owner->toplevel) ||
|
||||
else if (RTGUI_IS_APP(owner->toplevel) ||
|
||||
RTGUI_IS_WIN(owner->toplevel))
|
||||
{
|
||||
rtgui_toplevel_t* top = RTGUI_TOPLEVEL(owner->toplevel);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <rtgui/dc_hw.h>
|
||||
#include <rtgui/driver.h>
|
||||
#include <rtgui/rtgui_system.h>
|
||||
#include <rtgui/rtgui_application.h>
|
||||
#include <rtgui/rtgui_app.h>
|
||||
#include <rtgui/rtgui_server.h>
|
||||
|
||||
#include <rtgui/widgets/container.h>
|
||||
@@ -117,7 +117,7 @@ struct rtgui_dc* rtgui_dc_hw_create(rtgui_widget_t* owner)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (RTGUI_IS_APPLICATION(owner->toplevel) ||
|
||||
else if (RTGUI_IS_APP(owner->toplevel) ||
|
||||
RTGUI_IS_WIN(owner->toplevel))
|
||||
{
|
||||
rtgui_toplevel_t* top = RTGUI_TOPLEVEL(owner->toplevel);
|
||||
@@ -184,7 +184,7 @@ static rt_bool_t rtgui_dc_hw_fini(struct rtgui_dc* dc)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (RTGUI_IS_APPLICATION(owner->toplevel) ||
|
||||
else if (RTGUI_IS_APP(owner->toplevel) ||
|
||||
RTGUI_IS_WIN(owner->toplevel))
|
||||
{
|
||||
rtgui_toplevel_t* top = RTGUI_TOPLEVEL(owner->toplevel);
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2012-01-24 onelife fix a bug in framebuffer_draw_raw_hline
|
||||
*/
|
||||
#include <rtgui/rtgui_system.h>
|
||||
#include <rtgui/driver.h>
|
||||
|
||||
@@ -108,7 +113,7 @@ 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));
|
||||
rt_memcpy(dst, pixels, (x2 - x1 + 1) * (rtgui_graphic_get_device()->bits_per_pixel/8));
|
||||
}
|
||||
|
||||
const struct rtgui_graphic_driver_ops _framebuffer_rgb565_ops =
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2009-10-16 Bernard first version
|
||||
* 2012-01-24 onelife add TJpgDec (Tiny JPEG Decompressor) support
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
#include <rtgui/image.h>
|
||||
@@ -27,7 +28,7 @@
|
||||
#ifdef RTGUI_IMAGE_BMP
|
||||
#include <rtgui/image_bmp.h>
|
||||
#endif
|
||||
#ifdef RTGUI_IMAGE_JPEG
|
||||
#if (defined(RTGUI_IMAGE_JPEG) || defined(RTGUI_IMAGE_TJPGD))
|
||||
#include <rtgui/image_jpeg.h>
|
||||
#endif
|
||||
#ifdef RTGUI_IMAGE_PNG
|
||||
@@ -50,7 +51,7 @@ void rtgui_system_image_init(void)
|
||||
rtgui_image_bmp_init();
|
||||
#endif
|
||||
|
||||
#ifdef RTGUI_IMAGE_JPEG
|
||||
#if (defined(RTGUI_IMAGE_JPEG) || defined(RTGUI_IMAGE_TJPGD))
|
||||
rtgui_image_jpeg_init();
|
||||
#endif
|
||||
|
||||
|
||||
+688
-511
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -242,9 +242,16 @@ static void rtgui_image_png_unload(struct rtgui_image* image)
|
||||
|
||||
static void rtgui_image_png_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect)
|
||||
{
|
||||
struct rtgui_graphic_driver* hwdev = rtgui_graphic_get_device();
|
||||
rt_uint16_t x, y, w, h;
|
||||
rtgui_color_t* ptr;
|
||||
struct rtgui_image_png* png;
|
||||
int fg_maxsample;
|
||||
int ialpha;
|
||||
float alpha;
|
||||
rtgui_color_t color;
|
||||
rtgui_color_t c, bgcolor;
|
||||
int fc[3], bc[3];
|
||||
|
||||
RT_ASSERT(image != RT_NULL && dc != RT_NULL && rect != RT_NULL);
|
||||
RT_ASSERT(image->data != RT_NULL);
|
||||
@@ -255,21 +262,56 @@ static void rtgui_image_png_blit(struct rtgui_image* image, struct rtgui_dc* dc,
|
||||
else w = rtgui_rect_width(*rect);
|
||||
if (image->h < rtgui_rect_height(*rect)) h = image->h;
|
||||
else h = rtgui_rect_height(*rect);
|
||||
|
||||
fg_maxsample = (1 << png->info_ptr->bit_depth) - 1;
|
||||
|
||||
if (png->pixels != RT_NULL)
|
||||
{
|
||||
ptr = (rtgui_color_t*)png->pixels;
|
||||
/* draw each point within dc */
|
||||
bgcolor = rtgui_color_from_565(RTGUI_DC_BC(dc));
|
||||
bc[0] = RTGUI_RGB_R(bgcolor);
|
||||
bc[1] = RTGUI_RGB_G(bgcolor);
|
||||
bc[2] = RTGUI_RGB_B(bgcolor);
|
||||
/* draw each point within dc */
|
||||
for (y = 0; y < h; y ++)
|
||||
{
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
/* not alpha */
|
||||
if ((*ptr >> 24) != 255)
|
||||
{
|
||||
rtgui_dc_draw_color_point(dc, x + rect->x1, y + rect->y1, *ptr);
|
||||
}
|
||||
|
||||
c = *ptr;
|
||||
ialpha = RTGUI_RGB_A(c);
|
||||
if(ialpha == 0)
|
||||
{
|
||||
/*
|
||||
* Foreground image is transparent hear.
|
||||
* If the background image is already in the frame
|
||||
* buffer, there is nothing to do.
|
||||
*/
|
||||
}
|
||||
else if (ialpha == fg_maxsample)
|
||||
{
|
||||
/*
|
||||
* Copy foreground pixel to frame buffer.
|
||||
*/
|
||||
rtgui_dc_draw_color_point(dc, x + rect->x1, y + rect->y1, c);
|
||||
}
|
||||
else
|
||||
{ /* output = alpha * foreground + (1-alpha) * background */
|
||||
/*
|
||||
* Compositing is necessary.
|
||||
* Get floating-point alpha and its complement.
|
||||
* Note: alpha is always linear: gamma does not
|
||||
* affect it.
|
||||
*/
|
||||
fc[0] = RTGUI_RGB_R(c);
|
||||
fc[1] = RTGUI_RGB_G(c);
|
||||
fc[2] = RTGUI_RGB_B(c);
|
||||
|
||||
alpha = (float) ialpha / fg_maxsample;
|
||||
color = RTGUI_RGB( (rt_uint8_t)(fc[0]*alpha + bc[0]*(1-alpha)),
|
||||
(rt_uint8_t)(fc[1]*alpha + bc[1]*(1-alpha)),
|
||||
(rt_uint8_t)(fc[2]*alpha + bc[2]*(1-alpha)));
|
||||
rtgui_dc_draw_color_point(dc, x + rect->x1, y + rect->y1, color);
|
||||
}
|
||||
/* move to next color buffer */
|
||||
ptr ++;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,23 @@
|
||||
/*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2012-01-24 onelife add mono color support
|
||||
* 2012-01-24 onelife fix a bug in _pixel_draw_raw_hline
|
||||
*/
|
||||
#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_mono_set_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
rt_uint8_t pixel;
|
||||
|
||||
pixel = rtgui_color_to_mono(*c);
|
||||
gfx_device_ops->set_pixel((char*)&pixel, x, y);
|
||||
}
|
||||
|
||||
static void _pixel_rgb565p_set_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
@@ -28,6 +42,14 @@ static void _pixel_rgb888_set_pixel(rtgui_color_t *c, int x, int y)
|
||||
gfx_device_ops->set_pixel((char*)&pixel, x, y);
|
||||
}
|
||||
|
||||
static void _pixel_mono_get_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
rt_uint8_t pixel;
|
||||
|
||||
gfx_device_ops->get_pixel((char*)&pixel, x, y);
|
||||
*c = rtgui_color_from_mono(pixel);
|
||||
}
|
||||
|
||||
static void _pixel_rgb565p_get_pixel(rtgui_color_t *c, int x, int y)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
@@ -52,6 +74,14 @@ static void _pixel_rgb888_get_pixel(rtgui_color_t *c, int x, int y)
|
||||
*c = rtgui_color_from_888(pixel);
|
||||
}
|
||||
|
||||
static void _pixel_mono_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
|
||||
{
|
||||
rt_uint8_t pixel;
|
||||
|
||||
pixel = rtgui_color_to_mono(*c);
|
||||
gfx_device_ops->draw_hline((char*)&pixel, x1, x2, y);
|
||||
}
|
||||
|
||||
static void _pixel_rgb565p_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
@@ -76,6 +106,14 @@ static void _pixel_rgb888_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
|
||||
gfx_device_ops->draw_hline((char*)&pixel, x1, x2, y);
|
||||
}
|
||||
|
||||
static void _pixel_mono_draw_vline(rtgui_color_t *c, int x, int y1, int y2)
|
||||
{
|
||||
rt_uint8_t pixel;
|
||||
|
||||
pixel = rtgui_color_to_mono(*c);
|
||||
gfx_device_ops->draw_vline((char*)&pixel, x, y1, y2);
|
||||
}
|
||||
|
||||
static void _pixel_rgb565p_draw_vline(rtgui_color_t *c, int x, int y1, int y2)
|
||||
{
|
||||
rt_uint16_t pixel;
|
||||
@@ -102,13 +140,19 @@ static void _pixel_rgb888_draw_vline(rtgui_color_t *c, int x, int y1, int 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));
|
||||
gfx_device_ops->blit_line((char*)pixels, x1, x2, y);
|
||||
}
|
||||
|
||||
/* pixel device */
|
||||
const struct rtgui_graphic_driver_ops _pixel_mono_ops =
|
||||
{
|
||||
_pixel_mono_set_pixel,
|
||||
_pixel_mono_get_pixel,
|
||||
_pixel_mono_draw_hline,
|
||||
_pixel_mono_draw_vline,
|
||||
_pixel_draw_raw_hline,
|
||||
};
|
||||
|
||||
const struct rtgui_graphic_driver_ops _pixel_rgb565p_ops =
|
||||
{
|
||||
_pixel_rgb565p_set_pixel,
|
||||
@@ -140,6 +184,9 @@ const struct rtgui_graphic_driver_ops *rtgui_pixel_device_get_ops(int pixel_form
|
||||
{
|
||||
switch (pixel_format)
|
||||
{
|
||||
case RTGRAPHIC_PIXEL_FORMAT_MONO:
|
||||
return &_pixel_mono_ops;
|
||||
|
||||
case RTGRAPHIC_PIXEL_FORMAT_RGB565:
|
||||
return &_pixel_rgb565_ops;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -14,3 +14,5 @@ slider 处理上下键,上面的值小,下面的值大。
|
||||
|
||||
6, view 不再提供 show 方法。如果想单独显示控件,请用 window 包含之。
|
||||
|
||||
7, 若窗口在销毁(destroy)时没有关闭,则 RTGUI 会先关闭之。也会调用 on_close 函数
|
||||
但是此函数的返回值会被忽略。
|
||||
|
||||
@@ -46,9 +46,9 @@ mq 的模式。rtgui_application 记录当前依附的 panel,和 panel 的 ext
|
||||
10, 在 widget 中添加 on_show 和 on_hide 事件回调函数。(Done)
|
||||
|
||||
11, 添加 EVENT_WIN_MODAL_ENTER 和 EVENT_WIN_MODAL_EXIT 事件,用来通知窗口管理器
|
||||
(topwin)一个窗口进入模态。窗口管理器根据这个进行相应的设置。
|
||||
(topwin)一个窗口进入模态。窗口管理器根据这个进行相应的设置。(Done)
|
||||
|
||||
12, rtgui_filelist_view 不必继承自 container。
|
||||
12, rtgui_filelist_view 不必继承自 container。(Deprecated)
|
||||
|
||||
13, 添加 desktop window 支持。(Done)
|
||||
概念与名词:
|
||||
|
||||
@@ -5,5 +5,6 @@
|
||||
|
||||
typedef void (*rtgui_blit_line_func)(rt_uint8_t* dst, rt_uint8_t* src, int line);
|
||||
rtgui_blit_line_func rtgui_blit_line_get(int dst_bpp, int src_bpp);
|
||||
rtgui_blit_line_func rtgui_blit_line_get_inv(int dst_bpp, int src_bpp);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2009-10-16 Bernard first version
|
||||
* 2012-01-24 onelife add mono color support
|
||||
*/
|
||||
#ifndef __RTGUI_COLOR_H__
|
||||
#define __RTGUI_COLOR_H__
|
||||
@@ -45,6 +46,30 @@ extern const rtgui_color_t light_grey;
|
||||
* BBBB BBBB GGGG GGGG RRRR RRRR
|
||||
*/
|
||||
|
||||
/* convert rtgui color to mono */
|
||||
rt_inline rt_uint8_t rtgui_color_to_mono(rtgui_color_t c)
|
||||
{
|
||||
rt_uint8_t pixel;
|
||||
|
||||
pixel = (RTGUI_RGB_R(c) | RTGUI_RGB_G(c) | RTGUI_RGB_B(c)) ? 0x01 : 0x00;
|
||||
return pixel;
|
||||
}
|
||||
|
||||
rt_inline rtgui_color_t rtgui_color_from_mono(rt_uint8_t pixel)
|
||||
{
|
||||
rtgui_color_t color;
|
||||
|
||||
if (pixel)
|
||||
{
|
||||
color = white;
|
||||
}
|
||||
else
|
||||
{
|
||||
color = black;
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
/* convert rtgui color to BBBBBGGGGGGRRRRR */
|
||||
rt_inline rt_uint16_t rtgui_color_to_565(rtgui_color_t c)
|
||||
{
|
||||
|
||||
@@ -54,6 +54,7 @@ struct rtgui_graphic_driver* rtgui_graphic_driver_get_default(void);
|
||||
void rtgui_graphic_driver_get_rect(const struct rtgui_graphic_driver *driver, rtgui_rect_t *rect);
|
||||
void rtgui_graphic_driver_screen_update(const struct rtgui_graphic_driver* driver, rtgui_rect_t *rect);
|
||||
rt_uint8_t* rtgui_graphic_driver_get_framebuffer(const struct rtgui_graphic_driver* driver);
|
||||
rt_uint8_t* rtgui_graphic_driver_get_default_framebuffer(void);
|
||||
|
||||
rt_err_t rtgui_graphic_set_device(rt_device_t device);
|
||||
|
||||
|
||||
@@ -21,6 +21,11 @@
|
||||
* rtgui_event_generic */
|
||||
enum _rtgui_event_type
|
||||
{
|
||||
/* applications event */
|
||||
RTGUI_EVENT_APP_CREATE, /* create an application */
|
||||
RTGUI_EVENT_APP_DESTROY, /* destroy an application */
|
||||
RTGUI_EVENT_APP_ACTIVATE, /* activate an application */
|
||||
|
||||
/* window event */
|
||||
RTGUI_EVENT_WIN_CREATE, /* create a window */
|
||||
RTGUI_EVENT_WIN_DESTROY, /* destroy a window */
|
||||
@@ -43,6 +48,8 @@ enum _rtgui_event_type
|
||||
RTGUI_EVENT_UPDATE_END, /* update a rect */
|
||||
RTGUI_EVENT_MONITOR_ADD, /* add a monitor rect */
|
||||
RTGUI_EVENT_MONITOR_REMOVE, /* remove a monitor rect */
|
||||
RTGUI_EVENT_SHOW, /* the widget is going to be shown */
|
||||
RTGUI_EVENT_HIDE, /* the widget is going to be hidden */
|
||||
RTGUI_EVENT_PAINT, /* paint on screen */
|
||||
RTGUI_EVENT_TIMER, /* timer */
|
||||
|
||||
@@ -94,6 +101,24 @@ typedef struct rtgui_event rtgui_event_t;
|
||||
(e)->ack = RT_NULL; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* RTGUI Application Event
|
||||
*/
|
||||
struct rtgui_event_application
|
||||
{
|
||||
struct rtgui_event parent;
|
||||
|
||||
struct rtgui_app* app;
|
||||
};
|
||||
|
||||
/* gui application init */
|
||||
#define RTGUI_EVENT_APP_CREATE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_APP_CREATE)
|
||||
#define RTGUI_EVENT_APP_DESTROY_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_APP_DESTROY)
|
||||
#define RTGUI_EVENT_APP_ACTIVATE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_APP_ACTIVATE)
|
||||
|
||||
/*
|
||||
* RTGUI Window Event
|
||||
*/
|
||||
#define _RTGUI_EVENT_WIN_ELEMENTS \
|
||||
struct rtgui_event parent; \
|
||||
struct rtgui_win *wid;
|
||||
@@ -151,6 +176,16 @@ struct rtgui_event_win_resize
|
||||
#define RTGUI_EVENT_WIN_RESIZE_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_RESIZE)
|
||||
#define RTGUI_EVENT_WIN_MODAL_ENTER_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_WIN_MODAL_ENTER)
|
||||
|
||||
/*
|
||||
* RTGUI set window manager
|
||||
*/
|
||||
struct rtgui_event_set_wm
|
||||
{
|
||||
struct rtgui_event parent;
|
||||
struct rtgui_app *app;
|
||||
};
|
||||
#define RTGUI_EVENT_SET_WM_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_SET_WM);
|
||||
|
||||
/*
|
||||
* RTGUI Other Event
|
||||
*/
|
||||
@@ -214,6 +249,12 @@ struct rtgui_event_clip_info
|
||||
#define RTGUI_EVENT_PAINT_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_PAINT)
|
||||
#define RTGUI_EVENT_TIMER_INIT(e) RTGUI_EVENT_INIT(&((e)->parent), RTGUI_EVENT_TIMER)
|
||||
|
||||
#define rtgui_event_show rtgui_event
|
||||
#define rtgui_event_hide rtgui_event
|
||||
|
||||
#define RTGUI_EVENT_SHOW_INIT(e) RTGUI_EVENT_INIT((e), RTGUI_EVENT_SHOW)
|
||||
#define RTGUI_EVENT_HIDE_INIT(e) RTGUI_EVENT_INIT((e), RTGUI_EVENT_HIDE)
|
||||
|
||||
/*
|
||||
* RTGUI Mouse and Keyboard Event
|
||||
*/
|
||||
@@ -325,6 +366,12 @@ struct rtgui_event_resize
|
||||
union rtgui_event_generic
|
||||
{
|
||||
struct rtgui_event base;
|
||||
|
||||
struct rtgui_event_application app_create;
|
||||
struct rtgui_event_application app_destroy;
|
||||
struct rtgui_event_application app_activate;
|
||||
|
||||
struct rtgui_event_set_wm set_wm;
|
||||
struct rtgui_event_win win_base;
|
||||
struct rtgui_event_win_create win_create;
|
||||
struct rtgui_event_win_move win_move;
|
||||
|
||||
@@ -30,7 +30,7 @@ struct rtgui_font;
|
||||
|
||||
typedef struct rtgui_win rtgui_win_t;
|
||||
typedef struct rtgui_workbench rtgui_workbench_t;
|
||||
typedef rt_bool_t (*rtgui_event_handler_ptr)(struct rtgui_object* widget, struct rtgui_event* event);
|
||||
typedef rt_bool_t (*rtgui_event_handler_ptr)(struct rtgui_object* object, struct rtgui_event* event);
|
||||
typedef void (*rtgui_onbutton_func_t)(struct rtgui_object* object, struct rtgui_event* event);
|
||||
|
||||
struct rtgui_point
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* File : rtgui_application.h
|
||||
* This file is part of RTGUI in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2012-01-13 Grissiom first version
|
||||
*/
|
||||
#ifndef __RTGUI_APPLICATION_H__
|
||||
#define __RTGUI_APPLICATION_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtgui/rtgui.h>
|
||||
#include <rtgui/event.h>
|
||||
#include <rtgui/rtgui_system.h>
|
||||
|
||||
DECLARE_CLASS_TYPE(application);
|
||||
|
||||
/** Gets the type of a application */
|
||||
#define RTGUI_APP_TYPE (RTGUI_TYPE(application))
|
||||
/** Casts the object to an rtgui_workbench */
|
||||
#define RTGUI_APP(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_APP_TYPE, struct rtgui_app))
|
||||
/** Checks if the object is an rtgui_workbench */
|
||||
#define RTGUI_IS_APP(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_APP_TYPE))
|
||||
|
||||
enum rtgui_app_flag
|
||||
{
|
||||
RTGUI_APP_FLAG_EXITED = 0x04,
|
||||
RTGUI_APP_FLAG_SHOWN = 0x08
|
||||
};
|
||||
|
||||
typedef void (*rtgui_idle_func_t)(struct rtgui_object* obj, struct rtgui_event *event);
|
||||
|
||||
struct rtgui_app
|
||||
{
|
||||
struct rtgui_object parent;
|
||||
|
||||
/* application name */
|
||||
unsigned char *name;
|
||||
struct rtgui_image* icon;
|
||||
|
||||
enum rtgui_app_flag state_flag;
|
||||
|
||||
rt_uint16_t ref_count;
|
||||
rt_uint16_t exit_code;
|
||||
|
||||
/* the thread id */
|
||||
rt_thread_t tid;
|
||||
/* the RTGUI server id */
|
||||
rt_thread_t server;
|
||||
|
||||
/* the message queue of thread */
|
||||
rt_mq_t mq;
|
||||
/* event buffer */
|
||||
rt_uint8_t event_buffer[sizeof(union rtgui_event_generic)];
|
||||
|
||||
/* if not RT_NULL, the application is in modal state by modal_object. If is
|
||||
* RT_NULL, nothing modal windows. */
|
||||
struct rtgui_object *modal_object;
|
||||
struct rtgui_object *main_object;
|
||||
|
||||
/* on idle event handler */
|
||||
rtgui_idle_func_t on_idle;
|
||||
};
|
||||
|
||||
/**
|
||||
* create an application named @myname on thread @param tid
|
||||
*/
|
||||
struct rtgui_app* rtgui_app_create(rt_thread_t tid, const char *title);
|
||||
void rtgui_app_destroy(struct rtgui_app *app);
|
||||
rt_bool_t rtgui_app_event_handler(struct rtgui_object* obj, rtgui_event_t* event);
|
||||
|
||||
rt_base_t rtgui_app_run(struct rtgui_app *app);
|
||||
void rtgui_app_exit(struct rtgui_app *app, rt_uint16_t code);
|
||||
|
||||
void rtgui_app_set_onidle(rtgui_idle_func_t onidle);
|
||||
rtgui_idle_func_t rtgui_app_get_onidle(void);
|
||||
struct rtgui_app* rtgui_app_self(void);
|
||||
|
||||
rt_err_t rtgui_app_set_as_wm(void);
|
||||
void rtgui_app_set_main_win(struct rtgui_win* win);
|
||||
|
||||
#endif /* end of include guard: RTGUI_APPLICATION_H */
|
||||
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* File : rtgui_application.h
|
||||
* This file is part of RTGUI in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2012-01-13 Grissiom first version
|
||||
*/
|
||||
#ifndef __RTGUI_APPLICATION_H__
|
||||
#define __RTGUI_APPLICATION_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtgui/rtgui.h>
|
||||
#include <rtgui/event.h>
|
||||
#include <rtgui/rtgui_system.h>
|
||||
|
||||
DECLARE_CLASS_TYPE(application);
|
||||
|
||||
/** Gets the type of a application */
|
||||
#define RTGUI_APPLICATION_TYPE (RTGUI_TYPE(application))
|
||||
/** Casts the object to an rtgui_workbench */
|
||||
#define RTGUI_APPLICATION(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_APPLICATION_TYPE, struct rtgui_application))
|
||||
/** Checks if the object is an rtgui_workbench */
|
||||
#define RTGUI_IS_APPLICATION(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_APPLICATION_TYPE))
|
||||
|
||||
enum rtgui_application_flag
|
||||
{
|
||||
RTGUI_APPLICATION_FLAG_EXITED = 0x04,
|
||||
RTGUI_APPLICATION_FLAG_SHOWN = 0x08
|
||||
};
|
||||
|
||||
typedef void (*rtgui_idle_func)(struct rtgui_object* obj, struct rtgui_event *event);
|
||||
|
||||
struct rtgui_application
|
||||
{
|
||||
struct rtgui_object parent;
|
||||
|
||||
/* application name */
|
||||
unsigned char *name;
|
||||
|
||||
enum rtgui_application_flag state_flag;
|
||||
|
||||
rt_uint16_t ref_count;
|
||||
rt_uint16_t exit_code;
|
||||
|
||||
/* the thread id */
|
||||
rt_thread_t tid;
|
||||
rt_thread_t server;
|
||||
|
||||
/* the message queue of thread */
|
||||
rt_mq_t mq;
|
||||
/* event buffer */
|
||||
rt_uint8_t event_buffer[sizeof(union rtgui_event_generic)];
|
||||
|
||||
/* if not RT_NULL, the application is modaled by modal_object. If is
|
||||
* RT_NULL, nothing modals. */
|
||||
struct rtgui_object *modal_object;
|
||||
|
||||
/* on idle event handler */
|
||||
rtgui_idle_func on_idle;
|
||||
};
|
||||
|
||||
/**
|
||||
* create an application named @myname on thread @param tid
|
||||
*/
|
||||
struct rtgui_application* rtgui_application_create(
|
||||
rt_thread_t tid,
|
||||
const char *myname);
|
||||
void rtgui_application_destroy(struct rtgui_application *app);
|
||||
rt_err_t rtgui_application_show(struct rtgui_application *app);
|
||||
rt_err_t rtgui_application_hide(struct rtgui_application *app);
|
||||
|
||||
rt_base_t rtgui_application_run(struct rtgui_application *app);
|
||||
void rtgui_application_exit(struct rtgui_application *app, rt_uint16_t code);
|
||||
|
||||
void rtgui_application_set_onidle(rtgui_idle_func onidle);
|
||||
rtgui_idle_func rtgui_application_get_onidle(void);
|
||||
struct rtgui_application* rtgui_application_self(void);
|
||||
|
||||
rt_thread_t rtgui_application_get_server(void);
|
||||
|
||||
void rtgui_application_set_root_object(struct rtgui_object* object);
|
||||
struct rtgui_object* rtgui_application_get_root_object(void);
|
||||
|
||||
struct rtgui_event;
|
||||
rt_err_t rtgui_application_send(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size);
|
||||
rt_err_t rtgui_application_send_urgent(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size);
|
||||
rt_err_t rtgui_application_send_sync(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size);
|
||||
rt_err_t rtgui_application_ack(struct rtgui_event* event, rt_int32_t status);
|
||||
rt_err_t rtgui_application_recv(struct rtgui_event* event, rt_size_t event_size);
|
||||
rt_err_t rtgui_application_recv_nosuspend(struct rtgui_event* event, rt_size_t event_size);
|
||||
rt_err_t rtgui_application_recv_filter(rt_uint32_t type, struct rtgui_event* event, rt_size_t event_size);
|
||||
|
||||
#endif /* end of include guard: RTGUI_APPLICATION_H */
|
||||
@@ -77,5 +77,6 @@
|
||||
//#define RTGUI_USING_DESKTOP_WINDOW
|
||||
|
||||
#define RTGUI_EVENT_DEBUG
|
||||
#undef RTGUI_USING_SMALL_SIZE
|
||||
// #undef RTGUI_USING_SMALL_SIZE
|
||||
|
||||
#endif
|
||||
|
||||
@@ -31,7 +31,7 @@ extern "C" {
|
||||
/** Casts the function pointer to an rtgui_constructor */
|
||||
#define RTGUI_DESTRUCTOR(destructor) ((rtgui_destructor_t)(destructor))
|
||||
|
||||
/* pre-definetion */
|
||||
/* pre-definition */
|
||||
struct rtgui_object;
|
||||
typedef struct rtgui_object rtgui_object_t;
|
||||
typedef void (*rtgui_constructor_t)(rtgui_object_t *object);
|
||||
@@ -125,9 +125,6 @@ rt_bool_t rtgui_object_event_handler(struct rtgui_object *object, struct rtgui_e
|
||||
/* supress compiler warning */ \
|
||||
widget = widget;
|
||||
|
||||
void rtgui_object_name_set(rtgui_object_t *object, const char *name);
|
||||
const char *rtgui_object_name_get(rtgui_object_t *object);
|
||||
|
||||
rtgui_object_t *rtgui_object_check_cast(rtgui_object_t *object, rtgui_type_t *type, const char* func, int line);
|
||||
rtgui_type_t *rtk_object_object_type_get(rtgui_object_t *object);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
/* RTGUI server definitions */
|
||||
|
||||
/* top window definitions in server */
|
||||
enum
|
||||
enum rtgui_topwin_flag
|
||||
{
|
||||
WINTITLE_NO = 0x01,
|
||||
WINTITLE_BORDER = 0x02,
|
||||
@@ -34,7 +34,9 @@ enum
|
||||
/* window is modaled by other window */
|
||||
WINTITLE_MODALED = 0x80,
|
||||
/* window is modaling other window */
|
||||
WINTITLE_MODALING = 0x100
|
||||
WINTITLE_MODALING = 0x100,
|
||||
WINTITLE_ONTOP = 0x200,
|
||||
WINTITLE_ONBTM = 0x400,
|
||||
};
|
||||
|
||||
#define WINTITLE_HEIGHT 20
|
||||
@@ -45,7 +47,7 @@ enum
|
||||
struct rtgui_topwin
|
||||
{
|
||||
/* the window flag */
|
||||
rt_uint32_t flag;
|
||||
enum rtgui_topwin_flag flag;
|
||||
/* event mask */
|
||||
rt_uint32_t mask;
|
||||
|
||||
|
||||
@@ -53,5 +53,16 @@ void* rtgui_realloc(void* ptr, rt_size_t size);
|
||||
#define rtgui_enter_critical rt_enter_critical
|
||||
#define rtgui_exit_critical rt_exit_critical
|
||||
|
||||
rt_thread_t rtgui_get_server(void);
|
||||
|
||||
struct rtgui_event;
|
||||
rt_err_t rtgui_send(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size);
|
||||
rt_err_t rtgui_send_urgent(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size);
|
||||
rt_err_t rtgui_send_sync(rt_thread_t tid, struct rtgui_event* event, rt_size_t event_size);
|
||||
rt_err_t rtgui_ack(struct rtgui_event* event, rt_int32_t status);
|
||||
rt_err_t rtgui_recv(struct rtgui_event* event, rt_size_t event_size);
|
||||
rt_err_t rtgui_recv_nosuspend(struct rtgui_event* event, rt_size_t event_size);
|
||||
rt_err_t rtgui_recv_filter(rt_uint32_t type, struct rtgui_event* event, rt_size_t event_size);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* File : list_view.h
|
||||
* This file is part of RTGUI in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2010, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2010-01-06 Bernard first version
|
||||
*/
|
||||
|
||||
#ifndef __RTGUI_ABOUT_VIEW_H__
|
||||
#define __RTGUI_ABOUT_VIEW_H__
|
||||
|
||||
#include <rtgui/rtgui.h>
|
||||
#include <rtgui/image.h>
|
||||
#include <rtgui/rtgui_system.h>
|
||||
#include <rtgui/widgets/container.h>
|
||||
|
||||
DECLARE_CLASS_TYPE(aboutview);
|
||||
/** Gets the type of a about view */
|
||||
#define RTGUI_ABOUT_VIEW_TYPE (RTGUI_TYPE(aboutview))
|
||||
/** Casts the object to a about view */
|
||||
#define RTGUI_ABOUT_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_ABOUT_VIEW_TYPE, rtgui_about_view_t))
|
||||
/** Checks if the object is a about view */
|
||||
#define RTGUI_IS_ABOUT_VIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_ABOUT_VIEW_TYPE))
|
||||
|
||||
struct rtgui_about_view
|
||||
{
|
||||
struct rtgui_container parent;
|
||||
|
||||
/* widget private data */
|
||||
rtgui_image_t* logo;
|
||||
const char* description;
|
||||
};
|
||||
typedef struct rtgui_about_view rtgui_about_view_t;
|
||||
|
||||
rtgui_about_view_t* rtgui_about_view_create(rtgui_image_t *logo, const char* description);
|
||||
rt_bool_t rtgui_about_view_event_handler(struct rtgui_object* widget, struct rtgui_event* event);
|
||||
|
||||
#endif
|
||||
@@ -33,26 +33,23 @@ DECLARE_CLASS_TYPE(box);
|
||||
|
||||
struct rtgui_box
|
||||
{
|
||||
struct rtgui_container parent;
|
||||
struct rtgui_object parent;
|
||||
|
||||
rt_uint16_t orient;
|
||||
rt_uint16_t border_size;
|
||||
|
||||
struct rtgui_container* container;
|
||||
};
|
||||
typedef struct rtgui_box rtgui_box_t;
|
||||
|
||||
struct rtgui_box* rtgui_box_create(int orientation, rtgui_rect_t* rect);
|
||||
struct rtgui_box* rtgui_box_create(int orientation, int border_size);
|
||||
void rtgui_box_destroy(struct rtgui_box* box);
|
||||
|
||||
rt_bool_t rtgui_box_event_handler(struct rtgui_object* object, rtgui_event_t* event);
|
||||
|
||||
void rtgui_box_append(rtgui_box_t* box, rtgui_widget_t* widget);
|
||||
void rtgui_box_layout(rtgui_box_t* box);
|
||||
|
||||
rt_uint32_t rtgui_box_get_width(rtgui_box_t* box);
|
||||
rt_uint32_t rtgui_box_get_height(rtgui_box_t* box);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#define __RTGUI_CONTAINER_H__
|
||||
|
||||
#include <rtgui/widgets/widget.h>
|
||||
#include <rtgui/widgets/box.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -35,6 +36,9 @@ struct rtgui_container
|
||||
{
|
||||
struct rtgui_widget parent;
|
||||
|
||||
/* layout box */
|
||||
struct rtgui_box* layout_box;
|
||||
|
||||
rtgui_list_t children;
|
||||
};
|
||||
typedef struct rtgui_container rtgui_container_t;
|
||||
@@ -44,12 +48,9 @@ void rtgui_container_destroy(rtgui_container_t* container);
|
||||
|
||||
rt_bool_t rtgui_container_event_handler(struct rtgui_object* widget, struct rtgui_event* event);
|
||||
|
||||
#ifndef RTGUI_USING_SMALL_SIZE
|
||||
struct rtgui_box;
|
||||
/* set layout box */
|
||||
void rtgui_container_set_box(struct rtgui_container* container, struct rtgui_box* box);
|
||||
#endif
|
||||
|
||||
void rtgui_container_hide(rtgui_container_t* container);
|
||||
void rtgui_container_layout(struct rtgui_container* container);
|
||||
|
||||
void rtgui_container_add_child(rtgui_container_t *container, rtgui_widget_t* child);
|
||||
void rtgui_container_remove_child(rtgui_container_t *container, rtgui_widget_t* child);
|
||||
|
||||
@@ -49,7 +49,7 @@ rtgui_filelist_view_t* rtgui_filelist_view_create(const char* directory,
|
||||
const rtgui_rect_t* rect);
|
||||
void rtgui_filelist_view_destroy(rtgui_filelist_view_t* view);
|
||||
|
||||
rt_bool_t rtgui_filelist_view_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
|
||||
rt_bool_t rtgui_filelist_view_event_handler(struct rtgui_object* object, struct rtgui_event* event);
|
||||
void rtgui_filelist_view_set_directory(rtgui_filelist_view_t* view, const char* directory);
|
||||
|
||||
void rtgui_filelist_view_get_fullpath(rtgui_filelist_view_t* view, char* path, rt_size_t len);
|
||||
|
||||
@@ -29,7 +29,7 @@ struct rtgui_menu_item
|
||||
rt_uint16_t submenu_count;
|
||||
|
||||
/* menu action */
|
||||
rt_bool_t (*on_menuaction)(rtgui_widget_t* widget, rtgui_event_t* event);
|
||||
rt_bool_t (*on_menuaction)(struct rtgui_object* object, struct rtgui_event* event);
|
||||
};
|
||||
typedef struct rtgui_menu_item rtgui_menu_item_t;
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* File : panel.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2009-10-16 Bernard first version
|
||||
*/
|
||||
#ifndef __RTGUI_PANEL_H__
|
||||
#define __RTGUI_PANEL_H__
|
||||
|
||||
#include <rtgui/rtgui.h>
|
||||
#include <rtgui/widgets/container.h>
|
||||
|
||||
DECLARE_CLASS_TYPE(panel);
|
||||
|
||||
/** Gets the type of a panel */
|
||||
#define RTGUI_PANEL_TYPE (RTGUI_TYPE(panel))
|
||||
/** Casts the object to an panel */
|
||||
#define RTGUI_PANEL(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_PANEL_TYPE, rtgui_panel_t))
|
||||
/** Checks if the object is an rtgui_button */
|
||||
#define RTGUI_IS_PANEL(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_PANEL_TYPE))
|
||||
|
||||
/*
|
||||
* the panel widget
|
||||
*/
|
||||
struct rtgui_panel
|
||||
{
|
||||
struct rtgui_container parent;
|
||||
|
||||
int border_style;
|
||||
};
|
||||
typedef struct rtgui_panel rtgui_panel_t;
|
||||
|
||||
rtgui_panel_t* rtgui_panel_create(int border_style);
|
||||
void rtgui_panel_destroy(rtgui_panel_t* panel);
|
||||
|
||||
rt_bool_t rtgui_panel_event_handler(struct rtgui_object* object, struct rtgui_event* event);
|
||||
|
||||
#endif
|
||||
@@ -14,32 +14,34 @@
|
||||
#ifndef __RTGUI_TEXTBOX_H__
|
||||
#define __RTGUI_TEXTBOX_H__
|
||||
|
||||
#include <rtgui/rtgui.h>
|
||||
#include <rtgui/rtgui_system.h>
|
||||
#include <rtgui/widgets/widget.h>
|
||||
#include <rtgui/widgets/container.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
DECLARE_CLASS_TYPE(textbox);
|
||||
|
||||
/** Gets the type of a textbox */
|
||||
#define RTGUI_TEXTBOX_TYPE (RTGUI_TYPE(textbox))
|
||||
/** Casts the object to a rtgui_textbox */
|
||||
/** Casts the object to a rtgui_textbox_t */
|
||||
#define RTGUI_TEXTBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_TEXTBOX_TYPE, rtgui_textbox_t))
|
||||
/** Checks if the object is a rtgui_textbox */
|
||||
/** Checks if the object is a rtgui_textbox_t */
|
||||
#define RTGUI_IS_TEXTBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_TEXTBOX_TYPE))
|
||||
|
||||
#define RTGUI_TEXTBOX_DEFAULT_WIDTH 80
|
||||
#define RTGUI_TEXTBOX_DEFAULT_HEIGHT 20
|
||||
#define RTGUI_TEXTBOX_DEFAULT_HEIGHT 20
|
||||
|
||||
#define RTGUI_TEXTBOX_SINGLE 0x00
|
||||
#define RTGUI_TEXTBOX_MULTI 0x01
|
||||
#define RTGUI_TEXTBOX_MASK 0x02
|
||||
#define RTGUI_TEXTBOX_CARET_SHOW 0x10
|
||||
#define RTGUI_TEXTBOX_CARET_HIDE 0x00
|
||||
#define RTGUI_TEXTBOX_SINGLE 0x00
|
||||
#define RTGUI_TEXTBOX_MULTI 0x01 /* multiline */
|
||||
#define RTGUI_TEXTBOX_MASK 0x02 /* ciphertext */
|
||||
#define RTGUI_TEXTBOX_DIGIT 0x04 /* digit */
|
||||
#define RTGUI_TEXTBOX_CARET_SHOW 0x10
|
||||
#define RTGUI_TEXTBOX_CARET_STAT 0x20 /* unused */
|
||||
|
||||
struct rtgui_textbox_line
|
||||
{
|
||||
char* line_text;
|
||||
|
||||
struct rtgui_textbox_line *prev, *next;
|
||||
};
|
||||
#define RTGUI_TEXTBOX_LINE_MAX 128 /* text line cache */
|
||||
|
||||
struct rtgui_textbox
|
||||
{
|
||||
@@ -47,22 +49,24 @@ struct rtgui_textbox
|
||||
struct rtgui_widget parent;
|
||||
|
||||
/* text box flag */
|
||||
rt_uint8_t flag;
|
||||
rt_uint32_t flag;
|
||||
|
||||
/* current line and position */
|
||||
rt_uint16_t line, line_begin, position, line_length;
|
||||
|
||||
rt_uint16_t dis_length; /*may be display length.*/
|
||||
char* text;
|
||||
rt_size_t font_width;
|
||||
|
||||
struct rtgui_timer* caret_timer;
|
||||
rtgui_timer_t *caret_timer;
|
||||
rtgui_color_t *caret;
|
||||
rtgui_rect_t caret_rect;
|
||||
|
||||
/* widget private data */
|
||||
rt_bool_t (*on_enter) (struct rtgui_widget* widget, struct rtgui_event* event);
|
||||
/* textbox private data */
|
||||
rt_bool_t (*on_enter) (struct rtgui_textbox *box, rtgui_event_t* event);
|
||||
};
|
||||
typedef struct rtgui_textbox rtgui_textbox_t;
|
||||
|
||||
struct rtgui_textbox* rtgui_textbox_create(const char* text, rt_uint8_t flag);
|
||||
struct rtgui_textbox* rtgui_textbox_create(const char* text, rt_uint32_t flag);
|
||||
void rtgui_textbox_destroy(struct rtgui_textbox* box);
|
||||
|
||||
rt_bool_t rtgui_textbox_event_handler(struct rtgui_object* object, struct rtgui_event* event);
|
||||
@@ -72,4 +76,11 @@ const char* rtgui_textbox_get_value(struct rtgui_textbox* box);
|
||||
|
||||
void rtgui_textbox_set_line_length(struct rtgui_textbox* box, rt_size_t length);
|
||||
|
||||
void rtgui_textbox_get_edit_rect(struct rtgui_textbox *box,rtgui_rect_t *rect);
|
||||
|
||||
void rtgui_textbox_ondraw(rtgui_textbox_t* box);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -26,16 +26,16 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#define RTGUI_WIDGET_FLAG_DEFAULT 0x0000
|
||||
#define RTGUI_WIDGET_FLAG_HIDE 0x0001
|
||||
#define RTGUI_WIDGET_FLAG_SHOWN 0x0001
|
||||
#define RTGUI_WIDGET_FLAG_DISABLE 0x0002
|
||||
#define RTGUI_WIDGET_FLAG_FOCUS 0x0004
|
||||
#define RTGUI_WIDGET_FLAG_TRANSPARENT 0x0008
|
||||
#define RTGUI_WIDGET_FLAG_FOCUSABLE 0x0010
|
||||
#define RTGUI_WIDGET_FLAG_DC_VISIBLE 0x0100
|
||||
|
||||
#define RTGUI_WIDGET_UNHIDE(w) (w)->flag &= ~RTGUI_WIDGET_FLAG_HIDE
|
||||
#define RTGUI_WIDGET_HIDE(w) (w)->flag |= RTGUI_WIDGET_FLAG_HIDE
|
||||
#define RTGUI_WIDGET_IS_HIDE(w) ((w)->flag & RTGUI_WIDGET_FLAG_HIDE)
|
||||
#define RTGUI_WIDGET_UNHIDE(w) (w)->flag |= RTGUI_WIDGET_FLAG_SHOWN
|
||||
#define RTGUI_WIDGET_HIDE(w) (w)->flag &= ~RTGUI_WIDGET_FLAG_SHOWN
|
||||
#define RTGUI_WIDGET_IS_HIDE(w) (!((w)->flag & RTGUI_WIDGET_FLAG_SHOWN))
|
||||
|
||||
#define RTGUI_WIDGET_ENABLE(w) (w)->flag &= ~RTGUI_WIDGET_FLAG_DISABLE
|
||||
#define RTGUI_WIDGET_DISABLE(w) (w)->flag |= RTGUI_WIDGET_FLAG_DISABLE
|
||||
@@ -52,12 +52,13 @@ extern "C" {
|
||||
#define RTGUI_WIDGET_DC_SET_UNVISIBLE(w) (w)->flag &= ~RTGUI_WIDGET_FLAG_DC_VISIBLE
|
||||
#define RTGUI_WIDGET_DC(w) ((struct rtgui_dc*)&((w)->dc_type))
|
||||
|
||||
/* get rtgui widget object */
|
||||
#define RTGUI_WIDGET_FOREGROUND(w) ((w)->gc.foreground)
|
||||
#define RTGUI_WIDGET_BACKGROUND(w) ((w)->gc.background)
|
||||
#define RTGUI_WIDGET_TEXTALIGN(w) ((w)->gc.textalign)
|
||||
#define RTGUI_WIDGET_FONT(w) ((w)->gc.font)
|
||||
#define RTGUI_WIDGET_FLAG(w) ((w)->flag)
|
||||
/* rtgui widget attribute */
|
||||
#define RTGUI_WIDGET_FOREGROUND(w) (RTGUI_WIDGET(w)->gc.foreground)
|
||||
#define RTGUI_WIDGET_BACKGROUND(w) (RTGUI_WIDGET(w)->gc.background)
|
||||
#define RTGUI_WIDGET_TEXTALIGN(w) (RTGUI_WIDGET(w)->gc.textalign)
|
||||
#define RTGUI_WIDGET_FONT(w) (RTGUI_WIDGET(w)->gc.font)
|
||||
#define RTGUI_WIDGET_FLAG(w) (RTGUI_WIDGET(w)->flag)
|
||||
#define RTGUI_WIDGET_ALIGN(w) (RTGUI_WIDGET(w)->align)
|
||||
|
||||
DECLARE_CLASS_TYPE(widget);
|
||||
|
||||
@@ -96,14 +97,10 @@ struct rtgui_widget
|
||||
/* the widget extent */
|
||||
rtgui_rect_t extent;
|
||||
|
||||
#ifndef RTGUI_USING_SMALL_SIZE
|
||||
/* minimal width and height of widget */
|
||||
rt_int16_t mini_width, mini_height;
|
||||
rt_int16_t margin, margin_style;
|
||||
|
||||
/* widget align */
|
||||
rt_int32_t align;
|
||||
#endif
|
||||
|
||||
/* the rect clip */
|
||||
rtgui_region_t clip;
|
||||
@@ -189,7 +186,9 @@ void rtgui_widget_update_clip(rtgui_widget_t* widget);
|
||||
struct rtgui_win* rtgui_widget_get_toplevel(rtgui_widget_t* widget);
|
||||
|
||||
void rtgui_widget_show(rtgui_widget_t* widget);
|
||||
rt_bool_t rtgui_widget_onshow(struct rtgui_object *object, struct rtgui_event *event);
|
||||
void rtgui_widget_hide(rtgui_widget_t* widget);
|
||||
rt_bool_t rtgui_widget_onhide(struct rtgui_object *object, struct rtgui_event *event);
|
||||
void rtgui_widget_update(rtgui_widget_t* widget);
|
||||
|
||||
/* get parent color */
|
||||
|
||||
@@ -37,16 +37,8 @@ DECLARE_CLASS_TYPE(win);
|
||||
#define RTGUI_WIN_STYLE_MINIBOX 0x010 /* window has the mini button */
|
||||
|
||||
#define RTGUI_WIN_STYLE_DESTROY_ON_CLOSE 0x020 /* window is destroyed when closed */
|
||||
#ifdef RTGUI_USING_DESKTOP_WINDOW
|
||||
/* A desktop window is a full screen window which will beneath all other windows.
|
||||
* There will be only one desktop window in a system. And this window should be
|
||||
* created _before_ any other windows.
|
||||
*/
|
||||
#define RTGUI_WIN_STYLE_DESKTOP 0x8000
|
||||
#define RTGUI_WIN_STYLE_DESKTOP_DEFAULT RTGUI_WIN_STYLE_DESKTOP |\
|
||||
RTGUI_WIN_STYLE_NO_BORDER |\
|
||||
RTGUI_WIN_STYLE_NO_TITLE
|
||||
#endif
|
||||
#define RTGUI_WIN_STYLE_ONTOP 0x040 /* window is in the top layer */
|
||||
#define RTGUI_WIN_STYLE_ONBTM 0x080 /* window is in the bottom layer */
|
||||
|
||||
#define RTGUI_WIN_STYLE_DEFAULT (RTGUI_WIN_STYLE_CLOSEBOX | RTGUI_WIN_STYLE_MINIBOX)
|
||||
|
||||
@@ -84,7 +76,7 @@ struct rtgui_win
|
||||
/* the widget that will grab the focus in current window */
|
||||
struct rtgui_widget *focused_widget;
|
||||
|
||||
/* top window style */
|
||||
/* window style */
|
||||
rt_uint16_t style;
|
||||
|
||||
/* window state flag */
|
||||
@@ -133,7 +125,7 @@ rt_bool_t rtgui_win_close(struct rtgui_win* win);
|
||||
rt_base_t rtgui_win_show(struct rtgui_win *win, rt_bool_t is_modal);
|
||||
void rtgui_win_hiden(rtgui_win_t* win);
|
||||
void rtgui_win_end_modal(rtgui_win_t* win, rtgui_modal_code_t modal_code);
|
||||
|
||||
rt_err_t rtgui_win_activate(struct rtgui_win *win);
|
||||
rt_bool_t rtgui_win_is_activated(struct rtgui_win* win);
|
||||
|
||||
void rtgui_win_move(struct rtgui_win* win, int x, int y);
|
||||
|
||||
@@ -88,3 +88,7 @@ rt_uint8_t* rtgui_graphic_driver_get_framebuffer(const struct rtgui_graphic_driv
|
||||
return (rt_uint8_t*)driver->framebuffer;
|
||||
}
|
||||
|
||||
rt_uint8_t* rtgui_graphic_driver_get_default_framebuffer(void)
|
||||
{
|
||||
return rtgui_graphic_driver_get_framebuffer(&_driver);
|
||||
}
|
||||
|
||||
@@ -52,9 +52,6 @@ struct rtgui_cursor
|
||||
rt_uint8_t *win_top, *win_bottom;
|
||||
rt_bool_t win_rect_show, win_rect_has_saved;
|
||||
#endif
|
||||
|
||||
/* screen framebuffer */
|
||||
rt_uint8_t* framebuffer;
|
||||
};
|
||||
|
||||
struct rtgui_cursor* _rtgui_cursor;
|
||||
@@ -140,7 +137,6 @@ void rtgui_mouse_init()
|
||||
|
||||
/* init cursor */
|
||||
_rtgui_cursor->bpp = gd->bits_per_pixel/8;
|
||||
_rtgui_cursor->framebuffer = rtgui_graphic_driver_get_framebuffer(gd);
|
||||
_rtgui_cursor->screen_pitch = _rtgui_cursor->bpp * gd->width;
|
||||
|
||||
#ifdef RTGUI_USING_MOUSE_CURSOR
|
||||
@@ -300,7 +296,7 @@ static void rtgui_cursor_restore()
|
||||
rt_base_t idx, height, cursor_pitch;
|
||||
rt_uint8_t *cursor_ptr, *fb_ptr;
|
||||
|
||||
fb_ptr = _rtgui_cursor->framebuffer + _rtgui_cursor->cy * _rtgui_cursor->screen_pitch
|
||||
fb_ptr = rtgui_graphic_driver_get_default_framebuffer() + _rtgui_cursor->cy * _rtgui_cursor->screen_pitch
|
||||
+ _rtgui_cursor->cx * _rtgui_cursor->bpp;
|
||||
cursor_ptr = _rtgui_cursor->cursor_saved;
|
||||
|
||||
@@ -327,7 +323,7 @@ static void rtgui_cursor_save()
|
||||
rt_base_t idx, height, cursor_pitch;
|
||||
rt_uint8_t *cursor_ptr, *fb_ptr;
|
||||
|
||||
fb_ptr = _rtgui_cursor->framebuffer + _rtgui_cursor->cy * _rtgui_cursor->screen_pitch +
|
||||
fb_ptr = _driver_get_default_framebuffer() + _rtgui_cursor->cy * _rtgui_cursor->screen_pitch +
|
||||
_rtgui_cursor->cx * _rtgui_cursor->bpp;
|
||||
cursor_ptr = _rtgui_cursor->cursor_saved;
|
||||
|
||||
@@ -488,10 +484,11 @@ static void rtgui_winrect_show()
|
||||
|
||||
static void rtgui_winrect_restore()
|
||||
{
|
||||
rt_uint8_t *winrect_ptr, *fb_ptr;
|
||||
rt_uint8_t *winrect_ptr, *fb_ptr, *driver_fb;
|
||||
int winrect_pitch, idx;
|
||||
rtgui_rect_t screen_rect, win_rect;
|
||||
|
||||
driver_fb = rtgui_graphic_driver_get_default_framebuffer();
|
||||
win_rect = _rtgui_cursor->win_rect;
|
||||
|
||||
rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(),
|
||||
@@ -499,7 +496,7 @@ static void rtgui_winrect_restore()
|
||||
rtgui_rect_intersect(&screen_rect, &win_rect);
|
||||
|
||||
/* restore winrect left */
|
||||
fb_ptr = _rtgui_cursor->framebuffer + win_rect.y1 * _rtgui_cursor->screen_pitch +
|
||||
fb_ptr = driver_fb + win_rect.y1 * _rtgui_cursor->screen_pitch +
|
||||
win_rect.x1 * _rtgui_cursor->bpp;
|
||||
winrect_ptr = _rtgui_cursor->win_left;
|
||||
winrect_pitch = WIN_MOVE_BORDER * _rtgui_cursor->bpp;
|
||||
@@ -507,7 +504,7 @@ static void rtgui_winrect_restore()
|
||||
(win_rect.y2 - win_rect.y1), winrect_pitch);
|
||||
|
||||
/* restore winrect right */
|
||||
fb_ptr = _rtgui_cursor->framebuffer + win_rect.y1 * _rtgui_cursor->screen_pitch +
|
||||
fb_ptr = driver_fb + win_rect.y1 * _rtgui_cursor->screen_pitch +
|
||||
(win_rect.x2 - WIN_MOVE_BORDER) * _rtgui_cursor->bpp;
|
||||
winrect_ptr = _rtgui_cursor->win_right;
|
||||
winrect_pitch = WIN_MOVE_BORDER * _rtgui_cursor->bpp;
|
||||
@@ -515,7 +512,7 @@ static void rtgui_winrect_restore()
|
||||
(win_rect.y2 - win_rect.y1), winrect_pitch);
|
||||
|
||||
/* restore winrect top */
|
||||
fb_ptr = _rtgui_cursor->framebuffer + win_rect.y1 * _rtgui_cursor->screen_pitch +
|
||||
fb_ptr = driver_fb + win_rect.y1 * _rtgui_cursor->screen_pitch +
|
||||
(win_rect.x1 + WIN_MOVE_BORDER)* _rtgui_cursor->bpp;
|
||||
winrect_ptr = _rtgui_cursor->win_top;
|
||||
winrect_pitch = (win_rect.x2 - win_rect.x1 - 2 * WIN_MOVE_BORDER) * _rtgui_cursor->bpp;
|
||||
@@ -523,7 +520,7 @@ static void rtgui_winrect_restore()
|
||||
WIN_MOVE_BORDER, winrect_pitch);
|
||||
|
||||
/* restore winrect bottom */
|
||||
fb_ptr = _rtgui_cursor->framebuffer + (win_rect.y2 - WIN_MOVE_BORDER) * _rtgui_cursor->screen_pitch +
|
||||
fb_ptr = driver_fb + (win_rect.y2 - WIN_MOVE_BORDER) * _rtgui_cursor->screen_pitch +
|
||||
(win_rect.x1 + WIN_MOVE_BORDER) * _rtgui_cursor->bpp;
|
||||
winrect_ptr = _rtgui_cursor->win_bottom;
|
||||
display_direct_memcpy(winrect_ptr, fb_ptr, winrect_pitch, _rtgui_cursor->screen_pitch,
|
||||
@@ -532,10 +529,11 @@ static void rtgui_winrect_restore()
|
||||
|
||||
static void rtgui_winrect_save()
|
||||
{
|
||||
rt_uint8_t *winrect_ptr, *fb_ptr;
|
||||
rt_uint8_t *winrect_ptr, *fb_ptr, *driver_fb;
|
||||
int winrect_pitch, idx;
|
||||
rtgui_rect_t screen_rect, win_rect;
|
||||
|
||||
driver_fb = rtgui_graphic_driver_get_default_framebuffer();
|
||||
win_rect = _rtgui_cursor->win_rect;
|
||||
|
||||
rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(),
|
||||
@@ -546,7 +544,7 @@ static void rtgui_winrect_save()
|
||||
_rtgui_cursor->win_rect_has_saved = RT_TRUE;
|
||||
|
||||
/* save winrect left */
|
||||
fb_ptr = _rtgui_cursor->framebuffer + win_rect.y1 * _rtgui_cursor->screen_pitch +
|
||||
fb_ptr = driver_fb + win_rect.y1 * _rtgui_cursor->screen_pitch +
|
||||
win_rect.x1 * _rtgui_cursor->bpp;
|
||||
winrect_ptr = _rtgui_cursor->win_left;
|
||||
winrect_pitch = WIN_MOVE_BORDER * _rtgui_cursor->bpp;
|
||||
@@ -554,7 +552,7 @@ static void rtgui_winrect_save()
|
||||
(win_rect.y2 - win_rect.y1), winrect_pitch);
|
||||
|
||||
/* save winrect right */
|
||||
fb_ptr = _rtgui_cursor->framebuffer + win_rect.y1 * _rtgui_cursor->screen_pitch +
|
||||
fb_ptr = driver_fb + win_rect.y1 * _rtgui_cursor->screen_pitch +
|
||||
(win_rect.x2 - WIN_MOVE_BORDER) * _rtgui_cursor->bpp;
|
||||
winrect_ptr = _rtgui_cursor->win_right;
|
||||
winrect_pitch = WIN_MOVE_BORDER * _rtgui_cursor->bpp;
|
||||
@@ -562,7 +560,7 @@ static void rtgui_winrect_save()
|
||||
(win_rect.y2 - win_rect.y1), winrect_pitch);
|
||||
|
||||
/* save winrect top */
|
||||
fb_ptr = _rtgui_cursor->framebuffer + win_rect.y1 * _rtgui_cursor->screen_pitch +
|
||||
fb_ptr = driver_fb + win_rect.y1 * _rtgui_cursor->screen_pitch +
|
||||
(win_rect.x1 + WIN_MOVE_BORDER)* _rtgui_cursor->bpp;
|
||||
winrect_ptr = _rtgui_cursor->win_top;
|
||||
winrect_pitch = (win_rect.x2 - win_rect.x1 - 2 * WIN_MOVE_BORDER) * _rtgui_cursor->bpp;
|
||||
@@ -570,7 +568,7 @@ static void rtgui_winrect_save()
|
||||
WIN_MOVE_BORDER, winrect_pitch);
|
||||
|
||||
/* save winrect bottom */
|
||||
fb_ptr = _rtgui_cursor->framebuffer + (win_rect.y2 - WIN_MOVE_BORDER) * _rtgui_cursor->screen_pitch +
|
||||
fb_ptr = driver_fb + (win_rect.y2 - WIN_MOVE_BORDER) * _rtgui_cursor->screen_pitch +
|
||||
(win_rect.x1 + WIN_MOVE_BORDER) * _rtgui_cursor->bpp;
|
||||
winrect_ptr = _rtgui_cursor->win_bottom;
|
||||
display_direct_memcpy(fb_ptr, winrect_ptr, _rtgui_cursor->screen_pitch, winrect_pitch,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+185
-122
File diff suppressed because it is too large
Load Diff
@@ -23,8 +23,8 @@
|
||||
/* add or remove a top win */
|
||||
rt_err_t rtgui_topwin_add(struct rtgui_event_win_create* event);
|
||||
rt_err_t rtgui_topwin_remove(struct rtgui_win* wid);
|
||||
|
||||
void rtgui_topwin_activate_win(struct rtgui_topwin* win);
|
||||
rt_err_t rtgui_topwin_activate(struct rtgui_event_win_activate* event);
|
||||
rt_err_t rtgui_topwin_activate_topwin(struct rtgui_topwin* win);
|
||||
|
||||
/* show a window */
|
||||
rt_err_t rtgui_topwin_show(struct rtgui_event_win* event);
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
* File : about_view.c
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <rtgui/rtgui_theme.h>
|
||||
#include <rtgui/widgets/about_view.h>
|
||||
|
||||
static void _rtgui_about_view_constructor(struct rtgui_about_view *view)
|
||||
{
|
||||
/* default rect */
|
||||
struct rtgui_rect rect = {0, 0, 200, 200};
|
||||
|
||||
/* set default widget rect and set event handler */
|
||||
rtgui_object_set_event_handler(RTGUI_OBJECT(view),rtgui_about_view_event_handler);
|
||||
rtgui_widget_set_rect(RTGUI_WIDGET(view), &rect);
|
||||
|
||||
RTGUI_WIDGET(view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
|
||||
|
||||
view->logo = RT_NULL;
|
||||
view->description = RT_NULL;
|
||||
|
||||
RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(view)) = RTGUI_ALIGN_CENTER_VERTICAL;
|
||||
}
|
||||
|
||||
DEFINE_CLASS_TYPE(aboutview, "aboutview",
|
||||
RTGUI_CONTAINER_TYPE,
|
||||
_rtgui_about_view_constructor,
|
||||
RT_NULL,
|
||||
sizeof(struct rtgui_about_view));
|
||||
|
||||
void rtgui_about_view_ondraw(struct rtgui_about_view* view)
|
||||
{
|
||||
struct rtgui_rect rect;
|
||||
struct rtgui_dc* dc;
|
||||
|
||||
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(view));
|
||||
if (dc == RT_NULL) return;
|
||||
|
||||
rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
|
||||
rtgui_dc_fill_rect(dc, &rect);
|
||||
|
||||
if (view->logo != RT_NULL)
|
||||
rtgui_image_blit(view->logo, dc, &rect);
|
||||
|
||||
rect.y1 += view->logo->h + 5;
|
||||
if (view->description != RT_NULL)
|
||||
rtgui_dc_draw_text(dc, view->description, &rect);
|
||||
|
||||
rect.y1 += rtgui_dc_get_gc(dc)->font->height;
|
||||
rtgui_dc_draw_hline(dc, rect.x1 + 3, rect.x2 - 3, rect.y1);
|
||||
RTGUI_DC_FC(dc) = white;
|
||||
rtgui_dc_draw_hline(dc, rect.x1 + 4, rect.x2 - 2, rect.y1 + 1);
|
||||
|
||||
rtgui_dc_end_drawing(dc);
|
||||
}
|
||||
|
||||
rt_bool_t rtgui_about_view_event_handler(struct rtgui_object* widget, struct rtgui_event* event)
|
||||
{
|
||||
struct rtgui_about_view* view = RT_NULL;
|
||||
|
||||
view = RTGUI_ABOUT_VIEW(widget);
|
||||
switch (event->type)
|
||||
{
|
||||
case RTGUI_EVENT_PAINT:
|
||||
rtgui_about_view_ondraw(view);
|
||||
return RT_FALSE;
|
||||
}
|
||||
|
||||
/* use view event handler */
|
||||
return rtgui_container_event_handler(widget, event);
|
||||
}
|
||||
|
||||
rtgui_about_view_t* rtgui_about_view_create(rtgui_image_t *logo, const char* description)
|
||||
{
|
||||
struct rtgui_about_view* view = RT_NULL;
|
||||
|
||||
view = (struct rtgui_about_view*) rtgui_widget_create(RTGUI_ABOUT_VIEW_TYPE);
|
||||
if (view != RT_NULL)
|
||||
{
|
||||
view->logo = logo;
|
||||
view->description = description;
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
void rtgui_about_view_destroy(rtgui_about_view_t* view)
|
||||
{
|
||||
/* destroy view */
|
||||
rtgui_widget_destroy(RTGUI_WIDGET(view));
|
||||
}
|
||||
+29
-114
File diff suppressed because it is too large
Load Diff
@@ -62,7 +62,7 @@ rt_bool_t rtgui_button_event_handler(struct rtgui_object* object, struct rtgui_e
|
||||
struct rtgui_widget *widget;
|
||||
struct rtgui_button *btn;
|
||||
|
||||
RT_ASSERT(widget != RT_NULL);
|
||||
RT_ASSERT(object != RT_NULL);
|
||||
RT_ASSERT(event != RT_NULL);
|
||||
|
||||
widget = RTGUI_WIDGET(object);
|
||||
@@ -189,6 +189,8 @@ rt_bool_t rtgui_button_event_handler(struct rtgui_object* object, struct rtgui_e
|
||||
|
||||
return RT_TRUE;
|
||||
}
|
||||
default:
|
||||
return rtgui_widget_event_handler(object, event);
|
||||
}
|
||||
|
||||
return RT_FALSE;
|
||||
|
||||
@@ -92,6 +92,8 @@ rt_bool_t rtgui_checkbox_event_handler(struct rtgui_object* object, struct rtgui
|
||||
|
||||
return RT_TRUE;
|
||||
}
|
||||
default:
|
||||
return rtgui_widget_event_handler(object, event);
|
||||
}
|
||||
|
||||
return RT_FALSE;
|
||||
|
||||
@@ -38,7 +38,6 @@ rt_bool_t rtgui_combobox_pdwin_onitem(struct rtgui_object* object, struct rtgui_
|
||||
rtgui_listbox_t* list;
|
||||
|
||||
RT_ASSERT(object != RT_NULL);
|
||||
RT_ASSERT(event != RT_NULL);
|
||||
|
||||
widget = RTGUI_WIDGET(object);
|
||||
list = RTGUI_LISTBOX(widget);
|
||||
@@ -228,6 +227,8 @@ rt_bool_t rtgui_combobox_event_handler(struct rtgui_object* object, struct rtgui
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return rtgui_widget_event_handler(object, event);
|
||||
}
|
||||
|
||||
return RT_FALSE;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
#include <rtgui/dc.h>
|
||||
#include <rtgui/rtgui_system.h>
|
||||
#include <rtgui/rtgui_application.h>
|
||||
#include <rtgui/rtgui_app.h>
|
||||
#include <rtgui/widgets/container.h>
|
||||
#include <rtgui/widgets/window.h>
|
||||
|
||||
@@ -25,26 +25,17 @@ static void _rtgui_container_constructor(rtgui_container_t *container)
|
||||
rtgui_container_event_handler);
|
||||
|
||||
rtgui_list_init(&(container->children));
|
||||
container->layout_box = RT_NULL;
|
||||
|
||||
/* container is used to 'contain'(show) widgets and dispatch events to
|
||||
* them, not interact with user. So no need to grab focus. If we did it,
|
||||
* some widget inherited from container(e.g. notebook) will grab the focus
|
||||
* annoyingly.
|
||||
*
|
||||
* For example, a focusable notebook N has a widget W. When the user press
|
||||
* W, N will gain the focus and W will lose it at first. Then N will set
|
||||
* focus to W because it is W that eventually interact with people. N will
|
||||
* yield focus and W will gain the focus again. This loop will make W
|
||||
* repaint twice every time user press it.
|
||||
*
|
||||
* Just eliminate it.
|
||||
*/
|
||||
RTGUI_WIDGET(container)->flag &= ~RTGUI_WIDGET_FLAG_FOCUSABLE;
|
||||
RTGUI_WIDGET(container)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
|
||||
}
|
||||
|
||||
static void _rtgui_container_destructor(rtgui_container_t *container)
|
||||
{
|
||||
rtgui_container_destroy_children(container);
|
||||
|
||||
if (container->layout_box != RT_NULL)
|
||||
rtgui_object_destroy(RTGUI_OBJECT(container->layout_box));
|
||||
}
|
||||
|
||||
static void _rtgui_container_update_toplevel(rtgui_container_t* container)
|
||||
@@ -152,15 +143,6 @@ rt_bool_t rtgui_container_event_handler(struct rtgui_object* object, struct rtgu
|
||||
break;
|
||||
|
||||
case RTGUI_EVENT_KBD:
|
||||
/* let parent to handle keyboard event */
|
||||
if (widget->parent != RT_NULL &&
|
||||
widget->parent != RTGUI_WIDGET(widget->toplevel) &&
|
||||
RTGUI_OBJECT(widget->parent)->event_handler)
|
||||
{
|
||||
return RTGUI_OBJECT(widget->parent)->event_handler(
|
||||
RTGUI_OBJECT(widget->parent),
|
||||
event);
|
||||
}
|
||||
break;
|
||||
|
||||
case RTGUI_EVENT_MOUSE_BUTTON:
|
||||
@@ -169,6 +151,14 @@ rt_bool_t rtgui_container_event_handler(struct rtgui_object* object, struct rtgu
|
||||
return rtgui_container_dispatch_mouse_event(container,
|
||||
(struct rtgui_event_mouse*)event);
|
||||
|
||||
case RTGUI_EVENT_SHOW:
|
||||
rtgui_widget_onshow(RTGUI_OBJECT(container), event);
|
||||
rtgui_container_dispatch_event(container, event);
|
||||
break;
|
||||
case RTGUI_EVENT_HIDE:
|
||||
rtgui_widget_onhide(RTGUI_OBJECT(container), event);
|
||||
rtgui_container_dispatch_event(container, event);
|
||||
break;
|
||||
case RTGUI_EVENT_COMMAND:
|
||||
case RTGUI_EVENT_RESIZE:
|
||||
rtgui_container_dispatch_event(container, event);
|
||||
@@ -193,7 +183,6 @@ rtgui_container_t* rtgui_container_create(void)
|
||||
|
||||
void rtgui_container_destroy(rtgui_container_t* container)
|
||||
{
|
||||
rtgui_container_hide(container);
|
||||
rtgui_widget_destroy(RTGUI_WIDGET(container));
|
||||
}
|
||||
|
||||
@@ -296,26 +285,20 @@ rtgui_widget_t* rtgui_container_get_first_child(rtgui_container_t* container)
|
||||
return child;
|
||||
}
|
||||
|
||||
#ifndef RTGUI_USING_SMALL_SIZE
|
||||
void rtgui_container_set_box(rtgui_container_t* container, struct rtgui_box* box)
|
||||
{
|
||||
if (container == RT_NULL || box == RT_NULL)
|
||||
return;
|
||||
|
||||
rtgui_container_add_child(RTGUI_CONTAINER(container), RTGUI_WIDGET(box));
|
||||
rtgui_widget_set_rect(RTGUI_WIDGET(box), &(RTGUI_WIDGET(container)->extent));
|
||||
container->layout_box = box;
|
||||
box->container = container;
|
||||
}
|
||||
#endif
|
||||
|
||||
void rtgui_container_hide(rtgui_container_t* container)
|
||||
void rtgui_container_layout(struct rtgui_container* container)
|
||||
{
|
||||
if (container == RT_NULL)
|
||||
if (container == RT_NULL || container->layout_box == RT_NULL)
|
||||
return;
|
||||
|
||||
if (RTGUI_WIDGET(container)->parent == RT_NULL)
|
||||
{
|
||||
RTGUI_WIDGET_HIDE(RTGUI_WIDGET(container));
|
||||
return;
|
||||
}
|
||||
rtgui_box_layout(container->layout_box);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <rtgui/rtgui_object.h>
|
||||
#include <rtgui/rtgui_system.h>
|
||||
#include <rtgui/rtgui_theme.h>
|
||||
#include <rtgui/rtgui_application.h>
|
||||
#include <rtgui/rtgui_app.h>
|
||||
|
||||
#include <rtgui/list.h>
|
||||
#include <rtgui/image.h>
|
||||
@@ -235,14 +235,14 @@ static struct rtgui_listbox_item items[] =
|
||||
};
|
||||
static void rtgui_filelist_view_clear(rtgui_filelist_view_t* view);
|
||||
|
||||
static void rtgui_filelist_view_on_folder_item(rtgui_widget_t* widget, struct rtgui_event* event)
|
||||
static rt_bool_t rtgui_filelist_view_on_folder_item(rtgui_object_t* object, struct rtgui_event* event)
|
||||
{
|
||||
rtgui_win_t *menu;
|
||||
rtgui_listbox_t *listbox;
|
||||
rtgui_filelist_view_t *view;
|
||||
|
||||
listbox = RTGUI_LISTBOX(widget);
|
||||
menu = RTGUI_WIN(rtgui_widget_get_toplevel(widget));
|
||||
listbox = RTGUI_LISTBOX(object);
|
||||
menu = RTGUI_WIN(rtgui_widget_get_toplevel(RTGUI_WIDGET(object)));
|
||||
view = RTGUI_FILELIST_VIEW(menu->user_data);
|
||||
|
||||
/* hide window */
|
||||
@@ -273,12 +273,14 @@ static void rtgui_filelist_view_on_folder_item(rtgui_widget_t* widget, struct rt
|
||||
rtgui_win_destroy(menu);
|
||||
break;
|
||||
}
|
||||
|
||||
return RT_TRUE;
|
||||
}
|
||||
|
||||
static rt_bool_t rtgui_filelist_view_on_menu_deactivate(rtgui_widget_t* widget, struct rtgui_event* event)
|
||||
static rt_bool_t rtgui_filelist_view_on_menu_deactivate(rtgui_object_t* object, struct rtgui_event* event)
|
||||
{
|
||||
rtgui_win_t *menu;
|
||||
menu = RTGUI_WIN(rtgui_widget_get_toplevel(widget));
|
||||
menu = RTGUI_WIN(rtgui_widget_get_toplevel(RTGUI_WIDGET(object)));
|
||||
|
||||
/* destroy menu window */
|
||||
rtgui_win_destroy(menu);
|
||||
@@ -295,7 +297,7 @@ static void rtgui_filelist_view_menu_pop(rtgui_widget_t *parent)
|
||||
rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &screen);
|
||||
rtgui_rect_moveto_align(&screen, &rect, RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL);
|
||||
|
||||
menu = rtgui_win_create(rtgui_widget_get_toplevel(parent),
|
||||
menu = rtgui_win_create(RTGUI_WIN(rtgui_widget_get_toplevel(parent)),
|
||||
"Folder Menu", &rect, RTGUI_WIN_STYLE_DEFAULT);
|
||||
if (menu != RT_NULL)
|
||||
{
|
||||
@@ -533,10 +535,12 @@ static void rtgui_filelist_view_onenturn(struct rtgui_filelist_view* view)
|
||||
}
|
||||
}
|
||||
|
||||
rt_bool_t rtgui_filelist_view_event_handler(struct rtgui_widget* widget, struct rtgui_event* event)
|
||||
rt_bool_t rtgui_filelist_view_event_handler(struct rtgui_object* object, struct rtgui_event* event)
|
||||
{
|
||||
struct rtgui_widget *widget;
|
||||
struct rtgui_filelist_view* view = RT_NULL;
|
||||
|
||||
widget = RTGUI_WIDGET(object);
|
||||
view = RTGUI_FILELIST_VIEW(widget);
|
||||
switch (event->type)
|
||||
{
|
||||
@@ -650,7 +654,7 @@ rt_bool_t rtgui_filelist_view_event_handler(struct rtgui_widget* widget, struct
|
||||
}
|
||||
|
||||
/* use view event handler */
|
||||
return rtgui_container_event_handler(RTGUI_OBJECT(widget), event);
|
||||
return rtgui_container_event_handler(object, event);
|
||||
}
|
||||
|
||||
rtgui_filelist_view_t* rtgui_filelist_view_create(const char* directory,
|
||||
|
||||
@@ -66,6 +66,8 @@ rt_bool_t rtgui_iconbox_event_handler(struct rtgui_object* object, struct rtgui_
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
return rtgui_widget_event_handler(object, event);
|
||||
}
|
||||
|
||||
return RT_FALSE;
|
||||
|
||||
@@ -49,6 +49,8 @@ rt_bool_t rtgui_label_event_handler(struct rtgui_object *object, struct rtgui_ev
|
||||
case RTGUI_EVENT_PAINT:
|
||||
rtgui_theme_draw_label(label);
|
||||
break;
|
||||
default:
|
||||
return rtgui_widget_event_handler(object, event);
|
||||
}
|
||||
|
||||
return RT_FALSE;
|
||||
|
||||
@@ -267,17 +267,18 @@ rt_bool_t rtgui_listbox_event_handler(struct rtgui_object* object, struct rtgui_
|
||||
{
|
||||
rt_int16_t old_item;
|
||||
|
||||
if (box->current_item == -1)
|
||||
if (box->current_item == -1)
|
||||
{
|
||||
/* set a initial item */
|
||||
if ((box->items_count > 0) &&
|
||||
if ((box->items_count > 0) &&
|
||||
(ekbd->key == RTGUIK_UP || ekbd->key == RTGUIK_DOWN))
|
||||
{
|
||||
box->current_item = 0;
|
||||
rtgui_listbox_update_current(box, -1);
|
||||
break;
|
||||
return RT_TRUE;
|
||||
}
|
||||
else return RT_FALSE;
|
||||
else
|
||||
return RT_FALSE;
|
||||
}
|
||||
old_item = box->current_item;
|
||||
|
||||
@@ -287,32 +288,30 @@ rt_bool_t rtgui_listbox_event_handler(struct rtgui_object* object, struct rtgui_
|
||||
if (box->current_item - box->page_items >= 0)
|
||||
box->current_item -= box->page_items;
|
||||
rtgui_listbox_update_current(box, old_item);
|
||||
return RT_FALSE;
|
||||
return RT_TRUE;
|
||||
|
||||
case RTGUIK_UP:
|
||||
if (box->current_item > 0)
|
||||
box->current_item --;
|
||||
rtgui_listbox_update_current(box, old_item);
|
||||
return RT_FALSE;
|
||||
return RT_TRUE;
|
||||
|
||||
case RTGUIK_RIGHT:
|
||||
if (box->current_item + box->page_items < box->items_count - 1)
|
||||
box->current_item += box->page_items;
|
||||
rtgui_listbox_update_current(box, old_item);
|
||||
return RT_FALSE;
|
||||
return RT_TRUE;
|
||||
|
||||
case RTGUIK_DOWN:
|
||||
if (box->current_item < box->items_count - 1)
|
||||
box->current_item ++;
|
||||
rtgui_listbox_update_current(box, old_item);
|
||||
return RT_FALSE;
|
||||
return RT_TRUE;
|
||||
|
||||
case RTGUIK_RETURN:
|
||||
if (box->on_item != RT_NULL)
|
||||
{
|
||||
box->on_item(RTGUI_OBJECT(box), RT_NULL);
|
||||
}
|
||||
return RT_FALSE;
|
||||
return RT_TRUE;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -316,13 +316,13 @@ rt_bool_t rtgui_listctrl_event_handler(struct rtgui_object* object, struct rtgui
|
||||
if (ctrl->current_item - ctrl->page_items >= 0)
|
||||
ctrl->current_item -= ctrl->page_items;
|
||||
rtgui_listctrl_update_current(ctrl, old_item);
|
||||
return RT_FALSE;
|
||||
return RT_TRUE;
|
||||
|
||||
case RTGUIK_UP:
|
||||
if (ctrl->current_item > 0)
|
||||
ctrl->current_item --;
|
||||
rtgui_listctrl_update_current(ctrl, old_item);
|
||||
return RT_FALSE;
|
||||
return RT_TRUE;
|
||||
|
||||
case RTGUIK_RIGHT:
|
||||
if (ctrl->current_item + ctrl->page_items < ctrl->items_count - 1)
|
||||
@@ -333,18 +333,18 @@ rt_bool_t rtgui_listctrl_event_handler(struct rtgui_object* object, struct rtgui
|
||||
ctrl->current_item = ((ctrl->current_item / ctrl->page_items) + 1) * ctrl->page_items;
|
||||
}
|
||||
rtgui_listctrl_update_current(ctrl, old_item);
|
||||
return RT_FALSE;
|
||||
return RT_TRUE;
|
||||
|
||||
case RTGUIK_DOWN:
|
||||
if (ctrl->current_item < ctrl->items_count - 1)
|
||||
ctrl->current_item ++;
|
||||
rtgui_listctrl_update_current(ctrl, old_item);
|
||||
return RT_FALSE;
|
||||
return RT_TRUE;
|
||||
|
||||
case RTGUIK_RETURN:
|
||||
if (ctrl->on_item != RT_NULL)
|
||||
{
|
||||
ctrl->on_item(RTGUI_OBJECT(ctrl), RT_NULL);
|
||||
return ctrl->on_item(RTGUI_OBJECT(ctrl), RT_NULL);
|
||||
}
|
||||
return RT_FALSE;
|
||||
|
||||
|
||||
@@ -40,10 +40,12 @@ static void _rtgui_menu_destructor(rtgui_menu_t* menu)
|
||||
static rt_bool_t _rtgui_menu_onitem(struct rtgui_object* object, struct rtgui_event* event)
|
||||
{
|
||||
struct rtgui_menu* menu;
|
||||
RTGUI_WIDGET_EVENT_HANDLER_PREPARE
|
||||
|
||||
/* event will be NULL, don't check it. */
|
||||
RT_ASSERT(object);
|
||||
|
||||
/* get menu */
|
||||
menu = RTGUI_MENU(rtgui_widget_get_toplevel(widget));
|
||||
menu = RTGUI_MENU(rtgui_widget_get_toplevel(RTGUI_WIDGET(object)));
|
||||
if (menu->items[menu->items_list->current_item].type == RTGUI_ITEM_SUBMENU)
|
||||
{
|
||||
const rtgui_menu_item_t* items;
|
||||
@@ -84,7 +86,7 @@ static rt_bool_t _rtgui_menu_onitem(struct rtgui_object* object, struct rtgui_ev
|
||||
{
|
||||
/* invoke action */
|
||||
if (menu->items[menu->items_list->current_item].on_menuaction != RT_NULL)
|
||||
menu->items[menu->items_list->current_item].on_menuaction(RTGUI_WIDGET(menu), RT_NULL);
|
||||
menu->items[menu->items_list->current_item].on_menuaction(RTGUI_OBJECT(menu), RT_NULL);
|
||||
|
||||
/* hide sub-menu */
|
||||
if (menu->sub_menu != RT_NULL)
|
||||
|
||||
@@ -301,12 +301,16 @@ void rtgui_notebook_set_current_by_index(struct rtgui_notebook* notebook, rt_uin
|
||||
|
||||
if ((index < notebook->count) && (notebook->current != index))
|
||||
{
|
||||
struct rtgui_widget *widget;
|
||||
|
||||
if (notebook->current != RTGUI_NOT_FOUND)
|
||||
rtgui_widget_hide(notebook->childs[notebook->current].widget);
|
||||
|
||||
notebook->current = index;
|
||||
rtgui_widget_show(notebook->childs[notebook->current].widget);
|
||||
rtgui_widget_update(notebook->childs[notebook->current].widget);
|
||||
widget = notebook->childs[notebook->current].widget;
|
||||
rtgui_widget_show(widget);
|
||||
rtgui_widget_update(widget);
|
||||
rtgui_widget_focus(widget);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,6 +323,16 @@ struct rtgui_widget* rtgui_notebook_get_widget_at(struct rtgui_notebook* noteboo
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
static rt_bool_t _rtgui_notebook_current_widget_handle(struct rtgui_notebook *notebook,
|
||||
struct rtgui_event *event)
|
||||
{
|
||||
struct rtgui_widget *widget = rtgui_notebook_get_current(notebook);
|
||||
if (widget && widget != RTGUI_WIDGET(notebook))
|
||||
return RTGUI_OBJECT(widget)->event_handler(RTGUI_OBJECT(widget), event);
|
||||
else
|
||||
return RT_FALSE;
|
||||
}
|
||||
|
||||
rt_bool_t rtgui_notebook_event_handler(struct rtgui_object* object, struct rtgui_event* event)
|
||||
{
|
||||
struct rtgui_notebook* notebook;
|
||||
@@ -336,17 +350,18 @@ rt_bool_t rtgui_notebook_event_handler(struct rtgui_object* object, struct rtgui
|
||||
case RTGUI_EVENT_MOUSE_BUTTON:
|
||||
_rtgui_notebook_onmouse(notebook, (struct rtgui_event_mouse*)event);
|
||||
break;
|
||||
case RTGUI_EVENT_SHOW:
|
||||
/* show myself */
|
||||
rtgui_widget_onshow(object, event);
|
||||
/* show the tab widget */
|
||||
return _rtgui_notebook_current_widget_handle(notebook, event);
|
||||
case RTGUI_EVENT_HIDE:
|
||||
/* hide myself */
|
||||
rtgui_widget_onhide(object, event);
|
||||
/* hide the tab widget */
|
||||
return _rtgui_notebook_current_widget_handle(notebook, event);
|
||||
case RTGUI_EVENT_KBD:
|
||||
if (notebook->current != RTGUI_NOT_FOUND)
|
||||
{
|
||||
if (RTGUI_OBJECT(notebook->childs[notebook->current].widget
|
||||
)->event_handler != RT_NULL)
|
||||
return RTGUI_OBJECT(notebook->childs[notebook->current].widget
|
||||
)->event_handler(
|
||||
RTGUI_OBJECT(notebook->childs[notebook->current].widget),
|
||||
event);
|
||||
}
|
||||
break;
|
||||
return _rtgui_notebook_current_widget_handle(notebook, event);
|
||||
default:
|
||||
/* use parent event handler */
|
||||
return rtgui_widget_event_handler(object, event);
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* File : panel.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2012, 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-07-07 Bernard implement panel as a widget
|
||||
*/
|
||||
#include <rtgui/dc.h>
|
||||
#include <rtgui/widgets/panel.h>
|
||||
#include <rtgui/rtgui_system.h>
|
||||
#include <rtgui/rtgui_theme.h>
|
||||
|
||||
static void _rtgui_panel_constructor(rtgui_panel_t *panel)
|
||||
{
|
||||
/* init widget and set event handler */
|
||||
rtgui_object_set_event_handler(RTGUI_OBJECT(panel), rtgui_panel_event_handler);
|
||||
|
||||
/* set field */
|
||||
panel->border_style = RTGUI_BORDER_NONE;
|
||||
}
|
||||
|
||||
DEFINE_CLASS_TYPE(panel, "panel",
|
||||
RTGUI_CONTAINER_TYPE,
|
||||
_rtgui_panel_constructor,
|
||||
RT_NULL,
|
||||
sizeof(struct rtgui_panel));
|
||||
|
||||
rt_bool_t rtgui_panel_event_handler(struct rtgui_object *object, struct rtgui_event* event)
|
||||
{
|
||||
struct rtgui_panel* panel;
|
||||
|
||||
panel = RTGUI_PANEL(object);
|
||||
switch (event->type)
|
||||
{
|
||||
case RTGUI_EVENT_PAINT:
|
||||
{
|
||||
struct rtgui_dc* dc;
|
||||
struct rtgui_rect rect;
|
||||
|
||||
rtgui_widget_get_rect(RTGUI_WIDGET(object), &rect);
|
||||
|
||||
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(object));
|
||||
if (dc == RT_NULL) return RT_FALSE;
|
||||
|
||||
rtgui_dc_fill_rect(dc, &rect);
|
||||
// rtgui_rect_inflate(&rect, RTGUI_WIDGET(panel)->);
|
||||
rtgui_dc_draw_border(dc, &rect, panel->border_style);
|
||||
|
||||
/* paint on each child */
|
||||
rtgui_container_dispatch_event(RTGUI_CONTAINER(panel), event);
|
||||
|
||||
rtgui_dc_end_drawing(dc);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return rtgui_container_event_handler(object, event);
|
||||
}
|
||||
|
||||
return RT_FALSE;
|
||||
}
|
||||
|
||||
rtgui_panel_t* rtgui_panel_create(int border_style)
|
||||
{
|
||||
struct rtgui_panel* panel;
|
||||
|
||||
panel = (struct rtgui_panel*) rtgui_widget_create(RTGUI_PANEL_TYPE);
|
||||
if (panel != RT_NULL)
|
||||
{
|
||||
rtgui_rect_t rect = {0, 0, 100, 100};
|
||||
rtgui_widget_set_rect(RTGUI_WIDGET(panel), &rect);
|
||||
|
||||
panel->border_style = border_style;
|
||||
}
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
void rtgui_panel_destroy(rtgui_panel_t* panel)
|
||||
{
|
||||
rtgui_object_destroy(RTGUI_OBJECT(panel));
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ rt_bool_t rtgui_progressbar_event_handler(struct rtgui_object* object,
|
||||
case RTGUI_EVENT_PAINT:
|
||||
rtgui_theme_draw_progressbar(bar);
|
||||
break;
|
||||
default:
|
||||
return rtgui_widget_event_handler(object, event);
|
||||
}
|
||||
|
||||
return RT_FALSE;
|
||||
|
||||
@@ -101,7 +101,7 @@ rt_bool_t rtgui_radiobox_event_handler(struct rtgui_object* object, struct rtgui
|
||||
|
||||
#ifndef RTGUI_USING_SMALL_SIZE
|
||||
if (widget->on_key != RT_NULL)
|
||||
widget->on_key(RTGUI_OBJECT(widget), event);
|
||||
return widget->on_key(RTGUI_OBJECT(widget), event);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
@@ -116,12 +116,18 @@ rt_bool_t rtgui_radiobox_event_handler(struct rtgui_object* object, struct rtgui
|
||||
if (e->key == RTGUIK_UP)
|
||||
{
|
||||
if (radiobox->item_selection > 0)
|
||||
{
|
||||
rtgui_radiobox_set_selection(radiobox, radiobox->item_selection - 1);
|
||||
return RT_TRUE;
|
||||
}
|
||||
}
|
||||
else if (e->key == RTGUIK_DOWN)
|
||||
{
|
||||
if (radiobox->item_selection < radiobox->item_count - 1)
|
||||
{
|
||||
rtgui_radiobox_set_selection(radiobox, radiobox->item_selection + 1);
|
||||
return RT_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -129,12 +135,18 @@ rt_bool_t rtgui_radiobox_event_handler(struct rtgui_object* object, struct rtgui
|
||||
if (e->key == RTGUIK_LEFT)
|
||||
{
|
||||
if (radiobox->item_selection > 0)
|
||||
{
|
||||
rtgui_radiobox_set_selection(radiobox, radiobox->item_selection - 1);
|
||||
return RT_TRUE;
|
||||
}
|
||||
}
|
||||
else if (e->key == RTGUIK_RIGHT)
|
||||
{
|
||||
if (radiobox->item_selection < radiobox->item_count - 1)
|
||||
{
|
||||
rtgui_radiobox_set_selection(radiobox, radiobox->item_selection + 1);
|
||||
return RT_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -150,6 +162,8 @@ rt_bool_t rtgui_radiobox_event_handler(struct rtgui_object* object, struct rtgui
|
||||
rtgui_radiobox_onmouse(radiobox, (struct rtgui_event_mouse*)event);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return rtgui_widget_event_handler(object, event);
|
||||
}
|
||||
|
||||
return RT_FALSE;
|
||||
|
||||
@@ -302,7 +302,7 @@ rt_bool_t rtgui_scrollbar_event_handler(struct rtgui_object *object,
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
return rtgui_widget_event_handler(object, event);
|
||||
}
|
||||
|
||||
return RT_FALSE;
|
||||
|
||||
@@ -168,13 +168,10 @@ rt_bool_t rtgui_slider_event_handler(struct rtgui_object *object, struct rtgui_e
|
||||
|
||||
#ifndef RTGUI_USING_SMALL_SIZE
|
||||
if (widget->on_key != RT_NULL)
|
||||
widget->on_key(RTGUI_OBJECT(widget), event);
|
||||
return widget->on_key(RTGUI_OBJECT(widget), event);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
return rtgui_slider_onkey(slider, (struct rtgui_event_kbd *)event);
|
||||
}
|
||||
break;
|
||||
|
||||
case RTGUI_EVENT_MOUSE_BUTTON:
|
||||
if (!RTGUI_WIDGET_IS_ENABLE(widget) || RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE;
|
||||
@@ -188,6 +185,9 @@ rt_bool_t rtgui_slider_event_handler(struct rtgui_object *object, struct rtgui_e
|
||||
rtgui_slider_onmouse(slider, (struct rtgui_event_mouse*)event);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return rtgui_widget_event_handler(object, event);
|
||||
}
|
||||
|
||||
return RT_FALSE;
|
||||
|
||||
@@ -36,6 +36,8 @@ rt_bool_t rtgui_staticline_event_handler(struct rtgui_object* object, struct rtg
|
||||
#endif
|
||||
rtgui_theme_draw_staticline(staticline);
|
||||
break;
|
||||
default:
|
||||
return rtgui_widget_event_handler(object, event);
|
||||
}
|
||||
|
||||
return RT_FALSE;
|
||||
|
||||
+437
-192
File diff suppressed because it is too large
Load Diff
@@ -307,6 +307,8 @@ rt_bool_t rtgui_textview_event_handler(struct rtgui_object* object, struct rtgui
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return rtgui_widget_event_handler(RTGUI_OBJECT(widget),event);
|
||||
}
|
||||
|
||||
return RT_FALSE;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include <rtgui/dc_client.h>
|
||||
#include <rtgui/rtgui_application.h>
|
||||
#include <rtgui/rtgui_app.h>
|
||||
#include <rtgui/widgets/widget.h>
|
||||
#include <rtgui/widgets/window.h>
|
||||
#include <rtgui/widgets/container.h>
|
||||
@@ -36,9 +36,7 @@ static void _rtgui_widget_constructor(rtgui_widget_t *widget)
|
||||
widget->gc.font = rtgui_font_default();
|
||||
widget->gc.textstyle = RTGUI_TEXTSTYLE_NORMAL;
|
||||
widget->gc.textalign = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_TOP;
|
||||
#ifndef RTGUI_USING_SMALL_SIZE
|
||||
widget->align = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_TOP;
|
||||
#endif
|
||||
|
||||
/* set parent and toplevel root */
|
||||
widget->parent = RT_NULL;
|
||||
@@ -88,7 +86,7 @@ static void _rtgui_widget_destructor(rtgui_widget_t *widget)
|
||||
rtgui_region_fini(&(widget->clip));
|
||||
}
|
||||
|
||||
DEFINE_CLASS_TYPE(widget, "widget",
|
||||
DEFINE_CLASS_TYPE(widget, "widget",
|
||||
RTGUI_OBJECT_TYPE,
|
||||
_rtgui_widget_constructor,
|
||||
_rtgui_widget_destructor,
|
||||
@@ -114,11 +112,9 @@ void rtgui_widget_set_rect(rtgui_widget_t* widget, const rtgui_rect_t* rect)
|
||||
|
||||
widget->extent = *rect;
|
||||
|
||||
#ifndef RTGUI_USING_SMALL_SIZE
|
||||
/* reset mini width and height */
|
||||
widget->mini_width = rtgui_rect_width(widget->extent);
|
||||
widget->mini_height = rtgui_rect_height(widget->extent);
|
||||
#endif
|
||||
|
||||
/* it's not empty, fini it */
|
||||
if (rtgui_region_not_empty(&(widget->clip)))
|
||||
@@ -166,7 +162,6 @@ void rtgui_widget_get_extent(rtgui_widget_t* widget, rtgui_rect_t *rect)
|
||||
*rect = widget->extent;
|
||||
}
|
||||
|
||||
#ifndef RTGUI_USING_SMALL_SIZE
|
||||
void rtgui_widget_set_miniwidth(rtgui_widget_t* widget, int width)
|
||||
{
|
||||
RT_ASSERT(widget != RT_NULL);
|
||||
@@ -180,7 +175,6 @@ void rtgui_widget_set_miniheight(rtgui_widget_t* widget, int height)
|
||||
|
||||
widget->mini_height = height;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This function moves widget and its children to a logic point
|
||||
@@ -410,16 +404,16 @@ struct rtgui_win* rtgui_widget_get_toplevel(rtgui_widget_t* widget)
|
||||
|
||||
rt_bool_t rtgui_widget_event_handler(struct rtgui_object* object, rtgui_event_t* event)
|
||||
{
|
||||
#ifndef RTGUI_USING_SMALL_SIZE
|
||||
struct rtgui_widget *widget;
|
||||
|
||||
RT_ASSERT(object != RT_NULL);
|
||||
RT_ASSERT(event != RT_NULL);
|
||||
|
||||
widget = RTGUI_WIDGET(object);
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case RTGUI_EVENT_SHOW:
|
||||
return rtgui_widget_onshow(object, event);
|
||||
case RTGUI_EVENT_HIDE:
|
||||
return rtgui_widget_onhide(object, event);
|
||||
#ifndef RTGUI_USING_SMALL_SIZE
|
||||
case RTGUI_EVENT_PAINT:
|
||||
if (widget->on_draw != RT_NULL)
|
||||
return widget->on_draw(RTGUI_OBJECT(widget), event);
|
||||
@@ -444,8 +438,8 @@ rt_bool_t rtgui_widget_event_handler(struct rtgui_object* object, rtgui_event_t*
|
||||
if (widget->on_size != RT_NULL)
|
||||
return widget->on_size(RTGUI_OBJECT(widget), event);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return RT_FALSE;
|
||||
}
|
||||
@@ -512,12 +506,26 @@ void rtgui_widget_update_clip(rtgui_widget_t* widget)
|
||||
}
|
||||
}
|
||||
|
||||
void rtgui_widget_show(rtgui_widget_t* widget)
|
||||
void rtgui_widget_show(struct rtgui_widget *widget)
|
||||
{
|
||||
/* there is no parent or the parent is hide, no show at all */
|
||||
if (widget->parent == RT_NULL ||
|
||||
RTGUI_WIDGET_IS_HIDE(widget->parent))
|
||||
return;
|
||||
struct rtgui_event_show eshow;
|
||||
RT_ASSERT(widget != RT_NULL);
|
||||
|
||||
if (!RTGUI_WIDGET_IS_HIDE(widget))
|
||||
return;
|
||||
|
||||
RTGUI_EVENT_SHOW_INIT(&eshow);
|
||||
if (RTGUI_OBJECT(widget)->event_handler != RT_NULL)
|
||||
{
|
||||
RTGUI_OBJECT(widget)->event_handler(
|
||||
RTGUI_OBJECT(widget),
|
||||
&eshow);
|
||||
}
|
||||
}
|
||||
|
||||
rt_bool_t rtgui_widget_onshow(struct rtgui_object *object, struct rtgui_event *event)
|
||||
{
|
||||
struct rtgui_widget *widget = RTGUI_WIDGET(object);
|
||||
|
||||
/* update the clip info of widget */
|
||||
RTGUI_WIDGET_UNHIDE(widget);
|
||||
@@ -525,10 +533,14 @@ void rtgui_widget_show(rtgui_widget_t* widget)
|
||||
|
||||
if (widget->on_show != RT_NULL)
|
||||
widget->on_show(RTGUI_OBJECT(widget), RT_NULL);
|
||||
|
||||
return RT_FALSE;
|
||||
}
|
||||
|
||||
void rtgui_widget_hide(rtgui_widget_t* widget)
|
||||
rt_bool_t rtgui_widget_onhide(struct rtgui_object *object, struct rtgui_event *event)
|
||||
{
|
||||
struct rtgui_widget *widget = RTGUI_WIDGET(object);
|
||||
|
||||
/* hide this widget */
|
||||
RTGUI_WIDGET_HIDE(widget);
|
||||
|
||||
@@ -549,12 +561,31 @@ void rtgui_widget_hide(rtgui_widget_t* widget)
|
||||
|
||||
if (widget->on_hide != RT_NULL)
|
||||
widget->on_hide(RTGUI_OBJECT(widget), RT_NULL);
|
||||
|
||||
return RT_FALSE;
|
||||
}
|
||||
|
||||
void rtgui_widget_hide(struct rtgui_widget *widget)
|
||||
{
|
||||
struct rtgui_event_hide ehide;
|
||||
RT_ASSERT(widget != RT_NULL);
|
||||
|
||||
if (RTGUI_WIDGET_IS_HIDE(widget))
|
||||
return;
|
||||
|
||||
RTGUI_EVENT_HIDE_INIT(&ehide);
|
||||
if (RTGUI_OBJECT(widget)->event_handler != RT_NULL)
|
||||
{
|
||||
RTGUI_OBJECT(widget)->event_handler(
|
||||
RTGUI_OBJECT(widget),
|
||||
&ehide);
|
||||
}
|
||||
}
|
||||
|
||||
rtgui_color_t rtgui_widget_get_parent_foreground(rtgui_widget_t* widget)
|
||||
{
|
||||
rtgui_widget_t* parent;
|
||||
|
||||
|
||||
/* get parent widget */
|
||||
parent = widget->parent;
|
||||
while (parent->parent != RT_NULL && (RTGUI_WIDGET_FLAG(parent) & RTGUI_WIDGET_FLAG_TRANSPARENT))
|
||||
@@ -591,6 +622,9 @@ void rtgui_widget_update(rtgui_widget_t* widget)
|
||||
|
||||
RT_ASSERT(widget != RT_NULL);
|
||||
|
||||
if (RTGUI_WIDGET_IS_HIDE(widget))
|
||||
return;
|
||||
|
||||
if (RTGUI_OBJECT(widget)->event_handler != RT_NULL)
|
||||
{
|
||||
RTGUI_OBJECT(widget)->event_handler(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user