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