mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-28 08:37:57 +08:00
update RT-Thread/GUI examples.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@711 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
1 parent
3f319a875c
commit
37e3e9886a
8 files changed
+364
-18
No files matched your search
@@ -35,7 +35,7 @@ static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event)
|
||||
char path[32];
|
||||
|
||||
/* 在文件列表视图中成功选择文件,这里获得相应的路径名 */
|
||||
rtgui_filelist_get_fullpath(view, path, sizeof(path));
|
||||
rtgui_filelist_view_get_fullpath(view, path, sizeof(path));
|
||||
|
||||
/* 设置文件路径到文本标签 */
|
||||
rtgui_label_set_text(label, path);
|
||||
|
||||
@@ -48,12 +48,7 @@ static void listitem_action(void* parameter)
|
||||
/* 返回功能的动作函数 */
|
||||
static void return_action(void* parameter)
|
||||
{
|
||||
if (_view != RT_NULL)
|
||||
{
|
||||
/* 删除列表视图 */
|
||||
rtgui_view_destroy(RTGUI_VIEW(_view));
|
||||
_view = RT_NULL;
|
||||
}
|
||||
rtgui_view_end_modal(RTGUI_VIEW(_view), RTGUI_MODAL_OK);
|
||||
}
|
||||
|
||||
/* 各个列表项定义 */
|
||||
@@ -78,12 +73,14 @@ static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event)
|
||||
|
||||
/* 创建一个列表视图, 项指定为items */
|
||||
_view = rtgui_list_view_create(items, sizeof(items)/sizeof(struct rtgui_list_item),
|
||||
&rect);
|
||||
&rect, RTGUI_LIST_VIEW_LIST);
|
||||
/* 在workbench中添加相应的视图 */
|
||||
rtgui_workbench_add_view(workbench, RTGUI_VIEW(_view));
|
||||
|
||||
/* 模式显示视图 */
|
||||
rtgui_view_show(RTGUI_VIEW(_view), RT_FALSE);
|
||||
rtgui_view_show(RTGUI_VIEW(_view), RT_TRUE);
|
||||
rtgui_view_destroy(RTGUI_VIEW(_view));
|
||||
_view = RT_NULL;
|
||||
}
|
||||
|
||||
/* 创建用于演示列表视图的视图 */
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -95,11 +95,11 @@ rtgui_view_t *demo_view_buffer_animation(rtgui_workbench_t* workbench)
|
||||
{
|
||||
rtgui_view_t *view;
|
||||
|
||||
view = demo_view(workbench, "DC 动画");
|
||||
view = demo_view(workbench, "DC 缓冲区动画");
|
||||
if (view != RT_NULL)
|
||||
rtgui_widget_set_event_handler(RTGUI_WIDGET(view), animation_event_handler);
|
||||
|
||||
rtgui_font_get_metrics(RTGUI_WIDGET_FONT(RTGUI_WIDGET(view)), "飞线乱飞", &text_rect);
|
||||
rtgui_font_get_metrics(RTGUI_WIDGET_FONT(RTGUI_WIDGET(view)), "缓冲动画", &text_rect);
|
||||
if (dc_buffer == RT_NULL)
|
||||
{
|
||||
rtgui_rect_t rect;
|
||||
@@ -113,7 +113,7 @@ rtgui_view_t *demo_view_buffer_animation(rtgui_workbench_t* workbench)
|
||||
rtgui_dc_fill_rect(dc_buffer, &rect);
|
||||
RTGUI_DC_FC(dc_buffer) = black;
|
||||
rect.x1 = 1; rect.y1 = 1;
|
||||
rtgui_dc_draw_text(dc_buffer, "飞线乱飞", &rect);
|
||||
rtgui_dc_draw_text(dc_buffer, "缓冲动画", &rect);
|
||||
}
|
||||
|
||||
/* 启动定时器以触发动画 */
|
||||
|
||||
@@ -69,6 +69,7 @@ rtgui_view_t *demo_view_dc_buffer(rtgui_workbench_t* workbench)
|
||||
dc_buffer = rtgui_dc_buffer_create(50, 50);
|
||||
RTGUI_DC_FC(dc_buffer) = blue;
|
||||
rtgui_dc_fill_rect(dc_buffer, &rect);
|
||||
|
||||
RTGUI_DC_FC(dc_buffer) = red;
|
||||
rtgui_dc_draw_circle(dc_buffer, 25, 25, 10);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event)
|
||||
char path[32], image_type[8];
|
||||
|
||||
/* 设置文件路径的标签 */
|
||||
rtgui_filelist_get_fullpath(view, path, sizeof(path));
|
||||
rtgui_filelist_view_get_fullpath(view, path, sizeof(path));
|
||||
if (image != RT_NULL) rtgui_image_destroy(image);
|
||||
|
||||
rt_memset(image_type, 0, sizeof(image_type));
|
||||
|
||||
@@ -37,9 +37,9 @@ static void workbench_entry(void* parameter)
|
||||
|
||||
/* 创建GUI应用需要的消息队列 */
|
||||
#ifdef RTGUI_USING_SMALL_SIZE
|
||||
mq = rt_mq_create("workbench", 32, 8, RT_IPC_FLAG_FIFO);
|
||||
mq = rt_mq_create("workbench", 32, 32, RT_IPC_FLAG_FIFO);
|
||||
#else
|
||||
mq = rt_mq_create("workbench", 256, 8, RT_IPC_FLAG_FIFO);
|
||||
mq = rt_mq_create("workbench", 256, 32, RT_IPC_FLAG_FIFO);
|
||||
#endif
|
||||
/* 注册当前线程为GUI线程 */
|
||||
rtgui_thread_register(rt_thread_self(), mq);
|
||||
@@ -67,6 +67,7 @@ static void workbench_entry(void* parameter)
|
||||
demo_view_mywidget(workbench);
|
||||
demo_view_image(workbench);
|
||||
demo_listview_view(workbench);
|
||||
demo_listview_icon_view(workbench);
|
||||
demo_fn_view(workbench);
|
||||
|
||||
/* 显示视图 */
|
||||
|
||||
@@ -23,15 +23,15 @@ static void rtgui_mywidget_ondraw(struct rtgui_mywidget* me)
|
||||
y = (rect.y2 + rect.y1)/2;
|
||||
|
||||
/* 绘制十字架 */
|
||||
RTGUI_DC_BC(dc) = black;
|
||||
RTGUI_DC_FC(dc) = black;
|
||||
rtgui_dc_draw_hline(dc, rect.x1, rect.x2, y);
|
||||
rtgui_dc_draw_vline(dc, x, rect.y1, rect.y2);
|
||||
|
||||
/* 根据状态绘制圆圈 */
|
||||
if (me->status == MYWIDGET_STATUS_ON)
|
||||
RTGUI_DC_BC(dc) = green;
|
||||
RTGUI_DC_FC(dc) = green;
|
||||
else
|
||||
RTGUI_DC_BC(dc) = red;
|
||||
RTGUI_DC_FC(dc) = red;
|
||||
rtgui_dc_fill_circle(dc, x, y, 5);
|
||||
|
||||
/* 结束绘图 */
|
||||
|
||||
Reference in new issue
Block a user