summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
author[email protected] <[email protected]>2010-12-22 23:56:44 +0000
committer[email protected] <[email protected]>2010-12-22 23:56:44 +0000
commitecb7e7d987e323837578516e0e0a14ba94000982 (patch)
tree194fbf6ef85f71790f4b33895042ba9c685f5a60 /examples
parent990d052de1c6eae325b4072723319d5cb3281ce2 (diff)
add notebook example.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1222 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'examples')
-rw-r--r--examples/gui/demo_view_notebook.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/examples/gui/demo_view_notebook.c b/examples/gui/demo_view_notebook.c
new file mode 100644
index 0000000000..f6a016dca8
--- /dev/null
+++ b/examples/gui/demo_view_notebook.c
@@ -0,0 +1,41 @@
+/*
+ * 程序清单:notebook控件演示
+ *
+ * 这个例子会在创建出的view上演示notebook控件
+ */
+
+#include "demo_view.h"
+#include <rtgui/widgets/notebook.h>
+#include <rtgui/widgets/listbox.h>
+
+const static struct rtgui_listbox_item items[] =
+{
+ {"list #0", RT_NULL},
+ {"list #1", RT_NULL},
+ {"list #2", RT_NULL},
+ {"list #3", RT_NULL},
+};
+
+/* 创建用于演示notebook控件的视图 */
+rtgui_view_t* demo_view_notebook(rtgui_workbench_t* workbench)
+{
+ rtgui_rect_t rect;
+ rtgui_view_t* view;
+ rtgui_notebook_t* notebook;
+ rtgui_listbox_t* box;
+
+ /* 先创建一个演示用的视图 */
+ view = demo_view(workbench, "Notebook View");
+
+ /* 获得视图的位置信息 */
+ demo_view_get_rect(view, &rect);
+
+ notebook = rtgui_notebook_create(&rect);
+ /* view是一个container控件,调用add_child方法添加这个notebook控件 */
+ rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(notebook));
+
+ box = rtgui_listbox_create(items, sizeof(items)/sizeof(struct rtgui_listbox_item), &rect);
+ rtgui_notebook_add(notebook, "Tab 1", RTGUI_WIDGET(box));
+
+ return view;
+}