xref: /aoo42x/main/sfx2/source/sidebar/TitleBar.cxx (revision 22de8995)
1*22de8995SAndre Fischer /**************************************************************
2*22de8995SAndre Fischer  *
3*22de8995SAndre Fischer  * Licensed to the Apache Software Foundation (ASF) under one
4*22de8995SAndre Fischer  * or more contributor license agreements.  See the NOTICE file
5*22de8995SAndre Fischer  * distributed with this work for additional information
6*22de8995SAndre Fischer  * regarding copyright ownership.  The ASF licenses this file
7*22de8995SAndre Fischer  * to you under the Apache License, Version 2.0 (the
8*22de8995SAndre Fischer  * "License"); you may not use this file except in compliance
9*22de8995SAndre Fischer  * with the License.  You may obtain a copy of the License at
10*22de8995SAndre Fischer  *
11*22de8995SAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
12*22de8995SAndre Fischer  *
13*22de8995SAndre Fischer  * Unless required by applicable law or agreed to in writing,
14*22de8995SAndre Fischer  * software distributed under the License is distributed on an
15*22de8995SAndre Fischer  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*22de8995SAndre Fischer  * KIND, either express or implied.  See the License for the
17*22de8995SAndre Fischer  * specific language governing permissions and limitations
18*22de8995SAndre Fischer  * under the License.
19*22de8995SAndre Fischer  *
20*22de8995SAndre Fischer  *************************************************************/
21*22de8995SAndre Fischer 
22*22de8995SAndre Fischer #include "precompiled_sfx2.hxx"
23*22de8995SAndre Fischer 
24*22de8995SAndre Fischer #include "TitleBar.hxx"
25*22de8995SAndre Fischer 
26*22de8995SAndre Fischer #include <tools/svborder.hxx>
27*22de8995SAndre Fischer #include <vcl/gradient.hxx>
28*22de8995SAndre Fischer 
29*22de8995SAndre Fischer 
30*22de8995SAndre Fischer namespace sfx2 {
31*22de8995SAndre Fischer 
32*22de8995SAndre Fischer TitleBar::TitleBar (
33*22de8995SAndre Fischer     const ::rtl::OUString& rsTitle,
34*22de8995SAndre Fischer     const bool bIsDeckTitle,
35*22de8995SAndre Fischer     Window* pParentWindow)
36*22de8995SAndre Fischer     : Window(pParentWindow),
37*22de8995SAndre Fischer       msTitle(rsTitle),
38*22de8995SAndre Fischer       mbIsDeckTitle(bIsDeckTitle)
39*22de8995SAndre Fischer {
40*22de8995SAndre Fischer     SetBackground(Wallpaper());
41*22de8995SAndre Fischer }
42*22de8995SAndre Fischer 
43*22de8995SAndre Fischer 
44*22de8995SAndre Fischer 
45*22de8995SAndre Fischer 
46*22de8995SAndre Fischer TitleBar::~TitleBar (void)
47*22de8995SAndre Fischer {
48*22de8995SAndre Fischer }
49*22de8995SAndre Fischer 
50*22de8995SAndre Fischer 
51*22de8995SAndre Fischer 
52*22de8995SAndre Fischer 
53*22de8995SAndre Fischer void TitleBar::Paint (const Rectangle& rUpdateArea)
54*22de8995SAndre Fischer {
55*22de8995SAndre Fischer     Push(PUSH_FONT | PUSH_FILLCOLOR | PUSH_LINECOLOR);
56*22de8995SAndre Fischer 
57*22de8995SAndre Fischer     // Set title bar colors.
58*22de8995SAndre Fischer     SetFillColor(GetSettings().GetStyleSettings().GetDialogColor());
59*22de8995SAndre Fischer     SetLineColor();
60*22de8995SAndre Fischer 
61*22de8995SAndre Fischer     // Paint title bar background.
62*22de8995SAndre Fischer     Size aWindowSize( GetOutputSizePixel() );
63*22de8995SAndre Fischer     int nOuterLeft = 0;
64*22de8995SAndre Fischer     const SvBorder aBorder( 3, 1, 3, 3 );
65*22de8995SAndre Fischer     const sal_Int32 m_nTitleBarHeight = GetSettings().GetStyleSettings().GetTitleHeight();
66*22de8995SAndre Fischer     int nInnerLeft = nOuterLeft + aBorder.Left() - 1;
67*22de8995SAndre Fischer     int nOuterRight = aWindowSize.Width() - 1;
68*22de8995SAndre Fischer     int nInnerRight = nOuterRight - aBorder.Right() + 1;
69*22de8995SAndre Fischer     int nInnerTop = m_nTitleBarHeight + aBorder.Top() - 1;
70*22de8995SAndre Fischer     int nOuterBottom = aWindowSize.Height() - 1;
71*22de8995SAndre Fischer     int nInnerBottom = nOuterBottom - aBorder.Bottom() + 1;
72*22de8995SAndre Fischer     Rectangle aTitleBarBox(
73*22de8995SAndre Fischer         nOuterLeft,
74*22de8995SAndre Fischer         0,
75*22de8995SAndre Fischer         nOuterRight,
76*22de8995SAndre Fischer         nInnerTop-1
77*22de8995SAndre Fischer         );
78*22de8995SAndre Fischer     const static Gradient aTitleBarGradient(
79*22de8995SAndre Fischer         GRADIENT_LINEAR,
80*22de8995SAndre Fischer         Color(0xe8e8f0),
81*22de8995SAndre Fischer         Color(0xf0f0ff));
82*22de8995SAndre Fischer     DrawGradient(aTitleBarBox, aTitleBarGradient);
83*22de8995SAndre Fischer 
84*22de8995SAndre Fischer     // Use a bold font for the deck title.
85*22de8995SAndre Fischer     Font aFont(GetFont());
86*22de8995SAndre Fischer     aFont.SetWeight(WEIGHT_BOLD);
87*22de8995SAndre Fischer     SetFont(aFont);
88*22de8995SAndre Fischer 
89*22de8995SAndre Fischer     // Paint title bar text.
90*22de8995SAndre Fischer     SetLineColor( GetSettings().GetStyleSettings().GetActiveTextColor() );
91*22de8995SAndre Fischer     aTitleBarBox.Left() += 3;
92*22de8995SAndre Fischer     DrawText(
93*22de8995SAndre Fischer         aTitleBarBox,
94*22de8995SAndre Fischer         msTitle,
95*22de8995SAndre Fischer         TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER);
96*22de8995SAndre Fischer 
97*22de8995SAndre Fischer     Pop();
98*22de8995SAndre Fischer }
99*22de8995SAndre Fischer 
100*22de8995SAndre Fischer 
101*22de8995SAndre Fischer } // end of namespace sfx2
102