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 #define SPLITWIN_SPLITSIZE 4
46 #define SPLITWIN_SPLITSIZEEXLN 7
48 class VCL_DLLPUBLIC SplitWindow
: public DockingWindow
51 std::unique_ptr
<ImplSplitSet
> mpMainSet
;
52 ImplSplitSet
* mpBaseSet
;
53 ImplSplitSet
* mpSplitSet
;
54 std::unique_ptr
<tools::Long
[]> mpLastSizes
;
55 tools::Rectangle maDragRect
;
58 tools::Long mnLeftBorder
;
59 tools::Long mnTopBorder
;
60 tools::Long mnRightBorder
;
61 tools::Long mnBottomBorder
;
62 tools::Long mnMaxSize
;
63 tools::Long mnMouseOff
;
64 tools::Long mnMStartPos
;
65 tools::Long mnMSplitPos
;
68 sal_uInt16 mnSplitTest
;
69 sal_uInt16 mnSplitPos
;
70 sal_uInt16 mnMouseModifier
;
84 Link
<SplitWindow
*,void> maSplitHdl
;
86 using Window::ImplInit
;
87 SAL_DLLPRIVATE
void ImplInit( vcl::Window
* pParent
, WinBits nStyle
);
88 SAL_DLLPRIVATE
void ImplInitSettings();
89 SAL_DLLPRIVATE
void ImplCalcLayout();
90 SAL_DLLPRIVATE
void ImplUpdate();
91 SAL_DLLPRIVATE
void ImplSetWindowSize( tools::Long nDelta
);
92 SAL_DLLPRIVATE
void ImplSplitMousePos( Point
& rMousePos
);
93 SAL_DLLPRIVATE
void ImplGetButtonRect( tools::Rectangle
& rRect
, bool bTest
) const;
94 SAL_DLLPRIVATE
void ImplGetFadeInRect( tools::Rectangle
& rRect
, bool bTest
= false ) const;
95 SAL_DLLPRIVATE
void ImplGetFadeOutRect( tools::Rectangle
& rRect
) const;
96 SAL_DLLPRIVATE
void ImplDrawFadeIn(vcl::RenderContext
& rRenderContext
);
97 SAL_DLLPRIVATE
void ImplDrawFadeOut(vcl::RenderContext
& rRenderContext
);
98 SAL_DLLPRIVATE
void ImplNewAlign();
99 SAL_DLLPRIVATE
void ImplDrawGrip(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
, bool bHorz
, bool bLeft
);
100 SAL_DLLPRIVATE
void ImplStartSplit( const MouseEvent
& rMEvt
);
102 SAL_DLLPRIVATE
void ImplDrawBorder(vcl::RenderContext
& rRenderContext
);
103 SAL_DLLPRIVATE
void ImplDrawBorderLine(vcl::RenderContext
& rRenderContext
);
104 static SAL_DLLPRIVATE
void ImplCalcSet2( SplitWindow
* pWindow
, ImplSplitSet
* pSet
, bool bHide
,
106 static SAL_DLLPRIVATE sal_uInt16
ImplTestSplit( ImplSplitSet
* pSet
, const Point
& rPos
,
107 tools::Long
& rMouseOff
, ImplSplitSet
** ppFoundSet
, sal_uInt16
& rFoundPos
,
109 static SAL_DLLPRIVATE sal_uInt16
ImplTestSplit( const SplitWindow
* pWindow
, const Point
& rPos
,
110 tools::Long
& rMouseOff
, ImplSplitSet
** ppFoundSet
, sal_uInt16
& rFoundPos
);
111 SAL_DLLPRIVATE
void ImplDrawSplitTracking(const Point
& rPos
);
113 SplitWindow (const SplitWindow
&) = delete;
114 SplitWindow
& operator= (const SplitWindow
&) = delete;
116 SplitWindow( vcl::Window
* pParent
, WinBits nStyle
= 0 );
117 virtual ~SplitWindow() override
;
118 virtual void dispose() override
;
120 virtual void StartSplit();
121 virtual void Split();
122 virtual void SplitResize();
123 virtual void FadeIn();
124 virtual void FadeOut();
126 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
127 virtual void MouseMove( const MouseEvent
& rMEvt
) override
;
128 virtual void Tracking( const TrackingEvent
& rTEvt
) override
;
129 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
130 virtual void Resize() override
;
131 virtual void RequestHelp( const HelpEvent
& rHEvt
) override
;
132 virtual void StateChanged( StateChangedType nType
) override
;
133 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
134 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
136 void InsertItem( sal_uInt16 nId
, vcl::Window
* pWindow
, tools::Long nSize
,
137 sal_uInt16 nPos
, sal_uInt16 nIntoSetId
,
138 SplitWindowItemFlags nBits
);
139 void InsertItem( sal_uInt16 nId
, tools::Long nSize
,
140 sal_uInt16 nPos
, sal_uInt16 nIntoSetId
,
141 SplitWindowItemFlags nBits
);
142 void RemoveItem( sal_uInt16 nId
);
144 void SplitItem( sal_uInt16 nId
, tools::Long nNewSize
,
147 void SetItemSize( sal_uInt16 nId
, tools::Long nNewSize
);
148 tools::Long
GetItemSize( sal_uInt16 nId
) const;
149 /** Set a range that limits the (variable part of the) size with an
150 upper and a lower bound (both are valid values themselves.)
152 Id of the item for which the size limits are set.
154 Values of -1 define missing bounds, thus setting a range (-1,-1)
155 (the default) removes the size limit.
157 void SetItemSizeRange (sal_uInt16 nId
, const Range
& rRange
);
158 /** Return the current size limits for the specified item.
160 tools::Long
GetItemSize( sal_uInt16 nId
, SplitWindowItemFlags nBits
) const;
161 sal_uInt16
GetSet( sal_uInt16 nId
) const;
162 sal_uInt16
GetItemId( vcl::Window
* pWindow
) const;
163 sal_uInt16
GetItemId( const Point
& rPos
) const;
164 sal_uInt16
GetItemPos( sal_uInt16 nId
, sal_uInt16 nSetId
= 0 ) const;
165 sal_uInt16
GetItemId( sal_uInt16 nPos
) const;
166 sal_uInt16
GetItemCount( sal_uInt16 nSetId
= 0 ) const;
167 bool IsItemValid( sal_uInt16 nId
) const;
169 void SetAlign( WindowAlign eNewAlign
);
170 WindowAlign
GetAlign() const { return meAlign
; }
171 bool IsHorizontal() const { return mbHorz
; }
173 void SetMaxSizePixel( tools::Long nNewMaxSize
) { mnMaxSize
= nNewMaxSize
; }
175 Size
CalcLayoutSizePixel( const Size
& aNewSize
);
177 void ShowFadeInHideButton();
178 void ShowFadeOutButton();
179 tools::Long
GetFadeInSize() const;
180 bool IsFadeNoButtonMode() const { return mbFadeNoButtonMode
; }
182 void SetSplitHdl( const Link
<SplitWindow
*,void>& rLink
) { maSplitHdl
= rLink
; }
185 #endif // INCLUDED_VCL_SPLITWIN_HXX
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */