|
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: CAknListLoader is used to load the APIs needed for listbox effects |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "aknlistloadertfx.h" |
|
20 #include "aknlistboxtfx.h" |
|
21 #include "aknlistboxtfxinternal.h" |
|
22 #include "aknlistboxtfxplugin.h" |
|
23 #include "aknlistboxecomids.h" |
|
24 #include <ecom/ecom.h> |
|
25 #include <eiklbx.h> |
|
26 #include <eiklbv.h> |
|
27 #include <eiklbi.h> |
|
28 #include <eikmenup.h> |
|
29 |
|
30 const TUid KUid = { 0x10282E46 }; // Uid for the CCoeStatic |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 EXPORT_C MAknListBoxTfx *CAknListLoader::TfxApi(CWindowGc *aGc) |
|
36 { |
|
37 CAknListLoader *singleton = CAknListLoader::Static(); |
|
38 |
|
39 if ( singleton && singleton->iListBoxPlugin && |
|
40 singleton->iGcArray.Find( aGc ) != KErrNotFound ) |
|
41 { |
|
42 return singleton->iListBoxPlugin->AknListBoxTfx(aGc); |
|
43 } |
|
44 return NULL; |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 EXPORT_C MAknListBoxTfxInternal *CAknListLoader::TfxApiInternal(CWindowGc *aGc) |
|
51 { |
|
52 CAknListLoader *singleton = CAknListLoader::Static(); |
|
53 |
|
54 if ( singleton && singleton->iListBoxPlugin && |
|
55 singleton->iGcArray.Find( aGc ) != KErrNotFound ) |
|
56 { |
|
57 return singleton->iListBoxPlugin->AknListBoxTfxInternal(aGc); |
|
58 } |
|
59 return NULL; |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 EXPORT_C CWindowGc* CAknListLoader::CreateTfxGc( CEikListBox& aListBox ) |
|
66 { |
|
67 CAknListLoader* singleton = CAknListLoader::Static(); |
|
68 if ( !singleton ) |
|
69 { |
|
70 singleton = new CAknListLoader(); |
|
71 } |
|
72 |
|
73 if( singleton && ( !singleton->iListBoxPlugin ) ) |
|
74 { |
|
75 // load plugin |
|
76 TInt err = KErrNone; |
|
77 TUid implementationUidCtrl = { KAknListBoxPluginEcomImpl }; |
|
78 |
|
79 TRAP( err,singleton->iListBoxPlugin = ( MAknListBoxTfxPlugin* ) |
|
80 REComSession::CreateImplementationL( implementationUidCtrl, |
|
81 singleton->iListBoxPluginEComDtorUID ) ); |
|
82 } |
|
83 if ( singleton && singleton->iListBoxPlugin && |
|
84 singleton->iGcArray.Reserve( singleton->iGcArray.Count() + 1 ) == KErrNone ) |
|
85 { |
|
86 CWindowGc* ret = singleton->iListBoxPlugin->CreateTfxGc( aListBox ); |
|
87 if ( ret && ret != aListBox.View()->ItemDrawer()->Gc() ) |
|
88 { |
|
89 singleton->iGcArray.Append( ret ); |
|
90 return ret; |
|
91 } |
|
92 } |
|
93 return aListBox.View()->ItemDrawer()->Gc(); |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 EXPORT_C CWindowGc *CAknListLoader::CreateTfxGc( CEikMenuPane& aMenuPane, |
|
100 TInt& aTopIndex, |
|
101 TInt& aItemsThatFitInView ) |
|
102 { |
|
103 CAknListLoader* singleton = CAknListLoader::Static(); |
|
104 if( !singleton ) |
|
105 { |
|
106 singleton = new CAknListLoader(); |
|
107 } |
|
108 |
|
109 if ( singleton && ( !singleton->iListBoxPlugin ) ) |
|
110 { |
|
111 // load plugin |
|
112 TInt err = KErrNone; |
|
113 TUid implementationUidCtrl = { KAknListBoxPluginEcomImpl }; |
|
114 |
|
115 TRAP( err, singleton->iListBoxPlugin = ( MAknListBoxTfxPlugin* ) |
|
116 REComSession::CreateImplementationL( |
|
117 implementationUidCtrl, |
|
118 singleton->iListBoxPluginEComDtorUID ) ); |
|
119 } |
|
120 CWindowGc* ret = NULL; |
|
121 if ( singleton && singleton->iListBoxPlugin && |
|
122 singleton->iGcArray.Reserve( singleton->iGcArray.Count() + 1 ) |
|
123 == KErrNone ) |
|
124 { |
|
125 ret = singleton->iListBoxPlugin->CreateTfxGc( aMenuPane, aTopIndex, |
|
126 aItemsThatFitInView ); |
|
127 if ( ret ) |
|
128 { |
|
129 singleton->iGcArray.Append( ret ); |
|
130 } |
|
131 } |
|
132 return ret; |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 EXPORT_C CWindowGc *CAknListLoader::CreateTfxGc( CAknTreeList& aTreeList, |
|
139 TInt& aTopIndex, |
|
140 TInt& aBottomIndex, |
|
141 TInt& aHighlightIndex, |
|
142 TInt& aRows ) |
|
143 { |
|
144 CAknListLoader* singleton = CAknListLoader::Static(); |
|
145 if( !singleton ) |
|
146 { |
|
147 singleton = new CAknListLoader(); |
|
148 } |
|
149 |
|
150 if ( singleton && ( !singleton->iListBoxPlugin ) ) |
|
151 { |
|
152 // load plugin |
|
153 TInt err = KErrNone; |
|
154 TUid implementationUidCtrl = { KAknListBoxPluginEcomImpl }; |
|
155 |
|
156 TRAP( err, singleton->iListBoxPlugin = ( MAknListBoxTfxPlugin* ) |
|
157 REComSession::CreateImplementationL( |
|
158 implementationUidCtrl, |
|
159 singleton->iListBoxPluginEComDtorUID ) ); |
|
160 } |
|
161 CWindowGc* ret = NULL; |
|
162 if ( singleton && singleton->iListBoxPlugin && |
|
163 singleton->iGcArray.Reserve( singleton->iGcArray.Count() + 1 ) |
|
164 == KErrNone ) |
|
165 { |
|
166 ret = singleton->iListBoxPlugin->CreateTfxGc( aTreeList, aTopIndex, |
|
167 aBottomIndex, aHighlightIndex, aRows ); |
|
168 if ( ret ) |
|
169 { |
|
170 singleton->iGcArray.Append( ret ); |
|
171 } |
|
172 } |
|
173 return ret; |
|
174 } |
|
175 |
|
176 // --------------------------------------------------------------------------- |
|
177 // --------------------------------------------------------------------------- |
|
178 // |
|
179 EXPORT_C CWindowGc* CAknListLoader::CreateTfxGc( CCoeControl& aAdapter ) |
|
180 { |
|
181 CAknListLoader* singleton = CAknListLoader::Static(); |
|
182 if( !singleton ) |
|
183 { |
|
184 singleton = new CAknListLoader(); |
|
185 } |
|
186 |
|
187 if ( singleton && !singleton->iListBoxPlugin ) |
|
188 { |
|
189 // load plugin |
|
190 TUid implementationUidCtrl = { KAknListBoxPluginEcomImpl }; |
|
191 |
|
192 TRAP_IGNORE( singleton->iListBoxPlugin = ( MAknListBoxTfxPlugin* ) |
|
193 REComSession::CreateImplementationL( |
|
194 implementationUidCtrl, |
|
195 singleton->iListBoxPluginEComDtorUID ) ); |
|
196 } |
|
197 if ( singleton && singleton->iListBoxPlugin && |
|
198 singleton->iGcArray.Reserve( singleton->iGcArray.Count() + 1 ) |
|
199 == KErrNone ) |
|
200 { |
|
201 CWindowGc* ret = singleton->iListBoxPlugin->CreateTfxGc( aAdapter ); |
|
202 if ( ret ) |
|
203 { |
|
204 singleton->iGcArray.Append( ret ); |
|
205 return ret; |
|
206 } |
|
207 } |
|
208 return &aAdapter.SystemGc(); |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------------------------- |
|
212 // --------------------------------------------------------------------------- |
|
213 // |
|
214 EXPORT_C void CAknListLoader::RemoveTfxGc ( CWindowGc* aGc ) |
|
215 { |
|
216 CAknListLoader* singleton = CAknListLoader::Static(); |
|
217 if( singleton ) |
|
218 { |
|
219 TInt index = singleton->iGcArray.Find( aGc ); |
|
220 if ( index != KErrNotFound ) |
|
221 { |
|
222 singleton->iGcArray.Remove( index ); |
|
223 } |
|
224 } |
|
225 |
|
226 } |
|
227 |
|
228 // --------------------------------------------------------------------------- |
|
229 // --------------------------------------------------------------------------- |
|
230 // |
|
231 EXPORT_C void CAknListLoader::InvalidateAll() |
|
232 { |
|
233 CAknListLoader* singleton = CAknListLoader::Static(); |
|
234 if ( singleton ) |
|
235 { |
|
236 for ( TInt i = 0; i < singleton->iGcArray.Count(); i++ ) |
|
237 { |
|
238 MAknListBoxTfxInternal* api = TfxApiInternal( singleton->iGcArray[i] ); |
|
239 if ( api ) |
|
240 { |
|
241 api->Remove( MAknListBoxTfxInternal:: EListEverything ); |
|
242 } |
|
243 } |
|
244 } |
|
245 } |
|
246 |
|
247 #ifdef RD_UI_TRANSITION_EFFECTS_TOUCH_P2 |
|
248 // --------------------------------------------------------------------------- |
|
249 // --------------------------------------------------------------------------- |
|
250 // |
|
251 EXPORT_C TInt CAknListLoader::LongTap( MAknListBoxTfxInternal::TLongTapEvent aEvent, |
|
252 TInt aDuration, const TPoint* aPoint ) |
|
253 { |
|
254 CAknListLoader* singleton = CAknListLoader::Static(); |
|
255 if ( singleton ) |
|
256 { |
|
257 for ( TInt i = 0; i < singleton->iGcArray.Count(); i++ ) |
|
258 { |
|
259 MAknListBoxTfxInternal* api = |
|
260 TfxApiInternal( singleton->iGcArray[i] ); |
|
261 if ( api && api->LongTap( aEvent, aDuration, aPoint ) == KErrNone ) |
|
262 { |
|
263 return KErrNone; |
|
264 } |
|
265 } |
|
266 } |
|
267 return KErrNotReady; |
|
268 } |
|
269 #endif // RD_UI_TRANSITION_EFFECTS_TOUCH_P2 |
|
270 |
|
271 // --------------------------------------------------------------------------- |
|
272 // --------------------------------------------------------------------------- |
|
273 // |
|
274 CAknListLoader *CAknListLoader::Static() |
|
275 { |
|
276 CAknListLoader *singleton = reinterpret_cast<CAknListLoader*>(CCoeEnv::Static(KUid)); |
|
277 return singleton; |
|
278 } |
|
279 |
|
280 // --------------------------------------------------------------------------- |
|
281 // --------------------------------------------------------------------------- |
|
282 // |
|
283 CAknListLoader::CAknListLoader() : CCoeStatic(KUid, -1, CCoeStatic::EThread) |
|
284 { |
|
285 } |
|
286 |
|
287 // --------------------------------------------------------------------------- |
|
288 // --------------------------------------------------------------------------- |
|
289 // |
|
290 CAknListLoader::~CAknListLoader() |
|
291 { |
|
292 iGcArray.ResetAndDestroy(); |
|
293 if(iListBoxPlugin) |
|
294 { |
|
295 delete iListBoxPlugin; |
|
296 REComSession::DestroyedImplementation( iListBoxPluginEComDtorUID ); |
|
297 } |
|
298 } |