1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 #ifndef SFX_SIDEBAR_THEME_HXX 23 #define SFX_SIDEBAR_THEME_HXX 24 25 #include "sfx2/dllapi.h" 26 27 #include <tools/color.hxx> 28 #include <vcl/image.hxx> 29 #include <cppuhelper/compbase2.hxx> 30 #include <cppuhelper/basemutex.hxx> 31 #include <tools/gen.hxx> 32 #include <rtl/ref.hxx> 33 #include <vcl/wall.hxx> 34 35 #include <com/sun/star/beans/XPropertySet.hpp> 36 37 #include <hash_map> 38 #include <map> 39 #include <boost/optional.hpp> 40 41 42 class SvBorder; 43 44 namespace css = ::com::sun::star; 45 namespace cssu = ::com::sun::star::uno; 46 47 48 namespace sfx2 { namespace sidebar { 49 50 51 namespace 52 { 53 typedef ::cppu::WeakComponentImplHelper2 < 54 css::beans::XPropertySet, 55 css::beans::XPropertySetInfo 56 > ThemeInterfaceBase; 57 } 58 59 class Paint; 60 61 /** Simple collection of colors, gradients, fonts that define the 62 look of the sidebar and its controls. 63 */ 64 class SFX2_DLLPUBLIC Theme 65 : private ::boost::noncopyable, 66 private ::cppu::BaseMutex, 67 public ThemeInterfaceBase 68 { 69 public: 70 enum ThemeItem 71 { 72 __Begin, 73 __Pre_Image = __Begin, 74 75 __AnyItem = __Pre_Image, 76 77 Image_Grip, 78 Image_Expand, 79 Image_Collapse, 80 Image_TabBarMenu, 81 Image_PanelMenu, 82 Image_ToolBoxItemSeparator, 83 Image_Closer, 84 Image_CloseIndicator, 85 86 __Image_Color, 87 88 Color_DeckTitleFont, 89 Color_PanelTitleFont, 90 Color_TabMenuSeparator, 91 Color_TabItemBorder, 92 Color_DropDownBorder, 93 Color_Highlight, 94 Color_HighlightText, 95 96 __Color_Paint, 97 98 Paint_DeckBackground, 99 Paint_DeckTitleBarBackground, 100 Paint_PanelBackground, 101 Paint_PanelTitleBarBackground, 102 Paint_TabBarBackground, 103 Paint_TabItemBackgroundNormal, 104 Paint_TabItemBackgroundHighlight, 105 Paint_HorizontalBorder, 106 Paint_VerticalBorder, 107 Paint_ToolBoxBackground, 108 Paint_ToolBoxBorderTopLeft, 109 Paint_ToolBoxBorderCenterCorners, 110 Paint_ToolBoxBorderBottomRight, 111 Paint_DropDownBackground, 112 113 __Paint_Int, 114 115 Int_DeckTitleBarHeight, 116 Int_DeckBorderSize, 117 Int_DeckSeparatorHeight, 118 Int_PanelTitleBarHeight, 119 Int_TabMenuPadding, 120 Int_TabMenuSeparatorPadding, 121 Int_TabItemWidth, 122 Int_TabItemHeight, 123 Int_DeckLeftPadding, 124 Int_DeckTopPadding, 125 Int_DeckRightPadding, 126 Int_DeckBottomPadding, 127 Int_TabBarLeftPadding, 128 Int_TabBarTopPadding, 129 Int_TabBarRightPadding, 130 Int_TabBarBottomPadding, 131 Int_ButtonCornerRadius, 132 133 __Int_Bool, 134 135 Bool_UseSymphonyIcons, 136 Bool_UseSystemColors, 137 Bool_UseToolBoxItemSeparator, 138 Bool_IsHighContrastModeActive, 139 140 __Bool_Rect, 141 142 Rect_ToolBoxPadding, 143 Rect_ToolBoxBorder, 144 145 __Post_Rect, 146 __End=__Post_Rect 147 }; 148 149 static Image GetImage (const ThemeItem eItem); 150 static Color GetColor (const ThemeItem eItem); 151 static const Paint& GetPaint (const ThemeItem eItem); 152 static const Wallpaper GetWallpaper (const ThemeItem eItem); 153 static sal_Int32 GetInteger (const ThemeItem eItem); 154 static bool GetBoolean (const ThemeItem eItem); 155 static Rectangle GetRectangle (const ThemeItem eItem); 156 157 static bool IsHighContrastMode (void); 158 159 static void HandleDataChange (void); 160 161 Theme (void); 162 virtual ~Theme (void); 163 164 virtual void SAL_CALL disposing (void); 165 166 static cssu::Reference<css::beans::XPropertySet> GetPropertySet (void); 167 168 // beans::XPropertySet 169 virtual cssu::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo (void); 170 virtual void SAL_CALL setPropertyValue ( 171 const ::rtl::OUString& rsPropertyName, 172 const cssu::Any& rValue); 173 virtual cssu::Any SAL_CALL getPropertyValue ( 174 const ::rtl::OUString& rsPropertyName); 175 virtual void SAL_CALL addPropertyChangeListener( 176 const ::rtl::OUString& rsPropertyName, 177 const cssu::Reference<css::beans::XPropertyChangeListener>& rxListener); 178 virtual void SAL_CALL removePropertyChangeListener( 179 const ::rtl::OUString& rsPropertyName, 180 const cssu::Reference<css::beans::XPropertyChangeListener>& rxListener); 181 virtual void SAL_CALL addVetoableChangeListener( 182 const ::rtl::OUString& rsPropertyName, 183 const cssu::Reference<css::beans::XVetoableChangeListener>& rxListener); 184 virtual void SAL_CALL removeVetoableChangeListener( 185 const ::rtl::OUString& rsPropertyName, 186 const cssu::Reference<css::beans::XVetoableChangeListener>& rxListener); 187 188 // beans::XPropertySetInfo 189 virtual cssu::Sequence<css::beans::Property> SAL_CALL getProperties (void); 190 virtual css::beans::Property SAL_CALL getPropertyByName (const ::rtl::OUString& rsName); 191 virtual sal_Bool SAL_CALL hasPropertyByName (const ::rtl::OUString& rsName); 192 193 private: 194 static ::rtl::Reference<Theme> mpInstance; 195 static Theme& GetCurrentTheme (void); 196 197 ::std::vector<Image> maImages; 198 ::std::vector<Color> maColors; 199 ::std::vector<Paint> maPaints; 200 ::std::vector<sal_Int32> maIntegers; 201 ::std::vector<bool> maBooleans; 202 ::std::vector<Rectangle> maRectangles; 203 bool mbIsHighContrastMode; 204 bool mbIsHighContrastModeSetManually; 205 206 typedef ::std::hash_map<rtl::OUString,ThemeItem, rtl::OUStringHash> PropertyNameToIdMap; 207 PropertyNameToIdMap maPropertyNameToIdMap; 208 typedef ::std::vector<rtl::OUString> PropertyIdToNameMap; 209 PropertyIdToNameMap maPropertyIdToNameMap; 210 typedef ::std::vector<cssu::Any> RawValueContainer; 211 RawValueContainer maRawValues; 212 213 typedef ::std::vector<cssu::Reference<css::beans::XPropertyChangeListener> > ChangeListenerContainer; 214 typedef ::std::map<ThemeItem,ChangeListenerContainer> ChangeListeners; 215 ChangeListeners maChangeListeners; 216 typedef ::std::vector<cssu::Reference<css::beans::XVetoableChangeListener> > VetoableListenerContainer; 217 typedef ::std::map<ThemeItem,VetoableListenerContainer> VetoableListeners; 218 VetoableListeners maVetoableListeners; 219 220 enum PropertyType 221 { 222 PT_Image, 223 PT_Color, 224 PT_Paint, 225 PT_Integer, 226 PT_Boolean, 227 PT_Rectangle, 228 PT_Invalid 229 }; 230 231 void SetupPropertyMaps (void); 232 void InitializeTheme (void); 233 void UpdateTheme (void); 234 static PropertyType GetPropertyType (const ThemeItem eItem); 235 static cssu::Type GetCppuType (const PropertyType eType); 236 static sal_Int32 GetIndex ( 237 const ThemeItem eItem, 238 const PropertyType eType); 239 240 VetoableListenerContainer* GetVetoableListeners ( 241 const ThemeItem eItem, 242 const bool bCreate); 243 ChangeListenerContainer* GetChangeListeners ( 244 const ThemeItem eItem, 245 const bool bCreate); 246 bool DoVetoableListenersVeto ( 247 const VetoableListenerContainer* pListeners, 248 const css::beans::PropertyChangeEvent& rEvent) const; 249 void BroadcastPropertyChange ( 250 const ChangeListenerContainer* pListeners, 251 const css::beans::PropertyChangeEvent& rEvent) const; 252 void ProcessNewValue ( 253 const cssu::Any& rValue, 254 const ThemeItem eItem, 255 const PropertyType eType); 256 }; 257 258 259 260 } } // end of namespace sfx2::sidebar 261 262 #endif 263