1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 
31 #include "PaneDockingWindow.hxx"
32 #include "Window.hxx"
33 #include "ViewShellBase.hxx"
34 #include "framework/FrameworkHelper.hxx"
35 #include "sdresid.hxx"
36 #include "res_bmp.hrc"
37 #include <sfx2/dispatch.hxx>
38 #include <vcl/toolbox.hxx>
39 #include <vcl/taskpanelist.hxx>
40 #include <vcl/splitwin.hxx>
41 #include <vcl/svapp.hxx>
42 #include <tools/wintypes.hxx>
43 #include <boost/bind.hpp>
44 
45 using namespace ::com::sun::star;
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::drawing::framework;
48 using ::sfx2::TitledDockingWindow;
49 
50 namespace sd {
51 
52 PaneDockingWindow::PaneDockingWindow(
53         SfxBindings *_pBindings, SfxChildWindow *pChildWindow, ::Window* pParent,
54         const ResId& rResId, const ::rtl::OUString& rsTitle )
55         :TitledDockingWindow( _pBindings, pChildWindow, pParent, rResId )
56 {
57     SetTitle( rsTitle );
58 }
59 
60 PaneDockingWindow::~PaneDockingWindow (void)
61 {
62 }
63 
64 void PaneDockingWindow::StateChanged( StateChangedType nType )
65 {
66     switch (nType)
67     {
68         case STATE_CHANGE_INITSHOW:
69             Resize();
70             GetContentWindow().SetStyle(GetContentWindow().GetStyle() | WB_DIALOGCONTROL);
71             break;
72 
73         case STATE_CHANGE_VISIBLE:
74             // The visibility of the docking window has changed.  Tell the
75             // ConfigurationController so that it can activate or deactivate
76             // a/the view for the pane.
77             // Without this the side panes remain empty after closing an
78             // in-place slide show.
79             ViewShellBase* pBase = ViewShellBase::GetViewShellBase(
80                 GetBindings().GetDispatcher()->GetFrame());
81             if (pBase != NULL)
82             {
83                 framework::FrameworkHelper::Instance(*pBase)->UpdateConfiguration();
84             }
85             break;
86     }
87     SfxDockingWindow::StateChanged (nType);
88 }
89 
90 void PaneDockingWindow::MouseButtonDown (const MouseEvent& rEvent)
91 {
92     if (rEvent.GetButtons() == MOUSE_LEFT)
93     {
94         // For some strange reason we have to set the WB_DIALOGCONTROL at
95         // the content window in order to have it pass focus to its content
96         // window.  Without setting this flag here that works only on views
97         // that have not been taken from the cash and relocated to this pane
98         // docking window.
99         GetContentWindow().SetStyle(GetContentWindow().GetStyle() | WB_DIALOGCONTROL);
100         GetContentWindow().GrabFocus();
101     }
102     SfxDockingWindow::MouseButtonDown(rEvent);
103 }
104 
105 
106 
107 
108 
109 
110 
111 
112 void PaneDockingWindow::SetValidSizeRange (const Range aValidSizeRange)
113 {
114     SplitWindow* pSplitWindow = dynamic_cast<SplitWindow*>(GetParent());
115     if (pSplitWindow != NULL)
116     {
117         const sal_uInt16 nId (pSplitWindow->GetItemId(static_cast< ::Window*>(this)));
118         const sal_uInt16 nSetId (pSplitWindow->GetSet(nId));
119         // Because the PaneDockingWindow paints its own decoration, we have
120         // to compensate the valid size range for that.
121         const SvBorder aBorder (GetDecorationBorder());
122         sal_Int32 nCompensation (pSplitWindow->IsHorizontal()
123             ? mnTitleBarHeight + aBorder.Top() + aBorder.Bottom()
124             : aBorder.Left() + aBorder.Right());
125         pSplitWindow->SetItemSizeRange(
126             nSetId,
127             Range(
128                 aValidSizeRange.Min() + nCompensation,
129                 aValidSizeRange.Max() + nCompensation));
130     }
131 }
132 
133 
134 
135 
136 PaneDockingWindow::Orientation PaneDockingWindow::GetOrientation (void) const
137 {
138     SplitWindow* pSplitWindow = dynamic_cast<SplitWindow*>(GetParent());
139     if (pSplitWindow == NULL)
140         return UnknownOrientation;
141     else if (pSplitWindow->IsHorizontal())
142         return HorizontalOrientation;
143     else
144         return VerticalOrientation;
145 }
146 
147 } // end of namespace ::sd
148