BToolBar: misc. fixes.
* Move common init. code to an _Init() function. * Create a layout constructor. * Make _AddView public and rename it to AddView.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user