1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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>
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
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;
69 ToolboxButtonColorUpdaterBase(ToolboxButtonColorUpdaterBase
const &) = delete;
70 ToolboxButtonColorUpdaterBase
& operator =(ToolboxButtonColorUpdaterBase
const &) = delete;
74 bool mbWasHiContrastMode
;
77 tools::Rectangle maUpdRect
;
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
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
);
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
116 virtual vcl::ImageType
GetImageSize() const override
;
117 virtual Size
GetItemSize(const Size
& rImageSize
) const override
;
120 class ToolboxButtonColorUpdater final
: public ToolboxButtonColorUpdaterBase
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
);
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
138 virtual vcl::ImageType
GetImageSize() const override
;
139 virtual Size
GetItemSize(const Size
& rImageSize
) const override
;
142 class ToolboxButtonLineStyleUpdater
145 css::drawing::LineStyle m_eXLS
;
146 int m_nDashStyleIndex
;
148 ToolboxButtonLineStyleUpdater();
149 void Update(const css::frame::FeatureStateEvent
& rEvent
);
150 int GetStyleIndex() const;
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */