wxWindow is the base class for all windows. Any children of the window will be deleted automatically by the destructor before the window itself is deleted.
Derived from
Include files
<wx/window.h>
Window styles
The following styles can apply to all windows, although they will not always make sense for a particular window class.
| wxSIMPLE_BORDER | Displays a thin border around the window. wxBORDER is the old name for this style. |
| wxDOUBLE_BORDER | Displays a double border. Windows only. |
| wxSUNKEN_BORDER | Displays a sunken border. |
| wxRAISED_BORDER | Displays a raised border. |
| wxSTATIC_BORDER | Displays a border suitable for a static control. |
| wxTRANSPARENT_WINDOW | The window is transparent, that is, it will not receive paint events. Windows only. |
| wxNO_3D | Prevents the children of this window taking on 3D styles, even though the application-wide policy is for 3D controls. Windows only. |
| wxTAB_TRAVERSAL | Use this to enable tab traversal for non-dialog windows. |
| wxVSCROLL | Use this style to enable a vertical scrollbar. |
| wxHSCROLL | Use this style to enable a horizontal scrollbar. |
| wxCLIP_CHILDREN | Use this style to eliminate flicker caused by the background being repainted, then children being painted over them. Windows-only. |
See also window styles overview.
See also
Members
wxWindow::wxWindow
wxWindow::~wxWindow
wxWindow::AddChild
wxWindow::CaptureMouse
wxWindow::Center
wxWindow::Centre
wxWindow::Clear
wxWindow::ClientToScreen
wxWindow::Close
wxWindow::ConvertDialogToPixels
wxWindow::ConvertPixelsToDialog
wxWindow::Destroy
wxWindow::DestroyChildren
wxWindow::DragAcceptFiles
wxWindow::Enable
wxWindow::FindFocus
wxWindow::FindWindow
wxWindow::Fit
wxWindow::GetBackgroundColour
wxWindow::GetCharHeight
wxWindow::GetCharWidth
wxWindow::GetChildren
wxWindow::GetClientSize
wxWindow::GetConstraints
wxWindow::GetDefaultItem
wxWindow::GetDropTarget
wxWindow::GetEventHandler
wxWindow::GetFont
wxWindow::GetForegroundColour
wxWindow::GetGrandParent
wxWindow::GetHandle
wxWindow::GetId
wxWindow::GetPosition
wxWindow::GetLabel
wxWindow::GetName
wxWindow::GetParent
wxWindow::GetRect
wxWindow::GetReturnCode
wxWindow::GetScrollThumb
wxWindow::GetScrollPos
wxWindow::GetScrollRange
wxWindow::GetSize
wxWindow::GetTextExtent
wxWindow::GetTitle
wxWindow::GetUpdateRegion
wxWindow::GetWindowStyleFlag
wxWindow::InitDialog
wxWindow::IsEnabled
wxWindow::IsRetained
wxWindow::IsShown
wxWindow::Layout
wxWindow::LoadFromResource
wxWindow::Lower
wxWindow::MakeModal
wxWindow::Move
wxWindow::OnActivate
wxWindow::OnChar
wxWindow::OnCharHook
wxWindow::OnCommand
wxWindow::OnClose
wxWindow::OnCloseWindow
wxWindow::OnDropFiles
wxWindow::OnEraseBackground
wxWindow::OnKeyDown
wxWindow::OnKeyUp
wxWindow::OnKillFocus
wxWindow::OnIdle
wxWindow::OnInitDialog
wxWindow::OnMenuCommand
wxWindow::OnMenuHighlight
wxWindow::OnMouseEvent
wxWindow::OnMove
wxWindow::OnPaint
wxWindow::OnScroll
wxWindow::OnSetFocus
wxWindow::OnSize
wxWindow::OnSysColourChanged
wxWindow::PopEventHandler
wxWindow::PopupMenu
wxWindow::PushEventHandler
wxWindow::Raise
wxWindow::Refresh
wxWindow::ReleaseMouse
wxWindow::RemoveChild
wxWindow::ScreenToClient
wxWindow::ScrollWindow
wxWindow::SetAcceleratorTable
wxWindow::SetAutoLayout
wxWindow::SetBackgroundColour
wxWindow::SetClientSize
wxWindow::SetCursor
wxWindow::SetEventHandler
wxWindow::SetConstraints
wxWindow::SetDropTarget
wxWindow::SetFocus
wxWindow::SetFont
wxWindow::SetForegroundColour
wxWindow::SetId
wxWindow::SetName
wxWindow::SetPalette
wxWindow::SetReturnCode
wxWindow::SetScrollbar
wxWindow::SetScrollPos
wxWindow::SetSize
wxWindow::SetSizeHints
wxWindow::SetTitle
wxWindow::Show
wxWindow::TransferDataFromWindow
wxWindow::TransferDataToWindow
wxWindow::Validate
wxWindow::WarpPointer
wxWindow()
Default constructor.
wxWindow(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxPanelNameStr)
Constructs a window, which can be a child of a frame, dialog or any other non-control window.
Parameters
parent
id
pos
size
style
name
~wxWindow()
Destructor. Deletes all subwindows, then deletes itself. Instead of using the delete operator explicitly, you should normally use wxWindow::Destroy so that wxWindows can delete a window only when it is safe to do so, in idle time.
See also
Window deletion overview, wxWindow::OnCloseWindow, wxWindow::Destroy, wxCloseEvent
virtual void AddChild(wxWindow* child)
Adds a child window. This is called automatically by window creation functions so should not be required by the application programmer.
Parameters
child
virtual void CaptureMouse()
Directs all mouse input to this window. Call wxWindow::ReleaseMouse to release the capture.
See also
void Center(int direction)
A synonym for Centre.
virtual void Centre(int direction = wxHORIZONTAL)
Centres the window.
Parameters
direction
Remarks
The actual behaviour depends on the derived window. For a frame or dialog box, centring is relative to the whole display. For a panel item, centring is relative to the panel.
See also
void Clear()
Clears the window by filling it with the current background colour. Does not cause an erase background event to be generated.
virtual void ClientToScreen(int* x, int* y) const
virtual wxPoint ClientToScreen(const wxPoint& pt) const
Converts to screen coordinates from coordinates relative to this window.
x
y
pt
wxPython note:
In place of a single overloaded method name, wxPython
implements the following methods:
| ClientToScreen(point) | Accepts and returns a wxPoint |
| ClientToScreenXY(x, y) | Returns a 2-tuple, (x, y) |
virtual bool Close(const bool force = FALSE)
The purpose of this call is to provide a safer way of destroying a window than using the delete operator.
Parameters
force
Remarks
Close calls the close handler for the window, providing an opportunity for the window to choose whether to destroy the window.
The close handler should check whether the window is being deleted forcibly, using wxCloseEvent::GetForce, in which case it should destroy the window using wxWindow::Destroy.
Applies to managed windows (wxFrame and wxDialog classes) only.
Note that calling Close does not guarantee that the window will be destroyed; but it provides a way to simulate a manual close of a window, which may or may not be implemented by destroying the window. The default implementation of wxDialog::OnCloseWindow does not necessarily delete the dialog, since it will simply simulate an wxID_CANCEL event which itself only hides the dialog.
To guarantee that the window will be destroyed, call wxWindow::Destroy instead.
See also
Window deletion overview, wxWindow::OnCloseWindow, wxWindow::Destroy, wxCloseEvent
wxPoint ConvertDialogToPixels(const wxPoint& pt)
wxSize ConvertDialogToPixels(const wxSize& sz)
Converts a point or size from dialog units to pixels.
For the x dimension, the dialog units are multiplied by the average character width and then divided by 4.
For the y dimension, the dialog units are multiplied by the average character height and then divided by 8.
Remarks
Dialog units are used for maintaining a dialog's proportions even if the font changes. Dialogs created using Dialog Editor optionally use dialog units.
You can also use these functions programmatically. A convenience macro is defined:
#define wxDLG_UNIT(parent, pt) parent->ConvertDialogToPixels(pt)
See also
wxWindow::ConvertPixelsToDialog
wxPython note:
In place of a single overloaded method name, wxPython
implements the following methods:
| ConvertDialogPointToPixels(point) | Accepts and returns a wxPoint |
| ConvertDialogSizeToPixels(size) | Accepts and returns a wxSize |
Additionally, the following helper functions are defined:
| wxDLG_PNT(win, point) | Converts a wxPoint from dialog units to pixels |
| wxDLG_SZE(win, size) | Converts a wxSize from dialog units to pixels |
wxPoint ConvertPixelsToDialog(const wxPoint& pt)
wxSize ConvertPixelsToDialog(const wxSize& sz)
Converts a point or size from pixels to dialog units.
For the x dimension, the pixels are multiplied by 4 and then divided by the average character width.
For the y dimension, the pixels are multipled by 8 and then divided by the average character height.
Remarks
Dialog units are used for maintaining a dialog's proportions even if the font changes. Dialogs created using Dialog Editor optionally use dialog units.
See also
wxWindow::ConvertDialogToPixels
wxPython note:
In place of a single overloaded method name, wxPython
implements the following methods:
| ConvertDialogPointToPixels(point) | Accepts and returns a wxPoint |
| ConvertDialogSizeToPixels(size) | Accepts and returns a wxSize |
virtual bool Destroy()
Destroys the window safely. Use this function instead of the delete operator, since different window classes can be destroyed differently. Frames and dialogs are not destroyed immediately when this function is called - they are added to a list of windows to be deleted on idle time, when all the window's events have been processed. This prevents problems with events being sent to non-existant windows.
Return value
TRUE if the window has either been successfully deleted, or it has been added to the list of windows pending real deletion.
virtual void DestroyChildren()
Destroys all children of a window. Called automatically by the destructor.
virtual void DragAcceptFiles(const bool accept)
Enables or disables elibility for drop file events (OnDropFiles).
Parameters
accept
Remarks
Windows only.
See also
virtual void Enable(const bool enable)
Enable or disable the window for user input.
Parameters
enable
See also
static wxWindow* FindFocus()
Finds the window or control which currently has the keyboard focus.
Remarks
Note that this is a static function, so it can be called without needing a wxWindow pointer.
See also
wxWindow* FindWindow(long id)
Find a child of this window, by identifier.
wxWindow* FindWindow(const wxString& name)
Find a child of this window, by name.
wxPython note:
In place of a single overloaded method name, wxPython
implements the following methods:
| FindWindowById(id) | Accepts an integer |
| FindWindowByName(name) | Accepts a string |
virtual void Fit()
Sizes the window so that it fits around its subwindows.
virtual wxColour GetBackgroundColour() const
Returns the background colour of the window.
See also
wxWindow::SetBackgroundColour, wxWindow::SetForegroundColour, wxWindow::GetForegroundColour, wxWindow::OnEraseBackground
virtual int GetCharHeight() const
Returns the character height for this window.
virtual int GetCharWidth() const
Returns the average character width for this window.
wxList& GetChildren()
Returns a reference to the list of the window's children.
virtual void GetClientSize(int* width, int* height) const
virtual wxSize GetClientSize() const
This gets the size of the window 'client area' in pixels. The client area is the area which may be drawn on by the programmer, excluding title bar, border etc.
Parameters
width
height
wxPython note:
In place of a single overloaded method name, wxPython
implements the following methods:
| wxGetClientSizeTuple() | Returns a 2-tuple of (width, height) |
| wxGetClientSize() | Returns a wxSize object |
wxLayoutConstraints* GetConstraints() const
Returns a pointer to the window's layout constraints, or NULL if there are none.
wxButton* GetDefaultItem() const
Returns a pointer to the button which is the default for this window, or NULL.
wxDropTarget* GetDropTarget() const
Returns the associated drop target, which may be NULL.
See also
wxWindow::SetDropTarget, Drag and drop overview
wxEvtHandler* GetEventHandler() const
Returns the event handler for this window. By default, the window is its own event handler.
See also
wxWindow::SetEventHandler, wxWindow::PushEventHandler, wxWindow::PopEventHandler, wxEvtHandler::ProcessEvent, wxEvtHandler
wxFont& GetFont() const
Returns a reference to the font for this window.
See also
virtual wxColour GetForegroundColour()
Returns the foreground colour of the window.
Remarks
The interpretation of foreground colour is open to interpretation according to the window class; it may be the text colour or other colour, or it may not be used at all.
See also
wxWindow::SetForegroundColour, wxWindow::SetBackgroundColour, wxWindow::GetBackgroundColour
wxWindow* GetGrandParent() const
Returns the grandparent of a window, or NULL if there isn't one.
void* GetHandle() const
Returns the platform-specific handle of the physical window. Cast it to an appropriate handle, such as HWND for Windows or Widget for Motif.
int GetId() const
Returns the identifier of the window.
Remarks
Each window has an integer identifier. If the application has not provided one, an identifier will be generated.
See also
wxWindow::SetId Window identifiers
virtual void GetPosition(int* x, int* y) const
This gets the position of the window in pixels, relative to the parent window or if no parent, relative to the whole display.
Parameters
x
y
wxPython note:
In place of a single overloaded method name, wxPython
implements the following methods:
| GetPosition() | Returns a wxPoint |
| GetPositionTuple() | Returns a tuple (x, y) |
virtual wxString& GetLabel() const
Generic way of getting a label from any window, for identification purposes.
Remarks
The interpretation of this function differs from class to class. For frames and dialogs, the value returned is the title. For buttons or static text controls, it is the button text. This function can be useful for meta-programs (such as testing tools or special-needs access programs) which need to identify windows by name.
virtual wxString& GetName() const
Returns the window's name.
Remarks
This name is not guaranteed to be unique; it is up to the programmer to supply an appropriate name in the window constructor or via wxWindow::SetName.
See also
virtual wxWindow* GetParent() const
Returns the parent of the window, or NULL if there is no parent.
virtual wxRect GetRect() const
Returns the size and position of the window as a wxRect object.
int GetReturnCode()
Gets the return code for this window.
Remarks
A return code is normally associated with a modal dialog, where wxDialog::ShowModal returns a code to the application.
See also
wxWindow::SetReturnCode, wxDialog::ShowModal, wxDialog::EndModal
virtual int GetScrollThumb(int orientation)
Returns the built-in scrollbar thumb size.
See also
virtual int GetScrollPos(int orientation)
Returns the built-in scrollbar position.
See also
virtual int GetScrollRange(int orientation)
Returns the built-in scrollbar range.
See also
virtual void GetSize(int* width, int* height) const
virtual wxSize GetSize() const
This gets the size of the entire window in pixels.
Parameters
width
height
wxPython note:
In place of a single overloaded method name, wxPython
implements the following methods:
| GetSize() | Returns a wxSize |
| GetSizeTuple() | Returns a 2-tuple (width, height) |
virtual void GetTextExtent(const wxString& string, int* x, int* y, int* descent = NULL, int* externalLeading = NULL, const wxFont* font = NULL, const bool use16 = FALSE) const
Gets the dimensions of the string as it would be drawn on the window with the currently selected font.
Parameters
string
x
y
descent
externalLeading
font
use16
wxPython note:
In place of a single overloaded method name, wxPython
implements the following methods:
| GetTextExtent(string) | Returns a 2-tuple, (width, height) |
| GetFullTextExtent(string, font=NULL) | Returns a 4-tuple, (width, height, descent, externalLeading) |
virtual wxString GetTitle()
Gets the window's title. Applicable only to frames and dialogs.
See also
virtual wxRegion GetUpdateRegion() const
Returns the region specifying which parts of the window have been damaged. Should only be called within an OnPaint event handler.
See also
wxRegion, wxRegionIterator, wxWindow::OnPaint
long GetWindowStyleFlag() const
Gets the window style that was passed to the consructor or Create member.
void InitDialog()
Sends an wxWindow::OnInitDialog event, which in turn transfers data to the dialog via validators.
See also
virtual bool IsEnabled() const
Returns TRUE if the window is enabled for input, FALSE otherwise.
See also
virtual bool IsRetained() const
Returns TRUE if the window is retained, FALSE otherwise.
Remarks
Retained windows are only available on X platforms.
virtual bool IsShown() const
Returns TRUE if the window is shown, FALSE if it has been hidden.
void Layout()
Invokes the constraint-based layout algorithm for this window. It is called automatically by the default wxWindow::OnSize member.
virtual bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL)
Loads a panel or dialog from a resource file.
Parameters
parent
resourceName
resourceTable
Return value
TRUE if the operation succeeded, otherwise FALSE.
void Lower()
Lowers the window to the bottom of the window hierarchy if it is a managed window (dialog or frame).
virtual void MakeModal(const bool flag)
Disables all other windows in the application so that the user can only interact with this window.
Parameters
flag
void Move(int x, int y)
void Move(const wxPoint& pt)
Moves the window to the given position.
Parameters
x
y
pt
Remarks
Implementations of SetSize can also implicitly implement the wxWindow::Move function, which is defined in the base wxWindow class as the call:
SetSize(x, y, -1, -1, wxSIZE_USE_EXISTING);See also
wxPython note:
In place of a single overloaded method name, wxPython
implements the following methods:
| Move(point) | Accepts a wxPoint |
| MoveXY(x, y) | Accepts a pair of integers |
void OnActivate(wxActivateEvent& event)
Called when a window is activated or deactivated.
Parameters
event
Remarks
If the window is being activated, wxActivateEvent::GetActive returns TRUE, otherwise it returns FALSE (it is being deactivated).
See also
wxActivateEvent, Event handling overview
void OnChar(wxKeyEvent& event)
Called when the user has pressed a key that is not a modifier (SHIFT, CONTROL or ALT).
Parameters
event
Remarks
This member function is called in response to a keypress. To intercept this event, use the EVT_CHAR macro in an event table definition. Your OnChar handler may call this default function to achieve default keypress functionality.
Note that the ASCII values do not have explicit key codes: they are passed as ASCII values.
Note that not all keypresses can be intercepted this way. If you wish to intercept modifier keypresses, then you will need to use wxWindow::OnKeyDown or wxWindow::OnKeyUp.
Most, but not all, windows allow keypresses to be intercepted.
See also
wxWindow::OnKeyDown, wxWindow::OnKeyUp, wxKeyEvent, wxWindow::OnCharHook, Event handling overview
void OnCharHook(wxKeyEvent& event)
This member is called to allow the window to intercept keyboard events before they are processed by child windows.
Parameters
event
Remarks
This member function is called in response to a keypress, if the window is active. To intercept this event, use the EVT_CHAR_HOOK macro in an event table definition. If you do not process a particular keypress, call wxEvent::Skip to allow default processing.
An example of using this function is in the implementation of escape-character processing for wxDialog, where pressing ESC dismisses the dialog by OnCharHook 'forging' a cancel button press event.
Note that the ASCII values do not have explicit key codes: they are passed as ASCII values.
This function is only relevant to top-level windows (frames and dialogs), and under Windows only.
See also
wxKeyEvent, wxWindow::OnCharHook, wxApp::OnCharHook, Event handling overview
virtual void OnCommand(wxEvtHandler& object, wxCommandEvent& event)
This virtual member function is called if the control does not handle the command event.
Parameters
object
event
Remarks
This virtual function is provided mainly for backward compatibility. You can also intercept commands from child controls by using an event table, with identifiers or identifier ranges to identify the control(s) in question.
See also
wxCommandEvent, Event handling overview
virtual bool OnClose()
Called when the user has tried to close a a frame or dialog box using the window manager (X) or system menu (Windows).
Note: This is an obsolete function. It is superceded by the wxWindow::OnCloseWindow event handler.
Return value
If TRUE is returned by OnClose, the window will be deleted by the system, otherwise the attempt will be ignored. Do not delete the window from within this handler, although you may delete other windows.
See also
Window deletion overview, wxWindow::Close, wxWindow::OnCloseWindow, wxCloseEvent
void OnCloseWindow(wxCloseEvent& event)
This is an event handler function called when the user has tried to close a a frame or dialog box using the window manager (X) or system menu (Windows). It is called via the wxWindow::Close function, so that the application can also invoke the handler programmatically.
Use the EVT_CLOSE event table macro to handle close events.
You should check whether the application is forcing the deletion of the window using wxCloseEvent::GetForce. If this is TRUE, destroy the window using wxWindow::Destroy. If fy windows by name.
virtual wxString& GetName() const
Returns the window's name.
Remarks
This name is not guaranteed to be unique; it is up to the programmer to supply an appropriate name in the window constructor or via wxWindow::SetName.
See also
virtual wxWindow* GetParent() const
Returns the parent of the window, or NULL if there is no parent.
virtual wxRect GetRect() const
Returns the size and position of the window as a wxRect object.
int GetReturnCode()
Gets the return code for this window.
Remarks
A return code is normally associated with a modal dialog, where wxDialog::ShowModal returns a code to the application.
See also
wxWindow::SetReturnCode, wxDialog::ShowModal, wxDialog::EndModal
virtual int GetScrollThumb(int orientation)
Returns the built-in scrollbar thumb size.
See also
virtual int GetScrollPos(int orientation)
Returns the built-in scrollbar position.
See also
virtual int GetScrollRange(int orientation)
Returns the built-in scrollbar range.
See also
virtual void GetSize(int* width, int* height) const
virtual wxSize GetSize() const
This gets the size of the entire window in pixels.
Parameters
width
height
wxPython note:
In place of a single overloaded method name, wxPython
implements the following methods:
| GetSize() | Returns a wxSize |
| GetSizeTuple() | Returns a 2-tuple (width, height) |
virtual void GetTextExtent(const wxString& string, int* x, int* y, int* descent = NULL, int* externalLeading = NULL, const wxFont* font = NULL, const bool use16 = FALSE) const
Gets the dimensions of the string as it would be drawn on the window with the currently selected font.
Parameters
string
x
y
descent
externalLeading
font
use16
wxPython note:
In place of a single overloaded method name, wxPython
implements the following methods:
| GetTextExtent(string) | Returns a 2-tuple, (width, height) |
| GetFullTextExtent(string, font=NULL) | Returns a 4-tuple, (width, height, descent, externalLeading) |
virtual wxString GetTitle()
Gets the window's title. Applicable only to frames and dialogs.
See also
virtual wxRegion GetUpdateRegion() const
Returns the region specifying which parts of the window have been damaged. Should only be called within an OnPaint event handler.
See also
wxRegion, wxRegionIterator, wxWindow::OnPaint
long GetWindowStyleFlag() const
Gets the window style that was passed to the consructor or Create member.
void InitDialog()
Sends an wxWindow::OnInitDialog event, which in turn transfers data to the dialog via validators.
See also
virtual bool IsEnabled() const
Returns TRUE if the window is enabled for input, FALSE otherwise.
See also
virtual bool IsRetained() const
Returns TRUE if the window is retained, FALSE otherwise.
Remarks
Retained windows are only available on X platforms.
virtual bool IsShown() const
Returns TRUE if the window is shown, FALSE if it has been hidden.
void Layout()
Invokes the constraint-based layout algorithm for this window. It is called automatically by the default wxWindow::OnSize member.
virtual bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL)
Loads a panel or dialog from a resource file.
Parameters
parent
resourceName
resourceTable
Return value
TRUE if the operation succeeded, otherwise FALSE.
void Lower()
Lowers the window to the bottom of the window hierarchy if it is a managed window (dialog or frame).
virtual void MakeModal(const bool flag)
Disables all other windows in the application so that the user can only interact with this window.
Parameters
flag
void Move(int x, int y)
void Move(const wxPoint& pt)
Moves the window to the given position.
Parameters
x
y
pt
Remarks
Implementations of SetSize can also implicitly implement the wxWindow::Move function, which is defined in the base wxWindow class as the call:
SetSize(x, y, -1, -1, wxSIZE_USE_EXISTING);See also
wxPython note:
In place of a single overloaded method name, wxPython
implements the following methods:
| Move(point) | Accepts a wxPoint |
| MoveXY(x, y) | Accepts a pair of integers |
void OnActivate(wxActivateEvent& event)
Called when a window is activated or deactivated.
Parameters
event
Remarks
If the window is being activated, wxActivateEvent::GetActive returns TRUE, otherwise it returns FALSE (it is being deactivated).
See also
wxActivateEvent, Event handling overview
void OnChar(wxKeyEvent& event)
Called when the user has pressed a key that is not a modifier (SHIFT, CONTROL or ALT).
Parameters
event
Remarks
This member function is called in response to a keypress. To intercept this event, use the EVT_CHAR macro in an event table definition. Your OnChar handler may call this default function to achieve default keypress functionality.
Note that the ASCII values do not have explicit key codes: they are passed as ASCII values.
Note that not all keypresses can be intercepted this way. If you wish to intercept modifier keypresses, then you will need to use wxWindow::OnKeyDown or wxWindow::OnKeyUp.
Most, but not all, windows allow keypresses to be intercepted.
See also
wxWindow::OnKeyDown, wxWindow::OnKeyUp, wxKeyEvent, wxWindow::OnCharHook, Event handling overview
void OnCharHook(wxKeyEvent& event)
This member is called to allow the window to intercept keyboard events before they are processed by child windows.
Parameters
event
Remarks
This member function is called in response to a keypress, if the window is active. To intercept this event, use the EVT_CHAR_HOOK macro in an event table definition. If you do not process a particular keypress, call wxEvent::Skip to allow default processing.
An example of using this function is in the implementation of escape-character processing for wxDialog, where pressing ESC dismisses the dialog by OnCharHook 'forging' a cancel button press event.
Note that the ASCII values do not have explicit key codes: they are passed as ASCII values.
This function is only relevant to top-level windows (frames and dialogs), and under Windows only.
See also
wxKeyEvent, wxWindow::OnCharHook, wxApp::OnCharHook, Event handling overview
virtual void OnCommand(wxEvtHandler& object, wxCommandEvent& event)
This virtual member function is called if the control does not handle the command event.
Parameters
object
event
Remarks
This virtual function is provided mainly for backward compatibility. You can also intercept commands from child controls by using an event table, with identifiers or identifier ranges to identify the control(s) in question.
See also
wxCommandEvent, Event handling overview
virtual bool OnClose()
Called when the user has tried to close a a frame or dialog box using the window manager (X) or system menu (Windows).
Note: This is an obsolete function. It is superceded by the wxWindow::OnCloseWindow event handler.
Return value
If TRUE is returned by OnClose, the window will be deleted by the system, otherwise the attempt will be ignored. Do not delete the window from within this handler, although you may delete other windows.
See also
Window deletion overview, wxWindow::Close, wxWindow::OnCloseWindow, wxCloseEvent
void OnCloseWindow(wxCloseEvent& event)
This is an event handler function called when the user has tried to close a a frame or dialog box using the window manager (X) or system menu (Windows). It is called via the wxWindow::Close function, so that the application can also invoke the handler programmatically.
Use the EVT_CLOSE event table macro to handle close events.
You should check whether the application is forcing the deletion of the window using wxCloseEvent::GetForce. If this is TRUE, destroy the window using wxWindow::Destroy. If fy windows by name.
virtual wxString& GetName() const
Returns the window's name.
Remarks
This name is not guaranteed to be unique; it is up to the programmer to supply an appropriate name in the window constructor or via wxWindow::SetName.
See also
virtual wxWindow* GetParent() const
Returns the parent of the window, or NULL if there is no parent.
virtual wxRect GetRect() const
Returns the size and position of the window as a wxRect object.
int GetReturnCode()
Gets the return code for this window.
Remarks
A return code is normally associated with a modal dialog, where wxDialog::ShowModal returns a code to the application.
See also
wxWindow::SetReturnCode, wxDialog::ShowModal, wxDialog::EndModal
virtual int GetScrollThumb(int orientation)
Returns the built-in scrollbar thumb size.
See also
virtual int GetScrollPos(int orientation)
Returns the built-in scrollbar position.
See also
virtual int GetScrollRange(int orientation)
Returns the built-in scrollbar range.
See also
virtual void GetSize(int* width, int* height) const
virtual wxSize GetSize() const
This gets the size of the entire window in pixels.
Parameters
width
height
wxPython note:
In place of a single overloaded method name, wxPython
implements the following methods:
| GetSize() | Returns a wxSize |
| GetSizeTuple() | Returns a 2-tuple (width, height) |
virtual void GetTextExtent(const wxString& string, int* x, int* y, int* descent = NULL, int* externalLeading = NULL, const wxFont* font = NULL, const bool use16 = FALSE) const
Gets the dimensions of the string as it would be drawn on the window with the currently selected font.
Parameters
string
x
y
descent
externalLeading
font
use16
wxPython note:
In place of a single overloaded method name, wxPython
implements the following methods:
| GetTextExtent(string) | Returns a 2-tuple, (width, height) |
| GetFullTextExtent(string, font=NULL) | Returns a 4-tuple, (width, height, descent, externalLeading) |
virtual wxString GetTitle()
Gets the window's title. Applicable only to frames and dialogs.
See also
virtual wxRegion GetUpdateRegion() const
Returns the region specifying which parts of the window have been damaged. Should only be called within an OnPaint event handler.
See also
wxRegion, wxRegionIterator, wxWindow::OnPaint
long GetWindowStyleFlag() const
Gets the window style that was passed to the consructor or Create member.
void InitDialog()
Sends an wxWindow::OnInitDialog event, which in turn transfers data to the dialog via validators.
See also
virtual bool IsEnabled() const
Returns TRUE if the window is enabled for input, FALSE otherwise.
See also
virtual bool IsRetained() const
Returns TRUE if the window is retained, FALSE otherwise.
Remarks
Retained windows are only available on X platforms.
virtual bool IsShown() const
Returns TRUE if the window is shown, FALSE if it has been hidden.
void Layout()
Invokes the constraint-based layout algorithm for this window. It is called automatically by the default wxWindow::OnSize member.
virtual bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL)
Loads a panel or dialog from a resource file.
Parameters
parent
resourceName
resourceTable
Return value
TRUE if the operation succeeded, otherwise FALSE.
void Lower()
Lowers the window to the bottom of the window hierarchy if it is a managed window (dialog or frame).
virtual void MakeModal(const bool flag)
Disables all other windows in the application so that the user can only interact with this window.
Parameters
flag
void Move(int x, int y)
void Move(const wxPoint& pt)
Moves the window to the given position.
Parameters
x
y
pt
Remarks
Implementations of SetSize can also implicitly implement the wxWindow::Move function, which is defined in the base wxWindow class as the call:
SetSize(x, y, -1, -1, wxSIZE_USE_EXISTING);See also
wxPython note:
In place of a single overloaded method name, wxPython
implements the following methods:
| Move(point) | Accepts a wxPoint |
| MoveXY(x, y) | Accepts a pair of integers |
void OnActivate(wxActivateEvent& event)
Called when a window is activated or deactivated.
Parameters
event
Remarks
If the window is being activated, wxActivateEvent::GetActive returns TRUE, otherwise it returns FALSE (it is being deactivated).
See also
wxActivateEvent, Event handling overview
void OnChar(wxKeyEvent& event)
Called when the user has pressed a key that is not a modifier (SHIFT, CONTROL or ALT).
Parameters
event
Remarks
This member function is called in response to a keypress. To intercept this event, use the EVT_CHAR macro in an event table definition. Your OnChar handler may call this default function to achieve default keypress functionality.
Note that the ASCII values do not have explicit key codes: they are passed as ASCII values.
Note that not all keypresses can be intercepted this way. If you wish to intercept modifier keypresses, then you will need to use wxWindow::OnKeyDown or wxWindow::OnKeyUp.
Most, but not all, windows allow keypresses to be intercepted.
See also
wxWindow::OnKeyDown, wxWindow::OnKeyUp, wxKeyEvent, wxWindow::OnCharHook, Event handling overview
void OnCharHook(wxKeyEvent& event)
This member is called to allow the window to intercept keyboard events before they are processed by child windows.
Parameters
event
Remarks
This member function is called in response to a keypress, if the window is active. To intercept this event, use the EVT_CHAR_HOOK macro in an event table definition. If you do not process a particular keypress, call wxEvent::Skip to allow default processing.
An example of using this function is in the implementation of escape-character processing for wxDialog, where pressing ESC dismisses the dialog by OnCharHook 'forging' a cancel button press event.
Note that the ASCII values do not have explicit key codes: they are passed as ASCII values.
This function is only relevant to top-level windows (frames and dialogs), and under Windows only.
See also
wxKeyEvent, wxWindow::OnCharHook, wxApp::OnCharHook, Event handling overview
virtual void OnCommand(wxEvtHandler& object, wxCommandEvent& event)
This virtual member function is called if the control does not handle the command event.
Parameters
object
event
Remarks
This virtual function is provided mainly for backward compatibility. You can also intercept commands from child controls by using an event table, with identifiers or identifier ranges to identify the control(s) in question.
See also
wxCommandEvent, Event handling overview
virtual bool OnClose()
Called when the user has tried to close a a frame or dialog box using the window manager (X) or system menu (Windows).
Note: This is an obsolete function. It is superceded by the wxWindow::OnCloseWindow event handler.
Return value
If TRUE is returned by OnClose, the window will be deleted by the system, otherwise the attempt will be ignored. Do not delete the window from within this handler, although you may delete other windows.
See also
Window deletion overview, wxWindow::Close, wxWindow::OnCloseWindow, wxCloseEvent
void OnCloseWindow(wxCloseEvent& event)
This is an event handler function called when the user has tried to close a a frame or dialog box using the window manager (X) or system menu (Windows). It is called via the wxWindow::Close function, so that the application can also invoke the handler programmatically.
Use the EVT_CLOSE event table macro to handle close events.
You should check whether the application is forcing the deletion of the window using wxCloseEvent::GetForce. If this is TRUE, destroy the window using wxWindow::Destroy. If fy windows by name.
virtual wxString& GetName() const
Returns the window's name.
Remarks
This name is not guaranteed to be unique; it is up to the programmer to supply an appropriate name in the window constructor or via wxWindow::SetName.
See also
virtual wxWindow* GetParent() const
Returns the parent of the window, or NULL if there is no parent.
virtual wxRect GetRect() const
Returns the size and position of the window as a wxRect object.
int GetReturnCode()
Gets the return code for this window.
Remarks
A return code is normally associated with a modal dialog, where wxDialog::ShowModal returns a code to the application.
See also
wxWindow::SetReturnCode, wxDialog::ShowModal, wxDialog::EndModal
virtual int GetScrollThumb(int orientation)
Returns the built-in scrollbar thumb size.
See also
virtual int GetScrollPos(int orientation)
Returns the built-in scrollbar position.
See also
virtual int GetScrollRange(int orientation)
Returns the built-in scrollbar range.
See also
virtual void GetSize(int* width, int* height) const
virtual wxSize GetSize() const
This gets the size of the entire window in pixels.
Parameters
width
height
wxPython note:
In place of a single overloaded method name, wxPython
implements the following methods:
| GetSize() | Returns a wxSize |
| GetSizeTuple() | Returns a 2-tuple (width, height) |
virtual void GetTextExtent(const wxString& string, int* x, int* y, int* descent = NULL, int* externalLeading = NULL, const wxFont* font = NULL, const bool use16 = FALSE) const
Gets the dimensions of the string as it would be drawn on the window with the currently selected font.
Parameters
string
x
y
descent
externalLeading
font
use16
wxPython note:
In place of a single overloaded method name, wxPython
implements the following methods:
| GetTextExtent(string) | Returns a 2-tuple, (width, height) |
| GetFullTextExtent(string, font=NULL) | Returns a 4-tuple, (width, height, descent, externalLeading) |
virtual wxString GetTitle()
Gets the window's title. Applicable only to frames and dialogs.
See also
virtual wxRegion GetUpdateRegion() const
Returns the region specifying which parts of the window have been damaged. Should only be called within an OnPaint event handler.
See also
wxRegion, wxRegionIterator, wxWindow::OnPaint
long GetWindowStyleFlag() const
Gets the window style that was passed to the consructor or Create member.
void InitDialog()
Sends an wxWindow::OnInitDialog event, which in turn transfers data to the dialog via validators.
See also
virtual bool IsEnabled() const
Returns TRUE if the window is enabled for input, FALSE otherwise.
See also
virtual bool IsRetained() const
Returns TRUE if the window is retained, FALSE otherwise.
Remarks
Retained windows are only available on X platforms.
virtual bool IsShown() const
Returns TRUE if the window is shown, FALSE if it has been hidden.
void Layout()
Invokes the constraint-based layout algorithm for this window. It is called automatically by the default wxWindow::OnSize member.
virtual bool LoadFromResource(wxWindow* parent, const wxString& resourceName, const wxResourceTable* resourceTable = NULL)
Loads a panel or dialog from a resource file.
Parameters
parent
resourceName
resourceTable
Return value
TRUE if the operation succeeded, otherwise FALSE.
void Lower()
Lowers the window to the bottom of the window hierarchy if it is a managed window (dialog or frame).
virtual void MakeModal(const bool flag)
Disables all other windows in the application so that the user can only interact with this window.
Parameters
flag
void Move(int x, int y)
void Move(const wxPoint& pt)
Moves the window to the given position.
Parameters
x
y
pt
Remarks
Implementations of SetSize can also implicitly implement the wxWindow::Move function, which is defined in the base wxWindow class as the call:
SetSize(x, y, -1, -1, wxSIZE_USE_EXISTING);See also
wxPython note:
In place of a single overloaded method name, wxPython
implements the following methods:
| Move(point) | Accepts a wxPoint |
| MoveXY(x, y) | Accepts a pair of integers |
void OnActivate(wxActivateEvent& event)
Called when a window is activated or deactivated.
Parameters
event
Remarks
If the window is being activated, wxActivateEvent::GetActive returns TRUE, otherwise it returns FALSE (it is being deactivated).
See also
wxActivateEvent, Event handling overview
void OnChar(wxKeyEvent& event)
Called when the user has pressed a key that is not a modifier (SHIFT, CONTROL or ALT).
Parameters
event
Remarks
This member function is called in response to a keypress. To intercept this event, use the EVT_CHAR macro in an event table definition. Your OnChar handler may call this default function to achieve default keypress functionality.
Note that the ASCII values do not have explicit key codes: they are passed as ASCII values.
Note that not all keypresses can be intercepted this way. If you wish to intercept modifier keypresses, then you will need to use