]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/window.cpp
removed FAQs: they are already available in the website; there's no reason to duplica...
[wxWidgets.git] / src / mac / carbon / window.cpp
index e4cb57c133b3d18844f14afb20640395ebfe1f7c..804c0c2650843d499da6f73d84260baa62f767c2 100644 (file)
@@ -211,7 +211,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
                 if ( thisWindow->MacIsUserPane() )
                 {
                     static float color = 0.5 ;
-                    static channel = 0 ;
+                    static int channel = 0 ;
                     HIRect bounds;
                     CGContextRef cgContext = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef) ;
 
@@ -415,28 +415,31 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
                 {
 // set back to 0 if problems arise
 #if 1
-                    ControlPartCode currentControlPart = cEvent.GetParameter<ControlPartCode>(kEventParamControlPart , typeControlPartCode );
-                    // synthesize the event focus changed event
-                    EventRef evRef = NULL ;
-
-                    OSStatus err = MacCreateEvent(
-                                         NULL , kEventClassControl , kEventControlFocusPartChanged , TicksToEventTime( TickCount() ) ,
-                                         kEventAttributeUserEvent , &evRef );
-                    verify_noerr( err );
-
-                    wxMacCarbonEvent iEvent( evRef ) ;
-                    iEvent.SetParameter<ControlRef>( kEventParamDirectObject , controlRef );
-                    iEvent.SetParameter<EventTargetRef>( kEventParamPostTarget, typeEventTargetRef, GetControlEventTarget( controlRef ) );
-                    iEvent.SetParameter<ControlPartCode>( kEventParamControlPreviousPart, typeControlPartCode, previousControlPart );
-                    iEvent.SetParameter<ControlPartCode>( kEventParamControlCurrentPart, typeControlPartCode, currentControlPart );
-
+                    if ( result == noErr )
+                    {
+                        ControlPartCode currentControlPart = cEvent.GetParameter<ControlPartCode>(kEventParamControlPart , typeControlPartCode );
+                        // synthesize the event focus changed event
+                        EventRef evRef = NULL ;
+
+                        OSStatus err = MacCreateEvent(
+                                             NULL , kEventClassControl , kEventControlFocusPartChanged , TicksToEventTime( TickCount() ) ,
+                                             kEventAttributeUserEvent , &evRef );
+                        verify_noerr( err );
+
+                        wxMacCarbonEvent iEvent( evRef ) ;
+                        iEvent.SetParameter<ControlRef>( kEventParamDirectObject , controlRef );
+                        iEvent.SetParameter<EventTargetRef>( kEventParamPostTarget, typeEventTargetRef, GetControlEventTarget( controlRef ) );
+                        iEvent.SetParameter<ControlPartCode>( kEventParamControlPreviousPart, typeControlPartCode, previousControlPart );
+                        iEvent.SetParameter<ControlPartCode>( kEventParamControlCurrentPart, typeControlPartCode, currentControlPart );
+        
 #if 1
-                    // TODO test this first, avoid double posts etc...
-                    PostEventToQueue( GetMainEventQueue(), evRef , kEventPriorityHigh );
+                        // TODO test this first, avoid double posts etc...
+                        PostEventToQueue( GetMainEventQueue(), evRef , kEventPriorityHigh );
 #else
-                    wxMacWindowControlEventHandler( NULL , evRef , data ) ;
+                        wxMacWindowControlEventHandler( NULL , evRef , data ) ;
 #endif
-                    ReleaseEvent( evRef ) ;
+                        ReleaseEvent( evRef ) ;
+                    }
 #else
                     // old implementation, to be removed if the new one works
                     if ( controlPart == kControlFocusNoPart )
@@ -1203,10 +1206,13 @@ void wxWindowMac::SetFocus()
 
     // as we cannot rely on the control features to find out whether we are in full keyboard mode,
     // we can only leave in case of an error
-    wxLogTrace(_T("Focus"), _T("before wxWindow::SetFocus(%p)"), wx_static_cast(void*, this));
+    wxLogTrace(_T("Focus"), _T("before wxWindow::SetFocus(%p) %d"), wx_static_cast(void*, this), GetName().c_str());
     OSStatus err = m_peer->SetFocus( kControlFocusNextPart ) ;
     if ( err == errCouldntSetFocus )
+    {
+        wxLogTrace(_T("Focus"), _T("in wxWindow::SetFocus(%p) errCouldntSetFocus"), wx_static_cast(void*, this));
         return ;
+    }
     wxLogTrace(_T("Focus"), _T("after wxWindow::SetFocus(%p)"), wx_static_cast(void*, this));
 
     SetUserFocusWindow( (WindowRef)MacGetTopLevelWindowRef() );
@@ -3165,11 +3171,15 @@ void wxWindowMac::OnMouseEvent( wxMouseEvent &event )
 
 void wxWindowMac::OnPaint( wxPaintEvent & WXUNUSED(event) )
 {
-    if ( wxTheApp->MacGetCurrentEvent() != NULL && wxTheApp->MacGetCurrentEventHandlerCallRef() != NULL
-         && GetBackgroundStyle() != wxBG_STYLE_TRANSPARENT )
-        CallNextEventHandler(
-            (EventHandlerCallRef)wxTheApp->MacGetCurrentEventHandlerCallRef() ,
-            (EventRef) wxTheApp->MacGetCurrentEvent() ) ;
+    // for native controls: call their native paint method
+    if ( !MacIsUserPane() || ( IsTopLevel() && GetBackgroundStyle() == wxBG_STYLE_SYSTEM ) )
+    {
+        if ( wxTheApp->MacGetCurrentEvent() != NULL && wxTheApp->MacGetCurrentEventHandlerCallRef() != NULL
+             && GetBackgroundStyle() != wxBG_STYLE_TRANSPARENT )
+            CallNextEventHandler(
+                (EventHandlerCallRef)wxTheApp->MacGetCurrentEventHandlerCallRef() ,
+                (EventRef) wxTheApp->MacGetCurrentEvent() ) ;
+    }
 }
 
 void wxWindowMac::MacHandleControlClick(WXWidget WXUNUSED(control),