xref: /trunk/main/vcl/source/window/dockmgr.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
19f62ea84SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
39f62ea84SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
49f62ea84SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
59f62ea84SAndrew Rist  * distributed with this work for additional information
69f62ea84SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
79f62ea84SAndrew Rist  * to you under the Apache License, Version 2.0 (the
89f62ea84SAndrew Rist  * "License"); you may not use this file except in compliance
99f62ea84SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
119f62ea84SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
139f62ea84SAndrew Rist  * Unless required by applicable law or agreed to in writing,
149f62ea84SAndrew Rist  * software distributed under the License is distributed on an
159f62ea84SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169f62ea84SAndrew Rist  * KIND, either express or implied.  See the License for the
179f62ea84SAndrew Rist  * specific language governing permissions and limitations
189f62ea84SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
209f62ea84SAndrew Rist  *************************************************************/
219f62ea84SAndrew Rist 
229f62ea84SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <tools/time.hxx>
28cdf0e10cSrcweir #ifndef _SV_RC_H
29cdf0e10cSrcweir #include <tools/rc.h>
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <brdwin.hxx>
33cdf0e10cSrcweir #include <svdata.hxx>
34cdf0e10cSrcweir #include <salframe.hxx>
35cdf0e10cSrcweir #include <window.h>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include <vcl/event.hxx>
38cdf0e10cSrcweir #include <vcl/floatwin.hxx>
39cdf0e10cSrcweir #include <vcl/dockwin.hxx>
40cdf0e10cSrcweir #include <vcl/toolbox.hxx>
41cdf0e10cSrcweir #include <vcl/svapp.hxx>
42cdf0e10cSrcweir #include <vcl/timer.hxx>
43cdf0e10cSrcweir #include <vcl/lineinfo.hxx>
44cdf0e10cSrcweir #include <vcl/unowrap.hxx>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir 
47cdf0e10cSrcweir // =======================================================================
48cdf0e10cSrcweir 
49cdf0e10cSrcweir #define DOCKWIN_FLOATSTYLES         (WB_SIZEABLE | WB_MOVEABLE | WB_CLOSEABLE | WB_STANDALONE | WB_PINABLE | WB_ROLLABLE )
50cdf0e10cSrcweir 
51cdf0e10cSrcweir // =======================================================================
52cdf0e10cSrcweir 
53cdf0e10cSrcweir 
54cdf0e10cSrcweir // =======================================================================
55cdf0e10cSrcweir 
56cdf0e10cSrcweir class ImplDockFloatWin2 : public FloatingWindow
57cdf0e10cSrcweir {
58cdf0e10cSrcweir private:
59cdf0e10cSrcweir     ImplDockingWindowWrapper*  mpDockWin;
60cdf0e10cSrcweir     sal_uLong           mnLastTicks;
61cdf0e10cSrcweir     Timer           maDockTimer;
62cdf0e10cSrcweir     Timer           maEndDockTimer;
63cdf0e10cSrcweir     Point           maDockPos;
64cdf0e10cSrcweir     Rectangle       maDockRect;
65cdf0e10cSrcweir     sal_Bool            mbInMove;
66cdf0e10cSrcweir     sal_uLong           mnLastUserEvent;
67cdf0e10cSrcweir 
68cdf0e10cSrcweir     DECL_LINK( DockingHdl, ImplDockFloatWin2* );
69cdf0e10cSrcweir     DECL_LINK( DockTimerHdl, ImplDockFloatWin2* );
70cdf0e10cSrcweir     DECL_LINK( EndDockTimerHdl, ImplDockFloatWin2* );
71cdf0e10cSrcweir public:
72cdf0e10cSrcweir     ImplDockFloatWin2( Window* pParent, WinBits nWinBits,
73cdf0e10cSrcweir                       ImplDockingWindowWrapper* pDockingWin );
74cdf0e10cSrcweir     ~ImplDockFloatWin2();
75cdf0e10cSrcweir 
76cdf0e10cSrcweir     virtual void    Move();
77cdf0e10cSrcweir     virtual void    Resize();
78cdf0e10cSrcweir     virtual void    TitleButtonClick( sal_uInt16 nButton );
79cdf0e10cSrcweir     virtual void    Pin();
80cdf0e10cSrcweir     virtual void    Roll();
81cdf0e10cSrcweir     virtual void    PopupModeEnd();
82cdf0e10cSrcweir     virtual void    Resizing( Size& rSize );
83cdf0e10cSrcweir     virtual sal_Bool    Close();
84cdf0e10cSrcweir     using Window::SetPosSizePixel;
85cdf0e10cSrcweir     virtual void    SetPosSizePixel( long nX, long nY,
86cdf0e10cSrcweir                                      long nWidth, long nHeight,
87cdf0e10cSrcweir                                      sal_uInt16 nFlags = WINDOW_POSSIZE_ALL );
88cdf0e10cSrcweir 
GetLastTicks() const89cdf0e10cSrcweir     sal_uLong GetLastTicks() const { return mnLastTicks; }
90cdf0e10cSrcweir };
91cdf0e10cSrcweir 
92cdf0e10cSrcweir // =======================================================================
93cdf0e10cSrcweir 
ImplDockFloatWin2(Window * pParent,WinBits nWinBits,ImplDockingWindowWrapper * pDockingWin)94cdf0e10cSrcweir ImplDockFloatWin2::ImplDockFloatWin2( Window* pParent, WinBits nWinBits,
95cdf0e10cSrcweir                                     ImplDockingWindowWrapper* pDockingWin ) :
96cdf0e10cSrcweir         FloatingWindow( pParent, nWinBits ),
97cdf0e10cSrcweir         mpDockWin( pDockingWin ),
98cdf0e10cSrcweir         mnLastTicks( Time::GetSystemTicks() ),
99cdf0e10cSrcweir         mbInMove( sal_False ),
100cdf0e10cSrcweir         mnLastUserEvent( 0 )
101cdf0e10cSrcweir {
102cdf0e10cSrcweir     // Daten vom DockingWindow uebernehmen
103cdf0e10cSrcweir     if ( pDockingWin )
104cdf0e10cSrcweir     {
105cdf0e10cSrcweir         SetSettings( pDockingWin->GetWindow()->GetSettings() );
106cdf0e10cSrcweir         Enable( pDockingWin->GetWindow()->IsEnabled(), sal_False );
107cdf0e10cSrcweir         EnableInput( pDockingWin->GetWindow()->IsInputEnabled(), sal_False );
108cdf0e10cSrcweir         AlwaysEnableInput( pDockingWin->GetWindow()->IsAlwaysEnableInput(), sal_False );
109cdf0e10cSrcweir         EnableAlwaysOnTop( pDockingWin->GetWindow()->IsAlwaysOnTopEnabled() );
110cdf0e10cSrcweir         SetActivateMode( pDockingWin->GetWindow()->GetActivateMode() );
111cdf0e10cSrcweir     }
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     SetBackground( GetSettings().GetStyleSettings().GetFaceColor() );
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     maDockTimer.SetTimeoutHdl( LINK( this, ImplDockFloatWin2, DockTimerHdl ) );
116cdf0e10cSrcweir     maDockTimer.SetTimeout( 50 );
117cdf0e10cSrcweir     maEndDockTimer.SetTimeoutHdl( LINK( this, ImplDockFloatWin2, EndDockTimerHdl ) );
118cdf0e10cSrcweir     maEndDockTimer.SetTimeout( 50 );
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir // -----------------------------------------------------------------------
122cdf0e10cSrcweir 
~ImplDockFloatWin2()123cdf0e10cSrcweir ImplDockFloatWin2::~ImplDockFloatWin2()
124cdf0e10cSrcweir {
125cdf0e10cSrcweir     if( mnLastUserEvent )
126cdf0e10cSrcweir         Application::RemoveUserEvent( mnLastUserEvent );
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
129cdf0e10cSrcweir // -----------------------------------------------------------------------
130cdf0e10cSrcweir 
IMPL_LINK(ImplDockFloatWin2,DockTimerHdl,ImplDockFloatWin2 *,EMPTYARG)131cdf0e10cSrcweir IMPL_LINK( ImplDockFloatWin2, DockTimerHdl, ImplDockFloatWin2*, EMPTYARG )
132cdf0e10cSrcweir {
133cdf0e10cSrcweir     DBG_ASSERT( mpDockWin->IsFloatingMode(), "docktimer called but not floating" );
134cdf0e10cSrcweir 
135cdf0e10cSrcweir     maDockTimer.Stop();
136cdf0e10cSrcweir     PointerState aState = GetPointerState();
137cdf0e10cSrcweir 
138cdf0e10cSrcweir     if( aState.mnState & KEY_MOD1 )
139cdf0e10cSrcweir     {
140cdf0e10cSrcweir         // i43499 CTRL disables docking now
141cdf0e10cSrcweir         mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
142cdf0e10cSrcweir         if( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) )
143cdf0e10cSrcweir             maDockTimer.Start();
144cdf0e10cSrcweir     }
145cdf0e10cSrcweir     else if( ! ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) )
146cdf0e10cSrcweir     {
147cdf0e10cSrcweir         mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
148cdf0e10cSrcweir         mpDockWin->EndDocking( maDockRect, sal_False );
149cdf0e10cSrcweir     }
150cdf0e10cSrcweir     else
151cdf0e10cSrcweir     {
152cdf0e10cSrcweir         mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect, SHOWTRACK_BIG | SHOWTRACK_WINDOW );
153cdf0e10cSrcweir         maDockTimer.Start();
154cdf0e10cSrcweir     }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir     return 0;
157cdf0e10cSrcweir }
158cdf0e10cSrcweir 
IMPL_LINK(ImplDockFloatWin2,EndDockTimerHdl,ImplDockFloatWin2 *,EMPTYARG)159cdf0e10cSrcweir IMPL_LINK( ImplDockFloatWin2, EndDockTimerHdl, ImplDockFloatWin2*, EMPTYARG )
160cdf0e10cSrcweir {
161cdf0e10cSrcweir     DBG_ASSERT( mpDockWin->IsFloatingMode(), "enddocktimer called but not floating" );
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     maEndDockTimer.Stop();
164cdf0e10cSrcweir     PointerState aState = GetPointerState();
165cdf0e10cSrcweir     if( ! ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) )
166cdf0e10cSrcweir     {
167cdf0e10cSrcweir         mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
168cdf0e10cSrcweir         mpDockWin->EndDocking( maDockRect, sal_True );
169cdf0e10cSrcweir     }
170cdf0e10cSrcweir     else
171cdf0e10cSrcweir     {
172cdf0e10cSrcweir         maEndDockTimer.Start();
173cdf0e10cSrcweir     }
174cdf0e10cSrcweir 
175cdf0e10cSrcweir     return 0;
176cdf0e10cSrcweir }
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 
IMPL_LINK(ImplDockFloatWin2,DockingHdl,ImplDockFloatWin2 *,EMPTYARG)179cdf0e10cSrcweir IMPL_LINK( ImplDockFloatWin2, DockingHdl, ImplDockFloatWin2*, EMPTYARG )
180cdf0e10cSrcweir {
181cdf0e10cSrcweir     // called during move of a floating window
182cdf0e10cSrcweir     mnLastUserEvent = 0;
183cdf0e10cSrcweir 
184cdf0e10cSrcweir     Window *pDockingArea = mpDockWin->GetWindow()->GetParent();
185cdf0e10cSrcweir     PointerState aState = pDockingArea->GetPointerState();
186cdf0e10cSrcweir 
187cdf0e10cSrcweir     sal_Bool bRealMove = sal_True;
188cdf0e10cSrcweir     if( GetStyle() & WB_OWNERDRAWDECORATION )
189cdf0e10cSrcweir     {
190cdf0e10cSrcweir         // for windows with ownerdraw decoration
191cdf0e10cSrcweir         // we allow docking only when the window was moved
192cdf0e10cSrcweir         // by dragging its caption
193cdf0e10cSrcweir         // and ignore move request due to resizing
194cdf0e10cSrcweir         Window *pBorder = GetWindow( WINDOW_BORDER );
195cdf0e10cSrcweir         if( pBorder != this )
196cdf0e10cSrcweir         {
197cdf0e10cSrcweir             Point aPt;
198cdf0e10cSrcweir             Rectangle aBorderRect( aPt, pBorder->GetSizePixel() );
199cdf0e10cSrcweir             sal_Int32 nLeft, nTop, nRight, nBottom;
200cdf0e10cSrcweir             GetBorder( nLeft, nTop, nRight, nBottom );
201cdf0e10cSrcweir             // limit borderrect to the caption part only and without the resizing borders
202cdf0e10cSrcweir             aBorderRect.nBottom = aBorderRect.nTop + nTop;
203cdf0e10cSrcweir             aBorderRect.nLeft += nLeft;
204cdf0e10cSrcweir             aBorderRect.nRight -= nRight;
205cdf0e10cSrcweir 
206cdf0e10cSrcweir             PointerState aBorderState = pBorder->GetPointerState();
207cdf0e10cSrcweir             if( aBorderRect.IsInside( aBorderState.maPos ) )
208cdf0e10cSrcweir                 bRealMove = sal_True;
209cdf0e10cSrcweir             else
210cdf0e10cSrcweir                 bRealMove = sal_False;
211cdf0e10cSrcweir         }
212cdf0e10cSrcweir     }
213cdf0e10cSrcweir 
214cdf0e10cSrcweir     if( mpDockWin->IsDockable() &&
215cdf0e10cSrcweir         mpDockWin->GetWindow()->IsVisible() &&
216cdf0e10cSrcweir         (Time::GetSystemTicks() - mnLastTicks > 500) &&
217cdf0e10cSrcweir         ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) &&
218cdf0e10cSrcweir         !(aState.mnState & KEY_MOD1) && // i43499 CTRL disables docking now
219cdf0e10cSrcweir         bRealMove )
220cdf0e10cSrcweir     {
221cdf0e10cSrcweir         maDockPos = Point( pDockingArea->OutputToScreenPixel( pDockingArea->AbsoluteScreenToOutputPixel( OutputToAbsoluteScreenPixel( Point() ) ) ) );
222cdf0e10cSrcweir         maDockRect = Rectangle( maDockPos, mpDockWin->GetSizePixel() );
223cdf0e10cSrcweir 
224cdf0e10cSrcweir         // mouse pos in screen pixels
225cdf0e10cSrcweir         Point aMousePos = pDockingArea->OutputToScreenPixel( aState.maPos );
226cdf0e10cSrcweir 
227cdf0e10cSrcweir         if( ! mpDockWin->IsDocking() )
228cdf0e10cSrcweir             mpDockWin->StartDocking( aMousePos, maDockRect );
229cdf0e10cSrcweir 
230cdf0e10cSrcweir         sal_Bool bFloatMode = mpDockWin->Docking( aMousePos, maDockRect );
231cdf0e10cSrcweir 
232cdf0e10cSrcweir         if( ! bFloatMode )
233cdf0e10cSrcweir         {
234cdf0e10cSrcweir             // indicates that the window could be docked at maDockRect
235cdf0e10cSrcweir             maDockRect.SetPos( mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->ScreenToOutputPixel(
236cdf0e10cSrcweir                  maDockRect.TopLeft() ) );
237cdf0e10cSrcweir             mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect, SHOWTRACK_BIG | SHOWTRACK_WINDOW );
238cdf0e10cSrcweir             maEndDockTimer.Stop();
239cdf0e10cSrcweir             DockTimerHdl( this );
240cdf0e10cSrcweir         }
241cdf0e10cSrcweir         else
242cdf0e10cSrcweir         {
243cdf0e10cSrcweir             mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
244cdf0e10cSrcweir             maDockTimer.Stop();
245cdf0e10cSrcweir             EndDockTimerHdl( this );
246cdf0e10cSrcweir         }
247cdf0e10cSrcweir     }
248cdf0e10cSrcweir     mbInMove = sal_False;
249cdf0e10cSrcweir     return 0;
250cdf0e10cSrcweir }
251cdf0e10cSrcweir // -----------------------------------------------------------------------
252cdf0e10cSrcweir 
Move()253cdf0e10cSrcweir void ImplDockFloatWin2::Move()
254cdf0e10cSrcweir {
255cdf0e10cSrcweir     if( mbInMove )
256cdf0e10cSrcweir         return;
257cdf0e10cSrcweir 
258cdf0e10cSrcweir     mbInMove = sal_True;
259cdf0e10cSrcweir     FloatingWindow::Move();
260cdf0e10cSrcweir     mpDockWin->GetWindow()->Move();
261cdf0e10cSrcweir 
262cdf0e10cSrcweir     /*
263cdf0e10cSrcweir      *  note: the window should only dock if KEY_MOD1 is pressed
264cdf0e10cSrcweir      *  and the user releases all mouse buttons. The real problem here
265cdf0e10cSrcweir      *  is that we don't get mouse events (at least not on X)
266cdf0e10cSrcweir      *  if the mouse is on the decoration. So we have to start an
267cdf0e10cSrcweir      *  awkward timer based process that polls the modifier/buttons
268cdf0e10cSrcweir      *  to see whether they are in the right condition shortly after the
269cdf0e10cSrcweir      *  last Move message.
270cdf0e10cSrcweir      */
271cdf0e10cSrcweir     if( ! mnLastUserEvent )
272cdf0e10cSrcweir         mnLastUserEvent = Application::PostUserEvent( LINK( this, ImplDockFloatWin2, DockingHdl ) );
273cdf0e10cSrcweir }
274cdf0e10cSrcweir 
275cdf0e10cSrcweir // -----------------------------------------------------------------------
276cdf0e10cSrcweir 
Resize()277cdf0e10cSrcweir void ImplDockFloatWin2::Resize()
278cdf0e10cSrcweir {
279cdf0e10cSrcweir     // forwarding of resize only required if we have no borderwindow ( GetWindow() then returns 'this' )
280cdf0e10cSrcweir     if( GetWindow( WINDOW_BORDER ) == this )
281cdf0e10cSrcweir     {
282cdf0e10cSrcweir         FloatingWindow::Resize();
283cdf0e10cSrcweir         Size aSize( GetSizePixel() );
284cdf0e10cSrcweir         mpDockWin->GetWindow()->ImplPosSizeWindow( 0, 0, aSize.Width(), aSize.Height(), WINDOW_POSSIZE_POSSIZE ); // is this needed ???
285cdf0e10cSrcweir     }
286cdf0e10cSrcweir }
287cdf0e10cSrcweir 
SetPosSizePixel(long nX,long nY,long nWidth,long nHeight,sal_uInt16 nFlags)288cdf0e10cSrcweir void ImplDockFloatWin2::SetPosSizePixel( long nX, long nY,
289cdf0e10cSrcweir                                      long nWidth, long nHeight,
290cdf0e10cSrcweir                                      sal_uInt16 nFlags )
291cdf0e10cSrcweir {
292cdf0e10cSrcweir     FloatingWindow::SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
293cdf0e10cSrcweir }
294cdf0e10cSrcweir 
295cdf0e10cSrcweir // -----------------------------------------------------------------------
296cdf0e10cSrcweir 
297cdf0e10cSrcweir 
TitleButtonClick(sal_uInt16 nButton)298cdf0e10cSrcweir void ImplDockFloatWin2::TitleButtonClick( sal_uInt16 nButton )
299cdf0e10cSrcweir {
300cdf0e10cSrcweir     FloatingWindow::TitleButtonClick( nButton );
301cdf0e10cSrcweir     mpDockWin->TitleButtonClick( nButton );
302cdf0e10cSrcweir }
303cdf0e10cSrcweir 
304cdf0e10cSrcweir // -----------------------------------------------------------------------
305cdf0e10cSrcweir 
Pin()306cdf0e10cSrcweir void ImplDockFloatWin2::Pin()
307cdf0e10cSrcweir {
308cdf0e10cSrcweir     FloatingWindow::Pin();
309cdf0e10cSrcweir     mpDockWin->Pin();
310cdf0e10cSrcweir }
311cdf0e10cSrcweir 
312cdf0e10cSrcweir // -----------------------------------------------------------------------
313cdf0e10cSrcweir 
Roll()314cdf0e10cSrcweir void ImplDockFloatWin2::Roll()
315cdf0e10cSrcweir {
316cdf0e10cSrcweir     FloatingWindow::Roll();
317cdf0e10cSrcweir     mpDockWin->Roll();
318cdf0e10cSrcweir }
319cdf0e10cSrcweir 
320cdf0e10cSrcweir // -----------------------------------------------------------------------
321cdf0e10cSrcweir 
PopupModeEnd()322cdf0e10cSrcweir void ImplDockFloatWin2::PopupModeEnd()
323cdf0e10cSrcweir {
324cdf0e10cSrcweir     FloatingWindow::PopupModeEnd();
325cdf0e10cSrcweir     mpDockWin->PopupModeEnd();
326cdf0e10cSrcweir }
327cdf0e10cSrcweir 
328cdf0e10cSrcweir // -----------------------------------------------------------------------
329cdf0e10cSrcweir 
Resizing(Size & rSize)330cdf0e10cSrcweir void ImplDockFloatWin2::Resizing( Size& rSize )
331cdf0e10cSrcweir {
332cdf0e10cSrcweir     FloatingWindow::Resizing( rSize );
333cdf0e10cSrcweir     mpDockWin->Resizing( rSize );
334cdf0e10cSrcweir }
335cdf0e10cSrcweir 
336cdf0e10cSrcweir // -----------------------------------------------------------------------
337cdf0e10cSrcweir 
Close()338cdf0e10cSrcweir sal_Bool ImplDockFloatWin2::Close()
339cdf0e10cSrcweir {
340cdf0e10cSrcweir     return mpDockWin->Close();
341cdf0e10cSrcweir }
342cdf0e10cSrcweir 
343cdf0e10cSrcweir // =======================================================================
344cdf0e10cSrcweir 
DockingManager()345cdf0e10cSrcweir DockingManager::DockingManager()
346cdf0e10cSrcweir {
347cdf0e10cSrcweir }
348cdf0e10cSrcweir 
~DockingManager()349cdf0e10cSrcweir DockingManager::~DockingManager()
350cdf0e10cSrcweir {
351cdf0e10cSrcweir     ::std::vector< ImplDockingWindowWrapper* >::iterator p;
352cdf0e10cSrcweir     p = mDockingWindows.begin();
353cdf0e10cSrcweir     for(; p != mDockingWindows.end(); ++p )
354cdf0e10cSrcweir     {
355cdf0e10cSrcweir         delete (*p);
356cdf0e10cSrcweir     }
357cdf0e10cSrcweir     mDockingWindows.clear();
358cdf0e10cSrcweir }
359cdf0e10cSrcweir 
GetDockingWindowWrapper(const Window * pWindow)360cdf0e10cSrcweir ImplDockingWindowWrapper* DockingManager::GetDockingWindowWrapper( const Window *pWindow )
361cdf0e10cSrcweir {
362cdf0e10cSrcweir     ::std::vector< ImplDockingWindowWrapper* >::iterator p;
363cdf0e10cSrcweir     p = mDockingWindows.begin();
364cdf0e10cSrcweir     while( p != mDockingWindows.end() )
365cdf0e10cSrcweir     {
366cdf0e10cSrcweir         if( (*p)->mpDockingWindow == pWindow )
367cdf0e10cSrcweir             return (*p);
368cdf0e10cSrcweir         else
369cdf0e10cSrcweir             p++;
370cdf0e10cSrcweir     }
371cdf0e10cSrcweir     return NULL;
372cdf0e10cSrcweir }
373cdf0e10cSrcweir 
IsDockable(const Window * pWindow)374cdf0e10cSrcweir sal_Bool DockingManager::IsDockable( const Window *pWindow )
375cdf0e10cSrcweir {
376cdf0e10cSrcweir     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
377cdf0e10cSrcweir 
378cdf0e10cSrcweir     /*
379cdf0e10cSrcweir     if( pWindow->HasDockingHandler() )
380cdf0e10cSrcweir         return sal_True;
381cdf0e10cSrcweir     */
382cdf0e10cSrcweir     return (pWrapper != NULL);
383cdf0e10cSrcweir }
384cdf0e10cSrcweir 
IsFloating(const Window * pWindow)385cdf0e10cSrcweir sal_Bool DockingManager::IsFloating( const Window *pWindow )
386cdf0e10cSrcweir {
387cdf0e10cSrcweir     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
388cdf0e10cSrcweir     if( pWrapper )
389cdf0e10cSrcweir         return pWrapper->IsFloatingMode();
390cdf0e10cSrcweir     else
391cdf0e10cSrcweir         return sal_False;
392cdf0e10cSrcweir }
393cdf0e10cSrcweir 
IsLocked(const Window * pWindow)394cdf0e10cSrcweir sal_Bool DockingManager::IsLocked( const Window *pWindow )
395cdf0e10cSrcweir {
396cdf0e10cSrcweir     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
397cdf0e10cSrcweir     if( pWrapper && pWrapper->IsLocked() )
398cdf0e10cSrcweir         return sal_True;
399cdf0e10cSrcweir     else
400cdf0e10cSrcweir         return sal_False;
401cdf0e10cSrcweir }
402cdf0e10cSrcweir 
Lock(const Window * pWindow)403cdf0e10cSrcweir void DockingManager::Lock( const Window *pWindow )
404cdf0e10cSrcweir {
405cdf0e10cSrcweir     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
406cdf0e10cSrcweir     if( pWrapper )
407cdf0e10cSrcweir         pWrapper->Lock();
408cdf0e10cSrcweir }
409cdf0e10cSrcweir 
Unlock(const Window * pWindow)410cdf0e10cSrcweir void DockingManager::Unlock( const Window *pWindow )
411cdf0e10cSrcweir {
412cdf0e10cSrcweir     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
413cdf0e10cSrcweir     if( pWrapper )
414cdf0e10cSrcweir         pWrapper->Unlock();
415cdf0e10cSrcweir }
416cdf0e10cSrcweir 
SetFloatingMode(const Window * pWindow,sal_Bool bFloating)417cdf0e10cSrcweir void DockingManager::SetFloatingMode( const Window *pWindow, sal_Bool bFloating )
418cdf0e10cSrcweir {
419cdf0e10cSrcweir     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
420cdf0e10cSrcweir     if( pWrapper )
421cdf0e10cSrcweir         pWrapper->SetFloatingMode( bFloating );
422cdf0e10cSrcweir }
423cdf0e10cSrcweir 
StartPopupMode(ToolBox * pParentToolBox,const Window * pWindow,sal_uLong nFlags)424cdf0e10cSrcweir void DockingManager::StartPopupMode( ToolBox *pParentToolBox, const Window *pWindow, sal_uLong nFlags )
425cdf0e10cSrcweir {
426cdf0e10cSrcweir     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
427cdf0e10cSrcweir     if( pWrapper )
428cdf0e10cSrcweir         pWrapper->StartPopupMode( pParentToolBox, nFlags );
429cdf0e10cSrcweir }
430cdf0e10cSrcweir 
StartPopupMode(ToolBox * pParentToolBox,const Window * pWindow)431cdf0e10cSrcweir void DockingManager::StartPopupMode( ToolBox *pParentToolBox, const Window *pWindow )
432cdf0e10cSrcweir {
433cdf0e10cSrcweir     StartPopupMode( pParentToolBox, pWindow, FLOATWIN_POPUPMODE_ALLOWTEAROFF         |
434cdf0e10cSrcweir                     FLOATWIN_POPUPMODE_NOFOCUSCLOSE         |
435cdf0e10cSrcweir                     FLOATWIN_POPUPMODE_ALLMOUSEBUTTONCLOSE  |
436cdf0e10cSrcweir                     FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE );
437cdf0e10cSrcweir }
438cdf0e10cSrcweir 
IsInPopupMode(const Window * pWindow)439cdf0e10cSrcweir sal_Bool DockingManager::IsInPopupMode( const Window *pWindow )
440cdf0e10cSrcweir {
441cdf0e10cSrcweir     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
442cdf0e10cSrcweir     if( pWrapper && pWrapper->IsInPopupMode() )
443cdf0e10cSrcweir         return sal_True;
444cdf0e10cSrcweir     else
445cdf0e10cSrcweir         return sal_False;
446cdf0e10cSrcweir }
447cdf0e10cSrcweir 
448cdf0e10cSrcweir // -----------------------------------------------------------------------
449cdf0e10cSrcweir 
EndPopupMode(const Window * pWin)450cdf0e10cSrcweir void DockingManager::EndPopupMode( const Window *pWin )
451cdf0e10cSrcweir {
452cdf0e10cSrcweir     ImplDockingWindowWrapper *pWrapper = GetDockingWindowWrapper( pWin );
453cdf0e10cSrcweir     if( pWrapper && pWrapper->GetFloatingWindow() && pWrapper->GetFloatingWindow()->IsInPopupMode() )
454cdf0e10cSrcweir         pWrapper->GetFloatingWindow()->EndPopupMode();
455cdf0e10cSrcweir }
456cdf0e10cSrcweir 
457cdf0e10cSrcweir // -----------------------------------------------------------------------
458cdf0e10cSrcweir 
AddWindow(const Window * pWindow)459cdf0e10cSrcweir void DockingManager::AddWindow( const Window *pWindow )
460cdf0e10cSrcweir {
461cdf0e10cSrcweir     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
462cdf0e10cSrcweir     if( pWrapper )
463cdf0e10cSrcweir         return;
464cdf0e10cSrcweir     else
465cdf0e10cSrcweir         pWrapper = new ImplDockingWindowWrapper( pWindow );
466cdf0e10cSrcweir 
467cdf0e10cSrcweir     mDockingWindows.push_back( pWrapper );
468cdf0e10cSrcweir }
469cdf0e10cSrcweir 
RemoveWindow(const Window * pWindow)470cdf0e10cSrcweir void DockingManager::RemoveWindow( const Window *pWindow )
471cdf0e10cSrcweir {
472cdf0e10cSrcweir     ::std::vector< ImplDockingWindowWrapper* >::iterator p;
473cdf0e10cSrcweir     p = mDockingWindows.begin();
474cdf0e10cSrcweir     while( p != mDockingWindows.end() )
475cdf0e10cSrcweir     {
476cdf0e10cSrcweir         if( (*p)->mpDockingWindow == pWindow )
477cdf0e10cSrcweir         {
478cdf0e10cSrcweir             delete (*p);
479cdf0e10cSrcweir             mDockingWindows.erase( p );
480cdf0e10cSrcweir             break;
481cdf0e10cSrcweir         }
482cdf0e10cSrcweir         else
483cdf0e10cSrcweir             p++;
484cdf0e10cSrcweir     }
485cdf0e10cSrcweir }
486cdf0e10cSrcweir 
SetPosSizePixel(Window * pWindow,long nX,long nY,long nWidth,long nHeight,sal_uInt16 nFlags)487cdf0e10cSrcweir void DockingManager::SetPosSizePixel( Window *pWindow, long nX, long nY,
488cdf0e10cSrcweir                                     long nWidth, long nHeight,
489cdf0e10cSrcweir                                     sal_uInt16 nFlags )
490cdf0e10cSrcweir {
491cdf0e10cSrcweir     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
492cdf0e10cSrcweir     if( pWrapper )
493cdf0e10cSrcweir         pWrapper->SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
494cdf0e10cSrcweir }
495cdf0e10cSrcweir 
GetPosSizePixel(const Window * pWindow)496cdf0e10cSrcweir Rectangle DockingManager::GetPosSizePixel( const Window *pWindow )
497cdf0e10cSrcweir {
498cdf0e10cSrcweir     Rectangle aRect;
499cdf0e10cSrcweir     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
500cdf0e10cSrcweir     if( pWrapper )
501cdf0e10cSrcweir         aRect = Rectangle( pWrapper->GetPosPixel(), pWrapper->GetSizePixel() );
502cdf0e10cSrcweir 
503cdf0e10cSrcweir     return aRect;
504cdf0e10cSrcweir }
505cdf0e10cSrcweir 
506cdf0e10cSrcweir // =======================================================================
507cdf0e10cSrcweir // special floating window for popup mode
508cdf0e10cSrcweir // main purpose: provides tear-off area for undocking
509cdf0e10cSrcweir // =======================================================================
510cdf0e10cSrcweir 
511cdf0e10cSrcweir // if TEAROFF_DASHED defined a single dashed line is used
512cdf0e10cSrcweir // otherwise multiple smaller lines will be painted
513cdf0e10cSrcweir //#define TEAROFF_DASHED
514cdf0e10cSrcweir 
515cdf0e10cSrcweir // size of the drag area
516cdf0e10cSrcweir #ifdef TEAROFF_DASHED
517cdf0e10cSrcweir #define POPUP_DRAGBORDER    2
518cdf0e10cSrcweir #define POPUP_DRAGGRIP      5
519cdf0e10cSrcweir #else
520cdf0e10cSrcweir #define POPUP_DRAGBORDER    3
521cdf0e10cSrcweir #define POPUP_DRAGGRIP      5
522cdf0e10cSrcweir #endif
523cdf0e10cSrcweir #define POPUP_DRAGHEIGHT    (POPUP_DRAGGRIP+POPUP_DRAGBORDER+POPUP_DRAGBORDER)
524cdf0e10cSrcweir #define POPUP_DRAGWIDTH     20
525cdf0e10cSrcweir 
526cdf0e10cSrcweir class ImplPopupFloatWin : public FloatingWindow
527cdf0e10cSrcweir {
528cdf0e10cSrcweir private:
529cdf0e10cSrcweir     ImplDockingWindowWrapper*   mpDockingWin;
530cdf0e10cSrcweir     sal_Bool                        mbHighlight;
531cdf0e10cSrcweir     sal_Bool                        mbMoving;
532cdf0e10cSrcweir     bool                        mbTrackingEnabled;
533cdf0e10cSrcweir     Point                       maDelta;
534cdf0e10cSrcweir     Point                       maTearOffPosition;
535cdf0e10cSrcweir     bool                        mbGripAtBottom;
536cdf0e10cSrcweir     bool                        mbHasGrip;
537cdf0e10cSrcweir     void                        ImplSetBorder();
538cdf0e10cSrcweir 
539cdf0e10cSrcweir public:
540cdf0e10cSrcweir     ImplPopupFloatWin( Window* pParent, ImplDockingWindowWrapper* pDockingWin, bool bHasGrip );
541cdf0e10cSrcweir     ~ImplPopupFloatWin();
542cdf0e10cSrcweir 
543cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
544cdf0e10cSrcweir     virtual void        Paint( const Rectangle& rRect );
545cdf0e10cSrcweir     virtual void        MouseMove( const MouseEvent& rMEvt );
546cdf0e10cSrcweir     virtual void        MouseButtonDown( const MouseEvent& rMEvt );
547cdf0e10cSrcweir     virtual void        MouseButtonUp( const MouseEvent& rMEvt );
548cdf0e10cSrcweir     virtual void        Tracking( const TrackingEvent& rTEvt );
549cdf0e10cSrcweir     virtual void        Resize();
550cdf0e10cSrcweir     virtual Window*     GetPreferredKeyInputWindow();
551cdf0e10cSrcweir 
552cdf0e10cSrcweir     Rectangle           GetDragRect() const;
553cdf0e10cSrcweir     Point               GetToolboxPosition() const;
554cdf0e10cSrcweir     Point               GetTearOffPosition() const;
555cdf0e10cSrcweir     void                DrawGrip();
556cdf0e10cSrcweir     void                DrawBorder();
557cdf0e10cSrcweir 
hasGrip() const558cdf0e10cSrcweir     bool                hasGrip() const { return mbHasGrip; }
559cdf0e10cSrcweir };
560cdf0e10cSrcweir 
ImplPopupFloatWin(Window * pParent,ImplDockingWindowWrapper * pDockingWin,bool bHasGrip)561cdf0e10cSrcweir ImplPopupFloatWin::ImplPopupFloatWin( Window* pParent, ImplDockingWindowWrapper* pDockingWin, bool bHasGrip ) :
562cdf0e10cSrcweir     FloatingWindow( pParent, WB_NOBORDER | WB_SYSTEMWINDOW | WB_NOSHADOW)
563cdf0e10cSrcweir {
564cdf0e10cSrcweir     mpWindowImpl->mbToolbarFloatingWindow = sal_True;   // indicate window type, required for accessibility
565cdf0e10cSrcweir                                                     // which should not see this window as a toplevel window
566cdf0e10cSrcweir     mpDockingWin = pDockingWin;
567cdf0e10cSrcweir     mbHighlight = sal_False;
568cdf0e10cSrcweir     mbMoving = sal_False;
569cdf0e10cSrcweir     mbTrackingEnabled = sal_False;
570cdf0e10cSrcweir     mbGripAtBottom = sal_True;
571cdf0e10cSrcweir     mbHasGrip = bHasGrip;
572cdf0e10cSrcweir 
573cdf0e10cSrcweir     ImplSetBorder();
574cdf0e10cSrcweir }
575cdf0e10cSrcweir 
~ImplPopupFloatWin()576cdf0e10cSrcweir ImplPopupFloatWin::~ImplPopupFloatWin()
577cdf0e10cSrcweir {
578cdf0e10cSrcweir     mpDockingWin = NULL;
579cdf0e10cSrcweir }
580cdf0e10cSrcweir 
CreateAccessible()581cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > ImplPopupFloatWin::CreateAccessible()
582cdf0e10cSrcweir {
583*ceb51a8eSJohn Bampton     // switch off direct accessibility support for this window
584cdf0e10cSrcweir 
585cdf0e10cSrcweir     // this is to avoid appearance of this window as standalone window in the accessibility hierarchy
586cdf0e10cSrcweir     // as this window is only used as a helper for subtoolbars that are not teared-off, the parent toolbar
587cdf0e10cSrcweir     // has to provide accessibility support (as implemented in the toolkit)
588*ceb51a8eSJohn Bampton     // so the contained toolbar should appear as child of the corresponding toolbar item of the parent toolbar
589cdf0e10cSrcweir     return ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >();
590cdf0e10cSrcweir }
591cdf0e10cSrcweir 
GetPreferredKeyInputWindow()592cdf0e10cSrcweir Window* ImplPopupFloatWin::GetPreferredKeyInputWindow()
593cdf0e10cSrcweir {
594cdf0e10cSrcweir     if( mpWindowImpl->mpClientWindow )
595cdf0e10cSrcweir         return mpWindowImpl->mpClientWindow;
596cdf0e10cSrcweir     else
597cdf0e10cSrcweir         return FloatingWindow::GetPreferredKeyInputWindow();
598cdf0e10cSrcweir }
599cdf0e10cSrcweir 
600cdf0e10cSrcweir 
ImplSetBorder()601cdf0e10cSrcweir void ImplPopupFloatWin::ImplSetBorder()
602cdf0e10cSrcweir {
603cdf0e10cSrcweir     // although we have no border in the sense of a borderwindow
604cdf0e10cSrcweir     //  we're using a special border for the grip
605cdf0e10cSrcweir     // by setting those members the method SetOutputSizePixel() can
606cdf0e10cSrcweir     //  be used to set the proper window size
607cdf0e10cSrcweir     mpWindowImpl->mnTopBorder     = 1;
608cdf0e10cSrcweir     if( hasGrip() )
609cdf0e10cSrcweir         mpWindowImpl->mnTopBorder += POPUP_DRAGHEIGHT+2;
610cdf0e10cSrcweir     mpWindowImpl->mnBottomBorder  = 1;
611cdf0e10cSrcweir     mpWindowImpl->mnLeftBorder    = 1;
612cdf0e10cSrcweir     mpWindowImpl->mnRightBorder   = 1;
613cdf0e10cSrcweir }
614cdf0e10cSrcweir 
Resize()615cdf0e10cSrcweir void ImplPopupFloatWin::Resize()
616cdf0e10cSrcweir {
617cdf0e10cSrcweir     // the borderview overwrites the border during resize so restore it
618cdf0e10cSrcweir     ImplSetBorder();
619cdf0e10cSrcweir }
620cdf0e10cSrcweir 
GetDragRect() const621cdf0e10cSrcweir Rectangle ImplPopupFloatWin::GetDragRect() const
622cdf0e10cSrcweir {
623cdf0e10cSrcweir     Rectangle aRect;
624cdf0e10cSrcweir     if( hasGrip() )
625cdf0e10cSrcweir     {
626cdf0e10cSrcweir         aRect = Rectangle( 1,1, GetOutputSizePixel().Width()-1, 2+POPUP_DRAGHEIGHT );
627cdf0e10cSrcweir         if( mbGripAtBottom )
628cdf0e10cSrcweir         {
629cdf0e10cSrcweir             int height = GetOutputSizePixel().Height();
630cdf0e10cSrcweir             aRect.Top() = height - 3 - POPUP_DRAGHEIGHT;
631cdf0e10cSrcweir             aRect.Bottom() = aRect.Top() + 1 + POPUP_DRAGHEIGHT;
632cdf0e10cSrcweir         }
633cdf0e10cSrcweir     }
634cdf0e10cSrcweir     return aRect;
635cdf0e10cSrcweir }
636cdf0e10cSrcweir 
GetToolboxPosition() const637cdf0e10cSrcweir Point ImplPopupFloatWin::GetToolboxPosition() const
638cdf0e10cSrcweir {
639cdf0e10cSrcweir     // return inner position where a toolbox could be placed
640cdf0e10cSrcweir     Point aPt( 1, 1 + ((mbGripAtBottom || !hasGrip()) ? 0 : GetDragRect().getHeight()) );    // grip + border
641cdf0e10cSrcweir 
642cdf0e10cSrcweir     return aPt;
643cdf0e10cSrcweir }
644cdf0e10cSrcweir 
GetTearOffPosition() const645cdf0e10cSrcweir Point ImplPopupFloatWin::GetTearOffPosition() const
646cdf0e10cSrcweir {
647cdf0e10cSrcweir     Point aPt( maTearOffPosition );
648cdf0e10cSrcweir     //aPt += GetToolboxPosition();    // remove 'decoration'
649cdf0e10cSrcweir     return aPt;
650cdf0e10cSrcweir }
651cdf0e10cSrcweir 
DrawBorder()652cdf0e10cSrcweir void ImplPopupFloatWin::DrawBorder()
653cdf0e10cSrcweir {
654cdf0e10cSrcweir     SetFillColor();
655cdf0e10cSrcweir     Point aPt;
656cdf0e10cSrcweir     Rectangle aRect( aPt, GetOutputSizePixel() );
657cdf0e10cSrcweir 
658cdf0e10cSrcweir     Region oldClipRgn( GetClipRegion( ) );
659cdf0e10cSrcweir     Region aClipRgn( aRect );
660cdf0e10cSrcweir     Rectangle aItemClipRect( ImplGetItemEdgeClipRect() );
661cdf0e10cSrcweir     if( !aItemClipRect.IsEmpty() )
662cdf0e10cSrcweir     {
663cdf0e10cSrcweir         aItemClipRect.SetPos( AbsoluteScreenToOutputPixel( aItemClipRect.TopLeft() ) );
664cdf0e10cSrcweir 
665cdf0e10cSrcweir         // draw the excluded border part with the background color of a toolbox
666cdf0e10cSrcweir         SetClipRegion( Region( aItemClipRect ) );
667cdf0e10cSrcweir         SetLineColor( GetSettings().GetStyleSettings().GetFaceColor() );
668cdf0e10cSrcweir         DrawRect( aRect );
669cdf0e10cSrcweir 
670cdf0e10cSrcweir         aClipRgn.Exclude( aItemClipRect );
671cdf0e10cSrcweir         SetClipRegion( aClipRgn );
672cdf0e10cSrcweir     }
673cdf0e10cSrcweir     SetLineColor( GetSettings().GetStyleSettings().GetShadowColor() );
674cdf0e10cSrcweir     DrawRect( aRect );
675cdf0e10cSrcweir     SetClipRegion( oldClipRgn );
676cdf0e10cSrcweir }
677cdf0e10cSrcweir 
DrawGrip()678cdf0e10cSrcweir void ImplPopupFloatWin::DrawGrip()
679cdf0e10cSrcweir {
680cdf0e10cSrcweir     sal_Bool bLinecolor     = IsLineColor();
681cdf0e10cSrcweir     Color aLinecolor    = GetLineColor();
682cdf0e10cSrcweir     sal_Bool bFillcolor     = IsFillColor();
683cdf0e10cSrcweir     Color aFillcolor    = GetFillColor();
684cdf0e10cSrcweir 
685cdf0e10cSrcweir     // draw background
686cdf0e10cSrcweir     Rectangle aRect( GetDragRect() );
687cdf0e10cSrcweir     aRect.nTop      += POPUP_DRAGBORDER;
688cdf0e10cSrcweir     aRect.nBottom   -= POPUP_DRAGBORDER;
689cdf0e10cSrcweir     aRect.nLeft+=3;
690cdf0e10cSrcweir     aRect.nRight-=3;
691cdf0e10cSrcweir 
692cdf0e10cSrcweir     if( mbHighlight )
693cdf0e10cSrcweir     {
694cdf0e10cSrcweir         Erase( aRect );
695cdf0e10cSrcweir         DrawSelectionBackground( aRect, 2, sal_False, sal_True, sal_False );
696cdf0e10cSrcweir     }
697cdf0e10cSrcweir     else
698cdf0e10cSrcweir     {
699cdf0e10cSrcweir         SetFillColor( GetSettings().GetStyleSettings().GetFaceColor() );
700cdf0e10cSrcweir         SetLineColor();
701cdf0e10cSrcweir         DrawRect( aRect );
702cdf0e10cSrcweir     }
703cdf0e10cSrcweir 
704cdf0e10cSrcweir     if( !ToolBox::AlwaysLocked() )  // no grip if toolboxes are locked
705cdf0e10cSrcweir     {
706cdf0e10cSrcweir #ifdef TEAROFF_DASHED
707cdf0e10cSrcweir         // draw single dashed line
708cdf0e10cSrcweir         LineInfo aLineInfo( LINE_DASH );
709cdf0e10cSrcweir         aLineInfo.SetDistance( 4 );
710cdf0e10cSrcweir         aLineInfo.SetDashLen( 12 );
711cdf0e10cSrcweir         aLineInfo.SetDashCount( 1 );
712cdf0e10cSrcweir 
713cdf0e10cSrcweir         aRect.nLeft+=2; aRect.nRight-=2;
714cdf0e10cSrcweir 
715cdf0e10cSrcweir         aRect.nTop+=2;
716cdf0e10cSrcweir         aRect.nBottom = aRect.nTop;
717cdf0e10cSrcweir         SetLineColor( GetSettings().GetStyleSettings().GetDarkShadowColor() );
718cdf0e10cSrcweir         DrawLine( aRect.TopLeft(), aRect.TopRight(), aLineInfo );
719cdf0e10cSrcweir 
720cdf0e10cSrcweir         if( !mbHighlight )
721cdf0e10cSrcweir         {
722cdf0e10cSrcweir             aRect.nTop++; aRect.nBottom++;
723cdf0e10cSrcweir             SetLineColor( GetSettings().GetStyleSettings().GetLightColor() );
724cdf0e10cSrcweir             DrawLine( aRect.TopLeft(), aRect.TopRight(), aLineInfo );
725cdf0e10cSrcweir         }
726cdf0e10cSrcweir 
727cdf0e10cSrcweir #else
728cdf0e10cSrcweir         // draw several grip lines
729cdf0e10cSrcweir         SetFillColor( GetSettings().GetStyleSettings().GetShadowColor() );
730cdf0e10cSrcweir         aRect.nTop++;
731cdf0e10cSrcweir         aRect.nBottom = aRect.nTop;
732cdf0e10cSrcweir 
733cdf0e10cSrcweir         int width = POPUP_DRAGWIDTH;
734cdf0e10cSrcweir         while( width >= aRect.getWidth() )
735cdf0e10cSrcweir             width -= 4;
736cdf0e10cSrcweir         if( width <= 0 )
737cdf0e10cSrcweir             width = aRect.getWidth();
738cdf0e10cSrcweir         //aRect.nLeft = aRect.nLeft + (aRect.getWidth() - width) / 2;
739cdf0e10cSrcweir         aRect.nLeft = (aRect.nLeft + aRect.nRight - width) / 2;
740cdf0e10cSrcweir         aRect.nRight = aRect.nLeft + width;
741cdf0e10cSrcweir 
742cdf0e10cSrcweir         int i=0;
743cdf0e10cSrcweir         while( i< POPUP_DRAGGRIP )
744cdf0e10cSrcweir         {
745cdf0e10cSrcweir             DrawRect( aRect );
746cdf0e10cSrcweir             aRect.nTop+=2;
747cdf0e10cSrcweir             aRect.nBottom+=2;
748cdf0e10cSrcweir             i+=2;
749cdf0e10cSrcweir         }
750cdf0e10cSrcweir #endif
751cdf0e10cSrcweir     }
752cdf0e10cSrcweir 
753cdf0e10cSrcweir     if( bLinecolor )
754cdf0e10cSrcweir         SetLineColor( aLinecolor );
755cdf0e10cSrcweir     else
756cdf0e10cSrcweir         SetLineColor();
757cdf0e10cSrcweir     if( bFillcolor )
758cdf0e10cSrcweir         SetFillColor( aFillcolor );
759cdf0e10cSrcweir     else
760cdf0e10cSrcweir         SetFillColor();
761cdf0e10cSrcweir }
762cdf0e10cSrcweir 
Paint(const Rectangle &)763cdf0e10cSrcweir void ImplPopupFloatWin::Paint( const Rectangle& )
764cdf0e10cSrcweir {
765cdf0e10cSrcweir     Point aPt;
766cdf0e10cSrcweir     Rectangle aRect( aPt, GetOutputSizePixel() );
767cdf0e10cSrcweir     DrawWallpaper( aRect, Wallpaper( GetSettings().GetStyleSettings().GetFaceGradientColor() ) );
768cdf0e10cSrcweir     DrawBorder();
769cdf0e10cSrcweir     if( hasGrip() )
770cdf0e10cSrcweir         DrawGrip();
771cdf0e10cSrcweir }
772cdf0e10cSrcweir 
MouseMove(const MouseEvent & rMEvt)773cdf0e10cSrcweir void ImplPopupFloatWin::MouseMove( const MouseEvent& rMEvt )
774cdf0e10cSrcweir {
775cdf0e10cSrcweir     Point aMousePos = rMEvt.GetPosPixel();
776cdf0e10cSrcweir 
777cdf0e10cSrcweir     if( !ToolBox::AlwaysLocked() )  // no tear off if locking is enabled
778cdf0e10cSrcweir     {
779cdf0e10cSrcweir         if( mbTrackingEnabled && rMEvt.IsLeft() && GetDragRect().IsInside( aMousePos ) )
780cdf0e10cSrcweir         {
781cdf0e10cSrcweir             // start window move
782cdf0e10cSrcweir             mbMoving = sal_True;
783cdf0e10cSrcweir             StartTracking( STARTTRACK_NOKEYCANCEL );
784cdf0e10cSrcweir             return;
785cdf0e10cSrcweir         }
786cdf0e10cSrcweir         if( !mbHighlight && GetDragRect().IsInside( aMousePos ) )
787cdf0e10cSrcweir         {
788cdf0e10cSrcweir             mbHighlight = sal_True;
789cdf0e10cSrcweir             DrawGrip();
790cdf0e10cSrcweir         }
791cdf0e10cSrcweir         if( mbHighlight && ( rMEvt.IsLeaveWindow() || !GetDragRect().IsInside( aMousePos ) ) )
792cdf0e10cSrcweir         {
793cdf0e10cSrcweir             mbHighlight = sal_False;
794cdf0e10cSrcweir             DrawGrip();
795cdf0e10cSrcweir         }
796cdf0e10cSrcweir     }
797cdf0e10cSrcweir }
798cdf0e10cSrcweir 
MouseButtonUp(const MouseEvent & rMEvt)799cdf0e10cSrcweir void ImplPopupFloatWin::MouseButtonUp( const MouseEvent& rMEvt )
800cdf0e10cSrcweir {
801cdf0e10cSrcweir     mbTrackingEnabled = false;
802cdf0e10cSrcweir     FloatingWindow::MouseButtonUp( rMEvt );
803cdf0e10cSrcweir }
804cdf0e10cSrcweir 
MouseButtonDown(const MouseEvent & rMEvt)805cdf0e10cSrcweir void ImplPopupFloatWin::MouseButtonDown( const MouseEvent& rMEvt )
806cdf0e10cSrcweir {
807cdf0e10cSrcweir     Point aMousePos = rMEvt.GetPosPixel();
808cdf0e10cSrcweir     if( GetDragRect().IsInside( aMousePos ) )
809cdf0e10cSrcweir     {
810cdf0e10cSrcweir         // get mouse pos at a static window to have a fixed reference point
811cdf0e10cSrcweir         PointerState aState = GetParent()->GetPointerState();
812cdf0e10cSrcweir         if (ImplHasMirroredGraphics() && IsRTLEnabled())
813cdf0e10cSrcweir             ImplMirrorFramePos(aState.maPos);
814cdf0e10cSrcweir         maTearOffPosition = GetWindow( WINDOW_BORDER )->GetPosPixel();
815cdf0e10cSrcweir         maDelta = aState.maPos - maTearOffPosition;
816cdf0e10cSrcweir         mbTrackingEnabled = true;
817cdf0e10cSrcweir     }
818cdf0e10cSrcweir     else
819cdf0e10cSrcweir     {
820cdf0e10cSrcweir         mbTrackingEnabled = false;
821cdf0e10cSrcweir     }
822cdf0e10cSrcweir }
823cdf0e10cSrcweir 
Tracking(const TrackingEvent & rTEvt)824cdf0e10cSrcweir void ImplPopupFloatWin::Tracking( const TrackingEvent& rTEvt )
825cdf0e10cSrcweir {
826cdf0e10cSrcweir     if( mbMoving )
827cdf0e10cSrcweir     {
828cdf0e10cSrcweir         if ( rTEvt.IsTrackingEnded() )
829cdf0e10cSrcweir         {
830cdf0e10cSrcweir             mbMoving = sal_False;
831cdf0e10cSrcweir             EndPopupMode( FLOATWIN_POPUPMODEEND_TEAROFF );
832cdf0e10cSrcweir         }
833cdf0e10cSrcweir         else if ( !rTEvt.GetMouseEvent().IsSynthetic() )
834cdf0e10cSrcweir         {
835cdf0e10cSrcweir             // move the window according to mouse pos
836cdf0e10cSrcweir             PointerState aState = GetParent()->GetPointerState();
837cdf0e10cSrcweir             if (ImplHasMirroredGraphics() && IsRTLEnabled())
838cdf0e10cSrcweir                 ImplMirrorFramePos(aState.maPos);
839cdf0e10cSrcweir             maTearOffPosition = aState.maPos - maDelta;
840cdf0e10cSrcweir             GetWindow( WINDOW_BORDER )->SetPosPixel( maTearOffPosition );
841cdf0e10cSrcweir         }
842cdf0e10cSrcweir     }
843cdf0e10cSrcweir }
844cdf0e10cSrcweir 
845cdf0e10cSrcweir 
846cdf0e10cSrcweir // =======================================================================
847cdf0e10cSrcweir 
ImplDockingWindowWrapper(const Window * pWindow)848cdf0e10cSrcweir ImplDockingWindowWrapper::ImplDockingWindowWrapper( const Window *pWindow )
849cdf0e10cSrcweir {
850cdf0e10cSrcweir     ImplInitData();
851cdf0e10cSrcweir 
852cdf0e10cSrcweir     mpDockingWindow = (Window*) pWindow;
853cdf0e10cSrcweir     mpParent        = pWindow->GetParent();
854cdf0e10cSrcweir     mbDockable      = sal_True;
855cdf0e10cSrcweir     mbLocked        = sal_False;
856cdf0e10cSrcweir     mnFloatBits     = WB_BORDER | WB_CLOSEABLE | WB_SIZEABLE | (pWindow->GetStyle() & DOCKWIN_FLOATSTYLES);
857cdf0e10cSrcweir     DockingWindow *pDockWin = dynamic_cast< DockingWindow* > ( mpDockingWindow );
858cdf0e10cSrcweir     if( pDockWin )
859cdf0e10cSrcweir         mnFloatBits = pDockWin->GetFloatStyle();
860cdf0e10cSrcweir 
861cdf0e10cSrcweir     // must be enabled in Window::Notify to prevent permanent docking during mouse move
862cdf0e10cSrcweir     mbStartDockingEnabled = sal_False;
863cdf0e10cSrcweir }
864cdf0e10cSrcweir 
~ImplDockingWindowWrapper()865cdf0e10cSrcweir ImplDockingWindowWrapper::~ImplDockingWindowWrapper()
866cdf0e10cSrcweir {
867cdf0e10cSrcweir     if ( IsFloatingMode() )
868cdf0e10cSrcweir     {
869cdf0e10cSrcweir         GetWindow()->Show( sal_False, SHOW_NOFOCUSCHANGE );
870cdf0e10cSrcweir         SetFloatingMode( sal_False );
871cdf0e10cSrcweir     }
872cdf0e10cSrcweir }
873cdf0e10cSrcweir 
874cdf0e10cSrcweir // -----------------------------------------------------------------------
875cdf0e10cSrcweir 
ImplStartDocking(const Point & rPos)876cdf0e10cSrcweir sal_Bool ImplDockingWindowWrapper::ImplStartDocking( const Point& rPos )
877cdf0e10cSrcweir {
878cdf0e10cSrcweir     if ( !mbDockable )
879cdf0e10cSrcweir         return sal_False;
880cdf0e10cSrcweir 
881cdf0e10cSrcweir     if( !mbStartDockingEnabled )
882cdf0e10cSrcweir         return sal_False;
883cdf0e10cSrcweir 
884cdf0e10cSrcweir     maMouseOff      = rPos;
885cdf0e10cSrcweir     maMouseStart    = maMouseOff;
886cdf0e10cSrcweir     mbDocking       = sal_True;
887cdf0e10cSrcweir     mbLastFloatMode = IsFloatingMode();
888cdf0e10cSrcweir     mbStartFloat    = mbLastFloatMode;
889cdf0e10cSrcweir 
890cdf0e10cSrcweir     // FloatingBorder berechnen
891cdf0e10cSrcweir     FloatingWindow* pWin;
892cdf0e10cSrcweir     if ( mpFloatWin )
893cdf0e10cSrcweir         pWin = mpFloatWin;
894cdf0e10cSrcweir     else
895cdf0e10cSrcweir         pWin = new ImplDockFloatWin2( mpParent, mnFloatBits, NULL );
896cdf0e10cSrcweir     pWin->GetBorder( mnDockLeft, mnDockTop, mnDockRight, mnDockBottom );
897cdf0e10cSrcweir     if ( !mpFloatWin )
898cdf0e10cSrcweir         delete pWin;
899cdf0e10cSrcweir 
900cdf0e10cSrcweir     Point   aPos    = GetWindow()->ImplOutputToFrame( Point() );
901cdf0e10cSrcweir     Size    aSize   = GetWindow()->GetOutputSizePixel();
902cdf0e10cSrcweir     mnTrackX        = aPos.X();
903cdf0e10cSrcweir     mnTrackY        = aPos.Y();
904cdf0e10cSrcweir     mnTrackWidth    = aSize.Width();
905cdf0e10cSrcweir     mnTrackHeight   = aSize.Height();
906cdf0e10cSrcweir 
907cdf0e10cSrcweir     if ( mbLastFloatMode )
908cdf0e10cSrcweir     {
909cdf0e10cSrcweir         maMouseOff.X()  += mnDockLeft;
910cdf0e10cSrcweir         maMouseOff.Y()  += mnDockTop;
911cdf0e10cSrcweir         mnTrackX        -= mnDockLeft;
912cdf0e10cSrcweir         mnTrackY        -= mnDockTop;
913cdf0e10cSrcweir         mnTrackWidth    += mnDockLeft+mnDockRight;
914cdf0e10cSrcweir         mnTrackHeight   += mnDockTop+mnDockBottom;
915cdf0e10cSrcweir     }
916cdf0e10cSrcweir 
917cdf0e10cSrcweir     Window *pDockingArea = GetWindow()->GetParent();
918cdf0e10cSrcweir     Window::PointerState aState = pDockingArea->GetPointerState();
919cdf0e10cSrcweir 
920cdf0e10cSrcweir     // mouse pos in screen pixels
921cdf0e10cSrcweir     Point aMousePos = pDockingArea->OutputToScreenPixel( aState.maPos );
922cdf0e10cSrcweir     Point aDockPos = Point( pDockingArea->AbsoluteScreenToOutputPixel( GetWindow()->OutputToAbsoluteScreenPixel( GetWindow()->GetPosPixel() ) ) );
923cdf0e10cSrcweir     Rectangle aDockRect( aDockPos, GetWindow()->GetSizePixel() );
924cdf0e10cSrcweir     StartDocking( aMousePos, aDockRect );
925cdf0e10cSrcweir 
926cdf0e10cSrcweir     GetWindow()->ImplUpdateAll();
927cdf0e10cSrcweir     GetWindow()->ImplGetFrameWindow()->ImplUpdateAll();
928cdf0e10cSrcweir 
929cdf0e10cSrcweir     GetWindow()->StartTracking( STARTTRACK_KEYMOD );
930cdf0e10cSrcweir     return sal_True;
931cdf0e10cSrcweir }
932cdf0e10cSrcweir 
933cdf0e10cSrcweir // =======================================================================
934cdf0e10cSrcweir 
ImplInitData()935cdf0e10cSrcweir void ImplDockingWindowWrapper::ImplInitData()
936cdf0e10cSrcweir {
937cdf0e10cSrcweir     mpDockingWindow     = NULL;
938cdf0e10cSrcweir 
939cdf0e10cSrcweir     //GetWindow()->mpWindowImpl->mbDockWin  = sal_True;     // TODO: must be eliminated
940cdf0e10cSrcweir     mpFloatWin          = NULL;
941cdf0e10cSrcweir     mbDockCanceled      = sal_False;
942cdf0e10cSrcweir     mbFloatPrevented    = sal_False;
943cdf0e10cSrcweir     mbDocking           = sal_False;
944cdf0e10cSrcweir     mbPined             = sal_False;
945cdf0e10cSrcweir     mbRollUp            = sal_False;
946cdf0e10cSrcweir     mbDockBtn           = sal_False;
947cdf0e10cSrcweir     mbHideBtn           = sal_False;
948cdf0e10cSrcweir     maMaxOutSize        = Size( SHRT_MAX, SHRT_MAX );
949cdf0e10cSrcweir }
950cdf0e10cSrcweir 
951cdf0e10cSrcweir // -----------------------------------------------------------------------
952cdf0e10cSrcweir 
Tracking(const TrackingEvent & rTEvt)953cdf0e10cSrcweir void ImplDockingWindowWrapper::Tracking( const TrackingEvent& rTEvt )
954cdf0e10cSrcweir {
955cdf0e10cSrcweir     // used during docking of a currently docked window
956cdf0e10cSrcweir     if ( mbDocking )
957cdf0e10cSrcweir     {
958cdf0e10cSrcweir         if ( rTEvt.IsTrackingEnded() )
959cdf0e10cSrcweir         {
960cdf0e10cSrcweir             mbDocking = sal_False;
961cdf0e10cSrcweir             GetWindow()->HideTracking();
962cdf0e10cSrcweir             if ( rTEvt.IsTrackingCanceled() )
963cdf0e10cSrcweir             {
964cdf0e10cSrcweir                 mbDockCanceled = sal_True;
965cdf0e10cSrcweir                 EndDocking( Rectangle( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) ), mbLastFloatMode );
966cdf0e10cSrcweir                 mbDockCanceled = sal_False;
967cdf0e10cSrcweir             }
968cdf0e10cSrcweir             else
969cdf0e10cSrcweir                 EndDocking( Rectangle( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) ), mbLastFloatMode );
970cdf0e10cSrcweir         }
971cdf0e10cSrcweir         // Docking only upon non-synthetic MouseEvents
972cdf0e10cSrcweir         else if ( !rTEvt.GetMouseEvent().IsSynthetic() || rTEvt.GetMouseEvent().IsModifierChanged() )
973cdf0e10cSrcweir         {
974cdf0e10cSrcweir             Point   aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
975cdf0e10cSrcweir             Point   aFrameMousePos = GetWindow()->ImplOutputToFrame( aMousePos );
976cdf0e10cSrcweir             Size    aFrameSize = GetWindow()->ImplGetFrameWindow()->GetOutputSizePixel();
977cdf0e10cSrcweir             if ( aFrameMousePos.X() < 0 )
978cdf0e10cSrcweir                 aFrameMousePos.X() = 0;
979cdf0e10cSrcweir             if ( aFrameMousePos.Y() < 0 )
980cdf0e10cSrcweir                 aFrameMousePos.Y() = 0;
981cdf0e10cSrcweir             if ( aFrameMousePos.X() > aFrameSize.Width()-1 )
982cdf0e10cSrcweir                 aFrameMousePos.X() = aFrameSize.Width()-1;
983cdf0e10cSrcweir             if ( aFrameMousePos.Y() > aFrameSize.Height()-1 )
984cdf0e10cSrcweir                 aFrameMousePos.Y() = aFrameSize.Height()-1;
985cdf0e10cSrcweir             aMousePos = GetWindow()->ImplFrameToOutput( aFrameMousePos );
986cdf0e10cSrcweir             aMousePos.X() -= maMouseOff.X();
987cdf0e10cSrcweir             aMousePos.Y() -= maMouseOff.Y();
988cdf0e10cSrcweir             Point aPos = GetWindow()->ImplOutputToFrame( aMousePos );
989cdf0e10cSrcweir             Rectangle aTrackRect( aPos, Size( mnTrackWidth, mnTrackHeight ) );
990cdf0e10cSrcweir             Rectangle aCompRect = aTrackRect;
991cdf0e10cSrcweir             aPos.X()    += maMouseOff.X();
992cdf0e10cSrcweir             aPos.Y()    += maMouseOff.Y();
993cdf0e10cSrcweir 
994cdf0e10cSrcweir             sal_Bool bFloatMode = Docking( aPos, aTrackRect );
995cdf0e10cSrcweir 
996cdf0e10cSrcweir             mbFloatPrevented = sal_False;
997cdf0e10cSrcweir             if ( mbLastFloatMode != bFloatMode )
998cdf0e10cSrcweir             {
999cdf0e10cSrcweir                 if ( bFloatMode )
1000cdf0e10cSrcweir                 {
1001cdf0e10cSrcweir                     aTrackRect.Left()   -= mnDockLeft;
1002cdf0e10cSrcweir                     aTrackRect.Top()    -= mnDockTop;
1003cdf0e10cSrcweir                     aTrackRect.Right()  += mnDockRight;
1004cdf0e10cSrcweir                     aTrackRect.Bottom() += mnDockBottom;
1005cdf0e10cSrcweir                 }
1006cdf0e10cSrcweir                 else
1007cdf0e10cSrcweir                 {
1008cdf0e10cSrcweir                     if ( aCompRect == aTrackRect )
1009cdf0e10cSrcweir                     {
1010cdf0e10cSrcweir                         aTrackRect.Left()   += mnDockLeft;
1011cdf0e10cSrcweir                         aTrackRect.Top()    += mnDockTop;
1012cdf0e10cSrcweir                         aTrackRect.Right()  -= mnDockRight;
1013cdf0e10cSrcweir                         aTrackRect.Bottom() -= mnDockBottom;
1014cdf0e10cSrcweir                     }
1015cdf0e10cSrcweir                 }
1016cdf0e10cSrcweir                 mbLastFloatMode = bFloatMode;
1017cdf0e10cSrcweir             }
1018cdf0e10cSrcweir 
1019cdf0e10cSrcweir             sal_uInt16 nTrackStyle;
1020cdf0e10cSrcweir             if ( bFloatMode )
1021cdf0e10cSrcweir                 nTrackStyle = SHOWTRACK_OBJECT;
1022cdf0e10cSrcweir             else
1023cdf0e10cSrcweir                 nTrackStyle = SHOWTRACK_BIG;
1024cdf0e10cSrcweir             Rectangle aShowTrackRect = aTrackRect;
1025cdf0e10cSrcweir             aShowTrackRect.SetPos( GetWindow()->ImplFrameToOutput( aShowTrackRect.TopLeft() ) );
1026cdf0e10cSrcweir             //if( bFloatMode )
1027cdf0e10cSrcweir                 GetWindow()->ShowTracking( aShowTrackRect, nTrackStyle );
1028cdf0e10cSrcweir             /*else
1029cdf0e10cSrcweir             {
1030cdf0e10cSrcweir                 GetWindow()->HideTracking();
1031cdf0e10cSrcweir                 Point aPt( GetWindow()->GetParent()->ScreenToOutputPixel( aTrackRect.TopLeft() ) );
1032cdf0e10cSrcweir                 GetWindow()->SetPosPixel( aPt );
1033cdf0e10cSrcweir             }*/
1034cdf0e10cSrcweir 
1035cdf0e10cSrcweir             // Maus-Offset neu berechnen, da Rechteck veraendert werden
1036cdf0e10cSrcweir             // konnte
1037cdf0e10cSrcweir             maMouseOff.X()  = aPos.X() - aTrackRect.Left();
1038cdf0e10cSrcweir             maMouseOff.Y()  = aPos.Y() - aTrackRect.Top();
1039cdf0e10cSrcweir 
1040cdf0e10cSrcweir             mnTrackX        = aTrackRect.Left();
1041cdf0e10cSrcweir             mnTrackY        = aTrackRect.Top();
1042cdf0e10cSrcweir             mnTrackWidth    = aTrackRect.GetWidth();
1043cdf0e10cSrcweir             mnTrackHeight   = aTrackRect.GetHeight();
1044cdf0e10cSrcweir         }
1045cdf0e10cSrcweir     }
1046cdf0e10cSrcweir }
1047cdf0e10cSrcweir 
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir // -----------------------------------------------------------------------
1050cdf0e10cSrcweir 
StartDocking(const Point & rPoint,Rectangle & rRect)1051cdf0e10cSrcweir void ImplDockingWindowWrapper::StartDocking( const Point& rPoint, Rectangle& rRect )
1052cdf0e10cSrcweir {
1053cdf0e10cSrcweir     DockingData data( rPoint, rRect, IsFloatingMode() );
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir     GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_STARTDOCKING, &data );
1056cdf0e10cSrcweir     mbDocking = sal_True;
1057cdf0e10cSrcweir }
1058cdf0e10cSrcweir 
1059cdf0e10cSrcweir // -----------------------------------------------------------------------
1060cdf0e10cSrcweir 
Docking(const Point & rPoint,Rectangle & rRect)1061cdf0e10cSrcweir sal_Bool ImplDockingWindowWrapper::Docking( const Point& rPoint, Rectangle& rRect )
1062cdf0e10cSrcweir {
1063cdf0e10cSrcweir     DockingData data( rPoint, rRect, IsFloatingMode() );
1064cdf0e10cSrcweir 
1065cdf0e10cSrcweir     GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_DOCKING, &data );
1066cdf0e10cSrcweir     rRect = data.maTrackRect;
1067cdf0e10cSrcweir     return data.mbFloating;
1068cdf0e10cSrcweir }
1069cdf0e10cSrcweir 
1070cdf0e10cSrcweir // -----------------------------------------------------------------------
1071cdf0e10cSrcweir 
EndDocking(const Rectangle & rRect,sal_Bool bFloatMode)1072cdf0e10cSrcweir void ImplDockingWindowWrapper::EndDocking( const Rectangle& rRect, sal_Bool bFloatMode )
1073cdf0e10cSrcweir {
1074cdf0e10cSrcweir     Rectangle aRect( rRect );
1075cdf0e10cSrcweir 
1076cdf0e10cSrcweir     if ( !IsDockingCanceled() )
1077cdf0e10cSrcweir     {
1078cdf0e10cSrcweir         sal_Bool bShow = sal_False;
1079cdf0e10cSrcweir         if ( bFloatMode != IsFloatingMode() )
1080cdf0e10cSrcweir         {
1081cdf0e10cSrcweir             GetWindow()->Show( sal_False, SHOW_NOFOCUSCHANGE );
1082cdf0e10cSrcweir             SetFloatingMode( bFloatMode );
1083cdf0e10cSrcweir             bShow = sal_True;
1084cdf0e10cSrcweir             if ( bFloatMode )
1085cdf0e10cSrcweir             {
1086cdf0e10cSrcweir                 // #i44800# always use outputsize - as in all other places
1087cdf0e10cSrcweir                 mpFloatWin->SetOutputSizePixel( aRect.GetSize() );
1088cdf0e10cSrcweir                 mpFloatWin->SetPosPixel( aRect.TopLeft() );
1089cdf0e10cSrcweir             }
1090cdf0e10cSrcweir         }
1091cdf0e10cSrcweir         if ( !bFloatMode )
1092cdf0e10cSrcweir         {
1093cdf0e10cSrcweir             Point aPos = aRect.TopLeft();
1094cdf0e10cSrcweir             aPos = GetWindow()->GetParent()->ScreenToOutputPixel( aPos );
1095cdf0e10cSrcweir             GetWindow()->SetPosSizePixel( aPos, aRect.GetSize() );
1096cdf0e10cSrcweir         }
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir         if ( bShow )
1099cdf0e10cSrcweir             GetWindow()->Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
1100cdf0e10cSrcweir     }
1101cdf0e10cSrcweir 
1102cdf0e10cSrcweir     EndDockingData data( aRect, IsFloatingMode(), IsDockingCanceled() );
1103cdf0e10cSrcweir     GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_ENDDOCKING, &data );
1104cdf0e10cSrcweir 
1105cdf0e10cSrcweir     mbDocking = sal_False;
1106cdf0e10cSrcweir 
1107cdf0e10cSrcweir     // must be enabled in Window::Notify to prevent permanent docking during mouse move
1108cdf0e10cSrcweir     mbStartDockingEnabled = sal_False;
1109cdf0e10cSrcweir }
1110cdf0e10cSrcweir 
1111cdf0e10cSrcweir // -----------------------------------------------------------------------
1112cdf0e10cSrcweir 
PrepareToggleFloatingMode()1113cdf0e10cSrcweir sal_Bool ImplDockingWindowWrapper::PrepareToggleFloatingMode()
1114cdf0e10cSrcweir {
1115cdf0e10cSrcweir     sal_Bool bFloating = sal_True;
1116cdf0e10cSrcweir     GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_PREPARETOGGLEFLOATING, &bFloating );
1117cdf0e10cSrcweir     return bFloating;
1118cdf0e10cSrcweir }
1119cdf0e10cSrcweir 
1120cdf0e10cSrcweir // -----------------------------------------------------------------------
1121cdf0e10cSrcweir 
Close()1122cdf0e10cSrcweir sal_Bool ImplDockingWindowWrapper::Close()
1123cdf0e10cSrcweir {
1124cdf0e10cSrcweir     // TODO: send event
1125cdf0e10cSrcweir /*
1126cdf0e10cSrcweir     ImplDelData aDelData;
1127cdf0e10cSrcweir     ImplAddDel( &aDelData );
1128cdf0e10cSrcweir     GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_CLOSE );
1129cdf0e10cSrcweir     if ( aDelData.IsDelete() )
1130cdf0e10cSrcweir         return sal_False;
1131cdf0e10cSrcweir     ImplRemoveDel( &aDelData );
1132cdf0e10cSrcweir 
1133cdf0e10cSrcweir     if ( mpWindowImpl->mxWindowPeer.is() && IsCreatedWithToolkit() )
1134cdf0e10cSrcweir         return sal_False;
1135cdf0e10cSrcweir 
1136cdf0e10cSrcweir     GetWindow()->Show( sal_False, SHOW_NOFOCUSCHANGE );
1137cdf0e10cSrcweir     */
1138cdf0e10cSrcweir     return sal_True;
1139cdf0e10cSrcweir }
1140cdf0e10cSrcweir 
1141cdf0e10cSrcweir // -----------------------------------------------------------------------
1142cdf0e10cSrcweir 
ToggleFloatingMode()1143cdf0e10cSrcweir void ImplDockingWindowWrapper::ToggleFloatingMode()
1144cdf0e10cSrcweir {
1145cdf0e10cSrcweir     // notify dockingwindow/toolbox
1146cdf0e10cSrcweir     // note: this must be done *before* notifying the
1147cdf0e10cSrcweir     //       listeners to have the toolbox in the proper state
1148cdf0e10cSrcweir     if( GetWindow()->ImplIsDockingWindow() )
1149cdf0e10cSrcweir         ((DockingWindow*) GetWindow())->ToggleFloatingMode();
1150cdf0e10cSrcweir 
1151cdf0e10cSrcweir     // now notify listeners
1152cdf0e10cSrcweir     GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_TOGGLEFLOATING );
1153cdf0e10cSrcweir 
1154cdf0e10cSrcweir     // must be enabled in Window::Notify to prevent permanent docking during mouse move
1155cdf0e10cSrcweir     mbStartDockingEnabled = sal_False;
1156cdf0e10cSrcweir }
1157cdf0e10cSrcweir 
1158cdf0e10cSrcweir // -----------------------------------------------------------------------
1159cdf0e10cSrcweir 
TitleButtonClick(sal_uInt16 nType)1160cdf0e10cSrcweir void ImplDockingWindowWrapper::TitleButtonClick( sal_uInt16 nType )
1161cdf0e10cSrcweir {
1162cdf0e10cSrcweir     if( nType == TITLE_BUTTON_MENU )
1163cdf0e10cSrcweir     {
1164cdf0e10cSrcweir         ToolBox *pToolBox = dynamic_cast< ToolBox* >( GetWindow() );
1165cdf0e10cSrcweir         if( pToolBox )
1166cdf0e10cSrcweir         {
1167cdf0e10cSrcweir             pToolBox->ExecuteCustomMenu();
1168cdf0e10cSrcweir         }
1169cdf0e10cSrcweir     }
1170cdf0e10cSrcweir     if( nType == TITLE_BUTTON_DOCKING )
1171cdf0e10cSrcweir     {
1172cdf0e10cSrcweir         SetFloatingMode( !IsFloatingMode() );
1173cdf0e10cSrcweir     }
1174cdf0e10cSrcweir }
1175cdf0e10cSrcweir 
1176cdf0e10cSrcweir // -----------------------------------------------------------------------
1177cdf0e10cSrcweir 
Pin()1178cdf0e10cSrcweir void ImplDockingWindowWrapper::Pin()
1179cdf0e10cSrcweir {
1180cdf0e10cSrcweir     // TODO: send event
1181cdf0e10cSrcweir }
1182cdf0e10cSrcweir 
1183cdf0e10cSrcweir // -----------------------------------------------------------------------
1184cdf0e10cSrcweir 
Roll()1185cdf0e10cSrcweir void ImplDockingWindowWrapper::Roll()
1186cdf0e10cSrcweir {
1187cdf0e10cSrcweir     // TODO: send event
1188cdf0e10cSrcweir }
1189cdf0e10cSrcweir 
1190cdf0e10cSrcweir // -----------------------------------------------------------------------
1191cdf0e10cSrcweir 
PopupModeEnd()1192cdf0e10cSrcweir void ImplDockingWindowWrapper::PopupModeEnd()
1193cdf0e10cSrcweir {
1194cdf0e10cSrcweir     // TODO: send event
1195cdf0e10cSrcweir }
1196cdf0e10cSrcweir 
1197cdf0e10cSrcweir // -----------------------------------------------------------------------
1198cdf0e10cSrcweir 
Resizing(Size & rSize)1199cdf0e10cSrcweir void ImplDockingWindowWrapper::Resizing( Size& rSize )
1200cdf0e10cSrcweir {
1201cdf0e10cSrcweir     // TODO: add virtual Resizing() to class Window, so we can get rid of class DockingWindow
1202cdf0e10cSrcweir     DockingWindow *pDockingWindow = dynamic_cast< DockingWindow* >( GetWindow() );
1203cdf0e10cSrcweir     if( pDockingWindow )
1204cdf0e10cSrcweir         pDockingWindow->Resizing( rSize );
1205cdf0e10cSrcweir }
1206cdf0e10cSrcweir 
1207cdf0e10cSrcweir // -----------------------------------------------------------------------
1208cdf0e10cSrcweir 
ShowTitleButton(sal_uInt16 nButton,sal_Bool bVisible)1209cdf0e10cSrcweir void ImplDockingWindowWrapper::ShowTitleButton( sal_uInt16 nButton, sal_Bool bVisible )
1210cdf0e10cSrcweir {
1211cdf0e10cSrcweir     if ( mpFloatWin )
1212cdf0e10cSrcweir         mpFloatWin->ShowTitleButton( nButton, bVisible );
1213cdf0e10cSrcweir     else
1214cdf0e10cSrcweir     {
1215cdf0e10cSrcweir         if ( nButton == TITLE_BUTTON_DOCKING )
1216cdf0e10cSrcweir             mbDockBtn = bVisible;
1217cdf0e10cSrcweir         else // if ( nButton == TITLE_BUTTON_HIDE )
1218cdf0e10cSrcweir             mbHideBtn = bVisible;
1219cdf0e10cSrcweir     }
1220cdf0e10cSrcweir }
1221cdf0e10cSrcweir 
1222cdf0e10cSrcweir // -----------------------------------------------------------------------
1223cdf0e10cSrcweir 
IsTitleButtonVisible(sal_uInt16 nButton) const1224cdf0e10cSrcweir sal_Bool ImplDockingWindowWrapper::IsTitleButtonVisible( sal_uInt16 nButton ) const
1225cdf0e10cSrcweir {
1226cdf0e10cSrcweir     if ( mpFloatWin )
1227cdf0e10cSrcweir         return mpFloatWin->IsTitleButtonVisible( nButton );
1228cdf0e10cSrcweir     else
1229cdf0e10cSrcweir     {
1230cdf0e10cSrcweir         if ( nButton == TITLE_BUTTON_DOCKING )
1231cdf0e10cSrcweir             return mbDockBtn;
1232cdf0e10cSrcweir         else // if ( nButton == TITLE_BUTTON_HIDE )
1233cdf0e10cSrcweir             return mbHideBtn;
1234cdf0e10cSrcweir     }
1235cdf0e10cSrcweir }
1236cdf0e10cSrcweir 
1237cdf0e10cSrcweir // -----------------------------------------------------------------------
1238cdf0e10cSrcweir 
StartPopupMode(ToolBox * pParentToolBox,sal_uLong nFlags)1239cdf0e10cSrcweir void ImplDockingWindowWrapper::StartPopupMode( ToolBox *pParentToolBox, sal_uLong nFlags )
1240cdf0e10cSrcweir {
1241cdf0e10cSrcweir     // do nothing if window is floating
1242cdf0e10cSrcweir     if( IsFloatingMode() )
1243cdf0e10cSrcweir         return;
1244cdf0e10cSrcweir 
1245cdf0e10cSrcweir     GetWindow()->Show( sal_False, SHOW_NOFOCUSCHANGE );
1246cdf0e10cSrcweir 
1247cdf0e10cSrcweir     // prepare reparenting
1248cdf0e10cSrcweir     Window* pRealParent = GetWindow()->GetWindow( WINDOW_PARENT );
1249cdf0e10cSrcweir     mpOldBorderWin = GetWindow()->GetWindow( WINDOW_BORDER );
1250cdf0e10cSrcweir     if( mpOldBorderWin == GetWindow() )
1251cdf0e10cSrcweir         mpOldBorderWin = NULL;  // no border window found
1252cdf0e10cSrcweir 
1253cdf0e10cSrcweir     // the new parent for popup mode
1254cdf0e10cSrcweir     ImplPopupFloatWin* pWin = new ImplPopupFloatWin( mpParent, this, (nFlags & FLOATWIN_POPUPMODE_ALLOWTEAROFF) != 0 );
1255cdf0e10cSrcweir 
1256cdf0e10cSrcweir     pWin->SetPopupModeEndHdl( LINK( this, ImplDockingWindowWrapper, PopupModeEnd ) );
1257cdf0e10cSrcweir     pWin->SetText( GetWindow()->GetText() );
1258cdf0e10cSrcweir 
1259cdf0e10cSrcweir     pWin->SetOutputSizePixel( GetWindow()->GetSizePixel() );
1260cdf0e10cSrcweir 
1261cdf0e10cSrcweir     GetWindow()->mpWindowImpl->mpBorderWindow  = NULL;
1262cdf0e10cSrcweir     GetWindow()->mpWindowImpl->mnLeftBorder    = 0;
1263cdf0e10cSrcweir     GetWindow()->mpWindowImpl->mnTopBorder     = 0;
1264cdf0e10cSrcweir     GetWindow()->mpWindowImpl->mnRightBorder   = 0;
1265cdf0e10cSrcweir     GetWindow()->mpWindowImpl->mnBottomBorder  = 0;
1266cdf0e10cSrcweir 
1267cdf0e10cSrcweir     // position toolbox below dragrect
1268cdf0e10cSrcweir     GetWindow()->SetPosPixel( pWin->GetToolboxPosition() );
1269cdf0e10cSrcweir 
1270cdf0e10cSrcweir     // reparent borderwindow and window
1271cdf0e10cSrcweir     if ( mpOldBorderWin )
1272cdf0e10cSrcweir         mpOldBorderWin->SetParent( pWin );
1273cdf0e10cSrcweir     GetWindow()->SetParent( pWin );
1274cdf0e10cSrcweir 
1275cdf0e10cSrcweir     // correct border window pointers
1276cdf0e10cSrcweir     GetWindow()->mpWindowImpl->mpBorderWindow = pWin;
1277cdf0e10cSrcweir     pWin->mpWindowImpl->mpClientWindow = GetWindow();
1278cdf0e10cSrcweir     GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
1279cdf0e10cSrcweir 
1280cdf0e10cSrcweir     // set mpFloatWin not until all window positioning is done !!!
1281cdf0e10cSrcweir     // (SetPosPixel etc. check for valid mpFloatWin pointer)
1282cdf0e10cSrcweir     mpFloatWin = pWin;
1283cdf0e10cSrcweir 
1284cdf0e10cSrcweir     // if the subtoolbar was opened via keyboard make sure that key events
1285cdf0e10cSrcweir     // will go into subtoolbar
1286cdf0e10cSrcweir     if( pParentToolBox->IsKeyEvent() )
1287cdf0e10cSrcweir         nFlags |= FLOATWIN_POPUPMODE_GRABFOCUS;
1288cdf0e10cSrcweir 
1289cdf0e10cSrcweir     mpFloatWin->StartPopupMode( pParentToolBox, nFlags );
1290cdf0e10cSrcweir     GetWindow()->Show();
1291cdf0e10cSrcweir 
1292cdf0e10cSrcweir     if( pParentToolBox->IsKeyEvent() )
1293cdf0e10cSrcweir     {
1294cdf0e10cSrcweir         // send HOME key to subtoolbar in order to select first item
1295cdf0e10cSrcweir         KeyEvent aEvent( 0, KeyCode( KEY_HOME ) );
1296cdf0e10cSrcweir         mpFloatWin->GetPreferredKeyInputWindow()->KeyInput( aEvent );
1297cdf0e10cSrcweir     }
1298cdf0e10cSrcweir }
1299cdf0e10cSrcweir 
IMPL_LINK(ImplDockingWindowWrapper,PopupModeEnd,void *,EMPTYARG)1300cdf0e10cSrcweir IMPL_LINK( ImplDockingWindowWrapper, PopupModeEnd, void*, EMPTYARG )
1301cdf0e10cSrcweir {
1302cdf0e10cSrcweir     GetWindow()->Show( sal_False, SHOW_NOFOCUSCHANGE );
1303cdf0e10cSrcweir 
1304cdf0e10cSrcweir     // set parameter for handler before destroying floating window
1305cdf0e10cSrcweir     ImplPopupFloatWin *pPopupFloatWin = (ImplPopupFloatWin*) mpFloatWin;
1306cdf0e10cSrcweir     EndPopupModeData aData( pPopupFloatWin->GetTearOffPosition(), mpFloatWin->IsPopupModeTearOff() );
1307cdf0e10cSrcweir 
1308cdf0e10cSrcweir     // before deleting change parent back, so we can delete the floating window alone
1309cdf0e10cSrcweir     Window* pRealParent = GetWindow()->GetWindow( WINDOW_PARENT );
1310cdf0e10cSrcweir     GetWindow()->mpWindowImpl->mpBorderWindow = NULL;
1311cdf0e10cSrcweir     if ( mpOldBorderWin )
1312cdf0e10cSrcweir     {
1313cdf0e10cSrcweir         GetWindow()->SetParent( mpOldBorderWin );
1314cdf0e10cSrcweir         ((ImplBorderWindow*)mpOldBorderWin)->GetBorder(
1315cdf0e10cSrcweir             GetWindow()->mpWindowImpl->mnLeftBorder, GetWindow()->mpWindowImpl->mnTopBorder,
1316cdf0e10cSrcweir             GetWindow()->mpWindowImpl->mnRightBorder, GetWindow()->mpWindowImpl->mnBottomBorder );
1317cdf0e10cSrcweir         mpOldBorderWin->Resize();
1318cdf0e10cSrcweir     }
1319cdf0e10cSrcweir     GetWindow()->mpWindowImpl->mpBorderWindow = mpOldBorderWin;
1320cdf0e10cSrcweir     GetWindow()->SetParent( pRealParent );
1321cdf0e10cSrcweir     GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
1322cdf0e10cSrcweir 
1323cdf0e10cSrcweir     delete mpFloatWin;
1324cdf0e10cSrcweir     mpFloatWin = NULL;
1325cdf0e10cSrcweir 
1326cdf0e10cSrcweir     // call handler - which will destroy the window and thus the wrapper as well !
1327cdf0e10cSrcweir     GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_ENDPOPUPMODE, &aData );
1328cdf0e10cSrcweir 
1329cdf0e10cSrcweir     return 0;
1330cdf0e10cSrcweir }
1331cdf0e10cSrcweir 
1332cdf0e10cSrcweir 
IsInPopupMode() const1333cdf0e10cSrcweir sal_Bool ImplDockingWindowWrapper::IsInPopupMode() const
1334cdf0e10cSrcweir {
1335cdf0e10cSrcweir     if( GetFloatingWindow() )
1336cdf0e10cSrcweir         return GetFloatingWindow()->IsInPopupMode();
1337cdf0e10cSrcweir     else
1338cdf0e10cSrcweir         return sal_False;
1339cdf0e10cSrcweir }
1340cdf0e10cSrcweir 
1341cdf0e10cSrcweir // -----------------------------------------------------------------------
1342cdf0e10cSrcweir 
SetFloatingMode(sal_Bool bFloatMode)1343cdf0e10cSrcweir void ImplDockingWindowWrapper::SetFloatingMode( sal_Bool bFloatMode )
1344cdf0e10cSrcweir {
1345cdf0e10cSrcweir     // do nothing if window is docked and locked
1346cdf0e10cSrcweir     if( !IsFloatingMode() && IsLocked() )
1347cdf0e10cSrcweir         return;
1348cdf0e10cSrcweir 
1349cdf0e10cSrcweir     if ( IsFloatingMode() != bFloatMode )
1350cdf0e10cSrcweir     {
1351cdf0e10cSrcweir         if ( PrepareToggleFloatingMode() )
1352cdf0e10cSrcweir         {
1353cdf0e10cSrcweir             sal_Bool bVisible = GetWindow()->IsVisible();
1354cdf0e10cSrcweir 
1355cdf0e10cSrcweir             if ( bFloatMode )
1356cdf0e10cSrcweir             {
1357cdf0e10cSrcweir                 GetWindow()->Show( sal_False, SHOW_NOFOCUSCHANGE );
1358cdf0e10cSrcweir 
1359cdf0e10cSrcweir                 maDockPos = GetWindow()->GetPosPixel();
1360cdf0e10cSrcweir 
1361cdf0e10cSrcweir                 Window* pRealParent = GetWindow()->GetWindow( WINDOW_PARENT );
1362cdf0e10cSrcweir                 mpOldBorderWin = GetWindow()->GetWindow( WINDOW_BORDER );
1363cdf0e10cSrcweir                 if( mpOldBorderWin == mpDockingWindow )
1364cdf0e10cSrcweir                     mpOldBorderWin = NULL;  // no border window found
1365cdf0e10cSrcweir 
1366cdf0e10cSrcweir                 ImplDockFloatWin2* pWin =
1367cdf0e10cSrcweir                     new ImplDockFloatWin2(
1368cdf0e10cSrcweir                                          mpParent,
1369cdf0e10cSrcweir                                          mnFloatBits & ( WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE ) ?
1370cdf0e10cSrcweir                                           mnFloatBits | WB_SYSTEMWINDOW
1371cdf0e10cSrcweir //#ifdef __USE_OWNERDRAWDECORATION__
1372cdf0e10cSrcweir                                           | WB_OWNERDRAWDECORATION
1373cdf0e10cSrcweir //#endif
1374cdf0e10cSrcweir                                           : mnFloatBits,
1375cdf0e10cSrcweir                                          this );
1376cdf0e10cSrcweir 
1377cdf0e10cSrcweir                 // reduce the border width for seamless NWF painting
1378cdf0e10cSrcweir                 // (especially for the toolbar gradient on Windows XP)
1379cdf0e10cSrcweir                 /*AllSettings aSettings( pWin->GetSettings() );
1380cdf0e10cSrcweir                 StyleSettings aStyleSettings( aSettings.GetStyleSettings() );
1381cdf0e10cSrcweir                 aStyleSettings.SetBorderSize( 0 );
1382cdf0e10cSrcweir                 aSettings.SetStyleSettings( aStyleSettings );
1383cdf0e10cSrcweir                 pWin->SetSettings( aSettings );*/
1384cdf0e10cSrcweir 
1385cdf0e10cSrcweir //                mpFloatWin      = pWin;
1386cdf0e10cSrcweir 
1387cdf0e10cSrcweir 
1388cdf0e10cSrcweir                 GetWindow()->mpWindowImpl->mpBorderWindow  = NULL;
1389cdf0e10cSrcweir                 GetWindow()->mpWindowImpl->mnLeftBorder    = 0;
1390cdf0e10cSrcweir                 GetWindow()->mpWindowImpl->mnTopBorder     = 0;
1391cdf0e10cSrcweir                 GetWindow()->mpWindowImpl->mnRightBorder   = 0;
1392cdf0e10cSrcweir                 GetWindow()->mpWindowImpl->mnBottomBorder  = 0;
1393cdf0e10cSrcweir 
1394cdf0e10cSrcweir                 // Falls Parent zerstoert wird, muessen wir auch vom
1395cdf0e10cSrcweir                 // BorderWindow den Parent umsetzen
1396cdf0e10cSrcweir                 if ( mpOldBorderWin )
1397cdf0e10cSrcweir                     mpOldBorderWin->SetParent( pWin );
1398cdf0e10cSrcweir                 GetWindow()->SetParent( pWin );
1399cdf0e10cSrcweir                 pWin->SetPosPixel( Point() );
1400cdf0e10cSrcweir 
1401cdf0e10cSrcweir                 GetWindow()->mpWindowImpl->mpBorderWindow = pWin;
1402cdf0e10cSrcweir                 pWin->mpWindowImpl->mpClientWindow = mpDockingWindow;
1403cdf0e10cSrcweir                 GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
1404cdf0e10cSrcweir 
1405cdf0e10cSrcweir                 pWin->SetText( GetWindow()->GetText() );
1406cdf0e10cSrcweir                 pWin->SetOutputSizePixel( GetWindow()->GetSizePixel() );
1407cdf0e10cSrcweir                 pWin->SetPosPixel( maFloatPos );
1408cdf0e10cSrcweir                 // DockingDaten ans FloatingWindow weiterreichen
1409cdf0e10cSrcweir                 pWin->ShowTitleButton( TITLE_BUTTON_DOCKING, mbDockBtn );
1410cdf0e10cSrcweir                 pWin->ShowTitleButton( TITLE_BUTTON_HIDE, mbHideBtn );
1411cdf0e10cSrcweir                 pWin->SetPin( mbPined );
1412cdf0e10cSrcweir                 if ( mbRollUp )
1413cdf0e10cSrcweir                     pWin->RollUp();
1414cdf0e10cSrcweir                 else
1415cdf0e10cSrcweir                     pWin->RollDown();
1416cdf0e10cSrcweir                 pWin->SetRollUpOutputSizePixel( maRollUpOutSize );
1417cdf0e10cSrcweir                 pWin->SetMinOutputSizePixel( maMinOutSize );
1418cdf0e10cSrcweir                 pWin->SetMaxOutputSizePixel( maMaxOutSize );
1419cdf0e10cSrcweir 
1420cdf0e10cSrcweir                 mpFloatWin      = pWin;
1421cdf0e10cSrcweir 
1422cdf0e10cSrcweir                 if ( bVisible )
1423cdf0e10cSrcweir                     GetWindow()->Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
1424cdf0e10cSrcweir 
1425cdf0e10cSrcweir                 ToggleFloatingMode();
1426cdf0e10cSrcweir             }
1427cdf0e10cSrcweir             else
1428cdf0e10cSrcweir             {
1429cdf0e10cSrcweir                 GetWindow()->Show( sal_False, SHOW_NOFOCUSCHANGE );
1430cdf0e10cSrcweir 
1431cdf0e10cSrcweir                 // FloatingDaten wird im FloatingWindow speichern
1432cdf0e10cSrcweir                 maFloatPos      = mpFloatWin->GetPosPixel();
1433cdf0e10cSrcweir                 mbDockBtn       = mpFloatWin->IsTitleButtonVisible( TITLE_BUTTON_DOCKING );
1434cdf0e10cSrcweir                 mbHideBtn       = mpFloatWin->IsTitleButtonVisible( TITLE_BUTTON_HIDE );
1435cdf0e10cSrcweir                 mbPined         = mpFloatWin->IsPined();
1436cdf0e10cSrcweir                 mbRollUp        = mpFloatWin->IsRollUp();
1437cdf0e10cSrcweir                 maRollUpOutSize = mpFloatWin->GetRollUpOutputSizePixel();
1438cdf0e10cSrcweir                 maMinOutSize    = mpFloatWin->GetMinOutputSizePixel();
1439cdf0e10cSrcweir                 maMaxOutSize    = mpFloatWin->GetMaxOutputSizePixel();
1440cdf0e10cSrcweir 
1441cdf0e10cSrcweir                 Window* pRealParent = GetWindow()->GetWindow( WINDOW_PARENT ); //mpWindowImpl->mpRealParent;
1442cdf0e10cSrcweir                 GetWindow()->mpWindowImpl->mpBorderWindow = NULL;
1443cdf0e10cSrcweir                 if ( mpOldBorderWin )
1444cdf0e10cSrcweir                 {
1445cdf0e10cSrcweir                     GetWindow()->SetParent( mpOldBorderWin );
1446cdf0e10cSrcweir                     ((ImplBorderWindow*)mpOldBorderWin)->GetBorder(
1447cdf0e10cSrcweir                         GetWindow()->mpWindowImpl->mnLeftBorder, GetWindow()->mpWindowImpl->mnTopBorder,
1448cdf0e10cSrcweir                         GetWindow()->mpWindowImpl->mnRightBorder, GetWindow()->mpWindowImpl->mnBottomBorder );
1449cdf0e10cSrcweir                     mpOldBorderWin->Resize();
1450cdf0e10cSrcweir                 }
1451cdf0e10cSrcweir                 GetWindow()->mpWindowImpl->mpBorderWindow = mpOldBorderWin;
1452cdf0e10cSrcweir                 GetWindow()->SetParent( pRealParent );
1453cdf0e10cSrcweir                 GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
1454cdf0e10cSrcweir 
1455cdf0e10cSrcweir                 delete static_cast<ImplDockFloatWin2*>(mpFloatWin);
1456cdf0e10cSrcweir                 mpFloatWin = NULL;
1457cdf0e10cSrcweir                 GetWindow()->SetPosPixel( maDockPos );
1458cdf0e10cSrcweir 
1459cdf0e10cSrcweir                 if ( bVisible )
1460cdf0e10cSrcweir                     GetWindow()->Show();
1461cdf0e10cSrcweir 
1462cdf0e10cSrcweir                 ToggleFloatingMode();
1463cdf0e10cSrcweir 
1464cdf0e10cSrcweir             }
1465cdf0e10cSrcweir         }
1466cdf0e10cSrcweir     }
1467cdf0e10cSrcweir }
1468cdf0e10cSrcweir 
1469cdf0e10cSrcweir // -----------------------------------------------------------------------
1470cdf0e10cSrcweir 
SetFloatStyle(WinBits nStyle)1471cdf0e10cSrcweir void ImplDockingWindowWrapper::SetFloatStyle( WinBits nStyle )
1472cdf0e10cSrcweir {
1473cdf0e10cSrcweir     mnFloatBits = nStyle;
1474cdf0e10cSrcweir }
1475cdf0e10cSrcweir 
1476cdf0e10cSrcweir // -----------------------------------------------------------------------
1477cdf0e10cSrcweir 
GetFloatStyle() const1478cdf0e10cSrcweir WinBits ImplDockingWindowWrapper::GetFloatStyle() const
1479cdf0e10cSrcweir {
1480cdf0e10cSrcweir     return mnFloatBits;
1481cdf0e10cSrcweir }
1482cdf0e10cSrcweir 
1483cdf0e10cSrcweir // -----------------------------------------------------------------------
1484cdf0e10cSrcweir 
SetTabStop()1485cdf0e10cSrcweir void ImplDockingWindowWrapper::SetTabStop()
1486cdf0e10cSrcweir {
1487cdf0e10cSrcweir     GetWindow()->SetStyle( GetWindow()->GetStyle() | (WB_GROUP | WB_TABSTOP) );
1488cdf0e10cSrcweir }
1489cdf0e10cSrcweir 
1490cdf0e10cSrcweir // -----------------------------------------------------------------------
1491cdf0e10cSrcweir 
SetPosSizePixel(long nX,long nY,long nWidth,long nHeight,sal_uInt16 nFlags)1492cdf0e10cSrcweir void ImplDockingWindowWrapper::SetPosSizePixel( long nX, long nY,
1493cdf0e10cSrcweir                                      long nWidth, long nHeight,
1494cdf0e10cSrcweir                                      sal_uInt16 nFlags )
1495cdf0e10cSrcweir {
1496cdf0e10cSrcweir     if ( mpFloatWin )
1497cdf0e10cSrcweir         mpFloatWin->SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
1498cdf0e10cSrcweir     else
1499cdf0e10cSrcweir         GetWindow()->SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
1500cdf0e10cSrcweir }
1501cdf0e10cSrcweir 
1502cdf0e10cSrcweir // -----------------------------------------------------------------------
1503cdf0e10cSrcweir 
GetPosPixel() const1504cdf0e10cSrcweir Point ImplDockingWindowWrapper::GetPosPixel() const
1505cdf0e10cSrcweir {
1506cdf0e10cSrcweir     if ( mpFloatWin )
1507cdf0e10cSrcweir         return mpFloatWin->GetPosPixel();
1508cdf0e10cSrcweir     else
1509cdf0e10cSrcweir         return mpDockingWindow->GetPosPixel();
1510cdf0e10cSrcweir }
1511cdf0e10cSrcweir 
1512cdf0e10cSrcweir // -----------------------------------------------------------------------
1513cdf0e10cSrcweir 
GetSizePixel() const1514cdf0e10cSrcweir Size ImplDockingWindowWrapper::GetSizePixel() const
1515cdf0e10cSrcweir {
1516cdf0e10cSrcweir     if ( mpFloatWin )
1517cdf0e10cSrcweir         return mpFloatWin->GetSizePixel();
1518cdf0e10cSrcweir     else
1519cdf0e10cSrcweir         return mpDockingWindow->GetSizePixel();
1520cdf0e10cSrcweir }
1521cdf0e10cSrcweir 
1522cdf0e10cSrcweir // -----------------------------------------------------------------------
1523cdf0e10cSrcweir 
SetOutputSizePixel(const Size & rNewSize)1524cdf0e10cSrcweir void ImplDockingWindowWrapper::SetOutputSizePixel( const Size& rNewSize )
1525cdf0e10cSrcweir {
1526cdf0e10cSrcweir     if ( mpFloatWin )
1527cdf0e10cSrcweir         mpFloatWin->SetOutputSizePixel( rNewSize );
1528cdf0e10cSrcweir     else
1529cdf0e10cSrcweir         GetWindow()->SetOutputSizePixel( rNewSize );
1530cdf0e10cSrcweir }
1531cdf0e10cSrcweir 
1532cdf0e10cSrcweir // -----------------------------------------------------------------------
1533cdf0e10cSrcweir 
GetOutputSizePixel() const1534cdf0e10cSrcweir Size ImplDockingWindowWrapper::GetOutputSizePixel() const
1535cdf0e10cSrcweir {
1536cdf0e10cSrcweir     if ( mpFloatWin )
1537cdf0e10cSrcweir         return mpFloatWin->GetOutputSizePixel();
1538cdf0e10cSrcweir     else
1539cdf0e10cSrcweir         return mpDockingWindow->GetOutputSizePixel();
1540cdf0e10cSrcweir }
1541cdf0e10cSrcweir 
GetFloatingPos() const1542cdf0e10cSrcweir Point ImplDockingWindowWrapper::GetFloatingPos() const
1543cdf0e10cSrcweir {
1544cdf0e10cSrcweir     if ( mpFloatWin )
1545cdf0e10cSrcweir     {
1546cdf0e10cSrcweir         //Rectangle aRect = mpFloatWin->GetWindow( WINDOW_CLIENT)->GetWindowExtentsRelative( mpFloatWin->GetParent() );
1547cdf0e10cSrcweir         WindowStateData aData;
1548cdf0e10cSrcweir         aData.SetMask( WINDOWSTATE_MASK_POS );
1549cdf0e10cSrcweir         mpFloatWin->GetWindowStateData( aData );
1550cdf0e10cSrcweir         Point aPos( aData.GetX(), aData.GetY() );
1551cdf0e10cSrcweir         aPos = mpFloatWin->GetParent()->ImplGetFrameWindow()->AbsoluteScreenToOutputPixel( aPos );
1552cdf0e10cSrcweir         return aPos;
1553cdf0e10cSrcweir     }
1554cdf0e10cSrcweir     else
1555cdf0e10cSrcweir         return maFloatPos;
1556cdf0e10cSrcweir }
1557cdf0e10cSrcweir 
1558cdf0e10cSrcweir // -----------------------------------------------------------------------
1559cdf0e10cSrcweir // old inlines from DockingWindow
1560cdf0e10cSrcweir // -----------------------------------------------------------------------
1561cdf0e10cSrcweir 
SetPin(sal_Bool bPin)1562cdf0e10cSrcweir void ImplDockingWindowWrapper::SetPin( sal_Bool bPin )
1563cdf0e10cSrcweir {
1564cdf0e10cSrcweir     if ( mpFloatWin )
1565cdf0e10cSrcweir         mpFloatWin->SetPin( bPin );
1566cdf0e10cSrcweir     mbPined = bPin;
1567cdf0e10cSrcweir }
1568cdf0e10cSrcweir 
IsPined() const1569cdf0e10cSrcweir sal_Bool ImplDockingWindowWrapper::IsPined() const
1570cdf0e10cSrcweir {
1571cdf0e10cSrcweir     if ( mpFloatWin )
1572cdf0e10cSrcweir         return mpFloatWin->IsPined();
1573cdf0e10cSrcweir     return mbPined;
1574cdf0e10cSrcweir }
1575cdf0e10cSrcweir 
RollUp()1576cdf0e10cSrcweir void ImplDockingWindowWrapper::RollUp()
1577cdf0e10cSrcweir {
1578cdf0e10cSrcweir     if ( mpFloatWin )
1579cdf0e10cSrcweir         mpFloatWin->RollUp();
1580cdf0e10cSrcweir     mbRollUp = sal_True;
1581cdf0e10cSrcweir }
1582cdf0e10cSrcweir 
RollDown()1583cdf0e10cSrcweir void ImplDockingWindowWrapper::RollDown()
1584cdf0e10cSrcweir {
1585cdf0e10cSrcweir     if ( mpFloatWin )
1586cdf0e10cSrcweir         mpFloatWin->RollDown();
1587cdf0e10cSrcweir     mbRollUp = sal_False;
1588cdf0e10cSrcweir }
1589cdf0e10cSrcweir 
IsRollUp() const1590cdf0e10cSrcweir sal_Bool ImplDockingWindowWrapper::IsRollUp() const
1591cdf0e10cSrcweir {
1592cdf0e10cSrcweir     if ( mpFloatWin )
1593cdf0e10cSrcweir         return mpFloatWin->IsRollUp();
1594cdf0e10cSrcweir     return mbRollUp;
1595cdf0e10cSrcweir }
1596cdf0e10cSrcweir 
SetRollUpOutputSizePixel(const Size & rSize)1597cdf0e10cSrcweir void ImplDockingWindowWrapper::SetRollUpOutputSizePixel( const Size& rSize )
1598cdf0e10cSrcweir {
1599cdf0e10cSrcweir     if ( mpFloatWin )
1600cdf0e10cSrcweir         mpFloatWin->SetRollUpOutputSizePixel( rSize );
1601cdf0e10cSrcweir     maRollUpOutSize = rSize;
1602cdf0e10cSrcweir }
1603cdf0e10cSrcweir 
GetRollUpOutputSizePixel() const1604cdf0e10cSrcweir Size ImplDockingWindowWrapper::GetRollUpOutputSizePixel() const
1605cdf0e10cSrcweir {
1606cdf0e10cSrcweir     if ( mpFloatWin )
1607cdf0e10cSrcweir         return mpFloatWin->GetRollUpOutputSizePixel();
1608cdf0e10cSrcweir     return maRollUpOutSize;
1609cdf0e10cSrcweir }
1610cdf0e10cSrcweir 
SetMinOutputSizePixel(const Size & rSize)1611cdf0e10cSrcweir void ImplDockingWindowWrapper::SetMinOutputSizePixel( const Size& rSize )
1612cdf0e10cSrcweir {
1613cdf0e10cSrcweir     if ( mpFloatWin )
1614cdf0e10cSrcweir         mpFloatWin->SetMinOutputSizePixel( rSize );
1615cdf0e10cSrcweir     maMinOutSize = rSize;
1616cdf0e10cSrcweir }
1617cdf0e10cSrcweir 
SetMaxOutputSizePixel(const Size & rSize)1618cdf0e10cSrcweir void ImplDockingWindowWrapper::SetMaxOutputSizePixel( const Size& rSize )
1619cdf0e10cSrcweir {
1620cdf0e10cSrcweir     if ( mpFloatWin )
1621cdf0e10cSrcweir         mpFloatWin->SetMaxOutputSizePixel( rSize );
1622cdf0e10cSrcweir     maMaxOutSize = rSize;
1623cdf0e10cSrcweir }
1624cdf0e10cSrcweir 
GetMinOutputSizePixel() const1625cdf0e10cSrcweir const Size& ImplDockingWindowWrapper::GetMinOutputSizePixel() const
1626cdf0e10cSrcweir {
1627cdf0e10cSrcweir     if ( mpFloatWin )
1628cdf0e10cSrcweir         return mpFloatWin->GetMinOutputSizePixel();
1629cdf0e10cSrcweir     return maMinOutSize;
1630cdf0e10cSrcweir }
1631cdf0e10cSrcweir 
GetMaxOutputSizePixel() const1632cdf0e10cSrcweir const Size& ImplDockingWindowWrapper::GetMaxOutputSizePixel() const
1633cdf0e10cSrcweir {
1634cdf0e10cSrcweir     if ( mpFloatWin )
1635cdf0e10cSrcweir         return mpFloatWin->GetMaxOutputSizePixel();
1636cdf0e10cSrcweir     return maMaxOutSize;
1637cdf0e10cSrcweir }
1638cdf0e10cSrcweir 
SetFloatingPos(const Point & rNewPos)1639cdf0e10cSrcweir void ImplDockingWindowWrapper::SetFloatingPos( const Point& rNewPos )
1640cdf0e10cSrcweir {
1641cdf0e10cSrcweir     if ( mpFloatWin )
1642cdf0e10cSrcweir         mpFloatWin->SetPosPixel( rNewPos );
1643cdf0e10cSrcweir     else
1644cdf0e10cSrcweir         maFloatPos = rNewPos;
1645cdf0e10cSrcweir }
1646cdf0e10cSrcweir 
IsFloatingMode() const1647cdf0e10cSrcweir sal_Bool ImplDockingWindowWrapper::IsFloatingMode() const
1648cdf0e10cSrcweir {
1649cdf0e10cSrcweir     return (mpFloatWin != NULL);
1650cdf0e10cSrcweir }
1651cdf0e10cSrcweir 
1652cdf0e10cSrcweir 
SetDragArea(const Rectangle & rRect)1653cdf0e10cSrcweir void    ImplDockingWindowWrapper::SetDragArea( const Rectangle& rRect )
1654cdf0e10cSrcweir {
1655cdf0e10cSrcweir     maDragArea = rRect;
1656cdf0e10cSrcweir }
1657cdf0e10cSrcweir 
GetDragArea() const1658cdf0e10cSrcweir Rectangle  ImplDockingWindowWrapper::GetDragArea() const
1659cdf0e10cSrcweir {
1660cdf0e10cSrcweir     return maDragArea;
1661cdf0e10cSrcweir }
1662cdf0e10cSrcweir 
Lock()1663cdf0e10cSrcweir void ImplDockingWindowWrapper::Lock()
1664cdf0e10cSrcweir {
1665cdf0e10cSrcweir     mbLocked = sal_True;
1666cdf0e10cSrcweir     // only toolbars support locking
1667cdf0e10cSrcweir     ToolBox *pToolBox = dynamic_cast< ToolBox * >( GetWindow() );
1668cdf0e10cSrcweir     if( pToolBox )
1669cdf0e10cSrcweir         pToolBox->Lock( mbLocked );
1670cdf0e10cSrcweir }
1671cdf0e10cSrcweir 
Unlock()1672cdf0e10cSrcweir void ImplDockingWindowWrapper::Unlock()
1673cdf0e10cSrcweir {
1674cdf0e10cSrcweir     mbLocked = sal_False;
1675cdf0e10cSrcweir     // only toolbars support locking
1676cdf0e10cSrcweir     ToolBox *pToolBox = dynamic_cast< ToolBox * >( GetWindow() );
1677cdf0e10cSrcweir     if( pToolBox )
1678cdf0e10cSrcweir         pToolBox->Lock( mbLocked );
1679cdf0e10cSrcweir }
1680cdf0e10cSrcweir 
IsLocked() const1681cdf0e10cSrcweir sal_Bool ImplDockingWindowWrapper::IsLocked() const
1682cdf0e10cSrcweir {
1683cdf0e10cSrcweir     return mbLocked;
1684cdf0e10cSrcweir }
1685