void rtgui_combo_ondraw(rtgui_combo_t *cbo) { rtgui_rect_t rect; rtgui_dc_t* dc; RT_ASSERT(cbo != RT_NULL); /* begin drawing */ dc = rtgui_dc_begin_drawing(cbo); if(dc == RT_NULL)return; rtgui_widget_get_rect(cbo, &rect); rtgui_rect_inflate(&rect,-RTGUI_WIDGET_BORDER_SIZE(cbo)); if(RTGUI_WIDGET_IS_ENABLE(cbo)) RTGUI_DC_BC(dc) = theme.blankspace; else RTGUI_DC_BC(dc) = theme.background; rtgui_dc_fill_rect(dc, &rect); rtgui_rect_inflate(&rect,RTGUI_WIDGET_BORDER_SIZE(cbo)); rtgui_dc_draw_border(dc, &rect,RTGUI_WIDGET_BORDER_STYLE(cbo)); if(RC_H(rect)<RTGUI_COMBO_HEIGHT)return; /* draw downarrow button */ rect.x1 = rect.x2-RTGUI_COMBO_BUTTON_WIDTH; RTGUI_DC_BC(dc) = theme.background; rtgui_dc_fill_rect(dc, &rect); if(cbo->style & RTGUI_COMBO_STYLE_DOWNARROW_UP) { rtgui_dc_draw_border(dc, &rect, theme.style); rtgui_dc_draw_byte(dc,rect.x1+(rect.x2-rect.x1-7)/2, rect.y1+(rect.y2-rect.y1-4)/2, 4, combo_down_bmp); } else if(cbo->style & RTGUI_COMBO_STYLE_DOWNARROW_DOWN) { rtgui_dc_draw_border(dc, &rect, theme.style); rtgui_dc_draw_byte(dc,rect.x1+(rect.x2-rect.x1-7)/2+1, rect.y1+(rect.y2-rect.y1-4)/2+1, 4, combo_down_bmp); } if(cbo->tbox != RT_NULL) { RTGUI_DC_FC(dc) = theme.foreground; rtgui_textbox_ondraw(cbo->tbox); } rtgui_dc_end_drawing(dc); }
void rtgui_combo_draw_downarrow(rtgui_combo_t *cbo) { rtgui_rect_t rect; rtgui_dc_t* dc; RT_ASSERT(cbo != RT_NULL); /* begin drawing */ dc = rtgui_dc_begin_drawing(cbo); if(dc == RT_NULL)return; rtgui_widget_get_rect(cbo, &rect); rect.x1 = rect.x2-RTGUI_COMBO_BUTTON_WIDTH-RTGUI_WIDGET_BORDER_SIZE(cbo); rect.y1 += RTGUI_WIDGET_BORDER_SIZE(cbo); rect.x2 -= RTGUI_WIDGET_BORDER_SIZE(cbo); rect.y2 -= RTGUI_WIDGET_BORDER_SIZE(cbo); RTGUI_DC_BC(dc) = theme.background; rtgui_dc_fill_rect(dc, &rect); if(cbo->style & RTGUI_COMBO_STYLE_DOWNARROW_UP) { rtgui_dc_draw_border(dc, &rect,RTGUI_WIDGET_BORDER_STYLE(cbo)); rtgui_dc_draw_byte(dc,rect.x1+4, rect.y1+8, 4, combo_down_bmp); } else if(cbo->style & RTGUI_COMBO_STYLE_DOWNARROW_DOWN) { rtgui_dc_draw_border(dc, &rect,RTGUI_WIDGET_BORDER_STYLE(cbo)); rtgui_dc_draw_byte(dc,rect.x1+5, rect.y1+9, 4, combo_down_bmp); } rtgui_dc_end_drawing(dc); }
rt_bool_t picture_win_onpaint(struct rtgui_object* object, struct rtgui_event* event) { struct rtgui_widget *widget = RTGUI_WIDGET(object); if (event->type == RTGUI_EVENT_PAINT) { struct rtgui_dc* dc; struct rtgui_rect rect; struct rtgui_event_paint event; rt_kprintf("handle custom paint event\n"); /* begin drawing */ dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(widget)); if (dc == RT_NULL) { rt_kprintf("dc init failed\n"); return RT_FALSE; } /* get window rect */ rtgui_widget_get_rect(RTGUI_WIDGET(widget), &rect); RTGUI_DC_BC(dc) = white; rtgui_dc_fill_rect(dc, &rect); rtgui_dc_end_drawing(dc); return RT_FALSE; } else { return rtgui_win_event_handler(object, event); } }
static rt_bool_t rtgui_slider_onunfocus(struct rtgui_object* object, rtgui_event_t* event) { rtgui_rect_t rect; rtgui_widget_t *widget; struct rtgui_dc *dc; RT_ASSERT(object); widget = RTGUI_WIDGET(object); dc = rtgui_dc_begin_drawing(widget); if(dc == RT_NULL) return RT_FALSE; rtgui_widget_get_rect(widget, &rect); if(!RTGUI_WIDGET_IS_FOCUSED(widget)) { /* only clear focus rect */ rtgui_color_t color = RTGUI_DC_FC(dc); RTGUI_DC_FC(dc) = RTGUI_DC_BC(dc); rtgui_dc_draw_focus_rect(dc, &rect); RTGUI_DC_FC(dc) = color; } rtgui_dc_end_drawing(dc); return RT_TRUE; }
static void info_timer_timeout(rtgui_timer_t* timer, void* parameter) { struct rtgui_dc* dc; rtgui_color_t saved; dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(home_view)); if (dc == RT_NULL) return ; saved = RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(home_view)); RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(home_view)) = RTGUI_RGB(206, 231, 255); rtgui_dc_draw_hline(dc, 14, 14 + (tinfo.position * 212) / tinfo.duration, 75); if ((player_mode == PLAYER_PLAY_RADIO) && ((tinfo.position * 212 + 14)/tinfo.duration) < 226) { tinfo.position = net_buf_get_usage(); RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(home_view)) = RTGUI_RGB(82, 199, 16); rtgui_dc_draw_hline(dc, 14 + (tinfo.position * 212) / tinfo.duration, 226, 75); } RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(home_view)) = saved; if (player_mode == PLAYER_PLAY_FILE) { rtgui_color_t saved; rtgui_rect_t rect; char line[32]; play_time++; rt_snprintf(line, sizeof(line), "%3d:%02d", play_time / 60, play_time % 60); rect.x1 = 172; rect.y1 = 48; rect.x2 = 220; rect.y2 = rect.y1 + 16; saved = RTGUI_DC_BC(dc); RTGUI_DC_BC(dc) = RTGUI_RGB(0, 125, 198); rtgui_dc_fill_rect(dc, &rect); rtgui_dc_draw_text(dc, line, &rect); RTGUI_DC_BC(dc) = saved; } rtgui_dc_end_drawing(dc); }
static void app_list_pagemark_change(struct app_list_view *view) { rtgui_rect_t rect = {0, 0, PAGE_MARK_ITEM_WIDTH, PAGE_MARK_ITEM_HEIGHT}; if (view->current_page != view->old_page) { /* draw the current page mark */ rect.x1 = view->current_page * (PAGE_MARK_ITEM_WIDTH + PAGE_MARK_MARGIN); rect.x2 = rect.x1 + PAGE_MARK_ITEM_WIDTH; RTGUI_DC_BC(view->pm_buffer) = RTGUI_ARGB(0, 0, 0, 0); rtgui_dc_fill_rect(view->pm_buffer, &rect); rtgui_image_blit(ycircle_image, view->pm_buffer, &rect); /* draw the old page mark */ rect.x1 = view->old_page * (PAGE_MARK_ITEM_WIDTH + PAGE_MARK_MARGIN); rect.x2 = rect.x1 + PAGE_MARK_ITEM_WIDTH; RTGUI_DC_BC(view->pm_buffer) = RTGUI_ARGB(0, 0, 0, 0); rtgui_dc_fill_rect(view->pm_buffer, &rect); rtgui_image_blit(gcircle_image, view->pm_buffer, &rect); view->old_page = view->current_page; } }
void rtgui_scrollbar_hide(rtgui_scrollbar_t* bar) { rtgui_rect_t rect; struct rtgui_dc* dc; RT_ASSERT(bar != RT_NULL); /* begin drawing */ dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(bar)); if(dc == RT_NULL)return; RTGUI_WIDGET_HIDE(bar); /* begin drawing */ rtgui_widget_get_rect(RTGUI_WIDGET(bar), &rect); if((RTGUI_WIDGET(bar))->parent != RT_NULL) RTGUI_DC_BC(dc) = RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(bar)->parent); else RTGUI_DC_BC(dc) = RTGUI_RGB(225, 228, 220); rtgui_dc_fill_rect(dc,&rect); rtgui_dc_end_drawing(dc); }
static void snake_fill_lattice(struct rtgui_dc *dc, rt_uint32_t x, rt_uint32_t y, rtgui_color_t color) { struct rtgui_rect rect; // coordinate conversion y = (lattice_size_y - 1) - y; RTGUI_DC_BC(dc) = color; rect.x1 = lattice_rect.x1 + (LATTICE_SIZE * x); rect.x2 = rect.x1 + LATTICE_SIZE; rect.x1 += 2; rect.y1 = lattice_rect.y1 + (LATTICE_SIZE * y); rect.y2 = rect.y1 + LATTICE_SIZE; rect.y1 += 2; rtgui_dc_fill_rect(dc, &rect); }
/* 控件绘图函数 */ static void rtgui_mywidget_ondraw(struct rtgui_mywidget* me) { struct rtgui_dc* dc; struct rtgui_rect rect; rt_uint16_t x, y; /* 获得目标DC,开始绘�?*/ dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(me)); if (dc == RT_NULL) return; /* 获得窗口的尺�?*/ rtgui_widget_get_rect(RTGUI_WIDGET(me), &rect); /* 绘制背景�?*/ RTGUI_DC_BC(dc) = white; rtgui_dc_fill_rect(dc, &rect); /* 计算中心原点 */ x = (rect.x2 + rect.x1)/2; y = (rect.y2 + rect.y1)/2; /* 绘制十字�?*/ RTGUI_DC_FC(dc) = black; rtgui_dc_draw_hline(dc, rect.x1, rect.x2, y); rtgui_dc_draw_vline(dc, x, rect.y1, rect.y2); /* 根据状态绘制圆�?*/ if (me->status == MYWIDGET_STATUS_ON) RTGUI_DC_FC(dc) = green; else RTGUI_DC_FC(dc) = red; rtgui_dc_fill_circle(dc, x, y, 5); /* 结束绘图 */ rtgui_dc_end_drawing(dc); return; }
void rtgui_scrollbar_ondraw(rtgui_scrollbar_t* bar) { /* draw scroll bar */ rtgui_rect_t rect, btn_rect, thum_rect, arrow_rect; struct rtgui_dc* dc; rtgui_color_t bc; RT_ASSERT(bar != RT_NULL); /* begin drawing */ dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(bar)); if(dc == RT_NULL)return; bc = RTGUI_DC_BC(dc); /* begin drawing */ rtgui_widget_get_rect(RTGUI_WIDGET(bar), &rect); RTGUI_DC_BC(dc) = white; rtgui_dc_fill_rect(dc,&rect); RTGUI_DC_BC(dc) = bc; if(bar->orient == RTGUI_VERTICAL) { btn_rect = rect; btn_rect.y2 = btn_rect.y1 + (rect.x2 - rect.x1); rtgui_dc_fill_rect(dc,&btn_rect); /* draw up button */ if(bar->status & SBS_UPARROW) rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_SUNKEN); else rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_RAISE); /* draw up arrow */ arrow_rect.x1 = 0; arrow_rect.y1 = 0; arrow_rect.x2 = 7; arrow_rect.y2 = 4; rtgui_rect_moveto_align(&btn_rect, &arrow_rect, RTGUI_ALIGN_CENTER); rtgui_dc_draw_byte(dc, arrow_rect.x1, arrow_rect.y1, rtgui_rect_height(arrow_rect), _up_arrow); /* draw thumb */ rtgui_scrollbar_get_thumb_rect(bar, &thum_rect); rtgui_dc_fill_rect(dc,&thum_rect); rtgui_dc_draw_border(dc, &thum_rect, RTGUI_BORDER_RAISE); /* draw down button */ btn_rect.y1 = rect.y2 - (rect.x2 - rect.x1); btn_rect.y2 = rect.y2; rtgui_dc_fill_rect(dc,&btn_rect); if(bar->status & SBS_DOWNARROW) rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_SUNKEN); else rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_RAISE); /* draw down arrow */ arrow_rect.x1 = 0; arrow_rect.y1 = 0; arrow_rect.x2 = 7; arrow_rect.y2 = 4; rtgui_rect_moveto_align(&btn_rect, &arrow_rect, RTGUI_ALIGN_CENTER); rtgui_dc_draw_byte(dc, arrow_rect.x1, arrow_rect.y1, rtgui_rect_height(arrow_rect), _down_arrow); } else { btn_rect = rect; btn_rect.x2 = btn_rect.x1 + (rect.y2 - rect.y1); rtgui_dc_fill_rect(dc,&btn_rect); /* draw left button */ if(bar->status & SBS_LEFTARROW) rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_SUNKEN); else rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_RAISE); arrow_rect.x1 = 0; arrow_rect.y1 = 0; arrow_rect.x2 = 4; arrow_rect.y2 = 7; rtgui_rect_moveto_align(&btn_rect, &arrow_rect, RTGUI_ALIGN_CENTER); rtgui_dc_draw_byte(dc, arrow_rect.x1, arrow_rect.y1, rtgui_rect_height(arrow_rect), _left_arrow); /* draw thumb */ if(RTGUI_WIDGET_IS_ENABLE(bar)) { rtgui_scrollbar_get_thumb_rect(bar, &thum_rect); rtgui_dc_fill_rect(dc,&thum_rect); rtgui_dc_draw_border(dc, &thum_rect, RTGUI_BORDER_RAISE); } btn_rect.x1 = rect.x2 - (rect.y2-rect.y1); btn_rect.x2 = rect.x2; rtgui_dc_fill_rect(dc,&btn_rect); /* draw right button */ if(bar->status & SBS_RIGHTARROW) rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_SUNKEN); else rtgui_dc_draw_border(dc, &btn_rect, RTGUI_BORDER_RAISE); arrow_rect.x1 = 0; arrow_rect.y1 = 0; arrow_rect.x2 = 4; arrow_rect.y2 = 7; rtgui_rect_moveto_align(&btn_rect, &arrow_rect, RTGUI_ALIGN_CENTER); rtgui_dc_draw_byte(dc, arrow_rect.x1, arrow_rect.y1, rtgui_rect_height(arrow_rect), _right_arrow); } rtgui_dc_end_drawing(dc); }
static struct app_list_view *app_list_create(rtgui_rect_t *rect, struct app_item *items, rt_uint16_t item_count, rt_uint8_t row_items, rt_uint8_t col_items, rtgui_image_t *bg_image) { struct app_list_view *view = RT_NULL; view = (struct app_list_view *)rtgui_malloc(sizeof(struct app_list_view)); view->rect = *rect; view->view_rect.x1 = rect->x1; view->view_rect.x2 = rect->x2; view->view_rect.y1 = rect->y1 + 4 * LIST_MARGIN; view->view_rect.y2 = rect->y2 - 6 * LIST_MARGIN; view->col_items = col_items; view->row_items = row_items; view->current_page = 0; view->old_page = 0; view->page_items = col_items * row_items; view->page_count = (item_count + view->page_items - 1) / view->page_items; view->current_item = -1; view->items = items; view->items_count = item_count; if (bg_image != RT_NULL) { rtgui_rect_t bg_rect; RTGUI_RECT(bg_rect, 0, 0, bg_image->w, bg_image->h); /* create background dc buffer */ view->bg_buffer = rtgui_dc_buffer_create(bg_image->w, bg_image->h); /* draw background image to buffer */ rtgui_image_blit(bg_image, view->bg_buffer, &bg_rect); } /* create the main menu dc buffer */ view->view_buffer = rtgui_dc_buffer_create_pixformat(RTGRAPHIC_PIXEL_FORMAT_ARGB888, rtgui_rect_width(view->view_rect) * view->page_count, rtgui_rect_height(view->view_rect)); RTGUI_DC_BC(view->view_buffer) = RTGUI_ARGB(0, 0, 0, 0); view->pm_rect.x1 = 0; view->pm_rect.y1 = rect->y2 - 6 * LIST_MARGIN; view->pm_rect.x2 = PAGE_MARK_ITEM_WIDTH * view->page_count + PAGE_MARK_MARGIN * (view->page_count - 1); view->pm_rect.y2 = view->pm_rect.y1 + PAGE_MARK_ITEM_HEIGHT; view->pm_buffer = rtgui_dc_buffer_create_pixformat(RTGRAPHIC_PIXEL_FORMAT_ARGB888, rtgui_rect_width(view->pm_rect) , rtgui_rect_height(view->pm_rect)); rtgui_rect_moveto_align(rect, &view->pm_rect, RTGUI_ALIGN_CENTER_HORIZONTAL); RTGUI_DC_BC(view->pm_buffer) = RTGUI_ARGB(0, 0, 0, 0); view->bgdisp_point.x = 0; view->bgdisp_point.y = 0; view->listdisp_point.x = 0; view->listdisp_point.y = 0; view->on_select = RT_NULL; return view; }
rt_bool_t rtgui_digtube_event_handler(struct rtgui_object *object, struct rtgui_event *event) { struct rtgui_digtube *digtube; struct rtgui_dc *dc; rtgui_rect_t rect; rtgui_rect_t text_rect; rtgui_color_t color = 0; char * disbuf; char tempbuf[8]; int i; RTGUI_WIDGET_EVENT_HANDLER_PREPARE digtube = RTGUI_DIGTUBE(object); switch (event->type) { case RTGUI_EVENT_PAINT: dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(object)); if (dc == RT_NULL) break; rtgui_widget_get_rect(RTGUI_WIDGET(object), &rect); rtgui_dc_fill_rect(dc, &rect); if (! (digtube->tube_style & RTGUI_DIGTUBE_STYLE_NOBACKFONT)) { color = RTGUI_DC_BC(dc); RTGUI_DC_BC(dc) = digtube->digit_bc; } if (digtube->tube_style & RTGUI_DIGTUBE_STYLE_DISCODES) disbuf = (char *) (digtube->value); else { const char * format = digtube->tube_style & RTGUI_DIGTUBE_STYLE_DISHEXNUM ? "%7x" : "%7d"; disbuf = &tempbuf[0]; rt_snprintf(disbuf, 8, format, digtube->value); /* */ for (i=0; i<7; i++) { if (disbuf[i] == ' ') disbuf[i] = 0; else { disbuf[i] = (disbuf[i] >= '0' && disbuf[i] <= '9') ? disbuf[i] - '0': disbuf[i] - 'a' + 10; disbuf[i] = digtube_code_table[disbuf[i]]; } } disbuf = tempbuf + 7 - digtube->tube_count; } text_rect.x1 = 0; text_rect.y1 = 0; text_rect.x2 = (digtube->digit_width + digtube->digit_space) * digtube->tube_count -digtube->digit_space; text_rect.y2 = digtube->digit_hight; rtgui_rect_moveto_align(&rect, &text_rect, RTGUI_DC_TEXTALIGN(dc)); for (i=0; i<digtube->tube_count; i++) { rtgui_dc_draw_digitfont_code(dc, &digtube->digitfont, &text_rect, disbuf[i]); text_rect.x1 += digtube->digit_width + digtube->digit_space; } if (! (digtube->tube_style & RTGUI_DIGTUBE_STYLE_NOBACKFONT)) RTGUI_DC_BC(dc) = color; rtgui_dc_end_drawing(dc); break; default: return rtgui_widget_event_handler(object, event); } return RT_FALSE; }
/* update fileview */ void rtgui_fileview_update_current(rtgui_fileview_t* fview) { rtgui_fileview_item_t *item; rtgui_rect_t rect, item_rect, image_rect; rtgui_dc_t *dc; RT_ASSERT(fview != RT_NULL); /* begin drawing */ dc = rtgui_dc_begin_drawing(fview); if(dc == RT_NULL)return; /* if directory is null, no dispost */ if(fview->items==RT_NULL)return; rtgui_widget_get_rect(fview, &rect); if(fview->sbar && !RTGUI_WIDGET_IS_HIDE(fview->sbar)) rect.x2 -= RC_W(fview->sbar->parent.extent); if((fview->old_item >= fview->first_item) && (fview->old_item < fview->first_item+fview->item_per_page) && (fview->old_item != fview->now_item)) { /* these condition dispell blinked when drawed */ /* get old item rect */ item_rect = rect; item_rect.x1 += RTGUI_WIDGET_BORDER_SIZE(fview); item_rect.x2 -= RTGUI_WIDGET_BORDER_SIZE(fview); item_rect.y1 += RTGUI_WIDGET_BORDER_SIZE(fview); item_rect.y1 += ((fview->old_item-fview->first_item) % fview->item_per_page) * (1 + RTGUI_SEL_H); item_rect.y2 = item_rect.y1 + (1 + RTGUI_SEL_H); /* get image rect */ image_rect.x1 = RTGUI_MARGIN; image_rect.y1 = 0; image_rect.x2 = RTGUI_MARGIN + file_image->w; image_rect.y2 = file_image->h; rtgui_rect_moveto_align(&item_rect, &image_rect, RTGUI_ALIGN_CENTER_VERTICAL); /* draw old item */ item = &(fview->items[fview->old_item]); if(item->type == RTGUI_FITEM_FILE) /* draw item image */ rtgui_image_paste(file_image, dc, &image_rect, Black); else rtgui_image_paste(folder_image, dc, &image_rect,Black); item_rect.x1 += RTGUI_MARGIN + file_image->w + 2; item_rect.x2 = item_rect.x1 + rtgui_font_get_string_width(RTGUI_DC_FONT(dc), item->name); RTGUI_DC_BC(dc) = theme.blankspace; RTGUI_DC_FC(dc) = theme.foreground; rtgui_dc_fill_rect(dc,&item_rect); rtgui_dc_draw_text(dc, item->name, &item_rect); } /* draw current item */ item_rect = rect; item_rect.x1 += RTGUI_WIDGET_BORDER_SIZE(fview); item_rect.x2 -= RTGUI_WIDGET_BORDER_SIZE(fview); item_rect.y1 += RTGUI_WIDGET_BORDER_SIZE(fview); item_rect.y1 += ((fview->now_item-fview->first_item) % fview->item_per_page) * (1 + RTGUI_SEL_H); item_rect.y2 = item_rect.y1 + (1 + RTGUI_SEL_H); /* get image base rect */ image_rect.x1 = RTGUI_MARGIN; image_rect.y1 = 0; image_rect.x2 = RTGUI_MARGIN + file_image->w; image_rect.y2 = file_image->h; rtgui_rect_moveto_align(&item_rect, &image_rect, RTGUI_ALIGN_CENTER_VERTICAL); item = &(fview->items[fview->now_item]); if(item->type == RTGUI_FITEM_FILE) /* draw item image */ rtgui_image_paste(file_image, dc, &image_rect, Black); else rtgui_image_paste(folder_image, dc, &image_rect, Black); if(fview->dlg != RT_NULL) { if(fview->dlg->filename != RT_NULL) { rt_free(fview->dlg->filename); fview->dlg->filename = RT_NULL; } fview->dlg->filename = rt_strdup(item->name); } item_rect.x1 += RTGUI_MARGIN + file_image->w + 2; item_rect.x2 = item_rect.x1 + rtgui_font_get_string_width(RTGUI_DC_FONT(dc), item->name); { if(RTGUI_WIDGET_IS_FOCUSED(fview)) { RTGUI_DC_BC(dc) = DarkBlue; RTGUI_DC_FC(dc) = theme.blankspace; } else { RTGUI_DC_BC(dc) = Gray; RTGUI_DC_FC(dc) = theme.foreground; } rtgui_dc_fill_rect(dc, &item_rect); rtgui_dc_draw_text(dc, item->name, &item_rect); } if(fview->dlg != RT_NULL) { if(item->type == RTGUI_FITEM_FILE) { if(fview->dlg->tbox_filename != RT_NULL) { rtgui_textbox_set_value(fview->dlg->tbox_filename,fview->dlg->filename); RTGUI_DC_FC(dc) = theme.foreground; rtgui_textbox_ondraw(fview->dlg->tbox_filename); } } } rtgui_dc_end_drawing(dc); }
void rtgui_fileview_ondraw(rtgui_fileview_t* fview) { rt_uint16_t first, i,rx2; rtgui_fileview_item_t* item; rtgui_rect_t rect, item_rect, image_rect; rtgui_dc_t* dc; RT_ASSERT(fview != RT_NULL); /* begin drawing */ dc = rtgui_dc_begin_drawing(fview); if(dc == RT_NULL)return; rtgui_widget_get_rect(fview, &rect); rtgui_dc_draw_border(dc, &rect,RTGUI_WIDGET_BORDER_STYLE(fview)); rtgui_rect_inflate(&rect,-RTGUI_WIDGET_BORDER_SIZE(fview)); RTGUI_DC_BC(dc) = theme.blankspace; rtgui_dc_fill_rect(dc,&rect); rtgui_rect_inflate(&rect,RTGUI_WIDGET_BORDER_SIZE(fview)); if(fview->sbar && !RTGUI_WIDGET_IS_HIDE(fview->sbar)) rect.x2 -= RC_W(fview->sbar->parent.extent); rect.x2 -=1; rect.y2 -= 1; /* get item base rect */ item_rect = rect; item_rect.x1 += RTGUI_WIDGET_BORDER_SIZE(fview); item_rect.x2 -= RTGUI_WIDGET_BORDER_SIZE(fview); rx2 = item_rect.x2; item_rect.y1 += RTGUI_WIDGET_BORDER_SIZE(fview); item_rect.y2 = item_rect.y1 + (1 + RTGUI_SEL_H); /* get image base rect */ image_rect.x1 = RTGUI_MARGIN; image_rect.y1 = 0; image_rect.x2 = RTGUI_MARGIN + file_image->w; image_rect.y2 = file_image->h; rtgui_rect_moveto_align(&item_rect, &image_rect, RTGUI_ALIGN_CENTER_VERTICAL); /* get current page */ first = fview->first_item; for(i = 0; i < fview->item_per_page; i ++) { char str_size[32]; if(first + i >= fview->item_count) break; item = &(fview->items[first + i]); /* draw item image */ if(item->type == RTGUI_FITEM_FILE) rtgui_image_paste(file_image, dc, &image_rect, Black); else rtgui_image_paste(folder_image, dc, &image_rect, Black); /* draw text */ item_rect.x1 += RTGUI_MARGIN + file_image->w + 2; item_rect.x2 = item_rect.x1 + rtgui_font_get_string_width(RTGUI_DC_FONT(dc), item->name); if(first + i == fview->now_item) { if(RTGUI_WIDGET_IS_FOCUSED(fview)) { RTGUI_DC_BC(dc) = DarkBlue; RTGUI_DC_FC(dc) = theme.blankspace; } else { RTGUI_DC_BC(dc) = Gray; RTGUI_DC_FC(dc) = theme.foreground; } rtgui_dc_fill_rect(dc, &item_rect); rtgui_dc_draw_text(dc, item->name, &item_rect); } else { /* draw background */ RTGUI_DC_BC(dc) = theme.blankspace; RTGUI_DC_FC(dc) = theme.foreground; rtgui_dc_fill_rect(dc,&item_rect); rtgui_dc_draw_text(dc, item->name, &item_rect); } #if (1) /* please turn off it when need. */ if(item->type == RTGUI_FITEM_FILE) { rtgui_rect_t rect=item_rect; /* print file information */ rt_snprintf(str_size, 16, "(%dB)",item->size); rect.x1 = rect.x2 + RTGUI_MARGIN; rect.x2 = rect.x1 + rt_strlen(str_size) * FONT_W(RTGUI_WIDGET_FONT(fview)); RTGUI_DC_FC(dc) = theme.foreground; rtgui_dc_draw_text(dc, str_size, &rect); } #endif item_rect.x1 -= RTGUI_MARGIN + file_image->w + 2; item_rect.x2 = rx2; /* move to next item position */ item_rect.y1 += (RTGUI_SEL_H + 1); item_rect.y2 += (RTGUI_SEL_H + 1); image_rect.y1 += (RTGUI_SEL_H + 1); image_rect.y2 += (RTGUI_SEL_H + 1); } if(fview->sbar && !RTGUI_WIDGET_IS_HIDE(fview->sbar)) { rtgui_scrollbar_ondraw(fview->sbar); } rtgui_dc_end_drawing(dc); }
void rtgui_theme_draw_progressbar(struct rtgui_progressbar* bar) { /* draw progress bar */ struct rtgui_dc* dc; struct rtgui_rect rect; int max = bar->range; int pos = bar->position; int left; rtgui_color_t bc; /* begin drawing */ dc = rtgui_dc_begin_drawing(&(bar->parent)); if (dc == RT_NULL) return; bc = RTGUI_DC_BC(dc); rtgui_widget_get_rect(&(bar->parent), &rect); /* fill button rect with background color */ bar->parent.gc.background = RTGUI_RGB(212, 208, 200); /* draw border */ rect.x2 --; rect.y2 --; rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_SUNKEN); /* Nothing to draw */ if (max == 0) { rtgui_dc_end_drawing(dc); return; } rect.x2 ++; rect.y2 ++; left = max - pos; rtgui_rect_inflate(&rect, -2); bar->parent.gc.background = RTGUI_RGB(0, 0, 255); if (bar->orient == RTGUI_VERTICAL) { /* Vertical bar grows from bottom to top */ int dy = (rtgui_rect_height(rect) * left) / max; rect.y1 += dy; rtgui_dc_fill_rect(dc, &rect); RTGUI_DC_BC(dc) = bc; rect.y1 -= dy; rect.y2 = dy; rtgui_dc_fill_rect(dc, &rect); } else { /* Horizontal bar grows from left to right */ int dx = (rtgui_rect_width(rect) * left) / max; rect.x2 -= dx; rtgui_dc_fill_rect(dc, &rect); RTGUI_DC_BC(dc) = bc; rect.x1 = rect.x2; rect.x2 += dx; rtgui_dc_fill_rect(dc, &rect); } /* end drawing */ rtgui_dc_end_drawing(dc); return; }
/* * container的事件处理函数 */ rt_bool_t instrument_panel_event_handler(struct rtgui_object *object, rtgui_event_t *event) { struct rtgui_widget *widget = RTGUI_WIDGET(object); char ac[4]; int i; int x0 = 120; int y0 = 170; int x, y; int default_color; /* 仅对PAINT事件进行处理 */ if (event->type == RTGUI_EVENT_PAINT) { struct rtgui_dc *dc; rtgui_rect_t rect; const int arrowx[] = {120 + 75, 120 + 75, 120 + 85}; const int arrowy[] = {170 - 5, 170 + 5, 170}; /* * 因为用的是demo container,上面本身有一部分控件,所以在绘图时先要让demo container * 先绘图 */ rtgui_container_event_handler(RTGUI_OBJECT(widget), event); /************************************************************************/ /* 下面的是DC的操作 */ /************************************************************************/ /* 获得控件所属的DC */ dc = rtgui_dc_begin_drawing(widget); /* 如果不能正常获得DC,返回(如果控件或父控件是隐藏状态,DC是获取不成功的) */ if (dc == RT_NULL) return RT_FALSE; /* 获得demo container允许绘图的区域 */ demo_view_get_rect(RTGUI_CONTAINER(widget), &rect); RTGUI_DC_TEXTALIGN(dc) = RTGUI_ALIGN_BOTTOM | RTGUI_ALIGN_CENTER_HORIZONTAL; /* 显示GUI的版本信息 */ #ifdef RTGUI_USING_SMALL_SIZE rtgui_dc_draw_text(dc, "RT-Thread/GUI小型版本", &rect); #else rtgui_dc_draw_text(dc, "RT-Thread/GUI标准版本", &rect); #endif RTGUI_DC_TEXTALIGN(dc) = RTGUI_ALIGN_CENTER_VERTICAL | RTGUI_ALIGN_CENTER_HORIZONTAL; RTGUI_DC_FC(dc) = blue; rect.y2 = 270; rtgui_dc_draw_text(dc, "rtgui-panel", &rect); for (i = 0; i < 6; i++) { rtgui_dc_draw_arc(dc, x0, y0, 117 - i, 150, 30); } RTGUI_DC_FC(dc) = black; RTGUI_DC_TEXTALIGN(dc) = RTGUI_ALIGN_LEFT; for (i = 0; i <= 23; i++) { if (i < 12) { x = x0 + 105 * cos((150 + i * 10) * 3.1415926 / 180); y = y0 + 105 * sin((150 + i * 10) * 3.1415926 / 180); rect.x1 = x; rect.y1 = y; rect.x2 = rect.x1 + 12 * 3; rect.y2 = rect.y1 + 12; rt_sprintf(ac, "%d", 10 * i); rtgui_dc_draw_text(dc, ac, &rect); } else { RTGUI_DC_TEXTALIGN(dc) = RTGUI_ALIGN_RIGHT; x = x0 + 105 * cos((160 + i * 10) * 3.1415926 / 180); y = y0 + 105 * sin((160 + i * 10) * 3.1415926 / 180); rect.x1 = x - 12 * 3; rect.y1 = y; rect.x2 = rect.x1 + 12 * 3; rect.y2 = rect.y1 + 12; rt_sprintf(ac, "%d", 10 * i); rtgui_dc_draw_text(dc, ac, &rect); } x = x0 + 107 * cos((150 + i * 10) * 3.1415926 / 180); y = y0 + 107 * sin((150 + i * 10) * 3.1415926 / 180); rtgui_dc_fill_circle(dc, x, y, 3); } RTGUI_DC_FC(dc) = RTGUI_RGB(166, 0, 166); rtgui_dc_fill_circle(dc, x0, y0, 3); RTGUI_DC_FC(dc) = RTGUI_RGB(120, 141, 30); rtgui_dc_draw_circle(dc, x0, y0, 5); default_color = RTGUI_DC_BC(dc); RTGUI_DC_BC(dc) = red; rect.x1 = x0 + 7; rect.y1 = y0 - 1; rect.x2 = x0 + 75; rect.y2 = y0 + 1; rtgui_dc_fill_rect(dc, &rect); RTGUI_DC_BC(dc) = default_color; rtgui_dc_fill_polygon(dc, arrowx, arrowy, 3); /* 绘图完成 */ rtgui_dc_end_drawing(dc); } else { /* 其他事件,调用默认的事件处理函数 */ return rtgui_container_event_handler(RTGUI_OBJECT(widget), event); } return RT_FALSE; }
void rtgui_edit_ondraw(struct rtgui_edit *edit) { rtgui_rect_t rect, r; struct rtgui_dc *dc; #ifdef RTGUI_EDIT_USING_SCROLL int hscroll_flag=0; int vscroll_flag=0; #endif RT_ASSERT(edit != RT_NULL); dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(edit)); if(dc == RT_NULL) return; /* get widget rect */ rtgui_widget_get_rect(RTGUI_WIDGET(edit), &rect); rtgui_rect_inflate(&rect, -RTGUI_WIDGET_BORDER_SIZE(edit)); /* fill widget rect with edit background color */ RTGUI_DC_BC(dc) = RTGUI_WIDGET_BC(edit); rtgui_dc_fill_rect(dc, &rect); rtgui_rect_inflate(&rect, RTGUI_WIDGET_BORDER_SIZE(edit)); /* draw border */ rtgui_dc_draw_border(dc, &rect, RTGUI_WIDGET_BORDER_STYLE(edit)); rtgui_rect_inflate(&rect, -(edit->margin + RTGUI_WIDGET_BORDER_SIZE(edit))); #ifdef RTGUI_EDIT_USING_SCROLL if(edit->vscroll && !RTGUI_WIDGET_IS_HIDE(edit->vscroll)) { rect.x2 = rect.x2 - rtgui_rect_width(edit->vscroll->parent.extent); } if(edit->hscroll && !RTGUI_WIDGET_IS_HIDE(edit->hscroll)) { rect.y2 = rect.y2 - rtgui_rect_height(edit->hscroll->parent.extent); } #endif r = rect; /* draw text */ if(edit->head != RT_NULL) { struct edit_line *line = edit->first_line; int num=0; rect.y2 = rect.y1 + edit->item_height; while(line) { rt_uint32_t tmp_pos=0, ofs; char *str = line->text+edit->upleft.x; if(edit->upleft.x < line->len) { rtgui_point_t p = edit->visual; edit->visual.x = 0; identify_double_byte(edit, line, EDIT_IDENT_DIR_LEFT, &tmp_pos); ofs = tmp_pos % 2; if(ofs == 1) { char dbl_bmp[3]; rtgui_point_t pot = {0}; rtgui_rect_t r = {0}; pot.x = edit->font_width; r.x2 = edit->font_width*2; r.y2 = edit->font_height; dbl_bmp[0] = *(str-1); dbl_bmp[1] = *str; dbl_bmp[2] = '\0'; RTGUI_DC_BC(edit->dbl_buf) = RTGUI_WIDGET_BC(edit); rtgui_dc_fill_rect(edit->dbl_buf, &r); RTGUI_DC_FC(edit->dbl_buf) = RTGUI_WIDGET_FC(edit); rtgui_dc_draw_text(edit->dbl_buf, dbl_bmp, &r); rtgui_dc_blit(edit->dbl_buf, pot.x, pot.y, dc, rect.x1, rect.y1, edit->font_width, edit->font_height); } rect.x1 += ofs * edit->font_width; rtgui_dc_draw_text(dc, line->text+edit->upleft.x+ofs, &rect); rect.x1 -= ofs * edit->font_width; edit->visual = p; } line = line->next; rect.y1 += edit->item_height; if((rect.y1 + edit->item_height) < r.y2) rect.y2 = rect.y1 + edit->item_height; else rect.y2 = r.y2; if(num++ >= edit->row_per_page) break; } } #ifdef RTGUI_EDIT_USING_SCROLL if(edit->hscroll && !RTGUI_WIDGET_IS_HIDE(edit->hscroll)) { hscroll_flag = 1; rtgui_scrollbar_ondraw(edit->hscroll); } if(edit->vscroll && !RTGUI_WIDGET_IS_HIDE(edit->vscroll)) { vscroll_flag = 1; rtgui_scrollbar_ondraw(edit->vscroll); } if(hscroll_flag && vscroll_flag) { rtgui_color_t _bc; rtgui_widget_get_rect(RTGUI_WIDGET(edit), &rect); rect.x1 = rect.x2-RTGUI_WIDGET_BORDER_SIZE(edit); rect.y1 = rect.y2-RTGUI_WIDGET_BORDER_SIZE(edit); _bc = RTGUI_DC_BC(dc); RTGUI_DC_BC(dc) = theme.background; rtgui_dc_fill_rect(dc,&rect); RTGUI_DC_BC(dc) = _bc; } #endif rtgui_dc_end_drawing(dc); }
static void snake_draw(struct rtgui_widget *widget) { struct rtgui_dc *dc; struct rtgui_rect rect; rt_uint32_t i; dc = rtgui_dc_begin_drawing(widget); if (dc == RT_NULL) { rt_kprintf("dc == RT_NULL\r\n"); return; } /* get room size, run once frist. */ if ((room_size_x == 0) || (room_size_y == 0)) { rt_size_t tmp; rtgui_widget_get_rect(widget, &rect); rt_kprintf("rect => x1:%d x2:%d, y1:%d y2:%d\r\n", rect.x1, rect.x2, rect.y1, rect.y2); room_size_x = rect.x2 - rect.x1; room_size_y = rect.y2 - rect.y1; memcpy(&room_rect, &rect, sizeof(struct rtgui_rect)); rt_kprintf("room_rect => x1:%d x2:%d, y1:%d y2:%d\r\n", room_rect.x1, room_rect.x2, room_rect.y1, room_rect.y2); lattice_size_x = (room_rect.x2 - room_rect.x1) / LATTICE_SIZE; lattice_size_y = (room_rect.y2 - room_rect.y1) / LATTICE_SIZE; lattice_size_x -= 2; lattice_size_y -= 2; rt_kprintf("lattice_size_x:%d lattice_size_y:%d\r\n", lattice_size_x, lattice_size_y); tmp = (room_rect.x2 - room_rect.x1) - (LATTICE_SIZE * lattice_size_x); lattice_rect.x1 = room_rect.x1 + (tmp / 2); lattice_rect.x2 = lattice_rect.x1 + (LATTICE_SIZE * lattice_size_x); tmp = (room_rect.y2 - room_rect.y1) - (LATTICE_SIZE * lattice_size_y); lattice_rect.y1 = room_rect.y1 + (tmp / 2); lattice_rect.y2 = lattice_rect.y1 + (LATTICE_SIZE * lattice_size_y); rt_kprintf("lattice_rect => x1:%d x2:%d, y1:%d y2:%d\r\n", lattice_rect.x1, lattice_rect.x2, lattice_rect.y1, lattice_rect.y2); /* create snake. */ { point_t start; map = map_init(lattice_size_x, lattice_size_y); if (map != RT_NULL) { start.x = snake_init_pointx; start.y = snake_init_pointy; run_state = SNAKE_DIR_DOWN; if (snake_init(&start, snake_length_init, run_state, map)) { food_num = 1; food_init(map, food_num); } else { map_deinit(map); map = RT_NULL; } } } } RTGUI_DC_BC(dc) = BACKGROUND_COLOR; rtgui_dc_fill_rect(dc, &room_rect); memcpy(&rect, &lattice_rect, sizeof(struct rtgui_rect)); rect.x2 += 1; rect.y2 += 1; RTGUI_DC_FC(dc) = WALL_COLOR; rtgui_dc_draw_rect(dc, &rect); for (i = 1; i < lattice_size_y; i++) { memcpy(&rect, &lattice_rect, sizeof(struct rtgui_rect)); rect.x1 += 1; rect.x2 -= 1; rtgui_dc_draw_horizontal_line(dc, rect.x1, rect.x2, rect.y1 + (LATTICE_SIZE * i)); } for (i = 1; i < lattice_size_x; i++) { memcpy(&rect, &lattice_rect, sizeof(struct rtgui_rect)); rect.y1 += 1; rect.y2 -= 1; rtgui_dc_draw_vertical_line(dc, rect.x1 + (LATTICE_SIZE * i), rect.y1, rect.y2); } /* draw snake. */ { rt_int32_t x, y; rt_bool_t first_node = RT_TRUE; for (y = 0; y < map->height; y++) { for (x = 0; x < map->width; x++) { switch (map->range[y * map->width + x]) { case NORMAL: break; case FOOD: snake_fill_lattice(dc, x, y, FOOD_COLOR); break; case OVER: if (first_node) { first_node = RT_FALSE; second_node.x = x; second_node.y = y; snake_fill_lattice(dc, x, y, SNAKE_HEAD_COLOR); } else { snake_fill_lattice(dc, x, y, SNAKE_COLOR); } break; } } } } rtgui_dc_end_drawing(dc); return; }
static void rtgui_image_png_blit(struct rtgui_image *image, struct rtgui_dc *dc, struct rtgui_rect *rect) { rt_uint16_t x, y, w, h; rtgui_color_t *ptr; struct rtgui_image_png *png; int fg_maxsample; int ialpha; float alpha; rtgui_color_t color; rtgui_color_t c, bgcolor; int fc[3], bc[3]; struct rtgui_graphic_driver *hwdev = rtgui_graphic_get_device(); RT_ASSERT(image != RT_NULL && dc != RT_NULL && rect != RT_NULL); RT_ASSERT(image->data != RT_NULL); png = (struct rtgui_image_png *) image->data; w = _UI_MIN(image->w, rtgui_rect_width(*rect)); h = _UI_MIN(image->h, rtgui_rect_height(*rect)); fg_maxsample = (1 << png->info_ptr->bit_depth) - 1; if (png->pixels != RT_NULL) { ptr = (rtgui_color_t *)png->pixels; bgcolor = RTGUI_DC_BC(dc); bc[0] = RTGUI_RGB_R(bgcolor); bc[1] = RTGUI_RGB_G(bgcolor); bc[2] = RTGUI_RGB_B(bgcolor); /* draw each point within dc */ for (y = 0; y < h; y ++) { for (x = 0; x < w; x++) { c = *ptr; ialpha = RTGUI_RGB_A(c); if (ialpha == 0) { /* * Foreground image is transparent hear. * If the background image is already in the frame * buffer, there is nothing to do. */ } else if (ialpha == fg_maxsample) { /* * Copy foreground pixel to frame buffer. */ rtgui_dc_draw_color_point(dc, x + rect->x1, y + rect->y1, c); } else { /* output = alpha * foreground + (1-alpha) * background */ /* * Compositing is necessary. * Get floating-point alpha and its complement. * Note: alpha is always linear: gamma does not * affect it. */ fc[0] = RTGUI_RGB_R(c); fc[1] = RTGUI_RGB_G(c); fc[2] = RTGUI_RGB_B(c); alpha = (float) ialpha / fg_maxsample; color = RTGUI_RGB((rt_uint8_t)(fc[0] * alpha + bc[0] * (1 - alpha)), (rt_uint8_t)(fc[1] * alpha + bc[1] * (1 - alpha)), (rt_uint8_t)(fc[2] * alpha + bc[2] * (1 - alpha))); rtgui_dc_draw_color_point(dc, x + rect->x1, y + rect->y1, color); } /* move to next color buffer */ ptr ++; } } } else { png_bytep row; png_bytep data; row = (png_bytep) rtgui_malloc(png_get_rowbytes(png->png_ptr, png->info_ptr)); if (row == RT_NULL) return ; switch (png->info_ptr->color_type) { case PNG_COLOR_TYPE_RGB: for (y = 0; y < h; y++) { png_read_row(png->png_ptr, row, png_bytep_NULL); for (x = 0; x < w; x++) { data = &(row[x * 3]); rtgui_dc_draw_color_point(dc, x + rect->x1, y + rect->y1, RTGUI_RGB(data[0], data[1], data[2])); } } break; case PNG_COLOR_TYPE_RGBA: for (y = 0; y < h; y++) { png_read_row(png->png_ptr, row, png_bytep_NULL); for (x = 0; x < w; x++) { data = &(row[x * 4]); if (data[3] != 0) { rtgui_dc_draw_color_point(dc, x + rect->x1, y + rect->y1, RTGUI_ARGB(data[3], data[0], data[1], data[2])); } } } break; case PNG_COLOR_TYPE_PALETTE: for (y = 0; y < h; y++) { png_read_row(png->png_ptr, row, png_bytep_NULL); for (x = 0; x < w; x++) { data = &(row[x]); rtgui_dc_draw_color_point(dc, x + rect->x1, y + rect->y1, RTGUI_ARGB(0, png->info_ptr->palette[data[0]].red, png->info_ptr->palette[data[0]].green, png->info_ptr->palette[data[0]].blue)); } } default: break; }; rtgui_free(row); } }
static void player_update_tag_info() { char line[32]; struct rtgui_dc* dc; rtgui_color_t bc, fc; rtgui_rect_t rect; rtgui_image_t *button; /* get dc */ dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(home_view)); if (dc == RT_NULL) return; /* save old foreground and background color */ fc = RTGUI_DC_FC(dc); bc = RTGUI_DC_BC(dc); /* draw playing information */ rect.x1 = 25; rect.y1 = 20; rect.x2 = 220; rect.y2 = rect.y1 + 16; RTGUI_DC_BC(dc) = RTGUI_RGB(0, 134, 206); rtgui_dc_fill_rect(dc, &rect); RTGUI_DC_FC(dc) = black; if (player_mode == PLAYER_STOP) { rt_snprintf(line, sizeof(line), "网络收音机"); rtgui_dc_draw_text(dc, line, &rect); } else rtgui_dc_draw_text(dc, tinfo.title, &rect); /* reset progress bar */ #if 0 if (tinfo.position != 0) { rt_snprintf(line, sizeof(line), "%3d:%02d", item->duration / 60, item->duration % 60); } else #endif { RTGUI_DC_FC(dc) = RTGUI_RGB(82, 199, 16); rtgui_dc_draw_hline(dc, 14, 226, 75); } rect.x1 = 25; rect.y1 = 48; rect.x2 = 220; rect.y2 = rect.y1 + 16; RTGUI_DC_BC(dc) = RTGUI_RGB(0, 125, 198); rtgui_dc_fill_rect(dc, &rect); RTGUI_DC_FC(dc) = black; if (player_mode == PLAYER_STOP) { rt_snprintf(line, sizeof(line), "radio.rt-thread.org"); rtgui_dc_draw_text(dc, line, &rect); } else { rtgui_dc_draw_text(dc, tinfo.artist, &rect); } if ((tinfo.duration != 0) && player_mode == PLAYER_PLAY_FILE) { play_time = 0; rect.x1 = 172; rt_snprintf(line, sizeof(line), " 0:00"); rtgui_dc_draw_text(dc, line, &rect); } /* update playing button */ if (player_mode == PLAYER_STOP) button = (rtgui_image_t*)&stop_image; else button = (rtgui_image_t*)&play_image; rect.x1 = 32; rect.y1 = 92; rect.x2 = 61; rect.y2 = 114; rtgui_image_blit(button, dc, &rect); RTGUI_DC_FC(dc) = fc; RTGUI_DC_BC(dc) = bc; rtgui_dc_end_drawing(dc); }