void rtgui_server_thread_panel_show(struct rtgui_event_panel_show* event) { struct rtgui_panel* panel = event->panel; if (panel != RT_NULL) { struct rtgui_event_paint epaint; /* send the responses */ rtgui_thread_ack(RTGUI_EVENT(event), RTGUI_STATUS_OK); if (panel->wm_thread != RT_NULL) { /* notify to workbench */ rtgui_thread_send(panel->wm_thread, &(event->parent), sizeof(struct rtgui_event_panel_show)); } rtgui_panel_set_active_thread(panel, event->parent.sender); /* send all topwin clip info */ rtgui_topwin_update_clip_to_panel(panel); /* send paint event */ RTGUI_EVENT_PAINT_INIT(&epaint); epaint.wid = RT_NULL; rtgui_thread_send(event->parent.sender, (struct rtgui_event*)&epaint, sizeof(epaint)); } else { /* send failed */ rtgui_thread_ack(RTGUI_EVENT(event), RTGUI_STATUS_ERROR); } }
void rtgui_server_destroy_application(struct rtgui_event_panel_detach* event) { struct rtgui_panel* panel = event->panel; if (panel != RT_NULL) { if (panel->wm_thread != RT_NULL) { /* notify to workbench */ rtgui_thread_send(panel->wm_thread, &(event->parent), sizeof(struct rtgui_event_panel_detach)); } /* send the responses */ rtgui_thread_ack(RTGUI_EVENT(event), RTGUI_STATUS_OK); rtgui_panel_thread_remove(panel, event->parent.sender); { /* get next thread and active it */ rt_thread_t tid = rtgui_panel_get_active_thread(panel); /* let this thread repaint */ struct rtgui_event_paint epaint; RTGUI_EVENT_PAINT_INIT(&epaint); epaint.wid = RT_NULL; rtgui_thread_send(tid, (struct rtgui_event*)&epaint, sizeof(epaint)); } } else { /* send the responses - failure */ rtgui_thread_ack(RTGUI_EVENT(event), RTGUI_STATUS_NRC); } }
static rt_bool_t rtgui_win_ondraw(struct rtgui_win* win) { struct rtgui_dc* dc; struct rtgui_rect rect; struct rtgui_event_paint event; /* begin drawing */ dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(win)); if (dc == RT_NULL) return RT_FALSE; /* get window rect */ rtgui_widget_get_rect(RTGUI_WIDGET(win), &rect); /* fill area */ rtgui_dc_fill_rect(dc, &rect); /* paint each widget */ RTGUI_EVENT_PAINT_INIT(&event); event.wid = RT_NULL; rtgui_container_dispatch_event(RTGUI_CONTAINER(win), (rtgui_event_t*)&event); rtgui_dc_end_drawing(dc); return RT_FALSE; }
void rtgui_server_thread_panel_hide(struct rtgui_event_panel_hide* event) { struct rtgui_panel* panel = event->panel; if (panel != RT_NULL) { rt_thread_t tid; struct rtgui_event_paint epaint; /* send the responses */ rtgui_thread_ack(RTGUI_EVENT(event), RTGUI_STATUS_OK); if (panel->thread_list.next != RT_NULL) { struct rtgui_panel_thread* thread; thread = rtgui_list_entry(panel->thread_list.next, struct rtgui_panel_thread, list); /* remove it */ panel->thread_list.next = thread->list.next; /* append to the tail of thread list */ rtgui_list_append(&(panel->thread_list), &(thread->list)); } /* get new active thread */ tid = rtgui_panel_get_active_thread(panel); /* send all topwin clip info */ rtgui_topwin_update_clip_to_panel(panel); /* send paint event */ RTGUI_EVENT_PAINT_INIT(&epaint); epaint.wid = RT_NULL; rtgui_thread_send(tid, (struct rtgui_event*)&epaint, sizeof(epaint)); }
rt_bool_t rtgui_workbench_event_handler(rtgui_widget_t* widget, rtgui_event_t* event) { struct rtgui_workbench* workbench = (struct rtgui_workbench*)widget; switch (event->type) { case RTGUI_EVENT_PANEL_DETACH: RTGUI_WIDGET_HIDE(RTGUI_WIDGET(workbench)); RTGUI_TOPLEVEL(workbench)->server = RT_NULL; return RT_TRUE; case RTGUI_EVENT_PANEL_SHOW: /* show workbench in server */ rtgui_workbench_show(workbench); break; case RTGUI_EVENT_PANEL_HIDE: /* hide widget */ RTGUI_WIDGET_HIDE(widget); break; case RTGUI_EVENT_MOUSE_MOTION: { struct rtgui_event_mouse* emouse = (struct rtgui_event_mouse*)event; struct rtgui_toplevel* top = RTGUI_TOPLEVEL(emouse->wid); /* check the destination window */ if (top != RT_NULL && RTGUI_WIDGET(top)->event_handler != RT_NULL) { RTGUI_WIDGET(top)->event_handler(RTGUI_WIDGET(top), event); } else { /* let viewer to handle it */ rtgui_view_t* view = workbench->current_view; if (view != RT_NULL && RTGUI_WIDGET(view)->event_handler != RT_NULL) { RTGUI_WIDGET(view)->event_handler(RTGUI_WIDGET(view), event); } } } break; case RTGUI_EVENT_MOUSE_BUTTON: { struct rtgui_event_mouse* emouse = (struct rtgui_event_mouse*)event; struct rtgui_toplevel* top = RTGUI_TOPLEVEL(emouse->wid); /* check the destination window */ if (top != RT_NULL && RTGUI_WIDGET(top)->event_handler != RT_NULL) { RTGUI_WIDGET(top)->event_handler(RTGUI_WIDGET(top), event); } else { if (RTGUI_WORKBENCH_IS_MODAL_MODE(workbench)) { /* let modal widget to handle it */ if (workbench->modal_widget != RT_NULL && workbench->modal_widget->event_handler != RT_NULL) { workbench->modal_widget->event_handler(workbench->modal_widget, event); } } else { /* let viewer to handle it */ rtgui_view_t* view = workbench->current_view; if (view != RT_NULL && RTGUI_WIDGET(view)->event_handler != RT_NULL) { RTGUI_WIDGET(view)->event_handler(RTGUI_WIDGET(view), event); } } } } break; case RTGUI_EVENT_KBD: { struct rtgui_event_kbd* kbd = (struct rtgui_event_kbd*)event; struct rtgui_toplevel* top = RTGUI_TOPLEVEL(kbd->wid); /* check the destination window */ if (top != RT_NULL && RTGUI_WIDGET(top)->event_handler != RT_NULL) { RTGUI_WIDGET(top)->event_handler(RTGUI_WIDGET(top), event); } else { if (RTGUI_WORKBENCH_IS_MODAL_MODE(workbench)) { /* let modal widget to handle it */ if (workbench->modal_widget != RT_NULL && workbench->modal_widget->event_handler != RT_NULL) { workbench->modal_widget->event_handler(workbench->modal_widget, event); } } else { if (RTGUI_CONTAINER(widget)->focused == widget) { /* set focused widget to the current view */ if (workbench->current_view != RT_NULL) rtgui_widget_focus(RTGUI_WIDGET(RTGUI_CONTAINER(workbench->current_view)->focused)); } return rtgui_toplevel_event_handler(widget, event); } } } break; case RTGUI_EVENT_PAINT: { struct rtgui_event_paint* epaint = (struct rtgui_event_paint*)event; struct rtgui_toplevel* top = RTGUI_TOPLEVEL(epaint->wid); /* check the destination window */ if (top != RT_NULL && RTGUI_WIDGET(top)->event_handler != RT_NULL) { RTGUI_WIDGET(top)->event_handler(RTGUI_WIDGET(top), event); } else { rtgui_view_t* view; /* un-hide workbench */ RTGUI_WIDGET_UNHIDE(widget); /* paint a view */ view = workbench->current_view; if (view != RT_NULL) { /* remake a paint event */ RTGUI_EVENT_PAINT_INIT(epaint); epaint->wid = RT_NULL; /* send this event to the view */ if (RTGUI_WIDGET(view)->event_handler != RT_NULL) { RTGUI_WIDGET(view)->event_handler(RTGUI_WIDGET(view), event); } } else { struct rtgui_dc* dc; struct rtgui_rect rect; dc = rtgui_dc_begin_drawing(widget); rtgui_widget_get_rect(widget, &rect); rtgui_dc_fill_rect(dc, &rect); rtgui_dc_end_drawing(dc); } } } break; case RTGUI_EVENT_CLIP_INFO: { struct rtgui_event_clip_info* eclip = (struct rtgui_event_clip_info*)event; struct rtgui_widget* dest_widget = RTGUI_WIDGET(eclip->wid); if (dest_widget != RT_NULL && dest_widget->event_handler != RT_NULL) { dest_widget->event_handler(dest_widget, event); } else { return rtgui_toplevel_event_handler(widget, event); } } break; case RTGUI_EVENT_WIN_CLOSE: case RTGUI_EVENT_WIN_ACTIVATE: case RTGUI_EVENT_WIN_DEACTIVATE: { struct rtgui_event_win* wevent = (struct rtgui_event_win*)event; struct rtgui_widget* dest_widget = RTGUI_WIDGET(wevent->wid); if (dest_widget != RT_NULL && dest_widget->event_handler != RT_NULL) { dest_widget->event_handler(dest_widget, event); } } break; case RTGUI_EVENT_WIN_MOVE: { struct rtgui_event_win_move* wevent = (struct rtgui_event_win_move*)event; struct rtgui_toplevel* top = RTGUI_TOPLEVEL(wevent->wid); if (top != RT_NULL && RTGUI_WIDGET(top)->event_handler != RT_NULL) { RTGUI_WIDGET(top)->event_handler(RTGUI_WIDGET(top), event); } } break; default: return rtgui_toplevel_event_handler(widget, event); } return RT_TRUE; }