|
1 /* |
|
2 * Copyright (c) 2005 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 the License "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: Specialization of CEikRichTextEditor. Needed for enabling view |
|
15 * by view scrolling. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #include <frmtlay.h> |
|
22 |
|
23 #include "FeedsViewMgr.hrh" |
|
24 #include "RichTextEditor.h" |
|
25 |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CRichTextEditor::GetNumberOfLines |
|
29 // |
|
30 // Returns the total number of formatted lines in this text. |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 TInt CRichTextEditor::GetNumberOfLines() |
|
34 { |
|
35 return CEikEdwin::iLayout->NumFormattedLines(); |
|
36 } |
|
37 |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CRichTextEditor::MoveCursorL |
|
41 // |
|
42 // Handles the view by view scrolling. |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 void CRichTextEditor::MoveCursorL(TCursorPosition::TMovementType aMovement, TBool aSelect) |
|
46 { |
|
47 TInt numberOfLines(GetNumberOfLines()); |
|
48 TInt currentLine(GetLinePos(CursorPos())); |
|
49 TInt targetLine(0); |
|
50 |
|
51 switch(aMovement) |
|
52 { |
|
53 case TCursorPosition::EFPageDown: |
|
54 targetLine = currentLine + KNumberOfLinesInRichTextEditor; |
|
55 |
|
56 if (targetLine < numberOfLines) |
|
57 { |
|
58 SetCursorPosL(Get1stCharInLine(numberOfLines), aSelect); |
|
59 SetCursorPosL(Get1stCharInLine(targetLine), aSelect); |
|
60 } |
|
61 break; |
|
62 |
|
63 case TCursorPosition::EFPageUp: |
|
64 targetLine = currentLine - KNumberOfLinesInRichTextEditor; |
|
65 |
|
66 if (targetLine >= 0) |
|
67 { |
|
68 SetCursorPosL(0, aSelect); |
|
69 SetCursorPosL(Get1stCharInLine(targetLine), aSelect); |
|
70 } |
|
71 break; |
|
72 |
|
73 default: |
|
74 break; |
|
75 } |
|
76 } |
|
77 |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CRichTextEditor::GetLinePos |
|
81 // |
|
82 // Returns the line number of a given char position. |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 TInt CRichTextEditor::GetLinePos(TInt aPos) |
|
86 { |
|
87 return CEikEdwin::iLayout->GetLineNumber(aPos) + 1; |
|
88 } |
|
89 |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CRichTextEditor::Get1stCharInLine |
|
93 // |
|
94 // The 1st character in the given line. |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 TInt CRichTextEditor::Get1stCharInLine(TInt aLinePos) |
|
98 { |
|
99 return CEikEdwin::iLayout->FirstCharOnLine(aLinePos); |
|
100 } |
|
101 |
|
102 |