LibreOffice Module vcl (master) 1
dockmgr.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <tools/time.hxx>
21#include <sal/log.hxx>
22#include <o3tl/deleter.hxx>
23
24#include <brdwin.hxx>
25#include <svdata.hxx>
26#include <window.h>
27
28#include <vcl/event.hxx>
30#include <vcl/dockwin.hxx>
31#include <vcl/toolbox.hxx>
32#include <vcl/svapp.hxx>
33#include <vcl/timer.hxx>
34#include <vcl/settings.hxx>
35
37
38#define DOCKWIN_FLOATSTYLES (WB_SIZEABLE | WB_MOVEABLE | WB_CLOSEABLE | WB_STANDALONE)
39
40namespace {
41
42class ImplDockFloatWin2 : public FloatingWindow
43{
44private:
45 ImplDockingWindowWrapper* mpDockWin;
46 sal_uInt64 mnLastTicks;
47 Timer m_aDockTimer;
48 Timer m_aEndDockTimer;
49 Point maDockPos;
50 tools::Rectangle maDockRect;
51 bool mbInMove;
52 ImplSVEvent * mnLastUserEvent;
53
54 DECL_LINK(DockingHdl, void *, void);
55 DECL_LINK(DockTimerHdl, Timer *, void);
56 DECL_LINK(EndDockTimerHdl, Timer *, void);
57public:
58 ImplDockFloatWin2( vcl::Window* pParent, WinBits nWinBits,
59 ImplDockingWindowWrapper* pDockingWin );
60 virtual ~ImplDockFloatWin2() override;
61 virtual void dispose() override;
62
63 virtual void Move() override;
64 virtual void Resize() override;
65 virtual void TitleButtonClick( TitleButton nButton ) override;
66 virtual void Resizing( Size& rSize ) override;
67 virtual bool Close() override;
68};
69
70}
71
72ImplDockFloatWin2::ImplDockFloatWin2( vcl::Window* pParent, WinBits nWinBits,
73 ImplDockingWindowWrapper* pDockingWin ) :
74 FloatingWindow( pParent, nWinBits ),
75 mpDockWin( pDockingWin ),
76 mnLastTicks( tools::Time::GetSystemTicks() ),
77 m_aDockTimer("vcl::ImplDockFloatWin2 m_aDockTimer"),
78 m_aEndDockTimer( "vcl::ImplDockFloatWin2 m_aEndDockTimer" ),
79 mbInMove( false ),
80 mnLastUserEvent( nullptr )
81{
82 // copy state of DockingWindow
83 if ( pDockingWin )
84 {
85 GetOutDev()->SetSettings( pDockingWin->GetWindow()->GetSettings() );
86 Enable( pDockingWin->GetWindow()->IsEnabled(), false );
87 EnableInput( pDockingWin->GetWindow()->IsInputEnabled(), false );
88 AlwaysEnableInput( pDockingWin->GetWindow()->IsAlwaysEnableInput(), false );
89 EnableAlwaysOnTop( pDockingWin->GetWindow()->IsAlwaysOnTopEnabled() );
90 SetActivateMode( pDockingWin->GetWindow()->GetActivateMode() );
91 }
92
93 SetBackground( GetSettings().GetStyleSettings().GetFaceColor() );
94
95 m_aDockTimer.SetInvokeHandler( LINK( this, ImplDockFloatWin2, DockTimerHdl ) );
96 m_aDockTimer.SetPriority( TaskPriority::HIGH_IDLE );
97 m_aDockTimer.SetTimeout( 50 );
98
99 m_aEndDockTimer.SetInvokeHandler( LINK( this, ImplDockFloatWin2, EndDockTimerHdl ) );
100 m_aEndDockTimer.SetPriority( TaskPriority::HIGH_IDLE );
101 m_aEndDockTimer.SetTimeout( 50 );
102}
103
104ImplDockFloatWin2::~ImplDockFloatWin2()
105{
106 disposeOnce();
107}
108
109void ImplDockFloatWin2::dispose()
110{
111 if( mnLastUserEvent )
112 Application::RemoveUserEvent( mnLastUserEvent );
114}
115
116IMPL_LINK_NOARG(ImplDockFloatWin2, DockTimerHdl, Timer *, void)
117{
118 SAL_WARN_IF( !mpDockWin->IsFloatingMode(), "vcl", "docktimer called but not floating" );
119
120 PointerState aState = GetPointerState();
121
122 if( aState.mnState & KEY_MOD1 )
123 {
124 // i43499 CTRL disables docking now
125 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
126 if( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) )
127 m_aDockTimer.Start();
128 }
129 else if( ! ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) )
130 {
131 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
132 mpDockWin->EndDocking( maDockRect, false );
133 }
134 else
135 {
136 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect, ShowTrackFlags::Big | ShowTrackFlags::TrackWindow );
137 m_aDockTimer.Start();
138 }
139}
140
141IMPL_LINK_NOARG(ImplDockFloatWin2, EndDockTimerHdl, Timer *, void)
142{
143 SAL_WARN_IF( !mpDockWin->IsFloatingMode(), "vcl", "enddocktimer called but not floating" );
144
145 PointerState aState = GetPointerState();
146 if( ! ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) )
147 {
148 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
149 mpDockWin->EndDocking( maDockRect, true );
150 }
151 else
152 m_aEndDockTimer.Start();
153}
154
155IMPL_LINK_NOARG(ImplDockFloatWin2, DockingHdl, void*, void)
156{
157 // called during move of a floating window
158 mnLastUserEvent = nullptr;
159
160 vcl::Window *pDockingArea = mpDockWin->GetWindow()->GetParent();
161 PointerState aState = pDockingArea->GetPointerState();
162
163 bool bRealMove = true;
164 if( GetStyle() & WB_OWNERDRAWDECORATION )
165 {
166 // for windows with ownerdraw decoration
167 // we allow docking only when the window was moved
168 // by dragging its caption
169 // and ignore move request due to resizing
170 vcl::Window *pBorder = GetWindow( GetWindowType::Border );
171 if( pBorder != this )
172 {
173 tools::Rectangle aBorderRect( Point(), pBorder->GetSizePixel() );
174 sal_Int32 nLeft, nTop, nRight, nBottom;
175 GetBorder( nLeft, nTop, nRight, nBottom );
176 // limit borderrect to the caption part only and without the resizing borders
177 aBorderRect.SetBottom( aBorderRect.Top() + nTop );
178 aBorderRect.AdjustLeft(nLeft );
179 aBorderRect.AdjustRight( -nRight );
180
181 PointerState aBorderState = pBorder->GetPointerState();
182 bRealMove = aBorderRect.Contains( aBorderState.maPos );
183 }
184 }
185
186 if( mpDockWin->GetWindow()->IsVisible() &&
187 (tools::Time::GetSystemTicks() - mnLastTicks > 500) &&
188 ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) &&
189 !(aState.mnState & KEY_MOD1) && // i43499 CTRL disables docking now
190 bRealMove )
191 {
192 maDockPos = pDockingArea->OutputToScreenPixel( pDockingArea->AbsoluteScreenToOutputPixel( OutputToAbsoluteScreenPixel( Point() ) ) );
193 maDockRect = tools::Rectangle( maDockPos, mpDockWin->GetSizePixel() );
194
195 // mouse pos in screen pixels
196 Point aMousePos = pDockingArea->OutputToScreenPixel( aState.maPos );
197
198 if( ! mpDockWin->IsDocking() )
199 mpDockWin->StartDocking( aMousePos, maDockRect );
200
201 bool bFloatMode = mpDockWin->Docking( aMousePos, maDockRect );
202
203 if( ! bFloatMode )
204 {
205 // indicates that the window could be docked at maDockRect
206 maDockRect.SetPos( mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->ScreenToOutputPixel(
207 maDockRect.TopLeft() ) );
208 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect, ShowTrackFlags::Big | ShowTrackFlags::TrackWindow );
209 m_aEndDockTimer.Stop();
210 m_aDockTimer.Invoke();
211 }
212 else
213 {
214 mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
215 m_aDockTimer.Stop();
216 m_aEndDockTimer.Invoke();
217 }
218 }
219 mbInMove = false;
220}
221
222void ImplDockFloatWin2::Move()
223{
224 if( mbInMove )
225 return;
226
227 mbInMove = true;
229 mpDockWin->GetWindow()->Move();
230
231 /*
232 * note: the window should only dock if KEY_MOD1 is pressed
233 * and the user releases all mouse buttons. The real problem here
234 * is that we don't get mouse events (at least not on X)
235 * if the mouse is on the decoration. So we have to start an
236 * awkward timer based process that polls the modifier/buttons
237 * to see whether they are in the right condition shortly after the
238 * last Move message.
239 */
240 if( ! mnLastUserEvent )
241 mnLastUserEvent = Application::PostUserEvent( LINK( this, ImplDockFloatWin2, DockingHdl ), nullptr, true );
242}
243
244void ImplDockFloatWin2::Resize()
245{
246 // forwarding of resize only required if we have no borderwindow ( GetWindow() then returns 'this' )
247 if( GetWindow( GetWindowType::Border ) == this )
248 {
250 Size aSize( GetSizePixel() );
251 mpDockWin->GetWindow()->ImplPosSizeWindow( 0, 0, aSize.Width(), aSize.Height(), PosSizeFlags::PosSize ); // TODO: is this needed ???
252 }
253}
254
255void ImplDockFloatWin2::TitleButtonClick( TitleButton nButton )
256{
258 mpDockWin->TitleButtonClick( nButton );
259}
260
261void ImplDockFloatWin2::Resizing( Size& rSize )
262{
264 mpDockWin->Resizing( rSize );
265}
266
268{
269 return true;
270}
271
273{
274}
275
277{
278}
279
281{
282 for( const auto& xWrapper : mvDockingWindows )
283 {
284 if (xWrapper && xWrapper->mpDockingWindow == pWindow)
285 return xWrapper.get();
286 }
287 return nullptr;
288}
289
291{
293
294 /*
295 if( pWindow->HasDockingHandler() )
296 return true;
297 */
298 return (pWrapper != nullptr);
299}
300
302{
304 if( pWrapper )
305 return pWrapper->IsFloatingMode();
306 else
307 return false;
308}
309
311{
313 return pWrapper && pWrapper->IsLocked();
314}
315
316void DockingManager::Lock( const vcl::Window *pWindow )
317{
319 if( pWrapper )
320 pWrapper->Lock();
321}
322
324{
326 if( pWrapper )
327 pWrapper->Unlock();
328}
329
330void DockingManager::SetFloatingMode( const vcl::Window *pWindow, bool bFloating )
331{
333 if( pWrapper )
334 pWrapper->SetFloatingMode( bFloating );
335}
336
338{
340 if( pWrapper )
341 pWrapper->StartPopupMode( rRect, nFlags );
342}
343
344void DockingManager::StartPopupMode( ToolBox *pParentToolBox, const vcl::Window *pWindow, FloatWinPopupFlags nFlags )
345{
347 if( pWrapper )
348 pWrapper->StartPopupMode( pParentToolBox, nFlags );
349}
350
351void DockingManager::StartPopupMode( ToolBox *pParentToolBox, const vcl::Window *pWindow )
352{
353 StartPopupMode( pParentToolBox, pWindow, FloatWinPopupFlags::AllowTearOff |
356}
357
359{
361 return pWrapper && pWrapper->IsInPopupMode();
362}
363
365{
367 if( pWrapper && pWrapper->GetFloatingWindow() && static_cast<FloatingWindow*>(pWrapper->GetFloatingWindow())->IsInPopupMode() )
368 static_cast<FloatingWindow*>(pWrapper->GetFloatingWindow())->EndPopupMode();
369}
370
372{
374 if (pWrapper)
375 return pWrapper->GetFloatingWindow();
376 return nullptr;
377}
378
380{
382 if( pWrapper )
383 pWrapper->SetPopupModeEndHdl(rLink);
384}
385
387{
389 if( pWrapper )
390 return;
391 mvDockingWindows.emplace_back( new ImplDockingWindowWrapper( pWindow ) );
392}
393
395{
396 for( auto it = mvDockingWindows.begin(); it != mvDockingWindows.end(); ++it )
397 {
398 const auto& xWrapper = *it;
399 if (xWrapper && xWrapper->mpDockingWindow == pWindow)
400 {
401 // deleting wrappers calls set of actions which may want to use
402 // wrapper we want to delete - avoid crash using temporary owner
403 // while erasing
404 auto pTemporaryOwner = std::move(*it);
405 mvDockingWindows.erase( it );
406 break;
407 }
408 }
409}
410
412 tools::Long nWidth, tools::Long nHeight,
413 PosSizeFlags nFlags )
414{
416 if( pWrapper )
417 pWrapper->setPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
418}
419
421{
422 tools::Rectangle aRect;
424 if( pWrapper )
425 aRect = tools::Rectangle( pWrapper->GetPosPixel(), pWrapper->GetSizePixel() );
426
427 return aRect;
428}
429
431{
432private:
434
435public:
436 ImplPopupFloatWin( vcl::Window* pParent, bool bToolBox );
437 virtual ~ImplPopupFloatWin() override;
438 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
439};
440
443 mbToolBox( bToolBox )
444{
445 if ( bToolBox )
446 {
447 // indicate window type, required for accessibility
448 // which should not see this window as a toplevel window
449 mpWindowImpl->mbToolbarFloatingWindow = true;
450 }
451}
452
454{
455 disposeOnce();
456}
457
458css::uno::Reference< css::accessibility::XAccessible > ImplPopupFloatWin::CreateAccessible()
459{
460 if ( !mbToolBox )
462
463 // switch off direct accessibility support for this window
464
465 // this is to avoid appearance of this window as standalone window in the accessibility hierarchy
466 // as this window is only used as a helper for subtoolbars that are not teared-off, the parent toolbar
467 // has to provide accessibility support (as implemented in the toolkit)
468 // so the contained toolbar should appear as child of the corresponding toolbar item of the parent toolbar
469 return css::uno::Reference< css::accessibility::XAccessible >();
470}
471
473 : mpDockingWindow(const_cast<vcl::Window*>(pWindow))
474 , mpFloatWin(nullptr)
475 , mpOldBorderWin(nullptr)
476 , mpParent(pWindow->GetParent())
477 , maMaxOutSize( SHRT_MAX, SHRT_MAX )
478 , mnTrackX(0)
479 , mnTrackY(0)
480 , mnTrackWidth(0)
481 , mnTrackHeight(0)
482 , mnDockLeft(0)
483 , mnDockTop(0)
484 , mnDockRight(0)
485 , mnDockBottom(0)
486 , mnFloatBits(WB_BORDER | WB_CLOSEABLE | WB_SIZEABLE | (pWindow->GetStyle() & DOCKWIN_FLOATSTYLES))
487 , mbDockCanceled(false)
488 , mbDocking(false)
489 , mbLastFloatMode(false)
490 , mbDockBtn(false)
491 , mbHideBtn(false)
492 // must be enabled in Window::Notify to prevent permanent docking during mouse move
493 , mbStartDockingEnabled(false)
494 , mbLocked(false)
495{
496 assert(mpDockingWindow);
497 DockingWindow *pDockWin = dynamic_cast< DockingWindow* > ( mpDockingWindow.get() );
498 if( pDockWin )
499 mnFloatBits = pDockWin->GetFloatStyle();
500}
501
503{
504 if ( IsFloatingMode() )
505 {
507 SetFloatingMode(false);
508 }
509}
510
512{
514 return;
515
516 maMouseOff = rPos;
517 mbDocking = true;
519
520 // calculate FloatingBorder
522 if ( mpFloatWin )
523 pWin = mpFloatWin;
524 else
527 if ( !mpFloatWin )
528 pWin.disposeAndClear();
529
531 Size aSize = GetWindow()->GetOutputSizePixel();
532 mnTrackX = aPos.X();
533 mnTrackY = aPos.Y();
534 mnTrackWidth = aSize.Width();
535 mnTrackHeight = aSize.Height();
536
537 if ( mbLastFloatMode )
538 {
545 }
546
547 vcl::Window *pDockingArea = GetWindow()->GetParent();
548 vcl::Window::PointerState aState = pDockingArea->GetPointerState();
549
550 // mouse pos in screen pixels
551 Point aMousePos = pDockingArea->OutputToScreenPixel( aState.maPos );
552 Point aDockPos = pDockingArea->AbsoluteScreenToOutputPixel( GetWindow()->OutputToAbsoluteScreenPixel( GetWindow()->GetPosPixel() ) );
553 tools::Rectangle aDockRect( aDockPos, GetWindow()->GetSizePixel() );
554 StartDocking( aMousePos, aDockRect );
555
558
560}
561
563{
564 // used during docking of a currently docked window
565 if ( !mbDocking )
566 return;
567
568 if ( rTEvt.IsTrackingEnded() )
569 {
570 mbDocking = false;
572 if ( rTEvt.IsTrackingCanceled() )
573 {
574 mbDockCanceled = true;
576 mbDockCanceled = false;
577 }
578 else
580 }
581 // Docking only upon non-synthetic MouseEvents
582 else if ( !rTEvt.GetMouseEvent().IsSynthetic() || rTEvt.GetMouseEvent().IsModifierChanged() )
583 {
584 Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
585 Point aFrameMousePos = GetWindow()->OutputToScreenPixel( aMousePos );
587 if ( aFrameMousePos.X() < 0 )
588 aFrameMousePos.setX( 0 );
589 if ( aFrameMousePos.Y() < 0 )
590 aFrameMousePos.setY( 0 );
591 if ( aFrameMousePos.X() > aFrameSize.Width()-1 )
592 aFrameMousePos.setX( aFrameSize.Width()-1 );
593 if ( aFrameMousePos.Y() > aFrameSize.Height()-1 )
594 aFrameMousePos.setY( aFrameSize.Height()-1 );
595 aMousePos = GetWindow()->ScreenToOutputPixel( aFrameMousePos );
596 aMousePos.AdjustX( -(maMouseOff.X()) );
597 aMousePos.AdjustY( -(maMouseOff.Y()) );
598 Point aPos = GetWindow()->OutputToScreenPixel( aMousePos );
599 tools::Rectangle aTrackRect( aPos, Size( mnTrackWidth, mnTrackHeight ) );
600 tools::Rectangle aCompRect = aTrackRect;
601 aPos.AdjustX(maMouseOff.X() );
602 aPos.AdjustY(maMouseOff.Y() );
603
604 bool bFloatMode = Docking( aPos, aTrackRect );
605
606 if ( mbLastFloatMode != bFloatMode )
607 {
608 if ( bFloatMode )
609 {
610 aTrackRect.AdjustLeft( -mnDockLeft );
611 aTrackRect.AdjustTop( -mnDockTop );
612 aTrackRect.AdjustRight(mnDockRight );
613 aTrackRect.AdjustBottom(mnDockBottom );
614 }
615 else
616 {
617 if ( aCompRect == aTrackRect )
618 {
619 aTrackRect.AdjustLeft(mnDockLeft );
620 aTrackRect.AdjustTop(mnDockTop );
621 aTrackRect.AdjustRight( -mnDockRight );
622 aTrackRect.AdjustBottom( -mnDockBottom );
623 }
624 }
625 mbLastFloatMode = bFloatMode;
626 }
627
628 ShowTrackFlags nTrackStyle;
629 if ( bFloatMode )
630 nTrackStyle = ShowTrackFlags::Object;
631 else
632 nTrackStyle = ShowTrackFlags::Big;
633 tools::Rectangle aShowTrackRect = aTrackRect;
634 aShowTrackRect.SetPos( GetWindow()->ScreenToOutputPixel( aShowTrackRect.TopLeft() ) );
635
636 GetWindow()->ShowTracking( aShowTrackRect, nTrackStyle );
637
638 // calculate mouse offset again, as the rectangle was changed
639 maMouseOff.setX( aPos.X() - aTrackRect.Left() );
640 maMouseOff.setY( aPos.Y() - aTrackRect.Top() );
641
642 mnTrackX = aTrackRect.Left();
643 mnTrackY = aTrackRect.Top();
644 mnTrackWidth = aTrackRect.GetWidth();
645 mnTrackHeight = aTrackRect.GetHeight();
646 }
647}
648
650{
651 DockingData data( rPoint, rRect, IsFloatingMode() );
652
654 mbDocking = true;
655}
656
658{
659 DockingData data( rPoint, rRect, IsFloatingMode() );
660
662 rRect = data.maTrackRect;
663 return data.mbFloating;
664}
665
666void ImplDockingWindowWrapper::EndDocking( const tools::Rectangle& rRect, bool bFloatMode )
667{
668 tools::Rectangle aRect( rRect );
669
670 bool bOrigDockCanceled = mbDockCanceled;
671 if (bFloatMode && !StyleSettings::GetDockingFloatsSupported())
672 mbDockCanceled = true;
673
674 if ( !IsDockingCanceled() )
675 {
676 bool bShow = false;
677 if ( bFloatMode != IsFloatingMode() )
678 {
680 SetFloatingMode( bFloatMode );
681 bShow = true;
682 if ( bFloatMode )
683 {
684 // #i44800# always use outputsize - as in all other places
686 mpFloatWin->SetPosPixel( aRect.TopLeft() );
687 }
688 }
689 if ( !bFloatMode )
690 {
691 Point aPos = aRect.TopLeft();
692 aPos = GetWindow()->GetParent()->ScreenToOutputPixel( aPos );
693 GetWindow()->SetPosSizePixel( aPos, aRect.GetSize() );
694 }
695
696 if ( bShow )
698 }
699
702
703 mbDocking = false;
704
705 // must be enabled in Window::Notify to prevent permanent docking during mouse move
706 mbStartDockingEnabled = false;
707
708 mbDockCanceled = bOrigDockCanceled;
709}
710
712{
713 bool bFloating = true;
715 return bFloating;
716}
717
719{
720 // notify dockingwindow/toolbox
721 // note: this must be done *before* notifying the
722 // listeners to have the toolbox in the proper state
723 if( GetWindow()->IsDockingWindow() )
724 static_cast<DockingWindow*>(GetWindow())->ToggleFloatingMode();
725
726 // now notify listeners
728
729 // must be enabled in Window::Notify to prevent permanent docking during mouse move
730 mbStartDockingEnabled = false;
731}
732
734{
735 if( nType == TitleButton::Menu )
736 {
737 ToolBox *pToolBox = dynamic_cast< ToolBox* >( GetWindow() );
738 if( pToolBox )
739 {
740 pToolBox->ExecuteCustomMenu();
741 }
742 }
744 {
746 }
747}
748
750{
751 // TODO: add virtual Resizing() to class Window, so we can get rid of class DockingWindow
752 DockingWindow *pDockingWindow = dynamic_cast< DockingWindow* >( GetWindow() );
753 if( pDockingWindow )
754 pDockingWindow->Resizing( rSize );
755}
756
758{
759 if ( mpFloatWin )
761}
762
764{
765 VclPtr<vcl::Window> xWindow = GetWindow();
766 xWindow->Show( false, ShowFlags::NoFocusChange );
767
768 // prepare reparenting
769 vcl::Window* pRealParent = xWindow->GetWindow( GetWindowType::Parent );
771 if( mpOldBorderWin.get() == xWindow )
772 mpOldBorderWin = nullptr; // no border window found
773
774 // the new parent for popup mode
776 pWin->SetPopupModeEndHdl( LINK( this, ImplDockingWindowWrapper, PopupModeEnd ) );
777
778 // At least for DockingWindow, GetText() has a side effect of setting deferred
779 // properties. This must be done before setting the border window (see below),
780 // so that the border width will end up in mpWindowImpl->mnBorderWidth, not in
781 // the border window (See DockingWindow::setPosSizeOnContainee() and
782 // DockingWindow::GetOptimalSize()).
783 pWin->SetText( xWindow->GetText() );
784 pWin->SetOutputSizePixel( xWindow->GetSizePixel() );
785
786 xWindow->mpWindowImpl->mpBorderWindow = nullptr;
787 xWindow->mpWindowImpl->mnLeftBorder = 0;
788 xWindow->mpWindowImpl->mnTopBorder = 0;
789 xWindow->mpWindowImpl->mnRightBorder = 0;
790 xWindow->mpWindowImpl->mnBottomBorder = 0;
791
792 // reparent borderwindow and window
793 if ( mpOldBorderWin )
794 mpOldBorderWin->SetParent( pWin );
795 xWindow->SetParent( pWin );
796
797 // correct border window pointers
798 xWindow->mpWindowImpl->mpBorderWindow = pWin;
799 pWin->mpWindowImpl->mpClientWindow = xWindow;
800 xWindow->mpWindowImpl->mpRealParent = pRealParent;
801
802 // set mpFloatWin not until all window positioning is done !!!
803 // (SetPosPixel etc. check for valid mpFloatWin pointer)
804 mpFloatWin = pWin;
805}
806
808{
809 // do nothing if window is floating
810 if( IsFloatingMode() )
811 return;
812
814
815 // don't allow tearoff, if globally disabled
818
819 // if the subtoolbar was opened via keyboard make sure that key events
820 // will go into subtoolbar
821 if( pParentToolBox->IsKeyEvent() )
823
825
826 if( pParentToolBox->IsKeyEvent() )
827 {
828 // send HOME key to subtoolbar in order to select first item
831 }
832}
833
835{
836 // do nothing if window is floating
837 if( IsFloatingMode() )
838 return;
839
842}
843
845{
846 VclPtr<vcl::Window> xWindow = GetWindow();
847 xWindow->Show( false, ShowFlags::NoFocusChange );
848
849 // set parameter for handler before destroying floating window
850 EndPopupModeData aData( mpFloatWin->GetWindow( GetWindowType::Border )->GetPosPixel(), mpFloatWin->IsPopupModeTearOff() );
851
852 // before deleting change parent back, so we can delete the floating window alone
853 vcl::Window* pRealParent = xWindow->GetWindow( GetWindowType::Parent );
854 xWindow->mpWindowImpl->mpBorderWindow = nullptr;
855 if ( mpOldBorderWin )
856 {
857 xWindow->SetParent( mpOldBorderWin );
858 static_cast<ImplBorderWindow*>(mpOldBorderWin.get())->GetBorder(
859 xWindow->mpWindowImpl->mnLeftBorder, xWindow->mpWindowImpl->mnTopBorder,
860 xWindow->mpWindowImpl->mnRightBorder, xWindow->mpWindowImpl->mnBottomBorder );
861 mpOldBorderWin->Resize();
862 }
863 xWindow->mpWindowImpl->mpBorderWindow = mpOldBorderWin;
864 xWindow->SetParent( pRealParent );
865 xWindow->mpWindowImpl->mpRealParent = pRealParent;
866
867 // take ownership to local variable to protect against maPopupModeEndHdl destroying this object
868 auto xFloatWin = std::move(mpFloatWin);
869 maPopupModeEndHdl.Call(xFloatWin);
870 xFloatWin.disposeAndClear();
871
872 // call handler - which will destroy the window and thus the wrapper as well !
874}
875
877{
878 if( GetFloatingWindow() )
879 return static_cast<FloatingWindow*>(GetFloatingWindow())->IsInPopupMode();
880 else
881 return false;
882}
883
885{
886 // do nothing if window is docked and locked
887 if( !IsFloatingMode() && IsLocked() )
888 return;
889
890 if ( IsFloatingMode() == bFloatMode )
891 return;
892
894 return;
895
896 bool bVisible = GetWindow()->IsVisible();
897
898 if ( bFloatMode )
899 {
901
903
907 mpOldBorderWin = nullptr; // no border window found
908
910 mpParent,
914 : mnFloatBits,
915 this );
916
917 // At least for DockingWindow, GetText() has a side effect of setting deferred
918 // properties. This must be done before setting the border window (see below),
919 // so that the border width will end up in mpWindowImpl->mnBorderWidth, not in
920 // the border window (See DockingWindow::setPosSizeOnContainee() and
921 // DockingWindow::GetOptimalSize()).
922 pWin->SetText( GetWindow()->GetText() );
923
924 GetWindow()->mpWindowImpl->mpBorderWindow = nullptr;
925 GetWindow()->mpWindowImpl->mnLeftBorder = 0;
926 GetWindow()->mpWindowImpl->mnTopBorder = 0;
927 GetWindow()->mpWindowImpl->mnRightBorder = 0;
928 GetWindow()->mpWindowImpl->mnBottomBorder = 0;
929
930 // if the parent gets destroyed, we also have to reset the parent of the BorderWindow
931 if ( mpOldBorderWin )
932 mpOldBorderWin->SetParent( pWin );
933 GetWindow()->SetParent( pWin );
934 pWin->SetPosPixel( Point() );
935
936 GetWindow()->mpWindowImpl->mpBorderWindow = pWin;
937 pWin->mpWindowImpl->mpClientWindow = mpDockingWindow;
938 GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
939
940 pWin->SetOutputSizePixel( GetWindow()->GetSizePixel() );
941 pWin->SetPosPixel( maFloatPos );
942 // pass on DockingData to FloatingWindow
943 pWin->ShowTitleButton( TitleButton::Docking, mbDockBtn );
944 pWin->ShowTitleButton( TitleButton::Hide, mbHideBtn );
945 pWin->SetMinOutputSizePixel( maMinOutSize );
946 pWin->SetMaxOutputSizePixel( maMaxOutSize );
947
948 mpFloatWin = pWin;
949
950 if ( bVisible )
952
954 }
955 else
956 {
958
959 // store FloatingData in FloatingWindow
965
966 vcl::Window* pRealParent = GetWindow()->GetWindow( GetWindowType::Parent ); //mpWindowImpl->mpRealParent;
967 GetWindow()->mpWindowImpl->mpBorderWindow = nullptr;
968 if ( mpOldBorderWin )
969 {
971 static_cast<ImplBorderWindow*>(mpOldBorderWin.get())->GetBorder(
972 GetWindow()->mpWindowImpl->mnLeftBorder, GetWindow()->mpWindowImpl->mnTopBorder,
973 GetWindow()->mpWindowImpl->mnRightBorder, GetWindow()->mpWindowImpl->mnBottomBorder );
975 }
976 GetWindow()->mpWindowImpl->mpBorderWindow = mpOldBorderWin;
977 GetWindow()->SetParent( pRealParent );
978 GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
979
982
983 if ( bVisible )
984 GetWindow()->Show();
985
987
988 }
989}
990
992{
993 mnFloatBits = nStyle;
994}
995
996
998 tools::Long nWidth, tools::Long nHeight,
999 PosSizeFlags nFlags )
1000{
1001 if ( mpFloatWin )
1002 mpFloatWin->setPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
1003 else
1004 GetWindow()->setPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
1005}
1006
1008{
1009 if ( mpFloatWin )
1010 return mpFloatWin->GetPosPixel();
1011 else
1012 return mpDockingWindow->GetPosPixel();
1013}
1014
1016{
1017 if ( mpFloatWin )
1018 return mpFloatWin->GetSizePixel();
1019 else
1020 return mpDockingWindow->GetSizePixel();
1021}
1022
1023// old inlines from DockingWindow
1024
1026{
1027 if ( mpFloatWin )
1029 maMinOutSize = rSize;
1030}
1031
1033{
1034 if ( mpFloatWin )
1036 maMaxOutSize = rSize;
1037}
1038
1040{
1041 return (mpFloatWin != nullptr);
1042}
1043
1045{
1046 maDragArea = rRect;
1047}
1048
1049
1051{
1052 mbLocked = true;
1053 // only toolbars support locking
1054 ToolBox *pToolBox = dynamic_cast< ToolBox * >( GetWindow() );
1055 if( pToolBox )
1056 pToolBox->Lock( mbLocked );
1057}
1058
1060{
1061 mbLocked = false;
1062 // only toolbars support locking
1063 ToolBox *pToolBox = dynamic_cast< ToolBox * >( GetWindow() );
1064 if( pToolBox )
1065 pToolBox->Lock( mbLocked );
1066}
1067
1069{
1070 return mpFloatWin;
1071}
1072
1073/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AnyEventRef aEvent
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
Post a user event to the default window.
Definition: svapp.cxx:999
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
Remove user event based on event ID.
Definition: svapp.cxx:1023
void RemoveWindow(const vcl::Window *pWin)
Definition: dockmgr.cxx:394
void Lock(const vcl::Window *pWin)
Definition: dockmgr.cxx:316
bool IsInPopupMode(const vcl::Window *pWin)
Definition: dockmgr.cxx:358
bool IsDockable(const vcl::Window *pWin)
Definition: dockmgr.cxx:290
std::vector< std::unique_ptr< ImplDockingWindowWrapper, o3tl::default_delete< ImplDockingWindowWrapper > > > mvDockingWindows
Definition: dockwin.hxx:69
bool IsFloating(const vcl::Window *pWin)
Definition: dockmgr.cxx:301
void Unlock(const vcl::Window *pWin)
Definition: dockmgr.cxx:323
void SetFloatingMode(const vcl::Window *pWin, bool bFloating)
Definition: dockmgr.cxx:330
void EndPopupMode(const vcl::Window *pWin)
Definition: dockmgr.cxx:364
void SetPosSizePixel(vcl::Window const *pWin, tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags)
Definition: dockmgr.cxx:411
void AddWindow(const vcl::Window *pWin)
Definition: dockmgr.cxx:386
SystemWindow * GetFloatingWindow(const vcl::Window *pWin)
Definition: dockmgr.cxx:371
ImplDockingWindowWrapper * GetDockingWindowWrapper(const vcl::Window *pWin)
Definition: dockmgr.cxx:280
tools::Rectangle GetPosSizePixel(const vcl::Window *pWin)
Definition: dockmgr.cxx:420
bool IsLocked(const vcl::Window *pWin)
Definition: dockmgr.cxx:310
void StartPopupMode(const vcl::Window *pWin, const tools::Rectangle &rRect, FloatWinPopupFlags nPopupModeFlags)
Definition: dockmgr.cxx:337
void SetPopupModeEndHdl(const vcl::Window *pWindow, const Link< FloatingWindow *, void > &rLink)
Definition: dockmgr.cxx:379
virtual void Resizing(Size &rSize)
Definition: dockwin.cxx:643
WinBits GetFloatStyle() const
Definition: dockwin.cxx:811
void StartPopupMode(const tools::Rectangle &rRect, FloatWinPopupFlags nFlags)
Definition: floatwin.cxx:776
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: floatwin.cxx:204
bool IsInPopupMode() const
Definition: floatwin.hxx:130
virtual void Resize() override
Definition: brdwin.cxx:1678
ImplDockingWindowWrapper.
void SetDragArea(const tools::Rectangle &rRect)
Definition: dockmgr.cxx:1044
void StartPopupMode(const tools::Rectangle &rRect, FloatWinPopupFlags nPopupModeFlags)
Definition: dockmgr.cxx:834
void SetFloatStyle(WinBits nWinStyle)
Definition: dockmgr.cxx:991
bool Docking(const Point &rPos, tools::Rectangle &rRect)
Definition: dockmgr.cxx:657
void ShowMenuTitleButton(bool bVisible)
Definition: dockmgr.cxx:757
bool IsInPopupMode() const
Definition: dockmgr.cxx:876
bool IsFloatingMode() const
Definition: dockmgr.cxx:1039
Size GetSizePixel() const
Definition: dockmgr.cxx:1015
void SetMinOutputSizePixel(const Size &rSize)
Definition: dockmgr.cxx:1025
SystemWindow * GetFloatingWindow() const
Definition: dockmgr.cxx:1068
bool PrepareToggleFloatingMode()
Definition: dockmgr.cxx:711
void SetPopupModeEndHdl(const Link< FloatingWindow *, void > &rLink)
VclPtr< vcl::Window > mpDockingWindow
VclPtr< vcl::Window > mpParent
void TitleButtonClick(TitleButton nButton)
Definition: dockmgr.cxx:733
ImplDockingWindowWrapper(const vcl::Window *pWindow)
Definition: dockmgr.cxx:472
void Resizing(Size &rSize)
Definition: dockmgr.cxx:749
void EndDocking(const tools::Rectangle &rRect, bool bFloatMode)
Definition: dockmgr.cxx:666
void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags)
Definition: dockmgr.cxx:997
void StartDocking(const Point &rPos, tools::Rectangle const &rRect)
Definition: dockmgr.cxx:649
VclPtr< FloatingWindow > mpFloatWin
void SetFloatingMode(bool bFloatMode)
Definition: dockmgr.cxx:884
Point GetPosPixel() const
Definition: dockmgr.cxx:1007
VclPtr< vcl::Window > mpOldBorderWin
void SetMaxOutputSizePixel(const Size &rSize)
Definition: dockmgr.cxx:1032
void ImplStartDocking(const Point &rPos)
Definition: dockmgr.cxx:511
void Tracking(const TrackingEvent &rTEvt)
Definition: dockmgr.cxx:562
virtual ~ImplPopupFloatWin() override
Definition: dockmgr.cxx:453
ImplPopupFloatWin(vcl::Window *pParent, bool bToolBox)
Definition: dockmgr.cxx:441
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Definition: dockmgr.cxx:458
bool IsSynthetic() const
Definition: event.hxx:142
const Point & GetPosPixel() const
Definition: event.hxx:123
bool IsModifierChanged() const
Definition: event.hxx:144
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
static bool GetDockingFloatsSupported()
const Size & GetMinOutputSizePixel() const
Definition: syswin.hxx:175
void SetMinOutputSizePixel(const Size &rSize)
Definition: syswin.cxx:365
void ShowTitleButton(TitleButton nButton, bool bVisible)
Definition: syswin.cxx:328
virtual void Resizing(Size &rSize)
Definition: syswin.cxx:291
bool IsTitleButtonVisible(TitleButton nButton) const
Definition: syswin.cxx:357
virtual void TitleButtonClick(TitleButton nButton)
Definition: syswin.cxx:287
const Size & GetMaxOutputSizePixel() const
Definition: syswin.cxx:397
void SetMaxOutputSizePixel(const Size &rSize)
Definition: syswin.cxx:378
virtual bool Close()
Definition: syswin.cxx:262
virtual void Resize() override
Definition: syswin.cxx:993
Definition: timer.hxx:27
A toolbar: contains all those icons, typically below the menu bar.
Definition: toolbox.hxx:74
void Lock(bool bLock)
Definition: toolbox2.cxx:1644
void ExecuteCustomMenu(const tools::Rectangle &rRect=tools::Rectangle())
Definition: toolbox2.cxx:1563
bool IsKeyEvent() const
Definition: toolbox.hxx:477
bool IsTrackingEnded() const
Definition: event.hxx:261
bool IsTrackingCanceled() const
Definition: event.hxx:263
const MouseEvent & GetMouseEvent() const
Definition: event.hxx:257
A construction helper for a temporary VclPtr.
Definition: vclptr.hxx:277
void disposeAndClear()
Definition: vclptr.hxx:200
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
static VclPtr< reference_type > Create(Arg &&... arg)
A construction helper for VclPtr.
Definition: vclptr.hxx:127
constexpr tools::Long GetWidth() const
bool Contains(const Point &rPOINT) const
constexpr tools::Long Top() const
constexpr Point TopLeft() const
void SetPos(const Point &rPoint)
constexpr Size GetSize() const
tools::Long AdjustTop(tools::Long nVertMoveDelta)
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
constexpr void SetBottom(tools::Long v)
constexpr tools::Long GetHeight() const
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
constexpr tools::Long Left() const
static sal_uInt64 GetSystemTicks()
Point AbsoluteScreenToOutputPixel(const Point &rPos) const
Definition: window.cxx:2865
Point OutputToScreenPixel(const Point &rPos) const
Definition: window.cxx:2806
SAL_DLLPRIVATE void ImplUpdateAll()
Definition: paint.cxx:988
void StartTracking(StartTrackingFlags nFlags=StartTrackingFlags::NONE)
Definition: window2.cxx:252
vcl::Window * GetParent() const
Definition: window2.cxx:1123
ActivateModeFlags GetActivateMode() const
Definition: window2.cxx:1163
bool IsInputEnabled() const
Definition: window2.cxx:1153
void HideTracking()
Definition: window2.cxx:151
WindowType GetType() const
Definition: window2.cxx:1000
virtual void Resize()
Definition: window.cxx:1835
void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const
Definition: window.cxx:2424
vcl::Window * GetWindow(GetWindowType nType) const
Definition: stacking.cxx:1036
PointerState GetPointerState()
Definition: mouse.cxx:577
virtual Point GetPosPixel() const
Definition: window.cxx:2794
void SetParent(vcl::Window *pNewParent)
Definition: stacking.cxx:832
virtual void SetOutputSizePixel(const Size &rNewSize)
Definition: window2.cxx:1300
const AllSettings & GetSettings() const
Definition: window3.cxx:129
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2187
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1805
void ShowTracking(const tools::Rectangle &rRect, ShowTrackFlags nFlags=ShowTrackFlags::Small)
Definition: window2.cxx:128
virtual void Move()
Definition: window.cxx:1833
virtual void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
Definition: window.cxx:2666
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible()
bool IsAlwaysOnTopEnabled() const
Definition: window2.cxx:1169
void SetSettings(const AllSettings &rSettings)
Definition: window3.cxx:208
std::unique_ptr< WindowImpl > mpWindowImpl
Definition: window.hxx:484
virtual Size GetSizePixel() const
Definition: window.cxx:2402
Size GetOutputSizePixel() const
Definition: window3.cxx:89
bool IsVisible() const
Definition: window2.cxx:1128
virtual void SetPosPixel(const Point &rNewPos)
Definition: window2.cxx:1283
void CallEventListeners(VclEventId nEvent, void *pData=nullptr)
Definition: event.cxx:219
virtual OUString GetText() const
Definition: window.cxx:3055
Point ScreenToOutputPixel(const Point &rPos) const
Definition: window.cxx:2812
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize)
Definition: window2.cxx:1294
SAL_DLLPRIVATE vcl::Window * ImplGetFrameWindow() const
Definition: window2.cxx:937
bool IsEnabled() const
Definition: window2.cxx:1148
bool IsAlwaysEnableInput() const
returns the current AlwaysEnableInput state
Definition: window2.cxx:1158
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
#define DOCKWIN_FLOATSTYLES
Definition: dockmgr.cxx:38
IMPL_LINK_NOARG(ImplDockFloatWin2, DockTimerHdl, Timer *, void)
Definition: dockmgr.cxx:116
RegionData_Impl * mpParent
#define MOUSE_LEFT
Definition: event.hxx:102
#define MOUSE_MIDDLE
Definition: event.hxx:103
#define MOUSE_RIGHT
Definition: event.hxx:104
constexpr sal_uInt16 KEY_MOD1
Definition: keycodes.hxx:31
constexpr sal_uInt16 KEY_HOME
Definition: keycodes.hxx:114
#define SAL_WARN_IF(condition, area, stream)
constexpr OUStringLiteral aData
long Long
QPRO_FUNC_TYPE nType
bool mbFloating
Definition: dockwin.hxx:37
tools::Rectangle maTrackRect
Definition: dockwin.hxx:36
TitleButton
Definition: syswin.hxx:55
@ HIGH_IDLE
Important idle events to be run before processing drawing events.
bool bVisible
FloatWinPopupFlags
Definition: vclenum.hxx:323
@ MakeClientWindowVisibleBeforePopup
@ WindowEndPopupMode
@ WindowStartDocking
@ WindowPrepareToggleFloating
@ WindowToggleFloating
ShowTrackFlags
Definition: window.hxx:248
PosSizeFlags
Definition: window.hxx:127
sal_Int64 WinBits
Definition: wintypes.hxx:109
WinBits const WB_CLOSEABLE
Definition: wintypes.hxx:123
WinBits const WB_MOVEABLE
Definition: wintypes.hxx:122
WinBits const WB_OWNERDRAWDECORATION
Definition: wintypes.hxx:173
WinBits const WB_POPUP
Definition: wintypes.hxx:175
WinBits const WB_SIZEABLE
Definition: wintypes.hxx:117
WinBits const WB_SYSTEMWINDOW
Definition: wintypes.hxx:126
WinBits const WB_STDPOPUP
Definition: wintypes.hxx:220
WinBits const WB_BORDER
Definition: wintypes.hxx:115
WinBits const WB_NOSHADOW
Definition: wintypes.hxx:171