本文整理汇总了C++中RTGUI_CONTAINER函数的典型用法代码示例。如果您正苦于以下问题:C++ RTGUI_CONTAINER函数的具体用法?C++ RTGUI_CONTAINER怎么用?C++ RTGUI_CONTAINER使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTGUI_CONTAINER函数的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: demo_modalwin_onbutton
/* 触发模态窗口显示 */
static void demo_modalwin_onbutton(struct rtgui_object *object, rtgui_event_t *event)
{
rtgui_win_t *win;
rtgui_label_t *label;
rtgui_rect_t rect = {0, 0, 150, 80};
rtgui_rect_moveto(&rect, delta_x, delta_y);
delta_x += 20;
delta_y += 20;
/* 创建一个窗口 */
win = rtgui_win_create(main_win,
get_win_title(), &rect, RTGUI_WIN_STYLE_DEFAULT);
rect.x1 += 20;
rect.x2 -= 5;
rect.y1 += 5;
rect.y2 = rect.y1 + 20;
label = rtgui_label_create("这是一个模式窗口");
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(label));
/* 模态显示窗口 */
rtgui_win_show(win, RT_TRUE);
/* 删除非自动删除窗口 */
rtgui_win_destroy(win);
}
示例3: demo_autowin_onbutton
/* 触发自动窗口显示 */
static void demo_autowin_onbutton(struct rtgui_object *object, rtgui_event_t *event)
{
struct rtgui_rect rect = {50, 50, 200, 200};
/* don't create the window twice */
if (autowin)
return;
autowin = rtgui_win_create(main_win, "Information",
&rect, RTGUI_WIN_STYLE_DEFAULT | RTGUI_WIN_STYLE_DESTROY_ON_CLOSE);
if (autowin == RT_NULL)
return;
cnt = 5;
rt_sprintf(label_text, "closed then %d second!", cnt);
label = rtgui_label_create(label_text);
rect.x1 += 5;
rect.x2 -= 5;
rect.y1 += 5;
rect.y2 = rect.y1 + 20;
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
rtgui_container_add_child(RTGUI_CONTAINER(autowin),
RTGUI_WIDGET(label));
/* 设置关闭窗口时的动作 */
rtgui_win_set_onclose(autowin, auto_window_close);
rtgui_win_show(autowin, RT_FALSE);
/* 创建一个定时器 */
timer = rtgui_timer_create(100, RT_TIMER_FLAG_PERIODIC, diag_close, RT_NULL);
rtgui_timer_start(timer);
}
示例4: rtgui_filelist_view_menu_pop
static void rtgui_filelist_view_menu_pop(rtgui_widget_t *parent)
{
rtgui_win_t *menu;
rtgui_listbox_t *listbox;
rtgui_rect_t screen, rect = {0, 0, 140, 85};
rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &screen);
rtgui_rect_moveto_align(&screen, &rect, RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL);
menu = rtgui_win_create(RTGUI_WIN(rtgui_widget_get_toplevel(parent)),
"Folder Menu", &rect, RTGUI_WIN_STYLE_DEFAULT);
if (menu != RT_NULL)
{
/* set user data on menu window */
menu->user_data = (rt_uint32_t)parent;
rtgui_win_set_ondeactivate(menu, rtgui_filelist_view_on_menu_deactivate);
listbox = rtgui_listbox_create(items, sizeof(items)/sizeof(items[0]), &rect);
rtgui_listbox_set_onitem(listbox, rtgui_filelist_view_on_folder_item);
rtgui_container_add_child(RTGUI_CONTAINER(menu), RTGUI_WIDGET(listbox));
rtgui_win_show(menu, RT_FALSE);
rtgui_widget_focus(RTGUI_WIDGET(listbox));
rtgui_listbox_set_current_item(listbox, 0);
}
}
示例5: rtgui_win_set_box
void rtgui_win_set_box(rtgui_win_t* win, rtgui_box_t* box)
{
if (win == RT_NULL || box == RT_NULL) return;
rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(box));
rtgui_widget_set_rect(RTGUI_WIDGET(box), &(RTGUI_WIDGET(win)->extent));
}
示例6: _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);
}
示例7: _onidle
void _onidle(struct rtgui_object *object, rtgui_event_t *event)
{
rtgui_color_t color;
rtgui_rect_t rect, draw_rect;
struct rtgui_dc *dc;
/* 获得控件所属的DC */
// dc = rtgui_dc_hw_create(RTGUI_WIDGET(container));
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(container));
if (dc == RT_NULL)
return;
demo_view_get_logic_rect(RTGUI_CONTAINER(container), &rect);
draw_rect.x1 = RAND(rect.x1, rect.x2);
draw_rect.y1 = RAND(rect.y1, rect.y2);
draw_rect.x2 = RAND(draw_rect.x1, rect.x2);
draw_rect.y2 = RAND(draw_rect.y1, rect.y2);
color = RTGUI_RGB(rand() % 255, rand() % 255, rand() % 255);
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(container)) = color;
rtgui_dc_fill_rect(dc, &draw_rect);
/* 绘图完成 */
rtgui_dc_end_drawing(dc);
}
示例8: rtgui_notebook_get_object
struct rtgui_object* rtgui_notebook_get_object(struct rtgui_notebook *notebook,
rt_uint32_t id)
{
int i;
for (i = 0; i < notebook->count; i++)
{
struct rtgui_object *o = RTGUI_OBJECT(notebook->childs[i].widget);
if (o->id == id)
return o;
if (RTGUI_IS_CONTAINER(o))
{
struct rtgui_object *obj;
obj = rtgui_container_get_object(RTGUI_CONTAINER(o), id);
if (obj)
return obj;
}
else if (RTGUI_IS_NOTEBOOK(o))
{
struct rtgui_object *obj;
obj = rtgui_notebook_get_object(RTGUI_NOTEBOOK(o), id);
if (obj)
return obj;
}
}
return RT_NULL;
}
示例9: main
int main(int argc, char** argv)
{
struct rtgui_app* application;
struct rtgui_win* win;
struct rtgui_button *button;
application = rtgui_app_create("button");
if (application != RT_NULL)
{
rtgui_rect_t rect;
win = rtgui_mainwin_create(RT_NULL, "button",
RTGUI_WIN_STYLE_MAINWIN | RTGUI_WIN_STYLE_DESTROY_ON_CLOSE);
rtgui_widget_get_extent(RTGUI_WIDGET(win), &rect);
/* create lable in app window */
button = rtgui_button_create("close");
rtgui_button_set_onbutton(button, _on_close);
rect.x2 -= 5; rect.y2 -= 5;
rect.x1 = rect.x2 - 80; rect.y1 = rect.y2 - 25;
rtgui_widget_set_rect(RTGUI_WIDGET(button), &rect);
rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(button));
rtgui_win_show(win, RT_TRUE);
rtgui_app_destroy(application);
}
return 0;
}
示例10: rtgui_terminal_create
rtgui_terminal_t* rtgui_terminal_create(pvoid parent,const char* text, int left,int top,int w,int h)
{
rtgui_container_t *container;
rtgui_terminal_t* tma;
RT_ASSERT(parent != RT_NULL);
container = RTGUI_CONTAINER(parent);
tma = rtgui_widget_create(RTGUI_TERMINAL_TYPE);
if(tma != RT_NULL)
{
rtgui_rect_t rect;
rtgui_widget_get_rect(container, &rect);
rtgui_widget_rect_to_device(container,&rect);
rect.x1 += left;
rect.y1 += top;
rect.x2 = rect.x1+w;
rect.y2 = rect.y1+h;
rtgui_widget_set_rect(tma,&rect);
rtgui_container_add_child(container, tma);
/* calculate line width and line page count */
rtgui_terminal_calc_width(tma);
/* set text */
rtgui_terminal_calc_line(tma, text);
}
return tma;
}
示例11: rtgui_menu_create
struct rtgui_menu* rtgui_menu_create(const char* title, struct rtgui_menu* parent_menu,
const struct rtgui_menu_item* items, rt_uint16_t count)
{
rtgui_rect_t rect = {0, 0, 100, 100};
struct rtgui_menu* menu;
menu = (struct rtgui_menu*) rtgui_widget_create ( RTGUI_MENU_TYPE );
if (menu != RT_NULL)
{
rtgui_win_set_title(RTGUI_WIN(menu), title);
menu->parent_menu = parent_menu;
menu->items = items;
menu->items_count = count;
rtgui_widget_set_rect(RTGUI_WIDGET(menu), &rect);
rtgui_rect_inflate(&rect, -1);
/* create menu item list */
menu->items_list = rtgui_listctrl_create((rt_uint32_t)items, count, &rect, _rtgui_menu_item_ondraw);
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(menu->items_list)) = rtgui_theme_default_bc();
rtgui_container_add_child(RTGUI_CONTAINER(menu), RTGUI_WIDGET(menu->items_list));
rtgui_listctrl_set_onitem(menu->items_list, _rtgui_menu_onitem);
}
return menu;
}
示例12: apps_list_create
struct rtgui_panel* apps_list_create(struct rtgui_panel* panel)
{
struct rtgui_rect rect;
RT_ASSERT(panel != RT_NULL);
if (app_default_icon == RT_NULL)
{
app_default_icon = rtgui_image_create_from_mem("xpm", (const rt_uint8_t*)exec_xpm, sizeof(exec_xpm), RT_FALSE);
}
if (app_close == RT_NULL)
{
app_close = rtgui_image_create_from_mem("xpm", (const rt_uint8_t *)close_xpm, sizeof(close_xpm), RT_FALSE);
}
rtgui_widget_get_extent(RTGUI_WIDGET(panel), &rect);
/* create application list */
rtgui_rect_inflate(&rect, -15);
app_list = rtgui_listctrl_create(RTGUI_CONTAINER(panel), (rt_uint32_t)app_items, app_count, 15,15,RC_W(rect)-30,RC_H(rect)-30, _app_info_draw);
rtgui_listctrl_set_itemheight(app_list, app_default_icon->h + 2);
rtgui_listctrl_set_onitem(app_list, _handle_app_activate);
rtgui_object_set_event_handler(RTGUI_OBJECT(app_list), apps_listctrl_event_handler);
//rtgui_container_add_child(RTGUI_CONTAINER(panel), RTGUI_WIDGET(app_list));
return RTGUI_PANEL(panel);
}
示例13: demo_view_notebook
/* 创建用于演示notebook控件的视图 */
rtgui_view_t* demo_view_notebook(rtgui_workbench_t* workbench)
{
rtgui_rect_t rect;
rtgui_view_t* view;
rtgui_notebook_t* notebook;
rtgui_listbox_t* box;
/* 先创建一个演示用的视图 */
view = demo_view(workbench, "Notebook View");
/* 获得视图的位置信息 */
demo_view_get_rect(view, &rect);
notebook = rtgui_notebook_create(&rect, RTGUI_NOTEBOOK_BOTTOM);
/* view是一个container控件,调用add_child方法添加这个notebook控件 */
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(notebook));
box = rtgui_listbox_create(items, sizeof(items)/sizeof(struct rtgui_listbox_item), &rect);
rtgui_notebook_add(notebook, "Tab 1", RTGUI_WIDGET(box));
box = rtgui_listbox_create(items2, sizeof(items2)/sizeof(struct rtgui_listbox_item), &rect);
rtgui_notebook_add(notebook, "Tab 2", RTGUI_WIDGET(box));
return view;
}
示例14: listitem_action
static void listitem_action(void* parameter)
#endif
{
char label_text[32];
rtgui_win_t *win;
rtgui_label_t *label;
rtgui_rect_t rect = {0, 0, 150, 80};
int no = (int)parameter;
rtgui_rect_moveto(&rect, 20, 50);
/* 显示消息窗口 */
win = rtgui_win_create(RTGUI_TOPLEVEL(workbench),
"窗口", &rect, RTGUI_WIN_STYLE_DEFAULT);
rect.x1 += 20;
rect.x2 -= 5;
rect.y1 += 5;
rect.y2 = rect.y1 + 20;
/* 添加相应的标签 */
rt_sprintf(label_text, "动作 %d", no);
label = rtgui_label_create(label_text);
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(label));
/* 非模态显示窗口 */
rtgui_win_show(win, RT_FALSE);
}
示例15: demo_listview_icon_view
/* 创建用于演示列表视图的视图 */
rtgui_view_t* demo_listview_icon_view(rtgui_workbench_t* workbench)
{
rtgui_rect_t rect;
rtgui_view_t *view;
rtgui_button_t* open_btn;
view = demo_view(workbench, "图标视图演示");
if (item_icon == RT_NULL)
item_icon = rtgui_image_create_from_mem("xpm",
(const rt_uint8_t*)image_xpm, sizeof(image_xpm), RT_TRUE);
if (exit_icon == RT_NULL)
exit_icon = rtgui_image_create_from_mem("xpm",
(const rt_uint8_t*)exit_xpm, sizeof(exit_xpm), RT_TRUE);
/* 添加动作按钮 */
demo_view_get_rect(view, &rect);
rect.x1 += 5;
rect.x2 = rect.x1 + 80;
rect.y1 += 30;
rect.y2 = rect.y1 + 20;
open_btn = rtgui_button_create("打开图标列表");
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(open_btn));
rtgui_widget_set_rect(RTGUI_WIDGET(open_btn), &rect);
rtgui_button_set_onbutton(open_btn, open_btn_onbutton);
return view;
}