Window 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 before the window itself is deleted which means that you
don’t have to worry about deleting them manually.
The following styles can apply to all windows, although they will not always make sense for a particular
window class or on all platforms.
SIMPLE_BORDER |
Displays a thin border around the window. BORDER is the old namefor this style. |
DOUBLE_BORDER |
Displays a double border. Windows and Mac only. |
SUNKEN_BORDER |
Displays a sunken border. |
RAISED_BORDER |
Displays a raised border. |
STATIC_BORDER |
Displays a border suitable for a static control. Windows only. |
NO_BORDER |
Displays no border, overriding the default border style for the window. |
TRANSPARENT_WINDOW |
The window is transparent, that is, it will not receive paintevents. Windows only. |
TAB_TRAVERSAL |
Use this to enable tab traversal for non-dialog windows. |
WANTS_CHARS |
Use this to indicate thatthe window wants to get all char/key events for all keys – even forkeys like TAB or ENTER which are usually used for dialog navigationand which wouldn’t be generated without this style. If you need touse this style in order to get the arrows or etc., but would still like to havenormal keyboard navigation take place, you should create and send aNavigationKeyEvent in response to the key events for Tab andShift-Tab. |
NO_FULL_REPAINT_ON_RESIZE |
On Windows, this style used to disable repaintingthe window completely when its size is changed. Since this behaviour is now the default, the style is now obsoleteand no longer has an effect. |
VSCROLL |
Use this style to enable a vertical scrollbar. |
HSCROLL |
Use this style to enable a horizontal scrollbar. |
ALWAYS_SHOW_SB |
If a window has scrollbars,disable them instead of hiding them when they are not needed (i.e. when thesize of the window is big enough to not require the scrollbars to navigate it).This style is currently implemented for MSW, GTK and Universal and doesnothing on the other platforms. |
CLIP_CHILDREN |
Use this style to eliminate flicker caused by the background beingrepainted, then children being painted over them. Windows only. |
FULL_REPAINT_ON_RESIZE |
Use this style to forcea complete redraw of the window whenever it is resized instead of redrawingjust the part of the window affected by resizing. Note that this was thebehaviour by default before 2.5.1 release and that if you experience redrawproblems 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 alwaysdone on other platforms. |
See also window styles overview.
The following are extra styles, set using Window#set_extra_style.
WS_EX_BLOCK_EVENTS |
CommandEvents and the objects of the derived classes are forwarded to theparent window and so on recursively by default. Using this flag for thegiven window allows to block this propagation at this window, i.e. preventthe events from being propagated further upwards. Dialogs have thisflag on by default. |
WS_EX_TRANSIENT |
Don’t use this window as an implicit parent for the other windows: this mustbe used with transient windows as otherwise there is the risk of creating adialog/frame with this window as a parent which would lead to a crash if theparent is destroyed before the child. |
WS_EX_PROCESS_IDLE |
This window should always process idle events, evenif the mode set by IdleEvent#set_mode is IDLE_PROCESS_SPECIFIED. |
WS_EX_PROCESS_UI_UPDATES |
This window should always process UI update events,even if the mode set by UpdateUIEvent#set_mode is UPDATE_UI_PROCESS_SPECIFIED. |
Constructs a window, which can be a child of a frame, dialog or any
other non-control window. All Windows apart from
top-level main windows must have another window as parent – this
argument cannot be nil
.
Any constructor for a Window can be passed a block to do further set-up
of the Window. If no argument is specifid for the block, it will be run
in the context of the newly created instance, with the Window as self
.
If an explicit parameter is passeed, the new Window will be passed as that
argument to this block. ie, either of the following is allowed:
or
Wx::Button.new(…) do | button | button.label = ‘Foo’ endWindow deletion overview, Window#destroy, CloseEvent
Finds the window or control which currently has the keyboard focus.
Note that this is a class method, so it can be called without needing a
Window receiver.
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 Widgets and shouldn’t be
called by the user code.
Raises the window to the top of the window hierarchy (z-order). In the
current version of wxRuby this works both for managed windows (Frames)
and child windows, although it is most often useful for Frames.
Sets the cached best size value.
Directs all mouse input to this window. Call Window#release_mouse to
release the capture.
Note that Widgets maintains the stack of windows having captured the mouse
and when the mouse is released the capture returns to the window which had had
captured it previously and it is only really released if there were no previous
window. In particular, this means that you must release the mouse as many times
as you capture it, unless the window receives
the MouseCaptureLostEvent event.
Any application which captures the mouse in the beginning of some operation
must handle MouseCaptureLostEvent
and cancel this operation when it receives the event. The event handler must
not recapture mouse.
Window#release_mouse
MouseCaptureLostEvent
A synonym for Centre.
A synonym for centre_on_parent.
Centres the window.
HORIZONTAL
, VERTICAL
or BOTH
. It may also include CENTRE_ON_SCREEN
flagThe flag CENTRE_FRAME
is obsolete and should not be used any longer
(it has no effect).
If the window is a top level one (i.e. doesn’t have a parent), it will be
centered relative to the screen anyhow.
Centres the window on its parent. This is a more readable synonym for
Centre.
HORIZONTAL
, VERTICAL
or BOTH
.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
Window#centre.
Clears the window by filling it with the current background colour. Does not
cause an erase background event to be generated.
Converts to screen coordinates from coordinates relative to this
window. The method may be passed either two integers, representing the
x and y coordinates, or a single Point object. If a
Point is passed in, one will be returned; if two integers are passed in,
two co-ordinates will be returned.
false
)
This function simply generates a CloseEvent whose
handler usually tries to close the window. It doesn’t close the window itself,
however.
false
if the window’s close handler should be able to vetotrue
if it cannot.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 (Frame and Dialog
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 CloseEvent#can_veto, in which case it
should destroy the window using Window#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 Dialog::OnCloseWindow does not necessarily delete the
dialog, since it will simply simulate an ID_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
Window#destroy instead
Window deletion overview, Window#destroy, CloseEvent
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.
Dialog units are used for maintaining a dialog’s proportions even if the font changes.
Window#convert_pixels_to_dialog
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.
Dialog units are used for maintaining a dialog’s proportions even if the font changes.
Window#convert_dialog_to_pixels
Destroys the window. 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.
Note that it is unusual for wxRuby code to need to explicitly call this
method; normally, windows are automatically destroyed when their
containing Frame or Dialog is closed.
Two circumstances where it can be important to call destroy are firstly,
if a window is detached from a Sizer and replaced with
another window. In this case destroy will immediately dispose of the
detached window. Secondly, if a dialog is created with no
parent argument, it can be necessary to call destroy when the dialog is
finished to signal that the dialog will not be re-used.
true
if the window has either been successfully deleted, or it has been added
to the list of windows pending real deletion.
Destroys all children of a window. Called automatically by the destructor.
Disables the window, same as enable.
Returns true
if the window has been disabled, false
if it had been
already disabled before the call to this function.
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.
Does the window-specific updating after processing the update event.
This function is called by
Window#update_window_ui in order to
check return values in the UpdateUIEvent and act
appropriately. For example, to allow frame and dialog title updating,
Widgets implements this function as follows:
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.
true
, enables the window for input. If false
, disables the window.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.
Window#is_enabled, Window#disable, RadioBox#enable
Find a child of this window, by identifier.
Window find_window(%(arg-type)String% name)Find a child of this window, by name.
Find the first window with the given id.
If parent is nil
, 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.
Find a window by its name (as given in a window constructor or create
function call). If parent is nil
, 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,
find_window_by_label is called.
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 nil
, the
search will start from all top-level frames and dialog boxes; if
not nil
, the search will be limited to the given window hierarchy. The
search is recursive in both cases.
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
instead of calling Fit.
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.
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 re-enable 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 TextCtrl under GTK) but is not implemented on all platforms nor for all
controls so it is mostly just a hint to Widgets and not a mandatory
directive.
Gets the accelerator table for this window. See AcceleratorTable.
Returns the accessible object for this window, if any.
See also Accessible.
Returns the background colour of the window.
Window#set_background_colour, Window#set_foreground_colour, Window#get_foreground_colour
Returns the background style of the window. The background style indicates
whether background colour should be determined by the system (BG_STYLE_SYSTEM),
be set to a specific colour (BG_STYLE_COLOUR), or should be left to the
application to implement (BG_STYLE_CUSTOM).
On GTK+, use of BG_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.
Window#set_background_colour, Window#get_foreground_colour, Window#set_background_style
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.
Window#get_best_size, Window#set_initial_size
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
Panel), the size returned by this function will be the
same as the size the window would have had after calling
Fit.
Returns the currently captured window.
Window#has_capture,
Window#capture_mouse,
Window#release_mouse,
MouseCaptureLostEvent
MouseCaptureChangedEvent
Returns the caret associated with the window.
Returns the character height for this window.
Returns the average character width for this window.
Returns a reference to the list of the window’s children.
WINDOW_VARIANT_NORMAL
)
Returns the default font and colours which are used by the control. This is
useful if you want to use the same font or colour in your own control as in a
standard control — which is a much better idea than hard coding specific
colours or fonts which might look completely out of place on the users
system, especially if it uses themes.
The variant parameter is only relevant under Mac currently and is
ignore under other platforms. Under Mac, it will change the size of the
returned font. See Window#set_window_variant
for more about this.
This static method is ’’overridden’’ in many derived classes and so calling,
for example, Button#get_class_default_attributes will typically
return the values appropriate for a button which will be normally different
from those returned by, say, ListCtrl#get_class_default_attributes.
The VisualAttributes
structure has at least the fields
font
, colFg
and colBg
. All of them may be invalid
if it was not possible to determine the default control appearance or,
especially for the background colour, if the field doesn’t make sense as is
the case for colBg
for the controls with themed background.
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.
Returns the client area position and size as a Rect
object. The client area is the window space available for drawing -
i.e. its whole size minus window decorations like scrollbars, title bars
and so on.
Returns a pointer to the window’s layout constraints, or nil
if there are none.
Return the sizer that this window is a member of, if any, otherwise
nil
.
Return the cursor associated with this window.
Currently this is the same as calling
get_class_default_attributes (get_window_variant).
One advantage of using this function compared to the static version is that
the call is automatically dispatched to the correct class (as usual with
virtual functions) and you don’t have to specify the class name explicitly.
The other one is that in the future this function could return different
results, for example it might return a different font for an ’’Ok’’ button
than for a generic button if the users GUI is configured to show such buttons
in bold font. Of course, the down side is that it is impossible to call this
function without actually having an object to apply it to whereas the static
version can be used without having to create an object first.
Returns the associated drop target, which may be nil
.
Window#set_drop_target,
Drag and drop overview
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.
Window#get_best_size, Window#set_initial_size
Returns the event handler for this window. By default, the window is its
own event handler.
Window#set_event_handler, Window#push_event_handler, Window#pop_event_handler, EvtHandler#process_event, EvtHandler
Returns the extra style bits for the window.
Returns the font for this window.
Returns the foreground colour of the window.
The interpretation of foreground colour is open to interpretation according
to the window class; it may be the text colour or other colour, or it may not
be used at all.
Window#set_foreground_colour, Window#set_background_colour, Window#get_background_colour
Returns the grandparent of a window, or nil
if there isn’t one.
Returns the platform-specific handle of the physical window. This is a
platform-specific Integer, which may be used to make native API calls,
eg via Ruby’s Win32API library. It will correspond to a HWND for
Windows, Widget for Motif, GtkWidget for GTK or WinHandle for
PalmOS.
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 get_help_text can be used.
2.7.0
Gets the help text to be used as context-sensitive help for this window.
Note that the text is actually stored by the current HelpProvider implementation,
and not in the window object itself.
set_help_text, get_help_text_at_point, HelpProvider
Returns the identifier of the window.
Each window has an integer identifier. If the application has not provided one
(or the default ID_ANY) an unique identifier with a negative value will be generated.
Window#set_id, Window identifiers
Generic way of getting a label from any window, for
identification purposes.
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.
Returns the maximum size of the window, an indication to the sizer layout mechanism
that this is the maximum possible size.
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 set_min_size, but it can be overridden to do the
calculation on demand.
Returns the window’s name.
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 Window#set_name.
Returns the parent of the window, or nil
if there is no parent.
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.
Returns the size and position of the window as a Rect object.
Returns the window position in screen coordinates, whether the window is a
child window or a top level one.
Returns the size and position of the window on the screen as a
Rect object.
Returns the built-in scrollbar position.
Returns the built-in scrollbar range.
Returns the built-in scrollbar thumb size.
This gets the size of the entire window in pixels,
including title bar, border, scrollbars, etc.
get_client_size, get_virtual_size
Return the sizer associated with the window by a previous call to
set_sizer or nil
.
false
)
Gets the dimensions of the string as it would be drawn on the
window with the currently selected font. The dimensions are returned as
a four-element array.
The first two elements are the width and height, in pixels, of the
string. The third and fourth values are the descent and external
leading – which are not normally needed.
The font
parameter may optionally be passed to specify the font and
size for which the dimensions of the string will be calculated. If this
parameter is not passed, the current window font is used.
true
, string contains 16-bit characters. The default is false
.Get the associated tooltip or nil
if none.
Returns the region specifying which parts of the window have been damaged. Should
only be called within an PaintEvent handler.
Returns a pointer to the current validator for the window, or nil
if there is none.
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
set_virtual_size it will return
that size.
Returns the size of the left/right and top/bottom borders of this window in x
and y components of the result respectively.
Gets the window style that was passed to the constructor or Create
method. GetWindowStyle() is another name for the same function.
Returns the value previously passed to
Window#set_window_variant.
Returns true
if this window has the current mouse capture.
Window#capture_mouse,
Window#release_mouse,
MouseCaptureLostEvent
MouseCaptureChangedEvent
Returns true
if the window has the given flag bit set.
This method should be overridden to return true
if this window has
multiple pages. All standard class with multiple pages such as
Notebook, Listbook and
Treebook already override it to return true
and user-defined classes with similar behaviour should do it as well to allow
the library to handle such windows appropriately.
Returns true
if this window has a scroll bar for this orientation.
HORIZONTAL
or VERTICAL
.Returns if this window background is transparent (as, for example, for
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
Window-derived class to ensure that background is painted correctly.
Equivalent to calling show (false
).
This function is (or should be, in case of custom controls) called during
window creation to intelligently set up the window visual attributes, that is
the font and the foreground and background colours.
By ’’intelligently’’ the following is meant: by default, all windows use their
own default attributes. However
if some of the parents attributes are explicitly (that is, using
set_font and not
set_own_font) changed and if the
corresponding attribute hadn’t been explicitly set for this window itself,
then this window takes the same value as used by the parent. In addition, if
the window overrides should_inherit_colours
to return , the colours will not be changed no matter what and only the
font might.
This rather complicated logic is necessary in order to accommodate the
different usage scenarios. The most common one is when all default attributes
are used and in this case, nothing should be inherited as in modern GUIs
different controls use different fonts (and colours) than their siblings so
they can’t inherit the same value from the parent. However it was also deemed
desirable to allow to simply change the attributes of all children at once by
just changing the font or colour of their common parent, hence in this case we
do inherit the parents attributes.
Sends an EVT_INIT_DIALOG
event.
Resets the cached best size value so it will be recalculated the next time it is needed.
Returns 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.
Returns true
if the window is enabled for input, false
otherwise.
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.
Returns if the window is currently frozen by a call to
Freeze.
Returns true
if the window is retained, false
otherwise.
Retained windows are only available on X platforms.
Returns true
if the window is shown, false
if it has been hidden.
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.
Returns true
if the given window is a top-level one. Currently all frames and
dialogs are considered to be top-level windows (even if they have a parent
window).
Invokes the constraint-based layout algorithm or the sizer-based algorithm
for this window.
See Window#set_auto_layout: when auto
layout is on, this function gets called automatically when the window is resized.
This is just a wrapper for scroll_lines (1).
This is just a wrapper for scroll_lines (-1).
Lowers the window to the bottom of the window hierarchy (z-order). A
deprecated alias for send_to_back.
Disables all other windows in the application so that
the user can only interact with this window.
true
, this call disables all other windows in the application so thatfalse
, the effect is reversed.Moves the window to the given position.
Implementations of set_size can also implicitly implement the
Window::move function, which is defined in the base Window class
as the call:
Moves this window in the tab navigation order after the specified win.
This means that when the user presses TAB
key on that other window,
the focus switches to this window.
Default tab order is the same as creation order, this function and
move_before_in_tab_order allow to change
it after creating all the windows.
Same as move_after_in_tab_order except that
it inserts this window just before win instead of putting it right after
it.
Does keyboard navigation from this window to another, by sending
a NavigationKeyEvent.
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 TE_PROCESS_TAB style is to insert a tab
and not navigate to the next control.
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 Window#update_window_ui
in order to send update events to the window in idle time.
This is just a convenience wrapper for
scroll_pages . It scrolls the window down one page
This is just a convenience wrapper for
scroll_pages . It scrolls the window up one page.
Run code to draws lines, shapes and bitmaps onto the Window. The block
should receive a DC (device context) object which can then be
used to do the actual drawing. See the DC documentation for
valid drawing methods.
The preferred usage of this method is within an evt_paint
handler,
which is called whenever any part of the Window needs to be redrawn. In
this case, the block will receive a PaintDC object. If
paint
is called outside a paint event handler, it will receive a
ClientDC object. These two classes support identical methods.
This is the correct way in wxRuby to draw directly upon, for example,
Panels. You should not attempt to instantiate a PaintDC or ClientDC
directly. This will raise an exception, as doing so can cause serious
errors on some platforms.
Note also that it is not possible to draw directly upon some core
controls, such as Wx::Button. Whilst this may work on some
platforms, it is not portable.
If the drawing block contains many separate drawing commands, using
paint_buffered may reduce flicker on some
platforms, in particular Windows.
Enables flicker-free drawing. All drawing commands are carried out on
an off-screen buffer, then copied en-masse to the on-screen Window when
the drawing is finished. The method otherwise works identically to
paint.
The method may be passed an existing bitmap as the buffer
to carry out drawing on, otherwise one will be created as required. It
may be more efficient to re-use an existing buffer for frequently
updated drawings.
Note that some platforms such as OS X and GTK support double-buffering
natively, and in this case no special buffer will be created.
false
)
Removes and returns the top-most event handler on the event handler stack.
true
, the handler will be deleted after it is removed. Thefalse
.Window#set_event_handler, Window#get_event_handler, Window#push_event_handler, EvtHandler#process_event, EvtHandler
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, current mouse
cursor position is used.
Just before the menu is popped up, Menu#update_ui
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, GTK) can do
a better job of positioning the menu in that case.
Pushes this event handler onto the event stack for the window.
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.
Window#push_event_handler 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 Window#pop_event_handler to
remove the event handler.
Window#set_event_handler, Window#get_event_handler, Window#pop_event_handler, EvtHandler#process_event, EvtHandler
Raises the window to the top of the window hierarchy (z-order).
This is a deprecated alias for bring_to_front, as
the method name “raise” conflicts with Ruby’s core method for raising an
exception. It’s recommended to use “bring_to_front” in new code.
true
, Rect rect = nil)
Causes this window, and all of its children recursively (except under GTK1
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.
true
, the background will betrue
)
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 Rect object as argument like this
refresh_rect(Rect(x, y, w, h))
.
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.
MOD_SHIFT
, MOD_CONTROL
, MOD_ALT
MOD_WIN
specifying the modifier keys that have to be pressed along with the key.true
if the hotkey was registered successfully. false
if some other application already registered a
hotkey with this modifier/virtualKeyCode combination.
Use EVT_HOTKEY(hotkeyId, fnc) in the event table to capture the event.
This function is currently only implemented under Windows. It is used
in the Windows CE port for detecting hardware button presses.
Releases mouse input captured with Window#capture_mouse.
Window#capture_mouse,
Window#has_capture,
Window#release_mouse,
MouseCaptureLostEvent
MouseCaptureChangedEvent
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 Widgets and shouldn’t be
called by the user code.
Find the given handler in the windows event handler chain and remove (but
not delete) it from it.
nil
andReturns true
if it was found and false
otherwise (this also results
in an assert failure so this function should only be called when the
handler is supposed to be there).
push_event_handler, pop_event_handler
Reparents the window, i.e the window will be removed from its
current parent window (e.g. a non-standard toolbar in a Frame)
and then re-inserted into another.
Converts from screen to client window coordinates. The method may be
passed either two integers, representing the x and y coordinates,
or a single Point object. If a Point is passed in, one
will be returned; if two integers are passed in, two co-ordinates will
be returned.
Scrolls the window by the given number of lines down (if lines is
positive) or up.
Returns true
if the window was scrolled, false
if it was already
on top/bottom and nothing was done.
This function is currently only implemented under MSW and TextCtrl under
GTK (it also works for ScrolledWindow derived classes under all
platforms).
Scrolls the window by the given number of pages down (if pages is
positive) or up.
Returns true
if the window was scrolled, false
if it was already
on top/bottom and nothing was done.
This function is currently only implemented under MSW and GTK.
Physically scrolls the pixels in the window and move child windows accordingly.
Note that you can often use ScrolledWindow
instead of using this function directly.
Lowers the window – most often, a Frame – to the bottom of the window
hierarchy (z-order).
Sets the accelerator table for this window. See AcceleratorTable.
Sets the accessible for this window. Any existing accessible for this window
will be deleted first, if not identical to accessible.
See also Accessible.
Determines whether the Window#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
Panel and TopLevelWindow
(and the classes deriving from them).
This method is called implicitly by
Window#set_sizer but if you use
Window#set_constraints you should call it
manually or otherwise the window layout won’t be correctly updated when its
size changes.
Sets the background colour of the window.
Please see inherit_attributes for
explanation of the difference between this method and
set_own_background_colour.
NullColour
to reset to the default colour.The background colour is usually painted by the default EraseEvent event handler function
under Windows and automatically under GTK.
Note that setting the background colour does not cause an immediate refresh, so you
may wish to call Window#clear_background or Window#refresh after
calling this function.
Using this function will disable attempts to use themes for this
window, if the system supports them. Use with care since usually the
themes represent the appearance chosen by the user to be used for all
applications on the system.
Window#get_background_colour, Window#set_foreground_colour, Window#get_foreground_colour, Window#clear_background, Window#refresh, EraseEvent
Sets the background style of the window. The background style indicates
whether background colour should be determined by the system (BG_STYLE_SYSTEM),
be set to a specific colour (BG_STYLE_COLOUR), or should be left to the
application to implement (BG_STYLE_CUSTOM).
On GTK+, use of BG_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.
Window#set_background_colour, Window#get_foreground_colour, Window#get_background_style
A smart SetSize that will fill in default size components with the
window’s best size values. Also sets the window’s minsize to
the value passed in for use with sizers. This means that if a full or
partial size is passed to this function then the sizers will use that
size instead of the results of GetBestSize to determine the minimum
needs of the window for layout.
Most controls will use this to set their initial size, and their min
size to the passed in value (if any.)
Window#set_size, Window#get_best_size, Window#get_effective_min_size
Sets the caret associated with the window.
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 Window#set_size, 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.
This normally does not need to be called by user code. It is called
when a window is added to a sizer, and is used so the window can
remove itself from the sizer when it is destroyed.
Sets the window’s cursor. Notice that the window cursor also sets it for the
children of the window implicitly.
The cursor may be NullCursor
in which case the window cursor will
be reset back to default.
Specifies the size and position of the window, in pixel units.
SIZE_AUTO_WIDTH: a -1 width value is taken to indicate
a wxRuby-supplied default width.
SIZE_AUTO_HEIGHT: a -1 height value is taken to indicate
a wxRuby-supplied default width.
SIZE_AUTO: -1 size values are taken to indicate
a wxRuby-supplied default size.
SIZE_USE_EXISTING: existing dimensions should be used
if -1 values are supplied.
SIZE_ALLOW_MINUS_ONE: allow dimensions of -1 and less to be interpreted
as real dimensions, not default values.
SIZE_FORCE: 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 MSW and ignored elsewhere currently)
This normally does not need to be called by user code. It is called
when a window is added to a sizer, and is used so the window can
remove itself from the sizer when it is destroyed.
Sets the window’s cursor. Notice that the window cursor also sets it for the
children of the window implicitly.
The cursor may be NullCursor
in which case the window cursor will
be reset back to default.
Associates a drop target with this window.
If the window already has a drop target, it is deleted.
Sets the initial window size if none is given (i.e. at least one of the
components of the size passed to ctor/Create() is DefaultCoord).
Sets the event handler for this window.
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 Window#push_event_handler 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.
Window#get_event_handler, Window#push_event_handler, Window#pop_event_handler, EvtHandler#process_event, EvtHandler
Sets the extra style bits for the window. The currently defined extra style
bits are:
WS_EX_BLOCK_EVENTS |
Normally, the commandevents are propagated upwards to the window parent recursively until a handlerfor them is found. Using this style allows to prevent them from beingpropagated beyond this window. Notice that Dialog has this style on bydefault for the reasons explained in the"event processing overview":eventprocessing.html. |
WS_EX_TRANSIENT |
This can be used to prevent awindow from being used as an implicit parent for the dialogs which werecreated without a parent. It is useful for the windows which can disappear atany moment as creating children of such windows results in fatal problems. |
FRAME_EX_CONTEXTHELP |
Under Windows, puts a query button on the caption. When pressed, Windows will go into a context-sensitive help mode and Widgets will send a EVT_HELP event if the user clicked on an application window. This style cannot be used together with MAXIMIZE_BOX or MINIMIZE_BOX , soyou should use the style of DEFAULT_FRAME_STYLE & (MINIMIZE_BOX | MAXIMIZE_BOX ) for the frames having this style (the dialogs don’t have minimize nor maximize box bydefault) |
WS_EX_PROCESS_IDLE |
This window should always process idle events, evenif the mode set by IdleEvent#set_mode is IDLE_PROCESS_SPECIFIED . |
WS_EX_PROCESS_UI_UPDATES |
This window should always process UI update events,even if the mode set by UpdateUIEvent#set_mode is UPDATE_UI_PROCESS_SPECIFIED . |
This sets the window to receive keyboard input.
Note that on some platforms, the focus cannot be set until the Window is
visible. Therefore, ensure that show has been called on
the Window, or its containing Frame, before calling this method.
FocusEvent
Panel#set_focus
Panel#set_focus_ignoring_children
This function is called by Widgets 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 set_focus but
can be overridden to do something in addition to this in the derived classes.
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 set_own_font instead in this case and
see inherit_attributes for more
explanations.
Please notice that the given font is not automatically used for
PaintDC objects associated with this window, you need to
call DC::SetFont too. However this font is used by
any standard controls for drawing their text as well as by
Window::GetTextExtent.
Wx::NULL_FONT
reset to the default font.Sets the foreground colour of the window.
Please see inherit_attributes for
explanation of the difference between this method and
set_own_foreground_colour.
Wx::NULL_COLOUR
to reset to the default colour.The interpretation of foreground colour is open to interpretation according
to the window class; it may be the text colour or other colour, or it may not
be used at all.
Using this function will disable attempts to use themes for this
window, if the system supports them. Use with care since usually the
themes represent the appearance chosen by the user to be used for all
applications on the system.
Window#get_foreground_colour, Window#set_background_colour, Window#get_background_colour, Window#should_inherit_colours
Sets the help text to be used as context-sensitive help for this window.
Note that the text is actually stored by the current
HelpProvider by calling its
add_help method, and not in
the window object itself.
Sets the identifier of the window.
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.
Window#get_id, Window identifiers
Sets the window’s label.
Sets the maximum size of the window, to indicate to the sizer layout mechanism
that this is the maximum possible 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.
Sets the window’s name.
Sets the background colour of the window but prevents it from being inherited
by the children of this window.
set_background_colour, inherit_attributes
Sets the font of the window but prevents it from being inherited by the
children of this window.
Sets the foreground colour of the window but prevents it from being inherited
by the children of this window.
set_foreground_colour, inherit_attributes
Obsolete – use DC#set_palette instead.
true
)
Sets the scrollbar properties of a built-in scrollbar.
true
to redraw the scrollbar, false
otherwise.Let’s say you wish to display 50 lines of text, using the same font.
The window is sized so that you can only see 16 lines at a time.
You would use:
set_scrollbar(VERTICAL, 0, 16, 50)Note that with the window at this size, the thumb position can never go
above 50 minus 16, or 34.
You can determine how many lines are currently visible by dividing the
current view size by the character height in pixels.
When defining your own scrollbar behaviour, you will always need to
recalculate the scrollbar settings when the window size changes. You
could therefore put your scrollbar calculations and set_scrollbar call
into a function named adjust_scrollbars, which can be called initially
and also from your SizeEvent handler function.
Scrolling overview, ScrollBar, ScrolledWindow, ScrollWinEvent
true
)
Sets the page size of one of the built-in scrollbars.
true
to redraw the scrollbar, false
otherwise.The page size of a scrollbar is the number of scroll units that the
scroll thumb travels when you click on the area above/left of or
below/right of the thumb. Normally you will want a whole visible page to
be scrolled, i.e. the size of the current view (perhaps the window
client size). This value has to be adjusted when the window is resized,
since the page size will have changed.
In addition to specifying how far the scroll thumb travels when paging,
in Motif and some versions of Windows the thumb changes size to reflect
the page size relative to the length of the document. When the document
size is only slightly bigger than the current view (window) size, almost
all of the scrollbar will be taken up by the thumb. When the two values
become the same, the scrollbar will (on some systems) disappear.
Currently, this function should be called before “set_page_range”, because
of a quirk in the Windows handling of pages and ranges.
Window#set_scroll_pos, Window#get_scroll_pos, Window#get_scroll_page, ScrollBar, ScrolledWindow
true
)
Sets the position of one of the built-in scrollbars.
true
to redraw the scrollbar, false
otherwise.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.
Window#set_scrollbar, Window#get_scroll_pos, Window#get_scroll_thumb, ScrollBar, ScrolledWindow
true
)
Sets the range of one of the built-in scrollbars.
true
to redraw the scrollbar, false
otherwise.The range of a scrollbar is the number of steps that the thumb may travel, rather than the total
object length of the scrollbar. If you are implementing a scrolling window, for example, you
would adjust the scroll range when the window is resized, by subtracting the window view size from the
total virtual window size. When the two sizes are the same (all the window is visible), the range goes to zero
and usually the scrollbar will be automatically hidden.
Window#set_scroll_pos, Window#set_scroll_page, Window#get_scroll_pos, Window#get_scroll_page, ScrollBar, ScrolledWindow
Sets the size of the window using either a Size or Rect
object. The former just specifies the size of the window, in pixels; a
rect specifies a new size and position.
Window:set_dimensions , Window#move
Allows specification of minimum and maximum window sizes, and window size increments.
If a pair of values is not set (or set to -1), the default values will be used.
If this function is called, the user will not be able to size the window outside the
given bounds.
The resizing increments are only significant under Motif or Xt.
Sets the window to have the given layout sizer. The window
will then own the object, and will take care of its deletion.
If an existing layout constraints object is already owned by the
window, it will be deleted if the deleteOld parameter is true.
Note that this function will also call
set_auto_layout implicitly with true
parameter if the sizer is non-nil and false
otherwise.
nil
to disassociate and conditionally deleteSetSizer now enables and disables Layout automatically, but prior to Widgets 2.3.3
the following applied:
You must call Window#set_auto_layout to tell a window to use
the sizer automatically in OnSize; otherwise, you must override OnSize and call Layout()
explicitly. When setting both a Sizer and a LayoutConstraints,
only the sizer will have effect.
The same as set_sizer, except it also sets the size hints
for the window based on the sizer’s minimum size.
This function tells a window if it should use the system’s “theme” code
to draw the windows’ background instead if its own background drawing
code. This does not always have any effect since the underlying platform
obviously needs to support the notion of themes in user defined windows.
One such platform is GTK+ where windows can have (very colourful) backgrounds
defined by a user’s selected theme.
Dialogs, notebook pages and the status bar have this flag set to true
by default so that the default look and feel is simulated best.
Attach a tooltip to the window.
See also: get_tool_tip,
ToolTip
Deletes the current validator (if any) and sets the window validator, having called Validator::Clone to
create a new validator of this type.
Sets the virtual size of the window in pixels.
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.
If this function is called, the user will not be able to size the virtual area
of the window outside the given bounds.
Identical to set_window_style_flag.
Sets the style of the window. Please note that some styles cannot be changed
after the window creation and that refresh might
be called after changing the others for the change to take place immediately.
See Window styles for more information about flags.
This function can be called under all platforms but only does anything under
Mac OS X 10.3+ currently. Under this system, each of the standard control can
exist in several sizes which correspond to the elements of WindowVariant
enum:
By default the controls use the normal size, of course, but this function can
be used to change this.
Return from here to allow the colours of this window to be changed by
inherit_attributes, returning
forbids inheriting them from the parent window.
The base class version returns , but this method is overridden in
Control where it returns .
true
)
Shows or hides the window. You may need to call raise
for a top level window if you want to bring it to top, although this is not
needed if show() is called immediately after the frame creation.
true
displays the window. Otherwise, hides it.true
if the window has been shown or hidden or false
if nothing was
done because it already was in the requested state.
Window#is_shown, Window#hide, RadioBox#show
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.
Unregisters a system wide hotkey.
true
if the hotkey was unregistered successfully, false
if the id was invalid.
This function is currently only implemented under MSW.
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.
Returns if the style was turned on by this function, if it was
switched off.
Window#set_window_style_flag, Window#has_flag
Calling this method immediately repaints the invalidated area of the window and
all of its children recursively while this would usually only happen when the
flow of control returns to the event loop. Notice that this function doesn’t
refresh the window and does nothing if the window hadn’t been already
repainted. Use refresh first if you want to
immediately redraw the window unconditionally.
This function sends UpdateUIEvents to
the window. The particular implementation depends on the window; for
example a ToolBar will send an update UI event for each toolbar button,
and a Frame 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 UpdateUIEvent handlers
are concerned). This may be necessary if you have called
UpdateUIEvent#set_mode or
UpdateUIEvent#set_update_interval to
limit the overhead that Widgets incurs by sending update UI events in idle time.
flags should be a bitlist of one or more of the following values.
enum UpdateUI { UPDATE_UI_NONE = 0×0000, // No particular value UPDATE_UI_RECURSE = 0×0001, // Call the function for descendants UPDATE_UI_FROMIDLE = 0×0002 // Invoked from On(Internal)Idle };If you are calling this function from an on_internal_idle or on_idle
function, make sure you pass the UPDATE_UI_FROMIDLE flag, since
this tells the window to only update the UI elements that need
to be updated in idle time. Some windows update their elements
only when necessary, for example when a menu is about to be shown.
The following is an example of how to call update_window_ui from
an idle function.
UpdateUIEvent,
Window#do_update_window_ui,
Window#on_internal_idle
Validates the current values of the child controls using their validators.
If the window has WS_EX_VALIDATE_RECURSIVELY
extra style flag set,
the method will also call validate() of all child windows.
Returns false
if any of the validations failed.
Moves the pointer to the given position on the window.
NB: This function is not supported under Mac because Apple Human
Interface Guidelines forbid moving the mouse cursor programmatically.
[This page automatically generated from the Textile source at 2023-06-09 00:45:26 +0000]