1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG definitions of various window classes
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
18 #include <wx/menuitem.h>
21 //----------------------------------------------------------------------
24 %include my_typemaps.i
26 // Import some definitions of other classes, etc.
31 %pragma(python) code = "import wx"
34 //---------------------------------------------------------------------------
38 bool ProcessEvent(wxEvent& event);
40 void Connect( int id, int lastId, int eventType, PyObject* func) {
41 if (PyCallable_Check(func)) {
42 self->Connect(id, lastId, eventType,
43 (wxObjectEventFunction) &wxPyCallback::EventThunker,
44 new wxPyCallback(func));
51 //----------------------------------------------------------------------
53 %apply int * INOUT { int* x, int* y };
55 class wxWindow : public wxEvtHandler {
58 wxWindow(wxWindow* parent, const wxWindowID id,
59 const wxPoint& pos = wxPyDefaultPosition,
60 const wxSize& size = wxPyDefaultSize,
62 char* name = "panel");
64 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
67 void Center(int direction = wxBOTH);
68 void Centre(int direction = wxBOTH);
69 void CentreOnParent(int direction = wxBOTH );
70 void CenterOnParent(int direction = wxBOTH );
72 // (uses apply'ed INOUT typemap, see above)
73 %name(ClientToScreenXY)void ClientToScreen(int* x, int* y);
74 wxPoint ClientToScreen(const wxPoint& pt);
76 bool Close(int force = FALSE);
78 void DestroyChildren();
80 void DragAcceptFiles(bool accept);
82 void Enable(bool enable);
83 //bool FakePopupMenu(wxMenu* menu, int x, int y);
84 %name(FindWindowById) wxWindow* FindWindow(long id);
85 %name(FindWindowByName) wxWindow* FindWindow(const wxString& name);
87 wxColour GetBackgroundColour();
89 //wxList& GetChildren();
91 PyObject* GetChildren() {
92 wxWindowList& list = self->GetChildren();
93 return wxPy_ConvertList(&list, "wxWindow");
100 %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT);
101 wxSize GetClientSize();
102 wxLayoutConstraints * GetConstraints();
103 wxEvtHandler* GetEventHandler();
106 wxColour GetForegroundColour();
107 wxWindow * GetGrandParent();
110 void SetLabel(const wxString& label);
112 wxWindow * GetParent();
113 %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT);
114 wxPoint GetPosition();
116 int GetScrollThumb(int orientation);
117 int GetScrollPos(int orientation);
118 int GetScrollRange(int orientation);
119 %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT);
121 void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT);
122 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
123 int *OUTPUT, int *OUTPUT, int *OUTPUT, int* OUTPUT,
124 const wxFont* font = NULL); //, bool use16 = FALSE)
126 wxRegion GetUpdateRegion();
127 long GetWindowStyleFlag();
135 bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL);
137 void MakeModal(bool flag);
138 %name(MoveXY)void Move(int x, int y);
139 void Move(const wxPoint& point);
141 wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE);
142 void PushEventHandler(wxEvtHandler* handler);
144 %name(PopupMenuXY)bool PopupMenu(wxMenu *menu, int x, int y);
145 bool PopupMenu(wxMenu *menu, const wxPoint& pos);
148 void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL);
150 bool Reparent( wxWindow* newParent );
152 // (uses apply'ed INOUT typemap, see above)
153 %name(ScreenToClientXY)void ScreenToClient(int *x, int *y);
154 wxPoint ScreenToClient(const wxPoint& pt);
156 void ScrollWindow(int dx, int dy, const wxRect* rect = NULL);
157 void SetAcceleratorTable(const wxAcceleratorTable& accel);
158 void SetAutoLayout(bool autoLayout);
159 void SetBackgroundColour(const wxColour& colour);
160 void SetConstraints(wxLayoutConstraints *constraints);
162 void SetFont(const wxFont& font);
163 void SetForegroundColour(const wxColour& colour);
165 void SetName(const wxString& name);
166 void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh = TRUE);
167 void SetScrollPos(int orientation, int pos, bool refresh = TRUE);
169 %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
171 void SetSize(const wxSize& size) {
172 self->SetSize(size.x, size.y);
175 void SetPosition(const wxPoint& pos) {
176 self->SetSize(pos.x, pos.y, -1, -1);
180 void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1);
181 %name(SetClientSizeWH)void SetClientSize(int width, int height);
182 void SetClientSize(const wxSize& size);
183 //void SetPalette(wxPalette* palette);
184 void SetCursor(const wxCursor&cursor);
185 void SetEventHandler(wxEvtHandler* handler);
186 void SetTitle(const wxString& title);
187 bool Show(bool show);
188 bool TransferDataFromWindow();
189 bool TransferDataToWindow();
191 void WarpPointer(int x, int y);
193 %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt);
194 %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz);
196 %name(DLG_PNT) wxPoint ConvertDialogToPixels(const wxPoint& pt);
197 %name(DLG_SZE) wxSize ConvertDialogToPixels(const wxSize& sz);
199 %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt);
200 %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz);
202 %name(SetToolTipString)void SetToolTip(const wxString &tip);
203 void SetToolTip(wxToolTip *tooltip);
204 wxToolTip* GetToolTip();
207 //%clear int* x, int* y;
211 %pragma(python) code = "
212 def wxDLG_PNT(win, point_or_x, y=None):
214 return win.ConvertDialogPointToPixels(point_or_x)
216 return win.ConvertDialogPointToPixels(wxPoint(point_or_x, y))
218 def wxDLG_SZE(win, size_width, height=None):
220 return win.ConvertDialogSizeToPixels(size_width)
222 return win.ConvertDialogSizeToPixels(wxSize(size_width, height))
227 wxWindow* wxWindow_FindFocus() {
228 return wxWindow::FindFocus();
234 wxWindow* wxWindow_FromHWND(unsigned long hWnd) {
235 wxWindow* win = new wxWindow;
237 win->SubclassWin(hWnd);
245 //---------------------------------------------------------------------------
247 class wxPanel : public wxWindow {
249 wxPanel(wxWindow* parent,
251 const wxPoint& pos = wxPyDefaultPosition,
252 const wxSize& size = wxPyDefaultSize,
253 long style = wxTAB_TRAVERSAL,
254 const char* name = "panel");
256 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
259 wxButton* GetDefaultItem();
260 void SetDefaultItem(wxButton *btn);
262 // fix some SWIG trouble...
263 %pragma(python) addtoclass = "
264 def GetDefaultItem(self):
266 val = windowsc.wxPanel_GetDefaultItem(self.this)
267 val = controls.wxButtonPtr(val)
272 //---------------------------------------------------------------------------
274 class wxDialog : public wxPanel {
276 wxDialog(wxWindow* parent,
278 const wxString& title,
279 const wxPoint& pos = wxPyDefaultPosition,
280 const wxSize& size = wxPyDefaultSize,
281 long style = wxDEFAULT_DIALOG_STYLE,
282 const char* name = "dialogBox");
284 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
286 void Centre(int direction = wxBOTH);
287 void EndModal(int retCode);
289 void Iconize(bool iconize);
291 void SetModal(bool flag);
293 void SetTitle(const wxString& title);
294 bool Show(bool show);
298 void SetReturnCode(int retCode);
301 //---------------------------------------------------------------------------
303 class wxScrolledWindow : public wxPanel {
305 wxScrolledWindow(wxWindow* parent,
306 const wxWindowID id = -1,
307 const wxPoint& pos = wxPyDefaultPosition,
308 const wxSize& size = wxPyDefaultSize,
309 long style = wxHSCROLL | wxVSCROLL,
310 char* name = "scrolledWindow");
312 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
313 %pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)"
315 void EnableScrolling(bool xScrolling, bool yScrolling);
316 void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT);
317 void GetVirtualSize(int* OUTPUT, int* OUTPUT);
319 void PrepareDC(wxDC& dc);
320 void Scroll(int x, int y);
321 void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
322 int noUnitsX, int noUnitsY,
323 int xPos = 0, int yPos = 0);
324 void ViewStart(int* OUTPUT, int* OUTPUT);
327 //----------------------------------------------------------------------
330 class wxMenu : public wxEvtHandler {
332 wxMenu(const wxString& title = wxPyEmptyStr, long style = 0);
334 void Append(int id, const wxString& item,
335 const wxString& helpString = wxPyEmptyStr,
336 int checkable = FALSE);
337 %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu,
338 const wxString& helpString = wxPyEmptyStr);
340 %name(AppendItem)void Append(const wxMenuItem* item);
343 void AppendSeparator();
345 void Check(int id, bool flag);
346 void Enable(int id, bool enable);
347 int FindItem(const wxString& itemString);
349 void SetTitle(const wxString& title);
350 wxMenuItem* FindItemForId(int id);
351 wxString GetHelpString(int id);
352 wxString GetLabel(int id);
353 void SetHelpString(int id, const wxString& helpString);
354 bool IsChecked(int id);
355 bool IsEnabled(int id);
356 void SetLabel(int id, const wxString& label);
357 void UpdateUI(wxEvtHandler* source = NULL);
369 // This one knows how to set a callback and handle INC- and DECREFing it. To
370 // be used for PopupMenus, but you must retain a referece to it while using
373 // class wxPyMenu : public wxMenu {
375 // wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL);
379 //----------------------------------------------------------------------
381 class wxMenuBar : public wxEvtHandler {
385 void Append(wxMenu *menu, const wxString& title);
386 void Check(int id, bool flag);
387 bool Checked(int id);
388 void Enable(int id, bool enable);
389 bool Enabled(int id);
390 int FindMenuItem(const wxString& menuString, const wxString& itemString);
391 wxMenuItem * FindItemForId(int id);
393 void EnableTop(int pos, bool enable);
394 wxString GetHelpString(int id);
395 wxString GetLabel(int id);
396 void SetHelpString(int id, const wxString& helpString);
397 void SetLabel(int id, const wxString& label);
398 wxString GetLabelTop(int pos);
399 void SetLabelTop(int pos, const wxString& label);
402 wxMenu* GetMenu(int i);
406 //----------------------------------------------------------------------
411 wxMenuItem(wxMenu* parentMenu=NULL, int id=ID_SEPARATOR,
412 const wxString& text = wxPyEmptyStr,
413 const wxString& helpString = wxPyEmptyStr,
414 bool checkable = FALSE, wxMenu* subMenu = NULL);
424 wxMenu* GetSubMenu();
425 void SetName(const wxString& strName);
428 void SetHelp(const wxString& strHelp);
429 void Enable(bool bDoEnable = TRUE);
430 void Check(bool bDoCheck = TRUE);
433 wxColour& GetBackgroundColour();
434 wxBitmap GetBitmap(bool checked = TRUE);
436 int GetMarginWidth();
437 wxColour& GetTextColour();
438 void SetBackgroundColour(const wxColour& colour);
439 void SetBitmaps(const wxBitmap& checked, const wxBitmap& unchecked = wxNullBitmap);
440 void SetFont(const wxFont& font);
441 void SetMarginWidth(int width);
442 void SetTextColour(const wxColour& colour);
443 void DeleteSubMenu();
447 //---------------------------------------------------------------------------