BToolBar: made FindButton() public.

This commit is contained in:
Axel Dörfler 2015-09-02 21:31:09 +02:00
parent 50d381e862
commit 6b8712663a
2 changed files with 25 additions and 24 deletions

View File

@ -39,12 +39,13 @@ public:
void SetActionPressed(uint32 command, bool pressed);
void SetActionVisible(uint32 command, bool visible);
BButton* FindButton(uint32 command) const;
private:
virtual void Pulse();
virtual void FrameResized(float width, float height);
void _Init();
BButton* _FindButton(uint32 command) const;
void _HideToolTips() const;
orientation fOrientation;

View File

@ -136,7 +136,7 @@ BToolBar::AddView(BView* view)
void
BToolBar::SetActionEnabled(uint32 command, bool enabled)
{
if (BButton* button = _FindButton(command))
if (BButton* button = FindButton(command))
button->SetEnabled(enabled);
}
@ -144,7 +144,7 @@ BToolBar::SetActionEnabled(uint32 command, bool enabled)
void
BToolBar::SetActionPressed(uint32 command, bool pressed)
{
if (BButton* button = _FindButton(command))
if (BButton* button = FindButton(command))
button->SetValue(pressed);
}
@ -152,7 +152,7 @@ BToolBar::SetActionPressed(uint32 command, bool pressed)
void
BToolBar::SetActionVisible(uint32 command, bool visible)
{
BButton* button = _FindButton(command);
BButton* button = FindButton(command);
if (button == NULL)
return;
for (int32 i = 0; BLayoutItem* item = GroupLayout()->ItemAt(i); i++) {
@ -164,6 +164,26 @@ BToolBar::SetActionVisible(uint32 command, bool visible)
}
BButton*
BToolBar::FindButton(uint32 command) const
{
for (int32 i = 0; BView* view = ChildAt(i); i++) {
BButton* button = dynamic_cast<BButton*>(view);
if (button == NULL)
continue;
BMessage* message = button->Message();
if (message == NULL)
continue;
if (message->what == command) {
return button;
// Assumes there is only one button with this message...
break;
}
}
return NULL;
}
// #pragma mark - Private methods
@ -197,26 +217,6 @@ BToolBar::_Init()
}
BButton*
BToolBar::_FindButton(uint32 command) const
{
for (int32 i = 0; BView* view = ChildAt(i); i++) {
BButton* button = dynamic_cast<BButton*>(view);
if (button == NULL)
continue;
BMessage* message = button->Message();
if (message == NULL)
continue;
if (message->what == command) {
return button;
// Assumes there is only one button with this message...
break;
}
}
return NULL;
}
void
BToolBar::_HideToolTips() const
{