]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/dialog.cpp
pen.h depends from brush.h in compat mode
[wxWidgets.git] / src / mac / carbon / dialog.cpp
index 2a127e76319c5a884278d7f9461894cb98fb2573..bb90e3812be7a6cb83f3cdfd81eca38da74de30b 100644 (file)
@@ -53,13 +53,6 @@ bool wxDialog::Create( wxWindow *parent,
     if ( !wxTopLevelWindow::Create( parent, id, title, pos, size, style, name ) )
         return false;
 
-#if TARGET_API_MAC_OSX
-    HIViewRef growBoxRef = 0 ;
-    OSStatus err = HIViewFindByID( HIViewGetRoot( (WindowRef)m_macWindow ), kHIViewWindowGrowBoxID, &growBoxRef  );
-    if ( err == noErr && growBoxRef != 0 )
-        HIGrowBoxViewSetTransparent( growBoxRef, true ) ;
-#endif
-
     return true;
 }
 
@@ -71,9 +64,7 @@ void wxDialog::SetModal( bool flag )
 
         wxModelessWindows.DeleteObject( this );
 
-#if TARGET_CARBON
         SetWindowModality( (WindowRef)MacGetWindowRef(), kWindowModalityAppModal, NULL ) ;
-#endif
     }
     else
     {
@@ -86,6 +77,8 @@ void wxDialog::SetModal( bool flag )
 wxDialog::~wxDialog()
 {
     m_isBeingDeleted = true;
+
+    // if the dialog is modal, this will end its event loop
     Show(false);
 }
 
@@ -112,10 +105,15 @@ bool wxDialog::Show(bool show)
         // nothing to do
         return false;
 
+    if (show && CanDoLayoutAdaptation())
+        DoLayoutAdaptation();
+
     if ( show )
         // usually will result in TransferDataToWindow() being called
         InitDialog();
 
+    HiliteMenu(0);
+
     if ( m_isModalStyle )
     {
         if ( show )
@@ -133,10 +131,6 @@ bool wxDialog::Show(bool show)
     return true;
 }
 
-#if !TARGET_CARBON
-extern bool s_macIsInModalLoop ;
-#endif
-
 void wxDialog::DoShowModal()
 {
     wxCHECK_RET( !IsModal(), wxT("DoShowModal() called twice") );
@@ -145,13 +139,19 @@ void wxDialog::DoShowModal()
 
     SetFocus() ;
 
-#if TARGET_CARBON
-    BeginAppModalStateForWindow(  (WindowRef) MacGetWindowRef()) ;
-#else
-    // TODO : test whether parent gets disabled
-    bool formerModal = s_macIsInModalLoop ;
-    s_macIsInModalLoop = true ;
-#endif
+    WindowRef windowRef = (WindowRef) MacGetWindowRef();
+    WindowGroupRef windowGroup;
+    WindowGroupRef formerParentGroup;
+    bool resetGroupParent = false;
+
+    if ( GetParent() == NULL )
+    {
+        windowGroup = GetWindowGroup(windowRef) ;
+        formerParentGroup = GetWindowGroupParent( windowGroup );
+        SetWindowGroupParent( windowGroup, GetWindowGroupOfClass( kMovableModalWindowClass ) );
+        resetGroupParent = true;
+    }
+    BeginAppModalStateForWindow(windowRef) ;
 
     while ( IsModal() )
     {
@@ -159,12 +159,11 @@ void wxDialog::DoShowModal()
         // calls process idle itself
     }
 
-#if TARGET_CARBON
-    EndAppModalStateForWindow( (WindowRef) MacGetWindowRef() ) ;
-#else
-    // TODO probably reenable the parent window if any
-    s_macIsInModalLoop = formerModal ;
-#endif
+    EndAppModalStateForWindow(windowRef) ;
+    if ( resetGroupParent )
+    {
+        SetWindowGroupParent( windowGroup , formerParentGroup );
+    }
 }