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 <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>
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
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;
65 ToolboxButtonColorUpdaterBase(ToolboxButtonColorUpdaterBase
const &) = delete;
66 ToolboxButtonColorUpdaterBase
& operator =(ToolboxButtonColorUpdaterBase
const &) = delete;
70 bool mbWasHiContrastMode
;
72 tools::Rectangle maUpdRect
;
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
: public ToolboxButtonColorUpdaterBase
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
);
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
: public ToolboxButtonColorUpdaterBase
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
);
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
130 css::drawing::LineStyle m_eXLS
;
131 int m_nDashStyleIndex
;
133 ToolboxButtonLineStyleUpdater();
134 void Update(const css::frame::FeatureStateEvent
& rEvent
);
135 int GetStyleIndex() const;
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */