LibreOffice Module vcl (master)  1
layout.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 
10 #include <com/sun/star/accessibility/AccessibleRole.hpp>
11 #include <o3tl/enumarray.hxx>
12 #include <o3tl/enumrange.hxx>
13 #include <vcl/toolkit/button.hxx>
14 #include <vcl/decoview.hxx>
15 #include <vcl/toolkit/dialog.hxx>
16 #include <vcl/layout.hxx>
17 #include <vcl/scrbar.hxx>
18 #include <vcl/stdtext.hxx>
19 #include <vcl/split.hxx>
20 #include <vcl/svapp.hxx>
21 #include <vcl/settings.hxx>
22 #include <bitmaps.hlst>
23 #include <messagedialog.hxx>
24 #include <svdata.hxx>
25 #include <window.h>
26 #include <boost/multi_array.hpp>
27 #include <boost/property_tree/ptree.hpp>
28 #include <vcl/vclmedit.hxx>
29 #include <sal/log.hxx>
30 
33  , m_bLayoutDirty(true)
34 {
35  ImplInit(pParent, nStyle, nullptr);
37  SetPaintTransparent(true);
38  SetBackground();
39 }
40 
42 {
43  return css::accessibility::AccessibleRole::PANEL;
44 }
45 
47 {
48  return calculateRequisition();
49 }
50 
51 void VclContainer::setLayoutPosSize(vcl::Window &rWindow, const Point &rPos, const Size &rSize)
52 {
53  sal_Int32 nBorderWidth = rWindow.get_border_width();
54  sal_Int32 nLeft = rWindow.get_margin_left() + nBorderWidth;
55  sal_Int32 nTop = rWindow.get_margin_top() + nBorderWidth;
56  sal_Int32 nRight = rWindow.get_margin_right() + nBorderWidth;
57  sal_Int32 nBottom = rWindow.get_margin_bottom() + nBorderWidth;
58  Point aPos(rPos.X() + nLeft, rPos.Y() + nTop);
59  Size aSize(rSize.Width() - nLeft - nRight, rSize.Height() - nTop - nBottom);
60  rWindow.SetPosSizePixel(aPos, aSize);
61 }
62 
63 void VclContainer::setLayoutAllocation(vcl::Window &rChild, const Point &rAllocPos, const Size &rChildAlloc)
64 {
65  VclAlign eHalign = rChild.get_halign();
66  VclAlign eValign = rChild.get_valign();
67 
68  //typical case
69  if (eHalign == VclAlign::Fill && eValign == VclAlign::Fill)
70  {
71  setLayoutPosSize(rChild, rAllocPos, rChildAlloc);
72  return;
73  }
74 
75  Point aChildPos(rAllocPos);
76  Size aChildSize(rChildAlloc);
77  Size aChildPreferredSize(getLayoutRequisition(rChild));
78 
79  switch (eHalign)
80  {
81  case VclAlign::Fill:
82  break;
83  case VclAlign::Start:
84  if (aChildPreferredSize.Width() < rChildAlloc.Width())
85  aChildSize.setWidth( aChildPreferredSize.Width() );
86  break;
87  case VclAlign::End:
88  if (aChildPreferredSize.Width() < rChildAlloc.Width())
89  aChildSize.setWidth( aChildPreferredSize.Width() );
90  aChildPos.AdjustX(rChildAlloc.Width() );
91  aChildPos.AdjustX( -(aChildSize.Width()) );
92  break;
93  case VclAlign::Center:
94  if (aChildPreferredSize.Width() < aChildSize.Width())
95  aChildSize.setWidth( aChildPreferredSize.Width() );
96  aChildPos.AdjustX((rChildAlloc.Width() - aChildSize.Width()) / 2 );
97  break;
98  }
99 
100  switch (eValign)
101  {
102  case VclAlign::Fill:
103  break;
104  case VclAlign::Start:
105  if (aChildPreferredSize.Height() < rChildAlloc.Height())
106  aChildSize.setHeight( aChildPreferredSize.Height() );
107  break;
108  case VclAlign::End:
109  if (aChildPreferredSize.Height() < rChildAlloc.Height())
110  aChildSize.setHeight( aChildPreferredSize.Height() );
111  aChildPos.AdjustY(rChildAlloc.Height() );
112  aChildPos.AdjustY( -(aChildSize.Height()) );
113  break;
114  case VclAlign::Center:
115  if (aChildPreferredSize.Height() < aChildSize.Height())
116  aChildSize.setHeight( aChildPreferredSize.Height() );
117  aChildPos.AdjustY((rChildAlloc.Height() - aChildSize.Height()) / 2 );
118  break;
119  }
120 
121  setLayoutPosSize(rChild, aChildPos, aChildSize);
122 }
123 
124 namespace
125 {
126  Size subtractBorder(const vcl::Window &rWindow, const Size& rSize)
127  {
128  sal_Int32 nBorderWidth = rWindow.get_border_width();
129  sal_Int32 nLeft = rWindow.get_margin_left() + nBorderWidth;
130  sal_Int32 nTop = rWindow.get_margin_top() + nBorderWidth;
131  sal_Int32 nRight = rWindow.get_margin_right() + nBorderWidth;
132  sal_Int32 nBottom = rWindow.get_margin_bottom() + nBorderWidth;
133  Size aSize(rSize);
134  return Size(aSize.Width() + nLeft + nRight, aSize.Height() + nTop + nBottom);
135  }
136 }
137 
139 {
140  return subtractBorder(rWindow, rWindow.get_preferred_size());
141 }
142 
143 void VclContainer::SetPosSizePixel(const Point& rAllocPos, const Size& rAllocation)
144 {
145  bool bSizeChanged = rAllocation != GetOutputSizePixel();
146  Window::SetPosSizePixel(rAllocPos, rAllocation);
147  if (m_bLayoutDirty || bSizeChanged)
148  {
149  m_bLayoutDirty = false;
150  setAllocation(rAllocation);
151  }
152 }
153 
154 void VclContainer::SetPosPixel(const Point& rAllocPos)
155 {
156  Point aAllocPos = rAllocPos;
157  sal_Int32 nBorderWidth = get_border_width();
158  aAllocPos.AdjustX(nBorderWidth + get_margin_left() );
159  aAllocPos.AdjustY(nBorderWidth + get_margin_top() );
160 
161  if (aAllocPos != GetPosPixel())
162  Window::SetPosPixel(aAllocPos);
163 }
164 
165 void VclContainer::SetSizePixel(const Size& rAllocation)
166 {
167  Size aAllocation = rAllocation;
168  sal_Int32 nBorderWidth = get_border_width();
169  aAllocation.AdjustWidth( -(nBorderWidth*2 + get_margin_left() + get_margin_right()) );
170  aAllocation.AdjustHeight( -(nBorderWidth*2 + get_margin_top() + get_margin_bottom()) );
171  bool bSizeChanged = aAllocation != GetSizePixel();
172  if (bSizeChanged)
173  Window::SetSizePixel(aAllocation);
174  if (m_bLayoutDirty || bSizeChanged)
175  {
176  m_bLayoutDirty = false;
177  setAllocation(aAllocation);
178  }
179 }
180 
182 {
183  m_bLayoutDirty = true;
184  Window::queue_resize(eReason);
185 }
186 
187 // support for screenshot context menu
189 {
191  {
192  auto pParent = GetParent();
193  if (pParent)
194  {
195  CommandEvent aCEvt(rCEvt.GetMousePosPixel() + GetPosPixel(), rCEvt.GetCommand(), rCEvt.IsMouseEvent(), rCEvt.GetEventData());
196  pParent->Command(aCEvt);
197  return;
198  }
199  }
200 
201  // call parent (do not consume)
202  Window::Command(rCEvt);
203 }
204 
205 void VclBox::accumulateMaxes(const Size &rChildSize, Size &rSize) const
206 {
207  long nSecondaryChildDimension = getSecondaryDimension(rChildSize);
208  long nSecondaryBoxDimension = getSecondaryDimension(rSize);
209  setSecondaryDimension(rSize, std::max(nSecondaryChildDimension, nSecondaryBoxDimension));
210 
211  long nPrimaryChildDimension = getPrimaryDimension(rChildSize);
212  long nPrimaryBoxDimension = getPrimaryDimension(rSize);
213  if (m_bHomogeneous)
214  setPrimaryDimension(rSize, std::max(nPrimaryBoxDimension, nPrimaryChildDimension));
215  else
216  setPrimaryDimension(rSize, nPrimaryBoxDimension + nPrimaryChildDimension);
217 }
218 
220 {
221  sal_uInt16 nVisibleChildren = 0;
222 
223  Size aSize;
224  for (vcl::Window *pChild = GetWindow(GetWindowType::FirstChild); pChild; pChild = pChild->GetWindow(GetWindowType::Next))
225  {
226  if (!pChild->IsVisible())
227  continue;
228  ++nVisibleChildren;
229  Size aChildSize = getLayoutRequisition(*pChild);
230 
231  long nPrimaryDimension = getPrimaryDimension(aChildSize);
232  nPrimaryDimension += pChild->get_padding() * 2;
233  setPrimaryDimension(aChildSize, nPrimaryDimension);
234 
235  accumulateMaxes(aChildSize, aSize);
236  }
237 
238  return finalizeMaxes(aSize, nVisibleChildren);
239 }
240 
241 void VclBox::setAllocation(const Size &rAllocation)
242 {
243  sal_uInt16 nVisibleChildren = 0, nExpandChildren = 0;
244  for (vcl::Window *pChild = GetWindow(GetWindowType::FirstChild); pChild; pChild = pChild->GetWindow(GetWindowType::Next))
245  {
246  if (!pChild->IsVisible())
247  continue;
248  ++nVisibleChildren;
249  bool bExpand = getPrimaryDimensionChildExpand(*pChild);
250  if (bExpand)
251  ++nExpandChildren;
252  }
253 
254  if (!nVisibleChildren)
255  return;
256 
257  long nAllocPrimaryDimension = getPrimaryDimension(rAllocation);
258 
259  long nHomogeneousDimension = 0, nExtraSpace = 0;
260  if (m_bHomogeneous)
261  {
262  nHomogeneousDimension = (nAllocPrimaryDimension -
263  (nVisibleChildren - 1) * m_nSpacing) / nVisibleChildren;
264  }
265  else if (nExpandChildren)
266  {
267  Size aRequisition = calculateRequisition();
268  nExtraSpace = (getPrimaryDimension(rAllocation) - getPrimaryDimension(aRequisition)) / nExpandChildren;
269  }
270 
271  //Split into those we pack from the start onwards, and those we pack from the end backwards
273  for (vcl::Window *pChild = GetWindow(GetWindowType::FirstChild); pChild; pChild = pChild->GetWindow(GetWindowType::Next))
274  {
275  if (!pChild->IsVisible())
276  continue;
277 
278  VclPackType ePacking = pChild->get_pack_type();
279  aWindows[ePacking].push_back(pChild);
280  }
281 
282  //See VclBuilder::sortIntoBestTabTraversalOrder for why they are in visual
283  //order under the parent which requires us to reverse them here to
284  //pack from the end back
285  std::reverse(aWindows[VclPackType::End].begin(),aWindows[VclPackType::End].end());
286 
287  for (VclPackType ePackType : o3tl::enumrange<VclPackType>())
288  {
289  Point aPos(0, 0);
290  if (ePackType == VclPackType::End)
291  {
292  long nPrimaryCoordinate = getPrimaryCoordinate(aPos);
293  setPrimaryCoordinate(aPos, nPrimaryCoordinate + nAllocPrimaryDimension);
294  }
295 
296  for (auto const& window : aWindows[ePackType])
297  {
298  vcl::Window *pChild = window;
299 
300  long nPadding = pChild->get_padding();
301 
302  Size aBoxSize;
303  if (m_bHomogeneous)
304  setPrimaryDimension(aBoxSize, nHomogeneousDimension);
305  else
306  {
307  aBoxSize = getLayoutRequisition(*pChild);
308  long nPrimaryDimension = getPrimaryDimension(aBoxSize);
309  nPrimaryDimension += nPadding * 2;
310  if (getPrimaryDimensionChildExpand(*pChild))
311  nPrimaryDimension += nExtraSpace;
312  setPrimaryDimension(aBoxSize, nPrimaryDimension);
313  }
314  setSecondaryDimension(aBoxSize, getSecondaryDimension(rAllocation));
315 
316  Point aChildPos(aPos);
317  Size aChildSize(aBoxSize);
318  long nPrimaryCoordinate = getPrimaryCoordinate(aPos);
319 
320  bool bFill = pChild->get_fill();
321  if (bFill)
322  {
323  setPrimaryDimension(aChildSize, std::max(static_cast<long>(1),
324  getPrimaryDimension(aBoxSize) - nPadding * 2));
325 
326  setPrimaryCoordinate(aChildPos, nPrimaryCoordinate + nPadding);
327  }
328  else
329  {
330  setPrimaryDimension(aChildSize,
332 
333  setPrimaryCoordinate(aChildPos, nPrimaryCoordinate +
334  (getPrimaryDimension(aBoxSize) - getPrimaryDimension(aChildSize)) / 2);
335  }
336 
337  long nDiff = getPrimaryDimension(aBoxSize) + m_nSpacing;
338  if (ePackType == VclPackType::Start)
339  setPrimaryCoordinate(aPos, nPrimaryCoordinate + nDiff);
340  else
341  {
342  setPrimaryCoordinate(aPos, nPrimaryCoordinate - nDiff);
343  setPrimaryCoordinate(aChildPos, getPrimaryCoordinate(aChildPos) -
344  getPrimaryDimension(aBoxSize));
345  }
346 
347  setLayoutAllocation(*pChild, aChildPos, aChildSize);
348  }
349  }
350 }
351 
352 bool VclBox::set_property(const OString &rKey, const OUString &rValue)
353 {
354  if (rKey == "spacing")
355  set_spacing(rValue.toInt32());
356  else if (rKey == "homogeneous")
357  set_homogeneous(toBool(rValue));
358  else
359  return VclContainer::set_property(rKey, rValue);
360  return true;
361 }
362 
363 boost::property_tree::ptree VclBox::DumpAsPropertyTree()
364 {
365  boost::property_tree::ptree aTree(VclContainer::DumpAsPropertyTree());
366  aTree.put("vertical", m_bVerticalContainer);
367  return aTree;
368 }
369 
371 {
372 #if defined(_WIN32)
373  //fdo#74284 call Boxes Panels, keep then as "Filler" under
374  //at least Linux seeing as that's what Gtk does for GtkBoxes
375  return css::accessibility::AccessibleRole::PANEL;
376 #else
377  return css::accessibility::AccessibleRole::FILLER;
378 #endif
379 }
380 
381 #define DEFAULT_CHILD_MIN_WIDTH 85
382 #define DEFAULT_CHILD_MIN_HEIGHT 27
383 
384 Size VclBox::finalizeMaxes(const Size &rSize, sal_uInt16 nVisibleChildren) const
385 {
386  Size aRet;
387 
388  if (nVisibleChildren)
389  {
390  long nPrimaryDimension = getPrimaryDimension(rSize);
391  if (m_bHomogeneous)
392  nPrimaryDimension *= nVisibleChildren;
393  setPrimaryDimension(aRet, nPrimaryDimension + m_nSpacing * (nVisibleChildren-1));
395  }
396 
397  return aRet;
398 }
399 
401 {
402  Size aRet;
403 
404  long nMainGroupDimension = getPrimaryDimension(rReq.m_aMainGroupSize);
405  long nSubGroupDimension = getPrimaryDimension(rReq.m_aSubGroupSize);
406 
407  setPrimaryDimension(aRet, nMainGroupDimension + nSubGroupDimension);
408 
412 
413  return aRet;
414 }
415 
416 static long getMaxNonOutlier(const std::vector<long> &rG, long nAvgDimension)
417 {
418  long nMaxDimensionNonOutlier = 0;
419  for (auto const& nPrimaryChildDimension : rG)
420  {
421  if (nPrimaryChildDimension < nAvgDimension * 1.5)
422  {
423  nMaxDimensionNonOutlier = std::max(nPrimaryChildDimension,
424  nMaxDimensionNonOutlier);
425  }
426  }
427  return nMaxDimensionNonOutlier;
428 }
429 
430 static std::vector<long> setButtonSizes(const std::vector<long> &rG,
431  const std::vector<bool> &rNonHomogeneous,
432  long nAvgDimension, long nMaxNonOutlier, long nMinWidth)
433 {
434  std::vector<long> aVec;
435  //set everything < 1.5 times the average to the same width, leave the
436  //outliers un-touched
437  std::vector<bool>::const_iterator aJ = rNonHomogeneous.begin();
438  auto nNonOutlierWidth = std::max(nMaxNonOutlier, nMinWidth);
439  for (auto const& nPrimaryChildDimension : rG)
440  {
441  bool bNonHomogeneous = *aJ;
442  if (!bNonHomogeneous && nPrimaryChildDimension < nAvgDimension * 1.5)
443  {
444  aVec.push_back(nNonOutlierWidth);
445  }
446  else
447  {
448  aVec.push_back(std::max(nPrimaryChildDimension, nMinWidth));
449  }
450  ++aJ;
451  }
452  return aVec;
453 }
454 
456 {
457  Requisition aReq;
458 
459  Size aMainGroupSize(DEFAULT_CHILD_MIN_WIDTH, DEFAULT_CHILD_MIN_HEIGHT); //to-do, pull from theme
460  Size aSubGroupSize(DEFAULT_CHILD_MIN_WIDTH, DEFAULT_CHILD_MIN_HEIGHT); //to-do, pull from theme
461 
462  long nMinMainGroupPrimary = getPrimaryDimension(aMainGroupSize);
463  long nMinSubGroupPrimary = getPrimaryDimension(aSubGroupSize);
464  long nMainGroupSecondary = getSecondaryDimension(aMainGroupSize);
465  long nSubGroupSecondary = getSecondaryDimension(aSubGroupSize);
466 
467  bool bIgnoreSecondaryPacking = (m_eLayoutStyle == VclButtonBoxStyle::Spread || m_eLayoutStyle == VclButtonBoxStyle::Center);
468 
469  std::vector<long> aMainGroupSizes;
470  std::vector<bool> aMainGroupNonHomogeneous;
471  std::vector<long> aSubGroupSizes;
472  std::vector<bool> aSubGroupNonHomogeneous;
473 
474  for (const vcl::Window *pChild = GetWindow(GetWindowType::FirstChild); pChild; pChild = pChild->GetWindow(GetWindowType::Next))
475  {
476  if (!pChild->IsVisible())
477  continue;
478  Size aChildSize = getLayoutRequisition(*pChild);
479  if (bIgnoreSecondaryPacking || !pChild->get_secondary())
480  {
481  //set the max secondary dimension
482  nMainGroupSecondary = std::max(nMainGroupSecondary, getSecondaryDimension(aChildSize));
483  //collect the primary dimensions
484  aMainGroupSizes.push_back(getPrimaryDimension(aChildSize));
485  aMainGroupNonHomogeneous.push_back(pChild->get_non_homogeneous());
486  }
487  else
488  {
489  nSubGroupSecondary = std::max(nSubGroupSecondary, getSecondaryDimension(aChildSize));
490  aSubGroupSizes.push_back(getPrimaryDimension(aChildSize));
491  aSubGroupNonHomogeneous.push_back(pChild->get_non_homogeneous());
492  }
493  }
494 
495  if (m_bHomogeneous)
496  {
497  long nMaxMainDimension = aMainGroupSizes.empty() ? 0 :
498  *std::max_element(aMainGroupSizes.begin(), aMainGroupSizes.end());
499  nMaxMainDimension = std::max(nMaxMainDimension, nMinMainGroupPrimary);
500  long nMaxSubDimension = aSubGroupSizes.empty() ? 0 :
501  *std::max_element(aSubGroupSizes.begin(), aSubGroupSizes.end());
502  nMaxSubDimension = std::max(nMaxSubDimension, nMinSubGroupPrimary);
503  long nMaxDimension = std::max(nMaxMainDimension, nMaxSubDimension);
504  aReq.m_aMainGroupDimensions.resize(aMainGroupSizes.size(), nMaxDimension);
505  aReq.m_aSubGroupDimensions.resize(aSubGroupSizes.size(), nMaxDimension);
506  }
507  else
508  {
509  //Ideally set everything to the same size, but find outlier widgets
510  //that are way wider than the average and leave them
511  //at their natural size and set the remainder to share the
512  //max size of the remaining members of the buttonbox
513  long nAccDimension = std::accumulate(aMainGroupSizes.begin(),
514  aMainGroupSizes.end(), 0);
515  nAccDimension = std::accumulate(aSubGroupSizes.begin(),
516  aSubGroupSizes.end(), nAccDimension);
517 
518  size_t nTotalSize = aMainGroupSizes.size() + aSubGroupSizes.size();
519 
520  long nAvgDimension = nTotalSize ? nAccDimension / nTotalSize : 0;
521 
522  long nMaxMainNonOutlier = getMaxNonOutlier(aMainGroupSizes,
523  nAvgDimension);
524  long nMaxSubNonOutlier = getMaxNonOutlier(aSubGroupSizes,
525  nAvgDimension);
526  long nMaxNonOutlier = std::max(nMaxMainNonOutlier, nMaxSubNonOutlier);
527 
528  aReq.m_aMainGroupDimensions = setButtonSizes(aMainGroupSizes,
529  aMainGroupNonHomogeneous,
530  nAvgDimension, nMaxNonOutlier, nMinMainGroupPrimary);
531  aReq.m_aSubGroupDimensions = setButtonSizes(aSubGroupSizes,
532  aSubGroupNonHomogeneous,
533  nAvgDimension, nMaxNonOutlier, nMinSubGroupPrimary);
534  }
535 
536  if (!aReq.m_aMainGroupDimensions.empty())
537  {
538  setSecondaryDimension(aReq.m_aMainGroupSize, nMainGroupSecondary);
540  std::accumulate(aReq.m_aMainGroupDimensions.begin(),
541  aReq.m_aMainGroupDimensions.end(), 0));
542  }
543  if (!aReq.m_aSubGroupDimensions.empty())
544  {
545  setSecondaryDimension(aReq.m_aSubGroupSize, nSubGroupSecondary);
547  std::accumulate(aReq.m_aSubGroupDimensions.begin(),
548  aReq.m_aSubGroupDimensions.end(), 0));
549  }
550 
551  return aReq;
552 }
553 
554 Size VclButtonBox::addSpacing(const Size &rSize, sal_uInt16 nVisibleChildren) const
555 {
556  Size aRet;
557 
558  if (nVisibleChildren)
559  {
560  long nPrimaryDimension = getPrimaryDimension(rSize);
561  setPrimaryDimension(aRet,
562  nPrimaryDimension + m_nSpacing * (nVisibleChildren-1));
564  }
565 
566  return aRet;
567 }
568 
570 {
572  sal_uInt16 nVisibleChildren = aReq.m_aMainGroupDimensions.size() +
573  aReq.m_aSubGroupDimensions.size();
574  return addSpacing(addReqGroups(aReq), nVisibleChildren);
575 }
576 
577 bool VclButtonBox::set_property(const OString &rKey, const OUString &rValue)
578 {
579  if (rKey == "layout-style")
580  {
582  if (rValue == "spread")
583  eStyle = VclButtonBoxStyle::Spread;
584  else if (rValue == "edge")
585  eStyle = VclButtonBoxStyle::Edge;
586  else if (rValue == "start")
587  eStyle = VclButtonBoxStyle::Start;
588  else if (rValue == "end")
589  eStyle = VclButtonBoxStyle::End;
590  else if (rValue == "center")
591  eStyle = VclButtonBoxStyle::Center;
592  else
593  {
594  SAL_WARN("vcl.layout", "unknown layout style " << rValue);
595  }
596  m_eLayoutStyle = eStyle;
597  }
598  else
599  return VclBox::set_property(rKey, rValue);
600  return true;
601 }
602 
603 void VclButtonBox::setAllocation(const Size &rAllocation)
604 {
606 
607  if (aReq.m_aMainGroupDimensions.empty() && aReq.m_aSubGroupDimensions.empty())
608  return;
609 
610  long nAllocPrimaryDimension = getPrimaryDimension(rAllocation);
611 
612  Point aMainGroupPos, aOtherGroupPos;
613  int nSpacing = m_nSpacing;
614 
615  //To-Do, other layout styles
616  switch (m_eLayoutStyle)
617  {
619  if (!aReq.m_aSubGroupDimensions.empty())
620  {
621  long nOtherPrimaryDimension = getPrimaryDimension(
623  setPrimaryCoordinate(aOtherGroupPos,
624  nAllocPrimaryDimension - nOtherPrimaryDimension);
625  }
626  break;
628  if (!aReq.m_aMainGroupDimensions.empty())
629  {
630  long nMainPrimaryDimension = getPrimaryDimension(
632  long nExtraSpace = nAllocPrimaryDimension - nMainPrimaryDimension;
633  nExtraSpace += (aReq.m_aMainGroupDimensions.size()-1) * nSpacing;
634  nSpacing = nExtraSpace/(aReq.m_aMainGroupDimensions.size()+1);
635  setPrimaryCoordinate(aMainGroupPos, nSpacing);
636  }
637  break;
639  if (!aReq.m_aMainGroupDimensions.empty())
640  {
641  long nMainPrimaryDimension = getPrimaryDimension(
643  long nExtraSpace = nAllocPrimaryDimension - nMainPrimaryDimension;
644  setPrimaryCoordinate(aMainGroupPos, nExtraSpace/2);
645  }
646  break;
647  default:
648  SAL_WARN("vcl.layout", "todo unimplemented layout style");
649  [[fallthrough]];
652  if (!aReq.m_aMainGroupDimensions.empty())
653  {
654  long nMainPrimaryDimension = getPrimaryDimension(
656  setPrimaryCoordinate(aMainGroupPos,
657  nAllocPrimaryDimension - nMainPrimaryDimension);
658  }
659  break;
660  }
661 
662  Size aChildSize;
663  setSecondaryDimension(aChildSize, getSecondaryDimension(rAllocation));
664 
665  std::vector<long>::const_iterator aPrimaryI = aReq.m_aMainGroupDimensions.begin();
666  std::vector<long>::const_iterator aSecondaryI = aReq.m_aSubGroupDimensions.begin();
667  bool bIgnoreSecondaryPacking = (m_eLayoutStyle == VclButtonBoxStyle::Spread || m_eLayoutStyle == VclButtonBoxStyle::Center);
668  for (vcl::Window *pChild = GetWindow(GetWindowType::FirstChild); pChild; pChild = pChild->GetWindow(GetWindowType::Next))
669  {
670  if (!pChild->IsVisible())
671  continue;
672 
673  if (bIgnoreSecondaryPacking || !pChild->get_secondary())
674  {
675  long nMainGroupPrimaryDimension = *aPrimaryI++;
676  setPrimaryDimension(aChildSize, nMainGroupPrimaryDimension);
677  setLayoutAllocation(*pChild, aMainGroupPos, aChildSize);
678  long nPrimaryCoordinate = getPrimaryCoordinate(aMainGroupPos);
679  setPrimaryCoordinate(aMainGroupPos, nPrimaryCoordinate + nMainGroupPrimaryDimension + nSpacing);
680  }
681  else
682  {
683  long nSubGroupPrimaryDimension = *aSecondaryI++;
684  setPrimaryDimension(aChildSize, nSubGroupPrimaryDimension);
685  setLayoutAllocation(*pChild, aOtherGroupPos, aChildSize);
686  long nPrimaryCoordinate = getPrimaryCoordinate(aOtherGroupPos);
687  setPrimaryCoordinate(aOtherGroupPos, nPrimaryCoordinate + nSubGroupPrimaryDimension + nSpacing);
688  }
689  }
690 }
691 
692 namespace {
693 
694 struct ButtonOrder
695 {
696  const char* m_aType;
697  int m_nPriority;
698 };
699 
700 }
701 
702 static int getButtonPriority(const OString &rType)
703 {
704  static const size_t N_TYPES = 6;
705  static const ButtonOrder aDiscardCancelSave[N_TYPES] =
706  {
707  { "/discard", 0 },
708  { "/cancel", 1 },
709  { "/no", 2 },
710  { "/save", 3 },
711  { "/yes", 3 },
712  { "/ok", 3 }
713  };
714 
715  static const ButtonOrder aSaveDiscardCancel[N_TYPES] =
716  {
717  { "/save", 0 },
718  { "/yes", 0 },
719  { "/ok", 0 },
720  { "/discard", 1 },
721  { "/no", 1 },
722  { "/cancel", 2 }
723  };
724 
725  const ButtonOrder* pOrder = &aDiscardCancelSave[0];
726 
727  const OUString &rEnv = Application::GetDesktopEnvironment();
728 
729  if (rEnv.equalsIgnoreAsciiCase("windows") ||
730  rEnv.equalsIgnoreAsciiCase("lxqt") ||
731  rEnv.startsWithIgnoreAsciiCase("plasma"))
732  {
733  pOrder = &aSaveDiscardCancel[0];
734  }
735 
736  for (size_t i = 0; i < N_TYPES; ++i, ++pOrder)
737  {
738  if (rType.endsWith(pOrder->m_aType))
739  return pOrder->m_nPriority;
740  }
741 
742  return -1;
743 }
744 
745 namespace {
746 
747 class sortButtons
748 {
749  bool m_bVerticalContainer;
750 public:
751  explicit sortButtons(bool bVerticalContainer)
752  : m_bVerticalContainer(bVerticalContainer)
753  {
754  }
755  bool operator()(const vcl::Window *pA, const vcl::Window *pB) const;
756 };
757 
758 }
759 
760 bool sortButtons::operator()(const vcl::Window *pA, const vcl::Window *pB) const
761 {
762  //sort into two groups of pack start and pack end
763  VclPackType ePackA = pA->get_pack_type();
764  VclPackType ePackB = pB->get_pack_type();
765  if (ePackA < ePackB)
766  return true;
767  if (ePackA > ePackB)
768  return false;
769  bool bPackA = pA->get_secondary();
770  bool bPackB = pB->get_secondary();
771  if (!m_bVerticalContainer)
772  {
773  //for horizontal boxes group secondaries before primaries
774  if (bPackA > bPackB)
775  return true;
776  if (bPackA < bPackB)
777  return false;
778  }
779  else
780  {
781  //for vertical boxes group secondaries after primaries
782  if (bPackA < bPackB)
783  return true;
784  if (bPackA > bPackB)
785  return false;
786  }
787 
788  //now order within groups according to platform rules
790 }
791 
793 {
794  std::vector<vcl::Window*> aChilds;
795  for (vcl::Window* pChild = GetWindow(GetWindowType::FirstChild); pChild;
796  pChild = pChild->GetWindow(GetWindowType::Next))
797  {
798  aChilds.push_back(pChild);
799  }
800 
801  //sort child order within parent so that we match the platform
802  //button order
803  std::stable_sort(aChilds.begin(), aChilds.end(), sortButtons(m_bVerticalContainer));
804  BuilderUtils::reorderWithinParent(aChilds, true);
805 }
806 
807 namespace {
808 
809 struct GridEntry
810 {
811  VclPtr<vcl::Window> pChild;
812  sal_Int32 nSpanWidth;
813  sal_Int32 nSpanHeight;
814  int x;
815  int y;
816  GridEntry()
817  : pChild(nullptr)
818  , nSpanWidth(0)
819  , nSpanHeight(0)
820  , x(-1)
821  , y(-1)
822  {
823  }
824 };
825 
826 }
827 
828 typedef boost::multi_array<GridEntry, 2> array_type;
829 
830 static array_type assembleGrid(const VclGrid &rGrid);
831 static bool isNullGrid(const array_type& A);
832 static void calcMaxs(const array_type &A, std::vector<VclGrid::Value> &rWidths, std::vector<VclGrid::Value> &rHeights);
833 
834 array_type assembleGrid(const VclGrid &rGrid)
835 {
836  array_type A;
837 
838  for (vcl::Window* pChild = rGrid.GetWindow(GetWindowType::FirstChild); pChild;
839  pChild = pChild->GetWindow(GetWindowType::Next))
840  {
841  sal_Int32 nLeftAttach = std::max<sal_Int32>(pChild->get_grid_left_attach(), 0);
842  sal_Int32 nWidth = pChild->get_grid_width();
843  sal_Int32 nMaxXPos = nLeftAttach+nWidth-1;
844 
845  sal_Int32 nTopAttach = std::max<sal_Int32>(pChild->get_grid_top_attach(), 0);
846  sal_Int32 nHeight = pChild->get_grid_height();
847  sal_Int32 nMaxYPos = nTopAttach+nHeight-1;
848 
849  sal_Int32 nCurrentMaxXPos = A.shape()[0]-1;
850  sal_Int32 nCurrentMaxYPos = A.shape()[1]-1;
851  if (nMaxXPos > nCurrentMaxXPos || nMaxYPos > nCurrentMaxYPos)
852  {
853  nCurrentMaxXPos = std::max(nMaxXPos, nCurrentMaxXPos);
854  nCurrentMaxYPos = std::max(nMaxYPos, nCurrentMaxYPos);
855  A.resize(boost::extents[nCurrentMaxXPos+1][nCurrentMaxYPos+1]);
856  }
857 
858  GridEntry &rEntry = A[nLeftAttach][nTopAttach];
859  rEntry.pChild = pChild;
860  rEntry.nSpanWidth = nWidth;
861  rEntry.nSpanHeight = nHeight;
862  rEntry.x = nLeftAttach;
863  rEntry.y = nTopAttach;
864 
865  for (sal_Int32 nSpanX = 0; nSpanX < nWidth; ++nSpanX)
866  {
867  for (sal_Int32 nSpanY = 0; nSpanY < nHeight; ++nSpanY)
868  {
869  GridEntry &rSpan = A[nLeftAttach+nSpanX][nTopAttach+nSpanY];
870  rSpan.x = nLeftAttach;
871  rSpan.y = nTopAttach;
872  }
873  }
874  }
875 
876  //see if we have any empty rows/cols
877  sal_Int32 nMaxX = A.shape()[0];
878  sal_Int32 nMaxY = A.shape()[1];
879 
880  std::vector<bool> aNonEmptyCols(nMaxX);
881  std::vector<bool> aNonEmptyRows(nMaxY);
882 
883  for (sal_Int32 x = 0; x < nMaxX; ++x)
884  {
885  for (sal_Int32 y = 0; y < nMaxY; ++y)
886  {
887  const GridEntry &rEntry = A[x][y];
888  const vcl::Window *pChild = rEntry.pChild;
889  if (pChild && pChild->IsVisible())
890  {
891  aNonEmptyCols[x] = true;
892  if (rGrid.get_column_homogeneous())
893  {
894  for (sal_Int32 nSpanX = 1; nSpanX < rEntry.nSpanWidth; ++nSpanX)
895  aNonEmptyCols[x+nSpanX] = true;
896  }
897  aNonEmptyRows[y] = true;
898  if (rGrid.get_row_homogeneous())
899  {
900  for (sal_Int32 nSpanY = 1; nSpanY < rEntry.nSpanHeight; ++nSpanY)
901  aNonEmptyRows[y+nSpanY] = true;
902  }
903  }
904  }
905  }
906 
907  if (!rGrid.get_column_homogeneous())
908  {
909  //reduce the spans of elements that span empty columns
910  for (sal_Int32 x = 0; x < nMaxX; ++x)
911  {
912  std::set<GridEntry*> candidates;
913  for (sal_Int32 y = 0; y < nMaxY; ++y)
914  {
915  if (aNonEmptyCols[x])
916  continue;
917  GridEntry &rSpan = A[x][y];
918  //cell x/y is spanned by the widget at cell rSpan.x/rSpan.y,
919  //just points back to itself if there's no cell spanning
920  if ((rSpan.x == -1) || (rSpan.y == -1))
921  {
922  //there is no entry for this cell, i.e. this is a cell
923  //with no widget in it, or spanned by any other widget
924  continue;
925  }
926  GridEntry &rEntry = A[rSpan.x][rSpan.y];
927  candidates.insert(&rEntry);
928  }
929  for (auto const& candidate : candidates)
930  {
931  GridEntry *pEntry = candidate;
932  --pEntry->nSpanWidth;
933  }
934  }
935  }
936 
937  if (!rGrid.get_row_homogeneous())
938  {
939  //reduce the spans of elements that span empty rows
940  for (sal_Int32 y = 0; y < nMaxY; ++y)
941  {
942  std::set<GridEntry*> candidates;
943  for (sal_Int32 x = 0; x < nMaxX; ++x)
944  {
945  if (aNonEmptyRows[y])
946  continue;
947  GridEntry &rSpan = A[x][y];
948  //cell x/y is spanned by the widget at cell rSpan.x/rSpan.y,
949  //just points back to itself if there's no cell spanning
950  if ((rSpan.x == -1) || (rSpan.y == -1))
951  {
952  //there is no entry for this cell, i.e. this is a cell
953  //with no widget in it, or spanned by any other widget
954  continue;
955  }
956  GridEntry &rEntry = A[rSpan.x][rSpan.y];
957  candidates.insert(&rEntry);
958  }
959  for (auto const& candidate : candidates)
960  {
961  GridEntry *pEntry = candidate;
962  --pEntry->nSpanHeight;
963  }
964  }
965  }
966 
967  sal_Int32 nNonEmptyCols = std::count(aNonEmptyCols.begin(), aNonEmptyCols.end(), true);
968  sal_Int32 nNonEmptyRows = std::count(aNonEmptyRows.begin(), aNonEmptyRows.end(), true);
969 
970  //make new grid without empty rows and columns
971  array_type B(boost::extents[nNonEmptyCols][nNonEmptyRows]);
972  for (sal_Int32 x = 0, x2 = 0; x < nMaxX; ++x)
973  {
974  if (!aNonEmptyCols[x])
975  continue;
976  for (sal_Int32 y = 0, y2 = 0; y < nMaxY; ++y)
977  {
978  if (!aNonEmptyRows[y])
979  continue;
980  GridEntry &rEntry = A[x][y];
981  B[x2][y2++] = rEntry;
982  }
983  ++x2;
984  }
985 
986  return B;
987 }
988 
989 static bool isNullGrid(const array_type &A)
990 {
991  sal_Int32 nMaxX = A.shape()[0];
992  sal_Int32 nMaxY = A.shape()[1];
993 
994  return !nMaxX || !nMaxY;
995 }
996 
997 static void calcMaxs(const array_type &A, std::vector<VclGrid::Value> &rWidths, std::vector<VclGrid::Value> &rHeights)
998 {
999  sal_Int32 nMaxX = A.shape()[0];
1000  sal_Int32 nMaxY = A.shape()[1];
1001 
1002  rWidths.resize(nMaxX);
1003  rHeights.resize(nMaxY);
1004 
1005  //first use the non spanning entries to set default width/heights
1006  for (sal_Int32 x = 0; x < nMaxX; ++x)
1007  {
1008  for (sal_Int32 y = 0; y < nMaxY; ++y)
1009  {
1010  const GridEntry &rEntry = A[x][y];
1011  const vcl::Window *pChild = rEntry.pChild;
1012  if (!pChild || !pChild->IsVisible())
1013  continue;
1014 
1015  sal_Int32 nWidth = rEntry.nSpanWidth;
1016  sal_Int32 nHeight = rEntry.nSpanHeight;
1017 
1018  for (sal_Int32 nSpanX = 0; nSpanX < nWidth; ++nSpanX)
1019  rWidths[x+nSpanX].m_bExpand |= pChild->get_hexpand();
1020 
1021  for (sal_Int32 nSpanY = 0; nSpanY < nHeight; ++nSpanY)
1022  rHeights[y+nSpanY].m_bExpand |= pChild->get_vexpand();
1023 
1024  if (nWidth == 1 || nHeight == 1)
1025  {
1026  Size aChildSize = VclContainer::getLayoutRequisition(*pChild);
1027  if (nWidth == 1)
1028  rWidths[x].m_nValue = std::max(rWidths[x].m_nValue, aChildSize.Width());
1029  if (nHeight == 1)
1030  rHeights[y].m_nValue = std::max(rHeights[y].m_nValue, aChildSize.Height());
1031  }
1032  }
1033  }
1034 
1035  //now use the spanning entries and split any extra sizes across expanding rows/cols
1036  //where possible
1037  for (sal_Int32 x = 0; x < nMaxX; ++x)
1038  {
1039  for (sal_Int32 y = 0; y < nMaxY; ++y)
1040  {
1041  const GridEntry &rEntry = A[x][y];
1042  const vcl::Window *pChild = rEntry.pChild;
1043  if (!pChild || !pChild->IsVisible())
1044  continue;
1045 
1046  sal_Int32 nWidth = rEntry.nSpanWidth;
1047  sal_Int32 nHeight = rEntry.nSpanHeight;
1048 
1049  if (nWidth == 1 && nHeight == 1)
1050  continue;
1051 
1052  Size aChildSize = VclContainer::getLayoutRequisition(*pChild);
1053 
1054  if (nWidth > 1)
1055  {
1056  sal_Int32 nExistingWidth = 0;
1057  for (sal_Int32 nSpanX = 0; nSpanX < nWidth; ++nSpanX)
1058  nExistingWidth += rWidths[x+nSpanX].m_nValue;
1059 
1060  sal_Int32 nExtraWidth = aChildSize.Width() - nExistingWidth;
1061 
1062  if (nExtraWidth > 0)
1063  {
1064  bool bForceExpandAll = false;
1065  sal_Int32 nExpandables = 0;
1066  for (sal_Int32 nSpanX = 0; nSpanX < nWidth; ++nSpanX)
1067  if (rWidths[x+nSpanX].m_bExpand)
1068  ++nExpandables;
1069  if (nExpandables == 0)
1070  {
1071  nExpandables = nWidth;
1072  bForceExpandAll = true;
1073  }
1074 
1075  for (sal_Int32 nSpanX = 0; nSpanX < nWidth; ++nSpanX)
1076  {
1077  if (rWidths[x+nSpanX].m_bExpand || bForceExpandAll)
1078  rWidths[x+nSpanX].m_nValue += nExtraWidth/nExpandables;
1079  }
1080  }
1081  }
1082 
1083  if (nHeight > 1)
1084  {
1085  sal_Int32 nExistingHeight = 0;
1086  for (sal_Int32 nSpanY = 0; nSpanY < nHeight; ++nSpanY)
1087  nExistingHeight += rHeights[y+nSpanY].m_nValue;
1088 
1089  sal_Int32 nExtraHeight = aChildSize.Height() - nExistingHeight;
1090 
1091  if (nExtraHeight > 0)
1092  {
1093  bool bForceExpandAll = false;
1094  sal_Int32 nExpandables = 0;
1095  for (sal_Int32 nSpanY = 0; nSpanY < nHeight; ++nSpanY)
1096  if (rHeights[y+nSpanY].m_bExpand)
1097  ++nExpandables;
1098  if (nExpandables == 0)
1099  {
1100  nExpandables = nHeight;
1101  bForceExpandAll = true;
1102  }
1103 
1104  for (sal_Int32 nSpanY = 0; nSpanY < nHeight; ++nSpanY)
1105  {
1106  if (rHeights[y+nSpanY].m_bExpand || bForceExpandAll)
1107  rHeights[y+nSpanY].m_nValue += nExtraHeight/nExpandables;
1108  }
1109  }
1110  }
1111  }
1112  }
1113 }
1114 
1115 static bool compareValues(const VclGrid::Value &i, const VclGrid::Value &j)
1116 {
1117  return i.m_nValue < j.m_nValue;
1118 }
1119 
1121 {
1122  VclGrid::Value aRet;
1123  aRet.m_nValue = i.m_nValue + j.m_nValue;
1124  aRet.m_bExpand = i.m_bExpand || j.m_bExpand;
1125  return aRet;
1126 }
1127 
1129 {
1131 }
1132 
1133 Size VclGrid::calculateRequisitionForSpacings(sal_Int32 nRowSpacing, sal_Int32 nColSpacing) const
1134 {
1135  array_type A = assembleGrid(*this);
1136 
1137  if (isNullGrid(A))
1138  return Size();
1139 
1140  std::vector<Value> aWidths;
1141  std::vector<Value> aHeights;
1142  calcMaxs(A, aWidths, aHeights);
1143 
1144  long nTotalWidth = 0;
1145  if (get_column_homogeneous())
1146  {
1147  nTotalWidth = std::max_element(aWidths.begin(), aWidths.end(), compareValues)->m_nValue;
1148  nTotalWidth *= aWidths.size();
1149  }
1150  else
1151  {
1152  nTotalWidth = std::accumulate(aWidths.begin(), aWidths.end(), Value(), accumulateValues).m_nValue;
1153  }
1154 
1155  nTotalWidth += nColSpacing * (aWidths.size()-1);
1156 
1157  long nTotalHeight = 0;
1158  if (get_row_homogeneous())
1159  {
1160  nTotalHeight = std::max_element(aHeights.begin(), aHeights.end(), compareValues)->m_nValue;
1161  nTotalHeight *= aHeights.size();
1162  }
1163  else
1164  {
1165  nTotalHeight = std::accumulate(aHeights.begin(), aHeights.end(), Value(), accumulateValues).m_nValue;
1166  }
1167 
1168  nTotalHeight += nRowSpacing * (aHeights.size()-1);
1169 
1170  return Size(nTotalWidth, nTotalHeight);
1171 }
1172 
1173 void VclGrid::setAllocation(const Size& rAllocation)
1174 {
1175  array_type A = assembleGrid(*this);
1176 
1177  if (isNullGrid(A))
1178  return;
1179 
1180  sal_Int32 nMaxX = A.shape()[0];
1181  sal_Int32 nMaxY = A.shape()[1];
1182 
1183  Size aRequisition;
1184  std::vector<Value> aWidths(nMaxX);
1185  std::vector<Value> aHeights(nMaxY);
1187  {
1188  aRequisition = calculateRequisition();
1189  calcMaxs(A, aWidths, aHeights);
1190  }
1191 
1192  sal_Int32 nColSpacing(get_column_spacing());
1193  sal_Int32 nRowSpacing(get_row_spacing());
1194 
1195  long nAvailableWidth = rAllocation.Width();
1196  if (nMaxX)
1197  nAvailableWidth -= nColSpacing * (nMaxX - 1);
1198  if (get_column_homogeneous())
1199  {
1200  for (sal_Int32 x = 0; x < nMaxX; ++x)
1201  aWidths[x].m_nValue = nAvailableWidth/nMaxX;
1202  }
1203  else if (rAllocation.Width() != aRequisition.Width())
1204  {
1205  sal_Int32 nExpandables = 0;
1206  for (sal_Int32 x = 0; x < nMaxX; ++x)
1207  if (aWidths[x].m_bExpand)
1208  ++nExpandables;
1209  long nExtraWidthForExpanders = nExpandables ? (rAllocation.Width() - aRequisition.Width()) / nExpandables : 0;
1210 
1211  //We don't fit and there is no volunteer to be shrunk
1212  if (!nExpandables && rAllocation.Width() < aRequisition.Width())
1213  {
1214  //first reduce spacing
1215  while (nColSpacing)
1216  {
1217  nColSpacing /= 2;
1218  aRequisition = calculateRequisitionForSpacings(nRowSpacing, nColSpacing);
1219  if (aRequisition.Width() <= rAllocation.Width())
1220  break;
1221  }
1222 
1223  //share out the remaining pain to everyone
1224  long nExtraWidth = (rAllocation.Width() - aRequisition.Width()) / nMaxX;
1225 
1226  for (sal_Int32 x = 0; x < nMaxX; ++x)
1227  aWidths[x].m_nValue += nExtraWidth;
1228  }
1229 
1230  if (nExtraWidthForExpanders)
1231  {
1232  for (sal_Int32 x = 0; x < nMaxX; ++x)
1233  if (aWidths[x].m_bExpand)
1234  aWidths[x].m_nValue += nExtraWidthForExpanders;
1235  }
1236  }
1237 
1238  long nAvailableHeight = rAllocation.Height();
1239  if (nMaxY)
1240  nAvailableHeight -= nRowSpacing * (nMaxY - 1);
1241  if (get_row_homogeneous())
1242  {
1243  for (sal_Int32 y = 0; y < nMaxY; ++y)
1244  aHeights[y].m_nValue = nAvailableHeight/nMaxY;
1245  }
1246  else if (rAllocation.Height() != aRequisition.Height())
1247  {
1248  sal_Int32 nExpandables = 0;
1249  for (sal_Int32 y = 0; y < nMaxY; ++y)
1250  if (aHeights[y].m_bExpand)
1251  ++nExpandables;
1252  long nExtraHeightForExpanders = nExpandables ? (rAllocation.Height() - aRequisition.Height()) / nExpandables : 0;
1253 
1254  //We don't fit and there is no volunteer to be shrunk
1255  if (!nExpandables && rAllocation.Height() < aRequisition.Height())
1256  {
1257  //first reduce spacing
1258  while (nRowSpacing)
1259  {
1260  nRowSpacing /= 2;
1261  aRequisition = calculateRequisitionForSpacings(nRowSpacing, nColSpacing);
1262  if (aRequisition.Height() <= rAllocation.Height())
1263  break;
1264  }
1265 
1266  //share out the remaining pain to everyone
1267  long nExtraHeight = (rAllocation.Height() - aRequisition.Height()) / nMaxY;
1268 
1269  for (sal_Int32 y = 0; y < nMaxY; ++y)
1270  aHeights[y].m_nValue += nExtraHeight;
1271  }
1272 
1273  if (nExtraHeightForExpanders)
1274  {
1275  for (sal_Int32 y = 0; y < nMaxY; ++y)
1276  if (aHeights[y].m_bExpand)
1277  aHeights[y].m_nValue += nExtraHeightForExpanders;
1278  }
1279  }
1280 
1281  Point aAllocPos(0, 0);
1282  for (sal_Int32 x = 0; x < nMaxX; ++x)
1283  {
1284  for (sal_Int32 y = 0; y < nMaxY; ++y)
1285  {
1286  GridEntry &rEntry = A[x][y];
1287  vcl::Window *pChild = rEntry.pChild;
1288  if (pChild)
1289  {
1290  Size aChildAlloc(0, 0);
1291 
1292  sal_Int32 nWidth = rEntry.nSpanWidth;
1293  for (sal_Int32 nSpanX = 0; nSpanX < nWidth; ++nSpanX)
1294  aChildAlloc.AdjustWidth(aWidths[x+nSpanX].m_nValue );
1295  aChildAlloc.AdjustWidth(nColSpacing*(nWidth-1) );
1296 
1297  sal_Int32 nHeight = rEntry.nSpanHeight;
1298  for (sal_Int32 nSpanY = 0; nSpanY < nHeight; ++nSpanY)
1299  aChildAlloc.AdjustHeight(aHeights[y+nSpanY].m_nValue );
1300  aChildAlloc.AdjustHeight(nRowSpacing*(nHeight-1) );
1301 
1302  setLayoutAllocation(*pChild, aAllocPos, aChildAlloc);
1303  }
1304  aAllocPos.AdjustY(aHeights[y].m_nValue + nRowSpacing );
1305  }
1306  aAllocPos.AdjustX(aWidths[x].m_nValue + nColSpacing );
1307  aAllocPos.setY( 0 );
1308  }
1309 }
1310 
1311 boost::property_tree::ptree VclGrid::DumpAsPropertyTree()
1312 {
1313  boost::property_tree::ptree aTree(VclContainer::DumpAsPropertyTree());
1314  aTree.put("type", "grid");
1315  return aTree;
1316 }
1317 
1318 bool toBool(const OUString &rValue)
1319 {
1320  return (!rValue.isEmpty() && (rValue[0] == 't' || rValue[0] == 'T' || rValue[0] == '1'));
1321 }
1322 
1323 bool VclGrid::set_property(const OString &rKey, const OUString &rValue)
1324 {
1325  if (rKey == "row-spacing")
1326  set_row_spacing(rValue.toInt32());
1327  else if (rKey == "column-spacing")
1328  set_column_spacing(rValue.toInt32());
1329  else if (rKey == "row-homogeneous")
1330  m_bRowHomogeneous = toBool(rValue);
1331  else if (rKey == "column-homogeneous")
1332  m_bColumnHomogeneous = toBool(rValue);
1333  else if (rKey == "n-rows")
1334  /*nothing to do*/;
1335  else
1336  return VclContainer::set_property(rKey, rValue);
1337  return true;
1338 }
1339 
1340 const vcl::Window *VclBin::get_child() const
1341 {
1342  const WindowImpl* pWindowImpl = ImplGetWindowImpl();
1343 
1344  return pWindowImpl->mpFirstChild;
1345 }
1346 
1347 vcl::Window *VclBin::get_child()
1348 {
1349  return const_cast<vcl::Window*>(const_cast<const VclBin*>(this)->get_child());
1350 }
1351 
1352 Size VclBin::calculateRequisition() const
1353 {
1354  const vcl::Window *pChild = get_child();
1355  if (pChild && pChild->IsVisible())
1356  return getLayoutRequisition(*pChild);
1357  return Size(0, 0);
1358 }
1359 
1360 void VclBin::setAllocation(const Size &rAllocation)
1361 {
1362  vcl::Window *pChild = get_child();
1363  if (pChild && pChild->IsVisible())
1364  setLayoutAllocation(*pChild, Point(0, 0), rAllocation);
1365 }
1366 
1368 {
1369  disposeOnce();
1370 }
1371 
1373 {
1374  m_pLabel.clear();
1375  VclBin::dispose();
1376 }
1377 
1378 //To-Do, hook a DecorationView into VclFrame ?
1379 
1381 {
1382  Size aRet(0, 0);
1383 
1384  const vcl::Window *pChild = get_child();
1385  const vcl::Window *pLabel = get_label_widget();
1386 
1387  if (pChild && pChild->IsVisible())
1388  aRet = getLayoutRequisition(*pChild);
1389 
1390  if (pLabel && pLabel->IsVisible())
1391  {
1392  Size aLabelSize = getLayoutRequisition(*pLabel);
1393  aRet.AdjustHeight(aLabelSize.Height() );
1394  aRet.setWidth( std::max(aLabelSize.Width(), aRet.Width()) );
1395  }
1396 
1397  return aRet;
1398 }
1399 
1400 void VclFrame::setAllocation(const Size &rAllocation)
1401 {
1402  //SetBackground( Color(0xFF, 0x00, 0xFF) );
1403 
1404  Size aAllocation(rAllocation);
1405  Point aChildPos;
1406 
1407  vcl::Window *pChild = get_child();
1408  vcl::Window *pLabel = get_label_widget();
1409 
1410  if (pLabel && pLabel->IsVisible())
1411  {
1412  Size aLabelSize = getLayoutRequisition(*pLabel);
1413  aLabelSize.setHeight( std::min(aLabelSize.Height(), aAllocation.Height()) );
1414  aLabelSize.setWidth( std::min(aLabelSize.Width(), aAllocation.Width()) );
1415  setLayoutAllocation(*pLabel, aChildPos, aLabelSize);
1416  aAllocation.AdjustHeight( -(aLabelSize.Height()) );
1417  aChildPos.AdjustY(aLabelSize.Height() );
1418  }
1419 
1420  if (pChild && pChild->IsVisible())
1421  setLayoutAllocation(*pChild, aChildPos, aAllocation);
1422 }
1423 
1424 IMPL_LINK(VclFrame, WindowEventListener, VclWindowEvent&, rEvent, void)
1425 {
1426  if (rEvent.GetId() == VclEventId::ObjectDying)
1427  designate_label(nullptr);
1428 }
1429 
1431 {
1432  assert(!pWindow || pWindow->GetParent() == this);
1433  if (m_pLabel)
1434  m_pLabel->RemoveEventListener(LINK(this, VclFrame, WindowEventListener));
1435  m_pLabel = pWindow;
1436  if (m_pLabel)
1437  m_pLabel->AddEventListener(LINK(this, VclFrame, WindowEventListener));
1438 }
1439 
1441 {
1442  assert(GetChildCount() == 2);
1443  if (m_pLabel)
1444  return m_pLabel;
1445  //The label widget is normally the first (of two) children
1446  const WindowImpl* pWindowImpl = ImplGetWindowImpl();
1447  if (pWindowImpl->mpFirstChild == pWindowImpl->mpLastChild) //no label exists
1448  return nullptr;
1449  return pWindowImpl->mpFirstChild;
1450 }
1451 
1453 {
1454  return const_cast<vcl::Window*>(const_cast<const VclFrame*>(this)->get_label_widget());
1455 }
1456 
1458 {
1459  //The child widget is the normally the last (of two) children
1460  const WindowImpl* pWindowImpl = ImplGetWindowImpl();
1461  assert(GetChildCount() == 2 || pWindowImpl->mbInDispose);
1462  if (!m_pLabel)
1463  return pWindowImpl->mpLastChild;
1464  if (pWindowImpl->mpFirstChild == pWindowImpl->mpLastChild) //only label exists
1465  return nullptr;
1466  return pWindowImpl->mpLastChild;
1467 }
1468 
1470 {
1471  return const_cast<vcl::Window*>(const_cast<const VclFrame*>(this)->get_child());
1472 }
1473 
1474 void VclFrame::set_label(const OUString &rLabel)
1475 {
1476  vcl::Window *pLabel = get_label_widget();
1477  assert(pLabel);
1478  pLabel->SetText(rLabel);
1479 }
1480 
1481 OUString VclFrame::get_label() const
1482 {
1483  const vcl::Window *pLabel = get_label_widget();
1484  assert(pLabel);
1485  return pLabel->GetText();
1486 }
1487 
1489 {
1490  const vcl::Window *pLabel = get_label_widget();
1491  if (pLabel)
1492  return pLabel->GetAccessibleName();
1493  return VclBin::getDefaultAccessibleName();
1494 }
1495 
1496 boost::property_tree::ptree VclFrame::DumpAsPropertyTree()
1497 {
1498  boost::property_tree::ptree aTree(VclBin::DumpAsPropertyTree());
1499  aTree.put("type", "frame");
1500  return aTree;
1501 }
1502 
1503 Size VclAlignment::calculateRequisition() const
1504 {
1505  Size aRet(m_nLeftPadding + m_nRightPadding,
1506  m_nTopPadding + m_nBottomPadding);
1507 
1508  const vcl::Window *pChild = get_child();
1509  if (pChild && pChild->IsVisible())
1510  {
1511  Size aChildSize = getLayoutRequisition(*pChild);
1512  aRet.AdjustWidth(aChildSize.Width() );
1513  aRet.AdjustHeight(aChildSize.Height() );
1514  }
1515 
1516  return aRet;
1517 }
1518 
1519 void VclAlignment::setAllocation(const Size &rAllocation)
1520 {
1521  vcl::Window *pChild = get_child();
1522  if (!pChild || !pChild->IsVisible())
1523  return;
1524 
1525  Point aChildPos(m_nLeftPadding, m_nTopPadding);
1526 
1527  Size aAllocation;
1528  aAllocation.setWidth( rAllocation.Width() - (m_nLeftPadding + m_nRightPadding) );
1529  aAllocation.setHeight( rAllocation.Height() - (m_nTopPadding + m_nBottomPadding) );
1530 
1531  setLayoutAllocation(*pChild, aChildPos, aAllocation);
1532 }
1533 
1534 bool VclAlignment::set_property(const OString &rKey, const OUString &rValue)
1535 {
1536  if (rKey == "bottom-padding")
1537  m_nBottomPadding = rValue.toInt32();
1538  else if (rKey == "left-padding")
1539  m_nLeftPadding = rValue.toInt32();
1540  else if (rKey == "right-padding")
1541  m_nRightPadding = rValue.toInt32();
1542  else if (rKey == "top-padding")
1543  m_nTopPadding = rValue.toInt32();
1544  else
1545  return VclBin::set_property(rKey, rValue);
1546  return true;
1547 }
1548 
1549 class DisclosureButton final : public CheckBox
1550 {
1551  virtual void ImplDrawCheckBoxState(vcl::RenderContext& rRenderContext) override
1552  {
1553  /* HACK: DisclosureButton is currently assuming, that the disclosure sign
1554  will fit into the rectangle occupied by a normal checkbox on all themes.
1555  If this does not hold true for some theme, ImplGetCheckImageSize
1556  would have to be overridden for DisclosureButton; also GetNativeControlRegion
1557  for ControlType::ListNode would have to be implemented and taken into account
1558  */
1559 
1560  tools::Rectangle aStateRect(GetStateRect());
1561 
1563  tools::Rectangle aCtrlRegion(aStateRect);
1565 
1566  if (HasFocus())
1567  nState |= ControlState::FOCUSED;
1569  nState |= ControlState::DEFAULT;
1570  if (Window::IsEnabled())
1571  nState |= ControlState::ENABLED;
1572  if (IsMouseOver() && GetMouseRect().IsInside(GetPointerPosPixel()))
1573  nState |= ControlState::ROLLOVER;
1574 
1575  if (rRenderContext.DrawNativeControl(ControlType::ListNode, ControlPart::Entire, aCtrlRegion,
1576  nState, aControlValue, OUString()))
1577  return;
1578 
1579  ImplSVCtrlData& rCtrlData(ImplGetSVData()->maCtrlData);
1580  if (!rCtrlData.mpDisclosurePlus)
1581  rCtrlData.mpDisclosurePlus.reset(new Image(StockImage::Yes, SV_DISCLOSURE_PLUS));
1582  if (!rCtrlData.mpDisclosureMinus)
1583  rCtrlData.mpDisclosureMinus.reset(new Image(StockImage::Yes, SV_DISCLOSURE_MINUS));
1584 
1585  Image* pImg
1586  = IsChecked() ? rCtrlData.mpDisclosureMinus.get() : rCtrlData.mpDisclosurePlus.get();
1587 
1589  if (!IsEnabled())
1590  nStyle |= DrawImageFlags::Disable;
1591 
1592  Size aSize(aStateRect.GetSize());
1593  Size aImgSize(pImg->GetSizePixel());
1594  Point aOff((aSize.Width() - aImgSize.Width()) / 2,
1595  (aSize.Height() - aImgSize.Height()) / 2);
1596  aOff += aStateRect.TopLeft();
1597  rRenderContext.DrawImage(aOff, *pImg, nStyle);
1598  }
1599 
1600 public:
1601  explicit DisclosureButton(vcl::Window* pParent)
1602  : CheckBox(pParent, 0)
1603  {
1604  }
1605 
1606  virtual void KeyInput( const KeyEvent& rKEvt ) override
1607  {
1608  vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
1609 
1610  if( !aKeyCode.GetModifier() &&
1611  ( ( aKeyCode.GetCode() == KEY_ADD ) ||
1612  ( aKeyCode.GetCode() == KEY_SUBTRACT ) )
1613  )
1614  {
1615  Check( aKeyCode.GetCode() == KEY_ADD );
1616  }
1617  else
1618  CheckBox::KeyInput( rKEvt );
1619  }
1620 };
1621 
1623  : VclBin(pParent)
1624  , m_bResizeTopLevel(true)
1625  , m_pDisclosureButton(VclPtr<DisclosureButton>::Create(this))
1626 {
1627  m_pDisclosureButton->SetToggleHdl(LINK(this, VclExpander, ClickHdl));
1629 }
1630 
1632 {
1633  disposeOnce();
1634 }
1635 
1637 {
1638  return m_pDisclosureButton->IsChecked();
1639 }
1640 
1641 void VclExpander::set_expanded(bool bExpanded)
1642 {
1643  m_pDisclosureButton->Check(bExpanded);
1644 }
1645 
1646 void VclExpander::set_label(const OUString& rLabel)
1647 {
1648  m_pDisclosureButton->SetText(rLabel);
1649 }
1650 
1652 {
1654  VclBin::dispose();
1655 }
1656 
1658 {
1659  const WindowImpl* pWindowImpl = ImplGetWindowImpl();
1660 
1661  assert(pWindowImpl->mpFirstChild == m_pDisclosureButton);
1662 
1663  return pWindowImpl->mpFirstChild->GetWindow(GetWindowType::Next);
1664 }
1665 
1667 {
1668  return const_cast<vcl::Window*>(const_cast<const VclExpander*>(this)->get_child());
1669 }
1670 
1672 {
1673  Size aRet(0, 0);
1674 
1675  WindowImpl* pWindowImpl = ImplGetWindowImpl();
1676 
1677  const vcl::Window *pChild = get_child();
1678  const vcl::Window *pLabel = pChild != pWindowImpl->mpLastChild ? pWindowImpl->mpLastChild.get() : nullptr;
1679 
1680  if (pChild && pChild->IsVisible() && m_pDisclosureButton->IsChecked())
1681  aRet = getLayoutRequisition(*pChild);
1682 
1683  Size aExpanderSize = getLayoutRequisition(*m_pDisclosureButton);
1684 
1685  if (pLabel && pLabel->IsVisible())
1686  {
1687  Size aLabelSize = getLayoutRequisition(*pLabel);
1688  aExpanderSize.setHeight( std::max(aExpanderSize.Height(), aLabelSize.Height()) );
1689  aExpanderSize.AdjustWidth(aLabelSize.Width() );
1690  }
1691 
1692  aRet.AdjustHeight(aExpanderSize.Height() );
1693  aRet.setWidth( std::max(aExpanderSize.Width(), aRet.Width()) );
1694 
1695  return aRet;
1696 }
1697 
1698 void VclExpander::setAllocation(const Size &rAllocation)
1699 {
1700  Size aAllocation(rAllocation);
1701  Point aChildPos;
1702 
1703  WindowImpl* pWindowImpl = ImplGetWindowImpl();
1704 
1705  //The label widget is the last (of two) children
1706  vcl::Window *pChild = get_child();
1707  vcl::Window *pLabel = pChild != pWindowImpl->mpLastChild.get() ? pWindowImpl->mpLastChild.get() : nullptr;
1708 
1709  Size aButtonSize = getLayoutRequisition(*m_pDisclosureButton);
1710  Size aLabelSize;
1711  Size aExpanderSize = aButtonSize;
1712  if (pLabel && pLabel->IsVisible())
1713  {
1714  aLabelSize = getLayoutRequisition(*pLabel);
1715  aExpanderSize.setHeight( std::max(aExpanderSize.Height(), aLabelSize.Height()) );
1716  aExpanderSize.AdjustWidth(aLabelSize.Width() );
1717  }
1718 
1719  aExpanderSize.setHeight( std::min(aExpanderSize.Height(), aAllocation.Height()) );
1720  aExpanderSize.setWidth( std::min(aExpanderSize.Width(), aAllocation.Width()) );
1721 
1722  aButtonSize.setHeight( std::min(aButtonSize.Height(), aExpanderSize.Height()) );
1723  aButtonSize.setWidth( std::min(aButtonSize.Width(), aExpanderSize.Width()) );
1724 
1725  long nExtraExpanderHeight = aExpanderSize.Height() - aButtonSize.Height();
1726  Point aButtonPos(aChildPos.X(), aChildPos.Y() + nExtraExpanderHeight/2);
1727  setLayoutAllocation(*m_pDisclosureButton, aButtonPos, aButtonSize);
1728 
1729  if (pLabel && pLabel->IsVisible())
1730  {
1731  aLabelSize.setHeight( std::min(aLabelSize.Height(), aExpanderSize.Height()) );
1732  aLabelSize.setWidth( std::min(aLabelSize.Width(),
1733  aExpanderSize.Width() - aButtonSize.Width()) );
1734 
1735  long nExtraLabelHeight = aExpanderSize.Height() - aLabelSize.Height();
1736  Point aLabelPos(aChildPos.X() + aButtonSize.Width(), aChildPos.Y() + nExtraLabelHeight/2);
1737  setLayoutAllocation(*pLabel, aLabelPos, aLabelSize);
1738  }
1739 
1740  aAllocation.AdjustHeight( -(aExpanderSize.Height()) );
1741  aChildPos.AdjustY(aExpanderSize.Height() );
1742 
1743  if (pChild && pChild->IsVisible())
1744  {
1746  aAllocation = Size();
1747  setLayoutAllocation(*pChild, aChildPos, aAllocation);
1748  }
1749 }
1750 
1751 bool VclExpander::set_property(const OString &rKey, const OUString &rValue)
1752 {
1753  if (rKey == "expanded")
1754  set_expanded(toBool(rValue));
1755  else if (rKey == "resize-toplevel")
1756  m_bResizeTopLevel = toBool(rValue);
1757  else
1758  return VclBin::set_property(rKey, rValue);
1759  return true;
1760 }
1761 
1763 {
1764  VclBin::StateChanged( nType );
1765 
1766  if (nType == StateChangedType::InitShow)
1767  {
1768  vcl::Window *pChild = get_child();
1769  if (pChild)
1770  pChild->Show(m_pDisclosureButton->IsChecked());
1771  }
1772 }
1773 
1774 IMPL_LINK( VclExpander, ClickHdl, CheckBox&, rBtn, void )
1775 {
1776  vcl::Window *pChild = get_child();
1777  if (pChild)
1778  {
1779  pChild->Show(rBtn.IsChecked());
1780  queue_resize();
1781  Dialog* pResizeDialog = m_bResizeTopLevel ? GetParentDialog() : nullptr;
1782  if (pResizeDialog)
1783  pResizeDialog->setOptimalLayoutSize();
1784  }
1785  maExpandedHdl.Call(*this);
1786 }
1787 
1790  , m_bUserManagedScrolling(false)
1791  , m_eDrawFrameStyle(DrawFrameStyle::NONE)
1792  , m_pVScroll(VclPtr<ScrollBar>::Create(this, WB_HIDE | WB_VERT))
1793  , m_pHScroll(VclPtr<ScrollBar>::Create(this, WB_HIDE | WB_HORZ))
1794  , m_aScrollBarBox(VclPtr<ScrollBarBox>::Create(this, WB_HIDE))
1795 {
1796  SetType(WindowType::SCROLLWINDOW);
1797 
1798  Link<ScrollBar*,void> aLink( LINK( this, VclScrolledWindow, ScrollBarHdl ) );
1799  m_pVScroll->SetScrollHdl(aLink);
1800  m_pHScroll->SetScrollHdl(aLink);
1801 }
1802 
1804 {
1808  VclBin::dispose();
1809 }
1810 
1812 {
1813  vcl::Window *pChild = get_child();
1814  if (!pChild)
1815  return;
1816 
1817  assert(dynamic_cast<VclViewport*>(pChild) && "scrolledwindow child should be a Viewport");
1818 
1819  pChild = pChild->GetWindow(GetWindowType::FirstChild);
1820 
1821  if (!pChild)
1822  return;
1823 
1824  Point aWinPos(-m_pHScroll->GetThumbPos(), -m_pVScroll->GetThumbPos());
1825  pChild->SetPosPixel(aWinPos);
1826 }
1827 
1829 {
1830  const WindowImpl* pWindowImpl = ImplGetWindowImpl();
1831  assert(GetChildCount() == 4 || pWindowImpl->mbInDispose);
1832  return pWindowImpl->mpLastChild;
1833 }
1834 
1836 {
1837  return const_cast<vcl::Window*>(const_cast<const VclScrolledWindow*>(this)->get_child());
1838 }
1839 
1841 {
1842  Size aRet(0, 0);
1843 
1844  const vcl::Window *pChild = get_child();
1845  if (pChild && pChild->IsVisible())
1846  aRet = getLayoutRequisition(*pChild);
1847 
1848  if (GetStyle() & WB_VSCROLL)
1849  aRet.AdjustWidth(getLayoutRequisition(*m_pVScroll).Width() );
1850 
1851  if (GetStyle() & WB_HSCROLL)
1852  aRet.AdjustHeight(getLayoutRequisition(*m_pHScroll).Height() );
1853 
1854  aRet.AdjustHeight(2);
1855  aRet.AdjustWidth(2);
1856 
1857  return aRet;
1858 }
1859 
1861 {
1862  const vcl::Window *pChild = get_child();
1863  if (!pChild || !pChild->IsVisible())
1864  return;
1865 
1866  Size aOutSize(getVisibleChildSize());
1867 
1868  m_pVScroll->SetRangeMax(rRequest.Height());
1869  m_pVScroll->SetVisibleSize(aOutSize.Height());
1870  m_pVScroll->SetPageSize(16);
1871 
1872  m_pHScroll->SetRangeMax(rRequest.Width());
1873  m_pHScroll->SetVisibleSize(aOutSize.Width());
1874  m_pHScroll->SetPageSize(16);
1875 
1876  m_pVScroll->Scroll();
1877  m_pHScroll->Scroll();
1878 }
1879 
1880 void VclScrolledWindow::doSetAllocation(const Size &rAllocation, bool bRetryOnFailure)
1881 {
1882  Size aChildReq;
1883 
1884  vcl::Window *pChild = get_child();
1885  if (pChild && pChild->IsVisible())
1886  aChildReq = getLayoutRequisition(*pChild);
1887 
1888  long nAvailHeight = rAllocation.Height() - 2;
1889  long nAvailWidth = rAllocation.Width() - 2;
1890  // vert. ScrollBar
1891  if (GetStyle() & WB_AUTOVSCROLL)
1892  {
1893  m_pVScroll->Show(nAvailHeight < aChildReq.Height());
1894  }
1895  else if (m_pVScroll->IsVisible() != bool(GetStyle() & WB_VSCROLL))
1896  m_pVScroll->Show((GetStyle() & WB_VSCROLL) != 0);
1897 
1898  if (m_pVScroll->IsVisible())
1899  nAvailWidth -= getLayoutRequisition(*m_pVScroll).Width();
1900 
1901  // horz. ScrollBar
1902  if (GetStyle() & WB_AUTOHSCROLL)
1903  {
1904  bool bShowHScroll = nAvailWidth < aChildReq.Width();
1905  m_pHScroll->Show(bShowHScroll);
1906 
1907  if (bShowHScroll)
1908  nAvailHeight -= getLayoutRequisition(*m_pHScroll).Height();
1909 
1910  if (GetStyle() & WB_AUTOVSCROLL)
1911  m_pVScroll->Show(nAvailHeight < aChildReq.Height());
1912  }
1913  else if (m_pHScroll->IsVisible() != bool(GetStyle() & WB_HSCROLL))
1914  m_pHScroll->Show((GetStyle() & WB_HSCROLL) != 0);
1915 
1916  Size aInnerSize(rAllocation);
1917  aInnerSize.AdjustWidth(-2);
1918  aInnerSize.AdjustHeight(-2);
1919 
1920  bool bBothVisible = m_pVScroll->IsVisible() && m_pHScroll->IsVisible();
1921  auto nScrollBarWidth = getLayoutRequisition(*m_pVScroll).Width();
1922  auto nScrollBarHeight = getLayoutRequisition(*m_pHScroll).Height();
1923 
1924  if (m_pVScroll->IsVisible())
1925  {
1926  Point aScrollPos(rAllocation.Width() - nScrollBarWidth - 2, 1);
1927  Size aScrollSize(nScrollBarWidth, rAllocation.Height() - 2);
1928  if (bBothVisible)
1929  aScrollSize.AdjustHeight(-nScrollBarHeight);
1930  setLayoutAllocation(*m_pVScroll, aScrollPos, aScrollSize);
1931  aInnerSize.AdjustWidth( -nScrollBarWidth );
1932  }
1933 
1934  if (m_pHScroll->IsVisible())
1935  {
1936  Point aScrollPos(1, rAllocation.Height() - nScrollBarHeight);
1937  Size aScrollSize(rAllocation.Width() - 2, nScrollBarHeight);
1938  if (bBothVisible)
1939  aScrollSize.AdjustWidth(-nScrollBarWidth);
1940  setLayoutAllocation(*m_pHScroll, aScrollPos, aScrollSize);
1941  aInnerSize.AdjustHeight( -nScrollBarHeight );
1942  }
1943 
1944  if (bBothVisible)
1945  {
1946  Point aBoxPos(aInnerSize.Width() + 1, aInnerSize.Height() + 1);
1947  m_aScrollBarBox->SetPosSizePixel(aBoxPos, Size(nScrollBarWidth, nScrollBarHeight));
1948  m_aScrollBarBox->Show();
1949  }
1950  else
1951  {
1952  m_aScrollBarBox->Hide();
1953  }
1954 
1955  if (pChild && pChild->IsVisible())
1956  {
1957  assert(dynamic_cast<VclViewport*>(pChild) && "scrolledwindow child should be a Viewport");
1958 
1959  WinBits nOldBits = (GetStyle() & (WB_AUTOVSCROLL | WB_VSCROLL | WB_AUTOHSCROLL | WB_HSCROLL));
1960 
1961  setLayoutAllocation(*pChild, Point(1, 1), aInnerSize);
1962 
1963  // tdf#128758 if the layout allocation triggered some callback that
1964  // immediately invalidates the layout by adding scrollbars then
1965  // normally this would simply retrigger layout and another toplevel
1966  // attempt is made later. But the initial layout attempt blocks
1967  // relayouts, so just make another single effort here.
1968  WinBits nNewBits = (GetStyle() & (WB_AUTOVSCROLL | WB_VSCROLL | WB_AUTOHSCROLL | WB_HSCROLL));
1969  if (nOldBits != nNewBits && bRetryOnFailure)
1970  {
1971  doSetAllocation(rAllocation, false);
1972  return;
1973  }
1974  }
1975 
1977  InitScrollBars(aChildReq);
1978 }
1979 
1980 void VclScrolledWindow::setAllocation(const Size &rAllocation)
1981 {
1982  doSetAllocation(rAllocation, true);
1983 }
1984 
1986 {
1987  Size aRet(GetSizePixel());
1988  if (m_pVScroll->IsVisible())
1989  aRet.AdjustWidth( -(m_pVScroll->GetSizePixel().Width()) );
1990  if (m_pHScroll->IsVisible())
1991  aRet.AdjustHeight( -(m_pHScroll->GetSizePixel().Height()) );
1992  aRet.AdjustHeight(-2);
1993  aRet.AdjustWidth(-2);
1994  return aRet;
1995 }
1996 
1997 bool VclScrolledWindow::set_property(const OString &rKey, const OUString &rValue)
1998 {
1999  if (rKey == "shadow-type")
2000  {
2001  // despite the style names, this looks like the best mapping
2002  if (rValue == "in")
2004  else if (rValue == "out")
2006  else if (rValue == "etched-in")
2008  else if (rValue == "etched-out")
2010  else if (rValue == "none")
2012  return true;
2013  }
2014 
2015  bool bRet = VclBin::set_property(rKey, rValue);
2016  m_pVScroll->Show((GetStyle() & WB_VSCROLL) != 0);
2017  m_pHScroll->Show((GetStyle() & WB_HSCROLL) != 0);
2018  return bRet;
2019 }
2020 
2022 {
2023  bool bDone = false;
2024  if ( rNEvt.GetType() == MouseNotifyEvent::COMMAND )
2025  {
2026  const CommandEvent& rCEvt = *rNEvt.GetCommandEvent();
2027  if ( rCEvt.GetCommand() == CommandEventId::Wheel )
2028  {
2029  const CommandWheelData* pData = rCEvt.GetWheelData();
2030  if( !pData->GetModifier() && ( pData->GetMode() == CommandWheelMode::SCROLL ) )
2031  {
2032  bDone = HandleScrollCommand(rCEvt, m_pHScroll, m_pVScroll);
2033  }
2034  }
2035  }
2036 
2037  return bDone || VclBin::EventNotify( rNEvt );
2038 }
2039 
2041 {
2042  VclBin::Paint(rRenderContext, rRect);
2043  DecorationView aDecoView(&rRenderContext);
2044  aDecoView.DrawFrame(tools::Rectangle(Point(0,0), GetSizePixel()), m_eDrawFrameStyle);
2045 }
2046 
2047 void VclViewport::setAllocation(const Size &rAllocation)
2048 {
2049  vcl::Window *pChild = get_child();
2050  if (pChild && pChild->IsVisible())
2051  {
2052  Size aReq(getLayoutRequisition(*pChild));
2053  aReq.setWidth( std::max(aReq.Width(), rAllocation.Width()) );
2054  aReq.setHeight( std::max(aReq.Height(), rAllocation.Height()) );
2055  Point aKeepPos(pChild->GetPosPixel());
2057  {
2058  aKeepPos = Point(0, 0);
2059  m_bInitialAllocation = false;
2060  }
2061  setLayoutAllocation(*pChild, aKeepPos, aReq);
2062  }
2063 }
2064 
2066 {
2067  const WindowImpl* pWindowImpl = ImplGetWindowImpl();
2068 
2069  assert(pWindowImpl->mpFirstChild.get() == m_aEventBoxHelper.get());
2070 
2071  return pWindowImpl->mpFirstChild->GetWindow(GetWindowType::Next);
2072 }
2073 
2075 {
2076  return const_cast<vcl::Window*>(const_cast<const VclEventBox*>(this)->get_child());
2077 }
2078 
2079 void VclEventBox::setAllocation(const Size& rAllocation)
2080 {
2081  Point aChildPos(0, 0);
2082  for (vcl::Window *pChild = GetWindow(GetWindowType::FirstChild); pChild; pChild = pChild->GetWindow(GetWindowType::Next))
2083  {
2084  if (!pChild->IsVisible())
2085  continue;
2086  setLayoutAllocation(*pChild, aChildPos, rAllocation);
2087  }
2088 }
2089 
2091 {
2092  Size aRet(0, 0);
2093 
2094  for (const vcl::Window* pChild = get_child(); pChild;
2095  pChild = pChild->GetWindow(GetWindowType::Next))
2096  {
2097  if (!pChild->IsVisible())
2098  continue;
2099  Size aChildSize = getLayoutRequisition(*pChild);
2100  aRet.setWidth( std::max(aRet.Width(), aChildSize.Width()) );
2101  aRet.setHeight( std::max(aRet.Height(), aChildSize.Height()) );
2102  }
2103 
2104  return aRet;
2105 }
2106 
2108 {
2109  //discard events by default to block them reaching children
2110 }
2111 
2113 {
2114  disposeOnce();
2115 }
2116 
2118 {
2119  m_aEventBoxHelper.disposeAndClear();
2120  VclBin::dispose();
2121 }
2122 
2124 {
2125  //sufficient to trigger one widget to trigger all of them
2126  if (!m_aWindows.empty())
2127  {
2128  (*m_aWindows.begin())->queue_resize();
2129  }
2130 }
2131 
2132 void VclSizeGroup::set_ignore_hidden(bool bIgnoreHidden)
2133 {
2134  if (bIgnoreHidden != m_bIgnoreHidden)
2135  {
2136  m_bIgnoreHidden = bIgnoreHidden;
2138  }
2139 }
2140 
2142 {
2143  if (eMode != m_eMode)
2144  {
2145  m_eMode = eMode;
2147  }
2148 
2149 }
2150 
2151 void VclSizeGroup::set_property(const OString &rKey, const OUString &rValue)
2152 {
2153  if (rKey == "ignore-hidden")
2154  set_ignore_hidden(toBool(rValue));
2155  else if (rKey == "mode")
2156  {
2158  if (rValue == "none")
2159  eMode = VclSizeGroupMode::NONE;
2160  else if (rValue == "horizontal")
2162  else if (rValue == "vertical")
2164  else if (rValue == "both")
2165  eMode = VclSizeGroupMode::Both;
2166  else
2167  {
2168  SAL_WARN("vcl.layout", "unknown size group mode" << rValue);
2169  }
2170  set_mode(eMode);
2171  }
2172  else
2173  {
2174  SAL_INFO("vcl.layout", "unhandled property: " << rKey);
2175  }
2176 }
2177 
2179 {
2181 
2182  if (!m_pGrid)
2183  {
2184  VclContainer *pContainer = get_content_area();
2185  assert(pContainer);
2186 
2187  m_pGrid.set( VclPtr<VclGrid>::Create(pContainer) );
2194 
2196  switch (m_eMessageType)
2197  {
2198  case VclMessageType::Info:
2200  break;
2203  break;
2206  break;
2207  case VclMessageType::Error:
2209  break;
2210  }
2214  m_pImage->Show();
2215 
2217 
2218  bool bHasSecondaryText = !m_sSecondaryString.isEmpty();
2219 
2223 
2227 
2233  m_pSecondaryMessage->Show(bHasSecondaryText);
2234 
2235  MessageDialog::SetMessagesWidths(this, m_pPrimaryMessage, bHasSecondaryText ? m_pSecondaryMessage.get() : nullptr);
2236 
2237  VclButtonBox *pButtonBox = get_action_area();
2238  assert(pButtonBox);
2239 
2240  VclPtr<PushButton> pBtn;
2241  short nDefaultResponse = get_default_response();
2242  switch (m_eButtonsType)
2243  {
2244  case VclButtonsType::NONE:
2245  break;
2246  case VclButtonsType::Ok:
2247  pBtn.set( VclPtr<OKButton>::Create(pButtonBox) );
2248  pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON);
2249  pBtn->Show();
2250  pBtn->set_id("ok");
2251  add_button(pBtn, RET_OK, true);
2252  nDefaultResponse = RET_OK;
2253  break;
2254  case VclButtonsType::Close:
2255  pBtn.set( VclPtr<CloseButton>::Create(pButtonBox) );
2256  pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON);
2257  pBtn->Show();
2258  pBtn->set_id("close");
2259  add_button(pBtn, RET_CLOSE, true);
2260  nDefaultResponse = RET_CLOSE;
2261  break;
2263  pBtn.set( VclPtr<CancelButton>::Create(pButtonBox) );
2264  pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON);
2265  pBtn->Show();
2266  pBtn->set_id("cancel");
2267  add_button(pBtn, RET_CANCEL, true);
2268  nDefaultResponse = RET_CANCEL;
2269  break;
2270  case VclButtonsType::YesNo:
2271  pBtn = VclPtr<PushButton>::Create(pButtonBox);
2272  pBtn->SetText(GetStandardText(StandardButtonType::Yes));
2273  pBtn->Show();
2274  pBtn->set_id("yes");
2275  add_button(pBtn, RET_YES, true);
2276 
2277  pBtn.set( VclPtr<PushButton>::Create(pButtonBox) );
2278  pBtn->SetText(GetStandardText(StandardButtonType::No));
2279  pBtn->Show();
2280  pBtn->set_id("no");
2281  add_button(pBtn, RET_NO, true);
2282  nDefaultResponse = RET_NO;
2283  break;
2285  pBtn.set( VclPtr<OKButton>::Create(pButtonBox) );
2286  pBtn->Show();
2287  pBtn->set_id("ok");
2288  add_button(pBtn, RET_OK, true);
2289 
2290  pBtn.set( VclPtr<CancelButton>::Create(pButtonBox) );
2291  pBtn->Show();
2292  pBtn->set_id("cancel");
2293  add_button(pBtn, RET_CANCEL, true);
2294  nDefaultResponse = RET_CANCEL;
2295  break;
2296  }
2297  set_default_response(nDefaultResponse);
2298  pButtonBox->sort_native_button_order();
2299  m_pMessageBox->Show();
2300  m_pGrid->Show();
2301  }
2302 }
2303 
2305 {
2306 #if defined _WIN32
2307  set_border_width(3);
2308 #else
2309  set_border_width(12);
2310 #endif
2317 }
2318 
2320  : Dialog(pParent, nStyle)
2321  , m_eButtonsType(VclButtonsType::NONE)
2322  , m_eMessageType(VclMessageType::Info)
2323  , m_pOwnedContentArea(nullptr)
2324  , m_pOwnedActionArea(nullptr)
2325  , m_pGrid(nullptr)
2326  , m_pMessageBox(nullptr)
2327  , m_pImage(nullptr)
2328  , m_pPrimaryMessage(nullptr)
2329  , m_pSecondaryMessage(nullptr)
2330 {
2331  SetType(WindowType::MESSBOX);
2332 }
2333 
2335  const OUString &rMessage,
2336  VclMessageType eMessageType,
2337  VclButtonsType eButtonsType)
2338  : Dialog(pParent, WB_MOVEABLE | WB_3DLOOK | WB_CLOSEABLE)
2339  , m_eButtonsType(eButtonsType)
2340  , m_eMessageType(eMessageType)
2341  , m_pGrid(nullptr)
2342  , m_pMessageBox(nullptr)
2343  , m_pImage(nullptr)
2344  , m_pPrimaryMessage(nullptr)
2345  , m_pSecondaryMessage(nullptr)
2346  , m_sPrimaryString(rMessage)
2347 {
2348  SetType(WindowType::MESSBOX);
2351 
2352  switch (m_eMessageType)
2353  {
2354  case VclMessageType::Info:
2356  break;
2359  break;
2362  break;
2363  case VclMessageType::Error:
2365  break;
2366  }
2367 }
2368 
2370 {
2379  Dialog::dispose();
2380 }
2381 
2383 {
2384  disposeOnce();
2385 }
2386 
2388  VclMultiLineEdit *pPrimaryMessage, VclMultiLineEdit *pSecondaryMessage)
2389 {
2390  if (pSecondaryMessage)
2391  {
2392  assert(pPrimaryMessage);
2393  vcl::Font aFont = pParent->GetSettings().GetStyleSettings().GetLabelFont();
2394  aFont.SetFontSize(Size(0, aFont.GetFontSize().Height() * 1.2));
2395  aFont.SetWeight(WEIGHT_BOLD);
2396  pPrimaryMessage->SetControlFont(aFont);
2397  pPrimaryMessage->SetMaxTextWidth(pPrimaryMessage->approximate_char_width() * 44);
2398  pSecondaryMessage->SetMaxTextWidth(pSecondaryMessage->approximate_char_width() * 60);
2399  }
2400  else
2401  pPrimaryMessage->SetMaxTextWidth(pPrimaryMessage->approximate_char_width() * 60);
2402 }
2403 
2404 OUString const & MessageDialog::get_primary_text() const
2405 {
2406  const_cast<MessageDialog*>(this)->setDeferredProperties();
2407 
2408  return m_sPrimaryString;
2409 }
2410 
2411 OUString const & MessageDialog::get_secondary_text() const
2412 {
2413  const_cast<MessageDialog*>(this)->setDeferredProperties();
2414 
2415  return m_sSecondaryString;
2416 }
2417 
2418 bool MessageDialog::set_property(const OString &rKey, const OUString &rValue)
2419 {
2420  if (rKey == "text")
2421  set_primary_text(rValue);
2422  else if (rKey == "secondary-text")
2423  set_secondary_text(rValue);
2424  else if (rKey == "message-type")
2425  {
2427  if (rValue == "info")
2428  eMode = VclMessageType::Info;
2429  else if (rValue == "warning")
2430  eMode = VclMessageType::Warning;
2431  else if (rValue == "question")
2432  eMode = VclMessageType::Question;
2433  else if (rValue == "error")
2434  eMode = VclMessageType::Error;
2435  else
2436  {
2437  SAL_WARN("vcl.layout", "unknown message type mode" << rValue);
2438  }
2439  m_eMessageType = eMode;
2440  }
2441  else if (rKey == "buttons")
2442  {
2444  if (rValue == "none")
2445  eMode = VclButtonsType::NONE;
2446  else if (rValue == "ok")
2447  eMode = VclButtonsType::Ok;
2448  else if (rValue == "cancel")
2449  eMode = VclButtonsType::Cancel;
2450  else if (rValue == "close")
2451  eMode = VclButtonsType::Close;
2452  else if (rValue == "yes-no")
2453  eMode = VclButtonsType::YesNo;
2454  else if (rValue == "ok-cancel")
2455  eMode = VclButtonsType::OkCancel;
2456  else
2457  {
2458  SAL_WARN("vcl.layout", "unknown buttons type mode" << rValue);
2459  }
2460  m_eButtonsType = eMode;
2461  }
2462  else
2463  return Dialog::set_property(rKey, rValue);
2464  return true;
2465 }
2466 
2467 void MessageDialog::set_primary_text(const OUString &rPrimaryString)
2468 {
2469  m_sPrimaryString = rPrimaryString;
2470  if (m_pPrimaryMessage)
2471  {
2475  }
2476 }
2477 
2478 void MessageDialog::set_secondary_text(const OUString &rSecondaryString)
2479 {
2480  m_sSecondaryString = rSecondaryString;
2481  if (m_pSecondaryMessage)
2482  {
2486  }
2487 }
2488 
2490 {
2491  Dialog::StateChanged(nType);
2492  if (nType == StateChangedType::InitShow)
2493  {
2494  // MessageBox should be at least as wide as to see the title
2495  auto nTitleWidth = CalcTitleWidth();
2496  // Extra-Width for Close button
2497  nTitleWidth += mpWindowImpl->mnTopBorder;
2498  if (get_preferred_size().Width() < nTitleWidth)
2499  {
2500  set_width_request(nTitleWidth);
2501  DoInitialLayout();
2502  }
2503  }
2504 }
2505 
2506 VclPaned::VclPaned(vcl::Window *pParent, bool bVertical)
2507  : VclContainer(pParent, WB_HIDE | WB_CLIPCHILDREN)
2508  , m_pSplitter(VclPtr<Splitter>::Create(this, bVertical ? WB_VSCROLL : WB_HSCROLL))
2509  , m_nPosition(-1)
2510 {
2511  m_pSplitter->SetBackground(Wallpaper(Application::GetSettings().GetStyleSettings().GetFaceColor()));
2512  m_pSplitter->Show();
2513 }
2514 
2516 {
2519 }
2520 
2522  : VclPaned(pParent, true)
2523 {
2524  m_pSplitter->SetSplitHdl(LINK(this, VclVPaned, SplitHdl));
2525 }
2526 
2527 IMPL_LINK(VclVPaned, SplitHdl, Splitter*, pSplitter, void)
2528 {
2529  long nSize = pSplitter->GetSplitPosPixel();
2530  Size aSplitterSize(m_pSplitter->GetSizePixel());
2531  Size aAllocation(GetSizePixel());
2532  arrange(aAllocation, nSize, aAllocation.Height() - nSize - aSplitterSize.Height());
2533 }
2534 
2535 void VclVPaned::arrange(const Size& rAllocation, long nFirstHeight, long nSecondHeight)
2536 {
2537  Size aSplitterSize(rAllocation.Width(), getLayoutRequisition(*m_pSplitter).Height());
2538  Size aFirstChildSize(rAllocation.Width(), nFirstHeight);
2539  Size aSecondChildSize(rAllocation.Width(), nSecondHeight);
2540  int nElement = 0;
2541  for (vcl::Window* pChild = GetWindow(GetWindowType::FirstChild); pChild;
2542  pChild = pChild->GetWindow(GetWindowType::Next))
2543  {
2544  if (!pChild->IsVisible())
2545  continue;
2546  if (nElement == 0)
2547  {
2548  Point aSplitterPos(0, aFirstChildSize.Height());
2549  setLayoutAllocation(*m_pSplitter, aSplitterPos, aSplitterSize);
2550  set_position(aSplitterPos.Y() + aSplitterSize.Height() / 2);
2551  }
2552  else if (nElement == 1)
2553  {
2554  Point aChildPos(0, 0);
2555  setLayoutAllocation(*pChild, aChildPos, aFirstChildSize);
2556  }
2557  else if (nElement == 2)
2558  {
2559  Point aChildPos(0, aFirstChildSize.Height() + aSplitterSize.Height());
2560  setLayoutAllocation(*pChild, aChildPos, aSecondChildSize);
2561  }
2562  ++nElement;
2563  }
2564 }
2565 
2566 void VclVPaned::setAllocation(const Size& rAllocation)
2567 {
2568  //supporting "shrink" could be done by adjusting the allowed drag rectangle
2569  m_pSplitter->SetDragRectPixel(tools::Rectangle(Point(0, 0), rAllocation));
2570  Size aSplitterSize(rAllocation.Width(), getLayoutRequisition(*m_pSplitter).Height());
2571  const long nHeight = rAllocation.Height() - aSplitterSize.Height();
2572 
2573  long nFirstHeight = 0;
2574  long nSecondHeight = 0;
2575  bool bFirstCanResize = true;
2576  bool bSecondCanResize = true;
2577  const bool bInitialAllocation = get_position() < 0;
2578  int nElement = 0;
2579  for (const vcl::Window* pChild = GetWindow(GetWindowType::FirstChild); pChild;
2580  pChild = pChild->GetWindow(GetWindowType::Next))
2581  {
2582  if (!pChild->IsVisible())
2583  continue;
2584  if (nElement == 1)
2585  {
2586  if (bInitialAllocation)
2587  nFirstHeight = getLayoutRequisition(*pChild).Height();
2588  else
2589  nFirstHeight = pChild->GetSizePixel().Height();
2590  bFirstCanResize = pChild->get_expand();
2591  }
2592  else if (nElement == 2)
2593  {
2594  if (bInitialAllocation)
2595  nSecondHeight = getLayoutRequisition(*pChild).Height();
2596  else
2597  nSecondHeight = pChild->GetSizePixel().Height();
2598  bSecondCanResize = pChild->get_expand();
2599  }
2600  ++nElement;
2601  }
2602  long nHeightRequest = nFirstHeight + nSecondHeight;
2603  long nHeightDiff = nHeight - nHeightRequest;
2604  if (bFirstCanResize == bSecondCanResize)
2605  nFirstHeight += nHeightDiff/2;
2606  else if (bFirstCanResize)
2607  nFirstHeight += nHeightDiff;
2608  arrange(rAllocation, nFirstHeight, rAllocation.Height() - nFirstHeight - aSplitterSize.Height());
2609 }
2610 
2612 {
2613  Size aRet(0, 0);
2614 
2615  for (const vcl::Window* pChild = GetWindow(GetWindowType::FirstChild); pChild;
2616  pChild = pChild->GetWindow(GetWindowType::Next))
2617  {
2618  if (!pChild->IsVisible())
2619  continue;
2620  Size aChildSize = getLayoutRequisition(*pChild);
2621  aRet.setWidth( std::max(aRet.Width(), aChildSize.Width()) );
2622  aRet.AdjustHeight(aChildSize.Height() );
2623  }
2624 
2625  return aRet;
2626 }
2627 
2629  : VclPaned(pParent, false)
2630 {
2631  m_pSplitter->SetSplitHdl(LINK(this, VclHPaned, SplitHdl));
2632 }
2633 
2634 IMPL_LINK(VclHPaned, SplitHdl, Splitter*, pSplitter, void)
2635 {
2636  long nSize = pSplitter->GetSplitPosPixel();
2637  Size aSplitterSize(m_pSplitter->GetSizePixel());
2638  Size aAllocation(GetSizePixel());
2639  arrange(aAllocation, nSize, aAllocation.Width() - nSize - aSplitterSize.Width());
2640 }
2641 
2642 void VclHPaned::arrange(const Size& rAllocation, long nFirstWidth, long nSecondWidth)
2643 {
2644  Size aSplitterSize(getLayoutRequisition(*m_pSplitter).Width(), rAllocation.Height());
2645  Size aFirstChildSize(nFirstWidth, rAllocation.Height());
2646  Size aSecondChildSize(nSecondWidth, rAllocation.Height());
2647  int nElement = 0;
2648  for (vcl::Window* pChild = GetWindow(GetWindowType::FirstChild); pChild;
2649  pChild = pChild->GetWindow(GetWindowType::Next))
2650  {
2651  if (!pChild->IsVisible())
2652  continue;
2653  if (nElement == 0)
2654  {
2655  Point aSplitterPos(aFirstChildSize.Width(), 0);
2656  setLayoutAllocation(*m_pSplitter, aSplitterPos, aSplitterSize);
2657  set_position(aSplitterPos.X() + aSplitterSize.Width() / 2);
2658  }
2659  else if (nElement == 1)
2660  {
2661  Point aChildPos(0, 0);
2662  setLayoutAllocation(*pChild, aChildPos, aFirstChildSize);
2663  }
2664  else if (nElement == 2)
2665  {
2666  Point aChildPos(aFirstChildSize.Width() + aSplitterSize.Width(), 0);
2667  setLayoutAllocation(*pChild, aChildPos, aSecondChildSize);
2668  }
2669  ++nElement;
2670  }
2671 }
2672 
2673 void VclHPaned::setAllocation(const Size& rAllocation)
2674 {
2675  //supporting "shrink" could be done by adjusting the allowed drag rectangle
2676  m_pSplitter->SetDragRectPixel(tools::Rectangle(Point(0, 0), rAllocation));
2677  Size aSplitterSize(getLayoutRequisition(*m_pSplitter).Width(), rAllocation.Height());
2678  const long nWidth = rAllocation.Width() - aSplitterSize.Width();
2679 
2680  long nFirstWidth = 0;
2681  long nSecondWidth = 0;
2682  bool bFirstCanResize = true;
2683  bool bSecondCanResize = true;
2684  const bool bInitialAllocation = get_position() < 0;
2685  int nElement = 0;
2686  for (const vcl::Window* pChild = GetWindow(GetWindowType::FirstChild); pChild;
2687  pChild = pChild->GetWindow(GetWindowType::Next))
2688  {
2689  if (!pChild->IsVisible())
2690  continue;
2691  if (nElement == 1)
2692  {
2693  if (bInitialAllocation)
2694  nFirstWidth = getLayoutRequisition(*pChild).Width();
2695  else
2696  nFirstWidth = pChild->GetSizePixel().Width();
2697  bFirstCanResize = pChild->get_expand();
2698  }
2699  else if (nElement == 2)
2700  {
2701  if (bInitialAllocation)
2702  nSecondWidth = getLayoutRequisition(*pChild).Width();
2703  else
2704  nSecondWidth = pChild->GetSizePixel().Width();
2705  bSecondCanResize = pChild->get_expand();
2706  }
2707  ++nElement;
2708  }
2709  long nWidthRequest = nFirstWidth + nSecondWidth;
2710  long nWidthDiff = nWidth - nWidthRequest;
2711  if (bFirstCanResize == bSecondCanResize)
2712  nFirstWidth += nWidthDiff/2;
2713  else if (bFirstCanResize)
2714  nFirstWidth += nWidthDiff;
2715  arrange(rAllocation, nFirstWidth, rAllocation.Width() - nFirstWidth - aSplitterSize.Width());
2716 }
2717 
2719 {
2720  Size aRet(0, 0);
2721 
2722  for (const vcl::Window* pChild = GetWindow(GetWindowType::FirstChild); pChild;
2723  pChild = pChild->GetWindow(GetWindowType::Next))
2724  {
2725  if (!pChild->IsVisible())
2726  continue;
2727  Size aChildSize = getLayoutRequisition(*pChild);
2728  aRet.setHeight( std::max(aRet.Height(), aChildSize.Height()) );
2729  aRet.AdjustWidth(aChildSize.Width() );
2730  }
2731 
2732  return aRet;
2733 }
2734 
2736 {
2737  tools::Rectangle aBounds;
2738 
2739  for (const vcl::Window* pChild = rWindow.GetWindow(GetWindowType::FirstChild); pChild;
2740  pChild = pChild->GetWindow(GetWindowType::Next))
2741  {
2742  if (!pChild->IsVisible())
2743  continue;
2744 
2745  tools::Rectangle aChildBounds(pChild->GetPosPixel(), pChild->GetSizePixel());
2746  aBounds.Union(aChildBounds);
2747  }
2748 
2749  if (aBounds.IsEmpty())
2750  return rWindow.GetSizePixel();
2751 
2752  Size aRet(aBounds.GetSize());
2753  Point aTopLeft(aBounds.TopLeft());
2754  aRet.AdjustWidth(aTopLeft.X()*2 );
2755  aRet.AdjustHeight(aTopLeft.Y()*2 );
2756 
2757  return aRet;
2758 }
2759 
2761 {
2762  while (pWindow)
2763  {
2764  pWindow = pWindow->GetParent();
2765  if (!pWindow || !isContainerWindow(*pWindow))
2766  break;
2767  }
2768  return pWindow;
2769 }
2770 
2771 bool isVisibleInLayout(const vcl::Window *pWindow)
2772 {
2773  bool bVisible = true;
2774  while (bVisible)
2775  {
2776  bVisible = pWindow->IsVisible();
2777  pWindow = pWindow->GetParent();
2778  if (!pWindow || !isContainerWindow(*pWindow))
2779  break;
2780  }
2781  return bVisible;
2782 }
2783 
2784 bool isEnabledInLayout(const vcl::Window *pWindow)
2785 {
2786  bool bEnabled = true;
2787  while (bEnabled)
2788  {
2789  bEnabled = pWindow->IsEnabled();
2790  pWindow = pWindow->GetParent();
2791  if (!pWindow || !isContainerWindow(*pWindow))
2792  break;
2793  }
2794  return bEnabled;
2795 }
2796 
2797 bool isLayoutEnabled(const vcl::Window *pWindow)
2798 {
2799  //Child is a container => we're layout enabled
2800  const vcl::Window *pChild = pWindow ? pWindow->GetWindow(GetWindowType::FirstChild) : nullptr;
2801  return pChild && isContainerWindow(*pChild) && !pChild->GetWindow(GetWindowType::Next);
2802 }
2803 
2805 {
2806  if (m_aStartDragHdl.Call(this))
2807  return;
2808 
2810  if (!m_xTransferHelper.is())
2811  return;
2812 
2813  xContainer->StartDrag(this, m_nDragAction);
2814 }
2815 
2817 {
2818 }
2819 
2821 {
2822 }
2823 
2825 {
2826  disposeOnce();
2827 }
2828 
2830 {
2831  disposeOnce();
2832 }
2833 
2834 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual Point GetPosPixel() const
Definition: window.cxx:2860
virtual void SetText(const OUString &rStr)
Definition: window.cxx:3084
virtual boost::property_tree::ptree DumpAsPropertyTree() override
Dumps itself and potentially its children to a property tree, to be written easily to JSON...
Definition: layout.cxx:363
Point TopLeft() const
long Width() const
Size GetSizePixel() const
Definition: Image.cxx:86
virtual sal_uInt16 getDefaultAccessibleRole() const override
Definition: layout.cxx:41
Image const & GetStandardInfoBoxImage()
Definition: stdtext.cxx:49
virtual ~VclExpander() override
Definition: layout.cxx:1631
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: layout.cxx:2418
bool m_bColumnHomogeneous
Definition: layout.hxx:314
SAL_DLLPRIVATE float approximate_char_width() const
Definition: text.cxx:904
virtual void setAllocation(const Size &rAllocation)=0
int get_column_spacing() const
Definition: layout.hxx:358
void SetDragRectPixel(const tools::Rectangle &rDragRect, vcl::Window *pRefWin=nullptr)
Definition: split.cxx:445
Point GetPointerPosPixel()
Definition: mouse.cxx:550
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: layout.cxx:1323
sal_Int32 get_padding() const
Definition: window2.cxx:1742
void setDeferredProperties()
Definition: builder.hxx:482
static VclGrid::Value accumulateValues(const VclGrid::Value &i, const VclGrid::Value &j)
Definition: layout.cxx:1120
virtual void SetPosPixel(const Point &rAllocPos) override
Definition: layout.cxx:154
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: layout.cxx:1997
static void setLayoutAllocation(vcl::Window &rWindow, const Point &rPos, const Size &rSize)
Definition: layout.cxx:63
Image const & GetStandardWarningBoxImage()
Definition: stdtext.cxx:60
void sort_native_button_order()
Definition: layout.cxx:792
void SetFontSize(const Size &)
Definition: font/font.cxx:117
bool get_vexpand() const
Definition: window2.cxx:1706
bool bVisible
bool isVisibleInLayout(const vcl::Window *pWindow)
Definition: layout.cxx:2771
void InitScrollBars(const Size &rRequest)
Definition: layout.cxx:1860
WinBits const WB_NOLABEL
VclPtr< ScrollBar > m_pHScroll
Definition: layout.hxx:520
void DrawImage(const Point &rPos, const Image &rImage, DrawImageFlags nStyle=DrawImageFlags::NONE)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void set_border_width(sal_Int32 nBorderWidth)
Definition: window2.cxx:1814
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: layout.cxx:2515
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: layout.cxx:1751
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.
OUString const & get_secondary_text() const
Definition: layout.cxx:2411
static void SetMessagesWidths(vcl::Window const *pParent, VclMultiLineEdit *pPrimaryMessage, VclMultiLineEdit *pSecondaryMessage)
Definition: layout.cxx:2387
sal_Int32 get_margin_bottom() const
Definition: window2.cxx:1884
long AdjustWidth(long n)
void designate_label(vcl::Window *pWindow)
Definition: layout.cxx:1430
VclButtonsType
Definition: vclenum.hxx:246
static array_type assembleGrid(const VclGrid &rGrid)
Definition: layout.cxx:834
VclBox * get_content_area()
Definition: dialog.hxx:114
void create_message_area()
Definition: layout.cxx:2178
virtual Size GetOptimalSize() const override
Definition: layout.cxx:46
virtual void setAllocation(const Size &rAllocation) override
Definition: layout.cxx:1400
const CommandEvent * GetCommandEvent() const
Definition: event.hxx:327
std::unique_ptr< ContentProperties > pData
virtual void setSecondaryDimension(Size &rSize, long) const =0
VclPtr< vcl::Window > m_pLabel
Definition: layout.hxx:421
void set_grid_left_attach(sal_Int32 nAttach)
Definition: window2.cxx:1784
virtual void setAllocation(const Size &rAllocation) override
Definition: layout.cxx:603
OUString GetStandardText(StandardButtonType eButton)
Definition: stdtext.cxx:93
long Height() const
signed char sal_Int8
bool m_bVerticalContainer
Definition: layout.hxx:75
virtual ~VclPaned() override
Definition: layout.cxx:2824
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
OUString GetStandardErrorBoxText()
Definition: stdtext.cxx:77
VclPtr< DisclosureButton > m_pDisclosureButton
Definition: layout.hxx:489
virtual void StateChanged(StateChangedType nType) override
Definition: layout.cxx:2489
bool get_hexpand() const
Definition: window2.cxx:1694
static Size getLayoutRequisition(const vcl::Window &rWindow)
Definition: layout.cxx:138
OUString const & get_primary_text() const
Definition: layout.cxx:2404
VclPtr< VclMultiLineEdit > m_pSecondaryMessage
void disposeAndClear()
Definition: vclptr.hxx:200
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
Gets the application's settings.
Definition: svapp.cxx:715
SAL_DLLPRIVATE void disposeOwnedButtons()
Definition: dialog.cxx:378
VclPtr< VclVBox > m_pMessageBox
void DrawFrame(const tools::Rectangle &rRect, const Color &rLeftTopColor, const Color &rRightBottomColor)
Definition: decoview.cxx:848
SAL_DLLPRIVATE const tools::Rectangle & GetStateRect() const
Definition: button.hxx:414
VclButtonsType m_eButtonsType
virtual Size GetSizePixel() const
Definition: window.cxx:2418
void EnableCursor(bool bEnable)
Definition: vclmedit.cxx:1513
void SetWeight(FontWeight)
Definition: font/font.cxx:215
virtual boost::property_tree::ptree DumpAsPropertyTree() override
Dumps itself and potentially its children to a property tree, to be written easily to JSON...
Definition: layout.cxx:1311
bool m_bRowHomogeneous
Definition: layout.hxx:313
WinBits const WB_AUTOVSCROLL
void set_row_spacing(int nSpacing)
Definition: layout.hxx:346
virtual Size calculateRequisition() const override
Definition: layout.cxx:1380
sal_uInt16 GetCode() const
Definition: keycod.hxx:53
VclPtr< VclBox > m_pOwnedContentArea
void set_spacing(int nSpacing)
Definition: layout.hxx:85
virtual vcl::Window * get_child() override
Definition: layout.cxx:1469
WinBits const WB_VSCROLL
Info
const CommandWheelData * GetWheelData() const
bool m_bExpand
Definition: layout.hxx:322
VclButtonBoxStyle
Definition: layout.hxx:195
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: window.cxx:144
void SetType(WindowType nType)
Definition: window2.cxx:968
constexpr sal_uInt16 KEY_ADD
Definition: keycodes.hxx:127
virtual void dispose() override
Definition: layout.cxx:1803
virtual void setAllocation(const Size &rAllocation) override
Definition: layout.cxx:1698
float x
TRISTATE_TRUE
long AdjustHeight(long n)
VclContainer(vcl::Window *pParent, WinBits nStyle=WB_HIDE|WB_CLIPCHILDREN)
Definition: layout.cxx:31
bool get_fill() const
Definition: window2.cxx:1754
static const OUString & GetDesktopEnvironment()
Get the desktop environment the process is currently running in.
Definition: svapp.cxx:1590
void create_owned_areas()
Definition: layout.cxx:2304
NONE
virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const =0
OUString GetStandardQueryBoxText()
Definition: stdtext.cxx:88
WEIGHT_BOLD
bool IsEmpty() const
StateChangedType
Definition: window.hxx:311
const sal_uInt8 A
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: button.cxx:3155
rtl::Reference< TransferDataContainer > m_xTransferHelper
Definition: layout.hxx:632
OUString GetAccessibleName() const
sal_Int64 WinBits
virtual void dispose() override
Definition: layout.cxx:2117
sal_Int32 get_margin_right() const
Definition: window2.cxx:1852
void SetBackground()
void SetControlFont()
Definition: window2.cxx:409
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: dialog.cxx:610
std::set< VclPtr< vcl::Window > > m_aWindows
Definition: layout.hxx:586
virtual void dispose() override
Definition: layout.cxx:1372
bool m_bLayoutDirty
Definition: layout.hxx:68
void set_ignore_hidden(bool bIgnoreHidden)
Definition: layout.cxx:2132
const vcl::Font & GetLabelFont() const
virtual Size calculateRequisition() const =0
WinBits const WB_DEFBUTTON
enumrange< T >::Iterator begin(enumrange< T >)
Size addSpacing(const Size &rSize, sal_uInt16 nVisibleChildren) const
Definition: layout.cxx:554
uno::Type m_aType
WinBits const WB_VERT
VclMessageType m_eMessageType
WinBits const WB_HSCROLL
bool IsMouseEvent() const
boost::multi_array< GridEntry, 2 > array_type
Definition: layout.cxx:828
virtual boost::property_tree::ptree DumpAsPropertyTree() override
Definition: layout.cxx:1496
void reorderWithinParent(vcl::Window &rWindow, sal_uInt16 nNewPosition)
Definition: builder.cxx:2549
void Hide()
Definition: window.hxx:936
virtual long getPrimaryDimension(const Size &rSize) const =0
VclSizeGroupMode
Definition: vclenum.hxx:264
VclPtr< vcl::Window > mpLastChild
Definition: window.h:234
void set_default_response(int nResponse)
Definition: dialog.cxx:1503
virtual ~VclHPaned() override
Definition: layout.cxx:2816
Mode eMode
sal_Int8 m_nDragAction
Definition: layout.hxx:633
virtual long getSecondaryDimension(const Size &rSize) const =0
static bool compareValues(const VclGrid::Value &i, const VclGrid::Value &j)
Definition: layout.cxx:1115
void set_width_request(sal_Int32 nWidthRequest)
Definition: window2.cxx:1603
sal_uInt16 GetModifier() const
Definition: keycod.hxx:56
virtual OUString GetText() const
Definition: window.cxx:3113
void set_mode(VclSizeGroupMode eMode)
Definition: layout.cxx:2141
VclMessageType
Definition: vclenum.hxx:256
virtual void Command(const CommandEvent &rCEvt) override
Definition: layout.cxx:2107
void * GetEventData() const
std::vector< long > m_aMainGroupDimensions
Definition: layout.hxx:223
bool get_secondary() const
Definition: window2.cxx:1902
WinBits const WB_HIDE
TriState GetState() const
Definition: button.hxx:438
Link< VclDrawingArea *, bool > m_aStartDragHdl
Definition: layout.hxx:644
bool m_bResizeTopLevel
Definition: layout.hxx:488
bool isContainerWindow(const vcl::Window &rWindow)
Definition: layout.hxx:833
float y
sal_Int32 get_margin_left() const
Definition: window2.cxx:1836
bool mbInDispose
Definition: window.h:317
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:75
Size getLegacyBestSizeForChildren(const vcl::Window &rWindow)
Definition: layout.cxx:2735
virtual boost::property_tree::ptree DumpAsPropertyTree()
Dumps itself and potentially its children to a property tree, to be written easily to JSON...
Definition: window.cxx:3410
const OString & GetHelpId() const
Definition: window2.cxx:828
Size finalizeMaxes(const Size &rSize, sal_uInt16 nVisibleChildren) const
Definition: layout.cxx:384
virtual Size calculateRequisition() const override
Definition: layout.cxx:2611
void clear()
Definition: vclptr.hxx:190
bool isEnabledInLayout(const vcl::Window *pWindow)
Definition: layout.cxx:2784
void arrange(const Size &rAllocation, long nFirstHeight, long nSecondHeight)
Definition: layout.cxx:2642
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: dialog.cxx:1361
virtual ~VclFrame() override
Definition: layout.cxx:1367
VclPackType
Definition: vclenum.hxx:224
virtual void setAllocation(const Size &rAllocation) override
Definition: layout.cxx:241
void set_property(const OString &rKey, const OUString &rValue)
Definition: layout.cxx:2151
int i
VclPtr< ScrollBarBox > m_aScrollBarBox
Definition: layout.hxx:521
VclPtr< VclButtonBox > m_pOwnedActionArea
void SetMaxTextWidth(long nMaxWidth)
Definition: vclmedit.cxx:1102
DrawFrameStyle m_eDrawFrameStyle
Definition: layout.hxx:518
VclPtr< ScrollBar > m_pVScroll
Definition: layout.hxx:519
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: layout.cxx:2021
bool get_expanded() const
Definition: layout.cxx:1636
int get_default_response() const
Definition: dialog.cxx:1463
bool m_bIgnoreHidden
Definition: layout.hxx:587
virtual ~VclScrolledWindow() override
Definition: layout.cxx:2829
void SetRangeMax(long nNewRange)
Definition: scrbar.cxx:1333
std::unique_ptr< Image > mpDisclosureMinus
Definition: svdata.hxx:274
virtual void SetText(const OUString &rStr) override
Definition: ctrl.cxx:95
virtual void setAllocation(const Size &rAllocation) override
Definition: layout.cxx:2566
void SetVisibleSize(long nNewSize)
Definition: scrbar.cxx:1377
void SetSplitHdl(const Link< Splitter *, void > &rLink)
Definition: split.hxx:99
OUString get_label() const
Definition: layout.cxx:1481
CommandWheelMode GetMode() const
WinBits const WB_VCENTER
virtual void setPrimaryDimension(Size &rSize, long) const =0
virtual void SetSizePixel(const Size &rAllocation) override
Definition: layout.cxx:165
sal_Int32 get_margin_top() const
Definition: window2.cxx:1868
#define DEFAULT_CHILD_MIN_WIDTH
Definition: layout.cxx:381
virtual sal_uInt16 getDefaultAccessibleRole() const override
Definition: layout.cxx:370
Size calculateRequisitionForSpacings(sal_Int32 nRowSpacing, sal_Int32 nColSpacing) const
Definition: layout.cxx:1133
Requisition calculatePrimarySecondaryRequisitions() const
Definition: layout.cxx:455
Image const & GetStandardErrorBoxImage()
Definition: stdtext.cxx:71
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
CommandEventId GetCommand() const
virtual void setAllocation(const Size &rAllocation) override
Definition: layout.cxx:1173
sal_uInt16 GetModifier() const
virtual void Command(const CommandEvent &rCEvt) override
Definition: layout.cxx:188
bool IsChecked() const
Definition: button.hxx:472
void add_button(PushButton *pButton, int nResponse, bool bTransferOwnership)
Definition: dialog.cxx:1393
std::unique_ptr< WindowImpl > mpWindowImpl
Definition: window.hxx:511
const Size & GetFontSize() const
Definition: font/font.cxx:673
Size get_preferred_size() const
Definition: window2.cxx:1639
VclSizeGroupMode m_eMode
Definition: layout.hxx:588
bool isLayoutEnabled(const vcl::Window *pWindow)
Definition: layout.cxx:2797
MouseNotifyEvent GetType() const
Definition: event.hxx:303
void SetPageSize(long nNewSize)
Definition: scrbar.hxx:125
VclPtr< FixedImage > m_pImage
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: layout.cxx:577
void SetToggleHdl(const Link< CheckBox &, void > &rLink)
Definition: button.hxx:455
void set_homogeneous(bool bHomogeneous)
Definition: layout.hxx:93
virtual void dispose() override
Definition: layout.cxx:1651
const AllSettings & GetSettings() const
Definition: outdev.hxx:420
virtual Size calculateRequisition() const override
Definition: layout.cxx:569
void SetPaintTransparent(bool bTransparent)
Definition: paint.cxx:1022
Size GetOutputSizePixel() const
Definition: outdev.hxx:441
void SetImage(const Image &rImage)
Definition: fixed.cxx:933
VclPtr< Splitter > m_pSplitter
Definition: layout.hxx:381
bool get_row_homogeneous() const
Definition: layout.hxx:338
virtual bool set_property(const OString &rKey, const OUString &rValue)
Definition: window2.cxx:1431
static void setLayoutPosSize(vcl::Window &rWindow, const Point &rPos, const Size &rSize)
Definition: layout.cxx:51
void reorderWithinParent(sal_uInt16 nNewPosition)
Definition: stacking.cxx:162
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: layout.cxx:1606
void Check(bool bCheck=true)
Definition: button.hxx:467
VclPackType get_pack_type() const
Definition: window2.cxx:1730
long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
Definition: text.cxx:891
vcl::Window * GetParent() const
Definition: window2.cxx:1097
virtual void ImplDrawCheckBoxState(vcl::RenderContext &rRenderContext) override
Definition: layout.cxx:1551
WinBits const WB_LEFT
void SetStyle(WinBits nStyle)
Definition: window.cxx:1979
Size GetSize() const
enumrange< T >::Iterator end(enumrange< T >)
void setOptimalLayoutSize()
Definition: syswin.cxx:1119
void Scroll()
Definition: scrbar.cxx:1293
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize)
Definition: window2.cxx:1268
bool get_expand() const
Definition: window2.cxx:1718
vcl::Window * GetWindow(GetWindowType nType) const
Definition: stacking.cxx:1046
void arrange(const Size &rAllocation, long nFirstHeight, long nSecondHeight)
Definition: layout.cxx:2535
DrawFrameStyle
Definition: vclenum.hxx:332
Size getVisibleChildSize() const
Definition: layout.cxx:1985
const Point & GetMousePosPixel() const
DisclosureButton(vcl::Window *pParent)
Definition: layout.cxx:1601
virtual Size calculateRequisition() const override
Definition: layout.cxx:2718
void set_grid_top_attach(sal_Int32 nAttach)
Definition: window2.cxx:1808
bool m_bInitialAllocation
Definition: layout.hxx:534
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:935
#define DEFAULT_CHILD_MIN_HEIGHT
Definition: layout.cxx:382
WinBits const WB_3DLOOK
virtual void setAllocation(const Size &rAllocation) override
Definition: layout.cxx:2079
VclScrolledWindow(vcl::Window *pParent)
Definition: layout.cxx:1788
DrawButtonFlags GetButtonState() const
Definition: button.cxx:493
VclButtonBox * get_action_area()
Definition: dialog.hxx:113
void set_id(const OUString &rID)
Sets an ID.
Definition: window.cxx:3936
long CalcTitleWidth() const
Definition: window.cxx:2065
VclPtr< VclGrid > m_pGrid
void AddEventListener(const Link< VclWindowEvent &, void > &rEventListener)
Definition: event.cxx:302
void set_valign(VclAlign eAlign)
Definition: window2.cxx:1688
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:54
static std::vector< long > setButtonSizes(const std::vector< long > &rG, const std::vector< bool > &rNonHomogeneous, long nAvgDimension, long nMaxNonOutlier, long nMinWidth)
Definition: layout.cxx:430
virtual void StateChanged(StateChangedType nStateChange) override
Definition: dialog.cxx:736
virtual ~VclVPaned() override
Definition: layout.cxx:2820
OUString GetStandardInfoBoxText()
Definition: stdtext.cxx:55
virtual ~MessageDialog() override
Definition: layout.cxx:2382
bool IsMouseOver() const
Definition: mouse.cxx:606
virtual vcl::Window * get_child() override
Definition: layout.cxx:1835
virtual vcl::Window * get_child() override
Definition: layout.cxx:2074
constexpr sal_uInt16 KEY_SUBTRACT
Definition: keycodes.hxx:128
VclVPaned(vcl::Window *pParent)
Definition: layout.cxx:2521
sal_Int32 m_nPosition
void set_hexpand(bool bExpand)
Definition: window2.cxx:1700
WindowType
virtual Size calculateRequisition() const override
Definition: layout.cxx:1840
tools::Rectangle & Union(const tools::Rectangle &rRect)
bool get_column_homogeneous() const
Definition: layout.hxx:342
void set_expanded(bool bExpanded)
Definition: layout.cxx:1641
void set_label(const OUString &rLabel)
Definition: layout.cxx:1646
int m_nSpacing
Definition: layout.hxx:76
VclExpander(vcl::Window *pParent)
Definition: layout.cxx:1622
virtual void setAllocation(const Size &rAllocation) override
Definition: layout.cxx:2047
virtual long getPrimaryCoordinate(const Point &rPos) const =0
Size addReqGroups(const VclButtonBox::Requisition &rReq) const
Definition: layout.cxx:400
vcl::Window * get_label_widget()
Definition: layout.cxx:1452
bool IsVisible() const
Definition: window2.cxx:1102
virtual vcl::Window * get_child() override
Definition: layout.cxx:1666
#define SAL_INFO(area, stream)
virtual void setAllocation(const Size &rAllocation) override
Definition: layout.cxx:1980
virtual void StartDrag(sal_Int8 nAction, const Point &rPosPixel) override
Definition: layout.cxx:2804
VclPtr< EventBoxHelper > m_aEventBoxHelper
Definition: layout.hxx:565
void set_column_spacing(int nSpacing)
Definition: layout.hxx:350
virtual Size calculateRequisition() const override
Definition: layout.cxx:2090
void EnableChildTransparentMode(bool bEnable=true)
Definition: window2.cxx:1022
virtual OUString getDefaultAccessibleName() const override
Definition: layout.cxx:1488
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: layout.cxx:2369
VclPtr< VclMultiLineEdit > m_pPrimaryMessage
virtual void SetText(const OUString &rStr) override
Definition: syswin.cxx:1103
void SetScrollHdl(const Link< ScrollBar *, void > &rLink)
Definition: scrbar.hxx:133
Definition: image.hxx:40
static VclPtr< reference_type > Create(Arg &&...arg)
A construction helper for VclPtr.
Definition: vclptr.hxx:127
virtual void setPrimaryCoordinate(Point &rPos, long) const =0
virtual Size calculateRequisition() const override
Definition: layout.cxx:1671
virtual void set_content_area(VclBox *pBox)
Definition: dialog.cxx:592
void set_action_area(VclButtonBox *pBox)
Definition: dialog.cxx:581
virtual Size calculateRequisition() const override
Definition: layout.cxx:1128
VclAlign get_valign() const
Definition: window2.cxx:1682
MessageDialog(vcl::Window *pParent, WinBits nStyle)
Definition: layout.cxx:2319
WinBits const WB_AUTOHSCROLL
void set(reference_type *pBody)
Definition: vclptr.hxx:148
VclPtr< vcl::Window > mpFirstChild
Definition: window.h:233
virtual ~VclEventBox() override
Definition: layout.cxx:2112
SAL_DLLPRIVATE const tools::Rectangle & GetMouseRect() const
Definition: button.hxx:415
WinBits const WB_TABSTOP
std::vector< long > m_aSubGroupDimensions
Definition: layout.hxx:224
IMPL_LINK(VclFrame, WindowEventListener, VclWindowEvent &, rEvent, void)
Definition: layout.cxx:1424
std::unique_ptr< Image > mpDisclosurePlus
Definition: svdata.hxx:273
vcl::Window * getNonLayoutParent(vcl::Window *pWindow)
Definition: layout.cxx:2760
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize) override
Definition: layout.cxx:143
void doSetAllocation(const Size &rAllocation, bool bRetryOnFailure)
Definition: layout.cxx:1880
VclAlign
Definition: vclenum.hxx:216
WinBits const WB_CENTER
OUString GetStandardWarningBoxText()
Definition: stdtext.cxx:66
void set_secondary_text(const OUString &rSecondaryString)
Definition: layout.cxx:2478
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
bool IsEnabled() const
Definition: window2.cxx:1122
#define SAL_WARN(area, stream)
void RemoveEventListener(const Link< VclWindowEvent &, void > &rEventListener)
Definition: event.cxx:307
virtual Size calculateRequisition() const override
Definition: layout.cxx:219
virtual void setAllocation(const Size &rAllocation) override
Definition: layout.cxx:2673
WinBits GetStyle() const
Definition: window2.cxx:953
OUString m_sPrimaryString
void set_primary_text(const OUString &rPrimaryString)
Definition: layout.cxx:2467
static int getButtonPriority(const OString &rType)
Definition: layout.cxx:702
static long getMaxNonOutlier(const std::vector< long > &rG, long nAvgDimension)
Definition: layout.cxx:416
long get_position() const
Definition: layout.hxx:388
WinBits const WB_CLOSEABLE
void set_position(long nPosition)
Definition: layout.hxx:389
WinBits const WB_MOVEABLE
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout) override
Definition: layout.cxx:181
Image const & GetStandardQueryBoxImage()
Definition: stdtext.cxx:82
void accumulateMaxes(const Size &rChildSize, Size &rSize) const
Definition: layout.cxx:205
virtual void StateChanged(StateChangedType nType) override
Definition: layout.cxx:1762
int get_row_spacing() const
Definition: layout.hxx:354
WinBits const WB_HORZ
bool HasFocus() const
Definition: window.cxx:3039
bool m_bUserManagedScrolling
Definition: layout.hxx:517
void setWidth(long nWidth)
bool m_bHomogeneous
Definition: layout.hxx:74
void set_label(const OUString &rLabel)
Definition: layout.cxx:1474
WinBits const WB_CLIPCHILDREN
sal_Int32 nState
DrawImageFlags
Definition: outdev.hxx:172
WinBits const WB_NOTABSTOP
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: layout.cxx:2040
virtual void SetPosPixel(const Point &rNewPos)
Definition: window2.cxx:1257
IMPL_LINK_NOARG(VclScrolledWindow, ScrollBarHdl, ScrollBar *, void)
Definition: layout.cxx:1811
VclButtonBoxStyle m_eLayoutStyle
Definition: layout.hxx:220
virtual void SetText(const OUString &rStr) override
Definition: vclmedit.cxx:1147
sal_Int32 get_border_width() const
Definition: window2.cxx:1820
VclPaned(vcl::Window *pParent, bool bVertical)
Definition: layout.cxx:2506
SAL_DLLPRIVATE void DoInitialLayout()
Definition: syswin.cxx:1140
void trigger_queue_resize()
Definition: layout.cxx:2123
VclHPaned(vcl::Window *pParent)
Definition: layout.cxx:2628
static bool isNullGrid(const array_type &A)
Definition: layout.cxx:989
VclAlign get_halign() const
Definition: window2.cxx:1670
static void calcMaxs(const array_type &A, std::vector< VclGrid::Value > &rWidths, std::vector< VclGrid::Value > &rHeights)
Definition: layout.cxx:997
OUString m_sSecondaryString
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2204
bool toBool(const OUString &rValue)
Definition: layout.cxx:1318
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: layout.cxx:352
void setHeight(long nHeight)