Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / include / vcl / splitwin.hxx
blobb71b8e745b6ec9c3ce331863f1a9aa49130a1e9c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
26 class Wallpaper;
27 struct ImplSplitSet;
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
42 private:
43 ImplSplitSet* mpMainSet;
44 ImplSplitSet* mpBaseSet;
45 ImplSplitSet* mpSplitSet;
46 long* mpLastSizes;
47 Rectangle maDragRect;
48 long mnDX;
49 long mnDY;
50 long mnLeftBorder;
51 long mnTopBorder;
52 long mnRightBorder;
53 long mnBottomBorder;
54 long mnMaxSize;
55 long mnMouseOff;
56 long mnMStartPos;
57 long mnMSplitPos;
58 WinBits mnWinStyle;
59 WindowAlign meAlign;
60 sal_uInt16 mnSplitTest;
61 sal_uInt16 mnSplitPos;
62 sal_uInt16 mnMouseModifier;
63 bool mbDragFull:1,
64 mbHorz:1,
65 mbBottomRight:1,
66 mbCalc:1,
67 mbRecalc:1,
68 mbInvalidate:1,
69 mbSizeable:1,
70 mbBorder:1,
71 mbAutoHide:1,
72 mbFadeIn:1,
73 mbFadeOut:1,
74 mbAutoHideIn:1,
75 mbAutoHideDown:1,
76 mbFadeInDown:1,
77 mbFadeOutDown:1,
78 mbAutoHidePressed:1,
79 mbFadeInPressed:1,
80 mbFadeOutPressed:1,
81 mbFadeNoButtonMode:1,
82 mbNoAlign:1;
83 Link maStartSplitHdl;
84 Link maSplitHdl;
85 Link maSplitResizeHdl;
86 Link maAutoHideHdl;
87 Link maFadeInHdl;
88 Link maFadeOutHdl;
90 using Window::ImplInit;
91 SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
92 SAL_DLLPRIVATE void ImplInitSettings();
93 SAL_DLLPRIVATE void ImplCalcLayout();
94 SAL_DLLPRIVATE void ImplUpdate();
95 SAL_DLLPRIVATE void ImplSetWindowSize( long nDelta );
96 SAL_DLLPRIVATE void ImplSplitMousePos( Point& rMousePos );
97 SAL_DLLPRIVATE void ImplGetButtonRect( Rectangle& rRect, long nEx, bool bTest ) const;
98 SAL_DLLPRIVATE void ImplGetAutoHideRect( Rectangle& rRect, bool bTest = false ) const;
99 SAL_DLLPRIVATE void ImplGetFadeInRect( Rectangle& rRect, bool bTest = false ) const;
100 SAL_DLLPRIVATE void ImplGetFadeOutRect( Rectangle& rRect, bool bTest = false ) const;
101 SAL_DLLPRIVATE void ImplDrawButtonRect( const Rectangle& rRect, long nSize );
102 SAL_DLLPRIVATE void ImplDrawAutoHide( bool bInPaint );
103 SAL_DLLPRIVATE void ImplDrawFadeIn( bool bInPaint );
104 SAL_DLLPRIVATE void ImplDrawFadeOut( bool bInPaint );
105 SAL_DLLPRIVATE void ImplNewAlign();
106 SAL_DLLPRIVATE void ImplDrawGrip( const Rectangle& rRect, bool bHorz, bool bLeft );
107 SAL_DLLPRIVATE void ImplDrawFadeArrow( const Point& rPt, bool bHorz, bool bLeft );
108 SAL_DLLPRIVATE void ImplStartSplit( const MouseEvent& rMEvt );
110 static SAL_DLLPRIVATE void ImplDrawBorder( SplitWindow* pWin );
111 static SAL_DLLPRIVATE void ImplDrawBorderLine( SplitWindow* pWin );
112 static SAL_DLLPRIVATE void ImplCalcSet2( SplitWindow* pWindow, ImplSplitSet* pSet, bool bHide,
113 bool bRows, bool bDown = true );
114 static SAL_DLLPRIVATE void ImplDrawBack( SplitWindow* pWindow, ImplSplitSet* pSet );
115 static SAL_DLLPRIVATE void ImplDrawBack( SplitWindow* pWindow, const Rectangle& rRect,
116 const Wallpaper* pWall, const Bitmap* pBitmap );
117 static SAL_DLLPRIVATE sal_uInt16 ImplTestSplit( ImplSplitSet* pSet, const Point& rPos,
118 long& rMouseOff, ImplSplitSet** ppFoundSet, sal_uInt16& rFoundPos,
119 bool bRows, bool bDown = true );
120 static SAL_DLLPRIVATE sal_uInt16 ImplTestSplit( SplitWindow* pWindow, const Point& rPos,
121 long& rMouseOff, ImplSplitSet** ppFoundSet, sal_uInt16& rFoundPos );
122 static SAL_DLLPRIVATE void ImplDrawSplitTracking( SplitWindow* pThis, const Point& rPos );
124 // Copy assignment is forbidden and not implemented.
125 SAL_DLLPRIVATE SplitWindow (const SplitWindow &);
126 SAL_DLLPRIVATE SplitWindow & operator= (const SplitWindow &);
127 public:
128 SplitWindow( Window* pParent, WinBits nStyle = 0 );
129 virtual ~SplitWindow();
131 virtual void StartSplit();
132 virtual void Split();
133 virtual void SplitResize();
134 virtual void AutoHide();
135 virtual void FadeIn();
136 virtual void FadeOut();
138 virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
139 virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
140 virtual void Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
141 virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
142 virtual void Move() SAL_OVERRIDE;
143 virtual void Resize() SAL_OVERRIDE;
144 virtual void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
145 virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
146 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
147 virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
149 void InsertItem( sal_uInt16 nId, Window* pWindow, long nSize,
150 sal_uInt16 nPos = SPLITWINDOW_APPEND, sal_uInt16 nSetId = 0,
151 SplitWindowItemBits nBits = 0 );
152 void InsertItem( sal_uInt16 nId, long nSize,
153 sal_uInt16 nPos = SPLITWINDOW_APPEND, sal_uInt16 nSetId = 0,
154 SplitWindowItemBits nBits = 0 );
155 void RemoveItem( sal_uInt16 nId, bool bHide = true );
156 void Clear();
158 void SplitItem( sal_uInt16 nId, long nNewSize,
159 bool bPropSmall = false,
160 bool bPropGreat = false );
161 void SetItemSize( sal_uInt16 nId, long nNewSize );
162 long GetItemSize( sal_uInt16 nId ) const;
163 /** Set a range that limits the (variable part of the) size with an
164 upper and a lower bound (both are valid values themselves.)
165 @param nId
166 Id of the item for which the size limits are set.
167 @param aRange
168 Values of -1 define missing bounds, thus setting a range (-1,-1)
169 (the default) removes the size limitiation.
171 void SetItemSizeRange (sal_uInt16 nId, const Range aRange);
172 /** Return the current size limits for the specified item.
174 long GetItemSize( sal_uInt16 nId, SplitWindowItemBits nBits ) const;
175 sal_uInt16 GetSet( sal_uInt16 nId ) const;
176 sal_uInt16 GetItemId( Window* pWindow ) const;
177 sal_uInt16 GetItemId( const Point& rPos ) const;
178 sal_uInt16 GetItemPos( sal_uInt16 nId, sal_uInt16 nSetId = 0 ) const;
179 sal_uInt16 GetItemId( sal_uInt16 nPos, sal_uInt16 nSetId = 0 ) const;
180 sal_uInt16 GetItemCount( sal_uInt16 nSetId = 0 ) const;
181 bool IsItemValid( sal_uInt16 nId ) const;
183 bool IsNoAlign() const { return mbNoAlign; }
184 void SetAlign( WindowAlign eNewAlign = WINDOWALIGN_TOP );
185 WindowAlign GetAlign() const { return meAlign; }
186 bool IsHorizontal() const { return mbHorz; }
188 bool IsSplitting() const { return IsTracking(); }
190 void SetMaxSizePixel( long nNewMaxSize ) { mnMaxSize = nNewMaxSize; }
191 long GetMaxSizePixel() const { return mnMaxSize; }
193 Size CalcLayoutSizePixel( const Size& aNewSize );
195 void ShowAutoHideButton( bool bShow = true );
196 bool IsAutoHideButtonVisible() const { return mbAutoHide; }
197 void ShowFadeInHideButton( bool bShow = true );
198 void ShowFadeInButton( bool bShow = true ) { ShowFadeInHideButton( bShow ); }
199 bool IsFadeInButtonVisible() const { return mbFadeIn; }
200 void ShowFadeOutButton( bool bShow = true );
201 bool IsFadeOutButtonVisible() const { return mbFadeOut; }
202 long GetFadeInSize() const;
203 bool IsFadeNoButtonMode() const { return mbFadeNoButtonMode; }
205 void SetAutoHideState( bool bAutoHide );
206 bool GetAutoHideState() const { return mbAutoHideIn; }
208 void SetStartSplitHdl( const Link& rLink ) { maStartSplitHdl = rLink; }
209 const Link& GetStartSplitHdl() const { return maStartSplitHdl; }
210 void SetSplitHdl( const Link& rLink ) { maSplitHdl = rLink; }
211 const Link& GetSplitHdl() const { return maSplitHdl; }
212 void SetSplitResizeHdl( const Link& rLink ) { maSplitResizeHdl = rLink; }
213 const Link& GetSplitResizeHdl() const { return maSplitResizeHdl; }
214 void SetAutoHideHdl( const Link& rLink ) { maAutoHideHdl = rLink; }
215 const Link& GetAutoHideHdl() const { return maAutoHideHdl; }
216 void SetFadeInHdl( const Link& rLink ) { maFadeInHdl = rLink; }
217 const Link& GetFadeInHdl() const { return maFadeInHdl; }
218 void SetFadeOutHdl( const Link& rLink ) { maFadeOutHdl = rLink; }
219 const Link& GetFadeOutHdl() const { return maFadeOutHdl; }
222 #endif // INCLUDED_VCL_SPLITWIN_HXX
224 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */