build fix: no comphelper/profilezone.hxx in this branch
[LibreOffice.git] / vcl / source / window / dockmgr.cxx
blobe22b306d8a0b742dfba9070f8da5f1642ae6a031
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <tools/time.hxx>
21 #include <tools/rc.h>
23 #include <brdwin.hxx>
24 #include <svdata.hxx>
25 #include <salframe.hxx>
26 #include <window.h>
28 #include <vcl/event.hxx>
29 #include <vcl/floatwin.hxx>
30 #include <vcl/dockwin.hxx>
31 #include <vcl/toolbox.hxx>
32 #include <vcl/svapp.hxx>
33 #include <vcl/timer.hxx>
34 #include <vcl/idle.hxx>
35 #include <vcl/lineinfo.hxx>
36 #include <vcl/unowrap.hxx>
37 #include <vcl/settings.hxx>
39 #define DOCKWIN_FLOATSTYLES (WB_SIZEABLE | WB_MOVEABLE | WB_CLOSEABLE | WB_STANDALONE | WB_PINABLE | WB_ROLLABLE )
41 class ImplDockFloatWin2 : public FloatingWindow
43 private:
44 ImplDockingWindowWrapper* mpDockWin;
45 sal_uInt64 mnLastTicks;
46 Idle maDockIdle;
47 Idle maEndDockIdle;
48 Point maDockPos;
49 Rectangle maDockRect;
50 bool mbInMove;
51 ImplSVEvent * mnLastUserEvent;
53 DECL_LINK(DockingHdl, void *, void);
54 DECL_LINK(DockTimerHdl, Idle *, void);
55 DECL_LINK(EndDockTimerHdl, Idle *, void);
56 public:
57 ImplDockFloatWin2( vcl::Window* pParent, WinBits nWinBits,
58 ImplDockingWindowWrapper* pDockingWin );
59 virtual ~ImplDockFloatWin2() override;
60 virtual void dispose() override;
62 virtual void Move() override;
63 virtual void Resize() override;
64 virtual void TitleButtonClick( TitleButton nButton ) override;
65 virtual void Resizing( Size& rSize ) override;
66 virtual bool Close() override;
69 ImplDockFloatWin2::ImplDockFloatWin2( vcl::Window* pParent, WinBits nWinBits,
70 ImplDockingWindowWrapper* pDockingWin ) :
71 FloatingWindow( pParent, nWinBits ),
72 mpDockWin( pDockingWin ),
73 mnLastTicks( tools::Time::GetSystemTicks() ),
74 mbInMove( false ),
75 mnLastUserEvent( nullptr )
77 // copy state of DockingWindow
78 if ( pDockingWin )
80 SetSettings( pDockingWin->GetWindow()->GetSettings() );
81 Enable( pDockingWin->GetWindow()->IsEnabled(), false );
82 EnableInput( pDockingWin->GetWindow()->IsInputEnabled(), false );
83 AlwaysEnableInput( pDockingWin->GetWindow()->IsAlwaysEnableInput(), false );
84 EnableAlwaysOnTop( pDockingWin->GetWindow()->IsAlwaysOnTopEnabled() );
85 SetActivateMode( pDockingWin->GetWindow()->GetActivateMode() );
88 SetBackground( GetSettings().GetStyleSettings().GetFaceColor() );
90 maDockIdle.SetIdleHdl( LINK( this, ImplDockFloatWin2, DockTimerHdl ) );
91 maDockIdle.SetPriority( SchedulerPriority::MEDIUM );
92 maDockIdle.SetDebugName( "vcl::ImplDockFloatWin2 maDockIdle" );
94 maEndDockIdle.SetIdleHdl( LINK( this, ImplDockFloatWin2, EndDockTimerHdl ) );
95 maEndDockIdle.SetPriority( SchedulerPriority::MEDIUM );
96 maEndDockIdle.SetDebugName( "vcl::ImplDockFloatWin2 maEndDockIdle" );
99 ImplDockFloatWin2::~ImplDockFloatWin2()
101 disposeOnce();
104 void ImplDockFloatWin2::dispose()
106 if( mnLastUserEvent )
107 Application::RemoveUserEvent( mnLastUserEvent );
108 FloatingWindow::dispose();
111 IMPL_LINK_NOARG(ImplDockFloatWin2, DockTimerHdl, Idle *, void)
113 SAL_WARN_IF( !mpDockWin->IsFloatingMode(), "vcl", "docktimer called but not floating" );
115 maDockIdle.Stop();
116 PointerState aState = GetPointerState();
118 if( aState.mnState & KEY_MOD1 )
120 // i43499 CTRL disables docking now
121 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
122 if( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) )
123 maDockIdle.Start();
125 else if( ! ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) )
127 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
128 mpDockWin->EndDocking( maDockRect, false );
130 else
132 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect, ShowTrackFlags::Big | ShowTrackFlags::TrackWindow );
133 maDockIdle.Start();
137 IMPL_LINK_NOARG(ImplDockFloatWin2, EndDockTimerHdl, Idle *, void)
139 SAL_WARN_IF( !mpDockWin->IsFloatingMode(), "vcl", "enddocktimer called but not floating" );
141 maEndDockIdle.Stop();
142 PointerState aState = GetPointerState();
143 if( ! ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) )
145 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
146 mpDockWin->EndDocking( maDockRect, true );
148 else
150 maEndDockIdle.Start();
154 IMPL_LINK_NOARG(ImplDockFloatWin2, DockingHdl, void*, void)
156 // called during move of a floating window
157 mnLastUserEvent = nullptr;
159 vcl::Window *pDockingArea = mpDockWin->GetWindow()->GetParent();
160 PointerState aState = pDockingArea->GetPointerState();
162 bool bRealMove = true;
163 if( GetStyle() & WB_OWNERDRAWDECORATION )
165 // for windows with ownerdraw decoration
166 // we allow docking only when the window was moved
167 // by dragging its caption
168 // and ignore move request due to resizing
169 vcl::Window *pBorder = GetWindow( GetWindowType::Border );
170 if( pBorder != this )
172 Rectangle aBorderRect( Point(), pBorder->GetSizePixel() );
173 sal_Int32 nLeft, nTop, nRight, nBottom;
174 GetBorder( nLeft, nTop, nRight, nBottom );
175 // limit borderrect to the caption part only and without the resizing borders
176 aBorderRect.Bottom() = aBorderRect.Top() + nTop;
177 aBorderRect.Left() += nLeft;
178 aBorderRect.Right() -= nRight;
180 PointerState aBorderState = pBorder->GetPointerState();
181 if( aBorderRect.IsInside( aBorderState.maPos ) )
182 bRealMove = true;
183 else
184 bRealMove = false;
188 if( mpDockWin->GetWindow()->IsVisible() &&
189 (tools::Time::GetSystemTicks() - mnLastTicks > 500) &&
190 ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) &&
191 !(aState.mnState & KEY_MOD1) && // i43499 CTRL disables docking now
192 bRealMove )
194 maDockPos = Point( pDockingArea->OutputToScreenPixel( pDockingArea->AbsoluteScreenToOutputPixel( OutputToAbsoluteScreenPixel( Point() ) ) ) );
195 maDockRect = Rectangle( maDockPos, mpDockWin->GetSizePixel() );
197 // mouse pos in screen pixels
198 Point aMousePos = pDockingArea->OutputToScreenPixel( aState.maPos );
200 if( ! mpDockWin->IsDocking() )
201 mpDockWin->StartDocking( aMousePos, maDockRect );
203 bool bFloatMode = mpDockWin->Docking( aMousePos, maDockRect );
205 if( ! bFloatMode )
207 // indicates that the window could be docked at maDockRect
208 maDockRect.SetPos( mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->ScreenToOutputPixel(
209 maDockRect.TopLeft() ) );
210 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect, ShowTrackFlags::Big | ShowTrackFlags::TrackWindow );
211 maEndDockIdle.Stop();
212 DockTimerHdl( nullptr );
214 else
216 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
217 maDockIdle.Stop();
218 EndDockTimerHdl( nullptr );
221 mbInMove = false;
224 void ImplDockFloatWin2::Move()
226 if( mbInMove )
227 return;
229 mbInMove = true;
230 FloatingWindow::Move();
231 mpDockWin->GetWindow()->Move();
234 * note: the window should only dock if KEY_MOD1 is pressed
235 * and the user releases all mouse buttons. The real problem here
236 * is that we don't get mouse events (at least not on X)
237 * if the mouse is on the decoration. So we have to start an
238 * awkward timer based process that polls the modifier/buttons
239 * to see whether they are in the right condition shortly after the
240 * last Move message.
242 if( ! mnLastUserEvent )
243 mnLastUserEvent = Application::PostUserEvent( LINK( this, ImplDockFloatWin2, DockingHdl ), nullptr, true );
246 void ImplDockFloatWin2::Resize()
248 // forwarding of resize only required if we have no borderwindow ( GetWindow() then returns 'this' )
249 if( GetWindow( GetWindowType::Border ) == this )
251 FloatingWindow::Resize();
252 Size aSize( GetSizePixel() );
253 mpDockWin->GetWindow()->ImplPosSizeWindow( 0, 0, aSize.Width(), aSize.Height(), PosSizeFlags::PosSize ); // TODO: is this needed ???
257 void ImplDockFloatWin2::TitleButtonClick( TitleButton nButton )
259 FloatingWindow::TitleButtonClick( nButton );
260 mpDockWin->TitleButtonClick( nButton );
263 void ImplDockFloatWin2::Resizing( Size& rSize )
265 FloatingWindow::Resizing( rSize );
266 mpDockWin->Resizing( rSize );
269 bool ImplDockFloatWin2::Close()
271 return true;
274 DockingManager::DockingManager()
278 DockingManager::~DockingManager()
280 ::std::vector< ImplDockingWindowWrapper* >::iterator p;
281 p = mDockingWindows.begin();
282 for(; p != mDockingWindows.end(); ++p )
284 delete (*p);
286 mDockingWindows.clear();
289 ImplDockingWindowWrapper* DockingManager::GetDockingWindowWrapper( const vcl::Window *pWindow )
291 ::std::vector< ImplDockingWindowWrapper* >::iterator p;
292 p = mDockingWindows.begin();
293 while( p != mDockingWindows.end() )
295 if( (*p)->mpDockingWindow == pWindow )
296 return (*p);
297 else
298 ++p;
300 return nullptr;
303 bool DockingManager::IsDockable( const vcl::Window *pWindow )
305 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
308 if( pWindow->HasDockingHandler() )
309 return true;
311 return (pWrapper != nullptr);
314 bool DockingManager::IsFloating( const vcl::Window *pWindow )
316 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
317 if( pWrapper )
318 return pWrapper->IsFloatingMode();
319 else
320 return false;
323 bool DockingManager::IsLocked( const vcl::Window *pWindow )
325 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
326 if( pWrapper && pWrapper->IsLocked() )
327 return true;
328 else
329 return false;
332 void DockingManager::Lock( const vcl::Window *pWindow )
334 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
335 if( pWrapper )
336 pWrapper->Lock();
339 void DockingManager::Unlock( const vcl::Window *pWindow )
341 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
342 if( pWrapper )
343 pWrapper->Unlock();
346 void DockingManager::SetFloatingMode( const vcl::Window *pWindow, bool bFloating )
348 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
349 if( pWrapper )
350 pWrapper->SetFloatingMode( bFloating );
353 void DockingManager::StartPopupMode( ToolBox *pParentToolBox, const vcl::Window *pWindow, FloatWinPopupFlags nFlags )
355 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
356 if( pWrapper )
357 pWrapper->StartPopupMode( pParentToolBox, nFlags );
360 void DockingManager::StartPopupMode( ToolBox *pParentToolBox, const vcl::Window *pWindow )
362 StartPopupMode( pParentToolBox, pWindow, FloatWinPopupFlags::AllowTearOff |
363 FloatWinPopupFlags::AllMouseButtonClose |
364 FloatWinPopupFlags::NoMouseUpClose );
367 bool DockingManager::IsInPopupMode( const vcl::Window *pWindow )
369 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
370 if( pWrapper && pWrapper->IsInPopupMode() )
371 return true;
372 else
373 return false;
376 void DockingManager::EndPopupMode( const vcl::Window *pWin )
378 ImplDockingWindowWrapper *pWrapper = GetDockingWindowWrapper( pWin );
379 if( pWrapper && pWrapper->GetFloatingWindow() && pWrapper->GetFloatingWindow()->IsInPopupMode() )
380 pWrapper->GetFloatingWindow()->EndPopupMode();
383 void DockingManager::AddWindow( const vcl::Window *pWindow )
385 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
386 if( pWrapper )
387 return;
388 else
389 pWrapper = new ImplDockingWindowWrapper( pWindow );
391 mDockingWindows.push_back( pWrapper );
394 void DockingManager::RemoveWindow( const vcl::Window *pWindow )
396 ::std::vector< ImplDockingWindowWrapper* >::iterator p;
397 p = mDockingWindows.begin();
398 while( p != mDockingWindows.end() )
400 if( (*p)->mpDockingWindow == pWindow )
402 delete (*p);
403 mDockingWindows.erase( p );
404 break;
406 else
407 ++p;
411 void DockingManager::SetPosSizePixel( vcl::Window *pWindow, long nX, long nY,
412 long nWidth, long nHeight,
413 PosSizeFlags nFlags )
415 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
416 if( pWrapper )
417 pWrapper->setPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
420 Rectangle DockingManager::GetPosSizePixel( const vcl::Window *pWindow )
422 Rectangle aRect;
423 ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
424 if( pWrapper )
425 aRect = Rectangle( pWrapper->GetPosPixel(), pWrapper->GetSizePixel() );
427 return aRect;
430 // special floating window for popup mode
431 // main purpose: provides tear-off area for undocking
433 // if TEAROFF_DASHED defined a single dashed line is used
434 // otherwise multiple smaller lines will be painted
435 //#define TEAROFF_DASHED
437 // size of the drag area
438 #ifdef TEAROFF_DASHED
439 #define POPUP_DRAGBORDER 2
440 #define POPUP_DRAGGRIP 5
441 #else
442 #define POPUP_DRAGBORDER 3
443 #define POPUP_DRAGGRIP 5
444 #endif
445 #define POPUP_DRAGHEIGHT (POPUP_DRAGGRIP+POPUP_DRAGBORDER+POPUP_DRAGBORDER)
446 #define POPUP_DRAGWIDTH 20
448 class ImplPopupFloatWin : public FloatingWindow
450 private:
451 ImplDockingWindowWrapper* mpDockingWin;
452 bool mbHighlight;
453 bool mbMoving;
454 bool mbTrackingEnabled;
455 Point maDelta;
456 bool mbHasGrip;
457 void ImplSetBorder();
459 public:
460 ImplPopupFloatWin( vcl::Window* pParent, ImplDockingWindowWrapper* pDockingWin, bool bHasGrip );
461 virtual ~ImplPopupFloatWin() override;
462 virtual void dispose() override;
464 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
465 virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) override;
466 virtual void MouseMove( const MouseEvent& rMEvt ) override;
467 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
468 virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
469 virtual void Tracking( const TrackingEvent& rTEvt ) override;
470 virtual void Resize() override;
472 Rectangle GetDragRect() const;
473 void DrawGrip(vcl::RenderContext& rRenderContext);
474 void DrawBorder(vcl::RenderContext& rRenderContext);
476 bool hasGrip() const { return mbHasGrip; }
479 ImplPopupFloatWin::ImplPopupFloatWin( vcl::Window* pParent, ImplDockingWindowWrapper* pDockingWin, bool bHasGrip ) :
480 FloatingWindow( pParent, WB_NOBORDER | WB_SYSTEMWINDOW | WB_NOSHADOW)
482 mpWindowImpl->mbToolbarFloatingWindow = true; // indicate window type, required for accessibility
483 // which should not see this window as a toplevel window
484 mpDockingWin = pDockingWin;
485 mbHighlight = false;
486 mbMoving = false;
487 mbTrackingEnabled = false;
488 mbHasGrip = bHasGrip;
490 ImplSetBorder();
493 ImplPopupFloatWin::~ImplPopupFloatWin()
495 disposeOnce();
498 void ImplPopupFloatWin::dispose()
500 mpDockingWin = nullptr;
501 FloatingWindow::dispose();
504 css::uno::Reference< css::accessibility::XAccessible > ImplPopupFloatWin::CreateAccessible()
506 // switch off direct accessibilty support for this window
508 // this is to avoid appearance of this window as standalone window in the accessibility hierarchy
509 // as this window is only used as a helper for subtoolbars that are not teared-off, the parent toolbar
510 // has to provide accessibility support (as implemented in the toolkit)
511 // so the contained toolbar should appear as child of the corresponding toolbar item of the parent toolbar
512 return css::uno::Reference< css::accessibility::XAccessible >();
515 void ImplPopupFloatWin::ImplSetBorder()
517 // although we have no border in the sense of a borderwindow
518 // we're using a special border for the grip
519 // by setting those members the method SetOutputSizePixel() can
520 // be used to set the proper window size
521 mpWindowImpl->mnTopBorder = 1;
522 if( hasGrip() )
523 mpWindowImpl->mnTopBorder += POPUP_DRAGHEIGHT+2;
524 mpWindowImpl->mnBottomBorder = 1;
525 mpWindowImpl->mnLeftBorder = 1;
526 mpWindowImpl->mnRightBorder = 1;
529 void ImplPopupFloatWin::Resize()
531 // the borderview overwrites the border during resize so restore it
532 ImplSetBorder();
535 Rectangle ImplPopupFloatWin::GetDragRect() const
537 if( !hasGrip() )
538 return Rectangle();
540 return Rectangle( 1, GetOutputSizePixel().Height() - 3 - POPUP_DRAGHEIGHT,
541 GetOutputSizePixel().Width() - 1, GetOutputSizePixel().Height() - 1 );
544 void ImplPopupFloatWin::DrawBorder(vcl::RenderContext& rRenderContext)
546 rRenderContext.SetFillColor();
547 Rectangle aRect( Point(), GetOutputSizePixel() );
549 vcl::Region oldClipRgn( GetClipRegion( ) );
550 vcl::Region aClipRgn( aRect );
551 Rectangle aItemClipRect( ImplGetItemEdgeClipRect() );
552 if( !aItemClipRect.IsEmpty() )
554 aItemClipRect.SetPos( AbsoluteScreenToOutputPixel( aItemClipRect.TopLeft() ) );
556 // draw the excluded border part with the background color of a toolbox
557 rRenderContext.SetClipRegion( vcl::Region( aItemClipRect ) );
558 rRenderContext.SetLineColor( GetSettings().GetStyleSettings().GetFaceColor() );
559 rRenderContext.DrawRect( aRect );
561 aClipRgn.Exclude( aItemClipRect );
562 SetClipRegion( aClipRgn );
564 rRenderContext.SetLineColor( rRenderContext.GetSettings().GetStyleSettings().GetShadowColor() );
565 rRenderContext.DrawRect( aRect );
566 rRenderContext.SetClipRegion( oldClipRgn );
569 void ImplPopupFloatWin::DrawGrip(vcl::RenderContext& rRenderContext)
571 bool bLinecolor = rRenderContext.IsLineColor();
572 Color aLinecolor = rRenderContext.GetLineColor();
573 bool bFillcolor = rRenderContext.IsFillColor();
574 Color aFillcolor = rRenderContext.GetFillColor();
576 // draw background
577 Rectangle aRect(GetDragRect());
578 aRect.Top() += POPUP_DRAGBORDER;
579 aRect.Bottom() -= POPUP_DRAGBORDER;
580 aRect.Left() += 3;
581 aRect.Right() -= 3;
583 if (mbHighlight)
585 rRenderContext.Erase(aRect);
586 vcl::RenderTools::DrawSelectionBackground(rRenderContext, *this, aRect, 2, false, true, false);
588 else
590 rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetFaceColor());
591 rRenderContext.SetLineColor();
592 rRenderContext.DrawRect(aRect);
595 if (!ToolBox::AlwaysLocked()) // no grip if toolboxes are locked
597 #ifdef TEAROFF_DASHED
598 // draw single dashed line
599 LineInfo aLineInfo(LineStyle::Dash);
600 aLineInfo.SetDistance(4);
601 aLineInfo.SetDashLen(12);
602 aLineInfo.SetDashCount(1);
604 aRect.Left() += 2;
605 aRect.Right()-= 2;
607 aRect.Top() += 2;
608 aRect.Bottom() = aRect.Top();
609 rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetDarkShadowColor());
610 rRenderContext.DrawLine(aRect.TopLeft(), aRect.TopRight(), aLineInfo);
612 if (!mbHighlight)
614 ++aRect.Top();
615 ++aRect.Bottom();
616 rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetLightColor());
617 rRenderContext.DrawLine(aRect.TopLeft(), aRect.TopRight(), aLineInfo);
620 #else
621 // draw several grip lines
622 rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetShadowColor());
623 aRect.Top()++;
624 aRect.Bottom() = aRect.Top();
626 int width = POPUP_DRAGWIDTH;
627 while(width >= aRect.getWidth())
629 width -= 4;
631 if (width <= 0)
632 width = aRect.getWidth();
633 //aRect.nLeft = aRect.nLeft + (aRect.getWidth() - width) / 2;
634 aRect.Left() = (aRect.Left() + aRect.Right() - width) / 2;
635 aRect.Right() = aRect.Left() + width;
637 int i = 0;
638 while (i < POPUP_DRAGGRIP)
640 rRenderContext.DrawRect(aRect);
641 aRect.Top() += 2;
642 aRect.Bottom() += 2;
643 i += 2;
645 #endif
648 if (bLinecolor)
649 rRenderContext.SetLineColor(aLinecolor);
650 else
651 rRenderContext.SetLineColor();
652 if (bFillcolor)
653 rRenderContext.SetFillColor(aFillcolor);
654 else
655 rRenderContext.SetFillColor();
658 void ImplPopupFloatWin::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
660 Rectangle aRect(Point(), GetOutputSizePixel());
661 rRenderContext.DrawWallpaper(aRect, Wallpaper(rRenderContext.GetSettings().GetStyleSettings().GetFaceGradientColor()));
662 DrawBorder(rRenderContext);
663 if (hasGrip())
664 DrawGrip(rRenderContext);
667 void ImplPopupFloatWin::MouseMove( const MouseEvent& rMEvt )
669 Point aMousePos = rMEvt.GetPosPixel();
671 if( !ToolBox::AlwaysLocked() ) // no tear off if locking is enabled
673 if( mbTrackingEnabled && rMEvt.IsLeft() && GetDragRect().IsInside( aMousePos ) )
675 // start window move
676 mbMoving = true;
677 StartTracking( StartTrackingFlags::NoKeyCancel );
678 return;
680 if( !mbHighlight && GetDragRect().IsInside( aMousePos ) )
682 mbHighlight = true;
683 Invalidate();
685 if (mbHighlight && ( rMEvt.IsLeaveWindow() || !GetDragRect().IsInside( aMousePos ) ) )
687 mbHighlight = false;
688 Invalidate();
693 void ImplPopupFloatWin::MouseButtonUp( const MouseEvent& rMEvt )
695 mbTrackingEnabled = false;
696 FloatingWindow::MouseButtonUp( rMEvt );
699 void ImplPopupFloatWin::MouseButtonDown( const MouseEvent& rMEvt )
701 Point aMousePos = rMEvt.GetPosPixel();
702 if( GetDragRect().IsInside( aMousePos ) )
704 // get mouse pos at a static window to have a fixed reference point
705 PointerState aState = GetParent()->GetPointerState();
706 if (HasMirroredGraphics() && IsRTLEnabled())
707 ImplMirrorFramePos(aState.maPos);
708 maDelta = aState.maPos - GetWindow( GetWindowType::Border )->GetPosPixel();
709 mbTrackingEnabled = true;
711 else
713 mbTrackingEnabled = false;
717 void ImplPopupFloatWin::Tracking( const TrackingEvent& rTEvt )
719 if( mbMoving )
721 if ( rTEvt.IsTrackingEnded() )
723 mbMoving = false;
724 EndPopupMode( FloatWinPopupEndFlags::TearOff );
726 else if ( !rTEvt.GetMouseEvent().IsSynthetic() )
728 // move the window according to mouse pos
729 PointerState aState = GetParent()->GetPointerState();
730 const OutputDevice *pOutDev = GetOutDev();
731 if (pOutDev->HasMirroredGraphics() && IsRTLEnabled())
732 ImplMirrorFramePos(aState.maPos);
733 GetWindow( GetWindowType::Border )->SetPosPixel( aState.maPos - maDelta );
738 ImplDockingWindowWrapper::ImplDockingWindowWrapper( const vcl::Window *pWindow )
739 : mpDockingWindow(const_cast<vcl::Window*>(pWindow))
740 , mpFloatWin(nullptr)
741 , mpOldBorderWin(nullptr)
742 , mpParent(pWindow->GetParent())
743 , maMaxOutSize( SHRT_MAX, SHRT_MAX )
744 , mnTrackX(0)
745 , mnTrackY(0)
746 , mnTrackWidth(0)
747 , mnTrackHeight(0)
748 , mnDockLeft(0)
749 , mnDockTop(0)
750 , mnDockRight(0)
751 , mnDockBottom(0)
752 , mnFloatBits(WB_BORDER | WB_CLOSEABLE | WB_SIZEABLE | (pWindow->GetStyle() & DOCKWIN_FLOATSTYLES))
753 , mbDockCanceled(false)
754 , mbDocking(false)
755 , mbLastFloatMode(false)
756 , mbStartFloat(false)
757 , mbPinned(false)
758 , mbRollUp(false)
759 , mbDockBtn(false)
760 , mbHideBtn(false)
761 // must be enabled in Window::Notify to prevent permanent docking during mouse move
762 , mbStartDockingEnabled(false)
763 , mbLocked(false)
765 DockingWindow *pDockWin = dynamic_cast< DockingWindow* > ( mpDockingWindow.get() );
766 if( pDockWin )
767 mnFloatBits = pDockWin->GetFloatStyle();
770 ImplDockingWindowWrapper::~ImplDockingWindowWrapper()
772 if ( IsFloatingMode() )
774 GetWindow()->Show( false, ShowFlags::NoFocusChange );
775 SetFloatingMode(false);
779 bool ImplDockingWindowWrapper::ImplStartDocking( const Point& rPos )
781 if( !mbStartDockingEnabled )
782 return false;
784 maMouseOff = rPos;
785 maMouseStart = maMouseOff;
786 mbDocking = true;
787 mbLastFloatMode = IsFloatingMode();
788 mbStartFloat = mbLastFloatMode;
790 // calculate FloatingBorder
791 VclPtr<FloatingWindow> pWin;
792 if ( mpFloatWin )
793 pWin = mpFloatWin;
794 else
795 pWin = VclPtr<ImplDockFloatWin2>::Create( mpParent, mnFloatBits, nullptr );
796 pWin->GetBorder( mnDockLeft, mnDockTop, mnDockRight, mnDockBottom );
797 if ( !mpFloatWin )
798 pWin.disposeAndClear();
800 Point aPos = GetWindow()->ImplOutputToFrame( Point() );
801 Size aSize = GetWindow()->GetOutputSizePixel();
802 mnTrackX = aPos.X();
803 mnTrackY = aPos.Y();
804 mnTrackWidth = aSize.Width();
805 mnTrackHeight = aSize.Height();
807 if ( mbLastFloatMode )
809 maMouseOff.X() += mnDockLeft;
810 maMouseOff.Y() += mnDockTop;
811 mnTrackX -= mnDockLeft;
812 mnTrackY -= mnDockTop;
813 mnTrackWidth += mnDockLeft+mnDockRight;
814 mnTrackHeight += mnDockTop+mnDockBottom;
817 vcl::Window *pDockingArea = GetWindow()->GetParent();
818 vcl::Window::PointerState aState = pDockingArea->GetPointerState();
820 // mouse pos in screen pixels
821 Point aMousePos = pDockingArea->OutputToScreenPixel( aState.maPos );
822 Point aDockPos = Point( pDockingArea->AbsoluteScreenToOutputPixel( GetWindow()->OutputToAbsoluteScreenPixel( GetWindow()->GetPosPixel() ) ) );
823 Rectangle aDockRect( aDockPos, GetWindow()->GetSizePixel() );
824 StartDocking( aMousePos, aDockRect );
826 GetWindow()->ImplUpdateAll();
827 GetWindow()->ImplGetFrameWindow()->ImplUpdateAll();
829 GetWindow()->StartTracking( StartTrackingFlags::KeyMod );
830 return true;
833 void ImplDockingWindowWrapper::Tracking( const TrackingEvent& rTEvt )
835 // used during docking of a currently docked window
836 if ( mbDocking )
838 if ( rTEvt.IsTrackingEnded() )
840 mbDocking = false;
841 GetWindow()->HideTracking();
842 if ( rTEvt.IsTrackingCanceled() )
844 mbDockCanceled = true;
845 EndDocking( Rectangle( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) ), mbLastFloatMode );
846 mbDockCanceled = false;
848 else
849 EndDocking( Rectangle( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) ), mbLastFloatMode );
851 // Docking only upon non-synthetic MouseEvents
852 else if ( !rTEvt.GetMouseEvent().IsSynthetic() || rTEvt.GetMouseEvent().IsModifierChanged() )
854 Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
855 Point aFrameMousePos = GetWindow()->ImplOutputToFrame( aMousePos );
856 Size aFrameSize = GetWindow()->ImplGetFrameWindow()->GetOutputSizePixel();
857 if ( aFrameMousePos.X() < 0 )
858 aFrameMousePos.X() = 0;
859 if ( aFrameMousePos.Y() < 0 )
860 aFrameMousePos.Y() = 0;
861 if ( aFrameMousePos.X() > aFrameSize.Width()-1 )
862 aFrameMousePos.X() = aFrameSize.Width()-1;
863 if ( aFrameMousePos.Y() > aFrameSize.Height()-1 )
864 aFrameMousePos.Y() = aFrameSize.Height()-1;
865 aMousePos = GetWindow()->ImplFrameToOutput( aFrameMousePos );
866 aMousePos.X() -= maMouseOff.X();
867 aMousePos.Y() -= maMouseOff.Y();
868 Point aPos = GetWindow()->ImplOutputToFrame( aMousePos );
869 Rectangle aTrackRect( aPos, Size( mnTrackWidth, mnTrackHeight ) );
870 Rectangle aCompRect = aTrackRect;
871 aPos.X() += maMouseOff.X();
872 aPos.Y() += maMouseOff.Y();
874 bool bFloatMode = Docking( aPos, aTrackRect );
876 if ( mbLastFloatMode != bFloatMode )
878 if ( bFloatMode )
880 aTrackRect.Left() -= mnDockLeft;
881 aTrackRect.Top() -= mnDockTop;
882 aTrackRect.Right() += mnDockRight;
883 aTrackRect.Bottom() += mnDockBottom;
885 else
887 if ( aCompRect == aTrackRect )
889 aTrackRect.Left() += mnDockLeft;
890 aTrackRect.Top() += mnDockTop;
891 aTrackRect.Right() -= mnDockRight;
892 aTrackRect.Bottom() -= mnDockBottom;
895 mbLastFloatMode = bFloatMode;
898 ShowTrackFlags nTrackStyle;
899 if ( bFloatMode )
900 nTrackStyle = ShowTrackFlags::Object;
901 else
902 nTrackStyle = ShowTrackFlags::Big;
903 Rectangle aShowTrackRect = aTrackRect;
904 aShowTrackRect.SetPos( GetWindow()->ImplFrameToOutput( aShowTrackRect.TopLeft() ) );
906 GetWindow()->ShowTracking( aShowTrackRect, nTrackStyle );
908 // calculate mouse offset again, as the rectangle was changed
909 maMouseOff.X() = aPos.X() - aTrackRect.Left();
910 maMouseOff.Y() = aPos.Y() - aTrackRect.Top();
912 mnTrackX = aTrackRect.Left();
913 mnTrackY = aTrackRect.Top();
914 mnTrackWidth = aTrackRect.GetWidth();
915 mnTrackHeight = aTrackRect.GetHeight();
920 void ImplDockingWindowWrapper::StartDocking( const Point& rPoint, Rectangle& rRect )
922 DockingData data( rPoint, rRect, IsFloatingMode() );
924 GetWindow()->CallEventListeners( VCLEVENT_WINDOW_STARTDOCKING, &data );
925 mbDocking = true;
928 bool ImplDockingWindowWrapper::Docking( const Point& rPoint, Rectangle& rRect )
930 DockingData data( rPoint, rRect, IsFloatingMode() );
932 GetWindow()->CallEventListeners( VCLEVENT_WINDOW_DOCKING, &data );
933 rRect = data.maTrackRect;
934 return data.mbFloating;
937 void ImplDockingWindowWrapper::EndDocking( const Rectangle& rRect, bool bFloatMode )
939 Rectangle aRect( rRect );
941 bool bOrigDockCanceled = mbDockCanceled;
942 if (bFloatMode && !StyleSettings::GetDockingFloatsSupported())
943 mbDockCanceled = true;
945 if ( !IsDockingCanceled() )
947 bool bShow = false;
948 if ( bFloatMode != IsFloatingMode() )
950 GetWindow()->Show( false, ShowFlags::NoFocusChange );
951 SetFloatingMode( bFloatMode );
952 bShow = true;
953 if ( bFloatMode )
955 // #i44800# always use outputsize - as in all other places
956 mpFloatWin->SetOutputSizePixel( aRect.GetSize() );
957 mpFloatWin->SetPosPixel( aRect.TopLeft() );
960 if ( !bFloatMode )
962 Point aPos = aRect.TopLeft();
963 aPos = GetWindow()->GetParent()->ScreenToOutputPixel( aPos );
964 GetWindow()->SetPosSizePixel( aPos, aRect.GetSize() );
967 if ( bShow )
968 GetWindow()->Show( true, ShowFlags::NoFocusChange | ShowFlags::NoActivate );
971 EndDockingData data( aRect, IsFloatingMode(), IsDockingCanceled() );
972 GetWindow()->CallEventListeners( VCLEVENT_WINDOW_ENDDOCKING, &data );
974 mbDocking = false;
976 // must be enabled in Window::Notify to prevent permanent docking during mouse move
977 mbStartDockingEnabled = false;
979 mbDockCanceled = bOrigDockCanceled;
982 bool ImplDockingWindowWrapper::PrepareToggleFloatingMode()
984 bool bFloating = true;
985 GetWindow()->CallEventListeners( VCLEVENT_WINDOW_PREPARETOGGLEFLOATING, &bFloating );
986 return bFloating;
989 void ImplDockingWindowWrapper::ToggleFloatingMode()
991 // notify dockingwindow/toolbox
992 // note: this must be done *before* notifying the
993 // listeners to have the toolbox in the proper state
994 if( GetWindow()->IsDockingWindow() )
995 static_cast<DockingWindow*>(GetWindow())->ToggleFloatingMode();
997 // now notify listeners
998 GetWindow()->CallEventListeners( VCLEVENT_WINDOW_TOGGLEFLOATING );
1000 // must be enabled in Window::Notify to prevent permanent docking during mouse move
1001 mbStartDockingEnabled = false;
1004 void ImplDockingWindowWrapper::TitleButtonClick( TitleButton nType )
1006 if( nType == TitleButton::Menu )
1008 ToolBox *pToolBox = dynamic_cast< ToolBox* >( GetWindow() );
1009 if( pToolBox )
1011 pToolBox->ExecuteCustomMenu();
1014 if( nType == TitleButton::Docking )
1016 SetFloatingMode( !IsFloatingMode() );
1020 void ImplDockingWindowWrapper::Resizing( Size& rSize )
1022 // TODO: add virtual Resizing() to class Window, so we can get rid of class DockingWindow
1023 DockingWindow *pDockingWindow = dynamic_cast< DockingWindow* >( GetWindow() );
1024 if( pDockingWindow )
1025 pDockingWindow->Resizing( rSize );
1028 void ImplDockingWindowWrapper::ShowTitleButton( TitleButton nButton, bool bVisible )
1030 if ( mpFloatWin )
1031 mpFloatWin->ShowTitleButton( nButton, bVisible );
1032 else
1034 if ( nButton == TitleButton::Docking )
1035 mbDockBtn = bVisible;
1036 else // if ( nButton == TitleButton::Hide )
1037 mbHideBtn = bVisible;
1041 void ImplDockingWindowWrapper::StartPopupMode( ToolBox *pParentToolBox, FloatWinPopupFlags nFlags )
1043 // do nothing if window is floating
1044 if( IsFloatingMode() )
1045 return;
1047 GetWindow()->Show( false, ShowFlags::NoFocusChange );
1049 // prepare reparenting
1050 vcl::Window* pRealParent = GetWindow()->GetWindow( GetWindowType::Parent );
1051 mpOldBorderWin = GetWindow()->GetWindow( GetWindowType::Border );
1052 if( mpOldBorderWin.get() == GetWindow() )
1053 mpOldBorderWin = nullptr; // no border window found
1055 bool bAllowTearOff = bool( nFlags & FloatWinPopupFlags::AllowTearOff );
1056 bool bIsToolBox = GetWindow()->GetType() == WINDOW_TOOLBOX;
1058 // the new parent for popup mode
1059 VclPtr<FloatingWindow> pWin;
1060 if ( bAllowTearOff && !bIsToolBox )
1061 pWin = VclPtr<FloatingWindow>::Create( mpParent, WB_STDPOPUP );
1062 else
1063 pWin = VclPtr<ImplPopupFloatWin>::Create( mpParent, this, bAllowTearOff );
1065 pWin->SetPopupModeEndHdl( LINK( this, ImplDockingWindowWrapper, PopupModeEnd ) );
1066 pWin->SetText( GetWindow()->GetText() );
1068 pWin->SetOutputSizePixel( GetWindow()->GetSizePixel() );
1070 GetWindow()->mpWindowImpl->mpBorderWindow = nullptr;
1071 GetWindow()->mpWindowImpl->mnLeftBorder = 0;
1072 GetWindow()->mpWindowImpl->mnTopBorder = 0;
1073 GetWindow()->mpWindowImpl->mnRightBorder = 0;
1074 GetWindow()->mpWindowImpl->mnBottomBorder = 0;
1076 // position toolbox above DragRect
1077 GetWindow()->SetPosPixel( Point( 1, 1 ) );
1079 // reparent borderwindow and window
1080 if ( mpOldBorderWin )
1081 mpOldBorderWin->SetParent( pWin );
1082 GetWindow()->SetParent( pWin );
1084 // correct border window pointers
1085 GetWindow()->mpWindowImpl->mpBorderWindow = pWin;
1086 pWin->mpWindowImpl->mpClientWindow = GetWindow();
1087 GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
1089 // set mpFloatWin not until all window positioning is done !!!
1090 // (SetPosPixel etc. check for valid mpFloatWin pointer)
1091 mpFloatWin = pWin;
1093 // if the subtoolbar was opened via keyboard make sure that key events
1094 // will go into subtoolbar
1095 if( pParentToolBox->IsKeyEvent() )
1096 nFlags |= FloatWinPopupFlags::GrabFocus;
1098 mpFloatWin->StartPopupMode( pParentToolBox, nFlags );
1099 GetWindow()->Show();
1101 if( pParentToolBox->IsKeyEvent() )
1103 // send HOME key to subtoolbar in order to select first item
1104 KeyEvent aEvent( 0, vcl::KeyCode( KEY_HOME ) );
1105 GetWindow()->KeyInput(aEvent);
1109 IMPL_LINK_NOARG(ImplDockingWindowWrapper, PopupModeEnd, FloatingWindow*, void)
1111 GetWindow()->Show( false, ShowFlags::NoFocusChange );
1113 // set parameter for handler before destroying floating window
1114 EndPopupModeData aData( mpFloatWin->GetWindow( GetWindowType::Border )->GetPosPixel(), mpFloatWin->IsPopupModeTearOff() );
1116 // before deleting change parent back, so we can delete the floating window alone
1117 vcl::Window* pRealParent = GetWindow()->GetWindow( GetWindowType::Parent );
1118 GetWindow()->mpWindowImpl->mpBorderWindow = nullptr;
1119 if ( mpOldBorderWin )
1121 GetWindow()->SetParent( mpOldBorderWin );
1122 static_cast<ImplBorderWindow*>(mpOldBorderWin.get())->GetBorder(
1123 GetWindow()->mpWindowImpl->mnLeftBorder, GetWindow()->mpWindowImpl->mnTopBorder,
1124 GetWindow()->mpWindowImpl->mnRightBorder, GetWindow()->mpWindowImpl->mnBottomBorder );
1125 mpOldBorderWin->Resize();
1127 GetWindow()->mpWindowImpl->mpBorderWindow = mpOldBorderWin;
1128 GetWindow()->SetParent( pRealParent );
1129 GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
1131 mpFloatWin.disposeAndClear();
1133 // call handler - which will destroy the window and thus the wrapper as well !
1134 GetWindow()->CallEventListeners( VCLEVENT_WINDOW_ENDPOPUPMODE, &aData );
1137 bool ImplDockingWindowWrapper::IsInPopupMode() const
1139 if( GetFloatingWindow() )
1140 return GetFloatingWindow()->IsInPopupMode();
1141 else
1142 return false;
1145 void ImplDockingWindowWrapper::SetFloatingMode( bool bFloatMode )
1147 // do nothing if window is docked and locked
1148 if( !IsFloatingMode() && IsLocked() )
1149 return;
1151 if ( IsFloatingMode() != bFloatMode )
1153 if ( PrepareToggleFloatingMode() )
1155 bool bVisible = GetWindow()->IsVisible();
1157 if ( bFloatMode )
1159 GetWindow()->Show( false, ShowFlags::NoFocusChange );
1161 maDockPos = GetWindow()->GetPosPixel();
1163 vcl::Window* pRealParent = GetWindow()->GetWindow( GetWindowType::Parent );
1164 mpOldBorderWin = GetWindow()->GetWindow( GetWindowType::Border );
1165 if( mpOldBorderWin == mpDockingWindow )
1166 mpOldBorderWin = nullptr; // no border window found
1168 VclPtrInstance<ImplDockFloatWin2> pWin(
1169 mpParent,
1170 mnFloatBits & ( WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE ) ?
1171 mnFloatBits | WB_SYSTEMWINDOW
1172 | WB_OWNERDRAWDECORATION
1173 : mnFloatBits,
1174 this );
1176 GetWindow()->mpWindowImpl->mpBorderWindow = nullptr;
1177 GetWindow()->mpWindowImpl->mnLeftBorder = 0;
1178 GetWindow()->mpWindowImpl->mnTopBorder = 0;
1179 GetWindow()->mpWindowImpl->mnRightBorder = 0;
1180 GetWindow()->mpWindowImpl->mnBottomBorder = 0;
1182 // if the parent gets destroyed, we also have to reset the parent of the BorderWindow
1183 if ( mpOldBorderWin )
1184 mpOldBorderWin->SetParent( pWin );
1185 GetWindow()->SetParent( pWin );
1186 pWin->SetPosPixel( Point() );
1188 GetWindow()->mpWindowImpl->mpBorderWindow = pWin;
1189 pWin->mpWindowImpl->mpClientWindow = mpDockingWindow;
1190 GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
1192 pWin->SetText( GetWindow()->GetText() );
1193 pWin->SetOutputSizePixel( GetWindow()->GetSizePixel() );
1194 pWin->SetPosPixel( maFloatPos );
1195 // pass on DockingData to FloatingWindow
1196 pWin->ShowTitleButton( TitleButton::Docking, mbDockBtn );
1197 pWin->ShowTitleButton( TitleButton::Hide, mbHideBtn );
1198 pWin->SetPin( mbPinned );
1199 if ( mbRollUp )
1200 pWin->RollUp();
1201 else
1202 pWin->RollDown();
1203 pWin->SetRollUpOutputSizePixel( maRollUpOutSize );
1204 pWin->SetMinOutputSizePixel( maMinOutSize );
1205 pWin->SetMaxOutputSizePixel( maMaxOutSize );
1207 mpFloatWin = pWin;
1209 if ( bVisible )
1210 GetWindow()->Show( true, ShowFlags::NoFocusChange | ShowFlags::NoActivate );
1212 ToggleFloatingMode();
1214 else
1216 GetWindow()->Show( false, ShowFlags::NoFocusChange );
1218 // store FloatingData in FloatingWindow
1219 maFloatPos = mpFloatWin->GetPosPixel();
1220 mbDockBtn = mpFloatWin->IsTitleButtonVisible( TitleButton::Docking );
1221 mbHideBtn = mpFloatWin->IsTitleButtonVisible( TitleButton::Hide );
1222 mbPinned = mpFloatWin->IsPinned();
1223 mbRollUp = mpFloatWin->IsRollUp();
1224 maRollUpOutSize = mpFloatWin->GetRollUpOutputSizePixel();
1225 maMinOutSize = mpFloatWin->GetMinOutputSizePixel();
1226 maMaxOutSize = mpFloatWin->GetMaxOutputSizePixel();
1228 vcl::Window* pRealParent = GetWindow()->GetWindow( GetWindowType::Parent ); //mpWindowImpl->mpRealParent;
1229 GetWindow()->mpWindowImpl->mpBorderWindow = nullptr;
1230 if ( mpOldBorderWin )
1232 GetWindow()->SetParent( mpOldBorderWin );
1233 static_cast<ImplBorderWindow*>(mpOldBorderWin.get())->GetBorder(
1234 GetWindow()->mpWindowImpl->mnLeftBorder, GetWindow()->mpWindowImpl->mnTopBorder,
1235 GetWindow()->mpWindowImpl->mnRightBorder, GetWindow()->mpWindowImpl->mnBottomBorder );
1236 mpOldBorderWin->Resize();
1238 GetWindow()->mpWindowImpl->mpBorderWindow = mpOldBorderWin;
1239 GetWindow()->SetParent( pRealParent );
1240 GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
1242 mpFloatWin.disposeAndClear();
1243 GetWindow()->SetPosPixel( maDockPos );
1245 if ( bVisible )
1246 GetWindow()->Show();
1248 ToggleFloatingMode();
1255 void ImplDockingWindowWrapper::SetFloatStyle( WinBits nStyle )
1257 mnFloatBits = nStyle;
1261 void ImplDockingWindowWrapper::setPosSizePixel( long nX, long nY,
1262 long nWidth, long nHeight,
1263 PosSizeFlags nFlags )
1265 if ( mpFloatWin )
1266 mpFloatWin->setPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
1267 else
1268 GetWindow()->setPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
1271 Point ImplDockingWindowWrapper::GetPosPixel() const
1273 if ( mpFloatWin )
1274 return mpFloatWin->GetPosPixel();
1275 else
1276 return mpDockingWindow->GetPosPixel();
1279 Size ImplDockingWindowWrapper::GetSizePixel() const
1281 if ( mpFloatWin )
1282 return mpFloatWin->GetSizePixel();
1283 else
1284 return mpDockingWindow->GetSizePixel();
1287 // old inlines from DockingWindow
1289 void ImplDockingWindowWrapper::SetMinOutputSizePixel( const Size& rSize )
1291 if ( mpFloatWin )
1292 mpFloatWin->SetMinOutputSizePixel( rSize );
1293 maMinOutSize = rSize;
1296 void ImplDockingWindowWrapper::SetMaxOutputSizePixel( const Size& rSize )
1298 if ( mpFloatWin )
1299 mpFloatWin->SetMaxOutputSizePixel( rSize );
1300 maMaxOutSize = rSize;
1303 bool ImplDockingWindowWrapper::IsFloatingMode() const
1305 return (mpFloatWin != nullptr);
1308 void ImplDockingWindowWrapper::SetDragArea( const Rectangle& rRect )
1310 maDragArea = rRect;
1314 void ImplDockingWindowWrapper::Lock()
1316 mbLocked = true;
1317 // only toolbars support locking
1318 ToolBox *pToolBox = dynamic_cast< ToolBox * >( GetWindow() );
1319 if( pToolBox )
1320 pToolBox->Lock( mbLocked );
1323 void ImplDockingWindowWrapper::Unlock()
1325 mbLocked = false;
1326 // only toolbars support locking
1327 ToolBox *pToolBox = dynamic_cast< ToolBox * >( GetWindow() );
1328 if( pToolBox )
1329 pToolBox->Lock( mbLocked );
1333 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */