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