merge the formfield patch from ooo-build
[ooovba.git] / sw / source / core / inc / scrrect.hxx
blob4031c1e9673828bba16a014162ba8ccdc45c0f87
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: scrrect.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SCRRECT_HXX
31 #define _SCRRECT_HXX
33 #include <svtools/svarray.hxx>
34 #include "swrect.hxx"
35 #include <swtypes.hxx>
37 class SwStripe
39 SwTwips nY;
40 SwTwips nHeight;
41 public:
42 inline SwStripe( SwTwips nPos, SwTwips nHght )
43 : nY( nPos ), nHeight( nHght ) {}
44 inline SwTwips GetY() const { return nY; }
45 inline SwTwips& Y() { return nY; }
46 inline SwTwips GetHeight() const { return nHeight; }
47 inline SwTwips& Height() { return nHeight; }
48 inline SwTwips GetBottom() const { return nHeight ? nY + nHeight - 1 : nY; }
49 inline BOOL operator<( const SwStripe &rTst ) const
50 { return nY < rTst.nY || ( nY == rTst.nY && nHeight > rTst.nHeight ); }
51 inline BOOL operator==( const SwStripe& rTst ) const
52 { return nY == rTst.nY && nHeight == rTst.nHeight; }
55 SV_DECL_VARARR( SwStripeArr, SwStripe, 1, 4 )
57 class SwStripes : public SwStripeArr, public SwStripe
59 SwTwips nMin; // Left minimum
60 SwTwips nMax; // Right maximum
61 public:
62 SwStripes( SwTwips nPos, SwTwips nSize, SwTwips nMn, SwTwips nMx )
63 : SwStripe( nPos, nSize ), nMin( nMn ), nMax( nMx ) {}
64 SwStripes& Plus( const SwStripes& rOther, BOOL bVert );
65 BOOL Recalc( BOOL bVert );
67 inline SwTwips GetMin() const { return nMin; }
68 inline SwTwips GetMax() const { return nMax; }
69 inline void SetMin( const SwTwips nNew ) { nMin = nNew; }
70 inline void SetMax( const SwTwips nNew ) { nMax = nNew; }
71 inline void ChkMin( const SwTwips nNew ) { if( nNew < nMin ) nMin = nNew; }
72 inline void ChkMax( const SwTwips nNew ) { if( nNew > nMax ) nMax = nNew; }
73 inline SwTwips GetRight() const { return nMax > nMin ? nMax - 1 : nMax; }
74 inline SwTwips GetWidth() const { return nMax - nMin; }
77 class SwScrollColumn
79 SwTwips nX;
80 SwTwips nWidth;
81 SwTwips nOffs;
82 BOOL bVertical;
83 public:
84 inline SwScrollColumn( SwTwips nPos, SwTwips nSz, SwTwips nOff, BOOL bVert )
85 : nX( nPos ), nWidth( nSz ), nOffs( nOff ), bVertical( bVert ) {}
86 inline SwScrollColumn( const SwScrollColumn& rCol )
87 : nX( rCol.nX ), nWidth( rCol.nWidth ),
88 nOffs( rCol.nOffs ), bVertical( rCol.bVertical ) {}
89 BOOL IsVertical() const { return bVertical; }
90 inline BOOL operator<( const SwScrollColumn &rTst ) const
91 { return bVertical < rTst.bVertical || ( bVertical == rTst.bVertical &&
92 ( nX < rTst.nX || ( nX == rTst.nX && ( nWidth < rTst.nWidth ||
93 ( nWidth == rTst.nWidth && nOffs < rTst.nOffs ) ) ) ) ); }
94 inline BOOL operator==( const SwScrollColumn &rTst ) const
95 { return bVertical == rTst.bVertical && nX == rTst.nX &&
96 nWidth == rTst.nWidth && nOffs == rTst.nOffs;}
97 inline SwTwips GetX() const { return nX; }
98 inline SwTwips GetWidth() const { return nWidth; }
99 inline SwTwips GetOffs() const { return nOffs; }
100 inline void ClrOffs() { nOffs = 0; }
101 inline SwTwips GetRight() const { return nWidth ? nX + nWidth - 1 : nX; }
104 typedef SwStripes* SwStripesPtr;
105 SV_DECL_PTRARR_SORT(SwScrollStripes, SwStripesPtr, 1, 4)
107 class SwScrollArea : public SwScrollColumn, public SwScrollStripes
109 public:
110 void SmartInsert( SwStripes* pStripes );
111 void Add( SwScrollArea *pScroll );
112 inline SwScrollArea( const SwScrollColumn &rCol, SwStripes* pStripes )
113 : SwScrollColumn( rCol )
114 { Insert( pStripes ); }
115 BOOL Compress();
118 typedef SwScrollArea* SwScrollAreaPtr;
119 SV_DECL_PTRARR_SORT(SScrAreas,SwScrollAreaPtr,1,2)
121 class SwScrollAreas : public SScrAreas
123 public:
124 void InsertCol( const SwScrollColumn &rCol, SwStripes *pStripes );
128 #endif //_SCRRECT_HXX