git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1347 bbd45198-f89e-11dd-88c7-29a3b14d5316

This commit is contained in:
iamyhw@gmail.com 2011-03-24 15:47:58 +00:00
parent 0621f30e9d
commit c715ed6d90
3 changed files with 96 additions and 0 deletions

View File

@ -1,5 +1,7 @@
/*
* RTGUI的例子RTGUI程序
* rtgui_win这个分支中toplevel控件panel
* toplevel级别控件
*/
#include <rtthread.h>
#include <rtgui/rtgui.h>
@ -12,6 +14,8 @@
#include <rtgui/widgets/listbox.h>
#include <rtgui/rtgui_theme.h>
void demo_gui_win(PVOID wdt, rtgui_event_t *event);
rtgui_listbox_t *__lbox;
static rtgui_listbox_item_t _demo_list[] =
@ -63,6 +67,9 @@ static void rtgui_panel_entry(void* parameter)
10,150,180,50,
RTGUI_TEXTBOX_MULTI);
button = rtgui_button_create(panel, "win",140,90,50,25);
rtgui_button_set_onbutton(button,demo_gui_win);
///////////////////////////////////////////////////////
rtgui_panel_show(panel);

View File

@ -0,0 +1,86 @@
/*
* 线win
*/
#include <rtthread.h>
#include <rtgui/rtgui.h>
#include <rtgui/event.h>
#include <rtgui/driver.h>
#include <rtgui/widgets/label.h>
#include <rtgui/widgets/button.h>
#include <rtgui/widgets/window.h>
static rt_bool_t demo_win_inited = RT_FALSE;
static rt_bool_t demo_gui_win_event_handler(PVOID wdt, rtgui_event_t* event)
{
if(event->type == RTGUI_EVENT_PAINT)
{
}
/* 其他事件使用win默认的事件处理函数处理 */
return rtgui_win_event_handler(wdt, event);
}
static void gui_win_entry(void* parameter)
{
const struct rtgui_graphic_driver* gd = rtgui_graphic_driver_get_default();
struct rt_messagequeue *mq;
rtgui_win_t *win;
rtgui_button_t *button;
rtgui_point_t p;
rtgui_rect_t rect = {0,0,150,120};
/* 创建GUI应用需要的消息队列 */
mq = rt_mq_create("demo_win", 256, 32, RT_IPC_FLAG_FIFO);
/* 注册当前线程 */
rtgui_thread_register(rt_thread_self(), mq);
/* 窗口居中 */
rtgui_rect_moveto(&rect, (gd->width - rtgui_rect_width(rect))/2, (gd->height - rtgui_rect_height(rect))/2);
/* 创建窗口 */
win = rtgui_win_create(RT_NULL,"demo_win",&rect,RTGUI_WIN_DEFAULT);
if(win == RT_NULL) return;
/* 取得客户区坐标零点 */
p = rtgui_win_get_client_zero(win);
rtgui_label_create(win, "hello world!", p.x+10, p.y+10, 100,25);
button = rtgui_button_create(win, "Exit", 50,80,50,25);
rtgui_button_set_onbutton(button,rtgui_win_close);
rtgui_widget_set_event_handler(win, demo_gui_win_event_handler);
rtgui_win_show(win,RT_FALSE);
/* 执行工作台事件循环 */
rtgui_win_event_loop(win);
demo_win_inited = RT_FALSE;
/* 去注册GUI线程 */
rtgui_thread_deregister(rt_thread_self());
rt_mq_delete(mq);
}
void demo_gui_win(PVOID wdt, rtgui_event_t *event)
{
if(demo_win_inited == RT_FALSE) /* 避免重复初始化而做的保护 */
{
struct rt_thread* tid;
tid = rt_thread_create("demo_win", gui_win_entry, RT_NULL, 1024, 5, 10);
if(tid != RT_NULL) rt_thread_startup(tid);
demo_win_inited = RT_TRUE;
}
}

View File

@ -0,0 +1,3 @@
这个文件夹下的例子对应于rtgui_win分支分支地址是
http://rt-thread.googlecode.com/svn/branches/rtgui_win/
新建个文件夹将SVN update地址设置成上面的地址即可获得rtgui_win分支的代码。