|
1 /* |
|
2 * Copyright (c) 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: Implementation of CFsFastAddressingVisualizer class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 //<cmail> removed __FS_ALFRED_SUPPORT flag |
|
20 //#include <fsconfig.h> |
|
21 //</cmail> removed __FS_ALFRED_SUPPORT flag |
|
22 //<cmail> SF |
|
23 #include "emailtrace.h" |
|
24 #include <alf/alfAnchorLayout.h> |
|
25 #include <alf/alfFlowLayout.h> |
|
26 #include <alf/alfimagevisual.h> |
|
27 //</cmail> |
|
28 #include <COECNTRL.H> |
|
29 |
|
30 #include "fsfastaddressingvisualizer.h" |
|
31 #include "fstextinputvisual.h" |
|
32 #include "fsgenericpanic.h" |
|
33 |
|
34 //Height of text input field in pixels |
|
35 const TInt KFixedTexFieldHeight = 20; |
|
36 |
|
37 const TInt KFixedSpacing = 5; //Spacing in pixels |
|
38 const TInt KOrdinalTextField = 0; |
|
39 const TInt KOrdinalListField = 2; |
|
40 const TReal32 KOpacityVisible = 1; |
|
41 const TReal32 KOpacityInvisible = 0; |
|
42 |
|
43 |
|
44 // ======== MEMBER FUNCTIONS ======== |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // Constructor |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CFsFastAddressingVisualizer::CFsFastAddressingVisualizer( CAlfControl& aOwner ) |
|
51 : iControlOwner( aOwner ), |
|
52 iListPosition( CFsFastAddressingList::EListBelowTextField ) |
|
53 { |
|
54 FUNC_LOG; |
|
55 //No implementation needed |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // Two phased constructor |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 void CFsFastAddressingVisualizer::ConstructL( CCoeControl& aTextControl ) |
|
63 { |
|
64 FUNC_LOG; |
|
65 CAlfLayout* parent = CAlfLayout::AddNewL( iControlOwner ); |
|
66 iRootLayout = CAlfAnchorLayout::AddNewL( iControlOwner, parent ); |
|
67 iTextField = CAlfFlowLayout::AddNewL( iControlOwner, |
|
68 iRootLayout ); |
|
69 iTextField->SetFlowDirection( CAlfFlowLayout::EFlowHorizontal ); |
|
70 |
|
71 iItemsList = CAlfLayout::AddNewL( iControlOwner, iRootLayout ); |
|
72 iIconA = CAlfImageVisual::AddNewL( iControlOwner, iTextField ); |
|
73 iTextInputVisual = CFsTextInputVisual::AddNewL( iControlOwner, |
|
74 aTextControl, |
|
75 iTextField ); |
|
76 iIconB = CAlfImageVisual::AddNewL( iControlOwner, iTextField ); |
|
77 iTextFieldVisible = ETrue; |
|
78 //----TO BE REMOVED |
|
79 //Set size of the component |
|
80 // this part of code exists only for tests purpose |
|
81 //<cmail> removed from cmail |
|
82 //iRootLayout->SetRect( TAlfRealRect( TRect( 0, 0, 240, 150 ) ), 0 ); |
|
83 //</cmail> |
|
84 //----END OF TO BE REMOVED |
|
85 SetAnchors(); |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // Constructs and returns an CFsFastAddressingVisualizer object. |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 CFsFastAddressingVisualizer* CFsFastAddressingVisualizer::NewL( |
|
93 CAlfControl& aOwner, |
|
94 CCoeControl& aTextControl |
|
95 /*CCoeControl& aDispControl */) |
|
96 { |
|
97 FUNC_LOG; |
|
98 CFsFastAddressingVisualizer* self = |
|
99 CFsFastAddressingVisualizer::NewLC( aOwner, |
|
100 aTextControl ); |
|
101 CleanupStack::Pop( self ); |
|
102 return self; |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // Constructs and returns an CFsFastAddressingVisualizer object. |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 CFsFastAddressingVisualizer* CFsFastAddressingVisualizer::NewLC( |
|
110 CAlfControl& aOwner, |
|
111 CCoeControl& aTextControl ) |
|
112 { |
|
113 FUNC_LOG; |
|
114 CFsFastAddressingVisualizer* self = |
|
115 new( ELeave ) CFsFastAddressingVisualizer( aOwner ); |
|
116 CleanupStack::PushL( self ); |
|
117 self->ConstructL( aTextControl ); |
|
118 return self; |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // Destructor. |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 CFsFastAddressingVisualizer::~CFsFastAddressingVisualizer() |
|
126 { |
|
127 FUNC_LOG; |
|
128 } |
|
129 |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // Sets icon image. |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 void CFsFastAddressingVisualizer::SetIcon( |
|
136 const CFsFastAddressingList::TIconID aIconID, |
|
137 const TAlfImage& aImage ) |
|
138 { |
|
139 FUNC_LOG; |
|
140 if ( aIconID == CFsFastAddressingList::EIconA ) |
|
141 { |
|
142 iIconA->SetImage( aImage ); |
|
143 iIconA->SetSize( TAlfRealSize( KFixedTexFieldHeight, |
|
144 KFixedTexFieldHeight ) ); |
|
145 } |
|
146 else if ( aIconID == CFsFastAddressingList::EIconB ) |
|
147 { |
|
148 iIconB->SetImage( aImage ); |
|
149 iIconB->SetSize( TAlfRealSize( KFixedTexFieldHeight, |
|
150 KFixedTexFieldHeight ) ); |
|
151 } |
|
152 SetAnchors(); |
|
153 } |
|
154 |
|
155 // --------------------------------------------------------------------------- |
|
156 // Controls icon visibility. |
|
157 // --------------------------------------------------------------------------- |
|
158 // |
|
159 void CFsFastAddressingVisualizer::SetIconVisible( |
|
160 const CFsFastAddressingList::TIconID aIconID, |
|
161 const TBool aVisible ) |
|
162 { |
|
163 FUNC_LOG; |
|
164 CAlfImageVisual* icon(NULL); |
|
165 if ( aIconID == CFsFastAddressingList::EIconA ) |
|
166 { |
|
167 icon = iIconA; |
|
168 } |
|
169 else if ( aIconID == CFsFastAddressingList::EIconB ) |
|
170 { |
|
171 icon = iIconB; |
|
172 } |
|
173 else |
|
174 { |
|
175 FsGenericPanic( EFsFastAddressingListBadIconId ); |
|
176 } |
|
177 |
|
178 const TAlfImage& img = icon->Image(); |
|
179 if ( !img.HasTexture()) |
|
180 { |
|
181 FsGenericPanic( EFsFastAddressingListTextureNotSet ); |
|
182 } |
|
183 |
|
184 if ( aVisible ) |
|
185 { |
|
186 TAlfTimedValue opacity( icon->Opacity() ); |
|
187 opacity.SetValueNow( KOpacityVisible ); |
|
188 icon->SetOpacity( opacity ); |
|
189 icon->SetSize( TAlfRealSize( KFixedTexFieldHeight, |
|
190 KFixedTexFieldHeight ) ); |
|
191 } |
|
192 else |
|
193 { |
|
194 TAlfTimedValue opacity( icon->Opacity() ); |
|
195 opacity.SetValueNow( KOpacityVisible ); |
|
196 icon->SetOpacity( opacity ); |
|
197 icon->SetSize( TAlfRealSize( 0, 0 ) ); |
|
198 } |
|
199 SetAnchors(); |
|
200 } |
|
201 |
|
202 |
|
203 // --------------------------------------------------------------------------- |
|
204 // Resturns status of the icon visibility. |
|
205 // --------------------------------------------------------------------------- |
|
206 // |
|
207 TBool CFsFastAddressingVisualizer::IconVisible( |
|
208 const CFsFastAddressingList::TIconID aIconID ) const |
|
209 { |
|
210 FUNC_LOG; |
|
211 TBool result( EFalse ); |
|
212 |
|
213 switch ( aIconID ) |
|
214 { |
|
215 case CFsFastAddressingList::EIconA: |
|
216 { |
|
217 result = TBool( iIconA->Opacity().ValueNow() == KOpacityInvisible ); |
|
218 break; |
|
219 } |
|
220 |
|
221 case CFsFastAddressingList::EIconB: |
|
222 { |
|
223 result = TBool( iIconB->Opacity().ValueNow() == KOpacityInvisible ); |
|
224 break; |
|
225 } |
|
226 |
|
227 default: |
|
228 { |
|
229 FsGenericPanic( EFsFastAddressingListBadIconId ); |
|
230 break; |
|
231 } |
|
232 } |
|
233 |
|
234 return result; |
|
235 } |
|
236 |
|
237 // --------------------------------------------------------------------------- |
|
238 // Redraws whole fast addressing list component. |
|
239 // --------------------------------------------------------------------------- |
|
240 // |
|
241 void CFsFastAddressingVisualizer::Refresh() |
|
242 { |
|
243 FUNC_LOG; |
|
244 //TO DO |
|
245 } |
|
246 |
|
247 // --------------------------------------------------------------------------- |
|
248 // Controls visibility of the component |
|
249 // --------------------------------------------------------------------------- |
|
250 // |
|
251 void CFsFastAddressingVisualizer::SetVisible(const TBool /*aVisible*/) |
|
252 { |
|
253 FUNC_LOG; |
|
254 //TO DO |
|
255 } |
|
256 |
|
257 // --------------------------------------------------------------------------- |
|
258 // Move selection up. |
|
259 // --------------------------------------------------------------------------- |
|
260 // |
|
261 void CFsFastAddressingVisualizer::MoveSelectionUp() |
|
262 { |
|
263 FUNC_LOG; |
|
264 //TO DO |
|
265 } |
|
266 |
|
267 // --------------------------------------------------------------------------- |
|
268 // Move selection down. |
|
269 // --------------------------------------------------------------------------- |
|
270 // |
|
271 void CFsFastAddressingVisualizer::MoveSelectionDown() |
|
272 { |
|
273 FUNC_LOG; |
|
274 //TO DO |
|
275 } |
|
276 |
|
277 // --------------------------------------------------------------------------- |
|
278 // Retuns latyout for the text input field |
|
279 // --------------------------------------------------------------------------- |
|
280 // |
|
281 CAlfLayout* CFsFastAddressingVisualizer::GetTextLayout() const |
|
282 { |
|
283 FUNC_LOG; |
|
284 return iTextField; |
|
285 } |
|
286 |
|
287 |
|
288 // --------------------------------------------------------------------------- |
|
289 // Controls visibility of the text field |
|
290 // --------------------------------------------------------------------------- |
|
291 // |
|
292 void CFsFastAddressingVisualizer::SetTextFieldVisible( const TBool aVisible ) |
|
293 { |
|
294 FUNC_LOG; |
|
295 iTextFieldVisible = aVisible; |
|
296 if ( aVisible ) |
|
297 { |
|
298 TAlfTimedValue opacity( iTextInputVisual->Opacity() ); |
|
299 opacity.SetValueNow( KOpacityVisible ); |
|
300 iTextInputVisual->SetOpacity( opacity ); |
|
301 } |
|
302 else |
|
303 { |
|
304 TAlfTimedValue opacity( iTextInputVisual->Opacity() ); |
|
305 opacity.SetValueNow( KOpacityInvisible ); |
|
306 iTextInputVisual->SetOpacity( opacity ); |
|
307 } |
|
308 } |
|
309 |
|
310 // --------------------------------------------------------------------------- |
|
311 // Returns status of the text field visibility |
|
312 // --------------------------------------------------------------------------- |
|
313 // |
|
314 TBool CFsFastAddressingVisualizer::IsTextFieldVisible() const |
|
315 { |
|
316 FUNC_LOG; |
|
317 return iTextFieldVisible; |
|
318 } |
|
319 |
|
320 // --------------------------------------------------------------------------- |
|
321 // Sets list position (above/below of the text input field) |
|
322 // --------------------------------------------------------------------------- |
|
323 // |
|
324 void CFsFastAddressingVisualizer::SetListPosition( |
|
325 const CFsFastAddressingList::TFsListPosition aPos ) |
|
326 { |
|
327 FUNC_LOG; |
|
328 iListPosition = aPos; |
|
329 SetAnchors(); |
|
330 } |
|
331 |
|
332 // --------------------------------------------------------------------------- |
|
333 // Returns the list position (above/below of the text input field) |
|
334 // --------------------------------------------------------------------------- |
|
335 // |
|
336 CFsFastAddressingList::TFsListPosition |
|
337 CFsFastAddressingVisualizer::ListPosition() const |
|
338 { |
|
339 return iListPosition; |
|
340 } |
|
341 |
|
342 // --------------------------------------------------------------------------- |
|
343 // Returns pointer to the main layout |
|
344 // --------------------------------------------------------------------------- |
|
345 // |
|
346 CAlfLayout* CFsFastAddressingVisualizer::GetMainLayout() const |
|
347 { |
|
348 FUNC_LOG; |
|
349 return iRootLayout; |
|
350 } |
|
351 |
|
352 // --------------------------------------------------------------------------- |
|
353 // Returns layout for list component |
|
354 // --------------------------------------------------------------------------- |
|
355 // |
|
356 CAlfLayout* CFsFastAddressingVisualizer::GetListLayout() const |
|
357 { |
|
358 FUNC_LOG; |
|
359 return iItemsList; |
|
360 } |
|
361 |
|
362 // --------------------------------------------------------------------------- |
|
363 // Draws underline of matching part of text in the list items. |
|
364 // --------------------------------------------------------------------------- |
|
365 // |
|
366 void CFsFastAddressingVisualizer::DrawUnderline() |
|
367 { |
|
368 FUNC_LOG; |
|
369 //TO DO - probably not needed. |
|
370 } |
|
371 |
|
372 // --------------------------------------------------------------------------- |
|
373 // Sets anchors in root layout (positioning) |
|
374 // --------------------------------------------------------------------------- |
|
375 // |
|
376 void CFsFastAddressingVisualizer::SetAnchors() |
|
377 { |
|
378 FUNC_LOG; |
|
379 iRootLayout->Reset(); |
|
380 TAlfTimedPoint rootSize = iRootLayout->Size(); |
|
381 TPoint size = rootSize.ValueNow(); |
|
382 |
|
383 if ((!size.iX) || (!size.iY)) |
|
384 { |
|
385 return; //if size is zero its not needed to set anchors. |
|
386 } |
|
387 |
|
388 TAlfTimedPoint listTopLeft( 0, 0 ); |
|
389 TAlfTimedPoint listBottomRight( rootSize ); |
|
390 |
|
391 if ( iTextFieldVisible ) |
|
392 { |
|
393 TPoint iconA = iIconA->Size().ValueNow(); |
|
394 TPoint iconB = iIconB->Size().ValueNow(); |
|
395 TAlfTimedPoint textFieldTopLeft; |
|
396 TAlfTimedPoint textFieldBottomRight; |
|
397 |
|
398 if ( iListPosition == CFsFastAddressingList::EListBelowTextField ) |
|
399 { |
|
400 textFieldTopLeft.SetTarget( TAlfRealPoint( 0, 0 ) ); |
|
401 textFieldBottomRight.SetTarget( TAlfRealPoint( size.iX, |
|
402 KFixedTexFieldHeight ) ); |
|
403 listTopLeft.SetTarget( TAlfRealPoint( 0, |
|
404 KFixedTexFieldHeight+KFixedSpacing ) ); |
|
405 } |
|
406 else if (iListPosition == |
|
407 CFsFastAddressingList::EListOnTopOfTextField ) |
|
408 { |
|
409 textFieldTopLeft.SetTarget( TAlfRealPoint( 0, |
|
410 size.iY - KFixedTexFieldHeight ) ); |
|
411 textFieldBottomRight.SetTarget( TAlfRealPoint( size.iX, size.iY ) ); |
|
412 listBottomRight.SetTarget( TAlfRealPoint( size.iX, |
|
413 size.iY - ( KFixedTexFieldHeight+KFixedSpacing ) ) ); |
|
414 } |
|
415 |
|
416 iTextInputVisual->SetSize( TAlfRealSize( ( size.iX )- |
|
417 ( iconA.iX + iconB.iX ), |
|
418 KFixedTexFieldHeight ) ); |
|
419 |
|
420 iRootLayout->SetAnchor( EAlfAnchorTopLeft, |
|
421 KOrdinalTextField, |
|
422 EAlfAnchorOriginLeft, |
|
423 EAlfAnchorOriginTop, |
|
424 EAlfAnchorMetricAbsolute, |
|
425 EAlfAnchorMetricAbsolute, |
|
426 textFieldTopLeft); |
|
427 |
|
428 iRootLayout->SetAnchor( EAlfAnchorBottomRight, |
|
429 KOrdinalTextField, |
|
430 EAlfAnchorOriginLeft, |
|
431 EAlfAnchorOriginTop, |
|
432 EAlfAnchorMetricAbsolute, |
|
433 EAlfAnchorMetricAbsolute, |
|
434 textFieldBottomRight); |
|
435 } |
|
436 |
|
437 iRootLayout->SetAnchor( EAlfAnchorTopLeft, |
|
438 KOrdinalListField, |
|
439 EAlfAnchorOriginLeft, |
|
440 EAlfAnchorOriginTop, |
|
441 EAlfAnchorMetricAbsolute, |
|
442 EAlfAnchorMetricAbsolute, |
|
443 listTopLeft); |
|
444 |
|
445 iRootLayout->SetAnchor( EAlfAnchorBottomRight, |
|
446 KOrdinalListField, |
|
447 EAlfAnchorOriginLeft, |
|
448 EAlfAnchorOriginTop, |
|
449 EAlfAnchorMetricAbsolute, |
|
450 EAlfAnchorMetricAbsolute, |
|
451 listBottomRight); |
|
452 |
|
453 iRootLayout->UpdateChildrenLayout(); |
|
454 } |
|
455 |