本文整理汇总了C++中RTGUI_OBJECT函数的典型用法代码示例。如果您正苦于以下问题:C++ RTGUI_OBJECT函数的具体用法?C++ RTGUI_OBJECT怎么用?C++ RTGUI_OBJECT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTGUI_OBJECT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rtgui_recv_filter
rt_err_t rtgui_recv_filter(rt_uint32_t type, rtgui_event_t *event, rt_size_t event_size)
{
struct rtgui_app *app;
RT_ASSERT(event != RT_NULL);
RT_ASSERT(event_size != 0);
app = (struct rtgui_app *)(rt_thread_self()->user_data);
if (app == RT_NULL)
return -RT_ERROR;
while (rt_mq_recv(app->mq, event, event_size, RT_WAITING_FOREVER) == RT_EOK)
{
if (event->type == type)
{
return RT_EOK;
}
else
{
if (RTGUI_OBJECT(app)->event_handler != RT_NULL)
{
RTGUI_OBJECT(app)->event_handler(RTGUI_OBJECT(app), event);
}
}
}
return -RT_ERROR;
}
示例2: 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_OBJECT(menu->items_list), &(eresize.parent));
/* on menu pop handler */
if (menu->on_menupop != RT_NULL)
{
menu->on_menupop(RTGUI_OBJECT(menu), RT_NULL);
}
/* show menu window */
rtgui_win_show(RTGUI_WIN(menu), RT_FALSE);
}
示例3: rtgui_recv_filter
rt_err_t rtgui_recv_filter(rt_uint32_t type, rtgui_event_t *event, rt_size_t event_size)
{
rtgui_event_t *e;
struct rtgui_app *app;
RT_ASSERT(event != RT_NULL);
RT_ASSERT(event_size != 0);
app = (struct rtgui_app *)(rt_thread_self()->user_data);
if (app == RT_NULL)
return -RT_ERROR;
e = (rtgui_event_t*)&app->event_buffer[0];
while (rt_mq_recv(app->mq, e, sizeof(union rtgui_event_generic), RT_WAITING_FOREVER) == RT_EOK)
{
if (e->type == type)
{
rt_memcpy(event, e, event_size);
return RT_EOK;
}
else
{
if (RTGUI_OBJECT(app)->event_handler != RT_NULL)
{
RTGUI_OBJECT(app)->event_handler(RTGUI_OBJECT(app), e);
}
}
}
return -RT_ERROR;
}
示例4: _rtgui_application_event_loop
rt_inline void _rtgui_application_event_loop(struct rtgui_app *app)
{
rt_err_t result;
rt_uint16_t current_ref;
struct rtgui_event *event;
_rtgui_application_check(app);
/* point to event buffer */
event = (struct rtgui_event*)app->event_buffer;
current_ref = ++app->ref_count;
while (current_ref <= app->ref_count)
{
RT_ASSERT(current_ref == app->ref_count);
if (app->on_idle != RT_NULL)
{
result = rtgui_recv_nosuspend(event, sizeof(union rtgui_event_generic));
if (result == RT_EOK)
RTGUI_OBJECT(app)->event_handler(RTGUI_OBJECT(app), event);
else if (result == -RT_ETIMEOUT)
app->on_idle(RTGUI_OBJECT(app), RT_NULL);
}
else
{
result = rtgui_recv(event, sizeof(union rtgui_event_generic));
if (result == RT_EOK)
RTGUI_OBJECT(app)->event_handler(RTGUI_OBJECT(app), event);
}
}
}
示例5: _rtgui_notebook_current_widget_handle
static rt_bool_t _rtgui_notebook_current_widget_handle(struct rtgui_notebook *notebook,
struct rtgui_event *event)
{
struct rtgui_widget *widget = rtgui_notebook_get_current(notebook);
if (widget && widget != RTGUI_WIDGET(notebook))
return RTGUI_OBJECT(widget)->event_handler(RTGUI_OBJECT(widget), event);
else
return RT_FALSE;
}
示例6: rtgui_slider_event_handler
rt_bool_t rtgui_slider_event_handler(struct rtgui_object *object, struct rtgui_event *event)
{
struct rtgui_widget *widget;
struct rtgui_slider* slider;
RT_ASSERT(object != RT_NULL);
RT_ASSERT(event != RT_NULL);
widget = RTGUI_WIDGET(object);
slider = RTGUI_SLIDER(object);
switch (event->type)
{
case RTGUI_EVENT_PAINT:
#ifndef RTGUI_USING_SMALL_SIZE
if (widget->on_draw != RT_NULL)
widget->on_draw(RTGUI_OBJECT(widget), event);
else
#endif
{
rtgui_theme_draw_slider(slider);
}
break;
case RTGUI_EVENT_KBD:
if (!RTGUI_WIDGET_IS_ENABLE(widget) || RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE;
#ifndef RTGUI_USING_SMALL_SIZE
if (widget->on_key != RT_NULL)
widget->on_key(RTGUI_OBJECT(widget), event);
else
#endif
{
return rtgui_slider_onkey(slider, (struct rtgui_event_kbd *)event);
}
break;
case RTGUI_EVENT_MOUSE_BUTTON:
if (!RTGUI_WIDGET_IS_ENABLE(widget) || RTGUI_WIDGET_IS_HIDE(widget)) return RT_FALSE;
#ifndef RTGUI_USING_SMALL_SIZE
if (widget->on_mouseclick != RT_NULL)
widget->on_mouseclick(RTGUI_OBJECT(widget), event);
else
#endif
{
rtgui_slider_onmouse(slider, (struct rtgui_event_mouse*)event);
}
break;
}
return RT_FALSE;
}
示例7: _rtgui_notebook_onmouse
static void _rtgui_notebook_onmouse(struct rtgui_notebook *notebook, struct rtgui_event_mouse* emouse)
{
rtgui_rect_t rect;
/* handle notebook bar */
_rtgui_notebook_get_bar_rect(notebook, &rect);
rtgui_widget_rect_to_device(RTGUI_WIDGET(notebook), &rect);
if (rtgui_rect_contains_point(&rect, emouse->x, emouse->y) == RT_EOK)
{
int index;
struct rtgui_dc* dc;
if (notebook->flag == RTGUI_NOTEBOOK_BOTTOM || notebook->flag == RTGUI_NOTEBOOK_TOP)
{
index = (emouse->x - rect.x1) / notebook->tab_w;
if (index < notebook->count && index != notebook->current)
{
/* update tab bar */
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(notebook));
if (dc == RT_NULL) return;
rtgui_notebook_set_current_by_index(notebook, index);
_rtgui_notebook_draw_bar(notebook, dc);
rtgui_dc_end_drawing(dc);
}
}
else
{
index = (emouse->y - rect.y1) / notebook->tab_h;
if (index < notebook->count && index != notebook->current)
{
/* update tab bar */
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(notebook));
if (dc == RT_NULL) return;
rtgui_notebook_set_current_by_index(notebook, index);
_rtgui_notebook_draw_bar(notebook, dc);
rtgui_dc_end_drawing(dc);
}
}
}
else
{
/* handle on page */
if (RTGUI_OBJECT(notebook->childs[notebook->current].widget)->event_handler != RT_NULL)
RTGUI_OBJECT(notebook->childs[notebook->current].widget)->event_handler(
RTGUI_OBJECT(notebook->childs[notebook->current].widget),
&(emouse->parent));
}
}
示例8: _rtgui_notebook_ontab
static void _rtgui_notebook_ontab(struct rtgui_notebook *notebook, struct rtgui_event *event)
{
int index;
for (index = 0; index < notebook->count; index ++)
{
struct rtgui_widget *widget;
widget = notebook->childs[index].widget;
if (RTGUI_OBJECT(widget)->event_handler &&
RTGUI_OBJECT(widget)->event_handler(RTGUI_OBJECT(widget), event) == RT_TRUE)
break;
}
}
示例9: _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);
}
}
示例10: _rtgui_menu_onitem
static rt_bool_t _rtgui_menu_onitem(struct rtgui_object* object, struct rtgui_event* event)
{
struct rtgui_menu* menu;
/* event will be NULL, don't check it. */
RT_ASSERT(object);
/* get menu */
menu = RTGUI_MENU(rtgui_widget_get_toplevel(RTGUI_WIDGET(object)));
if (menu->items[menu->items_list->current_item].type == RTGUI_ITEM_SUBMENU)
{
const rtgui_menu_item_t* items;
rt_uint16_t count;
rtgui_rect_t item_rect;
items = (rtgui_menu_item_t*)menu->items[menu->items_list->current_item].submenu;
count = menu->items[menu->items_list->current_item].submenu_count;
if (menu->sub_menu != RT_NULL)
{
if (menu->sub_menu->items == items)
{
if (!RTGUI_WIDGET_IS_HIDE(RTGUI_WIDGET(menu->sub_menu)))
{
/* hide this sub menu */
rtgui_win_hiden(RTGUI_WIN(menu->sub_menu));
return RT_FALSE;
}
/* show this sub menu */
rtgui_listctrl_get_item_rect(menu->items_list, menu->items_list->current_item, &item_rect);
rtgui_menu_pop(menu->sub_menu, item_rect.x2, item_rect.y1);
return RT_FALSE;
}
/* delete sub menu */
rtgui_menu_destroy(menu->sub_menu);
menu->sub_menu = RT_NULL;
}
/* create sub menu */
menu->sub_menu = rtgui_menu_create("submenu", menu, items, count);
rtgui_listctrl_get_item_rect(menu->items_list, menu->items_list->current_item, &item_rect);
rtgui_menu_pop(menu->sub_menu, item_rect.x2 + 5, item_rect.y1);
}
else /* other menu item */
{
/* invoke action */
if (menu->items[menu->items_list->current_item].on_menuaction != RT_NULL)
menu->items[menu->items_list->current_item].on_menuaction(RTGUI_OBJECT(menu), RT_NULL);
/* hide sub-menu */
if (menu->sub_menu != RT_NULL)
{
rtgui_menu_hiden(menu->sub_menu);
}
rtgui_menu_hiden(menu);
}
return RT_FALSE;
}
示例11: _rtgui_win_deal_close
static rt_bool_t _rtgui_win_deal_close(struct rtgui_win *win,
struct rtgui_event *event,
rt_bool_t force_close)
{
if (win->on_close != RT_NULL)
{
if ((win->on_close(RTGUI_OBJECT(win), event) == RT_FALSE) && !force_close)
return RT_FALSE;
}
rtgui_win_hiden(win);
win->flag |= RTGUI_WIN_FLAG_CLOSED;
if (win->flag & RTGUI_WIN_FLAG_MODAL)
{
rtgui_win_end_modal(win, RTGUI_MODAL_CANCEL);
}
else if (win->style & RTGUI_WIN_STYLE_DESTROY_ON_CLOSE)
{
rtgui_win_destroy(win);
}
return RT_TRUE;
}
示例12: _rtgui_digtube_constructor
static void _rtgui_digtube_constructor(struct rtgui_digtube * digtube)
{
RTGUI_WIDGET_TEXTALIGN(digtube) = RTGUI_ALIGN_CENTER;
/* init widget and set event handler */
rtgui_object_set_event_handler(RTGUI_OBJECT(digtube), rtgui_digtube_event_handler);
}
示例13: app_mainmenu_init
static void app_mainmenu_init(void)
{
struct rtgui_image *bg_image;
rtgui_rect_t rect;
/* create main window of Application Manager */
win = rtgui_mainwin_create(RT_NULL, "mainmenu", RTGUI_WIN_STYLE_MAINWIN);
if (win != RT_NULL)
{
rtgui_object_set_event_handler(RTGUI_OBJECT(win), mainmenu_event_handler);
rtgui_widget_get_rect(RTGUI_WIDGET(win), &rect);
#ifdef RT_USING_MODULE
mainmenu_scan_apps();
#endif
/* create background image */
bg_image = rtgui_image_create("/resource/bg_image.jpg", RT_TRUE);
if (bg_image == RT_NULL)
{
rt_kprintf("open \"/resource/bg_image.jpg\" failed\n");
}
ycircle_image = rtgui_image_create("/resource/ycircle.png", RT_TRUE);
gcircle_image = rtgui_image_create("/resource/gcircle.png", RT_TRUE);
app_list = app_list_create(&rect, items, ITEM_MAX, 2, 5, bg_image);
rtgui_image_destroy(bg_image);
app_list_draw(app_list);
app_list_draw_pagemark(app_list);
app_list->on_select = exec_internal_app;
rtgui_win_show(win, RT_FALSE);
/* set as main window */
rtgui_app_set_main_win(rtgui_app_self(), win);
}
}
示例14: _rtgui_win_constructor
static void _rtgui_win_constructor(rtgui_win_t *win)
{
RTGUI_WIDGET(win)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
win->parent_window = RT_NULL;
/* init window attribute */
win->on_activate = RT_NULL;
win->on_deactivate = RT_NULL;
win->on_close = RT_NULL;
win->on_key = RT_NULL;
win->title = RT_NULL;
win->modal_code = RTGUI_MODAL_OK;
/* initialize last mouse event handled widget */
win->last_mevent_widget = RT_NULL;
win->focused_widget = RT_NULL;
/* set window hide */
RTGUI_WIDGET_HIDE(RTGUI_WIDGET(win));
/* set window style */
win->style = RTGUI_WIN_STYLE_DEFAULT;
win->flag = RTGUI_WIN_FLAG_INIT;
rtgui_object_set_event_handler(RTGUI_OBJECT(win), rtgui_win_event_handler);
/* init user data */
win->user_data = 0;
}
示例15: _rtgui_textbox_constructor
static void _rtgui_textbox_constructor(rtgui_textbox_t *box)
{
rtgui_rect_t rect;
RTGUI_WIDGET_FLAG(RTGUI_WIDGET(box)) |= 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);
#ifndef RTGUI_USING_SMALL_SIZE
rtgui_widget_set_onkey(RTGUI_WIDGET(box), rtgui_textbox_onkey);
#endif
RTGUI_WIDGET_FOREGROUND(box) = black;
RTGUI_WIDGET_BACKGROUND(box) = white;
/* set default text align */
RTGUI_WIDGET_TEXTALIGN(box) = RTGUI_ALIGN_CENTER_VERTICAL;
/* set proper of control */
box->caret_timer = RT_NULL;
box->caret = RT_NULL;
box->line = box->line_begin = box->position = 0;
box->flag = RTGUI_TEXTBOX_SINGLE;
/* allocate default line buffer */
box->text = RT_NULL;
rtgui_textbox_set_mask_char(box, '*');
rtgui_font_get_metrics(RTGUI_WIDGET_FONT(box), "H", &rect);
box->font_width = rtgui_rect_width(rect);
box->on_enter = RT_NULL;
box->dis_length = 0;
box->first_pos = 0;
}