bump product version to 4.2.0.1
[LibreOffice.git] / include / sfx2 / sidebar / Theme.hxx
blobd8cc59f9932d28a5ecf28277438cff160d99d1d7
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 .
19 #ifndef INCLUDED_SFX2_SIDEBAR_THEME_HXX
20 #define INCLUDED_SFX2_SIDEBAR_THEME_HXX
22 #include <sfx2/dllapi.h>
24 #include <tools/color.hxx>
25 #include <vcl/image.hxx>
26 #include <cppuhelper/compbase2.hxx>
27 #include <cppuhelper/basemutex.hxx>
28 #include <tools/gen.hxx>
29 #include <rtl/ref.hxx>
30 #include <vcl/wall.hxx>
32 #include <com/sun/star/beans/XPropertySet.hpp>
34 #include <boost/unordered_map.hpp>
35 #include <map>
36 #include <boost/optional.hpp>
38 class SvBorder;
40 namespace cssu = ::com::sun::star::uno;
43 namespace sfx2 { namespace sidebar {
46 namespace
48 typedef ::cppu::WeakComponentImplHelper2 <
49 css::beans::XPropertySet,
50 css::beans::XPropertySetInfo
51 > ThemeInterfaceBase;
54 class Paint;
56 /** Simple collection of colors, gradients, fonts that define the
57 look of the sidebar and its controls.
59 class SFX2_DLLPUBLIC Theme
60 : private ::boost::noncopyable,
61 private ::cppu::BaseMutex,
62 public ThemeInterfaceBase
64 public:
65 enum ThemeItem
67 __Begin,
68 __Pre_Image = __Begin,
70 __AnyItem = __Pre_Image,
72 Image_Grip,
73 Image_Expand,
74 Image_Collapse,
75 Image_TabBarMenu,
76 Image_PanelMenu,
77 Image_ToolBoxItemSeparator,
78 Image_Closer,
79 Image_CloseIndicator,
81 __Image_Color,
83 Color_DeckTitleFont,
84 Color_PanelTitleFont,
85 Color_TabMenuSeparator,
86 Color_TabItemBorder,
87 Color_DropDownBorder,
88 Color_Highlight,
89 Color_HighlightText,
91 __Color_Paint,
93 Paint_DeckBackground,
94 Paint_DeckTitleBarBackground,
95 Paint_PanelBackground,
96 Paint_PanelTitleBarBackground,
97 Paint_TabBarBackground,
98 Paint_TabItemBackgroundNormal,
99 Paint_TabItemBackgroundHighlight,
100 Paint_HorizontalBorder,
101 Paint_VerticalBorder,
102 Paint_ToolBoxBackground,
103 Paint_ToolBoxBorderTopLeft,
104 Paint_ToolBoxBorderCenterCorners,
105 Paint_ToolBoxBorderBottomRight,
106 Paint_DropDownBackground,
108 __Paint_Int,
110 Int_DeckTitleBarHeight,
111 Int_DeckBorderSize,
112 Int_DeckSeparatorHeight,
113 Int_PanelTitleBarHeight,
114 Int_TabMenuPadding,
115 Int_TabMenuSeparatorPadding,
116 Int_TabItemWidth,
117 Int_TabItemHeight,
118 Int_DeckLeftPadding,
119 Int_DeckTopPadding,
120 Int_DeckRightPadding,
121 Int_DeckBottomPadding,
122 Int_TabBarLeftPadding,
123 Int_TabBarTopPadding,
124 Int_TabBarRightPadding,
125 Int_TabBarBottomPadding,
126 Int_ButtonCornerRadius,
128 __Int_Bool,
130 Bool_UseSymphonyIcons,
131 Bool_UseSystemColors,
132 Bool_UseToolBoxItemSeparator,
133 Bool_IsHighContrastModeActive,
135 __Bool_Rect,
137 Rect_ToolBoxPadding,
138 Rect_ToolBoxBorder,
140 __Post_Rect,
141 __End=__Post_Rect
144 static Image GetImage (const ThemeItem eItem);
145 static Color GetColor (const ThemeItem eItem);
146 static const Paint& GetPaint (const ThemeItem eItem);
147 static const Wallpaper GetWallpaper (const ThemeItem eItem);
148 static sal_Int32 GetInteger (const ThemeItem eItem);
149 static bool GetBoolean (const ThemeItem eItem);
151 static bool IsHighContrastMode (void);
153 static void HandleDataChange (void);
155 void InitializeTheme();
157 Theme (void);
158 virtual ~Theme (void);
160 virtual void SAL_CALL disposing (void);
162 static cssu::Reference<css::beans::XPropertySet> GetPropertySet (void);
164 // beans::XPropertySet
165 virtual cssu::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo (void)
166 throw(cssu::RuntimeException);
167 virtual void SAL_CALL setPropertyValue (
168 const ::rtl::OUString& rsPropertyName,
169 const cssu::Any& rValue)
170 throw(cssu::RuntimeException);
171 virtual cssu::Any SAL_CALL getPropertyValue (
172 const ::rtl::OUString& rsPropertyName)
173 throw(css::beans::UnknownPropertyException,
174 css::lang::WrappedTargetException,
175 cssu::RuntimeException);
176 virtual void SAL_CALL addPropertyChangeListener(
177 const ::rtl::OUString& rsPropertyName,
178 const cssu::Reference<css::beans::XPropertyChangeListener>& rxListener)
179 throw(css::beans::UnknownPropertyException,
180 css::lang::WrappedTargetException,
181 cssu::RuntimeException);
182 virtual void SAL_CALL removePropertyChangeListener(
183 const ::rtl::OUString& rsPropertyName,
184 const cssu::Reference<css::beans::XPropertyChangeListener>& rxListener)
185 throw(css::beans::UnknownPropertyException,
186 css::lang::WrappedTargetException,
187 cssu::RuntimeException);
188 virtual void SAL_CALL addVetoableChangeListener(
189 const ::rtl::OUString& rsPropertyName,
190 const cssu::Reference<css::beans::XVetoableChangeListener>& rxListener)
191 throw(css::beans::UnknownPropertyException,
192 css::lang::WrappedTargetException,
193 cssu::RuntimeException);
194 virtual void SAL_CALL removeVetoableChangeListener(
195 const ::rtl::OUString& rsPropertyName,
196 const cssu::Reference<css::beans::XVetoableChangeListener>& rxListener)
197 throw(css::beans::UnknownPropertyException,
198 css::lang::WrappedTargetException,
199 cssu::RuntimeException);
201 // beans::XPropertySetInfo
202 virtual cssu::Sequence<css::beans::Property> SAL_CALL getProperties (void)
203 throw(cssu::RuntimeException);
204 virtual css::beans::Property SAL_CALL getPropertyByName (const ::rtl::OUString& rsName)
205 throw(css::beans::UnknownPropertyException,
206 cssu::RuntimeException);
207 virtual sal_Bool SAL_CALL hasPropertyByName (const ::rtl::OUString& rsName)
208 throw(cssu::RuntimeException);
210 private:
211 static Theme& GetCurrentTheme();
213 ::std::vector<Image> maImages;
214 ::std::vector<Color> maColors;
215 ::std::vector<Paint> maPaints;
216 ::std::vector<sal_Int32> maIntegers;
217 ::std::vector<bool> maBooleans;
218 ::std::vector<Rectangle> maRectangles;
219 bool mbIsHighContrastMode;
220 bool mbIsHighContrastModeSetManually;
222 typedef ::boost::unordered_map<rtl::OUString,ThemeItem, rtl::OUStringHash> PropertyNameToIdMap;
223 PropertyNameToIdMap maPropertyNameToIdMap;
224 typedef ::std::vector<rtl::OUString> PropertyIdToNameMap;
225 PropertyIdToNameMap maPropertyIdToNameMap;
226 typedef ::std::vector<cssu::Any> RawValueContainer;
227 RawValueContainer maRawValues;
229 typedef ::std::vector<cssu::Reference<css::beans::XPropertyChangeListener> > ChangeListenerContainer;
230 typedef ::std::map<ThemeItem,ChangeListenerContainer> ChangeListeners;
231 ChangeListeners maChangeListeners;
232 typedef ::std::vector<cssu::Reference<css::beans::XVetoableChangeListener> > VetoableListenerContainer;
233 typedef ::std::map<ThemeItem,VetoableListenerContainer> VetoableListeners;
234 VetoableListeners maVetoableListeners;
236 enum PropertyType
238 PT_Image,
239 PT_Color,
240 PT_Paint,
241 PT_Integer,
242 PT_Boolean,
243 PT_Rectangle,
244 PT_Invalid
247 void SetupPropertyMaps (void);
248 void UpdateTheme (void);
249 static PropertyType GetPropertyType (const ThemeItem eItem);
250 static cssu::Type GetCppuType (const PropertyType eType);
251 static sal_Int32 GetIndex (
252 const ThemeItem eItem,
253 const PropertyType eType);
255 VetoableListenerContainer* GetVetoableListeners (
256 const ThemeItem eItem,
257 const bool bCreate);
258 ChangeListenerContainer* GetChangeListeners (
259 const ThemeItem eItem,
260 const bool bCreate);
261 bool DoVetoableListenersVeto (
262 const VetoableListenerContainer* pListeners,
263 const css::beans::PropertyChangeEvent& rEvent) const;
264 void BroadcastPropertyChange (
265 const ChangeListenerContainer* pListeners,
266 const css::beans::PropertyChangeEvent& rEvent) const;
267 void ProcessNewValue (
268 const cssu::Any& rValue,
269 const ThemeItem eItem,
270 const PropertyType eType);
275 } } // end of namespace sfx2::sidebar
277 #endif
279 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */