]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/toplevel.cpp
style creation
[wxWidgets.git] / src / mac / carbon / toplevel.cpp
index 7e109340963f558aaeed76ef66e09c890476f133..8e4a9551c5f90cb7fce2cde8130dacbaabc42cc9 100644 (file)
@@ -439,6 +439,7 @@ void wxRemoveMacWindowAssociation(wxTopLevelWindowMac *win)
 // ----------------------------------------------------------------------------
 
 WXHWND wxTopLevelWindowMac::s_macWindowInUpdate = NULL;
 // ----------------------------------------------------------------------------
 
 WXHWND wxTopLevelWindowMac::s_macWindowInUpdate = NULL;
+wxTopLevelWindowMac *wxTopLevelWindowMac::s_macDeactivateWindow = NULL;
 
 void wxTopLevelWindowMac::Init()
 {
 
 void wxTopLevelWindowMac::Init()
 {
@@ -563,6 +564,7 @@ void  wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
            long style,
            const wxString& name )
 {
            long style,
            const wxString& name )
 {
+    OSStatus err = noErr ;
     SetName(name);
     m_windowStyle = style;
     m_isShown = FALSE;
     SetName(name);
     m_windowStyle = style;
     m_isShown = FALSE;
@@ -622,7 +624,7 @@ void  wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
     else
     {
         if ( HasFlag( wxMINIMIZE_BOX ) || HasFlag( wxMAXIMIZE_BOX ) ||
     else
     {
         if ( HasFlag( wxMINIMIZE_BOX ) || HasFlag( wxMAXIMIZE_BOX ) ||
-            HasFlag( wxSYSTEM_MENU ) )
+            HasFlag( wxCLOSE_BOX ) || HasFlag( wxSYSTEM_MENU ) )
         {
             wclass = kDocumentWindowClass ;
         }
         {
             wclass = kDocumentWindowClass ;
         }
@@ -636,16 +638,19 @@ void  wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
         }
     }
 
         }
     }
 
-    if ( HasFlag( wxMINIMIZE_BOX ) || HasFlag( wxMAXIMIZE_BOX ) )
+    if ( HasFlag( wxMINIMIZE_BOX ) )
     {
     {
-        attr |= kWindowFullZoomAttribute ;
         attr |= kWindowCollapseBoxAttribute ;
     }
         attr |= kWindowCollapseBoxAttribute ;
     }
+    if ( HasFlag( wxMAXIMIZE_BOX ) )
+    {
+        attr |= kWindowFullZoomAttribute ;
+    }
     if ( HasFlag( wxRESIZE_BORDER ) )
     {
         attr |= kWindowResizableAttribute ;
     }
     if ( HasFlag( wxRESIZE_BORDER ) )
     {
         attr |= kWindowResizableAttribute ;
     }
-    if ( HasFlag( wxSYSTEM_MENU ) )
+    if ( HasFlag( wxCLOSE_BOX) )
     {
         attr |= kWindowCloseBoxAttribute ;
     }
     {
         attr |= kWindowCloseBoxAttribute ;
     }
@@ -664,23 +669,24 @@ void  wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
         customWindowDefSpec.defType = kWindowDefProcPtr;
         customWindowDefSpec.u.defProc = NewWindowDefUPP(wxShapedMacWindowDef);
 
         customWindowDefSpec.defType = kWindowDefProcPtr;
         customWindowDefSpec.u.defProc = NewWindowDefUPP(wxShapedMacWindowDef);
 
-        ::CreateCustomWindow( &customWindowDefSpec, wclass,
+        err = ::CreateCustomWindow( &customWindowDefSpec, wclass,
                               attr, &theBoundsRect,
                               (WindowRef*) &m_macWindow);
     }
     else
 #endif
     {
                               attr, &theBoundsRect,
                               (WindowRef*) &m_macWindow);
     }
     else
 #endif
     {
-        ::CreateNewWindow( wclass , attr , &theBoundsRect , (WindowRef*)&m_macWindow ) ;
+        err = ::CreateNewWindow( wclass , attr , &theBoundsRect , (WindowRef*)&m_macWindow ) ;
     }
 
     }
 
+    wxCHECK_RET( err == noErr, wxT("Mac OS error when trying to create new window") );
     wxAssociateWinWithMacWindow( m_macWindow , this ) ;
     UMASetWTitle( (WindowRef)m_macWindow , title ) ;
     ::CreateRootControl( (WindowRef)m_macWindow , (ControlHandle*)&m_macRootControl ) ;
 #if TARGET_CARBON
     InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_macWindow)) ) ;
     InstallWindowEventHandler(MAC_WXHWND(m_macWindow), GetwxMacWindowEventHandlerUPP(),
     wxAssociateWinWithMacWindow( m_macWindow , this ) ;
     UMASetWTitle( (WindowRef)m_macWindow , title ) ;
     ::CreateRootControl( (WindowRef)m_macWindow , (ControlHandle*)&m_macRootControl ) ;
 #if TARGET_CARBON
     InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_macWindow)) ) ;
     InstallWindowEventHandler(MAC_WXHWND(m_macWindow), GetwxMacWindowEventHandlerUPP(),
-        GetEventTypeCount(eventList), eventList, this, &((EventHandlerRef)m_macEventHandler));
+        GetEventTypeCount(eventList), eventList, this, (EventHandlerRef *)&m_macEventHandler);
 #endif
     m_macFocus = NULL ;
 
 #endif
     m_macFocus = NULL ;
 
@@ -916,8 +922,21 @@ void wxTopLevelWindowMac::MacMouseMoved( WXEVENTREF ev , short part)
 
 #endif
 
 
 #endif
 
+void wxTopLevelWindowMac::MacDelayedDeactivation(long timestamp)
+{
+    if(s_macDeactivateWindow)
+    {
+        wxLogDebug("Doing delayed deactivation of %p",s_macDeactivateWindow);
+        s_macDeactivateWindow->MacActivate(timestamp, false);
+    }
+}
+
 void wxTopLevelWindowMac::MacActivate( long timestamp , bool inIsActivating )
 {
 void wxTopLevelWindowMac::MacActivate( long timestamp , bool inIsActivating )
 {
+    wxLogDebug("TopLevel=%p::MacActivate",this);
+    if(s_macDeactivateWindow==this)
+        s_macDeactivateWindow=NULL;
+    MacDelayedDeactivation(timestamp);
     wxActivateEvent event(wxEVT_ACTIVATE, inIsActivating , m_windowId);
     event.m_timeStamp = timestamp ;
     event.SetEventObject(this);
     wxActivateEvent event(wxEVT_ACTIVATE, inIsActivating , m_windowId);
     event.m_timeStamp = timestamp ;
     event.SetEventObject(this);