93 lines
2.3 KiB
C
93 lines
2.3 KiB
C
|
/*
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>RTGUI<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>RTGUI<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
#include <rtthread.h>
|
|||
|
#include <rtgui/rtgui.h>
|
|||
|
#include <panel.h>
|
|||
|
#include <rtgui/event.h>
|
|||
|
#include <rtgui/widgets/widget.h>
|
|||
|
#include <rtgui/widgets/button.h>
|
|||
|
#include <rtgui/widgets/textbox.h>
|
|||
|
#include <rtgui/widgets/view.h>
|
|||
|
#include <rtgui/widgets/listbox.h>
|
|||
|
#include <rtgui/rtgui_theme.h>
|
|||
|
|
|||
|
rtgui_listbox_t *__lbox;
|
|||
|
|
|||
|
static rtgui_listbox_item_t _demo_list[] =
|
|||
|
{
|
|||
|
{"item1", RT_NULL},
|
|||
|
{"item2", RT_NULL},
|
|||
|
};
|
|||
|
|
|||
|
/* <20><><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ŀ */
|
|||
|
void user_add_one_item(PVOID wdt, rtgui_event_t *event)
|
|||
|
{
|
|||
|
rtgui_listbox_item_t item={"new item", RT_NULL};
|
|||
|
if(__lbox != RT_NULL)
|
|||
|
{
|
|||
|
__lbox->add_item(__lbox, &item);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static void rtgui_panel_entry(void* parameter)
|
|||
|
{
|
|||
|
const struct rtgui_graphic_driver* gd = rtgui_graphic_driver_get_default();
|
|||
|
struct rt_messagequeue* mq;
|
|||
|
rtgui_panel_t *panel;
|
|||
|
rtgui_view_t *view;
|
|||
|
rtgui_button_t *button;
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD>GUIӦ<49><D3A6><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD> */
|
|||
|
mq = rt_mq_create("Panel", 256, 32, RT_IPC_FLAG_FIFO);
|
|||
|
/* ע<>ᵱǰ<E1B5B1>߳<EFBFBD>ΪGUI<55>߳<EFBFBD> */
|
|||
|
rtgui_thread_register(rt_thread_self(), mq);
|
|||
|
|
|||
|
panel = rtgui_panel_create(0,0,gd->width,gd->height);
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><>Ϣ<EFBFBD><CFA2>
|
|||
|
view = rtgui_view_create(panel,"titlebar",0,0,gd->width,30);
|
|||
|
rtgui_widget_set_style(view, RTGUI_BORDER_SIMPLE);
|
|||
|
rtgui_label_create(view, "hello world!",5,2,150,24);
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>б<EFBFBD>
|
|||
|
__lbox = rtgui_listbox_create(panel,10,30,120,100,RTGUI_BORDER_SUNKEN);
|
|||
|
rtgui_listbox_set_items(__lbox,_demo_list,RT_COUNT(_demo_list));
|
|||
|
button = rtgui_button_create(panel,"add",140,60,50,25);
|
|||
|
rtgui_button_set_onbutton(button,user_add_one_item);
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>༭<EFBFBD><E0BCAD>
|
|||
|
rtgui_textbox_create(panel,
|
|||
|
"this is a textbox,\n"
|
|||
|
"demo multi text.\n",
|
|||
|
10,150,180,50,
|
|||
|
RTGUI_TEXTBOX_MULTI);
|
|||
|
|
|||
|
///////////////////////////////////////////////////////
|
|||
|
rtgui_panel_show(panel);
|
|||
|
|
|||
|
/* ִ<>й<EFBFBD><D0B9><EFBFBD>̨<EFBFBD>¼<EFBFBD>ѭ<EFBFBD><D1AD> */
|
|||
|
rtgui_panel_event_loop(panel);
|
|||
|
|
|||
|
/* ȥע<C8A5><D7A2>GUI<55>߳<EFBFBD> */
|
|||
|
rtgui_thread_deregister(rt_thread_self());
|
|||
|
rt_mq_delete(mq);
|
|||
|
}
|
|||
|
|
|||
|
void rtgui_panel_init(void)
|
|||
|
{
|
|||
|
static rt_bool_t main_inited = RT_FALSE;
|
|||
|
|
|||
|
if(main_inited == RT_FALSE) /* <20><><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD> */
|
|||
|
{
|
|||
|
struct rt_thread* tid;
|
|||
|
|
|||
|
tid = rt_thread_create("Panel", rtgui_panel_entry, RT_NULL, 4096, 4, 5);
|
|||
|
|
|||
|
if(tid != RT_NULL) rt_thread_startup(tid);
|
|||
|
|
|||
|
main_inited = RT_TRUE;
|
|||
|
}
|
|||
|
}
|
|||
|
|