79
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: MsgBodyControl implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// ========== INCLUDE FILES ================================
|
|
21 |
|
|
22 |
#include <txtrich.h> // for CRichText
|
|
23 |
#include <eikenv.h> // for CEikonEnv
|
|
24 |
#include <gulfont.h> // for TLogicalFont
|
|
25 |
#include <AknUtils.h> // for AknUtils
|
|
26 |
#include <aknenv.h> // for CAknEnv
|
|
27 |
#include <ItemFinder.h> // for automatic highlight
|
|
28 |
#include <AknsUtils.h> // for Skinned drawing
|
|
29 |
#include <AknDef.h>
|
|
30 |
#include <StringLoader.h> // for StringLoader (load and foramt strings from resources)
|
|
31 |
#include <MsgEditorAppUi.rsg>
|
|
32 |
|
|
33 |
#include <applayout.cdl.h> // LAF
|
|
34 |
#include <aknlayoutscalable_apps.cdl.h>
|
|
35 |
|
|
36 |
#include "MsgEditorCommon.h" //
|
|
37 |
#include "MsgEditorView.h" // for CMsgEditorView
|
|
38 |
#include "MsgBodyControl.h" // for CMsgBodyControl
|
|
39 |
#include "MsgBaseControlObserver.h" // for MMsgBaseControlObserver
|
|
40 |
#include "MsgBodyControlEditor.h" // for CMsgBodyControlEditor
|
|
41 |
#include "MsgEditorPanic.h" // for MsgEditor panics
|
|
42 |
|
|
43 |
#include "MsgEditorLogging.h"
|
|
44 |
|
|
45 |
// ========== EXTERNAL DATA STRUCTURES =====================
|
|
46 |
|
|
47 |
// ========== EXTERNAL FUNCTION PROTOTYPES =================
|
|
48 |
|
|
49 |
// ========== CONSTANTS ====================================
|
|
50 |
|
|
51 |
// ========== MACROS =======================================
|
|
52 |
|
|
53 |
// ========== LOCAL CONSTANTS AND MACROS ===================
|
|
54 |
|
|
55 |
// ========== MODULE DATA STRUCTURES =======================
|
|
56 |
|
|
57 |
// ========== LOCAL FUNCTION PROTOTYPES ====================
|
|
58 |
|
|
59 |
// ========== LOCAL FUNCTIONS ==============================
|
|
60 |
|
|
61 |
// ========== MEMBER FUNCTIONS =============================
|
|
62 |
|
|
63 |
// ---------------------------------------------------------
|
|
64 |
// CMsgBodyControl::CMsgBodyControl
|
|
65 |
//
|
|
66 |
// Constructor.
|
|
67 |
// ---------------------------------------------------------
|
|
68 |
//
|
|
69 |
CMsgBodyControl::CMsgBodyControl( MMsgBaseControlObserver& aBaseControlObserver ) :
|
|
70 |
CMsgExpandableTextEditorControl( aBaseControlObserver )
|
|
71 |
{
|
|
72 |
}
|
|
73 |
|
|
74 |
// ---------------------------------------------------------
|
|
75 |
// CMsgBodyControl::~CMsgBodyControl
|
|
76 |
//
|
|
77 |
// Destructor.
|
|
78 |
// ---------------------------------------------------------
|
|
79 |
//
|
|
80 |
CMsgBodyControl::~CMsgBodyControl()
|
|
81 |
{
|
|
82 |
AknsUtils::DeregisterControlPosition( iEditor );
|
|
83 |
delete iEditor;
|
|
84 |
delete iCaptionText;
|
|
85 |
AknsUtils::DeregisterControlPosition( this );
|
|
86 |
}
|
|
87 |
|
|
88 |
// ---------------------------------------------------------
|
|
89 |
// CMsgBodyControl::NewL
|
|
90 |
//
|
|
91 |
// Factory method that creates this control.
|
|
92 |
// ---------------------------------------------------------
|
|
93 |
//
|
|
94 |
EXPORT_C CMsgBodyControl* CMsgBodyControl::NewL( CCoeControl* aParent )
|
|
95 |
{
|
|
96 |
__ASSERT_DEBUG( aParent, Panic( EMsgNullPointer ) );
|
|
97 |
|
|
98 |
CMsgEditorView* obs = static_cast<CMsgEditorView*>( aParent );
|
|
99 |
CMsgBodyControl* self = new ( ELeave ) CMsgBodyControl( *obs );
|
|
100 |
self->SetMopParent( aParent );
|
|
101 |
|
|
102 |
CleanupStack::PushL( self );
|
|
103 |
self->ConstructL();
|
|
104 |
CleanupStack::Pop( self );
|
|
105 |
|
|
106 |
return self;
|
|
107 |
}
|
|
108 |
|
|
109 |
// ---------------------------------------------------------
|
|
110 |
// CMsgBodyControl::ConstructL
|
|
111 |
//
|
|
112 |
// Creates the body control editor for the this control and sets necessary details.
|
|
113 |
// ---------------------------------------------------------
|
|
114 |
//
|
|
115 |
void CMsgBodyControl::ConstructL()
|
|
116 |
{
|
|
117 |
iControlType = EMsgBodyControl;
|
|
118 |
|
|
119 |
iEditor = new ( ELeave ) CMsgBodyControlEditor( this,
|
|
120 |
iControlModeFlags,
|
|
121 |
iBaseControlObserver );
|
|
122 |
iEditor->ConstructL();
|
|
123 |
|
|
124 |
iEditor->SetControlType(iControlType);
|
|
125 |
iEditor->SetObserver( this );
|
|
126 |
iEditor->SetEdwinSizeObserver( this );
|
|
127 |
iEditor->AddEdwinObserverL( this );
|
|
128 |
iEditor->SetMaxNumberOfChars( 0 );
|
|
129 |
iEditor->SetBorder( TGulBorder::ENone );
|
|
130 |
iEditor->SetAknEditorFlags( EAknEditorFlagUseSCTNumericCharmap |
|
|
131 |
EAknEditorFlagEnablePictographInput |
|
|
132 |
EAknEditorFlagAllowEntersWithScrollDown |
|
|
133 |
EAknEditorFlagEnablePartialScreen
|
|
134 |
);
|
|
135 |
|
|
136 |
SetPlainTextMode( ETrue );
|
|
137 |
|
|
138 |
ResolveFontMetrics();
|
|
139 |
SetIcfPromptTextL();
|
|
140 |
CItemFinder* itemFinder = iEditor->ItemFinder();
|
|
141 |
if ( itemFinder )
|
|
142 |
{
|
|
143 |
// for automatic highlight
|
|
144 |
itemFinder->SetEditor( (CEikRichTextEditor**)&iEditor );
|
|
145 |
}
|
|
146 |
}
|
|
147 |
|
|
148 |
// ---------------------------------------------------------
|
|
149 |
// CMsgBodyControl::Editor
|
|
150 |
//
|
|
151 |
// Returns a reference to the editor control.
|
|
152 |
// ---------------------------------------------------------
|
|
153 |
//
|
|
154 |
EXPORT_C CEikRichTextEditor& CMsgBodyControl::Editor() const
|
|
155 |
{
|
|
156 |
return *iEditor;
|
|
157 |
}
|
|
158 |
|
|
159 |
// ---------------------------------------------------------
|
|
160 |
// CMsgBodyControl::SetTextContentL
|
|
161 |
//
|
|
162 |
// Sets text content to the control editor.
|
|
163 |
// ---------------------------------------------------------
|
|
164 |
//
|
|
165 |
EXPORT_C void CMsgBodyControl::SetTextContentL( CRichText& aText )
|
|
166 |
{
|
|
167 |
CItemFinder* autofind = ItemFinder();
|
|
168 |
|
|
169 |
TBool alreadyBandFormatting( EFalse );
|
|
170 |
if ( iEditor->TextLayout( )->IsFormattingBand( ) )
|
|
171 |
{
|
|
172 |
alreadyBandFormatting = ETrue;
|
|
173 |
}
|
|
174 |
|
|
175 |
iEditor->SetTextContentL( aText );
|
|
176 |
|
|
177 |
// Text added after control has been set visible and
|
|
178 |
// there is enough text to change editor to do band formatting.
|
|
179 |
// We have to update the editor size to maximum body control size
|
|
180 |
// and enable force control size updating to start size change really
|
|
181 |
// happening.
|
|
182 |
if ( iControlModeFlags & EMsgControlModeInitialized &&
|
|
183 |
!alreadyBandFormatting &&
|
|
184 |
iEditor->TextLayout( )->IsFormattingBand( ) )
|
|
185 |
{
|
|
186 |
iControlModeFlags |= EMsgControlModeForceSizeUpdate;
|
|
187 |
|
|
188 |
TSize newSize( iSize.iWidth, iMaxBodyHeight );
|
|
189 |
iEditor->SetSize( newSize );
|
|
190 |
|
|
191 |
iControlModeFlags &= ~EMsgControlModeForceSizeUpdate;
|
|
192 |
}
|
|
193 |
|
|
194 |
if ( autofind ) // for automatic highlight
|
|
195 |
{
|
|
196 |
autofind->SetEditor( (CEikRichTextEditor**)&iEditor );
|
|
197 |
}
|
|
198 |
|
|
199 |
iControlModeFlags |= EMsgControlModeModified;
|
|
200 |
}
|
|
201 |
|
|
202 |
// ---------------------------------------------------------
|
|
203 |
// CMsgBodyControl::InsertCharacterL
|
|
204 |
//
|
|
205 |
// Inserts a character to the editor.
|
|
206 |
// ---------------------------------------------------------
|
|
207 |
//
|
|
208 |
EXPORT_C void CMsgBodyControl::InsertCharacterL( const TChar& aCharacter )
|
|
209 |
{
|
|
210 |
BodyControlEditor()->InsertCharacterL( aCharacter );
|
|
211 |
iControlModeFlags |= EMsgControlModeModified;
|
|
212 |
}
|
|
213 |
|
|
214 |
|
|
215 |
// ---------------------------------------------------------
|
|
216 |
// CMsgBodyControl::InsertTextL
|
|
217 |
//
|
|
218 |
// Inserts text to the editor.
|
|
219 |
// ---------------------------------------------------------
|
|
220 |
//
|
|
221 |
EXPORT_C void CMsgBodyControl::InsertTextL( const TDesC& aText )
|
|
222 |
{
|
|
223 |
BodyControlEditor()->InsertTextL( aText );
|
|
224 |
iControlModeFlags |= EMsgControlModeModified;
|
|
225 |
|
|
226 |
//iBaseControlObserver->HandleBaseControlEventRequestL(this, EMsgEnsureCorrectFormPosition);
|
|
227 |
}
|
|
228 |
|
|
229 |
// ---------------------------------------------------------
|
|
230 |
// CMsgBodyControl::NotifyViewEvent
|
|
231 |
// ---------------------------------------------------------
|
|
232 |
//
|
|
233 |
void CMsgBodyControl::NotifyViewEvent( TMsgViewEvent aEvent, TInt aParam )
|
|
234 |
{
|
|
235 |
TRAP_IGNORE( DoNotifyViewEventL( aEvent, aParam ) );
|
|
236 |
}
|
|
237 |
|
|
238 |
// ---------------------------------------------------------
|
|
239 |
// CMsgBodyControl::DoNotifyViewEventL
|
|
240 |
// ---------------------------------------------------------
|
|
241 |
//
|
|
242 |
void CMsgBodyControl::DoNotifyViewEventL( TMsgViewEvent aEvent, TInt /*aParam*/ )
|
|
243 |
{
|
|
244 |
switch ( aEvent )
|
|
245 |
{
|
|
246 |
case EMsgViewEventPrepareFocusTransitionUp:
|
|
247 |
{
|
|
248 |
if ( IsFocused() && iEditor->TextView() )
|
|
249 |
{
|
|
250 |
iEditor->ClearSelectionL();
|
|
251 |
|
|
252 |
iEditor->TextView()->FinishBackgroundFormattingL();
|
|
253 |
if ( iEditor->TextLayout()->FirstDocPosFullyInBand() != 0 )
|
|
254 |
{
|
|
255 |
iEditor->NotifyNewDocumentL();
|
|
256 |
}
|
|
257 |
|
|
258 |
if ( IsReadOnly() )
|
|
259 |
{
|
|
260 |
iEditor->SetCursorPosL( 0, EFalse );
|
|
261 |
}
|
|
262 |
}
|
|
263 |
|
|
264 |
BodyControlEditor()->PrepareFocusTransition();
|
|
265 |
break;
|
|
266 |
}
|
|
267 |
case EMsgViewEventPrepareFocusTransitionDown:
|
|
268 |
{
|
|
269 |
if ( IsFocused() && iEditor->TextView() )
|
|
270 |
{
|
|
271 |
iEditor->ClearSelectionL();
|
|
272 |
|
|
273 |
iEditor->TextView()->FinishBackgroundFormattingL();
|
|
274 |
if ( !iEditor->CursorInLastLine() )
|
|
275 |
{
|
|
276 |
iEditor->TextView()->SetDocPosL( iEditor->TextLength(), EFalse );
|
|
277 |
|
|
278 |
// fills the screen
|
|
279 |
TViewYPosQualifier yPosQualifier;
|
|
280 |
yPosQualifier.SetFillScreen();
|
|
281 |
iEditor->TextView()->HandleGlobalChangeL( yPosQualifier );
|
|
282 |
}
|
|
283 |
|
|
284 |
if ( IsReadOnly() )
|
|
285 |
{
|
|
286 |
iEditor->SetCursorPosL( iEditor->TextLength(), EFalse );
|
|
287 |
}
|
|
288 |
}
|
|
289 |
|
|
290 |
BodyControlEditor()->PrepareFocusTransition();
|
|
291 |
break;
|
|
292 |
}
|
|
293 |
case EMsgViewEventSetCursorFirstPos:
|
|
294 |
{
|
|
295 |
if ( iEditor->TextView() &&
|
|
296 |
!IsReadOnly() &&
|
|
297 |
!iEditor->CursorInFirstLine() )
|
|
298 |
{
|
|
299 |
iEditor->SetCursorPosL( 0, EFalse );
|
|
300 |
}
|
|
301 |
break;
|
|
302 |
}
|
|
303 |
case EMsgViewEventSetCursorLastPos:
|
|
304 |
{
|
|
305 |
if ( iEditor->TextView() &&
|
|
306 |
!IsReadOnly() &&
|
|
307 |
!iEditor->CursorInLastLine() )
|
|
308 |
{
|
|
309 |
iEditor->SetCursorPosL( iEditor->TextLength(), EFalse );
|
|
310 |
}
|
|
311 |
break;
|
|
312 |
}
|
|
313 |
case EMsgViewEventPrepareForViewing:
|
|
314 |
{
|
|
315 |
/*
|
|
316 |
iEditor->SetSuppressFormatting( EFalse );
|
|
317 |
iEditor->NotifyNewFormatL();
|
|
318 |
*/
|
|
319 |
}
|
|
320 |
default:
|
|
321 |
{
|
|
322 |
break;
|
|
323 |
}
|
|
324 |
}
|
|
325 |
}
|
|
326 |
|
|
327 |
// ---------------------------------------------------------
|
|
328 |
// CMsgBodyControl::Reset
|
|
329 |
//
|
|
330 |
// Resets the editor content and notifies view if EMsgControlModeBodyMaxHeight
|
|
331 |
// is enabled. Explicit function call is needed as control height is not actually
|
|
332 |
// changing on CMsgBodyControl::HandleEdwinSizeEventL.
|
|
333 |
// ---------------------------------------------------------
|
|
334 |
//
|
|
335 |
EXPORT_C void CMsgBodyControl::Reset()
|
|
336 |
{
|
|
337 |
iEditor->Reset();
|
|
338 |
|
|
339 |
if ( iControlModeFlags & EMsgControlModeBodyMaxHeight &&
|
|
340 |
iControlModeFlags & EMsgControlModeInitialized )
|
|
341 |
{
|
|
342 |
TRAP_IGNORE( iBaseControlObserver->HandleBaseControlEventRequestL( this,
|
|
343 |
EMsgHeightChanged ) );
|
|
344 |
}
|
|
345 |
|
|
346 |
iControlModeFlags |= EMsgControlModeModified;
|
|
347 |
}
|
|
348 |
|
|
349 |
// ---------------------------------------------------------
|
|
350 |
// CMsgBodyControl::SetAndGetSizeL
|
|
351 |
//
|
|
352 |
// Sets size for the editor and this control.
|
|
353 |
// ---------------------------------------------------------
|
|
354 |
//
|
|
355 |
EXPORT_C void CMsgBodyControl::SetAndGetSizeL( TSize& aSize )
|
|
356 |
{
|
|
357 |
TSize bodySize( aSize );
|
|
358 |
|
|
359 |
if ( iControlModeFlags & EMsgControlModeBodyMaxHeight )
|
|
360 |
{
|
|
361 |
bodySize.iHeight = iMaxBodyHeight;
|
|
362 |
}
|
|
363 |
else
|
|
364 |
{
|
|
365 |
if ( iEditor->TextLayout() )
|
|
366 |
{
|
|
367 |
if ( iEditor->TextLayout()->IsFormattingBand() )
|
|
368 |
{
|
|
369 |
// With band formatting the idea is that it is only
|
|
370 |
// used when there is more than screen size of text.
|
|
371 |
// If this is false then formatting limits should be
|
|
372 |
// change. This is the reason we can safely use
|
|
373 |
// max body height with it.
|
|
374 |
bodySize.iHeight = iMaxBodyHeight;
|
|
375 |
}
|
|
376 |
else
|
|
377 |
{
|
|
378 |
// Force background formatting to stop so that correct
|
|
379 |
// height can be retrieved
|
|
380 |
if ( iEditor->TextView() )
|
|
381 |
{
|
|
382 |
iEditor->TextView()->FinishBackgroundFormattingL();
|
|
383 |
}
|
|
384 |
|
|
385 |
bodySize.iHeight = iEditor->TextLayout()->NumFormattedLines() * iLineHeight;
|
|
386 |
}
|
|
387 |
}
|
|
388 |
}
|
|
389 |
|
|
390 |
iEditor->SetAndGetSizeL( bodySize );
|
|
391 |
|
|
392 |
MsgEditorCommons::RoundToNextLine( bodySize.iHeight, iLineHeight );
|
|
393 |
|
|
394 |
SetSizeWithoutNotification( bodySize );
|
|
395 |
|
|
396 |
aSize = bodySize;
|
|
397 |
}
|
|
398 |
|
|
399 |
// ---------------------------------------------------------
|
|
400 |
// CMsgBodyControl::IsFocusChangePossible
|
|
401 |
//
|
|
402 |
// Checks if the focus change up or down is possible and returns ETrue if it is.
|
|
403 |
// ---------------------------------------------------------
|
|
404 |
//
|
|
405 |
EXPORT_C TBool CMsgBodyControl::IsFocusChangePossible( TMsgFocusDirection aDirection ) const
|
|
406 |
{
|
|
407 |
TBool changeFocusPossible = EFalse;
|
|
408 |
|
|
409 |
if ( IsReadOnly() )
|
|
410 |
{
|
|
411 |
TRAPD( error, changeFocusPossible = BodyControlEditor()->IsFocusChangePossibleL( aDirection ) );
|
|
412 |
if ( error != KErrNone )
|
|
413 |
{
|
|
414 |
changeFocusPossible = ETrue;
|
|
415 |
}
|
|
416 |
}
|
|
417 |
else
|
|
418 |
{
|
|
419 |
if ( IsCursorLocation( aDirection == EMsgFocusUp ? EMsgTop :
|
|
420 |
EMsgBottom ) )
|
|
421 |
{
|
|
422 |
changeFocusPossible = ETrue;
|
|
423 |
}
|
|
424 |
}
|
|
425 |
|
|
426 |
return changeFocusPossible;
|
|
427 |
}
|
|
428 |
|
|
429 |
// ---------------------------------------------------------
|
|
430 |
// CMsgBodyControl::PrepareForReadOnly
|
|
431 |
//
|
|
432 |
// Sets the editor read only or editable.
|
|
433 |
// ---------------------------------------------------------
|
|
434 |
//
|
|
435 |
void CMsgBodyControl::PrepareForReadOnly( TBool aReadOnly )
|
|
436 |
{
|
|
437 |
TRAP_IGNORE( iEditor->PrepareForReadOnlyL( aReadOnly ) );
|
|
438 |
}
|
|
439 |
|
|
440 |
// ---------------------------------------------------------
|
|
441 |
// CMsgBodyControl::OfferKeyEventL
|
|
442 |
//
|
|
443 |
// Handles key events.
|
|
444 |
// ---------------------------------------------------------
|
|
445 |
//
|
|
446 |
EXPORT_C TKeyResponse CMsgBodyControl::OfferKeyEventL( const TKeyEvent& aKeyEvent,
|
|
447 |
TEventCode aType )
|
|
448 |
{
|
|
449 |
return iEditor->OfferKeyEventL( aKeyEvent, aType );
|
|
450 |
}
|
|
451 |
|
|
452 |
// ---------------------------------------------------------
|
|
453 |
// CMsgBodyControl::InputCapabilities
|
|
454 |
//
|
|
455 |
// Returns input capabilities.
|
|
456 |
// ---------------------------------------------------------
|
|
457 |
//
|
|
458 |
EXPORT_C TCoeInputCapabilities CMsgBodyControl::InputCapabilities() const
|
|
459 |
{
|
|
460 |
if ( iEditor->IsFocused() )
|
|
461 |
{
|
|
462 |
TCoeInputCapabilities inputCapabilities( TCoeInputCapabilities::ENone,
|
|
463 |
NULL,
|
|
464 |
const_cast<CMsgBodyControl*>( this ) );
|
|
465 |
inputCapabilities.MergeWith( iEditor->InputCapabilities() );
|
|
466 |
|
|
467 |
return inputCapabilities;
|
|
468 |
}
|
|
469 |
else
|
|
470 |
{
|
|
471 |
return TCoeInputCapabilities::ENone;
|
|
472 |
}
|
|
473 |
}
|
|
474 |
|
|
475 |
// ---------------------------------------------------------
|
|
476 |
// CMsgBodyControl::HandleResourceChange
|
|
477 |
//
|
|
478 |
//
|
|
479 |
// ---------------------------------------------------------
|
|
480 |
//
|
|
481 |
void CMsgBodyControl::HandleResourceChange( TInt aType )
|
|
482 |
{
|
|
483 |
CMsgExpandableTextEditorControl::HandleResourceChange( aType );
|
|
484 |
|
|
485 |
if ( aType == KEikDynamicLayoutVariantSwitch )
|
|
486 |
{
|
|
487 |
ResolveFontMetrics();
|
|
488 |
|
|
489 |
CItemFinder* itemFinder = iEditor->ItemFinder();
|
|
490 |
if ( itemFinder &&
|
|
491 |
itemFinder->CurrentItemExt().iItemType != CItemFinder::ENoneSelected )
|
|
492 |
{
|
|
493 |
// Refreshes the item finder highlight if present highlighted
|
|
494 |
TRAP_IGNORE( itemFinder->ResolveAndSetItemTypeL() );
|
|
495 |
}
|
|
496 |
}
|
|
497 |
}
|
|
498 |
|
|
499 |
// ---------------------------------------------------------
|
|
500 |
// CMsgBodyControl::CountComponentControls
|
|
501 |
//
|
|
502 |
// Returns a number of controls.
|
|
503 |
// ---------------------------------------------------------
|
|
504 |
//
|
|
505 |
TInt CMsgBodyControl::CountComponentControls() const
|
|
506 |
{
|
|
507 |
CCoeControl* controls[] = { iEditor };
|
|
508 |
|
|
509 |
TInt count = 0;
|
|
510 |
for ( TUint ii = 0; ii < sizeof( controls ) / sizeof( CCoeControl* ); ii++ )
|
|
511 |
{
|
|
512 |
if ( controls[ii] )
|
|
513 |
{
|
|
514 |
count++;
|
|
515 |
}
|
|
516 |
}
|
|
517 |
|
|
518 |
return count;
|
|
519 |
}
|
|
520 |
|
|
521 |
// ---------------------------------------------------------
|
|
522 |
// CMsgBodyControl::ComponentControl
|
|
523 |
//
|
|
524 |
// Returns a control of index aIndex.
|
|
525 |
// ---------------------------------------------------------
|
|
526 |
//
|
|
527 |
CCoeControl* CMsgBodyControl::ComponentControl( TInt aIndex ) const
|
|
528 |
{
|
|
529 |
CCoeControl* controls[] = { iEditor };
|
|
530 |
|
|
531 |
for ( TUint ii = 0; ii < sizeof( controls ) / sizeof( CCoeControl* ); ii++ )
|
|
532 |
{
|
|
533 |
if ( controls[ii] && aIndex-- == 0 )
|
|
534 |
{
|
|
535 |
return controls[ii];
|
|
536 |
}
|
|
537 |
}
|
|
538 |
|
|
539 |
return NULL;
|
|
540 |
}
|
|
541 |
|
|
542 |
// ---------------------------------------------------------
|
|
543 |
// CMsgBodyControl::SizeChanged
|
|
544 |
//
|
|
545 |
// Sets position for the editor.
|
|
546 |
// ---------------------------------------------------------
|
|
547 |
//
|
|
548 |
void CMsgBodyControl::SizeChanged()
|
|
549 |
{
|
|
550 |
MEBLOGGER_ENTERFN("CMsgBodyControl::SizeChanged");
|
|
551 |
|
|
552 |
if ( iControlModeFlags & EMsgControlModeSizeChanging )
|
|
553 |
{
|
|
554 |
MEBLOGGER_WRITE("EMsgControlModeSizeChanging");
|
|
555 |
}
|
|
556 |
else
|
|
557 |
{
|
|
558 |
TPoint editorPosition( Position() );
|
|
559 |
editorPosition.iY += iEditorTop;
|
|
560 |
iEditor->SetExtent( editorPosition, iEditor->Size() );
|
|
561 |
|
|
562 |
AknsUtils::RegisterControlPosition( this );
|
|
563 |
AknsUtils::RegisterControlPosition( iEditor );
|
|
564 |
}
|
|
565 |
|
|
566 |
MEBLOGGER_LEAVEFN("CMsgBodyControl::SizeChanged");
|
|
567 |
}
|
|
568 |
|
|
569 |
// ---------------------------------------------------------
|
|
570 |
// CMsgBodyControl::FocusChanged
|
|
571 |
//
|
|
572 |
// This is called when the focus of the control is changed.
|
|
573 |
// ---------------------------------------------------------
|
|
574 |
//
|
|
575 |
void CMsgBodyControl::FocusChanged( TDrawNow aDrawNow )
|
|
576 |
{
|
|
577 |
// For automatic highlight
|
|
578 |
iEditor->SetFocus( IsFocused(), aDrawNow );
|
|
579 |
if ( aDrawNow == EDrawNow )
|
|
580 |
{
|
|
581 |
DrawDeferred();
|
|
582 |
}
|
|
583 |
}
|
|
584 |
|
|
585 |
// ---------------------------------------------------------
|
|
586 |
// CMsgBodyControl::SetContainerWindowL
|
|
587 |
//
|
|
588 |
// Sets container window.
|
|
589 |
// ---------------------------------------------------------
|
|
590 |
//
|
|
591 |
void CMsgBodyControl::SetContainerWindowL( const CCoeControl& aContainer )
|
|
592 |
{
|
|
593 |
CCoeControl::SetContainerWindowL( aContainer );
|
|
594 |
|
|
595 |
iEditor->SetContainerWindowL( aContainer );
|
|
596 |
}
|
|
597 |
|
|
598 |
// ---------------------------------------------------------
|
|
599 |
// CMsgBodyControl::CheckCorrectControlYPos
|
|
600 |
//
|
|
601 |
//
|
|
602 |
// ---------------------------------------------------------
|
|
603 |
//
|
|
604 |
void CMsgBodyControl::CheckCorrectControlYPosL()
|
|
605 |
{
|
|
606 |
// SJK 06.09.2004: Added "IsReadOnly" check. Fixing KHAI-5KLH8L.
|
|
607 |
if ( IsReadOnly() && iEditor->TextView() && IsFocused() )
|
|
608 |
{
|
|
609 |
TRect viewRect = iBaseControlObserver->ViewRect();
|
|
610 |
TInt delta = viewRect.iTl.iY - iEditor->Rect().iTl.iY;
|
|
611 |
iEditor->TextView()->FinishBackgroundFormattingL();
|
|
612 |
TInt msgBaseLineDelta( iLineHeight );
|
|
613 |
|
|
614 |
if ( delta % msgBaseLineDelta )
|
|
615 |
{
|
|
616 |
if ( delta < 0 )
|
|
617 |
{
|
|
618 |
delta = ( delta - delta % msgBaseLineDelta );
|
|
619 |
}
|
|
620 |
else
|
|
621 |
{
|
|
622 |
delta = ( delta - delta % msgBaseLineDelta ) + msgBaseLineDelta;
|
|
623 |
}
|
|
624 |
}
|
|
625 |
|
|
626 |
if ( ( ( delta < 0) &&
|
|
627 |
( iEditor->TextLayout()->FirstDocPosFullyInBand() != 0 ) )
|
|
628 |
|| ( delta > 0 ) )
|
|
629 |
{
|
|
630 |
// these three lines must be here in order to
|
|
631 |
// keep text filled with the view.
|
|
632 |
TViewYPosQualifier yPosQualifier;
|
|
633 |
yPosQualifier.SetFillScreen();
|
|
634 |
iEditor->TextView()->HandleGlobalChangeL( yPosQualifier );
|
|
635 |
|
|
636 |
iBaseControlObserver->HandleBaseControlEventRequestL(
|
|
637 |
this, EMsgScrollForm, delta );
|
|
638 |
}
|
|
639 |
}
|
|
640 |
}
|
|
641 |
|
|
642 |
// ---------------------------------------------------------
|
|
643 |
// CMsgBodyControl::ItemFinder
|
|
644 |
//
|
|
645 |
//
|
|
646 |
// ---------------------------------------------------------
|
|
647 |
//
|
|
648 |
CItemFinder* CMsgBodyControl::ItemFinder()
|
|
649 |
{
|
|
650 |
return IsReadOnly() ? iEditor->ItemFinder() :
|
|
651 |
NULL;
|
|
652 |
}
|
|
653 |
|
|
654 |
// ---------------------------------------------------------
|
|
655 |
// CMsgBodyControl::SetupAutomaticFindAfterFocusChangeL
|
|
656 |
//
|
|
657 |
//
|
|
658 |
// ---------------------------------------------------------
|
|
659 |
//
|
|
660 |
void CMsgBodyControl::SetupAutomaticFindAfterFocusChangeL( TBool aBeginning )
|
|
661 |
{
|
|
662 |
BodyControlEditor()->SetupAutomaticFindAfterFocusChangeL( aBeginning );
|
|
663 |
}
|
|
664 |
|
|
665 |
// ---------------------------------------------------------
|
|
666 |
// CMsgBodyControl::ResolveFontMetrics
|
|
667 |
//
|
|
668 |
//
|
|
669 |
// ---------------------------------------------------------
|
|
670 |
//
|
|
671 |
void CMsgBodyControl::ResolveFontMetrics()
|
|
672 |
{
|
|
673 |
TAknLayoutText textLayout;
|
|
674 |
TAknTextLineLayout textLineLayout;
|
|
675 |
|
|
676 |
TAknLayoutRect msgTextPane;
|
|
677 |
msgTextPane.LayoutRect( MsgEditorCommons::MsgDataPane(),
|
|
678 |
AknLayoutScalable_Apps::msg_text_pane( 0 ).LayoutLine() );
|
|
679 |
TAknLayoutRect msgBodyPane;
|
|
680 |
msgBodyPane.LayoutRect( msgTextPane.Rect(),
|
|
681 |
AknLayoutScalable_Apps::msg_body_pane().LayoutLine() );
|
|
682 |
|
|
683 |
if ( IsReadOnly() )
|
|
684 |
{
|
|
685 |
textLineLayout = AknLayoutScalable_Apps::msg_body_pane_t1( 0 ).LayoutLine();
|
|
686 |
}
|
|
687 |
else
|
|
688 |
{
|
|
689 |
textLineLayout = AknLayoutScalable_Apps::msg_body_pane_t1( 1 ).LayoutLine();
|
|
690 |
}
|
|
691 |
|
|
692 |
textLayout.LayoutText( msgBodyPane.Rect(),
|
|
693 |
textLineLayout );
|
|
694 |
|
|
695 |
iEditorTop = textLayout.TextRect().iTl.iY - msgBodyPane.Rect().iTl.iY;
|
|
696 |
|
|
697 |
// Set editor alignment
|
|
698 |
iEditor->SetAlignment( textLineLayout.iJ );
|
|
699 |
|
|
700 |
iEditor->SetMaximumHeight( MsgEditorCommons::MaxBodyHeight() - iEditorTop );
|
|
701 |
}
|
|
702 |
|
|
703 |
// ---------------------------------------------------------
|
|
704 |
// CMsgBodyControl::BodyControlEditor
|
|
705 |
// ---------------------------------------------------------
|
|
706 |
//
|
|
707 |
CMsgBodyControlEditor* CMsgBodyControl::BodyControlEditor() const
|
|
708 |
{
|
|
709 |
return static_cast<CMsgBodyControlEditor*>( iEditor );
|
|
710 |
}
|
|
711 |
|
|
712 |
// ---------------------------------------------------------
|
|
713 |
// CMsgBodyControl::GetCaptionForFep
|
|
714 |
// Returns the ICF Prompt text of Body control to FEP
|
|
715 |
// ---------------------------------------------------------
|
|
716 |
//
|
|
717 |
void CMsgBodyControl::GetCaptionForFep( TDes& aCaption ) const
|
|
718 |
{
|
|
719 |
const TInt maximumLength = aCaption.MaxLength();
|
|
720 |
|
|
721 |
if ( iCaptionText->Length() < maximumLength )
|
|
722 |
{
|
|
723 |
TPtr ptr = iCaptionText->Des();
|
|
724 |
aCaption.Copy( ptr );
|
|
725 |
}
|
|
726 |
}
|
|
727 |
// ---------------------------------------------------------
|
|
728 |
// CMsgBodyControl::SetIcfPromptTextL()
|
|
729 |
// Loads ICF Prompt text of Message Body control
|
|
730 |
// ---------------------------------------------------------
|
|
731 |
//
|
|
732 |
void CMsgBodyControl::SetIcfPromptTextL()
|
|
733 |
{
|
|
734 |
|
|
735 |
if(iCaptionText)
|
|
736 |
{
|
|
737 |
delete iCaptionText;
|
|
738 |
iCaptionText = NULL;
|
|
739 |
}
|
|
740 |
iCaptionText = StringLoader::LoadLC( R_QTN_MSG_ICF_PROMPT_TEXT_MESSAGE, iCoeEnv );
|
|
741 |
CleanupStack::Pop( iCaptionText );
|
|
742 |
|
|
743 |
}
|
|
744 |
|
|
745 |
// End of File
|