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