1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dockwin.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
37 #include <tools/time.hxx>
41 #include <vcl/event.hxx>
42 #include <vcl/brdwin.hxx>
43 #include <vcl/floatwin.hxx>
44 #include <vcl/dockwin.hxx>
45 #include <vcl/svapp.hxx>
46 #include <vcl/svdata.hxx>
47 #include <vcl/timer.hxx>
48 #include <vcl/window.h>
49 #include <vcl/unowrap.hxx>
50 #include <vcl/salframe.hxx>
54 // =======================================================================
56 #define DOCKWIN_FLOATSTYLES (WB_SIZEABLE | WB_MOVEABLE | WB_CLOSEABLE | WB_STANDALONE | WB_PINABLE | WB_ROLLABLE )
58 // =======================================================================
60 // -----------------------------------------------------------------------
62 class DockingWindow::ImplData
72 DockingWindow::ImplData::ImplData()
75 maMaxOutSize
= Size( SHRT_MAX
, SHRT_MAX
);
78 DockingWindow::ImplData::~ImplData()
82 // -----------------------------------------------------------------------
84 class ImplDockFloatWin
: public FloatingWindow
87 DockingWindow
* mpDockWin
;
93 ULONG mnLastUserEvent
;
95 DECL_LINK( DockingHdl
, ImplDockFloatWin
* );
96 DECL_LINK( DockTimerHdl
, ImplDockFloatWin
* );
98 ImplDockFloatWin( Window
* pParent
, WinBits nWinBits
,
99 DockingWindow
* pDockingWin
);
103 virtual void Resize();
104 virtual void TitleButtonClick( USHORT nButton
);
107 virtual void PopupModeEnd();
108 virtual void Resizing( Size
& rSize
);
109 virtual BOOL
Close();
111 ULONG
GetLastTicks() const { return mnLastTicks
; }
115 ImplDockFloatWin::ImplDockFloatWin( Window
* pParent
, WinBits nWinBits
,
116 DockingWindow
* pDockingWin
) :
117 FloatingWindow( pParent
, nWinBits
),
118 mpDockWin( pDockingWin
),
119 mnLastTicks( Time::GetSystemTicks() ),
123 // Daten vom DockingWindow uebernehmen
126 SetSettings( pDockingWin
->GetSettings() );
127 Enable( pDockingWin
->IsEnabled(), FALSE
);
128 EnableInput( pDockingWin
->IsInputEnabled(), FALSE
);
129 AlwaysEnableInput( pDockingWin
->IsAlwaysEnableInput(), FALSE
);
130 EnableAlwaysOnTop( pDockingWin
->IsAlwaysOnTopEnabled() );
131 SetActivateMode( pDockingWin
->GetActivateMode() );
136 maDockTimer
.SetTimeoutHdl( LINK( this, ImplDockFloatWin
, DockTimerHdl
) );
137 maDockTimer
.SetTimeout( 50 );
140 // -----------------------------------------------------------------------
142 ImplDockFloatWin::~ImplDockFloatWin()
144 if( mnLastUserEvent
)
145 Application::RemoveUserEvent( mnLastUserEvent
);
148 // -----------------------------------------------------------------------
150 IMPL_LINK( ImplDockFloatWin
, DockTimerHdl
, ImplDockFloatWin
*, EMPTYARG
)
152 DBG_ASSERT( mpDockWin
->IsFloatingMode(), "docktimer called but not floating" );
155 PointerState aState
= GetPointerState();
157 if( aState
.mnState
& KEY_MOD1
)
159 // i43499 CTRL disables docking now
160 mpDockWin
->GetParent()->ImplGetFrameWindow()->HideTracking();
161 mpDockWin
->EndDocking( maDockRect
, TRUE
);
162 if( aState
.mnState
& ( MOUSE_LEFT
| MOUSE_MIDDLE
| MOUSE_RIGHT
) )
165 else if( ! ( aState
.mnState
& ( MOUSE_LEFT
| MOUSE_MIDDLE
| MOUSE_RIGHT
) ) )
167 mpDockWin
->GetParent()->ImplGetFrameWindow()->HideTracking();
168 mpDockWin
->EndDocking( maDockRect
, FALSE
);
172 mpDockWin
->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect
, SHOWTRACK_BIG
| SHOWTRACK_WINDOW
);
179 IMPL_LINK( ImplDockFloatWin
, DockingHdl
, ImplDockFloatWin
*, EMPTYARG
)
181 PointerState aState
= mpDockWin
->GetParent()->GetPointerState();
184 if( mpDockWin
->IsDockable() &&
185 (Time::GetSystemTicks() - mnLastTicks
> 500) &&
186 ( aState
.mnState
& ( MOUSE_LEFT
| MOUSE_MIDDLE
| MOUSE_RIGHT
) ) &&
187 !(aState
.mnState
& KEY_MOD1
) ) // i43499 CTRL disables docking now
189 maDockPos
= Point( mpDockWin
->GetParent()->AbsoluteScreenToOutputPixel( OutputToAbsoluteScreenPixel( Point() ) ) );
190 maDockPos
= mpDockWin
->GetParent()->OutputToScreenPixel( maDockPos
); // sfx expects screen coordinates
192 if( ! mpDockWin
->IsDocking() )
193 mpDockWin
->StartDocking();
194 maDockRect
= Rectangle( maDockPos
, mpDockWin
->GetSizePixel() );
196 // mouse pos also in screen pixels
197 Point aMousePos
= mpDockWin
->GetParent()->OutputToScreenPixel( aState
.maPos
);
199 BOOL bFloatMode
= mpDockWin
->Docking( aMousePos
, maDockRect
);
202 mpDockWin
->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect
, SHOWTRACK_OBJECT
| SHOWTRACK_WINDOW
);
203 DockTimerHdl( this );
207 mpDockWin
->GetParent()->ImplGetFrameWindow()->HideTracking();
209 mpDockWin
->EndDocking( maDockRect
, TRUE
);
215 // -----------------------------------------------------------------------
217 void ImplDockFloatWin::Move()
223 FloatingWindow::Move();
227 * note: the window should only dock if
228 * the user releases all mouse buttons. The real problem here
229 * is that we don't get mouse events (at least not on X)
230 * if the mouse is on the decoration. So we have to start an
231 * awkward timer based process that polls the modifier/buttons
232 * to see whether they are in the right condition shortly after the
235 if( ! mnLastUserEvent
)
236 mnLastUserEvent
= Application::PostUserEvent( LINK( this, ImplDockFloatWin
, DockingHdl
) );
239 // -----------------------------------------------------------------------
241 void ImplDockFloatWin::Resize()
243 FloatingWindow::Resize();
244 Size
aSize( GetSizePixel() );
245 mpDockWin
->ImplPosSizeWindow( 0, 0, aSize
.Width(), aSize
.Height(), WINDOW_POSSIZE_POSSIZE
);
248 // -----------------------------------------------------------------------
250 void ImplDockFloatWin::TitleButtonClick( USHORT nButton
)
252 FloatingWindow::TitleButtonClick( nButton
);
253 mpDockWin
->TitleButtonClick( nButton
);
256 // -----------------------------------------------------------------------
258 void ImplDockFloatWin::Pin()
260 FloatingWindow::Pin();
264 // -----------------------------------------------------------------------
266 void ImplDockFloatWin::Roll()
268 FloatingWindow::Roll();
272 // -----------------------------------------------------------------------
274 void ImplDockFloatWin::PopupModeEnd()
276 FloatingWindow::PopupModeEnd();
277 mpDockWin
->PopupModeEnd();
280 // -----------------------------------------------------------------------
282 void ImplDockFloatWin::Resizing( Size
& rSize
)
284 FloatingWindow::Resizing( rSize
);
285 mpDockWin
->Resizing( rSize
);
288 // -----------------------------------------------------------------------
290 BOOL
ImplDockFloatWin::Close()
292 return mpDockWin
->Close();
295 // =======================================================================
297 BOOL
DockingWindow::ImplStartDocking( const Point
& rPos
)
303 maMouseStart
= maMouseOff
;
305 mbLastFloatMode
= IsFloatingMode();
306 mbStartFloat
= mbLastFloatMode
;
308 // FloatingBorder berechnen
309 FloatingWindow
* pWin
;
313 pWin
= new ImplDockFloatWin( mpImplData
->mpParent
, mnFloatBits
, NULL
);
314 pWin
->GetBorder( mnDockLeft
, mnDockTop
, mnDockRight
, mnDockBottom
);
318 Point aPos
= ImplOutputToFrame( Point() );
319 Size aSize
= Window::GetOutputSizePixel();
322 mnTrackWidth
= aSize
.Width();
323 mnTrackHeight
= aSize
.Height();
325 if ( mbLastFloatMode
)
327 maMouseOff
.X() += mnDockLeft
;
328 maMouseOff
.Y() += mnDockTop
;
329 mnTrackX
-= mnDockLeft
;
330 mnTrackY
-= mnDockTop
;
331 mnTrackWidth
+= mnDockLeft
+mnDockRight
;
332 mnTrackHeight
+= mnDockTop
+mnDockBottom
;
335 if ( GetSettings().GetStyleSettings().GetDragFullOptions() & DRAGFULL_OPTION_DOCKING
&&
336 !( mnFloatBits
& ( WB_MOVEABLE
| WB_SIZEABLE
| WB_CLOSEABLE
) ) ) // no full drag when migrating to system window
343 ImplGetFrameWindow()->ImplUpdateAll();
346 StartTracking( STARTTRACK_KEYMOD
);
350 // =======================================================================
352 void DockingWindow::ImplInitDockingWindowData()
354 mpImplData
= new ImplData
;
355 mpWindowImpl
->mbDockWin
= TRUE
;
358 mbDockCanceled
= FALSE
;
359 mbDockPrevented
= FALSE
;
360 mbFloatPrevented
= FALSE
;
368 // -----------------------------------------------------------------------
370 void DockingWindow::ImplInit( Window
* pParent
, WinBits nStyle
)
372 if ( !(nStyle
& WB_NODIALOGCONTROL
) )
373 nStyle
|= WB_DIALOGCONTROL
;
375 mpImplData
->mpParent
= pParent
;
376 mbDockable
= (nStyle
& WB_DOCKABLE
) != 0;
377 mnFloatBits
= WB_BORDER
| (nStyle
& DOCKWIN_FLOATSTYLES
);
378 nStyle
&= ~(DOCKWIN_FLOATSTYLES
| WB_BORDER
);
379 if ( nStyle
& WB_DOCKBORDER
)
382 Window::ImplInit( pParent
, nStyle
, NULL
);
387 // -----------------------------------------------------------------------
389 void DockingWindow::ImplInitSettings()
391 // Hack, damit man auch DockingWindows ohne Hintergrund bauen kann
392 // und noch nicht alles umgestellt ist
393 if ( IsBackground() )
395 const StyleSettings
& rStyleSettings
= GetSettings().GetStyleSettings();
398 if ( IsControlBackground() )
399 aColor
= GetControlBackground();
400 else if ( Window::GetStyle() & WB_3DLOOK
)
401 aColor
= rStyleSettings
.GetFaceColor();
403 aColor
= rStyleSettings
.GetWindowColor();
404 SetBackground( aColor
);
408 // -----------------------------------------------------------------------
410 void DockingWindow::ImplLoadRes( const ResId
& rResId
)
412 Window::ImplLoadRes( rResId
);
414 ULONG nMask
= ReadLongRes();
416 if ( (RSC_DOCKINGWINDOW_XYMAPMODE
| RSC_DOCKINGWINDOW_X
|
417 RSC_DOCKINGWINDOW_Y
) & nMask
)
419 // Groessenangabe aus der Resource verwenden
421 MapUnit ePosMap
= MAP_PIXEL
;
423 if ( RSC_DOCKINGWINDOW_XYMAPMODE
& nMask
)
424 ePosMap
= (MapUnit
)ReadLongRes();
426 if ( RSC_DOCKINGWINDOW_X
& nMask
)
428 aPos
.X() = ReadShortRes();
429 aPos
.X() = ImplLogicUnitToPixelX( aPos
.X(), ePosMap
);
432 if ( RSC_DOCKINGWINDOW_Y
& nMask
)
434 aPos
.Y() = ReadShortRes();
435 aPos
.Y() = ImplLogicUnitToPixelY( aPos
.Y(), ePosMap
);
438 SetFloatingPos( aPos
);
441 if ( nMask
& RSC_DOCKINGWINDOW_FLOATING
)
443 if ( (BOOL
)ReadShortRes() )
444 SetFloatingMode( TRUE
);
448 // -----------------------------------------------------------------------
450 DockingWindow::DockingWindow( WindowType nType
) :
453 ImplInitDockingWindowData();
456 // -----------------------------------------------------------------------
458 DockingWindow::DockingWindow( Window
* pParent
, WinBits nStyle
) :
459 Window( WINDOW_DOCKINGWINDOW
)
461 ImplInitDockingWindowData();
462 ImplInit( pParent
, nStyle
);
465 // -----------------------------------------------------------------------
467 DockingWindow::DockingWindow( Window
* pParent
, const ResId
& rResId
) :
468 Window( WINDOW_DOCKINGWINDOW
)
470 ImplInitDockingWindowData();
471 rResId
.SetRT( RSC_DOCKINGWINDOW
);
472 WinBits nStyle
= ImplInitRes( rResId
);
473 ImplInit( pParent
, nStyle
);
474 ImplLoadRes( rResId
);
476 if ( !(nStyle
& WB_HIDE
) )
480 // -----------------------------------------------------------------------
482 DockingWindow::~DockingWindow()
484 if ( IsFloatingMode() )
486 Show( FALSE
, SHOW_NOFOCUSCHANGE
);
487 SetFloatingMode( FALSE
);
492 // -----------------------------------------------------------------------
494 void DockingWindow::Tracking( const TrackingEvent
& rTEvt
)
496 if( GetDockingManager()->IsDockable( this ) ) // new docking interface
497 return Window::Tracking( rTEvt
);
501 if ( rTEvt
.IsTrackingEnded() )
506 // Bei Abbruch alten Zustand wieder herstellen
507 if ( rTEvt
.IsTrackingCanceled() )
510 Rectangle
aRect( Point( mnTrackX
, mnTrackY
), Size( mnTrackWidth
, mnTrackHeight
) );
511 EndDocking( aRect
, mbStartFloat
);
517 if ( rTEvt
.IsTrackingCanceled() )
519 mbDockCanceled
= TRUE
;
520 EndDocking( Rectangle( Point( mnTrackX
, mnTrackY
), Size( mnTrackWidth
, mnTrackHeight
) ), mbLastFloatMode
);
521 mbDockCanceled
= FALSE
;
524 EndDocking( Rectangle( Point( mnTrackX
, mnTrackY
), Size( mnTrackWidth
, mnTrackHeight
) ), mbLastFloatMode
);
527 // Docking nur bei nicht synthetischen MouseEvents
528 else if ( !rTEvt
.GetMouseEvent().IsSynthetic() || rTEvt
.GetMouseEvent().IsModifierChanged() )
530 Point aMousePos
= rTEvt
.GetMouseEvent().GetPosPixel();
531 Point aFrameMousePos
= ImplOutputToFrame( aMousePos
);
532 Size aFrameSize
= mpWindowImpl
->mpFrameWindow
->GetOutputSizePixel();
533 if ( aFrameMousePos
.X() < 0 )
534 aFrameMousePos
.X() = 0;
535 if ( aFrameMousePos
.Y() < 0 )
536 aFrameMousePos
.Y() = 0;
537 if ( aFrameMousePos
.X() > aFrameSize
.Width()-1 )
538 aFrameMousePos
.X() = aFrameSize
.Width()-1;
539 if ( aFrameMousePos
.Y() > aFrameSize
.Height()-1 )
540 aFrameMousePos
.Y() = aFrameSize
.Height()-1;
541 aMousePos
= ImplFrameToOutput( aFrameMousePos
);
542 aMousePos
.X() -= maMouseOff
.X();
543 aMousePos
.Y() -= maMouseOff
.Y();
544 Point aFramePos
= ImplOutputToFrame( aMousePos
);
545 Rectangle
aTrackRect( aFramePos
, Size( mnTrackWidth
, mnTrackHeight
) );
546 Rectangle aCompRect
= aTrackRect
;
547 aFramePos
.X() += maMouseOff
.X();
548 aFramePos
.Y() += maMouseOff
.Y();
551 BOOL bFloatMode
= Docking( aFramePos
, aTrackRect
);
552 mbDockPrevented
= FALSE
;
553 mbFloatPrevented
= FALSE
;
554 if ( mbLastFloatMode
!= bFloatMode
)
558 aTrackRect
.Left() -= mnDockLeft
;
559 aTrackRect
.Top() -= mnDockTop
;
560 aTrackRect
.Right() += mnDockRight
;
561 aTrackRect
.Bottom() += mnDockBottom
;
565 if ( aCompRect
== aTrackRect
)
567 aTrackRect
.Left() += mnDockLeft
;
568 aTrackRect
.Top() += mnDockTop
;
569 aTrackRect
.Right() -= mnDockRight
;
570 aTrackRect
.Bottom() -= mnDockBottom
;
573 mbLastFloatMode
= bFloatMode
;
578 Point aOldPos
= OutputToScreenPixel( aPos
);
579 EndDocking( aTrackRect
, mbLastFloatMode
);
580 // Wenn der Status bzw. die Position sich
581 // geaendert hat, dann neu ausgeben
582 if ( aOldPos
!= OutputToScreenPixel( aPos
) )
585 ImplGetFrameWindow()->ImplUpdateAll();
587 // EndDocking( aTrackRect, mbLastFloatMode );
593 nTrackStyle
= SHOWTRACK_BIG
;
595 nTrackStyle
= SHOWTRACK_OBJECT
;
596 Rectangle aShowTrackRect
= aTrackRect
;
597 aShowTrackRect
.SetPos( ImplFrameToOutput( aShowTrackRect
.TopLeft() ) );
598 ShowTracking( aShowTrackRect
, nTrackStyle
);
600 // Maus-Offset neu berechnen, da Rechteck veraendert werden
602 maMouseOff
.X() = aFramePos
.X() - aTrackRect
.Left();
603 maMouseOff
.Y() = aFramePos
.Y() - aTrackRect
.Top();
606 mnTrackX
= aTrackRect
.Left();
607 mnTrackY
= aTrackRect
.Top();
608 mnTrackWidth
= aTrackRect
.GetWidth();
609 mnTrackHeight
= aTrackRect
.GetHeight();
614 // -----------------------------------------------------------------------
616 long DockingWindow::Notify( NotifyEvent
& rNEvt
)
618 if( GetDockingManager()->IsDockable( this ) ) // new docking interface
619 return Window::Notify( rNEvt
);
623 if ( rNEvt
.GetType() == EVENT_MOUSEBUTTONDOWN
)
625 const MouseEvent
* pMEvt
= rNEvt
.GetMouseEvent();
626 if ( pMEvt
->IsLeft() )
628 if ( pMEvt
->IsMod1() && (pMEvt
->GetClicks() == 2) )
630 SetFloatingMode( !IsFloatingMode() );
633 else if ( pMEvt
->GetClicks() == 1 )
635 // check if window is floating standalone (IsFloating())
636 // or only partially floating and still docked with one border
637 // ( !mpWindowImpl->mbFrame)
638 if( ! IsFloatingMode() || ! mpFloatWin
->mpWindowImpl
->mbFrame
)
640 Point aPos
= pMEvt
->GetPosPixel();
641 Window
* pWindow
= rNEvt
.GetWindow();
642 if ( pWindow
!= this )
644 aPos
= pWindow
->OutputToScreenPixel( aPos
);
645 aPos
= ScreenToOutputPixel( aPos
);
647 ImplStartDocking( aPos
);
653 else if( rNEvt
.GetType() == EVENT_KEYINPUT
)
655 const KeyCode
& rKey
= rNEvt
.GetKeyEvent()->GetKeyCode();
656 if( rKey
.GetCode() == KEY_F10
&& rKey
.GetModifier() &&
657 rKey
.IsShift() && rKey
.IsMod1() )
659 SetFloatingMode( !IsFloatingMode() );
665 return Window::Notify( rNEvt
);
668 // -----------------------------------------------------------------------
670 void DockingWindow::StartDocking()
675 // -----------------------------------------------------------------------
677 BOOL
DockingWindow::Docking( const Point
&, Rectangle
& )
679 return IsFloatingMode();
682 // -----------------------------------------------------------------------
684 void DockingWindow::EndDocking( const Rectangle
& rRect
, BOOL bFloatMode
)
686 if ( !IsDockingCanceled() )
689 if ( bFloatMode
!= IsFloatingMode() )
691 Show( FALSE
, SHOW_NOFOCUSCHANGE
);
692 SetFloatingMode( bFloatMode
);
694 if ( bFloatMode
&& mpFloatWin
)
695 mpFloatWin
->SetPosSizePixel( rRect
.TopLeft(), rRect
.GetSize() );
699 Point aPos
= rRect
.TopLeft();
700 aPos
= GetParent()->ScreenToOutputPixel( aPos
);
701 Window::SetPosSizePixel( aPos
, rRect
.GetSize() );
710 // -----------------------------------------------------------------------
712 BOOL
DockingWindow::PrepareToggleFloatingMode()
717 // -----------------------------------------------------------------------
719 BOOL
DockingWindow::Close()
721 ImplDelData aDelData
;
722 ImplAddDel( &aDelData
);
723 ImplCallEventListeners( VCLEVENT_WINDOW_CLOSE
);
724 if ( aDelData
.IsDelete() )
726 ImplRemoveDel( &aDelData
);
728 if ( mpWindowImpl
->mxWindowPeer
.is() && IsCreatedWithToolkit() )
731 Show( FALSE
, SHOW_NOFOCUSCHANGE
);
735 // -----------------------------------------------------------------------
737 void DockingWindow::ToggleFloatingMode()
741 // -----------------------------------------------------------------------
743 void DockingWindow::TitleButtonClick( USHORT
)
747 // -----------------------------------------------------------------------
749 void DockingWindow::Pin()
753 // -----------------------------------------------------------------------
755 void DockingWindow::Roll()
759 // -----------------------------------------------------------------------
761 void DockingWindow::PopupModeEnd()
765 // -----------------------------------------------------------------------
767 void DockingWindow::Resizing( Size
& )
771 // -----------------------------------------------------------------------
773 void DockingWindow::StateChanged( StateChangedType nType
)
775 if ( nType
== STATE_CHANGE_CONTROLBACKGROUND
)
781 Window::StateChanged( nType
);
784 // -----------------------------------------------------------------------
786 void DockingWindow::DataChanged( const DataChangedEvent
& rDCEvt
)
788 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
789 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
795 Window::DataChanged( rDCEvt
);
798 // -----------------------------------------------------------------------
800 void DockingWindow::ShowTitleButton( USHORT nButton
, BOOL bVisible
)
803 mpFloatWin
->ShowTitleButton( nButton
, bVisible
);
806 if ( nButton
== TITLE_BUTTON_DOCKING
)
807 mbDockBtn
= bVisible
;
808 else /* if ( nButton == TITLE_BUTTON_HIDE ) */
809 mbHideBtn
= bVisible
;
813 // -----------------------------------------------------------------------
815 BOOL
DockingWindow::IsTitleButtonVisible( USHORT nButton
) const
818 return mpFloatWin
->IsTitleButtonVisible( nButton
);
821 if ( nButton
== TITLE_BUTTON_DOCKING
)
823 else /* if ( nButton == TITLE_BUTTON_HIDE ) */
828 // -----------------------------------------------------------------------
830 void DockingWindow::SetFloatingMode( BOOL bFloatMode
)
832 ImplDockingWindowWrapper
*pWrapper
= ImplGetDockingManager()->GetDockingWindowWrapper( this );
835 pWrapper
->SetFloatingMode( bFloatMode
);
838 if ( IsFloatingMode() != bFloatMode
)
840 if ( PrepareToggleFloatingMode() ) // changes to floating mode can be vetoed
842 BOOL bVisible
= IsVisible();
846 Show( FALSE
, SHOW_NOFOCUSCHANGE
);
848 maDockPos
= Window::GetPosPixel();
850 Window
* pRealParent
= mpWindowImpl
->mpRealParent
;
851 mpOldBorderWin
= mpWindowImpl
->mpBorderWindow
;
853 ImplDockFloatWin
* pWin
=
854 new ImplDockFloatWin(
855 mpImplData
->mpParent
,
856 mnFloatBits
& ( WB_MOVEABLE
| WB_SIZEABLE
| WB_CLOSEABLE
) ? mnFloatBits
| WB_SYSTEMWINDOW
: mnFloatBits
,
859 mpWindowImpl
->mpBorderWindow
= NULL
;
860 mpWindowImpl
->mnLeftBorder
= 0;
861 mpWindowImpl
->mnTopBorder
= 0;
862 mpWindowImpl
->mnRightBorder
= 0;
863 mpWindowImpl
->mnBottomBorder
= 0;
864 // Falls Parent zerstoert wird, muessen wir auch vom
865 // BorderWindow den Parent umsetzen
866 if ( mpOldBorderWin
)
867 mpOldBorderWin
->SetParent( pWin
);
869 SetPosPixel( Point() );
870 mpWindowImpl
->mpBorderWindow
= pWin
;
871 pWin
->mpWindowImpl
->mpClientWindow
= this;
872 mpWindowImpl
->mpRealParent
= pRealParent
;
873 pWin
->SetText( Window::GetText() );
874 pWin
->SetOutputSizePixel( Window::GetSizePixel() );
875 pWin
->SetPosPixel( maFloatPos
);
876 // DockingDaten ans FloatingWindow weiterreichen
877 pWin
->ShowTitleButton( TITLE_BUTTON_DOCKING
, mbDockBtn
);
878 pWin
->ShowTitleButton( TITLE_BUTTON_HIDE
, mbHideBtn
);
879 pWin
->SetPin( mbPined
);
884 pWin
->SetRollUpOutputSizePixel( maRollUpOutSize
);
885 pWin
->SetMinOutputSizePixel( maMinOutSize
);
886 pWin
->SetMaxOutputSizePixel( mpImplData
->maMaxOutSize
);
888 ToggleFloatingMode();
895 Show( FALSE
, SHOW_NOFOCUSCHANGE
);
897 // FloatingDaten wird im FloatingWindow speichern
898 maFloatPos
= mpFloatWin
->GetPosPixel();
899 mbDockBtn
= mpFloatWin
->IsTitleButtonVisible( TITLE_BUTTON_DOCKING
);
900 mbHideBtn
= mpFloatWin
->IsTitleButtonVisible( TITLE_BUTTON_HIDE
);
901 mbPined
= mpFloatWin
->IsPined();
902 mbRollUp
= mpFloatWin
->IsRollUp();
903 maRollUpOutSize
= mpFloatWin
->GetRollUpOutputSizePixel();
904 maMinOutSize
= mpFloatWin
->GetMinOutputSizePixel();
905 mpImplData
->maMaxOutSize
= mpFloatWin
->GetMaxOutputSizePixel();
907 Window
* pRealParent
= mpWindowImpl
->mpRealParent
;
908 mpWindowImpl
->mpBorderWindow
= NULL
;
909 if ( mpOldBorderWin
)
911 SetParent( mpOldBorderWin
);
912 ((ImplBorderWindow
*)mpOldBorderWin
)->GetBorder( mpWindowImpl
->mnLeftBorder
, mpWindowImpl
->mnTopBorder
, mpWindowImpl
->mnRightBorder
, mpWindowImpl
->mnBottomBorder
);
913 mpOldBorderWin
->Resize();
915 mpWindowImpl
->mpBorderWindow
= mpOldBorderWin
;
916 SetParent( pRealParent
);
917 mpWindowImpl
->mpRealParent
= pRealParent
;
918 delete static_cast<ImplDockFloatWin
*>(mpFloatWin
);
920 SetPosPixel( maDockPos
);
922 ToggleFloatingMode();
931 // -----------------------------------------------------------------------
933 void DockingWindow::SetFloatStyle( WinBits nStyle
)
935 ImplDockingWindowWrapper
*pWrapper
= ImplGetDockingManager()->GetDockingWindowWrapper( this );
938 pWrapper
->SetFloatStyle( nStyle
);
942 mnFloatBits
= nStyle
;
945 // -----------------------------------------------------------------------
947 WinBits
DockingWindow::GetFloatStyle() const
949 ImplDockingWindowWrapper
*pWrapper
= ImplGetDockingManager()->GetDockingWindowWrapper( this );
952 return pWrapper
->GetFloatStyle();
958 // -----------------------------------------------------------------------
960 void DockingWindow::SetTabStop()
962 ImplDockingWindowWrapper
*pWrapper
= ImplGetDockingManager()->GetDockingWindowWrapper( this );
965 pWrapper
->SetTabStop();
969 mpWindowImpl
->mnStyle
|= WB_GROUP
| WB_TABSTOP
;
972 // -----------------------------------------------------------------------
974 void DockingWindow::SetPosSizePixel( long nX
, long nY
,
975 long nWidth
, long nHeight
,
978 ImplDockingWindowWrapper
*pWrapper
= ImplGetDockingManager()->GetDockingWindowWrapper( this );
981 if ( pWrapper
->mpFloatWin
)
982 pWrapper
->mpFloatWin
->SetPosSizePixel( nX
, nY
, nWidth
, nHeight
, nFlags
);
984 Window::SetPosSizePixel( nX
, nY
, nWidth
, nHeight
, nFlags
);
989 mpFloatWin
->SetPosSizePixel( nX
, nY
, nWidth
, nHeight
, nFlags
);
991 Window::SetPosSizePixel( nX
, nY
, nWidth
, nHeight
, nFlags
);
994 // -----------------------------------------------------------------------
996 Point
DockingWindow::GetPosPixel() const
998 ImplDockingWindowWrapper
*pWrapper
= ImplGetDockingManager()->GetDockingWindowWrapper( this );
1001 if ( pWrapper
->mpFloatWin
)
1002 return pWrapper
->mpFloatWin
->GetPosPixel();
1004 return Window::GetPosPixel();
1008 return mpFloatWin
->GetPosPixel();
1010 return Window::GetPosPixel();
1013 // -----------------------------------------------------------------------
1015 Size
DockingWindow::GetSizePixel() const
1017 ImplDockingWindowWrapper
*pWrapper
= ImplGetDockingManager()->GetDockingWindowWrapper( this );
1020 if ( pWrapper
->mpFloatWin
)
1021 return pWrapper
->mpFloatWin
->GetSizePixel();
1023 return Window::GetSizePixel();
1027 return mpFloatWin
->GetSizePixel();
1029 return Window::GetSizePixel();
1032 // -----------------------------------------------------------------------
1034 void DockingWindow::SetOutputSizePixel( const Size
& rNewSize
)
1036 ImplDockingWindowWrapper
*pWrapper
= ImplGetDockingManager()->GetDockingWindowWrapper( this );
1039 if ( pWrapper
->mpFloatWin
)
1040 pWrapper
->mpFloatWin
->SetOutputSizePixel( rNewSize
);
1042 Window::SetOutputSizePixel( rNewSize
);
1047 mpFloatWin
->SetOutputSizePixel( rNewSize
);
1049 Window::SetOutputSizePixel( rNewSize
);
1052 // -----------------------------------------------------------------------
1054 Size
DockingWindow::GetOutputSizePixel() const
1056 ImplDockingWindowWrapper
*pWrapper
= ImplGetDockingManager()->GetDockingWindowWrapper( this );
1059 if ( pWrapper
->mpFloatWin
)
1060 return pWrapper
->mpFloatWin
->GetOutputSizePixel();
1062 return Window::GetOutputSizePixel();
1066 return mpFloatWin
->GetOutputSizePixel();
1068 return Window::GetOutputSizePixel();
1071 Point
DockingWindow::GetFloatingPos() const
1073 ImplDockingWindowWrapper
*pWrapper
= ImplGetDockingManager()->GetDockingWindowWrapper( this );
1076 if ( pWrapper
->mpFloatWin
)
1078 WindowStateData aData
;
1079 aData
.SetMask( WINDOWSTATE_MASK_POS
);
1080 pWrapper
->mpFloatWin
->GetWindowStateData( aData
);
1081 Point
aPos( aData
.GetX(), aData
.GetY() );
1082 aPos
= pWrapper
->mpFloatWin
->GetParent()->ImplGetFrameWindow()->AbsoluteScreenToOutputPixel( aPos
);
1091 WindowStateData aData
;
1092 aData
.SetMask( WINDOWSTATE_MASK_POS
);
1093 mpFloatWin
->GetWindowStateData( aData
);
1094 Point
aPos( aData
.GetX(), aData
.GetY() );
1095 aPos
= mpFloatWin
->GetParent()->ImplGetFrameWindow()->AbsoluteScreenToOutputPixel( aPos
);
1102 BOOL
DockingWindow::IsFloatingMode() const
1104 ImplDockingWindowWrapper
*pWrapper
= ImplGetDockingManager()->GetDockingWindowWrapper( this );
1106 return pWrapper
->IsFloatingMode();
1108 return (mpFloatWin
!= NULL
);
1111 void DockingWindow::SetMaxOutputSizePixel( const Size
& rSize
)
1114 mpFloatWin
->SetMaxOutputSizePixel( rSize
);
1115 mpImplData
->maMaxOutSize
= rSize
;
1118 const Size
& DockingWindow::GetMaxOutputSizePixel() const
1121 return mpFloatWin
->GetMaxOutputSizePixel();
1122 return mpImplData
->maMaxOutSize
;