Bump version to 21.06.18.1
[LibreOffice.git] / include / svx / colorwindow.hxx
blob05917b2dfcfcdb29913fe69f906a9d6b56ec045e
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SVX_SOURCE_TBXCTRLS_COLORWINDOW_HXX
21 #define INCLUDED_SVX_SOURCE_TBXCTRLS_COLORWINDOW_HXX
23 #include <svtools/toolbarmenu.hxx>
24 #include <rtl/ustring.hxx>
25 #include <svx/SvxColorValueSet.hxx>
26 #include <svx/Palette.hxx>
27 #include <vcl/toolbox.hxx>
29 namespace com::sun::star::frame { class XFrame; }
31 class PaletteManager;
33 class SVXCORE_DLLPUBLIC ColorStatus
35 Color maColor;
36 Color maTLBRColor;
37 Color maBLTRColor;
38 public:
39 ColorStatus();
40 ~ColorStatus();
41 void statusChanged( const css::frame::FeatureStateEvent& rEvent );
42 Color GetColor();
45 class Button;
47 #define COL_NONE_COLOR ::Color(0x80, 0xFF, 0xFF, 0xFF)
49 class SvxColorToolBoxControl;
51 class SVXCORE_DLLPUBLIC MenuOrToolMenuButton
53 private:
54 // either
55 weld::MenuButton* m_pMenuButton;
56 // or
57 weld::Toolbar* m_pToolbar;
58 OString m_aIdent;
59 // or
60 SvxColorToolBoxControl* m_pControl;
61 VclPtr<ToolBox> m_xToolBox;
62 sal_uInt16 m_nId;
63 public:
64 MenuOrToolMenuButton(weld::MenuButton* pMenuButton);
65 MenuOrToolMenuButton(weld::Toolbar* pToolbar, const OString& rIdent);
66 MenuOrToolMenuButton(SvxColorToolBoxControl* pControl, ToolBox* pToolbar, sal_uInt16 nId);
67 ~MenuOrToolMenuButton();
69 MenuOrToolMenuButton(MenuOrToolMenuButton const &) = default;
70 MenuOrToolMenuButton(MenuOrToolMenuButton &&) = default;
71 MenuOrToolMenuButton & operator =(MenuOrToolMenuButton const &) = default;
72 MenuOrToolMenuButton & operator =(MenuOrToolMenuButton &&) = default;
74 bool get_active() const;
75 void set_inactive() const;
76 weld::Widget* get_widget() const;
79 class SVXCORE_DLLPUBLIC ColorWindow final : public WeldToolbarPopup
81 private:
82 const sal_uInt16 theSlotId;
83 OUString maCommand;
84 weld::Window* mpParentWindow;
85 MenuOrToolMenuButton maMenuButton;
86 std::shared_ptr<PaletteManager> mxPaletteManager;
87 ColorStatus& mrColorStatus;
88 ColorSelectFunction maColorSelectFunction;
90 std::unique_ptr<SvxColorValueSet> mxColorSet;
91 std::unique_ptr<SvxColorValueSet> mxRecentColorSet;
92 std::unique_ptr<weld::ComboBox> mxPaletteListBox;
93 std::unique_ptr<weld::Button> mxButtonAutoColor;
94 std::unique_ptr<weld::Button> mxButtonNoneColor;
95 std::unique_ptr<weld::Button> mxButtonPicker;
96 std::unique_ptr<weld::Widget> mxAutomaticSeparator;
97 std::unique_ptr<weld::CustomWeld> mxColorSetWin;
98 std::unique_ptr<weld::CustomWeld> mxRecentColorSetWin;
99 weld::Button* mpDefaultButton;
101 Link<const NamedColor&, void> maSelectedLink;
102 DECL_LINK(SelectHdl, ValueSet*, void);
103 DECL_LINK(SelectPaletteHdl, weld::ComboBox&, void);
104 DECL_LINK(AutoColorClickHdl, weld::Button&, void);
105 DECL_LINK(OpenPickerClickHdl, weld::Button&, void);
107 static bool SelectValueSetEntry(SvxColorValueSet* pColorSet, const Color& rColor);
108 static NamedColor GetSelectEntryColor(ValueSet const * pColorSet);
109 NamedColor GetAutoColor() const;
111 public:
112 ColorWindow(const OUString& rCommand,
113 std::shared_ptr<PaletteManager> const & rPaletteManager,
114 ColorStatus& rColorStatus,
115 sal_uInt16 nSlotId,
116 const css::uno::Reference< css::frame::XFrame >& rFrame,
117 weld::Window* pParentWindow, const MenuOrToolMenuButton &rMenuButton,
118 ColorSelectFunction const& rColorSelectFunction);
119 virtual ~ColorWindow() override;
120 void ShowNoneButton();
121 void SetNoSelection();
122 bool IsNoSelection() const;
123 void SelectEntry(const NamedColor& rColor);
124 void SelectEntry(const Color& rColor);
125 NamedColor GetSelectEntryColor() const;
127 virtual void statusChanged( const css::frame::FeatureStateEvent& rEvent ) override;
129 void SetSelectedHdl( const Link<const NamedColor&, void>& rLink ) { maSelectedLink = rLink; }
131 virtual void GrabFocus() override;
134 #endif
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */