LibreOffice Module svx (master) 1
colorbox.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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 */
9
10#ifndef INCLUDED_SVX_COLORBOX_HXX
11#define INCLUDED_SVX_COLORBOX_HXX
12
13#include <memory>
14#include <vcl/weld.hxx>
15#include <svx/colorwindow.hxx>
16
17class ColorListBox;
18
20{
21public:
23 void operator()(const OUString& rCommand,
24 const NamedColor& rColor); // ColorSelectFunction signature
25private:
27};
28
30{
31private:
32 friend class ListBoxColorWrapper;
33 std::unique_ptr<ColorWindow> m_xColorWindow;
34 std::unique_ptr<weld::MenuButton> m_xButton;
40 sal_uInt16 m_nSlotId;
42 std::shared_ptr<PaletteManager> m_xPaletteManager;
45
46 void Selected(const NamedColor& rNamedColor);
47 void createColorWindow();
48 void LockWidthRequest(int nWidthRequest);
49 int CalcBestWidthRequest();
50 ColorWindow* getColorWindow() const;
51
53
54public:
55 // rTopLevelParentFunction will be used to get parent for any color picker dialog created
56 ColorListBox(std::unique_ptr<weld::MenuButton> pControl,
57 TopLevelParentFunction aTopLevelParentFunction,
58 const ColorListBox* pCache = nullptr);
60
61 void SetSelectHdl(const Link<ColorListBox&, void>& rLink) { m_aSelectedLink = rLink; }
62
63 void SetSlotId(sal_uInt16 nSlotId, bool bShowNoneButton = false);
64
65 Color const& GetSelectEntryColor() const { return m_aSelectedColor.m_aColor; }
66 NamedColor GetSelectedEntry() const { return m_aSelectedColor; }
67 const NamedColor& GetSelectedEntryThemedColor() const { return m_aSelectedColor; }
68
69 void SelectEntry(const NamedColor& rColor);
70 void SelectEntry(const Color& rColor);
71
72 void SetNoSelection() { getColorWindow()->SetNoSelection(); }
73 bool IsNoSelection() const { return getColorWindow()->IsNoSelection(); }
74
75 void SetAutoDisplayColor(const Color& rColor) { m_aAutoDisplayColor = rColor; }
76
77 void ShowPreview(const NamedColor& rColor);
78 void EnsurePaletteManager();
79
80 void SaveValue() { m_aSaveColor = GetSelectEntryColor(); }
81 bool IsValueChangedFromSaved() const { return m_aSaveColor != GetSelectEntryColor(); }
82
83 void set_sensitive(bool sensitive) { m_xButton->set_sensitive(sensitive); }
84 bool get_sensitive() const { return m_xButton->get_sensitive(); }
85 void show() { m_xButton->show(); }
86 void hide() { m_xButton->hide(); }
87 void set_visible(bool bShow) { m_xButton->set_visible(bShow); }
88 void set_help_id(const OUString& rHelpId) { m_xButton->set_help_id(rHelpId); }
90 {
91 m_xButton->connect_focus_in(rLink);
92 }
94 {
95 m_xButton->connect_focus_out(rLink);
96 }
97 weld::MenuButton& get_widget() { return *m_xButton; }
98};
99
100#endif
101
102/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< ColorWindow > m_xColorWindow
Definition: colorbox.hxx:33
bool get_sensitive() const
Definition: colorbox.hxx:84
Color const & GetSelectEntryColor() const
Definition: colorbox.hxx:65
std::unique_ptr< weld::MenuButton > m_xButton
Definition: colorbox.hxx:34
void SetSelectHdl(const Link< ColorListBox &, void > &rLink)
Definition: colorbox.hxx:61
void show()
Definition: colorbox.hxx:85
sal_uInt16 m_nSlotId
Definition: colorbox.hxx:40
Link< ColorListBox &, void > m_aSelectedLink
Definition: colorbox.hxx:35
void set_visible(bool bShow)
Definition: colorbox.hxx:87
NamedColor m_aSelectedColor
Definition: colorbox.hxx:39
bool IsValueChangedFromSaved() const
Definition: colorbox.hxx:81
ColorStatus m_aColorStatus
Definition: colorbox.hxx:44
NamedColor GetSelectedEntry() const
Definition: colorbox.hxx:66
bool m_bShowNoneButton
Definition: colorbox.hxx:41
void SaveValue()
Definition: colorbox.hxx:80
void connect_focus_in(const Link< weld::Widget &, void > &rLink)
Definition: colorbox.hxx:89
ListBoxColorWrapper m_aColorWrapper
Definition: colorbox.hxx:36
void SetNoSelection()
Definition: colorbox.hxx:72
bool IsNoSelection() const
Definition: colorbox.hxx:73
weld::MenuButton & get_widget()
Definition: colorbox.hxx:97
void connect_focus_out(const Link< weld::Widget &, void > &rLink)
Definition: colorbox.hxx:93
TopLevelParentFunction m_aTopLevelParentFunction
Definition: colorbox.hxx:43
void set_sensitive(bool sensitive)
Definition: colorbox.hxx:83
void SetAutoDisplayColor(const Color &rColor)
Definition: colorbox.hxx:75
Color m_aAutoDisplayColor
Definition: colorbox.hxx:37
void hide()
Definition: colorbox.hxx:86
DECL_DLLPRIVATE_LINK(ToggleHdl, weld::Toggleable &, void)
void set_help_id(const OUString &rHelpId)
Definition: colorbox.hxx:88
Color m_aSaveColor
Definition: colorbox.hxx:38
std::shared_ptr< PaletteManager > m_xPaletteManager
Definition: colorbox.hxx:42
const NamedColor & GetSelectedEntryThemedColor() const
Definition: colorbox.hxx:67
ListBoxColorWrapper(ColorListBox *pControl)
Definition: tbcontrl.cxx:4237
void operator()(const OUString &rCommand, const NamedColor &rColor)
Definition: tbcontrl.cxx:4242
ColorListBox * mpControl
Definition: colorbox.hxx:26
std::function< weld::Window *()> TopLevelParentFunction
Definition: colorwindow.hxx:28
Color m_aColor
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35