]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/window.cpp
fix compilation error after r50329: wxMenu doesn't have HandleWindowEvent() as it...
[wxWidgets.git] / src / mac / carbon / window.cpp
index 5bafb0db3f7dc65cc8ee862bcca9f7b392ff3677..6c158e6acdee9fda4e7098e7723a77d9ef7f8c0e 100644 (file)
@@ -78,8 +78,6 @@ BEGIN_EVENT_TABLE(wxWindowMac, wxWindowBase)
     EVT_NC_PAINT(wxWindowMac::OnNcPaint)
     EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground)
     EVT_PAINT(wxWindowMac::OnPaint)
-    EVT_SET_FOCUS(wxWindowMac::OnSetFocus)
-    EVT_KILL_FOCUS(wxWindowMac::OnSetFocus)
     EVT_MOUSE_EVENTS(wxWindowMac::OnMouseEvent)
 END_EVENT_TABLE()
 
@@ -312,6 +310,12 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
             {
                 ControlPartCode previousControlPart = cEvent.GetParameter<ControlPartCode>(kEventParamControlPreviousPart , typeControlPartCode );
                 ControlPartCode currentControlPart = cEvent.GetParameter<ControlPartCode>(kEventParamControlCurrentPart , typeControlPartCode );
+
+                if ( thisWindow->MacGetTopLevelWindow() && thisWindow->GetPeer()->NeedsFocusRect() )
+                {
+                    thisWindow->MacInvalidateBorders();
+                }
+                
                 if ( currentControlPart == 0 )
                 {
                     // kill focus
@@ -330,7 +334,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
                         inKillFocusEvent = true ;
                         wxFocusEvent event( wxEVT_KILL_FOCUS, thisWindow->GetId());
                         event.SetEventObject(thisWindow);
-                        thisWindow->GetEventHandler()->ProcessEvent(event) ;
+                        thisWindow->HandleWindowEvent(event) ;
                         inKillFocusEvent = false ;
                     }
                 }
@@ -340,7 +344,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
                     // panel wants to track the window which was the last to have focus in it
                     wxLogTrace(_T("Focus"), _T("focus set(%p)"), wx_static_cast(void*, thisWindow));
                     wxChildFocusEvent eventFocus((wxWindow*)thisWindow);
-                    thisWindow->GetEventHandler()->ProcessEvent(eventFocus);
+                    thisWindow->HandleWindowEvent(eventFocus);
                     
 #if wxUSE_CARET
                     if ( thisWindow->GetCaret() )
@@ -349,7 +353,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
                     
                     wxFocusEvent event(wxEVT_SET_FOCUS, thisWindow->GetId());
                     event.SetEventObject(thisWindow);
-                    thisWindow->GetEventHandler()->ProcessEvent(event) ;
+                    thisWindow->HandleWindowEvent(event) ;
                 }
             }
             break;
@@ -419,7 +423,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
                             inKillFocusEvent = true ;
                             wxFocusEvent event( wxEVT_KILL_FOCUS, thisWindow->GetId());
                             event.SetEventObject(thisWindow);
-                            thisWindow->GetEventHandler()->ProcessEvent(event) ;
+                            thisWindow->HandleWindowEvent(event) ;
                             inKillFocusEvent = false ;
                         }
                     }
@@ -428,7 +432,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
                         // panel wants to track the window which was the last to have focus in it
                         wxLogTrace(_T("Focus"), _T("focus set(%p)"), wx_static_cast(void*, thisWindow));
                         wxChildFocusEvent eventFocus((wxWindow*)thisWindow);
-                        thisWindow->GetEventHandler()->ProcessEvent(eventFocus);
+                        thisWindow->HandleWindowEvent(eventFocus);
 
     #if wxUSE_CARET
                         if ( thisWindow->GetCaret() )
@@ -437,7 +441,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
 
                         wxFocusEvent event(wxEVT_SET_FOCUS, thisWindow->GetId());
                         event.SetEventObject(thisWindow);
-                        thisWindow->GetEventHandler()->ProcessEvent(event) ;
+                        thisWindow->HandleWindowEvent(event) ;
                     }
 #endif
                 }
@@ -1675,7 +1679,7 @@ void wxWindowMac::MacInvalidateBorders()
         return ;
 
     int outerBorder = MacGetLeftBorderSize() ;
-    if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() )
+    if ( m_peer->NeedsFocusRect() /* && m_peer->HasFocus() */ )
         outerBorder += 4 ;
 
     if ( outerBorder == 0 )
@@ -1771,7 +1775,7 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height)
             wxPoint point(actualX, actualY);
             wxMoveEvent event(point, m_windowId);
             event.SetEventObject(this);
-            GetEventHandler()->ProcessEvent(event) ;
+            HandleWindowEvent(event) ;
         }
 
         if ( doResize )
@@ -1780,7 +1784,7 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height)
             wxSize size(actualWidth, actualHeight);
             wxSizeEvent event(size, m_windowId);
             event.SetEventObject(this);
-            GetEventHandler()->ProcessEvent(event);
+            HandleWindowEvent(event);
         }
     }
 }
@@ -2384,7 +2388,7 @@ void wxWindowMac::DoUpdateScrollbarVisibility()
     {
         wxSizeEvent event(GetSize(), m_windowId);
         event.SetEventObject(this);
-        GetEventHandler()->ProcessEvent(event);
+        HandleWindowEvent(event);
     }
 }
 
@@ -2496,7 +2500,7 @@ void wxWindowMac::MacOnScroll( wxScrollEvent &event )
         else if (event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE)
             wevent.SetEventType( wxEVT_SCROLLWIN_THUMBRELEASE );
 
-        GetEventHandler()->ProcessEvent(wevent);
+        HandleWindowEvent(wevent);
     }
 }
 
@@ -2508,54 +2512,6 @@ wxWindowMac *wxWindowBase::DoFindFocus()
     return wxFindControlFromMacControl( control ) ;
 }
 
-void wxWindowMac::OnSetFocus( wxFocusEvent& event )
-{
-    // panel wants to track the window which was the last to have focus in it,
-    // so we want to set ourselves as the window which last had focus
-    //
-    // notice that it's also important to do it upwards the tree because
-    // otherwise when the top level panel gets focus, it won't set it back to
-    // us, but to some other sibling
-
-    // CS: don't know if this is still needed:
-    //wxChildFocusEvent eventFocus(this);
-    //(void)GetEventHandler()->ProcessEvent(eventFocus);
-
-    if ( MacGetTopLevelWindow() && m_peer->NeedsFocusRect() )
-    {
-        GetParent()->Refresh() ;
-        wxMacWindowStateSaver sv( this ) ;
-        Rect rect ;
-
-        m_peer->GetRect( &rect ) ;
-        // on the surrounding frame
-        InsetRect( &rect, -1 , -1 ) ;
-
-        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 ;
-        }
-
-        bool bIsFocusEvent = (event.GetEventType() == wxEVT_SET_FOCUS);
-        DrawThemeFocusRect( &rect , bIsFocusEvent ) ;
-        if ( !bIsFocusEvent )
-        {
-            // 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
-            MacInvalidateBorders() ;
-        }
-    }
-
-    event.Skip();
-}
-
 void wxWindowMac::OnInternalIdle()
 {
     // This calls the UI-update mechanism (querying windows for
@@ -2589,7 +2545,7 @@ bool wxWindowMac::MacSetupCursor( const wxPoint& pt )
     {
         wxSetCursorEvent event( pt.x , pt.y );
 
-        bool processedEvtSetCursor = GetEventHandler()->ProcessEvent(event);
+        bool processedEvtSetCursor = HandleWindowEvent(event);
         if ( processedEvtSetCursor && event.HasCursor() )
         {
             cursor = event.GetCursor() ;
@@ -2807,7 +2763,7 @@ bool wxWindowMac::MacDoRedraw( void* updatergnr , long time )
 
             wxEraseEvent eevent( GetId(), dc );
             eevent.SetEventObject( this );
-            GetEventHandler()->ProcessEvent( eevent );
+            HandleWindowEvent( eevent );
             delete dc ;
         }
 
@@ -2825,7 +2781,7 @@ bool wxWindowMac::MacDoRedraw( void* updatergnr , long time )
             wxPaintEvent event;
             event.SetTimestamp(time);
             event.SetEventObject(this);
-            GetEventHandler()->ProcessEvent(event);
+            HandleWindowEvent(event);
             handled = true ;
         }
 
@@ -2864,7 +2820,7 @@ bool wxWindowMac::MacDoRedraw( void* updatergnr , long time )
                 // paint custom borders
                 wxNcPaintEvent eventNc( child->GetId() );
                 eventNc.SetEventObject( child );
-                if ( !child->GetEventHandler()->ProcessEvent( eventNc ) )
+                if ( !child->HandleWindowEvent( eventNc ) )
                 {
                     child->MacPaintBorders(0, 0) ;
                 }
@@ -3199,7 +3155,7 @@ void wxWindowMac::OnMouseEvent( wxMouseEvent &event )
         wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU,
                                   this->GetId(),
                                   this->ClientToScreen(event.GetPosition()));
-        if ( ! GetEventHandler()->ProcessEvent(evtCtx) )
+        if ( ! HandleWindowEvent(evtCtx) )
             event.Skip() ;
     }
     else