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 "TitleBar.hxx" 25 #include "Theme.hxx" 26 #include "Paint.hxx" 27 28 #include <tools/svborder.hxx> 29 #include <vcl/gradient.hxx> 30 31 ToolbarValue::~ToolbarValue (void) {} 32 33 34 namespace sfx2 { namespace sidebar { 35 36 TitleBar::TitleBar ( 37 const ::rtl::OUString& rsTitle, 38 Window* pParentWindow) 39 : Window(pParentWindow), 40 msTitle(rsTitle) 41 { 42 SetBackground(Wallpaper()); 43 } 44 45 46 47 48 TitleBar::~TitleBar (void) 49 { 50 } 51 52 53 54 55 void TitleBar::Paint (const Rectangle& rUpdateArea) 56 { 57 // Paint title bar background. 58 Size aWindowSize( GetOutputSizePixel() ); 59 /* 60 int nOuterLeft = 0; 61 const SvBorder aBorder( 3, 1, 3, 3 ); 62 const sal_Int32 m_nTitleBarHeight = GetSettings().GetStyleSettings().GetTitleHeight(); 63 int nInnerLeft = nOuterLeft + aBorder.Left() - 1; 64 int nOuterRight = aWindowSize.Width() - 1; 65 int nInnerRight = nOuterRight - aBorder.Right() + 1; 66 int nInnerTop = m_nTitleBarHeight + aBorder.Top() - 1; 67 int nOuterBottom = aWindowSize.Height() - 1; 68 int nInnerBottom = nOuterBottom - aBorder.Bottom() + 1; 69 Rectangle aTitleBarBox( 70 nOuterLeft, 71 0, 72 nOuterRight, 73 nInnerTop-1 74 ); 75 */ 76 Rectangle aTitleBarBox( 77 0, 78 0, 79 aWindowSize.Width(), 80 aWindowSize.Height() 81 ); 82 83 84 PaintBackground(aTitleBarBox); 85 PaintDecoration(aTitleBarBox); 86 PaintTitle(GetTitleArea(aTitleBarBox)); 87 } 88 89 90 91 void TitleBar::PaintBackground (const Rectangle& rTitleBarBox) 92 { 93 const sidebar::Paint aBackgroundPaint (GetBackgroundPaint()); 94 95 switch(aBackgroundPaint.GetType()) 96 { 97 case Paint::NoPaint: 98 default: 99 break; 100 101 case Paint::ColorPaint: 102 // Set title bar colors. 103 Push(PUSH_LINECOLOR | PUSH_FILLCOLOR); 104 SetFillColor(aBackgroundPaint.GetColor()); 105 SetLineColor(); 106 DrawRect(rTitleBarBox); 107 Pop(); 108 break; 109 110 case Paint::GradientPaint: 111 DrawGradient(rTitleBarBox, aBackgroundPaint.GetGradient()); 112 break; 113 } 114 } 115 116 117 118 119 void TitleBar::PaintTitle (const Rectangle& rTitleBox) 120 { 121 Push(PUSH_FONT | PUSH_TEXTCOLOR); 122 123 // Use a bold font for the deck title. 124 Font aFont(GetFont()); 125 aFont.SetWeight(WEIGHT_BOLD); 126 SetFont(aFont); 127 128 // Paint title bar text. 129 SetTextColor(GetTextColor()); 130 DrawText( 131 rTitleBox, 132 msTitle, 133 TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER); 134 135 Pop(); 136 } 137 138 139 } } // end of namespace sfx2::sidebar 140