13 * |
13 * |
14 * Description: ESMR repeat until field implementation |
14 * Description: ESMR repeat until field implementation |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "emailtrace.h" |
18 |
19 #include "cesmrrepeatuntil.h" |
19 #include "cesmrrepeatuntil.h" |
20 |
|
21 #include <AknUtils.h> |
|
22 #include <eikmfne.h> |
|
23 #include <avkon.hrh> |
|
24 #include <eiklabel.h> |
|
25 #include <StringLoader.h> |
|
26 #include <AknsDrawUtils.h> |
|
27 #include <AknsFrameBackgroundControlContext.h> |
|
28 #include <esmrgui.rsg> |
|
29 |
|
30 #include "cesmrborderlayer.h" |
|
31 #include "mesmrfieldvalidator.h" |
20 #include "mesmrfieldvalidator.h" |
32 #include "cesmrglobalnote.h" |
21 #include "cesmrglobalnote.h" |
33 #include "esmrfieldbuilderdef.h" |
22 #include "esmrfieldbuilderdef.h" |
34 #include "cesmrlayoutmgr.h" |
23 #include "nmrlayoutmanager.h" |
35 |
24 #include "nmrcolormanager.h" |
36 using namespace ESMRLayout; |
25 #include "cmrlabel.h" |
|
26 #include "nmrbitmapmanager.h" |
|
27 |
|
28 #include <eikmfne.h> |
|
29 #include <stringloader.h> |
|
30 #include <esmrgui.rsg> |
|
31 #include <aknsbasicbackgroundcontrolcontext.h> |
|
32 |
|
33 #include "emailtrace.h" |
37 |
34 |
38 // ======== MEMBER FUNCTIONS ======== |
35 // ======== MEMBER FUNCTIONS ======== |
39 |
36 |
40 // --------------------------------------------------------------------------- |
37 // --------------------------------------------------------------------------- |
41 // CESMRRepeatUntilField::CESMRRepeatUntilField |
38 // CESMRRepeatUntilField::CESMRRepeatUntilField |
42 // --------------------------------------------------------------------------- |
39 // --------------------------------------------------------------------------- |
43 // |
40 // |
44 CESMRRepeatUntilField::CESMRRepeatUntilField( |
41 CESMRRepeatUntilField::CESMRRepeatUntilField( |
45 MESMRFieldValidator* aValidator ) |
42 MESMRFieldValidator* aValidator ) |
46 : iValidator(aValidator) |
43 { |
47 { |
44 FUNC_LOG; |
48 FUNC_LOG; |
45 |
49 //do nothing |
46 iValidator = aValidator; |
|
47 SetFieldId( EESMRFieldRecurrenceDate ); |
|
48 SetFocusType( EESMRHighlightFocus ); |
50 } |
49 } |
51 |
50 |
52 // --------------------------------------------------------------------------- |
51 // --------------------------------------------------------------------------- |
53 // CESMRRepeatUntilField::~CESMRRepeatUntilField |
52 // CESMRRepeatUntilField::~CESMRRepeatUntilField |
54 // --------------------------------------------------------------------------- |
53 // --------------------------------------------------------------------------- |
55 // |
54 // |
56 CESMRRepeatUntilField::~CESMRRepeatUntilField( ) |
55 CESMRRepeatUntilField::~CESMRRepeatUntilField( ) |
57 { |
56 { |
58 FUNC_LOG; |
57 FUNC_LOG; |
59 delete iLabel; |
58 delete iLabel; |
60 delete iFrameBgContext; |
59 delete iBgCtrlContext; |
61 } |
60 } |
62 |
61 |
63 // --------------------------------------------------------------------------- |
62 // --------------------------------------------------------------------------- |
64 // CESMRRepeatUntilField::NewL |
63 // CESMRRepeatUntilField::NewL |
65 // --------------------------------------------------------------------------- |
64 // --------------------------------------------------------------------------- |
67 CESMRRepeatUntilField* CESMRRepeatUntilField::NewL( |
66 CESMRRepeatUntilField* CESMRRepeatUntilField::NewL( |
68 MESMRFieldValidator* aValidator ) |
67 MESMRFieldValidator* aValidator ) |
69 { |
68 { |
70 FUNC_LOG; |
69 FUNC_LOG; |
71 CESMRRepeatUntilField* self = |
70 CESMRRepeatUntilField* self = |
72 new (ELeave) CESMRRepeatUntilField( aValidator ); |
71 new( ELeave )CESMRRepeatUntilField( aValidator ); |
73 CleanupStack::PushL ( self ); |
72 CleanupStack::PushL( self ); |
74 self->ConstructL ( ); |
73 self->ConstructL(); |
75 CleanupStack::Pop ( self ); |
74 CleanupStack::Pop( self ); |
76 return self; |
75 return self; |
77 } |
76 } |
78 |
77 |
79 // --------------------------------------------------------------------------- |
78 // --------------------------------------------------------------------------- |
80 // CESMRRepeatUntilField::ConstructL |
79 // CESMRRepeatUntilField::ConstructL |
81 // --------------------------------------------------------------------------- |
80 // --------------------------------------------------------------------------- |
82 // |
81 // |
83 void CESMRRepeatUntilField::ConstructL( ) |
82 void CESMRRepeatUntilField::ConstructL( ) |
84 { |
83 { |
85 FUNC_LOG; |
84 FUNC_LOG; |
|
85 SetComponentsToInheritVisibility( ETrue ); |
86 HBufC* label = StringLoader::LoadLC( R_QTN_MEET_REQ_REPEAT_UNTIL ); |
86 HBufC* label = StringLoader::LoadLC( R_QTN_MEET_REQ_REPEAT_UNTIL ); |
87 SetFieldId ( EESMRFieldRecurrenceDate ); |
87 |
88 iLabel = new (ELeave) CEikLabel(); |
88 iLabel = CMRLabel::NewL(); |
89 iLabel->SetTextL ( *label ); |
89 iLabel->SetParent( this ); |
|
90 iLabel->SetTextL( *label ); |
90 CleanupStack::PopAndDestroy( label ); |
91 CleanupStack::PopAndDestroy( label ); |
91 |
92 |
92 TTime startTime; |
93 TTime startTime; |
93 startTime.UniversalTime ( ); |
94 startTime.UniversalTime(); |
94 |
95 |
95 iDate = new (ELeave) CEikDateEditor; |
96 iDate = new( ELeave )CEikDateEditor; |
|
97 CESMRField::ConstructL( iDate ); //ownership transferred |
|
98 |
96 iDate->ConstructL( |
99 iDate->ConstructL( |
97 KAknMinimumDate, |
100 KAknMinimumDate, |
98 TTIME_MAXIMUMDATE, |
101 TTIME_MAXIMUMDATE, |
99 startTime, |
102 startTime, |
100 EFalse ); |
103 EFalse ); |
|
104 |
101 iDate->SetUpAndDownKeysConsumed ( EFalse ); |
105 iDate->SetUpAndDownKeysConsumed ( EFalse ); |
102 |
106 |
103 iBackground = AknsDrawUtils::ControlContext( this ); |
|
104 CESMRField::ConstructL ( iDate ); |
|
105 |
|
106 if ( iValidator ) |
107 if ( iValidator ) |
107 { |
108 { |
108 iValidator->SetRecurrenceUntilDateFieldL( *iDate ); |
109 iValidator->SetRecurrenceUntilDateFieldL( *iDate ); |
109 } |
110 } |
110 } |
111 |
111 |
112 TRect tempRect( 0, 0, 0, 0 ); |
112 // --------------------------------------------------------------------------- |
113 |
113 // CESMRRepeatUntilField::InitializeL |
114 // Setting background instead of theme skin |
114 // --------------------------------------------------------------------------- |
115 NMRBitmapManager::TMRBitmapStruct bitmapStruct; |
115 // |
116 bitmapStruct = NMRBitmapManager::GetBitmapStruct( NMRBitmapManager::EMRBitmapInputCenter ); |
116 void CESMRRepeatUntilField::InitializeL() |
117 |
117 { |
118 iBgCtrlContext = CAknsBasicBackgroundControlContext::NewL( |
118 FUNC_LOG; |
119 bitmapStruct.iItemId, |
119 iLabel->SetFont( iLayout->Font( iCoeEnv, iFieldId ) ); |
120 tempRect, |
120 iLabel->SetLabelAlignment( CESMRLayoutManager::IsMirrored ( ) |
121 EFalse ); |
121 ? ELayoutAlignRight : ELayoutAlignLeft ); |
122 |
122 AknLayoutUtils::OverrideControlColorL( |
123 iDate->SetSkinBackgroundControlContextL( iBgCtrlContext ); |
123 *iLabel, |
124 } |
124 EColorLabelText, |
125 |
125 iLayout->GeneralListAreaTextColor() ); |
126 // --------------------------------------------------------------------------- |
126 |
127 // CESMRRepeatUntilField::MinimumSize |
127 iDate->SetFont( iLayout->Font( iCoeEnv, iFieldId ) ); |
128 // --------------------------------------------------------------------------- |
128 iDate->SetMfneAlignment( CESMRLayoutManager::IsMirrored ( ) |
129 // |
129 ? EAknEditorAlignRight : EAknEditorAlignLeft ); |
130 TSize CESMRRepeatUntilField::MinimumSize() |
130 iDate->SetSkinTextColorL( iLayout->NormalTextColorID() ); |
131 { |
|
132 TRect parentRect( Parent()->Rect() ); |
|
133 |
|
134 TRect richTextRect = |
|
135 NMRLayoutManager::GetFieldLayoutRect( parentRect, 1 ).Rect(); |
|
136 |
|
137 // Add title area to the required size |
|
138 TSize titleSize( CESMRField::MinimumSize() ); |
|
139 |
|
140 TSize completeFieldSize( titleSize ); |
|
141 completeFieldSize.iHeight += richTextRect.Height(); |
|
142 |
|
143 return completeFieldSize; |
131 } |
144 } |
132 |
145 |
133 // --------------------------------------------------------------------------- |
146 // --------------------------------------------------------------------------- |
134 // CESMRRepeatUntilField::OkToLoseFocusL |
147 // CESMRRepeatUntilField::OkToLoseFocusL |
135 // --------------------------------------------------------------------------- |
148 // --------------------------------------------------------------------------- |
142 if ( KErrNone != err ) |
155 if ( KErrNone != err ) |
143 { |
156 { |
144 CESMRGlobalNote::ExecuteL( |
157 CESMRGlobalNote::ExecuteL( |
145 CESMRGlobalNote::EESMRRepeatEndEarlierThanItStart ); |
158 CESMRGlobalNote::EESMRRepeatEndEarlierThanItStart ); |
146 } |
159 } |
147 return (KErrNone == err); |
160 return( KErrNone == err ); |
148 } |
161 } |
149 |
162 |
150 // --------------------------------------------------------------------------- |
163 // --------------------------------------------------------------------------- |
151 // CESMRRepeatUntilField::CountComponentControls |
164 // CESMRRepeatUntilField::CountComponentControls |
152 // --------------------------------------------------------------------------- |
165 // --------------------------------------------------------------------------- |
153 // |
166 // |
154 TInt CESMRRepeatUntilField::CountComponentControls( ) const |
167 TInt CESMRRepeatUntilField::CountComponentControls( ) const |
155 { |
168 { |
156 FUNC_LOG; |
169 FUNC_LOG; |
157 TInt count = CESMRField::CountComponentControls(); |
170 TInt count( 0 ); |
158 |
171 if( iLabel ) |
159 if ( iLabel ) |
|
160 { |
172 { |
161 ++count; |
173 ++count; |
162 } |
174 } |
163 |
175 if( iDate ) |
|
176 { |
|
177 ++count; |
|
178 } |
|
179 |
164 return count; |
180 return count; |
165 } |
181 } |
166 |
182 |
167 // --------------------------------------------------------------------------- |
183 // --------------------------------------------------------------------------- |
168 // CESMRRepeatUntilField::ComponentControl |
184 // CESMRRepeatUntilField::ComponentControl |
169 // --------------------------------------------------------------------------- |
185 // --------------------------------------------------------------------------- |
170 // |
186 // |
171 CCoeControl* CESMRRepeatUntilField::ComponentControl( TInt aInd ) const |
187 CCoeControl* CESMRRepeatUntilField::ComponentControl( TInt aInd ) const |
172 { |
188 { |
173 FUNC_LOG; |
189 FUNC_LOG; |
174 if ( aInd == 0 ) |
190 |
175 { |
191 switch ( aInd ) |
176 return iLabel; |
192 { |
177 } |
193 case 0: |
178 |
194 return iLabel; |
179 return CESMRField::ComponentControl ( aInd ); |
195 case 1: |
|
196 return iDate; |
|
197 default: |
|
198 return NULL; |
|
199 } |
180 } |
200 } |
181 |
201 |
182 // --------------------------------------------------------------------------- |
202 // --------------------------------------------------------------------------- |
183 // CESMRRepeatUntilField::SizeChanged |
203 // CESMRRepeatUntilField::SizeChanged |
184 // --------------------------------------------------------------------------- |
204 // --------------------------------------------------------------------------- |
185 // |
205 // |
186 void CESMRRepeatUntilField::SizeChanged( ) |
206 void CESMRRepeatUntilField::SizeChanged() |
187 { |
207 { |
188 FUNC_LOG; |
208 FUNC_LOG; |
189 TRect rect = Rect(); |
209 TRect rect( Rect() ); |
190 TPoint titlePos; |
210 |
191 TSize titleSize; |
211 // Layouting label |
192 |
212 TAknLayoutRect rowLayoutRect = |
193 if ( CESMRLayoutManager::IsMirrored ( ) ) |
213 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ); |
194 { |
214 TRect rowRect = rowLayoutRect.Rect(); |
195 titleSize = TSize( rect.Width()- ( KIconSize.iWidth + KIconBorderMargin ), |
215 |
196 iLayout->FieldSize( EESMRFieldAlarmDate ).iHeight ); |
216 // Layout label to first row's rect |
197 |
217 TAknTextComponentLayout titleLayout = |
198 TPoint titlePos( rect.iBr.iX - KIconSize.iWidth - titleSize.iWidth, |
218 NMRLayoutManager::GetTextComponentLayout( |
199 rect.iTl.iY); |
219 NMRLayoutManager::EMRTextLayoutText ); |
200 iLabel->SetExtent ( titlePos, titleSize ); |
220 AknLayoutUtils::LayoutLabel( iLabel, rect, titleLayout ); |
201 |
221 |
202 TSize dateSize( rect.Width()- ( KIconSize.iWidth + KIconBorderMargin ), |
222 // Move upper left corner below first line and get second row's rect. |
203 rect.Height() - titleSize.iHeight ); |
223 rect.iTl.iY += rowRect.Height(); |
204 TPoint datePos(rect.iBr.iX - KIconSize.iWidth - dateSize.iWidth, |
224 rowLayoutRect = |
205 rect.iTl.iY + titleSize.iHeight); |
225 NMRLayoutManager::GetFieldRowLayoutRect( rect, 2 ); |
206 iBorder->SetExtent ( datePos, dateSize ); |
226 rowRect = rowLayoutRect.Rect(); |
207 } |
227 |
208 else |
228 // Layouting date editor |
209 { |
229 if( iDate ) |
210 // title |
230 { |
211 titlePos = TPoint( rect.iTl.iX + KIconSize.iWidth + KIconBorderMargin, |
231 TAknLayoutRect bgLayoutRect = |
212 rect.iTl.iY); |
232 NMRLayoutManager::GetLayoutRect( |
213 titleSize = TSize ( |
233 rowRect, NMRLayoutManager::EMRLayoutTextEditorBg ); |
214 rect.Width() - KIconSize.iWidth - KIconBorderMargin, |
234 TRect bgRect( bgLayoutRect.Rect() ); |
215 iLayout->FieldSize( EESMRFieldAlarmDate ).iHeight ); |
235 // Move focus rect so that it's relative to field's position. |
216 |
236 bgRect.Move( -Position() ); |
217 iLabel->SetExtent ( titlePos, titleSize ); |
237 SetFocusRect( bgRect ); |
218 |
238 |
219 // Current implemenattion does not need the ID here |
239 TAknTextComponentLayout editorLayout = |
220 CESMRLayoutManager::TMarginsId nullID = CESMRLayoutManager::EFieldMargins; |
240 NMRLayoutManager::GetTextComponentLayout( |
221 TInt topMargin = iLayout->Margins( nullID ).iTop; |
241 NMRLayoutManager::EMRTextLayoutDateEditor ); |
222 |
242 AknLayoutUtils::LayoutMfne( iDate, rect, editorLayout ); |
223 TPoint datePosition = TPoint ( |
243 |
224 rect.iTl.iX + KIconSize.iWidth + KIconBorderMargin, |
244 NMRColorManager::SetColor( *iDate, |
225 rect.iTl.iY + iLabel->Size().iHeight + topMargin ); |
245 NMRColorManager::EMRMainAreaTextColor ); |
226 |
|
227 TSize dateSize = TSize ( |
|
228 rect.Width() - KIconSize.iWidth - KIconBorderMargin, |
|
229 iLayout->FieldSize( EESMRFieldAlarmDate ).iHeight ); |
|
230 |
|
231 iBorder->SetPosition( datePosition ); |
|
232 iBorder->SetSize( dateSize ); |
|
233 |
|
234 TInt h = iLabel->Size().iHeight + iDate->Size().iHeight; |
|
235 |
|
236 if( iFrameBgContext ) |
|
237 { |
|
238 iFrameBgContext->SetFrameRects( iDate->Rect(), iDate->Rect() ); |
|
239 } |
|
240 } |
|
241 } |
|
242 |
|
243 // --------------------------------------------------------------------------- |
|
244 // CESMRRepeatUntilField::ActivateL |
|
245 // --------------------------------------------------------------------------- |
|
246 // |
|
247 void CESMRRepeatUntilField::ActivateL() |
|
248 { |
|
249 FUNC_LOG; |
|
250 CCoeControl::ActivateL(); |
|
251 TRect rect(TPoint(iDate->Position()), iDate->Size()); |
|
252 TRect inner(rect); |
|
253 TRect outer(rect); |
|
254 |
|
255 iDate->SetSize( TSize( iDate->Size().iWidth, |
|
256 iLayout->FieldSize( FieldId() ).iHeight )); |
|
257 |
|
258 iDate->SetBorder( TGulBorder::ENone ); |
|
259 |
|
260 delete iFrameBgContext; |
|
261 iFrameBgContext = NULL; |
|
262 iFrameBgContext = CAknsFrameBackgroundControlContext::NewL( |
|
263 KAknsIIDQsnFrInput, outer, inner, EFalse ) ; |
|
264 |
|
265 iFrameBgContext->SetParentContext( iBackground ); |
|
266 iDate->SetSkinBackgroundControlContextL(iFrameBgContext); |
|
267 } |
|
268 |
|
269 // --------------------------------------------------------------------------- |
|
270 // CESMRRepeatUntilField::PositionChanged |
|
271 // --------------------------------------------------------------------------- |
|
272 // |
|
273 void CESMRRepeatUntilField::PositionChanged() |
|
274 { |
|
275 FUNC_LOG; |
|
276 CCoeControl::PositionChanged(); |
|
277 if( iFrameBgContext ) |
|
278 { |
|
279 iFrameBgContext->SetFrameRects( iDate->Rect(), iDate->Rect() ); |
|
280 } |
246 } |
281 } |
247 } |
282 |
248 |
283 // --------------------------------------------------------------------------- |
249 // --------------------------------------------------------------------------- |
284 // CESMRRepeatUntilField::OfferKeyEventL |
250 // CESMRRepeatUntilField::OfferKeyEventL |
334 { |
306 { |
335 ChangeMiddleSoftKeyL(EESMRCmdSaveMR,R_QTN_MSK_SAVE); |
307 ChangeMiddleSoftKeyL(EESMRCmdSaveMR,R_QTN_MSK_SAVE); |
336 } |
308 } |
337 } |
309 } |
338 |
310 |
|
311 // --------------------------------------------------------------------------- |
|
312 // CESMRRepeatUntilField::SetValidatorL |
|
313 // --------------------------------------------------------------------------- |
|
314 // |
|
315 void CESMRRepeatUntilField::SetValidatorL( MESMRFieldValidator* aValidator ) |
|
316 { |
|
317 FUNC_LOG; |
|
318 |
|
319 CESMRField::SetValidatorL( aValidator ); |
|
320 |
|
321 if ( iValidator ) |
|
322 { |
|
323 iValidator->SetRecurrenceUntilDateFieldL( *iDate ); |
|
324 } |
|
325 } |
|
326 |
|
327 // --------------------------------------------------------------------------- |
|
328 // CESMRRepeatUntilField::ExecuteGenericCommandL() |
|
329 // --------------------------------------------------------------------------- |
|
330 // |
|
331 TBool CESMRRepeatUntilField::ExecuteGenericCommandL( TInt aCommand ) |
|
332 { |
|
333 FUNC_LOG; |
|
334 |
|
335 TBool retValue( EFalse ); |
|
336 |
|
337 if ( EMRCmdDoEnvironmentChange == aCommand ) |
|
338 { |
|
339 // Locale has been changed |
|
340 DoEnvChangeL(); |
|
341 retValue = ETrue; |
|
342 } |
|
343 |
|
344 return retValue; |
|
345 } |
|
346 |
|
347 // --------------------------------------------------------------------------- |
|
348 // CESMRRepeatUntilField::SetContainerWindowL |
|
349 // --------------------------------------------------------------------------- |
|
350 // |
|
351 void CESMRRepeatUntilField::SetContainerWindowL( |
|
352 const CCoeControl& aContainer ) |
|
353 { |
|
354 iContainerWindow = &aContainer; |
|
355 |
|
356 CCoeControl::SetContainerWindowL( aContainer ); |
|
357 iDate->SetContainerWindowL( aContainer ); |
|
358 iLabel->SetContainerWindowL( aContainer ); |
|
359 |
|
360 iDate->SetParent( this ); |
|
361 iLabel->SetParent( this ); |
|
362 } |
|
363 |
|
364 // --------------------------------------------------------------------------- |
|
365 // CESMRRepeatUntilField::DoEnvChangeL |
|
366 // --------------------------------------------------------------------------- |
|
367 // |
|
368 void CESMRRepeatUntilField::DoEnvChangeL() |
|
369 { |
|
370 FUNC_LOG; |
|
371 |
|
372 CEikDateEditor* date = new( ELeave )CEikDateEditor; |
|
373 CleanupStack::PushL( date ); |
|
374 |
|
375 date->ConstructL( |
|
376 TTIME_MINIMUMDATE, |
|
377 TTIME_MAXIMUMDATE, |
|
378 iDate->Date(), |
|
379 EFalse ); |
|
380 date->SetUpAndDownKeysConsumed( EFalse ); |
|
381 |
|
382 UpdateExtControlL( date ); |
|
383 |
|
384 CleanupStack::Pop( date ); |
|
385 iDate = date; |
|
386 |
|
387 if ( iValidator ) |
|
388 { |
|
389 iValidator->SetRecurrenceUntilDateFieldL( *iDate ); |
|
390 } |
|
391 |
|
392 iDate->SetSkinBackgroundControlContextL( iBgCtrlContext ); |
|
393 SetContainerWindowL( *iContainerWindow ); |
|
394 |
|
395 iDate->ActivateL(); |
|
396 SizeChanged(); |
|
397 DrawDeferred(); |
|
398 } |
|
399 |
339 // EOF |
400 // EOF |
340 |
401 |