Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SV_SPLITWIN_HXX
30 : : #define _SV_SPLITWIN_HXX
31 : :
32 : : #include <tools/solar.h>
33 : : #include <vcl/dllapi.h>
34 : : #include <vcl/dockwin.hxx>
35 : :
36 : : class Wallpaper;
37 : : struct ImplSplitSet;
38 : :
39 : : // -----------------------
40 : : // - SplitWindowItemBits -
41 : : // -----------------------
42 : :
43 : : typedef sal_uInt16 SplitWindowItemBits;
44 : :
45 : : // -------------------------------
46 : : // - Bits fuer SplitWindow-Items -
47 : : // -------------------------------
48 : :
49 : : #define SWIB_FIXED ((SplitWindowItemBits)0x0001)
50 : : #define SWIB_RELATIVESIZE ((SplitWindowItemBits)0x0002)
51 : : #define SWIB_PERCENTSIZE ((SplitWindowItemBits)0x0004)
52 : : #define SWIB_COLSET ((SplitWindowItemBits)0x0008)
53 : : #define SWIB_INVISIBLE ((SplitWindowItemBits)0x0010)
54 : :
55 : : // ---------------------
56 : : // - SplitWindow-Types -
57 : : // ---------------------
58 : :
59 : : #define SPLITWINDOW_APPEND ((sal_uInt16)0xFFFF)
60 : : #define SPLITWINDOW_ITEM_NOTFOUND ((sal_uInt16)0xFFFF)
61 : :
62 : : // ---------------
63 : : // - SplitWindow -
64 : : // ---------------
65 : :
66 : : class VCL_DLLPUBLIC SplitWindow : public DockingWindow
67 : : {
68 : : private:
69 : : ImplSplitSet* mpMainSet;
70 : : ImplSplitSet* mpBaseSet;
71 : : ImplSplitSet* mpSplitSet;
72 : : long* mpLastSizes;
73 : : Rectangle maDragRect;
74 : : long mnDX;
75 : : long mnDY;
76 : : long mnLeftBorder;
77 : : long mnTopBorder;
78 : : long mnRightBorder;
79 : : long mnBottomBorder;
80 : : long mnMaxSize;
81 : : long mnMouseOff;
82 : : long mnMStartPos;
83 : : long mnMSplitPos;
84 : : WinBits mnWinStyle;
85 : : WindowAlign meAlign;
86 : : sal_uInt16 mnSplitTest;
87 : : sal_uInt16 mnSplitPos;
88 : : sal_uInt16 mnMouseModifier;
89 : : sal_Bool mbDragFull:1,
90 : : mbHorz:1,
91 : : mbBottomRight:1,
92 : : mbCalc:1,
93 : : mbRecalc:1,
94 : : mbInvalidate:1,
95 : : mbSizeable:1,
96 : : mbBorder:1,
97 : : mbAutoHide:1,
98 : : mbFadeIn:1,
99 : : mbFadeOut:1,
100 : : mbAutoHideIn:1,
101 : : mbAutoHideDown:1,
102 : : mbFadeInDown:1,
103 : : mbFadeOutDown:1,
104 : : mbAutoHidePressed:1,
105 : : mbFadeInPressed:1,
106 : : mbFadeOutPressed:1,
107 : : mbFadeNoButtonMode:1,
108 : : mbNoAlign:1;
109 : : Link maStartSplitHdl;
110 : : Link maSplitHdl;
111 : : Link maSplitResizeHdl;
112 : : Link maAutoHideHdl;
113 : : Link maFadeInHdl;
114 : : Link maFadeOutHdl;
115 : :
116 : : using Window::ImplInit;
117 : : SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
118 : : SAL_DLLPRIVATE void ImplInitSettings();
119 : : SAL_DLLPRIVATE void ImplCalcLayout();
120 : : SAL_DLLPRIVATE void ImplUpdate();
121 : : SAL_DLLPRIVATE void ImplSetWindowSize( long nDelta );
122 : : SAL_DLLPRIVATE void ImplSplitMousePos( Point& rMousePos );
123 : : SAL_DLLPRIVATE void ImplGetButtonRect( Rectangle& rRect, long nEx, sal_Bool bTest ) const;
124 : : SAL_DLLPRIVATE void ImplGetAutoHideRect( Rectangle& rRect, sal_Bool bTest = sal_False ) const;
125 : : SAL_DLLPRIVATE void ImplGetFadeInRect( Rectangle& rRect, sal_Bool bTest = sal_False ) const;
126 : : SAL_DLLPRIVATE void ImplGetFadeOutRect( Rectangle& rRect, sal_Bool bTest = sal_False ) const;
127 : : SAL_DLLPRIVATE void ImplDrawButtonRect( const Rectangle& rRect, long nSize );
128 : : SAL_DLLPRIVATE void ImplDrawAutoHide( sal_Bool bInPaint );
129 : : SAL_DLLPRIVATE void ImplDrawFadeIn( sal_Bool bInPaint );
130 : : SAL_DLLPRIVATE void ImplDrawFadeOut( sal_Bool bInPaint );
131 : : SAL_DLLPRIVATE void ImplNewAlign();
132 : : SAL_DLLPRIVATE void ImplDrawGrip( const Rectangle& rRect, sal_Bool bHorz, sal_Bool bLeft );
133 : : SAL_DLLPRIVATE void ImplDrawFadeArrow( const Point& rPt, sal_Bool bHorz, sal_Bool bLeft );
134 : : SAL_DLLPRIVATE void ImplStartSplit( const MouseEvent& rMEvt );
135 : :
136 : : static SAL_DLLPRIVATE void ImplDrawBorder( SplitWindow* pWin );
137 : : static SAL_DLLPRIVATE void ImplDrawBorderLine( SplitWindow* pWin );
138 : : static SAL_DLLPRIVATE void ImplCalcSet2( SplitWindow* pWindow, ImplSplitSet* pSet, sal_Bool bHide,
139 : : sal_Bool bRows, sal_Bool bDown = sal_True );
140 : : static SAL_DLLPRIVATE void ImplDrawBack( SplitWindow* pWindow, ImplSplitSet* pSet );
141 : : static SAL_DLLPRIVATE void ImplDrawBack( SplitWindow* pWindow, const Rectangle& rRect,
142 : : const Wallpaper* pWall, const Bitmap* pBitmap );
143 : : static SAL_DLLPRIVATE sal_uInt16 ImplTestSplit( ImplSplitSet* pSet, const Point& rPos,
144 : : long& rMouseOff, ImplSplitSet** ppFoundSet, sal_uInt16& rFoundPos,
145 : : sal_Bool bRows, sal_Bool bDown = sal_True );
146 : : static SAL_DLLPRIVATE sal_uInt16 ImplTestSplit( SplitWindow* pWindow, const Point& rPos,
147 : : long& rMouseOff, ImplSplitSet** ppFoundSet, sal_uInt16& rFoundPos );
148 : : static SAL_DLLPRIVATE void ImplDrawSplitTracking( SplitWindow* pThis, const Point& rPos );
149 : :
150 : : // Copy assignment is forbidden and not implemented.
151 : : SAL_DLLPRIVATE SplitWindow (const SplitWindow &);
152 : : SAL_DLLPRIVATE SplitWindow & operator= (const SplitWindow &);
153 : : public:
154 : : SplitWindow( Window* pParent, WinBits nStyle = 0 );
155 : : ~SplitWindow();
156 : :
157 : : virtual void StartSplit();
158 : : virtual void Split();
159 : : virtual void SplitResize();
160 : : virtual void AutoHide();
161 : : virtual void FadeIn();
162 : : virtual void FadeOut();
163 : :
164 : : virtual void MouseButtonDown( const MouseEvent& rMEvt );
165 : : virtual void MouseMove( const MouseEvent& rMEvt );
166 : : virtual void Tracking( const TrackingEvent& rTEvt );
167 : : virtual void Paint( const Rectangle& rRect );
168 : : virtual void Move();
169 : : virtual void Resize();
170 : : virtual void RequestHelp( const HelpEvent& rHEvt );
171 : : virtual void StateChanged( StateChangedType nType );
172 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
173 : : virtual long PreNotify( NotifyEvent& rNEvt );
174 : :
175 : : void InsertItem( sal_uInt16 nId, Window* pWindow, long nSize,
176 : : sal_uInt16 nPos = SPLITWINDOW_APPEND, sal_uInt16 nSetId = 0,
177 : : SplitWindowItemBits nBits = 0 );
178 : : void InsertItem( sal_uInt16 nId, long nSize,
179 : : sal_uInt16 nPos = SPLITWINDOW_APPEND, sal_uInt16 nSetId = 0,
180 : : SplitWindowItemBits nBits = 0 );
181 : : void RemoveItem( sal_uInt16 nId, sal_Bool bHide = sal_True );
182 : : void Clear();
183 : :
184 : : void SplitItem( sal_uInt16 nId, long nNewSize,
185 : : sal_Bool bPropSmall = sal_False,
186 : : sal_Bool bPropGreat = sal_False );
187 : : void SetItemSize( sal_uInt16 nId, long nNewSize );
188 : : long GetItemSize( sal_uInt16 nId ) const;
189 : : /** Set a range that limits the (variable part of the) size with an
190 : : upper and a lower bound (both are valid values themselves.)
191 : : @param nId
192 : : Id of the item for which the size limits are set.
193 : : @param aRange
194 : : Values of -1 define missing bounds, thus setting a range (-1,-1)
195 : : (the default) removes the size limitiation.
196 : : */
197 : : void SetItemSizeRange (sal_uInt16 nId, const Range aRange);
198 : : /** Return the current size limits for the specified item.
199 : : */
200 : : long GetItemSize( sal_uInt16 nId, SplitWindowItemBits nBits ) const;
201 : : sal_uInt16 GetSet( sal_uInt16 nId ) const;
202 : : sal_uInt16 GetItemId( Window* pWindow ) const;
203 : : sal_uInt16 GetItemId( const Point& rPos ) const;
204 : : sal_uInt16 GetItemPos( sal_uInt16 nId, sal_uInt16 nSetId = 0 ) const;
205 : : sal_uInt16 GetItemId( sal_uInt16 nPos, sal_uInt16 nSetId = 0 ) const;
206 : : sal_uInt16 GetItemCount( sal_uInt16 nSetId = 0 ) const;
207 : : sal_Bool IsItemValid( sal_uInt16 nId ) const;
208 : :
209 : : sal_Bool IsNoAlign() const { return mbNoAlign; }
210 : : void SetAlign( WindowAlign eNewAlign = WINDOWALIGN_TOP );
211 : 21452 : WindowAlign GetAlign() const { return meAlign; }
212 : 737 : sal_Bool IsHorizontal() const { return mbHorz; }
213 : :
214 : : sal_Bool IsSplitting() const { return IsTracking(); }
215 : :
216 : 0 : void SetMaxSizePixel( long nNewMaxSize ) { mnMaxSize = nNewMaxSize; }
217 : : long GetMaxSizePixel() const { return mnMaxSize; }
218 : :
219 : : Size CalcLayoutSizePixel( const Size& aNewSize );
220 : :
221 : : void ShowAutoHideButton( sal_Bool bShow = sal_True );
222 : 6844 : sal_Bool IsAutoHideButtonVisible() const { return mbAutoHide; }
223 : : void ShowFadeInHideButton( sal_Bool bShow = sal_True );
224 : : void ShowFadeInButton( sal_Bool bShow = sal_True ) { ShowFadeInHideButton( bShow ); }
225 : : sal_Bool IsFadeInButtonVisible() const { return mbFadeIn; }
226 : : void ShowFadeOutButton( sal_Bool bShow = sal_True );
227 : : sal_Bool IsFadeOutButtonVisible() const { return mbFadeOut; }
228 : : long GetFadeInSize() const;
229 : 0 : sal_Bool IsFadeNoButtonMode() const { return mbFadeNoButtonMode; }
230 : :
231 : : void SetAutoHideState( sal_Bool bAutoHide );
232 : : sal_Bool GetAutoHideState() const { return mbAutoHideIn; }
233 : :
234 : : void SetStartSplitHdl( const Link& rLink ) { maStartSplitHdl = rLink; }
235 : : const Link& GetStartSplitHdl() const { return maStartSplitHdl; }
236 : 0 : void SetSplitHdl( const Link& rLink ) { maSplitHdl = rLink; }
237 : : const Link& GetSplitHdl() const { return maSplitHdl; }
238 : : void SetSplitResizeHdl( const Link& rLink ) { maSplitResizeHdl = rLink; }
239 : : const Link& GetSplitResizeHdl() const { return maSplitResizeHdl; }
240 : : void SetAutoHideHdl( const Link& rLink ) { maAutoHideHdl = rLink; }
241 : : const Link& GetAutoHideHdl() const { return maAutoHideHdl; }
242 : : void SetFadeInHdl( const Link& rLink ) { maFadeInHdl = rLink; }
243 : : const Link& GetFadeInHdl() const { return maFadeInHdl; }
244 : : void SetFadeOutHdl( const Link& rLink ) { maFadeOutHdl = rLink; }
245 : : const Link& GetFadeOutHdl() const { return maFadeOutHdl; }
246 : : };
247 : :
248 : : #endif // _SV_SPLITWIN_HXX
249 : :
250 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|