📄 wxpython_int.h
字号:
~wxPyCallbackHelper() {
#ifdef wxPyUSE_EXPORTED_API
wxPyGetCoreAPIPtr()->p_wxPyCBH_delete(this);
#else
wxPyCBH_delete(this);
#endif
}
void setSelf(PyObject* self, PyObject* klass, int incref=true);
bool findCallback(const char* name, bool setGuard=true) const;
int callCallback(PyObject* argTuple) const;
PyObject* callCallbackObj(PyObject* argTuple) const;
PyObject* GetLastFound() const { return m_lastFound; }
void setRecursionGuard(PyObject* method) const;
void clearRecursionGuard(PyObject* method) const;
private:
PyObject* m_self;
PyObject* m_class;
PyObject* m_lastFound;
int m_incRef;
friend void wxPyCBH_delete(wxPyCallbackHelper* cbh);
};
void wxPyCBH_setCallbackInfo(wxPyCallbackHelper& cbh, PyObject* self, PyObject* klass, int incref);
bool wxPyCBH_findCallback(const wxPyCallbackHelper& cbh, const char* name, bool setGuard=true);
int wxPyCBH_callCallback(const wxPyCallbackHelper& cbh, PyObject* argTuple);
PyObject* wxPyCBH_callCallbackObj(const wxPyCallbackHelper& cbh, PyObject* argTuple);
void wxPyCBH_delete(wxPyCallbackHelper* cbh);
//---------------------------------------------------------------------------
// This is used in C++ classes that need to be able to make callback to
// "overloaded" python methods
#define PYPRIVATE \
void _setCallbackInfo(PyObject* self, PyObject* _class, int incref=1) { \
wxPyCBH_setCallbackInfo(m_myInst, self, _class, incref); \
} \
private: wxPyCallbackHelper m_myInst
//---------------------------------------------------------------------------
// The wxPythonApp class
enum {
wxPYAPP_ASSERT_SUPPRESS = 1,
wxPYAPP_ASSERT_EXCEPTION = 2,
wxPYAPP_ASSERT_DIALOG = 4,
wxPYAPP_ASSERT_LOG = 8
};
class wxPyApp: public wxApp
{
DECLARE_ABSTRACT_CLASS(wxPyApp)
public:
wxPyApp();
~wxPyApp();
bool OnInit();
int MainLoop();
int GetAssertMode() { return m_assertMode; }
void SetAssertMode(int mode) { m_assertMode = mode; }
virtual bool OnInitGui();
virtual int OnExit();
#ifdef __WXDEBUG__
virtual void OnAssertFailure(const wxChar *file,
int line,
const wxChar *func,
const wxChar *cond,
const wxChar *msg);
#endif
virtual void ExitMainLoop();
// virtual int FilterEvent(wxEvent& event); // This one too????
// For catching Apple Events
virtual void MacOpenFile(const wxString &fileName);
virtual void MacPrintFile(const wxString &fileName);
virtual void MacNewFile();
virtual void MacReopenApp();
static bool GetMacSupportPCMenuShortcuts();
static long GetMacAboutMenuItemId();
static long GetMacPreferencesMenuItemId();
static long GetMacExitMenuItemId();
static wxString GetMacHelpMenuTitleName();
static void SetMacSupportPCMenuShortcuts(bool val);
static void SetMacAboutMenuItemId(long val);
static void SetMacPreferencesMenuItemId(long val);
static void SetMacExitMenuItemId(long val);
static void SetMacHelpMenuTitleName(const wxString& val);
void _BootstrapApp();
// implementation only
void SetStartupComplete(bool val) { m_startupComplete = val; };
PYPRIVATE;
int m_assertMode;
bool m_startupComplete;
};
extern wxPyApp *wxPythonApp;
//----------------------------------------------------------------------
// These macros are used to implement the virtual methods that should
// redirect to a Python method if one exists. The names designate the
// return type, if any, as well as any parameter types.
//---------------------------------------------------------------------------
#define DEC_PYCALLBACK__(CBNAME) \
void CBNAME()
#define IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME() { \
bool found; \
wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("()")); \
wxPyEndBlockThreads(blocked); \
if (! found) \
PCLASS::CBNAME(); \
}
#define DEC_PYCALLBACK_VOID_(CBNAME) \
DEC_PYCALLBACK__(CBNAME)
#define IMP_PYCALLBACK_VOID_(CLASS, PCLASS, CBNAME) \
IMP_PYCALLBACK__(CLASS, PCLASS, CBNAME)
//---------------------------------------------------------------------------
#define DEC_PYCALLBACK_BOOL_INTINT(CBNAME) \
bool CBNAME(int a, int b)
#define IMP_PYCALLBACK_BOOL_INTINT(CLASS, PCLASS, CBNAME) \
bool CLASS::CBNAME(int a, int b) { \
bool rval=false, found; \
wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
wxPyEndBlockThreads(blocked); \
if (! found) \
rval = PCLASS::CBNAME(a,b); \
return rval; \
}
//---------------------------------------------------------------------------
#define DEC_PYCALLBACK_VOID_INTINT(CBNAME) \
void CBNAME(int a, int b)
#define IMP_PYCALLBACK_VOID_INTINT(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(int a, int b) { \
bool found; \
wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(ii)",a,b)); \
wxPyEndBlockThreads(blocked); \
if (! found) \
PCLASS::CBNAME(a,b); \
}
//---------------------------------------------------------------------------
#define DEC_PYCALLBACK_VOID_INT(CBNAME) \
void CBNAME(int a)
#define IMP_PYCALLBACK_VOID_INT(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(int a) { \
bool found; \
wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(i)",a)); \
wxPyEndBlockThreads(blocked); \
if (! found) \
PCLASS::CBNAME(a); \
}
//---------------------------------------------------------------------------
#define DEC_PYCALLBACK_VOID_INT4(CBNAME) \
void CBNAME(int a, int b, int c, int d)
#define IMP_PYCALLBACK_VOID_INT4(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(int a, int b, int c, int d) { \
bool found; \
wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiii)",a,b,c,d)); \
wxPyEndBlockThreads(blocked); \
if (! found) \
PCLASS::CBNAME(a,b,c,d); \
}
//---------------------------------------------------------------------------
#define DEC_PYCALLBACK_VOID_INT5(CBNAME) \
void CBNAME(int a, int b, int c, int d, int e)
#define IMP_PYCALLBACK_VOID_INT5(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(int a, int b, int c, int d, int e) { \
bool found; \
wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) \
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iiiii)",a,b,c,d,e)); \
wxPyEndBlockThreads(blocked); \
if (! found) \
PCLASS::CBNAME(a,b,c,d,e); \
}
//---------------------------------------------------------------------------
#define DEC_PYCALLBACK_VOID_INTPINTP_const(CBNAME) \
void CBNAME(int* a, int* b) const
#define IMP_PYCALLBACK_VOID_INTPINTP_const(CLASS, PCLASS, CBNAME) \
void CLASS::CBNAME(int* a, int* b) const { \
const char* errmsg = #CBNAME " should return a 2-tuple of integers."; \
bool found; \
wxPyBlock_t blocked = wxPyBeginBlockThreads(); \
if ((found = wxPyCBH_findCallback(m_myInst, #CBNAME))) { \
PyObject* ro; \
ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("()")); \
if (ro) { \
if (PySequence_Check(ro) && PyObject_Length(ro) == 2) { \
PyObject* o1 = PySequence_GetItem(ro, 0); \
PyObject* o2 = PySequence_GetItem(ro, 1); \
if (PyNumber_Check(o1) && PyNumber_Check(o2)) { \
*a = PyInt_AsLong(o1); *b = PyInt_AsLong(o2); \
} \
else \
PyErr_SetString(PyExc_TypeError, errmsg); \
Py_DECREF(o1); \
Py_DECREF(o2); \
} \
else { \
PyErr_SetString(PyExc_TypeError, errmsg); \
} \
Py_DECREF(ro); \
} \
} \
wxPyEndBlockThreads(blocked); \
if (! found) \
PCLASS::CBNAME(a,b); \
}
//---------------------------------------------------------------------------
#define DEC_PYCALLBACK_SIZE_const(CBNAME) \
wxSize CBNAME() const
#define IMP_PYCALLBACK_SIZE_const(CLASS, PCLASS, CBNAME) \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -