summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorbernard.xiong <[email protected]>2010-01-25 23:40:18 +0000
committerbernard.xiong <[email protected]>2010-01-25 23:40:18 +0000
commit43082e9e546b054362651d0b13445a500e677c8b (patch)
tree1ad9455017bded0693744411af4ae1c4faa5ed54 /examples
parent0c817b1d16c2edb745704955005e71448caded5e (diff)
update window demo.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@338 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'examples')
-rw-r--r--examples/gui/demo_view_window.c112
1 files changed, 103 insertions, 9 deletions
diff --git a/examples/gui/demo_view_window.c b/examples/gui/demo_view_window.c
index 9786198717..a14d42abd5 100644
--- a/examples/gui/demo_view_window.c
+++ b/examples/gui/demo_view_window.c
@@ -11,6 +11,18 @@ static struct rtgui_win* msgbox = RT_NULL;
static rt_uint8_t label_text[80];
static int cnt = 5;
+void window_demo_close(struct rtgui_widget* widget, rtgui_event_t *even)
+{
+ rtgui_win_t* win;
+
+ /* ������ؼ� */
+ win = RTGUI_WIN(rtgui_widget_get_toplevel(widget));
+
+ /* ���ٴ��� */
+ rtgui_win_destroy(win);
+}
+
+/* �رնԻ���ʱ�Ļص����� */
void diag_close(struct rtgui_timer* timer, void* parameter)
{
sprintf(label_text, "closed then %d second!", cnt);
@@ -27,11 +39,12 @@ void diag_close(struct rtgui_timer* timer, void* parameter)
cnt --;
}
-void window_demo()
+void window_demo_autoclose(rtgui_toplevel_t* parent)
{
+#if 0
struct rtgui_rect rect = {50, 50, 200, 200};
- msgbox = rtgui_win_create(RT_NULL, "Information", &rect, RTGUI_WIN_STYLE_DEFAULT);
+ msgbox = rtgui_win_create(parent, "Information", &rect, RTGUI_WIN_STYLE_DEFAULT);
if (msgbox != RT_NULL)
{
struct rtgui_box* box = rtgui_box_create(RTGUI_VERTICAL, RT_NULL);
@@ -52,32 +65,113 @@ void window_demo()
timer = rtgui_timer_create(200, RT_TIMER_FLAG_PERIODIC, diag_close, RT_NULL);
rtgui_timer_start(timer);
+#endif
}
-#ifdef RT_USING_FINSH
-#include <finsh.h>
-void win_demo()
+static rt_uint16_t delta_x = 20;
+static rt_uint16_t delta_y = 40;
+
+/* ��ʾ�������� */
+void window_demo_normal(rtgui_toplevel_t* parent)
{
- window_demo();
+ rtgui_win_t *win;
+ rtgui_label_t *label;
+ rtgui_rect_t rect = {0, 0, 150, 80};
+
+ rtgui_rect_moveto(&rect, delta_x, delta_y);
+ delta_x += 20; delta_y += 20;
+
+ /* ����һ������ */
+ win = rtgui_win_create(parent,
+ "����", &rect, RTGUI_WIN_STYLE_DEFAULT);
+
+ rect.x1 += 20; rect.x2 -= 5;
+ rect.y1 += 5; rect.y2 = rect.y1 + 20;
+
+ label = rtgui_label_create("����һ����ͨ����");
+ rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
+ rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(label));
+
+ /* ��ģ̬��ʾ���� */
+ rtgui_win_show(win, RT_FALSE);
+}
+
+void window_demo_modal(rtgui_toplevel_t* parent)
+{
+ rtgui_win_t *win;
+ rtgui_label_t *label;
+ rtgui_rect_t rect = {0, 0, 150, 80};
+
+ rtgui_rect_moveto(&rect, delta_x, delta_y);
+ delta_x += 20; delta_y += 20;
+
+ /* ����һ������ */
+ win = rtgui_win_create(parent,
+ "ģʽ����", &rect, RTGUI_WIN_STYLE_DEFAULT);
+
+ rect.x1 += 20; rect.x2 -= 5;
+ rect.y1 += 5; rect.y2 = rect.y1 + 20;
+
+ label = rtgui_label_create("����һ��ģʽ����");
+ rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
+ rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(label));
+
+ /* ģ̬��ʾ���� */
+ rtgui_win_show(win, RT_TRUE);
+}
+
+void window_demo_notitle(rtgui_toplevel_t* parent)
+{
+ rtgui_win_t *win;
+ rtgui_label_t *label;
+ rtgui_button_t *button;
+ rtgui_rect_t rect = {0, 0, 150, 80};
+
+ rtgui_rect_moveto(&rect, delta_x, delta_y);
+ delta_x += 20; delta_y += 20;
+
+ /* ����һ������ */
+ win = rtgui_win_create(parent,
+ "no title", &rect, RTGUI_WIN_STYLE_NO_TITLE | RTGUI_WIN_STYLE_NO_BORDER);
+ RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(win)) = white;
+
+ /* ����һ���ı���ǩ */
+ rect.x1 += 20; rect.x2 -= 5;
+ rect.y1 += 5; rect.y2 = rect.y1 + 20;
+ label = rtgui_label_create("�ޱ߿򴰿�");
+ rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
+ rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(label));
+
+ /* ����һ���رհ�ť */
+ rect.x1 += 20; rect.x2 = rect.x1 + 40;
+ rect.y1 += 35; rect.y2 = rect.y1 + 20;
+ button = rtgui_button_create("�ر�");
+ rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
+ rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(button));
+ rtgui_button_set_onbutton(button, window_demo_close);
+
+ /* ��ģ̬��ʾ���� */
+ rtgui_win_show(win, RT_FALSE);
}
-FINSH_FUNCTION_EXPORT(win_demo, a window demo)
-#endif
static void demo_win_onbutton(struct rtgui_widget* widget, rtgui_event_t* event)
{
- window_demo();
+ window_demo_normal(RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget)));
}
static void demo_autowin_onbutton(struct rtgui_widget* widget, rtgui_event_t* event)
{
+ // window_demo_autoclose(RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget)));
}
static void demo_modalwin_onbutton(struct rtgui_widget* widget, rtgui_event_t* event)
{
+ window_demo_modal(RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget)));
}
static void demo_ntitlewin_onbutton(struct rtgui_widget* widget, rtgui_event_t* event)
{
+ window_demo_notitle(RTGUI_TOPLEVEL(rtgui_widget_get_toplevel(widget)));
}
rtgui_view_t* demo_view_window(rtgui_workbench_t* workbench)