summaryrefslogtreecommitdiff
path: root/examples/gui
diff options
context:
space:
mode:
authorbernard.xiong <[email protected]>2010-02-04 00:07:08 +0000
committerbernard.xiong <[email protected]>2010-02-04 00:07:08 +0000
commitc05af1b737a0f994deffe2b0b87d47807d67c13e (patch)
tree41585bb6bb2c91bf1899ce01cf843d2c2a5d69bd /examples/gui
parent12961c68dacfc041686e72c1e054cb1edafdbe49 (diff)
update dc and window demo.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@370 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'examples/gui')
-rw-r--r--examples/gui/demo_view_dc.c7
-rw-r--r--examples/gui/demo_view_window.c28
2 files changed, 23 insertions, 12 deletions
diff --git a/examples/gui/demo_view_dc.c b/examples/gui/demo_view_dc.c
index 8a5f54b5b1..775038fdf6 100644
--- a/examples/gui/demo_view_dc.c
+++ b/examples/gui/demo_view_dc.c
@@ -49,6 +49,13 @@ rt_bool_t dc_event_handler(rtgui_widget_t* widget, rtgui_event_t *event)
/* ���demo view������ͼ������ */
demo_view_get_rect(RTGUI_VIEW(widget), &rect);
+ rtgui_dc_set_textalign(dc, RTGUI_ALIGN_BOTTOM | RTGUI_ALIGN_CENTER_HORIZONTAL);
+#ifdef RTGUI_USING_SMALL_SIZE
+ rtgui_dc_draw_text(dc, "RT-Thread/GUIС�Ͱ汾", &rect);
+#else
+ rtgui_dc_draw_text(dc, "RT-Thread/GUI��׼�汾", &rect);
+#endif
+
/* ����һ��Բ�� */
rtgui_dc_set_color(dc, red);
rtgui_dc_draw_circle(dc, rect.x1 + 10, rect.y1 + 10, 10);
diff --git a/examples/gui/demo_view_window.c b/examples/gui/demo_view_window.c
index 96b1613fb6..b04a37db08 100644
--- a/examples/gui/demo_view_window.c
+++ b/examples/gui/demo_view_window.c
@@ -9,7 +9,16 @@ static struct rtgui_timer *timer;
static struct rtgui_label* label;
static struct rtgui_win* msgbox = RT_NULL;
static rt_uint8_t label_text[80];
-static int cnt = 5;
+static rt_uint8_t cnt = 5;
+
+static char* get_win_title()
+{
+ static rt_uint8_t win_no = 0;
+ static char win_title[16];
+
+ rt_sprintf(win_title, "���� %d", ++win_no);
+ return win_title;
+}
void window_demo_close(struct rtgui_widget* widget, rtgui_event_t *even)
{
@@ -46,18 +55,13 @@ void window_demo_autoclose(rtgui_toplevel_t* parent)
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);
-
cnt = 5;
sprintf(label_text, "closed then %d second!", cnt);
label = rtgui_label_create(label_text);
-
- rtgui_win_set_box(msgbox, box);
- RTGUI_WIDGET(label)->align = RTGUI_ALIGN_CENTER_HORIZONTAL |
- RTGUI_ALIGN_CENTER_VERTICAL;
- rtgui_widget_set_miniwidth(RTGUI_WIDGET(label),130);
- rtgui_box_append(box, RTGUI_WIDGET(label));
- rtgui_box_layout(box);
+ rect.x1 += 5; rect.x2 -= 5;
+ rect.y1 += 5; rect.y2 = rect.y1 + 20;
+ rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
+ rtgui_container_add_child(RTGUI_CONTAINER(msgbox), RTGUI_WIDGET(label));
rtgui_win_show(msgbox, RT_FALSE);
}
@@ -81,7 +85,7 @@ void window_demo_normal(rtgui_toplevel_t* parent)
/* ����һ������ */
win = rtgui_win_create(parent,
- "����", &rect, RTGUI_WIN_STYLE_DEFAULT);
+ get_win_title(), &rect, RTGUI_WIN_STYLE_DEFAULT);
rect.x1 += 20; rect.x2 -= 5;
rect.y1 += 5; rect.y2 = rect.y1 + 20;
@@ -105,7 +109,7 @@ void window_demo_modal(rtgui_toplevel_t* parent)
/* ����һ������ */
win = rtgui_win_create(parent,
- "ģʽ����", &rect, RTGUI_WIN_STYLE_DEFAULT);
+ get_win_title(), &rect, RTGUI_WIN_STYLE_DEFAULT);
rect.x1 += 20; rect.x2 -= 5;
rect.y1 += 5; rect.y2 = rect.y1 + 20;