#endif
m_peer->SetCallbacks( &callbacks);
+#if 0
+ // shouldn't be necessary anymore under 10.2
+ m_peer->SetData( kControlNoPart, kControlDataBrowserIncludesFrameAndFocusTag, (Boolean) false ) ;
+ m_peer->SetNeedsFocusRect( true ) ;
+#endif
+
MacPostControlCreate(pos,size) ;
for ( int i = 0 ; i < n ; i++ )
// wxPoint point(localMouse.h , localMouse.v) ;
wxWindow *win = NULL ;
ControlPartCode controlPart ;
- ControlRef control = wxMacFindControlUnderMouse( localMouse ,
+ ControlRef control = wxMacFindControlUnderMouse( toplevel , localMouse ,
theWindow , &controlPart ) ;
if ( control )
win = wxFindControlFromMacControl( control ) ;
// we just introduce id s corresponding
// to the line number
+DataBrowserItemDataUPP gDataBrowserItemDataUPP = NULL ;
+DataBrowserItemNotificationUPP gDataBrowserItemNotificationUPP = NULL ;
+DataBrowserDrawItemUPP gDataBrowserDrawItemUPP = NULL ;
+
#if TARGET_API_MAC_OSX
static pascal void DataBrowserItemNotificationProc(ControlRef browser, DataBrowserItemID itemID,
DataBrowserItemNotification message, DataBrowserItemDataRef itemData)
return err;
}
+static pascal void ListBoxDrawProc( ControlRef browser , DataBrowserItemID item , DataBrowserPropertyID property ,
+ DataBrowserItemState itemState , const Rect *itemRect , SInt16 depth , Boolean isColorDevice )
+{
+
+ CFStringRef cfString;
+ long systemVersion;
+
+ cfString = CFStringCreateWithFormat( NULL, NULL, CFSTR("Row %d"), item );
+
+ ThemeDrawingState themeState ;
+ GetThemeDrawingState( &themeState ) ;
+
+ if ( itemState == kDataBrowserItemIsSelected ) // In this sample we handle the "selected" state, all others fall through to our "active" state
+ {
+ Gestalt( gestaltSystemVersion, &systemVersion );
+ if ( (systemVersion >= 0x00001030) && (IsControlActive( browser ) == false) ) // Panther DB starts using kThemeBrushSecondaryHighlightColor for inactive browser hilighting
+ SetThemePen( kThemeBrushSecondaryHighlightColor, 32, true );
+ else
+ SetThemePen( kThemeBrushPrimaryHighlightColor, 32, true );
+
+ PaintRect( itemRect ); // First paint the hilite rect, then the text on top
+ SetThemeDrawingState( themeState , false ) ;
+ }
+ DrawThemeTextBox( cfString, kThemeApplicationFont, kThemeStateActive, true, itemRect, teFlushDefault, NULL );
+ if ( cfString != NULL )
+ CFRelease( cfString );
+ SetThemeDrawingState( themeState , true ) ;
+}
// Listbox item
wxListBox::wxListBox()
options += kDataBrowserSelectOnlyOne ;
}
verify_noerr(m_peer->SetSelectionFlags( options ) );
+
+ if ( gDataBrowserItemDataUPP == NULL ) gDataBrowserItemDataUPP = NewDataBrowserItemDataUPP(ListBoxGetSetItemData) ;
+ if ( gDataBrowserItemNotificationUPP == NULL )
+ {
+ gDataBrowserItemNotificationUPP =
+#if TARGET_API_MAC_OSX
+ (DataBrowserItemNotificationUPP) NewDataBrowserItemNotificationWithItemUPP(DataBrowserItemNotificationProc) ;
+#else
+ NewDataBrowserItemNotificationUPP(DataBrowserItemNotificationProc) ;
+#endif
+ }
+ if ( gDataBrowserDrawItemUPP == NULL ) gDataBrowserDrawItemUPP = NewDataBrowserDrawItemUPP(ListBoxDrawProc) ;
+
+ DataBrowserCallbacks callbacks ;
+ InitializeDataBrowserCallbacks( &callbacks , kDataBrowserLatestCallbacks ) ;
+
+ callbacks.u.v1.itemDataCallback = gDataBrowserItemDataUPP;
+ callbacks.u.v1.itemNotificationCallback = gDataBrowserItemNotificationUPP;
+ m_peer->SetCallbacks( &callbacks);
+ DataBrowserCustomCallbacks customCallbacks ;
+ InitializeDataBrowserCustomCallbacks( &customCallbacks , kDataBrowserLatestCustomCallbacks ) ;
+
+ customCallbacks.u.v1.drawItemCallback = gDataBrowserDrawItemUPP ;
+
+ SetDataBrowserCustomCallbacks( m_peer->GetControlRef() , &customCallbacks ) ;
+
DataBrowserListViewColumnDesc columnDesc ;
columnDesc.headerBtnDesc.titleOffset = 0;
columnDesc.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;
kControlUseFontMask | kControlUseJustMask;
columnDesc.headerBtnDesc.btnContentInfo.contentType = kControlNoContent;
- columnDesc.propertyDesc.propertyType = kDataBrowserTextType;
columnDesc.headerBtnDesc.btnFontStyle.just = teFlushDefault;
columnDesc.headerBtnDesc.minimumWidth = 0;
columnDesc.headerBtnDesc.maximumWidth = 10000;
columnDesc.headerBtnDesc.titleString = NULL ; // CFSTR( "" );
columnDesc.propertyDesc.propertyID = kTextColumnId;
- columnDesc.propertyDesc.propertyType = kDataBrowserTextType;
+ columnDesc.propertyDesc.propertyType = kDataBrowserTextType ; // kDataBrowserCustomType;
columnDesc.propertyDesc.propertyFlags =
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
kDataBrowserListViewTypeSelectColumn |
#endif
kDataBrowserTableViewSelectionColumn ;
-
verify_noerr(m_peer->AddListViewColumn( &columnDesc, kDataBrowserListViewAppendColumn) ) ;
verify_noerr(m_peer->AutoSizeListViewColumns() ) ;
verify_noerr(m_peer->SetHasScrollBars(false , true ) ) ;
verify_noerr(m_peer->SetTableViewHiliteStyle(kDataBrowserTableViewFillHilite ) ) ;
verify_noerr(m_peer->SetListViewHeaderBtnHeight( 0 ) ) ;
- DataBrowserCallbacks callbacks ;
-
- callbacks.version = kDataBrowserLatestCallbacks;
-
- InitDataBrowserCallbacks(&callbacks);
- callbacks.u.v1.itemDataCallback =
- NewDataBrowserItemDataUPP(ListBoxGetSetItemData);
-
- callbacks.u.v1.itemNotificationCallback =
-#if TARGET_API_MAC_OSX
- (DataBrowserItemNotificationUPP) NewDataBrowserItemNotificationWithItemUPP(DataBrowserItemNotificationProc) ;
-#else
- NewDataBrowserItemNotificationUPP(DataBrowserItemNotificationProc) ;
+#if 0
+ // shouldn't be necessary anymore under 10.2
+ m_peer->SetData( kControlNoPart, kControlDataBrowserIncludesFrameAndFocusTag, (Boolean) false ) ;
+ m_peer->SetNeedsFocusRect( true ) ;
#endif
- m_peer->SetCallbacks( &callbacks);
-#if TARGET_API_MAC_OSX
- // there is a redraw bug in 10.2.X
- if ( UMAGetSystemVersion() < 0x1030 )
- m_peer->SetData( kControlNoPart, kControlDataBrowserIncludesFrameAndFocusTag, (Boolean) false ) ;
-#endif
MacPostControlCreate(pos,size) ;
for ( int i = 0 ; i < n ; i++ )
class wxMacMLTEControl : public wxMacTextControl
{
public :
- wxMacMLTEControl( wxTextCtrl *peer ) : wxMacTextControl( peer ) {}
+ wxMacMLTEControl( wxTextCtrl *peer ) ;
virtual wxString GetStringValue() const ;
virtual void SetStringValue( const wxString &str) ;
const wxSize& size, long style ) ;
virtual OSStatus SetFocus( ControlFocusPart focusPart ) ;
virtual bool HasFocus() const ;
- virtual bool NeedsFocusRect() const;
protected :
HIViewRef m_scrollView ;
HIViewRef m_textView ;
~wxMacMLTEClassicControl() ;
virtual void VisibilityChanged(bool shown) ;
virtual void SuperChangedPosition() ;
- virtual bool NeedsFocusRect() const;
virtual void MacControlUserPaneDrawProc(wxInt16 part) ;
virtual wxInt16 MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) ;
TXNControlData m_data[1] ;
} ;
+wxMacMLTEControl::wxMacMLTEControl( wxTextCtrl *peer ) : wxMacTextControl( peer )
+{
+ SetNeedsFocusRect( true ) ;
+}
+
wxString wxMacMLTEControl::GetStringValue() const
{
wxString result ;
void wxMacMLTEClassicControl::MacSetObjectVisibility(Boolean vis)
{
-
+ ControlRef controlFocus = 0 ;
+ GetKeyboardFocus( m_txnWindow , &controlFocus ) ;
+
+ if ( controlFocus == m_controlRef && vis == false )
+ {
+ SetKeyboardFocus( m_txnWindow , m_controlRef , kControlFocusNoPart ) ;
+ }
// we right now are always clipping as partial visibility (overlapped) visibility
// is also a problem, if we run into further problems we might set the FrameBounds to an empty
// rect here
wxMacWindowClipper cl(textctrl) ;
#ifdef __WXMAC_OSX__
+ bool isCompositing = textctrl->MacGetTopLevelWindow()->MacUsesCompositing() ;
if ( m_sbHorizontal || m_sbVertical )
{
int w = bounds.right - bounds.left ;
sbBounds.top = h - 14 ;
sbBounds.right = w + 1 ;
sbBounds.bottom = h + 1 ;
+
+ if ( !isCompositing )
+ OffsetRect( &sbBounds , m_txnControlBounds.left , m_txnControlBounds.top ) ;
+
SetControlBounds( m_sbHorizontal , &sbBounds ) ;
SetControlViewSize( m_sbHorizontal , w ) ;
}
sbBounds.right = w + 1 ;
sbBounds.bottom = m_sbHorizontal ? h - 14 : h + 1 ;
+ if ( !isCompositing )
+ OffsetRect( &sbBounds , m_txnControlBounds.left , m_txnControlBounds.top ) ;
+
SetControlBounds( m_sbVertical , &sbBounds ) ;
SetControlViewSize( m_sbVertical , h ) ;
}
wxMacControl::SuperChangedPosition() ;
}
-bool wxMacMLTEClassicControl::NeedsFocusRect() const
-{
- return true;
-}
-
#ifdef __WXMAC_OSX__
ControlUserPaneDrawUPP gTPDrawProc = NULL;
return control == m_textView ;
}
-bool wxMacMLTEHIViewControl::NeedsFocusRect() const
-{
- return m_windowStyle & wxNO_BORDER ? false : true;
-}
-
#endif // MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
m_x = position.x;
m_y = position.y;
- if ( IsButton() )
+ int x , y ;
+ x = y = 0 ;
+ int mac_x = position.x ;
+ int mac_y = position.y ;
+
+ if ( ! GetToolBar()->MacGetTopLevelWindow()->MacUsesCompositing() )
{
- int x , y ;
- x = y = 0 ;
- int mac_x = position.x ;
- int mac_y = position.y ;
-#ifdef __WXMAC_OSX__
- // already correctly set up
-#else
WindowRef rootwindow = (WindowRef) GetToolBar()->MacGetTopLevelWindowRef() ;
GetToolBar()->MacWindowToRootWindow( &x , &y ) ;
mac_x += x;
mac_y += y;
-#endif
+ }
+
+ if ( IsButton() )
+ {
Rect contrlRect ;
GetControlBounds( m_controlHandle , &contrlRect ) ;
int former_mac_x = contrlRect.left ;
{
// separator
#ifdef __WXMAC_OSX__
- int x , y ;
- x = y = 0 ;
- int mac_x = position.x ;
- int mac_y = position.y ;
-
Rect contrlRect ;
GetControlBounds( m_controlHandle , &contrlRect ) ;
int former_mac_x = contrlRect.left ;
}
}
-ControlRef wxMacFindSubControl( Point location , ControlRef superControl , ControlPartCode *outPart )
+ControlRef wxMacFindSubControl( wxTopLevelWindowMac* toplevelWindow, Point location , ControlRef superControl , ControlPartCode *outPart )
{
if ( superControl )
{
UMAGetControlBoundsInWindowCoords( sibling , &r ) ;
if ( MacPtInRect( location , &r ) )
{
- ControlHandle child = wxMacFindSubControl( location , sibling , outPart ) ;
+ ControlHandle child = wxMacFindSubControl( toplevelWindow , location , sibling , outPart ) ;
if ( child )
return child ;
else
{
Point testLocation = location ;
-#if TARGET_API_MAC_OSX
- testLocation.h -= r.left ;
- testLocation.v -= r.top ;
-#endif
+
+ if ( toplevelWindow && toplevelWindow->MacUsesCompositing() )
+ {
+ testLocation.h -= r.left ;
+ testLocation.v -= r.top ;
+ }
+
*outPart = TestControl( sibling , testLocation ) ;
return sibling ;
}
return NULL ;
}
-ControlRef wxMacFindControlUnderMouse( Point location , WindowRef window , ControlPartCode *outPart )
+ControlRef wxMacFindControlUnderMouse( wxTopLevelWindowMac* toplevelWindow , Point location , WindowRef window , ControlPartCode *outPart )
{
#if TARGET_API_MAC_OSX
- if ( UMAGetSystemVersion() >= 0x1030 )
+ if ( UMAGetSystemVersion() >= 0x1030 && ( toplevelWindow == 0 || toplevelWindow->MacUsesCompositing() ) )
return FindControlUnderMouse( location , window , outPart ) ;
#endif
ControlRef rootControl = NULL ;
verify_noerr( GetRootControl( window , &rootControl ) ) ;
- return wxMacFindSubControl( location , rootControl , outPart ) ;
+ return wxMacFindSubControl( toplevelWindow , location , rootControl , outPart ) ;
}
pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
{
+ wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ;
OSStatus result = eventNotHandledErr ;
else if ( (IsWindowActive(window) && windowPart == inContent) )
{
ControlPartCode part ;
- control = wxMacFindControlUnderMouse( windowMouseLocation , window , &part ) ;
+ control = wxMacFindControlUnderMouse( toplevelWindow , windowMouseLocation , window , &part ) ;
// if there is no control below the mouse position, send the event to the toplevel window itself
if ( control == 0 )
currentMouseWindow = (wxWindow*) data ;
#ifdef __WXMAC_OSX__
&&
(FindControlUnderMouse(windowMouseLocation , window , &dummyPart) !=
- wxMacFindControlUnderMouse( windowMouseLocation , window , &dummyPart ) )
+ wxMacFindControlUnderMouse( toplevelWindow , windowMouseLocation , window , &dummyPart ) )
#endif
)
{
{
EventModifiers modifiers = cEvent.GetParameter<EventModifiers>(kEventParamKeyModifiers, typeUInt32) ;
Point clickLocation = windowMouseLocation ;
- #if TARGET_API_MAC_OSX
- currentMouseWindow->MacRootWindowToWindow( &clickLocation.h , &clickLocation.v ) ;
- #endif
+
+ if ( toplevelWindow->MacUsesCompositing() )
+ currentMouseWindow->MacRootWindowToWindow( &clickLocation.h , &clickLocation.v ) ;
+
HandleControlClick( (ControlRef) currentMouseWindow->GetHandle() , clickLocation ,
modifiers , (ControlActionUPP ) -1 ) ;
// don't mess with controls we don't know about
// for some reason returning eventNotHandledErr does not lead to the correct behaviour
// so we try sending them the correct control directly
- wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ;
if ( cEvent.GetKind() == kEventMouseDown && toplevelWindow && control )
{
EventModifiers modifiers = cEvent.GetParameter<EventModifiers>(kEventParamKeyModifiers, typeUInt32) ;
Point clickLocation = windowMouseLocation ;
-#if TARGET_API_MAC_OSX
- HIPoint hiPoint ;
- hiPoint.x = clickLocation.h ;
- hiPoint.y = clickLocation.v ;
- HIViewConvertPoint( &hiPoint , (ControlRef) toplevelWindow->GetHandle() , control ) ;
- clickLocation.h = (int)hiPoint.x ;
- clickLocation.v = (int)hiPoint.y ;
+ if ( toplevelWindow->MacUsesCompositing() )
+ {
+#ifdef __WXMAC_OSX__
+ HIPoint hiPoint ;
+ hiPoint.x = clickLocation.h ;
+ hiPoint.y = clickLocation.v ;
+ HIViewConvertPoint( &hiPoint , (ControlRef) toplevelWindow->GetHandle() , control ) ;
+ clickLocation.h = (int)hiPoint.x ;
+ clickLocation.v = (int)hiPoint.y ;
#endif
+ }
HandleControlClick( control , clickLocation ,
modifiers , (ControlActionUPP ) -1 ) ;
result = noErr ;
cEvent.SetParameter<Rect>( kEventParamCurrentBounds , &adjustedRect ) ;
}
- result = noErr ;
+ result = noErr ;
break ;
}
default :
m_maximizeOnShow = FALSE;
m_macWindow = NULL ;
#if TARGET_API_MAC_OSX
- m_macUsesCompositing = TRUE;
-#else
- m_macUsesCompositing = FALSE;
+ if ( UMAGetSystemVersion() >= 0x1030 )
+ {
+ m_macUsesCompositing = TRUE;
+ }
+ else
#endif
+ {
+ m_macUsesCompositing = FALSE;
+ }
m_macEventHandler = NULL ;
m_macFullScreenData = NULL ;
}
else if ( HasFlag( wxFRAME_DRAWER ) )
{
wclass = kDrawerWindowClass;
- // Should this be left for compositing check below?
- // CreateNewWindow will fail without it, should wxDrawerWindow turn
- // on compositing before calling MacCreateRealWindow?
- attr |= kWindowCompositingAttribute;// | kWindowStandardHandlerAttribute;
+ // we must force compositing on a drawer
+ m_macUsesCompositing = TRUE ;
}
#endif //10.2 and up
else
}
#if TARGET_API_MAC_OSX
- attr |= kWindowCompositingAttribute;
+ if ( m_macUsesCompositing )
+ attr |= kWindowCompositingAttribute;
#endif
if ( HasFlag(wxFRAME_SHAPED) )
UMASetWTitle( (WindowRef) m_macWindow , title , m_font.GetEncoding() ) ;
m_peer = new wxMacControl(this) ;
#if TARGET_API_MAC_OSX
- // There is a bug in 10.2.X for ::GetRootControl returning the window view instead of
- // the content view, so we have to retrieve it explicitely
- HIViewFindByID( HIViewGetRoot( (WindowRef) m_macWindow ) , kHIViewWindowContentID ,
- m_peer->GetControlRefAddr() ) ;
- if ( !m_peer->Ok() )
+
+ if ( m_macUsesCompositing )
{
- // compatibility mode fallback
- GetRootControl( (WindowRef) m_macWindow , m_peer->GetControlRefAddr() ) ;
+ // There is a bug in 10.2.X for ::GetRootControl returning the window view instead of
+ // the content view, so we have to retrieve it explicitely
+ HIViewFindByID( HIViewGetRoot( (WindowRef) m_macWindow ) , kHIViewWindowContentID ,
+ m_peer->GetControlRefAddr() ) ;
+ if ( !m_peer->Ok() )
+ {
+ // compatibility mode fallback
+ GetRootControl( (WindowRef) m_macWindow , m_peer->GetControlRefAddr() ) ;
+ }
}
-#else
- ::CreateRootControl( (WindowRef)m_macWindow , m_peer->GetControlRefAddr() ) ;
#endif
+ {
+ ::CreateRootControl( (WindowRef)m_macWindow , m_peer->GetControlRefAddr() ) ;
+ }
// the root control level handleer
MacInstallEventHandler( (WXWidget) m_peer->GetControlRef() ) ;
void wxTopLevelWindowMac::MacSetMetalAppearance( bool set )
{
#if TARGET_API_MAC_OSX
- UInt32 attr = 0 ;
- GetWindowAttributes((WindowRef) m_macWindow , &attr ) ;
- wxASSERT_MSG( attr & kWindowCompositingAttribute ,
+ wxASSERT_MSG( m_macUsesCompositing ,
wxT("Cannot set metal appearance on a non-compositing window") ) ;
MacChangeWindowAttributes( set ? kWindowMetalAttribute : kWindowNoAttributes ,
Rect* UMAGetControlBoundsInWindowCoords(ControlRef theControl, Rect *bounds)
{
-// wxWindow* win = wxFindControlFromMacControl( theControl ) ;
-
GetControlBounds( theControl , bounds ) ;
#if TARGET_API_MAC_OSX
WindowRef tlwref = GetControlOwner( theControl ) ;
- wxWindow* tlwwx = (wxWindow*) wxFindWinFromMacWindow( tlwref ) ;
- ControlRef rootControl = tlwwx->GetPeer()->GetControlRef() ;
- HIPoint hiPoint = CGPointMake( 0 , 0 ) ;
-
- HIViewConvertPoint( &hiPoint , HIViewGetSuperview(theControl) , rootControl ) ;
- OffsetRect( bounds , (short) (hiPoint.x) , (short) (hiPoint.y) ) ;
+ wxTopLevelWindowMac* tlwwx = wxFindWinFromMacWindow( tlwref ) ;
+ if ( tlwwx->MacUsesCompositing() )
+ {
+ ControlRef rootControl = tlwwx->GetPeer()->GetControlRef() ;
+ HIPoint hiPoint = CGPointMake( 0 , 0 ) ;
+ HIViewConvertPoint( &hiPoint , HIViewGetSuperview(theControl) , rootControl ) ;
+ OffsetRect( bounds , (short) hiPoint.x , (short) hiPoint.y ) ;
+ }
#endif
return bounds ;
}
RgnHandle updateRgn = NULL ;
RgnHandle allocatedRgn = NULL ;
wxRegion visRegion = thisWindow->MacGetVisibleRegion() ;
- if ( cEvent.GetParameter<RgnHandle>(kEventParamRgnHandle, &updateRgn) != noErr )
+ if ( thisWindow->MacGetTopLevelWindow()->MacUsesCompositing() == false || cEvent.GetParameter<RgnHandle>(kEventParamRgnHandle, &updateRgn) != noErr )
{
updateRgn = (RgnHandle) visRegion.GetWXHRGN() ;
}
int& x, int& y,
int& w, int& h , bool adjustOrigin ) const
{
+ bool isCompositing = MacGetTopLevelWindow()->MacUsesCompositing() ;
+
// the desired size, minus the border pixels gives the correct size of the control
x = (int)pos.x;
// todo the default calls may be used as soon as PostCreateControl Is moved here
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
+
+ if ( !isCompositing )
+ GetParent()->MacWindowToRootWindow( &x , &y ) ;
x += MacGetLeftBorderSize() ;
y += MacGetTopBorderSize() ;
if ( adjustOrigin )
AdjustForParentClientOrigin( x , y ) ;
-#if TARGET_API_MAC_OSX
+
// this is in window relative coordinate, as this parent may have a border, its physical position is offset by this border
- if ( ! GetParent()->IsTopLevel() )
+ if ( !GetParent()->IsTopLevel() )
{
x -= GetParent()->MacGetLeftBorderSize() ;
y -= GetParent()->MacGetTopBorderSize() ;
}
-#endif
+
return true ;
}
// get the position of the bounds of this window in client coordinates of its parent
void wxWindowMac::DoGetPosition(int *x, int *y) const
{
+ bool isCompositing = MacGetTopLevelWindow()->MacUsesCompositing() ;
+
int x1 , y1 , w1 ,h1 ;
MacGetPositionAndSizeFromControl( x1 , y1, w1 ,h1 ) ;
x1 -= MacGetLeftBorderSize() ;
y1 -= MacGetTopBorderSize() ;
// to non-client
- #if !TARGET_API_MAC_OSX
- if ( !GetParent()->IsTopLevel() )
+
+ if ( !isCompositing && !GetParent()->IsTopLevel() )
{
Rect bounds ;
GetControlBounds( (ControlRef) GetParent()->GetHandle() , &bounds ) ;
x1 -= bounds.left ;
y1 -= bounds.top ;
}
-#endif
+
if ( !IsTopLevel() )
{
wxWindow *parent = GetParent();
void wxWindowMac::MacGetContentAreaInset( int &left , int &top , int &right , int &bottom )
{
+ bool isCompositing = MacGetTopLevelWindow()->MacUsesCompositing() ;
+
RgnHandle rgn = NewRgn() ;
Rect content ;
if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr )
DisposeRgn( rgn ) ;
Rect structure ;
m_peer->GetRect( &structure ) ;
-#if !TARGET_API_MAC_OSX
- OffsetRect( &content , -structure.left , -structure.top ) ;
-#endif
+
+ if ( !isCompositing )
+ OffsetRect( &content , -structure.left , -structure.top ) ;
+
left = content.left - structure.left ;
top = content.top - structure.top ;
right = structure.right - content.right ;
wxSize wxWindowMac::DoGetSizeFromClientSize( const wxSize & size ) const
{
+ bool isCompositing = MacGetTopLevelWindow()->MacUsesCompositing() ;
wxSize sizeTotal = size;
RgnHandle rgn = NewRgn() ;
DisposeRgn( rgn ) ;
Rect structure ;
m_peer->GetRect( &structure ) ;
-#if !TARGET_API_MAC_OSX
- OffsetRect( &content , -structure.left , -structure.top ) ;
-#endif
+
+ if ( !isCompositing )
+ OffsetRect( &content , -structure.left , -structure.top ) ;
sizeTotal.x += (structure.right - structure.left) - (content.right - content.left) ;
sizeTotal.y += (structure.bottom - structure.top) - (content.bottom - content.top ) ;
// Get size *available for subwindows* i.e. excluding menu bar etc.
void wxWindowMac::DoGetClientSize(int *x, int *y) const
{
+ bool isCompositing = MacGetTopLevelWindow()->MacUsesCompositing() ;
int ww, hh;
RgnHandle rgn = NewRgn() ;
m_peer->GetRect( &content ) ;
}
DisposeRgn( rgn ) ;
-#if !TARGET_API_MAC_OSX
- Rect structure ;
- m_peer->GetRect( &structure ) ;
- OffsetRect( &content , -structure.left , -structure.top ) ;
-#endif
+
+ if ( !isCompositing )
+ {
+ Rect structure ;
+ m_peer->GetRect( &structure ) ;
+ OffsetRect( &content , -structure.left , -structure.top ) ;
+ }
ww = content.right - content.left ;
hh = content.bottom - content.top ;
/*
wxWindowMac *mouseWin = 0 ;
{
- WindowRef window = (WindowRef) MacGetTopLevelWindowRef() ;
+ wxTopLevelWindowMac *tlw = MacGetTopLevelWindow() ;
+ WindowRef window = (WindowRef) ( tlw ? tlw->MacGetWindowRef() : 0 ) ;
CGrafPtr savePort ;
Boolean swapped = QDSwapPort( GetWindowPort( window ) , &savePort ) ;
GetMouse( &pt ) ;
ControlPartCode part ;
ControlRef control ;
- control = wxMacFindControlUnderMouse( pt , window , &part ) ;
+ control = wxMacFindControlUnderMouse( tlw , pt , window , &part ) ;
if ( control )
mouseWin = wxFindControlFromMacControl( control ) ;
bool vis = MacIsReallyShown() ;
MacInvalidateBorders() ;
-
- // the HIViewSetFrame call itself should invalidate the areas, but when testing with the UnicodeTextCtrl it does not !
- if ( vis )
- m_peer->SetVisibility( false , true ) ;
-
+
m_peer->SetRect( &r ) ;
- if ( vis )
- m_peer->SetVisibility( true , true ) ;
if ( doMove )
wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
wxPoint wxWindowMac::GetClientAreaOrigin() const
{
+ bool isCompositing = MacGetTopLevelWindow()->MacUsesCompositing() ;
RgnHandle rgn = NewRgn() ;
Rect content ;
m_peer->GetRegion( kControlContentMetaPart , rgn ) ;
GetRegionBounds( rgn , &content ) ;
DisposeRgn( rgn ) ;
-#if !TARGET_API_MAC_OSX
- // if the content rgn is empty / not supported
- // don't attempt to correct the coordinates to wxWindow relative ones
- if (!::EmptyRect( &content ) )
+
+ if ( !isCompositing )
{
- Rect structure ;
- m_peer->GetRect( &structure ) ;
- OffsetRect( &content , -structure.left , -structure.top ) ;
+ // if the content rgn is empty / not supported
+ // don't attempt to correct the coordinates to wxWindow relative ones
+ if (!::EmptyRect( &content ) )
+ {
+ Rect structure ;
+ m_peer->GetRect( &structure ) ;
+ OffsetRect( &content , -structure.left , -structure.top ) ;
+ }
}
-#endif
return wxPoint( content.left + MacGetLeftBorderSize( ) , content.top + MacGetTopBorderSize( ) );
}
if ( m_peer == NULL )
return ;
-#if TARGET_API_MAC_OSX
- if ( rect == NULL )
- m_peer->SetNeedsDisplay( true ) ;
- else
+
+ bool isCompositing = MacGetTopLevelWindow()->MacUsesCompositing() ;
+// if ( isCompositing )
{
- RgnHandle update = NewRgn() ;
- SetRectRgn( update , rect->x , rect->y , rect->x + rect->width , rect->y + rect->height ) ;
- SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , update , update ) ;
- wxPoint origin = GetClientAreaOrigin() ;
- OffsetRgn( update, origin.x , origin.y ) ;
- // right now this is wx' window coordinates, as our native peer does not have borders, this is
- // inset
- OffsetRgn( update , -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
- m_peer->SetNeedsDisplay( true , update) ;
- DisposeRgn( update ) ;
- }
-#else
-/*
- RgnHandle updateRgn = NewRgn() ;
- if ( rect == NULL )
- {
- CopyRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , updateRgn ) ;
- }
+ if ( rect == NULL && isCompositing )
+ m_peer->SetNeedsDisplay( true ) ;
else
{
- SetRectRgn( updateRgn , rect->x , rect->y , rect->x + rect->width , rect->y + rect->height ) ;
- SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , updateRgn , updateRgn ) ;
+
+ Rect controlBounds ;
+ m_peer->GetRect( &controlBounds ) ;
+ InvalWindowRect( (WindowRef) MacGetTopLevelWindowRef() , &controlBounds ) ;
+ /*
+ RgnHandle update = NewRgn() ;
+ if ( rect == NULL )
+ {
+ CopyRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , update ) ;
+ }
+ else
+ {
+ SetRectRgn( update , rect->x , rect->y , rect->x + rect->width , rect->y + rect->height ) ;
+ SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , update , update ) ;
+ }
+
+ wxPoint origin = GetClientAreaOrigin() ;
+ OffsetRgn( update, origin.x , origin.y ) ;
+ // right now this is wx' window coordinates, as our native peer does not have borders, this is
+ // inset
+ if ( isCompositing )
+ {
+ OffsetRgn( update , -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
+ m_peer->SetNeedsDisplay( true , update) ;
+ }
+ else
+ {
+ int x = 0 ;
+ int y = 0 ;
+ MacWindowToRootWindow( &x , &y ) ;
+ OffsetRgn( update , x , y ) ;
+ InvalWindowRgn( (WindowRef) MacGetTopLevelWindowRef() , update ) ;
+ }
+ DisposeRgn( update ) ;
+ */
}
- InvalWindowRgn( (WindowRef) MacGetTopLevelWindowRef() , updateRgn ) ;
- DisposeRgn(updateRgn) ;
-*/
- if ( MacIsReallyShown() )
- {
- m_peer->SetVisibility( false , false ) ;
- m_peer->SetVisibility( true , true ) ;
}
- /*
- if ( MacGetTopLevelWindow() == NULL )
- return ;
- if ( !m_peer->IsVisible())
- return ;
-
- wxPoint client = GetClientAreaOrigin();
- int x1 = -client.x;
- int y1 = -client.y;
- int x2 = m_width - client.x;
- int y2 = m_height - client.y;
-
- if (IsKindOf( CLASSINFO(wxButton)))
+ if ( 0 )
{
- // buttons have an "aura"
- y1 -= 5;
- x1 -= 5;
- y2 += 5;
- x2 += 5;
- }
-
- Rect clientrect = { y1, x1, y2, x2 };
-
- if ( rect )
- {
- Rect r = { rect->y , rect->x , rect->y + rect->height , rect->x + rect->width } ;
- SectRect( &clientrect , &r , &clientrect ) ;
- }
-
- if ( !EmptyRect( &clientrect ) )
- {
- int top = 0 , left = 0 ;
-
- MacClientToRootWindow( &left , &top ) ;
- OffsetRect( &clientrect , left , top ) ;
-
- MacGetTopLevelWindow()->MacInvalidate( &clientrect , eraseBack ) ;
+ if ( MacIsReallyShown() )
+ {
+ /*
+ m_peer->SetVisibility( false , false ) ;
+ m_peer->SetVisibility( true , true ) ;
+ */
+ }
}
- */
-#endif
}
void wxWindowMac::Freeze()
void wxWindowMac::OnEraseBackground(wxEraseEvent& event)
{
#if TARGET_API_MAC_OSX
- if ( m_macBackgroundBrush.Ok() == false || m_macBackgroundBrush.GetStyle() == wxTRANSPARENT )
+ if ( MacGetTopLevelWindow()->MacUsesCompositing() && (m_macBackgroundBrush.Ok() == false || m_macBackgroundBrush.GetStyle() == wxTRANSPARENT ) )
{
event.Skip() ;
}
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)
+ if (top && top->MacUsesCompositing())
{
wxPoint pt(0,0) ;
wxMacControl::Convert( &pt , GetParent()->m_peer , top->m_peer ) ;
rect.top += pt.y ;
rect.bottom += pt.y ;
}
-#endif
if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
{
#ifdef __WXMAC_OSX__
// as the non OSX Version is already working in window relative coordinates, it's not needed
wxTopLevelWindowMac* top = MacGetTopLevelWindow();
- if (top)
+ if (top && top->MacUsesCompositing() )
{
wxPoint pt(0,0) ;
wxMacControl::Convert( &pt , GetParent()->m_peer , top->m_peer ) ;