1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include <tools/time.hxx>
23 #include <vcl/event.hxx>
24 #include <vcl/floatwin.hxx>
25 #include <vcl/dockwin.hxx>
26 #include <vcl/svapp.hxx>
27 #include <vcl/timer.hxx>
28 #include <vcl/unowrap.hxx>
33 #include <salframe.hxx>
37 // =======================================================================
39 #define DOCKWIN_FLOATSTYLES (WB_SIZEABLE | WB_MOVEABLE | WB_CLOSEABLE | WB_STANDALONE | WB_PINABLE | WB_ROLLABLE )
41 // =======================================================================
43 // -----------------------------------------------------------------------
45 class DockingWindow::ImplData
55 DockingWindow::ImplData::ImplData()
58 maMaxOutSize
= Size( SHRT_MAX
, SHRT_MAX
);
61 DockingWindow::ImplData::~ImplData()
65 // -----------------------------------------------------------------------
67 class ImplDockFloatWin
: public FloatingWindow
70 DockingWindow
* mpDockWin
;
71 sal_uLong mnLastTicks
;
76 sal_uLong mnLastUserEvent
;
78 DECL_LINK(DockingHdl
, void *);
79 DECL_LINK(DockTimerHdl
, void *);
81 ImplDockFloatWin( Window
* pParent
, WinBits nWinBits
,
82 DockingWindow
* pDockingWin
);
86 virtual void Resize();
87 virtual void TitleButtonClick( sal_uInt16 nButton
);
90 virtual void PopupModeEnd();
91 virtual void Resizing( Size
& rSize
);
92 virtual sal_Bool
Close();
94 sal_uLong
GetLastTicks() const { return mnLastTicks
; }
98 ImplDockFloatWin::ImplDockFloatWin( Window
* pParent
, WinBits nWinBits
,
99 DockingWindow
* pDockingWin
) :
100 FloatingWindow( pParent
, nWinBits
),
101 mpDockWin( pDockingWin
),
102 mnLastTicks( Time::GetSystemTicks() ),
106 // Daten vom DockingWindow uebernehmen
109 SetSettings( pDockingWin
->GetSettings() );
110 Enable( pDockingWin
->IsEnabled(), sal_False
);
111 EnableInput( pDockingWin
->IsInputEnabled(), sal_False
);
112 AlwaysEnableInput( pDockingWin
->IsAlwaysEnableInput(), sal_False
);
113 EnableAlwaysOnTop( pDockingWin
->IsAlwaysOnTopEnabled() );
114 SetActivateMode( pDockingWin
->GetActivateMode() );
119 maDockTimer
.SetTimeoutHdl( LINK( this, ImplDockFloatWin
, DockTimerHdl
) );
120 maDockTimer
.SetTimeout( 50 );
123 // -----------------------------------------------------------------------
125 ImplDockFloatWin::~ImplDockFloatWin()
127 if( mnLastUserEvent
)
128 Application::RemoveUserEvent( mnLastUserEvent
);
131 // -----------------------------------------------------------------------
133 IMPL_LINK_NOARG(ImplDockFloatWin
, DockTimerHdl
)
135 DBG_ASSERT( mpDockWin
->IsFloatingMode(), "docktimer called but not floating" );
138 PointerState aState
= GetPointerState();
140 if( aState
.mnState
& KEY_MOD1
)
142 // i43499 CTRL disables docking now
143 mpDockWin
->GetParent()->ImplGetFrameWindow()->HideTracking();
144 mpDockWin
->EndDocking( maDockRect
, sal_True
);
145 if( aState
.mnState
& ( MOUSE_LEFT
| MOUSE_MIDDLE
| MOUSE_RIGHT
) )
148 else if( ! ( aState
.mnState
& ( MOUSE_LEFT
| MOUSE_MIDDLE
| MOUSE_RIGHT
) ) )
150 mpDockWin
->GetParent()->ImplGetFrameWindow()->HideTracking();
151 mpDockWin
->EndDocking( maDockRect
, sal_False
);
155 mpDockWin
->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect
, SHOWTRACK_BIG
| SHOWTRACK_WINDOW
);
162 IMPL_LINK_NOARG(ImplDockFloatWin
, DockingHdl
)
164 PointerState aState
= mpDockWin
->GetParent()->GetPointerState();
167 if( mpDockWin
->IsDockable() &&
168 (Time::GetSystemTicks() - mnLastTicks
> 500) &&
169 ( aState
.mnState
& ( MOUSE_LEFT
| MOUSE_MIDDLE
| MOUSE_RIGHT
) ) &&
170 !(aState
.mnState
& KEY_MOD1
) ) // i43499 CTRL disables docking now
172 maDockPos
= Point( mpDockWin
->GetParent()->AbsoluteScreenToOutputPixel( OutputToAbsoluteScreenPixel( Point() ) ) );
173 maDockPos
= mpDockWin
->GetParent()->OutputToScreenPixel( maDockPos
); // sfx expects screen coordinates
175 if( ! mpDockWin
->IsDocking() )
176 mpDockWin
->StartDocking();
177 maDockRect
= Rectangle( maDockPos
, mpDockWin
->GetSizePixel() );
179 // mouse pos also in screen pixels
180 Point aMousePos
= mpDockWin
->GetParent()->OutputToScreenPixel( aState
.maPos
);
182 sal_Bool bFloatMode
= mpDockWin
->Docking( aMousePos
, maDockRect
);
185 mpDockWin
->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect
, SHOWTRACK_OBJECT
| SHOWTRACK_WINDOW
);
186 DockTimerHdl( this );
190 mpDockWin
->GetParent()->ImplGetFrameWindow()->HideTracking();
192 mpDockWin
->EndDocking( maDockRect
, sal_True
);
198 // -----------------------------------------------------------------------
200 void ImplDockFloatWin::Move()
206 FloatingWindow::Move();
210 * note: the window should only dock if
211 * the user releases all mouse buttons. The real problem here
212 * is that we don't get mouse events (at least not on X)
213 * if the mouse is on the decoration. So we have to start an
214 * awkward timer based process that polls the modifier/buttons
215 * to see whether they are in the right condition shortly after the
218 if( ! mnLastUserEvent
)
219 mnLastUserEvent
= Application::PostUserEvent( LINK( this, ImplDockFloatWin
, DockingHdl
) );
222 // -----------------------------------------------------------------------
224 void ImplDockFloatWin::Resize()
226 FloatingWindow::Resize();
227 Size
aSize( GetSizePixel() );
228 mpDockWin
->ImplPosSizeWindow( 0, 0, aSize
.Width(), aSize
.Height(), WINDOW_POSSIZE_POSSIZE
);
231 // -----------------------------------------------------------------------
233 void ImplDockFloatWin::TitleButtonClick( sal_uInt16 nButton
)
235 FloatingWindow::TitleButtonClick( nButton
);
236 mpDockWin
->TitleButtonClick( nButton
);
239 // -----------------------------------------------------------------------
241 void ImplDockFloatWin::Pin()
243 FloatingWindow::Pin();
247 // -----------------------------------------------------------------------
249 void ImplDockFloatWin::Roll()
251 FloatingWindow::Roll();
255 // -----------------------------------------------------------------------
257 void ImplDockFloatWin::PopupModeEnd()
259 FloatingWindow::PopupModeEnd();
260 mpDockWin
->PopupModeEnd();
263 // -----------------------------------------------------------------------
265 void ImplDockFloatWin::Resizing( Size
& rSize
)
267 FloatingWindow::Resizing( rSize
);
268 mpDockWin
->Resizing( rSize
);
271 // -----------------------------------------------------------------------
273 sal_Bool
ImplDockFloatWin::Close()
275 return mpDockWin
->Close();
278 // =======================================================================
280 sal_Bool
DockingWindow::ImplStartDocking( const Point
& rPos
)
286 maMouseStart
= maMouseOff
;
287 mbDocking
= sal_True
;
288 mbLastFloatMode
= IsFloatingMode();
289 mbStartFloat
= mbLastFloatMode
;
291 // FloatingBorder berechnen
292 FloatingWindow
* pWin
;
296 pWin
= new ImplDockFloatWin( mpImplData
->mpParent
, mnFloatBits
, NULL
);
297 pWin
->GetBorder( mnDockLeft
, mnDockTop
, mnDockRight
, mnDockBottom
);
301 Point aPos
= ImplOutputToFrame( Point() );
302 Size aSize
= Window::GetOutputSizePixel();
305 mnTrackWidth
= aSize
.Width();
306 mnTrackHeight
= aSize
.Height();
308 if ( mbLastFloatMode
)
310 maMouseOff
.X() += mnDockLeft
;
311 maMouseOff
.Y() += mnDockTop
;
312 mnTrackX
-= mnDockLeft
;
313 mnTrackY
-= mnDockTop
;
314 mnTrackWidth
+= mnDockLeft
+mnDockRight
;
315 mnTrackHeight
+= mnDockTop
+mnDockBottom
;
318 if ( GetSettings().GetStyleSettings().GetDragFullOptions() & DRAGFULL_OPTION_DOCKING
&&
319 !( mnFloatBits
& ( WB_MOVEABLE
| WB_SIZEABLE
| WB_CLOSEABLE
) ) ) // no full drag when migrating to system window
320 mbDragFull
= sal_True
;
324 mbDragFull
= sal_False
;
326 ImplGetFrameWindow()->ImplUpdateAll();
329 StartTracking( STARTTRACK_KEYMOD
);
333 // =======================================================================
335 void DockingWindow::ImplInitDockingWindowData()
337 mpImplData
= new ImplData
;
338 mpWindowImpl
->mbDockWin
= sal_True
;
341 mbDockCanceled
= sal_False
;
342 mbDockPrevented
= sal_False
;
343 mbFloatPrevented
= sal_False
;
344 mbDocking
= sal_False
;
346 mbRollUp
= sal_False
;
347 mbDockBtn
= sal_False
;
348 mbHideBtn
= sal_False
;
351 // -----------------------------------------------------------------------
353 void DockingWindow::ImplInit( Window
* pParent
, WinBits nStyle
)
355 if ( !(nStyle
& WB_NODIALOGCONTROL
) )
356 nStyle
|= WB_DIALOGCONTROL
;
358 mpImplData
->mpParent
= pParent
;
359 mbDockable
= (nStyle
& WB_DOCKABLE
) != 0;
360 mnFloatBits
= WB_BORDER
| (nStyle
& DOCKWIN_FLOATSTYLES
);
361 nStyle
&= ~(DOCKWIN_FLOATSTYLES
| WB_BORDER
);
362 if ( nStyle
& WB_DOCKBORDER
)
365 Window::ImplInit( pParent
, nStyle
, NULL
);
370 // -----------------------------------------------------------------------
372 void DockingWindow::ImplInitSettings()
374 // Hack, damit man auch DockingWindows ohne Hintergrund bauen kann
375 // und noch nicht alles umgestellt ist
376 if ( IsBackground() )
378 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
381 if ( IsControlBackground() )
382 aColor
= GetControlBackground();
383 else if ( Window::GetStyle() & WB_3DLOOK
)
384 aColor
= rStyleSettings
.GetFaceColor();
386 aColor
= rStyleSettings
.GetWindowColor();
387 SetBackground( aColor
);
391 // -----------------------------------------------------------------------
393 void DockingWindow::ImplLoadRes( const ResId
& rResId
)
395 Window::ImplLoadRes( rResId
);
397 sal_uLong nMask
= ReadLongRes();
399 if ( (RSC_DOCKINGWINDOW_XYMAPMODE
| RSC_DOCKINGWINDOW_X
|
400 RSC_DOCKINGWINDOW_Y
) & nMask
)
402 // Groessenangabe aus der Resource verwenden
404 MapUnit ePosMap
= MAP_PIXEL
;
406 if ( RSC_DOCKINGWINDOW_XYMAPMODE
& nMask
)
407 ePosMap
= (MapUnit
)ReadLongRes();
409 if ( RSC_DOCKINGWINDOW_X
& nMask
)
411 aPos
.X() = ReadShortRes();
412 aPos
.X() = ImplLogicUnitToPixelX( aPos
.X(), ePosMap
);
415 if ( RSC_DOCKINGWINDOW_Y
& nMask
)
417 aPos
.Y() = ReadShortRes();
418 aPos
.Y() = ImplLogicUnitToPixelY( aPos
.Y(), ePosMap
);
421 SetFloatingPos( aPos
);
424 if ( nMask
& RSC_DOCKINGWINDOW_FLOATING
)
426 if ( (sal_Bool
)ReadShortRes() )
427 SetFloatingMode( sal_True
);
431 // -----------------------------------------------------------------------
433 DockingWindow::DockingWindow( WindowType nType
) :
436 ImplInitDockingWindowData();
439 // -----------------------------------------------------------------------
441 DockingWindow::DockingWindow( Window
* pParent
, WinBits nStyle
) :
442 Window( WINDOW_DOCKINGWINDOW
)
444 ImplInitDockingWindowData();
445 ImplInit( pParent
, nStyle
);
448 // -----------------------------------------------------------------------
450 DockingWindow::DockingWindow( Window
* pParent
, const ResId
& rResId
) :
451 Window( WINDOW_DOCKINGWINDOW
)
453 ImplInitDockingWindowData();
454 rResId
.SetRT( RSC_DOCKINGWINDOW
);
455 WinBits nStyle
= ImplInitRes( rResId
);
456 ImplInit( pParent
, nStyle
);
457 ImplLoadRes( rResId
);
459 if ( !(nStyle
& WB_HIDE
) )
463 // -----------------------------------------------------------------------
465 DockingWindow::~DockingWindow()
467 if ( IsFloatingMode() )
469 Show( sal_False
, SHOW_NOFOCUSCHANGE
);
470 SetFloatingMode( sal_False
);
475 // -----------------------------------------------------------------------
477 void DockingWindow::Tracking( const TrackingEvent
& rTEvt
)
479 if( GetDockingManager()->IsDockable( this ) ) // new docking interface
480 return Window::Tracking( rTEvt
);
484 if ( rTEvt
.IsTrackingEnded() )
486 mbDocking
= sal_False
;
489 // Bei Abbruch alten Zustand wieder herstellen
490 if ( rTEvt
.IsTrackingCanceled() )
493 Rectangle
aRect( Point( mnTrackX
, mnTrackY
), Size( mnTrackWidth
, mnTrackHeight
) );
494 EndDocking( aRect
, mbStartFloat
);
500 if ( rTEvt
.IsTrackingCanceled() )
502 mbDockCanceled
= sal_True
;
503 EndDocking( Rectangle( Point( mnTrackX
, mnTrackY
), Size( mnTrackWidth
, mnTrackHeight
) ), mbLastFloatMode
);
504 mbDockCanceled
= sal_False
;
507 EndDocking( Rectangle( Point( mnTrackX
, mnTrackY
), Size( mnTrackWidth
, mnTrackHeight
) ), mbLastFloatMode
);
510 // Docking nur bei nicht synthetischen MouseEvents
511 else if ( !rTEvt
.GetMouseEvent().IsSynthetic() || rTEvt
.GetMouseEvent().IsModifierChanged() )
513 Point aMousePos
= rTEvt
.GetMouseEvent().GetPosPixel();
514 Point aFrameMousePos
= ImplOutputToFrame( aMousePos
);
515 Size aFrameSize
= mpWindowImpl
->mpFrameWindow
->GetOutputSizePixel();
516 if ( aFrameMousePos
.X() < 0 )
517 aFrameMousePos
.X() = 0;
518 if ( aFrameMousePos
.Y() < 0 )
519 aFrameMousePos
.Y() = 0;
520 if ( aFrameMousePos
.X() > aFrameSize
.Width()-1 )
521 aFrameMousePos
.X() = aFrameSize
.Width()-1;
522 if ( aFrameMousePos
.Y() > aFrameSize
.Height()-1 )
523 aFrameMousePos
.Y() = aFrameSize
.Height()-1;
524 aMousePos
= ImplFrameToOutput( aFrameMousePos
);
525 aMousePos
.X() -= maMouseOff
.X();
526 aMousePos
.Y() -= maMouseOff
.Y();
527 Point aFramePos
= ImplOutputToFrame( aMousePos
);
528 Rectangle
aTrackRect( aFramePos
, Size( mnTrackWidth
, mnTrackHeight
) );
529 Rectangle aCompRect
= aTrackRect
;
530 aFramePos
.X() += maMouseOff
.X();
531 aFramePos
.Y() += maMouseOff
.Y();
534 sal_Bool bFloatMode
= Docking( aFramePos
, aTrackRect
);
535 mbDockPrevented
= sal_False
;
536 mbFloatPrevented
= sal_False
;
537 if ( mbLastFloatMode
!= bFloatMode
)
541 aTrackRect
.Left() -= mnDockLeft
;
542 aTrackRect
.Top() -= mnDockTop
;
543 aTrackRect
.Right() += mnDockRight
;
544 aTrackRect
.Bottom() += mnDockBottom
;
548 if ( aCompRect
== aTrackRect
)
550 aTrackRect
.Left() += mnDockLeft
;
551 aTrackRect
.Top() += mnDockTop
;
552 aTrackRect
.Right() -= mnDockRight
;
553 aTrackRect
.Bottom() -= mnDockBottom
;
556 mbLastFloatMode
= bFloatMode
;
561 Point aOldPos
= OutputToScreenPixel( aPos
);
562 EndDocking( aTrackRect
, mbLastFloatMode
);
563 // Wenn der Status bzw. die Position sich
564 // geaendert hat, dann neu ausgeben
565 if ( aOldPos
!= OutputToScreenPixel( aPos
) )
568 ImplGetFrameWindow()->ImplUpdateAll();
570 // EndDocking( aTrackRect, mbLastFloatMode );
574 sal_uInt16 nTrackStyle
;
576 nTrackStyle
= SHOWTRACK_BIG
;
578 nTrackStyle
= SHOWTRACK_OBJECT
;
579 Rectangle aShowTrackRect
= aTrackRect
;
580 aShowTrackRect
.SetPos( ImplFrameToOutput( aShowTrackRect
.TopLeft() ) );
581 ShowTracking( aShowTrackRect
, nTrackStyle
);
583 // Maus-Offset neu berechnen, da Rechteck veraendert werden
585 maMouseOff
.X() = aFramePos
.X() - aTrackRect
.Left();
586 maMouseOff
.Y() = aFramePos
.Y() - aTrackRect
.Top();
589 mnTrackX
= aTrackRect
.Left();
590 mnTrackY
= aTrackRect
.Top();
591 mnTrackWidth
= aTrackRect
.GetWidth();
592 mnTrackHeight
= aTrackRect
.GetHeight();
597 // -----------------------------------------------------------------------
599 long DockingWindow::Notify( NotifyEvent
& rNEvt
)
601 if( GetDockingManager()->IsDockable( this ) ) // new docking interface
602 return Window::Notify( rNEvt
);
606 if ( rNEvt
.GetType() == EVENT_MOUSEBUTTONDOWN
)
608 const MouseEvent
* pMEvt
= rNEvt
.GetMouseEvent();
609 if ( pMEvt
->IsLeft() )
611 if ( pMEvt
->IsMod1() && (pMEvt
->GetClicks() == 2) )
613 SetFloatingMode( !IsFloatingMode() );
616 else if ( pMEvt
->GetClicks() == 1 )
618 // check if window is floating standalone (IsFloating())
619 // or only partially floating and still docked with one border
620 // ( !mpWindowImpl->mbFrame)
621 if( ! IsFloatingMode() || ! mpFloatWin
->mpWindowImpl
->mbFrame
)
623 Point aPos
= pMEvt
->GetPosPixel();
624 Window
* pWindow
= rNEvt
.GetWindow();
625 if ( pWindow
!= this )
627 aPos
= pWindow
->OutputToScreenPixel( aPos
);
628 aPos
= ScreenToOutputPixel( aPos
);
630 ImplStartDocking( aPos
);
636 else if( rNEvt
.GetType() == EVENT_KEYINPUT
)
638 const KeyCode
& rKey
= rNEvt
.GetKeyEvent()->GetKeyCode();
639 if( rKey
.GetCode() == KEY_F10
&& rKey
.GetModifier() &&
640 rKey
.IsShift() && rKey
.IsMod1() )
642 SetFloatingMode( !IsFloatingMode() );
648 return Window::Notify( rNEvt
);
651 // -----------------------------------------------------------------------
653 void DockingWindow::StartDocking()
655 mbDocking
= sal_True
;
658 // -----------------------------------------------------------------------
660 sal_Bool
DockingWindow::Docking( const Point
&, Rectangle
& )
662 return IsFloatingMode();
665 // -----------------------------------------------------------------------
667 void DockingWindow::EndDocking( const Rectangle
& rRect
, sal_Bool bFloatMode
)
669 if ( !IsDockingCanceled() )
672 if ( bFloatMode
!= IsFloatingMode() )
674 Show( sal_False
, SHOW_NOFOCUSCHANGE
);
675 SetFloatingMode( bFloatMode
);
677 if ( bFloatMode
&& mpFloatWin
)
678 mpFloatWin
->SetPosSizePixel( rRect
.TopLeft(), rRect
.GetSize() );
682 Point aPos
= rRect
.TopLeft();
683 aPos
= GetParent()->ScreenToOutputPixel( aPos
);
684 Window::SetPosSizePixel( aPos
, rRect
.GetSize() );
690 mbDocking
= sal_False
;
693 // -----------------------------------------------------------------------
695 sal_Bool
DockingWindow::PrepareToggleFloatingMode()
700 // -----------------------------------------------------------------------
702 sal_Bool
DockingWindow::Close()
704 ImplDelData aDelData
;
705 ImplAddDel( &aDelData
);
706 ImplCallEventListeners( VCLEVENT_WINDOW_CLOSE
);
707 if ( aDelData
.IsDead() )
709 ImplRemoveDel( &aDelData
);
711 if ( mpWindowImpl
->mxWindowPeer
.is() && IsCreatedWithToolkit() )
714 Show( sal_False
, SHOW_NOFOCUSCHANGE
);
718 // -----------------------------------------------------------------------
720 void DockingWindow::ToggleFloatingMode()
724 // -----------------------------------------------------------------------
726 void DockingWindow::TitleButtonClick( sal_uInt16
)
730 // -----------------------------------------------------------------------
732 void DockingWindow::Pin()
736 // -----------------------------------------------------------------------
738 void DockingWindow::Roll()
742 // -----------------------------------------------------------------------
744 void DockingWindow::PopupModeEnd()
748 // -----------------------------------------------------------------------
750 void DockingWindow::Resizing( Size
& )
754 // -----------------------------------------------------------------------
756 void DockingWindow::StateChanged( StateChangedType nType
)
760 case STATE_CHANGE_CONTROLBACKGROUND
:
765 case STATE_CHANGE_STYLE
:
766 mbDockable
= (GetStyle() & WB_DOCKABLE
) != 0;
773 Window::StateChanged( nType
);
776 // -----------------------------------------------------------------------
778 void DockingWindow::DataChanged( const DataChangedEvent
& rDCEvt
)
780 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
781 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
787 Window::DataChanged( rDCEvt
);
790 // -----------------------------------------------------------------------
792 void DockingWindow::SetFloatingMode( sal_Bool bFloatMode
)
794 ImplDockingWindowWrapper
*pWrapper
= ImplGetDockingManager()->GetDockingWindowWrapper( this );
797 pWrapper
->SetFloatingMode( bFloatMode
);
800 if ( IsFloatingMode() != bFloatMode
)
802 if ( PrepareToggleFloatingMode() ) // changes to floating mode can be vetoed
804 sal_Bool bVisible
= IsVisible();
808 Show( sal_False
, SHOW_NOFOCUSCHANGE
);
810 maDockPos
= Window::GetPosPixel();
812 Window
* pRealParent
= mpWindowImpl
->mpRealParent
;
813 mpOldBorderWin
= mpWindowImpl
->mpBorderWindow
;
815 ImplDockFloatWin
* pWin
=
816 new ImplDockFloatWin(
817 mpImplData
->mpParent
,
818 mnFloatBits
& ( WB_MOVEABLE
| WB_SIZEABLE
| WB_CLOSEABLE
) ? mnFloatBits
| WB_SYSTEMWINDOW
: mnFloatBits
,
821 mpWindowImpl
->mpBorderWindow
= NULL
;
822 mpWindowImpl
->mnLeftBorder
= 0;
823 mpWindowImpl
->mnTopBorder
= 0;
824 mpWindowImpl
->mnRightBorder
= 0;
825 mpWindowImpl
->mnBottomBorder
= 0;
826 // Falls Parent zerstoert wird, muessen wir auch vom
827 // BorderWindow den Parent umsetzen
828 if ( mpOldBorderWin
)
829 mpOldBorderWin
->SetParent( pWin
);
831 // #i123765# reset the buffered DropTargets when undocking, else it may not
832 // be correctly initialized
833 mpWindowImpl
->mxDNDListenerContainer
.clear();
836 SetPosPixel( Point() );
837 mpWindowImpl
->mpBorderWindow
= pWin
;
838 pWin
->mpWindowImpl
->mpClientWindow
= this;
839 mpWindowImpl
->mpRealParent
= pRealParent
;
840 pWin
->SetText( Window::GetText() );
841 pWin
->SetOutputSizePixel( Window::GetSizePixel() );
842 pWin
->SetPosPixel( maFloatPos
);
843 // DockingDaten ans FloatingWindow weiterreichen
844 pWin
->ShowTitleButton( TITLE_BUTTON_DOCKING
, mbDockBtn
);
845 pWin
->ShowTitleButton( TITLE_BUTTON_HIDE
, mbHideBtn
);
846 pWin
->SetPin( mbPined
);
851 pWin
->SetRollUpOutputSizePixel( maRollUpOutSize
);
852 pWin
->SetMinOutputSizePixel( maMinOutSize
);
853 pWin
->SetMaxOutputSizePixel( mpImplData
->maMaxOutSize
);
855 ToggleFloatingMode();
862 Show( sal_False
, SHOW_NOFOCUSCHANGE
);
864 // FloatingDaten wird im FloatingWindow speichern
865 maFloatPos
= mpFloatWin
->GetPosPixel();
866 mbDockBtn
= mpFloatWin
->IsTitleButtonVisible( TITLE_BUTTON_DOCKING
);
867 mbHideBtn
= mpFloatWin
->IsTitleButtonVisible( TITLE_BUTTON_HIDE
);
868 mbPined
= mpFloatWin
->IsPined();
869 mbRollUp
= mpFloatWin
->IsRollUp();
870 maRollUpOutSize
= mpFloatWin
->GetRollUpOutputSizePixel();
871 maMinOutSize
= mpFloatWin
->GetMinOutputSizePixel();
872 mpImplData
->maMaxOutSize
= mpFloatWin
->GetMaxOutputSizePixel();
874 Window
* pRealParent
= mpWindowImpl
->mpRealParent
;
875 mpWindowImpl
->mpBorderWindow
= NULL
;
876 if ( mpOldBorderWin
)
878 SetParent( mpOldBorderWin
);
879 ((ImplBorderWindow
*)mpOldBorderWin
)->GetBorder( mpWindowImpl
->mnLeftBorder
, mpWindowImpl
->mnTopBorder
, mpWindowImpl
->mnRightBorder
, mpWindowImpl
->mnBottomBorder
);
880 mpOldBorderWin
->Resize();
882 mpWindowImpl
->mpBorderWindow
= mpOldBorderWin
;
883 SetParent( pRealParent
);
884 mpWindowImpl
->mpRealParent
= pRealParent
;
885 delete static_cast<ImplDockFloatWin
*>(mpFloatWin
);
887 SetPosPixel( maDockPos
);
889 ToggleFloatingMode();
898 // -----------------------------------------------------------------------
900 void DockingWindow::SetFloatStyle( WinBits nStyle
)
902 ImplDockingWindowWrapper
*pWrapper
= ImplGetDockingManager()->GetDockingWindowWrapper( this );
905 pWrapper
->SetFloatStyle( nStyle
);
909 mnFloatBits
= nStyle
;
912 // -----------------------------------------------------------------------
914 WinBits
DockingWindow::GetFloatStyle() const
916 ImplDockingWindowWrapper
*pWrapper
= ImplGetDockingManager()->GetDockingWindowWrapper( this );
919 return pWrapper
->GetFloatStyle();
925 // -----------------------------------------------------------------------
927 void DockingWindow::setPosSizePixel( long nX
, long nY
,
928 long nWidth
, long nHeight
,
931 ImplDockingWindowWrapper
*pWrapper
= ImplGetDockingManager()->GetDockingWindowWrapper( this );
934 if ( pWrapper
->mpFloatWin
)
935 pWrapper
->mpFloatWin
->setPosSizePixel( nX
, nY
, nWidth
, nHeight
, nFlags
);
937 Window::setPosSizePixel( nX
, nY
, nWidth
, nHeight
, nFlags
);
942 mpFloatWin
->setPosSizePixel( nX
, nY
, nWidth
, nHeight
, nFlags
);
944 Window::setPosSizePixel( nX
, nY
, nWidth
, nHeight
, nFlags
);
947 // -----------------------------------------------------------------------
949 Point
DockingWindow::GetPosPixel() const
951 ImplDockingWindowWrapper
*pWrapper
= ImplGetDockingManager()->GetDockingWindowWrapper( this );
954 if ( pWrapper
->mpFloatWin
)
955 return pWrapper
->mpFloatWin
->GetPosPixel();
957 return Window::GetPosPixel();
961 return mpFloatWin
->GetPosPixel();
963 return Window::GetPosPixel();
966 // -----------------------------------------------------------------------
968 Size
DockingWindow::GetSizePixel() const
970 ImplDockingWindowWrapper
*pWrapper
= ImplGetDockingManager()->GetDockingWindowWrapper( this );
973 if ( pWrapper
->mpFloatWin
)
974 return pWrapper
->mpFloatWin
->GetSizePixel();
976 return Window::GetSizePixel();
980 return mpFloatWin
->GetSizePixel();
982 return Window::GetSizePixel();
985 // -----------------------------------------------------------------------
987 void DockingWindow::SetOutputSizePixel( const Size
& rNewSize
)
989 ImplDockingWindowWrapper
*pWrapper
= ImplGetDockingManager()->GetDockingWindowWrapper( this );
992 if ( pWrapper
->mpFloatWin
)
993 pWrapper
->mpFloatWin
->SetOutputSizePixel( rNewSize
);
995 Window::SetOutputSizePixel( rNewSize
);
1000 mpFloatWin
->SetOutputSizePixel( rNewSize
);
1002 Window::SetOutputSizePixel( rNewSize
);
1005 // -----------------------------------------------------------------------
1007 Size
DockingWindow::GetOutputSizePixel() const
1009 ImplDockingWindowWrapper
*pWrapper
= ImplGetDockingManager()->GetDockingWindowWrapper( this );
1012 if ( pWrapper
->mpFloatWin
)
1013 return pWrapper
->mpFloatWin
->GetOutputSizePixel();
1015 return Window::GetOutputSizePixel();
1019 return mpFloatWin
->GetOutputSizePixel();
1021 return Window::GetOutputSizePixel();
1024 Point
DockingWindow::GetFloatingPos() const
1026 ImplDockingWindowWrapper
*pWrapper
= ImplGetDockingManager()->GetDockingWindowWrapper( this );
1029 if ( pWrapper
->mpFloatWin
)
1031 WindowStateData aData
;
1032 aData
.SetMask( WINDOWSTATE_MASK_POS
);
1033 pWrapper
->mpFloatWin
->GetWindowStateData( aData
);
1034 Point
aPos( aData
.GetX(), aData
.GetY() );
1035 aPos
= pWrapper
->mpFloatWin
->GetParent()->ImplGetFrameWindow()->AbsoluteScreenToOutputPixel( aPos
);
1044 WindowStateData aData
;
1045 aData
.SetMask( WINDOWSTATE_MASK_POS
);
1046 mpFloatWin
->GetWindowStateData( aData
);
1047 Point
aPos( aData
.GetX(), aData
.GetY() );
1048 aPos
= mpFloatWin
->GetParent()->ImplGetFrameWindow()->AbsoluteScreenToOutputPixel( aPos
);
1055 sal_Bool
DockingWindow::IsFloatingMode() const
1057 ImplDockingWindowWrapper
*pWrapper
= ImplGetDockingManager()->GetDockingWindowWrapper( this );
1059 return pWrapper
->IsFloatingMode();
1061 return (mpFloatWin
!= NULL
);
1064 void DockingWindow::SetMaxOutputSizePixel( const Size
& rSize
)
1067 mpFloatWin
->SetMaxOutputSizePixel( rSize
);
1068 mpImplData
->maMaxOutSize
= rSize
;
1071 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */