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 .
20 #include "PanelTitleBar.hxx"
21 #include "PanelDescriptor.hxx"
22 #include "sfx2/sidebar/Theme.hxx"
24 #include "ResourceManager.hxx"
27 #include "sfx2/sidebar/Tools.hxx"
31 #include <tools/svborder.hxx>
32 #include <toolkit/helper/vclunohelper.hxx>
34 #include <com/sun/star/awt/XWindowPeer.hpp>
35 #include <com/sun/star/awt/PosSize.hpp>
36 #include <com/sun/star/ui/XToolPanel.hpp>
38 #include <boost/bind.hpp>
46 namespace sfx2
{ namespace sidebar
{
49 const PanelDescriptor
& rPanelDescriptor
,
50 Window
* pParentWindow
,
51 const bool bIsInitiallyExpanded
,
52 const ::boost::function
<void(void)>& rDeckLayoutTrigger
,
53 const ::boost::function
<Context(void)>& rContextAccess
)
54 : Window(pParentWindow
),
55 msPanelId(rPanelDescriptor
.msId
),
56 mpTitleBar(new PanelTitleBar(
57 rPanelDescriptor
.msTitle
,
60 mbIsTitleBarOptional(rPanelDescriptor
.mbIsTitleBarOptional
),
63 mbIsExpanded(bIsInitiallyExpanded
),
64 maDeckLayoutTrigger(rDeckLayoutTrigger
),
65 maContextAccess(rContextAccess
)
67 SetBackground(Theme::GetPaint(Theme::Paint_PanelBackground
).GetWallpaper());
70 SetText(A2S("Panel"));
85 void Panel::Dispose (void)
87 mxPanelComponent
= NULL
;
90 Reference
<lang::XComponent
> xComponent (mxElement
, UNO_QUERY
);
93 xComponent
->dispose();
97 Reference
<lang::XComponent
> xComponent (GetElementWindow(), UNO_QUERY
);
99 xComponent
->dispose();
108 PanelTitleBar
* Panel::GetTitleBar (void) const
110 return mpTitleBar
.get();
116 bool Panel::IsTitleBarOptional (void) const
118 return mbIsTitleBarOptional
;
124 void Panel::SetUIElement (const Reference
<ui::XUIElement
>& rxElement
)
126 mxElement
= rxElement
;
129 mxPanelComponent
.set(mxElement
->getRealInterface(), UNO_QUERY
);
136 void Panel::SetExpanded (const bool bIsExpanded
)
138 if (mbIsExpanded
!= bIsExpanded
)
140 mbIsExpanded
= bIsExpanded
;
141 maDeckLayoutTrigger();
144 ResourceManager::Instance().StorePanelExpansionState(
154 bool Panel::IsExpanded (void) const
162 bool Panel::HasIdPredicate (const ::rtl::OUString
& rsId
) const
167 return msPanelId
.equals(rsId
);
173 const ::rtl::OUString
& Panel::GetId (void) const
181 void Panel::Paint (const Rectangle
& rUpdateArea
)
183 Window::Paint(rUpdateArea
);
189 void Panel::Resize (void)
193 // Forward new size to window of XUIElement.
194 Reference
<awt::XWindow
> xElementWindow (GetElementWindow());
195 if (xElementWindow
.is())
197 const Size
aSize (GetSizePixel());
198 xElementWindow
->setPosSize(
203 awt::PosSize::POSSIZE
);
210 void Panel::Activate (void)
219 void Panel::DataChanged (const DataChangedEvent
& rEvent
)
222 SetBackground(Theme::GetPaint(Theme::Paint_PanelBackground
).GetWallpaper());
228 Reference
<ui::XSidebarPanel
> Panel::GetPanelComponent (void) const
230 return mxPanelComponent
;
236 void Panel::PrintWindowTree (void)
239 Window
* pElementWindow
= VCLUnoHelper::GetWindow(GetElementWindow());
240 if (pElementWindow
!= NULL
)
242 OSL_TRACE("panel parent is %x", pElementWindow
->GetParent());
243 Deck::PrintWindowSubTree(pElementWindow
, 2);
246 OSL_TRACE(" panel is empty");
253 Reference
<awt::XWindow
> Panel::GetElementWindow (void)
257 Reference
<ui::XToolPanel
> xToolPanel(mxElement
->getRealInterface(), UNO_QUERY
);
259 return xToolPanel
->getWindow();
266 } } // end of namespace sfx2::sidebar