+ {
+ str = dialog.GetValue();
+ }
+
+ return str;
+}
+
+wxString wxGetPasswordFromUser(const wxString& message,
+ const wxString& caption,
+ const wxString& defaultValue,
+ wxWindow *parent,
+ wxCoord x, wxCoord y, bool centre )
+{
+ wxString str;
+ long style = wxTextEntryDialogStyle;
+
+ if (centre)
+ style |= wxCENTRE;
+ else
+ style &= ~wxCENTRE;
+
+ wxPasswordEntryDialog dialog(parent, message, caption, defaultValue,
+ style, wxPoint(x, y));
+ if ( dialog.ShowModal() == wxID_OK )
+ {
+ str = dialog.GetValue();
+ }
+
+ return str;
+}
+
+#endif // wxUSE_TEXTDLG
+
+#if wxUSE_COLOURDLG
+
+wxColour wxGetColourFromUser(wxWindow *parent,
+ const wxColour& colInit,
+ const wxString& caption,
+ wxColourData *ptrData)
+{
+ // contains serialized representation of wxColourData used the last time
+ // the dialog was shown: we want to reuse it the next time in order to show
+ // the same custom colours to the user (and we can't just have static
+ // wxColourData itself because it's a GUI object and so should be destroyed
+ // before GUI shutdown and doing it during static cleanup is too late)
+ static wxString s_strColourData;
+
+ wxColourData data;
+ if ( !ptrData )
+ {
+ ptrData = &data;
+ if ( !s_strColourData.empty() )
+ {
+ if ( !data.FromString(s_strColourData) )
+ {
+ wxFAIL_MSG( "bug in wxColourData::FromString()?" );
+ }
+
+#ifdef __WXMSW__
+ // we don't get back the "choose full" flag value from the native
+ // dialog and so we can't preserve it between runs, so we decide to
+ // always use it as it seems better than not using it (user can
+ // just ignore the extra controls in the dialog but having to click
+ // a button each time to show them would be very annoying
+ data.SetChooseFull(true);
+#endif // __WXMSW__
+ }
+ }
+
+ if ( colInit.IsOk() )
+ {
+ ptrData->SetColour(colInit);
+ }
+
+ wxColour colRet;
+ wxColourDialog dialog(parent, ptrData);
+ if (!caption.empty())
+ dialog.SetTitle(caption);
+ if ( dialog.ShowModal() == wxID_OK )
+ {
+ *ptrData = dialog.GetColourData();
+ colRet = ptrData->GetColour();
+ s_strColourData = ptrData->ToString();
+ }
+ //else: leave colRet invalid
+
+ return colRet;
+}
+
+#endif // wxUSE_COLOURDLG
+
+#if wxUSE_FONTDLG
+
+wxFont wxGetFontFromUser(wxWindow *parent, const wxFont& fontInit, const wxString& caption)
+{
+ wxFontData data;
+ if ( fontInit.IsOk() )
+ {
+ data.SetInitialFont(fontInit);
+ }
+
+ wxFont fontRet;
+ wxFontDialog dialog(parent, data);
+ if (!caption.empty())
+ dialog.SetTitle(caption);
+ if ( dialog.ShowModal() == wxID_OK )
+ {
+ fontRet = dialog.GetFontData().GetChosenFont();
+ }
+ //else: leave it invalid
+
+ return fontRet;
+}
+
+#endif // wxUSE_FONTDLG
+
+// ----------------------------------------------------------------------------
+// wxSafeYield and supporting functions
+// ----------------------------------------------------------------------------
+
+void wxEnableTopLevelWindows(bool enable)
+{
+ wxWindowList::compatibility_iterator node;
+ for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() )
+ node->GetData()->Enable(enable);
+}
+
+#if defined(__WXOSX__) && wxOSX_USE_COCOA
+
+// defined in evtloop.mm
+
+#else
+
+wxWindowDisabler::wxWindowDisabler(bool disable)
+{
+ m_disabled = disable;
+ if ( disable )
+ DoDisable();
+}
+
+wxWindowDisabler::wxWindowDisabler(wxWindow *winToSkip)
+{
+ m_disabled = true;
+ DoDisable(winToSkip);
+}
+
+void wxWindowDisabler::DoDisable(wxWindow *winToSkip)
+{
+ // remember the top level windows which were already disabled, so that we
+ // don't reenable them later
+ m_winDisabled = NULL;
+
+ wxWindowList::compatibility_iterator node;
+ for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() )
+ {
+ wxWindow *winTop = node->GetData();
+ if ( winTop == winToSkip )
+ continue;
+
+ // we don't need to disable the hidden or already disabled windows
+ if ( winTop->IsEnabled() && winTop->IsShown() )
+ {
+ winTop->Disable();
+ }
+ else
+ {
+ if ( !m_winDisabled )
+ {
+ m_winDisabled = new wxWindowList;
+ }
+
+ m_winDisabled->Append(winTop);
+ }
+ }
+}
+
+wxWindowDisabler::~wxWindowDisabler()
+{
+ if ( !m_disabled )
+ return;
+
+ wxWindowList::compatibility_iterator node;
+ for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() )
+ {
+ wxWindow *winTop = node->GetData();
+ if ( !m_winDisabled || !m_winDisabled->Find(winTop) )
+ {
+ winTop->Enable();
+ }
+ //else: had been already disabled, don't reenable
+ }
+
+ delete m_winDisabled;
+}
+
+#endif
+
+// Yield to other apps/messages and disable user input to all windows except
+// the given one
+bool wxSafeYield(wxWindow *win, bool onlyIfNeeded)
+{
+ wxWindowDisabler wd(win);
+
+ bool rc;
+ if (onlyIfNeeded)
+ rc = wxYieldIfNeeded();