xref: /AOO41X/main/vcl/inc/vcl/splitwin.hxx (revision 0d63794c5b3715d9f8da2f4b7b451b7426ee7897)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SV_SPLITWIN_HXX
25 #define _SV_SPLITWIN_HXX
26 
27 #include <vcl/sv.h>
28 #include <vcl/dllapi.h>
29 #include <vcl/dockwin.hxx>
30 
31 class Wallpaper;
32 struct ImplSplitSet;
33 
34 // -----------------------
35 // - SplitWindowItemBits -
36 // -----------------------
37 
38 typedef sal_uInt16 SplitWindowItemBits;
39 
40 // -------------------------------
41 // - Bits fuer SplitWindow-Items -
42 // -------------------------------
43 
44 #define SWIB_FIXED                  ((SplitWindowItemBits)0x0001)
45 #define SWIB_RELATIVESIZE           ((SplitWindowItemBits)0x0002)
46 #define SWIB_PERCENTSIZE            ((SplitWindowItemBits)0x0004)
47 #define SWIB_COLSET                 ((SplitWindowItemBits)0x0008)
48 #define SWIB_INVISIBLE              ((SplitWindowItemBits)0x0010)
49 
50 // ---------------------
51 // - SplitWindow-Types -
52 // ---------------------
53 
54 #define SPLITWINDOW_APPEND          ((sal_uInt16)0xFFFF)
55 #define SPLITWINDOW_ITEM_NOTFOUND   ((sal_uInt16)0xFFFF)
56 
57 // ---------------
58 // - SplitWindow -
59 // ---------------
60 
61 class VCL_DLLPUBLIC SplitWindow : public DockingWindow
62 {
63 private:
64     ImplSplitSet*       mpMainSet;
65     ImplSplitSet*       mpBaseSet;
66     ImplSplitSet*       mpSplitSet;
67     long*               mpLastSizes;
68     Rectangle           maDragRect;
69     long                mnDX;
70     long                mnDY;
71     long                mnLeftBorder;
72     long                mnTopBorder;
73     long                mnRightBorder;
74     long                mnBottomBorder;
75     long                mnMaxSize;
76     long                mnMouseOff;
77     long                mnMStartPos;
78     long                mnMSplitPos;
79     WinBits             mnWinStyle;
80     WindowAlign         meAlign;
81     sal_uInt16              mnSplitTest;
82     sal_uInt16              mnSplitPos;
83     sal_uInt16              mnMouseModifier;
84     sal_Bool                mbDragFull:1,
85                         mbHorz:1,
86                         mbBottomRight:1,
87                         mbCalc:1,
88                         mbRecalc:1,
89                         mbInvalidate:1,
90                         mbSizeable:1,
91                         mbBorder:1,
92                         mbAutoHide:1,
93                         mbFadeIn:1,
94                         mbFadeOut:1,
95                         mbAutoHideIn:1,
96                         mbAutoHideDown:1,
97                         mbFadeInDown:1,
98                         mbFadeOutDown:1,
99                         mbAutoHidePressed:1,
100                         mbFadeInPressed:1,
101                         mbFadeOutPressed:1,
102                         mbFadeNoButtonMode:1,
103                         mbNoAlign:1;
104     Link                maStartSplitHdl;
105     Link                maSplitHdl;
106     Link                maSplitResizeHdl;
107     Link                maAutoHideHdl;
108     Link                maFadeInHdl;
109     Link                maFadeOutHdl;
110 
111     using Window::ImplInit;
112     SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
113     SAL_DLLPRIVATE void ImplInitSettings();
114     SAL_DLLPRIVATE void ImplCalcLayout();
115     SAL_DLLPRIVATE void ImplUpdate();
116     SAL_DLLPRIVATE void ImplUpdateSet( ImplSplitSet* pSet );
117     SAL_DLLPRIVATE void ImplSetWindowSize( long nDelta );
118     SAL_DLLPRIVATE void ImplSplitMousePos( Point& rMousePos );
119     SAL_DLLPRIVATE void ImplGetButtonRect( Rectangle& rRect, long nEx, sal_Bool bTest ) const;
120     SAL_DLLPRIVATE void ImplGetAutoHideRect( Rectangle& rRect, sal_Bool bTest = sal_False ) const;
121     SAL_DLLPRIVATE void ImplGetFadeInRect( Rectangle& rRect, sal_Bool bTest = sal_False ) const;
122     SAL_DLLPRIVATE void ImplGetFadeOutRect( Rectangle& rRect, sal_Bool bTest = sal_False ) const;
123     SAL_DLLPRIVATE void ImplDrawButtonRect( const Rectangle& rRect, long nSize );
124     SAL_DLLPRIVATE void ImplDrawAutoHide( sal_Bool bInPaint );
125     SAL_DLLPRIVATE void ImplDrawFadeIn( sal_Bool bInPaint );
126     SAL_DLLPRIVATE void ImplDrawFadeOut( sal_Bool bInPaint );
127     SAL_DLLPRIVATE void ImplNewAlign();
128     SAL_DLLPRIVATE void ImplDrawGrip( const Rectangle& rRect, sal_Bool bHorz, sal_Bool bLeft );
129     SAL_DLLPRIVATE void ImplDrawFadeArrow( const Point& rPt, sal_Bool bHorz, sal_Bool bLeft );
130     SAL_DLLPRIVATE void ImplStartSplit( const MouseEvent& rMEvt );
131 
132     static SAL_DLLPRIVATE void ImplDrawBorder( SplitWindow* pWin );
133     static SAL_DLLPRIVATE void ImplDrawBorderLine( SplitWindow* pWin );
134     static SAL_DLLPRIVATE void ImplCalcSet2( SplitWindow* pWindow, ImplSplitSet* pSet, sal_Bool bHide,
135                                              sal_Bool bRows, sal_Bool bDown = sal_True );
136     static SAL_DLLPRIVATE void ImplDrawBack( SplitWindow* pWindow, ImplSplitSet* pSet );
137     static SAL_DLLPRIVATE void ImplDrawBack( SplitWindow* pWindow, const Rectangle& rRect,
138                                              const Wallpaper* pWall, const Bitmap* pBitmap );
139     static SAL_DLLPRIVATE sal_uInt16 ImplTestSplit( ImplSplitSet* pSet, const Point& rPos,
140                                                 long& rMouseOff, ImplSplitSet** ppFoundSet, sal_uInt16& rFoundPos,
141                                                 sal_Bool bRows, sal_Bool bDown = sal_True );
142     static SAL_DLLPRIVATE sal_uInt16 ImplTestSplit( SplitWindow* pWindow, const Point& rPos,
143                                                 long& rMouseOff, ImplSplitSet** ppFoundSet, sal_uInt16& rFoundPos );
144     static SAL_DLLPRIVATE void ImplDrawSplitTracking( SplitWindow* pThis, const Point& rPos );
145 
146     // Copy assignment is forbidden and not implemented.
147     SAL_DLLPRIVATE      SplitWindow (const SplitWindow &);
148     SAL_DLLPRIVATE      SplitWindow & operator= (const SplitWindow &);
149 public:
150                         SplitWindow( Window* pParent, WinBits nStyle = 0 );
151                         SplitWindow( Window* pParent, const ResId& rResId );
152                         ~SplitWindow();
153 
154     virtual void        StartSplit();
155     virtual void        Split();
156     virtual void        SplitResize();
157     virtual void        AutoHide();
158     virtual void        FadeIn();
159     virtual void        FadeOut();
160 
161     virtual void        MouseButtonDown( const MouseEvent& rMEvt );
162     virtual void        MouseMove( const MouseEvent& rMEvt );
163     virtual void        Tracking( const TrackingEvent& rTEvt );
164     virtual void        Paint( const Rectangle& rRect );
165     virtual void        Move();
166     virtual void        Resize();
167     virtual void        RequestHelp( const HelpEvent& rHEvt );
168     virtual void        StateChanged( StateChangedType nType );
169     virtual void        DataChanged( const DataChangedEvent& rDCEvt );
170     virtual long        PreNotify( NotifyEvent& rNEvt );
171 
172     void                InsertItem( sal_uInt16 nId, Window* pWindow, long nSize,
173                                     sal_uInt16 nPos = SPLITWINDOW_APPEND, sal_uInt16 nSetId = 0,
174                                     SplitWindowItemBits nBits = 0 );
175     void                InsertItem( sal_uInt16 nId, long nSize,
176                                     sal_uInt16 nPos = SPLITWINDOW_APPEND, sal_uInt16 nSetId = 0,
177                                     SplitWindowItemBits nBits = 0 );
178     void                MoveItem( sal_uInt16 nId, sal_uInt16 nNewPos, sal_uInt16 nNewSetId = 0 );
179     void                RemoveItem( sal_uInt16 nId, sal_Bool bHide = sal_True );
180     void                Clear();
181 
182     void                SetBaseSet( sal_uInt16 nSetId = 0 );
183     sal_uInt16              GetBaseSet() const;
184 
185     void                SetSplitSize( sal_uInt16 nSetId, long nSplitSize,
186                                       sal_Bool bWithChilds = sal_False );
187     long                GetSplitSize( sal_uInt16 nSetId ) const;
188     void                SetItemBackground( sal_uInt16 nSetId );
189     void                SetItemBackground( sal_uInt16 nSetId, const Wallpaper& rWallpaper );
190     Wallpaper           GetItemBackground( sal_uInt16 nSetId ) const;
191     sal_Bool                IsItemBackground( sal_uInt16 nSetId ) const;
192     void                SetItemBitmap( sal_uInt16 nSetId, const Bitmap& rBitmap );
193     Bitmap              GetItemBitmap( sal_uInt16 nSetId ) const;
194 
195     void                SplitItem( sal_uInt16 nId, long nNewSize,
196                                    sal_Bool bPropSmall = sal_False,
197                                    sal_Bool bPropGreat = sal_False );
198     void                SetItemSize( sal_uInt16 nId, long nNewSize );
199     long                GetItemSize( sal_uInt16 nId ) const;
200     /** Set a range that limits the (variable part of the) size with an
201         upper and a lower bound (both are valid values themselves.)
202         @param nId
203             Id of the item for which the size limits are set.
204         @param aRange
205             Values of -1 define missing bounds, thus setting a range (-1,-1)
206             (the default) removes the size limitiation.
207     */
208     void                SetItemSizeRange (sal_uInt16 nId, const Range aRange);
209     /** Return the current size limits for the specified item.
210     */
211     Range               GetItemSizeRange (sal_uInt16 nId) const;
212     long                GetItemSize( sal_uInt16 nId, SplitWindowItemBits nBits ) const;
213     void                SetItemBits( sal_uInt16 nId, SplitWindowItemBits nNewBits );
214     SplitWindowItemBits GetItemBits( sal_uInt16 nId ) const;
215     Window*             GetItemWindow( sal_uInt16 nId ) const;
216     sal_uInt16              GetSet( sal_uInt16 nId ) const;
217     sal_Bool                GetSet( sal_uInt16 nId, sal_uInt16& rSetId, sal_uInt16& rPos ) const;
218     sal_uInt16              GetItemId( Window* pWindow ) const;
219     sal_uInt16              GetItemId( const Point& rPos ) const;
220     sal_uInt16              GetItemPos( sal_uInt16 nId, sal_uInt16 nSetId = 0 ) const;
221     sal_uInt16              GetItemId( sal_uInt16 nPos, sal_uInt16 nSetId = 0 ) const;
222     sal_uInt16              GetItemCount( sal_uInt16 nSetId = 0 ) const;
223     sal_Bool                IsItemValid( sal_uInt16 nId ) const;
224 
225     void                SetNoAlign( sal_Bool bNoAlign );
IsNoAlign() const226     sal_Bool                IsNoAlign() const { return mbNoAlign; }
227     void                SetAlign( WindowAlign eNewAlign = WINDOWALIGN_TOP );
GetAlign() const228     WindowAlign         GetAlign() const { return meAlign; }
IsHorizontal() const229     sal_Bool                IsHorizontal() const { return mbHorz; }
230 
IsSplitting() const231     sal_Bool                IsSplitting() const { return IsTracking(); }
232 
SetMaxSizePixel(long nNewMaxSize)233     void                SetMaxSizePixel( long nNewMaxSize ) { mnMaxSize = nNewMaxSize; }
GetMaxSizePixel() const234     long                GetMaxSizePixel() const { return mnMaxSize; }
235 
236     static Size         CalcWindowSizePixel( const Size& rSize,
237                                              WindowAlign eAlign,
238                                              WinBits nWinStyle,
239                                              sal_Bool bExtra = sal_False );
CalcWindowSizePixel(const Size & rSize)240     Size                CalcWindowSizePixel( const Size& rSize )
241                             { return CalcWindowSizePixel( rSize, meAlign, mnWinStyle, (mbAutoHide || mbFadeOut) ); }
242 
243     Size                CalcLayoutSizePixel( const Size& aNewSize );
244 
245     void                ShowAutoHideButton( sal_Bool bShow = sal_True );
IsAutoHideButtonVisible() const246     sal_Bool                IsAutoHideButtonVisible() const { return mbAutoHide; }
247     void                ShowFadeInHideButton( sal_Bool bShow = sal_True );
ShowFadeInButton(sal_Bool bShow=sal_True)248     void                ShowFadeInButton( sal_Bool bShow = sal_True ) { ShowFadeInHideButton( bShow ); }
IsFadeInButtonVisible() const249     sal_Bool                IsFadeInButtonVisible() const { return mbFadeIn; }
250     void                ShowFadeOutButton( sal_Bool bShow = sal_True );
IsFadeOutButtonVisible() const251     sal_Bool                IsFadeOutButtonVisible() const { return mbFadeOut; }
252     long                GetFadeInSize() const;
IsFadeNoButtonMode() const253     sal_Bool                IsFadeNoButtonMode() const { return mbFadeNoButtonMode; }
254 
255     void                SetAutoHideState( sal_Bool bAutoHide );
GetAutoHideState() const256     sal_Bool                GetAutoHideState() const { return mbAutoHideIn; }
257 
258     Rectangle           GetAutoHideRect() const;
259     Rectangle           GetFadeInRect() const;
260     Rectangle           GetFadeOutRect() const;
261 
SetStartSplitHdl(const Link & rLink)262     void                SetStartSplitHdl( const Link& rLink ) { maStartSplitHdl = rLink; }
GetStartSplitHdl() const263     const Link&         GetStartSplitHdl() const { return maStartSplitHdl; }
SetSplitHdl(const Link & rLink)264     void                SetSplitHdl( const Link& rLink ) { maSplitHdl = rLink; }
GetSplitHdl() const265     const Link&         GetSplitHdl() const { return maSplitHdl; }
SetSplitResizeHdl(const Link & rLink)266     void                SetSplitResizeHdl( const Link& rLink ) { maSplitResizeHdl = rLink; }
GetSplitResizeHdl() const267     const Link&         GetSplitResizeHdl() const { return maSplitResizeHdl; }
SetAutoHideHdl(const Link & rLink)268     void                SetAutoHideHdl( const Link& rLink ) { maAutoHideHdl = rLink; }
GetAutoHideHdl() const269     const Link&         GetAutoHideHdl() const { return maAutoHideHdl; }
SetFadeInHdl(const Link & rLink)270     void                SetFadeInHdl( const Link& rLink ) { maFadeInHdl = rLink; }
GetFadeInHdl() const271     const Link&         GetFadeInHdl() const { return maFadeInHdl; }
SetFadeOutHdl(const Link & rLink)272     void                SetFadeOutHdl( const Link& rLink ) { maFadeOutHdl = rLink; }
GetFadeOutHdl() const273     const Link&         GetFadeOutHdl() const { return maFadeOutHdl; }
274 };
275 
276 #endif  // _SV_SPLITWIN_HXX
277