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() ""
170 RefDoc(wxWindow, ""); // turn it off for the ctors
173 wxWindow(wxWindow* parent, const wxWindowID id,
174 const wxPoint& pos = wxDefaultPosition,
175 const wxSize& size = wxDefaultSize,
177 const wxString& name = wxPyPanelNameStr),
178 "Construct and show a generic Window.");
182 "Precreate a Window for 2-phase creation.",
187 bool , Create(wxWindow* parent, const wxWindowID id,
188 const wxPoint& pos = wxDefaultPosition,
189 const wxSize& size = wxDefaultSize,
191 const wxString& name = wxPyPanelNameStr),
192 "Create the GUI part of the Window for 2-phase creation mode.");
195 // deleting the window
196 // -------------------
200 bool , Close( bool force = False ),
201 "This function simply generates a EVT_CLOSE event whose handler usually
202 tries to close the window. It doesn't close the window itself,
203 however. If force is False (the default) then the window's close
204 handler will be allowed to veto the destruction of the window.
206 Usually Close is only used with the top level windows (wx.Frame and
207 wx.Dialog classes) as the others are not supposed to have any special
210 The close handler should check whether the window is being deleted
211 forcibly, using wx.CloseEvent.GetForce, in which case it should
212 destroy the window using wx.Window.Destroy.
214 Note that calling Close does not guarantee that the window will be
215 destroyed; but it provides a way to simulate a manual close of a
216 window, which may or may not be implemented by destroying the
217 window. The default EVT_CLOSE handler for wx.Dialog does not
218 necessarily delete the dialog, since it will simply simulate an
219 wxID_CANCEL event which is handled by the appropriate button event
220 handler and may do anything at all.
222 To guarantee that the window will be destroyed, call wx.Window.Destroy
228 virtual bool , Destroy(),
229 "Destroys the window safely. Frames and dialogs are not destroyed
230 immediately when this function is called -- they are added to a list
231 of windows to be deleted on idle time, when all the window's events
232 have been processed. This prevents problems with events being sent to
233 non-existent windows.
235 Returns True if the window has either been successfully deleted, or it
236 has been added to the list of windows pending real deletion.");
240 bool , DestroyChildren(),
241 "Destroys all children of a window. Called automatically by the destructor.");
245 bool , IsBeingDeleted() const,
246 "Is the window in the process of being deleted?");
254 virtual void , SetTitle( const wxString& title),
255 "Sets the window's title. Applicable only to frames and dialogs.");
258 virtual wxString , GetTitle() const,
259 "Gets the window's title. Applicable only to frames and dialogs.");
263 virtual void , SetLabel(const wxString& label),
264 "Set the text which the window shows in its label if applicable.");
267 virtual wxString , GetLabel() const,
268 "Generic way of getting a label from any window, for
269 identification purposes. The interpretation of this function
270 differs from class to class. For frames and dialogs, the value
271 returned is the title. For buttons or static text controls, it is
272 the button text. This function can be useful for meta-programs
273 (such as testing tools or special-needs access programs) which
274 need to identify windows by name.");
277 // the window name is used for ressource setting in X, it is not the
278 // same as the window title/label
280 virtual void , SetName( const wxString &name ),
281 "Sets the window's name. The window name is used for ressource
282 setting in X, it is not the same as the window title/label");
285 virtual wxString , GetName() const,
286 "Returns the window's name. This name is not guaranteed to be
287 unique; it is up to the programmer to supply an appropriate name
288 in the window constructor or via wx.Window.SetName.");
293 void , SetWindowVariant( wxWindowVariant variant ),
294 "Sets the variant of the window/font size to use for this window,
295 if the platform supports variants, (for example, wxMac.)");
298 wxWindowVariant , GetWindowVariant() const,
303 void , SetId( wxWindowID winid ),
304 "Sets the identifier of the window. Each window has an integer
305 identifier. If the application has not provided one, an identifier
306 will be generated. Normally, the identifier should be provided on
307 creation and should not be modified subsequently.");
310 wxWindowID , GetId() const,
311 "Returns the identifier of the window. Each window has an integer
312 identifier. If the application has not provided one (or the default Id
313 -1 is used) then an unique identifier with a negative value will be
318 static int , NewControlId(),
319 "Generate a control id for the controls which were not given one.");
323 static int , NextControlId(int winid),
324 "Get the id of the control following the one with the given\n"
325 "(autogenerated) id");
329 static int , PrevControlId(int winid),
330 "Get the id of the control preceding the one with the given\n"
331 "(autogenerated) id");
341 void , SetSize( const wxSize& size ),
342 "Sets the size of the window in pixels.");
346 void , SetSize( int x, int y, int width, int height,
347 int sizeFlags = wxSIZE_AUTO ),
348 "Sets the position and size of the window in pixels. The sizeFlags
349 parameter indicates the interpretation of the other params if they are
350 -1. wx.SIZE_AUTO*: a -1 indicates that a class-specific default
351 shoudl be used. wx.SIZE_USE_EXISTING: existing dimensions should be
352 used if -1 values are supplied. wxSIZE_ALLOW_MINUS_ONE: allow
353 dimensions of -1 and less to be interpreted as real dimensions, not
359 void , SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO),
360 "Sets the position and size of the window in pixels using a wx.Rect.",
365 void , SetSize( int width, int height ),
366 "Sets the size of the window in pixels.",
371 void , Move(const wxPoint& pt, int flags = wxSIZE_USE_EXISTING),
372 "Moves the window to the given position.");
374 %pythoncode { SetPosition = Move }
378 void , Move(int x, int y, int flags = wxSIZE_USE_EXISTING),
379 "Moves the window to the given position.",
385 virtual void , Raise(),
386 "Raises the window to the top of the window hierarchy if it is a
387 managed window (dialog or frame).");
390 virtual void , Lower(),
391 "Lowers the window to the bottom of the window hierarchy if it is a
392 managed window (dialog or frame).");
396 // client size is the size of the area available for subwindows
397 DocStr(SetClientSize,
398 "This sets the size of the window client area in pixels. Using this
399 function to size a window tends to be more device-independent than
400 wx.Window.SetSize, since the application need not worry about what
401 dimensions the border or title bar have when trying to fit the window
402 around panel items, for example.");
403 void SetClientSize( const wxSize& size );
404 %name(SetClientSizeWH) void SetClientSize( int width, int height );
405 %name(SetClientRect) void SetClientSize(const wxRect& rect);
408 DocStr(GetPosition, // sets the docstring for both
409 "Get the window's position.");
410 wxPoint GetPosition();
413 void, GetPosition(int *OUTPUT, int *OUTPUT),
414 "GetPositionTuple() -> (x,y)",
418 DocStr(GetSize, "Get the window size.");
419 wxSize GetSize() const;
421 void, GetSize( int *OUTPUT, int *OUTPUT ) const,
422 "GetSizeTuple() -> (width, height)",
428 wxRect , GetRect() const,
429 "Returns the size and position of the window as a wx.Rect object.");
432 DocStr(GetClientSize,
433 "This gets the size of the window's 'client area' in pixels. The client
434 area is the area which may be drawn on by the programmer, excluding
435 title bar, border, scrollbars, etc.");
436 wxSize GetClientSize() const;
438 void, GetClientSize( int *OUTPUT, int *OUTPUT ) const,
439 "GetClientSizeTuple() -> (width, height)",
445 virtual wxPoint , GetClientAreaOrigin() const,
446 "Get the origin of the client area of the window relative to the
447 window's top left corner (the client area may be shifted because of
448 the borders, scrollbars, other decorations...)");
452 wxRect , GetClientRect() const,
453 "Get the client area position and size as a wx.Rect object.");
458 "This functions returns the best acceptable minimal size for the
459 window, if applicable. For example, for a static text control, it will be
460 the minimal size such that the control label is not truncated. For
461 windows containing subwindows (suzh aswx.Panel), the size returned
462 by this function will be the same as the size the window would have
463 had after calling Fit.");
464 wxSize GetBestSize() const;
466 void, GetBestSize(int *OUTPUT, int *OUTPUT) const,
467 "GetBestSizeTuple() -> (width, height)",
472 wxSize , GetAdjustedBestSize() const,
473 "This method is similar to GetBestSize, except in one
474 thing. GetBestSize should return the minimum untruncated size of the
475 window, while this method will return the largest of BestSize and any
476 user specified minimum size. ie. it is the minimum size the window
477 should currently be drawn at, not the minimal size it can possibly
484 void , Center( int direction = wxBOTH ),
485 "Centers the window. The parameter specifies the direction for
486 cetering, and may be wx.HORIZONTAL, wx.VERTICAL or wx.BOTH. It may
487 also include wx.CENTER_ON_SCREEN flag if you want to center the window
488 on the entire screen and not on its parent window. If it is a
489 top-level window and has no parent then it will always be centered
490 relative to the screen.");
492 %pythoncode { Centre = Center }
496 void , CenterOnScreen(int dir = wxBOTH),
497 "Center on screen (only works for top level windows)");
498 %pythoncode { CentreOnScreen = CenterOnScreen }
502 void , CenterOnParent(int dir = wxBOTH),
503 "Center with respect to the the parent window");
504 %pythoncode { CentreOnParent = CenterOnParent }
509 virtual void , Fit(),
510 "Sizes the window so that it fits around its subwindows. This function
511 won't do anything if there are no subwindows and will only really work
512 correctly if sizers are used for the subwindows layout. Also, if the
513 window has exactly one subwindow it is better (faster and the result
514 is more precise as Fit adds some margin to account for fuzziness of
515 its calculations) to call window.SetClientSize(child.GetSize())
516 instead of calling Fit.");
520 virtual void , FitInside(),
521 "Similar to Fit, but sizes the interior (virtual) size of a
522 window. Mainly useful with scrolled windows to reset scrollbars after
523 sizing changes that do not trigger a size event, and/or scrolled
524 windows without an interior sizer. This function similarly won't do
525 anything if there are no subwindows.");
530 virtual void , SetSizeHints( int minW, int minH,
531 int maxW = -1, int maxH = -1,
532 int incW = -1, int incH = -1 ),
533 "Allows specification of minimum and maximum window sizes, and window
534 size increments. If a pair of values is not set (or set to -1), the
535 default values will be used. If this function is called, the user
536 will not be able to size the window outside the given bounds. The
537 resizing increments are only significant under Motif or Xt.");
541 virtual void , SetVirtualSizeHints( int minW, int minH,
542 int maxW = -1, int maxH = -1 ),
543 "Allows specification of minimum and maximum virtual window sizes. If a
544 pair of values is not set (or set to -1), the default values will be
545 used. If this function is called, the user will not be able to size
546 the virtual area of the window outside the given bounds.");
550 virtual int , GetMinWidth() const,
554 virtual int , GetMinHeight() const,
558 int , GetMaxWidth() const,
562 int , GetMaxHeight() const,
567 virtual wxSize , GetMaxSize() const,
572 DocStr(SetVirtualSize,
573 "Set the the virtual size of a window in pixels. For most windows this
574 is just the client area of the window, but for some like scrolled
575 windows it is more or less independent of the screen window size.");
576 void SetVirtualSize(const wxSize& size );
577 %name(SetVirtualSizeWH) void SetVirtualSize( int w, int h );
580 DocStr(GetVirtualSize,
581 "Get the the virtual size of the window in pixels. For most windows
582 this is just the client area of the window, but for some like scrolled
583 windows it is more or less independent of the screen window size.");
584 wxSize GetVirtualSize() const;
586 void, GetVirtualSize( int *OUTPUT, int *OUTPUT ) const,
587 "GetVirtualSizeTuple() -> (width, height)",
588 GetVirtualSizeTuple);
591 // TODO: using directors?
592 // // Override these methods for windows that have a virtual size
593 // // independent of their client size. eg. the virtual area of a
594 // // wxScrolledWindow. Default is to alias VirtualSize to ClientSize.
595 // virtual void DoSetVirtualSize( int x, int y );
596 // virtual wxSize DoGetVirtualSize() const; // { return m_virtualSize; }
600 virtual wxSize , GetBestVirtualSize() const,
601 "Return the largest of ClientSize and BestSize (as determined by a
602 sizer, interior children, or other means)");
610 virtual bool , Show( bool show = True ),
611 "Shows or hides the window. You may need to call Raise for a top level
612 window if you want to bring it to top, although this is not needed if
613 Show is called immediately after the frame creation. Returns True if
614 the window has been shown or hidden or False if nothing was done
615 because it already was in the requested state.");
619 "Equivalent to calling Show(False).");
623 virtual bool , Enable( bool enable = True ),
624 "Enable or disable the window for user input. Note that when a parent
625 window is disabled, all of its children are disabled as well and they
626 are reenabled again when the parent is. Returns true if the window
627 has been enabled or disabled, false if nothing was done, i.e. if the
628 window had already been in the specified state.");
632 "Disables the window, same as Enable(false).");
636 bool , IsShown() const,
637 "Returns true if the window is shown, false if it has been hidden.");
640 bool , IsEnabled() const,
641 "Returns true if the window is enabled for input, false otherwise.");
647 virtual void , SetWindowStyleFlag( long style ),
648 "Sets the style of the window. Please note that some styles cannot be
649 changed after the window creation and that Refresh() might be called
650 after changing the others for the change to take place immediately.");
653 virtual long , GetWindowStyleFlag() const,
654 "Gets the window style that was passed to the constructor or Create
657 %pythoncode { SetWindowStyle = SetWindowStyleFlag; GetWindowStyle = GetWindowStyleFlag }
661 bool , HasFlag(int flag) const,
662 "Test if the given style is set for this window.");
666 virtual bool , IsRetained() const,
667 "Returns true if the window is retained, false otherwise. Retained
668 windows are only available on X platforms.");
673 virtual void , SetExtraStyle(long exStyle),
674 "Sets the extra style bits for the window. Extra styles are the less
675 often used style bits which can't be set with the constructor or with
676 SetWindowStyleFlag()");
679 long , GetExtraStyle() const,
680 "Returns the extra style bits for the window.");
685 virtual void , MakeModal(bool modal = True),
686 "Disables all other windows in the application so that the user can
687 only interact with this window. Passing False will reverse this
693 virtual void , SetThemeEnabled(bool enableTheme),
694 "This function tells a window if it should use the system's \"theme\"
695 code to draw the windows' background instead if its own background
696 drawing code. This will only have an effect on platforms that support
697 the notion of themes in user defined windows. One such platform is
698 GTK+ where windows can have (very colourful) backgrounds defined by a
699 user's selected theme.
701 Dialogs, notebook pages and the status bar have this flag set to true
702 by default so that the default look and feel is simulated best.");
705 virtual bool , GetThemeEnabled() const,
706 "Return the themeEnabled flag.");
709 // TODO with directors
710 // // controls by default inherit the colours of their parents, if a
711 // // particular control class doesn't want to do it, it can override
712 // // ShouldInheritColours() to return False
713 // virtual bool ShouldInheritColours() const;
719 // focus and keyboard handling
720 // ---------------------------
724 virtual void , SetFocus(),
725 "Set's the focus to this window, allowing it to receive keyboard input.");
728 virtual void , SetFocusFromKbd(),
729 "Set focus to this window as the result of a keyboard action. Normally
730 only called internally.");
735 static wxWindow *, FindFocus(),
736 "Returns the window or control that currently has the keyboard focus,
741 virtual bool , AcceptsFocus() const,
742 "Can this window have focus?");
746 virtual bool , AcceptsFocusFromKeyboard() const,
747 "Can this window be given focus by keyboard navigation? if not, the
748 only way to give it focus (provided it accepts it at all) is to click
755 virtual wxWindow *, GetDefaultItem() const,
756 "Get the default child of this parent, i.e. the one which is activated
757 by pressing <Enter> such as the OK button on a wx.Dialog.");
760 virtual wxWindow *, SetDefaultItem(wxWindow * child),
761 "Set this child as default, return the old default.");
764 virtual void , SetTmpDefaultItem(wxWindow * win),
765 "Set this child as temporary default");
771 // parent/children relations
772 // -------------------------
775 //wxWindowList& GetChildren(); // TODO: Do a typemap or a wrapper for wxWindowList
778 "Returns a list of the window's children. NOTE: Currently this is a
779 copy of the child window list maintained by the window, so the return
780 value of this function is only valid as long as the window's children
782 PyObject* GetChildren() {
783 wxWindowList& list = self->GetChildren();
784 return wxPy_ConvertList(&list);
789 wxWindow *, GetParent() const,
790 "Returns the parent window of this window, or None if there isn't one.");
793 wxWindow *, GetGrandParent() const,
794 "Returns the parent of the parent of this window, or None if there isn't one.");
799 virtual bool , IsTopLevel() const,
800 "Returns true if the given window is a top-level one. Currently all
801 frames and dialogs are always considered to be top-level windows (even
802 if they have a parent window).");
805 // change the real parent of this window, return True if the parent
806 // was changed, False otherwise (error or newParent == oldParent)
808 virtual bool , Reparent( wxWindow *newParent ),
809 "Reparents the window, i.e the window will be removed from its current
810 parent window (e.g. a non-standard toolbar in a wxFrame) and then
811 re-inserted into another. Available on Windows and GTK. Returns True
812 if the parent was changed, False otherwise (error or newParent ==
817 virtual void , AddChild( wxWindow *child ),
818 "Adds a child window. This is called automatically by window creation
819 functions so should not be required by the application programmer.");
822 virtual void , RemoveChild( wxWindow *child ),
823 "Removes a child window. This is called automatically by window
824 deletion functions so should not be required by the application
830 // looking for windows
831 // -------------------
834 wxWindow *, FindWindow( long winid ),
835 "Find a chld of this window by window ID",
839 wxWindow *, FindWindow( const wxString& name ),
840 "Find a child of this window by name",
845 // event handler stuff
846 // -------------------
849 wxEvtHandler *, GetEventHandler() const,
850 "Returns the event handler for this window. By default, the window is
851 its own event handler.");
855 void , SetEventHandler( wxEvtHandler *handler ),
856 "Sets the event handler for this window. An event handler is an object
857 that is capable of processing the events sent to a window. By default,
858 the window is its own event handler, but an application may wish to
859 substitute another, for example to allow central implementation of
860 event-handling for a variety of different window classes.
862 It is usually better to use wx.Window.PushEventHandler since this sets
863 up a chain of event handlers, where an event not handled by one event
864 handler is handed to the next one in the chain.");
868 void , PushEventHandler( wxEvtHandler *handler ),
869 "Pushes this event handler onto the event handler stack for the window.
870 An event handler is an object that is capable of processing the events
871 sent to a window. By default, the window is its own event handler, but
872 an application may wish to substitute another, for example to allow
873 central implementation of event-handling for a variety of different
876 wx.Window.PushEventHandler allows an application to set up a chain of
877 event handlers, where an event not handled by one event handler is
878 handed to the next one in the chain. Use wx.Window.PopEventHandler to
879 remove the event handler.");
883 wxEvtHandler *, PopEventHandler( bool deleteHandler = False ),
884 "Removes and returns the top-most event handler on the event handler
885 stack. If deleteHandler is True then the wx.EvtHandler object will be
886 destroyed after it is popped.");
890 bool , RemoveEventHandler(wxEvtHandler *handler),
891 "Find the given handler in the event handler chain and remove (but
892 not delete) it from the event handler chain, return True if it was
893 found and False otherwise (this also results in an assert failure so
894 this function should only be called when the handler is supposed to
903 // a window may have an associated validator which is used to control
906 virtual void , SetValidator( const wxValidator &validator ),
907 "Deletes the current validator (if any) and sets the window validator,
908 having called wx.Validator.Clone to create a new validator of this
912 virtual wxValidator *, GetValidator(),
913 "Returns a pointer to the current validator for the window, or None if
922 virtual void , SetAcceleratorTable( const wxAcceleratorTable& accel ),
923 "Sets the accelerator table for this window.");
926 wxAcceleratorTable *, GetAcceleratorTable(),
927 "Gets the accelerator table for this window.");
933 // hot keys (system wide accelerators)
934 // -----------------------------------
936 DocStr(RegisterHotKey,
937 "Registers a system wide hotkey. Every time the user presses the hotkey
938 registered here, this window will receive a hotkey event. It will
939 receive the event even if the application is in the background and
940 does not have the input focus because the user is working with some
941 other application. To bind an event handler function to this hotkey
942 use EVT_HOTKEY with an id equal to hotkeyId. Returns True if the
943 hotkey was registered successfully.");
944 bool RegisterHotKey(int hotkeyId, int modifiers, int keycode) {
946 return self->RegisterHotKey(hotkeyId, modifiers, keycode);
953 DocStr(UnregisterHotKey,
954 "Unregisters a system wide hotkey.");
955 bool UnregisterHotKey(int hotkeyId) {
957 return self->UnregisterHotKey(hotkeyId);
966 // "dialog units" translations
967 // ---------------------------
969 DocStr(ConvertDialogToPixels,
970 "Converts a point or size from dialog units to pixels. Dialog units
971 are used for maintaining a dialog's proportions even if the font
972 changes. For the x dimension, the dialog units are multiplied by the
973 average character width and then divided by 4. For the y dimension,
974 the dialog units are multiplied by the average character height and
975 then divided by 8.");
976 %name(ConvertDialogPointToPixels) wxPoint ConvertDialogToPixels(const wxPoint& pt);
977 %name(ConvertDialogSizeToPixels) wxSize ConvertDialogToPixels(const wxSize& sz);
978 %name(DLG_PNT) wxPoint ConvertDialogToPixels(const wxPoint& pt);
979 %name(DLG_SZE) wxSize ConvertDialogToPixels(const wxSize& sz);
982 DocStr(ConvertPixelPointToDialog,
983 "Converts a point or size from pixels to dialog units. Dialog units
984 are used for maintaining a dialog's proportions even if the font
985 changes. For the x dimension, the dialog units are multiplied by the
986 average character width and then divided by 4. For the y dimension,
987 the dialog units are multiplied by the average character height and
988 then divided by 8.");
989 %name(ConvertPixelPointToDialog) wxPoint ConvertPixelsToDialog(const wxPoint& pt);
990 %name(ConvertPixelSizeToDialog) wxSize ConvertPixelsToDialog(const wxSize& sz);
998 virtual void , WarpPointer(int x, int y),
999 "Moves the pointer to the given position on the window.
1001 NOTE: This function is not supported under Mac because Apple Human
1002 Interface Guidelines forbid moving the mouse cursor programmatically.");
1006 void , CaptureMouse(),
1007 "Directs all mouse input to this window. Call wx.Window.ReleaseMouse to
1008 release the capture.
1010 Note that wxWindows maintains the stack of windows having captured the
1011 mouse and when the mouse is released the capture returns to the window
1012 which had had captured it previously and it is only really released if
1013 there were no previous window. In particular, this means that you must
1014 release the mouse as many times as you capture it.");
1017 void , ReleaseMouse(),
1018 "Releases mouse input captured with wx.Window.CaptureMouse.");
1022 static wxWindow *, GetCapture(),
1023 "Returns the window which currently captures the mouse or None");
1027 virtual bool , HasCapture() const,
1028 "Returns true if this window has the current mouse capture.");
1034 // painting the window
1035 // -------------------
1038 virtual void , Refresh( bool eraseBackground = True,
1039 const wxRect *rect = NULL ),
1040 "Mark the specified rectangle (or the whole window) as \"dirty\" so it
1041 will be repainted. Causes an EVT_PAINT event to be generated and sent
1046 void , RefreshRect(const wxRect& rect),
1047 "Redraws the contents of the given rectangle: the area inside it will
1048 be repainted. This is the same as Refresh but has a nicer syntax.");
1052 virtual void , Update(),
1053 "Calling this method immediately repaints the invalidated area of the
1054 window instead of waiting for the EVT_PAINT event to happen, (normally
1055 this would usually only happen when the flow of control returns to the
1056 event loop.) Notice that this function doesn't refresh the window and
1057 does nothing if the window has been already repainted. Use Refresh
1058 first if you want to immediately redraw the window (or some portion of
1059 it) unconditionally.");
1063 virtual void , ClearBackground(),
1064 "Clears the window by filling it with the current background
1065 colour. Does not cause an erase background event to be generated.");
1070 virtual void , Freeze(),
1071 "Freezes the window or, in other words, prevents any updates from taking place
1072 on screen, the window is not redrawn at all. Thaw must be called to reenable
1073 window redrawing. Calls to Freeze/Thaw may be nested, with the actual Thaw
1074 being delayed until all the nesting has been undone.
1076 This method is useful for visual appearance optimization (for example,
1077 it is a good idea to use it before inserting large amount of text into
1078 a wxTextCtrl under wxGTK) but is not implemented on all platforms nor
1079 for all controls so it is mostly just a hint to wxWindows and not a
1080 mandatory directive.");
1084 virtual void , Thaw(),
1085 "Reenables window updating after a previous call to Freeze. Calls to
1086 Freeze/Thaw may be nested, so Thaw must be called the same number of times
1087 that Freeze was before the window will be updated.");
1091 virtual void , PrepareDC( wxDC & dc ),
1092 "Call this function to prepare the device context for drawing a
1093 scrolled image. It sets the device origin according to the current
1098 wxRegion& , GetUpdateRegion(),
1099 "Returns the region specifying which parts of the window have been
1100 damaged. Should only be called within an EVT_PAINT handler.");
1104 wxRect , GetUpdateClientRect() const,
1105 "Get the update rectangle region bounding box in client coords.");
1109 "Returns true if the given point or rectangle area has been exposed
1110 since the last repaint. Call this in an paint event handler to
1111 optimize redrawing by only redrawing those areas, which have been
1113 bool IsExposed( int x, int y, int w=1, int h=1 ) const;
1114 %name(IsExposedPoint) bool IsExposed( const wxPoint& pt ) const;
1115 %name(IsExposedRect) bool IsExposed( const wxRect& rect ) const;
1119 // colours, fonts and cursors
1120 // --------------------------
1122 // set/retrieve the window colours (system defaults are used by
1123 // default): Set functions return True if colour was changed
1128 virtual bool , SetBackgroundColour( const wxColour &colour ),
1129 "Sets the background colour of the window. Returns True if the colour
1130 was changed. The background colour is usually painted by the default
1131 EVT_ERASE_BACKGROUND event handler function under Windows and
1132 automatically under GTK.
1134 Note that setting the background colour does not cause an immediate
1135 refresh, so you may wish to call ClearBackground or Refresh after
1136 calling this function.
1138 Use this function with care under GTK+ as the new appearance of the
1139 window might not look equally well when used with themes, i.e GTK+'s
1140 ability to change its look as the user wishes with run-time loadable
1144 virtual bool , SetForegroundColour( const wxColour &colour ),
1145 "Sets the foreground colour of the window. Returns True is the colour
1146 was changed. The interpretation of foreground colour is dependent on
1147 the window class; it may be the text colour or other colour, or it may
1148 not be used at all.");
1152 wxColour , GetBackgroundColour() const,
1153 "Returns the background colour of the window.");
1156 wxColour , GetForegroundColour() const,
1157 "Returns the foreground colour of the window. The interpretation of
1158 foreground colour is dependent on the window class; it may be the text
1159 colour or other colour, or it may not be used at all.");
1165 virtual bool , SetCursor( const wxCursor &cursor ),
1166 "Sets the window's cursor. Notice that the window cursor also sets it
1167 for the children of the window implicitly.
1169 The cursor may be wx.NullCursor in which case the window cursor will
1170 be reset back to default.");
1173 wxCursor& , GetCursor(),
1174 "Return the cursor associated with this window.");
1179 virtual bool , SetFont( const wxFont &font ),
1180 "Sets the font for this window.");
1183 wxFont& , GetFont(),
1184 "Returns the default font used for this window.");
1189 void , SetCaret(wxCaret *caret),
1190 "Sets the caret associated with the window.");
1193 wxCaret *, GetCaret() const,
1194 "Returns the caret associated with the window.");
1199 virtual int , GetCharHeight() const,
1200 "Get the (average) character size for the current font.");
1203 virtual int , GetCharWidth() const,
1204 "Get the (average) character size for the current font.");
1209 void, GetTextExtent(const wxString& string, int *OUTPUT, int *OUTPUT),
1210 "GetTextExtent(String string) -> (width, height)",
1211 "Get the width and height of the text using the current font.");
1213 void, GetTextExtent(const wxString& string,
1214 int *OUTPUT, int *OUTPUT, int *OUTPUT, int* OUTPUT,
1215 const wxFont* font = NULL),
1216 "GetFullTextExtent(String string, Font font=None) ->\n (width, height, descent, externalLeading)",
1217 "Get the width, height, decent and leading of the text using the
1218 current or specified font.",
1223 // client <-> screen coords
1224 // ------------------------
1226 %apply int * INOUT { int* x, int* y };
1228 // translate to/from screen/client coordinates
1230 void , ClientToScreen( int *x, int *y ) const,
1231 "ClientToScreenXY(int x, int y) -> (x,y)",
1232 "Converts to screen coordinates from coordinates relative to this window.",
1236 void , ScreenToClient( int *x, int *y ) const,
1237 "ScreenToClientXY(int x, int y) -> (x,y)",
1238 "Converts from screen to client window coordinates.",
1243 wxPoint , ClientToScreen(const wxPoint& pt) const,
1244 "Converts to screen coordinates from coordinates relative to this window.");
1247 wxPoint , ScreenToClient(const wxPoint& pt) const,
1248 "Converts from screen to client window coordinates.");
1253 wxHitTest , HitTest(wxCoord x, wxCoord y) const,
1254 "Test where the given (in client coords) point lies",
1258 wxHitTest , HitTest(const wxPoint& pt) const,
1259 "Test where the given (in client coords) point lies");
1267 %nokwargs GetBorder;
1269 wxBorder , GetBorder(long flags) const,
1270 "Get the window border style from the given flags: this is different
1271 from simply doing flags & wxBORDER_MASK because it uses
1272 GetDefaultBorder() to translate wxBORDER_DEFAULT to something
1277 wxBorder , GetBorder() const,
1278 "Get border for the flags of this window");
1284 virtual void , UpdateWindowUI(long flags = wxUPDATE_UI_NONE),
1285 "This function sends EVT_UPDATE_UI events to the window. The particular
1286 implementation depends on the window; for example a wx.ToolBar will
1287 send an update UI event for each toolbar button, and a wx.Frame will
1288 send an update UI event for each menubar menu item. You can call this
1289 function from your application to ensure that your UI is up-to-date at
1290 a particular point in time (as far as your EVT_UPDATE_UI handlers are
1291 concerned). This may be necessary if you have called
1292 wx.UpdateUIEvent.SetMode or wx.UpdateUIEvent.SetUpdateInterval to
1293 limit the overhead that wxWindows incurs by sending update UI events
1296 The flags should be a bitlist of one or more of the following values:
1298 wx.UPDATE_UI_NONE No particular value
1299 wx.UPDATE_UI_RECURSE Call the function for descendants
1300 wx.UPDATE_UI_FROMIDLE Invoked from OnIdle
1302 If you are calling this function from an OnIdle function, make sure
1303 you pass the wx.UPDATE_UI_FROMIDLE flag, since this tells the window to
1304 only update the UI elements that need to be updated in idle time. Some
1305 windows update their elements only when necessary, for example when a
1306 menu is about to be shown. The following is an example of how to call
1307 UpdateWindowUI from an idle function.
1309 def OnIdle(self, evt):
1310 if wx.UpdateUIEvent.CanUpdate(self):
1311 self.UpdateWindowUI(wx.UPDATE_UI_FROMIDLE);
1315 // TODO: using directors?
1316 // // do the window-specific processing after processing the update event
1317 // virtual void DoUpdateWindowUI(wxUpdateUIEvent& event) ;
1321 "Pops up the given menu at the specified coordinates, relative to this
1322 window, and returns control when the user has dismissed the menu. If a
1323 menu item is selected, the corresponding menu event is generated and
1324 will be processed as usual.");
1325 %name(PopupMenuXY) bool PopupMenu(wxMenu *menu, int x, int y);
1326 bool PopupMenu(wxMenu *menu, const wxPoint& pos);
1333 "Returns the platform-specific handle (as a long integer) of the
1334 physical window. Currently on wxMac it returns the handle of the
1335 toplevel parent of the window.");
1337 return wxPyGetWinHandle(self);
1344 // A way to do the native draw first... Too bad it isn't in wxGTK too.
1345 void OnPaint(wxPaintEvent& event);
1355 bool , HasScrollbar(int orient) const,
1356 "Does the window have the scrollbar for this orientation?");
1359 // configure the window scrollbars
1361 virtual void , SetScrollbar( int orientation,
1365 bool refresh = True ),
1366 "Sets the scrollbar properties of a built-in scrollbar.
1368 orientation: Determines the scrollbar whose page size is to be
1369 set. May be wx.HORIZONTAL or wx.VERTICAL.
1371 position: The position of the scrollbar in scroll units.
1373 thumbSize: The size of the thumb, or visible portion of the
1374 scrollbar, in scroll units.
1376 range: The maximum position of the scrollbar.
1378 refresh: True to redraw the scrollbar, false otherwise.");
1381 virtual void , SetScrollPos( int orientation, int pos, bool refresh = True ),
1382 "Sets the position of one of the built-in scrollbars.");
1385 virtual int , GetScrollPos( int orientation ) const,
1386 "Returns the built-in scrollbar position.");
1389 virtual int , GetScrollThumb( int orientation ) const,
1390 "Returns the built-in scrollbar thumb size.");
1393 virtual int , GetScrollRange( int orientation ) const,
1394 "Returns the built-in scrollbar range.");
1400 virtual void , ScrollWindow( int dx, int dy,
1401 const wxRect* rect = NULL ),
1402 "Physically scrolls the pixels in the window and move child windows
1403 accordingly. Use this function to optimise your scrolling
1404 implementations, to minimise the area that must be redrawn. Note that
1405 it is rarely required to call this function from a user program.
1407 dx: Amount to scroll horizontally.
1409 dy: Amount to scroll vertically.
1411 rect: Rectangle to invalidate. If this is None, the whole window
1412 is invalidated. If you pass a rectangle corresponding to the
1413 area of the window exposed by the scroll, your painting
1414 handler can optimize painting by checking for the
1415 invalidated region.");
1419 virtual bool , ScrollLines(int lines),
1420 "If the platform and window class supports it, scrolls the window by
1421 the given number of lines down, if lines is positive, or up if lines
1422 is negative. Returns True if the window was scrolled, False if it was
1423 already on top/bottom and nothing was done.");
1426 virtual bool , ScrollPages(int pages),
1427 "If the platform and window class supports it, scrolls the window by
1428 the given number of pages down, if pages is positive, or up if pages
1429 is negative. Returns True if the window was scrolled, False if it was
1430 already on top/bottom and nothing was done.");
1435 "This is just a wrapper for ScrollLines(-1).");
1439 "This is just a wrapper for ScrollLines(1).");
1443 "This is just a wrapper for ScrollPages(-1).");
1447 "This is just a wrapper for ScrollPages(1).");
1452 // context-sensitive help
1453 // ----------------------
1456 void , SetHelpText(const wxString& text),
1457 "Sets the help text to be used as context-sensitive help for this
1458 window. Note that the text is actually stored by the current
1459 wxHelpProvider implementation, and not in the window object itself.");
1463 void , SetHelpTextForId(const wxString& text),
1464 "Associate this help text with all windows with the same id as this
1469 wxString , GetHelpText() const,
1470 "Gets the help text to be used as context-sensitive help for this
1471 window. Note that the text is actually stored by the current
1472 wxHelpProvider implementation, and not in the window object itself.");
1481 "Attach a tooltip to the window.");
1482 %name(SetToolTipString) void SetToolTip( const wxString &tip );
1483 void SetToolTip( wxToolTip *tip );
1486 wxToolTip* , GetToolTip() const,
1487 "get the associated tooltip or None if none");
1489 // LINK ERROR --> wxString GetToolTipText() const;
1498 // set/retrieve the drop target associated with this window (may be
1499 // NULL; it's owned by the window and will be deleted by it)
1500 %apply SWIGTYPE *DISOWN { wxPyDropTarget *dropTarget };
1503 virtual void , SetDropTarget( wxPyDropTarget *dropTarget ),
1504 "Associates a drop target with this window. If the window already has
1505 a drop target, it is deleted.");
1507 %clear wxPyDropTarget *dropTarget;
1511 virtual wxPyDropTarget *, GetDropTarget() const,
1512 "Returns the associated drop target, which may be None.");
1515 #ifdef __WXMSW__ // TODO: should I drop-kick this?
1517 void , DragAcceptFiles(bool accept),
1518 "Enables or disables eligibility for drop file events, EVT_DROP_FILES.
1519 Only available on Windows.");
1524 // constraints and sizers
1525 // ----------------------
1527 // set the constraints for this window or retrieve them (may be NULL)
1529 void , SetConstraints( wxLayoutConstraints *constraints ),
1530 "Sets the window to have the given layout constraints. If an existing
1531 layout constraints object is already owned by the window, it will be
1532 deleted. Pass None to disassociate and delete the window's current
1535 You must call SetAutoLayout to tell a window to use the constraints
1536 automatically in its default EVT_SIZE handler; otherwise, you must
1537 handle EVT_SIZE yourself and call Layout() explicitly. When setting
1538 both a wx.LayoutConstraints and a wx.Sizer, only the sizer will have
1542 wxLayoutConstraints *, GetConstraints() const,
1543 "Returns a pointer to the window's layout constraints, or None if there
1548 void , SetAutoLayout( bool autoLayout ),
1549 "Determines whether the Layout function will be called automatically
1550 when the window is resized. It is called implicitly by SetSizer but
1551 if you use SetConstraints you should call it manually or otherwise the
1552 window layout won't be correctly updated when its size changes.");
1555 bool , GetAutoLayout() const,
1556 "Returns the current autoLayout setting");
1560 virtual bool , Layout(),
1561 "Invokes the constraint-based layout algorithm or the sizer-based
1562 algorithm for this window. See SetAutoLayout: when auto layout is on,
1563 this function gets called automatically by the default EVT_SIZE
1564 handler when the window is resized.");
1568 void , SetSizer(wxSizer *sizer, bool deleteOld = True ),
1569 "Sets the window to have the given layout sizer. The window will then
1570 own the object, and will take care of its deletion. If an existing
1571 layout sizer object is already owned by the window, it will be deleted
1572 if the deleteOld parameter is true. Note that this function will also
1573 call SetAutoLayout implicitly with a True parameter if the sizer is
1574 non-NoneL and False otherwise.");
1577 void , SetSizerAndFit( wxSizer *sizer, bool deleteOld = True ),
1578 "The same as SetSizer, except it also sets the size hints for the
1579 window based on the sizer's minimum size.");
1583 wxSizer *, GetSizer() const,
1584 "Return the sizer associated with the window by a previous call to
1585 SetSizer or None if there isn't one.");
1588 // Track if this window is a member of a sizer
1590 void , SetContainingSizer(wxSizer* sizer),
1591 "This normally does not need to be called by application code. It is
1592 called internally when a window is added to a sizer, and is used so
1593 the window can remove itself from the sizer when it is destroyed.");
1596 wxSizer *, GetContainingSizer() const,
1597 "Return the sizer that this window is a member of, if any, otherwise None.");
1603 // ----------------------
1604 #if wxUSE_ACCESSIBILITY
1605 // Override to create a specific accessible object.
1606 virtual wxAccessible* CreateAccessible();
1608 // Sets the accessible object.
1609 void SetAccessible(wxAccessible* accessible) ;
1611 // Returns the accessible object.
1612 wxAccessible* GetAccessible() { return m_accessible; };
1614 // Returns the accessible object, creating if necessary.
1615 wxAccessible* GetOrCreateAccessible() ;
1621 def PostCreate(self, pre):
1623 Phase 3 of the 2-phase create <wink!>
1624 Call this method after precreating the window with the 2-phase create method.
1626 self.this = pre.this
1627 self.thisown = pre.thisown
1629 if hasattr(self, '_setOORInfo'):
1630 self._setOORInfo(self)
1631 if hasattr(self, '_setCallbackInfo'):
1632 self._setCallbackInfo(self, self.__class__)
1644 def DLG_PNT(win, point_or_x, y=None):
1646 Convenience function for converting a Point or (x,y) in
1647 dialog units to pixel units.
1650 return win.ConvertDialogPointToPixels(point_or_x)
1652 return win.ConvertDialogPointToPixels(wx.Point(point_or_x, y))
1654 def DLG_SZE(win, size_width, height=None):
1656 Convenience function for converting a Size or (w,h) in
1657 dialog units to pixel units.
1660 return win.ConvertDialogSizeToPixels(size_width)
1662 return win.ConvertDialogSizeToPixels(wx.Size(size_width, height))
1668 // Unfortunatly the names of these new static methods clash with the
1669 // names wxPython has been using forever for the overloaded
1670 // wxWindow::FindWindow, so instead of swigging them as statics create
1671 // standalone functions for them.
1674 DocStr(wxFindWindowById,
1675 "Find the first window in the application with the given id. If parent
1676 is None, the search will start from all top-level frames and dialog
1677 boxes; if non-None, the search will be limited to the given window
1678 hierarchy. The search is recursive in both cases.");
1680 DocStr(wxFindWindowByName,
1681 "Find a window by its name (as given in a window constructor or Create
1682 function call). If parent is None, the search will start from all
1683 top-level frames and dialog boxes; if non-None, the search will be
1684 limited to the given window hierarchy. The search is recursive in both
1687 If no window with such name is found, wx.FindWindowByLabel is called.");
1689 DocStr(wxFindWindowByLabel,
1690 "Find a window by its label. Depending on the type of window, the label
1691 may be a window title or panel item label. If parent is None, the
1692 search will start from all top-level frames and dialog boxes; if
1693 non-None, the search will be limited to the given window
1694 hierarchy. The search is recursive in both cases.");
1698 wxWindow* wxFindWindowById( long id, const wxWindow *parent = NULL ) {
1699 return wxWindow::FindWindowById(id, parent);
1702 wxWindow* wxFindWindowByName( const wxString& name,
1703 const wxWindow *parent = NULL ) {
1704 return wxWindow::FindWindowByName(name, parent);
1707 wxWindow* wxFindWindowByLabel( const wxString& label,
1708 const wxWindow *parent = NULL ) {
1709 return wxWindow::FindWindowByLabel(label, parent);
1717 #include <wx/msw/private.h> // to get wxGetWindowId
1722 wxWindow* wxWindow_FromHWND(wxWindow* parent, unsigned long _hWnd) {
1724 WXHWND hWnd = (WXHWND)_hWnd;
1725 long id = wxGetWindowId(hWnd);
1726 wxWindow* win = new wxWindow;
1727 parent->AddChild(win);
1728 win->SetEventHandler(win);
1731 win->SubclassWin(hWnd);
1732 win->AdoptAttributesFromHWND();
1733 win->SetupColours();
1736 wxPyRaiseNotImplemented();
1742 //---------------------------------------------------------------------------
1743 //---------------------------------------------------------------------------