update dev300-m58
[ooovba.git] / vcl / source / window / window2.cxx
blob3837d075c148dc4d6592b59879d607713cc934af
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: window2.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 #include <limits.h>
35 #ifndef _SV_SVSYS_HXX
36 #include <svsys.h>
37 #endif
38 #include <vcl/salbmp.hxx>
39 #include <vcl/salgdi.hxx>
40 #include <vcl/salframe.hxx>
41 #include <tools/debug.hxx>
42 #include <vcl/svdata.hxx>
43 #include <vcl/impbmp.hxx>
44 #include <vcl/bitmap.hxx>
45 #include <vcl/event.hxx>
46 #include <vcl/timer.hxx>
47 #include <vcl/metric.hxx>
48 #include <vcl/outfont.hxx>
49 #include <vcl/outdev.h>
50 #include <tools/poly.hxx>
51 #include <vcl/virdev.hxx>
52 #include <vcl/window.h>
53 #include <vcl/window.hxx>
54 #include <vcl/scrbar.hxx>
55 #ifndef _SV_SCRWND_HXX
56 #include <scrwnd.hxx>
57 #endif
58 #include <vcl/dockwin.hxx>
62 // =======================================================================
64 DBG_NAMEEX( Window )
66 // =======================================================================
68 #define IMPL_MAXSAVEBACKSIZE (640*480)
69 #define IMPL_MAXALLSAVEBACKSIZE (800*600*2)
71 // =======================================================================
73 struct ImplFocusDelData : public ImplDelData
75 Window* mpFocusWin;
78 // =======================================================================
80 BOOL Window::ImplIsWindowInFront( const Window* pTestWindow ) const
82 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
83 DBG_CHKOBJ( pTestWindow, Window, ImplDbgCheckWindow );
85 // Testen, ob es Fenster untereinander liegen
86 pTestWindow = pTestWindow->ImplGetFirstOverlapWindow();
87 const Window* pTempWindow = pTestWindow;
88 const Window* pThisWindow = ImplGetFirstOverlapWindow();
89 if ( pTempWindow == pThisWindow )
90 return FALSE;
93 if ( pTempWindow == pThisWindow )
94 return TRUE;
95 if ( pTempWindow->mpWindowImpl->mbFrame )
96 break;
97 pTempWindow = pTempWindow->mpWindowImpl->mpOverlapWindow;
99 while ( pTempWindow );
100 pTempWindow = pThisWindow;
103 if ( pTempWindow == pTestWindow )
104 return FALSE;
105 if ( pTempWindow->mpWindowImpl->mbFrame )
106 break;
107 pTempWindow = pTempWindow->mpWindowImpl->mpOverlapWindow;
109 while ( pTempWindow );
111 // Fenster auf gleiche Ebene bringen
112 if ( pThisWindow->mpWindowImpl->mpOverlapWindow != pTestWindow->mpWindowImpl->mpOverlapWindow )
114 USHORT nThisLevel = 0;
115 USHORT nTestLevel = 0;
116 pTempWindow = pThisWindow;
119 nThisLevel++;
120 pTempWindow = pTempWindow->mpWindowImpl->mpOverlapWindow;
122 while ( !pTempWindow->mpWindowImpl->mbFrame );
123 pTempWindow = pTestWindow;
126 nTestLevel++;
127 pTempWindow = pTempWindow->mpWindowImpl->mpOverlapWindow;
129 while ( !pTempWindow->mpWindowImpl->mbFrame );
131 if ( nThisLevel < nTestLevel )
135 if ( pTestWindow->mpWindowImpl->mpOverlapWindow == pThisWindow->mpWindowImpl->mpOverlapWindow )
136 break;
137 if ( pTestWindow->mpWindowImpl->mbFrame )
138 break;
139 pTestWindow = pTestWindow->mpWindowImpl->mpOverlapWindow;
141 while ( pTestWindow );
143 else
147 if ( pThisWindow->mpWindowImpl->mpOverlapWindow == pTempWindow->mpWindowImpl->mpOverlapWindow )
148 break;
149 if ( pThisWindow->mpWindowImpl->mbFrame )
150 break;
151 pThisWindow = pThisWindow->mpWindowImpl->mpOverlapWindow;
153 while ( pThisWindow );
157 // Wenn TestWindow vor ThisWindow kommt, liegt es vorne
158 pTempWindow = pTestWindow;
161 if ( pTempWindow == pThisWindow )
162 return TRUE;
163 pTempWindow = pTempWindow->mpWindowImpl->mpNext;
165 while ( pTempWindow );
167 return FALSE;
170 // =======================================================================
172 void Window::ImplSaveOverlapBackground()
174 DBG_ASSERT( !mpWindowImpl->mpOverlapData->mpSaveBackDev, "Window::ImplSaveOverlapBackground() - Background already saved" );
176 if ( !mpWindowImpl->mbFrame )
178 ULONG nSaveBackSize = mnOutWidth*mnOutHeight;
179 if ( nSaveBackSize <= IMPL_MAXSAVEBACKSIZE )
181 if ( nSaveBackSize+mpWindowImpl->mpFrameData->mnAllSaveBackSize <= IMPL_MAXALLSAVEBACKSIZE )
183 Size aOutSize( mnOutWidth, mnOutHeight );
184 mpWindowImpl->mpOverlapData->mpSaveBackDev = new VirtualDevice( *mpWindowImpl->mpFrameWindow );
185 if ( mpWindowImpl->mpOverlapData->mpSaveBackDev->SetOutputSizePixel( aOutSize ) )
187 mpWindowImpl->mpFrameWindow->ImplUpdateAll();
189 if ( mpWindowImpl->mbInitWinClipRegion )
190 ImplInitWinClipRegion();
192 mpWindowImpl->mpOverlapData->mnSaveBackSize = nSaveBackSize;
193 mpWindowImpl->mpFrameData->mnAllSaveBackSize += nSaveBackSize;
194 Point aDevPt;
195 mpWindowImpl->mpFrameWindow->ImplGetFrameDev( Point( mnOutOffX, mnOutOffY ),
196 aDevPt, aOutSize,
197 *(mpWindowImpl->mpOverlapData->mpSaveBackDev) );
198 mpWindowImpl->mpOverlapData->mpNextBackWin = mpWindowImpl->mpFrameData->mpFirstBackWin;
199 mpWindowImpl->mpFrameData->mpFirstBackWin = this;
201 else
203 delete mpWindowImpl->mpOverlapData->mpSaveBackDev;
204 mpWindowImpl->mpOverlapData->mpSaveBackDev = NULL;
211 // -----------------------------------------------------------------------
213 BOOL Window::ImplRestoreOverlapBackground( Region& rInvRegion )
215 if ( mpWindowImpl->mpOverlapData->mpSaveBackDev )
217 if ( mpWindowImpl->mbInitWinClipRegion )
218 ImplInitWinClipRegion();
220 if ( mpWindowImpl->mpOverlapData->mpSaveBackDev )
222 Point aDevPt;
223 Point aDestPt( mnOutOffX, mnOutOffY );
224 Size aDevSize = mpWindowImpl->mpOverlapData->mpSaveBackDev->GetOutputSizePixel();
225 if ( mpWindowImpl->mpOverlapData->mpSaveBackRgn )
227 mpWindowImpl->mpOverlapData->mpSaveBackRgn->Intersect( mpWindowImpl->maWinClipRegion );
228 rInvRegion = mpWindowImpl->maWinClipRegion;
229 rInvRegion.Exclude( *mpWindowImpl->mpOverlapData->mpSaveBackRgn );
230 mpWindowImpl->mpFrameWindow->ImplDrawFrameDev( aDestPt, aDevPt, aDevSize,
231 *(mpWindowImpl->mpOverlapData->mpSaveBackDev),
232 *mpWindowImpl->mpOverlapData->mpSaveBackRgn );
234 else
236 mpWindowImpl->mpFrameWindow->ImplDrawFrameDev( aDestPt, aDevPt, aDevSize,
237 *(mpWindowImpl->mpOverlapData->mpSaveBackDev),
238 mpWindowImpl->maWinClipRegion );
240 ImplDeleteOverlapBackground();
243 return TRUE;
246 return FALSE;
249 // -----------------------------------------------------------------------
251 void Window::ImplDeleteOverlapBackground()
253 if ( mpWindowImpl->mpOverlapData->mpSaveBackDev )
255 mpWindowImpl->mpFrameData->mnAllSaveBackSize -= mpWindowImpl->mpOverlapData->mnSaveBackSize;
256 delete mpWindowImpl->mpOverlapData->mpSaveBackDev;
257 mpWindowImpl->mpOverlapData->mpSaveBackDev = NULL;
258 if ( mpWindowImpl->mpOverlapData->mpSaveBackRgn )
260 delete mpWindowImpl->mpOverlapData->mpSaveBackRgn;
261 mpWindowImpl->mpOverlapData->mpSaveBackRgn = NULL;
264 // Fenster aus der Liste entfernen
265 if ( mpWindowImpl->mpFrameData->mpFirstBackWin == this )
266 mpWindowImpl->mpFrameData->mpFirstBackWin = mpWindowImpl->mpOverlapData->mpNextBackWin;
267 else
269 Window* pTemp = mpWindowImpl->mpFrameData->mpFirstBackWin;
270 while ( pTemp->mpWindowImpl->mpOverlapData->mpNextBackWin != this )
271 pTemp = pTemp->mpWindowImpl->mpOverlapData->mpNextBackWin;
272 pTemp->mpWindowImpl->mpOverlapData->mpNextBackWin = mpWindowImpl->mpOverlapData->mpNextBackWin;
274 mpWindowImpl->mpOverlapData->mpNextBackWin = NULL;
278 // -----------------------------------------------------------------------
280 void Window::ImplInvalidateAllOverlapBackgrounds()
282 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
284 Window* pWindow = mpWindowImpl->mpFrameData->mpFirstBackWin;
285 while ( pWindow )
287 // Naechstes Fenster schon hier merken, da dieses Fenster in
288 // der if-Abfrage aus der Liste entfernt werden kann
289 Window* pNext = pWindow->mpWindowImpl->mpOverlapData->mpNextBackWin;
291 if ( ImplIsWindowInFront( pWindow ) )
293 Rectangle aRect1( Point( mnOutOffX, mnOutOffY ),
294 Size( mnOutWidth, mnOutHeight ) );
295 Rectangle aRect2( Point( pWindow->mnOutOffX, pWindow->mnOutOffY ),
296 Size( pWindow->mnOutWidth, pWindow->mnOutHeight ) );
297 aRect1.Intersection( aRect2 );
298 if ( !aRect1.IsEmpty() )
300 if ( !pWindow->mpWindowImpl->mpOverlapData->mpSaveBackRgn )
301 pWindow->mpWindowImpl->mpOverlapData->mpSaveBackRgn = new Region( aRect2 );
302 pWindow->mpWindowImpl->mpOverlapData->mpSaveBackRgn->Exclude( aRect1 );
303 if ( pWindow->mpWindowImpl->mpOverlapData->mpSaveBackRgn->IsEmpty() )
304 pWindow->ImplDeleteOverlapBackground();
309 pWindow = pNext;
313 // =======================================================================
315 Bitmap Window::SnapShot( BOOL bBorder ) const
317 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
319 Bitmap aBmp;
321 if ( IsReallyVisible() )
323 if ( bBorder && mpWindowImpl->mpBorderWindow )
324 aBmp = mpWindowImpl->mpBorderWindow->SnapShot();
325 else
327 ((Window*)this)->Update();
329 if ( bBorder && mpWindowImpl->mbFrame )
331 SalBitmap* pSalBmp = mpWindowImpl->mpFrame->SnapShot();
333 if ( pSalBmp )
335 ImpBitmap* pImpBmp = new ImpBitmap;
336 pImpBmp->ImplSetSalBitmap( pSalBmp );
337 aBmp.ImplSetImpBitmap( pImpBmp );
338 return aBmp;
342 mpWindowImpl->mpFrameWindow->ImplGetFrameBitmap( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ), aBmp );
346 return aBmp;
349 // -----------------------------------------------------------------------
351 Bitmap Window::SnapShot() const
353 // Should be merged in the next top level build !!!
354 return SnapShot( TRUE );
357 // -----------------------------------------------------------------------
359 void Window::ShowFocus( const Rectangle& rRect )
361 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
363 if( mpWindowImpl->mbInShowFocus )
364 return;
365 mpWindowImpl->mbInShowFocus = TRUE;
367 ImplWinData* pWinData = ImplGetWinData();
369 // native themeing suggest not to use focus rects
370 if( ! ( mpWindowImpl->mbUseNativeFocus &&
371 IsNativeWidgetEnabled() ) )
373 if ( !mpWindowImpl->mbInPaint )
375 if ( mpWindowImpl->mbFocusVisible )
377 if ( *(pWinData->mpFocusRect) == rRect )
379 mpWindowImpl->mbInShowFocus = FALSE;
380 return;
383 ImplInvertFocus( *(pWinData->mpFocusRect) );
386 ImplInvertFocus( rRect );
388 if ( !pWinData->mpFocusRect )
389 pWinData->mpFocusRect = new Rectangle( rRect );
390 else
391 *(pWinData->mpFocusRect) = rRect;
392 mpWindowImpl->mbFocusVisible = TRUE;
394 else
396 if( ! mpWindowImpl->mbNativeFocusVisible )
398 mpWindowImpl->mbNativeFocusVisible = TRUE;
399 if ( !mpWindowImpl->mbInPaint )
400 Invalidate();
403 mpWindowImpl->mbInShowFocus = FALSE;
406 // -----------------------------------------------------------------------
408 void Window::HideFocus()
410 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
412 if( mpWindowImpl->mbInHideFocus )
413 return;
414 mpWindowImpl->mbInHideFocus = TRUE;
416 // native themeing can suggest not to use focus rects
417 if( ! ( mpWindowImpl->mbUseNativeFocus &&
418 IsNativeWidgetEnabled() ) )
420 if ( !mpWindowImpl->mbFocusVisible )
422 mpWindowImpl->mbInHideFocus = FALSE;
423 return;
426 if ( !mpWindowImpl->mbInPaint )
427 ImplInvertFocus( *(ImplGetWinData()->mpFocusRect) );
428 mpWindowImpl->mbFocusVisible = FALSE;
430 else
432 if( mpWindowImpl->mbNativeFocusVisible )
434 mpWindowImpl->mbNativeFocusVisible = FALSE;
435 if ( !mpWindowImpl->mbInPaint )
436 Invalidate();
439 mpWindowImpl->mbInHideFocus = FALSE;
442 // -----------------------------------------------------------------------
444 void Window::Invert( const Rectangle& rRect, USHORT nFlags )
446 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
448 if ( !IsDeviceOutputNecessary() )
449 return;
451 Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
453 if ( aRect.IsEmpty() )
454 return;
455 aRect.Justify();
457 // we need a graphics
458 if ( !mpGraphics )
460 if ( !ImplGetGraphics() )
461 return;
464 if ( mbInitClipRegion )
465 ImplInitClipRegion();
467 if ( mbOutputClipped )
468 return;
470 SalInvert nSalFlags = 0;
471 if ( nFlags & INVERT_HIGHLIGHT )
472 nSalFlags |= SAL_INVERT_HIGHLIGHT;
473 if ( nFlags & INVERT_50 )
474 nSalFlags |= SAL_INVERT_50;
475 mpGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), nSalFlags, this );
478 // -----------------------------------------------------------------------
480 void Window::Invert( const Polygon& rPoly, USHORT nFlags )
482 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
484 if ( !IsDeviceOutputNecessary() )
485 return;
487 USHORT nPoints = rPoly.GetSize();
489 if ( nPoints < 2 )
490 return;
492 Polygon aPoly( ImplLogicToDevicePixel( rPoly ) );
494 // we need a graphics
495 if ( !mpGraphics )
497 if ( !ImplGetGraphics() )
498 return;
501 if ( mbInitClipRegion )
502 ImplInitClipRegion();
504 if ( mbOutputClipped )
505 return;
507 SalInvert nSalFlags = 0;
508 if ( nFlags & INVERT_HIGHLIGHT )
509 nSalFlags |= SAL_INVERT_HIGHLIGHT;
510 if ( nFlags & INVERT_50 )
511 nSalFlags |= SAL_INVERT_50;
512 const SalPoint* pPtAry = (const SalPoint*)aPoly.GetConstPointAry();
513 mpGraphics->Invert( nPoints, pPtAry, nSalFlags, this );
516 // -----------------------------------------------------------------------
518 void Window::ShowTracking( const Rectangle& rRect, USHORT nFlags )
520 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
522 ImplWinData* pWinData = ImplGetWinData();
524 if ( !mpWindowImpl->mbInPaint || !(nFlags & SHOWTRACK_WINDOW) )
526 if ( mpWindowImpl->mbTrackVisible )
528 if ( (*(pWinData->mpTrackRect) == rRect) &&
529 (pWinData->mnTrackFlags == nFlags) )
530 return;
532 InvertTracking( *(pWinData->mpTrackRect), pWinData->mnTrackFlags );
535 InvertTracking( rRect, nFlags );
538 if ( !pWinData->mpTrackRect )
539 pWinData->mpTrackRect = new Rectangle( rRect );
540 else
541 *(pWinData->mpTrackRect) = rRect;
542 pWinData->mnTrackFlags = nFlags;
543 mpWindowImpl->mbTrackVisible = TRUE;
546 // -----------------------------------------------------------------------
548 void Window::HideTracking()
550 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
552 if ( mpWindowImpl->mbTrackVisible )
554 ImplWinData* pWinData = ImplGetWinData();
555 if ( !mpWindowImpl->mbInPaint || !(pWinData->mnTrackFlags & SHOWTRACK_WINDOW) )
556 InvertTracking( *(pWinData->mpTrackRect), pWinData->mnTrackFlags );
557 mpWindowImpl->mbTrackVisible = FALSE;
561 // -----------------------------------------------------------------------
563 void Window::InvertTracking( const Rectangle& rRect, USHORT nFlags )
565 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
567 Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
569 if ( aRect.IsEmpty() )
570 return;
571 aRect.Justify();
573 SalGraphics* pGraphics;
575 if ( nFlags & SHOWTRACK_WINDOW )
577 if ( !IsDeviceOutputNecessary() )
578 return;
580 // we need a graphics
581 if ( !mpGraphics )
583 if ( !ImplGetGraphics() )
584 return;
587 if ( mbInitClipRegion )
588 ImplInitClipRegion();
590 if ( mbOutputClipped )
591 return;
593 pGraphics = mpGraphics;
595 else
597 pGraphics = ImplGetFrameGraphics();
599 if ( nFlags & SHOWTRACK_CLIP )
601 Point aPoint( mnOutOffX, mnOutOffY );
602 Region aRegion( Rectangle( aPoint,
603 Size( mnOutWidth, mnOutHeight ) ) );
604 ImplClipBoundaries( aRegion, FALSE, FALSE );
605 ImplSelectClipRegion( aRegion, pGraphics );
609 USHORT nStyle = nFlags & SHOWTRACK_STYLE;
610 if ( nStyle == SHOWTRACK_OBJECT )
611 pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), SAL_INVERT_TRACKFRAME, this );
612 else if ( nStyle == SHOWTRACK_SPLIT )
613 pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), SAL_INVERT_50, this );
614 else
616 long nBorder = 1;
617 if ( nStyle == SHOWTRACK_BIG )
618 nBorder = 5;
619 pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), nBorder, SAL_INVERT_50, this );
620 pGraphics->Invert( aRect.Left(), aRect.Bottom()-nBorder+1, aRect.GetWidth(), nBorder, SAL_INVERT_50, this );
621 pGraphics->Invert( aRect.Left(), aRect.Top()+nBorder, nBorder, aRect.GetHeight()-(nBorder*2), SAL_INVERT_50, this );
622 pGraphics->Invert( aRect.Right()-nBorder+1, aRect.Top()+nBorder, nBorder, aRect.GetHeight()-(nBorder*2), SAL_INVERT_50, this );
626 // -----------------------------------------------------------------------
628 void Window::InvertTracking( const Polygon& rPoly, USHORT nFlags )
630 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
632 USHORT nPoints = rPoly.GetSize();
634 if ( nPoints < 2 )
635 return;
637 Polygon aPoly( ImplLogicToDevicePixel( rPoly ) );
639 SalGraphics* pGraphics;
641 if ( nFlags & SHOWTRACK_WINDOW )
643 if ( !IsDeviceOutputNecessary() )
644 return;
646 // we need a graphics
647 if ( !mpGraphics )
649 if ( !ImplGetGraphics() )
650 return;
653 if ( mbInitClipRegion )
654 ImplInitClipRegion();
656 if ( mbOutputClipped )
657 return;
659 pGraphics = mpGraphics;
661 else
663 pGraphics = ImplGetFrameGraphics();
665 if ( nFlags & SHOWTRACK_CLIP )
667 Point aPoint( mnOutOffX, mnOutOffY );
668 Region aRegion( Rectangle( aPoint,
669 Size( mnOutWidth, mnOutHeight ) ) );
670 ImplClipBoundaries( aRegion, FALSE, FALSE );
671 ImplSelectClipRegion( aRegion, pGraphics );
675 const SalPoint* pPtAry = (const SalPoint*)aPoly.GetConstPointAry();
676 pGraphics->Invert( nPoints, pPtAry, SAL_INVERT_TRACKFRAME, this );
679 // -----------------------------------------------------------------------
681 IMPL_LINK( Window, ImplTrackTimerHdl, Timer*, pTimer )
683 ImplSVData* pSVData = ImplGetSVData();
685 // Bei Button-Repeat muessen wir den Timeout umsetzen
686 if ( pSVData->maWinData.mnTrackFlags & STARTTRACK_BUTTONREPEAT )
687 pTimer->SetTimeout( GetSettings().GetMouseSettings().GetButtonRepeat() );
689 // Tracking-Event erzeugen
690 Point aMousePos( mpWindowImpl->mpFrameData->mnLastMouseX, mpWindowImpl->mpFrameData->mnLastMouseY );
691 if( ImplIsAntiparallel() )
693 // - RTL - re-mirror frame pos at pChild
694 ImplReMirror( aMousePos );
696 MouseEvent aMEvt( ImplFrameToOutput( aMousePos ),
697 mpWindowImpl->mpFrameData->mnClickCount, 0,
698 mpWindowImpl->mpFrameData->mnMouseCode, mpWindowImpl->mpFrameData->mnMouseCode );
699 TrackingEvent aTEvt( aMEvt, TRACKING_REPEAT );
700 Tracking( aTEvt );
702 return 0;
705 // -----------------------------------------------------------------------
707 void Window::StartTracking( USHORT nFlags )
709 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
711 ImplSVData* pSVData = ImplGetSVData();
713 if ( pSVData->maWinData.mpTrackWin != this )
715 if ( pSVData->maWinData.mpTrackWin )
716 pSVData->maWinData.mpTrackWin->EndTracking( ENDTRACK_CANCEL );
719 if ( nFlags & (STARTTRACK_SCROLLREPEAT | STARTTRACK_BUTTONREPEAT) )
721 pSVData->maWinData.mpTrackTimer = new AutoTimer;
723 if ( nFlags & STARTTRACK_SCROLLREPEAT )
724 pSVData->maWinData.mpTrackTimer->SetTimeout( GetSettings().GetMouseSettings().GetScrollRepeat() );
725 else
726 pSVData->maWinData.mpTrackTimer->SetTimeout( GetSettings().GetMouseSettings().GetButtonStartRepeat() );
727 pSVData->maWinData.mpTrackTimer->SetTimeoutHdl( LINK( this, Window, ImplTrackTimerHdl ) );
728 pSVData->maWinData.mpTrackTimer->Start();
731 pSVData->maWinData.mpTrackWin = this;
732 pSVData->maWinData.mnTrackFlags = nFlags;
733 CaptureMouse();
736 // -----------------------------------------------------------------------
738 void Window::EndTracking( USHORT nFlags )
740 ImplSVData* pSVData = ImplGetSVData();
742 if ( pSVData->maWinData.mpTrackWin == this )
744 // Hier wegen DbgChkThis geklammert, da Window im Handler zerstoert
745 // werden kann
747 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
749 if ( pSVData->maWinData.mpTrackTimer )
751 delete pSVData->maWinData.mpTrackTimer;
752 pSVData->maWinData.mpTrackTimer = NULL;
755 pSVData->maWinData.mpTrackWin = NULL;
756 pSVData->maWinData.mnTrackFlags = 0;
757 ReleaseMouse();
760 // EndTracking rufen, wenn es gerufen werden soll
761 if ( !(nFlags & ENDTRACK_DONTCALLHDL) )
763 Point aMousePos( mpWindowImpl->mpFrameData->mnLastMouseX, mpWindowImpl->mpFrameData->mnLastMouseY );
764 if( ImplIsAntiparallel() )
766 // - RTL - re-mirror frame pos at pChild
767 ImplReMirror( aMousePos );
770 MouseEvent aMEvt( ImplFrameToOutput( aMousePos ),
771 mpWindowImpl->mpFrameData->mnClickCount, 0,
772 mpWindowImpl->mpFrameData->mnMouseCode, mpWindowImpl->mpFrameData->mnMouseCode );
773 TrackingEvent aTEvt( aMEvt, nFlags | ENDTRACK_END );
774 Tracking( aTEvt );
779 // -----------------------------------------------------------------------
781 BOOL Window::IsTracking() const
783 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
785 return (ImplGetSVData()->maWinData.mpTrackWin == this);
788 // -----------------------------------------------------------------------
790 void Window::StartAutoScroll( USHORT nFlags )
792 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
794 ImplSVData* pSVData = ImplGetSVData();
796 if ( pSVData->maWinData.mpAutoScrollWin != this )
798 if ( pSVData->maWinData.mpAutoScrollWin )
799 pSVData->maWinData.mpAutoScrollWin->EndAutoScroll();
802 pSVData->maWinData.mpAutoScrollWin = this;
803 pSVData->maWinData.mnAutoScrollFlags = nFlags;
804 pSVData->maAppData.mpWheelWindow = new ImplWheelWindow( this );
807 // -----------------------------------------------------------------------
809 void Window::EndAutoScroll()
811 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
813 ImplSVData* pSVData = ImplGetSVData();
815 if ( pSVData->maWinData.mpAutoScrollWin == this )
817 pSVData->maWinData.mpAutoScrollWin = NULL;
818 pSVData->maWinData.mnAutoScrollFlags = 0;
819 pSVData->maAppData.mpWheelWindow->ImplStop();
820 pSVData->maAppData.mpWheelWindow->doLazyDelete();
821 pSVData->maAppData.mpWheelWindow = NULL;
825 // -----------------------------------------------------------------------
827 BOOL Window::IsAutoScroll() const
829 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
831 return (ImplGetSVData()->maWinData.mpAutoScrollWin == this);
834 // -----------------------------------------------------------------------
836 void Window::SaveBackground( const Point& rPos, const Size& rSize,
837 const Point& rDestOff, VirtualDevice& rSaveDevice )
839 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
841 if ( mpWindowImpl->mpPaintRegion )
843 Region aClip( *mpWindowImpl->mpPaintRegion );
844 const Point aPixPos( LogicToPixel( rPos ) );
846 aClip.Move( -mnOutOffX, -mnOutOffY );
847 aClip.Intersect( Rectangle( aPixPos, LogicToPixel( rSize ) ) );
849 if ( !aClip.IsEmpty() )
851 const Region aOldClip( rSaveDevice.GetClipRegion() );
852 const Point aPixOffset( rSaveDevice.LogicToPixel( rDestOff ) );
853 const BOOL bMap = rSaveDevice.IsMapModeEnabled();
855 // move clip region to have the same distance to DestOffset
856 aClip.Move( aPixOffset.X() - aPixPos.X(), aPixOffset.Y() - aPixPos.Y() );
858 // set pixel clip region
859 rSaveDevice.EnableMapMode( FALSE );
860 rSaveDevice.SetClipRegion( aClip );
861 rSaveDevice.EnableMapMode( bMap );
862 rSaveDevice.DrawOutDev( rDestOff, rSize, rPos, rSize, *this );
863 rSaveDevice.SetClipRegion( aOldClip );
866 else
867 rSaveDevice.DrawOutDev( rDestOff, rSize, rPos, rSize, *this );
870 // -----------------------------------------------------------------------
872 sal_uIntPtr Window::SaveFocus()
874 ImplSVData* pSVData = ImplGetSVData();
875 if ( pSVData->maWinData.mpFocusWin )
877 ImplFocusDelData* pDelData = new ImplFocusDelData;
878 pSVData->maWinData.mpFocusWin->ImplAddDel( pDelData );
879 pDelData->mpFocusWin = pSVData->maWinData.mpFocusWin;
880 return (sal_uIntPtr)(void*)pDelData;
882 else
883 return 0;
886 // -----------------------------------------------------------------------
888 BOOL Window::EndSaveFocus( sal_uIntPtr nSaveId, BOOL bRestore )
890 if ( !nSaveId )
891 return FALSE;
892 else
894 BOOL bOK = TRUE;
895 ImplFocusDelData* pDelData = (ImplFocusDelData*)(void*)nSaveId;
896 if ( !pDelData->IsDelete() )
898 pDelData->mpFocusWin->ImplRemoveDel( pDelData );
899 if ( bRestore )
900 pDelData->mpFocusWin->GrabFocus();
902 else
903 bOK = !bRestore;
904 delete pDelData;
905 return bOK;
909 // -----------------------------------------------------------------------
911 void Window::SetZoom( const Fraction& rZoom )
913 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
915 if ( mpWindowImpl->maZoom != rZoom )
917 mpWindowImpl->maZoom = rZoom;
918 StateChanged( STATE_CHANGE_ZOOM );
922 // -----------------------------------------------------------------------
924 inline long WinFloatRound( double fVal )
926 return( fVal > 0.0 ? (long) ( fVal + 0.5 ) : -(long) ( -fVal + 0.5 ) );
929 // -----------------------------------------------------------------------
931 void Window::SetZoomedPointFont( const Font& rFont )
933 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
935 const Fraction& rZoom = GetZoom();
936 if ( rZoom.GetNumerator() != rZoom.GetDenominator() )
938 Font aFont( rFont );
939 Size aSize = aFont.GetSize();
940 double n = (double)aSize.Width();
941 n *= (double)rZoom.GetNumerator();
942 n /= (double)rZoom.GetDenominator();
943 aSize.Width() = WinFloatRound( n );
944 n = (double)aSize.Height();
945 n *= (double)rZoom.GetNumerator();
946 n /= (double)rZoom.GetDenominator();
947 aSize.Height() = WinFloatRound( n );
948 aFont.SetSize( aSize );
949 SetPointFont( aFont );
951 // Wenn Darstellung skaliert wird, nehmen wir gegebenenfalls
952 // einen anderen Font, wenn der aktuelle nicht skalierbar ist
953 FontMetric aMetric = GetFontMetric();
954 long nFontDiff = Abs( GetFont().GetSize().Height()-aMetric.GetSize().Height() );
955 if ( (aMetric.GetType() == TYPE_RASTER) && (nFontDiff >= 2) )
957 USHORT nType;
958 if ( aMetric.GetPitch() == PITCH_FIXED )
959 nType = DEFAULTFONT_FIXED;
960 else
961 nType = DEFAULTFONT_UI_SANS;
962 Font aTempFont = GetDefaultFont( nType, GetSettings().GetLanguage(), 0 );
963 aFont.SetName( aTempFont.GetName() );
964 SetPointFont( aFont );
967 else
968 SetPointFont( rFont );
971 // -----------------------------------------------------------------------
973 long Window::CalcZoom( long nCalc ) const
975 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
977 const Fraction& rZoom = GetZoom();
978 if ( rZoom.GetNumerator() != rZoom.GetDenominator() )
980 double n = (double)nCalc;
981 n *= (double)rZoom.GetNumerator();
982 n /= (double)rZoom.GetDenominator();
983 nCalc = WinFloatRound( n );
985 return nCalc;
988 // -----------------------------------------------------------------------
990 void Window::SetControlFont()
992 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
994 if ( mpWindowImpl->mpControlFont )
996 delete mpWindowImpl->mpControlFont;
997 mpWindowImpl->mpControlFont = NULL;
998 StateChanged( STATE_CHANGE_CONTROLFONT );
1002 // -----------------------------------------------------------------------
1004 void Window::SetControlFont( const Font& rFont )
1006 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1008 if ( rFont == Font() )
1010 SetControlFont();
1011 return;
1014 if ( mpWindowImpl->mpControlFont )
1016 if ( *mpWindowImpl->mpControlFont == rFont )
1017 return;
1018 *mpWindowImpl->mpControlFont = rFont;
1020 else
1021 mpWindowImpl->mpControlFont = new Font( rFont );
1023 StateChanged( STATE_CHANGE_CONTROLFONT );
1026 // -----------------------------------------------------------------------
1028 Font Window::GetControlFont() const
1030 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1032 if ( mpWindowImpl->mpControlFont )
1033 return *mpWindowImpl->mpControlFont;
1034 else
1036 Font aFont;
1037 return aFont;
1041 // -----------------------------------------------------------------------
1043 void Window::SetControlForeground()
1045 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1047 if ( mpWindowImpl->mbControlForeground )
1049 mpWindowImpl->maControlForeground = Color( COL_TRANSPARENT );
1050 mpWindowImpl->mbControlForeground = FALSE;
1051 StateChanged( STATE_CHANGE_CONTROLFOREGROUND );
1055 // -----------------------------------------------------------------------
1057 void Window::SetControlForeground( const Color& rColor )
1059 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1061 if ( rColor.GetTransparency() )
1063 if ( mpWindowImpl->mbControlForeground )
1065 mpWindowImpl->maControlForeground = Color( COL_TRANSPARENT );
1066 mpWindowImpl->mbControlForeground = FALSE;
1067 StateChanged( STATE_CHANGE_CONTROLFOREGROUND );
1070 else
1072 if ( mpWindowImpl->maControlForeground != rColor )
1074 mpWindowImpl->maControlForeground = rColor;
1075 mpWindowImpl->mbControlForeground = TRUE;
1076 StateChanged( STATE_CHANGE_CONTROLFOREGROUND );
1081 // -----------------------------------------------------------------------
1083 void Window::SetControlBackground()
1085 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1087 if ( mpWindowImpl->mbControlBackground )
1089 mpWindowImpl->maControlBackground = Color( COL_TRANSPARENT );
1090 mpWindowImpl->mbControlBackground = FALSE;
1091 StateChanged( STATE_CHANGE_CONTROLBACKGROUND );
1095 // -----------------------------------------------------------------------
1097 void Window::SetControlBackground( const Color& rColor )
1099 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1101 if ( rColor.GetTransparency() )
1103 if ( mpWindowImpl->mbControlBackground )
1105 mpWindowImpl->maControlBackground = Color( COL_TRANSPARENT );
1106 mpWindowImpl->mbControlBackground = FALSE;
1107 StateChanged( STATE_CHANGE_CONTROLBACKGROUND );
1110 else
1112 if ( mpWindowImpl->maControlBackground != rColor )
1114 mpWindowImpl->maControlBackground = rColor;
1115 mpWindowImpl->mbControlBackground = TRUE;
1116 StateChanged( STATE_CHANGE_CONTROLBACKGROUND );
1121 // -----------------------------------------------------------------------
1123 Size Window::CalcWindowSize( const Size& rOutSz ) const
1125 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1127 Size aSz = rOutSz;
1128 aSz.Width() += mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder;
1129 aSz.Height() += mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder;
1130 return aSz;
1133 // -----------------------------------------------------------------------
1135 Size Window::CalcOutputSize( const Size& rWinSz ) const
1137 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1139 Size aSz = rWinSz;
1140 aSz.Width() -= mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder;
1141 aSz.Height() -= mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder;
1142 return aSz;
1145 // -----------------------------------------------------------------------
1147 Font Window::GetDrawPixelFont( OutputDevice* pDev ) const
1149 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1151 Font aFont = GetPointFont();
1152 Size aFontSize = aFont.GetSize();
1153 MapMode aPtMapMode( MAP_POINT );
1154 aFontSize = pDev->LogicToPixel( aFontSize, aPtMapMode );
1155 aFont.SetSize( aFontSize );
1156 return aFont;
1159 // -----------------------------------------------------------------------
1161 long Window::GetDrawPixel( OutputDevice* pDev, long nPixels ) const
1163 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1165 long nP = nPixels;
1166 if ( pDev->GetOutDevType() != OUTDEV_WINDOW )
1168 MapMode aMap( MAP_100TH_MM );
1169 Size aSz( nP, 0 );
1170 aSz = PixelToLogic( aSz, aMap );
1171 aSz = pDev->LogicToPixel( aSz, aMap );
1172 nP = aSz.Width();
1174 return nP;
1177 // -----------------------------------------------------------------------
1179 BOOL Window::HandleScrollCommand( const CommandEvent& rCmd,
1180 ScrollBar* pHScrl, ScrollBar* pVScrl )
1182 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1184 BOOL bRet = FALSE;
1186 if ( pHScrl || pVScrl )
1188 switch( rCmd.GetCommand() )
1190 case COMMAND_STARTAUTOSCROLL:
1192 USHORT nFlags = 0;
1193 if ( pHScrl )
1195 if ( (pHScrl->GetVisibleSize() < pHScrl->GetRangeMax()) &&
1196 pHScrl->IsEnabled() && pHScrl->IsInputEnabled() && ! pHScrl->IsInModalMode() )
1197 nFlags |= AUTOSCROLL_HORZ;
1199 if ( pVScrl )
1201 if ( (pVScrl->GetVisibleSize() < pVScrl->GetRangeMax()) &&
1202 pVScrl->IsEnabled() && pVScrl->IsInputEnabled() && ! pVScrl->IsInModalMode() )
1203 nFlags |= AUTOSCROLL_VERT;
1206 if ( nFlags )
1208 StartAutoScroll( nFlags );
1209 bRet = TRUE;
1212 break;
1214 case COMMAND_WHEEL:
1216 const CommandWheelData* pData = rCmd.GetWheelData();
1218 if ( pData && (COMMAND_WHEEL_SCROLL == pData->GetMode()) )
1220 ULONG nScrollLines = pData->GetScrollLines();
1221 long nLines;
1222 if ( nScrollLines == COMMAND_WHEEL_PAGESCROLL )
1224 if ( pData->GetDelta() < 0 )
1225 nLines = -LONG_MAX;
1226 else
1227 nLines = LONG_MAX;
1229 else
1230 nLines = pData->GetNotchDelta() * (long)nScrollLines;
1231 if ( nLines )
1233 ImplHandleScroll( NULL,
1234 0L,
1235 pData->IsHorz() ? pHScrl : pVScrl,
1236 nLines );
1237 bRet = TRUE;
1241 break;
1243 case COMMAND_AUTOSCROLL:
1245 const CommandScrollData* pData = rCmd.GetAutoScrollData();
1246 if ( pData && (pData->GetDeltaX() || pData->GetDeltaY()) )
1248 ImplHandleScroll( pHScrl, pData->GetDeltaX(),
1249 pVScrl, pData->GetDeltaY() );
1250 bRet = TRUE;
1253 break;
1255 default:
1256 break;
1260 return bRet;
1263 // -----------------------------------------------------------------------
1265 void Window::ImplHandleScroll( ScrollBar* pHScrl, long nX,
1266 ScrollBar* pVScrl, long nY )
1268 if ( pHScrl && nX && pHScrl->IsEnabled() && pHScrl->IsInputEnabled() && ! pHScrl->IsInModalMode() )
1270 long nNewPos = pHScrl->GetThumbPos();
1272 if ( nX == -LONG_MAX )
1273 nNewPos += pHScrl->GetPageSize();
1274 else if ( nX == LONG_MAX )
1275 nNewPos -= pHScrl->GetPageSize();
1276 else
1278 const double fVal = (double)nNewPos - ((double)nX * pHScrl->GetLineSize());
1280 if ( fVal < LONG_MIN )
1281 nNewPos = LONG_MIN;
1282 else if ( fVal > LONG_MAX )
1283 nNewPos = LONG_MAX;
1284 else
1285 nNewPos = (long)fVal;
1288 pHScrl->DoScroll( nNewPos );
1291 if ( pVScrl && nY && pVScrl->IsEnabled() && pVScrl->IsInputEnabled() && ! pVScrl->IsInModalMode() )
1293 long nNewPos = pVScrl->GetThumbPos();
1295 if ( nY == -LONG_MAX )
1296 nNewPos += pVScrl->GetPageSize();
1297 else if ( nY == LONG_MAX )
1298 nNewPos -= pVScrl->GetPageSize();
1299 else
1301 const double fVal = (double)nNewPos - ((double)nY * pVScrl->GetLineSize());
1303 if ( fVal < LONG_MIN )
1304 nNewPos = LONG_MIN;
1305 else if ( fVal > LONG_MAX )
1306 nNewPos = LONG_MAX;
1307 else
1308 nNewPos = (long)fVal;
1311 pVScrl->DoScroll( nNewPos );
1315 // support for docking
1316 // this is currently handled in ImplDockingWindowWrapper
1318 void Window::ImplSetFloatingMode( BOOL bFloatMode )
1320 // if the window is docked, put it into a flaoting window
1321 // if it is floating put it back in the old frame
1323 ImplDockingWindowWrapper *pWrapper = pDockingMgr->GetDockingWindowWrapper( this );
1324 if( !pDockingData )
1325 return;
1327 if ( pWrapper->IsFloatingMode() != bFloatMode )
1329 if ( pWrapper->PrepareToggleFloatingMode() )
1331 BOOL bVisible = IsVisible();
1333 if ( bFloatMode )
1335 Show( FALSE, SHOW_NOFOCUSCHANGE );
1337 pWrapper->maDockPos = GetPosPixel();
1339 Window* pRealParent = mpWindowImpl->mpRealParent;
1340 pWrapper->mpOldBorderWin = mpWindowImpl->mpBorderWindow;
1342 ImplDockFloatWin* pWin =
1343 new ImplDockFloatWin2(
1344 mpWindowImpl->mpParent,
1345 mnFloatBits & ( WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE ) ? mnFloatBits | WB_SYSTEMWINDOW : mnFloatBits,
1346 pWrapper );
1347 pWrapper->mpFloatWin = pWin;
1348 mpWindowImpl->mpBorderWindow = NULL;
1349 mpWindowImpl->mnLeftBorder = 0;
1350 mpWindowImpl->mnTopBorder = 0;
1351 mpWindowImpl->mnRightBorder = 0;
1352 mpWindowImpl->mnBottomBorder = 0;
1353 // Falls Parent zerstoert wird, muessen wir auch vom
1354 // BorderWindow den Parent umsetzen
1355 if ( pWrapper->mpOldBorderWin )
1356 pWrapper->mpOldBorderWin->SetParent( pWin );
1357 SetParent( pWin );
1358 pWin->SetPosPixel( Point() );
1359 mpWindowImpl->mpBorderWindow = pWin;
1360 pWin->mpWindowImpl->mpClientWindow = this;
1361 mpWindowImpl->mpRealParent = pRealParent;
1362 pWin->SetText( GetText() );
1363 pWin->SetOutputSizePixel( GetSizePixel() );
1364 pWin->SetPosPixel( pWrapper->maFloatPos );
1365 // DockingDaten ans FloatingWindow weiterreichen
1366 pWin->ShowTitleButton( TITLE_BUTTON_DOCKING, pWrapper->mbDockBtn );
1367 pWin->ShowTitleButton( TITLE_BUTTON_HIDE, pWrapper->mbHideBtn );
1368 pWin->SetPin( pWrapper->mbPined );
1369 if ( pWrapper->mbRollUp )
1370 pWin->RollUp();
1371 else
1372 pWin->RollDown();
1373 pWin->SetRollUpOutputSizePixel( pWrapper->maRollUpOutSize );
1374 pWin->SetMinOutputSizePixel( pWrapper->maMinOutSize );
1376 pWrapper->ToggleFloatingMode();
1378 if ( bVisible )
1379 Show();
1381 else
1383 Show( FALSE, SHOW_NOFOCUSCHANGE );
1385 // FloatingDaten wird im FloatingWindow speichern
1386 pWrapper->maFloatPos = mpFloatWin->GetPosPixel();
1387 pWrapper->mbDockBtn = mpFloatWin->IsTitleButtonVisible( TITLE_BUTTON_DOCKING );
1388 pWrapper->mbHideBtn = mpFloatWin->IsTitleButtonVisible( TITLE_BUTTON_HIDE );
1389 pWrapper->mbPined = mpFloatWin->IsPined();
1390 pWrapper->mbRollUp = mpFloatWin->IsRollUp();
1391 pWrapper->maRollUpOutSize = mpFloatWin->GetRollUpOutputSizePixel();
1392 pWrapper->maMinOutSize = mpFloatWin->GetMinOutputSizePixel();
1394 Window* pRealParent = mpWindowImpl->mpRealParent;
1395 mpWindowImpl->mpBorderWindow = NULL;
1396 if ( pWrapper->mpOldBorderWin )
1398 SetParent( pWrapper->mpOldBorderWin );
1399 ((ImplBorderWindow*)pWrapper->mpOldBorderWin)->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
1400 pWrapper->mpOldBorderWin->Resize();
1402 mpWindowImpl->mpBorderWindow = pWrapper->mpOldBorderWin;
1403 SetParent( pRealParent );
1404 mpWindowImpl->mpRealParent = pRealParent;
1405 delete static_cast<ImplDockFloatWin*>(mpFloatWin);
1406 pWrapper->mpFloatWin = NULL;
1407 SetPosPixel( maDockPos );
1409 pWrapper->ToggleFloatingMode();
1411 if ( bVisible )
1412 Show();
1419 DockingManager* Window::GetDockingManager()
1421 return ImplGetDockingManager();
1424 void Window::EnableDocking( BOOL bEnable )
1426 // update list of dockable windows
1427 if( bEnable )
1428 ImplGetDockingManager()->AddWindow( this );
1429 else
1430 ImplGetDockingManager()->RemoveWindow( this );
1434 // retrieves the list of owner draw decorated windows for this window hiearchy
1435 ::std::vector<Window *>& Window::ImplGetOwnerDrawList()
1437 return ImplGetTopmostFrameWindow()->mpWindowImpl->mpFrameData->maOwnerDrawList;
1440 Window* Window::ImplGetTopmostFrameWindow()
1442 Window *pTopmostParent = this;
1443 while( pTopmostParent->ImplGetParent() )
1444 pTopmostParent = pTopmostParent->ImplGetParent();
1445 return pTopmostParent->mpWindowImpl->mpFrameWindow;
1448 // making these Methods out of line to be able to change them lateron without complete rebuild
1449 // TODO: Set the SmartId in here and remove mpWindowImpl->mnHelpId
1450 void Window::SetHelpId( ULONG nHelpId )
1452 SetSmartHelpId(SmartId(nHelpId));
1455 ULONG Window::GetHelpId() const
1457 return mpWindowImpl->mnHelpId;
1460 void Window::SetSmartHelpId( const SmartId& aId, SmartIdUpdateMode aMode )
1462 mpWindowImpl->maHelpText = String();
1463 // create SmartId if required
1464 if ( (aMode == SMART_SET_STR) || (aMode == SMART_SET_ALL) || ( (aMode == SMART_SET_SMART) && aId.HasString() ) )
1466 if ( !ImplGetWinData()->mpSmartHelpId )
1467 ImplGetWinData()->mpSmartHelpId = new SmartId();
1470 // if we have a SmartId (eather from earlier call or just created) fill with new values
1471 if ( mpWindowImpl->mpWinData && mpWindowImpl->mpWinData->mpSmartHelpId )
1472 ImplGetWinData()->mpSmartHelpId->UpdateId( aId, aMode );
1474 if ( (aMode == SMART_SET_NUM) || (aMode == SMART_SET_ALL) || ( (aMode == SMART_SET_SMART) && aId.HasNumeric() ) )
1476 mpWindowImpl->mnHelpId = aId.GetNum();
1480 SmartId Window::GetSmartHelpId() const
1482 if ( mpWindowImpl->mpWinData && mpWindowImpl->mpWinData->mpSmartHelpId )
1484 if ( mpWindowImpl->mnHelpId || mpWindowImpl->mpWinData->mpSmartHelpId->HasNumeric() )
1485 mpWindowImpl->mpWinData->mpSmartHelpId->UpdateId( SmartId( mpWindowImpl->mnHelpId ), SMART_SET_NUM );
1486 return *mpWindowImpl->mpWinData->mpSmartHelpId;
1488 else
1490 if ( mpWindowImpl->mnHelpId )
1491 return SmartId( mpWindowImpl->mnHelpId );
1492 else
1493 return SmartId();
1498 // making these Methods out of line to be able to change them lateron without complete rebuild
1499 // TODO: Set the SmartId in here and remove mpWindowImpl->mnUniqId
1500 void Window::SetUniqueId( ULONG nUniqueId ) { mpWindowImpl->mnUniqId = nUniqueId; }
1501 ULONG Window::GetUniqueId() const { return mpWindowImpl->mnUniqId; }
1504 void Window::SetSmartUniqueId( const SmartId& aId, SmartIdUpdateMode aMode )
1506 // create SmartId if required
1507 if ( (aMode == SMART_SET_STR) || (aMode == SMART_SET_ALL) || ( (aMode == SMART_SET_SMART) && aId.HasString() ) )
1509 if ( !ImplGetWinData()->mpSmartUniqueId )
1510 ImplGetWinData()->mpSmartUniqueId = new SmartId();
1513 // if we have a SmartId (eather from earlier call or just created) fill with new values
1514 if ( mpWindowImpl->mpWinData && mpWindowImpl->mpWinData->mpSmartUniqueId )
1515 ImplGetWinData()->mpSmartUniqueId->UpdateId( aId, aMode );
1517 if ( (aMode == SMART_SET_NUM) || (aMode == SMART_SET_ALL) || ( (aMode == SMART_SET_SMART) && aId.HasNumeric() ) )
1518 mpWindowImpl->mnUniqId = aId.GetNum();
1521 SmartId Window::GetSmartUniqueId() const
1523 if ( mpWindowImpl->mpWinData && mpWindowImpl->mpWinData->mpSmartUniqueId )
1525 if ( mpWindowImpl->mnUniqId || mpWindowImpl->mpWinData->mpSmartUniqueId->HasNumeric() )
1526 mpWindowImpl->mpWinData->mpSmartUniqueId->UpdateId( SmartId( mpWindowImpl->mnUniqId ), SMART_SET_NUM );
1527 return *mpWindowImpl->mpWinData->mpSmartUniqueId;
1529 else
1531 if ( mpWindowImpl->mnUniqId )
1532 return SmartId( mpWindowImpl->mnUniqId );
1533 else
1534 return SmartId();
1538 SmartId Window::GetSmartUniqueOrHelpId() const
1540 if ( ( mpWindowImpl->mpWinData && mpWindowImpl->mpWinData->mpSmartHelpId ) || mpWindowImpl->mnHelpId )
1542 if ( ( mpWindowImpl->mpWinData && mpWindowImpl->mpWinData->mpSmartUniqueId ) || mpWindowImpl->mnUniqId )
1544 SmartId aTemp = GetSmartHelpId();
1545 aTemp.UpdateId( GetSmartUniqueId() );
1546 return aTemp;
1548 else
1549 return GetSmartHelpId();
1551 else
1552 return GetSmartUniqueId();
1558 // --------- old inline methods ---------------
1560 Window* Window::ImplGetWindow()
1562 if ( mpWindowImpl->mpClientWindow )
1563 return mpWindowImpl->mpClientWindow;
1564 else
1565 return this;
1568 ImplFrameData* Window::ImplGetFrameData()
1570 return mpWindowImpl->mpFrameData;
1573 SalFrame* Window::ImplGetFrame() const
1575 return mpWindowImpl->mpFrame;
1578 Window* Window::ImplGetParent() const
1580 return mpWindowImpl->mpParent;
1583 Window* Window::ImplGetClientWindow() const
1585 return mpWindowImpl->mpClientWindow;
1588 Window* Window::ImplGetBorderWindow() const
1590 return mpWindowImpl->mpBorderWindow;
1593 Window* Window::ImplGetFirstOverlapWindow()
1595 if ( mpWindowImpl->mbOverlapWin )
1596 return this;
1597 else
1598 return mpWindowImpl->mpOverlapWindow;
1601 const Window* Window::ImplGetFirstOverlapWindow() const
1603 if ( mpWindowImpl->mbOverlapWin )
1604 return this;
1605 else
1606 return mpWindowImpl->mpOverlapWindow;
1609 Window* Window::ImplGetFrameWindow() const
1611 return mpWindowImpl->mpFrameWindow;
1614 BOOL Window::ImplIsDockingWindow() const
1616 return mpWindowImpl->mbDockWin;
1619 BOOL Window::ImplIsFloatingWindow() const
1621 return mpWindowImpl->mbFloatWin;
1624 BOOL Window::ImplIsToolbox() const
1626 return mpWindowImpl->mbToolBox;
1629 BOOL Window::ImplIsSplitter() const
1631 return mpWindowImpl->mbSplitter;
1634 BOOL Window::ImplIsPushButton() const
1636 return mpWindowImpl->mbPushButton;
1639 BOOL Window::ImplIsOverlapWindow() const
1641 return mpWindowImpl->mbOverlapWin;
1644 void Window::ImplSetActive( BOOL bActive )
1646 mpWindowImpl->mbActive = bActive;
1649 BOOL Window::ImplIsMouseTransparent() const
1651 return mpWindowImpl->mbMouseTransparent;
1654 void Window::ImplSetMouseTransparent( BOOL bTransparent )
1656 mpWindowImpl->mbMouseTransparent = bTransparent;
1659 Point Window::ImplOutputToFrame( const Point& rPos )
1661 return Point( rPos.X()+mnOutOffX, rPos.Y()+mnOutOffY );
1664 Point Window::ImplFrameToOutput( const Point& rPos )
1666 return Point( rPos.X()-mnOutOffX, rPos.Y()-mnOutOffY );
1669 void Window::ImplOutputToFrame( Rectangle& rRect )
1671 rRect.Left()+=mnOutOffX;
1672 rRect.Top()+=mnOutOffY;
1673 rRect.Right()+=mnOutOffX;
1674 rRect.Bottom()+=mnOutOffY;
1677 void Window::ImplFrameToOutput( Rectangle& rRect )
1679 rRect.Left()-=mnOutOffX;
1680 rRect.Top()-=mnOutOffY;
1681 rRect.Right()-=mnOutOffX;
1682 rRect.Bottom()-=mnOutOffY;
1685 void Window::SetCompoundControl( BOOL bCompound )
1687 mpWindowImpl->mbCompoundControl = bCompound;
1690 void Window::IncrementLockCount()
1692 mpWindowImpl->mnLockCount++;
1695 void Window::DecrementLockCount()
1697 mpWindowImpl->mnLockCount--;
1700 WinBits Window::GetStyle() const
1702 return mpWindowImpl->mnStyle;
1705 WinBits Window::GetPrevStyle() const
1707 return mpWindowImpl->mnPrevStyle;
1710 WinBits Window::GetExtendedStyle() const
1712 return mpWindowImpl->mnExtendedStyle;
1715 WinBits Window::GetPrevExtendedStyle() const
1717 return mpWindowImpl->mnExtendedStyle;
1720 void Window::SetType( WindowType nType )
1722 mpWindowImpl->mnType = nType;
1725 WindowType Window::GetType() const
1727 return mpWindowImpl->mnType;
1729 BOOL Window::IsSystemWindow() const
1731 return mpWindowImpl->mbSysWin;
1734 BOOL Window::IsDialog() const
1736 return mpWindowImpl->mbDialog;
1739 BOOL Window::IsMenuFloatingWindow() const
1741 return mpWindowImpl->mbMenuFloatingWindow;
1744 BOOL Window::IsToolbarFloatingWindow() const
1746 return mpWindowImpl->mbToolbarFloatingWindow;
1749 void Window::EnableAllResize( BOOL bEnable )
1751 mpWindowImpl->mbAllResize = bEnable;
1754 BOOL Window::IsAllResizeEnabled() const
1756 return mpWindowImpl->mbAllResize;
1759 BOOL Window::IsClipSiblingsEnabled() const
1761 return mpWindowImpl->mbClipSiblings;
1764 void Window::EnableChildTransparentMode( BOOL bEnable )
1766 mpWindowImpl->mbChildTransparent = bEnable;
1769 BOOL Window::IsChildTransparentModeEnabled() const
1771 return mpWindowImpl->mbChildTransparent;
1774 BOOL Window::IsMouseTransparent() const
1776 return mpWindowImpl->mbMouseTransparent;
1779 BOOL Window::IsPaintTransparent() const
1781 return mpWindowImpl->mbPaintTransparent;
1784 void Window::SetDialogControlStart( BOOL bStart )
1786 mpWindowImpl->mbDlgCtrlStart = bStart;
1789 BOOL Window::IsDialogControlStart() const
1791 return mpWindowImpl->mbDlgCtrlStart;
1794 void Window::SetDialogControlFlags( USHORT nFlags )
1796 mpWindowImpl->mnDlgCtrlFlags = nFlags;
1799 USHORT Window::GetDialogControlFlags() const
1801 return mpWindowImpl->mnDlgCtrlFlags;
1804 const InputContext& Window::GetInputContext() const
1806 return mpWindowImpl->maInputContext;
1809 BOOL Window::IsExtTextInput() const
1811 return mpWindowImpl->mbExtTextInput;
1814 void Window::EnableChildNotify( BOOL bEnable )
1816 mpWindowImpl->mbChildNotify = bEnable;
1819 BOOL Window::IsChildNotify() const
1821 return mpWindowImpl->mbChildNotify;
1824 BOOL Window::IsControlFont() const
1826 return (mpWindowImpl->mpControlFont != 0);
1829 Color Window::GetControlForeground() const
1831 return mpWindowImpl->maControlForeground;
1834 BOOL Window::IsControlForeground() const
1836 return mpWindowImpl->mbControlForeground;
1839 Color Window::GetControlBackground() const
1841 return mpWindowImpl->maControlBackground;
1844 BOOL Window::IsControlBackground() const
1846 return mpWindowImpl->mbControlBackground;
1849 BOOL Window::IsInPaint() const
1851 return mpWindowImpl->mbInPaint;
1854 Window* Window::GetParent() const
1856 return mpWindowImpl->mpRealParent;
1859 BOOL Window::IsVisible() const
1861 return mpWindowImpl->mbVisible;
1864 BOOL Window::IsReallyVisible() const
1866 return mpWindowImpl->mbReallyVisible;
1869 BOOL Window::IsParentPathVisible() const
1871 return mpWindowImpl->mbReallyVisible;
1874 BOOL Window::IsReallyShown() const
1876 return mpWindowImpl->mbReallyShown;
1879 BOOL Window::IsInInitShow() const
1881 return mpWindowImpl->mbInInitShow;
1884 BOOL Window::IsEnabled() const
1886 return !mpWindowImpl->mbDisabled;
1889 BOOL Window::IsInputEnabled() const
1891 return !mpWindowImpl->mbInputDisabled;
1894 BOOL Window::IsAlwaysEnableInput() const
1896 return mpWindowImpl->meAlwaysInputMode == AlwaysInputEnabled;
1899 BOOL Window::IsAlwaysDisableInput() const
1901 return mpWindowImpl->meAlwaysInputMode == AlwaysInputDisabled;
1904 USHORT Window::GetActivateMode() const
1906 return mpWindowImpl->mnActivateMode;
1910 BOOL Window::IsAlwaysOnTopEnabled() const
1912 return mpWindowImpl->mbAlwaysOnTop;
1915 BOOL Window::IsDefaultPos() const
1917 return mpWindowImpl->mbDefPos;
1920 BOOL Window::IsDefaultSize() const
1922 return mpWindowImpl->mbDefSize;
1925 void Window::EnablePaint( BOOL bEnable )
1927 mpWindowImpl->mbPaintDisabled = !bEnable;
1930 BOOL Window::IsPaintEnabled() const
1932 return !mpWindowImpl->mbPaintDisabled;
1935 BOOL Window::IsUpdateMode() const
1937 return !mpWindowImpl->mbNoUpdate;
1940 void Window::SetParentUpdateMode( BOOL bUpdate )
1942 mpWindowImpl->mbNoParentUpdate = !bUpdate;
1945 BOOL Window::IsParentUpdateMode() const
1947 return !mpWindowImpl->mbNoParentUpdate;
1950 BOOL Window::IsActive() const
1952 return mpWindowImpl->mbActive;
1955 USHORT Window::GetGetFocusFlags() const
1957 return mpWindowImpl->mnGetFocusFlags;
1960 BOOL Window::IsCompoundControl() const
1962 return mpWindowImpl->mbCompoundControl;
1965 BOOL Window::HasCompoundControlFocus() const
1967 return mpWindowImpl->mbCompoundControlHasFocus;
1970 BOOL Window::IsChildPointerOverwrite() const
1972 return mpWindowImpl->mbChildPtrOverwrite;
1975 BOOL Window::IsPointerVisible() const
1977 return !mpWindowImpl->mbNoPtrVisible;
1980 BOOL Window::IsWait() const
1982 return (mpWindowImpl->mnWaitCount != 0);
1985 Cursor* Window::GetCursor() const
1987 return mpWindowImpl->mpCursor;
1990 const Fraction& Window::GetZoom() const
1992 return mpWindowImpl->maZoom;
1995 BOOL Window::IsZoom() const
1997 return mpWindowImpl->maZoom.GetNumerator() != mpWindowImpl->maZoom.GetDenominator();
2000 void Window::SetHelpText( const XubString& rHelpText )
2002 mpWindowImpl->maHelpText = rHelpText;
2005 void Window::SetQuickHelpText( const XubString& rHelpText )
2007 mpWindowImpl->maQuickHelpText = rHelpText;
2010 const XubString& Window::GetQuickHelpText() const
2012 return mpWindowImpl->maQuickHelpText;
2015 void Window::SetData( void* pNewData )
2017 mpWindowImpl->mpUserData = pNewData;
2020 void* Window::GetData() const
2022 return mpWindowImpl->mpUserData;
2025 BOOL Window::IsCreatedWithToolkit() const
2027 return mpWindowImpl->mbCreatedWithToolkit;
2030 void Window::SetCreatedWithToolkit( BOOL b )
2032 mpWindowImpl->mbCreatedWithToolkit = b;
2035 const Pointer& Window::GetPointer() const
2037 return mpWindowImpl->maPointer;
2040 VCLXWindow* Window::GetWindowPeer() const
2042 return mpWindowImpl->mpVCLXWindow;
2045 void Window::SetPosPixel( const Point& rNewPos )
2047 SetPosSizePixel( rNewPos.X(), rNewPos.Y(), 0, 0, WINDOW_POSSIZE_POS );
2050 void Window::SetSizePixel( const Size& rNewSize )
2052 SetPosSizePixel( 0, 0, rNewSize.Width(), rNewSize.Height(),
2053 WINDOW_POSSIZE_SIZE );
2056 void Window::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
2058 SetPosSizePixel( rNewPos.X(), rNewPos.Y(),
2059 rNewSize.Width(), rNewSize.Height(),
2060 WINDOW_POSSIZE_POSSIZE );
2063 void Window::SetOutputSizePixel( const Size& rNewSize )
2065 SetSizePixel( Size( rNewSize.Width()+mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder,
2066 rNewSize.Height()+mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder ) );