xref: /trunk/main/sfx2/source/sidebar/DeckTitleBar.cxx (revision 549760eabef7046a021eb562805aa3542b2e9b62)
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 
35ff12d537SAndre Fischer namespace sfx2 { namespace sidebar {
36ff12d537SAndre Fischer 
37ff12d537SAndre Fischer static const sal_Int32 gaLeftGripPadding (3);
38*549760eaSmseidel static const sal_Int32 gaRightGripPadding (4);
39ff12d537SAndre Fischer 
40ff12d537SAndre Fischer 
DeckTitleBar(const::rtl::OUString & rsTitle,Window * pParentWindow,const::boost::function<void (void)> & rCloserAction)41ff12d537SAndre Fischer DeckTitleBar::DeckTitleBar (
42ff12d537SAndre Fischer     const ::rtl::OUString& rsTitle,
437a32b0c8SAndre Fischer     Window* pParentWindow,
447a32b0c8SAndre Fischer     const ::boost::function<void(void)>& rCloserAction)
457a32b0c8SAndre Fischer     : TitleBar(rsTitle, pParentWindow, GetBackgroundPaint()),
467a32b0c8SAndre Fischer       mnCloserItemIndex(1),
477a32b0c8SAndre Fischer       maCloserAction(rCloserAction),
48abdd804dSAndre Fischer       mbIsCloserVisible(false)
49ff12d537SAndre Fischer {
507a32b0c8SAndre Fischer     OSL_ASSERT(pParentWindow != NULL);
517a32b0c8SAndre Fischer 
527a32b0c8SAndre Fischer     if (maCloserAction)
53abdd804dSAndre Fischer         SetCloserVisible(true);
547a32b0c8SAndre Fischer 
557a32b0c8SAndre Fischer #ifdef DEBUG
567a32b0c8SAndre Fischer     SetText(A2S("DeckTitleBar"));
577a32b0c8SAndre Fischer #endif
58ff12d537SAndre Fischer }
59ff12d537SAndre Fischer 
~DeckTitleBar(void)60ff12d537SAndre Fischer DeckTitleBar::~DeckTitleBar (void)
61ff12d537SAndre Fischer {
62ff12d537SAndre Fischer }
63ff12d537SAndre Fischer 
SetCloserVisible(const bool bIsCloserVisible)647a32b0c8SAndre Fischer void DeckTitleBar::SetCloserVisible (const bool bIsCloserVisible)
657a32b0c8SAndre Fischer {
667a32b0c8SAndre Fischer     if (mbIsCloserVisible != bIsCloserVisible)
677a32b0c8SAndre Fischer     {
687a32b0c8SAndre Fischer         mbIsCloserVisible = bIsCloserVisible;
697a32b0c8SAndre Fischer 
707a32b0c8SAndre Fischer         if (mbIsCloserVisible)
71abdd804dSAndre Fischer         {
727a32b0c8SAndre Fischer             maToolBox.InsertItem(
737a32b0c8SAndre Fischer                 mnCloserItemIndex,
747a32b0c8SAndre Fischer                 Theme::GetImage(Theme::Image_Closer));
75abdd804dSAndre Fischer             maToolBox.SetQuickHelpText(
76abdd804dSAndre Fischer                 mnCloserItemIndex,
77abdd804dSAndre Fischer                 String(SfxResId(SFX_STR_SIDEBAR_CLOSE_DECK)));
78abdd804dSAndre Fischer         }
797a32b0c8SAndre Fischer         else
807a32b0c8SAndre Fischer             maToolBox.RemoveItem(
817a32b0c8SAndre Fischer                 maToolBox.GetItemPos(mnCloserItemIndex));
827a32b0c8SAndre Fischer     }
837a32b0c8SAndre Fischer }
847a32b0c8SAndre Fischer 
GetTitleArea(const Rectangle & rTitleBarBox)85ff12d537SAndre Fischer Rectangle DeckTitleBar::GetTitleArea (const Rectangle& rTitleBarBox)
86ff12d537SAndre Fischer {
87b9e67834SAndre Fischer     Image aGripImage (Theme::GetImage(Theme::Image_Grip));
88ff12d537SAndre Fischer     return Rectangle(
89ff12d537SAndre Fischer         aGripImage.GetSizePixel().Width() + gaLeftGripPadding + gaRightGripPadding,
90ff12d537SAndre Fischer         rTitleBarBox.Top(),
91ff12d537SAndre Fischer         rTitleBarBox.Right(),
92ff12d537SAndre Fischer         rTitleBarBox.Bottom());
93ff12d537SAndre Fischer }
94ff12d537SAndre Fischer 
PaintDecoration(const Rectangle & rTitleBarBox)95ff12d537SAndre Fischer void DeckTitleBar::PaintDecoration (const Rectangle& rTitleBarBox)
96ff12d537SAndre Fischer {
97b9e67834SAndre Fischer     (void)rTitleBarBox;
98ff12d537SAndre Fischer }
99ff12d537SAndre Fischer 
GetBackgroundPaint(void)100ff12d537SAndre Fischer sidebar::Paint DeckTitleBar::GetBackgroundPaint (void)
101ff12d537SAndre Fischer {
102b9e67834SAndre Fischer     return Theme::GetPaint(Theme::Paint_DeckTitleBarBackground);
103ff12d537SAndre Fischer }
104ff12d537SAndre Fischer 
GetTextColor(void)105ff12d537SAndre Fischer Color DeckTitleBar::GetTextColor (void)
106ff12d537SAndre Fischer {
107b9e67834SAndre Fischer     return Theme::GetColor(Theme::Color_DeckTitleFont);
108ff12d537SAndre Fischer }
109ff12d537SAndre Fischer 
HandleToolBoxItemClick(const sal_uInt16 nItemIndex)1107a32b0c8SAndre Fischer void DeckTitleBar::HandleToolBoxItemClick (const sal_uInt16 nItemIndex)
1117a32b0c8SAndre Fischer {
1127a32b0c8SAndre Fischer     if (nItemIndex == mnCloserItemIndex)
1137a32b0c8SAndre Fischer         if (maCloserAction)
1147a32b0c8SAndre Fischer             maCloserAction();
1157a32b0c8SAndre Fischer }
1167a32b0c8SAndre Fischer 
CreateAccessible(void)1173b2c5b9dSAndre Fischer cssu::Reference<css::accessibility::XAccessible> DeckTitleBar::CreateAccessible (void)
1183b2c5b9dSAndre Fischer {
1193b2c5b9dSAndre Fischer     const ::rtl::OUString sAccessibleName(msTitle);
1203b2c5b9dSAndre Fischer     SetAccessibleName(sAccessibleName);
1213b2c5b9dSAndre Fischer     SetAccessibleDescription(sAccessibleName);
1223b2c5b9dSAndre Fischer     return TitleBar::CreateAccessible();
1233b2c5b9dSAndre Fischer }
1243b2c5b9dSAndre Fischer 
DataChanged(const DataChangedEvent & rEvent)1257a32b0c8SAndre Fischer void DeckTitleBar::DataChanged (const DataChangedEvent& rEvent)
1267a32b0c8SAndre Fischer {
1277a32b0c8SAndre Fischer     maToolBox.SetItemImage(
1287a32b0c8SAndre Fischer         mnCloserItemIndex,
1297a32b0c8SAndre Fischer         Theme::GetImage(Theme::Image_Closer));
130580828edSAndre Fischer     TitleBar::DataChanged(rEvent);
1317a32b0c8SAndre Fischer }
1327a32b0c8SAndre Fischer 
133ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar
134*549760eaSmseidel 
135*549760eaSmseidel /* vim: set noet sw=4 ts=4: */
136