diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-06-26 14:28:29 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-06-26 18:13:10 +0200 |
commit | b08292b918f264c4f012ef8c543062cb23ad3b7b (patch) | |
tree | 7440515c823cf896ca31f9d5c03d41e612997d83 | |
parent | 5d296183072dc7cfe7a9985c38388b56f37d873c (diff) |
weld FixedImageControl
Change-Id: I13f3480794232a9c203ae047a4fcad372988b8b8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97235
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | framework/inc/uielement/FixedImageToolbarController.hxx | 7 | ||||
-rw-r--r-- | framework/inc/uielement/spinfieldtoolbarcontroller.hxx | 5 | ||||
-rw-r--r-- | framework/source/uielement/FixedImageToolbarController.cxx | 67 | ||||
-rw-r--r-- | svtools/UIConfig_svt.mk | 1 | ||||
-rw-r--r-- | svtools/uiconfig/ui/fixedimagecontrol.ui | 24 |
5 files changed, 80 insertions, 24 deletions
diff --git a/framework/inc/uielement/FixedImageToolbarController.hxx b/framework/inc/uielement/FixedImageToolbarController.hxx index 2f10503e5343..66533fbc9cde 100644 --- a/framework/inc/uielement/FixedImageToolbarController.hxx +++ b/framework/inc/uielement/FixedImageToolbarController.hxx @@ -23,13 +23,14 @@ #include <com/sun/star/frame/ControlCommand.hpp> #include <uielement/complextoolbarcontroller.hxx> -#include <vcl/fixed.hxx> +#include <vcl/vclptr.hxx> class ToolBox; -class FixedImage; namespace framework { +class FixedImageControl; + class FixedImageToolbarController final : public ComplexToolbarController { public: @@ -47,7 +48,7 @@ private: DECL_LINK(MiscOptionsChanged, LinkParamNone*, void); - VclPtr<FixedImage> m_pFixedImageControl; + VclPtr<FixedImageControl> m_pFixedImageControl; sal_Int16 m_eSymbolSize; }; } // namespace framework diff --git a/framework/inc/uielement/spinfieldtoolbarcontroller.hxx b/framework/inc/uielement/spinfieldtoolbarcontroller.hxx index 3e2af6c78719..8085c68c1cbf 100644 --- a/framework/inc/uielement/spinfieldtoolbarcontroller.hxx +++ b/framework/inc/uielement/spinfieldtoolbarcontroller.hxx @@ -23,7 +23,6 @@ #include <com/sun/star/frame/ControlCommand.hpp> #include <uielement/complextoolbarcontroller.hxx> -#include <vcl/event.hxx> #include <vcl/vclptr.hxx> class ToolBox; @@ -49,10 +48,6 @@ class SpinfieldToolbarController final : public ComplexToolbarController virtual void SAL_CALL dispose() override; // called from SpinfieldControl - void Up(); - void Down(); - void First(); - void Last(); void Modify(); void GetFocus(); void LoseFocus(); diff --git a/framework/source/uielement/FixedImageToolbarController.cxx b/framework/source/uielement/FixedImageToolbarController.cxx index cfc987d97d3f..a666261b0f03 100644 --- a/framework/source/uielement/FixedImageToolbarController.cxx +++ b/framework/source/uielement/FixedImageToolbarController.cxx @@ -19,9 +19,10 @@ #include <uielement/FixedImageToolbarController.hxx> +#include <vcl/graph.hxx> #include <vcl/svapp.hxx> #include <vcl/toolbox.hxx> -#include <vcl/fixed.hxx> +#include <vcl/InterimItemWindow.hxx> #include <svtools/miscopt.hxx> #include <svtools/imgdef.hxx> #include <framework/addonsoptions.hxx> @@ -36,21 +37,60 @@ using namespace ::com::sun::star::util; namespace framework { +class FixedImageControl final : public InterimItemWindow +{ +public: + FixedImageControl(vcl::Window* pParent, const OUString& rCommand); + virtual ~FixedImageControl() override; + virtual void dispose() override; + virtual void GetFocus() override + { + if (m_xWidget) + m_xWidget->grab_focus(); + InterimItemWindow::GetFocus(); + } + DECL_LINK(KeyInputHdl, const ::KeyEvent&, bool); + +private: + std::unique_ptr<weld::Image> m_xWidget; +}; + +FixedImageControl::FixedImageControl(vcl::Window* pParent, const OUString& rCommand) + : InterimItemWindow(pParent, "svt/ui/fixedimagecontrol.ui", "FixedImageControl") + , m_xWidget(m_xBuilder->weld_image("image")) +{ + m_xWidget->connect_key_press(LINK(this, FixedImageControl, KeyInputHdl)); + + bool bBigImages(SvtMiscOptions().AreCurrentSymbolsLarge()); + auto xImage + = Graphic(AddonsOptions().GetImageFromURL(rCommand, bBigImages, true)).GetXGraphic(); + m_xWidget->set_image(xImage); + + SetSizePixel(get_preferred_size()); +} + +IMPL_LINK(FixedImageControl, KeyInputHdl, const ::KeyEvent&, rKEvt, bool) +{ + return ChildKeyInput(rKEvt); +} + +FixedImageControl::~FixedImageControl() { disposeOnce(); } + +void FixedImageControl::dispose() +{ + m_xWidget.reset(); + InterimItemWindow::dispose(); +} + FixedImageToolbarController::FixedImageToolbarController( const Reference<XComponentContext>& rxContext, const Reference<XFrame>& rFrame, - ToolBox* pToolbar, sal_uInt16 nID, const OUString& aCommand) - : ComplexToolbarController(rxContext, rFrame, pToolbar, nID, aCommand) + ToolBox* pToolbar, sal_uInt16 nID, const OUString& rCommand) + : ComplexToolbarController(rxContext, rFrame, pToolbar, nID, rCommand) , m_eSymbolSize(SvtMiscOptions().GetCurrentSymbolsSize()) { - m_pFixedImageControl = VclPtr<FixedImage>::Create(m_xToolbar, 0); + m_pFixedImageControl = VclPtr<FixedImageControl>::Create(m_xToolbar, rCommand); m_xToolbar->SetItemWindow(m_nID, m_pFixedImageControl); - bool bBigImages(SvtMiscOptions().AreCurrentSymbolsLarge()); - - Image aImage(AddonsOptions().GetImageFromURL(aCommand, bBigImages, true)); - m_pFixedImageControl->SetImage(aImage); - m_pFixedImageControl->SetSizePixel(m_pFixedImageControl->GetOptimalSize()); - SvtMiscOptions().AddListenerLink(LINK(this, FixedImageToolbarController, MiscOptionsChanged)); } @@ -79,7 +119,7 @@ void FixedImageToolbarController::CheckAndUpdateImages() m_eSymbolSize = eNewSymbolSize; // Refresh images if requested - auto aSize(m_pFixedImageControl->GetOptimalSize()); + ::Size aSize(16, 16); if (m_eSymbolSize == SFX_SYMBOLS_SIZE_LARGE) { aSize.setWidth(26); @@ -90,11 +130,6 @@ void FixedImageToolbarController::CheckAndUpdateImages() aSize.setWidth(32); aSize.setHeight(32); } - else - { - aSize.setWidth(16); - aSize.setHeight(16); - } m_pFixedImageControl->SetSizePixel(aSize); } diff --git a/svtools/UIConfig_svt.mk b/svtools/UIConfig_svt.mk index 46fd24e6a4c2..cca4c8c824e9 100644 --- a/svtools/UIConfig_svt.mk +++ b/svtools/UIConfig_svt.mk @@ -17,6 +17,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svt,\ svtools/uiconfig/ui/editcontrol \ svtools/uiconfig/ui/emptypage \ svtools/uiconfig/ui/fileviewmenu \ + svtools/uiconfig/ui/fixedimagecontrol \ svtools/uiconfig/ui/graphicexport \ svtools/uiconfig/ui/inputbox \ svtools/uiconfig/ui/javadisableddialog \ diff --git a/svtools/uiconfig/ui/fixedimagecontrol.ui b/svtools/uiconfig/ui/fixedimagecontrol.ui new file mode 100644 index 000000000000..d0778273b2bf --- /dev/null +++ b/svtools/uiconfig/ui/fixedimagecontrol.ui @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.2 --> +<interface domain="svt"> + <requires lib="gtk+" version="3.18"/> + <object class="GtkBox" id="FixedImageControl"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkImage" id="image"> + <property name="name">image</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="stock">gtk-missing-image</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> +</interface> |