Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / vcl / source / window / dockmgr.cxx
blob2fd719393555264fb917142b407147d7d47af85f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <tools/time.hxx>
31 #include <tools/rc.h>
33 #include <brdwin.hxx>
34 #include <svdata.hxx>
35 #include <salframe.hxx>
36 #include <window.h>
38 #include <vcl/event.hxx>
39 #include <vcl/floatwin.hxx>
40 #include <vcl/dockwin.hxx>
41 #include <vcl/toolbox.hxx>
42 #include <vcl/svapp.hxx>
43 #include <vcl/timer.hxx>
44 #include <vcl/lineinfo.hxx>
45 #include <vcl/unowrap.hxx>
48 // =======================================================================
50 #define DOCKWIN_FLOATSTYLES (WB_SIZEABLE | WB_MOVEABLE | WB_CLOSEABLE | WB_STANDALONE | WB_PINABLE | WB_ROLLABLE )
52 // =======================================================================
55 // =======================================================================
57 class ImplDockFloatWin2 : public FloatingWindow
59 private:
60 ImplDockingWindowWrapper* mpDockWin;
61 sal_uLong mnLastTicks;
62 Timer maDockTimer;
63 Timer maEndDockTimer;
64 Point maDockPos;
65 Rectangle maDockRect;
66 sal_Bool mbInMove;
67 sal_uLong mnLastUserEvent;
69 DECL_LINK(DockingHdl, void *);
70 DECL_LINK(DockTimerHdl, void *);
71 DECL_LINK(EndDockTimerHdl, void *);
72 public:
73 ImplDockFloatWin2( Window* pParent, WinBits nWinBits,
74 ImplDockingWindowWrapper* pDockingWin );
75 ~ImplDockFloatWin2();
77 virtual void Move();
78 virtual void Resize();
79 virtual void TitleButtonClick( sal_uInt16 nButton );
80 virtual void Pin();
81 virtual void Roll();
82 virtual void PopupModeEnd();
83 virtual void Resizing( Size& rSize );
84 virtual sal_Bool Close();
85 using Window::SetPosSizePixel;
86 virtual void SetPosSizePixel( long nX, long nY,
87 long nWidth, long nHeight,
88 sal_uInt16 nFlags = WINDOW_POSSIZE_ALL );
90 sal_uLong GetLastTicks() const { return mnLastTicks; }
93 // =======================================================================
95 ImplDockFloatWin2::ImplDockFloatWin2( Window* pParent, WinBits nWinBits,
96 ImplDockingWindowWrapper* pDockingWin ) :
97 FloatingWindow( pParent, nWinBits ),
98 mpDockWin( pDockingWin ),
99 mnLastTicks( Time::GetSystemTicks() ),
100 mbInMove( sal_False ),
101 mnLastUserEvent( 0 )
103 // Daten vom DockingWindow uebernehmen
104 if ( pDockingWin )
106 SetSettings( pDockingWin->GetWindow()->GetSettings() );
107 Enable( pDockingWin->GetWindow()->IsEnabled(), sal_False );
108 EnableInput( pDockingWin->GetWindow()->IsInputEnabled(), sal_False );
109 AlwaysEnableInput( pDockingWin->GetWindow()->IsAlwaysEnableInput(), sal_False );
110 EnableAlwaysOnTop( pDockingWin->GetWindow()->IsAlwaysOnTopEnabled() );
111 SetActivateMode( pDockingWin->GetWindow()->GetActivateMode() );
114 SetBackground( GetSettings().GetStyleSettings().GetFaceColor() );
116 maDockTimer.SetTimeoutHdl( LINK( this, ImplDockFloatWin2, DockTimerHdl ) );
117 maDockTimer.SetTimeout( 50 );
118 maEndDockTimer.SetTimeoutHdl( LINK( this, ImplDockFloatWin2, EndDockTimerHdl ) );
119 maEndDockTimer.SetTimeout( 50 );
122 // -----------------------------------------------------------------------
124 ImplDockFloatWin2::~ImplDockFloatWin2()
126 if( mnLastUserEvent )
127 Application::RemoveUserEvent( mnLastUserEvent );
130 // -----------------------------------------------------------------------
132 IMPL_LINK_NOARG(ImplDockFloatWin2, DockTimerHdl)
134 DBG_ASSERT( mpDockWin->IsFloatingMode(), "docktimer called but not floating" );
136 maDockTimer.Stop();
137 PointerState aState = GetPointerState();
139 if( aState.mnState & KEY_MOD1 )
141 // i43499 CTRL disables docking now
142 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
143 if( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) )
144 maDockTimer.Start();
146 else if( ! ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) )
148 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
149 mpDockWin->EndDocking( maDockRect, sal_False );
151 else
153 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect, SHOWTRACK_BIG | SHOWTRACK_WINDOW );
154 maDockTimer.Start();
157 return 0;
160 IMPL_LINK_NOARG(ImplDockFloatWin2, EndDockTimerHdl)
162 DBG_ASSERT( mpDockWin->IsFloatingMode(), "enddocktimer called but not floating" );
164 maEndDockTimer.Stop();
165 PointerState aState = GetPointerState();
166 if( ! ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) )
168 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
169 mpDockWin->EndDocking( maDockRect, sal_True );
171 else
173 maEndDockTimer.Start();
176 return 0;
180 IMPL_LINK_NOARG(ImplDockFloatWin2, DockingHdl)
182 // called during move of a floating window
183 mnLastUserEvent = 0;
185 Window *pDockingArea = mpDockWin->GetWindow()->GetParent();
186 PointerState aState = pDockingArea->GetPointerState();
188 sal_Bool bRealMove = sal_True;
189 if( GetStyle() & WB_OWNERDRAWDECORATION )
191 // for windows with ownerdraw decoration
192 // we allow docking only when the window was moved
193 // by dragging its caption
194 // and ignore move request due to resizing
195 Window *pBorder = GetWindow( WINDOW_BORDER );
196 if( pBorder != this )
198 Point aPt;
199 Rectangle aBorderRect( aPt, pBorder->GetSizePixel() );
200 sal_Int32 nLeft, nTop, nRight, nBottom;
201 GetBorder( nLeft, nTop, nRight, nBottom );
202 // limit borderrect to the caption part only and without the resizing borders
203 aBorderRect.nBottom = aBorderRect.nTop + nTop;
204 aBorderRect.nLeft += nLeft;
205 aBorderRect.nRight -= nRight;
207 PointerState aBorderState = pBorder->GetPointerState();
208 if( aBorderRect.IsInside( aBorderState.maPos ) )
209 bRealMove = sal_True;
210 else
211 bRealMove = sal_False;
215 if( mpDockWin->IsDockable() &&
216 mpDockWin->GetWindow()->IsVisible() &&
217 (Time::GetSystemTicks() - mnLastTicks > 500) &&
218 ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) &&
219 !(aState.mnState & KEY_MOD1) && // i43499 CTRL disables docking now
220 bRealMove )
222 maDockPos = Point( pDockingArea->OutputToScreenPixel( pDockingArea->AbsoluteScreenToOutputPixel( OutputToAbsoluteScreenPixel( Point() ) ) ) );
223 maDockRect = Rectangle( maDockPos, mpDockWin->GetSizePixel() );
225 // mouse pos in screen pixels
226 Point aMousePos = pDockingArea->OutputToScreenPixel( aState.maPos );
228 if( ! mpDockWin->IsDocking() )
229 mpDockWin->StartDocking( aMousePos, maDockRect );
231 sal_Bool bFloatMode = mpDockWin->Docking( aMousePos, maDockRect );
233 if( ! bFloatMode )
235 // indicates that the window could be docked at maDockRect
236 maDockRect.SetPos( mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->ScreenToOutputPixel(
237 maDockRect.TopLeft() ) );
238 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect, SHOWTRACK_BIG | SHOWTRACK_WINDOW );
239 maEndDockTimer.Stop();
240 DockTimerHdl( this );
242 else
244 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
245 maDockTimer.Stop();
246 EndDockTimerHdl( this );
249 mbInMove = sal_False;
250 return 0;
252 // -----------------------------------------------------------------------
254 void ImplDockFloatWin2::Move()
256 if( mbInMove )
257 return;
259 mbInMove = sal_True;
260 FloatingWindow::Move();
261 mpDockWin->GetWindow()->Move();
264 * note: the window should only dock if KEY_MOD1 is pressed
265 * and the user releases all mouse buttons. The real problem here
266 * is that we don't get mouse events (at least not on X)
267 * if the mouse is on the decoration. So we have to start an
268 * awkward timer based process that polls the modifier/buttons
269 * to see whether they are in the right condition shortly after the
270 * last Move message.
272 if( ! mnLastUserEvent )
273 mnLastUserEvent = Application::PostUserEvent( LINK( this, ImplDockFloatWin2, DockingHdl ) );
276 // -----------------------------------------------------------------------
278 void ImplDockFloatWin2::Resize()
280 // forwarding of resize only required if we have no borderwindow ( GetWindow() then returns 'this' )
281 if( GetWindow( WINDOW_BORDER ) == this )
283 FloatingWindow::Resize();
284 Size aSize( GetSizePixel() );
285 mpDockWin->GetWindow()->ImplPosSizeWindow( 0, 0, aSize.Width(), aSize.Height(), WINDOW_POSSIZE_POSSIZE ); // is this needed ???
289 void ImplDockFloatWin2::SetPosSizePixel( long nX, long nY,
290 long nWidth, long nHeight,
291 sal_uInt16 nFlags )
293 FloatingWindow::SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
296 // -----------------------------------------------------------------------
299 void ImplDockFloatWin2::TitleButtonClick( sal_uInt16 nButton )
301 FloatingWindow::TitleButtonClick( nButton );
302 mpDockWin->TitleButtonClick( nButton );
305 // -----------------------------------------------------------------------
307 void ImplDockFloatWin2::Pin()
309 FloatingWindow::Pin();
310 mpDockWin->Pin();
313 // -----------------------------------------------------------------------
315 void ImplDockFloatWin2::Roll()
317 FloatingWindow::Roll();
318 mpDockWin->Roll();
321 // -----------------------------------------------------------------------
323 void ImplDockFloatWin2::PopupModeEnd()
325 FloatingWindow::PopupModeEnd();
326 mpDockWin->PopupModeEnd();
329 // -----------------------------------------------------------------------
331 void ImplDockFloatWin2::Resizing( Size& rSize )
333 FloatingWindow::Resizing( rSize );
334 mpDockWin->Resizing( rSize );
337 // -----------------------------------------------------------------------
339 sal_Bool ImplDockFloatWin2::Close()
341 return mpDockWin->Close();
344 // =======================================================================
346 DockingManager::DockingManager()
350 DockingManager::~DockingManager()
352 ::std::vector< ImplDockingWindowWrapper* >::iterator p;
353 p = mDockingWindows.begin();
354 for(; p != mDockingWindows.end(); ++p )
356 delete (*p);
358 mDockingWindows.clear();
361 ImplDockingWindowWrapper* DockingManager::GetDockingWindowWrapper( const Window *pWindow )
363 ::std::vector< ImplDockingWindowWrapper* >::iterator p;
364 p = mDockingWindows.begin();
365 while( p != mDockingWindows.end() )
367 if( (*p)->mpDockingWindow == pWindow )
368 return (*p);
369 else
370 ++p;
372 return NULL;
375 sal_Bool DockingManager::IsDockable( const Window *pWindow )
377 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
380 if( pWindow->HasDockingHandler() )
381 return sal_True;
383 return (pWrapper != NULL);
386 sal_Bool DockingManager::IsFloating( const Window *pWindow )
388 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
389 if( pWrapper )
390 return pWrapper->IsFloatingMode();
391 else
392 return sal_False;
395 sal_Bool DockingManager::IsLocked( const Window *pWindow )
397 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
398 if( pWrapper && pWrapper->IsLocked() )
399 return sal_True;
400 else
401 return sal_False;
404 void DockingManager::Lock( const Window *pWindow )
406 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
407 if( pWrapper )
408 pWrapper->Lock();
411 void DockingManager::Unlock( const Window *pWindow )
413 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
414 if( pWrapper )
415 pWrapper->Unlock();
418 void DockingManager::SetFloatingMode( const Window *pWindow, sal_Bool bFloating )
420 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
421 if( pWrapper )
422 pWrapper->SetFloatingMode( bFloating );
425 void DockingManager::StartPopupMode( ToolBox *pParentToolBox, const Window *pWindow, sal_uLong nFlags )
427 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
428 if( pWrapper )
429 pWrapper->StartPopupMode( pParentToolBox, nFlags );
432 void DockingManager::StartPopupMode( ToolBox *pParentToolBox, const Window *pWindow )
434 StartPopupMode( pParentToolBox, pWindow, FLOATWIN_POPUPMODE_ALLOWTEAROFF |
435 FLOATWIN_POPUPMODE_NOFOCUSCLOSE |
436 FLOATWIN_POPUPMODE_ALLMOUSEBUTTONCLOSE |
437 FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE );
440 sal_Bool DockingManager::IsInPopupMode( const Window *pWindow )
442 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
443 if( pWrapper && pWrapper->IsInPopupMode() )
444 return sal_True;
445 else
446 return sal_False;
449 // -----------------------------------------------------------------------
451 void DockingManager::EndPopupMode( const Window *pWin )
453 ImplDockingWindowWrapper *pWrapper = GetDockingWindowWrapper( pWin );
454 if( pWrapper && pWrapper->GetFloatingWindow() && pWrapper->GetFloatingWindow()->IsInPopupMode() )
455 pWrapper->GetFloatingWindow()->EndPopupMode();
458 // -----------------------------------------------------------------------
460 void DockingManager::AddWindow( const Window *pWindow )
462 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
463 if( pWrapper )
464 return;
465 else
466 pWrapper = new ImplDockingWindowWrapper( pWindow );
468 mDockingWindows.push_back( pWrapper );
471 void DockingManager::RemoveWindow( const Window *pWindow )
473 ::std::vector< ImplDockingWindowWrapper* >::iterator p;
474 p = mDockingWindows.begin();
475 while( p != mDockingWindows.end() )
477 if( (*p)->mpDockingWindow == pWindow )
479 delete (*p);
480 mDockingWindows.erase( p );
481 break;
483 else
484 ++p;
488 void DockingManager::SetPosSizePixel( Window *pWindow, long nX, long nY,
489 long nWidth, long nHeight,
490 sal_uInt16 nFlags )
492 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
493 if( pWrapper )
494 pWrapper->SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
497 Rectangle DockingManager::GetPosSizePixel( const Window *pWindow )
499 Rectangle aRect;
500 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
501 if( pWrapper )
502 aRect = Rectangle( pWrapper->GetPosPixel(), pWrapper->GetSizePixel() );
504 return aRect;
507 // =======================================================================
508 // special floating window for popup mode
509 // main purpose: provides tear-off area for undocking
510 // =======================================================================
512 // if TEAROFF_DASHED defined a single dashed line is used
513 // otherwise multiple smaller lines will be painted
514 //#define TEAROFF_DASHED
516 // size of the drag area
517 #ifdef TEAROFF_DASHED
518 #define POPUP_DRAGBORDER 2
519 #define POPUP_DRAGGRIP 5
520 #else
521 #define POPUP_DRAGBORDER 3
522 #define POPUP_DRAGGRIP 5
523 #endif
524 #define POPUP_DRAGHEIGHT (POPUP_DRAGGRIP+POPUP_DRAGBORDER+POPUP_DRAGBORDER)
525 #define POPUP_DRAGWIDTH 20
527 class ImplPopupFloatWin : public FloatingWindow
529 private:
530 ImplDockingWindowWrapper* mpDockingWin;
531 sal_Bool mbHighlight;
532 sal_Bool mbMoving;
533 bool mbTrackingEnabled;
534 Point maDelta;
535 Point maTearOffPosition;
536 bool mbGripAtBottom;
537 bool mbHasGrip;
538 void ImplSetBorder();
540 public:
541 ImplPopupFloatWin( Window* pParent, ImplDockingWindowWrapper* pDockingWin, bool bHasGrip );
542 ~ImplPopupFloatWin();
544 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
545 virtual void Paint( const Rectangle& rRect );
546 virtual void MouseMove( const MouseEvent& rMEvt );
547 virtual void MouseButtonDown( const MouseEvent& rMEvt );
548 virtual void MouseButtonUp( const MouseEvent& rMEvt );
549 virtual void Tracking( const TrackingEvent& rTEvt );
550 virtual void Resize();
551 virtual Window* GetPreferredKeyInputWindow();
553 Rectangle GetDragRect() const;
554 Point GetToolboxPosition() const;
555 Point GetTearOffPosition() const;
556 void DrawGrip();
557 void DrawBorder();
559 bool hasGrip() const { return mbHasGrip; }
562 ImplPopupFloatWin::ImplPopupFloatWin( Window* pParent, ImplDockingWindowWrapper* pDockingWin, bool bHasGrip ) :
563 FloatingWindow( pParent, WB_NOBORDER | WB_SYSTEMWINDOW | WB_NOSHADOW)
565 mpWindowImpl->mbToolbarFloatingWindow = sal_True; // indicate window type, required for accessibility
566 // which should not see this window as a toplevel window
567 mpDockingWin = pDockingWin;
568 mbHighlight = sal_False;
569 mbMoving = sal_False;
570 mbTrackingEnabled = sal_False;
571 mbGripAtBottom = sal_True;
572 mbHasGrip = bHasGrip;
574 ImplSetBorder();
577 ImplPopupFloatWin::~ImplPopupFloatWin()
579 mpDockingWin = NULL;
582 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > ImplPopupFloatWin::CreateAccessible()
584 // switch off direct accessibilty support for this window
586 // this is to avoid appearance of this window as standalone window in the accessibility hierarchy
587 // as this window is only used as a helper for subtoolbars that are not teared-off, the parent toolbar
588 // has to provide accessibility support (as implemented in the toolkit)
589 // so the contained toolbar should appear as child of the correponsing toolbar item of the parent toolbar
590 return ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >();
593 Window* ImplPopupFloatWin::GetPreferredKeyInputWindow()
595 if( mpWindowImpl->mpClientWindow )
596 return mpWindowImpl->mpClientWindow;
597 else
598 return FloatingWindow::GetPreferredKeyInputWindow();
602 void ImplPopupFloatWin::ImplSetBorder()
604 // although we have no border in the sense of a borderwindow
605 // we're using a special border for the grip
606 // by setting those members the method SetOutputSizePixel() can
607 // be used to set the proper window size
608 mpWindowImpl->mnTopBorder = 1;
609 if( hasGrip() )
610 mpWindowImpl->mnTopBorder += POPUP_DRAGHEIGHT+2;
611 mpWindowImpl->mnBottomBorder = 1;
612 mpWindowImpl->mnLeftBorder = 1;
613 mpWindowImpl->mnRightBorder = 1;
616 void ImplPopupFloatWin::Resize()
618 // the borderview overwrites the border during resize so restore it
619 ImplSetBorder();
622 Rectangle ImplPopupFloatWin::GetDragRect() const
624 Rectangle aRect;
625 if( hasGrip() )
627 aRect = Rectangle( 1,1, GetOutputSizePixel().Width()-1, 2+POPUP_DRAGHEIGHT );
628 if( mbGripAtBottom )
630 int height = GetOutputSizePixel().Height();
631 aRect.Top() = height - 3 - POPUP_DRAGHEIGHT;
632 aRect.Bottom() = aRect.Top() + 1 + POPUP_DRAGHEIGHT;
635 return aRect;
638 Point ImplPopupFloatWin::GetToolboxPosition() const
640 // return inner position where a toolbox could be placed
641 Point aPt( 1, 1 + ((mbGripAtBottom || !hasGrip()) ? 0 : GetDragRect().getHeight()) ); // grip + border
643 return aPt;
646 Point ImplPopupFloatWin::GetTearOffPosition() const
648 Point aPt( maTearOffPosition );
649 //aPt += GetToolboxPosition(); // remove 'decoration'
650 return aPt;
653 void ImplPopupFloatWin::DrawBorder()
655 SetFillColor();
656 Point aPt;
657 Rectangle aRect( aPt, GetOutputSizePixel() );
659 Region oldClipRgn( GetClipRegion( ) );
660 Region aClipRgn( aRect );
661 Rectangle aItemClipRect( ImplGetItemEdgeClipRect() );
662 if( !aItemClipRect.IsEmpty() )
664 aItemClipRect.SetPos( AbsoluteScreenToOutputPixel( aItemClipRect.TopLeft() ) );
666 // draw the excluded border part with the background color of a toolbox
667 SetClipRegion( Region( aItemClipRect ) );
668 SetLineColor( GetSettings().GetStyleSettings().GetFaceColor() );
669 DrawRect( aRect );
671 aClipRgn.Exclude( aItemClipRect );
672 SetClipRegion( aClipRgn );
674 SetLineColor( GetSettings().GetStyleSettings().GetShadowColor() );
675 DrawRect( aRect );
676 SetClipRegion( oldClipRgn );
679 void ImplPopupFloatWin::DrawGrip()
681 sal_Bool bLinecolor = IsLineColor();
682 Color aLinecolor = GetLineColor();
683 sal_Bool bFillcolor = IsFillColor();
684 Color aFillcolor = GetFillColor();
686 // draw background
687 Rectangle aRect( GetDragRect() );
688 aRect.nTop += POPUP_DRAGBORDER;
689 aRect.nBottom -= POPUP_DRAGBORDER;
690 aRect.nLeft+=3;
691 aRect.nRight-=3;
693 if( mbHighlight )
695 Erase( aRect );
696 DrawSelectionBackground( aRect, 2, sal_False, sal_True, sal_False );
698 else
700 SetFillColor( GetSettings().GetStyleSettings().GetFaceColor() );
701 SetLineColor();
702 DrawRect( aRect );
705 if( !ToolBox::AlwaysLocked() ) // no grip if toolboxes are locked
707 #ifdef TEAROFF_DASHED
708 // draw single dashed line
709 LineInfo aLineInfo( LINE_DASH );
710 aLineInfo.SetDistance( 4 );
711 aLineInfo.SetDashLen( 12 );
712 aLineInfo.SetDashCount( 1 );
714 aRect.nLeft+=2; aRect.nRight-=2;
716 aRect.nTop+=2;
717 aRect.nBottom = aRect.nTop;
718 SetLineColor( GetSettings().GetStyleSettings().GetDarkShadowColor() );
719 DrawLine( aRect.TopLeft(), aRect.TopRight(), aLineInfo );
721 if( !mbHighlight )
723 aRect.nTop++; aRect.nBottom++;
724 SetLineColor( GetSettings().GetStyleSettings().GetLightColor() );
725 DrawLine( aRect.TopLeft(), aRect.TopRight(), aLineInfo );
728 #else
729 // draw several grip lines
730 SetFillColor( GetSettings().GetStyleSettings().GetShadowColor() );
731 aRect.nTop++;
732 aRect.nBottom = aRect.nTop;
734 int width = POPUP_DRAGWIDTH;
735 while( width >= aRect.getWidth() )
736 width -= 4;
737 if( width <= 0 )
738 width = aRect.getWidth();
739 //aRect.nLeft = aRect.nLeft + (aRect.getWidth() - width) / 2;
740 aRect.nLeft = (aRect.nLeft + aRect.nRight - width) / 2;
741 aRect.nRight = aRect.nLeft + width;
743 int i=0;
744 while( i< POPUP_DRAGGRIP )
746 DrawRect( aRect );
747 aRect.nTop+=2;
748 aRect.nBottom+=2;
749 i+=2;
751 #endif
754 if( bLinecolor )
755 SetLineColor( aLinecolor );
756 else
757 SetLineColor();
758 if( bFillcolor )
759 SetFillColor( aFillcolor );
760 else
761 SetFillColor();
764 void ImplPopupFloatWin::Paint( const Rectangle& )
766 Point aPt;
767 Rectangle aRect( aPt, GetOutputSizePixel() );
768 DrawWallpaper( aRect, Wallpaper( GetSettings().GetStyleSettings().GetFaceGradientColor() ) );
769 DrawBorder();
770 if( hasGrip() )
771 DrawGrip();
774 void ImplPopupFloatWin::MouseMove( const MouseEvent& rMEvt )
776 Point aMousePos = rMEvt.GetPosPixel();
778 if( !ToolBox::AlwaysLocked() ) // no tear off if locking is enabled
780 if( mbTrackingEnabled && rMEvt.IsLeft() && GetDragRect().IsInside( aMousePos ) )
782 // start window move
783 mbMoving = sal_True;
784 StartTracking( STARTTRACK_NOKEYCANCEL );
785 return;
787 if( !mbHighlight && GetDragRect().IsInside( aMousePos ) )
789 mbHighlight = sal_True;
790 DrawGrip();
792 if( mbHighlight && ( rMEvt.IsLeaveWindow() || !GetDragRect().IsInside( aMousePos ) ) )
794 mbHighlight = sal_False;
795 DrawGrip();
800 void ImplPopupFloatWin::MouseButtonUp( const MouseEvent& rMEvt )
802 mbTrackingEnabled = false;
803 FloatingWindow::MouseButtonUp( rMEvt );
806 void ImplPopupFloatWin::MouseButtonDown( const MouseEvent& rMEvt )
808 Point aMousePos = rMEvt.GetPosPixel();
809 if( GetDragRect().IsInside( aMousePos ) )
811 // get mouse pos at a static window to have a fixed reference point
812 PointerState aState = GetParent()->GetPointerState();
813 if (ImplHasMirroredGraphics() && IsRTLEnabled())
814 ImplMirrorFramePos(aState.maPos);
815 maTearOffPosition = GetWindow( WINDOW_BORDER )->GetPosPixel();
816 maDelta = aState.maPos - maTearOffPosition;
817 mbTrackingEnabled = true;
819 else
821 mbTrackingEnabled = false;
825 void ImplPopupFloatWin::Tracking( const TrackingEvent& rTEvt )
827 if( mbMoving )
829 if ( rTEvt.IsTrackingEnded() )
831 mbMoving = sal_False;
832 EndPopupMode( FLOATWIN_POPUPMODEEND_TEAROFF );
834 else if ( !rTEvt.GetMouseEvent().IsSynthetic() )
836 // move the window according to mouse pos
837 PointerState aState = GetParent()->GetPointerState();
838 if (ImplHasMirroredGraphics() && IsRTLEnabled())
839 ImplMirrorFramePos(aState.maPos);
840 maTearOffPosition = aState.maPos - maDelta;
841 GetWindow( WINDOW_BORDER )->SetPosPixel( maTearOffPosition );
847 // =======================================================================
849 ImplDockingWindowWrapper::ImplDockingWindowWrapper( const Window *pWindow )
851 ImplInitData();
853 mpDockingWindow = (Window*) pWindow;
854 mpParent = pWindow->GetParent();
855 mbDockable = sal_True;
856 mbLocked = sal_False;
857 mnFloatBits = WB_BORDER | WB_CLOSEABLE | WB_SIZEABLE | (pWindow->GetStyle() & DOCKWIN_FLOATSTYLES);
858 DockingWindow *pDockWin = dynamic_cast< DockingWindow* > ( mpDockingWindow );
859 if( pDockWin )
860 mnFloatBits = pDockWin->GetFloatStyle();
862 // must be enabled in Window::Notify to prevent permanent docking during mouse move
863 mbStartDockingEnabled = sal_False;
866 ImplDockingWindowWrapper::~ImplDockingWindowWrapper()
868 if ( IsFloatingMode() )
870 GetWindow()->Show( sal_False, SHOW_NOFOCUSCHANGE );
871 SetFloatingMode( sal_False );
875 // -----------------------------------------------------------------------
877 sal_Bool ImplDockingWindowWrapper::ImplStartDocking( const Point& rPos )
879 if ( !mbDockable )
880 return sal_False;
882 if( !mbStartDockingEnabled )
883 return sal_False;
885 maMouseOff = rPos;
886 maMouseStart = maMouseOff;
887 mbDocking = sal_True;
888 mbLastFloatMode = IsFloatingMode();
889 mbStartFloat = mbLastFloatMode;
891 // FloatingBorder berechnen
892 FloatingWindow* pWin;
893 if ( mpFloatWin )
894 pWin = mpFloatWin;
895 else
896 pWin = new ImplDockFloatWin2( mpParent, mnFloatBits, NULL );
897 pWin->GetBorder( mnDockLeft, mnDockTop, mnDockRight, mnDockBottom );
898 if ( !mpFloatWin )
899 delete pWin;
901 Point aPos = GetWindow()->ImplOutputToFrame( Point() );
902 Size aSize = GetWindow()->GetOutputSizePixel();
903 mnTrackX = aPos.X();
904 mnTrackY = aPos.Y();
905 mnTrackWidth = aSize.Width();
906 mnTrackHeight = aSize.Height();
908 if ( mbLastFloatMode )
910 maMouseOff.X() += mnDockLeft;
911 maMouseOff.Y() += mnDockTop;
912 mnTrackX -= mnDockLeft;
913 mnTrackY -= mnDockTop;
914 mnTrackWidth += mnDockLeft+mnDockRight;
915 mnTrackHeight += mnDockTop+mnDockBottom;
918 Window *pDockingArea = GetWindow()->GetParent();
919 Window::PointerState aState = pDockingArea->GetPointerState();
921 // mouse pos in screen pixels
922 Point aMousePos = pDockingArea->OutputToScreenPixel( aState.maPos );
923 Point aDockPos = Point( pDockingArea->AbsoluteScreenToOutputPixel( GetWindow()->OutputToAbsoluteScreenPixel( GetWindow()->GetPosPixel() ) ) );
924 Rectangle aDockRect( aDockPos, GetWindow()->GetSizePixel() );
925 StartDocking( aMousePos, aDockRect );
927 GetWindow()->ImplUpdateAll();
928 GetWindow()->ImplGetFrameWindow()->ImplUpdateAll();
930 GetWindow()->StartTracking( STARTTRACK_KEYMOD );
931 return sal_True;
934 // =======================================================================
936 void ImplDockingWindowWrapper::ImplInitData()
938 mpDockingWindow = NULL;
940 //GetWindow()->mpWindowImpl->mbDockWin = sal_True; // TODO: must be eliminated
941 mpFloatWin = NULL;
942 mbDockCanceled = sal_False;
943 mbFloatPrevented = sal_False;
944 mbDocking = sal_False;
945 mbPined = sal_False;
946 mbRollUp = sal_False;
947 mbDockBtn = sal_False;
948 mbHideBtn = sal_False;
949 maMaxOutSize = Size( SHRT_MAX, SHRT_MAX );
952 // -----------------------------------------------------------------------
954 void ImplDockingWindowWrapper::Tracking( const TrackingEvent& rTEvt )
956 // used during docking of a currently docked window
957 if ( mbDocking )
959 if ( rTEvt.IsTrackingEnded() )
961 mbDocking = sal_False;
962 GetWindow()->HideTracking();
963 if ( rTEvt.IsTrackingCanceled() )
965 mbDockCanceled = sal_True;
966 EndDocking( Rectangle( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) ), mbLastFloatMode );
967 mbDockCanceled = sal_False;
969 else
970 EndDocking( Rectangle( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) ), mbLastFloatMode );
972 // Docking only upon non-synthetic MouseEvents
973 else if ( !rTEvt.GetMouseEvent().IsSynthetic() || rTEvt.GetMouseEvent().IsModifierChanged() )
975 Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
976 Point aFrameMousePos = GetWindow()->ImplOutputToFrame( aMousePos );
977 Size aFrameSize = GetWindow()->ImplGetFrameWindow()->GetOutputSizePixel();
978 if ( aFrameMousePos.X() < 0 )
979 aFrameMousePos.X() = 0;
980 if ( aFrameMousePos.Y() < 0 )
981 aFrameMousePos.Y() = 0;
982 if ( aFrameMousePos.X() > aFrameSize.Width()-1 )
983 aFrameMousePos.X() = aFrameSize.Width()-1;
984 if ( aFrameMousePos.Y() > aFrameSize.Height()-1 )
985 aFrameMousePos.Y() = aFrameSize.Height()-1;
986 aMousePos = GetWindow()->ImplFrameToOutput( aFrameMousePos );
987 aMousePos.X() -= maMouseOff.X();
988 aMousePos.Y() -= maMouseOff.Y();
989 Point aPos = GetWindow()->ImplOutputToFrame( aMousePos );
990 Rectangle aTrackRect( aPos, Size( mnTrackWidth, mnTrackHeight ) );
991 Rectangle aCompRect = aTrackRect;
992 aPos.X() += maMouseOff.X();
993 aPos.Y() += maMouseOff.Y();
995 sal_Bool bFloatMode = Docking( aPos, aTrackRect );
997 mbFloatPrevented = sal_False;
998 if ( mbLastFloatMode != bFloatMode )
1000 if ( bFloatMode )
1002 aTrackRect.Left() -= mnDockLeft;
1003 aTrackRect.Top() -= mnDockTop;
1004 aTrackRect.Right() += mnDockRight;
1005 aTrackRect.Bottom() += mnDockBottom;
1007 else
1009 if ( aCompRect == aTrackRect )
1011 aTrackRect.Left() += mnDockLeft;
1012 aTrackRect.Top() += mnDockTop;
1013 aTrackRect.Right() -= mnDockRight;
1014 aTrackRect.Bottom() -= mnDockBottom;
1017 mbLastFloatMode = bFloatMode;
1020 sal_uInt16 nTrackStyle;
1021 if ( bFloatMode )
1022 nTrackStyle = SHOWTRACK_OBJECT;
1023 else
1024 nTrackStyle = SHOWTRACK_BIG;
1025 Rectangle aShowTrackRect = aTrackRect;
1026 aShowTrackRect.SetPos( GetWindow()->ImplFrameToOutput( aShowTrackRect.TopLeft() ) );
1028 GetWindow()->ShowTracking( aShowTrackRect, nTrackStyle );
1030 // Maus-Offset neu berechnen, da Rechteck veraendert werden
1031 // konnte
1032 maMouseOff.X() = aPos.X() - aTrackRect.Left();
1033 maMouseOff.Y() = aPos.Y() - aTrackRect.Top();
1035 mnTrackX = aTrackRect.Left();
1036 mnTrackY = aTrackRect.Top();
1037 mnTrackWidth = aTrackRect.GetWidth();
1038 mnTrackHeight = aTrackRect.GetHeight();
1044 // -----------------------------------------------------------------------
1046 void ImplDockingWindowWrapper::StartDocking( const Point& rPoint, Rectangle& rRect )
1048 DockingData data( rPoint, rRect, IsFloatingMode() );
1050 GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_STARTDOCKING, &data );
1051 mbDocking = sal_True;
1054 // -----------------------------------------------------------------------
1056 sal_Bool ImplDockingWindowWrapper::Docking( const Point& rPoint, Rectangle& rRect )
1058 DockingData data( rPoint, rRect, IsFloatingMode() );
1060 GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_DOCKING, &data );
1061 rRect = data.maTrackRect;
1062 return data.mbFloating;
1065 // -----------------------------------------------------------------------
1067 void ImplDockingWindowWrapper::EndDocking( const Rectangle& rRect, sal_Bool bFloatMode )
1069 Rectangle aRect( rRect );
1071 if ( !IsDockingCanceled() )
1073 sal_Bool bShow = sal_False;
1074 if ( bFloatMode != IsFloatingMode() )
1076 GetWindow()->Show( sal_False, SHOW_NOFOCUSCHANGE );
1077 SetFloatingMode( bFloatMode );
1078 bShow = sal_True;
1079 if ( bFloatMode )
1081 // #i44800# always use outputsize - as in all other places
1082 mpFloatWin->SetOutputSizePixel( aRect.GetSize() );
1083 mpFloatWin->SetPosPixel( aRect.TopLeft() );
1086 if ( !bFloatMode )
1088 Point aPos = aRect.TopLeft();
1089 aPos = GetWindow()->GetParent()->ScreenToOutputPixel( aPos );
1090 GetWindow()->SetPosSizePixel( aPos, aRect.GetSize() );
1093 if ( bShow )
1094 GetWindow()->Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
1097 EndDockingData data( aRect, IsFloatingMode(), IsDockingCanceled() );
1098 GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_ENDDOCKING, &data );
1100 mbDocking = sal_False;
1102 // must be enabled in Window::Notify to prevent permanent docking during mouse move
1103 mbStartDockingEnabled = sal_False;
1106 // -----------------------------------------------------------------------
1108 sal_Bool ImplDockingWindowWrapper::PrepareToggleFloatingMode()
1110 sal_Bool bFloating = sal_True;
1111 GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_PREPARETOGGLEFLOATING, &bFloating );
1112 return bFloating;
1115 // -----------------------------------------------------------------------
1117 sal_Bool ImplDockingWindowWrapper::Close()
1119 // TODO: send event
1120 return sal_True;
1123 // -----------------------------------------------------------------------
1125 void ImplDockingWindowWrapper::ToggleFloatingMode()
1127 // notify dockingwindow/toolbox
1128 // note: this must be done *before* notifying the
1129 // listeners to have the toolbox in the proper state
1130 if( GetWindow()->ImplIsDockingWindow() )
1131 ((DockingWindow*) GetWindow())->ToggleFloatingMode();
1133 // now notify listeners
1134 GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_TOGGLEFLOATING );
1136 // must be enabled in Window::Notify to prevent permanent docking during mouse move
1137 mbStartDockingEnabled = sal_False;
1140 // -----------------------------------------------------------------------
1142 void ImplDockingWindowWrapper::TitleButtonClick( sal_uInt16 nType )
1144 if( nType == TITLE_BUTTON_MENU )
1146 ToolBox *pToolBox = dynamic_cast< ToolBox* >( GetWindow() );
1147 if( pToolBox )
1149 pToolBox->ExecuteCustomMenu();
1152 if( nType == TITLE_BUTTON_DOCKING )
1154 SetFloatingMode( !IsFloatingMode() );
1158 // -----------------------------------------------------------------------
1160 void ImplDockingWindowWrapper::Pin()
1162 // TODO: send event
1165 // -----------------------------------------------------------------------
1167 void ImplDockingWindowWrapper::Roll()
1169 // TODO: send event
1172 // -----------------------------------------------------------------------
1174 void ImplDockingWindowWrapper::PopupModeEnd()
1176 // TODO: send event
1179 // -----------------------------------------------------------------------
1181 void ImplDockingWindowWrapper::Resizing( Size& rSize )
1183 // TODO: add virtual Resizing() to class Window, so we can get rid of class DockingWindow
1184 DockingWindow *pDockingWindow = dynamic_cast< DockingWindow* >( GetWindow() );
1185 if( pDockingWindow )
1186 pDockingWindow->Resizing( rSize );
1189 // -----------------------------------------------------------------------
1191 void ImplDockingWindowWrapper::ShowTitleButton( sal_uInt16 nButton, sal_Bool bVisible )
1193 if ( mpFloatWin )
1194 mpFloatWin->ShowTitleButton( nButton, bVisible );
1195 else
1197 if ( nButton == TITLE_BUTTON_DOCKING )
1198 mbDockBtn = bVisible;
1199 else // if ( nButton == TITLE_BUTTON_HIDE )
1200 mbHideBtn = bVisible;
1204 // -----------------------------------------------------------------------
1206 void ImplDockingWindowWrapper::StartPopupMode( ToolBox *pParentToolBox, sal_uLong nFlags )
1208 // do nothing if window is floating
1209 if( IsFloatingMode() )
1210 return;
1212 GetWindow()->Show( sal_False, SHOW_NOFOCUSCHANGE );
1214 // prepare reparenting
1215 Window* pRealParent = GetWindow()->GetWindow( WINDOW_PARENT );
1216 mpOldBorderWin = GetWindow()->GetWindow( WINDOW_BORDER );
1217 if( mpOldBorderWin == GetWindow() )
1218 mpOldBorderWin = NULL; // no border window found
1220 // the new parent for popup mode
1221 ImplPopupFloatWin* pWin = new ImplPopupFloatWin( mpParent, this, (nFlags & FLOATWIN_POPUPMODE_ALLOWTEAROFF) != 0 );
1223 pWin->SetPopupModeEndHdl( LINK( this, ImplDockingWindowWrapper, PopupModeEnd ) );
1224 pWin->SetText( GetWindow()->GetText() );
1226 pWin->SetOutputSizePixel( GetWindow()->GetSizePixel() );
1228 GetWindow()->mpWindowImpl->mpBorderWindow = NULL;
1229 GetWindow()->mpWindowImpl->mnLeftBorder = 0;
1230 GetWindow()->mpWindowImpl->mnTopBorder = 0;
1231 GetWindow()->mpWindowImpl->mnRightBorder = 0;
1232 GetWindow()->mpWindowImpl->mnBottomBorder = 0;
1234 // position toolbox below dragrect
1235 GetWindow()->SetPosPixel( pWin->GetToolboxPosition() );
1237 // reparent borderwindow and window
1238 if ( mpOldBorderWin )
1239 mpOldBorderWin->SetParent( pWin );
1240 GetWindow()->SetParent( pWin );
1242 // correct border window pointers
1243 GetWindow()->mpWindowImpl->mpBorderWindow = pWin;
1244 pWin->mpWindowImpl->mpClientWindow = GetWindow();
1245 GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
1247 // set mpFloatWin not until all window positioning is done !!!
1248 // (SetPosPixel etc. check for valid mpFloatWin pointer)
1249 mpFloatWin = pWin;
1251 // if the subtoolbar was opened via keyboard make sure that key events
1252 // will go into subtoolbar
1253 if( pParentToolBox->IsKeyEvent() )
1254 nFlags |= FLOATWIN_POPUPMODE_GRABFOCUS;
1256 mpFloatWin->StartPopupMode( pParentToolBox, nFlags );
1257 GetWindow()->Show();
1259 if( pParentToolBox->IsKeyEvent() )
1261 // send HOME key to subtoolbar in order to select first item
1262 KeyEvent aEvent( 0, KeyCode( KEY_HOME ) );
1263 mpFloatWin->GetPreferredKeyInputWindow()->KeyInput( aEvent );
1267 IMPL_LINK_NOARG(ImplDockingWindowWrapper, PopupModeEnd)
1269 GetWindow()->Show( sal_False, SHOW_NOFOCUSCHANGE );
1271 // set parameter for handler before destroying floating window
1272 ImplPopupFloatWin *pPopupFloatWin = (ImplPopupFloatWin*) mpFloatWin;
1273 EndPopupModeData aData( pPopupFloatWin->GetTearOffPosition(), mpFloatWin->IsPopupModeTearOff() );
1275 // before deleting change parent back, so we can delete the floating window alone
1276 Window* pRealParent = GetWindow()->GetWindow( WINDOW_PARENT );
1277 GetWindow()->mpWindowImpl->mpBorderWindow = NULL;
1278 if ( mpOldBorderWin )
1280 GetWindow()->SetParent( mpOldBorderWin );
1281 ((ImplBorderWindow*)mpOldBorderWin)->GetBorder(
1282 GetWindow()->mpWindowImpl->mnLeftBorder, GetWindow()->mpWindowImpl->mnTopBorder,
1283 GetWindow()->mpWindowImpl->mnRightBorder, GetWindow()->mpWindowImpl->mnBottomBorder );
1284 mpOldBorderWin->Resize();
1286 GetWindow()->mpWindowImpl->mpBorderWindow = mpOldBorderWin;
1287 GetWindow()->SetParent( pRealParent );
1288 GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
1290 delete mpFloatWin;
1291 mpFloatWin = NULL;
1293 // call handler - which will destroy the window and thus the wrapper as well !
1294 GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_ENDPOPUPMODE, &aData );
1296 return 0;
1300 sal_Bool ImplDockingWindowWrapper::IsInPopupMode() const
1302 if( GetFloatingWindow() )
1303 return GetFloatingWindow()->IsInPopupMode();
1304 else
1305 return sal_False;
1308 // -----------------------------------------------------------------------
1310 void ImplDockingWindowWrapper::SetFloatingMode( sal_Bool bFloatMode )
1312 // do nothing if window is docked and locked
1313 if( !IsFloatingMode() && IsLocked() )
1314 return;
1316 if ( IsFloatingMode() != bFloatMode )
1318 if ( PrepareToggleFloatingMode() )
1320 sal_Bool bVisible = GetWindow()->IsVisible();
1322 if ( bFloatMode )
1324 GetWindow()->Show( sal_False, SHOW_NOFOCUSCHANGE );
1326 maDockPos = GetWindow()->GetPosPixel();
1328 Window* pRealParent = GetWindow()->GetWindow( WINDOW_PARENT );
1329 mpOldBorderWin = GetWindow()->GetWindow( WINDOW_BORDER );
1330 if( mpOldBorderWin == mpDockingWindow )
1331 mpOldBorderWin = NULL; // no border window found
1333 ImplDockFloatWin2* pWin =
1334 new ImplDockFloatWin2(
1335 mpParent,
1336 mnFloatBits & ( WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE ) ?
1337 mnFloatBits | WB_SYSTEMWINDOW
1338 | WB_OWNERDRAWDECORATION
1339 : mnFloatBits,
1340 this );
1342 GetWindow()->mpWindowImpl->mpBorderWindow = NULL;
1343 GetWindow()->mpWindowImpl->mnLeftBorder = 0;
1344 GetWindow()->mpWindowImpl->mnTopBorder = 0;
1345 GetWindow()->mpWindowImpl->mnRightBorder = 0;
1346 GetWindow()->mpWindowImpl->mnBottomBorder = 0;
1348 // Falls Parent zerstoert wird, muessen wir auch vom
1349 // BorderWindow den Parent umsetzen
1350 if ( mpOldBorderWin )
1351 mpOldBorderWin->SetParent( pWin );
1352 GetWindow()->SetParent( pWin );
1353 pWin->SetPosPixel( Point() );
1355 GetWindow()->mpWindowImpl->mpBorderWindow = pWin;
1356 pWin->mpWindowImpl->mpClientWindow = mpDockingWindow;
1357 GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
1359 pWin->SetText( GetWindow()->GetText() );
1360 pWin->SetOutputSizePixel( GetWindow()->GetSizePixel() );
1361 pWin->SetPosPixel( maFloatPos );
1362 // DockingDaten ans FloatingWindow weiterreichen
1363 pWin->ShowTitleButton( TITLE_BUTTON_DOCKING, mbDockBtn );
1364 pWin->ShowTitleButton( TITLE_BUTTON_HIDE, mbHideBtn );
1365 pWin->SetPin( mbPined );
1366 if ( mbRollUp )
1367 pWin->RollUp();
1368 else
1369 pWin->RollDown();
1370 pWin->SetRollUpOutputSizePixel( maRollUpOutSize );
1371 pWin->SetMinOutputSizePixel( maMinOutSize );
1372 pWin->SetMaxOutputSizePixel( maMaxOutSize );
1374 mpFloatWin = pWin;
1376 if ( bVisible )
1377 GetWindow()->Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
1379 ToggleFloatingMode();
1381 else
1383 GetWindow()->Show( sal_False, SHOW_NOFOCUSCHANGE );
1385 // FloatingDaten wird im FloatingWindow speichern
1386 maFloatPos = mpFloatWin->GetPosPixel();
1387 mbDockBtn = mpFloatWin->IsTitleButtonVisible( TITLE_BUTTON_DOCKING );
1388 mbHideBtn = mpFloatWin->IsTitleButtonVisible( TITLE_BUTTON_HIDE );
1389 mbPined = mpFloatWin->IsPined();
1390 mbRollUp = mpFloatWin->IsRollUp();
1391 maRollUpOutSize = mpFloatWin->GetRollUpOutputSizePixel();
1392 maMinOutSize = mpFloatWin->GetMinOutputSizePixel();
1393 maMaxOutSize = mpFloatWin->GetMaxOutputSizePixel();
1395 Window* pRealParent = GetWindow()->GetWindow( WINDOW_PARENT ); //mpWindowImpl->mpRealParent;
1396 GetWindow()->mpWindowImpl->mpBorderWindow = NULL;
1397 if ( mpOldBorderWin )
1399 GetWindow()->SetParent( mpOldBorderWin );
1400 ((ImplBorderWindow*)mpOldBorderWin)->GetBorder(
1401 GetWindow()->mpWindowImpl->mnLeftBorder, GetWindow()->mpWindowImpl->mnTopBorder,
1402 GetWindow()->mpWindowImpl->mnRightBorder, GetWindow()->mpWindowImpl->mnBottomBorder );
1403 mpOldBorderWin->Resize();
1405 GetWindow()->mpWindowImpl->mpBorderWindow = mpOldBorderWin;
1406 GetWindow()->SetParent( pRealParent );
1407 GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
1409 delete static_cast<ImplDockFloatWin2*>(mpFloatWin);
1410 mpFloatWin = NULL;
1411 GetWindow()->SetPosPixel( maDockPos );
1413 if ( bVisible )
1414 GetWindow()->Show();
1416 ToggleFloatingMode();
1423 // -----------------------------------------------------------------------
1425 void ImplDockingWindowWrapper::SetFloatStyle( WinBits nStyle )
1427 mnFloatBits = nStyle;
1430 // -----------------------------------------------------------------------
1432 WinBits ImplDockingWindowWrapper::GetFloatStyle() const
1434 return mnFloatBits;
1437 // -----------------------------------------------------------------------
1439 void ImplDockingWindowWrapper::SetPosSizePixel( long nX, long nY,
1440 long nWidth, long nHeight,
1441 sal_uInt16 nFlags )
1443 if ( mpFloatWin )
1444 mpFloatWin->SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
1445 else
1446 GetWindow()->SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
1449 // -----------------------------------------------------------------------
1451 Point ImplDockingWindowWrapper::GetPosPixel() const
1453 if ( mpFloatWin )
1454 return mpFloatWin->GetPosPixel();
1455 else
1456 return mpDockingWindow->GetPosPixel();
1459 // -----------------------------------------------------------------------
1461 Size ImplDockingWindowWrapper::GetSizePixel() const
1463 if ( mpFloatWin )
1464 return mpFloatWin->GetSizePixel();
1465 else
1466 return mpDockingWindow->GetSizePixel();
1469 // -----------------------------------------------------------------------
1470 // old inlines from DockingWindow
1471 // -----------------------------------------------------------------------
1473 void ImplDockingWindowWrapper::SetMinOutputSizePixel( const Size& rSize )
1475 if ( mpFloatWin )
1476 mpFloatWin->SetMinOutputSizePixel( rSize );
1477 maMinOutSize = rSize;
1480 void ImplDockingWindowWrapper::SetMaxOutputSizePixel( const Size& rSize )
1482 if ( mpFloatWin )
1483 mpFloatWin->SetMaxOutputSizePixel( rSize );
1484 maMaxOutSize = rSize;
1487 sal_Bool ImplDockingWindowWrapper::IsFloatingMode() const
1489 return (mpFloatWin != NULL);
1493 void ImplDockingWindowWrapper::SetDragArea( const Rectangle& rRect )
1495 maDragArea = rRect;
1498 Rectangle ImplDockingWindowWrapper::GetDragArea() const
1500 return maDragArea;
1503 void ImplDockingWindowWrapper::Lock()
1505 mbLocked = sal_True;
1506 // only toolbars support locking
1507 ToolBox *pToolBox = dynamic_cast< ToolBox * >( GetWindow() );
1508 if( pToolBox )
1509 pToolBox->Lock( mbLocked );
1512 void ImplDockingWindowWrapper::Unlock()
1514 mbLocked = sal_False;
1515 // only toolbars support locking
1516 ToolBox *pToolBox = dynamic_cast< ToolBox * >( GetWindow() );
1517 if( pToolBox )
1518 pToolBox->Lock( mbLocked );
1521 sal_Bool ImplDockingWindowWrapper::IsLocked() const
1523 return mbLocked;
1526 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */