X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c67d6888d421207045dc6ce9c9762727118c92e2..109c7768eb46ccbb45adc1c409fe8f6b7d799e2f:/src/common/utilscmn.cpp diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 517850d992..05e1c3f123 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -68,10 +68,10 @@ #if wxUSE_GUI #include "wx/colordlg.h" + #include "wx/fontdlg.h" #include "wx/notebook.h" #include "wx/frame.h" #include "wx/statusbr.h" - #include "wx/toolbar.h" #endif // wxUSE_GUI #include @@ -90,13 +90,17 @@ #endif // ---------------------------------------------------------------------------- -// function protoypes +// common data // ---------------------------------------------------------------------------- -#if wxUSE_GUI - static wxWindow *wxFindWindowByLabel1(const wxString& title, wxWindow *parent); - static wxWindow *wxFindWindowByName1 (const wxString& title, wxWindow *parent); -#endif // wxUSE_GUI +#if WXWIN_COMPATIBILITY_2_2 + const wxChar *wxInternalErrorStr = wxT("wxWindows Internal Error"); + const wxChar *wxFatalErrorStr = wxT("wxWindows Fatal Error"); +#endif // WXWIN_COMPATIBILITY_2_2 + +// ---------------------------------------------------------------------------- +// function protoypes +// ---------------------------------------------------------------------------- // ============================================================================ // implementation @@ -217,6 +221,11 @@ extern "C" #define strncasecmp strnicmp #endif +#ifdef __WATCOMC__ +#define strcasecmp stricmp +#define strncasecmp strnicmp +#endif + wxChar * copystring (const wxChar *s) { @@ -477,52 +486,9 @@ wxString wxStripMenuCodes(const wxString& in) wxWindow * wxFindWindowByLabel (const wxString& title, wxWindow * parent) { - if (parent) - { - return wxFindWindowByLabel1(title, parent); - } - else - { - for ( wxWindowList::Node * node = wxTopLevelWindows.GetFirst(); - node; - node = node->GetNext() ) - { - wxWindow *win = node->GetData(); - wxWindow *retwin = wxFindWindowByLabel1 (title, win); - if (retwin) - return retwin; - } // for() - - } - return (wxWindow *) NULL; + return wxWindow::FindWindowByLabel( title, parent ); } -// Recursive -static wxWindow * -wxFindWindowByLabel1 (const wxString& title, wxWindow * parent) -{ - if (parent) - { - if (parent->GetLabel() == title) - return parent; - } - - if (parent) - { - for ( wxWindowList::Node * node = parent->GetChildren().GetFirst(); - node; - node = node->GetNext() ) - { - wxWindow *win = (wxWindow *)node->GetData(); - wxWindow *retwin = wxFindWindowByLabel1 (title, win); - if (retwin) - return retwin; - } - - } - - return (wxWindow *) NULL; // Not found -} /* * If parent is non-NULL, look through children for a name @@ -531,54 +497,9 @@ wxFindWindowByLabel1 (const wxString& title, wxWindow * parent) */ wxWindow * -wxFindWindowByName (const wxString& title, wxWindow * parent) -{ - if (parent) - { - return wxFindWindowByName1 (title, parent); - } - else - { - for ( wxWindowList::Node * node = wxTopLevelWindows.GetFirst(); - node; - node = node->GetNext() ) - { - wxWindow *win = node->GetData(); - wxWindow *retwin = wxFindWindowByName1 (title, win); - if (retwin) - return retwin; - } - - } - - // Failed? Try by label instead. - return wxFindWindowByLabel(title, parent); -} - -// Recursive -static wxWindow * -wxFindWindowByName1 (const wxString& title, wxWindow * parent) +wxFindWindowByName (const wxString& name, wxWindow * parent) { - if (parent) - { - if ( parent->GetName() == title ) - return parent; - } - - if (parent) - { - for (wxNode * node = parent->GetChildren().First (); node; node = node->Next ()) - { - wxWindow *win = (wxWindow *) node->Data (); - wxWindow *retwin = wxFindWindowByName1 (title, win); - if (retwin) - return retwin; - } // for() - - } - - return (wxWindow *) NULL; // Not found - + return wxWindow::FindWindowByName( name, parent ); } // Returns menu item id or -1 if none. @@ -742,7 +663,7 @@ whereami(name) t = imagedir; if (!absolute_pathname(name)) { -#if defined(DOS) || defined(__WIN32__) +#if defined(__DOS__) || defined(__WIN32__) int drive; char *newrbuf; @@ -957,36 +878,59 @@ wxString wxGetPasswordFromUser(const wxString& message, wxColour wxGetColourFromUser(wxWindow *parent, const wxColour& colInit) { - wxColourData data; - data.SetChooseFull(TRUE); - if ( colInit.Ok() ) - { - data.SetColour((wxColour &)colInit); // const_cast - } + 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 + wxColour colRet; + wxColourDialog dialog(parent, &data); + if ( dialog.ShowModal() == wxID_OK ) + { + colRet = dialog.GetColourData().GetColour(); + } + //else: leave it invalid - return colRet; + return colRet; } #endif // wxUSE_COLOURDLG +#if wxUSE_FONTDLG + +wxFont wxGetFontFromUser(wxWindow *parent, const wxFont& fontInit) +{ + wxFontData data; + if ( fontInit.Ok() ) + { + data.SetInitialFont(fontInit); + } + + wxFont fontRet; + wxFontDialog dialog(parent, data); + if ( dialog.ShowModal() == wxID_OK ) + { + fontRet = dialog.GetFontData().GetChosenFont(); + } + //else: leave it invalid + + return fontRet; +} + +#endif // wxUSE_FONTDLG // ---------------------------------------------------------------------------- // missing C RTL functions (FIXME shouldn't be here at all) // ---------------------------------------------------------------------------- #ifdef __MWERKS__ +#if __MSL__ < 0x7000 char *strdup(const char *s) { return strcpy( (char*) malloc( strlen( s ) + 1 ) , s ) ; } - +#endif int isascii( int c ) { return ( c >= 0 && c < 128 ) ; @@ -1080,7 +1024,7 @@ const wxChar *wxGetInstallPrefix() { wxString prefix; - if ( wxGetEnv(wxT("WX_PREFIX"), &prefix) ) + if ( wxGetEnv(wxT("WXPREFIX"), &prefix) ) return prefix.c_str(); #ifdef wxINSTALL_PREFIX @@ -1257,7 +1201,7 @@ static long wxDoExecuteWithCapture(const wxString& command, wxProcess *process = new wxProcess; process->Redirect(); - long rc = wxExecute(command, TRUE /* sync */, process); + long rc = wxExecute(command, wxEXEC_SYNC, process); #if wxUSE_STREAMS if ( rc != -1 )