add Chinese Comments
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@481 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
f05df1f97b
commit
e48f777a6d
|
@ -45,16 +45,20 @@ rtgui_view_t* demo_fn_view(rtgui_workbench_t* workbench)
|
|||
view = demo_view(workbench, "FileList View");
|
||||
demo_view_get_rect(view, &rect);
|
||||
|
||||
rect.x1 += 5; rect.x2 -= 5;
|
||||
rect.y1 += 5; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 5;
|
||||
rect.x2 -= 5;
|
||||
rect.y1 += 5;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
label = rtgui_label_create("fn: ");
|
||||
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
|
||||
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
|
||||
RTGUI_WIDGET_FONT(RTGUI_WIDGET(label)) = font;
|
||||
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 = rect.x1 + 80;
|
||||
rect.y1 += 30; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 5;
|
||||
rect.x2 = rect.x1 + 80;
|
||||
rect.y1 += 30;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
open_btn = rtgui_button_create("Open File");
|
||||
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(open_btn));
|
||||
rtgui_widget_set_rect(RTGUI_WIDGET(open_btn), &rect);
|
||||
|
|
|
@ -22,8 +22,10 @@ static void listitem_action(void* parameter)
|
|||
win = rtgui_win_create(RTGUI_TOPLEVEL(workbench),
|
||||
"窗口", &rect, RTGUI_WIN_STYLE_DEFAULT);
|
||||
|
||||
rect.x1 += 20; rect.x2 -= 5;
|
||||
rect.y1 += 5; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 20;
|
||||
rect.x2 -= 5;
|
||||
rect.y1 += 5;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
|
||||
rt_sprintf(label_text, "动作 %d", no);
|
||||
label = rtgui_label_create(label_text);
|
||||
|
@ -62,7 +64,8 @@ static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event)
|
|||
workbench = RTGUI_WORKBENCH(rtgui_widget_get_toplevel(widget));
|
||||
rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect);
|
||||
|
||||
_view = rtgui_list_view_create(items, sizeof(items)/sizeof(struct rtgui_list_item), &rect);
|
||||
_view = rtgui_list_view_create(items, sizeof(items)/sizeof(struct rtgui_list_item),
|
||||
&rect);
|
||||
rtgui_workbench_add_view(workbench, RTGUI_VIEW(_view));
|
||||
|
||||
/* 模式显示视图 */
|
||||
|
@ -78,8 +81,10 @@ rtgui_view_t* demo_listview_view(rtgui_workbench_t* workbench)
|
|||
view = demo_view(workbench, "列表视图演示");
|
||||
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 = rect.x1 + 80;
|
||||
rect.y1 += 30; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 5;
|
||||
rect.x2 = rect.x1 + 80;
|
||||
rect.y1 += 30;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
open_btn = rtgui_button_create("打开列表");
|
||||
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(open_btn));
|
||||
rtgui_widget_set_rect(RTGUI_WIDGET(open_btn), &rect);
|
||||
|
|
|
@ -58,8 +58,10 @@ rtgui_view_t* demo_view(rtgui_workbench_t* workbench, const char* title)
|
|||
|
||||
/* 获得视图的位置信息(在加入到workbench中时,workbench会自动调整视图的大小) */
|
||||
rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
|
||||
rect.x1 += 5; rect.y1 += 5;
|
||||
rect.x2 -= 5; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 5;
|
||||
rect.y1 += 5;
|
||||
rect.x2 -= 5;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
|
||||
/* 创建标题用的标签 */
|
||||
label = rtgui_label_create(title);
|
||||
|
@ -68,7 +70,8 @@ rtgui_view_t* demo_view(rtgui_workbench_t* workbench, const char* title)
|
|||
/* 添加标签到视图中 */
|
||||
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
|
||||
|
||||
rect.y1 += 20; rect.y2 += 20;
|
||||
rect.y1 += 20;
|
||||
rect.y2 += 20;
|
||||
/* 创建一个水平的staticline线 */
|
||||
line = rtgui_staticline_create(RTGUI_HORIZONTAL);
|
||||
/* 设置静态线的位置信息 */
|
||||
|
@ -78,8 +81,10 @@ rtgui_view_t* demo_view(rtgui_workbench_t* workbench, const char* title)
|
|||
|
||||
/* 获得视图的位置信息 */
|
||||
rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
|
||||
rect.x2 -= 5; rect.y2 -= 5;
|
||||
rect.x1 = rect.x2 - 50; rect.y1 = rect.y2 - 20;
|
||||
rect.x2 -= 5;
|
||||
rect.y2 -= 5;
|
||||
rect.x1 = rect.x2 - 50;
|
||||
rect.y1 = rect.y2 - 20;
|
||||
|
||||
/* 创建"下一个"按钮 */
|
||||
next_btn = rtgui_button_create("Next");
|
||||
|
@ -92,8 +97,10 @@ rtgui_view_t* demo_view(rtgui_workbench_t* workbench, const char* title)
|
|||
|
||||
/* 获得视图的位置信息 */
|
||||
rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
|
||||
rect.x1 += 5; rect.y2 -= 5;
|
||||
rect.x2 = rect.x1 + 50; rect.y1 = rect.y2 - 20;
|
||||
rect.x1 += 5;
|
||||
rect.y2 -= 5;
|
||||
rect.x2 = rect.x1 + 50;
|
||||
rect.y1 = rect.y2 - 20;
|
||||
|
||||
/* 创建"上一个"按钮 */
|
||||
prev_btn = rtgui_button_create("Prev");
|
||||
|
|
|
@ -20,8 +20,10 @@ rtgui_view_t* demo_view_button(rtgui_workbench_t* workbench)
|
|||
|
||||
/* 获得视图的位置信息 */
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 5;
|
||||
rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
/* 创建一个button控件 */
|
||||
button = rtgui_button_create("Red");
|
||||
/* 设置label控件的前景色为红色 */
|
||||
|
@ -33,8 +35,10 @@ rtgui_view_t* demo_view_button(rtgui_workbench_t* workbench)
|
|||
|
||||
/* 获得视图的位置信息 */
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5 + 25; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 5;
|
||||
rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5 + 25;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
/* 创建一个button控件 */
|
||||
button = rtgui_button_create("Blue");
|
||||
/* 设置label控件的前景色为蓝色 */
|
||||
|
@ -46,8 +50,10 @@ rtgui_view_t* demo_view_button(rtgui_workbench_t* workbench)
|
|||
|
||||
/* 获得视图的位置信息 */
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5 + 25 + 25; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 5;
|
||||
rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5 + 25 + 25;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
/* 创建一个button控件 */
|
||||
button = rtgui_button_create("12 font");
|
||||
/* 设置字体为12点阵的asc字体 */
|
||||
|
@ -60,8 +66,10 @@ rtgui_view_t* demo_view_button(rtgui_workbench_t* workbench)
|
|||
|
||||
/* 获得视图的位置信息 */
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5 + 25 + 25 + 25; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 5;
|
||||
rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5 + 25 + 25 + 25;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
/* 创建一个button控件 */
|
||||
button = rtgui_button_create("16 font");
|
||||
/* 设置字体为16点阵的asc字体 */
|
||||
|
|
|
@ -20,8 +20,10 @@ rtgui_view_t* demo_view_checkbox(rtgui_workbench_t* workbench)
|
|||
|
||||
/* 获得视图的位置信息 */
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 5;
|
||||
rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
/* 创建一个checkbox控件 */
|
||||
checkbox = rtgui_checkbox_create("Red",RT_TRUE);
|
||||
/* 设置前景色为红色 */
|
||||
|
@ -33,8 +35,10 @@ rtgui_view_t* demo_view_checkbox(rtgui_workbench_t* workbench)
|
|||
|
||||
/* 获得视图的位置信息 */
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5 + 25; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 5;
|
||||
rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5 + 25;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
/* 创建一个checkbox控件 */
|
||||
checkbox = rtgui_checkbox_create("Blue",RT_TRUE);
|
||||
/* 设置前景色为蓝色 */
|
||||
|
@ -46,8 +50,10 @@ rtgui_view_t* demo_view_checkbox(rtgui_workbench_t* workbench)
|
|||
|
||||
/* 获得视图的位置信息 */
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5 + 25 + 25; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 5;
|
||||
rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5 + 25 + 25;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
/* 创建一个checkbox控件 */
|
||||
checkbox = rtgui_checkbox_create("12 font",RT_TRUE);
|
||||
/* 设置字体为12点阵 */
|
||||
|
@ -60,8 +66,10 @@ rtgui_view_t* demo_view_checkbox(rtgui_workbench_t* workbench)
|
|||
|
||||
/* 获得视图的位置信息 */
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5 + 25 + 25 + 25; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 5;
|
||||
rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5 + 25 + 25 + 25;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
/* 创建一个checkbox控件 */
|
||||
checkbox = rtgui_checkbox_create("16 font",RT_TRUE);
|
||||
/* 设置字体为16点阵 */
|
||||
|
|
|
@ -56,40 +56,58 @@ rt_bool_t dc_event_handler(rtgui_widget_t* widget, rtgui_event_t *event)
|
|||
rtgui_rect_moveto(&rect, 30, 120);
|
||||
|
||||
rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_RAISE);
|
||||
rect.x1 += 20; rect.x2 += 20 + 50;
|
||||
rect.x1 += 20;
|
||||
rect.x2 += 20 + 50;
|
||||
rtgui_dc_draw_text(dc, "raise", &rect);
|
||||
rect.x1 -= 20; rect.x2 -= 20 + 50;
|
||||
rect.y1 += 20; rect.y2 += 20;
|
||||
rect.x1 -= 20;
|
||||
rect.x2 -= 20 + 50;
|
||||
rect.y1 += 20;
|
||||
rect.y2 += 20;
|
||||
|
||||
rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_SIMPLE);
|
||||
rect.x1 += 20; rect.x2 += 20 + 50;
|
||||
rect.x1 += 20;
|
||||
rect.x2 += 20 + 50;
|
||||
rtgui_dc_draw_text(dc, "simple", &rect);
|
||||
rect.x1 -= 20; rect.x2 -= 20 + 50;
|
||||
rect.y1 += 20; rect.y2 += 20;
|
||||
rect.x1 -= 20;
|
||||
rect.x2 -= 20 + 50;
|
||||
rect.y1 += 20;
|
||||
rect.y2 += 20;
|
||||
|
||||
rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_SUNKEN);
|
||||
rect.x1 += 20; rect.x2 += 20 + 50;
|
||||
rect.x1 += 20;
|
||||
rect.x2 += 20 + 50;
|
||||
rtgui_dc_draw_text(dc, "sunken", &rect);
|
||||
rect.x1 -= 20; rect.x2 -= 20 + 50;
|
||||
rect.y1 += 20; rect.y2 += 20;
|
||||
rect.x1 -= 20;
|
||||
rect.x2 -= 20 + 50;
|
||||
rect.y1 += 20;
|
||||
rect.y2 += 20;
|
||||
|
||||
rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_BOX);
|
||||
rect.x1 += 20; rect.x2 += 20 + 50;
|
||||
rect.x1 += 20;
|
||||
rect.x2 += 20 + 50;
|
||||
rtgui_dc_draw_text(dc, "box", &rect);
|
||||
rect.x1 -= 20; rect.x2 -= 20 + 50;
|
||||
rect.y1 += 20; rect.y2 += 20;
|
||||
rect.x1 -= 20;
|
||||
rect.x2 -= 20 + 50;
|
||||
rect.y1 += 20;
|
||||
rect.y2 += 20;
|
||||
|
||||
rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_STATIC);
|
||||
rect.x1 += 20; rect.x2 += 20 + 50;
|
||||
rect.x1 += 20;
|
||||
rect.x2 += 20 + 50;
|
||||
rtgui_dc_draw_text(dc, "static", &rect);
|
||||
rect.x1 -= 20; rect.x2 -= 20 + 50;
|
||||
rect.y1 += 20; rect.y2 += 20;
|
||||
rect.x1 -= 20;
|
||||
rect.x2 -= 20 + 50;
|
||||
rect.y1 += 20;
|
||||
rect.y2 += 20;
|
||||
|
||||
rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_EXTRA);
|
||||
rect.x1 += 20; rect.x2 += 20 + 50;
|
||||
rect.x1 += 20;
|
||||
rect.x2 += 20 + 50;
|
||||
rtgui_dc_draw_text(dc, "extra", &rect);
|
||||
rect.x1 -= 20; rect.x2 -= 20 + 50;
|
||||
rect.y1 += 20; rect.y2 += 20;
|
||||
rect.x1 -= 20;
|
||||
rect.x2 -= 20 + 50;
|
||||
rect.y1 += 20;
|
||||
rect.y2 += 20;
|
||||
}
|
||||
/* »æͼÍê³É */
|
||||
rtgui_dc_end_drawing(dc);
|
||||
|
|
|
@ -19,8 +19,10 @@ rtgui_view_t* demo_view_label(rtgui_workbench_t* workbench)
|
|||
|
||||
/* 获得视图的位置信息 */
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 -= 5;
|
||||
rect.y1 += 5; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 5;
|
||||
rect.x2 -= 5;
|
||||
rect.y1 += 5;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
/* 创建一个label控件 */
|
||||
label = rtgui_label_create("Red Left");
|
||||
/* 设置label控件上的文本对齐方式为:左对齐 */
|
||||
|
@ -34,8 +36,10 @@ rtgui_view_t* demo_view_label(rtgui_workbench_t* workbench)
|
|||
|
||||
/* 获得视图的位置信息 */
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 -= 5;
|
||||
rect.y1 += 5 + 25; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 5;
|
||||
rect.x2 -= 5;
|
||||
rect.y1 += 5 + 25;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
/* 创建一个label控件 */
|
||||
label = rtgui_label_create("Blue Right");
|
||||
/* 设置label控件上的文本对齐方式为:右对齐 */
|
||||
|
@ -49,8 +53,10 @@ rtgui_view_t* demo_view_label(rtgui_workbench_t* workbench)
|
|||
|
||||
/* 获得视图的位置信息 */
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 -= 5;
|
||||
rect.y1 += 5 + 25 + 25; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 5;
|
||||
rect.x2 -= 5;
|
||||
rect.y1 += 5 + 25 + 25;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
/* 创建一个label控件 */
|
||||
label = rtgui_label_create("Green Center");
|
||||
/* 设置label控件的前景色为绿色 */
|
||||
|
@ -64,8 +70,10 @@ rtgui_view_t* demo_view_label(rtgui_workbench_t* workbench)
|
|||
|
||||
/* 获得视图的位置信息 */
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 -= 5;
|
||||
rect.y1 += 5 + 25 + 25 + 25; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 5;
|
||||
rect.x2 -= 5;
|
||||
rect.y1 += 5 + 25 + 25 + 25;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
/* 创建一个label控件 */
|
||||
label = rtgui_label_create("12 font");
|
||||
/* 设置字体为12点阵的asc字体 */
|
||||
|
@ -79,7 +87,8 @@ rtgui_view_t* demo_view_label(rtgui_workbench_t* workbench)
|
|||
/* 获得视图的位置信息 */
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5;
|
||||
rect.y1 += 5 + 25 + 25 + 25 + 25; rect.y2 = rect.y1 + 20;
|
||||
rect.y1 += 5 + 25 + 25 + 25 + 25;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
/* 创建一个label控件 */
|
||||
label = rtgui_label_create("16 font");
|
||||
/* 设置字体为16点阵的asc字体 */
|
||||
|
|
|
@ -18,8 +18,10 @@ rtgui_view_t *demo_view_mywidget(rtgui_workbench_t* workbench)
|
|||
|
||||
/* 获得视图的位置信息 */
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 = rect.y1 + 80;
|
||||
rect.y1 += 5; rect.y2 = rect.y1 + 80;
|
||||
rect.x1 += 5;
|
||||
rect.x2 = rect.y1 + 80;
|
||||
rect.y1 += 5;
|
||||
rect.y2 = rect.y1 + 80;
|
||||
/* 创建一个自定义控件 */
|
||||
mywidget = rtgui_mywidget_create(&rect);
|
||||
/* view是一个container控件,调用add_child方法添加这个自控件 */
|
||||
|
@ -27,8 +29,10 @@ rtgui_view_t *demo_view_mywidget(rtgui_workbench_t* workbench)
|
|||
|
||||
/* 获得视图的位置信息 */
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 25; rect.x2 = rect.y1 + 40;
|
||||
rect.y1 += 5 + 100; rect.y2 = rect.y1 + 40;
|
||||
rect.x1 += 25;
|
||||
rect.x2 = rect.y1 + 40;
|
||||
rect.y1 += 5 + 100;
|
||||
rect.y2 = rect.y1 + 40;
|
||||
/* 创建一个自定义控件 */
|
||||
mywidget = rtgui_mywidget_create(&rect);
|
||||
/* view是一个container控件,调用add_child方法添加这个自控件 */
|
||||
|
|
|
@ -9,19 +9,19 @@
|
|||
|
||||
/* 用于显示垂直方向的radio文本项数组 */
|
||||
static char* radio_item_v[5] =
|
||||
{
|
||||
{
|
||||
"one",
|
||||
"two",
|
||||
"three",
|
||||
"item 1",
|
||||
"item 2"
|
||||
};
|
||||
};
|
||||
|
||||
/* 用于显示水平方向的radio文本项数组 */
|
||||
static char* radio_item_h[3] =
|
||||
{
|
||||
{
|
||||
"one", "two", "three"
|
||||
};
|
||||
};
|
||||
|
||||
/* 创建用于演示radiobox控件的视图 */
|
||||
rtgui_view_t* demo_view_radiobox(rtgui_workbench_t* workbench)
|
||||
|
@ -35,8 +35,10 @@ rtgui_view_t* demo_view_radiobox(rtgui_workbench_t* workbench)
|
|||
|
||||
/* 获得视图的位置信息 */
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 -= 5;
|
||||
rect.y1 += 5; rect.y2 = rect.y1 + 5 * 25;
|
||||
rect.x1 += 5;
|
||||
rect.x2 -= 5;
|
||||
rect.y1 += 5;
|
||||
rect.y2 = rect.y1 + 5 * 25;
|
||||
|
||||
/* 创建一个垂直方向显示的radiobox控件,文本项是radio_item_v数组,共5个项 */
|
||||
radiobox = rtgui_radiobox_create("Radio Box", RTGUI_VERTICAL, radio_item_v, 5);
|
||||
|
@ -49,8 +51,10 @@ rtgui_view_t* demo_view_radiobox(rtgui_workbench_t* workbench)
|
|||
|
||||
/* 获得视图的位置信息 */
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 -= 5;
|
||||
rect.y1 += 5 + 5 * 25; rect.y2 = rect.y1 + 60;
|
||||
rect.x1 += 5;
|
||||
rect.x2 -= 5;
|
||||
rect.y1 += 5 + 5 * 25;
|
||||
rect.y2 = rect.y1 + 60;
|
||||
|
||||
/* 创建一个水平方向显示的radiobox控件,文本项是radio_item_h数组,共3个项 */
|
||||
radiobox = rtgui_radiobox_create("Radio Box", RTGUI_HORIZONTAL, radio_item_h, 3);
|
||||
|
|
|
@ -20,8 +20,10 @@ rtgui_view_t* demo_view_textbox(rtgui_workbench_t* workbench)
|
|||
|
||||
/* 获得视图的位置信息 */
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 = rect.x1 + 30;
|
||||
rect.y1 += 5; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 5;
|
||||
rect.x2 = rect.x1 + 30;
|
||||
rect.y1 += 5;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
/* 创建一个label控件 */
|
||||
label = rtgui_label_create("名字: ");
|
||||
/* 设置label的位置 */
|
||||
|
@ -31,7 +33,8 @@ rtgui_view_t* demo_view_textbox(rtgui_workbench_t* workbench)
|
|||
|
||||
/* 让textbox_rect赋值到rect,以计算textbox控件的位置 */
|
||||
textbox_rect = rect;
|
||||
textbox_rect.x1 = textbox_rect.x2 + 5; textbox_rect.x2 = textbox_rect.x1 + 160;
|
||||
textbox_rect.x1 = textbox_rect.x2 + 5;
|
||||
textbox_rect.x2 = textbox_rect.x1 + 160;
|
||||
/* 创建一个textbox控件 */
|
||||
text = rtgui_textbox_create("bernard",RTGUI_TEXTBOX_SINGLE);
|
||||
/* 设置textbox控件的位置 */
|
||||
|
@ -40,7 +43,8 @@ rtgui_view_t* demo_view_textbox(rtgui_workbench_t* workbench)
|
|||
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(text));
|
||||
|
||||
/* 计算下一个label控件的位置 */
|
||||
rect.y1 += 23; rect.y2 = rect.y1 + 20;
|
||||
rect.y1 += 23;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
/* 创建一个label控件 */
|
||||
label = rtgui_label_create("邮件: ");
|
||||
/* 设置label的位置 */
|
||||
|
@ -48,7 +52,8 @@ rtgui_view_t* demo_view_textbox(rtgui_workbench_t* workbench)
|
|||
/* 添加label控件到视图中 */
|
||||
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
|
||||
textbox_rect = rect;
|
||||
textbox_rect.x1 = textbox_rect.x2 + 5; textbox_rect.x2 = textbox_rect.x1 + 160;
|
||||
textbox_rect.x1 = textbox_rect.x2 + 5;
|
||||
textbox_rect.x2 = textbox_rect.x1 + 160;
|
||||
/* 创建一个textbox控件 */
|
||||
text = rtgui_textbox_create("bernard.xiong@gmail.com",RTGUI_TEXTBOX_SINGLE);
|
||||
/* 设置textbox控件的位置 */
|
||||
|
@ -56,7 +61,8 @@ rtgui_view_t* demo_view_textbox(rtgui_workbench_t* workbench)
|
|||
/* 添加textbox控件到视图中 */
|
||||
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(text));
|
||||
|
||||
rect.y1 += 23; rect.y2 = rect.y1 + 20;
|
||||
rect.y1 += 23;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
/* 创建一个label控件 */
|
||||
label = rtgui_label_create("密码: ");
|
||||
/* 设置label的位置 */
|
||||
|
@ -64,7 +70,8 @@ rtgui_view_t* demo_view_textbox(rtgui_workbench_t* workbench)
|
|||
/* 添加label控件到视图中 */
|
||||
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
|
||||
textbox_rect = rect;
|
||||
textbox_rect.x1 = textbox_rect.x2 + 5; textbox_rect.x2 = textbox_rect.x1 + 160;
|
||||
textbox_rect.x1 = textbox_rect.x2 + 5;
|
||||
textbox_rect.x2 = textbox_rect.x1 + 160;
|
||||
/* 创建一个textbox控件 */
|
||||
text = rtgui_textbox_create("rt-thread",RTGUI_TEXTBOX_SINGLE);
|
||||
/* 设置textbox显示文本为掩码形式(即显示为*号,适合于显示密码的情况) */
|
||||
|
@ -74,7 +81,8 @@ rtgui_view_t* demo_view_textbox(rtgui_workbench_t* workbench)
|
|||
/* 添加textbox控件到视图中 */
|
||||
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(text));
|
||||
|
||||
rect.y1 += 23; rect.y2 = rect.y1 + 20;
|
||||
rect.y1 += 23;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
/* 创建一个label控件 */
|
||||
label = rtgui_label_create("主页: ");
|
||||
/* 设置label的位置 */
|
||||
|
@ -82,7 +90,8 @@ rtgui_view_t* demo_view_textbox(rtgui_workbench_t* workbench)
|
|||
/* 添加label控件到视图中 */
|
||||
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
|
||||
textbox_rect = rect;
|
||||
textbox_rect.x1 = textbox_rect.x2 + 5; textbox_rect.x2 = textbox_rect.x1 + 160;
|
||||
textbox_rect.x1 = textbox_rect.x2 + 5;
|
||||
textbox_rect.x2 = textbox_rect.x1 + 160;
|
||||
/* 创建一个textbox控件 */
|
||||
text = rtgui_textbox_create("http://www.rt-thread.org",RTGUI_TEXTBOX_SINGLE);
|
||||
/* 设置textbox控件的位置 */
|
||||
|
|
|
@ -11,6 +11,7 @@ static struct rtgui_win* msgbox = RT_NULL;
|
|||
static rt_uint8_t label_text[80];
|
||||
static rt_uint8_t cnt = 5;
|
||||
|
||||
/* 获取一个递增的窗口标题 */
|
||||
static char* get_win_title()
|
||||
{
|
||||
static rt_uint8_t win_no = 0;
|
||||
|
@ -20,6 +21,7 @@ static char* get_win_title()
|
|||
return win_title;
|
||||
}
|
||||
|
||||
/* 窗口关闭时的事件处理 */
|
||||
void window_demo_close(struct rtgui_widget* widget, rtgui_event_t *even)
|
||||
{
|
||||
rtgui_win_t* win;
|
||||
|
@ -34,61 +36,48 @@ void window_demo_close(struct rtgui_widget* widget, rtgui_event_t *even)
|
|||
/* 关闭对话框时的回调函数 */
|
||||
void diag_close(struct rtgui_timer* timer, void* parameter)
|
||||
{
|
||||
cnt --;
|
||||
sprintf(label_text, "closed then %d second!", cnt);
|
||||
|
||||
/* 设置标签文本并更新控件 */
|
||||
rtgui_label_set_text(label, label_text);
|
||||
rtgui_widget_update(RTGUI_WIDGET(label));
|
||||
|
||||
if (cnt == 0)
|
||||
{
|
||||
/* 超时,关闭对话框 */
|
||||
rtgui_win_destroy(msgbox);
|
||||
|
||||
/* 停止并删除定时器 */
|
||||
rtgui_timer_stop(timer);
|
||||
rtgui_timer_destory(timer);
|
||||
}
|
||||
|
||||
cnt --;
|
||||
}
|
||||
|
||||
void window_demo_autoclose(rtgui_toplevel_t* parent)
|
||||
{
|
||||
struct rtgui_rect rect = {50, 50, 200, 200};
|
||||
|
||||
msgbox = rtgui_win_create(parent, "Information", &rect, RTGUI_WIN_STYLE_DEFAULT);
|
||||
if (msgbox != RT_NULL)
|
||||
{
|
||||
cnt = 5;
|
||||
sprintf(label_text, "closed then %d second!", cnt);
|
||||
label = rtgui_label_create(label_text);
|
||||
rect.x1 += 5; rect.x2 -= 5;
|
||||
rect.y1 += 5; rect.y2 = rect.y1 + 20;
|
||||
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
|
||||
rtgui_container_add_child(RTGUI_CONTAINER(msgbox), RTGUI_WIDGET(label));
|
||||
|
||||
rtgui_win_show(msgbox, RT_FALSE);
|
||||
}
|
||||
|
||||
timer = rtgui_timer_create(100, RT_TIMER_FLAG_PERIODIC, diag_close, RT_NULL);
|
||||
rtgui_timer_start(timer);
|
||||
}
|
||||
|
||||
static rt_uint16_t delta_x = 20;
|
||||
static rt_uint16_t delta_y = 40;
|
||||
|
||||
/* 显示正常窗口 */
|
||||
void window_demo_normal(rtgui_toplevel_t* parent)
|
||||
/* 触发正常窗口显示 */
|
||||
static void demo_win_onbutton(struct rtgui_widget* widget, rtgui_event_t* event)
|
||||
{
|
||||
rtgui_win_t *win;
|
||||
rtgui_label_t *label;
|
||||
rtgui_toplevel_t *parent;
|
||||
rtgui_rect_t rect = {0, 0, 150, 80};
|
||||
|
||||
parent = RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget));
|
||||
rtgui_rect_moveto(&rect, delta_x, delta_y);
|
||||
delta_x += 20; delta_y += 20;
|
||||
delta_x += 20;
|
||||
delta_y += 20;
|
||||
|
||||
/* 创建一个窗口 */
|
||||
win = rtgui_win_create(parent,
|
||||
get_win_title(), &rect, RTGUI_WIN_STYLE_DEFAULT);
|
||||
|
||||
rect.x1 += 20; rect.x2 -= 5;
|
||||
rect.y1 += 5; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 20;
|
||||
rect.x2 -= 5;
|
||||
rect.y1 += 5;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
|
||||
label = rtgui_label_create("这是一个普通窗口");
|
||||
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
|
||||
|
@ -98,21 +87,58 @@ void window_demo_normal(rtgui_toplevel_t* parent)
|
|||
rtgui_win_show(win, RT_FALSE);
|
||||
}
|
||||
|
||||
void window_demo_modal(rtgui_toplevel_t* parent)
|
||||
/* 触发自动窗口显示 */
|
||||
static void demo_autowin_onbutton(struct rtgui_widget* widget, rtgui_event_t* event)
|
||||
{
|
||||
rtgui_toplevel_t *parent;
|
||||
struct rtgui_rect rect =
|
||||
{
|
||||
50, 50, 200, 200
|
||||
};
|
||||
|
||||
parent = RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget));
|
||||
msgbox = rtgui_win_create(parent, "Information", &rect, RTGUI_WIN_STYLE_DEFAULT);
|
||||
if (msgbox != RT_NULL)
|
||||
{
|
||||
cnt = 5;
|
||||
sprintf(label_text, "closed then %d second!", cnt);
|
||||
label = rtgui_label_create(label_text);
|
||||
rect.x1 += 5;
|
||||
rect.x2 -= 5;
|
||||
rect.y1 += 5;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
|
||||
rtgui_container_add_child(RTGUI_CONTAINER(msgbox), RTGUI_WIDGET(label));
|
||||
|
||||
rtgui_win_show(msgbox, RT_FALSE);
|
||||
}
|
||||
|
||||
/* 创建一个定时器 */
|
||||
timer = rtgui_timer_create(100, RT_TIMER_FLAG_PERIODIC, diag_close, RT_NULL);
|
||||
rtgui_timer_start(timer);
|
||||
}
|
||||
|
||||
/* 触发模态窗口显示 */
|
||||
static void demo_modalwin_onbutton(struct rtgui_widget* widget, rtgui_event_t* event)
|
||||
{
|
||||
rtgui_win_t *win;
|
||||
rtgui_label_t *label;
|
||||
rtgui_toplevel_t *parent;
|
||||
rtgui_rect_t rect = {0, 0, 150, 80};
|
||||
|
||||
parent = RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget));
|
||||
rtgui_rect_moveto(&rect, delta_x, delta_y);
|
||||
delta_x += 20; delta_y += 20;
|
||||
delta_x += 20;
|
||||
delta_y += 20;
|
||||
|
||||
/* 创建一个窗口 */
|
||||
win = rtgui_win_create(parent,
|
||||
get_win_title(), &rect, RTGUI_WIN_STYLE_DEFAULT);
|
||||
|
||||
rect.x1 += 20; rect.x2 -= 5;
|
||||
rect.y1 += 5; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 20;
|
||||
rect.x2 -= 5;
|
||||
rect.y1 += 5;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
|
||||
label = rtgui_label_create("这是一个模式窗口");
|
||||
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
|
||||
|
@ -124,17 +150,21 @@ void window_demo_modal(rtgui_toplevel_t* parent)
|
|||
rtgui_win_destroy(win);
|
||||
}
|
||||
|
||||
void window_demo_notitle(rtgui_toplevel_t* parent)
|
||||
/* 触发无标题窗口显示 */
|
||||
static void demo_ntitlewin_onbutton(struct rtgui_widget* widget, rtgui_event_t* event)
|
||||
{
|
||||
rtgui_win_t *win;
|
||||
rtgui_label_t *label;
|
||||
rtgui_button_t *button;
|
||||
rtgui_toplevel_t *parent;
|
||||
rtgui_rect_t widget_rect, rect = {0, 0, 150, 80};
|
||||
|
||||
parent = RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget));
|
||||
rtgui_rect_moveto(&rect, delta_x, delta_y);
|
||||
delta_x += 20; delta_y += 20;
|
||||
delta_x += 20;
|
||||
delta_y += 20;
|
||||
|
||||
/* 创建一个窗口 */
|
||||
/* 创建一个窗口,风格为无标题及无边框 */
|
||||
win = rtgui_win_create(parent,
|
||||
"no title", &rect, RTGUI_WIN_STYLE_NO_TITLE | RTGUI_WIN_STYLE_NO_BORDER);
|
||||
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(win)) = white;
|
||||
|
@ -143,16 +173,20 @@ void window_demo_notitle(rtgui_toplevel_t* parent)
|
|||
label = rtgui_label_create("无边框窗口");
|
||||
rtgui_font_get_metrics(RTGUI_WIDGET_FONT(RTGUI_WIDGET(label)), "无边框窗口", &widget_rect);
|
||||
rtgui_rect_moveto_align(&rect, &widget_rect, RTGUI_ALIGN_CENTER_HORIZONTAL);
|
||||
widget_rect.y1 += 20; widget_rect.y2 += 20;
|
||||
widget_rect.y1 += 20;
|
||||
widget_rect.y2 += 20;
|
||||
rtgui_widget_set_rect(RTGUI_WIDGET(label), &widget_rect);
|
||||
rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(label));
|
||||
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(label)) = white;
|
||||
|
||||
/* 创建一个关闭按钮 */
|
||||
widget_rect.x1 = 0; widget_rect.y1 = 0;
|
||||
widget_rect.x2 = 40; widget_rect.y2 = 20;
|
||||
widget_rect.x1 = 0;
|
||||
widget_rect.y1 = 0;
|
||||
widget_rect.x2 = 40;
|
||||
widget_rect.y2 = 20;
|
||||
rtgui_rect_moveto_align(&rect, &widget_rect, RTGUI_ALIGN_CENTER_HORIZONTAL);
|
||||
widget_rect.y1 += 40; widget_rect.y2 += 40;
|
||||
widget_rect.y1 += 40;
|
||||
widget_rect.y2 += 40;
|
||||
button = rtgui_button_create("关闭");
|
||||
rtgui_widget_set_rect(RTGUI_WIDGET(button), &widget_rect);
|
||||
rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(button));
|
||||
|
@ -162,64 +196,61 @@ void window_demo_notitle(rtgui_toplevel_t* parent)
|
|||
rtgui_win_show(win, RT_FALSE);
|
||||
}
|
||||
|
||||
static void demo_win_onbutton(struct rtgui_widget* widget, rtgui_event_t* event)
|
||||
{
|
||||
window_demo_normal(RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget)));
|
||||
}
|
||||
|
||||
static void demo_autowin_onbutton(struct rtgui_widget* widget, rtgui_event_t* event)
|
||||
{
|
||||
window_demo_autoclose(RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget)));
|
||||
}
|
||||
|
||||
static void demo_modalwin_onbutton(struct rtgui_widget* widget, rtgui_event_t* event)
|
||||
{
|
||||
window_demo_modal(RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget)));
|
||||
}
|
||||
|
||||
static void demo_ntitlewin_onbutton(struct rtgui_widget* widget, rtgui_event_t* event)
|
||||
{
|
||||
window_demo_notitle(RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget)));
|
||||
}
|
||||
|
||||
rtgui_view_t* demo_view_window(rtgui_workbench_t* workbench)
|
||||
{
|
||||
rtgui_rect_t rect;
|
||||
rtgui_view_t* view;
|
||||
rtgui_button_t *button;
|
||||
|
||||
/* 创建一个演示用的视图 */
|
||||
view = demo_view(workbench, "Window Demo");
|
||||
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 5;
|
||||
rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
/* 创建按钮用于显示正常窗口 */
|
||||
button = rtgui_button_create("Normal Win");
|
||||
rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
|
||||
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(button));
|
||||
/* 设置onbutton为demo_win_onbutton函数 */
|
||||
rtgui_button_set_onbutton(button, demo_win_onbutton);
|
||||
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5 + 25; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 5;
|
||||
rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5 + 25;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
/* 创建按钮用于显示一个自动关闭的窗口 */
|
||||
button = rtgui_button_create("Auto Win");
|
||||
rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
|
||||
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(button));
|
||||
/* 设置onbutton为demo_autowin_onbutton函数 */
|
||||
rtgui_button_set_onbutton(button, demo_autowin_onbutton);
|
||||
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5 + 25 + 25; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 5;
|
||||
rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5 + 25 + 25;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
/* 创建按钮用于触发一个模式窗口 */
|
||||
button = rtgui_button_create("Modal Win");
|
||||
rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
|
||||
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(button));
|
||||
/* 设置onbutton为demo_modalwin_onbutton函数 */
|
||||
rtgui_button_set_onbutton(button, demo_modalwin_onbutton);
|
||||
|
||||
demo_view_get_rect(view, &rect);
|
||||
rect.x1 += 5; rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5 + 25 + 25 + 25; rect.y2 = rect.y1 + 20;
|
||||
rect.x1 += 5;
|
||||
rect.x2 = rect.x1 + 100;
|
||||
rect.y1 += 5 + 25 + 25 + 25;
|
||||
rect.y2 = rect.y1 + 20;
|
||||
/* 创建按钮用于触发一个不包含标题的窗口 */
|
||||
button = rtgui_button_create("NoTitle Win");
|
||||
rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
|
||||
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(button));
|
||||
/* 设置onbutton为demo_ntitlewin_onbutton函数 */
|
||||
rtgui_button_set_onbutton(button, demo_ntitlewin_onbutton);
|
||||
|
||||
return view;
|
||||
|
|
|
@ -19,7 +19,8 @@ static void rtgui_mywidget_ondraw(struct rtgui_mywidget* me)
|
|||
rtgui_dc_fill_rect(dc, &rect);
|
||||
|
||||
/* 计算中心原点 */
|
||||
x = (rect.x2 + rect.x1)/2; y = (rect.y2 + rect.y1)/2;
|
||||
x = (rect.x2 + rect.x1)/2;
|
||||
y = (rect.y2 + rect.y1)/2;
|
||||
|
||||
/* 绘制十字架 */
|
||||
rtgui_dc_set_color(dc, black);
|
||||
|
@ -53,7 +54,8 @@ static void rtgui_mywidget_onmouse(struct rtgui_mywidget* me, struct rtgui_event
|
|||
rtgui_widget_rect_to_device(RTGUI_WIDGET(me), &rect);
|
||||
|
||||
/* 计算中心原点 */
|
||||
x = (rect.x2 + rect.x1)/2; y = (rect.y2 + rect.y1)/2;
|
||||
x = (rect.x2 + rect.x1)/2;
|
||||
y = (rect.y2 + rect.y1)/2;
|
||||
|
||||
/* 比较鼠标坐标是否在圈内 */
|
||||
if ((mouse->x < x + 5 && mouse->x > x - 5) &&
|
||||
|
|
Loading…
Reference in New Issue