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:
|
public:
|
||||||
BToolBar(BRect frame,
|
BToolBar(BRect frame,
|
||||||
orientation ont = B_HORIZONTAL);
|
orientation ont = B_HORIZONTAL);
|
||||||
|
BToolBar(orientation ont = B_HORIZONTAL);
|
||||||
virtual ~BToolBar();
|
virtual ~BToolBar();
|
||||||
|
|
||||||
virtual void Hide();
|
virtual void Hide();
|
||||||
@@ -30,6 +31,7 @@ public:
|
|||||||
bool lockable = false);
|
bool lockable = false);
|
||||||
void AddSeparator();
|
void AddSeparator();
|
||||||
void AddGlue();
|
void AddGlue();
|
||||||
|
void AddView(BView* view);
|
||||||
|
|
||||||
void SetActionEnabled(uint32 command, bool enabled);
|
void SetActionEnabled(uint32 command, bool enabled);
|
||||||
void SetActionPressed(uint32 command, bool pressed);
|
void SetActionPressed(uint32 command, bool pressed);
|
||||||
@@ -39,7 +41,7 @@ private:
|
|||||||
virtual void Pulse();
|
virtual void Pulse();
|
||||||
virtual void FrameResized(float width, float height);
|
virtual void FrameResized(float width, float height);
|
||||||
|
|
||||||
void _AddView(BView* view);
|
void _Init();
|
||||||
BButton* _FindButton(uint32 command) const;
|
BButton* _FindButton(uint32 command) const;
|
||||||
void _HideToolTips() const;
|
void _HideToolTips() const;
|
||||||
|
|
||||||
|
|||||||
@@ -49,11 +49,7 @@ BToolBar::BToolBar(BRect frame, orientation ont)
|
|||||||
BGroupView(ont),
|
BGroupView(ont),
|
||||||
fOrientation(ont)
|
fOrientation(ont)
|
||||||
{
|
{
|
||||||
float inset = ceilf(be_control_look->DefaultItemSpacing() / 2);
|
_Init();
|
||||||
GroupLayout()->SetInsets(inset, 0, inset, 0);
|
|
||||||
GroupLayout()->SetSpacing(1);
|
|
||||||
|
|
||||||
SetFlags(Flags() | B_FRAME_EVENTS | B_PULSE_NEEDED);
|
|
||||||
|
|
||||||
MoveTo(frame.LeftTop());
|
MoveTo(frame.LeftTop());
|
||||||
ResizeTo(frame.Width(), frame.Height());
|
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()
|
BToolBar::~BToolBar()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -98,7 +103,7 @@ BToolBar::AddAction(BMessage* message, BHandler* target,
|
|||||||
button->SetFlat(true);
|
button->SetFlat(true);
|
||||||
if (toolTipText != NULL)
|
if (toolTipText != NULL)
|
||||||
button->SetToolTip(toolTipText);
|
button->SetToolTip(toolTipText);
|
||||||
_AddView(button);
|
AddView(button);
|
||||||
button->SetTarget(target);
|
button->SetTarget(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +113,7 @@ BToolBar::AddSeparator()
|
|||||||
{
|
{
|
||||||
orientation ont = (fOrientation == B_HORIZONTAL) ?
|
orientation ont = (fOrientation == B_HORIZONTAL) ?
|
||||||
B_VERTICAL : 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
|
void
|
||||||
BToolBar::SetActionEnabled(uint32 command, bool enabled)
|
BToolBar::SetActionEnabled(uint32 command, bool enabled)
|
||||||
{
|
{
|
||||||
@@ -150,6 +162,9 @@ BToolBar::SetActionVisible(uint32 command, bool visible)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - Private methods
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BToolBar::Pulse()
|
BToolBar::Pulse()
|
||||||
{
|
{
|
||||||
@@ -170,9 +185,13 @@ BToolBar::FrameResized(float width, float height)
|
|||||||
|
|
||||||
|
|
||||||
void
|
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