xref: /aoo41x/main/sfx2/source/sidebar/TitleBar.cxx (revision b9e67834)
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     // Paint title bar background.
57     Size aWindowSize( GetOutputSizePixel() );
58     /*
59     int nOuterLeft = 0;
60     const SvBorder aBorder( 3, 1, 3, 3 );
61     const sal_Int32 m_nTitleBarHeight = GetSettings().GetStyleSettings().GetTitleHeight();
62     int nInnerLeft = nOuterLeft + aBorder.Left() - 1;
63     int nOuterRight = aWindowSize.Width() - 1;
64     int nInnerRight = nOuterRight - aBorder.Right() + 1;
65     int nInnerTop = m_nTitleBarHeight + aBorder.Top() - 1;
66     int nOuterBottom = aWindowSize.Height() - 1;
67     int nInnerBottom = nOuterBottom - aBorder.Bottom() + 1;
68     Rectangle aTitleBarBox(
69         nOuterLeft,
70         0,
71         nOuterRight,
72         nInnerTop-1
73         );
74     */
75     Rectangle aTitleBarBox(
76         0,
77         0,
78         aWindowSize.Width(),
79         aWindowSize.Height()
80         );
81 
82 
83     PaintBackground(aTitleBarBox);
84     PaintDecoration(aTitleBarBox);
85     PaintTitle(GetTitleArea(aTitleBarBox));
86 }
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