本文整理汇总了C++中rtgui_dc_draw_text函数的典型用法代码示例。如果您正苦于以下问题:C++ rtgui_dc_draw_text函数的具体用法?C++ rtgui_dc_draw_text怎么用?C++ rtgui_dc_draw_text使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rtgui_dc_draw_text函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rtgui_theme_draw_iconbox
void rtgui_theme_draw_iconbox(rtgui_iconbox_t* iconbox)
{
struct rtgui_dc* dc;
struct rtgui_rect rect;
/* begin drawing */
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(iconbox));
if (dc == RT_NULL) return;
/* get widget rect */
rtgui_widget_get_rect(RTGUI_WIDGET(iconbox), &rect);
/* draw icon */
rtgui_image_blit(iconbox->image, dc, &rect);
/* draw text */
if (iconbox->text_position == RTGUI_ICONBOX_TEXT_BELOW && iconbox->text != RT_NULL)
{
rect.y1 = iconbox->image->h + RTGUI_WIDGET_DEFAULT_MARGIN;
rtgui_dc_draw_text(dc, iconbox->text, &rect);
}
else if (iconbox->text_position == RTGUI_ICONBOX_TEXT_RIGHT && iconbox->text != RT_NULL)
{
rect.x1 = iconbox->image->w + RTGUI_WIDGET_DEFAULT_MARGIN;
rtgui_dc_draw_text(dc, iconbox->text, &rect);
}
/* end drawing */
rtgui_dc_end_drawing(dc);
}
示例2: rtgui_textbox_ondraw
void rtgui_textbox_ondraw(rtgui_textbox_t *box)
{
/* draw button */
rtgui_rect_t rect;
struct rtgui_dc *dc;
rtgui_color_t fc;
RT_ASSERT(box != RT_NULL);
/* begin drawing */
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(box));
if (dc == RT_NULL)
return;
/* get widget rect */
rtgui_widget_get_rect(RTGUI_WIDGET(box), &rect);
fc = RTGUI_WIDGET_FOREGROUND(box);
rtgui_rect_inflate(&rect, -1);
/* fill widget rect with white color */
RTGUI_WIDGET_BACKGROUND(box) = white;
rtgui_dc_fill_rect(dc, &rect);
rtgui_rect_inflate(&rect, 1);
/* draw border */
RTGUI_WIDGET_FOREGROUND(box) = RTGUI_RGB(123, 158, 189);
rtgui_dc_draw_rect(dc, &rect);
/* draw text */
RTGUI_WIDGET_FOREGROUND(box) = fc;
if (box->text != RT_NULL)
{
rect.x1 += RTGUI_WIDGET_DEFAULT_MARGIN;
/* draw single text */
if (box->flag & RTGUI_TEXTBOX_MASK)
{
/* draw mask char */
rt_size_t len = rt_strlen(box->text);
if (len > 0)
{
char *text_mask = rtgui_malloc(len + 1);
rt_memset(text_mask, box->mask_char, len + 1);
text_mask[len] = 0;
rtgui_dc_draw_text(dc, text_mask+box->first_pos, &rect);
rtgui_free(text_mask);
}
}
else
{
rtgui_dc_draw_text(dc, box->text+box->first_pos, &rect);
}
}
rtgui_dc_end_drawing(dc);
}
示例3: tetris_refreshmap
void tetris_refreshmap(struct rtgui_dc *dc) //刷新地图
{
rt_uint8_t i, j;
rt_uint8_t buf[5];
rtgui_rect_t rect = {XOFFSET, YOFFSET, XOFFSET + 240, YOFFSET + 400};
RTGUI_DC_FC(dc) = RTGUI_RGB(0x55, 0x55, 0x55);
rtgui_dc_fill_rect_forecolor(dc, &rect);
rect.x1 -= 10;
rect.x2 += 150;
rect.y1 -= 10;
rect.y2 += 10;
RTGUI_DC_FC(dc) = RTGUI_RGB(0x00, 0x00, 0xff);
rtgui_dc_draw_rect(dc, &rect);
rect.x1 += 290;
rect.x2 -= 30;
rect.y1 += 40;
rect.y2 -= 360;
RTGUI_DC_FC(dc) = RTGUI_RGB(0x00, 0x00, 0x00);
rtgui_dc_draw_text(dc, "下一个", &rect);
rect.y1 += 130;
rect.y2 += 130;
rtgui_dc_draw_text(dc, "总得分", &rect);
rect.y1 += 80;
rect.y2 += 80;
rtgui_dc_draw_text(dc, "LEVEL", &rect);
RTGUI_DC_FC(dc) = RTGUI_RGB(0xff, 0x00, 0x00);
rect.x1 += 20;
rect.x2 += 20;
rect.y1 -= 60;
rect.y2 -= 60;
rt_sprintf(buf, "%d", score);
rtgui_dc_fill_rect(dc, &rect);
rtgui_dc_draw_text(dc, buf, &rect);
rect.y1 += 80;
rect.y2 += 80;
rt_sprintf(buf, "%d", level);
rtgui_dc_fill_rect(dc, &rect);
rtgui_dc_draw_text(dc, buf, &rect);
for (i = 0; i < 25; i++)
{
for (j = 0; j < 15; j++)
{
if (tetris_map[j][i] != 0)
{
tetris_drawbox(dc, j, i, tetris_colors[tetris_map[j][i]]);
}
}
}
}
示例4: _rtgui_menu_item_ondraw
static void _rtgui_menu_item_ondraw(struct rtgui_listctrl *list,
struct rtgui_dc* dc,
rtgui_rect_t* rect,
rt_uint16_t index)
{
rtgui_rect_t item_rect;
struct rtgui_menu_item* item;
item_rect = *rect;
item_rect.x1 += 5;
/* re-fill item */
if (list->current_item == index)
{
rtgui_color_t bc;
bc = RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(list));
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(list)) = blue;
rtgui_dc_fill_rect(dc, rect);
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(list)) = bc;
}
/* get menu item */
item = (rtgui_menu_item_t*)list->items;
item = &item[index];
if (item->type == RTGUI_ITEM_SUBMENU)
{
rtgui_rect_t r = {0, 0, 8, 8};
rtgui_dc_draw_text(dc, item->label, &item_rect);
item_rect.x1 = item_rect.x2 - 16; item_rect.x2 -= 8;
rtgui_rect_moveto_align(&item_rect, &r, RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL);
rtgui_dc_draw_byte(dc, r.x1, r.y1, 8, right_arrow);
}
else if (item->type == RTGUI_ITEM_SEPARATOR)
{
rtgui_dc_draw_horizontal_line(dc, item_rect.x1, item_rect.x2, (item_rect.y2 + item_rect.y1)/2);
}
else if (item->type == RTGUI_ITEM_CHECK)
{
/* not support right now */
}
else
{
/* normal menu item */
rtgui_dc_draw_text(dc, item->label, &item_rect);
if (item->image != RT_NULL)
rtgui_image_blit(item->image, dc, &item_rect);
}
}
示例5: _draw_default
void _draw_default(struct rtgui_object *object, rtgui_event_t* event)
{
struct rtgui_widget *widget = RTGUI_WIDGET(object);
struct rtgui_dc* dc;
rtgui_rect_t rect;
/* 因为用的是demo container,上面本身有一部分控件,所以在绘图时先要让demo container先绘图 */
rtgui_container_event_handler(object, event);
/* 获得控件所属的DC */
dc = rtgui_dc_begin_drawing(widget);
if (dc == RT_NULL) /* 如果不能正常获得DC,返回(如果控件或父控件是隐藏状态,DC是获取不成功的) */
return;
/* 获得demo container允许绘图的区域 */
demo_view_get_logic_rect(RTGUI_CONTAINER(widget), &rect);
/* 擦除所有 */
RTGUI_WIDGET_BACKGROUND(widget) = default_background;
rtgui_dc_fill_rect(dc, &rect);
/* 显示提示 */
rtgui_dc_draw_text(dc, "按任意键开始/停止测试...", &rect);
/* 绘图完成 */
rtgui_dc_end_drawing(dc);
}
示例6: _draw_default
void _draw_default(PVOID wdt, rtgui_event_t* event)
{
struct rtgui_dc* dc;
rtgui_widget_t* widget = (rtgui_widget_t*)wdt;
rtgui_rect_t rect;
/* 因为用的是demo view,上面本身有一部分控件,所以在绘图时先要让demo view先绘图 */
rtgui_view_event_handler(widget, event);
/* 获得控件所属的DC */
dc = rtgui_dc_begin_drawing(widget);
if (dc == RT_NULL) /* 如果不能正常获得DC,返回(如果控件或父控件是隐藏状态,DC是获取不成功的) */
return ;
/* 获得demo view允许绘图的区域 */
rtgui_widget_get_rect(widget, &rect);
rtgui_rect_inflate(&rect, -5);
rect.y1 += 35;
/* 擦除所有 */
RTGUI_WIDGET_BACKGROUND(widget) = default_background;
rtgui_dc_fill_rect(dc, &rect);
/* 显示提示 */
rtgui_dc_draw_text(dc, "按鼠标键开始/停止测试...", &rect);
/* 绘图完成 */
rtgui_dc_end_drawing(dc);
}
示例7: _draw_textview
static void _draw_textview(rtgui_textview_t *textview)
{
struct rtgui_dc* dc;
struct rtgui_rect rect, font_rect;
char* line;
rt_ubase_t line_index, item_height;
rtgui_font_get_metrics(RTGUI_WIDGET_FONT(RTGUI_WIDGET(textview)), "W", &font_rect);
item_height = rtgui_rect_height(font_rect) + 3;
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(textview));
if (dc == RT_NULL) return ;
/* fill rect */
rtgui_widget_get_rect(RTGUI_WIDGET(textview), &rect);
rtgui_dc_fill_rect(dc, &rect);
rect.x1 += 3;
rect.x2 -= 3;
for (line_index = textview->line_current;
(line_index < textview->line_current + textview->line_page_count) &&
(line_index < textview->line_count);
line_index ++)
{
line = (char* )_get_line_text(textview, line_index);
rtgui_dc_draw_text(dc, line, &rect);
rect.y1 += item_height;
}
rtgui_dc_end_drawing(dc);
}
示例8: demo_view
rtgui_view_t *demo_view_buffer_animation(rtgui_workbench_t* workbench)
{
rtgui_view_t *view;
view = demo_view(workbench, "DC 缓冲区动画");
if (view != RT_NULL)
rtgui_widget_set_event_handler(RTGUI_WIDGET(view), animation_event_handler);
rtgui_font_get_metrics(RTGUI_WIDGET_FONT(RTGUI_WIDGET(view)), "缓冲动画", &text_rect);
if (dc_buffer == RT_NULL)
{
rtgui_rect_t rect;
rect.x1 = 0; rect.x2 = rtgui_rect_width(text_rect) + 2;
rect.y1 = 0; rect.y2 = rtgui_rect_height(text_rect) + 2;
/* 创建 DC Buffer,长 50,宽 50 */
dc_buffer = rtgui_dc_buffer_create(rtgui_rect_width(rect), rtgui_rect_height(rect));
RTGUI_DC_FC(dc_buffer) = RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view));
rtgui_dc_fill_rect(dc_buffer, &rect);
RTGUI_DC_FC(dc_buffer) = black;
rect.x1 = 1; rect.y1 = 1;
rtgui_dc_draw_text(dc_buffer, "缓冲动画", &rect);
}
/* 启动定时器以触发动画 */
timer = rtgui_timer_create(1, RT_TIMER_FLAG_PERIODIC, timeout, (void*)view);
rtgui_timer_start(timer);
return view;
}
示例9: view_event_handler
static rt_bool_t view_event_handler(struct rtgui_widget* widget, struct rtgui_event* event)
{
if (event->type == RTGUI_EVENT_PAINT)
{
struct rtgui_dc* dc;
struct rtgui_rect rect;
dc = rtgui_dc_begin_drawing(widget);
if (dc == RT_NULL) return RT_FALSE;
rtgui_widget_get_rect(widget, &rect);
rtgui_dc_fill_rect(dc, &rect);
if (background != RT_NULL)
rtgui_image_blit(background, dc, &rect);
rtgui_dc_draw_text(dc, "Radio Today", &rect);
rtgui_dc_end_drawing(dc);
return RT_FALSE;
}
return rtgui_view_event_handler(widget, event);
}
示例10: _rtgui_listctrl_item_draw
void _rtgui_listctrl_item_draw(struct rtgui_listctrl *list,
struct rtgui_dc *dc,
rtgui_rect_t *rect,
rt_uint16_t index)
{
char age_str[8];
rtgui_rect_t item_rect;
struct list_item *items, *item;
item_rect = *rect;
item_rect.x1 += 5;
items = (struct list_item *)list->items;
item = &items[index];
/* draw text */
rtgui_dc_draw_text(dc, item->name, &item_rect);
item_rect.x1 += 60;
rtgui_dc_draw_vline(dc, item_rect.x1, item_rect.y1, item_rect.y2);
item_rect.x1 += 5;
rtgui_dc_draw_text(dc, item->gender, &item_rect);
item_rect.x1 += 60;
rtgui_dc_draw_vline(dc, item_rect.x1, item_rect.y1, item_rect.y2);
item_rect.x1 += 5;
rt_snprintf(age_str, sizeof(age_str), "%d", item->age);
rtgui_dc_draw_text(dc, age_str, &item_rect);
item_rect.x1 += 40;
rtgui_dc_draw_vline(dc, item_rect.x1, item_rect.y1, item_rect.y2);
item_rect.x1 += 5;
/* draw image */
if (item->image != RT_NULL)
{
rtgui_rect_t image_rect;
image_rect.x1 = 0;
image_rect.y1 = 0;
image_rect.x2 = item->image->w;
image_rect.y2 = item->image->h;
rtgui_rect_moveto_align(&item_rect, &image_rect, RTGUI_ALIGN_CENTER_VERTICAL);
rtgui_image_blit(item->image, dc, &image_rect);
}
}
示例11: rtgui_listbox_ondraw
void rtgui_listbox_ondraw(struct rtgui_listbox* box)
{
struct rtgui_rect rect, item_rect;
struct rtgui_dc* dc;
rt_uint16_t page_index, index;
const struct rtgui_listbox_item* item;
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(box));
if (dc == RT_NULL) return;
rtgui_widget_get_rect(RTGUI_WIDGET(box), &rect);
rtgui_dc_fill_rect(dc, &rect);
rect.x2 -= 1; rect.y2 -= 1;
/* draw focused border */
if (RTGUI_WIDGET_IS_FOCUSED(RTGUI_WIDGET(box)))
rtgui_dc_draw_focus_rect(dc, &rect);
/* get item base rect */
item_rect = rect;
item_rect.x1 += 1; item_rect.x2 -= 1;
item_rect.y1 += 2;
item_rect.y2 = item_rect.y1 + (2 + rtgui_theme_get_selected_height());
/* get current page */
page_index = (box->current_item / box->page_items) * box->page_items;
for (index = 0; index < box->page_items; index ++)
{
if (page_index + index >= box->items_count) break;
item = &(box->items[page_index + index]);
if (page_index + index == box->current_item)
{
rtgui_theme_draw_selected(dc, &item_rect);
}
item_rect.x1 += LIST_MARGIN;
if (item->image != RT_NULL)
{
rtgui_image_blit(item->image, dc, &item_rect);
item_rect.x1 += item->image->w + 2;
}
/* draw text */
rtgui_dc_draw_text(dc, item->name, &item_rect);
if (item->image != RT_NULL)
item_rect.x1 -= (item->image->w + 2);
item_rect.x1 -= LIST_MARGIN;
/* move to next item position */
item_rect.y1 += (rtgui_theme_get_selected_height() + 2);
item_rect.y2 += (rtgui_theme_get_selected_height() + 2);
}
rtgui_dc_end_drawing(dc);
}
示例12: rtgui_list_view_onicondraw
static void rtgui_list_view_onicondraw(struct rtgui_list_view *view, struct rtgui_dc *dc)
{
struct rtgui_rect rect, item_rect, drawing_rect;
rt_ubase_t c, r, item_index; /* col and row index */
rt_ubase_t item_width, item_height;
rtgui_image_t *image;
if (view->items_count == 0) return;
rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
item_index = (view->current_item / view->page_items) * view->page_items;
item_width = (rtgui_rect_width(rect) - 2 * LIST_MARGIN) / view->col_items;
item_height = (rtgui_rect_height(rect) - 4) / view->row_items;
image = view->items[0].image;
for (r = 0; r < view->row_items; r ++)
{
for (c = 0; c < view->col_items; c ++)
{
if (item_index < view->items_count)
{
item_rect.y1 = rect.y1 + LIST_MARGIN + r * item_height;
item_rect.x1 = rect.x1 + LIST_MARGIN + c * item_width;
item_rect.x2 = item_rect.x1 + item_width;
item_rect.y2 = item_rect.y1 + item_height;
if (item_index == view->current_item)
{
rtgui_theme_draw_selected(dc, &item_rect);
}
drawing_rect.x1 = drawing_rect.y1 = 0;
drawing_rect.x2 = image->w;
drawing_rect.y2 = image->h;
rtgui_rect_moveto_align(&item_rect, &drawing_rect, RTGUI_ALIGN_CENTER_HORIZONTAL);
drawing_rect.y1 += 5;
drawing_rect.y2 += 5;
rtgui_image_blit(view->items[item_index].image, dc, &drawing_rect);
item_rect.y1 = drawing_rect.y2 + LIST_MARGIN;
item_rect.x1 += 3;
item_rect.x2 -= 3;
rtgui_font_get_metrics(RTGUI_WIDGET_FONT(view), view->items[item_index].name,
&drawing_rect);
rtgui_rect_moveto_align(&item_rect, &drawing_rect, RTGUI_ALIGN_CENTER_HORIZONTAL);
rtgui_dc_draw_text(dc, view->items[item_index].name, &drawing_rect);
item_index ++;
}
else break;
}
}
}
示例13: rtgui_list_view_onlistdraw
static void rtgui_list_view_onlistdraw(struct rtgui_list_view *view, struct rtgui_dc *dc)
{
rt_ubase_t index, page_index;
rtgui_rect_t rect, item_rect, image_rect;
const struct rtgui_list_item *item;
rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
/* get item base rect */
item_rect = rect;
item_rect.y1 += 2;
item_rect.y2 = item_rect.y1 + (2 + rtgui_theme_get_selected_height());
/* get current page */
page_index = (view->current_item / view->page_items) * view->page_items;
for (index = 0; index < view->page_items; index ++)
{
if (page_index + index >= view->items_count) break;
item = &(view->items[page_index + index]);
if (page_index + index == view->current_item)
{
rtgui_theme_draw_selected(dc, &item_rect);
}
item_rect.x1 += LIST_MARGIN;
if (item->image != RT_NULL)
{
/* blit on center */
image_rect.x1 = 0;
image_rect.y1 = 0;
image_rect.x2 = item->image->w;
image_rect.y2 = item->image->h;
rtgui_rect_moveto_align(&item_rect, &image_rect, RTGUI_ALIGN_CENTER_VERTICAL);
rtgui_image_blit(item->image, dc, &image_rect);
item_rect.x1 += item->image->w + 2;
}
/* draw text */
rtgui_dc_draw_text(dc, item->name, &item_rect);
if (item->image != RT_NULL)
item_rect.x1 -= (item->image->w + 2);
item_rect.x1 -= LIST_MARGIN;
/* move to next item position */
item_rect.y1 += (rtgui_theme_get_selected_height() + 2);
item_rect.y2 += (rtgui_theme_get_selected_height() + 2);
}
}
示例14: draw_form_head
static int draw_form_head(struct rtgui_form *form, const struct rtgui_font *font,
struct rtgui_dc* dc, struct rtgui_rect *rect, struct rtgui_rect *row_rect, char *buf)
{
struct rtgui_rect form_rect;
char *pch1;
const char *pch2;
int i, j, len;
#if 0
form_debug(("func:%s, (%d,%d), (%d,%d),bytes:%d, h:%d, r:%d\n", __FUNCTION__,
rect->x1, rect->y1, rect->x2, rect->y2, form->bytes_of_row, font->height, form->row_cnt_of_fbody));
#endif
form_rect.x1 = 0;
form_rect.y1 = 0;
form_rect.x2 = (form->bytes_of_row + GAG_BETWEEN_COL*form->head_item_cnt) * 8;
form_rect.y2 = (font->height + GAG_BETWEEN_ROW) * (form->row_cnt_of_fbody + 1);
rtgui_rect_moveto_align(rect, &form_rect, RTGUI_ALIGN_CENTER_HORIZONTAL);
form_rect.y1 += GAG_BEFORE_FORM_HEAD;
form_rect.y2 += GAG_BEFORE_FORM_HEAD;
if (0xffff == form->form_rect.x1) {
form->form_rect = form_rect;
}
j = form->head_item_cnt;
pch1 = buf;
for (i=0; i<j; ++i) {
pch2 = form->head_name[i];
while ('\0' != *pch2)
*pch1++ = *pch2++;
/* 用空格填充列间隔 */
len = GAG_BETWEEN_COL;
while (len--)
*pch1++ = ' ';
}
*--pch1 = '\0';
row_rect->x1 = form_rect.x1;
row_rect->y1 = form_rect.y1;
row_rect->x2 = form_rect.x2;
row_rect->y2 = form_rect.y1 + font->height;
#if 0
form_debug(("func:%s, (%d,%d), (%d,%d),hic:%d, len:%d, buf:%s\n", __FUNCTION__,
row_rect->x1, row_rect->y1, row_rect->x2,row_rect->y2,j,pch1 -buf, buf));
#endif
rtgui_dc_draw_text(dc, buf, row_rect);
rtgui_dc_draw_horizontal_line(dc, row_rect->x1, row_rect->x2, row_rect->y2+1);
return SUCC;
}
示例15: rtgui_combobox_ondraw
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;
}