Documentation | InterfaceKit | Window
SYNOPSIS
Perl
use HaikuR1::Application; use HaikuR1::Window qw(B_CURRENT_WORKSPACE); # define MyApplication and MyWindow subclass here my $app = MyApplication->new($signature); my $window = MyWindow->new( frame => Rect->new($left, $top, $right, $bottom), title => $title, type => B_TITLED_WINDOW, flags => B_QUIT_ON_WINDOW_CLOSE, workspaces => B_CURRENT_WORKSPACE, ); $window->Show(); $app->Run(); # wait for an event to Quit the app or window
Python
from HaikuR1.ApplicationKit import Application from HaikuR1.InterfaceKit import Window, B_CURRENT_WORKSPACE # define MyApplication and MyWindow subclass here app = MyApplication(signature) window = MyWindow( frame = Rect(left, top, right, bottom), title = title, type = B_TITLED_WINDOW, flags = B_QUIT_ON_WINDOW_CLOSE, workspaces = B_CURRENT_WORKSPACE, ) window.Show() app.Run() # wait for an event to Quit the app or window
DESCRIPTION
Exposes the BWindow
object.
For more information on Window, see the Be Book class description, the Be Book overview, and the Haiku Book class description.
METHODS
Constructor
Creates a Window.
Perl
HaikuR1::Window->new( frame => $frame, title => $title, type => $type, flags => $flags, workspaces => $workspaces, ); HaikuR1::Window->new( frame => $frame, title => $title, look => $look, feel => $feel, flags => $flags, workspaces => $workspaces, ); HaikuR1::Window->new($archive);
Python
Window( frame = frame, title = title, type = type, flags = flags, workspaces = workspaces, ) Window( frame = frame, title = title, look = look, feel = feel, flags = flags, workspaces = workspaces, ) Window(archive)
frame
A Rect that indicates where on the screen the Window should be.
title
A string, a caption for the Window.
type
An integer window type. (See the window type constants.)
look
An integer window look. (See the window look constants.)
feel
An integer window feel. (See the window feel constants.)
flags
An integer, window flags. (See the window flag constants.)
workspaces
An integer indicating which workspaces the Window should appear in. Defaults to
B_CURRENT_WORKSPACE
.archive
A Message, contains an archived version of the Window.
Activate
IsActive
Activate
activates or deactivates the Window.
IsActive
returns true if the Window is active, false otherwise.
Perl
$window->Activate($flag); $window->IsActive();
Python
window.Activate(flag) window.IsActive()
flag
A boolean, if true, activates; if false, deactivates.
App Server Communication
Flush
Sync
Flush
sends all pending messages to the Application Server and immediately
returns. Sync
sends all pending messages to the Application Server and
returns when they have all been processed.
Perl
$window->Flush(); $window->Sync();
Python
window.Flush() window.Sync()
Bounds
Frame
DecoratorFrame
Size
Returns the Window's bounding rectangle; Bounds
returns it in the Window's
own coordinate system (i.e., the left and top will both be 0
), while
Frame
returns it in the screen's coordinate system.
DecoratorFrame
returns a rectange that includes the decorators (title tab
and borders).
Size
returns the size of the Window's bounding rectangle.
Perl
$window->Bounds(); $window->Frame(); $window->DecoratorFrame(); $window->Size();
Python
window.Bounds() window.Frame() window.DecoratorFrame() window.Size()
Child Views
AddChild
ChildAt
CountChildren
CurrentFocus
FindView
LastMouseMovedView
RemoveChild
These methods do what you expect. ChildAt
returns a View object.
Perl
$window->AddChild($view, $sibling); $window->ChildAt($index); $window->CountChildren(); $window->CurrentFocus(); $window->FindView($viewName); $window->FindView($point); $window->LastMouseMovedView(); $window->RemoveChild($view);
Python
window.AddChild(view, sibling) window.ChildAt(index) window.CountChildren() window.CurrentFocus() window.FindView(viewName) window.FindView(point) window.LastMouseMovedView() window.RemoveChild(view)
view
A View to add or remove.
sibling
A View, if provided, the new View will be added before this View; default is to add the new View at the end.
layout_item
A LayoutItem to add.
index
The integer index of the View to find.
viewName
A string, the name of the View to find.
point
The Point to check.
Coordinate Conversion
ConvertToScreen
ConvertFromScreen
These methods do what you expect.
Perl
$window->ConvertToScreen($windowPoint); $window->ConvertToScreen($windowRect); $window->ConvertFromScreen($screenPoint); $window->ConvertFromScreen($screenRect);
Python
window.ConvertToScreen(windowPoint) window.ConvertToScreen(windowRect) window.ConvertFromScreen(screenPoint) window.ConvertFromScreen(screenRect)
Close
Ends the window's message loop.
Perl
$window->Close();
Python
window.Close()
Decorator Settings
GetDecoratorSettings
SetDecoratorSettings
Gets or sets the Window's decorator settings (tab title frame and border size) as a Message with the following fields:
tab frame
A Rect.
border width
A floating point number.
Perl
$window->GetDecoratorSettings(); $window->SetDecoratorSettings($settings);
Python
window.GetDecoratorSettings() window.SetDecoratorSettings(settings)
settings
A Message.
DefaultButton
SetDefaultButton
Gets or sets the Button mapped to the Enter key.
Perl
$window->DefaultButton(); $window->SetDefaultButton($button);
Python
window.DefaultButton() window.SetDefaultButton(button)
button
The target Button.
Menus
KeyMenuBar
SetKeyMenuBar
Gets or sets the Window's primary menubar, the one that accepts shortcuts sent to the Window.
Perl
$window->KeyMenuBar(); $window->SetKeyMenuBar($bar);
Python
window.KeyMenuBar() window.SetKeyMenuBar(bar)
bar
A MenuBar to set.
Moving and Resizing
MoveBy
MoveTo
ResizeBy
ResizeTo
ResizeToPreferred
CenterIn
CenterOnScreen
MoveOnScreen
MoveOnScreen
makes as much of the Window as possible visible on the screen.
It will resize the Window unless you tell it not to with the flags. If the
Window will not fit and cannot be resized, the upper left corner will be made
visible.
The other methods do what you expect.
Perl
$window->MoveBy($horizontal, $vertical); $window->MoveTo($x, $y); $window->MoveTo($where); $window->ResizeBy($horizontal, $vertical); $window->ResizeTo($width, $height); $window->ResizeToPreferred(); $window->CenterIn($rect); $window->CenterOnScreen($id); $window->MoveOnScreen($flags);
Python
window.MoveBy(horizontal, vertical) window.MoveTo(x, y) window.MoveTo(where) window.ResizeBy(horizontal, vertical) window.ResizeTo(width, height) window.ResizeToPreferred() window.CenterIn(rect) window.CenterOnScreen(id) window.MoveOnScreen(flags)
horizontal
A floating point number, the horizontal distance.
vertical
A floating point number, the vertical distance.
x
A floating point number, the new
x
coordinate.y
A floating point number, the new
y
coordinate.where
The new origin Point.
width
A floating point number, the new width.
height
A floating point number, the new height.
rect
A Rect to center the Window in.
id
A screen_id, the id of the target screen; if omitted, will use the current screen.
flags
An integer, one or more of the MoveOnScreen flags.
PulseRate
SetPulseRate
Gets or sets the Window's pulse rate (in milliseconds). (Note: the Window's Views, not the Window itself, will receive the Pulse messages.)
Perl
$window->PulseRate(); $window->SetPulseRate($microseconds);
Python
window.PulseRate() window.SetPulseRate(microseconds)
microseconds
An integer, the new pulse rate.
SendBehind
IsFront
SendBehind
sends the Window behind another Window.
IsFont
returns true if the Window is frontmost, false otherwise.
Perl
$window->SendBehind($window); $window->IsFront();
Python
window.SendBehind(window) window.IsFront()
window
The target Window.
Settings
Type
SetType
Look
SetLook
Feel
SetFeel
Flags
SetFlags
IsFloating
IsModal
Perl
$window->Type(); $window->SetType($type); $window->Look(); $window->SetLook($look); $window->Feel(); $window->SetFeel($feel); $window->Flags(); $window->SetFlags($flags); $window->IsFloating(); $window->IsModal();
Python
window.Type() window.SetType(type) window.Look() window.SetLook(look) window.Feel() window.SetFeel(feel) window.Flags() window.SetFlags(flags) window.IsFloating() window.IsModal()
type
The window type.
look
The window look.
feel
The window feel.
flags
The window flags.
Shortcuts
AddShortcut
HasShortcut
RemoveShortcut
These methods do what you expect.
Perl
$window->AddShortcut($key, $modifiers, $message, $target); $window->HasShortcut($key, $modifiers); $window->RemoveShortcut($key, $modifiers);
Python
window.AddShortcut(key, modifiers, message, target) window.HasShortcut(key, modifiers) window.RemoveShortcut(key, modifiers)
key
A character, the key to associate with the shortcut. This value is case-insensitive; if you want to specify an upper-case letter, add
B_SHIFT_KEY
to the modifiers.modifiers
An intger, the modifier keys that should be pressed for the shortcut. (See the modifier key constants.)
message
A Message to send when the shortcut is pressed.
target
The Handler to send the Message to; defaults to the Window itself.
Showing and Hiding
Show
Hide
IsHidden
IsOffscreenWindow
These methods do what you expect.
Note: A Window is not automatically shown when created; you must call Show
to make it visible. In addition, Show
will start the Window's message loop
if it is not already running.
An offscreen Window is a special Window created by a Bitmap to be the owner for the View that the Bitmap draws to. Offscreen Windows should never be shown. (In fact, if you Show() an offscreen Window, then your app will crash when the Bitmap is destroyed.)
See also Looper.Run.
Perl
$window->Show(); $window->Hide(); $window->IsHidden();
Python
window.Show() window.Hide() window.IsHidden()
Size Limits
GetSizeLimits
SetSizeLimits
UpdateSizeLimits
Gets or sets the Window's size limits.
GetSizeLimits
returns a 4-element
native list.
Perl
GetSizeLimits
returns a list, not an arrayref.
UpdateSizeLimits
sets the Window's size limits to those of the (internal)
topmost view.
Perl
$window->GetSizeLimits(); $window->SetSizeLimits( minWidth => $minWidth, maxWidth => $maxWidth, minHeight => $minHeight, maxHeight => $maxHeight, ); $window->UpdateSizeLimits();
Python
window.GetSizeLimits() window.SetSizeLimits( minWidth = minWidth, maxWidth = maxWidth, minHeight = minHeight, maxHeight = maxHeight, ) window.UpdateSizeLimits()
minWidth
A floating point number, the minimum width.
maxWidth
A floating point number, the maximum width.
minHeight
A floating point number, the minimum height.
maxHeight
A floating point number, the maximum height.
Subsets
AddToSubset
RemoveFromSubset
Adds a Window to, or removes it from, this Window's subset (see window feel).
Perl
$window->AddToSubset($window); $window->RemoveFromSubset($window);
Python
window.AddToSubset(window) window.RemoveFromSubset(window)
window
A Window, the Window to add or remove.
Title
SetTitle
Gets or sets the Window's title.
Perl
$window->Title(); $window->SetTitle($newTitle);
Python
window.Title() window.SetTitle(newTitle)
newTitle
A string, the new title.
Updates
NeedsUpdate
UpdateIfNeeded
DisableUpdates
EnableUpdates
The methods do what you expect. ("Update" here means redraw.)
Note: disabled updates are merely postponed, not discarded.
Perl
$window->NeedsUpdate(); $window->UpdateIfNeeded(); $window->DisableUpdates(); $window->EnableUpdates();
Python
window.NeedsUpdate() window.UpdateIfNeeded() window.DisableUpdates() window.EnableUpdates()
View Transactions
BeginViewTransaction
EndViewTransaction
InViewTransaction
A view transaction is a series of drawing operations on Views.
Any such drawing operations called between BeginViewTransaction
and
EndViewTransaction
will be "saved up" and only drawn to the screen after
EndViewTransaction
.
Perl
$window->BeginViewTransaction(); $window->EndViewTransaction(); $window->InViewTransaction();
Python
window.BeginViewTransaction() window.EndViewTransaction() window.InViewTransaction()
Window Alignment
GetWindowAlignment
SetWindowAlignment
Sets the alignment for the Window.
GetWindowAlignment
returns a 9-element
native list.
Perl
GetWindowAlignment
returns a list, not an arrayref.
> warning!
These methods are not yet implemented in Haiku's Application Server, so calling them will not do anything.
Perl
$window->GetWindowAlignment(); $window->SetWindowAlignment( mode => $mode, h => $h, hOffset => $hOffset, width => $width, widthOffset => $widthOffset, v => $v, vOffset => $vOffset, height => $height, heightOffset => $heightOffset, );
Python
window.GetWindowAlignment() window.SetWindowAlignment( mode = mode, h = h, hOffset = hOffset, width = width, widthOffset = widthOffset, v = v, vOffset = vOffset, height = height, heightOffset = heightOffset, )
mode
One of the window alignment constants.
h
An integer, horizontal step.
hOffset
An integer, horizontal offset.
width
An integer, width step.
widthOffset
An integer, width offset.
v
An integer, vertical step.
vOffset
An integer, vertical offset.
height
An integer, height step.
heightOffset
An integer, height offset.
Workspaces
SetWorkspaces
Gets or sets the workspaces in which the Window is present. This number is a
32-bit integer; each set bit indicates a workspace in which the Window is
present; i.e., the value 1
(with the 0
bit set) means the Window is
present in the first workspace.
Perl
$window->Workspaces(); $window->SetWorkspaces($workspaces);
Python
window.Workspaces() window.SetWorkspaces(workspaces)
workspaces
A 32-bit integer.
Zooming and Minimizing
Zoom
Minimize
IsMinimized
SetZoomLimits
Zoom
increases a Window to its largest size; this is more or less what is
called "maximizing" on other systems. It can also be called as a hook; the
hook version provides three arguments, while the non-hook version takes
none.
If you want to override Zoom
in your subclass, do something like this:
Perl
sub Zoom { my $self = shift; # if no arguments, this is the non-hook version, just call the base class version unless (@_) { $self->SUPER::Zoom(); return; } my ($origin, $width, $height) = @_; # override arguments as desired $self->SUPER::Zoom($origin, $width, $height); }
Python
def Zoom(self, origin=None width=None, height=None): # if no arguments, this is the non-hook version, just call the base class version if origin is None: super(TestWindow, self).Zoom() return # override arguments as desired super(TestWindow, self).Zoom(origin, width, height)
Maximize
can also be called as a hook; both hook and non-hook take the
same arguments.
IsMinimized
does what you expect.
SetZoomLimits
allows you to set a maximum zoomed size for a Window. A
Window can only be zoomed to the intersection of the zoom limits, the size
limits, and the screen size.
Perl
$window->Zoom($origin, $width, $height); # hook version $window->Zoom(); # non-hook version $window->Minimize($minimize); $window->IsMinimized(); $window->SetZoomLimits($maxWidth, $maxHeight);
Python
window.Zoom(origin, width, height); # hook version window.Zoom(); # non-hook version window.Minimize(minimize) window.IsMinimized() window.SetZoomLimits(maxWidth, maxHeight)
origin
A Point, the new origin.
width
A floating point number, the new width.
height
A floating point number, the new height.
minimize
A boolean, if true, minimizes the Window; otherwise unminimizes it.
maxWidth
A floating point number, the maximum zoom width.
maxHeight
A floating point number, the maximum zoom height.
HOOKS
FrameMoved
Called when the Window is moved.
Perl
$window->FrameMoved($newPosition);
Python
window.FrameMoved(newPosition)
newPosition
A Point containing the new position.
FrameResized
Called when the Window is resized.
Perl
$window->FrameResized($newWidth, $newHeight);
Python
window.FrameResized(newWidth, newHeight)
newWidth
A floating point number, the new width.
newHeight
A floating point number, the new height.
MenusBeginning
Called when the menu is about to be shown.
Perl
$window->MenusBeginning();
Python
window.MenusBeginning()
MenusEnded
Called when the menu has been removed.
Perl
$window->MenusEnded();
Python
window.MenusEnded()
ScreenChanged
Called when the screen changes.
Perl
$window->ScreenChanged($screenSize, $format);
Python
window.ScreenChanged(screenSize, format)
screenSize
A Rect, the size of new screen.
format
The color space of the new screen.
WindowActivated
Called when the Window is activated or deactivated.
Perl
$window->WindowActivated($state);
Python
window.WindowActivated(state)
state
A boolean, this parameter will be true if the window is being activated, false if deactivated.
WorkspaceActivated
Called when the Window's workspace is activated or deactivated.
Perl
$window->WorkspaceActivated($workspace, $state);
Python
window.WorkspaceActivated(workspace, state)
workspace
An integer, the workspace that has been activated or deactivated.
state
A boolean, this will be true if the workspace has been acitvated; false if deactivated.
WorkspacesChanged
Called when the Window is added to or removed from a workspace.
Perl
$window->WorkspacesChanged($oldWorkspaces, $newWorkspaces);
Python
window.WorkspacesChanged(oldWorkspaces, newWorkspaces)
oldWorkspaces
An integer, the old workspace.
newWorkspaces
An integer, the new workspace.
ARCHIVABLE INTERFACE
Window
inherits the methods and hooks of Archivable.
HANDLER INTERFACE
Window
inherits the methods and hooks of Handler.
LOOPER INTERFACE
Window
inherits the methods and hooks of Looper.
CONSTANTS
MoveOnScreen flags
Perl
use HaikuR1::Window qw(:move_on_screen)
Python
Python does not support export tags.
- B_DO_NOT_RESIZE_TO_FIT
- B_MOVE_IF_PARTIALLY_OFFSCREEN
Window alignment
Perl
use HaikuR1::Window qw(:window_alignment)
Python
Python does not support export tags.
B_BYTE_ALIGNMENT
The alignment is in frame buffer offsets. (Whatever that means.)
B_PIXEL_ALIGNMENT
The alignment is in pixel coordinates.
Window feel
Perl
use HaikuR1::Window qw(:window_feel)
Python
Python does not support export tags.
B_NORMAL_WINDOW_FEEL
A normal (non-modal, non-floating) window.
B_MODAL_SUBSET_WINDOW_FEEL
A window that is modal with respect to windows in its subset.
B_MODAL_APP_WINDOW_FEEL
A window that is modal with respect to the other windows in its application.
B_MODAL_ALL_WINDOW_FEEL
A window that is modal with respect to all other windows.
B_FLOATING_SUBSET_WINDOW_FEEL
A window that floats above windows in its subset.
B_FLOATING_APP_WINDOW_FEEL
A window that floats above the other windows in its application.
B_FLOATING_ALL_WINDOW_FEEL
A window that floats above all other windows.
Window flags
Perl
use HaikuR1::Window qw(:window_flags)
Python
Python does not support export tags.
- B_NOT_MOVABLE
- B_NOT_CLOSABLE
- B_NOT_ZOOMABLE
- B_NOT_MINIMIZABLE
- B_NOT_RESIZABLE
- B_NOT_H_RESIZABLE
- B_NOT_V_RESIZABLE
- B_AVOID_FRONT
- B_AVOID_FOCUS
B_WILL_ACCEPT_FIRST_CLICK
If this is set, the first mouse click is processed like a normal click; otherwise the first mouse click merely activates the window.
B_OUTLINE_RESIZE
The window does not refresh as it resizes; instead it draws an outline.
B_NO_WORKSPACE_ACTIVATION
When you call Show, the desktop normally switches to the window's workspace; this flag prevents that from happening.
B_NOT_ANCHORED_ON_ACTIVATE
When you select a window from the deskbar, the desktop normally switches to the window's workspace; with this flag, the window is instead brought to the current workspace.
B_ASYNCHRONOUS_CONTROLS
Controls will run asynchronously. All windows with controls should have this set. Haiku sets this flag by default.
B_QUIT_ON_WINDOW_CLOSE
- B_SAME_POSITION_IN_ALL_WORKSPACES
- B_AUTO_UPDATE_SIZE_LIMITS
- B_CLOSE_ON_ESCAPE
- B_NO_SERVER_SIDE_WINDOW_MODIFIERS
Window look
Perl
use HaikuR1::Window qw(:window_look)
Python
Python does not support export tags.
B_BORDERED_WINDOW_LOOK
No title bar, line border, no resize control.
B_NO_BORDER_WINDOW_LOOK
Borderless white rectangle.
B_TITLED_WINDOW_LOOK
Large title bar, thick border, small resize corner.
B_DOCUMENT_WINDOW_LOOK
Large title bar, thick border, resize corner.
B_MODAL_WINDOW_LOOK
No title bar, thick border, no resize control.
B_FLOATING_WINDOW_LOOK
Small title bar, thin border, resize corner.
Window type
Perl
use HaikuR1::Window qw(:window_type)
Python
Python does not support export tags.
Window types are a shortcut for combination of a look and a feel.
B_UNTYPED_WINDOW
No look or type.
B_TITLED_WINDOW
B_TITLED_WINDOW_LOOK
andB_NORMAL_WINDOW_FEEL
B_MODAL_WINDOW
B_MODAL_WINDOW_LOOK
andB_MODAL_APP_WINDOW_FEEL
B_DOCUMENT_WINDOW
B_DOCUMENT_WINDOW_LOOK
andB_NORMAL_WINDOW_FEEL
B_BORDERED_WINDOW
B_BORDERED_WINDOW_LOOK
andB_NORMAL_WINDOW_FEEL
B_FLOATING_WINDOW
B_FLOATING_WINDOW_LOOK
andB_NORMAL_WINDOW_FEEL
Workspaces
Perl
use HaikuR1::Window qw(:workspaces)
Python
Python does not support export tags.
- B_CURRENT_WORKSPACE
- B_ALL_WORKSPACES
SCRIPTING SUITE
The name of Window's scripting suite is suite/vnd.Be-window
.
Properties
Active
B_GET_PROPERTY
,B_SET_PROPERTY
A boolean, whether the Window is active
Feel
B_GET_PROPERTY
,B_SET_PROPERTY
An integer, the Window feel
Flags
B_GET_PROPERTY
,B_SET_PROPERTY
An integer, the Window flags
Frame
B_GET_PROPERTY
,B_SET_PROPERTY
A Rect, the Window frame
Hidden
B_GET_PROPERTY
,B_SET_PROPERTY
A boolean, whether the Window is hidden
Look
B_GET_PROPERTY
,B_SET_PROPERTY
An integer, the Window look
Minimize
B_GET_PROPERTY
,B_SET_PROPERTY
A boolean, whether the Window is minimized
TabFrame
B_GET_PROPERTY
,B_SET_PROPERTY
A Rect, the Window tab frame
Title
B_GET_PROPERTY
,B_SET_PROPERTY
A string, the Window title
Workspaces
B_GET_PROPERTY
,B_SET_PROPERTY
An integer, the workspaces in which the Window is visible
View
B_COUNT_PROPERTIES
Gets the number of Views in the Window
Specifiers
MenuBar
B_DIRECT_SPECIFIER
Targets the Window's KeyMenuBar
View
B_INDEX_SPECIFIER
,B_REVERSE_INDEX_SPECIFIER
Targets the Windows's
index
th View, either from the front or the end of the listB_NAME_SPECIFIER
Targets the View with the given name
Window also inherits the following suites: