X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/03c4c72be65175f847770e183d3333862878bc67..aa57eeea83fac24e9d188fa800bdc96c95f5bbeb:/src/mac/carbon/window.cpp diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 4ebd816b71..f5bfbfaab2 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -53,9 +53,11 @@ #include #endif +#if TARGET_API_MAC_OSX #ifndef __HIVIEW__ #include #endif +#endif #if wxUSE_DRAG_AND_DROP #include "wx/dnd.h" @@ -103,9 +105,14 @@ pascal OSStatus wxMacSetupControlBackground( ControlRef iControl , SInt16 iMessa static const EventTypeSpec eventList[] = { #if TARGET_API_MAC_OSX - { kEventClassControl , kEventControlDraw } , + { kEventClassControl , kEventControlDraw } , + { kEventClassControl , kEventControlVisibilityChanged } , + { kEventClassControl , kEventControlEnabledStateChanged } , + { kEventClassControl , kEventControlHiliteChanged } , // { kEventClassControl , kEventControlInvalidateForSizeChange } , // 10.3 only // { kEventClassControl , kEventControlBoundsChanged } , + + {} #else {} #endif @@ -146,6 +153,15 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl result = eventNotHandledErr; } break ; + case kEventControlVisibilityChanged : + thisWindow->MacVisibilityChanged() ; + break ; + case kEventControlEnabledStateChanged : + thisWindow->MacEnabledStateChanged() ; + break ; + case kEventControlHiliteChanged : + thisWindow->MacHiliteChanged() ; + break ; default : break ; } @@ -1345,6 +1361,7 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) wxSize wxWindowMac::DoGetBestSize() const { + /* Rect bestsize = { 0 , 0 , 0 , 0 } ; short baselineoffset ; int bestWidth, bestHeight ; @@ -1376,6 +1393,8 @@ wxSize wxWindowMac::DoGetBestSize() const bestHeight = 13 ; return wxSize(bestWidth, bestHeight); + */ + return wxWindowBase::DoGetBestSize() ; } @@ -1398,7 +1417,7 @@ void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags) // ... and don't do anything (avoiding flicker) if it's already ok if ( x == currentX && y == currentY && - width == currentW && height == currentH ) + width == currentW && height == currentH && ( height != -1 && width != -1 ) ) { // TODO REMOVE MacRepositionScrollBars() ; // we might have a real position shift @@ -1497,8 +1516,44 @@ wxString wxWindowMac::GetTitle() const return m_label ; } +bool wxWindowMac::Show(bool show) +{ + if ( !wxWindowBase::Show(show) ) + return FALSE; + + // TODO use visibilityChanged Carbon Event for OSX + bool former = MacIsReallyShown() ; + + SetControlVisibility( (ControlRef) m_macControl , show , true ) ; + if ( former != MacIsReallyShown() ) + MacPropagateVisibilityChanged() ; + return TRUE; +} + +bool wxWindowMac::Enable(bool enable) +{ + wxASSERT( m_macControl != NULL ) ; + if ( !wxWindowBase::Enable(enable) ) + return FALSE; + + bool former = MacIsReallyEnabled() ; + if ( enable ) + EnableControl( (ControlRef) m_macControl ) ; + else + DisableControl( (ControlRef) m_macControl ) ; + + if ( former != MacIsReallyEnabled() ) + MacPropagateEnabledStateChanged() ; + return TRUE; +} + +// +// status change propagations (will be not necessary for OSX later ) +// + void wxWindowMac::MacPropagateVisibilityChanged() { +#if !TARGET_API_MAC_OSX MacVisibilityChanged() ; wxWindowListNode *node = GetChildren().GetFirst(); @@ -1509,22 +1564,61 @@ void wxWindowMac::MacPropagateVisibilityChanged() child->MacPropagateVisibilityChanged( ) ; node = node->GetNext(); } +#endif } -bool wxWindowMac::Show(bool show) +void wxWindowMac::MacPropagateEnabledStateChanged( ) { - if ( !wxWindowBase::Show(show) ) - return FALSE; +#if !TARGET_API_MAC_OSX + MacEnabledStateChanged() ; - // TODO use visibilityChanged Carbon Event for OSX - bool former = MacIsReallyShown() ; + wxWindowListNode *node = GetChildren().GetFirst(); + while ( node ) + { + wxWindowMac *child = node->GetData(); + if ( child->IsEnabled() ) + child->MacPropagateEnabledStateChanged() ; + node = node->GetNext(); + } +#endif +} + +void wxWindowMac::MacPropagateHiliteChanged( ) +{ +#if !TARGET_API_MAC_OSX + MacHiliteChanged() ; - SetControlVisibility( (ControlRef) m_macControl , show , true ) ; - if ( former != MacIsReallyShown() ) - MacPropagateVisibilityChanged() ; - return TRUE; + wxWindowListNode *node = GetChildren().GetFirst(); + while ( node ) + { + wxWindowMac *child = node->GetData(); + // if ( child->IsEnabled() ) + child->MacPropagateHiliteChanged() ; + node = node->GetNext(); + } +#endif +} + +// +// status change notifications +// + +void wxWindowMac::MacVisibilityChanged() +{ } +void wxWindowMac::MacHiliteChanged() +{ +} + +void wxWindowMac::MacEnabledStateChanged() +{ +} + +// +// status queries on the inherited window's state +// + bool wxWindowMac::MacIsReallyShown() { // only under OSX the visibility of the TLW is taken into account @@ -1546,50 +1640,20 @@ bool wxWindowMac::MacIsReallyShown() #endif } -void wxWindowMac::MacVisibilityChanged() -{ -} - -void wxWindowMac::MacPropagateEnabledStateChanged( ) -{ - MacEnabledStateChanged() ; - - wxWindowListNode *node = GetChildren().GetFirst(); - while ( node ) - { - wxWindowMac *child = node->GetData(); - if ( child->IsEnabled() ) - child->MacPropagateEnabledStateChanged() ; - node = node->GetNext(); - } -} - -bool wxWindowMac::Enable(bool enable) -{ - wxASSERT( m_macControl != NULL ) ; - if ( !wxWindowBase::Enable(enable) ) - return FALSE; - - bool former = MacIsReallyEnabled() ; - if ( enable ) - UMAActivateControl( (ControlRef) m_macControl ) ; - else - UMADeactivateControl( (ControlRef) m_macControl ) ; - - if ( former != MacIsReallyEnabled() ) - MacPropagateEnabledStateChanged() ; - return TRUE; -} - bool wxWindowMac::MacIsReallyEnabled() { return IsControlEnabled( (ControlRef) m_macControl ) ; } -void wxWindowMac::MacEnabledStateChanged() +bool wxWindowMac::MacIsReallyHilited() { + return IsControlActive( (ControlRef) m_macControl ) ; } +// +// +// + int wxWindowMac::GetCharHeight() const { wxClientDC dc ( (wxWindowMac*)this ) ;