X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ed12f1dd6d40be5dcbd61140d63eec435f88e096..88594d02eb59a55ac85d3210a49d02918124617b:/src/common/utilscmn.cpp?ds=sidebyside diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 1867cc1d44..a5e42a0eb1 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -36,6 +36,7 @@ #include "wx/log.h" #if wxUSE_GUI + #include "wx/app.h" #include "wx/window.h" #include "wx/frame.h" #include "wx/menu.h" @@ -105,7 +106,7 @@ // string functions // ---------------------------------------------------------------------------- -#if defined(__WXMAC__) && !defined(__DARWIN) +#if defined(__WXMAC__) && !defined(__DARWIN__) int strcasecmp(const char *str_1, const char *str_2) { register char c1, c2; @@ -216,6 +217,11 @@ extern "C" #define strncasecmp strnicmp #endif +#ifdef __WATCOMC__ +#define strcasecmp stricmp +#define strncasecmp strnicmp +#endif + wxChar * copystring (const wxChar *s) { @@ -248,14 +254,14 @@ wxRegisterId (long id) } void -StringToFloat (wxChar *s, float *number) +StringToFloat (const wxChar *s, float *number) { if (s && *s && number) *number = (float) wxStrtod (s, (wxChar **) NULL); } void -StringToDouble (wxChar *s, double *number) +StringToDouble (const wxChar *s, double *number) { if (s && *s && number) *number = wxStrtod (s, (wxChar **) NULL); @@ -280,14 +286,14 @@ DoubleToString (double number, const wxChar *fmt) } void -StringToInt (wxChar *s, int *number) +StringToInt (const wxChar *s, int *number) { if (s && *s && number) *number = (int) wxStrtol (s, (wxChar **) NULL, 10); } void -StringToLong (wxChar *s, long *number) +StringToLong (const wxChar *s, long *number) { if (s && *s && number) *number = wxStrtol (s, (wxChar **) NULL, 10); @@ -352,7 +358,7 @@ wxString wxDecToHex(int dec) // Match a string INDEPENDENT OF CASE bool -StringMatch (char *str1, char *str2, bool subString, bool exact) +StringMatch (const char *str1, const char *str2, bool subString, bool exact) { if (str1 == NULL || str2 == NULL) return FALSE; @@ -408,7 +414,7 @@ wxString wxNow() // Menu accelerators related functions // ---------------------------------------------------------------------------- -wxChar *wxStripMenuCodes(wxChar *in, wxChar *out) +wxChar *wxStripMenuCodes(const wxChar *in, wxChar *out) { wxString s = wxMenuItem::GetLabelFromText(in); if ( out ) @@ -605,6 +611,7 @@ wxWindow* wxFindWindowAtPoint(wxWindow* win, const wxPoint& pt) // Hack for wxNotebook case: at least in wxGTK, all pages // claim to be shown, so we must only deal with the selected one. +#if wxUSE_NOTEBOOK if (win->IsKindOf(CLASSINFO(wxNotebook))) { wxNotebook* nb = (wxNotebook*) win; @@ -617,6 +624,8 @@ wxWindow* wxFindWindowAtPoint(wxWindow* win, const wxPoint& pt) return foundWin; } } +#endif + /* Doesn't work // Frame case else if (win->IsKindOf(CLASSINFO(wxFrame))) @@ -738,7 +747,7 @@ whereami(name) t = imagedir; if (!absolute_pathname(name)) { -#if defined(DOS) || defined(__WIN32__) +#if defined(__DOS__) || defined(__WIN32__) int drive; char *newrbuf; @@ -1086,6 +1095,18 @@ const wxChar *wxGetInstallPrefix() #endif } +wxString wxGetDataDir() +{ + wxString format = wxGetInstallPrefix(); + format << wxFILE_SEP_PATH + << wxT("share") << wxFILE_SEP_PATH + << wxT("wx") << wxFILE_SEP_PATH + << wxT("%i.%i"); + wxString dir; + dir.Printf(format.c_str(), wxMAJOR_VERSION, wxMINOR_VERSION); + return dir; +} + // ---------------------------------------------------------------------------- // network and user id functions @@ -1312,4 +1333,25 @@ long wxExecute(const wxString& command, return wxDoExecuteWithCapture(command, output, &error); } +// ---------------------------------------------------------------------------- +// wxApp::Yield() wrappers for backwards compatibility +// ---------------------------------------------------------------------------- + +bool wxYield() +{ +#if wxUSE_GUI + return wxTheApp && wxTheApp->Yield(); +#else + return FALSE; +#endif +} + +bool wxYieldIfNeeded() +{ +#if wxUSE_GUI + return wxTheApp && wxTheApp->Yield(TRUE); +#else + return FALSE; +#endif +}