summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-06-26 14:28:29 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-06-26 18:13:10 +0200
commitb08292b918f264c4f012ef8c543062cb23ad3b7b (patch)
tree7440515c823cf896ca31f9d5c03d41e612997d83 /framework
parent5d296183072dc7cfe7a9985c38388b56f37d873c (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>
Diffstat (limited to 'framework')
-rw-r--r--framework/inc/uielement/FixedImageToolbarController.hxx7
-rw-r--r--framework/inc/uielement/spinfieldtoolbarcontroller.hxx5
-rw-r--r--framework/source/uielement/FixedImageToolbarController.cxx67
3 files changed, 55 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);
}