1.185 class window

A window is a subwindow of a frame object. It appears on the screen as a rectangular area inside a frame. It defines an infinite two-dimensional drawing plane of which a rectangular sub-area is window<-visible. A window optionally has window->scrollbars attached that allows the user to move the visible rectangle over the infinite plane.

Class window takes care of the communication with its window<-frame and the window system it uses for it's graphical representation.

As defined in class device, a window can display graphical objects (i.e. instances of one of the subclasses of class graphical). There are several kinds of windows:

1.185.1 Class variables

window.size: size = size(200,100)
Default size of a window. Normally applications have several windows and decide on the size and placement of each of these windows itself.

1.185.2 Instance variables

window <- background: [colour]
Background colour of the window.
window-bounding_box: area
Union of graphicals in this window in the coordinate system of the window.
window <- current_event: event*
Event that is currently being processed by this window or @nil if this window is not processing any events. This variable is managed by device->event.

This is not necessarily the same as @event. Consider the case were the window has opened a popup. In this case window<-current_event will point to the event that caused the popup to open (generally an ms_right_down event), while @event will point to the various events that are processed during the opened state of the popup window.

See also
device->event
window <- decoration: window_decorator*
Window displaying me and my decorations. This slot will normally contain an instance of class window_decorator. The window decoration displays a label above the Window and/or adds scrollbars to the window. window->catch_all creates a decorator for methods that are not defined on class window and are defined by class window_decorator. This allows for e.g.,
send(Window, scrollbars, both)
window-displayed_cursor: cursor*
Currently visible cursor. This attribute is computed dynamically. The actually displayed cursor of a window is:

window <- focus: graphical*
Graphical object in focus of events. When not @nil, events will be sent to this graphical. When window<-focus_recogniser too is not @nil the event will be posted to this recogniser only.

Note that keyboard events will be send to the window<-keyboard_focus when this is not @nil.

See also
- device->event
- window-keyboard_focus
- window->focus
- window-focus_recogniser
window <- focus_button: [button_name]*
When a focus is set (window<-focus is not @nil), this focus remains active until a button-up-event is received with this button. When @nil, the focus remains set till it is explicitly cleared.
See also
- device->event
- window->focus
window <- focus_cursor: cursor*
When not @nil and window<-focus is not @nil, this cursor will be displayed.
See also
- window->focus_cursor
- window-displayed_cursor
window <- focus_recogniser: recogniser*
When not @nil and window<-focus is not @nil, events are given to this recogniser object.
See also
- class gesture
- device->event
- window-focus
window-frame: frame*
Frame object of which the window is a frame<-member. If the window has no frame and is not displayed on another graphical and create is @on or @default a default frame is attached to the window which is returned.
See also
- frame<-frame
- window->above
window <-> has_pointer: bool
If @on, pointer (mouse) is in window. The method is invoked from device->event and may be redefined, but should always invoke the primary implementation.
window <- input_focus: bool
When @on, this window is the window receiving keyboard input. See also frame->input_focus. When modified, and the window<-keyboard_focus is not @nil, the method will generate either an activate_keyboard_focus or a deactivate_keyboard_focus event to window<-keyboard_focus.
See also
- frame<-input_focus
- frame->input_focus
window <- keyboard_focus: graphical*
Graphical object in the window to which keyboard events should be posted. When @nil, keyboard events are dispatched the same way as pointer events.

A graphical getting the keyboard focus will be sent an obtain_keyboard_focus event. Graphicals loosing the keyboard focus will be sent a release_keybaord_focus event.

See also
- device->event
- window-focus
- window->keyboard_focus
window <-> popup: popup*
Popup menu associated with this window. It is activated through the global object @_popup_gesture when all other attempts to handle the button-event have failed. See device->event.
See also
- device->event
- class popup
window <- resize_message: code*
The message is executed after the window has been resized by its frame. It allows the programmer to reorganise the contents of the frame such that they better fit the new size. The arguments are:
@receiver The window
@arg1 The window
@arg2 New size of the window

This message is always sent when the associated frame is created.

Resizing a window may also be specified by redefining the window->geometry method. See also window<-visible and dialog->layout.

See also
frame->set
window-scroll_offset: point
Indicates how much the window is scrolled. The top-left corner of the window is -in the coordinate system of the displayed graphicals- negative the x- and y- parameters of this point.

window<-visible is the proper way to get information on the current location of the visible area of the window.

window <- selection_feedback: {invert,handles,colour}|elevation|colour*
The value of this variable determines how graphicals with graphical<-selected: @on are visualised. Values:

window <-> sensitive: bool
Determines whether or not the window is sensitive for events. When @off, all events are ignored. Rarely used.
See also
device->event
window-tile: tile*
Tile object associated with this window. The associated tile negotiates the layout of windows in the frame with the frame and finally dictates the size and position of the window. If the window has no tile, a this method creates a tile object for the window and returns the new tile.
See also
- window-display_area
- window->border

1.185.3 Send methods

window ->_compute_desired_size:
This method is invoked by class frame to as part of frame->fit. It allows the window to resize itself to fit with its contents. By default this method is only active for class dialog.

This method may be redefined.

window ->above: window|tile
Part of the definition of the layout of windows inside a frame. Requests the receiver to be placed above the argument window.

Depending on whether or not the argument is a window or a tile, the behaviour of this method is rather different. Using window argument is intended for initial creation of windows, while using a tile argument is intended for adding windows to an already open frame object:

window ->background: colour|pixmap
Colour of the drawing plane. Changing the colour forces a redraw.

Defaults: The display<-background.

See also
- window->foreground
- display-background
window ->below: window|tile
Similar to window->above, but rhe receiver is placed below the argument.
See also
- topic Window Layout
- window->above
window ->bubble_scroll_bar: scroll_bar
Update bubble of given scroll_bar object. Called by‘scroll_bar window->compute’.
window ->catch_all: name, unchecked ...
Handle delegation to window<-decoration, window<-frame and window<-tile while these slots are not yet filled. If the selector is found on any of these classes, the corresponding object is associated to the window and the message is delegated. This implementation ensures that messages like window_decorator->scrollbars, frame->kind and tile->hor_stretch may always be send directly to the window.
window ->changed_union: ox=int, oy=int, ow=int, oh=int
This method is invoked from class device when the union of all graphicals has changed. Used to update the scrollbars accordingly. See also window->update_scroll_bar_values.
window ->foreground: [colour]
window ->colour: [colour]
Set the default colour for all graphicals displayed on this window: each graphical that has its colour set to @default will be displayed in the colour specified. If the window is displayed, it will be redrawn.

Defaults: When @default is provided, display<-foreground is used.

See also
- window->foreground
- graphical<-display_colour
- window<-foreground
- class colour
window ->create: [window]
window->create establishes the resources for making the window visible. This method is normally called from frame->open and should not be used directly by the user.
See also
- frame->create
- window->open
window ->decorate: area=[{grow,shrink}], left_margin=[int], right_margin=[int], top_margin=[int], bottom_margin=[int], decorator=[window]
Attach a window_decorator object to this window for displaying scroll_bar objects or a label. This method is used by window_decorator->initialise.
window ->destroy:
Destroys the associated window. See visual->destroy for details.
window ->expose:
Exposes (take to the front) the frame of the window on its screen. Invokes frame->expose.
window ->flash: area=[area], time=[int]
Flashes the window by temporary inverting it. Normally, applications should invoke graphical->alert, which depending on the setting of the window.visual_bell will either ring the bell or flash the object.
See also
- graphical.visual_bell_duration
- graphical.visual_bell
- graphical->bell
- graphical->alert
window ->flush:
Updates all graphicals in this window and requests a redraw for the window system.
See also
- graphical->flush
- display->flush
window ->focus: graphical*, [recogniser]*, [cursor]*, [name]*
Forward events arriving on this window to some graphical. This method is normally used only by class gesture to process all events starting with a mouse-down and ending with the mouse-up of the same mouse-button.

Graphical is the graphical object in focus. If Recogniser is not @nil, events are given to this particular recogniser object. If Cursor is not @nil, the cursor is set to this value until the focus is released. The Name argument indicates the button that initiated the focus. If a button-up event is received of this button, the focus will be released automatically. If the value is @nil, the focus remains active until a new window->focus message is received.

See also window->grab_pointer and window->grab_keyboard.

Defaults: The following defaults apply:

Recogniser@nil (None)
Cursor@nil (Cursor is not changed)
ButtonButton of the current event, computed with: Window?current_event?button
See also
- graphical->focus
- window-focus_button
- window-focus
- window-displayed_cursor
- window->grab_pointer
- class gesture
- window->keyboard_focus
- event->post
- window->focus_cursor
window ->focus_cursor: cursor*
Changes the window<-focus_cursor variable and displayed cursor if the window has window<->focus not equal to @nil. The cursor is automatically reset if the focus of the window is set to @nil. This method is often used by gestures to change the cursor while the gesture is active.
See also
- class cursor
- window-focus_cursor
- graphical->focus_cursor
- window->focus
window ->free:
window->free causes the entire frame and possible other windows that are part of the frame to be freed.

If a window is just to be deleted from its window<-frame use frame->delete.

window ->geometry: x=[int], y=[int], width=[int], height=[int]
Traps the graphical->set, graphical->size, window->position and other methods to manipulate the geometry that are inherited from class graphical. It sets the graphical<-area of the window.

Note that the size and position of a window is dictated by its associated window<-tile. To change the layout of windows in a frame, please examine the behaviour defined on class tile. Windows delegate to their tile.

window ->grab_pointer: bool
If @on is specified, all subsequent events will be reported as if they happened on this window. @off should be used to resume normal event-processing.

The normal XPCE event-processing ensures the window in which a mouse-down event occurrs grabs the pointer until the mouse-button is released (see also class gesture).

Most modern window environments do not allow a global grab on the pointer. Any event happening on any xpce window of the same process is redirected to this window.

See also window->focus and window->grab_keyboard.

See also
- window-grab_pointer
- window->grab_keyboard
- display->inform
- window->focus
window ->hide:
Hides (put at the back) the frame of the window on its screen. Redefines graphical->hide.
window ->initialise: label=[name], size=[size], display=[display]
Create a window object from its label, size and the display on which is has to be displayed.

This will create a default frame for this window. When two windows are related using window->above, window->below, window->left or window->right, both windows will be made part of the same frame. The frame of the receiver of the window->above, etc. method will be destroyed and this window will be made part of the frame of the argument window.

Defaults:

labeluntitled
sizeresource defined (see size resource)
display@display
See also
class frame
window ->keyboard_focus: graphical*
Direct keyboard events to the given graphical.
See also
- window-keyboard_focus
- device->advance
- window->focus
window ->left: window|tile
Similar to window->above, but rhe receiver is placed left of the argument.
See also
- topic Window Layout
- window->above
window ->position: point
Position in window<-frame.
window ->x: int
Move graphical horizontally.
window ->y: int
Move graphical vertically.
window ->move: point
Class window redefines the inherited placement methods of class device to be equivalent to those of class graphical again. Class device defines the position to be the origin of the coordinate system, while the position of a window is the position of the top-left corner as with class graphical.
window ->normalise: on=area|graphical|chain, mode=[{xy,x,y}]
Try to make object visible by scrolling the window. Object is either an area, a graphical or a chain of graphicals. The area that is made visible is the area itself, the area of the graphical or the union of the areas of the graphicals in the chain.

If it is not possible to make the entire area visible, it is ensured the top-left corner of the area is visible.

If mode is x, the window is only scrolled horizontally. Likewise if mode is y the window is only scrolled vertically. In all other cases scrolling is performed in both directions.

See also
- window->scroll_to
- window<-visible
window ->open: [point], display=[display]
Ensures the window has a window<-frame and invokes frame->open to realise the toplevel window on the given display. Some window systems, notably Wayland, ignore the position argument.
See also
- frame->open
- window<-confirm
- window->open_centered
- window->create
window ->open_centered: center=[point|frame], display=[display], grab=[bool]
Equivalent to window->open, but the frame is centered around the given point.

Defaults: If no point is specified, the window is opened at the center of the display.

See also
- frame->open_centered
- window<-confirm_centered
- window->open
window ->pen: 0..
Thickness of the line surrounding the window.

Defaults: 1

See also
window->border
window ->pointer: point
Move the pointer to the indicated position, which is in the same coordinate system as the graphicals displayed in the window. The pointer needs not be in the window, nor need the indicated coordinate be inside the window.

This method should be used with care. Users tend not to like jumping mice. It is generally better to place a UI component close to the pointer location (see event<-position) than to place the UI component far away and jump the pointer towards it.

Class resize_gesture uses it to position the pointer exactly on the border of a graphical if it was depressed close to it.

Diagnostics: Succeeds without side-effects if the window is not displayed.

See also
graphical->pointer
window ->post_event: event
Handle events comming from the underlying windowing system. This method deals with focus handling, cursor managements, etc. For normal unfocussed events is calls device->event with the same event, similar to the device->event routine on normal graphical objects. The distinction makes the function of device->event the same on all graphical classes, simplifying code reuse. Redefinition of window->post_event should rarely be necessary.
window ->redraw: [area]
Redraw the entire window or some area of it. This method is normally invoked automatically if the window is opened on the display or part of it is exposed after it has been obscured by other windows.

PCE is designed to take care of all visual side-effects automatically, so the user should never have to invoke methods explicitly. An exception on this rule are the decorations (scrollbars and label) of the window. If these are changed this method needs to be called explicitly to update the window.

window ->reset:
Assigns window<-current_event to @nil and releases a possible event-focus. Then invokes visual->reset to take care of the graphicals displayed on it.
See also
visual->reset
window ->resize:
Invoked from the low-level window interface after the window has been resized for any reason. If window<-resize_message is specified, this message is executed with the following arguments:
@receiver The window
@arg1 The window (i.e. same)
@arg2 The new size of the window

The new size is the area<-size of the graphical<-area.

See also window<-visible and dialog->layout.

window ->resize_message: code*
Set the variable window<-resize_message and executes it if the window has already been created. Arguments:
@receiver:The WIndow
@arg1 Same as @receiver
@arg2 Size object reflecting the new size
See also
window-resize_message
window ->right: window|tile
Similar to window->above, but rhe receiver is placed right of the argument.
See also
- topic Window Layout
- window->above
window ->scroll_vertical: direction={forwards,backwards,goto}, unit={page,file,line}, amount=int, force=[bool]
Trap message from vertical scrollbar.
window ->scroll_horizontal: direction={forwards,backwards,goto}, unit={page,file,line}, amount=int, force=[bool]
Traps a scroll-request from the horizontal scrollbar or a wheel-mouse. See class scroll_bar for details.

If the force argument is @on, the scroll actions is performed unconditionally. Otherwise it is only performed if the window has the associated scroll_bar object. This ensures no scrolling is performed based on a wheel-mouse if the window has no scroll_bar.

See also
- window->scroll_vertical
- class scroll_bar
- scroll_bar-object
window ->scroll_to: point
Point is in the coordinate system of the graphicals displayed in the window. Makes this point the top-left corner of the window. Windows can scroll both the positive and negative coordinates. See also window<-visible.
See also
window->normalise
graphical ->size: size
Argument is the desired size in pixels. This method enlarges the requested size with the window<->border and offset caused by possible scrollbars and then invokes
`tile ->set: @default, @default, Width, Height`

Which will change the desired size. The associated frame then decides on the actual size. If the associated frame is already created, only the distribution of the windows inside the frame may be changed. The frame itself won't be resized. The method frame->fit requests the frame to resize its contents and itself to the most desirable value.

Various subclasses of window redefined this method to make the unit of the size dependent on their font.

See also
- window-display_area
- frame->fit
- window->display_size
window ->typed: event|event_id, delegate=[bool]
Handle accelerator bindings. This method is normally invoked from device->event if no graphical object in the window accepted the typed key. The window will forward the typed key to the frame using frame->typed The frame in turn will check for another window (generally a dialog object) that is capable of handling the typed key.

If delegate = @on (as invoked from device->event) it invokes window->typed on window<-frame.

window ->uncreate:
Destroy associated window system resources. This method is used internally when a window is deleted from another window or its frame.
window ->unlink:
In addition to device->unlink, this method takes care of the window<-decoration and the associated window-system window.
window ->update_scroll_bar_values:
This message is sent to the window object if either the window is resized (see window->resize), the bounding box of the content changed (see window->changed_union) or the window was scrolled (see window->scroll_to).

It can be redefined to constrain other objects to these actions. The redefined method must call this method to ensure proper update of the windows window->scrollbars.

1.185.4 Get methods

window <-confirm: position=[point], grab=[bool] -> any
Creates the window and then invokes frame<-confirm on its frame.
See also
- window->open
- window<-confirm_centered
- frame<-confirm
window <-confirm_centered: center=[point|frame], display=[display], grab=[bool] -> any
Similar to window<-confirm, but centers the frame of the window around the given position instead of putting the top-left corner at the given position.
See also
- window->open_centered
- frame<-confirm_centered
- window<-confirm
window <-contained_in: -> frame|device
Implements visual<-contained_in for class window. Windows normally appear as tiled objects in a frame object. They can also be displayed as normal graphical objects.
See also
visual<-contained_in
window <-convert: graphical -> window
Convert a graphical to it's window using graphical<-window. Simplifies activating methods that accept a window as argument.
window <-foreground: -> colour
Equivalent to graphical<-colour.
See also
window->colour
window <-frame: create=[bool] -> frame
window <-visible: -> area
New area object reflecting the visible area of the drawing plane. The device<-position of this area is the coordinate of the top-left corner of the window. Its value is initially (0,0), but may be changed if the window is scrolled. The window<-size is the size of the visible area of the drawing plane.
See also
- window<-display_size
- window->normalise