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>
22 #include <ViewShellBase.hxx>
23 #include <framework/FrameworkHelper.hxx>
25 #include <sfx2/dispatch.hxx>
26 #include <vcl/toolbox.hxx>
27 #include <vcl/taskpanelist.hxx>
28 #include <vcl/splitwin.hxx>
29 #include <vcl/svapp.hxx>
30 #include <tools/wintypes.hxx>
32 using namespace ::com::sun::star
;
33 using namespace ::com::sun::star::uno
;
34 using namespace ::com::sun::star::drawing::framework
;
35 using ::sfx2::TitledDockingWindow
;
39 PaneDockingWindow::PaneDockingWindow(
40 SfxBindings
*_pBindings
, SfxChildWindow
*pChildWindow
, vcl::Window
* pParent
,
41 const OUString
& rsTitle
)
42 : TitledDockingWindow(_pBindings
, pChildWindow
, pParent
)
45 SetSizePixel(LogicToPixel(Size(80,200), MapMode(MapUnit::MapAppFont
)));
48 PaneDockingWindow::~PaneDockingWindow()
52 void PaneDockingWindow::StateChanged( StateChangedType nType
)
56 case StateChangedType::InitShow
:
58 GetContentWindow().SetStyle(GetContentWindow().GetStyle() | WB_DIALOGCONTROL
);
61 case StateChangedType::Visible
:
63 // The visibility of the docking window has changed. Tell the
64 // ConfigurationController so that it can activate or deactivate
65 // a/the view for the pane.
66 // Without this the side panes remain empty after closing an
67 // in-place slide show.
68 ViewShellBase
* pBase
= ViewShellBase::GetViewShellBase(
69 GetBindings().GetDispatcher()->GetFrame());
72 framework::FrameworkHelper::Instance(*pBase
)->UpdateConfiguration();
79 SfxDockingWindow::StateChanged (nType
);
82 void PaneDockingWindow::MouseButtonDown (const MouseEvent
& rEvent
)
84 if (rEvent
.GetButtons() == MOUSE_LEFT
)
86 // For some strange reason we have to set the WB_DIALOGCONTROL at
87 // the content window in order to have it pass focus to its content
88 // window. Without setting this flag here that works only on views
89 // that have not been taken from the cash and relocated to this pane
91 GetContentWindow().SetStyle(GetContentWindow().GetStyle() | WB_DIALOGCONTROL
);
92 GetContentWindow().GrabFocus();
94 SfxDockingWindow::MouseButtonDown(rEvent
);
97 void PaneDockingWindow::SetValidSizeRange (const Range
& rValidSizeRange
)
99 SplitWindow
* pSplitWindow
= dynamic_cast<SplitWindow
*>(GetParent());
100 if (pSplitWindow
!= nullptr)
102 const sal_uInt16
nId (pSplitWindow
->GetItemId(static_cast< vcl::Window
*>(this)));
103 const sal_uInt16
nSetId (pSplitWindow
->GetSet(nId
));
104 // Because the PaneDockingWindow paints its own decoration, we have
105 // to compensate the valid size range for that.
106 const SvBorder
aBorder (GetDecorationBorder());
107 sal_Int32
nCompensation (pSplitWindow
->IsHorizontal()
108 ? aBorder
.Top() + aBorder
.Bottom()
109 : aBorder
.Left() + aBorder
.Right());
110 pSplitWindow
->SetItemSizeRange(
113 rValidSizeRange
.Min() + nCompensation
,
114 rValidSizeRange
.Max() + nCompensation
));
118 PaneDockingWindow::Orientation
PaneDockingWindow::GetOrientation() const
120 SplitWindow
* pSplitWindow
= dynamic_cast<SplitWindow
*>(GetParent());
121 if (pSplitWindow
== nullptr)
122 return UnknownOrientation
;
123 else if (pSplitWindow
->IsHorizontal())
124 return HorizontalOrientation
;
126 return VerticalOrientation
;
129 } // end of namespace ::sd
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */