lok: calc - send other views our selection in their co-ordinates.
[LibreOffice.git] / include / vcl / layout.hxx
blob9d8290929db67f6d41df9ea4437ff61c596b1d8c
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 // 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 virtual boost::property_tree::ptree DumpAsPropertyTree() override;
94 protected:
95 virtual sal_uInt16 getDefaultAccessibleRole() const override;
96 void accumulateMaxes(const Size &rChildSize, Size &rSize) const;
97 Size finalizeMaxes(const Size &rSize, sal_uInt16 nVisibleChildren) const;
99 virtual Size calculateRequisition() const override;
100 virtual void setAllocation(const Size &rAllocation) override;
102 virtual long getPrimaryDimension(const Size &rSize) const = 0;
103 virtual void setPrimaryDimension(Size &rSize, long) const = 0;
104 virtual long getPrimaryCoordinate(const Point &rPos) const = 0;
105 virtual void setPrimaryCoordinate(Point &rPos, long) const = 0;
106 virtual long getSecondaryDimension(const Size &rSize) const = 0;
107 virtual void setSecondaryDimension(Size &rSize, long) const = 0;
109 virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const = 0;
112 class VCL_DLLPUBLIC VclVBox : public VclBox
114 public:
115 VclVBox(vcl::Window *pParent, bool bHomogeneous = false, int nSpacing = 0)
116 : VclBox(pParent, bHomogeneous, nSpacing)
118 m_bVerticalContainer = true;
120 protected:
121 virtual long getPrimaryDimension(const Size &rSize) const override
123 return rSize.getHeight();
125 virtual void setPrimaryDimension(Size &rSize, long nHeight) const override
127 rSize.setHeight(nHeight);
129 virtual long getPrimaryCoordinate(const Point &rPos) const override
131 return rPos.getY();
133 virtual void setPrimaryCoordinate(Point &rPos, long nPos) const override
135 rPos.setY(nPos);
137 virtual long getSecondaryDimension(const Size &rSize) const override
139 return rSize.getWidth();
141 virtual void setSecondaryDimension(Size &rSize, long nWidth) const override
143 rSize.setWidth(nWidth);
145 virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const override
147 return rWindow.get_expand() || rWindow.get_vexpand();
151 class VCL_DLLPUBLIC VclHBox : public VclBox
153 public:
154 VclHBox(vcl::Window *pParent, bool bHomogeneous = false, int nSpacing = 0)
155 : VclBox(pParent, bHomogeneous, nSpacing)
157 m_bVerticalContainer = false;
159 protected:
160 virtual long getPrimaryDimension(const Size &rSize) const override
162 return rSize.getWidth();
164 virtual void setPrimaryDimension(Size &rSize, long nWidth) const override
166 rSize.setWidth(nWidth);
168 virtual long getPrimaryCoordinate(const Point &rPos) const override
170 return rPos.getX();
172 virtual void setPrimaryCoordinate(Point &rPos, long nPos) const override
174 rPos.setX(nPos);
176 virtual long getSecondaryDimension(const Size &rSize) const override
178 return rSize.getHeight();
180 virtual void setSecondaryDimension(Size &rSize, long nHeight) const override
182 rSize.setHeight(nHeight);
184 virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const override
186 return rWindow.get_expand() || rWindow.get_hexpand();
190 enum class VclButtonBoxStyle
192 Default,
193 Spread,
194 Edge,
195 Start,
196 End,
197 Center
200 class VCL_DLLPUBLIC VclButtonBox : public VclBox
202 public:
203 VclButtonBox(vcl::Window *pParent)
204 : VclBox(pParent, false, Application::GetSettings().GetStyleSettings().GetDialogStyle().button_spacing)
205 , m_eLayoutStyle(VclButtonBoxStyle::Default)
208 virtual bool set_property(const OString &rKey, const OUString &rValue) override;
209 void sort_native_button_order();
210 protected:
211 virtual Size calculateRequisition() const override;
212 virtual void setAllocation(const Size &rAllocation) override;
213 Size addSpacing(const Size &rSize, sal_uInt16 nVisibleChildren) const;
214 private:
215 VclButtonBoxStyle m_eLayoutStyle;
216 struct Requisition
218 std::vector<long> m_aMainGroupDimensions;
219 std::vector<long> m_aSubGroupDimensions;
220 Size m_aMainGroupSize;
221 Size m_aSubGroupSize;
223 Requisition calculatePrimarySecondaryRequisitions() const;
224 Size addReqGroups(const VclButtonBox::Requisition &rReq) const;
227 class VCL_DLLPUBLIC VclVButtonBox : public VclButtonBox
229 public:
230 VclVButtonBox(vcl::Window *pParent)
231 : VclButtonBox(pParent)
233 m_bVerticalContainer = true;
235 protected:
236 virtual long getPrimaryDimension(const Size &rSize) const override
238 return rSize.getHeight();
240 virtual void setPrimaryDimension(Size &rSize, long nHeight) const override
242 rSize.setHeight(nHeight);
244 virtual long getPrimaryCoordinate(const Point &rPos) const override
246 return rPos.getY();
248 virtual void setPrimaryCoordinate(Point &rPos, long nPos) const override
250 rPos.setY(nPos);
252 virtual long getSecondaryDimension(const Size &rSize) const override
254 return rSize.getWidth();
256 virtual void setSecondaryDimension(Size &rSize, long nWidth) const override
258 rSize.setWidth(nWidth);
260 virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const override
262 return rWindow.get_expand() || rWindow.get_vexpand();
266 class VCL_DLLPUBLIC VclHButtonBox final : public VclButtonBox
268 public:
269 VclHButtonBox(vcl::Window *pParent)
270 : VclButtonBox(pParent)
272 m_bVerticalContainer = false;
274 private:
275 virtual long getPrimaryDimension(const Size &rSize) const override
277 return rSize.getWidth();
279 virtual void setPrimaryDimension(Size &rSize, long nWidth) const override
281 rSize.setWidth(nWidth);
283 virtual long getPrimaryCoordinate(const Point &rPos) const override
285 return rPos.getX();
287 virtual void setPrimaryCoordinate(Point &rPos, long nPos) const override
289 rPos.setX(nPos);
291 virtual long getSecondaryDimension(const Size &rSize) const override
293 return rSize.getHeight();
295 virtual void setSecondaryDimension(Size &rSize, long nHeight) const override
297 rSize.setHeight(nHeight);
299 virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const override
301 return rWindow.get_expand() || rWindow.get_hexpand();
305 class VCL_DLLPUBLIC VclGrid final : public VclContainer
307 private:
308 bool m_bRowHomogeneous;
309 bool m_bColumnHomogeneous;
310 int m_nRowSpacing;
311 int m_nColumnSpacing;
313 public:
314 struct Value
316 long m_nValue;
317 bool m_bExpand;
318 Value() : m_nValue(0), m_bExpand(false) {}
320 private:
322 Size calculateRequisitionForSpacings(sal_Int32 nRowSpacing, sal_Int32 nColSpacing) const;
323 virtual Size calculateRequisition() const override;
324 virtual void setAllocation(const Size &rAllocation) override;
325 virtual boost::property_tree::ptree DumpAsPropertyTree() override;
326 public:
327 VclGrid(vcl::Window *pParent)
328 : VclContainer(pParent)
329 , m_bRowHomogeneous(false), m_bColumnHomogeneous(false)
330 , m_nRowSpacing(0), m_nColumnSpacing(0)
333 bool get_row_homogeneous() const
335 return m_bRowHomogeneous;
337 bool get_column_homogeneous() const
339 return m_bColumnHomogeneous;
341 void set_row_spacing(int nSpacing)
343 m_nRowSpacing = nSpacing;
345 void set_column_spacing(int nSpacing)
347 m_nColumnSpacing = nSpacing;
349 int get_row_spacing() const
351 return m_nRowSpacing;
353 int get_column_spacing() const
355 return m_nColumnSpacing;
357 virtual bool set_property(const OString &rKey, const OUString &rValue) override;
360 class VCL_DLLPUBLIC VclBin : public VclContainer
362 public:
363 VclBin(vcl::Window *pParent, WinBits nStyle = WB_HIDE | WB_CLIPCHILDREN)
364 : VclContainer(pParent, nStyle)
367 virtual vcl::Window *get_child();
368 virtual const vcl::Window *get_child() const;
369 virtual Size calculateRequisition() const override;
370 virtual void setAllocation(const Size &rAllocation) override;
373 class VclPaned : public VclContainer
375 protected:
376 VclPtr<Splitter> m_pSplitter;
377 long m_nPosition;
379 VclPaned(vcl::Window *pParent, bool bVertical);
380 public:
381 virtual ~VclPaned() override { disposeOnce(); }
382 virtual void dispose() override;
383 long get_position() const { return m_nPosition; }
384 void set_position(long nPosition) { m_nPosition = nPosition; }
387 class VclVPaned final : public VclPaned
389 private:
390 DECL_LINK(SplitHdl, Splitter*, void);
391 void arrange(const Size& rAllocation, long nFirstHeight, long nSecondHeight);
393 public:
394 VclVPaned(vcl::Window *pParent);
395 virtual Size calculateRequisition() const override;
396 virtual void setAllocation(const Size &rAllocation) override;
399 class VclHPaned final : public VclPaned
401 private:
402 DECL_LINK(SplitHdl, Splitter*, void);
403 void arrange(const Size& rAllocation, long nFirstHeight, long nSecondHeight);
405 public:
406 VclHPaned(vcl::Window *pParent);
407 virtual Size calculateRequisition() const override;
408 virtual void setAllocation(const Size &rAllocation) override;
411 class VclFrame final : public VclBin
413 private:
414 VclPtr<vcl::Window> m_pLabel;
415 private:
416 friend class VclBuilder;
417 void designate_label(vcl::Window *pWindow);
418 DECL_LINK(WindowEventListener, VclWindowEvent&, void);
419 public:
420 VclFrame(vcl::Window *pParent)
421 : VclBin(pParent)
422 , m_pLabel(nullptr)
425 virtual ~VclFrame() override;
426 virtual void dispose() override;
427 void set_label(const OUString &rLabel);
428 OUString get_label() const;
429 virtual vcl::Window *get_child() override;
430 virtual const vcl::Window *get_child() const override;
431 vcl::Window *get_label_widget();
432 const vcl::Window *get_label_widget() const;
433 virtual boost::property_tree::ptree DumpAsPropertyTree() override;
434 private:
435 virtual Size calculateRequisition() const override;
436 virtual void setAllocation(const Size &rAllocation) override;
437 virtual OUString getDefaultAccessibleName() const override;
440 class VCL_DLLPUBLIC VclAlignment final : public VclBin
442 public:
443 VclAlignment(vcl::Window *pParent)
444 : VclBin(pParent)
445 , m_nBottomPadding(0)
446 , m_nLeftPadding(0)
447 , m_nRightPadding(0)
448 , m_nTopPadding(0)
451 virtual bool set_property(const OString &rKey, const OUString &rValue) override;
452 private:
453 virtual Size calculateRequisition() const override;
454 virtual void setAllocation(const Size &rAllocation) override;
455 sal_Int32 m_nBottomPadding;
456 sal_Int32 m_nLeftPadding;
457 sal_Int32 m_nRightPadding;
458 sal_Int32 m_nTopPadding;
461 class VclExpander final : public VclBin
463 public:
464 VclExpander(vcl::Window *pParent)
465 : VclBin(pParent)
466 , m_bResizeTopLevel(true)
467 , m_pDisclosureButton(VclPtr<DisclosureButton>::Create(this))
469 m_pDisclosureButton->SetToggleHdl(LINK(this, VclExpander, ClickHdl));
470 m_pDisclosureButton->Show();
472 virtual ~VclExpander() override { disposeOnce(); }
473 virtual void dispose() override;
474 virtual vcl::Window *get_child() override;
475 virtual const vcl::Window *get_child() const override;
476 virtual bool set_property(const OString &rKey, const OUString &rValue) override;
477 bool get_expanded() const
479 return m_pDisclosureButton->IsChecked();
481 void set_expanded(bool bExpanded)
483 m_pDisclosureButton->Check(bExpanded);
485 void set_label(const OUString& rLabel)
487 m_pDisclosureButton->SetText(rLabel);
489 virtual void StateChanged(StateChangedType nType) override;
490 void SetExpandedHdl( const Link<VclExpander&,void>& rLink ) { maExpandedHdl = rLink; }
491 private:
492 virtual Size calculateRequisition() const override;
493 virtual void setAllocation(const Size &rAllocation) override;
494 bool m_bResizeTopLevel;
495 VclPtr<DisclosureButton> m_pDisclosureButton;
496 Link<VclExpander&,void> maExpandedHdl;
497 DECL_LINK(ClickHdl, CheckBox&, void);
500 class VCL_DLLPUBLIC VclScrolledWindow final : public VclBin
502 public:
503 VclScrolledWindow(vcl::Window *pParent );
504 virtual ~VclScrolledWindow() override { disposeOnce(); }
505 virtual void dispose() override;
506 virtual vcl::Window *get_child() override;
507 virtual const vcl::Window *get_child() const override;
508 virtual bool set_property(const OString &rKey, const OUString &rValue) override;
509 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
510 ScrollBar& getVertScrollBar() { return *m_pVScroll; }
511 ScrollBar& getHorzScrollBar() { return *m_pHScroll; }
512 Size getVisibleChildSize() const;
513 //set to true to disable the built-in scrolling callbacks to allow the user
514 //to override it
515 void setUserManagedScrolling(bool bUserManagedScrolling) { m_bUserManagedScrolling = bUserManagedScrolling;}
516 void doSetAllocation(const Size &rAllocation, bool bRetryOnFailure);
517 private:
518 virtual Size calculateRequisition() const override;
519 virtual void setAllocation(const Size &rAllocation) override;
520 DECL_LINK(ScrollBarHdl, ScrollBar*, void);
521 void InitScrollBars(const Size &rRequest);
522 virtual bool EventNotify(NotifyEvent& rNEvt) override;
523 bool m_bUserManagedScrolling;
524 DrawFrameStyle m_eDrawFrameStyle;
525 VclPtr<ScrollBar> m_pVScroll;
526 VclPtr<ScrollBar> m_pHScroll;
527 VclPtr<ScrollBarBox> m_aScrollBarBox;
530 class VclViewport final : public VclBin
532 public:
533 VclViewport(vcl::Window *pParent)
534 : VclBin(pParent, WB_HIDE | WB_CLIPCHILDREN)
535 , m_bInitialAllocation(true)
538 private:
539 virtual void setAllocation(const Size &rAllocation) override;
540 bool m_bInitialAllocation;
543 //Enforces that its children are always the same size as itself.
544 //Intercepts any Commands intended for its children.
546 //by default the Commands are discarded, inherit from this
547 //and implement "Command" to get them
548 class VclEventBox final : public VclBin
550 private:
551 //Any Commands an EventBoxHelper receives are forwarded to its parent
552 //The VclEventBox ensures that m_aEventBoxHelper is the
553 //first child and is transparent, but covers the rest of the children
554 class EventBoxHelper : public vcl::Window
556 public:
557 EventBoxHelper(vcl::Window* pParent)
558 : Window(pParent, 0)
560 SetSizePixel(pParent->GetSizePixel());
561 EnableChildTransparentMode();
562 SetPaintTransparent(true);
563 SetBackground();
565 virtual void Command(const CommandEvent& rCEvt) override
567 GetParent()->Command(rCEvt);
571 VclPtr<EventBoxHelper> m_aEventBoxHelper;
572 virtual void dispose() override;
573 virtual ~VclEventBox() override;
574 public:
575 VclEventBox(vcl::Window* pParent)
576 : VclBin(pParent)
577 , m_aEventBoxHelper(VclPtr<EventBoxHelper>::Create(this))
579 m_aEventBoxHelper->Show();
581 virtual vcl::Window *get_child() override;
582 virtual const vcl::Window *get_child() const override;
583 virtual Size calculateRequisition() const override;
584 virtual void setAllocation(const Size &rAllocation) override;
586 virtual void Command(const CommandEvent& rCEvt) override;
589 class VclSizeGroup
591 private:
592 std::set< VclPtr<vcl::Window> > m_aWindows;
593 bool m_bIgnoreHidden;
594 VclSizeGroupMode m_eMode;
596 void trigger_queue_resize();
597 public:
598 VclSizeGroup()
599 : m_bIgnoreHidden(false)
600 , m_eMode(VclSizeGroupMode::Horizontal)
603 void insert(vcl::Window *pWindow)
605 m_aWindows.insert(VclPtr<vcl::Window>(pWindow));
607 void erase(vcl::Window *pWindow)
609 m_aWindows.erase(VclPtr<vcl::Window>(pWindow));
611 const std::set< VclPtr<vcl::Window> >& get_widgets() const
613 return m_aWindows;
615 std::set< VclPtr<vcl::Window> >& get_widgets()
617 return m_aWindows;
619 void set_ignore_hidden(bool bIgnoreHidden);
620 bool get_ignore_hidden() const
622 return m_bIgnoreHidden;
624 void set_mode(VclSizeGroupMode eMode);
625 VclSizeGroupMode get_mode() const
627 return m_eMode;
629 void set_property(const OString &rKey, const OUString &rValue);
632 class VCL_DLLPUBLIC VclDrawingArea final : public Control
634 private:
635 FactoryFunction m_pFactoryFunction;
636 void* m_pUserData;
637 Link<std::pair<vcl::RenderContext&, const tools::Rectangle&>, void> m_aPaintHdl;
638 Link<const Size&, void> m_aResizeHdl;
639 Link<const MouseEvent&, bool> m_aMousePressHdl;
640 Link<const MouseEvent&, bool> m_aMouseMotionHdl;
641 Link<const MouseEvent&, bool> m_aMouseReleaseHdl;
642 Link<const KeyEvent&, bool> m_aKeyPressHdl;
643 Link<const KeyEvent&, bool> m_aKeyReleaseHdl;
644 Link<VclDrawingArea&, void> m_aStyleUpdatedHdl;
645 Link<const CommandEvent&, bool> m_aCommandHdl;
646 Link<tools::Rectangle&, OUString> m_aQueryTooltipHdl;
648 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override
650 m_aPaintHdl.Call(std::pair<vcl::RenderContext&, const tools::Rectangle&>(rRenderContext, rRect));
652 virtual void Resize() override
654 m_aResizeHdl.Call(GetOutputSizePixel());
656 virtual void MouseMove(const MouseEvent& rMEvt) override
658 if (!m_aMouseMotionHdl.Call(rMEvt))
659 Control::MouseMove(rMEvt);
661 virtual void MouseButtonDown(const MouseEvent& rMEvt) override
663 if (!m_aMousePressHdl.Call(rMEvt))
664 Control::MouseButtonDown(rMEvt);
666 virtual void MouseButtonUp(const MouseEvent& rMEvt) override
668 if (!m_aMouseReleaseHdl.Call(rMEvt))
669 Control::MouseButtonUp(rMEvt);
671 virtual void KeyInput(const KeyEvent& rKEvt) override
673 if (!m_aKeyPressHdl.Call(rKEvt))
674 Control::KeyInput(rKEvt);
677 virtual void KeyUp(const KeyEvent& rKEvt) override
679 if (!m_aKeyReleaseHdl.Call(rKEvt))
680 Control::KeyUp(rKEvt);
682 virtual void StateChanged(StateChangedType nType) override
684 Control::StateChanged(nType);
685 if (nType == StateChangedType::ControlForeground || nType == StateChangedType::ControlBackground)
687 m_aStyleUpdatedHdl.Call(*this);
688 Invalidate();
691 virtual void DataChanged(const DataChangedEvent& rDCEvt) override
693 Control::DataChanged(rDCEvt);
694 if ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) && (rDCEvt.GetFlags() & AllSettingsFlags::STYLE))
696 m_aStyleUpdatedHdl.Call(*this);
697 Invalidate();
700 virtual void Command(const CommandEvent& rEvent) override
702 if (m_aCommandHdl.Call(rEvent))
703 return;
704 Control::Command(rEvent);
706 virtual void RequestHelp(const HelpEvent& rHelpEvent) override
708 if (rHelpEvent.GetMode() & (HelpEventMode::QUICK | HelpEventMode::BALLOON))
710 Point aPos(ScreenToOutputPixel(rHelpEvent.GetMousePosPixel()));
711 tools::Rectangle aHelpArea(aPos.X(), aPos.Y());
712 OUString sHelpTip = m_aQueryTooltipHdl.Call(aHelpArea);
713 if (sHelpTip.isEmpty())
714 return;
715 Point aPt = OutputToScreenPixel(aHelpArea.TopLeft());
716 aHelpArea.SetLeft(aPt.X());
717 aHelpArea.SetTop(aPt.Y());
718 aPt = OutputToScreenPixel(aHelpArea.BottomRight());
719 aHelpArea.SetRight(aPt.X());
720 aHelpArea.SetBottom(aPt.Y());
721 // tdf#125369 recover newline support of tdf#101779
722 QuickHelpFlags eHelpWinStyle = sHelpTip.indexOf('\n') != -1 ? QuickHelpFlags::TipStyleBalloon : QuickHelpFlags::NONE;
723 Help::ShowQuickHelp(this, aHelpArea, sHelpTip, eHelpWinStyle);
726 virtual FactoryFunction GetUITestFactory() const override
728 if (m_pFactoryFunction)
729 return m_pFactoryFunction;
730 return Control::GetUITestFactory();
733 public:
734 VclDrawingArea(vcl::Window *pParent, WinBits nStyle)
735 : Control(pParent, nStyle)
736 , m_pFactoryFunction(nullptr)
737 , m_pUserData(nullptr)
739 SetBackground();
741 void SetUITestFactory(FactoryFunction pFactoryFunction, void* pUserData)
743 m_pFactoryFunction = pFactoryFunction;
744 m_pUserData = pUserData;
746 void* GetUserData() const
748 return m_pUserData;
750 void SetPaintHdl(const Link<std::pair<vcl::RenderContext&, const tools::Rectangle&>, void>& rLink)
752 m_aPaintHdl = rLink;
754 void SetResizeHdl(const Link<const Size&, void>& rLink)
756 m_aResizeHdl = rLink;
758 void SetMousePressHdl(const Link<const MouseEvent&, bool>& rLink)
760 m_aMousePressHdl = rLink;
762 void SetMouseMoveHdl(const Link<const MouseEvent&, bool>& rLink)
764 m_aMouseMotionHdl = rLink;
766 void SetMouseReleaseHdl(const Link<const MouseEvent&, bool>& rLink)
768 m_aMouseReleaseHdl = rLink;
770 void SetKeyPressHdl(const Link<const KeyEvent&, bool>& rLink)
772 m_aKeyPressHdl = rLink;
774 void SetKeyReleaseHdl(const Link<const KeyEvent&, bool>& rLink)
776 m_aKeyReleaseHdl = rLink;
778 void SetStyleUpdatedHdl(const Link<VclDrawingArea&, void>& rLink)
780 m_aStyleUpdatedHdl = rLink;
782 void SetCommandHdl(const Link<const CommandEvent&, bool>& rLink)
784 m_aCommandHdl = rLink;
786 void SetQueryTooltipHdl(const Link<tools::Rectangle&, OUString>& rLink)
788 m_aQueryTooltipHdl = rLink;
792 //Get first window of a pTopLevel window as
793 //if any intermediate layout widgets didn't exist
794 //i.e. acts like pChild = pChild->GetWindow(GetWindowType::FirstChild);
795 //in a flat hierarchy where dialogs only have one layer
796 //of children
797 vcl::Window* firstLogicalChildOfParent(const vcl::Window *pTopLevel);
799 //Get last window of a pTopLevel window as
800 //if any intermediate layout widgets didn't exist
801 //i.e. acts like pChild = pChild->GetWindow(GetWindowType::LastChild);
802 //in a flat hierarchy where dialogs only have one layer
803 //of children
804 vcl::Window* lastLogicalChildOfParent(const vcl::Window *pTopLevel);
806 //Get next window after pChild of a pTopLevel window as
807 //if any intermediate layout widgets didn't exist
808 //i.e. acts like pChild = pChild->GetWindow(GetWindowType::Next);
809 //in a flat hierarchy where dialogs only have one layer
810 //of children
811 vcl::Window* nextLogicalChildOfParent(const vcl::Window *pTopLevel, const vcl::Window *pChild);
813 //Get previous window before pChild of a pTopLevel window as
814 //if any intermediate layout widgets didn't exist
815 //i.e. acts like pChild = pChild->GetWindow(GetWindowType::Prev);
816 //in a flat hierarchy where dialogs only have one layer
817 //of children
818 vcl::Window* prevLogicalChildOfParent(const vcl::Window *pTopLevel, const vcl::Window *pChild);
820 //Returns true is the Window has a single child which is a container
821 VCL_DLLPUBLIC bool isLayoutEnabled(const vcl::Window *pWindow);
823 inline bool isContainerWindow(const vcl::Window &rWindow)
825 WindowType eType = rWindow.GetType();
826 return eType == WindowType::CONTAINER || eType == WindowType::SCROLLWINDOW ||
827 (eType == WindowType::DOCKINGWINDOW && ::isLayoutEnabled(&rWindow));
830 inline bool isContainerWindow(const vcl::Window *pWindow)
832 return pWindow && isContainerWindow(*pWindow);
835 // retro-fitting utilities
837 //Get a Size which is large enough to contain all children with
838 //an equal amount of space at top left and bottom right
839 Size getLegacyBestSizeForChildren(const vcl::Window &rWindow);
841 //Get first parent which is not a layout widget
842 vcl::Window* getNonLayoutParent(vcl::Window *pParent);
844 #endif
846 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */