bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / svx / colorwindow.hxx
blob183a29d231ba3fbf6ba3019276df0120f8c77917
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/lstbox.hxx>
28 #include <vcl/fixed.hxx>
30 #include <functional>
32 namespace com::sun::star::frame { class XFrame; }
34 class PaletteManager;
36 class SVX_DLLPUBLIC ColorStatus
38 Color maColor;
39 Color maTLBRColor;
40 Color maBLTRColor;
41 public:
42 ColorStatus();
43 ~ColorStatus();
44 void statusChanged( const css::frame::FeatureStateEvent& rEvent );
45 Color GetColor();
48 class Button;
49 typedef std::function<void(const OUString&, const NamedColor&)> ColorSelectFunction;
51 #define COL_NONE_COLOR ::Color(0x80, 0xFF, 0xFF, 0xFF)
53 class SVX_DLLPUBLIC SvxColorWindow : public svtools::ToolbarPopup
55 private:
56 const sal_uInt16 theSlotId;
57 VclPtr<SvxColorValueSet> mpColorSet;
58 VclPtr<SvxColorValueSet> mpRecentColorSet;
60 VclPtr<ListBox> mpPaletteListBox;
61 VclPtr<PushButton> mpButtonAutoColor;
62 VclPtr<PushButton> mpButtonNoneColor;
63 VclPtr<PushButton> mpButtonPicker;
64 VclPtr<FixedLine> mpAutomaticSeparator;
65 OUString const maCommand;
66 Link<const NamedColor&, void> maSelectedLink;
68 VclPtr<vcl::Window> mxParentWindow;
69 std::shared_ptr<PaletteManager> mxPaletteManager;
70 ColorStatus& mrColorStatus;
72 ColorSelectFunction const maColorSelectFunction;
73 bool const mbReuseParentForPicker;
75 DECL_LINK( SelectHdl, ValueSet*, void );
76 DECL_LINK( SelectPaletteHdl, ListBox&, void);
77 DECL_LINK( AutoColorClickHdl, Button*, void );
78 DECL_LINK( OpenPickerClickHdl, Button*, void );
80 static bool SelectValueSetEntry(SvxColorValueSet* pColorSet, const Color& rColor);
81 static NamedColor GetSelectEntryColor(ValueSet const * pColorSet);
82 NamedColor GetAutoColor() const;
84 public:
85 SvxColorWindow(const OUString& rCommand,
86 std::shared_ptr<PaletteManager> const & rPaletteManager,
87 ColorStatus& rColorStatus,
88 sal_uInt16 nSlotId,
89 const css::uno::Reference< css::frame::XFrame >& rFrame,
90 vcl::Window* pParentWindow,
91 // tdf#118251 When true, reuse pParentWindow as the parent of the color picker
92 // that appears from the 'custom color' button. When false use the window of
93 // rFrame. true is helpful when launched from a dialog, false for launched
94 // from a toolbar
95 bool bReuseParentForPicker,
96 ColorSelectFunction const& rColorSelectFunction);
97 virtual ~SvxColorWindow() override;
98 virtual void dispose() override;
99 void ShowNoneButton();
100 void StartSelection();
101 void SetNoSelection();
102 bool IsNoSelection() const;
103 void SelectEntry(const NamedColor& rColor);
104 void SelectEntry(const Color& rColor);
105 NamedColor GetSelectEntryColor() const;
107 virtual void KeyInput( const KeyEvent& rKEvt ) override;
108 virtual void statusChanged( const css::frame::FeatureStateEvent& rEvent ) override;
110 void SetSelectedHdl( const Link<const NamedColor&, void>& rLink ) { maSelectedLink = rLink; }
113 class SVX_DLLPUBLIC ColorWindow : public svtools::ToolbarPopupBase
115 private:
116 std::unique_ptr<weld::Builder> m_xBuilder;
118 const sal_uInt16 theSlotId;
119 weld::Window* const mpParentWindow;
120 weld::MenuButton* mpMenuButton;
121 std::shared_ptr<PaletteManager> mxPaletteManager;
122 ColorStatus& mrColorStatus;
123 ColorSelectFunction const maColorSelectFunction;
125 std::unique_ptr<ColorValueSet> mxColorSet;
126 std::unique_ptr<ColorValueSet> mxRecentColorSet;
127 std::unique_ptr<weld::Container> mxTopLevel;
128 std::unique_ptr<weld::ComboBox> mxPaletteListBox;
129 std::unique_ptr<weld::Button> mxButtonAutoColor;
130 std::unique_ptr<weld::Button> mxButtonNoneColor;
131 std::unique_ptr<weld::Button> mxButtonPicker;
132 std::unique_ptr<weld::Widget> mxAutomaticSeparator;
133 std::unique_ptr<weld::CustomWeld> mxColorSetWin;
134 std::unique_ptr<weld::CustomWeld> mxRecentColorSetWin;
136 DECL_LINK(SelectHdl, SvtValueSet*, void);
137 DECL_LINK(SelectPaletteHdl, weld::ComboBox&, void);
138 DECL_LINK(AutoColorClickHdl, weld::Button&, void);
139 DECL_LINK(OpenPickerClickHdl, weld::Button&, void);
140 DECL_LINK(FocusHdl, weld::Widget&, void);
142 static bool SelectValueSetEntry(ColorValueSet* pColorSet, const Color& rColor);
143 static NamedColor GetSelectEntryColor(SvtValueSet const * pColorSet);
144 NamedColor GetAutoColor() const;
146 public:
147 ColorWindow(std::shared_ptr<PaletteManager> const & rPaletteManager,
148 ColorStatus& rColorStatus,
149 sal_uInt16 nSlotId,
150 const css::uno::Reference< css::frame::XFrame >& rFrame,
151 weld::Window* pParentWindow, weld::MenuButton* pMenuButton,
152 bool bInterimBuilder,
153 ColorSelectFunction const& rColorSelectFunction);
154 weld::Container* GetWidget() { return mxTopLevel.get(); }
155 virtual ~ColorWindow() override;
156 void ShowNoneButton();
157 void SetNoSelection();
158 bool IsNoSelection() const;
159 void SelectEntry(const NamedColor& rColor);
160 void SelectEntry(const Color& rColor);
161 NamedColor GetSelectEntryColor() const;
163 virtual void statusChanged( const css::frame::FeatureStateEvent& rEvent ) override;
167 #endif
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */