diff options
Diffstat (limited to 'include/svx/colorbox.hxx')
-rw-r--r-- | include/svx/colorbox.hxx | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/include/svx/colorbox.hxx b/include/svx/colorbox.hxx new file mode 100644 index 000000000000..8043363f9856 --- /dev/null +++ b/include/svx/colorbox.hxx @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_SVX_COLORBOX_HXX +#define INCLUDED_SVX_COLORBOX_HXX + +#include <vcl/menubtn.hxx> +#include <svx/colorwindow.hxx> +#include <sfx2/controlwrapper.hxx> + +class SvxColorListBox; + +class SvxListBoxColorWrapper +{ +public: + SvxListBoxColorWrapper(SvxColorListBox* pControl); + void operator()(const OUString& rCommand, const NamedColor& rColor); +private: + VclPtr<SvxColorListBox> mxControl; +}; + +class SVX_DLLPUBLIC SvxColorListBox : public MenuButton +{ +private: + friend class SvxListBoxColorWrapper; + VclPtr<SvxColorWindow> m_xColorWindow; + Link<SvxColorListBox&, void> m_aSelectedLink; + SvxListBoxColorWrapper m_aColorWrapper; + Color m_aAutoDisplayColor; + NamedColor m_aSelectedColor; + sal_uInt16 m_nSlotId; + bool m_bShowNoneButton; + PaletteManager m_aPaletteManager; + BorderColorStatus m_aBorderColorStatus; + + DECL_LINK_TYPED(MenuActivateHdl, MenuButton *, void); + void Selected(const NamedColor& rNamedColor); + void createColorWindow(); + void LockWidthRequest(); + VclPtr<SvxColorWindow> getColorWindow() const; +public: + SvxColorListBox(vcl::Window* pParent); + virtual ~SvxColorListBox() override; + virtual void dispose() override; + + void SetSelectHdl(const Link<SvxColorListBox&, void>& rLink) + { + m_aSelectedLink = rLink; + } + + void SetSlotId(sal_uInt16 nSlotId, bool bShowNoneButton = false); + + NamedColor GetSelectEntry() const; + Color GetSelectEntryColor() const; + + void SelectEntry(const NamedColor& rColor); + void SelectEntry(const Color& rColor); + + void SetNoSelection() { getColorWindow()->SetNoSelection(); } + bool IsNoSelection() const { return getColorWindow()->IsNoSelection(); } + + void SetAutoDisplayColor(const Color &rColor) { m_aAutoDisplayColor = rColor; } + void ShowPreview(const NamedColor &rColor); +}; + +/** A wrapper for SvxColorListBox. */ +class SVX_DLLPUBLIC SvxColorListBoxWrapper + : public sfx::SingleControlWrapper<SvxColorListBox, Color> +{ + /* Note: cannot use 'const Color&' as template argument, because the + SvxColorListBox returns the color by value and not by reference, + therefore GetControlValue() must return a temporary object too. */ +public: + explicit SvxColorListBoxWrapper(SvxColorListBox& rListBox); + + virtual ~SvxColorListBoxWrapper() override; + + virtual bool IsControlDontKnow() const override; + virtual void SetControlDontKnow( bool bSet ) override; + + virtual Color GetControlValue() const override; + virtual void SetControlValue( Color aColor ) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |