本文整理汇总了C++中rtgui_widget_set_rect函数的典型用法代码示例。如果您正苦于以下问题:C++ rtgui_widget_set_rect函数的具体用法?C++ rtgui_widget_set_rect怎么用?C++ rtgui_widget_set_rect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rtgui_widget_set_rect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rtgui_combo_add_string
void rtgui_combo_add_string(rtgui_combo_t* cbo,const char* string)
{
if(cbo->lbox != RT_NULL)
{
rtgui_listbox_item_t item;
rtgui_rect_t rect;
rt_uint32_t h,count;
item.name = (char*)string;
item.image = RT_NULL;
rtgui_listbox_add_item(cbo->lbox, &item, 1);
rtgui_widget_get_rect(cbo->lbox, &rect);
count = rtgui_listbox_get_count(cbo->lbox);
h = RTGUI_WIDGET_BORDER_SIZE(cbo->lbox)*2+(RTGUI_SEL_H + 2)*count;
if(h>RC_H(rect))
{
if(cbo->lbox->item_per_page<5)/* change when less than five */
{
rect.y2 = rect.y1+h;
rtgui_widget_rect_to_device(cbo->lbox,&rect);
rtgui_widget_set_rect(cbo->lbox,&rect);/* update listbox extent */
cbo->lbox->item_per_page = RC_H(rect) / (RTGUI_SEL_H+2);
if(cbo->lbox->scroll != RT_NULL)/* update scrollbar extent */
{
rtgui_widget_get_rect(cbo->lbox->scroll, &rect);
rect.y2 = rect.y1+h-RTGUI_WIDGET_BORDER_SIZE(cbo->lbox)*2;
rtgui_widget_rect_to_device(cbo->lbox->scroll,&rect);
rtgui_widget_set_rect(cbo->lbox->scroll,&rect);
if(cbo->lbox->item_count > cbo->lbox->item_per_page)
{
RTGUI_WIDGET_SHOW(cbo->lbox->scroll);
rtgui_scrollbar_set_line_step(cbo->lbox->scroll, 1);
rtgui_scrollbar_set_page_step(cbo->lbox->scroll, cbo->lbox->item_per_page);
rtgui_scrollbar_set_range(cbo->lbox->scroll, cbo->lbox->item_count);
}
else
{
RTGUI_WIDGET_HIDE(cbo->lbox->scroll);
}
rtgui_widget_update_clip(cbo->lbox);
}
}
}
}
}
示例2: rtgui_win_create
rtgui_win_t* rtgui_win_create(rtgui_toplevel_t* parent_toplevel, const char* title, rtgui_rect_t *rect, rt_uint8_t style)
{
struct rtgui_win* win;
/* allocate win memory */
win = (struct rtgui_win*) rtgui_widget_create (RTGUI_WIN_TYPE);
if (win != RT_NULL)
{
/* set parent toplevel */
win->parent_toplevel = parent_toplevel;
/* set title, rect and style */
if (title != RT_NULL) win->title = rt_strdup(title);
else win->title = RT_NULL;
rtgui_widget_set_rect(RTGUI_WIDGET(win), rect);
win->style = style;
if (_rtgui_win_create_in_server(win) == RT_FALSE)
{
rtgui_widget_destroy(RTGUI_WIDGET(win));
return RT_NULL;
}
}
return 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: while
/*
* head_name[] -- 最后一个元素必须是NULL
* rows -- 包含表头在内
*/
rtgui_form_t *rtgui_form_create(const char *head_name[], int rows, int cols, rtgui_rect_t *rect)
{
int i, len;
struct rtgui_form *form;
if (NULL==head_name || NULL==rect)
return NULL;
form = (struct rtgui_form *)rtgui_widget_create(RTGUI_FORM_TYPE);
if (NULL == form)
return NULL;
i = 0;
while (NULL != head_name[i])
++i;
if (i != cols) {
form_debug(("%s(), head items (%d) not same as cols(%d)!\n", __FUNCTION__, i, cols));
goto err_entry;
}
form_debug(("%s(), line:%d: rows:%d, cols:%d!\n", __FUNCTION__, __LINE__, rows, cols));
len = 0;
for (i=0; i<cols; ++i) {
len += rt_strlen(head_name[i]);
}
len += cols * GAG_BETWEEN_COL;
form->fbody = rt_calloc(len*(rows-1), 1); /* 不包含表格头部占用的存储空间 */
if (NULL == form->fbody) {
form_debug(("fun:%s(), line:%d:%d malloc fail!\n", __FUNCTION__, __LINE__, len*(rows-1)));
goto err_entry;
}
form->head_name = rt_calloc(cols, sizeof(head_name[0]));
if (NULL == form->head_name) {
form_debug(("fun:%s(), line:%d:%d malloc fail!\n", __FUNCTION__, __LINE__, cols * sizeof(head_name[0])));
rt_free(form->fbody);
goto err_entry;
}
form_debug(("%s(), line:%d: fbody-len:%d, head-name-len:%d!\n", __FUNCTION__, __LINE__,
len*(rows-1), cols * sizeof(head_name[0])));
for (i=0; i<cols; ++i) {
form->head_name[i] = head_name[i];
}
form->head_item_cnt = cols;
form->row_cnt_of_fbody = rows - 1;
form->bytes_of_row = len;
rtgui_widget_set_rect(RTGUI_WIDGET(form), rect);
return form;
err_entry:
rtgui_widget_destroy(RTGUI_WIDGET(form));
return NULL;
}
示例5: rtgui_win_create
rtgui_win_t* rtgui_win_create(struct rtgui_win* parent_window,
const char* title,
rtgui_rect_t *rect,
rt_uint16_t style)
{
struct rtgui_win* win;
/* allocate win memory */
win = RTGUI_WIN(rtgui_widget_create(RTGUI_WIN_TYPE));
if (win == RT_NULL)
return RT_NULL;
/* set parent toplevel */
win->parent_window = parent_window;
/* set title, rect and style */
if (title != RT_NULL)
win->title = rt_strdup(title);
else
win->title = RT_NULL;
rtgui_widget_set_rect(RTGUI_WIDGET(win), rect);
win->style = style;
if (_rtgui_win_create_in_server(win) == RT_FALSE)
{
goto __on_err;
}
return win;
__on_err:
rtgui_widget_destroy(RTGUI_WIDGET(win));
return RT_NULL;
}
示例6: 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;
}
示例7: show_modal_info
rt_bool_t show_modal_info(struct rtgui_widget *object, struct rtgui_event *event)
{
rtgui_label_t *label;
struct rtgui_win *win;
rtgui_rect_t rect = {0, 60, 150, 100};
win = rtgui_win_create(main_win,
"Info",
&rect,
RTGUI_WIN_STYLE_DEFAULT);
rect.x1 += 20;
rect.x2 -= 5;
rect.y1 += 5;
rect.y2 = rect.y1 + 20;
label = rtgui_label_create("modal mode info");
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);
return RT_TRUE;
}
示例8: rtgui_checkbox_create
struct rtgui_checkbox* rtgui_checkbox_create(const char* text, rt_bool_t checked)
{
struct rtgui_checkbox* box;
box = (struct rtgui_checkbox*) rtgui_widget_create (RTGUI_CHECKBOX_TYPE);
if (box != RT_NULL)
{
rtgui_rect_t rect;
/* set default rect */
rtgui_font_get_metrics(rtgui_font_default(), text, &rect);
rect.x2 += RTGUI_BORDER_DEFAULT_WIDTH + 5 + (RTGUI_BORDER_DEFAULT_WIDTH << 1);
rect.y2 += (RTGUI_BORDER_DEFAULT_WIDTH << 1);
rtgui_widget_set_rect(RTGUI_WIDGET(box), &rect);
rtgui_label_set_text(RTGUI_LABEL(box), text);
if (checked == RT_TRUE)
box->status_down = RTGUI_CHECKBOX_STATUS_CHECKED;
else
box->status_down = RTGUI_CHECKBOX_STATUS_UNCHECKED;
}
return box;
}
示例9: rtgui_menu_pop
void rtgui_menu_pop(struct rtgui_menu* menu, int x, int y)
{
rtgui_rect_t rect;
struct rtgui_event_resize eresize;
if (menu == RT_NULL) return;
/* set window extent */
rect.x1 = 0; rect.y1 = 0;
rect.x2 = 100; rect.y2 = menu->items_count * (rtgui_theme_get_selected_height() + 2) + 5;
rtgui_rect_moveto(&rect, x, y);
rtgui_win_set_rect(RTGUI_WIN(menu), &rect);
rtgui_rect_inflate(&rect, -1);
rtgui_widget_set_rect(RTGUI_WIDGET(menu->items_list), &rect);
eresize.parent.type = RTGUI_EVENT_RESIZE;
eresize.x = rect.x1; eresize.y = rect.y1;
eresize.h = rect.y2 - rect.y1; eresize.w = rect.x2 - rect.x1;
rtgui_listctrl_event_handler(RTGUI_WIDGET(menu->items_list), &(eresize.parent));
/* on menu pop handler */
if (menu->on_menupop != RT_NULL)
{
menu->on_menupop(RTGUI_WIDGET(menu), RT_NULL);
}
/* show menu window */
rtgui_win_show(RTGUI_WIN(menu), RT_FALSE);
}
示例10: _rtgui_filelist_view_constructor
static void _rtgui_filelist_view_constructor(struct rtgui_filelist_view *view)
{
/* default rect */
struct rtgui_rect rect = {0, 0, 200, 200};
/* set default widget rect and set event handler */
rtgui_object_set_event_handler(RTGUI_OBJECT(view), rtgui_filelist_view_event_handler);
rtgui_widget_set_rect(RTGUI_WIDGET(view), &rect);
RTGUI_WIDGET(view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
view->current_item = 0;
view->items_count = 0;
view->page_items = 0;
view->on_changed = RT_NULL;
view->current_directory = RT_NULL;
view->pattern = RT_NULL;
RTGUI_WIDGET_BACKGROUND(view) = white;
RTGUI_WIDGET_TEXTALIGN(view) = RTGUI_ALIGN_CENTER_VERTICAL;
_instance_count++;
if (_instance_count == 1)
{
file_image = rtgui_image_create_from_mem("xpm", (rt_uint8_t *)file_xpm,
sizeof(file_xpm), RT_TRUE);
folder_image = rtgui_image_create_from_mem("xpm", (rt_uint8_t *)folder_xpm,
sizeof(folder_xpm), RT_TRUE);
}
}
示例11: 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);
}
示例12: listitem_action
/* 列表项的动作函数 */
static void listitem_action(rtgui_widget_t *widget, void *parameter)
{
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(main_win,
"窗口", &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(win, RTGUI_WIDGET(label));
/* 非模态显示窗口 */
rtgui_win_show(win, RT_FALSE);
}
示例13: _rtgui_textbox_constructor
static void _rtgui_textbox_constructor(rtgui_textbox_t *box)
{
rtgui_rect_t rect = {0, 0, RTGUI_TEXTBOX_DEFAULT_WIDTH, RTGUI_TEXTBOX_DEFAULT_HEIGHT};
rtgui_widget_set_rect(RTGUI_WIDGET(box), &rect);
RTGUI_WIDGET(box)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
rtgui_object_set_event_handler(RTGUI_OBJECT(box), rtgui_textbox_event_handler);
rtgui_widget_set_onfocus(RTGUI_WIDGET(box), rtgui_textbox_onfocus);
rtgui_widget_set_onunfocus(RTGUI_WIDGET(box), rtgui_textbox_onunfocus);
/* set default text align */
RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(box)) = RTGUI_ALIGN_CENTER_VERTICAL;
/* set proper of control */
box->caret_timer = rtgui_timer_create(RT_TICK_PER_SECOND, RT_TIMER_FLAG_PERIODIC,
_rtgui_textbox_caret_timeout, box);
box->line = box->line_begin = box->position = 0;
box->flag = RTGUI_TEXTBOX_SINGLE;
/* allocate default line buffer */
box->text = RT_NULL;
rtgui_font_get_metrics(RTGUI_WIDGET(box)->gc.font, "h", &rect);
box->font_width = rtgui_rect_width(rect);
}
示例14: 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;
}
示例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;
}