use boost flat_map for faster map
[LibreOffice.git] / svx / inc / tbxcolorupdate.hxx
blobe6520f862a1626e140637c06871c3b9addd91f4a
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 <tools/gen.hxx>
23 #include <tools/color.hxx>
24 #include <vcl/vclenum.hxx>
25 #include <vcl/vclptr.hxx>
26 #include <vcl/toolbox.hxx>
27 #include <svx/Palette.hxx>
28 #include <com/sun/star/drawing/LineStyle.hpp>
29 #include <com/sun/star/frame/FeatureStateEvent.hpp>
30 #include <com/sun/star/frame/XFrame.hpp>
32 class ToolBox;
33 class VirtualDevice;
35 namespace weld
37 class Toolbar;
40 namespace svx
44 //= ToolboxButtonColorUpdater
46 /** helper class to update a color in a toolbox button image
48 formerly known as SvxTbxButtonColorUpdater_Impl, residing in svx/source/tbxctrls/colorwindow.hxx.
50 class ToolboxButtonColorUpdaterBase
52 public:
53 ToolboxButtonColorUpdaterBase(bool bWideButton, const OUString& rCommandLabel,
54 const OUString& rCommandURL,
55 const css::uno::Reference<css::frame::XFrame>& rFrame);
57 virtual ~ToolboxButtonColorUpdaterBase();
59 void Update( const NamedColor& rNamedColor );
60 void Update( const Color& rColor, bool bForceUpdate = false );
61 Color const & GetCurrentColor() const { return maCurColor; }
62 OUString GetCurrentColorName() const;
64 private:
65 ToolboxButtonColorUpdaterBase(ToolboxButtonColorUpdaterBase const &) = delete;
66 ToolboxButtonColorUpdaterBase& operator =(ToolboxButtonColorUpdaterBase const &) = delete;
68 protected:
69 bool mbWideButton;
70 bool mbWasHiContrastMode;
71 Color maCurColor;
72 tools::Rectangle maUpdRect;
73 Size maBmpSize;
74 vcl::ImageType meImageType;
75 OUString maCommandLabel;
76 OUString maCommandURL;
77 css::uno::Reference<css::frame::XFrame> mxFrame;
79 void Init(sal_uInt16 nSlotId);
81 virtual void SetQuickHelpText(const OUString& rText) = 0;
82 virtual OUString GetQuickHelpText() const = 0;
83 virtual void SetImage(VirtualDevice* pVirDev) = 0;
84 virtual VclPtr<VirtualDevice> CreateVirtualDevice() const = 0;
85 virtual vcl::ImageType GetImageSize() const = 0;
86 virtual Size GetItemSize(const Size& rImageSize) const = 0;
89 class VclToolboxButtonColorUpdater final : public ToolboxButtonColorUpdaterBase
91 public:
92 VclToolboxButtonColorUpdater(sal_uInt16 nSlotId, ToolBoxItemId nTbxBtnId, ToolBox* ptrTbx, bool bWideButton,
93 const OUString& rCommandLabel, const OUString& rCommandURL,
94 const css::uno::Reference<css::frame::XFrame>& rFrame);
97 private:
98 ToolBoxItemId mnBtnId;
99 VclPtr<ToolBox> mpTbx;
101 virtual void SetQuickHelpText(const OUString& rText) override;
102 virtual OUString GetQuickHelpText() const override;
103 virtual void SetImage(VirtualDevice* pVirDev) override;
104 virtual VclPtr<VirtualDevice> CreateVirtualDevice() const override;
105 virtual vcl::ImageType GetImageSize() const override;
106 virtual Size GetItemSize(const Size& rImageSize) const override;
109 class ToolboxButtonColorUpdater final : public ToolboxButtonColorUpdaterBase
111 public:
112 ToolboxButtonColorUpdater(sal_uInt16 nSlotId, const OString& rTbxBtnId, weld::Toolbar* ptrTbx, bool bWideButton,
113 const OUString& rCommandLabel, const css::uno::Reference<css::frame::XFrame>& rFrame);
115 private:
116 OString msBtnId;
117 weld::Toolbar* mpTbx;
119 virtual void SetQuickHelpText(const OUString& rText) override;
120 virtual OUString GetQuickHelpText() const override;
121 virtual void SetImage(VirtualDevice* pVirDev) override;
122 virtual VclPtr<VirtualDevice> CreateVirtualDevice() const override;
123 virtual vcl::ImageType GetImageSize() const override;
124 virtual Size GetItemSize(const Size& rImageSize) const override;
127 class ToolboxButtonLineStyleUpdater
129 private:
130 css::drawing::LineStyle m_eXLS;
131 int m_nDashStyleIndex;
132 public:
133 ToolboxButtonLineStyleUpdater();
134 void Update(const css::frame::FeatureStateEvent& rEvent);
135 int GetStyleIndex() const;
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */