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
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.
| wxSIMPLE_BORDER | Displays a thin border around the window. wxBORDER is the old name for this style. |
| wxDOUBLE_BORDER | Displays a double border. Windows and Mac only. |
| wxSUNKEN_BORDER | Displays a sunken border. |
| wxRAISED_BORDER | Displays a raised border. |
| wxSTATIC_BORDER | Displays a border suitable for a static control. Windows only. |
| wxNO_BORDER | Displays no border, overriding the default border style for the window. |
| 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 only implemented for wxMSW 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
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::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::FindWindowByName
wxWindow::FindWindowByLabel
wxWindow::Fit
wxWindow::FitInside
wxWindow::Freeze
wxWindow::GetAcceleratorTable
wxWindow::GetAccessible
wxWindow::GetAdjustedBestSize
wxWindow::GetBackgroundColour
wxWindow::GetBackgroundStyle
wxWindow::GetBestFittingSize
wxWindow::GetBestSize
wxWindow::GetCaret
wxWindow::GetCapture
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::GetHelpText
wxWindow::GetId
wxWindow::GetLabel
wxWindow::GetMaxSize
wxWindow::GetMinSize
wxWindow::GetName
wxWindow::GetParent
wxWindow::GetPosition
wxWindow::GetRect
wxWindow::GetScrollPos
wxWindow::GetScrollRange
wxWindow::GetScrollThumb
wxWindow::GetSize
wxWindow::GetSizer
wxWindow::GetTextExtent
wxWindow::GetTitle
wxWindow::GetToolTip
wxWindow::GetUpdateRegion
wxWindow::GetValidator
wxWindow::GetVirtualSize
wxWindow::GetWindowStyleFlag
wxWindow::GetWindowVariant
wxWindow::HasCapture
wxWindow::HasScrollbar
wxWindow::HasTransparentBackground
wxWindow::Hide
wxWindow::InheritAttributes
wxWindow::InitDialog
wxWindow::InvalidateBestSize
wxWindow::IsEnabled
wxWindow::IsExposed
wxWindow::IsRetained
wxWindow::IsShown
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::SetBestFittingSize
wxWindow::SetCaret
wxWindow::SetClientSize
wxWindow::SetContainingSizer
wxWindow::SetCursor
wxWindow::SetConstraints
wxWindow::SetInitialBestSize
wxWindow::SetMaxSize
wxWindow::SetMinSize
wxWindow::SetOwnBackgroundColour
wxWindow::SetOwnFont
wxWindow::SetOwnForegroundColour
wxWindow::SetDropTarget
wxWindow::SetEventHandler
wxWindow::SetExtraStyle
wxWindow::SetFocus
wxWindow::SetFocusFromKbd
wxWindow::SetFont
wxWindow::SetForegroundColour
wxWindow::SetHelpText
wxWindow::SetId
wxWindow::SetLabel
wxWindow::SetName
wxWindow::SetPalette
wxWindow::SetScrollbar
wxWindow::SetScrollPos
wxWindow::SetSize
wxWindow::SetSizeHints
wxWindow::SetSizer
wxWindow::SetSizerAndFit
wxWindow::SetTitle
wxWindow::SetThemeEnabled
wxWindow::SetToolTip
wxWindow::SetValidator
wxWindow::SetVirtualSize
wxWindow::SetVirtualSizeHints
wxWindow::SetWindowStyle
wxWindow::SetWindowStyleFlag
wxWindow::SetWindowVariant
wxWindow::ShouldInheritColours
wxWindow::Show
wxWindow::Thaw
wxWindow::TransferDataFromWindow
wxWindow::TransferDataToWindow
wxWindow::UnregisterHotKey
wxWindow::Update
wxWindow::UpdateWindowUI
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 wxWidgets can delete a window only when it is safe to do so, in idle time.
See also
Window deletion overview, 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.
Notice that this function is mostly internal to wxWidgets and shouldn't be called by the user code.
Parameters
child
void CacheBestSize(const wxSize& size) const
Sets the cached best size value.
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.
See also
void Center(int direction)
A synonym for Centre.
void CenterOnParent(int direction)
A synonym for CentreOnParent.
void CenterOnScreen(int direction)
A synonym for CentreOnScreen.
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
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
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
void ClearBackground()
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
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:
| ClientToScreen(point) | Accepts and returns a wxPoint |
| ClientToScreenXY(x, y) | Returns a 2-tuple, (x, y) |
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
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:
| 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 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:
| 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-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.
virtual void DestroyChildren()
Destroys all children of a window. Called automatically by the destructor.
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.
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().
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());
}
}
virtual void DragAcceptFiles(bool accept)
Enables or disables eligibility for drop file events (OnDropFiles).
Parameters
accept
Remarks
Windows only.
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
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) 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:
| FindWindowById(id) | Accepts an integer |
| FindWindowByName(name) | Accepts a string |
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
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
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
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.
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.
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 wxDT FACE="Arial, Lucida, Helvetica"> Accepts and returns a wxPoint
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
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:
| 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 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:
| 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-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.
virtual void DestroyChildren()
Destroys all children of a window. Called automatically by the destructor.
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.
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().
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());
}
}
virtual void DragAcceptFiles(bool accept)
Enables or disables eligibility for drop file events (OnDropFiles).
Parameters
accept
Remarks
Windows only.
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
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) 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:
| FindWindowById(id) | Accepts an integer |
| FindWindowByName(name) | Accepts a string |
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
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
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
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.
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.
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 wxDT FACE="Arial, Lucida, Helvetica"> Accepts and returns a wxPoint
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
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:
| 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 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:
| 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-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.
virtual void DestroyChildren()
Destroys all children of a window. Called automatically by the destructor.
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.
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().
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());
}
}
virtual void DragAcceptFiles(bool accept)
Enables or disables eligibility for drop file events (OnDropFiles).
Parameters
accept
Remarks
Windows only.
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
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) 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:
| FindWindowById(id) | Accepts an integer |
| FindWindowByName(name) | Accepts a string |
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
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
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
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.
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.
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 wxDT FACE="Arial, Lucida, Helvetica"> Accepts and returns a wxPoint
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
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:
| 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 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:
| 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-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.
virtual void DestroyChildren()
Destroys all children of a window. Called automatically by the destructor.
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.
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().
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());
}
}
virtual void DragAcceptFiles(bool accept)
Enables or disables eligibility for drop file events (OnDropFiles).
Parameters
accept
Remarks
Windows only.
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
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) 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:
| FindWindowById(id) | Accepts an integer |
| FindWindowByName(name) | Accepts a string |
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
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
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
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.
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.
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 wxDT FACE="Arial, Lucida, Helvetica"> Accepts and returns a wxPoint
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
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:
| 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 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:
| 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-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.
virtual void DestroyChildren()
Destroys all children of a window. Called automatically by the destructor.
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.
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().
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());
}
}
virtual void DragAcceptFiles(bool accept)
Enables or disables eligibility for drop file events (OnDropFiles).
Parameters
accept
Remarks
Windows only.
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
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) 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:
| FindWindowById(id) | Accepts an integer |
| FindWindowByName(name) | Accepts a string |
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
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
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
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.
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.
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 wxDT FACE="Arial, Lucida, Helvetica"> Accepts and returns a wxPoint
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
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:
| 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 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:
| 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-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.
virtual void DestroyChildren()
Destroys all children of a window. Called automatically by the destructor.
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.
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().
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());
}
}
virtual void DragAcceptFiles(bool accept)
Enables or disables eligibility for drop file events (OnDropFiles).
Parameters
accept
Remarks
Windows only.
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
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) 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:
| FindWindowById(id) | Accepts an integer |
| FindWindowByName(name) | Accepts a string |
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
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
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
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.
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.
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 wxDT FACE="Arial, Lucida, Helvetica"> Accepts and returns a wxPoint
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
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:
| 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 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:
| 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-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.
virtual void DestroyChildren()
Destroys all children of a window. Called automatically by the destructor.
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.
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().
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());
}
}
virtual void DragAcceptFiles(bool accept)
Enables or disables eligibility for drop file events (OnDropFiles).
Parameters
accept
Remarks
Windows only.
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
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) 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:
| FindWindowById(id) | Accepts an integer |
| FindWindowByName(name) | Accepts a string |
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
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
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
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.
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.
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 wxDT FACE="Arial, Lucida, Helvetica"> Accepts and returns a wxPoint
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
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:
| 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 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 i