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/menubtn.hxx>
15 #include <vcl/weld.hxx>
16 #include <svx/colorwindow.hxx>
17 
18 class SvxColorListBox;
19 class ColorListBox;
20 
22 {
23 public:
25  void operator()(const OUString& rCommand, const NamedColor& rColor);
26  void dispose();
27 private:
29 };
30 
32 {
33 private:
34  friend class SvxListBoxColorWrapper;
40  sal_uInt16 m_nSlotId;
41  std::shared_ptr<PaletteManager> m_xPaletteManager;
43 
44  DECL_LINK(MenuActivateHdl, MenuButton *, void);
45  void Selected(const NamedColor& rNamedColor);
46  void createColorWindow();
47  void LockWidthRequest();
48  VclPtr<SvxColorWindow> const & getColorWindow() const;
49 public:
50  SvxColorListBox(vcl::Window* pParent, WinBits nStyle = 0);
51  virtual ~SvxColorListBox() override;
52  virtual void dispose() override;
53 
55  {
56  m_aSelectedLink = rLink;
57  }
58 
59  Color const & GetSelectEntryColor() const { return m_aSelectedColor.first; }
60 
61  void SelectEntry(const Color& rColor);
62 
63  void SetNoSelection() { getColorWindow()->SetNoSelection(); }
64 
65  void ShowPreview(const NamedColor &rColor);
66  void EnsurePaletteManager();
67 
68  DECL_LINK(WindowEventListener, VclWindowEvent&, void);
69 
70  virtual boost::property_tree::ptree DumpAsPropertyTree() override;
71 };
72 
74 {
75 public:
77  void operator()(const OUString& rCommand, const NamedColor& rColor);
78 private:
80 };
81 
83 {
84 private:
85  friend class ListBoxColorWrapper;
86  std::unique_ptr<ColorWindow> m_xColorWindow;
87  std::unique_ptr<weld::MenuButton> m_xButton;
94  sal_uInt16 m_nSlotId;
96  std::shared_ptr<PaletteManager> m_xPaletteManager;
98 
99  void Selected(const NamedColor& rNamedColor);
100  void createColorWindow();
101  void LockWidthRequest();
102  ColorWindow* getColorWindow() const;
103 
104  DECL_LINK(ToggleHdl, weld::ToggleButton&, void);
105 
106 public:
107  // pTopLevelWindow will be used as parent for any color picker dialog created
108  ColorListBox(std::unique_ptr<weld::MenuButton> pControl, weld::Window* pTopLevelWindow);
109  ~ColorListBox();
110 
112  {
113  m_aSelectedLink = rLink;
114  }
115 
116  void SetSlotId(sal_uInt16 nSlotId, bool bShowNoneButton = false);
117 
118  Color const & GetSelectEntryColor() const { return m_aSelectedColor.first; }
119  NamedColor const & GetSelectedEntry() const { return m_aSelectedColor; }
120 
121  void SelectEntry(const NamedColor& rColor);
122  void SelectEntry(const Color& rColor);
123 
124  void SetNoSelection() { getColorWindow()->SetNoSelection(); }
125  bool IsNoSelection() const { return getColorWindow()->IsNoSelection(); }
126 
127  void SetAutoDisplayColor(const Color &rColor) { m_aAutoDisplayColor = rColor; }
128 
129  void ShowPreview(const NamedColor &rColor);
130  void EnsurePaletteManager();
131 
132  void SaveValue() { m_aSaveColor = GetSelectEntryColor(); }
133  bool IsValueChangedFromSaved() const { return m_aSaveColor != GetSelectEntryColor(); }
134 
135  void set_sensitive(bool sensitive) { m_xButton->set_sensitive(sensitive); }
136  bool get_sensitive() const { return m_xButton->get_sensitive(); }
137  void show() { m_xButton->show(); }
138  void hide() { m_xButton->hide(); }
139  void set_visible(bool bShow) { m_xButton->set_visible(bShow); }
140  void set_help_id(const OString& rHelpId) { m_xButton->set_help_id(rHelpId); }
141  void connect_focus_in(const Link<weld::Widget&, void>& rLink) { m_xButton->connect_focus_in(rLink); }
142  void connect_focus_out(const Link<weld::Widget&, void>& rLink) { m_xButton->connect_focus_out(rLink); }
143  weld::MenuButton& get_widget() { return *m_xButton; }
144 };
145 
146 #endif
147 
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::pair< Color, OUString > NamedColor
Definition: Palette.hxx:27
void SetSelectHdl(const Link< SvxColorListBox &, void > &rLink)
Definition: colorbox.hxx:54
void set_help_id(const OString &rHelpId)
Definition: colorbox.hxx:140
Color const & GetSelectEntryColor() const
Definition: colorbox.hxx:59
bool IsNoSelection() const
Definition: colorbox.hxx:125
ColorListBox * mpControl
Definition: colorbox.hxx:79
void SetNoSelection()
Definition: colorbox.hxx:63
ColorStatus m_aColorStatus
Definition: colorbox.hxx:42
virtual void dispose() override
void SetAutoDisplayColor(const Color &rColor)
Definition: colorbox.hxx:127
VclPtr< SvxColorListBox > mxControl
Definition: colorbox.hxx:28
void SaveValue()
Definition: colorbox.hxx:132
NamedColor m_aSelectedColor
Definition: colorbox.hxx:39
sal_Int64 WinBits
void SetNoSelection()
Definition: colorbox.hxx:124
Color m_aAutoDisplayColor
Definition: colorbox.hxx:38
VclPtr< SvxColorWindow > m_xColorWindow
Definition: colorbox.hxx:35
bool get_sensitive() const
Definition: colorbox.hxx:136
void operator()(const OUString &rCommand, const NamedColor &rColor)
Definition: tbcontrl.cxx:3957
void operator()(const OUString &rCommand, const NamedColor &rColor)
Definition: tbcontrl.cxx:3940
NamedColor const & GetSelectedEntry() const
Definition: colorbox.hxx:119
sal_uInt16 m_nSlotId
Definition: colorbox.hxx:40
virtual boost::property_tree::ptree DumpAsPropertyTree() override
bool IsValueChangedFromSaved() const
Definition: colorbox.hxx:133
void connect_focus_in(const Link< weld::Widget &, void > &rLink)
Definition: colorbox.hxx:141
void SetSelectHdl(const Link< ColorListBox &, void > &rLink)
Definition: colorbox.hxx:111
ColorStatus m_aColorStatus
Definition: colorbox.hxx:97
NamedColor m_aSelectedColor
Definition: colorbox.hxx:93
Link< SvxColorListBox &, void > m_aSelectedLink
Definition: colorbox.hxx:36
weld::MenuButton & get_widget()
Definition: colorbox.hxx:143
void show()
Definition: colorbox.hxx:137
Color const & GetSelectEntryColor() const
Definition: colorbox.hxx:118
ListBoxColorWrapper(ColorListBox *pControl)
Definition: tbcontrl.cxx:3952
std::unique_ptr< ColorWindow > m_xColorWindow
Definition: colorbox.hxx:86
Color m_aAutoDisplayColor
Definition: colorbox.hxx:91
void connect_focus_out(const Link< weld::Widget &, void > &rLink)
Definition: colorbox.hxx:142
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
std::shared_ptr< PaletteManager > m_xPaletteManager
Definition: colorbox.hxx:41
std::shared_ptr< PaletteManager > m_xPaletteManager
Definition: colorbox.hxx:96
Link< ColorListBox &, void > m_aSelectedLink
Definition: colorbox.hxx:89
void set_sensitive(bool sensitive)
Definition: colorbox.hxx:135
void hide()
Definition: colorbox.hxx:138
bool m_bShowNoneButton
Definition: colorbox.hxx:95
sal_uInt16 m_nSlotId
Definition: colorbox.hxx:94
void set_visible(bool bShow)
Definition: colorbox.hxx:139
Color m_aSaveColor
Definition: colorbox.hxx:92
ListBoxColorWrapper m_aColorWrapper
Definition: colorbox.hxx:90
weld::Window * m_pTopLevel
Definition: colorbox.hxx:88
std::unique_ptr< weld::MenuButton > m_xButton
Definition: colorbox.hxx:87
SvxListBoxColorWrapper m_aColorWrapper
Definition: colorbox.hxx:37
SvxListBoxColorWrapper(SvxColorListBox *pControl)
Definition: tbcontrl.cxx:3935