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>
29 typedef sal_uInt16 SplitWindowItemBits
;
31 #define SWIB_FIXED ((SplitWindowItemBits)0x0001)
32 #define SWIB_RELATIVESIZE ((SplitWindowItemBits)0x0002)
33 #define SWIB_PERCENTSIZE ((SplitWindowItemBits)0x0004)
34 #define SWIB_COLSET ((SplitWindowItemBits)0x0008)
35 #define SWIB_INVISIBLE ((SplitWindowItemBits)0x0010)
37 #define SPLITWINDOW_APPEND ((sal_uInt16)0xFFFF)
38 #define SPLITWINDOW_ITEM_NOTFOUND ((sal_uInt16)0xFFFF)
40 class VCL_DLLPUBLIC SplitWindow
: public DockingWindow
43 ImplSplitSet
* mpMainSet
;
44 ImplSplitSet
* mpBaseSet
;
45 ImplSplitSet
* mpSplitSet
;
60 sal_uInt16 mnSplitTest
;
61 sal_uInt16 mnSplitPos
;
62 sal_uInt16 mnMouseModifier
;
81 Link
<> maStartSplitHdl
;
83 Link
<> maSplitResizeHdl
;
88 using Window::ImplInit
;
89 SAL_DLLPRIVATE
void ImplInit( vcl::Window
* pParent
, WinBits nStyle
);
90 SAL_DLLPRIVATE
void ImplInitSettings();
91 SAL_DLLPRIVATE
void ImplCalcLayout();
92 SAL_DLLPRIVATE
void ImplUpdate();
93 SAL_DLLPRIVATE
void ImplSetWindowSize( long nDelta
);
94 SAL_DLLPRIVATE
void ImplSplitMousePos( Point
& rMousePos
);
95 SAL_DLLPRIVATE
void ImplGetButtonRect( Rectangle
& rRect
, long nEx
, bool bTest
) const;
96 SAL_DLLPRIVATE
void ImplGetAutoHideRect( Rectangle
& rRect
, bool bTest
= false ) const;
97 SAL_DLLPRIVATE
void ImplGetFadeInRect( Rectangle
& rRect
, bool bTest
= false ) const;
98 SAL_DLLPRIVATE
void ImplGetFadeOutRect( Rectangle
& rRect
, bool bTest
= false ) const;
99 SAL_DLLPRIVATE
void ImplDrawButtonRect(vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
, long nSize
);
100 SAL_DLLPRIVATE
void ImplDrawAutoHide(vcl::RenderContext
& rRenderContext
, bool bInPaint
);
101 SAL_DLLPRIVATE
void ImplDrawFadeIn(vcl::RenderContext
& rRenderContext
, bool bInPaint
);
102 SAL_DLLPRIVATE
void ImplDrawFadeOut(vcl::RenderContext
& rRenderContext
, bool bInPaint
);
103 SAL_DLLPRIVATE
void ImplNewAlign();
104 SAL_DLLPRIVATE
void ImplDrawGrip(vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
, bool bHorz
, bool bLeft
);
105 SAL_DLLPRIVATE
void ImplDrawFadeArrow(vcl::RenderContext
& rRenderContext
, const Point
& rPt
, bool bHorz
, bool bLeft
);
106 SAL_DLLPRIVATE
void ImplStartSplit( const MouseEvent
& rMEvt
);
108 SAL_DLLPRIVATE
void ImplDrawBorder(vcl::RenderContext
& rRenderContext
);
109 SAL_DLLPRIVATE
void ImplDrawBorderLine(vcl::RenderContext
& rRenderContext
);
110 static SAL_DLLPRIVATE
void ImplCalcSet2( SplitWindow
* pWindow
, ImplSplitSet
* pSet
, bool bHide
,
111 bool bRows
, bool bDown
= true );
112 SAL_DLLPRIVATE
void ImplDrawBack(vcl::RenderContext
& rRenderContext
, ImplSplitSet
* pSet
);
113 SAL_DLLPRIVATE
void ImplDrawBack(vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
,
114 const Wallpaper
* pWall
, const Bitmap
* pBitmap
);
115 static SAL_DLLPRIVATE sal_uInt16
ImplTestSplit( ImplSplitSet
* pSet
, const Point
& rPos
,
116 long& rMouseOff
, ImplSplitSet
** ppFoundSet
, sal_uInt16
& rFoundPos
,
117 bool bRows
, bool bDown
= true );
118 static SAL_DLLPRIVATE sal_uInt16
ImplTestSplit( SplitWindow
* pWindow
, const Point
& rPos
,
119 long& rMouseOff
, ImplSplitSet
** ppFoundSet
, sal_uInt16
& rFoundPos
);
120 SAL_DLLPRIVATE
void ImplDrawSplitTracking(const Point
& rPos
);
122 SplitWindow (const SplitWindow
&) SAL_DELETED_FUNCTION
;
123 SplitWindow
& operator= (const SplitWindow
&) SAL_DELETED_FUNCTION
;
125 SplitWindow( vcl::Window
* pParent
, WinBits nStyle
= 0 );
126 virtual ~SplitWindow();
127 virtual void dispose() SAL_OVERRIDE
;
129 virtual void StartSplit();
130 virtual void Split();
131 virtual void SplitResize();
132 virtual void AutoHide();
133 virtual void FadeIn();
134 virtual void FadeOut();
136 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
137 virtual void MouseMove( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
138 virtual void Tracking( const TrackingEvent
& rTEvt
) SAL_OVERRIDE
;
139 virtual void Paint( vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
) SAL_OVERRIDE
;
140 virtual void Move() SAL_OVERRIDE
;
141 virtual void Resize() SAL_OVERRIDE
;
142 virtual void RequestHelp( const HelpEvent
& rHEvt
) SAL_OVERRIDE
;
143 virtual void StateChanged( StateChangedType nType
) SAL_OVERRIDE
;
144 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) SAL_OVERRIDE
;
145 virtual bool PreNotify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
147 void InsertItem( sal_uInt16 nId
, vcl::Window
* pWindow
, long nSize
,
148 sal_uInt16 nPos
= SPLITWINDOW_APPEND
, sal_uInt16 nIntoSetId
= 0,
149 SplitWindowItemBits nBits
= 0 );
150 void InsertItem( sal_uInt16 nId
, long nSize
,
151 sal_uInt16 nPos
= SPLITWINDOW_APPEND
, sal_uInt16 nIntoSetId
= 0,
152 SplitWindowItemBits nBits
= 0 );
153 void RemoveItem( sal_uInt16 nId
, bool bHide
= true );
156 void SplitItem( sal_uInt16 nId
, long nNewSize
,
157 bool bPropSmall
= false,
158 bool bPropGreat
= false );
159 void SetItemSize( sal_uInt16 nId
, long nNewSize
);
160 long GetItemSize( sal_uInt16 nId
) const;
161 /** Set a range that limits the (variable part of the) size with an
162 upper and a lower bound (both are valid values themselves.)
164 Id of the item for which the size limits are set.
166 Values of -1 define missing bounds, thus setting a range (-1,-1)
167 (the default) removes the size limitiation.
169 void SetItemSizeRange (sal_uInt16 nId
, const Range
& rRange
);
170 /** Return the current size limits for the specified item.
172 long GetItemSize( sal_uInt16 nId
, SplitWindowItemBits nBits
) const;
173 sal_uInt16
GetSet( sal_uInt16 nId
) const;
174 sal_uInt16
GetItemId( vcl::Window
* pWindow
) const;
175 sal_uInt16
GetItemId( const Point
& rPos
) const;
176 sal_uInt16
GetItemPos( sal_uInt16 nId
, sal_uInt16 nSetId
= 0 ) const;
177 sal_uInt16
GetItemId( sal_uInt16 nPos
, sal_uInt16 nSetId
= 0 ) const;
178 sal_uInt16
GetItemCount( sal_uInt16 nSetId
= 0 ) const;
179 bool IsItemValid( sal_uInt16 nId
) const;
181 bool IsNoAlign() const { return mbNoAlign
; }
182 void SetAlign( WindowAlign eNewAlign
= WINDOWALIGN_TOP
);
183 WindowAlign
GetAlign() const { return meAlign
; }
184 bool IsHorizontal() const { return mbHorz
; }
186 bool IsSplitting() const { return IsTracking(); }
188 void SetMaxSizePixel( long nNewMaxSize
) { mnMaxSize
= nNewMaxSize
; }
189 long GetMaxSizePixel() const { return mnMaxSize
; }
191 Size
CalcLayoutSizePixel( const Size
& aNewSize
);
193 void ShowAutoHideButton( bool bShow
= true );
194 bool IsAutoHideButtonVisible() const { return mbAutoHide
; }
195 void ShowFadeInHideButton( bool bShow
= true );
196 void ShowFadeInButton( bool bShow
= true ) { ShowFadeInHideButton( bShow
); }
197 bool IsFadeInButtonVisible() const { return mbFadeIn
; }
198 void ShowFadeOutButton( bool bShow
= true );
199 bool IsFadeOutButtonVisible() const { return mbFadeOut
; }
200 long GetFadeInSize() const;
201 bool IsFadeNoButtonMode() const { return mbFadeNoButtonMode
; }
203 void SetAutoHideState( bool bAutoHide
);
204 bool GetAutoHideState() const { return mbAutoHideIn
; }
206 void SetStartSplitHdl( const Link
<>& rLink
) { maStartSplitHdl
= rLink
; }
207 const Link
<>& GetStartSplitHdl() const { return maStartSplitHdl
; }
208 void SetSplitHdl( const Link
<>& rLink
) { maSplitHdl
= rLink
; }
209 const Link
<>& GetSplitHdl() const { return maSplitHdl
; }
210 void SetSplitResizeHdl( const Link
<>& rLink
) { maSplitResizeHdl
= rLink
; }
211 const Link
<>& GetSplitResizeHdl() const { return maSplitResizeHdl
; }
212 void SetAutoHideHdl( const Link
<>& rLink
) { maAutoHideHdl
= rLink
; }
213 const Link
<>& GetAutoHideHdl() const { return maAutoHideHdl
; }
214 void SetFadeInHdl( const Link
<>& rLink
) { maFadeInHdl
= rLink
; }
215 const Link
<>& GetFadeInHdl() const { return maFadeInHdl
; }
216 void SetFadeOutHdl( const Link
<>& rLink
) { maFadeOutHdl
= rLink
; }
217 const Link
<>& GetFadeOutHdl() const { return maFadeOutHdl
; }
220 #endif // INCLUDED_VCL_SPLITWIN_HXX
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */