bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / vcl / layout.hxx
blobcb031a0efe3bc8f984ce231cc7e4e96ac3a2acb5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #ifndef INCLUDED_VCL_LAYOUT_HXX
11 #define INCLUDED_VCL_LAYOUT_HXX
13 #include <vcl/dllapi.h>
14 #include <vcl/button.hxx>
15 #include <vcl/help.hxx>
16 #include <vcl/scrbar.hxx>
17 #include <vcl/split.hxx>
18 #include <vcl/svapp.hxx>
19 #include <vcl/window.hxx>
20 #include <vcl/settings.hxx>
21 #include <vcl/event.hxx>
22 #include <vcl/vclptr.hxx>
23 #include <vcl/IContext.hxx>
24 #include <vcl/commandevent.hxx>
25 #include <set>
27 class VCL_DLLPUBLIC VclContainer : public vcl::Window,
28 public vcl::IContext
30 public:
31 VclContainer(vcl::Window *pParent, WinBits nStyle = WB_HIDE | WB_CLIPCHILDREN);
33 //These take into account the external margins of the rWindow widget
34 //while GetOptimalSize/get_preferred_size and SetPosSizePixel are
35 //oblivious to them
36 static Size getLayoutRequisition(const vcl::Window &rWindow);
37 static void setLayoutPosSize(vcl::Window &rWindow, const Point &rPos, const Size &rSize);
39 //applies the allocation pos and size onto rWindow via setLayoutPosSize taking into account
40 //the rWindows alignment desires within that allocation
41 static void setLayoutAllocation(vcl::Window &rWindow, const Point &rPos, const Size &rSize);
43 virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
44 protected:
45 //these are the two that need to be implemented by
46 //containers, figure out how much space you want...
47 virtual Size calculateRequisition() const = 0;
48 //..and decide what to do when set to this size
49 virtual void setAllocation(const Size &rAllocation) = 0;
51 virtual sal_uInt16 getDefaultAccessibleRole() const override;
53 // evtl. support for screenshot context menu
54 virtual void Command(const CommandEvent& rCEvt) override;
56 public:
57 //you don't want to override these
58 virtual Size GetOptimalSize() const override;
59 virtual void SetPosSizePixel(const Point& rNewPos, const Size& rNewSize) override;
60 virtual void SetPosPixel(const Point& rAllocPos) override;
61 virtual void SetSizePixel(const Size& rAllocation) override;
62 private:
63 bool m_bLayoutDirty;
66 class VCL_DLLPUBLIC VclBox : public VclContainer
68 protected:
69 bool m_bHomogeneous;
70 bool m_bVerticalContainer;
71 int m_nSpacing;
72 public:
73 VclBox(vcl::Window *pParent, bool bHomogeneous, int nSpacing)
74 : VclContainer(pParent)
75 , m_bHomogeneous(bHomogeneous)
76 , m_bVerticalContainer(false)
77 , m_nSpacing(nSpacing)
80 void set_spacing(int nSpacing)
82 m_nSpacing = nSpacing;
84 int get_spacing() const
86 return m_nSpacing;
88 void set_homogeneous(bool bHomogeneous)
90 m_bHomogeneous = bHomogeneous;
92 virtual bool set_property(const OString &rKey, const OUString &rValue) override;
93 protected:
94 virtual sal_uInt16 getDefaultAccessibleRole() const override;
95 void accumulateMaxes(const Size &rChildSize, Size &rSize) const;
96 Size finalizeMaxes(const Size &rSize, sal_uInt16 nVisibleChildren) const;
98 virtual Size calculateRequisition() const override;
99 virtual void setAllocation(const Size &rAllocation) override;
101 virtual long getPrimaryDimension(const Size &rSize) const = 0;
102 virtual void setPrimaryDimension(Size &rSize, long) const = 0;
103 virtual long getPrimaryCoordinate(const Point &rPos) const = 0;
104 virtual void setPrimaryCoordinate(Point &rPos, long) const = 0;
105 virtual long getSecondaryDimension(const Size &rSize) const = 0;
106 virtual void setSecondaryDimension(Size &rSize, long) const = 0;
108 virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const = 0;
111 class VCL_DLLPUBLIC VclVBox : public VclBox
113 public:
114 VclVBox(vcl::Window *pParent, bool bHomogeneous = false, int nSpacing = 0)
115 : VclBox(pParent, bHomogeneous, nSpacing)
117 m_bVerticalContainer = true;
119 protected:
120 virtual long getPrimaryDimension(const Size &rSize) const override
122 return rSize.getHeight();
124 virtual void setPrimaryDimension(Size &rSize, long nHeight) const override
126 rSize.setHeight(nHeight);
128 virtual long getPrimaryCoordinate(const Point &rPos) const override
130 return rPos.getY();
132 virtual void setPrimaryCoordinate(Point &rPos, long nPos) const override
134 rPos.setY(nPos);
136 virtual long getSecondaryDimension(const Size &rSize) const override
138 return rSize.getWidth();
140 virtual void setSecondaryDimension(Size &rSize, long nWidth) const override
142 rSize.setWidth(nWidth);
144 virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const override
146 return rWindow.get_expand() || rWindow.get_vexpand();
150 class VCL_DLLPUBLIC VclHBox : public VclBox
152 public:
153 VclHBox(vcl::Window *pParent, bool bHomogeneous = false, int nSpacing = 0)
154 : VclBox(pParent, bHomogeneous, nSpacing)
156 m_bVerticalContainer = false;
158 protected:
159 virtual long getPrimaryDimension(const Size &rSize) const override
161 return rSize.getWidth();
163 virtual void setPrimaryDimension(Size &rSize, long nWidth) const override
165 rSize.setWidth(nWidth);
167 virtual long getPrimaryCoordinate(const Point &rPos) const override
169 return rPos.getX();
171 virtual void setPrimaryCoordinate(Point &rPos, long nPos) const override
173 rPos.setX(nPos);
175 virtual long getSecondaryDimension(const Size &rSize) const override
177 return rSize.getHeight();
179 virtual void setSecondaryDimension(Size &rSize, long nHeight) const override
181 rSize.setHeight(nHeight);
183 virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const override
185 return rWindow.get_expand() || rWindow.get_hexpand();
189 enum class VclButtonBoxStyle
191 Default,
192 Spread,
193 Edge,
194 Start,
195 End,
196 Center
199 class VCL_DLLPUBLIC VclButtonBox : public VclBox
201 public:
202 VclButtonBox(vcl::Window *pParent)
203 : VclBox(pParent, false, Application::GetSettings().GetStyleSettings().GetDialogStyle().button_spacing)
204 , m_eLayoutStyle(VclButtonBoxStyle::Default)
207 virtual bool set_property(const OString &rKey, const OUString &rValue) override;
208 void sort_native_button_order();
209 protected:
210 virtual Size calculateRequisition() const override;
211 virtual void setAllocation(const Size &rAllocation) override;
212 Size addSpacing(const Size &rSize, sal_uInt16 nVisibleChildren) const;
213 private:
214 VclButtonBoxStyle m_eLayoutStyle;
215 struct Requisition
217 std::vector<long> m_aMainGroupDimensions;
218 std::vector<long> m_aSubGroupDimensions;
219 Size m_aMainGroupSize;
220 Size m_aSubGroupSize;
222 Requisition calculatePrimarySecondaryRequisitions() const;
223 Size addReqGroups(const VclButtonBox::Requisition &rReq) const;
226 class VCL_DLLPUBLIC VclVButtonBox : public VclButtonBox
228 public:
229 VclVButtonBox(vcl::Window *pParent)
230 : VclButtonBox(pParent)
232 m_bVerticalContainer = true;
234 protected:
235 virtual long getPrimaryDimension(const Size &rSize) const override
237 return rSize.getHeight();
239 virtual void setPrimaryDimension(Size &rSize, long nHeight) const override
241 rSize.setHeight(nHeight);
243 virtual long getPrimaryCoordinate(const Point &rPos) const override
245 return rPos.getY();
247 virtual void setPrimaryCoordinate(Point &rPos, long nPos) const override
249 rPos.setY(nPos);
251 virtual long getSecondaryDimension(const Size &rSize) const override
253 return rSize.getWidth();
255 virtual void setSecondaryDimension(Size &rSize, long nWidth) const override
257 rSize.setWidth(nWidth);
259 virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const override
261 return rWindow.get_expand() || rWindow.get_vexpand();
265 class VCL_DLLPUBLIC VclHButtonBox : public VclButtonBox
267 public:
268 VclHButtonBox(vcl::Window *pParent)
269 : VclButtonBox(pParent)
271 m_bVerticalContainer = false;
273 protected:
274 virtual long getPrimaryDimension(const Size &rSize) const override
276 return rSize.getWidth();
278 virtual void setPrimaryDimension(Size &rSize, long nWidth) const override
280 rSize.setWidth(nWidth);
282 virtual long getPrimaryCoordinate(const Point &rPos) const override
284 return rPos.getX();
286 virtual void setPrimaryCoordinate(Point &rPos, long nPos) const override
288 rPos.setX(nPos);
290 virtual long getSecondaryDimension(const Size &rSize) const override
292 return rSize.getHeight();
294 virtual void setSecondaryDimension(Size &rSize, long nHeight) const override
296 rSize.setHeight(nHeight);
298 virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const override
300 return rWindow.get_expand() || rWindow.get_hexpand();
304 class VCL_DLLPUBLIC VclGrid : public VclContainer
306 private:
307 bool m_bRowHomogeneous;
308 bool m_bColumnHomogeneous;
309 int m_nRowSpacing;
310 int m_nColumnSpacing;
312 public:
313 struct Value
315 long m_nValue;
316 bool m_bExpand;
317 Value() : m_nValue(0), m_bExpand(false) {}
319 private:
321 Size calculateRequisitionForSpacings(sal_Int32 nRowSpacing, sal_Int32 nColSpacing) const;
322 virtual Size calculateRequisition() const override;
323 virtual void setAllocation(const Size &rAllocation) override;
324 public:
325 VclGrid(vcl::Window *pParent)
326 : VclContainer(pParent)
327 , m_bRowHomogeneous(false), m_bColumnHomogeneous(false)
328 , m_nRowSpacing(0), m_nColumnSpacing(0)
331 bool get_row_homogeneous() const
333 return m_bRowHomogeneous;
335 bool get_column_homogeneous() const
337 return m_bColumnHomogeneous;
339 void set_row_spacing(int nSpacing)
341 m_nRowSpacing = nSpacing;
343 void set_column_spacing(int nSpacing)
345 m_nColumnSpacing = nSpacing;
347 int get_row_spacing() const
349 return m_nRowSpacing;
351 int get_column_spacing() const
353 return m_nColumnSpacing;
355 virtual bool set_property(const OString &rKey, const OUString &rValue) override;
358 class VCL_DLLPUBLIC VclBin : public VclContainer
360 public:
361 VclBin(vcl::Window *pParent, WinBits nStyle = WB_HIDE | WB_CLIPCHILDREN)
362 : VclContainer(pParent, nStyle)
365 virtual vcl::Window *get_child();
366 virtual const vcl::Window *get_child() const;
367 virtual Size calculateRequisition() const override;
368 virtual void setAllocation(const Size &rAllocation) override;
371 class VCL_DLLPUBLIC VclVPaned : public VclContainer
373 private:
374 VclPtr<Splitter> m_pSplitter;
375 long m_nPosition;
376 DECL_LINK(SplitHdl, Splitter*, void);
377 void arrange(const Size& rAllocation, long nFirstHeight, long nSecondHeight);
378 public:
379 VclVPaned(vcl::Window *pParent);
380 virtual ~VclVPaned() override { disposeOnce(); }
381 virtual void dispose() override;
382 virtual Size calculateRequisition() const override;
383 virtual void setAllocation(const Size &rAllocation) override;
384 long get_position() const { return m_nPosition; }
385 void set_position(long nPosition) { m_nPosition = nPosition; }
388 class VCL_DLLPUBLIC VclFrame : public VclBin
390 private:
391 VclPtr<vcl::Window> m_pLabel;
392 private:
393 friend class VclBuilder;
394 void designate_label(vcl::Window *pWindow);
395 DECL_LINK(WindowEventListener, VclWindowEvent&, void);
396 public:
397 VclFrame(vcl::Window *pParent)
398 : VclBin(pParent)
399 , m_pLabel(nullptr)
402 virtual ~VclFrame() override;
403 virtual void dispose() override;
404 void set_label(const OUString &rLabel);
405 OUString get_label() const;
406 virtual vcl::Window *get_child() override;
407 virtual const vcl::Window *get_child() const override;
408 vcl::Window *get_label_widget();
409 const vcl::Window *get_label_widget() const;
410 protected:
411 virtual Size calculateRequisition() const override;
412 virtual void setAllocation(const Size &rAllocation) override;
413 virtual OUString getDefaultAccessibleName() const override;
416 class VCL_DLLPUBLIC VclAlignment : public VclBin
418 public:
419 VclAlignment(vcl::Window *pParent)
420 : VclBin(pParent)
421 , m_nBottomPadding(0)
422 , m_nLeftPadding(0)
423 , m_nRightPadding(0)
424 , m_nTopPadding(0)
427 virtual bool set_property(const OString &rKey, const OUString &rValue) override;
428 protected:
429 virtual Size calculateRequisition() const override;
430 virtual void setAllocation(const Size &rAllocation) override;
431 private:
432 sal_Int32 m_nBottomPadding;
433 sal_Int32 m_nLeftPadding;
434 sal_Int32 m_nRightPadding;
435 sal_Int32 m_nTopPadding;
438 class VCL_DLLPUBLIC VclExpander : public VclBin
440 public:
441 VclExpander(vcl::Window *pParent)
442 : VclBin(pParent)
443 , m_bResizeTopLevel(true)
444 , m_pDisclosureButton(VclPtr<DisclosureButton>::Create(this))
446 m_pDisclosureButton->SetToggleHdl(LINK(this, VclExpander, ClickHdl));
447 m_pDisclosureButton->Show();
449 virtual ~VclExpander() override { disposeOnce(); }
450 virtual void dispose() override;
451 virtual vcl::Window *get_child() override;
452 virtual const vcl::Window *get_child() const override;
453 virtual bool set_property(const OString &rKey, const OUString &rValue) override;
454 bool get_expanded() const
456 return m_pDisclosureButton->IsChecked();
458 void set_expanded(bool bExpanded)
460 m_pDisclosureButton->Check(bExpanded);
462 void set_label(const OUString& rLabel)
464 m_pDisclosureButton->SetText(rLabel);
466 virtual void StateChanged(StateChangedType nType) override;
467 void SetExpandedHdl( const Link<VclExpander&,void>& rLink ) { maExpandedHdl = rLink; }
468 protected:
469 virtual Size calculateRequisition() const override;
470 virtual void setAllocation(const Size &rAllocation) override;
471 private:
472 bool m_bResizeTopLevel;
473 VclPtr<DisclosureButton> m_pDisclosureButton;
474 Link<VclExpander&,void> maExpandedHdl;
475 DECL_DLLPRIVATE_LINK(ClickHdl, CheckBox&, void);
478 class VCL_DLLPUBLIC VclScrolledWindow : public VclBin
480 public:
481 VclScrolledWindow(vcl::Window *pParent );
482 virtual ~VclScrolledWindow() override { disposeOnce(); }
483 virtual void dispose() override;
484 virtual vcl::Window *get_child() override;
485 virtual const vcl::Window *get_child() const override;
486 virtual bool set_property(const OString &rKey, const OUString &rValue) override;
487 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
488 ScrollBar& getVertScrollBar() { return *m_pVScroll; }
489 ScrollBar& getHorzScrollBar() { return *m_pHScroll; }
490 Size getVisibleChildSize() const;
491 //set to true to disable the built-in scrolling callbacks to allow the user
492 //to override it
493 void setUserManagedScrolling(bool bUserManagedScrolling) { m_bUserManagedScrolling = bUserManagedScrolling;}
494 private:
495 virtual Size calculateRequisition() const override;
496 virtual void setAllocation(const Size &rAllocation) override;
497 DECL_LINK(ScrollBarHdl, ScrollBar*, void);
498 void InitScrollBars(const Size &rRequest);
499 virtual bool EventNotify(NotifyEvent& rNEvt) override;
500 bool m_bUserManagedScrolling;
501 VclPtr<ScrollBar> m_pVScroll;
502 VclPtr<ScrollBar> m_pHScroll;
503 VclPtr<ScrollBarBox> m_aScrollBarBox;
506 class VCL_DLLPUBLIC VclViewport : public VclBin
508 public:
509 VclViewport(vcl::Window *pParent)
510 : VclBin(pParent, WB_HIDE | WB_CLIPCHILDREN)
511 , m_bInitialAllocation(true)
514 protected:
515 virtual void setAllocation(const Size &rAllocation) override;
516 private:
517 bool m_bInitialAllocation;
520 //Enforces that its children are always the same size as itself.
521 //Intercepts any Commands intended for its children.
523 //by default the Commands are discarded, inherit from this
524 //and implement "Command" to get them
525 class VCL_DLLPUBLIC VclEventBox : public VclBin
527 private:
528 //Any Commands an EventBoxHelper receives are forwarded to its parent
529 //The VclEventBox ensures that m_aEventBoxHelper is the
530 //first child and is transparent, but covers the rest of the children
531 class EventBoxHelper : public vcl::Window
533 public:
534 EventBoxHelper(vcl::Window* pParent)
535 : Window(pParent, 0)
537 SetSizePixel(pParent->GetSizePixel());
538 EnableChildTransparentMode();
539 SetPaintTransparent(true);
540 SetBackground();
542 virtual void Command(const CommandEvent& rCEvt) override
544 GetParent()->Command(rCEvt);
548 VclPtr<EventBoxHelper> m_aEventBoxHelper;
549 protected:
550 virtual void dispose() override;
551 virtual ~VclEventBox() override;
552 public:
553 VclEventBox(vcl::Window* pParent)
554 : VclBin(pParent)
555 , m_aEventBoxHelper(VclPtr<EventBoxHelper>::Create(this))
557 m_aEventBoxHelper->Show();
559 virtual vcl::Window *get_child() override;
560 virtual const vcl::Window *get_child() const override;
561 virtual Size calculateRequisition() const override;
562 virtual void setAllocation(const Size &rAllocation) override;
564 virtual void Command(const CommandEvent& rCEvt) override;
567 class VCL_DLLPUBLIC VclSizeGroup
569 private:
570 std::set< VclPtr<vcl::Window> > m_aWindows;
571 bool m_bIgnoreHidden;
572 VclSizeGroupMode m_eMode;
574 void trigger_queue_resize();
575 public:
576 VclSizeGroup()
577 : m_bIgnoreHidden(false)
578 , m_eMode(VclSizeGroupMode::Horizontal)
581 void insert(vcl::Window *pWindow)
583 m_aWindows.insert(VclPtr<vcl::Window>(pWindow));
585 void erase(vcl::Window *pWindow)
587 m_aWindows.erase(VclPtr<vcl::Window>(pWindow));
589 const std::set< VclPtr<vcl::Window> >& get_widgets() const
591 return m_aWindows;
593 std::set< VclPtr<vcl::Window> >& get_widgets()
595 return m_aWindows;
597 void set_ignore_hidden(bool bIgnoreHidden);
598 bool get_ignore_hidden() const
600 return m_bIgnoreHidden;
602 void set_mode(VclSizeGroupMode eMode);
603 VclSizeGroupMode get_mode() const
605 return m_eMode;
607 void set_property(const OString &rKey, const OUString &rValue);
610 class VCL_DLLPUBLIC VclDrawingArea : public Control
612 private:
613 FactoryFunction m_pFactoryFunction;
614 void* m_pUserData;
615 Link<std::pair<vcl::RenderContext&, const tools::Rectangle&>, void> m_aPaintHdl;
616 Link<const Size&, void> m_aResizeHdl;
617 Link<const MouseEvent&, bool> m_aMousePressHdl;
618 Link<const MouseEvent&, bool> m_aMouseMotionHdl;
619 Link<const MouseEvent&, bool> m_aMouseReleaseHdl;
620 Link<const KeyEvent&, bool> m_aKeyPressHdl;
621 Link<const KeyEvent&, bool> m_aKeyReleaseHdl;
622 Link<VclDrawingArea&, void> m_aStyleUpdatedHdl;
623 Link<const CommandEvent&, bool> m_aPopupMenuHdl;
624 Link<tools::Rectangle&, OUString> m_aQueryTooltipHdl;
626 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override
628 m_aPaintHdl.Call(std::pair<vcl::RenderContext&, const tools::Rectangle&>(rRenderContext, rRect));
630 virtual void Resize() override
632 m_aResizeHdl.Call(GetOutputSizePixel());
634 virtual void MouseMove(const MouseEvent& rMEvt) override
636 if (!m_aMouseMotionHdl.Call(rMEvt))
637 Control::MouseMove(rMEvt);
639 virtual void MouseButtonDown(const MouseEvent& rMEvt) override
641 if (!m_aMousePressHdl.Call(rMEvt))
642 Control::MouseButtonDown(rMEvt);
644 virtual void MouseButtonUp(const MouseEvent& rMEvt) override
646 if (!m_aMouseReleaseHdl.Call(rMEvt))
647 Control::MouseButtonUp(rMEvt);
649 virtual void KeyInput(const KeyEvent& rKEvt) override
651 if (!m_aKeyPressHdl.Call(rKEvt))
652 Control::KeyInput(rKEvt);
655 virtual void KeyUp(const KeyEvent& rKEvt) override
657 if (!m_aKeyReleaseHdl.Call(rKEvt))
658 Control::KeyUp(rKEvt);
660 virtual void StateChanged(StateChangedType nType) override
662 Control::StateChanged(nType);
663 if (nType == StateChangedType::ControlForeground || nType == StateChangedType::ControlBackground)
665 m_aStyleUpdatedHdl.Call(*this);
666 Invalidate();
669 virtual void DataChanged(const DataChangedEvent& rDCEvt) override
671 Control::DataChanged(rDCEvt);
672 if ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) && (rDCEvt.GetFlags() & AllSettingsFlags::STYLE))
674 m_aStyleUpdatedHdl.Call(*this);
675 Invalidate();
678 virtual void Command(const CommandEvent& rEvent) override
680 if (rEvent.GetCommand() == CommandEventId::ContextMenu && m_aPopupMenuHdl.Call(rEvent))
681 return;
682 Control::Command(rEvent);
684 virtual void RequestHelp(const HelpEvent& rHelpEvent) override
686 if (rHelpEvent.GetMode() & (HelpEventMode::QUICK | HelpEventMode::BALLOON))
688 Point aPos(ScreenToOutputPixel(rHelpEvent.GetMousePosPixel()));
689 tools::Rectangle aHelpArea(aPos.X(), aPos.Y());
690 OUString sHelpTip = m_aQueryTooltipHdl.Call(aHelpArea);
691 if (sHelpTip.isEmpty())
692 return;
693 Point aPt = OutputToScreenPixel(aHelpArea.TopLeft());
694 aHelpArea.SetLeft(aPt.X());
695 aHelpArea.SetTop(aPt.Y());
696 aPt = OutputToScreenPixel(aHelpArea.BottomRight());
697 aHelpArea.SetRight(aPt.X());
698 aHelpArea.SetBottom(aPt.Y());
699 // tdf#125369 recover newline support of tdf#101779
700 QuickHelpFlags eHelpWinStyle = sHelpTip.indexOf('\n') != -1 ? QuickHelpFlags::TipStyleBalloon : QuickHelpFlags::NONE;
701 Help::ShowQuickHelp(this, aHelpArea, sHelpTip, eHelpWinStyle);
704 virtual FactoryFunction GetUITestFactory() const override
706 if (m_pFactoryFunction)
707 return m_pFactoryFunction;
708 return Control::GetUITestFactory();
711 public:
712 VclDrawingArea(vcl::Window *pParent, WinBits nStyle)
713 : Control(pParent, nStyle)
714 , m_pFactoryFunction(nullptr)
715 , m_pUserData(nullptr)
717 SetBackground();
719 void SetUITestFactory(FactoryFunction pFactoryFunction, void* pUserData)
721 m_pFactoryFunction = pFactoryFunction;
722 m_pUserData = pUserData;
724 void* GetUserData() const
726 return m_pUserData;
728 void SetPaintHdl(const Link<std::pair<vcl::RenderContext&, const tools::Rectangle&>, void>& rLink)
730 m_aPaintHdl = rLink;
732 void SetResizeHdl(const Link<const Size&, void>& rLink)
734 m_aResizeHdl = rLink;
736 void SetMousePressHdl(const Link<const MouseEvent&, bool>& rLink)
738 m_aMousePressHdl = rLink;
740 void SetMouseMoveHdl(const Link<const MouseEvent&, bool>& rLink)
742 m_aMouseMotionHdl = rLink;
744 void SetMouseReleaseHdl(const Link<const MouseEvent&, bool>& rLink)
746 m_aMouseReleaseHdl = rLink;
748 void SetKeyPressHdl(const Link<const KeyEvent&, bool>& rLink)
750 m_aKeyPressHdl = rLink;
752 void SetKeyReleaseHdl(const Link<const KeyEvent&, bool>& rLink)
754 m_aKeyReleaseHdl = rLink;
756 void SetStyleUpdatedHdl(const Link<VclDrawingArea&, void>& rLink)
758 m_aStyleUpdatedHdl = rLink;
760 void SetPopupMenuHdl(const Link<const CommandEvent&, bool>& rLink)
762 m_aPopupMenuHdl = rLink;
764 void SetQueryTooltipHdl(const Link<tools::Rectangle&, OUString>& rLink)
766 m_aQueryTooltipHdl = rLink;
770 //Get first window of a pTopLevel window as
771 //if any intermediate layout widgets didn't exist
772 //i.e. acts like pChild = pChild->GetWindow(GetWindowType::FirstChild);
773 //in a flat hierarchy where dialogs only have one layer
774 //of children
775 VCL_DLLPUBLIC vcl::Window* firstLogicalChildOfParent(const vcl::Window *pTopLevel);
777 //Get last window of a pTopLevel window as
778 //if any intermediate layout widgets didn't exist
779 //i.e. acts like pChild = pChild->GetWindow(GetWindowType::LastChild);
780 //in a flat hierarchy where dialogs only have one layer
781 //of children
782 VCL_DLLPUBLIC vcl::Window* lastLogicalChildOfParent(const vcl::Window *pTopLevel);
784 //Get next window after pChild of a pTopLevel window as
785 //if any intermediate layout widgets didn't exist
786 //i.e. acts like pChild = pChild->GetWindow(GetWindowType::Next);
787 //in a flat hierarchy where dialogs only have one layer
788 //of children
789 VCL_DLLPUBLIC vcl::Window* nextLogicalChildOfParent(const vcl::Window *pTopLevel, const vcl::Window *pChild);
791 //Get previous window before pChild of a pTopLevel window as
792 //if any intermediate layout widgets didn't exist
793 //i.e. acts like pChild = pChild->GetWindow(GetWindowType::Prev);
794 //in a flat hierarchy where dialogs only have one layer
795 //of children
796 VCL_DLLPUBLIC vcl::Window* prevLogicalChildOfParent(const vcl::Window *pTopLevel, const vcl::Window *pChild);
798 //Returns true is the Window has a single child which is a container
799 VCL_DLLPUBLIC bool isLayoutEnabled(const vcl::Window *pWindow);
801 inline bool isContainerWindow(const vcl::Window &rWindow)
803 WindowType eType = rWindow.GetType();
804 return eType == WindowType::CONTAINER || eType == WindowType::SCROLLWINDOW ||
805 (eType == WindowType::DOCKINGWINDOW && ::isLayoutEnabled(&rWindow));
808 inline bool isContainerWindow(const vcl::Window *pWindow)
810 return pWindow && isContainerWindow(*pWindow);
813 //Returns true if the containing dialog is doing its initial
814 //layout and isn't visible yet
815 VCL_DLLPUBLIC bool isInitialLayout(const vcl::Window *pWindow);
817 // retro-fitting utilities
819 //Get a Size which is large enough to contain all children with
820 //an equal amount of space at top left and bottom right
821 Size getLegacyBestSizeForChildren(const vcl::Window &rWindow);
823 //Get first parent which is not a layout widget
824 VCL_DLLPUBLIC vcl::Window* getNonLayoutParent(vcl::Window *pParent);
826 #endif
828 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */