]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/dlgcmn.cpp
DC reorganization
[wxWidgets.git] / src / common / dlgcmn.cpp
index 7100e0fd7a70921ba148313b4e3cfd400ea50c7c..5621cbc6a978991b91aa58ef451a9829a013d54d 100644 (file)
@@ -52,12 +52,8 @@ BEGIN_EVENT_TABLE(wxDialogBase, wxTopLevelWindow)
     EVT_CLOSE(wxDialogBase::OnCloseWindow)
 
     EVT_CHAR_HOOK(wxDialogBase::OnCharHook)
-
-    WX_EVENT_TABLE_CONTROL_CONTAINER(wxDialogBase)
 END_EVENT_TABLE()
 
-WX_DELEGATE_TO_CONTROL_CONTAINER(wxDialogBase, wxTopLevelWindow)
-
 void wxDialogBase::Init()
 {
     m_returnCode = 0;
@@ -68,8 +64,17 @@ void wxDialogBase::Init()
     // dialog controls from reaching the parent frame which is usually
     // undesirable and can lead to unexpected and hard to find bugs
     SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS);
+}
 
-    WX_INIT_CONTROL_CONTAINER();
+// helper of GetParentForModalDialog()
+static bool CanBeUsedAsParent(wxWindow *parent)
+{
+    extern WXDLLIMPEXP_DATA_CORE(wxList) wxPendingDelete;
+
+    return !parent->HasExtraStyle(wxWS_EX_TRANSIENT) &&
+                parent->IsShownOnScreen() &&
+                    !wxPendingDelete.Member(parent) &&
+                        !parent->IsBeingDeleted();
 }
 
 wxWindow *wxDialogBase::GetParentForModalDialog(wxWindow *parent) const
@@ -79,10 +84,10 @@ wxWindow *wxDialogBase::GetParentForModalDialog(wxWindow *parent) const
     if ( parent )
         parent = wxGetTopLevelParent(parent);
 
-    if ( !parent || parent->HasExtraStyle(wxWS_EX_TRANSIENT) )
+    if ( !parent || !CanBeUsedAsParent(parent) )
         parent = wxTheApp->GetTopWindow();
 
-    if ( parent && parent->HasExtraStyle(wxWS_EX_TRANSIENT) )
+    if ( parent && !CanBeUsedAsParent(parent) )
     {
         // can't use this one, it's going to disappear
         parent = NULL;
@@ -187,7 +192,9 @@ wxSizer *wxDialogBase::CreateButtonSizer(long flags)
     {
         sizer = CreateStdDialogButtonSizer(flags);
     }
-#endif // wxUSE_BUTTON
+#else // !wxUSE_BUTTON
+    wxUnusedVar(flags);
+#endif // wxUSE_BUTTON/!wxUSE_BUTTON
 
 #endif // __SMARTPHONE__/!__SMARTPHONE__
 
@@ -443,8 +450,12 @@ void wxDialogBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
     closing.DeleteObject(this);
 }
 
-void wxDialogBase::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
+void wxDialogBase::OnSysColourChanged(wxSysColourChangedEvent& event)
 {
-  SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
-  Refresh();
+#ifndef __WXGTK__
+    SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
+    Refresh();
+#endif
+
+    event.Skip();
 }