case kEventControlHiliteChanged :
thisWindow->MacHiliteChanged() ;
break ;
+#endif
+ // we emulate this event under Carbon CFM
case kEventControlSetFocusPart :
{
Boolean focusEverything = false ;
ControlPartCode controlPart = cEvent.GetParameter<ControlPartCode>(kEventParamControlPart , typeControlPartCode );
+#ifdef __WXMAC_OSX__
if ( cEvent.GetParameter<Boolean>(kEventParamControlFocusEverything , &focusEverything ) == noErr )
{
}
+#endif
if ( controlPart == kControlFocusNoPart )
{
#if wxUSE_CARET
result = noErr ;
}
break ;
-#endif
case kEventControlHit :
{
result = thisWindow->MacControlHit( handler , event ) ;
static pascal void wxMacControlUserPaneDrawProc(ControlRef control, SInt16 part)
{
wxWindow * win = wxFindControlFromMacControl(control) ;
- wxCHECK_RET( win , wxT("Callback from unkown control") ) ;
- win->MacControlUserPaneDrawProc(part) ;
+ if ( win )
+ win->MacControlUserPaneDrawProc(part) ;
}
static pascal ControlPartCode wxMacControlUserPaneHitTestProc(ControlRef control, Point where)
{
wxWindow * win = wxFindControlFromMacControl(control) ;
- wxCHECK_MSG( win , kControlNoPart , wxT("Callback from unkown control") ) ;
- return win->MacControlUserPaneHitTestProc(where.h , where.v) ;
+ if ( win )
+ return win->MacControlUserPaneHitTestProc(where.h , where.v) ;
+ else
+ return kControlNoPart ;
}
static pascal ControlPartCode wxMacControlUserPaneTrackingProc(ControlRef control, Point startPt, ControlActionUPP actionProc)
{
wxWindow * win = wxFindControlFromMacControl(control) ;
- wxCHECK_MSG( win , kControlNoPart , wxT("Callback from unkown control") ) ;
- return win->MacControlUserPaneTrackingProc( startPt.h , startPt.v , (void*) actionProc) ;
+ if ( win )
+ return win->MacControlUserPaneTrackingProc( startPt.h , startPt.v , (void*) actionProc) ;
+ else
+ return kControlNoPart ;
}
static pascal void wxMacControlUserPaneIdleProc(ControlRef control)
{
wxWindow * win = wxFindControlFromMacControl(control) ;
- wxCHECK_RET( win , wxT("Callback from unkown control") ) ;
- win->MacControlUserPaneIdleProc() ;
+ if ( win )
+ win->MacControlUserPaneIdleProc() ;
}
static pascal ControlPartCode wxMacControlUserPaneKeyDownProc(ControlRef control, SInt16 keyCode, SInt16 charCode, SInt16 modifiers)
{
wxWindow * win = wxFindControlFromMacControl(control) ;
- wxCHECK_MSG( win , kControlNoPart , wxT("Callback from unkown control") ) ;
- return win->MacControlUserPaneKeyDownProc(keyCode,charCode,modifiers) ;
+ if ( win )
+ return win->MacControlUserPaneKeyDownProc(keyCode,charCode,modifiers) ;
+ else
+ return kControlNoPart ;
}
static pascal void wxMacControlUserPaneActivateProc(ControlRef control, Boolean activating)
{
wxWindow * win = wxFindControlFromMacControl(control) ;
- wxCHECK_RET( win , wxT("Callback from unkown control") ) ;
- win->MacControlUserPaneActivateProc(activating) ;
+ if ( win )
+ win->MacControlUserPaneActivateProc(activating) ;
}
static pascal ControlPartCode wxMacControlUserPaneFocusProc(ControlRef control, ControlFocusPart action)
{
wxWindow * win = wxFindControlFromMacControl(control) ;
- wxCHECK_MSG( win , kControlNoPart , wxT("Callback from unkown control") ) ;
- return win->MacControlUserPaneFocusProc(action) ;
+ if ( win )
+ return win->MacControlUserPaneFocusProc(action) ;
+ else
+ return kControlNoPart ;
}
static pascal void wxMacControlUserPaneBackgroundProc(ControlRef control, ControlBackgroundPtr info)
{
wxWindow * win = wxFindControlFromMacControl(control) ;
- wxCHECK_RET( win , wxT("Callback from unkown control") ) ;
- win->MacControlUserPaneBackgroundProc(info) ;
+ if ( win )
+ win->MacControlUserPaneBackgroundProc(info) ;
}
void wxWindowMac::MacControlUserPaneDrawProc(wxInt16 part)
m_isBeingDeleted = TRUE;
- if ( m_peer )
- {
- // deleting a window while it is shown invalidates the region occupied by border or
- // focus
- int outerBorder = MacGetLeftBorderSize() ;
- if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() )
- outerBorder += 4 ;
-
- if ( IsShown() && ( outerBorder > 0 ) )
- {
- // as the borders are drawn on the parent we have to properly invalidate all these areas
- RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() , updateTotal = NewRgn() ;
-
- Rect rect ;
-
- m_peer->GetRect( &rect ) ;
- RectRgn( updateInner , &rect ) ;
- InsetRect( &rect , -outerBorder , -outerBorder ) ;
- RectRgn( updateOuter , &rect ) ;
- DiffRgn( updateOuter , updateInner ,updateOuter ) ;
- wxPoint parent(0,0);
- GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ;
- parent -= GetParent()->GetClientAreaOrigin() ;
- OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
- CopyRgn( updateOuter , updateTotal ) ;
-
- GetParent()->m_peer->SetNeedsDisplay( true , updateTotal ) ;
- DisposeRgn(updateOuter) ;
- DisposeRgn(updateInner) ;
- DisposeRgn(updateTotal) ;
- }
- }
+ MacInvalidateBorders() ;
#ifndef __WXUNIVERSAL__
// VS: make sure there's no wxFrame with last focus set to us:
// | kControlWantsIdle
;
- m_peer = new wxMacControl() ;
+ m_peer = new wxMacControl(this) ;
::CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds, features , m_peer->GetControlRefAddr() );
x = (int)pos.x;
y = (int)pos.y;
// todo the default calls may be used as soon as PostCreateControl Is moved here
- w = size.x ; // WidthDefault( size.x );
- h = size.y ; // HeightDefault( size.y ) ;
+ w = wxMax(size.x,0) ; // WidthDefault( size.x );
+ h = wxMax(size.y,0) ; // HeightDefault( size.y ) ;
#if !TARGET_API_MAC_OSX
GetParent()->MacWindowToRootWindow( &x , &y ) ;
#endif
void wxWindowMac::MacWindowToRootWindow( int *x , int *y ) const
{
- #if TARGET_API_MAC_OSX
wxPoint pt ;
if ( x ) pt.x = *x ;
if ( y ) pt.y = *y ;
if ( x ) *x = (int) pt.x ;
if ( y ) *y = (int) pt.y ;
- #else
- if ( !IsTopLevel() )
- {
- Rect bounds ;
- m_peer->GetRect( &bounds ) ;
- if(x) *x += bounds.left - MacGetLeftBorderSize() ;
- if(y) *y += bounds.top - MacGetTopBorderSize() ;
- }
-#endif
}
void wxWindowMac::MacWindowToRootWindow( short *x , short *y ) const
void wxWindowMac::MacRootWindowToWindow( int *x , int *y ) const
{
- #if TARGET_API_MAC_OSX
wxPoint pt ;
if ( x ) pt.x = *x ;
if ( y ) pt.y = *y ;
if ( x ) *x = (int) pt.x ;
if ( y ) *y = (int) pt.y ;
- #else
- if ( !IsTopLevel() )
- {
- Rect bounds ;
- m_peer->GetRect( &bounds ) ;
- if(x) *x -= bounds.left + MacGetLeftBorderSize() ;
- if(y) *y -= bounds.top + MacGetTopBorderSize() ;
- }
-#endif
}
void wxWindowMac::MacRootWindowToWindow( short *x , short *y ) const
#endif // wxUSE_TOOLTIPS
+void wxWindowMac::MacInvalidateBorders()
+{
+ if ( m_peer == NULL )
+ return ;
+
+ bool vis = MacIsReallyShown() ;
+ if ( !vis )
+ return ;
+
+ int outerBorder = MacGetLeftBorderSize() ;
+ if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() )
+ outerBorder += 4 ;
+
+ if ( outerBorder == 0 )
+ return ;
+
+ // now we know that we have something to do at all
+
+ // as the borders are drawn on the parent we have to properly invalidate all these areas
+ RgnHandle updateInner = NewRgn() ,
+ updateOuter = NewRgn() ;
+
+ // this rectangle is in HIViewCoordinates under OSX and in Window Coordinates under Carbon
+ Rect rect ;
+ m_peer->GetRect( &rect ) ;
+ RectRgn( updateInner , &rect ) ;
+ InsetRect( &rect , -outerBorder , -outerBorder ) ;
+ RectRgn( updateOuter , &rect ) ;
+ DiffRgn( updateOuter , updateInner ,updateOuter ) ;
+#ifdef __WXMAC_OSX__
+ GetParent()->m_peer->SetNeedsDisplay( true , updateOuter ) ;
+#else
+ WindowRef tlw = (WindowRef) MacGetTopLevelWindowRef() ;
+ if ( tlw )
+ InvalWindowRgn( tlw , updateOuter ) ;
+#endif
+ DisposeRgn(updateOuter) ;
+ DisposeRgn(updateInner) ;
+/*
+ RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() ;
+ RectRgn( updateInner , &rect ) ;
+ InsetRect( &rect , -4 , -4 ) ;
+ RectRgn( updateOuter , &rect ) ;
+ DiffRgn( updateOuter , updateInner ,updateOuter ) ;
+ wxPoint parent(0,0);
+ GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ;
+ parent -= GetParent()->GetClientAreaOrigin() ;
+ OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
+ GetParent()->m_peer->SetNeedsDisplay( true , updateOuter ) ;
+ DisposeRgn(updateOuter) ;
+ DisposeRgn(updateInner) ;
+*/
+/*
+ if ( m_peer )
+ {
+ // deleting a window while it is shown invalidates the region occupied by border or
+ // focus
+
+ if ( IsShown() && ( outerBorder > 0 ) )
+ {
+ // as the borders are drawn on the parent we have to properly invalidate all these areas
+ RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() , updateTotal = NewRgn() ;
+
+ Rect rect ;
+
+ m_peer->GetRect( &rect ) ;
+ RectRgn( updateInner , &rect ) ;
+ InsetRect( &rect , -outerBorder , -outerBorder ) ;
+ RectRgn( updateOuter , &rect ) ;
+ DiffRgn( updateOuter , updateInner ,updateOuter ) ;
+ wxPoint parent(0,0);
+ GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ;
+ parent -= GetParent()->GetClientAreaOrigin() ;
+ OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
+ CopyRgn( updateOuter , updateTotal ) ;
+
+ GetParent()->m_peer->SetNeedsDisplay( true , updateTotal ) ;
+ DisposeRgn(updateOuter) ;
+ DisposeRgn(updateInner) ;
+ DisposeRgn(updateTotal) ;
+ }
+ }
+*/
+#if 0
+ Rect r = wxMacGetBoundsForControl(this , wxPoint( actualX,actualY), wxSize( actualWidth, actualHeight ) , false ) ;
+
+ int outerBorder = MacGetLeftBorderSize() ;
+ if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() )
+ outerBorder += 4 ;
+
+ if ( vis && ( outerBorder > 0 ) )
+ {
+ // as the borders are drawn on the parent we have to properly invalidate all these areas
+ RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() , updateTotal = NewRgn() ;
+
+ Rect rect ;
+
+ m_peer->GetRect( &rect ) ;
+ RectRgn( updateInner , &rect ) ;
+ InsetRect( &rect , -outerBorder , -outerBorder ) ;
+ RectRgn( updateOuter , &rect ) ;
+ DiffRgn( updateOuter , updateInner ,updateOuter ) ;
+ /*
+ wxPoint parent(0,0);
+#if TARGET_API_MAC_OSX
+ // no offsetting needed when compositing
+#else
+ GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ;
+ parent -= GetParent()->GetClientAreaOrigin() ;
+ OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
+#endif
+ */
+ CopyRgn( updateOuter , updateTotal ) ;
+
+ rect = r ;
+ RectRgn( updateInner , &rect ) ;
+ InsetRect( &rect , -outerBorder , -outerBorder ) ;
+ RectRgn( updateOuter , &rect ) ;
+ DiffRgn( updateOuter , updateInner ,updateOuter ) ;
+/*
+ OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
+*/
+ UnionRgn( updateOuter , updateTotal , updateTotal ) ;
+
+ GetParent()->m_peer->SetNeedsDisplay( true , updateTotal ) ;
+ DisposeRgn(updateOuter) ;
+ DisposeRgn(updateInner) ;
+ DisposeRgn(updateTotal) ;
+ }
+#endif
+}
+
void wxWindowMac::DoMoveWindow(int x, int y, int width, int height)
{
// this is never called for a toplevel window, so we know we have a parent
former_y += pt.y ;
}
- int actualWidth = width;
- int actualHeight = height;
+ int actualWidth = width ;
+ int actualHeight = height ;
int actualX = x;
int actualY = y;
if ((m_maxWidth != -1) && (actualWidth > m_maxWidth))
actualWidth = m_maxWidth;
if ((m_maxHeight != -1) && (actualHeight > m_maxHeight))
- actualHeight = m_maxHeight;
+ actualHeight = m_maxHeight;
bool doMove = false ;
bool doResize = false ;
{
// we don't adjust twice for the origin
Rect r = wxMacGetBoundsForControl(this , wxPoint( actualX,actualY), wxSize( actualWidth, actualHeight ) , false ) ;
- bool vis = m_peer->IsVisible();
-
- int outerBorder = MacGetLeftBorderSize() ;
- if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() )
- outerBorder += 4 ;
+ bool vis = MacIsReallyShown() ;
- if ( vis && ( outerBorder > 0 ) )
- {
- // as the borders are drawn on the parent we have to properly invalidate all these areas
- RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() , updateTotal = NewRgn() ;
-
- Rect rect ;
-
- m_peer->GetRect( &rect ) ;
- RectRgn( updateInner , &rect ) ;
- InsetRect( &rect , -outerBorder , -outerBorder ) ;
- RectRgn( updateOuter , &rect ) ;
- DiffRgn( updateOuter , updateInner ,updateOuter ) ;
- wxPoint parent(0,0);
-#if TARGET_API_MAC_OSX
- // no offsetting needed when compositing
-#else
- GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ;
- parent -= GetParent()->GetClientAreaOrigin() ;
- OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
-#endif
- CopyRgn( updateOuter , updateTotal ) ;
-
- rect = r ;
- RectRgn( updateInner , &rect ) ;
- InsetRect( &rect , -outerBorder , -outerBorder ) ;
- RectRgn( updateOuter , &rect ) ;
- DiffRgn( updateOuter , updateInner ,updateOuter ) ;
-
- OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
- UnionRgn( updateOuter , updateTotal , updateTotal ) ;
-
- GetParent()->m_peer->SetNeedsDisplay( true , updateTotal ) ;
- DisposeRgn(updateOuter) ;
- DisposeRgn(updateInner) ;
- DisposeRgn(updateTotal) ;
- }
+ MacInvalidateBorders() ;
// the HIViewSetFrame call itself should invalidate the areas, but when testing with the UnicodeTextCtrl it does not !
if ( vis )
if ( vis )
m_peer->SetVisibility( true , true ) ;
+ if ( doMove )
+ wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
+
+ MacInvalidateBorders() ;
+
MacRepositionScrollBars() ;
if ( doMove )
{
bool wxWindowMac::Show(bool show)
{
+ bool former = MacIsReallyShown() ;
if ( !wxWindowBase::Show(show) )
return FALSE;
// TODO use visibilityChanged Carbon Event for OSX
if ( m_peer )
{
- bool former = MacIsReallyShown() ;
-
m_peer->SetVisibility( show , true ) ;
- if ( former != MacIsReallyShown() )
- MacPropagateVisibilityChanged() ;
}
+ if ( former != MacIsReallyShown() )
+ MacPropagateVisibilityChanged() ;
return TRUE;
}
bool wxWindowMac::Enable(bool enable)
{
wxASSERT( m_peer->Ok() ) ;
+ bool former = MacIsReallyEnabled() ;
if ( !wxWindowBase::Enable(enable) )
return FALSE;
- bool former = MacIsReallyEnabled() ;
m_peer->Enable( enable ) ;
if ( former != MacIsReallyEnabled() )
InvalWindowRgn( (WindowRef) MacGetTopLevelWindowRef() , updateRgn ) ;
DisposeRgn(updateRgn) ;
*/
- if ( m_peer->IsVisible())
+ if ( MacIsReallyShown() )
{
m_peer->SetVisibility( false , false ) ;
m_peer->SetVisibility( true , true ) ;
InsetRect( &rect, -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
#if wxMAC_USE_CORE_GRAPHICS && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
- if ( HIThemeDrawFrame != 0)
+ if ( UMAGetSystemVersion() >= 0x1030 )
{
Rect srect = rect ;
HIThemeFrameDrawInfo info ;
else
#endif
{
+#ifdef __WXMAC_OSX__
+ // as the non OSX Version is already working in window relative coordinates, it's not needed
wxTopLevelWindowMac* top = MacGetTopLevelWindow();
if (top)
{
rect.top += pt.y ;
rect.bottom += pt.y ;
}
+#endif
if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
{
{
#if !wxMAC_USE_CORE_GRAPHICS
wxMacWindowStateSaver sv( this ) ;
-
- int w , h ;
- int x , y ;
- x = y = 0 ;
- MacWindowToRootWindow( &x , &y ) ;
- GetSize( &w , &h ) ;
- Rect rect = {y , x , h + y , w + x } ;
+ Rect rect ;
+ m_peer->GetRect( &rect ) ;
+ InsetRect( &rect, -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
+#ifdef __WXMAC_OSX__
+ // as the non OSX Version is already working in window relative coordinates, it's not needed
+ wxTopLevelWindowMac* top = MacGetTopLevelWindow();
+ if (top)
+ {
+ wxPoint pt(0,0) ;
+ wxMacControl::Convert( &pt , GetParent()->m_peer , top->m_peer ) ;
+ rect.left += pt.x ;
+ rect.right += pt.x ;
+ rect.top += pt.y ;
+ rect.bottom += pt.y ;
+ }
+#endif
if ( event.GetEventType() == wxEVT_SET_FOCUS )
DrawThemeFocusRect( &rect , true ) ;
// as this erases part of the frame we have to redraw borders
// and because our z-ordering is not always correct (staticboxes)
// we have to invalidate things, we cannot simple redraw
- RgnHandle updateInner = NewRgn() , updateOuter = NewRgn() ;
- RectRgn( updateInner , &rect ) ;
- InsetRect( &rect , -4 , -4 ) ;
- RectRgn( updateOuter , &rect ) ;
- DiffRgn( updateOuter , updateInner ,updateOuter ) ;
- wxPoint parent(0,0);
- GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ;
- parent -= GetParent()->GetClientAreaOrigin() ;
- OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
- GetParent()->m_peer->SetNeedsDisplay( true , updateOuter ) ;
- DisposeRgn(updateOuter) ;
- DisposeRgn(updateInner) ;
+ MacInvalidateBorders() ;
}
#else
GetParent()->Refresh() ;
Rect r ;
RgnHandle visRgn = NewRgn() ;
RgnHandle tempRgn = NewRgn() ;
- if ( !m_isBeingDeleted && m_peer->IsVisible())
+ if ( !m_isBeingDeleted && MacIsReallyShown() /*m_peer->IsVisible() */ )
{
m_peer->GetRect( &r ) ;
r.left -= MacGetLeftBorderSize() ;
if ( !child->GetEventHandler()->ProcessEvent( eventNc ) )
{
#if wxMAC_USE_CORE_GRAPHICS && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
- if ( HIThemeDrawFrame != 0)
+ if ( UMAGetSystemVersion() >= 0x1030 )
{
child->MacPaintBorders(0,0) ;
}