1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #ifndef INCLUDED_VCL_LAYOUT_HXX
11 #define INCLUDED_VCL_LAYOUT_HXX
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>
31 class VCL_DLLPUBLIC VclContainer
: public vcl::Window
,
35 VclContainer(vcl::Window
*pParent
, WinBits nStyle
= WB_HIDE
| WB_CLIPCHILDREN
);
37 //These take into account the external margins of the rWindow widget
38 //while GetOptimalSize/get_preferred_size and SetPosSizePixel are
40 static Size
getLayoutRequisition(const vcl::Window
&rWindow
);
41 static void setLayoutPosSize(vcl::Window
&rWindow
, const Point
&rPos
, const Size
&rSize
);
43 //applies the allocation pos and size onto rWindow via setLayoutPosSize taking into account
44 //the rWindows alignment desires within that allocation
45 static void setLayoutAllocation(vcl::Window
&rWindow
, const Point
&rPos
, const Size
&rSize
);
47 virtual void queue_resize(StateChangedType eReason
= StateChangedType::Layout
) override
;
49 //these are the two that need to be implemented by
50 //containers, figure out how much space you want...
51 virtual Size
calculateRequisition() const = 0;
52 //..and decide what to do when set to this size
53 virtual void setAllocation(const Size
&rAllocation
) = 0;
55 virtual sal_uInt16
getDefaultAccessibleRole() const override
;
57 // support for screenshot context menu
58 virtual void Command(const CommandEvent
& rCEvt
) override
;
61 //you don't want to override these
62 virtual Size
GetOptimalSize() const override
;
63 virtual void SetPosSizePixel(const Point
& rNewPos
, const Size
& rNewSize
) override
;
64 virtual void SetPosPixel(const Point
& rAllocPos
) override
;
65 virtual void SetSizePixel(const Size
& rAllocation
) override
;
70 class VCL_DLLPUBLIC VclBox
: public VclContainer
74 bool m_bVerticalContainer
;
77 VclBox(vcl::Window
*pParent
, bool bHomogeneous
, int nSpacing
)
78 : VclContainer(pParent
)
79 , m_bHomogeneous(bHomogeneous
)
80 , m_bVerticalContainer(false)
81 , m_nSpacing(nSpacing
)
84 void set_spacing(int nSpacing
)
86 m_nSpacing
= nSpacing
;
88 int get_spacing() const
92 void set_homogeneous(bool bHomogeneous
)
94 m_bHomogeneous
= bHomogeneous
;
96 bool get_orientation() const
98 return m_bVerticalContainer
;
100 virtual bool set_property(const OString
&rKey
, const OUString
&rValue
) override
;
101 virtual void DumpAsPropertyTree(tools::JsonWriter
&) override
;
103 virtual sal_uInt16
getDefaultAccessibleRole() const override
;
104 void accumulateMaxes(const Size
&rChildSize
, Size
&rSize
) const;
105 Size
finalizeMaxes(const Size
&rSize
, sal_uInt16 nVisibleChildren
) const;
107 virtual Size
calculateRequisition() const override
;
108 virtual void setAllocation(const Size
&rAllocation
) override
;
110 virtual tools::Long
getPrimaryDimension(const Size
&rSize
) const = 0;
111 virtual void setPrimaryDimension(Size
&rSize
, tools::Long
) const = 0;
112 virtual tools::Long
getPrimaryCoordinate(const Point
&rPos
) const = 0;
113 virtual void setPrimaryCoordinate(Point
&rPos
, tools::Long
) const = 0;
114 virtual tools::Long
getSecondaryDimension(const Size
&rSize
) const = 0;
115 virtual void setSecondaryDimension(Size
&rSize
, tools::Long
) const = 0;
117 virtual bool getPrimaryDimensionChildExpand(const vcl::Window
&rWindow
) const = 0;
120 class VCL_DLLPUBLIC VclVBox
: public VclBox
123 VclVBox(vcl::Window
*pParent
, bool bHomogeneous
= false, int nSpacing
= 0)
124 : VclBox(pParent
, bHomogeneous
, nSpacing
)
126 m_bVerticalContainer
= true;
129 virtual tools::Long
getPrimaryDimension(const Size
&rSize
) const override
131 return rSize
.getHeight();
133 virtual void setPrimaryDimension(Size
&rSize
, tools::Long nHeight
) const override
135 rSize
.setHeight(nHeight
);
137 virtual tools::Long
getPrimaryCoordinate(const Point
&rPos
) const override
141 virtual void setPrimaryCoordinate(Point
&rPos
, tools::Long nPos
) const override
145 virtual tools::Long
getSecondaryDimension(const Size
&rSize
) const override
147 return rSize
.getWidth();
149 virtual void setSecondaryDimension(Size
&rSize
, tools::Long nWidth
) const override
151 rSize
.setWidth(nWidth
);
153 virtual bool getPrimaryDimensionChildExpand(const vcl::Window
&rWindow
) const override
155 return rWindow
.get_expand() || rWindow
.get_vexpand();
159 class VCL_DLLPUBLIC VclHBox
: public VclBox
162 VclHBox(vcl::Window
*pParent
, bool bHomogeneous
= false, int nSpacing
= 0)
163 : VclBox(pParent
, bHomogeneous
, nSpacing
)
165 m_bVerticalContainer
= false;
168 virtual tools::Long
getPrimaryDimension(const Size
&rSize
) const override
170 return rSize
.getWidth();
172 virtual void setPrimaryDimension(Size
&rSize
, tools::Long nWidth
) const override
174 rSize
.setWidth(nWidth
);
176 virtual tools::Long
getPrimaryCoordinate(const Point
&rPos
) const override
180 virtual void setPrimaryCoordinate(Point
&rPos
, tools::Long nPos
) const override
184 virtual tools::Long
getSecondaryDimension(const Size
&rSize
) const override
186 return rSize
.getHeight();
188 virtual void setSecondaryDimension(Size
&rSize
, tools::Long nHeight
) const override
190 rSize
.setHeight(nHeight
);
192 virtual bool getPrimaryDimensionChildExpand(const vcl::Window
&rWindow
) const override
194 return rWindow
.get_expand() || rWindow
.get_hexpand();
198 enum class VclButtonBoxStyle
208 class VCL_DLLPUBLIC VclButtonBox
: public VclBox
211 VclButtonBox(vcl::Window
*pParent
)
212 : VclBox(pParent
, false, Application::GetSettings().GetStyleSettings().GetDialogStyle().button_spacing
)
213 , m_eLayoutStyle(VclButtonBoxStyle::Default
)
216 virtual bool set_property(const OString
&rKey
, const OUString
&rValue
) override
;
218 virtual Size
calculateRequisition() const override
;
219 virtual void setAllocation(const Size
&rAllocation
) override
;
220 Size
addSpacing(const Size
&rSize
, sal_uInt16 nVisibleChildren
) const;
222 VclButtonBoxStyle m_eLayoutStyle
;
225 std::vector
<tools::Long
> m_aMainGroupDimensions
;
226 std::vector
<tools::Long
> m_aSubGroupDimensions
;
227 Size m_aMainGroupSize
;
228 Size m_aSubGroupSize
;
230 Requisition
calculatePrimarySecondaryRequisitions() const;
231 Size
addReqGroups(const VclButtonBox::Requisition
&rReq
) const;
234 class VCL_DLLPUBLIC VclVButtonBox
: public VclButtonBox
237 VclVButtonBox(vcl::Window
*pParent
)
238 : VclButtonBox(pParent
)
240 m_bVerticalContainer
= true;
243 virtual tools::Long
getPrimaryDimension(const Size
&rSize
) const override
245 return rSize
.getHeight();
247 virtual void setPrimaryDimension(Size
&rSize
, tools::Long nHeight
) const override
249 rSize
.setHeight(nHeight
);
251 virtual tools::Long
getPrimaryCoordinate(const Point
&rPos
) const override
255 virtual void setPrimaryCoordinate(Point
&rPos
, tools::Long nPos
) const override
259 virtual tools::Long
getSecondaryDimension(const Size
&rSize
) const override
261 return rSize
.getWidth();
263 virtual void setSecondaryDimension(Size
&rSize
, tools::Long nWidth
) const override
265 rSize
.setWidth(nWidth
);
267 virtual bool getPrimaryDimensionChildExpand(const vcl::Window
&rWindow
) const override
269 return rWindow
.get_expand() || rWindow
.get_vexpand();
273 class VCL_DLLPUBLIC VclHButtonBox final
: public VclButtonBox
276 VclHButtonBox(vcl::Window
*pParent
)
277 : VclButtonBox(pParent
)
279 m_bVerticalContainer
= false;
282 virtual tools::Long
getPrimaryDimension(const Size
&rSize
) const override
284 return rSize
.getWidth();
286 virtual void setPrimaryDimension(Size
&rSize
, tools::Long nWidth
) const override
288 rSize
.setWidth(nWidth
);
290 virtual tools::Long
getPrimaryCoordinate(const Point
&rPos
) const override
294 virtual void setPrimaryCoordinate(Point
&rPos
, tools::Long nPos
) const override
298 virtual tools::Long
getSecondaryDimension(const Size
&rSize
) const override
300 return rSize
.getHeight();
302 virtual void setSecondaryDimension(Size
&rSize
, tools::Long nHeight
) const override
304 rSize
.setHeight(nHeight
);
306 virtual bool getPrimaryDimensionChildExpand(const vcl::Window
&rWindow
) const override
308 return rWindow
.get_expand() || rWindow
.get_hexpand();
312 class VCL_DLLPUBLIC VclGrid final
: public VclContainer
315 bool m_bRowHomogeneous
;
316 bool m_bColumnHomogeneous
;
318 int m_nColumnSpacing
;
323 tools::Long m_nValue
;
325 Value() : m_nValue(0), m_bExpand(false) {}
329 Size
calculateRequisitionForSpacings(sal_Int32 nRowSpacing
, sal_Int32 nColSpacing
) const;
330 virtual Size
calculateRequisition() const override
;
331 virtual void setAllocation(const Size
&rAllocation
) override
;
332 virtual void DumpAsPropertyTree(tools::JsonWriter
&) override
;
334 VclGrid(vcl::Window
*pParent
)
335 : VclContainer(pParent
)
336 , m_bRowHomogeneous(false), m_bColumnHomogeneous(false)
337 , m_nRowSpacing(0), m_nColumnSpacing(0)
340 bool get_row_homogeneous() const
342 return m_bRowHomogeneous
;
344 bool get_column_homogeneous() const
346 return m_bColumnHomogeneous
;
348 void set_row_spacing(int nSpacing
)
350 m_nRowSpacing
= nSpacing
;
352 void set_column_spacing(int nSpacing
)
354 m_nColumnSpacing
= nSpacing
;
356 int get_row_spacing() const
358 return m_nRowSpacing
;
360 int get_column_spacing() const
362 return m_nColumnSpacing
;
364 virtual bool set_property(const OString
&rKey
, const OUString
&rValue
) override
;
367 class UNLESS_MERGELIBS(VCL_DLLPUBLIC
) VclBin
: public VclContainer
370 VclBin(vcl::Window
*pParent
, WinBits nStyle
= WB_HIDE
| WB_CLIPCHILDREN
)
371 : VclContainer(pParent
, nStyle
)
374 virtual vcl::Window
*get_child();
375 virtual const vcl::Window
*get_child() const;
376 virtual Size
calculateRequisition() const override
;
377 virtual void setAllocation(const Size
&rAllocation
) override
;
380 class VclPaned
: public VclContainer
383 VclPtr
<Splitter
> m_pSplitter
;
384 tools::Long m_nPosition
;
386 VclPaned(vcl::Window
*pParent
, bool bVertical
);
388 virtual ~VclPaned() override
;
389 virtual void dispose() override
;
390 tools::Long
get_position() const { return m_nPosition
; }
391 virtual void set_position(tools::Long nPosition
) { m_nPosition
= nPosition
; }
394 class VclVPaned final
: public VclPaned
397 DECL_LINK(SplitHdl
, Splitter
*, void);
398 void arrange(const Size
& rAllocation
, tools::Long nFirstHeight
, tools::Long nSecondHeight
);
401 VclVPaned(vcl::Window
*pParent
);
402 virtual ~VclVPaned() override
;
403 virtual Size
calculateRequisition() const override
;
404 virtual void setAllocation(const Size
&rAllocation
) override
;
405 virtual void set_position(tools::Long nPosition
) override
;
408 class VclHPaned final
: public VclPaned
411 DECL_LINK(SplitHdl
, Splitter
*, void);
412 void arrange(const Size
& rAllocation
, tools::Long nFirstHeight
, tools::Long nSecondHeight
);
415 VclHPaned(vcl::Window
*pParent
);
416 virtual ~VclHPaned() override
;
417 virtual Size
calculateRequisition() const override
;
418 virtual void setAllocation(const Size
&rAllocation
) override
;
419 virtual void set_position(tools::Long nPosition
) override
;
422 class VclFrame final
: public VclBin
425 VclPtr
<vcl::Window
> m_pLabel
;
427 friend class VclBuilder
;
428 void designate_label(vcl::Window
*pWindow
);
429 DECL_LINK(WindowEventListener
, VclWindowEvent
&, void);
431 VclFrame(vcl::Window
*pParent
)
436 virtual ~VclFrame() override
;
437 virtual void dispose() override
;
438 void set_label(const OUString
&rLabel
);
439 OUString
get_label() const;
440 virtual vcl::Window
*get_child() override
;
441 virtual const vcl::Window
*get_child() const override
;
442 vcl::Window
*get_label_widget();
443 const vcl::Window
*get_label_widget() const;
444 virtual void DumpAsPropertyTree(tools::JsonWriter
&) override
;
446 virtual Size
calculateRequisition() const override
;
447 virtual void setAllocation(const Size
&rAllocation
) override
;
448 virtual OUString
getDefaultAccessibleName() const override
;
451 class UNLESS_MERGELIBS(VCL_DLLPUBLIC
) VclAlignment final
: public VclBin
454 VclAlignment(vcl::Window
*pParent
)
456 , m_nBottomPadding(0)
462 virtual bool set_property(const OString
&rKey
, const OUString
&rValue
) override
;
464 virtual Size
calculateRequisition() const override
;
465 virtual void setAllocation(const Size
&rAllocation
) override
;
466 sal_Int32 m_nBottomPadding
;
467 sal_Int32 m_nLeftPadding
;
468 sal_Int32 m_nRightPadding
;
469 sal_Int32 m_nTopPadding
;
472 class DisclosureButton
;
475 class VclExpander final
: public VclBin
478 VclExpander(vcl::Window
*pParent
);
479 virtual ~VclExpander() override
;
480 virtual void dispose() override
;
481 virtual vcl::Window
*get_child() override
;
482 virtual const vcl::Window
*get_child() const override
;
483 virtual bool set_property(const OString
&rKey
, const OUString
&rValue
) override
;
484 bool get_expanded() const;
485 void set_expanded(bool bExpanded
);
486 void set_label(const OUString
& rLabel
);
487 OUString
get_label() const;
488 vcl::Window
*get_label_widget();
489 const vcl::Window
*get_label_widget() const;
490 virtual void StateChanged(StateChangedType nType
) override
;
491 void SetExpandedHdl( const Link
<VclExpander
&,void>& rLink
) { maExpandedHdl
= rLink
; }
493 virtual Size
calculateRequisition() const override
;
494 virtual void setAllocation(const Size
&rAllocation
) override
;
495 bool m_bResizeTopLevel
;
496 VclPtr
<DisclosureButton
> m_pDisclosureButton
;
497 Link
<VclExpander
&,void> maExpandedHdl
;
498 DECL_LINK(ClickHdl
, CheckBox
&, void);
501 class VCL_DLLPUBLIC VclScrolledWindow final
: public VclBin
504 VclScrolledWindow(vcl::Window
*pParent
);
505 virtual ~VclScrolledWindow() override
;
506 virtual void dispose() override
;
507 virtual vcl::Window
*get_child() override
;
508 virtual const vcl::Window
*get_child() const override
;
509 virtual bool set_property(const OString
&rKey
, const OUString
&rValue
) override
;
510 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
511 bool HasVisibleBorder() const { return m_eDrawFrameStyle
!= DrawFrameStyle::NONE
; }
512 ScrollBar
& getVertScrollBar() { return *m_pVScroll
; }
513 ScrollBar
& getHorzScrollBar() { return *m_pHScroll
; }
514 Size
getVisibleChildSize() const;
515 //set to true to disable the built-in scrolling callbacks to allow the user
517 void setUserManagedScrolling(bool bUserManagedScrolling
) { m_bUserManagedScrolling
= bUserManagedScrolling
;}
518 void doSetAllocation(const Size
&rAllocation
, bool bRetryOnFailure
);
520 virtual Size
calculateRequisition() const override
;
521 virtual void setAllocation(const Size
&rAllocation
) override
;
522 // sets new border size and adapts scrollbar and child widget position/size as needed
523 void updateBorderWidth(tools::Long nBorderWidth
);
524 DECL_LINK(ScrollBarHdl
, ScrollBar
*, void);
525 void InitScrollBars(const Size
&rRequest
);
526 virtual bool EventNotify(NotifyEvent
& rNEvt
) override
;
527 bool m_bUserManagedScrolling
;
528 tools::Long m_nBorderWidth
;
529 DrawFrameStyle m_eDrawFrameStyle
;
530 DrawFrameFlags m_eDrawFrameFlags
;
531 VclPtr
<ScrollBar
> m_pVScroll
;
532 VclPtr
<ScrollBar
> m_pHScroll
;
533 VclPtr
<ScrollBarBox
> m_aScrollBarBox
;
536 class VclViewport final
: public VclBin
539 VclViewport(vcl::Window
*pParent
)
540 : VclBin(pParent
, WB_HIDE
| WB_CLIPCHILDREN
)
541 , m_bInitialAllocation(true)
545 virtual void setAllocation(const Size
&rAllocation
) override
;
546 bool m_bInitialAllocation
;
549 //Enforces that its children are always the same size as itself.
550 //Intercepts any Commands intended for its children.
552 //by default the Commands are discarded, inherit from this
553 //and implement "Command" to get them
554 class VclEventBox final
: public VclBin
557 //Any Commands an EventBoxHelper receives are forwarded to its parent
558 //The VclEventBox ensures that m_aEventBoxHelper is the
559 //first child and is transparent, but covers the rest of the children
560 class EventBoxHelper
: public vcl::Window
563 EventBoxHelper(vcl::Window
* pParent
)
566 SetSizePixel(pParent
->GetSizePixel());
567 EnableChildTransparentMode();
568 SetPaintTransparent(true);
571 virtual void Command(const CommandEvent
& rCEvt
) override
573 GetParent()->Command(rCEvt
);
577 VclPtr
<EventBoxHelper
> m_aEventBoxHelper
;
578 virtual void dispose() override
;
579 virtual ~VclEventBox() override
;
581 VclEventBox(vcl::Window
* pParent
)
583 , m_aEventBoxHelper(VclPtr
<EventBoxHelper
>::Create(this))
585 m_aEventBoxHelper
->Show();
587 virtual vcl::Window
*get_child() override
;
588 virtual const vcl::Window
*get_child() const override
;
589 virtual Size
calculateRequisition() const override
;
590 virtual void setAllocation(const Size
&rAllocation
) override
;
592 virtual void Command(const CommandEvent
& rCEvt
) override
;
598 std::set
< VclPtr
<vcl::Window
> > m_aWindows
;
599 bool m_bIgnoreHidden
;
600 VclSizeGroupMode m_eMode
;
602 void trigger_queue_resize();
605 : m_bIgnoreHidden(false)
606 , m_eMode(VclSizeGroupMode::Horizontal
)
609 void insert(vcl::Window
*pWindow
)
611 m_aWindows
.insert(VclPtr
<vcl::Window
>(pWindow
));
613 void erase(vcl::Window
*pWindow
)
615 m_aWindows
.erase(VclPtr
<vcl::Window
>(pWindow
));
617 const std::set
< VclPtr
<vcl::Window
> >& get_widgets() const
621 std::set
< VclPtr
<vcl::Window
> >& get_widgets()
625 void set_ignore_hidden(bool bIgnoreHidden
);
626 bool get_ignore_hidden() const
628 return m_bIgnoreHidden
;
630 void set_mode(VclSizeGroupMode eMode
);
631 VclSizeGroupMode
get_mode() const
635 void set_property(const OString
&rKey
, const OUString
&rValue
);
638 class VCL_DLLPUBLIC VclDrawingArea final
: public Control
639 , public DragSourceHelper
642 FactoryFunction m_pFactoryFunction
;
644 rtl::Reference
<TransferDataContainer
> m_xTransferHelper
;
645 sal_Int8 m_nDragAction
;
646 Link
<std::pair
<vcl::RenderContext
&, const tools::Rectangle
&>, void> m_aPaintHdl
;
647 Link
<const Size
&, void> m_aResizeHdl
;
648 Link
<const MouseEvent
&, bool> m_aMousePressHdl
;
649 Link
<const MouseEvent
&, bool> m_aMouseMotionHdl
;
650 Link
<const MouseEvent
&, bool> m_aMouseReleaseHdl
;
651 Link
<const KeyEvent
&, bool> m_aKeyPressHdl
;
652 Link
<const KeyEvent
&, bool> m_aKeyReleaseHdl
;
653 Link
<VclDrawingArea
&, void> m_aStyleUpdatedHdl
;
654 Link
<const CommandEvent
&, bool> m_aCommandHdl
;
655 Link
<tools::Rectangle
&, OUString
> m_aQueryTooltipHdl
;
656 Link
<OUString
&, int> m_aGetSurroundingHdl
;
657 Link
<const Selection
&, bool> m_aDeleteSurroundingHdl
;
658 Link
<VclDrawingArea
*, bool> m_aStartDragHdl
;
660 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
662 m_aPaintHdl
.Call(std::pair
<vcl::RenderContext
&, const tools::Rectangle
&>(rRenderContext
, rRect
));
664 virtual void Resize() override
666 m_aResizeHdl
.Call(GetOutputSizePixel());
668 virtual void MouseMove(const MouseEvent
& rMEvt
) override
670 if (!m_aMouseMotionHdl
.Call(rMEvt
))
671 Control::MouseMove(rMEvt
);
673 virtual void KeyInput(const KeyEvent
& rKEvt
) override
675 if (!m_aKeyPressHdl
.Call(rKEvt
))
676 Control::KeyInput(rKEvt
);
679 virtual void KeyUp(const KeyEvent
& rKEvt
) override
681 if (!m_aKeyReleaseHdl
.Call(rKEvt
))
682 Control::KeyUp(rKEvt
);
684 virtual void StateChanged(StateChangedType nType
) override
686 Control::StateChanged(nType
);
687 if (nType
== StateChangedType::ControlForeground
|| nType
== StateChangedType::ControlBackground
)
689 m_aStyleUpdatedHdl
.Call(*this);
693 virtual void DataChanged(const DataChangedEvent
& rDCEvt
) override
695 Control::DataChanged(rDCEvt
);
696 if ((rDCEvt
.GetType() == DataChangedEventType::SETTINGS
) && (rDCEvt
.GetFlags() & AllSettingsFlags::STYLE
))
698 m_aStyleUpdatedHdl
.Call(*this);
702 virtual void Command(const CommandEvent
& rEvent
) override
704 if (m_aCommandHdl
.Call(rEvent
))
706 Control::Command(rEvent
);
708 virtual void RequestHelp(const HelpEvent
& rHelpEvent
) override
710 if (rHelpEvent
.GetMode() & (HelpEventMode::QUICK
| HelpEventMode::BALLOON
))
712 Point
aPos(ScreenToOutputPixel(rHelpEvent
.GetMousePosPixel()));
713 tools::Rectangle
aHelpArea(aPos
.X(), aPos
.Y());
714 OUString sHelpTip
= m_aQueryTooltipHdl
.Call(aHelpArea
);
715 if (sHelpTip
.isEmpty())
717 Point aPt
= OutputToScreenPixel(aHelpArea
.TopLeft());
718 aHelpArea
.SetLeft(aPt
.X());
719 aHelpArea
.SetTop(aPt
.Y());
720 aPt
= OutputToScreenPixel(aHelpArea
.BottomRight());
721 aHelpArea
.SetRight(aPt
.X());
722 aHelpArea
.SetBottom(aPt
.Y());
723 // tdf#125369 recover newline support of tdf#101779
724 QuickHelpFlags eHelpWinStyle
= sHelpTip
.indexOf('\n') != -1 ? QuickHelpFlags::TipStyleBalloon
: QuickHelpFlags::NONE
;
725 Help::ShowQuickHelp(this, aHelpArea
, sHelpTip
, eHelpWinStyle
);
728 virtual void StartDrag(sal_Int8 nAction
, const Point
& rPosPixel
) override
;
729 virtual FactoryFunction
GetUITestFactory() const override
731 if (m_pFactoryFunction
)
732 return m_pFactoryFunction
;
733 return Control::GetUITestFactory();
737 VclDrawingArea(vcl::Window
*pParent
, WinBits nStyle
)
738 : Control(pParent
, nStyle
)
739 , DragSourceHelper(this)
740 , m_pFactoryFunction(nullptr)
741 , m_pUserData(nullptr)
746 virtual void MouseButtonDown(const MouseEvent
& rMEvt
) override
748 if (!m_aMousePressHdl
.Call(rMEvt
))
749 Control::MouseButtonDown(rMEvt
);
751 virtual void MouseButtonUp(const MouseEvent
& rMEvt
) override
753 if (!m_aMouseReleaseHdl
.Call(rMEvt
))
754 Control::MouseButtonUp(rMEvt
);
756 virtual OUString
GetSurroundingText() const override
;
757 virtual Selection
GetSurroundingTextSelection() const override
;
758 virtual bool DeleteSurroundingText(const Selection
& rSelection
) override
;
759 void SetUITestFactory(FactoryFunction pFactoryFunction
, void* pUserData
)
761 m_pFactoryFunction
= pFactoryFunction
;
762 m_pUserData
= pUserData
;
764 void* GetUserData() const
768 void SetPaintHdl(const Link
<std::pair
<vcl::RenderContext
&, const tools::Rectangle
&>, void>& rLink
)
772 void SetResizeHdl(const Link
<const Size
&, void>& rLink
)
774 m_aResizeHdl
= rLink
;
776 void SetMousePressHdl(const Link
<const MouseEvent
&, bool>& rLink
)
778 m_aMousePressHdl
= rLink
;
780 void SetMouseMoveHdl(const Link
<const MouseEvent
&, bool>& rLink
)
782 m_aMouseMotionHdl
= rLink
;
784 void SetMouseReleaseHdl(const Link
<const MouseEvent
&, bool>& rLink
)
786 m_aMouseReleaseHdl
= rLink
;
788 void SetKeyPressHdl(const Link
<const KeyEvent
&, bool>& rLink
)
790 m_aKeyPressHdl
= rLink
;
792 void SetKeyReleaseHdl(const Link
<const KeyEvent
&, bool>& rLink
)
794 m_aKeyReleaseHdl
= rLink
;
796 void SetStyleUpdatedHdl(const Link
<VclDrawingArea
&, void>& rLink
)
798 m_aStyleUpdatedHdl
= rLink
;
800 void SetCommandHdl(const Link
<const CommandEvent
&, bool>& rLink
)
802 m_aCommandHdl
= rLink
;
804 void SetQueryTooltipHdl(const Link
<tools::Rectangle
&, OUString
>& rLink
)
806 m_aQueryTooltipHdl
= rLink
;
808 void SetGetSurroundingHdl(const Link
<OUString
&, int>& rLink
)
810 m_aGetSurroundingHdl
= rLink
;
812 void SetDeleteSurroundingHdl(const Link
<const Selection
&, bool>& rLink
)
814 m_aDeleteSurroundingHdl
= rLink
;
816 void SetStartDragHdl(const Link
<VclDrawingArea
*, bool>& rLink
)
818 m_aStartDragHdl
= rLink
;
820 void SetDragHelper(const rtl::Reference
<TransferDataContainer
>& rHelper
, sal_uInt8 eDNDConstants
)
822 m_xTransferHelper
= rHelper
;
823 m_nDragAction
= eDNDConstants
;
825 virtual void DumpAsPropertyTree(tools::JsonWriter
&) override
;
828 //Get first window of a pTopLevel window as
829 //if any intermediate layout widgets didn't exist
830 //i.e. acts like pChild = pChild->GetWindow(GetWindowType::FirstChild);
831 //in a flat hierarchy where dialogs only have one layer
833 vcl::Window
* firstLogicalChildOfParent(const vcl::Window
*pTopLevel
);
835 //Get last window of a pTopLevel window as
836 //if any intermediate layout widgets didn't exist
837 //i.e. acts like pChild = pChild->GetWindow(GetWindowType::LastChild);
838 //in a flat hierarchy where dialogs only have one layer
840 vcl::Window
* lastLogicalChildOfParent(const vcl::Window
*pTopLevel
);
842 //Get next window after pChild of a pTopLevel window as
843 //if any intermediate layout widgets didn't exist
844 //i.e. acts like pChild = pChild->GetWindow(GetWindowType::Next);
845 //in a flat hierarchy where dialogs only have one layer
847 vcl::Window
* nextLogicalChildOfParent(const vcl::Window
*pTopLevel
, const vcl::Window
*pChild
);
849 //Get previous window before pChild of a pTopLevel window as
850 //if any intermediate layout widgets didn't exist
851 //i.e. acts like pChild = pChild->GetWindow(GetWindowType::Prev);
852 //in a flat hierarchy where dialogs only have one layer
854 vcl::Window
* prevLogicalChildOfParent(const vcl::Window
*pTopLevel
, const vcl::Window
*pChild
);
856 //Returns true is the Window has a single child which is a container
857 VCL_DLLPUBLIC
bool isLayoutEnabled(const vcl::Window
*pWindow
);
859 inline bool isContainerWindow(const vcl::Window
&rWindow
)
861 WindowType eType
= rWindow
.GetType();
862 return eType
== WindowType::CONTAINER
|| eType
== WindowType::SCROLLWINDOW
||
863 (eType
== WindowType::DOCKINGWINDOW
&& ::isLayoutEnabled(&rWindow
));
866 inline bool isContainerWindow(const vcl::Window
*pWindow
)
868 return pWindow
&& isContainerWindow(*pWindow
);
871 // retro-fitting utilities
873 //Get a Size which is large enough to contain all children with
874 //an equal amount of space at top left and bottom right
875 Size
getLegacyBestSizeForChildren(const vcl::Window
&rWindow
);
877 //Get first parent which is not a layout widget
878 vcl::Window
* getNonLayoutParent(vcl::Window
*pParent
);
880 //Sort ok/cancel etc buttons in platform order
881 void sort_native_button_order(const VclBox
& rContainer
);
885 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */