update GUI examples.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1047 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
bernard.xiong@gmail.com 2010-11-15 00:26:11 +00:00
parent 468db50159
commit ac407d25ae
8 changed files with 37 additions and 18 deletions

View File

@ -56,6 +56,7 @@ rtgui_view_t* demo_view(rtgui_workbench_t* workbench, const char* title)
/* 获得视图的位置信息(在加入到workbench中时workbench会自动调整视图的大小) */
rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
rtgui_widget_rect_to_device(RTGUI_WIDGET(view), &rect);
rect.x1 += 5;
rect.y1 += 5;
rect.x2 -= 5;
@ -79,13 +80,14 @@ rtgui_view_t* demo_view(rtgui_workbench_t* workbench, const char* title)
/* 获得视图的位置信息 */
rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
rtgui_widget_rect_to_device(RTGUI_WIDGET(view), &rect);
rect.x2 -= 5;
rect.y2 -= 5;
rect.x1 = rect.x2 - 50;
rect.y1 = rect.y2 - 20;
rect.x1 = rect.x2 - 100;
rect.y1 = rect.y2 - 25;
/* 创建"下一个"按钮 */
next_btn = rtgui_button_create("Next");
next_btn = rtgui_button_create("下一个");
/* 设置onbutton动作到demo_view_next函数 */
rtgui_button_set_onbutton(next_btn, demo_view_next);
/* 设置按钮的位置信息 */
@ -95,13 +97,14 @@ rtgui_view_t* demo_view(rtgui_workbench_t* workbench, const char* title)
/* 获得视图的位置信息 */
rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
rtgui_widget_rect_to_device(RTGUI_WIDGET(view), &rect);
rect.x1 += 5;
rect.y2 -= 5;
rect.x2 = rect.x1 + 50;
rect.y1 = rect.y2 - 20;
rect.x2 = rect.x1 + 100;
rect.y1 = rect.y2 - 25;
/* 创建"上一个"按钮 */
prev_btn = rtgui_button_create("Prev");
prev_btn = rtgui_button_create("上一个");
/* 设置onbutton动作到demo_view_prev函数 */
rtgui_button_set_onbutton(prev_btn, demo_view_prev);
/* 设置按钮的位置信息 */
@ -121,9 +124,21 @@ void demo_view_get_rect(rtgui_view_t* view, rtgui_rect_t *rect)
RT_ASSERT(rect != RT_NULL);
rtgui_widget_get_rect(RTGUI_WIDGET(view), rect);
rtgui_widget_rect_to_device(RTGUI_WIDGET(view), rect);
/* 去除演示标题和下方按钮的区域 */
rect->y1 += 45;
rect->y2 -= 25;
rect->y2 -= 35;
}
void demo_view_get_logic_rect(rtgui_view_t* view, rtgui_rect_t *rect)
{
RT_ASSERT(view != RT_NULL);
RT_ASSERT(rect != RT_NULL);
rtgui_widget_get_rect(RTGUI_WIDGET(view), rect);
/* 去除演示标题和下方按钮的区域 */
rect->y1 += 45;
rect->y2 -= 35;
}
/* 当是标准版本时这个函数用于返回自动布局引擎box控件 */

View File

@ -27,6 +27,7 @@
rtgui_view_t* demo_view(rtgui_workbench_t* workbench, const char* title);
/* 获得演示视图提供给演示控件用的区域信息 */
void demo_view_get_rect(rtgui_view_t* view, rtgui_rect_t *rect);
void demo_view_get_logic_rect(rtgui_view_t* view, rtgui_rect_t *rect);
void demo_view_show(void);
/* 如果是标准版,可以调用这个函数获得一个自动布局引擎 */

View File

@ -21,7 +21,7 @@ void _onidle(rtgui_widget_t* widget, rtgui_event_t *event)
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(view));
if (dc == RT_NULL) return ;
demo_view_get_rect(RTGUI_VIEW(view), &rect);
demo_view_get_logic_rect(RTGUI_VIEW(view), &rect);
draw_rect.x1 = RAND(rect.x1, rect.x2);
draw_rect.y1 = RAND(rect.y1, rect.y2);
draw_rect.x2 = RAND(draw_rect.x1, rect.x2);
@ -50,7 +50,7 @@ void _draw_default(rtgui_widget_t* widget, rtgui_event_t* event)
return ;
/* 获得demo view允许绘图的区域 */
demo_view_get_rect(RTGUI_VIEW(widget), &rect);
demo_view_get_logic_rect(RTGUI_VIEW(widget), &rect);
/* 擦除所有 */
RTGUI_WIDGET_BACKGROUND(widget) = default_background;

View File

@ -28,7 +28,7 @@ static void timeout(struct rtgui_timer* timer, void* parameter)
return ;
/* 获得demo view允许绘图的区域主要用于判断边界 */
demo_view_get_rect(RTGUI_VIEW(widget), &rect);
demo_view_get_logic_rect(RTGUI_VIEW(widget), &rect);
rect.y2 -= 5;
/* 判断是否是第一次绘图 */
@ -72,7 +72,7 @@ static rt_bool_t animation_event_handler(rtgui_widget_t* widget, rtgui_event_t *
return RT_FALSE;
/* 获得demo view允许绘图的区域 */
demo_view_get_rect(RTGUI_VIEW(widget), &rect);
demo_view_get_logic_rect(RTGUI_VIEW(widget), &rect);
/* 绘图 */
rect = text_rect;

View File

@ -46,7 +46,7 @@ rt_bool_t dc_event_handler(rtgui_widget_t* widget, rtgui_event_t *event)
return RT_FALSE;
/* 获得demo view允许绘图的区域 */
demo_view_get_rect(RTGUI_VIEW(widget), &rect);
demo_view_get_logic_rect(RTGUI_VIEW(widget), &rect);
RTGUI_DC_TEXTALIGN(dc) = RTGUI_ALIGN_BOTTOM | RTGUI_ALIGN_CENTER_HORIZONTAL;
/* 显示GUI的版本信息 */
@ -73,7 +73,7 @@ rt_bool_t dc_event_handler(rtgui_widget_t* widget, rtgui_event_t *event)
/* 填充一个圆形 */
RTGUI_DC_FC(dc) = green;
rtgui_dc_fill_circle(dc, rect.x1 + 30, rect.y1 + 10, 10);
#if 0
/* 画一个圆角矩形 */
rect.x1 = 150;
rect.y1 = 180;
@ -101,6 +101,9 @@ rt_bool_t dc_event_handler(rtgui_widget_t* widget, rtgui_event_t *event)
RTGUI_DC_FC(dc) = blue;
rtgui_dc_draw_polygon(dc, vx, vy, 6);
#endif
RTGUI_DC_FC(dc) = blue;
/* 绘制不同的边框 */
{
rtgui_rect_t rect = {0, 0, 16, 16};

View File

@ -38,7 +38,7 @@ static rt_bool_t dc_buffer_event_handler(rtgui_widget_t* widget, rtgui_event_t *
return RT_FALSE;
/* 获得demo view允许绘图的区域 */
demo_view_get_rect(RTGUI_VIEW(widget), &rect);
demo_view_get_logic_rect(RTGUI_VIEW(widget), &rect);
rect.x1 += 10;
rect.y1 += 10;

View File

@ -29,7 +29,7 @@ rtgui_view_t *demo_view_progressbar(rtgui_workbench_t* workbench)
/* get demo view rect */
demo_view_get_rect(view, &rect);
label = rtgui_label_create("horizontal progress bar:");
label = rtgui_label_create("ËŽĆ˝˝řśČĚő:");
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
rect.x1 += 5; rect.x2 -= 5;
rect.y1 += 5; rect.y2 = rect.y1 + 18;
@ -40,7 +40,7 @@ rtgui_view_t *demo_view_progressbar(rtgui_workbench_t* workbench)
/* get demo view rect */
demo_view_get_rect(view, &rect);
label = rtgui_label_create("vertical progress bar:");
label = rtgui_label_create("´šÖą˝řśČĚő:");
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
rect.x1 += 5; rect.x2 -= 5;
rect.y1 += 45; rect.y2 = rect.y1 + 18;

View File

@ -52,7 +52,7 @@ static void workbench_entry(void* parameter)
/* 初始化各个例子的视图 */
#if RT_VERSION == 4
// demo_view_benchmark(workbench);
demo_view_benchmark(workbench);
#endif
demo_view_dc(workbench);
@ -68,7 +68,7 @@ static void workbench_entry(void* parameter)
demo_view_animation(workbench);
#ifndef RTGUI_USING_SMALL_SIZE
demo_view_buffer_animation(workbench);
demo_view_instrument_panel(workbench);
// demo_view_instrument_panel(workbench);
#endif
demo_view_window(workbench);
demo_view_label(workbench);