1 /* |
1 /* |
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
13 * |
13 * |
14 * Description: ESMR editor impl. |
14 * Description: ESMR editor impl. |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 #include "cesmreditor.h" |
19 #include "emailtrace.h" |
19 #include "nmrcolormanager.h" |
|
20 #include "esmrfieldbuilderdef.h" |
|
21 #include "esmrdef.h" |
|
22 #include "mesmrlistobserver.h" |
|
23 |
20 #include <txtfrmat.h> |
24 #include <txtfrmat.h> |
21 #include <txtglobl.h> |
25 #include <txtglobl.h> |
22 #include <txtrich.h> |
26 #include <txtrich.h> |
23 #include <gulfont.h> |
27 #include <gulfont.h> |
24 #include <eikenv.h> |
28 #include <eikenv.h> |
25 #include <avkon.hrh> |
29 #include <avkon.hrh> |
26 |
30 |
27 #include "cesmreditor.h" |
31 |
28 #include "cesmrlayoutmgr.h" |
32 #include "emailtrace.h" |
29 #include "esmrfieldbuilderdef.h" |
|
30 |
33 |
31 // ======== MEMBER FUNCTIONS ======== |
34 // ======== MEMBER FUNCTIONS ======== |
32 |
35 |
33 // --------------------------------------------------------------------------- |
36 // --------------------------------------------------------------------------- |
34 // CESMREditor::NewL |
37 // CESMREditor::NewL |
123 TInt listHeight = iObserver->ListHeight(); |
126 TInt listHeight = iObserver->ListHeight(); |
124 |
127 |
125 // edwinTlY negative |
128 // edwinTlY negative |
126 if ( cursorLowerPosition > ( listHeight - edwinTlY )) |
129 if ( cursorLowerPosition > ( listHeight - edwinTlY )) |
127 { |
130 { |
128 iObserver->MoveListAreaUpL(RowHeight()); |
131 iObserver->RePositionFields( -RowHeight() ); |
129 } |
132 } |
130 } |
133 } |
131 else if ( aKeyEvent.iCode == EKeyUpArrow && iObserver) |
134 else if ( aKeyEvent.iCode == EKeyUpArrow && iObserver) |
132 { |
135 { |
133 TPoint firstRowExtra(0,RowHeight()); |
136 TPoint firstRowExtra(0,RowHeight()); |
138 // upper corner of field not visible |
141 // upper corner of field not visible |
139 if ( hiddenHeight < 0 ) |
142 if ( hiddenHeight < 0 ) |
140 { |
143 { |
141 if ( (cursorPos.iY - firstRowExtra.iY * 2) < (-hiddenHeight)) |
144 if ( (cursorPos.iY - firstRowExtra.iY * 2) < (-hiddenHeight)) |
142 { |
145 { |
143 iObserver->MoveListAreaDownL(RowHeight()); |
146 iObserver->RePositionFields( RowHeight() ); |
144 } |
147 } |
145 } |
148 } |
146 } |
149 } |
147 } |
150 } |
148 |
151 |
149 |
152 |
150 return ret; |
153 return ret; |
151 } |
154 } |
152 |
155 |
153 // --------------------------------------------------------------------------- |
156 // --------------------------------------------------------------------------- |
154 // CESMREditor::ClearSelectionAndSetTextL |
157 // CESMREditor::FocusChanged |
155 // --------------------------------------------------------------------------- |
158 // --------------------------------------------------------------------------- |
156 // |
159 // |
157 EXPORT_C void CESMREditor::FocusChanged(TDrawNow aDrawNow) |
160 EXPORT_C void CESMREditor::FocusChanged(TDrawNow aDrawNow) |
158 { |
161 { |
159 FUNC_LOG; |
162 FUNC_LOG; |
|
163 |
160 CEikRichTextEditor::FocusChanged( aDrawNow ); |
164 CEikRichTextEditor::FocusChanged( aDrawNow ); |
|
165 |
161 TRAPD( error, TryToSetSelectionL() ); |
166 TRAPD( error, TryToSetSelectionL() ); |
162 if ( error != KErrNone ) |
167 if ( error != KErrNone ) |
163 { |
168 { |
164 CEikonEnv::Static()->HandleError( error );// codescanner::eikonenvstatic |
169 iCoeEnv->HandleError( error );// codescanner::eikonenvstatic |
|
170 } |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------------------------- |
|
174 // CESMREditor::HandlePointerEventL |
|
175 // --------------------------------------------------------------------------- |
|
176 // |
|
177 |
|
178 void CESMREditor::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
179 { |
|
180 if ( Rect().Contains( aPointerEvent.iPosition ) ) |
|
181 { |
|
182 switch ( aPointerEvent.iType ) |
|
183 { |
|
184 case TPointerEvent::EButton1Down: |
|
185 case TPointerEvent::EButton1Up: |
|
186 { |
|
187 CEikRichTextEditor::HandlePointerEventL( aPointerEvent ); |
|
188 break; |
|
189 } |
|
190 default: |
|
191 break; |
|
192 } |
165 } |
193 } |
166 } |
194 } |
167 |
195 |
168 // --------------------------------------------------------------------------- |
196 // --------------------------------------------------------------------------- |
169 // CESMREditor::TryToSetSelectionL |
197 // CESMREditor::TryToSetSelectionL |
194 // |
222 // |
195 EXPORT_C void CESMREditor::HandleEdwinEventL( |
223 EXPORT_C void CESMREditor::HandleEdwinEventL( |
196 CEikEdwin* aEdwin,TEdwinEvent aEventType ) |
224 CEikEdwin* aEdwin,TEdwinEvent aEventType ) |
197 { |
225 { |
198 FUNC_LOG; |
226 FUNC_LOG; |
199 if ( aEdwin == this && aEventType == EEventNavigation && iObserver) |
227 if ( aEdwin == this ) |
200 { |
228 { |
201 TInt curPos = CursorPos (); |
229 switch( aEventType ) |
202 TInt textLength = TextLength(); |
230 { |
203 // Update viewarea scrolling in cases where the cursor location |
231 case EEventNavigation: |
204 // is changed directly from bottom to upmost position or vise versa. |
232 { |
205 if ( CursorPos () == TextLength() ) |
233 if ( iObserver ) |
206 { |
234 { |
207 // KErrNotFound as field id is interpret as focused field: |
235 TInt curPos = CursorPos (); |
208 iObserver->ScrollItemVisible( KErrNotFound ); |
236 TInt textLength = TextLength(); |
209 } |
237 // Update viewarea scrolling in cases where the cursor location |
210 if ( CursorPos () == 0 ) |
238 // is changed directly from bottom to upmost position or vise versa. |
211 { |
239 if ( CursorPos () == TextLength() || CursorPos () == 0 ) |
212 // KErrNotFound as field id is interpret as focused field: |
240 { |
213 iObserver->ScrollItemVisible( KErrNotFound ); |
241 // KErrNotFound as field id is interpret as focused field: |
214 } |
242 iObserver->ScrollControlVisible( KErrNotFound ); |
|
243 } |
|
244 } |
|
245 break; |
|
246 } |
|
247 |
|
248 case EEventTextUpdate: |
|
249 { |
|
250 if ( IsVisible() ) |
|
251 { |
|
252 DrawDeferred(); |
|
253 } |
|
254 break; |
|
255 } |
|
256 |
|
257 default: |
|
258 { |
|
259 break; |
|
260 } |
|
261 } |
215 } |
262 } |
216 } |
263 } |
217 |
264 |
218 // --------------------------------------------------------------------------- |
265 // --------------------------------------------------------------------------- |
219 // CESMREditor::ClearSelectionAndSetTextL |
266 // CESMREditor::ClearSelectionAndSetTextL |
231 |
278 |
232 // --------------------------------------------------------------------------- |
279 // --------------------------------------------------------------------------- |
233 // CESMREditor::SetFontL |
280 // CESMREditor::SetFontL |
234 // --------------------------------------------------------------------------- |
281 // --------------------------------------------------------------------------- |
235 // |
282 // |
236 EXPORT_C void CESMREditor::SetFontL( |
283 EXPORT_C void CESMREditor::SetFontL( const CFont* aFont ) |
237 const CFont* aFont, CESMRLayoutManager* aLayout ) |
|
238 { |
284 { |
239 FUNC_LOG; |
285 FUNC_LOG; |
240 const CFont* font = aFont; |
286 const CFont* font = aFont; |
241 TFontSpec fontSpec = font->FontSpecInTwips(); |
287 TFontSpec fontSpec = font->FontSpecInTwips(); |
242 |
288 |
254 |
300 |
255 formatMask.SetAttrib( EAttFontTypeface ); |
301 formatMask.SetAttrib( EAttFontTypeface ); |
256 formatMask.SetAttrib( EAttFontHeight ); |
302 formatMask.SetAttrib( EAttFontHeight ); |
257 formatMask.SetAttrib( EAttFontPosture ); |
303 formatMask.SetAttrib( EAttFontPosture ); |
258 formatMask.SetAttrib( EAttFontStrokeWeight ); |
304 formatMask.SetAttrib( EAttFontStrokeWeight ); |
259 |
305 formatMask.SetAttrib(EAttFontHighlightColor); |
260 charFormat.iFontPresentation.iTextColor = aLayout->NormalTextColor(); |
|
261 formatMask.SetAttrib( EAttColor ); |
306 formatMask.SetAttrib( EAttColor ); |
|
307 |
|
308 charFormat.iFontPresentation.iTextColor = |
|
309 NMRColorManager::Color( NMRColorManager::EMRMainAreaTextColor ); |
|
310 |
|
311 charFormat.iFontPresentation.iHighlightColor = |
|
312 NMRColorManager::Color( NMRColorManager::EMRCutCopyPasteHighlightColor ); |
262 |
313 |
263 CParaFormatLayer* paraFormatLayer = |
314 CParaFormatLayer* paraFormatLayer = |
264 CParaFormatLayer::NewL( paraFormat, paraFormatMask ); |
315 CParaFormatLayer::NewL( paraFormat, paraFormatMask ); |
265 CleanupStack::PushL( paraFormatLayer ); |
316 CleanupStack::PushL( paraFormatLayer ); |
266 CCharFormatLayer* charFormatLayer = |
317 CCharFormatLayer* charFormatLayer = |
293 // --------------------------------------------------------------------------- |
344 // --------------------------------------------------------------------------- |
294 // |
345 // |
295 EXPORT_C TInt CESMREditor::LineCount( ) const |
346 EXPORT_C TInt CESMREditor::LineCount( ) const |
296 { |
347 { |
297 FUNC_LOG; |
348 FUNC_LOG; |
298 return TextLayout()->GetLineNumber ( TextLength ( ) ); |
349 // first line is zero, that's why + 1 is added |
|
350 TInt lineCount( TextLayout()->GetLineNumber ( TextLength ( ) ) + 1 ); |
|
351 return lineCount; |
299 } |
352 } |
300 |
353 |
301 // --------------------------------------------------------------------------- |
354 // --------------------------------------------------------------------------- |
302 // CESMREditor::RowHeight |
355 // CESMREditor::RowHeight |
303 // --------------------------------------------------------------------------- |
356 // --------------------------------------------------------------------------- |
350 FUNC_LOG; |
403 FUNC_LOG; |
351 return *iDefaultText; |
404 return *iDefaultText; |
352 } |
405 } |
353 |
406 |
354 // --------------------------------------------------------------------------- |
407 // --------------------------------------------------------------------------- |
355 // CESMREditor::LineCount |
408 // CESMREditor::SetListObserver |
356 // --------------------------------------------------------------------------- |
409 // --------------------------------------------------------------------------- |
357 // |
410 // |
358 EXPORT_C void CESMREditor::SetListObserver( MESMRListObserver* aObserver ) |
411 EXPORT_C void CESMREditor::SetListObserver( MESMRListObserver* aObserver ) |
359 { |
412 { |
360 FUNC_LOG; |
413 FUNC_LOG; |
377 // |
430 // |
378 void CESMREditor::ConstructL(const CCoeControl* aParent, TInt aNumberOfLines, |
431 void CESMREditor::ConstructL(const CCoeControl* aParent, TInt aNumberOfLines, |
379 TInt aTextLimit, TInt aEdwinFlags ) |
432 TInt aTextLimit, TInt aEdwinFlags ) |
380 { |
433 { |
381 FUNC_LOG; |
434 FUNC_LOG; |
382 CEikRichTextEditor::ConstructL (aParent, aNumberOfLines, aTextLimit, |
435 CEikRichTextEditor::ConstructL ( aParent, aNumberOfLines, aTextLimit, |
383 aEdwinFlags ); |
436 aEdwinFlags ); |
384 |
437 |
385 AddEdwinObserverL(this); |
438 AddEdwinObserverL(this); |
386 |
439 |
387 SetUpperFullFormattingLength( aTextLimit ); |
440 SetUpperFullFormattingLength( aTextLimit ); |
388 |
441 |
389 iLimitLength = aTextLimit; |
442 iLimitLength = aTextLimit; |
390 |
|
391 SetAlignment ( CESMRLayoutManager::IsMirrored ( ) ? EAknEditorAlignRight |
|
392 : EAknEditorAlignLeft ); |
|
393 SetHighlightStyleL ( EEikEdwinHighlightLink ); |
|
394 } |
443 } |
395 |
444 |
396 // --------------------------------------------------------------------------- |
445 // --------------------------------------------------------------------------- |
397 // CESMREditor::GetLimitLength |
446 // CESMREditor::GetLimitLength |
398 // --------------------------------------------------------------------------- |
447 // --------------------------------------------------------------------------- |