]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/toplevel.cpp
added adjustOrigin parameter to bounds calculation, added Freeze and Thaw implementation
[wxWidgets.git] / src / mac / carbon / toplevel.cpp
index 6d038b6fa8de22c3e5b8060a831462c7b3e2995d..63b69a544e4741bceb11bc8fbfc7656d6d8a9edf 100644 (file)
@@ -74,7 +74,7 @@ extern long wxMacTranslateKey(unsigned char key, unsigned char code) ;
 static const EventTypeSpec eventList[] =
 {
     // TODO remove control related event like key and mouse (except for WindowLeave events)
-#if !TARGET_API_MAC_OSX    
+#if 1
     { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } ,
 
     { kEventClassKeyboard, kEventRawKeyDown } ,
@@ -512,12 +512,11 @@ static pascal OSStatus wxMacTopLevelWindowEventHandler( EventHandlerCallRef hand
         case kEventWindowActivated :
         {
             toplevelWindow->MacActivate( cEvent.GetTicks() , true) ;
-
             wxActivateEvent wxevent(wxEVT_ACTIVATE, true , toplevelWindow->GetId());
             wxevent.SetTimestamp( cEvent.GetTicks() ) ;
             wxevent.SetEventObject(toplevelWindow);
             toplevelWindow->GetEventHandler()->ProcessEvent(wxevent);
-            result = noErr ;
+            // we still sending an eventNotHandledErr in order to allow for default processing
             break ;
         }
         case kEventWindowDeactivated :
@@ -527,7 +526,7 @@ static pascal OSStatus wxMacTopLevelWindowEventHandler( EventHandlerCallRef hand
             wxevent.SetTimestamp( cEvent.GetTicks() ) ;
             wxevent.SetEventObject(toplevelWindow);
             toplevelWindow->GetEventHandler()->ProcessEvent(wxevent);
-            result = noErr ;
+            // we still sending an eventNotHandledErr in order to allow for default processing
             break ;
         }
        case kEventWindowShown :
@@ -590,11 +589,11 @@ static pascal OSStatus wxMacTopLevelWindowEventHandler( EventHandlerCallRef hand
                 }
                 if ( toplevelWindow->GetMaxWidth() != -1 && adjustR.GetWidth() > toplevelWindow->GetMaxWidth() )
                     adjustR.SetWidth( toplevelWindow->GetMaxWidth() ) ;
-                if ( toplevelWindow->GetMaxHeight() != -1 && adjustR.GetWidth() > toplevelWindow->GetMaxHeight() )
+                if ( toplevelWindow->GetMaxHeight() != -1 && adjustR.GetHeight() > toplevelWindow->GetMaxHeight() )
                     adjustR.SetHeight( toplevelWindow->GetMaxHeight() ) ;
                 if ( toplevelWindow->GetMinWidth() != -1 && adjustR.GetWidth() < toplevelWindow->GetMinWidth() )
                     adjustR.SetWidth( toplevelWindow->GetMinWidth() ) ;
-                if ( toplevelWindow->GetMinHeight() != -1 && adjustR.GetWidth() < toplevelWindow->GetMinHeight() )
+                if ( toplevelWindow->GetMinHeight() != -1 && adjustR.GetHeight() < toplevelWindow->GetMinHeight() )
                     adjustR.SetHeight( toplevelWindow->GetMinHeight() ) ;
                 Rect adjustedRect = { adjustR.y , adjustR.x , adjustR.y + adjustR.height , adjustR.x + adjustR.width } ;
                 if ( !EqualRect( &newRect , &adjustedRect ) )
@@ -827,6 +826,16 @@ void  wxTopLevelWindowMac::MacSetBackgroundBrush( const wxBrush &brush )
     }
 }
 
+void wxTopLevelWindowMac::MacInstallTopLevelWindowEventHandler() 
+{
+    if ( m_macEventHandler != NULL )
+    {
+        verify_noerr( ::RemoveEventHandler( (EventHandlerRef) m_macEventHandler ) ) ;
+    }
+    InstallWindowEventHandler(MAC_WXHWND(m_macWindow), GetwxMacTopLevelEventHandlerUPP(),
+        GetEventTypeCount(eventList), eventList, this, (EventHandlerRef *)&m_macEventHandler);
+}
+
 void  wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
            const wxPoint& pos,
            const wxSize& size,
@@ -950,13 +959,14 @@ void  wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
     else
     {
         ::CreateRootControl( (WindowRef)m_macWindow , (ControlRef*)&m_macControl ) ;
-        MacInstallEventHandler() ;
     }
+    // the root control level handleer
+    MacInstallEventHandler() ;
 
+    // the frame window event handler
     InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_macWindow)) ) ;
-    InstallWindowEventHandler(MAC_WXHWND(m_macWindow), GetwxMacTopLevelEventHandlerUPP(),
-        GetEventTypeCount(eventList), eventList, this, (EventHandlerRef *)&m_macEventHandler);
-
+    MacInstallTopLevelWindowEventHandler() ;
+    
     m_macFocus = NULL ;
 
     if ( HasFlag(wxFRAME_SHAPED) )
@@ -1004,6 +1014,7 @@ void wxTopLevelWindowMac::MacActivate( long timestamp , bool inIsActivating )
     if(s_macDeactivateWindow==this)
         s_macDeactivateWindow=NULL;
     MacDelayedDeactivation(timestamp);
+    MacPropagateHiliteChanged() ;
 }
 
 void wxTopLevelWindowMac::SetTitle(const wxString& title)
@@ -1098,6 +1109,15 @@ void wxTopLevelWindowMac::MacSetMetalAppearance( bool set )
 #endif
 }
 
+bool wxTopLevelWindowMac::MacGetMetalAppearance() const 
+{
+#if TARGET_API_MAC_OSX
+    return MacGetWindowAttributes() & kWindowMetalAttribute ;
+#else
+    return false ;
+#endif
+}
+
 void wxTopLevelWindowMac::MacChangeWindowAttributes( wxUint32 attributesToSet , wxUint32 attributesToClear ) 
 {
     ChangeWindowAttributes ( (WindowRef) m_macWindow , attributesToSet, attributesToClear ) ;