|
1 /* |
|
2 * Copyright (c) 2007-2009 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: ESMR repeat until field implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "emailtrace.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" |
|
32 #include "cesmrglobalnote.h" |
|
33 #include "esmrfieldbuilderdef.h" |
|
34 #include "cesmrlayoutmgr.h" |
|
35 |
|
36 using namespace ESMRLayout; |
|
37 |
|
38 // ======== MEMBER FUNCTIONS ======== |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // CESMRRepeatUntilField::CESMRRepeatUntilField |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 CESMRRepeatUntilField::CESMRRepeatUntilField( |
|
45 MESMRFieldValidator* aValidator ) |
|
46 : iValidator(aValidator) |
|
47 { |
|
48 FUNC_LOG; |
|
49 //do nothing |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // CESMRRepeatUntilField::~CESMRRepeatUntilField |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 CESMRRepeatUntilField::~CESMRRepeatUntilField( ) |
|
57 { |
|
58 FUNC_LOG; |
|
59 delete iLabel; |
|
60 delete iFrameBgContext; |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // CESMRRepeatUntilField::NewL |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CESMRRepeatUntilField* CESMRRepeatUntilField::NewL( |
|
68 MESMRFieldValidator* aValidator ) |
|
69 { |
|
70 FUNC_LOG; |
|
71 CESMRRepeatUntilField* self = |
|
72 new (ELeave) CESMRRepeatUntilField( aValidator ); |
|
73 CleanupStack::PushL ( self ); |
|
74 self->ConstructL ( ); |
|
75 CleanupStack::Pop ( self ); |
|
76 return self; |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // CESMRRepeatUntilField::ConstructL |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 void CESMRRepeatUntilField::ConstructL( ) |
|
84 { |
|
85 FUNC_LOG; |
|
86 HBufC* label = StringLoader::LoadLC( R_QTN_MEET_REQ_REPEAT_UNTIL ); |
|
87 SetFieldId ( EESMRFieldRecurrenceDate ); |
|
88 iLabel = new (ELeave) CEikLabel(); |
|
89 iLabel->SetTextL ( *label ); |
|
90 CleanupStack::PopAndDestroy( label ); |
|
91 |
|
92 TTime startTime; |
|
93 startTime.UniversalTime ( ); |
|
94 |
|
95 iDate = new (ELeave) CEikDateEditor; |
|
96 iDate->ConstructL( |
|
97 KAknMinimumDate, |
|
98 TTIME_MAXIMUMDATE, |
|
99 startTime, |
|
100 EFalse ); |
|
101 iDate->SetUpAndDownKeysConsumed ( EFalse ); |
|
102 |
|
103 iBackground = AknsDrawUtils::ControlContext( this ); |
|
104 CESMRField::ConstructL ( iDate ); |
|
105 |
|
106 if ( iValidator ) |
|
107 { |
|
108 iValidator->SetRecurrenceUntilDateFieldL( *iDate ); |
|
109 } |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // CESMRRepeatUntilField::InitializeL |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 void CESMRRepeatUntilField::InitializeL() |
|
117 { |
|
118 FUNC_LOG; |
|
119 iLabel->SetFont( iLayout->Font( iCoeEnv, iFieldId ) ); |
|
120 iLabel->SetLabelAlignment( CESMRLayoutManager::IsMirrored ( ) |
|
121 ? ELayoutAlignRight : ELayoutAlignLeft ); |
|
122 AknLayoutUtils::OverrideControlColorL( |
|
123 *iLabel, |
|
124 EColorLabelText, |
|
125 iLayout->GeneralListAreaTextColor() ); |
|
126 |
|
127 iDate->SetFont( iLayout->Font( iCoeEnv, iFieldId ) ); |
|
128 iDate->SetMfneAlignment( CESMRLayoutManager::IsMirrored ( ) |
|
129 ? EAknEditorAlignRight : EAknEditorAlignLeft ); |
|
130 iDate->SetSkinTextColorL( iLayout->NormalTextColorID() ); |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // CESMRRepeatUntilField::OkToLoseFocusL |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 TBool CESMRRepeatUntilField::OkToLoseFocusL( TESMREntryFieldId /*aNextItem*/ ) |
|
138 { |
|
139 FUNC_LOG; |
|
140 TRAPD(err, iValidator->RecurrenceEndDateChangedL() ); |
|
141 |
|
142 if ( KErrNone != err ) |
|
143 { |
|
144 CESMRGlobalNote::ExecuteL( |
|
145 CESMRGlobalNote::EESMRRepeatEndEarlierThanItStart ); |
|
146 } |
|
147 return (KErrNone == err); |
|
148 } |
|
149 |
|
150 // --------------------------------------------------------------------------- |
|
151 // CESMRRepeatUntilField::CountComponentControls |
|
152 // --------------------------------------------------------------------------- |
|
153 // |
|
154 TInt CESMRRepeatUntilField::CountComponentControls( ) const |
|
155 { |
|
156 FUNC_LOG; |
|
157 TInt count = CESMRField::CountComponentControls(); |
|
158 |
|
159 if ( iLabel ) |
|
160 { |
|
161 ++count; |
|
162 } |
|
163 |
|
164 return count; |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // CESMRRepeatUntilField::ComponentControl |
|
169 // --------------------------------------------------------------------------- |
|
170 // |
|
171 CCoeControl* CESMRRepeatUntilField::ComponentControl( TInt aInd ) const |
|
172 { |
|
173 FUNC_LOG; |
|
174 if ( aInd == 0 ) |
|
175 { |
|
176 return iLabel; |
|
177 } |
|
178 |
|
179 return CESMRField::ComponentControl ( aInd ); |
|
180 } |
|
181 |
|
182 // --------------------------------------------------------------------------- |
|
183 // CESMRRepeatUntilField::SizeChanged |
|
184 // --------------------------------------------------------------------------- |
|
185 // |
|
186 void CESMRRepeatUntilField::SizeChanged( ) |
|
187 { |
|
188 FUNC_LOG; |
|
189 TRect rect = Rect(); |
|
190 TPoint titlePos; |
|
191 TSize titleSize; |
|
192 |
|
193 if ( CESMRLayoutManager::IsMirrored ( ) ) |
|
194 { |
|
195 titleSize = TSize( rect.Width()- ( KIconSize.iWidth + KIconBorderMargin ), |
|
196 iLayout->FieldSize( EESMRFieldAlarmDate ).iHeight ); |
|
197 |
|
198 TPoint titlePos( rect.iBr.iX - KIconSize.iWidth - titleSize.iWidth, |
|
199 rect.iTl.iY); |
|
200 iLabel->SetExtent ( titlePos, titleSize ); |
|
201 |
|
202 TSize dateSize( rect.Width()- ( KIconSize.iWidth + KIconBorderMargin ), |
|
203 rect.Height() - titleSize.iHeight ); |
|
204 TPoint datePos(rect.iBr.iX - KIconSize.iWidth - dateSize.iWidth, |
|
205 rect.iTl.iY + titleSize.iHeight); |
|
206 iBorder->SetExtent ( datePos, dateSize ); |
|
207 } |
|
208 else |
|
209 { |
|
210 // title |
|
211 titlePos = TPoint( rect.iTl.iX + KIconSize.iWidth + KIconBorderMargin, |
|
212 rect.iTl.iY); |
|
213 titleSize = TSize ( |
|
214 rect.Width() - KIconSize.iWidth - KIconBorderMargin, |
|
215 iLayout->FieldSize( EESMRFieldAlarmDate ).iHeight ); |
|
216 |
|
217 iLabel->SetExtent ( titlePos, titleSize ); |
|
218 |
|
219 // Current implemenattion does not need the ID here |
|
220 CESMRLayoutManager::TMarginsId nullID = CESMRLayoutManager::EFieldMargins; |
|
221 TInt topMargin = iLayout->Margins( nullID ).iTop; |
|
222 |
|
223 TPoint datePosition = TPoint ( |
|
224 rect.iTl.iX + KIconSize.iWidth + KIconBorderMargin, |
|
225 rect.iTl.iY + iLabel->Size().iHeight + topMargin ); |
|
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 } |
|
281 } |
|
282 |
|
283 // --------------------------------------------------------------------------- |
|
284 // CESMRRepeatUntilField::OfferKeyEventL |
|
285 // --------------------------------------------------------------------------- |
|
286 // |
|
287 TKeyResponse CESMRRepeatUntilField::OfferKeyEventL( |
|
288 const TKeyEvent& aEvent, |
|
289 TEventCode aType ) |
|
290 { |
|
291 FUNC_LOG; |
|
292 TKeyResponse response( EKeyWasNotConsumed); |
|
293 |
|
294 if ( aType == EEventKey ) |
|
295 { |
|
296 TInt fieldIndex( iDate->CurrentField() ); |
|
297 response = CESMRField::OfferKeyEventL( aEvent, aType ); |
|
298 } |
|
299 |
|
300 return response; |
|
301 } |
|
302 |
|
303 // --------------------------------------------------------------------------- |
|
304 // CESMRRepeatUntilField::CheckIfValidatingNeededL |
|
305 // --------------------------------------------------------------------------- |
|
306 // |
|
307 void CESMRRepeatUntilField::CheckIfValidatingNeededL( |
|
308 TInt aStartFieldIndex ) |
|
309 { |
|
310 FUNC_LOG; |
|
311 TInt fieldIndex( iDate->CurrentField() ); |
|
312 |
|
313 if ( fieldIndex != aStartFieldIndex && iValidator ) |
|
314 { |
|
315 TRAPD(err, iValidator->RecurrenceEndDateChangedL() ); |
|
316 |
|
317 if ( KErrNone != err ) |
|
318 { |
|
319 CESMRGlobalNote::ExecuteL( |
|
320 CESMRGlobalNote::EESMRRepeatEndEarlierThanItStart ); |
|
321 } |
|
322 } |
|
323 } |
|
324 |
|
325 // --------------------------------------------------------------------------- |
|
326 // CESMRTimeField::SetOutlineFocusL |
|
327 // --------------------------------------------------------------------------- |
|
328 // |
|
329 void CESMRRepeatUntilField::SetOutlineFocusL( TBool aFocus ) |
|
330 { |
|
331 FUNC_LOG; |
|
332 CESMRField::SetOutlineFocusL ( aFocus ); |
|
333 if ( aFocus ) |
|
334 { |
|
335 ChangeMiddleSoftKeyL(EESMRCmdSaveMR,R_QTN_MSK_SAVE); |
|
336 } |
|
337 } |
|
338 |
|
339 // EOF |
|
340 |