Public Member Functions | Protected Member Functions | List of all members
BMenu Class Reference

Displays a list of menu items including additional menus arranged hierarchically. More...

Inherits BView.

Inherited by BMenuBar, and BPopUpMenu.

Public Member Functions

 BMenu (const char *name, menu_layout layout=B_ITEMS_IN_COLUMN)
 Creates a new menu object with the specified name and layout. More...
 
 BMenu (const char *name, float width, float height)
 Creates a new menu object with a B_ITEMS_IN_MATRIX layout and the specified name, width, and height. More...
 
 BMenu (BMessage *archive)
 Archive constructor. More...
 
virtual ~BMenu ()
 Destructor. More...
 
virtual bool AddDynamicItem (add_state state)
 Implemented by subclasses to Add a dynamic item to the menu. More...
 
bool AddItem (BMenuItem *item)
 Adds a menu item to the end of the list. More...
 
bool AddItem (BMenuItem *item, int32 index)
 Adds a menu item at the specified index. More...
 
bool AddItem (BMenuItem *item, BRect frame)
 Adds a menu item in the specified frame rectangle within the menu. More...
 
bool AddItem (BMenu *menu)
 Add a submenu to the end of the list. More...
 
bool AddItem (BMenu *menu, int32 index)
 Add a submenu at the specified index. More...
 
bool AddItem (BMenu *menu, BRect frame)
 Adds a submenu in the specified frame rectangle within the menu. More...
 
bool AddList (BList *list, int32 index)
 Add a list of menu items at the specified index. More...
 
bool AddSeparatorItem ()
 Adds a separator item to the end of the menu. More...
 
virtual void AllAttached ()
 Similar to AttachedToWindow() but this method is triggered after all child views have already been attached to a window. More...
 
virtual void AllDetached ()
 Similar to AttachedToWindow() but this method is triggered after all child views have already been detached from a window. More...
 
bool AreTriggersEnabled () const
 Returns whether or not triggers are enabled. More...
 
int32 CountItems () const
 Returns the number of items added to the menu. More...
 
virtual void DetachedFromWindow ()
 Hook method called when the object is detached from a window. More...
 
virtual void DoLayout ()
 Layout view within the layout context. More...
 
virtual void DrawBackground (BRect updateRect)
 Draw the menu background within the bounds of updateRect. More...
 
BMenuItemFindItem (uint32 command) const
 Returns a pointer to the menu item with the specified command for its associated message. More...
 
BMenuItemFindItem (const char *name) const
 Returns a pointer to the menu item with the specified label. More...
 
BMenuItemFindMarked ()
 Return a pointer to the first marked menu item. More...
 
int32 FindMarkedIndex ()
 Return the index of the first marked menu item. More...
 
virtual void FrameMoved (BPoint newPosition)
 Hook method called when the view is moved. More...
 
virtual void FrameResized (float newWidth, float newHeight)
 Hook method called when the view is resized. More...
 
virtual void GetPreferredSize (float *_width, float *_height)
 Fill out the preferred width and height of the view into the _width and _height parameters. More...
 
virtual status_t GetSupportedSuites (BMessage *data)
 Reports the suites of messages and specifiers that derived classes understand. More...
 
int32 IndexOf (BMenuItem *item) const
 Returns the index of the specified menu item. More...
 
int32 IndexOf (BMenu *menu) const
 Returns the index of the specified submenu. More...
 
bool IsEnabled () const
 Returns whether or not the menu is enabled. More...
 
bool IsLabelFromMarked ()
 Returns whether or not the menu is in label-from-marked mode. More...
 
bool IsRadioMode () const
 Returns whether or not the menu is in radio mode. More...
 
bool IsRedrawAfterSticky () const
 Returns whether or not the menu is in redraw-after-sticky mode. More...
 
BMenuItemItemAt (int32 index) const
 Returns a pointer to the menu item at the specified index. More...
 
virtual void MakeFocus (bool focus=true)
 Makes the view the current focus view of the window or gives up being the window's focus view. More...
 
float MaxContentWidth () const
 Return the maximum width of the menu items' content area. More...
 
virtual BSize MaxSize ()
 Return the maximum size of the view. More...
 
virtual BSize MinSize ()
 Return the minimum size of the view. More...
 
virtual status_t Perform (perform_code d, void *arg)
 Perform some action. (Internal Method) More...
 
virtual BSize PreferredSize ()
 Return the preferred size of the view. More...
 
bool RemoveItem (BMenuItem *item)
 Remove and delete the specified item from the menu. More...
 
BMenuItemRemoveItem (int32 index)
 Remove the item at the specified index from the menu. More...
 
bool RemoveItem (BMenu *menu)
 Remove and delete a submenu from the menu. More...
 
bool RemoveItems (int32 index, int32 count, bool deleteItems=false)
 Remove count number of items from the menu starting at the specified index and delete them if deleteItems is true. More...
 
virtual void ResizeToPreferred ()
 Resizes the view to its preferred size keeping the position of the left top corner constant. More...
 
virtual BHandlerResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 form, const char *property)
 Determine the proper handler for a scripting message. More...
 
virtual void SetEnabled (bool enable)
 Enables or disables the menu. More...
 
void SetLabelFromMarked (bool on)
 Sets whether or not the label of the menu is set according to the marked item. More...
 
virtual void SetMaxContentWidth (float maxWidth)
 Sets the maximum width of the menu items' content area. More...
 
virtual void SetRadioMode (bool on)
 Turns radio mode on or off. More...
 
virtual status_t SetTargetForItems (BHandler *target)
 Set the target to handler for each item in the menu. More...
 
virtual status_t SetTargetForItems (BMessenger messenger)
 Set the target to messenger for each item in the menu. More...
 
void SetTrackingHook (menu_tracking_hook hook, void *state)
 Sets a hook function that is called when tracking begins. More...
 
virtual void SetTriggersEnabled (bool enable)
 Enables or disables triggers. More...
 
BMenuSubmenuAt (int32 index) const
 Returns a pointer to a submenu at the specified index. More...
 
BMenuItemSuperitem () const
 Returns the pointer to the menu item that this menu it attached to. More...
 
BMenuSupermenu () const
 Returns the pointer to the menu that this menu it attached to. More...
 
Hook Methods
virtual void AttachedToWindow ()
 Lays out the menu items and resizes the menu to fit. More...
 
virtual void Draw (BRect updateRect)
 Draws the menu. More...
 
virtual void MessageReceived (BMessage *message)
 Handles a message received by the associated looper. More...
 
virtual void KeyDown (const char *bytes, int32 numBytes)
 Hook method that is called when a keyboard key is pressed. More...
 
- Public Member Functions inherited from BView
 BView (const char *name, uint32 flags, BLayout *layout=NULL)
 Layout constructor. More...
 
 BView (BRect frame, const char *name, uint32 resizingMode, uint32 flags)
 Standard constructor. More...
 
 BView (BMessage *archive)
 Archive constructor. More...
 
virtual ~BView ()
 Destructor method. More...
 
BRect Bounds () const
 Returns the view's frame rectangle in the view's coordinate system. More...
 
uint32 Flags () const
 Return the view flags set in the constructor or by SetFlags(). More...
 
void Flush () const
 Flushes the attached window's connection to App Server. More...
 
BRect Frame () const
 Returns the view's frame rectangle in the parent's coordinate system. More...
 
bool IsFocus () const
 Returns whether or not the view is the window's current focus view. More...
 
bool IsHidden () const
 Returns whether or not the view is hidden. More...
 
bool IsHidden (const BView *looking_from) const
 Returns whether or not the view is hidden from the perspective of lookingFrom. More...
 
bool IsPrinting () const
 Returns whether or not the view is drawing to a printer. More...
 
BPoint LeftTop () const
 Returns the left top corner point. More...
 
uint32 ResizingMode () const
 Returns the resizing mode flags mask set in the constructor or by SetResizingMode(). More...
 
virtual void SetFlags (uint32 flags)
 Sets the view flags to the flags mask. More...
 
virtual void SetResizingMode (uint32 mode)
 Sets the resizing mode of the view according to the mode mask. More...
 
void SetViewCursor (const BCursor *cursor, bool sync=true)
 Assigns cursor to the view. More...
 
void Sync () const
 Synchronizes the attached window's connection to App Server. More...
 
BWindowWindow () const
 Returns the window the view is attached to. More...
 
void AddChild (BView *child, BView *before=NULL)
 Adds child to the view hierarchy immediately before before. More...
 
bool AddChild (BLayoutItem *child)
 Add the child layout item to the view hierarchy. More...
 
bool RemoveChild (BView *child)
 Removes child from the view hierarchy. More...
 
int32 CountChildren () const
 Returns the number of child views that this view has. More...
 
BViewChildAt (int32 index) const
 Returns a pointer to the child view found at index. More...
 
BViewNextSibling () const
 Returns a pointer to the next sibling view. More...
 
BViewPreviousSibling () const
 Returns a pointer to the previous sibling view. More...
 
bool RemoveSelf ()
 Removes the view and all child views from the view hierarchy. More...
 
BViewFindView (const char *name) const
 Returns the view in the view hierarchy with the specified name. More...
 
BViewParent () const
 Returns a pointer to the view's parent. More...
 
void ConvertToScreen (BPoint *point) const
 Convert point to the screen's coordinate system in place. More...
 
BPoint ConvertToScreen (BPoint point) const
 Returns point converted to the screen's coordinate system. More...
 
void ConvertFromScreen (BPoint *point) const
 Convert point from the screen's coordinate system to the view's coordinate system in place. More...
 
BPoint ConvertFromScreen (BPoint point) const
 Returns point converted from the screen's coordinate system to the view's coordinate system. More...
 
void ConvertToScreen (BRect *rect) const
 Convert rect to the screen's coordinate system in place. More...
 
BRect ConvertToScreen (BRect rect) const
 Returns rect converted to the screen's coordinate system. More...
 
void ConvertFromScreen (BRect *rect) const
 Convert rect from the screen's coordinate system to the view's coordinate system in place. More...
 
BRect ConvertFromScreen (BRect rect) const
 Returns rect converted from the screen's coordinate system to the view's coordinate system. More...
 
void ConvertToParent (BPoint *point) const
 Convert point to the parent's coordinate system in place. More...
 
BPoint ConvertToParent (BPoint point) const
 Returns point converted to the parent's coordinate system. More...
 
void ConvertFromParent (BPoint *point) const
 Convert point from the parent's coordinate system to the view's coordinate system in place. More...
 
BPoint ConvertFromParent (BPoint point) const
 Returns point converted from the parent's coordinate system to the view's coordinate system. More...
 
void ConvertToParent (BRect *rect) const
 Convert rect to the parent's coordinate system in place. More...
 
BRect ConvertToParent (BRect rect) const
 Returns rect converted to the parent's coordinate system. More...
 
void ConvertFromParent (BRect *rect) const
 Convert rect from the parent's coordinate system to the view's coordinate system in place. More...
 
BRect ConvertFromParent (BRect rect) const
 Returns rect converted from the parent's coordinate system to the view's coordinate system. More...
 
void GetClippingRegion (BRegion *region) const
 Fill out region with the view's clipping region. More...
 
virtual void ConstrainClippingRegion (BRegion *region)
 Set the clipping region the region restricting the area that the view can draw in. More...
 
void ClipToPicture (BPicture *picture, BPoint where=B_ORIGIN, bool sync=true)
 Intersects the current clipping region of the view with the pixels of picture. More...
 
void ClipToInversePicture (BPicture *picture, BPoint where=B_ORIGIN, bool sync=true)
 Intersects the current clipping region of the view with the pixels outside of picture. More...
 
virtual void SetDrawingMode (drawing_mode mode)
 Sets the drawing mode of the view. More...
 
drawing_mode DrawingMode () const
 Return the current drawing_mode. More...
 
void SetBlendingMode (source_alpha srcAlpha, alpha_function alphaFunc)
 Set the blending mode which controls how transparency is used. More...
 
void GetBlendingMode (source_alpha *srcAlpha, alpha_function *alphaFunc) const
 Fill out srcAlpha and alphaFunc with the alpha mode and alpha function of the view. More...
 
virtual void SetPenSize (float size)
 Set the pen size to size. More...
 
float PenSize () const
 Return the current pen size. More...
 
bool HasDefaultColors () const
 Tests if the view has any colors set. More...
 
bool HasSystemColors () const
 Tests if the view is using system "panel" colors. B_PANEL_BACKGROUND_COLOR for ViewUIColor() B_PANEL_BACKGROUND_COLOR for LowUIColor() B_PANEL_TEXT_COLOR for HighUIColor() More...
 
void AdoptParentColors ()
 Attempts to use the colors of any parent view. Will adopt view, low, and high colors. Should be called in AttachedToWindow() or AllAttached(). More...
 
void AdoptSystemColors ()
 Instructs view to use standard system "panel" colors. B_PANEL_BACKGROUND_COLOR for ViewUIColor() B_PANEL_BACKGROUND_COLOR for LowUIColor() B_PANEL_TEXT_COLOR for HighUIColor() More...
 
void AdoptViewColors (BView *view)
 Attempts to use the colors of a given view. Will adopt view, low, and high colors. More...
 
virtual void SetViewColor (rgb_color color)
 Set the view color of the view. More...
 
void SetViewColor (uchar red, uchar green, uchar blue, uchar alpha=255)
 Set the view color of the view. More...
 
rgb_color ViewColor () const
 Return the current view color. More...
 
void SetViewUIColor (color_which which, float tint=B_NO_TINT)
 Set the view color of the view to a system constant. The color will update live with user changes. More...
 
color_which ViewUIColor (float *tint=NULL) const
 Return the current view color constant being used. More...
 
virtual void SetHighColor (rgb_color color)
 Set the high color of the view. More...
 
void SetHighColor (uchar red, uchar green, uchar blue, uchar alpha=255)
 Set the high color of the view. More...
 
rgb_color HighColor () const
 Return the current high color. More...
 
void SetHighUIColor (color_which which, float tint=B_NO_TINT)
 Set the high color of the view to a system constant. The color will update live with user changes. More...
 
color_which HighUIColor (float *tint=NULL) const
 Return the current high color constant being used. More...
 
virtual void SetLowColor (rgb_color color)
 Set the low color of the view. More...
 
void SetLowColor (uchar red, uchar green, uchar blue, uchar alpha=255)
 Set the low color of the view. More...
 
rgb_color LowColor () const
 Return the current low color. More...
 
void SetLowUIColor (color_which which, float tint=B_NO_TINT)
 Set the low color of the view to a system constant. The color will update live with user changes. More...
 
color_which LowUIColor (float *tint=NULL) const
 Return the current low color constant being used. More...
 
void SetLineMode (cap_mode lineCap, join_mode lineJoin, float miterLimit=B_DEFAULT_MITER_LIMIT)
 Set line mode to use PostScript-style line cap and join modes. More...
 
join_mode LineJoinMode () const
 Returns the current line join mode. More...
 
cap_mode LineCapMode () const
 Returns the current line cap mode. More...
 
float LineMiterLimit () const
 Returns the miter limit used for B_MITER_JOIN join mode. More...
 
void SetOrigin (BPoint where)
 Sets the origin in the view's coordinate system. More...
 
void SetOrigin (float x, float y)
 Sets the origin in the view's coordinate system. More...
 
BPoint Origin () const
 Returns the origin point in the view's coordinate system. More...
 
void PushState ()
 Saves the drawing state to the stack. More...
 
void PopState ()
 Restores the drawing state from the stack. More...
 
void MovePenTo (BPoint pt)
 Move the pen to point in the view's coordinate system. More...
 
void MovePenTo (float x, float y)
 Move the pen to the point specified by x and y in the view's coordinate system. More...
 
void MovePenBy (float x, float y)
 Move the pen by x pixels horizontally and y pixels vertically. More...
 
BPoint PenLocation () const
 Return the current pen location as a BPoint object. More...
 
virtual void SetFont (const BFont *font, uint32 mask=B_FONT_ALL)
 Set the font of the view. More...
 
void GetFont (BFont *font) const
 Fill out font with the font set to the view. More...
 
void TruncateString (BString *in_out, uint32 mode, float width) const
 Truncate string with truncation mode mode so that it is no wider than width set in the view's font. More...
 
float StringWidth (const char *string) const
 Return the width of string set in the font of the view. More...
 
float StringWidth (const char *string, int32 length) const
 Return the width of string set in the font of the view up to length characters. More...
 
void GetStringWidths (char *stringArray[], int32 lengthArray[], int32 numStrings, float widthArray[]) const
 Fill out widths of the strings in stringArray set in the font of the view into widthArray. More...
 
void SetFontSize (float size)
 Set the size of the view's font to size. More...
 
void ForceFontAliasing (bool enable)
 Turn anti-aliasing on and off when printing. More...
 
void GetFontHeight (font_height *height) const
 Fill out the font_height struct with the view font. More...
 
void SetScale (float scale) const
 Sets the scale of the coordinate system the view uses for drawing. More...
 
float Scale () const
 Return the current drawing scale. More...
 
void SetViewBitmap (const BBitmap *bitmap, BRect srcRect, BRect dstRect, uint32 followFlags=B_FOLLOW_LEFT_TOP, uint32 options=B_TILE_BITMAP)
 Sets the background bitmap of the view. More...
 
void SetViewBitmap (const BBitmap *bitmap, uint32 followFlags=B_FOLLOW_LEFT_TOP, uint32 options=B_TILE_BITMAP)
 Sets the background bitmap of the view. More...
 
void ClearViewBitmap ()
 Clears the background bitmap of the view if it has one. More...
 
status_t SetViewOverlay (const BBitmap *overlay, BRect srcRect, BRect dstRect, rgb_color *colorKey, uint32 followFlags=B_FOLLOW_LEFT_TOP, uint32 options=0)
 Sets the overlay bitmap of the view. More...
 
status_t SetViewOverlay (const BBitmap *overlay, rgb_color *colorKey, uint32 followFlags=B_FOLLOW_LEFT_TOP, uint32 options=0)
 Sets the overlay bitmap of the view. More...
 
void ClearViewOverlay ()
 Clears the overlay bitmap of the view if it has one. More...
 
void StrokeLine (BPoint toPoint, ::pattern pattern=B_SOLID_HIGH)
 Stroke a line from the current pen location to the point toPoint. More...
 
void StrokeLine (BPoint start, BPoint end, ::pattern pattern=B_SOLID_HIGH)
 Stroke a line from point start to point end. More...
 
void BeginLineArray (int32 count)
 Begin a line array of up to count lines. More...
 
void AddLine (BPoint start, BPoint end, rgb_color color)
 Add a line to the line array drawn from start to end. More...
 
void EndLineArray ()
 End the line array drawing the lines. More...
 
void StrokePolygon (const BPolygon *polygon, bool closed=true, ::pattern pattern=B_SOLID_HIGH)
 Stroke a polygon shape. More...
 
void StrokePolygon (const BPoint *pointArray, int32 numPoints, bool closed=true, ::pattern pattern=B_SOLID_HIGH)
 Stroke a polygon shape made up of points specified by pointArray. More...
 
void StrokePolygon (const BPoint *pointArray, int32 numPoints, BRect bounds, bool closed=true, ::pattern pattern=B_SOLID_HIGH)
 Stroke a polygon shape made up of points specified by pointArray inscribed by bounds. More...
 
void FillPolygon (const BPolygon *polygon, ::pattern pattern=B_SOLID_HIGH)
 Fill a polygon shape. More...
 
void FillPolygon (const BPoint *pointArray, int32 numPoints, ::pattern pattern=B_SOLID_HIGH)
 Fill a polygon shape made up of points specified by pointArray. More...
 
void FillPolygon (const BPoint *pointArray, int32 numPoints, BRect bounds, ::pattern pattern=B_SOLID_HIGH)
 Fill a polygon shape made up of points specified by pointArray inscribed by bounds. More...
 
void FillPolygon (const BPolygon *polygon, const BGradient &gradient)
 Fill a polygon shape with the specified gradient pattern. More...
 
void FillPolygon (const BPoint *pointArray, int32 numPoints, const BGradient &gradient)
 Fill a polygon shape made up of points specified by pointArray with the specified gradient pattern. More...
 
void FillPolygon (const BPoint *pointArray, int32 numPoints, BRect bounds, const BGradient &gradient)
 Fill a polygon shape made up of points specified by pointArray inscribed by bounds with the specified gradient pattern. More...
 
void StrokeTriangle (BPoint point1, BPoint point2, BPoint point3, BRect bounds, ::pattern pattern=B_SOLID_HIGH)
 Stroke the triangle specified by points point1, point2, and point3 and enclosed by bounds. More...
 
void StrokeTriangle (BPoint point1, BPoint point2, BPoint point3, ::pattern pattern=B_SOLID_HIGH)
 Stroke the triangle specified by points point1, point2, and point3. More...
 
void FillTriangle (BPoint point1, BPoint point2, BPoint point3, ::pattern pattern=B_SOLID_HIGH)
 Fill the triangle specified by points point1, point2, and point3. More...
 
void FillTriangle (BPoint point1, BPoint point2, BPoint point3, BRect bounds, ::pattern pattern=B_SOLID_HIGH)
 Fill the triangle specified by points point1, point2, and point3 and enclosed by bounds. More...
 
void FillTriangle (BPoint point1, BPoint point2, BPoint point3, const BGradient &gradient)
 Fill the triangle specified by points point1, point2, and point3 with the specified gradient pattern. More...
 
void FillTriangle (BPoint point1, BPoint point2, BPoint point3, BRect bounds, const BGradient &gradient)
 Fill the triangle specified by points point1, point2, and point3 and enclosed by bounds with the specified gradient pattern. More...
 
void StrokeRect (BRect rect, ::pattern pattern=B_SOLID_HIGH)
 Stroke the rectangle specified by rect. More...
 
void FillRect (BRect rect, ::pattern pattern=B_SOLID_HIGH)
 Fill the rectangle specified by rect. More...
 
void FillRect (BRect rect, const BGradient &gradient)
 Fill the rectangle specified by rect with the specified gradient pattern. More...
 
void FillRegion (BRegion *rectegion, ::pattern pattern=B_SOLID_HIGH)
 Fill region. More...
 
void FillRegion (BRegion *rectegion, const BGradient &gradient)
 Fill region with the specified gradient pattern. More...
 
void InvertRect (BRect rect)
 Inverts the colors within rect. More...
 
void StrokeRoundRect (BRect rect, float xRadius, float yRadius, ::pattern pattern=B_SOLID_HIGH)
 Stroke the rounded rectangle with horizontal radius xRadius and vertical radius yRadius. More...
 
void FillRoundRect (BRect rect, float xRadius, float yRadius, ::pattern pattern=B_SOLID_HIGH)
 Fill the rounded rectangle with horizontal radius xRadius and vertical radius yRadius. More...
 
void FillRoundRect (BRect rect, float xRadius, float yRadius, const BGradient &gradient)
 Fill the rounded rectangle with horizontal radius xRadius and vertical radius yRadius with the specified gradient pattern. More...
 
void StrokeEllipse (BPoint center, float xRadius, float yRadius, ::pattern pattern=B_SOLID_HIGH)
 Stroke the outline of an ellipse starting at center with a horizontal radius of xRadius and a vertical radius of yRadius. More...
 
void StrokeEllipse (BRect rect, ::pattern pattern=B_SOLID_HIGH)
 Stroke the outline of an ellipse inscribed within rect. More...
 
void FillEllipse (BPoint center, float xRadius, float yRadius, ::pattern pattern=B_SOLID_HIGH)
 Fill an ellipse starting at center with a horizontal radius of xRadius and a vertical radius of yRadius. More...
 
void FillEllipse (BRect rect, ::pattern pattern=B_SOLID_HIGH)
 Fill an ellipse inscribed within rect. More...
 
void FillEllipse (BPoint center, float xRadius, float yRadius, const BGradient &gradient)
 Fill an ellipse with the specified gradient pattern starting at center with a horizontal radius of xRadius and a vertical radius of yRadius. More...
 
void FillEllipse (BRect rect, const BGradient &gradient)
 Fill an ellipse with the specified gradient pattern inscribed within rect. More...
 
void StrokeArc (BPoint center, float xRadius, float yRadius, float startAngle, float arcAngle, ::pattern pattern=B_SOLID_HIGH)
 Stroke the outline of an arc starting at center with a horizontal radius of xRadius and a vertical radius of yRadius starting at startAngle and drawing arcAngle degrees. More...
 
void StrokeArc (BRect rect, float startAngle, float arcAngle, ::pattern pattern=B_SOLID_HIGH)
 Stroke the outline of an arc inscribed within rect starting at startAngle and drawing arcAngle degrees. More...
 
void FillArc (BPoint center, float xRadius, float yRadius, float startAngle, float arcAngle, ::pattern pattern=B_SOLID_HIGH)
 Fill an arc starting at center with a horizontal radius of xRadius and a vertical radius of yRadius starting at startAngle and drawing arcAngle degrees. More...
 
void FillArc (BRect rect, float startAngle, float arcAngle, ::pattern pattern=B_SOLID_HIGH)
 Fill an arc inscribed within rect starting at startAngle and drawing arcAngle degrees. More...
 
void FillArc (BPoint center, float xRadius, float yRadius, float startAngle, float arcAngle, const BGradient &gradient)
 Fill an arc with the specified gradient pattern starting at center with a horizontal radius of xRadius and a vertical radius of yRadius starting at startAngle and drawing arcAngle degrees. More...
 
void FillArc (BRect rect, float startAngle, float arcAngle, const BGradient &gradient)
 Fill an arc with the specified gradient pattern inscribed within rect starting at startAngle and drawing arcAngle degrees. More...
 
void StrokeBezier (BPoint *controlPoints, ::pattern pattern=B_SOLID_HIGH)
 Stroke a bezier curve. More...
 
void FillBezier (BPoint *controlPoints, ::pattern pattern=B_SOLID_HIGH)
 Fill a bezier curve. More...
 
void FillBezier (BPoint *controlPoints, const BGradient &gradient)
 Fill a bezier curve. More...
 
void StrokeShape (BShape *shape, ::pattern pattern=B_SOLID_HIGH)
 Stroke shape. More...
 
void FillShape (BShape *shape, ::pattern pattern=B_SOLID_HIGH)
 Fill shape. More...
 
void FillShape (BShape *shape, const BGradient &gradient)
 Fill shape with the specified gradient pattern. More...
 
void CopyBits (BRect src, BRect dst)
 Copy the bits from the src rectangle to the dst rectangle in the view's coordinate system. More...
 
void DrawBitmapAsync (const BBitmap *aBitmap, BRect bitmapRect, BRect viewRect, uint32 options)
 Draws bitmap on the view within viewRect asynchronously. More...
 
void DrawBitmapAsync (const BBitmap *aBitmap, BRect bitmapRect, BRect viewRect)
 Draws bitmap on the view within viewRect asynchronously. More...
 
void DrawBitmapAsync (const BBitmap *aBitmap, BRect viewRect)
 Draws bitmap on the view within viewRect asynchronously. More...
 
void DrawBitmapAsync (const BBitmap *aBitmap, BPoint where)
 Draws bitmap on the view offset by where asynchronously. More...
 
void DrawBitmapAsync (const BBitmap *aBitmap)
 Draws bitmap on the view asynchronously. More...
 
void DrawBitmap (const BBitmap *aBitmap, BRect bitmapRect, BRect viewRect, uint32 options)
 brief Draws bitmap on the view within viewRect. More...
 
void DrawBitmap (const BBitmap *aBitmap, BRect bitmapRect, BRect viewRect)
 Draws bitmap on the view within viewRect. More...
 
void DrawBitmap (const BBitmap *aBitmap, BRect viewRect)
 Draws bitmap on the view within viewRect. More...
 
void DrawBitmap (const BBitmap *aBitmap, BPoint where)
 Draws bitmap on the view offset by where. More...
 
void DrawBitmap (const BBitmap *aBitmap)
 Draws bitmap on the view. More...
 
void DrawChar (char aChar)
 Draws character c onto to the view at the current pen position. More...
 
void DrawChar (char aChar, BPoint location)
 Draws character c at the specified location in the view. More...
 
void DrawString (const char *string, escapement_delta *delta=NULL)
 Draw string onto the view at the current pen position. More...
 
void DrawString (const char *string, BPoint location, escapement_delta *delta=NULL)
 Draw string onto the view at the specified location in the view. More...
 
void DrawString (const char *string, int32 length, escapement_delta *delta=NULL)
 Draw string up to length characters onto the view at the current pen position. More...
 
void DrawString (const char *string, int32 length, BPoint location, escapement_delta *delta=0L)
 Draw string up to length characters onto the view at the specified location in the view. More...
 
void DrawString (const char *string, const BPoint *locations, int32 locationCount)
 Draw string locationCount times at the specified locations. More...
 
void DrawString (const char *string, int32 length, const BPoint *locations, int32 locationCount)
 Draw string up to length characters locationCount times at the specified locations. More...
 
void Invalidate (BRect invalRect)
 Sends a message to App Server to redraw the portion of the view specified by invalRect. More...
 
void Invalidate (const BRegion *invalRegion)
 Sends a message to App Server to redraw the portion of the view specified by region. More...
 
void Invalidate ()
 Sends a message to App Server to redraw the view. More...
 
void DelayedInvalidate (bigtime_t delay)
 Sends a message to App Server to redraw the entire view after a certain, minimum, delay. Repeated calls to this method may be merged, but the view is guaranteed to be redrawn after the delay given in the first call of this method. More...
 
void DelayedInvalidate (bigtime_t delay, BRect invalRect)
 Sends a message to App Server to redraw the portion of the view specified by invalRect after a certain, minimum, delay. Repeated calls to this method may be merged, but the invalidated rect is guaranteed to be redrawn after the minimum delay given by the first call of this method. More...
 
void SetDiskMode (char *filename, long offset)
 Unimplemented. More...
 
void BeginPicture (BPicture *a_picture)
 Begins sending drawing instructions to picture. More...
 
void AppendToPicture (BPicture *a_picture)
 Appends drawing instructions to picture without clearing it first. More...
 
BPictureEndPicture ()
 Ends the drawing instruction recording session and returns the BPicture object passed to BeginPicture() or AppendToPicture(). More...
 
void DrawPicture (const BPicture *a_picture)
 Draws the picture at the view's current pen position. More...
 
void DrawPicture (const BPicture *a_picture, BPoint where)
 Draws the picture at the location in the view specified by where. More...
 
void DrawPicture (const char *filename, long offset, BPoint where)
 Draws the picture from the file specified by filename offset by offset bytes at the location in the view specified by where. More...
 
void DrawPictureAsync (const BPicture *a_picture)
 Draws the picture at the view's current pen position. More...
 
void DrawPictureAsync (const BPicture *a_picture, BPoint where)
 Draws the picture at the location in the view specified by where. More...
 
void DrawPictureAsync (const char *filename, long offset, BPoint where)
 Draws the picture from the file specified by filename offset by offset bytes at the location in the view specified by where. More...
 
void MoveBy (float dh, float dv)
 Moves the view deltaX pixels horizontally and deltaY pixels vertically in the parent view's coordinate system. More...
 
void MoveTo (BPoint where)
 Move the view to the location specified by where in the parent view's coordinate system. More...
 
void MoveTo (float x, float y)
 Move the view to the coordinates specified by x in the horizontal dimension and y in the vertical dimension in the parent view's coordinate system. More...
 
void ResizeBy (float dh, float dv)
 Resize the view by deltaWidth horizontally and deltaHeight vertically without moving the top left corner of the view. More...
 
void ResizeTo (float width, float height)
 Resize the view to the specified width and height. More...
 
void ResizeTo (BSize size)
 Resize the view to the dimension specified by size. More...
 
virtual status_t AllUnarchived (const BMessage *archive)
 Hook method called when all views have been unarchived. More...
 
virtual status_t AllArchived (BMessage *archive) const
 Hook method called when all views have been archived. More...
 
virtual void MouseDown (BPoint where)
 Hook method called when a mouse button is pressed. More...
 
virtual void MouseUp (BPoint where)
 Hook method called when a mouse button is released. More...
 
virtual void MouseMoved (BPoint where, uint32 code, const BMessage *dragMessage)
 Hook method called when the mouse is moved. More...
 
virtual void WindowActivated (bool active)
 Hook method called when the attached window is activated or deactivated. More...
 
virtual void KeyUp (const char *bytes, int32 numBytes)
 Hook method called when a keyboard key is released. More...
 
virtual void Pulse ()
 Hook method called when the view receives a B_PULSE message. More...
 
virtual void TargetedByScrollView (BScrollView *scrollView)
 Hook method called when the view becomes the target of scrollView. More...
 
virtual void DrawAfterChildren (BRect updateRect)
 Perform any drawing that needs to be done after child view have already been drawn. More...
 
void BeginRectTracking (BRect startRect, uint32 style=B_TRACK_WHOLE_RECT)
 Displays an outline rectangle on the view and initiates tracking. More...
 
void EndRectTracking ()
 Ends tracking removing the outline rectangle from the view. More...
 
void GetMouse (BPoint *location, uint32 *buttons, bool checkMessageQueue=true)
 Fills out the cursor location and the current state of the mouse buttons. More...
 
void DragMessage (BMessage *message, BRect dragRect, BHandler *replyTo=NULL)
 Initiates a drag-and-drop session. More...
 
void DragMessage (BMessage *message, BBitmap *bitmap, BPoint offset, BHandler *replyTo=NULL)
 Initiates a drag-and-drop session of an image. More...
 
void DragMessage (BMessage *message, BBitmap *bitmap, drawing_mode dragMode, BPoint offset, BHandler *replyTo=NULL)
 Initiates a drag-and-drop session of an image with drawing_mode set by dragMode. More...
 
status_t SetEventMask (uint32 mask, uint32 options=0)
 Sets whether or not the view can accept mouse and keyboard events when not in focus. More...
 
uint32 EventMask ()
 Returns the current event mask. More...
 
status_t SetMouseEventMask (uint32 mask, uint32 options=0)
 Sets whether or not the view can accept mouse and keyboard events when not in focus from within MouseDown() until the following MouseUp() event. More...
 
void ScrollBy (float dh, float dv)
 Scroll the view by deltaX horizontally and deltaY vertically. More...
 
virtual void ScrollTo (BPoint where)
 Scroll the view to the point specified by where. More...
 
BScrollBarScrollBar (orientation direction) const
 Returns the BScrollBar object that has the BView set as its target. More...
 
void SetExplicitMinSize (BSize size)
 Set this view's min size, to be used by MinSize(). More...
 
void SetExplicitMaxSize (BSize size)
 Set this view's max size, to be used by MaxSize(). More...
 
void SetExplicitPreferredSize (BSize size)
 Set this view's preferred size, to be used by PreferredSize(). More...
 
void SetExplicitAlignment (BAlignment alignment)
 Set this view's alignment, to be used by Alignment(). More...
 
void InvalidateLayout (bool descendants=false)
 Invalidate layout. More...
 
virtual void SetLayout (BLayout *layout)
 Sets the layout of the view. More...
 
BLayoutGetLayout () const
 Get the layout of the view. More...
 
void EnableLayoutInvalidation ()
 Enable layout invalidation. More...
 
void DisableLayoutInvalidation ()
 Disable layout invalidation. More...
 
bool IsLayoutInvalidationDisabled ()
 Returns whether or not layout invalidation is disabled. More...
 
bool IsLayoutValid () const
 Returns whether or not the layout is valid. More...
 
void ResetLayoutInvalidation ()
 Service call for BView derived classes re-enabling InvalidateLayout() notifications. More...
 
void Layout (bool force)
 Layout the view. More...
 
void Relayout ()
 Relayout the view. More...
 
void SetToolTip (const char *text)
 Set the tool tip of the view to text. More...
 
void SetToolTip (BToolTip *tip)
 Set the tool tip of the view to the tip object. More...
 
BToolTipToolTip () const
 Return the tool tip set to the view or NULL if not set. More...
 
void ShowToolTip (BToolTip *tip=NULL)
 Show the tool tip at the current mouse position. More...
 
void HideToolTip ()
 Hide the view's tool tip. More...
 
- Public Member Functions inherited from BHandler
 BHandler (const char *name=NULL)
 Construct a new handler with a name. More...
 
virtual ~BHandler ()
 Free the filters of this handler, as well as the list of observers. More...
 
 BHandler (BMessage *data)
 Construct a handler from an archived message. More...
 
BLooperLooper () const
 Return a pointer to the looper that this handler is associated with. More...
 
void SetName (const char *name)
 Set or change the name of this handler. More...
 
const char * Name () const
 Return the name of this handler. More...
 
virtual void SetNextHandler (BHandler *handler)
 Set the next handler in the chain that the message is passed on to if this handler cannot process it. More...
 
BHandlerNextHandler () const
 Return the next hander in the chain to which the message is passed on. More...
 
virtual void AddFilter (BMessageFilter *filter)
 Add filter as a prerequisite to this handler. More...
 
virtual bool RemoveFilter (BMessageFilter *filter)
 Remove filter from the filter list. More...
 
virtual void SetFilterList (BList *filters)
 Set the internal list of filters to filters. More...
 
BListFilterList ()
 Return a pointer to the list of filters. More...
 
bool LockLooper ()
 Lock the looper associated with this handler. More...
 
status_t LockLooperWithTimeout (bigtime_t timeout)
 Lock the looper associated with this handler, with a time out value. More...
 
void UnlockLooper ()
 Unlock the looper. More...
 
status_t StartWatching (BMessenger target, uint32 what)
 Subscribe this handler to watch a specific state change of a target. More...
 
status_t StartWatchingAll (BMessenger target)
 Subscribe this handler to watch a target for all events. More...
 
status_t StopWatching (BMessenger target, uint32 what)
 Unsubscribe this handler from watching a specific state. More...
 
status_t StopWatchingAll (BMessenger target)
 Unsubscribe this handler from watching all states. More...
 
status_t StartWatching (BHandler *observer, uint32 what)
 Subscribe an observer for a specific state change of this handler. More...
 
status_t StartWatchingAll (BHandler *observer)
 Subscribe an observer for a all state changes. More...
 
status_t StopWatching (BHandler *observer, uint32 what)
 Unsubscribe an observer from watching a specific state. More...
 
status_t StopWatchingAll (BHandler *observer)
 Unsubscribe an observer from watching all states. More...
 
virtual void SendNotices (uint32 what, const BMessage *notice=NULL)
 Emit a state change to the observers. More...
 
bool IsWatched () const
 Check if there are any observers watching this handler. More...
 
- Public Member Functions inherited from BArchivable
 BArchivable (BMessage *from)
 Constructor. Does important behind-the-scenes work in the unarchiving process. More...
 
 BArchivable ()
 Constructor. Does nothing. More...
 
virtual ~BArchivable ()
 Destructor. Does nothing. More...
 

Protected Member Functions

 BMenu (BRect frame, const char *name, uint32 resizeMask, uint32 flags, menu_layout layout, bool resizeToFit)
 Implemented by derived classes to create a new menu object. More...
 
void GetItemMargins (float *_left, float *_top, float *_right, float *_bottom) const
 Fill out the margins into the passed in float pointers. More...
 
void Hide ()
 Hides the view without removing it from the view hierarchy. More...
 
menu_layout Layout () const
 Returns the current menu_layout constant. More...
 
virtual void LayoutInvalidated (bool descendants)
 Hook method called when the layout is invalidated. More...
 
void SetItemMargins (float left, float top, float right, float bottom)
 Set the menu item margins. More...
 
virtual void Show ()
 Shows the view making it visible. More...
 
BMenuItemTrack (bool startOpened=false, BRect *specialRect=NULL)
 Initiates tracking the cursor within the menu. More...
 
- Protected Member Functions inherited from BView
status_t ScrollWithMouseWheelDelta (BScrollBar *, float)
 Handle the scroll wheel changing over scrollbars. More...
 
virtual bool GetToolTipAt (BPoint point, BToolTip **_tip)
 Point _tip with the view's tool tip. More...
 

Archiving

virtual status_t Archive (BMessage *archive, bool deep=true) const
 Archives the the BMenu object into the data message. More...
 
static BArchivableInstantiate (BMessage *archive)
 Creates a new BMenu object from an archive message. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from BView
static BArchivableInstantiate (BMessage *archive)
 Creates a new BView object from the data message. More...
 
- Static Public Member Functions inherited from BHandler
static BArchivableInstantiate (BMessage *data)
 Static method to instantiate a handler from an archived message. More...
 
- Static Public Member Functions inherited from BArchivable
static BArchivableInstantiate (BMessage *archive)
 Static member to restore objects from messages. More...
 

Detailed Description

Displays a list of menu items including additional menus arranged hierarchically.

A newly created BMenu object doesn't contain any menu items, you need to call AddItem() or AddList() to add some.

In addition to BMenuItem objects you can also add additional BMenu objects in order to create a menu hierarchy. Unlike menus in other operating systems you can always select both the submenu and menu items, although selecting the submenu might not actually produce any action other than to close the menu. The name of a submenu is used to draw its label.

BMenu_example.png

BMenu is the basis of several other Interface Kit classes including BMenuBar and BPopUpMenu. See BMenu::SetRadioMode() and BMenu::SetLabelFromMarked() for additional details on how BMenu and BPopUpMenu are related.

Menus arrange their items in one of three possible layouts:

B_ITEMS_IN_COLUMN The menu items are stacked vertically in a column, one on top of another, as in a typical pop-up menu.
B_ITEMS_IN_ROW The menu items are laid out horizontally in a row, from end to end, as in a typical menu bar.
B_ITEMS_IN_MATRIX The menu items are arranged in a free-form arrangement that you create, such as a matrix.

Either B_ITEMS_IN_COLUMN or B_ITEMS_IN_ROW can be passed into the default constructor, but, you should use the constructor that allows you to set the height and width of the menu in order to utilize the B_ITEMS_IN_MATRIX layout.

Several methods will only work in some layouts as noted in the method description below.

Since
BeOS R3

Constructor & Destructor Documentation

◆ BMenu() [1/4]

BMenu::BMenu ( const char *  name,
menu_layout  layout = B_ITEMS_IN_COLUMN 
)

Creates a new menu object with the specified name and layout.

Don't pass B_ITEMS_IN_MATRIX into layout with this method, use BMenu::BMenu(const char* name, float width, float height) instead.

Parameters
nameThe menu's name, serves as a label for submenus.
layoutThe menu layout, possibilities include:
  • B_ITEMS_IN_ROW items are displayed in a single row,
  • B_ITEMS_IN_COLUMN items are displayed in a single column.
Since
BeOS R3

◆ BMenu() [2/4]

BMenu::BMenu ( const char *  name,
float  width,
float  height 
)

Creates a new menu object with a B_ITEMS_IN_MATRIX layout and the specified name, width, and height.

Parameters
nameThe menu's name, serves as a label for submenus.
widthThe menu width.
heightThe menu height.
Since
BeOS R3

◆ BMenu() [3/4]

BMenu::BMenu ( BMessage archive)

Archive constructor.

Parameters
archiveThe message data to construct the menu from.
Since
BeOS R3

◆ ~BMenu()

BMenu::~BMenu ( )
virtual

Destructor.

Also frees the memory used by any attached menu items and submenus.

Since
BeOS R3

◆ BMenu() [4/4]

BMenu::BMenu ( BRect  frame,
const char *  name,
uint32  resizingMode,
uint32  flags,
menu_layout  layout,
bool  resizeToFit 
)
protected

Implemented by derived classes to create a new menu object.

This method is intended to be used by derived classes that don't simply wish to utilize different sorts of menu items or arrange them in a different way, but wish to invent a different kind of menu altogether.

If the layout is set to B_ITEMS_IN_MATRIX the resizeToFit flag should be set to false.

Parameters
frameThe frame rectangle to create the menu in.
nameThe menu's name, serves as a label for submenus.
resizingModeThe resizing mode flags, see BView for more details.
flagsThe view flags, see BView for more details.
layoutThe menu layout, possibilities include:
  • B_ITEMS_IN_ROW items are displayed in a single row,
  • B_ITEMS_IN_COLUMN items are displayed in a single column,
  • B_ITEMS_IN_MATRIX items are displayed in a custom matrix.
resizeToFitWhether or not the menu should automatically resize itself to fit its contents, this will not work in B_ITEMS_IN_MATRIX layout.
Since
BeOS R3

Member Function Documentation

◆ AddDynamicItem()

bool BMenu::AddDynamicItem ( add_state  state)
virtual

Implemented by subclasses to Add a dynamic item to the menu.

Parameters
statePossibilities include:
  • B_INITIAL_ADD,
  • B_PROCESSING,
  • B_ABORT
Returns
true if the dynamic item was added, false otherwise.
Since
Haiku R1

◆ AddItem() [1/6]

bool BMenu::AddItem ( BMenuItem item)

Adds a menu item to the end of the list.

Warning
This method should only be used for a menu in B_ITEMS_IN_COLUMN or B_ITEMS_IN_ROW layout, it is an error to use this method for a menu in B_ITEMS_IN_MATRIX layout.
Parameters
itemThe menu item to add.
Returns
Whether or not the item was added to the menu.
Since
BeOS R3

◆ AddItem() [2/6]

bool BMenu::AddItem ( BMenuItem item,
int32  index 
)

Adds a menu item at the specified index.

Warning
This method should only be used for a menu in B_ITEMS_IN_COLUMN or B_ITEMS_IN_ROW layout, it is an error to use this method for a menu in B_ITEMS_IN_MATRIX layout.
Parameters
itemThe menu item to add.
indexThe index where to add the item to the menu.
Returns
Whether or not the item was added to the menu.
Since
BeOS R3

◆ AddItem() [3/6]

bool BMenu::AddItem ( BMenuItem item,
BRect  frame 
)

Adds a menu item in the specified frame rectangle within the menu.

Warning
This method should only be used for a menu in B_ITEMS_IN_MATRIX layout, it is an error to use this method for a menu in B_ITEMS_IN_COLUMN or B_ITEMS_IN_ROW layout.
Parameters
itemThe menu item to add.
frameThe frame rectangle where to add the item to the menu.
Returns
Whether or not the item was added to the menu.
Since
BeOS R3

◆ AddItem() [4/6]

bool BMenu::AddItem ( BMenu submenu)

Add a submenu to the end of the list.

Warning
This method should only be used for a menu in B_ITEMS_IN_COLUMN or B_ITEMS_IN_ROW layout, it is an error to use this method for a menu in B_ITEMS_IN_MATRIX layout.
Parameters
submenuThe submenu to add.
Returns
Whether or not the submenu was added to the menu.
Since
BeOS R3

◆ AddItem() [5/6]

bool BMenu::AddItem ( BMenu submenu,
int32  index 
)

Add a submenu at the specified index.

Warning
This method should only be used for a menu in B_ITEMS_IN_COLUMN or B_ITEMS_IN_ROW layout, it is an error to use this method for a menu in B_ITEMS_IN_MATRIX layout.
Parameters
submenuThe submenu to add.
indexThe index where to add the submenu to the menu.
Returns
Whether or not the submenu was added to the menu.
Since
BeOS R3

◆ AddItem() [6/6]

bool BMenu::AddItem ( BMenu submenu,
BRect  frame 
)

Adds a submenu in the specified frame rectangle within the menu.

Warning
This method should only be used for a menu in B_ITEMS_IN_MATRIX layout, it is an error to use this method for a menu in B_ITEMS_IN_COLUMN or B_ITEMS_IN_ROW layout.
Parameters
submenuThe submenu to add.
frameThe frame rectangle where to add the submenu to the menu.
Returns
Whether or not the submenu was added to the menu.
Since
BeOS R3

◆ AddList()

bool BMenu::AddList ( BList list,
int32  index 
)

Add a list of menu items at the specified index.

Warning
This method should only be used for a menu in B_ITEMS_IN_COLUMN or B_ITEMS_IN_ROW layout, it is an error to use this method for a menu in B_ITEMS_IN_MATRIX layout.
Parameters
listThe list of menu items to add.
indexThe index where to add the list to the menu.
Returns
Whether or not the list of menu items was added to the menu.
Since
BeOS R3

◆ AddSeparatorItem()

bool BMenu::AddSeparatorItem ( )

Adds a separator item to the end of the menu.

Warning
This method should only be used for a menu in B_ITEMS_IN_COLUMN layout, it is an error to use this method for a menu in B_ITEMS_IN_ROW or B_ITEMS_IN_MATRIX layout.
Returns
Whether or not the separator item was added to the menu.
Since
BeOS R3

◆ AllAttached()

virtual void BMenu::AllAttached ( )
virtual

Similar to AttachedToWindow() but this method is triggered after all child views have already been attached to a window.

Since
BeOS R3

Reimplemented from BView.

Reimplemented in BPopUpMenu, and BMenuBar.

◆ AllDetached()

virtual void BMenu::AllDetached ( )
virtual

Similar to AttachedToWindow() but this method is triggered after all child views have already been detached from a window.

Since
BeOS R3

Reimplemented from BView.

Reimplemented in BPopUpMenu, and BMenuBar.

◆ Archive()

status_t BMenu::Archive ( BMessage data,
bool  deep = true 
) const
virtual

Archives the the BMenu object into the data message.

Parameters
dataA pointer to the BMessage to archive the object into.
deepWhether or not to archive attached menu items as well.
Returns
A status code, B_OK if everything went well or an error code otherwise.
Return values
B_OKThe object was archived successfully.
B_NO_MEMORYRan out of memory while archiving the object.
Since
BeOS R3

Reimplemented from BView.

Reimplemented in BMenuBar, and BPopUpMenu.

◆ AreTriggersEnabled()

bool BMenu::AreTriggersEnabled ( ) const

Returns whether or not triggers are enabled.

Returns
true if triggers are enabled, false if triggers are disabled.
Since
BeOS R3

◆ AttachedToWindow()

void BMenu::AttachedToWindow ( )
virtual

Lays out the menu items and resizes the menu to fit.

Since
BeOS R3

Reimplemented from BView.

Reimplemented in BMenuBar, and BPopUpMenu.

◆ CountItems()

int32 BMenu::CountItems ( ) const

Returns the number of items added to the menu.

Returns
The number of items added to the menu.
Since
BeOS R3

◆ DetachedFromWindow()

virtual void BMenu::DetachedFromWindow ( )
virtual

Hook method called when the object is detached from a window.

Since
BeOS R3

Reimplemented from BView.

Reimplemented in BMenuBar, and BPopUpMenu.

◆ DoLayout()

virtual void BMenu::DoLayout ( )
virtual

Layout view within the layout context.

Remarks
This is only meaningful if the view is part of a BLayout.
Since
Haiku R1

Reimplemented from BView.

◆ Draw()

void BMenu::Draw ( BRect  updateRect)
virtual

Draws the menu.

Parameters
updateRectThe area to draw in.
Since
BeOS R3

Reimplemented from BView.

Reimplemented in BMenuBar.

◆ DrawBackground()

void BMenu::DrawBackground ( BRect  updateRect)
virtual

Draw the menu background within the bounds of updateRect.

Parameters
updateRectThe area to draw the background in.
Since
Haiku R1

◆ FindItem() [1/2]

BMenuItem * BMenu::FindItem ( uint32  command) const

Returns a pointer to the menu item with the specified command for its associated message.

Parameters
commandThe command of the associated message of the menu item to find.
Returns
A pointer to a menu item or NULL if not found.
Since
BeOS R3

◆ FindItem() [2/2]

BMenuItem * BMenu::FindItem ( const char *  label) const

Returns a pointer to the menu item with the specified label.

Parameters
labelThe label of the menu item to find.
Returns
A pointer to a menu item or NULL if not found.
Since
BeOS R3

◆ FindMarked()

BMenuItem * BMenu::FindMarked ( )

Return a pointer to the first marked menu item.

The index starts at the left for a menu in B_ITEMS_IN_COLUMN layout going right or at the top for a menu in B_ITEMS_IN_ROW layout going down.

Warning
This method should only be used for a menu in B_ITEMS_IN_COLUMN or B_ITEMS_IN_ROW layout, it is an error to use this method for a menu in B_ITEMS_IN_MATRIX layout.
Returns
A pointer to the first marked menu item or NULL if not found.
Since
BeOS R3

◆ FindMarkedIndex()

int32 BMenu::FindMarkedIndex ( )

Return the index of the first marked menu item.

The index starts at the left for a menu in B_ITEMS_IN_COLUMN layout going right or at the top for a menu in B_ITEMS_IN_ROW layout going down.

Warning
This method should only be used for a menu in B_ITEMS_IN_COLUMN or B_ITEMS_IN_ROW layout, it is an error to use this method for a menu in B_ITEMS_IN_MATRIX layout.
Returns
The index of the first marked menu item or -1 if not found.
Since
Haiku R1

◆ FrameMoved()

virtual void BMenu::FrameMoved ( BPoint  newPosition)
virtual

Hook method called when the view is moved.

Parameters
newPositionThe point of the top left corner of the frame that the view has been moved to.
Since
BeOS R3

Reimplemented from BView.

Reimplemented in BMenuBar, and BPopUpMenu.

◆ FrameResized()

virtual void BMenu::FrameResized ( float  newWidth,
float  newHeight 
)
virtual

Hook method called when the view is resized.

Parameters
newWidthThe new width of the view.
newHeightThe new height of the view.
Since
BeOS R3

Reimplemented from BView.

Reimplemented in BMenuBar, and BPopUpMenu.

◆ GetItemMargins()

void BMenu::GetItemMargins ( float *  _left,
float *  _top,
float *  _right,
float *  _bottom 
) const
protected

Fill out the margins into the passed in float pointers.

Parameters
_leftThe left margin to fill out, can be NULL.
_topThe top margin to fill out, can be NULL.
_rightThe right margin to fill out, can be NULL.
_bottomThe bottom margin to fill out, can be NULL.
Since
BeOS R3

◆ GetPreferredSize()

virtual void BMenu::GetPreferredSize ( float *  _width,
float *  _height 
)
virtual

Fill out the preferred width and height of the view into the _width and _height parameters.

Derived classes should override this method to set the preferred size of object.

Remarks
Either the _width or _height parameter may be set to NULL if you only want to get the other one.
Parameters
[out]_widthPointer to a float to store the width of the view.
[out]_heightPointer to a float to store the height of the view.
Since
BeOS R3

Reimplemented from BView.

Reimplemented in BMenuBar, and BPopUpMenu.

◆ GetSupportedSuites()

virtual status_t BMenu::GetSupportedSuites ( BMessage data)
virtual

Reports the suites of messages and specifiers that derived classes understand.

Since
BeOS R3

Reimplemented from BView.

Reimplemented in BMenuBar, and BPopUpMenu.

◆ Hide()

void BMenu::Hide ( )
protectedvirtual

Hides the view without removing it from the view hierarchy.

Calls to Hide() and Show() are cumulative. A visible view becomes hidden once the number of Hide() calls exceeds the number of Show() calls.

See also
Show()
BWindow::Hide()
IsHidden()
Since
BeOS R3

Reimplemented from BView.

Reimplemented in BMenuBar.

◆ IndexOf() [1/2]

int32 BMenu::IndexOf ( BMenuItem item) const

Returns the index of the specified menu item.

The index starts at the left for a menu in B_ITEMS_IN_COLUMN layout going right or start at the top for a menu in B_ITEMS_IN_ROW layout going down.

Warning
This method should only be used for a menu in B_ITEMS_IN_COLUMN or B_ITEMS_IN_ROW layout, it is an error to use this method for a menu in B_ITEMS_IN_MATRIX layout.
Returns
The index of the menu item or B_ERROR of not found.
Since
BeOS R3

◆ IndexOf() [2/2]

int32 BMenu::IndexOf ( BMenu submenu) const

Returns the index of the specified submenu.

The index starts at the left for a menu in B_ITEMS_IN_COLUMN layout going right or at the top for a menu in B_ITEMS_IN_ROW layout going down.

Warning
This method should only be used for a menu in B_ITEMS_IN_COLUMN or B_ITEMS_IN_ROW layout, it is an error to use this method for a menu in B_ITEMS_IN_MATRIX layout.
Returns
The index of the submenu or B_ERROR of not found.
Since
BeOS R3

◆ Instantiate()

BArchivable * BMenu::Instantiate ( BMessage archive)
static

Creates a new BMenu object from an archive message.

Returns
A newly created BMenu object or NULL if the message doesn't contain an archived BMenu.
Since
BeOS R3

◆ IsEnabled()

bool BMenu::IsEnabled ( ) const

Returns whether or not the menu is enabled.

Returns
true if menu is enabled, false if it is disabled.
Since
BeOS R3

◆ IsLabelFromMarked()

bool BMenu::IsLabelFromMarked ( )

Returns whether or not the menu is in label-from-marked mode.

Returns
true if menu is in label-from-marked mode, false if not.
Since
BeOS R3

◆ IsRadioMode()

bool BMenu::IsRadioMode ( ) const

Returns whether or not the menu is in radio mode.

Returns
true if menu is in radio mode, false if not.
Since
BeOS R3

◆ IsRedrawAfterSticky()

bool BMenu::IsRedrawAfterSticky ( ) const

Returns whether or not the menu is in redraw-after-sticky mode.

Returns
true if menu is in redraw-after-sticky mode, false if not.
Since
Haiku R1

◆ ItemAt()

BMenuItem * BMenu::ItemAt ( int32  index) const

Returns a pointer to the menu item at the specified index.

Warning
This method should only be used for a menu in B_ITEMS_IN_COLUMN or B_ITEMS_IN_ROW layout, it is an error to use this method for a menu in B_ITEMS_IN_MATRIX layout.
Returns
A pointer to a menu item or NULL if not found.
Since
BeOS R3

◆ KeyDown()

void BMenu::KeyDown ( const char *  bytes,
int32  numBytes 
)
virtual

Hook method that is called when a keyboard key is pressed.

Handles keyboard navigation and triggers.

Parameters
bytesThe bytes of the key combination pressed.
numBytesThe number of bytes in bytes.
Since
BeOS R3

Reimplemented from BView.

◆ Layout()

menu_layout BMenu::Layout ( ) const
protected

Returns the current menu_layout constant.

Since
BeOS R3

◆ LayoutInvalidated()

virtual void BMenu::LayoutInvalidated ( bool  descendants)
protectedvirtual

Hook method called when the layout is invalidated.

Parameters
descendantsWhether or not child views have also been invalidated.
Since
Haiku R1

Reimplemented from BView.

◆ MakeFocus()

virtual void BMenu::MakeFocus ( bool  focus = true)
virtual

Makes the view the current focus view of the window or gives up being the window's focus view.

The focus view handles selections and KeyDown events when the the attached window is active. There can be only one focus view at a time per window.

When called with focus set to true this method first calls MakeFocus() on the previously focused view with focus set to false.

The focus doesn't automatically change when MouseDown() is called so calling MakeFocus() is the only way to make a view the focus view of a window. Classes derived from BView that can display the current selection, or that can accept pasted data should call MakeFocus() in their MouseDown() method to update the focus view of the window on click.

If the view isn't attached to a window this method has no effect.

Parameters
focustrue to set focus, false to remove it.
Since
BeOS R3

Reimplemented from BView.

Reimplemented in BPopUpMenu, and BMenuBar.

◆ MaxContentWidth()

float BMenu::MaxContentWidth ( ) const

Return the maximum width of the menu items' content area.

Returns
The maximum width of the menu items' content area as a float.
See also
SetMaxContentWidth()
Since
BeOS R3

◆ MaxSize()

virtual BSize BMenu::MaxSize ( )
virtual

Return the maximum size of the view.

Remarks
This is only meaningful if the view is part of a BLayout.
Returns
The maximum size of the view as a BSize.
See also
BAbstractLayout::MaxSize()
Since
Haiku R1

Reimplemented from BView.

Reimplemented in BMenuBar.

◆ MessageReceived()

void BMenu::MessageReceived ( BMessage message)
virtual

Handles a message received by the associated looper.

Responds to mouse wheel events scrolling the menu if it is too long to fit in the window. Hold B_SHIFT_KEY to cause the menu to scroll faster.

Parameters
messageThe message received by the associated looper.
Since
BeOS R3

Reimplemented from BView.

Reimplemented in BMenuBar, and BPopUpMenu.

◆ MinSize()

virtual BSize BMenu::MinSize ( )
virtual

Return the minimum size of the view.

Remarks
This is only meaningful if the view is part of a BLayout.
Returns
The minimum size of the view as a BSize.
See also
BAbstractLayout::MinSize()
Since
Haiku R1

Reimplemented from BView.

Reimplemented in BMenuBar.

◆ Perform()

virtual status_t BMenu::Perform ( perform_code  code,
void *  _data 
)
virtual

Perform some action. (Internal Method)

The following perform codes are recognized:

  • PERFORM_CODE_MIN_SIZE:
  • PERFORM_CODE_MAX_SIZE:
  • PERFORM_CODE_PREFERRED_SIZE:
  • PERFORM_CODE_LAYOUT_ALIGNMENT:
  • PERFORM_CODE_HAS_HEIGHT_FOR_WIDTH:
  • PERFORM_CODE_GET_HEIGHT_FOR_WIDTH:
  • PERFORM_CODE_SET_LAYOUT:
  • PERFORM_CODE_INVALIDATE_LAYOUT:
  • PERFORM_CODE_DO_LAYOUT:
  • PERFORM_CODE_GET_TOOL_TIP_AT:
  • PERFORM_CODE_ALL_UNARCHIVED:
  • PERFORM_CODE_ALL_ARCHIVED:
Parameters
codeThe perform code.
_dataA pointer to store some data.
Returns
A status code.
Since
Haiku R1

Reimplemented from BView.

Reimplemented in BMenuBar, and BPopUpMenu.

◆ PreferredSize()

virtual BSize BMenu::PreferredSize ( )
virtual

Return the preferred size of the view.

Remarks
This is only meaningful if the view is part of a BLayout.
Returns
The preferred size of the view as a BSize.
See also
BAbstractLayout::PreferredSize()
Since
Haiku R1

Reimplemented from BView.

Reimplemented in BMenuBar.

◆ RemoveItem() [1/3]

bool BMenu::RemoveItem ( BMenuItem item)

Remove and delete the specified item from the menu.

Returns
Whether or not the item was removed from the menu.
Since
BeOS R3

◆ RemoveItem() [2/3]

BMenuItem * BMenu::RemoveItem ( int32  index)

Remove the item at the specified index from the menu.

The menu item object is not deleted.

Warning
This method should only be used for a menu in B_ITEMS_IN_COLUMN or B_ITEMS_IN_ROW layout, it is an error to use this method for a menu in B_ITEMS_IN_MATRIX layout.
Parameters
indexThe index of where to remove the menu item.
Returns
The menu item object or NULL if not found.
Since
BeOS R3

◆ RemoveItem() [3/3]

bool BMenu::RemoveItem ( BMenu submenu)

Remove and delete a submenu from the menu.

Parameters
submenuThe submenu to remove.
Returns
Whether or not the submenu was removed from the menu.
Since
BeOS R3

◆ RemoveItems()

bool BMenu::RemoveItems ( int32  index,
int32  count,
bool  deleteItems = false 
)

Remove count number of items from the menu starting at the specified index and delete them if deleteItems is true.

Warning
This method should only be used for a menu in B_ITEMS_IN_COLUMN or B_ITEMS_IN_ROW layout, it is an error to use this method for a menu in B_ITEMS_IN_MATRIX layout.
Parameters
indexThe index of where to start removing menu items.
countThe number of items to remove.
deleteItemsWhether or not to delete the items after removing them.
Returns
Whether or not the items were removed from the menu.
Since
BeOS R3

◆ ResizeToPreferred()

virtual void BMenu::ResizeToPreferred ( )
virtual

Resizes the view to its preferred size keeping the position of the left top corner constant.

Warning
It is not recommended to use this method for views that are part of a BLayout.
Since
BeOS R3

Reimplemented from BView.

Reimplemented in BMenuBar, and BPopUpMenu.

◆ ResolveSpecifier()

virtual BHandler* BMenu::ResolveSpecifier ( BMessage message,
int32  index,
BMessage specifier,
int32  what,
const char *  property 
)
virtual

Determine the proper handler for a scripting message.

Parameters
messageThe scripting message to determine the handler.
indexThe index of the specifier.
specifierThe message which contains the specifier.
whatThe 'what' field of the specifier message.
propertyThe name of the target property.
Returns
A pointer to the proper BHandler for the given scripting message.
Since
BeOS R3

Reimplemented from BView.

Reimplemented in BMenuBar, and BPopUpMenu.

◆ SetEnabled()

void BMenu::SetEnabled ( bool  enable)
virtual

Enables or disables the menu.

Parameters
enabletrue to enable, false to disable.
Since
BeOS R3

◆ SetItemMargins()

void BMenu::SetItemMargins ( float  left,
float  top,
float  right,
float  bottom 
)
protected

Set the menu item margins.

Parameters
leftThe left margin to set.
topThe top margin to set.
rightThe right margin to set.
bottomThe bottom margin to set.
Since
BeOS R3

◆ SetLabelFromMarked()

void BMenu::SetLabelFromMarked ( bool  on)

Sets whether or not the label of the menu is set according to the marked item.

Turning label-from-marked mode on also turns radio mode on.

Parameters
ontrue to turn label-from-marked mode on, false to turn it off.
Since
BeOS R3

◆ SetMaxContentWidth()

void BMenu::SetMaxContentWidth ( float  width)
virtual

Sets the maximum width of the menu items' content area.

This is the maximum width that a menu item can draw in. Note that menu items have built-in margins on the left and right sides that are not included as part of the maximum content width.

Parameters
widthThe maximum width for the menu item contents to draw in.
Since
BeOS R3

◆ SetRadioMode()

void BMenu::SetRadioMode ( bool  on)
virtual

Turns radio mode on or off.

Turning radio mode off also turns off label-from-marked mode.

Radio mode means that only one menu item can be set as marked at a time. Marking a menu item automatically unmarks all other menu items and draws a check mark on the left side of the marked menu item. You don't have to call BMenuItem::SetMarked() yourself for a menu in radio mode, this is done for you automatically.

Radio mode does not work recursively, only the current menu is considered. If you want to make a menu work in radio mode recursively you'll have to turn radio mode off and iterate through each menu marking and unmarking the items yourself.

Parameters
ontrue to turn radio mode on, false to turn it off.
Since
BeOS R3

◆ SetTargetForItems() [1/2]

status_t BMenu::SetTargetForItems ( BHandler handler)
virtual

Set the target to handler for each item in the menu.

This is a convenient way to set the target for all the items in a menu.

Parameters
handlerThe BHandler object to set the target of the menu item to.

This method doesn't descend into submenus recursively and only acts on items that have already been added to the menu.

Returns
B_OK on success or an error code on error.
Since
BeOS R3

◆ SetTargetForItems() [2/2]

status_t BMenu::SetTargetForItems ( BMessenger  messenger)
virtual

Set the target to messenger for each item in the menu.

This is a convenient way to set the target for all the items in a menu.

This method doesn't descend into submenus recursively and only acts on items that have already been added to the menu.

Parameters
messengerThe BMessenger object to set the target of the menu item to.
Returns
B_OK on success or an error code on error.
Since
BeOS R3

◆ SetTrackingHook()

void BMenu::SetTrackingHook ( menu_tracking_hook  func,
void *  state 
)

Sets a hook function that is called when tracking begins.

Parameters
funcThe hook function to call.
stateA variable passed to the hook function.
Since
Haiku R1

◆ SetTriggersEnabled()

void BMenu::SetTriggersEnabled ( bool  enable)
virtual

Enables or disables triggers.

Parameters
enabletrue to enable triggers, false to disable triggers.
Since
BeOS R3

◆ Show()

virtual void BMenu::Show ( )
protectedvirtual

Shows the view making it visible.

Calls to Hide() and Show() are cumulative. A hidden view becomes visible again once the number of Show() calls matches the number of Hide() calls.

See also
Hide()
BWindow::Show()
IsHidden()
Since
BeOS R3

Reimplemented from BView.

Reimplemented in BMenuBar.

◆ SubmenuAt()

BMenu * BMenu::SubmenuAt ( int32  index) const

Returns a pointer to a submenu at the specified index.

Warning
This method should only be used for a menu in B_ITEMS_IN_COLUMN or B_ITEMS_IN_ROW layout, it is an error to use this method for a menu in B_ITEMS_IN_MATRIX layout.
Returns
A pointer to a submenu or NULL if not found.
Since
BeOS R3

◆ Superitem()

BMenuItem * BMenu::Superitem ( ) const

Returns the pointer to the menu item that this menu it attached to.

Returns
A pointer to a BMenuItem object or NULL if not found.
Since
BeOS R3

◆ Supermenu()

BMenu * BMenu::Supermenu ( ) const

Returns the pointer to the menu that this menu it attached to.

Returns
A pointer to a BMenu object or NULL if not found.
Since
BeOS R3

◆ Track()

BMenuItem * BMenu::Track ( bool  sticky = false,
BRect clickToOpenRect = NULL 
)
protected

Initiates tracking the cursor within the menu.

This method passes tracking control to submenus hierarchically depending on where the user moves their mouse.

You only need to call this method yourself if you are implementing a menu that needs to track the cursor under nonstandard circumstances.

Parameters
stickyIf true Track() leaves the menu open even after the mouse button is no longer held down.
clickToOpenRectIf sticky is true, leave the menu open even if the user releases the mouse button while the cursor is inside clickToOpenRect.
Returns
A BMenuItem object if the user ends tracking by invoking an item or NULL if the user didn't invoke an item.
Since
BeOS R3