79
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 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: MsgAttachmentControl implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// ========== INCLUDE FILES ================================
|
|
21 |
|
|
22 |
#include <barsread.h> // for TResourceReader
|
|
23 |
#include <txtrich.h> // for CRichText
|
|
24 |
|
|
25 |
#include <eikenv.h> // for CEikonEnv
|
|
26 |
#include <eikappui.h> // for CEikAppUi
|
|
27 |
#include <eikedwin.h> // for TClipboardFunc
|
|
28 |
#include <eiklabel.h>
|
|
29 |
|
|
30 |
#include <AknUtils.h> // for AknUtils
|
|
31 |
#include <aknbutton.h> // for CAknButton
|
|
32 |
|
|
33 |
#include <MsgAttachmentModel.h>
|
|
34 |
#include <MsgAttachmentInfo.h>
|
|
35 |
|
|
36 |
#include <gulicon.h>
|
|
37 |
#include <AknsUtils.h>
|
|
38 |
#include <AknsConstants.h>
|
|
39 |
#include <aknlayoutscalable_apps.cdl.h>
|
|
40 |
|
|
41 |
#include <data_caging_path_literals.hrh>
|
|
42 |
#include <msgeditor.mbg>
|
|
43 |
#include <aknlayoutscalable_avkon.cdl.h>
|
|
44 |
|
|
45 |
#ifdef RD_TACTILE_FEEDBACK
|
|
46 |
#include <touchfeedback.h>
|
|
47 |
#endif
|
|
48 |
|
|
49 |
#include "MsgAttachmentControl.h" // for CMsgAttachmentControl
|
|
50 |
#include "MsgExpandableControlEditor.h" // for CMsgExpandableControlEditor
|
|
51 |
#include "MsgBaseControlObserver.h" // for MMsgBaseControlObserver
|
|
52 |
#include "MsgEditorView.h"
|
|
53 |
#include "MsgEditorPanic.h" // for CMsgEditor panics
|
|
54 |
#include "MsgEditorCommon.h" // for KArabicSemicolon
|
|
55 |
#include "MsgEditorCustomDraw.h" // for CMsgEditorCustomDraw
|
|
56 |
|
|
57 |
// ========== EXTERNAL DATA STRUCTURES =====================
|
|
58 |
|
|
59 |
// ========== EXTERNAL FUNCTION PROTOTYPES =================
|
|
60 |
|
|
61 |
// ========== CONSTANTS ====================================
|
|
62 |
|
|
63 |
// Default color for EAknsCIQsnIconColorsCG13 group icons
|
|
64 |
const TInt KDefaultAttachmentColor = 215;
|
|
65 |
|
|
66 |
// ========== MACROS =======================================
|
|
67 |
|
|
68 |
// ========== LOCAL CONSTANTS AND MACROS ===================
|
|
69 |
|
|
70 |
const TInt KAttachmentArrayGranularity = 10;
|
|
71 |
|
|
72 |
_LIT( KAttachmentListSeparator, ", " );
|
|
73 |
_LIT( KIconMbmFile, "msgeditor.mbm" );
|
|
74 |
_LIT( KStripList, "\x000A\x000D\x2029\x2028\x0085" );
|
|
75 |
|
|
76 |
const TText KZeroWidthJoiner = 0x200D;
|
|
77 |
const TText KLRMarker = 0x200E;
|
|
78 |
const TText KRLMarker = 0x200F;
|
|
79 |
|
|
80 |
const TInt KScrollStartDelay = 1500000; // 1,5 s
|
|
81 |
const TInt KScrollEndDelay = 500000; // 0,5 s
|
|
82 |
const TInt KScrollRestartDelay = 3000000; // 3 s.
|
|
83 |
const TInt KScrollTickDelay = 135000; // 0,135s
|
|
84 |
const TInt KScrollJumpAreaDivider = 15;
|
|
85 |
|
|
86 |
// ========== MODULE DATA STRUCTURES =======================
|
|
87 |
|
|
88 |
// ========== LOCAL FUNCTION PROTOTYPES ====================
|
|
89 |
|
|
90 |
// ========== LOCAL FUNCTIONS ==============================
|
|
91 |
|
|
92 |
// ========== MEMBER FUNCTIONS =============================
|
|
93 |
|
|
94 |
|
|
95 |
// ---------------------------------------------------------
|
|
96 |
// CMsgAttachmentControl::CMsgAttachmentControl
|
|
97 |
//
|
|
98 |
// Constructor.
|
|
99 |
// ---------------------------------------------------------
|
|
100 |
//
|
|
101 |
CMsgAttachmentControl::CMsgAttachmentControl(
|
|
102 |
MMsgBaseControlObserver& aBaseControlObserver,
|
|
103 |
CMsgEditorView& aView ) :
|
|
104 |
CMsgExpandableControl( aBaseControlObserver ),
|
|
105 |
iScrollPos( EScrollPosBeginning )
|
|
106 |
{
|
|
107 |
iControlType = EMsgAttachmentControl;
|
|
108 |
iControlId = EMsgComponentIdAttachment;
|
|
109 |
|
|
110 |
SetMopParent( &aView );
|
|
111 |
}
|
|
112 |
|
|
113 |
// ---------------------------------------------------------
|
|
114 |
// CMsgAttachmentControl::ConstructL
|
|
115 |
//
|
|
116 |
// 2nd phase constructor. After base class initialization creates
|
|
117 |
// attachment array that holds the attachment name strings. Empty
|
|
118 |
// caption control is also created for base class purposes. NOTE! This is
|
|
119 |
// something that would be good to get rid off. Initializes editor control
|
|
120 |
// and sets itself as it's edwin event, edwin size event and
|
|
121 |
// control event observer. Creates editor is set as readonly and cursor is
|
|
122 |
// hidden. Focus must stop to this control when navigating. No formatting
|
|
123 |
// is allowed. Label icon and if pen input (i.e. touch screen) is enabled
|
|
124 |
// then also button are created. Initializes marquee scroll timer and
|
|
125 |
// layout related parameters.
|
|
126 |
// ---------------------------------------------------------
|
|
127 |
//
|
|
128 |
void CMsgAttachmentControl::ConstructL()
|
|
129 |
{
|
|
130 |
BaseConstructL(); // Sets margins only.
|
|
131 |
|
|
132 |
iAttachmentArray = new( ELeave ) CDesCArrayFlat( KAttachmentArrayGranularity );
|
|
133 |
|
|
134 |
// Create empty caption. (Needed by base class.)
|
|
135 |
iCaption = new( ELeave ) CEikLabel;
|
|
136 |
|
|
137 |
// Create editor.
|
|
138 |
iEditor = new( ELeave ) CMsgExpandableControlEditor( this,
|
|
139 |
iControlModeFlags,
|
|
140 |
iBaseControlObserver );
|
|
141 |
iEditor->SetControlType(iControlType);
|
|
142 |
iEditor->ConstructL();
|
|
143 |
iEditor->SetObserver( this );
|
|
144 |
iEditor->SetEdwinSizeObserver( this );
|
|
145 |
iEditor->AddEdwinObserverL( this );
|
|
146 |
iEditor->SetReadOnly( ETrue );
|
|
147 |
iEditor->AddFlagToUserFlags( CEikEdwin::EAvkonDisableCursor );
|
|
148 |
|
|
149 |
// To Dis-able Smiley support for attachment field.
|
|
150 |
iEditor->RemoveFlagFromUserFlags(CEikEdwin::EAvkonEnableSmileySupport);
|
|
151 |
|
|
152 |
iControlModeFlags |= EMsgControlModeForceFocusStop;
|
|
153 |
|
|
154 |
SetPlainTextMode( ETrue );
|
|
155 |
|
|
156 |
iLabelIcon = CreateAttachmentIconsL();
|
|
157 |
|
|
158 |
#ifdef RD_SCALABLE_UI_V2
|
|
159 |
if ( AknLayoutUtils::PenEnabled() )
|
|
160 |
{
|
|
161 |
CreateButtonL();
|
|
162 |
}
|
|
163 |
#endif // RD_SCALABLE_UI_V2
|
|
164 |
|
|
165 |
iScrollTimer = CPeriodic::NewL( EPriorityNormal );
|
|
166 |
|
|
167 |
ResolveLayoutsL();
|
|
168 |
}
|
|
169 |
|
|
170 |
// ----------------------------------------------------------------------------
|
|
171 |
// CMsgAttachmentControl::NewL
|
|
172 |
// Symbian two phased constructor
|
|
173 |
// ----------------------------------------------------------------------------
|
|
174 |
//
|
|
175 |
EXPORT_C CMsgAttachmentControl* CMsgAttachmentControl::NewL(
|
|
176 |
MMsgBaseControlObserver& aBaseControlObserver,
|
|
177 |
CMsgEditorView& aView )
|
|
178 |
{
|
|
179 |
CMsgAttachmentControl* self = new( ELeave ) CMsgAttachmentControl( aBaseControlObserver,
|
|
180 |
aView );
|
|
181 |
|
|
182 |
CleanupStack::PushL( self );
|
|
183 |
self->ConstructL();
|
|
184 |
CleanupStack::Pop( self );
|
|
185 |
|
|
186 |
return self;
|
|
187 |
}
|
|
188 |
|
|
189 |
// ---------------------------------------------------------
|
|
190 |
// CMsgAttachmentControl::~CMsgAttachmentControl
|
|
191 |
//
|
|
192 |
// Destructor.
|
|
193 |
// ---------------------------------------------------------
|
|
194 |
//
|
|
195 |
CMsgAttachmentControl::~CMsgAttachmentControl()
|
|
196 |
{
|
|
197 |
if ( iAttachmentArray )
|
|
198 |
{
|
|
199 |
iAttachmentArray->Reset();
|
|
200 |
}
|
|
201 |
|
|
202 |
delete iAttachmentArray;
|
|
203 |
delete iLabelIcon;
|
|
204 |
delete iScrollTimer;
|
|
205 |
}
|
|
206 |
|
|
207 |
// ---------------------------------------------------------
|
|
208 |
// CMsgAttachmentControl::AppendAttachmentL
|
|
209 |
//
|
|
210 |
//
|
|
211 |
// ---------------------------------------------------------
|
|
212 |
//
|
|
213 |
EXPORT_C void CMsgAttachmentControl::AppendAttachmentL( const TDesC& aName )
|
|
214 |
{
|
|
215 |
InsertAttachmentL( aName, Count() );
|
|
216 |
}
|
|
217 |
|
|
218 |
// ---------------------------------------------------------
|
|
219 |
// CMsgAttachmentControl::InsertAttachmentL
|
|
220 |
//
|
|
221 |
//
|
|
222 |
// ---------------------------------------------------------
|
|
223 |
//
|
|
224 |
EXPORT_C void CMsgAttachmentControl::InsertAttachmentL( const TDesC& aName, TInt aIndex )
|
|
225 |
{
|
|
226 |
AddToAttachmentArrayL( aName, aIndex );
|
|
227 |
|
|
228 |
UpdateControlL();
|
|
229 |
}
|
|
230 |
|
|
231 |
// ---------------------------------------------------------
|
|
232 |
// CMsgAttachmentControl::AddAttachmentL
|
|
233 |
//
|
|
234 |
//
|
|
235 |
// ---------------------------------------------------------
|
|
236 |
//
|
|
237 |
EXPORT_C void CMsgAttachmentControl::AddAttachmentsL( const MDesCArray& aNames )
|
|
238 |
{
|
|
239 |
Reset();
|
|
240 |
|
|
241 |
for ( TInt i = 0; i < aNames.MdcaCount(); i++ )
|
|
242 |
{
|
|
243 |
AddToAttachmentArrayL( aNames.MdcaPoint( i ), Count() );
|
|
244 |
}
|
|
245 |
|
|
246 |
UpdateControlL();
|
|
247 |
}
|
|
248 |
|
|
249 |
|
|
250 |
// ---------------------------------------------------------
|
|
251 |
// CMsgAttachmentControl::AddAttachmentL
|
|
252 |
//
|
|
253 |
//
|
|
254 |
// ---------------------------------------------------------
|
|
255 |
//
|
|
256 |
EXPORT_C void CMsgAttachmentControl::AddAttachmentsL( const CMsgAttachmentModel& aModel )
|
|
257 |
{
|
|
258 |
Reset();
|
|
259 |
|
|
260 |
TParse* parser = new( ELeave ) TParse ;
|
|
261 |
CleanupStack::PushL( parser );
|
|
262 |
|
|
263 |
for ( TInt i = 0; i < aModel.NumberOfItems(); i++ )
|
|
264 |
{
|
|
265 |
parser->Set( aModel.AttachmentInfoAt( i ).FileName(),NULL, NULL );
|
|
266 |
AddToAttachmentArrayL( parser->NameAndExt(), Count() );
|
|
267 |
}
|
|
268 |
|
|
269 |
CleanupStack::PopAndDestroy( parser );
|
|
270 |
UpdateControlL();
|
|
271 |
}
|
|
272 |
|
|
273 |
// ---------------------------------------------------------
|
|
274 |
// CMsgAttachmentControl::RemoveAttachmentL
|
|
275 |
// ---------------------------------------------------------
|
|
276 |
//
|
|
277 |
EXPORT_C void CMsgAttachmentControl::RemoveAttachmentL( const TDesC& aName )
|
|
278 |
{
|
|
279 |
HBufC* convertedFileName = AknTextUtils::ConvertFileNameL( aName );
|
|
280 |
CleanupStack::PushL( convertedFileName );
|
|
281 |
|
|
282 |
TPtr convertedFileNamePtr = convertedFileName->Des();
|
|
283 |
|
|
284 |
AknTextUtils::StripCharacters( convertedFileNamePtr, KAknStripListControlChars );
|
|
285 |
|
|
286 |
TInt pos( KErrNotFound );
|
|
287 |
if ( iAttachmentArray->Find( *convertedFileName, pos ) == 0 )
|
|
288 |
{
|
|
289 |
RemoveAttachmentL( pos );
|
|
290 |
}
|
|
291 |
|
|
292 |
CleanupStack::PopAndDestroy( convertedFileName );
|
|
293 |
}
|
|
294 |
|
|
295 |
// ---------------------------------------------------------
|
|
296 |
// CMsgAttachmentControl::RemoveAttachmentL
|
|
297 |
// ---------------------------------------------------------
|
|
298 |
//
|
|
299 |
EXPORT_C void CMsgAttachmentControl::RemoveAttachmentL( TInt aIndex )
|
|
300 |
{
|
|
301 |
iAttachmentArray->Delete( aIndex );
|
|
302 |
UpdateControlL();
|
|
303 |
}
|
|
304 |
|
|
305 |
// ---------------------------------------------------------
|
|
306 |
// CMsgAttachmentControl::Reset
|
|
307 |
//
|
|
308 |
// from CMsgBaseControl.
|
|
309 |
// Same as above but non-leaving version.
|
|
310 |
// ---------------------------------------------------------
|
|
311 |
//
|
|
312 |
EXPORT_C void CMsgAttachmentControl::Reset()
|
|
313 |
{
|
|
314 |
if ( iAttachmentArray )
|
|
315 |
{
|
|
316 |
iAttachmentArray->Reset();
|
|
317 |
}
|
|
318 |
if ( iEditor )
|
|
319 |
{
|
|
320 |
iEditor->Reset();
|
|
321 |
}
|
|
322 |
}
|
|
323 |
|
|
324 |
|
|
325 |
// ---------------------------------------------------------
|
|
326 |
// CMsgAttachmentControl::Count
|
|
327 |
// ---------------------------------------------------------
|
|
328 |
//
|
|
329 |
EXPORT_C TInt CMsgAttachmentControl::Count() const
|
|
330 |
{
|
|
331 |
return iAttachmentArray->MdcaCount();
|
|
332 |
}
|
|
333 |
|
|
334 |
// ---------------------------------------------------------
|
|
335 |
// CMsgAttachmentControl::Attachment
|
|
336 |
// ---------------------------------------------------------
|
|
337 |
//
|
|
338 |
EXPORT_C TPtrC CMsgAttachmentControl::Attachment( TInt aIndex ) const
|
|
339 |
{
|
|
340 |
return iAttachmentArray->MdcaPoint( aIndex );
|
|
341 |
}
|
|
342 |
|
|
343 |
// ---------------------------------------------------------
|
|
344 |
// CMsgAttachmentControl::ConstructFromResourceL
|
|
345 |
//
|
|
346 |
// Creates this control from resource.
|
|
347 |
// ---------------------------------------------------------
|
|
348 |
//
|
|
349 |
void CMsgAttachmentControl::ConstructFromResourceL( TInt aResourceId )
|
|
350 |
{
|
|
351 |
TResourceReader reader;
|
|
352 |
iCoeEnv->CreateResourceReaderLC( reader, aResourceId );
|
|
353 |
|
|
354 |
// Read some information about control from resource.
|
|
355 |
ReadControlPropertiesFromResourceL( reader );
|
|
356 |
|
|
357 |
ConstructL();
|
|
358 |
|
|
359 |
CleanupStack::PopAndDestroy(); // reader
|
|
360 |
}
|
|
361 |
|
|
362 |
// ---------------------------------------------------------
|
|
363 |
// CMsgAttachmentControl::EditPermission
|
|
364 |
//
|
|
365 |
// Checks and returns control's edit permissions. Edit permissions are needed
|
|
366 |
// to check in order to know whether some key press is allowed to pass
|
|
367 |
// to the control or not.
|
|
368 |
// ---------------------------------------------------------
|
|
369 |
//
|
|
370 |
TUint32 CMsgAttachmentControl::EditPermission() const
|
|
371 |
{
|
|
372 |
return CMsgBaseControl::EMsgEditNone;
|
|
373 |
}
|
|
374 |
|
|
375 |
// ---------------------------------------------------------
|
|
376 |
// CMsgAttachmentControl::NotifyViewEvent
|
|
377 |
//
|
|
378 |
// Builds up text fields for the control i.e. reads verified recipients and
|
|
379 |
// creates corresponding text fields for them.
|
|
380 |
// ---------------------------------------------------------
|
|
381 |
//
|
|
382 |
void CMsgAttachmentControl::NotifyViewEvent( TMsgViewEvent aEvent, TInt aParam )
|
|
383 |
{
|
|
384 |
if ( IsReadOnly() )
|
|
385 |
{
|
|
386 |
aParam |= EMsgViewEventAutoHighlight;
|
|
387 |
}
|
|
388 |
|
|
389 |
if ( aEvent != EMsgViewEventSetCursorFirstPos &&
|
|
390 |
aEvent != EMsgViewEventSetCursorLastPos )
|
|
391 |
{
|
|
392 |
CMsgExpandableControl::NotifyViewEvent( aEvent, aParam );
|
|
393 |
}
|
|
394 |
}
|
|
395 |
|
|
396 |
|
|
397 |
// ---------------------------------------------------------
|
|
398 |
// CMsgAttachmentControl::PrepareForReadOnly
|
|
399 |
// ---------------------------------------------------------
|
|
400 |
//
|
|
401 |
void CMsgAttachmentControl::PrepareForReadOnly( TBool aReadOnly )
|
|
402 |
{
|
|
403 |
if ( aReadOnly )
|
|
404 |
{
|
|
405 |
TRAP_IGNORE( iEditor->SetHighlightStyleL( EEikEdwinHighlightLink ) );
|
|
406 |
}
|
|
407 |
}
|
|
408 |
|
|
409 |
// ---------------------------------------------------------
|
|
410 |
// CMsgAttachmentControl::CountComponentControls
|
|
411 |
//
|
|
412 |
// Returns a number of controls.
|
|
413 |
// ---------------------------------------------------------
|
|
414 |
//
|
|
415 |
TInt CMsgAttachmentControl::CountComponentControls() const
|
|
416 |
{
|
|
417 |
TInt result( 1 );
|
|
418 |
|
|
419 |
if ( iButton )
|
|
420 |
{
|
|
421 |
result++;
|
|
422 |
}
|
|
423 |
|
|
424 |
return result;
|
|
425 |
}
|
|
426 |
|
|
427 |
// ---------------------------------------------------------
|
|
428 |
// CMsgAttachmentControl::ComponentControl
|
|
429 |
//
|
|
430 |
// Returns a control of index aIndex.
|
|
431 |
// ---------------------------------------------------------
|
|
432 |
//
|
|
433 |
CCoeControl* CMsgAttachmentControl::ComponentControl( TInt aIndex ) const
|
|
434 |
{
|
|
435 |
CCoeControl* result = NULL;
|
|
436 |
switch ( aIndex )
|
|
437 |
{
|
|
438 |
case 0:
|
|
439 |
{
|
|
440 |
result = iEditor;
|
|
441 |
break;
|
|
442 |
}
|
|
443 |
case 1:
|
|
444 |
{
|
|
445 |
result = iButton;
|
|
446 |
break;
|
|
447 |
}
|
|
448 |
default:
|
|
449 |
{
|
|
450 |
break;
|
|
451 |
}
|
|
452 |
}
|
|
453 |
|
|
454 |
return result;
|
|
455 |
}
|
|
456 |
|
|
457 |
// ---------------------------------------------------------
|
|
458 |
// CMsgAttachmentControl::OfferKeyEventL
|
|
459 |
//
|
|
460 |
// Handles key events. The most of the keys are passed to the control editor.
|
|
461 |
// ---------------------------------------------------------
|
|
462 |
//
|
|
463 |
TKeyResponse CMsgAttachmentControl::OfferKeyEventL(
|
|
464 |
const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/ )
|
|
465 |
{
|
|
466 |
return EKeyWasNotConsumed;
|
|
467 |
}
|
|
468 |
|
|
469 |
// ---------------------------------------------------------
|
|
470 |
// CMsgAttachmentControl::HandleResourceChange
|
|
471 |
//
|
|
472 |
// Handles resouce change events. Event are passed to the base
|
|
473 |
// class and if layout has been switched new layouts are resolved
|
|
474 |
// from LAF.
|
|
475 |
// ---------------------------------------------------------
|
|
476 |
//
|
|
477 |
void CMsgAttachmentControl::HandleResourceChange( TInt aType )
|
|
478 |
{
|
|
479 |
TRAP_IGNORE(
|
|
480 |
{
|
|
481 |
DoHandleResourceChangeBeforeL( aType );
|
|
482 |
|
|
483 |
CMsgExpandableControl::HandleResourceChange( aType );
|
|
484 |
|
|
485 |
DoHandleResourceChangeAfterL( aType );
|
|
486 |
} );
|
|
487 |
}
|
|
488 |
|
|
489 |
// ---------------------------------------------------------
|
|
490 |
// CMsgAttachmentControl::HandlePointerEventL
|
|
491 |
//
|
|
492 |
// Pointer event handling is disabled on editor
|
|
493 |
// ---------------------------------------------------------
|
|
494 |
//
|
|
495 |
void CMsgAttachmentControl::HandlePointerEventL( const TPointerEvent& aPointerEvent )
|
|
496 |
{
|
|
497 |
if ( !iEditor->Rect().Contains( aPointerEvent.iPosition ) )
|
|
498 |
{
|
|
499 |
CMsgExpandableControl::HandlePointerEventL( aPointerEvent );
|
|
500 |
}
|
|
501 |
#ifdef RD_TACTILE_FEEDBACK
|
|
502 |
else if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
|
|
503 |
{
|
|
504 |
MTouchFeedback* feedback = MTouchFeedback::Instance();
|
|
505 |
if ( feedback )
|
|
506 |
{
|
|
507 |
feedback->InstantFeedback( this, ETouchFeedbackBasic );
|
|
508 |
}
|
|
509 |
}
|
|
510 |
#endif
|
|
511 |
}
|
|
512 |
|
|
513 |
// ---------------------------------------------------------
|
|
514 |
// CMsgAttachmentControl::FocusChanged
|
|
515 |
//
|
|
516 |
// This is called when the focus of the control is changed.
|
|
517 |
// ---------------------------------------------------------
|
|
518 |
//
|
|
519 |
void CMsgAttachmentControl::FocusChanged( TDrawNow aDrawNow )
|
|
520 |
{
|
|
521 |
CMsgExpandableControl::FocusChanged( aDrawNow );
|
|
522 |
|
|
523 |
if ( IsReadOnly() )
|
|
524 |
{
|
|
525 |
TRAP_IGNORE( UpdateFocusL() );
|
|
526 |
}
|
|
527 |
|
|
528 |
if ( iAutomaticScrolling )
|
|
529 |
{
|
|
530 |
StopAutomaticScrolling();
|
|
531 |
|
|
532 |
if ( IsFocused() )
|
|
533 |
{
|
|
534 |
StartAutomaticScrolling( KScrollStartDelay );
|
|
535 |
}
|
|
536 |
else
|
|
537 |
{
|
|
538 |
// Reset text to the beginning when focus is lost.
|
|
539 |
iScrollPos = EScrollPosBeginning;
|
|
540 |
TRAP_IGNORE( SetTextForEditorL( EFalse, ETrue ) );
|
|
541 |
|
|
542 |
// Reset the text view to it's original position.
|
|
543 |
iEditor->TextView()->SetLeftTextMargin( 0 );
|
|
544 |
}
|
|
545 |
}
|
|
546 |
}
|
|
547 |
|
|
548 |
// ---------------------------------------------------------
|
|
549 |
// CMsgAttachmentControl::Draw
|
|
550 |
// Attachment icon is drawn to the line indicated by LAF x
|
|
551 |
// coordinate and controls current y coordinate.
|
|
552 |
// Attachment icon is also centered vertically to current
|
|
553 |
// control height.
|
|
554 |
// ---------------------------------------------------------
|
|
555 |
//
|
|
556 |
void CMsgAttachmentControl::Draw( const TRect& /*aRect*/ ) const
|
|
557 |
{
|
|
558 |
if ( !iButton )
|
|
559 |
{
|
|
560 |
TPoint tlc( iIconLayout.Rect().iTl.iX, Position().iY );
|
|
561 |
tlc.iY += ( Size().iHeight - iIconLayout.Rect().Size().iHeight ) / 2;
|
|
562 |
|
|
563 |
SystemGc().BitBltMasked( tlc,
|
|
564 |
iLabelIcon->Bitmap(),
|
|
565 |
iIconLayout.Rect().Size(),
|
|
566 |
iLabelIcon->Mask(),
|
|
567 |
EFalse );
|
|
568 |
}
|
|
569 |
}
|
|
570 |
|
|
571 |
// ---------------------------------------------------------
|
|
572 |
// CMsgAttachmentControl::ActivateL
|
|
573 |
// ---------------------------------------------------------
|
|
574 |
//
|
|
575 |
void CMsgAttachmentControl::ActivateL()
|
|
576 |
{
|
|
577 |
CMsgExpandableControl::ActivateL();
|
|
578 |
|
|
579 |
// Needs to be called after CEikEdwin::ActivateL as
|
|
580 |
// panics if CEikEdwin::iTextView is not present
|
|
581 |
iEditor->SetWordWrapL( EFalse );
|
|
582 |
|
|
583 |
// Cursor is set to the beginning of text.
|
|
584 |
iEditor->SetCursorPosL( 0, EFalse );
|
|
585 |
|
|
586 |
if ( iEditor->TextView() )
|
|
587 |
{
|
|
588 |
const CFont* font = iEditorLayout.Font();
|
|
589 |
TInt scrollJump( font->WidthZeroInPixels() );
|
|
590 |
if ( scrollJump == 0 )
|
|
591 |
{
|
|
592 |
// Font gave us invalid scrollJump have to make
|
|
593 |
// estimate according to scroll area.
|
|
594 |
scrollJump = iEditorLayout.TextRect().Width() / KScrollJumpAreaDivider;
|
|
595 |
}
|
|
596 |
iEditor->TextView()->SetHorizontalScrollJump( scrollJump );
|
|
597 |
}
|
|
598 |
}
|
|
599 |
|
|
600 |
// ---------------------------------------------------------
|
|
601 |
// CMsgAttachmentControl::UpdateControlL
|
|
602 |
// ---------------------------------------------------------
|
|
603 |
//
|
|
604 |
void CMsgAttachmentControl::UpdateControlL()
|
|
605 |
{
|
|
606 |
SetTextForEditorL( ETrue, ETrue );
|
|
607 |
|
|
608 |
if ( iScrollTimer->IsActive() )
|
|
609 |
{
|
|
610 |
// Restart scrolling when attachment list is modified.
|
|
611 |
iScrollPos = EScrollPosBeginning;
|
|
612 |
StartAutomaticScrolling( KScrollStartDelay );
|
|
613 |
}
|
|
614 |
|
|
615 |
DrawDeferred();
|
|
616 |
iControlModeFlags |= EMsgControlModeModified;
|
|
617 |
}
|
|
618 |
|
|
619 |
|
|
620 |
// ---------------------------------------------------------
|
|
621 |
// CMsgAttachmentControl::SetTextForEditorL
|
|
622 |
// ---------------------------------------------------------
|
|
623 |
//
|
|
624 |
void CMsgAttachmentControl::SetTextForEditorL( TBool aContentChanged, TBool aClipText )
|
|
625 |
{
|
|
626 |
TInt count = iAttachmentArray->Count();
|
|
627 |
TInt length = 0;
|
|
628 |
|
|
629 |
for ( TInt i = 0; i < count; i++ )
|
|
630 |
{
|
|
631 |
length += iAttachmentArray->MdcaPoint( i ).Length();
|
|
632 |
length += KAttachmentListSeparator().Length();
|
|
633 |
}
|
|
634 |
|
|
635 |
HBufC* buf = HBufC::NewLC( length );
|
|
636 |
TPtr temp = buf->Des();
|
|
637 |
|
|
638 |
for ( TInt j = 0; j < count; j++ )
|
|
639 |
{
|
|
640 |
temp.Append( iAttachmentArray->MdcaPoint( j ) );
|
|
641 |
if ( j < count - 1 )
|
|
642 |
{
|
|
643 |
temp.Append( KAttachmentListSeparator );
|
|
644 |
}
|
|
645 |
}
|
|
646 |
|
|
647 |
const CFont* font = iEditorLayout.Font();
|
|
648 |
|
|
649 |
TInt clipWidth = 0;
|
|
650 |
|
|
651 |
if ( iEditor->TextView() )
|
|
652 |
{
|
|
653 |
clipWidth = iEditor->TextView()->ViewRect().Width();
|
|
654 |
}
|
|
655 |
else
|
|
656 |
{
|
|
657 |
clipWidth = iEditorLayout.TextRect().Width();
|
|
658 |
}
|
|
659 |
|
|
660 |
TBool enableAutomaticScrolling( ETrue );
|
|
661 |
if ( temp.Length() == 0 )
|
|
662 |
{
|
|
663 |
// Disable all processing if field is empty.
|
|
664 |
enableAutomaticScrolling = EFalse;
|
|
665 |
aContentChanged = EFalse;
|
|
666 |
}
|
|
667 |
|
|
668 |
if ( aContentChanged )
|
|
669 |
{
|
|
670 |
// Attachment array has been updated.
|
|
671 |
TInt fits = font->TextCount( temp, clipWidth );
|
|
672 |
|
|
673 |
if ( fits >= temp.Length() )
|
|
674 |
{
|
|
675 |
// All text fits to the field. No automatic scrolling.
|
|
676 |
enableAutomaticScrolling = EFalse;
|
|
677 |
}
|
|
678 |
}
|
|
679 |
|
|
680 |
if ( enableAutomaticScrolling )
|
|
681 |
{
|
|
682 |
EnableAutomaticScrolling();
|
|
683 |
|
|
684 |
if ( aClipText )
|
|
685 |
{
|
|
686 |
ClipTextL( temp, clipWidth );
|
|
687 |
}
|
|
688 |
}
|
|
689 |
else
|
|
690 |
{
|
|
691 |
DisableAutomaticScrolling();
|
|
692 |
}
|
|
693 |
|
|
694 |
// Replaces old text with new text.
|
|
695 |
iEditor->SetTextL( buf );
|
|
696 |
|
|
697 |
if ( IsActivated() && iEditor->CursorPos() != 0 )
|
|
698 |
{
|
|
699 |
// Cursor is set to the beginning of text.
|
|
700 |
// Should not be called for non-activated control.
|
|
701 |
iEditor->SetCursorPosL( 0, EFalse );
|
|
702 |
}
|
|
703 |
|
|
704 |
CleanupStack::PopAndDestroy( buf );
|
|
705 |
}
|
|
706 |
|
|
707 |
// ---------------------------------------------------------
|
|
708 |
// CMsgAttachmentControl::ResolveLayoutsL
|
|
709 |
//
|
|
710 |
// ---------------------------------------------------------
|
|
711 |
//
|
|
712 |
void CMsgAttachmentControl::ResolveLayoutsL()
|
|
713 |
{
|
|
714 |
TAknLayoutRect msgTextPane;
|
|
715 |
msgTextPane.LayoutRect( MsgEditorCommons::MsgDataPane(),
|
|
716 |
AknLayoutScalable_Apps::msg_text_pane( 0 ).LayoutLine() );
|
|
717 |
|
|
718 |
TAknLayoutRect msgHeaderPane;
|
|
719 |
msgHeaderPane.LayoutRect( msgTextPane.Rect(),
|
|
720 |
AknLayoutScalable_Apps::msg_header_pane().LayoutLine() );
|
|
721 |
|
|
722 |
iIconLayout.LayoutRect( msgHeaderPane.Rect(),
|
|
723 |
AknLayoutScalable_Apps::msg_header_pane_g1().LayoutLine() );
|
|
724 |
|
|
725 |
CMsgExpandableControl::ResolveLayoutsL();
|
|
726 |
|
|
727 |
//partial input in landscape causes rects to overlay when toolbar is invisible
|
|
728 |
if (iIconLayout.Rect().Intersects(iEditorLayout.TextRect()))
|
|
729 |
{
|
|
730 |
TRect headerPane = msgHeaderPane.Rect();
|
|
731 |
//include toolbar width
|
|
732 |
if (!AknLayoutUtils::LayoutMirrored())
|
|
733 |
{
|
|
734 |
headerPane.iBr.iX -= GetToolBarRect().Width();
|
|
735 |
}
|
|
736 |
else
|
|
737 |
{
|
|
738 |
headerPane.iTl.iX += GetToolBarRect().Width();
|
|
739 |
}
|
|
740 |
|
|
741 |
iIconLayout.LayoutRect( headerPane,
|
|
742 |
AknLayoutScalable_Apps::msg_header_pane_g1( 0 ).LayoutLine() );
|
|
743 |
LayoutButton();
|
|
744 |
}
|
|
745 |
|
|
746 |
if ( iButton )
|
|
747 |
{
|
|
748 |
iButton->SetSize( iButton->Size() );
|
|
749 |
}
|
|
750 |
else
|
|
751 |
{
|
|
752 |
User::LeaveIfError( AknIconUtils::SetSize( iLabelIcon->Bitmap(),
|
|
753 |
iIconLayout.Rect().Size() ) );
|
|
754 |
}
|
|
755 |
if ( iEditor->MsgEditorCustomDraw() )
|
|
756 |
{
|
|
757 |
iEditor->MsgEditorCustomDraw()->ResolveLayouts();
|
|
758 |
}
|
|
759 |
}
|
|
760 |
|
|
761 |
// ---------------------------------------------------------
|
|
762 |
// CMsgAttachmentControl::CreateAttachmentIconsL
|
|
763 |
// ---------------------------------------------------------
|
|
764 |
//
|
|
765 |
CGulIcon* CMsgAttachmentControl::CreateAttachmentIconsL()
|
|
766 |
{
|
|
767 |
TParse fileParse;
|
|
768 |
fileParse.Set( KIconMbmFile, &KDC_APP_BITMAP_DIR, NULL );
|
|
769 |
|
|
770 |
CFbsBitmap* bitmap = NULL;
|
|
771 |
CFbsBitmap* mask = NULL;
|
|
772 |
|
|
773 |
AknsUtils::CreateColorIconLC( AknsUtils::SkinInstance(),
|
|
774 |
KAknsIIDQgnIndiMceAttach,
|
|
775 |
KAknsIIDQsnIconColors,
|
|
776 |
EAknsCIQsnIconColorsCG13,
|
|
777 |
bitmap,
|
|
778 |
mask,
|
|
779 |
fileParse.FullName(),
|
|
780 |
EMbmMsgeditorQgn_indi_mce_attach,
|
|
781 |
EMbmMsgeditorQgn_indi_mce_attach_mask,
|
|
782 |
AKN_LAF_COLOR( KDefaultAttachmentColor ) );
|
|
783 |
|
|
784 |
CGulIcon* result = CGulIcon::NewL( bitmap, mask ); // Ownership transferred
|
|
785 |
CleanupStack::Pop( 2 ); // bitmap, mask
|
|
786 |
|
|
787 |
return result;
|
|
788 |
}
|
|
789 |
|
|
790 |
// ---------------------------------------------------------
|
|
791 |
// CMsgAttachmentControl::CreateButtonL
|
|
792 |
// ---------------------------------------------------------
|
|
793 |
//
|
|
794 |
#ifdef RD_SCALABLE_UI_V2
|
|
795 |
void CMsgAttachmentControl::CreateButtonL()
|
|
796 |
{
|
|
797 |
delete iButton;
|
|
798 |
iButton = NULL;
|
|
799 |
|
|
800 |
CGulIcon* buttonIcon = CGulIcon::NewL( iLabelIcon->Bitmap(), iLabelIcon->Mask() );
|
|
801 |
buttonIcon->SetBitmapsOwnedExternally( ETrue ); // bitmaps owned by iLabelIcon
|
|
802 |
|
|
803 |
CleanupStack::PushL( buttonIcon );
|
|
804 |
|
|
805 |
iButton = CAknButton::NewL( buttonIcon,
|
|
806 |
NULL,
|
|
807 |
NULL,
|
|
808 |
NULL,
|
|
809 |
KNullDesC,
|
|
810 |
KNullDesC,
|
|
811 |
KAknButtonSizeFitText,
|
|
812 |
0 );
|
|
813 |
|
|
814 |
CleanupStack::Pop( buttonIcon ); // buttonIcon owned by iButton
|
|
815 |
|
|
816 |
iButton->SetIconScaleMode( EAspectRatioPreserved );
|
|
817 |
|
|
818 |
iButton->SetObserver( this );
|
|
819 |
|
|
820 |
if ( DrawableWindow() )
|
|
821 |
{
|
|
822 |
iButton->SetContainerWindowL( Window() );
|
|
823 |
iButton->ActivateL();
|
|
824 |
}
|
|
825 |
}
|
|
826 |
#else
|
|
827 |
void CMsgAttachmentControl::CreateButtonL()
|
|
828 |
{
|
|
829 |
}
|
|
830 |
#endif // RD_SCALABLE_UI_V2
|
|
831 |
|
|
832 |
|
|
833 |
// ---------------------------------------------------------
|
|
834 |
// CMsgAttachmentControl::DoScrollTextL
|
|
835 |
// ---------------------------------------------------------
|
|
836 |
//
|
|
837 |
TInt CMsgAttachmentControl::DoScrollTextL( TAny* aObject )
|
|
838 |
{
|
|
839 |
// cast, and call non-static function
|
|
840 |
CMsgAttachmentControl* control = static_cast<CMsgAttachmentControl*>( aObject );
|
|
841 |
TRAPD( error ,control->ScrollTextL() );
|
|
842 |
if ( error != KErrNone )
|
|
843 |
{
|
|
844 |
control->StopAutomaticScrolling();
|
|
845 |
User::Leave( error );
|
|
846 |
}
|
|
847 |
return KErrNone;
|
|
848 |
}
|
|
849 |
|
|
850 |
// ---------------------------------------------------------
|
|
851 |
// CMsgAttachmentControl::ScrollTextL
|
|
852 |
// ---------------------------------------------------------
|
|
853 |
//
|
|
854 |
void CMsgAttachmentControl::ScrollTextL()
|
|
855 |
{
|
|
856 |
TBool scrollText( ETrue );
|
|
857 |
if ( iScrollPos == EScrollPosBeginning )
|
|
858 |
{
|
|
859 |
SetTextForEditorL( EFalse, EFalse );
|
|
860 |
}
|
|
861 |
else if ( iScrollPos == EScrollPosEnd )
|
|
862 |
{
|
|
863 |
// Indicates that text has been scrolled to the end and should be restarted.
|
|
864 |
SetTextForEditorL( EFalse, ETrue );
|
|
865 |
iScrollPos = EScrollPosBeginning;
|
|
866 |
scrollText = EFalse;
|
|
867 |
|
|
868 |
// Reset the text view to it's original position.
|
|
869 |
iEditor->TextView()->SetLeftTextMargin( 0 );
|
|
870 |
DrawNow();
|
|
871 |
|
|
872 |
StartAutomaticScrolling( KScrollRestartDelay );
|
|
873 |
}
|
|
874 |
|
|
875 |
if ( scrollText )
|
|
876 |
{
|
|
877 |
TInt scrolledPixels = iEditor->TextView()->ScrollDisplayL( TCursorPosition::EFRight );
|
|
878 |
if ( scrolledPixels == 0 )
|
|
879 |
{
|
|
880 |
// Indicates that text has been scrolled to the end.
|
|
881 |
iScrollPos = EScrollPosEnd;
|
|
882 |
StartAutomaticScrolling( KScrollEndDelay );
|
|
883 |
}
|
|
884 |
else
|
|
885 |
{
|
|
886 |
iScrollPos = EScrollPosOther;
|
|
887 |
}
|
|
888 |
}
|
|
889 |
}
|
|
890 |
|
|
891 |
// ---------------------------------------------------------
|
|
892 |
// CMsgAttachmentControl::DisableAutomaticScrolling
|
|
893 |
// ---------------------------------------------------------
|
|
894 |
//
|
|
895 |
void CMsgAttachmentControl::DisableAutomaticScrolling()
|
|
896 |
{
|
|
897 |
iAutomaticScrolling = EFalse;
|
|
898 |
StopAutomaticScrolling();
|
|
899 |
}
|
|
900 |
|
|
901 |
// ---------------------------------------------------------
|
|
902 |
// CMsgAttachmentControl::EnableAutomaticScrolling
|
|
903 |
// ---------------------------------------------------------
|
|
904 |
//
|
|
905 |
void CMsgAttachmentControl::EnableAutomaticScrolling()
|
|
906 |
{
|
|
907 |
iAutomaticScrolling = ETrue;
|
|
908 |
|
|
909 |
if ( !iScrollTimer->IsActive() &&
|
|
910 |
IsFocused() )
|
|
911 |
{
|
|
912 |
StartAutomaticScrolling( KScrollStartDelay );
|
|
913 |
}
|
|
914 |
}
|
|
915 |
|
|
916 |
|
|
917 |
// ---------------------------------------------------------
|
|
918 |
// CMsgAttachmentControl::StartAutomaticScrolling
|
|
919 |
// ---------------------------------------------------------
|
|
920 |
//
|
|
921 |
void CMsgAttachmentControl::StartAutomaticScrolling( TInt aStartDelay )
|
|
922 |
{
|
|
923 |
StopAutomaticScrolling();
|
|
924 |
iScrollTimer->Start( aStartDelay,
|
|
925 |
KScrollTickDelay,
|
|
926 |
TCallBack( DoScrollTextL, this ) );
|
|
927 |
}
|
|
928 |
|
|
929 |
// ---------------------------------------------------------
|
|
930 |
// CMsgAttachmentControl::StopAutomaticScrolling
|
|
931 |
// ---------------------------------------------------------
|
|
932 |
//
|
|
933 |
void CMsgAttachmentControl::StopAutomaticScrolling()
|
|
934 |
{
|
|
935 |
iScrollTimer->Cancel();
|
|
936 |
}
|
|
937 |
|
|
938 |
// ---------------------------------------------------------
|
|
939 |
// CMsgAttachmentControl::ClipTextL
|
|
940 |
// ---------------------------------------------------------
|
|
941 |
//
|
|
942 |
void CMsgAttachmentControl::ClipTextL( TPtr aText, TInt aClipWidth )
|
|
943 |
{
|
|
944 |
const CFont* font = iEditorLayout.Font();
|
|
945 |
|
|
946 |
TInt fits = font->TextCount( aText, aClipWidth );
|
|
947 |
|
|
948 |
if ( fits < aText.Length() )
|
|
949 |
{
|
|
950 |
// Clipping is actually done only if text is at the beginning.
|
|
951 |
TInt ellipsisWidth = font->CharWidthInPixels( KEllipsis );
|
|
952 |
|
|
953 |
fits = font->TextCount( aText, aClipWidth - ellipsisWidth );
|
|
954 |
|
|
955 |
// Work out the text directionality before the truncation point.
|
|
956 |
// First put the text in reverse order and then call
|
|
957 |
// TBidiText::TextDirectionality. This effectively tells the
|
|
958 |
// directionality of the last strongly directional character
|
|
959 |
// in the text.
|
|
960 |
HBufC* temp = aText.Left( fits ).AllocL();
|
|
961 |
TPtr tempPtr = temp->Des();
|
|
962 |
|
|
963 |
TInt i = 0;
|
|
964 |
TInt j = tempPtr.Length() - 1;
|
|
965 |
while ( i < j )
|
|
966 |
{
|
|
967 |
TText t = tempPtr[i];
|
|
968 |
tempPtr[i++] = tempPtr[j];
|
|
969 |
tempPtr[j--] = t;
|
|
970 |
}
|
|
971 |
|
|
972 |
TBidiText::TDirectionality dir = TBidiText::TextDirectionality( tempPtr );
|
|
973 |
|
|
974 |
delete temp;
|
|
975 |
|
|
976 |
TText dirMarker = ( dir == TBidiText::ERightToLeft ) ? KRLMarker :
|
|
977 |
KLRMarker;
|
|
978 |
|
|
979 |
// Insert zero width joiner if necessary to get the correct glyph form
|
|
980 |
// before truncation.
|
|
981 |
TText lastChar = aText[fits - 1];
|
|
982 |
TText next = aText[fits];
|
|
983 |
|
|
984 |
TInt ellipsisPos = fits;
|
|
985 |
|
|
986 |
if ( CFont::CharactersJoin( lastChar, KZeroWidthJoiner ) &&
|
|
987 |
CFont::CharactersJoin( lastChar, next ) )
|
|
988 |
{
|
|
989 |
aText[fits] = KZeroWidthJoiner;
|
|
990 |
ellipsisPos++;
|
|
991 |
}
|
|
992 |
|
|
993 |
aText.SetMax();
|
|
994 |
|
|
995 |
aText[ellipsisPos] = KEllipsis;
|
|
996 |
|
|
997 |
// Inserting direction marker after the ellipsis ensures that
|
|
998 |
// the ellipsis is shown on the correct side of the text
|
|
999 |
// before it.
|
|
1000 |
aText[ellipsisPos + 1] = dirMarker;
|
|
1001 |
|
|
1002 |
aText.SetLength( ellipsisPos + 2 );
|
|
1003 |
}
|
|
1004 |
}
|
|
1005 |
|
|
1006 |
// ---------------------------------------------------------
|
|
1007 |
// CMsgAttachmentControl::UpdateFocusL
|
|
1008 |
// ---------------------------------------------------------
|
|
1009 |
//
|
|
1010 |
void CMsgAttachmentControl::UpdateFocusL()
|
|
1011 |
{
|
|
1012 |
TCharFormat charFormat;
|
|
1013 |
TCharFormatMask applyMask;
|
|
1014 |
|
|
1015 |
iEditor->RichText()->GetCharFormat( charFormat,
|
|
1016 |
applyMask,
|
|
1017 |
0,
|
|
1018 |
iEditor->TextLength() );
|
|
1019 |
|
|
1020 |
if ( !IsFocused() )
|
|
1021 |
{
|
|
1022 |
TRgb textColor( KRgbBlack );
|
|
1023 |
AknsUtils::GetCachedColor( AknsUtils::SkinInstance(),
|
|
1024 |
textColor,
|
|
1025 |
KAknsIIDQsnTextColors,
|
|
1026 |
EAknsCIQsnTextColorsCG6 );
|
|
1027 |
|
|
1028 |
charFormat.iFontPresentation.iTextColor = textColor;
|
|
1029 |
applyMask.SetAttrib( EAttColor );
|
|
1030 |
|
|
1031 |
charFormat.iFontPresentation.iHighlightStyle = TFontPresentation::EFontHighlightNone;
|
|
1032 |
applyMask.SetAttrib( EAttFontHighlightStyle );
|
|
1033 |
}
|
|
1034 |
else
|
|
1035 |
{
|
|
1036 |
TRgb textColor( KRgbWhite );
|
|
1037 |
AknsUtils::GetCachedColor( AknsUtils::SkinInstance(),
|
|
1038 |
textColor,
|
|
1039 |
KAknsIIDQsnHighlightColors,
|
|
1040 |
EAknsCIQsnTextColorsCG3 );
|
|
1041 |
|
|
1042 |
charFormat.iFontPresentation.iTextColor = textColor;
|
|
1043 |
applyMask.SetAttrib( EAttColor );
|
|
1044 |
|
|
1045 |
TRgb highlightColor( KRgbBlue );
|
|
1046 |
AknsUtils::GetCachedColor( AknsUtils::SkinInstance(),
|
|
1047 |
highlightColor,
|
|
1048 |
KAknsIIDQsnHighlightColors,
|
|
1049 |
EAknsCIQsnHighlightColorsCG1 );
|
|
1050 |
|
|
1051 |
charFormat.iFontPresentation.iHighlightColor = highlightColor;
|
|
1052 |
applyMask.SetAttrib( EAttFontHighlightColor );
|
|
1053 |
|
|
1054 |
charFormat.iFontPresentation.iHighlightStyle = TFontPresentation::EFontHighlightNormal;
|
|
1055 |
applyMask.SetAttrib( EAttFontHighlightStyle );
|
|
1056 |
}
|
|
1057 |
|
|
1058 |
iEditor->RichText()->ApplyCharFormatL( charFormat,
|
|
1059 |
applyMask,
|
|
1060 |
0,
|
|
1061 |
iEditor->TextLength() );
|
|
1062 |
}
|
|
1063 |
|
|
1064 |
// ---------------------------------------------------------
|
|
1065 |
// CMsgAttachmentControl::DoHandleResourceChangeBeforeL
|
|
1066 |
//
|
|
1067 |
// Contains functionality that base class handle resource change
|
|
1068 |
// is depending on to be completed before it can be executed properly.
|
|
1069 |
// ---------------------------------------------------------
|
|
1070 |
//
|
|
1071 |
void CMsgAttachmentControl::DoHandleResourceChangeBeforeL( TInt aType )
|
|
1072 |
{
|
|
1073 |
switch( aType )
|
|
1074 |
{
|
|
1075 |
case KEikDynamicLayoutVariantSwitch:
|
|
1076 |
{
|
|
1077 |
#ifdef RD_SCALABLE_UI_V2
|
|
1078 |
if ( AknLayoutUtils::PenEnabled() )
|
|
1079 |
{
|
|
1080 |
if ( !iButton )
|
|
1081 |
{
|
|
1082 |
CreateButtonL();
|
|
1083 |
}
|
|
1084 |
}
|
|
1085 |
else
|
|
1086 |
{
|
|
1087 |
delete iButton;
|
|
1088 |
iButton = NULL;
|
|
1089 |
}
|
|
1090 |
#endif // RD_SCALABLE_UI_V2
|
|
1091 |
break;
|
|
1092 |
}
|
|
1093 |
default:
|
|
1094 |
{
|
|
1095 |
break;
|
|
1096 |
}
|
|
1097 |
}
|
|
1098 |
}
|
|
1099 |
|
|
1100 |
// ---------------------------------------------------------
|
|
1101 |
// CMsgAttachmentControl::DoHandleResourceChangeAfterL
|
|
1102 |
//
|
|
1103 |
// Contains functionality that is dependant of base class handle
|
|
1104 |
// resource change to complete before these can be executed properly.
|
|
1105 |
// ---------------------------------------------------------
|
|
1106 |
//
|
|
1107 |
void CMsgAttachmentControl::DoHandleResourceChangeAfterL( TInt aType )
|
|
1108 |
{
|
|
1109 |
switch( aType )
|
|
1110 |
{
|
|
1111 |
case KEikDynamicLayoutVariantSwitch:
|
|
1112 |
{
|
|
1113 |
StopAutomaticScrolling();
|
|
1114 |
iScrollPos = EScrollPosBeginning;
|
|
1115 |
SetTextForEditorL( EFalse, ETrue );
|
|
1116 |
|
|
1117 |
break;
|
|
1118 |
}
|
|
1119 |
case KAknsMessageSkinChange:
|
|
1120 |
{
|
|
1121 |
CGulIcon* icon = CreateAttachmentIconsL();
|
|
1122 |
CleanupStack::PushL( icon );
|
|
1123 |
|
|
1124 |
if ( iButton )
|
|
1125 |
{
|
|
1126 |
CGulIcon* buttonIcon = CGulIcon::NewL( icon->Bitmap(), icon->Mask() );
|
|
1127 |
buttonIcon->SetBitmapsOwnedExternally( ETrue ); // bitmaps owned by iLabelIcon
|
|
1128 |
|
|
1129 |
iButton->State()->SetIcon( buttonIcon ); // buttonIcon ownership transferred
|
|
1130 |
}
|
|
1131 |
|
|
1132 |
// Make the change here as button will take the old size from
|
|
1133 |
// old icons that must be still valid when setting to button icon.
|
|
1134 |
delete iLabelIcon;
|
|
1135 |
iLabelIcon = icon;
|
|
1136 |
|
|
1137 |
CleanupStack::Pop( icon );
|
|
1138 |
|
|
1139 |
ResolveLayoutsL();
|
|
1140 |
break;
|
|
1141 |
}
|
|
1142 |
default:
|
|
1143 |
{
|
|
1144 |
break;
|
|
1145 |
}
|
|
1146 |
}
|
|
1147 |
}
|
|
1148 |
|
|
1149 |
// ---------------------------------------------------------
|
|
1150 |
// CMsgAttachmentControl::AddToAttachmentArrayL
|
|
1151 |
// ---------------------------------------------------------
|
|
1152 |
//
|
|
1153 |
void CMsgAttachmentControl::AddToAttachmentArrayL( const TDesC& aName, TInt aIndex )
|
|
1154 |
{
|
|
1155 |
HBufC* convertedFileName =
|
|
1156 |
AknTextUtils::ConvertFileNameL( aName );
|
|
1157 |
CleanupStack::PushL( convertedFileName );
|
|
1158 |
|
|
1159 |
TPtr convertedFileNamePtr = convertedFileName->Des();
|
|
1160 |
|
|
1161 |
AknTextUtils::StripCharacters( convertedFileNamePtr, KStripList );
|
|
1162 |
|
|
1163 |
iAttachmentArray->InsertL( aIndex, *convertedFileName );
|
|
1164 |
|
|
1165 |
CleanupStack::PopAndDestroy( convertedFileName );
|
|
1166 |
}
|
|
1167 |
|
|
1168 |
// ---------------------------------------------------------
|
|
1169 |
// CMsgAttachmentControl::LayoutButton
|
|
1170 |
// ---------------------------------------------------------
|
|
1171 |
//
|
|
1172 |
void CMsgAttachmentControl::LayoutButton()
|
|
1173 |
{
|
|
1174 |
#ifdef RD_SCALABLE_UI_V2
|
|
1175 |
CMsgExpandableControl::LayoutButton();
|
|
1176 |
|
|
1177 |
if ( iButton )
|
|
1178 |
{
|
|
1179 |
TMargins8 margins;
|
|
1180 |
TRect buttonRect = iButtonLayout.Rect();
|
|
1181 |
TRect iconRect = iIconLayout.Rect();
|
|
1182 |
margins.iTop = iconRect.iTl.iY - buttonRect.iTl.iY;
|
|
1183 |
margins.iBottom = buttonRect.iBr.iY - iconRect.iBr.iY;
|
|
1184 |
margins.iLeft = iconRect.iTl.iX - buttonRect.iTl.iX;
|
|
1185 |
margins.iRight = buttonRect.iBr.iX - iconRect.iBr.iX;
|
|
1186 |
|
|
1187 |
iButton->SetMargins( margins );
|
|
1188 |
}
|
|
1189 |
#endif // RD_SCALABLE_UI_V2
|
|
1190 |
}
|
|
1191 |
|
|
1192 |
|
|
1193 |
// End of File
|