1b9e67834SAndre Fischer /************************************************************** 2b9e67834SAndre Fischer * 3b9e67834SAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 4b9e67834SAndre Fischer * or more contributor license agreements. See the NOTICE file 5b9e67834SAndre Fischer * distributed with this work for additional information 6b9e67834SAndre Fischer * regarding copyright ownership. The ASF licenses this file 7b9e67834SAndre Fischer * to you under the Apache License, Version 2.0 (the 8b9e67834SAndre Fischer * "License"); you may not use this file except in compliance 9b9e67834SAndre Fischer * with the License. You may obtain a copy of the License at 10b9e67834SAndre Fischer * 11b9e67834SAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 12b9e67834SAndre Fischer * 13b9e67834SAndre Fischer * Unless required by applicable law or agreed to in writing, 14b9e67834SAndre Fischer * software distributed under the License is distributed on an 15b9e67834SAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16b9e67834SAndre Fischer * KIND, either express or implied. See the License for the 17b9e67834SAndre Fischer * specific language governing permissions and limitations 18b9e67834SAndre Fischer * under the License. 19b9e67834SAndre Fischer * 20b9e67834SAndre Fischer *************************************************************/ 21b9e67834SAndre Fischer 22b9e67834SAndre Fischer #include "precompiled_sfx2.hxx" 23b9e67834SAndre Fischer 24b9e67834SAndre Fischer #include "SidebarToolBox.hxx" 2595a18594SAndre Fischer #include "ToolBoxBackground.hxx" 2695a18594SAndre Fischer #include "sfx2/sidebar/Theme.hxx" 27*7a32b0c8SAndre Fischer #include "Tools.hxx" 28b9e67834SAndre Fischer 29b9e67834SAndre Fischer #include <vcl/gradient.hxx> 30b9e67834SAndre Fischer 3195a18594SAndre Fischer 32b9e67834SAndre Fischer using namespace ::com::sun::star; 33b9e67834SAndre Fischer using namespace ::com::sun::star::uno; 34b9e67834SAndre Fischer 35b9e67834SAndre Fischer 36b9e67834SAndre Fischer namespace sfx2 { namespace sidebar { 37b9e67834SAndre Fischer 38b9e67834SAndre Fischer 39b9e67834SAndre Fischer SidebarToolBox::SidebarToolBox ( 40b9e67834SAndre Fischer Window* pParentWindow, 41b9e67834SAndre Fischer const ResId& rResId) 4295a18594SAndre Fischer : ToolBox(pParentWindow, rResId), 4395a18594SAndre Fischer mbParentIsBorder(false), 4495a18594SAndre Fischer maItemSeparator(Theme::GetImage(Theme::Image_ToolBoxItemSeparator)) 45b9e67834SAndre Fischer { 4695a18594SAndre Fischer SetBackground(Wallpaper()); 4795a18594SAndre Fischer SetPaintTransparent(true); 48*7a32b0c8SAndre Fischer #ifdef DEBUG 49*7a32b0c8SAndre Fischer SetText(A2S("SidebarToolBox")); 50*7a32b0c8SAndre Fischer #endif 51b9e67834SAndre Fischer } 52b9e67834SAndre Fischer 53b9e67834SAndre Fischer 54b9e67834SAndre Fischer 55b9e67834SAndre Fischer 56b9e67834SAndre Fischer SidebarToolBox::~SidebarToolBox (void) 57b9e67834SAndre Fischer { 58b9e67834SAndre Fischer } 59b9e67834SAndre Fischer 60b9e67834SAndre Fischer 61b9e67834SAndre Fischer 62b9e67834SAndre Fischer 6395a18594SAndre Fischer void SidebarToolBox::SetBorderWindow (const Window* pBorderWindow) 64b9e67834SAndre Fischer { 6595a18594SAndre Fischer if (pBorderWindow != GetParent()) 6695a18594SAndre Fischer { 6795a18594SAndre Fischer OSL_ASSERT("SetBorderWindow can only handle parent as border window"); 6895a18594SAndre Fischer return; 6995a18594SAndre Fischer } 70b9e67834SAndre Fischer 7195a18594SAndre Fischer if ( ! mbParentIsBorder) 72b9e67834SAndre Fischer { 7395a18594SAndre Fischer mbParentIsBorder = true; 7495a18594SAndre Fischer 7595a18594SAndre Fischer SetPosSizePixel ( 7695a18594SAndre Fischer GetPosPixel().X(), 7795a18594SAndre Fischer GetPosPixel().Y(), 7895a18594SAndre Fischer GetSizePixel().Width(), 7995a18594SAndre Fischer GetSizePixel().Height(), 8095a18594SAndre Fischer WINDOW_POSSIZE_ALL); 81b9e67834SAndre Fischer } 8295a18594SAndre Fischer } 8395a18594SAndre Fischer 8495a18594SAndre Fischer 8595a18594SAndre Fischer 86b9e67834SAndre Fischer 8795a18594SAndre Fischer void SidebarToolBox::Paint (const Rectangle& rRect) 8895a18594SAndre Fischer { 89b9e67834SAndre Fischer ToolBox::Paint(rRect); 9095a18594SAndre Fischer 9195a18594SAndre Fischer OSL_TRACE("paint ToolBox at %d,%d", 9295a18594SAndre Fischer GetPosPixel().X(), 9395a18594SAndre Fischer GetPosPixel().Y()); 9495a18594SAndre Fischer 9595a18594SAndre Fischer if (Theme::GetBoolean(Theme::Bool_UseToolBoxItemSeparator)) 9695a18594SAndre Fischer { 9795a18594SAndre Fischer const sal_Int32 nSeparatorY ((GetSizePixel().Height() - maItemSeparator.GetSizePixel().Height())/2); 9895a18594SAndre Fischer const sal_uInt16 nItemCount (GetItemCount()); 9995a18594SAndre Fischer int nLastRight (-1); 10095a18594SAndre Fischer for (sal_uInt16 nIndex=0; nIndex<nItemCount; ++nIndex) 10195a18594SAndre Fischer { 10295a18594SAndre Fischer const Rectangle aItemBoundingBox (GetItemPosRect(nIndex)); 10395a18594SAndre Fischer if (nLastRight >= 0) 10495a18594SAndre Fischer { 10595a18594SAndre Fischer const int nSeparatorX ((nLastRight + aItemBoundingBox.Left() - 1) / 2); 10695a18594SAndre Fischer DrawImage(Point(nSeparatorX,nSeparatorY), maItemSeparator); 10795a18594SAndre Fischer } 10895a18594SAndre Fischer 10995a18594SAndre Fischer nLastRight = aItemBoundingBox.Right(); 11095a18594SAndre Fischer } 11195a18594SAndre Fischer } 112b9e67834SAndre Fischer } 113b9e67834SAndre Fischer 11495a18594SAndre Fischer 11595a18594SAndre Fischer 11695a18594SAndre Fischer 11795a18594SAndre Fischer Point SidebarToolBox::GetPosPixel (void) const 11895a18594SAndre Fischer { 11995a18594SAndre Fischer if (mbParentIsBorder) 12095a18594SAndre Fischer { 12195a18594SAndre Fischer const Point aParentPoint (GetParent()->GetPosPixel()); 12295a18594SAndre Fischer const Point aChildPoint (ToolBox::GetPosPixel()); 12395a18594SAndre Fischer return Point( 12495a18594SAndre Fischer aParentPoint.X() + aChildPoint.X(), 12595a18594SAndre Fischer aParentPoint.Y() + aChildPoint.Y()); 12695a18594SAndre Fischer } 12795a18594SAndre Fischer else 12895a18594SAndre Fischer return ToolBox::GetPosPixel(); 12995a18594SAndre Fischer } 13095a18594SAndre Fischer 13195a18594SAndre Fischer 13295a18594SAndre Fischer 13395a18594SAndre Fischer 13495a18594SAndre Fischer void SidebarToolBox::SetPosSizePixel ( 13595a18594SAndre Fischer long nX, 13695a18594SAndre Fischer long nY, 13795a18594SAndre Fischer long nWidth, 13895a18594SAndre Fischer long nHeight, 13995a18594SAndre Fischer sal_uInt16 nFlags) 14095a18594SAndre Fischer { 14195a18594SAndre Fischer if (mbParentIsBorder) 14295a18594SAndre Fischer { 14395a18594SAndre Fischer const Point aRelativePosition (static_cast<ToolBoxBackground*>(GetParent())->SetToolBoxChild( 14495a18594SAndre Fischer this, 14595a18594SAndre Fischer nX, 14695a18594SAndre Fischer nY, 14795a18594SAndre Fischer nWidth, 14895a18594SAndre Fischer nHeight, 14995a18594SAndre Fischer nFlags)); 15095a18594SAndre Fischer ToolBox::SetPosSizePixel( 15195a18594SAndre Fischer aRelativePosition.X(), 15295a18594SAndre Fischer aRelativePosition.Y(), 15395a18594SAndre Fischer nWidth, 15495a18594SAndre Fischer nHeight, 15595a18594SAndre Fischer nFlags); 15695a18594SAndre Fischer } 15795a18594SAndre Fischer else 15895a18594SAndre Fischer ToolBox::SetPosSizePixel(nX, nY, nWidth, nHeight, nFlags); 15995a18594SAndre Fischer } 16095a18594SAndre Fischer 16195a18594SAndre Fischer 16295a18594SAndre Fischer 163b9e67834SAndre Fischer } } // end of namespace sfx2::sidebar 164