Contents Up Previous Next

wxWindow

wxWindow is the base class for all windows and represents any visible object on screen. All controls, top level windows and so on are windows. Sizers and device contexts are not, however, as they don't appear on screen themselves.

Please note that all children of the window will be deleted automatically by the destructor before the window itself is deleted which means that you don't have to worry about deleting them manually. Please see the window deletion overview for more information.

Also note that in this, and many others, wxWidgets classes some GetXXX() methods may be overloaded (as, for example, GetSize or GetClientSize). In this case, the overloads are non-virtual because having multiple virtual functions with the same name results in a virtual function name hiding at the derived class level (in English, this means that the derived class has to override all overloaded variants if it overrides any of them). To allow overriding them in the derived class, wxWidgets uses a unique protected virtual DoGetXXX() method and all GetXXX() ones are forwarded to it, so overriding the former changes the behaviour of the latter.

Derived from

wxEvtHandler
wxObject

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 or on all platforms.

wxBORDER_SIMPLE Displays a thin border around the window. wxSIMPLE_BORDER is the old name for this style.
wxBORDER_DOUBLE Displays a double border. wxDOUBLE_BORDER is the old name for this style. Windows and Mac only.
wxBORDER_SUNKEN Displays a sunken border. wxSUNKEN_BORDER is the old name for this style.
wxBORDER_RAISED Displays a raised border. wxRAISED_BORDER is the old name for this style.
wxBORDER_STATIC Displays a border suitable for a static control. wxSTATIC_BORDER is the old name for this style. Windows only.
wxBORDER_THEME Displays a themed border where possible. Currently this has an effect on Windows XP and above only. For more information on themed borders, please see Themed borders on Windows.
wxBORDER_NONE Displays no border, overriding the default border style for the window. wxNO_BORDER is the old name for this style.
wxTRANSPARENT_WINDOW The window is transparent, that is, it will not receive paint events. Windows only.
wxTAB_TRAVERSAL Use this to enable tab traversal for non-dialog windows.
wxWANTS_CHARS Use this to indicate that the window wants to get all char/key events for all keys - even for keys like TAB or ENTER which are usually used for dialog navigation and which wouldn't be generated without this style. If you need to use this style in order to get the arrows or etc., but would still like to have normal keyboard navigation take place, you should create and send a wxNavigationKeyEvent in response to the key events for Tab and Shift-Tab.
wxNO_FULL_REPAINT_ON_RESIZE On Windows, this style used to disable repainting the window completely when its size is changed. Since this behaviour is now the default, the style is now obsolete and no longer has an effect.
wxVSCROLL Use this style to enable a vertical scrollbar.
wxHSCROLL Use this style to enable a horizontal scrollbar.
wxALWAYS_SHOW_SB If a window has scrollbars, disable them instead of hiding them when they are not needed (i.e. when the size of the window is big enough to not require the scrollbars to navigate it). This style is currently implemented for wxMSW, wxGTK and wxUniversal and does nothing on the other platforms.
wxCLIP_CHILDREN Use this style to eliminate flicker caused by the background being repainted, then children being painted over them. Windows only.
wxFULL_REPAINT_ON_RESIZE Use this style to force a complete redraw of the window whenever it is resized instead of redrawing just the part of the window affected by resizing. Note that this was the behaviour by default before 2.5.1 release and that if you experience redraw problems with code which previously used to work you may want to try this. Currently this style applies on GTK+ 2 and Windows only, and full repainting is always done on other platforms.

See also window styles overview.

Extra window styles

The following are extra styles, set using wxWindow::SetExtraStyle.

wxWS_EX_VALIDATE_RECURSIVELY By default, Validate/TransferDataTo/FromWindow() only work on direct children of the window (compatible behaviour). Set this flag to make them recursively descend into all subwindows.
wxWS_EX_BLOCK_EVENTS wxCommandEvents and the objects of the derived classes are forwarded to the parent window and so on recursively by default. Using this flag for the given window allows to block this propagation at this window, i.e. prevent the events from being propagated further upwards. Dialogs have this flag on by default.
wxWS_EX_TRANSIENT Don't use this window as an implicit parent for the other windows: this must be used with transient windows as otherwise there is the risk of creating a dialog/frame with this window as a parent which would lead to a crash if the parent is destroyed before the child.
wxWS_EX_PROCESS_IDLE This window should always process idle events, even if the mode set by wxIdleEvent::SetMode is wxIDLE_PROCESS_SPECIFIED.
wxWS_EX_PROCESS_UI_UPDATES This window should always process UI update events, even if the mode set by wxUpdateUIEvent::SetMode is wxUPDATE_UI_PROCESS_SPECIFIED.

See also

Event handling overview
Window sizing overview

Members

wxWindow::wxWindow
wxWindow::~wxWindow
wxWindow::AddChild
wxWindow::CacheBestSize
wxWindow::CaptureMouse
wxWindow::Center
wxWindow::CenterOnParent
wxWindow::CenterOnScreen
wxWindow::Centre
wxWindow::CentreOnParent
wxWindow::CentreOnScreen
wxWindow::ClearBackground
wxWindow::ClientToScreen
wxWindow::ClientToWindowSize
wxWindow::Close
wxWindow::ConvertDialogToPixels
wxWindow::ConvertPixelsToDialog
wxWindow::Destroy
wxWindow::DestroyChildren
wxWindow::Disable
wxWindow::DoGetBestSize
wxWindow::DoUpdateWindowUI
wxWindow::DragAcceptFiles
wxWindow::Enable
wxWindow::FindFocus
wxWindow::FindWindow
wxWindow::FindWindowById
wxWindow::FindWindowByLabel
wxWindow::FindWindowByName
wxWindow::Fit
wxWindow::FitInside
wxWindow::Freeze
wxWindow::GetAcceleratorTable
wxWindow::GetAccessible
wxWindow::GetAdjustedBestSize
wxWindow::GetBackgroundColour
wxWindow::GetBackgroundStyle
wxWindow::GetEffectiveMinSize
wxWindow::GetBestSize
wxWindow::GetCapture
wxWindow::GetCaret
wxWindow::GetCharHeight
wxWindow::GetCharWidth
wxWindow::GetChildren
wxWindow::GetClassDefaultAttributes
wxWindow::GetClientSize
wxWindow::GetConstraints
wxWindow::GetContainingSizer
wxWindow::GetCursor
wxWindow::GetDefaultAttributes
wxWindow::GetDropTarget
wxWindow::GetEventHandler
wxWindow::GetExtraStyle
wxWindow::GetFont
wxWindow::GetForegroundColour
wxWindow::GetGrandParent
wxWindow::GetHandle
wxWindow::GetHelpTextAtPoint
wxWindow::GetHelpText
wxWindow::GetId
wxWindow::GetLabel
wxWindow::GetMaxSize
wxWindow::GetMinSize
wxWindow::GetName
wxWindow::GetNextSibling
wxWindow::GetParent
wxWindow::GetPosition
wxWindow::GetPrevSibling
wxWindow::GetRect
wxWindow::GetScreenPosition
wxWindow::GetScreenRect
wxWindow::GetScrollPos
wxWindow::GetScrollRange
wxWindow::GetScrollThumb
wxWindow::GetSize
wxWindow::GetSizer
wxWindow::GetTextExtent
wxWindow::GetToolTip
wxWindow::GetUpdateRegion
wxWindow::GetValidator
wxWindow::GetVirtualSize
wxWindow::GetWindowBorderSize
wxWindow::GetWindowStyleFlag
wxWindow::GetWindowVariant
wxWindow::HasCapture
wxWindow::HasFlag
wxWindow::HasMultiplePages
wxWindow::HasScrollbar
wxWindow::HasTransparentBackground
wxWindow::Hide
wxWindow::InheritAttributes
wxWindow::InitDialog
wxWindow::InvalidateBestSize
wxWindow::IsDoubleBuffered
wxWindow::IsEnabled
wxWindow::IsExposed
wxWindow::IsFrozen
wxWindow::IsRetained
wxWindow::IsShown
wxWindow::IsShownOnScreen
wxWindow::IsTopLevel
wxWindow::Layout
wxWindow::LineDown
wxWindow::LineUp
wxWindow::Lower
wxWindow::MakeModal
wxWindow::Move
wxWindow::MoveAfterInTabOrder
wxWindow::MoveBeforeInTabOrder
wxWindow::Navigate
wxWindow::OnInternalIdle
wxWindow::PageDown
wxWindow::PageUp
wxWindow::PopEventHandler
wxWindow::PopupMenu
wxWindow::PushEventHandler
wxWindow::Raise
wxWindow::Refresh
wxWindow::RefreshRect
wxWindow::RegisterHotKey
wxWindow::ReleaseMouse
wxWindow::RemoveChild
wxWindow::RemoveEventHandler
wxWindow::Reparent
wxWindow::ScreenToClient
wxWindow::ScrollLines
wxWindow::ScrollPages
wxWindow::ScrollWindow
wxWindow::SetAcceleratorTable
wxWindow::SetAccessible
wxWindow::SetAutoLayout
wxWindow::SetBackgroundColour
wxWindow::SetBackgroundStyle
wxWindow::SetInitialSize
wxWindow::SetCaret
wxWindow::SetClientSize
wxWindow::SetConstraints
wxWindow::SetContainingSizer
wxWindow::SetCursor
wxWindow::SetDropTarget
wxWindow::SetInitialBestSize
wxWindow::SetEventHandler
wxWindow::SetExtraStyle
wxWindow::SetFocus
wxWindow::SetFocusFromKbd
wxWindow::SetFont
wxWindow::SetForegroundColour
wxWindow::SetHelpText
wxWindow::SetId
wxWindow::SetLabel
wxWindow::SetMaxSize
wxWindow::SetMinSize
wxWindow::SetName
wxWindow::SetOwnBackgroundColour
wxWindow::SetOwnFont
wxWindow::SetOwnForegroundColour
wxWindow::SetPalette
wxWindow::SetScrollbar
wxWindow::SetScrollPos
wxWindow::SetSize
wxWindow::SetSizeHints
wxWindow::SetSizer
wxWindow::SetSizerAndFit
wxWindow::SetThemeEnabled
wxWindow::SetToolTip
wxWindow::SetValidator
wxWindow::SetVirtualSize
wxWindow::SetVirtualSizeHints
wxWindow::SetWindowStyle
wxWindow::SetWindowStyleFlag
wxWindow::SetWindowVariant
wxWindow::ShouldInheritColours
wxWindow::Show
wxWindow::Thaw
wxWindow::ToggleWindowStyle
wxWindow::TransferDataFromWindow
wxWindow::TransferDataToWindow
wxWindow::UnregisterHotKey
wxWindow::Update
wxWindow::UpdateWindowUI
wxWindow::Validate
wxWindow::WarpPointer
wxWindow::WindowToClientSize


wxWindow::wxWindow

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::~wxWindow

~wxWindow()

Destructor. Deletes all subwindows, then deletes itself. Instead of using the delete operator explicitly, you should normally use wxWindow::Destroy so that wxWidgets can delete a window only when it is safe to do so, in idle time.

See also

Window deletion overview, wxWindow::Destroy, wxCloseEvent


wxWindow::AddChild

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.

Notice that this function is mostly internal to wxWidgets and shouldn't be called by the user code.

Parameters

child


wxWindow::CacheBestSize

void CacheBestSize(const wxSize& size) const

Sets the cached best size value.


wxWindow::CaptureMouse

virtual void CaptureMouse()

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

Note that wxWidgets maintains the stack of windows having captured the mouse and when the mouse is released the capture returns to the window which had had captured it previously and it is only really released if there were no previous window. In particular, this means that you must release the mouse as many times as you capture it, unless the window receives the wxMouseCaptureLostEvent event.

Any application which captures the mouse in the beginning of some operation must handle wxMouseCaptureLostEvent and cancel this operation when it receives the event. The event handler must not recapture mouse.

See also

wxWindow::ReleaseMouse wxMouseCaptureLostEvent


wxWindow::Center

void Center(int direction)

A synonym for Centre.


wxWindow::CenterOnParent

void CenterOnParent(int direction)

A synonym for CentreOnParent.


wxWindow::CenterOnScreen

void CenterOnScreen(int direction)

A synonym for CentreOnScreen.


wxWindow::Centre

void Centre(int direction = wxBOTH)

Centres the window.

Parameters

direction

The flag wxCENTRE_FRAME is obsolete and should not be used any longer (it has no effect).

Remarks

If the window is a top level one (i.e. doesn't have a parent), it will be centered relative to the screen anyhow.

See also

wxWindow::Center


wxWindow::CentreOnParent

void CentreOnParent(int direction = wxBOTH)

Centres the window on its parent. This is a more readable synonym for Centre.

Parameters

direction

Remarks

This methods provides for a way to center top level windows over their parents instead of the entire screen. If there is no parent or if the window is not a top level window, then behaviour is the same as wxWindow::Centre.

See also

wxWindow::CentreOnScreen


wxWindow::CentreOnScreen

void CentreOnScreen(int direction = wxBOTH)

Centres the window on screen. This only works for top level windows - otherwise, the window will still be centered on its parent.

Parameters

direction

See also

wxWindow::CentreOnParent


wxWindow::ClearBackground

void ClearBackground()

Clears the window by filling it with the current background colour. Does not cause an erase background event to be generated.


wxWindow::ClientToScreen

virtual void ClientToScreen(int* x, int* y) const

wxPerl note: In wxPerl this method returns a 2-element list instead of modifying its parameters.

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:


wxWindow::ClientToWindowSize

wxSize ClientToWindowSize(const wxSize& size)

Converts client area size size to corresponding window size. In other words, the returned value is what would GetSize return if this window had client area of given size. Components with wxDefaultCoord value are left unchanged.

Note that the conversion is not always exact, it assumes that non-client area doesn't change and so doesn't take into account things like menu bar (un)wrapping or (dis)appearance of the scrollbars.

This function is new since wxWidgets version 2.8.8

See also

wxWindow::WindowToClientSize


wxWindow::Close

bool Close(bool force = false)

This function simply generates a wxCloseEvent whose handler usually tries to close the window. It doesn't close the window itself, however.

Parameters

force

Remarks

Close calls the close handler for the window, providing an opportunity for the window to choose whether to destroy the window. Usually it is only used with the top level windows (wxFrame and wxDialog classes) as the others are not supposed to have any special OnClose() logic.

The close handler should check whether the window is being deleted forcibly, using wxCloseEvent::CanVeto, in which case it should destroy the window using wxWindow::Destroy.

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 is handled by the appropriate button event handler and may do anything at all.

To guarantee that the window will be destroyed, call wxWindow::Destroy instead

See also

Window deletion overview, wxWindow::Destroy, wxCloseEvent


wxWindow::ConvertDialogToPixels

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.

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:

Additionally, the following helper functions are defined:


wxWindow::ConvertPixelsToDialog

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 multiplied 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.

See also

wxWindow::ConvertDialogToPixels

wxPython note: In place of a single overloaded method name, wxPython implements the following methods:


wxWindow::Destroy

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-existent 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.


wxWindow::DestroyChildren

virtual void DestroyChildren()

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


wxWindow::Disable

bool Disable()

Disables the window, same as Enable(false).

Return value

Returns true if the window has been disabled, false if it had been already disabled before the call to this function.


wxWindow::DoGetBestSize

virtual wxSize DoGetBestSize() const

Gets the size which best suits the window: for a control, it would be the minimal size which doesn't truncate the control, for a panel - the same size as it would have after a call to Fit().


wxWindow::DoUpdateWindowUI

virtual void DoUpdateWindowUI(wxUpdateUIEvent& event)

Does the window-specific updating after processing the update event. This function is called by wxWindow::UpdateWindowUI in order to check return values in the wxUpdateUIEvent and act appropriately. For example, to allow frame and dialog title updating, wxWidgets implements this function as follows:

// do the window-specific processing after processing the update event
void wxTopLevelWindowBase::DoUpdateWindowUI(wxUpdateUIEvent& event)
{
    if ( event.GetSetEnabled() )
        Enable(event.GetEnabled());

    if ( event.GetSetText() )
    {
        if ( event.GetText() != GetTitle() )
            SetTitle(event.GetText());
    }
}


wxWindow::DragAcceptFiles

virtual void DragAcceptFiles(bool accept)

Enables or disables eligibility for drop file events (OnDropFiles).

Parameters

accept

Remarks

Windows only until version 2.8.9, available on all platforms since 2.8.10. Cannot be used together with SetDropTarget on non-Windows platforms.


wxWindow::Enable

virtual bool Enable(bool enable = true)

Enable or disable the window for user input. Note that when a parent window is disabled, all of its children are disabled as well and they are reenabled again when the parent is.

Parameters

enable

Return value

Returns true if the window has been enabled or disabled, false if nothing was done, i.e. if the window had already been in the specified state.

See also

wxWindow::IsEnabled, wxWindow::Disable, wxRadioBox::Enable


wxWindow::FindFocus

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::SetFocus


wxWindow::FindWindow

wxWindow* FindWindow(long id) const

Find a child of this window, by identifier.

wxWindow* FindWindow(const wxString& name) const

Find a child of this window, by name.

wxPython note: In place of a single overloaded method name, wxPython implements the following methods:


wxWindow::FindWindowById

static wxWindow* FindWindowById(long id, wxWindow* parent = NULL)

Find the first window with the given id.

If parent is NULL, the search will start from all top-level frames and dialog boxes; if non-NULL, the search will be limited to the given window hierarchy. The search is recursive in both cases.

See also

FindWindow


wxWindow::FindWindowByLabel

static wxWindow* FindWindowByLabel(const wxString& label, wxWindow* parent = NULL)

Find a window by its label. Depending on the type of window, the label may be a window title or panel item label. If parent is NULL, the search will start from all top-level frames and dialog boxes; if non-NULL, the search will be limited to the given window hierarchy. The search is recursive in both cases.

See also

FindWindow


wxWindow::FindWindowByName

static wxWindow* FindWindowByName(const wxString& name, wxWindow* parent = NULL)

Find a window by its name (as given in a window constructor or Create function call). If parent is NULL, the search will start from all top-level frames and dialog boxes; if non-NULL, the search will be limited to the given window hierarchy. The search is recursive in both cases.

If no window with such name is found, FindWindowByLabel is called.

See also

FindWindow


wxWindow::Fit

virtual void Fit()

Sizes the window so that it fits around its subwindows. This function won't do anything if there are no subwindows and will only really work correctly if the sizers are used for the subwindows layout. Also, if the window has exactly one subwindow it is better (faster and the result is more precise as Fit adds some margin to account for fuzziness of its calculations) to call

    window->SetClientSize(child->GetSize());
instead of calling Fit.


wxWindow::FitInside

virtual void FitInside()

Similar to Fit, but sizes the interior (virtual) size of a window. Mainly useful with scrolled windows to reset scrollbars after sizing changes that do not trigger a size event, and/or scrolled windows without an interior sizer. This function similarly won't do anything if there are no subwindows.


wxWindow::Freeze

virtual void Freeze()

Freezes the window or, in other words, prevents any updates from taking place on screen, the window is not redrawn at all. Thaw must be called to reenable window redrawing. Calls to these two functions may be nested.

This method is useful for visual appearance optimization (for example, it is a good idea to use it before doing many large text insertions in a row into a wxTextCtrl under wxGTK) but is not implemented on all platforms nor for all controls so it is mostly just a hint to wxWidgets and not a mandatory directive.

See also

wxWindowUpdateLocker


wxWindow::GetAcceleratorTable

wxAcceleratorTable* GetAcceleratorTable() const

Gets the accelerator table for this window. See wxAcceleratorTable.


wxWindow::GetAccessible

wxAccessible* GetAccessible()

Returns the accessible object for this window, if any.

See also wxAccessible.


wxWindow::GetAdjustedBestSize

wxSize GetAdjustedBestSize() const

This method is deprecated, use GetEffectiveMinSize instead.


wxWindow::GetBackgroundColour

virtual wxColour GetBackgroundColour() const

Returns the background colour of the window.

See also

wxWindow::SetBackgroundColour, wxWindow::SetForegroundColour, wxWindow::GetForegroundColour


wxWindow::GetBackgroundStyle

virtual wxBackgroundStyle GetBackgroundStyle() const

Returns the background style of the window. The background style indicates whether background colour should be determined by the system (wxBG_STYLE_SYSTEM), be set to a specific colour (wxBG_STYLE_COLOUR), or should be left to the application to implement (wxBG_STYLE_CUSTOM).

On GTK+, use of wxBG_STYLE_CUSTOM allows the flicker-free drawing of a custom background, such as a tiled bitmap. Currently the style has no effect on other platforms.

See also

wxWindow::SetBackgroundColour, wxWindow::GetForegroundColour, wxWindow::SetBackgroundStyle


wxWindow::GetEffectiveMinSize

wxSize GetEffectiveMinSize() const

Merges the window's best size into the min size and returns the result. This is the value used by sizers to determine the appropriate ammount of sapce to allocate for the widget.

See also

wxWindow::GetBestSize, wxWindow::SetInitialSize


wxWindow::GetBestSize

wxSize GetBestSize() const

This functions returns the best acceptable minimal size for the window. For example, for a static control, it will be the minimal size such that the control label is not truncated. For windows containing subwindows (typically wxPanel), the size returned by this function will be the same as the size the window would have had after calling Fit.


wxWindow::GetCapture

static wxWindow * GetCapture()

Returns the currently captured window.

See also

wxWindow::HasCapture, wxWindow::CaptureMouse, wxWindow::ReleaseMouse, wxMouseCaptureLostEvent wxMouseCaptureChangedEvent


wxWindow::GetCaret

wxCaret * GetCaret() const

Returns the caret associated with the window.


wxWindow::GetCharHeight

virtual int GetCharHeight() const

Returns the character height for this window.


wxWindow::GetCharWidth

virtual int GetCharWidth() const

Returns the average character width for this window.


wxWindow::GetChildren

wxWindowList& GetChildren()

const wxWindowList& GetChildren() const

Returns a reference to the list of the window's children. wxWindowList is a type-safe wxList-like class whose elements are of type wxWindow *.


wxWindow::GetClassDefaultAttributes

static wxVisualAttributes GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL)

Returns the default font and colours which are used by the control. This is useful if you want to use the same font or colour in your own control as in a standard control -- which is a much better idea than hard coding specific colours or fonts which might look completely out of place on the users system, especially if it uses themes.

The variant parameter is only relevant under Mac currently and is ignore under other platforms. Under Mac, it will change the size of the returned font. See wxWindow::SetWindowVariant for more about this.

This static method is "overridden'' in many derived classes and so calling, for example, wxButton::GetClassDefaultAttributes() will typically return the values appropriate for a button which will be normally different from those returned by, say, wxListCtrl::GetClassDefaultAttributes().

The wxVisualAttributes structure has at least the fields font, colFg and colBg. All of them may be invalid if it was not possible to determine the default control appearance or, especially for the background colour, if the field doesn't make sense as is the case for colBg for the controls with themed background.

See also

InheritAttributes


wxWindow::GetClientSize

void GetClientSize(int* width, int* height) const

wxPerl note: In wxPerl this method takes no parameter and returns a 2-element list (width, height).

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, scrollbars, etc.

Parameters

width

height

wxPython note: In place of a single overloaded method name, wxPython implements the following methods:

See also

GetSize, GetVirtualSize


wxWindow::GetConstraints

wxLayoutConstraints* GetConstraints() const

Returns a pointer to the window's layout constraints, or NULL if there are none.


wxWindow::GetContainingSizer

const wxSizer * GetContainingSizer() const

Return the sizer that this window is a member of, if any, otherwise NULL.


wxWindow::GetCursor

const wxCursor& GetCursor() const

Return the cursor associated with this window.

See also

wxWindow::SetCursor


wxWindow::GetDefaultAttributes

virtual wxVisualAttributes GetDefaultAttributes() const

Currently this is the same as calling GetClassDefaultAttributes(GetWindowVariant()).

One advantage of using this function compared to the static version is that the call is automatically dispatched to the correct class (as usual with virtual functions) and you don't have to specify the class name explicitly.

The other one is that in the future this function could return different results, for example it might return a different font for an "Ok'' button than for a generic button if the users GUI is configured to show such buttons in bold font. Of course, the down side is that it is impossible to call this function without actually having an object to apply it to whereas the static version can be used without having to create an object first.


wxWindow::GetDropTarget

wxDropTarget* GetDropTarget() const

Returns the associated drop target, which may be NULL.

See also

wxWindow::SetDropTarget, Drag and drop overview


wxWindow::GetEventHandler

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


wxWindow::GetExtraStyle

long GetExtraStyle() const

Returns the extra style bits for the window.


wxWindow::GetFont

wxFont GetFont() const

Returns the font for this window.

See also

wxWindow::SetFont


wxWindow::GetForegroundColour

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

wxWindow* GetGrandParent() const

Returns the grandparent of a window, or NULL if there isn't one.


wxWindow::GetHandle

void* GetHandle() const

Returns the platform-specific handle of the physical window. Cast it to an appropriate handle, such as HWND for Windows, Widget for Motif, GtkWidget for GTK or WinHandle for PalmOS.

wxPython note: This method will return an integer in wxPython.

wxPerl note: This method will return an integer in wxPerl.


wxWindow::GetHelpTextAtPoint

virtual wxString GetHelpTextAtPoint(const wxPointpoint, wxHelpEvent::Origin origin) const

Gets the help text to be used as context-sensitive help for this window. This method should be overridden if the help message depends on the position inside the window, otherwise GetHelpText can be used.

Parameters

point

origin

This function is new since wxWidgets version 2.7.0


wxWindow::GetHelpText

virtual wxString GetHelpText() const

Gets the help text to be used as context-sensitive help for this window.

Note that the text is actually stored by the current wxHelpProvider implementation, and not in the window object itself.

See also

SetHelpText, GetHelpTextAtPoint, wxHelpProvider


wxWindow::GetId

int GetId() const

Returns the identifier of the window.

Remarks

Each window has an integer identifier. If the application has not provided one (or the default wxID_ANY) an unique identifier with a negative value will be generated.

See also

wxWindow::SetId, Window identifiers


wxWindow::GetLabel

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.


wxWindow::GetMaxSize

wxSize GetMaxSize() const

Returns the maximum size of the window, an indication to the sizer layout mechanism that this is the maximum possible size.


wxWindow::GetMinSize

virtual wxSize GetMinSize() const

Returns the minimum size of the window, an indication to the sizer layout mechanism that this is the minimum required size. It normally just returns the value set by SetMinSize, but it can be overridden to do the calculation on demand.


wxWindow::GetName

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

wxWindow::SetName


wxWindow::GetNextSibling

wxWindow * GetNextSibling() const

Returns the next window after this one among the parent children or NULL if this window is the last child.

This function is new since wxWidgets version 2.8.8

See also

GetPrevSibling


wxWindow::GetParent

virtual wxWindow* GetParent() const

Returns the parent of the window, or NULL if there is no parent.


wxWindow::GetPosition

virtual void GetPosition(int* x, int* y) const

wxPoint GetPosition() const

This gets the position of the window in pixels, relative to the parent window for the child windows or relative to the display origin for the top level windows.

Parameters

x

y

wxPython note: In place of a single overloaded method name, wxPython implements the following methods:

wxPerl note: In wxPerl there are two methods instead of a single overloaded method:

See also

GetScreenPosition


wxWindow::GetPrevSibling

wxWindow * GetPrevSibling() const

Returns the previous window before this one among the parent children or NULL if this window is the first child.

This function is new since wxWidgets version 2.8.8

See also

GetNextSibling


wxWindow::GetRect

virtual wxRect GetRect() const

Returns the size and position of the window as a wxRect object.

See also

GetScreenRect


wxWindow::GetScreenPosition

virtual void GetScreenPosition(int* x, int* y) const

wxPoint GetScreenPosition() const

Returns the window position in screen coordinates, whether the window is a child window or a top level one.

Parameters

x

y

See also

GetPosition


wxWindow::GetScreenRect

virtual wxRect GetScreenRect() const

Returns the size and position of the window on the screen as a wxRect object.

See also

GetRect


wxWindow::GetScrollPos

virtual int GetScrollPos(int orientation)

Returns the built-in scrollbar position.

See also

See wxWindow::SetScrollbar


wxWindow::GetScrollRange

virtual int GetScrollRange(int orientation)

Returns the built-in scrollbar range.

See also

wxWindow::SetScrollbar


wxWindow::GetScrollThumb

virtual int GetScrollThumb(int orientation)

Returns the built-in scrollbar thumb size.

See also

wxWindow::SetScrollbar


wxWindow::GetSize

void GetSize(int* width, int* height) const

wxSize GetSize() const

This gets the size of the entire window in pixels, including title bar, border, scrollbars, etc.

Parameters

width

height

wxPython note: In place of a single overloaded method name, wxPython implements the following methods:

wxPerl note: In wxPerl there are two methods instead of a single overloaded method:

See also

GetClientSize, GetVirtualSize


wxWindow::GetSizer

wxSizer * GetSizer() const

Return the sizer associated with the window by a previous call to SetSizer() or NULL.


wxWindow::GetTextExtent

virtual void GetTextExtent(const wxString& string, int* x, int* y, int* descent = NULL, int* externalLeading = NULL, const wxFont* font = NULL, 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:

wxPerl note: In wxPerl this method takes only the string and optionally font parameters, and returns a 4-element list ( x, y, descent, externalLeading ).


wxWindow::GetToolTip

wxToolTip* GetToolTip() const

Get the associated tooltip or NULL if none.


wxWindow::GetUpdateRegion

virtual wxRegion GetUpdateRegion() const

Returns the region specifying which parts of the window have been damaged. Should only be called within an wxPaintEvent handler.

See also

wxRegion, wxRegionIterator


wxWindow::GetValidator

wxValidator* GetValidator() const

Returns a pointer to the current validator for the window, or NULL if there is none.


wxWindow::GetVirtualSize

void GetVirtualSize(int* width, int* height) const

wxSize GetVirtualSize() const

This gets the virtual size of the window in pixels. By default it returns the client size of the window, but after a call to SetVirtualSize it will return that size.

Parameters

width

height

GetSize, GetClientSize


wxWindow::GetWindowBorderSize

wxSize GetWindowBorderSize() const

Returns the size of the left/right and top/bottom borders of this window in x and y components of the result respectively.


wxWindow::GetWindowStyleFlag

long GetWindowStyleFlag() const

Gets the window style that was passed to the constructor or Create method. GetWindowStyle() is another name for the same function.


wxWindow::GetWindowVariant

wxWindowVariant GetWindowVariant() const

Returns the value previously passed to wxWindow::SetWindowVariant.


wxWindow::HasCapture

virtual bool HasCapture() const

Returns true if this window has the current mouse capture.

See also

wxWindow::CaptureMouse, wxWindow::ReleaseMouse, wxMouseCaptureLostEvent wxMouseCaptureChangedEvent


wxWindow::HasFlag

bool HasFlag(int flag) const

Returns true if the window has the given flag bit set.


wxWindow::HasMultiplePages

virtual bool HasMultiplePages() const

This method should be overridden to return true if this window has multiple pages. All standard class with multiple pages such as wxNotebook, wxListbook and wxTreebook already override it to return true and user-defined classes with similar behaviour should do it as well to allow the library to handle such windows appropriately.


wxWindow::HasScrollbar

virtual bool HasScrollbar(int orient) const

Returns true if this window has a scroll bar for this orientation.

Parameters

orient


wxWindow::HasTransparentBackground

virtual bool HasTransparentBackground() const

Returns true if this window background is transparent (as, for example, for wxStaticText) and should show the parent window background.

This method is mostly used internally by the library itself and you normally shouldn't have to call it. You may, however, have to override it in your wxWindow-derived class to ensure that background is painted correctly.


wxWindow::Hide

bool Hide()

Equivalent to calling Show(false).


wxWindow::InheritAttributes

void InheritAttributes()

This function is (or should be, in case of custom controls) called during window creation to intelligently set up the window visual attributes, that is the font and the foreground and background colours.

By "intelligently'' the following is meant: by default, all windows use their own default attributes. However if some of the parents attributes are explicitly (that is, using SetFont and not SetOwnFont) changed and if the corresponding attribute hadn't been explicitly set for this window itself, then this window takes the same value as used by the parent. In addition, if the window overrides ShouldInheritColours to return false, the colours will not be changed no matter what and only the font might.

This rather complicated logic is necessary in order to accommodate the different usage scenarios. The most common one is when all default attributes are used and in this case, nothing should be inherited as in modern GUIs different controls use different fonts (and colours) than their siblings so they can't inherit the same value from the parent. However it was also deemed desirable to allow to simply change the attributes of all children at once by just changing the font or colour of their common parent, hence in this case we do inherit the parents attributes.


wxWindow::InitDialog

void InitDialog()

Sends an wxEVT_INIT_DIALOG event, whose handler usually transfers data to the dialog via validators.


wxWindow::InvalidateBestSize

void InvalidateBestSize()

Resets the cached best size value so it will be recalculated the next time it is needed.


wxWindow::IsDoubleBuffered

virtual bool IsDoubleBuffered() const

Returns true if the window contents is double-buffered by the system, i.e. if any drawing done on the window is really done on a temporary backing surface and transferred to the screen all at once later.

See also

wxBufferedDC


wxWindow::IsEnabled

virtual bool IsEnabled() const

Returns true if the window is enabled for input, false otherwise.

See also

wxWindow::Enable


wxWindow::IsExposed

bool IsExposed(int x, int y) const

bool IsExposed(wxPoint &pt) const

bool IsExposed(int x, int y, int w, int h) const

bool IsExposed(wxRect &rect) const

Returns true if the given point or rectangle area has been exposed since the last repaint. Call this in an paint event handler to optimize redrawing by only redrawing those areas, which have been exposed.

wxPython note: In place of a single overloaded method name, wxPython implements the following methods:


wxWindow::IsFrozen

virtual bool IsFrozen() const

Returns true if the window is currently frozen by a call to Freeze().

See also

Thaw()


wxWindow::IsRetained

virtual bool IsRetained() const

Returns true if the window is retained, false otherwise.

Remarks

Retained windows are only available on X platforms.


wxWindow::IsShown

virtual bool IsShown() const

Returns true if the window is shown, false if it has been hidden.

See also

wxWindow::IsShownOnScreen


wxWindow::IsShownOnScreen

virtual bool IsShownOnScreen() const

Returns true if the window is physically visible on the screen, i.e. it is shown and all its parents up to the toplevel window are shown as well.

See also

wxWindow::IsShown


wxWindow::IsTopLevel

bool IsTopLevel() const

Returns true if the given window is a top-level one. Currently all frames and dialogs are considered to be top-level windows (even if they have a parent window).


wxWindow::Layout

void Layout()

Invokes the constraint-based layout algorithm or the sizer-based algorithm for this window.

See wxWindow::SetAutoLayout: when auto layout is on, this function gets called automatically when the window is resized.


wxWindow::LineDown

This is just a wrapper for ScrollLines(1).


wxWindow::LineUp

This is just a wrapper for ScrollLines(-1).


wxWindow::Lower

void Lower()

Lowers the window to the bottom of the window hierarchy (z-order).

See also

Raise


wxWindow::MakeModal

virtual void MakeModal(bool flag)

Disables all other windows in the application so that the user can only interact with this window.

Parameters

flag


wxWindow::Move

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, wxDefaultCoord, wxDefaultCoord, wxSIZE_USE_EXISTING);
See also

wxWindow::SetSize

wxPython note: In place of a single overloaded method name, wxPython implements the following methods:


wxWindow::MoveAfterInTabOrder

void MoveAfterInTabOrder(wxWindow *win)

Moves this window in the tab navigation order after the specified win. This means that when the user presses TAB key on that other window, the focus switches to this window.

Default tab order is the same as creation order, this function and MoveBeforeInTabOrder() allow to change it after creating all the windows.

Parameters

win


wxWindow::MoveBeforeInTabOrder

void MoveBeforeInTabOrder(wxWindow *win)

Same as MoveAfterInTabOrder except that it inserts this window just before win instead of putting it right after it.


wxWindow::Navigate

bool Navigate(int flags = wxNavigationKeyEvent::IsForward)

Does keyboard navigation from this window to another, by sending a wxNavigationKeyEvent.

Parameters

flags

Remarks

You may wish to call this from a text control custom keypress handler to do the default navigation behaviour for the tab key, since the standard default behaviour for a multiline text control with the wxTE_PROCESS_TAB style is to insert a tab and not navigate to the next control.


wxWindow::OnInternalIdle

virtual void OnInternalIdle()

This virtual function is normally only used internally, but sometimes an application may need it to implement functionality that should not be disabled by an application defining an OnIdle handler in a derived class.

This function may be used to do delayed painting, for example, and most implementations call wxWindow::UpdateWindowUI in order to send update events to the window in idle time.


wxWindow::PageDown

This is just a wrapper for ScrollPages()(1).


wxWindow::PageUp

This is just a wrapper for ScrollPages()(-1).


wxWindow::PopEventHandler

wxEvtHandler* PopEventHandler(bool deleteHandler = false) const

Removes and returns the top-most event handler on the event handler stack.

Parameters

deleteHandler

See also

wxWindow::SetEventHandler, wxWindow::GetEventHandler, wxWindow::PushEventHandler, wxEvtHandler::ProcessEvent, wxEvtHandler


wxWindow::PopupMenu

bool PopupMenu(wxMenu* menu, const wxPoint& pos = wxDefaultPosition)

bool PopupMenu(wxMenu* menu, int x, int 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 corresponding menu event is generated and will be processed as usually. If the coordinates are not specified, the current mouse cursor position is used.

Parameters

menu

pos

x

y

See also

wxMenu

Remarks

Just before the menu is popped up, wxMenu::UpdateUI is called to ensure that the menu items are in the correct state. The menu does not get deleted by the window.

It is recommended to not explicitly specify coordinates when calling PopupMenu in response to mouse click, because some of the ports (namely, wxGTK) can do a better job of positioning the menu in that case.

wxPython note: In place of a single overloaded method name, wxPython implements the following methods:


wxWindow::PushEventHandler

void PushEventHandler(wxEvtHandler* handler)

Pushes this event handler onto the event stack for the window.

Parameters

handler

Remarks

An event handler is an object that is capable of processing the events sent to a window. By default, the window is its own event handler, but an application may wish to substitute another, for example to allow central implementation of event-handling for a variety of different window classes.

wxWindow::PushEventHandler allows an application to set up a chain of event handlers, where an event not handled by one event handler is handed to the next one in the chain. Use wxWindow::PopEventHandler to remove the event handler.

See also

wxWindow::SetEventHandler, wxWindow::GetEventHandler, wxWindow::PopEventHandler, wxEvtHandler::ProcessEvent, wxEvtHandler


wxWindow::Raise

void Raise()

Raises the window to the top of the window hierarchy (z-order).

In current version of wxWidgets this works both for managed and child windows.

See also

Lower


wxWindow::Refresh

virtual void Refresh(bool eraseBackground = true, const wxRect* rect = NULL)

Causes this window, and all of its children recursively (except under wxGTK1 where this is not implemented), to be repainted. Note that repainting doesn't happen immediately but only during the next event loop iteration, if you need to update the window immediately you should use Update instead.

Parameters

eraseBackground

rect

See also

wxWindow::RefreshRect


wxWindow::RefreshRect

void RefreshRect(const wxRect& rect, bool eraseBackground = true)

Redraws the contents of the given rectangle: only the area inside it will be repainted.

This is the same as Refresh but has a nicer syntax as it can be called with a temporary wxRect object as argument like this RefreshRect(wxRect(x, y, w, h)).


wxWindow::RegisterHotKey

bool RegisterHotKey(int hotkeyId, int modifiers, int virtualKeyCode)

Registers a system wide hotkey. Every time the user presses the hotkey registered here, this window will receive a hotkey event. It will receive the event even if the application is in the background and does not have the input focus because the user is working with some other application.

Parameters

hotkeyId

modifiers

virtualKeyCode

Return value

true if the hotkey was registered successfully. false if some other application already registered a hotkey with this modifier/virtualKeyCode combination.

Remarks

Use EVT_HOTKEY(hotkeyId, fnc) in the event table to capture the event. This function is currently only implemented under Windows. It is used in the Windows CE port for detecting hardware button presses.

See also

wxWindow::UnregisterHotKey


wxWindow::ReleaseMouse

virtual void ReleaseMouse()

Releases mouse input captured with wxWindow::CaptureMouse.

See also

wxWindow::CaptureMouse, wxWindow::HasCapture, wxWindow::ReleaseMouse, wxMouseCaptureLostEvent wxMouseCaptureChangedEvent


wxWindow::RemoveChild

virtual void RemoveChild(wxWindow* child)

Removes a child window. This is called automatically by window deletion functions so should not be required by the application programmer.

Notice that this function is mostly internal to wxWidgets and shouldn't be called by the user code.

Parameters

child


wxWindow::RemoveEventHandler

bool RemoveEventHandler(wxEvtHandler *handler)

Find the given handler in the windows event handler chain and remove (but not delete) it from it.

Parameters

handler

Return value

Returns true if it was found and false otherwise (this also results in an assert failure so this function should only be called when the handler is supposed to be there).

See also

PushEventHandler, PopEventHandler


wxWindow::Reparent

virtual bool Reparent(wxWindow* newParent)

Reparents the window, i.e the window will be removed from its current parent window (e.g. a non-standard toolbar in a wxFrame) and then re-inserted into another.

Parameters

newParent


wxWindow::ScreenToClient

virtual void ScreenToClient(int* x, int* y) const

virtual wxPoint ScreenToClient(const wxPoint& pt) const

Converts from screen to client window coordinates.

Parameters

x

y

pt

wxPython note: In place of a single overloaded method name, wxPython implements the following methods:


wxWindow::ScrollLines

virtual bool ScrollLines(int lines)

Scrolls the window by the given number of lines down (if lines is positive) or up.

Return value

Returns true if the window was scrolled, false if it was already on top/bottom and nothing was done.

Remarks

This function is currently only implemented under MSW and wxTextCtrl under wxGTK (it also works for wxScrolledWindow derived classes under all platforms).

See also

ScrollPages


wxWindow::ScrollPages

virtual bool ScrollPages(int pages)

Scrolls the window by the given number of pages down (if pages is positive) or up.

Return value

Returns true if the window was scrolled, false if it was already on top/bottom and nothing was done.

Remarks

This function is currently only implemented under MSW and wxGTK.

See also

ScrollLines


wxWindow::ScrollWindow

virtual void ScrollWindow(int dx, int dy, const wxRect* rect = NULL)

Physically scrolls the pixels in the window and move child windows accordingly.

Parameters

dx

dy

rect

Remarks

Note that you can often use wxScrolledWindow instead of using this function directly.


wxWindow::SetAcceleratorTable

virtual void SetAcceleratorTable(const wxAcceleratorTable& accel)

Sets the accelerator table for this window. See wxAcceleratorTable.


wxWindow::SetAccessible

void SetAccessible(wxAccessible* accessible)

Sets the accessible for this window. Any existing accessible for this window will be deleted first, if not identical to accessible.

See also wxAccessible.


wxWindow::SetAutoLayout

void SetAutoLayout(bool autoLayout)

Determines whether the wxWindow::Layout function will be called automatically when the window is resized. Please note that this only happens for the windows usually used to contain children, namely wxPanel and wxTopLevelWindow (and the classes deriving from them).

This method is called implicitly by wxWindow::SetSizer but if you use wxWindow::SetConstraints you should call it manually or otherwise the window layout won't be correctly updated when its size changes.

Parameters

autoLayout

See also

wxWindow::SetConstraints


wxWindow::SetBackgroundColour

virtual bool SetBackgroundColour(const wxColour& colour)

Sets the background colour of the window.

Please see InheritAttributes for explanation of the difference between this method and SetOwnBackgroundColour.

Parameters

colour

Remarks

The background colour is usually painted by the default wxEraseEvent event handler function under Windows and automatically under GTK.

Note that setting the background colour does not cause an immediate refresh, so you may wish to call wxWindow::ClearBackground or wxWindow::Refresh after calling this function.

Using this function will disable attempts to use themes for this window, if the system supports them. Use with care since usually the themes represent the appearance chosen by the user to be used for all applications on the system.

See also

wxWindow::GetBackgroundColour, wxWindow::SetForegroundColour, wxWindow::GetForegroundColour, wxWindow::ClearBackground, wxWindow::Refresh, wxEraseEvent


wxWindow::SetBackgroundStyle

virtual void SetBackgroundStyle(wxBackgroundStyle style)

Sets the background style of the window. The background style indicates whether background colour should be determined by the system (wxBG_STYLE_SYSTEM), be set to a specific colour (wxBG_STYLE_COLOUR), or should be left to the application to implement (wxBG_STYLE_CUSTOM).

On GTK+, use of wxBG_STYLE_CUSTOM allows the flicker-free drawing of a custom background, such as a tiled bitmap. Currently the style has no effect on other platforms.

See also

wxWindow::SetBackgroundColour, wxWindow::GetForegroundColour, wxWindow::GetBackgroundStyle


wxWindow::SetInitialSize

void SetInitialSize(const wxSize& size = wxDefaultSize)

A smart SetSize that will fill in default size components with the window's best size values. Also sets the window's minsize to the value passed in for use with sizers. This means that if a full or partial size is passed to this function then the sizers will use that size instead of the results of GetBestSize to determine the minimum needs of the window for layout.

Most controls will use this to set their initial size, and their min size to the passed in value (if any.)

See also

wxWindow::SetSize, wxWindow::GetBestSize, wxWindow::GetEffectiveMinSize


wxWindow::SetCaret

void SetCaret(wxCaret *caret) const

Sets the caret associated with the window.


wxWindow::SetClientSize

virtual void SetClientSize(int width, int height)

virtual void SetClientSize(const wxSize& size)

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 wxWindow::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.

Parameters

width

height

size

wxPython note: In place of a single overloaded method name, wxPython implements the following methods:


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.

Parameters

constraints

Remarks

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. When setting both a wxLayoutConstraints and a wxSizer, only the sizer will have effect.


wxWindow::SetContainingSizer

void SetContainingSizer(wxSizer* sizer)

This normally does not need to be called by user code. It is called when a window is added to a sizer, and is used so the window can remove itself from the sizer when it is destroyed.


wxWindow::SetCursor

virtual void SetCursor(const wxCursor&cursor)

Sets the window's cursor. Notice that the window cursor also sets it for the children of the window implicitly.

The cursor may be wxNullCursor in which case the window cursor will be reset back to default.

Parameters

cursor

See also

::wxSetCursor, wxCursor


wxWindow::SetDropTarget

void SetDropTarget(wxDropTarget* target)

Associates a drop target with this window.

If the window already has a drop target, it is deleted.

See also

wxWindow::GetDropTarget, Drag and drop overview


wxWindow::SetInitialBestSize

virtual void SetInitialBestSize(const wxSize& size)

Sets the initial window size if none is given (i.e. at least one of the components of the size passed to ctor/Create() is wxDefaultCoord).


wxWindow::SetEventHandler

void SetEventHandler(wxEvtHandler* handler)

Sets the event handler for this window.

Parameters

handler

Remarks

An event handler is an object that is capable of processing the events sent to a window. By default, the window is its own event handler, but an application may wish to substitute another, for example to allow central implementation of event-handling for a variety of different window classes.

It is usually better to use wxWindow::PushEventHandler since this sets up a chain of event handlers, where an event not handled by one event handler is handed to the next one in the chain.

See also

wxWindow::GetEventHandler, wxWindow::PushEventHandler, wxWindow::PopEventHandler, wxEvtHandler::ProcessEvent, wxEvtHandler


wxWindow::SetExtraStyle

void SetExtraStyle(long exStyle)

Sets the extra style bits for the window. The currently defined extra style bits are:

wxWS_EX_VALIDATE_RECURSIVELY TransferDataTo/FromWindow() and Validate() methods will recursively descend into all children of the window if it has this style flag set.
wxWS_EX_BLOCK_EVENTS Normally, the command events are propagated upwards to the window parent recursively until a handler for them is found. Using this style allows to prevent them from being propagated beyond this window. Notice that wxDialog has this style on by default for the reasons explained in the event processing overview.
wxWS_EX_TRANSIENT This can be used to prevent a window from being used as an implicit parent for the dialogs which were created without a parent. It is useful for the windows which can disappear at any moment as creating children of such windows results in fatal problems.
wxWS_EX_CONTEXTHELP Under Windows, puts a query button on the caption. When pressed, Windows will go into a context-sensitive help mode and wxWidgets will send a wxEVT_HELP event if the user clicked on an application window. This style cannot be used together with wxMAXIMIZE_BOX or wxMINIMIZE_BOX, so these two styles are automatically turned of if this one is used.
wxWS_EX_PROCESS_IDLE This window should always process idle events, even if the mode set by wxIdleEvent::SetMode is wxIDLE_PROCESS_SPECIFIED.
wxWS_EX_PROCESS_UI_UPDATES This window should always process UI update events, even if the mode set by wxUpdateUIEvent::SetMode is wxUPDATE_UI_PROCESS_SPECIFIED.


wxWindow::SetFocus

virtual void SetFocus()

This sets the window to receive keyboard input.

See also

wxFocusEvent wxPanel::SetFocus wxPanel::SetFocusIgnoringChildren


wxWindow::SetFocusFromKbd

virtual void SetFocusFromKbd()

This function is called by wxWidgets keyboard navigation code when the user gives the focus to this window from keyboard (e.g. using TAB key). By default this method simply calls SetFocus but can be overridden to do something in addition to this in the derived classes.


wxWindow::SetFont

void SetFont(const wxFont& font)

Sets the font for this window. This function should not be called for the parent window if you don't want its font to be inherited by its children, use SetOwnFont instead in this case and see InheritAttributes for more explanations.

Please notice that the given font is not automatically used for wxPaintDC objects associated with this window, you need to call wxDC::SetFont() too. However this font is used by any standard controls for drawing their text as well as by wxWindow::GetTextExtent().

Parameters

font

See also

wxWindow::GetFont,
InheritAttributes


wxWindow::SetForegroundColour

virtual void SetForegroundColour(const wxColour& colour)

Sets the foreground colour of the window.

Please see InheritAttributes for explanation of the difference between this method and SetOwnForegroundColour.

Parameters

colour

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.

Using this function will disable attempts to use themes for this window, if the system supports them. Use with care since usually the themes represent the appearance chosen by the user to be used for all applications on the system.

See also

wxWindow::GetForegroundColour, wxWindow::SetBackgroundColour, wxWindow::GetBackgroundColour, wxWindow::ShouldInheritColours


wxWindow::SetHelpText

virtual void SetHelpText(const wxString& helpText)

Sets the help text to be used as context-sensitive help for this window.

Note that the text is actually stored by the current wxHelpProvider implementation, and not in the window object itself.

See also

GetHelpText, wxHelpProvider


wxWindow::SetId

void SetId(int id)

Sets the identifier of the window.

Remarks

Each window has an integer identifier. If the application has not provided one, an identifier will be generated. Normally, the identifier should be provided on creation and should not be modified subsequently.

See also

wxWindow::GetId, Window identifiers


wxWindow::SetLabel

virtual void SetLabel(const wxString& label)

Sets the window's label.

Parameters

label

See also

wxWindow::GetLabel


wxWindow::SetMaxSize

void SetMaxSize(const wxSize& size)

Sets the maximum size of the window, to indicate to the sizer layout mechanism that this is the maximum possible size.


wxWindow::SetMinSize

void SetMinSize(const wxSize& size)

Sets the minimum size of the window, to indicate to the sizer layout mechanism that this is the minimum required size. You may need to call this if you change the window size after construction and before adding to its parent sizer.


wxWindow::SetName

virtual void SetName(const wxString& name)

Sets the window's name.

Parameters

name

See also

wxWindow::GetName


wxWindow::SetOwnBackgroundColour

void SetOwnBackgroundColour(const wxColour& colour)

Sets the background colour of the window but prevents it from being inherited by the children of this window.

See also

SetBackgroundColour, InheritAttributes


wxWindow::SetOwnFont

void SetOwnFont(const wxFont& font)

Sets the font of the window but prevents it from being inherited by the children of this window.

See also

SetFont, InheritAttributes


wxWindow::SetOwnForegroundColour

void SetOwnForegroundColour(const wxColour& colour)

Sets the foreground colour of the window but prevents it from being inherited by the children of this window.

See also

SetForegroundColour, InheritAttributes


wxWindow::SetPalette

virtual void SetPalette(wxPalette* palette)

Obsolete - use wxDC::SetPalette instead.


wxWindow::SetScrollbar

virtual void SetScrollbar(int orientation, int position, int thumbSize, int range, bool refresh = true)

Sets the scrollbar properties of a built-in scrollbar.

Parameters

orientation

position

thumbSize

range

refresh

Remarks

Let's say you wish to display 50 lines of text, using the same font. The window is sized so that you can only see 16 lines at a time.

You would use:

  SetScrollbar(wxVERTICAL, 0, 16, 50);

Note that with the window at this size, the thumb position can never go above 50 minus 16, or 34.

You can determine how many lines are currently visible by dividing the current view size by the character height in pixels.

When defining your own scrollbar behaviour, you will always need to recalculate the scrollbar settings when the window size changes. You could therefore put your scrollbar calculations and SetScrollbar call into a function named AdjustScrollbars, which can be called initially and also from your wxSizeEvent handler function.

See also

Scrolling overview, wxScrollBar, wxScrolledWindow, wxScrollWinEvent


wxWindow::SetScrollPos

virtual void SetScrollPos(int orientation, int pos, bool refresh = true)

Sets the position of one of the built-in scrollbars.

Parameters

orientation

pos

refresh

Remarks

This function does not directly affect the contents of the window: it is up to the application to take note of scrollbar attributes and redraw contents accordingly.

See also

wxWindow::SetScrollbar, wxWindow::GetScrollPos, wxWindow::GetScrollThumb, wxScrollBar, wxScrolledWindow


wxWindow::SetSize

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

virtual void SetSize(const wxRect& rect)

Sets the size and position of the window in pixels.

virtual void SetSize(int width, int height)

virtual void SetSize(const wxSize& size)

Sets the size of the window in pixels.

Parameters

x

y

width

height

size

rect

sizeFlags

Remarks

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 wxDefaultCoord to indicate either that a default should be supplied by wxWidgets, or that the current value of the dimension should be used.

See also

wxWindow::Move

wxPython note: In place of a single overloaded method name, wxPython implements the following methods:


wxWindow::SetSizeHints

Use of this function for windows which are not toplevel windows (such as wxDialog or wxFrame) is discouraged. Please use SetMinSize and SetMaxSize instead.

See also

wxTopLevelWindow::SetSizeHints.


wxWindow::SetSizer

void SetSizer(wxSizer* sizer, bool deleteOld=true)

Sets the window to have the given layout sizer. 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 if the deleteOld parameter is true.

Note that this function will also call SetAutoLayout implicitly with true parameter if the sizer is non-NULL and false otherwise.

Parameters

sizer

deleteOld

Remarks

SetSizer now enables and disables Layout automatically, but prior to wxWidgets 2.3.3 the following applied:

You must call wxWindow::SetAutoLayout to tell a window to use the sizer automatically in OnSize; otherwise, you must override OnSize and call Layout() explicitly. When setting both a wxSizer and a wxLayoutConstraints, only the sizer will have effect.


wxWindow::SetSizerAndFit

void SetSizerAndFit(wxSizer* sizer, bool deleteOld=true)

The same as SetSizer, except it also sets the size hints for the window based on the sizer's minimum size.


wxWindow::SetThemeEnabled

virtual void SetThemeEnabled(bool enable)

This function tells a window if it should use the system's "theme" code to draw the windows' background instead if its own background drawing code. This does not always have any effect since the underlying platform obviously needs to support the notion of themes in user defined windows. One such platform is GTK+ where windows can have (very colourful) backgrounds defined by a user's selected theme.

Dialogs, notebook pages and the status bar have this flag set to true by default so that the default look and feel is simulated best.


wxWindow::SetToolTip

void SetToolTip(const wxString& tip)

void SetToolTip(wxToolTip* tip)

Attach a tooltip to the window.

See also: GetToolTip, wxToolTip


wxWindow::SetValidator

virtual void SetValidator(const wxValidator& validator)

Deletes the current validator (if any) and sets the window validator, having called wxValidator::Clone to create a new validator of this type.


wxWindow::SetVirtualSize

void SetVirtualSize(int width, int height)

void SetVirtualSize(const wxSize& size)

Sets the virtual size of the window in pixels.


wxWindow::SetVirtualSizeHints

virtual void SetVirtualSizeHints(int minW,int minH, int maxW=-1, int maxH=-1)

void SetVirtualSizeHints(const wxSize& minSize=wxDefaultSize, const wxSize& maxSize=wxDefaultSize)

Allows specification of minimum and maximum virtual window sizes. If a pair of values is not set (or set to -1), the default values will be used.

Parameters

minW

minH

maxW

maxH

minSize

maxSize

Remarks

If this function is called, the user will not be able to size the virtual area of the window outside the given bounds.


wxWindow::SetWindowStyle

void SetWindowStyle(long style)

Identical to SetWindowStyleFlag.


wxWindow::SetWindowStyleFlag

virtual void SetWindowStyleFlag(long style)

Sets the style of the window. Please note that some styles cannot be changed after the window creation and that Refresh() might need to be be called after changing the others for the change to take place immediately.

See Window styles for more information about flags.

See also

GetWindowStyleFlag


wxWindow::SetWindowVariant

void SetWindowVariant(wxWindowVariantvariant)

This function can be called under all platforms but only does anything under Mac OS X 10.3+ currently. Under this system, each of the standard control can exist in several sizes which correspond to the elements of wxWindowVariant enum:

enum wxWindowVariant
{
    wxWINDOW_VARIANT_NORMAL,        // Normal size
    wxWINDOW_VARIANT_SMALL,         // Smaller size (about 25 % smaller than normal )
    wxWINDOW_VARIANT_MINI,          // Mini size (about 33 % smaller than normal )
    wxWINDOW_VARIANT_LARGE,         // Large size (about 25 % larger than normal )
};
By default the controls use the normal size, of course, but this function can be used to change this.


wxWindow::ShouldInheritColours

virtual bool ShouldInheritColours()

Return true from here to allow the colours of this window to be changed by InheritAttributes, returning false forbids inheriting them from the parent window.

The base class version returns false, but this method is overridden in wxControl where it returns true.


wxWindow::Show

virtual bool Show(bool show = true)

Shows or hides the window. You may need to call Raise for a top level window if you want to bring it to top, although this is not needed if Show() is called immediately after the frame creation.

Parameters

show

Return value

true if the window has been shown or hidden or false if nothing was done because it already was in the requested state.

See also

wxWindow::IsShown, wxWindow::Hide, wxRadioBox::Show


wxWindow::Thaw

virtual void Thaw()

Reenables window updating after a previous call to Freeze. To really thaw the control, it must be called exactly the same number of times as Freeze.

See also

wxWindowUpdateLocker


wxWindow::ToggleWindowStyle

bool ToggleWindowStyle(int flag)

Turns the given flag on if it's currently turned off and vice versa. This function cannot be used if the value of the flag is 0 (which is often the case for default flags).

Also, please notice that not all styles can be changed after the control creation.

Return value

Returns true if the style was turned on by this function, false if it was switched off.

See also

wxWindow::SetWindowStyleFlag, wxWindow::HasFlag


wxWindow::TransferDataFromWindow

virtual bool TransferDataFromWindow()

Transfers values from child controls to data areas specified by their validators. Returns false if a transfer failed.

If the window has wxWS_EX_VALIDATE_RECURSIVELY extra style flag set, the method will also call TransferDataFromWindow() of all child windows.

See also

wxWindow::TransferDataToWindow, wxValidator, wxWindow::Validate


wxWindow::TransferDataToWindow

virtual bool TransferDataToWindow()

Transfers values to child controls from data areas specified by their validators.

If the window has wxWS_EX_VALIDATE_RECURSIVELY extra style flag set, the method will also call TransferDataToWindow() of all child windows.

Return value

Returns false if a transfer failed.

See also

wxWindow::TransferDataFromWindow, wxValidator, wxWindow::Validate


wxWindow::UnregisterHotKey

bool UnregisterHotKey(int hotkeyId)

Unregisters a system wide hotkey.

Parameters

hotkeyId

Return value

true if the hotkey was unregistered successfully, false if the id was invalid.

Remarks

This function is currently only implemented under MSW.

See also

wxWindow::RegisterHotKey


wxWindow::Update

virtual void Update()

Calling this method immediately repaints the invalidated area of the window and all of its children recursively while this would usually only happen when the flow of control returns to the event loop. Notice that this function doesn't invalidate any area of the window so nothing happens if nothing has been invalidated (i.e. marked as requiring a redraw). Use Refresh first if you want to immediately redraw the window unconditionally.


wxWindow::UpdateWindowUI

virtual void UpdateWindowUI(long flags = wxUPDATE_UI_NONE)

This function sends wxUpdateUIEvents to the window. The particular implementation depends on the window; for example a wxToolBar will send an update UI event for each toolbar button, and a wxFrame will send an update UI event for each menubar menu item. You can call this function from your application to ensure that your UI is up-to-date at this point (as far as your wxUpdateUIEvent handlers are concerned). This may be necessary if you have called wxUpdateUIEvent::SetMode or wxUpdateUIEvent::SetUpdateInterval to limit the overhead that wxWidgets incurs by sending update UI events in idle time.

flags should be a bitlist of one or more of the following values.

enum wxUpdateUI
{
    wxUPDATE_UI_NONE          = 0x0000, // No particular value
    wxUPDATE_UI_RECURSE       = 0x0001, // Call the function for descendants
    wxUPDATE_UI_FROMIDLE      = 0x0002  // Invoked from On(Internal)Idle
};
If you are calling this function from an OnInternalIdle or OnIdle function, make sure you pass the wxUPDATE_UI_FROMIDLE flag, since this tells the window to only update the UI elements that need to be updated in idle time. Some windows update their elements only when necessary, for example when a menu is about to be shown. The following is an example of how to call UpdateWindowUI from an idle function.

void MyWindow::OnInternalIdle()
{
    if (wxUpdateUIEvent::CanUpdate(this))
        UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
}
See also

wxUpdateUIEvent, wxWindow::DoUpdateWindowUI, wxWindow::OnInternalIdle


wxWindow::Validate

virtual bool Validate()

Validates the current values of the child controls using their validators.

If the window has wxWS_EX_VALIDATE_RECURSIVELY extra style flag set, the method will also call Validate() of all child windows.

Return value

Returns false if any of the validations failed.

See also

wxWindow::TransferDataFromWindow, wxWindow::TransferDataToWindow, wxValidator


wxWindow::WarpPointer

void WarpPointer(int x, int y)

Moves the pointer to the given position on the window.

NB: This function is not supported under Mac because Apple Human Interface Guidelines forbid moving the mouse cursor programmatically.

Parameters

x

y


wxWindow::WindowToClientSize

virtual wxSize WindowToClientSize(const wxSize& size)

Converts window size size to corresponding client area size. In other words, the returned value is what would GetClientSize return if this window had given window size. Components with wxDefaultCoord value are left unchanged.

Note that the conversion is not always exact, it assumes that non-client area doesn't change and so doesn't take into account things like menu bar (un)wrapping or (dis)appearance of the scrollbars.

This function is new since wxWidgets version 2.8.8

See also

wxWindow::ClientToWindowSize