X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8950f7cc7e1dbe7cd1b9513d8ba74610fa696e36..adf2eb2d343159326a68ba1a9b1a76f60f30d937:/src/mac/window.cpp diff --git a/src/mac/window.cpp b/src/mac/window.cpp index 92efcad9f1..d68b00c5bd 100644 --- a/src/mac/window.cpp +++ b/src/mac/window.cpp @@ -104,17 +104,7 @@ void wxWindowMac::Init() // generic InitBase(); - // MSW specific - m_doubleClickAllowed = 0; - m_winCaptured = FALSE; - m_isBeingDeleted = FALSE; - - m_useCtl3D = FALSE; - m_mouseInWindow = FALSE; - - m_xThumbSize = 0; - m_yThumbSize = 0; m_backgroundTransparent = FALSE; // as all windows are created with WS_VISIBLE style... @@ -151,7 +141,7 @@ wxWindowMac::~wxWindowMac() } m_isBeingDeleted = TRUE; - + #ifndef __WXUNIVERSAL__ // VS: make sure there's no wxFrame with last focus set to us: for ( wxWindow *win = GetParent(); win; win = win->GetParent() ) @@ -386,40 +376,7 @@ bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y) menu->UpdateUI(); ClientToScreen( &x , &y ) ; - wxArrayPtrVoid submenus ; - wxMenuItemList::Node *node; - wxMenuItem *item; - int pos ; - for (pos = 0, node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++) - { - item = (wxMenuItem *)node->GetData(); - wxMenu* subMenu = item->GetSubMenu() ; - if (subMenu) - { - submenus.Add(subMenu) ; - } - } - - ::InsertMenu( (MenuHandle) menu->GetHMenu() , -1 ) ; - - for ( size_t i = 0 ; i < submenus.GetCount() ; ++i ) - { - wxMenu* submenu = (wxMenu*) submenus[i] ; - wxMenuItemList::Node *subnode; - wxMenuItem *subitem; - int subpos ; - for ( subpos = 0 , subnode = submenu->GetMenuItems().GetFirst(); subnode; subnode = subnode->GetNext(), subpos++) - { - subitem = (wxMenuItem *)subnode->GetData(); - wxMenu* itsSubMenu = subitem->GetSubMenu() ; - if (itsSubMenu) - { - submenus.Add(itsSubMenu) ; - } - } - ::InsertMenu( MAC_WXHMENU(submenu->GetHMenu()) , -1 ) ; - } - + menu->MacBeforeDisplay( true ) ; long menuResult = ::PopUpMenuSelect((MenuHandle) menu->GetHMenu() ,y,x, 0) ; if ( HiWord(menuResult) != 0 ) { @@ -434,12 +391,7 @@ bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y) } menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ; } - ::DeleteMenu( menu->MacGetMenuId() ) ; - for ( size_t i = 0 ; i < submenus.GetCount() ; ++i ) - { - wxMenu* submenu = (wxMenu*) submenus[i] ; - ::DeleteMenu( submenu->MacGetMenuId() ) ; - } + menu->MacAfterDisplay( true ) ; menu->SetInvokingWindow(NULL); @@ -838,25 +790,9 @@ bool wxWindowMac::Show(bool show) if ( !wxWindowBase::Show(show) ) return FALSE; -/* - WindowRef window = (WindowRef) MacGetRootWindow() ; - wxWindowMac* win = wxFindWinFromMacWindow( window ) ; - if ( win == NULL && win->m_isBeingDeleted ) - return FALSE ; -*/ MacSuperShown( show ) ; Refresh() ; -/* - if ( !show ) - { - if ( win && !win->m_isBeingDeleted ) - Refresh() ; - } - else - { - Refresh() ; - } -*/ + return TRUE; } @@ -865,7 +801,7 @@ void wxWindowMac::MacSuperShown( bool show ) wxWindowListNode *node = GetChildren().GetFirst(); while ( node ) { - wxWindowMac *child = (wxWindowMac *)node->GetData(); + wxWindowMac *child = node->GetData(); if ( child->m_isShown ) child->MacSuperShown( show ) ; node = node->GetNext(); @@ -1316,7 +1252,7 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect) for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) { - wxWindowMac *child = (wxWindowMac*)node->GetData(); + wxWindowMac *child = node->GetData(); if (child == m_vScrollBar) continue; if (child == m_hScrollBar) continue; if (child->IsTopLevel()) continue; @@ -1435,21 +1371,6 @@ void wxWindowMac::SetupColours() void wxWindowMac::OnIdle(wxIdleEvent& event) { -/* - // Check if we need to send a LEAVE event - if (m_mouseInWindow) - { - POINT pt; - ::GetCursorPos(&pt); - if (::WindowFromPoint(pt) != (HWND) GetHWND()) - { - // Generate a LEAVE event - m_mouseInWindow = FALSE; - MSWOnMouseLeave(pt.x, pt.y, 0); - } - } -*/ - // This calls the UI-update mechanism (querying windows for // menu/toolbar/control state information) UpdateWindowUI(); @@ -1512,7 +1433,7 @@ bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) { - wxWindowMac *child = (wxWindowMac*)node->GetData(); + wxWindowMac *child = node->GetData(); // added the m_isShown test --dmazzoni if ( child->MacGetRootWindow() == window && child->m_isShown ) { @@ -1617,7 +1538,7 @@ bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event) for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) { - wxWindowMac *child = (wxWindowMac*)node->GetData(); + wxWindowMac *child = node->GetData(); if ( child->MacGetRootWindow() == window && child->IsShown() && child->IsEnabled() ) { if (child->MacDispatchMouseEvent(event)) @@ -1680,7 +1601,7 @@ wxString wxWindowMac::MacGetToolTipString( wxPoint &pt ) { return m_tooltip->GetTip() ; } - return "" ; + return wxEmptyString ; } void wxWindowMac::Update() @@ -1755,7 +1676,7 @@ const wxRegion& wxWindowMac::MacGetVisibleRegion( bool respectChildrenAndSibling { for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) { - wxWindowMac *child = (wxWindowMac*)node->GetData(); + wxWindowMac *child = node->GetData(); if ( !child->IsTopLevel() && child->IsShown() ) { @@ -1778,7 +1699,7 @@ const wxRegion& wxWindowMac::MacGetVisibleRegion( bool respectChildrenAndSibling bool thisWindowThrough = false ; for (wxWindowListNode *node = GetParent()->GetChildren().GetFirst(); node; node = node->GetNext()) { - wxWindowMac *sibling = (wxWindowMac*)node->GetData(); + wxWindowMac *sibling = node->GetData(); if ( sibling == this ) { thisWindowThrough = true ; @@ -1867,7 +1788,7 @@ void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase) { // calculate the update region for the child windows by intersecting the window rectangle with our own // passed in update region and then offset it to be client-wise window coordinates again - wxWindowMac *child = (wxWindowMac*)node->GetData(); + wxWindowMac *child = node->GetData(); SetRectRgn( childupdate , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ; SectRgn( childupdate , updatergn , childupdate ) ; OffsetRgn( childupdate , -child->m_x , -child->m_y ) ; @@ -1893,13 +1814,13 @@ WXHWND wxWindowMac::MacGetRootWindow() const iter = iter->GetParent() ; } - wxASSERT_MSG( 1 , "No valid mac root window" ) ; + wxASSERT_MSG( 1 , wxT("No valid mac root window") ) ; return NULL ; } void wxWindowMac::MacCreateScrollBars( long style ) { - wxASSERT_MSG( m_vScrollBar == NULL && m_hScrollBar == NULL , "attempt to create window twice" ) ; + wxASSERT_MSG( m_vScrollBar == NULL && m_hScrollBar == NULL , wxT("attempt to create window twice") ) ; bool hasBoth = ( style & wxVSCROLL ) && ( style & wxHSCROLL ) ; int adjust = hasBoth ? MAC_SCROLLBAR_SIZE - 1: 0 ; @@ -2027,7 +1948,7 @@ void wxWindowMac::MacSuperChangedPosition() wxWindowListNode *node = GetChildren().GetFirst(); while ( node ) { - wxWindowMac *child = (wxWindowMac *)node->GetData(); + wxWindowMac *child = node->GetData(); child->MacSuperChangedPosition() ; node = node->GetNext(); } @@ -2040,7 +1961,7 @@ void wxWindowMac::MacTopLevelWindowChangedPosition() wxWindowListNode *node = GetChildren().GetFirst(); while ( node ) { - wxWindowMac *child = (wxWindowMac *)node->GetData(); + wxWindowMac *child = node->GetData(); child->MacTopLevelWindowChangedPosition() ; node = node->GetNext(); } @@ -2122,7 +2043,7 @@ void wxWindowMac::OnMouseEvent( wxMouseEvent &event ) if ( event.GetEventType() == wxEVT_RIGHT_DOWN ) { // copied from wxGTK : CS - // generate a "context menu" event: this is similar to wxEVT_RIGHT_UP + // generate a "context menu" event: this is similar to wxEVT_RIGHT_DOWN // except that: // // (a) it's a command event and so is propagated to the parent @@ -2131,7 +2052,8 @@ void wxWindowMac::OnMouseEvent( wxMouseEvent &event ) wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU, this->GetId(), this->ClientToScreen(event.GetPosition())); - this->GetEventHandler()->ProcessEvent(evtCtx); + if ( ! GetEventHandler()->ProcessEvent(evtCtx) ) + event.Skip() ; } else {