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)
frame
A 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.
name
A string, the View's internal name.
resizingMode
An integer, the resizing mode. (See the resizing mode constants.) Should only be specified when there is a frame. Defaults to
B_FOLLOW_NONE
.flags
An integer, view flags. (See the view flag constants.)
layout
A Layout object, indicates how children of this View should be laid out. This can be omitted if the View will not have children.
archive
A 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()
bitmap
A Bitmap, the Bitmap.
srcRect
A Rect, the source rectangle; if not given, uses the whole Bitmap.
dstRect
A 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.colorKey
An rgb_color indicating the transparent color for the overlay.
followFlags
A 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).options
An 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)
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.
name
A 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
,parentPoint
A Point to convert.
viewRect
,screenRect
,parentRect
A Rect to convert.
CopyBits
Copies bits from one rectangle to another, scaling if necessary.
Perl
$view->CopyBits($src, $dst);
Python
view.CopyBits(src, dst)
src
A Rect, the source rectangle.
dst
A 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, )
message
A Message, contains the information for the destination View.
bitmap
A Bitmap, a bitmap to be used as the drag image.
hotspot
A Point, the hotspot within the image.
dragMode
An integer, one of the drawing mode constants; defaults to
B_OP_COPY
.offset
A Point, the hotspot within the image.
rect
A Rect, a rectangle (in the View's coordinate system) to be used in place of a drag image.
replyTarget
A 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)
mask
An integer, one or more of the event mask constants.
options
An 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)
rule
One 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)
flags
An 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()
enable
A 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)
checkMessageQueue
A 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)
rect
A Rect, the rectangle to invalidate.
region
A Region, the region to invalidate.
delay
An 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_from
The 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)
where
The 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)
size
The new coordinates as a Size.
width
,height
Floating 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)
mode
An 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)
posture
One 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)
where
The new coordinates as a Point.
x
,y
Floating 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)
direction
One of the orientation constants.
delta
A 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)
cursor
A Cursor object.
sync
A 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)
string
The string to truncate or measure.
strings
A native list of strings to measure.
mode
An integer, one of the truncation mode constants.
width
A 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()
class
Optional; a class for the native wrapper object returned by the method; defaults to
ToolTip
. (SinceToolTip
is not a fully functional class, you probably want to useTextToolTip
here, unless you create your own ToolTip subclass.)tip
A ToolTip object to set or show.
text
A 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()
rect
A Rect, the rectangle to display.
how
An 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)
newPosition
A Point, the new position.
FrameResized
Called when the View has been resized.
Perl
$view->FrameResized($newWidth, $newHeight);
Python
view.FrameResized(newWidth, newHeight)
newWidth
,newHeight
Floating 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)
point
A 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)
bytes
A 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)
bytes
A 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)
focused
A 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)
point
A 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)
point
A Point, the cursor's new location.
transit
An integer, the type of movement, as one of the transit constants.
message
A 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)
point
A 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)
scrollView
The 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)
state
A 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
Frame
B_GET_PROPERTY
,B_SET_PROPERTY
A Rect, the View frame
Hidden
B_GET_PROPERTY
,B_SET_PROPERTY
A boolean, whether the View is hidden
View
B_COUNT_PROPERTIES
Gets the number of child Views
Specifiers
Shelf
B_DIRECT_SPECIFIER
Targets the View's Shelf
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
View also inherits the following suites: