merge the formfield patch from ooo-build
[ooovba.git] / vcl / source / window / dockwin.cxx
blobb06c4d3d5d2d135994e3c865d1cd5c82a66ca380
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dockwin.cxx,v $
10 * $Revision: 1.29 $
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"
34 #ifndef _SV_SVSYS_HXX
35 #include <svsys.h>
36 #endif
37 #include <tools/time.hxx>
38 #ifndef _SV_RC_H
39 #include <tools/rc.h>
40 #endif
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
64 public:
65 ImplData();
66 ~ImplData();
68 Window* mpParent;
69 Size maMaxOutSize;
72 DockingWindow::ImplData::ImplData()
74 mpParent = NULL;
75 maMaxOutSize = Size( SHRT_MAX, SHRT_MAX );
78 DockingWindow::ImplData::~ImplData()
82 // -----------------------------------------------------------------------
84 class ImplDockFloatWin : public FloatingWindow
86 private:
87 DockingWindow* mpDockWin;
88 ULONG mnLastTicks;
89 Timer maDockTimer;
90 Point maDockPos;
91 Rectangle maDockRect;
92 BOOL mbInMove;
93 ULONG mnLastUserEvent;
95 DECL_LINK( DockingHdl, ImplDockFloatWin* );
96 DECL_LINK( DockTimerHdl, ImplDockFloatWin* );
97 public:
98 ImplDockFloatWin( Window* pParent, WinBits nWinBits,
99 DockingWindow* pDockingWin );
100 ~ImplDockFloatWin();
102 virtual void Move();
103 virtual void Resize();
104 virtual void TitleButtonClick( USHORT nButton );
105 virtual void Pin();
106 virtual void Roll();
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() ),
120 mbInMove( FALSE ),
121 mnLastUserEvent( 0 )
123 // Daten vom DockingWindow uebernehmen
124 if ( pDockingWin )
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() );
134 SetBackground();
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" );
154 maDockTimer.Stop();
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 ) )
163 maDockTimer.Start();
165 else if( ! ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) )
167 mpDockWin->GetParent()->ImplGetFrameWindow()->HideTracking();
168 mpDockWin->EndDocking( maDockRect, FALSE );
170 else
172 mpDockWin->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect, SHOWTRACK_BIG | SHOWTRACK_WINDOW );
173 maDockTimer.Start();
176 return 0;
179 IMPL_LINK( ImplDockFloatWin, DockingHdl, ImplDockFloatWin*, EMPTYARG )
181 PointerState aState = mpDockWin->GetParent()->GetPointerState();
183 mnLastUserEvent = 0;
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 );
200 if( ! bFloatMode )
202 mpDockWin->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect, SHOWTRACK_OBJECT | SHOWTRACK_WINDOW );
203 DockTimerHdl( this );
205 else
207 mpDockWin->GetParent()->ImplGetFrameWindow()->HideTracking();
208 maDockTimer.Stop();
209 mpDockWin->EndDocking( maDockRect, TRUE );
212 mbInMove = FALSE;
213 return 0;
215 // -----------------------------------------------------------------------
217 void ImplDockFloatWin::Move()
219 if( mbInMove )
220 return;
222 mbInMove = TRUE;
223 FloatingWindow::Move();
224 mpDockWin->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
233 * last Move message.
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();
261 mpDockWin->Pin();
264 // -----------------------------------------------------------------------
266 void ImplDockFloatWin::Roll()
268 FloatingWindow::Roll();
269 mpDockWin->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 )
299 if ( !mbDockable )
300 return FALSE;
302 maMouseOff = rPos;
303 maMouseStart = maMouseOff;
304 mbDocking = TRUE;
305 mbLastFloatMode = IsFloatingMode();
306 mbStartFloat = mbLastFloatMode;
308 // FloatingBorder berechnen
309 FloatingWindow* pWin;
310 if ( mpFloatWin )
311 pWin = mpFloatWin;
312 else
313 pWin = new ImplDockFloatWin( mpImplData->mpParent, mnFloatBits, NULL );
314 pWin->GetBorder( mnDockLeft, mnDockTop, mnDockRight, mnDockBottom );
315 if ( !mpFloatWin )
316 delete pWin;
318 Point aPos = ImplOutputToFrame( Point() );
319 Size aSize = Window::GetOutputSizePixel();
320 mnTrackX = aPos.X();
321 mnTrackY = aPos.Y();
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
337 mbDragFull = TRUE;
338 else
340 StartDocking();
341 mbDragFull = FALSE;
342 ImplUpdateAll();
343 ImplGetFrameWindow()->ImplUpdateAll();
346 StartTracking( STARTTRACK_KEYMOD );
347 return TRUE;
350 // =======================================================================
352 void DockingWindow::ImplInitDockingWindowData()
354 mpImplData = new ImplData;
355 mpWindowImpl->mbDockWin = TRUE;
357 mpFloatWin = NULL;
358 mbDockCanceled = FALSE;
359 mbDockPrevented = FALSE;
360 mbFloatPrevented = FALSE;
361 mbDocking = FALSE;
362 mbPined = FALSE;
363 mbRollUp = FALSE;
364 mbDockBtn = FALSE;
365 mbHideBtn = 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 )
380 nStyle |= WB_BORDER;
382 Window::ImplInit( pParent, nStyle, NULL );
384 ImplInitSettings();
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();
397 Color aColor;
398 if ( IsControlBackground() )
399 aColor = GetControlBackground();
400 else if ( Window::GetStyle() & WB_3DLOOK )
401 aColor = rStyleSettings.GetFaceColor();
402 else
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
420 Point aPos;
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 ) :
451 Window( 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) )
477 Show();
480 // -----------------------------------------------------------------------
482 DockingWindow::~DockingWindow()
484 if ( IsFloatingMode() )
486 Show( FALSE, SHOW_NOFOCUSCHANGE );
487 SetFloatingMode( FALSE );
489 delete mpImplData;
492 // -----------------------------------------------------------------------
494 void DockingWindow::Tracking( const TrackingEvent& rTEvt )
496 if( GetDockingManager()->IsDockable( this ) ) // new docking interface
497 return Window::Tracking( rTEvt );
499 if ( mbDocking )
501 if ( rTEvt.IsTrackingEnded() )
503 mbDocking = FALSE;
504 if ( mbDragFull )
506 // Bei Abbruch alten Zustand wieder herstellen
507 if ( rTEvt.IsTrackingCanceled() )
509 StartDocking();
510 Rectangle aRect( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) );
511 EndDocking( aRect, mbStartFloat );
514 else
516 HideTracking();
517 if ( rTEvt.IsTrackingCanceled() )
519 mbDockCanceled = TRUE;
520 EndDocking( Rectangle( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) ), mbLastFloatMode );
521 mbDockCanceled = FALSE;
523 else
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();
549 if ( mbDragFull )
550 StartDocking();
551 BOOL bFloatMode = Docking( aFramePos, aTrackRect );
552 mbDockPrevented = FALSE;
553 mbFloatPrevented = FALSE;
554 if ( mbLastFloatMode != bFloatMode )
556 if ( bFloatMode )
558 aTrackRect.Left() -= mnDockLeft;
559 aTrackRect.Top() -= mnDockTop;
560 aTrackRect.Right() += mnDockRight;
561 aTrackRect.Bottom() += mnDockBottom;
563 else
565 if ( aCompRect == aTrackRect )
567 aTrackRect.Left() += mnDockLeft;
568 aTrackRect.Top() += mnDockTop;
569 aTrackRect.Right() -= mnDockRight;
570 aTrackRect.Bottom() -= mnDockBottom;
573 mbLastFloatMode = bFloatMode;
575 if ( mbDragFull )
577 Point aPos;
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 ) )
584 ImplUpdateAll();
585 ImplGetFrameWindow()->ImplUpdateAll();
587 // EndDocking( aTrackRect, mbLastFloatMode );
589 else
591 USHORT nTrackStyle;
592 if ( bFloatMode )
593 nTrackStyle = SHOWTRACK_BIG;
594 else
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
601 // konnte
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 );
621 if ( mbDockable )
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() );
631 return TRUE;
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 );
649 return TRUE;
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() );
660 return TRUE;
665 return Window::Notify( rNEvt );
668 // -----------------------------------------------------------------------
670 void DockingWindow::StartDocking()
672 mbDocking = TRUE;
675 // -----------------------------------------------------------------------
677 BOOL DockingWindow::Docking( const Point&, Rectangle& )
679 return IsFloatingMode();
682 // -----------------------------------------------------------------------
684 void DockingWindow::EndDocking( const Rectangle& rRect, BOOL bFloatMode )
686 if ( !IsDockingCanceled() )
688 BOOL bShow = FALSE;
689 if ( bFloatMode != IsFloatingMode() )
691 Show( FALSE, SHOW_NOFOCUSCHANGE );
692 SetFloatingMode( bFloatMode );
693 bShow = TRUE;
694 if ( bFloatMode && mpFloatWin )
695 mpFloatWin->SetPosSizePixel( rRect.TopLeft(), rRect.GetSize() );
697 if ( !bFloatMode )
699 Point aPos = rRect.TopLeft();
700 aPos = GetParent()->ScreenToOutputPixel( aPos );
701 Window::SetPosSizePixel( aPos, rRect.GetSize() );
704 if ( bShow )
705 Show();
707 mbDocking = FALSE;
710 // -----------------------------------------------------------------------
712 BOOL DockingWindow::PrepareToggleFloatingMode()
714 return TRUE;
717 // -----------------------------------------------------------------------
719 BOOL DockingWindow::Close()
721 ImplDelData aDelData;
722 ImplAddDel( &aDelData );
723 ImplCallEventListeners( VCLEVENT_WINDOW_CLOSE );
724 if ( aDelData.IsDelete() )
725 return FALSE;
726 ImplRemoveDel( &aDelData );
728 if ( mpWindowImpl->mxWindowPeer.is() && IsCreatedWithToolkit() )
729 return FALSE;
731 Show( FALSE, SHOW_NOFOCUSCHANGE );
732 return TRUE;
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 )
777 ImplInitSettings();
778 Invalidate();
781 Window::StateChanged( nType );
784 // -----------------------------------------------------------------------
786 void DockingWindow::DataChanged( const DataChangedEvent& rDCEvt )
788 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
789 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
791 ImplInitSettings();
792 Invalidate();
794 else
795 Window::DataChanged( rDCEvt );
798 // -----------------------------------------------------------------------
800 void DockingWindow::ShowTitleButton( USHORT nButton, BOOL bVisible )
802 if ( mpFloatWin )
803 mpFloatWin->ShowTitleButton( nButton, bVisible );
804 else
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
817 if ( mpFloatWin )
818 return mpFloatWin->IsTitleButtonVisible( nButton );
819 else
821 if ( nButton == TITLE_BUTTON_DOCKING )
822 return mbDockBtn;
823 else /* if ( nButton == TITLE_BUTTON_HIDE ) */
824 return mbHideBtn;
828 // -----------------------------------------------------------------------
830 void DockingWindow::SetFloatingMode( BOOL bFloatMode )
832 ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
833 if( pWrapper )
835 pWrapper->SetFloatingMode( bFloatMode );
836 return;
838 if ( IsFloatingMode() != bFloatMode )
840 if ( PrepareToggleFloatingMode() ) // changes to floating mode can be vetoed
842 BOOL bVisible = IsVisible();
844 if ( bFloatMode )
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,
857 this );
858 mpFloatWin = pWin;
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 );
868 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 );
880 if ( mbRollUp )
881 pWin->RollUp();
882 else
883 pWin->RollDown();
884 pWin->SetRollUpOutputSizePixel( maRollUpOutSize );
885 pWin->SetMinOutputSizePixel( maMinOutSize );
886 pWin->SetMaxOutputSizePixel( mpImplData->maMaxOutSize );
888 ToggleFloatingMode();
890 if ( bVisible )
891 Show();
893 else
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);
919 mpFloatWin = NULL;
920 SetPosPixel( maDockPos );
922 ToggleFloatingMode();
924 if ( bVisible )
925 Show();
931 // -----------------------------------------------------------------------
933 void DockingWindow::SetFloatStyle( WinBits nStyle )
935 ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
936 if( pWrapper )
938 pWrapper->SetFloatStyle( nStyle );
939 return;
942 mnFloatBits = nStyle;
945 // -----------------------------------------------------------------------
947 WinBits DockingWindow::GetFloatStyle() const
949 ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
950 if( pWrapper )
952 return pWrapper->GetFloatStyle();
955 return mnFloatBits;
958 // -----------------------------------------------------------------------
960 void DockingWindow::SetTabStop()
962 ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
963 if( pWrapper )
965 pWrapper->SetTabStop();
966 return;
969 mpWindowImpl->mnStyle |= WB_GROUP | WB_TABSTOP;
972 // -----------------------------------------------------------------------
974 void DockingWindow::SetPosSizePixel( long nX, long nY,
975 long nWidth, long nHeight,
976 USHORT nFlags )
978 ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
979 if( pWrapper )
981 if ( pWrapper->mpFloatWin )
982 pWrapper->mpFloatWin->SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
983 else
984 Window::SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
985 return;
988 if ( mpFloatWin )
989 mpFloatWin->SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
990 else
991 Window::SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
994 // -----------------------------------------------------------------------
996 Point DockingWindow::GetPosPixel() const
998 ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
999 if( pWrapper )
1001 if ( pWrapper->mpFloatWin )
1002 return pWrapper->mpFloatWin->GetPosPixel();
1003 else
1004 return Window::GetPosPixel();
1007 if ( mpFloatWin )
1008 return mpFloatWin->GetPosPixel();
1009 else
1010 return Window::GetPosPixel();
1013 // -----------------------------------------------------------------------
1015 Size DockingWindow::GetSizePixel() const
1017 ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
1018 if( pWrapper )
1020 if ( pWrapper->mpFloatWin )
1021 return pWrapper->mpFloatWin->GetSizePixel();
1022 else
1023 return Window::GetSizePixel();
1026 if ( mpFloatWin )
1027 return mpFloatWin->GetSizePixel();
1028 else
1029 return Window::GetSizePixel();
1032 // -----------------------------------------------------------------------
1034 void DockingWindow::SetOutputSizePixel( const Size& rNewSize )
1036 ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
1037 if( pWrapper )
1039 if ( pWrapper->mpFloatWin )
1040 pWrapper->mpFloatWin->SetOutputSizePixel( rNewSize );
1041 else
1042 Window::SetOutputSizePixel( rNewSize );
1043 return;
1046 if ( mpFloatWin )
1047 mpFloatWin->SetOutputSizePixel( rNewSize );
1048 else
1049 Window::SetOutputSizePixel( rNewSize );
1052 // -----------------------------------------------------------------------
1054 Size DockingWindow::GetOutputSizePixel() const
1056 ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
1057 if( pWrapper )
1059 if ( pWrapper->mpFloatWin )
1060 return pWrapper->mpFloatWin->GetOutputSizePixel();
1061 else
1062 return Window::GetOutputSizePixel();
1065 if ( mpFloatWin )
1066 return mpFloatWin->GetOutputSizePixel();
1067 else
1068 return Window::GetOutputSizePixel();
1071 Point DockingWindow::GetFloatingPos() const
1073 ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
1074 if( pWrapper )
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 );
1083 return aPos;
1085 else
1086 return maFloatPos;
1089 if ( mpFloatWin )
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 );
1096 return aPos;
1098 else
1099 return maFloatPos;
1102 BOOL DockingWindow::IsFloatingMode() const
1104 ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
1105 if( pWrapper )
1106 return pWrapper->IsFloatingMode();
1107 else
1108 return (mpFloatWin != NULL);
1111 void DockingWindow::SetMaxOutputSizePixel( const Size& rSize )
1113 if ( mpFloatWin )
1114 mpFloatWin->SetMaxOutputSizePixel( rSize );
1115 mpImplData->maMaxOutSize = rSize;
1118 const Size& DockingWindow::GetMaxOutputSizePixel() const
1120 if ( mpFloatWin )
1121 return mpFloatWin->GetMaxOutputSizePixel();
1122 return mpImplData->maMaxOutSize;