1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "PanelTitleBar.hxx"
22 #include "PanelDescriptor.hxx"
23 #include <sfx2/sidebar/Theme.hxx>
25 #include "ResourceManager.hxx"
28 #include <sfx2/sidebar/Tools.hxx>
32 #include <tools/svborder.hxx>
33 #include <toolkit/helper/vclunohelper.hxx>
35 #include <com/sun/star/awt/XWindowPeer.hpp>
36 #include <com/sun/star/awt/PosSize.hpp>
37 #include <com/sun/star/ui/XToolPanel.hpp>
39 #include <boost/bind.hpp>
42 using namespace css::uno
;
44 namespace sfx2
{ namespace sidebar
{
46 Panel::Panel(const PanelDescriptor
& rPanelDescriptor
,
47 vcl::Window
* pParentWindow
,
48 const bool bIsInitiallyExpanded
,
49 const std::function
<void()>& rDeckLayoutTrigger
,
50 const std::function
<Context()>& rContextAccess
)
51 : Window(pParentWindow
)
52 , msPanelId(rPanelDescriptor
.msId
)
53 , mpTitleBar(VclPtr
<PanelTitleBar
>::Create(rPanelDescriptor
.msTitle
, pParentWindow
, this))
54 , mbIsTitleBarOptional(rPanelDescriptor
.mbIsTitleBarOptional
)
57 , mbIsExpanded(bIsInitiallyExpanded
)
58 , maDeckLayoutTrigger(rDeckLayoutTrigger
)
59 , maContextAccess(rContextAccess
)
62 SetText(OUString("Panel"));
71 void Panel::ApplySettings(vcl::RenderContext
& rRenderContext
)
73 rRenderContext
.SetBackground(Theme::GetPaint(Theme::Paint_PanelBackground
).GetWallpaper());
78 mxPanelComponent
= NULL
;
81 Reference
<lang::XComponent
> xComponent (mxElement
, UNO_QUERY
);
84 xComponent
->dispose();
88 Reference
<lang::XComponent
> xComponent (GetElementWindow(), UNO_QUERY
);
90 xComponent
->dispose();
93 mpTitleBar
.disposeAndClear();
95 vcl::Window::dispose();
98 PanelTitleBar
* Panel::GetTitleBar() const
100 return mpTitleBar
.get();
103 void Panel::SetUIElement (const Reference
<ui::XUIElement
>& rxElement
)
105 mxElement
= rxElement
;
108 mxPanelComponent
.set(mxElement
->getRealInterface(), UNO_QUERY
);
112 void Panel::SetExpanded (const bool bIsExpanded
)
114 if (mbIsExpanded
!= bIsExpanded
)
116 mbIsExpanded
= bIsExpanded
;
117 maDeckLayoutTrigger();
121 ResourceManager::Instance().StorePanelExpansionState(
129 bool Panel::HasIdPredicate (const OUString
& rsId
) const
131 return msPanelId
.equals(rsId
);
134 void Panel::Paint (vcl::RenderContext
& rRenderContext
, const Rectangle
& rUpdateArea
)
136 Window::Paint(rRenderContext
, rUpdateArea
);
143 // Forward new size to window of XUIElement.
144 Reference
<awt::XWindow
> xElementWindow (GetElementWindow());
145 if(xElementWindow
.is())
147 const Size
aSize(GetSizePixel());
148 xElementWindow
->setPosSize(0, 0, aSize
.Width(), aSize
.Height(),
149 awt::PosSize::POSSIZE
);
153 void Panel::Activate()
158 void Panel::DataChanged (const DataChangedEvent
& rEvent
)
164 Reference
<awt::XWindow
> Panel::GetElementWindow()
168 Reference
<ui::XToolPanel
> xToolPanel(mxElement
->getRealInterface(), UNO_QUERY
);
170 return xToolPanel
->getWindow();
176 } } // end of namespace sfx2::sidebar
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */