1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_SVX_COLORBOX_HXX
#define INCLUDED_SVX_COLORBOX_HXX
#include <memory>
#include <vcl/menubtn.hxx>
#include <vcl/weld.hxx>
#include <svx/colorwindow.hxx>
#include <sfx2/controlwrapper.hxx>
class SvxColorListBox;
class ColorListBox;
class SvxListBoxColorWrapper
{
public:
SvxListBoxColorWrapper(SvxColorListBox* pControl);
void operator()(const OUString& rCommand, const NamedColor& rColor);
void dispose();
private:
VclPtr<SvxColorListBox> mxControl;
};
class SVX_DLLPUBLIC SvxColorListBox : public MenuButton
{
private:
friend class SvxListBoxColorWrapper;
VclPtr<SvxColorWindow> m_xColorWindow;
Link<SvxColorListBox&, void> m_aSelectedLink;
SvxListBoxColorWrapper m_aColorWrapper;
Color m_aAutoDisplayColor;
Color m_aSaveColor;
NamedColor m_aSelectedColor;
sal_uInt16 m_nSlotId;
bool m_bShowNoneButton;
std::shared_ptr<PaletteManager> m_xPaletteManager;
BorderColorStatus m_aBorderColorStatus;
DECL_LINK(MenuActivateHdl, MenuButton *, void);
void Selected(const NamedColor& rNamedColor);
void createColorWindow();
void LockWidthRequest();
VclPtr<SvxColorWindow> const & getColorWindow() const;
public:
SvxColorListBox(vcl::Window* pParent, WinBits nStyle = 0);
virtual ~SvxColorListBox() override;
virtual void dispose() override;
void SetSelectHdl(const Link<SvxColorListBox&, void>& rLink)
{
m_aSelectedLink = rLink;
}
void SetSlotId(sal_uInt16 nSlotId, bool bShowNoneButton = false);
Color const & GetSelectEntryColor() const { return m_aSelectedColor.first; }
NamedColor const & GetSelectedEntry() const { return m_aSelectedColor; }
void SelectEntry(const NamedColor& rColor);
void SelectEntry(const Color& rColor);
void SetNoSelection() { getColorWindow()->SetNoSelection(); }
bool IsNoSelection() const { return getColorWindow()->IsNoSelection(); }
void SetAutoDisplayColor(const Color &rColor) { m_aAutoDisplayColor = rColor; }
void ShowPreview(const NamedColor &rColor);
void EnsurePaletteManager();
void SaveValue() { m_aSaveColor = GetSelectEntryColor(); }
bool IsValueChangedFromSaved() const { return m_aSaveColor != GetSelectEntryColor(); }
DECL_LINK(WindowEventListener, VclWindowEvent&, void);
};
class ListBoxColorWrapper
{
public:
ListBoxColorWrapper(ColorListBox* pControl);
void operator()(const OUString& rCommand, const NamedColor& rColor);
private:
ColorListBox* mpControl;
};
class SVX_DLLPUBLIC ColorListBox
{
private:
friend class ListBoxColorWrapper;
std::unique_ptr<ColorWindow> m_xColorWindow;
std::unique_ptr<weld::MenuButton> m_xButton;
weld::Window* m_pTopLevel;
Link<ColorListBox&, void> m_aSelectedLink;
ListBoxColorWrapper m_aColorWrapper;
Color m_aAutoDisplayColor;
Color m_aSaveColor;
NamedColor m_aSelectedColor;
bool m_bInterimBuilder;
std::shared_ptr<PaletteManager> m_xPaletteManager;
BorderColorStatus m_aBorderColorStatus;
void Selected(const NamedColor& rNamedColor);
void createColorWindow();
void LockWidthRequest();
ColorWindow* getColorWindow() const;
public:
ColorListBox(weld::MenuButton* pControl, weld::Window* pWindow, bool bInterimBuilder = false);
~ColorListBox();
void SetSelectHdl(const Link<ColorListBox&, void>& rLink)
{
m_aSelectedLink = rLink;
}
Color const & GetSelectEntryColor() const { return m_aSelectedColor.first; }
void SelectEntry(const Color& rColor);
void SetNoSelection() { getColorWindow()->SetNoSelection(); }
void ShowPreview(const NamedColor &rColor);
void EnsurePaletteManager();
void SaveValue() { m_aSaveColor = GetSelectEntryColor(); }
bool IsValueChangedFromSaved() const { return m_aSaveColor != GetSelectEntryColor(); }
};
/** A wrapper for SvxColorListBox. */
class SVX_DLLPUBLIC SvxColorListBoxWrapper
: public sfx::SingleControlWrapper<SvxColorListBox, Color>
{
/* Note: cannot use 'const Color&' as template argument, because the
SvxColorListBox returns the color by value and not by reference,
therefore GetControlValue() must return a temporary object too. */
public:
explicit SvxColorListBoxWrapper(SvxColorListBox& rListBox);
virtual ~SvxColorListBoxWrapper() override;
virtual bool IsControlDontKnow() const override;
virtual void SetControlDontKnow( bool bSet ) override;
virtual Color GetControlValue() const override;
virtual void SetControlValue( Color aColor ) override;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|