From 8e5f4287777d2dc1aad05e0db908ffaff22bec9d Mon Sep 17 00:00:00 2001 From: "iamyhw@gmail.com" Date: Sat, 7 May 2011 10:17:01 +0000 Subject: [PATCH] add example: RTTAB git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1398 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- examples/rtgui_win/SConscript | 8 ++ examples/rtgui_win/demo_gui_main.c | 2 +- examples/rtgui_win/demo_gui_rttab.c | 120 ++++++++++++++++++++++++++++ examples/rtgui_win/demo_view.h | 1 + 4 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 examples/rtgui_win/demo_gui_rttab.c diff --git a/examples/rtgui_win/SConscript b/examples/rtgui_win/SConscript index ec3a831a31..f06a8bcb2c 100644 --- a/examples/rtgui_win/SConscript +++ b/examples/rtgui_win/SConscript @@ -4,8 +4,10 @@ Import('projects') src = Split(""" gui_init.c demo_gui_main.c +demo_gui_benchmark.c demo_gui_button.c demo_gui_dc_buffer.c +demo_gui_buffer_animation.c demo_gui_label.c demo_gui_radiobox.c demo_gui_window.c @@ -15,6 +17,12 @@ demo_gui_scrollbar.c demo_gui_textbox.c demo_gui_listbox.c demo_gui_combobox.c +demo_gui_menu.c +demo_gui_listctrl.c +demo_gui_slider.c +demo_gui_image.c +demo_gui_fnview.c +demo_gui_rttab.c """) group = {} diff --git a/examples/rtgui_win/demo_gui_main.c b/examples/rtgui_win/demo_gui_main.c index 3ef1438e60..a83fab342d 100644 --- a/examples/rtgui_win/demo_gui_main.c +++ b/examples/rtgui_win/demo_gui_main.c @@ -144,7 +144,7 @@ static void rtgui_panel_entry(void* parameter) #if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) demo_gui_fnview(view); #endif - + demo_gui_rttab(view); rtgui_view_show(demo_list[demo_current]); //}}} END ADD CODE. diff --git a/examples/rtgui_win/demo_gui_rttab.c b/examples/rtgui_win/demo_gui_rttab.c new file mode 100644 index 0000000000..2b6c089fae --- /dev/null +++ b/examples/rtgui_win/demo_gui_rttab.c @@ -0,0 +1,120 @@ +/* + * 程序清单:rttab控件演示 + * + * 这个例子会在创建出的view上显示一个rttab控件 + */ +#include "demo_view.h" +#include +#include +#include +#include + +const unsigned char image_tool[] = { +'H', 'D', 'C', 0x00, +0x10, 0x00, 0x10, 0x00, +0x10, 0x00, 0x10, 0x00, +0x00, 0x00, 0x10, 0x00, +0x00, 0x00, 0x10, 0x00, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x04, +0x00, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x18, 0xC6, +0x00, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x04, +0x00, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x04, +0x18, 0xC6, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x04, +0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, +0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, +0x00, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0x00, 0x04, 0x00, 0x04, 0x10, 0x04, 0x10, 0x04, +0x10, 0x04, 0x10, 0x04, 0x00, 0x04, 0x00, 0x04, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0x00, 0x04, 0x10, 0x04, 0xF3, 0x4C, 0xFF, 0x07, +0xFF, 0x07, 0xF3, 0x4C, 0x10, 0x04, 0x00, 0x04, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x04, 0x00, 0x04, +0x00, 0x04, 0x10, 0x04, 0xFF, 0x07, 0xFF, 0x07, +0xFF, 0x07, 0xFF, 0x07, 0x10, 0x04, 0x00, 0x04, +0x00, 0x04, 0x00, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x04, 0x00, 0x04, +0x00, 0x04, 0x10, 0x04, 0xFF, 0x07, 0xFF, 0x07, +0xFF, 0x07, 0xFF, 0x07, 0x10, 0x04, 0x00, 0x04, +0x00, 0x04, 0x00, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0x00, 0x04, 0x10, 0x04, 0xF3, 0x4C, 0xFF, 0x07, +0xFF, 0x07, 0xF3, 0x4C, 0x10, 0x04, 0x00, 0x04, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +0xFF, 0xFF, 0xF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F, 0xFF, 0xFF, +0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +}; + +/* 创建用于演示rttab控件的视图 */ +rtgui_view_t* demo_gui_rttab(rtgui_view_t* parent_view) +{ + rtgui_view_t* view; + rtgui_image_t* image; + rtgui_rttab_t* tab; + rtgui_container_t* box; + + /* 先创建一个演示用的视图 */ + view = demo_view_create(parent_view, "RTTAB View"); + image = rtgui_image_create_from_mem("hdc",image_tool,sizeof(image_tool),RT_TRUE); + /* 创建一个rttab控件 */ + tab = rtgui_rttab_create(view, "TAB", 10, 40, 210, 160); + /* 添加标签页 */ + rtgui_rttab_add_tag(tab, "Editor", image); + box = rtgui_rttab_get_container_by_index(tab, 0); + rtgui_label_create(box, "label1",5,5,100,20); + + rtgui_rttab_add_tag(tab, "Other", RT_NULL); + box = rtgui_rttab_get_container_by_title(tab, "Other"); + rtgui_label_create(box, "label3",5,5,100,20); + + rtgui_rttab_add_tag(tab, "TAG1", image); + box = rtgui_rttab_get_container_by_title(tab, "TAG1"); + rtgui_button_create(box, "button",5,5,80,25); + + rtgui_rttab_add_tag(tab, "TAG2", RT_NULL); + rtgui_rttab_add_tag(tab, "TAG3", RT_NULL); + rtgui_rttab_add_tag(tab, "TAG4", RT_NULL); + rtgui_rttab_add_tag(tab, "TAG5", RT_NULL); + rtgui_rttab_add_tag(tab, "TAG6", RT_NULL); + rtgui_rttab_add_tag(tab, "TAG7", RT_NULL); + rtgui_rttab_add_tag(tab, "TAG8", RT_NULL); + + return view; +} + diff --git a/examples/rtgui_win/demo_view.h b/examples/rtgui_win/demo_view.h index abcd48fb05..acfac4b6e7 100644 --- a/examples/rtgui_win/demo_view.h +++ b/examples/rtgui_win/demo_view.h @@ -25,6 +25,7 @@ rtgui_view_t* demo_gui_combobox(rtgui_view_t* parent_view); rtgui_view_t* demo_gui_slider(rtgui_view_t* parent_view); rtgui_view_t* demo_gui_image(rtgui_view_t* parent_view); rtgui_view_t* demo_gui_fnview(rtgui_view_t* parent_view); +rtgui_view_t* demo_gui_rttab(rtgui_view_t* parent_view); #endif