X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/479cd5de40ca8029c79e780170fa7c0af7ec0297..bcaa23de098c1276b3f35716c9ea8b73cf3599bd:/src/common/utilscmn.cpp diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index ec09523cc7..fbcad04649 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -59,6 +59,10 @@ #endif #endif +#if wxUSE_GUI + #include "wx/colordlg.h" +#endif // wxUSE_GUI + #include #ifndef __MWERKS__ @@ -880,14 +884,58 @@ wxString wxGetTextFromUser(const wxString& message, const wxString& caption, const wxString& defaultValue, wxWindow *parent, int x, int y, bool WXUNUSED(centre) ) { + wxString str; wxTextEntryDialog dialog(parent, message, caption, defaultValue, wxOK|wxCANCEL, wxPoint(x, y)); if (dialog.ShowModal() == wxID_OK) - return dialog.GetValue(); - else - return wxString(""); + { + str = dialog.GetValue(); + } + + return str; +} + +wxString wxGetPasswordFromUser(const wxString& message, + const wxString& caption, + const wxString& defaultValue, + wxWindow *parent) +{ + wxString str; + wxTextEntryDialog dialog(parent, message, caption, defaultValue, + wxOK | wxCANCEL | wxTE_PASSWORD); + if ( dialog.ShowModal() == wxID_OK ) + { + str = dialog.GetValue(); + } + + return str; } + #endif // wxUSE_TEXTDLG +wxColour wxGetColourFromUser(wxWindow *parent, const wxColour& colInit) +{ + wxColourData data; + data.SetChooseFull(TRUE); + if ( colInit.Ok() ) + { + data.SetColour((wxColour &)colInit); // const_cast + } + + wxColour colRet; + wxColourDialog dialog(parent, &data); + if ( dialog.ShowModal() == wxID_OK ) + { + colRet = dialog.GetColourData().GetColour(); + } + //else: leave it invalid + + return colRet; +} + +// ---------------------------------------------------------------------------- +// missing C RTL functions (FIXME shouldn't be here at all) +// ---------------------------------------------------------------------------- + #ifdef __MWERKS__ char *strdup(const char *s) { @@ -906,21 +954,58 @@ int isascii( int c ) void wxEnableTopLevelWindows(bool enable) { - wxWindowList::Node *node; - for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() ) - node->GetData()->Enable(enable); + wxWindowList::Node *node; + for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() ) + node->GetData()->Enable(enable); } -// Yield to other apps/messages and disable user input +static void wxFindDisabledWindows(wxWindowList& winDisabled, wxWindow *win) +{ + wxWindowList::Node *node; + for ( node = win->GetChildren().GetFirst(); node; node = node->GetNext() ) + { + wxWindow *child = node->GetData(); + if ( child->IsEnabled() ) + { + winDisabled.Append(child); + } + + wxFindDisabledWindows(winDisabled, child); + } +} + +// Yield to other apps/messages and disable user input to all windows except +// the given one bool wxSafeYield(wxWindow *win) { - wxEnableTopLevelWindows(FALSE); - // always enable ourselves - if ( win ) - win->Enable(TRUE); - bool rc = wxYield(); - wxEnableTopLevelWindows(TRUE); - return rc; + // remember all windows we're going to (temporarily) disable + wxWindowList winDisabled; + + wxWindowList::Node *node; + for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() ) + { + wxWindow *winTop = node->GetData(); + wxFindDisabledWindows(winDisabled, winTop); + + winTop->Disable(); + } + + if ( win ) + { + // always enable ourselves + win->Enable(); + } + + bool rc = wxYield(); + + // don't call wxEnableTopLevelWindows(TRUE) because this will reenable even + // the window which had been disabled before, do it manually instead + for ( node = winDisabled.GetFirst(); node; node = node->GetNext() ) + { + node->GetData()->Enable(); + } + + return rc; } // Don't synthesize KeyUp events holding down a key and producing KeyDown @@ -929,7 +1014,7 @@ bool wxSafeYield(wxWindow *win) #ifndef __WXGTK__ bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag) ) { - return TRUE; // detectable auto-repeat is the only mode MSW supports + return TRUE; // detectable auto-repeat is the only mode MSW supports } #endif // !wxGTK