]>
Commit | Line | Data |
---|---|---|
d14a1e28 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: _window.i | |
3 | // Purpose: SWIG interface for wxWindow | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 24-June-1997 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2003 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | // Not a %module | |
14 | ||
15 | ||
16 | //--------------------------------------------------------------------------- | |
17 | ||
18 | %{ | |
19 | %} | |
20 | ||
dd9f7fea RD |
21 | MAKE_CONST_WXSTRING(PanelNameStr); |
22 | ||
d14a1e28 RD |
23 | //--------------------------------------------------------------------------- |
24 | %newgroup | |
25 | ||
26 | class wxWindow : public wxEvtHandler | |
27 | { | |
28 | public: | |
29 | %addtofunc wxWindow "self._setOORInfo(self)" | |
30 | %addtofunc wxWindow() "" | |
31 | ||
32 | wxWindow(wxWindow* parent, const wxWindowID id, | |
33 | const wxPoint& pos = wxDefaultPosition, | |
34 | const wxSize& size = wxDefaultSize, | |
35 | long style = 0, | |
36 | const wxString& name = wxPyPanelNameStr); | |
37 | %name(PreWindow)wxWindow(); | |
38 | ||
39 | bool Create(wxWindow* parent, const wxWindowID id, | |
40 | const wxPoint& pos = wxDefaultPosition, | |
41 | const wxSize& size = wxDefaultSize, | |
42 | long style = 0, | |
43 | const wxString& name = wxPyPanelNameStr); | |
44 | ||
45 | ||
46 | ||
47 | // deleting the window | |
48 | // ------------------- | |
49 | ||
dd9f7fea | 50 | // ask the window to close itself, return True if the event handler |
d14a1e28 | 51 | // honoured our request |
dd9f7fea | 52 | bool Close( bool force = False ); |
d14a1e28 | 53 | |
dd9f7fea | 54 | // delete window unconditionally (dangerous!), returns True if ok |
d14a1e28 RD |
55 | virtual bool Destroy(); |
56 | ||
dd9f7fea | 57 | // delete all children of this window, returns True if ok |
d14a1e28 RD |
58 | bool DestroyChildren(); |
59 | ||
60 | // is the window being deleted? | |
61 | bool IsBeingDeleted() const; | |
62 | ||
63 | ||
64 | // window attributes | |
65 | // ----------------- | |
66 | ||
67 | // the text which the window shows in the title if applicable | |
68 | virtual void SetTitle( const wxString& WXUNUSED(title) ); | |
69 | virtual wxString GetTitle() const; | |
70 | ||
71 | // the text which the window shows in its label if applicable | |
72 | virtual void SetLabel(const wxString& label); | |
73 | virtual wxString GetLabel() const; | |
74 | ||
75 | // the window name is used for ressource setting in X, it is not the | |
76 | // same as the window title/label | |
77 | virtual void SetName( const wxString &name ); | |
78 | virtual wxString GetName() const; | |
79 | ||
80 | // window id uniquely identifies the window among its siblings unless | |
81 | // it is -1 which means "don't care" | |
82 | void SetId( wxWindowID winid ); | |
83 | wxWindowID GetId() const; | |
84 | ||
85 | // generate a control id for the controls which were not given one by | |
86 | // user | |
87 | static int NewControlId(); | |
88 | ||
89 | // get the id of the control following the one with the given | |
90 | // (autogenerated) id | |
91 | static int NextControlId(int winid); | |
92 | ||
93 | // get the id of the control preceding the one with the given | |
94 | // (autogenerated) id | |
95 | static int PrevControlId(int winid); | |
96 | ||
97 | ||
98 | ||
99 | // moving/resizing | |
100 | // --------------- | |
101 | ||
102 | // set the window size | |
103 | void SetSize( const wxSize& size ); | |
104 | ||
105 | // set the window size and position | |
106 | %name(SetDimensions) void SetSize( int x, int y, int width, int height, | |
107 | int sizeFlags = wxSIZE_AUTO ); | |
108 | ||
109 | // set the window size and position with a wxRect | |
110 | %name(SetRect) void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO); | |
111 | ||
112 | // set window size | |
113 | %name(SetSizeWH)void SetSize( int width, int height ); | |
114 | ||
115 | // set window position | |
116 | void Move(const wxPoint& pt, int flags = wxSIZE_USE_EXISTING); | |
117 | %pythoncode { SetPosition = Move } | |
118 | ||
119 | // set window position | |
120 | %name(MoveXY) void Move(int x, int y, int flags = wxSIZE_USE_EXISTING); | |
121 | ||
122 | // Z-order | |
123 | virtual void Raise(); | |
124 | virtual void Lower(); | |
125 | ||
126 | // client size is the size of the area available for subwindows | |
127 | void SetClientSize( const wxSize& size ); | |
128 | %name(SetClientSizeWH) void SetClientSize( int width, int height ); | |
129 | %name(SetClientRect) void SetClientSize(const wxRect& rect); | |
130 | ||
131 | ||
dd9f7fea RD |
132 | DocStr(GetPosition, // sets the docstring for both |
133 | "Get the window's position."); | |
134 | wxPoint GetPosition(); | |
d14a1e28 | 135 | |
dd9f7fea RD |
136 | DocDeclAName( |
137 | void, GetPosition(int *OUTPUT, int *OUTPUT), | |
138 | "GetPositionTuple() -> (x,y)", | |
139 | GetPositionTuple); | |
d14a1e28 | 140 | |
d14a1e28 | 141 | |
dd9f7fea RD |
142 | |
143 | DocStr(GetSize, "Get the window size."); | |
144 | wxSize GetSize() const; | |
145 | DocDeclAName( | |
146 | void, GetSize( int *OUTPUT, int *OUTPUT ) const, | |
147 | "GetSizeTuple() -> (width, height)", | |
148 | GetSizeTuple); | |
149 | ||
150 | ||
d14a1e28 RD |
151 | // get the window position and size |
152 | wxRect GetRect() const; | |
153 | ||
dd9f7fea | 154 | DocStr(GetClientSize, "Get the window's client size."); |
d14a1e28 | 155 | wxSize GetClientSize() const; |
dd9f7fea RD |
156 | DocDeclAName( |
157 | void, GetClientSize( int *OUTPUT, int *OUTPUT ) const, | |
158 | "GetClientSizeTuple() -> (width, height)", | |
159 | GetClientSizeTuple); | |
d14a1e28 RD |
160 | |
161 | ||
162 | // get the origin of the client area of the window relative to the | |
163 | // window top left corner (the client area may be shifted because of | |
164 | // the borders, scrollbars, other decorations...) | |
165 | virtual wxPoint GetClientAreaOrigin() const; | |
166 | ||
167 | // get the client rectangle in window (i.e. client) coordinates | |
168 | wxRect GetClientRect() const; | |
169 | ||
dd9f7fea RD |
170 | DocStr(GetBestSize, |
171 | "Get the size best suited for the window (in fact, minimal acceptable size\n" | |
172 | "using which it will still look \"nice\")"); | |
d14a1e28 | 173 | wxSize GetBestSize() const; |
dd9f7fea RD |
174 | DocDeclAName( |
175 | void, GetBestSize(int *OUTPUT, int *OUTPUT) const, | |
176 | "GetBestSizeTuple() -> (width, height)", | |
177 | GetBestSizeTuple); | |
178 | ||
d14a1e28 RD |
179 | |
180 | // There are times (and windows) where 'Best' size and 'Min' size | |
181 | // are vastly out of sync. This should be remedied somehow, but in | |
182 | // the meantime, this method will return the larger of BestSize | |
183 | // (the window's smallest legible size), and any user specified | |
184 | // MinSize hint. | |
185 | wxSize GetAdjustedBestSize() const; | |
186 | ||
187 | ||
188 | // the generic center function - centers the window on parent by | |
189 | // default or on screen if it doesn't have parent or | |
190 | // wxCENTER_ON_SCREEN flag is given | |
191 | void Center( int direction = wxBOTH ); | |
192 | %pythoncode { Centre = Center } | |
193 | ||
194 | // center on screen (only works for top level windows) | |
195 | void CenterOnScreen(int dir = wxBOTH); | |
196 | %pythoncode { CentreOnScreen = CenterOnScreen } | |
197 | ||
198 | // center with respect to the the parent window | |
199 | void CenterOnParent(int dir = wxBOTH); | |
200 | %pythoncode { CentreOnParent = CenterOnParent } | |
201 | ||
202 | ||
203 | // set window size to wrap around its children | |
204 | virtual void Fit(); | |
205 | ||
206 | // set virtual size to satisfy children | |
207 | virtual void FitInside(); | |
208 | ||
209 | // set min/max size of the window | |
210 | virtual void SetSizeHints( int minW, int minH, | |
211 | int maxW = -1, int maxH = -1, | |
212 | int incW = -1, int incH = -1 ); | |
213 | ||
214 | virtual void SetVirtualSizeHints( int minW, int minH, | |
215 | int maxW = -1, int maxH = -1 ); | |
216 | ||
217 | virtual int GetMinWidth() const; | |
218 | virtual int GetMinHeight() const; | |
219 | int GetMaxWidth() const; | |
220 | int GetMaxHeight() const; | |
221 | ||
222 | ||
223 | // Override this method to control the values given to Sizers etc. | |
224 | virtual wxSize GetMaxSize() const; | |
225 | ||
dd9f7fea RD |
226 | |
227 | DocStr(SetVirtualSize, | |
228 | "Set the the virtual size of a window. For most windows this is just the\n" | |
229 | "client area of the window, but for some like scrolled windows it is more or\n" | |
230 | "less independent of the screen window size."); | |
231 | void SetVirtualSize(const wxSize& size ); | |
d14a1e28 RD |
232 | %name(SetVirtualSizeWH) void SetVirtualSize( int w, int h ); |
233 | ||
dd9f7fea RD |
234 | |
235 | DocStr(GetVirtualSize, | |
236 | "Get the the virtual size of the window. For most windows this is just\n" | |
237 | "the client area of the window, but for some like scrolled windows it is\n" | |
238 | "more or less independent of the screen window size."); | |
d14a1e28 | 239 | wxSize GetVirtualSize() const; |
dd9f7fea RD |
240 | DocDeclAName( |
241 | void, GetVirtualSize( int *OUTPUT, int *OUTPUT ) const, | |
242 | "GetVirtualSizeTuple() -> (width, height)", | |
243 | GetVirtualSizeTuple); | |
d14a1e28 RD |
244 | |
245 | ||
246 | // TODO: using directors? | |
247 | // // Override these methods for windows that have a virtual size | |
248 | // // independent of their client size. eg. the virtual area of a | |
249 | // // wxScrolledWindow. Default is to alias VirtualSize to ClientSize. | |
250 | // virtual void DoSetVirtualSize( int x, int y ); | |
251 | // virtual wxSize DoGetVirtualSize() const; // { return m_virtualSize; } | |
252 | ||
253 | ||
254 | // Return the largest of ClientSize and BestSize (as determined | |
255 | // by a sizer, interior children, or other means) | |
256 | virtual wxSize GetBestVirtualSize() const; | |
257 | ||
258 | ||
259 | ||
260 | // window state | |
261 | // ------------ | |
262 | ||
dd9f7fea | 263 | // returns True if window was shown/hidden, False if the nothing was |
d14a1e28 | 264 | // done (window was already shown/hidden) |
dd9f7fea | 265 | virtual bool Show( bool show = True ); |
d14a1e28 RD |
266 | bool Hide(); |
267 | ||
dd9f7fea RD |
268 | // returns True if window was enabled/disabled, False if nothing done |
269 | virtual bool Enable( bool enable = True ); | |
d14a1e28 RD |
270 | bool Disable(); |
271 | ||
272 | bool IsShown() const; | |
273 | bool IsEnabled() const; | |
274 | ||
275 | // get/set window style (setting style won't update the window and so | |
276 | // is only useful for internal usage) | |
277 | virtual void SetWindowStyleFlag( long style ); | |
278 | virtual long GetWindowStyleFlag() const; | |
279 | ||
280 | // get/set window style (setting style won't update the window and so | |
281 | // is only useful for internal usage) | |
282 | void SetWindowStyle( long style ); | |
283 | long GetWindowStyle() const; | |
284 | ||
285 | bool HasFlag(int flag) const; | |
286 | virtual bool IsRetained() const; | |
287 | ||
288 | // extra style: the less often used style bits which can't be set with | |
289 | // SetWindowStyleFlag() | |
290 | virtual void SetExtraStyle(long exStyle); | |
291 | long GetExtraStyle() const; | |
292 | ||
293 | // make the window modal (all other windows unresponsive) | |
dd9f7fea | 294 | virtual void MakeModal(bool modal = True); |
d14a1e28 RD |
295 | |
296 | virtual void SetThemeEnabled(bool enableTheme); | |
297 | virtual bool GetThemeEnabled() const; | |
298 | ||
299 | // controls by default inherit the colours of their parents, if a | |
300 | // particular control class doesn't want to do it, it can override | |
dd9f7fea | 301 | // ShouldInheritColours() to return False |
d14a1e28 RD |
302 | virtual bool ShouldInheritColours() const; |
303 | ||
304 | ||
305 | // focus and keyboard handling | |
306 | // --------------------------- | |
307 | ||
308 | // set focus to this window | |
309 | virtual void SetFocus(); | |
310 | ||
311 | // set focus to this window as the result of a keyboard action | |
312 | virtual void SetFocusFromKbd(); | |
313 | ||
314 | // return the window which currently has the focus or NULL | |
315 | static wxWindow *FindFocus(); | |
316 | ||
317 | // can this window have focus? | |
318 | virtual bool AcceptsFocus() const; | |
319 | ||
320 | // can this window be given focus by keyboard navigation? if not, the | |
321 | // only way to give it focus (provided it accepts it at all) is to | |
322 | // click it | |
323 | virtual bool AcceptsFocusFromKeyboard() const; | |
324 | ||
325 | // get the default child of this parent, i.e. the one which is | |
326 | // activated by pressing <Enter> | |
327 | virtual wxWindow *GetDefaultItem() const; | |
328 | ||
329 | // set this child as default, return the old default | |
330 | virtual wxWindow *SetDefaultItem(wxWindow * WXUNUSED(child)); | |
331 | ||
332 | // set this child as temporary default | |
333 | virtual void SetTmpDefaultItem(wxWindow * WXUNUSED(win)); | |
334 | ||
335 | ||
336 | ||
337 | // parent/children relations | |
338 | // ------------------------- | |
339 | ||
340 | // get the list of children | |
341 | //wxWindowList& GetChildren(); // TODO: Do a typemap or a wrapper for wxWindowList | |
342 | %extend { | |
343 | PyObject* GetChildren() { | |
344 | wxWindowList& list = self->GetChildren(); | |
345 | return wxPy_ConvertList(&list); | |
346 | } | |
347 | } | |
348 | ||
349 | // get the parent or the parent of the parent | |
350 | wxWindow *GetParent() const; | |
351 | wxWindow *GetGrandParent() const; | |
352 | ||
353 | // is this window a top level one? | |
354 | virtual bool IsTopLevel() const; | |
355 | ||
dd9f7fea RD |
356 | // change the real parent of this window, return True if the parent |
357 | // was changed, False otherwise (error or newParent == oldParent) | |
d14a1e28 RD |
358 | virtual bool Reparent( wxWindow *newParent ); |
359 | ||
360 | // implementation mostly | |
361 | virtual void AddChild( wxWindow *child ); | |
362 | virtual void RemoveChild( wxWindow *child ); | |
363 | ||
364 | ||
365 | ||
366 | // looking for windows | |
367 | // ------------------- | |
368 | ||
369 | // find window among the descendants of this one either by id or by | |
370 | // name (return NULL if not found) | |
371 | %name(FindWindowById) wxWindow *FindWindow( long winid ); | |
372 | %name(FindWindowByName) wxWindow *FindWindow( const wxString& name ); | |
373 | ||
374 | ||
375 | // event handler stuff | |
376 | // ------------------- | |
377 | ||
378 | // get the current event handler | |
379 | wxEvtHandler *GetEventHandler() const; | |
380 | ||
381 | // replace the event handler (allows to completely subclass the | |
382 | // window) | |
383 | void SetEventHandler( wxEvtHandler *handler ); | |
384 | ||
385 | // push/pop event handler: allows to chain a custom event handler to | |
386 | // alreasy existing ones | |
387 | void PushEventHandler( wxEvtHandler *handler ); | |
dd9f7fea | 388 | wxEvtHandler *PopEventHandler( bool deleteHandler = False ); |
d14a1e28 RD |
389 | |
390 | // find the given handler in the event handler chain and remove (but | |
dd9f7fea RD |
391 | // not delete) it from the event handler chain, return True if it was |
392 | // found and False otherwise (this also results in an assert failure so | |
d14a1e28 RD |
393 | // this function should only be called when the handler is supposed to |
394 | // be there) | |
395 | bool RemoveEventHandler(wxEvtHandler *handler); | |
396 | ||
397 | ||
398 | ||
399 | // validators | |
400 | // ---------- | |
401 | ||
402 | // a window may have an associated validator which is used to control | |
403 | // user input | |
404 | virtual void SetValidator( const wxValidator &validator ); | |
405 | virtual wxValidator *GetValidator(); | |
406 | ||
407 | ||
408 | // accelerators | |
409 | // ------------ | |
410 | ||
411 | virtual void SetAcceleratorTable( const wxAcceleratorTable& accel ); | |
412 | wxAcceleratorTable *GetAcceleratorTable(); | |
413 | ||
414 | ||
415 | ||
416 | ||
417 | // hot keys (system wide accelerators) | |
418 | // ----------------------------------- | |
419 | %extend { | |
420 | // hot keys (system wide accelerators) | |
421 | bool RegisterHotKey(int hotkeyId, int modifiers, int keycode) { | |
422 | #if wxUSE_HOTKEY | |
423 | return self->RegisterHotKey(hotkeyId, modifiers, keycode); | |
424 | #else | |
dd9f7fea | 425 | return False; |
d14a1e28 RD |
426 | #endif |
427 | } | |
428 | ||
429 | bool UnregisterHotKey(int hotkeyId) { | |
430 | #if wxUSE_HOTKEY | |
431 | return self->UnregisterHotKey(hotkeyId); | |
432 | #else | |
dd9f7fea | 433 | return False; |
d14a1e28 RD |
434 | #endif |
435 | } | |
436 | } | |
437 | ||
438 | ||
439 | ||
440 | // "dialog units" translations | |
441 | // --------------------------- | |
442 | ||
443 | %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt); | |
444 | %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz); | |
445 | ||
446 | %name(DLG_PNT) wxPoint ConvertDialogToPixels(const wxPoint& pt); | |
447 | %name(DLG_SZE) wxSize ConvertDialogToPixels(const wxSize& sz); | |
448 | ||
449 | %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt); | |
450 | %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz); | |
451 | ||
452 | ||
453 | ||
454 | // mouse functions | |
455 | // --------------- | |
456 | ||
457 | // move the mouse to the specified position | |
458 | virtual void WarpPointer(int x, int y); | |
459 | ||
460 | // start or end mouse capture, these functions maintain the stack of | |
461 | // windows having captured the mouse and after calling ReleaseMouse() | |
462 | // the mouse is not released but returns to the window which had had | |
463 | // captured it previously (if any) | |
464 | void CaptureMouse(); | |
465 | void ReleaseMouse(); | |
466 | ||
467 | // get the window which currently captures the mouse or NULL | |
468 | static wxWindow *GetCapture(); | |
469 | ||
470 | // does this window have the capture? | |
471 | virtual bool HasCapture() const; | |
472 | ||
473 | ||
474 | ||
475 | // painting the window | |
476 | // ------------------- | |
477 | ||
478 | // mark the specified rectangle (or the whole window) as "dirty" so it | |
479 | // will be repainted | |
dd9f7fea | 480 | virtual void Refresh( bool eraseBackground = True, |
d14a1e28 RD |
481 | const wxRect *rect = NULL ); |
482 | ||
483 | // a less awkward wrapper for Refresh | |
484 | void RefreshRect(const wxRect& rect); | |
485 | ||
486 | // repaint all invalid areas of the window immediately | |
487 | virtual void Update(); | |
488 | ||
489 | // clear the window background | |
490 | virtual void ClearBackground(); | |
491 | ||
492 | // freeze the window: don't redraw it until it is thawed | |
493 | virtual void Freeze(); | |
494 | ||
495 | // thaw the window: redraw it after it had been frozen | |
496 | virtual void Thaw(); | |
497 | ||
498 | // adjust DC for drawing on this window | |
499 | virtual void PrepareDC( wxDC & WXUNUSED(dc) ); | |
500 | ||
501 | // the update region of the window contains the areas which must be | |
502 | // repainted by the program | |
503 | wxRegion& GetUpdateRegion(); | |
504 | ||
505 | // get the update rectangle region bounding box in client coords | |
506 | wxRect GetUpdateClientRect() const; | |
507 | ||
508 | // these functions verify whether the given point/rectangle belongs to | |
509 | // (or at least intersects with) the update region | |
510 | bool IsExposed( int x, int y, int w=1, int h=1 ) const; | |
511 | %name(IsExposedPoint) bool IsExposed( const wxPoint& pt ) const; | |
512 | %name(isExposedRect) bool IsExposed( const wxRect& rect ) const; | |
513 | ||
514 | ||
515 | ||
516 | // colours, fonts and cursors | |
517 | // -------------------------- | |
518 | ||
519 | // set/retrieve the window colours (system defaults are used by | |
dd9f7fea | 520 | // default): Set functions return True if colour was changed |
d14a1e28 RD |
521 | virtual bool SetBackgroundColour( const wxColour &colour ); |
522 | virtual bool SetForegroundColour( const wxColour &colour ); | |
523 | ||
524 | wxColour GetBackgroundColour() const; | |
525 | wxColour GetForegroundColour() const; | |
526 | ||
dd9f7fea | 527 | // set/retrieve the cursor for this window (SetCursor() returns True |
d14a1e28 RD |
528 | // if the cursor was really changed) |
529 | virtual bool SetCursor( const wxCursor &cursor ); | |
530 | wxCursor& GetCursor(); | |
531 | ||
dd9f7fea | 532 | // set/retrieve the font for the window (SetFont() returns True if the |
d14a1e28 RD |
533 | // font really changed) |
534 | virtual bool SetFont( const wxFont &font ); | |
535 | wxFont& GetFont(); | |
536 | ||
537 | // associate a caret with the window | |
538 | void SetCaret(wxCaret *caret); | |
539 | ||
540 | // get the current caret (may be NULL) | |
541 | wxCaret *GetCaret() const; | |
542 | ||
543 | // get the (average) character size for the current font | |
544 | virtual int GetCharHeight() const; | |
545 | virtual int GetCharWidth() const; | |
546 | ||
dd9f7fea RD |
547 | |
548 | DocDeclAStr( | |
549 | void, GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT), | |
550 | "GetTextExtent(wxString string) -> (width, height)", | |
551 | "Get the width and height of the text using the current font."); | |
552 | DocDeclAStrName( | |
553 | void, GetTextExtent(const wxString& string, | |
554 | int *OUTPUT, int *OUTPUT, int *OUTPUT, int* OUTPUT, | |
555 | const wxFont* font = NULL), | |
556 | "GetFullTextExtent(wxString string, Font font=None) ->\n (width, height, descent, externalLeading)", | |
557 | "Get the width, height, decent and leading of the text using the current or specified font.", | |
558 | GetFullTextExtent); | |
559 | ||
d14a1e28 RD |
560 | |
561 | ||
562 | // client <-> screen coords | |
563 | // ------------------------ | |
564 | ||
565 | %apply int * INOUT { int* x, int* y }; | |
566 | ||
567 | // translate to/from screen/client coordinates | |
568 | %name(ClientToScreenXY) void ClientToScreen( int *x, int *y ) const; | |
569 | %name(ScreenToClientXY) void ScreenToClient( int *x, int *y ) const; | |
570 | ||
571 | wxPoint ClientToScreen(const wxPoint& pt) const; | |
572 | wxPoint ScreenToClient(const wxPoint& pt) const; | |
573 | ||
574 | // test where the given (in client coords) point lies | |
575 | %name(HitTestXY) wxHitTest HitTest(wxCoord x, wxCoord y) const; | |
576 | wxHitTest HitTest(const wxPoint& pt) const; | |
577 | ||
578 | ||
579 | ||
580 | // misc | |
581 | // ---- | |
582 | ||
583 | // get the window border style from the given flags: this is different from | |
584 | // simply doing flags & wxBORDER_MASK because it uses GetDefaultBorder() to | |
585 | // translate wxBORDER_DEFAULT to something reasonable | |
586 | %name(GetBorderFlags) wxBorder GetBorder(long flags) const; | |
587 | ||
588 | // get border for the flags of this window | |
589 | wxBorder GetBorder() const { return GetBorder(GetWindowStyleFlag()); } | |
590 | ||
dd9f7fea | 591 | // send wxUpdateUIEvents to this window, and children if recurse is True |
d14a1e28 RD |
592 | virtual void UpdateWindowUI(long flags = wxUPDATE_UI_NONE); |
593 | ||
594 | // TODO: using directors? | |
595 | // // do the window-specific processing after processing the update event | |
596 | // virtual void DoUpdateWindowUI(wxUpdateUIEvent& event) ; | |
597 | ||
598 | %name(PopupMenuXY) bool PopupMenu(wxMenu *menu, int x, int y); | |
599 | bool PopupMenu(wxMenu *menu, const wxPoint& pos); | |
600 | ||
601 | %extend { | |
602 | long GetHandle() { | |
603 | return wxPyGetWinHandle(self); | |
604 | } | |
605 | } | |
606 | ||
607 | ||
608 | #ifdef __WXMSW__ | |
609 | // A way to do the native draw first... Too bad it isn't in wxGTK too. | |
610 | void OnPaint(wxPaintEvent& event); | |
611 | #endif | |
612 | ||
613 | ||
614 | ||
615 | // scrollbars | |
616 | // ---------- | |
617 | ||
618 | // does the window have the scrollbar for this orientation? | |
619 | bool HasScrollbar(int orient) const; | |
620 | ||
621 | // configure the window scrollbars | |
622 | virtual void SetScrollbar( int orient, | |
623 | int pos, | |
624 | int thumbvisible, | |
625 | int range, | |
dd9f7fea RD |
626 | bool refresh = True ); |
627 | virtual void SetScrollPos( int orient, int pos, bool refresh = True ); | |
d14a1e28 RD |
628 | virtual int GetScrollPos( int orient ) const; |
629 | virtual int GetScrollThumb( int orient ) const; | |
630 | virtual int GetScrollRange( int orient ) const; | |
631 | ||
632 | // scroll window to the specified position | |
633 | virtual void ScrollWindow( int dx, int dy, | |
634 | const wxRect* rect = NULL ); | |
635 | ||
636 | // scrolls window by line/page: note that not all controls support this | |
637 | // | |
dd9f7fea | 638 | // return True if the position changed, False otherwise |
d14a1e28 RD |
639 | virtual bool ScrollLines(int WXUNUSED(lines)); |
640 | virtual bool ScrollPages(int WXUNUSED(pages)); | |
641 | ||
642 | // convenient wrappers for ScrollLines/Pages | |
643 | bool LineUp(); | |
644 | bool LineDown(); | |
645 | bool PageUp(); | |
646 | bool PageDown(); | |
647 | ||
648 | ||
649 | ||
650 | // context-sensitive help | |
651 | // ---------------------- | |
652 | ||
653 | // associate this help text with this window | |
654 | void SetHelpText(const wxString& text); | |
655 | ||
656 | // associate this help text with all windows with the same id as this | |
657 | // one | |
658 | void SetHelpTextForId(const wxString& text); | |
659 | ||
660 | // get the help string associated with this window (may be empty) | |
661 | wxString GetHelpText() const; | |
662 | ||
663 | ||
664 | ||
665 | // tooltips | |
666 | // -------- | |
667 | ||
668 | // the easiest way to set a tooltip for a window is to use this method | |
669 | %name(SetToolTipString) void SetToolTip( const wxString &tip ); | |
670 | ||
671 | // attach a tooltip to the window | |
672 | void SetToolTip( wxToolTip *tip ); | |
673 | ||
674 | // get the associated tooltip or NULL if none | |
675 | wxToolTip* GetToolTip() const; | |
676 | // LINK ERROR --> wxString GetToolTipText() const; | |
677 | ||
678 | ||
679 | ||
680 | // drag and drop | |
681 | // ------------- | |
682 | ||
683 | // set/retrieve the drop target associated with this window (may be | |
684 | // NULL; it's owned by the window and will be deleted by it) | |
685 | %addtofunc SetDropTarget "args[1].thisown = 0" | |
686 | virtual void SetDropTarget( wxDropTarget *dropTarget ); | |
687 | virtual wxDropTarget *GetDropTarget() const; | |
688 | ||
689 | #ifdef __WXMSW__ // TODO: should I drop-kick this? | |
690 | void DragAcceptFiles(bool accept); | |
691 | #endif | |
692 | ||
693 | ||
694 | // constraints and sizers | |
695 | // ---------------------- | |
696 | ||
697 | // set the constraints for this window or retrieve them (may be NULL) | |
698 | void SetConstraints( wxLayoutConstraints *constraints ); | |
699 | wxLayoutConstraints *GetConstraints() const; | |
700 | ||
701 | // when using constraints or sizers, it makes sense to update | |
702 | // children positions automatically whenever the window is resized | |
703 | // - this is done if autoLayout is on | |
704 | void SetAutoLayout( bool autoLayout ); | |
705 | bool GetAutoLayout() const; | |
706 | ||
707 | // lay out the window and its children | |
708 | virtual bool Layout(); | |
709 | ||
710 | // sizers | |
dd9f7fea RD |
711 | void SetSizer(wxSizer *sizer, bool deleteOld = True ); |
712 | void SetSizerAndFit( wxSizer *sizer, bool deleteOld = True ); | |
d14a1e28 RD |
713 | |
714 | wxSizer *GetSizer() const; | |
715 | ||
716 | // Track if this window is a member of a sizer | |
717 | void SetContainingSizer(wxSizer* sizer); | |
718 | wxSizer *GetContainingSizer() const; | |
719 | ||
720 | ||
721 | ||
722 | // accessibility | |
723 | // ---------------------- | |
724 | #if wxUSE_ACCESSIBILITY | |
725 | // Override to create a specific accessible object. | |
726 | virtual wxAccessible* CreateAccessible(); | |
727 | ||
728 | // Sets the accessible object. | |
729 | void SetAccessible(wxAccessible* accessible) ; | |
730 | ||
731 | // Returns the accessible object. | |
732 | wxAccessible* GetAccessible() { return m_accessible; }; | |
733 | ||
734 | // Returns the accessible object, creating if necessary. | |
735 | wxAccessible* GetOrCreateAccessible() ; | |
736 | #endif | |
737 | ||
738 | ||
739 | ||
740 | %pythoncode { | |
741 | def PostCreate(self, pre): | |
742 | """Phase 3 of the 2-phase create <wink!> | |
743 | Call this method after precreating the window with the 2-phase create method.""" | |
744 | self.this = pre.this | |
745 | self.thisown = pre.thisown | |
746 | pre.thisown = 0 | |
747 | if hasattr(self, '_setOORInfo'): | |
748 | self._setOORInfo(self) | |
749 | if hasattr(self, '_setCallbackInfo'): | |
750 | self._setCallbackInfo(self, self.__class__) | |
751 | } | |
752 | }; | |
753 | ||
754 | ||
755 | ||
756 | ||
757 | ||
758 | ||
759 | ||
760 | ||
761 | %pythoncode { | |
762 | def DLG_PNT(win, point_or_x, y=None): | |
763 | if y is None: | |
764 | return win.ConvertDialogPointToPixels(point_or_x) | |
765 | else: | |
766 | return win.ConvertDialogPointToPixels(wxPoint(point_or_x, y)) | |
767 | ||
768 | def DLG_SZE(win, size_width, height=None): | |
769 | if height is None: | |
770 | return win.ConvertDialogSizeToPixels(size_width) | |
771 | else: | |
772 | return win.ConvertDialogSizeToPixels(wxSize(size_width, height)) | |
773 | } | |
774 | ||
775 | ||
776 | ||
777 | ||
778 | // Unfortunatly the names of these new static methods clash with the | |
779 | // names wxPython has been using forever for the overloaded | |
780 | // wxWindow::FindWindow, so instead of swigging them as statics create | |
781 | // standalone functions for them. | |
782 | ||
783 | ||
784 | // Find a window among any window in the application (all return NULL if not found) | |
785 | %inline %{ | |
786 | wxWindow* wxFindWindowById( long id, const wxWindow *parent = NULL ) { | |
787 | return wxWindow::FindWindowById(id, parent); | |
788 | } | |
789 | ||
790 | wxWindow* wxFindWindowByName( const wxString& name, | |
791 | const wxWindow *parent = NULL ) { | |
792 | return wxWindow::FindWindowByName(name, parent); | |
793 | } | |
794 | ||
795 | wxWindow* wxFindWindowByLabel( const wxString& label, | |
796 | const wxWindow *parent = NULL ) { | |
797 | return wxWindow::FindWindowByLabel(label, parent); | |
798 | } | |
799 | %} | |
800 | ||
801 | ||
802 | ||
803 | %inline %{ | |
804 | wxWindow* wxWindow_FromHWND(unsigned long hWnd) { | |
805 | #ifdef __WXMSW__ | |
806 | wxWindow* win = new wxWindow; | |
807 | win->SetHWND(hWnd); | |
808 | win->SubclassWin(hWnd); | |
809 | return win; | |
810 | #else | |
811 | PyErr_SetNone(PyExc_NotImplementedError); | |
812 | return NULL; | |
813 | #endif | |
814 | } | |
815 | %} | |
816 | ||
817 | //--------------------------------------------------------------------------- | |
818 | //--------------------------------------------------------------------------- | |
819 |