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 
17 class ColorListBox;
18 
20 {
21 public:
23  void operator()(const OUString& rCommand,
24  const svx::NamedThemedColor& rColor); // ColorSelectFunction signature
25 private:
27 };
28 
30 {
31 private:
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 svx::NamedThemedColor& rNamedColor);
47  void createColorWindow();
48  void LockWidthRequest();
49  ColorWindow* getColorWindow() const;
50 
51  DECL_DLLPRIVATE_LINK(ToggleHdl, weld::Toggleable&, void);
52 
53 public:
54  // rTopLevelParentFunction will be used to get parent for any color picker dialog created
55  ColorListBox(std::unique_ptr<weld::MenuButton> pControl,
56  TopLevelParentFunction const& rTopLevelParentFunction);
57  ~ColorListBox();
58 
59  void SetSelectHdl(const Link<ColorListBox&, void>& rLink) { m_aSelectedLink = rLink; }
60 
61  void SetSlotId(sal_uInt16 nSlotId, bool bShowNoneButton = false);
62 
63  Color const& GetSelectEntryColor() const { return m_aSelectedColor.m_aColor; }
64  NamedColor GetSelectedEntry() const { return m_aSelectedColor.ToNamedColor(); }
65  const svx::NamedThemedColor& GetSelectedEntryThemedColor() const { return m_aSelectedColor; }
66 
67  void SelectEntry(const NamedColor& rColor);
68  void SelectEntry(const Color& rColor);
69 
70  void SetNoSelection() { getColorWindow()->SetNoSelection(); }
71  bool IsNoSelection() const { return getColorWindow()->IsNoSelection(); }
72 
73  void SetAutoDisplayColor(const Color& rColor) { m_aAutoDisplayColor = rColor; }
74 
75  void ShowPreview(const NamedColor& rColor);
76  void EnsurePaletteManager();
77 
78  void SaveValue() { m_aSaveColor = GetSelectEntryColor(); }
79  bool IsValueChangedFromSaved() const { return m_aSaveColor != GetSelectEntryColor(); }
80 
81  void set_sensitive(bool sensitive) { m_xButton->set_sensitive(sensitive); }
82  bool get_sensitive() const { return m_xButton->get_sensitive(); }
83  void show() { m_xButton->show(); }
84  void hide() { m_xButton->hide(); }
85  void set_visible(bool bShow) { m_xButton->set_visible(bShow); }
86  void set_help_id(const OString& rHelpId) { m_xButton->set_help_id(rHelpId); }
88  {
89  m_xButton->connect_focus_in(rLink);
90  }
92  {
93  m_xButton->connect_focus_out(rLink);
94  }
95  weld::MenuButton& get_widget() { return *m_xButton; }
96 };
97 
98 #endif
99 
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::pair< Color, OUString > NamedColor
Definition: Palette.hxx:30
A color with an optional name and other theming-related properties.
Definition: Palette.hxx:37
void set_help_id(const OString &rHelpId)
Definition: colorbox.hxx:86
bool IsNoSelection() const
Definition: colorbox.hxx:71
ColorListBox * mpControl
Definition: colorbox.hxx:26
void SetAutoDisplayColor(const Color &rColor)
Definition: colorbox.hxx:73
NamedColor GetSelectedEntry() const
Definition: colorbox.hxx:64
void SaveValue()
Definition: colorbox.hxx:78
void SetNoSelection()
Definition: colorbox.hxx:70
svx::NamedThemedColor m_aSelectedColor
Definition: colorbox.hxx:39
bool get_sensitive() const
Definition: colorbox.hxx:82
TopLevelParentFunction m_aTopLevelParentFunction
Definition: colorbox.hxx:43
bool IsValueChangedFromSaved() const
Definition: colorbox.hxx:79
void connect_focus_in(const Link< weld::Widget &, void > &rLink)
Definition: colorbox.hxx:87
const svx::NamedThemedColor & GetSelectedEntryThemedColor() const
Definition: colorbox.hxx:65
void operator()(const OUString &rCommand, const svx::NamedThemedColor &rColor)
Definition: tbcontrl.cxx:3950
void SetSelectHdl(const Link< ColorListBox &, void > &rLink)
Definition: colorbox.hxx:59
std::function< weld::Window *()> TopLevelParentFunction
Definition: colorwindow.hxx:28
ColorStatus m_aColorStatus
Definition: colorbox.hxx:44
weld::MenuButton & get_widget()
Definition: colorbox.hxx:95
void show()
Definition: colorbox.hxx:83
Color const & GetSelectEntryColor() const
Definition: colorbox.hxx:63
ListBoxColorWrapper(ColorListBox *pControl)
Definition: tbcontrl.cxx:3945
std::unique_ptr< ColorWindow > m_xColorWindow
Definition: colorbox.hxx:33
Color m_aAutoDisplayColor
Definition: colorbox.hxx:37
void connect_focus_out(const Link< weld::Widget &, void > &rLink)
Definition: colorbox.hxx:91
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
std::shared_ptr< PaletteManager > m_xPaletteManager
Definition: colorbox.hxx:42
Link< ColorListBox &, void > m_aSelectedLink
Definition: colorbox.hxx:35
void set_sensitive(bool sensitive)
Definition: colorbox.hxx:81
void hide()
Definition: colorbox.hxx:84
bool m_bShowNoneButton
Definition: colorbox.hxx:41
sal_uInt16 m_nSlotId
Definition: colorbox.hxx:40
void set_visible(bool bShow)
Definition: colorbox.hxx:85
Color m_aSaveColor
Definition: colorbox.hxx:38
ListBoxColorWrapper m_aColorWrapper
Definition: colorbox.hxx:36
NamedColor ToNamedColor() const
Definition: Palette.cxx:366
std::unique_ptr< weld::MenuButton > m_xButton
Definition: colorbox.hxx:34