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 297a32b0c8SAndre Fischer #ifdef DEBUG 307a32b0c8SAndre Fischer #include "Tools.hxx" 317a32b0c8SAndre Fischer #endif 327a32b0c8SAndre 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, 427a32b0c8SAndre Fischer Window* pParentWindow, 437a32b0c8SAndre Fischer const ::boost::function<void(void)>& rCloserAction) 447a32b0c8SAndre Fischer : TitleBar(rsTitle, pParentWindow, GetBackgroundPaint()), 457a32b0c8SAndre Fischer mnCloserItemIndex(1), 467a32b0c8SAndre Fischer maCloserAction(rCloserAction), 477a32b0c8SAndre Fischer mbIsCloserVisible(rCloserAction) 48ff12d537SAndre Fischer { 497a32b0c8SAndre Fischer OSL_ASSERT(pParentWindow != NULL); 507a32b0c8SAndre Fischer 517a32b0c8SAndre Fischer if (maCloserAction) 527a32b0c8SAndre Fischer { 537a32b0c8SAndre Fischer maToolBox.InsertItem( 547a32b0c8SAndre Fischer mnCloserItemIndex, 557a32b0c8SAndre Fischer Theme::GetImage(Theme::Image_Closer)); 567a32b0c8SAndre Fischer } 577a32b0c8SAndre Fischer 587a32b0c8SAndre Fischer #ifdef DEBUG 597a32b0c8SAndre Fischer SetText(A2S("DeckTitleBar")); 607a32b0c8SAndre 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 737a32b0c8SAndre Fischer void DeckTitleBar::SetCloserVisible (const bool bIsCloserVisible) 747a32b0c8SAndre Fischer { 757a32b0c8SAndre Fischer if (mbIsCloserVisible != bIsCloserVisible) 767a32b0c8SAndre Fischer { 777a32b0c8SAndre Fischer mbIsCloserVisible = bIsCloserVisible; 787a32b0c8SAndre Fischer 797a32b0c8SAndre Fischer if (mbIsCloserVisible) 807a32b0c8SAndre Fischer maToolBox.InsertItem( 817a32b0c8SAndre Fischer mnCloserItemIndex, 827a32b0c8SAndre Fischer Theme::GetImage(Theme::Image_Closer)); 837a32b0c8SAndre Fischer else 847a32b0c8SAndre Fischer maToolBox.RemoveItem( 857a32b0c8SAndre Fischer maToolBox.GetItemPos(mnCloserItemIndex)); 867a32b0c8SAndre Fischer } 877a32b0c8SAndre Fischer } 887a32b0c8SAndre Fischer 897a32b0c8SAndre Fischer 907a32b0c8SAndre Fischer 917a32b0c8SAndre 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; 10895a18594SAndre 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 1347a32b0c8SAndre Fischer 1357a32b0c8SAndre Fischer 1367a32b0c8SAndre Fischer void DeckTitleBar::HandleToolBoxItemClick (const sal_uInt16 nItemIndex) 1377a32b0c8SAndre Fischer { 1387a32b0c8SAndre Fischer if (nItemIndex == mnCloserItemIndex) 1397a32b0c8SAndre Fischer if (maCloserAction) 1407a32b0c8SAndre Fischer maCloserAction(); 1417a32b0c8SAndre Fischer } 1427a32b0c8SAndre Fischer 1437a32b0c8SAndre Fischer 1447a32b0c8SAndre Fischer 1457a32b0c8SAndre Fischer 1467a32b0c8SAndre Fischer void DeckTitleBar::DataChanged (const DataChangedEvent& rEvent) 1477a32b0c8SAndre Fischer { 1487a32b0c8SAndre Fischer maToolBox.SetItemImage( 1497a32b0c8SAndre Fischer mnCloserItemIndex, 1507a32b0c8SAndre Fischer Theme::GetImage(Theme::Image_Closer)); 151*580828edSAndre Fischer TitleBar::DataChanged(rEvent); 1527a32b0c8SAndre Fischer } 1537a32b0c8SAndre Fischer 1547a32b0c8SAndre Fischer 155ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 156