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>
|
|
|
|
|
|
|
|
|
|
static rtgui_image_t *background;
|
|
|
|
|
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(struct rtgui_object* object, rtgui_event_t *event)
|
|
|
|
|
{
|
|
|
|
|
struct rtgui_widget *widget = RTGUI_WIDGET(object);
|
|
|
|
|
|
|
|
|
|
/* <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);
|
|
|
|
|
|
|
|
|
|
/* <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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <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()
|
|
|
|
|
{
|
|
|
|
|
rtgui_container_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("<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);
|
|
|
|
|
|
|
|
|
|
return view;
|
|
|
|
|
}
|