25
|
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: This file implements class CNcsEditor.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#include "emailtrace.h"
|
|
21 |
#include <avkon.hrh>
|
|
22 |
#include <aknenv.h> // CAknEnv
|
|
23 |
#include <txtrich.h>
|
|
24 |
#include <txtglobl.h>
|
|
25 |
#include <AknUtils.h> // AknLayoutUtils
|
|
26 |
#include <AknsConstants.h>
|
|
27 |
#include <AknsUtils.h>
|
|
28 |
#include <AknsSkinInstance.h>
|
|
29 |
#include <aknedsts.h>
|
|
30 |
#include <AknsBasicBackgroundControlContext.h>
|
|
31 |
#include <centralrepository.h>
|
|
32 |
|
|
33 |
#include "ncseditor.h"
|
|
34 |
#include "ncsutility.h"
|
|
35 |
#include "ncscustomdraw.h"
|
|
36 |
#include "ncseditorcustomdraw.h"
|
|
37 |
#include "freestyleemailcenrepkeys.h"
|
|
38 |
|
|
39 |
// ========================= MEMBER FUNCTIONS ==================================
|
|
40 |
|
|
41 |
// ---------------------------------------------------------------------------
|
|
42 |
// constructor
|
|
43 |
// ---------------------------------------------------------------------------
|
|
44 |
//
|
|
45 |
CNcsEditor::CNcsEditor( MNcsFieldSizeObserver* aSizeObserver,
|
|
46 |
TBool aHeaderField,
|
|
47 |
TNcsEditorUsage aEditorUsage,
|
|
48 |
const TDesC& aCaptionText ) :
|
|
49 |
MNcsControl( aSizeObserver ),
|
|
50 |
iPreviousFontHeight( -1 ),
|
|
51 |
iPreviousLineSpacingInTwips( -1 ),
|
|
52 |
// Platform layout change
|
|
53 |
iHeaderField( aHeaderField ),
|
|
54 |
iNcsFontType ( NcsUtility::ENcsHeaderDetailFont ),
|
|
55 |
iEditorUsage( aEditorUsage ),
|
|
56 |
iRealRect( 0, 0, 0, 0 ),
|
|
57 |
iCaptionText( aCaptionText.Alloc() )
|
|
58 |
{
|
|
59 |
FUNC_LOG;
|
|
60 |
}
|
|
61 |
|
|
62 |
// ---------------------------------------------------------------------------
|
|
63 |
// second phase constructor
|
|
64 |
// ---------------------------------------------------------------------------
|
|
65 |
//
|
|
66 |
void CNcsEditor::ConstructL( const CCoeControl* aParent,
|
|
67 |
TInt aNumberOfLines,
|
|
68 |
TInt aTextLimit )
|
|
69 |
{
|
|
70 |
FUNC_LOG;
|
|
71 |
CEikRichTextEditor::ConstructL( aParent, aNumberOfLines, aTextLimit,
|
|
72 |
CEikEdwin::EAvkonEditor | CEikEdwin::EResizable |
|
|
73 |
CEikEdwin::ENoAutoSelection | CEikEdwin::EInclusiveSizeFixed |
|
|
74 |
CEikEdwin::ENoHorizScrolling | CEikRichTextEditor::EPasteAsPlainText );
|
|
75 |
|
|
76 |
CRepository* repository = NULL;
|
|
77 |
TRAPD( err, repository = CRepository::NewL( KFreestyleEmailCenRep ) );
|
|
78 |
if ( !err )
|
|
79 |
{
|
|
80 |
TInt value( 0 );
|
|
81 |
err = repository->Get( KEmailFeatureSplitScreen, value );
|
|
82 |
if( !err && value )
|
|
83 |
{
|
|
84 |
SetAknEditorFlags( AknEditorFlags() | EAknEditorFlagEnablePartialScreen );
|
|
85 |
}
|
|
86 |
}
|
|
87 |
delete repository;
|
|
88 |
repository = NULL;
|
|
89 |
iGlobalCharFormat = CCharFormatLayer::NewL();
|
|
90 |
iGlobalCharFormat->SetBase( GlobalText()->GlobalCharFormatLayer() );
|
|
91 |
GlobalText()->SetGlobalCharFormat( iGlobalCharFormat );
|
|
92 |
}
|
|
93 |
|
|
94 |
// -----------------------------------------------------------------------------
|
|
95 |
// destructor
|
|
96 |
// -----------------------------------------------------------------------------
|
|
97 |
//
|
|
98 |
CNcsEditor::~CNcsEditor()
|
|
99 |
{
|
|
100 |
FUNC_LOG;
|
|
101 |
delete iGlobalCharFormat;
|
|
102 |
delete iEditorCustomDrawer;
|
|
103 |
delete iCaptionText;
|
|
104 |
}
|
|
105 |
|
|
106 |
// -----------------------------------------------------------------------------
|
|
107 |
// CNcsEditor::OpenVirtualKeyBoardL()
|
|
108 |
// -----------------------------------------------------------------------------
|
|
109 |
//
|
|
110 |
void CNcsEditor::OpenVirtualKeyBoardL()
|
|
111 |
{
|
|
112 |
FUNC_LOG;
|
|
113 |
MCoeFepAwareTextEditor_Extension1* fepAwareTextEditor(
|
|
114 |
InputCapabilities().FepAwareTextEditor()->Extension1() );
|
|
115 |
CAknEdwinState* state( NULL );
|
|
116 |
if ( fepAwareTextEditor )
|
|
117 |
{
|
|
118 |
state = static_cast<CAknEdwinState*>(
|
|
119 |
fepAwareTextEditor->State( KNullUid ) );
|
|
120 |
}
|
|
121 |
if (state)
|
|
122 |
{
|
|
123 |
state->ReportAknEdStateEventL(
|
|
124 |
MAknEdStateObserver::EAknActivatePenInputRequest );
|
|
125 |
}
|
|
126 |
}
|
|
127 |
|
|
128 |
// -----------------------------------------------------------------------------
|
|
129 |
// CNcsEditor::GetLineRectL() const
|
|
130 |
// -----------------------------------------------------------------------------
|
|
131 |
//
|
|
132 |
void CNcsEditor::GetLineRectL( TRect& aLineRect ) const
|
|
133 |
{
|
|
134 |
FUNC_LOG;
|
|
135 |
TPoint position;
|
|
136 |
iLayout->DocPosToXyPosL( CursorPos(), position );
|
|
137 |
iLayout->GetLineRect( position.iY, aLineRect );
|
|
138 |
}
|
|
139 |
|
|
140 |
// -----------------------------------------------------------------------------
|
|
141 |
// CNcsEditor::CursorLineNumber() const
|
|
142 |
// -----------------------------------------------------------------------------
|
|
143 |
//
|
|
144 |
TInt CNcsEditor::CursorLineNumber() const
|
|
145 |
{
|
|
146 |
FUNC_LOG;
|
|
147 |
TInt ret = iLayout->GetLineNumber( CursorPos() );
|
|
148 |
ret++;
|
|
149 |
return ret;
|
|
150 |
}
|
|
151 |
|
|
152 |
// -----------------------------------------------------------------------------
|
|
153 |
// CNcsEditor::CursorPosition() const
|
|
154 |
// -----------------------------------------------------------------------------
|
|
155 |
//
|
|
156 |
TInt CNcsEditor::CursorPosition() const
|
|
157 |
{
|
|
158 |
FUNC_LOG;
|
|
159 |
// Return the position of the cursor relative
|
|
160 |
// to the top of the control (in pixels)
|
|
161 |
TPoint position;
|
|
162 |
TInt cp = CursorPos();
|
|
163 |
TRAP_IGNORE( iLayout->DocPosToXyPosL( cp , position ) );
|
|
164 |
position.iY += iLayout->PixelsAboveBand();
|
|
165 |
return position.iY;
|
|
166 |
}
|
|
167 |
|
|
168 |
|
|
169 |
// -----------------------------------------------------------------------------
|
|
170 |
// CNcsEditor::OfferKeyEventL() const
|
|
171 |
// -----------------------------------------------------------------------------
|
|
172 |
//
|
|
173 |
TKeyResponse CNcsEditor::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
|
|
174 |
{
|
|
175 |
FUNC_LOG;
|
|
176 |
TKeyResponse ret( EKeyWasNotConsumed );
|
|
177 |
if( aKeyEvent.iCode == EKeyDelete && CursorPos() == TextLength() )
|
|
178 |
{
|
|
179 |
ClearSelectionL();
|
|
180 |
return EKeyWasConsumed;
|
|
181 |
}
|
|
182 |
else
|
|
183 |
{
|
|
184 |
ret = CEikRichTextEditor::OfferKeyEventL( aKeyEvent, aType );
|
|
185 |
}
|
|
186 |
|
|
187 |
return ret;
|
|
188 |
}
|
|
189 |
|
|
190 |
// -----------------------------------------------------------------------------
|
|
191 |
// CNcsEditor::SetTextL
|
|
192 |
// -----------------------------------------------------------------------------
|
|
193 |
//
|
|
194 |
void CNcsEditor::SetTextL( const TDesC* aDes )
|
|
195 |
{
|
|
196 |
FUNC_LOG;
|
|
197 |
CEikEdwin::SetTextL( aDes );
|
|
198 |
if ( ( *aDes ).Compare( KNullDesC ) == 0 )
|
|
199 |
{
|
|
200 |
// when text is emptied, set text color again
|
|
201 |
SetTextColorL( iTextColor );
|
|
202 |
UpdateFontSize();
|
|
203 |
}
|
|
204 |
}
|
|
205 |
|
|
206 |
// -----------------------------------------------------------------------------
|
|
207 |
// CNcsEditor::HandleResourceChange
|
|
208 |
// -----------------------------------------------------------------------------
|
|
209 |
//
|
|
210 |
void CNcsEditor::HandleResourceChange( TInt aType )
|
|
211 |
{
|
|
212 |
FUNC_LOG;
|
|
213 |
CEikRichTextEditor::HandleResourceChange( aType );
|
|
214 |
|
|
215 |
if ( aType == KAknsMessageSkinChange )
|
|
216 |
{
|
|
217 |
UpdateFontSize();
|
|
218 |
UpdateColors();
|
|
219 |
if ( iCustomDrawer )
|
|
220 |
{
|
|
221 |
iCustomDrawer->UpdateColors();
|
|
222 |
}
|
|
223 |
}
|
|
224 |
else if ( aType == KEikMessageColorSchemeChange )
|
|
225 |
{
|
|
226 |
UpdateFontSize();
|
|
227 |
UpdateColors();
|
|
228 |
if ( iCustomDrawer )
|
|
229 |
{
|
|
230 |
iCustomDrawer->UpdateColors();
|
|
231 |
}
|
|
232 |
}
|
|
233 |
else if ( aType == KEikMessageZoomChange )
|
|
234 |
{
|
|
235 |
UpdateFontSize();
|
|
236 |
}
|
|
237 |
|
|
238 |
if ( iEditorCustomDrawer )
|
|
239 |
{
|
|
240 |
iEditorCustomDrawer->UpdateLayout( GetLayout() );
|
|
241 |
}
|
|
242 |
}
|
|
243 |
|
|
244 |
//<cmail> Platform layout change
|
|
245 |
// -----------------------------------------------------------------------------
|
|
246 |
// CNcsEditor::CreateCustomDrawL
|
|
247 |
// -----------------------------------------------------------------------------
|
|
248 |
//
|
|
249 |
/*
|
|
250 |
CLafEdwinCustomDrawBase* CNcsEditor::CreateCustomDrawL()
|
|
251 |
{
|
|
252 |
CLafEdwinCustomDrawBase* drawer = CEikEdwin::CreateCustomDrawL();
|
|
253 |
iCustomDrawer = new ( ELeave ) CNcsCustomDraw(
|
|
254 |
static_cast<CEikonEnv*>( ControlEnv() )->LafEnv(),
|
|
255 |
*this,
|
|
256 |
drawer,
|
|
257 |
this,
|
|
258 |
iHeaderField );
|
|
259 |
iCustomDrawer->UpdateColors();
|
|
260 |
return iCustomDrawer;
|
|
261 |
}
|
|
262 |
*/
|
|
263 |
// </cmail>
|
|
264 |
|
|
265 |
// -----------------------------------------------------------------------------
|
|
266 |
// CNcsEditor::SetupEditorL()
|
|
267 |
// -----------------------------------------------------------------------------
|
|
268 |
//
|
|
269 |
void CNcsEditor::SetupEditorL()
|
|
270 |
{
|
|
271 |
FUNC_LOG;
|
|
272 |
// <cmail> Added text view creation.
|
|
273 |
// In S60 5.0 we end up here before this control is "activated". Normally
|
|
274 |
// text view is created in CEikGlobalTextEditor::ActivateL
|
|
275 |
// Find out why this problem doesn't exist in Freestyle/S60 3.2.3.
|
|
276 |
if ( !iTextView )
|
|
277 |
{
|
|
278 |
CreateTextViewL();
|
|
279 |
}
|
|
280 |
// </cmail>
|
|
281 |
|
|
282 |
// <cmail> Platform layout change
|
|
283 |
//TextLayout()->RestrictScrollToTopsOfLines( EFalse );
|
|
284 |
// </cmail>
|
|
285 |
|
|
286 |
// Set the cursor position to initialize the edit control
|
|
287 |
SetCursorPosL(0,EFalse);
|
|
288 |
UpdateFontSize();
|
|
289 |
UpdateColors();
|
|
290 |
}
|
|
291 |
|
|
292 |
// -----------------------------------------------------------------------------
|
|
293 |
// CNcsEditor::LineCount() const
|
|
294 |
// -----------------------------------------------------------------------------
|
|
295 |
//
|
|
296 |
TInt CNcsEditor::LineCount() const
|
|
297 |
{
|
|
298 |
FUNC_LOG;
|
|
299 |
TInt lineCount = iLayout->GetLineNumber( TextLength() );
|
|
300 |
lineCount++;
|
|
301 |
return lineCount;
|
|
302 |
}
|
|
303 |
|
|
304 |
TInt CNcsEditor::ScrollableLines() const
|
|
305 |
{
|
|
306 |
FUNC_LOG;
|
|
307 |
TRect lineRect;
|
|
308 |
// First get the rect for one line
|
|
309 |
iLayout->GetLineRect(0, lineRect);
|
|
310 |
TRect rect = Rect();
|
|
311 |
TInt lines = rect.Height()/lineRect.Height();
|
|
312 |
return lines;
|
|
313 |
}
|
|
314 |
|
|
315 |
// -----------------------------------------------------------------------------
|
|
316 |
// CNcsEditor::PositionChanged() const
|
|
317 |
// -----------------------------------------------------------------------------
|
|
318 |
//
|
|
319 |
void CNcsEditor::PositionChanged()
|
|
320 |
{
|
|
321 |
FUNC_LOG;
|
|
322 |
if( iTextView )
|
|
323 |
{
|
|
324 |
TRect displayRect=iBorder.InnerRect(Rect());
|
|
325 |
displayRect=iMargins.InnerRect(displayRect);
|
|
326 |
iTextView->SetViewRect(displayRect);
|
|
327 |
}
|
|
328 |
}
|
|
329 |
|
|
330 |
// -----------------------------------------------------------------------------
|
|
331 |
// CNcsEditor::TextHeight() const
|
|
332 |
// -----------------------------------------------------------------------------
|
|
333 |
//
|
|
334 |
TInt CNcsEditor::TextHeight() const
|
|
335 |
{
|
|
336 |
FUNC_LOG;
|
|
337 |
return iLayout->FormattedHeightInPixels();
|
|
338 |
}
|
|
339 |
|
|
340 |
#ifdef _DEBUG
|
|
341 |
// Is is meant for debugging.
|
|
342 |
// Break here to see what the values are.
|
|
343 |
void CNcsEditor::DebugDump()
|
|
344 |
{
|
|
345 |
FUNC_LOG;
|
|
346 |
TInt bandHeight = iLayout->BandHeight();
|
|
347 |
TInt firstDocPosFullyInBad = iLayout->FirstDocPosFullyInBand();
|
|
348 |
TInt firstLineInBand = iLayout->FirstLineInBand();
|
|
349 |
TInt pixelsAboveBand = iLayout->PixelsAboveBand();
|
|
350 |
}
|
|
351 |
#endif
|
|
352 |
|
|
353 |
// -----------------------------------------------------------------------------
|
|
354 |
// CNcsEditor::SetTextColorL()
|
|
355 |
// -----------------------------------------------------------------------------
|
|
356 |
//
|
|
357 |
void CNcsEditor::SetTextColorL( TLogicalRgb aColor )
|
|
358 |
{
|
|
359 |
FUNC_LOG;
|
|
360 |
TCharFormat charFormat;
|
|
361 |
charFormat.iFontPresentation.iTextColor = aColor;
|
|
362 |
TCharFormatMask charFormatMask;
|
|
363 |
charFormatMask.SetAttrib( EAttColor );
|
|
364 |
iGlobalCharFormat->SetL( charFormat, charFormatMask );
|
|
365 |
GlobalText()->SetGlobalCharFormat( iGlobalCharFormat );
|
|
366 |
NotifyNewFormatL();
|
|
367 |
}
|
|
368 |
|
|
369 |
TBool CNcsEditor::HasSemicolonAtTheEndL() const
|
|
370 |
{
|
|
371 |
HBufC* text = GetTextInHBufL();
|
|
372 |
|
|
373 |
TBool result(EFalse);
|
|
374 |
if ( text && text->Right(1).Compare(_L(";") ) == 0 )
|
|
375 |
{
|
|
376 |
result = ETrue;
|
|
377 |
}
|
|
378 |
delete text;
|
|
379 |
text = NULL;
|
|
380 |
|
|
381 |
return result;
|
|
382 |
}
|
|
383 |
|
|
384 |
// -----------------------------------------------------------------------------
|
|
385 |
// CNcsEditor::TrimmedTextLength()
|
|
386 |
// -----------------------------------------------------------------------------
|
|
387 |
//
|
|
388 |
TInt CNcsEditor::TrimmedTextLength()
|
|
389 |
{
|
|
390 |
FUNC_LOG;
|
|
391 |
HBufC* text = NULL;
|
|
392 |
TRAP_IGNORE( text = GetTextInHBufL() );
|
|
393 |
TInt length = 0;
|
|
394 |
if ( text )
|
|
395 |
{
|
|
396 |
text->Des().TrimAll();
|
|
397 |
length = text->Des().Length();
|
|
398 |
delete text;
|
|
399 |
}
|
|
400 |
return length;
|
|
401 |
}
|
|
402 |
|
|
403 |
// -----------------------------------------------------------------------------
|
|
404 |
// CNcsEditor::EditObserver()
|
|
405 |
// -----------------------------------------------------------------------------
|
|
406 |
//
|
|
407 |
void CNcsEditor::EditObserver( TInt aStart, TInt aExtent )
|
|
408 |
{
|
|
409 |
FUNC_LOG;
|
|
410 |
CEikRichTextEditor::EditObserver( aStart, aExtent );
|
|
411 |
}
|
|
412 |
|
|
413 |
// -----------------------------------------------------------------------------
|
|
414 |
// CNcsEditor::UpdateColors
|
|
415 |
// -----------------------------------------------------------------------------
|
|
416 |
//
|
|
417 |
void CNcsEditor::UpdateColors()
|
|
418 |
{
|
|
419 |
FUNC_LOG;
|
|
420 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
|
|
421 |
// <cmail> S60 Skin support
|
|
422 |
const TInt error( AknsUtils::GetCachedColor( skin, iTextColor,
|
|
423 |
KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 ) );
|
|
424 |
if ( error )
|
|
425 |
{
|
|
426 |
iTextColor = KRgbBlack;
|
|
427 |
}
|
|
428 |
|
|
429 |
// </cmail>
|
|
430 |
TRAP_IGNORE( SetTextColorL( iTextColor ) );
|
|
431 |
}
|
|
432 |
|
|
433 |
// <cmail>
|
|
434 |
// -----------------------------------------------------------------------------
|
|
435 |
// CNcsEditor::SetNcsFontType
|
|
436 |
// -----------------------------------------------------------------------------
|
|
437 |
//
|
|
438 |
void CNcsEditor::SetNcsFontType( NcsUtility::TNcsLayoutFont aFontType )
|
|
439 |
{
|
|
440 |
FUNC_LOG;
|
|
441 |
iNcsFontType = aFontType;
|
|
442 |
}
|
|
443 |
|
|
444 |
// -----------------------------------------------------------------------------
|
|
445 |
// CNcsEditor::UpdateFontSize
|
|
446 |
// -----------------------------------------------------------------------------
|
|
447 |
//
|
|
448 |
void CNcsEditor::UpdateFontSize()
|
|
449 |
{
|
|
450 |
FUNC_LOG;
|
|
451 |
/*TCharFormat charFormat;
|
|
452 |
TCharFormatMask charFormatMask;
|
|
453 |
|
|
454 |
TNcsMeasures m = NcsUtility::Measures();
|
|
455 |
|
|
456 |
// <cmail>
|
|
457 |
CFont* editorFont = NULL;
|
|
458 |
|
|
459 |
TRAPD( err, editorFont = NcsUtility::GetNearestFontL(
|
|
460 |
EAknLogicalFontPrimarySmallFont,
|
|
461 |
m.iEditorFontHeightPx)
|
|
462 |
);
|
|
463 |
|
|
464 |
if( err == KErrNone )
|
|
465 |
{
|
|
466 |
*/
|
|
467 |
|
|
468 |
TRAP_IGNORE( UpdateFontL() );
|
|
469 |
// CEikonEnv::Static()->ScreenDevice()->ReleaseFont( editorFont );
|
|
470 |
// }
|
|
471 |
}
|
|
472 |
|
|
473 |
// -----------------------------------------------------------------------------
|
|
474 |
// CNcsEditor::UpdateFontL
|
|
475 |
// -----------------------------------------------------------------------------
|
|
476 |
//
|
|
477 |
void CNcsEditor::UpdateFontL()
|
|
478 |
{
|
|
479 |
FUNC_LOG;
|
|
480 |
TCharFormat charFormat;
|
|
481 |
TCharFormatMask charFormatMask;
|
|
482 |
charFormat.iFontSpec = NcsUtility::GetLayoutFont( Rect(), iNcsFontType )->FontSpecInTwips();
|
|
483 |
charFormat.iFontPresentation.iTextColor = iTextColor;
|
|
484 |
charFormatMask.SetAttrib(EAttColor);
|
|
485 |
charFormatMask.SetAttrib(EAttFontTypeface);
|
|
486 |
charFormatMask.SetAttrib(EAttFontHeight);
|
|
487 |
iGlobalCharFormat->SetL(charFormat, charFormatMask);
|
|
488 |
GlobalText()->SetGlobalCharFormat( iGlobalCharFormat );
|
|
489 |
}
|
|
490 |
|
|
491 |
// ---------------------------------------------------------------------------
|
|
492 |
// CNcsEditor::GetLabelText
|
|
493 |
// ---------------------------------------------------------------------------
|
|
494 |
//
|
|
495 |
const TDesC& CNcsEditor::GetLabelText() const
|
|
496 |
{
|
|
497 |
return KNullDesC;
|
|
498 |
}
|
|
499 |
|
|
500 |
// <cmail> Platform layout change
|
|
501 |
// ---------------------------------------------------------------------------
|
|
502 |
// CNcsEditor::LayoutLineCount
|
|
503 |
// ---------------------------------------------------------------------------
|
|
504 |
//
|
|
505 |
TInt CNcsEditor::LayoutLineCount() const
|
|
506 |
{
|
|
507 |
return IsVisible() ? LineCount() : 0;
|
|
508 |
}
|
|
509 |
// </cmail> Platform layout change
|
|
510 |
|
|
511 |
// ---------------------------------------------------------------------------
|
|
512 |
// CNcsEditor::GetNumChars
|
|
513 |
// ---------------------------------------------------------------------------
|
|
514 |
//
|
|
515 |
TInt CNcsEditor::GetNumChars() const
|
|
516 |
{
|
|
517 |
FUNC_LOG;
|
|
518 |
TInt cnt = iLayout->DocumentLength();
|
|
519 |
return cnt;
|
|
520 |
}
|
|
521 |
|
|
522 |
TInt CNcsEditor::GetLineHeightL() const
|
|
523 |
{
|
|
524 |
FUNC_LOG;
|
|
525 |
TPoint pos;
|
|
526 |
TRect rect;
|
|
527 |
iLayout->DocPosToXyPosL(0, pos);
|
|
528 |
iLayout->GetLineRect(pos.iY,rect);
|
|
529 |
return rect.Height();
|
|
530 |
}
|
|
531 |
|
|
532 |
TInt CNcsEditor::DocumentLength() const
|
|
533 |
{
|
|
534 |
FUNC_LOG;
|
|
535 |
return iLayout->DocumentLength();
|
|
536 |
}
|
|
537 |
|
|
538 |
TInt CNcsEditor::PixelsAboveBand() const
|
|
539 |
{
|
|
540 |
FUNC_LOG;
|
|
541 |
return iLayout->PixelsAboveBand();
|
|
542 |
}
|
|
543 |
|
|
544 |
TInt CNcsEditor::ChangeBandTopL(TInt aPixels)
|
|
545 |
{
|
|
546 |
FUNC_LOG;
|
|
547 |
TInt px = aPixels;
|
|
548 |
return iLayout->ChangeBandTopL(px);
|
|
549 |
}
|
|
550 |
|
|
551 |
void CNcsEditor::ActivateL()
|
|
552 |
{
|
|
553 |
if ( IsActivated() )
|
|
554 |
{
|
|
555 |
return;
|
|
556 |
}
|
|
557 |
|
|
558 |
CEikRichTextEditor::ActivateL();
|
|
559 |
|
|
560 |
if ( !iEditorCustomDrawer && iEditorUsage != ENcsEditorDefault )
|
|
561 |
{
|
|
562 |
TAknTextComponentLayout layout;
|
|
563 |
if ( iEditorUsage == ENcsEditorBody )
|
|
564 |
{
|
|
565 |
layout = AknLayoutScalable_Apps::list_cmail_body_pane_t1();
|
|
566 |
}
|
|
567 |
else if ( iEditorUsage == ENcsEditorAddress ||
|
|
568 |
iEditorUsage == ENcsEditorSubject )
|
|
569 |
{
|
|
570 |
layout = AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t1( KHeaderDetailTextPaneVariety );
|
|
571 |
}
|
|
572 |
|
|
573 |
// Swap the custom drawer to our own to show text lines.
|
|
574 |
const MFormCustomDraw* customDraw = TextLayout()->CustomDraw();
|
|
575 |
|
|
576 |
iEditorCustomDrawer = CNcsEditorCustomDraw::NewL( customDraw, this, GetLayout() );
|
|
577 |
|
|
578 |
TextLayout()->SetCustomDraw( iEditorCustomDrawer );
|
|
579 |
}
|
|
580 |
}
|
|
581 |
|
|
582 |
//<cmail>
|
|
583 |
void CNcsEditor::SetRealRect( TRect aRect )
|
|
584 |
{
|
|
585 |
iRealRect = aRect;
|
|
586 |
}
|
|
587 |
|
|
588 |
void CNcsEditor::Draw( const TRect& /*aRect*/ ) const
|
|
589 |
{
|
|
590 |
if ( iTextView )
|
|
591 |
{
|
|
592 |
CWindowGc& gc=SystemGc();
|
|
593 |
TRect viewRect( iTextView->ViewRect() );
|
|
594 |
if( iRealRect.Height() > 0 )
|
|
595 |
{
|
|
596 |
if( !( viewRect.iTl.iY > iRealRect.iBr.iY || viewRect.iBr.iY < iRealRect.iTl.iY ) )
|
|
597 |
{
|
|
598 |
TrappedDraw( iRealRect );
|
|
599 |
}
|
|
600 |
}
|
|
601 |
else
|
|
602 |
{
|
|
603 |
TrappedDraw( viewRect );
|
|
604 |
}
|
|
605 |
|
|
606 |
|
|
607 |
#ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
|
|
608 |
// Workaround for clipping rect problem in multiline queries with text
|
|
609 |
// entries. Because of differences between CRemoteGc and CWindowGc,
|
|
610 |
// parts of the query wouldn't be drawn by CRemoteGc. The Reset() call
|
|
611 |
// is to cancel the clipping rect. For some reason, CancelClippingRect()
|
|
612 |
// and CancelClippingRegion() don't work.
|
|
613 |
gc.Reset();
|
|
614 |
#endif
|
|
615 |
}
|
|
616 |
}
|
|
617 |
|
|
618 |
void CNcsEditor::FormatAllTextNowL()
|
|
619 |
{
|
|
620 |
iLayout->SetAmountToFormat(CTextLayout::EFFormatAllText);
|
|
621 |
iTextView->FormatTextL();
|
|
622 |
}
|
|
623 |
//</cmail>
|
|
624 |
|
|
625 |
TAknTextComponentLayout CNcsEditor::GetLayout()
|
|
626 |
{
|
|
627 |
TAknTextComponentLayout layout;
|
|
628 |
|
|
629 |
if ( iEditorUsage == ENcsEditorBody )
|
|
630 |
{
|
|
631 |
layout = AknLayoutScalable_Apps::list_cmail_body_pane_t1();
|
|
632 |
}
|
|
633 |
else if ( iEditorUsage == ENcsEditorAddress ||
|
|
634 |
iEditorUsage == ENcsEditorSubject )
|
|
635 |
{
|
|
636 |
layout = AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t1( KHeaderDetailTextPaneVariety );
|
|
637 |
}
|
|
638 |
|
|
639 |
return layout;
|
|
640 |
}
|
|
641 |
|
|
642 |
|
|
643 |
void CNcsEditor::UpdateCustomDrawer()
|
|
644 |
{
|
|
645 |
if ( iEditorCustomDrawer )
|
|
646 |
{
|
|
647 |
iEditorCustomDrawer->UpdateLayout( GetLayout() );
|
|
648 |
}
|
|
649 |
}
|
|
650 |
|
|
651 |
void CNcsEditor::GetCaptionForFep(TDes& aCaption) const
|
|
652 |
{
|
|
653 |
const TInt maximumLength = aCaption.MaxLength();
|
|
654 |
if ( iCaptionText && (iCaptionText->Length() < maximumLength) )
|
|
655 |
{
|
|
656 |
TPtr ptr = iCaptionText->Des();
|
|
657 |
aCaption.Copy( ptr );
|
|
658 |
}
|
|
659 |
}
|
|
660 |
|
|
661 |
TCoeInputCapabilities CNcsEditor::InputCapabilities() const
|
|
662 |
{
|
|
663 |
TCoeInputCapabilities caps = CEikEdwin::InputCapabilities();
|
|
664 |
TCoeInputCapabilities caps2 = TCoeInputCapabilities(TCoeInputCapabilities::ENone, NULL, const_cast<CNcsEditor*>(this));
|
|
665 |
caps.MergeWith(caps2);
|
|
666 |
return caps;
|
|
667 |
}
|
|
668 |
|
|
669 |
|
|
670 |
void CNcsEditor::SetPhysicsEmulationOngoing( TBool aPhysOngoing )
|
|
671 |
{
|
|
672 |
iPhysOngoing = aPhysOngoing;
|
|
673 |
this->SetCursorVisible( !aPhysOngoing );
|
|
674 |
}
|
|
675 |
|
|
676 |
TBool CNcsEditor::IsPhysicsEmulationOngoing() const
|
|
677 |
{
|
|
678 |
return iPhysOngoing;
|
|
679 |
}
|