void GUIDestroyWnd( gui_window *wnd ) { HWND hwnd; gui_window *curr; if( wnd == NULL ) { curr = GUIGetFront(); while( curr != NULL ) { if( curr->flags & DOING_CLOSE ) { curr = GUIGetNextWindow( curr ); } else if( _wpi_getparent( GUIGetParentFrameHWND( curr ) ) == HWND_DESKTOP ) { GUIDestroyWnd( curr ); curr = GUIGetFront(); } else { curr = GUIGetNextWindow( curr ); } } } else { if ( GUIIsOpen( wnd ) ) { /* this will make a new window be chosen as current if this * window was current */ hwnd = GUIGetParentFrameHWND( wnd ); wnd->flags |= DOING_CLOSE; if( NumWindows == 1 || ( _wpi_getparent( hwnd ) == HWND_DESKTOP ) && !( wnd->style & GUI_POPUP ) ) { _wpi_sendmessage( hwnd, WM_CLOSE, 0, 0 ); } else { DestroyWindow( hwnd ); } } } }
bool GUIProcessEvent( EVENT ev ) { gui_event gui_ev; ORD row, col; gui_window *wnd; int prev; int diff; gui_ctl_id id; gui_window *menu_window; bool new_curr_wnd; VSCREEN *screen; // this is processed before all others and signals the end for all // GUI UI windows ( unconditional ) if( ev == EV_KILL_UI ) { GUIDestroyWnd( NULL ); return( false ); } ev = MapMiddleToRight( ev ); ev = CheckPrevEvent( ev ); wnd = NULL; if( uimouseinstalled() ) { screen = uivmousepos( NULL, &row, &col ); if( screen != NULL && (screen->flags & V_GUI_WINDOW) != 0 ) { wnd = (gui_window *)((char *)screen - offsetof( gui_window, screen )); } } if( GUIDoKeyboardMoveResize( ev ) ) { return( true ); } if( MouseState == MOUSE_MOVE || MouseState == MOUSE_SIZE ) { if( GUIDoMoveResizeCheck( GUIMouseWnd, ev, row, col ) ) { MouseState = MOUSE_FREE; return( true ); } if( GUI_WND_MINIMIZED( GUIMouseWnd ) ) { switch( ev ) { case EV_MOUSE_DCLICK : case EV_MOUSE_RELEASE : case EV_MOUSE_DRAG : ProcessMinimizedMouseEvent( ev, row, col ); } } else { switch( ev ) { case EV_MOUSE_RELEASE : case EV_MOUSE_DRAG : case EV_MOUSE_DRAG_R : ProcessMouseReleaseDrag( ev, GUI_LBUTTONUP, row, col ); } } return( true ); } new_curr_wnd = SetCurrWnd( ev, wnd ); if( GUIProcessAltMenuEvent( ev ) ) { return( true ); } /* Only deal with press and dclick events for minimized windows. * All other non-menu events are ingored. */ if( !IS_CTLEVENT( ev ) && ( GUICurrWnd != NULL ) && GUI_WND_MINIMIZED( GUICurrWnd ) ) { /* ignore event if mouse not in minimized current window */ if( GUICurrWnd == wnd ) { switch( ev ) { case EV_MOUSE_PRESS : case EV_MOUSE_DCLICK : case EV_MOUSE_RELEASE : GUIMouseWnd = GUICurrWnd; ProcessMinimizedMouseEvent( ev, row, col ); break; } } return( true ); } if( !IS_CTLEVENT( ev ) && ( GUICurrWnd != NULL ) && GUIIsOpen( GUICurrWnd ) ) { /* see if any of the controls in the window consume the event */ ev = GUIProcessControlEvent( GUICurrWnd, ev, row, col ); /* See if the event is for on of the scroll bars. */ /* Diff and prev are used if the event return is */ /* EV_SCROLL_HORIZONTAL or EV_SCROLL_VERTICAL. */ if( !new_curr_wnd || ( GUIGetWindowStyles() & ( GUI_INACT_GADGETS+GUI_INACT_SAME ) ) ) { ev = GUIGadgetFilter( GUICurrWnd, ev, &prev, &diff ); } if( ev == EV_NO_EVENT ) { return( true ); } } gui_ev = GUI_NO_EVENT; ev = GUIMapKeys( ev ); switch( ev ) { case EV_MOUSE_DCLICK_R : ProcessMousePos( GUI_RBUTTONDBLCLK, row, col, wnd ); return( true ); break; case EV_MOUSE_RELEASE_R : ProcessMouseReleaseDrag( ev, GUI_RBUTTONUP, row, col ); return( true ); break; case EV_MOUSE_DRAG_R : if( GUICurrWnd != GUIMouseWnd ) { /* got drag without press first */ ProcessMousePress( EV_MOUSE_PRESS_R, GUI_LBUTTONDOWN, row, col, new_curr_wnd ); } case EV_MOUSE_MOVE : ProcessMousePos( GUI_MOUSEMOVE, row, col, wnd ); return( true ); break; case EV_MOUSE_RELEASE : ProcessMouseReleaseDrag( ev, GUI_LBUTTONUP, row, col ); return( true ); break; case EV_MOUSE_DRAG : if( GUICurrWnd != GUIMouseWnd ) { /* got drag without press first */ ProcessMousePress( EV_MOUSE_PRESS, GUI_LBUTTONDOWN, row, col, new_curr_wnd ); } ProcessMouseReleaseDrag( ev, GUI_MOUSEMOVE, row, col ); return( true ); break; case EV_MOUSE_PRESS_R : ProcessMousePress( ev, GUI_RBUTTONDOWN, row, col, new_curr_wnd ); return( true ); break; case EV_MOUSE_PRESS : ProcessMousePress( ev, GUI_LBUTTONDOWN, row, col, new_curr_wnd ); return( true ); break; case EV_MOUSE_DCLICK : ProcessMousePress( ev, GUI_LBUTTONDBLCLK, row, col, new_curr_wnd ); return( true ); break; case EV_NO_EVENT : gui_ev = GUI_NO_EVENT; break; case EV_SCROLL_UP : case EV_SCROLL_DOWN : case EV_SCROLL_PAGE_UP : case EV_SCROLL_PAGE_DOWN : case EV_SCROLL_LEFT : case EV_SCROLL_RIGHT : case EV_SCROLL_LEFT_PAGE : case EV_SCROLL_RIGHT_PAGE : if( GUICurrWnd != NULL ) { ProcessScrollEvent( ev ); return( true ); } break; case EV_SCROLL_VERTICAL : if( GUI_VSCROLL_EVENTS_SET( GUICurrWnd ) ) { DoScrollDrag( GUICurrWnd->vgadget, prev, diff ); } else { GUIWholeWndDirty( GUICurrWnd ); } return( true ); break; case EV_SCROLL_HORIZONTAL : if( GUI_HSCROLL_EVENTS_SET( GUICurrWnd ) ) { DoScrollDrag( GUICurrWnd->hgadget, prev, diff ); } else { GUIWholeWndDirty( GUICurrWnd ); } return( true ); break; case EV_MENU_INITPOPUP : ProcessInitPopupEvent(); return( true ); break; #if 0 case EV_BACKGROUND_RESIZE : { gui_window *root; root = GUIGetRootWindow(); if( root != NULL ) { GUIZoomWnd( root, GUI_NONE ); } } return( true ); break; #endif default : if( IS_CTLEVENT( ev ) ) { if( !GUIMDIProcessEvent( ev ) ) { menu_window = GUIGetMenuWindow(); if( menu_window != NULL ) { id = EV2ID( ev ); GUIEVENTWND( menu_window, GUI_CLICKED, &id ); } } return( true ); } break; } if( ( GUICurrWnd != NULL ) && (gui_ev != GUI_NO_EVENT ) ) { GUIEVENTWND( GUICurrWnd, gui_ev, NULL ); } return( true ); }