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