2012-04-18 23:06:12 +08:00
|
|
|
|
/*
|
|
|
|
|
* <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 "demo_view.h"
|
|
|
|
|
#include <rtgui/rtgui_system.h>
|
|
|
|
|
#include <rtgui/widgets/label.h>
|
|
|
|
|
#include <rtgui/widgets/slider.h>
|
|
|
|
|
#include <rtgui/image.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* view<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
2012-08-13 16:32:01 +08:00
|
|
|
|
static rt_bool_t dc_buffer_event_handler(struct rtgui_object *object, rtgui_event_t *event)
|
2012-04-18 23:06:12 +08:00
|
|
|
|
{
|
2012-08-13 16:32:01 +08:00
|
|
|
|
struct rtgui_widget *widget = RTGUI_WIDGET(object);
|
2012-09-07 09:50:13 +08:00
|
|
|
|
struct rtgui_dc *dc_buffer;
|
2012-08-13 16:32:01 +08:00
|
|
|
|
|
|
|
|
|
/* <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_container_event_handler(object, event);
|
2012-09-07 09:50:13 +08:00
|
|
|
|
dc_buffer = (struct rtgui_dc*)widget->user_data;
|
2012-08-13 16:32:01 +08:00
|
|
|
|
/* <20><><EFBFBD>ÿؼ<C3BF><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DC */
|
|
|
|
|
dc = rtgui_dc_begin_drawing(widget);
|
|
|
|
|
/* <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;
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD>demo view<65><77><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
demo_view_get_logic_rect(RTGUI_CONTAINER(widget), &rect);
|
|
|
|
|
|
|
|
|
|
rect.x1 += 10;
|
|
|
|
|
rect.y1 += 10;
|
|
|
|
|
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_container_event_handler(object, event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return RT_FALSE;
|
2012-04-18 23:06:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DC Buffer<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD>ͼ */
|
|
|
|
|
rtgui_container_t *demo_view_dc_buffer()
|
|
|
|
|
{
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_container_t *view;
|
2012-09-07 09:50:13 +08:00
|
|
|
|
struct rtgui_dc *dc_buffer=RT_NULL;
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2012-08-13 16:32:01 +08:00
|
|
|
|
if (dc_buffer == RT_NULL)
|
|
|
|
|
{
|
|
|
|
|
rtgui_rect_t rect = {0, 0, 50, 50};
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2012-08-13 16:32:01 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD> DC Buffer<65><72><EFBFBD><EFBFBD> 50<35><30><EFBFBD><EFBFBD> 50 */
|
|
|
|
|
dc_buffer = rtgui_dc_buffer_create(50, 50);
|
2012-09-07 09:50:13 +08:00
|
|
|
|
RTGUI_DC_BC(dc_buffer) = blue;
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_dc_fill_rect(dc_buffer, &rect);
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2012-08-13 16:32:01 +08:00
|
|
|
|
RTGUI_DC_FC(dc_buffer) = red;
|
|
|
|
|
rtgui_dc_draw_circle(dc_buffer, 25, 25, 10);
|
|
|
|
|
}
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2012-08-13 16:32:01 +08:00
|
|
|
|
view = demo_view("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>DC<EFBFBD><EFBFBD>ʾ");
|
|
|
|
|
if (view != RT_NULL)
|
|
|
|
|
/* <20><><EFBFBD>ó<EFBFBD><C3B3>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
rtgui_object_set_event_handler(RTGUI_OBJECT(view), dc_buffer_event_handler);
|
2012-09-07 09:50:13 +08:00
|
|
|
|
RTGUI_WIDGET(view)->user_data = (rt_uint32_t)dc_buffer;
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2012-08-13 16:32:01 +08:00
|
|
|
|
return view;
|
2012-04-18 23:06:12 +08:00
|
|
|
|
}
|