BButton: Add optional pop-up marker
* Add behavior constant B_POP_UP_BEHAVIOR which adds a pop-up marker to the button (similar to that of BMenuField). * Add methods [Set]PopUpMessage(). To set/get the the message that is sent to the button's target when the pop-up marker is clicked.
This commit is contained in:
@@ -13,6 +13,7 @@ public:
|
||||
enum BBehavior {
|
||||
B_BUTTON_BEHAVIOR,
|
||||
B_TOGGLE_BEHAVIOR,
|
||||
B_POP_UP_BEHAVIOR,
|
||||
};
|
||||
|
||||
public:
|
||||
@@ -51,6 +52,9 @@ public:
|
||||
BBehavior Behavior() const;
|
||||
void SetBehavior(BBehavior behavior);
|
||||
|
||||
BMessage* PopUpMessage() const;
|
||||
void SetPopUpMessage(BMessage* message);
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void WindowActivated(bool active);
|
||||
virtual void MouseMoved(BPoint point, uint32 transit,
|
||||
@@ -82,7 +86,6 @@ public:
|
||||
|
||||
virtual status_t SetIcon(const BBitmap* icon, uint32 flags = 0);
|
||||
|
||||
|
||||
protected:
|
||||
virtual void LayoutInvalidated(bool descendants = false);
|
||||
|
||||
@@ -95,6 +98,8 @@ private:
|
||||
|
||||
BSize _ValidatePreferredSize();
|
||||
|
||||
BRect _PopUpRect() const;
|
||||
|
||||
inline bool _Flag(uint32 flag) const;
|
||||
inline bool _SetFlag(uint32 flag, bool set);
|
||||
|
||||
@@ -102,8 +107,7 @@ private:
|
||||
BSize fPreferredSize;
|
||||
uint32 fFlags;
|
||||
BBehavior fBehavior;
|
||||
|
||||
uint32 _reserved[1];
|
||||
BMessage* fPopUpMessage;
|
||||
};
|
||||
|
||||
#endif // _BUTTON_H
|
||||
|
||||
@@ -44,6 +44,7 @@ public:
|
||||
|
||||
enum background_type {
|
||||
B_BUTTON_BACKGROUND,
|
||||
B_BUTTON_WITH_POP_UP_BACKGROUND,
|
||||
B_MENU_BACKGROUND,
|
||||
B_MENU_BAR_BACKGROUND,
|
||||
B_MENU_FIELD_BACKGROUND,
|
||||
@@ -360,6 +361,30 @@ public:
|
||||
uint32 flags, float& _left, float& _top,
|
||||
float& _right, float& _bottom);
|
||||
|
||||
virtual void DrawButtonWithPopUpBackground(BView* view,
|
||||
BRect& rect, const BRect& updateRect,
|
||||
const rgb_color& base,
|
||||
uint32 flags = 0,
|
||||
uint32 borders = B_ALL_BORDERS,
|
||||
orientation orientation = B_HORIZONTAL);
|
||||
virtual void DrawButtonWithPopUpBackground(BView* view,
|
||||
BRect& rect, const BRect& updateRect,
|
||||
float radius,
|
||||
const rgb_color& base,
|
||||
uint32 flags = 0,
|
||||
uint32 borders = B_ALL_BORDERS,
|
||||
orientation orientation = B_HORIZONTAL);
|
||||
virtual void DrawButtonWithPopUpBackground(BView* view,
|
||||
BRect& rect, const BRect& updateRect,
|
||||
float leftTopRadius,
|
||||
float rightTopRadius,
|
||||
float leftBottomRadius,
|
||||
float rightBottomRadius,
|
||||
const rgb_color& base,
|
||||
uint32 flags = 0,
|
||||
uint32 borders = B_ALL_BORDERS,
|
||||
orientation orientation = B_HORIZONTAL);
|
||||
|
||||
void SetBackgroundInfo(
|
||||
const BMessage& backgroundInfo);
|
||||
|
||||
@@ -405,9 +430,32 @@ protected:
|
||||
float leftBottomRadius,
|
||||
float rightBottomRadius,
|
||||
const rgb_color& base,
|
||||
bool popupIndicator = false,
|
||||
uint32 flags = 0,
|
||||
uint32 borders = B_ALL_BORDERS,
|
||||
orientation orientation = B_HORIZONTAL);
|
||||
void _DrawFlatButtonBackground(BView* view,
|
||||
BRect& rect, const BRect& updateRect,
|
||||
const rgb_color& base,
|
||||
bool popupIndicator = false,
|
||||
uint32 flags = 0,
|
||||
uint32 borders = B_ALL_BORDERS,
|
||||
orientation orientation = B_HORIZONTAL);
|
||||
void _DrawNonFlatButtonBackground(BView* view,
|
||||
BRect& rect, const BRect& updateRect,
|
||||
BRegion& clipping,
|
||||
float leftTopRadius,
|
||||
float rightTopRadius,
|
||||
float leftBottomRadius,
|
||||
float rightBottomRadius,
|
||||
const rgb_color& base,
|
||||
bool popupIndicator = false,
|
||||
uint32 flags = 0,
|
||||
uint32 borders = B_ALL_BORDERS,
|
||||
orientation orientation = B_HORIZONTAL);
|
||||
|
||||
void _DrawPopUpMarker(BView* view, const BRect& rect,
|
||||
const rgb_color& base, uint32 flags);
|
||||
|
||||
void _DrawMenuFieldBackgroundOutside(BView* view,
|
||||
BRect& rect, const BRect& updateRect,
|
||||
|
||||
Reference in New Issue
Block a user