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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_SPLITWIN_HXX
21 #define INCLUDED_VCL_SPLITWIN_HXX
23 #include <vcl/dllapi.h>
24 #include <vcl/dockwin.hxx>
25 #include <o3tl/typed_flags_set.hxx>
29 enum class SplitWindowItemFlags
33 RelativeSize
= 0x0002,
39 template<> struct typed_flags
<SplitWindowItemFlags
> : is_typed_flags
<SplitWindowItemFlags
, 0x0f> {};
42 #define SPLITWINDOW_APPEND (sal_uInt16(0xFFFF))
43 #define SPLITWINDOW_ITEM_NOTFOUND (sal_uInt16(0xFFFF))
45 class VCL_DLLPUBLIC SplitWindow
: public DockingWindow
48 std::unique_ptr
<ImplSplitSet
> mpMainSet
;
49 ImplSplitSet
* mpBaseSet
;
50 ImplSplitSet
* mpSplitSet
;
51 tools::Long
* mpLastSizes
;
52 tools::Rectangle maDragRect
;
55 tools::Long mnLeftBorder
;
56 tools::Long mnTopBorder
;
57 tools::Long mnRightBorder
;
58 tools::Long mnBottomBorder
;
59 tools::Long mnMaxSize
;
60 tools::Long mnMouseOff
;
61 tools::Long mnMStartPos
;
62 tools::Long mnMSplitPos
;
65 sal_uInt16 mnSplitTest
;
66 sal_uInt16 mnSplitPos
;
67 sal_uInt16 mnMouseModifier
;
81 Link
<SplitWindow
*,void> maSplitHdl
;
83 using Window::ImplInit
;
84 SAL_DLLPRIVATE
void ImplInit( vcl::Window
* pParent
, WinBits nStyle
);
85 SAL_DLLPRIVATE
void ImplInitSettings();
86 SAL_DLLPRIVATE
void ImplCalcLayout();
87 SAL_DLLPRIVATE
void ImplUpdate();
88 SAL_DLLPRIVATE
void ImplSetWindowSize( tools::Long nDelta
);
89 SAL_DLLPRIVATE
void ImplSplitMousePos( Point
& rMousePos
);
90 SAL_DLLPRIVATE
void ImplGetButtonRect( tools::Rectangle
& rRect
, bool bTest
) const;
91 SAL_DLLPRIVATE
void ImplGetFadeInRect( tools::Rectangle
& rRect
, bool bTest
= false ) const;
92 SAL_DLLPRIVATE
void ImplGetFadeOutRect( tools::Rectangle
& rRect
) const;
93 SAL_DLLPRIVATE
void ImplDrawFadeIn(vcl::RenderContext
& rRenderContext
);
94 SAL_DLLPRIVATE
void ImplDrawFadeOut(vcl::RenderContext
& rRenderContext
);
95 SAL_DLLPRIVATE
void ImplNewAlign();
96 SAL_DLLPRIVATE
void ImplDrawGrip(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
, bool bHorz
, bool bLeft
);
97 SAL_DLLPRIVATE
void ImplStartSplit( const MouseEvent
& rMEvt
);
99 SAL_DLLPRIVATE
void ImplDrawBorder(vcl::RenderContext
& rRenderContext
);
100 SAL_DLLPRIVATE
void ImplDrawBorderLine(vcl::RenderContext
& rRenderContext
);
101 static SAL_DLLPRIVATE
void ImplCalcSet2( SplitWindow
* pWindow
, ImplSplitSet
* pSet
, bool bHide
,
103 static SAL_DLLPRIVATE sal_uInt16
ImplTestSplit( ImplSplitSet
* pSet
, const Point
& rPos
,
104 tools::Long
& rMouseOff
, ImplSplitSet
** ppFoundSet
, sal_uInt16
& rFoundPos
,
106 static SAL_DLLPRIVATE sal_uInt16
ImplTestSplit( const SplitWindow
* pWindow
, const Point
& rPos
,
107 tools::Long
& rMouseOff
, ImplSplitSet
** ppFoundSet
, sal_uInt16
& rFoundPos
);
108 SAL_DLLPRIVATE
void ImplDrawSplitTracking(const Point
& rPos
);
110 SplitWindow (const SplitWindow
&) = delete;
111 SplitWindow
& operator= (const SplitWindow
&) = delete;
113 SplitWindow( vcl::Window
* pParent
, WinBits nStyle
= 0 );
114 virtual ~SplitWindow() override
;
115 virtual void dispose() override
;
117 virtual void StartSplit();
118 virtual void Split();
119 virtual void SplitResize();
120 virtual void FadeIn();
121 virtual void FadeOut();
123 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
124 virtual void MouseMove( const MouseEvent
& rMEvt
) override
;
125 virtual void Tracking( const TrackingEvent
& rTEvt
) override
;
126 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
127 virtual void Resize() override
;
128 virtual void RequestHelp( const HelpEvent
& rHEvt
) override
;
129 virtual void StateChanged( StateChangedType nType
) override
;
130 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
131 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
133 void InsertItem( sal_uInt16 nId
, vcl::Window
* pWindow
, tools::Long nSize
,
134 sal_uInt16 nPos
, sal_uInt16 nIntoSetId
,
135 SplitWindowItemFlags nBits
);
136 void InsertItem( sal_uInt16 nId
, tools::Long nSize
,
137 sal_uInt16 nPos
, sal_uInt16 nIntoSetId
,
138 SplitWindowItemFlags nBits
);
139 void RemoveItem( sal_uInt16 nId
);
141 void SplitItem( sal_uInt16 nId
, tools::Long nNewSize
,
144 void SetItemSize( sal_uInt16 nId
, tools::Long nNewSize
);
145 tools::Long
GetItemSize( sal_uInt16 nId
) const;
146 /** Set a range that limits the (variable part of the) size with an
147 upper and a lower bound (both are valid values themselves.)
149 Id of the item for which the size limits are set.
151 Values of -1 define missing bounds, thus setting a range (-1,-1)
152 (the default) removes the size limit.
154 void SetItemSizeRange (sal_uInt16 nId
, const Range
& rRange
);
155 /** Return the current size limits for the specified item.
157 tools::Long
GetItemSize( sal_uInt16 nId
, SplitWindowItemFlags nBits
) const;
158 sal_uInt16
GetSet( sal_uInt16 nId
) const;
159 sal_uInt16
GetItemId( vcl::Window
* pWindow
) const;
160 sal_uInt16
GetItemId( const Point
& rPos
) const;
161 sal_uInt16
GetItemPos( sal_uInt16 nId
, sal_uInt16 nSetId
= 0 ) const;
162 sal_uInt16
GetItemId( sal_uInt16 nPos
) const;
163 sal_uInt16
GetItemCount( sal_uInt16 nSetId
= 0 ) const;
164 bool IsItemValid( sal_uInt16 nId
) const;
166 void SetAlign( WindowAlign eNewAlign
);
167 WindowAlign
GetAlign() const { return meAlign
; }
168 bool IsHorizontal() const { return mbHorz
; }
170 void SetMaxSizePixel( tools::Long nNewMaxSize
) { mnMaxSize
= nNewMaxSize
; }
172 Size
CalcLayoutSizePixel( const Size
& aNewSize
);
174 void ShowFadeInHideButton();
175 void ShowFadeOutButton();
176 tools::Long
GetFadeInSize() const;
177 bool IsFadeNoButtonMode() const { return mbFadeNoButtonMode
; }
179 void SetSplitHdl( const Link
<SplitWindow
*,void>& rLink
) { maSplitHdl
= rLink
; }
182 #endif // INCLUDED_VCL_SPLITWIN_HXX
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */