void rtgui_win_move(struct rtgui_win* win, int x, int y) { struct rtgui_event_win_move emove; RTGUI_EVENT_WIN_MOVE_INIT(&emove); if (win == RT_NULL) return; /* move window to logic position */ rtgui_widget_move_to_logic(RTGUI_WIDGET(win), x - RTGUI_WIDGET(win)->extent.x1, y - RTGUI_WIDGET(win)->extent.y1); if (win->flag & RTGUI_WIN_FLAG_CONNECTED) { /* set win hide firstly */ rtgui_widget_hide(RTGUI_WIDGET(win)); emove.wid = win; emove.x = x; emove.y = y; if (rtgui_server_post_event_sync(RTGUI_EVENT(&emove), sizeof(struct rtgui_event_win_move)) != RT_EOK) { return; } } /* set window visible */ rtgui_widget_show(RTGUI_WIDGET(win)); return; }
void rtgui_notebook_remove(struct rtgui_notebook* notebook, rt_uint16_t index) { struct rtgui_notebook_tab tab; rt_bool_t need_update = RT_FALSE; RT_ASSERT(notebook != RT_NULL); if (index < notebook->count) { if (notebook->count == 1) { tab = notebook->childs[0]; rtgui_free(notebook->childs); notebook->childs = RT_NULL; notebook->count = 0; } else { if (notebook->current == index) need_update = RT_TRUE; tab = notebook->childs[index]; for (;index < notebook->count - 1; index++) { notebook->childs[index] = notebook->childs[index + 1]; } notebook->count -= 1; notebook->childs = (struct rtgui_notebook_tab*) rtgui_realloc(notebook->childs, sizeof(struct rtgui_notebook_tab) * notebook->count); } rt_free(tab.title); if (need_update) { if (notebook->current > notebook->count - 1) notebook->current = notebook->count - 1; rtgui_widget_hide(tab.widget); rtgui_widget_show(notebook->childs[notebook->current].widget); rtgui_widget_update(RTGUI_WIDGET(notebook)); rtgui_widget_set_parent(tab.widget, RT_NULL); } } }
void rtgui_notebook_set_current_by_index(struct rtgui_notebook* notebook, rt_uint16_t index) { RT_ASSERT(notebook != RT_NULL); if ((index < notebook->count) && (notebook->current != index)) { struct rtgui_widget *widget; if (notebook->current != RTGUI_NOT_FOUND) rtgui_widget_hide(notebook->childs[notebook->current].widget); notebook->current = index; widget = notebook->childs[notebook->current].widget; rtgui_widget_show(widget); rtgui_widget_update_clip(widget); rtgui_widget_update(widget); rtgui_widget_focus(widget); } }
rt_base_t rtgui_win_show(struct rtgui_win* win, rt_bool_t is_modal) { rt_base_t exit_code = -1; struct rtgui_app *app; struct rtgui_event_win_show eshow; app = rtgui_app_self(); RTGUI_EVENT_WIN_SHOW_INIT(&eshow); eshow.wid = win; if (win == RT_NULL) return exit_code; /* if it does not register into server, create it in server */ if (!(win->flag & RTGUI_WIN_FLAG_CONNECTED)) { if (_rtgui_win_create_in_server(win) == RT_FALSE) return exit_code; } /* set window unhidden before notify the server */ rtgui_widget_show(RTGUI_WIDGET(win)); if (rtgui_server_post_event_sync(RTGUI_EVENT(&eshow), sizeof(struct rtgui_event_win_show)) != RT_EOK) { /* It could not be shown if a parent window is hidden. */ rtgui_widget_hide(RTGUI_WIDGET(win)); return exit_code; } if (win->focused_widget == RT_NULL) rtgui_widget_focus(RTGUI_WIDGET(win)); /* set main window */ if (app->main_object == RT_NULL) rtgui_app_set_main_win(win); if (is_modal == RT_TRUE) { struct rtgui_app *app; struct rtgui_event_win_modal_enter emodal; RTGUI_EVENT_WIN_MODAL_ENTER_INIT(&emodal); emodal.wid = win; app = rtgui_app_self(); RT_ASSERT(app != RT_NULL); win->flag |= RTGUI_WIN_FLAG_MODAL; if (rtgui_server_post_event_sync((struct rtgui_event*)&emodal, sizeof(emodal)) != RT_EOK) return exit_code; app->modal_object = RTGUI_OBJECT(win); exit_code = rtgui_app_run(app); app->modal_object = RT_NULL; win->flag &= ~RTGUI_WIN_FLAG_MODAL; if (win->style & RTGUI_WIN_STYLE_DESTROY_ON_CLOSE) { rtgui_win_destroy(win); } } return exit_code; }