Haiku API Bindings
Window
Not logged in

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)

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()

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)

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:

Perl

$window->GetDecoratorSettings();
$window->SetDecoratorSettings($settings);

Python

window.GetDecoratorSettings()
window.SetDecoratorSettings(settings)

DefaultButton

SetDefaultButton

Gets or sets the Button mapped to the Enter key.

Perl

$window->DefaultButton();
$window->SetDefaultButton($button);

Python

window.DefaultButton()
window.SetDefaultButton(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)

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)

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)

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()

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()

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)

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()

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)

Title

SetTitle

Gets or sets the Window's title.

Perl

$window->Title();
$window->SetTitle($newTitle);

Python

window.Title()
window.SetTitle(newTitle)

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,
)

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)

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)

HOOKS

FrameMoved

Called when the Window is moved.

Perl

$window->FrameMoved($newPosition);

Python

window.FrameMoved(newPosition)

FrameResized

Called when the Window is resized.

Perl

$window->FrameResized($newWidth, $newHeight);

Python

window.FrameResized(newWidth, newHeight)

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)

WindowActivated

Called when the Window is activated or deactivated.

Perl

$window->WindowActivated($state);

Python

window.WindowActivated(state)

WorkspaceActivated

Called when the Window's workspace is activated or deactivated.

Perl

$window->WorkspaceActivated($workspace, $state);

Python

window.WorkspaceActivated(workspace, state)

WorkspacesChanged

Called when the Window is added to or removed from a workspace.

Perl

$window->WorkspacesChanged($oldWorkspaces, $newWorkspaces);

Python

window.WorkspacesChanged(oldWorkspaces, newWorkspaces)

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.

Window alignment

Perl

use HaikuR1::Window qw(:window_alignment)

Python

Python does not support export tags.

Window feel

Perl

use HaikuR1::Window qw(:window_feel)

Python

Python does not support export tags.

Window flags

Perl

use HaikuR1::Window qw(:window_flags)

Python

Python does not support export tags.

Window look

Perl

use HaikuR1::Window qw(:window_look)

Python

Python does not support export tags.

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.

Workspaces

Perl

use HaikuR1::Window qw(:workspaces)

Python

Python does not support export tags.

SCRIPTING SUITE

The name of Window's scripting suite is suite/vnd.Be-window.

Window also inherits the following suites:

SEE ALSO

Layout-related Window methods.