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 #include "precompiled_sfx2.hxx" 23 24 #include "Theme.hxx" 25 #include "Paint.hxx" 26 #include "SidebarResource.hxx" 27 28 #include <tools/SvBorder.hxx> 29 #include <tools/rc.hxx> 30 #include <vcl/svapp.hxx> 31 32 33 namespace sfx2 { namespace sidebar { 34 35 void InitializeTheme1 (Theme::Data& rData); 36 37 class Theme::Data 38 { 39 public: 40 Data (void) {} 41 void Initialize (void) { if ( ! mbIsInitialized) {InitializeTheme1(*this);mbIsInitialized=true;} } 42 43 Paint maDeckBackground; 44 Paint maDeckTitleBackground; 45 SvBorder maDeckPadding; 46 sal_Int32 mnDeckBorderSize; 47 Color maDeckTitleFontColor; 48 sal_Int32 mnDeckTitleBarHeight; 49 50 Paint maPanelBackground; 51 Paint maPanelTitleBackground; 52 Color maPanelTitleFontColor; 53 sal_Int32 mnPanelTitleBarHeight; 54 55 Paint maTabBarBackground; 56 SvBorder maTabBarPadding; 57 58 sal_Int32 mnTabMenuPadding; 59 Color maTabMenuSeparatorColor; 60 sal_Int32 mnTabMenuSeparatorPadding; 61 62 Size maTabItemSize; 63 Color maTabItemBorderColor; 64 Paint maTabItemBackgroundPaint; 65 66 Paint maHorizontalBorderPaint; 67 Paint maVerticalBorderPaint; 68 69 Image maGripImage; 70 Image maExpandImage; 71 Image maCollapseImage; 72 Image maMenuImage; 73 74 bool mbIsHighContrastMode; 75 }; 76 77 78 bool Theme::mbIsInitialized (false); 79 80 81 82 Theme::Data& Theme::GetCurrentTheme (void) 83 { 84 static Theme::Data maData; 85 maData.Initialize(); 86 return maData; 87 } 88 89 Paint& Theme::GetDeckBackground (void) 90 { 91 return GetCurrentTheme().maDeckBackground; 92 } 93 94 95 96 97 Paint& Theme::GetDeckTitleBackground (void) 98 { 99 return GetCurrentTheme().maDeckTitleBackground; 100 } 101 102 103 104 105 SvBorder& Theme::GetDeckPadding (void) 106 { 107 return GetCurrentTheme().maDeckPadding; 108 } 109 110 111 112 113 Color Theme::GetDeckTitleFontColor (void) 114 { 115 return GetCurrentTheme().maDeckTitleFontColor; 116 } 117 118 119 120 121 sal_Int32 Theme::GetDeckTitleBarHeight (void) 122 { 123 return GetCurrentTheme().mnDeckTitleBarHeight; 124 } 125 126 127 128 129 Paint& Theme::GetPanelBackground (void) 130 { 131 return GetCurrentTheme().maPanelBackground; 132 } 133 134 135 136 137 Paint& Theme::GetPanelTitleBackground (void) 138 { 139 return GetCurrentTheme().maPanelTitleBackground; 140 } 141 142 143 144 145 Color Theme::GetPanelTitleFontColor (void) 146 { 147 return GetCurrentTheme().maPanelTitleFontColor; 148 } 149 150 151 152 153 sal_Int32 Theme::GetPanelTitleBarHeight (void) 154 { 155 return GetCurrentTheme().mnPanelTitleBarHeight; 156 } 157 158 159 160 161 Paint& Theme::GetTabBarBackground (void) 162 { 163 return GetCurrentTheme().maTabBarBackground; 164 } 165 166 167 168 169 SvBorder& Theme::GetTabBarPadding (void) 170 { 171 return GetCurrentTheme().maTabBarPadding; 172 } 173 174 175 176 177 sal_Int32 Theme::GetTabMenuPadding (void) 178 { 179 return GetCurrentTheme().mnTabMenuPadding; 180 } 181 182 183 184 185 Color Theme::GetTabMenuSeparatorColor (void) 186 { 187 return GetCurrentTheme().maTabMenuSeparatorColor; 188 } 189 190 191 192 193 sal_Int32 Theme::GetTabMenuSeparatorPadding (void) 194 { 195 return GetCurrentTheme().mnTabMenuSeparatorPadding; 196 } 197 198 199 200 201 Size Theme::GetTabItemSize (void) 202 { 203 return GetCurrentTheme().maTabItemSize; 204 } 205 206 207 208 209 Color Theme::GetTabItemBorderColor (void) 210 { 211 return GetCurrentTheme().maTabItemBorderColor; 212 } 213 214 215 216 217 Paint& Theme::GetTabItemBackgroundPaint (void) 218 { 219 return GetCurrentTheme().maTabItemBackgroundPaint; 220 } 221 222 223 224 225 Paint& Theme::GetHorizontalBorderPaint (void) 226 { 227 return GetCurrentTheme().maHorizontalBorderPaint; 228 } 229 230 231 232 233 Paint& Theme::GetVerticalBorderPaint (void) 234 { 235 return GetCurrentTheme().maVerticalBorderPaint; 236 } 237 238 239 240 241 sal_Int32 Theme::GetBorderSize (void) 242 { 243 return GetCurrentTheme().mnDeckBorderSize; 244 } 245 246 247 248 249 Image Theme::GetGripImage (void) 250 { 251 return GetCurrentTheme().maGripImage; 252 } 253 254 255 256 257 Image Theme::GetExpandImage (void) 258 { 259 return GetCurrentTheme().maExpandImage; 260 } 261 262 263 264 265 Image Theme::GetCollapseImage (void) 266 { 267 return GetCurrentTheme().maCollapseImage; 268 } 269 270 271 272 273 Image Theme::GetMenuImage (void) 274 { 275 return GetCurrentTheme().maMenuImage; 276 } 277 278 279 280 281 bool Theme::IsHighContrastMode (void) 282 { 283 return GetCurrentTheme().mbIsHighContrastMode; 284 } 285 286 287 288 289 void Theme::HandleDataChange (void) 290 { 291 mbIsInitialized = false; 292 } 293 294 295 296 297 void InitializeTheme1 (Theme::Data& rData) 298 { 299 SidebarResource aLocalResource; 300 301 rData.mbIsHighContrastMode = Application::GetSettings().GetStyleSettings().GetHighContrastMode(); 302 303 rData.maDeckBackground.Set(Paint(Color( 304 rData.mbIsHighContrastMode ? 0x000000 : 0xf0f0f0))); 305 rData.maDeckTitleBackground.Set(Paint(Color( 306 rData.mbIsHighContrastMode ? 0x000000 :0xf0f0f0))); 307 rData.maDeckPadding = SvBorder(2,2,2,2); 308 rData.mnDeckBorderSize = 1; 309 rData.maDeckTitleFontColor.SetColor( 310 rData.mbIsHighContrastMode ? 0x00ff00 : 0x262626); 311 rData.mnDeckTitleBarHeight = 26; 312 313 rData.maPanelBackground.Set(Paint(Color( 314 rData.mbIsHighContrastMode ? 0x000000 : 0xffffff))); 315 rData.maPanelTitleBackground.Set(Paint(Color( 316 rData.mbIsHighContrastMode ? 0x000000 : 0xb2b2b2))); 317 rData.maPanelTitleFontColor.SetColor( 318 rData.mbIsHighContrastMode ? 0x00ff00 : 0x262626); 319 rData.mnPanelTitleBarHeight = 26; 320 321 rData.maTabBarBackground.Set(Paint(Color( 322 rData.mbIsHighContrastMode ? 0x000000 : 0xf0f0f0))); 323 rData.maTabBarPadding = SvBorder(2,2,2,2); 324 325 rData.mnTabMenuPadding = 6; 326 rData.maTabMenuSeparatorColor.SetColor( 327 rData.mbIsHighContrastMode ? 0x00ff00 : 0xbfbfbf); 328 rData.mnTabMenuSeparatorPadding = 7; 329 330 rData.maTabItemSize = Size(32,32); 331 rData.maTabItemBorderColor.SetColor( 332 rData.mbIsHighContrastMode ? 0x00ff00 : 0xbfbfbf); 333 rData.maTabItemBackgroundPaint.Set(Paint(Color( 334 rData.mbIsHighContrastMode ? 0x000000 : 0xffffff))); 335 336 rData.maHorizontalBorderPaint.Set(Paint(Color( 337 rData.mbIsHighContrastMode ? 0x00ff000 : 0xd9d9d9))); 338 rData.maVerticalBorderPaint.Set(Paint(Color( 339 rData.mbIsHighContrastMode ? 0x00ff000 : 0xd9d9d9))); 340 341 rData.maGripImage = Image(SfxResId( 342 rData.mbIsHighContrastMode 343 ? IMAGE_SIDEBAR_GRIP_HC 344 : IMAGE_SIDEBAR_GRIP)); 345 rData.maExpandImage = Image(SfxResId( 346 rData.mbIsHighContrastMode 347 ? IMAGE_SIDEBAR_PLUS_HC 348 : IMAGE_SIDEBAR_PLUS)); 349 rData.maCollapseImage = Image(SfxResId( 350 rData.mbIsHighContrastMode 351 ? IMAGE_SIDEBAR_MINUS_HC 352 : IMAGE_SIDEBAR_MINUS)); 353 rData.maMenuImage = Image(SfxResId( 354 rData.mbIsHighContrastMode 355 ? IMAGE_SIDEBAR_MENU_HC 356 : IMAGE_SIDEBAR_MENU)); 357 } 358 359 } } // end of namespace sfx2::sidebar 360