X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/67f28607c8638e2fc5f6fb62931ff4b2fd19c04c..6ac23e25b85468c7885f6ab43ca0a45f6458af2e:/src/mac/carbon/window.cpp?ds=sidebyside diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index bbd59ffe8c..a25e4b30e7 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -343,9 +343,15 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl thisWindow->GetCaret()->OnKillFocus(); } #endif // wxUSE_CARET - wxFocusEvent event( wxEVT_KILL_FOCUS, thisWindow->GetId()); - event.SetEventObject(thisWindow); - thisWindow->GetEventHandler()->ProcessEvent(event) ; + static bool inKillFocusEvent = false ; + if ( !inKillFocusEvent ) + { + inKillFocusEvent = true ; + wxFocusEvent event( wxEVT_KILL_FOCUS, thisWindow->GetId()); + event.SetEventObject(thisWindow); + thisWindow->GetEventHandler()->ProcessEvent(event) ; + inKillFocusEvent = false ; + } } else { @@ -628,35 +634,6 @@ wxMAC_DEFINE_PROC_GETTER( ControlActionUPP , wxMacLiveScrollbarActionProc ) ; // implementation // =========================================================================== -#if KEY_wxList_DEPRECATED -wxList wxWinMacControlList(wxKEY_INTEGER); - -wxWindow *wxFindControlFromMacControl(ControlRef inControl ) -{ - wxNode *node = wxWinMacControlList.Find((long)inControl); - if (!node) - return NULL; - return (wxControl *)node->GetData(); -} - -void wxAssociateControlWithMacControl(ControlRef inControl, wxWindow *control) -{ - // adding NULL ControlRef is (first) surely a result of an error and - // (secondly) breaks native event processing - wxCHECK_RET( inControl != (ControlRef) NULL, wxT("attempt to add a NULL WindowRef to window list") ); - - if ( !wxWinMacControlList.Find((long)inControl) ) - wxWinMacControlList.Append((long)inControl, control); -} - -void wxRemoveMacControlAssociation(wxWindow *control) -{ - // remove all associations pointing to us - while ( wxWinMacControlList.DeleteObject(control) ) - {} -} -#else - WX_DECLARE_HASH_MAP(ControlRef, wxWindow*, wxPointerHash, wxPointerEqual, MacControlMap); static MacControlMap wxWinMacControlList; @@ -699,7 +676,6 @@ void wxRemoveMacControlAssociation(wxWindow *control) } } } -#endif // deprecated wxList // ---------------------------------------------------------------------------- // constructors and such @@ -1831,15 +1807,15 @@ void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags) return; } - if ( x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) + if ( x == wxDefaultCoord && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) x = currentX; - if ( y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) + if ( y == wxDefaultCoord && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) y = currentY; AdjustForParentClientOrigin(x, y, sizeFlags); - wxSize size(-1, -1); - if ( width == -1 ) + wxSize size = wxDefaultSize; + if ( width == wxDefaultCoord ) { if ( sizeFlags & wxSIZE_AUTO_WIDTH ) { @@ -1853,11 +1829,11 @@ void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags) } } - if ( height == -1 ) + if ( height == wxDefaultCoord ) { if ( sizeFlags & wxSIZE_AUTO_HEIGHT ) { - if ( size.x == -1 ) + if ( size.x == wxDefaultCoord ) { size = DoGetBestSize(); } @@ -1894,7 +1870,7 @@ wxPoint wxWindowMac::GetClientAreaOrigin() const void wxWindowMac::DoSetClientSize(int clientwidth, int clientheight) { - if ( clientheight != -1 || clientheight != -1 ) + if ( clientheight != wxDefaultCoord || clientheight != wxDefaultCoord ) { int currentclientwidth , currentclientheight ; int currentwidth , currentheight ; @@ -1902,7 +1878,7 @@ void wxWindowMac::DoSetClientSize(int clientwidth, int clientheight) GetClientSize( ¤tclientwidth , ¤tclientheight ) ; GetSize( ¤twidth , ¤theight ) ; - DoSetSize( -1 , -1 , currentwidth + clientwidth - currentclientwidth , + DoSetSize( wxDefaultCoord , wxDefaultCoord , currentwidth + clientwidth - currentclientwidth , currentheight + clientheight - currentclientheight , wxSIZE_USE_EXISTING ) ; } } @@ -2169,8 +2145,8 @@ void wxWindowMac::WarpPointer (int x_pos, int y_pos) void wxWindowMac::OnEraseBackground(wxEraseEvent& event) { - if ( MacGetTopLevelWindow() == NULL ) - return ; + if ( MacGetTopLevelWindow() == NULL ) + return ; #if TARGET_API_MAC_OSX if ( MacGetTopLevelWindow()->MacUsesCompositing() && (m_macBackgroundBrush.Ok() == false || m_macBackgroundBrush.GetStyle() == wxTRANSPARENT ) ) { @@ -2405,8 +2381,8 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect) if( dx == 0 && dy ==0 ) return ; - int width , height ; - GetClientSize( &width , &height ) ; + int width , height ; + GetClientSize( &width , &height ) ; #if TARGET_API_MAC_OSX if ( 1 /* m_peer->IsCompositing() */ ) { @@ -2467,7 +2443,7 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect) Rect scrollrect; RgnHandle updateRgn = NewRgn() ; - { + { wxClientDC dc(this) ; wxMacPortSetter helper(&dc) ; @@ -3241,4 +3217,17 @@ wxInt32 wxWindowMac::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENT return eventNotHandledErr ; } +bool wxWindowMac::Reparent(wxWindowBase *newParentBase) +{ + wxWindowMac *newParent = (wxWindowMac *)newParentBase; + if ( !wxWindowBase::Reparent(newParent) ) + return false; + + //copied from MacPostControlCreate + ControlRef container = (ControlRef) GetParent()->GetHandle() ; + wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ; + ::EmbedControl( m_peer->GetControlRef() , container ) ; + + return true; +}