update credits
[LibreOffice.git] / vcl / source / window / window2.cxx
blob98d7559fde432a764d469ddd3d574cc02abbcf00
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <limits.h>
22 #include <tools/debug.hxx>
23 #include <tools/poly.hxx>
25 #include <vcl/bitmap.hxx>
26 #include <vcl/dialog.hxx>
27 #include <vcl/event.hxx>
28 #include <vcl/fixed.hxx>
29 #include <vcl/layout.hxx>
30 #include <vcl/timer.hxx>
31 #include <vcl/metric.hxx>
32 #include <vcl/virdev.hxx>
33 #include <vcl/window.hxx>
34 #include <vcl/scrbar.hxx>
35 #include <vcl/dockwin.hxx>
36 #include <vcl/tabctrl.hxx>
38 #include <window.h>
39 #include <outfont.hxx>
40 #include <outdev.h>
41 #include <svdata.hxx>
42 #include <impbmp.hxx>
43 #include <salbmp.hxx>
44 #include <salgdi.hxx>
45 #include <salframe.hxx>
46 #include <scrwnd.hxx>
48 using namespace com::sun::star;
50 // =======================================================================
52 DBG_NAMEEX( Window )
54 // =======================================================================
56 #define IMPL_MAXSAVEBACKSIZE (640*480)
57 #define IMPL_MAXALLSAVEBACKSIZE (800*600*2)
59 // =======================================================================
61 struct ImplFocusDelData : public ImplDelData
63 Window* mpFocusWin;
66 // =======================================================================
68 sal_Bool Window::ImplIsWindowInFront( const Window* pTestWindow ) const
70 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
71 DBG_CHKOBJ( pTestWindow, Window, ImplDbgCheckWindow );
73 // check for overlapping window
74 pTestWindow = pTestWindow->ImplGetFirstOverlapWindow();
75 const Window* pTempWindow = pTestWindow;
76 const Window* pThisWindow = ImplGetFirstOverlapWindow();
77 if ( pTempWindow == pThisWindow )
78 return sal_False;
81 if ( pTempWindow == pThisWindow )
82 return sal_True;
83 if ( pTempWindow->mpWindowImpl->mbFrame )
84 break;
85 pTempWindow = pTempWindow->mpWindowImpl->mpOverlapWindow;
87 while ( pTempWindow );
88 pTempWindow = pThisWindow;
91 if ( pTempWindow == pTestWindow )
92 return sal_False;
93 if ( pTempWindow->mpWindowImpl->mbFrame )
94 break;
95 pTempWindow = pTempWindow->mpWindowImpl->mpOverlapWindow;
97 while ( pTempWindow );
99 // move window to same level
100 if ( pThisWindow->mpWindowImpl->mpOverlapWindow != pTestWindow->mpWindowImpl->mpOverlapWindow )
102 sal_uInt16 nThisLevel = 0;
103 sal_uInt16 nTestLevel = 0;
104 pTempWindow = pThisWindow;
107 nThisLevel++;
108 pTempWindow = pTempWindow->mpWindowImpl->mpOverlapWindow;
110 while ( !pTempWindow->mpWindowImpl->mbFrame );
111 pTempWindow = pTestWindow;
114 nTestLevel++;
115 pTempWindow = pTempWindow->mpWindowImpl->mpOverlapWindow;
117 while ( !pTempWindow->mpWindowImpl->mbFrame );
119 if ( nThisLevel < nTestLevel )
123 if ( pTestWindow->mpWindowImpl->mpOverlapWindow == pThisWindow->mpWindowImpl->mpOverlapWindow )
124 break;
125 if ( pTestWindow->mpWindowImpl->mbFrame )
126 break;
127 pTestWindow = pTestWindow->mpWindowImpl->mpOverlapWindow;
129 while ( pTestWindow );
131 else
135 if ( pThisWindow->mpWindowImpl->mpOverlapWindow == pTempWindow->mpWindowImpl->mpOverlapWindow )
136 break;
137 if ( pThisWindow->mpWindowImpl->mbFrame )
138 break;
139 pThisWindow = pThisWindow->mpWindowImpl->mpOverlapWindow;
141 while ( pThisWindow );
145 // if TestWindow is before ThisWindow, it is in front
146 pTempWindow = pTestWindow;
149 if ( pTempWindow == pThisWindow )
150 return sal_True;
151 pTempWindow = pTempWindow->mpWindowImpl->mpNext;
153 while ( pTempWindow );
155 return sal_False;
158 // =======================================================================
160 void Window::ImplSaveOverlapBackground()
162 DBG_ASSERT( !mpWindowImpl->mpOverlapData->mpSaveBackDev, "Window::ImplSaveOverlapBackground() - Background already saved" );
164 if ( !mpWindowImpl->mbFrame )
166 sal_uLong nSaveBackSize = mnOutWidth*mnOutHeight;
167 if ( nSaveBackSize <= IMPL_MAXSAVEBACKSIZE )
169 if ( nSaveBackSize+mpWindowImpl->mpFrameData->mnAllSaveBackSize <= IMPL_MAXALLSAVEBACKSIZE )
171 Size aOutSize( mnOutWidth, mnOutHeight );
172 mpWindowImpl->mpOverlapData->mpSaveBackDev = new VirtualDevice( *mpWindowImpl->mpFrameWindow );
173 if ( mpWindowImpl->mpOverlapData->mpSaveBackDev->SetOutputSizePixel( aOutSize ) )
175 mpWindowImpl->mpFrameWindow->ImplUpdateAll();
177 if ( mpWindowImpl->mbInitWinClipRegion )
178 ImplInitWinClipRegion();
180 mpWindowImpl->mpOverlapData->mnSaveBackSize = nSaveBackSize;
181 mpWindowImpl->mpFrameData->mnAllSaveBackSize += nSaveBackSize;
182 Point aDevPt;
183 mpWindowImpl->mpFrameWindow->ImplGetFrameDev( Point( mnOutOffX, mnOutOffY ),
184 aDevPt, aOutSize,
185 *(mpWindowImpl->mpOverlapData->mpSaveBackDev) );
186 mpWindowImpl->mpOverlapData->mpNextBackWin = mpWindowImpl->mpFrameData->mpFirstBackWin;
187 mpWindowImpl->mpFrameData->mpFirstBackWin = this;
189 else
191 delete mpWindowImpl->mpOverlapData->mpSaveBackDev;
192 mpWindowImpl->mpOverlapData->mpSaveBackDev = NULL;
199 // -----------------------------------------------------------------------
201 sal_Bool Window::ImplRestoreOverlapBackground( Region& rInvRegion )
203 if ( mpWindowImpl->mpOverlapData->mpSaveBackDev )
205 if ( mpWindowImpl->mbInitWinClipRegion )
206 ImplInitWinClipRegion();
208 if ( mpWindowImpl->mpOverlapData->mpSaveBackDev )
210 Point aDevPt;
211 Point aDestPt( mnOutOffX, mnOutOffY );
212 Size aDevSize = mpWindowImpl->mpOverlapData->mpSaveBackDev->GetOutputSizePixel();
213 if ( mpWindowImpl->mpOverlapData->mpSaveBackRgn )
215 mpWindowImpl->mpOverlapData->mpSaveBackRgn->Intersect( mpWindowImpl->maWinClipRegion );
216 rInvRegion = mpWindowImpl->maWinClipRegion;
217 rInvRegion.Exclude( *mpWindowImpl->mpOverlapData->mpSaveBackRgn );
218 mpWindowImpl->mpFrameWindow->ImplDrawFrameDev( aDestPt, aDevPt, aDevSize,
219 *(mpWindowImpl->mpOverlapData->mpSaveBackDev),
220 *mpWindowImpl->mpOverlapData->mpSaveBackRgn );
222 else
224 mpWindowImpl->mpFrameWindow->ImplDrawFrameDev( aDestPt, aDevPt, aDevSize,
225 *(mpWindowImpl->mpOverlapData->mpSaveBackDev),
226 mpWindowImpl->maWinClipRegion );
228 ImplDeleteOverlapBackground();
231 return sal_True;
234 return sal_False;
237 // -----------------------------------------------------------------------
239 void Window::ImplDeleteOverlapBackground()
241 if ( mpWindowImpl->mpOverlapData->mpSaveBackDev )
243 mpWindowImpl->mpFrameData->mnAllSaveBackSize -= mpWindowImpl->mpOverlapData->mnSaveBackSize;
244 delete mpWindowImpl->mpOverlapData->mpSaveBackDev;
245 mpWindowImpl->mpOverlapData->mpSaveBackDev = NULL;
246 if ( mpWindowImpl->mpOverlapData->mpSaveBackRgn )
248 delete mpWindowImpl->mpOverlapData->mpSaveBackRgn;
249 mpWindowImpl->mpOverlapData->mpSaveBackRgn = NULL;
252 // remove window from the list
253 if ( mpWindowImpl->mpFrameData->mpFirstBackWin == this )
254 mpWindowImpl->mpFrameData->mpFirstBackWin = mpWindowImpl->mpOverlapData->mpNextBackWin;
255 else
257 Window* pTemp = mpWindowImpl->mpFrameData->mpFirstBackWin;
258 while ( pTemp->mpWindowImpl->mpOverlapData->mpNextBackWin != this )
259 pTemp = pTemp->mpWindowImpl->mpOverlapData->mpNextBackWin;
260 pTemp->mpWindowImpl->mpOverlapData->mpNextBackWin = mpWindowImpl->mpOverlapData->mpNextBackWin;
262 mpWindowImpl->mpOverlapData->mpNextBackWin = NULL;
266 // -----------------------------------------------------------------------
268 void Window::ImplInvalidateAllOverlapBackgrounds()
270 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
272 Window* pWindow = mpWindowImpl->mpFrameData->mpFirstBackWin;
273 while ( pWindow )
275 // remember next window here already, as this window could
276 // be removed within the next if clause from the list
277 Window* pNext = pWindow->mpWindowImpl->mpOverlapData->mpNextBackWin;
279 if ( ImplIsWindowInFront( pWindow ) )
281 Rectangle aRect1( Point( mnOutOffX, mnOutOffY ),
282 Size( mnOutWidth, mnOutHeight ) );
283 Rectangle aRect2( Point( pWindow->mnOutOffX, pWindow->mnOutOffY ),
284 Size( pWindow->mnOutWidth, pWindow->mnOutHeight ) );
285 aRect1.Intersection( aRect2 );
286 if ( !aRect1.IsEmpty() )
288 if ( !pWindow->mpWindowImpl->mpOverlapData->mpSaveBackRgn )
289 pWindow->mpWindowImpl->mpOverlapData->mpSaveBackRgn = new Region( aRect2 );
290 pWindow->mpWindowImpl->mpOverlapData->mpSaveBackRgn->Exclude( aRect1 );
291 if ( pWindow->mpWindowImpl->mpOverlapData->mpSaveBackRgn->IsEmpty() )
292 pWindow->ImplDeleteOverlapBackground();
297 pWindow = pNext;
301 // -----------------------------------------------------------------------
303 void Window::ShowFocus( const Rectangle& rRect )
305 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
307 if( mpWindowImpl->mbInShowFocus )
308 return;
309 mpWindowImpl->mbInShowFocus = sal_True;
311 ImplWinData* pWinData = ImplGetWinData();
313 // native themeing suggest not to use focus rects
314 if( ! ( mpWindowImpl->mbUseNativeFocus &&
315 IsNativeWidgetEnabled() ) )
317 if ( !mpWindowImpl->mbInPaint )
319 if ( mpWindowImpl->mbFocusVisible )
321 if ( *(pWinData->mpFocusRect) == rRect )
323 mpWindowImpl->mbInShowFocus = sal_False;
324 return;
327 ImplInvertFocus( *(pWinData->mpFocusRect) );
330 ImplInvertFocus( rRect );
332 if ( !pWinData->mpFocusRect )
333 pWinData->mpFocusRect = new Rectangle( rRect );
334 else
335 *(pWinData->mpFocusRect) = rRect;
336 mpWindowImpl->mbFocusVisible = sal_True;
338 else
340 if( ! mpWindowImpl->mbNativeFocusVisible )
342 mpWindowImpl->mbNativeFocusVisible = sal_True;
343 if ( !mpWindowImpl->mbInPaint )
344 Invalidate();
347 mpWindowImpl->mbInShowFocus = sal_False;
350 // -----------------------------------------------------------------------
352 void Window::HideFocus()
354 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
356 if( mpWindowImpl->mbInHideFocus )
357 return;
358 mpWindowImpl->mbInHideFocus = sal_True;
360 // native themeing can suggest not to use focus rects
361 if( ! ( mpWindowImpl->mbUseNativeFocus &&
362 IsNativeWidgetEnabled() ) )
364 if ( !mpWindowImpl->mbFocusVisible )
366 mpWindowImpl->mbInHideFocus = sal_False;
367 return;
370 if ( !mpWindowImpl->mbInPaint )
371 ImplInvertFocus( *(ImplGetWinData()->mpFocusRect) );
372 mpWindowImpl->mbFocusVisible = sal_False;
374 else
376 if( mpWindowImpl->mbNativeFocusVisible )
378 mpWindowImpl->mbNativeFocusVisible = sal_False;
379 if ( !mpWindowImpl->mbInPaint )
380 Invalidate();
383 mpWindowImpl->mbInHideFocus = sal_False;
386 // -----------------------------------------------------------------------
388 void Window::Invert( const Rectangle& rRect, sal_uInt16 nFlags )
390 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
392 if ( !IsDeviceOutputNecessary() )
393 return;
395 Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
397 if ( aRect.IsEmpty() )
398 return;
399 aRect.Justify();
401 // we need a graphics
402 if ( !mpGraphics )
404 if ( !ImplGetGraphics() )
405 return;
408 if ( mbInitClipRegion )
409 ImplInitClipRegion();
411 if ( mbOutputClipped )
412 return;
414 SalInvert nSalFlags = 0;
415 if ( nFlags & INVERT_HIGHLIGHT )
416 nSalFlags |= SAL_INVERT_HIGHLIGHT;
417 if ( nFlags & INVERT_50 )
418 nSalFlags |= SAL_INVERT_50;
419 mpGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), nSalFlags, this );
422 // -----------------------------------------------------------------------
424 void Window::Invert( const Polygon& rPoly, sal_uInt16 nFlags )
426 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
428 if ( !IsDeviceOutputNecessary() )
429 return;
431 sal_uInt16 nPoints = rPoly.GetSize();
433 if ( nPoints < 2 )
434 return;
436 Polygon aPoly( ImplLogicToDevicePixel( rPoly ) );
438 // we need a graphics
439 if ( !mpGraphics )
441 if ( !ImplGetGraphics() )
442 return;
445 if ( mbInitClipRegion )
446 ImplInitClipRegion();
448 if ( mbOutputClipped )
449 return;
451 SalInvert nSalFlags = 0;
452 if ( nFlags & INVERT_HIGHLIGHT )
453 nSalFlags |= SAL_INVERT_HIGHLIGHT;
454 if ( nFlags & INVERT_50 )
455 nSalFlags |= SAL_INVERT_50;
456 const SalPoint* pPtAry = (const SalPoint*)aPoly.GetConstPointAry();
457 mpGraphics->Invert( nPoints, pPtAry, nSalFlags, this );
460 // -----------------------------------------------------------------------
462 void Window::ShowTracking( const Rectangle& rRect, sal_uInt16 nFlags )
464 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
466 ImplWinData* pWinData = ImplGetWinData();
468 if ( !mpWindowImpl->mbInPaint || !(nFlags & SHOWTRACK_WINDOW) )
470 if ( mpWindowImpl->mbTrackVisible )
472 if ( (*(pWinData->mpTrackRect) == rRect) &&
473 (pWinData->mnTrackFlags == nFlags) )
474 return;
476 InvertTracking( *(pWinData->mpTrackRect), pWinData->mnTrackFlags );
479 InvertTracking( rRect, nFlags );
482 if ( !pWinData->mpTrackRect )
483 pWinData->mpTrackRect = new Rectangle( rRect );
484 else
485 *(pWinData->mpTrackRect) = rRect;
486 pWinData->mnTrackFlags = nFlags;
487 mpWindowImpl->mbTrackVisible = sal_True;
490 // -----------------------------------------------------------------------
492 void Window::HideTracking()
494 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
496 if ( mpWindowImpl->mbTrackVisible )
498 ImplWinData* pWinData = ImplGetWinData();
499 if ( !mpWindowImpl->mbInPaint || !(pWinData->mnTrackFlags & SHOWTRACK_WINDOW) )
500 InvertTracking( *(pWinData->mpTrackRect), pWinData->mnTrackFlags );
501 mpWindowImpl->mbTrackVisible = sal_False;
505 // -----------------------------------------------------------------------
507 void Window::InvertTracking( const Rectangle& rRect, sal_uInt16 nFlags )
509 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
511 Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
513 if ( aRect.IsEmpty() )
514 return;
515 aRect.Justify();
517 SalGraphics* pGraphics;
519 if ( nFlags & SHOWTRACK_WINDOW )
521 if ( !IsDeviceOutputNecessary() )
522 return;
524 // we need a graphics
525 if ( !mpGraphics )
527 if ( !ImplGetGraphics() )
528 return;
531 if ( mbInitClipRegion )
532 ImplInitClipRegion();
534 if ( mbOutputClipped )
535 return;
537 pGraphics = mpGraphics;
539 else
541 pGraphics = ImplGetFrameGraphics();
543 if ( nFlags & SHOWTRACK_CLIP )
545 Point aPoint( mnOutOffX, mnOutOffY );
546 Region aRegion( Rectangle( aPoint,
547 Size( mnOutWidth, mnOutHeight ) ) );
548 ImplClipBoundaries( aRegion, sal_False, sal_False );
549 ImplSelectClipRegion( aRegion, pGraphics );
553 sal_uInt16 nStyle = nFlags & SHOWTRACK_STYLE;
554 if ( nStyle == SHOWTRACK_OBJECT )
555 pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), SAL_INVERT_TRACKFRAME, this );
556 else if ( nStyle == SHOWTRACK_SPLIT )
557 pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), SAL_INVERT_50, this );
558 else
560 long nBorder = 1;
561 if ( nStyle == SHOWTRACK_BIG )
562 nBorder = 5;
563 pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), nBorder, SAL_INVERT_50, this );
564 pGraphics->Invert( aRect.Left(), aRect.Bottom()-nBorder+1, aRect.GetWidth(), nBorder, SAL_INVERT_50, this );
565 pGraphics->Invert( aRect.Left(), aRect.Top()+nBorder, nBorder, aRect.GetHeight()-(nBorder*2), SAL_INVERT_50, this );
566 pGraphics->Invert( aRect.Right()-nBorder+1, aRect.Top()+nBorder, nBorder, aRect.GetHeight()-(nBorder*2), SAL_INVERT_50, this );
570 // -----------------------------------------------------------------------
572 void Window::InvertTracking( const Polygon& rPoly, sal_uInt16 nFlags )
574 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
576 sal_uInt16 nPoints = rPoly.GetSize();
578 if ( nPoints < 2 )
579 return;
581 Polygon aPoly( ImplLogicToDevicePixel( rPoly ) );
583 SalGraphics* pGraphics;
585 if ( nFlags & SHOWTRACK_WINDOW )
587 if ( !IsDeviceOutputNecessary() )
588 return;
590 // we need a graphics
591 if ( !mpGraphics )
593 if ( !ImplGetGraphics() )
594 return;
597 if ( mbInitClipRegion )
598 ImplInitClipRegion();
600 if ( mbOutputClipped )
601 return;
603 pGraphics = mpGraphics;
605 else
607 pGraphics = ImplGetFrameGraphics();
609 if ( nFlags & SHOWTRACK_CLIP )
611 Point aPoint( mnOutOffX, mnOutOffY );
612 Region aRegion( Rectangle( aPoint,
613 Size( mnOutWidth, mnOutHeight ) ) );
614 ImplClipBoundaries( aRegion, sal_False, sal_False );
615 ImplSelectClipRegion( aRegion, pGraphics );
619 const SalPoint* pPtAry = (const SalPoint*)aPoly.GetConstPointAry();
620 pGraphics->Invert( nPoints, pPtAry, SAL_INVERT_TRACKFRAME, this );
623 // -----------------------------------------------------------------------
625 IMPL_LINK( Window, ImplTrackTimerHdl, Timer*, pTimer )
627 ImplSVData* pSVData = ImplGetSVData();
629 // Bei Button-Repeat muessen wir den Timeout umsetzen
630 if ( pSVData->maWinData.mnTrackFlags & STARTTRACK_BUTTONREPEAT )
631 pTimer->SetTimeout( GetSettings().GetMouseSettings().GetButtonRepeat() );
633 // Tracking-Event erzeugen
634 Point aMousePos( mpWindowImpl->mpFrameData->mnLastMouseX, mpWindowImpl->mpFrameData->mnLastMouseY );
635 if( ImplIsAntiparallel() )
637 // - RTL - re-mirror frame pos at pChild
638 ImplReMirror( aMousePos );
640 MouseEvent aMEvt( ImplFrameToOutput( aMousePos ),
641 mpWindowImpl->mpFrameData->mnClickCount, 0,
642 mpWindowImpl->mpFrameData->mnMouseCode, mpWindowImpl->mpFrameData->mnMouseCode );
643 TrackingEvent aTEvt( aMEvt, TRACKING_REPEAT );
644 Tracking( aTEvt );
646 return 0;
649 // -----------------------------------------------------------------------
651 void Window::StartTracking( sal_uInt16 nFlags )
653 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
655 ImplSVData* pSVData = ImplGetSVData();
657 if ( pSVData->maWinData.mpTrackWin != this )
659 if ( pSVData->maWinData.mpTrackWin )
660 pSVData->maWinData.mpTrackWin->EndTracking( ENDTRACK_CANCEL );
663 if ( nFlags & (STARTTRACK_SCROLLREPEAT | STARTTRACK_BUTTONREPEAT) )
665 pSVData->maWinData.mpTrackTimer = new AutoTimer;
667 if ( nFlags & STARTTRACK_SCROLLREPEAT )
668 pSVData->maWinData.mpTrackTimer->SetTimeout( GetSettings().GetMouseSettings().GetScrollRepeat() );
669 else
670 pSVData->maWinData.mpTrackTimer->SetTimeout( GetSettings().GetMouseSettings().GetButtonStartRepeat() );
671 pSVData->maWinData.mpTrackTimer->SetTimeoutHdl( LINK( this, Window, ImplTrackTimerHdl ) );
672 pSVData->maWinData.mpTrackTimer->Start();
675 pSVData->maWinData.mpTrackWin = this;
676 pSVData->maWinData.mnTrackFlags = nFlags;
677 CaptureMouse();
680 // -----------------------------------------------------------------------
682 void Window::EndTracking( sal_uInt16 nFlags )
684 ImplSVData* pSVData = ImplGetSVData();
686 if ( pSVData->maWinData.mpTrackWin == this )
688 // due to DbgChkThis in brackets, as the window could be destroyed
689 // in the handler
691 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
693 if ( pSVData->maWinData.mpTrackTimer )
695 delete pSVData->maWinData.mpTrackTimer;
696 pSVData->maWinData.mpTrackTimer = NULL;
699 pSVData->maWinData.mpTrackWin = NULL;
700 pSVData->maWinData.mnTrackFlags = 0;
701 ReleaseMouse();
704 // call EndTracking if required
705 if ( !(nFlags & ENDTRACK_DONTCALLHDL) )
707 Point aMousePos( mpWindowImpl->mpFrameData->mnLastMouseX, mpWindowImpl->mpFrameData->mnLastMouseY );
708 if( ImplIsAntiparallel() )
710 // - RTL - re-mirror frame pos at pChild
711 ImplReMirror( aMousePos );
714 MouseEvent aMEvt( ImplFrameToOutput( aMousePos ),
715 mpWindowImpl->mpFrameData->mnClickCount, 0,
716 mpWindowImpl->mpFrameData->mnMouseCode, mpWindowImpl->mpFrameData->mnMouseCode );
717 TrackingEvent aTEvt( aMEvt, nFlags | ENDTRACK_END );
718 Tracking( aTEvt );
723 // -----------------------------------------------------------------------
725 sal_Bool Window::IsTracking() const
727 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
729 return (ImplGetSVData()->maWinData.mpTrackWin == this);
732 // -----------------------------------------------------------------------
734 void Window::StartAutoScroll( sal_uInt16 nFlags )
736 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
738 ImplSVData* pSVData = ImplGetSVData();
740 if ( pSVData->maWinData.mpAutoScrollWin != this )
742 if ( pSVData->maWinData.mpAutoScrollWin )
743 pSVData->maWinData.mpAutoScrollWin->EndAutoScroll();
746 pSVData->maWinData.mpAutoScrollWin = this;
747 pSVData->maWinData.mnAutoScrollFlags = nFlags;
748 pSVData->maAppData.mpWheelWindow = new ImplWheelWindow( this );
751 // -----------------------------------------------------------------------
753 void Window::EndAutoScroll()
755 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
757 ImplSVData* pSVData = ImplGetSVData();
759 if ( pSVData->maWinData.mpAutoScrollWin == this )
761 pSVData->maWinData.mpAutoScrollWin = NULL;
762 pSVData->maWinData.mnAutoScrollFlags = 0;
763 pSVData->maAppData.mpWheelWindow->ImplStop();
764 pSVData->maAppData.mpWheelWindow->doLazyDelete();
765 pSVData->maAppData.mpWheelWindow = NULL;
769 // -----------------------------------------------------------------------
771 void Window::SaveBackground( const Point& rPos, const Size& rSize,
772 const Point& rDestOff, VirtualDevice& rSaveDevice )
774 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
776 if ( mpWindowImpl->mpPaintRegion )
778 Region aClip( *mpWindowImpl->mpPaintRegion );
779 const Point aPixPos( LogicToPixel( rPos ) );
781 aClip.Move( -mnOutOffX, -mnOutOffY );
782 aClip.Intersect( Rectangle( aPixPos, LogicToPixel( rSize ) ) );
784 if ( !aClip.IsEmpty() )
786 const Region aOldClip( rSaveDevice.GetClipRegion() );
787 const Point aPixOffset( rSaveDevice.LogicToPixel( rDestOff ) );
788 const sal_Bool bMap = rSaveDevice.IsMapModeEnabled();
790 // move clip region to have the same distance to DestOffset
791 aClip.Move( aPixOffset.X() - aPixPos.X(), aPixOffset.Y() - aPixPos.Y() );
793 // set pixel clip region
794 rSaveDevice.EnableMapMode( sal_False );
795 rSaveDevice.SetClipRegion( aClip );
796 rSaveDevice.EnableMapMode( bMap );
797 rSaveDevice.DrawOutDev( rDestOff, rSize, rPos, rSize, *this );
798 rSaveDevice.SetClipRegion( aOldClip );
801 else
802 rSaveDevice.DrawOutDev( rDestOff, rSize, rPos, rSize, *this );
805 // -----------------------------------------------------------------------
807 sal_uIntPtr Window::SaveFocus()
809 ImplSVData* pSVData = ImplGetSVData();
810 if ( pSVData->maWinData.mpFocusWin )
812 ImplFocusDelData* pDelData = new ImplFocusDelData;
813 pSVData->maWinData.mpFocusWin->ImplAddDel( pDelData );
814 pDelData->mpFocusWin = pSVData->maWinData.mpFocusWin;
815 return (sal_uIntPtr)(void*)pDelData;
817 else
818 return 0;
821 // -----------------------------------------------------------------------
823 sal_Bool Window::EndSaveFocus( sal_uIntPtr nSaveId, sal_Bool bRestore )
825 if ( !nSaveId )
826 return sal_False;
827 else
829 sal_Bool bOK = sal_True;
830 ImplFocusDelData* pDelData = (ImplFocusDelData*)(void*)nSaveId;
831 if ( !pDelData->IsDead() )
833 pDelData->mpFocusWin->ImplRemoveDel( pDelData );
834 if ( bRestore )
835 pDelData->mpFocusWin->GrabFocus();
837 else
838 bOK = !bRestore;
839 delete pDelData;
840 return bOK;
844 // -----------------------------------------------------------------------
846 void Window::SetZoom( const Fraction& rZoom )
848 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
850 if ( mpWindowImpl->maZoom != rZoom )
852 mpWindowImpl->maZoom = rZoom;
853 StateChanged( STATE_CHANGE_ZOOM );
857 // -----------------------------------------------------------------------
859 inline long WinFloatRound( double fVal )
861 return( fVal > 0.0 ? (long) ( fVal + 0.5 ) : -(long) ( -fVal + 0.5 ) );
864 // -----------------------------------------------------------------------
866 void Window::SetZoomedPointFont( const Font& rFont )
868 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
870 const Fraction& rZoom = GetZoom();
871 if ( rZoom.GetNumerator() != rZoom.GetDenominator() )
873 Font aFont( rFont );
874 Size aSize = aFont.GetSize();
875 double n = (double)aSize.Width();
876 n *= (double)rZoom.GetNumerator();
877 n /= (double)rZoom.GetDenominator();
878 aSize.Width() = WinFloatRound( n );
879 n = (double)aSize.Height();
880 n *= (double)rZoom.GetNumerator();
881 n /= (double)rZoom.GetDenominator();
882 aSize.Height() = WinFloatRound( n );
883 aFont.SetSize( aSize );
884 SetPointFont( aFont );
886 // Use another font if the representation is to be scaled,
887 // and the actual font is not scalable
888 FontMetric aMetric = GetFontMetric();
889 long nFontDiff = std::abs( GetFont().GetSize().Height()-aMetric.GetSize().Height() );
890 if ( (aMetric.GetType() == TYPE_RASTER) && (nFontDiff >= 2) )
892 sal_uInt16 nType;
893 if ( aMetric.GetPitch() == PITCH_FIXED )
894 nType = DEFAULTFONT_FIXED;
895 else
896 nType = DEFAULTFONT_UI_SANS;
897 Font aTempFont = GetDefaultFont( nType, GetSettings().GetLanguageTag().getLanguageType(), 0 );
898 aFont.SetName( aTempFont.GetName() );
899 SetPointFont( aFont );
902 else
903 SetPointFont( rFont );
906 // -----------------------------------------------------------------------
908 long Window::CalcZoom( long nCalc ) const
910 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
912 const Fraction& rZoom = GetZoom();
913 if ( rZoom.GetNumerator() != rZoom.GetDenominator() )
915 double n = (double)nCalc;
916 n *= (double)rZoom.GetNumerator();
917 n /= (double)rZoom.GetDenominator();
918 nCalc = WinFloatRound( n );
920 return nCalc;
923 // -----------------------------------------------------------------------
925 void Window::SetControlFont()
927 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
929 if ( mpWindowImpl->mpControlFont )
931 delete mpWindowImpl->mpControlFont;
932 mpWindowImpl->mpControlFont = NULL;
933 StateChanged( STATE_CHANGE_CONTROLFONT );
937 // -----------------------------------------------------------------------
939 void Window::SetControlFont( const Font& rFont )
941 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
943 if ( rFont == Font() )
945 SetControlFont();
946 return;
949 if ( mpWindowImpl->mpControlFont )
951 if ( *mpWindowImpl->mpControlFont == rFont )
952 return;
953 *mpWindowImpl->mpControlFont = rFont;
955 else
956 mpWindowImpl->mpControlFont = new Font( rFont );
958 StateChanged( STATE_CHANGE_CONTROLFONT );
961 // -----------------------------------------------------------------------
963 Font Window::GetControlFont() const
965 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
967 if ( mpWindowImpl->mpControlFont )
968 return *mpWindowImpl->mpControlFont;
969 else
971 Font aFont;
972 return aFont;
976 // -----------------------------------------------------------------------
978 void Window::SetControlForeground()
980 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
982 if ( mpWindowImpl->mbControlForeground )
984 mpWindowImpl->maControlForeground = Color( COL_TRANSPARENT );
985 mpWindowImpl->mbControlForeground = sal_False;
986 StateChanged( STATE_CHANGE_CONTROLFOREGROUND );
990 // -----------------------------------------------------------------------
992 void Window::SetControlForeground( const Color& rColor )
994 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
996 if ( rColor.GetTransparency() )
998 if ( mpWindowImpl->mbControlForeground )
1000 mpWindowImpl->maControlForeground = Color( COL_TRANSPARENT );
1001 mpWindowImpl->mbControlForeground = sal_False;
1002 StateChanged( STATE_CHANGE_CONTROLFOREGROUND );
1005 else
1007 if ( mpWindowImpl->maControlForeground != rColor )
1009 mpWindowImpl->maControlForeground = rColor;
1010 mpWindowImpl->mbControlForeground = sal_True;
1011 StateChanged( STATE_CHANGE_CONTROLFOREGROUND );
1016 // -----------------------------------------------------------------------
1018 void Window::SetControlBackground()
1020 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1022 if ( mpWindowImpl->mbControlBackground )
1024 mpWindowImpl->maControlBackground = Color( COL_TRANSPARENT );
1025 mpWindowImpl->mbControlBackground = sal_False;
1026 StateChanged( STATE_CHANGE_CONTROLBACKGROUND );
1030 // -----------------------------------------------------------------------
1032 void Window::SetControlBackground( const Color& rColor )
1034 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1036 if ( rColor.GetTransparency() )
1038 if ( mpWindowImpl->mbControlBackground )
1040 mpWindowImpl->maControlBackground = Color( COL_TRANSPARENT );
1041 mpWindowImpl->mbControlBackground = sal_False;
1042 StateChanged( STATE_CHANGE_CONTROLBACKGROUND );
1045 else
1047 if ( mpWindowImpl->maControlBackground != rColor )
1049 mpWindowImpl->maControlBackground = rColor;
1050 mpWindowImpl->mbControlBackground = sal_True;
1051 StateChanged( STATE_CHANGE_CONTROLBACKGROUND );
1056 // -----------------------------------------------------------------------
1058 Size Window::CalcWindowSize( const Size& rOutSz ) const
1060 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1062 Size aSz = rOutSz;
1063 aSz.Width() += mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder;
1064 aSz.Height() += mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder;
1065 return aSz;
1068 // -----------------------------------------------------------------------
1070 Size Window::CalcOutputSize( const Size& rWinSz ) const
1072 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1074 Size aSz = rWinSz;
1075 aSz.Width() -= mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder;
1076 aSz.Height() -= mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder;
1077 return aSz;
1080 // -----------------------------------------------------------------------
1082 Font Window::GetDrawPixelFont( OutputDevice* pDev ) const
1084 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1086 Font aFont = GetPointFont();
1087 Size aFontSize = aFont.GetSize();
1088 MapMode aPtMapMode( MAP_POINT );
1089 aFontSize = pDev->LogicToPixel( aFontSize, aPtMapMode );
1090 aFont.SetSize( aFontSize );
1091 return aFont;
1094 // -----------------------------------------------------------------------
1096 long Window::GetDrawPixel( OutputDevice* pDev, long nPixels ) const
1098 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1100 long nP = nPixels;
1101 if ( pDev->GetOutDevType() != OUTDEV_WINDOW )
1103 MapMode aMap( MAP_100TH_MM );
1104 Size aSz( nP, 0 );
1105 aSz = PixelToLogic( aSz, aMap );
1106 aSz = pDev->LogicToPixel( aSz, aMap );
1107 nP = aSz.Width();
1109 return nP;
1112 // -----------------------------------------------------------------------
1114 sal_Bool Window::HandleScrollCommand( const CommandEvent& rCmd,
1115 ScrollBar* pHScrl, ScrollBar* pVScrl )
1117 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
1119 sal_Bool bRet = sal_False;
1121 if ( pHScrl || pVScrl )
1123 switch( rCmd.GetCommand() )
1125 case COMMAND_STARTAUTOSCROLL:
1127 sal_uInt16 nFlags = 0;
1128 if ( pHScrl )
1130 if ( (pHScrl->GetVisibleSize() < pHScrl->GetRangeMax()) &&
1131 pHScrl->IsEnabled() && pHScrl->IsInputEnabled() && ! pHScrl->IsInModalMode() )
1132 nFlags |= AUTOSCROLL_HORZ;
1134 if ( pVScrl )
1136 if ( (pVScrl->GetVisibleSize() < pVScrl->GetRangeMax()) &&
1137 pVScrl->IsEnabled() && pVScrl->IsInputEnabled() && ! pVScrl->IsInModalMode() )
1138 nFlags |= AUTOSCROLL_VERT;
1141 if ( nFlags )
1143 StartAutoScroll( nFlags );
1144 bRet = sal_True;
1147 break;
1149 case COMMAND_WHEEL:
1151 const CommandWheelData* pData = rCmd.GetWheelData();
1153 if ( pData && (COMMAND_WHEEL_SCROLL == pData->GetMode()) )
1155 sal_uLong nScrollLines = pData->GetScrollLines();
1156 long nLines;
1157 if ( nScrollLines == COMMAND_WHEEL_PAGESCROLL )
1159 if ( pData->GetDelta() < 0 )
1160 nLines = -LONG_MAX;
1161 else
1162 nLines = LONG_MAX;
1164 else
1165 nLines = pData->GetNotchDelta() * (long)nScrollLines;
1166 if ( nLines )
1168 ImplHandleScroll( NULL,
1170 pData->IsHorz() ? pHScrl : pVScrl,
1171 nLines );
1172 bRet = sal_True;
1176 break;
1178 case COMMAND_AUTOSCROLL:
1180 const CommandScrollData* pData = rCmd.GetAutoScrollData();
1181 if ( pData && (pData->GetDeltaX() || pData->GetDeltaY()) )
1183 ImplHandleScroll( pHScrl, pData->GetDeltaX(),
1184 pVScrl, pData->GetDeltaY() );
1185 bRet = sal_True;
1188 break;
1190 default:
1191 break;
1195 return bRet;
1198 // -----------------------------------------------------------------------
1200 static void lcl_HandleScrollHelper( ScrollBar* pScrl, long nN )
1202 if ( pScrl && nN && pScrl->IsEnabled() && pScrl->IsInputEnabled() && ! pScrl->IsInModalMode() )
1204 long nNewPos = pScrl->GetThumbPos();
1206 if ( nN == -LONG_MAX )
1207 nNewPos += pScrl->GetPageSize();
1208 else if ( nN == LONG_MAX )
1209 nNewPos -= pScrl->GetPageSize();
1210 else
1212 const double fVal = (double)nNewPos - ((double)nN * pScrl->GetLineSize());
1214 if ( fVal < LONG_MIN )
1215 nNewPos = LONG_MIN;
1216 else if ( fVal > LONG_MAX )
1217 nNewPos = LONG_MAX;
1218 else
1219 nNewPos = (long)fVal;
1222 pScrl->DoScroll( nNewPos );
1227 // Note that when called for COMMAND_WHEEL above, despite its name,
1228 // pVScrl isn't necessarily the vertical scroll bar. Depending on
1229 // whether the scroll is horizontal or vertical, it is either the
1230 // horizontal or vertical scroll bar. nY is correspondingly either
1231 // the horizontal or vertical scroll amount.
1233 void Window::ImplHandleScroll( ScrollBar* pHScrl, long nX,
1234 ScrollBar* pVScrl, long nY )
1236 lcl_HandleScrollHelper( pHScrl, nX );
1237 lcl_HandleScrollHelper( pVScrl, nY );
1240 DockingManager* Window::GetDockingManager()
1242 return ImplGetDockingManager();
1245 void Window::EnableDocking( sal_Bool bEnable )
1247 // update list of dockable windows
1248 if( bEnable )
1249 ImplGetDockingManager()->AddWindow( this );
1250 else
1251 ImplGetDockingManager()->RemoveWindow( this );
1255 // retrieves the list of owner draw decorated windows for this window hiearchy
1256 ::std::vector<Window *>& Window::ImplGetOwnerDrawList()
1258 return ImplGetTopmostFrameWindow()->mpWindowImpl->mpFrameData->maOwnerDrawList;
1261 Window* Window::ImplGetTopmostFrameWindow()
1263 Window *pTopmostParent = this;
1264 while( pTopmostParent->ImplGetParent() )
1265 pTopmostParent = pTopmostParent->ImplGetParent();
1266 return pTopmostParent->mpWindowImpl->mpFrameWindow;
1269 void Window::SetHelpId( const OString& rHelpId )
1271 mpWindowImpl->maHelpId = rHelpId;
1274 const OString& Window::GetHelpId() const
1276 return mpWindowImpl->maHelpId;
1279 void Window::SetUniqueId( const OString& rUniqueId )
1281 mpWindowImpl->maUniqId = rUniqueId;
1284 const OString& Window::GetUniqueId() const
1286 return mpWindowImpl->maUniqId;
1289 // --------- old inline methods ---------------
1291 Window* Window::ImplGetWindow()
1293 if ( mpWindowImpl->mpClientWindow )
1294 return mpWindowImpl->mpClientWindow;
1295 else
1296 return this;
1299 ImplFrameData* Window::ImplGetFrameData()
1301 return mpWindowImpl->mpFrameData;
1304 SalFrame* Window::ImplGetFrame() const
1306 return mpWindowImpl->mpFrame;
1309 Window* Window::ImplGetParent() const
1311 return mpWindowImpl->mpParent;
1314 Window* Window::ImplGetClientWindow() const
1316 return mpWindowImpl->mpClientWindow;
1319 Window* Window::ImplGetBorderWindow() const
1321 return mpWindowImpl->mpBorderWindow;
1324 Window* Window::ImplGetFirstOverlapWindow()
1326 if ( mpWindowImpl->mbOverlapWin )
1327 return this;
1328 else
1329 return mpWindowImpl->mpOverlapWindow;
1332 const Window* Window::ImplGetFirstOverlapWindow() const
1334 if ( mpWindowImpl->mbOverlapWin )
1335 return this;
1336 else
1337 return mpWindowImpl->mpOverlapWindow;
1340 Window* Window::ImplGetFrameWindow() const
1342 return mpWindowImpl->mpFrameWindow;
1345 sal_Bool Window::ImplIsDockingWindow() const
1347 return mpWindowImpl->mbDockWin;
1350 sal_Bool Window::ImplIsFloatingWindow() const
1352 return mpWindowImpl->mbFloatWin;
1355 sal_Bool Window::ImplIsSplitter() const
1357 return mpWindowImpl->mbSplitter;
1360 sal_Bool Window::ImplIsPushButton() const
1362 return mpWindowImpl->mbPushButton;
1365 sal_Bool Window::ImplIsOverlapWindow() const
1367 return mpWindowImpl->mbOverlapWin;
1370 void Window::ImplSetMouseTransparent( sal_Bool bTransparent )
1372 mpWindowImpl->mbMouseTransparent = bTransparent;
1375 Point Window::ImplOutputToFrame( const Point& rPos )
1377 return Point( rPos.X()+mnOutOffX, rPos.Y()+mnOutOffY );
1380 Point Window::ImplFrameToOutput( const Point& rPos )
1382 return Point( rPos.X()-mnOutOffX, rPos.Y()-mnOutOffY );
1385 void Window::SetCompoundControl( sal_Bool bCompound )
1387 mpWindowImpl->mbCompoundControl = bCompound;
1390 void Window::IncrementLockCount()
1392 mpWindowImpl->mnLockCount++;
1395 void Window::DecrementLockCount()
1397 mpWindowImpl->mnLockCount--;
1400 WinBits Window::GetStyle() const
1402 return mpWindowImpl->mnStyle;
1405 WinBits Window::GetPrevStyle() const
1407 return mpWindowImpl->mnPrevStyle;
1410 WinBits Window::GetExtendedStyle() const
1412 return mpWindowImpl->mnExtendedStyle;
1415 void Window::SetType( WindowType nType )
1417 mpWindowImpl->mnType = nType;
1420 WindowType Window::GetType() const
1422 return mpWindowImpl->mnType;
1425 Dialog* Window::GetParentDialog() const
1427 const Window *pWindow = this;
1429 while( pWindow )
1431 if( pWindow->IsDialog() )
1432 break;
1434 pWindow = pWindow->GetParent();
1437 return const_cast<Dialog *>(dynamic_cast<const Dialog*>(pWindow));
1440 sal_Bool Window::IsSystemWindow() const
1442 return mpWindowImpl->mbSysWin;
1445 sal_Bool Window::IsDialog() const
1447 return mpWindowImpl->mbDialog;
1450 sal_Bool Window::IsMenuFloatingWindow() const
1452 return mpWindowImpl->mbMenuFloatingWindow;
1455 sal_Bool Window::IsToolbarFloatingWindow() const
1457 return mpWindowImpl->mbToolbarFloatingWindow;
1460 void Window::EnableAllResize( sal_Bool bEnable )
1462 mpWindowImpl->mbAllResize = bEnable;
1465 void Window::EnableChildTransparentMode( sal_Bool bEnable )
1467 mpWindowImpl->mbChildTransparent = bEnable;
1470 sal_Bool Window::IsChildTransparentModeEnabled() const
1472 return mpWindowImpl->mbChildTransparent;
1475 sal_Bool Window::IsMouseTransparent() const
1477 return mpWindowImpl->mbMouseTransparent;
1480 sal_Bool Window::IsPaintTransparent() const
1482 return mpWindowImpl->mbPaintTransparent;
1485 void Window::SetDialogControlStart( sal_Bool bStart )
1487 mpWindowImpl->mbDlgCtrlStart = bStart;
1490 sal_Bool Window::IsDialogControlStart() const
1492 return mpWindowImpl->mbDlgCtrlStart;
1495 void Window::SetDialogControlFlags( sal_uInt16 nFlags )
1497 mpWindowImpl->mnDlgCtrlFlags = nFlags;
1500 sal_uInt16 Window::GetDialogControlFlags() const
1502 return mpWindowImpl->mnDlgCtrlFlags;
1505 const InputContext& Window::GetInputContext() const
1507 return mpWindowImpl->maInputContext;
1510 sal_Bool Window::IsControlFont() const
1512 return (mpWindowImpl->mpControlFont != 0);
1515 Color Window::GetControlForeground() const
1517 return mpWindowImpl->maControlForeground;
1520 sal_Bool Window::IsControlForeground() const
1522 return mpWindowImpl->mbControlForeground;
1525 Color Window::GetControlBackground() const
1527 return mpWindowImpl->maControlBackground;
1530 sal_Bool Window::IsControlBackground() const
1532 return mpWindowImpl->mbControlBackground;
1535 sal_Bool Window::IsInPaint() const
1537 return mpWindowImpl->mbInPaint;
1540 Window* Window::GetParent() const
1542 return mpWindowImpl->mpRealParent;
1545 sal_Bool Window::IsVisible() const
1547 return mpWindowImpl->mbVisible;
1550 sal_Bool Window::IsReallyVisible() const
1552 return mpWindowImpl->mbReallyVisible;
1555 sal_Bool Window::IsReallyShown() const
1557 return mpWindowImpl->mbReallyShown;
1560 sal_Bool Window::IsInInitShow() const
1562 return mpWindowImpl->mbInInitShow;
1565 sal_Bool Window::IsEnabled() const
1567 return !mpWindowImpl->mbDisabled;
1570 sal_Bool Window::IsInputEnabled() const
1572 return !mpWindowImpl->mbInputDisabled;
1575 sal_Bool Window::IsAlwaysEnableInput() const
1577 return mpWindowImpl->meAlwaysInputMode == AlwaysInputEnabled;
1580 sal_uInt16 Window::GetActivateMode() const
1582 return mpWindowImpl->mnActivateMode;
1586 sal_Bool Window::IsAlwaysOnTopEnabled() const
1588 return mpWindowImpl->mbAlwaysOnTop;
1591 sal_Bool Window::IsDefaultPos() const
1593 return mpWindowImpl->mbDefPos;
1596 sal_Bool Window::IsDefaultSize() const
1598 return mpWindowImpl->mbDefSize;
1601 void Window::EnablePaint( sal_Bool bEnable )
1603 mpWindowImpl->mbPaintDisabled = !bEnable;
1606 sal_Bool Window::IsPaintEnabled() const
1608 return !mpWindowImpl->mbPaintDisabled;
1611 sal_Bool Window::IsUpdateMode() const
1613 return !mpWindowImpl->mbNoUpdate;
1616 void Window::SetParentUpdateMode( sal_Bool bUpdate )
1618 mpWindowImpl->mbNoParentUpdate = !bUpdate;
1621 sal_Bool Window::IsActive() const
1623 return mpWindowImpl->mbActive;
1626 sal_uInt16 Window::GetGetFocusFlags() const
1628 return mpWindowImpl->mnGetFocusFlags;
1631 sal_Bool Window::IsCompoundControl() const
1633 return mpWindowImpl->mbCompoundControl;
1636 sal_Bool Window::IsWait() const
1638 return (mpWindowImpl->mnWaitCount != 0);
1641 Cursor* Window::GetCursor() const
1643 return mpWindowImpl->mpCursor;
1646 const Fraction& Window::GetZoom() const
1648 return mpWindowImpl->maZoom;
1651 sal_Bool Window::IsZoom() const
1653 return mpWindowImpl->maZoom.GetNumerator() != mpWindowImpl->maZoom.GetDenominator();
1656 void Window::SetHelpText( const XubString& rHelpText )
1658 mpWindowImpl->maHelpText = rHelpText;
1659 mpWindowImpl->mbHelpTextDynamic = sal_True;
1662 void Window::SetQuickHelpText( const XubString& rHelpText )
1664 mpWindowImpl->maQuickHelpText = rHelpText;
1667 const XubString& Window::GetQuickHelpText() const
1669 return mpWindowImpl->maQuickHelpText;
1672 void Window::SetData( void* pNewData )
1674 mpWindowImpl->mpUserData = pNewData;
1677 void* Window::GetData() const
1679 return mpWindowImpl->mpUserData;
1682 sal_Bool Window::IsCreatedWithToolkit() const
1684 return mpWindowImpl->mbCreatedWithToolkit;
1687 void Window::SetCreatedWithToolkit( sal_Bool b )
1689 mpWindowImpl->mbCreatedWithToolkit = b;
1692 const Pointer& Window::GetPointer() const
1694 return mpWindowImpl->maPointer;
1697 VCLXWindow* Window::GetWindowPeer() const
1699 return mpWindowImpl->mpVCLXWindow;
1702 void Window::SetPosPixel( const Point& rNewPos )
1704 setPosSizePixel( rNewPos.X(), rNewPos.Y(), 0, 0, WINDOW_POSSIZE_POS );
1707 void Window::SetSizePixel( const Size& rNewSize )
1709 setPosSizePixel( 0, 0, rNewSize.Width(), rNewSize.Height(),
1710 WINDOW_POSSIZE_SIZE );
1713 void Window::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
1715 setPosSizePixel( rNewPos.X(), rNewPos.Y(),
1716 rNewSize.Width(), rNewSize.Height(),
1717 WINDOW_POSSIZE_POSSIZE );
1720 void Window::SetOutputSizePixel( const Size& rNewSize )
1722 SetSizePixel( Size( rNewSize.Width()+mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder,
1723 rNewSize.Height()+mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder ) );
1726 //When a widget wants to renegotiate layout, get toplevel parent dialog and call
1727 //resize on it. Mark all intermediate containers (or container-alike) widgets
1728 //as dirty for the size remains unchanged, but layout changed circumstances
1729 namespace
1731 bool queue_ungrouped_resize(Window *pOrigWindow)
1733 bool bSomeoneCares = false;
1735 Dialog *pDialog = NULL;
1737 Window *pWindow = pOrigWindow;
1739 while (pWindow)
1741 if (isContainerWindow(*pWindow))
1743 VclContainer *pContainer = static_cast<VclContainer*>(pWindow);
1744 pContainer->markLayoutDirty();
1745 bSomeoneCares = true;
1747 else if (pWindow->GetType() == WINDOW_TABCONTROL)
1749 TabControl *pTabControl = static_cast<TabControl*>(pWindow);
1750 pTabControl->markLayoutDirty();
1751 bSomeoneCares = true;
1753 else if (pWindow->IsDialog())
1755 pDialog = dynamic_cast<Dialog*>(pWindow);
1756 break;
1758 pWindow = pWindow->GetParent();
1761 if (pDialog && pDialog != pOrigWindow)
1762 pDialog->queue_layout();
1763 return bSomeoneCares;
1767 void Window::queue_resize()
1769 bool bSomeoneCares = queue_ungrouped_resize(this);
1771 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
1772 if (pWindowImpl->m_xSizeGroup && pWindowImpl->m_xSizeGroup->get_mode() != VCL_SIZE_GROUP_NONE)
1774 std::set<Window*> &rWindows = pWindowImpl->m_xSizeGroup->get_widgets();
1775 for (std::set<Window*>::iterator aI = rWindows.begin(),
1776 aEnd = rWindows.end(); aI != aEnd; ++aI)
1778 Window *pOther = *aI;
1779 if (pOther == this)
1780 continue;
1781 queue_ungrouped_resize(pOther);
1785 if (bSomeoneCares)
1787 //fdo#57090 force a resync of the borders of the borderwindow onto this
1788 //window in case they have changed
1789 Window* pBorderWindow = ImplGetBorderWindow();
1790 if (pBorderWindow)
1791 pBorderWindow->Resize();
1795 namespace
1797 VclAlign toAlign(const OString &rValue)
1799 VclAlign eRet = VCL_ALIGN_FILL;
1801 if (rValue == "fill")
1802 eRet = VCL_ALIGN_FILL;
1803 else if (rValue == "start")
1804 eRet = VCL_ALIGN_START;
1805 else if (rValue == "end")
1806 eRet = VCL_ALIGN_END;
1807 else if (rValue == "center")
1808 eRet = VCL_ALIGN_CENTER;
1809 return eRet;
1813 bool Window::set_font_attribute(const OString &rKey, const OString &rValue)
1815 if (rKey == "weight")
1817 Font aFont(GetControlFont());
1818 if (rValue == "thin")
1819 aFont.SetWeight(WEIGHT_THIN);
1820 else if (rValue == "ultralight")
1821 aFont.SetWeight(WEIGHT_ULTRALIGHT);
1822 else if (rValue == "light")
1823 aFont.SetWeight(WEIGHT_LIGHT);
1824 else if (rValue == "book")
1825 aFont.SetWeight(WEIGHT_SEMILIGHT);
1826 else if (rValue == "normal")
1827 aFont.SetWeight(WEIGHT_NORMAL);
1828 else if (rValue == "medium")
1829 aFont.SetWeight(WEIGHT_MEDIUM);
1830 else if (rValue == "semibold")
1831 aFont.SetWeight(WEIGHT_SEMIBOLD);
1832 else if (rValue == "bold")
1833 aFont.SetWeight(WEIGHT_BOLD);
1834 else if (rValue == "ultrabold")
1835 aFont.SetWeight(WEIGHT_ULTRABOLD);
1836 else
1837 aFont.SetWeight(WEIGHT_BLACK);
1838 SetControlFont(aFont);
1840 else if (rKey == "style")
1842 Font aFont(GetControlFont());
1843 if (rValue == "normal")
1844 aFont.SetItalic(ITALIC_NONE);
1845 else if (rValue == "oblique")
1846 aFont.SetItalic(ITALIC_OBLIQUE);
1847 else if (rValue == "italic")
1848 aFont.SetItalic(ITALIC_NORMAL);
1849 SetControlFont(aFont);
1851 else
1853 SAL_INFO("vcl.layout", "unhandled font attribute: " << rKey.getStr());
1854 return false;
1856 return true;
1860 bool Window::set_property(const OString &rKey, const OString &rValue)
1862 if ((rKey == "label") || (rKey == "title") || (rKey == "text") )
1864 SetText(OStringToOUString(VclBuilder::convertMnemonicMarkup(rValue), RTL_TEXTENCODING_UTF8));
1866 else if (rKey == "visible")
1867 Show(toBool(rValue));
1868 else if (rKey == "sensitive")
1869 Enable(toBool(rValue));
1870 else if (rKey == "resizable")
1872 WinBits nBits = GetStyle();
1873 nBits &= ~(WB_SIZEABLE);
1874 if (toBool(rValue))
1875 nBits |= WB_SIZEABLE;
1876 SetStyle(nBits);
1878 else if (rKey == "xalign")
1880 WinBits nBits = GetStyle();
1881 nBits &= ~(WB_LEFT | WB_CENTER | WB_RIGHT);
1883 float f = rValue.toFloat();
1884 if (f == 0.0)
1885 nBits |= WB_LEFT;
1886 else if (f == 1.0)
1887 nBits |= WB_RIGHT;
1888 else if (f == 0.5)
1889 nBits |= WB_CENTER;
1891 SetStyle(nBits);
1893 else if (rKey == "justification")
1895 WinBits nBits = GetStyle();
1896 nBits &= ~(WB_LEFT | WB_CENTER | WB_RIGHT);
1898 if (rValue == "left")
1899 nBits |= WB_LEFT;
1900 else if (rValue == "right")
1901 nBits |= WB_RIGHT;
1902 else if (rValue == "center")
1903 nBits |= WB_CENTER;
1905 SetStyle(nBits);
1907 else if (rKey == "yalign")
1909 WinBits nBits = GetStyle();
1910 nBits &= ~(WB_TOP | WB_VCENTER | WB_BOTTOM);
1912 float f = rValue.toFloat();
1913 if (f == 0.0)
1914 nBits |= WB_TOP;
1915 else if (f == 1.0)
1916 nBits |= WB_BOTTOM;
1917 else if (f == 0.5)
1918 nBits |= WB_CENTER;
1920 SetStyle(nBits);
1922 else if (rKey == "wrap")
1924 WinBits nBits = GetStyle();
1925 nBits &= ~(WB_WORDBREAK);
1926 if (toBool(rValue))
1927 nBits |= WB_WORDBREAK;
1928 SetStyle(nBits);
1930 else if (rKey == "height-request")
1931 set_height_request(rValue.toInt32());
1932 else if (rKey == "width-request")
1933 set_width_request(rValue.toInt32());
1934 else if (rKey == "hexpand")
1935 set_hexpand(toBool(rValue));
1936 else if (rKey == "vexpand")
1937 set_vexpand(toBool(rValue));
1938 else if (rKey == "halign")
1939 set_halign(toAlign(rValue));
1940 else if (rKey == "valign")
1941 set_valign(toAlign(rValue));
1942 else if (rKey == "tooltip-markup")
1943 SetQuickHelpText(OStringToOUString(rValue, RTL_TEXTENCODING_UTF8));
1944 else if (rKey == "tooltip-text")
1945 SetQuickHelpText(OStringToOUString(rValue, RTL_TEXTENCODING_UTF8));
1946 else if (rKey == "border-width")
1947 set_border_width(rValue.toInt32());
1948 else if (rKey == "margin-left")
1949 set_margin_left(rValue.toInt32());
1950 else if (rKey == "margin-right")
1951 set_margin_right(rValue.toInt32());
1952 else if (rKey == "margin-top")
1953 set_margin_top(rValue.toInt32());
1954 else if (rKey == "margin-bottom")
1955 set_margin_bottom(rValue.toInt32());
1956 else if (rKey == "hscrollbar-policy")
1958 WinBits nBits = GetStyle();
1959 nBits &= ~(WB_AUTOHSCROLL|WB_HSCROLL);
1960 if (rValue == "always")
1961 nBits |= WB_HSCROLL;
1962 else if (rValue == "automatic")
1963 nBits |= WB_AUTOHSCROLL;
1964 SetStyle(nBits);
1966 else if (rKey == "vscrollbar-policy")
1968 WinBits nBits = GetStyle();
1969 nBits &= ~(WB_AUTOVSCROLL|WB_VSCROLL);
1970 if (rValue == "always")
1971 nBits |= WB_VSCROLL;
1972 else if (rValue == "automatic")
1973 nBits |= WB_AUTOVSCROLL;
1974 SetStyle(nBits);
1976 else if (rKey == "accessible-name")
1978 SetAccessibleName(OStringToOUString(rValue, RTL_TEXTENCODING_UTF8));
1980 else if (rKey == "accessible-description")
1982 SetAccessibleDescription(OStringToOUString(rValue, RTL_TEXTENCODING_UTF8));
1984 else if (rKey == "use-markup")
1986 //https://live.gnome.org/GnomeGoals/RemoveMarkupInMessages
1987 SAL_WARN_IF(toBool(rValue), "vcl.layout", "Use pango attributes instead of mark-up");
1989 else
1991 SAL_INFO("vcl.layout", "unhandled property: " << rKey.getStr());
1992 return false;
1994 return true;
1997 void Window::set_height_request(sal_Int32 nHeightRequest)
1999 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
2001 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2003 if ( pWindowImpl->mnHeightRequest != nHeightRequest )
2005 pWindowImpl->mnHeightRequest = nHeightRequest;
2006 queue_resize();
2010 void Window::set_width_request(sal_Int32 nWidthRequest)
2012 DBG_CHKTHIS( Window, ImplDbgCheckWindow );
2014 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2016 if ( pWindowImpl->mnWidthRequest != nWidthRequest )
2018 pWindowImpl->mnWidthRequest = nWidthRequest;
2019 queue_resize();
2023 namespace
2025 Size get_ungrouped_preferred_size(const Window &rWindow)
2027 Size aRet(rWindow.get_width_request(), rWindow.get_height_request());
2028 if (aRet.Width() == -1 || aRet.Height() == -1)
2030 Size aOptimal = rWindow.GetOptimalSize();
2031 if (aRet.Width() == -1)
2032 aRet.Width() = aOptimal.Width();
2033 if (aRet.Height() == -1)
2034 aRet.Height() = aOptimal.Height();
2036 return aRet;
2040 Size Window::get_preferred_size() const
2042 Size aRet(get_ungrouped_preferred_size(*this));
2044 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2045 if (pWindowImpl->m_xSizeGroup)
2047 const VclSizeGroupMode eMode = pWindowImpl->m_xSizeGroup->get_mode();
2048 if (eMode != VCL_SIZE_GROUP_NONE)
2050 const bool bIgnoreInHidden = pWindowImpl->m_xSizeGroup->get_ignore_hidden();
2051 const std::set<Window*> &rWindows = pWindowImpl->m_xSizeGroup->get_widgets();
2052 for (std::set<Window*>::const_iterator aI = rWindows.begin(),
2053 aEnd = rWindows.end(); aI != aEnd; ++aI)
2055 const Window *pOther = *aI;
2056 if (pOther == this)
2057 continue;
2058 if (bIgnoreInHidden && !pOther->IsVisible())
2059 continue;
2060 Size aOtherSize = get_ungrouped_preferred_size(*pOther);
2061 if (eMode == VCL_SIZE_GROUP_BOTH || eMode == VCL_SIZE_GROUP_HORIZONTAL)
2062 aRet.Width() = std::max(aRet.Width(), aOtherSize.Width());
2063 if (eMode == VCL_SIZE_GROUP_BOTH || eMode == VCL_SIZE_GROUP_VERTICAL)
2064 aRet.Height() = std::max(aRet.Height(), aOtherSize.Height());
2069 return aRet;
2072 VclAlign Window::get_halign() const
2074 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2075 return pWindowImpl->meHalign;
2078 void Window::set_halign(VclAlign eAlign)
2080 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2081 pWindowImpl->meHalign = eAlign;
2084 VclAlign Window::get_valign() const
2086 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2087 return pWindowImpl->meValign;
2090 void Window::set_valign(VclAlign eAlign)
2092 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2093 pWindowImpl->meValign = eAlign;
2096 bool Window::get_hexpand() const
2098 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2099 return pWindowImpl->mbHexpand;
2102 void Window::set_hexpand(bool bExpand)
2104 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2105 pWindowImpl->mbHexpand = bExpand;
2108 bool Window::get_vexpand() const
2110 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2111 return pWindowImpl->mbVexpand;
2114 void Window::set_vexpand(bool bExpand)
2116 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2117 pWindowImpl->mbVexpand = bExpand;
2120 bool Window::get_expand() const
2122 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2123 return pWindowImpl->mbExpand;
2126 void Window::set_expand(bool bExpand)
2128 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2129 pWindowImpl->mbExpand = bExpand;
2132 VclPackType Window::get_pack_type() const
2134 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2135 return pWindowImpl->mePackType;
2138 void Window::set_pack_type(VclPackType ePackType)
2140 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2141 pWindowImpl->mePackType = ePackType;
2144 sal_Int32 Window::get_padding() const
2146 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2147 return pWindowImpl->mnPadding;
2150 void Window::set_padding(sal_Int32 nPadding)
2152 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2153 pWindowImpl->mnPadding = nPadding;
2156 bool Window::get_fill() const
2158 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2159 return pWindowImpl->mbFill;
2162 void Window::set_fill(bool bFill)
2164 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2165 pWindowImpl->mbFill = bFill;
2168 sal_Int32 Window::get_grid_width() const
2170 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2171 return pWindowImpl->mnGridWidth;
2174 void Window::set_grid_width(sal_Int32 nCols)
2176 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2177 pWindowImpl->mnGridWidth = nCols;
2180 sal_Int32 Window::get_grid_left_attach() const
2182 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2183 return pWindowImpl->mnGridLeftAttach;
2186 void Window::set_grid_left_attach(sal_Int32 nAttach)
2188 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2189 pWindowImpl->mnGridLeftAttach = nAttach;
2192 sal_Int32 Window::get_grid_height() const
2194 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2195 return pWindowImpl->mnGridHeight;
2198 void Window::set_grid_height(sal_Int32 nRows)
2200 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2201 pWindowImpl->mnGridHeight = nRows;
2204 sal_Int32 Window::get_grid_top_attach() const
2206 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2207 return pWindowImpl->mnGridTopAttach;
2210 void Window::set_grid_top_attach(sal_Int32 nAttach)
2212 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2213 pWindowImpl->mnGridTopAttach = nAttach;
2216 void Window::set_border_width(sal_Int32 nBorderWidth)
2218 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2219 pWindowImpl->mnBorderWidth = nBorderWidth;
2222 sal_Int32 Window::get_border_width() const
2224 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2225 return pWindowImpl->mnBorderWidth;
2228 void Window::set_margin_left(sal_Int32 nWidth)
2230 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2231 pWindowImpl->mnMarginLeft = nWidth;
2234 sal_Int32 Window::get_margin_left() const
2236 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2237 return pWindowImpl->mnMarginLeft;
2240 void Window::set_margin_right(sal_Int32 nWidth)
2242 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2243 pWindowImpl->mnMarginRight = nWidth;
2246 sal_Int32 Window::get_margin_right() const
2248 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2249 return pWindowImpl->mnMarginRight;
2252 void Window::set_margin_top(sal_Int32 nWidth)
2254 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2255 pWindowImpl->mnMarginTop = nWidth;
2258 sal_Int32 Window::get_margin_top() const
2260 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2261 return pWindowImpl->mnMarginTop;
2264 void Window::set_margin_bottom(sal_Int32 nWidth)
2266 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2267 pWindowImpl->mnMarginBottom = nWidth;
2270 sal_Int32 Window::get_margin_bottom() const
2272 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2273 return pWindowImpl->mnMarginBottom;
2276 sal_Int32 Window::get_height_request() const
2278 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2279 return pWindowImpl->mnHeightRequest;
2282 sal_Int32 Window::get_width_request() const
2284 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2285 return pWindowImpl->mnWidthRequest;
2288 bool Window::get_secondary() const
2290 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2291 return pWindowImpl->mbSecondary;
2294 void Window::set_secondary(bool bSecondary)
2296 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2297 pWindowImpl->mbSecondary = bSecondary;
2300 void Window::add_to_size_group(boost::shared_ptr< VclSizeGroup > xGroup)
2302 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2303 //To-Do, multiple groups
2304 pWindowImpl->m_xSizeGroup = xGroup;
2305 pWindowImpl->m_xSizeGroup->insert(this);
2306 if (VCL_SIZE_GROUP_NONE != pWindowImpl->m_xSizeGroup->get_mode())
2307 queue_resize();
2310 void Window::remove_from_all_size_groups()
2312 WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl : mpWindowImpl;
2313 //To-Do, multiple groups
2314 if (pWindowImpl->m_xSizeGroup)
2316 if (VCL_SIZE_GROUP_NONE != pWindowImpl->m_xSizeGroup->get_mode())
2317 queue_resize();
2318 pWindowImpl->m_xSizeGroup->erase(this);
2319 pWindowImpl->m_xSizeGroup.reset();
2323 void Window::add_mnemonic_label(FixedText *pLabel)
2325 std::vector<FixedText*>& v = mpWindowImpl->m_aMnemonicLabels;
2326 if (std::find(v.begin(), v.end(), pLabel) != v.end())
2327 return;
2328 v.push_back(pLabel);
2329 pLabel->set_mnemonic_widget(this);
2332 void Window::remove_mnemonic_label(FixedText *pLabel)
2334 std::vector<FixedText*>& v = mpWindowImpl->m_aMnemonicLabels;
2335 std::vector<FixedText*>::iterator aFind = std::find(v.begin(), v.end(), pLabel);
2336 if (aFind == v.end())
2337 return;
2338 v.erase(aFind);
2339 pLabel->set_mnemonic_widget(NULL);
2342 std::vector<FixedText*> Window::list_mnemonic_labels() const
2344 return mpWindowImpl->m_aMnemonicLabels;
2347 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */