|
1 /* |
|
2 * Copyright (c) 1999-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: |
|
15 * MTmTextLayoutForwarder functions. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "TAGMA.H" |
|
21 |
|
22 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
23 #include "TAGMA_INTERNAL.H" |
|
24 #endif |
|
25 |
|
26 /** |
|
27 Return the number of lines in the text. |
|
28 */ |
|
29 EXPORT_C TInt MTmTextLayoutForwarder::Lines() const |
|
30 { |
|
31 return TextLayout().Lines(); |
|
32 } |
|
33 |
|
34 /** |
|
35 Return the number of paragraphs in the text. |
|
36 */ |
|
37 EXPORT_C TInt MTmTextLayoutForwarder::Paragraphs() const |
|
38 { |
|
39 return TextLayout().Paragraphs(); |
|
40 } |
|
41 |
|
42 /** |
|
43 Return the displayed form of the text for a particular line. See CTmLayout::GetDisplayedText for details. |
|
44 */ |
|
45 EXPORT_C TBool MTmTextLayoutForwarder::GetDisplayedText(TInt aLineNumber,TDes& aText,TInt& aNeeded) const |
|
46 { |
|
47 return TextLayout().GetDisplayedText(aLineNumber,aText,aNeeded); |
|
48 } |
|
49 |
|
50 /** |
|
51 Get the minimum size of the formatted text. See CTmTextLayout::GetMinimumLayoutSizeL for details. |
|
52 */ |
|
53 EXPORT_C void MTmTextLayoutForwarder::GetMinimumLayoutSizeL(TInt aWrapWidth,TSize& aSize) const |
|
54 { |
|
55 TextLayout().GetMinimumLayoutSizeL(aWrapWidth,aSize); |
|
56 } |
|
57 |
|
58 /** |
|
59 Get the minimum size of the formatted text. See CTmTextLayout::GetMinimumLayoutSizeL for details. |
|
60 */ |
|
61 EXPORT_C void MTmTextLayoutForwarder::GetMinimumLayoutSizeL(TInt aWrapWidth,TBool aAllowLegalLineBreaksOnly,TSize& aSize) const |
|
62 { |
|
63 TextLayout().GetMinimumLayoutSizeL(aWrapWidth,aAllowLegalLineBreaksOnly,aSize); |
|
64 } |
|
65 |
|
66 /** |
|
67 Return the first formatted character. |
|
68 */ |
|
69 EXPORT_C TInt MTmTextLayoutForwarder::StartChar() const |
|
70 { |
|
71 return TextLayout().StartChar(); |
|
72 } |
|
73 |
|
74 /** |
|
75 Return the character after the last formatted character. |
|
76 */ |
|
77 EXPORT_C TInt MTmTextLayoutForwarder::EndChar() const |
|
78 { |
|
79 return TextLayout().EndChar(); |
|
80 } |
|
81 |
|
82 /** |
|
83 Return the width in pixels of the formatted text, not including paragraph labels if present. |
|
84 */ |
|
85 EXPORT_C TInt MTmTextLayoutForwarder::LayoutWidth() const |
|
86 { |
|
87 return TextLayout().LayoutWidth(); |
|
88 } |
|
89 |
|
90 /** |
|
91 Return the height in pixels of the formatted text. |
|
92 */ |
|
93 EXPORT_C TInt MTmTextLayoutForwarder::LayoutHeight() const |
|
94 { |
|
95 return TextLayout().LayoutHeight(); |
|
96 } |
|
97 |
|
98 EXPORT_C void MTmTextLayoutForwarder::DrawLayout(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect, |
|
99 const TLogicalRgb* aDocBackground,TBool aDrawParBackground) const |
|
100 { |
|
101 TPoint origin; |
|
102 GetOrigin(origin); |
|
103 TextLayout().DrawLayout(aGc,aTopLeft + origin,aClipRect,aDocBackground,aDrawParBackground); |
|
104 } |
|
105 |
|
106 EXPORT_C void MTmTextLayoutForwarder::DrawBackground(CGraphicsContext& aGc,const TPoint& aTopLeft, |
|
107 const TRect& aClipRect,const TLogicalRgb& aBackground) const |
|
108 { |
|
109 TPoint origin; |
|
110 GetOrigin(origin); |
|
111 TextLayout().DrawBackground(aGc,aTopLeft + origin,aClipRect,aBackground); |
|
112 } |
|
113 |
|
114 EXPORT_C void MTmTextLayoutForwarder::InvertLayout(CGraphicsContext& aGc,const TPoint& aTopLeft, |
|
115 TInt aStartDocPos,TInt aEndDocPos) |
|
116 { |
|
117 TPoint origin; |
|
118 GetOrigin(origin); |
|
119 TextLayout().InvertLayout(aGc,aTopLeft + origin,aStartDocPos,aEndDocPos); |
|
120 } |
|
121 |
|
122 EXPORT_C TBool MTmTextLayoutForwarder::FindDocPos(const TTmDocPosSpec& aDocPos, |
|
123 TTmPosInfo2& aPosInfo, TTmLineInfo& aLineInfo) const |
|
124 { |
|
125 TPoint origin; |
|
126 GetOrigin(origin); |
|
127 TBool result = TextLayout().FindDocPos(aDocPos,aPosInfo,aLineInfo); |
|
128 if (origin.iX || origin.iY) |
|
129 { |
|
130 FixUpLineInfo(aLineInfo,&origin); |
|
131 aPosInfo.iEdge += origin; |
|
132 } |
|
133 return result; |
|
134 } |
|
135 |
|
136 /** @deprecated 7.0s */ |
|
137 EXPORT_C TBool MTmTextLayoutForwarder::FindDocPos(const TTmDocPos& aDocPos,TTmPosInfo& aPosInfo, |
|
138 TTmLineInfo& aLineInfo) const |
|
139 { |
|
140 TTmDocPosSpec dp = aDocPos; |
|
141 TTmPosInfo2 pi; |
|
142 TBool r = FindDocPos(dp, pi, aLineInfo); |
|
143 aPosInfo = pi; |
|
144 return r; |
|
145 } |
|
146 |
|
147 EXPORT_C TBool MTmTextLayoutForwarder::FindXyPos(const TPoint& aXyPos, |
|
148 TTmPosInfo2& aPosInfo,TTmLineInfo& aLineInfo) const |
|
149 { |
|
150 TPoint origin; |
|
151 GetOrigin(origin); |
|
152 TBool result = TextLayout().FindXyPos(aXyPos - origin,aPosInfo,aLineInfo); |
|
153 if (origin.iX || origin.iY) |
|
154 { |
|
155 FixUpLineInfo(aLineInfo,&origin); |
|
156 aPosInfo.iEdge += origin; |
|
157 } |
|
158 return result; |
|
159 } |
|
160 |
|
161 EXPORT_C TBool MTmTextLayoutForwarder::FindXyPosWithDisambiguation( |
|
162 const TPoint& aXyPos, TTmPosInfo2& aPosLeft, TTmPosInfo2& aPosRight, |
|
163 TTmLineInfo& aLineInfo) const |
|
164 { |
|
165 TPoint origin; |
|
166 GetOrigin(origin); |
|
167 TBool result = TextLayout().FindXyPosWithDisambiguation(aXyPos - origin, |
|
168 aPosLeft, aPosRight, aLineInfo); |
|
169 if (origin.iX || origin.iY) |
|
170 { |
|
171 FixUpLineInfo(aLineInfo, &origin); |
|
172 aPosLeft.iEdge += origin; |
|
173 aPosRight.iEdge += origin; |
|
174 } |
|
175 return result; |
|
176 } |
|
177 |
|
178 EXPORT_C TBool MTmTextLayoutForwarder::GetNextPosLeftWithDisambiguation( |
|
179 const TTmDocPosSpec& aDocPos, |
|
180 TTmPosInfo2& aPosLeft, TTmPosInfo2& aPosRight) const |
|
181 { |
|
182 TPoint origin; |
|
183 GetOrigin(origin); |
|
184 TBool result = TextLayout().GetNextPosLeftWithDisambiguation(aDocPos, |
|
185 aPosLeft, aPosRight); |
|
186 if (origin.iX || origin.iY) |
|
187 { |
|
188 aPosLeft.iEdge += origin; |
|
189 aPosRight.iEdge += origin; |
|
190 } |
|
191 return result; |
|
192 } |
|
193 |
|
194 EXPORT_C TBool MTmTextLayoutForwarder::GetNextPosRightWithDisambiguation( |
|
195 const TTmDocPosSpec& aDocPos, |
|
196 TTmPosInfo2& aPosLeft, TTmPosInfo2& aPosRight) const |
|
197 { |
|
198 TPoint origin; |
|
199 GetOrigin(origin); |
|
200 TBool result = TextLayout().GetNextPosRightWithDisambiguation(aDocPos, |
|
201 aPosLeft, aPosRight); |
|
202 if (origin.iX || origin.iY) |
|
203 { |
|
204 aPosLeft.iEdge += origin; |
|
205 aPosRight.iEdge += origin; |
|
206 } |
|
207 return result; |
|
208 } |
|
209 |
|
210 /** @deprecated 7.0s */ |
|
211 EXPORT_C TBool MTmTextLayoutForwarder::FindXyPos(const TPoint& aXyPos,TTmPosInfo& aPosInfo,TTmLineInfo& aLineInfo) const |
|
212 { |
|
213 TTmPosInfo2 pi; |
|
214 TBool r = FindXyPos(aXyPos, pi, aLineInfo); |
|
215 aPosInfo = pi; |
|
216 return r; |
|
217 } |
|
218 |
|
219 EXPORT_C TBool MTmTextLayoutForwarder::DocPosToLine( |
|
220 const TTmDocPosSpec& aDocPos, TTmLineInfo& aLineInfo) const |
|
221 { |
|
222 TBool result = TextLayout().DocPosToLine(aDocPos,aLineInfo); |
|
223 FixUpLineInfo(aLineInfo); |
|
224 return result; |
|
225 } |
|
226 |
|
227 /** @deprecated 7.0s */ |
|
228 EXPORT_C TBool MTmTextLayoutForwarder::DocPosToLine(const TTmDocPos& aDocPos,TTmLineInfo& aLineInfo) const |
|
229 { |
|
230 TTmDocPosSpec dp = aDocPos; |
|
231 return DocPosToLine(dp, aLineInfo); |
|
232 } |
|
233 |
|
234 EXPORT_C TBool MTmTextLayoutForwarder::LineNumberToLine(TInt aLineNumber,TTmLineInfo& aLineInfo) const |
|
235 { |
|
236 TBool result = TextLayout().LineNumberToLine(aLineNumber,aLineInfo); |
|
237 FixUpLineInfo(aLineInfo); |
|
238 return result; |
|
239 } |
|
240 |
|
241 EXPORT_C TBool MTmTextLayoutForwarder::ParNumberToLine(TInt aParNumber,TInt aLineInPar,TTmLineInfo& aLineInfo) const |
|
242 { |
|
243 TBool result = TextLayout().ParNumberToLine(aParNumber,aLineInPar,aLineInfo); |
|
244 FixUpLineInfo(aLineInfo); |
|
245 return result; |
|
246 } |
|
247 |
|
248 EXPORT_C TBool MTmTextLayoutForwarder::YPosToLine(TInt aYPos,TTmLineInfo& aLineInfo) const |
|
249 { |
|
250 TPoint origin; |
|
251 GetOrigin(origin); |
|
252 TBool result = TextLayout().YPosToLine(aYPos - origin.iY,aLineInfo); |
|
253 if (origin.iX || origin.iY) |
|
254 FixUpLineInfo(aLineInfo,&origin); |
|
255 return result; |
|
256 } |
|
257 |
|
258 EXPORT_C TInt MTmTextLayoutForwarder::WidthOfWidestLine(TInt aTop,TInt aBottom) const |
|
259 { |
|
260 TPoint origin; |
|
261 GetOrigin(origin); |
|
262 aTop -= origin.iY; |
|
263 aBottom -= origin.iY; |
|
264 return TextLayout().WidthOfWidestLine(aTop,aBottom); |
|
265 } |
|
266 |
|
267 EXPORT_C void MTmTextLayoutForwarder::HorizontalExtremes( |
|
268 TInt &aLeft, TInt &aRight, TInt aTopY, TInt aBottomY) const |
|
269 { |
|
270 TPoint origin; |
|
271 GetOrigin(origin); |
|
272 aTopY -= origin.iY; |
|
273 aBottomY -= origin.iY; |
|
274 TextLayout().HorizontalExtremes(aLeft, aRight, aTopY, aBottomY); |
|
275 if (aLeft != KMaxTInt) |
|
276 aLeft += origin.iX; |
|
277 if (aRight != KMinTInt) |
|
278 aRight += origin.iX; |
|
279 } |
|
280 |
|
281 EXPORT_C TBool MTmTextLayoutForwarder::GetNextVisualCursorPos( |
|
282 const TTmDocPosSpec& aDocPos, TTmPosInfo2& aInfo, TBool aToLeft) const |
|
283 { |
|
284 TBool result = TextLayout().GetNextVisualCursorPos(aDocPos,aInfo,aToLeft); |
|
285 TPoint origin; |
|
286 GetOrigin(origin); |
|
287 aInfo.iEdge += origin; |
|
288 return result; |
|
289 } |
|
290 |
|
291 /** deprecated 7.0s */ |
|
292 EXPORT_C TBool MTmTextLayoutForwarder::GetNextVisualCursorPos(const TTmDocPos& aDocPos,TTmPosInfo& aInfo, |
|
293 TBool aToLeft) const |
|
294 { |
|
295 TBool result = TextLayout().GetNextVisualCursorPos(aDocPos,aInfo,aToLeft); |
|
296 TPoint origin; |
|
297 GetOrigin(origin); |
|
298 aInfo.iEdge += origin; |
|
299 return result; |
|
300 } |
|
301 |
|
302 EXPORT_C TBool MTmTextLayoutForwarder::GetCursor(const TTmDocPosSpec& aDocPos, |
|
303 TTmCursorPlacement aPlacement, TTmLineInfo& aLineInfo, TPoint& aOrigin, |
|
304 TInt& aWidth, TInt& aAscent, TInt& aDescent) const |
|
305 { |
|
306 TBool result = TextLayout().GetCursor(aDocPos, aPlacement, aLineInfo, |
|
307 aOrigin, aWidth, aAscent, aDescent); |
|
308 if (result) |
|
309 { |
|
310 TPoint origin; |
|
311 GetOrigin(origin); |
|
312 if (origin.iX || origin.iY) |
|
313 { |
|
314 aOrigin += origin; |
|
315 FixUpLineInfo(aLineInfo,&origin); |
|
316 } |
|
317 } |
|
318 return result; |
|
319 } |
|
320 |
|
321 /** @deprecated 7.0s */ |
|
322 EXPORT_C TBool MTmTextLayoutForwarder::GetCursor(const TTmDocPos& aDocPos,TTmCursorPlacement aPlacement, |
|
323 TTmLineInfo& aLineInfo,TPoint& aOrigin,TInt& aWidth,TInt& aAscent,TInt& aDescent) const |
|
324 { |
|
325 TBool result = TextLayout().GetCursor(aDocPos,aPlacement,aLineInfo,aOrigin,aWidth,aAscent,aDescent); |
|
326 if (result) |
|
327 { |
|
328 TPoint origin; |
|
329 GetOrigin(origin); |
|
330 if (origin.iX || origin.iY) |
|
331 { |
|
332 aOrigin += origin; |
|
333 FixUpLineInfo(aLineInfo,&origin); |
|
334 } |
|
335 } |
|
336 return result; |
|
337 } |
|
338 |
|
339 void MTmTextLayoutForwarder::FixUpLineInfo(TTmLineInfo& aInfo,const TPoint* aOrigin) const |
|
340 { |
|
341 TPoint origin; |
|
342 if (aOrigin) |
|
343 origin = *aOrigin; |
|
344 else |
|
345 GetOrigin(origin); |
|
346 if (origin.iX || origin.iY) |
|
347 { |
|
348 aInfo.iInnerRect.Move(origin); |
|
349 aInfo.iOuterRect.Move(origin); |
|
350 aInfo.iBaseline += origin.iY; |
|
351 aInfo.iParTop += origin.iY; |
|
352 } |
|
353 } |
|
354 |
|
355 EXPORT_C void MTmTextLayoutForwarder::GetOrigin(TPoint& aPoint) const |
|
356 { |
|
357 aPoint.iX = aPoint.iY = 0; |
|
358 } |