bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / svx / colorbox.hxx
bloba9b38b7612ba715fd098aafeec85bb5d90fe024d
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 <vcl/weld.hxx>
16 #include <svx/colorwindow.hxx>
18 class SvxColorListBox;
19 class ColorListBox;
21 class SvxListBoxColorWrapper
23 public:
24 SvxListBoxColorWrapper(SvxColorListBox* pControl);
25 void operator()(const OUString& rCommand, const NamedColor& rColor);
26 void dispose();
27 private:
28 VclPtr<SvxColorListBox> mxControl;
31 class SVX_DLLPUBLIC SvxColorListBox : public MenuButton
33 private:
34 friend class SvxListBoxColorWrapper;
35 VclPtr<SvxColorWindow> m_xColorWindow;
36 Link<SvxColorListBox&, void> m_aSelectedLink;
37 SvxListBoxColorWrapper m_aColorWrapper;
38 Color m_aAutoDisplayColor;
39 Color m_aSaveColor;
40 NamedColor m_aSelectedColor;
41 sal_uInt16 m_nSlotId;
42 bool m_bShowNoneButton;
43 std::shared_ptr<PaletteManager> m_xPaletteManager;
44 ColorStatus m_aColorStatus;
46 DECL_LINK(MenuActivateHdl, MenuButton *, void);
47 void Selected(const NamedColor& rNamedColor);
48 void createColorWindow();
49 void LockWidthRequest();
50 VclPtr<SvxColorWindow> const & getColorWindow() const;
51 public:
52 SvxColorListBox(vcl::Window* pParent, WinBits nStyle = 0);
53 virtual ~SvxColorListBox() override;
54 virtual void dispose() override;
56 void SetSelectHdl(const Link<SvxColorListBox&, void>& rLink)
58 m_aSelectedLink = rLink;
61 void SetSlotId(sal_uInt16 nSlotId, bool bShowNoneButton = false);
63 Color const & GetSelectEntryColor() const { return m_aSelectedColor.first; }
64 NamedColor const & GetSelectedEntry() const { return m_aSelectedColor; }
66 void SelectEntry(const NamedColor& rColor);
67 void SelectEntry(const Color& rColor);
69 void SetNoSelection() { getColorWindow()->SetNoSelection(); }
70 bool IsNoSelection() const { return getColorWindow()->IsNoSelection(); }
72 void SetAutoDisplayColor(const Color &rColor) { m_aAutoDisplayColor = rColor; }
73 void ShowPreview(const NamedColor &rColor);
74 void EnsurePaletteManager();
76 void SaveValue() { m_aSaveColor = GetSelectEntryColor(); }
77 bool IsValueChangedFromSaved() const { return m_aSaveColor != GetSelectEntryColor(); }
79 DECL_LINK(WindowEventListener, VclWindowEvent&, void);
82 class ListBoxColorWrapper
84 public:
85 ListBoxColorWrapper(ColorListBox* pControl);
86 void operator()(const OUString& rCommand, const NamedColor& rColor);
87 private:
88 ColorListBox* mpControl;
91 class SVX_DLLPUBLIC ColorListBox
93 private:
94 friend class ListBoxColorWrapper;
95 std::unique_ptr<ColorWindow> m_xColorWindow;
96 std::unique_ptr<weld::MenuButton> m_xButton;
97 weld::Window* const m_pTopLevel;
98 Link<ColorListBox&, void> m_aSelectedLink;
99 ListBoxColorWrapper m_aColorWrapper;
100 Color const m_aAutoDisplayColor;
101 Color m_aSaveColor;
102 NamedColor m_aSelectedColor;
103 sal_uInt16 m_nSlotId;
104 bool m_bShowNoneButton;
105 std::shared_ptr<PaletteManager> m_xPaletteManager;
106 ColorStatus m_aColorStatus;
108 void Selected(const NamedColor& rNamedColor);
109 void createColorWindow();
110 void LockWidthRequest();
111 ColorWindow* getColorWindow() const;
112 public:
113 ColorListBox(std::unique_ptr<weld::MenuButton> pControl, weld::Window* pWindow);
114 ~ColorListBox();
116 void SetSelectHdl(const Link<ColorListBox&, void>& rLink)
118 m_aSelectedLink = rLink;
121 void SetSlotId(sal_uInt16 nSlotId, bool bShowNoneButton = false);
123 Color const & GetSelectEntryColor() const { return m_aSelectedColor.first; }
124 NamedColor const & GetSelectedEntry() const { return m_aSelectedColor; }
126 void SelectEntry(const Color& rColor);
128 void SetNoSelection() { getColorWindow()->SetNoSelection(); }
129 bool IsNoSelection() const { return getColorWindow()->IsNoSelection(); }
131 void ShowPreview(const NamedColor &rColor);
132 void EnsurePaletteManager();
134 void SaveValue() { m_aSaveColor = GetSelectEntryColor(); }
135 bool IsValueChangedFromSaved() const { return m_aSaveColor != GetSelectEntryColor(); }
137 void set_sensitive(bool sensitive) { m_xButton->set_sensitive(sensitive); }
138 bool get_sensitive() const { return m_xButton->get_sensitive(); }
139 void show() { m_xButton->show(); }
140 void hide() { m_xButton->hide(); }
141 void set_visible(bool bShow) { m_xButton->set_visible(bShow); }
142 void set_help_id(const OString& rHelpId) { m_xButton->set_help_id(rHelpId); }
143 weld::MenuButton& get_widget() { return *m_xButton; }
146 #endif
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */