rt-thread/examples/rtgui_win/demo_gui_dc_buffer.c

81 lines
1.8 KiB
C
Raw Normal View History

/*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DC Buffer<EFBFBD><EFBFBD>ʾ
*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>view<EFBFBD>Ͻ<EFBFBD><EFBFBD><EFBFBD>DC Buffer<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
*/
#include <rtgui/event.h>
#include <rtgui/widgets/view.h>
#include <rtgui/rtgui_system.h>
#include <rtgui/widgets/label.h>
#include <rtgui/widgets/slider.h>
#include <rtgui/image.h>
#include "demo_view.h"
static struct rtgui_dc *dc_buffer;
/*
* view<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
static rt_bool_t dc_buffer_event_handler(PVOID wdt, rtgui_event_t *event)
{
/* <20><><EFBFBD><EFBFBD>PAINT<4E>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD> */
if (event->type == RTGUI_EVENT_PAINT)
{
struct rtgui_dc* dc;
rtgui_rect_t rect;
/*
* <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>ͼ
*/
rtgui_view_event_handler(wdt, event);
/* <20><><EFBFBD>ÿؼ<C3BF><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DC */
dc = rtgui_dc_begin_drawing(wdt);
/* <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)
return RT_FALSE;
rtgui_widget_get_rect(wdt, &rect);
rect.x1 += 10;
rect.y1 += 40;
rtgui_dc_blit(dc_buffer, NULL, dc, &rect);
/* <20><>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD> */
rtgui_dc_end_drawing(dc);
}
else
{
/* <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϵ<EFBFBD><CFB5>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
return rtgui_view_event_handler(wdt, event);
}
return RT_FALSE;
}
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DC Buffer<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD>ͼ */
rtgui_view_t *demo_gui_dc_buffer(rtgui_view_t* parent_view)
{
rtgui_view_t *view;
if (dc_buffer == RT_NULL)
{
rtgui_rect_t rect = {0, 0, 50, 50};
/* <20><><EFBFBD><EFBFBD> DC Buffer<65><72><EFBFBD><EFBFBD> 50<35><30><EFBFBD><EFBFBD> 50 */
dc_buffer = rtgui_dc_buffer_create(50, 50);
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);
}
view = demo_view_create(parent_view, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>DC<EFBFBD><EFBFBD>ʾ");
if (view == RT_NULL) return RT_NULL;
/* <20><><EFBFBD>ó<EFBFBD><C3B3>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
rtgui_widget_set_event_handler(view, dc_buffer_event_handler);
return view;
}