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