bump product version to 4.1.6.2
[LibreOffice.git] / sfx2 / source / sidebar / ToolBoxBackground.cxx
blob23c6af3ce4f5ae711c4e7c0b7970ae9ffc0e9f90
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 #include "ToolBoxBackground.hxx"
19 #include "Paint.hxx"
20 #include "DrawHelper.hxx"
21 #include "sfx2/sidebar/Tools.hxx"
22 #include "sfx2/sidebar/Theme.hxx"
24 #include <vcl/svapp.hxx>
25 #include <vcl/toolbox.hxx>
26 #include <svl/smplhint.hxx>
29 namespace sfx2 { namespace sidebar {
31 ToolBoxBackground::ToolBoxBackground (
32 Window* pParentWindow,
33 const bool bShowBorder)
34 : Window(pParentWindow, WB_DIALOGCONTROL),
35 maPadding(bShowBorder
36 ? Tools::RectangleToSvBorder(Theme::GetRectangle(Theme::Rect_ToolBoxPadding))
37 : SvBorder())
39 if (bShowBorder)
40 SetBackground(Theme::GetPaint(Theme::Paint_ToolBoxBackground).GetWallpaper());
41 else
42 SetBackground(Wallpaper());
44 #ifdef DEBUG
45 SetText(A2S("ToolBoxBackground"));
46 #endif
52 ToolBoxBackground::~ToolBoxBackground (void)
54 Link aEventListener (LINK(this, ToolBoxBackground, WindowEventHandler));
55 if (GetChildCount() > 0)
56 GetChild(0)->RemoveEventListener(aEventListener);
62 Point ToolBoxBackground::SetToolBoxChild (
63 ToolBox* pChild,
64 long nX,
65 long nY,
66 long nWidth,
67 long nHeight,
68 sal_uInt16 nFlags)
70 if (pChild == NULL)
72 OSL_ASSERT(pChild!=NULL);
73 return Point(nX, nY);
76 Link aEventListener (LINK(this, ToolBoxBackground, WindowEventHandler));
77 pChild->AddEventListener(aEventListener);
79 setPosSizePixel(
80 nX - maPadding.Left(),
81 nY - maPadding.Top(),
82 nWidth + maPadding.Left() + maPadding.Right(),
83 nHeight + maPadding.Top() + maPadding.Bottom(),
84 nFlags);
85 return Point(
86 maPadding.Left(),
87 maPadding.Top());
93 void ToolBoxBackground::Paint (const Rectangle& rRect)
95 Window::Paint(rRect);
97 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
98 SetFillColor();
99 SetLineColor( rStyleSettings.GetShadowColor() );
101 DrawRect( Rectangle( Point( 0, 0 ), GetSizePixel() ) );
107 void ToolBoxBackground::DataChanged (const DataChangedEvent& rEvent)
109 (void)rEvent;
111 maPadding = Tools::RectangleToSvBorder(Theme::GetRectangle(Theme::Rect_ToolBoxPadding));
117 IMPL_LINK(ToolBoxBackground, WindowEventHandler, VclWindowEvent*, pEvent)
119 if (pEvent != NULL)
121 switch (pEvent->GetId())
123 case VCLEVENT_WINDOW_SHOW:
124 if (GetChild(0)->IsVisible())
125 Show();
126 break;
128 case VCLEVENT_WINDOW_HIDE:
129 if ( ! GetChild(0)->IsVisible())
130 Hide();
131 break;
133 default:
134 break;
138 return sal_True;
142 } } // end of namespace sfx2::sidebar