LibreOffice Module svx (master)  1
colorwindow.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SVX_SOURCE_TBXCTRLS_COLORWINDOW_HXX
21 #define INCLUDED_SVX_SOURCE_TBXCTRLS_COLORWINDOW_HXX
22 
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>
28 
29 typedef std::function<weld::Window*()> TopLevelParentFunction;
30 
31 namespace com::sun::star::frame { class XFrame; }
32 
33 class PaletteManager;
34 
36 {
40 public:
41  ColorStatus();
42  ~ColorStatus();
43  void statusChanged( const css::frame::FeatureStateEvent& rEvent );
44  Color GetColor();
45 };
46 
47 class Button;
48 
49 #define COL_NONE_COLOR ::Color(ColorTransparency, 0x80, 0xFF, 0xFF, 0xFF)
50 
52 
54 {
55 private:
56  // either
58  // or
60  OString m_aIdent;
61  // or
65 public:
67  MenuOrToolMenuButton(weld::Toolbar* pToolbar, const OString& rIdent);
70 
71  MenuOrToolMenuButton(MenuOrToolMenuButton const &) = default;
73  MenuOrToolMenuButton & operator =(MenuOrToolMenuButton const &) = default;
74  MenuOrToolMenuButton & operator =(MenuOrToolMenuButton &&) = default;
75 
76  bool get_active() const;
77  void set_inactive() const;
78  weld::Widget* get_widget() const;
79 };
80 
82 {
83 private:
84  const sal_uInt16 theSlotId;
85  OUString maCommand;
87  std::shared_ptr<PaletteManager> mxPaletteManager;
91 
92  std::unique_ptr<SvxColorValueSet> mxColorSet;
93  std::unique_ptr<SvxColorValueSet> mxRecentColorSet;
94  std::unique_ptr<weld::ComboBox> mxPaletteListBox;
95  std::unique_ptr<weld::Button> mxButtonAutoColor;
96  std::unique_ptr<weld::Button> mxButtonNoneColor;
97  std::unique_ptr<weld::Button> mxButtonPicker;
98  std::unique_ptr<weld::Widget> mxAutomaticSeparator;
99  std::unique_ptr<weld::CustomWeld> mxColorSetWin;
100  std::unique_ptr<weld::CustomWeld> mxRecentColorSetWin;
102 
104  DECL_LINK(SelectHdl, ValueSet*, void);
105  DECL_LINK(SelectPaletteHdl, weld::ComboBox&, void);
106  DECL_LINK(AutoColorClickHdl, weld::Button&, void);
107  DECL_LINK(OpenPickerClickHdl, weld::Button&, void);
108 
109  static bool SelectValueSetEntry(SvxColorValueSet* pColorSet, const Color& rColor);
110  static NamedColor GetSelectEntryColor(ValueSet const * pColorSet);
111  NamedColor GetAutoColor() const;
112 
113 public:
114  ColorWindow(const OUString& rCommand,
115  std::shared_ptr<PaletteManager> const & rPaletteManager,
116  ColorStatus& rColorStatus,
117  sal_uInt16 nSlotId,
118  const css::uno::Reference<css::frame::XFrame>& rFrame,
119  const MenuOrToolMenuButton &rMenuButton,
120  TopLevelParentFunction const& rTopLevelParentFunction,
121  ColorSelectFunction const& rColorSelectFunction);
122  virtual ~ColorWindow() override;
123  void ShowNoneButton();
124  void SetNoSelection();
125  bool IsNoSelection() const;
126  void SelectEntry(const NamedColor& rColor);
127  void SelectEntry(const Color& rColor);
128  NamedColor GetSelectEntryColor() const;
129 
130  virtual void statusChanged( const css::frame::FeatureStateEvent& rEvent ) override;
131 
132  void SetSelectedHdl( const Link<const NamedColor&, void>& rLink ) { maSelectedLink = rLink; }
133 
134  virtual void GrabFocus() override;
135 };
136 
137 #endif
138 
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::pair< Color, OUString > NamedColor
Definition: Palette.hxx:29
SvxColorToolBoxControl * m_pControl
Definition: colorwindow.hxx:62
weld::Toolbar * m_pToolbar
Definition: colorwindow.hxx:59
OUString maCommand
Definition: colorwindow.hxx:85
VclPtr< ToolBox > m_xToolBox
Definition: colorwindow.hxx:63
TopLevelParentFunction maTopLevelParentFunction
Definition: colorwindow.hxx:89
MenuOrToolMenuButton maMenuButton
Definition: colorwindow.hxx:86
weld::MenuButton * m_pMenuButton
Definition: colorwindow.hxx:57
ColorStatus & mrColorStatus
Definition: colorwindow.hxx:88
virtual void statusChanged(const css::frame::FeatureStateEvent &Event)
std::unique_ptr< weld::ComboBox > mxPaletteListBox
Definition: colorwindow.hxx:94
std::unique_ptr< weld::CustomWeld > mxRecentColorSetWin
std::unique_ptr< weld::Button > mxButtonPicker
Definition: colorwindow.hxx:97
std::unique_ptr< weld::Button > mxButtonNoneColor
Definition: colorwindow.hxx:96
std::unique_ptr< SvxColorValueSet > mxRecentColorSet
Definition: colorwindow.hxx:93
ToolBoxItemId m_nId
Definition: colorwindow.hxx:64
weld::Button * mpDefaultButton
std::unique_ptr< weld::Widget > mxAutomaticSeparator
Definition: colorwindow.hxx:98
std::unique_ptr< weld::CustomWeld > mxColorSetWin
Definition: colorwindow.hxx:99
DECL_LINK(FocusHdl, weld::Widget &, void)
std::shared_ptr< PaletteManager > mxPaletteManager
Definition: colorwindow.hxx:87
Link< const NamedColor &, void > maSelectedLink
std::unique_ptr< weld::Button > mxButtonAutoColor
Definition: colorwindow.hxx:95
std::function< weld::Window *()> TopLevelParentFunction
Definition: colorwindow.hxx:29
const sal_uInt16 theSlotId
Definition: colorwindow.hxx:84
void SetSelectedHdl(const Link< const NamedColor &, void > &rLink)
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
std::function< void(const OUString &, const NamedColor &)> ColorSelectFunction
Definition: Palette.hxx:33
Color maTLBRColor
Definition: colorwindow.hxx:38
std::unique_ptr< SvxColorValueSet > mxColorSet
Definition: colorwindow.hxx:92
virtual void GrabFocus()=0
Color maBLTRColor
Definition: colorwindow.hxx:39
ColorSelectFunction maColorSelectFunction
Definition: colorwindow.hxx:90