1*95a18594SAndre Fischer /************************************************************** 2*95a18594SAndre Fischer * 3*95a18594SAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 4*95a18594SAndre Fischer * or more contributor license agreements. See the NOTICE file 5*95a18594SAndre Fischer * distributed with this work for additional information 6*95a18594SAndre Fischer * regarding copyright ownership. The ASF licenses this file 7*95a18594SAndre Fischer * to you under the Apache License, Version 2.0 (the 8*95a18594SAndre Fischer * "License"); you may not use this file except in compliance 9*95a18594SAndre Fischer * with the License. You may obtain a copy of the License at 10*95a18594SAndre Fischer * 11*95a18594SAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 12*95a18594SAndre Fischer * 13*95a18594SAndre Fischer * Unless required by applicable law or agreed to in writing, 14*95a18594SAndre Fischer * software distributed under the License is distributed on an 15*95a18594SAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*95a18594SAndre Fischer * KIND, either express or implied. See the License for the 17*95a18594SAndre Fischer * specific language governing permissions and limitations 18*95a18594SAndre Fischer * under the License. 19*95a18594SAndre Fischer * 20*95a18594SAndre Fischer *************************************************************/ 21*95a18594SAndre Fischer 22*95a18594SAndre Fischer #include "precompiled_sfx2.hxx" 23*95a18594SAndre Fischer 24*95a18594SAndre Fischer #include "ToolBoxBackground.hxx" 25*95a18594SAndre Fischer #include "Paint.hxx" 26*95a18594SAndre Fischer #include "DrawHelper.hxx" 27*95a18594SAndre Fischer #include "Tools.hxx" 28*95a18594SAndre Fischer #include "sfx2/sidebar/Theme.hxx" 29*95a18594SAndre Fischer 30*95a18594SAndre Fischer #include <vcl/toolbox.hxx> 31*95a18594SAndre Fischer #include <vcl/gradient.hxx> 32*95a18594SAndre Fischer 33*95a18594SAndre Fischer 34*95a18594SAndre Fischer namespace sfx2 { namespace sidebar { 35*95a18594SAndre Fischer 36*95a18594SAndre Fischer ToolBoxBackground::ToolBoxBackground (Window* pParentWindow) 37*95a18594SAndre Fischer : Window(pParentWindow), 38*95a18594SAndre Fischer maPadding(Tools::RectangleToSvBorder(Theme::GetRectangle(Theme::Rect_ToolBoxPadding))) 39*95a18594SAndre Fischer { 40*95a18594SAndre Fischer SetBackground(Theme::GetPaint(Theme::Paint_ToolBoxBackground).GetWallpaper()); 41*95a18594SAndre Fischer } 42*95a18594SAndre Fischer 43*95a18594SAndre Fischer 44*95a18594SAndre Fischer 45*95a18594SAndre Fischer 46*95a18594SAndre Fischer ToolBoxBackground::~ToolBoxBackground (void) 47*95a18594SAndre Fischer { 48*95a18594SAndre Fischer Link aEventListener (LINK(this, ToolBoxBackground, WindowEventHandler)); 49*95a18594SAndre Fischer if (GetChildCount() > 0) 50*95a18594SAndre Fischer GetChild(0)->RemoveEventListener(aEventListener); 51*95a18594SAndre Fischer } 52*95a18594SAndre Fischer 53*95a18594SAndre Fischer 54*95a18594SAndre Fischer 55*95a18594SAndre Fischer 56*95a18594SAndre Fischer Point ToolBoxBackground::SetToolBoxChild ( 57*95a18594SAndre Fischer ToolBox* pChild, 58*95a18594SAndre Fischer long nX, 59*95a18594SAndre Fischer long nY, 60*95a18594SAndre Fischer long nWidth, 61*95a18594SAndre Fischer long nHeight, 62*95a18594SAndre Fischer sal_uInt16 nFlags) 63*95a18594SAndre Fischer { 64*95a18594SAndre Fischer if (pChild == NULL) 65*95a18594SAndre Fischer { 66*95a18594SAndre Fischer OSL_ASSERT(pChild!=NULL); 67*95a18594SAndre Fischer return Point(nX, nY); 68*95a18594SAndre Fischer } 69*95a18594SAndre Fischer 70*95a18594SAndre Fischer Link aEventListener (LINK(this, ToolBoxBackground, WindowEventHandler)); 71*95a18594SAndre Fischer pChild->AddEventListener(aEventListener); 72*95a18594SAndre Fischer 73*95a18594SAndre Fischer SetPosSizePixel( 74*95a18594SAndre Fischer nX - maPadding.Left(), 75*95a18594SAndre Fischer nY - maPadding.Top(), 76*95a18594SAndre Fischer nWidth + maPadding.Left() + maPadding.Right(), 77*95a18594SAndre Fischer nHeight + maPadding.Top() + maPadding.Bottom(), 78*95a18594SAndre Fischer nFlags); 79*95a18594SAndre Fischer return Point( 80*95a18594SAndre Fischer maPadding.Left(), 81*95a18594SAndre Fischer maPadding.Top()); 82*95a18594SAndre Fischer } 83*95a18594SAndre Fischer 84*95a18594SAndre Fischer 85*95a18594SAndre Fischer 86*95a18594SAndre Fischer 87*95a18594SAndre Fischer void ToolBoxBackground::Paint (const Rectangle& rRect) 88*95a18594SAndre Fischer { 89*95a18594SAndre Fischer Window::Paint(rRect); 90*95a18594SAndre Fischer 91*95a18594SAndre Fischer OSL_TRACE("paint ToolBoxBackground at %d,%d", 92*95a18594SAndre Fischer GetPosPixel().X(), 93*95a18594SAndre Fischer GetPosPixel().Y()); 94*95a18594SAndre Fischer Rectangle aBox (Point(0,0), GetSizePixel()); 95*95a18594SAndre Fischer 96*95a18594SAndre Fischer const sidebar::Paint aTopLeftBorderPaint (Theme::GetPaint(Theme::Paint_ToolBoxBorderTopLeft)); 97*95a18594SAndre Fischer const sidebar::Paint aCenterBorderPaint (Theme::GetPaint(Theme::Paint_ToolBoxBorderCenterCorners)); 98*95a18594SAndre Fischer const sidebar::Paint aBottomRightBorderPaint (Theme::GetPaint(Theme::Paint_ToolBoxBorderBottomRight)); 99*95a18594SAndre Fischer const Rectangle aBorderSize (Theme::GetRectangle(Theme::Rect_ToolBoxBorder)); 100*95a18594SAndre Fischer DrawHelper::DrawBevelBorder ( 101*95a18594SAndre Fischer *this, 102*95a18594SAndre Fischer aBox, 103*95a18594SAndre Fischer Tools::RectangleToSvBorder(aBorderSize), 104*95a18594SAndre Fischer aTopLeftBorderPaint, 105*95a18594SAndre Fischer aCenterBorderPaint, 106*95a18594SAndre Fischer aBottomRightBorderPaint); 107*95a18594SAndre Fischer } 108*95a18594SAndre Fischer 109*95a18594SAndre Fischer 110*95a18594SAndre Fischer 111*95a18594SAndre Fischer 112*95a18594SAndre Fischer void ToolBoxBackground::DataChanged (const DataChangedEvent& rEvent) 113*95a18594SAndre Fischer { 114*95a18594SAndre Fischer (void)rEvent; 115*95a18594SAndre Fischer 116*95a18594SAndre Fischer SetBackground(Theme::GetPaint(Theme::Paint_ToolBoxBackground).GetWallpaper()); 117*95a18594SAndre Fischer maPadding = Tools::RectangleToSvBorder(Theme::GetRectangle(Theme::Rect_ToolBoxPadding)); 118*95a18594SAndre Fischer } 119*95a18594SAndre Fischer 120*95a18594SAndre Fischer 121*95a18594SAndre Fischer 122*95a18594SAndre Fischer 123*95a18594SAndre Fischer IMPL_LINK(ToolBoxBackground, WindowEventHandler, VclWindowEvent*, pEvent) 124*95a18594SAndre Fischer { 125*95a18594SAndre Fischer if (pEvent != NULL) 126*95a18594SAndre Fischer { 127*95a18594SAndre Fischer switch (pEvent->GetId()) 128*95a18594SAndre Fischer { 129*95a18594SAndre Fischer case VCLEVENT_WINDOW_SHOW: 130*95a18594SAndre Fischer if (GetChild(0)->IsVisible()) 131*95a18594SAndre Fischer Show(); 132*95a18594SAndre Fischer break; 133*95a18594SAndre Fischer 134*95a18594SAndre Fischer case VCLEVENT_WINDOW_HIDE: 135*95a18594SAndre Fischer if ( ! GetChild(0)->IsVisible()) 136*95a18594SAndre Fischer Hide(); 137*95a18594SAndre Fischer break; 138*95a18594SAndre Fischer 139*95a18594SAndre Fischer default: 140*95a18594SAndre Fischer break; 141*95a18594SAndre Fischer } 142*95a18594SAndre Fischer } 143*95a18594SAndre Fischer 144*95a18594SAndre Fischer return sal_True; 145*95a18594SAndre Fischer } 146*95a18594SAndre Fischer 147*95a18594SAndre Fischer 148*95a18594SAndre Fischer } } // end of namespace sfx2::sidebar 149