author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:11:15 +0300 | |
branch | RCL_3 |
changeset 80 | 726fba06891a |
parent 64 | 3533d4323edc |
permissions | -rw-r--r-- |
64 | 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: message editor |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include "emailtrace.h" |
|
20 |
#include <StringLoader.h> |
|
21 |
#include <AknUtils.h> |
|
22 |
#include <AknsUtils.h> |
|
23 |
#include <AknsSkinInstance.h> |
|
24 |
#include <FreestyleEmailUi.rsg> |
|
25 |
#include <touchfeedback.h> |
|
26 |
||
27 |
#include "FreestyleEmailUiLayoutData.h" |
|
28 |
#include "FreestyleEmailUiAppui.h" |
|
29 |
#include "FreestyleEmailUiTextureManager.h" |
|
30 |
#include "FreestyleEmailUiLayoutHandler.h" |
|
31 |
#include "ncsattachmentfield.h" |
|
32 |
#include "ncsutility.h" |
|
33 |
#include "ncsheadercontainer.h" |
|
34 |
#include "FSEmail.pan" |
|
35 |
||
36 |
||
37 |
CNcsAttachmentField* CNcsAttachmentField::NewL( |
|
38 |
TInt aLabelTextId, |
|
39 |
MNcsFieldSizeObserver* aSizeObserver, |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
40 |
MNcsAttachmentFieldObserver* aObserver, |
64 | 41 |
CNcsHeaderContainer* aParentControl ) |
42 |
{ |
|
43 |
FUNC_LOG; |
|
44 |
CNcsAttachmentField* self = |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
45 |
new ( ELeave ) CNcsAttachmentField( aLabelTextId, aSizeObserver, |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
46 |
aObserver, aParentControl ); |
64 | 47 |
CleanupStack::PushL( self ); |
48 |
self->ConstructL(); |
|
49 |
CleanupStack::Pop( self ); |
|
50 |
return self; |
|
51 |
} |
|
52 |
||
53 |
CNcsAttachmentField::~CNcsAttachmentField() |
|
54 |
{ |
|
55 |
FUNC_LOG; |
|
56 |
iAttachmentLabels.ResetAndDestroy(); |
|
57 |
||
58 |
delete iAttachmentNames; |
|
59 |
delete iAttachmentSizes; |
|
60 |
||
61 |
delete iAttachmentBitmap; |
|
62 |
delete iAttachmentMask; |
|
63 |
} |
|
64 |
||
65 |
// ----------------------------------------------------------------------------- |
|
66 |
// CNcsAttachmentField::CNcsAttachmentField() |
|
67 |
// ----------------------------------------------------------------------------- |
|
68 |
// |
|
69 |
CNcsAttachmentField::CNcsAttachmentField( TInt aLabelTextId, |
|
70 |
MNcsFieldSizeObserver* aSizeObserver, |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
71 |
MNcsAttachmentFieldObserver* aObserver, |
64 | 72 |
CNcsHeaderContainer* aParentControl ): |
73 |
MNcsControl( aSizeObserver ), |
|
74 |
iParentControl( aParentControl ), |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
75 |
iObserver( aObserver ), |
64 | 76 |
iLabelTextId ( aLabelTextId ), |
77 |
iFocusedLabelIndex( KNoAttachmentLabelFocused ) |
|
78 |
{ |
|
79 |
FUNC_LOG; |
|
80 |
} |
|
81 |
||
82 |
void CNcsAttachmentField::ConstructL() |
|
83 |
{ |
|
84 |
FUNC_LOG; |
|
85 |
CreateIconsL(); |
|
86 |
} |
|
87 |
||
88 |
// ----------------------------------------------------------------------------- |
|
89 |
// CNcsAttachmentField::LineCount() |
|
90 |
// ----------------------------------------------------------------------------- |
|
91 |
// |
|
92 |
TInt CNcsAttachmentField::LineCount() const |
|
93 |
{ |
|
94 |
FUNC_LOG; |
|
95 |
return 0; |
|
96 |
} |
|
97 |
||
98 |
// ----------------------------------------------------------------------------- |
|
99 |
// CNcsAttachmentField::ScrollableLines() |
|
100 |
// ----------------------------------------------------------------------------- |
|
101 |
// |
|
102 |
TInt CNcsAttachmentField::ScrollableLines() const |
|
103 |
{ |
|
104 |
FUNC_LOG; |
|
105 |
return 0; |
|
106 |
} |
|
107 |
||
108 |
// ----------------------------------------------------------------------------- |
|
109 |
// CNcsAttachmentField::GetNumChars() |
|
110 |
// ----------------------------------------------------------------------------- |
|
111 |
// |
|
112 |
TInt CNcsAttachmentField::GetNumChars() const |
|
113 |
{ |
|
114 |
FUNC_LOG; |
|
115 |
return 0; |
|
116 |
} |
|
117 |
||
118 |
// ----------------------------------------------------------------------------- |
|
119 |
// CNcsAttachmentField::CursorLineNumber() |
|
120 |
// ----------------------------------------------------------------------------- |
|
121 |
// |
|
122 |
TInt CNcsAttachmentField::CursorLineNumber() const |
|
123 |
{ |
|
124 |
FUNC_LOG; |
|
125 |
return 0; |
|
126 |
} |
|
127 |
||
128 |
// ----------------------------------------------------------------------------- |
|
129 |
// CNcsAttachmentField::CursorPosition() |
|
130 |
// ----------------------------------------------------------------------------- |
|
131 |
// |
|
132 |
TInt CNcsAttachmentField::CursorPosition() const |
|
133 |
{ |
|
134 |
FUNC_LOG; |
|
135 |
return 0; |
|
136 |
} |
|
137 |
||
138 |
// ----------------------------------------------------------------------------- |
|
139 |
// CNcsAttachmentField::Reposition() |
|
140 |
// ----------------------------------------------------------------------------- |
|
141 |
// |
|
142 |
void CNcsAttachmentField::Reposition(TPoint& aPt, TInt /*aWidth*/ ) |
|
143 |
{ |
|
144 |
FUNC_LOG; |
|
145 |
SetPosition( aPt ); |
|
146 |
} |
|
147 |
||
148 |
// ----------------------------------------------------------------------------- |
|
149 |
// CNcsAttachmentField::GetLabelText() |
|
150 |
// ----------------------------------------------------------------------------- |
|
151 |
// |
|
152 |
const TDesC& CNcsAttachmentField::GetLabelText() const |
|
153 |
{ |
|
154 |
FUNC_LOG; |
|
155 |
return KNullDesC; |
|
156 |
} |
|
157 |
||
158 |
// --------------------------------------------------------------------------- |
|
159 |
// CNcsAttachmentField::LayoutLineCount |
|
160 |
// --------------------------------------------------------------------------- |
|
161 |
// |
|
162 |
TInt CNcsAttachmentField::LayoutLineCount() const |
|
163 |
{ |
|
164 |
FUNC_LOG; |
|
165 |
return ( IsVisible() ? iAttachmentLabelCount : 0 ); |
|
166 |
} |
|
167 |
||
168 |
// ----------------------------------------------------------------------------- |
|
169 |
// CNcsAttachmentField::Draw() |
|
170 |
// ----------------------------------------------------------------------------- |
|
171 |
// |
|
172 |
void CNcsAttachmentField::Draw( const TRect& /*aRect*/ ) const |
|
173 |
{ |
|
174 |
FUNC_LOG; |
|
175 |
CWindowGc& gc = SystemGc(); |
|
176 |
||
177 |
// Draw text box |
|
178 |
if ( IsFocused() ) |
|
179 |
{ |
|
180 |
TBool highlighedFound( EFalse ); |
|
181 |
for ( TInt i( 0 ); !highlighedFound && i<iAttachmentLabelCount; ++i ) |
|
182 |
{ |
|
183 |
if ( iAttachmentLabels[i]->IsFocused() ) |
|
184 |
{ |
|
185 |
highlighedFound = ETrue; |
|
186 |
// highlight for label when focused |
|
187 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
188 |
TRgb imageColor; |
|
189 |
if( KErrNone != AknsUtils::GetCachedColor( |
|
190 |
skin, imageColor, |
|
191 |
KAknsIIDFsHighlightColors, |
|
192 |
EAknsCIFsHighlightColorsCG4 ) && |
|
193 |
KErrNone != AknsUtils::GetCachedColor( |
|
194 |
skin, imageColor, |
|
195 |
KAknsIIDQsnHighlightColors, |
|
196 |
EAknsCIQsnHighlightColorsCG2 ) ) |
|
197 |
{ |
|
198 |
imageColor = KRgbBlue; |
|
199 |
} |
|
200 |
||
201 |
gc.SetPenStyle( CGraphicsContext::ENullPen ); |
|
202 |
gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
203 |
gc.SetBrushColor( imageColor ); |
|
204 |
||
205 |
TRect highlightRect( |
|
206 |
iAttachmentLabels[i]->TextHitAreaRect() ); |
|
207 |
highlightRect.Grow( 0, 1 ); |
|
208 |
gc.DrawRect( highlightRect ); |
|
209 |
} |
|
210 |
} |
|
211 |
} |
|
212 |
||
213 |
// Draw icons |
|
214 |
gc.SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
215 |
gc.BitBltMasked( iAttachmentIconPos, iAttachmentBitmap, |
|
216 |
iAttachmentBitmap->SizeInPixels(), |
|
217 |
iAttachmentMask, ETrue ); |
|
218 |
} |
|
219 |
||
220 |
// ----------------------------------------------------------------------------- |
|
221 |
// CNcsAttachmentField::SizeChanged() |
|
222 |
// ----------------------------------------------------------------------------- |
|
223 |
// |
|
224 |
void CNcsAttachmentField::SizeChanged() |
|
225 |
{ |
|
226 |
FUNC_LOG; |
|
227 |
LayoutControls(); |
|
228 |
UpdateFontSize(); |
|
229 |
UpdateColors(); |
|
230 |
// The attachment texts needs to be updated when label size changes because it |
|
231 |
// may now get truncated differently. |
|
232 |
TRAP_IGNORE( UpdateAttachmentTextsL() ); |
|
233 |
} |
|
234 |
||
235 |
// ----------------------------------------------------------------------------- |
|
236 |
// CNcsAttachmentField::PositionChanged() |
|
237 |
// ----------------------------------------------------------------------------- |
|
238 |
// |
|
239 |
void CNcsAttachmentField::PositionChanged() |
|
240 |
{ |
|
241 |
FUNC_LOG; |
|
242 |
LayoutControls(); |
|
243 |
UpdateColors(); |
|
244 |
} |
|
245 |
||
246 |
// ----------------------------------------------------------------------------- |
|
247 |
// CNcsAttachmentField::MinimumHeight() |
|
248 |
// ----------------------------------------------------------------------------- |
|
249 |
// |
|
250 |
TInt CNcsAttachmentField::MinimumHeight() const |
|
251 |
{ |
|
252 |
FUNC_LOG; |
|
253 |
return 0; |
|
254 |
} |
|
255 |
||
256 |
// ----------------------------------------------------------------------------- |
|
257 |
// CNcsAttachmentField::SetMaxLabelLength() |
|
258 |
// ----------------------------------------------------------------------------- |
|
259 |
// |
|
260 |
void CNcsAttachmentField::SetMaxLabelLength( TInt aMaxLength ) |
|
261 |
{ |
|
262 |
FUNC_LOG; |
|
263 |
iMaximumLabelLength = aMaxLength; |
|
264 |
} |
|
265 |
||
266 |
// ----------------------------------------------------------------------------- |
|
267 |
// CNcsAttachmentField::GetMinLabelLength() |
|
268 |
// ----------------------------------------------------------------------------- |
|
269 |
// |
|
270 |
TInt CNcsAttachmentField::GetMinLabelLength() const |
|
271 |
{ |
|
272 |
FUNC_LOG; |
|
273 |
return 0; |
|
274 |
} |
|
275 |
||
276 |
// ----------------------------------------------------------------------------- |
|
277 |
// CNcsAttachmentField::SetContainerWindowL() |
|
278 |
// ----------------------------------------------------------------------------- |
|
279 |
// |
|
280 |
void CNcsAttachmentField::SetContainerWindowL( const CCoeControl& aContainer ) |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
281 |
{ |
64 | 282 |
FUNC_LOG; |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
283 |
CCoeControl::SetContainerWindowL( aContainer ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
284 |
UpdateComponentArrayL(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
285 |
} |
64 | 286 |
|
287 |
// ----------------------------------------------------------------------------- |
|
288 |
// CNcsAttachmentField::UpdateComponentArrayL() |
|
289 |
// ----------------------------------------------------------------------------- |
|
290 |
// |
|
291 |
void CNcsAttachmentField::UpdateComponentArrayL() |
|
292 |
{ |
|
293 |
FUNC_LOG; |
|
294 |
InitComponentArrayL(); |
|
295 |
CCoeControlArray& controls = Components(); |
|
296 |
TInt controlsCount( controls.Count() ); |
|
297 |
controls.SetControlsOwnedExternally( ETrue ); |
|
298 |
||
299 |
// Create the new component array items if needed |
|
300 |
if ( iAttachmentLabelCount > controlsCount ) |
|
301 |
{ |
|
302 |
// append controls for new attachment labels after the existing ones |
|
303 |
for ( TInt i( controlsCount ); i<iAttachmentLabelCount; ++i ) |
|
304 |
{ |
|
305 |
controls.AppendLC( iAttachmentLabels[i] ); |
|
306 |
CleanupStack::Pop( iAttachmentLabels[i] ); |
|
307 |
||
308 |
UpdateFontSize( iAttachmentLabels[i] ); |
|
309 |
||
310 |
// Align according to mirrored layout variation |
|
311 |
iAttachmentLabels[i]->SetAlignment( AknLayoutUtils::LayoutMirrored() ? |
|
312 |
EHRightVCenter : EHLeftVCenter ); |
|
313 |
} |
|
314 |
} |
|
315 |
// Remove unnecessary component array items from the end |
|
316 |
else if ( iAttachmentLabelCount < controlsCount ) |
|
317 |
{ |
|
318 |
for ( TInt i( controlsCount-1 ); i>=iAttachmentLabelCount ; --i ) |
|
319 |
{ |
|
320 |
controls.Remove( iAttachmentLabels[i] ); |
|
321 |
} |
|
322 |
} |
|
323 |
} |
|
324 |
||
325 |
// ----------------------------------------------------------------------------- |
|
326 |
// CNcsAttachmentField::SetTextsLD() |
|
327 |
// ----------------------------------------------------------------------------- |
|
328 |
// |
|
329 |
void CNcsAttachmentField::SetTextsLD( |
|
330 |
CDesCArray* aAttachmentNames, CDesCArray* aAttachmentSizes ) |
|
331 |
{ |
|
332 |
FUNC_LOG; |
|
333 |
delete iAttachmentNames; |
|
334 |
iAttachmentNames = NULL; |
|
335 |
iAttachmentNames = aAttachmentNames; |
|
336 |
delete iAttachmentSizes; |
|
337 |
iAttachmentSizes = NULL; |
|
338 |
iAttachmentSizes = aAttachmentSizes; |
|
339 |
||
340 |
if ( iAttachmentNames ) |
|
341 |
{ |
|
342 |
__ASSERT_DEBUG( iAttachmentNames && |
|
343 |
iAttachmentSizes && |
|
344 |
iAttachmentNames->Count() == iAttachmentSizes->Count(), |
|
345 |
Panic( ENcsBasicUi ) ); |
|
346 |
||
347 |
TInt attachmentLabelCountBeforeUpdate( iAttachmentLabelCount ); |
|
348 |
||
349 |
UpdateAttachmentTextsL(); |
|
350 |
||
351 |
// set the focused attachment label |
|
352 |
if ( iAttachmentLabelCount == 0 ) |
|
353 |
{ |
|
354 |
// No attachments |
|
355 |
iFocusedLabelIndex = KNoAttachmentLabelFocused; |
|
356 |
} |
|
357 |
else if ( iFocusedLabelIndex >= iAttachmentLabelCount || |
|
358 |
attachmentLabelCountBeforeUpdate < iAttachmentLabelCount ) |
|
359 |
{ |
|
360 |
// Set the focused index to last, we get here either if the last |
|
361 |
// attachment label in list was removed or a new one was added. |
|
362 |
// In either case focused should be the new last attachment label. |
|
363 |
iFocusedLabelIndex = iAttachmentLabelCount-1; |
|
364 |
} |
|
365 |
// In any other case, don't re-set the focused label index |
|
366 |
} |
|
367 |
else // no attachments |
|
368 |
{ |
|
369 |
iAttachmentLabelCount = 0; |
|
370 |
iFocusedLabelIndex = KNoAttachmentLabelFocused; |
|
371 |
} |
|
372 |
||
373 |
UpdateComponentArrayL(); |
|
374 |
LayoutControls(); |
|
375 |
iSizeObserver->UpdateFieldSizeL(); |
|
376 |
} |
|
377 |
||
378 |
// ----------------------------------------------------------------------------- |
|
379 |
// CNcsAttachmentField::FocusedAttachmentLabelIndex() |
|
380 |
// ----------------------------------------------------------------------------- |
|
381 |
// |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
382 |
TInt CNcsAttachmentField::FocusedAttachmentLabelIndex() const |
64 | 383 |
{ |
384 |
FUNC_LOG; |
|
385 |
return iFocusedLabelIndex; |
|
386 |
} |
|
387 |
||
388 |
// ----------------------------------------------------------------------------- |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
389 |
// CNcsAttachmentField::SetFocusedAttachmentLabelIndex() |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
390 |
// ----------------------------------------------------------------------------- |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
391 |
// |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
392 |
void CNcsAttachmentField::SetFocusedAttachmentLabelIndex( TInt aIndex ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
393 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
394 |
FUNC_LOG; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
395 |
iFocusedLabelIndex = aIndex; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
396 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
397 |
|
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
398 |
// ----------------------------------------------------------------------------- |
64 | 399 |
// CNcsAttachmentField::UpdateAttachmentTextsL() |
400 |
// ----------------------------------------------------------------------------- |
|
401 |
// |
|
402 |
void CNcsAttachmentField::UpdateAttachmentTextsL() |
|
403 |
{ |
|
404 |
FUNC_LOG; |
|
405 |
// create new array of labels. |
|
406 |
iAttachmentLabelCount = 0; |
|
407 |
TInt count = iAttachmentNames->MdcaCount(); |
|
408 |
TInt existingLabelCount = iAttachmentLabels.Count(); |
|
409 |
TInt i( 0 ); |
|
410 |
||
411 |
// First, set the new texts using existing attachment labels objects |
|
412 |
for ( ; i<count; ++i ) |
|
413 |
{ |
|
414 |
if ( i==existingLabelCount ) |
|
415 |
{ |
|
416 |
// no more re-usable label objects in their array.. break this |
|
417 |
// loop and continue with the next one (that creates new labels) |
|
418 |
break; |
|
419 |
} |
|
420 |
UpdateSingleAttachmentLabelTextL( iAttachmentLabels[i], i ); |
|
421 |
++iAttachmentLabelCount; |
|
422 |
} |
|
423 |
||
424 |
// Create new attachment labels if needed |
|
425 |
if ( i<count ) |
|
426 |
{ |
|
427 |
// stringloader used to get the initial (dummy) attachment text.. |
|
428 |
HBufC* textBuf = StringLoader::LoadLC( iLabelTextId ); |
|
429 |
||
430 |
for ( ; i<count; ++i ) |
|
431 |
{ |
|
432 |
// create and initialize (fonts & colors) new label |
|
433 |
CNcsLabel* label = new ( ELeave ) CNcsLabel( *this, NULL ); |
|
434 |
CleanupStack::PushL( label ); |
|
435 |
label->SetTextL( *textBuf ); |
|
436 |
UpdateFontSize( label ); |
|
437 |
UpdateColors( label ); |
|
438 |
UpdateSingleAttachmentLabelTextL( label, i ); |
|
439 |
||
440 |
// append then new label to attachment label array |
|
441 |
iAttachmentLabels.AppendL( label ); |
|
442 |
CleanupStack::Pop( label ); |
|
443 |
++iAttachmentLabelCount; |
|
444 |
} |
|
445 |
CleanupStack::PopAndDestroy( textBuf ); |
|
446 |
} |
|
447 |
} |
|
448 |
||
449 |
||
450 |
// ----------------------------------------------------------------------------- |
|
451 |
// CNcsAttachmentField::ResizeIcons() |
|
452 |
// ----------------------------------------------------------------------------- |
|
453 |
// |
|
454 |
void CNcsAttachmentField::ResizeIcons() |
|
455 |
{ |
|
456 |
FUNC_LOG; |
|
457 |
const TSize frontIconSize( NcsUtility::HeaderDetailIconRect( |
|
458 |
Rect(), 1, NcsUtility::EIconFront ).Size() ); |
|
459 |
if ( frontIconSize != iAttachmentBitmap->SizeInPixels() ) |
|
460 |
{ |
|
461 |
AknIconUtils::SetSize( iAttachmentBitmap, frontIconSize, |
|
462 |
EAspectRatioPreservedAndUnusedSpaceRemoved ); |
|
463 |
AknIconUtils::SetSize( iAttachmentMask, frontIconSize, |
|
464 |
EAspectRatioPreservedAndUnusedSpaceRemoved ); |
|
465 |
} |
|
466 |
} |
|
467 |
||
468 |
// ----------------------------------------------------------------------------- |
|
469 |
// CNcsAttachmentField::FocusChanged() |
|
470 |
// ----------------------------------------------------------------------------- |
|
471 |
// |
|
472 |
void CNcsAttachmentField::FocusChanged( TDrawNow aDrawNow ) |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
473 |
{ |
64 | 474 |
FUNC_LOG; |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
475 |
if ( IsFocused() ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
476 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
477 |
for ( TInt i( 0 ); i < iAttachmentLabelCount; ++i ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
478 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
479 |
iAttachmentLabels[i]->SetFocus( i==iFocusedLabelIndex ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
480 |
} |
64 | 481 |
// make sure that control is visible on screen |
482 |
if ( Rect().iTl.iY < 0 ) |
|
483 |
{ |
|
484 |
TPoint pt = TPoint( 0, 0 ); |
|
485 |
Reposition( pt,Rect().Width() ); |
|
486 |
iSizeObserver->UpdateFieldPosition( this ); |
|
487 |
} |
|
488 |
else |
|
489 |
{ |
|
490 |
TPoint pos = PositionRelativeToScreen(); |
|
491 |
pos.iY += Size().iHeight; |
|
492 |
CWsScreenDevice* screenDev = ControlEnv()->ScreenDevice(); |
|
493 |
TPixelsAndRotation pix; |
|
494 |
screenDev->GetDefaultScreenSizeAndRotation( pix ); |
|
495 |
const TInt h = pix.iPixelSize.iHeight; |
|
496 |
if ( pos.iY >= h - h / 3 ) |
|
497 |
{ |
|
498 |
TPoint pt = TPoint( 0, h / 3 ); |
|
499 |
Reposition( pt,Rect().Width() ); |
|
500 |
iSizeObserver->UpdateFieldPosition( this ); |
|
501 |
} |
|
502 |
} |
|
503 |
||
504 |
if ( iParentControl ) |
|
505 |
{ |
|
506 |
TRAP_IGNORE( iParentControl->SetMskL() ); |
|
507 |
} |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
508 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
509 |
else |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
510 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
511 |
for ( TInt i( 0 ); i<iAttachmentLabelCount; ++i ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
512 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
513 |
iAttachmentLabels[i]->SetFocus( EFalse ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
514 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
515 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
516 |
|
64 | 517 |
UpdateColors(); |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
518 |
|
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
519 |
if ( aDrawNow ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
520 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
521 |
DrawNow(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
522 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
523 |
else |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
524 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
525 |
DrawDeferred(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
526 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
527 |
} |
64 | 528 |
|
529 |
// ----------------------------------------------------------------------------- |
|
530 |
// CNcsAttachmentField::UpdateColors() |
|
531 |
// ----------------------------------------------------------------------------- |
|
532 |
// |
|
533 |
void CNcsAttachmentField::UpdateColors() |
|
534 |
{ |
|
535 |
FUNC_LOG; |
|
536 |
for ( TInt i( 0 ); i<iAttachmentLabelCount; ++i ) |
|
537 |
{ |
|
538 |
UpdateColors( iAttachmentLabels[i] ); |
|
539 |
// currently all attachments are underlined |
|
540 |
iAttachmentLabels[i]->SetUnderlining( ETrue ); |
|
541 |
} |
|
542 |
||
543 |
CFreestyleEmailUiAppUi* appUi = |
|
544 |
static_cast<CFreestyleEmailUiAppUi*>( ControlEnv()->AppUi() ); |
|
545 |
iBorderColor = appUi->LayoutHandler()->ComposerFieldBorderColor(); |
|
546 |
iBgColor = appUi->LayoutHandler()->ComposerFieldBackgroundColor(); |
|
547 |
} |
|
548 |
||
549 |
// ----------------------------------------------------------------------------- |
|
550 |
// CNcsAttachmentField::UpdateColors() |
|
551 |
// ----------------------------------------------------------------------------- |
|
552 |
// |
|
553 |
void CNcsAttachmentField::UpdateColors( CNcsLabel* aLabel ) |
|
554 |
{ |
|
555 |
FUNC_LOG; |
|
556 |
if ( aLabel ) |
|
557 |
{ |
|
558 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
559 |
TRgb labelTextColor = KRgbBlack; |
|
560 |
TRgb labelEmphasisColor = KRgbBlack; |
|
561 |
TRgb labelHighlightFullEmphasisColor = KRgbBlack; |
|
562 |
||
563 |
AknsUtils::GetCachedColor( |
|
564 |
skin, |
|
565 |
labelTextColor, |
|
566 |
KAknsIIDQsnTextColors, |
|
567 |
aLabel->IsFocused() ? |
|
568 |
EAknsCIQsnTextColorsCG24 : EAknsCIQsnTextColorsCG6 ); |
|
569 |
AknsUtils::GetCachedColor( |
|
570 |
skin, |
|
571 |
labelEmphasisColor, |
|
572 |
KAknsIIDQsnHighlightColors, |
|
573 |
EAknsCIQsnHighlightColorsCG3 ); |
|
574 |
AknsUtils::GetCachedColor( |
|
575 |
skin, |
|
576 |
labelHighlightFullEmphasisColor, |
|
577 |
KAknsIIDQsnHighlightColors, |
|
578 |
EAknsCIQsnHighlightColorsCG2 ); |
|
579 |
||
580 |
TRAP_IGNORE( aLabel->OverrideColorL( |
|
581 |
EColorLabelText, labelTextColor ) ); |
|
582 |
TRAP_IGNORE( aLabel->OverrideColorL( |
|
583 |
EColorLabelTextEmphasis, labelEmphasisColor ) ); |
|
584 |
TRAP_IGNORE( aLabel->OverrideColorL( |
|
585 |
EColorLabelHighlightFullEmphasis, |
|
586 |
labelHighlightFullEmphasisColor ) ); |
|
587 |
} |
|
588 |
} |
|
589 |
||
590 |
// ----------------------------------------------------------------------------- |
|
591 |
// CNcsAttachmentField::UpdateFontSize() |
|
592 |
// ----------------------------------------------------------------------------- |
|
593 |
// |
|
594 |
void CNcsAttachmentField::UpdateFontSize() |
|
595 |
{ |
|
596 |
FUNC_LOG; |
|
597 |
if ( iAttachmentLabelCount ) |
|
598 |
{ |
|
599 |
// same font used for all labels, so just get the first one's |
|
600 |
iEditorFont = NcsUtility::GetLayoutFont( |
|
601 |
iAttachmentLabels[0]->Rect(), NcsUtility::ENcsHeaderDetailFont ); |
|
602 |
} |
|
603 |
for ( TInt i( 0 ); i<iAttachmentLabelCount; ++i ) |
|
604 |
{ |
|
605 |
iAttachmentLabels[i]->SetFont( iEditorFont ); |
|
606 |
} |
|
607 |
} |
|
608 |
||
609 |
// ----------------------------------------------------------------------------- |
|
610 |
// CNcsAttachmentField::UpdateFontSize() |
|
611 |
// ----------------------------------------------------------------------------- |
|
612 |
// |
|
613 |
void CNcsAttachmentField::UpdateFontSize( CNcsLabel* aLabel ) |
|
614 |
{ |
|
615 |
FUNC_LOG; |
|
616 |
iEditorFont = NcsUtility::GetLayoutFont( |
|
617 |
aLabel->Rect(), NcsUtility::ENcsHeaderDetailFont ); |
|
618 |
aLabel->SetFont( iEditorFont ); |
|
619 |
} |
|
620 |
||
621 |
// ----------------------------------------------------------------------------- |
|
622 |
// CNcsAttachmentField::LayoutControls() |
|
623 |
// ----------------------------------------------------------------------------- |
|
624 |
// |
|
625 |
void CNcsAttachmentField::LayoutControls() |
|
626 |
{ |
|
627 |
FUNC_LOG; |
|
628 |
const TRect rect( Rect() ); |
|
629 |
for ( TInt i( 0 ); i<iAttachmentLabelCount; ++i ) |
|
630 |
{ |
|
631 |
NcsUtility::LayoutDetailLabel( iAttachmentLabels[i], rect, i ); |
|
632 |
if ( i == 0 ) |
|
633 |
{ |
|
634 |
// icons need to be updated for first round only |
|
635 |
UpdateIconPositions( rect ); |
|
636 |
} |
|
637 |
} |
|
638 |
} |
|
639 |
||
640 |
// ----------------------------------------------------------------------------- |
|
641 |
// CNcsAttachmentField::UpdateIconPositions() |
|
642 |
// ----------------------------------------------------------------------------- |
|
643 |
// |
|
644 |
void CNcsAttachmentField::UpdateIconPositions( const TRect& aRect ) |
|
645 |
{ |
|
646 |
FUNC_LOG; |
|
647 |
iAttachmentIconPos = NcsUtility::HeaderDetailIconRect( |
|
648 |
aRect, 1, NcsUtility::EIconFront ).iTl; |
|
649 |
} |
|
650 |
||
651 |
// ----------------------------------------------------------------------------- |
|
652 |
// CNcsAttachmentField::HandleResourceChange() |
|
653 |
// ----------------------------------------------------------------------------- |
|
654 |
// |
|
655 |
void CNcsAttachmentField::HandleResourceChange( TInt aType ) |
|
656 |
{ |
|
657 |
FUNC_LOG; |
|
658 |
CCoeControl::HandleResourceChange( aType ); |
|
659 |
if ( aType == KAknsMessageSkinChange || |
|
660 |
aType == KEikMessageColorSchemeChange ) |
|
661 |
{ |
|
662 |
UpdateFontSize(); |
|
663 |
UpdateColors(); |
|
664 |
CreateIcons(); |
|
665 |
DrawDeferred(); |
|
666 |
} |
|
667 |
} |
|
668 |
||
669 |
// ----------------------------------------------------------------------------- |
|
670 |
// CNcsAttachmentField::HandlePointerEventL() |
|
671 |
// ----------------------------------------------------------------------------- |
|
672 |
// |
|
673 |
void CNcsAttachmentField::HandlePointerEventL( |
|
674 |
const TPointerEvent& aPointerEvent ) |
|
675 |
{ |
|
676 |
FUNC_LOG; |
|
677 |
CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
678 |
|
64 | 679 |
if ( aPointerEvent.iType == TPointerEvent::EButton1Down && |
680 |
Rect().Contains( aPointerEvent.iPosition ) ) |
|
681 |
{ |
|
682 |
TBool focusedAttachmentLabelIndexChanged( EFalse ); |
|
683 |
TInt i( 0 ); |
|
684 |
for ( ; i<iAttachmentLabelCount; ++i ) |
|
685 |
{ |
|
686 |
if ( iAttachmentLabels[i]->TextHitAreaRect().Contains( |
|
687 |
aPointerEvent.iPosition ) ) |
|
688 |
{ |
|
689 |
// tactile feedback |
|
690 |
MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
691 |
if ( feedback ) |
|
692 |
{ |
|
693 |
feedback->InstantFeedback( this, ETouchFeedbackBasic ); |
|
694 |
} |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
695 |
|
64 | 696 |
if ( iFocusedLabelIndex != i ) |
697 |
{ |
|
698 |
focusedAttachmentLabelIndexChanged = ETrue; |
|
699 |
iFocusedLabelIndex = i; |
|
700 |
} |
|
701 |
break; |
|
702 |
} |
|
703 |
} |
|
704 |
||
705 |
if ( i == iAttachmentLabelCount ) |
|
706 |
{ |
|
707 |
// Pointer event happened outside any of the labels. |
|
708 |
// Invalidate focused label index.. this will cause the next |
|
709 |
// for loop to set all label focuses to EFalse. |
|
710 |
iFocusedLabelIndex = KNoAttachmentLabelFocused; |
|
711 |
focusedAttachmentLabelIndexChanged = ETrue; |
|
712 |
} |
|
713 |
||
714 |
if ( focusedAttachmentLabelIndexChanged ) |
|
715 |
{ |
|
716 |
// only redraw if focused attachment label changed |
|
717 |
for ( TInt i( 0 ); i<iAttachmentLabelCount; ++i ) |
|
718 |
{ |
|
719 |
iAttachmentLabels[i]->SetFocus( i==iFocusedLabelIndex ); |
|
720 |
} |
|
721 |
UpdateColors(); |
|
722 |
DrawDeferred(); |
|
723 |
} |
|
724 |
} |
|
725 |
} |
|
726 |
||
727 |
// ----------------------------------------------------------------------------- |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
728 |
// CNcsAttachmentField::OfferKeyEventL() |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
729 |
// ----------------------------------------------------------------------------- |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
730 |
// |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
731 |
TKeyResponse CNcsAttachmentField::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
732 |
TEventCode aType ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
733 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
734 |
TKeyResponse response = EKeyWasNotConsumed; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
735 |
TBool focusedAttachmentLabelIndexChanged = EFalse; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
736 |
|
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
737 |
if ( aType == EEventKey ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
738 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
739 |
if ( aKeyEvent.iCode == EKeyUpArrow ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
740 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
741 |
if ( iFocusedLabelIndex > 0 ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
742 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
743 |
iFocusedLabelIndex -= 1; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
744 |
focusedAttachmentLabelIndexChanged = ETrue; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
745 |
response = EKeyWasConsumed; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
746 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
747 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
748 |
else if ( aKeyEvent.iCode == EKeyDownArrow ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
749 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
750 |
if ( iFocusedLabelIndex < iAttachmentLabelCount - 1 ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
751 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
752 |
iFocusedLabelIndex += 1; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
753 |
focusedAttachmentLabelIndexChanged = ETrue; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
754 |
response = EKeyWasConsumed; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
755 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
756 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
757 |
else if ( aKeyEvent.iCode == EKeyBackspace || |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
758 |
aKeyEvent.iCode == EKeyDelete ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
759 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
760 |
iObserver->AttachmentRemoveL(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
761 |
response = EKeyWasConsumed; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
762 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
763 |
else if ( aKeyEvent.iCode == EKeyEnter || |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
764 |
aKeyEvent.iScanCode == EStdKeyEnter || |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
765 |
aKeyEvent.iCode == EKeyOK || |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
766 |
aKeyEvent.iScanCode == EStdKeyDevice3 ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
767 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
768 |
iObserver->AttachmentOpenL(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
769 |
response = EKeyWasConsumed; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
770 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
771 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
772 |
|
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
773 |
if ( focusedAttachmentLabelIndexChanged ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
774 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
775 |
// only redraw if focused attachment label changed |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
776 |
for ( TInt i = 0; i < iAttachmentLabelCount; i++ ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
777 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
778 |
iAttachmentLabels[i]->SetFocus( i == iFocusedLabelIndex ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
779 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
780 |
|
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
781 |
UpdateColors(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
782 |
DrawDeferred(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
783 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
784 |
|
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
785 |
return response; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
786 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
787 |
|
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
788 |
// ----------------------------------------------------------------------------- |
64 | 789 |
// CNcsAttachmentField::CreateIcons() |
790 |
// ----------------------------------------------------------------------------- |
|
791 |
// |
|
792 |
TInt CNcsAttachmentField::CreateIcons() |
|
793 |
{ |
|
794 |
FUNC_LOG; |
|
795 |
TRAPD( error, CreateIconsL() ); |
|
796 |
return error; |
|
797 |
} |
|
798 |
||
799 |
// ----------------------------------------------------------------------------- |
|
800 |
// CNcsAttachmentField::CreateIconsL() |
|
801 |
// ----------------------------------------------------------------------------- |
|
802 |
// |
|
803 |
void CNcsAttachmentField::CreateIconsL() |
|
804 |
{ |
|
805 |
FUNC_LOG; |
|
806 |
CFreestyleEmailUiAppUi* fsAppUi = |
|
807 |
static_cast<CFreestyleEmailUiAppUi*>( ControlEnv()->AppUi() ); |
|
808 |
delete iAttachmentBitmap; |
|
809 |
iAttachmentBitmap = NULL; |
|
810 |
delete iAttachmentMask; |
|
811 |
iAttachmentMask = NULL; |
|
812 |
fsAppUi->FsTextureManager()->ProvideBitmapL( |
|
813 |
EAttachmentIcon, iAttachmentBitmap, iAttachmentMask ); |
|
814 |
ResizeIcons(); |
|
815 |
} |
|
816 |
||
817 |
// ----------------------------------------------------------------------------- |
|
818 |
// CNcsAttachmentField::UpdateSingleAttachmentLabelTextL() |
|
819 |
// ----------------------------------------------------------------------------- |
|
820 |
// |
|
821 |
void CNcsAttachmentField::UpdateSingleAttachmentLabelTextL( |
|
822 |
CNcsLabel* aLabel, TInt aIndex ) |
|
823 |
{ |
|
824 |
FUNC_LOG; |
|
825 |
// create decorated size text including the preceeding space character |
|
826 |
HBufC* decoratedSize = StringLoader::LoadLC( |
|
827 |
R_FSE_VIEWER_ATTACHMENTS_LIST_SIZE, |
|
828 |
iAttachmentSizes->MdcaPoint( aIndex ) ); |
|
829 |
HBufC* decoratedSizeWithSpace = HBufC::NewL( |
|
830 |
decoratedSize->Length() + |
|
831 |
KSpace().Length() + |
|
832 |
KBidiRleStartChar().Length() + |
|
833 |
KBidiPdfChar().Length() ); |
|
834 |
decoratedSizeWithSpace->Des().Append( KSpace ); |
|
835 |
if ( AknLayoutUtils::LayoutMirrored() ) |
|
836 |
{ |
|
837 |
// Put size part into embedded right-to-left block to ensure |
|
838 |
// correct rendering even when name part is written from |
|
839 |
// left-to-right. |
|
840 |
decoratedSizeWithSpace->Des().Append( KBidiRleStartChar ); |
|
841 |
decoratedSizeWithSpace->Des().Append( *decoratedSize ); |
|
842 |
decoratedSizeWithSpace->Des().Append( KBidiPdfChar ); |
|
843 |
} |
|
844 |
else |
|
845 |
{ |
|
846 |
decoratedSizeWithSpace->Des().Append( *decoratedSize ); |
|
847 |
} |
|
848 |
CleanupStack::PopAndDestroy( decoratedSize ); |
|
849 |
CleanupStack::PushL( decoratedSizeWithSpace ); |
|
850 |
||
851 |
// clip attachment name to fit the field so that size information has |
|
852 |
// enough space too. |
|
853 |
const CFont& font = *aLabel->Font(); |
|
854 |
||
855 |
TInt labelWidth = aLabel->Size().iWidth; |
|
856 |
TInt sizeTextInPixels = |
|
857 |
font.TextWidthInPixels( *decoratedSizeWithSpace ); |
|
858 |
TInt pixelsLeftForAttachmentName = labelWidth - sizeTextInPixels; |
|
859 |
||
860 |
HBufC* attachmentText = NULL; // will contain the complete text |
|
861 |
// safe check if the size information is too wide for some reason. |
|
862 |
if ( pixelsLeftForAttachmentName < 0 ) |
|
863 |
{ |
|
864 |
attachmentText = HBufC::NewLC( |
|
865 |
iAttachmentNames->MdcaPoint( aIndex ).Length() |
|
866 |
+ decoratedSizeWithSpace->Length() ); |
|
867 |
attachmentText->Des().Append( iAttachmentNames->MdcaPoint( aIndex ) ); |
|
868 |
attachmentText->Des().Append( *decoratedSizeWithSpace ); |
|
869 |
TPtr attachmentTextBufferModDes = attachmentText->Des(); |
|
870 |
AknTextUtils::ClipToFit( attachmentTextBufferModDes, |
|
871 |
font, labelWidth ); |
|
872 |
} |
|
873 |
else |
|
874 |
{ // normal case |
|
875 |
HBufC* attacmentNameBuffer = |
|
876 |
iAttachmentNames->MdcaPoint( aIndex ).AllocLC(); |
|
877 |
TPtr attachmentNameBufferModDes = attacmentNameBuffer->Des(); |
|
878 |
AknTextUtils::ClipToFit( attachmentNameBufferModDes, |
|
879 |
font, pixelsLeftForAttachmentName ); |
|
880 |
||
881 |
attachmentText = HBufC::NewL( |
|
882 |
attacmentNameBuffer->Length() |
|
883 |
+ decoratedSizeWithSpace->Length() ); |
|
884 |
attachmentText->Des().Append( *attacmentNameBuffer ); |
|
885 |
attachmentText->Des().Append( *decoratedSizeWithSpace ); |
|
886 |
CleanupStack::PopAndDestroy( attacmentNameBuffer ); |
|
887 |
CleanupStack::PushL( attachmentText ); |
|
888 |
} |
|
889 |
aLabel->SetTextL( *attachmentText ); |
|
890 |
CleanupStack::PopAndDestroy( attachmentText ); |
|
891 |
CleanupStack::PopAndDestroy( decoratedSizeWithSpace ); |
|
892 |
} |
|
893 |