//---------------------------------------------------------------------------
%newgroup
-enum wxLayoutDirection
-{
- wxLayout_Default,
- wxLayout_LeftToRight,
- wxLayout_RightToLeft
-};
-
-
enum wxLanguage
{
// user's default/preffered language as got from OS:
~wxLocale();
%extend {
- bool Init1(const wxString& szName,
- const wxString& szShort = wxPyEmptyString,
- const wxString& szLocale = wxPyEmptyString,
+ bool Init1(const wxString& name,
+ const wxString& shortName = wxPyEmptyString,
+ const wxString& locale = wxPyEmptyString,
bool bLoadDefault = true,
bool bConvertEncoding = false) {
- bool rc = self->Init(szName, szShort, szLocale, bLoadDefault, bConvertEncoding);
+ bool rc = self->Init(name, shortName, locale, bLoadDefault, bConvertEncoding);
// Python before 2.4 needs to have LC_NUMERIC set to "C" in order
// for the floating point conversions and such to work right.
%#if PY_VERSION_HEX < 0x02040000
// The loaded catalog will be used for message lookup by GetString().
//
// Returns 'True' if it was successfully loaded
- bool AddCatalog(const wxString& szDomain);
+ bool AddCatalog(const wxString& domain);
// check if the given locale is provided by OS and C run time
static bool IsAvailable(int lang);
// check if the given catalog is loaded
- bool IsLoaded(const wxString& szDomain) const;
+ bool IsLoaded(const wxString& domain) const;
// Retrieve the language info struct for the given language
//
//
// domains are searched in the last to first order, i.e. catalogs
// added later override those added before.
- wxString GetString(const wxString& szOrigString,
- const wxString& szDomain = wxPyEmptyString) const;
+ wxString GetString(const wxString& origString,
+ const wxString& domain = wxPyEmptyString) const;
// Returns the current short name for the locale
const wxString& GetName() const;
public:
wxPyLocale();
- wxPyLocale(const wxChar *szName, // name (for messages)
- const wxChar *szShort = (const wxChar *) NULL, // dir prefix (for msg files)
- const wxChar *szLocale = (const wxChar *) NULL, // locale (for setlocale)
- bool bLoadDefault = true, // preload wxstd.mo?
- bool bConvertEncoding = false); // convert Win<->Unix if necessary?
+ wxPyLocale(const wxString& name, // name (for messages)
+ const wxString& shortName = wxPyEmptyString, // dir prefix (for msg files)
+ const wxString& locale = wxPyEmptyString, // locale (for setlocale)
+ bool bLoadDefault = true, // preload wxstd.mo?
+ bool bConvertEncoding = false); // convert Win<->Unix if necessary?
wxPyLocale(int language, // wxLanguage id or custom language
- int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
+ int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
~wxPyLocale();
- virtual const wxChar *GetString(const wxChar *szOrigString,
- const wxChar *szDomain = NULL) const;
- virtual const wxChar *GetString(const wxChar *szOrigString,
- const wxChar *szOrigString2, size_t n,
- const wxChar *szDomain = NULL) const;
-
- virtual wxChar *GetSingularString(const wxChar *szOrigString,
- const wxChar *szDomain = NULL) const;
- virtual wxChar *GetPluralString(const wxChar *szOrigString,
- const wxChar *szOrigString2, size_t n,
- const wxChar *szDomain = NULL) const;
+ virtual const wxString& GetString(const wxString& origString,
+ const wxString& domain = wxPyEmptyString) const;
+ virtual const wxString& GetString(const wxString& origString,
+ const wxString& origString2,
+ size_t n,
+ const wxString& domain = wxPyEmptyString) const;
+
+ virtual const wxString& GetSingularString(const wxString& origString,
+ const wxString& domain = wxPyEmptyString) const;
+ virtual const wxString& GetPluralString(const wxString& origString,
+ const wxString& origString2,
+ size_t n,
+ const wxString& domain = wxPyEmptyString) const;
+
PYPRIVATE;
private:
{
}
-wxPyLocale::wxPyLocale(const wxChar *szName, // name (for messages)
- const wxChar *szShort, // dir prefix (for msg files)
- const wxChar *szLocale, // locale (for setlocale)
- bool bLoadDefault, // preload wxstd.mo?
- bool bConvertEncoding) // convert Win<->Unix if necessary?
- : wxLocale(szName, szShort, szLocale, bLoadDefault, bConvertEncoding)
+wxPyLocale::wxPyLocale(const wxString& name, // name (for messages)
+ const wxString& shortName, // dir prefix (for msg files)
+ const wxString& locale, // locale (for setlocale)
+ bool bLoadDefault, // preload wxstd.mo?
+ bool bConvertEncoding) // convert Win<->Unix if necessary?
+ : wxLocale(name, shortName, locale, bLoadDefault, bConvertEncoding)
{
}
{
}
-const wxChar *wxPyLocale::GetString(const wxChar *szOrigString,
- const wxChar *szDomain) const
+const wxString& wxPyLocale::GetString(const wxString& origString,
+ const wxString& domain) const
{
- wxChar *str = GetSingularString(szOrigString, szDomain);
- return (str != NULL) ? str : wxLocale::GetString(szOrigString, szDomain);
+ return GetSingularString(origString, domain);
}
-const wxChar *wxPyLocale::GetString(const wxChar *szOrigString,
- const wxChar *szOrigString2, size_t n,
- const wxChar *szDomain) const
+const wxString& wxPyLocale::GetString(const wxString& origString,
+ const wxString& origString2,
+ size_t n,
+ const wxString& domain) const
{
- wxChar *str = GetPluralString(szOrigString, szOrigString2, n, szDomain);
- return (str != NULL) ? str : wxLocale::GetString(szOrigString, szOrigString2, n, szDomain);
+ return GetPluralString(origString, origString2, n, domain);
}
-wxChar *wxPyLocale::GetSingularString(const wxChar *szOrigString,
- const wxChar *szDomain) const
+const wxString& wxPyLocale::GetSingularString(const wxString& origString,
+ const wxString& domain) const
{
bool found;
- static wxString str;
- str = _T("error in translation"); // when the first if condition is true but the second if condition is not we do not want to return the previously queried string.
+ wxString str( _T("error in translation"));
wxPyBlock_t blocked = wxPyBeginBlockThreads();
- if((found=wxPyCBH_findCallback(m_myInst, "GetSingularString"))) {
- PyObject* param1 = wx2PyString(szOrigString);
- PyObject* param2 = wx2PyString(szDomain);
+ if ((found=wxPyCBH_findCallback(m_myInst, "GetSingularString"))) {
+ PyObject* param1 = wx2PyString(origString);
+ PyObject* param2 = wx2PyString(domain);
PyObject* ret = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", param1, param2));
Py_DECREF(param1);
Py_DECREF(param2);
}
}
wxPyEndBlockThreads(blocked);
- return (found ? (wxChar*)str.c_str() : NULL);
+ return (found ? str : wxLocale::GetString(origString, domain));
}
-wxChar *wxPyLocale::GetPluralString(const wxChar *szOrigString,
- const wxChar *szOrigString2, size_t n,
- const wxChar *szDomain) const
+const wxString& wxPyLocale::GetPluralString(const wxString& origString,
+ const wxString& origString2, size_t n,
+ const wxString& domain) const
{
bool found;
- static wxString str;
- str = _T("error in translation"); // when the first if condition is true but the second if condition is not we do not want to return the previously queried string.
+ wxString str( _T("error in translation"));
wxPyBlock_t blocked = wxPyBeginBlockThreads();
- if((found=wxPyCBH_findCallback(m_myInst, "GetPluralString"))) {
- PyObject* param1 = wx2PyString(szOrigString);
- PyObject* param2 = wx2PyString(szOrigString2);
- PyObject* param4 = wx2PyString(szDomain);
- PyObject* ret = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOiO)", param1, param2, (int)n, param4));
+ if ((found=wxPyCBH_findCallback(m_myInst, "GetPluralString"))) {
+ PyObject* param1 = wx2PyString(origString);
+ PyObject* param2 = wx2PyString(origString2);
+ PyObject* param4 = wx2PyString(domain);
+ PyObject* ret = wxPyCBH_callCallbackObj(m_myInst,
+ Py_BuildValue("(OOiO)",
+ param1, param2,
+ (int)n, param4));
Py_DECREF(param1);
Py_DECREF(param2);
Py_DECREF(param4);
}
}
wxPyEndBlockThreads(blocked);
- return (found ? (wxChar*)str.c_str() : NULL);
+ return (found ? str : wxLocale::GetString(origString, origString2, n, domain) );
}
%}
class wxPyLocale : public wxLocale
{
public:
- %pythonAppend wxPyLocale "self._setCallbackInfo(self, PyLocale)"
+ %pythonAppend wxPyLocale setCallbackInfo(PyLocale)
// ctor & dtor
// -----------
void _setCallbackInfo(PyObject* self, PyObject* _class);
- virtual const wxChar *GetSingularString(const wxChar *szOrigString,
- const wxChar *szDomain = NULL) const;
- virtual const wxChar *GetPluralString(const wxChar *szOrigString,
- const wxChar *szOrigString2, size_t n,
- const wxChar *szDomain = NULL) const;
+ virtual const wxString& GetSingularString(const wxString& origString,
+ const wxString& domain = wxPyEmptyString) const;
+ virtual const wxString& GetPluralString(const wxString& origString,
+ const wxString& origString2, size_t n,
+ const wxString& domain = wxPyEmptyString) const;
};
//---------------------------------------------------------------------------