tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / include / svx / colorbox.hxx
blob04d1c740f2ff665f47240da2a87b7002cc2428a8
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/weld.hxx>
15 #include <svx/colorwindow.hxx>
17 class ColorListBox;
19 class ListBoxColorWrapper
21 public:
22 ListBoxColorWrapper(ColorListBox* pControl);
23 void operator()(const OUString& rCommand,
24 const NamedColor& rColor); // ColorSelectFunction signature
25 private:
26 ColorListBox* mpControl;
29 class SVXCORE_DLLPUBLIC ColorListBox
31 private:
32 friend class ListBoxColorWrapper;
33 std::unique_ptr<ColorWindow> m_xColorWindow;
34 std::unique_ptr<weld::MenuButton> m_xButton;
35 Link<ColorListBox&, void> m_aSelectedLink;
36 ListBoxColorWrapper m_aColorWrapper;
37 Color m_aAutoDisplayColor;
38 Color m_aSaveColor;
39 NamedColor m_aSelectedColor;
40 sal_uInt16 m_nSlotId;
41 bool m_bShowNoneButton;
42 std::shared_ptr<PaletteManager> m_xPaletteManager;
43 TopLevelParentFunction m_aTopLevelParentFunction;
44 ColorStatus m_aColorStatus;
46 void Selected(const NamedColor& rNamedColor);
47 void createColorWindow();
48 void LockWidthRequest(int nWidthRequest);
49 int CalcBestWidthRequest();
50 ColorWindow* getColorWindow() const;
52 DECL_DLLPRIVATE_LINK(ToggleHdl, weld::Toggleable&, void);
54 public:
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);
59 ~ColorListBox();
61 void SetSelectHdl(const Link<ColorListBox&, void>& rLink) { m_aSelectedLink = rLink; }
63 void SetSlotId(sal_uInt16 nSlotId, bool bShowNoneButton = false);
65 Color const& GetSelectEntryColor() const { return m_aSelectedColor.m_aColor; }
66 const NamedColor& GetSelectedEntry() const { return m_aSelectedColor; }
67 const NamedColor& GetSelectedEntryThemedColor() const { return m_aSelectedColor; }
69 void SelectEntry(const NamedColor& rColor);
70 void SelectEntry(const Color& rColor);
72 void SetNoSelection() { getColorWindow()->SetNoSelection(); }
73 bool IsNoSelection() const { return getColorWindow()->IsNoSelection(); }
75 void SetAutoDisplayColor(const Color& rColor) { m_aAutoDisplayColor = rColor; }
77 void ShowPreview(const NamedColor& rColor);
78 void EnsurePaletteManager();
80 void SaveValue() { m_aSaveColor = GetSelectEntryColor(); }
81 bool IsValueChangedFromSaved() const { return m_aSaveColor != GetSelectEntryColor(); }
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); }
89 void set_accessible_name(const OUString& rName) { m_xButton->set_accessible_name(rName); };
90 void connect_focus_in(const Link<weld::Widget&, void>& rLink)
92 m_xButton->connect_focus_in(rLink);
94 void connect_focus_out(const Link<weld::Widget&, void>& rLink)
96 m_xButton->connect_focus_out(rLink);
98 weld::MenuButton& get_widget() { return *m_xButton; }
101 #endif
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */