LibreOffice Module vcl (master)  1
window2.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <limits.h>
21 
23 #include <sal/log.hxx>
24 
25 #include <vcl/toolkit/dialog.hxx>
26 #include <vcl/event.hxx>
27 #include <vcl/toolkit/fixed.hxx>
28 #include <vcl/layout.hxx>
29 #include <vcl/timer.hxx>
30 #include <vcl/window.hxx>
31 #include <vcl/scrbar.hxx>
32 #include <vcl/dockwin.hxx>
33 #include <vcl/settings.hxx>
34 #include <vcl/builder.hxx>
35 
36 #include <window.h>
37 #include <svdata.hxx>
38 #include <salgdi.hxx>
39 #include <salframe.hxx>
40 #include <scrwnd.hxx>
41 
42 #include <com/sun/star/accessibility/AccessibleRelation.hpp>
43 #include <com/sun/star/accessibility/AccessibleRole.hpp>
44 
45 using namespace com::sun::star;
46 
47 namespace vcl {
48 
49 void Window::ShowFocus( const tools::Rectangle& rRect )
50 {
51  if( mpWindowImpl->mbInShowFocus )
52  return;
53  mpWindowImpl->mbInShowFocus = true;
54 
55  ImplWinData* pWinData = ImplGetWinData();
56 
57  // native themeing suggest not to use focus rects
58  if( ! ( mpWindowImpl->mbUseNativeFocus &&
59  IsNativeWidgetEnabled() ) )
60  {
61  if ( !mpWindowImpl->mbInPaint )
62  {
63  if ( mpWindowImpl->mbFocusVisible )
64  {
65  if ( *pWinData->mpFocusRect == rRect )
66  {
67  mpWindowImpl->mbInShowFocus = false;
68  return;
69  }
70 
71  ImplInvertFocus( *pWinData->mpFocusRect );
72  }
73 
74  ImplInvertFocus( rRect );
75  }
76  pWinData->mpFocusRect = rRect;
77  mpWindowImpl->mbFocusVisible = true;
78  }
79  else
80  {
81  if( ! mpWindowImpl->mbNativeFocusVisible )
82  {
83  mpWindowImpl->mbNativeFocusVisible = true;
84  if ( !mpWindowImpl->mbInPaint )
85  Invalidate();
86  }
87  }
88  mpWindowImpl->mbInShowFocus = false;
89 }
90 
91 void Window::HideFocus()
92 {
93 
94  if( mpWindowImpl->mbInHideFocus )
95  return;
96  mpWindowImpl->mbInHideFocus = true;
97 
98  // native themeing can suggest not to use focus rects
99  if( ! ( mpWindowImpl->mbUseNativeFocus &&
100  IsNativeWidgetEnabled() ) )
101  {
102  if ( !mpWindowImpl->mbFocusVisible )
103  {
104  mpWindowImpl->mbInHideFocus = false;
105  return;
106  }
107 
108  if ( !mpWindowImpl->mbInPaint )
109  ImplInvertFocus( *ImplGetWinData()->mpFocusRect );
110  mpWindowImpl->mbFocusVisible = false;
111  }
112  else
113  {
114  if( mpWindowImpl->mbNativeFocusVisible )
115  {
116  mpWindowImpl->mbNativeFocusVisible = false;
117  if ( !mpWindowImpl->mbInPaint )
118  Invalidate();
119  }
120  }
121  mpWindowImpl->mbInHideFocus = false;
122 }
123 
124 void Window::ShowTracking( const tools::Rectangle& rRect, ShowTrackFlags nFlags )
125 {
126  ImplWinData* pWinData = ImplGetWinData();
127 
128  if ( !mpWindowImpl->mbInPaint || !(nFlags & ShowTrackFlags::TrackWindow) )
129  {
130  if ( mpWindowImpl->mbTrackVisible )
131  {
132  if ( (*pWinData->mpTrackRect == rRect) &&
133  (pWinData->mnTrackFlags == nFlags) )
134  return;
135 
136  InvertTracking( *pWinData->mpTrackRect, pWinData->mnTrackFlags );
137  }
138 
139  InvertTracking( rRect, nFlags );
140  }
141 
142  pWinData->mpTrackRect = rRect;
143  pWinData->mnTrackFlags = nFlags;
144  mpWindowImpl->mbTrackVisible = true;
145 }
146 
147 void Window::HideTracking()
148 {
149  if ( mpWindowImpl->mbTrackVisible )
150  {
151  ImplWinData* pWinData = ImplGetWinData();
152  if ( !mpWindowImpl->mbInPaint || !(pWinData->mnTrackFlags & ShowTrackFlags::TrackWindow) )
153  InvertTracking( *pWinData->mpTrackRect, pWinData->mnTrackFlags );
154  mpWindowImpl->mbTrackVisible = false;
155  }
156 }
157 
158 void Window::InvertTracking( const tools::Rectangle& rRect, ShowTrackFlags nFlags )
159 {
160  OutputDevice *pOutDev = GetOutDev();
161  tools::Rectangle aRect( pOutDev->ImplLogicToDevicePixel( rRect ) );
162 
163  if ( aRect.IsEmpty() )
164  return;
165  aRect.Justify();
166 
167  SalGraphics* pGraphics;
168 
169  if ( nFlags & ShowTrackFlags::TrackWindow )
170  {
171  if ( !IsDeviceOutputNecessary() )
172  return;
173 
174  // we need a graphics
175  if ( !mpGraphics )
176  {
177  if ( !pOutDev->AcquireGraphics() )
178  return;
179  }
180 
181  if ( mbInitClipRegion )
182  InitClipRegion();
183 
184  if ( mbOutputClipped )
185  return;
186 
187  pGraphics = mpGraphics;
188  }
189  else
190  {
191  pGraphics = ImplGetFrameGraphics();
192 
193  if ( nFlags & ShowTrackFlags::Clip )
194  {
195  Point aPoint( mnOutOffX, mnOutOffY );
196  vcl::Region aRegion( tools::Rectangle( aPoint,
197  Size( mnOutWidth, mnOutHeight ) ) );
198  ImplClipBoundaries( aRegion, false, false );
199  pOutDev->SelectClipRegion( aRegion, pGraphics );
200  }
201  }
202 
203  ShowTrackFlags nStyle = nFlags & ShowTrackFlags::StyleMask;
204  if ( nStyle == ShowTrackFlags::Object )
205  pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), SalInvert::TrackFrame, *this );
206  else if ( nStyle == ShowTrackFlags::Split )
207  pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), SalInvert::N50, *this );
208  else
209  {
210  tools::Long nBorder = 1;
211  if ( nStyle == ShowTrackFlags::Big )
212  nBorder = 5;
213  pGraphics->Invert( aRect.Left(), aRect.Top(), aRect.GetWidth(), nBorder, SalInvert::N50, *this );
214  pGraphics->Invert( aRect.Left(), aRect.Bottom()-nBorder+1, aRect.GetWidth(), nBorder, SalInvert::N50, *this );
215  pGraphics->Invert( aRect.Left(), aRect.Top()+nBorder, nBorder, aRect.GetHeight()-(nBorder*2), SalInvert::N50, *this );
216  pGraphics->Invert( aRect.Right()-nBorder+1, aRect.Top()+nBorder, nBorder, aRect.GetHeight()-(nBorder*2), SalInvert::N50, *this );
217  }
218 }
219 
220 IMPL_LINK( Window, ImplTrackTimerHdl, Timer*, pTimer, void )
221 {
222  ImplSVData* pSVData = ImplGetSVData();
223 
224  // if Button-Repeat we have to change the timeout
226  pTimer->SetTimeout( GetSettings().GetMouseSettings().GetButtonRepeat() );
227 
228  // create Tracking-Event
229  Point aMousePos( mpWindowImpl->mpFrameData->mnLastMouseX, mpWindowImpl->mpFrameData->mnLastMouseY );
230  if( ImplIsAntiparallel() )
231  {
232  // re-mirror frame pos at pChild
233  const OutputDevice *pOutDev = GetOutDev();
234  pOutDev->ReMirror( aMousePos );
235  }
236  MouseEvent aMEvt( ImplFrameToOutput( aMousePos ),
237  mpWindowImpl->mpFrameData->mnClickCount, MouseEventModifiers::NONE,
238  mpWindowImpl->mpFrameData->mnMouseCode,
239  mpWindowImpl->mpFrameData->mnMouseCode );
241  Tracking( aTEvt );
242 }
243 
244 void Window::StartTracking( StartTrackingFlags nFlags )
245 {
246  ImplSVData* pSVData = ImplGetSVData();
247 
248  if ( pSVData->mpWinData->mpTrackWin.get() != this )
249  {
250  if ( pSVData->mpWinData->mpTrackWin )
252  }
253 
255  {
256  pSVData->mpWinData->mpTrackTimer = new AutoTimer;
257 
258  if ( nFlags & StartTrackingFlags::ScrollRepeat )
260  else
262  pSVData->mpWinData->mpTrackTimer->SetInvokeHandler( LINK( this, Window, ImplTrackTimerHdl ) );
263  pSVData->mpWinData->mpTrackTimer->SetDebugName( "vcl::Window pSVData->mpWinData->mpTrackTimer" );
264  pSVData->mpWinData->mpTrackTimer->Start();
265  }
266 
267  pSVData->mpWinData->mpTrackWin = this;
268  pSVData->mpWinData->mnTrackFlags = nFlags;
269  CaptureMouse();
270 }
271 
272 void Window::EndTracking( TrackingEventFlags nFlags )
273 {
274  ImplSVData* pSVData = ImplGetSVData();
275 
276  if ( pSVData->mpWinData->mpTrackWin.get() != this )
277  return;
278 
279  if ( pSVData->mpWinData->mpTrackTimer )
280  {
281  delete pSVData->mpWinData->mpTrackTimer;
282  pSVData->mpWinData->mpTrackTimer = nullptr;
283  }
284 
285  pSVData->mpWinData->mpTrackWin = nullptr;
287  ReleaseMouse();
288 
289  // call EndTracking if required
290  {
291  Point aMousePos( mpWindowImpl->mpFrameData->mnLastMouseX, mpWindowImpl->mpFrameData->mnLastMouseY );
292  if( ImplIsAntiparallel() )
293  {
294  // re-mirror frame pos at pChild
295  const OutputDevice *pOutDev = GetOutDev();
296  pOutDev->ReMirror( aMousePos );
297  }
298 
299  MouseEvent aMEvt( ImplFrameToOutput( aMousePos ),
300  mpWindowImpl->mpFrameData->mnClickCount, MouseEventModifiers::NONE,
301  mpWindowImpl->mpFrameData->mnMouseCode,
302  mpWindowImpl->mpFrameData->mnMouseCode );
303  TrackingEvent aTEvt( aMEvt, nFlags | TrackingEventFlags::End );
304  // CompatTracking effectively
305  if (!mpWindowImpl || mpWindowImpl->mbInDispose)
306  return Window::Tracking( aTEvt );
307  else
308  return Tracking( aTEvt );
309  }
310 }
311 
312 bool Window::IsTracking() const
313 {
314  return (ImplGetSVData()->mpWinData->mpTrackWin == this);
315 }
316 
317 void Window::StartAutoScroll( StartAutoScrollFlags nFlags )
318 {
319  ImplSVData* pSVData = ImplGetSVData();
320 
321  if ( pSVData->mpWinData->mpAutoScrollWin.get() != this )
322  {
323  if ( pSVData->mpWinData->mpAutoScrollWin )
325  }
326 
327  pSVData->mpWinData->mpAutoScrollWin = this;
328  pSVData->mpWinData->mnAutoScrollFlags = nFlags;
330 }
331 
332 void Window::EndAutoScroll()
333 {
334  ImplSVData* pSVData = ImplGetSVData();
335 
336  if ( pSVData->mpWinData->mpAutoScrollWin.get() == this )
337  {
338  pSVData->mpWinData->mpAutoScrollWin = nullptr;
340  pSVData->maAppData.mpWheelWindow->ImplStop();
343  }
344 }
345 
346 VclPtr<vcl::Window> Window::SaveFocus()
347 {
348  ImplSVData* pSVData = ImplGetSVData();
349  if ( pSVData->mpWinData->mpFocusWin )
350  {
351  return pSVData->mpWinData->mpFocusWin;
352  }
353  else
354  return nullptr;
355 }
356 
357 void Window::EndSaveFocus(const VclPtr<vcl::Window>& xFocusWin)
358 {
359  if (xFocusWin && !xFocusWin->IsDisposed())
360  {
361  xFocusWin->GrabFocus();
362  }
363 }
364 
365 void Window::SetZoom( const Fraction& rZoom )
366 {
367  if ( mpWindowImpl && mpWindowImpl->maZoom != rZoom )
368  {
369  mpWindowImpl->maZoom = rZoom;
370  CompatStateChanged( StateChangedType::Zoom );
371  }
372 }
373 
374 static tools::Long WinFloatRound( double fVal )
375 {
376  return( fVal > 0.0 ? static_cast<tools::Long>( fVal + 0.5 ) : -static_cast<tools::Long>( -fVal + 0.5 ) );
377 }
378 
379 void Window::SetZoomedPointFont(vcl::RenderContext& rRenderContext, const vcl::Font& rFont)
380 {
381  const Fraction& rZoom = GetZoom();
382  if (rZoom.GetNumerator() != rZoom.GetDenominator())
383  {
384  vcl::Font aFont(rFont);
385  Size aSize = aFont.GetFontSize();
386  aSize.setWidth( WinFloatRound(double(aSize.Width() * rZoom)) );
387  aSize.setHeight( WinFloatRound(double(aSize.Height() * rZoom)) );
388  aFont.SetFontSize(aSize);
389  SetPointFont(rRenderContext, aFont);
390  }
391  else
392  {
393  SetPointFont(rRenderContext, rFont);
394  }
395 }
396 
397 tools::Long Window::CalcZoom( tools::Long nCalc ) const
398 {
399 
400  const Fraction& rZoom = GetZoom();
401  if ( rZoom.GetNumerator() != rZoom.GetDenominator() )
402  {
403  double n = double(nCalc * rZoom);
404  nCalc = WinFloatRound( n );
405  }
406  return nCalc;
407 }
408 
409 void Window::SetControlFont()
410 {
411  if (mpWindowImpl && mpWindowImpl->mpControlFont)
412  {
413  mpWindowImpl->mpControlFont.reset();
414  CompatStateChanged(StateChangedType::ControlFont);
415  }
416 }
417 
418 void Window::SetControlFont(const vcl::Font& rFont)
419 {
420  if (rFont == vcl::Font())
421  {
422  SetControlFont();
423  return;
424  }
425 
426  if (mpWindowImpl->mpControlFont)
427  {
428  if (*mpWindowImpl->mpControlFont == rFont)
429  return;
430  *mpWindowImpl->mpControlFont = rFont;
431  }
432  else
433  mpWindowImpl->mpControlFont.reset( new vcl::Font(rFont) );
434 
435  CompatStateChanged(StateChangedType::ControlFont);
436 }
437 
438 vcl::Font Window::GetControlFont() const
439 {
440  if (mpWindowImpl->mpControlFont)
441  return *mpWindowImpl->mpControlFont;
442  else
443  {
444  vcl::Font aFont;
445  return aFont;
446  }
447 }
448 
449 void Window::ApplyControlFont(vcl::RenderContext& rRenderContext, const vcl::Font& rFont)
450 {
451  vcl::Font aFont(rFont);
452  if (IsControlFont())
453  aFont.Merge(GetControlFont());
454  SetZoomedPointFont(rRenderContext, aFont);
455 }
456 
457 void Window::SetControlForeground()
458 {
459  if (mpWindowImpl->mbControlForeground)
460  {
461  mpWindowImpl->maControlForeground = COL_TRANSPARENT;
462  mpWindowImpl->mbControlForeground = false;
463  CompatStateChanged(StateChangedType::ControlForeground);
464  }
465 }
466 
467 void Window::SetControlForeground(const Color& rColor)
468 {
469  if (rColor.IsTransparent())
470  {
471  if (mpWindowImpl->mbControlForeground)
472  {
473  mpWindowImpl->maControlForeground = COL_TRANSPARENT;
474  mpWindowImpl->mbControlForeground = false;
475  CompatStateChanged(StateChangedType::ControlForeground);
476  }
477  }
478  else
479  {
480  if (mpWindowImpl->maControlForeground != rColor)
481  {
482  mpWindowImpl->maControlForeground = rColor;
483  mpWindowImpl->mbControlForeground = true;
484  CompatStateChanged(StateChangedType::ControlForeground);
485  }
486  }
487 }
488 
489 void Window::ApplyControlForeground(vcl::RenderContext& rRenderContext, const Color& rDefaultColor)
490 {
491  Color aTextColor(rDefaultColor);
492  if (IsControlForeground())
493  aTextColor = GetControlForeground();
494  rRenderContext.SetTextColor(aTextColor);
495 }
496 
497 void Window::SetControlBackground()
498 {
499  if (mpWindowImpl->mbControlBackground)
500  {
501  mpWindowImpl->maControlBackground = COL_TRANSPARENT;
502  mpWindowImpl->mbControlBackground = false;
503  CompatStateChanged(StateChangedType::ControlBackground);
504  }
505 }
506 
507 void Window::SetControlBackground(const Color& rColor)
508 {
509  if (rColor.IsTransparent())
510  {
511  if (mpWindowImpl->mbControlBackground)
512  {
513  mpWindowImpl->maControlBackground = COL_TRANSPARENT;
514  mpWindowImpl->mbControlBackground = false;
515  CompatStateChanged(StateChangedType::ControlBackground);
516  }
517  }
518  else
519  {
520  if (mpWindowImpl->maControlBackground != rColor)
521  {
522  mpWindowImpl->maControlBackground = rColor;
523  mpWindowImpl->mbControlBackground = true;
524  CompatStateChanged(StateChangedType::ControlBackground);
525  }
526  }
527 }
528 
529 void Window::ApplyControlBackground(vcl::RenderContext& rRenderContext, const Color& rDefaultColor)
530 {
531  Color aColor(rDefaultColor);
532  if (IsControlBackground())
533  aColor = GetControlBackground();
534  rRenderContext.SetBackground(aColor);
535 }
536 
537 Size Window::CalcWindowSize( const Size& rOutSz ) const
538 {
539  Size aSz = rOutSz;
540  aSz.AdjustWidth(mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder );
541  aSz.AdjustHeight(mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder );
542  return aSz;
543 }
544 
545 Size Window::CalcOutputSize( const Size& rWinSz ) const
546 {
547  Size aSz = rWinSz;
548  aSz.AdjustWidth( -(mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder) );
549  aSz.AdjustHeight( -(mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder) );
550  return aSz;
551 }
552 
553 vcl::Font Window::GetDrawPixelFont(OutputDevice const * pDev) const
554 {
555  vcl::Font aFont = GetPointFont(*const_cast<Window*>(this));
556  Size aFontSize = aFont.GetFontSize();
557  MapMode aPtMapMode(MapUnit::MapPoint);
558  aFontSize = pDev->LogicToPixel( aFontSize, aPtMapMode );
559  aFont.SetFontSize( aFontSize );
560  return aFont;
561 }
562 
563 tools::Long Window::GetDrawPixel( OutputDevice const * pDev, tools::Long nPixels ) const
564 {
565  tools::Long nP = nPixels;
566  if ( pDev->GetOutDevType() != OUTDEV_WINDOW )
567  {
568  MapMode aMap( MapUnit::Map100thMM );
569  Size aSz( nP, 0 );
570  aSz = PixelToLogic( aSz, aMap );
571  aSz = pDev->LogicToPixel( aSz, aMap );
572  nP = aSz.Width();
573  }
574  return nP;
575 }
576 
577 static void lcl_HandleScrollHelper( ScrollBar* pScrl, double nN, bool isMultiplyByLineSize )
578 {
579  if ( !pScrl || !nN || !pScrl->IsEnabled() || !pScrl->IsInputEnabled() || pScrl->IsInModalMode() )
580  return;
581 
582  tools::Long nNewPos = pScrl->GetThumbPos();
583 
584  if ( nN == double(-LONG_MAX) )
585  nNewPos += pScrl->GetPageSize();
586  else if ( nN == double(LONG_MAX) )
587  nNewPos -= pScrl->GetPageSize();
588  else
589  {
590  // allowing both chunked and continuous scrolling
591  if(isMultiplyByLineSize){
592  nN*=pScrl->GetLineSize();
593  }
594 
595  const double fVal = nNewPos - nN;
596 
597  if ( !o3tl::convertsToAtLeast(fVal, LONG_MIN) )
598  nNewPos = LONG_MIN;
599  else if ( !o3tl::convertsToAtMost(fVal, LONG_MAX) )
600  nNewPos = LONG_MAX;
601  else
602  nNewPos = static_cast<tools::Long>(fVal);
603  }
604 
605  pScrl->DoScroll( nNewPos );
606 
607 }
608 
609 bool Window::HandleScrollCommand( const CommandEvent& rCmd,
610  ScrollBar* pHScrl, ScrollBar* pVScrl )
611 {
612  bool bRet = false;
613 
614  if ( pHScrl || pVScrl )
615  {
616  switch( rCmd.GetCommand() )
617  {
619  {
621  if ( pHScrl )
622  {
623  if ( (pHScrl->GetVisibleSize() < pHScrl->GetRangeMax()) &&
624  pHScrl->IsEnabled() && pHScrl->IsInputEnabled() && ! pHScrl->IsInModalMode() )
625  nFlags |= StartAutoScrollFlags::Horz;
626  }
627  if ( pVScrl )
628  {
629  if ( (pVScrl->GetVisibleSize() < pVScrl->GetRangeMax()) &&
630  pVScrl->IsEnabled() && pVScrl->IsInputEnabled() && ! pVScrl->IsInModalMode() )
631  nFlags |= StartAutoScrollFlags::Vert;
632  }
633 
634  if ( nFlags != StartAutoScrollFlags::NONE )
635  {
636  StartAutoScroll( nFlags );
637  bRet = true;
638  }
639  }
640  break;
641 
643  {
644  const CommandWheelData* pData = rCmd.GetWheelData();
645 
646  if ( pData && (CommandWheelMode::SCROLL == pData->GetMode()) )
647  {
648  if (!pData->IsDeltaPixel())
649  {
650  double nScrollLines = pData->GetScrollLines();
651  double nLines;
652  if ( nScrollLines == COMMAND_WHEEL_PAGESCROLL )
653  {
654  if ( pData->GetDelta() < 0 )
655  nLines = double(-LONG_MAX);
656  else
657  nLines = double(LONG_MAX);
658  }
659  else
660  nLines = pData->GetNotchDelta() * nScrollLines;
661  if ( nLines )
662  {
663  ImplHandleScroll( nullptr,
664  0L,
665  pData->IsHorz() ? pHScrl : pVScrl,
666  nLines );
667  bRet = true;
668  }
669  }
670  else
671  {
672  // Mobile / touch scrolling section
673  const Point & deltaPoint = rCmd.GetMousePosPixel();
674 
675  double deltaXInPixels = double(deltaPoint.X());
676  double deltaYInPixels = double(deltaPoint.Y());
677  Size winSize = GetOutputSizePixel();
678 
679  if(pHScrl)
680  {
681  double visSizeX = double(pHScrl->GetVisibleSize());
682  double ratioX = deltaXInPixels / double(winSize.getWidth());
683  tools::Long deltaXInLogic = tools::Long(visSizeX * ratioX);
684  // Touch need to work by pixels. Did not apply this to
685  // Android, as android code may require adaptations
686  // to work with this scrolling code
687 #ifndef IOS
688  tools::Long lineSizeX = pHScrl->GetLineSize();
689 
690  if(lineSizeX)
691  {
692  deltaXInLogic /= lineSizeX;
693  }
694  else
695  {
696  deltaXInLogic = 0;
697  }
698 #endif
699  if ( deltaXInLogic)
700  {
701 #ifndef IOS
702  bool const isMultiplyByLineSize = true;
703 #else
704  bool const isMultiplyByLineSize = false;
705 #endif
706  lcl_HandleScrollHelper( pHScrl, deltaXInLogic, isMultiplyByLineSize );
707  bRet = true;
708  }
709  }
710  if(pVScrl)
711  {
712  double visSizeY = double(pVScrl->GetVisibleSize());
713  double ratioY = deltaYInPixels / double(winSize.getHeight());
714  tools::Long deltaYInLogic = tools::Long(visSizeY * ratioY);
715 
716  // Touch need to work by pixels. Did not apply this to
717  // Android, as android code may require adaptations
718  // to work with this scrolling code
719 #ifndef IOS
720  tools::Long lineSizeY = pVScrl->GetLineSize();
721  if(lineSizeY)
722  {
723  deltaYInLogic /= lineSizeY;
724  }
725  else
726  {
727  deltaYInLogic = 0;
728  }
729 #endif
730  if ( deltaYInLogic )
731  {
732 #ifndef IOS
733  bool const isMultiplyByLineSize = true;
734 #else
735  bool const isMultiplyByLineSize = false;
736 #endif
737  lcl_HandleScrollHelper( pVScrl, deltaYInLogic, isMultiplyByLineSize );
738 
739  bRet = true;
740  }
741  }
742  }
743  }
744  }
745  break;
746 
748  {
749  if (pVScrl)
750  {
751  const CommandGestureData* pData = rCmd.GetGestureData();
753  {
754  mpWindowImpl->mpFrameData->mnTouchPanPosition = pVScrl->GetThumbPos();
755  }
757  {
758  tools::Long nOriginalPosition = mpWindowImpl->mpFrameData->mnTouchPanPosition;
759  pVScrl->DoScroll(nOriginalPosition + (pData->mfOffset / pVScrl->GetVisibleSize()));
760  }
762  {
763  mpWindowImpl->mpFrameData->mnTouchPanPosition = -1;
764  }
765  bRet = true;
766  }
767  break;
768  }
769 
771  {
772  const CommandScrollData* pData = rCmd.GetAutoScrollData();
773  if ( pData && (pData->GetDeltaX() || pData->GetDeltaY()) )
774  {
775  ImplHandleScroll( pHScrl, pData->GetDeltaX(),
776  pVScrl, pData->GetDeltaY() );
777  bRet = true;
778  }
779  }
780  break;
781 
782  default:
783  break;
784  }
785  }
786 
787  return bRet;
788 }
789 
790 // Note that when called for CommandEventId::Wheel above, despite its name,
791 // pVScrl isn't necessarily the vertical scroll bar. Depending on
792 // whether the scroll is horizontal or vertical, it is either the
793 // horizontal or vertical scroll bar. nY is correspondingly either
794 // the horizontal or vertical scroll amount.
795 
796 void Window::ImplHandleScroll( ScrollBar* pHScrl, double nX,
797  ScrollBar* pVScrl, double nY )
798 {
799  lcl_HandleScrollHelper( pHScrl, nX, true );
800  lcl_HandleScrollHelper( pVScrl, nY, true );
801 }
802 
803 DockingManager* Window::GetDockingManager()
804 {
805  return ImplGetDockingManager();
806 }
807 
808 void Window::EnableDocking( bool bEnable )
809 {
810  // update list of dockable windows
811  if( bEnable )
812  ImplGetDockingManager()->AddWindow( this );
813  else
815 }
816 
817 // retrieves the list of owner draw decorated windows for this window hierarchy
818 ::std::vector<VclPtr<vcl::Window> >& Window::ImplGetOwnerDrawList()
819 {
820  return ImplGetTopmostFrameWindow()->mpWindowImpl->mpFrameData->maOwnerDrawList;
821 }
822 
823 void Window::SetHelpId( const OString& rHelpId )
824 {
825  mpWindowImpl->maHelpId = rHelpId;
826 }
827 
828 const OString& Window::GetHelpId() const
829 {
830  return mpWindowImpl->maHelpId;
831 }
832 
833 // --------- old inline methods ---------------
834 
835 vcl::Window* Window::ImplGetWindow() const
836 {
837  if ( mpWindowImpl->mpClientWindow )
838  return mpWindowImpl->mpClientWindow;
839  else
840  return const_cast<vcl::Window*>(this);
841 }
842 
843 ImplFrameData* Window::ImplGetFrameData()
844 {
845  return mpWindowImpl ? mpWindowImpl->mpFrameData : nullptr;
846 }
847 
848 SalFrame* Window::ImplGetFrame() const
849 {
850  return mpWindowImpl ? mpWindowImpl->mpFrame : nullptr;
851 }
852 
853 weld::Window* Window::GetFrameWeld() const
854 {
855  SalFrame* pFrame = ImplGetFrame();
856  return pFrame ? pFrame->GetFrameWeld() : nullptr;
857 }
858 
859 vcl::Window* Window::GetFrameWindow() const
860 {
861  SalFrame* pFrame = ImplGetFrame();
862  return pFrame ? pFrame->GetWindow() : nullptr;
863 }
864 
865 vcl::Window* Window::ImplGetParent() const
866 {
867  return mpWindowImpl ? mpWindowImpl->mpParent.get() : nullptr;
868 }
869 
870 vcl::Window* Window::ImplGetClientWindow() const
871 {
872  return mpWindowImpl ? mpWindowImpl->mpClientWindow.get() : nullptr;
873 }
874 
875 vcl::Window* Window::ImplGetBorderWindow() const
876 {
877  return mpWindowImpl ? mpWindowImpl->mpBorderWindow.get() : nullptr;
878 }
879 
880 vcl::Window* Window::ImplGetFirstOverlapWindow()
881 {
882  if (!mpWindowImpl)
883  {
884  return nullptr;
885  }
886 
887  if ( mpWindowImpl->mbOverlapWin )
888  return this;
889  else
890  return mpWindowImpl->mpOverlapWindow;
891 }
892 
893 const vcl::Window* Window::ImplGetFirstOverlapWindow() const
894 {
895  if ( mpWindowImpl->mbOverlapWin )
896  return this;
897  else
898  return mpWindowImpl->mpOverlapWindow;
899 }
900 
901 vcl::Window* Window::ImplGetFrameWindow() const
902 {
903  return mpWindowImpl ? mpWindowImpl->mpFrameWindow.get() : nullptr;
904 }
905 
906 bool Window::IsDockingWindow() const
907 {
908  return mpWindowImpl && mpWindowImpl->mbDockWin;
909 }
910 
911 bool Window::ImplIsFloatingWindow() const
912 {
913  return mpWindowImpl && mpWindowImpl->mbFloatWin;
914 }
915 
916 bool Window::ImplIsSplitter() const
917 {
918  return mpWindowImpl && mpWindowImpl->mbSplitter;
919 }
920 
921 bool Window::ImplIsPushButton() const
922 {
923  return mpWindowImpl && mpWindowImpl->mbPushButton;
924 }
925 
926 bool Window::ImplIsOverlapWindow() const
927 {
928  return mpWindowImpl && mpWindowImpl->mbOverlapWin;
929 }
930 
931 void Window::ImplSetMouseTransparent( bool bTransparent )
932 {
933  if (mpWindowImpl)
934  mpWindowImpl->mbMouseTransparent = bTransparent;
935 }
936 
937 Point Window::ImplOutputToFrame( const Point& rPos )
938 {
939  return Point( rPos.X()+mnOutOffX, rPos.Y()+mnOutOffY );
940 }
941 
942 Point Window::ImplFrameToOutput( const Point& rPos )
943 {
944  return Point( rPos.X()-mnOutOffX, rPos.Y()-mnOutOffY );
945 }
946 
947 void Window::SetCompoundControl( bool bCompound )
948 {
949  if (mpWindowImpl)
950  mpWindowImpl->mbCompoundControl = bCompound;
951 }
952 
953 WinBits Window::GetStyle() const
954 {
955  return mpWindowImpl ? mpWindowImpl->mnStyle : 0;
956 }
957 
958 WinBits Window::GetPrevStyle() const
959 {
960  return mpWindowImpl ? mpWindowImpl->mnPrevStyle : 0;
961 }
962 
963 WindowExtendedStyle Window::GetExtendedStyle() const
964 {
965  return mpWindowImpl ? mpWindowImpl->mnExtendedStyle : WindowExtendedStyle::NONE;
966 }
967 
968 void Window::SetType( WindowType nType )
969 {
970  if (mpWindowImpl)
971  mpWindowImpl->mnType = nType;
972 }
973 
974 WindowType Window::GetType() const
975 {
976  if (mpWindowImpl)
977  return mpWindowImpl->mnType;
978  else
979  return WindowType::NONE;
980 }
981 
982 Dialog* Window::GetParentDialog() const
983 {
984  const vcl::Window *pWindow = this;
985 
986  while( pWindow )
987  {
988  if( pWindow->IsDialog() )
989  break;
990 
991  pWindow = pWindow->GetParent();
992  }
993 
994  return const_cast<Dialog *>(dynamic_cast<const Dialog*>(pWindow));
995 }
996 
997 bool Window::IsSystemWindow() const
998 {
999  return mpWindowImpl && mpWindowImpl->mbSysWin;
1000 }
1001 
1002 bool Window::IsDialog() const
1003 {
1004  return mpWindowImpl && mpWindowImpl->mbDialog;
1005 }
1006 
1007 bool Window::IsMenuFloatingWindow() const
1008 {
1009  return mpWindowImpl && mpWindowImpl->mbMenuFloatingWindow;
1010 }
1011 
1012 bool Window::IsToolbarFloatingWindow() const
1013 {
1014  return mpWindowImpl && mpWindowImpl->mbToolbarFloatingWindow;
1015 }
1016 
1017 void Window::EnableAllResize()
1018 {
1019  mpWindowImpl->mbAllResize = true;
1020 }
1021 
1022 void Window::EnableChildTransparentMode( bool bEnable )
1023 {
1024  mpWindowImpl->mbChildTransparent = bEnable;
1025 }
1026 
1027 bool Window::IsChildTransparentModeEnabled() const
1028 {
1029  return mpWindowImpl && mpWindowImpl->mbChildTransparent;
1030 }
1031 
1032 bool Window::IsMouseTransparent() const
1033 {
1034  return mpWindowImpl && mpWindowImpl->mbMouseTransparent;
1035 }
1036 
1037 bool Window::IsPaintTransparent() const
1038 {
1039  return mpWindowImpl && mpWindowImpl->mbPaintTransparent;
1040 }
1041 
1042 void Window::SetDialogControlStart( bool bStart )
1043 {
1044  mpWindowImpl->mbDlgCtrlStart = bStart;
1045 }
1046 
1047 bool Window::IsDialogControlStart() const
1048 {
1049  return mpWindowImpl && mpWindowImpl->mbDlgCtrlStart;
1050 }
1051 
1052 void Window::SetDialogControlFlags( DialogControlFlags nFlags )
1053 {
1054  mpWindowImpl->mnDlgCtrlFlags = nFlags;
1055 }
1056 
1057 DialogControlFlags Window::GetDialogControlFlags() const
1058 {
1059  return mpWindowImpl->mnDlgCtrlFlags;
1060 }
1061 
1062 const InputContext& Window::GetInputContext() const
1063 {
1064  return mpWindowImpl->maInputContext;
1065 }
1066 
1067 bool Window::IsControlFont() const
1068 {
1069  return bool(mpWindowImpl->mpControlFont);
1070 }
1071 
1072 const Color& Window::GetControlForeground() const
1073 {
1074  return mpWindowImpl->maControlForeground;
1075 }
1076 
1077 bool Window::IsControlForeground() const
1078 {
1079  return mpWindowImpl->mbControlForeground;
1080 }
1081 
1082 const Color& Window::GetControlBackground() const
1083 {
1084  return mpWindowImpl->maControlBackground;
1085 }
1086 
1087 bool Window::IsControlBackground() const
1088 {
1089  return mpWindowImpl->mbControlBackground;
1090 }
1091 
1092 bool Window::IsInPaint() const
1093 {
1094  return mpWindowImpl && mpWindowImpl->mbInPaint;
1095 }
1096 
1097 vcl::Window* Window::GetParent() const
1098 {
1099  return mpWindowImpl ? mpWindowImpl->mpRealParent.get() : nullptr;
1100 }
1101 
1102 bool Window::IsVisible() const
1103 {
1104  return mpWindowImpl && mpWindowImpl->mbVisible;
1105 }
1106 
1107 bool Window::IsReallyVisible() const
1108 {
1109  return mpWindowImpl && mpWindowImpl->mbReallyVisible;
1110 }
1111 
1112 bool Window::IsReallyShown() const
1113 {
1114  return mpWindowImpl && mpWindowImpl->mbReallyShown;
1115 }
1116 
1117 bool Window::IsInInitShow() const
1118 {
1119  return mpWindowImpl->mbInInitShow;
1120 }
1121 
1122 bool Window::IsEnabled() const
1123 {
1124  return mpWindowImpl && !mpWindowImpl->mbDisabled;
1125 }
1126 
1127 bool Window::IsInputEnabled() const
1128 {
1129  return mpWindowImpl && !mpWindowImpl->mbInputDisabled;
1130 }
1131 
1132 bool Window::IsAlwaysEnableInput() const
1133 {
1134  return mpWindowImpl->meAlwaysInputMode == AlwaysInputEnabled;
1135 }
1136 
1137 ActivateModeFlags Window::GetActivateMode() const
1138 {
1139  return mpWindowImpl->mnActivateMode;
1140 
1141 }
1142 
1143 bool Window::IsAlwaysOnTopEnabled() const
1144 {
1145  return mpWindowImpl->mbAlwaysOnTop;
1146 }
1147 
1148 bool Window::IsDefaultPos() const
1149 {
1150  return mpWindowImpl->mbDefPos;
1151 }
1152 
1153 bool Window::IsDefaultSize() const
1154 {
1155  return mpWindowImpl->mbDefSize;
1156 }
1157 
1158 Point Window::GetOffsetPixelFrom(const vcl::Window& rWindow) const
1159 {
1160  return Point(GetOutOffXPixel() - rWindow.GetOutOffXPixel(), GetOutOffYPixel() - rWindow.GetOutOffYPixel());
1161 }
1162 
1163 void Window::EnablePaint( bool bEnable )
1164 {
1165  mpWindowImpl->mbPaintDisabled = !bEnable;
1166 }
1167 
1168 bool Window::IsPaintEnabled() const
1169 {
1170  return !mpWindowImpl->mbPaintDisabled;
1171 }
1172 
1173 bool Window::IsUpdateMode() const
1174 {
1175  return !mpWindowImpl->mbNoUpdate;
1176 }
1177 
1178 void Window::SetParentUpdateMode( bool bUpdate )
1179 {
1180  mpWindowImpl->mbNoParentUpdate = !bUpdate;
1181 }
1182 
1183 bool Window::IsActive() const
1184 {
1185  return mpWindowImpl->mbActive;
1186 }
1187 
1188 GetFocusFlags Window::GetGetFocusFlags() const
1189 {
1190  return mpWindowImpl->mnGetFocusFlags;
1191 }
1192 
1193 bool Window::IsCompoundControl() const
1194 {
1195  return mpWindowImpl->mbCompoundControl;
1196 }
1197 
1198 bool Window::IsWait() const
1199 {
1200  return (mpWindowImpl->mnWaitCount != 0);
1201 }
1202 
1203 vcl::Cursor* Window::GetCursor() const
1204 {
1205  if (!mpWindowImpl)
1206  return nullptr;
1207  return mpWindowImpl->mpCursor;
1208 }
1209 
1210 const Fraction& Window::GetZoom() const
1211 {
1212  return mpWindowImpl->maZoom;
1213 }
1214 
1215 bool Window::IsZoom() const
1216 {
1217  return mpWindowImpl->maZoom.GetNumerator() != mpWindowImpl->maZoom.GetDenominator();
1218 }
1219 
1220 void Window::SetHelpText( const OUString& rHelpText )
1221 {
1222  mpWindowImpl->maHelpText = rHelpText;
1223  mpWindowImpl->mbHelpTextDynamic = true;
1224 }
1225 
1226 void Window::SetQuickHelpText( const OUString& rHelpText )
1227 {
1228  if (mpWindowImpl)
1229  mpWindowImpl->maQuickHelpText = rHelpText;
1230 }
1231 
1232 const OUString& Window::GetQuickHelpText() const
1233 {
1234  return mpWindowImpl->maQuickHelpText;
1235 }
1236 
1237 bool Window::IsCreatedWithToolkit() const
1238 {
1239  return mpWindowImpl->mbCreatedWithToolkit;
1240 }
1241 
1242 void Window::SetCreatedWithToolkit( bool b )
1243 {
1244  mpWindowImpl->mbCreatedWithToolkit = b;
1245 }
1246 
1247 PointerStyle Window::GetPointer() const
1248 {
1249  return mpWindowImpl->maPointer;
1250 }
1251 
1252 VCLXWindow* Window::GetWindowPeer() const
1253 {
1254  return mpWindowImpl ? mpWindowImpl->mpVCLXWindow : nullptr;
1255 }
1256 
1257 void Window::SetPosPixel( const Point& rNewPos )
1258 {
1259  setPosSizePixel( rNewPos.X(), rNewPos.Y(), 0, 0, PosSizeFlags::Pos );
1260 }
1261 
1262 void Window::SetSizePixel( const Size& rNewSize )
1263 {
1264  setPosSizePixel( 0, 0, rNewSize.Width(), rNewSize.Height(),
1266 }
1267 
1268 void Window::SetPosSizePixel( const Point& rNewPos, const Size& rNewSize )
1269 {
1270  setPosSizePixel( rNewPos.X(), rNewPos.Y(),
1271  rNewSize.Width(), rNewSize.Height());
1272 }
1273 
1274 void Window::SetOutputSizePixel( const Size& rNewSize )
1275 {
1276  SetSizePixel( Size( rNewSize.Width()+mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder,
1277  rNewSize.Height()+mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder ) );
1278 }
1279 
1280 //When a widget wants to renegotiate layout, get toplevel parent dialog and call
1281 //resize on it. Mark all intermediate containers (or container-alike) widgets
1282 //as dirty for the size remains unchanged, but layout changed circumstances
1283 namespace
1284 {
1285  bool queue_ungrouped_resize(vcl::Window const *pOrigWindow)
1286  {
1287  bool bSomeoneCares = false;
1288 
1289  vcl::Window *pWindow = pOrigWindow->GetParent();
1290  if (pWindow)
1291  {
1292  if (isContainerWindow(*pWindow))
1293  {
1294  bSomeoneCares = true;
1295  }
1296  else if (pWindow->GetType() == WindowType::TABCONTROL)
1297  {
1298  bSomeoneCares = true;
1299  }
1300  pWindow->queue_resize();
1301  }
1302 
1303  return bSomeoneCares;
1304  }
1305 }
1306 
1307 void Window::InvalidateSizeCache()
1308 {
1309  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1310  pWindowImpl->mnOptimalWidthCache = -1;
1311  pWindowImpl->mnOptimalHeightCache = -1;
1312 }
1313 
1314 static bool HasParentDockingWindow(const vcl::Window* pWindow)
1315 {
1316  while( pWindow )
1317  {
1318  if( pWindow->IsDockingWindow() )
1319  return true;
1320 
1321  pWindow = pWindow->GetParent();
1322  }
1323 
1324  return false;
1325 }
1326 
1327 void Window::queue_resize(StateChangedType eReason)
1328 {
1329  if (IsDisposed())
1330  return;
1331 
1332  bool bSomeoneCares = queue_ungrouped_resize(this);
1333 
1334  if (eReason != StateChangedType::Visible)
1335  {
1336  InvalidateSizeCache();
1337  }
1338 
1339  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1340  if (pWindowImpl->m_xSizeGroup && pWindowImpl->m_xSizeGroup->get_mode() != VclSizeGroupMode::NONE)
1341  {
1342  std::set<VclPtr<vcl::Window> > &rWindows = pWindowImpl->m_xSizeGroup->get_widgets();
1343  for (VclPtr<vcl::Window> const & pOther : rWindows)
1344  {
1345  if (pOther == this)
1346  continue;
1347  queue_ungrouped_resize(pOther);
1348  }
1349  }
1350 
1351  if (bSomeoneCares && !mpWindowImpl->mbInDispose)
1352  {
1353  //fdo#57090 force a resync of the borders of the borderwindow onto this
1354  //window in case they have changed
1355  vcl::Window* pBorderWindow = ImplGetBorderWindow();
1356  if (pBorderWindow)
1357  pBorderWindow->Resize();
1358  }
1359  if (VclPtr<vcl::Window> pParent = GetParentWithLOKNotifier())
1360  {
1361  Size aSize = GetSizePixel();
1362  if (!aSize.IsEmpty() && !pParent->IsInInitShow()
1363  && (GetParentDialog() || HasParentDockingWindow(this)))
1364  LogicInvalidate(nullptr);
1365  }
1366 }
1367 
1368 namespace
1369 {
1370  VclAlign toAlign(std::u16string_view rValue)
1371  {
1372  VclAlign eRet = VclAlign::Fill;
1373 
1374  if (rValue == u"fill")
1375  eRet = VclAlign::Fill;
1376  else if (rValue == u"start")
1377  eRet = VclAlign::Start;
1378  else if (rValue == u"end")
1379  eRet = VclAlign::End;
1380  else if (rValue == u"center")
1381  eRet = VclAlign::Center;
1382  return eRet;
1383  }
1384 }
1385 
1386 bool Window::set_font_attribute(const OString &rKey, const OUString &rValue)
1387 {
1388  if (rKey == "weight")
1389  {
1390  vcl::Font aFont(GetControlFont());
1391  if (rValue == "thin")
1392  aFont.SetWeight(WEIGHT_THIN);
1393  else if (rValue == "ultralight")
1395  else if (rValue == "light")
1396  aFont.SetWeight(WEIGHT_LIGHT);
1397  else if (rValue == "book")
1398  aFont.SetWeight(WEIGHT_SEMILIGHT);
1399  else if (rValue == "normal")
1400  aFont.SetWeight(WEIGHT_NORMAL);
1401  else if (rValue == "medium")
1402  aFont.SetWeight(WEIGHT_MEDIUM);
1403  else if (rValue == "semibold")
1404  aFont.SetWeight(WEIGHT_SEMIBOLD);
1405  else if (rValue == "bold")
1406  aFont.SetWeight(WEIGHT_BOLD);
1407  else if (rValue == "ultrabold")
1408  aFont.SetWeight(WEIGHT_ULTRABOLD);
1409  else
1410  aFont.SetWeight(WEIGHT_BLACK);
1411  SetControlFont(aFont);
1412  }
1413  else if (rKey == "style")
1414  {
1415  vcl::Font aFont(GetControlFont());
1416  if (rValue == "normal")
1417  aFont.SetItalic(ITALIC_NONE);
1418  else if (rValue == "oblique")
1419  aFont.SetItalic(ITALIC_OBLIQUE);
1420  else if (rValue == "italic")
1421  aFont.SetItalic(ITALIC_NORMAL);
1422  SetControlFont(aFont);
1423  }
1424  else if (rKey == "underline")
1425  {
1426  vcl::Font aFont(GetControlFont());
1428  SetControlFont(aFont);
1429  }
1430  else if (rKey == "size")
1431  {
1432  vcl::Font aFont(GetControlFont());
1433  sal_Int32 nHeight = rValue.toInt32() / 1000;
1434  aFont.SetFontHeight(nHeight);
1435  SetControlFont(aFont);
1436  }
1437  else
1438  {
1439  SAL_INFO("vcl.layout", "unhandled font attribute: " << rKey);
1440  return false;
1441  }
1442  return true;
1443 }
1444 
1445 bool Window::set_property(const OString &rKey, const OUString &rValue)
1446 {
1447  if ((rKey == "label") || (rKey == "title") || (rKey == "text") )
1448  {
1449  SetText(BuilderUtils::convertMnemonicMarkup(rValue));
1450  }
1451  else if (rKey == "visible")
1452  Show(toBool(rValue));
1453  else if (rKey == "sensitive")
1454  Enable(toBool(rValue));
1455  else if (rKey == "resizable")
1456  {
1457  WinBits nBits = GetStyle();
1458  nBits &= ~WB_SIZEABLE;
1459  if (toBool(rValue))
1460  nBits |= WB_SIZEABLE;
1461  SetStyle(nBits);
1462  }
1463  else if (rKey == "xalign")
1464  {
1465  WinBits nBits = GetStyle();
1466  nBits &= ~(WB_LEFT | WB_CENTER | WB_RIGHT);
1467 
1468  float f = rValue.toFloat();
1469  if (f == 0.0)
1470  nBits |= WB_LEFT;
1471  else if (f == 1.0)
1472  nBits |= WB_RIGHT;
1473  else if (f == 0.5)
1474  nBits |= WB_CENTER;
1475 
1476  SetStyle(nBits);
1477  }
1478  else if (rKey == "justification")
1479  {
1480  WinBits nBits = GetStyle();
1481  nBits &= ~(WB_LEFT | WB_CENTER | WB_RIGHT);
1482 
1483  if (rValue == "left")
1484  nBits |= WB_LEFT;
1485  else if (rValue == "right")
1486  nBits |= WB_RIGHT;
1487  else if (rValue == "center")
1488  nBits |= WB_CENTER;
1489 
1490  SetStyle(nBits);
1491  }
1492  else if (rKey == "yalign")
1493  {
1494  WinBits nBits = GetStyle();
1495  nBits &= ~(WB_TOP | WB_VCENTER | WB_BOTTOM);
1496 
1497  float f = rValue.toFloat();
1498  if (f == 0.0)
1499  nBits |= WB_TOP;
1500  else if (f == 1.0)
1501  nBits |= WB_BOTTOM;
1502  else if (f == 0.5)
1503  nBits |= WB_CENTER;
1504 
1505  SetStyle(nBits);
1506  }
1507  else if (rKey == "wrap")
1508  {
1509  WinBits nBits = GetStyle();
1510  nBits &= ~WB_WORDBREAK;
1511  if (toBool(rValue))
1512  nBits |= WB_WORDBREAK;
1513  SetStyle(nBits);
1514  }
1515  else if (rKey == "height-request")
1516  set_height_request(rValue.toInt32());
1517  else if (rKey == "width-request")
1518  set_width_request(rValue.toInt32());
1519  else if (rKey == "hexpand")
1520  set_hexpand(toBool(rValue));
1521  else if (rKey == "vexpand")
1522  set_vexpand(toBool(rValue));
1523  else if (rKey == "halign")
1524  set_halign(toAlign(rValue));
1525  else if (rKey == "valign")
1526  set_valign(toAlign(rValue));
1527  else if (rKey == "tooltip-markup")
1528  SetQuickHelpText(rValue);
1529  else if (rKey == "tooltip-text")
1530  SetQuickHelpText(rValue);
1531  else if (rKey == "border-width")
1532  set_border_width(rValue.toInt32());
1533  else if (rKey == "margin-start" || rKey == "margin-left")
1534  {
1535  assert(rKey == "margin-start" && "margin-left deprecated in favor of margin-start");
1536  set_margin_start(rValue.toInt32());
1537  }
1538  else if (rKey == "margin-end" || rKey == "margin-right")
1539  {
1540  assert(rKey == "margin-end" && "margin-right deprecated in favor of margin-end");
1541  set_margin_end(rValue.toInt32());
1542  }
1543  else if (rKey == "margin-top")
1544  set_margin_top(rValue.toInt32());
1545  else if (rKey == "margin-bottom")
1546  set_margin_bottom(rValue.toInt32());
1547  else if (rKey == "hscrollbar-policy")
1548  {
1549  WinBits nBits = GetStyle();
1550  nBits &= ~(WB_AUTOHSCROLL|WB_HSCROLL);
1551  if (rValue == "always")
1552  nBits |= WB_HSCROLL;
1553  else if (rValue == "automatic")
1554  nBits |= WB_AUTOHSCROLL;
1555  SetStyle(nBits);
1556  }
1557  else if (rKey == "vscrollbar-policy")
1558  {
1559  WinBits nBits = GetStyle();
1560  nBits &= ~(WB_AUTOVSCROLL|WB_VSCROLL);
1561  if (rValue == "always")
1562  nBits |= WB_VSCROLL;
1563  else if (rValue == "automatic")
1564  nBits |= WB_AUTOVSCROLL;
1565  SetStyle(nBits);
1566  }
1567  else if (rKey == "accessible-name")
1568  {
1569  SetAccessibleName(rValue);
1570  }
1571  else if (rKey == "accessible-description")
1572  {
1573  SetAccessibleDescription(rValue);
1574  }
1575  else if (rKey == "accessible-role")
1576  {
1577  sal_Int16 role = BuilderUtils::getRoleFromName(rValue.toUtf8());
1578  if (role != com::sun::star::accessibility::AccessibleRole::UNKNOWN)
1579  SetAccessibleRole(role);
1580  }
1581  else if (rKey == "use-markup")
1582  {
1583  //https://live.gnome.org/GnomeGoals/RemoveMarkupInMessages
1584  SAL_WARN_IF(toBool(rValue), "vcl.layout", "Use pango attributes instead of mark-up");
1585  }
1586  else if (rKey == "has-focus")
1587  {
1588  if (toBool(rValue))
1589  GrabFocus();
1590  }
1591  else if (rKey == "can-focus")
1592  {
1593  WinBits nBits = GetStyle();
1594  nBits &= ~(WB_TABSTOP|WB_NOTABSTOP);
1595  if (toBool(rValue))
1596  nBits |= WB_TABSTOP;
1597  else
1598  nBits |= WB_NOTABSTOP;
1599  SetStyle(nBits);
1600  }
1601  else
1602  {
1603  SAL_INFO("vcl.layout", "unhandled property: " << rKey);
1604  return false;
1605  }
1606  return true;
1607 }
1608 
1609 void Window::set_height_request(sal_Int32 nHeightRequest)
1610 {
1611  if (!mpWindowImpl)
1612  return;
1613 
1614  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1615 
1616  if ( pWindowImpl->mnHeightRequest != nHeightRequest )
1617  {
1618  pWindowImpl->mnHeightRequest = nHeightRequest;
1619  queue_resize();
1620  }
1621 }
1622 
1623 void Window::set_width_request(sal_Int32 nWidthRequest)
1624 {
1625  if (!mpWindowImpl)
1626  return;
1627 
1628  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1629 
1630  if ( pWindowImpl->mnWidthRequest != nWidthRequest )
1631  {
1632  pWindowImpl->mnWidthRequest = nWidthRequest;
1633  queue_resize();
1634  }
1635 }
1636 
1637 Size Window::get_ungrouped_preferred_size() const
1638 {
1639  Size aRet(get_width_request(), get_height_request());
1640  if (aRet.Width() == -1 || aRet.Height() == -1)
1641  {
1642  //cache gets blown away by queue_resize
1643  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1644  if (pWindowImpl->mnOptimalWidthCache == -1 || pWindowImpl->mnOptimalHeightCache == -1)
1645  {
1646  Size aOptimal(GetOptimalSize());
1647  pWindowImpl->mnOptimalWidthCache = aOptimal.Width();
1648  pWindowImpl->mnOptimalHeightCache = aOptimal.Height();
1649  }
1650 
1651  if (aRet.Width() == -1)
1652  aRet.setWidth( pWindowImpl->mnOptimalWidthCache );
1653  if (aRet.Height() == -1)
1654  aRet.setHeight( pWindowImpl->mnOptimalHeightCache );
1655  }
1656  return aRet;
1657 }
1658 
1659 Size Window::get_preferred_size() const
1660 {
1661  Size aRet(get_ungrouped_preferred_size());
1662 
1663  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1664  if (pWindowImpl->m_xSizeGroup)
1665  {
1666  const VclSizeGroupMode eMode = pWindowImpl->m_xSizeGroup->get_mode();
1667  if (eMode != VclSizeGroupMode::NONE)
1668  {
1669  const bool bIgnoreInHidden = pWindowImpl->m_xSizeGroup->get_ignore_hidden();
1670  const std::set<VclPtr<vcl::Window> > &rWindows = pWindowImpl->m_xSizeGroup->get_widgets();
1671  for (auto const& window : rWindows)
1672  {
1673  const vcl::Window *pOther = window;
1674  if (pOther == this)
1675  continue;
1676  if (bIgnoreInHidden && !pOther->IsVisible())
1677  continue;
1678  Size aOtherSize = pOther->get_ungrouped_preferred_size();
1679  if (eMode == VclSizeGroupMode::Both || eMode == VclSizeGroupMode::Horizontal)
1680  aRet.setWidth( std::max(aRet.Width(), aOtherSize.Width()) );
1681  if (eMode == VclSizeGroupMode::Both || eMode == VclSizeGroupMode::Vertical)
1682  aRet.setHeight( std::max(aRet.Height(), aOtherSize.Height()) );
1683  }
1684  }
1685  }
1686 
1687  return aRet;
1688 }
1689 
1690 VclAlign Window::get_halign() const
1691 {
1692  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1693  return pWindowImpl->meHalign;
1694 }
1695 
1696 void Window::set_halign(VclAlign eAlign)
1697 {
1698  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1699  pWindowImpl->meHalign = eAlign;
1700 }
1701 
1702 VclAlign Window::get_valign() const
1703 {
1704  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1705  return pWindowImpl->meValign;
1706 }
1707 
1708 void Window::set_valign(VclAlign eAlign)
1709 {
1710  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1711  pWindowImpl->meValign = eAlign;
1712 }
1713 
1714 bool Window::get_hexpand() const
1715 {
1716  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1717  return pWindowImpl->mbHexpand;
1718 }
1719 
1720 void Window::set_hexpand(bool bExpand)
1721 {
1722  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1723  pWindowImpl->mbHexpand = bExpand;
1724 }
1725 
1726 bool Window::get_vexpand() const
1727 {
1728  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1729  return pWindowImpl->mbVexpand;
1730 }
1731 
1732 void Window::set_vexpand(bool bExpand)
1733 {
1734  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1735  pWindowImpl->mbVexpand = bExpand;
1736 }
1737 
1738 bool Window::get_expand() const
1739 {
1740  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1741  return pWindowImpl->mbExpand;
1742 }
1743 
1744 void Window::set_expand(bool bExpand)
1745 {
1746  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1747  pWindowImpl->mbExpand = bExpand;
1748 }
1749 
1750 VclPackType Window::get_pack_type() const
1751 {
1752  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1753  return pWindowImpl->mePackType;
1754 }
1755 
1756 void Window::set_pack_type(VclPackType ePackType)
1757 {
1758  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1759  pWindowImpl->mePackType = ePackType;
1760 }
1761 
1762 sal_Int32 Window::get_padding() const
1763 {
1764  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1765  return pWindowImpl->mnPadding;
1766 }
1767 
1768 void Window::set_padding(sal_Int32 nPadding)
1769 {
1770  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1771  pWindowImpl->mnPadding = nPadding;
1772 }
1773 
1774 bool Window::get_fill() const
1775 {
1776  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1777  return pWindowImpl->mbFill;
1778 }
1779 
1780 void Window::set_fill(bool bFill)
1781 {
1782  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1783  pWindowImpl->mbFill = bFill;
1784 }
1785 
1786 sal_Int32 Window::get_grid_width() const
1787 {
1788  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1789  return pWindowImpl->mnGridWidth;
1790 }
1791 
1792 void Window::set_grid_width(sal_Int32 nCols)
1793 {
1794  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1795  pWindowImpl->mnGridWidth = nCols;
1796 }
1797 
1798 sal_Int32 Window::get_grid_left_attach() const
1799 {
1800  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1801  return pWindowImpl->mnGridLeftAttach;
1802 }
1803 
1804 void Window::set_grid_left_attach(sal_Int32 nAttach)
1805 {
1806  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1807  pWindowImpl->mnGridLeftAttach = nAttach;
1808 }
1809 
1810 sal_Int32 Window::get_grid_height() const
1811 {
1812  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1813  return pWindowImpl->mnGridHeight;
1814 }
1815 
1816 void Window::set_grid_height(sal_Int32 nRows)
1817 {
1818  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1819  pWindowImpl->mnGridHeight = nRows;
1820 }
1821 
1822 sal_Int32 Window::get_grid_top_attach() const
1823 {
1824  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1825  return pWindowImpl->mnGridTopAttach;
1826 }
1827 
1828 void Window::set_grid_top_attach(sal_Int32 nAttach)
1829 {
1830  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1831  pWindowImpl->mnGridTopAttach = nAttach;
1832 }
1833 
1834 void Window::set_border_width(sal_Int32 nBorderWidth)
1835 {
1836  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1837  pWindowImpl->mnBorderWidth = nBorderWidth;
1838 }
1839 
1840 sal_Int32 Window::get_border_width() const
1841 {
1842  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1843  return pWindowImpl->mnBorderWidth;
1844 }
1845 
1846 void Window::set_margin_start(sal_Int32 nWidth)
1847 {
1848  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1849  if (pWindowImpl->mnMarginLeft != nWidth)
1850  {
1851  pWindowImpl->mnMarginLeft = nWidth;
1852  queue_resize();
1853  }
1854 }
1855 
1856 sal_Int32 Window::get_margin_start() const
1857 {
1858  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1859  return pWindowImpl->mnMarginLeft;
1860 }
1861 
1862 void Window::set_margin_end(sal_Int32 nWidth)
1863 {
1864  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1865  if (pWindowImpl->mnMarginRight != nWidth)
1866  {
1867  pWindowImpl->mnMarginRight = nWidth;
1868  queue_resize();
1869  }
1870 }
1871 
1872 sal_Int32 Window::get_margin_end() const
1873 {
1874  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1875  return pWindowImpl->mnMarginRight;
1876 }
1877 
1878 void Window::set_margin_top(sal_Int32 nWidth)
1879 {
1880  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1881  if (pWindowImpl->mnMarginTop != nWidth)
1882  {
1883  pWindowImpl->mnMarginTop = nWidth;
1884  queue_resize();
1885  }
1886 }
1887 
1888 sal_Int32 Window::get_margin_top() const
1889 {
1890  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1891  return pWindowImpl->mnMarginTop;
1892 }
1893 
1894 void Window::set_margin_bottom(sal_Int32 nWidth)
1895 {
1896  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1897  if (pWindowImpl->mnMarginBottom != nWidth)
1898  {
1899  pWindowImpl->mnMarginBottom = nWidth;
1900  queue_resize();
1901  }
1902 }
1903 
1904 sal_Int32 Window::get_margin_bottom() const
1905 {
1906  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1907  return pWindowImpl->mnMarginBottom;
1908 }
1909 
1910 sal_Int32 Window::get_height_request() const
1911 {
1912  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1913  return pWindowImpl->mnHeightRequest;
1914 }
1915 
1916 sal_Int32 Window::get_width_request() const
1917 {
1918  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1919  return pWindowImpl->mnWidthRequest;
1920 }
1921 
1922 bool Window::get_secondary() const
1923 {
1924  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1925  return pWindowImpl->mbSecondary;
1926 }
1927 
1928 void Window::set_secondary(bool bSecondary)
1929 {
1930  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1931  pWindowImpl->mbSecondary = bSecondary;
1932 }
1933 
1934 bool Window::get_non_homogeneous() const
1935 {
1936  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1937  return pWindowImpl->mbNonHomogeneous;
1938 }
1939 
1940 void Window::set_non_homogeneous(bool bNonHomogeneous)
1941 {
1942  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1943  pWindowImpl->mbNonHomogeneous = bNonHomogeneous;
1944 }
1945 
1946 void Window::add_to_size_group(const std::shared_ptr<VclSizeGroup>& xGroup)
1947 {
1948  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1949  //To-Do, multiple groups
1950  pWindowImpl->m_xSizeGroup = xGroup;
1951  pWindowImpl->m_xSizeGroup->insert(this);
1952  if (VclSizeGroupMode::NONE != pWindowImpl->m_xSizeGroup->get_mode())
1953  queue_resize();
1954 }
1955 
1956 void Window::remove_from_all_size_groups()
1957 {
1958  WindowImpl *pWindowImpl = mpWindowImpl->mpBorderWindow ? mpWindowImpl->mpBorderWindow->mpWindowImpl.get() : mpWindowImpl.get();
1959  //To-Do, multiple groups
1960  if (pWindowImpl->m_xSizeGroup)
1961  {
1962  if (VclSizeGroupMode::NONE != pWindowImpl->m_xSizeGroup->get_mode())
1963  queue_resize();
1964  pWindowImpl->m_xSizeGroup->erase(this);
1965  pWindowImpl->m_xSizeGroup.reset();
1966  }
1967 }
1968 
1969 void Window::add_mnemonic_label(FixedText *pLabel)
1970 {
1971  std::vector<VclPtr<FixedText> >& v = mpWindowImpl->m_aMnemonicLabels;
1972  if (std::find(v.begin(), v.end(), VclPtr<FixedText>(pLabel)) != v.end())
1973  return;
1974  v.emplace_back(pLabel);
1975  pLabel->set_mnemonic_widget(this);
1976 }
1977 
1978 void Window::remove_mnemonic_label(FixedText *pLabel)
1979 {
1980  std::vector<VclPtr<FixedText> >& v = mpWindowImpl->m_aMnemonicLabels;
1981  auto aFind = std::find(v.begin(), v.end(), VclPtr<FixedText>(pLabel));
1982  if (aFind == v.end())
1983  return;
1984  v.erase(aFind);
1985  pLabel->set_mnemonic_widget(nullptr);
1986 }
1987 
1988 const std::vector<VclPtr<FixedText> >& Window::list_mnemonic_labels() const
1989 {
1990  return mpWindowImpl->m_aMnemonicLabels;
1991 }
1992 
1993 } /* namespace vcl */
1994 
1995 void DrawFocusRect(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
1996 {
1997  const int nBorder = 1;
1998  rRenderContext.Invert(tools::Rectangle(Point(rRect.Left(), rRect.Top()), Size(rRect.GetWidth(), nBorder)), InvertFlags::N50);
1999  rRenderContext.Invert(tools::Rectangle(Point(rRect.Left(), rRect.Bottom()-nBorder+1), Size(rRect.GetWidth(), nBorder)), InvertFlags::N50);
2000  rRenderContext.Invert(tools::Rectangle(Point(rRect.Left(), rRect.Top()+nBorder), Size(nBorder, rRect.GetHeight()-(nBorder*2))), InvertFlags::N50);
2001  rRenderContext.Invert(tools::Rectangle(Point(rRect.Right()-nBorder+1, rRect.Top()+nBorder), Size(nBorder, rRect.GetHeight()-(nBorder*2))), InvertFlags::N50);
2002 }
2003 
2004 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool toBool(std::string_view rValue)
Definition: builder.cxx:85
OutDevType GetOutDevType() const
Definition: outdev.hxx:524
bool IsInputEnabled() const
Definition: window2.cxx:1127
void set_mnemonic_widget(vcl::Window *pWindow)
Definition: fixed.cxx:408
static bool HasParentDockingWindow(const vcl::Window *pWindow)
Definition: window2.cxx:1314
sal_Int32 mnPadding
Definition: window.h:307
void SetFontSize(const Size &)
Definition: font/font.cxx:118
bool mbHexpand
Definition: window.h:317
tools::Long GetRangeMax() const
Definition: scrbar.hxx:118
VclPtr< vcl::Window > mpFocusWin
Definition: svdata.hxx:248
void EndAutoScroll()
Definition: window2.cxx:332
sal_Int32 mnGridWidth
Definition: window.h:311
bool mbVexpand
Definition: window.h:317
VclPackType mePackType
Definition: window.h:306
void setWidth(tools::Long nWidth)
void ImplStop()
Definition: scrwnd.cxx:98
void Invert(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, SalInvert nFlags, const OutputDevice &rOutDev)
StartAutoScrollFlags
Definition: window.hxx:305
StartTrackingFlags
Definition: window.hxx:291
std::unique_ptr< ContentProperties > pData
bool IsTransparent() const
WindowExtendedStyle
Definition: window.hxx:451
sal_Int32 mnOptimalHeightCache
Definition: window.h:271
ImplSVAppData maAppData
Definition: svdata.hxx:391
long Long
void disposeAndClear()
Definition: vclptr.hxx:200
bool mbNonHomogeneous
Definition: window.h:317
WEIGHT_THIN
tools::Long GetOutOffXPixel() const
Definition: outdev.hxx:445
sal_Int64 n
sal_Int32 mnHeightRequest
Definition: window.h:269
WinBits const WB_RIGHT
WEIGHT_BLACK
void SetWeight(FontWeight)
Definition: font/font.cxx:216
tools::Long GetDeltaY() const
WinBits const WB_AUTOVSCROLL
WEIGHT_SEMIBOLD
tools::Long GetWidth() const
tools::Long GetLineSize() const
Definition: scrbar.hxx:124
WinBits const WB_VSCROLL
const CommandWheelData * GetWheelData() const
const CommandScrollData * GetAutoScrollData() const
WEIGHT_LIGHT
GestureEventType const meEventType
bool IsHorz() const
bool SelectClipRegion(const vcl::Region &, SalGraphics *pGraphics=nullptr)
std::shared_ptr< VclSizeGroup > m_xSizeGroup
Definition: window.h:283
tools::Long GetDeltaX() const
WEIGHT_BOLD
bool mbSecondary
Definition: window.h:317
StateChangedType
Definition: window.hxx:317
HashMap_OWString_Interface aMap
sal_Int64 WinBits
constexpr::Color COL_TRANSPARENT(0xFF, 0xFF, 0xFF, 0xFF)
void SetBackground()
void Invert(const tools::Rectangle &rRect, InvertFlags nFlags=InvertFlags::NONE)
Definition: rect.cxx:147
WinBits const WB_BOTTOM
WinBits const WB_TOP
SAL_DLLPRIVATE void ReMirror(Point &rPoint) const
Definition: outdev.cxx:603
tools::Long Left() const
LINESTYLE_NONE
void DrawFocusRect(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: window2.cxx:1995
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
sal_Int32 mnMarginRight
Definition: window.h:314
WinBits const WB_HSCROLL
void EndTracking(TrackingEventFlags nFlags=TrackingEventFlags::NONE)
Definition: window2.cxx:272
tools::Long Bottom() const
VclSizeGroupMode
Definition: vclenum.hxx:265
TrackingEventFlags
Definition: window.hxx:104
sal_Int32 mnWidthRequest
Definition: window.h:268
virtual weld::Window * GetFrameWeld() const
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
Definition: window2.cxx:1327
Mode eMode
void SetUnderline(FontLineStyle)
Definition: font/font.cxx:246
AutoTimer * mpTrackTimer
Definition: svdata.hxx:255
bool mbFill
Definition: window.h:317
bool IsDeltaPixel() const
GetFocusFlags
Definition: window.hxx:339
bool isContainerWindow(const vcl::Window &rWindow)
Definition: layout.hxx:840
void SetDebugName(const char *pDebugName)
Definition: task.hxx:81
VclPtr< ImplWheelWindow > mpWheelWindow
Definition: svdata.hxx:146
bool IsDockingWindow() const
Definition: window2.cxx:906
DialogControlFlags
Definition: window.hxx:372
double GetScrollLines() const
std::optional< tools::Rectangle > mpTrackRect
Definition: window.h:115
static void lcl_HandleScrollHelper(ScrollBar *pScrl, double nN, bool isMultiplyByLineSize)
Definition: window2.cxx:577
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:73
An auto-timer is a multi-shot timer re-emitting itself at interval until destroyed or stopped...
Definition: timer.hxx:72
GraphicsSharedPtr mpGraphics
tools::Long GetPageSize() const
Definition: scrbar.hxx:126
StartAutoScrollFlags mnAutoScrollFlags
Definition: svdata.hxx:262
Size get_ungrouped_preferred_size() const
Definition: window2.cxx:1637
WEIGHT_SEMILIGHT
VclPackType
Definition: vclenum.hxx:224
bool IsEmpty() const
sal_Int32 mnOptimalWidthCache
Definition: window.h:270
ITALIC_OBLIQUE
VclAlign meValign
Definition: window.h:305
virtual bool AcquireGraphics() const =0
Acquire a graphics device that the output device uses to draw on.
tools::Long GetNotchDelta() const
CommandWheelMode GetMode() const
WinBits const WB_VCENTER
WEIGHT_MEDIUM
sal_Int32 mnMarginTop
Definition: window.h:315
ShowTrackFlags
Definition: window.hxx:275
tools::Long Width() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:303
WEIGHT_NORMAL
CommandEventId GetCommand() const
ActivateModeFlags
Definition: window.hxx:186
LINESTYLE_SINGLE
WEIGHT_ULTRALIGHT
bool IsDialog() const
Definition: window2.cxx:1002
void SetTextColor(const Color &rColor)
Definition: text.cxx:662
double const mfOffset
std::unique_ptr< WindowImpl > mpWindowImpl
Definition: window.hxx:519
bool IsInModalMode() const
A window is in modal mode if one of its children or subchildren is a running modal window (a modal di...
Definition: window.cxx:3587
virtual void Start() override
Activates the timer task.
Definition: timer.cxx:83
void AddWindow(const vcl::Window *pWin)
Definition: dockmgr.cxx:376
virtual void Resize()
Definition: window.cxx:1834
IMPL_LINK(Window, ImplTrackTimerHdl, Timer *, pTimer, void)
Definition: window2.cxx:220
void Merge(const Font &rFont)
Definition: font/font.cxx:299
const Size & GetFontSize() const
Definition: font/font.cxx:675
std::enable_if_t< std::is_floating_point_v< F > &&std::is_integral_v< I >, bool > convertsToAtMost(F value, I max)
const CommandGestureData * GetGestureData() const
WEIGHT_ULTRABOLD
VclAlign meHalign
Definition: window.h:304
ITALIC_NONE
tools::Long Top() const
void SetTimeout(sal_uInt64 nTimeoutMs)
Definition: timer.cxx:89
#define COMMAND_WHEEL_PAGESCROLL
void GrabFocus()
Definition: window.cxx:2978
vcl::Window * GetParent() const
Definition: window2.cxx:1097
VclPtr< vcl::Window > mpTrackWin
Definition: svdata.hxx:254
WinBits const WB_LEFT
VclPtr< vcl::Window > mpBorderWindow
Definition: window.h:230
void SetParentToDefaultWindow()
Definition: window.cxx:1788
const long LONG_MAX
tools::Long GetOutOffYPixel() const
Definition: outdev.hxx:446
OUString convertMnemonicMarkup(const OUString &rIn)
Definition: builder.cxx:2400
tools::Long GetThumbPos() const
Definition: scrbar.hxx:122
bool mbExpand
Definition: window.h:317
const Point & GetMousePosPixel() const
Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:828
tools::Long const nBorder
WinBits const WB_SIZEABLE
float v
tools::Long DoScroll(tools::Long nNewPos)
Definition: scrbar.cxx:1303
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:112
sal_Int32 mnGridLeftAttach
Definition: window.h:309
void RemoveWindow(const vcl::Window *pWin)
Definition: dockmgr.cxx:384
sal_Int32 GetDenominator() const
DockingManager * ImplGetDockingManager()
Definition: svdata.cxx:298
WindowType
#define SAL_WARN_IF(condition, area, stream)
ITALIC_NORMAL
bool IsVisible() const
Definition: window2.cxx:1102
VclPtr< vcl::Window > mpAutoScrollWin
Definition: svdata.hxx:257
#define SAL_INFO(area, stream)
sal_Int32 mnMarginBottom
Definition: window.h:316
sal_Int32 mnBorderWidth
Definition: window.h:312
tools::Long AdjustWidth(tools::Long n)
static VclPtr< reference_type > Create(Arg &&...arg)
A construction helper for VclPtr.
Definition: vclptr.hxx:127
tools::Long Height() const
std::enable_if_t< std::is_floating_point_v< F > &&std::is_integral_v< I >, bool > convertsToAtLeast(F value, I min)
sal_Int32 GetNumerator() const
void SetInvokeHandler(const Link< Timer *, void > &rLink)
Definition: timer.hxx:56
std::optional< tools::Rectangle > mpFocusRect
Definition: window.h:113
WinBits const WB_AUTOHSCROLL
tools::Long AdjustHeight(tools::Long n)
ShowTrackFlags mnTrackFlags
Definition: window.h:116
PointerStyle
Definition: ptrstyle.hxx:25
bool IsDisposed() const
Definition: window.cxx:142
WinBits const WB_TABSTOP
void SetFontHeight(tools::Long nHeight)
Definition: font/font.cxx:676
void SetItalic(FontItalic)
Definition: font/font.cxx:228
SAL_DLLPRIVATE tools::Rectangle ImplLogicToDevicePixel(const tools::Rectangle &rLogicRect) const
Convert a logical rectangle to a rectangle in physical device pixel units.
Definition: map.cxx:406
sal_Int16 getRoleFromName(const OString &roleName)
Definition: builder.cxx:2481
void setHeight(tools::Long nHeight)
sal_Int32 mnGridTopAttach
Definition: window.h:310
tools::Long GetHeight() const
WindowType GetType() const
Definition: window2.cxx:974
tools::Long GetVisibleSize() const
Definition: scrbar.hxx:128
tools::Long GetDelta() const
VclAlign
Definition: vclenum.hxx:216
WinBits const WB_CENTER
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
bool IsEnabled() const
Definition: window2.cxx:1122
Definition: timer.hxx:26
void(* f)(TrueTypeTable *)
Definition: ttcr.cxx:482
StartTrackingFlags mnTrackFlags
Definition: svdata.hxx:261
static sal_uLong GetScrollRepeat()
WinBits const WB_WORDBREAK
static tools::Long WinFloatRound(double fVal)
Definition: window2.cxx:374
WinBits const WB_NOTABSTOP
tools::Long Right() const
sal_Int32 mnMarginLeft
Definition: window.h:313
vcl::Window * GetWindow() const
Definition: salframe.hxx:293
sal_Int32 mnGridHeight
Definition: window.h:308
ImplSVWinData * mpWinData
Definition: svdata.hxx:394
static sal_uLong GetButtonStartRepeat()