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/.
10 #include <sal/log.hxx>
11 #include <sfx2/sidebar/Panel.hxx>
12 #include <sfx2/sidebar/PanelLayout.hxx>
13 #include <sfx2/sidebar/Theme.hxx>
14 #include <sfx2/viewsh.hxx>
15 #include <vcl/event.hxx>
16 #include <vcl/svapp.hxx>
18 using namespace sfx2::sidebar
;
20 PanelLayout::PanelLayout(weld::Widget
* pParent
, const OUString
& rID
, const OUString
& rUIXMLDescription
)
21 : m_xBuilder(Application::CreateBuilder(pParent
, rUIXMLDescription
, false, reinterpret_cast<sal_uInt64
>(SfxViewShell::Current())))
22 , m_xContainer(m_xBuilder
->weld_container(rID
))
25 m_xContainer
->set_background(Theme::GetColor(Theme::Color_PanelBackground
));
26 m_xContainer
->connect_get_property_tree(LINK(this, PanelLayout
, DumpAsPropertyTreeHdl
));
27 ::Application::AddEventListener(LINK(this, PanelLayout
, DataChangedEventListener
));
30 IMPL_LINK(PanelLayout
, DumpAsPropertyTreeHdl
, tools::JsonWriter
&, rJsonWriter
, void)
32 DumpAsPropertyTree(rJsonWriter
);
35 void PanelLayout::DumpAsPropertyTree(tools::JsonWriter
&)
39 IMPL_LINK(PanelLayout
, DataChangedEventListener
, VclSimpleEvent
&, rEvent
, void)
41 if (rEvent
.GetId() != VclEventId::ApplicationDataChanged
)
44 DataChangedEvent
* pData
= static_cast<DataChangedEvent
*>(static_cast<VclWindowEvent
&>(rEvent
).GetData());
48 void PanelLayout::DataChanged(const DataChangedEvent
& rEvent
)
50 if (rEvent
.GetType() != DataChangedEventType::SETTINGS
)
52 if (rEvent
.GetFlags() & AllSettingsFlags::STYLE
)
53 m_xContainer
->set_background(Theme::GetColor(Theme::Color_PanelBackground
));
56 void PanelLayout::SetPanel(sfx2::sidebar::Panel
* pPanel
)
61 weld::Window
* PanelLayout::GetFrameWeld() const
65 SAL_WARN("sfx.sidebar", "Expected a toplevel Panel to exist");
68 return m_pPanel
->GetFrameWeld();
71 PanelLayout::~PanelLayout()
73 ::Application::RemoveEventListener(LINK(this, PanelLayout
, DataChangedEventListener
));
79 void PanelLayout::queue_resize()
83 m_xContainer
->queue_resize();
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */