diff options
-rw-r--r-- | include/vcl/button.hxx | 6 | ||||
-rw-r--r-- | vcl/source/control/button.cxx | 12 | ||||
-rw-r--r-- | vcl/source/control/buttonstatuslistener.cxx | 2 |
3 files changed, 19 insertions, 1 deletions
diff --git a/include/vcl/button.hxx b/include/vcl/button.hxx index cfd32e013b46..93d5b99e8b03 100644 --- a/include/vcl/button.hxx +++ b/include/vcl/button.hxx @@ -31,6 +31,8 @@ #include <vcl/vclptr.hxx> #include <vector> +#include <com/sun/star/frame/FeatureStateEvent.hpp> + class UserDrawEvent; class ImplCommonButtonData; enum class DrawButtonFlags; @@ -91,6 +93,9 @@ public: void SetSmallSymbol(bool bSmall = true); virtual bool set_property(const OString &rKey, const OString &rValue) override; + /// Sets the button state according to the FeatureStateEvent emitted by an Uno state change. + virtual void SetStateUno(const css::frame::FeatureStateEvent& rEvent); + protected: /// Handler for click, in case we want the button to handle uno commands (.uno:Something). @@ -182,6 +187,7 @@ public: void SetState( TriState eState ); TriState GetState() const { return meState; } + virtual void SetStateUno(const css::frame::FeatureStateEvent& rEvent) override; void Check( bool bCheck = true ); bool IsChecked() const; diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index d3435a57c8f2..153c706c6b76 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -617,6 +617,11 @@ bool Button::set_property(const OString &rKey, const OString &rValue) return true; } +void Button::SetStateUno(const css::frame::FeatureStateEvent& rEvent) +{ + Enable(rEvent.IsEnabled); +} + IMPL_STATIC_LINK_TYPED( Button, dispatchCommandHandler, Button*, pButton, void ) { if (pButton == nullptr) @@ -1601,6 +1606,13 @@ void PushButton::SetState( TriState eState ) } } +void PushButton::SetStateUno(const css::frame::FeatureStateEvent& rEvent) +{ + Button::SetStateUno(rEvent); + if (rEvent.State.has<bool>()) + SetPressed(rEvent.State.get<bool>()); +} + void PushButton::SetPressed( bool bPressed ) { if ( mbPressed != bPressed ) diff --git a/vcl/source/control/buttonstatuslistener.cxx b/vcl/source/control/buttonstatuslistener.cxx index 984842df4d1c..bad5452daacf 100644 --- a/vcl/source/control/buttonstatuslistener.cxx +++ b/vcl/source/control/buttonstatuslistener.cxx @@ -45,7 +45,7 @@ ButtonStatusListener::ButtonStatusListener(Button* button, const rtl::OUString& void ButtonStatusListener::statusChanged(const css::frame::FeatureStateEvent& rEvent) throw(css::uno::RuntimeException, std::exception) { - mButton->Enable(rEvent.IsEnabled); + mButton->SetStateUno(rEvent); } void ButtonStatusListener::disposing(const css::lang::EventObject& /*Source*/) |