|
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: |
|
15 * Location editors |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 #include <aknlocationed.h> |
|
21 #include <lbsposition.h> |
|
22 #include <barsread.h> |
|
23 #include <eikon.hrh> |
|
24 #include <e32math.h> |
|
25 #include <centralrepository.h> |
|
26 #include <AvkonInternalCRKeys.h> |
|
27 #include <eikenv.h> |
|
28 #include <eikctl.rsg> |
|
29 #include <cenrepnotifyhandler.h> |
|
30 #include <AknUtils.h> |
|
31 #include "aknmfneseparator.h" |
|
32 |
|
33 #include <AknTasHook.h> |
|
34 struct CLocationStrings : public CBase, public MCenRepNotifyHandlerCallback |
|
35 { |
|
36 HBufC *iDegree; |
|
37 HBufC *iMinMark; |
|
38 HBufC *iSecMark; |
|
39 HBufC *iNorth; |
|
40 HBufC *iSouth; |
|
41 HBufC *iEast; |
|
42 HBufC *iWest; |
|
43 ~CLocationStrings() |
|
44 { |
|
45 delete iDegree; |
|
46 delete iMinMark; |
|
47 delete iSecMark; |
|
48 delete iNorth; |
|
49 delete iSouth; |
|
50 delete iEast; |
|
51 delete iWest; |
|
52 } |
|
53 |
|
54 TInt iType; |
|
55 |
|
56 // From MCenRepNotifyHandlerCallback |
|
57 void HandleNotifyInt(TUint32 aId, TInt aNewValue); |
|
58 CAknLocationEditor *iParent; |
|
59 // Handle to Central Repository. |
|
60 CRepository* iCenRep; |
|
61 // For Central Repository value change notifications. |
|
62 CCenRepNotifyHandler* iCenRepNotifyHandler; |
|
63 TBool iMirroredLayoutUsed; |
|
64 }; |
|
65 |
|
66 |
|
67 void CLocationStrings::HandleNotifyInt(TUint32 aId, TInt aNewValue) |
|
68 { |
|
69 TRAP_IGNORE( iParent->HandleCenRepChangedL(aId, aNewValue)); |
|
70 } |
|
71 |
|
72 |
|
73 _LIT(KRLM, "\x200F"); // Directionality marker: Right-to-Left Marker. |
|
74 _LIT(KLRE, "\x202A"); // Directionality marker: Left-to-Right Embedding. |
|
75 _LIT(KPDF, "\x202C"); // Directionality marker: Pop Directional Format |
|
76 |
|
77 EXPORT_C CAknLocationEditor::CAknLocationEditor() |
|
78 { |
|
79 } |
|
80 EXPORT_C CAknLocationEditor::~CAknLocationEditor() |
|
81 { |
|
82 AKNTASHOOK_REMOVE(); |
|
83 // Stop listening CenRep. |
|
84 if (iStrings) |
|
85 { |
|
86 if (iStrings->iCenRepNotifyHandler) |
|
87 { |
|
88 iStrings->iCenRepNotifyHandler->StopListening(); |
|
89 } |
|
90 delete iStrings->iCenRepNotifyHandler; |
|
91 delete iStrings->iCenRep; |
|
92 } |
|
93 delete iStrings; |
|
94 } |
|
95 |
|
96 |
|
97 EXPORT_C CAknLocationEditor *CAknLocationEditor::NewL(TPosition &aValue, TLocationContext aContext) |
|
98 { |
|
99 CAknLocationEditor *editor = new(ELeave)CAknLocationEditor; |
|
100 CleanupStack::PushL(editor); |
|
101 editor->LoadStringsL(R_EIK_LATITUDE_AND_LONGITUDE); |
|
102 editor->ConstructL(aValue, aContext); |
|
103 CleanupStack::Pop(editor); |
|
104 AKNTASHOOK_ADDL( editor, "CAknLocationEditor" ); |
|
105 return editor; |
|
106 } |
|
107 |
|
108 static void AppendString(TPtr aBuf, TPtrC aString) |
|
109 { |
|
110 aBuf.Append(aString); |
|
111 } |
|
112 static void AppendString(TPtr aBuf, TChar aChar) |
|
113 { |
|
114 aBuf.Append(aChar); |
|
115 } |
|
116 static void AppendNum(TPtr aBuf, TInt aValue, TInt aNumOfDigits) |
|
117 { |
|
118 aBuf.AppendNumFixedWidthUC(aValue, EDecimal, aNumOfDigits); |
|
119 } |
|
120 static void AppendNumFst(TPtr aBuf, TInt aValue, TInt /*aNumOfDigits*/) |
|
121 { |
|
122 aBuf.AppendNum(aValue); |
|
123 } |
|
124 |
|
125 static HBufC *CopyDesL(HBufC *aOrig) |
|
126 { |
|
127 HBufC *buf = HBufC::NewL(aOrig->Length()); |
|
128 *buf = aOrig->Des(); |
|
129 return buf; |
|
130 } |
|
131 static TChar DecimalSeparator() |
|
132 { |
|
133 TLocale t; |
|
134 TChar c = t.DecimalSeparator(); |
|
135 return c; |
|
136 } |
|
137 |
|
138 EXPORT_C HBufC *CAknLocationEditor::DisplayableLocationL(const TPosition & aValue, TLocationContext aContext) |
|
139 { |
|
140 // read cenrep key |
|
141 TInt type = EDD; |
|
142 CRepository* repository = NULL; |
|
143 TRAPD(err, repository = CRepository::NewL(KCRUidAvkon)); |
|
144 TUint32 key = KAknLocationEditorCoordinateDataFormat; |
|
145 if (err == KErrNone) |
|
146 { |
|
147 err = repository->Get(key, (TInt&)type); |
|
148 } |
|
149 delete repository; |
|
150 |
|
151 CLocationStrings *strings = new (ELeave) CLocationStrings; |
|
152 CleanupStack::PushL(strings); |
|
153 // read resources |
|
154 TResourceReader reader; |
|
155 CEikonEnv::Static()->CreateResourceReaderLC(reader, R_EIK_LATITUDE_AND_LONGITUDE); |
|
156 strings->iDegree = reader.ReadHBufCL(); |
|
157 strings->iMinMark = reader.ReadHBufCL(); |
|
158 strings->iSecMark = reader.ReadHBufCL(); |
|
159 strings->iNorth = reader.ReadHBufCL(); |
|
160 reader.ReadInt16(); |
|
161 strings->iSouth = reader.ReadHBufCL(); |
|
162 reader.ReadInt16(); |
|
163 strings->iEast = reader.ReadHBufCL(); |
|
164 reader.ReadInt16(); |
|
165 strings->iWest = reader.ReadHBufCL(); |
|
166 reader.ReadInt16(); |
|
167 CleanupStack::PopAndDestroy(); // reader |
|
168 |
|
169 strings->iMirroredLayoutUsed = AknLayoutUtils::LayoutMirrored(); |
|
170 HBufC *buffer = HBufC::NewL(200); |
|
171 |
|
172 switch(type) |
|
173 { |
|
174 case EDD: |
|
175 { |
|
176 TInt degrees; |
|
177 TInt decidegrees; |
|
178 TBool neg; |
|
179 TBool nan; |
|
180 SplitDD(aValue, aContext, degrees, decidegrees, neg, nan); |
|
181 |
|
182 if (nan) |
|
183 { |
|
184 CleanupStack::PopAndDestroy(strings); |
|
185 return buffer; |
|
186 } |
|
187 if (strings->iMirroredLayoutUsed) |
|
188 { |
|
189 AppendString(buffer->Des(), TPtrC(KRLM)); |
|
190 AppendString(buffer->Des(), TPtrC(KLRE)); |
|
191 } |
|
192 AppendNumFst(buffer->Des(), degrees, aContext==ELatitudeOnly?2:3); |
|
193 AppendString(buffer->Des(), DecimalSeparator()); |
|
194 AppendNum(buffer->Des(), decidegrees, 5); |
|
195 AppendString(buffer->Des(), *strings->iDegree); |
|
196 if (strings->iMirroredLayoutUsed) |
|
197 { |
|
198 AppendString(buffer->Des(), TPtrC(KPDF)); |
|
199 } |
|
200 AppendString(buffer->Des(), neg?(aContext==ELatitudeOnly?*strings->iSouth:*strings->iWest) |
|
201 :(aContext==ELatitudeOnly?*strings->iNorth:*strings->iEast)); |
|
202 break; |
|
203 } |
|
204 case EDMM: |
|
205 { |
|
206 int degrees; |
|
207 int minutes; |
|
208 int deciminutes; |
|
209 TBool neg; |
|
210 TBool nan; |
|
211 SplitDMM(aValue, aContext, degrees, minutes, deciminutes, neg, nan); |
|
212 if (nan) |
|
213 { |
|
214 CleanupStack::PopAndDestroy(strings); |
|
215 return buffer; |
|
216 } |
|
217 if (strings->iMirroredLayoutUsed) |
|
218 { |
|
219 AppendString(buffer->Des(), TPtrC(KRLM)); |
|
220 AppendString(buffer->Des(), TPtrC(KLRE)); |
|
221 } |
|
222 AppendNumFst(buffer->Des(), degrees, aContext==ELatitudeOnly?2:3); |
|
223 AppendString(buffer->Des(), *strings->iDegree); |
|
224 AppendNum(buffer->Des(), minutes, 2); |
|
225 AppendString(buffer->Des(), DecimalSeparator()); |
|
226 AppendNum(buffer->Des(), deciminutes, 4); |
|
227 AppendString(buffer->Des(), *strings->iMinMark); |
|
228 if (strings->iMirroredLayoutUsed) |
|
229 { |
|
230 AppendString(buffer->Des(), TPtrC(KPDF)); |
|
231 } |
|
232 AppendString(buffer->Des(), neg?(aContext==ELatitudeOnly?*strings->iSouth:*strings->iWest) |
|
233 :(aContext==ELatitudeOnly?*strings->iNorth:*strings->iEast)); |
|
234 |
|
235 |
|
236 break; |
|
237 } |
|
238 case EDMSD: |
|
239 { |
|
240 int degrees; |
|
241 int minutes; |
|
242 int secs; |
|
243 int deciseconds; |
|
244 TBool neg; |
|
245 TBool nan; |
|
246 SplitDMSD(aValue, aContext, degrees, minutes, secs, deciseconds, neg, nan); |
|
247 if (nan) |
|
248 { |
|
249 CleanupStack::PopAndDestroy(strings); |
|
250 return buffer; |
|
251 } |
|
252 if (strings->iMirroredLayoutUsed) |
|
253 { |
|
254 AppendString(buffer->Des(), TPtrC(KRLM)); |
|
255 AppendString(buffer->Des(), TPtrC(KLRE)); |
|
256 } |
|
257 AppendNumFst(buffer->Des(), degrees, aContext==ELatitudeOnly?2:3); |
|
258 AppendString(buffer->Des(), *strings->iDegree); |
|
259 AppendNum(buffer->Des(), minutes, 2); |
|
260 AppendString(buffer->Des(), *strings->iMinMark); |
|
261 AppendNum(buffer->Des(), secs, 2); |
|
262 AppendString(buffer->Des(), DecimalSeparator()); |
|
263 AppendNum(buffer->Des(), deciseconds, 2); |
|
264 AppendString(buffer->Des(), *strings->iSecMark); |
|
265 if (strings->iMirroredLayoutUsed) |
|
266 { |
|
267 AppendString(buffer->Des(), TPtrC(KPDF)); |
|
268 } |
|
269 AppendString(buffer->Des(), neg?(aContext==ELatitudeOnly?*strings->iSouth:*strings->iWest) |
|
270 :(aContext==ELatitudeOnly?*strings->iNorth:*strings->iEast)); |
|
271 break; |
|
272 |
|
273 } |
|
274 }; |
|
275 TPtr ptr = buffer->Des(); |
|
276 AknTextUtils::LanguageSpecificNumberConversion(ptr); |
|
277 |
|
278 CleanupStack::PopAndDestroy(strings); // strings |
|
279 |
|
280 return buffer; |
|
281 } |
|
282 |
|
283 EXPORT_C void CAknLocationEditor::ConstructFromResourceL(TResourceReader& aResourceReader) |
|
284 { |
|
285 TInt flags( aResourceReader.ReadInt32() ); |
|
286 TInt res_id( aResourceReader.ReadInt32() ); |
|
287 TLocationContext context( ELongitudeOnly ); |
|
288 if (flags & ELocationEdFlagLatitude) |
|
289 { |
|
290 context = ELatitudeOnly; |
|
291 } |
|
292 TCoordinate coord( 0.0, 0.0 ); |
|
293 TLocality loc(coord, 0.1 ); |
|
294 TPosition p(loc, TTime(0) ); |
|
295 LoadStringsL(res_id); |
|
296 ConstructL(p, context); |
|
297 } |
|
298 |
|
299 EXPORT_C void CAknLocationEditor::Set(const TPosition &aValue) |
|
300 { |
|
301 TLocationType type = Type(); |
|
302 switch(type) |
|
303 { |
|
304 case EDD: |
|
305 { |
|
306 TInt degrees; |
|
307 TInt decidegrees; |
|
308 TBool neg; |
|
309 TBool nan; |
|
310 SplitDD(aValue, iContext, degrees, decidegrees, neg, nan); |
|
311 |
|
312 CEikMfneNumber *field; |
|
313 field = (CEikMfneNumber*)Field(FieldMapping(0, type)); |
|
314 field->SetValue(degrees, *Font()); |
|
315 |
|
316 field = (CEikMfneNumber*)Field(FieldMapping(2, type)); |
|
317 field->SetValue(decidegrees, *Font()); |
|
318 |
|
319 CEikMfneSymbol *field2 = (CEikMfneSymbol*)Field(FieldMapping(4, type)); |
|
320 field2->SetCurrentSymbolicItemToId(neg ? 1 : 0); |
|
321 SetUninitialised(nan); |
|
322 break; |
|
323 } |
|
324 case EDMM: |
|
325 { |
|
326 int degrees; |
|
327 int minutes; |
|
328 int deciminutes; |
|
329 TBool neg; |
|
330 TBool nan; |
|
331 SplitDMM(aValue, iContext, degrees, minutes, deciminutes, neg, nan); |
|
332 |
|
333 CEikMfneNumber *field = (CEikMfneNumber*)Field(FieldMapping(0, type)); |
|
334 field->SetValue(degrees, *Font()); |
|
335 |
|
336 field = (CEikMfneNumber*)Field(FieldMapping(2, type)); |
|
337 field->SetValue(minutes, *Font()); |
|
338 |
|
339 field = (CEikMfneNumber*)Field(FieldMapping(4, type)); |
|
340 field->SetValue(deciminutes, *Font()); |
|
341 |
|
342 CEikMfneSymbol *field2 = (CEikMfneSymbol*)Field(FieldMapping(6, type)); |
|
343 field2->SetCurrentSymbolicItemToId(neg ? 1 : 0); |
|
344 SetUninitialised(nan); |
|
345 |
|
346 break; |
|
347 } |
|
348 case EDMSD: |
|
349 { |
|
350 int degrees; |
|
351 int minutes; |
|
352 int secs; |
|
353 int deciseconds; |
|
354 TBool neg; |
|
355 TBool nan; |
|
356 SplitDMSD(aValue, iContext, degrees, minutes, secs, deciseconds, neg, nan); |
|
357 |
|
358 CEikMfneNumber *field = (CEikMfneNumber*)Field(FieldMapping(0, type)); |
|
359 field->SetValue(degrees, *Font()); |
|
360 |
|
361 field = (CEikMfneNumber*)Field(FieldMapping(2, type)); |
|
362 field->SetValue(minutes, *Font()); |
|
363 |
|
364 |
|
365 field = (CEikMfneNumber*)Field(FieldMapping(4, type)); |
|
366 field->SetValue(secs, *Font()); |
|
367 |
|
368 field = (CEikMfneNumber*)Field(FieldMapping(6, type)); |
|
369 field->SetValue(deciseconds, *Font()); |
|
370 |
|
371 CEikMfneSymbol *field2 = (CEikMfneSymbol*)Field(FieldMapping(8, type)); |
|
372 field2->SetCurrentSymbolicItemToId(neg ? 1 : 0); |
|
373 SetUninitialised(nan); |
|
374 break; |
|
375 |
|
376 } |
|
377 } |
|
378 if ( !IsFocused() ) |
|
379 { |
|
380 TRAP_IGNORE( ReportEventL( MCoeControlObserver::EEventStateChanged ) ); |
|
381 } |
|
382 } |
|
383 |
|
384 EXPORT_C void CAknLocationEditor::Get(TPosition &aValue) const |
|
385 { |
|
386 TLocationType type = Type(); |
|
387 switch(type) |
|
388 { |
|
389 case EDD: |
|
390 { |
|
391 TBool nan = ETrue; |
|
392 CEikMfneNumber *field = (CEikMfneNumber*)Field(FieldMapping(0, type)); |
|
393 TInt degrees = field->Value(); |
|
394 nan = nan && field->IsUninitialised(); |
|
395 |
|
396 field = (CEikMfneNumber*)Field(FieldMapping(2, type)); |
|
397 TInt decidegrees = field->Value(); |
|
398 nan = nan && field->IsUninitialised(); |
|
399 |
|
400 CEikMfneSymbol *field2 = (CEikMfneSymbol*)Field(FieldMapping(4, type)); |
|
401 TBool neg = field2->IdOfCurrentSymbolicItem() != 0; |
|
402 |
|
403 CombineDD(aValue, iContext, degrees, decidegrees, neg, nan); |
|
404 break; |
|
405 } |
|
406 case EDMM: |
|
407 { |
|
408 TBool nan( ETrue ); |
|
409 |
|
410 CEikMfneNumber *field = (CEikMfneNumber*)Field(FieldMapping(0, type)); |
|
411 TInt degrees = field->Value(); |
|
412 nan = nan && field->IsUninitialised(); |
|
413 |
|
414 field = (CEikMfneNumber*)Field(FieldMapping(2, type)); |
|
415 TInt minutes = field->Value(); |
|
416 nan = nan && field->IsUninitialised(); |
|
417 |
|
418 field = (CEikMfneNumber*)Field(FieldMapping(4, type)); |
|
419 TInt deciminutes = field->Value(); |
|
420 nan = nan && field->IsUninitialised(); |
|
421 |
|
422 CEikMfneSymbol *field2 = (CEikMfneSymbol*)Field(FieldMapping(6, type)); |
|
423 TBool neg = field2->IdOfCurrentSymbolicItem() != 0; |
|
424 |
|
425 |
|
426 CombineDMM(aValue, iContext, degrees, minutes, deciminutes, neg, nan); |
|
427 break; |
|
428 } |
|
429 case EDMSD: |
|
430 { |
|
431 TBool nan( ETrue ); |
|
432 |
|
433 CEikMfneNumber *field = (CEikMfneNumber*)Field(FieldMapping(0, type)); |
|
434 TInt degrees = field->Value(); |
|
435 nan = nan && field->IsUninitialised(); |
|
436 |
|
437 field = (CEikMfneNumber*)Field(FieldMapping(2, type)); |
|
438 TInt minutes = field->Value(); |
|
439 nan = nan && field->IsUninitialised(); |
|
440 |
|
441 field = (CEikMfneNumber*)Field(FieldMapping(4, type)); |
|
442 TInt secs = field->Value(); |
|
443 nan = nan && field->IsUninitialised(); |
|
444 |
|
445 field = (CEikMfneNumber*)Field(FieldMapping(6, type)); |
|
446 TInt deciseconds = field->Value(); |
|
447 nan = nan && field->IsUninitialised(); |
|
448 |
|
449 CEikMfneSymbol *field2 = (CEikMfneSymbol*)Field(FieldMapping(8, type)); |
|
450 TBool neg = field2->IdOfCurrentSymbolicItem() != 0; |
|
451 |
|
452 CombineDMSD(aValue, iContext, degrees, minutes, secs, deciseconds, neg, nan); |
|
453 break; |
|
454 } |
|
455 } |
|
456 } |
|
457 |
|
458 void CAknLocationEditor::ConstructL(TPosition &aValue, TLocationContext aContext) |
|
459 { |
|
460 iContext = aContext; |
|
461 if (!iStrings) |
|
462 { |
|
463 iStrings = new(ELeave)CLocationStrings; |
|
464 } |
|
465 iStrings->iParent = this; |
|
466 iStrings->iType = -1; |
|
467 |
|
468 // Start listening a CenRep key indicating whether hash key selection is active. |
|
469 TRAPD(err, iStrings->iCenRep = CRepository::NewL(KCRUidAvkon)); |
|
470 if (err == KErrNone) |
|
471 { |
|
472 iStrings->iCenRepNotifyHandler = CCenRepNotifyHandler::NewL(*iStrings, |
|
473 *iStrings->iCenRep, |
|
474 CCenRepNotifyHandler::EIntKey, |
|
475 KAknLocationEditorCoordinateDataFormat); |
|
476 |
|
477 iStrings->iCenRepNotifyHandler->StartListeningL(); |
|
478 } |
|
479 |
|
480 // This is for the lifetime of the editor. |
|
481 iStrings->iMirroredLayoutUsed = AknLayoutUtils::LayoutMirrored(); |
|
482 CreateMfneFieldsL(aValue); |
|
483 RefreshFromLocale(); |
|
484 } |
|
485 |
|
486 void CAknLocationEditor::CreateMfneFieldsL(const TPosition &aValue) |
|
487 { |
|
488 TInt flags = CEikMfneNumber::EFillWithLeadingZeros; |
|
489 TInt flags_fst = 0; |
|
490 TInt numberOfFields = 0; |
|
491 TLocationType type = Type(); |
|
492 |
|
493 switch(type) |
|
494 { |
|
495 case EDD: numberOfFields = 5; break; |
|
496 case EDMM: numberOfFields = 7; break; |
|
497 case EDMSD: numberOfFields = 9; break; |
|
498 default: break; |
|
499 }; |
|
500 |
|
501 CreateFieldArrayL(numberOfFields); |
|
502 |
|
503 switch(type) |
|
504 { |
|
505 case EDD: |
|
506 { |
|
507 TInt degrees; |
|
508 TInt decidegrees; |
|
509 TBool neg; |
|
510 TBool nan; |
|
511 SplitDD(aValue, iContext, degrees, decidegrees, neg, nan); |
|
512 |
|
513 // cardinal point |
|
514 CEikMfneSymbol *field3; |
|
515 field3 = CEikMfneSymbol::NewL(2); |
|
516 |
|
517 CEikMfneSymbol::CItem *item = CEikMfneSymbol::CItem::NewL(0, |
|
518 iContext == ELatitudeOnly ? 'N' : 'E', |
|
519 CopyDesL(iContext == ELatitudeOnly ? iStrings->iNorth : iStrings->iEast)); |
|
520 CEikMfneSymbol::CItem *item2 = CEikMfneSymbol::CItem::NewL(1, |
|
521 iContext == ELatitudeOnly ? 'S' : 'W', |
|
522 CopyDesL(iContext == ELatitudeOnly ? iStrings->iSouth : iStrings->iWest)); |
|
523 field3->AddSymbolicItem(item, !neg); |
|
524 field3->AddSymbolicItem(item2, neg); |
|
525 |
|
526 if ( iStrings->iMirroredLayoutUsed ) |
|
527 { |
|
528 // Add cardinal point field to first field when reading direction is right-to-left. |
|
529 AddField(field3); |
|
530 } |
|
531 |
|
532 // degrees |
|
533 CEikMfneNumber *field; |
|
534 field = CEikMfneNumber::NewL(*Font(), |
|
535 00, |
|
536 iContext==ELatitudeOnly ? 90 : 180, |
|
537 degrees, |
|
538 flags_fst); |
|
539 AddField(field); |
|
540 |
|
541 // . |
|
542 HBufC* delimiterText=HBufC::NewLC(3); |
|
543 delimiterText->Des().Append(DecimalSeparator()); |
|
544 AddField(CAknMfneSeparator::NewL(*delimiterText)); |
|
545 CleanupStack::PopAndDestroy(); // delimiterText |
|
546 |
|
547 // decidegrees |
|
548 CEikMfneNumber *field2; |
|
549 field2 = CEikMfneNumber::NewL(*Font(), |
|
550 00, |
|
551 99999, |
|
552 decidegrees, |
|
553 flags); |
|
554 field2->SetTrailingZeros(); |
|
555 AddField(field2); |
|
556 |
|
557 // circle |
|
558 HBufC* delimiterText2=HBufC::NewLC(300); |
|
559 delimiterText2->Des().Append(*iStrings->iDegree); |
|
560 AddField(CAknMfneSeparator::NewL(*delimiterText2)); |
|
561 CleanupStack::PopAndDestroy(); // delimiterText |
|
562 |
|
563 if ( !iStrings->iMirroredLayoutUsed ) |
|
564 { |
|
565 // Add cardinal point field to first field when reading direction is left-to-right. |
|
566 AddField(field3); |
|
567 } |
|
568 SetUninitialised(nan); |
|
569 break; |
|
570 } |
|
571 case EDMM: |
|
572 { |
|
573 int degrees; |
|
574 int minutes; |
|
575 int deciminutes; |
|
576 TBool neg; |
|
577 TBool nan; |
|
578 SplitDMM(aValue, iContext, degrees, minutes, deciminutes, neg, nan); |
|
579 |
|
580 // cardinal point |
|
581 CEikMfneSymbol *field4; |
|
582 field4 = CEikMfneSymbol::NewL(2); |
|
583 |
|
584 CEikMfneSymbol::CItem *item = CEikMfneSymbol::CItem::NewL(0, |
|
585 iContext == ELatitudeOnly ? 'N' : 'E', |
|
586 CopyDesL(iContext == ELatitudeOnly ? iStrings->iNorth : iStrings->iEast)); |
|
587 CEikMfneSymbol::CItem *item2 = CEikMfneSymbol::CItem::NewL(1, |
|
588 iContext == ELatitudeOnly ? 'S' : 'W', |
|
589 CopyDesL(iContext == ELatitudeOnly ? iStrings->iSouth : iStrings->iWest)); |
|
590 field4->AddSymbolicItem(item, !neg); |
|
591 field4->AddSymbolicItem(item2, neg); |
|
592 field4->SetUninitialised(nan); |
|
593 |
|
594 if ( iStrings->iMirroredLayoutUsed ) |
|
595 { |
|
596 // Add cardinal point field to first field when reading direction is right-to-left. |
|
597 AddField(field4); |
|
598 } |
|
599 |
|
600 // degrees |
|
601 CEikMfneNumber *field; |
|
602 field = CEikMfneNumber::NewL(*Font(), |
|
603 00, |
|
604 iContext==ELatitudeOnly ? 90 : 180, |
|
605 degrees, |
|
606 flags_fst); |
|
607 field->SetUninitialised(nan); |
|
608 AddField(field); |
|
609 |
|
610 // o |
|
611 HBufC* delimiterText=HBufC::NewLC(3); |
|
612 delimiterText->Des().Append(*iStrings->iDegree); |
|
613 AddField(CAknMfneSeparator::NewL(*delimiterText)); |
|
614 CleanupStack::PopAndDestroy(); // delimiterText |
|
615 |
|
616 // minutes |
|
617 CEikMfneNumber *field2; |
|
618 field2 = CEikMfneNumber::NewL(*Font(), |
|
619 00, |
|
620 59, |
|
621 minutes, |
|
622 flags); |
|
623 field2->SetUninitialised(nan); |
|
624 AddField(field2); |
|
625 |
|
626 // . |
|
627 HBufC* delimiterText2=HBufC::NewLC(3); |
|
628 delimiterText2->Des().Append(DecimalSeparator()); |
|
629 AddField(CAknMfneSeparator::NewL(*delimiterText2)); |
|
630 CleanupStack::PopAndDestroy(); // delimiterText |
|
631 |
|
632 // deciminutes |
|
633 CEikMfneNumber *field3; |
|
634 field3 = CEikMfneNumber::NewL(*Font(), |
|
635 0, |
|
636 9999, |
|
637 deciminutes, |
|
638 flags); |
|
639 field3->SetUninitialised(nan); |
|
640 field3->SetTrailingZeros(); |
|
641 AddField(field3); |
|
642 |
|
643 // ' |
|
644 HBufC* delimiterText3=HBufC::NewLC(3); |
|
645 delimiterText3->Des().Append(*iStrings->iMinMark ); |
|
646 AddField(CAknMfneSeparator::NewL(*delimiterText3)); |
|
647 CleanupStack::PopAndDestroy(); // delimiterText |
|
648 |
|
649 |
|
650 if ( !iStrings->iMirroredLayoutUsed ) |
|
651 { |
|
652 // Add cardinal point field to first field when reading direction is left-to-right. |
|
653 AddField(field4); |
|
654 } |
|
655 SetUninitialised(nan); |
|
656 |
|
657 break; |
|
658 } |
|
659 case EDMSD: |
|
660 { |
|
661 int degrees; |
|
662 int minutes; |
|
663 int secs; |
|
664 int deciseconds; |
|
665 TBool neg; |
|
666 TBool nan; |
|
667 SplitDMSD(aValue, iContext, degrees, minutes, secs, deciseconds, neg, nan); |
|
668 |
|
669 // cardinal point |
|
670 CEikMfneSymbol *field5; |
|
671 field5 = CEikMfneSymbol::NewL(2); |
|
672 |
|
673 CEikMfneSymbol::CItem *item = CEikMfneSymbol::CItem::NewL(0, |
|
674 iContext == ELatitudeOnly ? 'N' : 'E', |
|
675 CopyDesL(iContext == ELatitudeOnly ? iStrings->iNorth : iStrings->iEast)); |
|
676 CEikMfneSymbol::CItem *item2 = CEikMfneSymbol::CItem::NewL(1, |
|
677 iContext == ELatitudeOnly ? 'S' : 'W', |
|
678 CopyDesL(iContext == ELatitudeOnly ? iStrings->iSouth : iStrings->iWest)); |
|
679 field5->AddSymbolicItem(item, !neg); |
|
680 field5->AddSymbolicItem(item2, neg); |
|
681 |
|
682 if ( iStrings->iMirroredLayoutUsed ) |
|
683 { |
|
684 // Add cardinal point field to first field when reading direction is right-to-left. |
|
685 AddField(field5); |
|
686 } |
|
687 |
|
688 // degrees |
|
689 CEikMfneNumber *field; |
|
690 field = CEikMfneNumber::NewL(*Font(), |
|
691 00, |
|
692 iContext==ELatitudeOnly ? 90 : 180, |
|
693 degrees, |
|
694 flags_fst); |
|
695 AddField(field); |
|
696 |
|
697 // o |
|
698 HBufC* delimiterText=HBufC::NewLC(3); |
|
699 delimiterText->Des().Append(*iStrings->iDegree); |
|
700 AddField(CAknMfneSeparator::NewL(*delimiterText)); |
|
701 CleanupStack::PopAndDestroy(); // delimiterText |
|
702 |
|
703 // minutes |
|
704 CEikMfneNumber *field2; |
|
705 field2 = CEikMfneNumber::NewL(*Font(), |
|
706 00, |
|
707 59, |
|
708 minutes, |
|
709 flags); |
|
710 AddField(field2); |
|
711 |
|
712 |
|
713 // ' |
|
714 HBufC* delimiterText3=HBufC::NewLC(3); |
|
715 delimiterText3->Des().Append(*iStrings->iMinMark ); |
|
716 AddField(CAknMfneSeparator::NewL(*delimiterText3)); |
|
717 CleanupStack::PopAndDestroy(); // delimiterText |
|
718 |
|
719 // seconds |
|
720 CEikMfneNumber *field3; |
|
721 field3 = CEikMfneNumber::NewL(*Font(), |
|
722 00, |
|
723 59, |
|
724 secs, |
|
725 flags); |
|
726 AddField(field3); |
|
727 |
|
728 |
|
729 // . |
|
730 HBufC* delimiterText2=HBufC::NewLC(3); |
|
731 delimiterText2->Des().Append(DecimalSeparator()); |
|
732 AddField(CAknMfneSeparator::NewL(*delimiterText2)); |
|
733 CleanupStack::PopAndDestroy(); // delimiterText |
|
734 |
|
735 |
|
736 // deciseconds |
|
737 CEikMfneNumber *field4; |
|
738 field4 = CEikMfneNumber::NewL(*Font(), |
|
739 00, |
|
740 99, |
|
741 deciseconds, |
|
742 flags); |
|
743 field4->SetTrailingZeros(); |
|
744 AddField(field4); |
|
745 |
|
746 |
|
747 // " |
|
748 HBufC* delimiterText4=HBufC::NewLC(3); |
|
749 delimiterText4->Des().Append(*iStrings->iSecMark); |
|
750 AddField(CAknMfneSeparator::NewL(*delimiterText4)); |
|
751 CleanupStack::PopAndDestroy(); // delimiterText |
|
752 |
|
753 if ( !iStrings->iMirroredLayoutUsed ) |
|
754 { |
|
755 // Add cardinal point field to first field when reading direction is left-to-right. |
|
756 AddField(field5); |
|
757 } |
|
758 SetUninitialised(nan); |
|
759 |
|
760 break; |
|
761 } |
|
762 }; |
|
763 HighlightField(FieldMapping(0, type)); |
|
764 } |
|
765 |
|
766 EXPORT_C void CAknLocationEditor::PrepareForFocusLossL() |
|
767 { |
|
768 CEikMfne::PrepareForFocusLossL(); |
|
769 TLocationType type = Type(); |
|
770 CEikMfneNumber *field = (CEikMfneNumber*)Field(FieldMapping(0, type)); |
|
771 TInt degrees = field->Value(); |
|
772 TInt minimum, maximum; |
|
773 field->GetMinimumAndMaximum(minimum, maximum); |
|
774 if (degrees == maximum) |
|
775 { |
|
776 TBool error = EFalse; |
|
777 |
|
778 CEikMfneNumber *field = (CEikMfneNumber*)Field(FieldMapping(2, type)); |
|
779 TInt val = field->Value(); |
|
780 if (val != 0) error = ETrue; |
|
781 TInt cardinalPointFieldNumber = 4; |
|
782 |
|
783 if (type != EDD) |
|
784 { |
|
785 CEikMfneNumber *field = (CEikMfneNumber*)Field(FieldMapping(4, type)); |
|
786 TInt val = field->Value(); |
|
787 if (val != 0) error = ETrue; |
|
788 cardinalPointFieldNumber = 6; |
|
789 } |
|
790 |
|
791 if (type == EDMSD) |
|
792 { |
|
793 CEikMfneNumber *field = (CEikMfneNumber*)Field(FieldMapping(6, type)); |
|
794 TInt val = field->Value(); |
|
795 if (val != 0) error = ETrue; |
|
796 cardinalPointFieldNumber = 8; |
|
797 } |
|
798 |
|
799 CEikMfneSymbol* cardinalPointField = |
|
800 static_cast<CEikMfneSymbol*> |
|
801 ( Field( FieldMapping(cardinalPointFieldNumber, type) ) ); |
|
802 |
|
803 if ( iContext == ELongitudeOnly && |
|
804 cardinalPointField->IdOfCurrentSymbolicItem() == 0 ) |
|
805 { |
|
806 // if represents east.. |
|
807 error = ETrue; |
|
808 cardinalPointField->SetCurrentSymbolicItemToId( 1 ); |
|
809 } |
|
810 |
|
811 if (error) |
|
812 { |
|
813 HighlightField(FieldMapping(0, type)); |
|
814 ((CEikMfneNumber*)Field(FieldMapping(0, type)))->SetValue(maximum, *Font()); |
|
815 ((CEikMfneNumber*)Field(FieldMapping(2, type)))->SetValue(0, *Font()); |
|
816 if (type != EDD) ((CEikMfneNumber*)Field(FieldMapping(4, type)))->SetValue(0, *Font()); |
|
817 if (type == EDMSD) ((CEikMfneNumber*)Field(FieldMapping(6, type)))->SetValue(0, *Font()); |
|
818 CEikMfne::InvalidFieldAlert(); |
|
819 DrawNow(); |
|
820 CBaActiveScheduler::LeaveNoAlert(); |
|
821 } |
|
822 |
|
823 } |
|
824 } |
|
825 |
|
826 CAknLocationEditor::TLocationType CAknLocationEditor::Type() const |
|
827 { |
|
828 if (!iStrings) |
|
829 return EDD; |
|
830 if (iStrings->iType == -1) |
|
831 { |
|
832 CRepository* repository = NULL; |
|
833 TRAPD(err, repository = CRepository::NewL(KCRUidAvkon)); |
|
834 TUint32 key = KAknLocationEditorCoordinateDataFormat; |
|
835 if (err == KErrNone) |
|
836 { |
|
837 err = repository->Get(key, (TInt&)iStrings->iType); |
|
838 } |
|
839 delete repository; |
|
840 } |
|
841 |
|
842 if (iStrings->iType == 0) |
|
843 return EDD; |
|
844 if (iStrings->iType == 1) |
|
845 return EDMM; |
|
846 if (iStrings->iType == 2) |
|
847 return EDMSD; |
|
848 |
|
849 // TODO, shared data keys. |
|
850 //return EDMSD; |
|
851 //return EDMM; |
|
852 return EDD; |
|
853 |
|
854 } |
|
855 |
|
856 void CAknLocationEditor::LoadStringsL(TInt aResourceId) |
|
857 { |
|
858 if (!iStrings) |
|
859 { |
|
860 iStrings = new(ELeave)CLocationStrings; |
|
861 } |
|
862 |
|
863 TResourceReader reader; |
|
864 iCoeEnv->CreateResourceReaderLC(reader, aResourceId); |
|
865 iStrings->iDegree = reader.ReadHBufCL(); |
|
866 iStrings->iMinMark = reader.ReadHBufCL(); |
|
867 iStrings->iSecMark = reader.ReadHBufCL(); |
|
868 iStrings->iNorth = reader.ReadHBufCL(); |
|
869 reader.ReadInt16(); |
|
870 iStrings->iSouth = reader.ReadHBufCL(); |
|
871 reader.ReadInt16(); |
|
872 iStrings->iEast = reader.ReadHBufCL(); |
|
873 reader.ReadInt16(); |
|
874 iStrings->iWest = reader.ReadHBufCL(); |
|
875 reader.ReadInt16(); |
|
876 CleanupStack::PopAndDestroy(); // reader |
|
877 } |
|
878 |
|
879 |
|
880 TInt CAknLocationEditor::FieldMapping(const TInt aFieldNumber, const TLocationType aType) const |
|
881 { |
|
882 if ( iStrings->iMirroredLayoutUsed ) |
|
883 { |
|
884 // Cardinal point field is mapped first field when |
|
885 // reading direction is right-to-left. |
|
886 if ( aType == EDD ) |
|
887 { |
|
888 static const TInt fieldMapping[] = { 1, 2, 3, 4, 0 }; |
|
889 return fieldMapping[aFieldNumber]; |
|
890 } |
|
891 else if ( aType == EDMM) |
|
892 { |
|
893 static const TInt fieldMapping[] = { 1, 2, 3, 4, 5, 6, 0 }; |
|
894 return fieldMapping[aFieldNumber]; |
|
895 } |
|
896 else if ( aType == EDMSD ) |
|
897 { |
|
898 static const TInt fieldMapping[] = { 1, 2, 3, 4, 5, 6, 7, 8, 0 }; |
|
899 return fieldMapping[aFieldNumber]; |
|
900 } |
|
901 } |
|
902 |
|
903 return aFieldNumber; |
|
904 } |
|
905 |
|
906 |
|
907 void CAknLocationEditor::Split(const TPosition &aValue, TLocationContext aContext, |
|
908 TInt &aDegrees, TInt &aDeciDegrees, |
|
909 TInt &aMinutes, TInt &aDeciMinutes, |
|
910 TInt &aSeconds, TInt &aDeciSeconds, |
|
911 TBool &aNeg, TBool &aNan) |
|
912 |
|
913 { |
|
914 TReal64 value = aContext == ELongitudeOnly ? aValue.Longitude() : aValue.Latitude(); |
|
915 |
|
916 if (Math::IsNaN(value)) |
|
917 { |
|
918 aNan = ETrue; |
|
919 aDegrees = 0; |
|
920 aDeciDegrees = 0; |
|
921 aMinutes = 0; |
|
922 aDeciMinutes = 0; |
|
923 aSeconds = 0; |
|
924 aDeciSeconds = 0; |
|
925 return; |
|
926 } |
|
927 aNan = EFalse; |
|
928 |
|
929 // Negative values |
|
930 if (value<0) |
|
931 { |
|
932 aNeg = ETrue; |
|
933 value = -value; |
|
934 } |
|
935 else |
|
936 { |
|
937 aNeg = EFalse; |
|
938 } |
|
939 |
|
940 // rounding... |
|
941 value += TReal64(0.1)/TReal64(360000.0); |
|
942 // Positive values |
|
943 TInt degrees = TInt(value); |
|
944 TReal64 deciDegrees = value - TReal64(degrees); |
|
945 TInt mins = TInt(deciDegrees * 60.0); |
|
946 TReal64 deciMins = deciDegrees*60.0 - TReal64(mins); |
|
947 TInt secs = TInt(deciMins * 60.0); |
|
948 TReal64 deciSecs = deciMins*60.0 - TReal64(secs); |
|
949 |
|
950 TInt deciDegree2 = deciDegrees * 100000.0; |
|
951 TInt deciMins2 = deciMins * 10000.0; |
|
952 TInt deciSecs2 = deciSecs * 100.0; |
|
953 aDegrees = degrees; |
|
954 aDeciDegrees = deciDegree2; |
|
955 aMinutes = mins; |
|
956 aDeciMinutes = deciMins2; |
|
957 aSeconds = secs; |
|
958 aDeciSeconds = deciSecs2; |
|
959 } |
|
960 |
|
961 void CAknLocationEditor::SplitDD(const TPosition &aValue, TLocationContext aContext, TInt &aDegrees, TInt &aDeciDegrees, TBool &aNeg, TBool &aNan) |
|
962 { |
|
963 TInt degs, ddegs; |
|
964 TInt mins, dmins; |
|
965 TInt secs, dsecs; |
|
966 Split(aValue, aContext, degs, ddegs, mins, dmins, secs, dsecs, aNeg, aNan); |
|
967 aDegrees = degs; |
|
968 aDeciDegrees = ddegs; |
|
969 } |
|
970 |
|
971 void CAknLocationEditor::SplitDMM(const TPosition &aValue, TLocationContext aContext, TInt &aDegrees, TInt &aMinutes, TInt &aDeciMinutes, TBool &aNeg, TBool &aNan) |
|
972 { |
|
973 TInt degs, ddegs; |
|
974 TInt mins, dmins; |
|
975 TInt secs, dsecs; |
|
976 Split(aValue, aContext, degs, ddegs, mins, dmins, secs, dsecs, aNeg, aNan); |
|
977 aDegrees = degs; |
|
978 aMinutes = mins; |
|
979 aDeciMinutes = dmins; |
|
980 } |
|
981 |
|
982 void CAknLocationEditor::SplitDMSD(const TPosition &aValue, TLocationContext aContext, TInt &aDegrees, TInt &aMinutes, TInt &aSeconds, TInt &aDeciSeconds, TBool &aNeg, TBool &aNan) |
|
983 { |
|
984 TInt degs, ddegs; |
|
985 TInt mins, dmins; |
|
986 TInt secs, dsecs; |
|
987 Split(aValue, aContext, degs, ddegs, mins, dmins, secs, dsecs, aNeg, aNan); |
|
988 aDegrees = degs; |
|
989 aMinutes = mins; |
|
990 aSeconds = secs; |
|
991 aDeciSeconds = dsecs; |
|
992 } |
|
993 |
|
994 void CAknLocationEditor::CombineDD(TPosition &aValue, TLocationContext aContext, TInt aDegrees, TInt aDeciDegrees, TBool aNeg, TBool aNan) |
|
995 { |
|
996 TReal64 value = TReal64(aDegrees); |
|
997 value += TReal64(aDeciDegrees) / 100000.0; |
|
998 if (aNeg) |
|
999 { |
|
1000 value = -value; |
|
1001 } |
|
1002 if (aNan) |
|
1003 { |
|
1004 TRealX nan; |
|
1005 nan.SetNaN(); |
|
1006 value = nan; |
|
1007 } |
|
1008 |
|
1009 if (aContext == ELongitudeOnly) |
|
1010 { |
|
1011 aValue.SetCoordinate( aValue.Latitude(), value, aValue.Altitude()); |
|
1012 } |
|
1013 else |
|
1014 { |
|
1015 aValue.SetCoordinate( value, aValue.Longitude(), aValue.Altitude()); |
|
1016 } |
|
1017 } |
|
1018 |
|
1019 void CAknLocationEditor::CombineDMM(TPosition &aValue, TLocationContext aContext, TInt aDegrees, TInt aMinutes, TInt aDeciMinutes, TBool aNeg, TBool aNan) |
|
1020 { |
|
1021 TReal64 value = TReal64(aDegrees); |
|
1022 value += TReal64(aMinutes) / 60.0; |
|
1023 value += TReal64(aDeciMinutes) / 10000.0 / 60.0; |
|
1024 if (aNeg) |
|
1025 { |
|
1026 value = -value; |
|
1027 } |
|
1028 if (aNan) |
|
1029 { |
|
1030 TRealX nan; |
|
1031 nan.SetNaN(); |
|
1032 value = nan; |
|
1033 } |
|
1034 |
|
1035 if (aContext == ELongitudeOnly) |
|
1036 { |
|
1037 aValue.SetCoordinate( aValue.Latitude(), value, aValue.Altitude()); |
|
1038 } |
|
1039 else |
|
1040 { |
|
1041 aValue.SetCoordinate( value, aValue.Longitude(), aValue.Altitude()); |
|
1042 } |
|
1043 |
|
1044 } |
|
1045 |
|
1046 void CAknLocationEditor::CombineDMSD(TPosition &aValue, TLocationContext aContext, TInt aDegrees, TInt aMinutes, TInt aSeconds, TInt aDeciSeconds, TBool aNeg, TBool aNan) |
|
1047 { |
|
1048 TReal64 value = TReal64(aDegrees); |
|
1049 value += TReal64(aMinutes) / 60.0; |
|
1050 value += TReal64(aSeconds) / 60.0 / 60.0; |
|
1051 value += TReal64(aDeciSeconds) / 100.0 / 60.0 / 60.0; |
|
1052 if (aNeg) |
|
1053 { |
|
1054 value = -value; |
|
1055 } |
|
1056 if (aNan) |
|
1057 { |
|
1058 TRealX nan; |
|
1059 nan.SetNaN(); |
|
1060 value = nan; |
|
1061 } |
|
1062 |
|
1063 if (aContext == ELongitudeOnly) |
|
1064 { |
|
1065 aValue.SetCoordinate( aValue.Latitude(), value, aValue.Altitude()); |
|
1066 } |
|
1067 else |
|
1068 { |
|
1069 aValue.SetCoordinate( value, aValue.Longitude(), aValue.Altitude()); |
|
1070 } |
|
1071 |
|
1072 } |
|
1073 |
|
1074 void CAknLocationEditor::SetUninitialised(TBool aIsUninitialized) |
|
1075 { |
|
1076 TBool nan = aIsUninitialized; |
|
1077 TLocationType type = Type(); |
|
1078 |
|
1079 switch(type) |
|
1080 { |
|
1081 case EDD: |
|
1082 { |
|
1083 CEikMfneNumber *field; |
|
1084 CEikMfneSymbol *symbol; |
|
1085 CAknMfneSeparator *sep; |
|
1086 |
|
1087 field = (CEikMfneNumber*)Field(FieldMapping(0, type)); |
|
1088 field->SetUninitialised(nan); |
|
1089 |
|
1090 sep = (CAknMfneSeparator*)Field(FieldMapping(1, type)); // . |
|
1091 sep->MakeVisible(!nan); |
|
1092 |
|
1093 field = (CEikMfneNumber*)Field(FieldMapping(2, type)); |
|
1094 field->SetUninitialised(nan); |
|
1095 |
|
1096 sep = (CAknMfneSeparator*)Field(FieldMapping(3, type)); // o |
|
1097 sep->MakeVisible(!nan); |
|
1098 |
|
1099 symbol = (CEikMfneSymbol*)Field(FieldMapping(4, type)); |
|
1100 symbol->SetUninitialised(nan); |
|
1101 break; |
|
1102 } |
|
1103 case EDMM: |
|
1104 { |
|
1105 CEikMfneNumber *field; |
|
1106 CAknMfneSeparator *sep; |
|
1107 CEikMfneSymbol *symbol; |
|
1108 |
|
1109 field = (CEikMfneNumber*)Field(FieldMapping(0, type)); |
|
1110 field->SetUninitialised(nan); |
|
1111 |
|
1112 sep = (CAknMfneSeparator*)Field(FieldMapping(1, type)); // |
|
1113 sep->MakeVisible(!nan); |
|
1114 |
|
1115 field = (CEikMfneNumber*)Field(FieldMapping(2, type)); |
|
1116 field->SetUninitialised(nan); |
|
1117 |
|
1118 sep = (CAknMfneSeparator*)Field(FieldMapping(3, type)); |
|
1119 sep->MakeVisible(!nan); |
|
1120 |
|
1121 field = (CEikMfneNumber*)Field(FieldMapping(4, type)); |
|
1122 field->SetUninitialised(nan); |
|
1123 |
|
1124 sep = (CAknMfneSeparator*)Field(FieldMapping(5, type)); |
|
1125 sep->MakeVisible(!nan); |
|
1126 |
|
1127 symbol = (CEikMfneSymbol*)Field(FieldMapping(6, type)); |
|
1128 symbol->SetUninitialised(nan); |
|
1129 break; |
|
1130 } |
|
1131 case EDMSD: |
|
1132 { |
|
1133 CEikMfneNumber *field; |
|
1134 CAknMfneSeparator *sep; |
|
1135 CEikMfneSymbol *symbol; |
|
1136 |
|
1137 field = (CEikMfneNumber*)Field(FieldMapping(0, type)); |
|
1138 field->SetUninitialised(nan); |
|
1139 |
|
1140 sep = (CAknMfneSeparator*)Field(FieldMapping(1, type)); |
|
1141 sep->MakeVisible(!nan); |
|
1142 |
|
1143 field = (CEikMfneNumber*)Field(FieldMapping(2, type)); |
|
1144 field->SetUninitialised(nan); |
|
1145 |
|
1146 sep = (CAknMfneSeparator*)Field(FieldMapping(3, type)); |
|
1147 sep->MakeVisible(!nan); |
|
1148 |
|
1149 field = (CEikMfneNumber*)Field(FieldMapping(4, type)); |
|
1150 field->SetUninitialised(nan); |
|
1151 |
|
1152 sep = (CAknMfneSeparator*)Field(FieldMapping(5, type)); |
|
1153 sep->MakeVisible(!nan); |
|
1154 |
|
1155 field = (CEikMfneNumber*)Field(FieldMapping(6, type)); |
|
1156 field->SetUninitialised(nan); |
|
1157 |
|
1158 sep = (CAknMfneSeparator*)Field(FieldMapping(7, type)); |
|
1159 sep->MakeVisible(!nan); |
|
1160 |
|
1161 symbol = (CEikMfneSymbol*)Field(FieldMapping(8, type)); |
|
1162 symbol->SetUninitialised(nan); |
|
1163 break; |
|
1164 } |
|
1165 } |
|
1166 } |
|
1167 |
|
1168 void CAknLocationEditor::RefreshFromLocale() |
|
1169 { |
|
1170 const CFont &font = *Font(); |
|
1171 TLocationType type = Type(); |
|
1172 switch(type) |
|
1173 { |
|
1174 case EDD: |
|
1175 { |
|
1176 CEikMfneNumber *field; |
|
1177 field = (CEikMfneNumber*)Field(FieldMapping(0, type)); |
|
1178 field->RefreshDigitType(font); |
|
1179 |
|
1180 field = (CEikMfneNumber*)Field(FieldMapping(2, type)); |
|
1181 field->RefreshDigitType(font); |
|
1182 break; |
|
1183 } |
|
1184 case EDMM: |
|
1185 { |
|
1186 CEikMfneNumber *field; |
|
1187 field = (CEikMfneNumber*)Field(FieldMapping(0, type)); |
|
1188 field->RefreshDigitType(font); |
|
1189 |
|
1190 field = (CEikMfneNumber*)Field(FieldMapping(2, type)); |
|
1191 field->RefreshDigitType(font); |
|
1192 |
|
1193 field = (CEikMfneNumber*)Field(FieldMapping(4, type)); |
|
1194 field->RefreshDigitType(font); |
|
1195 break; |
|
1196 } |
|
1197 case EDMSD: |
|
1198 { |
|
1199 CEikMfneNumber *field; |
|
1200 field = (CEikMfneNumber*)Field(FieldMapping(0, type)); |
|
1201 field->RefreshDigitType(font); |
|
1202 |
|
1203 field = (CEikMfneNumber*)Field(FieldMapping(2, type)); |
|
1204 field->RefreshDigitType(font); |
|
1205 |
|
1206 field = (CEikMfneNumber*)Field(FieldMapping(4, type)); |
|
1207 field->RefreshDigitType(font); |
|
1208 |
|
1209 field = (CEikMfneNumber*)Field(FieldMapping(6, type)); |
|
1210 field->RefreshDigitType(font); |
|
1211 break; |
|
1212 } |
|
1213 } |
|
1214 } |
|
1215 |
|
1216 EXPORT_C TKeyResponse CAknLocationEditor::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) |
|
1217 { |
|
1218 if (aType == EEventKey && ((aKeyEvent.iCode >= '0' && aKeyEvent.iCode <= '9') |
|
1219 || aKeyEvent.iCode == EKeyLeftArrow || aKeyEvent.iCode == EKeyRightArrow)) |
|
1220 { |
|
1221 TInt firstField( FieldMapping( 0, Type() ) ); |
|
1222 CEikMfneNumber* field( (CEikMfneNumber*)Field( firstField ) ); |
|
1223 if ( field->IsUninitialised() ) |
|
1224 { |
|
1225 SetCurrentField( firstField ); |
|
1226 } |
|
1227 SetUninitialised(EFalse); |
|
1228 |
|
1229 DrawNow(); |
|
1230 } |
|
1231 return CEikMfne::OfferKeyEventL(aKeyEvent, aType); |
|
1232 } |
|
1233 |
|
1234 void CAknLocationEditor::HandleCenRepChangedL(TUint32, TInt) |
|
1235 { |
|
1236 TPosition pos; |
|
1237 Get(pos); |
|
1238 iStrings->iType = -1; |
|
1239 ResetFieldArray(); |
|
1240 CreateMfneFieldsL(pos); |
|
1241 RefreshFromLocale(); |
|
1242 MfneSize(); |
|
1243 DrawDeferred(); |
|
1244 } |
|
1245 |
|
1246 EXPORT_C void* CAknLocationEditor::CAknLocationEditor_ExtensionInterface( TUid /*aInterface*/ ) |
|
1247 { |
|
1248 return 0; |
|
1249 } |
|
1250 |