diff options
| author | [email protected] <[email protected]> | 2010-12-07 00:05:14 +0000 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2010-12-07 00:05:14 +0000 |
| commit | ffbda314107391c4ef3bcf1a2b8906b99f7d7651 (patch) | |
| tree | 65cd152a2358bf41399a75130ceb85c9abd677b6 | |
| parent | 5c21c6b45dbb8e4fc91fbaff08e49123a05963d1 (diff) | |
add combobox example.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1181 bbd45198-f89e-11dd-88c7-29a3b14d5316
| -rw-r--r-- | examples/gui/demo_view_combobox.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/examples/gui/demo_view_combobox.c b/examples/gui/demo_view_combobox.c new file mode 100644 index 0000000000..d1251035ef --- /dev/null +++ b/examples/gui/demo_view_combobox.c @@ -0,0 +1,40 @@ +/*
+ * 程序清单:label控件演示
+ *
+ * 这个例子会在创建出的view上添加几个不同类型的label控件
+ */
+#include "demo_view.h"
+#include <rtgui/widgets/combobox.h>
+
+struct rtgui_combobox_item items[] =
+{
+ {"item 1", RT_NULL},
+ {"item 2", RT_NULL},
+ {"item 3", RT_NULL},
+ {"item 4", RT_NULL},
+ {"item 5", RT_NULL},
+};
+
+/* 创建用于演示combobox控件的视图 */
+rtgui_view_t* demo_view_combobox(rtgui_workbench_t* workbench)
+{
+ rtgui_rect_t rect;
+ rtgui_view_t* view;
+ rtgui_combobox_t* box;
+
+ /* 先创建一个演示用的视图 */
+ view = demo_view(workbench, "ComboBox View");
+
+ /* 获得视图的位置信息 */
+ demo_view_get_rect(view, &rect);
+ rect.x1 += 5;
+ rect.x2 -= 5;
+ rect.y1 += 5;
+ rect.y2 = rect.y1 + 20;
+ /* 创建一个label控件 */
+ box = rtgui_combobox_create(items, sizeof(items)/sizeof(items[0]), &rect);
+ /* view是一个container控件,调用add_child方法添加这个box控件 */
+ rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(box));
+
+ return view;
+}
|
