- SetSize(x+x_offset, y+y_offset, width, height);
+ // remember where the focus was
+ wxWindow *winFocus = FindFocus();
+ if ( !winFocus )
+ {
+ winFocus = parent;
+ }
+ if ( !winFocus )
+ {
+ winFocus = wxTheApp->GetTopWindow();
+ }
+#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
+
+
+ // and restore focus
+ if ( winFocus )
+ {
+ winFocus->SetFocus();
+ }