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)
frameA Rect that indicates where on the parent Window the View should be. You should not specify a frame on a View that will be added to a parent which uses a Layout.
nameA string, the View's internal name.
resizingModeAn integer, the resizing mode. (See the resizing mode constants.) Should only be specified when there is a frame. Defaults to
B_FOLLOW_NONE.flagsAn integer, view flags. (See the view flag constants.)
layoutA Layout object, indicates how children of this View should be laid out. This can be omitted if the View will not have children.
archiveA Message, contains an archived version of the View.
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()
bitmapA Bitmap, the Bitmap.
srcRectA Rect, the source rectangle; if not given, uses the whole Bitmap.
dstRectA Rect, the destination rectangle; if given, the Bitmap will be scaled to fit; if not given, the Bitmap (or the portion of it selected by
srcRect) will be drawn unscaled starting at the upper left corner of the View.colorKeyAn rgb_color indicating the transparent color for the overlay.
followFlagsA combination of resizing mode constants; determines how the Bitmap is resized when the View is resized; defaults to
B_FOLLOW_TOP | B_FOLLOW_LEFT(i.e., does not resize when the View resizes).optionsAn integer, additional options; currently only the bitmap tiling constants are in use; defaults to
B_TILE_BITMAP.
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)
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.
nameA string, the name of the View to search for.
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)
viewPoint,screenPoint,parentPointA Point to convert.
viewRect,screenRect,parentRectA Rect to convert.
CopyBits
Copies bits from one rectangle to another, scaling if necessary.
Perl
$view->CopyBits($src, $dst);
Python
view.CopyBits(src, dst)
srcA Rect, the source rectangle.
dstA Rect, the destination rectangle.
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,
)
messageA Message, contains the information for the destination View.
bitmapA Bitmap, a bitmap to be used as the drag image.
hotspotA Point, the hotspot within the image.
dragModeAn integer, one of the drawing mode constants; defaults to
B_OP_COPY.offsetA Point, the hotspot within the image.
rectA Rect, a rectangle (in the View's coordinate system) to be used in place of a drag image.
replyTargetA Handler, a handler that the destination View may use to send a reply message to; if NULL, the reply will be sent to the calling View.
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)
maskAn integer, one or more of the event mask constants.
optionsAn integer, one or more of the event mask option constants.
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)
ruleOne of the polygon filling constants.
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)
flagsAn integer, one or more of the flag constants.
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()
enableA boolean; if true, aliasing will be turned off for printing; otherwise, aliasing will be turned on.
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)
checkMessageQueueA boolean, if this parameter is true (the default), then the location and state will be taken from the oldest mouse-moved or mouse-up Message in the Window's message queue. It will also remove that message from the queue. If this parameter is false, or if there are no such messages in the queue, it will report the current location and state.
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)
rectA Rect, the rectangle to invalidate.
regionA Region, the region to invalidate.
delayAn integer, the delay in milliseconds.
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)
looking_fromThe View to look 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)
whereThe new coordinates as a Point.
x,y
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)
sizeThe new coordinates as a Size.
width,heightFloating point numbers, the new dimensions or the differences for the new dimensions.
ResizingMode
SetResizingMode
Gets or sets the View's resizing mode.
Perl
$view->ResizingMode(); $view->SetResizingMode($mode);
Python
view.ResizingMode() view.SetResizingMode(mode)
modeAn integer, one or more of the resizing constants.
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)
postureOne of the orientation constants.
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)
whereThe new coordinates as a Point.
x,yFloating point numbers, the new scroll origin coordinates or the offsets to the new scroll origin.
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)
directionOne of the orientation constants.
deltaA floating point number, the mouse wheel delta. Each unit of delta is equivalent to three of the given ScrollBar's small steps, or if the Shift key is being held down, to one of the ScrollBar's large steps.
SetViewCursor
Sets the View's cursor.
Perl
$view->SetViewCursor($cursor, $sync);
Python
view.SetViewCursor(cursor, sync)
cursorA Cursor object.
syncA boolean; if true, forces a sync with the Application Server so the cursor changes immediately.
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)
stringThe string to truncate or measure.
stringsA native list of strings to measure.
modeAn integer, one of the truncation mode constants.
widthA floating point number, the width to truncate to.
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()
classOptional; a class for the native wrapper object returned by the method; defaults to
ToolTip. (SinceToolTipis not a fully functional class, you probably want to useTextToolTiphere, unless you create your own ToolTip subclass.)tipA ToolTip object to set or show.
textA tooltip string.
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()
rectA Rect, the rectangle to display.
howAn integer, the tracking method, one of the tracking constants.
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)
newPositionA Point, the new position.
FrameResized
Called when the View has been resized.
Perl
$view->FrameResized($newWidth, $newHeight);
Python
view.FrameResized(newWidth, newHeight)
newWidth,newHeightFloating point numbers, the new width and height.
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)
pointA Point, the coordinates where the mouse is hovering.
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)
bytesA string, the character that is mapped to the key pressed, in UTF-8. (This may have been processed by an input filter before it reaches you, so this value may not match the actual key that was pressed.)
KeyUp
Called when the user releases a key while the View has focus.
Perl
$view->KeyUp($bytes);
Python
view.KeyUp(bytes)
bytesA string, the character that is mapped to the key pressed, in UTF-8. (This may have been processed by an input filter before it reaches you, so this value may not match the actual key that was pressed.)
MakeFocus
Makes the view focused (or not focused) within its Window.
Perl
$view->MakeFocus($focused);
Python
view.MakeFocus(focused)
focusedA boolean, if true, the View takes the focus; if false, it loses the focus.
MouseDown
Called when the user presses the mouse button while the View has focus.
Perl
$view->MouseDown($point);
Python
view.MouseDown(point)
pointA Point, the coordinates where the button was pressed.
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)
pointA Point, the cursor's new location.
transitAn integer, the type of movement, as one of the transit constants.
messageA Message containing a dragged bundle of information.
MouseUp
Called when the user releases the mouse button while the View has focus.
Perl
$view->MouseUp($point);
Python
view.MouseUp(point)
pointA Point, the coordinates where the button was released.
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)
scrollViewThe ScrollView that targeted the View.
WindowActivated
Called when the View's owning Window is activated or deactivated.
Perl
$view->WindowActivated($state);
Python
view.WindowActivated(state)
stateA boolean, true if the Window is being activated, false if being deactivated.
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.
- B_POINTER_EVENTS
- B_KEYBOARD_EVENTS
Event mask options
Perl
use HaikuR1::View qw(:event_mask_options)
Python
Python does not support export tags.
- B_LOCK_WINDOW_FOCUS
- B_SUSPEND_VIEW_FOCUS
- B_NO_POINTER_HISTORY
- B_FULL_POINTER_HISTORY
Mouse buttons
Perl
use HaikuR1::View qw(:mouse_buttons)
Python
Python does not support export tags.
- B_PRIMARY_MOUSE_BUTTON
- B_SECONDARY_MOUSE_BUTTON
- B_TERTIARY_MOUSE_BUTTON
Mouse transit
Perl
use HaikuR1::View qw(:mouse_transit)
Python
Python does not support export tags.
- B_ENTERED_VIEW
- B_INSIDE_VIEW
- B_EXITED_VIEW
- B_OUTSIDE_VIEW
Resize modes
Perl
use HaikuR1::View qw(:resizing)
Python
Python does not support export tags.
- B_FOLLOW_NONE
- B_FOLLOW_ALL_SIDES
- B_FOLLOW_ALL
- B_FOLLOW_LEFT
- B_FOLLOW_RIGHT
- B_FOLLOW_LEFT_RIGHT
- B_FOLLOW_H_CENTER
- B_FOLLOW_TOP
- B_FOLLOW_BOTTOM
- B_FOLLOW_TOP_BOTTOM
- B_FOLLOW_V_CENTER
- B_FOLLOW_LEFT_TOP
Tracking
Perl
use HaikuR1::View qw(:tracking)
Python
Python does not support export tags.
- B_TRACK_WHOLE_RECT
- B_TRACK_RECT_CORNER
View flags
Perl
use HaikuR1::View qw(:flags)
Python
Python does not support export tags.
- B_FULL_UPDATE_ON_RESIZE
- B_WILL_DRAW
- B_PULSE_NEEDED
- B_NAVIGABLE_JUMP
- B_FRAME_EVENTS
- B_NAVIGABLE
- B_SUBPIXEL_PRECISE
- B_DRAW_ON_CHILDREN
- B_INPUT_METHOD_AWARE
- B_SUPPORTS_LAYOUT
- B_INVALIDATE_AFTER_LAYOUT
SCRIPTING SUITE
The name of View's scripting suite is suite/vnd.Be-view.
Properties
FrameB_GET_PROPERTY,B_SET_PROPERTYA Rect, the View frame
HiddenB_GET_PROPERTY,B_SET_PROPERTYA boolean, whether the View is hidden
ViewB_COUNT_PROPERTIESGets the number of child Views
Specifiers
ShelfB_DIRECT_SPECIFIERTargets the View's Shelf
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
View also inherits the following suites: