1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface for wxWindow
7 // Created: 24-June-1997
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
21 MAKE_CONST_WXSTRING(PanelNameStr);
23 //---------------------------------------------------------------------------
29 wxWINDOW_VARIANT_DEFAULT, // Default size (usually == normal, may be set by a wxSystemOptions entry)
30 wxWINDOW_VARIANT_NORMAL, // Normal size
31 wxWINDOW_VARIANT_SMALL, // Smaller size (about 25 % smaller than normal )
32 wxWINDOW_VARIANT_MINI, // Mini size (about 33 % smaller than normal )
33 wxWINDOW_VARIANT_LARGE, // Large size (about 25 % larger than normal )
39 wx.Window is the base class for all windows and represents any visible
40 object on the screen. All controls, top level windows and so on are
41 wx.Windows. Sizers and device contexts are not however, as they don't
42 appear on screen themselves.
48 wx.SIMPLE_BORDER: Displays a thin border around the window.
50 wx.DOUBLE_BORDER: Displays a double border. Windows and Mac only.
52 wx.SUNKEN_BORDER: Displays a sunken border.
54 wx.RAISED_BORDER: Displays a raised border.
56 wx.STATIC_BORDER: Displays a border suitable for a static
57 control. Windows only.
59 wx.NO_BORDER: Displays no border, overriding the default
60 border style for the window.
62 wx.TRANSPARENT_WINDOW: The window is transparent, that is, it
63 will not receive paint events. Windows only.
65 wx.TAB_TRAVERSAL: Use this to enable tab traversal for
68 wx.WANTS_CHARS: Use this to indicate that the window
69 wants to get all char/key events for
70 all keys - even for keys like TAB or
71 ENTER which are usually used for
72 dialog navigation and which wouldn't
73 be generated without this style. If
74 you need to use this style in order to
75 get the arrows or etc., but would
76 still like to have normal keyboard
77 navigation take place, you should
78 create and send a wxNavigationKeyEvent
79 in response to the key events for Tab
82 wx.NO_FULL_REPAINT_ON_RESIZE: Disables repainting the window
83 completely when its size is changed
84 - you will have to repaint the new
85 window area manually if you use this
86 style. As of version 2.5.1 this
87 style is on by default. Use
88 wx.FULL_REPAINT_ON_RESIZE to
91 wx.VSCROLL: Use this style to enable a vertical scrollbar.
93 wx.HSCROLL: Use this style to enable a horizontal scrollbar.
95 wx.ALWAYS_SHOW_SB: If a window has scrollbars, disable them
96 instead of hiding them when they are
97 not needed (i.e. when the size of the
98 window is big enough to not require
99 the scrollbars to navigate it). This
100 style is currently only implemented
101 for wxMSW and wxUniversal and does
102 nothing on the other platforms.
104 wx.CLIP_CHILDREN: Use this style to eliminate flicker caused by
105 the background being repainted, then
106 children being painted over
109 wx.FULL_REPAINT_ON_RESIZE: Use this style to force a complete
110 redraw of the window whenever it is
111 resized instead of redrawing just the
112 part of the window affected by
113 resizing. Note that this was the
114 behaviour by default before 2.5.1
115 release and that if you experience
116 redraw problems with the code which
117 previously used to work you may want
122 wx.WS_EX_VALIDATE_RECURSIVELY: By default,
123 Validate/TransferDataTo/FromWindow()
124 only work on direct children of
125 the window (compatible
126 behaviour). Set this flag to make
127 them recursively descend into all
130 wx.WS_EX_BLOCK_EVENTS: wx.CommandEvents and the objects of the
131 derived classes are forwarded to
132 the parent window and so on
133 recursively by default. Using this
134 flag for the given window allows
135 to block this propagation at this
136 window, i.e. prevent the events
137 from being propagated further
138 upwards. Dialogs have this flag on
141 wx.WS_EX_TRANSIENT Don't use this window as an implicit parent for
142 the other windows: this must be
143 used with transient windows as
144 otherwise there is the risk of
145 creating a dialog/frame with this
146 window as a parent which would
147 lead to a crash if the parent is
148 destroyed before the child.
150 wx.WS_EX_PROCESS_IDLE: This window should always process idle
151 events, even if the mode set by
152 wx.IdleEvent.SetMode is
153 wx.IDLE_PROCESS_SPECIFIED.
155 wx.WS_EX_PROCESS_UI_UPDATES This window should always process UI
156 update events, even if the mode
157 set by wxUpdateUIEvent::SetMode is
158 wxUPDATE_UI_PROCESS_SPECIFIED.
164 class wxWindow : public wxEvtHandler
167 %pythonAppend wxWindow "self._setOORInfo(self)"
168 %pythonAppend wxWindow() ""
171 wxWindow(wxWindow* parent, const wxWindowID id,
172 const wxPoint& pos = wxDefaultPosition,
173 const wxSize& size = wxDefaultSize,
175 const wxString& name = wxPyPanelNameStr),
176 "Construct and show a generic Window.");
180 "Precreate a Window for 2-phase creation.",
185 bool , Create(wxWindow* parent, const wxWindowID id,
186 const wxPoint& pos = wxDefaultPosition,
187 const wxSize& size = wxDefaultSize,
189 const wxString& name = wxPyPanelNameStr),
190 "Create the GUI part of the Window for 2-phase creation mode.");
193 // deleting the window
194 // -------------------
198 bool , Close( bool force = False ),
199 "This function simply generates a EVT_CLOSE event whose handler usually
200 tries to close the window. It doesn't close the window itself,
201 however. If force is False (the default) then the window's close
202 handler will be allowed to veto the destruction of the window.
204 Usually Close is only used with the top level windows (wx.Frame and
205 wx.Dialog classes) as the others are not supposed to have any special
208 The close handler should check whether the window is being deleted
209 forcibly, using wx.CloseEvent.GetForce, in which case it should
210 destroy the window using wx.Window.Destroy.
212 Note that calling Close does not guarantee that the window will be
213 destroyed; but it provides a way to simulate a manual close of a
214 window, which may or may not be implemented by destroying the
215 window. The default EVT_CLOSE handler for wx.Dialog does not
216 necessarily delete the dialog, since it will simply simulate an
217 wxID_CANCEL event which is handled by the appropriate button event
218 handler and may do anything at all.
220 To guarantee that the window will be destroyed, call wx.Window.Destroy
226 virtual bool , Destroy(),
227 "Destroys the window safely. Frames and dialogs are not destroyed
228 immediately when this function is called -- they are added to a list
229 of windows to be deleted on idle time, when all the window's events
230 have been processed. This prevents problems with events being sent to
231 non-existent windows.
233 Returns True if the window has either been successfully deleted, or it
234 has been added to the list of windows pending real deletion.");
238 bool , DestroyChildren(),
239 "Destroys all children of a window. Called automatically by the destructor.");
243 bool , IsBeingDeleted() const,
244 "Is the window in the process of being deleted?");
252 virtual void , SetTitle( const wxString& title),
253 "Sets the window's title. Applicable only to frames and dialogs.");
256 virtual wxString , GetTitle() const,
257 "Gets the window's title. Applicable only to frames and dialogs.");
261 virtual void , SetLabel(const wxString& label),
262 "Set the text which the window shows in its label if applicable.");
265 virtual wxString , GetLabel() const,
266 "Generic way of getting a label from any window, for
267 identification purposes. The interpretation of this function
268 differs from class to class. For frames and dialogs, the value
269 returned is the title. For buttons or static text controls, it is
270 the button text. This function can be useful for meta-programs
271 (such as testing tools or special-needs access programs) which
272 need to identify windows by name.");
275 // the window name is used for ressource setting in X, it is not the
276 // same as the window title/label
278 virtual void , SetName( const wxString &name ),
279 "Sets the window's name. The window name is used for ressource
280 setting in X, it is not the same as the window title/label");
283 virtual wxString , GetName() const,
284 "Returns the window's name. This name is not guaranteed to be
285 unique; it is up to the programmer to supply an appropriate name
286 in the window constructor or via wx.Window.SetName.");
291 void , SetWindowVariant( wxWindowVariant variant ),
292 "Sets the variant of the window/font size to use for this window,
293 if the platform supports variants, (for example, wxMac.)");
296 wxWindowVariant , GetWindowVariant() const,
301 void , SetId( wxWindowID winid ),
302 "Sets the identifier of the window. Each window has an integer
303 identifier. If the application has not provided one, an identifier
304 will be generated. Normally, the identifier should be provided on
305 creation and should not be modified subsequently.");
308 wxWindowID , GetId() const,
309 "Returns the identifier of the window. Each window has an integer
310 identifier. If the application has not provided one (or the default Id
311 -1 is used) then an unique identifier with a negative value will be
316 static int , NewControlId(),
317 "Generate a control id for the controls which were not given one.");
321 static int , NextControlId(int winid),
322 "Get the id of the control following the one with the given\n"
323 "(autogenerated) id");
327 static int , PrevControlId(int winid),
328 "Get the id of the control preceding the one with the given\n"
329 "(autogenerated) id");
339 void , SetSize( const wxSize& size ),
340 "Sets the size of the window in pixels.");
344 void , SetSize( int x, int y, int width, int height,
345 int sizeFlags = wxSIZE_AUTO ),
346 "Sets the position and size of the window in pixels. The sizeFlags
347 parameter indicates the interpretation of the other params if they are
348 -1. wx.SIZE_AUTO*: a -1 indicates that a class-specific default
349 shoudl be used. wx.SIZE_USE_EXISTING: existing dimensions should be
350 used if -1 values are supplied. wxSIZE_ALLOW_MINUS_ONE: allow
351 dimensions of -1 and less to be interpreted as real dimensions, not
357 void , SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO),
358 "Sets the position and size of the window in pixels using a wx.Rect.",
363 void , SetSize( int width, int height ),
364 "Sets the size of the window in pixels.",
369 void , Move(const wxPoint& pt, int flags = wxSIZE_USE_EXISTING),
370 "Moves the window to the given position.");
372 %pythoncode { SetPosition = Move }
376 void , Move(int x, int y, int flags = wxSIZE_USE_EXISTING),
377 "Moves the window to the given position.",
383 virtual void , Raise(),
384 "Raises the window to the top of the window hierarchy if it is a
385 managed window (dialog or frame).");
388 virtual void , Lower(),
389 "Lowers the window to the bottom of the window hierarchy if it is a
390 managed window (dialog or frame).");
394 // client size is the size of the area available for subwindows
395 DocStr(SetClientSize,
396 "This sets the size of the window client area in pixels. Using this
397 function to size a window tends to be more device-independent than
398 wx.Window.SetSize, since the application need not worry about what
399 dimensions the border or title bar have when trying to fit the window
400 around panel items, for example.");
401 void SetClientSize( const wxSize& size );
402 %name(SetClientSizeWH) void SetClientSize( int width, int height );
403 %name(SetClientRect) void SetClientSize(const wxRect& rect);
406 DocStr(GetPosition, // sets the docstring for both
407 "Get the window's position.");
408 wxPoint GetPosition();
411 void, GetPosition(int *OUTPUT, int *OUTPUT),
412 "GetPositionTuple() -> (x,y)",
416 DocStr(GetSize, "Get the window size.");
417 wxSize GetSize() const;
419 void, GetSize( int *OUTPUT, int *OUTPUT ) const,
420 "GetSizeTuple() -> (width, height)",
426 wxRect , GetRect() const,
427 "Returns the size and position of the window as a wx.Rect object.");
430 DocStr(GetClientSize,
431 "This gets the size of the window's 'client area' in pixels. The client
432 area is the area which may be drawn on by the programmer, excluding
433 title bar, border, scrollbars, etc.");
434 wxSize GetClientSize() const;
436 void, GetClientSize( int *OUTPUT, int *OUTPUT ) const,
437 "GetClientSizeTuple() -> (width, height)",
443 virtual wxPoint , GetClientAreaOrigin() const,
444 "Get the origin of the client area of the window relative to the
445 window's top left corner (the client area may be shifted because of
446 the borders, scrollbars, other decorations...)");
450 wxRect , GetClientRect() const,
451 "Get the client area position and size as a wx.Rect object.");
456 "This functions returns the best acceptable minimal size for the
457 window, if applicable. For example, for a static text control, it will be
458 the minimal size such that the control label is not truncated. For
459 windows containing subwindows (suzh aswx.Panel), the size returned
460 by this function will be the same as the size the window would have
461 had after calling Fit.");
462 wxSize GetBestSize() const;
464 void, GetBestSize(int *OUTPUT, int *OUTPUT) const,
465 "GetBestSizeTuple() -> (width, height)",
470 wxSize , GetAdjustedBestSize() const,
471 "This method is similar to GetBestSize, except in one
472 thing. GetBestSize should return the minimum untruncated size of the
473 window, while this method will return the largest of BestSize and any
474 user specified minimum size. ie. it is the minimum size the window
475 should currently be drawn at, not the minimal size it can possibly
482 void , Center( int direction = wxBOTH ),
483 "Centers the window. The parameter specifies the direction for
484 cetering, and may be wx.HORIZONTAL, wx.VERTICAL or wx.BOTH. It may
485 also include wx.CENTER_ON_SCREEN flag if you want to center the window
486 on the entire screen and not on its parent window. If it is a
487 top-level window and has no parent then it will always be centered
488 relative to the screen.");
490 %pythoncode { Centre = Center }
494 void , CenterOnScreen(int dir = wxBOTH),
495 "Center on screen (only works for top level windows)");
496 %pythoncode { CentreOnScreen = CenterOnScreen }
500 void , CenterOnParent(int dir = wxBOTH),
501 "Center with respect to the the parent window");
502 %pythoncode { CentreOnParent = CenterOnParent }
507 virtual void , Fit(),
508 "Sizes the window so that it fits around its subwindows. This function
509 won't do anything if there are no subwindows and will only really work
510 correctly if sizers are used for the subwindows layout. Also, if the
511 window has exactly one subwindow it is better (faster and the result
512 is more precise as Fit adds some margin to account for fuzziness of
513 its calculations) to call window.SetClientSize(child.GetSize())
514 instead of calling Fit.");
518 virtual void , FitInside(),
519 "Similar to Fit, but sizes the interior (virtual) size of a
520 window. Mainly useful with scrolled windows to reset scrollbars after
521 sizing changes that do not trigger a size event, and/or scrolled
522 windows without an interior sizer. This function similarly won't do
523 anything if there are no subwindows.");
528 virtual void , SetSizeHints( int minW, int minH,
529 int maxW = -1, int maxH = -1,
530 int incW = -1, int incH = -1 ),
531 "Allows specification of minimum and maximum window sizes, and window
532 size increments. If a pair of values is not set (or set to -1), the
533 default values will be used. If this function is called, the user
534 will not be able to size the window outside the given bounds. The
535 resizing increments are only significant under Motif or Xt.");
539 virtual void , SetVirtualSizeHints( int minW, int minH,
540 int maxW = -1, int maxH = -1 ),
541 "Allows specification of minimum and maximum virtual window sizes. If a
542 pair of values is not set (or set to -1), the default values will be
543 used. If this function is called, the user will not be able to size
544 the virtual area of the window outside the given bounds.");
548 virtual int , GetMinWidth() const,
552 virtual int , GetMinHeight() const,
556 int , GetMaxWidth() const,
560 int , GetMaxHeight() const,
565 virtual wxSize , GetMaxSize() const,
570 DocStr(SetVirtualSize,
571 "Set the the virtual size of a window in pixels. For most windows this
572 is just the client area of the window, but for some like scrolled
573 windows it is more or less independent of the screen window size.");
574 void SetVirtualSize(const wxSize& size );
575 %name(SetVirtualSizeWH) void SetVirtualSize( int w, int h );
578 DocStr(GetVirtualSize,
579 "Get the the virtual size of the window in pixels. For most windows
580 this is just the client area of the window, but for some like scrolled
581 windows it is more or less independent of the screen window size.");
582 wxSize GetVirtualSize() const;
584 void, GetVirtualSize( int *OUTPUT, int *OUTPUT ) const,
585 "GetVirtualSizeTuple() -> (width, height)",
586 GetVirtualSizeTuple);
589 // TODO: using directors?
590 // // Override these methods for windows that have a virtual size
591 // // independent of their client size. eg. the virtual area of a
592 // // wxScrolledWindow. Default is to alias VirtualSize to ClientSize.
593 // virtual void DoSetVirtualSize( int x, int y );
594 // virtual wxSize DoGetVirtualSize() const; // { return m_virtualSize; }
598 virtual wxSize , GetBestVirtualSize() const,
599 "Return the largest of ClientSize and BestSize (as determined by a
600 sizer, interior children, or other means)");
608 virtual bool , Show( bool show = True ),
609 "Shows or hides the window. You may need to call Raise for a top level
610 window if you want to bring it to top, although this is not needed if
611 Show is called immediately after the frame creation. Returns True if
612 the window has been shown or hidden or False if nothing was done
613 because it already was in the requested state.");
617 "Equivalent to calling Show(False).");
621 virtual bool , Enable( bool enable = True ),
622 "Enable or disable the window for user input. Note that when a parent
623 window is disabled, all of its children are disabled as well and they
624 are reenabled again when the parent is. Returns true if the window
625 has been enabled or disabled, false if nothing was done, i.e. if the
626 window had already been in the specified state.");
630 "Disables the window, same as Enable(false).");
634 bool , IsShown() const,
635 "Returns true if the window is shown, false if it has been hidden.");
638 bool , IsEnabled() const,
639 "Returns true if the window is enabled for input, false otherwise.");
645 virtual void , SetWindowStyleFlag( long style ),
646 "Sets the style of the window. Please note that some styles cannot be
647 changed after the window creation and that Refresh() might be called
648 after changing the others for the change to take place immediately.");
651 virtual long , GetWindowStyleFlag() const,
652 "Gets the window style that was passed to the constructor or Create
655 %pythoncode { SetWindowStyle = SetWindowStyleFlag; GetWindowStyle = GetWindowStyleFlag }
659 bool , HasFlag(int flag) const,
660 "Test if the given style is set for this window.");
664 virtual bool , IsRetained() const,
665 "Returns true if the window is retained, false otherwise. Retained
666 windows are only available on X platforms.");
671 virtual void , SetExtraStyle(long exStyle),
672 "Sets the extra style bits for the window. Extra styles are the less
673 often used style bits which can't be set with the constructor or with
674 SetWindowStyleFlag()");
677 long , GetExtraStyle() const,
678 "Returns the extra style bits for the window.");
683 virtual void , MakeModal(bool modal = True),
684 "Disables all other windows in the application so that the user can
685 only interact with this window. Passing False will reverse this
691 virtual void , SetThemeEnabled(bool enableTheme),
692 "This function tells a window if it should use the system's \"theme\"
693 code to draw the windows' background instead if its own background
694 drawing code. This will only have an effect on platforms that support
695 the notion of themes in user defined windows. One such platform is
696 GTK+ where windows can have (very colourful) backgrounds defined by a
697 user's selected theme.
699 Dialogs, notebook pages and the status bar have this flag set to true
700 by default so that the default look and feel is simulated best.");
703 virtual bool , GetThemeEnabled() const,
704 "Return the themeEnabled flag.");
707 // TODO with directors
708 // // controls by default inherit the colours of their parents, if a
709 // // particular control class doesn't want to do it, it can override
710 // // ShouldInheritColours() to return False
711 // virtual bool ShouldInheritColours() const;
717 // focus and keyboard handling
718 // ---------------------------
722 virtual void , SetFocus(),
723 "Set's the focus to this window, allowing it to receive keyboard input.");
726 virtual void , SetFocusFromKbd(),
727 "Set focus to this window as the result of a keyboard action. Normally
728 only called internally.");
733 static wxWindow *, FindFocus(),
734 "Returns the window or control that currently has the keyboard focus,
739 virtual bool , AcceptsFocus() const,
740 "Can this window have focus?");
744 virtual bool , AcceptsFocusFromKeyboard() const,
745 "Can this window be given focus by keyboard navigation? if not, the
746 only way to give it focus (provided it accepts it at all) is to click
753 virtual wxWindow *, GetDefaultItem() const,
754 "Get the default child of this parent, i.e. the one which is activated
755 by pressing <Enter> such as the OK button on a wx.Dialog.");
758 virtual wxWindow *, SetDefaultItem(wxWindow * child),
759 "Set this child as default, return the old default.");
762 virtual void , SetTmpDefaultItem(wxWindow * win),
763 "Set this child as temporary default");
769 // parent/children relations
770 // -------------------------
773 //wxWindowList& GetChildren(); // TODO: Do a typemap or a wrapper for wxWindowList
776 "Returns a list of the window's children. NOTE: Currently this is a
777 copy of the child window list maintained by the window, so the return
778 value of this function is only valid as long as the window's children
780 PyObject* GetChildren() {
781 wxWindowList& list = self->GetChildren();
782 return wxPy_ConvertList(&list);
787 wxWindow *, GetParent() const,
788 "Returns the parent window of this window, or None if there isn't one.");
791 wxWindow *, GetGrandParent() const,
792 "Returns the parent of the parent of this window, or None if there isn't one.");
797 virtual bool , IsTopLevel() const,
798 "Returns true if the given window is a top-level one. Currently all
799 frames and dialogs are always considered to be top-level windows (even
800 if they have a parent window).");
803 // change the real parent of this window, return True if the parent
804 // was changed, False otherwise (error or newParent == oldParent)
806 virtual bool , Reparent( wxWindow *newParent ),
807 "Reparents the window, i.e the window will be removed from its current
808 parent window (e.g. a non-standard toolbar in a wxFrame) and then
809 re-inserted into another. Available on Windows and GTK. Returns True
810 if the parent was changed, False otherwise (error or newParent ==
815 virtual void , AddChild( wxWindow *child ),
816 "Adds a child window. This is called automatically by window creation
817 functions so should not be required by the application programmer.");
820 virtual void , RemoveChild( wxWindow *child ),
821 "Removes a child window. This is called automatically by window
822 deletion functions so should not be required by the application
828 // looking for windows
829 // -------------------
832 wxWindow *, FindWindow( long winid ),
833 "Find a chld of this window by window ID",
837 wxWindow *, FindWindow( const wxString& name ),
838 "Find a child of this window by name",
843 // event handler stuff
844 // -------------------
847 wxEvtHandler *, GetEventHandler() const,
848 "Returns the event handler for this window. By default, the window is
849 its own event handler.");
853 void , SetEventHandler( wxEvtHandler *handler ),
854 "Sets the event handler for this window. An event handler is an object
855 that is capable of processing the events sent to a window. By default,
856 the window is its own event handler, but an application may wish to
857 substitute another, for example to allow central implementation of
858 event-handling for a variety of different window classes.
860 It is usually better to use wx.Window.PushEventHandler since this sets
861 up a chain of event handlers, where an event not handled by one event
862 handler is handed to the next one in the chain.");
866 void , PushEventHandler( wxEvtHandler *handler ),
867 "Pushes this event handler onto the event handler stack for the window.
868 An event handler is an object that is capable of processing the events
869 sent to a window. By default, the window is its own event handler, but
870 an application may wish to substitute another, for example to allow
871 central implementation of event-handling for a variety of different
874 wx.Window.PushEventHandler allows an application to set up a chain of
875 event handlers, where an event not handled by one event handler is
876 handed to the next one in the chain. Use wx.Window.PopEventHandler to
877 remove the event handler.");
881 wxEvtHandler *, PopEventHandler( bool deleteHandler = False ),
882 "Removes and returns the top-most event handler on the event handler
883 stack. If deleteHandler is True then the wx.EvtHandler object will be
884 destroyed after it is popped.");
888 bool , RemoveEventHandler(wxEvtHandler *handler),
889 "Find the given handler in the event handler chain and remove (but
890 not delete) it from the event handler chain, return True if it was
891 found and False otherwise (this also results in an assert failure so
892 this function should only be called when the handler is supposed to
901 // a window may have an associated validator which is used to control
904 virtual void , SetValidator( const wxValidator &validator ),
905 "Deletes the current validator (if any) and sets the window validator,
906 having called wx.Validator.Clone to create a new validator of this
910 virtual wxValidator *, GetValidator(),
911 "Returns a pointer to the current validator for the window, or None if
920 virtual void , SetAcceleratorTable( const wxAcceleratorTable& accel ),
921 "Sets the accelerator table for this window.");
924 wxAcceleratorTable *, GetAcceleratorTable(),
925 "Gets the accelerator table for this window.");
931 // hot keys (system wide accelerators)
932 // -----------------------------------
934 DocStr(RegisterHotKey,
935 "Registers a system wide hotkey. Every time the user presses the hotkey
936 registered here, this window will receive a hotkey event. It will
937 receive the event even if the application is in the background and
938 does not have the input focus because the user is working with some
939 other application. To bind an event handler function to this hotkey
940 use EVT_HOTKEY with an id equal to hotkeyId. Returns True if the
941 hotkey was registered successfully.");
942 bool RegisterHotKey(int hotkeyId, int modifiers, int keycode) {
944 return self->RegisterHotKey(hotkeyId, modifiers, keycode);
951 DocStr(UnregisterHotKey,
952 "Unregisters a system wide hotkey.");
953 bool UnregisterHotKey(int hotkeyId) {
955 return self->UnregisterHotKey(hotkeyId);
964 // "dialog units" translations
965 // ---------------------------
967 DocStr(ConvertDialogToPixels,
968 "Converts a point or size from dialog units to pixels. Dialog units
969 are used for maintaining a dialog's proportions even if the font
970 changes. For the x dimension, the dialog units are multiplied by the
971 average character width and then divided by 4. For the y dimension,
972 the dialog units are multiplied by the average character height and
973 then divided by 8.");
974 %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt);
975 %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz);
976 %name(DLG_PNT) wxPoint ConvertDialogToPixels(const wxPoint& pt);
977 %name(DLG_SZE) wxSize ConvertDialogToPixels(const wxSize& sz);
980 DocStr(ConvertPixelPointToDialog,
981 "Converts a point or size from pixels to dialog units. Dialog units
982 are used for maintaining a dialog's proportions even if the font
983 changes. For the x dimension, the dialog units are multiplied by the
984 average character width and then divided by 4. For the y dimension,
985 the dialog units are multiplied by the average character height and
986 then divided by 8.");
987 %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt);
988 %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz);
996 virtual void , WarpPointer(int x, int y),
997 "Moves the pointer to the given position on the window.
999 NOTE: This function is not supported under Mac because Apple Human
1000 Interface Guidelines forbid moving the mouse cursor programmatically.");
1004 void , CaptureMouse(),
1005 "Directs all mouse input to this window. Call wx.Window.ReleaseMouse to
1006 release the capture.
1008 Note that wxWindows maintains the stack of windows having captured the
1009 mouse and when the mouse is released the capture returns to the window
1010 which had had captured it previously and it is only really released if
1011 there were no previous window. In particular, this means that you must
1012 release the mouse as many times as you capture it.");
1015 void , ReleaseMouse(),
1016 "Releases mouse input captured with wx.Window.CaptureMouse.");
1020 static wxWindow *, GetCapture(),
1021 "Returns the window which currently captures the mouse or None");
1025 virtual bool , HasCapture() const,
1026 "Returns true if this window has the current mouse capture.");
1032 // painting the window
1033 // -------------------
1036 virtual void , Refresh( bool eraseBackground = True,
1037 const wxRect *rect = NULL ),
1038 "Mark the specified rectangle (or the whole window) as \"dirty\" so it
1039 will be repainted. Causes an EVT_PAINT event to be generated and sent
1044 void , RefreshRect(const wxRect& rect),
1045 "Redraws the contents of the given rectangle: the area inside it will
1046 be repainted. This is the same as Refresh but has a nicer syntax.");
1050 virtual void , Update(),
1051 "Calling this method immediately repaints the invalidated area of the
1052 window instead of waiting for the EVT_PAINT event to happen, (normally
1053 this would usually only happen when the flow of control returns to the
1054 event loop.) Notice that this function doesn't refresh the window and
1055 does nothing if the window has been already repainted. Use Refresh
1056 first if you want to immediately redraw the window (or some portion of
1057 it) unconditionally.");
1061 virtual void , ClearBackground(),
1062 "Clears the window by filling it with the current background
1063 colour. Does not cause an erase background event to be generated.");
1068 virtual void , Freeze(),
1069 "Freezes the window or, in other words, prevents any updates from taking place
1070 on screen, the window is not redrawn at all. Thaw must be called to reenable
1071 window redrawing. Calls to Freeze/Thaw may be nested, with the actual Thaw
1072 being delayed until all the nesting has been undone.
1074 This method is useful for visual appearance optimization (for example,
1075 it is a good idea to use it before inserting large amount of text into
1076 a wxTextCtrl under wxGTK) but is not implemented on all platforms nor
1077 for all controls so it is mostly just a hint to wxWindows and not a
1078 mandatory directive.");
1082 virtual void , Thaw(),
1083 "Reenables window updating after a previous call to Freeze. Calls to
1084 Freeze/Thaw may be nested, so Thaw must be called the same number of times
1085 that Freeze was before the window will be updated.");
1089 virtual void , PrepareDC( wxDC & dc ),
1090 "Call this function to prepare the device context for drawing a
1091 scrolled image. It sets the device origin according to the current
1096 wxRegion& , GetUpdateRegion(),
1097 "Returns the region specifying which parts of the window have been
1098 damaged. Should only be called within an EVT_PAINT handler.");
1102 wxRect , GetUpdateClientRect() const,
1103 "Get the update rectangle region bounding box in client coords.");
1107 "Returns true if the given point or rectangle area has been exposed
1108 since the last repaint. Call this in an paint event handler to
1109 optimize redrawing by only redrawing those areas, which have been
1111 bool IsExposed( int x, int y, int w=1, int h=1 ) const;
1112 %name(IsExposedPoint) bool IsExposed( const wxPoint& pt ) const;
1113 %name(IsExposedRect) bool IsExposed( const wxRect& rect ) const;
1117 // colours, fonts and cursors
1118 // --------------------------
1120 // set/retrieve the window colours (system defaults are used by
1121 // default): Set functions return True if colour was changed
1126 virtual bool , SetBackgroundColour( const wxColour &colour ),
1127 "Sets the background colour of the window. Returns True if the colour
1128 was changed. The background colour is usually painted by the default
1129 EVT_ERASE_BACKGROUND event handler function under Windows and
1130 automatically under GTK.
1132 Note that setting the background colour does not cause an immediate
1133 refresh, so you may wish to call ClearBackground or Refresh after
1134 calling this function.
1136 Use this function with care under GTK+ as the new appearance of the
1137 window might not look equally well when used with themes, i.e GTK+'s
1138 ability to change its look as the user wishes with run-time loadable
1142 virtual bool , SetForegroundColour( const wxColour &colour ),
1143 "Sets the foreground colour of the window. Returns True is the colour
1144 was changed. The interpretation of foreground colour is dependent on
1145 the window class; it may be the text colour or other colour, or it may
1146 not be used at all.");
1150 wxColour , GetBackgroundColour() const,
1151 "Returns the background colour of the window.");
1154 wxColour , GetForegroundColour() const,
1155 "Returns the foreground colour of the window. The interpretation of
1156 foreground colour is dependent on the window class; it may be the text
1157 colour or other colour, or it may not be used at all.");
1163 virtual bool , SetCursor( const wxCursor &cursor ),
1164 "Sets the window's cursor. Notice that the window cursor also sets it
1165 for the children of the window implicitly.
1167 The cursor may be wx.NullCursor in which case the window cursor will
1168 be reset back to default.");
1171 wxCursor& , GetCursor(),
1172 "Return the cursor associated with this window.");
1177 virtual bool , SetFont( const wxFont &font ),
1178 "Sets the font for this window.");
1181 wxFont& , GetFont(),
1182 "Returns the default font used for this window.");
1187 void , SetCaret(wxCaret *caret),
1188 "Sets the caret associated with the window.");
1191 wxCaret *, GetCaret() const,
1192 "Returns the caret associated with the window.");
1197 virtual int , GetCharHeight() const,
1198 "Get the (average) character size for the current font.");
1201 virtual int , GetCharWidth() const,
1202 "Get the (average) character size for the current font.");
1207 void, GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT),
1208 "GetTextExtent(String string) -> (width, height)",
1209 "Get the width and height of the text using the current font.");
1211 void, GetTextExtent(const wxString& string,
1212 int *OUTPUT, int *OUTPUT, int *OUTPUT, int* OUTPUT,
1213 const wxFont* font = NULL),
1214 "GetFullTextExtent(String string, Font font=None) ->\n (width, height, descent, externalLeading)",
1215 "Get the width, height, decent and leading of the text using the
1216 current or specified font.",
1221 // client <-> screen coords
1222 // ------------------------
1224 %apply int * INOUT { int* x, int* y };
1226 // translate to/from screen/client coordinates
1228 void , ClientToScreen( int *x, int *y ) const,
1229 "ClientToScreenXY(int x, int y) -> (x,y)",
1230 "Converts to screen coordinates from coordinates relative to this window.",
1234 void , ScreenToClient( int *x, int *y ) const,
1235 "ScreenToClientXY(int x, int y) -> (x,y)",
1236 "Converts from screen to client window coordinates.",
1241 wxPoint , ClientToScreen(const wxPoint& pt) const,
1242 "Converts to screen coordinates from coordinates relative to this window.");
1245 wxPoint , ScreenToClient(const wxPoint& pt) const,
1246 "Converts from screen to client window coordinates.");
1251 wxHitTest , HitTest(wxCoord x, wxCoord y) const,
1252 "Test where the given (in client coords) point lies",
1256 wxHitTest , HitTest(const wxPoint& pt) const,
1257 "Test where the given (in client coords) point lies");
1265 %nokwargs GetBorder;
1267 wxBorder , GetBorder(long flags) const,
1268 "Get the window border style from the given flags: this is different
1269 from simply doing flags & wxBORDER_MASK because it uses
1270 GetDefaultBorder() to translate wxBORDER_DEFAULT to something
1275 wxBorder , GetBorder() const,
1276 "Get border for the flags of this window");
1282 virtual void , UpdateWindowUI(long flags = wxUPDATE_UI_NONE),
1283 "This function sends EVT_UPDATE_UI events to the window. The particular
1284 implementation depends on the window; for example a wx.ToolBar will
1285 send an update UI event for each toolbar button, and a wx.Frame will
1286 send an update UI event for each menubar menu item. You can call this
1287 function from your application to ensure that your UI is up-to-date at
1288 a particular point in time (as far as your EVT_UPDATE_UI handlers are
1289 concerned). This may be necessary if you have called
1290 wx.UpdateUIEvent.SetMode or wx.UpdateUIEvent.SetUpdateInterval to
1291 limit the overhead that wxWindows incurs by sending update UI events
1294 The flags should be a bitlist of one or more of the following values:
1296 wx.UPDATE_UI_NONE No particular value
1297 wx.UPDATE_UI_RECURSE Call the function for descendants
1298 wx.UPDATE_UI_FROMIDLE Invoked from OnIdle
1300 If you are calling this function from an OnIdle function, make sure
1301 you pass the wx.UPDATE_UI_FROMIDLE flag, since this tells the window to
1302 only update the UI elements that need to be updated in idle time. Some
1303 windows update their elements only when necessary, for example when a
1304 menu is about to be shown. The following is an example of how to call
1305 UpdateWindowUI from an idle function.
1307 def OnIdle(self, evt):
1308 if wx.UpdateUIEvent.CanUpdate(self):
1309 self.UpdateWindowUI(wx.UPDATE_UI_FROMIDLE);
1313 // TODO: using directors?
1314 // // do the window-specific processing after processing the update event
1315 // virtual void DoUpdateWindowUI(wxUpdateUIEvent& event) ;
1319 "Pops up the given menu at the specified coordinates, relative to this
1320 window, and returns control when the user has dismissed the menu. If a
1321 menu item is selected, the corresponding menu event is generated and
1322 will be processed as usual.");
1323 %name(PopupMenuXY) bool PopupMenu(wxMenu *menu, int x, int y);
1324 bool PopupMenu(wxMenu *menu, const wxPoint& pos);
1331 "Returns the platform-specific handle (as a long integer) of the
1332 physical window. Currently on wxMac it returns the handle of the
1333 toplevel parent of the window.");
1335 return wxPyGetWinHandle(self);
1342 // A way to do the native draw first... Too bad it isn't in wxGTK too.
1343 void OnPaint(wxPaintEvent& event);
1353 bool , HasScrollbar(int orient) const,
1354 "Does the window have the scrollbar for this orientation?");
1357 // configure the window scrollbars
1359 virtual void , SetScrollbar( int orientation,
1363 bool refresh = True ),
1364 "Sets the scrollbar properties of a built-in scrollbar.
1366 orientation: Determines the scrollbar whose page size is to be
1367 set. May be wx.HORIZONTAL or wx.VERTICAL.
1369 position: The position of the scrollbar in scroll units.
1371 thumbSize: The size of the thumb, or visible portion of the
1372 scrollbar, in scroll units.
1374 range: The maximum position of the scrollbar.
1376 refresh: True to redraw the scrollbar, false otherwise.");
1379 virtual void , SetScrollPos( int orientation, int pos, bool refresh = True ),
1380 "Sets the position of one of the built-in scrollbars.");
1383 virtual int , GetScrollPos( int orientation ) const,
1384 "Returns the built-in scrollbar position.");
1387 virtual int , GetScrollThumb( int orientation ) const,
1388 "Returns the built-in scrollbar thumb size.");
1391 virtual int , GetScrollRange( int orientation ) const,
1392 "Returns the built-in scrollbar range.");
1398 virtual void , ScrollWindow( int dx, int dy,
1399 const wxRect* rect = NULL ),
1400 "Physically scrolls the pixels in the window and move child windows
1401 accordingly. Use this function to optimise your scrolling
1402 implementations, to minimise the area that must be redrawn. Note that
1403 it is rarely required to call this function from a user program.
1405 dx: Amount to scroll horizontally.
1407 dy: Amount to scroll vertically.
1409 rect: Rectangle to invalidate. If this is None, the whole window
1410 is invalidated. If you pass a rectangle corresponding to the
1411 area of the window exposed by the scroll, your painting
1412 handler can optimize painting by checking for the
1413 invalidated region.");
1417 virtual bool , ScrollLines(int lines),
1418 "If the platform and window class supports it, scrolls the window by
1419 the given number of lines down, if lines is positive, or up if lines
1420 is negative. Returns True if the window was scrolled, False if it was
1421 already on top/bottom and nothing was done.");
1424 virtual bool , ScrollPages(int pages),
1425 "If the platform and window class supports it, scrolls the window by
1426 the given number of pages down, if pages is positive, or up if pages
1427 is negative. Returns True if the window was scrolled, False if it was
1428 already on top/bottom and nothing was done.");
1433 "This is just a wrapper for ScrollLines(-1).");
1437 "This is just a wrapper for ScrollLines(1).");
1441 "This is just a wrapper for ScrollPages(-1).");
1445 "This is just a wrapper for ScrollPages(1).");
1450 // context-sensitive help
1451 // ----------------------
1454 void , SetHelpText(const wxString& text),
1455 "Sets the help text to be used as context-sensitive help for this
1456 window. Note that the text is actually stored by the current
1457 wxHelpProvider implementation, and not in the window object itself.");
1461 void , SetHelpTextForId(const wxString& text),
1462 "Associate this help text with all windows with the same id as this
1467 wxString , GetHelpText() const,
1468 "Gets the help text to be used as context-sensitive help for this
1469 window. Note that the text is actually stored by the current
1470 wxHelpProvider implementation, and not in the window object itself.");
1479 "Attach a tooltip to the window.");
1480 %name(SetToolTipString) void SetToolTip( const wxString &tip );
1481 void SetToolTip( wxToolTip *tip );
1484 wxToolTip* , GetToolTip() const,
1485 "get the associated tooltip or None if none");
1487 // LINK ERROR --> wxString GetToolTipText() const;
1496 // set/retrieve the drop target associated with this window (may be
1497 // NULL; it's owned by the window and will be deleted by it)
1498 %apply SWIGTYPE *DISOWN { wxPyDropTarget *dropTarget };
1501 virtual void , SetDropTarget( wxPyDropTarget *dropTarget ),
1502 "Associates a drop target with this window. If the window already has
1503 a drop target, it is deleted.");
1505 %clear wxPyDropTarget *dropTarget;
1509 virtual wxPyDropTarget *, GetDropTarget() const,
1510 "Returns the associated drop target, which may be None.");
1513 #ifdef __WXMSW__ // TODO: should I drop-kick this?
1515 void , DragAcceptFiles(bool accept),
1516 "Enables or disables eligibility for drop file events, EVT_DROP_FILES.
1517 Only available on Windows.");
1522 // constraints and sizers
1523 // ----------------------
1525 // set the constraints for this window or retrieve them (may be NULL)
1527 void , SetConstraints( wxLayoutConstraints *constraints ),
1528 "Sets the window to have the given layout constraints. If an existing
1529 layout constraints object is already owned by the window, it will be
1530 deleted. Pass None to disassociate and delete the window's current
1533 You must call SetAutoLayout to tell a window to use the constraints
1534 automatically in its default EVT_SIZE handler; otherwise, you must
1535 handle EVT_SIZE yourself and call Layout() explicitly. When setting
1536 both a wx.LayoutConstraints and a wx.Sizer, only the sizer will have
1540 wxLayoutConstraints *, GetConstraints() const,
1541 "Returns a pointer to the window's layout constraints, or None if there
1546 void , SetAutoLayout( bool autoLayout ),
1547 "Determines whether the Layout function will be called automatically
1548 when the window is resized. It is called implicitly by SetSizer but
1549 if you use SetConstraints you should call it manually or otherwise the
1550 window layout won't be correctly updated when its size changes.");
1553 bool , GetAutoLayout() const,
1554 "Returns the current autoLayout setting");
1558 virtual bool , Layout(),
1559 "Invokes the constraint-based layout algorithm or the sizer-based
1560 algorithm for this window. See SetAutoLayout: when auto layout is on,
1561 this function gets called automatically by the default EVT_SIZE
1562 handler when the window is resized.");
1566 void , SetSizer(wxSizer *sizer, bool deleteOld = True ),
1567 "Sets the window to have the given layout sizer. The window will then
1568 own the object, and will take care of its deletion. If an existing
1569 layout sizer object is already owned by the window, it will be deleted
1570 if the deleteOld parameter is true. Note that this function will also
1571 call SetAutoLayout implicitly with a True parameter if the sizer is
1572 non-NoneL and False otherwise.");
1575 void , SetSizerAndFit( wxSizer *sizer, bool deleteOld = True ),
1576 "The same as SetSizer, except it also sets the size hints for the
1577 window based on the sizer's minimum size.");
1581 wxSizer *, GetSizer() const,
1582 "Return the sizer associated with the window by a previous call to
1583 SetSizer or None if there isn't one.");
1586 // Track if this window is a member of a sizer
1588 void , SetContainingSizer(wxSizer* sizer),
1589 "This normally does not need to be called by application code. It is
1590 called internally when a window is added to a sizer, and is used so
1591 the window can remove itself from the sizer when it is destroyed.");
1594 wxSizer *, GetContainingSizer() const,
1595 "Return the sizer that this window is a member of, if any, otherwise None.");
1601 // ----------------------
1602 #if wxUSE_ACCESSIBILITY
1603 // Override to create a specific accessible object.
1604 virtual wxAccessible* CreateAccessible();
1606 // Sets the accessible object.
1607 void SetAccessible(wxAccessible* accessible) ;
1609 // Returns the accessible object.
1610 wxAccessible* GetAccessible() { return m_accessible; };
1612 // Returns the accessible object, creating if necessary.
1613 wxAccessible* GetOrCreateAccessible() ;
1619 def PostCreate(self, pre):
1621 Phase 3 of the 2-phase create <wink!>
1622 Call this method after precreating the window with the 2-phase create method.
1624 self.this = pre.this
1625 self.thisown = pre.thisown
1627 if hasattr(self, '_setOORInfo'):
1628 self._setOORInfo(self)
1629 if hasattr(self, '_setCallbackInfo'):
1630 self._setCallbackInfo(self, self.__class__)
1642 def DLG_PNT(win, point_or_x, y=None):
1644 Convenience function for converting a Point or (x,y) in
1645 dialog units to pixel units.
1648 return win.ConvertDialogPointToPixels(point_or_x)
1650 return win.ConvertDialogPointToPixels(wx.Point(point_or_x, y))
1652 def DLG_SZE(win, size_width, height=None):
1654 Convenience function for converting a Size or (w,h) in
1655 dialog units to pixel units.
1658 return win.ConvertDialogSizeToPixels(size_width)
1660 return win.ConvertDialogSizeToPixels(wx.Size(size_width, height))
1666 // Unfortunatly the names of these new static methods clash with the
1667 // names wxPython has been using forever for the overloaded
1668 // wxWindow::FindWindow, so instead of swigging them as statics create
1669 // standalone functions for them.
1672 DocStr(wxFindWindowById,
1673 "Find the first window in the application with the given id. If parent
1674 is None, the search will start from all top-level frames and dialog
1675 boxes; if non-None, the search will be limited to the given window
1676 hierarchy. The search is recursive in both cases.");
1678 DocStr(wxFindWindowByName,
1679 "Find a window by its name (as given in a window constructor or Create
1680 function call). If parent is None, the search will start from all
1681 top-level frames and dialog boxes; if non-None, the search will be
1682 limited to the given window hierarchy. The search is recursive in both
1685 If no window with such name is found, wx.FindWindowByLabel is called.");
1687 DocStr(wxFindWindowByLabel,
1688 "Find a window by its label. Depending on the type of window, the label
1689 may be a window title or panel item label. If parent is None, the
1690 search will start from all top-level frames and dialog boxes; if
1691 non-None, the search will be limited to the given window
1692 hierarchy. The search is recursive in both cases.");
1696 wxWindow* wxFindWindowById( long id, const wxWindow *parent = NULL ) {
1697 return wxWindow::FindWindowById(id, parent);
1700 wxWindow* wxFindWindowByName( const wxString& name,
1701 const wxWindow *parent = NULL ) {
1702 return wxWindow::FindWindowByName(name, parent);
1705 wxWindow* wxFindWindowByLabel( const wxString& label,
1706 const wxWindow *parent = NULL ) {
1707 return wxWindow::FindWindowByLabel(label, parent);
1715 #include <wx/msw/private.h> // to get wxGetWindowId
1720 wxWindow* wxWindow_FromHWND(wxWindow* parent, unsigned long _hWnd) {
1722 WXHWND hWnd = (WXHWND)_hWnd;
1723 long id = wxGetWindowId(hWnd);
1724 wxWindow* win = new wxWindow;
1725 parent->AddChild(win);
1726 win->SetEventHandler(win);
1729 win->SubclassWin(hWnd);
1730 win->AdoptAttributesFromHWND();
1731 win->SetupColours();
1734 wxPyRaiseNotImplemented();
1740 //---------------------------------------------------------------------------
1741 //---------------------------------------------------------------------------