xref: /trunk/main/sfx2/source/sidebar/TitleBar.cxx (revision 7a32b0c8)
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     const sidebar::Paint& rInitialBackgroundPaint)
39     : Window(pParentWindow),
40       maToolBox(this),
41       msTitle(rsTitle)
42 {
43     SetBackground(rInitialBackgroundPaint.GetWallpaper());
44 
45     maToolBox.SetSelectHdl(LINK(this, TitleBar, SelectionHandler));
46 }
47 
48 
49 
50 
51 TitleBar::~TitleBar (void)
52 {
53 }
54 
55 
56 
57 
58 void TitleBar::Paint (const Rectangle& rUpdateArea)
59 {
60     (void)rUpdateArea;
61 
62     // Paint title bar background.
63     Size aWindowSize( GetOutputSizePixel() );
64     Rectangle aTitleBarBox(
65         0,
66         0,
67         aWindowSize.Width(),
68         aWindowSize.Height()
69         );
70 
71     PaintDecoration(aTitleBarBox);
72     PaintTitle(GetTitleArea(aTitleBarBox));
73 }
74 
75 
76 
77 
78 void TitleBar::DataChanged (const DataChangedEvent& rEvent)
79 {
80     (void)rEvent;
81 
82     SetBackground(GetBackgroundPaint().GetWallpaper());
83 }
84 
85 
86 
87 
88 void TitleBar::SetPosSizePixel (
89     long nX,
90     long nY,
91     long nWidth,
92     long nHeight,
93     sal_uInt16 nFlags)
94 {
95     Window::SetPosSizePixel(nX,nY,nWidth,nHeight,nFlags);
96 
97     // Place the toolbox.
98     const sal_Int32 nToolBoxWidth (maToolBox.GetItemPosRect(0).GetWidth());
99     maToolBox.SetPosSizePixel(nWidth-nToolBoxWidth,0,nToolBoxWidth,nHeight);
100     maToolBox.Show();
101 }
102 
103 
104 
105 
106 void TitleBar::HandleToolBoxItemClick (const sal_uInt16 nItemIndex)
107 {
108     (void)nItemIndex;
109     // Any real processing has to be done in derived class.
110 }
111 
112 
113 
114 
115 void TitleBar::PaintTitle (const Rectangle& rTitleBox)
116 {
117     Push(PUSH_FONT | PUSH_TEXTCOLOR);
118 
119     // Use a bold font for the deck title.
120     Font aFont(GetFont());
121     aFont.SetWeight(WEIGHT_BOLD);
122     SetFont(aFont);
123 
124     // Paint title bar text.
125     SetTextColor(GetTextColor());
126     DrawText(
127         rTitleBox,
128         msTitle,
129         TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER);
130 
131     Pop();
132 }
133 
134 
135 
136 
137 IMPL_LINK(TitleBar, SelectionHandler, ToolBox*, pToolBox)
138 {
139     (void)pToolBox;
140     OSL_ASSERT(&maToolBox==pToolBox);
141     const sal_uInt16 nItemId (maToolBox.GetHighlightItemId());
142 
143     HandleToolBoxItemClick(nItemId);
144 
145     return sal_True;
146 }
147 
148 } } // end of namespace sfx2::sidebar
149