64
|
1 |
/*
|
|
2 |
* Copyright (c) 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 |
|
|
19 |
#include "cesmrrepeatuntil.h"
|
|
20 |
#include "mesmrfieldvalidator.h"
|
|
21 |
#include "cesmrglobalnote.h"
|
|
22 |
#include "esmrfieldbuilderdef.h"
|
|
23 |
#include "nmrlayoutmanager.h"
|
|
24 |
#include "nmrcolormanager.h"
|
|
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"
|
|
34 |
|
|
35 |
// ======== MEMBER FUNCTIONS ========
|
|
36 |
|
|
37 |
// ---------------------------------------------------------------------------
|
|
38 |
// CESMRRepeatUntilField::CESMRRepeatUntilField
|
|
39 |
// ---------------------------------------------------------------------------
|
|
40 |
//
|
|
41 |
CESMRRepeatUntilField::CESMRRepeatUntilField(
|
|
42 |
MESMRFieldValidator* aValidator )
|
|
43 |
{
|
|
44 |
FUNC_LOG;
|
|
45 |
|
|
46 |
iValidator = aValidator;
|
|
47 |
SetFieldId( EESMRFieldRecurrenceDate );
|
|
48 |
SetFocusType( EESMRHighlightFocus );
|
|
49 |
}
|
|
50 |
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
// CESMRRepeatUntilField::~CESMRRepeatUntilField
|
|
53 |
// ---------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
CESMRRepeatUntilField::~CESMRRepeatUntilField( )
|
|
56 |
{
|
|
57 |
FUNC_LOG;
|
|
58 |
delete iLabel;
|
|
59 |
delete iBgCtrlContext;
|
|
60 |
}
|
|
61 |
|
|
62 |
// ---------------------------------------------------------------------------
|
|
63 |
// CESMRRepeatUntilField::NewL
|
|
64 |
// ---------------------------------------------------------------------------
|
|
65 |
//
|
|
66 |
CESMRRepeatUntilField* CESMRRepeatUntilField::NewL(
|
|
67 |
MESMRFieldValidator* aValidator )
|
|
68 |
{
|
|
69 |
FUNC_LOG;
|
|
70 |
CESMRRepeatUntilField* self =
|
|
71 |
new( ELeave )CESMRRepeatUntilField( aValidator );
|
|
72 |
CleanupStack::PushL( self );
|
|
73 |
self->ConstructL();
|
|
74 |
CleanupStack::Pop( self );
|
|
75 |
return self;
|
|
76 |
}
|
|
77 |
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
// CESMRRepeatUntilField::ConstructL
|
|
80 |
// ---------------------------------------------------------------------------
|
|
81 |
//
|
|
82 |
void CESMRRepeatUntilField::ConstructL( )
|
|
83 |
{
|
|
84 |
FUNC_LOG;
|
|
85 |
SetComponentsToInheritVisibility( ETrue );
|
|
86 |
HBufC* label = StringLoader::LoadLC( R_QTN_MEET_REQ_REPEAT_UNTIL );
|
|
87 |
|
|
88 |
iLabel = CMRLabel::NewL();
|
|
89 |
iLabel->SetParent( this );
|
|
90 |
iLabel->SetTextL( *label );
|
|
91 |
CleanupStack::PopAndDestroy( label );
|
|
92 |
|
|
93 |
TTime startTime;
|
|
94 |
startTime.UniversalTime();
|
|
95 |
|
|
96 |
iDate = new( ELeave )CEikDateEditor;
|
|
97 |
CESMRField::ConstructL( iDate ); //ownership transferred
|
|
98 |
|
|
99 |
iDate->ConstructL(
|
|
100 |
KAknMinimumDate,
|
|
101 |
TTIME_MAXIMUMDATE,
|
|
102 |
startTime,
|
|
103 |
EFalse );
|
|
104 |
|
|
105 |
iDate->SetUpAndDownKeysConsumed ( EFalse );
|
|
106 |
|
|
107 |
if ( iValidator )
|
|
108 |
{
|
|
109 |
iValidator->SetRecurrenceUntilDateFieldL( *iDate );
|
|
110 |
}
|
|
111 |
|
|
112 |
TRect tempRect( 0, 0, 0, 0 );
|
|
113 |
|
|
114 |
// Setting background instead of theme skin
|
|
115 |
NMRBitmapManager::TMRBitmapStruct bitmapStruct;
|
|
116 |
bitmapStruct = NMRBitmapManager::GetBitmapStruct( NMRBitmapManager::EMRBitmapInputCenter );
|
|
117 |
|
|
118 |
iBgCtrlContext = CAknsBasicBackgroundControlContext::NewL(
|
|
119 |
bitmapStruct.iItemId,
|
|
120 |
tempRect,
|
|
121 |
EFalse );
|
|
122 |
|
|
123 |
iDate->SetSkinBackgroundControlContextL( iBgCtrlContext );
|
|
124 |
}
|
|
125 |
|
|
126 |
// ---------------------------------------------------------------------------
|
|
127 |
// CESMRRepeatUntilField::MinimumSize
|
|
128 |
// ---------------------------------------------------------------------------
|
|
129 |
//
|
|
130 |
TSize CESMRRepeatUntilField::MinimumSize()
|
|
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;
|
|
144 |
}
|
|
145 |
|
|
146 |
// ---------------------------------------------------------------------------
|
|
147 |
// CESMRRepeatUntilField::OkToLoseFocusL
|
|
148 |
// ---------------------------------------------------------------------------
|
|
149 |
//
|
|
150 |
TBool CESMRRepeatUntilField::OkToLoseFocusL( TESMREntryFieldId /*aNextItem*/ )
|
|
151 |
{
|
|
152 |
FUNC_LOG;
|
|
153 |
TRAPD(err, iValidator->RecurrenceEndDateChangedL() );
|
|
154 |
|
|
155 |
if ( KErrNone != err )
|
|
156 |
{
|
|
157 |
CESMRGlobalNote::ExecuteL(
|
|
158 |
CESMRGlobalNote::EESMRRepeatEndEarlierThanItStart );
|
|
159 |
}
|
|
160 |
return( KErrNone == err );
|
|
161 |
}
|
|
162 |
|
|
163 |
// ---------------------------------------------------------------------------
|
|
164 |
// CESMRRepeatUntilField::CountComponentControls
|
|
165 |
// ---------------------------------------------------------------------------
|
|
166 |
//
|
|
167 |
TInt CESMRRepeatUntilField::CountComponentControls( ) const
|
|
168 |
{
|
|
169 |
FUNC_LOG;
|
|
170 |
TInt count( 0 );
|
|
171 |
if( iLabel )
|
|
172 |
{
|
|
173 |
++count;
|
|
174 |
}
|
|
175 |
if( iDate )
|
|
176 |
{
|
|
177 |
++count;
|
|
178 |
}
|
|
179 |
|
|
180 |
return count;
|
|
181 |
}
|
|
182 |
|
|
183 |
// ---------------------------------------------------------------------------
|
|
184 |
// CESMRRepeatUntilField::ComponentControl
|
|
185 |
// ---------------------------------------------------------------------------
|
|
186 |
//
|
|
187 |
CCoeControl* CESMRRepeatUntilField::ComponentControl( TInt aInd ) const
|
|
188 |
{
|
|
189 |
FUNC_LOG;
|
|
190 |
|
|
191 |
switch ( aInd )
|
|
192 |
{
|
|
193 |
case 0:
|
|
194 |
return iLabel;
|
|
195 |
case 1:
|
|
196 |
return iDate;
|
|
197 |
default:
|
|
198 |
return NULL;
|
|
199 |
}
|
|
200 |
}
|
|
201 |
|
|
202 |
// ---------------------------------------------------------------------------
|
|
203 |
// CESMRRepeatUntilField::SizeChanged
|
|
204 |
// ---------------------------------------------------------------------------
|
|
205 |
//
|
|
206 |
void CESMRRepeatUntilField::SizeChanged()
|
|
207 |
{
|
|
208 |
FUNC_LOG;
|
|
209 |
TRect rect( Rect() );
|
|
210 |
|
|
211 |
// Layouting label
|
|
212 |
TAknLayoutRect rowLayoutRect =
|
|
213 |
NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
|
|
214 |
TRect rowRect = rowLayoutRect.Rect();
|
|
215 |
|
|
216 |
// Layout label to first row's rect
|
|
217 |
TAknTextComponentLayout titleLayout =
|
|
218 |
NMRLayoutManager::GetTextComponentLayout(
|
|
219 |
NMRLayoutManager::EMRTextLayoutText );
|
|
220 |
AknLayoutUtils::LayoutLabel( iLabel, rect, titleLayout );
|
|
221 |
|
|
222 |
// Move upper left corner below first line and get second row's rect.
|
|
223 |
rect.iTl.iY += rowRect.Height();
|
|
224 |
rowLayoutRect =
|
|
225 |
NMRLayoutManager::GetFieldRowLayoutRect( rect, 2 );
|
|
226 |
rowRect = rowLayoutRect.Rect();
|
|
227 |
|
|
228 |
// Layouting date editor
|
|
229 |
if( iDate )
|
|
230 |
{
|
|
231 |
TAknLayoutRect bgLayoutRect =
|
|
232 |
NMRLayoutManager::GetLayoutRect(
|
|
233 |
rowRect, NMRLayoutManager::EMRLayoutTextEditorBg );
|
|
234 |
TRect bgRect( bgLayoutRect.Rect() );
|
|
235 |
// Move focus rect so that it's relative to field's position.
|
|
236 |
bgRect.Move( -Position() );
|
|
237 |
SetFocusRect( bgRect );
|
|
238 |
|
|
239 |
TAknTextComponentLayout editorLayout =
|
|
240 |
NMRLayoutManager::GetTextComponentLayout(
|
|
241 |
NMRLayoutManager::EMRTextLayoutDateEditor );
|
|
242 |
AknLayoutUtils::LayoutMfne( iDate, rect, editorLayout );
|
|
243 |
|
|
244 |
NMRColorManager::SetColor( *iDate,
|
|
245 |
NMRColorManager::EMRMainAreaTextColor );
|
|
246 |
}
|
|
247 |
}
|
|
248 |
|
|
249 |
// ---------------------------------------------------------------------------
|
|
250 |
// CESMRRepeatUntilField::OfferKeyEventL
|
|
251 |
// ---------------------------------------------------------------------------
|
|
252 |
//
|
|
253 |
TKeyResponse CESMRRepeatUntilField::OfferKeyEventL(
|
|
254 |
const TKeyEvent& aEvent,
|
|
255 |
TEventCode aType )
|
|
256 |
{
|
|
257 |
FUNC_LOG;
|
|
258 |
TKeyResponse response( EKeyWasNotConsumed);
|
|
259 |
|
|
260 |
if ( aType == EEventKey )
|
|
261 |
{
|
|
262 |
TInt fieldIndex( iDate->CurrentField() );
|
|
263 |
response = CESMRField::OfferKeyEventL( aEvent, aType );
|
|
264 |
|
|
265 |
if ( aEvent.iScanCode != EStdKeyUpArrow &&
|
|
266 |
aEvent.iScanCode != EStdKeyDownArrow )
|
|
267 |
{
|
|
268 |
iDate->DrawDeferred();
|
|
269 |
}
|
|
270 |
}
|
|
271 |
|
|
272 |
return response;
|
|
273 |
}
|
|
274 |
|
|
275 |
// ---------------------------------------------------------------------------
|
|
276 |
// CESMRRepeatUntilField::CheckIfValidatingNeededL
|
|
277 |
// ---------------------------------------------------------------------------
|
|
278 |
//
|
|
279 |
void CESMRRepeatUntilField::CheckIfValidatingNeededL(
|
|
280 |
TInt aStartFieldIndex )
|
|
281 |
{
|
|
282 |
FUNC_LOG;
|
|
283 |
TInt fieldIndex( iDate->CurrentField() );
|
|
284 |
|
|
285 |
if ( fieldIndex != aStartFieldIndex && iValidator )
|
|
286 |
{
|
|
287 |
TRAPD(err, iValidator->RecurrenceEndDateChangedL() );
|
|
288 |
|
|
289 |
if ( KErrNone != err )
|
|
290 |
{
|
|
291 |
CESMRGlobalNote::ExecuteL(
|
|
292 |
CESMRGlobalNote::EESMRRepeatEndEarlierThanItStart );
|
|
293 |
}
|
|
294 |
}
|
|
295 |
}
|
|
296 |
|
|
297 |
// ---------------------------------------------------------------------------
|
|
298 |
// CESMRRepeatUntilField::SetOutlineFocusL
|
|
299 |
// ---------------------------------------------------------------------------
|
|
300 |
//
|
|
301 |
void CESMRRepeatUntilField::SetOutlineFocusL( TBool aFocus )
|
|
302 |
{
|
|
303 |
FUNC_LOG;
|
|
304 |
CESMRField::SetOutlineFocusL ( aFocus );
|
|
305 |
if ( aFocus )
|
|
306 |
{
|
|
307 |
ChangeMiddleSoftKeyL(EESMRCmdSaveMR,R_QTN_MSK_SAVE);
|
|
308 |
}
|
|
309 |
}
|
|
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 |
|
|
400 |
// EOF
|
|
401 |
|