X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/be0b002a3e815be81e604e4a47a7d297c7c01f71..bf60426831535738b1b784629f08e9dd00bf9ecc:/src/mac/window.cpp diff --git a/src/mac/window.cpp b/src/mac/window.cpp index 70ffe076e7..cf5a48692c 100644 --- a/src/mac/window.cpp +++ b/src/mac/window.cpp @@ -197,6 +197,17 @@ bool wxWindowMac::Create(wxWindowMac *parent, wxWindowID id, { wxCHECK_MSG( parent, FALSE, wxT("can't create wxWindowMac without parent") ); +#if wxUSE_STATBOX + // wxGTK doesn't allow to create controls with static box as the parent so + // this will result in a crash when the program is ported to wxGTK - warn + // about it + // + // the correct solution is to create the controls as siblings of the + // static box + wxASSERT_MSG( !wxDynamicCast(parent, wxStaticBox), + _T("wxStaticBox can't be used as a window parent!") ); +#endif // wxUSE_STATBOX + if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) ) return FALSE; @@ -227,24 +238,32 @@ void wxWindowMac::SetFocus() { if (gFocusWindow ) { - #if wxUSE_CARET +#if wxUSE_CARET // Deal with caret if ( gFocusWindow->m_caret ) { gFocusWindow->m_caret->OnKillFocus(); } - #endif // wxUSE_CARET - #ifndef __WXUNIVERSAL__ +#endif // wxUSE_CARET +#ifndef __WXUNIVERSAL__ wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ; if ( control && control->GetMacControl() ) { UMASetKeyboardFocus( (WindowRef) gFocusWindow->MacGetRootWindow() , (ControlHandle) control->GetMacControl() , kControlFocusNoPart ) ; control->MacRedrawControl() ; } - #endif - wxFocusEvent event(wxEVT_KILL_FOCUS, gFocusWindow->m_windowId); - event.SetEventObject(gFocusWindow); - gFocusWindow->GetEventHandler()->ProcessEvent(event) ; +#endif + // Without testing the window id, for some reason + // a kill focus event can still be sent to + // the control just being focussed. + int thisId = this->m_windowId; + int gFocusWindowId = gFocusWindow->m_windowId; + if (gFocusWindowId != thisId) + { + wxFocusEvent event(wxEVT_KILL_FOCUS, gFocusWindow->m_windowId); + event.SetEventObject(gFocusWindow); + gFocusWindow->GetEventHandler()->ProcessEvent(event) ; + } } gFocusWindow = this ; { @@ -786,13 +805,13 @@ bool wxWindowMac::Show(bool show) void wxWindowMac::MacSuperShown( bool show ) { - wxNode *node = GetChildren().First(); + wxWindowListNode *node = GetChildren().GetFirst(); while ( node ) { - wxWindowMac *child = (wxWindowMac *)node->Data(); + wxWindowMac *child = (wxWindowMac *)node->GetData(); if ( child->m_isShown ) child->MacSuperShown( show ) ; - node = node->Next(); + node = node->GetNext(); } } @@ -804,13 +823,13 @@ void wxWindowMac::MacSuperEnabled( bool enabled ) // because unter MacOSX the frames are drawn with an addXXX mode) // the borders area } - wxNode *node = GetChildren().First(); + wxWindowListNode *node = GetChildren().GetFirst(); while ( node ) { - wxWindowMac *child = (wxWindowMac *)node->Data(); + wxWindowMac *child = (wxWindowMac *)node->GetData(); if ( child->m_isShown ) child->MacSuperEnabled( enabled ) ; - node = node->Next(); + node = node->GetNext(); } } @@ -1239,9 +1258,9 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect) DisposeRgn( updateRgn ) ; } - for (wxNode *node = GetChildren().First(); node; node = node->Next()) + for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) { - wxWindowMac *child = (wxWindowMac*)node->Data(); + wxWindowMac *child = (wxWindowMac*)node->GetData(); if (child == m_vScrollBar) continue; if (child == m_hScrollBar) continue; if (child->IsTopLevel()) continue; @@ -1313,13 +1332,13 @@ void wxWindowMac::OnCommand(wxWindowMac& win, wxCommandEvent& event) wxObject* wxWindowMac::GetChild(int number) const { // Return a pointer to the Nth object in the Panel - wxNode *node = GetChildren().First(); + wxNode *node = GetChildren().GetFirst(); int n = number; while (node && n--) - node = node->Next(); + node = node->GetNext(); if ( node ) { - wxObject *obj = (wxObject *)node->Data(); + wxObject *obj = (wxObject *)node->GetData(); return(obj); } else @@ -1435,9 +1454,9 @@ bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** newPoint.y -= m_y; } - for (wxNode *node = GetChildren().First(); node; node = node->Next()) + for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) { - wxWindowMac *child = (wxWindowMac*)node->Data(); + wxWindowMac *child = (wxWindowMac*)node->GetData(); // added the m_isShown test --dmazzoni if ( child->MacGetRootWindow() == window && child->m_isShown ) { @@ -1478,7 +1497,6 @@ bool wxWindowMac::MacGetWindowFromPoint( const wxPoint &screenpoint , wxWindowMa return FALSE ; } -extern int wxBusyCursorCount ; static wxWindow *gs_lastWhich = NULL; bool wxWindowMac::MacSetupCursor( const wxPoint& pt) @@ -1541,9 +1559,9 @@ bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event) int x = event.m_x ; int y = event.m_y ; - for (wxNode *node = GetChildren().First(); node; node = node->Next()) + for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) { - wxWindowMac *child = (wxWindowMac*)node->Data(); + wxWindowMac *child = (wxWindowMac*)node->GetData(); if ( child->MacGetRootWindow() == window && child->IsShown() && child->IsEnabled() ) { if (child->MacDispatchMouseEvent(event)) @@ -1666,8 +1684,8 @@ const wxRegion& wxWindowMac::MacGetVisibleRegion( bool respectChildrenAndSibling SetRectRgn( tempRgn , x + parent->MacGetLeftBorderSize() , y + parent->MacGetTopBorderSize() , - x + size.x - parent->MacGetLeftBorderSize() - parent->MacGetRightBorderSize(), - y + size.y - parent->MacGetTopBorderSize() - parent->MacGetBottomBorderSize()) ; + x + size.x - parent->MacGetRightBorderSize(), + y + size.y - parent->MacGetBottomBorderSize()) ; SectRgn( visRgn , tempRgn , visRgn ) ; if ( parent->IsTopLevel() ) @@ -1679,9 +1697,9 @@ const wxRegion& wxWindowMac::MacGetVisibleRegion( bool respectChildrenAndSibling { if ( GetWindowStyle() & wxCLIP_CHILDREN ) { - for (wxNode *node = GetChildren().First(); node; node = node->Next()) + for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) { - wxWindowMac *child = (wxWindowMac*)node->Data(); + wxWindowMac *child = (wxWindowMac*)node->GetData(); if ( !child->IsTopLevel() && child->IsShown() ) { @@ -1702,9 +1720,9 @@ const wxRegion& wxWindowMac::MacGetVisibleRegion( bool respectChildrenAndSibling if ( (GetWindowStyle() & wxCLIP_SIBLINGS) && GetParent() ) { bool thisWindowThrough = false ; - for (wxNode *node = GetParent()->GetChildren().First(); node; node = node->Next()) + for (wxWindowListNode *node = GetParent()->GetChildren().GetFirst(); node; node = node->GetNext()) { - wxWindowMac *sibling = (wxWindowMac*)node->Data(); + wxWindowMac *sibling = (wxWindowMac*)node->GetData(); if ( sibling == this ) { thisWindowThrough = true ; @@ -1766,7 +1784,8 @@ void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase) if ( erase && !EmptyRgn(ownUpdateRgn) ) { wxWindowDC dc(this); - dc.SetClippingRegion(wxRegion(ownUpdateRgn)); + if (!EmptyRgn(ownUpdateRgn)) + dc.SetClippingRegion(wxRegion(ownUpdateRgn)); wxEraseEvent eevent( GetId(), &dc ); eevent.SetEventObject( this ); GetEventHandler()->ProcessEvent( eevent ); @@ -1788,11 +1807,11 @@ void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase) // now intersect for each of the children their rect with the updateRgn and call MacRedraw recursively RgnHandle childupdate = NewRgn() ; - for (wxNode *node = GetChildren().First(); node; node = node->Next()) + for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) { // 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->Data(); + wxWindowMac *child = (wxWindowMac*)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 ) ; @@ -1949,12 +1968,12 @@ void wxWindowMac::MacSuperChangedPosition() { // only window-absolute structures have to be moved i.e. controls - wxNode *node = GetChildren().First(); + wxWindowListNode *node = GetChildren().GetFirst(); while ( node ) { - wxWindowMac *child = (wxWindowMac *)node->Data(); + wxWindowMac *child = (wxWindowMac *)node->GetData(); child->MacSuperChangedPosition() ; - node = node->Next(); + node = node->GetNext(); } } @@ -1962,12 +1981,12 @@ void wxWindowMac::MacTopLevelWindowChangedPosition() { // only screen-absolute structures have to be moved i.e. glcanvas - wxNode *node = GetChildren().First(); + wxWindowListNode *node = GetChildren().GetFirst(); while ( node ) { - wxWindowMac *child = (wxWindowMac *)node->Data(); + wxWindowMac *child = (wxWindowMac *)node->GetData(); child->MacTopLevelWindowChangedPosition() ; - node = node->Next(); + node = node->GetNext(); } } long wxWindowMac::MacGetLeftBorderSize( ) const