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