64
|
1 |
/*
|
|
2 |
* Copyright (c) 2006 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: Base class for brushes
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#include "alf/alfbrush.h"
|
|
21 |
#include "alf/alfgencomponent.h"
|
|
22 |
#include "alf/alfconstants.h"
|
|
23 |
#include "alf/alfbrusharray.h"
|
|
24 |
#include "alflogger.h"
|
|
25 |
|
|
26 |
#include <uiacceltk/HuiUtil.h>
|
|
27 |
|
|
28 |
// Private data structure
|
|
29 |
struct CAlfBrush::TPrivateData
|
|
30 |
{
|
|
31 |
CAlfGenComponent* iComms; // owned
|
|
32 |
TAlfTimedValue iOpacity;
|
|
33 |
TBool iClipToVisual;
|
|
34 |
|
|
35 |
// Array keeps track of all the brush arrays in which this brush instance
|
|
36 |
// has been added on. Duplicates are allowed.
|
|
37 |
RPointerArray<CAlfBrushArray> iContainingBrushArrays;
|
|
38 |
};
|
|
39 |
|
|
40 |
// ======== MEMBER FUNCTIONS ========
|
|
41 |
|
|
42 |
// ---------------------------------------------------------------------------
|
|
43 |
// Constructor
|
|
44 |
// ---------------------------------------------------------------------------
|
|
45 |
//
|
|
46 |
EXPORT_C CAlfBrush::CAlfBrush()
|
|
47 |
{
|
|
48 |
}
|
|
49 |
|
|
50 |
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
// 2nd phase constructor
|
|
53 |
// ---------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
EXPORT_C void CAlfBrush::ConstructL(
|
|
56 |
CAlfEnv& aEnv,
|
|
57 |
TInt aImplementationId,
|
|
58 |
TInt aImplementationUid,
|
|
59 |
const TDesC8& aConstructionParams )
|
|
60 |
{
|
|
61 |
ConstructL();
|
|
62 |
|
|
63 |
if (!iData->iComms)
|
|
64 |
{
|
|
65 |
iData->iComms = CAlfGenComponent::NewL(
|
|
66 |
aEnv,
|
|
67 |
aImplementationId,
|
|
68 |
aImplementationUid,
|
|
69 |
aConstructionParams);
|
|
70 |
}
|
|
71 |
}
|
|
72 |
|
|
73 |
// ---------------------------------------------------------------------------
|
|
74 |
//
|
|
75 |
// ---------------------------------------------------------------------------
|
|
76 |
//
|
|
77 |
EXPORT_C void CAlfBrush::ConstructL()
|
|
78 |
{
|
|
79 |
iData = new (ELeave) TPrivateData;
|
|
80 |
|
|
81 |
iData->iComms = NULL;
|
|
82 |
iData->iClipToVisual = EFalse;
|
|
83 |
}
|
|
84 |
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
// Destructor
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
//
|
|
89 |
EXPORT_C CAlfBrush::~CAlfBrush()
|
|
90 |
{
|
|
91 |
if ( iData )
|
|
92 |
{
|
|
93 |
const TInt containingBrushArrayCount = iData->iContainingBrushArrays.Count();
|
|
94 |
if ( containingBrushArrayCount )
|
|
95 |
{
|
|
96 |
__ALFLOGSTRING1( "CAlfBrush::~CAlfBrush Warning: deleted brush still in %d arrays", containingBrushArrayCount )
|
|
97 |
}
|
|
98 |
|
|
99 |
// Remove from containing arrays
|
|
100 |
for ( TInt i = containingBrushArrayCount-1 ; i>=0 ; i-- )
|
|
101 |
{
|
|
102 |
iData->iContainingBrushArrays[i]->HandleBrushDestroyed(*this);
|
|
103 |
}
|
|
104 |
|
|
105 |
iData->iContainingBrushArrays.Close();
|
|
106 |
|
|
107 |
delete iData->iComms;
|
|
108 |
}
|
|
109 |
delete iData;
|
|
110 |
iData = NULL;
|
|
111 |
}
|
|
112 |
|
|
113 |
// ---------------------------------------------------------------------------
|
|
114 |
//
|
|
115 |
// ---------------------------------------------------------------------------
|
|
116 |
//
|
|
117 |
EXPORT_C const TAlfTimedValue& CAlfBrush::Opacity() const
|
|
118 |
{
|
|
119 |
TPckg<TAlfTimedValue> buf(iData->iOpacity);
|
|
120 |
TInt err = iData->iComms->DoSynchronousCmd( EAlfBrushGetOpacity, buf, buf);
|
|
121 |
|
|
122 |
if ( err != KErrNone )
|
|
123 |
{
|
|
124 |
__ALFLOGSTRING1( "CAlfBrush::Opacity panic error %d", err )
|
|
125 |
USER_INVARIANT();
|
|
126 |
}
|
|
127 |
|
|
128 |
return iData->iOpacity;
|
|
129 |
}
|
|
130 |
|
|
131 |
// ---------------------------------------------------------------------------
|
|
132 |
//
|
|
133 |
// ---------------------------------------------------------------------------
|
|
134 |
//
|
|
135 |
EXPORT_C void CAlfBrush::SetOpacity( const TAlfTimedValue& aOpacity )
|
|
136 |
{
|
|
137 |
TPckgC<TAlfTimedValue> buf(aOpacity);
|
|
138 |
|
|
139 |
TInt err = iData->iComms->DoCmdNoReply( EAlfBrushSetOpacity, buf );
|
|
140 |
|
|
141 |
if ( err == KErrNone )
|
|
142 |
{
|
|
143 |
iData->iOpacity = aOpacity;
|
|
144 |
}
|
|
145 |
else
|
|
146 |
{
|
|
147 |
__ALFLOGSTRING1( "CAlfBrush::SetOpacity panic error %d", err )
|
|
148 |
USER_INVARIANT();
|
|
149 |
}
|
|
150 |
}
|
|
151 |
|
|
152 |
// ---------------------------------------------------------------------------
|
|
153 |
// Returns server handle. 0 if not set.
|
|
154 |
// ---------------------------------------------------------------------------
|
|
155 |
//
|
|
156 |
EXPORT_C TInt CAlfBrush::Identifier() const
|
|
157 |
{
|
|
158 |
return iData->iComms->Identifier();
|
|
159 |
}
|
|
160 |
|
|
161 |
// ---------------------------------------------------------------------------
|
|
162 |
//
|
|
163 |
// ---------------------------------------------------------------------------
|
|
164 |
//
|
|
165 |
EXPORT_C void CAlfBrush::SetLayer(TAlfBrushLayer aLayer)
|
|
166 |
{
|
|
167 |
TPckgC<TAlfBrushLayer> buf(aLayer);
|
|
168 |
|
|
169 |
TInt err = iData->iComms->DoCmdNoReply( EAlfBrushSetLayer, buf );
|
|
170 |
|
|
171 |
if ( err )
|
|
172 |
{
|
|
173 |
__ALFLOGSTRING1( "CAlfBrush::SetLayer panic error %d", err )
|
|
174 |
USER_INVARIANT();
|
|
175 |
}
|
|
176 |
}
|
|
177 |
|
|
178 |
// ---------------------------------------------------------------------------
|
|
179 |
//
|
|
180 |
// ---------------------------------------------------------------------------
|
|
181 |
//
|
|
182 |
EXPORT_C CAlfGenComponent* CAlfBrush::Comms() const
|
|
183 |
{
|
|
184 |
ASSERT(iData);
|
|
185 |
return iData->iComms;
|
|
186 |
}
|
|
187 |
|
|
188 |
// ---------------------------------------------------------------------------
|
|
189 |
// future proofing
|
|
190 |
// ---------------------------------------------------------------------------
|
|
191 |
//
|
|
192 |
EXPORT_C void CAlfBrush::PropertyOwnerExtension(const TUid& aExtensionUid, TAny** aExtensionParams)
|
|
193 |
{
|
|
194 |
CAlfPropertyOwner::PropertyOwnerExtension(aExtensionUid, aExtensionParams);
|
|
195 |
}
|
|
196 |
|
|
197 |
|
|
198 |
// ---------------------------------------------------------------------------
|
|
199 |
// Append a brush array which holds this brush
|
|
200 |
// ---------------------------------------------------------------------------
|
|
201 |
//
|
|
202 |
TInt CAlfBrush::AppendContainingArray( CAlfBrushArray& aContainingArray )
|
|
203 |
{
|
|
204 |
__ASSERT_ALWAYS( iData , USER_INVARIANT() );
|
|
205 |
|
|
206 |
// allow duplicates, because a brush can be in the same array many times.
|
|
207 |
return iData->iContainingBrushArrays.Append( &aContainingArray );
|
|
208 |
}
|
|
209 |
|
|
210 |
// ---------------------------------------------------------------------------
|
|
211 |
// Removes a brush array which holds this brush
|
|
212 |
// ---------------------------------------------------------------------------
|
|
213 |
//
|
|
214 |
void CAlfBrush::RemoveContainingArray( CAlfBrushArray& aContainingArray )
|
|
215 |
{
|
|
216 |
__ASSERT_ALWAYS( iData , USER_INVARIANT() );
|
|
217 |
|
|
218 |
for ( TInt i = iData->iContainingBrushArrays.Count()-1 ; i>=0 ; i-- )
|
|
219 |
{
|
|
220 |
if ( iData->iContainingBrushArrays[i] == &aContainingArray )
|
|
221 |
{
|
|
222 |
// remove one instance only once becuase it might be on the same array
|
|
223 |
// several times
|
|
224 |
iData->iContainingBrushArrays.Remove(i);
|
|
225 |
iData->iContainingBrushArrays.Compress();
|
|
226 |
break;
|
|
227 |
}
|
|
228 |
}
|
|
229 |
}
|
|
230 |
|
|
231 |
// ---------------------------------------------------------------------------
|
|
232 |
//
|
|
233 |
// ---------------------------------------------------------------------------
|
|
234 |
//
|
|
235 |
EXPORT_C void CAlfBrush::SetClipToVisual(TBool aClipToVisual)
|
|
236 |
{
|
|
237 |
TPckgC<TBool> buf(aClipToVisual);
|
|
238 |
|
|
239 |
TInt err = iData->iComms->DoCmdNoReply( EAlfBrushSetClipToVisual, buf );
|
|
240 |
|
|
241 |
if ( err )
|
|
242 |
{
|
|
243 |
__ALFLOGSTRING1( "CAlfBrush::SetClipToVisual panic error %d", err )
|
|
244 |
USER_INVARIANT();
|
|
245 |
}
|
|
246 |
}
|
|
247 |
|
|
248 |
// ---------------------------------------------------------------------------
|
|
249 |
//
|
|
250 |
// ---------------------------------------------------------------------------
|
|
251 |
//
|
|
252 |
EXPORT_C TBool CAlfBrush::ClipToVisual() const
|
|
253 |
{
|
|
254 |
TPckg<TBool> buf(iData->iClipToVisual);
|
|
255 |
TInt err = iData->iComms->DoSynchronousCmd( EAlfBrushClipToVisual, buf, buf);
|
|
256 |
|
|
257 |
if ( err != KErrNone )
|
|
258 |
{
|
|
259 |
__ALFLOGSTRING1( "CAlfBrush::ClipToVisual panic error %d", err )
|
|
260 |
USER_INVARIANT();
|
|
261 |
}
|
|
262 |
|
|
263 |
return iData->iClipToVisual;
|
|
264 |
|
|
265 |
}
|
|
266 |
|