2010-07-05 07:59:45 +08:00
|
|
|
|
#include <rtgui/dc.h>
|
2010-08-16 08:03:51 +08:00
|
|
|
|
#include <rtgui/dc_hw.h>
|
2010-07-05 07:59:45 +08:00
|
|
|
|
#include <rtgui/rtgui_system.h>
|
|
|
|
|
#include <rtgui/widgets/view.h>
|
|
|
|
|
#include "demo_view.h"
|
|
|
|
|
|
2010-08-16 08:03:51 +08:00
|
|
|
|
#define RAND(x1, x2) ((rand() % (x2 - x1)) + x1)
|
2010-08-13 18:36:52 +08:00
|
|
|
|
|
2010-08-16 08:03:51 +08:00
|
|
|
|
static rtgui_view_t* view = RT_NULL;
|
2010-08-13 18:36:52 +08:00
|
|
|
|
void _onidle(rtgui_widget_t* widget, rtgui_event_t *event)
|
|
|
|
|
{
|
|
|
|
|
rtgui_color_t color;
|
|
|
|
|
rtgui_rect_t rect, draw_rect;
|
2010-08-16 08:03:51 +08:00
|
|
|
|
struct rtgui_dc *dc;
|
2010-08-13 18:36:52 +08:00
|
|
|
|
|
2010-08-16 08:03:51 +08:00
|
|
|
|
/* <20><><EFBFBD>ÿؼ<C3BF><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DC */
|
|
|
|
|
// dc = rtgui_dc_hw_create(RTGUI_WIDGET(view));
|
|
|
|
|
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(view));
|
2010-08-13 18:36:52 +08:00
|
|
|
|
if (dc == RT_NULL) return ;
|
|
|
|
|
|
2010-08-16 08:03:51 +08:00
|
|
|
|
demo_view_get_rect(RTGUI_VIEW(view), &rect);
|
2010-08-13 18:36:52 +08:00
|
|
|
|
draw_rect.x1 = RAND(rect.x1, rect.x2);
|
|
|
|
|
draw_rect.y1 = RAND(rect.y1, rect.y2);
|
|
|
|
|
draw_rect.x2 = RAND(draw_rect.x1, rect.x2);
|
|
|
|
|
draw_rect.y2 = RAND(draw_rect.y1, rect.y2);
|
|
|
|
|
|
2010-08-16 08:03:51 +08:00
|
|
|
|
color = RTGUI_RGB(rand() % 255, rand() % 255, rand() % 255);
|
|
|
|
|
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = color;
|
2010-08-13 18:36:52 +08:00
|
|
|
|
|
2010-08-16 08:03:51 +08:00
|
|
|
|
rtgui_dc_fill_rect(dc, &draw_rect);
|
2010-08-13 18:36:52 +08:00
|
|
|
|
|
2010-08-16 08:03:51 +08:00
|
|
|
|
/* <20><>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD> */
|
2010-08-13 18:36:52 +08:00
|
|
|
|
rtgui_dc_end_drawing(dc);
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-05 07:59:45 +08:00
|
|
|
|
rt_bool_t benchmark_event_handler(rtgui_widget_t* widget, rtgui_event_t *event)
|
|
|
|
|
{
|
|
|
|
|
if (event->type == RTGUI_EVENT_PAINT)
|
|
|
|
|
{
|
|
|
|
|
struct rtgui_dc* dc;
|
|
|
|
|
rtgui_rect_t rect;
|
|
|
|
|
|
2010-08-16 08:03:51 +08:00
|
|
|
|
/* <20><>Ϊ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD>demo view<65><77><EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ֿؼ<D6BF><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD>ͼʱ<CDBC><CAB1>Ҫ<EFBFBD><D2AA>demo view<65>Ȼ<EFBFBD>ͼ */
|
2010-07-05 07:59:45 +08:00
|
|
|
|
rtgui_view_event_handler(widget, event);
|
|
|
|
|
|
2010-08-16 08:03:51 +08:00
|
|
|
|
/* <20><><EFBFBD>ÿؼ<C3BF><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DC */
|
2010-07-05 07:59:45 +08:00
|
|
|
|
dc = rtgui_dc_begin_drawing(widget);
|
2010-08-16 08:03:51 +08:00
|
|
|
|
if (dc == RT_NULL) /* <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> */
|
2010-07-05 07:59:45 +08:00
|
|
|
|
return RT_FALSE;
|
|
|
|
|
|
2010-08-16 08:03:51 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>demo view<65><77><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2010-07-05 07:59:45 +08:00
|
|
|
|
demo_view_get_rect(RTGUI_VIEW(widget), &rect);
|
|
|
|
|
|
2010-08-16 08:03:51 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2010-07-05 07:59:45 +08:00
|
|
|
|
rtgui_dc_fill_rect(dc, &rect);
|
|
|
|
|
|
2010-08-16 08:03:51 +08:00
|
|
|
|
/* <20><>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD> */
|
2010-07-05 07:59:45 +08:00
|
|
|
|
rtgui_dc_end_drawing(dc);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-08-16 08:03:51 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϵ<EFBFBD><CFB5>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2010-07-05 07:59:45 +08:00
|
|
|
|
return rtgui_view_event_handler(widget, event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return RT_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rtgui_view_t *demo_view_benchmark(rtgui_workbench_t* workbench)
|
|
|
|
|
{
|
2010-08-16 08:03:51 +08:00
|
|
|
|
// rtgui_view_t *view;
|
2010-07-05 07:59:45 +08:00
|
|
|
|
|
2010-08-13 18:36:52 +08:00
|
|
|
|
srand(100);
|
2010-08-16 08:03:51 +08:00
|
|
|
|
view = demo_view(workbench, "<EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
rtgui_widget_set_event_handler(RTGUI_WIDGET(view), benchmark_event_handler);
|
2010-07-05 07:59:45 +08:00
|
|
|
|
|
2010-08-13 18:36:52 +08:00
|
|
|
|
rtgui_thread_set_onidle(_onidle);
|
|
|
|
|
|
2010-07-05 07:59:45 +08:00
|
|
|
|
return view;
|
|
|
|
|
}
|