|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Graphics Extension Library source file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "GfxRoundRectangleIteratorP.h" |
|
20 #include "GfxRoundRectangle2D.h" |
|
21 |
|
22 |
|
23 // --------------------------------------------------------------------------- |
|
24 // Constructor |
|
25 // --------------------------------------------------------------------------- |
|
26 // -------------------------------------------------------------------------- |
|
27 // CGfxRoundRectangleIteratorP::CGfxRoundRectangleIteratorP( TGfxRoundRectangle2D* aRoundRect, |
|
28 // --------------------------------------------------------------------------- |
|
29 CGfxRoundRectangleIteratorP::CGfxRoundRectangleIteratorP( TGfxRoundRectangle2D* aRoundRect, |
|
30 TGfxAffineTransform* aAffine ) |
|
31 : iRoundRect( aRoundRect ) |
|
32 { |
|
33 iTransform = aAffine; |
|
34 |
|
35 |
|
36 |
|
37 TFloatFixPt invalid( -1 ); |
|
38 TFloatFixPt KZero; |
|
39 |
|
40 iRx = aRoundRect->iArcWidth; |
|
41 iRy = aRoundRect->iArcHeight; |
|
42 |
|
43 if ( ( ( iRx == invalid ) && ( iRy == invalid ) ) || |
|
44 ( iRx < invalid ) || ( iRy < invalid ) ) |
|
45 { |
|
46 iRx = KZero; |
|
47 iRy = KZero; |
|
48 } |
|
49 else if ( iRx == invalid ) |
|
50 { |
|
51 iRx = iRy; |
|
52 } |
|
53 else if ( iRy == invalid ) |
|
54 { |
|
55 iRy = iRx; |
|
56 } |
|
57 |
|
58 if ( aRoundRect->iWidth < KZero ) |
|
59 aRoundRect->iWidth = KZero; |
|
60 |
|
61 if ( aRoundRect->iHeight < KZero ) |
|
62 aRoundRect->iHeight = KZero; |
|
63 |
|
64 #ifdef SVG_FLOAT_BUILD |
|
65 TFloatFixPt hw = aRoundRect->iWidth * TFloatFixPt(.5f); |
|
66 TFloatFixPt hh = aRoundRect->iHeight * TFloatFixPt(.5f); |
|
67 #else |
|
68 TFloatFixPt hw = aRoundRect->iWidth >> 1; |
|
69 TFloatFixPt hh = aRoundRect->iHeight >> 1; |
|
70 #endif |
|
71 if ( iRx > hw ) |
|
72 iRx = hw; |
|
73 if ( iRy > hh ) |
|
74 iRy = hh; |
|
75 |
|
76 aRoundRect->iArcWidth = iRx; |
|
77 aRoundRect->iArcHeight = iRy; |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // Destructor |
|
82 // --------------------------------------------------------------------------- |
|
83 // -------------------------------------------------------------------------- |
|
84 // CGfxRoundRectangleIteratorP::~CGfxRoundRectangleIteratorP() |
|
85 // --------------------------------------------------------------------------- |
|
86 CGfxRoundRectangleIteratorP::~CGfxRoundRectangleIteratorP() |
|
87 { |
|
88 } |
|
89 |
|
90 // -------------------------------------------------------------------------- |
|
91 // TGfxSegType CGfxRoundRectangleIteratorP::CurrentSegment( TFloatFixPt* aCoords ) |
|
92 // --------------------------------------------------------------------------- |
|
93 TGfxSegType CGfxRoundRectangleIteratorP::CurrentSegment( TFloatFixPt* aCoords ) |
|
94 { |
|
95 TGfxSegType segtype; |
|
96 TInt32 pts = 1; |
|
97 |
|
98 switch ( iIdx ) |
|
99 { |
|
100 case 0: |
|
101 aCoords[0] = iRoundRect->iX + iRx; |
|
102 aCoords[1] = iRoundRect->iY; |
|
103 segtype = EGfxSegMoveTo; |
|
104 break; |
|
105 case 1: |
|
106 aCoords[0] = iRoundRect->iX + iRoundRect->iWidth - iRx; |
|
107 aCoords[1] = iRoundRect->iY ; |
|
108 segtype = EGfxSegLineTo; |
|
109 break; |
|
110 case 2: |
|
111 aCoords[0] = iRoundRect->iX + iRoundRect->iWidth; |
|
112 aCoords[1] = iRoundRect->iY ; |
|
113 aCoords[2] = iRoundRect->iX + iRoundRect->iWidth; |
|
114 aCoords[3] = iRoundRect->iY + iRy; |
|
115 segtype = EGfxSegQuadTo; |
|
116 pts = 2; |
|
117 break; |
|
118 case 3: |
|
119 aCoords[0] = iRoundRect->iX + iRoundRect->iWidth; |
|
120 aCoords[1] = iRoundRect->iY + iRoundRect->iHeight - iRy; |
|
121 segtype = EGfxSegLineTo; |
|
122 break; |
|
123 case 4: |
|
124 aCoords[0] = iRoundRect->iX + iRoundRect->iWidth; |
|
125 aCoords[1] = iRoundRect->iY + iRoundRect->iHeight; |
|
126 aCoords[2] = iRoundRect->iX + iRoundRect->iWidth - iRx; |
|
127 aCoords[3] = iRoundRect->iY + iRoundRect->iHeight; |
|
128 segtype = EGfxSegQuadTo; |
|
129 pts = 2; |
|
130 break; |
|
131 case 5: |
|
132 aCoords[0] = iRoundRect->iX + iRx; |
|
133 aCoords[1] = iRoundRect->iY + iRoundRect->iHeight; |
|
134 segtype = EGfxSegLineTo; |
|
135 break; |
|
136 case 6: |
|
137 aCoords[0] = iRoundRect->iX; |
|
138 aCoords[1] = iRoundRect->iY + iRoundRect->iHeight; |
|
139 aCoords[2] = iRoundRect->iX; |
|
140 aCoords[3] = iRoundRect->iY + iRoundRect->iHeight - iRy; |
|
141 segtype = EGfxSegQuadTo; |
|
142 pts = 2; |
|
143 break; |
|
144 case 7: |
|
145 aCoords[0] = iRoundRect->iX; |
|
146 aCoords[1] = iRoundRect->iY + iRy; |
|
147 segtype = EGfxSegLineTo; |
|
148 break; |
|
149 case 8: |
|
150 aCoords[0] = iRoundRect->iX; |
|
151 aCoords[1] = iRoundRect->iY; |
|
152 aCoords[2] = iRoundRect->iX + iRx; |
|
153 aCoords[3] = iRoundRect->iY; |
|
154 segtype = EGfxSegQuadTo; |
|
155 pts = 2; |
|
156 break; |
|
157 default: |
|
158 segtype = EGfxSegClose; |
|
159 pts = 0; |
|
160 } |
|
161 |
|
162 if ( !iTransform->IsIdentity() && pts > 0 ) |
|
163 { |
|
164 iTransform->Transform( aCoords, aCoords, pts ); |
|
165 } |
|
166 |
|
167 return segtype; |
|
168 } |
|
169 |
|
170 // -------------------------------------------------------------------------- |
|
171 // TBool CGfxRoundRectangleIteratorP::IsDone() |
|
172 // --------------------------------------------------------------------------- |
|
173 TBool CGfxRoundRectangleIteratorP::IsDone() |
|
174 { |
|
175 return ( iIdx > 9 ); |
|
176 } |
|
177 |
|
178 // -------------------------------------------------------------------------- |
|
179 // void CGfxRoundRectangleIteratorP::Next() |
|
180 // --------------------------------------------------------------------------- |
|
181 void CGfxRoundRectangleIteratorP::NextL() |
|
182 { |
|
183 iIdx++; |
|
184 } |
|
185 |