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