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