本文整理汇总了C++中RTGUI_WIDGET函数的典型用法代码示例。如果您正苦于以下问题:C++ RTGUI_WIDGET函数的具体用法?C++ RTGUI_WIDGET怎么用?C++ RTGUI_WIDGET使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTGUI_WIDGET函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: app_lcd
static void app_lcd(void *parameter)
{
/* create application */
struct rtgui_app *app;
struct rtgui_rect rect1 = {0, 0, 240, 320};
struct rtgui_button* btn;
struct rtgui_label *lb;
app = rtgui_app_create("lcd_app");
if (!app)
{
rt_kprintf("Create application \"lcd_app\" failed!\n");
return;
}
/* create main window */
win_main = rtgui_win_create(RT_NULL, "main",
&rect1,
RTGUI_WIN_STYLE_NO_BORDER | RTGUI_WIN_STYLE_NO_TITLE);
if (win_main == RT_NULL)
{
rt_kprintf("Create window \"main\" failed!\n");
rtgui_app_destroy(app);
return;
}
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(win_main)) = green;
rect1.x1 = rect1.y1 = 50;
rect1.x2 -= 50;
rect1.y2 -= 50;
lb = rtgui_label_create("I am a transparent label!!!!!!!!!");
rtgui_widget_set_rect(RTGUI_WIDGET(lb), &rect1);
RTGUI_WIDGET_FLAG(RTGUI_WIDGET(lb)) |= RTGUI_WIDGET_FLAG_TRANSPARENT;
rect1.x1 += 20;
rect1.y1 += 20;
notebook = rtgui_notebook_create(&rect1, 0);
/* create lable in main container */
btn = rtgui_button_create("Here I am.");
rtgui_notebook_add(notebook, "btn A", RTGUI_WIDGET(btn));
rtgui_button_set_onbutton(btn, remove_myself);
btn = rtgui_button_create("There I am.");
rtgui_notebook_add(notebook, "btn B", RTGUI_WIDGET(btn));
rtgui_container_add_child(RTGUI_CONTAINER(win_main), RTGUI_WIDGET(lb));
rtgui_container_add_child(RTGUI_CONTAINER(win_main), RTGUI_WIDGET(notebook));
rtgui_win_show(win_main, RT_FALSE);
rtgui_app_run(app);
rtgui_app_destroy(app);
}
示例2: rtgui_notebook_add_image
void rtgui_notebook_add_image(struct rtgui_notebook* notebook, const char* label, struct rtgui_widget* child,
struct rtgui_image *pressed_image, struct rtgui_image *unpressed_image)
{
rtgui_rect_t rect;
RT_ASSERT(notebook != RT_NULL);
notebook->count += 1;
notebook->childs = (struct rtgui_notebook_tab*)
rtgui_realloc(notebook->childs,
sizeof(struct rtgui_notebook_tab) * notebook->count);
notebook->childs[notebook->count - 1].title = rt_strdup(label);
notebook->childs[notebook->count - 1].widget = child;
notebook->childs[notebook->count - 1].pressed_image = pressed_image;
notebook->childs[notebook->count - 1].unpressed_image = unpressed_image;
/* set parent */
rtgui_widget_set_parent(child, RTGUI_WIDGET(notebook));
_rtgui_notebook_get_page_rect(notebook, &rect);
rtgui_widget_rect_to_device(RTGUI_WIDGET(notebook), &rect);
rtgui_widget_set_rect(child, &rect);
if (notebook->count - 1 != notebook->current)
rtgui_widget_hide(child);
if (RTGUI_WIDGET(notebook)->toplevel != RT_NULL &&
RTGUI_IS_WIN(RTGUI_WIDGET(notebook)->toplevel))
{
struct rtgui_event_update_toplvl eup;
RTGUI_EVENT_UPDATE_TOPLVL_INIT(&eup);
eup.toplvl = RTGUI_WIDGET(notebook)->toplevel;
if (RTGUI_OBJECT(child)->event_handler)
RTGUI_OBJECT(child)->event_handler(RTGUI_OBJECT(child), (struct rtgui_event*)&eup);
}
return;
}
示例3: demo_view
/* 创建用于演示label控件的视图 */
rtgui_container_t *demo_view_listctrl(void)
{
rtgui_rect_t rect;
rtgui_container_t *container;
rtgui_label_t *label;
rtgui_listctrl_t *box;
/* 先创建一个演示用的视图 */
container = demo_view("List Control Demo");
if (item_icon == RT_NULL)
item_icon = rtgui_image_create_from_mem("xpm",
(const rt_uint8_t *)image_xpm, sizeof(image_xpm), RT_TRUE);
items[1].image = item_icon;
/* 获得视图的位置信息 */
demo_view_get_rect(container, &rect);
rect.x1 += 5;
rect.x2 -= 5;
rect.y1 += 5;
rect.y2 = rect.y1 + 20;
/* 创建一个label控件 */
label = rtgui_label_create("List Control: ");
/* 设置label的位置 */
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
/* container是一个container控件,调用add_child方法添加这个label控件 */
rtgui_container_add_child(container, RTGUI_WIDGET(label));
rect.y1 = rect.y2 + 3;
rect.y2 = 250;
box = rtgui_listctrl_create(items, sizeof(items) / sizeof(items[0]), &rect,
_rtgui_listctrl_item_draw);
rtgui_listctrl_set_onitem(box, on_items);
/* container是一个container控件,调用add_child方法添加这个listctrl控件 */
rtgui_container_add_child(container, RTGUI_WIDGET(box));
return container;
}
示例4: rtgui_textbox_onmouse
static void rtgui_textbox_onmouse(struct rtgui_textbox* box, struct rtgui_event_mouse* event)
{
rt_size_t length;
RT_ASSERT(box != RT_NULL);
RT_ASSERT(event != RT_NULL);
length = rt_strlen((const char*)box->text);
if (event->button & RTGUI_MOUSE_BUTTON_LEFT &&
event->button & RTGUI_MOUSE_BUTTON_DOWN)
{
rt_int32_t x;
/* set caret position */
x = event->x - RTGUI_WIDGET(box)->extent.x1;
if (x < 0)
{
box->position = 0;
}
else if (x > length * box->font_width)
{
box->position = length;
}
else
{
box->position = x / box->font_width;
}
/* set caret to show */
box->flag |= RTGUI_TEXTBOX_CARET_SHOW;
/* set widget focus */
rtgui_widget_focus(RTGUI_WIDGET(box));
/* re-draw text box */
rtgui_theme_draw_textbox(box);
}
}
示例5: create_normal_win
static void create_normal_win(void)
{
rtgui_rect_t rect = {30, 40, 150, 80};
normal_window = rtgui_win_create(RT_NULL, "普通窗口",
&rect, RTGUI_WIN_STYLE_DEFAULT);
rect.x1 += 20;
rect.x2 -= 5;
rect.y1 += 5;
rect.y2 = rect.y1 + 20;
/* 添加一个文本标签 */
rt_sprintf(normal_window_label_text,
"第 %d 次显示", normal_window_show_count);
normal_window_label = rtgui_label_create(normal_window_label_text);
rtgui_widget_set_rect(RTGUI_WIDGET(normal_window_label), &rect);
rtgui_container_add_child(RTGUI_CONTAINER(normal_window),
RTGUI_WIDGET(normal_window_label));
rtgui_win_set_onclose(normal_window,
normal_window_onclose);
}
示例6: main
void main(void)
{
struct rtgui_app* application;
struct rtgui_win* win;
application = rtgui_app_create(rt_thread_self(), "filelist");
if (application != RT_NULL)
{
struct rtgui_rect rect;
rtgui_filelist_view_t *view;
win = rtgui_mainwin_create(RT_NULL, "filelist",
RTGUI_WIN_STYLE_MAINWIN | RTGUI_WIN_STYLE_DESTROY_ON_CLOSE);
rtgui_widget_get_extent(RTGUI_WIDGET(win), &rect);
view = rtgui_filelist_view_create("/", "*.*", &rect);
rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(view));
rtgui_win_show(win, RT_TRUE);
rtgui_app_destroy(application);
}
}
示例7: _rtgui_progressbar_constructor
static void _rtgui_progressbar_constructor(rtgui_progressbar_t *bar)
{
rtgui_rect_t rect = {0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT};
rtgui_object_set_event_handler(RTGUI_OBJECT(bar), rtgui_progressbar_event_handler);
rtgui_widget_set_rect(RTGUI_WIDGET(bar), &rect);
bar->orient = RTGUI_HORIZONTAL;
bar->range = RTGUI_PROGRESSBAR_DEFAULT_RANGE;
bar->position = 0;
/* set gc */
RTGUI_WIDGET_TEXTALIGN(bar) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
}
示例8: rtgui_combobox_pdwin_onitem
rt_bool_t rtgui_combobox_pdwin_onitem(struct rtgui_object* object, struct rtgui_event* event)
{
struct rtgui_widget *widget;
rtgui_win_t* pd_win;
rtgui_combobox_t* combo;
rtgui_listbox_t* list;
RT_ASSERT(object != RT_NULL);
widget = RTGUI_WIDGET(object);
list = RTGUI_LISTBOX(widget);
pd_win = RTGUI_WIN(rtgui_widget_get_toplevel(widget));
combo = RTGUI_COMBOBOX(pd_win->user_data);
combo->current_item = list->current_item;
if (combo->on_selected != RT_NULL)
combo->on_selected(RTGUI_OBJECT(combo), RT_NULL);
rtgui_win_hiden(pd_win);
rtgui_widget_update(RTGUI_WIDGET(combo));
return RT_FALSE;
}
示例9: 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);
}
}
示例10: rtgui_list_view_ondraw
void rtgui_list_view_ondraw(struct rtgui_list_view* view)
{
struct rtgui_rect rect;
struct rtgui_dc* dc;
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(view));
if (dc == RT_NULL) return;
rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
rtgui_dc_fill_rect(dc, &rect);
switch (view->flag) {
case RTGUI_LIST_VIEW_LIST:
rtgui_list_view_onlistdraw(view, dc);
break;
case RTGUI_LIST_VIEW_ICON:
rtgui_list_view_onicondraw(view, dc);
break;
}
rtgui_dc_end_drawing(dc);
}
示例11: _rtgui_scrollbar_get_length
rt_uint32_t _rtgui_scrollbar_get_length(rtgui_scrollbar_t *bar)
{
rtgui_rect_t rect;
rt_uint32_t result;
rtgui_widget_get_rect(RTGUI_WIDGET(bar), &rect);
if(bar->orient & RTGUI_VERTICAL)
result = rtgui_rect_height(rect) - 2*rtgui_rect_width(rect) - bar->thumb_len;
else
result = rtgui_rect_width(rect) - 2*rtgui_rect_height(rect) - bar->thumb_len;
return result;
}
示例12: rtgui_scrollbar_hide
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);
}
示例13: rtgui_edit_get_caret_rect
static void rtgui_edit_get_caret_rect(struct rtgui_edit *edit, rtgui_rect_t *rect, rtgui_point_t visual)
{
RT_ASSERT(edit != RT_NULL);
rtgui_widget_get_rect(RTGUI_WIDGET(edit), rect);
rect->x1 += visual.x * edit->font_width + RTGUI_WIDGET_BORDER_SIZE(edit) + edit->margin;
rect->x2 = rect->x1+2; /* caret width: 1 */
rect->y1 += visual.y * edit->item_height + RTGUI_WIDGET_BORDER_SIZE(edit) + edit->margin;
if((rect->y1 + edit->font_height) < (rect->y2 - RTGUI_WIDGET_BORDER_SIZE(edit) - edit->margin))
rect->y2 = rect->y1 + edit->font_height;
else
rect->y2 = rect->y2 - RTGUI_WIDGET_BORDER_SIZE(edit) - edit->margin;
}
示例14: program_create
struct rtgui_panel* program_create(struct rtgui_panel* panel)
{
int i = 0;
struct rtgui_rect rect;
RT_ASSERT(panel != RT_NULL);
rtgui_widget_get_extent(RTGUI_WIDGET(panel), &rect);
items = (struct rtgui_list_item *) rtgui_malloc((ITEM_MAX) * sizeof(struct rtgui_list_item));
for(i=0; i< ITEM_MAX; i++) items[i].action = exec_app;
/* create application list */
rtgui_rect_inflate(&rect, -15);
scan_app_dir(APP_PATH);
if(pos >= 0)
{
_view = rtgui_list_view_create(items, pos + 1, &rect, RTGUI_LIST_VIEW_ICON);
rtgui_container_add_child(RTGUI_CONTAINER(panel), RTGUI_WIDGET(_view));
}
return RTGUI_PANEL(panel);
}
示例15: picture_show_next
static void picture_show_next()
{
DIR* dir;
struct dirent* entry;
rt_bool_t found, has_image;
found = RT_FALSE; has_image = RT_FALSE;
__restart:
dir = opendir(PICTURE_DIR);
if (dir == RT_NULL)
{
rt_kprintf("open directory failed\n");
return;
}
do
{
entry = readdir(dir);
if (entry != RT_NULL)
{
if (strstr(entry->d_name, ".hdc") != RT_NULL ||
strstr(entry->d_name, ".HDC") != RT_NULL)
{
/* this directory includes image */
has_image = RT_TRUE;
if (found == RT_TRUE || current_fn[0] == '\0')
{
strcpy(current_fn, entry->d_name);
rtgui_widget_update(RTGUI_WIDGET(picture_view));
closedir(dir);
return;
}
/* it's a HDC image */
if (strcmp(entry->d_name, current_fn) == 0)
found = RT_TRUE;
}
}
} while(entry != RT_NULL);
/* close directory */
closedir(dir);
if (has_image != RT_TRUE) return;
current_fn[0] = '\0';
goto __restart;
}