From 6b8712663acc699606054363a509f6e6cbed3fd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 2 Sep 2015 21:31:09 +0200 Subject: [PATCH] BToolBar: made FindButton() public. --- headers/private/shared/ToolBar.h | 3 ++- src/kits/shared/ToolBar.cpp | 46 ++++++++++++++++---------------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/headers/private/shared/ToolBar.h b/headers/private/shared/ToolBar.h index 57d9ff9a32..b5468859ec 100644 --- a/headers/private/shared/ToolBar.h +++ b/headers/private/shared/ToolBar.h @@ -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; diff --git a/src/kits/shared/ToolBar.cpp b/src/kits/shared/ToolBar.cpp index daabc66221..e29fe50005 100644 --- a/src/kits/shared/ToolBar.cpp +++ b/src/kits/shared/ToolBar.cpp @@ -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(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(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 {