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"
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
),
36 ? Tools::RectangleToSvBorder(Theme::GetRectangle(Theme::Rect_ToolBoxPadding
))
40 SetBackground(Theme::GetPaint(Theme::Paint_ToolBoxBackground
).GetWallpaper());
42 SetBackground(Wallpaper());
45 SetText(A2S("ToolBoxBackground"));
52 ToolBoxBackground::~ToolBoxBackground (void)
54 Link
aEventListener (LINK(this, ToolBoxBackground
, WindowEventHandler
));
55 if (GetChildCount() > 0)
56 GetChild(0)->RemoveEventListener(aEventListener
);
62 Point
ToolBoxBackground::SetToolBoxChild (
72 OSL_ASSERT(pChild
!=NULL
);
76 Link
aEventListener (LINK(this, ToolBoxBackground
, WindowEventHandler
));
77 pChild
->AddEventListener(aEventListener
);
80 nX
- maPadding
.Left(),
82 nWidth
+ maPadding
.Left() + maPadding
.Right(),
83 nHeight
+ maPadding
.Top() + maPadding
.Bottom(),
93 void ToolBoxBackground::Paint (const Rectangle
& rRect
)
97 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
99 SetLineColor( rStyleSettings
.GetShadowColor() );
101 DrawRect( Rectangle( Point( 0, 0 ), GetSizePixel() ) );
107 void ToolBoxBackground::DataChanged (const DataChangedEvent
& rEvent
)
111 maPadding
= Tools::RectangleToSvBorder(Theme::GetRectangle(Theme::Rect_ToolBoxPadding
));
117 IMPL_LINK(ToolBoxBackground
, WindowEventHandler
, VclWindowEvent
*, pEvent
)
121 switch (pEvent
->GetId())
123 case VCLEVENT_WINDOW_SHOW
:
124 if (GetChild(0)->IsVisible())
128 case VCLEVENT_WINDOW_HIDE
:
129 if ( ! GetChild(0)->IsVisible())
142 } } // end of namespace sfx2::sidebar