Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / inc / regband.hxx
blob690888291598d400a8f0cc08ed359b65c16f3f98
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_INC_REGBAND_HXX
21 #define INCLUDED_VCL_INC_REGBAND_HXX
23 #include <tools/poly.hxx>
27 class ImplRegionBand
29 This class handles one y-band of the region. In this band may contain one
30 or more seprarations in x-direction. The y-Band do not contain any
31 separation after creation.
33 The separations are modified with basic clipping functions like Union and
34 Intersection - the Class will process the clipping for the actual band.
38 // element for the list with x-separations
39 struct ImplRegionBandSep
41 ImplRegionBandSep* mpNextSep;
42 long mnXLeft;
43 long mnXRight;
44 bool mbRemoved;
47 enum LineType { LINE_ASCENDING, LINE_DESCENDING, LINE_HORIZONTAL };
49 // element for the list with x-separations
50 struct ImplRegionBandPoint
52 ImplRegionBandPoint* mpNextBandPoint;
53 long mnX;
54 long mnLineId;
55 bool mbEndPoint;
56 LineType meLineType;
59 class ImplRegionBand
61 public:
62 ImplRegionBand* mpNextBand; // pointer to the next element of the list
63 ImplRegionBand* mpPrevBand; // pointer to the previous element of the list (only used temporarily)
64 ImplRegionBandSep* mpFirstSep; // root of the list with x-separations
65 ImplRegionBandPoint* mpFirstBandPoint; // root of the list with lines
66 long mnYTop; // actual boundary of the band
67 long mnYBottom;
69 // bitfield
70 bool mbTouched : 1;
72 // create y-band with boundaries
73 ImplRegionBand( long nYTop, long nYBottom );
74 /** copy y-band with all data
75 @param theSourceBand
76 The new ImplRegionBand object will
77 be a copy of this band.
78 @param bIgnorePoints
79 When true (the default) the
80 band points pointed to by
81 mpFirstBandPoint are not copied.
82 When false they are copied.
83 You need the points when you are
84 planning to call ProcessPoints()
85 later on.
87 ImplRegionBand( const ImplRegionBand & theSourceBand,
88 const bool bIgnorePoints = true);
89 ~ImplRegionBand();
91 long GetXLeftBoundary() const;
92 long GetXRightBoundary() const;
94 // combine overlapping bands
95 bool OptimizeBand();
97 // generate separations from lines and process
98 // union with existing separations
99 void ProcessPoints();
100 // insert point in the list for later processing
101 bool InsertPoint( long nX, long nLineID,
102 bool bEndPoint, LineType eLineType );
104 void Union( long nXLeft, long nXRight );
105 void Intersect( long nXLeft, long nXRight );
106 void Exclude( long nXLeft, long nXRight );
107 void XOr( long nXLeft, long nXRight );
109 void MoveX( long nHorzMove );
110 void ScaleX( double fHorzScale );
112 bool IsInside( long nX );
114 bool IsEmpty() const { return ((!mpFirstSep) && (!mpFirstBandPoint)); }
116 bool operator==( const ImplRegionBand& rRegionBand ) const;
118 /** Split the called band at the given vertical coordinate. After the
119 split the called band will cover the upper part not including nY.
120 The new band will cover the lower part including nY.
121 @param nY
122 The band is split at this y coordinate. The new, lower band
123 will include this very value.
124 @return
125 Returns the new, lower band.
127 ImplRegionBand* SplitBand (const sal_Int32 nY);
130 #endif // INCLUDED_VCL_INC_REGBAND_HXX
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */