LibreOffice Module svx (master) 1
tbxcolorupdate.hxx
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
20#pragma once
21
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 <vcl/toolboxid.hxx>
28#include <svl/lstner.hxx>
29#include <svx/Palette.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>
33
34class ToolBox;
35class VirtualDevice;
36
37namespace weld
38{
39 class Toolbar;
40}
41
42namespace svx
43{
44
45
46 //= ToolboxButtonColorUpdater
47
53 {
54 public:
55 ToolboxButtonColorUpdaterBase(bool bWideButton, OUString aCommandLabel,
56 OUString aCommandURL, sal_uInt16 nSlotId,
57 css::uno::Reference<css::frame::XFrame> xFrame);
58
60
61 void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
62 void SetRecentColor(const NamedColor& rNamedColor);
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;
67
68 private:
71
72 protected:
75 sal_uInt16 mnSlotId;
81 OUString maCommandURL;
82 css::uno::Reference<css::frame::XFrame> mxFrame;
83
84 void Init(sal_uInt16 nSlotId);
85
86 virtual void SetQuickHelpText(const OUString& rText) = 0;
87 virtual OUString GetQuickHelpText() const = 0;
88 virtual void SetImage(VirtualDevice* pVirDev) = 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;
94 };
95
97 {
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);
102
103
104 private:
107
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
113 {
114 return true;
115 }
116 virtual vcl::ImageType GetImageSize() const override;
117 virtual Size GetItemSize(const Size& rImageSize) const override;
118 };
119
121 {
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);
125
126 private:
127 OUString msBtnId;
129
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
135 {
136 return false;
137 }
138 virtual vcl::ImageType GetImageSize() const override;
139 virtual Size GetItemSize(const Size& rImageSize) const override;
140 };
141
143 {
144 private:
145 css::drawing::LineStyle m_eXLS;
147 public:
149 void Update(const css::frame::FeatureStateEvent& rEvent);
150 int GetStyleIndex() const;
151 };
152}
153
154/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
helper class to update a color in a toolbox button image
ToolboxButtonColorUpdaterBase & operator=(ToolboxButtonColorUpdaterBase const &)=delete
void Update(const NamedColor &rNamedColor)
ToolboxButtonColorUpdaterBase(ToolboxButtonColorUpdaterBase const &)=delete
virtual VclPtr< VirtualDevice > CreateVirtualDevice() const =0
ToolboxButtonColorUpdaterBase(bool bWideButton, OUString aCommandLabel, OUString aCommandURL, sal_uInt16 nSlotId, css::uno::Reference< css::frame::XFrame > xFrame)
virtual vcl::ImageType GetImageSize() const =0
void SetRecentColor(const NamedColor &rNamedColor)
virtual void SetImage(VirtualDevice *pVirDev)=0
css::uno::Reference< css::frame::XFrame > mxFrame
virtual Size GetItemSize(const Size &rImageSize) const =0
void Init(sal_uInt16 nSlotId)
void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
virtual bool RecordVirtualDevice() const =0
virtual void SetQuickHelpText(const OUString &rText)=0
virtual OUString GetQuickHelpText() const =0
Color const & GetCurrentColor() const
virtual void SetImage(VirtualDevice *pVirDev) override
virtual vcl::ImageType GetImageSize() const override
virtual Size GetItemSize(const Size &rImageSize) const override
virtual VclPtr< VirtualDevice > CreateVirtualDevice() const override
virtual bool RecordVirtualDevice() const override
ToolboxButtonColorUpdater(sal_uInt16 nSlotId, const OUString &rTbxBtnId, weld::Toolbar *ptrTbx, bool bWideButton, const OUString &rCommandLabel, const css::uno::Reference< css::frame::XFrame > &rFrame)
virtual void SetQuickHelpText(const OUString &rText) override
virtual OUString GetQuickHelpText() const override
void Update(const css::frame::FeatureStateEvent &rEvent)
virtual void SetImage(VirtualDevice *pVirDev) override
virtual OUString GetQuickHelpText() const override
virtual bool RecordVirtualDevice() const override
virtual void SetQuickHelpText(const OUString &rText) override
virtual vcl::ImageType GetImageSize() const override
virtual VclPtr< VirtualDevice > CreateVirtualDevice() const override
virtual Size GetItemSize(const Size &rImageSize) const override
VclToolboxButtonColorUpdater(sal_uInt16 nSlotId, ToolBoxItemId nTbxBtnId, ToolBox *ptrTbx, bool bWideButton, const OUString &rCommandLabel, const OUString &rCommandURL, const css::uno::Reference< css::frame::XFrame > &rFrame)
Reference< XFrame > xFrame