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