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"
26abdd804dSAndre Fischer #include "sfx2/sfxresid.hxx"
27abdd804dSAndre Fischer #include "Sidebar.hrc"
28ff12d537SAndre Fischer
2995a18594SAndre Fischer #include <vcl/image.hxx>
3095a18594SAndre Fischer
317a32b0c8SAndre Fischer #ifdef DEBUG
32f35c6d02SAndre Fischer #include "sfx2/sidebar/Tools.hxx"
337a32b0c8SAndre Fischer #endif
347a32b0c8SAndre Fischer
3595a18594SAndre Fischer
36ff12d537SAndre Fischer namespace sfx2 { namespace sidebar {
37ff12d537SAndre Fischer
38ff12d537SAndre Fischer static const sal_Int32 gaLeftGripPadding (3);
39ff12d537SAndre Fischer static const sal_Int32 gaRightGripPadding (3);
40ff12d537SAndre Fischer
41ff12d537SAndre Fischer
DeckTitleBar(const::rtl::OUString & rsTitle,Window * pParentWindow,const::boost::function<void (void)> & rCloserAction)42ff12d537SAndre Fischer DeckTitleBar::DeckTitleBar (
43ff12d537SAndre Fischer const ::rtl::OUString& rsTitle,
447a32b0c8SAndre Fischer Window* pParentWindow,
457a32b0c8SAndre Fischer const ::boost::function<void(void)>& rCloserAction)
467a32b0c8SAndre Fischer : TitleBar(rsTitle, pParentWindow, GetBackgroundPaint()),
477a32b0c8SAndre Fischer mnCloserItemIndex(1),
487a32b0c8SAndre Fischer maCloserAction(rCloserAction),
49abdd804dSAndre Fischer mbIsCloserVisible(false)
50ff12d537SAndre Fischer {
517a32b0c8SAndre Fischer OSL_ASSERT(pParentWindow != NULL);
527a32b0c8SAndre Fischer
537a32b0c8SAndre Fischer if (maCloserAction)
54abdd804dSAndre Fischer SetCloserVisible(true);
557a32b0c8SAndre Fischer
567a32b0c8SAndre Fischer #ifdef DEBUG
577a32b0c8SAndre Fischer SetText(A2S("DeckTitleBar"));
587a32b0c8SAndre Fischer #endif
59ff12d537SAndre Fischer }
60ff12d537SAndre Fischer
61ff12d537SAndre Fischer
62ff12d537SAndre Fischer
63ff12d537SAndre Fischer
~DeckTitleBar(void)64ff12d537SAndre Fischer DeckTitleBar::~DeckTitleBar (void)
65ff12d537SAndre Fischer {
66ff12d537SAndre Fischer }
67ff12d537SAndre Fischer
68ff12d537SAndre Fischer
69ff12d537SAndre Fischer
70ff12d537SAndre Fischer
SetCloserVisible(const bool bIsCloserVisible)717a32b0c8SAndre Fischer void DeckTitleBar::SetCloserVisible (const bool bIsCloserVisible)
727a32b0c8SAndre Fischer {
737a32b0c8SAndre Fischer if (mbIsCloserVisible != bIsCloserVisible)
747a32b0c8SAndre Fischer {
757a32b0c8SAndre Fischer mbIsCloserVisible = bIsCloserVisible;
767a32b0c8SAndre Fischer
777a32b0c8SAndre Fischer if (mbIsCloserVisible)
78abdd804dSAndre Fischer {
797a32b0c8SAndre Fischer maToolBox.InsertItem(
807a32b0c8SAndre Fischer mnCloserItemIndex,
817a32b0c8SAndre Fischer Theme::GetImage(Theme::Image_Closer));
82abdd804dSAndre Fischer maToolBox.SetQuickHelpText(
83abdd804dSAndre Fischer mnCloserItemIndex,
84abdd804dSAndre Fischer String(SfxResId(SFX_STR_SIDEBAR_CLOSE_DECK)));
85abdd804dSAndre Fischer }
867a32b0c8SAndre Fischer else
877a32b0c8SAndre Fischer maToolBox.RemoveItem(
887a32b0c8SAndre Fischer maToolBox.GetItemPos(mnCloserItemIndex));
897a32b0c8SAndre Fischer }
907a32b0c8SAndre Fischer }
917a32b0c8SAndre Fischer
927a32b0c8SAndre Fischer
937a32b0c8SAndre Fischer
947a32b0c8SAndre Fischer
GetTitleArea(const Rectangle & rTitleBarBox)95ff12d537SAndre Fischer Rectangle DeckTitleBar::GetTitleArea (const Rectangle& rTitleBarBox)
96ff12d537SAndre Fischer {
97b9e67834SAndre Fischer Image aGripImage (Theme::GetImage(Theme::Image_Grip));
98ff12d537SAndre Fischer return Rectangle(
99ff12d537SAndre Fischer aGripImage.GetSizePixel().Width() + gaLeftGripPadding + gaRightGripPadding,
100ff12d537SAndre Fischer rTitleBarBox.Top(),
101ff12d537SAndre Fischer rTitleBarBox.Right(),
102ff12d537SAndre Fischer rTitleBarBox.Bottom());
103ff12d537SAndre Fischer }
104ff12d537SAndre Fischer
105ff12d537SAndre Fischer
106ff12d537SAndre Fischer
107ff12d537SAndre Fischer
PaintDecoration(const Rectangle & rTitleBarBox)108ff12d537SAndre Fischer void DeckTitleBar::PaintDecoration (const Rectangle& rTitleBarBox)
109ff12d537SAndre Fischer {
110b9e67834SAndre Fischer (void)rTitleBarBox;
111ff12d537SAndre Fischer }
112ff12d537SAndre Fischer
113ff12d537SAndre Fischer
114ff12d537SAndre Fischer
115ff12d537SAndre Fischer
GetBackgroundPaint(void)116ff12d537SAndre Fischer sidebar::Paint DeckTitleBar::GetBackgroundPaint (void)
117ff12d537SAndre Fischer {
118b9e67834SAndre Fischer return Theme::GetPaint(Theme::Paint_DeckTitleBarBackground);
119ff12d537SAndre Fischer }
120ff12d537SAndre Fischer
121ff12d537SAndre Fischer
122ff12d537SAndre Fischer
123ff12d537SAndre Fischer
GetTextColor(void)124ff12d537SAndre Fischer Color DeckTitleBar::GetTextColor (void)
125ff12d537SAndre Fischer {
126b9e67834SAndre Fischer return Theme::GetColor(Theme::Color_DeckTitleFont);
127ff12d537SAndre Fischer }
128ff12d537SAndre Fischer
129ff12d537SAndre Fischer
1307a32b0c8SAndre Fischer
1317a32b0c8SAndre Fischer
HandleToolBoxItemClick(const sal_uInt16 nItemIndex)1327a32b0c8SAndre Fischer void DeckTitleBar::HandleToolBoxItemClick (const sal_uInt16 nItemIndex)
1337a32b0c8SAndre Fischer {
1347a32b0c8SAndre Fischer if (nItemIndex == mnCloserItemIndex)
1357a32b0c8SAndre Fischer if (maCloserAction)
1367a32b0c8SAndre Fischer maCloserAction();
1377a32b0c8SAndre Fischer }
1387a32b0c8SAndre Fischer
1397a32b0c8SAndre Fischer
1407a32b0c8SAndre Fischer
1417a32b0c8SAndre Fischer
CreateAccessible(void)142*3b2c5b9dSAndre Fischer cssu::Reference<css::accessibility::XAccessible> DeckTitleBar::CreateAccessible (void)
143*3b2c5b9dSAndre Fischer {
144*3b2c5b9dSAndre Fischer const ::rtl::OUString sAccessibleName(msTitle);
145*3b2c5b9dSAndre Fischer SetAccessibleName(sAccessibleName);
146*3b2c5b9dSAndre Fischer SetAccessibleDescription(sAccessibleName);
147*3b2c5b9dSAndre Fischer return TitleBar::CreateAccessible();
148*3b2c5b9dSAndre Fischer }
149*3b2c5b9dSAndre Fischer
150*3b2c5b9dSAndre Fischer
151*3b2c5b9dSAndre Fischer
152*3b2c5b9dSAndre Fischer
DataChanged(const DataChangedEvent & rEvent)1537a32b0c8SAndre Fischer void DeckTitleBar::DataChanged (const DataChangedEvent& rEvent)
1547a32b0c8SAndre Fischer {
1557a32b0c8SAndre Fischer maToolBox.SetItemImage(
1567a32b0c8SAndre Fischer mnCloserItemIndex,
1577a32b0c8SAndre Fischer Theme::GetImage(Theme::Image_Closer));
158580828edSAndre Fischer TitleBar::DataChanged(rEvent);
1597a32b0c8SAndre Fischer }
1607a32b0c8SAndre Fischer
1617a32b0c8SAndre Fischer
162ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar
163