Class Fox::FXWindow

In: | FXWindow.rb ../lib/fox/core.rb ../lib/fox/responder2.rb
Parent: | FXDrawable

Base class for all windows

### Events

The following messages are sent by FXWindow to its target:

`SEL_MAP`: | sent when the window is mapped to the screen; the message data is an FXEvent instance.
`SEL_UNMAP`: | sent when the window is unmapped; the message data is an FXEvent instance.
`SEL_CONFIGURE`: | sent when the window’s size changes; the message data is an FXEvent instance.
`SEL_ENTER`: | sent when the mouse cursor enters this window
`SEL_LEAVE`: | sent when the mouse cursor leaves this window
`SEL_FOCUSIN`: | sent when this window gains the focus
`SEL_FOCUSOUT`: | sent when this window loses the focus
`SEL_UPDATE`: | sent when this window needs an update
`SEL_UNGRABBED`: | sent when this window loses the mouse grab (or capture)

For each of the following keyboard-related events, the message data is an FXEvent instance:

`SEL_KEYPRESS`: | sent when a key is pressed
`SEL_KEYRELEASE`: | sent when a key is released

For each of the following mouse-related events, the message data is an FXEvent instance:

`SEL_MOTION`: | sent when the mouse moves
`SEL_LEFTBUTTONPRESS`: | sent when the left mouse button goes down
`SEL_LEFTBUTTONRELEASE`: | sent when the left mouse button goes up
`SEL_MIDDLEBUTTONPRESS`: | sent when the middle mouse button goes down
`SEL_MIDDLEBUTTONRELEASE`: | sent when the middle mouse button goes up
`SEL_RIGHTBUTTONPRESS`: | sent when the right mouse button goes down
`SEL_RIGHTBUTTONRELEASE`: | sent when the right mouse button goes up
`SEL_MOUSEWHEEL`: | sent when the mouse wheel is scrolled

For each of the following selection-related events, the message data is an FXEvent instance:

`SEL_SELECTION_GAINED`: | sent when this window acquires the selection
`SEL_SELECTION_LOST`: | sent when this window loses the selection
`SEL_SELECTION_REQUEST`: | sent when this window’s selection is requested

For each of the following clipboard-related events, the message data is an FXEvent instance:

`SEL_CLIPBOARD_GAINED`: | sent when this window acquires the clipboard
`SEL_CLIPBOARD_LOST`: | sent when this window loses the clipboard
`SEL_CLIPBOARD_REQUEST`: | sent when this window’s clipboard data is requested

For each of the following drag-and-drop events, the message data is an FXEvent instance:

`SEL_BEGINDRAG`: | sent at the beginning of a drag operation
`SEL_DRAGGED`: | sent while stuff is being dragged around
`SEL_ENDDRAG`: | sent at the end of a drag operation
`SEL_DND_ENTER`: | drag-and-drop enter
`SEL_DND_LEAVE`: | drag-and-drop leave
`SEL_DND_MOTION`: | drag-and-drop motion
`SEL_DND_DROP`: | drag-and-drop motion
`SEL_DND_REQUEST`: | drag-and-drop request

### Layout hints for child widgets

`LAYOUT_NORMAL`: | Default layout mode
`LAYOUT_SIDE_TOP`: | Pack on top side (default)
`LAYOUT_SIDE_BOTTOM`: | Pack on bottom side
`LAYOUT_SIDE_LEFT`: | Pack on left side
`LAYOUT_SIDE_RIGHT`: | Pack on right side
`LAYOUT_FILL_COLUMN`: | Matrix column is stretchable
`LAYOUT_FILL_ROW`: | Matrix row is stretchable
`LAYOUT_LEFT`: | Stick on left (default)
`LAYOUT_RIGHT`: | Stick on right
`LAYOUT_CENTER_X`: | Center horizontally
`LAYOUT_FIX_X`: | X fixed
`LAYOUT_TOP`: | Stick on top (default)
`LAYOUT_BOTTOM`: | Stick on bottom
`LAYOUT_CENTER_Y`: | Center vertically
`LAYOUT_FIX_Y`: | Y fixed
`LAYOUT_FIX_WIDTH`: | Width fixed
`LAYOUT_FIX_HEIGHT`: | Height fixed
`LAYOUT_MIN_WIDTH`: | Minimum width is the default
`LAYOUT_MIN_HEIGHT`: | Minimum height is the default
`LAYOUT_FILL_X`: | Stretch or shrink horizontally
`LAYOUT_FILL_Y`: | Stretch or shrink vertically
`LAYOUT_EXPLICIT`: | Explicit placement

### Frame border appearance styles (for subclasses)

`FRAME_NONE`: | Default is no frame
`FRAME_SUNKEN`: | Sunken border
`FRAME_RAISED`: | Raised border
`FRAME_THICK`: | Thick border
`FRAME_GROOVE`: | A groove or etched-in border
`FRAME_RIDGE`: | A ridge or embossed border
`FRAME_LINE`: | Simple line border
`FRAME_NORMAL`: | Regular raised/thick border

### Packing style (for packers)

`PACK_NORMAL`: | Default is each its own size
`PACK_UNIFORM_HEIGHT`: | Uniform height
`PACK_UNIFORM_WIDTH`: | Uniform width

### Message IDs common to most windows

`ID_NONE`: | x
`ID_HIDE`: | x
`ID_SHOW`: | x
`ID_TOGGLESHOWN`: | x
`ID_LOWER`: | x
`ID_RAISE`: | x
`ID_DELETE`: | x
`ID_DISABLE`: | x
`ID_ENABLE`: | x
`ID_UNCHECK`: | x
`ID_CHECK`: | x
`ID_UNKNOWN`: | x
`ID_UPDATE`: | x
`ID_AUTOSCROLL`: | x
`ID_HSCROLLED`: | x
`ID_VSCROLLED`: | x
`ID_SETVALUE`: | x
`ID_SETINTVALUE`: | x
`ID_SETREALVALUE`: | x
`ID_SETSTRINGVALUE`: | x
`ID_SETINTRANGE`: | x
`ID_SETREALRANGE`: | x
`ID_GETINTVALUE`: | x
`ID_GETREALVALUE`: | x
`ID_GETSTRINGVALUE`: | x
`ID_GETINTRANGE`: | x
`ID_GETREALRANGE`: | x
`ID_QUERY_TIP`: | x
`ID_QUERY_HELP`: | x
`ID_QUERY_MENU`: | x
`ID_HOTKEY`: | x
`ID_ACCEL`: | x
`ID_UNPOST`: | x
`ID_POST`: | x
`ID_MDI_TILEHORIZONTAL`: | x
`ID_MDI_TILEVERTICAL`: | x
`ID_MDI_CASCADE`: | x
`ID_MDI_MAXIMIZE`: | x
`ID_MDI_MINIMIZE`: | x
`ID_MDI_RESTORE`: | x
`ID_MDI_CLOSE`: | x
`ID_MDI_WINDOW`: | x
`ID_MDI_MENUWINDOW`: | x
`ID_MDI_MENUMINIMIZE`: | x
`ID_MDI_MENURESTORE`: | x
`ID_MDI_MENUCLOSE`: | x
`ID_MDI_NEXT`: | x
`ID_MDI_PREV`: | x
`ID_CLOSE_DOCUMENT`: | Close active document
`ID_CLOSE_ALL_DOCUMENTS`: | Close all documents

Methods

acceptDrop acquireClipboard acquireSelection active? addHotKey beginDrag canFocus? childAtIndex childOf? children clearDragRectangle colorType colorTypeName commonAncestor composite? contains? containsChild? create cursorPosition default? defaultHeight defaultWidth deleteType deleteTypeName destroy detach didAccept disable doesSaveUnder? dragging? dropDisable dropEnable dropEnabled? dropTarget? each_child enable enabled? endDrag forceRefresh getChildAt getDNDData getHeightForWidth getWidthForHeight grab grabKeyboard grabbed? grabbedKeyboard? handleDrag hasClipboard? hasFocus? hasSelection? hide indexOfChild initial? inquireDNDAction inquireDNDTypes killFocus linkAfter linkBefore lower move new offeredDNDType? position raise recalc releaseClipboard releaseSelection remHotKey removeChild repaint repaint reparent resize scroll setCursorPosition setDNDData setDefault setDragRectangle setFocus setInitial shell? show shown? stringType textType textTypeName translateCoordinatesFrom translateCoordinatesTo underCursor? ungrab ungrabKeyboard update update urilistType urilistTypeName

Attributes

accelTable | [RW] | The accelerator table for this window [FXAccelTable]
backColor | [RW] | Window background color [FXColor]
defaultCursor | [RW] | Default cursor for this window [FXCursor]
dragCursor | [RW] | Drag cursor for this window [FXCursor]
first | [R] | This window’s first child window, if any [FXWindow]
focus | [R] | Currently focused child window, if any [FXWindow]
height | [RW] | Window height, in pixels [Integer]
key | [RW] | Window key [Integer]
last | [R] | This window’s last child window, if any [FXWindow]
layoutHints | [RW] | Layout hints for this window [Integer]
next | [R] | Next (sibling) window, if any [FXWindow]
numChildren | [R] | Number of child windows for this window [Integer]
owner | [R] | This window’s owner window [FXWindow]
parent | [R] | This window’s parent window [FXWindow]
prev | [R] | Previous (sibling) window, if any [FXWindow]
root | [R] | Root window [FXWindow]
selector | [RW] | Message identifier for this window [Integer]
shell | [R] | The shell window for this window [FXWindow]
target | [RW] | Message target object for this window [FXObject]
width | [RW] | Window width, in pixels [Integer]
x | [RW] | This window’s x-coordinate, in the parent’s coordinate system [Integer]
y | [RW] | This window’s y-coordinate, in the parent’s coordinate system [Integer]

Included modules

Responder2

Public Class methods

deleteType()

Common DND type: Delete request

textType()

Common DND type: ASCII text

stringType()

Common DND type: Clipboard text type (pre-registered)

colorType()

Common DND type: Color

urilistType()

Common DND type: URI List

deleteTypeName()

Common DND type name: Delete request

textTypeName()

Common DND type name: ASCII text

colorTypeName()

Common DND type name: Color

urilistTypeName()

Common DND type name: URI List

new(parent, opts=0, x=0, y=0, w=0, h=0) {|theWindow| ...}

Constructor

commonAncestor(a, b)

Return the common ancestor of window a and window b.

Public Instance methods

defaultWidth()

Return the default width of this window

defaultHeight()

Return the default height of this window

getWidthForHeight(givenHeight)

Return width for given height

getHeightForWidth(givenWidth)

Return height for given width

addHotKey(code)

Add this hot key to the closest ancestor’s accelerator table.

remHotKey(code)

Remove this hot key from the closest ancestor’s accelerator table.

shell?()

Return `true` if this window is a shell window.

childOf?(window)

Return `true` if window is this window’s parent.

containsChild?(child)

Return `true` if child is a child of this window.

getChildAt(x, y)

Return the child window at specified coordinates (x, y)

indexOfChild(window)

Return the index (starting from zero) of the specified child window, or -1 if the window is not a child of this window.

removeChild(child)

Remove specified child window

children()

Returns an array containing all child windows of this window

childAtIndex(index)

Return the child window at specified index. Raises IndexError if index is out of range.

cursorPosition()

Return the cursor position and mouse button-state as a three-element array.

setCursorPosition(x, y)

Warp the cursor to the new position (x, y).

enabled?()

Return `true` if this window is able to receive mouse and keyboard events.

active?()

Return `true` if this window is active.

canFocus?()

Return `true` if this window is a control capable of receiving the focus.

hasFocus?()

Return `true` if this window has the focus.

setFocus()

Move the focus to this window.

killFocus()

Remove the focus from this window.

setDefault(enable=TRUE)

This changes the default window which responds to the Enter key in a dialog. If enable is `true`, this window becomes the default window; when enable is `false`, this window will no longer be the default window. Finally, when enable is `MAYBE`, the default window will revert to the initial default window.

default?()

Return `true` if this is the default window.

setInitial(enable=true)

Make this window the initial default window.

initial?()

Return `true` if this is the initial default window.

enable()

Enable the window to receive mouse and keyboard events.

disable()

Disable the window from receiving mouse and keyboard events.

create()

Create all of the server-side resources for this window.

detach()

Detach the server-side resources for this window.

destroy()

Destroy the server-side resources for this window.

raise()

Raise this window to the top of the stacking order.

lower()

Lower this window to the bottom of the stacking order.

move(x, y)

Move this window to the specified position (x, y) in the parent’s coordinates.

resize(w, h)

Resize this window to the specified width and height (w, h).

position(x, y, w, h)

Move and resize this window in the parent’s coordinates.

recalc()

Mark this window’s layout as dirty

forceRefresh()

Force a GUI update of this window and its children

reparent(newParent)

Change the parent for this window to newParent.

scroll(x, y, w, h, dx, dy)

Scroll rectangle (x, y, w, h) by a shift of (dx, dy)

update()

Mark the entire window client area dirty.

update(x, y, w, h)

Mark the specified rectangle dirty

repaint(x, y, w, h)

If marked but not yet painted, paint the given area

repaint()

If marked but not yet painted, paint the entire window

grab()

Grab the mouse to this window; future mouse events will be reported to this window even while the cursor goes outside of this window

ungrab()

Release the mouse grab

grabbed?()

Return `true` if the window has been grabbed

grabKeyboard()

Grab keyboard device

ungrabKeyboard()

Ungrab keyboard device

grabbedKeyboard?()

Return `true` if active grab is in effect

show()

Show this window

hide()

Hide this window

shown?()

Return `true` if this window is shown.

composite?()

Return `true` if this window is a composite.

underCursor?()

Return `true` if this window is under the cursor

hasSelection?()

Return `true` if this window owns the primary selection

acquireSelection(typesArray)

Try to acquire the primary selection, given an array of drag types

releaseSelection()

Release the primary selection

hasClipboard?()

Return `true` if this window owns the clipboard

acquireClipboard(typesArray)

Try to acquire the clipboard, given an array of drag types

releaseClipboard()

Release the clipboard

dropEnable()

Enable this window to receive drops

dropDisable()

Disable this window from receiving drops

dropEnabled?()

Return `true` if this window is able to receive drops

dragging?()

Return `true` if a drag operation has been initiated from this window

beginDrag(typesArray)

Initiate a drag operation with an array of previously registered drag types

handleDrag(x, y, action=DRAG_COPY)

When dragging, inform the drop target of the new position and the drag action. The action is a constant, one of:

`DRAG_REJECT`: | reject all drop actions
`DRAG_ACCEPT`: | accept any drop action
`DRAG_COPY`: | accept this drop as a copy
`DRAG_MOVE`: | accept this drop as a move
`DRAG_LINK`: | accept this drop as a link
`DRAG_PRIVATE`: | private

endDrag(drop=true)

Terminate the drag operation with or without actually dropping the data

dropTarget?()

Return `true` if this window is the target of a drop

setDragRectangle(x, y, w, h, wantUpdates=true)

When being dragged over, indicate that no further `SEL_DND_MOTION` messages are required while the cursor is inside the given rectangle

clearDragRectangle()

When being dragged over, indicate we want to receive `SEL_DND_MOTION` messages every time the cursor moves

acceptDrop(action=DRAG_ACCEPT)

When being dragged over, indicate acceptance or rejection of the dragged data. The action is a constant indicating the suggested drag action, one of:

`DRAG_REJECT`: | reject all drop actions
`DRAG_ACCEPT`: | accept any drop action
`DRAG_COPY`: | accept this drop as a copy
`DRAG_MOVE`: | accept this drop as a move
`DRAG_LINK`: | accept this drop as a link
`DRAG_PRIVATE`: | private

didAccept()

Returns `DRAG_REJECT` when the drop target would not accept the drop; otherwise indicates acceptance by returning one of `DRAG_ACCEPT`, `DRAG_COPY`, `DRAG_MOVE` or `DRAG_LINK`.

inquireDNDTypes(origin)

When being dragged over, inquire the drag types being offered. The origin is a constant indicating the origin of the data, one of `FROM_SELECTION`, `FROM_CLIPBOARD` or `FROM_DRAGNDROP`. Returns an array of drag types.

offeredDNDType?(origin, type)

When being dragged over, return `true` if we are offered the given drag type. The origin is a constant indicating the origin of the data, one of `FROM_SELECTION`, `FROM_CLIPBOARD` or `FROM_DRAGNDROP`. The type is a previously registered drag type.

inquireDNDAction()

When being dragged over, return the drag action

getDNDData(origin, type)

Get DND data; the caller becomes the owner of the array. The origin is a constant indicating the origin of the data, one of `FROM_SELECTION`, `FROM_CLIPBOARD` or `FROM_DRAGNDROP`. The type is a previously registered drag type.

setDNDData(origin, type, data)

Set DND data; ownership is transferred to the system. The origin is a constant indicating the origin of the data, one of `FROM_SELECTION`, `FROM_CLIPBOARD` or `FROM_DRAGNDROP`. The type is a previously registered drag type.

contains?(parentX, parentY)

Return `true` if this window logically contains the given point (parentX, parentY).

translateCoordinatesFrom(fromWindow, fromX, fromY)

Translate coordinates (fromX, fromY) from fromWindow’s coordinate system to this window’s coordinate system. Returns a two-element array containing the coordinates in this window’s coordinate system.

translateCoordinatesTo(toWindow, fromX, fromY)

Translate coordinates (fromX, fromY) from this window’s coordinate system to toWindow’s coordinate system. Returns a two-element array containing the coordinates in toWindow’s coordinate system.

linkBefore(sibling)

Relink this window before sibling in the parent’s window list.

linkAfter(sibling)

Relink this window after sibling in the parent’ window list.

doesSaveUnder?()

Return `true` if this window does save-unders.

each_child() {|child| ...}

Iterate over the child windows for this window.