2010-03-14 21:47:49 +08:00
|
|
|
|
/*
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>嵥<EFBFBD><EFBFBD>DC<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
*
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>view<EFBFBD>Ͻ<EFBFBD><EFBFBD><EFBFBD>DC<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
*/
|
|
|
|
|
|
2010-01-25 08:02:14 +08:00
|
|
|
|
#include "demo_view.h"
|
2010-04-12 22:09:56 +08:00
|
|
|
|
#include <rtgui/dc.h>
|
2010-01-25 08:02:14 +08:00
|
|
|
|
#include <rtgui/rtgui_system.h>
|
|
|
|
|
#include <rtgui/widgets/label.h>
|
|
|
|
|
#include <rtgui/widgets/slider.h>
|
2010-07-05 07:59:45 +08:00
|
|
|
|
#include <rtgui/image_hdc.h>
|
|
|
|
|
|
|
|
|
|
#include "play.hdh"
|
|
|
|
|
#include "stop.hdh"
|
|
|
|
|
struct rtgui_image_hdcmm play_image = RTGUI_IMAGE_HDC_DEF(2, 0x1c, 0x16, play_hdh);
|
|
|
|
|
struct rtgui_image_hdcmm stop_image = RTGUI_IMAGE_HDC_DEF(2, 0x1c, 0x16, stop_hdh);
|
2010-01-25 08:02:14 +08:00
|
|
|
|
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/*
|
|
|
|
|
* view<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
2010-01-25 08:02:14 +08:00
|
|
|
|
rt_bool_t dc_event_handler(rtgui_widget_t* widget, rtgui_event_t *event)
|
|
|
|
|
{
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>PAINT<4E>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD> */
|
2010-01-25 08:02:14 +08:00
|
|
|
|
if (event->type == RTGUI_EVENT_PAINT)
|
|
|
|
|
{
|
|
|
|
|
struct rtgui_dc* dc;
|
|
|
|
|
rtgui_rect_t rect;
|
|
|
|
|
rt_uint32_t vx[] = {20, 50, 60, 45, 60, 20};
|
|
|
|
|
rt_uint32_t vy[] = {150, 50, 90, 60, 45, 50};
|
|
|
|
|
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/*
|
|
|
|
|
* <EFBFBD><EFBFBD>Ϊ<EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD>demo view<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ֿؼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD>ͼʱ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>demo view
|
|
|
|
|
* <EFBFBD>Ȼ<EFBFBD>ͼ
|
|
|
|
|
*/
|
2010-01-25 08:02:14 +08:00
|
|
|
|
rtgui_view_event_handler(widget, event);
|
|
|
|
|
|
|
|
|
|
/************************************************************************/
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DC<44>IJ<EFBFBD><C4B2><EFBFBD> */
|
2010-01-25 08:02:14 +08:00
|
|
|
|
/************************************************************************/
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD>ÿؼ<C3BF><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DC */
|
|
|
|
|
dc = rtgui_dc_begin_drawing(widget);
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DC<44><43><EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD><D8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC>ؼ<F2B8B8BF><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC>DC<44>ǻ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ɹ<EFBFBD><C9B9>ģ<EFBFBD> */
|
|
|
|
|
if (dc == RT_NULL)
|
2010-01-25 08:02:14 +08:00
|
|
|
|
return RT_FALSE;
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD>demo view<65><77><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
demo_view_get_rect(RTGUI_VIEW(widget), &rect);
|
|
|
|
|
|
2010-04-12 22:09:56 +08:00
|
|
|
|
RTGUI_DC_TEXTALIGN(dc) = RTGUI_ALIGN_BOTTOM | RTGUI_ALIGN_CENTER_HORIZONTAL;
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/* <20><>ʾGUI<55>İ汾<C4B0><E6B1BE>Ϣ */
|
2010-02-04 08:07:08 +08:00
|
|
|
|
#ifdef RTGUI_USING_SMALL_SIZE
|
|
|
|
|
rtgui_dc_draw_text(dc, "RT-Thread/GUIС<49>Ͱ汾", &rect);
|
|
|
|
|
#else
|
|
|
|
|
rtgui_dc_draw_text(dc, "RT-Thread/GUI<55><49><EFBFBD>汾", &rect);
|
|
|
|
|
#endif
|
|
|
|
|
|
2010-07-05 07:59:45 +08:00
|
|
|
|
{
|
|
|
|
|
rtgui_rect_t rect = {0, 0, 0x1c, 0x16};
|
|
|
|
|
rtgui_rect_moveto(&rect, 80, 80);
|
|
|
|
|
rtgui_image_blit((rtgui_image_t*)&play_image, dc, &rect);
|
|
|
|
|
|
|
|
|
|
rect.x1 = 0; rect.y1 = 0;
|
|
|
|
|
rect.x2 = 0x1c; rect.y2 = 0x16;
|
|
|
|
|
rtgui_rect_moveto(&rect, 130, 80);
|
|
|
|
|
rtgui_image_blit((rtgui_image_t*)&stop_image, dc, &rect);
|
|
|
|
|
}
|
2010-01-25 08:02:14 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>Բ<EFBFBD><D4B2> */
|
2010-04-12 22:09:56 +08:00
|
|
|
|
RTGUI_DC_FC(dc) = red;
|
2010-01-25 08:02:14 +08:00
|
|
|
|
rtgui_dc_draw_circle(dc, rect.x1 + 10, rect.y1 + 10, 10);
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>Բ<EFBFBD><D4B2> */
|
2010-04-12 22:09:56 +08:00
|
|
|
|
RTGUI_DC_FC(dc) = green;
|
2010-01-25 08:02:14 +08:00
|
|
|
|
rtgui_dc_fill_circle(dc, rect.x1 + 30, rect.y1 + 10, 10);
|
|
|
|
|
|
2010-02-01 17:45:33 +08:00
|
|
|
|
/* <20><>һ<EFBFBD><D2BB>Բ<EFBFBD><D4B2> */
|
2010-04-12 22:09:56 +08:00
|
|
|
|
RTGUI_DC_FC(dc) = RTGUI_RGB(250, 120, 120);
|
2010-01-27 17:42:19 +08:00
|
|
|
|
rtgui_dc_draw_arc(dc, rect.x1 + 120, rect.y1 + 60, 30, 0, 120);
|
|
|
|
|
|
2010-01-25 08:02:14 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2010-04-12 22:09:56 +08:00
|
|
|
|
RTGUI_DC_FC(dc) = blue;
|
2010-01-25 08:02:14 +08:00
|
|
|
|
rtgui_dc_draw_polygon(dc, vx, vy, 6);
|
|
|
|
|
|
2010-02-13 00:02:58 +08:00
|
|
|
|
/* <20><><EFBFBD>Ʋ<EFBFBD>ͬ<EFBFBD>ı߿<C4B1> */
|
2010-02-01 17:45:33 +08:00
|
|
|
|
{
|
|
|
|
|
rtgui_rect_t rect = {0, 0, 16, 16};
|
|
|
|
|
rtgui_rect_moveto(&rect, 30, 120);
|
|
|
|
|
|
2010-03-14 14:36:46 +08:00
|
|
|
|
rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_RAISE);
|
|
|
|
|
rect.x1 += 20;
|
|
|
|
|
rect.x2 += 20 + 50;
|
2010-02-01 17:45:33 +08:00
|
|
|
|
rtgui_dc_draw_text(dc, "raise", &rect);
|
2010-03-14 14:36:46 +08:00
|
|
|
|
rect.x1 -= 20;
|
|
|
|
|
rect.x2 -= 20 + 50;
|
|
|
|
|
rect.y1 += 20;
|
|
|
|
|
rect.y2 += 20;
|
2010-02-01 17:45:33 +08:00
|
|
|
|
|
|
|
|
|
rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_SIMPLE);
|
2010-03-14 14:36:46 +08:00
|
|
|
|
rect.x1 += 20;
|
|
|
|
|
rect.x2 += 20 + 50;
|
2010-02-01 17:45:33 +08:00
|
|
|
|
rtgui_dc_draw_text(dc, "simple", &rect);
|
2010-03-14 14:36:46 +08:00
|
|
|
|
rect.x1 -= 20;
|
|
|
|
|
rect.x2 -= 20 + 50;
|
|
|
|
|
rect.y1 += 20;
|
|
|
|
|
rect.y2 += 20;
|
2010-02-01 17:45:33 +08:00
|
|
|
|
|
|
|
|
|
rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_SUNKEN);
|
2010-03-14 14:36:46 +08:00
|
|
|
|
rect.x1 += 20;
|
|
|
|
|
rect.x2 += 20 + 50;
|
2010-02-01 17:45:33 +08:00
|
|
|
|
rtgui_dc_draw_text(dc, "sunken", &rect);
|
2010-03-14 14:36:46 +08:00
|
|
|
|
rect.x1 -= 20;
|
|
|
|
|
rect.x2 -= 20 + 50;
|
|
|
|
|
rect.y1 += 20;
|
|
|
|
|
rect.y2 += 20;
|
2010-02-01 17:45:33 +08:00
|
|
|
|
|
|
|
|
|
rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_BOX);
|
2010-03-14 14:36:46 +08:00
|
|
|
|
rect.x1 += 20;
|
|
|
|
|
rect.x2 += 20 + 50;
|
2010-02-01 17:45:33 +08:00
|
|
|
|
rtgui_dc_draw_text(dc, "box", &rect);
|
2010-03-14 14:36:46 +08:00
|
|
|
|
rect.x1 -= 20;
|
|
|
|
|
rect.x2 -= 20 + 50;
|
|
|
|
|
rect.y1 += 20;
|
|
|
|
|
rect.y2 += 20;
|
2010-02-01 17:45:33 +08:00
|
|
|
|
|
|
|
|
|
rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_STATIC);
|
2010-03-14 14:36:46 +08:00
|
|
|
|
rect.x1 += 20;
|
|
|
|
|
rect.x2 += 20 + 50;
|
2010-02-01 17:45:33 +08:00
|
|
|
|
rtgui_dc_draw_text(dc, "static", &rect);
|
2010-03-14 14:36:46 +08:00
|
|
|
|
rect.x1 -= 20;
|
|
|
|
|
rect.x2 -= 20 + 50;
|
|
|
|
|
rect.y1 += 20;
|
|
|
|
|
rect.y2 += 20;
|
2010-02-01 17:45:33 +08:00
|
|
|
|
|
|
|
|
|
rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_EXTRA);
|
2010-03-14 14:36:46 +08:00
|
|
|
|
rect.x1 += 20;
|
|
|
|
|
rect.x2 += 20 + 50;
|
2010-02-01 17:45:33 +08:00
|
|
|
|
rtgui_dc_draw_text(dc, "extra", &rect);
|
2010-03-14 14:36:46 +08:00
|
|
|
|
rect.x1 -= 20;
|
|
|
|
|
rect.x2 -= 20 + 50;
|
|
|
|
|
rect.y1 += 20;
|
|
|
|
|
rect.y2 += 20;
|
2010-02-01 17:45:33 +08:00
|
|
|
|
}
|
2010-03-14 21:47:49 +08:00
|
|
|
|
|
2010-01-25 08:02:14 +08:00
|
|
|
|
/* <20><>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD> */
|
|
|
|
|
rtgui_dc_end_drawing(dc);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϵ<EFBFBD><CFB5>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2010-01-25 08:02:14 +08:00
|
|
|
|
return rtgui_view_event_handler(widget, event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return RT_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DC<44><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD>ͼ */
|
2010-01-25 08:02:14 +08:00
|
|
|
|
rtgui_view_t *demo_view_dc(rtgui_workbench_t* workbench)
|
|
|
|
|
{
|
|
|
|
|
rtgui_view_t *view;
|
|
|
|
|
|
|
|
|
|
view = demo_view(workbench, "DC Demo");
|
2010-01-27 17:42:19 +08:00
|
|
|
|
if (view != RT_NULL)
|
2010-03-14 21:47:49 +08:00
|
|
|
|
/* <20><><EFBFBD>ó<EFBFBD><C3B3>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2010-01-27 17:42:19 +08:00
|
|
|
|
rtgui_widget_set_event_handler(RTGUI_WIDGET(view), dc_event_handler);
|
2010-01-25 08:02:14 +08:00
|
|
|
|
|
|
|
|
|
return view;
|
|
|
|
|
}
|