loplugin:unnecessaryvirtual
[LibreOffice.git] / svx / inc / tbxcolorupdate.hxx
blob7e2170c7b5996183b9609d1823396925472aa338
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <sfx2/namedcolor.hxx>
23 #include <tools/gen.hxx>
24 #include <tools/color.hxx>
25 #include <vcl/vclenum.hxx>
26 #include <vcl/vclptr.hxx>
27 #include <vcl/toolbox.hxx>
28 #include <vcl/toolboxid.hxx>
29 #include <svl/lstner.hxx>
30 #include <com/sun/star/drawing/LineStyle.hpp>
31 #include <com/sun/star/frame/FeatureStateEvent.hpp>
32 #include <com/sun/star/frame/XFrame.hpp>
34 class ToolBox;
35 class VirtualDevice;
37 namespace weld
39 class Toolbar;
42 namespace svx
46 //= ToolboxButtonColorUpdater
48 /** helper class to update a color in a toolbox button image
50 formerly known as SvxTbxButtonColorUpdater_Impl, residing in svx/source/tbxctrls/colorwindow.hxx.
52 class ToolboxButtonColorUpdaterBase : public SfxListener
54 public:
55 ToolboxButtonColorUpdaterBase(bool bWideButton, OUString aCommandLabel,
56 OUString aCommandURL, sal_uInt16 nSlotId,
57 css::uno::Reference<css::frame::XFrame> xFrame);
59 virtual ~ToolboxButtonColorUpdaterBase();
61 void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
62 void SetRecentColor(const NamedColor& rNamedColor, bool bBroadcast = true);
63 void Update( const NamedColor& rNamedColor );
64 void Update( const Color& rColor, bool bForceUpdate = false );
65 Color const & GetCurrentColor() const { return maCurColor; }
66 OUString GetCurrentColorName() const;
68 private:
69 ToolboxButtonColorUpdaterBase(ToolboxButtonColorUpdaterBase const &) = delete;
70 ToolboxButtonColorUpdaterBase& operator =(ToolboxButtonColorUpdaterBase const &) = delete;
72 protected:
73 bool mbWideButton;
74 bool mbWasHiContrastMode;
75 sal_uInt16 mnSlotId;
76 Color maCurColor;
77 tools::Rectangle maUpdRect;
78 Size maBmpSize;
79 vcl::ImageType meImageType;
80 OUString maCommandLabel;
81 OUString maCommandURL;
82 css::uno::Reference<css::frame::XFrame> mxFrame;
84 void Init(sal_uInt16 nSlotId);
86 virtual void SetQuickHelpText(const OUString& rText) = 0;
87 virtual OUString GetQuickHelpText() const = 0;
88 virtual void SetImage(VirtualDevice* pVirDev) = 0;
89 virtual VclPtr<VirtualDevice> CreateVirtualDevice() const = 0;
90 // true -> use Device to Record to Metafile, false -> Render to Device
91 virtual bool RecordVirtualDevice() const = 0;
92 virtual vcl::ImageType GetImageSize() const = 0;
93 virtual Size GetItemSize(const Size& rImageSize) const = 0;
96 class VclToolboxButtonColorUpdater final : public ToolboxButtonColorUpdaterBase
98 public:
99 VclToolboxButtonColorUpdater(sal_uInt16 nSlotId, ToolBoxItemId nTbxBtnId, ToolBox* ptrTbx, bool bWideButton,
100 const OUString& rCommandLabel, const OUString& rCommandURL,
101 const css::uno::Reference<css::frame::XFrame>& rFrame);
104 private:
105 ToolBoxItemId mnBtnId;
106 VclPtr<ToolBox> mpTbx;
108 virtual void SetQuickHelpText(const OUString& rText) override;
109 virtual OUString GetQuickHelpText() const override;
110 virtual void SetImage(VirtualDevice* pVirDev) override;
111 virtual VclPtr<VirtualDevice> CreateVirtualDevice() const override;
112 virtual bool RecordVirtualDevice() const override
114 return true;
116 virtual vcl::ImageType GetImageSize() const override;
117 virtual Size GetItemSize(const Size& rImageSize) const override;
120 class ToolboxButtonColorUpdater final : public ToolboxButtonColorUpdaterBase
122 public:
123 ToolboxButtonColorUpdater(sal_uInt16 nSlotId, const OUString& rTbxBtnId, weld::Toolbar* ptrTbx, bool bWideButton,
124 const OUString& rCommandLabel, const css::uno::Reference<css::frame::XFrame>& rFrame);
126 private:
127 OUString msBtnId;
128 weld::Toolbar* mpTbx;
130 virtual void SetQuickHelpText(const OUString& rText) override;
131 virtual OUString GetQuickHelpText() const override;
132 virtual void SetImage(VirtualDevice* pVirDev) override;
133 virtual VclPtr<VirtualDevice> CreateVirtualDevice() const override;
134 virtual bool RecordVirtualDevice() const override
136 return false;
138 virtual vcl::ImageType GetImageSize() const override;
139 virtual Size GetItemSize(const Size& rImageSize) const override;
142 class ToolboxButtonLineStyleUpdater
144 private:
145 css::drawing::LineStyle m_eXLS;
146 int m_nDashStyleIndex;
147 public:
148 ToolboxButtonLineStyleUpdater();
149 void Update(const css::frame::FeatureStateEvent& rEvent);
150 int GetStyleIndex() const;
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */