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