diff --git a/headers/private/shared/ToolBar.h b/headers/private/shared/ToolBar.h index c7122ac4c6..71864290e3 100644 --- a/headers/private/shared/ToolBar.h +++ b/headers/private/shared/ToolBar.h @@ -16,6 +16,7 @@ class BToolBar : public BGroupView { public: BToolBar(BRect frame, orientation ont = B_HORIZONTAL); + BToolBar(orientation ont = B_HORIZONTAL); virtual ~BToolBar(); virtual void Hide(); @@ -30,6 +31,7 @@ public: bool lockable = false); void AddSeparator(); void AddGlue(); + void AddView(BView* view); void SetActionEnabled(uint32 command, bool enabled); void SetActionPressed(uint32 command, bool pressed); @@ -39,7 +41,7 @@ private: virtual void Pulse(); virtual void FrameResized(float width, float height); - void _AddView(BView* view); + void _Init(); BButton* _FindButton(uint32 command) const; void _HideToolTips() const; diff --git a/src/kits/shared/ToolBar.cpp b/src/kits/shared/ToolBar.cpp index 130e40efd1..6ae093c894 100644 --- a/src/kits/shared/ToolBar.cpp +++ b/src/kits/shared/ToolBar.cpp @@ -49,11 +49,7 @@ BToolBar::BToolBar(BRect frame, orientation ont) BGroupView(ont), fOrientation(ont) { - float inset = ceilf(be_control_look->DefaultItemSpacing() / 2); - GroupLayout()->SetInsets(inset, 0, inset, 0); - GroupLayout()->SetSpacing(1); - - SetFlags(Flags() | B_FRAME_EVENTS | B_PULSE_NEEDED); + _Init(); MoveTo(frame.LeftTop()); ResizeTo(frame.Width(), frame.Height()); @@ -61,6 +57,15 @@ BToolBar::BToolBar(BRect frame, orientation ont) } +BToolBar::BToolBar(orientation ont) + : + BGroupView(ont), + fOrientation(ont) +{ + _Init(); +} + + BToolBar::~BToolBar() { } @@ -98,7 +103,7 @@ BToolBar::AddAction(BMessage* message, BHandler* target, button->SetFlat(true); if (toolTipText != NULL) button->SetToolTip(toolTipText); - _AddView(button); + AddView(button); button->SetTarget(target); } @@ -108,7 +113,7 @@ BToolBar::AddSeparator() { orientation ont = (fOrientation == B_HORIZONTAL) ? B_VERTICAL : B_HORIZONTAL; - _AddView(new BSeparatorView(ont, B_PLAIN_BORDER)); + AddView(new BSeparatorView(ont, B_PLAIN_BORDER)); } @@ -119,6 +124,13 @@ BToolBar::AddGlue() } +void +BToolBar::AddView(BView* view) +{ + GroupLayout()->AddView(view); +} + + void BToolBar::SetActionEnabled(uint32 command, bool enabled) { @@ -150,6 +162,9 @@ BToolBar::SetActionVisible(uint32 command, bool visible) } +// #pragma mark - Private methods + + void BToolBar::Pulse() { @@ -170,9 +185,13 @@ BToolBar::FrameResized(float width, float height) void -BToolBar::_AddView(BView* view) +BToolBar::_Init() { - GroupLayout()->AddView(view); + float inset = ceilf(be_control_look->DefaultItemSpacing() / 2); + GroupLayout()->SetInsets(inset, 0, inset, 0); + GroupLayout()->SetSpacing(1); + + SetFlags(Flags() | B_FRAME_EVENTS | B_PULSE_NEEDED); }