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); }
static void rtgui_combobox_ondraw(struct rtgui_combobox* box) { /* draw button */ rtgui_color_t bc; struct rtgui_dc* dc; struct rtgui_rect rect, r; /* begin drawing */ dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(box)); if (dc == RT_NULL) return; bc = RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(box)); /* get widget rect */ rtgui_widget_get_rect(RTGUI_WIDGET(box), &rect); RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(box)) = white; /* fill widget rect with background color */ rtgui_dc_fill_rect(dc, &rect); rtgui_dc_draw_rect(dc, &rect); /* draw current item */ if (box->current_item < box->items_count) { rect.x1 += 5; rtgui_dc_draw_text(dc, box->items[box->current_item].name, &rect); } /* restore background color */ RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(box)) = bc; /* draw pull down button */ rect.x1 = rect.x2 - RTGUI_COMBOBOX_BUTTON_WIDTH; rtgui_rect_inflate(&rect, -1); rtgui_dc_fill_rect(dc, &rect); if (box->pd_pressed == RT_TRUE) rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_SUNKEN); else rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_RAISE); r.x1 = 0; r.y1 = 0; r.x2 = 8; r.y2 = 4; rtgui_rect_moveto_align(&rect, &r, RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL); rtgui_dc_draw_byte(dc, r.x1, r.y1, 4, down_arrow); /* end drawing */ rtgui_dc_end_drawing(dc); return; }
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); }
static void rtgui_terminal_ondraw(rtgui_terminal_t *tma) { rtgui_dc_t* dc; rtgui_rect_t rect; char* str; rt_ubase_t i, item_height; item_height = FONT_H(RTGUI_WIDGET_FONT(tma)); dc = rtgui_dc_begin_drawing(tma); if(dc == RT_NULL) return ; /* get widget rect */ rtgui_widget_get_rect(tma, &rect); rtgui_rect_inflate(&rect,-RTGUI_WIDGET_BORDER_SIZE(tma)); rtgui_dc_fill_rect(dc,&rect); rtgui_rect_inflate(&rect,RTGUI_WIDGET_BORDER_SIZE(tma)); /* draw border */ rtgui_dc_draw_border(dc,&rect,RTGUI_WIDGET_BORDER_STYLE(tma)); rect.x1 += RTGUI_MARGIN+RTGUI_WIDGET_BORDER_SIZE(tma); rect.x2 -= RTGUI_MARGIN; rect.y1 += RTGUI_MARGIN; rect.y2 = rect.y1+item_height; for(i = tma->now_item; (i < tma->now_item + tma->item_per_page) && (i < tma->item_count); i++) { str = (char*)rtgui_terminal_getline(tma, i); rtgui_dc_draw_text(dc, str, &rect); rect.y1 += item_height; rect.y2 = rect.y1+item_height; } rtgui_dc_end_drawing(dc); }
rt_bool_t demo_bitmap_showbox(struct rtgui_object* object, struct rtgui_event* event) { rtgui_container_t *container; rtgui_widget_t *widget; RT_ASSERT(object != RT_NULL); container = RTGUI_CONTAINER(object); widget = RTGUI_WIDGET(object); if(event->type == RTGUI_EVENT_PAINT) { int w, h; rtgui_rect_t rect; struct rtgui_dc *dc; struct rtgui_image *image = bmpdt.showimg; /* 如果从其他标签切换到当前标签, image应该是RT_NULL, 重置它 */ if(image == RT_NULL && bmpdt.image != RT_NULL) { image = bmpdt.image; bmpdt.scale = 1.0f; bmpdt.angle = 0.0f; rtgui_widget_get_rect(RTGUI_WIDGET(bmpdt.showbox), &bmpdt.lastrect); rtgui_rect_inflate(&bmpdt.lastrect, -RTGUI_WIDGET_BORDER(bmpdt.showbox)); } dc = rtgui_dc_begin_drawing(widget); if (dc == RT_NULL) return RT_FALSE; rtgui_widget_get_rect(widget, &rect); /* 在绘制边框后, 再将rect缩小填充背景, 可以降低闪烁现象 */ rtgui_dc_draw_border(dc, &rect, RTGUI_WIDGET_BORDER_STYLE(widget)); rtgui_rect_inflate(&rect, -RTGUI_WIDGET_BORDER(widget)); w = rtgui_rect_width(bmpdt.lastrect); h = rtgui_rect_height(bmpdt.lastrect); if(w > rtgui_rect_width(rect)) w = rtgui_rect_width(rect); if(h > rtgui_rect_height(rect)) h = rtgui_rect_height(rect); /* fill container with background */ /* * 参数lastrect会记录上一次绘图所用区域 * 每次重绘时,只需与lastrect比较,即可得知那些背景区域需要刷新 * 例如当放大图片时,lastrect比当前绘图区小,所有无需更新背景区, * 当缩小图片时, 也仅需要更新绘图区比lastrect大的区域. */ if(image != RT_NULL) { /* 减少不必要的绘图 */ rtgui_rect_t rc; if(w > image->w) { rc.x1 = image->w; rc.y1 = bmpdt.lastrect.y1; rc.x2 = bmpdt.lastrect.x2; rc.y2 = (h > image->h) ? image->h : bmpdt.lastrect.y2; rtgui_dc_fill_rect(dc, &rc); } if(h > image->h) { rc.x1 = bmpdt.lastrect.x1; rc.y1 = image->h; rc.x2 = bmpdt.lastrect.x2; rc.y2 = bmpdt.lastrect.y2; rtgui_dc_fill_rect(dc, &rc); } } else rtgui_dc_fill_rect(dc, &bmpdt.lastrect); /* 将图像数据blit到画布上 */ if (image != RT_NULL) { int value; rtgui_image_blit(image, dc, &rect); bmpdt.lastrect.x1 = bmpdt.lastrect.y1 = RTGUI_WIDGET_BORDER(bmpdt.showbox); if(image->w > rtgui_rect_width(rect)) value = rtgui_rect_width(rect); else value = image->w; bmpdt.lastrect.x2 = bmpdt.lastrect.x1 + value; if(image->h > rtgui_rect_height(rect)) value = rtgui_rect_height(rect); else value = image->h; bmpdt.lastrect.y2 = bmpdt.lastrect.y1 + value; } rtgui_dc_end_drawing(dc); return RT_FALSE; } return rtgui_container_event_handler(object, event); }
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; }
void rtgui_theme_draw_scrollbar(struct rtgui_scrollbar* bar) { /* draw scroll bar */ struct rtgui_dc* dc; rtgui_rect_t rect, btn_rect, thum_rect, arrow_rect; rtgui_color_t bc, fc; /* begin drawing */ dc = rtgui_dc_begin_drawing(&(bar->parent)); if (dc == RT_NULL) return; rtgui_widget_get_rect(RTGUI_WIDGET(bar), &rect); /* draw background */ fc = RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(bar)); if (!RTGUI_WIDGET_IS_ENABLE(RTGUI_WIDGET(bar))) RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(bar)) = RTGUI_RGB(128, 128, 128); bc = RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(bar)); RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(bar)) = white; rtgui_dc_fill_rect(dc, &rect); RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(bar)) = bc; if (bar->orient == RTGUI_VERTICAL) { btn_rect = rect; btn_rect.y2 = btn_rect.y1 + (rect.x2 - rect.x1); /* draw up button */ rtgui_dc_fill_rect(dc, &btn_rect); 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 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_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL); rtgui_dc_draw_byte(dc, arrow_rect.x1, arrow_rect.y1, rtgui_rect_height(arrow_rect), _up_arrow); /* draw thumb */ if (RTGUI_WIDGET_IS_ENABLE(RTGUI_WIDGET(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); } /* 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); 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_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL); rtgui_dc_draw_byte(dc, arrow_rect.x1, arrow_rect.y1, rtgui_rect_height(arrow_rect), _down_arrow); } else { btn_rect.x1 = rect.x1; btn_rect.y1 = rect.y1; btn_rect.x2 = rect.y2; btn_rect.y2 = rect.y2; /* draw left button */ rtgui_dc_fill_rect(dc, &btn_rect); 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_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL); 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(RTGUI_WIDGET(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; btn_rect.x2 = rect.x2; /* draw right button */ rtgui_dc_fill_rect(dc, &btn_rect); 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_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL); rtgui_dc_draw_byte(dc, arrow_rect.x1, arrow_rect.y1, rtgui_rect_height(arrow_rect), _right_arrow); } /* end drawing */ rtgui_dc_end_drawing(dc); RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(bar)) = fc; return; }
void rtgui_theme_draw_slider(struct rtgui_slider* slider) { /* draw button */ struct rtgui_dc* dc; int i, xsize, x0; rtgui_rect_t r, focus_rect, slider_rect, slot_rect; /* begin drawing */ dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(slider)); if (dc == RT_NULL) return; /* get widget rect */ rtgui_widget_get_rect(RTGUI_WIDGET(slider), &focus_rect); /* fill widget rect with background color */ rtgui_dc_fill_rect(dc, &focus_rect); r = focus_rect; if (slider->orient == RTGUI_VERTICAL) { rtgui_rect_inflate(&r, -1); xsize = r.y2 - r.y1 + 1 - slider->thumb_width; x0 = r.y1 + slider->thumb_width / 2; /* calculate thumb position */ slider_rect = r; slider_rect.x1 = 5; slider_rect.y1 = x0 + xsize * (slider->value - slider->min) / (slider->max - slider->min) - slider->thumb_width/2; slider_rect.y2 = slider_rect.y1 + slider->thumb_width; /* calculate slot position */ slot_rect.y1 = x0; slot_rect.y2 = x0 + xsize; slot_rect.x1 = (slider_rect.x1 + slider_rect.x2) /2 -1; slot_rect.x2 = slot_rect.x1 +3; /* draw slot */ rtgui_dc_draw_border(dc, &slot_rect, RTGUI_BORDER_RAISE); /* draw the ticks */ for (i = 0; i <= slider->ticks; i++) { int x = x0 + xsize * i / slider->ticks; rtgui_dc_draw_hline(dc, 1, 3, x); } /* draw the thumb */ rtgui_dc_fill_rect(dc, &slider_rect); rtgui_dc_draw_border(dc, &slider_rect, RTGUI_BORDER_RAISE); } else { rtgui_rect_inflate(&r, -1); xsize = r.x2 - r.x1 + 1 - slider->thumb_width; x0 = r.x1 + slider->thumb_width / 2; /* calculate thumb position */ slider_rect = r; slider_rect.y1 = 5; slider_rect.x1 = x0 + xsize * (slider->value - slider->min) / (slider->max - slider->min) - slider->thumb_width/2; slider_rect.x2 = slider_rect.x1 + slider->thumb_width; /* calculate slot position */ slot_rect.x1 = x0; slot_rect.x2 = x0 + xsize; slot_rect.y1 = (slider_rect.y1 + slider_rect.y2) /2 -1; slot_rect.y2 = slot_rect.y1 +3; /* draw slot */ rtgui_dc_draw_border(dc, &slot_rect, RTGUI_BORDER_RAISE); /* draw the ticks */ for (i = 0; i <= slider->ticks; i++) { int x = x0 + xsize * i / slider->ticks; rtgui_dc_draw_vline(dc, x, 1, 3); } /* draw the thumb */ rtgui_dc_fill_rect(dc, &slider_rect); rtgui_dc_draw_border(dc, &slider_rect, RTGUI_BORDER_RAISE); } /* draw focus */ if (RTGUI_WIDGET_IS_FOCUSED(RTGUI_WIDGET(slider))) { rtgui_dc_draw_focus_rect(dc, &focus_rect); } /* end drawing */ rtgui_dc_end_drawing(dc); return; }
/* window drawing */ void rtgui_theme_draw_win(struct rtgui_topwin* win) { struct rtgui_dc* dc; rtgui_rect_t rect; if (win->title == RT_NULL) return; /* no title and no board */ /* begin drawing */ dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(win->title)); if (dc == RT_NULL) return; /* get rect */ rtgui_widget_get_rect(RTGUI_WIDGET(win->title), &rect); /* draw border */ if (win->flag & WINTITLE_BORDER) { rect.x2 -= 1; rect.y2 -= 1; RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(win->title)) = RTGUI_RGB(212, 208, 200); rtgui_dc_draw_hline(dc, rect.x1, rect.x2, rect.y1); rtgui_dc_draw_vline(dc, rect.x1, rect.y1, rect.y2); RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(win->title)) = white; rtgui_dc_draw_hline(dc, rect.x1 + 1, rect.x2 - 1, rect.y1 + 1); rtgui_dc_draw_vline(dc, rect.x1 + 1, rect.y1 + 1, rect.y2 - 1); RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(win->title)) = RTGUI_RGB(128, 128, 128); rtgui_dc_draw_hline(dc, rect.x1 + 1, rect.x2 - 1, rect.y2 - 1); rtgui_dc_draw_vline(dc, rect.x2 - 1, rect.y1 + 1, rect.y2 - 1); RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(win->title)) = RTGUI_RGB(64, 64, 64); rtgui_dc_draw_hline(dc, rect.x1, rect.x2, rect.y2); rtgui_dc_draw_vline(dc, rect.x2, rect.y1, rect.y2); /* shrink border */ rtgui_rect_inflate(&rect, -WINTITLE_BORDER_SIZE); } /* draw title */ if (!(win->flag & WINTITLE_NO)) { rt_uint32_t index; float r, g, b, delta; if (win->flag & WINTITLE_ACTIVATE) { r = 10; g = 36; b = 106; delta = 150 / (float)(rect.x2 - rect.x1); } else { r = 128; g = 128; b = 128; delta = 64 / (float)(rect.x2 - rect.x1); } RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(win->title)) = RTGUI_RGB(r, g, b); for (index = rect.x1; index < rect.x2 + 1; index ++) { rtgui_dc_draw_vline(dc, index, rect.y1, rect.y2); r += delta; g += delta; b += delta; } if (win->flag & WINTITLE_ACTIVATE) { RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(win->title)) = white; } else { RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(win->title)) = RTGUI_RGB(212, 208, 200); } rect.x1 += 4; rect.y1 += 2; rect.y2 = rect.y1 + WINTITLE_CB_HEIGHT; rtgui_dc_draw_text(dc, rtgui_wintitle_get_title(win->title), &rect); if (win->flag & WINTITLE_CLOSEBOX) { /* get close button rect */ rtgui_rect_t box_rect = {0, 0, WINTITLE_CB_WIDTH, WINTITLE_CB_HEIGHT}; rtgui_rect_moveto_align(&rect, &box_rect, RTGUI_ALIGN_CENTER_VERTICAL | RTGUI_ALIGN_RIGHT); box_rect.x1 -= 3; box_rect.x2 -= 3; rtgui_dc_fill_rect(dc, &box_rect); /* draw close box */ if (win->flag & WINTITLE_CB_PRESSED) { rtgui_dc_draw_border(dc, &box_rect, RTGUI_BORDER_SUNKEN); RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(win->title)) = red; rtgui_dc_draw_word(dc, box_rect.x1, box_rect.y1 + 6, 7, close_byte); } else { rtgui_dc_draw_border(dc, &box_rect, RTGUI_BORDER_RAISE); RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(win->title)) = black; rtgui_dc_draw_word(dc, box_rect.x1 - 1, box_rect.y1 + 5, 7, close_byte); } } } rtgui_dc_end_drawing(dc); }
void rtgui_theme_draw_checkbox(struct rtgui_checkbox* checkbox) { struct rtgui_dc* dc; struct rtgui_rect rect, box_rect; rtgui_color_t bc, fc; fc = RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(checkbox)); bc = RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(checkbox)); /* begin drawing */ dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(checkbox)); if (dc == RT_NULL) return; /* get rect */ rtgui_widget_get_rect(RTGUI_WIDGET(checkbox), &rect); /* fill rect */ rtgui_dc_fill_rect(dc, &rect); if (RTGUI_WIDGET_IS_FOCUSED(RTGUI_WIDGET(checkbox))) { RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(checkbox)) = black; /* draw focused border */ rtgui_rect_inflate(&rect, -1); rtgui_dc_draw_focus_rect(dc, &rect); rtgui_rect_inflate(&rect, 1); } /* draw check box */ box_rect.x1 = 0; box_rect.y1 = 0; box_rect.x2 = CHECK_BOX_W; box_rect.y2 = CHECK_BOX_H; rtgui_rect_moveto_align(&rect, &box_rect, RTGUI_ALIGN_CENTER_VERTICAL); box_rect.x1 += 2; box_rect.x2 += 2; rtgui_dc_draw_border(dc, &box_rect, RTGUI_BORDER_BOX); rtgui_rect_inflate(&box_rect, -1); RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(checkbox)) = RTGUI_RGB(247, 247, 246); rtgui_dc_fill_rect(dc, &box_rect); if (checkbox->status_down == RTGUI_CHECKBOX_STATUS_CHECKED) { RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(checkbox)) = RTGUI_RGB(33, 161, 33); rtgui_dc_draw_byte(dc, box_rect.x1 + 2, box_rect.y1 + 2, 7, checked_byte); } /* restore saved color */ RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(checkbox)) = bc; RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(checkbox)) = fc; /* draw text */ rect.x1 += rtgui_rect_height(rect) - 4 + 5; rtgui_dc_draw_text(dc, rtgui_label_get_text(RTGUI_LABEL(checkbox)), &rect); /* end drawing */ 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); }
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); }
/* Draw tab bars of @param notebook. @param dc should be initialized and * finished outside this function. Don't pass @param notebook or @param dc as * RT_NULL, it should be checked outside. */ static void _rtgui_notebook_draw_bar(struct rtgui_notebook *notebook, struct rtgui_dc *dc) { int index; struct rtgui_rect rect; struct rtgui_rect text_rect; #ifdef RTGUI_USING_NOTEBOOK_IMAGE struct rtgui_image* image = RT_NULL; struct rtgui_rect image_rect; #endif RT_ASSERT((notebook != RT_NULL) && (dc != RT_NULL)); if (notebook->flag == RTGUI_NOTEBOOK_NOTAB) return; _rtgui_notebook_get_bar_rect(notebook, &rect); rtgui_dc_fill_rect(dc, &rect); if (notebook->flag == RTGUI_NOTEBOOK_TOP || notebook->flag == RTGUI_NOTEBOOK_BOTTOM) { rect.x2 = rect.x1 + notebook->tab_w; /* draw tab bar */ for (index = 0; index < notebook->count; index++) { if (notebook->current == index) { #ifdef RTGUI_USING_NOTEBOOK_IMAGE if (notebook->childs[index].pressed_image != RT_NULL) image = notebook->childs[index].pressed_image; else #endif rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_SUNKEN); } else { #ifdef RTGUI_USING_NOTEBOOK_IMAGE if (notebook->childs[index].unpressed_image != RT_NULL) image = notebook->childs[index].unpressed_image; else #endif rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_BOX); } rtgui_font_get_metrics(RTGUI_WIDGET_FONT(notebook), notebook->childs[index].title, &text_rect); rtgui_rect_moveto_align(&rect, &text_rect, RTGUI_ALIGN_CENTER); #ifdef RTGUI_USING_NOTEBOOK_IMAGE if (image != RT_NULL) { image_rect.x1 = 0; image_rect.y1 = RTGUI_WIDGET_DEFAULT_MARGIN; image_rect.x2 = image_rect.x1 + image->w; image_rect.y2 = image_rect.y1 + image->h; rtgui_rect_moveto_align(&rect, &image_rect, RTGUI_ALIGN_CENTER_HORIZONTAL); rtgui_image_blit(image, dc, &image_rect); } if (image != RT_NULL) { int text_height = text_rect.y2 - text_rect.y1; text_rect.y1 = image_rect.y2 + RTGUI_WIDGET_DEFAULT_MARGIN; text_rect.y2 = text_rect.y1 + text_height; } image = RT_NULL; #endif rtgui_dc_draw_text(dc, notebook->childs[index].title, &text_rect); /* move to next tab */ rect.x1 = rect.x2; rect.x2 = rect.x1 + notebook->tab_w; } } else { rect.y2 = rect.y1 + notebook->tab_h; /* draw tab bar */ for (index = 0; index < notebook->count; index++) { if (notebook->current == index) { #ifdef RTGUI_USING_NOTEBOOK_IMAGE if (notebook->childs[index].pressed_image != RT_NULL) image = notebook->childs[index].pressed_image; else #endif rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_SUNKEN); } else { #ifdef RTGUI_USING_NOTEBOOK_IMAGE if (notebook->childs[index].unpressed_image != RT_NULL) image = notebook->childs[index].unpressed_image; else #endif rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_BOX); } rtgui_font_get_metrics(RTGUI_WIDGET_FONT(notebook), notebook->childs[index].title, &text_rect); rtgui_rect_moveto_align(&rect, &text_rect, RTGUI_ALIGN_CENTER); #ifdef RTGUI_USING_NOTEBOOK_IMAGE if (image != RT_NULL) { image_rect.x1 = 0; image_rect.y1 = RTGUI_WIDGET_DEFAULT_MARGIN; image_rect.x2 = image->w; image_rect.y2 = image_rect.y1 + image->h; rtgui_rect_moveto_align(&rect, &image_rect, RTGUI_ALIGN_CENTER_HORIZONTAL); rtgui_image_blit(image, dc, &image_rect); } if (image != RT_NULL) { int text_height = text_rect.y2 - text_rect.y1; text_rect.y1 = image_rect.y2 + RTGUI_WIDGET_DEFAULT_MARGIN; text_rect.y2 = text_rect.y1 + text_height; } image = RT_NULL; #endif rtgui_dc_draw_text(dc, notebook->childs[index].title, &text_rect); /* move to next tab */ rect.y1 = rect.y2; rect.y2 = rect.y1 + notebook->tab_h; } } }
/* * view的事件处理函数 */ rt_bool_t dc_event_handler(rtgui_widget_t* widget, rtgui_event_t *event) { /* 仅对PAINT事件进行处理 */ if (event->type == RTGUI_EVENT_PAINT) { struct rtgui_dc* dc; rtgui_rect_t rect; /* const int vx[] = {20, 50, 60, 45, 60, 20}; const int vy[] = {150, 50, 90, 60, 45, 50}; */ /* * 因为用的是demo view,上面本身有一部分控件,所以在绘图时先要让demo view * 先绘图 */ rtgui_view_event_handler(widget, event); /************************************************************************/ /* 下面的是DC的操作 */ /************************************************************************/ /* 获得控件所属的DC */ dc = rtgui_dc_begin_drawing(widget); /* 如果不能正常获得DC,返回(如果控件或父控件是隐藏状态,DC是获取不成功的) */ if (dc == RT_NULL) return RT_FALSE; /* 获得demo view允许绘图的区域 */ demo_view_get_logic_rect(RTGUI_VIEW(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_rect_t rect = {0, 0, 0x1c, 0x16}; rtgui_rect_moveto(&rect, 80, 80); rtgui_image_blit((rtgui_image_t*)&play_image, dc, &rect); rect.x1 = 0; rect.y1 = 0; rect.x2 = 0x1c; rect.y2 = 0x16; rtgui_rect_moveto(&rect, 130, 80); rtgui_image_blit((rtgui_image_t*)&stop_image, dc, &rect); } /* 绘制一个圆形 */ RTGUI_DC_FC(dc) = red; rtgui_dc_draw_circle(dc, rect.x1 + 10, rect.y1 + 10, 10); /* 填充一个圆形 */ RTGUI_DC_FC(dc) = green; rtgui_dc_fill_circle(dc, rect.x1 + 30, rect.y1 + 10, 10); #if 0 /* 画一个圆角矩形 */ rect.x1 = 150; rect.y1 = 180; rect.x2 = 210; rect.y2 = 260; RTGUI_DC_FC(dc) = RTGUI_RGB(25, 70, 150); rtgui_dc_draw_round_rect(dc, &rect, 10); rect.x1 = 160; rect.y1 = 190; rect.x2 = 200; rect.y2 = 250; RTGUI_DC_FC(dc) = RTGUI_RGB(170, 7, 80); rtgui_dc_fill_round_rect(dc, &rect, 7); /* 画一个圆弧 */ RTGUI_DC_FC(dc) = RTGUI_RGB(250, 120, 120); rtgui_dc_draw_arc(dc, rect.x1 + 120, rect.y1 + 60, 30, 0, 120); /* 画一个扇形圆环 */ RTGUI_DC_FC(dc) = RTGUI_RGB(150, 23, 100); rtgui_dc_draw_annulus(dc, 180, 170, 30, 50, 210, 330); /* 多边形 */ RTGUI_DC_FC(dc) = blue; rtgui_dc_draw_polygon(dc, vx, vy, 6); #endif RTGUI_DC_FC(dc) = blue; /* 绘制不同的边框 */ { rtgui_rect_t rect = {0, 0, 16, 16}; rtgui_rect_moveto(&rect, 30, 120); rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_RAISE); rect.x1 += 20; rect.x2 += 20 + 50; rtgui_dc_draw_text(dc, "raise", &rect); rect.x1 -= 20; rect.x2 -= 20 + 50; rect.y1 += 20; rect.y2 += 20; rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_SIMPLE); rect.x1 += 20; rect.x2 += 20 + 50; rtgui_dc_draw_text(dc, "simple", &rect); rect.x1 -= 20; rect.x2 -= 20 + 50; rect.y1 += 20; rect.y2 += 20; rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_SUNKEN); rect.x1 += 20; rect.x2 += 20 + 50; rtgui_dc_draw_text(dc, "sunken", &rect); rect.x1 -= 20; rect.x2 -= 20 + 50; rect.y1 += 20; rect.y2 += 20; rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_BOX); rect.x1 += 20; rect.x2 += 20 + 50; rtgui_dc_draw_text(dc, "box", &rect); rect.x1 -= 20; rect.x2 -= 20 + 50; rect.y1 += 20; rect.y2 += 20; rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_STATIC); rect.x1 += 20; rect.x2 += 20 + 50; rtgui_dc_draw_text(dc, "static", &rect); rect.x1 -= 20; rect.x2 -= 20 + 50; rect.y1 += 20; rect.y2 += 20; rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_EXTRA); rect.x1 += 20; rect.x2 += 20 + 50; rtgui_dc_draw_text(dc, "extera", &rect); rect.x1 -= 20; rect.x2 -= 20 + 50; rect.y1 += 20; rect.y2 += 20; } /* 绘图完成 */ rtgui_dc_end_drawing(dc); } else { /* 其他事件,调用默认的事件处理函数 */ return rtgui_view_event_handler(widget, event); } return RT_FALSE; }