]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/window.tex
made wxPanel be auto layout aware
[wxWidgets.git] / docs / latex / wx / window.tex
CommitLineData
a660d684
KB
1\section{\class{wxWindow}}\label{wxwindow}
2
2cdac558 3wxWindow is the base class for all windows. Any children of the window will be deleted
4130b487
RR
4automatically by the destructor before the window itself is deleted.
5
2cdac558
RD
6Please note that we documented a number of handler functions (OnChar(), OnMouse() etc.) in this
7help text. These must not be called by a user program and are documented only for illustration.
4130b487
RR
8On several platforms, only a few of these handlers are actually written (they are not always
9needed) and if you are uncertain on how to add a certain behaviour to a window class, intercept
10the respective event as usual and call \helpref{wxEvent::Skip}{wxeventskip} so that the native
11platform can implement its native behaviour or just ignore the event if nothing needs to be
12done.
a660d684
KB
13
14\wxheading{Derived from}
15
16\helpref{wxEvtHandler}{wxevthandler}\\
17\helpref{wxObject}{wxobject}
18
954b8ae6
JS
19\wxheading{Include files}
20
21<wx/window.h>
22
a660d684
KB
23\wxheading{Window styles}
24
25The following styles can apply to all windows, although they will not always make sense for a particular
4130b487 26window class or on all platforms.
a660d684
KB
27
28\twocolwidtha{5cm}%
29\begin{twocollist}\itemsep=0pt
30\twocolitem{\windowstyle{wxSIMPLE\_BORDER}}{Displays a thin border around the window. wxBORDER is the old name
27d029c7 31for this style. }
a660d684
KB
32\twocolitem{\windowstyle{wxDOUBLE\_BORDER}}{Displays a double border. Windows only.}
33\twocolitem{\windowstyle{wxSUNKEN\_BORDER}}{Displays a sunken border.}
27d029c7 34\twocolitem{\windowstyle{wxRAISED\_BORDER}}{Displays a raised border. GTK only. }
6453876e 35\twocolitem{\windowstyle{wxSTATIC\_BORDER}}{Displays a border suitable for a static control. Windows only. }
a660d684
KB
36\twocolitem{\windowstyle{wxTRANSPARENT\_WINDOW}}{The window is transparent, that is, it will not receive paint
37events. Windows only.}
38\twocolitem{\windowstyle{wxNO\_3D}}{Prevents the children of this window taking on 3D styles, even though
39the application-wide policy is for 3D controls. Windows only.}
40\twocolitem{\windowstyle{wxTAB\_TRAVERSAL}}{Use this to enable tab traversal for non-dialog windows.}
895fc9cb
VZ
41\twocolitem{\windowstyle{wxWANTS\_CHARS}}{Use this to indicate that the window
42wants to get all char events - even for keys like TAB or ENTER which are
43usually used for dialog navigation and which wouldn't be generated without
44this style}
45\twocolitem{\windowstyle{wxNO\_FULLREPAINT\_ON\_RESIZE}}{Disables repainting
46the window completely when its size is changed - you will have to repaint the
47new window area manually if you use style. Currently only has effect for
4130b487 48Windows.}
6453876e
RR
49\twocolitem{\windowstyle{wxVSCROLL}}{Use this style to enable a vertical scrollbar. (Still used?) }
50\twocolitem{\windowstyle{wxHSCROLL}}{Use this style to enable a horizontal scrollbar. (Still used?) }
884360bc 51\twocolitem{\windowstyle{wxCLIP\_CHILDREN}}{Use this style to eliminate flicker caused by the background being
6453876e 52repainted, then children being painted over them. Windows only.}
a660d684
KB
53\end{twocollist}
54
55See also \helpref{window styles overview}{windowstyles}.
56
57\wxheading{See also}
58
59\helpref{Event handling overview}{eventhandlingoverview}
60
61\latexignore{\rtfignore{\wxheading{Members}}}
62
63\membersection{wxWindow::wxWindow}
64
65\func{}{wxWindow}{\void}
66
67Default constructor.
68
eaaa6a06 69\func{}{wxWindow}{\param{wxWindow*}{ parent}, \param{wxWindowID }{id},
a660d684
KB
70 \param{const wxPoint\& }{pos = wxDefaultPosition},
71 \param{const wxSize\& }{size = wxDefaultSize},
eaaa6a06 72 \param{long }{style = 0},
a660d684
KB
73 \param{const wxString\& }{name = wxPanelNameStr}}
74
75Constructs a window, which can be a child of a frame, dialog or any other non-control window.
76
77\wxheading{Parameters}
78
79\docparam{parent}{Pointer to a parent window.}
80
81\docparam{id}{Window identifier. If -1, will automatically create an identifier.}
82
83\docparam{pos}{Window position. wxDefaultPosition is (-1, -1) which indicates that wxWindows
84should generate a default position for the window. If using the wxWindow class directly, supply
85an actual position.}
86
87\docparam{size}{Window size. wxDefaultSize is (-1, -1) which indicates that wxWindows
6453876e
RR
88should generate a default size for the window. If no suitable size can be found, the
89window will be sized to 20x20 pixels so that the window is visible but obviously not
90correctly sized. }
a660d684
KB
91
92\docparam{style}{Window style. For generic window styles, please see \helpref{wxWindow}{wxwindow}.}
93
94\docparam{name}{Window name.}
95
96\membersection{wxWindow::\destruct{wxWindow}}
97
98\func{}{\destruct{wxWindow}}{\void}
99
100Destructor. Deletes all subwindows, then deletes itself. Instead of using
101the {\bf delete} operator explicitly, you should normally
102use \helpref{wxWindow::Destroy}{wxwindowdestroy} so that wxWindows
103can delete a window only when it is safe to do so, in idle time.
104
105\wxheading{See also}
106
107\helpref{Window deletion overview}{windowdeletionoverview},\rtfsp
108\helpref{wxWindow::OnCloseWindow}{wxwindowonclosewindow},\rtfsp
109\helpref{wxWindow::Destroy}{wxwindowdestroy},\rtfsp
110\helpref{wxCloseEvent}{wxcloseevent}
111
112\membersection{wxWindow::AddChild}
113
114\func{virtual void}{AddChild}{\param{wxWindow* }{child}}
115
116Adds a child window. This is called automatically by window creation
117functions so should not be required by the application programmer.
118
119\wxheading{Parameters}
120
121\docparam{child}{Child window to add.}
122
123\membersection{wxWindow::CaptureMouse}\label{wxwindowcapturemouse}
124
125\func{virtual void}{CaptureMouse}{\void}
126
127Directs all mouse input to this window. Call \helpref{wxWindow::ReleaseMouse}{wxwindowreleasemouse} to
128release the capture.
129
130\wxheading{See also}
131
132\helpref{wxWindow::ReleaseMouse}{wxwindowreleasemouse}
133
134\membersection{wxWindow::Center}\label{wxwindowcenter}
135
eaaa6a06 136\func{void}{Center}{\param{int}{ direction}}
a660d684
KB
137
138A synonym for \helpref{Centre}{wxwindowcentre}.
139
7631a292
RD
140\membersection{wxWindow::CenterOnParent}\label{wxwindowcenteronparent}
141
142\func{void}{CenterOnParent}{\param{int}{ direction}}
143
144A synonym for \helpref{CentreOnParent}{wxwindowcentreonparent}.
145
a660d684
KB
146\membersection{wxWindow::Centre}\label{wxwindowcentre}
147
7631a292 148\func{void}{Centre}{\param{int}{ direction = wxHORIZONTAL}}
a660d684
KB
149
150Centres the window.
151
152\wxheading{Parameters}
153
154\docparam{direction}{Specifies the direction for the centering. May be {\tt wxHORIZONTAL}, {\tt wxVERTICAL}\rtfsp
18ac8d69
RD
155or {\tt wxBOTH}. It may also include {\tt wxCENTRE\_ON\_SCREEN} flag
156if you want to center the window on the entire screen and not on its
157parent window.}
d22699b5
VZ
158
159The flag {\tt wxCENTRE\_FRAME} is obsolete and should not be used any longer.
a660d684
KB
160
161\wxheading{Remarks}
162
d22699b5
VZ
163If the window is a top level one (i.e. doesn't have a parent), it will be
164centered relative to the screen anyhow.
a660d684
KB
165
166\wxheading{See also}
167
168\helpref{wxWindow::Center}{wxwindowcenter}
169
7631a292
RD
170\membersection{wxWindow::CentreOnParent}\label{wxwindowcentreonparent}
171
172\func{void}{CentreOnParent}{\param{int}{ direction = wxHORIZONTAL}}
173
174Centres the window.
175
176\wxheading{Parameters}
177
178\docparam{direction}{Specifies the direction for the centering. May be {\tt wxHORIZONTAL}, {\tt wxVERTICAL}\rtfsp
179or {\tt wxBOTH}.}
180
181\wxheading{Remarks}
182
183This methods provides for a way to center top level windows over their
184parents instead of the entire screen. If there is no parent or if the
185window is not a top level window, then behaviour is the same as
186\helpref{wxWindow::Centre}{wxwindowcentre}.
187
188\wxheading{See also}
189
190\helpref{wxWindow::CenterOnParent}{wxwindowcenteronparent}
191
a660d684
KB
192\membersection{wxWindow::Clear}\label{wxwindowclear}
193
194\func{void}{Clear}{\void}
195
5b6aa0ff
JS
196Clears the window by filling it with the current background colour. Does not
197cause an erase background event to be generated.
a660d684
KB
198
199\membersection{wxWindow::ClientToScreen}
200
201\constfunc{virtual void}{ClientToScreen}{\param{int* }{x}, \param{int* }{y}}
202
a974387a
JS
203\constfunc{virtual wxPoint}{ClientToScreen}{\param{const wxPoint\&}{ pt}}
204
a660d684
KB
205Converts to screen coordinates from coordinates relative to this window.
206
207\docparam{x}{A pointer to a integer value for the x coordinate. Pass the client coordinate in, and
208a screen coordinate will be passed out.}
209
210\docparam{y}{A pointer to a integer value for the y coordinate. Pass the client coordinate in, and
211a screen coordinate will be passed out.}
212
a974387a
JS
213\docparam{pt}{The client position for the second form of the function.}
214
06d20283
RD
215\pythonnote{In place of a single overloaded method name, wxPython
216implements the following methods:\par
217\indented{2cm}{\begin{twocollist}
218\twocolitem{\bf{ClientToScreen(point)}}{Accepts and returns a wxPoint}
219\twocolitem{\bf{ClientToScreenXY(x, y)}}{Returns a 2-tuple, (x, y)}
220\end{twocollist}}
221}
222
223
a660d684
KB
224\membersection{wxWindow::Close}\label{wxwindowclose}
225
226\func{virtual bool}{Close}{\param{const bool}{ force = FALSE}}
227
228The purpose of this call is to provide a safer way of destroying a window than using
229the {\it delete} operator.
230
231\wxheading{Parameters}
232
233\docparam{force}{FALSE if the window's close handler should be able to veto the destruction
234of this window, TRUE if it cannot.}
235
236\wxheading{Remarks}
237
238Close calls the \helpref{close handler}{wxcloseevent} for the window, providing an opportunity for the window to
239choose whether to destroy the window.
240
241The close handler should check whether the window is being deleted forcibly,
242using \helpref{wxCloseEvent::GetForce}{wxcloseeventgetforce}, in which case it should
243destroy the window using \helpref{wxWindow::Destroy}{wxwindowdestroy}.
244
245Applies to managed windows (wxFrame and wxDialog classes) only.
246
532372a3
JS
247{\it Note} that calling Close does not guarantee that the window will be destroyed; but it
248provides a way to simulate a manual close of a window, which may or may not be implemented by
249destroying the window. The default implementation of wxDialog::OnCloseWindow does not
250necessarily delete the dialog, since it will simply simulate an wxID\_CANCEL event which
251itself only hides the dialog.
252
253To guarantee that the window will be destroyed, call \helpref{wxWindow::Destroy}{wxwindowdestroy} instead.
254
a660d684
KB
255\wxheading{See also}
256
257\helpref{Window deletion overview}{windowdeletionoverview},\rtfsp
258\helpref{wxWindow::OnCloseWindow}{wxwindowonclosewindow},\rtfsp
259\helpref{wxWindow::Destroy}{wxwindowdestroy},\rtfsp
260\helpref{wxCloseEvent}{wxcloseevent}
261
387a3b02
JS
262\membersection{wxWindow::ConvertDialogToPixels}\label{wxwindowconvertdialogtopixels}
263
264\func{wxPoint}{ConvertDialogToPixels}{\param{const wxPoint\&}{ pt}}
265
266\func{wxSize}{ConvertDialogToPixels}{\param{const wxSize\&}{ sz}}
267
268Converts a point or size from dialog units to pixels.
269
270For the x dimension, the dialog units are multiplied by the average character width
271and then divided by 4.
272
273For the y dimension, the dialog units are multiplied by the average character height
274and then divided by 8.
275
276\wxheading{Remarks}
277
278Dialog units are used for maintaining a dialog's proportions even if the font changes.
279Dialogs created using Dialog Editor optionally use dialog units.
280
281You can also use these functions programmatically. A convenience macro is defined:
282
283{\small
284\begin{verbatim}
285#define wxDLG_UNIT(parent, pt) parent->ConvertDialogToPixels(pt)
286\end{verbatim}
287}
288
289\wxheading{See also}
290
291\helpref{wxWindow::ConvertPixelsToDialog}{wxwindowconvertpixelstodialog}
292
06d20283
RD
293\pythonnote{In place of a single overloaded method name, wxPython
294implements the following methods:\par
295\indented{2cm}{\begin{twocollist}
296\twocolitem{\bf{ConvertDialogPointToPixels(point)}}{Accepts and returns a wxPoint}
297\twocolitem{\bf{ConvertDialogSizeToPixels(size)}}{Accepts and returns a wxSize}
298\end{twocollist}}
299
300Additionally, the following helper functions are defined:\par
301\indented{2cm}{\begin{twocollist}
34636400 302\twocolitem{\bf{wxDLG\_PNT(win, point)}}{Converts a wxPoint from dialog
06d20283 303units to pixels}
34636400 304\twocolitem{\bf{wxDLG\_SZE(win, size)}}{Converts a wxSize from dialog
06d20283
RD
305units to pixels}
306\end{twocollist}}
307}
308
309
387a3b02
JS
310\membersection{wxWindow::ConvertPixelsToDialog}\label{wxwindowconvertpixelstodialog}
311
312\func{wxPoint}{ConvertPixelsToDialog}{\param{const wxPoint\&}{ pt}}
313
314\func{wxSize}{ConvertPixelsToDialog}{\param{const wxSize\&}{ sz}}
315
316Converts a point or size from pixels to dialog units.
317
318For the x dimension, the pixels are multiplied by 4 and then divided by the average
319character width.
320
321For the y dimension, the pixels are multipled by 8 and then divided by the average
322character height.
323
324\wxheading{Remarks}
325
326Dialog units are used for maintaining a dialog's proportions even if the font changes.
327Dialogs created using Dialog Editor optionally use dialog units.
328
329\wxheading{See also}
330
331\helpref{wxWindow::ConvertDialogToPixels}{wxwindowconvertdialogtopixels}
332
06d20283
RD
333
334\pythonnote{In place of a single overloaded method name, wxPython
335implements the following methods:\par
336\indented{2cm}{\begin{twocollist}
337\twocolitem{\bf{ConvertDialogPointToPixels(point)}}{Accepts and returns a wxPoint}
338\twocolitem{\bf{ConvertDialogSizeToPixels(size)}}{Accepts and returns a wxSize}
339\end{twocollist}}
340}
341
a660d684
KB
342\membersection{wxWindow::Destroy}\label{wxwindowdestroy}
343
344\func{virtual bool}{Destroy}{\void}
345
346Destroys the window safely. Use this function instead of the delete operator, since
347different window classes can be destroyed differently. Frames and dialogs
348are not destroyed immediately when this function is called - they are added
349to a list of windows to be deleted on idle time, when all the window's events
350have been processed. This prevents problems with events being sent to non-existant
351windows.
352
353\wxheading{Return value}
354
355TRUE if the window has either been successfully deleted, or it has been added
356to the list of windows pending real deletion.
357
358\membersection{wxWindow::DestroyChildren}
359
360\func{virtual void}{DestroyChildren}{\void}
361
362Destroys all children of a window. Called automatically by the destructor.
363
364\membersection{wxWindow::DragAcceptFiles}\label{wxwindowdragacceptfiles}
365
366\func{virtual void}{DragAcceptFiles}{\param{const bool}{ accept}}
367
368Enables or disables elibility for drop file events (OnDropFiles).
369
370\wxheading{Parameters}
371
372\docparam{accept}{If TRUE, the window is eligible for drop file events. If FALSE, the window
373will not accept drop file events.}
374
375\wxheading{Remarks}
376
377Windows only.
378
379\wxheading{See also}
380
381\helpref{wxWindow::OnDropFiles}{wxwindowondropfiles}
382
383\membersection{wxWindow::Enable}\label{wxwindowenable}
384
385\func{virtual void}{Enable}{\param{const bool}{ enable}}
386
387Enable or disable the window for user input.
388
389\wxheading{Parameters}
390
391\docparam{enable}{If TRUE, enables the window for input. If FALSE, disables the window.}
392
393\wxheading{See also}
394
395\helpref{wxWindow::IsEnabled}{wxwindowisenabled}
396
a660d684
KB
397\membersection{wxWindow::FindFocus}\label{wxwindowfindfocus}
398
399\func{static wxWindow*}{FindFocus}{\void}
400
401Finds the window or control which currently has the keyboard focus.
402
403\wxheading{Remarks}
404
405Note that this is a static function, so it can be called without needing a wxWindow pointer.
406
407\wxheading{See also}
408
409\helpref{wxWindow::SetFocus}{wxwindowsetfocus}
410
dfad0599
JS
411\membersection{wxWindow::FindWindow}\label{wxwindowfindwindow}
412
413\func{wxWindow*}{FindWindow}{\param{long}{ id}}
414
415Find a child of this window, by identifier.
416
417\func{wxWindow*}{FindWindow}{\param{const wxString\&}{ name}}
418
419Find a child of this window, by name.
420
06d20283
RD
421\pythonnote{In place of a single overloaded method name, wxPython
422implements the following methods:\par
423\indented{2cm}{\begin{twocollist}
424\twocolitem{\bf{FindWindowById(id)}}{Accepts an integer}
425\twocolitem{\bf{FindWindowByName(name)}}{Accepts a string}
426\end{twocollist}}
427}
428
a660d684
KB
429\membersection{wxWindow::Fit}\label{wxwindowfit}
430
431\func{virtual void}{Fit}{\void}
432
433Sizes the window so that it fits around its subwindows.
434
435\membersection{wxWindow::GetBackgroundColour}\label{wxwindowgetbackgroundcolour}
436
437\constfunc{virtual wxColour}{GetBackgroundColour}{\void}
438
439Returns the background colour of the window.
440
441\wxheading{See also}
442
443\helpref{wxWindow::SetBackgroundColour}{wxwindowsetbackgroundcolour},\rtfsp
444\helpref{wxWindow::SetForegroundColour}{wxwindowsetforegroundcolour},\rtfsp
445\helpref{wxWindow::GetForegroundColour}{wxwindowgetforegroundcolour},\rtfsp
446\helpref{wxWindow::OnEraseBackground}{wxwindowonerasebackground}
447
448\membersection{wxWindow::GetCharHeight}
449
450\constfunc{virtual int}{GetCharHeight}{\void}
451
452Returns the character height for this window.
453
454\membersection{wxWindow::GetCharWidth}
455
456\constfunc{virtual int}{GetCharWidth}{\void}
457
458Returns the average character width for this window.
459
460\membersection{wxWindow::GetChildren}
461
c0ed460c 462\func{wxList\&}{GetChildren}{\void}
a660d684 463
c0ed460c 464Returns a reference to the list of the window's children.
a660d684
KB
465
466\membersection{wxWindow::GetClientSize}\label{wxwindowgetclientsize}
467
468\constfunc{virtual void}{GetClientSize}{\param{int* }{width}, \param{int* }{height}}
469
a974387a
JS
470\constfunc{virtual wxSize}{GetClientSize}{\void}
471
a660d684
KB
472This gets the size of the window `client area' in pixels. The client area is the
473area which may be drawn on by the programmer, excluding title bar, border etc.
474
475\wxheading{Parameters}
476
477\docparam{width}{Receives the client width in pixels.}
478
479\docparam{height}{Receives the client height in pixels.}
480
06d20283
RD
481\pythonnote{In place of a single overloaded method name, wxPython
482implements the following methods:\par
483\indented{2cm}{\begin{twocollist}
484\twocolitem{\bf{wxGetClientSizeTuple()}}{Returns a 2-tuple of (width, height)}
485\twocolitem{\bf{wxGetClientSize()}}{Returns a wxSize object}
486\end{twocollist}}
487}
488
a660d684
KB
489\membersection{wxWindow::GetConstraints}\label{wxwindowgetconstraints}
490
491\constfunc{wxLayoutConstraints*}{GetConstraints}{\void}
492
493Returns a pointer to the window's layout constraints, or NULL if there are none.
494
495\membersection{wxWindow::GetDefaultItem}\label{wxwindowgetdefaultitem}
496
497\constfunc{wxButton*}{GetDefaultItem}{\void}
498
499Returns a pointer to the button which is the default for this window, or NULL.
500
dface61c
JS
501\membersection{wxWindow::GetDropTarget}\label{wxwindowgetdroptarget}
502
503\constfunc{wxDropTarget*}{GetDropTarget}{\void}
504
505Returns the associated drop target, which may be NULL.
506
507\wxheading{See also}
508
06d20283 509\helpref{wxWindow::SetDropTarget}{wxwindowsetdroptarget},
dface61c
JS
510\helpref{Drag and drop overview}{wxdndoverview}
511
a660d684
KB
512\membersection{wxWindow::GetEventHandler}\label{wxwindowgeteventhandler}
513
514\constfunc{wxEvtHandler*}{GetEventHandler}{\void}
515
516Returns the event handler for this window. By default, the window is its
517own event handler.
518
519\wxheading{See also}
520
521\helpref{wxWindow::SetEventHandler}{wxwindowseteventhandler},\rtfsp
522\helpref{wxWindow::PushEventHandler}{wxwindowpusheventhandler},\rtfsp
523\helpref{wxWindow::PopEventHandler}{wxwindowpusheventhandler},\rtfsp
524\helpref{wxEvtHandler::ProcessEvent}{wxevthandlerprocessevent},\rtfsp
525\helpref{wxEvtHandler}{wxevthandler}\rtfsp
526
527\membersection{wxWindow::GetFont}\label{wxwindowgetfont}
528
c0ed460c 529\constfunc{wxFont\&}{GetFont}{\void}
a660d684 530
c0ed460c 531Returns a reference to the font for this window.
a660d684
KB
532
533\wxheading{See also}
534
535\helpref{wxWindow::SetFont}{wxwindowsetfont}
536
537\membersection{wxWindow::GetForegroundColour}\label{wxwindowgetforegroundcolour}
538
539\func{virtual wxColour}{GetForegroundColour}{\void}
540
541Returns the foreground colour of the window.
542
543\wxheading{Remarks}
544
545The interpretation of foreground colour is open to interpretation according
546to the window class; it may be the text colour or other colour, or it may not
547be used at all.
548
549\wxheading{See also}
550
551\helpref{wxWindow::SetForegroundColour}{wxwindowsetforegroundcolour},\rtfsp
552\helpref{wxWindow::SetBackgroundColour}{wxwindowsetbackgroundcolour},\rtfsp
553\helpref{wxWindow::GetBackgroundColour}{wxwindowgetbackgroundcolour}
554
555\membersection{wxWindow::GetGrandParent}
556
557\constfunc{wxWindow*}{GetGrandParent}{\void}
558
559Returns the grandparent of a window, or NULL if there isn't one.
560
561\membersection{wxWindow::GetHandle}
562
563\constfunc{void*}{GetHandle}{\void}
564
565Returns the platform-specific handle of the physical window. Cast it to an appropriate
6453876e 566handle, such as {\bf HWND} for Windows, {\bf Widget} for Motif or {\bf GtkWidget} for GTK.
a660d684
KB
567
568\membersection{wxWindow::GetId}\label{wxwindowgetid}
569
570\constfunc{int}{GetId}{\void}
571
572Returns the identifier of the window.
573
574\wxheading{Remarks}
575
6453876e
RR
576Each window has an integer identifier. If the application has not provided one
577(or the default Id -1) an unique identifier with a negative value will be generated.
a660d684 578
a660d684
KB
579\wxheading{See also}
580
5b6aa0ff
JS
581\helpref{wxWindow::SetId}{wxwindowsetid}\rtfsp
582\helpref{Window identifiers}{windowids}
a660d684
KB
583
584\membersection{wxWindow::GetPosition}
585
586\constfunc{virtual void}{GetPosition}{\param{int* }{x}, \param{int* }{y}}
587
588This gets the position of the window in pixels, relative to the parent window or
589if no parent, relative to the whole display.
590
591\wxheading{Parameters}
592
593\docparam{x}{Receives the x position of the window.}
594
595\docparam{y}{Receives the y position of the window.}
596
06d20283
RD
597\pythonnote{In place of a single overloaded method name, wxPython
598implements the following methods:\par
599\indented{2cm}{\begin{twocollist}
600\twocolitem{\bf{GetPosition()}}{Returns a wxPoint}
601\twocolitem{\bf{GetPositionTuple()}}{Returns a tuple (x, y)}
602\end{twocollist}}
603}
604
a660d684
KB
605\membersection{wxWindow::GetLabel}
606
6453876e 607\constfunc{virtual wxString }{GetLabel}{\void}
a660d684
KB
608
609Generic way of getting a label from any window, for
610identification purposes.
611
612\wxheading{Remarks}
613
614The interpretation of this function differs from class to class.
615For frames and dialogs, the value returned is the title. For buttons or static text controls, it is
616the button text. This function can be useful for meta-programs (such as testing
617tools or special-needs access programs) which need to identify windows
618by name.
619
620\membersection{wxWindow::GetName}\label{wxwindowgetname}
621
6453876e 622\constfunc{virtual wxString }{GetName}{\void}
a660d684
KB
623
624Returns the window's name.
625
626\wxheading{Remarks}
627
628This name is not guaranteed to be unique; it is up to the programmer to supply an appropriate
629name in the window constructor or via \helpref{wxWindow::SetName}{wxwindowsetname}.
630
631\wxheading{See also}
632
633\helpref{wxWindow::SetName}{wxwindowsetname}
634
635\membersection{wxWindow::GetParent}
636
637\constfunc{virtual wxWindow*}{GetParent}{\void}
638
639Returns the parent of the window, or NULL if there is no parent.
640
a974387a
JS
641\membersection{wxWindow::GetRect}\label{wxwindowgetrect}
642
643\constfunc{virtual wxRect}{GetRect}{\void}
644
645Returns the size and position of the window as a \helpref{wxRect}{wxrect} object.
646
a660d684
KB
647\membersection{wxWindow::GetScrollThumb}\label{wxwindowgetscrollthumb}
648
eaaa6a06 649\func{virtual int}{GetScrollThumb}{\param{int }{orientation}}
a660d684
KB
650
651Returns the built-in scrollbar thumb size.
652
653\wxheading{See also}
654
655\helpref{wxWindow::SetScrollbar}{wxwindowsetscrollbar}
656
657\membersection{wxWindow::GetScrollPos}\label{wxwindowgetscrollpos}
658
eaaa6a06 659\func{virtual int}{GetScrollPos}{\param{int }{orientation}}
a660d684
KB
660
661Returns the built-in scrollbar position.
662
663\wxheading{See also}
664
665See \helpref{wxWindow::SetScrollbar}{wxwindowsetscrollbar}
666
667\membersection{wxWindow::GetScrollRange}\label{wxwindowgetscrollrange}
668
eaaa6a06 669\func{virtual int}{GetScrollRange}{\param{int }{orientation}}
a660d684
KB
670
671Returns the built-in scrollbar range.
672
673\wxheading{See also}
674
675\helpref{wxWindow::SetScrollbar}{wxwindowsetscrollbar}
676
a974387a 677\membersection{wxWindow::GetSize}\label{wxwindowgetsize}
a660d684
KB
678
679\constfunc{virtual void}{GetSize}{\param{int* }{width}, \param{int* }{height}}
680
a974387a
JS
681\constfunc{virtual wxSize}{GetSize}{\void}
682
a660d684
KB
683This gets the size of the entire window in pixels.
684
685\wxheading{Parameters}
686
687\docparam{width}{Receives the window width.}
688
689\docparam{height}{Receives the window height.}
690
06d20283
RD
691\pythonnote{In place of a single overloaded method name, wxPython
692implements the following methods:\par
693\indented{2cm}{\begin{twocollist}
694\twocolitem{\bf{GetSize()}}{Returns a wxSize}
695\twocolitem{\bf{GetSizeTuple()}}{Returns a 2-tuple (width, height)}
696\end{twocollist}}
697}
698
a660d684
KB
699\membersection{wxWindow::GetTextExtent}
700
701\constfunc{virtual void}{GetTextExtent}{\param{const wxString\& }{string}, \param{int* }{x}, \param{int* }{y},
702 \param{int* }{descent = NULL}, \param{int* }{externalLeading = NULL},
703 \param{const wxFont* }{font = NULL}, \param{const bool}{ use16 = FALSE}}
704
705Gets the dimensions of the string as it would be drawn on the
706window with the currently selected font.
707
708\wxheading{Parameters}
709
710\docparam{string}{String whose extent is to be measured.}
711
712\docparam{x}{Return value for width.}
713
714\docparam{y}{Return value for height.}
715
716\docparam{descent}{Return value for descent (optional).}
717
718\docparam{externalLeading}{Return value for external leading (optional).}
719
720\docparam{font}{Font to use instead of the current window font (optional).}
721
722\docparam{use16}{If TRUE, {\it string} contains 16-bit characters. The default is FALSE.}
723
06d20283
RD
724
725\pythonnote{In place of a single overloaded method name, wxPython
726implements the following methods:\par
727\indented{2cm}{\begin{twocollist}
728\twocolitem{\bf{GetTextExtent(string)}}{Returns a 2-tuple, (width, height)}
729\twocolitem{\bf{GetFullTextExtent(string, font=NULL)}}{Returns a
7304-tuple, (width, height, descent, externalLeading) }
731\end{twocollist}}
732}
733
734
a660d684
KB
735\membersection{wxWindow::GetTitle}\label{wxwindowgettitle}
736
737\func{virtual wxString}{GetTitle}{\void}
738
739Gets the window's title. Applicable only to frames and dialogs.
740
741\wxheading{See also}
742
743\helpref{wxWindow::SetTitle}{wxwindowsettitle}
744
76c5df24
JS
745\membersection{wxWindow::GetUpdateRegion}\label{wxwindowgetupdateregion}
746
747\constfunc{virtual wxRegion}{GetUpdateRegion}{\void}
748
749Returns the region specifying which parts of the window have been damaged. Should
750only be called within an \helpref{OnPaint}{wxwindowonpaint} event handler.
751
752\wxheading{See also}
753
754\helpref{wxRegion}{wxregion}, \helpref{wxRegionIterator}{wxregioniterator}, \helpref{wxWindow::OnPaint}{wxwindowonpaint}
755
aeab10d0
JS
756\membersection{wxWindow::GetValidator}\label{wxwindowgetvalidator}
757
758\constfunc{wxValidator*}{GetValidator}{\void}
759
760Returns a pointer to the current validator for the window, or NULL if there is none.
761
a660d684
KB
762\membersection{wxWindow::GetWindowStyleFlag}
763
764\constfunc{long}{GetWindowStyleFlag}{\void}
765
7631a292 766Gets the window style that was passed to the consructor or {\bf Create} member.
6453876e 767{\bf GetWindowStyle} is synonymous.
a660d684
KB
768
769\membersection{wxWindow::InitDialog}\label{wxwindowinitdialog}
770
771\func{void}{InitDialog}{\void}
772
773Sends an \helpref{wxWindow::OnInitDialog}{wxwindowoninitdialog} event, which
774in turn transfers data to the dialog via validators.
775
776\wxheading{See also}
777
778\helpref{wxWindow::OnInitDialog}{wxwindowoninitdialog}
779
780\membersection{wxWindow::IsEnabled}\label{wxwindowisenabled}
781
782\constfunc{virtual bool}{IsEnabled}{\void}
783
784Returns TRUE if the window is enabled for input, FALSE otherwise.
785
786\wxheading{See also}
787
788\helpref{wxWindow::Enable}{wxwindowenable}
789
515da557 790\membersection{wxWindow:IsExposed}\label{wxwindowisexposed}
ad9edf45
RR
791
792\constfunc{bool}{IsExposed}{\param{int }{x}, \param{int }{y}}
793
515da557
RR
794\constfunc{bool}{IsExposed}{\param{wxPoint }{&pt}}
795
ad9edf45
RR
796\constfunc{bool}{IsExposed}{\param{int }{x}, \param{int }{y}, \param{int }{w}, \param{int }{h}}
797
fd9811b1 798\constfunc{bool}{IsExposed}{\param{wxRect }{&rect}}
515da557 799
ad9edf45
RR
800Returns TRUE if the given point or rectange area has been exposed since the
801last repaint. Call this in an paint event handler to optimize redrawing by
4130b487 802only redrawing those areas, which have been exposed.
ad9edf45 803
a660d684
KB
804\membersection{wxWindow::IsRetained}\label{wxwindowisretained}
805
806\constfunc{virtual bool}{IsRetained}{\void}
807
808Returns TRUE if the window is retained, FALSE otherwise.
809
810\wxheading{Remarks}
811
812Retained windows are only available on X platforms.
813
814\membersection{wxWindow::IsShown}\label{wxwindowisshown}
815
816\constfunc{virtual bool}{IsShown}{\void}
817
818Returns TRUE if the window is shown, FALSE if it has been hidden.
819
34636400
VZ
820\membersection{wxWindow::IsTopLevel}\label{wxwindowistoplevel}
821
822\constfunc{bool}{IsTopLevel}{\void}
823
824Returns TRUE if the given window is a top-level one. Currently all frames and
825dialogs are considered to be top-level windows (even if they have a parent
826window).
827
a660d684
KB
828\membersection{wxWindow::Layout}\label{wxwindowlayout}
829
830\func{void}{Layout}{\void}
831
515da557
RR
832Invokes the constraint-based layout algorithm or the sizer-based algorithm
833for this window.
6453876e
RR
834
835See \helpref{wxWindow::SetAutoLayout}{wxwindowsetautolayout} on when
836this function gets called automatically using auto layout.
a660d684
KB
837
838\membersection{wxWindow::LoadFromResource}\label{wxwindowloadfromresource}
839
840\func{virtual bool}{LoadFromResource}{\param{wxWindow* }{parent},\rtfsp
841\param{const wxString\& }{resourceName}, \param{const wxResourceTable* }{resourceTable = NULL}}
842
843Loads a panel or dialog from a resource file.
844
845\wxheading{Parameters}
846
847\docparam{parent}{Parent window.}
848
849\docparam{resourceName}{The name of the resource to load.}
850
851\docparam{resourceTable}{The resource table to load it from. If this is NULL, the
852default resource table will be used.}
853
854\wxheading{Return value}
855
856TRUE if the operation succeeded, otherwise FALSE.
857
a660d684
KB
858\membersection{wxWindow::Lower}\label{wxwindowlower}
859
860\func{void}{Lower}{\void}
861
862Lowers the window to the bottom of the window hierarchy if it is a managed window (dialog
863or frame).
864
865\membersection{wxWindow::MakeModal}\label{wxwindowmakemodal}
866
867\func{virtual void}{MakeModal}{\param{const bool }{flag}}
868
869Disables all other windows in the application so that
6453876e
RR
870the user can only interact with this window. (This function
871is not implemented anywhere).
a660d684
KB
872
873\wxheading{Parameters}
874
875\docparam{flag}{If TRUE, this call disables all other windows in the application so that
876the user can only interact with this window. If FALSE, the effect is reversed.}
877
878\membersection{wxWindow::Move}\label{wxwindowmove}
879
eaaa6a06 880\func{void}{Move}{\param{int}{ x}, \param{int}{ y}}
a660d684 881
a974387a
JS
882\func{void}{Move}{\param{const wxPoint\&}{ pt}}
883
a660d684
KB
884Moves the window to the given position.
885
886\wxheading{Parameters}
887
888\docparam{x}{Required x position.}
889
890\docparam{y}{Required y position.}
891
a974387a
JS
892\docparam{pt}{\helpref{wxPoint}{wxpoint} object representing the position.}
893
a660d684
KB
894\wxheading{Remarks}
895
896Implementations of SetSize can also implicitly implement the
897wxWindow::Move function, which is defined in the base wxWindow class
898as the call:
899
900\begin{verbatim}
901 SetSize(x, y, -1, -1, wxSIZE_USE_EXISTING);
902\end{verbatim}
903
904\wxheading{See also}
905
906\helpref{wxWindow::SetSize}{wxwindowsetsize}
907
06d20283
RD
908\pythonnote{In place of a single overloaded method name, wxPython
909implements the following methods:\par
910\indented{2cm}{\begin{twocollist}
911\twocolitem{\bf{Move(point)}}{Accepts a wxPoint}
912\twocolitem{\bf{MoveXY(x, y)}}{Accepts a pair of integers}
913\end{twocollist}}
914}
915
a660d684
KB
916\membersection{wxWindow::OnActivate}\label{wxwindowonactivate}
917
918\func{void}{OnActivate}{\param{wxActivateEvent\&}{ event}}
919
920Called when a window is activated or deactivated.
921
922\wxheading{Parameters}
923
924\docparam{event}{Object containing activation information.}
925
926\wxheading{Remarks}
927
928If the window is being activated, \helpref{wxActivateEvent::GetActive}{wxactivateeventgetactive} returns TRUE,
929otherwise it returns FALSE (it is being deactivated).
930
931\wxheading{See also}
932
933\helpref{wxActivateEvent}{wxactivateevent},\rtfsp
934\helpref{Event handling overview}{eventhandlingoverview}
935
936\membersection{wxWindow::OnChar}\label{wxwindowonchar}
937
938\func{void}{OnChar}{\param{wxKeyEvent\&}{ event}}
939
818e52c2 940Called when the user has pressed a key that is not a modifier (SHIFT, CONTROL or ALT).
a660d684
KB
941
942\wxheading{Parameters}
943
944\docparam{event}{Object containing keypress information. See \helpref{wxKeyEvent}{wxkeyevent} for
945details about this class.}
946
947\wxheading{Remarks}
948
949This member function is called in response to a keypress. To intercept this event,
950use the EVT\_CHAR macro in an event table definition. Your {\bf OnChar} handler may call this
951default function to achieve default keypress functionality.
952
953Note that the ASCII values do not have explicit key codes: they are passed as ASCII
954values.
955
818e52c2 956Note that not all keypresses can be intercepted this way. If you wish to intercept modifier
06d20283 957keypresses, then you will need to use \helpref{wxWindow::OnKeyDown}{wxwindowonkeydown} or
4ce81a75
JS
958\helpref{wxWindow::OnKeyUp}{wxwindowonkeyup}.
959
a660d684
KB
960Most, but not all, windows allow keypresses to be intercepted.
961
962\wxheading{See also}
963
4ce81a75 964\helpref{wxWindow::OnKeyDown}{wxwindowonkeydown}, \helpref{wxWindow::OnKeyUp}{wxwindowonkeyup},\rtfsp
a660d684
KB
965\helpref{wxKeyEvent}{wxkeyevent}, \helpref{wxWindow::OnCharHook}{wxwindowoncharhook},\rtfsp
966\helpref{Event handling overview}{eventhandlingoverview}
967
968\membersection{wxWindow::OnCharHook}\label{wxwindowoncharhook}
969
970\func{void}{OnCharHook}{\param{wxKeyEvent\&}{ event}}
971
972This member is called to allow the window to intercept keyboard events
973before they are processed by child windows.
974
975\wxheading{Parameters}
976
977\docparam{event}{Object containing keypress information. See \helpref{wxKeyEvent}{wxkeyevent} for
978details about this class.}
979
980\wxheading{Remarks}
981
982This member function is called in response to a keypress, if the window is active. To intercept this event,
983use the EVT\_CHAR\_HOOK macro in an event table definition. If you do not process a particular
984keypress, call \helpref{wxEvent::Skip}{wxeventskip} to allow default processing.
985
986An example of using this function is in the implementation of escape-character processing for wxDialog,
987where pressing ESC dismisses the dialog by {\bf OnCharHook} 'forging' a cancel button press event.
988
989Note that the ASCII values do not have explicit key codes: they are passed as ASCII
990values.
991
992This function is only relevant to top-level windows (frames and dialogs), and under
6453876e
RR
993Windows only. Under GTK the normal EVT\_CHAR\_ event has the functionality, i.e.
994you can intercepts it and if you don't call \helpref{wxEvent::Skip}{wxeventskip}
995the window won't get the event.
a660d684
KB
996
997\wxheading{See also}
998
999\helpref{wxKeyEvent}{wxkeyevent}, \helpref{wxWindow::OnCharHook}{wxwindowoncharhook},\rtfsp
1000\helpref{wxApp::OnCharHook}{wxapponcharhook},\rtfsp
1001\helpref{Event handling overview}{eventhandlingoverview}
1002
1003\membersection{wxWindow::OnCommand}\label{wxwindowoncommand}
1004
1005\func{virtual void}{OnCommand}{\param{wxEvtHandler\& }{object}, \param{wxCommandEvent\& }{event}}
1006
1007This virtual member function is called if the control does not handle the command event.
1008
1009\wxheading{Parameters}
1010
1011\docparam{object}{Object receiving the command event.}
1012
1013\docparam{event}{Command event}
1014
1015\wxheading{Remarks}
1016
1017This virtual function is provided mainly for backward compatibility. You can also intercept commands
1018from child controls by using an event table, with identifiers or identifier ranges to identify
1019the control(s) in question.
1020
1021\wxheading{See also}
1022
1023\helpref{wxCommandEvent}{wxcommandevent},\rtfsp
1024\helpref{Event handling overview}{eventhandlingoverview}
1025
1026\membersection{wxWindow::OnClose}\label{wxwindowonclose}
1027
1028\func{virtual bool}{OnClose}{\void}
1029
1030Called when the user has tried to close a a frame
1031or dialog box using the window manager (X) or system menu (Windows).
1032
e3065973 1033{\bf Note:} This is an obsolete function.
a660d684
KB
1034It is superceded by the \helpref{wxWindow::OnCloseWindow}{wxwindowonclosewindow} event
1035handler.
1036
1037\wxheading{Return value}
1038
1039If TRUE is returned by OnClose, the window will be deleted by the system, otherwise the
1040attempt will be ignored. Do not delete the window from within this handler, although
1041you may delete other windows.
1042
a660d684
KB
1043\wxheading{See also}
1044
1045\helpref{Window deletion overview}{windowdeletionoverview},\rtfsp
1046\helpref{wxWindow::Close}{wxwindowclose},\rtfsp
1047\helpref{wxWindow::OnCloseWindow}{wxwindowonclosewindow},\rtfsp
1048\helpref{wxCloseEvent}{wxcloseevent}
1049
1050\membersection{wxWindow::OnCloseWindow}\label{wxwindowonclosewindow}
1051
1052\func{void}{OnCloseWindow}{\param{wxCloseEvent\& }{event}}
1053
1054This is an event handler function called when the user has tried to close a a frame
1055or dialog box using the window manager (X) or system menu (Windows). It is
1056called via the \helpref{wxWindow::Close}{wxwindowclose} function, so
1057that the application can also invoke the handler programmatically.
1058
1059Use the EVT\_CLOSE event table macro to handle close events.
1060
1061You should check whether the application is forcing the deletion of the window
1062using \helpref{wxCloseEvent::GetForce}{wxcloseeventgetforce}. If this is TRUE,
1063destroy the window using \helpref{wxWindow::Destroy}{wxwindowdestroy}.
1064If not, it is up to you whether you respond by destroying the window.
1065
387a3b02
JS
1066(Note: GetForce is now superceded by CanVeto. So to test whether forced destruction of
1067the window is required, test for the negative of CanVeto. If CanVeto returns FALSE,
1068it is not possible to skip window deletion.)
1069
1070If you don't destroy the window, you should call \helpref{wxCloseEvent::Veto}{wxcloseeventveto} to
1071let the calling code know that you did not destroy the window. This allows the \helpref{wxWindow::Close}{wxwindowclose} function
1072to return TRUE or FALSE depending on whether the close instruction was honoured or not.
1073
a660d684
KB
1074\wxheading{Remarks}
1075
1076The \helpref{wxWindow::OnClose}{wxwindowonclose} virtual function remains
1077for backward compatibility with earlier versions of wxWindows. The
1078default {\bf OnCloseWindow} handler for wxFrame and wxDialog will call {\bf OnClose},
1079destroying the window if it returns TRUE or if the close is being forced.
1080
1081\wxheading{See also}
1082
1083\helpref{Window deletion overview}{windowdeletionoverview},\rtfsp
1084\helpref{wxWindow::Close}{wxwindowclose},\rtfsp
1085\helpref{wxWindow::OnClose}{wxwindowonclose},\rtfsp
1086\helpref{wxWindow::Destroy}{wxwindowdestroy},\rtfsp
387a3b02
JS
1087\helpref{wxCloseEvent}{wxcloseevent},\rtfsp
1088\helpref{wxApp::OnQueryEndSession}{wxapponqueryendsession},\rtfsp
1089\helpref{wxApp::OnEndSession}{wxapponendsession}
a660d684 1090
a660d684
KB
1091\membersection{wxWindow::OnDropFiles}\label{wxwindowondropfiles}
1092
1093\func{void}{OnDropFiles}{\param{wxDropFilesEvent\&}{ event}}
1094
1095Called when files have been dragged from the file manager to the window.
1096
1097\wxheading{Parameters}
1098
1099\docparam{event}{Drop files event. For more information, see \helpref{wxDropFilesEvent}{wxdropfilesevent}.}
1100
1101\wxheading{Remarks}
1102
1103The window must have previously been enabled for dropping by calling
1104\rtfsp\helpref{wxWindow::DragAcceptFiles}{wxwindowdragacceptfiles}.
1105
1106This event is only generated under Windows.
1107
1108To intercept this event, use the EVT\_DROP\_FILES macro in an event table definition.
1109
1110\wxheading{See also}
1111
1112\helpref{wxDropFilesEvent}{wxdropfilesevent}, \helpref{wxWindow::DragAcceptFiles}{wxwindowdragacceptfiles},\rtfsp
1113\helpref{Event handling overview}{eventhandlingoverview}
1114
1115\membersection{wxWindow::OnEraseBackground}\label{wxwindowonerasebackground}
1116
1117\func{void}{OnEraseBackground}{\param{wxEraseEvent\&}{ event}}
1118
1119Called when the background of the window needs to be erased.
1120
1121\wxheading{Parameters}
1122
1123\docparam{event}{Erase background event. For more information, see \helpref{wxEraseEvent}{wxeraseevent}.}
1124
1125\wxheading{Remarks}
1126
6453876e
RR
1127This event is only generated under Windows. It is therefore recommended that
1128you set the text background colour explicitly in order to prevent flicker.
1129The default background colour under GTK is grey.
a660d684
KB
1130
1131To intercept this event, use the EVT\_ERASE\_BACKGROUND macro in an event table definition.
1132
1133\wxheading{See also}
1134
1135\helpref{wxEraseEvent}{wxeraseevent}, \helpref{Event handling overview}{eventhandlingoverview}
1136
4ce81a75
JS
1137\membersection{wxWindow::OnKeyDown}\label{wxwindowonkeydown}
1138
1139\func{void}{OnKeyDown}{\param{wxKeyEvent\&}{ event}}
1140
1141Called when the user has pressed a key, before it is translated into an ASCII value using other
1142modifier keys that might be pressed at the same time.
1143
1144\wxheading{Parameters}
1145
1146\docparam{event}{Object containing keypress information. See \helpref{wxKeyEvent}{wxkeyevent} for
1147details about this class.}
1148
1149\wxheading{Remarks}
1150
1151This member function is called in response to a key down event. To intercept this event,
1152use the EVT\_KEY\_DOWN macro in an event table definition. Your {\bf OnKeyDown} handler may call this
1153default function to achieve default keypress functionality.
1154
1155Note that not all keypresses can be intercepted this way. If you wish to intercept special
06d20283 1156keys, such as shift, control, and function keys, then you will need to use \helpref{wxWindow::OnKeyDown}{wxwindowonkeydown} or
4ce81a75
JS
1157\helpref{wxWindow::OnKeyUp}{wxwindowonkeyup}.
1158
1159Most, but not all, windows allow keypresses to be intercepted.
1160
1161\wxheading{See also}
1162
1163\helpref{wxWindow::OnChar}{wxwindowonchar}, \helpref{wxWindow::OnKeyUp}{wxwindowonkeyup},\rtfsp
1164\helpref{wxKeyEvent}{wxkeyevent}, \helpref{wxWindow::OnCharHook}{wxwindowoncharhook},\rtfsp
1165\helpref{Event handling overview}{eventhandlingoverview}
1166
1167\membersection{wxWindow::OnKeyUp}\label{wxwindowonkeyup}
1168
1169\func{void}{OnKeyUp}{\param{wxKeyEvent\&}{ event}}
1170
1171Called when the user has released a key.
1172
1173\wxheading{Parameters}
1174
1175\docparam{event}{Object containing keypress information. See \helpref{wxKeyEvent}{wxkeyevent} for
1176details about this class.}
1177
1178\wxheading{Remarks}
1179
1180This member function is called in response to a key up event. To intercept this event,
1181use the EVT\_KEY\_UP macro in an event table definition. Your {\bf OnKeyUp} handler may call this
1182default function to achieve default keypress functionality.
1183
1184Note that not all keypresses can be intercepted this way. If you wish to intercept special
06d20283 1185keys, such as shift, control, and function keys, then you will need to use \helpref{wxWindow::OnKeyDown}{wxwindowonkeydown} or
4ce81a75
JS
1186\helpref{wxWindow::OnKeyUp}{wxwindowonkeyup}.
1187
1188Most, but not all, windows allow key up events to be intercepted.
1189
1190\wxheading{See also}
1191
1192\helpref{wxWindow::OnChar}{wxwindowonchar}, \helpref{wxWindow::OnKeyDown}{wxwindowonkeydown},\rtfsp
1193\helpref{wxKeyEvent}{wxkeyevent}, \helpref{wxWindow::OnCharHook}{wxwindowoncharhook},\rtfsp
1194\helpref{Event handling overview}{eventhandlingoverview}
1195
a660d684
KB
1196\membersection{wxWindow::OnKillFocus}\label{wxwindowonkillfocus}
1197
1198\func{void}{OnKillFocus}{\param{wxFocusEvent\& }{event}}
1199
1200Called when a window's focus is being killed.
1201
1202\wxheading{Parameters}
1203
1204\docparam{event}{The focus event. For more information, see \helpref{wxFocusEvent}{wxfocusevent}.}
1205
1206\wxheading{Remarks}
1207
1208To intercept this event, use the macro EVT\_KILL\_FOCUS in an event table definition.
1209
1210Most, but not all, windows respond to this event.
1211
1212\wxheading{See also}
1213
1214\helpref{wxFocusEvent}{wxfocusevent}, \helpref{wxWindow::OnSetFocus}{wxwindowonsetfocus},\rtfsp
1215\helpref{Event handling overview}{eventhandlingoverview}
1216
1217\membersection{wxWindow::OnIdle}\label{wxwindowonidle}
1218
6e6110ee 1219\func{void}{OnIdle}{\param{wxIdleEvent\& }{event}}
a660d684
KB
1220
1221Provide this member function for any processing which needs to be done
1222when the application is idle.
1223
1224\wxheading{See also}
1225
1226\helpref{wxApp::OnIdle}{wxapponidle}, \helpref{wxIdleEvent}{wxidleevent}
1227
1228\membersection{wxWindow::OnInitDialog}\label{wxwindowoninitdialog}
1229
1230\func{void}{OnInitDialog}{\param{wxInitDialogEvent\&}{ event}}
1231
1232Default handler for the wxEVT\_INIT\_DIALOG event. Calls \helpref{wxWindow::TransferDataToWindow}{wxwindowtransferdatatowindow}.
1233
1234\wxheading{Parameters}
1235
1236\docparam{event}{Dialog initialisation event.}
1237
1238\wxheading{Remarks}
1239
1240Gives the window the default behaviour of transferring data to child controls via
1241the validator that each control has.
1242
1243\wxheading{See also}
1244
1245\helpref{wxValidator}{wxvalidator}, \helpref{wxWindow::TransferDataToWindow}{wxwindowtransferdatatowindow}
1246
1247\membersection{wxWindow::OnMenuCommand}\label{wxwindowonmenucommand}
1248
1249\func{void}{OnMenuCommand}{\param{wxCommandEvent\& }{event}}
1250
1251Called when a menu command is received from a menu bar.
1252
1253\wxheading{Parameters}
1254
1255\docparam{event}{The menu command event. For more information, see \helpref{wxCommandEvent}{wxcommandevent}.}
1256
1257\wxheading{Remarks}
1258
1259A function with this name doesn't actually exist; you can choose any member function to receive
1260menu command events, using the EVT\_COMMAND macro for individual commands or EVT\_COMMAND\_RANGE for
1261a range of commands.
1262
1263\wxheading{See also}
1264
1265\helpref{wxCommandEvent}{wxcommandevent},\rtfsp
1266\helpref{wxWindow::OnMenuHighlight}{wxwindowonmenuhighlight},\rtfsp
1267\helpref{Event handling overview}{eventhandlingoverview}
1268
1269\membersection{wxWindow::OnMenuHighlight}\label{wxwindowonmenuhighlight}
1270
1271\func{void}{OnMenuHighlight}{\param{wxMenuEvent\& }{event}}
1272
1273Called when a menu select is received from a menu bar: that is, the
1274mouse cursor is over a menu item, but the left mouse button has not been
1275pressed.
1276
1277\wxheading{Parameters}
1278
1279\docparam{event}{The menu highlight event. For more information, see \helpref{wxMenuEvent}{wxmenuevent}.}
1280
1281\wxheading{Remarks}
1282
1283You can choose any member function to receive
1284menu select events, using the EVT\_MENU\_HIGHLIGHT macro for individual menu items or EVT\_MENU\_HIGHLIGHT\_ALL macro
1285for all menu items.
1286
1287The default implementation for \helpref{wxFrame::OnMenuHighlight}{wxframeonmenuhighlight} displays help
1288text in the first field of the status bar.
1289
1290This function was known as {\bf OnMenuSelect} in earlier versions of wxWindows, but this was confusing
1291since a selection is normally a left-click action.
1292
1293\wxheading{See also}
1294
1295\helpref{wxMenuEvent}{wxmenuevent},\rtfsp
1296\helpref{wxWindow::OnMenuCommand}{wxwindowonmenucommand},\rtfsp
1297\helpref{Event handling overview}{eventhandlingoverview}
1298
1299
1300\membersection{wxWindow::OnMouseEvent}\label{wxwindowonmouseevent}
1301
1302\func{void}{OnMouseEvent}{\param{wxMouseEvent\&}{ event}}
1303
1304Called when the user has initiated an event with the
1305mouse.
1306
1307\wxheading{Parameters}
1308
1309\docparam{event}{The mouse event. See \helpref{wxMouseEvent}{wxmouseevent} for
1310more details.}
1311
1312\wxheading{Remarks}
1313
1314Most, but not all, windows respond to this event.
1315
1316To intercept this event, use the EVT\_MOUSE\_EVENTS macro in an event table definition, or individual
1317mouse event macros such as EVT\_LEFT\_DOWN.
1318
1319\wxheading{See also}
1320
1321\helpref{wxMouseEvent}{wxmouseevent},\rtfsp
1322\helpref{Event handling overview}{eventhandlingoverview}
1323
1324\membersection{wxWindow::OnMove}\label{wxwindowonmove}
1325
1326\func{void}{OnMove}{\param{wxMoveEvent\& }{event}}
1327
1328Called when a window is moved.
1329
1330\wxheading{Parameters}
1331
1332\docparam{event}{The move event. For more information, see \helpref{wxMoveEvent}{wxmoveevent}.}
1333
1334\wxheading{Remarks}
1335
1336Use the EVT\_MOVE macro to intercept move events.
1337
1338\wxheading{Remarks}
1339
1340Not currently implemented.
1341
1342\wxheading{See also}
1343
1344\helpref{wxMoveEvent}{wxmoveevent},\rtfsp
1345\helpref{wxFrame::OnSize}{wxframeonsize},\rtfsp
1346\helpref{Event handling overview}{eventhandlingoverview}
1347
1348\membersection{wxWindow::OnPaint}\label{wxwindowonpaint}
1349
1350\func{void}{OnPaint}{\param{wxPaintEvent\& }{event}}
1351
1352Sent to the event handler when the window must be refreshed.
1353
1354\wxheading{Parameters}
1355
1356\docparam{event}{Paint event. For more information, see \helpref{wxPaintEvent}{wxpaintevent}.}
1357
1358\wxheading{Remarks}
1359
1360Use the EVT\_PAINT macro in an event table definition to intercept paint events.
1361
1362In a paint event handler, the application should always create a \helpref{wxPaintDC}{wxpaintdc} object.
1363
1364For example:
1365
1366\small{%
1367\begin{verbatim}
1368 void MyWindow::OnPaint(wxPaintEvent& event)
1369 {
1370 wxPaintDC dc(this);
1371
1372 DrawMyDocument(dc);
1373 }
1374\end{verbatim}
1375}%
1376
1377You can optimize painting by retrieving the rectangles
1378that have been damaged and only repainting these. The rectangles are in
1379terms of the client area, and are unscrolled, so you will need to do
1380some calculations using the current view position to obtain logical,
1381scrolled units.
1382
76c5df24 1383Here is an example of using the \helpref{wxRegionIterator}{wxregioniterator} class:
a660d684
KB
1384
1385{\small%
1386\begin{verbatim}
1387// Called when window needs to be repainted.
1388void MyWindow::OnPaint(wxPaintEvent& event)
1389{
1390 wxPaintDC dc(this);
1391
1392 // Find Out where the window is scrolled to
1393 int vbX,vbY; // Top left corner of client
1394 ViewStart(&vbX,&vbY);
1395
1396 int vX,vY,vW,vH; // Dimensions of client area in pixels
76c5df24 1397 wxRegionIterator upd(GetUpdateRegion()); // get the update rect list
a660d684
KB
1398
1399 while (upd)
1400 {
1401 vX = upd.GetX();
1402 vY = upd.GetY();
1403 vW = upd.GetW();
1404 vH = upd.GetH();
1405
1406 // Alternatively we can do this:
1407 // wxRect rect;
1408 // upd.GetRect(&rect);
1409
1410 // Repaint this rectangle
1411 ...some code...
1412
1413 upd ++ ;
1414 }
1415}
1416\end{verbatim}
1417}%
1418
1419\wxheading{See also}
1420
1421\helpref{wxPaintEvent}{wxpaintevent},\rtfsp
1422\helpref{wxPaintDC}{wxpaintdc},\rtfsp
1423\helpref{Event handling overview}{eventhandlingoverview}
1424
b82827dd
JS
1425\membersection{wxWindow::OnScroll}\label{wxwindowonscroll}
1426
5f1ea0ee 1427\func{void}{OnScroll}{\param{wxScrollWinEvent\& }{event}}
a660d684 1428
5f1ea0ee 1429Called when a scroll window event is received from one of the window's built-in scrollbars.
a660d684
KB
1430
1431\wxheading{Parameters}
1432
1433\docparam{event}{Command event. Retrieve the new scroll position by
1434calling \helpref{wxScrollEvent::GetPosition}{wxscrolleventgetposition}, and the
1435scrollbar orientation by calling \helpref{wxScrollEvent::GetOrientation}{wxscrolleventgetorientation}.}
1436
1437\wxheading{Remarks}
1438
1439Note that it is not possible to distinguish between horizontal and vertical scrollbars
1440until the function is executing (you can't have one function for vertical, another
1441for horizontal events).
1442
1443\wxheading{See also}
1444
5f1ea0ee 1445\helpref{wxScrollWinEvent}{wxscrollwinevent},\rtfsp
a660d684
KB
1446\helpref{Event handling overview}{eventhandlingoverview}
1447
1448\membersection{wxWindow::OnSetFocus}\label{wxwindowonsetfocus}
1449
1450\func{void}{OnSetFocus}{\param{wxFocusEvent\& }{event}}
1451
1452Called when a window's focus is being set.
1453
1454\wxheading{Parameters}
1455
1456\docparam{event}{The focus event. For more information, see \helpref{wxFocusEvent}{wxfocusevent}.}
1457
1458\wxheading{Remarks}
1459
1460To intercept this event, use the macro EVT\_SET\_FOCUS in an event table definition.
1461
1462Most, but not all, windows respond to this event.
1463
1464\wxheading{See also}
1465
1466\helpref{wxFocusEvent}{wxfocusevent}, \helpref{wxWindow::OnKillFocus}{wxwindowonkillfocus},\rtfsp
1467\helpref{Event handling overview}{eventhandlingoverview}
1468
1469\membersection{wxWindow::OnSize}\label{wxwindowonsize}
1470
1471\func{void}{OnSize}{\param{wxSizeEvent\& }{event}}
1472
1473Called when the window has been resized.
1474
1475\wxheading{Parameters}
1476
1477\docparam{event}{Size event. For more information, see \helpref{wxSizeEvent}{wxsizeevent}.}
1478
1479\wxheading{Remarks}
1480
1481You may wish to use this for frames to resize their child windows as appropriate.
1482
1483Note that the size passed is of
1484the whole window: call \helpref{wxWindow::GetClientSize}{wxwindowgetclientsize} for the area which may be
1485used by the application.
1486
1487\wxheading{See also}
1488
1489\helpref{wxSizeEvent}{wxsizeevent},\rtfsp
1490\helpref{Event handling overview}{eventhandlingoverview}
1491
1492\membersection{wxWindow::OnSysColourChanged}\label{wxwindowonsyscolourchanged}
1493
1494\func{void}{OnSysColourChanged}{\param{wxOnSysColourChangedEvent\& }{event}}
1495
6453876e 1496Called when the user has changed the system colours. Windows only.
a660d684
KB
1497
1498\wxheading{Parameters}
1499
1500\docparam{event}{System colour change event. For more information, see \helpref{wxSysColourChangedEvent}{wxsyscolourchangedevent}.}
1501
1502\wxheading{See also}
1503
1504\helpref{wxSysColourChangedEvent}{wxsyscolourchangedevent},\rtfsp
1505\helpref{Event handling overview}{eventhandlingoverview}
1506
1507\membersection{wxWindow::PopEventHandler}\label{wxwindowpopeventhandler}
1508
1509\constfunc{wxEvtHandler*}{PopEventHandler}{\param{bool }{deleteHandler = FALSE}}
1510
1511Removes and returns the top-most event handler on the event handler stack.
1512
1513\wxheading{Parameters}
1514
1515\docparam{deleteHandler}{If this is TRUE, the handler will be deleted after it is removed. The
1516default value is FALSE.}
1517
1518\wxheading{See also}
1519
1520\helpref{wxWindow::SetEventHandler}{wxwindowseteventhandler},\rtfsp
1521\helpref{wxWindow::GetEventHandler}{wxwindowgeteventhandler},\rtfsp
1522\helpref{wxWindow::PushEventHandler}{wxwindowpusheventhandler},\rtfsp
1523\helpref{wxEvtHandler::ProcessEvent}{wxevthandlerprocessevent},\rtfsp
1524\helpref{wxEvtHandler}{wxevthandler}\rtfsp
1525
1526\membersection{wxWindow::PopupMenu}\label{wxwindowpopupmenu}
1527
a1665b22
VZ
1528\func{bool}{PopupMenu}{\param{wxMenu* }{menu}, \param{const wxPoint& }{pos}}
1529
1530\func{bool}{PopupMenu}{\param{wxMenu* }{menu}, \param{int }{x}, \param{int }{y}}
a660d684
KB
1531
1532Pops up the given menu at the specified coordinates, relative to this
1533window, and returns control when the user has dismissed the menu. If a
a1665b22
VZ
1534menu item is selected, the corresponding menu event is generated and will be
1535processed as usually.
a660d684
KB
1536
1537\wxheading{Parameters}
1538
1539\docparam{menu}{Menu to pop up.}
1540
a1665b22
VZ
1541\docparam{pos}{The position where the menu will appear.}
1542
a660d684
KB
1543\docparam{x}{Required x position for the menu to appear.}
1544
1545\docparam{y}{Required y position for the menu to appear.}
1546
a660d684
KB
1547\wxheading{See also}
1548
631f1bfe
JS
1549\helpref{wxMenu}{wxmenu}
1550
1551\wxheading{Remarks}
1552
1553Just before the menu is popped up, \helpref{wxMenu::UpdateUI}{wxmenuupdateui} is called
2259e007
RR
1554to ensure that the menu items are in the correct state. The menu does not get deleted
1555by the window.
a660d684 1556
dfa13ec8
RD
1557\pythonnote{In place of a single overloaded method name, wxPython
1558implements the following methods:\par
1559\indented{2cm}{\begin{twocollist}
1560\twocolitem{\bf{PopupMenu(menu, point)}}{Specifies position with a wxPoint}
1561\twocolitem{\bf{PopupMenuXY(menu, x, y)}}{Specifies position with two integers (x, y)}
1562\end{twocollist}}
1563}
1564
a660d684
KB
1565\membersection{wxWindow::PushEventHandler}\label{wxwindowpusheventhandler}
1566
1567\func{void}{PushEventHandler}{\param{wxEvtHandler* }{handler}}
1568
1569Pushes this event handler onto the event stack for the window.
1570
1571\wxheading{Parameters}
1572
1573\docparam{handler}{Specifies the handler to be pushed.}
1574
1575\wxheading{Remarks}
1576
1577An event handler is an object that is capable of processing the events
1578sent to a window. By default, the window is its own event handler, but
1579an application may wish to substitute another, for example to allow
1580central implementation of event-handling for a variety of different
1581window classes.
1582
1583\helpref{wxWindow::PushEventHandler}{wxwindowpusheventhandler} allows
1584an application to set up a chain of event handlers, where an event not handled by one event handler is
1585handed to the next one in the chain. Use \helpref{wxWindow::PopEventHandler}{wxwindowpopeventhandler} to
1586remove the event handler.
1587
1588\wxheading{See also}
1589
1590\helpref{wxWindow::SetEventHandler}{wxwindowseteventhandler},\rtfsp
1591\helpref{wxWindow::GetEventHandler}{wxwindowgeteventhandler},\rtfsp
1592\helpref{wxWindow::PopEventHandler}{wxwindowpusheventhandler},\rtfsp
1593\helpref{wxEvtHandler::ProcessEvent}{wxevthandlerprocessevent},\rtfsp
1594\helpref{wxEvtHandler}{wxevthandler}
1595
1596\membersection{wxWindow::Raise}\label{wxwindowraise}
1597
1598\func{void}{Raise}{\void}
1599
1600Raises the window to the top of the window hierarchy if it is a managed window (dialog
1601or frame).
1602
1603\membersection{wxWindow::Refresh}\label{wxwindowrefresh}
1604
1605\func{virtual void}{Refresh}{\param{const bool}{ eraseBackground = TRUE}, \param{const wxRect* }{rect
1606= NULL}}
1607
1608Causes a message or event to be generated to repaint the
1609window.
1610
1611\wxheading{Parameters}
1612
1613\docparam{eraseBackground}{If TRUE, the background will be
1614erased.}
1615
1616\docparam{rect}{If non-NULL, only the given rectangle will
1617be treated as damaged.}
1618
1619\membersection{wxWindow::ReleaseMouse}\label{wxwindowreleasemouse}
1620
1621\func{virtual void}{ReleaseMouse}{\void}
1622
1623Releases mouse input captured with \helpref{wxWindow::CaptureMouse}{wxwindowcapturemouse}.
1624
1625\wxheading{See also}
1626
1627\helpref{wxWindow::CaptureMouse}{wxwindowcapturemouse}
1628
1629\membersection{wxWindow::RemoveChild}\label{wxwindowremovechild}
1630
1631\func{virtual void}{RemoveChild}{\param{wxWindow* }{child}}
1632
1633Removes a child window. This is called automatically by window deletion
1634functions so should not be required by the application programmer.
1635
1636\wxheading{Parameters}
1637
1638\docparam{child}{Child window to remove.}
1639
2259e007
RR
1640\membersection{wxWindow::Reparent}\label{wxwindowreparent}
1641
1642\func{virtual bool}{Reparent}{\param{wxWindow* }{newParent}}
1643
1644Reparents the window, i.e the window will be removed from its
18ac8d69 1645current parent window (e.g. a non-standard toolbar in a wxFrame)
2259e007
RR
1646and then re-inserted into another (e.g. a wxMiniFrame for a
1647floating toolbar). Available on Windows and GTK+.
1648
1649\wxheading{Parameters}
1650
1651\docparam{newParent}{New parent.}
1652
a974387a 1653\membersection{wxWindow::ScreenToClient}\label{wxwindowscreentoclient}
a660d684
KB
1654
1655\constfunc{virtual void}{ScreenToClient}{\param{int* }{x}, \param{int* }{y}}
1656
a974387a
JS
1657\constfunc{virtual wxPoint}{ScreenToClient}{\param{const wxPoint\& }{pt}}
1658
a660d684
KB
1659Converts from screen to client window coordinates.
1660
1661\wxheading{Parameters}
1662
1663\docparam{x}{Stores the screen x coordinate and receives the client x coordinate.}
1664
1665\docparam{y}{Stores the screen x coordinate and receives the client x coordinate.}
1666
a974387a
JS
1667\docparam{pt}{The screen position for the second form of the function.}
1668
06d20283
RD
1669\pythonnote{In place of a single overloaded method name, wxPython
1670implements the following methods:\par
1671\indented{2cm}{\begin{twocollist}
1672\twocolitem{\bf{ScreenToClient(point)}}{Accepts and returns a wxPoint}
1673\twocolitem{\bf{ScreenToClientXY(x, y)}}{Returns a 2-tuple, (x, y)}
1674\end{twocollist}}
1675}
1676
1677
a660d684
KB
1678\membersection{wxWindow::ScrollWindow}\label{wxwindowscrollwindow}
1679
eaaa6a06 1680\func{virtual void}{ScrollWindow}{\param{int }{dx}, \param{int }{dy}, \param{const wxRect*}{ rect = NULL}}
a660d684 1681
6453876e 1682Physically scrolls the pixels in the window and move child windows accordingly.
a660d684
KB
1683
1684\wxheading{Parameters}
1685
1686\docparam{dx}{Amount to scroll horizontally.}
1687
1688\docparam{dy}{Amount to scroll vertically.}
1689
1690\docparam{rect}{Rectangle to invalidate. If this is NULL, the whole window is invalidated. If you
1691pass a rectangle corresponding to the area of the window exposed by the scroll, your painting handler
6453876e
RR
1692can optimise painting by checking for the invalidated region. This paramter is ignored under GTK,
1693instead the regions to be invalidated are calculated automatically. }
a660d684
KB
1694
1695\wxheading{Remarks}
1696
a660d684 1697Use this function to optimise your scrolling implementations, to minimise the area that must be
6453876e 1698redrawn. Note that it is rarely required to call this function from a user program.
a660d684 1699
3972fb49
JS
1700\membersection{wxWindow::SetAcceleratorTable}\label{wxwindowsetacceleratortable}
1701
1702\func{virtual void}{SetAcceleratorTable}{\param{const wxAcceleratorTable\&}{ accel}}
1703
1704Sets the accelerator table for this window. See \helpref{wxAcceleratorTable}{wxacceleratortable}.
1705
a660d684
KB
1706\membersection{wxWindow::SetAutoLayout}\label{wxwindowsetautolayout}
1707
1708\func{void}{SetAutoLayout}{\param{const bool}{ autoLayout}}
1709
1710Determines whether the \helpref{wxWindow::Layout}{wxwindowlayout} function will
515da557 1711be called automatically when the window is resized. Use in connection with
2cdac558 1712\helpref{wxWindow::SetSizer}{wxwindowsetsizer} and
515da557 1713\helpref{wxWindow::SetConstraints}{wxwindowsetconstraints} for layouting subwindows.
a660d684
KB
1714
1715\wxheading{Parameters}
1716
1717\docparam{autoLayout}{Set this to TRUE if you wish the Layout function to be called
1718from within wxWindow::OnSize functions.}
1719
6453876e
RR
1720\wxheading{Remarks}
1721
2cdac558
RD
1722Note that this function is actually disabled for wxWindow. It has
1723effect for wxDialog, wxFrame, wxPanel and wxScrolledWindow as well as indirectly for
8e00741d 1724children of wxNotebook and wxSplitterWindow.
6453876e 1725
a660d684
KB
1726\wxheading{See also}
1727
1728\helpref{wxWindow::SetConstraints}{wxwindowsetconstraints}
1729
1730\membersection{wxWindow::SetBackgroundColour}\label{wxwindowsetbackgroundcolour}
1731
1732\func{virtual void}{SetBackgroundColour}{\param{const wxColour\& }{colour}}
1733
1734Sets the background colour of the window.
1735
1736\wxheading{Parameters}
1737
1738\docparam{colour}{The colour to be used as the background colour.}
1739
1740\wxheading{Remarks}
1741
1742The background colour is usually painted by the default\rtfsp
6453876e
RR
1743\helpref{wxWindow::OnEraseBackground}{wxwindowonerasebackground} event handler function
1744under Windows and automatically under GTK.
a660d684 1745
5b6aa0ff
JS
1746Note that setting the background colour does not cause an immediate refresh, so you
1747may wish to call \helpref{wxWindow::Clear}{wxwindowclear} or \helpref{wxWindow::Refresh}{wxwindowrefresh} after
1748calling this function.
1749
6453876e
RR
1750Note that when using this functions under GTK, you will disable the so called "themes",
1751i.e. the user chosen apperance of windows and controls, including the themes of
1752their parent windows.
1753
a660d684
KB
1754\wxheading{See also}
1755
1756\helpref{wxWindow::GetBackgroundColour}{wxwindowgetbackgroundcolour},\rtfsp
1757\helpref{wxWindow::SetForegroundColour}{wxwindowsetforegroundcolour},\rtfsp
1758\helpref{wxWindow::GetForegroundColour}{wxwindowgetforegroundcolour},\rtfsp
5b6aa0ff
JS
1759\helpref{wxWindow::Clear}{wxwindowclear},\rtfsp
1760\helpref{wxWindow::Refresh}{wxwindowrefresh},\rtfsp
a660d684
KB
1761\helpref{wxWindow::OnEraseBackground}{wxwindowonerasebackground}
1762
dbdb39b2
JS
1763\membersection{wxWindow::SetClientSize}\label{wxwindowsetclientsize}
1764
1765\func{virtual void}{SetClientSize}{\param{int}{ width}, \param{int}{ height}}
1766
1767\func{virtual void}{SetClientSize}{\param{const wxSize\&}{ size}}
1768
1769This sets the size of the window client area in pixels. Using this function to size a window
1770tends to be more device-independent than \helpref{wxWindow::SetSize}{wxwindowsetsize}, since the application need not
1771worry about what dimensions the border or title bar have when trying to fit the window
1772around panel items, for example.
1773
1774\wxheading{Parameters}
1775
1776\docparam{width}{The required client area width.}
1777
1778\docparam{height}{The required client area height.}
1779
1780\docparam{size}{The required client size.}
1781
06d20283
RD
1782\pythonnote{In place of a single overloaded method name, wxPython
1783implements the following methods:\par
1784\indented{2cm}{\begin{twocollist}
1785\twocolitem{\bf{SetClientSize(size)}}{Accepts a wxSize}
1786\twocolitem{\bf{SetClientSizeWH(width, height)}}{}
1787\end{twocollist}}
1788}
1789
dbdb39b2
JS
1790\membersection{wxWindow::SetCursor}\label{wxwindowsetcursor}
1791
1792\func{virtual void}{SetCursor}{\param{const wxCursor\&}{cursor}}
1793
3eddf563
VZ
1794Sets the window's cursor. Notice that setting the cursor for this window does
1795not set it for its children so you'll need to explicitly call SetCursor() for
1796them too if you need it.
dbdb39b2
JS
1797
1798\wxheading{Parameters}
1799
1800\docparam{cursor}{Specifies the cursor that the window should normally display.}
1801
dbdb39b2
JS
1802\wxheading{See also}
1803
1804\helpref{::wxSetCursor}{wxsetcursor}, \helpref{wxCursor}{wxcursor}
1805
1806\membersection{wxWindow::SetEventHandler}\label{wxwindowseteventhandler}
1807
1808\func{void}{SetEventHandler}{\param{wxEvtHandler* }{handler}}
1809
1810Sets the event handler for this window.
1811
1812\wxheading{Parameters}
1813
1814\docparam{handler}{Specifies the handler to be set.}
1815
1816\wxheading{Remarks}
1817
1818An event handler is an object that is capable of processing the events
1819sent to a window. By default, the window is its own event handler, but
1820an application may wish to substitute another, for example to allow
1821central implementation of event-handling for a variety of different
1822window classes.
1823
1824It is usually better to use \helpref{wxWindow::PushEventHandler}{wxwindowpusheventhandler} since
1825this sets up a chain of event handlers, where an event not handled by one event handler is
1826handed to the next one in the chain.
1827
1828\wxheading{See also}
1829
1830\helpref{wxWindow::GetEventHandler}{wxwindowgeteventhandler},\rtfsp
1831\helpref{wxWindow::PushEventHandler}{wxwindowpusheventhandler},\rtfsp
1832\helpref{wxWindow::PopEventHandler}{wxwindowpusheventhandler},\rtfsp
1833\helpref{wxEvtHandler::ProcessEvent}{wxevthandlerprocessevent},\rtfsp
1834\helpref{wxEvtHandler}{wxevthandler}
1835
a660d684
KB
1836\membersection{wxWindow::SetConstraints}\label{wxwindowsetconstraints}
1837
1838\func{void}{SetConstraints}{\param{wxLayoutConstraints* }{constraints}}
1839
1840Sets the window to have the given layout constraints. The window
1841will then own the object, and will take care of its deletion.
1842If an existing layout constraints object is already owned by the
1843window, it will be deleted.
1844
1845\wxheading{Parameters}
1846
1847\docparam{constraints}{The constraints to set. Pass NULL to disassociate and delete the window's
1848constraints.}
1849
1850\wxheading{Remarks}
1851
1852You must call \helpref{wxWindow::SetAutoLayout}{wxwindowsetautolayout} to tell a window to use
2cdac558 1853the constraints automatically in OnSize; otherwise, you must override OnSize and call Layout()
515da557
RR
1854explicitly. When setting both a wxLayoutConstraints and a \helpref{wxSizer}{wxsizer}, only the
1855sizer will have effect.
a660d684 1856
dface61c
JS
1857\membersection{wxWindow::SetDropTarget}\label{wxwindowsetdroptarget}
1858
1859\func{void}{SetDropTarget}{\param{wxDropTarget*}{ target}}
1860
1861Associates a drop target with this window.
1862
1863If the window already has a drop target, it is deleted.
1864
1865\wxheading{See also}
1866
06d20283 1867\helpref{wxWindow::GetDropTarget}{wxwindowgetdroptarget},
dface61c
JS
1868\helpref{Drag and drop overview}{wxdndoverview}
1869
a660d684
KB
1870\membersection{wxWindow::SetFocus}\label{wxwindowsetfocus}
1871
1872\func{virtual void}{SetFocus}{\void}
1873
1874This sets the window to receive keyboard input.
1875
1876\membersection{wxWindow::SetFont}\label{wxwindowsetfont}
1877
1878\func{void}{SetFont}{\param{const wxFont\& }{font}}
1879
1880Sets the font for this window.
1881
1882\wxheading{Parameters}
1883
1884\docparam{font}{Font to associate with this window.}
1885
1886\wxheading{See also}
1887
1888\helpref{wxWindow::GetFont}{wxwindowgetfont}
1889
1890\membersection{wxWindow::SetForegroundColour}\label{wxwindowsetforegroundcolour}
1891
1892\func{virtual void}{SetForegroundColour}{\param{const wxColour\& }{colour}}
1893
1894Sets the foreground colour of the window.
1895
1896\wxheading{Parameters}
1897
1898\docparam{colour}{The colour to be used as the foreground colour.}
1899
1900\wxheading{Remarks}
1901
1902The interpretation of foreground colour is open to interpretation according
1903to the window class; it may be the text colour or other colour, or it may not
1904be used at all.
1905
6453876e
RR
1906Note that when using this functions under GTK, you will disable the so called "themes",
1907i.e. the user chosen apperance of windows and controls, including the themes of
1908their parent windows.
1909
a660d684
KB
1910\wxheading{See also}
1911
1912\helpref{wxWindow::GetForegroundColour}{wxwindowgetforegroundcolour},\rtfsp
1913\helpref{wxWindow::SetBackgroundColour}{wxwindowsetbackgroundcolour},\rtfsp
1914\helpref{wxWindow::GetBackgroundColour}{wxwindowgetbackgroundcolour}
1915
1916\membersection{wxWindow::SetId}\label{wxwindowsetid}
1917
1918\func{void}{SetId}{\param{int}{ id}}
1919
1920Sets the identifier of the window.
1921
1922\wxheading{Remarks}
1923
1924Each window has an integer identifier. If the application has not provided one,
1925an identifier will be generated. Normally, the identifier should be provided
1926on creation and should not be modified subsequently.
1927
a660d684
KB
1928\wxheading{See also}
1929
5b6aa0ff
JS
1930\helpref{wxWindow::GetId}{wxwindowgetid},\rtfsp
1931\helpref{Window identifiers}{windowids}
a660d684
KB
1932
1933\membersection{wxWindow::SetName}\label{wxwindowsetname}
1934
1935\func{virtual void}{SetName}{\param{const wxString\& }{name}}
1936
1937Sets the window's name.
1938
1939\wxheading{Parameters}
1940
1941\docparam{name}{A name to set for the window.}
1942
1943\wxheading{See also}
1944
1945\helpref{wxWindow::GetName}{wxwindowgetname}
1946
dbdb39b2
JS
1947\membersection{wxWindow::SetPalette}\label{wxwindowsetpalette}
1948
1949\func{virtual void}{SetPalette}{\param{wxPalette* }{palette}}
1950
1951Obsolete - use \helpref{wxDC::SetPalette}{wxdcsetpalette} instead.
1952
a660d684
KB
1953\membersection{wxWindow::SetScrollbar}\label{wxwindowsetscrollbar}
1954
eaaa6a06
JS
1955\func{virtual void}{SetScrollbar}{\param{int }{orientation}, \param{int }{position},\rtfsp
1956\param{int }{thumbSize}, \param{int }{range},\rtfsp
a660d684
KB
1957\param{const bool }{refresh = TRUE}}
1958
1959Sets the scrollbar properties of a built-in scrollbar.
1960
1961\wxheading{Parameters}
1962
1963\docparam{orientation}{Determines the scrollbar whose page size is to be set. May be wxHORIZONTAL or wxVERTICAL.}
1964
1965\docparam{position}{The position of the scrollbar in scroll units.}
1966
1967\docparam{thumbSize}{The size of the thumb, or visible portion of the scrollbar, in scroll units.}
1968
1969\docparam{range}{The maximum position of the scrollbar.}
1970
1971\docparam{refresh}{TRUE to redraw the scrollbar, FALSE otherwise.}
1972
1973\wxheading{Remarks}
1974
1975Let's say you wish to display 50 lines of text, using the same font.
1976The window is sized so that you can only see 16 lines at a time.
1977
1978You would use:
1979
1980{\small%
1981\begin{verbatim}
1982 SetScrollbar(wxVERTICAL, 0, 16, 50);
1983\end{verbatim}
1984}
1985
1986Note that with the window at this size, the thumb position can never go
1987above 50 minus 16, or 34.
1988
1989You can determine how many lines are currently visible by dividing the current view
1990size by the character height in pixels.
1991
1992When defining your own scrollbar behaviour, you will always need to recalculate
1993the scrollbar settings when the window size changes. You could therefore put your
1994scrollbar calculations and SetScrollbar
1995call into a function named AdjustScrollbars, which can be called initially and also
1996from your \helpref{wxWindow::OnSize}{wxwindowonsize} event handler function.
1997
1998\wxheading{See also}
1999
2000\helpref{Scrolling overview}{scrollingoverview},\rtfsp
2001\helpref{wxScrollBar}{wxscrollbar}, \helpref{wxScrolledWindow}{wxscrolledwindow}
2002
2003\begin{comment}
2004\membersection{wxWindow::SetScrollPage}\label{wxwindowsetscrollpage}
2005
eaaa6a06 2006\func{virtual void}{SetScrollPage}{\param{int }{orientation}, \param{int }{pageSize}, \param{const bool }{refresh = TRUE}}
a660d684
KB
2007
2008Sets the page size of one of the built-in scrollbars.
2009
2010\wxheading{Parameters}
2011
2012\docparam{orientation}{Determines the scrollbar whose page size is to be set. May be wxHORIZONTAL or wxVERTICAL.}
2013
2014\docparam{pageSize}{Page size in scroll units.}
2015
2016\docparam{refresh}{TRUE to redraw the scrollbar, FALSE otherwise.}
2017
2018\wxheading{Remarks}
2019
2020The page size of a scrollbar is the number of scroll units that the scroll thumb travels when you
2021click on the area above/left of or below/right of the thumb. Normally you will want a whole visible
2022page to be scrolled, i.e. the size of the current view (perhaps the window client size). This
2023value has to be adjusted when the window is resized, since the page size will have changed.
2024
2025In addition to specifying how far the scroll thumb travels when paging, in Motif and some versions of Windows
2026the thumb changes size to reflect the page size relative to the length of the document. When the
2027document size is only slightly bigger than the current view (window) size, almost all of the scrollbar
2028will be taken up by the thumb. When the two values become the same, the scrollbar will (on some systems)
2029disappear.
2030
2031Currently, this function should be called before SetPageRange, because of a quirk in the Windows
2032handling of pages and ranges.
2033
2034\wxheading{See also}
2035
2036\helpref{wxWindow::SetScrollPos}{wxwindowsetscrollpos},\rtfsp
a660d684 2037\helpref{wxWindow::GetScrollPos}{wxwindowsetscrollpos},\rtfsp
f7bd2698 2038\helpref{wxWindow::GetScrollPage}{wxwindowsetscrollpage},\rtfsp
a660d684
KB
2039\helpref{wxScrollBar}{wxscrollbar}, \helpref{wxScrolledWindow}{wxscrolledwindow}
2040\end{comment}
2041
2042\membersection{wxWindow::SetScrollPos}\label{wxwindowsetscrollpos}
2043
eaaa6a06 2044\func{virtual void}{SetScrollPos}{\param{int }{orientation}, \param{int }{pos}, \param{const bool }{refresh = TRUE}}
a660d684
KB
2045
2046Sets the position of one of the built-in scrollbars.
2047
2048\wxheading{Parameters}
2049
2050\docparam{orientation}{Determines the scrollbar whose position is to be set. May be wxHORIZONTAL or wxVERTICAL.}
2051
2052\docparam{pos}{Position in scroll units.}
2053
2054\docparam{refresh}{TRUE to redraw the scrollbar, FALSE otherwise.}
2055
2056\wxheading{Remarks}
2057
2058This function does not directly affect the contents of the window: it is up to the
2059application to take note of scrollbar attributes and redraw contents accordingly.
2060
2061\wxheading{See also}
2062
2063\helpref{wxWindow::SetScrollbar}{wxwindowsetscrollbar},\rtfsp
2064\helpref{wxWindow::GetScrollPos}{wxwindowsetscrollpos},\rtfsp
f7bd2698 2065\helpref{wxWindow::GetScrollThumb}{wxwindowgetscrollthumb},\rtfsp
a660d684
KB
2066\helpref{wxScrollBar}{wxscrollbar}, \helpref{wxScrolledWindow}{wxscrolledwindow}
2067
2068\begin{comment}
2069\membersection{wxWindow::SetScrollRange}\label{wxwindowsetscrollrange}
2070
eaaa6a06 2071\func{virtual void}{SetScrollRange}{\param{int }{orientation}, \param{int }{range}, \param{const bool }{refresh = TRUE}}
a660d684
KB
2072
2073Sets the range of one of the built-in scrollbars.
2074
2075\wxheading{Parameters}
2076
2077\docparam{orientation}{Determines the scrollbar whose range is to be set. May be wxHORIZONTAL or wxVERTICAL.}
2078
2079\docparam{range}{Scroll range.}
2080
2081\docparam{refresh}{TRUE to redraw the scrollbar, FALSE otherwise.}
2082
2083\wxheading{Remarks}
2084
2085The range of a scrollbar is the number of steps that the thumb may travel, rather than the total
fe604ccd
JS
2086object length of the scrollbar. If you are implementing a scrolling window, for example, you
2087would adjust the scroll range when the window is resized, by subtracting the window view size from the
2088total virtual window size. When the two sizes are the same (all the window is visible), the range goes to zero
a660d684
KB
2089and usually the scrollbar will be automatically hidden.
2090
2091\wxheading{See also}
2092
2093\helpref{wxWindow::SetScrollPos}{wxwindowsetscrollpos},\rtfsp
2094\helpref{wxWindow::SetScrollPage}{wxwindowsetscrollpage},\rtfsp
2095\helpref{wxWindow::GetScrollPos}{wxwindowsetscrollpos},\rtfsp
f7bd2698 2096\helpref{wxWindow::GetScrollPage}{wxwindowsetscrollpage},\rtfsp
a660d684
KB
2097\helpref{wxScrollBar}{wxscrollbar}, \helpref{wxScrolledWindow}{wxscrolledwindow}
2098\end{comment}
2099
2100\membersection{wxWindow::SetSize}\label{wxwindowsetsize}
2101
eaaa6a06
JS
2102\func{virtual void}{SetSize}{\param{int}{ x}, \param{int}{ y}, \param{int}{ width}, \param{int}{ height},
2103 \param{int}{ sizeFlags = wxSIZE\_AUTO}}
a660d684 2104
a974387a
JS
2105\func{virtual void}{SetSize}{\param{const wxRect\&}{ rect}}
2106
a660d684
KB
2107Sets the size and position of the window in pixels.
2108
eaaa6a06 2109\func{virtual void}{SetSize}{\param{int}{ width}, \param{int}{ height}}
a660d684 2110
a974387a
JS
2111\func{virtual void}{SetSize}{\param{const wxSize\&}{ size}}
2112
a660d684
KB
2113Sets the size of the window in pixels.
2114
2115\wxheading{Parameters}
2116
2117\docparam{x}{Required x position in pixels, or -1 to indicate that the existing
2118value should be used.}
2119
2120\docparam{y}{Required y position in pixels, or -1 to indicate that the existing
2121value should be used.}
2122
2123\docparam{width}{Required width in pixels, or -1 to indicate that the existing
2124value should be used.}
2125
2126\docparam{height}{Required height position in pixels, or -1 to indicate that the existing
2127value should be used.}
2128
a974387a
JS
2129\docparam{size}{\helpref{wxSize}{wxsize} object for setting the size.}
2130
2131\docparam{rect}{\helpref{wxRect}{wxrect} object for setting the position and size.}
2132
a660d684
KB
2133\docparam{sizeFlags}{Indicates the interpretation of other parameters. It is a bit list of the following:
2134
2135{\bf wxSIZE\_AUTO\_WIDTH}: a -1 width value is taken to indicate
2136a wxWindows-supplied default width.\\
2137{\bf wxSIZE\_AUTO\_HEIGHT}: a -1 height value is taken to indicate
2138a wxWindows-supplied default width.\\
2139{\bf wxSIZE\_AUTO}: -1 size values are taken to indicate
2140a wxWindows-supplied default size.\\
2141{\bf wxSIZE\_USE\_EXISTING}: existing dimensions should be used
2142if -1 values are supplied.\\
2143{\bf wxSIZE\_ALLOW\_MINUS\_ONE}: allow dimensions of -1 and less to be interpreted
2144as real dimensions, not default values.
2145}
2146
2147\wxheading{Remarks}
2148
2149The second form is a convenience for calling the first form with default
2150x and y parameters, and must be used with non-default width and height values.
2151
2152The first form sets the position and optionally size, of the window.
2153Parameters may be -1 to indicate either that a default should be supplied
2154by wxWindows, or that the current value of the dimension should be used.
2155
2156\wxheading{See also}
2157
2158\helpref{wxWindow::Move}{wxwindowmove}
2159
06d20283
RD
2160\pythonnote{In place of a single overloaded method name, wxPython
2161implements the following methods:\par
2162\indented{2cm}{\begin{twocollist}
2163\twocolitem{\bf{SetDimensions(x, y, width, height, sizeFlags=wxSIZE_AUTO)}}{}
2164\twocolitem{\bf{SetSize(size)}}{}
2165\twocolitem{\bf{SetPosition(point)}}{}
2166\end{twocollist}}
2167}
2168
a660d684
KB
2169\membersection{wxWindow::SetSizeHints}\label{wxwindowsetsizehints}
2170
eaaa6a06
JS
2171\func{virtual void}{SetSizeHints}{\param{int}{ minW=-1}, \param{int}{ minH=-1}, \param{int}{ maxW=-1}, \param{int}{ maxH=-1},
2172 \param{int}{ incW=-1}, \param{int}{ incH=-1}}
a660d684
KB
2173
2174Allows specification of minimum and maximum window sizes, and window size increments.
2175If a pair of values is not set (or set to -1), the default values will be used.
2176
2177\wxheading{Parameters}
2178
2179\docparam{minW}{Specifies the minimum width allowable.}
2180
2181\docparam{minH}{Specifies the minimum height allowable.}
2182
2183\docparam{maxW}{Specifies the maximum width allowable.}
2184
2185\docparam{maxH}{Specifies the maximum height allowable.}
2186
2187\docparam{incW}{Specifies the increment for sizing the width (Motif/Xt only).}
2188
2189\docparam{incH}{Specifies the increment for sizing the height (Motif/Xt only).}
2190
2191\wxheading{Remarks}
2192
2193If this function is called, the user will not be able to size the window outside the
2194given bounds.
2195
2196The resizing increments are only significant under Motif or Xt.
2197
515da557
RR
2198\membersection{wxWindow::SetSizer}\label{wxwindowsetsizer}
2199
2200\func{void}{SetSizer}{\param{wxSizer* }{sizer}}
2201
2202Sets the window to have the given layout sizer. The window
2203will then own the object, and will take care of its deletion.
2204If an existing layout constraints object is already owned by the
2205window, it will be deleted.
2206
2207\wxheading{Parameters}
2208
2209\docparam{sizer}{The sizer to set. Pass NULL to disassociate and delete the window's
2210sizer.}
2211
2212\wxheading{Remarks}
2213
2214You must call \helpref{wxWindow::SetAutoLayout}{wxwindowsetautolayout} to tell a window to use
2cdac558
RD
2215the sizer automatically in OnSize; otherwise, you must override OnSize and call Layout()
2216explicitly. When setting both a wxSizer and a \helpref{wxLayoutConstraints}{wxlayoutconstraints},
515da557
RR
2217only the sizer will have effect.
2218
a660d684
KB
2219\membersection{wxWindow::SetTitle}\label{wxwindowsettitle}
2220
2221\func{virtual void}{SetTitle}{\param{const wxString\& }{title}}
2222
2223Sets the window's title. Applicable only to frames and dialogs.
2224
2225\wxheading{Parameters}
2226
2227\docparam{title}{The window's title.}
2228
2229\wxheading{See also}
2230
2231\helpref{wxWindow::GetTitle}{wxwindowgettitle}
2232
aeab10d0
JS
2233\membersection{wxWindow::SetValidator}\label{wxwindowsetvalidator}
2234
2235\func{virtual void}{SetValidator}{\param{const wxValidator\&}{ validator}}
2236
2237Deletes the current validator (if any) and sets the window validator, having called wxValidator::Clone to
2238create a new validator of this type.
2239
2240\membersection{wxWindow::Show}\label{wxwindowshow}
a660d684
KB
2241
2242\func{virtual bool}{Show}{\param{const bool}{ show}}
2243
2244Shows or hides the window.
2245
2246\wxheading{Parameters}
2247
2248\docparam{show}{If TRUE, displays the window and brings it to the front. Otherwise,
2249hides the window.}
2250
2251\wxheading{See also}
2252
2253\helpref{wxWindow::IsShown}{wxwindowisshown}
2254
2255\membersection{wxWindow::TransferDataFromWindow}\label{wxwindowtransferdatafromwindow}
2256
2257\func{virtual bool}{TransferDataFromWindow}{\void}
2258
2259Transfers values from child controls to data areas specified by their validators. Returns
2260FALSE if a transfer failed.
2261
2262\wxheading{See also}
2263
2264\helpref{wxWindow::TransferDataToWindow}{wxwindowtransferdatatowindow},\rtfsp
2265\helpref{wxValidator}{wxvalidator}, \helpref{wxWindow::Validate}{wxwindowvalidate}
2266
2267\membersection{wxWindow::TransferDataToWindow}\label{wxwindowtransferdatatowindow}
2268
2269\func{virtual bool}{TransferDataToWindow}{\void}
2270
2271Transfers values to child controls from data areas specified by their validators.
2272
2273\wxheading{Return value}
2274
2275Returns FALSE if a transfer failed.
2276
2277\wxheading{See also}
2278
2279\helpref{wxWindow::TransferDataFromWindow}{wxwindowtransferdatafromwindow},\rtfsp
2280\helpref{wxValidator}{wxvalidator}, \helpref{wxWindow::Validate}{wxwindowvalidate}
2281
2282\membersection{wxWindow::Validate}\label{wxwindowvalidate}
2283
2284\func{virtual bool}{Validate}{\void}
2285
2286Validates the current values of the child controls using their validators.
2287
2288\wxheading{Return value}
2289
2290Returns FALSE if any of the validations failed.
2291
2292\wxheading{See also}
2293
2294\helpref{wxWindow::TransferDataFromWindow}{wxwindowtransferdatafromwindow},\rtfsp
2295\helpref{wxWindow::TransferDataFromWindow}{wxwindowtransferdatafromwindow},\rtfsp
2296\helpref{wxValidator}{wxvalidator}
2297
2298\membersection{wxWindow::WarpPointer}\label{wxwindowwarppointer}
2299
2300\func{void}{WarpPointer}{\param{int}{ x}, \param{int}{ y}}
2301
2302Moves the pointer to the given position on the window.
2303
2304\wxheading{Parameters}
2305
2306\docparam{x}{The new x position for the cursor.}
2307
2308\docparam{y}{The new y position for the cursor.}
2309