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>
30 enum class SplitWindowItemFlags
34 RelativeSize
= 0x0002,
41 template<> struct typed_flags
<SplitWindowItemFlags
> : is_typed_flags
<SplitWindowItemFlags
, 0x1f> {};
44 #define SPLITWINDOW_APPEND ((sal_uInt16)0xFFFF)
45 #define SPLITWINDOW_ITEM_NOTFOUND ((sal_uInt16)0xFFFF)
47 class VCL_DLLPUBLIC SplitWindow
: public DockingWindow
50 ImplSplitSet
* mpMainSet
;
51 ImplSplitSet
* mpBaseSet
;
52 ImplSplitSet
* mpSplitSet
;
54 tools::Rectangle maDragRect
;
67 sal_uInt16 mnSplitTest
;
68 sal_uInt16 mnSplitPos
;
69 sal_uInt16 mnMouseModifier
;
83 Link
<SplitWindow
*,void> maSplitHdl
;
85 using Window::ImplInit
;
86 SAL_DLLPRIVATE
void ImplInit( vcl::Window
* pParent
, WinBits nStyle
);
87 SAL_DLLPRIVATE
void ImplInitSettings();
88 SAL_DLLPRIVATE
void ImplCalcLayout();
89 SAL_DLLPRIVATE
void ImplUpdate();
90 SAL_DLLPRIVATE
void ImplSetWindowSize( long nDelta
);
91 SAL_DLLPRIVATE
void ImplSplitMousePos( Point
& rMousePos
);
92 SAL_DLLPRIVATE
void ImplGetButtonRect( tools::Rectangle
& rRect
, bool bTest
) const;
93 SAL_DLLPRIVATE
void ImplGetFadeInRect( tools::Rectangle
& rRect
, bool bTest
= false ) const;
94 SAL_DLLPRIVATE
void ImplGetFadeOutRect( tools::Rectangle
& rRect
) const;
95 SAL_DLLPRIVATE
void ImplDrawFadeIn(vcl::RenderContext
& rRenderContext
);
96 SAL_DLLPRIVATE
void ImplDrawFadeOut(vcl::RenderContext
& rRenderContext
);
97 SAL_DLLPRIVATE
void ImplNewAlign();
98 SAL_DLLPRIVATE
void ImplDrawGrip(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
, bool bHorz
, bool bLeft
);
99 SAL_DLLPRIVATE
void ImplStartSplit( const MouseEvent
& rMEvt
);
101 SAL_DLLPRIVATE
void ImplDrawBorder(vcl::RenderContext
& rRenderContext
);
102 SAL_DLLPRIVATE
void ImplDrawBorderLine(vcl::RenderContext
& rRenderContext
);
103 static SAL_DLLPRIVATE
void ImplCalcSet2( SplitWindow
* pWindow
, ImplSplitSet
* pSet
, bool bHide
,
105 SAL_DLLPRIVATE
void ImplDrawBack(vcl::RenderContext
& rRenderContext
, ImplSplitSet
* pSet
);
106 SAL_DLLPRIVATE
static void ImplDrawBack(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
,
107 const Wallpaper
* pWall
, const Bitmap
* pBitmap
);
108 static SAL_DLLPRIVATE sal_uInt16
ImplTestSplit( ImplSplitSet
* pSet
, const Point
& rPos
,
109 long& rMouseOff
, ImplSplitSet
** ppFoundSet
, sal_uInt16
& rFoundPos
,
111 static SAL_DLLPRIVATE sal_uInt16
ImplTestSplit( SplitWindow
* pWindow
, const Point
& rPos
,
112 long& rMouseOff
, ImplSplitSet
** ppFoundSet
, sal_uInt16
& rFoundPos
);
113 SAL_DLLPRIVATE
void ImplDrawSplitTracking(const Point
& rPos
);
115 SplitWindow (const SplitWindow
&) = delete;
116 SplitWindow
& operator= (const SplitWindow
&) = delete;
118 SplitWindow( vcl::Window
* pParent
, WinBits nStyle
= 0 );
119 virtual ~SplitWindow() override
;
120 virtual void dispose() override
;
122 virtual void StartSplit();
123 virtual void Split();
124 virtual void SplitResize();
125 virtual void FadeIn();
126 virtual void FadeOut();
128 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
129 virtual void MouseMove( const MouseEvent
& rMEvt
) override
;
130 virtual void Tracking( const TrackingEvent
& rTEvt
) override
;
131 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
132 virtual void Resize() override
;
133 virtual void RequestHelp( const HelpEvent
& rHEvt
) override
;
134 virtual void StateChanged( StateChangedType nType
) override
;
135 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
136 virtual bool PreNotify( NotifyEvent
& rNEvt
) override
;
138 void InsertItem( sal_uInt16 nId
, vcl::Window
* pWindow
, long nSize
,
139 sal_uInt16 nPos
, sal_uInt16 nIntoSetId
,
140 SplitWindowItemFlags nBits
);
141 void InsertItem( sal_uInt16 nId
, long nSize
,
142 sal_uInt16 nPos
, sal_uInt16 nIntoSetId
,
143 SplitWindowItemFlags nBits
);
144 void RemoveItem( sal_uInt16 nId
);
147 void SplitItem( sal_uInt16 nId
, long nNewSize
,
150 void SetItemSize( sal_uInt16 nId
, long nNewSize
);
151 long GetItemSize( sal_uInt16 nId
) const;
152 /** Set a range that limits the (variable part of the) size with an
153 upper and a lower bound (both are valid values themselves.)
155 Id of the item for which the size limits are set.
157 Values of -1 define missing bounds, thus setting a range (-1,-1)
158 (the default) removes the size limit.
160 void SetItemSizeRange (sal_uInt16 nId
, const Range
& rRange
);
161 /** Return the current size limits for the specified item.
163 long GetItemSize( sal_uInt16 nId
, SplitWindowItemFlags nBits
) const;
164 sal_uInt16
GetSet( sal_uInt16 nId
) const;
165 sal_uInt16
GetItemId( vcl::Window
* pWindow
) const;
166 sal_uInt16
GetItemId( const Point
& rPos
) const;
167 sal_uInt16
GetItemPos( sal_uInt16 nId
, sal_uInt16 nSetId
= 0 ) const;
168 sal_uInt16
GetItemId( sal_uInt16 nPos
) const;
169 sal_uInt16
GetItemCount( sal_uInt16 nSetId
= 0 ) const;
170 bool IsItemValid( sal_uInt16 nId
) const;
172 void SetAlign( WindowAlign eNewAlign
);
173 WindowAlign
GetAlign() const { return meAlign
; }
174 bool IsHorizontal() const { return mbHorz
; }
176 void SetMaxSizePixel( long nNewMaxSize
) { mnMaxSize
= nNewMaxSize
; }
178 Size
CalcLayoutSizePixel( const Size
& aNewSize
);
180 void ShowFadeInHideButton();
181 void ShowFadeOutButton();
182 long GetFadeInSize() const;
183 bool IsFadeNoButtonMode() const { return mbFadeNoButtonMode
; }
185 void SetSplitHdl( const Link
<SplitWindow
*,void>& rLink
) { maSplitHdl
= rLink
; }
188 #endif // INCLUDED_VCL_SPLITWIN_HXX
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */