195a18594SAndre Fischer /**************************************************************
295a18594SAndre Fischer *
395a18594SAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one
495a18594SAndre Fischer * or more contributor license agreements. See the NOTICE file
595a18594SAndre Fischer * distributed with this work for additional information
695a18594SAndre Fischer * regarding copyright ownership. The ASF licenses this file
795a18594SAndre Fischer * to you under the Apache License, Version 2.0 (the
895a18594SAndre Fischer * "License"); you may not use this file except in compliance
995a18594SAndre Fischer * with the License. You may obtain a copy of the License at
1095a18594SAndre Fischer *
1195a18594SAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0
1295a18594SAndre Fischer *
1395a18594SAndre Fischer * Unless required by applicable law or agreed to in writing,
1495a18594SAndre Fischer * software distributed under the License is distributed on an
1595a18594SAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1695a18594SAndre Fischer * KIND, either express or implied. See the License for the
1795a18594SAndre Fischer * specific language governing permissions and limitations
1895a18594SAndre Fischer * under the License.
1995a18594SAndre Fischer *
2095a18594SAndre Fischer *************************************************************/
2195a18594SAndre Fischer
2295a18594SAndre Fischer #include "precompiled_sfx2.hxx"
2395a18594SAndre Fischer
2495a18594SAndre Fischer #include "ToolBoxBackground.hxx"
2595a18594SAndre Fischer #include "Paint.hxx"
2695a18594SAndre Fischer #include "DrawHelper.hxx"
27f35c6d02SAndre Fischer #include "sfx2/sidebar/Tools.hxx"
2895a18594SAndre Fischer #include "sfx2/sidebar/Theme.hxx"
2995a18594SAndre Fischer
3095a18594SAndre Fischer #include <vcl/toolbox.hxx>
3195a18594SAndre Fischer #include <vcl/gradient.hxx>
327a32b0c8SAndre Fischer #include <svl/smplhint.hxx>
3395a18594SAndre Fischer
3495a18594SAndre Fischer namespace sfx2 { namespace sidebar {
3595a18594SAndre Fischer
ToolBoxBackground(Window * pParentWindow,const bool bShowBorder)36d46a1e42SAndre Fischer ToolBoxBackground::ToolBoxBackground (
37d46a1e42SAndre Fischer Window* pParentWindow,
38d46a1e42SAndre Fischer const bool bShowBorder)
3965908a7eSAndre Fischer : Window(pParentWindow, WB_DIALOGCONTROL),
40d46a1e42SAndre Fischer maPadding(bShowBorder
41d46a1e42SAndre Fischer ? Tools::RectangleToSvBorder(Theme::GetRectangle(Theme::Rect_ToolBoxPadding))
42d46a1e42SAndre Fischer : SvBorder())
4395a18594SAndre Fischer {
44d46a1e42SAndre Fischer if (bShowBorder)
4595a18594SAndre Fischer SetBackground(Theme::GetPaint(Theme::Paint_ToolBoxBackground).GetWallpaper());
46d46a1e42SAndre Fischer else
47d46a1e42SAndre Fischer SetBackground(Wallpaper());
487a32b0c8SAndre Fischer
497a32b0c8SAndre Fischer #ifdef DEBUG
507a32b0c8SAndre Fischer SetText(A2S("ToolBoxBackground"));
517a32b0c8SAndre Fischer #endif
5295a18594SAndre Fischer }
5395a18594SAndre Fischer
~ToolBoxBackground(void)5495a18594SAndre Fischer ToolBoxBackground::~ToolBoxBackground (void)
5595a18594SAndre Fischer {
5695a18594SAndre Fischer Link aEventListener (LINK(this, ToolBoxBackground, WindowEventHandler));
5795a18594SAndre Fischer if (GetChildCount() > 0)
5895a18594SAndre Fischer GetChild(0)->RemoveEventListener(aEventListener);
5995a18594SAndre Fischer }
6095a18594SAndre Fischer
SetToolBoxChild(ToolBox * pChild,long nX,long nY,long nWidth,long nHeight,sal_uInt16 nFlags)6195a18594SAndre Fischer Point ToolBoxBackground::SetToolBoxChild (
6295a18594SAndre Fischer ToolBox* pChild,
6395a18594SAndre Fischer long nX,
6495a18594SAndre Fischer long nY,
6595a18594SAndre Fischer long nWidth,
6695a18594SAndre Fischer long nHeight,
6795a18594SAndre Fischer sal_uInt16 nFlags)
6895a18594SAndre Fischer {
6995a18594SAndre Fischer if (pChild == NULL)
7095a18594SAndre Fischer {
7195a18594SAndre Fischer OSL_ASSERT(pChild!=NULL);
7295a18594SAndre Fischer return Point(nX, nY);
7395a18594SAndre Fischer }
7495a18594SAndre Fischer
7595a18594SAndre Fischer Link aEventListener (LINK(this, ToolBoxBackground, WindowEventHandler));
7695a18594SAndre Fischer pChild->AddEventListener(aEventListener);
7795a18594SAndre Fischer
7895a18594SAndre Fischer SetPosSizePixel(
7995a18594SAndre Fischer nX - maPadding.Left(),
8095a18594SAndre Fischer nY - maPadding.Top(),
8195a18594SAndre Fischer nWidth + maPadding.Left() + maPadding.Right(),
8295a18594SAndre Fischer nHeight + maPadding.Top() + maPadding.Bottom(),
8395a18594SAndre Fischer nFlags);
8495a18594SAndre Fischer return Point(
8595a18594SAndre Fischer maPadding.Left(),
8695a18594SAndre Fischer maPadding.Top());
8795a18594SAndre Fischer }
8895a18594SAndre Fischer
Paint(const Rectangle & rRect)8995a18594SAndre Fischer void ToolBoxBackground::Paint (const Rectangle& rRect)
9095a18594SAndre Fischer {
9195a18594SAndre Fischer Window::Paint(rRect);
9295a18594SAndre Fischer
9395a18594SAndre Fischer Rectangle aBox (Point(0,0), GetSizePixel());
9495a18594SAndre Fischer
9595a18594SAndre Fischer const sidebar::Paint aTopLeftBorderPaint (Theme::GetPaint(Theme::Paint_ToolBoxBorderTopLeft));
9695a18594SAndre Fischer const sidebar::Paint aCenterBorderPaint (Theme::GetPaint(Theme::Paint_ToolBoxBorderCenterCorners));
9795a18594SAndre Fischer const sidebar::Paint aBottomRightBorderPaint (Theme::GetPaint(Theme::Paint_ToolBoxBorderBottomRight));
9895a18594SAndre Fischer const Rectangle aBorderSize (Theme::GetRectangle(Theme::Rect_ToolBoxBorder));
9995a18594SAndre Fischer DrawHelper::DrawBevelBorder (
10095a18594SAndre Fischer *this,
10195a18594SAndre Fischer aBox,
10295a18594SAndre Fischer Tools::RectangleToSvBorder(aBorderSize),
10395a18594SAndre Fischer aTopLeftBorderPaint,
10495a18594SAndre Fischer aCenterBorderPaint,
10595a18594SAndre Fischer aBottomRightBorderPaint);
10695a18594SAndre Fischer }
10795a18594SAndre Fischer
DataChanged(const DataChangedEvent & rEvent)10895a18594SAndre Fischer void ToolBoxBackground::DataChanged (const DataChangedEvent& rEvent)
10995a18594SAndre Fischer {
11095a18594SAndre Fischer (void)rEvent;
11195a18594SAndre Fischer
11295a18594SAndre Fischer SetBackground(Theme::GetPaint(Theme::Paint_ToolBoxBackground).GetWallpaper());
11395a18594SAndre Fischer maPadding = Tools::RectangleToSvBorder(Theme::GetRectangle(Theme::Rect_ToolBoxPadding));
11495a18594SAndre Fischer }
11595a18594SAndre Fischer
IMPL_LINK(ToolBoxBackground,WindowEventHandler,VclWindowEvent *,pEvent)11695a18594SAndre Fischer IMPL_LINK(ToolBoxBackground, WindowEventHandler, VclWindowEvent*, pEvent)
11795a18594SAndre Fischer {
11895a18594SAndre Fischer if (pEvent != NULL)
11995a18594SAndre Fischer {
12095a18594SAndre Fischer switch (pEvent->GetId())
12195a18594SAndre Fischer {
12295a18594SAndre Fischer case VCLEVENT_WINDOW_SHOW:
12395a18594SAndre Fischer if (GetChild(0)->IsVisible())
12495a18594SAndre Fischer Show();
12595a18594SAndre Fischer break;
12695a18594SAndre Fischer
12795a18594SAndre Fischer case VCLEVENT_WINDOW_HIDE:
12895a18594SAndre Fischer if ( ! GetChild(0)->IsVisible())
12995a18594SAndre Fischer Hide();
13095a18594SAndre Fischer break;
13195a18594SAndre Fischer
13295a18594SAndre Fischer default:
13395a18594SAndre Fischer break;
13495a18594SAndre Fischer }
13595a18594SAndre Fischer }
13695a18594SAndre Fischer
13795a18594SAndre Fischer return sal_True;
13895a18594SAndre Fischer }
13995a18594SAndre Fischer
14095a18594SAndre Fischer } } // end of namespace sfx2::sidebar
141*05574615Smseidel
142*05574615Smseidel /* vim: set noet sw=4 ts=4: */
143