]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_window.i
92c48f1a83421f8756a4c39380a7d14d3640899b
[wxWidgets.git] / wxPython / src / _window.i
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
27 DocStr(wxWindow,
28 "
29 wx.Window is the base class for all windows and represents any visible
30 object on the screen. All controls, top level windows and so on are
31 wx.Windows. Sizers and device contexts are not however, as they don't
32 appear on screen themselves.
33 ");
34
35 RefDoc(wxWindow, "
36 Styles
37
38 wx.SIMPLE_BORDER: Displays a thin border around the window.
39
40 wx.DOUBLE_BORDER: Displays a double border. Windows and Mac only.
41
42 wx.SUNKEN_BORDER: Displays a sunken border.
43
44 wx.RAISED_BORDER: Displays a raised border.
45
46 wx.STATIC_BORDER: Displays a border suitable for a static
47 control. Windows only.
48
49 wx.NO_BORDER: Displays no border, overriding the default
50 border style for the window.
51
52 wx.TRANSPARENT_WINDOW: The window is transparent, that is, it
53 will not receive paint events. Windows only.
54
55 wx.TAB_TRAVERSAL: Use this to enable tab traversal for
56 non-dialog windows.
57
58 wx.WANTS_CHARS: Use this to indicate that the window
59 wants to get all char/key events for
60 all keys - even for keys like TAB or
61 ENTER which are usually used for
62 dialog navigation and which wouldn't
63 be generated without this style. If
64 you need to use this style in order to
65 get the arrows or etc., but would
66 still like to have normal keyboard
67 navigation take place, you should
68 create and send a wxNavigationKeyEvent
69 in response to the key events for Tab
70 and Shift-Tab.
71
72 wx.NO_FULL_REPAINT_ON_RESIZE: Disables repainting the window
73 completely when its size is changed
74 - you will have to repaint the new
75 window area manually if you use this
76 style. As of version 2.5.1 this
77 style is on by default. Use
78 wx.FULL_REPAINT_ON_RESIZE to
79 deactivate it.
80
81 wx.VSCROLL: Use this style to enable a vertical scrollbar.
82
83 wx.HSCROLL: Use this style to enable a horizontal scrollbar.
84
85 wx.ALWAYS_SHOW_SB: If a window has scrollbars, disable them
86 instead of hiding them when they are
87 not needed (i.e. when the size of the
88 window is big enough to not require
89 the scrollbars to navigate it). This
90 style is currently only implemented
91 for wxMSW and wxUniversal and does
92 nothing on the other platforms.
93
94 wx.CLIP_CHILDREN: Use this style to eliminate flicker caused by
95 the background being repainted, then
96 children being painted over
97 them. Windows only.
98
99 wx.FULL_REPAINT_ON_RESIZE: Use this style to force a complete
100 redraw of the window whenever it is
101 resized instead of redrawing just the
102 part of the window affected by
103 resizing. Note that this was the
104 behaviour by default before 2.5.1
105 release and that if you experience
106 redraw problems with the code which
107 previously used to work you may want
108 to try this.
109
110 Extra Styles
111
112 wx.WS_EX_VALIDATE_RECURSIVELY: By default,
113 Validate/TransferDataTo/FromWindow()
114 only work on direct children of
115 the window (compatible
116 behaviour). Set this flag to make
117 them recursively descend into all
118 subwindows.
119
120 wx.WS_EX_BLOCK_EVENTS: wx.CommandEvents and the objects of the
121 derived classes are forwarded to
122 the parent window and so on
123 recursively by default. Using this
124 flag for the given window allows
125 to block this propagation at this
126 window, i.e. prevent the events
127 from being propagated further
128 upwards. Dialogs have this flag on
129 by default.
130
131 wx.WS_EX_TRANSIENT Don't use this window as an implicit parent for
132 the other windows: this must be
133 used with transient windows as
134 otherwise there is the risk of
135 creating a dialog/frame with this
136 window as a parent which would
137 lead to a crash if the parent is
138 destroyed before the child.
139
140 wx.WS_EX_PROCESS_IDLE: This window should always process idle
141 events, even if the mode set by
142 wx.IdleEvent.SetMode is
143 wx.IDLE_PROCESS_SPECIFIED.
144
145 wx.WS_EX_PROCESS_UI_UPDATES This window should always process UI
146 update events, even if the mode
147 set by wxUpdateUIEvent::SetMode is
148 wxUPDATE_UI_PROCESS_SPECIFIED.
149
150 ");
151
152
153
154 class wxWindow : public wxEvtHandler
155 {
156 public:
157 %pythonAppend wxWindow "self._setOORInfo(self)"
158 %pythonAppend wxWindow() ""
159
160 DocCtorStr(
161 wxWindow(wxWindow* parent, const wxWindowID id,
162 const wxPoint& pos = wxDefaultPosition,
163 const wxSize& size = wxDefaultSize,
164 long style = 0,
165 const wxString& name = wxPyPanelNameStr),
166 "Construct and show a generic Window.");
167
168 DocCtorStrName(
169 wxWindow(),
170 "Precreate a Window for 2-phase creation.",
171 PreWindow);
172
173
174 DocDeclStr(
175 bool , Create(wxWindow* parent, const wxWindowID id,
176 const wxPoint& pos = wxDefaultPosition,
177 const wxSize& size = wxDefaultSize,
178 long style = 0,
179 const wxString& name = wxPyPanelNameStr),
180 "Create the GUI part of the Window for 2-phase creation mode.");
181
182
183 // deleting the window
184 // -------------------
185
186
187 DocDeclStr(
188 bool , Close( bool force = False ),
189 "This function simply generates a EVT_CLOSE event whose handler usually
190 tries to close the window. It doesn't close the window itself,
191 however. If force is False (the default) then the window's close
192 handler will be allowed to veto the destruction of the window.
193
194 Usually Close is only used with the top level windows (wx.Frame and
195 wx.Dialog classes) as the others are not supposed to have any special
196 EVT_CLOSE logic.
197
198 The close handler should check whether the window is being deleted
199 forcibly, using wx.CloseEvent.GetForce, in which case it should
200 destroy the window using wx.Window.Destroy.
201
202 Note that calling Close does not guarantee that the window will be
203 destroyed; but it provides a way to simulate a manual close of a
204 window, which may or may not be implemented by destroying the
205 window. The default EVT_CLOSE handler for wx.Dialog does not
206 necessarily delete the dialog, since it will simply simulate an
207 wxID_CANCEL event which is handled by the appropriate button event
208 handler and may do anything at all.
209
210 To guarantee that the window will be destroyed, call wx.Window.Destroy
211 instead.");
212
213
214
215 DocDeclStr(
216 virtual bool , Destroy(),
217 "Destroys the window safely. Frames and dialogs are not destroyed
218 immediately when this function is called -- they are added to a list
219 of windows to be deleted on idle time, when all the window's events
220 have been processed. This prevents problems with events being sent to
221 non-existent windows.
222
223 Returns True if the window has either been successfully deleted, or it
224 has been added to the list of windows pending real deletion.");
225
226
227 DocDeclStr(
228 bool , DestroyChildren(),
229 "Destroys all children of a window. Called automatically by the destructor.");
230
231
232 DocDeclStr(
233 bool , IsBeingDeleted() const,
234 "Is the window in the process of being deleted?");
235
236
237
238 // window attributes
239 // -----------------
240
241 DocDeclStr(
242 virtual void , SetTitle( const wxString& title),
243 "Sets the window's title. Applicable only to frames and dialogs.");
244
245 DocDeclStr(
246 virtual wxString , GetTitle() const,
247 "Gets the window's title. Applicable only to frames and dialogs.");
248
249
250 DocDeclStr(
251 virtual void , SetLabel(const wxString& label),
252 "Set the text which the window shows in its label if applicable.");
253
254 DocDeclStr(
255 virtual wxString , GetLabel() const,
256 "Generic way of getting a label from any window, for identification
257 purposes. The interpretation of this function differs from class to
258 class. For frames and dialogs, the value returned is the title. For
259 buttons or static text controls, it is the button text. This function
260 can be useful for meta-programs (such as testing tools or
261 special-needs access programs) which need to identify windows by name.");
262
263
264 // the window name is used for ressource setting in X, it is not the
265 // same as the window title/label
266 DocDeclStr(
267 virtual void , SetName( const wxString &name ),
268 "Sets the window's name. The window name is used for ressource setting
269 in X, it is not the same as the window title/label");
270
271 DocDeclStr(
272 virtual wxString , GetName() const,
273 "Returns the window's name. This name is not guaranteed to be unique;
274 it is up to the programmer to supply an appropriate name in the window
275 constructor or via wx.Window.SetName.");
276
277
278 // window id uniquely identifies the window among its siblings unless
279 // it is -1 which means "don't care"
280 DocDeclStr(
281 void , SetId( wxWindowID winid ),
282 "Sets the identifier of the window. Each window has an integer
283 identifier. If the application has not provided one, an identifier
284 will be generated. Normally, the identifier should be provided on
285 creation and should not be modified subsequently.");
286
287 DocDeclStr(
288 wxWindowID , GetId() const,
289 "Returns the identifier of the window. Each window has an integer
290 identifier. If the application has not provided one (or the default Id
291 -1 is used) then an unique identifier with a negative value will be
292 generated.");
293
294
295 DocDeclStr(
296 static int , NewControlId(),
297 "Generate a control id for the controls which were not given one.");
298
299
300 DocDeclStr(
301 static int , NextControlId(int winid),
302 "Get the id of the control following the one with the given\n"
303 "(autogenerated) id");
304
305
306 DocDeclStr(
307 static int , PrevControlId(int winid),
308 "Get the id of the control preceding the one with the given\n"
309 "(autogenerated) id");
310
311
312
313
314 // moving/resizing
315 // ---------------
316
317
318 DocDeclStr(
319 void , SetSize( const wxSize& size ),
320 "Sets the size of the window in pixels.");
321
322
323 DocDeclStrName(
324 void , SetSize( int x, int y, int width, int height,
325 int sizeFlags = wxSIZE_AUTO ),
326 "Sets the position and size of the window in pixels. The sizeFlags
327 parameter indicates the interpretation of the other params if they are
328 -1. wx.SIZE_AUTO*: a -1 indicates that a class-specific default
329 shoudl be used. wx.SIZE_USE_EXISTING: existing dimensions should be
330 used if -1 values are supplied. wxSIZE_ALLOW_MINUS_ONE: allow
331 dimensions of -1 and less to be interpreted as real dimensions, not
332 default values.",
333 SetDimensions);
334
335
336 DocDeclStrName(
337 void , SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO),
338 "Sets the position and size of the window in pixels using a wx.Rect.",
339 SetRect);
340
341
342 DocDeclStrName(
343 void , SetSize( int width, int height ),
344 "Sets the size of the window in pixels.",
345 SetSizeWH);
346
347
348 DocDeclStr(
349 void , Move(const wxPoint& pt, int flags = wxSIZE_USE_EXISTING),
350 "Moves the window to the given position.");
351
352 %pythoncode { SetPosition = Move }
353
354
355 DocDeclStrName(
356 void , Move(int x, int y, int flags = wxSIZE_USE_EXISTING),
357 "Moves the window to the given position.",
358 MoveXY);
359
360
361
362 DocDeclStr(
363 virtual void , Raise(),
364 "Raises the window to the top of the window hierarchy if it is a
365 managed window (dialog or frame).");
366
367 DocDeclStr(
368 virtual void , Lower(),
369 "Lowers the window to the bottom of the window hierarchy if it is a
370 managed window (dialog or frame).");
371
372
373
374 // client size is the size of the area available for subwindows
375 DocStr(SetClientSize,
376 "This sets the size of the window client area in pixels. Using this
377 function to size a window tends to be more device-independent than
378 wx.Window.SetSize, since the application need not worry about what
379 dimensions the border or title bar have when trying to fit the window
380 around panel items, for example.");
381 void SetClientSize( const wxSize& size );
382 %name(SetClientSizeWH) void SetClientSize( int width, int height );
383 %name(SetClientRect) void SetClientSize(const wxRect& rect);
384
385
386 DocStr(GetPosition, // sets the docstring for both
387 "Get the window's position.");
388 wxPoint GetPosition();
389
390 DocDeclAName(
391 void, GetPosition(int *OUTPUT, int *OUTPUT),
392 "GetPositionTuple() -> (x,y)",
393 GetPositionTuple);
394
395
396 DocStr(GetSize, "Get the window size.");
397 wxSize GetSize() const;
398 DocDeclAName(
399 void, GetSize( int *OUTPUT, int *OUTPUT ) const,
400 "GetSizeTuple() -> (width, height)",
401 GetSizeTuple);
402
403
404
405 DocDeclStr(
406 wxRect , GetRect() const,
407 "Returns the size and position of the window as a wx.Rect object.");
408
409
410 DocStr(GetClientSize,
411 "This gets the size of the window's 'client area' in pixels. The client
412 area is the area which may be drawn on by the programmer, excluding
413 title bar, border, scrollbars, etc.");
414 wxSize GetClientSize() const;
415 DocDeclAName(
416 void, GetClientSize( int *OUTPUT, int *OUTPUT ) const,
417 "GetClientSizeTuple() -> (width, height)",
418 GetClientSizeTuple);
419
420
421
422 DocDeclStr(
423 virtual wxPoint , GetClientAreaOrigin() const,
424 "Get the origin of the client area of the window relative to the
425 window's top left corner (the client area may be shifted because of
426 the borders, scrollbars, other decorations...)");
427
428
429 DocDeclStr(
430 wxRect , GetClientRect() const,
431 "Get the client area position and size as a wx.Rect object.");
432
433
434
435 DocStr(GetBestSize,
436 "This functions returns the best acceptable minimal size for the
437 window, if applicable. For example, for a static text control, it will be
438 the minimal size such that the control label is not truncated. For
439 windows containing subwindows (suzh aswx.Panel), the size returned
440 by this function will be the same as the size the window would have
441 had after calling Fit.");
442 wxSize GetBestSize() const;
443 DocDeclAName(
444 void, GetBestSize(int *OUTPUT, int *OUTPUT) const,
445 "GetBestSizeTuple() -> (width, height)",
446 GetBestSizeTuple);
447
448
449 DocDeclStr(
450 wxSize , GetAdjustedBestSize() const,
451 "This method is similar to GetBestSize, except in one
452 thing. GetBestSize should return the minimum untruncated size of the
453 window, while this method will return the largest of BestSize and any
454 user specified minimum size. ie. it is the minimum size the window
455 should currently be drawn at, not the minimal size it can possibly
456 tolerate.");
457
458
459
460
461 DocDeclStr(
462 void , Center( int direction = wxBOTH ),
463 "Centers the window. The parameter specifies the direction for
464 cetering, and may be wx.HORIZONTAL, wx.VERTICAL or wx.BOTH. It may
465 also include wx.CENTER_ON_SCREEN flag if you want to center the window
466 on the entire screen and not on its parent window. If it is a
467 top-level window and has no parent then it will always be centered
468 relative to the screen.");
469
470 %pythoncode { Centre = Center }
471
472
473 DocDeclStr(
474 void , CenterOnScreen(int dir = wxBOTH),
475 "Center on screen (only works for top level windows)");
476 %pythoncode { CentreOnScreen = CenterOnScreen }
477
478
479 DocDeclStr(
480 void , CenterOnParent(int dir = wxBOTH),
481 "Center with respect to the the parent window");
482 %pythoncode { CentreOnParent = CenterOnParent }
483
484
485
486 DocDeclStr(
487 virtual void , Fit(),
488 "Sizes the window so that it fits around its subwindows. This function
489 won't do anything if there are no subwindows and will only really work
490 correctly if sizers are used for the subwindows layout. Also, if the
491 window has exactly one subwindow it is better (faster and the result
492 is more precise as Fit adds some margin to account for fuzziness of
493 its calculations) to call window.SetClientSize(child.GetSize())
494 instead of calling Fit.");
495
496
497 DocDeclStr(
498 virtual void , FitInside(),
499 "Similar to Fit, but sizes the interior (virtual) size of a
500 window. Mainly useful with scrolled windows to reset scrollbars after
501 sizing changes that do not trigger a size event, and/or scrolled
502 windows without an interior sizer. This function similarly won't do
503 anything if there are no subwindows.");
504
505
506
507 DocDeclStr(
508 virtual void , SetSizeHints( int minW, int minH,
509 int maxW = -1, int maxH = -1,
510 int incW = -1, int incH = -1 ),
511 "Allows specification of minimum and maximum window sizes, and window
512 size increments. If a pair of values is not set (or set to -1), the
513 default values will be used. If this function is called, the user
514 will not be able to size the window outside the given bounds. The
515 resizing increments are only significant under Motif or Xt.");
516
517
518 DocDeclStr(
519 virtual void , SetVirtualSizeHints( int minW, int minH,
520 int maxW = -1, int maxH = -1 ),
521 "Allows specification of minimum and maximum virtual window sizes. If a
522 pair of values is not set (or set to -1), the default values will be
523 used. If this function is called, the user will not be able to size
524 the virtual area of the window outside the given bounds.");
525
526
527 DocDeclStr(
528 virtual int , GetMinWidth() const,
529 "");
530
531 DocDeclStr(
532 virtual int , GetMinHeight() const,
533 "");
534
535 DocDeclStr(
536 int , GetMaxWidth() const,
537 "");
538
539 DocDeclStr(
540 int , GetMaxHeight() const,
541 "");
542
543
544 DocDeclStr(
545 virtual wxSize , GetMaxSize() const,
546 "");
547
548
549
550 DocStr(SetVirtualSize,
551 "Set the the virtual size of a window in pixels. For most windows this
552 is just the client area of the window, but for some like scrolled
553 windows it is more or less independent of the screen window size.");
554 void SetVirtualSize(const wxSize& size );
555 %name(SetVirtualSizeWH) void SetVirtualSize( int w, int h );
556
557
558 DocStr(GetVirtualSize,
559 "Get the the virtual size of the window in pixels. For most windows
560 this is just the client area of the window, but for some like scrolled
561 windows it is more or less independent of the screen window size.");
562 wxSize GetVirtualSize() const;
563 DocDeclAName(
564 void, GetVirtualSize( int *OUTPUT, int *OUTPUT ) const,
565 "GetVirtualSizeTuple() -> (width, height)",
566 GetVirtualSizeTuple);
567
568
569 // TODO: using directors?
570 // // Override these methods for windows that have a virtual size
571 // // independent of their client size. eg. the virtual area of a
572 // // wxScrolledWindow. Default is to alias VirtualSize to ClientSize.
573 // virtual void DoSetVirtualSize( int x, int y );
574 // virtual wxSize DoGetVirtualSize() const; // { return m_virtualSize; }
575
576
577 DocDeclStr(
578 virtual wxSize , GetBestVirtualSize() const,
579 "Return the largest of ClientSize and BestSize (as determined by a
580 sizer, interior children, or other means)");
581
582
583
584 // window state
585 // ------------
586
587 DocDeclStr(
588 virtual bool , Show( bool show = True ),
589 "Shows or hides the window. You may need to call Raise for a top level
590 window if you want to bring it to top, although this is not needed if
591 Show() is called immediately after the frame creation. Returns true
592 if the window has been shown or hidden or false if nothing was done
593 because it already was in the requested state.");
594
595 DocDeclStr(
596 bool , Hide(),
597 "Equivalent to calling Show(False).");
598
599
600 DocDeclStr(
601 virtual bool , Enable( bool enable = True ),
602 "Enable or disable the window for user input. Note that when a parent
603 window is disabled, all of its children are disabled as well and they
604 are reenabled again when the parent is. Returns true if the window
605 has been enabled or disabled, false if nothing was done, i.e. if the
606 window had already been in the specified state.");
607
608 DocDeclStr(
609 bool , Disable(),
610 "Disables the window, same as Enable(false).");
611
612
613 DocDeclStr(
614 bool , IsShown() const,
615 "Returns true if the window is shown, false if it has been hidden.");
616
617 DocDeclStr(
618 bool , IsEnabled() const,
619 "Returns true if the window is enabled for input, false otherwise.");
620
621
622
623
624 DocDeclStr(
625 virtual void , SetWindowStyleFlag( long style ),
626 "Sets the style of the window. Please note that some styles cannot be
627 changed after the window creation and that Refresh() might be called
628 after changing the others for the change to take place immediately.");
629
630 DocDeclStr(
631 virtual long , GetWindowStyleFlag() const,
632 "Gets the window style that was passed to the constructor or Create method.");
633
634 %pythoncode { SetWindowStyle = SetWindowStyleFlag; GetWindowStyle = GetWindowStyleFlag }
635
636
637 DocDeclStr(
638 bool , HasFlag(int flag) const,
639 "Test if the given style is set for this window.");
640
641
642 DocDeclStr(
643 virtual bool , IsRetained() const,
644 "Returns true if the window is retained, false otherwise. Retained
645 windows are only available on X platforms.");
646
647
648
649 DocDeclStr(
650 virtual void , SetExtraStyle(long exStyle),
651 "Sets the extra style bits for the window. Extra styles are the less
652 often used style bits which can't be set with the constructor or with
653 SetWindowStyleFlag()");
654
655 DocDeclStr(
656 long , GetExtraStyle() const,
657 "Returns the extra style bits for the window.");
658
659
660
661 DocDeclStr(
662 virtual void , MakeModal(bool modal = True),
663 "Disables all other windows in the application so that the user can
664 only interact with this window. Passing False will reverse this
665 effect.");
666
667
668
669 DocDeclStr(
670 virtual void , SetThemeEnabled(bool enableTheme),
671 "This function tells a window if it should use the system's \"theme\"
672 code to draw the windows' background instead if its own background
673 drawing code. This will only have an effect on platforms that support
674 the notion of themes in user defined windows. One such platform is
675 GTK+ where windows can have (very colourful) backgrounds defined by a
676 user's selected theme.
677
678 Dialogs, notebook pages and the status bar have this flag set to true
679 by default so that the default look and feel is simulated best.");
680
681 DocDeclStr(
682 virtual bool , GetThemeEnabled() const,
683 "Return the themeEnabled flag.");
684
685
686 // TODO with directors
687 // // controls by default inherit the colours of their parents, if a
688 // // particular control class doesn't want to do it, it can override
689 // // ShouldInheritColours() to return False
690 // virtual bool ShouldInheritColours() const;
691
692
693
694
695
696 // focus and keyboard handling
697 // ---------------------------
698
699
700 DocDeclStr(
701 virtual void , SetFocus(),
702 "Set's the focus to this window, allowing it to receive keyboard input.");
703
704 DocDeclStr(
705 virtual void , SetFocusFromKbd(),
706 "Set focus to this window as the result of a keyboard action. Normally
707 only called internally.");
708
709
710
711 DocDeclStr(
712 static wxWindow *, FindFocus(),
713 "Returns the window or control that currently has the keyboard focus,
714 or None.");
715
716
717 DocDeclStr(
718 virtual bool , AcceptsFocus() const,
719 "Can this window have focus?");
720
721
722 DocDeclStr(
723 virtual bool , AcceptsFocusFromKeyboard() const,
724 "Can this window be given focus by keyboard navigation? if not, the
725 only way to give it focus (provided it accepts it at all) is to click
726 it.
727 ");
728
729
730
731
732 DocDeclStr(
733 virtual wxWindow *, GetDefaultItem() const,
734 "Get the default child of this parent, i.e. the one which is activated
735 by pressing <Enter> such as the OK button on a wx.Dialog.
736 ");
737
738 DocDeclStr(
739 virtual wxWindow *, SetDefaultItem(wxWindow * child),
740 "Set this child as default, return the old default.");
741
742 DocDeclStr(
743 virtual void , SetTmpDefaultItem(wxWindow * win),
744 "Set this child as temporary default");
745
746
747
748
749
750 // parent/children relations
751 // -------------------------
752
753
754 //wxWindowList& GetChildren(); // TODO: Do a typemap or a wrapper for wxWindowList
755 %extend {
756 DocStr(GetChildren,
757 "Returns a list of the window's children. NOTE: Currently this is a
758 copy of the child window list maintained by the window, so the return
759 value of this function is only valid as long as the window's children
760 do not change.");
761 PyObject* GetChildren() {
762 wxWindowList& list = self->GetChildren();
763 return wxPy_ConvertList(&list);
764 }
765 }
766
767 DocDeclStr(
768 wxWindow *, GetParent() const,
769 "Returns the parent window of this window, or None if there isn't one.");
770
771 DocDeclStr(
772 wxWindow *, GetGrandParent() const,
773 "Returns the parent of the parent of this window, or None if there isn't one.");
774
775
776
777 DocDeclStr(
778 virtual bool , IsTopLevel() const,
779 "Returns true if the given window is a top-level one. Currently all
780 frames and dialogs are always considered to be top-level windows (even
781 if they have a parent window).");
782
783
784 // change the real parent of this window, return True if the parent
785 // was changed, False otherwise (error or newParent == oldParent)
786 DocDeclStr(
787 virtual bool , Reparent( wxWindow *newParent ),
788 "Reparents the window, i.e the window will be removed from its current
789 parent window (e.g. a non-standard toolbar in a wxFrame) and then
790 re-inserted into another. Available on Windows and GTK. Returns True
791 if the parent was changed, False otherwise (error or newParent ==
792 oldParent)");
793
794
795 DocDeclStr(
796 virtual void , AddChild( wxWindow *child ),
797 "Adds a child window. This is called automatically by window creation
798 functions so should not be required by the application programmer.");
799
800 DocDeclStr(
801 virtual void , RemoveChild( wxWindow *child ),
802 "Removes a child window. This is called automatically by window
803 deletion functions so should not be required by the application
804 programmer.");
805
806
807
808
809 // looking for windows
810 // -------------------
811
812 DocDeclStrName(
813 wxWindow *, FindWindow( long winid ),
814 "Find a chld of this window by window ID",
815 FindWindowById);
816
817 DocDeclStrName(
818 wxWindow *, FindWindow( const wxString& name ),
819 "Find a child of this window by name",
820 FindWindowByName);
821
822
823
824 // event handler stuff
825 // -------------------
826
827 DocDeclStr(
828 wxEvtHandler *, GetEventHandler() const,
829 "Returns the event handler for this window. By default, the window is
830 its own event handler.");
831
832
833 DocDeclStr(
834 void , SetEventHandler( wxEvtHandler *handler ),
835 "Sets the event handler for this window. An event handler is an object
836 that is capable of processing the events sent to a window. By default,
837 the window is its own event handler, but an application may wish to
838 substitute another, for example to allow central implementation of
839 event-handling for a variety of different window classes.
840
841 It is usually better to use wx.Window.PushEventHandler since this sets
842 up a chain of event handlers, where an event not handled by one event
843 handler is handed to the next one in the chain.");
844
845
846 DocDeclStr(
847 void , PushEventHandler( wxEvtHandler *handler ),
848 "Pushes this event handler onto the event handler stack for the window.
849 An event handler is an object that is capable of processing the events
850 sent to a window. By default, the window is its own event handler, but
851 an application may wish to substitute another, for example to allow
852 central implementation of event-handling for a variety of different
853 window classes.
854
855 wx.Window.PushEventHandler allows an application to set up a chain of
856 event handlers, where an event not handled by one event handler is
857 handed to the next one in the chain. Use wx.Window.PopEventHandler to
858 remove the event handler.");
859
860
861 DocDeclStr(
862 wxEvtHandler *, PopEventHandler( bool deleteHandler = False ),
863 "Removes and returns the top-most event handler on the event handler
864 stack. If deleteHandler is True then the wx.EvtHandler object will be
865 destroyed after it is popped.");
866
867
868 DocDeclStr(
869 bool , RemoveEventHandler(wxEvtHandler *handler),
870 "Find the given handler in the event handler chain and remove (but
871 not delete) it from the event handler chain, return True if it was
872 found and False otherwise (this also results in an assert failure so
873 this function should only be called when the handler is supposed to
874 be there.)");
875
876
877
878
879 // validators
880 // ----------
881
882 // a window may have an associated validator which is used to control
883 // user input
884 DocDeclStr(
885 virtual void , SetValidator( const wxValidator &validator ),
886 "Deletes the current validator (if any) and sets the window validator,
887 having called wx.Validator.Clone to create a new validator of this
888 type.");
889
890 DocDeclStr(
891 virtual wxValidator *, GetValidator(),
892 "Returns a pointer to the current validator for the window, or None if
893 there is none.");
894
895
896
897 // accelerators
898 // ------------
899
900 DocDeclStr(
901 virtual void , SetAcceleratorTable( const wxAcceleratorTable& accel ),
902 "Sets the accelerator table for this window.");
903
904 DocDeclStr(
905 wxAcceleratorTable *, GetAcceleratorTable(),
906 "Gets the accelerator table for this window.");
907
908
909
910
911
912 // hot keys (system wide accelerators)
913 // -----------------------------------
914 %extend {
915 DocStr(RegisterHotKey,
916 "Registers a system wide hotkey. Every time the user presses the hotkey
917 registered here, this window will receive a hotkey event. It will
918 receive the event even if the application is in the background and
919 does not have the input focus because the user is working with some
920 other application. To bind an event handler function to this hotkey
921 use EVT_HOTKEY with an id equal to hotkeyId. Returns True if the
922 hotkey was registered successfully.");
923 bool RegisterHotKey(int hotkeyId, int modifiers, int keycode) {
924 #if wxUSE_HOTKEY
925 return self->RegisterHotKey(hotkeyId, modifiers, keycode);
926 #else
927 return False;
928 #endif
929 }
930
931
932 DocStr(UnregisterHotKey,
933 "Unregisters a system wide hotkey.");
934 bool UnregisterHotKey(int hotkeyId) {
935 #if wxUSE_HOTKEY
936 return self->UnregisterHotKey(hotkeyId);
937 #else
938 return False;
939 #endif
940 }
941 }
942
943
944
945 // "dialog units" translations
946 // ---------------------------
947
948 DocStr(ConvertDialogToPixels,
949 "Converts a point or size from dialog units to pixels. Dialog units are
950 used for maintaining a dialog's proportions even if the font
951 changes. For the x dimension, the dialog units are multiplied by the
952 average character width and then divided by 4. For the y dimension,
953 the dialog units are multiplied by the average character height and
954 then divided by 8.");
955 %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt);
956 %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz);
957 %name(DLG_PNT) wxPoint ConvertDialogToPixels(const wxPoint& pt);
958 %name(DLG_SZE) wxSize ConvertDialogToPixels(const wxSize& sz);
959
960
961 DocStr(ConvertPixelPointToDialog,
962 "Converts a point or size from pixels to dialog units. Dialog units
963 are used for maintaining a dialog's proportions even if the font
964 changes. For the x dimension, the dialog units are multiplied by the
965 average character width and then divided by 4. For the y dimension,
966 the dialog units are multiplied by the average character height and
967 then divided by 8.");
968 %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt);
969 %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz);
970
971
972
973 // mouse functions
974 // ---------------
975
976 DocDeclStr(
977 virtual void , WarpPointer(int x, int y),
978 "Moves the pointer to the given position on the window.
979
980 NOTE: This function is not supported under Mac because Apple Human
981 Interface Guidelines forbid moving the mouse cursor programmatically.");
982
983
984 DocDeclStr(
985 void , CaptureMouse(),
986 "Directs all mouse input to this window. Call wx.Window.ReleaseMouse to
987 release the capture.
988
989 Note that wxWindows maintains the stack of windows having captured the
990 mouse and when the mouse is released the capture returns to the window
991 which had had captured it previously and it is only really released if
992 there were no previous window. In particular, this means that you must
993 release the mouse as many times as you capture it.");
994
995 DocDeclStr(
996 void , ReleaseMouse(),
997 "Releases mouse input captured with wx.Window.CaptureMouse.");
998
999
1000 DocDeclStr(
1001 static wxWindow *, GetCapture(),
1002 "Returns the window which currently captures the mouse or None");
1003
1004
1005 DocDeclStr(
1006 virtual bool , HasCapture() const,
1007 "Returns true if this window has the current mouse capture.");
1008
1009
1010
1011
1012
1013 // painting the window
1014 // -------------------
1015
1016 DocDeclStr(
1017 virtual void , Refresh( bool eraseBackground = True,
1018 const wxRect *rect = NULL ),
1019 "Mark the specified rectangle (or the whole window) as \"dirty\" so it
1020 will be repainted. Causes an EVT_PAINT event to be generated and sent
1021 to the window.");
1022
1023
1024 DocDeclStr(
1025 void , RefreshRect(const wxRect& rect),
1026 "Redraws the contents of the given rectangle: the area inside it will
1027 be repainted. This is the same as Refresh but has a nicer syntax.");
1028
1029
1030 DocDeclStr(
1031 virtual void , Update(),
1032 "Calling this method immediately repaints the invalidated area of the
1033 window instead of waiting for the EVT_PAINT event to happen, (normally
1034 this would usually only happen when the flow of control returns to the
1035 event loop.) Notice that this function doesn't refresh the window and
1036 does nothing if the window has been already repainted. Use Refresh
1037 first if you want to immediately redraw the window (or some portion of
1038 it) unconditionally.");
1039
1040
1041 DocDeclStr(
1042 virtual void , ClearBackground(),
1043 "Clears the window by filling it with the current background
1044 colour. Does not cause an erase background event to be generated.");
1045
1046
1047
1048 DocDeclStr(
1049 virtual void , Freeze(),
1050 "Freezes the window or, in other words, prevents any updates from
1051 taking place on screen, the window is not redrawn at all. Thaw must be
1052 called to reenable window redrawing.
1053
1054 This method is useful for visual appearance optimization (for example,
1055 it is a good idea to use it before inserting large amount of text into
1056 a wxTextCtrl under wxGTK) but is not implemented on all platforms nor
1057 for all controls so it is mostly just a hint to wxWindows and not a
1058 mandatory directive.");
1059
1060
1061 DocDeclStr(
1062 virtual void , Thaw(),
1063 "Reenables window updating after a previous call to Freeze.");
1064
1065
1066 DocDeclStr(
1067 virtual void , PrepareDC( wxDC & dc ),
1068 "Call this function to prepare the device context for drawing a
1069 scrolled image. It sets the device origin according to the current
1070 scroll position.");
1071
1072
1073 DocDeclStr(
1074 wxRegion& , GetUpdateRegion(),
1075 "Returns the region specifying which parts of the window have been
1076 damaged. Should only be called within an EVT_PAINT handler.");
1077
1078
1079 DocDeclStr(
1080 wxRect , GetUpdateClientRect() const,
1081 "Get the update rectangle region bounding box in client coords.");
1082
1083
1084 DocStr(IsExposed,
1085 "Returns true if the given point or rectangle area has been exposed
1086 since the last repaint. Call this in an paint event handler to
1087 optimize redrawing by only redrawing those areas, which have been
1088 exposed.");
1089 bool IsExposed( int x, int y, int w=1, int h=1 ) const;
1090 %name(IsExposedPoint) bool IsExposed( const wxPoint& pt ) const;
1091 %name(isExposedRect) bool IsExposed( const wxRect& rect ) const;
1092
1093
1094
1095 // colours, fonts and cursors
1096 // --------------------------
1097
1098 // set/retrieve the window colours (system defaults are used by
1099 // default): Set functions return True if colour was changed
1100
1101
1102
1103 DocDeclStr(
1104 virtual bool , SetBackgroundColour( const wxColour &colour ),
1105 "Sets the background colour of the window. Returns True if the colour
1106 was changed. The background colour is usually painted by the default
1107 EVT_ERASE_BACKGROUND event handler function under Windows and
1108 automatically under GTK.
1109
1110 Note that setting the background colour does not cause an immediate
1111 refresh, so you may wish to call ClearBackground or Refresh after
1112 calling this function.
1113
1114 Use this function with care under GTK+ as the new appearance of the
1115 window might not look equally well when used with themes, i.e GTK+'s
1116 ability to change its look as the user wishes with run-time loadable
1117 modules.");
1118
1119 DocDeclStr(
1120 virtual bool , SetForegroundColour( const wxColour &colour ),
1121 "Sets the foreground colour of the window. Returns True is the colour
1122 was changed. The interpretation of foreground colour is dependent on
1123 the window class; it may be the text colour or other colour, or it may
1124 not be used at all.");
1125
1126
1127 DocDeclStr(
1128 wxColour , GetBackgroundColour() const,
1129 "Returns the background colour of the window.");
1130
1131 DocDeclStr(
1132 wxColour , GetForegroundColour() const,
1133 "Returns the foreground colour of the window. The interpretation of
1134 foreground colour is dependent on the window class; it may be the text
1135 colour or other colour, or it may not be used at all.");
1136
1137
1138
1139
1140 DocDeclStr(
1141 virtual bool , SetCursor( const wxCursor &cursor ),
1142 "Sets the window's cursor. Notice that the window cursor also sets it
1143 for the children of the window implicitly.
1144
1145 The cursor may be wx.NullCursor in which case the window cursor will
1146 be reset back to default.");
1147
1148 DocDeclStr(
1149 wxCursor& , GetCursor(),
1150 "Return the cursor associated with this window.");
1151
1152
1153
1154 DocDeclStr(
1155 virtual bool , SetFont( const wxFont &font ),
1156 "Sets the font for this window.");
1157
1158 DocDeclStr(
1159 wxFont& , GetFont(),
1160 "Returns a reference to the font for this window.");
1161
1162
1163
1164 DocDeclStr(
1165 void , SetCaret(wxCaret *caret),
1166 "Sets the caret associated with the window.");
1167
1168 DocDeclStr(
1169 wxCaret *, GetCaret() const,
1170 "Returns the caret associated with the window.");
1171
1172
1173
1174 DocDeclStr(
1175 virtual int , GetCharHeight() const,
1176 "Get the (average) character size for the current font.");
1177
1178 DocDeclStr(
1179 virtual int , GetCharWidth() const,
1180 "Get the (average) character size for the current font.");
1181
1182
1183
1184 DocDeclAStr(
1185 void, GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT),
1186 "GetTextExtent(String string) -> (width, height)",
1187 "Get the width and height of the text using the current font.");
1188 DocDeclAStrName(
1189 void, GetTextExtent(const wxString& string,
1190 int *OUTPUT, int *OUTPUT, int *OUTPUT, int* OUTPUT,
1191 const wxFont* font = NULL),
1192 "GetFullTextExtent(String string, Font font=None) ->\n (width, height, descent, externalLeading)",
1193 "Get the width, height, decent and leading of the text using the
1194 current or specified font.",
1195 GetFullTextExtent);
1196
1197
1198
1199 // client <-> screen coords
1200 // ------------------------
1201
1202 %apply int * INOUT { int* x, int* y };
1203
1204 // translate to/from screen/client coordinates
1205 DocDeclAStrName(
1206 void , ClientToScreen( int *x, int *y ) const,
1207 "ClientToScreenXY(int x, int y) -> (x,y)",
1208 "Converts to screen coordinates from coordinates relative to this window.",
1209 ClientToScreenXY);
1210
1211 DocDeclAStrName(
1212 void , ScreenToClient( int *x, int *y ) const,
1213 "ScreenToClientXY(int x, int y) -> (x,y)",
1214 "Converts from screen to client window coordinates.",
1215 ScreenToClientXY);
1216
1217
1218 DocDeclStr(
1219 wxPoint , ClientToScreen(const wxPoint& pt) const,
1220 "Converts to screen coordinates from coordinates relative to this window.");
1221
1222 DocDeclStr(
1223 wxPoint , ScreenToClient(const wxPoint& pt) const,
1224 "Converts from screen to client window coordinates.");
1225
1226
1227
1228 DocDeclStrName(
1229 wxHitTest , HitTest(wxCoord x, wxCoord y) const,
1230 "Test where the given (in client coords) point lies",
1231 HitTestXY);
1232
1233 DocDeclStr(
1234 wxHitTest , HitTest(const wxPoint& pt) const,
1235 "Test where the given (in client coords) point lies");
1236
1237
1238
1239
1240 // misc
1241 // ----
1242
1243 %nokwargs GetBorder;
1244 DocDeclStr(
1245 wxBorder , GetBorder(long flags) const,
1246 "Get the window border style from the given flags: this is different
1247 from simply doing flags & wxBORDER_MASK because it uses
1248 GetDefaultBorder() to translate wxBORDER_DEFAULT to something
1249 reasonable.
1250 ");
1251
1252 DocDeclStr(
1253 wxBorder , GetBorder() const,
1254 "Get border for the flags of this window");
1255
1256
1257
1258
1259 DocDeclStr(
1260 virtual void , UpdateWindowUI(long flags = wxUPDATE_UI_NONE),
1261 "This function sends EVT_UPDATE_UI events to the window. The particular
1262 implementation depends on the window; for example a wx.ToolBar will
1263 send an update UI event for each toolbar button, and a wx.Frame will
1264 send an update UI event for each menubar menu item. You can call this
1265 function from your application to ensure that your UI is up-to-date at
1266 a particular point in time (as far as your EVT_UPDATE_UI handlers are
1267 concerned). This may be necessary if you have called
1268 wx.UpdateUIEvent.SetMode or wx.UpdateUIEvent.SetUpdateInterval to
1269 limit the overhead that wxWindows incurs by sending update UI events
1270 in idle time.
1271
1272 The flags should be a bitlist of one or more of the following values:
1273
1274 wx.UPDATE_UI_NONE No particular value
1275 wx.UPDATE_UI_RECURSE Call the function for descendants
1276 wx.UPDATE_UI_FROMIDLE Invoked from OnIdle
1277
1278 If you are calling this function from an OnIdle function, make sure
1279 you pass the wx.UPDATE_UI_FROMIDLE flag, since this tells the window to
1280 only update the UI elements that need to be updated in idle time. Some
1281 windows update their elements only when necessary, for example when a
1282 menu is about to be shown. The following is an example of how to call
1283 UpdateWindowUI from an idle function.
1284
1285 def OnIdle(self, evt):
1286 if wx.UpdateUIEvent.CanUpdate(self):
1287 self.UpdateWindowUI(wx.UPDATE_UI_FROMIDLE);
1288 ");
1289
1290
1291 // TODO: using directors?
1292 // // do the window-specific processing after processing the update event
1293 // virtual void DoUpdateWindowUI(wxUpdateUIEvent& event) ;
1294
1295
1296 DocStr(PopupMenu,
1297 "Pops up the given menu at the specified coordinates, relative to this
1298 window, and returns control when the user has dismissed the menu. If a
1299 menu item is selected, the corresponding menu event is generated and
1300 will be processed as usual.");
1301 %name(PopupMenuXY) bool PopupMenu(wxMenu *menu, int x, int y);
1302 bool PopupMenu(wxMenu *menu, const wxPoint& pos);
1303
1304
1305
1306
1307 %extend {
1308 DocStr(GetHandle,
1309 "Returns the platform-specific handle (as a long integer) of the
1310 physical window. Currently on wxMac it returns the handle of the
1311 toplevel parent of the window.");
1312 long GetHandle() {
1313 return wxPyGetWinHandle(self);
1314 }
1315 }
1316
1317
1318
1319 #ifdef __WXMSW__
1320 // A way to do the native draw first... Too bad it isn't in wxGTK too.
1321 void OnPaint(wxPaintEvent& event);
1322 #endif
1323
1324
1325
1326 // scrollbars
1327 // ----------
1328
1329
1330 DocDeclStr(
1331 bool , HasScrollbar(int orient) const,
1332 "Does the window have the scrollbar for this orientation?");
1333
1334
1335 // configure the window scrollbars
1336 DocDeclStr(
1337 virtual void , SetScrollbar( int orientation,
1338 int pos,
1339 int thumbvisible,
1340 int range,
1341 bool refresh = True ),
1342 "Sets the scrollbar properties of a built-in scrollbar.
1343
1344 orientation: Determines the scrollbar whose page size is to be
1345 set. May be wx.HORIZONTAL or wx.VERTICAL.
1346
1347 position: The position of the scrollbar in scroll units.
1348
1349 thumbSize: The size of the thumb, or visible portion of the
1350 scrollbar, in scroll units.
1351
1352 range: The maximum position of the scrollbar.
1353
1354 refresh: True to redraw the scrollbar, false otherwise.");
1355
1356 DocDeclStr(
1357 virtual void , SetScrollPos( int orientation, int pos, bool refresh = True ),
1358 "Sets the position of one of the built-in scrollbars.");
1359
1360 DocDeclStr(
1361 virtual int , GetScrollPos( int orientation ) const,
1362 "Returns the built-in scrollbar position.");
1363
1364 DocDeclStr(
1365 virtual int , GetScrollThumb( int orientation ) const,
1366 "Returns the built-in scrollbar thumb size.");
1367
1368 DocDeclStr(
1369 virtual int , GetScrollRange( int orientation ) const,
1370 "Returns the built-in scrollbar range.");
1371
1372
1373
1374
1375 DocDeclStr(
1376 virtual void , ScrollWindow( int dx, int dy,
1377 const wxRect* rect = NULL ),
1378 "Physically scrolls the pixels in the window and move child windows
1379 accordingly. Use this function to optimise your scrolling
1380 implementations, to minimise the area that must be redrawn. Note that
1381 it is rarely required to call this function from a user program.
1382
1383 dx: Amount to scroll horizontally.
1384
1385 dy: Amount to scroll vertically.
1386
1387 rect: Rectangle to invalidate. If this is None, the whole window
1388 is invalidated. If you pass a rectangle corresponding to the
1389 area of the window exposed by the scroll, your painting
1390 handler can optimize painting by checking for the
1391 invalidated region.");
1392
1393
1394 DocDeclStr(
1395 virtual bool , ScrollLines(int lines),
1396 "If the platform and window class supports it, scrolls the window by
1397 the given number of lines down, if lines is positive, or up if lines
1398 is negative. Returns True if the window was scrolled, False if it was
1399 already on top/bottom and nothing was done.");
1400
1401 DocDeclStr(
1402 virtual bool , ScrollPages(int pages),
1403 "If the platform and window class supports it, scrolls the window by
1404 the given number of pages down, if pages is positive, or up if pages
1405 is negative. Returns True if the window was scrolled, False if it was
1406 already on top/bottom and nothing was done.");
1407
1408
1409 DocDeclStr(
1410 bool , LineUp(),
1411 "This is just a wrapper for ScrollLines(-1).");
1412
1413 DocDeclStr(
1414 bool , LineDown(),
1415 "This is just a wrapper for ScrollLines(1).");
1416
1417 DocDeclStr(
1418 bool , PageUp(),
1419 "This is just a wrapper for ScrollPages(-1).");
1420
1421 DocDeclStr(
1422 bool , PageDown(),
1423 "This is just a wrapper for ScrollPages(1).");
1424
1425
1426
1427
1428 // context-sensitive help
1429 // ----------------------
1430
1431 DocDeclStr(
1432 void , SetHelpText(const wxString& text),
1433 "Sets the help text to be used as context-sensitive help for this
1434 window. Note that the text is actually stored by the current
1435 wxHelpProvider implementation, and not in the window object itself.");
1436
1437
1438 DocDeclStr(
1439 void , SetHelpTextForId(const wxString& text),
1440 "Associate this help text with all windows with the same id as this
1441 one.");
1442
1443
1444 DocDeclStr(
1445 wxString , GetHelpText() const,
1446 "Gets the help text to be used as context-sensitive help for this
1447 window. Note that the text is actually stored by the current
1448 wxHelpProvider implementation, and not in the window object itself.");
1449
1450
1451
1452 #ifndef __WXX11__
1453 // tooltips
1454 // --------
1455
1456 DocStr(SetToolTip,
1457 "Attach a tooltip to the window.");
1458 %name(SetToolTipString) void SetToolTip( const wxString &tip );
1459 void SetToolTip( wxToolTip *tip );
1460
1461 DocDeclStr(
1462 wxToolTip* , GetToolTip() const,
1463 "get the associated tooltip or None if none");
1464
1465 // LINK ERROR --> wxString GetToolTipText() const;
1466 #endif
1467
1468
1469
1470 #ifndef __WXX11__
1471 // drag and drop
1472 // -------------
1473
1474 // set/retrieve the drop target associated with this window (may be
1475 // NULL; it's owned by the window and will be deleted by it)
1476 %apply SWIGTYPE *DISOWN { wxPyDropTarget *dropTarget };
1477
1478 DocDeclStr(
1479 virtual void , SetDropTarget( wxPyDropTarget *dropTarget ),
1480 "Associates a drop target with this window. If the window already has
1481 a drop target, it is deleted.");
1482
1483 %clear wxPyDropTarget *dropTarget;
1484
1485
1486 DocDeclStr(
1487 virtual wxPyDropTarget *, GetDropTarget() const,
1488 "Returns the associated drop target, which may be None.");
1489
1490
1491 #ifdef __WXMSW__ // TODO: should I drop-kick this?
1492 DocDeclStr(
1493 void , DragAcceptFiles(bool accept),
1494 "Enables or disables eligibility for drop file events, EVT_DROP_FILES.
1495 Only available on Windows.");
1496 #endif
1497 #endif
1498
1499
1500 // constraints and sizers
1501 // ----------------------
1502
1503 // set the constraints for this window or retrieve them (may be NULL)
1504 DocDeclStr(
1505 void , SetConstraints( wxLayoutConstraints *constraints ),
1506 "Sets the window to have the given layout constraints. If an existing
1507 layout constraints object is already owned by the window, it will be
1508 deleted. Pass None to disassociate and delete the window's current
1509 constraints.
1510
1511 You must call SetAutoLayout to tell a window to use the constraints
1512 automatically in its default EVT_SIZE handler; otherwise, you must
1513 handle EVT_SIZE yourself and call Layout() explicitly. When setting
1514 both a wx.LayoutConstraints and a wx.Sizer, only the sizer will have
1515 effect.");
1516
1517 DocDeclStr(
1518 wxLayoutConstraints *, GetConstraints() const,
1519 "Returns a pointer to the window's layout constraints, or None if there
1520 are none.");
1521
1522
1523 DocDeclStr(
1524 void , SetAutoLayout( bool autoLayout ),
1525 "Determines whether the Layout function will be called automatically
1526 when the window is resized. It is called implicitly by SetSizer but
1527 if you use SetConstraints you should call it manually or otherwise the
1528 window layout won't be correctly updated when its size changes.");
1529
1530 DocDeclStr(
1531 bool , GetAutoLayout() const,
1532 "Returns the current autoLayout setting");
1533
1534
1535 DocDeclStr(
1536 virtual bool , Layout(),
1537 "Invokes the constraint-based layout algorithm or the sizer-based
1538 algorithm for this window. See SetAutoLayout: when auto layout is on,
1539 this function gets called automatically by the default EVT_SIZE
1540 handler when the window is resized.");
1541
1542
1543 DocDeclStr(
1544 void , SetSizer(wxSizer *sizer, bool deleteOld = True ),
1545 "Sets the window to have the given layout sizer. The window will then
1546 own the object, and will take care of its deletion. If an existing
1547 layout sizer object is already owned by the window, it will be deleted
1548 if the deleteOld parameter is true. Note that this function will also
1549 call SetAutoLayout implicitly with a True parameter if the sizer is
1550 non-NoneL and False otherwise.");
1551
1552 DocDeclStr(
1553 void , SetSizerAndFit( wxSizer *sizer, bool deleteOld = True ),
1554 "The same as SetSizer, except it also sets the size hints for the
1555 window based on the sizer's minimum size.");
1556
1557
1558 DocDeclStr(
1559 wxSizer *, GetSizer() const,
1560 "Return the sizer associated with the window by a previous call to
1561 SetSizer or None if there isn't one.");
1562
1563
1564 // Track if this window is a member of a sizer
1565 DocDeclStr(
1566 void , SetContainingSizer(wxSizer* sizer),
1567 "This normally does not need to be called by application code. It is
1568 called internally when a window is added to a sizer, and is used so
1569 the window can remove itself from the sizer when it is destroyed.");
1570
1571 DocDeclStr(
1572 wxSizer *, GetContainingSizer() const,
1573 "Return the sizer that this window is a member of, if any, otherwise None.");
1574
1575
1576
1577
1578 // accessibility
1579 // ----------------------
1580 #if wxUSE_ACCESSIBILITY
1581 // Override to create a specific accessible object.
1582 virtual wxAccessible* CreateAccessible();
1583
1584 // Sets the accessible object.
1585 void SetAccessible(wxAccessible* accessible) ;
1586
1587 // Returns the accessible object.
1588 wxAccessible* GetAccessible() { return m_accessible; };
1589
1590 // Returns the accessible object, creating if necessary.
1591 wxAccessible* GetOrCreateAccessible() ;
1592 #endif
1593
1594
1595
1596 %pythoncode {
1597 def PostCreate(self, pre):
1598 """
1599 Phase 3 of the 2-phase create <wink!>
1600 Call this method after precreating the window with the 2-phase create method.
1601 """
1602 self.this = pre.this
1603 self.thisown = pre.thisown
1604 pre.thisown = 0
1605 if hasattr(self, '_setOORInfo'):
1606 self._setOORInfo(self)
1607 if hasattr(self, '_setCallbackInfo'):
1608 self._setCallbackInfo(self, self.__class__)
1609 }
1610 };
1611
1612
1613
1614
1615
1616
1617
1618
1619 %pythoncode {
1620 def DLG_PNT(win, point_or_x, y=None):
1621 """
1622 Convenience function for converting a Point or (x,y) in
1623 dialog units to pixel units.
1624 """
1625 if y is None:
1626 return win.ConvertDialogPointToPixels(point_or_x)
1627 else:
1628 return win.ConvertDialogPointToPixels(wx.Point(point_or_x, y))
1629
1630 def DLG_SZE(win, size_width, height=None):
1631 """
1632 Convenience function for converting a Size or (w,h) in
1633 dialog units to pixel units.
1634 """
1635 if height is None:
1636 return win.ConvertDialogSizeToPixels(size_width)
1637 else:
1638 return win.ConvertDialogSizeToPixels(wx.Size(size_width, height))
1639 }
1640
1641
1642
1643
1644 // Unfortunatly the names of these new static methods clash with the
1645 // names wxPython has been using forever for the overloaded
1646 // wxWindow::FindWindow, so instead of swigging them as statics create
1647 // standalone functions for them.
1648
1649
1650 DocStr(wxFindWindowById,
1651 "Find the first window in the application with the given id. If parent
1652 is None, the search will start from all top-level frames and dialog
1653 boxes; if non-None, the search will be limited to the given window
1654 hierarchy. The search is recursive in both cases.");
1655
1656 DocStr(wxFindWindowByName,
1657 "Find a window by its name (as given in a window constructor or Create
1658 function call). If parent is None, the search will start from all
1659 top-level frames and dialog boxes; if non-None, the search will be
1660 limited to the given window hierarchy. The search is recursive in both
1661 cases.
1662
1663 If no window with such name is found, wx.FindWindowByLabel is called.");
1664
1665 DocStr(wxFindWindowByLabel,
1666 "Find a window by its label. Depending on the type of window, the label
1667 may be a window title or panel item label. If parent is None, the
1668 search will start from all top-level frames and dialog boxes; if
1669 non-None, the search will be limited to the given window
1670 hierarchy. The search is recursive in both cases.");
1671
1672
1673 %inline %{
1674 wxWindow* wxFindWindowById( long id, const wxWindow *parent = NULL ) {
1675 return wxWindow::FindWindowById(id, parent);
1676 }
1677
1678 wxWindow* wxFindWindowByName( const wxString& name,
1679 const wxWindow *parent = NULL ) {
1680 return wxWindow::FindWindowByName(name, parent);
1681 }
1682
1683 wxWindow* wxFindWindowByLabel( const wxString& label,
1684 const wxWindow *parent = NULL ) {
1685 return wxWindow::FindWindowByLabel(label, parent);
1686 }
1687 %}
1688
1689
1690
1691 %inline %{
1692 wxWindow* wxWindow_FromHWND(unsigned long hWnd) {
1693 #ifdef __WXMSW__
1694 wxWindow* win = new wxWindow;
1695 win->SetHWND(hWnd);
1696 win->SubclassWin(hWnd);
1697 return win;
1698 #else
1699 wxPyRaiseNotImplemented();
1700 return NULL;
1701 #endif
1702 }
1703 %}
1704
1705 //---------------------------------------------------------------------------
1706 //---------------------------------------------------------------------------
1707