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 .
20 #include <PaneDockingWindow.hxx>
21 #include <ViewShellBase.hxx>
22 #include <framework/FrameworkHelper.hxx>
24 #include <sfx2/dispatch.hxx>
25 #include <vcl/splitwin.hxx>
26 #include <tools/wintypes.hxx>
28 using namespace ::com::sun::star
;
29 using namespace ::com::sun::star::uno
;
30 using namespace ::com::sun::star::drawing::framework
;
31 using ::sfx2::TitledDockingWindow
;
35 PaneDockingWindow::PaneDockingWindow(
36 SfxBindings
*_pBindings
, SfxChildWindow
*pChildWindow
, vcl::Window
* pParent
,
37 const OUString
& rsTitle
)
38 : TitledDockingWindow(_pBindings
, pChildWindow
, pParent
)
41 SetSizePixel(LogicToPixel(Size(80,200), MapMode(MapUnit::MapAppFont
)));
44 PaneDockingWindow::~PaneDockingWindow()
48 void PaneDockingWindow::StateChanged( StateChangedType nType
)
52 case StateChangedType::InitShow
:
54 GetContentWindow().SetStyle(GetContentWindow().GetStyle() | WB_DIALOGCONTROL
);
57 case StateChangedType::Visible
:
59 // The visibility of the docking window has changed. Tell the
60 // ConfigurationController so that it can activate or deactivate
61 // a/the view for the pane.
62 // Without this the side panes remain empty after closing an
63 // in-place slide show.
64 ViewShellBase
* pBase
= ViewShellBase::GetViewShellBase(
65 GetBindings().GetDispatcher()->GetFrame());
68 framework::FrameworkHelper::Instance(*pBase
)->UpdateConfiguration();
75 SfxDockingWindow::StateChanged (nType
);
78 void PaneDockingWindow::MouseButtonDown (const MouseEvent
& rEvent
)
80 if (rEvent
.GetButtons() == MOUSE_LEFT
)
82 // For some strange reason we have to set the WB_DIALOGCONTROL at
83 // the content window in order to have it pass focus to its content
84 // window. Without setting this flag here that works only on views
85 // that have not been taken from the cash and relocated to this pane
87 GetContentWindow().SetStyle(GetContentWindow().GetStyle() | WB_DIALOGCONTROL
);
88 GetContentWindow().GrabFocus();
90 SfxDockingWindow::MouseButtonDown(rEvent
);
93 void PaneDockingWindow::SetValidSizeRange (const Range
& rValidSizeRange
)
95 SplitWindow
* pSplitWindow
= dynamic_cast<SplitWindow
*>(GetParent());
96 if (pSplitWindow
== nullptr)
99 const sal_uInt16
nId (pSplitWindow
->GetItemId(static_cast< vcl::Window
*>(this)));
100 const sal_uInt16
nSetId (pSplitWindow
->GetSet(nId
));
101 // Because the PaneDockingWindow paints its own decoration, we have
102 // to compensate the valid size range for that.
103 const SvBorder
aBorder (GetDecorationBorder());
104 sal_Int32
nCompensation (pSplitWindow
->IsHorizontal()
105 ? aBorder
.Top() + aBorder
.Bottom()
106 : aBorder
.Left() + aBorder
.Right());
107 pSplitWindow
->SetItemSizeRange(
110 rValidSizeRange
.Min() + nCompensation
,
111 rValidSizeRange
.Max() + nCompensation
));
114 PaneDockingWindow::Orientation
PaneDockingWindow::GetOrientation() const
116 SplitWindow
* pSplitWindow
= dynamic_cast<SplitWindow
*>(GetParent());
117 if (pSplitWindow
== nullptr)
118 return UnknownOrientation
;
119 else if (pSplitWindow
->IsHorizontal())
120 return HorizontalOrientation
;
122 return VerticalOrientation
;
125 } // end of namespace ::sd
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */