[bsp]update rtgui_demo.c
This commit is contained in:
parent
6127313514
commit
f878c6a59f
@ -45,42 +45,42 @@ struct rtgui_win *main_win;
|
|||||||
rt_bool_t dc_event_handler(struct rtgui_object *object, rtgui_event_t *event);
|
rt_bool_t dc_event_handler(struct rtgui_object *object, rtgui_event_t *event);
|
||||||
|
|
||||||
static void rt_gui_demo_entry(void *parameter)
|
static void rt_gui_demo_entry(void *parameter)
|
||||||
{
|
{
|
||||||
struct rtgui_app *app;
|
struct rtgui_app *app;
|
||||||
|
|
||||||
DEBUG_PRINTF("gui demo entry\n");
|
DEBUG_PRINTF("gui demo entry\n");
|
||||||
|
|
||||||
/* create gui app */
|
/* create gui app */
|
||||||
app = rtgui_app_create("gui_demo");
|
app = rtgui_app_create("gui_demo");
|
||||||
if (app == RT_NULL)
|
if (app == RT_NULL)
|
||||||
{
|
{
|
||||||
DEBUG_PRINTF("rtgui_app_create faild\n");
|
DEBUG_PRINTF("rtgui_app_create faild\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create main window */
|
/* create main window */
|
||||||
main_win = rtgui_mainwin_create(RT_NULL,
|
main_win = rtgui_mainwin_create(RT_NULL,
|
||||||
"UiWindow", RTGUI_WIN_STYLE_NO_TITLE | RTGUI_WIN_STYLE_NO_BORDER);
|
"UiWindow", RTGUI_WIN_STYLE_NO_TITLE | RTGUI_WIN_STYLE_NO_BORDER);
|
||||||
if (main_win == RT_NULL)
|
if (main_win == RT_NULL)
|
||||||
{
|
{
|
||||||
DEBUG_PRINTF("main_win is null\n");
|
DEBUG_PRINTF("main_win is null\n");
|
||||||
rtgui_app_destroy(app);
|
rtgui_app_destroy(app);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rtgui_object_set_event_handler(RTGUI_OBJECT(main_win), dc_event_handler);
|
rtgui_object_set_event_handler(RTGUI_OBJECT(main_win), dc_event_handler);
|
||||||
|
|
||||||
DEBUG_PRINTF("rtgui_win_show\n");
|
DEBUG_PRINTF("rtgui_win_show\n");
|
||||||
rtgui_win_show(main_win, RT_FALSE);
|
rtgui_win_show(main_win, RT_FALSE);
|
||||||
|
|
||||||
DEBUG_PRINTF("rtgui_app_run\n");
|
DEBUG_PRINTF("rtgui_app_run\n");
|
||||||
rtgui_app_run(app);
|
rtgui_app_run(app);
|
||||||
|
|
||||||
DEBUG_PRINTF("rtgui_win_destroy\n");
|
DEBUG_PRINTF("rtgui_win_destroy\n");
|
||||||
rtgui_win_destroy(main_win);
|
rtgui_win_destroy(main_win);
|
||||||
|
|
||||||
DEBUG_PRINTF("rtgui_app_destroy\n");
|
DEBUG_PRINTF("rtgui_app_destroy\n");
|
||||||
rtgui_app_destroy(app);
|
rtgui_app_destroy(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
rt_bool_t dc_event_handler(struct rtgui_object *object, rtgui_event_t *event)
|
rt_bool_t dc_event_handler(struct rtgui_object *object, rtgui_event_t *event)
|
||||||
@ -91,31 +91,31 @@ rt_bool_t dc_event_handler(struct rtgui_object *object, rtgui_event_t *event)
|
|||||||
{
|
{
|
||||||
struct rtgui_dc *dc;
|
struct rtgui_dc *dc;
|
||||||
rtgui_rect_t rect;
|
rtgui_rect_t rect;
|
||||||
|
|
||||||
rt_kprintf("\r\n RTGUI_EVENT_PAINT \r\n");
|
DEBUG_PRINTF("\r\n RTGUI_EVENT_PAINT \r\n");
|
||||||
rtgui_win_event_handler(RTGUI_OBJECT(widget), event);
|
rtgui_win_event_handler(RTGUI_OBJECT(widget), event);
|
||||||
|
|
||||||
rtgui_widget_get_rect(widget, &rect);
|
rtgui_widget_get_rect(widget, &rect);
|
||||||
DEBUG_PRINTF("widget react x1: %d, y1: %d, x2: %d, y2: %d\r\n",
|
DEBUG_PRINTF("widget react x1: %d, y1: %d, x2: %d, y2: %d\r\n",
|
||||||
rect.x1, rect.y1, rect.x2, rect.y2);
|
rect.x1, rect.y1, rect.x2, rect.y2);
|
||||||
|
|
||||||
dc = rtgui_dc_begin_drawing(widget);
|
dc = rtgui_dc_begin_drawing(widget);
|
||||||
if(dc == RT_NULL)
|
if (dc == RT_NULL)
|
||||||
{
|
{
|
||||||
DEBUG_PRINTF("\r\n dc is null \r\n");
|
DEBUG_PRINTF("\r\n dc is null \r\n");
|
||||||
return RT_FALSE;
|
return RT_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
rtgui_dc_draw_line(dc, rect.x1, rect.y1, rect.x2, rect.y2);
|
rtgui_dc_draw_line(dc, rect.x1, rect.y1, rect.x2, rect.y2);
|
||||||
rtgui_dc_draw_line(dc, rect.x1, rect.y2, rect.x2, rect.y1);
|
rtgui_dc_draw_line(dc, rect.x1, rect.y2, rect.x2, rect.y1);
|
||||||
|
|
||||||
rect.x1 += (rect.x2 - rect.x1) / 2;
|
rect.x1 += (rect.x2 - rect.x1) / 2;
|
||||||
rect.y1 += (rect.y2 - rect.y1) / 2;
|
rect.y1 += (rect.y2 - rect.y1) / 2;
|
||||||
rtgui_dc_draw_text_stroke(dc, __DATE__"--"__TIME__, &rect, HIGH_LIGHT, BLUE);
|
rtgui_dc_draw_text_stroke(dc, __DATE__"--"__TIME__, &rect, HIGH_LIGHT, BLUE);
|
||||||
|
|
||||||
rtgui_dc_end_drawing(dc,RT_TRUE);
|
rtgui_dc_end_drawing(dc,RT_TRUE);
|
||||||
}
|
}
|
||||||
return RT_FALSE;
|
return RT_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rt_gui_demo_init(void)
|
int rt_gui_demo_init(void)
|
||||||
@ -125,7 +125,7 @@ int rt_gui_demo_init(void)
|
|||||||
rt_err_t err;
|
rt_err_t err;
|
||||||
|
|
||||||
device = rt_device_find("lcd");
|
device = rt_device_find("lcd");
|
||||||
if(device == RT_NULL)
|
if (device == RT_NULL)
|
||||||
{
|
{
|
||||||
rt_kprintf("Not found LCD driver\n");
|
rt_kprintf("Not found LCD driver\n");
|
||||||
return RT_ERROR;
|
return RT_ERROR;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user