diff --git a/examples/gui/demo_view_dc.c b/examples/gui/demo_view_dc.c index 775038fdf6..b6c31d54ea 100644 --- a/examples/gui/demo_view_dc.c +++ b/examples/gui/demo_view_dc.c @@ -3,28 +3,6 @@ #include #include -static const rt_uint8_t boxChecked[7] = {0x02, 0x06, 0x8E, 0xDC, 0xF8, 0x70, 0x20}; - -static const rt_uint8_t sysMin[2] = {0x7E, 0x7E}; -static const rt_uint8_t sysMax[18] = {0x0F, 0xF8, 0x0F, 0xF8, 0x08, 0x08, - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x08, 0x08, 0x08, 0x08, 0x0F, 0xF8 -}; -static const rt_uint8_t sysNormal[18] = {0x03, 0xF0, 0x03, 0xF0, 0x02, 0x10, - 0x0F, 0xD0, 0x0F, 0xD0, 0x08, 0x70, - 0x08, 0x40, 0x08, 0x40, 0x0F, 0xC0 -}; - -static const rt_uint8_t sysClose[14] = {0x06, 0x18, 0x03, 0x30, 0x01, 0xE0, 0x00, - 0xC0, 0x01, 0xE0, 0x03, 0x30, 0x06, 0x18 -}; - -static const rt_uint8_t viewSYS[28] = {0xFF, 0x1F, 0x3C, 0x06, 0x1C, 0x04, 0x1C, - 0x0C, 0x0E, 0x08, 0x0E, 0x18, 0x07, 0x10, - 0x07, 0x30, 0x03, 0xA0, 0x03, 0xE0, 0x01, - 0xC0, 0x01, 0xC0, 0x00, 0x80, 0x00, 0x80 -}; - rt_bool_t dc_event_handler(rtgui_widget_t* widget, rtgui_event_t *event) { if (event->type == RTGUI_EVENT_PAINT) @@ -72,57 +50,7 @@ rt_bool_t dc_event_handler(rtgui_widget_t* widget, rtgui_event_t *event) rtgui_dc_set_color(dc, blue); rtgui_dc_draw_polygon(dc, vx, vy, 6); - { - rtgui_rect_t item_rect = {0, 0, 14, 14}; - rt_uint16_t item_size = 14; - - rtgui_rect_moveto(&item_rect, 100, 100); - - rtgui_dc_set_color(dc, RTGUI_RGB(0x66, 0x66, 0x66)); - rtgui_dc_draw_circle(dc, item_rect.x1 + item_size/2, item_rect.y1 + item_size/2, item_size/2); - rtgui_dc_set_color(dc, RTGUI_RGB(0xff, 0xFF, 0xFF)); - rtgui_dc_draw_circle(dc, item_rect.x1 + item_size/2, item_rect.y1 + item_size/2, item_size/2 - 1); - - rtgui_dc_set_color(dc, RTGUI_RGB(0x00, 0x00, 0x00)); - rtgui_dc_fill_circle(dc, item_rect.x1 + item_size/2, item_rect.y1 + item_size/2, item_size/2 - 3); - } - - { - rtgui_rect_t item_rect = {0, 0, 14, 14}; - rt_uint16_t item_size = 14; - rtgui_rect_moveto(&item_rect, 120, 120); - - rtgui_dc_set_color(dc, RTGUI_RGB(0x66, 0x66, 0x66)); - rtgui_dc_draw_circle(dc, item_rect.x1 + item_size/2, item_rect.y1 + item_size/2, item_size/2); - rtgui_dc_set_color(dc, RTGUI_RGB(0xff, 0xFF, 0xFF)); - rtgui_dc_draw_circle(dc, item_rect.x1 + item_size/2, item_rect.y1 + item_size/2, item_size/2 - 1); - rtgui_dc_set_color(dc, RTGUI_RGB(0x00, 0x00, 0x00)); - } - { - int x, y; - - x = 150; y = 150; - rtgui_dc_set_color(dc, black); - - rtgui_dc_draw_byte(dc, x, y, 7, boxChecked); - y += 7 + 2; - - rtgui_dc_draw_byte(dc, x, y, 2, sysMin); - y += 2 + 2; - - rtgui_dc_draw_word(dc, x, y, 9, sysMax); - y += 9 + 2; - - rtgui_dc_draw_word(dc, x, y, 9, sysNormal); - y += 9 + 2; - - rtgui_dc_draw_word(dc, x, y, 7, sysClose); - y += 7 + 2; - - rtgui_dc_draw_word(dc, x, y, 14, viewSYS); - y += 14 + 2; - } - + /* 绘制不同的边框 */ { rtgui_rect_t rect = {0, 0, 16, 16}; rtgui_rect_moveto(&rect, 30, 120); diff --git a/examples/gui/demo_view_image.c b/examples/gui/demo_view_image.c index 925e6b93a6..5053b8cd41 100644 --- a/examples/gui/demo_view_image.c +++ b/examples/gui/demo_view_image.c @@ -31,9 +31,16 @@ static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event) rt_memset(image_type, 0, sizeof(image_type)); /* 获得图像的类型 */ - if (rt_strstr(path, ".png") != RT_NULL) strcat(image_type, "png"); - if (rt_strstr(path, ".jpg") != RT_NULL) strcat(image_type, "jpeg"); - if (rt_strstr(path, ".hdc") != RT_NULL) strcat(image_type, "hdc"); + if (rt_strstr(path, ".png") != RT_NULL || + rt_strstr(path, ".PNG") != RT_NULL) + strcat(image_type, "png"); + if (rt_strstr(path, ".jpg") != RT_NULL || + rt_strstr(path, ".JPG") != RT_NULL) + strcat(image_type, "jpeg"); + if (rt_strstr(path, ".hdc") != RT_NULL || + rt_strstr(path, ".HDC") != RT_NULL) + strcat(image_type, "hdc"); + if (image_type[0] != '\0') image = rtgui_image_create_from_file(image_type, path, RT_TRUE); } diff --git a/examples/gui/demo_view_window.c b/examples/gui/demo_view_window.c index b04a37db08..5d336b552e 100644 --- a/examples/gui/demo_view_window.c +++ b/examples/gui/demo_view_window.c @@ -120,6 +120,8 @@ void window_demo_modal(rtgui_toplevel_t* parent) /* 模态显示窗口 */ rtgui_win_show(win, RT_TRUE); + /* 采用模态显示窗口,关闭时不会自行删除窗口,需要主动删除窗口 */ + rtgui_win_destroy(win); } void window_demo_notitle(rtgui_toplevel_t* parent) diff --git a/examples/gui/demo_workbench.c b/examples/gui/demo_workbench.c index 2dc43176b7..5b5d01dab0 100644 --- a/examples/gui/demo_workbench.c +++ b/examples/gui/demo_workbench.c @@ -6,8 +6,8 @@ static rt_bool_t demo_workbench_event_handler(struct rtgui_widget* widget, struct rtgui_event* event) { - /* 鎴戜滑鐩墠鍙鎸夐敭浜嬩欢鎰熷叴瓒 */ - if (event->type == RTGUI_EVENT_KBD) + /* 鎴戜滑鐩墠鍙鎸夐敭浜嬩欢鎰熷叴瓒c傚鏋滃綋鍓峸orkbench澶勪簬妯″紡鏄剧ず鐘舵侊紝蹇界暐瀹 */ + if ((event->type == RTGUI_EVENT_KBD) && !RTGUI_WORKBENCH_IS_MODAL_MODE(RTGUI_WORKBENCH(widget))) { struct rtgui_event_kbd* ekbd = (struct rtgui_event_kbd*)event;