update dev300-m58
[ooovba.git] / vcl / source / window / dockmgr.cxx
blob72f56826754b31b5904f97105bf98a82f4386338
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dockmgr.cxx,v $
10 * $Revision: 1.24 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
34 #ifndef _SV_SVSYS_HXX
35 #include <svsys.h>
36 #endif
37 #include <tools/time.hxx>
38 #ifndef _SV_RC_H
39 #include <tools/rc.h>
40 #endif
41 #include <vcl/event.hxx>
42 #include <vcl/brdwin.hxx>
43 #include <vcl/floatwin.hxx>
44 #include <vcl/dockwin.hxx>
45 #include <vcl/toolbox.hxx>
46 #include <vcl/svapp.hxx>
47 #include <vcl/svdata.hxx>
48 #include <vcl/timer.hxx>
49 #include <vcl/lineinfo.hxx>
50 #include <vcl/window.h>
51 #include <vcl/unowrap.hxx>
52 #include <vcl/salframe.hxx>
55 // =======================================================================
57 #define DOCKWIN_FLOATSTYLES (WB_SIZEABLE | WB_MOVEABLE | WB_CLOSEABLE | WB_STANDALONE | WB_PINABLE | WB_ROLLABLE )
59 // =======================================================================
62 // =======================================================================
64 class ImplDockFloatWin2 : public FloatingWindow
66 private:
67 ImplDockingWindowWrapper* mpDockWin;
68 ULONG mnLastTicks;
69 Timer maDockTimer;
70 Timer maEndDockTimer;
71 Point maDockPos;
72 Rectangle maDockRect;
73 BOOL mbInMove;
74 ULONG mnLastUserEvent;
76 DECL_LINK( DockingHdl, ImplDockFloatWin2* );
77 DECL_LINK( DockTimerHdl, ImplDockFloatWin2* );
78 DECL_LINK( EndDockTimerHdl, ImplDockFloatWin2* );
79 public:
80 ImplDockFloatWin2( Window* pParent, WinBits nWinBits,
81 ImplDockingWindowWrapper* pDockingWin );
82 ~ImplDockFloatWin2();
84 virtual void Move();
85 virtual void Resize();
86 virtual void TitleButtonClick( USHORT nButton );
87 virtual void Pin();
88 virtual void Roll();
89 virtual void PopupModeEnd();
90 virtual void Resizing( Size& rSize );
91 virtual BOOL Close();
92 using Window::SetPosSizePixel;
93 virtual void SetPosSizePixel( long nX, long nY,
94 long nWidth, long nHeight,
95 USHORT nFlags = WINDOW_POSSIZE_ALL );
97 ULONG GetLastTicks() const { return mnLastTicks; }
100 // =======================================================================
102 ImplDockFloatWin2::ImplDockFloatWin2( Window* pParent, WinBits nWinBits,
103 ImplDockingWindowWrapper* pDockingWin ) :
104 FloatingWindow( pParent, nWinBits ),
105 mpDockWin( pDockingWin ),
106 mnLastTicks( Time::GetSystemTicks() ),
107 mbInMove( FALSE ),
108 mnLastUserEvent( 0 )
110 // Daten vom DockingWindow uebernehmen
111 if ( pDockingWin )
113 SetSettings( pDockingWin->GetWindow()->GetSettings() );
114 Enable( pDockingWin->GetWindow()->IsEnabled(), FALSE );
115 EnableInput( pDockingWin->GetWindow()->IsInputEnabled(), FALSE );
116 AlwaysEnableInput( pDockingWin->GetWindow()->IsAlwaysEnableInput(), FALSE );
117 EnableAlwaysOnTop( pDockingWin->GetWindow()->IsAlwaysOnTopEnabled() );
118 SetActivateMode( pDockingWin->GetWindow()->GetActivateMode() );
121 SetBackground( GetSettings().GetStyleSettings().GetFaceColor() );
123 maDockTimer.SetTimeoutHdl( LINK( this, ImplDockFloatWin2, DockTimerHdl ) );
124 maDockTimer.SetTimeout( 50 );
125 maEndDockTimer.SetTimeoutHdl( LINK( this, ImplDockFloatWin2, EndDockTimerHdl ) );
126 maEndDockTimer.SetTimeout( 50 );
129 // -----------------------------------------------------------------------
131 ImplDockFloatWin2::~ImplDockFloatWin2()
133 if( mnLastUserEvent )
134 Application::RemoveUserEvent( mnLastUserEvent );
137 // -----------------------------------------------------------------------
139 IMPL_LINK( ImplDockFloatWin2, DockTimerHdl, ImplDockFloatWin2*, EMPTYARG )
141 DBG_ASSERT( mpDockWin->IsFloatingMode(), "docktimer called but not floating" );
143 maDockTimer.Stop();
144 PointerState aState = GetPointerState();
146 if( aState.mnState & KEY_MOD1 )
148 // i43499 CTRL disables docking now
149 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
150 if( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) )
151 maDockTimer.Start();
153 else if( ! ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) )
155 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
156 mpDockWin->EndDocking( maDockRect, FALSE );
158 else
160 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect, SHOWTRACK_BIG | SHOWTRACK_WINDOW );
161 maDockTimer.Start();
164 return 0;
167 IMPL_LINK( ImplDockFloatWin2, EndDockTimerHdl, ImplDockFloatWin2*, EMPTYARG )
169 DBG_ASSERT( mpDockWin->IsFloatingMode(), "enddocktimer called but not floating" );
171 maEndDockTimer.Stop();
172 PointerState aState = GetPointerState();
173 if( ! ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) )
175 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
176 mpDockWin->EndDocking( maDockRect, TRUE );
178 else
180 maEndDockTimer.Start();
183 return 0;
187 IMPL_LINK( ImplDockFloatWin2, DockingHdl, ImplDockFloatWin2*, EMPTYARG )
189 // called during move of a floating window
190 mnLastUserEvent = 0;
192 Window *pDockingArea = mpDockWin->GetWindow()->GetParent();
193 PointerState aState = pDockingArea->GetPointerState();
195 BOOL bRealMove = TRUE;
196 if( GetStyle() & WB_OWNERDRAWDECORATION )
198 // for windows with ownerdraw decoration
199 // we allow docking only when the window was moved
200 // by dragging its caption
201 // and ignore move request due to resizing
202 Window *pBorder = GetWindow( WINDOW_BORDER );
203 if( pBorder != this )
205 Point aPt;
206 Rectangle aBorderRect( aPt, pBorder->GetSizePixel() );
207 sal_Int32 nLeft, nTop, nRight, nBottom;
208 GetBorder( nLeft, nTop, nRight, nBottom );
209 // limit borderrect to the caption part only and without the resizing borders
210 aBorderRect.nBottom = aBorderRect.nTop + nTop;
211 aBorderRect.nLeft += nLeft;
212 aBorderRect.nRight -= nRight;
214 PointerState aBorderState = pBorder->GetPointerState();
215 if( aBorderRect.IsInside( aBorderState.maPos ) )
216 bRealMove = TRUE;
217 else
218 bRealMove = FALSE;
222 if( mpDockWin->IsDockable() &&
223 mpDockWin->GetWindow()->IsVisible() &&
224 (Time::GetSystemTicks() - mnLastTicks > 500) &&
225 ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) &&
226 !(aState.mnState & KEY_MOD1) && // i43499 CTRL disables docking now
227 bRealMove )
229 maDockPos = Point( pDockingArea->OutputToScreenPixel( pDockingArea->AbsoluteScreenToOutputPixel( OutputToAbsoluteScreenPixel( Point() ) ) ) );
230 maDockRect = Rectangle( maDockPos, mpDockWin->GetSizePixel() );
232 // mouse pos in screen pixels
233 Point aMousePos = pDockingArea->OutputToScreenPixel( aState.maPos );
235 if( ! mpDockWin->IsDocking() )
236 mpDockWin->StartDocking( aMousePos, maDockRect );
238 BOOL bFloatMode = mpDockWin->Docking( aMousePos, maDockRect );
240 if( ! bFloatMode )
242 // indicates that the window could be docked at maDockRect
243 maDockRect.SetPos( mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->ScreenToOutputPixel(
244 maDockRect.TopLeft() ) );
245 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect, SHOWTRACK_BIG | SHOWTRACK_WINDOW );
246 maEndDockTimer.Stop();
247 DockTimerHdl( this );
249 else
251 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
252 maDockTimer.Stop();
253 EndDockTimerHdl( this );
256 mbInMove = FALSE;
257 return 0;
259 // -----------------------------------------------------------------------
261 void ImplDockFloatWin2::Move()
263 if( mbInMove )
264 return;
266 mbInMove = TRUE;
267 FloatingWindow::Move();
268 mpDockWin->GetWindow()->Move();
271 * note: the window should only dock if KEY_MOD1 is pressed
272 * and the user releases all mouse buttons. The real problem here
273 * is that we don't get mouse events (at least not on X)
274 * if the mouse is on the decoration. So we have to start an
275 * awkward timer based process that polls the modifier/buttons
276 * to see whether they are in the right condition shortly after the
277 * last Move message.
279 if( ! mnLastUserEvent )
280 mnLastUserEvent = Application::PostUserEvent( LINK( this, ImplDockFloatWin2, DockingHdl ) );
283 // -----------------------------------------------------------------------
285 void ImplDockFloatWin2::Resize()
287 // forwarding of resize only required if we have no borderwindow ( GetWindow() then returns 'this' )
288 if( GetWindow( WINDOW_BORDER ) == this )
290 FloatingWindow::Resize();
291 Size aSize( GetSizePixel() );
292 mpDockWin->GetWindow()->ImplPosSizeWindow( 0, 0, aSize.Width(), aSize.Height(), WINDOW_POSSIZE_POSSIZE ); // is this needed ???
296 void ImplDockFloatWin2::SetPosSizePixel( long nX, long nY,
297 long nWidth, long nHeight,
298 USHORT nFlags )
300 FloatingWindow::SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
303 // -----------------------------------------------------------------------
306 void ImplDockFloatWin2::TitleButtonClick( USHORT nButton )
308 FloatingWindow::TitleButtonClick( nButton );
309 mpDockWin->TitleButtonClick( nButton );
312 // -----------------------------------------------------------------------
314 void ImplDockFloatWin2::Pin()
316 FloatingWindow::Pin();
317 mpDockWin->Pin();
320 // -----------------------------------------------------------------------
322 void ImplDockFloatWin2::Roll()
324 FloatingWindow::Roll();
325 mpDockWin->Roll();
328 // -----------------------------------------------------------------------
330 void ImplDockFloatWin2::PopupModeEnd()
332 FloatingWindow::PopupModeEnd();
333 mpDockWin->PopupModeEnd();
336 // -----------------------------------------------------------------------
338 void ImplDockFloatWin2::Resizing( Size& rSize )
340 FloatingWindow::Resizing( rSize );
341 mpDockWin->Resizing( rSize );
344 // -----------------------------------------------------------------------
346 BOOL ImplDockFloatWin2::Close()
348 return mpDockWin->Close();
351 // =======================================================================
353 DockingManager::DockingManager()
357 DockingManager::~DockingManager()
359 ::std::vector< ImplDockingWindowWrapper* >::iterator p;
360 p = mDockingWindows.begin();
361 for(; p != mDockingWindows.end(); ++p )
363 delete (*p);
365 mDockingWindows.clear();
368 ImplDockingWindowWrapper* DockingManager::GetDockingWindowWrapper( const Window *pWindow )
370 ::std::vector< ImplDockingWindowWrapper* >::iterator p;
371 p = mDockingWindows.begin();
372 while( p != mDockingWindows.end() )
374 if( (*p)->mpDockingWindow == pWindow )
375 return (*p);
376 else
377 p++;
379 return NULL;
382 BOOL DockingManager::IsDockable( const Window *pWindow )
384 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
387 if( pWindow->HasDockingHandler() )
388 return TRUE;
390 return (pWrapper != NULL);
393 BOOL DockingManager::IsFloating( const Window *pWindow )
395 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
396 if( pWrapper )
397 return pWrapper->IsFloatingMode();
398 else
399 return FALSE;
402 BOOL DockingManager::IsLocked( const Window *pWindow )
404 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
405 if( pWrapper && pWrapper->IsLocked() )
406 return TRUE;
407 else
408 return FALSE;
411 void DockingManager::Lock( const Window *pWindow )
413 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
414 if( pWrapper )
415 pWrapper->Lock();
418 void DockingManager::Unlock( const Window *pWindow )
420 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
421 if( pWrapper )
422 pWrapper->Unlock();
425 void DockingManager::SetFloatingMode( const Window *pWindow, BOOL bFloating )
427 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
428 if( pWrapper )
429 pWrapper->SetFloatingMode( bFloating );
432 void DockingManager::StartPopupMode( ToolBox *pParentToolBox, const Window *pWindow )
434 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
435 if( pWrapper )
436 pWrapper->StartPopupMode( pParentToolBox );
439 BOOL DockingManager::IsInPopupMode( const Window *pWindow )
441 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
442 if( pWrapper && pWrapper->IsInPopupMode() )
443 return TRUE;
444 else
445 return FALSE;
448 void DockingManager::AddWindow( const Window *pWindow )
450 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
451 if( pWrapper )
452 return;
453 else
454 pWrapper = new ImplDockingWindowWrapper( pWindow );
456 mDockingWindows.push_back( pWrapper );
459 void DockingManager::RemoveWindow( const Window *pWindow )
461 ::std::vector< ImplDockingWindowWrapper* >::iterator p;
462 p = mDockingWindows.begin();
463 while( p != mDockingWindows.end() )
465 if( (*p)->mpDockingWindow == pWindow )
467 delete (*p);
468 mDockingWindows.erase( p );
469 break;
471 else
472 p++;
476 void DockingManager::SetPosSizePixel( Window *pWindow, long nX, long nY,
477 long nWidth, long nHeight,
478 USHORT nFlags )
480 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
481 if( pWrapper )
482 pWrapper->SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
485 Rectangle DockingManager::GetPosSizePixel( const Window *pWindow )
487 Rectangle aRect;
488 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
489 if( pWrapper )
490 aRect = Rectangle( pWrapper->GetPosPixel(), pWrapper->GetSizePixel() );
492 return aRect;
495 // =======================================================================
496 // special floating window for popup mode
497 // main purpose: provides tear-off area for undocking
498 // =======================================================================
500 // if TEAROFF_DASHED defined a single dashed line is used
501 // otherwise multiple smaller lines will be painted
502 //#define TEAROFF_DASHED
504 // size of the drag area
505 #ifdef TEAROFF_DASHED
506 #define POPUP_DRAGBORDER 2
507 #define POPUP_DRAGGRIP 5
508 #else
509 #define POPUP_DRAGBORDER 3
510 #define POPUP_DRAGGRIP 5
511 #endif
512 #define POPUP_DRAGHEIGHT (POPUP_DRAGGRIP+POPUP_DRAGBORDER+POPUP_DRAGBORDER)
513 #define POPUP_DRAGWIDTH 20
515 class ImplPopupFloatWin : public FloatingWindow
517 private:
518 ImplDockingWindowWrapper* mpDockingWin;
519 BOOL mbHighlight;
520 BOOL mbMoving;
521 Point maDelta;
522 Point maTearOffPosition;
523 void ImplSetBorder();
525 public:
526 ImplPopupFloatWin( Window* pParent, ImplDockingWindowWrapper* pDockingWin );
527 ~ImplPopupFloatWin();
529 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
530 virtual void Paint( const Rectangle& rRect );
531 virtual void MouseMove( const MouseEvent& rMEvt );
532 virtual void MouseButtonDown( const MouseEvent& rMEvt );
533 virtual void MouseButtonUp( const MouseEvent& rMEvt );
534 virtual void Tracking( const TrackingEvent& rTEvt );
535 virtual void Resize();
536 virtual Window* GetPreferredKeyInputWindow();
538 Rectangle GetDragRect() const;
539 Point GetToolboxPosition() const;
540 Point GetTearOffPosition() const;
541 void DrawGrip();
542 void DrawBorder();
545 ImplPopupFloatWin::ImplPopupFloatWin( Window* pParent, ImplDockingWindowWrapper* pDockingWin ) :
546 FloatingWindow( pParent, WB_NOBORDER | WB_SYSTEMWINDOW | WB_NOSHADOW)
548 mpWindowImpl->mbToolbarFloatingWindow = TRUE; // indicate window type, required for accessibility
549 // which should not see this window as a toplevel window
550 mpDockingWin = pDockingWin;
551 mbHighlight = FALSE;
552 mbMoving = FALSE;
554 ImplSetBorder();
557 ImplPopupFloatWin::~ImplPopupFloatWin()
559 mpDockingWin = NULL;
562 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > ImplPopupFloatWin::CreateAccessible()
564 // switch off direct accessibilty support for this window
566 // this is to avoid appearance of this window as standalone window in the accessibility hierarchy
567 // as this window is only used as a helper for subtoolbars that are not teared-off, the parent toolbar
568 // has to provide accessibility support (as implemented in the toolkit)
569 // so the contained toolbar should appear as child of the correponsing toolbar item of the parent toolbar
570 return ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >();
573 Window* ImplPopupFloatWin::GetPreferredKeyInputWindow()
575 if( mpWindowImpl->mpClientWindow )
576 return mpWindowImpl->mpClientWindow;
577 else
578 return FloatingWindow::GetPreferredKeyInputWindow();
582 void ImplPopupFloatWin::ImplSetBorder()
584 // although we have no border in the sense of a borderwindow
585 // we're using a special border for the grip
586 // by setting those members the method SetOutputSizePixel() can
587 // be used to set the proper window size
588 mpWindowImpl->mnTopBorder = 1 + POPUP_DRAGHEIGHT+2;
589 mpWindowImpl->mnBottomBorder = 1;
590 mpWindowImpl->mnLeftBorder = 1;
591 mpWindowImpl->mnRightBorder = 1;
594 void ImplPopupFloatWin::Resize()
596 // the borderview overwrites the border during resize so restore it
597 ImplSetBorder();
600 Rectangle ImplPopupFloatWin::GetDragRect() const
602 return Rectangle( 1, 1, GetOutputSizePixel().Width()-1, 2+POPUP_DRAGHEIGHT );
605 Point ImplPopupFloatWin::GetToolboxPosition() const
607 // return inner position where a toolbox could be placed
608 Point aPt( 1, 1+GetDragRect().getHeight() ); // grip + border
609 return aPt;
612 Point ImplPopupFloatWin::GetTearOffPosition() const
614 Point aPt( maTearOffPosition );
615 //aPt += GetToolboxPosition(); // remove 'decoration'
616 return aPt;
619 void ImplPopupFloatWin::DrawBorder()
621 SetFillColor();
622 SetLineColor( GetSettings().GetStyleSettings().GetShadowColor() );
623 Point aPt;
624 Rectangle aRect( aPt, GetOutputSizePixel() );
626 Region oldClipRgn( GetClipRegion( ) );
627 Region aClipRgn( aRect );
628 Rectangle aItemClipRect( ImplGetItemEdgeClipRect() );
629 if( !aItemClipRect.IsEmpty() )
631 aItemClipRect.SetPos( AbsoluteScreenToOutputPixel( aItemClipRect.TopLeft() ) );
632 aClipRgn.Exclude( aItemClipRect );
633 SetClipRegion( aClipRgn );
635 DrawRect( aRect );
636 SetClipRegion( oldClipRgn );
639 void ImplPopupFloatWin::DrawGrip()
641 BOOL bLinecolor = IsLineColor();
642 Color aLinecolor = GetLineColor();
643 BOOL bFillcolor = IsFillColor();
644 Color aFillcolor = GetFillColor();
646 // draw background
647 Rectangle aRect( GetDragRect() );
648 aRect.nTop += POPUP_DRAGBORDER;
649 aRect.nBottom -= POPUP_DRAGBORDER;
650 aRect.nLeft+=3;
651 aRect.nRight-=3;
653 if( mbHighlight )
655 Erase( aRect );
656 DrawSelectionBackground( aRect, 2, FALSE, TRUE, FALSE );
658 else
660 SetFillColor( GetSettings().GetStyleSettings().GetFaceColor() );
661 SetLineColor();
662 DrawRect( aRect );
665 if( !ToolBox::AlwaysLocked() ) // no grip if toolboxes are locked
667 #ifdef TEAROFF_DASHED
668 // draw single dashed line
669 LineInfo aLineInfo( LINE_DASH );
670 aLineInfo.SetDistance( 4 );
671 aLineInfo.SetDashLen( 12 );
672 aLineInfo.SetDashCount( 1 );
674 aRect.nLeft+=2; aRect.nRight-=2;
676 aRect.nTop+=2;
677 aRect.nBottom = aRect.nTop;
678 SetLineColor( GetSettings().GetStyleSettings().GetDarkShadowColor() );
679 DrawLine( aRect.TopLeft(), aRect.TopRight(), aLineInfo );
681 if( !mbHighlight )
683 aRect.nTop++; aRect.nBottom++;
684 SetLineColor( GetSettings().GetStyleSettings().GetLightColor() );
685 DrawLine( aRect.TopLeft(), aRect.TopRight(), aLineInfo );
688 #else
689 // draw several grip lines
690 SetFillColor( GetSettings().GetStyleSettings().GetShadowColor() );
691 aRect.nTop++;
692 aRect.nBottom = aRect.nTop;
694 int width = POPUP_DRAGWIDTH;
695 while( width >= aRect.getWidth() )
696 width -= 4;
697 if( width <= 0 )
698 width = aRect.getWidth();
699 //aRect.nLeft = aRect.nLeft + (aRect.getWidth() - width) / 2;
700 aRect.nLeft = (aRect.nLeft + aRect.nRight - width) / 2;
701 aRect.nRight = aRect.nLeft + width;
703 int i=0;
704 while( i< POPUP_DRAGGRIP )
706 DrawRect( aRect );
707 aRect.nTop+=2;
708 aRect.nBottom+=2;
709 i+=2;
711 #endif
714 if( bLinecolor )
715 SetLineColor( aLinecolor );
716 else
717 SetLineColor();
718 if( bFillcolor )
719 SetFillColor( aFillcolor );
720 else
721 SetFillColor();
724 void ImplPopupFloatWin::Paint( const Rectangle& )
726 Point aPt;
727 Rectangle aRect( aPt, GetOutputSizePixel() );
728 DrawWallpaper( aRect, Wallpaper( GetSettings().GetStyleSettings().GetFaceGradientColor() ) );
729 DrawBorder();
730 DrawGrip();
733 void ImplPopupFloatWin::MouseMove( const MouseEvent& rMEvt )
735 Point aMousePos = rMEvt.GetPosPixel();
737 if( !ToolBox::AlwaysLocked() ) // no tear off if locking is enabled
739 if( rMEvt.IsLeft() && GetDragRect().IsInside( aMousePos ) )
741 // start window move
742 mbMoving = TRUE;
743 StartTracking( STARTTRACK_NOKEYCANCEL );
744 return;
746 if( !mbHighlight && GetDragRect().IsInside( aMousePos ) )
748 mbHighlight = TRUE;
749 DrawGrip();
751 if( mbHighlight && ( rMEvt.IsLeaveWindow() || !GetDragRect().IsInside( aMousePos ) ) )
753 mbHighlight = FALSE;
754 DrawGrip();
759 void ImplPopupFloatWin::MouseButtonUp( const MouseEvent& rMEvt )
761 FloatingWindow::MouseButtonUp( rMEvt );
764 void ImplPopupFloatWin::MouseButtonDown( const MouseEvent& rMEvt )
766 Point aMousePos = rMEvt.GetPosPixel();
767 if( GetDragRect().IsInside( aMousePos ) )
769 // get mouse pos at a static window to have a fixed reference point
770 PointerState aState = GetParent()->GetPointerState();
771 if (ImplHasMirroredGraphics() && IsRTLEnabled())
772 ImplMirrorFramePos(aState.maPos);
773 maTearOffPosition = GetWindow( WINDOW_BORDER )->GetPosPixel();
774 maDelta = aState.maPos - maTearOffPosition;
778 void ImplPopupFloatWin::Tracking( const TrackingEvent& rTEvt )
780 if( mbMoving )
782 if ( rTEvt.IsTrackingEnded() )
784 mbMoving = FALSE;
785 EndPopupMode( FLOATWIN_POPUPMODEEND_TEAROFF );
787 else if ( !rTEvt.GetMouseEvent().IsSynthetic() )
789 // move the window according to mouse pos
790 PointerState aState = GetParent()->GetPointerState();
791 if (ImplHasMirroredGraphics() && IsRTLEnabled())
792 ImplMirrorFramePos(aState.maPos);
793 maTearOffPosition = aState.maPos - maDelta;
794 GetWindow( WINDOW_BORDER )->SetPosPixel( maTearOffPosition );
800 // =======================================================================
802 ImplDockingWindowWrapper::ImplDockingWindowWrapper( const Window *pWindow )
804 ImplInitData();
806 mpDockingWindow = (Window*) pWindow;
807 mpParent = pWindow->GetParent();
808 mbDockable = TRUE;
809 mbLocked = FALSE;
810 mnFloatBits = WB_BORDER | WB_CLOSEABLE | WB_SIZEABLE | (pWindow->GetStyle() & DOCKWIN_FLOATSTYLES);
811 DockingWindow *pDockWin = dynamic_cast< DockingWindow* > ( mpDockingWindow );
812 if( pDockWin )
813 mnFloatBits = pDockWin->GetFloatStyle();
815 // must be enabled in Window::Notify to prevent permanent docking during mouse move
816 mbStartDockingEnabled = FALSE;
819 ImplDockingWindowWrapper::~ImplDockingWindowWrapper()
821 if ( IsFloatingMode() )
823 GetWindow()->Show( FALSE, SHOW_NOFOCUSCHANGE );
824 SetFloatingMode( FALSE );
828 // -----------------------------------------------------------------------
830 BOOL ImplDockingWindowWrapper::ImplStartDocking( const Point& rPos )
832 if ( !mbDockable )
833 return FALSE;
835 if( !mbStartDockingEnabled )
836 return FALSE;
838 maMouseOff = rPos;
839 maMouseStart = maMouseOff;
840 mbDocking = TRUE;
841 mbLastFloatMode = IsFloatingMode();
842 mbStartFloat = mbLastFloatMode;
844 // FloatingBorder berechnen
845 FloatingWindow* pWin;
846 if ( mpFloatWin )
847 pWin = mpFloatWin;
848 else
849 pWin = new ImplDockFloatWin2( mpParent, mnFloatBits, NULL );
850 pWin->GetBorder( mnDockLeft, mnDockTop, mnDockRight, mnDockBottom );
851 if ( !mpFloatWin )
852 delete pWin;
854 Point aPos = GetWindow()->ImplOutputToFrame( Point() );
855 Size aSize = GetWindow()->GetOutputSizePixel();
856 mnTrackX = aPos.X();
857 mnTrackY = aPos.Y();
858 mnTrackWidth = aSize.Width();
859 mnTrackHeight = aSize.Height();
861 if ( mbLastFloatMode )
863 maMouseOff.X() += mnDockLeft;
864 maMouseOff.Y() += mnDockTop;
865 mnTrackX -= mnDockLeft;
866 mnTrackY -= mnDockTop;
867 mnTrackWidth += mnDockLeft+mnDockRight;
868 mnTrackHeight += mnDockTop+mnDockBottom;
871 Window *pDockingArea = GetWindow()->GetParent();
872 Window::PointerState aState = pDockingArea->GetPointerState();
874 // mouse pos in screen pixels
875 Point aMousePos = pDockingArea->OutputToScreenPixel( aState.maPos );
876 Point aDockPos = Point( pDockingArea->AbsoluteScreenToOutputPixel( GetWindow()->OutputToAbsoluteScreenPixel( GetWindow()->GetPosPixel() ) ) );
877 Rectangle aDockRect( aDockPos, GetWindow()->GetSizePixel() );
878 StartDocking( aMousePos, aDockRect );
880 GetWindow()->ImplUpdateAll();
881 GetWindow()->ImplGetFrameWindow()->ImplUpdateAll();
883 GetWindow()->StartTracking( STARTTRACK_KEYMOD );
884 return TRUE;
887 // =======================================================================
889 void ImplDockingWindowWrapper::ImplInitData()
891 mpDockingWindow = NULL;
893 //GetWindow()->mpWindowImpl->mbDockWin = TRUE; // TODO: must be eliminated
894 mpFloatWin = NULL;
895 mbDockCanceled = FALSE;
896 mbFloatPrevented = FALSE;
897 mbDocking = FALSE;
898 mbPined = FALSE;
899 mbRollUp = FALSE;
900 mbDockBtn = FALSE;
901 mbHideBtn = FALSE;
902 maMaxOutSize = Size( SHRT_MAX, SHRT_MAX );
905 // -----------------------------------------------------------------------
907 void ImplDockingWindowWrapper::Tracking( const TrackingEvent& rTEvt )
909 // used during docking of a currently docked window
910 if ( mbDocking )
912 if ( rTEvt.IsTrackingEnded() )
914 mbDocking = FALSE;
915 GetWindow()->HideTracking();
916 if ( rTEvt.IsTrackingCanceled() )
918 mbDockCanceled = TRUE;
919 EndDocking( Rectangle( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) ), mbLastFloatMode );
920 mbDockCanceled = FALSE;
922 else
923 EndDocking( Rectangle( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) ), mbLastFloatMode );
925 // Docking only upon non-synthetic MouseEvents
926 else if ( !rTEvt.GetMouseEvent().IsSynthetic() || rTEvt.GetMouseEvent().IsModifierChanged() )
928 Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
929 Point aFrameMousePos = GetWindow()->ImplOutputToFrame( aMousePos );
930 Size aFrameSize = GetWindow()->ImplGetFrameWindow()->GetOutputSizePixel();
931 if ( aFrameMousePos.X() < 0 )
932 aFrameMousePos.X() = 0;
933 if ( aFrameMousePos.Y() < 0 )
934 aFrameMousePos.Y() = 0;
935 if ( aFrameMousePos.X() > aFrameSize.Width()-1 )
936 aFrameMousePos.X() = aFrameSize.Width()-1;
937 if ( aFrameMousePos.Y() > aFrameSize.Height()-1 )
938 aFrameMousePos.Y() = aFrameSize.Height()-1;
939 aMousePos = GetWindow()->ImplFrameToOutput( aFrameMousePos );
940 aMousePos.X() -= maMouseOff.X();
941 aMousePos.Y() -= maMouseOff.Y();
942 Point aPos = GetWindow()->ImplOutputToFrame( aMousePos );
943 Rectangle aTrackRect( aPos, Size( mnTrackWidth, mnTrackHeight ) );
944 Rectangle aCompRect = aTrackRect;
945 aPos.X() += maMouseOff.X();
946 aPos.Y() += maMouseOff.Y();
948 BOOL bFloatMode = Docking( aPos, aTrackRect );
950 mbFloatPrevented = FALSE;
951 if ( mbLastFloatMode != bFloatMode )
953 if ( bFloatMode )
955 aTrackRect.Left() -= mnDockLeft;
956 aTrackRect.Top() -= mnDockTop;
957 aTrackRect.Right() += mnDockRight;
958 aTrackRect.Bottom() += mnDockBottom;
960 else
962 if ( aCompRect == aTrackRect )
964 aTrackRect.Left() += mnDockLeft;
965 aTrackRect.Top() += mnDockTop;
966 aTrackRect.Right() -= mnDockRight;
967 aTrackRect.Bottom() -= mnDockBottom;
970 mbLastFloatMode = bFloatMode;
973 USHORT nTrackStyle;
974 if ( bFloatMode )
975 nTrackStyle = SHOWTRACK_OBJECT;
976 else
977 nTrackStyle = SHOWTRACK_BIG;
978 Rectangle aShowTrackRect = aTrackRect;
979 aShowTrackRect.SetPos( GetWindow()->ImplFrameToOutput( aShowTrackRect.TopLeft() ) );
980 //if( bFloatMode )
981 GetWindow()->ShowTracking( aShowTrackRect, nTrackStyle );
982 /*else
984 GetWindow()->HideTracking();
985 Point aPt( GetWindow()->GetParent()->ScreenToOutputPixel( aTrackRect.TopLeft() ) );
986 GetWindow()->SetPosPixel( aPt );
989 // Maus-Offset neu berechnen, da Rechteck veraendert werden
990 // konnte
991 maMouseOff.X() = aPos.X() - aTrackRect.Left();
992 maMouseOff.Y() = aPos.Y() - aTrackRect.Top();
994 mnTrackX = aTrackRect.Left();
995 mnTrackY = aTrackRect.Top();
996 mnTrackWidth = aTrackRect.GetWidth();
997 mnTrackHeight = aTrackRect.GetHeight();
1003 // -----------------------------------------------------------------------
1005 void ImplDockingWindowWrapper::StartDocking( const Point& rPoint, Rectangle& rRect )
1007 DockingData data( rPoint, rRect, IsFloatingMode() );
1009 GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_STARTDOCKING, &data );
1010 mbDocking = TRUE;
1013 // -----------------------------------------------------------------------
1015 BOOL ImplDockingWindowWrapper::Docking( const Point& rPoint, Rectangle& rRect )
1017 DockingData data( rPoint, rRect, IsFloatingMode() );
1019 GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_DOCKING, &data );
1020 rRect = data.maTrackRect;
1021 return data.mbFloating;
1024 // -----------------------------------------------------------------------
1026 void ImplDockingWindowWrapper::EndDocking( const Rectangle& rRect, BOOL bFloatMode )
1028 Rectangle aRect( rRect );
1030 if ( !IsDockingCanceled() )
1032 BOOL bShow = FALSE;
1033 if ( bFloatMode != IsFloatingMode() )
1035 GetWindow()->Show( FALSE, SHOW_NOFOCUSCHANGE );
1036 SetFloatingMode( bFloatMode );
1037 bShow = TRUE;
1038 if ( bFloatMode )
1040 // #i44800# always use outputsize - as in all other places
1041 mpFloatWin->SetOutputSizePixel( aRect.GetSize() );
1042 mpFloatWin->SetPosPixel( aRect.TopLeft() );
1045 if ( !bFloatMode )
1047 Point aPos = aRect.TopLeft();
1048 aPos = GetWindow()->GetParent()->ScreenToOutputPixel( aPos );
1049 GetWindow()->SetPosSizePixel( aPos, aRect.GetSize() );
1052 if ( bShow )
1053 GetWindow()->Show( TRUE, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
1056 EndDockingData data( aRect, IsFloatingMode(), IsDockingCanceled() );
1057 GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_ENDDOCKING, &data );
1059 mbDocking = FALSE;
1061 // must be enabled in Window::Notify to prevent permanent docking during mouse move
1062 mbStartDockingEnabled = FALSE;
1065 // -----------------------------------------------------------------------
1067 BOOL ImplDockingWindowWrapper::PrepareToggleFloatingMode()
1069 BOOL bFloating = TRUE;
1070 GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_PREPARETOGGLEFLOATING, &bFloating );
1071 return bFloating;
1074 // -----------------------------------------------------------------------
1076 BOOL ImplDockingWindowWrapper::Close()
1078 // TODO: send event
1080 ImplDelData aDelData;
1081 ImplAddDel( &aDelData );
1082 GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_CLOSE );
1083 if ( aDelData.IsDelete() )
1084 return FALSE;
1085 ImplRemoveDel( &aDelData );
1087 if ( mpWindowImpl->mxWindowPeer.is() && IsCreatedWithToolkit() )
1088 return FALSE;
1090 GetWindow()->Show( FALSE, SHOW_NOFOCUSCHANGE );
1092 return TRUE;
1095 // -----------------------------------------------------------------------
1097 void ImplDockingWindowWrapper::ToggleFloatingMode()
1099 // notify dockingwindow/toolbox
1100 // note: this must be done *before* notifying the
1101 // listeners to have the toolbox in the proper state
1102 if( GetWindow()->ImplIsDockingWindow() )
1103 ((DockingWindow*) GetWindow())->ToggleFloatingMode();
1105 // now notify listeners
1106 GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_TOGGLEFLOATING );
1108 // must be enabled in Window::Notify to prevent permanent docking during mouse move
1109 mbStartDockingEnabled = FALSE;
1112 // -----------------------------------------------------------------------
1114 void ImplDockingWindowWrapper::TitleButtonClick( USHORT nType )
1116 if( nType == TITLE_BUTTON_MENU )
1118 ToolBox *pToolBox = dynamic_cast< ToolBox* >( GetWindow() );
1119 if( pToolBox )
1121 pToolBox->ExecuteCustomMenu();
1124 if( nType == TITLE_BUTTON_DOCKING )
1126 SetFloatingMode( !IsFloatingMode() );
1130 // -----------------------------------------------------------------------
1132 void ImplDockingWindowWrapper::Pin()
1134 // TODO: send event
1137 // -----------------------------------------------------------------------
1139 void ImplDockingWindowWrapper::Roll()
1141 // TODO: send event
1144 // -----------------------------------------------------------------------
1146 void ImplDockingWindowWrapper::PopupModeEnd()
1148 // TODO: send event
1151 // -----------------------------------------------------------------------
1153 void ImplDockingWindowWrapper::Resizing( Size& rSize )
1155 // TODO: add virtual Resizing() to class Window, so we can get rid of class DockingWindow
1156 DockingWindow *pDockingWindow = dynamic_cast< DockingWindow* >( GetWindow() );
1157 if( pDockingWindow )
1158 pDockingWindow->Resizing( rSize );
1161 // -----------------------------------------------------------------------
1163 void ImplDockingWindowWrapper::ShowTitleButton( USHORT nButton, BOOL bVisible )
1165 if ( mpFloatWin )
1166 mpFloatWin->ShowTitleButton( nButton, bVisible );
1167 else
1169 if ( nButton == TITLE_BUTTON_DOCKING )
1170 mbDockBtn = bVisible;
1171 else // if ( nButton == TITLE_BUTTON_HIDE )
1172 mbHideBtn = bVisible;
1176 // -----------------------------------------------------------------------
1178 BOOL ImplDockingWindowWrapper::IsTitleButtonVisible( USHORT nButton ) const
1180 if ( mpFloatWin )
1181 return mpFloatWin->IsTitleButtonVisible( nButton );
1182 else
1184 if ( nButton == TITLE_BUTTON_DOCKING )
1185 return mbDockBtn;
1186 else // if ( nButton == TITLE_BUTTON_HIDE )
1187 return mbHideBtn;
1191 // -----------------------------------------------------------------------
1193 void ImplDockingWindowWrapper::StartPopupMode( ToolBox *pParentToolBox )
1195 // do nothing if window is floating
1196 if( IsFloatingMode() )
1197 return;
1199 GetWindow()->Show( FALSE, SHOW_NOFOCUSCHANGE );
1201 // prepare reparenting
1202 Window* pRealParent = GetWindow()->GetWindow( WINDOW_PARENT );
1203 mpOldBorderWin = GetWindow()->GetWindow( WINDOW_BORDER );
1204 if( mpOldBorderWin == GetWindow() )
1205 mpOldBorderWin = NULL; // no border window found
1207 // the new parent for popup mode
1208 ImplPopupFloatWin* pWin = new ImplPopupFloatWin( mpParent, this );
1210 pWin->SetPopupModeEndHdl( LINK( this, ImplDockingWindowWrapper, PopupModeEnd ) );
1211 pWin->SetText( GetWindow()->GetText() );
1213 pWin->SetOutputSizePixel( GetWindow()->GetSizePixel() );
1215 GetWindow()->mpWindowImpl->mpBorderWindow = NULL;
1216 GetWindow()->mpWindowImpl->mnLeftBorder = 0;
1217 GetWindow()->mpWindowImpl->mnTopBorder = 0;
1218 GetWindow()->mpWindowImpl->mnRightBorder = 0;
1219 GetWindow()->mpWindowImpl->mnBottomBorder = 0;
1221 // position toolbox below dragrect
1222 GetWindow()->SetPosPixel( pWin->GetToolboxPosition() );
1224 // reparent borderwindow and window
1225 if ( mpOldBorderWin )
1226 mpOldBorderWin->SetParent( pWin );
1227 GetWindow()->SetParent( pWin );
1229 // correct border window pointers
1230 GetWindow()->mpWindowImpl->mpBorderWindow = pWin;
1231 pWin->mpWindowImpl->mpClientWindow = GetWindow();
1232 GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
1234 // set mpFloatWin not until all window positioning is done !!!
1235 // (SetPosPixel etc. check for valid mpFloatWin pointer)
1236 mpFloatWin = pWin;
1238 ULONG nFlags = FLOATWIN_POPUPMODE_ALLOWTEAROFF |
1239 FLOATWIN_POPUPMODE_NOFOCUSCLOSE |
1240 FLOATWIN_POPUPMODE_ALLMOUSEBUTTONCLOSE |
1241 FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE |
1242 FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE;
1244 // if the subtoolbar was opened via keyboard make sure that key events
1245 // will go into subtoolbar
1246 if( pParentToolBox->IsKeyEvent() )
1247 nFlags |= FLOATWIN_POPUPMODE_GRABFOCUS;
1249 mpFloatWin->StartPopupMode( pParentToolBox, nFlags );
1250 GetWindow()->Show();
1252 if( pParentToolBox->IsKeyEvent() )
1254 // send HOME key to subtoolbar in order to select first item
1255 KeyEvent aEvent( 0, KeyCode( KEY_HOME ) );
1256 mpFloatWin->GetPreferredKeyInputWindow()->KeyInput( aEvent );
1260 IMPL_LINK( ImplDockingWindowWrapper, PopupModeEnd, void*, EMPTYARG )
1262 GetWindow()->Show( FALSE, SHOW_NOFOCUSCHANGE );
1264 // set parameter for handler before destroying floating window
1265 ImplPopupFloatWin *pPopupFloatWin = (ImplPopupFloatWin*) mpFloatWin;
1266 EndPopupModeData aData( pPopupFloatWin->GetTearOffPosition(), mpFloatWin->IsPopupModeTearOff() );
1268 // before deleting change parent back, so we can delete the floating window alone
1269 Window* pRealParent = GetWindow()->GetWindow( WINDOW_PARENT );
1270 GetWindow()->mpWindowImpl->mpBorderWindow = NULL;
1271 if ( mpOldBorderWin )
1273 GetWindow()->SetParent( mpOldBorderWin );
1274 ((ImplBorderWindow*)mpOldBorderWin)->GetBorder(
1275 GetWindow()->mpWindowImpl->mnLeftBorder, GetWindow()->mpWindowImpl->mnTopBorder,
1276 GetWindow()->mpWindowImpl->mnRightBorder, GetWindow()->mpWindowImpl->mnBottomBorder );
1277 mpOldBorderWin->Resize();
1279 GetWindow()->mpWindowImpl->mpBorderWindow = mpOldBorderWin;
1280 GetWindow()->SetParent( pRealParent );
1281 GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
1283 delete mpFloatWin;
1284 mpFloatWin = NULL;
1286 // call handler - which will destroy the window and thus the wrapper as well !
1287 GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_ENDPOPUPMODE, &aData );
1289 return 0;
1293 BOOL ImplDockingWindowWrapper::IsInPopupMode() const
1295 if( GetFloatingWindow() )
1296 return GetFloatingWindow()->IsInPopupMode();
1297 else
1298 return FALSE;
1301 // -----------------------------------------------------------------------
1303 void ImplDockingWindowWrapper::SetFloatingMode( BOOL bFloatMode )
1305 // do nothing if window is docked and locked
1306 if( !IsFloatingMode() && IsLocked() )
1307 return;
1309 if ( IsFloatingMode() != bFloatMode )
1311 if ( PrepareToggleFloatingMode() )
1313 BOOL bVisible = GetWindow()->IsVisible();
1315 if ( bFloatMode )
1317 GetWindow()->Show( FALSE, SHOW_NOFOCUSCHANGE );
1319 maDockPos = GetWindow()->GetPosPixel();
1321 Window* pRealParent = GetWindow()->GetWindow( WINDOW_PARENT );
1322 mpOldBorderWin = GetWindow()->GetWindow( WINDOW_BORDER );
1323 if( mpOldBorderWin == mpDockingWindow )
1324 mpOldBorderWin = NULL; // no border window found
1326 ImplDockFloatWin2* pWin =
1327 new ImplDockFloatWin2(
1328 mpParent,
1329 mnFloatBits & ( WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE ) ?
1330 mnFloatBits | WB_SYSTEMWINDOW
1331 //#ifdef __USE_OWNERDRAWDECORATION__
1332 | WB_OWNERDRAWDECORATION
1333 //#endif
1334 : mnFloatBits,
1335 this );
1337 // reduce the border width for seamless NWF painting
1338 // (especially for the toolbar gradient on Windows XP)
1339 /*AllSettings aSettings( pWin->GetSettings() );
1340 StyleSettings aStyleSettings( aSettings.GetStyleSettings() );
1341 aStyleSettings.SetBorderSize( 0 );
1342 aSettings.SetStyleSettings( aStyleSettings );
1343 pWin->SetSettings( aSettings );*/
1345 mpFloatWin = pWin;
1348 GetWindow()->mpWindowImpl->mpBorderWindow = NULL;
1349 GetWindow()->mpWindowImpl->mnLeftBorder = 0;
1350 GetWindow()->mpWindowImpl->mnTopBorder = 0;
1351 GetWindow()->mpWindowImpl->mnRightBorder = 0;
1352 GetWindow()->mpWindowImpl->mnBottomBorder = 0;
1354 // Falls Parent zerstoert wird, muessen wir auch vom
1355 // BorderWindow den Parent umsetzen
1356 if ( mpOldBorderWin )
1357 mpOldBorderWin->SetParent( pWin );
1358 GetWindow()->SetParent( pWin );
1359 pWin->SetPosPixel( Point() );
1361 GetWindow()->mpWindowImpl->mpBorderWindow = pWin;
1362 pWin->mpWindowImpl->mpClientWindow = mpDockingWindow;
1363 GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
1365 pWin->SetText( GetWindow()->GetText() );
1366 pWin->SetOutputSizePixel( GetWindow()->GetSizePixel() );
1367 pWin->SetPosPixel( maFloatPos );
1368 // DockingDaten ans FloatingWindow weiterreichen
1369 pWin->ShowTitleButton( TITLE_BUTTON_DOCKING, mbDockBtn );
1370 pWin->ShowTitleButton( TITLE_BUTTON_HIDE, mbHideBtn );
1371 pWin->SetPin( mbPined );
1372 if ( mbRollUp )
1373 pWin->RollUp();
1374 else
1375 pWin->RollDown();
1376 pWin->SetRollUpOutputSizePixel( maRollUpOutSize );
1377 pWin->SetMinOutputSizePixel( maMinOutSize );
1378 pWin->SetMaxOutputSizePixel( maMaxOutSize );
1380 if ( bVisible )
1381 GetWindow()->Show( TRUE, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
1383 ToggleFloatingMode();
1385 else
1387 GetWindow()->Show( FALSE, SHOW_NOFOCUSCHANGE );
1389 // FloatingDaten wird im FloatingWindow speichern
1390 maFloatPos = mpFloatWin->GetPosPixel();
1391 mbDockBtn = mpFloatWin->IsTitleButtonVisible( TITLE_BUTTON_DOCKING );
1392 mbHideBtn = mpFloatWin->IsTitleButtonVisible( TITLE_BUTTON_HIDE );
1393 mbPined = mpFloatWin->IsPined();
1394 mbRollUp = mpFloatWin->IsRollUp();
1395 maRollUpOutSize = mpFloatWin->GetRollUpOutputSizePixel();
1396 maMinOutSize = mpFloatWin->GetMinOutputSizePixel();
1397 maMaxOutSize = mpFloatWin->GetMaxOutputSizePixel();
1399 Window* pRealParent = GetWindow()->GetWindow( WINDOW_PARENT ); //mpWindowImpl->mpRealParent;
1400 GetWindow()->mpWindowImpl->mpBorderWindow = NULL;
1401 if ( mpOldBorderWin )
1403 GetWindow()->SetParent( mpOldBorderWin );
1404 ((ImplBorderWindow*)mpOldBorderWin)->GetBorder(
1405 GetWindow()->mpWindowImpl->mnLeftBorder, GetWindow()->mpWindowImpl->mnTopBorder,
1406 GetWindow()->mpWindowImpl->mnRightBorder, GetWindow()->mpWindowImpl->mnBottomBorder );
1407 mpOldBorderWin->Resize();
1409 GetWindow()->mpWindowImpl->mpBorderWindow = mpOldBorderWin;
1410 GetWindow()->SetParent( pRealParent );
1411 GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
1413 delete static_cast<ImplDockFloatWin2*>(mpFloatWin);
1414 mpFloatWin = NULL;
1415 GetWindow()->SetPosPixel( maDockPos );
1417 if ( bVisible )
1418 GetWindow()->Show();
1420 ToggleFloatingMode();
1427 // -----------------------------------------------------------------------
1429 void ImplDockingWindowWrapper::SetFloatStyle( WinBits nStyle )
1431 mnFloatBits = nStyle;
1434 // -----------------------------------------------------------------------
1436 WinBits ImplDockingWindowWrapper::GetFloatStyle() const
1438 return mnFloatBits;
1441 // -----------------------------------------------------------------------
1443 void ImplDockingWindowWrapper::SetTabStop()
1445 GetWindow()->SetStyle( GetWindow()->GetStyle() | (WB_GROUP | WB_TABSTOP) );
1448 // -----------------------------------------------------------------------
1450 void ImplDockingWindowWrapper::SetPosSizePixel( long nX, long nY,
1451 long nWidth, long nHeight,
1452 USHORT nFlags )
1454 if ( mpFloatWin )
1455 mpFloatWin->SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
1456 else
1457 GetWindow()->SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
1460 // -----------------------------------------------------------------------
1462 Point ImplDockingWindowWrapper::GetPosPixel() const
1464 if ( mpFloatWin )
1465 return mpFloatWin->GetPosPixel();
1466 else
1467 return mpDockingWindow->GetPosPixel();
1470 // -----------------------------------------------------------------------
1472 Size ImplDockingWindowWrapper::GetSizePixel() const
1474 if ( mpFloatWin )
1475 return mpFloatWin->GetSizePixel();
1476 else
1477 return mpDockingWindow->GetSizePixel();
1480 // -----------------------------------------------------------------------
1482 void ImplDockingWindowWrapper::SetOutputSizePixel( const Size& rNewSize )
1484 if ( mpFloatWin )
1485 mpFloatWin->SetOutputSizePixel( rNewSize );
1486 else
1487 GetWindow()->SetOutputSizePixel( rNewSize );
1490 // -----------------------------------------------------------------------
1492 Size ImplDockingWindowWrapper::GetOutputSizePixel() const
1494 if ( mpFloatWin )
1495 return mpFloatWin->GetOutputSizePixel();
1496 else
1497 return mpDockingWindow->GetOutputSizePixel();
1500 Point ImplDockingWindowWrapper::GetFloatingPos() const
1502 if ( mpFloatWin )
1504 //Rectangle aRect = mpFloatWin->GetWindow( WINDOW_CLIENT)->GetWindowExtentsRelative( mpFloatWin->GetParent() );
1505 WindowStateData aData;
1506 aData.SetMask( WINDOWSTATE_MASK_POS );
1507 mpFloatWin->GetWindowStateData( aData );
1508 Point aPos( aData.GetX(), aData.GetY() );
1509 aPos = mpFloatWin->GetParent()->ImplGetFrameWindow()->AbsoluteScreenToOutputPixel( aPos );
1510 return aPos;
1512 else
1513 return maFloatPos;
1516 // -----------------------------------------------------------------------
1517 // old inlines from DockingWindow
1518 // -----------------------------------------------------------------------
1520 void ImplDockingWindowWrapper::SetPin( BOOL bPin )
1522 if ( mpFloatWin )
1523 mpFloatWin->SetPin( bPin );
1524 mbPined = bPin;
1527 BOOL ImplDockingWindowWrapper::IsPined() const
1529 if ( mpFloatWin )
1530 return mpFloatWin->IsPined();
1531 return mbPined;
1534 void ImplDockingWindowWrapper::RollUp()
1536 if ( mpFloatWin )
1537 mpFloatWin->RollUp();
1538 mbRollUp = TRUE;
1541 void ImplDockingWindowWrapper::RollDown()
1543 if ( mpFloatWin )
1544 mpFloatWin->RollDown();
1545 mbRollUp = FALSE;
1548 BOOL ImplDockingWindowWrapper::IsRollUp() const
1550 if ( mpFloatWin )
1551 return mpFloatWin->IsRollUp();
1552 return mbRollUp;
1555 void ImplDockingWindowWrapper::SetRollUpOutputSizePixel( const Size& rSize )
1557 if ( mpFloatWin )
1558 mpFloatWin->SetRollUpOutputSizePixel( rSize );
1559 maRollUpOutSize = rSize;
1562 Size ImplDockingWindowWrapper::GetRollUpOutputSizePixel() const
1564 if ( mpFloatWin )
1565 return mpFloatWin->GetRollUpOutputSizePixel();
1566 return maRollUpOutSize;
1569 void ImplDockingWindowWrapper::SetMinOutputSizePixel( const Size& rSize )
1571 if ( mpFloatWin )
1572 mpFloatWin->SetMinOutputSizePixel( rSize );
1573 maMinOutSize = rSize;
1576 void ImplDockingWindowWrapper::SetMaxOutputSizePixel( const Size& rSize )
1578 if ( mpFloatWin )
1579 mpFloatWin->SetMaxOutputSizePixel( rSize );
1580 maMaxOutSize = rSize;
1583 const Size& ImplDockingWindowWrapper::GetMinOutputSizePixel() const
1585 if ( mpFloatWin )
1586 return mpFloatWin->GetMinOutputSizePixel();
1587 return maMinOutSize;
1590 const Size& ImplDockingWindowWrapper::GetMaxOutputSizePixel() const
1592 if ( mpFloatWin )
1593 return mpFloatWin->GetMaxOutputSizePixel();
1594 return maMaxOutSize;
1597 void ImplDockingWindowWrapper::SetFloatingPos( const Point& rNewPos )
1599 if ( mpFloatWin )
1600 mpFloatWin->SetPosPixel( rNewPos );
1601 else
1602 maFloatPos = rNewPos;
1605 BOOL ImplDockingWindowWrapper::IsFloatingMode() const
1607 return (mpFloatWin != NULL);
1611 void ImplDockingWindowWrapper::SetDragArea( const Rectangle& rRect )
1613 maDragArea = rRect;
1616 Rectangle ImplDockingWindowWrapper::GetDragArea() const
1618 return maDragArea;
1621 void ImplDockingWindowWrapper::Lock()
1623 mbLocked = TRUE;
1624 // only toolbars support locking
1625 ToolBox *pToolBox = dynamic_cast< ToolBox * >( GetWindow() );
1626 if( pToolBox )
1627 pToolBox->Lock( mbLocked );
1630 void ImplDockingWindowWrapper::Unlock()
1632 mbLocked = FALSE;
1633 // only toolbars support locking
1634 ToolBox *pToolBox = dynamic_cast< ToolBox * >( GetWindow() );
1635 if( pToolBox )
1636 pToolBox->Lock( mbLocked );
1639 BOOL ImplDockingWindowWrapper::IsLocked() const
1641 return mbLocked;