2012-04-18 23:06:12 +08:00
|
|
|
|
/*
|
|
|
|
|
* A simple workbench
|
|
|
|
|
*/
|
|
|
|
|
#include <rtthread.h>
|
|
|
|
|
#include <rtgui/rtgui_server.h>
|
|
|
|
|
#include <rtgui/rtgui_system.h>
|
|
|
|
|
#include <rtgui/widgets/label.h>
|
|
|
|
|
#include <rtgui/widgets/workbench.h>
|
|
|
|
|
|
|
|
|
|
static void workbench_entry(void* parameter)
|
|
|
|
|
{
|
|
|
|
|
rt_mq_t mq;
|
|
|
|
|
rtgui_container_t* view;
|
|
|
|
|
rtgui_label_t* label;
|
|
|
|
|
struct rtgui_workbench* workbench;
|
|
|
|
|
rtgui_rect_t rect;
|
|
|
|
|
|
|
|
|
|
mq = rt_mq_create("wmq", 256, 8, RT_IPC_FLAG_FIFO);
|
|
|
|
|
/* ע<>ᵱǰ<E1B5B1>߳<EFBFBD>ΪGUI<55>߳<EFBFBD> */
|
|
|
|
|
rtgui_thread_register(rt_thread_self(), mq);
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨ */
|
|
|
|
|
workbench = rtgui_workbench_create("main", "workbench #1");
|
|
|
|
|
if (workbench == RT_NULL) return;
|
|
|
|
|
|
|
|
|
|
view = rtgui_container_create("view");
|
|
|
|
|
if (view == RT_NULL) return;
|
|
|
|
|
/* ָ<><D6B8><EFBFBD><EFBFBD>ͼ<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ɫ */
|
|
|
|
|
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = white;
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>label */
|
|
|
|
|
label = rtgui_label_create("<EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>RT-Thread<61><64>");
|
|
|
|
|
rect.x1 = 10; rect.y1 = 10;
|
|
|
|
|
rect.x2 = 210; rect.y2 = 30;
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD>label<65><6C>λ<EFBFBD><CEBB> */
|
|
|
|
|
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
|
|
|
|
|
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD>workbench<63><68> */
|
|
|
|
|
rtgui_workbench_add_view(workbench, view);
|
|
|
|
|
/* <20><>ģʽ<C4A3><CABD>ʽ<EFBFBD><CABD>ʾ<EFBFBD><CABE>ͼ */
|
|
|
|
|
rtgui_container_show(view, RT_FALSE);
|
|
|
|
|
|
|
|
|
|
/* ִ<>й<EFBFBD><D0B9><EFBFBD>̨<EFBFBD>¼<EFBFBD>ѭ<EFBFBD><D1AD> */
|
|
|
|
|
rtgui_workbench_event_loop(workbench);
|
|
|
|
|
|
|
|
|
|
/* ȥע<C8A5><D7A2>GUI<55>߳<EFBFBD> */
|
|
|
|
|
rtgui_thread_deregister(rt_thread_self());
|
|
|
|
|
|
|
|
|
|
/* delete message queue */
|
|
|
|
|
rt_mq_delete(mq);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <20><>ʼ<EFBFBD><CABC>workbench */
|
|
|
|
|
void wb_init()
|
|
|
|
|
{
|
|
|
|
|
rt_thread_t tid;
|
|
|
|
|
|
|
|
|
|
tid = rt_thread_create("wb1", workbench_entry, RT_NULL, 2048, 20, 5);
|
|
|
|
|
if (tid != RT_NULL) rt_thread_startup(tid);
|
|
|
|
|
}
|