Haiku API Bindings
View
Not logged in

Documentation | InterfaceKit | View

SYNOPSIS

Perl

use HaikuR1::Application;
use HaikuR1::Window;
use HaikuR1::View;

# define MyApplication, MyWindow, and MyView 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,
);
my $view = MyView->new(
    frame        => Rect->new($vleft, $vtop, $vright, $vbottom),
    name         => $name,
    resizingMode => $resizing_mode,
    flags        = >$vflags,
);
$window->AddChild($view);

$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
from HaikuR1.InterfaceKit import View

# define MyApplication, MyWindow, and MyView 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,
)
view = MyView(
    frame        = Rect(vleft, vtop, vright, vbottom),
    name         = name,
    resizingMode = resizing_mode,
    flags        = >vflags,
)
window.AddChild(view)

window.Show()
app.Run()

# wait for an event to Quit the app or window

DESCRIPTION

Exposes the BView object.

For more information on View, see the Be Book class description, the Be Book overview, and the Haiku Book class description.

METHODS

In addition to the methods described here, there are also drawing operations and Layout-related methods.

While the majority of the drawing functions are not necessary for using standard Views, there are a few that are of more general use:

Constructor

Creates a View.

Perl

HaikuR1::View->new(
    frame        => $frame,
    name         => $name,
    resizingMode => $resizingMode,
    flags        => $flags,
);
HaikuR1::View->new(
    name   => $name,
    flags  => $flags,
    layout => $layout,
);
HaikuR1::View->new($archive);

Python

View(
    frame        = frame,
    name         = name,
    resizingMode = resizingMode,
    flags        = flags,
)
View(
    name   = name,
    flags  = flags,
    layout = layout,
)
View(archive)

Background bitmaps

SetViewBitmap

ClearViewBitmap

SetViewOverlay

ClearViewOverlay

Sets or clears the View's background or overlay Bitmap.

Perl

$view->SetViewBitmap(
    bitmap => $bitmap,
    srcRect => $srcRect,
    dstRect => $dstRect,
    followFlags => $followFlags,
    options => $options,
);
$view->ClearViewBitmap();
$view->SetViewOverlay(
    bitmap => $bitmap,
    srcRect => $srcRect,
    dstRect => $dstRect,
    colorKey => $colorKey,
    followFlags => $followFlags,
    options => $options,
);
$view->ClearViewOverlay();

Python

view.SetViewBitmap(
    bitmap = bitmap,
    srcRect = srcRect,
    dstRect = dstRect,
    followFlags = followFlags,
    options = options,
)
view.ClearViewBitmap()
view.SetViewOverlay(
    bitmap = bitmap,
    srcRect = srcRect,
    dstRect = dstRect,
    colorKey = colorKey,
    followFlags = followFlags,
    options = options,
)
view.ClearViewOverlay()

Bounds

Frame

LeftTop

Returns the View's bounding rectangle; Bounds returns it in the View's own coordinate system, while Frame returns it in the parent's coordinate system. The Bounds rectangle represents the visible rectangle; therefore it may not always originate at 0,0.

LeftTop returns the upper left coordinate of the View as a Point; this is the left top point of the Bounds rectangle.

Perl

$view->Bounds();
$view->Frame();
$view->LeftTop();

Python

view.Bounds()
view.Frame()
view.LeftTop()

Child Views

AddChild

ChildAt

CountChildren

Parent

NextSibling

PreviousSibling

FindView

RemoveChild

These methods do what you expect. ChildAt, Parent, NextSibling, and PreviousSibling return a View object.

Note that Parent will return NULL if the View's immediate parent is a Window instead of a View.

Perl

$view->AddChild($view, $sibling);
$view->ChildAt($index);
$view->CountChildren();
$view->Parent();
$view->NextSibling();
$view->PreviousSibling();
$view->FindView($name);
$view->RemoveChild($view);

Python

view.AddChild(view, sibling)
view.ChildAt(index)
view.CountChildren()
view.Parent()
view.NextSibling()
view.PreviousSibling()
view.FindView(name)
view.RemoveChild(view)

Coordinate Conversion

ConvertToScreen

ConvertFromScreen

ConvertToParent

ConvertFromParent

These methods do what you expect.

Perl

$view->ConvertToScreen($viewPoint);
$view->ConvertToScreen($viewRect);
$view->ConvertFromScreen($screenPoint);
$view->ConvertFromScreen($screenRect);
$view->ConvertToParent($viewPoint);
$view->ConvertToParent($viewRect);
$view->ConvertFromParent($parentPoint);
$view->ConvertFromParent($parentRect);

Python

view.ConvertToScreen(viewPoint)
view.ConvertToScreen(viewRect)
view.ConvertFromScreen(screenPoint)
view.ConvertFromScreen(screenRect)
view.ConvertToParent(viewPoint)
view.ConvertToParent(viewRect)
view.ConvertFromParent(parentPoint)
view.ConvertFromParent(parentRect)

CopyBits

Copies bits from one rectangle to another, scaling if necessary.

Perl

$view->CopyBits($src, $dst);

Python

view.CopyBits(src, dst)

DragMessage

For more information on dragging, see the BeBook section on Drag And Drop.

Starts a drag-and-drop session.

Perl

$view->DragMessage(
    message     => $message,
    bitmap      => $bitmap,
    dragMode    => $dragMode,
    point       => $point,
    replyTarget => $replyTarget,
);
$view->DragMessage(
    message     => $message,
    rect        => $rect,
    replyTarget => $replyTarget,
);

Python

view.DragMessage(
    message     = message,
    bitmap      = bitmap,
    dragMode    = dragMode,
    point       = point,
    replyTarget = replyTarget,
)
view.DragMessage(
    message     = message,
    rect        = rect,
    replyTarget = replyTarget,
)

EventMask

SetEventMask

SetMouseEventMask

Gets or sets the event mask, allowing the View to receive mouse events when the mouse isn't over the View, and/or keyboard events when the View does not have focus.

SetMouseEventMask can only be called during a MouseDown hook; in other cases it will do nothing and return B_ERROR. It will not work to call the hook yourself; it must be legitimate hook triggered in response to a B_MOUSE_DOWN message. The mask will be added to the current event mask for the remainder of the hook.

Perl

$view->EventMask();
$view->SetEventMask($mask, $options);
$view->SetMouseEventMask($mask, $options);

Python

view.EventMask()
view.SetEventMask(mask, options)
view.SetMouseEventMask(mask, options)

FillRule

SetFillRule

Gets or sets the View's fill rule (the way it fills shapes).

Perl

$view->FillRule();
$view->SetFillRule($rule);

Python

view.FillRule()
view.SetFillRule(rule)

Flags

SetFlags

Gets or sets the View's flags.

SetFlags can also also called as a hook.

Perl

$view->Flags();
$view->SetFlags($flags);

Python

view.Flags()
view.SetFlags(flags)

Flushing and Synching

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

$view->Flush();
$view->Sync();

Python

view.Flush()
view.Sync()

Font

ForceFontAliasing

GetFontHeight

These functions do what you expect. The return value of GetFontHeight is a font_height structure.

Perl

$view->ForceFontAliasing($enable);
$view->GetFontHeight();

Python

view.ForceFontAliasing(enable)
view.GetFontHeight()

GetMouse

Gets the mouse location and state. Returns a Point and a numeric value, one of the mouse button constants.

Perl

$view->GetMouse($checkMessageQueue);

Python

view.GetMouse(checkMessageQueue)

Invalidate

DelayedInvalidate

Marks the View, or a portion of it, as invalid, so it will be redrawn.

Perl

$view->Invalidate();
$view->Invalidate($rect);
$view->Invalidate($region);
$view->DelayedInvalidate($delay);
$view->DelayedInvalidate($delay, $rect);

Python

view.Invalidate()
view.Invalidate(rect)
view.Invalidate(region)
view.DelayedInvalidate(delay)
view.DelayedInvalidate(delay, rect)

IsFocus

Returns true if the View has the focus in its Window.

Perl

$view->IsFocus();

Python

view.IsFocus()

IsHidden

Returns true if the View is hidden.

If looking_from is omitted, or is provided but is not an ancestor of the View, then if the View or any ancestor View is hidden, the function will return true (i.e., will indicate that the View is hidden). Note that ancestor here includes the owner Window; that is, if the owner Window is hidden, the View is also hidden.

If looking_from is provided and is an ancestor of the View, then it will only check ancestors between the View and looking_from; if all of these (including looking_from itself) are visible, then the View is visible from the point of view of looking_from (even if it is in fact not visible on the screen).

Perl

$view->IsHidden();
$view->IsHidden($looking_from);

Python

view.IsHidden()
view.IsHidden(looking_from)

IsPrinting

Returns true if the View is printing.

Perl

$view->IsPrinting();

Python

view.IsPrinting()

MoveTo

MoveBy

Moves the View to or by the given coordinates.

Perl

$view->MoveTo($where);
$view->MoveTo($x, $y);
$view->MoveBy($horizontal, $vertical);

Python

view.MoveTo(where)
view.MoveTo(x, y)
view.MoveBy(horizontal, vertical)

Floating point numbers, the new coordinates or the offsets to the new coordinates.

ResizeTo

ResizeBy

Changes the View's size to or by the given dimensions.

Perl

$view->ResizeTo($size);
$view->ResizeTo($width, $height);
$view->ResizeBy($width, $height);

Python

view.ResizeTo(size)
view.ResizeTo(width, height)
view.ResizeBy(width, height)

ResizingMode

SetResizingMode

Gets or sets the View's resizing mode.

Perl

$view->ResizingMode();
$view->SetResizingMode($mode);

Python

view.ResizingMode()
view.SetResizingMode(mode)

ScrollBar

Returns the View's [ScrollBar](ScrollBar.html), or the
empty value if there is no Scrollbar.

Perl

$view->ScrollBar($posture);

Python

view.ScrollBar(posture)

ScrollTo

ScrollBy

Scrolls the View to or by the given coordinates.

The Set methods also serve as hooks. If you override these methods in a subclass, be aware that while an rgb_color may be either a native list or a native map, when the hook is called from C++ code, a map will be passed to your hook.

Perl

$view->ScrollTo($where);
$view->ScrollTo($x, $y);
$view->ScrollBy($x, $y);

Python

view.ScrollTo(where)
view.ScrollTo(x, y)
view.ScrollBy(x, y)

ScrollWithMouseWheelDelta

This method is mostly used internally; you may need to use it in a hook in a custom View, but otherwise you will not need to call it yourself.

Perl

$view->ScrollWithMouseWheelDelta($direction, $delta);

Python

view.ScrollWithMouseWheelDelta(direction, delta)

SetViewCursor

Sets the View's cursor.

Perl

$view->SetViewCursor($cursor, $sync);

Python

view.SetViewCursor(cursor, sync)

String Widths

TruncateString

StringWidth

GetStringWidths

These methods do what you expect.

Perl

$view->TruncateString($string, $mode, $width);
$view->StringWidth($string);
$view->GetStringWidths($strings);

Python

view.TruncateString(string, mode, width)
view.StringWidth(string)
view.GetStringWidths(strings)

ToolTip

SetToolTip

ShowToolTip

HideToolTip

Sets the tooltip.

Perl

$view->ToolTip($class);
$view->SetToolTip($tip);
$view->SetToolTip($text);
$view->ShowToolTip($tip);                                                                                                       
$view->HideToolTip();

Python

view.ToolTip(class)
view.SetToolTip(tip)
view.SetToolTip(text)
view.ShowToolTip(tip)
view.HideToolTip()

Tracking Rectangles

BeginRectTracking

EndRectTracking

Starts or stops displaying a rectangular outline that follows the cursor.

Perl

$view->BeginRectTracking($rect, $how);
$view->EndRectTracking();

Python

view.BeginRectTracking(rect, how)
view.EndRectTracking()

Window

RemoveSelf

Window returns the View's owner Window.

RemoveSelf removes this View from the owner Window. Returns true if the View was successfully removed, false if the View could not be removed or if the View doesn't belong to a Window.

Perl

$view->Window();
$view->RemoveSelf();

Python

view.Window()
view.RemoveSelf()

HOOKS

AllAttached

Called when all the View's child Views have been attached to a Window; a parent View will received this notification after its children.

Perl

$view->AllAttached();

Python

view.AllAttached()

AllDetached

Called when all the View's child Views have been detached from a Window; a parent View will received this notification after its children.

Perl

$view->AllDetached();

Python

view.AllDetached()

AttachedToWindow

Called when the View has been attached to a Window; a parent View will received this notification before its children.

Perl

$view->AttachedToWindow();

Python

view.AttachedToWindow()

DetachedFromWindow

Called when the View has been detached from a Window; a parent View will received this notification before its children.

Perl

$view->DetachedFromWindow();

Python

view.DetachedFromWindow()

FrameMoved

Called when the View has moved within its owning Window.

Perl

$view->FrameMoved($newPosition);

Python

view.FrameMoved(newPosition)

FrameResized

Called when the View has been resized.

Perl

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

Python

view.FrameResized(newWidth, newHeight)

GetPreferredSize

Gets the View's preferred size.

Perl

$view->GetPreferredSize();

Python

view.GetPreferredSize()

GetToolTipAt

Called when the user hovers over a point. You should return the ToolTip that should be shown.

Perl

$view->GetToolTipAt($point);

Python

view.GetToolTipAt(point)

Hide

Hides the View.

Perl

$view->Hide();

Python

view.Hide()

KeyDown

Called when the user presses a key while the View has focus.

Perl

$view->KeyDown($bytes);

Python

view.KeyDown(bytes)

KeyUp

Called when the user releases a key while the View has focus.

Perl

$view->KeyUp($bytes);

Python

view.KeyUp(bytes)

MakeFocus

Makes the view focused (or not focused) within its Window.

Perl

$view->MakeFocus($focused);

Python

view.MakeFocus(focused)

MouseDown

Called when the user presses the mouse button while the View has focus.

Perl

$view->MouseDown($point);

Python

view.MouseDown(point)

MouseMoved

Called when the user moves the mouse button while the View has focus.

Perl

$view->MouseMoved($point, $transit, $message);

Python

view.MouseMoved(point, transit, message)

MouseUp

Called when the user releases the mouse button while the View has focus.

Perl

$view->MouseUp($point);

Python

view.MouseUp(point)

Pulse

Called periodically, at the rate set by the owning Window's pulse rate.

Perl

$view->Pulse();

Python

view.Pulse()

ResizeToPreferred

Called when the View should be resized to its preferred size.

Perl

$view->ResizeToPreferred();

Python

view.ResizeToPreferred()

Show

Shows the View.

Perl

$view->Show();

Python

view.Show()

TargetedByScrollView

Called when the View becomes the target of a ScrollView.

Perl

$view->TargetedByScrollView($scrollView);

Python

view.TargetedByScrollView(scrollView)

WindowActivated

Called when the View's owning Window is activated or deactivated.

Perl

$view->WindowActivated($state);

Python

view.WindowActivated(state)

ARCHIVABLE INTERFACE

View inherits the methods and hooks of Archivable.

HANDLER INTERFACE

View inherits the methods and hooks of Handler.

CONSTANTS

Event mask

Perl

use HaikuR1::View qw(:event_mask)

Python

Python does not support export tags.

Event mask options

Perl

use HaikuR1::View qw(:event_mask_options)

Python

Python does not support export tags.

Mouse buttons

Perl

use HaikuR1::View qw(:mouse_buttons)

Python

Python does not support export tags.

Mouse transit

Perl

use HaikuR1::View qw(:mouse_transit)

Python

Python does not support export tags.

Resize modes

Perl

use HaikuR1::View qw(:resizing)

Python

Python does not support export tags.

Tracking

Perl

use HaikuR1::View qw(:tracking)

Python

Python does not support export tags.

View flags

Perl

use HaikuR1::View qw(:flags)

Python

Python does not support export tags.

SCRIPTING SUITE

The name of View's scripting suite is suite/vnd.Be-view.

View also inherits the following suites: