]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: helpers.h | |
3 | // Purpose: Helper functions/classes for the wxPython extenaion module | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 7/1/97 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 1998 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | #ifndef __wxp_helpers__ | |
14 | #define __wxp_helpers__ | |
15 | ||
16 | #include <wx/wx.h> | |
17 | ||
18 | ||
19 | //---------------------------------------------------------------------- | |
20 | ||
21 | // if we want to handle threads and Python threads are available... | |
22 | #if defined(WXP_USE_THREAD) && defined(WITH_THREAD) | |
23 | ||
24 | #define WXP_WITH_THREAD | |
25 | #define wxPy_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS | |
26 | #define wxPy_END_ALLOW_THREADS Py_END_ALLOW_THREADS | |
27 | ||
28 | #else // no Python threads... | |
29 | #undef WXP_WITH_THREAD | |
30 | #define wxPy_BEGIN_ALLOW_THREADS | |
31 | #define wxPy_END_ALLOW_THREADS | |
32 | #endif | |
33 | ||
34 | ||
35 | //---------------------------------------------------------------------- | |
36 | ||
37 | class wxPyApp: public wxApp | |
38 | { | |
39 | public: | |
40 | wxPyApp(); | |
41 | ~wxPyApp(); | |
42 | int MainLoop(void); | |
43 | bool OnInit(void); | |
44 | void AfterMainLoop(void); | |
45 | }; | |
46 | ||
47 | extern wxPyApp *wxPythonApp; | |
48 | ||
49 | //---------------------------------------------------------------------- | |
50 | ||
51 | void __wxPreStart(); | |
52 | PyObject* __wxStart(PyObject*, PyObject* args); | |
53 | ||
54 | extern PyObject* wxPython_dict; | |
55 | PyObject* __wxSetDictionary(PyObject*, PyObject* args); | |
56 | ||
57 | extern wxHashTable* wxPyWindows; // keep track of all windows so we | |
58 | // don't accidentally delete them twice. | |
59 | ||
60 | void wxPyEventThunker(wxObject*, wxEvent& event); | |
61 | ||
62 | //---------------------------------------------------------------------- | |
63 | ||
64 | ||
65 | #ifndef SWIGCODE | |
66 | extern "C" void SWIG_MakePtr(char *, void *, char *); | |
67 | extern "C" char *SWIG_GetPtr(char *, void **, char *); | |
68 | #endif | |
69 | ||
70 | ||
71 | #ifdef _MSC_VER | |
72 | # pragma warning(disable:4800) | |
73 | #endif | |
74 | ||
75 | typedef unsigned char byte; | |
76 | ||
77 | ||
78 | // Non-const versions to keep SWIG happy. | |
79 | extern wxPoint wxPyDefaultPosition; | |
80 | extern wxSize wxPyDefaultSize; | |
81 | extern wxString wxPyEmptyStr; | |
82 | ||
83 | //---------------------------------------------------------------------- | |
84 | ||
85 | class wxPyCallback : public wxObject { | |
86 | public: | |
87 | wxPyCallback(PyObject* func); | |
88 | ~wxPyCallback(); | |
89 | ||
90 | void EventThunker(wxEvent& event); | |
91 | ||
92 | PyObject* m_func; | |
93 | }; | |
94 | ||
95 | //--------------------------------------------------------------------------- | |
96 | ||
97 | class wxPyMenu : public wxMenu { | |
98 | public: | |
99 | wxPyMenu(const wxString& title = "", PyObject* func=NULL); | |
100 | ~wxPyMenu(); | |
101 | ||
102 | private: | |
103 | static void MenuCallback(wxMenu& menu, wxCommandEvent& evt); | |
104 | PyObject* func; | |
105 | }; | |
106 | ||
107 | ||
108 | //--------------------------------------------------------------------------- | |
109 | ||
110 | class wxPyTimer : public wxTimer { | |
111 | public: | |
112 | wxPyTimer(PyObject* callback); | |
113 | ~wxPyTimer(); | |
114 | ||
115 | void Notify(); | |
116 | ||
117 | private: | |
118 | PyObject* func; | |
119 | }; | |
120 | ||
121 | //--------------------------------------------------------------------------- | |
122 | ||
123 | class wxPyEvent : public wxCommandEvent { | |
124 | DECLARE_DYNAMIC_CLASS(wxPyEvent) | |
125 | public: | |
126 | wxPyEvent(wxEventType commandType = wxEVT_NULL, PyObject* userData = Py_None); | |
127 | ~wxPyEvent(); | |
128 | ||
129 | void SetUserData(PyObject* userData); | |
130 | PyObject* GetUserData(); | |
131 | ||
132 | private: | |
133 | PyObject* m_userData; | |
134 | }; | |
135 | ||
136 | //--------------------------------------------------------------------------- | |
137 | ///////////////////////////////////////////////////////////////////////////// | |
138 | // | |
139 | // $Log$ | |
140 | // Revision 1.7 1999/04/30 03:29:18 RD | |
141 | // wxPython 2.0b9, first phase (win32) | |
142 | // Added gobs of stuff, see wxPython/README.txt for details | |
143 | // | |
144 | // Revision 1.6.4.1 1999/03/27 23:29:14 RD | |
145 | // | |
146 | // wxPython 2.0b8 | |
147 | // Python thread support | |
148 | // various minor additions | |
149 | // various minor fixes | |
150 | // | |
151 | // Revision 1.6 1998/11/25 08:45:26 RD | |
152 | // | |
153 | // Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon | |
154 | // Added events for wxGrid | |
155 | // Other various fixes and additions | |
156 | // | |
157 | // Revision 1.5 1998/10/02 06:40:40 RD | |
158 | // | |
159 | // Version 0.4 of wxPython for MSW. | |
160 | // | |
161 | // Revision 1.4 1998/08/27 21:59:09 RD | |
162 | // Some chicken-and-egg problems solved for wxPython on wxGTK | |
163 | // | |
164 | // Revision 1.3 1998/08/16 04:31:09 RD | |
165 | // More wxGTK work. | |
166 | // | |
167 | // Revision 1.2 1998/08/14 23:36:37 RD | |
168 | // Beginings of wxGTK compatibility | |
169 | // | |
170 | // Revision 1.1 1998/08/09 08:25:51 RD | |
171 | // Initial version | |
172 | // | |
173 | // | |
174 | ||
175 | #endif | |
176 |