Wx::Window
From WxPerl wiki
Wx::Window is the base class for all windows and represents any visible object
on screen. All controls, toplevel windows and so on are windows. Sizers and
device contexts are not windows, however, as they don't appear on screen
themselves. If a Wx::Window has child windows, all children of the window will
be deleted automatically by the destructor before the window itself is deleted.
This means that you don't have to worry about deleting them manually. Please
see the Window Deletion Overview for more information. Is the following
paragraph relevant to WxPerl? I don't think so. 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.
Contents
1 Inheritance 2 Styles 2.1 Extra Styles 3 Constructor 4 Methods 4.1 AddChild
4.2 CacheBestSize 4.3 CaptureMouse 4.4 Center 4.5 CenterOnParent 4.6
CenterOnScreen 4.7 Centre 4.8 CentreOnParent 4.9 CentreOnScreen 4.10
ClearBackground 4.11 ClientToScreen 4.12 ClientToScreenXY 4.13 ClientToWindowSize
4.14 Close 4.15 ConvertDialogToPixels 4.16 ConvertPixelsToDialog
4.17 Destroy 4.18DestroyChildren 4.19 Disable 4.20 DoGetBestSize 4.21
DoUpdateWindowUI 4.22 DragAcceptFiles 4.23 Enable 4.24 FindFocus 4.25
FindWindow 4.26 FindWindowById 4.27 FindWindowByLabel 4.28 FindWindowByName
4.29 Fit 4.30 FitInside 4.31 Freeze 4.32 GetAcceleratorTable 4.33 GetAccessible
4.34 GetAdjustedBestSize 4.35 GetBackgroundColour 4.36 GetBackgroundStyle 4.37
GetEffectiveMinSize 4.38 GetBestSize 4.39 GetCapture 4.40 GetCaret 4.41
GetCharHeight 4.42 GetCharWidth 4.43 GetChildren 4.44 GetClassDefaultAttributes
4.45 GetClientSize 4.46 GetConstraints 4.47 GetContainingSizer 4.48 GetCursor
4.49 GetDefaultAttributes 4.50 GetDropTarget 4.51 GetEventHandler 4.52
GetExtraStyle 4.53 GetFont 4.54 GetForegroundColour 4.55 GetGrandParent 4.56
GetHandle 4.57 GetHelpTextAtPoint 4.58 GetHelpText 4.59 GetId 4.60 GetLabel
4.61 GetMaxSize 4.62 GetMinSize 4.63 GetName
4.64 GetNextSibling 4.65 GetParent 4.66 GetPosition 4.67 GetPrevSibling 4.68
GetRect 4.69 GetScreenPosition 4.70 GetScreenRect 4.71 GetScrollPos 4.72
GetScrollRange 4.73 GetScrollThumb 4.74 GetSize 4.75 GetSizer 4.76
GetTextExtent 4.77 GetToolTip 4.78 GetUpdateRegion 4.79 GetValidator 4.80
GetVirtualSize 4.81 GetWindowBorderSize 4.82 GetWindowStyleFlag 4.83
GetWindowVariant 4.84 HasCapture 4.85 HasFlag 4.86 HasMultiplePages 4.87
HasScrollbar 4.88 HasTransparentBackground 4.89 Hide 4.90 InheritAttributes
4.91 InitDialog 4.92 InvalidateBestSize 4.93 IsDoubleBuffered 4.94 IsEnabled 4.95
IsExposed 4.96 IsFrozen 4.97 IsRetained 4.98 IsShown 4.99 IsShownOnScreen 4.100
IsTopLevel 4.101 Layout 4.102 LineDown 4.103 LineUp 4.104 Lower 4.105 MakeModal
4.106 Move 4.107 MoveAfterInTabOrder 4.108 MoveBeforeInTabOrder 4.109Navigate
4.110 OnInternalIdle
4.111 PageDown 4.112 PageUp 4.113 PopEventHandler 4.114 PopupMenu 4.115
PushEventHandler 4.116 Raise 4.117 Refresh 4.118 RefreshRect 4.119
RegisterHotKey 4.120 ReleaseMouse 4.121 RemoveChild 4.122 RemoveEventHandler
4.123 Reparent 4.124 ScreenToClient 4.125 ScrollLines 4.126 ScrollPages 4.127
ScrollWindow 4.128 SetAcceleratorTable 4.129 SetAccessible 4.130 SetAutoLayout
4.131 SetBackgroundColour 4.132 SetBackgroundStyle 4.133 SetInitialSize 4.134
SetCaret 4.135 SetClientSize 4.136 SetConstraints 4.137 SetContainingSizer
4.138 SetCursor 4.139 SetDropTarget 4.140 SetInitialBestSize 4.141
SetEventHandler 4.142 SetExtraStyle 4.143 SetFocus 4.144 SetFocusFromKbd 4.145
SetFont 4.146 SetForegroundColour 4.147 SetHelpText 4.148 SetId 4.149 SetLabel
4.150 SetMaxSize 4.151 SetMinSize 4.152 SetName 4.153 SetOwnBackgroundColour
4.154 SetOwnFont 4.155 SetOwnForegroundColour 4.156 SetPalette 4.157
SetScrollbar
4.158 SetScrollPos 4.159 SetSize 4.160 SetSizeHints 4.161 SetSizer 4.162
SetSizerAndFit 4.163 SetThemeEnabled 4.164 SetToolTip 4.165 SetValidator 4.166
SetVirtualSize 4.167 SetVirtualSizeHints 4.168 SetWindowStyle 4.169
SetWindowStyleFlag 4.170 SetWindowVariant 4.171 ShouldInheritColours 4.172 Show
4.173 Thaw 4.174 ToggleWindowStyle 4.175 TransferDataFromWindow 4.176
TransferDataToWindow 4.177 UnregisterHotKey 4.178 Update 4.179 UpdateWindowUI
4.180 Validate 4.181 WarpPointer 4.182 WindowToClientSize
Inheritance
Wx::Window derives from Wx::EvtHandler and Wx::Object.
Styles
In theory, any of the following styles can be applied to any window, but a
given style may not make sense for a particular window class orwindowing
platform. These symbols are all exported by the Wx module. All may be exported
individually, or via the :everything export tag, or via the :window export tag
(except wxTAB_TRAVERSAL, which is not exported via the :window tag). These
styles may be combined by using the bitwise-or (|) operator. wxBORDER_SIMPLE
wxBORDER_DOUBLE Displays a thin border around the window. wxSIMPLE_BORDER is
the old name for this style. Displays a double border. wxDOUBLE_BORDER is the
old name for this style. Windows and Mac only.
wxBORDER_SUNKEN wxBORDER_RAISED
Displays a sunken border. wxSUNKEN_BORDER is the old name for this style.
Displays a raised border. wxRAISED_BORDER is the old name for this style.
Displays a border suitable for a static control. wxSTATIC_BORDER is the old
name for this style. Windows only. 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. Displays no border,
overriding the default border style for the window. wxNO_BORDER is the old name
for this style. The window is transparent, that is, it will not receive paint
events. Microsoft Windows only. Use this to enable tab traversal for non-dialog
windows. 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 responseto the key events for Tab and Shift-Tab.
wxBORDER_STATIC
wxBORDER_THEME
wxBORDER_NONE wxTRANSPARENT_WINDOW wxTAB_TRAVERSAL
wxWANTS_CHARS
On Microsoft Windows, this style used to disable repainting the window
completely when its size is changed. Since this wxNO_FULL_REPAINT_ON_RESIZE
behaviour is now the default, the style is now obsolete and no longer has an
effect. wxVSCROLL wxHSCROLL Use this style to enable a vertical scrollbar. Use
this style to enable a horizontal scrollbar. 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 Microsoft Windows, GTK, and
Wx::Universal it does nothing on other platforms. Use this style to eliminate
flicker caused by the background being repainted, then children being painted
over them. Microsoft Windows only. Use this style to force a complete redraw of
the window whenever it is resized, instead of redrawing just the part of the
wxALWAYS_SHOW_SB
wxCLIP_CHILDREN
wxFULL_REPAINT_ON_RESIZE
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 Microsoft Windows only; full repainting is always done on other
platforms.
Extra Styles
The following are 'extra' styles, which can be set using
SetExtraStyle. By default, Validate/TransferDataTo/FromWindow only work on
direct children of the window (compatiblewxWS_EX_VALIDATE_RECURSIVELY
behaviour). Set this flag to make them recursively descend into all subwindows.
Wx::CommandEvents and objects of derived classes thereof are forwarded to the
parent window (and its parent, etc., 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. 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. This window should
always process idle events, even if the mode set by Wx::IdleEvent::SetMode is
wxIDLE_PROCESS_SPECIFIED. This window should always process UI update events,
even if the mode set by Wx::UpdateUIEvent::SetMode is wxUPDATE_UI_PROCESS_SPECIFIED.
wxWS_EX_BLOCK_EVENTS
wxWS_EX_TRANSIENT
wxWS_EX_PROCESS_IDLE
wxWS_EX_PROCESS_UI_UPDATES
Constructor
$win = Wx::Window->new($parent, $id, $pos, $size, $style, $name);
Constructs a window, which can be a child of a frame, dialog or any other non-control
window. As this is generally used as a base class, you will almost never
construct a Wx::Window object directly, but instead use a control-specific
child class. Param $parent Reference to a parent window. Description
$id $pos
Window identifier, integer. If -1, will automatically create an identifier.
Window position. Reference to a two-position array containing an [x, y] pair.
The special value [1, -1] indicates that wxWidgets should generate a
defaultposition for the window. If using the Wx::Window class directly, you
should supply an actual position. Window size. Reference to a two-position
array containing a [width, height] pair. The special value [-1, -1] indicates
that wxWidgets should generate a default size for the window. If no suitable
size can be determined, the window will be sized to 20x20 pixels so that the
window is visible but obviously not correctly sized. Window style. See Styles,
above. Window name. This parameter is used to associate a name with the window,
which allows certain windowing systems to search for the window by name, and
allows X resources values to be applied to the window by name.
$size
$style $name
Methods
AddChild
$win->AddChild($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. Param Description
$child The child window to add, a Wx::Window-derived object.
CacheBestSize
$win->CacheBestSize($size);
Sets the cached best size value. Note: Is this relevant to WxPerl?
CaptureMouse
$win->CaptureMouse();
Directs all mouse input to this window. Call 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 receivesthe 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 ReleaseMouse
Wx::MouseCaptureLostEvent
Center
$win->Center($direction);
A synonym for Centre.
CenterOnParent
$win->CenterOnParent($direction);
A synonym for CentreOnParent.
CenterOnScreen
$win->CenterOnScreen($direction);
A synonym for CentreOnScreen.
Centre
$win->Centre($direction);
Centres the window. Param Description
Specifies the direction for the centering. May be wxHORIZONTAL, wxVERTICAL or
$direction wxBOTH (default: wxBoth). It may also include wxCENTRE_ON_SCREEN
flag if you want to center the window on the entire screen and not on its
parent window. These wx* symbols are exported by Wx. The symbol
wxCENTER_ON_SCREEN is available as a synonym for wxCENTER_ON_SCREEN. 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.
CentreOnParent
$win->CentreOnParent($direction);
Centres the window on its parent. This is a more readable synonym for Centre.
$direction defaults to wxBoth. Param $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 Centre. See also CentreOnScreen Description Specifies
the direction for the centering. May bewxHORIZONTAL, wxVERTICAL or (the
default) wxBOTH.
CentreOnScreen
$win->CentreOnScreen($direction);
Centres the window on screen. This only works for top level windows -
otherwise, the window will still be centered on its parent. Param $direction
See also CentreOnParent Description Specifies the direction for the centering.
May be wxHORIZONTAL, wxVERTICAL or (the default) wxBOTH.
ClearBackground
$win->ClearBackground();
Clears the window by filling it with the current background colour. Does not
cause an erase background event to be generated.
ClientToScreen
$point = $win->ClientToScreen($point)
Converts to screen coordinates from coordinates relative to this window. Param
Description
$point The client screen position, a Wx::Point object or an arrayref of [x, y]
coordinates.
ClientToScreenXY
($x, $y) = $win->ClientToScreenXY($x, $y);
Converts to screen coordinates from coordinates relative to this window. Param
$x $y Description An integer value for the x coordinate. Pass the client
coordinate in, and a screen coordinate will be passed out. An integer value for
the y coordinate. Pass the client coordinate in, and a screen coordinate will
be passed out.
ClientToWindowSize
$size = $win->ClientToWindowSize($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 WindowToClientSize
Close
$bool = $win->Close($force);
Tells the window to close. This function simply generates a Wx::CloseEvent
whose handler usually tries to close the window. It doesn't close the window
itself, however. Param $force Remarks 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 (Wx::Frame and
Wx::Dialog classes) as the others are not supposed to have any special
OnClose() logic.
Close
Description If false, the window's close handler should be allowed to veto the
destruction of this window. If true, it cannot. Optional; defaults to false.
The close handler should check whether the window is being deleted forcibly,
using Wx::CloseEvent::CanVeto, in which case it should destroy the window using
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 Wx::Dialog::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 Destroy instead. See also Window
deletion overview, Destroy, Wx::CloseEvent
ConvertDialogToPixels
$point = $win->ConvertDialogToPixels($point); $size =
$win->ConvertDialogToPixels($size);
Converts a point or size from dialog unitsto 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. Note that the
following methods are implemented as well:
$point = $win->ConvertDialogPointToPixels($point); $size =
$win->ConvertDialogSizeToPixels($size);
# Accepts and returns a Wx::Point # Accepts and returns a Wx::Size
See also ConvertPixelsToDialog
ConvertPixelsToDialog
$point = $win->ConvertPixelsToDialog($point); $size =
$win->ConvertPixelsToDialog($size);
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. Note that the following methods are
implemented as well:
$point = $win->ConvertDialogPointToPixels($point); $size =
$win->ConvertDialogSizeToPixels($size); # Accepts and returns a wxPoint #
Accepts and returns a wxSize
See also ConvertDialogToPixels
Destroy
$bool $win->Destroy();
Destroys the window safely. 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 windowhas either been successfully deleted, or it has been added to the
list of windows pending real deletion.
DestroyChildren
$win->DestroyChildren();
Destroys all children of a window. Called automatically by the destructor.
Disable
$bool = $win->Disable();
Disables the window, same as Enable(0). Return value Returns a true value if
the window has been disabled, a false value if it had been already disabled
before the call to this function.
DoGetBestSize
$size = $win->DoGetBestSize();
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().
DoUpdateWindowUI
$win->DoUpdateWindowUI($event);
Param
Description
$event The update event that was just processed, a Wx::UpdateUIEvent object.
Does the window-specific updating after processing the update event. This
function is called by UpdateWindowUI in order to check return values in the
update event and act appropriately. For example, to allow frame and dialog
title updating, wxWidgets implements this function approximatey as follows:
# do the window-specific processing after processing the update event sub
Wx::TopLevelWindowBase::DoUpdateWindowUI }
DragAcceptFiles
$win->DragAcceptFiles($accept);
Enables or disables eligibility for drop file events (OnDropFiles). Param
$accept Remarks Windows-only until version 2.8.9; available on all
platformssince 2.8.10. Cannot be used together with SetDropTarget on
non-Windows platforms. Description Boolean. If true, the window is eligible for
drop file events. If false, the window will not accept drop file events.
Enable
$bool = $win->Enable($enable);
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. Param Description
$enable Boolean. If true, enables the window for input. If false, disables the
window. 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 IsEnabled, Disable, wxRadioBox::Enable.
FindFocus
$win = Wx::Window::FindFocus();
Finds the window or control which currently has the keyboard focus. Remarks
Note that this is a class function, so it can be called without needing a
Wx::Window object reference. See also SetFocus
FindWindow
$child = $win->FindWindow($id);
Find a child of this window, by its numeric identifier.
$child = $win->FindWindow($name);
Find a child of this window, by its name. Note that this method will not work
properly if the window name you are looking for is numeric (consists of all
digits), because WxPerl will search by identifier. See FindWindowByID and
FindWindowByName to disambiguate these..
FindWindowById
$win = Wx::Window::FindWindowById($id, $parent);
Find the first window with the given id. If $parent is undef or omitted, the
search will start from all top-level frames and dialog boxes; otherwise, the
search will be limited to the givenwindow hierarchy. The search is recursive in
both cases. See also FindWindow
FindWindowByLabel
$win = Wx::Window::FindWindowByLabel($label, $parent);
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 undef or omitted, the search
will start from all top-level frames and dialog boxes; otherwise, the search
will be limited to the given window hierarchy. The search is recursive in both
cases. See also FindWindow
FindWindowByName
$win = Wx::Window::FindWindowByName($name, $parent);
Find the first window with the given name. If $parent is undef or omitted, the
search will start from all top-level frames and dialog boxes; otherwise, 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
Fit
$win->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
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
$win->SetClientSize($child->GetSize());
instead of calling Fit.
FitInside
$win->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 similarlywon't do anything if there are no subwindows.
Freeze
$win->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 Wx::TextCtrl
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
Wx::WindowUpdateLocker
GetAcceleratorTable
$atable = $win->GetAcceleratorTable();
Gets the accelerator table for this window. See Wx::AcceleratorTable.
GetAccessible
$acc = $win->GetAccessible();
Returns the accessible object for this window, if any. See also Wx::Accessible.
GetAdjustedBestSize
$size = $win->GetAdjustedBestSize();
This method is deprecated; use GetEffectiveMinSize instead.
GetBackgroundColour
$color = $win->GetBackgroundColour();
Returns the background colour of the window. See also SetBackgroundColour,
SetForegroundColour, GetForegroundColour
GetBackgroundStyle
$style = $win->GetBackgroundStyle();
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. Currentlythe style has no effect on other platforms. See
also SetBackgroundColour, GetForegroundColour, SetBackgroundStyle
GetEffectiveMinSize
$size = $win->GetEffectiveMinSize();
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
GetBestSize, SetInitialSize
GetBestSize
$size = $win->GetBestSize();
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
Wx::Panel), the size returned by this function will be the same as the size the
window would have had after calling Fit.
GetCapture
$cap_win = $win->GetCapture();
Returns the currently captured window. See also HasCapture, CaptureMouse,
ReleaseMouse, Wx::MouseCaptureLostEvent Wx::MouseCaptureChangedEvent
GetCaret
$caret = $win->GetCaret();
Returns the caret associated with the window.
GetCharHeight
$int = $win->GetCharHeight();
Returns the character height for this window.
GetCharWidth
$int = $win->GetCharWidth();
Returns the average character width for this window.
GetChildren
@list = $win->GetChildren();
Returns a list of the window's children — its child windows.
GetClassDefaultAttributes
$attr = Wx::Window::GetClassDefaultAttributes($variant);
Param
Description
$variant Mac only. See text below. Defaults to wxWINDOW_VARIANT_NORMAL. Returns
the default font and colours which are used by the control. This is useful if
you want to usethe 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 SetWindowVariant for more about this. This
static method is overridden in many derived classes. So calling, for example,
Wx::Button::GetClassDefaultAttributes() will typically return the values
appropriate for a button which will be normally different from those returned
by, say, Wx::ListCtrl::GetClassDefaultAttributes(). Mac Only: The $variant
parameter is a Wx::VisualAttributes structure, which 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
GetClientSize
($width, $height) = $win->GetClientSize(); $size = $win->GetClientSize();
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. Param Description
$width Receives the client width in pixels. $height Receives the client height
in pixels. See also
GetSize, GetVirtualSize
GetConstraints
$wxLayoutConstraints = $win->GetConstraints();
Returns a pointer to the window's layout constraints, or NULL if there are
none.GetContainingSizer
$size = $win->GetContainingSizer();
Return the sizer that this window is a member of, if any, otherwise undef.
GetCursor
$cursor = $win->GetCursor();
Return the cursor (a Wx::Cursor object) associated with this window. See also
SetCursor
GetDefaultAttributes
$attr = $win->GetDefaultAttributes();
Currently this is the same as calling
Wx::Windows::GetClassDefaultAttributes($self->GetWindowVariant())
One advantage of using this function as an object method, instead of as a class
method, is that the call is automatically dispatched to the correct class (as
usual with overloaded 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.
GetDropTarget
$target = $win->GetDropTarget();
Returns the associated drop target (which may be undef). See also
SetDropTarget, Drag and drop overview
GetEventHandler
$handler = $win->GetEventHandler();
Returns the event handler for this window. By default, the window is its own
event handler. See also SetEventHandler, PushEventHandler, PopEventHandler,
Wx::EvtHandler::ProcessEvent, Wx::EvtHandler
GetExtraStyle
$int = $win->GetExtraStyle();
Returns the extra style bits for the window.
GetFont
$font = $win->GetFont();Returns the font for this window. See also SetFont
GetForegroundColour
$color = $win->GetForegroundColour();
Returns the foreground colour of the window. Remarks The interpretation of
foreground colour varies according to the window class; it may be the text
color or other color, or it may not be used at all. See also
SetForegroundColour, SetBackgroundColour, GetBackgroundColour
GetGrandParent
$grand_win = $win->GetGrandParent();
Returns the grandparent of a window, or undef if there isn't one.
GetHandle
$int = $win->GetHandle();
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. This method will always return an integer in
WxPerl.
GetHelpTextAtPoint
$string = $win->GetHelpTextAtPoint($point, $origin);
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. Param $point Description
Coordinates of the mouse at the moment of help event emission.
$origin Help event origin, see also Wx::HelpEvent::GetOrigin. This function is
new since wxWidgets version 2.7.0
GetHelpText
$string = $win->GetHelpText();
Gets the help text to be used as context-sensitive help for this window. Note
that the text is actually stored by the current Wx::HelpProvider
implementation, and not in the window object itself. See also SetHelpText,
GetHelpTextAtPoint, Wx::HelpProvider
GetId
$int = $win->GetId();
Returns the identifier of the window. Remarks Eachwindow 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 SetId,
Window identifiers
GetLabel
$string = $win->GetLabel();
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.
GetMaxSize
$size = $win->GetMaxSize();
Returns the maximum size of the window, an indication to the sizer layout
mechanism that this is the maximum possible size. The returned value is a
Wx::Sizer object.
GetMinSize
$size = $win->GetMinSize();
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. The returned value is a Wx::Sizer object.
GetName
$string = $win->GetName();
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 SetName. See also SetName
GetNextSibling
$sib = $win->GetNextSibling();
Returns the next window after this one among the parent children or undef if
this window is the last child. This function is new since wxWidgets version
2.8.8 See also GetPrevSiblingGetParent
$parent = $win->GetParent();
Returns the parent of the window, or undef if there is no parent.
GetPosition
$point = $win->GetPosition(); ($x, $y) = $win->GetPositionXY();
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. See also GetScreenPosition
GetPrevSibling
$sib = $win->GetPrevSibling();
Returns the previous window before this one among the parent children or undef
if this window is the first child. This function is new since wxWidgets version
2.8.8 See also GetNextSibling
GetRect
$rect = $win->GetRect();
Returns the size and position of the window as a Wx::Rect object. See also
GetScreenRect
GetScreenPosition
$pos = $win->GetScreenPosition(); ($x, $y) = $win->GetScreenPositionXY();
Returns the window position in screen coordinates, whether the window is a
child window or a top level one. Note: Is this implemented in WxPerl? See also
GetPosition
GetScreenRect
$rect = $win->GetScreenRect();
Returns the size and position of the window on the screen as a Wx::Rect object.
See also GetRect
GetScrollPos
$int = $win->GetScrollPos($orientation);
Returns the built-in scrollbar position. See also SetScrollbar
GetScrollRange
$int = $win->GetScrollRange($orientation);
Returns the built-in scrollbar range. See also SetScrollbar
GetScrollThumb
$int = $win->GetScrollThumb($orientation);
Returns the built-in scrollbar thumb size. See also SetScrollbar
GetSize
$size = $win->GetSize(); ($w, $h) = $win->GetSizeWH();
This gets the size of the entire window in pixels, includingtitle bar, border,
scrollbars, etc. See also GetClientSize, GetVirtualSize
GetSizer
$size = $win->GetSizer();
Return the sizer associated with the window by a previous call to SetSizer, or
undef if that hasn't been called.
GetTextExtent
($x, $y, $descent, $externalLeading) = $win->GetTextExtent($string, $font);
Gets the dimensions of the string as it would be drawn on the window with the
currently selected font. Parameters Param Description
$string String whose extent is to be measured. $font Optional. Font to use
instead of the current window font. A Wx::Font object.
Return values
$x $y $descent
Width. Height. Descent.
$externalLeading External leading.
GetToolTip
$tool_tip = $win->GetToolTip();
Get the associated tooltip or undef if none.
GetUpdateRegion
$region = $win->GetUpdateRegion();
Returns the region specifying which parts of the window have been damaged.
Should only be called within a wxPaintEvent handler. See also Wx::Region,
Wx::RegionIterator
GetValidator
$validator = $win->GetValidator();
Returns the current validator for the window, or undef if there is none.
GetVirtualSize
$size = $win->GetVirtualSize();
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. Note: is this implemented in WxPerl? See also GetSize, GetClientSize
GetWindowBorderSize
$size = $win->GetWindowBorderSize();
Returns the size of the left/right and top/bottom borders of this window in x
and y components of the result respectively.
GetWindowStyleFlag
$int =$win->GetWindowStyleFlag();
Gets the window style that was passed to the constructor or Create method.
GetWindowStyle() is another name for the same function.
GetWindowVariant
$variant = $win->GetWindowVariant();
Returns the value previously passed to SetWindowVariant.
HasCapture
$bool = $win->HasCapture();
Returns true if this window has the current mouse capture. See also
CaptureMouse, ReleaseMouse, Wx::MouseCaptureLostEvent,
Wx::MouseCaptureChangedEvent
HasFlag
$bool = $win->HasFlag($flag);
Returns true if the window has the given flag bit set. Note: Is this
implemented in WxPerl?
HasMultiplePages
$bool = $win->HasMultiplePages();
Returns true if the window has multiple pages. This is only meaningful when
overridden by a child class. All standard classes with multiple pages such as
Wx::Notebook, Wx::Listbook and Wx::Treebook override it to return true;
user-defined classes with similar behaviour should do it as well to allow the
library to handle such windows appropriately.
HasScrollbar
$bool = $win->HasScrollbar($orient);
Returns true if this window has a scroll bar for this orientation. Param
Description
$orient Orientation to check, either wxHORIZONTAL or wxVERTICAL.
HasTransparentBackground
$bool = $win->HasTransparentBackground();
Returns true if this window background is transparent (as, for example, for
Wx::StaticText) 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.
Hide
$bool = $win->Hide();Equivalent to calling Show(false).
InheritAttributes
$win->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 changed
(that is, using SetFont and not SetOwnFont), 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 colors will not be changed; 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.
InitDialog
$win->InitDialog();
Sends an wxEVT_INIT_DIALOG event, whose handler usually transfers data to the
dialog via validators.
InvalidateBestSize
$win->InvalidateBestSize();
Resets the cached best size value so it will be recalculated the next time it
is needed.
IsDoubleBuffered
$bool =$win->IsDoubleBuffered();
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 Wx::BufferedDC
IsEnabled
$bool = $win->IsEnabled();
Returns true if the window is enabled for input, false otherwise. See also
Enable
IsExposed
$bool $bool $bool $bool = = = = $win->IsExposed($x, $y); $win->IsExposed($point);
$win->IsExposed($x, $y, $w, $h); $win->IsExposed($rect);
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.
IsFrozen
$bool = $win->IsFrozen();
Returns true if the window is currently frozen by a call to Freeze. See also
Thaw
IsRetained
$bool = $win->IsRetained();
[X Windows only] Returns true if the window is retained, false otherwise.
IsShown
$bool = $win->IsShown();
Returns true if the window is shown, false if it has been hidden. See also
IsShownOnScreen
IsShownOnScreen
$bool = $win->IsShownOnScreen();
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
IsShown
IsTopLevel
$bool = $win->IsTopLevel();
Returns true if the given window is a top-level one. Currently all frames and
dialogs are considered to be toplevel windows (even if they have a parent
window).
Layout
$win->Layout();
Invokes the constraint-based layout algorithm or the sizer-based algorithm for
this window. SeeSetAutoLayout:. When auto layout is on, this function gets
called automatically when the window is resized.
LineDown
$win->LineDown;
This is just a wrapper for ScrollLines(1).
LineUp
$win->LineUp;
This is just a wrapper for ScrollLines(-1).
Lower
$win->Lower();
Lowers the window to the bottom of the window hierarchy (z-order). See also
Raise
MakeModal
$win->MakeModal($flag);
Disables all other windows in the application so that the user can only
interact with this window. Param $flag Description If true, this call disables
all other windows in the application so that the user can only interact with this
window. If false, the effect is reversed.
Move
$win->Move($x, $y); $win->Move($point);
Moves the window to the given position. Param Description
$x $y $pt Remarks
Required x position. Required y position. wxPoint object representing the
position.
Implementations of SetSize can also implicitly implement the Move function,
which is defined in the base wxWindow class as the call:
$self->SetSize($x, $y, wxDefaultCoord, wxDefaultCoord, wxSIZE_USE_EXISTING);
See also SetSize
MoveAfterInTabOrder
$win->MoveAfterInTabOrder($control);
Moves this window in the tab navigation order after the specified control. 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. Param Description
$control A sibling of this window which should precede it in tab order, must
not be undef.
MoveBeforeInTabOrder$win->MoveBeforeInTabOrder($control);
Same as MoveAfterInTabOrder except that it inserts this window just before win
instead of putting it right after it.
Navigate
$bool = $win->Navigate($flags);
Does keyboard navigation from this window to another, by sending a
Wx::NavigationKeyEvent. Param Description
$flags A combination of Wx::NavigationKeyEvent::IsForward and
Wx::NavigationKeyEvent::WinChange.
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.
OnInternalIdle
$win->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.
PageDown
$win->PageDown;
This is just a wrapper for ScrollPages(1).
PageUp
$win->PageUp;
This is just a wrapper for ScrollPages(-1).
PopEventHandler
$handler = $win->PopEventHandler($deleteHandler);
Removes and returns the top-most event handler on the event handler stack.
Param Description
$deleteHandler If this is true, the handler will be deleted after it is
removed. The default value is false. See also SetEventHandler, GetEventHandler,
PushEventHandler, Wx::EvtHandler::ProcessEvent, Wx::EvtHandler
PopupMenu
$bool =$win->PopupMenu($menu, $pos); $bool = $win->PopupMenu($menu, $x,
$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. Param Description
$menu Menu to pop up. $pos $x $y See also Wx::Menu Remarks Just before the menu
is popped up, Wx::Menu::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. The position where the menu
will appear. X position for the menu to appear. Required y position for the
menu to appear.
PushEventHandler
$win->PushEventHandler($handler);
Pushes this event handler onto the event stack for the window. 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. 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
PopEventHandler to remove the event handler. See also SetEventHandler,
GetEventHandler, PopEventHandler,Wx::EvtHandler::ProcessEvent, Wx::EvtHandler
Raise
$win->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
Refresh
$win->Refresh($eraseBackground, $rect);
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. Param
Description
$eraseBackground If true, the background will be erased. $rect See also
RefreshRect Optional. If passed, only the given rectangle will be treated as
needing an update.
RefreshRect
$win->RefreshRect($rect, $eraseBackground);
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 Wx::Rect object as argument like this
RefreshRect(Wx::Rect->new($x, $y, $w, $h)).
RegisterHotKey
$bool = $win->RegisterHotKey($hotkeyId, $modifiers, $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. Param $hotkeyId
Description Numeric identifier of the hotkey. For applications this must be
between 0 and 0xBFFF. If this function is called from a shared DLL, it must be
a system wide unique identifierbetween 0xC000 and 0xFFFF. This is a Microsoft
Windows- specific detail. A bitwise combination of wxMOD_SHIFT, wxMOD_CONTROL,
wxMOD_ALT or
$modifiers
wxMOD_WIN specifying the modifier keys that have to be pressed along with the
key.
$virtualKeyCode The virtual key code of the hotkey. 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($self, $hotkeyId, &func) in the event table to capture the
event. This function is currently only implemented under Microsoft Windows. It
is used in the Windows CE port for detecting hardware button presses. See also
UnregisterHotKey
ReleaseMouse
$win->ReleaseMouse();
Releases mouse input captured with CaptureMouse. See also CaptureMouse,
HasCapture, ReleaseMouse, Wx::MouseCaptureLostEvent
Wx::MouseCaptureChangedEvent
RemoveChild
$win->RemoveChild($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.
RemoveEventHandler
$bool = $win->RemoveEventHandler($handler);
Find the given handler in the windows event handler chain and remove (but not
delete) it from the chain. Param $handler Description The event handler to
remove, must be defined and must be present in this window's event handler
chain.
Return value Returns true if the handler was found and false otherwise. This
also results in an assert failure, so this function should only be called when
the handleris supposed to be there. See also PushEventHandler, PopEventHandler
Reparent
$bool = $win->Reparent($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.
ScreenToClient
($x, $y) = $win->ScreenToClient($x, $y); $c_point =
$win->ScreenToClient($s_point);
Converts from screen to client window coordinates. Param $x $y Description
Stores the screen x coordinate and receives the client x coordinate. Stores the
screen x coordinate and receives the client x coordinate.
$c_point The client position for the second form of the function. $s_point The
screen position for the second form of the function.
ScrollLines
$bool = $win->ScrollLines($lines);
Scrolls the window down by the given number of lines (or up, if $lines is
negative). 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 MS-Windows and for Wx::TextCtrl under wxGTK
(it also works for Wx::ScrolledWindow-derived classes under all platforms).
See also ScrollPages
ScrollPages
$bool = $win->ScrollPages($pages);
Scrolls the window down by the given number of pages (or up, if $pages is
negative). 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 MS-Windows and wxGTK. See also ScrollLines
ScrollWindow
$win->ScrollWindow($dx, $dy, $rect);
Physically scrolls the pixels in the window and move child windowsaccordingly.
Param $dx $dy $rect Remarks Note that you can often use Wx::ScrolledWindow
instead of using this function directly. Amount to scroll horizontally. Amount
to scroll vertically. Rectangle to scroll. If it is undef or omitted, the whole
window is scrolled (this is always the case under wxGTK which doesn't support
this parameter). Description
SetAcceleratorTable
$win->SetAcceleratorTable($accel);
Sets the accelerator table for this window. See Wx::AcceleratorTable.
SetAccessible
$win->SetAccessible($accessible);
Sets the accessible (a Wx::Accessible object) for this window. Any existing
accessible for this window will be deleted first, if not identical to
accessible.
SetAutoLayout
$win->SetAutoLayout($autoLayout);
Determines whether the 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 Wx::Panel and Wx::TopLevelWindow (and the
classes deriving from them). This method is called implicitly by SetSizer but
if you use SetConstraints you should call it manually; otherwise the window
layout won't be correctly updated when its size changes. Param $autoLayout See
also SetConstraints Description Set this to true if you wish the Layout
function to be called automatically when the window is resized.
SetBackgroundColour
$bool = $win->SetBackgroundColour($colour);
Sets the background colour of the window. Please see InheritAttributes for
explanation of the difference between this method and SetOwnBackgroundColour.
Param $colour Remarks The background colour is usually painted by the default
wxEraseEventevent 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 Refresh after calling this
function. Using this function will disable attempts to use themes for this
window, if the system supports them. Use with Description The colour to be used
as the background colour, pass wxNullColour to reset to the default colour.
wxNullColour is exported by Wx.
care since usually the themes represent the appearance chosen by the user to be
used for all applications on the system. See also GetBackgroundColour,
SetForegroundColour, GetForegroundColour, ClearBackground, Refresh,
Wx::EraseEvent
SetBackgroundStyle
$win->SetBackgroundStyle($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
SetBackgroundColour, GetForegroundColour, GetBackgroundStyle
SetInitialSize
$win->SetInitialSize($size);
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 theminimum 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 SetSize, GetBestSize, GetEffectiveMinSize
SetCaret
$win->SetCaret($caret);
Sets the caret associated with the window.
SetClientSize
$win->SetClientSize($width, $height); $win->SetClientSize($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 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. Param
Description
$width The required client area width. $height The required client area height.
$size The required client size.
SetConstraints
$win->SetConstraints($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. Param
$constraints Remarks You must call 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 Wx::LayoutConstraints and a
Wx::Sizer, only the sizer will have effect. Description The constraints to set,
a Wx::LayoutConstraint object. Pass undef to disassociate and delete the
window's constraints.
SetContainingSizer
$win->SetContainingSizer($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 canremove itself from the
sizer when it is destroyed.
SetCursor
$win->SetCursor($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.
See also SetCursor, Wx::Cursor
SetDropTarget
$win->SetDropTarget($target);
Associates a drag-and-drop target with this window. If the window already has a
drop target, it is deleted. See also GetDropTarget, Drag and drop overview
SetInitialBestSize
$win->SetInitialBestSize($size);
Sets the initial window size, if none was specified to the constructor or the
Create method.
SetEventHandler
$win->SetEventHandler($handler);
Sets the event handler for this window. Param Description
$handler A Wx::EvtHandler objet. Specifies the handler to be set. 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 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 GetEventHandler, PushEventHandler, PopEventHandler,
Wx::EvtHandler::ProcessEvent, Wx::EvtHandler
SetExtraStyle
$win->SetExtraStyle($exStyle);
Sets the extra style bits for the window. See [#Extra_Styles|Extra Styles] for
the currently defined extra style bits.
SetFocus
$win->SetFocus();This sets the window to receive keyboard input. See also
Wx::FocusEvent, Wx::Panel::SetFocus, Wx::Panel::SetFocusIgnoringChildren
SetFocusFromKbd
$win->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.
SetFont
$win->SetFont($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. See InheritAttributes for more explanations.
Please notice that the given font is not automatically used for Wx::PaintDC objects
associated with this window; you need to call Wx::DC::SetFont too. However this
font is used by any standard controls for drawing their text, as well as by
GetTextExtent. Param $font See also GetFont, InheritAttributes Description Font
to associate with this window. Pass wxNullFont to reset to the default font.
SetForegroundColour
$win->SetForegroundColour($colour);
Sets the foreground colour of the window. Please see InheritAttributes for
explanation of the difference between this method and SetOwnForegroundColour.
Param Description
$colour The colour to be used as the foreground colour; pass wxNullColour to
reset to the default colour. Remarks The interpretation of foreground colour
depends on 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 thiswindow, 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 GetForegroundColour, SetBackgroundColour,
GetBackgroundColour, ShouldInheritColours
SetHelpText
$win->SetHelpText($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, Wx::HelpProvider
SetId
$win->SetId($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 GetId, Window identifiers
SetLabel
$win->SetLabel($label);
Sets the window's label. See also GetLabel
SetMaxSize
$win->SetMaxSize($size);
Sets the maximum size of the window, to indicate to the sizer layout mechanism
that this is the maximum possible size.
SetMinSize
$win->SetMinSize($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.
SetName
$win->SetName($name);
Sets the window's name. See also GetName
SetOwnBackgroundColour
$win->SetOwnBackgroundColour($colour);
Sets the background colour of the window but prevents it from being inherited
by the children of this window. See also SetBackgroundColour,InheritAttributes
SetOwnFont
$win->SetOwnFont($font);
Sets the font of the window but prevents it from being inherited by the
children of this window. See also SetFont, InheritAttributes
SetOwnForegroundColour
$win->SetOwnForegroundColour($colour);
Sets the foreground colour of the window but prevents it from being inherited
by the children of this window. See also SetForegroundColour, InheritAttributes
SetPalette
$win->SetPalette($palette);
Obsolete — use Wx::DC::SetPalette instead.
SetScrollbar
$win->SetScrollbar($orientation, $position, $thumbSize, $range, $refresh);
Sets the scrollbar properties of a built-in scrollbar. Param $orientation
$position Description Determines the scrollbar whose page size is to be set.
May be wxHORIZONTAL or wxVERTICAL. The position of the scrollbar in scroll
units.
$thumbSize The size of the thumb, or visible portion of the scrollbar, in
scroll units. $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. The maximum position of the scrollbar. True to redraw the
scrollbar, false otherwise. (Optional; default true)
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 andSetScrollbar call into a function named
'AdjustScrollbars', which can be called initially and also from your
Wx::SizeEvent handler function. See also Scrolling overview, Wx::ScrollBar,
Wx::ScrolledWindow, Wx::ScrollWinEvent
SetScrollPos
$win->SetScrollPos($orientation, $pos, $refresh;
Sets the position of one of the built-in scrollbars. Param $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 SetScrollbar, GetScrollPos,
GetScrollThumb, Wx::ScrollBar, Wx::ScrolledWindow Description Determines the
scrollbar whose position is to be set. May be wxHORIZONTAL or wxVERTICAL.
Position in scroll units. true to redraw the scrollbar, false otherwise.
(Optional; default true).
SetSize
$win->SetSize($x, $y, $width, $height, $sizeFlags; $win->SetSize($rect);
Sets the size and position of the window in pixels.
$win->SetSize($width, $height); $win->SetSize($size);
Sets the size of the window in pixels. Param $x $y $width $height $size $rect
Description Required x position in pixels, or wxDefaultCoord to indicate that
the existing value should be used. Required y position in pixels, or
wxDefaultCoord to indicate that the existing value should be used. Required
width in pixels, or wxDefaultCoord to indicate that the existing value should
be used. Required height position in pixels, or wxDefaultCoord to indicate that
the existing value should be used. Wx::Size object for setting the size.
Wx::Rect object for setting the position and size.
$sizeFlags Indicates the interpretation of otherparameters. See below.
$sizeFlags is a bitwise-OR combination of any of the following flags:
wxSIZE_AUTO_WIDTH wxSIZE_AUTO_HEIGHT wxSIZE_AUTO wxSIZE_USE_EXISTING
wxSIZE_ALLOW_MINUS_ONE a wxDefaultCoord width value is taken to indicate a
wxWidgetssupplied default width. a wxDefaultCoord height value is taken to
indicate a wxWidgetssupplied default height. wxDefaultCoord size values are
taken to indicate a wxWidgetssupplied default size. This is the default.
existing dimensions should be used if wxDefaultCoord values are supplied. allow
negative dimensions (ie. value of wxDefaultCoord) to be interpreted as real
dimensions, not default values. normally, if the position and the size of the
window are already the same as the parameters of this function, nothing is
done. but with this flag a window resize may be forced even in this case
(supported in wx 2.6.2 and later and only implemented for MS Windows and
ignored elsewhere currently).
wxSIZE_FORCE
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 Move
SetSizeHints
Use of this function for windows which are not toplevel windows (such as
Wx::Dialog or Wx::Frame) is discouraged. Please use SetMinSize and SetMaxSize
instead. See also Wx::TopLevelWindow::SetSizeHints.
SetSizer
$win->SetSizer($sizer, $deleteOld);
Sets the window to have the givenlayout 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 omitted or true. Note that this function will also call
SetAutoLayout implicitly with true parameter if the sizer is defined; false
otherwise. Param $sizer $deleteOld Remarks SetSizer now enables and disables
Layout automatically, but prior to wxWidgets 2.3.3 the following applied: You
must call 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 Wx::Sizer and a Wx::LayoutConstraints, only the sizer will have
effect. Description The sizer to set. Pass undef to disassociate and
conditionally delete the window's sizer. See below. If true (the default), this
will delete any prexisting sizer. Pass false if you wish to handle deleting the
old sizer yourself.
SetSizerAndFit
$win->SetSizerAndFit($sizer, $deleteOld);
The same as SetSizer, except it also sets the size hints for the window based
on the sizer's minimum size.
SetThemeEnabled
$win->SetThemeEnabled($enable);
This function tells a window if it should use the system's 'theme'
code to draw the window's background instead of 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 trueby default so that the default look and feel is
simulated best.
SetToolTip
$win->SetToolTip($tip); $win->SetToolTip($tip);
Attach a tooltip to the window. See also GetToolTip, Wx::ToolTip
SetValidator
$win->SetValidator($validator);
Deletes the current validator (if any) and sets the window validator, having
called Wx::Validator::Clone to create a new validator of this type.
SetVirtualSize
$win->SetVirtualSize($width, $height); $win->SetVirtualSize($size);
Sets the virtual size of the window in pixels.
SetVirtualSizeHints
$win->SetVirtualSizeHints($minW, $minH, $maxW, $maxH); $win->SetVirtualSizeHints($minSize,
$maxSize);
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.
Param $minW $minH $maxW $maxH
Description Specifies the minimum width allowable. Specifies the minimum height
allowable. Specifies the maximum width allowable. Specifies the maximum height
allowable.
$minSize Minimum size. $maxSize Maximum size. Remarks If this function is
called, the user will not be able to size the virtual area of the window
outside the given bounds.
SetWindowStyle
$win->SetWindowStyle($style);
Identical to SetWindowStyleFlag.
SetWindowStyleFlag
$win->SetWindowStyleFlag($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 some other settings for the change to take place immediately. See
Window styles for more information about flags. See also GetWindowStyleFlag
SetWindowVariant$win->SetWindowVariant(wxWindowVariantvariant);
This function can be called under all platforms but currently only does
anything under Mac OS X 10.3+. Under this system, each of the standard control
can exist in several sizes which correspond to the elements of wxWindowVariant
enum:
enum wxWindowVariant ;
// // // //
Normal size Smaller size (about 25 % smaller than normal ) Mini size (about 33
% smaller than normal ) 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.
ShouldInheritColours
$bool = $win->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
Wx::Control where it returns true.
Show
$bool = $win->Show($show);
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. Param Description
$show If true displays the window. Otherwise, hides it. Return value True if
the window has been shown or hidden; false if nothing was done because it
already was in the requested state. See also IsShown, Hide, Wx::RadioBox::Show
Thaw
$win->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
Wx::WindowUpdateLocker
ToggleWindowStyle
$bool = $win->ToggleWindowStyle($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 SetWindowStyleFlag,
HasFlag
TransferDataFromWindow
$bool = $win->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 TransferDataToWindow,
Wx::Validator, Validate
TransferDataToWindow
$bool = $win->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
TransferDataFromWindow, Wx::Validator, Validate
UnregisterHotKey
$bool = $win->UnregisterHotKey($hotkeyId);
Unregisters a system wide hotkey. Param Description
$hotkeyId Numeric identifier of the hotkey. Must be the same id that was passed
to RegisterHotKey. Return value true if the hotkey was unregistered
successfully, false if the id was invalid. Remarks This function is currently
only implemented under MS Windows. See also RegisterHotKeyUpdate
$win->Update();
Calling this method immediately repaints the invalidated area of the window and
all of its children recursively. This would normally 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.
UpdateWindowUI
$win->UpdateWindowUI($flags);
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 Wx::UpdateUIEvent::SetMode or Wx::UpdateUIEvent::SetUpdateInterval to
limit the overhead that wxWidgets incurs by sending update UI events in idle
time. $flags should be a bitwise-OR of one or more of the following values.
Param wxUPDATE_UI_NONE Description No particular value.
wxUPDATE_UI_RECURSE
Call the function for descendants
wxUPDATE_UI_FROMIDLE 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 tobe shown. The
following is an example of how to call UpdateWindowUI from an idle function.
sub MyWindow::OnInternalIdle }
See also Wx::UpdateUIEvent, DoUpdateWindowUI, OnInternalIdle
Validate
$bool = $win->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 TransferDataFromWindow,
TransferDataToWindow, Wx::Validator
WarpPointer
$win->WarpPointer($x, $y);
Moves the pointer to the given position on the window. Note: This function is
not supported under Mac because Apple Human Interface Guidelines forbid moving
the mouse cursor programmatically. Param Description
$x $y
The new x position for the cursor. The new y position for the cursor.
WindowToClientSize
($w, $h) = $win->WindowToClientSize($size);
Converts window size size to corresponding client area size. In other words,
the returned value is what would GetClientSize would return if this window had
the given window size. 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 ClientToWindowSize Retrieved from
'https://wxperl.pvoice.org/w/index.php/Wx::Window' This page was last
modified on 24 November 2010, at 04:11.