]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/window_osx.cpp
Applied #15375 to stop event-sending in generic wxSpinCtrl ctor (eco)
[wxWidgets.git] / src / osx / window_osx.cpp
index d7ef17acce5cb39ae1806f35152d747c74b49a15..cb3e871efdb8d5e888d6f7fe48f704a025e72a97 100644 (file)
@@ -4,7 +4,6 @@
 // Author:      Stefan Csomor
 // Modified by:
 // Created:     1998-01-01
 // Author:      Stefan Csomor
 // Modified by:
 // Created:     1998-01-01
-// RCS-ID:      $Id$
 // Copyright:   (c) Stefan Csomor
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 // Copyright:   (c) Stefan Csomor
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -416,6 +415,9 @@ bool wxWindowMac::Create(wxWindowMac *parent,
 
     m_windowVariant = parent->GetWindowVariant() ;
 
 
     m_windowVariant = parent->GetWindowVariant() ;
 
+    m_hScrollBarAlwaysShown =
+    m_vScrollBarAlwaysShown = HasFlag(wxALWAYS_SHOW_SB);
+
     if ( m_peer != kOSXNoWidgetImpl )
     {
         SetPeer(wxWidgetImpl::CreateUserPane( this, parent, id, pos, size , style, GetExtraStyle() ));
     if ( m_peer != kOSXNoWidgetImpl )
     {
         SetPeer(wxWidgetImpl::CreateUserPane( this, parent, id, pos, size , style, GetExtraStyle() ));
@@ -614,12 +616,14 @@ void wxWindowMac::OSXSimulateFocusEvents()
         {
             wxFocusEvent event( wxEVT_KILL_FOCUS, former->GetId());
             event.SetEventObject(former);
         {
             wxFocusEvent event( wxEVT_KILL_FOCUS, former->GetId());
             event.SetEventObject(former);
+            event.SetWindow(this);
             former->HandleWindowEvent(event) ;
         }
 
         {
             wxFocusEvent event(wxEVT_SET_FOCUS, former->GetId());
             event.SetEventObject(former);
             former->HandleWindowEvent(event) ;
         }
 
         {
             wxFocusEvent event(wxEVT_SET_FOCUS, former->GetId());
             event.SetEventObject(former);
+            event.SetWindow(this);
             former->HandleWindowEvent(event);
         }
     }
             former->HandleWindowEvent(event);
         }
     }
@@ -870,9 +874,22 @@ void wxWindowMac::DoGetClientSize( int *x, int *y ) const
 
 #endif
     if (x)
 
 #endif
     if (x)
-       *x = ww;
+    {
+        // we shouldn't return invalid width
+        if ( ww < 0 )
+            ww = 0;
+        
+        *x = ww;
+    }
+    
     if (y)
     if (y)
-       *y = hh;
+    {
+        // we shouldn't return invalid height
+        if ( hh < 0 )
+            hh = 0;
+        
+        *y = hh;
+    }
 }
 
 bool wxWindowMac::SetCursor(const wxCursor& cursor)
 }
 
 bool wxWindowMac::SetCursor(const wxCursor& cursor)
@@ -1058,11 +1075,7 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height)
         if ( doResize )
         {
             MacRepositionScrollBars() ;
         if ( doResize )
         {
             MacRepositionScrollBars() ;
-            MacOnInternalSize();
-            wxSize size(actualWidth, actualHeight);
-            wxSizeEvent event(size, m_windowId);
-            event.SetEventObject(this);
-            HandleWindowEvent(event);
+            SendSizeEvent();
         }
     }
 }
         }
     }
 }
@@ -1116,6 +1129,12 @@ wxSize wxWindowMac::DoGetBestSize() const
     }
 }
 
     }
 }
 
+void wxWindowMac::SendSizeEvent(int flags)
+{
+    MacOnInternalSize();
+    wxWindowBase::SendSizeEvent(flags);
+}
+
 // set the size of the window: if the dimensions are positive, just use them,
 // but if any of them is equal to -1, it means that we must find the value for
 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
 // set the size of the window: if the dimensions are positive, just use them,
 // but if any of them is equal to -1, it means that we must find the value for
 // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
@@ -1142,10 +1161,7 @@ void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags)
 
         if (sizeFlags & wxSIZE_FORCE_EVENT)
         {
 
         if (sizeFlags & wxSIZE_FORCE_EVENT)
         {
-            MacOnInternalSize();
-            wxSizeEvent event( wxSize(width,height), GetId() );
-            event.SetEventObject( this );
-            HandleWindowEvent( event );
+            SendSizeEvent();
         }
 
         return;
         }
 
         return;
@@ -1218,7 +1234,7 @@ void wxWindowMac::DoSetClientSize(int clientwidth, int clientheight)
     }
 }
 
     }
 }
 
-float wxWindowMac::GetContentScaleFactor() const 
+double wxWindowMac::GetContentScaleFactor() const 
 {
     return GetPeer()->GetContentScaleFactor();
 }
 {
     return GetPeer()->GetContentScaleFactor();
 }
@@ -1304,7 +1320,6 @@ void wxWindowMac::MacHiliteChanged()
 
 void wxWindowMac::MacEnabledStateChanged()
 {
 
 void wxWindowMac::MacEnabledStateChanged()
 {
-    OnEnabled( GetPeer()->IsEnabled() );
 }
 
 //
 }
 
 //
@@ -1677,10 +1692,7 @@ void wxWindowMac::DoUpdateScrollbarVisibility()
     MacRepositionScrollBars() ;
     if ( triggerSizeEvent )
     {
     MacRepositionScrollBars() ;
     if ( triggerSizeEvent )
     {
-        MacOnInternalSize();
-        wxSizeEvent event(GetSize(), m_windowId);
-        event.SetEventObject(this);
-        HandleWindowEvent(event);
+        SendSizeEvent();
     }
 #endif
 }
     }
 #endif
 }
@@ -2191,7 +2203,8 @@ bool wxWindowMac::MacHasScrollBarCorner() const
             const wxFrame *frame = wxDynamicCast( win, wxFrame ) ;
             if ( frame )
             {
             const wxFrame *frame = wxDynamicCast( win, wxFrame ) ;
             if ( frame )
             {
-                if ( frame->GetWindowStyleFlag() & wxRESIZE_BORDER )
+                // starting from 10.7 there are no resize indicators anymore
+                if ( (frame->GetWindowStyleFlag() & wxRESIZE_BORDER) && UMAGetSystemVersion() < 0x1070)
                 {
                     // Parent frame has resize handle
                     wxPoint frameBottomRight = frame->GetScreenRect().GetBottomRight();
                 {
                     // Parent frame has resize handle
                     wxPoint frameBottomRight = frame->GetScreenRect().GetBottomRight();
@@ -2741,13 +2754,13 @@ bool wxWindowMac::OSXHandleKeyEvent( wxKeyEvent& event )
             {
                 wxEvtHandler * const handler = ancestor->GetEventHandler();
 
             {
                 wxEvtHandler * const handler = ancestor->GetEventHandler();
 
-                wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
+                wxCommandEvent command_event( wxEVT_MENU, command );
                 handled = handler->ProcessEvent( command_event );
 
                 if ( !handled )
                 {
                     // accelerators can also be used with buttons, try them too
                 handled = handler->ProcessEvent( command_event );
 
                 if ( !handled )
                 {
                     // accelerators can also be used with buttons, try them too
-                    command_event.SetEventType(wxEVT_COMMAND_BUTTON_CLICKED);
+                    command_event.SetEventType(wxEVT_BUTTON);
                     handled = handler->ProcessEvent( command_event );
                 }
 
                     handled = handler->ProcessEvent( command_event );
                 }
 
@@ -2776,6 +2789,10 @@ bool wxWindowMac::OSXHandleKeyEvent( wxKeyEvent& event )
 // wxWidgetImpl
 //
 
 // wxWidgetImpl
 //
 
+// we are maintaining a n:1 map from native controls (ControlRef / NSView*) to their wxWidgetImpl
+// n:1 because we might have an embedded view eg within a scrollview, both being part of the same impl
+// the impl is calling Associate with its newly created native control(s), e.g. in InstallHandler
+
 WX_DECLARE_HASH_MAP(WXWidget, wxWidgetImpl*, wxPointerHash, wxPointerEqual, MacControlMap);
 
 static MacControlMap wxWinMacControlList;
 WX_DECLARE_HASH_MAP(WXWidget, wxWidgetImpl*, wxPointerHash, wxPointerEqual, MacControlMap);
 
 static MacControlMap wxWinMacControlList;