LibreOffice Module vcl (master)  1
paint.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 <config_features.h>
21 #include <vcl/gdimtf.hxx>
22 #include <vcl/window.hxx>
23 #include <vcl/virdev.hxx>
24 #include <vcl/cursor.hxx>
25 #include <vcl/settings.hxx>
26 #include <vcl/syswin.hxx>
27 
28 #include <sal/types.h>
29 #include <sal/log.hxx>
30 
31 #include <window.h>
32 #include <salgdi.hxx>
33 #include <salframe.hxx>
34 #include <svdata.hxx>
35 #include <comphelper/lok.hxx>
37 #if HAVE_FEATURE_OPENGL
39 #endif
40 
41 // PaintBufferGuard
42 
44  : mpFrameData(pFrameData),
45  m_pWindow(pWindow),
46  mbBackground(false),
47  mnOutOffX(0),
48  mnOutOffY(0)
49 {
50  if (!pFrameData->mpBuffer)
51  return;
52 
53  // transfer various settings
54  // FIXME: this must disappear as we move to RenderContext only,
55  // the painting must become state-less, so that no actual
56  // vcl::Window setting affects this
57  mbBackground = pFrameData->mpBuffer->IsBackground();
58  if (pWindow->IsBackground())
59  {
60  maBackground = pFrameData->mpBuffer->GetBackground();
61  pFrameData->mpBuffer->SetBackground(pWindow->GetBackground());
62  }
63  //else
64  //SAL_WARN("vcl.window", "the root of the double-buffering hierarchy should not have a transparent background");
65 
66  PushFlags nFlags = PushFlags::NONE;
67  nFlags |= PushFlags::CLIPREGION;
68  nFlags |= PushFlags::FILLCOLOR;
69  nFlags |= PushFlags::FONT;
70  nFlags |= PushFlags::LINECOLOR;
71  nFlags |= PushFlags::MAPMODE;
72  maSettings = pFrameData->mpBuffer->GetSettings();
73  nFlags |= PushFlags::REFPOINT;
74  nFlags |= PushFlags::TEXTCOLOR;
75  nFlags |= PushFlags::TEXTLINECOLOR;
76  nFlags |= PushFlags::OVERLINECOLOR;
77  nFlags |= PushFlags::TEXTFILLCOLOR;
78  nFlags |= PushFlags::TEXTALIGN;
79  nFlags |= PushFlags::RASTEROP;
80  nFlags |= PushFlags::TEXTLAYOUTMODE;
81  nFlags |= PushFlags::TEXTLANGUAGE;
82  pFrameData->mpBuffer->Push(nFlags);
83  pFrameData->mpBuffer->SetClipRegion(pWindow->GetClipRegion());
84  pFrameData->mpBuffer->SetFillColor(pWindow->GetFillColor());
85  pFrameData->mpBuffer->SetFont(pWindow->GetFont());
86  pFrameData->mpBuffer->SetLineColor(pWindow->GetLineColor());
87  pFrameData->mpBuffer->SetMapMode(pWindow->GetMapMode());
88  pFrameData->mpBuffer->SetRefPoint(pWindow->GetRefPoint());
89  pFrameData->mpBuffer->SetSettings(pWindow->GetSettings());
90  pFrameData->mpBuffer->SetTextColor(pWindow->GetTextColor());
91  pFrameData->mpBuffer->SetTextLineColor(pWindow->GetTextLineColor());
92  pFrameData->mpBuffer->SetOverlineColor(pWindow->GetOverlineColor());
93  pFrameData->mpBuffer->SetTextFillColor(pWindow->GetTextFillColor());
94  pFrameData->mpBuffer->SetTextAlign(pWindow->GetTextAlign());
95  pFrameData->mpBuffer->SetRasterOp(pWindow->GetRasterOp());
96  pFrameData->mpBuffer->SetLayoutMode(pWindow->GetLayoutMode());
97  pFrameData->mpBuffer->SetDigitLanguage(pWindow->GetDigitLanguage());
98 
99  mnOutOffX = pFrameData->mpBuffer->GetOutOffXPixel();
100  mnOutOffY = pFrameData->mpBuffer->GetOutOffYPixel();
101  pFrameData->mpBuffer->SetOutOffXPixel(pWindow->GetOutOffXPixel());
102  pFrameData->mpBuffer->SetOutOffYPixel(pWindow->GetOutOffYPixel());
103 }
104 
106 {
107  if (!mpFrameData->mpBuffer)
108  return;
109 
110  if (!m_aPaintRect.IsEmpty())
111  {
112  // copy the buffer content to the actual window
113  // export VCL_DOUBLEBUFFERING_AVOID_PAINT=1 to see where we are
114  // painting directly instead of using Invalidate()
115  // [ie. everything you can see was painted directly to the
116  // window either above or in eg. an event handler]
117  if (!getenv("VCL_DOUBLEBUFFERING_AVOID_PAINT"))
118  {
119  // Make sure that the +1 value GetSize() adds to the size is in pixels.
120  Size aPaintRectSize;
121  if (m_pWindow->GetMapMode().GetMapUnit() == MapUnit::MapPixel)
122  {
123  aPaintRectSize = m_aPaintRect.GetSize();
124  }
125  else
126  {
128  aPaintRectSize = m_pWindow->PixelToLogic(aRectanglePixel.GetSize());
129  }
130 
131  m_pWindow->DrawOutDev(m_aPaintRect.TopLeft(), aPaintRectSize, m_aPaintRect.TopLeft(), aPaintRectSize, *mpFrameData->mpBuffer.get());
132  }
133  }
134 
135  // Restore buffer state.
138 
141  if (mbBackground)
143  else
145 }
146 
148 {
149  m_aPaintRect = rRectangle;
150 }
151 
153 {
154  if (mpFrameData->mpBuffer)
155  return mpFrameData->mpBuffer;
156  else
157  return m_pWindow;
158 }
159 
161 {
162 private:
164  std::unique_ptr<vcl::Region> m_pChildRegion;
169  bool m_bPop : 1;
172 public:
173  PaintHelper(vcl::Window* pWindow, ImplPaintFlags nPaintFlags);
174  void SetPop()
175  {
176  m_bPop = true;
177  }
178  void SetPaintRect(const tools::Rectangle& rRect)
179  {
180  m_aPaintRect = rRect;
181  }
183  {
184  m_aSelectionRect = rRect;
185  }
186  void SetRestoreCursor(bool bRestoreCursor)
187  {
188  m_bRestoreCursor = bRestoreCursor;
189  }
190  bool GetRestoreCursor() const
191  {
192  return m_bRestoreCursor;
193  }
195  {
196  return m_nPaintFlags;
197  }
199  {
200  return m_aPaintRegion;
201  }
202  void DoPaint(const vcl::Region* pRegion);
203 
205  void StartBufferedPaint();
206 
208  void PaintBuffer();
209 
210  ~PaintHelper();
211 };
212 
214  : m_pWindow(pWindow)
215  , m_nPaintFlags(nPaintFlags)
216  , m_bPop(false)
217  , m_bRestoreCursor(false)
218  , m_bStartedBufferedPaint(false)
219 {
220 }
221 
223 {
224  ImplFrameData* pFrameData = m_pWindow->mpWindowImpl->mpFrameData;
225  assert(!pFrameData->mbInBufferedPaint);
226 
227  pFrameData->mbInBufferedPaint = true;
228  pFrameData->maBufferedRect = tools::Rectangle();
230 }
231 
233 {
234  ImplFrameData* pFrameData = m_pWindow->mpWindowImpl->mpFrameData;
235  assert(pFrameData->mbInBufferedPaint);
236  assert(m_bStartedBufferedPaint);
237 
238  PaintBufferGuard aGuard(pFrameData, m_pWindow);
239  aGuard.SetPaintRect(pFrameData->maBufferedRect);
240 }
241 
242 void PaintHelper::DoPaint(const vcl::Region* pRegion)
243 {
244  WindowImpl* pWindowImpl = m_pWindow->ImplGetWindowImpl();
245 
246  vcl::Region* pWinChildClipRegion = m_pWindow->ImplGetWinChildClipRegion();
247  ImplFrameData* pFrameData = m_pWindow->mpWindowImpl->mpFrameData;
248  if (pWindowImpl->mnPaintFlags & ImplPaintFlags::PaintAll || pFrameData->mbInBufferedPaint)
249  {
250  pWindowImpl->maInvalidateRegion = *pWinChildClipRegion;
251  }
252  else
253  {
254  if (pRegion)
255  pWindowImpl->maInvalidateRegion.Union( *pRegion );
256 
257  if (pWindowImpl->mpWinData && pWindowImpl->mbTrackVisible)
258  /* #98602# need to repaint all children within the
259  * tracking rectangle, so the following invert
260  * operation takes places without traces of the previous
261  * one.
262  */
263  pWindowImpl->maInvalidateRegion.Union(*pWindowImpl->mpWinData->mpTrackRect);
264 
266  m_pChildRegion.reset( new vcl::Region(pWindowImpl->maInvalidateRegion) );
267  pWindowImpl->maInvalidateRegion.Intersect(*pWinChildClipRegion);
268  }
269  pWindowImpl->mnPaintFlags = ImplPaintFlags::NONE;
270  if (!pWindowImpl->maInvalidateRegion.IsEmpty())
271  {
272 #if HAVE_FEATURE_OPENGL
273  VCL_GL_INFO("PaintHelper::DoPaint on " <<
274  typeid( *m_pWindow ).name() << " '" << m_pWindow->GetText() << "' begin");
275 #endif
276  // double-buffering: setup the buffer if it does not exist
277  if (!pFrameData->mbInBufferedPaint && m_pWindow->SupportsDoubleBuffering())
279 
280  // double-buffering: if this window does not support double-buffering,
281  // but we are in the middle of double-buffered paint, we might be
282  // losing information
283  if (pFrameData->mbInBufferedPaint && !m_pWindow->SupportsDoubleBuffering())
284  SAL_WARN("vcl.window", "non-double buffered window in the double-buffered hierarchy, painting directly: " << typeid(*m_pWindow.get()).name());
285 
287  {
288  // double-buffering
289  PaintBufferGuard g(pFrameData, m_pWindow);
290  m_pWindow->ApplySettings(*pFrameData->mpBuffer.get());
291 
292  m_pWindow->PushPaintHelper(this, *pFrameData->mpBuffer.get());
293  m_pWindow->Paint(*pFrameData->mpBuffer.get(), m_aPaintRect);
294  pFrameData->maBufferedRect.Union(m_aPaintRect);
295  }
296  else
297  {
298  // direct painting
299  Wallpaper aBackground = m_pWindow->GetBackground();
301  // Restore lost bitmap background.
302  if (aBackground.IsBitmap())
303  m_pWindow->SetBackground(aBackground);
306  }
307 #if HAVE_FEATURE_OPENGL
308  VCL_GL_INFO("PaintHelper::DoPaint end on " <<
309  typeid( *m_pWindow ).name() << " '" << m_pWindow->GetText() << "'");
310 #endif
311  }
312 }
313 
314 namespace vcl
315 {
316 
318  const tools::Rectangle& rRect, sal_uInt16 nHighlight,
319  bool bChecked, bool bDrawBorder, bool bDrawExtBorderOnly,
320  Color* pSelectionTextColor, long nCornerRadius, Color const * pPaintColor)
321 {
322  if (rRect.IsEmpty())
323  return;
324 
325  bool bRoundEdges = nCornerRadius > 0;
326 
327  const StyleSettings& rStyles = rRenderContext.GetSettings().GetStyleSettings();
328 
329  // colors used for item highlighting
330  Color aSelectionBorderColor(pPaintColor ? *pPaintColor : rStyles.GetHighlightColor());
331  Color aSelectionFillColor(aSelectionBorderColor);
332 
333  bool bDark = rStyles.GetFaceColor().IsDark();
334  bool bBright = ( rStyles.GetFaceColor() == COL_WHITE );
335 
336  int c1 = aSelectionBorderColor.GetLuminance();
337  int c2 = rWindow.GetBackgroundColor().GetLuminance();
338 
339  if (!bDark && !bBright && std::abs(c2 - c1) < (pPaintColor ? 40 : 75))
340  {
341  // contrast too low
342  sal_uInt16 h, s, b;
343  aSelectionFillColor.RGBtoHSB( h, s, b );
344  if( b > 50 ) b -= 40;
345  else b += 40;
346  aSelectionFillColor = Color::HSBtoRGB( h, s, b );
347  aSelectionBorderColor = aSelectionFillColor;
348  }
349 
350  if (bRoundEdges)
351  {
352  if (aSelectionBorderColor.IsDark())
353  aSelectionBorderColor.IncreaseLuminance(128);
354  else
355  aSelectionBorderColor.DecreaseLuminance(128);
356  }
357 
358  tools::Rectangle aRect(rRect);
359  if (bDrawExtBorderOnly)
360  {
361  aRect.AdjustLeft( -1 );
362  aRect.AdjustTop( -1 );
363  aRect.AdjustRight(1 );
364  aRect.AdjustBottom(1 );
365  }
367 
368  if (bDrawBorder)
369  rRenderContext.SetLineColor(bDark ? COL_WHITE : (bBright ? COL_BLACK : aSelectionBorderColor));
370  else
371  rRenderContext.SetLineColor();
372 
373  sal_uInt16 nPercent = 0;
374  if (!nHighlight)
375  {
376  if (bDark)
377  aSelectionFillColor = COL_BLACK;
378  else
379  nPercent = 80; // just checked (light)
380  }
381  else
382  {
383  if (bChecked && nHighlight == 2)
384  {
385  if (bDark)
386  aSelectionFillColor = COL_LIGHTGRAY;
387  else if (bBright)
388  {
389  aSelectionFillColor = COL_BLACK;
390  rRenderContext.SetLineColor(COL_BLACK);
391  nPercent = 0;
392  }
393  else
394  nPercent = bRoundEdges ? 40 : 20; // selected, pressed or checked ( very dark )
395  }
396  else if (bChecked || nHighlight == 1)
397  {
398  if (bDark)
399  aSelectionFillColor = COL_GRAY;
400  else if (bBright)
401  {
402  aSelectionFillColor = COL_BLACK;
403  rRenderContext.SetLineColor(COL_BLACK);
404  nPercent = 0;
405  }
406  else
407  nPercent = bRoundEdges ? 60 : 35; // selected, pressed or checked ( very dark )
408  }
409  else
410  {
411  if (bDark)
412  aSelectionFillColor = COL_LIGHTGRAY;
413  else if (bBright)
414  {
415  aSelectionFillColor = COL_BLACK;
416  rRenderContext.SetLineColor(COL_BLACK);
417  if (nHighlight == 3)
418  nPercent = 80;
419  else
420  nPercent = 0;
421  }
422  else
423  nPercent = 70; // selected ( dark )
424  }
425  }
426 
427  if (bDark && bDrawExtBorderOnly)
428  {
429  rRenderContext.SetFillColor();
430  if (pSelectionTextColor)
431  *pSelectionTextColor = rStyles.GetHighlightTextColor();
432  }
433  else
434  {
435  rRenderContext.SetFillColor(aSelectionFillColor);
436  if (pSelectionTextColor)
437  {
438  Color aTextColor = rWindow.IsControlBackground() ? rWindow.GetControlForeground() : rStyles.GetButtonTextColor();
439  Color aHLTextColor = rStyles.GetHighlightTextColor();
440  int nTextDiff = std::abs(aSelectionFillColor.GetLuminance() - aTextColor.GetLuminance());
441  int nHLDiff = std::abs(aSelectionFillColor.GetLuminance() - aHLTextColor.GetLuminance());
442  *pSelectionTextColor = (nHLDiff >= nTextDiff) ? aHLTextColor : aTextColor;
443  }
444  }
445 
446  if (bDark)
447  {
448  rRenderContext.DrawRect(aRect);
449  }
450  else
451  {
452  if (bRoundEdges)
453  {
454  tools::Polygon aPoly(aRect, nCornerRadius, nCornerRadius);
455  tools::PolyPolygon aPolyPoly(aPoly);
456  rRenderContext.DrawTransparent(aPolyPoly, nPercent);
457  }
458  else
459  {
460  tools::Polygon aPoly(aRect);
461  tools::PolyPolygon aPolyPoly(aPoly);
462  rRenderContext.DrawTransparent(aPolyPoly, nPercent);
463  }
464  }
465 
466  rRenderContext.Pop(); // LINECOLOR | FILLCOLOR
467 }
468 
470 {
471  pHelper->SetPop();
472 
473  if ( mpWindowImpl->mpCursor )
474  pHelper->SetRestoreCursor(mpWindowImpl->mpCursor->ImplSuspend());
475 
476  mbInitClipRegion = true;
477  mpWindowImpl->mbInPaint = true;
478 
479  // restore Paint-Region
480  vcl::Region &rPaintRegion = pHelper->GetPaintRegion();
481  rPaintRegion = mpWindowImpl->maInvalidateRegion;
482  tools::Rectangle aPaintRect = rPaintRegion.GetBoundRect();
483 
484  // RTL: re-mirror paint rect and region at this window
485  if (ImplIsAntiparallel())
486  {
487  rRenderContext.ReMirror(aPaintRect);
488  rRenderContext.ReMirror(rPaintRegion);
489  }
490  aPaintRect = ImplDevicePixelToLogic(aPaintRect);
491  mpWindowImpl->mpPaintRegion = &rPaintRegion;
492  mpWindowImpl->maInvalidateRegion.SetEmpty();
493 
494  if ((pHelper->GetPaintFlags() & ImplPaintFlags::Erase) && rRenderContext.IsBackground())
495  {
496  if (rRenderContext.IsClipRegion())
497  {
498  vcl::Region aOldRegion = rRenderContext.GetClipRegion();
499  rRenderContext.SetClipRegion();
500  Erase(rRenderContext);
501  rRenderContext.SetClipRegion(aOldRegion);
502  }
503  else
504  Erase(rRenderContext);
505  }
506 
507  // #98943# trigger drawing of toolbox selection after all children are painted
508  if (mpWindowImpl->mbDrawSelectionBackground)
509  pHelper->SetSelectionRect(aPaintRect);
510  pHelper->SetPaintRect(aPaintRect);
511 }
512 
514 {
515  if (mpWindowImpl->mpWinData)
516  {
517  if (mpWindowImpl->mbFocusVisible)
518  ImplInvertFocus(*mpWindowImpl->mpWinData->mpFocusRect);
519  }
520  mpWindowImpl->mbInPaint = false;
521  mbInitClipRegion = true;
522  mpWindowImpl->mpPaintRegion = nullptr;
523  if (mpWindowImpl->mpCursor)
524  mpWindowImpl->mpCursor->ImplResume(pHelper->GetRestoreCursor());
525 }
526 
527 } /* namespace vcl */
528 
530 {
531  WindowImpl* pWindowImpl = m_pWindow->ImplGetWindowImpl();
532  if (m_bPop)
533  {
534  m_pWindow->PopPaintHelper(this);
535  }
536 
537  ImplFrameData* pFrameData = m_pWindow->mpWindowImpl->mpFrameData;
539  {
540  // Paint from the bottom child window and frontward.
541  vcl::Window* pTempWindow = pWindowImpl->mpLastChild;
542  while (pTempWindow)
543  {
544  if (pTempWindow->mpWindowImpl->mbVisible)
545  pTempWindow->ImplCallPaint(m_pChildRegion.get(), m_nPaintFlags);
546  pTempWindow = pTempWindow->mpWindowImpl->mpPrev;
547  }
548  }
549 
550  if ( pWindowImpl->mpWinData && pWindowImpl->mbTrackVisible && (pWindowImpl->mpWinData->mnTrackFlags & ShowTrackFlags::TrackWindow) )
551  /* #98602# need to invert the tracking rect AFTER
552  * the children have painted
553  */
554  m_pWindow->InvertTracking( *pWindowImpl->mpWinData->mpTrackRect, pWindowImpl->mpWinData->mnTrackFlags );
555 
556  // double-buffering: paint in case we created the buffer, the children are
557  // already painted inside
558  if (m_bStartedBufferedPaint && pFrameData->mbInBufferedPaint)
559  {
560  PaintBuffer();
561  pFrameData->mbInBufferedPaint = false;
562  pFrameData->maBufferedRect = tools::Rectangle();
563  }
564 
565  // #98943# draw toolbox selection
566  if( !m_aSelectionRect.IsEmpty() )
568 }
569 
570 namespace vcl {
571 
572 void Window::ImplCallPaint(const vcl::Region* pRegion, ImplPaintFlags nPaintFlags)
573 {
574  // call PrePaint. PrePaint may add to the invalidate region as well as
575  // other parameters used below.
576  PrePaint(*this);
577 
578  mpWindowImpl->mbPaintFrame = false;
579 
580  if (nPaintFlags & ImplPaintFlags::PaintAllChildren)
581  mpWindowImpl->mnPaintFlags |= ImplPaintFlags::Paint | ImplPaintFlags::PaintAllChildren | (nPaintFlags & ImplPaintFlags::PaintAll);
582  if (nPaintFlags & ImplPaintFlags::PaintChildren)
584  if (nPaintFlags & ImplPaintFlags::Erase)
585  mpWindowImpl->mnPaintFlags |= ImplPaintFlags::Erase;
586  if (nPaintFlags & ImplPaintFlags::CheckRtl)
587  mpWindowImpl->mnPaintFlags |= ImplPaintFlags::CheckRtl;
588  if (!mpWindowImpl->mpFirstChild)
589  mpWindowImpl->mnPaintFlags &= ~ImplPaintFlags::PaintAllChildren;
590 
591  if (mpWindowImpl->mbPaintDisabled)
592  {
593  if (mpWindowImpl->mnPaintFlags & ImplPaintFlags::PaintAll)
595  else if ( pRegion )
597 
598  // call PostPaint before returning
599  PostPaint(*this);
600 
601  return;
602  }
603 
604  nPaintFlags = mpWindowImpl->mnPaintFlags & ~ImplPaintFlags::Paint;
605 
606  PaintHelper aHelper(this, nPaintFlags);
607 
608  if (mpWindowImpl->mnPaintFlags & ImplPaintFlags::Paint)
609  aHelper.DoPaint(pRegion);
610  else
611  mpWindowImpl->mnPaintFlags = ImplPaintFlags::NONE;
612 
613  // call PostPaint
614  PostPaint(*this);
615 }
616 
618 {
619  // emit overlapping windows first
620  vcl::Window* pTempWindow = mpWindowImpl->mpFirstOverlap;
621  while ( pTempWindow )
622  {
623  if ( pTempWindow->mpWindowImpl->mbReallyVisible )
624  pTempWindow->ImplCallOverlapPaint();
625  pTempWindow = pTempWindow->mpWindowImpl->mpNext;
626  }
627 
628  // only then ourself
630  {
631  // RTL: notify ImplCallPaint to check for re-mirroring
632  // because we were called from the Sal layer
633  ImplCallPaint(nullptr, mpWindowImpl->mnPaintFlags /*| ImplPaintFlags::CheckRtl */);
634  }
635 }
636 
637 IMPL_LINK_NOARG(Window, ImplHandlePaintHdl, Timer *, void)
638 {
639  comphelper::ProfileZone aZone("VCL idle re-paint");
640 
641  // save paint events until layout is done
642  if (IsSystemWindow() && static_cast<const SystemWindow*>(this)->hasPendingLayout())
643  {
644  mpWindowImpl->mpFrameData->maPaintIdle.Start();
645  return;
646  }
647 
648  // save paint events until resizing or initial sizing done
649  if (mpWindowImpl->mbFrame &&
650  mpWindowImpl->mpFrameData->maResizeIdle.IsActive())
651  {
652  mpWindowImpl->mpFrameData->maPaintIdle.Start();
653  }
654  else if ( mpWindowImpl->mbReallyVisible )
655  {
656  ImplCallOverlapPaint();
657  }
658 }
659 
660 IMPL_LINK_NOARG(Window, ImplHandleResizeTimerHdl, Timer *, void)
661 {
662  comphelper::ProfileZone aZone("VCL idle resize");
663 
664  if( mpWindowImpl->mbReallyVisible )
665  {
666  ImplCallResize();
667  if( mpWindowImpl->mpFrameData->maPaintIdle.IsActive() )
668  {
669  mpWindowImpl->mpFrameData->maPaintIdle.Stop();
670  mpWindowImpl->mpFrameData->maPaintIdle.Invoke( nullptr );
671  }
672  }
673 }
674 
676 {
677  // set PAINTCHILDREN for all parent windows till the first OverlapWindow
678  if ( !ImplIsOverlapWindow() )
679  {
680  vcl::Window* pTempWindow = this;
682  do
683  {
684  pTempWindow = pTempWindow->ImplGetParent();
685  if ( pTempWindow->mpWindowImpl->mnPaintFlags & ImplPaintFlags::PaintChildren )
686  break;
687  pTempWindow->mpWindowImpl->mnPaintFlags |= ImplPaintFlags::PaintChildren | nTranspPaint;
688  if( ! pTempWindow->IsPaintTransparent() )
689  nTranspPaint = ImplPaintFlags::NONE;
690  }
691  while ( !pTempWindow->ImplIsOverlapWindow() );
692  }
693 
694  // set Paint-Flags
695  mpWindowImpl->mnPaintFlags |= ImplPaintFlags::Paint;
696  if ( nFlags & InvalidateFlags::Children )
698  if ( !(nFlags & InvalidateFlags::NoErase) )
699  mpWindowImpl->mnPaintFlags |= ImplPaintFlags::Erase;
700 
701  if ( !pRegion )
702  mpWindowImpl->mnPaintFlags |= ImplPaintFlags::PaintAll;
703  else if ( !(mpWindowImpl->mnPaintFlags & ImplPaintFlags::PaintAll) )
704  {
705  // if not everything has to be redrawn, add the region to it
706  mpWindowImpl->maInvalidateRegion.Union( *pRegion );
707  }
708 
709  // Handle transparent windows correctly: invalidate must be done on the first opaque parent
711  && ImplGetParent() )
712  {
713  vcl::Window *pParent = ImplGetParent();
714  while( pParent && pParent->IsPaintTransparent() )
715  pParent = pParent->ImplGetParent();
716  if( pParent )
717  {
718  vcl::Region *pChildRegion;
719  if ( mpWindowImpl->mnPaintFlags & ImplPaintFlags::PaintAll )
720  // invalidate the whole child window region in the parent
721  pChildRegion = ImplGetWinChildClipRegion();
722  else
723  // invalidate the same region in the parent that has to be repainted in the child
724  pChildRegion = &mpWindowImpl->maInvalidateRegion;
725 
726  nFlags |= InvalidateFlags::Children; // paint should also be done on all children
727  nFlags &= ~InvalidateFlags::NoErase; // parent should paint and erase to create proper background
728  pParent->ImplInvalidateFrameRegion( pChildRegion, nFlags );
729  }
730  }
731 
732  if ( !mpWindowImpl->mpFrameData->maPaintIdle.IsActive() )
733  mpWindowImpl->mpFrameData->maPaintIdle.Start();
734 }
735 
737 {
738  vcl::Region aRegion = rRegion;
739 
740  ImplClipBoundaries( aRegion, true, true );
741  if ( !aRegion.IsEmpty() )
743 
744  // now we invalidate the overlapping windows
745  vcl::Window* pTempWindow = mpWindowImpl->mpFirstOverlap;
746  while ( pTempWindow )
747  {
748  if ( pTempWindow->IsVisible() )
749  pTempWindow->ImplInvalidateOverlapFrameRegion( rRegion );
750 
751  pTempWindow = pTempWindow->mpWindowImpl->mpNext;
752  }
753 }
754 
756 {
757  if ( mpWindowImpl->mbOverlapWin )
758  mpWindowImpl->mpFrameWindow->ImplInvalidateOverlapFrameRegion( rRegion );
759  else
760  {
761  if( ImplGetParent() )
763  }
764 }
765 
766 void Window::ImplInvalidate( const vcl::Region* pRegion, InvalidateFlags nFlags )
767 {
768  // check what has to be redrawn
769  bool bInvalidateAll = !pRegion;
770 
771  // take Transparent-Invalidate into account
772  vcl::Window* pOpaqueWindow = this;
773  if ( (mpWindowImpl->mbPaintTransparent && !(nFlags & InvalidateFlags::NoTransparent)) || (nFlags & InvalidateFlags::Transparent) )
774  {
775  vcl::Window* pTempWindow = pOpaqueWindow->ImplGetParent();
776  while ( pTempWindow )
777  {
778  if ( !pTempWindow->IsPaintTransparent() )
779  {
780  pOpaqueWindow = pTempWindow;
781  nFlags |= InvalidateFlags::Children;
782  bInvalidateAll = false;
783  break;
784  }
785 
786  if ( pTempWindow->ImplIsOverlapWindow() )
787  break;
788 
789  pTempWindow = pTempWindow->ImplGetParent();
790  }
791  }
792 
793  // assemble region
794  InvalidateFlags nOrgFlags = nFlags;
796  {
797  if ( GetStyle() & WB_CLIPCHILDREN )
798  nFlags |= InvalidateFlags::NoChildren;
799  else
800  nFlags |= InvalidateFlags::Children;
801  }
802  if ( (nFlags & InvalidateFlags::NoChildren) && mpWindowImpl->mpFirstChild )
803  bInvalidateAll = false;
804  if ( bInvalidateAll )
805  ImplInvalidateFrameRegion( nullptr, nFlags );
806  else
807  {
809  vcl::Region aRegion( aRect );
810  if ( pRegion )
811  {
812  // RTL: remirror region before intersecting it
813  if ( ImplIsAntiparallel() )
814  {
815  const OutputDevice *pOutDev = GetOutDev();
816 
817  vcl::Region aRgn( *pRegion );
818  pOutDev->ReMirror( aRgn );
819  aRegion.Intersect( aRgn );
820  }
821  else
822  aRegion.Intersect( *pRegion );
823  }
824  ImplClipBoundaries( aRegion, true, true );
825  if ( nFlags & InvalidateFlags::NoChildren )
826  {
827  nFlags &= ~InvalidateFlags::Children;
828  if ( !(nFlags & InvalidateFlags::NoClipChildren) )
829  {
830  if ( nOrgFlags & InvalidateFlags::NoChildren )
831  ImplClipAllChildren( aRegion );
832  else
833  {
834  if ( ImplClipChildren( aRegion ) )
835  nFlags |= InvalidateFlags::Children;
836  }
837  }
838  }
839  if ( !aRegion.IsEmpty() )
840  ImplInvalidateFrameRegion( &aRegion, nFlags ); // transparency is handled here, pOpaqueWindow not required
841  }
842 
843  if ( nFlags & InvalidateFlags::Update )
844  pOpaqueWindow->Update(); // start painting at the opaque parent
845 }
846 
848  long nHorzScroll, long nVertScroll,
849  bool bChildren )
850 {
852  {
853  vcl::Region aTempRegion = mpWindowImpl->maInvalidateRegion;
854  aTempRegion.Intersect( rRect );
855  aTempRegion.Move( nHorzScroll, nVertScroll );
856  mpWindowImpl->maInvalidateRegion.Union( aTempRegion );
857  }
858 
859  if ( bChildren && (mpWindowImpl->mnPaintFlags & ImplPaintFlags::PaintChildren) )
860  {
861  vcl::Window* pWindow = mpWindowImpl->mpFirstChild;
862  while ( pWindow )
863  {
864  pWindow->ImplMoveInvalidateRegion( rRect, nHorzScroll, nVertScroll, true );
865  pWindow = pWindow->mpWindowImpl->mpNext;
866  }
867  }
868 }
869 
871  long nHorzScroll, long nVertScroll,
872  bool bChildren )
873 {
874  // also shift Paint-Region when paints need processing
875  ImplMoveInvalidateRegion( rRect, nHorzScroll, nVertScroll, bChildren );
876  // Paint-Region should be shifted, as drawn by the parents
877  if ( !ImplIsOverlapWindow() )
878  {
879  vcl::Region aPaintAllRegion;
880  vcl::Window* pPaintAllWindow = this;
881  do
882  {
883  pPaintAllWindow = pPaintAllWindow->ImplGetParent();
884  if ( pPaintAllWindow->mpWindowImpl->mnPaintFlags & ImplPaintFlags::PaintAllChildren )
885  {
886  if ( pPaintAllWindow->mpWindowImpl->mnPaintFlags & ImplPaintFlags::PaintAll )
887  {
888  aPaintAllRegion.SetEmpty();
889  break;
890  }
891  else
892  aPaintAllRegion.Union( pPaintAllWindow->mpWindowImpl->maInvalidateRegion );
893  }
894  }
895  while ( !pPaintAllWindow->ImplIsOverlapWindow() );
896  if ( !aPaintAllRegion.IsEmpty() )
897  {
898  aPaintAllRegion.Move( nHorzScroll, nVertScroll );
900  if ( bChildren )
901  nPaintFlags |= InvalidateFlags::Children;
902  ImplInvalidateFrameRegion( &aPaintAllRegion, nPaintFlags );
903  }
904  }
905 }
906 
908 {
909  if ( !pRegion )
910  mpWindowImpl->maInvalidateRegion.SetEmpty();
911  else
912  {
913  // when all child windows have to be drawn we need to invalidate them before doing so
914  if ( (mpWindowImpl->mnPaintFlags & ImplPaintFlags::PaintAllChildren) && mpWindowImpl->mpFirstChild )
915  {
916  vcl::Region aChildRegion = mpWindowImpl->maInvalidateRegion;
917  if ( mpWindowImpl->mnPaintFlags & ImplPaintFlags::PaintAll )
918  {
920  aChildRegion = aRect;
921  }
922  vcl::Window* pChild = mpWindowImpl->mpFirstChild;
923  while ( pChild )
924  {
926  pChild = pChild->mpWindowImpl->mpNext;
927  }
928  }
929  if ( mpWindowImpl->mnPaintFlags & ImplPaintFlags::PaintAll )
930  {
932  mpWindowImpl->maInvalidateRegion = aRect;
933  }
934  mpWindowImpl->maInvalidateRegion.Exclude( *pRegion );
935  }
936  mpWindowImpl->mnPaintFlags &= ~ImplPaintFlags::PaintAll;
937 
938  if ( nFlags & ValidateFlags::Children )
939  {
940  vcl::Window* pChild = mpWindowImpl->mpFirstChild;
941  while ( pChild )
942  {
943  pChild->ImplValidateFrameRegion( pRegion, nFlags );
944  pChild = pChild->mpWindowImpl->mpNext;
945  }
946  }
947 }
948 
950 {
951  // assemble region
952  bool bValidateAll = true;
954  if ( GetStyle() & WB_CLIPCHILDREN )
955  nFlags |= ValidateFlags::NoChildren;
956  else
957  nFlags |= ValidateFlags::Children;
958  if ( (nFlags & ValidateFlags::NoChildren) && mpWindowImpl->mpFirstChild )
959  bValidateAll = false;
960  if ( bValidateAll )
961  ImplValidateFrameRegion( nullptr, nFlags );
962  else
963  {
965  vcl::Region aRegion( aRect );
966  ImplClipBoundaries( aRegion, true, true );
967  if ( nFlags & ValidateFlags::NoChildren )
968  {
969  nFlags &= ~ValidateFlags::Children;
970  if ( ImplClipChildren( aRegion ) )
971  nFlags |= ValidateFlags::Children;
972  }
973  if ( !aRegion.IsEmpty() )
974  ImplValidateFrameRegion( &aRegion, nFlags );
975  }
976 }
977 
979 {
980  if ( !mpWindowImpl->mbReallyVisible )
981  return;
982 
983  bool bFlush = false;
984  if ( mpWindowImpl->mpFrameWindow->mpWindowImpl->mbPaintFrame )
985  {
986  Point aPoint( 0, 0 );
987  vcl::Region aRegion( tools::Rectangle( aPoint, Size( mnOutWidth, mnOutHeight ) ) );
989  if ( mpWindowImpl->mbFrame || (mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame) )
990  bFlush = true;
991  }
992 
993  // an update changes the OverlapWindow, such that for later paints
994  // not too much has to be drawn, if ALLCHILDREN etc. is set
996  pWindow->ImplCallOverlapPaint();
997 
998  if ( bFlush )
999  Flush();
1000 }
1001 
1002 void Window::PrePaint(vcl::RenderContext& /*rRenderContext*/)
1003 {
1004 }
1005 
1006 void Window::PostPaint(vcl::RenderContext& /*rRenderContext*/)
1007 {
1008 }
1009 
1010 void Window::Paint(vcl::RenderContext& /*rRenderContext*/, const tools::Rectangle& rRect)
1011 {
1012  CallEventListeners(VclEventId::WindowPaint, const_cast<tools::Rectangle *>(&rRect));
1013 }
1014 
1015 void Window::SetPaintTransparent( bool bTransparent )
1016 {
1017  // transparency is not useful for frames as the background would have to be provided by a different frame
1018  if( bTransparent && mpWindowImpl->mbFrame )
1019  return;
1020 
1021  if ( mpWindowImpl->mpBorderWindow )
1022  mpWindowImpl->mpBorderWindow->SetPaintTransparent( bTransparent );
1023 
1024  mpWindowImpl->mbPaintTransparent = bTransparent;
1025 }
1026 
1028 {
1029 
1030  if ( mpWindowImpl->mpBorderWindow )
1031  mpWindowImpl->mpBorderWindow->SetWindowRegionPixel();
1032  else if( mpWindowImpl->mbFrame )
1033  {
1034  mpWindowImpl->maWinRegion = vcl::Region(true);
1035  mpWindowImpl->mbWinRegion = false;
1036  mpWindowImpl->mpFrame->ResetClipRegion();
1037  }
1038  else
1039  {
1040  if ( mpWindowImpl->mbWinRegion )
1041  {
1042  mpWindowImpl->maWinRegion = vcl::Region(true);
1043  mpWindowImpl->mbWinRegion = false;
1044  ImplSetClipFlag();
1045 
1046  if ( IsReallyVisible() )
1047  {
1049  vcl::Region aRegion( aRect );
1051  }
1052  }
1053  }
1054 }
1055 
1057 {
1058 
1059  if ( mpWindowImpl->mpBorderWindow )
1060  mpWindowImpl->mpBorderWindow->SetWindowRegionPixel( rRegion );
1061  else if( mpWindowImpl->mbFrame )
1062  {
1063  if( !rRegion.IsNull() )
1064  {
1065  mpWindowImpl->maWinRegion = rRegion;
1066  mpWindowImpl->mbWinRegion = ! rRegion.IsEmpty();
1067 
1068  if( mpWindowImpl->mbWinRegion )
1069  {
1070  // set/update ClipRegion
1071  RectangleVector aRectangles;
1072  mpWindowImpl->maWinRegion.GetRegionRectangles(aRectangles);
1073  mpWindowImpl->mpFrame->BeginSetClipRegion(aRectangles.size());
1074 
1075  for (auto const& rectangle : aRectangles)
1076  {
1077  mpWindowImpl->mpFrame->UnionClipRegion(
1078  rectangle.Left(),
1079  rectangle.Top(),
1080  rectangle.GetWidth(), // orig nWidth was ((R - L) + 1), same as GetWidth does
1081  rectangle.GetHeight()); // same for height
1082  }
1083 
1084  mpWindowImpl->mpFrame->EndSetClipRegion();
1085 
1086  //long nX;
1087  //long nY;
1088  //long nWidth;
1089  //long nHeight;
1090  //sal_uLong nRectCount;
1091  //ImplRegionInfo aInfo;
1092  //sal_Bool bRegionRect;
1093 
1094  //nRectCount = mpWindowImpl->maWinRegion.GetRectCount();
1095  //mpWindowImpl->mpFrame->BeginSetClipRegion( nRectCount );
1096  //bRegionRect = mpWindowImpl->maWinRegion.ImplGetFirstRect( aInfo, nX, nY, nWidth, nHeight );
1097  //while ( bRegionRect )
1098  //{
1099  // mpWindowImpl->mpFrame->UnionClipRegion( nX, nY, nWidth, nHeight );
1100  // bRegionRect = mpWindowImpl->maWinRegion.ImplGetNextRect( aInfo, nX, nY, nWidth, nHeight );
1101  //}
1102  //mpWindowImpl->mpFrame->EndSetClipRegion();
1103  }
1104  else
1106  }
1107  else
1109  }
1110  else
1111  {
1112  if ( rRegion.IsNull() )
1113  {
1114  if ( mpWindowImpl->mbWinRegion )
1115  {
1116  mpWindowImpl->maWinRegion = vcl::Region(true);
1117  mpWindowImpl->mbWinRegion = false;
1118  ImplSetClipFlag();
1119  }
1120  }
1121  else
1122  {
1123  mpWindowImpl->maWinRegion = rRegion;
1124  mpWindowImpl->mbWinRegion = true;
1125  ImplSetClipFlag();
1126  }
1127 
1128  if ( IsReallyVisible() )
1129  {
1131  vcl::Region aRegion( aRect );
1133  }
1134  }
1135 }
1136 
1138 {
1139 
1140  if ( mpWindowImpl->mpPaintRegion )
1141  {
1142  vcl::Region aRegion = *mpWindowImpl->mpPaintRegion;
1143  aRegion.Move( -mnOutOffX, -mnOutOffY );
1144  return PixelToLogic( aRegion );
1145  }
1146  else
1147  {
1148  vcl::Region aPaintRegion(true);
1149  return aPaintRegion;
1150  }
1151 }
1152 
1154 {
1156  return;
1157 
1158  ImplInvalidate( nullptr, nFlags );
1159  LogicInvalidate(nullptr);
1160 }
1161 
1163 {
1165  return;
1166 
1167  OutputDevice *pOutDev = GetOutDev();
1168  tools::Rectangle aRect = pOutDev->ImplLogicToDevicePixel( rRect );
1169  if ( !aRect.IsEmpty() )
1170  {
1171  vcl::Region aRegion( aRect );
1172  ImplInvalidate( &aRegion, nFlags );
1173  tools::Rectangle aLogicRectangle(rRect);
1174  LogicInvalidate(&aLogicRectangle);
1175  }
1176 }
1177 
1178 void Window::Invalidate( const vcl::Region& rRegion, InvalidateFlags nFlags )
1179 {
1181  return;
1182 
1183  if ( rRegion.IsNull() )
1184  {
1185  ImplInvalidate( nullptr, nFlags );
1186  LogicInvalidate(nullptr);
1187  }
1188  else
1189  {
1190  vcl::Region aRegion = ImplPixelToDevicePixel( LogicToPixel( rRegion ) );
1191  if ( !aRegion.IsEmpty() )
1192  {
1193  ImplInvalidate( &aRegion, nFlags );
1194  tools::Rectangle aLogicRectangle = rRegion.GetBoundRect();
1195  LogicInvalidate(&aLogicRectangle);
1196  }
1197  }
1198 }
1199 
1201 {
1202  if(pRectangle)
1203  {
1204  tools::Rectangle aRect = GetOutDev()->ImplLogicToDevicePixel( *pRectangle );
1205  PixelInvalidate(&aRect);
1206  }
1207  else
1208  PixelInvalidate(nullptr);
1209 }
1210 
1212 {
1214  return;
1215 
1216  if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
1217  {
1218  // In case we are routing the window, notify the client
1219  std::vector<vcl::LOKPayloadItem> aPayload;
1220  if (pRectangle)
1221  aPayload.push_back(std::make_pair(OString("rectangle"), pRectangle->toString()));
1222  else
1223  {
1224  const tools::Rectangle aRect(Point(0, 0), GetSizePixel());
1225  aPayload.push_back(std::make_pair(OString("rectangle"), aRect.toString()));
1226  }
1227 
1228  pNotifier->notifyWindow(GetLOKWindowId(), "invalidate", aPayload);
1229  }
1230  // Added for dialog items. Pass invalidation to the parent window.
1231  else if (VclPtr<vcl::Window> pParent = GetParentWithLOKNotifier())
1232  {
1234  pParent->PixelInvalidate(&aRect);
1235  }
1236 }
1237 
1239 {
1241  return;
1242 
1243  ImplValidate();
1244 }
1245 
1247 {
1248 
1249  if ( !mpWindowImpl->mbReallyVisible )
1250  return false;
1251 
1252  if ( mpWindowImpl->mpFrameWindow->mpWindowImpl->mbPaintFrame )
1253  return true;
1254 
1255  if ( mpWindowImpl->mnPaintFlags & ImplPaintFlags::Paint )
1256  return true;
1257 
1258  if ( !ImplIsOverlapWindow() )
1259  {
1260  const vcl::Window* pTempWindow = this;
1261  do
1262  {
1263  pTempWindow = pTempWindow->ImplGetParent();
1264  if ( pTempWindow->mpWindowImpl->mnPaintFlags & (ImplPaintFlags::PaintChildren | ImplPaintFlags::PaintAllChildren) )
1265  return true;
1266  }
1267  while ( !pTempWindow->ImplIsOverlapWindow() );
1268  }
1269 
1270  return false;
1271 }
1272 
1274 {
1275  if ( mpWindowImpl->mpBorderWindow )
1276  {
1277  mpWindowImpl->mpBorderWindow->Update();
1278  return;
1279  }
1280 
1281  if ( !mpWindowImpl->mbReallyVisible )
1282  return;
1283 
1284  bool bFlush = false;
1285  if ( mpWindowImpl->mpFrameWindow->mpWindowImpl->mbPaintFrame )
1286  {
1287  Point aPoint( 0, 0 );
1288  vcl::Region aRegion( tools::Rectangle( aPoint, Size( mnOutWidth, mnOutHeight ) ) );
1290  if ( mpWindowImpl->mbFrame || (mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame) )
1291  bFlush = true;
1292  }
1293 
1294  // First we should skip all windows which are Paint-Transparent
1295  vcl::Window* pUpdateWindow = this;
1296  vcl::Window* pWindow = pUpdateWindow;
1297  while ( !pWindow->ImplIsOverlapWindow() )
1298  {
1299  if ( !pWindow->mpWindowImpl->mbPaintTransparent )
1300  {
1301  pUpdateWindow = pWindow;
1302  break;
1303  }
1304  pWindow = pWindow->ImplGetParent();
1305  }
1306  // In order to limit drawing, an update only draws the window which
1307  // has PAINTALLCHILDREN set
1308  pWindow = pUpdateWindow;
1309  do
1310  {
1311  if ( pWindow->mpWindowImpl->mnPaintFlags & ImplPaintFlags::PaintAllChildren )
1312  pUpdateWindow = pWindow;
1313  if ( pWindow->ImplIsOverlapWindow() )
1314  break;
1315  pWindow = pWindow->ImplGetParent();
1316  }
1317  while ( pWindow );
1318 
1319  // if there is something to paint, trigger a Paint
1320  if ( pUpdateWindow->mpWindowImpl->mnPaintFlags & (ImplPaintFlags::Paint | ImplPaintFlags::PaintChildren) )
1321  {
1322  VclPtr<vcl::Window> xWindow(this);
1323 
1324  // trigger an update also for system windows on top of us,
1325  // otherwise holes would remain
1326  vcl::Window* pUpdateOverlapWindow = ImplGetFirstOverlapWindow()->mpWindowImpl->mpFirstOverlap;
1327  while ( pUpdateOverlapWindow )
1328  {
1329  pUpdateOverlapWindow->Update();
1330  pUpdateOverlapWindow = pUpdateOverlapWindow->mpWindowImpl->mpNext;
1331  }
1332 
1333  pUpdateWindow->ImplCallPaint(nullptr, pUpdateWindow->mpWindowImpl->mnPaintFlags);
1334 
1335  if (comphelper::LibreOfficeKit::isActive() && pUpdateWindow->GetParentDialog())
1336  pUpdateWindow->LogicInvalidate(nullptr);
1337 
1338  if (xWindow->IsDisposed())
1339  return;
1340 
1341  bFlush = true;
1342  }
1343 
1344  if ( bFlush )
1345  Flush();
1346 }
1347 
1348 void Window::ImplPaintToDevice( OutputDevice* i_pTargetOutDev, const Point& i_rPos )
1349 {
1350  // Special drawing when called through LOKit
1351  // TODO: Move to its own method
1353  {
1354  VclPtrInstance<VirtualDevice> pDevice(*i_pTargetOutDev);
1355 
1356  Size aSize(GetOutputSizePixel());
1357  pDevice->SetOutputSizePixel(aSize);
1358 
1359  vcl::Font aCopyFont = GetFont();
1360  pDevice->SetFont(aCopyFont);
1361 
1362  pDevice->SetTextColor(GetTextColor());
1363  if (IsLineColor())
1364  pDevice->SetLineColor(GetLineColor());
1365  else
1366  pDevice->SetLineColor();
1367 
1368  if (IsFillColor())
1369  pDevice->SetFillColor(GetFillColor());
1370  else
1371  pDevice->SetFillColor();
1372 
1373  if (IsTextLineColor())
1374  pDevice->SetTextLineColor(GetTextLineColor());
1375  else
1376  pDevice->SetTextLineColor();
1377 
1378  if (IsOverlineColor())
1379  pDevice->SetOverlineColor(GetOverlineColor());
1380  else
1381  pDevice->SetOverlineColor();
1382 
1383  if (IsTextFillColor())
1384  pDevice->SetTextFillColor(GetTextFillColor());
1385  else
1386  pDevice->SetTextFillColor();
1387 
1388  pDevice->SetTextAlign(GetTextAlign());
1389  pDevice->SetRasterOp(GetRasterOp());
1390 
1391  tools::Rectangle aPaintRect(Point(), GetOutputSizePixel());
1392 
1393  vcl::Region aClipRegion(GetClipRegion());
1394  pDevice->SetClipRegion();
1395  aClipRegion.Intersect(aPaintRect);
1396  pDevice->SetClipRegion(aClipRegion);
1397 
1399  Erase(*pDevice);
1400 
1401  pDevice->SetMapMode(GetMapMode());
1402 
1404 
1405  i_pTargetOutDev->DrawOutDev(i_rPos, aSize, Point(), pDevice->PixelToLogic(aSize), *pDevice);
1406 
1407  // get rid of virtual device now so they don't pile up during recursive calls
1408  pDevice.disposeAndClear();
1409 
1410 
1411  for( vcl::Window* pChild = mpWindowImpl->mpFirstChild; pChild; pChild = pChild->mpWindowImpl->mpNext )
1412  {
1413  if( pChild->mpWindowImpl->mpFrame == mpWindowImpl->mpFrame && pChild->IsVisible() )
1414  {
1415  long nDeltaX = pChild->mnOutOffX - mnOutOffX;
1416  long nDeltaY = pChild->mnOutOffY - mnOutOffY;
1417 
1418  Point aPos( i_rPos );
1419  aPos += Point(nDeltaX, nDeltaY);
1420 
1421  pChild->ImplPaintToDevice( i_pTargetOutDev, aPos );
1422  }
1423  }
1424  return;
1425  }
1426 
1427 
1428  bool bRVisible = mpWindowImpl->mbReallyVisible;
1429  mpWindowImpl->mbReallyVisible = mpWindowImpl->mbVisible;
1430  bool bDevOutput = mbDevOutput;
1431  mbDevOutput = true;
1432 
1433  const OutputDevice *pOutDev = GetOutDev();
1434  long nOldDPIX = pOutDev->GetDPIX();
1435  long nOldDPIY = pOutDev->GetDPIY();
1436  mnDPIX = i_pTargetOutDev->GetDPIX();
1437  mnDPIY = i_pTargetOutDev->GetDPIY();
1438  bool bOutput = IsOutputEnabled();
1439  EnableOutput();
1440 
1441  double fScaleX = 1;
1442  double fScaleY = 1;
1443  bool bNeedsScaling = false;
1445  {
1446  if(GetMapMode().GetMapUnit() != MapUnit::MapPixel &&
1447  // Some of the preview windows (SvxPreviewBase) uses different painting (drawinglayer primitives)
1448  // For these preview we don't need to scale even though the unit is not pixel.
1449  GetMapMode().GetMapUnit() != MapUnit::Map100thMM)
1450  {
1451  bNeedsScaling = true;
1452  // 1000.0 is used to reduce rounding imprecision (Size uses integers)
1453  Size aLogicSize = PixelToLogic(Size(1000.0, 1000.0));
1454  fScaleX = aLogicSize.Width() / 1000.0;
1455  fScaleY = aLogicSize.Height() / 1000.0;
1456  }
1457  }
1458  else
1459  { // TODO: Above scaling was added for LOK only, would be good to check how it works in other use cases
1460  SAL_WARN_IF( GetMapMode().GetMapUnit() != MapUnit::MapPixel, "vcl.window", "MapMode must be PIXEL based" );
1461  if ( GetMapMode().GetMapUnit() != MapUnit::MapPixel )
1462  return;
1463  }
1464 
1465  // preserve graphicsstate
1466  Push();
1467  vcl::Region aClipRegion( GetClipRegion() );
1468  SetClipRegion();
1469 
1470  GDIMetaFile* pOldMtf = GetConnectMetaFile();
1471  GDIMetaFile aMtf;
1472  SetConnectMetaFile( &aMtf );
1473 
1474  // put a push action to metafile
1475  Push();
1476  // copy graphics state to metafile
1477  vcl::Font aCopyFont = GetFont();
1478  if( nOldDPIX != mnDPIX || nOldDPIY != mnDPIY )
1479  {
1480  aCopyFont.SetFontHeight( aCopyFont.GetFontHeight() * mnDPIY / nOldDPIY );
1481  aCopyFont.SetAverageFontWidth( aCopyFont.GetAverageFontWidth() * mnDPIX / nOldDPIX );
1482  }
1483  SetFont( aCopyFont );
1485  if( IsLineColor() )
1487  else
1488  SetLineColor();
1489  if( IsFillColor() )
1491  else
1492  SetFillColor();
1493  if( IsTextLineColor() )
1495  else
1496  SetTextLineColor();
1497  if( IsOverlineColor() )
1499  else
1500  SetOverlineColor();
1501  if( IsTextFillColor() )
1503  else
1504  SetTextFillColor();
1506  SetRasterOp( GetRasterOp() );
1507  if( IsRefPoint() )
1508  SetRefPoint( GetRefPoint() );
1509  else
1510  SetRefPoint();
1513 
1514  tools::Rectangle aPaintRect;
1515  if(bNeedsScaling)
1516  {
1517  aPaintRect = tools::Rectangle( Point( 0, 0 ),
1518  Size(GetOutputSizePixel().Width() * fScaleX, GetOutputSizePixel().Height() * fScaleY) );
1519  }
1520  else
1521  {
1522  aPaintRect = tools::Rectangle( Point( 0, 0 ), GetOutputSizePixel() );
1523  }
1524  aClipRegion.Intersect( aPaintRect );
1525  SetClipRegion( aClipRegion );
1526 
1527  // do the actual paint
1528 
1529  // background
1531  {
1532  Erase(*this);
1533  if(bNeedsScaling)
1534  aMtf.Scale(fScaleX, fScaleY);
1535  }
1536  // foreground
1537  Paint(*this, aPaintRect);
1538  // put a pop action to metafile
1539  Pop();
1540 
1541  SetConnectMetaFile( pOldMtf );
1542  EnableOutput( bOutput );
1543  mpWindowImpl->mbReallyVisible = bRVisible;
1544 
1545  // paint metafile to VDev
1546  VclPtrInstance<VirtualDevice> pMaskedDevice(*i_pTargetOutDev,
1549 
1550  if(bNeedsScaling)
1551  pMaskedDevice->SetMapMode( GetMapMode() );
1552  pMaskedDevice->SetOutputSizePixel( GetOutputSizePixel() );
1553  pMaskedDevice->EnableRTL( IsRTLEnabled() );
1554  aMtf.WindStart();
1555  aMtf.Play( pMaskedDevice );
1556  BitmapEx aBmpEx( pMaskedDevice->GetBitmapEx( Point( 0, 0 ), aPaintRect.GetSize() ) );
1557  i_pTargetOutDev->DrawBitmapEx( i_rPos, aBmpEx );
1558  // get rid of virtual device now so they don't pile up during recursive calls
1559  pMaskedDevice.disposeAndClear();
1560 
1561  for( vcl::Window* pChild = mpWindowImpl->mpFirstChild; pChild; pChild = pChild->mpWindowImpl->mpNext )
1562  {
1563  if( pChild->mpWindowImpl->mpFrame == mpWindowImpl->mpFrame && pChild->IsVisible() )
1564  {
1565  long nDeltaX = pChild->mnOutOffX - mnOutOffX;
1566 
1567  if( pOutDev->HasMirroredGraphics() )
1568  nDeltaX = mnOutWidth - nDeltaX - pChild->mnOutWidth;
1569  long nDeltaY = pChild->GetOutOffYPixel() - GetOutOffYPixel();
1570  Point aPos( i_rPos );
1571  Point aDelta( nDeltaX, nDeltaY );
1572  aPos += aDelta;
1573  pChild->ImplPaintToDevice( i_pTargetOutDev, aPos );
1574  }
1575  }
1576 
1577  // restore graphics state
1578  Pop();
1579 
1580  EnableOutput( bOutput );
1581  mpWindowImpl->mbReallyVisible = bRVisible;
1582  mbDevOutput = bDevOutput;
1583  mnDPIX = nOldDPIX;
1584  mnDPIY = nOldDPIY;
1585 }
1586 
1587 void Window::PaintToDevice( OutputDevice* pDev, const Point& rPos, const Size& /*rSize*/ )
1588 {
1589  SAL_WARN_IF( pDev->HasMirroredGraphics(), "vcl.window", "PaintToDevice to mirroring graphics" );
1590  SAL_WARN_IF( pDev->IsRTLEnabled(), "vcl.window", "PaintToDevice to mirroring device" );
1591 
1592  vcl::Window* pRealParent = nullptr;
1593  if( ! mpWindowImpl->mbVisible )
1594  {
1595  vcl::Window* pTempParent = ImplGetDefaultWindow();
1596  pTempParent->EnableChildTransparentMode();
1597  pRealParent = GetParent();
1598  SetParent( pTempParent );
1599  // trigger correct visibility flags for children
1600  Show();
1601  Hide();
1602  }
1603 
1604  bool bVisible = mpWindowImpl->mbVisible;
1605  mpWindowImpl->mbVisible = true;
1606 
1607  if( mpWindowImpl->mpBorderWindow )
1608  mpWindowImpl->mpBorderWindow->ImplPaintToDevice( pDev, rPos );
1609  else
1610  ImplPaintToDevice( pDev, rPos );
1611 
1612  mpWindowImpl->mbVisible = bVisible;
1613 
1614  if( pRealParent )
1615  SetParent( pRealParent );
1616 }
1617 
1618 void Window::Erase(vcl::RenderContext& rRenderContext)
1619 {
1621  return;
1622 
1623  bool bNativeOK = false;
1624 
1626  if (aCtrlPart != ControlPart::NONE && ! IsControlBackground())
1627  {
1628  tools::Rectangle aCtrlRegion(Point(), GetOutputSizePixel());
1630 
1631  if (IsEnabled())
1632  nState |= ControlState::ENABLED;
1633 
1634  bNativeOK = rRenderContext.DrawNativeControl(ControlType::WindowBackground, aCtrlPart, aCtrlRegion,
1635  nState, ImplControlValue(), OUString());
1636  }
1637 
1638  if (mbBackground && !bNativeOK)
1639  {
1640  RasterOp eRasterOp = GetRasterOp();
1641  if (eRasterOp != RasterOp::OverPaint)
1643  rRenderContext.DrawWallpaper(0, 0, mnOutWidth, mnOutHeight, maBackground);
1644  if (eRasterOp != RasterOp::OverPaint)
1645  rRenderContext.SetRasterOp(eRasterOp);
1646  }
1647 
1648  if (mpAlphaVDev)
1649  mpAlphaVDev->Erase();
1650 }
1651 
1653  long nHorzScroll, long nVertScroll, ScrollFlags nFlags )
1654 {
1655  if ( !IsDeviceOutputNecessary() )
1656  return;
1657 
1658  nHorzScroll = ImplLogicWidthToDevicePixel( nHorzScroll );
1659  nVertScroll = ImplLogicHeightToDevicePixel( nVertScroll );
1660 
1661  if ( !nHorzScroll && !nVertScroll )
1662  return;
1663 
1664  if ( mpWindowImpl->mpCursor )
1665  mpWindowImpl->mpCursor->ImplSuspend();
1666 
1667  ScrollFlags nOrgFlags = nFlags;
1668  if ( !(nFlags & (ScrollFlags::Children | ScrollFlags::NoChildren)) )
1669  {
1670  if ( GetStyle() & WB_CLIPCHILDREN )
1671  nFlags |= ScrollFlags::NoChildren;
1672  else
1673  nFlags |= ScrollFlags::Children;
1674  }
1675 
1676  vcl::Region aInvalidateRegion;
1677  bool bScrollChildren(nFlags & ScrollFlags::Children);
1678 
1679  if ( !mpWindowImpl->mpFirstChild )
1680  bScrollChildren = false;
1681 
1682  OutputDevice *pOutDev = GetOutDev();
1683 
1684  // RTL: check if this window requires special action
1685  bool bReMirror = ImplIsAntiparallel();
1686 
1687  tools::Rectangle aRectMirror( rRect );
1688  if( bReMirror )
1689  {
1690  // make sure the invalidate region of this window is
1691  // computed in the same coordinate space as the one from the overlap windows
1692  pOutDev->ReMirror( aRectMirror );
1693  }
1694 
1695  // adapt paint areas
1696  ImplMoveAllInvalidateRegions( aRectMirror, nHorzScroll, nVertScroll, bScrollChildren );
1697 
1698  ImplCalcOverlapRegion( aRectMirror, aInvalidateRegion, !bScrollChildren, false );
1699 
1700  // if the scrolling on the device is performed in the opposite direction
1701  // then move the overlaps in that direction to compute the invalidate region
1702  // on the correct side, i.e., revert nHorzScroll
1703  if (!aInvalidateRegion.IsEmpty())
1704  {
1705  aInvalidateRegion.Move(bReMirror ? -nHorzScroll : nHorzScroll, nVertScroll);
1706  }
1707 
1708  tools::Rectangle aDestRect(aRectMirror);
1709  aDestRect.Move(bReMirror ? -nHorzScroll : nHorzScroll, nVertScroll);
1710  vcl::Region aWinInvalidateRegion(aRectMirror);
1711  if (!SupportsDoubleBuffering())
1712  {
1713  // There will be no CopyArea() call below, so invalidate the
1714  // whole visible area, not only the smaller one that was just
1715  // scrolled in.
1716  aWinInvalidateRegion.Exclude(aDestRect);
1717  }
1718 
1719  aInvalidateRegion.Union(aWinInvalidateRegion);
1720 
1721  Point aPoint( mnOutOffX, mnOutOffY );
1722  vcl::Region aRegion( tools::Rectangle( aPoint, Size( mnOutWidth, mnOutHeight ) ) );
1723  if ( nFlags & ScrollFlags::Clip )
1724  aRegion.Intersect( rRect );
1725  if ( mpWindowImpl->mbWinRegion )
1726  aRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
1727 
1728  aRegion.Exclude( aInvalidateRegion );
1729 
1730  ImplClipBoundaries( aRegion, false, true );
1731  if ( !bScrollChildren )
1732  {
1733  if ( nOrgFlags & ScrollFlags::NoChildren )
1734  ImplClipAllChildren( aRegion );
1735  else
1736  ImplClipChildren( aRegion );
1737  }
1738  if ( mbClipRegion && (nFlags & ScrollFlags::UseClipRegion) )
1739  aRegion.Intersect( maRegion );
1740  if ( !aRegion.IsEmpty() )
1741  {
1742  if ( mpWindowImpl->mpWinData )
1743  {
1744  if ( mpWindowImpl->mbFocusVisible )
1745  ImplInvertFocus( *mpWindowImpl->mpWinData->mpFocusRect );
1746  if ( mpWindowImpl->mbTrackVisible && (mpWindowImpl->mpWinData->mnTrackFlags & ShowTrackFlags::TrackWindow) )
1747  InvertTracking( *mpWindowImpl->mpWinData->mpTrackRect, mpWindowImpl->mpWinData->mnTrackFlags );
1748  }
1749 #ifndef IOS
1750  // This seems completely unnecessary with tiled rendering, and
1751  // causes the "AquaSalGraphics::copyArea() for non-layered
1752  // graphics" message. Presumably we should bypass this on all
1753  // platforms when dealing with a "window" that uses tiled
1754  // rendering at the moment. Unclear how to figure that out,
1755  // though. Also unclear whether we actually could just not
1756  // create a "frame window", whatever that exactly is, in the
1757  // tiled rendering case, or at least for platforms where tiles
1758  // rendering is all there is.
1759 
1760  SalGraphics* pGraphics = ImplGetFrameGraphics();
1761  // The invalidation area contains the area what would be copied here,
1762  // so avoid copying in case of double buffering.
1763  if (pGraphics && !SupportsDoubleBuffering())
1764  {
1765  if( bReMirror )
1766  {
1767  pOutDev->ReMirror( aRegion );
1768  }
1769 
1770  pOutDev->SelectClipRegion( aRegion, pGraphics );
1771  pGraphics->CopyArea( rRect.Left()+nHorzScroll, rRect.Top()+nVertScroll,
1772  rRect.Left(), rRect.Top(),
1773  rRect.GetWidth(), rRect.GetHeight(),
1774  this );
1775  }
1776 #endif
1777  if ( mpWindowImpl->mpWinData )
1778  {
1779  if ( mpWindowImpl->mbFocusVisible )
1780  ImplInvertFocus( *mpWindowImpl->mpWinData->mpFocusRect );
1781  if ( mpWindowImpl->mbTrackVisible && (mpWindowImpl->mpWinData->mnTrackFlags & ShowTrackFlags::TrackWindow) )
1782  InvertTracking( *mpWindowImpl->mpWinData->mpTrackRect, mpWindowImpl->mpWinData->mnTrackFlags );
1783  }
1784  }
1785 
1786  if ( !aInvalidateRegion.IsEmpty() )
1787  {
1788  // RTL: the invalidate region for this windows is already computed in frame coordinates
1789  // so it has to be re-mirrored before calling the Paint-handler
1790  mpWindowImpl->mnPaintFlags |= ImplPaintFlags::CheckRtl;
1791 
1792  if ( !bScrollChildren )
1793  {
1794  if ( nOrgFlags & ScrollFlags::NoChildren )
1795  ImplClipAllChildren( aInvalidateRegion );
1796  else
1797  ImplClipChildren( aInvalidateRegion );
1798  }
1800  }
1801 
1802  if ( bScrollChildren )
1803  {
1804  vcl::Window* pWindow = mpWindowImpl->mpFirstChild;
1805  while ( pWindow )
1806  {
1807  Point aPos = pWindow->GetPosPixel();
1808  aPos += Point( nHorzScroll, nVertScroll );
1809  pWindow->SetPosPixel( aPos );
1810 
1811  pWindow = pWindow->mpWindowImpl->mpNext;
1812  }
1813  }
1814 
1815  if ( nFlags & ScrollFlags::Update )
1816  Update();
1817 
1818  if ( mpWindowImpl->mpCursor )
1819  mpWindowImpl->mpCursor->ImplResume();
1820 }
1821 
1822 } /* namespace vcl */
1823 
1824 
1825 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual Point GetPosPixel() const
Definition: window.cxx:2806
void EnableOutput(bool bEnable=true)
Point TopLeft() const
long Width() const
vcl::Region GetClipRegion() const
const Color & GetTextColor() const
Definition: outdev.hxx:1110
bool IsControlBackground() const
Definition: window2.cxx:1081
long mnOutOffX
Output offset for device output in pixel (pseudo window offset within window system's frames) ...
Definition: outdev.hxx:342
void SetDigitLanguage(LanguageType)
tools::Rectangle m_aPaintRect
Definition: paint.cxx:166
long GetWidth() const
const Wallpaper & GetBackground() const
Definition: outdev.hxx:631
SAL_DLLPRIVATE SalGraphics * ImplGetFrameGraphics() const
Definition: window.cxx:1245
vcl::LOKWindowId GetLOKWindowId() const
Definition: window.cxx:3238
long GetHeight() const
constexpr::Color COL_BLACK(0x00, 0x00, 0x00)
SAL_DLLPRIVATE bool ImplIsRecordLayout() const
Definition: outdev.cxx:657
PaintBufferGuard(ImplFrameData *pFrameData, vcl::Window *pWindow)
Definition: paint.cxx:43
void SetAverageFontWidth(long nWidth)
Definition: font/font.cxx:672
bool IsNull() const
Definition: region.hxx:102
bool DrawNativeControl(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, const OUString &aCaption)
Request rendering of a particular control and/or part.
long GetFontHeight() const
Definition: font/font.cxx:671
const Point & GetRefPoint() const
Definition: outdev.hxx:436
SAL_DLLPRIVATE void ImplPaintToDevice(::OutputDevice *pTargetOutDev, const Point &rPos)
Definition: paint.cxx:1348
const Color & GetHighlightTextColor() const
SAL_DLLPRIVATE void ImplMoveInvalidateRegion(const tools::Rectangle &rRect, long nHorzScroll, long nVertScroll, bool bChildren)
Definition: paint.cxx:847
static void DrawSelectionBackground(vcl::RenderContext &rRenderContext, vcl::Window const &rWindow, const tools::Rectangle &rRect, sal_uInt16 nHighlight, bool bChecked, bool bDrawBorder, bool bDrawExtBorderOnly, Color *pSelectionTextColor=nullptr, long nCornerRadius=0, Color const *pPaintColor=nullptr)
Definition: paint.cxx:317
InvalidateFlags
Definition: window.hxx:211
long Height() const
long mnOutOffY
Output offset for device output in pixel (pseudo window offset within window system's frames) ...
Definition: outdev.hxx:344
const Color & GetTextLineColor() const
Definition: outdev.hxx:1119
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
This is an overloaded member function, provided for convenience. It differs from the above function o...
tools::Rectangle m_aSelectionRect
Definition: paint.cxx:165
void Union(const tools::Rectangle &rRegion)
Definition: region.cxx:508
VclPtr< vcl::Window > m_pWindow
Definition: paint.cxx:163
bool IsBackground() const
Definition: outdev.hxx:634
void InvertTracking(const tools::Rectangle &rRect, ShowTrackFlags nFlags)
Definition: window2.cxx:158
long AdjustLeft(long nHorzMoveDelta)
ValidateFlags
Definition: window.hxx:228
long GetOutOffXPixel() const
Definition: outdev.hxx:445
ImplPaintFlags GetPaintFlags() const
Definition: paint.cxx:194
bool mbInBufferedPaint
PaintHelper is in the process of painting into this buffer.
Definition: window.h:177
void disposeAndClear()
Definition: vclptr.hxx:200
const StyleSettings & GetStyleSettings() const
TextAlign GetTextAlign() const
Definition: outdev.hxx:1128
bool IsOutputEnabled() const
Definition: outdev.hxx:588
ParentClipMode GetParentClipMode() const
sal_uInt8 GetLuminance() const
const Color & GetFaceColor() const
bool IsTextLineColor() const
Definition: outdev.hxx:1120
void Flush() override
Definition: window.cxx:2962
vcl::Region maRegion
Definition: outdev.hxx:361
vcl::Region maInvalidateRegion
Definition: window.h:288
virtual Size GetSizePixel() const
Definition: window.cxx:2364
SAL_DLLPRIVATE WindowImpl * ImplGetWindowImpl() const
Definition: window.hxx:552
ComplexTextLayoutFlags GetLayoutMode() const
Definition: outdev.hxx:598
const MapMode & GetMapMode() const
Definition: outdev.hxx:1674
constexpr::Color COL_GRAY(0x80, 0x80, 0x80)
sal_Int32 mnDPIY
Definition: outdev.hxx:348
void SetTextFillColor()
Definition: text.cxx:697
vcl::Region GetPaintRegion() const
Definition: paint.cxx:1137
void SetLayoutMode(ComplexTextLayoutFlags nTextLayoutMode)
bool mbBackground
Definition: window.h:404
void SetPop()
Definition: paint.cxx:174
GDIMetaFile * GetConnectMetaFile() const
Definition: outdev.hxx:417
ImplWinData * mpWinData
Definition: window.h:223
sal_Int32 mnDPIX
Definition: outdev.hxx:347
virtual void SetSettings(const AllSettings &rSettings)
Definition: outdev.cxx:213
constexpr::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
SAL_DLLPRIVATE void ImplClipAllChildren(vcl::Region &rRegion) const
SAL_DLLPRIVATE void ImplUpdateAll()
Definition: paint.cxx:978
tools::Rectangle GetBoundRect() const
Definition: region.cxx:1214
VclPtr< VirtualDevice > mpBuffer
Buffer for the double-buffering.
Definition: window.h:176
SAL_DLLPRIVATE void ImplCallPaint(const vcl::Region *pRegion, ImplPaintFlags nPaintFlags)
Invoke the actual painting.
Definition: paint.cxx:572
void PaintBuffer()
Paint the content of the buffer to the current m_pWindow.
Definition: paint.cxx:232
void SetMapMode()
Definition: map.cxx:655
ImplPaintFlags const m_nPaintFlags
Definition: paint.cxx:168
Dialog * GetParentDialog() const
Definition: window2.cxx:976
const Color & GetHighlightColor() const
Color GetBackgroundColor() const override
Definition: window.cxx:580
SAL_DLLPRIVATE void ImplInvalidateFrameRegion(const vcl::Region *pRegion, InvalidateFlags nFlags)
Definition: paint.cxx:675
bool GetRestoreCursor() const
Definition: paint.cxx:190
long AdjustBottom(long nVertMoveDelta)
bool SelectClipRegion(const vcl::Region &, SalGraphics *pGraphics=nullptr)
SAL_DLLPRIVATE bool ImplIsOverlapWindow() const
Definition: window2.cxx:920
void Move(long nHorzMoveDelta, long nVertMoveDelta)
std::vector< tools::Rectangle > RectangleVector
Definition: region.hxx:37
void DrawWallpaper(const tools::Rectangle &rRect, const Wallpaper &rWallpaper)
Definition: wallpaper.cxx:42
bool IsEmpty() const
ImplFrameData * mpFrameData
Definition: window.h:402
const Color & GetOverlineColor() const
Definition: outdev.hxx:1124
VclPtr< vcl::Window > m_pWindow
Definition: window.h:403
Color GetTextFillColor() const
Definition: text.cxx:755
void SetBackground()
ScrollFlags
Definition: window.hxx:240
SAL_DLLPRIVATE void ReMirror(Point &rPoint) const
Definition: outdev.cxx:620
VclPtr< vcl::Window > GetParentWithLOKNotifier()
Find the nearest parent with LOK Notifier; can be itself if this Window has LOK notifier set...
Definition: window.cxx:3243
SAL_DLLPRIVATE void ImplInvalidate(const vcl::Region *rRegion, InvalidateFlags nFlags)
Definition: paint.cxx:766
SAL_DLLPRIVATE void ImplInvalidateParentFrameRegion(vcl::Region &rRegion)
Definition: paint.cxx:755
const vcl::Font & GetFont() const
Definition: outdev.hxx:637
RasterOp
Definition: vclenum.hxx:191
SAL_DLLPRIVATE void ImplClipBoundaries(vcl::Region &rRegion, bool bThis, bool bOverlaps)
void Hide()
Definition: window.hxx:930
boost::optional< tools::Rectangle > mpTrackRect
Definition: window.h:114
bool mbBackground
Definition: outdev.hxx:378
VclPtr< vcl::Window > mpLastChild
Definition: window.h:234
PushFlags
Definition: outdevstate.hxx:38
virtual OUString GetText() const
Definition: window.cxx:3051
long Top() const
void SetWindowRegionPixel()
Definition: paint.cxx:1027
void Play(GDIMetaFile &rMtf)
Definition: gdimtf.cxx:295
SAL_DLLPRIVATE void ImplValidate()
Definition: paint.cxx:949
void Move(long nHorzMove, long nVertMove)
Definition: region.cxx:414
Sets up the buffer to have settings matching the window, and restores the original state in the dtor...
Definition: window.h:400
static Color HSBtoRGB(sal_uInt16 nHue, sal_uInt16 nSaturation, sal_uInt16 nBrightness)
if(nullptr==pCandidateA||nullptr==pCandidateB)
void SetTextLineColor()
Definition: textline.cxx:800
void DrawRect(const tools::Rectangle &rRect)
Definition: rect.cxx:32
tools::Rectangle maBufferedRect
Rectangle in the buffer that has to be painted to the screen.
Definition: window.h:178
ImplPaintFlags
Definition: window.h:200
const Color & GetControlForeground() const
Definition: window2.cxx:1066
void Update()
Definition: paint.cxx:1273
bool IsTextFillColor() const
Definition: outdev.hxx:1115
bool IsEmpty() const
Definition: region.cxx:228
void SetLineColor()
void SetRefPoint()
Definition: outdev.cxx:278
virtual void PrePaint(vcl::RenderContext &rRenderContext)
Definition: paint.cxx:1002
void SetConnectMetaFile(GDIMetaFile *pMtf)
Definition: outdev.cxx:208
bool IsRTLEnabled() const
Definition: outdev.hxx:1354
void StartBufferedPaint()
Start buffered paint: set it up to have the same settings as m_pWindow.
Definition: paint.cxx:222
Wallpaper maBackground
Definition: outdev.hxx:369
#define VCL_GL_INFO(stream)
Helper to do a SAL_INFO as well as a GL log.
bool IsClipRegion() const
Definition: outdev.hxx:663
bool IsDark() const
bool IsLineColor() const
Definition: outdev.hxx:619
void DrawSelectionBackground(const tools::Rectangle &rRect, sal_uInt16 highlight, bool bChecked, bool bDrawBorder)
Definition: window.cxx:3323
void SetPaintRect(const tools::Rectangle &rRectangle)
If this is called, then the dtor will also copy rRectangle to the window from the buffer...
Definition: paint.cxx:147
void SetEmpty()
Definition: region.cxx:1417
void SetParent(vcl::Window *pNewParent)
Definition: stacking.cxx:831
virtual void ApplySettings(vcl::RenderContext &rRenderContext)
Definition: window.cxx:3670
void DrawTransparent(const tools::PolyPolygon &rPolyPoly, sal_uInt16 nTransparencePercent)
SAL_DLLPRIVATE void ImplCallOverlapPaint()
Definition: paint.cxx:617
~PaintHelper()
Definition: paint.cxx:529
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1153
SAL_DLLPRIVATE bool ImplIsAntiparallel() const
Definition: outdev.cxx:604
vcl::Region & GetPaintRegion()
Definition: paint.cxx:198
bool m_bPop
Definition: paint.cxx:169
bool m_bStartedBufferedPaint
This PaintHelper started a buffered paint, and should paint it on the screen when being destructed...
Definition: paint.cxx:171
virtual bool HasMirroredGraphics() const
Definition: outdev.cxx:652
std::unique_ptr< vcl::Region > m_pChildRegion
Definition: paint.cxx:164
SAL_DLLPRIVATE void PopPaintHelper(PaintHelper const *pHelper)
Definition: paint.cxx:513
void SetFillColor()
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
const Color & GetLineColor() const
Definition: outdev.hxx:618
void SetTextColor(const Color &rColor)
Definition: text.cxx:662
bool HasPaintEvent() const
Definition: paint.cxx:1246
std::unique_ptr< WindowImpl > mpWindowImpl
Definition: window.hxx:509
void SetOutOffYPixel(long nOutOffY)
Definition: outdev.cxx:319
void SetPaintRect(const tools::Rectangle &rRect)
Definition: paint.cxx:178
SAL_DLLPRIVATE vcl::Window * ImplGetParent() const
Definition: window2.cxx:864
virtual void PixelInvalidate(const tools::Rectangle *pRectangle)
Notification about some rectangle of the output device got invalidated.
Definition: paint.cxx:1211
void Intersect(const tools::Rectangle &rRegion)
Definition: region.cxx:584
void Validate()
Definition: paint.cxx:1238
void SetOverlineColor()
Definition: textline.cxx:849
const AllSettings & GetSettings() const
Definition: outdev.hxx:420
void SetPaintTransparent(bool bTransparent)
Definition: paint.cxx:1015
Size GetOutputSizePixel() const
Definition: outdev.hxx:441
MapUnit GetMapUnit() const
Definition: mapmod.cxx:163
void WindStart()
Definition: gdimtf.cxx:526
ControlPart mnNativeBackground
Definition: window.h:295
vcl::Window * GetParent() const
Definition: window2.cxx:1091
SAL_DLLPRIVATE void ImplCalcOverlapRegion(const tools::Rectangle &rSourceRect, vcl::Region &rRegion, bool bChildren, bool bSiblings)
Size GetSize() const
long mnOutOffY
Definition: window.h:408
MapUnit GetMapUnit()
Point PixelToLogic(const Point &rDevicePt) const
Definition: map.cxx:1185
Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:940
SAL_DLLPRIVATE void ImplValidateFrameRegion(const vcl::Region *rRegion, ValidateFlags nFlags)
Definition: paint.cxx:907
SAL_DLLPRIVATE vcl::Window * ImplGetFirstOverlapWindow()
Definition: window2.cxx:879
void SetSelectionRect(const tools::Rectangle &rRect)
Definition: paint.cxx:182
VclPtr< VirtualDevice > mpAlphaVDev
Definition: outdev.hxx:331
void Exclude(const tools::Rectangle &rRegion)
Definition: region.cxx:675
void CopyArea(long nDestX, long nDestY, long nSrcX, long nSrcY, long nSrcWidth, long nSrcHeight, const OutputDevice *pOutDev)
SAL_DLLPRIVATE vcl::Region ImplPixelToDevicePixel(const vcl::Region &rRegion) const
Convert a region in pixel units to a region in device pixel units and coords.
Definition: map.cxx:637
void Erase()
Definition: wallpaper.cxx:103
def rectangle(l)
bool IsRefPoint() const
Definition: outdev.hxx:437
long AdjustRight(long nHorzMoveDelta)
bool mbClipRegion
Definition: outdev.hxx:377
tools::Rectangle & Union(const tools::Rectangle &rRect)
const Color & GetButtonTextColor() const
#define SAL_WARN_IF(condition, area, stream)
void DoPaint(const vcl::Region *pRegion)
Definition: paint.cxx:242
void SetFont(const vcl::Font &rNewFont)
SAL_DLLPRIVATE void ImplInvalidateOverlapFrameRegion(const vcl::Region &rRegion)
Definition: paint.cxx:736
void PaintToDevice(::OutputDevice *pDevice, const Point &rPos, const Size &rSize)
Definition: paint.cxx:1587
SAL_DLLPRIVATE void ImplMoveAllInvalidateRegions(const tools::Rectangle &rRect, long nHorzScroll, long nVertScroll, bool bChildren)
Definition: paint.cxx:870
LanguageType GetDigitLanguage() const
Definition: outdev.hxx:601
SAL_DLLPRIVATE vcl::Region * ImplGetWinChildClipRegion()
SAL_DLLPRIVATE void ImplScroll(const tools::Rectangle &rRect, long nHorzScroll, long nVertScroll, ScrollFlags nFlags)
Definition: paint.cxx:1652
bool IsVisible() const
Definition: window2.cxx:1096
bool mbInitClipRegion
Definition: outdev.hxx:388
AllSettings maSettings
Definition: window.h:406
::OutputDevice const * GetOutDev() const
Definition: window.cxx:570
vcl::RenderContext * GetRenderContext()
Returns either the frame's buffer or the window, in case of no buffering.
Definition: paint.cxx:152
void EnableChildTransparentMode(bool bEnable=true)
Definition: window2.cxx:1016
void SetRasterOp(RasterOp eRasterOp)
SAL_DLLPRIVATE void PushPaintHelper(PaintHelper *pHelper, vcl::RenderContext &rRenderContext)
Definition: paint.cxx:469
void Scale(double fScaleX, double fScaleY)
Definition: gdimtf.cxx:684
void SetFontHeight(long nHeight)
Definition: font/font.cxx:670
long AdjustTop(long nVertMoveDelta)
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: paint.cxx:1010
const char * name
long GetOutOffYPixel() const
Definition: outdev.hxx:446
RasterOp GetRasterOp() const
Definition: outdev.hxx:604
constexpr::Color COL_WHITE(0xFF, 0xFF, 0xFF)
virtual void DrawOutDev(const Point &rDestPt, const Size &rDestSize, const Point &rSrcPt, const Size &rSrcSize)
Definition: outdev.cxx:348
SAL_DLLPRIVATE long ImplLogicWidthToDevicePixel(long nWidth) const
Convert a logical width to a width in units of device pixels.
Definition: map.cxx:430
long Left() const
ShowTrackFlags mnTrackFlags
Definition: window.h:115
SAL_DLLPRIVATE bool ImplSetClipFlag(bool bSysObjOnlySmaller=false)
bool IsDisposed() const
Definition: window.cxx:135
SAL_DLLPRIVATE long ImplLogicHeightToDevicePixel(long nHeight) const
Convert a logical height to a height in units of device pixels.
Definition: map.cxx:440
tools::Rectangle m_aPaintRect
Definition: window.h:409
bool IsBitmap() const
Definition: wall.cxx:254
SAL_DLLPRIVATE bool ImplClipChildren(vcl::Region &rRegion) const
long mnOutWidth
Definition: outdev.hxx:345
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:504
bool mbDevOutput
Definition: outdev.hxx:380
bool IsPaintTransparent() const
Definition: window2.cxx:1031
SAL_DLLPRIVATE void ImplInvertFocus(const tools::Rectangle &rRect)
Definition: mouse.cxx:175
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
bool IsEnabled() const
Definition: window2.cxx:1116
const vcl::ILibreOfficeKitNotifier * GetLOKNotifier() const
Definition: window.cxx:3233
#define SAL_WARN(area, stream)
void SetOutOffXPixel(long nOutOffX)
Definition: outdev.cxx:314
WinBits GetStyle() const
Definition: window2.cxx:947
Definition: timer.hxx:26
SAL_DLLPRIVATE tools::Rectangle ImplDevicePixelToLogic(const tools::Rectangle &rPixelRect) const
Convert a rectangle in physical pixel units to a rectangle in physical pixel units and coords...
Definition: map.cxx:612
virtual void LogicInvalidate(const tools::Rectangle *pRectangle)
Notification about some rectangle of the output device got invalidated.Used for the main document win...
Definition: paint.cxx:1200
bool IsFillColor() const
Definition: outdev.hxx:624
vcl::Region m_aPaintRegion
Definition: paint.cxx:167
virtual void PostPaint(vcl::RenderContext &rRenderContext)
Definition: paint.cxx:1006
bool IsOverlineColor() const
Definition: outdev.hxx:1125
long mnOutOffX
Definition: window.h:407
void CallEventListeners(VclEventId nEvent, void *pData=nullptr)
Definition: event.cxx:203
bool IsReallyVisible() const
Definition: window2.cxx:1101
long GetAverageFontWidth() const
Definition: font/font.cxx:673
void SetRestoreCursor(bool bRestoreCursor)
Definition: paint.cxx:186
ImplPaintFlags mnPaintFlags
Definition: window.h:297
long mnOutHeight
Definition: outdev.hxx:346
rtl::OString toString() const
vcl::Window * ImplGetDefaultWindow()
Returns either the application window, or the default GL context window.
Definition: svdata.cxx:202
IMPL_LINK_NOARG(QuickSelectionEngine_Data, SearchStringTimeout, Timer *, void)
bool IsDeviceOutputNecessary() const
Definition: outdev.hxx:589
void Push(PushFlags nFlags=PushFlags::ALL)
Definition: outdevstate.cxx:60
bool SupportsDoubleBuffering() const
Can the widget derived from this Window do the double-buffering via RenderContext properly...
Definition: window.cxx:3692
SAL_DLLPRIVATE sal_Int32 GetDPIY() const
Get the output device's DPI y-axis value.
Definition: outdev.hxx:507
bool m_bRestoreCursor
Definition: paint.cxx:170
sal_Int32 h
WinBits const WB_CLIPCHILDREN
PaintHelper(vcl::Window *pWindow, ImplPaintFlags nPaintFlags)
Definition: paint.cxx:213
virtual void SetPosPixel(const Point &rNewPos)
Definition: window2.cxx:1251
bool mbTrackVisible
Definition: window.h:316
SAL_DLLPRIVATE sal_Int32 GetDPIX() const
Get the output device's DPI x-axis value.
Definition: outdev.hxx:501
void SetTextAlign(TextAlign eAlign)
Definition: text.cxx:763
const Color & GetFillColor() const
Definition: outdev.hxx:623
Wallpaper maBackground
Definition: window.h:405
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2150