LibreOffice Module framework (master) 1
FixedImageToolbarController.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
21
22#include <vcl/graph.hxx>
23#include <vcl/svapp.hxx>
24#include <vcl/toolbox.hxx>
26#include <svtools/miscopt.hxx>
27#include <svtools/imgdef.hxx>
29
30using namespace ::com::sun::star;
31using namespace ::com::sun::star::awt;
32using namespace ::com::sun::star::uno;
33using namespace ::com::sun::star::beans;
34using namespace ::com::sun::star::lang;
35using namespace ::com::sun::star::frame;
36using namespace ::com::sun::star::util;
37
38namespace framework
39{
41{
42public:
43 FixedImageControl(vcl::Window* pParent, const OUString& rCommand);
44 virtual ~FixedImageControl() override;
45 virtual void dispose() override;
46 DECL_LINK(KeyInputHdl, const ::KeyEvent&, bool);
47
48private:
49 std::unique_ptr<weld::Image> m_xWidget;
50};
51
52FixedImageControl::FixedImageControl(vcl::Window* pParent, const OUString& rCommand)
53 : InterimItemWindow(pParent, "svt/ui/fixedimagecontrol.ui", "FixedImageControl")
54 , m_xWidget(m_xBuilder->weld_image("image"))
55{
57
58 m_xWidget->connect_key_press(LINK(this, FixedImageControl, KeyInputHdl));
59
61 auto xImage
62 = Graphic(AddonsOptions().GetImageFromURL(rCommand, bBigImages, true)).GetXGraphic();
63 m_xWidget->set_image(xImage);
64
66}
67
68IMPL_LINK(FixedImageControl, KeyInputHdl, const ::KeyEvent&, rKEvt, bool)
69{
70 return ChildKeyInput(rKEvt);
71}
72
74
76{
77 m_xWidget.reset();
79}
80
82 const Reference<XComponentContext>& rxContext, const Reference<XFrame>& rFrame,
83 ToolBox* pToolbar, ToolBoxItemId nID, const OUString& rCommand)
84 : ComplexToolbarController(rxContext, rFrame, pToolbar, nID, rCommand)
85 , m_eSymbolSize(SvtMiscOptions::GetCurrentSymbolsSize())
86{
88 m_xToolbar->SetItemWindow(m_nID, m_pFixedImageControl);
89
91}
92
94{
95 SolarMutexGuard aSolarMutexGuard;
97 LINK(this, FixedImageToolbarController, MiscOptionsChanged));
98 m_xToolbar->SetItemWindow(m_nID, nullptr);
99 m_pFixedImageControl.disposeAndClear();
101}
102
103void FixedImageToolbarController::executeControlCommand(const css::frame::ControlCommand&) {}
104
106{
107 SolarMutexGuard aSolarMutexGuard;
108
109 const sal_Int16 eNewSymbolSize = SvtMiscOptions::GetCurrentSymbolsSize();
110
111 if (m_eSymbolSize == eNewSymbolSize)
112 return;
113
114 m_eSymbolSize = eNewSymbolSize;
115
116 // Refresh images if requested
117 ::Size aSize(16, 16);
119 {
120 aSize.setWidth(26);
121 aSize.setHeight(26);
122 }
124 {
125 aSize.setWidth(32);
126 aSize.setHeight(32);
127 }
128 m_pFixedImageControl->SetSizePixel(aSize);
129}
130
132{
133 CheckAndUpdateImages();
134}
135
136} // namespace framework
137
138/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::Image > m_xWidget
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
virtual void dispose() override
void InitControlBase(weld::Widget *pWidget)
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
static sal_Int16 GetCurrentSymbolsSize()
void RemoveListenerLink(const Link< LinkParamNone *, void > &rLink)
static bool AreCurrentSymbolsLarge()
void AddListenerLink(const Link< LinkParamNone *, void > &rLink)
static VclPtr< reference_type > Create(Arg &&... arg)
virtual void SAL_CALL dispose() override
FixedImageControl(vcl::Window *pParent, const OUString &rCommand)
DECL_LINK(KeyInputHdl, const ::KeyEvent &, bool)
std::unique_ptr< weld::Image > m_xWidget
FixedImageToolbarController(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::frame::XFrame > &rFrame, ToolBox *pToolBar, ToolBoxItemId nID, const OUString &aCommand)
virtual void executeControlCommand(const css::frame::ControlCommand &rControlCommand) override
virtual void SetSizePixel(const Size &rNewSize)
Size get_preferred_size() const
SFX_SYMBOLS_SIZE_32
SFX_SYMBOLS_SIZE_LARGE
IMPL_LINK(WindowCommandDispatch, impl_notifyCommand, VclWindowEvent &, rEvent, void)
IMPL_LINK_NOARG(CloseDispatcher, impl_asyncCallback, LinkParamNone *, void)
asynchronous callback @descr We start all actions inside this object asynchronous (see comments there...