From 06f58468b6103683d2481757857c5d7767a208e3 Mon Sep 17 00:00:00 2001 From: "bernard.xiong" Date: Mon, 12 Apr 2010 14:09:56 +0000 Subject: [PATCH] add rtgui_dc_draw_color_point function. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@610 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- examples/gui/demo_view_dc.c | 11 ++++++----- examples/gui/demo_view_dc_buffer.c | 11 ++++++++--- examples/gui/demo_workbench.c | 3 +-- examples/gui/mywidget.c | 8 ++++---- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/examples/gui/demo_view_dc.c b/examples/gui/demo_view_dc.c index 501286aa99..f5407cdeb4 100644 --- a/examples/gui/demo_view_dc.c +++ b/examples/gui/demo_view_dc.c @@ -5,6 +5,7 @@ */ #include "demo_view.h" +#include #include #include #include @@ -41,7 +42,7 @@ 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); + RTGUI_DC_TEXTALIGN(dc) = RTGUI_ALIGN_BOTTOM | RTGUI_ALIGN_CENTER_HORIZONTAL; /* 显示GUI的版本信息 */ #ifdef RTGUI_USING_SMALL_SIZE rtgui_dc_draw_text(dc, "RT-Thread/GUI小型版本", &rect); @@ -50,19 +51,19 @@ rt_bool_t dc_event_handler(rtgui_widget_t* widget, rtgui_event_t *event) #endif /* 绘制一个圆形 */ - rtgui_dc_set_color(dc, red); + RTGUI_DC_FC(dc) = red; rtgui_dc_draw_circle(dc, rect.x1 + 10, rect.y1 + 10, 10); /* 填充一个圆形 */ - rtgui_dc_set_color(dc, green); + RTGUI_DC_FC(dc) = green; rtgui_dc_fill_circle(dc, rect.x1 + 30, rect.y1 + 10, 10); /* 画一个圆弧 */ - rtgui_dc_set_color(dc, RTGUI_RGB(250, 120, 120)); + RTGUI_DC_FC(dc) = RTGUI_RGB(250, 120, 120); rtgui_dc_draw_arc(dc, rect.x1 + 120, rect.y1 + 60, 30, 0, 120); /* 多边形 */ - rtgui_dc_set_color(dc, blue); + RTGUI_DC_FC(dc) = blue; rtgui_dc_draw_polygon(dc, vx, vy, 6); /* 绘制不同的边框 */ diff --git a/examples/gui/demo_view_dc_buffer.c b/examples/gui/demo_view_dc_buffer.c index 314fe88125..8cb35a608a 100644 --- a/examples/gui/demo_view_dc_buffer.c +++ b/examples/gui/demo_view_dc_buffer.c @@ -24,7 +24,6 @@ static rt_bool_t dc_buffer_event_handler(rtgui_widget_t* widget, rtgui_event_t * { struct rtgui_dc* dc; rtgui_rect_t rect; - rtgui_point_t point = {0, 0}; /* * 因为用的是demo view,上面本身有一部分控件,所以在绘图时先要让demo view @@ -41,7 +40,9 @@ static rt_bool_t dc_buffer_event_handler(rtgui_widget_t* widget, rtgui_event_t * /* 获得demo view允许绘图的区域 */ demo_view_get_rect(RTGUI_VIEW(widget), &rect); - rtgui_dc_blit(dc_buffer, &point, dc, &rect); + rect.x1 += 10; + rect.y1 += 10; + rtgui_dc_blit(dc_buffer, NULL, dc, &rect); /* 绘图完成 */ rtgui_dc_end_drawing(dc); @@ -62,9 +63,13 @@ rtgui_view_t *demo_view_dc_buffer(rtgui_workbench_t* workbench) if (dc_buffer == RT_NULL) { + rtgui_rect_t rect = {0, 0, 50, 50}; + /* 创建 DC Buffer,长 50,宽 50 */ dc_buffer = rtgui_dc_buffer_create(50, 50); - rtgui_dc_set_color(dc_buffer, blue); + RTGUI_DC_FC(dc_buffer) = blue; + rtgui_dc_fill_rect(dc_buffer, &rect); + RTGUI_DC_FC(dc_buffer) = red; rtgui_dc_draw_circle(dc_buffer, 25, 25, 10); } diff --git a/examples/gui/demo_workbench.c b/examples/gui/demo_workbench.c index 590b12fcc9..88d84c7f5b 100644 --- a/examples/gui/demo_workbench.c +++ b/examples/gui/demo_workbench.c @@ -33,7 +33,6 @@ static rt_bool_t demo_workbench_event_handler(struct rtgui_widget* widget, struc static void workbench_entry(void* parameter) { rt_mq_t mq; - struct rtgui_view* view; struct rtgui_workbench* workbench; /* 鍒涘缓GUI搴旂敤闇瑕佺殑娑堟伅闃熷垪 */ @@ -53,7 +52,7 @@ static void workbench_entry(void* parameter) /* 鍒濆鍖栧悇涓緥瀛愮殑瑙嗗浘 */ demo_view_dc(workbench); - /* demo_view_dc_buffer(workbench); */ + demo_view_dc_buffer(workbench); demo_view_animation(workbench); demo_view_window(workbench); demo_view_label(workbench); diff --git a/examples/gui/mywidget.c b/examples/gui/mywidget.c index 1c65240bc0..d41e3a77e7 100644 --- a/examples/gui/mywidget.c +++ b/examples/gui/mywidget.c @@ -15,7 +15,7 @@ static void rtgui_mywidget_ondraw(struct rtgui_mywidget* me) /* 鑾峰緱绐楀彛鐨勫昂瀵 */ rtgui_widget_get_rect(RTGUI_WIDGET(me), &rect); /* 缁樺埗鑳屾櫙鑹 */ - rtgui_dc_set_color(dc, white); + RTGUI_DC_BC(dc) = white; rtgui_dc_fill_rect(dc, &rect); /* 璁$畻涓績鍘熺偣 */ @@ -23,15 +23,15 @@ static void rtgui_mywidget_ondraw(struct rtgui_mywidget* me) y = (rect.y2 + rect.y1)/2; /* 缁樺埗鍗佸瓧鏋 */ - rtgui_dc_set_color(dc, black); + RTGUI_DC_BC(dc) = black; rtgui_dc_draw_hline(dc, rect.x1, rect.x2, y); rtgui_dc_draw_vline(dc, x, rect.y1, rect.y2); /* 鏍规嵁鐘舵佺粯鍒跺渾鍦 */ if (me->status == MYWIDGET_STATUS_ON) - rtgui_dc_set_color(dc, green); + RTGUI_DC_BC(dc) = green; else - rtgui_dc_set_color(dc, red); + RTGUI_DC_BC(dc) = red; rtgui_dc_fill_circle(dc, x, y, 5); /* 缁撴潫缁樺浘 */