- int x_offset,y_offset ;
- int display_width, display_height;
- int width, height, x, y;
- wxWindow *parent = GetParent();
- if ((direction & wxCENTER_FRAME) && parent)
- {
- parent->GetPosition(&x_offset,&y_offset) ;
- parent->GetSize(&display_width,&display_height) ;
- }
- else
- {
- wxDisplaySize(&display_width, &display_height);
- x_offset = 0 ;
- y_offset = 0 ;
- }
-
- GetSize(&width, &height);
- GetPosition(&x, &y);
-
- if (direction & wxHORIZONTAL)
- x = (int)((display_width - width)/2);
- if (direction & wxVERTICAL)
- y = (int)((display_height - height)/2);
-
- SetSize(x+x_offset, y+y_offset, width, height);
+ wxCHECK_RET( !IsModalShowing(), wxT("DoShowModal() called twice") );
+
+ wxModalDialogs.Append(this);
+
+ SetFocus() ;
+
+#if TARGET_CARBON
+ BeginAppModalStateForWindow( (WindowRef) MacGetWindowRef()) ;
+#else
+ // TODO : test whether parent gets disabled
+ bool formerModal = s_macIsInModalLoop ;
+ s_macIsInModalLoop = true ;
+#endif
+
+ while ( IsModalShowing() )
+ {
+ wxTheApp->MacDoOneEvent() ;
+ // calls process idle itself
+ }
+
+#if TARGET_CARBON
+ EndAppModalStateForWindow( (WindowRef) MacGetWindowRef() ) ;
+#else
+ // TODO probably reenable the parent window if any
+ s_macIsInModalLoop = formerModal ;
+#endif