|
1 /* |
|
2 * Copyright (c) 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: utility class definition |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "emailtrace.h" |
|
22 #include <StringLoader.h> |
|
23 #include <AknsUtils.h> |
|
24 #include <AknUtils.h> |
|
25 #include <AknsSkinInstance.h> |
|
26 #include <aknbutton.h> |
|
27 #include <eikedwin.h> |
|
28 #include <FreestyleEmailUi.rsg> |
|
29 #include <RPbkViewResourceFile.h> |
|
30 #include <CPbkContactEngine.h> |
|
31 #include <CPbkMultipleEntryFetchDlg.h> |
|
32 #include <CPbkContactItem.h> |
|
33 #include <AknIconUtils.h> |
|
34 #include <eikimage.h> |
|
35 #include <fbs.h> |
|
36 #include <flogger.h> |
|
37 #include <aknenv.h> // CAknEnv |
|
38 |
|
39 #include "cfsmailbox.h" |
|
40 #include "cfsmailclient.h" |
|
41 #include "cfsmailaddress.h" |
|
42 |
|
43 #include <aknlayoutscalable_apps.cdl.h> |
|
44 #include <layoutmetadata.cdl.h> |
|
45 #include <AknLayoutFont.h> |
|
46 |
|
47 #include "ncsutility.h" |
|
48 #include "ncsemailaddressobject.h" |
|
49 #include "ncsconstants.h" |
|
50 #include "FSDelayedLoader.h" |
|
51 #include "FreestyleEmailUiUtilities.h" |
|
52 #include "FreestyleEmailUiLayoutData.h" |
|
53 |
|
54 // CONSTANTS |
|
55 const TInt KFSUtilityMinColorValue = 0; |
|
56 const TInt KFSUtilityMaxColorValue = 255; |
|
57 const TInt KFSUtilityThresholdColorValue = 200; |
|
58 const TInt KFSUtilityThresholdColorMiddleValue = 127; |
|
59 |
|
60 // ========================= MEMBER FUNCTIONS ================================== |
|
61 |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // NcsUtility::CompleteRelativePathL() |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 void NcsUtility::CompleteRelativePathL( |
|
68 const TDesC& aRelativePath, TPtr& aAbsolutePath ) |
|
69 { |
|
70 FUNC_LOG; |
|
71 |
|
72 // + 2 is for drive letter and ":" |
|
73 if( aAbsolutePath.MaxLength() < aRelativePath.Length() + 2 ) |
|
74 { |
|
75 User::Leave( KErrArgument ); |
|
76 } |
|
77 |
|
78 TFileName path; |
|
79 path.Copy( aRelativePath ); |
|
80 TInt err = CompleteWithAppPath( path ); |
|
81 User::LeaveIfError( err ); |
|
82 |
|
83 aAbsolutePath.Copy( path ); |
|
84 |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // NcsUtility::GenerateFromLineToMessageBodyL() |
|
89 // |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 HBufC* NcsUtility::GenerateFromLineToMessageBodyL( |
|
93 const RPointerArray<CNcsEmailAddressObject>& aFromArray ) |
|
94 { |
|
95 FUNC_LOG; |
|
96 |
|
97 HBufC* buf = DoGenerateAddressLineToMessageBodyL( |
|
98 R_NCS_ENGINE_EMAIL_FROM, aFromArray ); |
|
99 |
|
100 return buf; |
|
101 } |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // NcsUtility::GenerateSentLineToMessageBodyL() |
|
105 // |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 HBufC* NcsUtility::GenerateSentLineToMessageBodyL( CFSMailMessage& aMessage ) |
|
109 { |
|
110 FUNC_LOG; |
|
111 |
|
112 HBufC* dateText = TFsEmailUiUtility::DateTextFromMsgLC( &aMessage ); |
|
113 HBufC* timeText = TFsEmailUiUtility::TimeTextFromMsgLC( &aMessage ); |
|
114 HBufC* sent = StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_SENT ); |
|
115 |
|
116 HBufC* buf = HBufC::NewL( sent->Length() + |
|
117 KSpace().Length() + |
|
118 dateText->Length() + |
|
119 KSentLineDateAndTimeSeparatorText().Length() + |
|
120 timeText->Length() ); |
|
121 TPtr ptr = buf->Des(); |
|
122 ptr.Append( *sent ); |
|
123 ptr.Append( KSpace ); |
|
124 ptr.Append( *dateText ); |
|
125 ptr.Append( KSentLineDateAndTimeSeparatorText ); |
|
126 ptr.Append( *timeText ); |
|
127 |
|
128 CleanupStack::PopAndDestroy( sent ); |
|
129 CleanupStack::PopAndDestroy( timeText ); |
|
130 CleanupStack::PopAndDestroy( dateText ); |
|
131 |
|
132 return buf; |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // NcsUtility::GenerateAddressLineToMessageBodyL() |
|
137 // |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 HBufC* NcsUtility::GenerateAddressLineToMessageBodyL( |
|
141 RPointerArray<CNcsEmailAddressObject>& aToArray, TRecipientType aType ) |
|
142 { |
|
143 FUNC_LOG; |
|
144 |
|
145 // figure out the recipient type dependent text |
|
146 TInt labelResource = R_NCS_ENGINE_EMAIL_TO; |
|
147 if ( aType == ERecipientTypeCc ) |
|
148 { |
|
149 labelResource = R_NCS_ENGINE_EMAIL_CC; |
|
150 } |
|
151 |
|
152 HBufC* buf = DoGenerateAddressLineToMessageBodyL( labelResource, aToArray ); |
|
153 |
|
154 return buf; |
|
155 } |
|
156 |
|
157 // ----------------------------------------------------------------------------- |
|
158 // NcsUtility::DoGenerateAddressLineToMessageBodyL() |
|
159 // |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 HBufC* NcsUtility::DoGenerateAddressLineToMessageBodyL( TInt aLabelResourceId, |
|
163 const RPointerArray<CNcsEmailAddressObject>& aAddressArray ) |
|
164 { |
|
165 FUNC_LOG; |
|
166 |
|
167 // load label string (e.g. "From:", "To:", "Cc:") |
|
168 HBufC* label = StringLoader::LoadLC( aLabelResourceId ); |
|
169 |
|
170 // calculate how large buffer do we need for the whole line |
|
171 TInt bufLength = label->Length(); |
|
172 TInt count = aAddressArray.Count(); |
|
173 for ( TInt i = 0; i < count; i++ ) |
|
174 { |
|
175 CNcsEmailAddressObject* obj = aAddressArray[i]; |
|
176 const TDesC& dispName = obj->DisplayName(); |
|
177 // use display name if it is available, otherwise email address |
|
178 if ( dispName.Length() > 0 ) |
|
179 { |
|
180 bufLength += dispName.Length(); |
|
181 } |
|
182 else |
|
183 { |
|
184 bufLength += obj->EmailAddress().Length(); |
|
185 } |
|
186 if ( i < ( count - 1 ) ) |
|
187 { |
|
188 bufLength += KEmailAddressSeparator().Length(); |
|
189 bufLength += KSpace().Length(); |
|
190 } |
|
191 } |
|
192 |
|
193 // allocate buffer to contain the whole text |
|
194 HBufC* buf = HBufC::NewL( bufLength ); |
|
195 TPtr ptr = buf->Des(); |
|
196 |
|
197 // add label |
|
198 ptr.Append( *label ); |
|
199 CleanupStack::PopAndDestroy( label ); |
|
200 |
|
201 // append each address into our text buffer |
|
202 for ( TInt i = 0; i < count; i++ ) |
|
203 { |
|
204 CNcsEmailAddressObject* obj = aAddressArray[i]; |
|
205 const TDesC& dispName = obj->DisplayName(); |
|
206 // use display name if it is available, otherwise email address |
|
207 if ( dispName.Length() > 0 ) |
|
208 { |
|
209 ptr.Append( dispName ); |
|
210 } |
|
211 else |
|
212 { |
|
213 ptr.Append( obj->EmailAddress() ); |
|
214 } |
|
215 if ( i < ( count - 1 ) ) |
|
216 { |
|
217 ptr.Append( KEmailAddressSeparator ); |
|
218 ptr.Append( KSpace ); |
|
219 } |
|
220 } |
|
221 |
|
222 return buf; |
|
223 } |
|
224 |
|
225 // ----------------------------------------------------------------------------- |
|
226 // NcsUtility::GenerateSubjectLineToMessageBodyL() |
|
227 // |
|
228 // ----------------------------------------------------------------------------- |
|
229 // |
|
230 HBufC* NcsUtility::GenerateSubjectLineToMessageBodyL( const TDesC& aSubject ) |
|
231 { |
|
232 FUNC_LOG; |
|
233 |
|
234 // load "Subject:" string |
|
235 HBufC* subjectLabel = StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_SUBJECT ); |
|
236 |
|
237 // allocate buffer for the text |
|
238 HBufC* buf = HBufC::NewL( subjectLabel->Length() + aSubject.Length() ); |
|
239 TPtr ptr = buf->Des(); |
|
240 ptr.Append( *subjectLabel ); |
|
241 ptr.Append( aSubject ); |
|
242 |
|
243 CleanupStack::PopAndDestroy( subjectLabel ); |
|
244 |
|
245 return buf; |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // NcsUtility::CreateNcsAddressL() |
|
250 // |
|
251 // ----------------------------------------------------------------------------- |
|
252 // |
|
253 CNcsEmailAddressObject* NcsUtility::CreateNcsAddressL( |
|
254 const CFSMailAddress& aFsAddress ) |
|
255 { |
|
256 FUNC_LOG; |
|
257 |
|
258 CNcsEmailAddressObject* address = CNcsEmailAddressObject::NewL( ETrue ); |
|
259 CleanupStack::PushL( address ); |
|
260 // temporary ugly code because email API can return references to null |
|
261 TDesC& a = aFsAddress.GetEmailAddress(); |
|
262 if ( &a ) |
|
263 { |
|
264 address->SetEmailAddressL( a ); |
|
265 } |
|
266 TDesC& name = aFsAddress.GetDisplayName(); |
|
267 if ( &name ) |
|
268 { |
|
269 address->SetDisplayNameL( name ); |
|
270 } |
|
271 |
|
272 CleanupStack::Pop( address ); |
|
273 |
|
274 return address; |
|
275 } |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // NcsUtility::CreateFsAddressL() |
|
279 // Caller takes the ownership of the returned address object |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 CFSMailAddress* NcsUtility::CreateFsAddressL( |
|
283 const CNcsEmailAddressObject& aNcsAddress ) |
|
284 { |
|
285 FUNC_LOG; |
|
286 |
|
287 CFSMailAddress* address = CFSMailAddress::NewL(); |
|
288 address->SetEmailAddress( aNcsAddress.EmailAddress() ); |
|
289 address->SetDisplayName( aNcsAddress.DisplayName() ); |
|
290 |
|
291 return address; |
|
292 } |
|
293 |
|
294 |
|
295 // ----------------------------------------------------------------------------- |
|
296 // NcsUtility::FormatSubjectLineL() |
|
297 // |
|
298 // ----------------------------------------------------------------------------- |
|
299 // |
|
300 HBufC* NcsUtility::FormatSubjectLineL( |
|
301 const TDesC& aNewSubjectLine, const TDesC& aPrefix ) |
|
302 { |
|
303 FUNC_LOG; |
|
304 |
|
305 HBufC* formattedSubjectLine = aNewSubjectLine.AllocLC(); |
|
306 HBufC* prefix = aPrefix.AllocLC(); |
|
307 TPtr formattedSubjectLinePtr = formattedSubjectLine->Des(); |
|
308 TPtr prefixPtr = prefix->Des(); |
|
309 prefixPtr.Trim(); |
|
310 |
|
311 TInt subjectLineLength = formattedSubjectLinePtr.Length(); |
|
312 TInt length = subjectLineLength; |
|
313 TInt prefixLength = prefixPtr.Length(); |
|
314 HBufC* fwdPrefix = StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_FORWARD_PREFIX ); |
|
315 TPtr fwdPrt = fwdPrefix->Des(); |
|
316 TInt fwdLength = fwdPrt.Length(); |
|
317 fwdPrt.Trim(); |
|
318 |
|
319 for(TInt index = formattedSubjectLinePtr.FindC( prefixPtr ); index != KErrNotFound ; index = formattedSubjectLinePtr.FindC( prefixPtr )) |
|
320 { |
|
321 formattedSubjectLinePtr = formattedSubjectLinePtr.RightTPtr( length ); |
|
322 length = formattedSubjectLinePtr.Length() - index - prefixLength; |
|
323 } |
|
324 formattedSubjectLinePtr.Trim(); |
|
325 |
|
326 for(TInt index = formattedSubjectLinePtr.FindC( fwdPrt) ; index != KErrNotFound ; index = formattedSubjectLinePtr.FindC( fwdPrt )) |
|
327 { |
|
328 formattedSubjectLinePtr = formattedSubjectLinePtr.RightTPtr( length ); |
|
329 length = formattedSubjectLinePtr.Length() - index - fwdLength; |
|
330 } |
|
331 |
|
332 formattedSubjectLinePtr.Trim(); |
|
333 |
|
334 |
|
335 HBufC* finalSubject = HBufC::NewL( formattedSubjectLinePtr.Length() + prefixPtr.Length() + KSpace().Length() ); |
|
336 TPtr ptr = finalSubject->Des(); |
|
337 if ( AknLayoutUtils::LayoutMirrored() ) |
|
338 { |
|
339 ptr.Append( formattedSubjectLinePtr ); |
|
340 ptr.Append( KSpace ); |
|
341 ptr.Append( prefixPtr ); |
|
342 |
|
343 } |
|
344 else |
|
345 { |
|
346 ptr.Append( prefixPtr ); |
|
347 ptr.Append( KSpace ); |
|
348 ptr.Append( formattedSubjectLinePtr ); |
|
349 |
|
350 } |
|
351 CleanupStack::PopAndDestroy( fwdPrefix ); |
|
352 CleanupStack::PopAndDestroy( prefix ); |
|
353 CleanupStack::PopAndDestroy( formattedSubjectLine ); |
|
354 |
|
355 return finalSubject; |
|
356 } |
|
357 |
|
358 // ----------------------------------------------------------------------------- |
|
359 // NcsUtility::ConvertAddressArrayL() |
|
360 // |
|
361 // ----------------------------------------------------------------------------- |
|
362 // |
|
363 void NcsUtility::ConvertAddressArrayL( |
|
364 const RPointerArray<CFSMailAddress>& aSrc, |
|
365 RPointerArray<CNcsEmailAddressObject>& aDst ) |
|
366 { |
|
367 FUNC_LOG; |
|
368 |
|
369 for ( TInt i=0; i<aSrc.Count(); i++ ) |
|
370 { |
|
371 CNcsEmailAddressObject* ncsRecipient = |
|
372 NcsUtility::CreateNcsAddressL( *aSrc[i] ); |
|
373 CleanupStack::PushL( ncsRecipient ); |
|
374 aDst.AppendL( ncsRecipient ); |
|
375 CleanupStack::Pop( ncsRecipient ); |
|
376 } |
|
377 |
|
378 } |
|
379 |
|
380 // ----------------------------------------------------------------------------- |
|
381 // NcsUtility::ConvertAddressArrayL() |
|
382 // Caller takes the ownership of address objects pointoed in the array aDst. |
|
383 // ----------------------------------------------------------------------------- |
|
384 // |
|
385 void NcsUtility::ConvertAddressArrayL( |
|
386 const RPointerArray<CNcsEmailAddressObject>& aSrc, |
|
387 RPointerArray<CFSMailAddress>& aDst ) |
|
388 { |
|
389 FUNC_LOG; |
|
390 |
|
391 for ( TInt i=0; i<aSrc.Count(); i++ ) |
|
392 { |
|
393 CFSMailAddress* fsRecipient = |
|
394 NcsUtility::CreateFsAddressL( *aSrc[i] ); |
|
395 CleanupStack::PushL( fsRecipient ); |
|
396 aDst.AppendL( fsRecipient ); |
|
397 CleanupStack::Pop( fsRecipient ); |
|
398 } |
|
399 |
|
400 } |
|
401 |
|
402 |
|
403 |
|
404 // ----------------------------------------------------------------------------- |
|
405 // NcsUtility::LoadScalableIconL() |
|
406 // |
|
407 // ----------------------------------------------------------------------------- |
|
408 // |
|
409 void NcsUtility::LoadScalableIconL( |
|
410 const TDesC& aMifRelativeFileName, TInt aImgId, |
|
411 TInt aMaskId, CEikImage*& aIcon, |
|
412 CFbsBitmap*& aImage, CFbsBitmap*& aMask ) |
|
413 { |
|
414 FUNC_LOG; |
|
415 |
|
416 HBufC* buf = HBufC::NewLC( KMaxFileName ); |
|
417 TPtr ptr = buf->Des(); |
|
418 NcsUtility::CompleteRelativePathL( aMifRelativeFileName, ptr ); |
|
419 |
|
420 AknIconUtils::CreateIconL( aImage, |
|
421 aMask, |
|
422 ptr, |
|
423 aImgId, |
|
424 aMaskId ); |
|
425 |
|
426 TSize size; |
|
427 AknIconUtils::GetContentDimensions( aImage, size ); |
|
428 AknIconUtils::SetSize( aImage, size ); |
|
429 |
|
430 aIcon = new ( ELeave ) CEikImage; |
|
431 aIcon->SetNewBitmaps( aImage, aMask ); |
|
432 aIcon->SetPictureOwnedExternally( ETrue ); |
|
433 |
|
434 CleanupStack::PopAndDestroy( buf ); |
|
435 |
|
436 } |
|
437 |
|
438 |
|
439 // ----------------------------------------------------------------------------- |
|
440 // NcsUtility::DebugLog |
|
441 // ----------------------------------------------------------------------------- |
|
442 // |
|
443 void NcsUtility::DebugLog( TRefByValue<const TDesC> aFmt, ... ) |
|
444 { |
|
445 FUNC_LOG; |
|
446 _LIT( KDebugDir, "FreestyleEmailUi" ); |
|
447 _LIT( KDebugLog, "log.txt" ); |
|
448 |
|
449 VA_LIST args; |
|
450 VA_START( args, aFmt ); |
|
451 RFileLogger::WriteFormat( KDebugDir, |
|
452 KDebugLog, |
|
453 EFileLoggingModeAppend, |
|
454 aFmt, |
|
455 args ); |
|
456 VA_END( args ); |
|
457 } |
|
458 |
|
459 // ----------------------------------------------------------------------------- |
|
460 // NcsUtility::IsEqualAddressArray |
|
461 // ----------------------------------------------------------------------------- |
|
462 // |
|
463 TBool NcsUtility::IsEqualAddressArray( |
|
464 const RPointerArray<CFSMailAddress>& aAddresses1, |
|
465 const RPointerArray<CFSMailAddress>& aAddresses2 ) |
|
466 { |
|
467 FUNC_LOG; |
|
468 |
|
469 if ( aAddresses1.Count() != aAddresses2.Count() ) |
|
470 { |
|
471 return EFalse; |
|
472 } |
|
473 for ( TInt i=0; i<aAddresses1.Count(); i++ ) |
|
474 { |
|
475 if ( aAddresses1[i]->GetEmailAddress().Compare( |
|
476 aAddresses2[i]->GetEmailAddress() ) != 0 ) |
|
477 { |
|
478 return EFalse; |
|
479 } |
|
480 if ( aAddresses1[i]->GetDisplayName().Compare( |
|
481 aAddresses2[i]->GetDisplayName() ) != 0 ) |
|
482 { |
|
483 return EFalse; |
|
484 } |
|
485 } |
|
486 |
|
487 return ETrue; |
|
488 } |
|
489 |
|
490 |
|
491 // ----------------------------------------------------------------------------- |
|
492 // NcsUtility::Measures |
|
493 // ----------------------------------------------------------------------------- |
|
494 // |
|
495 TNcsMeasures NcsUtility::Measures() |
|
496 { |
|
497 FUNC_LOG; |
|
498 |
|
499 TNcsMeasures ms; |
|
500 |
|
501 TAknUiZoom zoomLevel = EAknUiZoomNormal; |
|
502 CAknEnv::Static()->GetCurrentGlobalUiZoom( zoomLevel ); |
|
503 switch ( zoomLevel ) |
|
504 { |
|
505 case EAknUiZoomNormal: case EAknUiZoomAutomatic: |
|
506 { |
|
507 ms.iAifHeight = KAifHeight; |
|
508 ms.iAifLabelMarginVertical = KAifLabelMarginVertical; |
|
509 ms.iAifEditorMarginVertical = KAifEditorMarginVertical; |
|
510 ms.iAifEditorHeight = KAifEditorHeight; |
|
511 ms.iSubjectExtraHeightBottom = KSubjectExtraHeightBottom; |
|
512 ms.iAttachmentExtraHeightBottom = KAttachmentExtraHeightBottom; |
|
513 ms.iIconMarginPriorityVertical = KIconMarginPriorityVertical; |
|
514 ms.iIconMarginFollowUpVertical = KIconMarginFollowUpVertical; |
|
515 ms.iIconMarginAttachmentVertical = KIconMarginAttachmentVertical; |
|
516 ms.iLabelFontHeightPx = KLabelFontHeightPx; |
|
517 ms.iEditorFontHeightPx = KEditorFontHeightPx; |
|
518 } |
|
519 break; |
|
520 case EAknUiZoomSmall: case EAknUiZoomVerySmall: |
|
521 { |
|
522 ms.iAifHeight = KAifHeightSmall; |
|
523 ms.iAifLabelMarginVertical = KAifLabelMarginVerticalSmall; |
|
524 ms.iAifEditorMarginVertical = KAifEditorMarginVerticalSmall; |
|
525 ms.iAifEditorHeight = KAifEditorHeightSmall; |
|
526 ms.iSubjectExtraHeightBottom = KSubjectExtraHeightBottomSmall; |
|
527 ms.iAttachmentExtraHeightBottom = |
|
528 KAttachmentExtraHeightBottomSmall; |
|
529 ms.iIconMarginPriorityVertical = KIconMarginPriorityVerticalSmall; |
|
530 ms.iIconMarginFollowUpVertical = KIconMarginFollowUpVerticalSmall; |
|
531 ms.iIconMarginAttachmentVertical = |
|
532 KIconMarginAttachmentVerticalSmall; |
|
533 ms.iLabelFontHeightPx = KLabelFontHeightPxSmall; |
|
534 ms.iEditorFontHeightPx = KEditorFontHeightPxSmall; |
|
535 } |
|
536 break; |
|
537 case EAknUiZoomLarge: case EAknUiZoomVeryLarge: |
|
538 { |
|
539 ms.iAifHeight = KAifHeightLarge; |
|
540 ms.iAifLabelMarginVertical = KAifLabelMarginVerticalLarge; |
|
541 ms.iAifEditorMarginVertical = KAifEditorMarginVerticalLarge; |
|
542 ms.iAifEditorHeight = KAifEditorHeightLarge; |
|
543 ms.iSubjectExtraHeightBottom = KSubjectExtraHeightBottomLarge; |
|
544 ms.iAttachmentExtraHeightBottom = |
|
545 KAttachmentExtraHeightBottomLarge; |
|
546 ms.iIconMarginPriorityVertical = KIconMarginPriorityVerticalLarge; |
|
547 ms.iIconMarginFollowUpVertical = KIconMarginFollowUpVerticalLarge; |
|
548 ms.iIconMarginAttachmentVertical = |
|
549 KIconMarginAttachmentVerticalLarge; |
|
550 ms.iLabelFontHeightPx = KLabelFontHeightPxLarge; |
|
551 ms.iEditorFontHeightPx = KEditorFontHeightPxLarge; |
|
552 } |
|
553 break; |
|
554 } |
|
555 |
|
556 return ms; |
|
557 } |
|
558 |
|
559 // ----------------------------------------------------------------------------- |
|
560 // NcsUtility::GetNearestFontL |
|
561 // ----------------------------------------------------------------------------- |
|
562 // |
|
563 CFont* NcsUtility::GetNearestFontL( TInt aLogicalFontId, TInt aHeightPixels ) |
|
564 { |
|
565 FUNC_LOG; |
|
566 |
|
567 // Base the font on logical font passed to us |
|
568 const CFont* logicalFont = AknLayoutUtils::FontFromId( aLogicalFontId ); |
|
569 // Note: This font is owned by the application's system font array (where |
|
570 // it is likely already to have been created) and does not need to be |
|
571 // released. It can just go out of scope. |
|
572 |
|
573 // Extract font information |
|
574 TFontSpec fontSpec = logicalFont->FontSpecInTwips(); |
|
575 |
|
576 // Desired height, weight, and posture |
|
577 CWsScreenDevice& screenDev = *( CEikonEnv::Static()->ScreenDevice() ); |
|
578 fontSpec.iHeight = screenDev.VerticalPixelsToTwips( aHeightPixels ); |
|
579 fontSpec.iFontStyle.SetStrokeWeight( EStrokeWeightNormal ); |
|
580 fontSpec.iFontStyle.SetPosture( EPostureUpright ); |
|
581 |
|
582 // Obtain new font |
|
583 CFont* font; |
|
584 |
|
585 TInt err = screenDev.GetNearestFontInTwips( font, fontSpec ); |
|
586 User::LeaveIfError( err ); |
|
587 |
|
588 return font; |
|
589 // Font is now usable. Must be released before application |
|
590 // exit using CWsScreenDevice::ReleaseFont() |
|
591 } |
|
592 |
|
593 // <cmail> Platform layout change |
|
594 // ----------------------------------------------------------------------------- |
|
595 // NcsUtility::GetLayoutFont |
|
596 // ----------------------------------------------------------------------------- |
|
597 // |
|
598 const CFont* NcsUtility::GetLayoutFont( |
|
599 const TRect& aParent, TNcsLayoutFont aUsage ) |
|
600 { |
|
601 FUNC_LOG; |
|
602 TAknLayoutText layoutText; |
|
603 switch (aUsage) |
|
604 { |
|
605 case ENcsHeaderCaptionFont: |
|
606 { |
|
607 layoutText.LayoutText(aParent, AknLayoutScalable_Apps::list_single_cmail_header_caption_pane_t1()); |
|
608 break; |
|
609 } |
|
610 case ENcsHeaderDetailFont: |
|
611 { |
|
612 layoutText.LayoutText(aParent, AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t1(0)); |
|
613 break; |
|
614 } |
|
615 case ENcsBodytextFont: |
|
616 { |
|
617 layoutText.LayoutText(aParent, AknLayoutScalable_Apps::list_cmail_body_pane_t1()); |
|
618 break; |
|
619 } |
|
620 } |
|
621 return layoutText.Font(); |
|
622 } |
|
623 // </cmail> |
|
624 |
|
625 // ----------------------------------------------------------------------------- |
|
626 // NcsUtility::IsEditReplyForwardQuoteSupported |
|
627 // ----------------------------------------------------------------------------- |
|
628 // |
|
629 TBool NcsUtility::IsReplyForwardQuoteReadOnly( const CFSMailBox& aMailBox ) |
|
630 { |
|
631 FUNC_LOG; |
|
632 TBool r = aMailBox.HasCapability( EFSMBoxCapaReadOnlySmartQuote ); |
|
633 return r; |
|
634 } |
|
635 |
|
636 // ----------------------------------------------------------------------------- |
|
637 // NcsUtility::FindFirstPrintableCharIndex |
|
638 // ----------------------------------------------------------------------------- |
|
639 // |
|
640 TInt NcsUtility::FindFirstPrintableCharIndex( const TDesC& aText ) |
|
641 { |
|
642 FUNC_LOG; |
|
643 for ( TInt i=0; i<aText.Length(); i++ ) |
|
644 { |
|
645 TChar c = aText[i]; |
|
646 if ( c.IsGraph() ) |
|
647 { |
|
648 return i; |
|
649 } |
|
650 else |
|
651 { |
|
652 continue; |
|
653 } |
|
654 } |
|
655 return KErrNotFound; |
|
656 } |
|
657 |
|
658 // ----------------------------------------------------------------------------- |
|
659 // NcsUtility::ConvertCharacters |
|
660 // ----------------------------------------------------------------------------- |
|
661 // |
|
662 void NcsUtility::ConvertCharacters( TDes& aBuffer, TUint16 aFrom, TUint16 aTo ) |
|
663 { |
|
664 FUNC_LOG; |
|
665 for ( TInt i=0; i<aBuffer.Length(); i++ ) |
|
666 { |
|
667 if ( aBuffer[i] == aFrom ) |
|
668 { |
|
669 aBuffer[i] = aTo; |
|
670 } |
|
671 } |
|
672 } |
|
673 |
|
674 // ----------------------------------------------------------------------------- |
|
675 // NcsUtility::ConvertLineEndingsL |
|
676 // ----------------------------------------------------------------------------- |
|
677 // |
|
678 void NcsUtility::ConvertLineEndingsL( HBufC*& aBuffer ) |
|
679 { |
|
680 FUNC_LOG; |
|
681 // find line ending positions |
|
682 RArray<TInt> positions; |
|
683 CleanupClosePushL( positions ); |
|
684 for ( TInt i=0; i<aBuffer->Length(); i++ ) |
|
685 { |
|
686 if ( (*aBuffer)[i] == (TInt32)CEditableText::EParagraphDelimiter ) |
|
687 { |
|
688 positions.Append( i ); |
|
689 } |
|
690 } |
|
691 |
|
692 // case when there are no line endings can be early exited |
|
693 if ( positions.Count() <= 0 ) |
|
694 { |
|
695 CleanupStack::PopAndDestroy( &positions ); |
|
696 return; |
|
697 } |
|
698 |
|
699 // we need to do the conversion |
|
700 // initialize |
|
701 const TChar KCR = 0x0D; |
|
702 const TChar KLF = 0x0A; |
|
703 TInt startPos = 0; |
|
704 TInt length = 0; |
|
705 |
|
706 // create destination buffer |
|
707 HBufC* newBuffer = HBufC::NewL( aBuffer->Length() + positions.Count() * 2 ); |
|
708 TPtr dstPtr = newBuffer->Des(); |
|
709 |
|
710 // do the conversion |
|
711 for ( TInt i=0; i<positions.Count(); i++ ) |
|
712 { |
|
713 // copy text, no line ending |
|
714 length = positions[i] - startPos; |
|
715 TPtrC16 srcPtr = aBuffer->Mid( startPos, length ); |
|
716 dstPtr.Append( srcPtr ); |
|
717 startPos = positions[i] + 1; |
|
718 // append line ending |
|
719 dstPtr.Append( KCR ); |
|
720 dstPtr.Append( KLF ); |
|
721 } |
|
722 // handle the text piece after last line ending if there is such |
|
723 const TInt lastPos = positions[ positions.Count() - 1 ]; |
|
724 const TInt high = aBuffer->Length() - 1; |
|
725 if ( lastPos < high ) |
|
726 { |
|
727 const TInt start = lastPos + 1; |
|
728 TPtrC16 srcPtr = aBuffer->Mid( start, aBuffer->Length() - start ); |
|
729 dstPtr.Append( srcPtr ); |
|
730 } |
|
731 // delete old buffer and give pointer to new one |
|
732 delete aBuffer; |
|
733 aBuffer = newBuffer; |
|
734 CleanupStack::PopAndDestroy( &positions ); |
|
735 } |
|
736 |
|
737 // ----------------------------------------------------------------------------- |
|
738 // NcsUtility::DeleteMessage |
|
739 // ----------------------------------------------------------------------------- |
|
740 // |
|
741 TInt NcsUtility::DeleteMessage( CFSMailClient& aMailClient, |
|
742 const TFSMailMsgId& aMailBoxId, |
|
743 const TFSMailMsgId& aFolderId, |
|
744 const TFSMailMsgId& aMsgId ) |
|
745 { |
|
746 FUNC_LOG; |
|
747 RArray<TFSMailMsgId> msgIds; |
|
748 TInt error = msgIds.Append( aMsgId ); |
|
749 if ( error == KErrNone ) |
|
750 { |
|
751 TRAP( error, aMailClient.DeleteMessagesByUidL( aMailBoxId, aFolderId, |
|
752 msgIds ) ); |
|
753 } |
|
754 msgIds.Close(); |
|
755 return error; |
|
756 } |
|
757 |
|
758 // ----------------------------------------------------------------------------- |
|
759 // NcsUtility::HeaderCaptionPaneRect |
|
760 // ----------------------------------------------------------------------------- |
|
761 // |
|
762 TRect NcsUtility::HeaderCaptionPaneRect( const TRect& aParent ) |
|
763 { |
|
764 FUNC_LOG; |
|
765 TAknLayoutRect headerCaptionPaneRect; |
|
766 headerCaptionPaneRect.LayoutRect( aParent, AknLayoutScalable_Apps::list_single_cmail_header_caption_pane() ); |
|
767 return headerCaptionPaneRect.Rect(); |
|
768 } |
|
769 |
|
770 // ----------------------------------------------------------------------------- |
|
771 // NcsUtility::HeaderDetailPaneRect |
|
772 // ----------------------------------------------------------------------------- |
|
773 // |
|
774 TRect NcsUtility::HeaderDetailPaneRect( |
|
775 const TRect& aParent, const TInt aRows, TBool aSameRow ) |
|
776 { |
|
777 FUNC_LOG; |
|
778 const TInt variety( aRows == 1 ? 0 : 1 ); |
|
779 TAknLayoutRect headerDetailPaneRect; |
|
780 headerDetailPaneRect.LayoutRect( aParent, AknLayoutScalable_Apps::list_single_cmail_header_detail_pane( variety ) ); |
|
781 TRect result( headerDetailPaneRect.Rect() ); |
|
782 if (!aSameRow) |
|
783 { |
|
784 result.Move( 0, HeaderCaptionPaneRect( aParent ).Height() ); |
|
785 } |
|
786 return result; |
|
787 } |
|
788 |
|
789 // ----------------------------------------------------------------------------- |
|
790 // NcsUtility::HeaderDetailIconRect |
|
791 // ----------------------------------------------------------------------------- |
|
792 // |
|
793 TRect NcsUtility::HeaderDetailIconRect( |
|
794 const TRect& aParent, const TInt aRows, const THeaderDetailIcon aIcon ) |
|
795 { |
|
796 FUNC_LOG; |
|
797 const TInt variety( aRows == 1 ? 0 : 1 ); |
|
798 TAknLayoutRect headerIconRect; |
|
799 headerIconRect.LayoutRect( aParent, |
|
800 aIcon == EIconFront ? |
|
801 AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_g1( variety ) : |
|
802 AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_g2( variety ) ); |
|
803 // Offset detail rect by header caption pane height |
|
804 TRect result( headerIconRect.Rect() ); |
|
805 //result.Move( 0, HeaderCaptionPaneRect( aParent ).Height() ); |
|
806 return result; |
|
807 } |
|
808 |
|
809 // ----------------------------------------------------------------------------- |
|
810 // NcsUtility::ListscrollPaneRect |
|
811 // ----------------------------------------------------------------------------- |
|
812 TRect NcsUtility::ListscrollPaneRect() |
|
813 { |
|
814 FUNC_LOG; |
|
815 TRect mainPaneRect; |
|
816 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
817 TAknLayoutRect listRect; |
|
818 listRect.LayoutRect( mainPaneRect, AknLayoutScalable_Apps::main_sp_fs_listscroll_pane_te() ); |
|
819 return listRect.Rect(); |
|
820 } |
|
821 |
|
822 // ----------------------------------------------------------------------------- |
|
823 // NcsUtility::ListCmailPaneRect |
|
824 // ----------------------------------------------------------------------------- |
|
825 // |
|
826 TRect NcsUtility::ListCmailPaneRect( const TRect& aParent ) |
|
827 { |
|
828 FUNC_LOG; |
|
829 TAknLayoutRect listCmailPaneRect; |
|
830 listCmailPaneRect.LayoutRect( aParent, AknLayoutScalable_Apps::list_cmail_pane() ); |
|
831 return listCmailPaneRect.Rect(); |
|
832 } |
|
833 |
|
834 // ----------------------------------------------------------------------------- |
|
835 // NcsUtility::ListCmailScrollbarRect |
|
836 // ----------------------------------------------------------------------------- |
|
837 // |
|
838 TRect NcsUtility::ListCmailScrollbarRect( const TRect& aParent ) |
|
839 { |
|
840 FUNC_LOG; |
|
841 TAknLayoutRect listCmailPaneRect; |
|
842 listCmailPaneRect.LayoutRect( aParent, AknLayoutScalable_Apps::sp_fs_scroll_pane_cp03() ); |
|
843 return listCmailPaneRect.Rect(); |
|
844 } |
|
845 |
|
846 // ----------------------------------------------------------------------------- |
|
847 // NcsUtility::SeparatorSizeInThisResolution |
|
848 // |
|
849 // Returns size of empty space between header and message body |
|
850 // ----------------------------------------------------------------------------- |
|
851 // |
|
852 TSize NcsUtility::SeparatorSizeInThisResolution() |
|
853 { |
|
854 FUNC_LOG; |
|
855 |
|
856 TRect mainPaneRect; |
|
857 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); |
|
858 |
|
859 TAknLayoutRect listRect; |
|
860 listRect.LayoutRect(mainPaneRect, AknLayoutScalable_Apps::list_cmail_pane()); |
|
861 |
|
862 TAknLayoutRect bodyRect; |
|
863 bodyRect.LayoutRect(listRect.Rect(), AknLayoutScalable_Apps::list_cmail_body_pane()); |
|
864 |
|
865 TRect rect( bodyRect.Rect() ); |
|
866 rect.Shrink( 0, bodyRect.Rect().Height() / 4 ); |
|
867 return rect.Size(); |
|
868 } |
|
869 |
|
870 |
|
871 |
|
872 // ----------------------------------------------------------------------------- |
|
873 // NcsUtility::SeparatorLineColor |
|
874 // ----------------------------------------------------------------------------- |
|
875 // |
|
876 TRgb NcsUtility::SeparatorLineColor() |
|
877 { |
|
878 FUNC_LOG; |
|
879 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
880 TRgb rgb; |
|
881 if (AknsUtils::GetCachedColor( skin, rgb, |
|
882 KAknsIIDQsnLineColors, EAknsCIQsnLineColorsCG6) != KErrNone ) |
|
883 { |
|
884 rgb = KRgbBlack; |
|
885 } |
|
886 |
|
887 return rgb; |
|
888 } |
|
889 |
|
890 // ----------------------------------------------------------------------------- |
|
891 // NcsUtility::ComposerLeftMarginInPixels |
|
892 // |
|
893 // Left margin value for additional graphics in composer view |
|
894 // ----------------------------------------------------------------------------- |
|
895 // |
|
896 TInt NcsUtility::ComposerLeftMarginInPixels( const TRect& aParent ) |
|
897 { |
|
898 FUNC_LOG; |
|
899 const TRect cmailPaneRect( ListCmailPaneRect( aParent ) ); |
|
900 TAknLayoutRect layoutRect; |
|
901 layoutRect.LayoutRect( cmailPaneRect, AknLayoutScalable_Apps::list_single_cmail_header_caption_pane() ); |
|
902 TAknLayoutText captionTextRect; |
|
903 captionTextRect.LayoutText( layoutRect.Rect(), AknLayoutScalable_Apps::list_single_cmail_header_caption_pane_t1() ); |
|
904 return Abs( cmailPaneRect.iTl.iX - captionTextRect.TextRect().iTl.iX ); |
|
905 } |
|
906 |
|
907 // ----------------------------------------------------------------------------- |
|
908 // NcsUtility::ComposerRightMarginInPixels |
|
909 // |
|
910 // Right margin value for additional graphics in composer view |
|
911 // ----------------------------------------------------------------------------- |
|
912 // |
|
913 TInt NcsUtility::ComposerRightMarginInPixels( const TRect& aParent ) |
|
914 { |
|
915 FUNC_LOG; |
|
916 const TRect cmailPaneRect( ListCmailPaneRect( aParent ) ); |
|
917 TAknLayoutRect layoutRect; |
|
918 layoutRect.LayoutRect( cmailPaneRect, AknLayoutScalable_Apps::list_single_cmail_header_caption_pane() ); |
|
919 TAknLayoutText captionTextRect; |
|
920 captionTextRect.LayoutText( layoutRect.Rect(), AknLayoutScalable_Apps::list_single_cmail_header_caption_pane_t1() ); |
|
921 return Abs( cmailPaneRect.iBr.iX - captionTextRect.TextRect().iBr.iX ); |
|
922 } |
|
923 |
|
924 // ----------------------------------------------------------------------------- |
|
925 // NcsUtility::ListCmailBodyPaneRect |
|
926 // ----------------------------------------------------------------------------- |
|
927 // |
|
928 TRect NcsUtility::ListCmailBodyPaneRect( const TRect& aParent ) |
|
929 { |
|
930 FUNC_LOG; |
|
931 TAknLayoutRect listCmailBodyRect; |
|
932 listCmailBodyRect.LayoutRect( aParent, AknLayoutScalable_Apps::list_cmail_body_pane() ); |
|
933 return listCmailBodyRect.Rect(); |
|
934 } |
|
935 |
|
936 // ----------------------------------------------------------------------------- |
|
937 // NcsUtility::LayoutCaptionLabel |
|
938 // ----------------------------------------------------------------------------- |
|
939 // |
|
940 void NcsUtility::LayoutCaptionLabel( CEikLabel* aLabel, const TRect& aParentRect ) |
|
941 { |
|
942 FUNC_LOG; |
|
943 AknLayoutUtils::LayoutLabel( |
|
944 aLabel, NcsUtility::HeaderCaptionPaneRect( aParentRect ), |
|
945 AknLayoutScalable_Apps::list_single_cmail_header_caption_pane_t1().LayoutLine() ); |
|
946 } |
|
947 |
|
948 // ----------------------------------------------------------------------------- |
|
949 // NcsUtility::LayoutCaptionLabel |
|
950 // ----------------------------------------------------------------------------- |
|
951 // |
|
952 void NcsUtility::LayoutCaptionButton( |
|
953 CAknButton* aButton, const TRect& aParentRect) |
|
954 { |
|
955 FUNC_LOG; |
|
956 TAknLayoutText layoutText; |
|
957 |
|
958 const TInt labelVariety = 2; |
|
959 TAknTextComponentLayout textComponentLayout; |
|
960 TAknLayoutRect layoutRect; |
|
961 TRect rect; |
|
962 |
|
963 TInt fontId; |
|
964 TInt topMargin; |
|
965 TInt bottomMargin; |
|
966 |
|
967 // Getting editor's top and bottom margin from its layout |
|
968 textComponentLayout = |
|
969 AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t1( |
|
970 KHeaderDetailTextPaneVariety ); |
|
971 fontId = textComponentLayout.LayoutLine().FontId(); |
|
972 |
|
973 TAknTextDecorationMetrics metrics( fontId ); |
|
974 metrics.GetTopAndBottomMargins( topMargin, bottomMargin ); |
|
975 |
|
976 layoutRect.LayoutRect( |
|
977 HeaderDetailPaneRect( aParentRect, 1, ETrue ), |
|
978 AknLayoutScalable_Apps::bg_button_pane_cp12() ); |
|
979 |
|
980 textComponentLayout = |
|
981 AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t2( |
|
982 labelVariety ); |
|
983 layoutText.LayoutText( |
|
984 HeaderDetailPaneRect( aParentRect, 1, ETrue ), |
|
985 textComponentLayout.LayoutLine() ); |
|
986 |
|
987 rect = layoutRect.Rect(); |
|
988 rect.iTl.iY -= topMargin + bottomMargin; |
|
989 |
|
990 aButton->SetRect( rect ); |
|
991 aButton->SetTextFont( layoutText.Font() ); |
|
992 aButton->SetTextHorizontalAlignment( layoutText.Align() ); |
|
993 TMargins8 margs( 0, 0, 5, 0 ); |
|
994 aButton->SetMargins( margs ); |
|
995 } |
|
996 |
|
997 // ----------------------------------------------------------------------------- |
|
998 // NcsUtility::LayoutDetailLabel |
|
999 // ----------------------------------------------------------------------------- |
|
1000 // |
|
1001 void NcsUtility::LayoutDetailLabel( |
|
1002 CEikLabel* aLabel, const TRect& aParentRect, TInt aRow) |
|
1003 { |
|
1004 FUNC_LOG; |
|
1005 TRect rect( NcsUtility::HeaderDetailPaneRect( aParentRect, 1, ETrue ) ); |
|
1006 rect.Move( 0, aRow*rect.Height() ); |
|
1007 AknLayoutUtils::LayoutLabel( aLabel, rect, AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t1( 0 ).LayoutLine() ); |
|
1008 } |
|
1009 |
|
1010 // ----------------------------------------------------------------------------- |
|
1011 // NcsUtility::LayoutDetailEdwin |
|
1012 // ----------------------------------------------------------------------------- |
|
1013 // |
|
1014 void NcsUtility::LayoutDetailEdwin( |
|
1015 CEikEdwin* aEdwin, const TRect& aParentRect, |
|
1016 const TInt aLineCount, const TBool aBackIcon ) |
|
1017 { |
|
1018 FUNC_LOG; |
|
1019 TAknMultiLineTextLayout edwinLayout; |
|
1020 const TInt textPaneVariety( aBackIcon ? 1 : 3 ); |
|
1021 TAknTextComponentLayout textLayout( AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t1( textPaneVariety ) ); |
|
1022 RArray< TAknTextComponentLayout > edwinLayoutLines; |
|
1023 TAknTextComponentLayout textRowLayout; |
|
1024 TAknWindowComponentLayout headerDetailPane( AknLayoutScalable_Apps::list_single_cmail_header_detail_pane( 0, 0, 0 ) ); |
|
1025 for ( TInt line = 0; line < aLineCount; line++ ) |
|
1026 { |
|
1027 textRowLayout = TAknWindowComponentLayout::ComposeText( TAknWindowComponentLayout::MultiLineY( headerDetailPane, line, 0 ), textLayout ); |
|
1028 edwinLayoutLines.Append( textRowLayout ); |
|
1029 } |
|
1030 AknLayoutUtils::LayoutEdwin( aEdwin, NcsUtility::HeaderDetailPaneRect( aParentRect, aLineCount ), TAknTextComponentLayout::Multiline( edwinLayoutLines ) ); |
|
1031 edwinLayoutLines.Reset(); |
|
1032 } |
|
1033 |
|
1034 // ----------------------------------------------------------------------------- |
|
1035 // NcsUtility::LayoutDetailEdwin |
|
1036 // ----------------------------------------------------------------------------- |
|
1037 // |
|
1038 void NcsUtility::LayoutDetailEdwinTouch( |
|
1039 CEikEdwin* aEdwin, const TRect& aParentRect, |
|
1040 const TInt aLineCount, const TBool /*aBackIcon*/ ) |
|
1041 { |
|
1042 FUNC_LOG; |
|
1043 TAknMultiLineTextLayout edwinLayout; |
|
1044 TAknTextComponentLayout textLayout( AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t1( KHeaderDetailTextPaneVariety ) ); |
|
1045 RArray< TAknTextComponentLayout > edwinLayoutLines; |
|
1046 TAknTextComponentLayout textRowLayout; |
|
1047 TAknWindowComponentLayout headerDetailPane( AknLayoutScalable_Apps::list_single_cmail_header_detail_pane( 0, 0, 0 ) ); |
|
1048 for ( TInt line = 0; line < aLineCount; line++ ) |
|
1049 { |
|
1050 textRowLayout = TAknWindowComponentLayout::ComposeText( TAknWindowComponentLayout::MultiLineY( headerDetailPane, line, 0 ), textLayout ); |
|
1051 edwinLayoutLines.Append( textRowLayout ); |
|
1052 } |
|
1053 AknLayoutUtils::LayoutEdwin( aEdwin, NcsUtility::HeaderDetailPaneRect( aParentRect, aLineCount, ETrue ), TAknTextComponentLayout::Multiline( edwinLayoutLines ) ); |
|
1054 edwinLayoutLines.Reset(); |
|
1055 } |
|
1056 |
|
1057 // ----------------------------------------------------------------------------- |
|
1058 // NcsUtility::HeaderControlPosition |
|
1059 // ----------------------------------------------------------------------------- |
|
1060 // |
|
1061 TPoint NcsUtility::HeaderControlPosition( |
|
1062 const TRect& aParentRect, const TInt aCurrentLine ) |
|
1063 { |
|
1064 FUNC_LOG; |
|
1065 TAknLayoutRect detailPane; |
|
1066 TAknWindowComponentLayout headerDetailPane( AknLayoutScalable_Apps::list_single_cmail_header_detail_pane( 0, 0, 0 ) ); |
|
1067 detailPane.LayoutRect( aParentRect, TAknWindowComponentLayout::MultiLineY( headerDetailPane, aCurrentLine, 0 ) ); |
|
1068 return detailPane.Rect().iTl; |
|
1069 } |
|
1070 |
|
1071 // ----------------------------------------------------------------------------- |
|
1072 // NcsUtility::LayoutHeaderControl |
|
1073 // ----------------------------------------------------------------------------- |
|
1074 // |
|
1075 void NcsUtility::LayoutHeaderControl( |
|
1076 CCoeControl* aControl, const TRect& aParentRect, |
|
1077 const TInt aCurrentLine, const TInt aNumberOfLines ) |
|
1078 { |
|
1079 FUNC_LOG; |
|
1080 TAknLayoutRect detailPane; |
|
1081 TAknWindowComponentLayout headerDetailPane( AknLayoutScalable_Apps::list_single_cmail_header_detail_pane( 0, 0, 0 ) ); |
|
1082 detailPane.LayoutRect( aParentRect, TAknWindowComponentLayout::MultiLineY( headerDetailPane, aCurrentLine, 0 ) ); |
|
1083 TRect rect( detailPane.Rect() ); |
|
1084 rect.SetHeight( rect.Height() * aNumberOfLines ); |
|
1085 aControl->SetRect( rect ); |
|
1086 } |
|
1087 |
|
1088 // ----------------------------------------------------------------------------- |
|
1089 // NcsUtility::LayoutBodyEdwin |
|
1090 // ----------------------------------------------------------------------------- |
|
1091 // |
|
1092 void NcsUtility::LayoutBodyEdwin( |
|
1093 CEikEdwin* aEdwin, const TRect& aParentRect, const TInt aCurrentLine, |
|
1094 const TInt aNumberOfLines, TInt& aSeparatorYPosition ) |
|
1095 { |
|
1096 FUNC_LOG; |
|
1097 TAknMultiLineTextLayout edwinLayout; |
|
1098 TAknTextComponentLayout textLayout( AknLayoutScalable_Apps::list_cmail_body_pane_t1() ); |
|
1099 RArray< TAknTextComponentLayout > edwinLayoutLines; |
|
1100 TAknTextComponentLayout textRowLayout; |
|
1101 TAknWindowComponentLayout headerCaptionPane( AknLayoutScalable_Apps::list_single_cmail_header_caption_pane( 0, 0, 0 ) ); |
|
1102 TInt lines = Max( aNumberOfLines, 2 ); |
|
1103 for ( TInt line = 0; line < lines; line++ ) |
|
1104 { |
|
1105 textRowLayout = TAknWindowComponentLayout::ComposeText( TAknWindowComponentLayout::MultiLineY( headerCaptionPane, line, 0 ), textLayout ); |
|
1106 edwinLayoutLines.Append( textRowLayout ); |
|
1107 } |
|
1108 TAknLayoutRect bodyPane; |
|
1109 bodyPane.LayoutRect( aParentRect, AknLayoutScalable_Apps::list_cmail_body_pane() ); |
|
1110 TRect bodyRect( bodyPane.Rect() ); |
|
1111 TAknLayoutRect detailPane; |
|
1112 TAknWindowComponentLayout headerDetailPane( AknLayoutScalable_Apps::list_single_cmail_header_detail_pane( 0, 0, 0 ) ); |
|
1113 detailPane.LayoutRect( aParentRect, TAknWindowComponentLayout::MultiLineY( headerDetailPane, aCurrentLine, 0 ) ); |
|
1114 bodyRect = TRect( detailPane.Rect().iTl, bodyRect.Size() ); |
|
1115 aSeparatorYPosition = bodyRect.iTl.iY; |
|
1116 // Since layout doesn't specify enough space between separator line |
|
1117 // and editor, we add some space manually |
|
1118 TInt deltaMove = NcsUtility::SeparatorSizeInThisResolution().iHeight; |
|
1119 bodyRect.Move( 0, deltaMove ); |
|
1120 AknLayoutUtils::LayoutEdwin( aEdwin, bodyRect, TAknTextComponentLayout::Multiline( edwinLayoutLines ), EAknsCIQsnTextColorsCG6 ); |
|
1121 edwinLayoutLines.Reset(); |
|
1122 } |
|
1123 |
|
1124 // ----------------------------------------------------------------------------- |
|
1125 // NcsUtility::CalculateSeparatorLineSecondaryColor |
|
1126 // |
|
1127 // Calculates secondary color value based on the start value. Useful for |
|
1128 // gradient drawing. |
|
1129 // @param aDegree = color change coefficient |
|
1130 // ----------------------------------------------------------------------------- |
|
1131 // |
|
1132 TRgb NcsUtility::CalculateSeparatorLineSecondaryColor( TInt aDegree, |
|
1133 TRgb /*aStartColor*/ ) |
|
1134 { |
|
1135 TRgb secondaryColor; |
|
1136 TInt redValue; |
|
1137 TInt greenValue; |
|
1138 TInt blueValue; |
|
1139 TRgb startColor = SeparatorLineColor(); |
|
1140 if( startColor.Red() > KFSUtilityThresholdColorValue && |
|
1141 startColor.Green() > KFSUtilityThresholdColorValue && |
|
1142 startColor.Blue() > KFSUtilityThresholdColorValue ) |
|
1143 { |
|
1144 //Original color is bright, so let's make secondary color darker |
|
1145 redValue = startColor.Red() - ( startColor.Red() / aDegree ); |
|
1146 greenValue = startColor.Green() - ( startColor.Green() / aDegree ); |
|
1147 blueValue = startColor.Blue() - ( startColor.Blue() / aDegree ); |
|
1148 } |
|
1149 else |
|
1150 { |
|
1151 //Original color is dark, so let's make secondary color brighter |
|
1152 //Checking how bright original color is |
|
1153 if( startColor.Red() < KFSUtilityThresholdColorMiddleValue && |
|
1154 startColor.Green() < KFSUtilityThresholdColorMiddleValue && |
|
1155 startColor.Blue() < KFSUtilityThresholdColorMiddleValue ) |
|
1156 { |
|
1157 // Calculating new values from the unoccupied color space |
|
1158 redValue = startColor.Red() + ( ( |
|
1159 KFSUtilityMaxColorValue - startColor.Red() ) / aDegree ); |
|
1160 greenValue = startColor.Green() + ( ( |
|
1161 KFSUtilityMaxColorValue - startColor.Green() ) / aDegree ); |
|
1162 blueValue = startColor.Blue() + ( ( |
|
1163 KFSUtilityMaxColorValue - startColor.Blue() ) / aDegree ); |
|
1164 } |
|
1165 else |
|
1166 { |
|
1167 // Calculating new values from the occupied color space |
|
1168 redValue = startColor.Red() + ( startColor.Red() / aDegree ); |
|
1169 greenValue = startColor.Green() + ( startColor.Green() / aDegree ); |
|
1170 blueValue = startColor.Blue() + ( startColor.Blue() / aDegree ); |
|
1171 } |
|
1172 } |
|
1173 |
|
1174 if ( redValue > KFSUtilityMaxColorValue ) |
|
1175 { |
|
1176 redValue = KFSUtilityMaxColorValue; |
|
1177 } |
|
1178 if ( greenValue > KFSUtilityMaxColorValue ) |
|
1179 { |
|
1180 greenValue = KFSUtilityMaxColorValue; |
|
1181 } |
|
1182 if ( blueValue > KFSUtilityMaxColorValue ) |
|
1183 { |
|
1184 blueValue = KFSUtilityMaxColorValue; |
|
1185 } |
|
1186 return TRgb( redValue , greenValue, blueValue ); |
|
1187 } |
|
1188 |
|
1189 // ----------------------------------------------------------------------------- |
|
1190 // NcsUtility::CalculateMsgBodyLineColor |
|
1191 // |
|
1192 // Calculates line color to be used in message body. Calculated color is darker than |
|
1193 // given base color. |
|
1194 // @param aDegree = color darkening coefficient |
|
1195 // @param aBaseColor = base color to be used in calculation |
|
1196 // ----------------------------------------------------------------------------- |
|
1197 // |
|
1198 TRgb NcsUtility::CalculateMsgBodyLineColor( TInt aDegree, |
|
1199 TRgb aBaseColor ) |
|
1200 { |
|
1201 TInt redValue = aBaseColor.Red() - ( aBaseColor.Red() / aDegree ); |
|
1202 TInt greenValue = aBaseColor.Green() - ( aBaseColor.Green() / aDegree ); |
|
1203 TInt blueValue = aBaseColor.Blue() - ( aBaseColor.Blue() / aDegree ); |
|
1204 |
|
1205 if ( redValue < KFSUtilityMinColorValue ) |
|
1206 { |
|
1207 redValue = KFSUtilityMinColorValue; |
|
1208 } |
|
1209 if ( greenValue < KFSUtilityMinColorValue ) |
|
1210 { |
|
1211 greenValue = KFSUtilityMinColorValue; |
|
1212 } |
|
1213 if ( blueValue < KFSUtilityMinColorValue ) |
|
1214 { |
|
1215 blueValue = KFSUtilityMinColorValue; |
|
1216 } |
|
1217 |
|
1218 return TRgb( redValue , greenValue, blueValue ); |
|
1219 } |
|
1220 |
|
1221 //End of file |
|
1222 |