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/.
10 #ifndef INCLUDED_SVX_COLORBOX_HXX
11 #define INCLUDED_SVX_COLORBOX_HXX
14 #include <vcl/menubtn.hxx>
15 #include <svx/colorwindow.hxx>
16 #include <sfx2/controlwrapper.hxx>
18 class SvxColorListBox
;
20 class SvxListBoxColorWrapper
23 SvxListBoxColorWrapper(SvxColorListBox
* pControl
);
24 void operator()(const OUString
& rCommand
, const NamedColor
& rColor
);
27 VclPtr
<SvxColorListBox
> mxControl
;
30 class SVX_DLLPUBLIC SvxColorListBox
: public MenuButton
33 friend class SvxListBoxColorWrapper
;
34 VclPtr
<SvxColorWindow
> m_xColorWindow
;
35 Link
<SvxColorListBox
&, void> m_aSelectedLink
;
36 SvxListBoxColorWrapper m_aColorWrapper
;
37 Color m_aAutoDisplayColor
;
39 NamedColor m_aSelectedColor
;
41 bool m_bShowNoneButton
;
42 std::unique_ptr
<PaletteManager
> m_xPaletteManager
;
43 BorderColorStatus m_aBorderColorStatus
;
45 DECL_LINK(MenuActivateHdl
, MenuButton
*, void);
46 void Selected(const NamedColor
& rNamedColor
);
47 void createColorWindow();
48 void LockWidthRequest();
49 VclPtr
<SvxColorWindow
> getColorWindow() const;
51 SvxColorListBox(vcl::Window
* pParent
, WinBits nStyle
= 0);
52 virtual ~SvxColorListBox() override
;
53 virtual void dispose() override
;
55 void SetSelectHdl(const Link
<SvxColorListBox
&, void>& rLink
)
57 m_aSelectedLink
= rLink
;
60 void SetSlotId(sal_uInt16 nSlotId
, bool bShowNoneButton
= false);
62 Color
GetSelectEntryColor() const { return m_aSelectedColor
.first
; }
63 NamedColor
GetSelectEntry() const { return m_aSelectedColor
; }
65 void SelectEntry(const NamedColor
& rColor
);
66 void SelectEntry(const Color
& rColor
);
68 void SetNoSelection() { getColorWindow()->SetNoSelection(); }
69 bool IsNoSelection() const { return getColorWindow()->IsNoSelection(); }
71 void SetAutoDisplayColor(const Color
&rColor
) { m_aAutoDisplayColor
= rColor
; }
72 void ShowPreview(const NamedColor
&rColor
);
73 void EnsurePaletteManager();
75 void SaveValue() { m_aSaveColor
= GetSelectEntryColor(); }
76 bool IsValueChangedFromSaved() const { return m_aSaveColor
!= GetSelectEntryColor(); }
79 /** A wrapper for SvxColorListBox. */
80 class SVX_DLLPUBLIC SvxColorListBoxWrapper
81 : public sfx::SingleControlWrapper
<SvxColorListBox
, Color
>
83 /* Note: cannot use 'const Color&' as template argument, because the
84 SvxColorListBox returns the color by value and not by reference,
85 therefore GetControlValue() must return a temporary object too. */
87 explicit SvxColorListBoxWrapper(SvxColorListBox
& rListBox
);
89 virtual ~SvxColorListBoxWrapper() override
;
91 virtual bool IsControlDontKnow() const override
;
92 virtual void SetControlDontKnow( bool bSet
) override
;
94 virtual Color
GetControlValue() const override
;
95 virtual void SetControlValue( Color aColor
) override
;
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */