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)
frameA Rect that indicates where on the screen the Window should be.
titleA string, a caption for the Window.
typeAn integer window type. (See the window type constants.)
lookAn integer window look. (See the window look constants.)
feelAn integer window feel. (See the window feel constants.)
flagsAn integer, window flags. (See the window flag constants.)
workspacesAn integer indicating which workspaces the Window should appear in. Defaults to
B_CURRENT_WORKSPACE.archiveA 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()
flagA 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)
viewA View to add or remove.
siblingA View, if provided, the new View will be added before this View; default is to add the new View at the end.
layout_itemA LayoutItem to add.
indexThe integer index of the View to find.
viewNameA string, the name of the View to find.
pointThe 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)
settingsA 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)
buttonThe 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)
barA 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)
horizontalA floating point number, the horizontal distance.
verticalA floating point number, the vertical distance.
xA floating point number, the new
xcoordinate.yA floating point number, the new
ycoordinate.whereThe new origin Point.
widthA floating point number, the new width.
heightA floating point number, the new height.
rectA Rect to center the Window in.
idA screen_id, the id of the target screen; if omitted, will use the current screen.
flagsAn 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)
microsecondsAn 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()
windowThe 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()
typeThe window type.
lookThe window look.
feelThe window feel.
flagsThe 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)
keyA 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_KEYto the modifiers.modifiersAn intger, the modifier keys that should be pressed for the shortcut. (See the modifier key constants.)
messageA Message to send when the shortcut is pressed.
targetThe 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()
minWidthA floating point number, the minimum width.
maxWidthA floating point number, the maximum width.
minHeightA floating point number, the minimum height.
maxHeightA 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)
windowA 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)
newTitleA 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,
)
modeOne of the window alignment constants.
hAn integer, horizontal step.
hOffsetAn integer, horizontal offset.
widthAn integer, width step.
widthOffsetAn integer, width offset.
vAn integer, vertical step.
vOffsetAn integer, vertical offset.
heightAn integer, height step.
heightOffsetAn 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)
workspacesA 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)
originA Point, the new origin.
widthA floating point number, the new width.
heightA floating point number, the new height.
minimizeA boolean, if true, minimizes the Window; otherwise unminimizes it.
maxWidthA floating point number, the maximum zoom width.
maxHeightA floating point number, the maximum zoom height.
HOOKS
FrameMoved
Called when the Window is moved.
Perl
$window->FrameMoved($newPosition);
Python
window.FrameMoved(newPosition)
newPositionA Point containing the new position.
FrameResized
Called when the Window is resized.
Perl
$window->FrameResized($newWidth, $newHeight);
Python
window.FrameResized(newWidth, newHeight)
newWidthA floating point number, the new width.
newHeightA 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)
screenSizeA Rect, the size of new screen.
formatThe color space of the new screen.
WindowActivated
Called when the Window is activated or deactivated.
Perl
$window->WindowActivated($state);
Python
window.WindowActivated(state)
stateA 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)
workspaceAn integer, the workspace that has been activated or deactivated.
stateA 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)
oldWorkspacesAn integer, the old workspace.
newWorkspacesAn 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_LOOKandB_NORMAL_WINDOW_FEELB_MODAL_WINDOW
B_MODAL_WINDOW_LOOKandB_MODAL_APP_WINDOW_FEELB_DOCUMENT_WINDOW
B_DOCUMENT_WINDOW_LOOKandB_NORMAL_WINDOW_FEELB_BORDERED_WINDOW
B_BORDERED_WINDOW_LOOKandB_NORMAL_WINDOW_FEELB_FLOATING_WINDOW
B_FLOATING_WINDOW_LOOKandB_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
ActiveB_GET_PROPERTY,B_SET_PROPERTYA boolean, whether the Window is active
FeelB_GET_PROPERTY,B_SET_PROPERTYAn integer, the Window feel
FlagsB_GET_PROPERTY,B_SET_PROPERTYAn integer, the Window flags
FrameB_GET_PROPERTY,B_SET_PROPERTYA Rect, the Window frame
HiddenB_GET_PROPERTY,B_SET_PROPERTYA boolean, whether the Window is hidden
LookB_GET_PROPERTY,B_SET_PROPERTYAn integer, the Window look
MinimizeB_GET_PROPERTY,B_SET_PROPERTYA boolean, whether the Window is minimized
TabFrameB_GET_PROPERTY,B_SET_PROPERTYA Rect, the Window tab frame
TitleB_GET_PROPERTY,B_SET_PROPERTYA string, the Window title
WorkspacesB_GET_PROPERTY,B_SET_PROPERTYAn integer, the workspaces in which the Window is visible
ViewB_COUNT_PROPERTIESGets the number of Views in the Window
Specifiers
MenuBarB_DIRECT_SPECIFIERTargets the Window's KeyMenuBar
ViewB_INDEX_SPECIFIER,B_REVERSE_INDEX_SPECIFIERTargets the Windows's
indexth View, either from the front or the end of the listB_NAME_SPECIFIERTargets the View with the given name
Window also inherits the following suites: