]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/toplevel.cpp
Include missing.h to find O_* flags.
[wxWidgets.git] / src / mac / carbon / toplevel.cpp
index 0368071037ecda6ed739788a8ece787d9e8c4a23..d41ae760f042f007907aef794a75fc58b2647a84 100644 (file)
@@ -49,6 +49,9 @@
 
 #include <ToolUtils.h>
 
+//For targeting OSX
+#include "wx/mac/private.h"
+
 // ----------------------------------------------------------------------------
 // globals
 // ----------------------------------------------------------------------------
@@ -442,7 +445,19 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev
             if ( control == 0 )
                 currentMouseWindow = (wxWindow*) data ;
             else
+            {
                 currentMouseWindow = wxFindControlFromMacControl( control ) ;
+                if ( currentMouseWindow == NULL && cEvent.GetKind() == kEventMouseMoved )
+                {
+                       // for wxToolBar to function we have to send certaint events to it
+                       // instead of its children (wxToolBarTools)     
+                    ControlRef parent ;
+                    GetSuperControl(control, &parent );
+                    wxWindow *wxParent = wxFindControlFromMacControl( parent ) ;
+                    if ( wxParent && wxParent->IsKindOf( CLASSINFO( wxToolBar ) ) )
+                        currentMouseWindow = wxParent ;
+                }
+            }
         }        
     }
     
@@ -535,13 +550,16 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev
                 (FindControlUnderMouse(windowMouseLocation , window , &dummyPart) != 
                 wxMacFindControlUnderMouse( windowMouseLocation , window , &dummyPart ) ) )
             {
-                EventModifiers modifiers = cEvent.GetParameter<EventModifiers>(kEventParamKeyModifiers, typeUInt32) ;
-                Point clickLocation = windowMouseLocation ;
-#if TARGET_API_MAC_OSX
-                currentMouseWindow->MacRootWindowToWindow( &clickLocation.h , &clickLocation.v ) ;
-#endif
-                HandleControlClick( (ControlRef) currentMouseWindow->GetHandle() , clickLocation ,
-                    modifiers , (ControlActionUPP ) -1 ) ;
+                if ( currentMouseWindow->MacIsReallyEnabled() ) 
+                {
+                    EventModifiers modifiers = cEvent.GetParameter<EventModifiers>(kEventParamKeyModifiers, typeUInt32) ;
+                    Point clickLocation = windowMouseLocation ;
+    #if TARGET_API_MAC_OSX
+                    currentMouseWindow->MacRootWindowToWindow( &clickLocation.h , &clickLocation.v ) ;
+    #endif
+                    HandleControlClick( (ControlRef) currentMouseWindow->GetHandle() , clickLocation ,
+                        modifiers , (ControlActionUPP ) -1 ) ;
+                }
                 result = noErr ;
             }
         }
@@ -807,6 +825,7 @@ bool wxTopLevelWindowMac::Create(wxWindow *parent,
     SetName(name);
 
     m_windowId = id == -1 ? NewControlId() : id;
+    wxWindow::SetTitle( title ) ;
 
     MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ;
 
@@ -967,6 +986,16 @@ void  wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
     {
         wclass = kDocumentWindowClass ;
     }
+#if defined( __WXMAC__ ) && TARGET_API_MAC_OSX && ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2 )
+    else if ( HasFlag( wxFRAME_DRAWER ) )
+    {
+        wclass = kDrawerWindowClass;
+        // Should this be left for compositing check below?
+        // CreateNewWindow will fail without it, should wxDrawerWindow turn
+        // on compositing before calling MacCreateRealWindow?
+        attr |= kWindowCompositingAttribute;// | kWindowStandardHandlerAttribute;
+    }
+#endif  //10.2 and up
     else
     {
         if ( HasFlag( wxMINIMIZE_BOX ) || HasFlag( wxMAXIMIZE_BOX ) ||