%{
#include "helpers.h"
+#include "pyistream.h"
#include <wx/resource.h>
#include <wx/tooltip.h>
#include <wx/caret.h>
%import streams.i
%import utils.i
-%{
- static wxString wxPyEmptyStr("");
-%}
//---------------------------------------------------------------------------
// Dialog Functions
-wxString wxFileSelector(char* message,
- char* default_path = NULL,
- char* default_filename = NULL,
- char* default_extension = NULL,
- char* wildcard = "*.*",
+wxString wxFileSelector(const wxChar* message = wxFileSelectorPromptStr,
+ const wxChar* default_path = NULL,
+ const wxChar* default_filename = NULL,
+ const wxChar* default_extension = NULL,
+ const wxChar* wildcard = wxFileSelectorDefaultWildcardStr,
int flags = 0,
wxWindow *parent = NULL,
int x = -1, int y = -1);
+// Ask for filename to load
+wxString wxLoadFileSelector(const wxChar *what,
+ const wxChar *extension,
+ const wxChar *default_name = NULL,
+ wxWindow *parent = NULL);
+
+// Ask for filename to save
+wxString wxSaveFileSelector(const wxChar *what,
+ const wxChar *extension,
+ const wxChar *default_name = NULL,
+ wxWindow *parent = NULL);
+
wxString wxGetTextFromUser(const wxString& message,
- const wxString& caption = wxPyEmptyStr,
- const wxString& default_value = wxPyEmptyStr,
+ const wxString& caption = wxEmptyString,
+ const wxString& default_value = wxEmptyString,
wxWindow *parent = NULL,
int x = -1, int y = -1,
bool centre = TRUE);
wxString wxGetPasswordFromUser(const wxString& message,
- const wxString& caption = wxPyEmptyStr,
- const wxString& default_value = wxPyEmptyStr,
+ const wxString& caption = wxEmptyString,
+ const wxString& default_value = wxEmptyString,
wxWindow *parent = NULL);
int wxMessageBox(const wxString& message,
- const wxString& caption = wxPyEmptyStr,
+ const wxString& caption = wxEmptyString,
int style = wxOK | wxCENTRE,
wxWindow *parent = NULL,
int x = -1, int y = -1);
static bool IsEnabled();
static bool EnableLogging(bool doIt = TRUE);
- static void OnLog(wxLogLevel level, const char *szString, int t=0);
+ static void OnLog(wxLogLevel level, const wxString& szString, int t=0);
virtual void Flush();
bool HasPendingMessages() const;
bool GetVerbose() const { return m_bVerbose; }
static wxTraceMask GetTraceMask();
- static bool IsAllowedTraceMask(const char *mask);
+ static bool IsAllowedTraceMask(const wxString& mask);
// static void TimeStamp(wxString *str);
%addmethods {
{
public:
wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
- const char *szTitle, // the title of the frame
+ const wxString& szTitle, // the title of the frame
bool bShow = TRUE, // show window immediately?
bool bPassToOld = TRUE); // pass log messages to the old target?
wxFrame *GetFrame() const;
wxLog *GetOldLog() const;
bool IsPassingMessages() const;
- void PassMessages(bool bDoPass) { m_bPassMessages = bDoPass; }
+ void PassMessages(bool bDoPass);
};
unsigned long wxSysErrorCode();
-const char* wxSysErrorMsg(unsigned long nErrCode = 0);
-void wxLogFatalError(const char *szFormat);
-void wxLogError(const char *szFormat);
-void wxLogWarning(const char *szFormat);
-void wxLogMessage(const char *szFormat);
-void wxLogInfo(const char *szFormat);
-void wxLogVerbose(const char *szFormat);
-void wxLogStatus(const char *szFormat);
-%name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const char *szFormat);
-void wxLogSysError(const char *szFormat);
+const wxString wxSysErrorMsg(unsigned long nErrCode = 0);
+void wxLogFatalError(const wxString& szFormat);
+void wxLogError(const wxString& szFormat);
+void wxLogWarning(const wxString& szFormat);
+void wxLogMessage(const wxString& szFormat);
+void wxLogInfo(const wxString& szFormat);
+void wxLogVerbose(const wxString& szFormat);
+void wxLogStatus(const wxString& szFormat);
+%name(wxLogStatusFrame)void wxLogStatus(wxFrame *pFrame, const wxString& szFormat);
+void wxLogSysError(const wxString& szFormat);
%{
bool found;
wxPyBeginBlockThreads();
if ((found = wxPyCBH_findCallback(m_myInst, "DoLog")))
- wxPyCBH_callCallback(m_myInst, Py_BuildValue("(isi)", level, szString, t));
+ wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iOi)", level,
+ wx2PyString(szString), t));
wxPyEndBlockThreads();
if (! found)
wxLog::DoLog(level, szString, t);
bool found;
wxPyBeginBlockThreads();
if ((found = wxPyCBH_findCallback(m_myInst, "DoLogString")))
- wxPyCBH_callCallback(m_myInst, Py_BuildValue("(si)", szString, t));
+ wxPyCBH_callCallback(m_myInst, Py_BuildValue("(Oi)",
+ wx2PyString(szString), t));
wxPyEndBlockThreads();
if (! found)
wxLog::DoLogString(szString, t);
{
public:
// ctors
- MessageParameters(const wxString& filename=wxPyEmptyStr,
- const wxString& mimetype=wxPyEmptyStr);
+ MessageParameters(const wxString& filename=wxEmptyString,
+ const wxString& mimetype=wxEmptyString);
// accessors (called by GetOpenCommand)
// filename
%addmethods {
PyObject* GetMimeType() {
wxString str;
- if (self->GetMimeType(&str))
- return PyString_FromString(str.c_str());
+ if (self->GetMimeType(&str)) {
+#if wxUSE_UNICODE
+ return PyUnicode_FromUnicode(str.c_str(), str.Len());
+#else
+ return PyString_FromStringAndSize(str.c_str(), str.Len());
+#endif
+ }
else
RETURN_NONE();
}
PyObject* tuple = PyTuple_New(3);
PyTuple_SetItem(tuple, 0, wxPyConstructObject(new wxIcon(icon),
"wxIcon", TRUE));
- PyTuple_SetItem(tuple, 1, PyString_FromString(iconFile.c_str()));
+#if wxUSE_UNICODE
+ PyTuple_SetItem(tuple, 1, PyUnicode_FromUnicode(iconFile.c_str(), iconFile.Len()));
+#else
+ PyTuple_SetItem(tuple, 1, PyString_FromStringAndSize(iconFile.c_str(), iconFile.Len()));
+#endif
PyTuple_SetItem(tuple, 2, PyInt_FromLong(iconIndex));
wxPyEndBlockThreads();
return tuple;
// get a brief file type description ("*.txt" => "text document")
PyObject* GetDescription() {
wxString str;
- if (self->GetDescription(&str))
- return PyString_FromString(str.c_str());
- else
+ if (self->GetDescription(&str)) {
+#if wxUSE_UNICODE
+ return PyUnicode_FromUnicode(str.c_str(), str.Len());
+#else
+ return PyString_FromStringAndSize(str.c_str(), str.Len());
+#endif
+ } else
RETURN_NONE();
}
}
// get the command to open/execute the file of given type
%addmethods {
PyObject* GetOpenCommand(const wxString& filename,
- const wxString& mimetype=wxPyEmptyStr) {
+ const wxString& mimetype=wxEmptyString) {
wxString str;
- if (self->GetOpenCommand(&str, wxFileType::MessageParameters(filename, mimetype)))
- return PyString_FromString(str.c_str());
- else
+ if (self->GetOpenCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
+#if wxUSE_UNICODE
+ return PyUnicode_FromUnicode(str.c_str(), str.Len());
+#else
+ return PyString_FromStringAndSize(str.c_str(), str.Len());
+#endif
+ } else
RETURN_NONE();
}
}
// get the command to print the file of given type
%addmethods {
PyObject* GetPrintCommand(const wxString& filename,
- const wxString& mimetype=wxPyEmptyStr) {
+ const wxString& mimetype=wxEmptyString) {
wxString str;
- if (self->GetPrintCommand(&str, wxFileType::MessageParameters(filename, mimetype)))
- return PyString_FromString(str.c_str());
- else
+ if (self->GetPrintCommand(&str, wxFileType::MessageParameters(filename, mimetype))) {
+#if wxUSE_UNICODE
+ return PyUnicode_FromUnicode(str.c_str(), str.Len());
+#else
+ return PyString_FromStringAndSize(str.c_str(), str.Len());
+#endif
+ } else
RETURN_NONE();
}
}
// Get all commands defined for this file type
%addmethods {
PyObject* GetAllCommands(const wxString& filename,
- const wxString& mimetype=wxPyEmptyStr) {
+ const wxString& mimetype=wxEmptyString) {
wxArrayString verbs;
wxArrayString commands;
if (self->GetAllCommands(&verbs, &commands,