Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / svx / colorwindow.hxx
blob520a560880d1646caab10e4ebba10f40f32dfdd3
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 <sfx2/tbxctrl.hxx>
24 #include <svtools/valueset.hxx>
25 #include <svl/lstner.hxx>
26 #include <rtl/ustring.hxx>
27 #include <com/sun/star/frame/XFrame.hpp>
28 #include <svx/SvxColorValueSet.hxx>
29 #include <svx/PaletteManager.hxx>
30 #include <vcl/lstbox.hxx>
32 #include <functional>
34 class SVX_DLLPUBLIC BorderColorStatus
36 Color maColor;
37 Color maTLBRColor;
38 Color maBLTRColor;
39 public:
40 BorderColorStatus();
41 ~BorderColorStatus();
42 bool statusChanged( const css::frame::FeatureStateEvent& rEvent );
43 Color GetColor();
46 class Button;
47 typedef std::function<void(const OUString&, const NamedColor&)> ColorSelectFunction;
49 #define COL_NONE_COLOR TRGB_COLORDATA(0x80, 0xFF, 0xFF, 0xFF)
51 class SVX_DLLPUBLIC SvxColorWindow : public SfxPopupWindow
53 private:
54 const sal_uInt16 theSlotId;
55 VclPtr<SvxColorValueSet> mpColorSet;
56 VclPtr<SvxColorValueSet> mpRecentColorSet;
58 VclPtr<ListBox> mpPaletteListBox;
59 VclPtr<PushButton> mpButtonAutoColor;
60 VclPtr<PushButton> mpButtonNoneColor;
61 VclPtr<PushButton> mpButtonPicker;
62 VclPtr<FixedLine> mpAutomaticSeparator;
63 OUString maCommand;
64 Link<const NamedColor&, void> maSelectedLink;
66 PaletteManager& mrPaletteManager;
67 BorderColorStatus& mrBorderColorStatus;
69 ColorSelectFunction maColorSelectFunction;
71 DECL_LINK( SelectHdl, ValueSet*, void );
72 DECL_LINK( SelectPaletteHdl, ListBox&, void);
73 DECL_LINK( AutoColorClickHdl, Button*, void );
74 DECL_LINK( OpenPickerClickHdl, Button*, void );
76 static bool SelectValueSetEntry(SvxColorValueSet* pColorSet, const Color& rColor);
77 static NamedColor GetSelectEntryColor(ValueSet* pColorSet);
78 NamedColor GetAutoColor() const;
80 public:
81 SvxColorWindow(const OUString& rCommand,
82 PaletteManager& rPaletteManager,
83 BorderColorStatus& rBorderColorStatus,
84 sal_uInt16 nSlotId,
85 const css::uno::Reference< css::frame::XFrame >& rFrame,
86 vcl::Window* pParentWindow,
87 ColorSelectFunction const& rColorSelectFunction);
88 virtual ~SvxColorWindow() override;
89 virtual void dispose() override;
90 void ShowNoneButton();
91 void StartSelection();
92 void SetNoSelection();
93 bool IsNoSelection() const;
94 void SelectEntry(const NamedColor& rColor);
95 void SelectEntry(const Color& rColor);
96 NamedColor GetSelectEntryColor() const;
98 virtual void KeyInput( const KeyEvent& rKEvt ) override;
99 virtual void statusChanged( const css::frame::FeatureStateEvent& rEvent ) override;
101 void SetSelectedHdl( const Link<const NamedColor&, void>& rLink ) { maSelectedLink = rLink; }
104 #endif
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */