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" 25*95a18594SAndre Fischer #include "ToolBoxBackground.hxx" 26*95a18594SAndre Fischer #include "sfx2/sidebar/Theme.hxx" 27b9e67834SAndre Fischer 28b9e67834SAndre Fischer #include <vcl/gradient.hxx> 29b9e67834SAndre Fischer 30*95a18594SAndre Fischer 31b9e67834SAndre Fischer using namespace ::com::sun::star; 32b9e67834SAndre Fischer using namespace ::com::sun::star::uno; 33b9e67834SAndre Fischer 34b9e67834SAndre Fischer 35b9e67834SAndre Fischer namespace sfx2 { namespace sidebar { 36b9e67834SAndre Fischer 37b9e67834SAndre Fischer 38b9e67834SAndre Fischer SidebarToolBox::SidebarToolBox ( 39b9e67834SAndre Fischer Window* pParentWindow, 40b9e67834SAndre Fischer const ResId& rResId) 41*95a18594SAndre Fischer : ToolBox(pParentWindow, rResId), 42*95a18594SAndre Fischer mbParentIsBorder(false), 43*95a18594SAndre Fischer maItemSeparator(Theme::GetImage(Theme::Image_ToolBoxItemSeparator)) 44b9e67834SAndre Fischer { 45*95a18594SAndre Fischer SetBackground(Wallpaper()); 46*95a18594SAndre Fischer SetPaintTransparent(true); 47b9e67834SAndre Fischer } 48b9e67834SAndre Fischer 49b9e67834SAndre Fischer 50b9e67834SAndre Fischer 51b9e67834SAndre Fischer 52b9e67834SAndre Fischer SidebarToolBox::~SidebarToolBox (void) 53b9e67834SAndre Fischer { 54b9e67834SAndre Fischer } 55b9e67834SAndre Fischer 56b9e67834SAndre Fischer 57b9e67834SAndre Fischer 58b9e67834SAndre Fischer 59*95a18594SAndre Fischer void SidebarToolBox::SetBorderWindow (const Window* pBorderWindow) 60b9e67834SAndre Fischer { 61*95a18594SAndre Fischer if (pBorderWindow != GetParent()) 62*95a18594SAndre Fischer { 63*95a18594SAndre Fischer OSL_ASSERT("SetBorderWindow can only handle parent as border window"); 64*95a18594SAndre Fischer return; 65*95a18594SAndre Fischer } 66b9e67834SAndre Fischer 67*95a18594SAndre Fischer if ( ! mbParentIsBorder) 68b9e67834SAndre Fischer { 69*95a18594SAndre Fischer mbParentIsBorder = true; 70*95a18594SAndre Fischer 71*95a18594SAndre Fischer SetPosSizePixel ( 72*95a18594SAndre Fischer GetPosPixel().X(), 73*95a18594SAndre Fischer GetPosPixel().Y(), 74*95a18594SAndre Fischer GetSizePixel().Width(), 75*95a18594SAndre Fischer GetSizePixel().Height(), 76*95a18594SAndre Fischer WINDOW_POSSIZE_ALL); 77b9e67834SAndre Fischer } 78*95a18594SAndre Fischer } 79*95a18594SAndre Fischer 80*95a18594SAndre Fischer 81*95a18594SAndre Fischer 82b9e67834SAndre Fischer 83*95a18594SAndre Fischer void SidebarToolBox::Paint (const Rectangle& rRect) 84*95a18594SAndre Fischer { 85b9e67834SAndre Fischer ToolBox::Paint(rRect); 86*95a18594SAndre Fischer 87*95a18594SAndre Fischer OSL_TRACE("paint ToolBox at %d,%d", 88*95a18594SAndre Fischer GetPosPixel().X(), 89*95a18594SAndre Fischer GetPosPixel().Y()); 90*95a18594SAndre Fischer 91*95a18594SAndre Fischer if (Theme::GetBoolean(Theme::Bool_UseToolBoxItemSeparator)) 92*95a18594SAndre Fischer { 93*95a18594SAndre Fischer const sal_Int32 nSeparatorY ((GetSizePixel().Height() - maItemSeparator.GetSizePixel().Height())/2); 94*95a18594SAndre Fischer const sal_uInt16 nItemCount (GetItemCount()); 95*95a18594SAndre Fischer int nLastRight (-1); 96*95a18594SAndre Fischer for (sal_uInt16 nIndex=0; nIndex<nItemCount; ++nIndex) 97*95a18594SAndre Fischer { 98*95a18594SAndre Fischer const Rectangle aItemBoundingBox (GetItemPosRect(nIndex)); 99*95a18594SAndre Fischer if (nLastRight >= 0) 100*95a18594SAndre Fischer { 101*95a18594SAndre Fischer const int nSeparatorX ((nLastRight + aItemBoundingBox.Left() - 1) / 2); 102*95a18594SAndre Fischer DrawImage(Point(nSeparatorX,nSeparatorY), maItemSeparator); 103*95a18594SAndre Fischer } 104*95a18594SAndre Fischer 105*95a18594SAndre Fischer nLastRight = aItemBoundingBox.Right(); 106*95a18594SAndre Fischer } 107*95a18594SAndre Fischer } 108b9e67834SAndre Fischer } 109b9e67834SAndre Fischer 110*95a18594SAndre Fischer 111*95a18594SAndre Fischer 112*95a18594SAndre Fischer 113*95a18594SAndre Fischer Point SidebarToolBox::GetPosPixel (void) const 114*95a18594SAndre Fischer { 115*95a18594SAndre Fischer if (mbParentIsBorder) 116*95a18594SAndre Fischer { 117*95a18594SAndre Fischer const Point aParentPoint (GetParent()->GetPosPixel()); 118*95a18594SAndre Fischer const Point aChildPoint (ToolBox::GetPosPixel()); 119*95a18594SAndre Fischer return Point( 120*95a18594SAndre Fischer aParentPoint.X() + aChildPoint.X(), 121*95a18594SAndre Fischer aParentPoint.Y() + aChildPoint.Y()); 122*95a18594SAndre Fischer } 123*95a18594SAndre Fischer else 124*95a18594SAndre Fischer return ToolBox::GetPosPixel(); 125*95a18594SAndre Fischer } 126*95a18594SAndre Fischer 127*95a18594SAndre Fischer 128*95a18594SAndre Fischer 129*95a18594SAndre Fischer 130*95a18594SAndre Fischer void SidebarToolBox::SetPosSizePixel ( 131*95a18594SAndre Fischer long nX, 132*95a18594SAndre Fischer long nY, 133*95a18594SAndre Fischer long nWidth, 134*95a18594SAndre Fischer long nHeight, 135*95a18594SAndre Fischer sal_uInt16 nFlags) 136*95a18594SAndre Fischer { 137*95a18594SAndre Fischer if (mbParentIsBorder) 138*95a18594SAndre Fischer { 139*95a18594SAndre Fischer const Point aRelativePosition (static_cast<ToolBoxBackground*>(GetParent())->SetToolBoxChild( 140*95a18594SAndre Fischer this, 141*95a18594SAndre Fischer nX, 142*95a18594SAndre Fischer nY, 143*95a18594SAndre Fischer nWidth, 144*95a18594SAndre Fischer nHeight, 145*95a18594SAndre Fischer nFlags)); 146*95a18594SAndre Fischer ToolBox::SetPosSizePixel( 147*95a18594SAndre Fischer aRelativePosition.X(), 148*95a18594SAndre Fischer aRelativePosition.Y(), 149*95a18594SAndre Fischer nWidth, 150*95a18594SAndre Fischer nHeight, 151*95a18594SAndre Fischer nFlags); 152*95a18594SAndre Fischer } 153*95a18594SAndre Fischer else 154*95a18594SAndre Fischer ToolBox::SetPosSizePixel(nX, nY, nWidth, nHeight, nFlags); 155*95a18594SAndre Fischer } 156*95a18594SAndre Fischer 157*95a18594SAndre Fischer 158*95a18594SAndre Fischer 159b9e67834SAndre Fischer } } // end of namespace sfx2::sidebar 160