xref: /AOO41X/main/sfx2/source/sidebar/DeckTitleBar.cxx (revision 7a32b0c888def1bf84d1d657c48953bc10dc00c1)
1ff12d537SAndre Fischer /**************************************************************
2ff12d537SAndre Fischer  *
3ff12d537SAndre Fischer  * Licensed to the Apache Software Foundation (ASF) under one
4ff12d537SAndre Fischer  * or more contributor license agreements.  See the NOTICE file
5ff12d537SAndre Fischer  * distributed with this work for additional information
6ff12d537SAndre Fischer  * regarding copyright ownership.  The ASF licenses this file
7ff12d537SAndre Fischer  * to you under the Apache License, Version 2.0 (the
8ff12d537SAndre Fischer  * "License"); you may not use this file except in compliance
9ff12d537SAndre Fischer  * with the License.  You may obtain a copy of the License at
10ff12d537SAndre Fischer  *
11ff12d537SAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
12ff12d537SAndre Fischer  *
13ff12d537SAndre Fischer  * Unless required by applicable law or agreed to in writing,
14ff12d537SAndre Fischer  * software distributed under the License is distributed on an
15ff12d537SAndre Fischer  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16ff12d537SAndre Fischer  * KIND, either express or implied.  See the License for the
17ff12d537SAndre Fischer  * specific language governing permissions and limitations
18ff12d537SAndre Fischer  * under the License.
19ff12d537SAndre Fischer  *
20ff12d537SAndre Fischer  *************************************************************/
21ff12d537SAndre Fischer 
22ff12d537SAndre Fischer #include "precompiled_sfx2.hxx"
23ff12d537SAndre Fischer 
24ff12d537SAndre Fischer #include "DeckTitleBar.hxx"
25b9e67834SAndre Fischer #include "sfx2/sidebar/Theme.hxx"
26ff12d537SAndre Fischer 
2795a18594SAndre Fischer #include <vcl/image.hxx>
2895a18594SAndre Fischer 
29*7a32b0c8SAndre Fischer #ifdef DEBUG
30*7a32b0c8SAndre Fischer #include "Tools.hxx"
31*7a32b0c8SAndre Fischer #endif
32*7a32b0c8SAndre Fischer 
3395a18594SAndre Fischer 
34ff12d537SAndre Fischer namespace sfx2 { namespace sidebar {
35ff12d537SAndre Fischer 
36ff12d537SAndre Fischer static const sal_Int32 gaLeftGripPadding (3);
37ff12d537SAndre Fischer static const sal_Int32 gaRightGripPadding (3);
38ff12d537SAndre Fischer 
39ff12d537SAndre Fischer 
40ff12d537SAndre Fischer DeckTitleBar::DeckTitleBar (
41ff12d537SAndre Fischer     const ::rtl::OUString& rsTitle,
42*7a32b0c8SAndre Fischer     Window* pParentWindow,
43*7a32b0c8SAndre Fischer     const ::boost::function<void(void)>& rCloserAction)
44*7a32b0c8SAndre Fischer     : TitleBar(rsTitle, pParentWindow, GetBackgroundPaint()),
45*7a32b0c8SAndre Fischer       mnCloserItemIndex(1),
46*7a32b0c8SAndre Fischer       maCloserAction(rCloserAction),
47*7a32b0c8SAndre Fischer       mbIsCloserVisible(rCloserAction)
48ff12d537SAndre Fischer {
49*7a32b0c8SAndre Fischer     OSL_ASSERT(pParentWindow != NULL);
50*7a32b0c8SAndre Fischer 
51*7a32b0c8SAndre Fischer     if (maCloserAction)
52*7a32b0c8SAndre Fischer     {
53*7a32b0c8SAndre Fischer         maToolBox.InsertItem(
54*7a32b0c8SAndre Fischer             mnCloserItemIndex,
55*7a32b0c8SAndre Fischer             Theme::GetImage(Theme::Image_Closer));
56*7a32b0c8SAndre Fischer     }
57*7a32b0c8SAndre Fischer 
58*7a32b0c8SAndre Fischer #ifdef DEBUG
59*7a32b0c8SAndre Fischer     SetText(A2S("DeckTitleBar"));
60*7a32b0c8SAndre Fischer #endif
61ff12d537SAndre Fischer }
62ff12d537SAndre Fischer 
63ff12d537SAndre Fischer 
64ff12d537SAndre Fischer 
65ff12d537SAndre Fischer 
66ff12d537SAndre Fischer DeckTitleBar::~DeckTitleBar (void)
67ff12d537SAndre Fischer {
68ff12d537SAndre Fischer }
69ff12d537SAndre Fischer 
70ff12d537SAndre Fischer 
71ff12d537SAndre Fischer 
72ff12d537SAndre Fischer 
73*7a32b0c8SAndre Fischer void DeckTitleBar::SetCloserVisible (const bool bIsCloserVisible)
74*7a32b0c8SAndre Fischer {
75*7a32b0c8SAndre Fischer     if (mbIsCloserVisible != bIsCloserVisible)
76*7a32b0c8SAndre Fischer     {
77*7a32b0c8SAndre Fischer         mbIsCloserVisible = bIsCloserVisible;
78*7a32b0c8SAndre Fischer 
79*7a32b0c8SAndre Fischer         if (mbIsCloserVisible)
80*7a32b0c8SAndre Fischer             maToolBox.InsertItem(
81*7a32b0c8SAndre Fischer                 mnCloserItemIndex,
82*7a32b0c8SAndre Fischer                 Theme::GetImage(Theme::Image_Closer));
83*7a32b0c8SAndre Fischer         else
84*7a32b0c8SAndre Fischer             maToolBox.RemoveItem(
85*7a32b0c8SAndre Fischer                 maToolBox.GetItemPos(mnCloserItemIndex));
86*7a32b0c8SAndre Fischer     }
87*7a32b0c8SAndre Fischer }
88*7a32b0c8SAndre Fischer 
89*7a32b0c8SAndre Fischer 
90*7a32b0c8SAndre Fischer 
91*7a32b0c8SAndre Fischer 
92ff12d537SAndre Fischer Rectangle DeckTitleBar::GetTitleArea (const Rectangle& rTitleBarBox)
93ff12d537SAndre Fischer {
94b9e67834SAndre Fischer     Image aGripImage (Theme::GetImage(Theme::Image_Grip));
95ff12d537SAndre Fischer     return Rectangle(
96ff12d537SAndre Fischer         aGripImage.GetSizePixel().Width() + gaLeftGripPadding + gaRightGripPadding,
97ff12d537SAndre Fischer         rTitleBarBox.Top(),
98ff12d537SAndre Fischer         rTitleBarBox.Right(),
99ff12d537SAndre Fischer         rTitleBarBox.Bottom());
100ff12d537SAndre Fischer }
101ff12d537SAndre Fischer 
102ff12d537SAndre Fischer 
103ff12d537SAndre Fischer 
104ff12d537SAndre Fischer 
105ff12d537SAndre Fischer void DeckTitleBar::PaintDecoration (const Rectangle& rTitleBarBox)
106ff12d537SAndre Fischer {
107b9e67834SAndre Fischer     (void)rTitleBarBox;
108b9e67834SAndre Fischer 
109b9e67834SAndre Fischer     Image aGripImage (Theme::GetImage(Theme::Image_Grip));
110ff12d537SAndre Fischer 
111ff12d537SAndre Fischer     const Point aTopLeft (
112ff12d537SAndre Fischer         gaLeftGripPadding,
113ff12d537SAndre Fischer         (GetSizePixel().Height()-aGripImage.GetSizePixel().Height())/2);
114ff12d537SAndre Fischer     DrawImage(aTopLeft, aGripImage);
115ff12d537SAndre Fischer }
116ff12d537SAndre Fischer 
117ff12d537SAndre Fischer 
118ff12d537SAndre Fischer 
119ff12d537SAndre Fischer 
120ff12d537SAndre Fischer sidebar::Paint DeckTitleBar::GetBackgroundPaint (void)
121ff12d537SAndre Fischer {
122b9e67834SAndre Fischer     return Theme::GetPaint(Theme::Paint_DeckTitleBarBackground);
123ff12d537SAndre Fischer }
124ff12d537SAndre Fischer 
125ff12d537SAndre Fischer 
126ff12d537SAndre Fischer 
127ff12d537SAndre Fischer 
128ff12d537SAndre Fischer Color DeckTitleBar::GetTextColor (void)
129ff12d537SAndre Fischer {
130b9e67834SAndre Fischer     return Theme::GetColor(Theme::Color_DeckTitleFont);
131ff12d537SAndre Fischer }
132ff12d537SAndre Fischer 
133ff12d537SAndre Fischer 
134*7a32b0c8SAndre Fischer 
135*7a32b0c8SAndre Fischer 
136*7a32b0c8SAndre Fischer void DeckTitleBar::HandleToolBoxItemClick (const sal_uInt16 nItemIndex)
137*7a32b0c8SAndre Fischer {
138*7a32b0c8SAndre Fischer     if (nItemIndex == mnCloserItemIndex)
139*7a32b0c8SAndre Fischer         if (maCloserAction)
140*7a32b0c8SAndre Fischer             maCloserAction();
141*7a32b0c8SAndre Fischer }
142*7a32b0c8SAndre Fischer 
143*7a32b0c8SAndre Fischer 
144*7a32b0c8SAndre Fischer 
145*7a32b0c8SAndre Fischer 
146*7a32b0c8SAndre Fischer void DeckTitleBar::DataChanged (const DataChangedEvent& rEvent)
147*7a32b0c8SAndre Fischer {
148*7a32b0c8SAndre Fischer     maToolBox.SetItemImage(
149*7a32b0c8SAndre Fischer         mnCloserItemIndex,
150*7a32b0c8SAndre Fischer         Theme::GetImage(Theme::Image_Closer));
151*7a32b0c8SAndre Fischer }
152*7a32b0c8SAndre Fischer 
153*7a32b0c8SAndre Fischer 
154ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar
155