Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / svx / colorbox.hxx
blobe2cb74962aad0225069b388b7b0d0140d229b11c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #ifndef INCLUDED_SVX_COLORBOX_HXX
11 #define INCLUDED_SVX_COLORBOX_HXX
13 #include <memory>
14 #include <vcl/menubtn.hxx>
15 #include <svx/colorwindow.hxx>
16 #include <sfx2/controlwrapper.hxx>
18 class SvxColorListBox;
20 class SvxListBoxColorWrapper
22 public:
23 SvxListBoxColorWrapper(SvxColorListBox* pControl);
24 void operator()(const OUString& rCommand, const NamedColor& rColor);
25 void dispose();
26 private:
27 VclPtr<SvxColorListBox> mxControl;
30 class SVX_DLLPUBLIC SvxColorListBox : public MenuButton
32 private:
33 friend class SvxListBoxColorWrapper;
34 VclPtr<SvxColorWindow> m_xColorWindow;
35 Link<SvxColorListBox&, void> m_aSelectedLink;
36 SvxListBoxColorWrapper m_aColorWrapper;
37 Color m_aAutoDisplayColor;
38 Color m_aSaveColor;
39 NamedColor m_aSelectedColor;
40 sal_uInt16 m_nSlotId;
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;
50 public:
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. */
86 public:
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;
98 #endif
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */