extern long wxMacTranslateKey(unsigned char key, unsigned char code) ;
pascal OSStatus wxMacSetupControlBackground( ControlRef iControl , SInt16 iMessage , SInt16 iDepth , Boolean iIsColor ) ;
+#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3
+enum {
+ kEventControlVisibilityChanged = 157
+};
+#endif
+
static const EventTypeSpec eventList[] =
{
#if TARGET_API_MAC_OSX
{
case kEventControlDraw :
{
- RgnHandle updateRgn = cEvent.GetParameter<RgnHandle>(kEventParamRgnHandle) ;
+ RgnHandle updateRgn = NULL ;
+
+ wxRegion visRegion = thisWindow->MacGetVisibleRegion() ;
+ if ( cEvent.GetParameter<RgnHandle>(kEventParamRgnHandle, &updateRgn) != noErr )
+ {
+ updateRgn = (RgnHandle) visRegion.GetWXHRGN() ;
+ }
+ else
+ {
+ // unfortunately this update region may be incorrect (tree ctrl sample )
+ // so we have to reset it
+ // updateRgn = (RgnHandle) visRegion.GetWXHRGN() ;
+ }
// GrafPtr myport = cEvent.GetParameter<GrafPtr>(kEventParamGrafPort,typeGrafPtr) ;
#if 0 // in case we would need a coregraphics compliant background erase first
CGContextFillRect( cgContext, bounds );
}
#endif
- if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) )
+ if ( !thisWindow->MacIsUserPane() && thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) )
result = noErr ;
- else
- result = eventNotHandledErr;
+
}
break ;
case kEventControlVisibilityChanged :
{
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
- UInt32 features = kControlSupportsEmbedding | kControlSupportsLiveFeedback /*| kControlHasSpecialBackground */ | kControlSupportsCalcBestRect | kControlHandlesTracking | kControlSupportsFocus | kControlWantsActivate | kControlWantsIdle;
+ UInt32 features = kControlSupportsEmbedding | kControlSupportsLiveFeedback | kControlHasSpecialBackground |
+ kControlSupportsCalcBestRect | kControlHandlesTracking | kControlSupportsFocus | kControlWantsActivate | kControlWantsIdle;
- ::CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds, features, (ControlRef*) &m_macControl);
+ ::CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds, kControlSupportsEmbedding , (ControlRef*) &m_macControl);
MacPostControlCreate(pos,size) ;
-#if !TARGET_API_MAC_OSX
SetControlData((ControlRef) m_macControl,kControlEntireControl,kControlUserPaneDrawProcTag,
sizeof(gControlUserPaneDrawUPP),(Ptr) &gControlUserPaneDrawUPP);
+#if !TARGET_API_MAC_OSX
SetControlData((ControlRef) m_macControl,kControlEntireControl,kControlUserPaneHitTestProcTag,
sizeof(gControlUserPaneHitTestUPP),(Ptr) &gControlUserPaneHitTestUPP);
SetControlData((ControlRef) m_macControl,kControlEntireControl,kControlUserPaneTrackingProcTag,
wxSize wxWindowMac::DoGetBestSize() const
{
- /*
+ if ( m_macIsUserPane || IsTopLevel() )
+ return wxWindowBase::DoGetBestSize() ;
+
Rect bestsize = { 0 , 0 , 0 , 0 } ;
short baselineoffset ;
int bestWidth, bestHeight ;
bestHeight = 13 ;
return wxSize(bestWidth, bestHeight);
- */
- return wxWindowBase::DoGetBestSize() ;
+// return wxWindowBase::DoGetBestSize() ;
}
void wxWindowMac::Refresh(bool eraseBack, const wxRect *rect)
{
#if TARGET_API_MAC_OSX
- HIViewSetNeedsDisplay( (ControlRef) m_macControl , true ) ;
+ if ( rect == NULL )
+ HIViewSetNeedsDisplay( (ControlRef) m_macControl , true ) ;
+ else
+ {
+ RgnHandle update = NewRgn() ;
+ SetRectRgn( update , rect->x , rect->y , rect->x + rect->width , rect->y + rect->height ) ;
+ SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , update , update ) ;
+ HIViewSetNeedsDisplayInRegion( (ControlRef) m_macControl , update , true ) ;
+ }
#else
+/*
+ RgnHandle updateRgn = NewRgn() ;
+ if ( rect == NULL )
+ {
+ CopyRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , updateRgn ) ;
+ }
+ else
+ {
+ SetRectRgn( updateRgn , rect->x , rect->y , rect->x + rect->width , rect->y + rect->height ) ;
+ SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , updateRgn , updateRgn ) ;
+ }
+ InvalWindowRgn( (WindowRef) MacGetTopLevelWindowRef() , updateRgn ) ;
+ DisposeRgn(updateRgn) ;
+*/
if ( IsControlVisible( (ControlRef) m_macControl ) )
{
SetControlVisibility( (ControlRef) m_macControl , false , false ) ;
*/
bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time )
{
+ // we let the OS handle root control redraws
+ if ( m_macControl == MacGetTopLevelWindow()->GetHandle() )
+ return false ;
+
RgnHandle updatergn = (RgnHandle) updatergnr ;
bool handled = false ;