LibreOffice Module vcl (master)  1
layout.hxx
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 #ifndef INCLUDED_VCL_LAYOUT_HXX
11 #define INCLUDED_VCL_LAYOUT_HXX
12 
13 #include <config_options.h>
14 #include <vcl/dllapi.h>
15 #include <vcl/ctrl.hxx>
16 #include <vcl/help.hxx>
17 #include <vcl/svapp.hxx>
18 #include <vcl/window.hxx>
19 #include <vcl/settings.hxx>
20 #include <vcl/event.hxx>
21 #include <vcl/transfer.hxx>
22 #include <vcl/vclptr.hxx>
23 #include <vcl/IContext.hxx>
24 #include <vcl/commandevent.hxx>
25 #include <tools/stream.hxx>
26 #include <vcl/cvtgrf.hxx>
27 #include <comphelper/base64.hxx>
28 #include <vcl/virdev.hxx>
29 #include <set>
30 #include <boost/property_tree/json_parser.hpp>
31 
32 class ScrollBar;
33 class ScrollBar;
34 class ScrollBarBox;
35 class Splitter;
36 
38  public vcl::IContext
39 {
40 public:
42 
43  //These take into account the external margins of the rWindow widget
44  //while GetOptimalSize/get_preferred_size and SetPosSizePixel are
45  //oblivious to them
46  static Size getLayoutRequisition(const vcl::Window &rWindow);
47  static void setLayoutPosSize(vcl::Window &rWindow, const Point &rPos, const Size &rSize);
48 
49  //applies the allocation pos and size onto rWindow via setLayoutPosSize taking into account
50  //the rWindows alignment desires within that allocation
51  static void setLayoutAllocation(vcl::Window &rWindow, const Point &rPos, const Size &rSize);
52 
53  virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
54 protected:
55  //these are the two that need to be implemented by
56  //containers, figure out how much space you want...
57  virtual Size calculateRequisition() const = 0;
58  //..and decide what to do when set to this size
59  virtual void setAllocation(const Size &rAllocation) = 0;
60 
61  virtual sal_uInt16 getDefaultAccessibleRole() const override;
62 
63  // support for screenshot context menu
64  virtual void Command(const CommandEvent& rCEvt) override;
65 
66 public:
67  //you don't want to override these
68  virtual Size GetOptimalSize() const override;
69  virtual void SetPosSizePixel(const Point& rNewPos, const Size& rNewSize) override;
70  virtual void SetPosPixel(const Point& rAllocPos) override;
71  virtual void SetSizePixel(const Size& rAllocation) override;
72 private:
74 };
75 
77 {
78 protected:
82 public:
83  VclBox(vcl::Window *pParent, bool bHomogeneous, int nSpacing)
84  : VclContainer(pParent)
85  , m_bHomogeneous(bHomogeneous)
86  , m_bVerticalContainer(false)
87  , m_nSpacing(nSpacing)
88  {
89  }
90  void set_spacing(int nSpacing)
91  {
92  m_nSpacing = nSpacing;
93  }
94  int get_spacing() const
95  {
96  return m_nSpacing;
97  }
98  void set_homogeneous(bool bHomogeneous)
99  {
100  m_bHomogeneous = bHomogeneous;
101  }
102  bool get_orientation() const
103  {
104  return m_bVerticalContainer;
105  }
106  virtual bool set_property(const OString &rKey, const OUString &rValue) override;
107  virtual void DumpAsPropertyTree(tools::JsonWriter&) override;
108 protected:
109  virtual sal_uInt16 getDefaultAccessibleRole() const override;
110  void accumulateMaxes(const Size &rChildSize, Size &rSize) const;
111  Size finalizeMaxes(const Size &rSize, sal_uInt16 nVisibleChildren) const;
112 
113  virtual Size calculateRequisition() const override;
114  virtual void setAllocation(const Size &rAllocation) override;
115 
116  virtual long getPrimaryDimension(const Size &rSize) const = 0;
117  virtual void setPrimaryDimension(Size &rSize, long) const = 0;
118  virtual long getPrimaryCoordinate(const Point &rPos) const = 0;
119  virtual void setPrimaryCoordinate(Point &rPos, long) const = 0;
120  virtual long getSecondaryDimension(const Size &rSize) const = 0;
121  virtual void setSecondaryDimension(Size &rSize, long) const = 0;
122 
123  virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const = 0;
124 };
125 
127 {
128 public:
129  VclVBox(vcl::Window *pParent, bool bHomogeneous = false, int nSpacing = 0)
130  : VclBox(pParent, bHomogeneous, nSpacing)
131  {
132  m_bVerticalContainer = true;
133  }
134 protected:
135  virtual long getPrimaryDimension(const Size &rSize) const override
136  {
137  return rSize.getHeight();
138  }
139  virtual void setPrimaryDimension(Size &rSize, long nHeight) const override
140  {
141  rSize.setHeight(nHeight);
142  }
143  virtual long getPrimaryCoordinate(const Point &rPos) const override
144  {
145  return rPos.getY();
146  }
147  virtual void setPrimaryCoordinate(Point &rPos, long nPos) const override
148  {
149  rPos.setY(nPos);
150  }
151  virtual long getSecondaryDimension(const Size &rSize) const override
152  {
153  return rSize.getWidth();
154  }
155  virtual void setSecondaryDimension(Size &rSize, long nWidth) const override
156  {
157  rSize.setWidth(nWidth);
158  }
159  virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const override
160  {
161  return rWindow.get_expand() || rWindow.get_vexpand();
162  }
163 };
164 
166 {
167 public:
168  VclHBox(vcl::Window *pParent, bool bHomogeneous = false, int nSpacing = 0)
169  : VclBox(pParent, bHomogeneous, nSpacing)
170  {
171  m_bVerticalContainer = false;
172  }
173 protected:
174  virtual long getPrimaryDimension(const Size &rSize) const override
175  {
176  return rSize.getWidth();
177  }
178  virtual void setPrimaryDimension(Size &rSize, long nWidth) const override
179  {
180  rSize.setWidth(nWidth);
181  }
182  virtual long getPrimaryCoordinate(const Point &rPos) const override
183  {
184  return rPos.getX();
185  }
186  virtual void setPrimaryCoordinate(Point &rPos, long nPos) const override
187  {
188  rPos.setX(nPos);
189  }
190  virtual long getSecondaryDimension(const Size &rSize) const override
191  {
192  return rSize.getHeight();
193  }
194  virtual void setSecondaryDimension(Size &rSize, long nHeight) const override
195  {
196  rSize.setHeight(nHeight);
197  }
198  virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const override
199  {
200  return rWindow.get_expand() || rWindow.get_hexpand();
201  }
202 };
203 
205 {
206  Default,
207  Spread,
208  Edge,
209  Start,
210  End,
211  Center
212 };
213 
215 {
216 public:
218  : VclBox(pParent, false, Application::GetSettings().GetStyleSettings().GetDialogStyle().button_spacing)
219  , m_eLayoutStyle(VclButtonBoxStyle::Default)
220  {
221  }
222  virtual bool set_property(const OString &rKey, const OUString &rValue) override;
223 protected:
224  virtual Size calculateRequisition() const override;
225  virtual void setAllocation(const Size &rAllocation) override;
226  Size addSpacing(const Size &rSize, sal_uInt16 nVisibleChildren) const;
227 private:
229  struct Requisition
230  {
231  std::vector<long> m_aMainGroupDimensions;
232  std::vector<long> m_aSubGroupDimensions;
235  };
236  Requisition calculatePrimarySecondaryRequisitions() const;
237  Size addReqGroups(const VclButtonBox::Requisition &rReq) const;
238 };
239 
241 {
242 public:
244  : VclButtonBox(pParent)
245  {
246  m_bVerticalContainer = true;
247  }
248 protected:
249  virtual long getPrimaryDimension(const Size &rSize) const override
250  {
251  return rSize.getHeight();
252  }
253  virtual void setPrimaryDimension(Size &rSize, long nHeight) const override
254  {
255  rSize.setHeight(nHeight);
256  }
257  virtual long getPrimaryCoordinate(const Point &rPos) const override
258  {
259  return rPos.getY();
260  }
261  virtual void setPrimaryCoordinate(Point &rPos, long nPos) const override
262  {
263  rPos.setY(nPos);
264  }
265  virtual long getSecondaryDimension(const Size &rSize) const override
266  {
267  return rSize.getWidth();
268  }
269  virtual void setSecondaryDimension(Size &rSize, long nWidth) const override
270  {
271  rSize.setWidth(nWidth);
272  }
273  virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const override
274  {
275  return rWindow.get_expand() || rWindow.get_vexpand();
276  }
277 };
278 
280 {
281 public:
283  : VclButtonBox(pParent)
284  {
285  m_bVerticalContainer = false;
286  }
287 private:
288  virtual long getPrimaryDimension(const Size &rSize) const override
289  {
290  return rSize.getWidth();
291  }
292  virtual void setPrimaryDimension(Size &rSize, long nWidth) const override
293  {
294  rSize.setWidth(nWidth);
295  }
296  virtual long getPrimaryCoordinate(const Point &rPos) const override
297  {
298  return rPos.getX();
299  }
300  virtual void setPrimaryCoordinate(Point &rPos, long nPos) const override
301  {
302  rPos.setX(nPos);
303  }
304  virtual long getSecondaryDimension(const Size &rSize) const override
305  {
306  return rSize.getHeight();
307  }
308  virtual void setSecondaryDimension(Size &rSize, long nHeight) const override
309  {
310  rSize.setHeight(nHeight);
311  }
312  virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const override
313  {
314  return rWindow.get_expand() || rWindow.get_hexpand();
315  }
316 };
317 
318 class VCL_DLLPUBLIC VclGrid final : public VclContainer
319 {
320 private:
325 
326 public:
327  struct Value
328  {
329  long m_nValue;
330  bool m_bExpand;
331  Value() : m_nValue(0), m_bExpand(false) {}
332  };
333 private:
334 
335  Size calculateRequisitionForSpacings(sal_Int32 nRowSpacing, sal_Int32 nColSpacing) const;
336  virtual Size calculateRequisition() const override;
337  virtual void setAllocation(const Size &rAllocation) override;
338  virtual void DumpAsPropertyTree(tools::JsonWriter&) override;
339 public:
341  : VclContainer(pParent)
342  , m_bRowHomogeneous(false), m_bColumnHomogeneous(false)
343  , m_nRowSpacing(0), m_nColumnSpacing(0)
344  {
345  }
346  bool get_row_homogeneous() const
347  {
348  return m_bRowHomogeneous;
349  }
351  {
352  return m_bColumnHomogeneous;
353  }
354  void set_row_spacing(int nSpacing)
355  {
356  m_nRowSpacing = nSpacing;
357  }
358  void set_column_spacing(int nSpacing)
359  {
360  m_nColumnSpacing = nSpacing;
361  }
362  int get_row_spacing() const
363  {
364  return m_nRowSpacing;
365  }
366  int get_column_spacing() const
367  {
368  return m_nColumnSpacing;
369  }
370  virtual bool set_property(const OString &rKey, const OUString &rValue) override;
371 };
372 
373 class UNLESS_MERGELIBS(VCL_DLLPUBLIC) VclBin : public VclContainer
374 {
375 public:
376  VclBin(vcl::Window *pParent, WinBits nStyle = WB_HIDE | WB_CLIPCHILDREN)
377  : VclContainer(pParent, nStyle)
378  {
379  }
380  virtual vcl::Window *get_child();
381  virtual const vcl::Window *get_child() const;
382  virtual Size calculateRequisition() const override;
383  virtual void setAllocation(const Size &rAllocation) override;
384 };
385 
386 class VclPaned : public VclContainer
387 {
388 protected:
391 
392  VclPaned(vcl::Window *pParent, bool bVertical);
393 public:
394  virtual ~VclPaned() override;
395  virtual void dispose() override;
396  long get_position() const { return m_nPosition; }
397  virtual void set_position(long nPosition) { m_nPosition = nPosition; }
398 };
399 
400 class VclVPaned final : public VclPaned
401 {
402 private:
403  DECL_LINK(SplitHdl, Splitter*, void);
404  void arrange(const Size& rAllocation, long nFirstHeight, long nSecondHeight);
405 
406 public:
407  VclVPaned(vcl::Window *pParent);
408  virtual ~VclVPaned() override;
409  virtual Size calculateRequisition() const override;
410  virtual void setAllocation(const Size &rAllocation) override;
411  virtual void set_position(long nPosition) override;
412 };
413 
414 class VclHPaned final : public VclPaned
415 {
416 private:
417  DECL_LINK(SplitHdl, Splitter*, void);
418  void arrange(const Size& rAllocation, long nFirstHeight, long nSecondHeight);
419 
420 public:
421  VclHPaned(vcl::Window *pParent);
422  virtual ~VclHPaned() override;
423  virtual Size calculateRequisition() const override;
424  virtual void setAllocation(const Size &rAllocation) override;
425  virtual void set_position(long nPosition) override;
426 };
427 
428 class VclFrame final : public VclBin
429 {
430 private:
432 private:
433  friend class VclBuilder;
434  void designate_label(vcl::Window *pWindow);
435  DECL_LINK(WindowEventListener, VclWindowEvent&, void);
436 public:
438  : VclBin(pParent)
439  , m_pLabel(nullptr)
440  {
441  }
442  virtual ~VclFrame() override;
443  virtual void dispose() override;
444  void set_label(const OUString &rLabel);
445  OUString get_label() const;
446  virtual vcl::Window *get_child() override;
447  virtual const vcl::Window *get_child() const override;
448  vcl::Window *get_label_widget();
449  const vcl::Window *get_label_widget() const;
450  virtual void DumpAsPropertyTree(tools::JsonWriter&) override;
451 private:
452  virtual Size calculateRequisition() const override;
453  virtual void setAllocation(const Size &rAllocation) override;
454  virtual OUString getDefaultAccessibleName() const override;
455 };
456 
457 class UNLESS_MERGELIBS(VCL_DLLPUBLIC) VclAlignment final : public VclBin
458 {
459 public:
460  VclAlignment(vcl::Window *pParent)
461  : VclBin(pParent)
462  , m_nBottomPadding(0)
463  , m_nLeftPadding(0)
464  , m_nRightPadding(0)
465  , m_nTopPadding(0)
466  {
467  }
468  virtual bool set_property(const OString &rKey, const OUString &rValue) override;
469 private:
470  virtual Size calculateRequisition() const override;
471  virtual void setAllocation(const Size &rAllocation) override;
472  sal_Int32 m_nBottomPadding;
473  sal_Int32 m_nLeftPadding;
474  sal_Int32 m_nRightPadding;
475  sal_Int32 m_nTopPadding;
476 };
477 
478 class DisclosureButton;
479 class CheckBox;
480 
481 class VclExpander final : public VclBin
482 {
483 public:
484  VclExpander(vcl::Window *pParent);
485  virtual ~VclExpander() override;
486  virtual void dispose() override;
487  virtual vcl::Window *get_child() override;
488  virtual const vcl::Window *get_child() const override;
489  virtual bool set_property(const OString &rKey, const OUString &rValue) override;
490  bool get_expanded() const;
491  void set_expanded(bool bExpanded);
492  void set_label(const OUString& rLabel);
493  virtual void StateChanged(StateChangedType nType) override;
494  void SetExpandedHdl( const Link<VclExpander&,void>& rLink ) { maExpandedHdl = rLink; }
495 private:
496  virtual Size calculateRequisition() const override;
497  virtual void setAllocation(const Size &rAllocation) override;
501  DECL_LINK(ClickHdl, CheckBox&, void);
502 };
503 
504 class VCL_DLLPUBLIC VclScrolledWindow final : public VclBin
505 {
506 public:
507  VclScrolledWindow(vcl::Window *pParent );
508  virtual ~VclScrolledWindow() override;
509  virtual void dispose() override;
510  virtual vcl::Window *get_child() override;
511  virtual const vcl::Window *get_child() const override;
512  virtual bool set_property(const OString &rKey, const OUString &rValue) override;
513  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
514  bool HasVisibleBorder() const { return m_eDrawFrameStyle != DrawFrameStyle::NONE; }
515  ScrollBar& getVertScrollBar() { return *m_pVScroll; }
516  ScrollBar& getHorzScrollBar() { return *m_pHScroll; }
517  Size getVisibleChildSize() const;
518  //set to true to disable the built-in scrolling callbacks to allow the user
519  //to override it
520  void setUserManagedScrolling(bool bUserManagedScrolling) { m_bUserManagedScrolling = bUserManagedScrolling;}
521  void doSetAllocation(const Size &rAllocation, bool bRetryOnFailure);
522 private:
523  virtual Size calculateRequisition() const override;
524  virtual void setAllocation(const Size &rAllocation) override;
525  DECL_LINK(ScrollBarHdl, ScrollBar*, void);
526  void InitScrollBars(const Size &rRequest);
527  virtual bool EventNotify(NotifyEvent& rNEvt) override;
533 };
534 
535 class VclViewport final : public VclBin
536 {
537 public:
539  : VclBin(pParent, WB_HIDE | WB_CLIPCHILDREN)
540  , m_bInitialAllocation(true)
541  {
542  }
543 private:
544  virtual void setAllocation(const Size &rAllocation) override;
546 };
547 
548 //Enforces that its children are always the same size as itself.
549 //Intercepts any Commands intended for its children.
550 //
551 //by default the Commands are discarded, inherit from this
552 //and implement "Command" to get them
553 class VclEventBox final : public VclBin
554 {
555 private:
556  //Any Commands an EventBoxHelper receives are forwarded to its parent
557  //The VclEventBox ensures that m_aEventBoxHelper is the
558  //first child and is transparent, but covers the rest of the children
560  {
561  public:
563  : Window(pParent, 0)
564  {
565  SetSizePixel(pParent->GetSizePixel());
566  EnableChildTransparentMode();
567  SetPaintTransparent(true);
568  SetBackground();
569  }
570  virtual void Command(const CommandEvent& rCEvt) override
571  {
572  GetParent()->Command(rCEvt);
573  }
574  };
575 
577  virtual void dispose() override;
578  virtual ~VclEventBox() override;
579 public:
581  : VclBin(pParent)
582  , m_aEventBoxHelper(VclPtr<EventBoxHelper>::Create(this))
583  {
584  m_aEventBoxHelper->Show();
585  }
586  virtual vcl::Window *get_child() override;
587  virtual const vcl::Window *get_child() const override;
588  virtual Size calculateRequisition() const override;
589  virtual void setAllocation(const Size &rAllocation) override;
590 
591  virtual void Command(const CommandEvent& rCEvt) override;
592 };
593 
595 {
596 private:
597  std::set< VclPtr<vcl::Window> > m_aWindows;
600 
601  void trigger_queue_resize();
602 public:
604  : m_bIgnoreHidden(false)
605  , m_eMode(VclSizeGroupMode::Horizontal)
606  {
607  }
608  void insert(vcl::Window *pWindow)
609  {
610  m_aWindows.insert(VclPtr<vcl::Window>(pWindow));
611  }
612  void erase(vcl::Window *pWindow)
613  {
614  m_aWindows.erase(VclPtr<vcl::Window>(pWindow));
615  }
616  const std::set< VclPtr<vcl::Window> >& get_widgets() const
617  {
618  return m_aWindows;
619  }
620  std::set< VclPtr<vcl::Window> >& get_widgets()
621  {
622  return m_aWindows;
623  }
624  void set_ignore_hidden(bool bIgnoreHidden);
625  bool get_ignore_hidden() const
626  {
627  return m_bIgnoreHidden;
628  }
629  void set_mode(VclSizeGroupMode eMode);
631  {
632  return m_eMode;
633  }
634  void set_property(const OString &rKey, const OUString &rValue);
635 };
636 
638  , public DragSourceHelper
639 {
640 private:
642  void* m_pUserData;
656 
657  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override
658  {
659  m_aPaintHdl.Call(std::pair<vcl::RenderContext&, const tools::Rectangle&>(rRenderContext, rRect));
660  }
661  virtual void Resize() override
662  {
663  m_aResizeHdl.Call(GetOutputSizePixel());
664  }
665  virtual void MouseMove(const MouseEvent& rMEvt) override
666  {
667  if (!m_aMouseMotionHdl.Call(rMEvt))
668  Control::MouseMove(rMEvt);
669  }
670  virtual void KeyInput(const KeyEvent& rKEvt) override
671  {
672  if (!m_aKeyPressHdl.Call(rKEvt))
673  Control::KeyInput(rKEvt);
674 
675  }
676  virtual void KeyUp(const KeyEvent& rKEvt) override
677  {
678  if (!m_aKeyReleaseHdl.Call(rKEvt))
679  Control::KeyUp(rKEvt);
680  }
681  virtual void StateChanged(StateChangedType nType) override
682  {
683  Control::StateChanged(nType);
685  {
686  m_aStyleUpdatedHdl.Call(*this);
687  Invalidate();
688  }
689  }
690  virtual void DataChanged(const DataChangedEvent& rDCEvt) override
691  {
692  Control::DataChanged(rDCEvt);
694  {
695  m_aStyleUpdatedHdl.Call(*this);
696  Invalidate();
697  }
698  }
699  virtual void Command(const CommandEvent& rEvent) override
700  {
701  if (m_aCommandHdl.Call(rEvent))
702  return;
703  Control::Command(rEvent);
704  }
705  virtual void RequestHelp(const HelpEvent& rHelpEvent) override
706  {
707  if (rHelpEvent.GetMode() & (HelpEventMode::QUICK | HelpEventMode::BALLOON))
708  {
709  Point aPos(ScreenToOutputPixel(rHelpEvent.GetMousePosPixel()));
710  tools::Rectangle aHelpArea(aPos.X(), aPos.Y());
711  OUString sHelpTip = m_aQueryTooltipHdl.Call(aHelpArea);
712  if (sHelpTip.isEmpty())
713  return;
714  Point aPt = OutputToScreenPixel(aHelpArea.TopLeft());
715  aHelpArea.SetLeft(aPt.X());
716  aHelpArea.SetTop(aPt.Y());
717  aPt = OutputToScreenPixel(aHelpArea.BottomRight());
718  aHelpArea.SetRight(aPt.X());
719  aHelpArea.SetBottom(aPt.Y());
720  // tdf#125369 recover newline support of tdf#101779
721  QuickHelpFlags eHelpWinStyle = sHelpTip.indexOf('\n') != -1 ? QuickHelpFlags::TipStyleBalloon : QuickHelpFlags::NONE;
722  Help::ShowQuickHelp(this, aHelpArea, sHelpTip, eHelpWinStyle);
723  }
724  }
725  virtual void StartDrag(sal_Int8 nAction, const Point& rPosPixel) override;
726  virtual FactoryFunction GetUITestFactory() const override
727  {
728  if (m_pFactoryFunction)
729  return m_pFactoryFunction;
730  return Control::GetUITestFactory();
731  }
732 
733 public:
735  : Control(pParent, nStyle)
736  , DragSourceHelper(this)
737  , m_pFactoryFunction(nullptr)
738  , m_pUserData(nullptr)
739  , m_nDragAction(0)
740  {
741  SetBackground();
742  }
743  virtual void MouseButtonDown(const MouseEvent& rMEvt) override
744  {
745  if (!m_aMousePressHdl.Call(rMEvt))
747  }
748  virtual void MouseButtonUp(const MouseEvent& rMEvt) override
749  {
750  if (!m_aMouseReleaseHdl.Call(rMEvt))
751  Control::MouseButtonUp(rMEvt);
752  }
753  void SetUITestFactory(FactoryFunction pFactoryFunction, void* pUserData)
754  {
755  m_pFactoryFunction = pFactoryFunction;
756  m_pUserData = pUserData;
757  }
758  void* GetUserData() const
759  {
760  return m_pUserData;
761  }
762  void SetPaintHdl(const Link<std::pair<vcl::RenderContext&, const tools::Rectangle&>, void>& rLink)
763  {
764  m_aPaintHdl = rLink;
765  }
767  {
768  m_aResizeHdl = rLink;
769  }
771  {
772  m_aMousePressHdl = rLink;
773  }
775  {
776  m_aMouseMotionHdl = rLink;
777  }
779  {
780  m_aMouseReleaseHdl = rLink;
781  }
783  {
784  m_aKeyPressHdl = rLink;
785  }
787  {
788  m_aKeyReleaseHdl = rLink;
789  }
791  {
792  m_aStyleUpdatedHdl = rLink;
793  }
795  {
796  m_aCommandHdl = rLink;
797  }
799  {
800  m_aQueryTooltipHdl = rLink;
801  }
803  {
804  m_aStartDragHdl = rLink;
805  }
807  {
808  m_xTransferHelper = rHelper;
809  m_nDragAction = eDNDConstants;
810  }
811  virtual void DumpAsPropertyTree(tools::JsonWriter&) override;
812 };
813 
814 //Get first window of a pTopLevel window as
815 //if any intermediate layout widgets didn't exist
816 //i.e. acts like pChild = pChild->GetWindow(GetWindowType::FirstChild);
817 //in a flat hierarchy where dialogs only have one layer
818 //of children
820 
821 //Get last window of a pTopLevel window as
822 //if any intermediate layout widgets didn't exist
823 //i.e. acts like pChild = pChild->GetWindow(GetWindowType::LastChild);
824 //in a flat hierarchy where dialogs only have one layer
825 //of children
827 
828 //Get next window after pChild of a pTopLevel window as
829 //if any intermediate layout widgets didn't exist
830 //i.e. acts like pChild = pChild->GetWindow(GetWindowType::Next);
831 //in a flat hierarchy where dialogs only have one layer
832 //of children
833 vcl::Window* nextLogicalChildOfParent(const vcl::Window *pTopLevel, const vcl::Window *pChild);
834 
835 //Get previous window before pChild of a pTopLevel window as
836 //if any intermediate layout widgets didn't exist
837 //i.e. acts like pChild = pChild->GetWindow(GetWindowType::Prev);
838 //in a flat hierarchy where dialogs only have one layer
839 //of children
840 vcl::Window* prevLogicalChildOfParent(const vcl::Window *pTopLevel, const vcl::Window *pChild);
841 
842 //Returns true is the Window has a single child which is a container
843 VCL_DLLPUBLIC bool isLayoutEnabled(const vcl::Window *pWindow);
844 
845 inline bool isContainerWindow(const vcl::Window &rWindow)
846 {
847  WindowType eType = rWindow.GetType();
848  return eType == WindowType::CONTAINER || eType == WindowType::SCROLLWINDOW ||
849  (eType == WindowType::DOCKINGWINDOW && ::isLayoutEnabled(&rWindow));
850 }
851 
852 inline bool isContainerWindow(const vcl::Window *pWindow)
853 {
854  return pWindow && isContainerWindow(*pWindow);
855 }
856 
857 // retro-fitting utilities
858 
859 //Get a Size which is large enough to contain all children with
860 //an equal amount of space at top left and bottom right
862 
863 //Get first parent which is not a layout widget
865 
866 //Sort ok/cancel etc buttons in platform order
867 void sort_native_button_order(VclBox& rContainer);
868 
869 #endif
870 
871 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void setPrimaryCoordinate(Point &rPos, long nPos) const override
Definition: layout.hxx:261
virtual void Command(const CommandEvent &rCEvt) override
Definition: layout.hxx:570
virtual long getPrimaryCoordinate(const Point &rPos) const override
Definition: layout.hxx:257
virtual sal_uInt16 getDefaultAccessibleRole() const override
Definition: layout.cxx:42
virtual void setSecondaryDimension(Size &rSize, long nWidth) const override
Definition: layout.hxx:155
bool m_bColumnHomogeneous
Definition: layout.hxx:322
virtual void setAllocation(const Size &rAllocation)=0
int get_column_spacing() const
Definition: layout.hxx:366
VclFrame(vcl::Window *pParent)
Definition: layout.hxx:437
virtual long getPrimaryDimension(const Size &rSize) const override
Definition: layout.hxx:135
bool get_vexpand() const
Definition: window2.cxx:1706
virtual FactoryFunction GetUITestFactory() const
Definition: window.cxx:3910
vcl::Window * lastLogicalChildOfParent(const vcl::Window *pTopLevel)
Definition: dialog.cxx:195
VclPtr< ScrollBar > m_pHScroll
Definition: layout.hxx:531
Link< VclDrawingArea &, void > m_aStyleUpdatedHdl
Definition: layout.hxx:652
virtual void setSecondaryDimension(Size &rSize, long nHeight) const override
Definition: layout.hxx:308
virtual void setPrimaryCoordinate(Point &rPos, long nPos) const override
Definition: layout.hxx:147
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: layout.hxx:743
Link< std::pair< vcl::RenderContext &, const tools::Rectangle & >, void > m_aPaintHdl
Definition: layout.hxx:645
virtual void MouseButtonDown(const MouseEvent &rMEvt)
Definition: mouse.cxx:414
VclPtr< vcl::Window > m_pLabel
Definition: layout.hxx:431
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: layout.hxx:690
signed char sal_Int8
VclVBox(vcl::Window *pParent, bool bHomogeneous=false, int nSpacing=0)
Definition: layout.hxx:129
bool m_bVerticalContainer
Definition: layout.hxx:80
VclDrawingArea(vcl::Window *pParent, WinBits nStyle)
Definition: layout.hxx:734
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
VclPtr< DisclosureButton > m_pDisclosureButton
Definition: layout.hxx:499
bool get_hexpand() const
Definition: window2.cxx:1694
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
ScrollBar & getHorzScrollBar()
Definition: layout.hxx:516
VclViewport(vcl::Window *pParent)
Definition: layout.hxx:538
void SetMousePressHdl(const Link< const MouseEvent &, bool > &rLink)
Definition: layout.hxx:770
virtual long getSecondaryDimension(const Size &rSize) const override
Definition: layout.hxx:151
virtual void StateChanged(StateChangedType nStateChange) override
Definition: ctrl.cxx:260
VclHButtonBox(vcl::Window *pParent)
Definition: layout.hxx:282
bool get_ignore_hidden() const
Definition: layout.hxx:625
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
virtual Size GetSizePixel() const
Definition: window.cxx:2396
void * GetUserData() const
Definition: layout.hxx:758
virtual void SetSizePixel(const Size &rNewSize)
Definition: window2.cxx:1262
virtual void MouseMove(const MouseEvent &rMEvt) override
Definition: layout.hxx:665
virtual Size GetOptimalSize() const
Definition: window3.cxx:33
bool m_bRowHomogeneous
Definition: layout.hxx:321
void set_row_spacing(int nSpacing)
Definition: layout.hxx:354
DataChangedEventType GetType() const
Definition: event.hxx:357
vcl::Window * getNonLayoutParent(vcl::Window *pParent)
Definition: layout.cxx:2782
void set_spacing(int nSpacing)
Definition: layout.hxx:90
Link< const CommandEvent &, bool > m_aCommandHdl
Definition: layout.hxx:653
bool m_bExpand
Definition: layout.hxx:330
VclButtonBoxStyle
Definition: layout.hxx:204
Size getLegacyBestSizeForChildren(const vcl::Window &rWindow)
Definition: layout.cxx:2757
std::set< VclPtr< vcl::Window > > & get_widgets()
Definition: layout.hxx:620
virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const override
Definition: layout.hxx:312
void SetQueryTooltipHdl(const Link< tools::Rectangle &, OUString > &rLink)
Definition: layout.hxx:798
virtual void MouseButtonUp(const MouseEvent &rMEvt)
Definition: mouse.cxx:421
vcl::Window * prevLogicalChildOfParent(const vcl::Window *pTopLevel, const vcl::Window *pChild)
Definition: dialog.cxx:159
HelpEventMode GetMode() const
Definition: event.hxx:205
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: layout.hxx:670
void SetKeyReleaseHdl(const Link< const KeyEvent &, bool > &rLink)
Definition: layout.hxx:786
Link< const KeyEvent &, bool > m_aKeyReleaseHdl
Definition: layout.hxx:651
StateChangedType
Definition: window.hxx:310
css::uno::Any const & rValue
rtl::Reference< TransferDataContainer > m_xTransferHelper
Definition: layout.hxx:643
sal_Int64 WinBits
std::set< VclPtr< vcl::Window > > m_aWindows
Definition: layout.hxx:597
virtual void setPrimaryDimension(Size &rSize, long nWidth) const override
Definition: layout.hxx:178
VclHBox(vcl::Window *pParent, bool bHomogeneous=false, int nSpacing=0)
Definition: layout.hxx:168
bool m_bLayoutDirty
Definition: layout.hxx:73
virtual void DumpAsPropertyTree(tools::JsonWriter &)
Dumps itself and potentially its children to a property tree, to be written easily to JSON...
Definition: window.cxx:3380
virtual Size calculateRequisition() const =0
Creates a hierarchy of vcl::Windows (widgets) from a .ui file for dialogs, sidebar, etc.
Definition: builder.hxx:64
AllSettingsFlags GetFlags() const
Definition: event.hxx:358
void SetKeyPressHdl(const Link< const KeyEvent &, bool > &rLink)
Definition: layout.hxx:782
VclSizeGroupMode
Definition: vclenum.hxx:264
Link< VclExpander &, void > maExpandedHdl
Definition: layout.hxx:500
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
Definition: window2.cxx:1314
sal_Int8 m_nDragAction
Definition: layout.hxx:644
virtual FactoryFunction GetUITestFactory() const override
Definition: layout.hxx:726
force balloon-style in ShowPopover and ShowQuickHelp
int m_nRowSpacing
Definition: layout.hxx:323
std::vector< long > m_aMainGroupDimensions
Definition: layout.hxx:231
WinBits const WB_HIDE
Link< VclDrawingArea *, bool > m_aStartDragHdl
Definition: layout.hxx:655
bool m_bResizeTopLevel
Definition: layout.hxx:498
void * m_pUserData
Definition: layout.hxx:642
bool isContainerWindow(const vcl::Window &rWindow)
Definition: layout.hxx:845
const Point & GetMousePosPixel() const
Definition: event.hxx:204
DocumentType eType
void SetExpandedHdl(const Link< VclExpander &, void > &rLink)
Definition: layout.hxx:494
void SetStartDragHdl(const Link< VclDrawingArea *, bool > &rLink)
Definition: layout.hxx:802
virtual long getPrimaryCoordinate(const Point &rPos) const override
Definition: layout.hxx:143
void SetResizeHdl(const Link< const Size &, void > &rLink)
Definition: layout.hxx:766
void setUserManagedScrolling(bool bUserManagedScrolling)
Definition: layout.hxx:520
void erase(vcl::Window *pWindow)
Definition: layout.hxx:612
virtual void setAllocation(const Size &rAllocation) override
Definition: layout.cxx:242
VclPtr< ScrollBarBox > m_aScrollBarBox
Definition: layout.hxx:532
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
Definition: layout.hxx:748
DrawFrameStyle m_eDrawFrameStyle
Definition: layout.hxx:529
VclPtr< ScrollBar > m_pVScroll
Definition: layout.hxx:530
void SetStyleUpdatedHdl(const Link< VclDrawingArea &, void > &rLink)
Definition: layout.hxx:790
virtual void Resize() override
Definition: layout.hxx:661
bool m_bIgnoreHidden
Definition: layout.hxx:598
QuickHelpFlags
Definition: help.hxx:32
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:302
virtual void setPrimaryDimension(Size &rSize, long nHeight) const override
Definition: layout.hxx:253
VclSizeGroupMode get_mode() const
Definition: layout.hxx:630
const std::set< VclPtr< vcl::Window > > & get_widgets() const
Definition: layout.hxx:616
virtual long getPrimaryDimension(const Size &rSize) const override
Definition: layout.hxx:249
VclSizeGroupMode m_eMode
Definition: layout.hxx:599
void sort_native_button_order(VclBox &rContainer)
Definition: layout.cxx:792
virtual sal_uInt16 getDefaultAccessibleRole() const
void set_homogeneous(bool bHomogeneous)
Definition: layout.hxx:98
EventBoxHelper(vcl::Window *pParent)
Definition: layout.hxx:562
Base class used mainly for the LibreOffice Desktop class.
Definition: svapp.hxx:237
VclPtr< Splitter > m_pSplitter
Definition: layout.hxx:389
bool get_row_homogeneous() const
Definition: layout.hxx:346
virtual bool set_property(const OString &rKey, const OUString &rValue)
Definition: window2.cxx:1431
FactoryFunction m_pFactoryFunction
Definition: layout.hxx:641
bool get_orientation() const
Definition: layout.hxx:102
static void ShowQuickHelp(vcl::Window *pParent, const tools::Rectangle &rScreenRect, const OUString &rHelpText, QuickHelpFlags nStyle=QuickHelpFlags::NONE)
Definition: help.cxx:180
virtual long getSecondaryDimension(const Size &rSize) const override
Definition: layout.hxx:190
void SetPaintHdl(const Link< std::pair< vcl::RenderContext &, const tools::Rectangle & >, void > &rLink)
Definition: layout.hxx:762
virtual void KeyUp(const KeyEvent &rKEvt) override
Definition: layout.hxx:676
Link< const MouseEvent &, bool > m_aMouseMotionHdl
Definition: layout.hxx:648
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize)
Definition: window2.cxx:1268
bool get_expand() const
Definition: window2.cxx:1718
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: layout.hxx:657
Link< const Size &, void > m_aResizeHdl
Definition: layout.hxx:646
DrawFrameStyle
Definition: vclenum.hxx:332
VclButtonBox(vcl::Window *pParent)
Definition: layout.hxx:217
virtual long getPrimaryCoordinate(const Point &rPos) const override
Definition: layout.hxx:296
vcl::Window * firstLogicalChildOfParent(const vcl::Window *pTopLevel)
Definition: dialog.cxx:187
virtual void set_position(long nPosition)
Definition: layout.hxx:397
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1800
bool m_bInitialAllocation
Definition: layout.hxx:545
Link< const MouseEvent &, bool > m_aMousePressHdl
Definition: layout.hxx:647
void SetUITestFactory(FactoryFunction pFactoryFunction, void *pUserData)
Definition: layout.hxx:753
void SetDragHelper(rtl::Reference< TransferDataContainer > &rHelper, sal_uInt8 eDNDConstants)
Definition: layout.hxx:806
virtual long getPrimaryDimension(const Size &rSize) const override
Definition: layout.hxx:174
VclVButtonBox(vcl::Window *pParent)
Definition: layout.hxx:243
Link< const MouseEvent &, bool > m_aMouseReleaseHdl
Definition: layout.hxx:649
WindowType
virtual long getPrimaryCoordinate(const Point &rPos) const override
Definition: layout.hxx:182
Definition: ctrl.hxx:33
bool get_column_homogeneous() const
Definition: layout.hxx:350
unsigned char sal_uInt8
int m_nSpacing
Definition: layout.hxx:81
long m_nPosition
Definition: layout.hxx:390
virtual void setPrimaryCoordinate(Point &rPos, long nPos) const override
Definition: layout.hxx:300
VclPtr< EventBoxHelper > m_aEventBoxHelper
Definition: layout.hxx:576
void set_column_spacing(int nSpacing)
Definition: layout.hxx:358
virtual long getPrimaryDimension(const Size &rSize) const override
Definition: layout.hxx:288
void SetCommandHdl(const Link< const CommandEvent &, bool > &rLink)
Definition: layout.hxx:794
virtual void setPrimaryCoordinate(Point &rPos, long nPos) const override
Definition: layout.hxx:186
QPRO_FUNC_TYPE nType
virtual void RequestHelp(const HelpEvent &rHelpEvent) override
Definition: layout.hxx:705
Link< tools::Rectangle &, OUString > m_aQueryTooltipHdl
Definition: layout.hxx:654
virtual void setPrimaryDimension(Size &rSize, long nHeight) const override
Definition: layout.hxx:139
ScrollBar & getVertScrollBar()
Definition: layout.hxx:515
virtual long getSecondaryDimension(const Size &rSize) const override
Definition: layout.hxx:304
virtual void KeyUp(const KeyEvent &rKEvt)
Definition: window.cxx:1817
void insert(vcl::Window *pWindow)
Definition: layout.hxx:608
std::vector< long > m_aSubGroupDimensions
Definition: layout.hxx:232
VCL_DLLPUBLIC bool isLayoutEnabled(const vcl::Window *pWindow)
Definition: layout.cxx:2819
virtual long getSecondaryDimension(const Size &rSize) const override
Definition: layout.hxx:265
VclBox(vcl::Window *pParent, bool bHomogeneous, int nSpacing)
Definition: layout.hxx:83
virtual void setSecondaryDimension(Size &rSize, long nHeight) const override
Definition: layout.hxx:194
WindowType GetType() const
Definition: window2.cxx:974
virtual void MouseMove(const MouseEvent &rMEvt)
Definition: mouse.cxx:408
virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const override
Definition: layout.hxx:273
virtual void StateChanged(StateChangedType nType) override
Definition: layout.hxx:681
virtual Size calculateRequisition() const override
Definition: layout.cxx:220
virtual void setSecondaryDimension(Size &rSize, long nWidth) const override
Definition: layout.hxx:269
virtual void setPrimaryDimension(Size &rSize, long nWidth) const override
Definition: layout.hxx:292
int m_nColumnSpacing
Definition: layout.hxx:324
long get_position() const
Definition: layout.hxx:396
long getHeight() const
VclEventBox(vcl::Window *pParent)
Definition: layout.hxx:580
VclGrid(vcl::Window *pParent)
Definition: layout.hxx:340
void dispose()
vcl::Window * nextLogicalChildOfParent(const vcl::Window *pTopLevel, const vcl::Window *pChild)
Definition: dialog.cxx:131
virtual void Command(const CommandEvent &rCEvt)
Definition: window.cxx:1918
int get_row_spacing() const
Definition: layout.hxx:362
long getWidth() const
bool m_bUserManagedScrolling
Definition: layout.hxx:528
void setWidth(long nWidth)
bool m_bHomogeneous
Definition: layout.hxx:79
WinBits const WB_CLIPCHILDREN
virtual void SetPosPixel(const Point &rNewPos)
Definition: window2.cxx:1257
virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const override
Definition: layout.hxx:198
void SetMouseMoveHdl(const Link< const MouseEvent &, bool > &rLink)
Definition: layout.hxx:774
int get_spacing() const
Definition: layout.hxx:94
VclButtonBoxStyle m_eLayoutStyle
Definition: layout.hxx:228
virtual void Command(const CommandEvent &rEvent) override
Definition: layout.hxx:699
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:35
void SetMouseReleaseHdl(const Link< const MouseEvent &, bool > &rLink)
Definition: layout.hxx:778
virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const override
Definition: layout.hxx:159
Link< const KeyEvent &, bool > m_aKeyPressHdl
Definition: layout.hxx:650
bool HasVisibleBorder() const
Definition: layout.hxx:514
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: layout.cxx:353
void setHeight(long nHeight)