|
1 /* |
|
2 * Copyright (c) 2006-2007 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: Stub file for visual list adapter |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // CLASS HEADER |
|
22 #include "TMGlxVisualList_Adapter.h" |
|
23 |
|
24 // EXTERNAL INCLUDES |
|
25 #include <EUnitMacros.h> |
|
26 #include <mglxvisuallistobserver.h> |
|
27 |
|
28 // declate the enum to be printed as TInt |
|
29 EUNIT_DECLARE_PRINTABLE_AS_TINT( MGlxVisualList_Observer::TMGlxVisualListMethodId ) |
|
30 |
|
31 // INTERNAL INCLUDES |
|
32 |
|
33 // CONSTRUCTION |
|
34 |
|
35 TMGlxVisualList_Adapter::TMGlxVisualList_Adapter( MGlxVisualList_Observer* aObserver ) |
|
36 : iSize( TMGlxVisualList_Adapter_Config::KDefaultSize ), |
|
37 iFocus( TMGlxVisualList_Adapter_Config::KDefaultFocus ), |
|
38 iMGlxVisualList_Observer( aObserver ), |
|
39 iMGlxVisualList( NULL ) |
|
40 { |
|
41 } |
|
42 |
|
43 TMGlxVisualList_Adapter::~TMGlxVisualList_Adapter() |
|
44 { |
|
45 // release the array |
|
46 iObservers.Close(); |
|
47 } |
|
48 |
|
49 void TMGlxVisualList_Adapter::SetAdaptee( MGlxVisualList* aAdaptee ) |
|
50 { |
|
51 iMGlxVisualList = aAdaptee; |
|
52 } |
|
53 |
|
54 // METHODS |
|
55 TGlxVisualListId TMGlxVisualList_Adapter::Id() const |
|
56 { |
|
57 // inform the test case |
|
58 iMGlxVisualList_Observer->MGlxVisualList_MethodCalled( MGlxVisualList_Observer::E_TGlxVisualListId_Id_ ); |
|
59 // call the actual method |
|
60 if ( iMGlxVisualList ) |
|
61 { |
|
62 return iMGlxVisualList->Id(); |
|
63 } |
|
64 return TGlxVisualListId( reinterpret_cast< unsigned int >( (void*)this ) ); |
|
65 } |
|
66 |
|
67 CHuiVisual* TMGlxVisualList_Adapter::Visual( TInt aListIndex ) |
|
68 { |
|
69 // inform the test case |
|
70 iMGlxVisualList_Observer->MGlxVisualList_MethodCalled( MGlxVisualList_Observer::E_CHuiVisual_p_Visual_TInt_ ); |
|
71 // call the actual method |
|
72 if ( iMGlxVisualList ) |
|
73 { |
|
74 return iMGlxVisualList->Visual( aListIndex ); |
|
75 } |
|
76 // return the index as visual |
|
77 return (CHuiVisual*)aListIndex; |
|
78 } |
|
79 |
|
80 CGlxVisualObject* TMGlxVisualList_Adapter::Item( TInt aListIndex ) |
|
81 { |
|
82 // inform the test case |
|
83 iMGlxVisualList_Observer->MGlxVisualList_MethodCalled( MGlxVisualList_Observer::E_CGlxVisualObject_p_Item_TInt_ ); |
|
84 // call the actual method |
|
85 if ( iMGlxVisualList ) |
|
86 { |
|
87 return iMGlxVisualList->Item( aListIndex ); |
|
88 } |
|
89 // return the index as item |
|
90 return (CGlxVisualObject*)aListIndex; |
|
91 } |
|
92 |
|
93 TInt TMGlxVisualList_Adapter::ItemCount() const |
|
94 { |
|
95 // inform the test case |
|
96 iMGlxVisualList_Observer->MGlxVisualList_MethodCalled( MGlxVisualList_Observer::E_TInt_ItemCount_ ); |
|
97 // call the actual method |
|
98 if ( iMGlxVisualList ) |
|
99 { |
|
100 return iMGlxVisualList->ItemCount(); |
|
101 } |
|
102 return iSize; |
|
103 } |
|
104 |
|
105 TInt TMGlxVisualList_Adapter::FocusIndex() const |
|
106 { |
|
107 // inform the test case |
|
108 iMGlxVisualList_Observer->MGlxVisualList_MethodCalled( MGlxVisualList_Observer::E_TInt_FocusIndex_ ); |
|
109 // call the actual method |
|
110 if ( iMGlxVisualList ) |
|
111 { |
|
112 return iMGlxVisualList->FocusIndex(); |
|
113 } |
|
114 return iFocus; |
|
115 } |
|
116 |
|
117 CHuiControlGroup* TMGlxVisualList_Adapter::ControlGroup() const |
|
118 { |
|
119 // inform the test case |
|
120 iMGlxVisualList_Observer->MGlxVisualList_MethodCalled( MGlxVisualList_Observer::E_CHuiControlGroup_p_ControlGroup_ ); |
|
121 // call the actual method |
|
122 if ( iMGlxVisualList ) |
|
123 { |
|
124 return iMGlxVisualList->ControlGroup(); |
|
125 } |
|
126 return NULL; |
|
127 } |
|
128 |
|
129 void TMGlxVisualList_Adapter::AddObserverL( MGlxVisualListObserver* aObserver ) |
|
130 { |
|
131 // inform the test case |
|
132 iMGlxVisualList_Observer->MGlxVisualList_MethodCalled( MGlxVisualList_Observer::E_void_AddObserverL_MGlxVisualListObserver_p_ ); |
|
133 |
|
134 // call the actual method |
|
135 if ( iMGlxVisualList ) |
|
136 { |
|
137 iMGlxVisualList->AddObserverL( aObserver ); |
|
138 } |
|
139 |
|
140 // add the observer to array |
|
141 iObservers.AppendL( aObserver ); |
|
142 } |
|
143 |
|
144 void TMGlxVisualList_Adapter::RemoveObserver( MGlxVisualListObserver* aObserver ) |
|
145 { |
|
146 // inform the test case |
|
147 iMGlxVisualList_Observer->MGlxVisualList_MethodCalled( MGlxVisualList_Observer::E_void_RemoveObserver_MGlxVisualListObserver_p_ ); |
|
148 // call the actual method |
|
149 if ( iMGlxVisualList ) |
|
150 { |
|
151 iMGlxVisualList->RemoveObserver( aObserver ); |
|
152 } |
|
153 } |
|
154 |
|
155 void TMGlxVisualList_Adapter::AddLayoutL( MGlxLayout* aLayout ) |
|
156 { |
|
157 // inform the test case |
|
158 iMGlxVisualList_Observer->MGlxVisualList_MethodCalled( MGlxVisualList_Observer::E_void_AddLayoutL_MGlxLayout_p_ ); |
|
159 |
|
160 TInt* memAlloc = new (ELeave) TInt; |
|
161 delete memAlloc; |
|
162 |
|
163 // call the actual method |
|
164 if ( iMGlxVisualList ) |
|
165 { |
|
166 iMGlxVisualList->AddLayoutL( aLayout ); |
|
167 } |
|
168 } |
|
169 |
|
170 void TMGlxVisualList_Adapter::RemoveLayout( const MGlxLayout* aLayout ) |
|
171 { |
|
172 // inform the test case |
|
173 iMGlxVisualList_Observer->MGlxVisualList_MethodCalled( MGlxVisualList_Observer::E_void_RemoveLayout_const_MGlxLayout_p_ ); |
|
174 // call the actual method |
|
175 if ( iMGlxVisualList ) |
|
176 { |
|
177 iMGlxVisualList->RemoveLayout( aLayout ); |
|
178 } |
|
179 } |
|
180 |
|
181 TGlxViewContextId TMGlxVisualList_Adapter::AddContextL( TInt aFrontVisibleRangeOffset, TInt aRearVisibleRangeOffset ) |
|
182 { |
|
183 // inform the test case |
|
184 iMGlxVisualList_Observer->MGlxVisualList_MethodCalled( MGlxVisualList_Observer::E_TGlxViewContextId_AddContextL_TInt_TInt_ ); |
|
185 |
|
186 TInt* memAlloc = new (ELeave) TInt; |
|
187 delete memAlloc; |
|
188 |
|
189 // call the actual method |
|
190 if ( iMGlxVisualList ) |
|
191 { |
|
192 return iMGlxVisualList->AddContextL( aFrontVisibleRangeOffset, aRearVisibleRangeOffset ); |
|
193 } |
|
194 return TGlxViewContextId( reinterpret_cast< unsigned int >( (void*)this) ); |
|
195 } |
|
196 |
|
197 void TMGlxVisualList_Adapter::RemoveContext( const TGlxViewContextId& aContextId ) |
|
198 { |
|
199 // inform the test case |
|
200 iMGlxVisualList_Observer->MGlxVisualList_MethodCalled( MGlxVisualList_Observer::E_void_RemoveContext_const_TGlxViewContextId_r_ ); |
|
201 // call the actual method |
|
202 if ( iMGlxVisualList ) |
|
203 { |
|
204 iMGlxVisualList->RemoveContext( aContextId ); |
|
205 } |
|
206 } |
|
207 |
|
208 void TMGlxVisualList_Adapter::NavigateL( TInt aIndexCount ) |
|
209 { |
|
210 // inform the test case |
|
211 iMGlxVisualList_Observer->MGlxVisualList_MethodCalled( MGlxVisualList_Observer::E_void_NavigateL_TInt_ ); |
|
212 |
|
213 TInt* memAlloc = new (ELeave) TInt; |
|
214 delete memAlloc; |
|
215 |
|
216 // call the actual method |
|
217 if ( iMGlxVisualList ) |
|
218 { |
|
219 iMGlxVisualList->NavigateL( aIndexCount ); |
|
220 } |
|
221 |
|
222 // change the focus |
|
223 iFocus = (iFocus + aIndexCount)% iSize; |
|
224 // if navigated backwards, loop the index |
|
225 if( iFocus < 0 ) |
|
226 { |
|
227 iFocus = iSize - 1; |
|
228 } |
|
229 |
|
230 EUNIT_PRINT( _L("Visual list focus %d"), iFocus ); |
|
231 |
|
232 for( TInt i=0; i<iObservers.Count(); i++ ) |
|
233 { |
|
234 iObservers[ i ]->HandleFocusChangedL( iFocus, 0, this, NGlxListDefs::EUnknown ); |
|
235 } |
|
236 } |
|
237 |
|
238 TSize TMGlxVisualList_Adapter::Size() const |
|
239 { |
|
240 // inform the test case |
|
241 iMGlxVisualList_Observer->MGlxVisualList_MethodCalled( MGlxVisualList_Observer::E_TSize_Size_ ); |
|
242 // call the actual method |
|
243 if ( iMGlxVisualList ) |
|
244 { |
|
245 return iMGlxVisualList->Size(); |
|
246 } |
|
247 return TSize( 0, 0 ); |
|
248 } |
|
249 |
|
250 void TMGlxVisualList_Adapter::BringVisualsToFront() |
|
251 { |
|
252 // inform the test case |
|
253 iMGlxVisualList_Observer->MGlxVisualList_MethodCalled( MGlxVisualList_Observer::E_void_BringVisualsToFront_ ); |
|
254 // call the actual method |
|
255 if ( iMGlxVisualList ) |
|
256 { |
|
257 iMGlxVisualList->BringVisualsToFront(); |
|
258 } |
|
259 } |
|
260 |
|
261 void TMGlxVisualList_Adapter::EnableAnimationL(TBool /*aAnimate*/, TInt /*aIndex*/) |
|
262 { |
|
263 } |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // SetDefaultIconBehaviourL |
|
267 // ----------------------------------------------------------------------------- |
|
268 void TMGlxVisualList_Adapter::SetDefaultIconBehaviourL( TBool /*aEnable*/ ) |
|
269 { |
|
270 } |
|
271 |
|
272 // END OF FILE |