13 * |
13 * |
14 * Description: ESMR date field impl. |
14 * Description: ESMR date field impl. |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "emailtrace.h" |
|
19 #include "cesmrdatefield.h" |
18 #include "cesmrdatefield.h" |
20 |
|
21 #include <eikmfne.h> |
|
22 #include <avkon.hrh> |
|
23 #include <AknsConstants.h> |
|
24 #include <AknUtils.h> |
|
25 #include <AknsDrawUtils.h> |
|
26 #include <AknsFrameBackgroundControlContext.h> |
|
27 //<cmail> |
|
28 #include "esmrdef.h" |
|
29 //</cmail> |
|
30 |
|
31 #include "cesmrmeetingtimevalidator.h" |
19 #include "cesmrmeetingtimevalidator.h" |
32 #include "cesmrglobalnote.h" |
20 #include "cesmrglobalnote.h" |
33 #include "esmrfieldbuilderdef.h" |
21 #include "esmrfieldbuilderdef.h" |
34 #include "mesmrlistobserver.h" |
22 #include "mesmrlistobserver.h" |
35 #include "cesmrgenericfieldevent.h" |
23 #include "cesmrgenericfieldevent.h" |
|
24 #include "cmrimage.h" |
|
25 #include "nmrlayoutmanager.h" |
|
26 #include "nmrcolormanager.h" |
|
27 #include "nmrbitmapmanager.h" |
|
28 |
|
29 #include <aknsbasicbackgroundcontrolcontext.h> |
|
30 |
|
31 #include <eikmfne.h> |
|
32 //<cmail> |
|
33 #include "esmrdef.h" |
|
34 //</cmail> |
|
35 |
|
36 #include "emailtrace.h" |
36 |
37 |
37 // ======== MEMBER FUNCTIONS ======== |
38 // ======== MEMBER FUNCTIONS ======== |
38 |
39 |
39 // --------------------------------------------------------------------------- |
40 // --------------------------------------------------------------------------- |
40 // CESMRDateField::CESMRDateField |
41 // CESMRDateField::CESMRDateField |
41 // --------------------------------------------------------------------------- |
42 // --------------------------------------------------------------------------- |
42 // |
43 // |
43 CESMRDateField::CESMRDateField( |
44 CESMRDateField::CESMRDateField( MESMRFieldValidator* aValidator ) |
44 MESMRFieldValidator* aValidator ) : |
45 { |
45 iValidator(aValidator) |
46 FUNC_LOG; |
46 { |
47 |
47 FUNC_LOG; |
48 iValidator = aValidator; |
48 //do nothing |
49 |
|
50 SetFocusType( EESMRHighlightFocus ); |
49 } |
51 } |
50 |
52 |
51 // --------------------------------------------------------------------------- |
53 // --------------------------------------------------------------------------- |
52 // CESMRDateField::~CESMRDateField |
54 // CESMRDateField::~CESMRDateField |
53 // --------------------------------------------------------------------------- |
55 // --------------------------------------------------------------------------- |
54 // |
56 // |
55 CESMRDateField::~CESMRDateField( ) |
57 CESMRDateField::~CESMRDateField() |
56 { |
58 { |
57 FUNC_LOG; |
59 FUNC_LOG; |
58 delete iFrameBgContext; |
60 delete iFieldIcon; |
|
61 delete iBgCtrlContext; |
59 } |
62 } |
60 |
63 |
61 // --------------------------------------------------------------------------- |
64 // --------------------------------------------------------------------------- |
62 // CESMRDateField::NewL |
65 // CESMRDateField::NewL |
63 // --------------------------------------------------------------------------- |
66 // --------------------------------------------------------------------------- |
80 // |
83 // |
81 void CESMRDateField::ConstructL( TESMREntryFieldId aId ) |
84 void CESMRDateField::ConstructL( TESMREntryFieldId aId ) |
82 { |
85 { |
83 FUNC_LOG; |
86 FUNC_LOG; |
84 SetFieldId ( aId ); |
87 SetFieldId ( aId ); |
85 |
88 SetComponentsToInheritVisibility( ETrue ); |
|
89 |
86 TTime startTime; |
90 TTime startTime; |
87 startTime.UniversalTime ( ); |
91 startTime.UniversalTime(); |
88 |
92 |
89 iDate = new (ELeave) CEikDateEditor; |
93 iDate = new( ELeave )CEikDateEditor; |
90 iDate->ConstructL( TTIME_MINIMUMDATE, TTIME_MAXIMUMDATE, startTime, EFalse ); |
94 iDate->ConstructL( |
91 iDate->SetUpAndDownKeysConsumed ( EFalse ); |
95 TTIME_MINIMUMDATE, TTIME_MAXIMUMDATE, startTime, EFalse ); |
92 |
96 iDate->SetUpAndDownKeysConsumed( EFalse ); |
93 TAknsItemID aIconID = (iFieldId == EESMRFieldStartDate) ? KAknsIIDQgnMeetReqIndiDateStart |
97 |
94 : KAknsIIDQgnMeetReqIndiDateEnd; |
98 CESMRField::ConstructL( iDate ); //ownership transferred |
95 |
99 |
96 iBackground = AknsDrawUtils::ControlContext( this ); |
100 NMRBitmapManager::TMRBitmapId iconId = |
97 CESMRIconField::ConstructL( aIconID, iDate ); // ownership transferred |
101 ( iFieldId == EESMRFieldStartDate ) ? |
|
102 NMRBitmapManager::EMRBitmapDateStart : |
|
103 NMRBitmapManager::EMRBitmapDateEnd; |
|
104 |
|
105 iFieldIcon = CMRImage::NewL( iconId ); |
|
106 iFieldIcon->SetParent( this ); |
98 |
107 |
99 // Initialize validator |
108 // Initialize validator |
100 if ( iValidator ) |
109 InitializeValidatorL(); |
101 { |
110 |
102 switch ( iFieldId ) |
111 // Setting background instead of theme skin |
103 { |
112 TRect tempRect(0, 0, 0, 0); |
104 case EESMRFieldStartDate: |
113 NMRBitmapManager::TMRBitmapStruct bitmapStruct; |
105 iValidator->SetStartDateFieldL( *iDate ); |
114 bitmapStruct = NMRBitmapManager::GetBitmapStruct( NMRBitmapManager::EMRBitmapInputCenter ); |
106 break; |
115 |
107 case EESMRFieldStopDate: |
116 iBgCtrlContext = CAknsBasicBackgroundControlContext::NewL( |
108 iValidator->SetEndDateFieldL( *iDate ); |
117 bitmapStruct.iItemId, |
109 break; |
118 tempRect, |
110 case EESMRFieldAlarmDate: |
119 EFalse ); |
111 iValidator->SetAlarmDateFieldL( *iDate ); |
120 |
112 break; |
121 iDate->SetSkinBackgroundControlContextL( iBgCtrlContext ); |
113 default: |
|
114 break; |
|
115 } |
|
116 } |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // CESMRDateField::InitializeL |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 void CESMRDateField::InitializeL() |
|
124 { |
|
125 FUNC_LOG; |
|
126 iDate->SetFont( iLayout->Font(iCoeEnv, iFieldId ) ); |
|
127 iDate->SetMfneAlignment( CESMRLayoutManager::IsMirrored() |
|
128 ? EAknEditorAlignRight : EAknEditorAlignLeft ); |
|
129 |
|
130 iDate->SetSkinTextColorL( iLayout->NormalTextColorID() ); |
|
131 iDate->SetBorder( TGulBorder::ENone ); |
|
132 } |
122 } |
133 |
123 |
134 // --------------------------------------------------------------------------- |
124 // --------------------------------------------------------------------------- |
135 // CESMRDateField::OkToLoseFocusL |
125 // CESMRDateField::OkToLoseFocusL |
136 // --------------------------------------------------------------------------- |
126 // --------------------------------------------------------------------------- |
150 TEventCode aType ) |
140 TEventCode aType ) |
151 { |
141 { |
152 FUNC_LOG; |
142 FUNC_LOG; |
153 TKeyResponse response( EKeyWasNotConsumed); |
143 TKeyResponse response( EKeyWasNotConsumed); |
154 |
144 |
|
145 TInt fieldIndex( iDate->CurrentField() ); |
|
146 |
155 if ( aType == EEventKey ) |
147 if ( aType == EEventKey ) |
156 { |
148 { |
157 TInt fieldIndex( iDate->CurrentField() ); |
|
158 |
149 |
159 // flowthrough, these events shouldn't be consumed |
150 // flowthrough, these events shouldn't be consumed |
160 if ( aEvent.iScanCode != EStdKeyUpArrow && |
151 if ( aEvent.iScanCode != EStdKeyUpArrow && |
161 aEvent.iScanCode != EStdKeyDownArrow ) |
152 aEvent.iScanCode != EStdKeyDownArrow ) |
162 { |
153 { |
163 response = iDate->OfferKeyEventL( aEvent, aType ); |
154 response = iDate->OfferKeyEventL( aEvent, aType ); |
|
155 iDate->DrawDeferred(); |
164 } |
156 } |
165 } |
157 } |
166 |
158 |
|
159 TInt endIndex( iDate->CurrentField()); |
|
160 |
|
161 if ( ( response == EKeyWasConsumed ) && |
|
162 ( fieldIndex != endIndex) ) |
|
163 { |
|
164 CheckIfValidatingNeededL ( fieldIndex ); |
|
165 } |
|
166 |
167 return response; |
167 return response; |
168 } |
|
169 |
|
170 // --------------------------------------------------------------------------- |
|
171 // CESMRDateField::PositionChanged() |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 void CESMRDateField::PositionChanged() |
|
175 { |
|
176 FUNC_LOG; |
|
177 CCoeControl::PositionChanged(); |
|
178 if( iFrameBgContext ) |
|
179 { |
|
180 iFrameBgContext->SetFrameRects( iDate->Rect(), iDate->Rect() ); |
|
181 } |
|
182 } |
|
183 |
|
184 // --------------------------------------------------------------------------- |
|
185 // CESMRDateField::ActivateL |
|
186 // --------------------------------------------------------------------------- |
|
187 // |
|
188 void CESMRDateField::ActivateL() |
|
189 { |
|
190 FUNC_LOG; |
|
191 CCoeControl::ActivateL(); |
|
192 TRect rect(TPoint(iDate->Position()), iDate->Size()); |
|
193 TRect inner(rect); |
|
194 TRect outer(rect); |
|
195 |
|
196 iDate->SetSize(iLayout->FieldSize( FieldId() )); |
|
197 |
|
198 delete iFrameBgContext; |
|
199 iFrameBgContext = NULL; |
|
200 iFrameBgContext = CAknsFrameBackgroundControlContext::NewL(KAknsIIDQsnFrInput, outer, inner, EFalse ) ; |
|
201 |
|
202 iFrameBgContext->SetParentContext( iBackground ); |
|
203 iDate->SetSkinBackgroundControlContextL(iFrameBgContext); |
|
204 } |
168 } |
205 |
169 |
206 // --------------------------------------------------------------------------- |
170 // --------------------------------------------------------------------------- |
207 // CESMRDateField::CheckIfValidatingNeededL |
171 // CESMRDateField::CheckIfValidatingNeededL |
208 // --------------------------------------------------------------------------- |
172 // --------------------------------------------------------------------------- |
295 { |
271 { |
296 FUNC_LOG; |
272 FUNC_LOG; |
297 CESMRField::SetOutlineFocusL ( aFocus ); |
273 CESMRField::SetOutlineFocusL ( aFocus ); |
298 if ( aFocus ) |
274 if ( aFocus ) |
299 { |
275 { |
300 ChangeMiddleSoftKeyL(EESMRCmdSaveMR,R_QTN_MSK_SAVE); |
276 ChangeMiddleSoftKeyL( EESMRCmdSaveMR,R_QTN_MSK_SAVE ); |
301 } |
277 } |
|
278 } |
|
279 |
|
280 // --------------------------------------------------------------------------- |
|
281 // CESMRDateField::SetValidatorL |
|
282 // --------------------------------------------------------------------------- |
|
283 // |
|
284 void CESMRDateField::SetValidatorL( MESMRFieldValidator* aValidator ) |
|
285 { |
|
286 CESMRField::SetValidatorL( aValidator ); |
|
287 InitializeValidatorL(); |
|
288 } |
|
289 |
|
290 // --------------------------------------------------------------------------- |
|
291 // CESMRDateField::SizeChanged() |
|
292 // --------------------------------------------------------------------------- |
|
293 // |
|
294 TBool CESMRDateField::ExecuteGenericCommandL( TInt aCommand ) |
|
295 { |
|
296 FUNC_LOG; |
|
297 |
|
298 TBool retValue( EFalse ); |
|
299 |
|
300 if ( EMRCmdDoEnvironmentChange == aCommand ) |
|
301 { |
|
302 DoEnvChangeL(); |
|
303 retValue = ETrue; |
|
304 } |
|
305 |
|
306 return retValue; |
|
307 } |
|
308 |
|
309 |
|
310 // --------------------------------------------------------------------------- |
|
311 // CESMRDateField::CountComponentControls |
|
312 // --------------------------------------------------------------------------- |
|
313 // |
|
314 TInt CESMRDateField::CountComponentControls( ) const |
|
315 { |
|
316 FUNC_LOG; |
|
317 TInt count( 0 ); |
|
318 if( iFieldIcon ) |
|
319 { |
|
320 ++count; |
|
321 } |
|
322 if( iDate ) |
|
323 { |
|
324 ++count; |
|
325 } |
|
326 |
|
327 return count; |
|
328 } |
|
329 |
|
330 // --------------------------------------------------------------------------- |
|
331 // CESMRDateField::ComponentControl |
|
332 // --------------------------------------------------------------------------- |
|
333 // |
|
334 CCoeControl* CESMRDateField::ComponentControl( TInt aInd ) const |
|
335 { |
|
336 FUNC_LOG; |
|
337 |
|
338 switch ( aInd ) |
|
339 { |
|
340 case 0: |
|
341 return iFieldIcon; |
|
342 case 1: |
|
343 return iDate; |
|
344 default: |
|
345 return NULL; |
|
346 } |
|
347 } |
|
348 |
|
349 // --------------------------------------------------------------------------- |
|
350 // CESMRDateField::SizeChanged |
|
351 // --------------------------------------------------------------------------- |
|
352 // |
|
353 void CESMRDateField::SizeChanged() |
|
354 { |
|
355 FUNC_LOG; |
|
356 TRect rect( Rect() ); |
|
357 |
|
358 // Layouting field icon |
|
359 if( iFieldIcon ) |
|
360 { |
|
361 TAknWindowComponentLayout iconLayout = |
|
362 NMRLayoutManager::GetWindowComponentLayout( |
|
363 NMRLayoutManager::EMRLayoutDateEditorIcon ); |
|
364 AknLayoutUtils::LayoutImage( iFieldIcon, rect, iconLayout ); |
|
365 } |
|
366 |
|
367 // Layouting date editor |
|
368 if( iDate ) |
|
369 { |
|
370 TAknLayoutRect bgLayoutRect = |
|
371 NMRLayoutManager::GetLayoutRect( |
|
372 rect, NMRLayoutManager::EMRLayoutTextEditorBg ); |
|
373 TRect bgRect( bgLayoutRect.Rect() ); |
|
374 // Move focus rect so that it's relative to field's position. |
|
375 bgRect.Move( -Position() ); |
|
376 SetFocusRect( bgRect ); |
|
377 |
|
378 TAknTextComponentLayout editorLayout = |
|
379 NMRLayoutManager::GetTextComponentLayout( |
|
380 NMRLayoutManager::EMRTextLayoutDateEditor ); |
|
381 AknLayoutUtils::LayoutMfne( iDate, rect, editorLayout ); |
|
382 |
|
383 NMRColorManager::SetColor( *iDate, |
|
384 NMRColorManager::EMRMainAreaTextColor ); |
|
385 } |
|
386 } |
|
387 |
|
388 // --------------------------------------------------------------------------- |
|
389 // CESMRDateField::SetContainerWindowL |
|
390 // --------------------------------------------------------------------------- |
|
391 // |
|
392 void CESMRDateField::SetContainerWindowL( |
|
393 const CCoeControl& aContainer ) |
|
394 { |
|
395 iContainerWindow = &aContainer; |
|
396 |
|
397 CCoeControl::SetContainerWindowL( *iContainerWindow ); |
|
398 iDate->SetContainerWindowL( *iContainerWindow ); |
|
399 iFieldIcon->SetContainerWindowL( *iContainerWindow ); |
|
400 |
|
401 iDate->SetParent( this ); |
|
402 iFieldIcon->SetParent( this ); |
|
403 } |
|
404 |
|
405 // --------------------------------------------------------------------------- |
|
406 // CESMRDateField::InitializeValidatorL |
|
407 // --------------------------------------------------------------------------- |
|
408 // |
|
409 void CESMRDateField::InitializeValidatorL() |
|
410 { |
|
411 FUNC_LOG; |
|
412 |
|
413 // Initialize validator |
|
414 if ( iValidator ) |
|
415 { |
|
416 switch ( iFieldId ) |
|
417 { |
|
418 case EESMRFieldStartDate: |
|
419 iValidator->SetStartDateFieldL( *iDate ); |
|
420 break; |
|
421 case EESMRFieldStopDate: |
|
422 iValidator->SetEndDateFieldL( *iDate ); |
|
423 break; |
|
424 case EESMRFieldAlarmDate: |
|
425 iValidator->SetAlarmDateFieldL( *iDate ); |
|
426 break; |
|
427 default: |
|
428 break; |
|
429 } |
|
430 } |
|
431 } |
|
432 |
|
433 // --------------------------------------------------------------------------- |
|
434 // CESMRDateField::DoEnvChangeL |
|
435 // --------------------------------------------------------------------------- |
|
436 // |
|
437 void CESMRDateField::DoEnvChangeL() |
|
438 { |
|
439 FUNC_LOG; |
|
440 |
|
441 CEikDateEditor* date = new( ELeave )CEikDateEditor; |
|
442 CleanupStack::PushL( date ); |
|
443 |
|
444 TTime startTime; |
|
445 startTime.UniversalTime(); |
|
446 |
|
447 date->ConstructL( |
|
448 TTIME_MINIMUMDATE, |
|
449 TTIME_MAXIMUMDATE, |
|
450 startTime, |
|
451 EFalse ); |
|
452 |
|
453 date->SetUpAndDownKeysConsumed( EFalse ); |
|
454 |
|
455 UpdateExtControlL( date ); |
|
456 |
|
457 CleanupStack::Pop( date ); |
|
458 iDate = date; |
|
459 InitializeValidatorL(); |
|
460 |
|
461 iDate->SetSkinBackgroundControlContextL( iBgCtrlContext ); |
|
462 SetContainerWindowL( *iContainerWindow ); |
|
463 |
|
464 iDate->ActivateL(); |
|
465 SizeChanged(); |
|
466 DrawDeferred(); |
302 } |
467 } |
303 |
468 |
304 // EOF |
469 // EOF |