|
1 /* |
|
2 * Copyright (c) 2003 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: SVG Implementation source file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "SVGRadialGradientElementImpl.h" |
|
20 #include "SVGDocumentImpl.h" |
|
21 #include "SVGSchemaData.h" |
|
22 #include "SvgStopElementImpl.h" |
|
23 #include "SVGIntCssValueImpl.h" |
|
24 |
|
25 #include "GfxAffineTransform.h" |
|
26 |
|
27 _LIT(FX, "fx"); |
|
28 _LIT(FY, "fy"); |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 // --------------------------------------------------------------------------- |
|
33 CSvgRadialGradientElementImpl* CSvgRadialGradientElementImpl::NewL(const TUint8 aElemID, |
|
34 CSvgDocumentImpl* aDoc ) |
|
35 { |
|
36 CSvgRadialGradientElementImpl *self = new (ELeave) CSvgRadialGradientElementImpl(aDoc); |
|
37 CleanupStack::PushL(self); |
|
38 self->ConstructL(aElemID); |
|
39 CleanupStack::Pop(self); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 // --------------------------------------------------------------------------- |
|
46 void CSvgRadialGradientElementImpl::ConstructL(const TUint8 aElemID) |
|
47 { |
|
48 CSvgGradientElementImpl::ConstructL( aElemID ); |
|
49 |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 // --------------------------------------------------------------------------- |
|
55 CSvgRadialGradientElementImpl::CSvgRadialGradientElementImpl( CSvgDocumentImpl* aDoc ): |
|
56 CSvgGradientElementImpl(aDoc) |
|
57 { |
|
58 iGradientPaint = &iGfxRadialPaint; |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 // --------------------------------------------------------------------------- |
|
64 TInt CSvgRadialGradientElementImpl::SetAttributeL(const TDesC &aName, const TDesC &aValue) |
|
65 { |
|
66 CSvgGradientElementImpl::SetAttributeL( aName, aValue ); |
|
67 |
|
68 if(aName == FX) |
|
69 { |
|
70 iGfxRadialPaint.iFx=TFloatFixPt::ConvertString(aValue); |
|
71 |
|
72 return KErrNone; |
|
73 } |
|
74 else if(aName == FY) |
|
75 { |
|
76 iGfxRadialPaint.iFy=TFloatFixPt::ConvertString(aValue); |
|
77 |
|
78 return KErrNone; |
|
79 } |
|
80 |
|
81 return KErrNone; |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 // --------------------------------------------------------------------------- |
|
87 MGfxPaint *CSvgRadialGradientElementImpl::PaintAttribute() |
|
88 { |
|
89 TInt i=0; |
|
90 |
|
91 TFloatFixPt lOffset; |
|
92 TUint32 lStopColor; |
|
93 TFloatFixPt lStopOpacity; |
|
94 |
|
95 if( iStopElementData ) |
|
96 { |
|
97 iStopElementData->Reset(); |
|
98 } |
|
99 |
|
100 TInt svgStopEleArrayCnt = iSvgStopElementArray->Count(); |
|
101 for(i=0;i<svgStopEleArrayCnt;i++) |
|
102 { |
|
103 CSvgStopElementImpl* temp = (*iSvgStopElementArray)[i]; |
|
104 |
|
105 // Check if the element has valid offset value. If the offset had invalid value |
|
106 // it will be made zero but this function will return FALSE. |
|
107 if( temp->IsValidElement() ) |
|
108 { |
|
109 temp->GetOffset(lOffset); |
|
110 temp->GetStopColor(lStopColor); |
|
111 temp->GetStopOpacity (lStopOpacity); |
|
112 TSvgStopData la ; |
|
113 la.iOffset = lOffset; |
|
114 la.iStopColor = lStopColor; |
|
115 la.iStopOpacity = lStopOpacity; |
|
116 TInt error = iStopElementData->Append(la); |
|
117 if(error != KErrNone) |
|
118 { |
|
119 break; |
|
120 } |
|
121 } |
|
122 } |
|
123 iGfxRadialPaint.iStopData = iStopElementData; |
|
124 |
|
125 const TGfxAffineTransform& tempTransform = GetCTM(); |
|
126 iGradientPaint->iGradientTransform.matrix[0][0] = tempTransform.iM00.iValue; |
|
127 iGradientPaint->iGradientTransform.matrix[0][1] = tempTransform.iM01.iValue; |
|
128 iGradientPaint->iGradientTransform.matrix[0][2] = tempTransform.iM02.iValue; |
|
129 iGradientPaint->iGradientTransform.matrix[1][0] = tempTransform.iM10.iValue; |
|
130 iGradientPaint->iGradientTransform.matrix[1][1] = tempTransform.iM11.iValue; |
|
131 iGradientPaint->iGradientTransform.matrix[1][2] = tempTransform.iM12.iValue; |
|
132 |
|
133 |
|
134 return &iGfxRadialPaint; |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 // --------------------------------------------------------------------------- |
|
140 TInt CSvgRadialGradientElementImpl::GetAttributeFloat( const TInt aNameId, TFloatFixPt& aValue ) |
|
141 { |
|
142 switch ( aNameId ) |
|
143 { |
|
144 case KAtrCx: |
|
145 aValue = iGfxRadialPaint.iCx ; |
|
146 break; |
|
147 case KAtrCy: |
|
148 aValue = iGfxRadialPaint.iCy ; |
|
149 break; |
|
150 case KAtrR : |
|
151 aValue = iGfxRadialPaint.iR ; |
|
152 break; |
|
153 case KAtrFx: |
|
154 aValue = iGfxRadialPaint.iFx; |
|
155 break; |
|
156 case KAtrFy: |
|
157 aValue = iGfxRadialPaint.iFy; |
|
158 break; |
|
159 default: |
|
160 return CSvgElementImpl::GetAttributeFloat( aNameId, aValue ); |
|
161 } |
|
162 |
|
163 return 0; |
|
164 } |
|
165 |
|
166 // --------------------------------------------------------------------------- |
|
167 // |
|
168 // --------------------------------------------------------------------------- |
|
169 TInt CSvgRadialGradientElementImpl::SetAttributeFloatL( const TInt aNameId, const TFloatFixPt aValue ) |
|
170 { |
|
171 switch ( aNameId ) |
|
172 { |
|
173 case KAtrCx: |
|
174 iGfxRadialPaint.iCx = aValue; |
|
175 break; |
|
176 case KAtrCy: |
|
177 iGfxRadialPaint.iCy = aValue; |
|
178 break; |
|
179 case KAtrR : |
|
180 iGfxRadialPaint.iR = aValue; |
|
181 break; |
|
182 case KAtrFx: |
|
183 iGfxRadialPaint.iFx= aValue; |
|
184 break; |
|
185 case KAtrFy: |
|
186 iGfxRadialPaint.iFy = aValue; |
|
187 break; |
|
188 |
|
189 default: |
|
190 return CSvgElementImpl::SetAttributeFloatL( aNameId, aValue ); |
|
191 } |
|
192 return 0; |
|
193 } |
|
194 |
|
195 // --------------------------------------------------------------------------- |
|
196 // |
|
197 // --------------------------------------------------------------------------- |
|
198 CSvgRadialGradientElementImpl::~CSvgRadialGradientElementImpl() |
|
199 { |
|
200 |
|
201 } |
|
202 |
|
203 // --------------------------------------------------------------------------- |
|
204 // |
|
205 // --------------------------------------------------------------------------- |
|
206 void CSvgRadialGradientElementImpl::Print( TBool aIsEncodeOn ) |
|
207 { |
|
208 if (!aIsEncodeOn) |
|
209 { |
|
210 #ifdef _DEBUG |
|
211 RDebug::Printf("<radialGradient gradientUnits=\"hmm\" gradientTransform=\"hmm\" cx=\"%d\" cy=\"%d\" r=\"%d\" fx=\"%d\" fy=\"%d\" spreadMethod=\"hmm\" xlink:href=\"hmm\"/>", |
|
212 (int)iGfxRadialPaint.iCx, (int)iGfxRadialPaint.iCy, (int)iGfxRadialPaint.iR, (int)iGfxRadialPaint.iFx, (int)iGfxRadialPaint.iFy/*, Href()*/); |
|
213 #endif |
|
214 } |
|
215 } |