X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e508a2b616e077bf6c9b668b9f8034e1fbd59c4f..98672b4b9cb156c624a66efd5b3c1935a1d37de9:/wxPython/src/utils.i diff --git a/wxPython/src/utils.i b/wxPython/src/utils.i index 100f7a1160..67821cbaba 100644 --- a/wxPython/src/utils.i +++ b/wxPython/src/utils.i @@ -34,13 +34,15 @@ //--------------------------------------------------------------------------- %{ - static wxString wxPyEmptyStr(""); - static PyObject* __EnumerationHelper(bool flag, wxString& str, long index) { PyObject* ret = PyTuple_New(3); if (ret) { PyTuple_SET_ITEM(ret, 0, PyInt_FromLong(flag)); - PyTuple_SET_ITEM(ret, 1, PyString_FromString(str)); +#if wxUSE_UNICODE + PyTuple_SET_ITEM(ret, 1, PyUnicode_FromUnicode(str.c_str(), str.Len())); +#else + PyTuple_SET_ITEM(ret, 1, PyString_FromStringAndSize(str.c_str(), str.Len())); +#endif PyTuple_SET_ITEM(ret, 2, PyInt_FromLong(index)); } return ret; @@ -60,10 +62,10 @@ enum class wxConfigBase { public: -// wxConfigBase(const wxString& appName = wxPyEmptyStr, **** An ABC -// const wxString& vendorName = wxPyEmptyStr, -// const wxString& localFilename = wxPyEmptyStr, -// const wxString& globalFilename = wxPyEmptyStr, +// wxConfigBase(const wxString& appName = wxEmptyString, **** An ABC +// const wxString& vendorName = wxEmptyString, +// const wxString& localFilename = wxEmptyString, +// const wxString& globalFilename = wxEmptyString, // long style = 0); ~wxConfigBase(); @@ -148,9 +150,25 @@ public: bool IsExpandingEnvVars(); bool IsRecordingDefaults(); - wxString Read(const wxString& key, const wxString& defaultVal = wxPyEmptyStr); - %name(ReadInt)long Read(const wxString& key, long defaultVal = 0); - %name(ReadFloat)double Read(const wxString& key, double defaultVal = 0.0); + wxString Read(const wxString& key, const wxString& defaultVal = wxEmptyString); + + %addmethods { + long ReadInt(const wxString& key, long defaultVal = 0) { + long rv; + self->Read(key, &rv, defaultVal); + return rv; + } + double ReadFloat(const wxString& key, double defaultVal = 0.0) { + double rv; + self->Read(key, &rv, defaultVal); + return rv; + } + bool ReadBool(const wxString& key, bool defaultVal = FALSE) { + bool rv; + self->Read(key, &rv, defaultVal); + return rv; + } + } void SetExpandEnvVars (bool bDoIt = TRUE); void SetPath(const wxString& strPath); @@ -164,6 +182,7 @@ public: bool Write(const wxString& key, const wxString& value); %name(WriteInt)bool Write(const wxString& key, long value); %name(WriteFloat)bool Write(const wxString& key, double value); + %name(WriteBool)bool Write(const wxString& key, bool value); EntryType GetEntryType(const wxString& name); bool RenameEntry(const wxString& oldName, @@ -175,24 +194,28 @@ public: }; + //--------------------------------------------------------------------------- +// This will be a wxRegConfig on Win32 and wxFileConfig otherwise. class wxConfig : public wxConfigBase { public: - wxConfig(const wxString& appName = wxPyEmptyStr, - const wxString& vendorName = wxPyEmptyStr, - const wxString& localFilename = wxPyEmptyStr, - const wxString& globalFilename = wxPyEmptyStr, + wxConfig(const wxString& appName = wxEmptyString, + const wxString& vendorName = wxEmptyString, + const wxString& localFilename = wxEmptyString, + const wxString& globalFilename = wxEmptyString, long style = 0); ~wxConfig(); }; + +// Sometimes it's nice to explicitly have a wxFileConfig too. class wxFileConfig : public wxConfigBase { public: - wxFileConfig(const wxString& appName = wxPyEmptyStr, - const wxString& vendorName = wxPyEmptyStr, - const wxString& localFilename = wxPyEmptyStr, - const wxString& globalFilename = wxPyEmptyStr, + wxFileConfig(const wxString& appName = wxEmptyString, + const wxString& vendorName = wxEmptyString, + const wxString& localFilename = wxEmptyString, + const wxString& globalFilename = wxEmptyString, long style = 0); ~wxFileConfig(); }; @@ -516,10 +539,10 @@ public: int n = 1, Month month = Inv_Month, int year = Inv_Year); - wxDateTime GetWeekDay(WeekDay weekday, - int n = 1, - Month month = Inv_Month, - int year = Inv_Year); +// wxDateTime GetWeekDay(WeekDay weekday, +// int n = 1, +// Month month = Inv_Month, +// int year = Inv_Year); // sets to the last weekday in the given month, year bool SetToLastWeekDay(WeekDay weekday, @@ -748,32 +771,32 @@ public: // parse a string in RFC 822 format (found e.g. in mail headers and // having the form "Wed, 10 Feb 1999 19:07:07 +0100") - const char *ParseRfc822Date(const char* date); + const char *ParseRfc822Date(const wxChar* date); // parse a date/time in the given format (see strptime(3)), fill in // the missing (in the string) fields with the values of dateDef (by // default, they will not change if they had valid values or will // default to Today() otherwise) - const char *ParseFormat(const char *date, - const char *format = "%c", + const char *ParseFormat(const wxChar *date, + const wxChar *format = "%c", const wxDateTime& dateDef = wxDefaultDateTime); // parse a string containing the date/time in "free" format, this // function will try to make an educated guess at the string contents - const char *ParseDateTime(const char *datetime); + const char *ParseDateTime(const wxChar *datetime); // parse a string containing the date only in "free" format (less // flexible than ParseDateTime) - const char *ParseDate(const char *date); + const char *ParseDate(const wxChar *date); // parse a string containing the time only in "free" format - const char *ParseTime(const char *time); + const char *ParseTime(const wxChar *time); // this function accepts strftime()-like format string (default // argument corresponds to the preferred date and time representation // for the current locale) and returns the string containing the // resulting text representation - wxString Format(const char *format = "%c", + wxString Format(const wxChar *format = "%c", const wxDateTime::TimeZone& tz = LOCAL) const; // preferred date representation for the current locale @@ -923,7 +946,7 @@ public: // resulting text representation. Notice that only some of format // specifiers valid for wxDateTime are valid for wxTimeSpan: hours, // minutes and seconds make sense, but not "PM/AM" string for example. - wxString Format(const char *format = "%c") const; + wxString Format(const wxChar *format = "%c") const; // // preferred date representation for the current locale // wxString FormatDate() const;