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();
90 %name(GetClientSizeTuple) void GetClientSize(int *OUTPUT, int *OUTPUT);
91 wxSize GetClientSize();
92 wxLayoutConstraints * GetConstraints();
93 wxEvtHandler* GetEventHandler();
96 wxColour GetForegroundColour();
97 wxWindow * GetGrandParent();
100 void SetLabel(const wxString& label);
102 wxWindow * GetParent();
103 %name(GetPositionTuple) void GetPosition(int *OUTPUT, int *OUTPUT);
104 wxPoint GetPosition();
106 int GetScrollThumb(int orientation);
107 int GetScrollPos(int orientation);
108 int GetScrollRange(int orientation);
109 %name(GetSizeTuple) void GetSize(int *OUTPUT, int *OUTPUT);
111 void GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT);
112 %name(GetFullTextExtent)void GetTextExtent(const wxString& string,
113 int *OUTPUT, int *OUTPUT, int *OUTPUT, int* OUTPUT,
114 const wxFont* font = NULL); //, bool use16 = FALSE)
116 wxRegion GetUpdateRegion();
117 long GetWindowStyleFlag();
125 bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL);
127 void MakeModal(bool flag);
128 %name(MoveXY)void Move(int x, int y);
129 void Move(const wxPoint& point);
131 wxEvtHandler* PopEventHandler(bool deleteHandler = FALSE);
132 void PushEventHandler(wxEvtHandler* handler);
134 %name(PopupMenuXY)bool PopupMenu(wxMenu *menu, int x, int y);
135 bool PopupMenu(wxMenu *menu, const wxPoint& pos);
138 void Refresh(bool eraseBackground = TRUE, const wxRect* rect = NULL);
140 bool Reparent( wxWindow* newParent );
142 // (uses apply'ed INOUT typemap, see above)
143 %name(ScreenToClientXY)void ScreenToClient(int *x, int *y);
144 wxPoint ScreenToClient(const wxPoint& pt);
146 void ScrollWindow(int dx, int dy, const wxRect* rect = NULL);
147 void SetAcceleratorTable(const wxAcceleratorTable& accel);
148 void SetAutoLayout(bool autoLayout);
149 void SetBackgroundColour(const wxColour& colour);
150 void SetConstraints(wxLayoutConstraints *constraints);
152 void SetFont(const wxFont& font);
153 void SetForegroundColour(const wxColour& colour);
155 void SetName(const wxString& name);
156 void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh = TRUE);
157 void SetScrollPos(int orientation, int pos, bool refresh = TRUE);
159 %name(SetDimensions) void SetSize(int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO);
161 void SetSize(const wxSize& size) {
162 self->SetSize(size.x, size.y);
165 void SetPosition(const wxPoint& pos) {
166 self->SetSize(pos.x, pos.y, -1, -1);
170 void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1);
171 %name(SetClientSizeWH)void SetClientSize(int width, int height);
172 void SetClientSize(const wxSize& size);
173 //void SetPalette(wxPalette* palette);
174 void SetCursor(const wxCursor&cursor);
175 void SetEventHandler(wxEvtHandler* handler);
176 void SetTitle(const wxString& title);
177 bool Show(bool show);
178 bool TransferDataFromWindow();
179 bool TransferDataToWindow();
181 void WarpPointer(int x, int y);
183 %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt);
184 %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz);
186 %name(DLG_PNT) wxPoint ConvertDialogToPixels(const wxPoint& pt);
187 %name(DLG_SZE) wxSize ConvertDialogToPixels(const wxSize& sz);
189 %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt);
190 %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz);
192 %name(SetToolTipString)void SetToolTip(const wxString &tip);
193 void SetToolTip(wxToolTip *tooltip);
194 wxToolTip* GetToolTip();
197 //%clear int* x, int* y;
201 %pragma(python) code = "
202 def wxDLG_PNT(win, point_or_x, y=None):
204 return win.ConvertDialogPointToPixels(point_or_x)
206 return win.ConvertDialogPointToPixels(wxPoint(point_or_x, y))
208 def wxDLG_SZE(win, size_width, height=None):
210 return win.ConvertDialogSizeToPixels(size_width)
212 return win.ConvertDialogSizeToPixels(wxSize(size_width, height))
217 wxWindow* wxWindow_FindFocus() {
218 return wxWindow::FindFocus();
224 wxWindow* wxWindow_FromHWND(unsigned long hWnd) {
225 wxWindow* win = new wxWindow;
227 win->SubclassWin(hWnd);
235 //---------------------------------------------------------------------------
237 class wxPanel : public wxWindow {
239 wxPanel(wxWindow* parent,
241 const wxPoint& pos = wxPyDefaultPosition,
242 const wxSize& size = wxPyDefaultSize,
243 long style = wxTAB_TRAVERSAL,
244 const char* name = "panel");
246 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
249 wxButton* GetDefaultItem();
250 void SetDefaultItem(wxButton *btn);
252 // fix some SWIG trouble...
253 %pragma(python) addtoclass = "
254 def GetDefaultItem(self):
256 val = windowsc.wxPanel_GetDefaultItem(self.this)
257 val = controls.wxButtonPtr(val)
262 //---------------------------------------------------------------------------
264 class wxDialog : public wxPanel {
266 wxDialog(wxWindow* parent,
268 const wxString& title,
269 const wxPoint& pos = wxPyDefaultPosition,
270 const wxSize& size = wxPyDefaultSize,
271 long style = wxDEFAULT_DIALOG_STYLE,
272 const char* name = "dialogBox");
274 %pragma(python) addtomethod = "__init__:wx._StdDialogCallbacks(self)"
276 void Centre(int direction = wxBOTH);
277 void EndModal(int retCode);
279 void Iconize(bool iconize);
281 void SetModal(bool flag);
283 void SetTitle(const wxString& title);
284 bool Show(bool show);
288 void SetReturnCode(int retCode);
291 //---------------------------------------------------------------------------
293 class wxScrolledWindow : public wxPanel {
295 wxScrolledWindow(wxWindow* parent,
296 const wxWindowID id = -1,
297 const wxPoint& pos = wxPyDefaultPosition,
298 const wxSize& size = wxPyDefaultSize,
299 long style = wxHSCROLL | wxVSCROLL,
300 char* name = "scrolledWindow");
302 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
303 %pragma(python) addtomethod = "__init__:wx._StdOnScrollCallbacks(self)"
305 void EnableScrolling(bool xScrolling, bool yScrolling);
306 void GetScrollPixelsPerUnit(int* OUTPUT, int* OUTPUT);
307 void GetVirtualSize(int* OUTPUT, int* OUTPUT);
309 void PrepareDC(wxDC& dc);
310 void Scroll(int x, int y);
311 void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
312 int noUnitsX, int noUnitsY,
313 int xPos = 0, int yPos = 0);
314 void ViewStart(int* OUTPUT, int* OUTPUT);
317 //----------------------------------------------------------------------
320 class wxMenu : public wxEvtHandler {
322 wxMenu(const wxString& title = wxPyEmptyStr, long style = 0);
324 void Append(int id, const wxString& item,
325 const wxString& helpString = wxPyEmptyStr,
326 int checkable = FALSE);
327 %name(AppendMenu)void Append(int id, const wxString& item, wxMenu *subMenu,
328 const wxString& helpString = wxPyEmptyStr);
330 %name(AppendItem)void Append(const wxMenuItem* item);
333 void AppendSeparator();
335 void Check(int id, bool flag);
336 void Enable(int id, bool enable);
337 int FindItem(const wxString& itemString);
339 void SetTitle(const wxString& title);
340 wxMenuItem* FindItemForId(int id);
341 wxString GetHelpString(int id);
342 wxString GetLabel(int id);
343 void SetHelpString(int id, const wxString& helpString);
344 bool IsChecked(int id);
345 bool IsEnabled(int id);
346 void SetLabel(int id, const wxString& label);
347 void UpdateUI(wxEvtHandler* source = NULL);
359 // This one knows how to set a callback and handle INC- and DECREFing it. To
360 // be used for PopupMenus, but you must retain a referece to it while using
363 // class wxPyMenu : public wxMenu {
365 // wxPyMenu(const wxString& title = wxPyEmptyStr, PyObject* func = NULL);
369 //----------------------------------------------------------------------
371 class wxMenuBar : public wxEvtHandler {
375 void Append(wxMenu *menu, const wxString& title);
376 void Check(int id, bool flag);
377 bool Checked(int id);
378 void Enable(int id, bool enable);
379 bool Enabled(int id);
380 int FindMenuItem(const wxString& menuString, const wxString& itemString);
381 wxMenuItem * FindItemForId(int id);
383 void EnableTop(int pos, bool enable);
384 wxString GetHelpString(int id);
385 wxString GetLabel(int id);
386 void SetHelpString(int id, const wxString& helpString);
387 void SetLabel(int id, const wxString& label);
388 wxString GetLabelTop(int pos);
389 void SetLabelTop(int pos, const wxString& label);
392 wxMenu* GetMenu(int i);
396 //----------------------------------------------------------------------
401 wxMenuItem(wxMenu* parentMenu=NULL, int id=ID_SEPARATOR,
402 const wxString& text = wxPyEmptyStr,
403 const wxString& helpString = wxPyEmptyStr,
404 bool checkable = FALSE, wxMenu* subMenu = NULL);
414 wxMenu* GetSubMenu();
415 void SetName(const wxString& strName);
418 void SetHelp(const wxString& strHelp);
419 void Enable(bool bDoEnable = TRUE);
420 void Check(bool bDoCheck = TRUE);
423 wxColour& GetBackgroundColour();
424 wxBitmap GetBitmap(bool checked = TRUE);
426 int GetMarginWidth();
427 wxColour& GetTextColour();
428 void SetBackgroundColour(const wxColour& colour);
429 void SetBitmaps(const wxBitmap& checked, const wxBitmap& unchecked = wxNullBitmap);
430 void SetFont(const wxFont& font);
431 void SetMarginWidth(int width);
432 void SetTextColour(const wxColour& colour);
433 void DeleteSubMenu();
437 //---------------------------------------------------------------------------