+ static float color = 0.5 ;
+ static channel = 0 ;
+ HIRect bounds;
+ CGContextRef cgContext = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef) ;
+
+ HIViewGetBounds( controlRef, &bounds );
+ CGContextSetRGBFillColor( cgContext, channel == 0 ? color : 0.5 ,
+ channel == 1 ? color : 0.5 , channel == 2 ? color : 0.5 , 1 );
+ CGContextFillRect( cgContext, bounds );
+ color += 0.1 ;
+ if ( color > 0.9 )
+ {
+ color = 0.5 ;
+ channel++ ;
+ if ( channel == 3 )
+ channel = 0 ;
+ }
+ }
+#endif
+
+ {
+ bool created = false ;
+ CGContextRef cgContext = NULL ;
+ OSStatus err = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef, &cgContext) ;
+ if ( err != noErr )
+ {
+ wxFAIL_MSG("Unable to retrieve CGContextRef");
+ }
+
+ thisWindow->MacSetCGContextRef( cgContext ) ;
+
+ {
+ wxMacCGContextStateSaver sg( cgContext ) ;
+ CGFloat alpha = (CGFloat)1.0 ;
+ {
+ wxWindow* iter = thisWindow ;
+ while ( iter )
+ {
+ alpha *= (CGFloat)( iter->GetTransparent()/255.0 ) ;
+ if ( iter->IsTopLevel() )
+ iter = NULL ;
+ else
+ iter = iter->GetParent() ;
+ }
+ }
+ CGContextSetAlpha( cgContext , alpha ) ;
+
+ if ( thisWindow->GetBackgroundStyle() == wxBG_STYLE_TRANSPARENT )
+ {
+ HIRect bounds;
+ HIViewGetBounds( controlRef, &bounds );
+ CGContextClearRect( cgContext, bounds );
+ }
+
+
+
+ if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) )
+ result = noErr ;
+
+ thisWindow->MacSetCGContextRef( NULL ) ;
+ }
+
+ if ( created )
+ CGContextRelease( cgContext ) ;
+ }
+
+ if ( allocatedRgn )
+ DisposeRgn( allocatedRgn ) ;
+ }
+ break ;
+
+ case kEventControlVisibilityChanged :
+ // we might have two native controls attributed to the same wxWindow instance
+ // eg a scrollview and an embedded textview, make sure we only fire for the 'outer'
+ // control, as otherwise native and wx visibility are different
+ if ( thisWindow->GetPeer() != NULL && thisWindow->GetPeer()->GetControlRef() == controlRef )
+ {
+ thisWindow->MacVisibilityChanged() ;
+ }
+ break ;
+
+ case kEventControlEnabledStateChanged :
+ thisWindow->MacEnabledStateChanged();
+ break ;
+
+ case kEventControlHiliteChanged :
+ thisWindow->MacHiliteChanged() ;
+ break ;
+
+ case kEventControlActivate :
+ case kEventControlDeactivate :
+ // FIXME: we should have a virtual function for this!
+#if wxUSE_TREECTRL
+ if ( thisWindow->IsKindOf( CLASSINFO( wxTreeCtrl ) ) )
+ thisWindow->Refresh();
+#endif
+#if wxUSE_LISTCTRL
+ if ( thisWindow->IsKindOf( CLASSINFO( wxListCtrl ) ) )
+ thisWindow->Refresh();
+#endif
+ break ;
+
+ //
+ // focus handling
+ // different handling on OS X
+ //
+
+ case kEventControlFocusPartChanged :
+ // the event is emulated by wxmac for systems lower than 10.5
+ {
+ ControlPartCode previousControlPart = cEvent.GetParameter<ControlPartCode>(kEventParamControlPreviousPart , typeControlPartCode );
+ ControlPartCode currentControlPart = cEvent.GetParameter<ControlPartCode>(kEventParamControlCurrentPart , typeControlPartCode );
+
+ if ( thisWindow->MacGetTopLevelWindow() && thisWindow->GetPeer()->NeedsFocusRect() )
+ {
+ thisWindow->MacInvalidateBorders();