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 "DeckTitleBar.hxx" 25 #include "sfx2/sidebar/Theme.hxx" 26 #include "sfx2/sfxresid.hxx" 27 #include "Sidebar.hrc" 28 29 #include <vcl/image.hxx> 30 31 #ifdef DEBUG 32 #include "sfx2/sidebar/Tools.hxx" 33 #endif 34 35 namespace sfx2 { namespace sidebar { 36 37 static const sal_Int32 gaLeftGripPadding (3); 38 static const sal_Int32 gaRightGripPadding (4); 39 40 41 DeckTitleBar::DeckTitleBar ( 42 const ::rtl::OUString& rsTitle, 43 Window* pParentWindow, 44 const ::boost::function<void(void)>& rCloserAction) 45 : TitleBar(rsTitle, pParentWindow, GetBackgroundPaint()), 46 mnCloserItemIndex(1), 47 maCloserAction(rCloserAction), 48 mbIsCloserVisible(false) 49 { 50 OSL_ASSERT(pParentWindow != NULL); 51 52 if (maCloserAction) 53 SetCloserVisible(true); 54 55 #ifdef DEBUG 56 SetText(A2S("DeckTitleBar")); 57 #endif 58 } 59 60 DeckTitleBar::~DeckTitleBar (void) 61 { 62 } 63 64 void DeckTitleBar::SetCloserVisible (const bool bIsCloserVisible) 65 { 66 if (mbIsCloserVisible != bIsCloserVisible) 67 { 68 mbIsCloserVisible = bIsCloserVisible; 69 70 if (mbIsCloserVisible) 71 { 72 maToolBox.InsertItem( 73 mnCloserItemIndex, 74 Theme::GetImage(Theme::Image_Closer)); 75 maToolBox.SetQuickHelpText( 76 mnCloserItemIndex, 77 String(SfxResId(SFX_STR_SIDEBAR_CLOSE_DECK))); 78 } 79 else 80 maToolBox.RemoveItem( 81 maToolBox.GetItemPos(mnCloserItemIndex)); 82 } 83 } 84 85 Rectangle DeckTitleBar::GetTitleArea (const Rectangle& rTitleBarBox) 86 { 87 Image aGripImage (Theme::GetImage(Theme::Image_Grip)); 88 return Rectangle( 89 aGripImage.GetSizePixel().Width() + gaLeftGripPadding + gaRightGripPadding, 90 rTitleBarBox.Top(), 91 rTitleBarBox.Right(), 92 rTitleBarBox.Bottom()); 93 } 94 95 void DeckTitleBar::PaintDecoration (const Rectangle& rTitleBarBox) 96 { 97 (void)rTitleBarBox; 98 } 99 100 sidebar::Paint DeckTitleBar::GetBackgroundPaint (void) 101 { 102 return Theme::GetPaint(Theme::Paint_DeckTitleBarBackground); 103 } 104 105 Color DeckTitleBar::GetTextColor (void) 106 { 107 return Theme::GetColor(Theme::Color_DeckTitleFont); 108 } 109 110 void DeckTitleBar::HandleToolBoxItemClick (const sal_uInt16 nItemIndex) 111 { 112 if (nItemIndex == mnCloserItemIndex) 113 if (maCloserAction) 114 maCloserAction(); 115 } 116 117 cssu::Reference<css::accessibility::XAccessible> DeckTitleBar::CreateAccessible (void) 118 { 119 const ::rtl::OUString sAccessibleName(msTitle); 120 SetAccessibleName(sAccessibleName); 121 SetAccessibleDescription(sAccessibleName); 122 return TitleBar::CreateAccessible(); 123 } 124 125 void DeckTitleBar::DataChanged (const DataChangedEvent& rEvent) 126 { 127 maToolBox.SetItemImage( 128 mnCloserItemIndex, 129 Theme::GetImage(Theme::Image_Closer)); 130 TitleBar::DataChanged(rEvent); 131 } 132 133 } } // end of namespace sfx2::sidebar 134 135 /* vim: set noet sw=4 ts=4: */ 136