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 <svx/Palette.hxx>
29#include <com/sun/star/drawing/LineStyle.hpp>
30#include <com/sun/star/frame/FeatureStateEvent.hpp>
31#include <com/sun/star/frame/XFrame.hpp>
32
33class ToolBox;
34class VirtualDevice;
35
36namespace weld
37{
38 class Toolbar;
39}
40
41namespace svx
42{
43
44
45 //= ToolboxButtonColorUpdater
46
52 {
53 public:
54 ToolboxButtonColorUpdaterBase(bool bWideButton, OUString aCommandLabel,
55 OUString aCommandURL,
56 css::uno::Reference<css::frame::XFrame> xFrame);
57
59
60 void Update( const NamedColor& rNamedColor );
61 void Update( const Color& rColor, bool bForceUpdate = false );
62 Color const & GetCurrentColor() const { return maCurColor; }
63 OUString GetCurrentColorName() const;
64
65 private:
68
69 protected:
77 OUString maCommandURL;
78 css::uno::Reference<css::frame::XFrame> mxFrame;
79
80 void Init(sal_uInt16 nSlotId);
81
82 virtual void SetQuickHelpText(const OUString& rText) = 0;
83 virtual OUString GetQuickHelpText() const = 0;
84 virtual void SetImage(VirtualDevice* pVirDev) = 0;
86 // true -> use Device to Record to Metafile, false -> Render to Device
87 virtual bool RecordVirtualDevice() const = 0;
88 virtual vcl::ImageType GetImageSize() const = 0;
89 virtual Size GetItemSize(const Size& rImageSize) const = 0;
90 };
91
93 {
94 public:
95 VclToolboxButtonColorUpdater(sal_uInt16 nSlotId, ToolBoxItemId nTbxBtnId, ToolBox* ptrTbx, bool bWideButton,
96 const OUString& rCommandLabel, const OUString& rCommandURL,
97 const css::uno::Reference<css::frame::XFrame>& rFrame);
98
99
100 private:
103
104 virtual void SetQuickHelpText(const OUString& rText) override;
105 virtual OUString GetQuickHelpText() const override;
106 virtual void SetImage(VirtualDevice* pVirDev) override;
107 virtual VclPtr<VirtualDevice> CreateVirtualDevice() const override;
108 virtual bool RecordVirtualDevice() const override
109 {
110 return true;
111 }
112 virtual vcl::ImageType GetImageSize() const override;
113 virtual Size GetItemSize(const Size& rImageSize) const override;
114 };
115
117 {
118 public:
119 ToolboxButtonColorUpdater(sal_uInt16 nSlotId, const OString& rTbxBtnId, weld::Toolbar* ptrTbx, bool bWideButton,
120 const OUString& rCommandLabel, const css::uno::Reference<css::frame::XFrame>& rFrame);
121
122 private:
123 OString msBtnId;
125
126 virtual void SetQuickHelpText(const OUString& rText) override;
127 virtual OUString GetQuickHelpText() const override;
128 virtual void SetImage(VirtualDevice* pVirDev) override;
129 virtual VclPtr<VirtualDevice> CreateVirtualDevice() const override;
130 virtual bool RecordVirtualDevice() const override
131 {
132 return false;
133 }
134 virtual vcl::ImageType GetImageSize() const override;
135 virtual Size GetItemSize(const Size& rImageSize) const override;
136 };
137
139 {
140 private:
141 css::drawing::LineStyle m_eXLS;
143 public:
145 void Update(const css::frame::FeatureStateEvent& rEvent);
146 int GetStyleIndex() const;
147 };
148}
149
150/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::pair< Color, OUString > NamedColor
Definition: Palette.hxx:30
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
virtual vcl::ImageType GetImageSize() const =0
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)
virtual bool RecordVirtualDevice() const =0
virtual void SetQuickHelpText(const OUString &rText)=0
virtual OUString GetQuickHelpText() const =0
ToolboxButtonColorUpdaterBase(bool bWideButton, OUString aCommandLabel, OUString aCommandURL, css::uno::Reference< css::frame::XFrame > xFrame)
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 OString &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