Contents Up Previous Next

wxWindow: wxObject

Event handling overview

wxWindow is the base class for all windows and panel items. Any children of the window will be deleted automatically by the destructor before the window itself is deleted.

wxWindow::wxWindow
wxWindow::~wxWindow
wxWindow::AddChild
wxWindow::CaptureMouse
wxWindow::Center
wxWindow::Centre
wxWindow::ClientToScreen
wxWindow::Close
wxWindow::DestroyChildren
wxWindow::DragAcceptFiles
wxWindow::Enable
wxWindow::GetCharHeight
wxWindow::GetCharWidth
wxWindow::GetChildren
wxWindow::GetClientSize
wxWindow::GetConstraints
wxWindow::GetEventHandler
wxWindow::GetGrandParent
wxWindow::GetHandle
wxWindow::GetPosition
wxWindow::GetLabel
wxWindow::GetName
wxWindow::GetParent
wxWindow::GetSize
wxWindow::GetTextExtent
wxWindow::GetUserEditMode
wxWindow::GetWindowStyleFlag
wxWindow::IsShown
wxWindow::Layout
wxWindow::MakeModal
wxWindow::Move
wxWindow::PopupMenu
wxWindow::Refresh
wxWindow::ReleaseMouse
wxWindow::ScreenToClient
wxWindow::SetAutoLayout
wxWindow::SetConstraints
wxWindow::SetDoubleClick
wxWindow::SetFocus
wxWindow::SetName
wxWindow::SetSize
wxWindow::SetSizeHints
wxWindow::SetClientSize
wxWindow::SetColourMap
wxWindow::SetCursor
wxWindow::SetEventHandler
wxWindow::SetTitle
wxWindow::SetUserEditMode
wxWindow::Show


wxWindow::wxWindow

void wxWindow(void)

Constructor.


wxWindow::~wxWindow

void ~wxWindow(void)

Destructor. Deletes all subwindows, then deletes itself.


wxWindow::AddChild

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.


wxWindow::CaptureMouse

void CaptureMouse(void)

Directs all mouse input to this window. Call ReleaseMouse to release the capture.


wxWindow::Center

void Center(int direction)

See Centre.


wxWindow::Centre

void Centre(int direction)

Centres the window. The parameter may be wxHORIZONTAL, wxVERTICAL or wxBOTH.

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.


wxWindow::ClientToScreen

void ClientToScreen(int *x, int *y)

Converts the values pointed to by x and y to screen coordinates from coordinates relative to this window.


wxWindow::Close

Bool Close(Bool force)

Applies to managed windows (wxFrames and wxDialogBoxes) only. The purpose of this call is to provide a more elegant way of destroying a window than using the delete operator.

Close calls OnClose for the window, providing an opportunity for the window to veto the close.

If OnClose returns FALSE and force is FALSE, then FALSE is returned and no deletion occurs.

If force is TRUE, then regardless of the return value of OnClose, the window will be added to a list for deletion during application idle time. The window will therefore not be deleted immediately, and the object can be used just after calling Close.

This has an important benefit under X, where immediate deletion of a window can cause problems if events for that window and its children are still pending. Using Close should eliminate these problems since the window will not be deleted until there are no more X events pending.


wxWindow::DestroyChildren

void DestroyChildren(void)

Destroys all children of a window. Called automatically by the destructor.


wxWindow::DragAcceptFiles

void DragAcceptFiles(Bool accept)

Under Windows, if accept is TRUE, makes the window eligible for a OnDropFiles event.


wxWindow::Enable

void Enable(Bool enable)

Enable or disable the window, so input has no effect.


wxWindow::GetCharHeight

float GetCharHeight(void)

Get the character height for this window.


wxWindow::GetCharWidth

float GetCharWidth(void)

Get the average character width for this window.


wxWindow::GetChildren

wxList * GetChildren(void)

Returns a temporary pointer to a list of the window's children.


wxWindow::GetClientSize

void GetClientSize(int *width, int *height)

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.


wxWindow::GetConstraints

wxLayoutConstraints * GetConstraints(void)

Gets a pointer to the window's layout constraints (if any).


wxWindow::GetEventHandler

wxEvtHandler * GetEventHandler(void)

Gets the event handler for this window. By default, the window is its own event handler. Use this function if you wish to manually call an event handler function (such as OnPaint).

See wxEvtHandler.


wxWindow::GetGrandParent

wxWindow * GetGrandParent(void)

Returns the grandparent of a window, if any.


wxWindow::GetHandle

char * GetHandle(void)

Gets the platform-specific handle of the physical window.


wxWindow::GetPosition

void GetPosition(int *x, int *y)

This gets the position of the window in pixels, relative to the parent window or if no parent, relative to the whole display.


wxWindow::GetLabel

char * GetLabel(void)

Generic way of getting a label from any window, perhaps for identification purposes. Some windows do not have labels (such as subwindows), but frames, dialogs and panel items all have labels, where the interpretation of what constitutes a label differs from class to class. This can be useful for meta-programs (such as testing tools or special-needs access programs) which need to identify windows by name rather than visually.


wxWindow::GetName

char * GetName(void)

Returns a pointer to internal data containing the window's name. This name is not guaranteed to be unique; it is up to the programmer to supply an appropriate name.


wxWindow::GetParent

wxWindow * GetParent(void)

Returns the parent of a window, if any.


wxWindow::GetSize

void GetSize(int *width, int *height)

This gets the size of the entire window in pixels.


wxWindow::GetTextExtent

void GetTextExtent(char *string, float *x, float *y)

Gets the width and height of the string as it would be drawn on the window with the currently selected font.


wxWindow::GetUserEditMode

Bool GetUserEditMode(void)

Returns TRUE if the window is in user interface edit mode.

See wxWindow::SetUserEditMode for further details.


wxWindow::GetWindowStyleFlag

long GetWindowStyleFlag(void)

Gets the window style that was passed to the consructor or Create member.


wxWindow::IsShown

Bool IsShown(void)

Returns TRUE if the window is shown, FALSE if it has been hidden.


wxWindow::Layout

void Layout(void)

Invokes the constraint-based layout algorithm for this window. It is called automatically by the default wxWindow::OnSize member.


wxWindow::MakeModal

void MakeModal(Bool flag)

If flag is TRUE, this call disables all other windows in the application so that the user can only interact with this window. If flag is FALSE, the effect is reversed.


wxWindow::Move

void Move(int x, int y)

Moves the window to the given position.

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);

wxWindow::PopupMenu

Bool PopupMenu(wxMenu *menu, float x, float y)

Pops up the given menu at the specified coordinates, relative to this window, and returns control when the user has dismissed the menu. If a menu item is selected, the callback defined for the menu is called with wxMenu and wxCommandEvent reference arguments. The callback should access the commandInt member of the event to check the selected menu identifier.

Valid only for subwindows (panels, canvases and text windows).

See also wxMenu.

This function should now function correctly under Motif, removing the need to use FakePopupMenu.


wxWindow::Refresh

void Refresh(Bool eraseBackground = TRUE, wxRectangle *rect = NULL)

Causes a message or event to be generated to repaint the window. If eraseBackground is TRUE, the background will be erased. If rect is non-NULL, only the given rectangle will be treated as damaged.


wxWindow::ReleaseMouse

void ReleaseMouse(void)

Releases mouse input captured with CaptureMouse.


wxWindow::ScreenToClient

void ScreenToClient(int *x, int *y)

Converts the values pointed to by x and y to window coordinates from screen coordinates.


wxWindow::SetAutoLayout

void SetAutoLayout(Bool autoLayout)

Set this to TRUE if you wish the Layout function to be called from within wxWindow::OnSize functions (when the window is resized).

See also SetConstraints.


wxWindow::SetConstraints

void SetConstraints(wxLayoutConstraints *constraints)

Sets the window to have the given layout constraints. The window will then own the object, and will take care of its deletion. If an existing layout constraints object is already owned by the window, it will be deleted.

Pass NULL to this function to disassociate and delete the window's constraints.

You must call wxWindow::SetAutoLayout to tell a window to use the constraints automatically in OnSize; otherwise, you must override OnSize and call Layout explicitly.


wxWindow::SetDoubleClick

void SetDoubleClick(Bool allowDoubleClick)

For canvases, allows double click if allowDoubleClick is TRUE. The default is FALSE.


wxWindow::SetFocus

void SetFocus(void)

This sets the window to receive keyboard input. The only panel item that will respond to this under XView is the wxText item and derived items.


wxWindow::SetName

void SetName(char *name)

Sets the window's name.


wxWindow::SetSize

void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO)

void SetSize(int width, int height)

This sets the size and/or position of the entire window in pixels. The second form is a convenience for calling the first form with default x and y parameters, and must be used with non-default width and height values.

The first form sets the position and optionally size, of the window. Parameters may be -1 to indicate either that a default should be supplied by wxWindows, or that the current value of the dimension should be used. The behaviour is controlled by sizeFlags, which is a bit list of the following:

In versions of wxWindows prior to 1.61 (c), it was not always clear what interpretation was being used. Now implementations of SetSize can also implicitly implement the wxWindow::Move function, which is defined as the call:

  SetSize(x, y, -1, -1, wxSIZE_USE_EXISTING);

wxWindow::SetSizeHints

void SetSizeHints(int minW=-1, int minH=-1, int maxW=-1, int maxH=-1, int incW=-1, int incH=-1)

Sets the minimum and maximum frame size under MS Windows, Motif and XView. Under Motif and XView the width and height resizing increments can also be set.

If a pair of values is not set (or set to -1), the default values will be used.


wxWindow::SetClientSize

void SetClientSize(int width, int height)

This sets the size of the window client area in pixels. Using this function to size a window tends to be more device-independent than SetSize, since the application need not worry about what dimensions the border or title bar have when trying to fit the window around panel items, for example.


wxWindow::SetColourMap

void SetColourMap(wxColourMap *colourMap)

Assigns the given colourmap to the window.

See wxColourMap for further details.


wxWindow::SetCursor

wxCursor * SetCursor(wxCursor *cursor)

Sets the window's cursor, returning the previous cursor (if any). This function applies to all subwindows.

See also ::wxSetCursor, wxCursor.


wxWindow::SetEventHandler

void SetEventHandler(wxEvtHandler *handler)

Sets the event handler for this window. By default, the window is its own event handler. See wxEvtHandler.


wxWindow::SetTitle

void SetTitle(char *title)

Sets the window's title, allocating its own string storage. Currently applicable only to frames.


wxWindow::SetUserEditMode

void SetUserEditMode(Bool editable)

Sets a flag indicating that the user can 'edit' the interface. This is for the use of visual user interface building tools, and currently only works for wxPanel and wxDialogBox.

When this mode is on, the windows stop having their normal functionality and instead receives OnEvent calls that the application can intercept. In particular, the base wxPanel class implements panel item moving and sizing, and passes left and right click events from the items and panel to the application via functions such as OnLeftClick. The application might pop up a menu or select/deselect items in response to these calls.

See also wxWindow::GetUserEditMode.


wxWindow::Show

Bool Show(Bool show)

If show is TRUE, displays the window and brings it to the front. Otherwise, hides the window.