|
1 /* |
|
2 * Copyright (c) 1997-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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __FRMTLAY_H__ |
|
20 #define __FRMTLAY_H__ |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <e32base.h> |
|
24 #include <gdi.h> |
|
25 #include <txtfrmat.h> |
|
26 #include <txtetext.h> |
|
27 #include <frmlaydt.h> |
|
28 #include <frmparam.h> |
|
29 #include <frmvis.h> |
|
30 #include <tagma.h> |
|
31 |
|
32 class CWindowGc; |
|
33 class MLayDoc; |
|
34 class TLayDocTextSource; |
|
35 class TCursorPosition; |
|
36 |
|
37 class TLayDocTextSource; |
|
38 class CTmTextLayout; |
|
39 class TTmHighlightExtensions; |
|
40 class MTmSource; |
|
41 class TTmFormatParamBase; |
|
42 |
|
43 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
44 #include <frmtlay_internal.h> |
|
45 #endif |
|
46 |
|
47 /** |
|
48 This interface class defines an interface for clients of Form to provided |
|
49 implementations of customisation interfaces relating to the source text |
|
50 document as requried by the internals of Form and Tagma. Its use by |
|
51 Form clients is optional. |
|
52 Derived objects of this interface are registered with the CTextLayout |
|
53 API and are called from the TLayDocTextSource class at present. |
|
54 @publishedAll |
|
55 @released |
|
56 @see MTmInlineTextSource |
|
57 */ |
|
58 class MFormCustomInterfaceProvider |
|
59 { |
|
60 public: |
|
61 /** |
|
62 Form uses this method to request an interface implmentation for the |
|
63 specified interface Uid. See class description for interfaces covered |
|
64 by this API. |
|
65 @param aInterfaceId |
|
66 The unique identifier for the interface wanted by Form. |
|
67 @return |
|
68 Ptr to interface instance or 0 if not supported by client |
|
69 */ |
|
70 virtual TAny* GetExtendedInterface(const TUid& aInterfaceId) = 0; |
|
71 }; |
|
72 |
|
73 |
|
74 /** Parameter used to control which part of a line (top, baseline or bottom) |
|
75 should be scrolled to a certain vertical position in a view rectangle. Used |
|
76 as a parameter in functions like CTextView::HandleGlobalChangeL() and |
|
77 CTextLayout::SetViewL(). The selected part of the line is called the hotspot. |
|
78 @publishedAll |
|
79 @released |
|
80 */ |
|
81 class TViewYPosQualifier |
|
82 { |
|
83 friend class CTextLayout; |
|
84 friend class CTextView; |
|
85 public: |
|
86 /** Which part of a line (top, baseline or bottom) should appear at a |
|
87 vertical pixel position. */ |
|
88 enum TPartOfLine |
|
89 { |
|
90 /** The top pixel is placed at the specified vertical point. */ |
|
91 EFViewTopOfLine = 1, |
|
92 /** The baseline is placed at the specified vertical point. */ |
|
93 EFViewBaseLine = 0, |
|
94 /** The bottom pixel is placed at the specified vertical point. */ |
|
95 EFViewBottomOfLine = 2 |
|
96 }; |
|
97 |
|
98 /** Whether the top line in the view should be fully visible. */ |
|
99 enum TFullyVisible |
|
100 { |
|
101 /** Force a partially visible top line to be fully visible. */ |
|
102 EFViewForceLineFullyVisible = ETrue, |
|
103 /** Do not force a partially visible top line to be fully visible. */ |
|
104 EFViewDontForceLineFullyVisible = EFalse |
|
105 }; |
|
106 public: |
|
107 inline TViewYPosQualifier(); |
|
108 IMPORT_C void SetHotSpot(TPartOfLine aHotSpot); |
|
109 IMPORT_C void SetFillScreen(TBool aFillScreen = ETrue); |
|
110 IMPORT_C void SetMakeLineFullyVisible(TFullyVisible aMakeLineFullyVisible = EFViewForceLineFullyVisible); |
|
111 private: |
|
112 TPartOfLine iHotSpot; |
|
113 TBool iFillScreen; |
|
114 TFullyVisible iFullyVisible; |
|
115 }; |
|
116 |
|
117 /** |
|
118 A structure used to return the results of a reformatting operation. |
|
119 @see CTextLayout::HandleBlockChangeL() |
|
120 @publishedAll |
|
121 @released |
|
122 */ |
|
123 class TViewRectChanges |
|
124 |
|
125 { |
|
126 public: |
|
127 inline TViewRectChanges(); |
|
128 |
|
129 public: |
|
130 /** The vertical coordinate of the top of the first line of reformatted |
|
131 text. */ |
|
132 TInt iFormattedFrom; |
|
133 /** The vertical coordinate of the bottom of the last line of reformatted |
|
134 text. */ |
|
135 TInt iFormattedTo; |
|
136 /** The number of pixels by which text above the reformatted or edited |
|
137 block has scrolled (positive values mean the text moved down). */ |
|
138 TInt iScrollAtTop; |
|
139 /** The number of pixels by which text below the reformatted or edited |
|
140 block has scrolled (positive values mean the text moved down). */ |
|
141 TInt iScrollAtBottom; |
|
142 }; |
|
143 |
|
144 /** |
|
145 The cursor or cursor selection within a document. |
|
146 |
|
147 If the cursor and anchor position differ, the selection covers the text from |
|
148 the lower to the higher position, not including the character after the higher |
|
149 position. If the selection is changed (by shift plus arrow keys in many UIs) |
|
150 the cursor position changes and the anchor remains the same. |
|
151 @publishedAll |
|
152 @released |
|
153 */ |
|
154 class TCursorSelection |
|
155 |
|
156 { |
|
157 public: |
|
158 inline TCursorSelection(); |
|
159 inline TCursorSelection(TInt aCursorPos,TInt aAnchorPos); |
|
160 inline void SetSelection(TInt aCursorPos,TInt aAnchorPos); |
|
161 inline TInt LowerPos() const; |
|
162 inline TInt HigherPos() const; |
|
163 inline TInt Length() const; |
|
164 public: |
|
165 /** The cursor position. */ |
|
166 TInt iCursorPos; |
|
167 /** The anchor position. */ |
|
168 TInt iAnchorPos; |
|
169 }; |
|
170 |
|
171 /** |
|
172 Parameters used by functions that draw text. |
|
173 |
|
174 An object of this class is passed to CTextLayout::DrawL() and to |
|
175 InvertRangeL(). The draw context includes the view rectangle, the graphics |
|
176 context, the background colour and the margin widths. |
|
177 |
|
178 You only need to use this class directly when you are using a CTextLayout |
|
179 object which is not owned by a CTextView object. |
|
180 @publishedAll |
|
181 @released |
|
182 */ |
|
183 class TDrawTextLayoutContext |
|
184 |
|
185 { |
|
186 private: |
|
187 enum TDrawMode |
|
188 { |
|
189 EFDrawText=0x001, |
|
190 EFDrawGraphics=0x002, |
|
191 EFUseClippingRect=0x004, |
|
192 EFUseWindowGc=0x008, |
|
193 EFUseGcClear=0x020, |
|
194 EFUseBackgroundColor=0x040, |
|
195 EFUseOverrideTextColor=0x080, |
|
196 EFParagraphFillTextOnly=0x100, |
|
197 EFAllFlags=0xfff |
|
198 }; |
|
199 public: |
|
200 IMPORT_C TDrawTextLayoutContext(); |
|
201 |
|
202 IMPORT_C void SetGc(CGraphicsContext* aGc,CGraphicsContext* aPictureGc=NULL); |
|
203 IMPORT_C void SetBitmapGc(CBitmapContext* aGc,CBitmapContext* aPictureGc=NULL); |
|
204 IMPORT_C void SetWindowGc(CWindowGc* aGc,CWindowGc* aPictureGc=NULL); |
|
205 IMPORT_C void SetDrawToEveryPixel(TBool aDrawToEveryPixel); |
|
206 IMPORT_C void SetTextColorOverride(const TRgb *aOverrideColor); |
|
207 IMPORT_C void SetDrawTextOnly(); |
|
208 IMPORT_C void SetDrawGraphicsOnly(); |
|
209 IMPORT_C void SetDrawTextAndGraphics(); |
|
210 IMPORT_C void SetClipping(TBool aClipping); |
|
211 // deprecated 7.0 |
|
212 IMPORT_C void SetParagraphFillTextOnly(TBool aFillTextOnly); |
|
213 |
|
214 //Enquiry functions |
|
215 IMPORT_C const TRgb* TextOverrideColor() const; |
|
216 IMPORT_C CGraphicsContext* PrimaryGc() const; |
|
217 IMPORT_C CGraphicsContext* PictureGc() const; |
|
218 IMPORT_C TBool UseClippingRect() const; |
|
219 IMPORT_C TBool UseGcClear() const; |
|
220 IMPORT_C TBool DrawText() const; |
|
221 IMPORT_C TBool DrawGraphics() const; |
|
222 IMPORT_C TBool UseBackgroundColor() const; |
|
223 // deprecated 7.0 |
|
224 IMPORT_C TBool ParagraphFillTextOnly() const; |
|
225 |
|
226 //Physical dimensions |
|
227 IMPORT_C TRect TextArea() const; |
|
228 IMPORT_C TInt DisplayHeight() const; |
|
229 IMPORT_C TPoint TopLeftTextArea() const; |
|
230 IMPORT_C TRect TotalMargin() const; |
|
231 IMPORT_C TRect LabelMargin() const; |
|
232 IMPORT_C TBool IsLabelMargin() const; |
|
233 IMPORT_C TRect GutterMargin() const; |
|
234 IMPORT_C TBool IsGutterMargin() const; |
|
235 IMPORT_C TPoint TopLeftText() const; |
|
236 IMPORT_C void WindowToText(TPoint& aWinPos) const; |
|
237 IMPORT_C void WindowToText(TRect& aRect) const; |
|
238 IMPORT_C void TextToWindow(TPoint& aTextAreaPos) const; |
|
239 IMPORT_C void TextToWindow(TRect& aRect) const; |
|
240 |
|
241 TBool UseWindowGc() const; |
|
242 void SetDrawMode(TUint aDrawMode); |
|
243 TUint DrawMode() const; |
|
244 |
|
245 public: |
|
246 /** The view rectangle (specified in window coordinates). This is used to |
|
247 set the area in which text can be drawn. Text can only be drawn within the |
|
248 intersection between the text area and the aDrawRect parameter passed to |
|
249 CTextLayout::DrawL() or InvertRangeL(). */ |
|
250 TRect iViewRect; |
|
251 /** The label margin width. By default zero. Must have the same value as |
|
252 the label margin width as set in the text layout object. */ |
|
253 TInt iLabelMarginWidth; |
|
254 /** The gutter margin width (also known as the line cursor margin width). |
|
255 By default zero. */ |
|
256 TInt iGutterMarginWidth; |
|
257 /** The horizontal offset between window coordinates and text layout |
|
258 coordinates. */ |
|
259 TInt iTextStartX; |
|
260 /** The background colour for the view rectangle. The background colour is |
|
261 used to fill the parts of the view rectangle in which text cannot appear, |
|
262 for example, below the last line of the document and in the label, line |
|
263 cursor and left text margins. */ |
|
264 TLogicalRgb iBackgroundColor; |
|
265 private: |
|
266 CGraphicsContext* iGc; |
|
267 CGraphicsContext* iPictureGc; |
|
268 TLogicalRgb iOverrideTextColor; |
|
269 TUint iDrawMode; |
|
270 }; |
|
271 |
|
272 /** |
|
273 An abstract class which specifies the protocol for customising the way text |
|
274 and its background are drawn. |
|
275 |
|
276 Common uses for this are to implement custom highlighting or to draw a |
|
277 background bitmap. You must create an object of a class derived from this class |
|
278 and call CTextLayout::SetCustomDraw(), passing a pointer to the object. All of |
|
279 these functions have default implementations. Your class can override any of the |
|
280 virtual functions listed below. |
|
281 @publishedAll |
|
282 @released |
|
283 */ |
|
284 class MFormCustomDraw |
|
285 |
|
286 { |
|
287 public: |
|
288 |
|
289 class TParam |
|
290 /** |
|
291 Parameters used by several custom draw functions |
|
292 @publishedAll |
|
293 @released |
|
294 */ |
|
295 { |
|
296 public: |
|
297 TParam(CGraphicsContext& aGc,MGraphicsDeviceMap& aMap,const TPoint& aTextLayoutTopLeft,const TRect& aDrawRect): |
|
298 iGc(aGc), iMap(aMap), iTextLayoutTopLeft(aTextLayoutTopLeft), iDrawRect(aDrawRect) { } |
|
299 |
|
300 CGraphicsContext& iGc; |
|
301 MGraphicsDeviceMap& iMap; |
|
302 const TPoint& iTextLayoutTopLeft; |
|
303 const TRect& iDrawRect; |
|
304 }; |
|
305 |
|
306 class TLineInfo |
|
307 /** |
|
308 Contains the line metrics. |
|
309 @publishedAll |
|
310 @released |
|
311 */ |
|
312 { |
|
313 public: |
|
314 TLineInfo(const TRect& aOuterRect,const TRect& aInnerRect,TInt aBaseline): |
|
315 iOuterRect(aOuterRect), iInnerRect(aInnerRect), iBaseline(aBaseline) { } |
|
316 |
|
317 const TRect& iOuterRect; |
|
318 const TRect& iInnerRect; |
|
319 TInt iBaseline; |
|
320 }; |
|
321 |
|
322 IMPORT_C virtual void DrawBackground(const TParam& aParam,const TRgb& aBackground,TRect& aDrawn) const; |
|
323 IMPORT_C virtual void DrawLineGraphics(const TParam& aParam,const TLineInfo& aLineInfo) const; |
|
324 IMPORT_C virtual void DrawText(const TParam& aParam,const TLineInfo& aLineInfo,const TCharFormat& aFormat, |
|
325 const TDesC& aText,const TPoint& aTextOrigin,TInt aExtraPixels) const; |
|
326 IMPORT_C virtual TRgb SystemColor(TUint aColorIndex,TRgb aDefaultColor) const; |
|
327 |
|
328 IMPORT_C virtual void DrawText(const TParam& aParam,const TLineInfo& aLineInfo,const TCharFormat& aFormat, |
|
329 const TDesC& aText,const TInt aStart, const TInt aEnd, const TPoint& aTextOrigin,TInt aExtraPixels) const; |
|
330 IMPORT_C virtual void MFormCustomDraw_Reserved_2(); |
|
331 }; |
|
332 |
|
333 |
|
334 /** |
|
335 An interface class that can be derived from to implement custom line breaking. |
|
336 |
|
337 Custom line breaking allows the Text Views line wrapping algorithm to break |
|
338 lines in any way. For instance, it may be used to avoid the jagged white space |
|
339 at the right edge of text windows caused by normal line wrapping on a small |
|
340 screen. |
|
341 |
|
342 All of these functions have a default implementation. To change the default |
|
343 behaviour, a pointer to an object that overrides any or all of the functions |
|
344 in the interface needs to be passed to the function CTextLayout::SetCustomWrap(). |
|
345 @since 6.2 |
|
346 |
|
347 @see CTextLayout::SetCustomWrap() |
|
348 @publishedAll |
|
349 @released |
|
350 */ |
|
351 class MFormCustomWrap |
|
352 |
|
353 { |
|
354 public: |
|
355 IMPORT_C virtual TUint LineBreakClass(TUint aCode,TUint& aRangeStart,TUint& aRangeEnd) const; |
|
356 IMPORT_C virtual TBool LineBreakPossible(TUint aPrevClass,TUint aNextClass,TBool aHaveSpaces) const; |
|
357 IMPORT_C virtual TBool GetLineBreakInContext(const TDesC& aText,TInt aMinBreakPos,TInt aMaxBreakPos, |
|
358 TBool aForwards,TInt& aBreakPos) const; |
|
359 IMPORT_C virtual TBool IsHangingCharacter(TUint aChar) const; |
|
360 private: |
|
361 IMPORT_C virtual void MFormCustomWrap_Reserved_1(); |
|
362 IMPORT_C virtual void MFormCustomWrap_Reserved_2(); |
|
363 }; |
|
364 |
|
365 |
|
366 /** |
|
367 Mixin class used to customize visible appearance of invisible characters |
|
368 such as a paragraph mark or a tab. |
|
369 |
|
370 @see CTextView::SetCustomInvisibleCharacterRemapper() |
|
371 @publishedAll |
|
372 @released |
|
373 */ |
|
374 class MFormCustomInvisibleCharacterRemapper |
|
375 { |
|
376 public: |
|
377 IMPORT_C static TUint DefaultMapping(TUint aChar, const TNonPrintingCharVisibility aNonPrintingCharVisibility, const TLayDocTextSource& aLayDoc); |
|
378 |
|
379 /** |
|
380 Allows custom remapping of invisible characters. |
|
381 |
|
382 Called by TLayDocTextSource::Map() if it has been created and registered |
|
383 with TLayDocTextSource using CTextLayout::SetInvisibleCharacterRemapper(). |
|
384 |
|
385 Unless there is a specific reason for doing otherwise it is recommended |
|
386 that where this function has not remapped a given character it should |
|
387 pass it to DefaultMapping() to let it try. |
|
388 |
|
389 @param aChar |
|
390 Invisible character to be remapped |
|
391 @param aDesiredVisibilities |
|
392 Current state of flags showing visibility of invisible characters |
|
393 @param aLayDoc |
|
394 Const ref to the calling CLayDocTextSource |
|
395 @return |
|
396 The replacement character if remapping has taken place, else return original character |
|
397 */ |
|
398 virtual TUint Remap(TUint aChar, const TNonPrintingCharVisibility aNonPrintingCharVisibility, const TLayDocTextSource& aLayDoc) = 0; |
|
399 }; |
|
400 |
|
401 /** |
|
402 Text layout. |
|
403 |
|
404 CTextLayout is the lowest-level text formatting class in the Text Views API. It |
|
405 obtains text and formatting attributes via the MLayDoc interface class and |
|
406 formats the text to a certain width. |
|
407 |
|
408 It has functions for drawing the text and performing hit-detection that is, |
|
409 converting x-y coordinates to document positions, and vice versa. It defines |
|
410 many public functions that are not generally useful, but are called by the |
|
411 higher-level CTextView class, or exist only for the convenience of closely |
|
412 associated classes like the printing and pagination systems. These are |
|
413 identified in the documentation by the text "not generally useful". |
|
414 |
|
415 When using the CTextLayout class, you must be aware of what functions have |
|
416 previously been called. For example: |
|
417 |
|
418 1) Formatting and scrolling functions must not be called if a CTextView object |
|
419 owns the CTextLayout object, because the CTextView object may be reformatting |
|
420 the CTextLayout object asynchronously by means of an active object, or may hold |
|
421 some state information about the CTextLayout object that would be invalidated |
|
422 by reformatting. These functions are identified in the documentation by the |
|
423 text "Do not use if a CTextView object owns this CTextLayout object.". |
|
424 |
|
425 2) Functions that raise out of memory exceptions can leave the object in an |
|
426 inconsistent state; these functions can be identified as usual by their |
|
427 trailing L. When this occurs, it is necessary to discard the formatting |
|
428 information by calling DiscardFormat(). |
|
429 |
|
430 3) Some functions change formatting parameters like the wrap width or band |
|
431 height, but do not reformat to reflect the change. These functions are |
|
432 identified in the documentation by the text "Reformat needed". |
|
433 @publishedAll |
|
434 @released |
|
435 */ |
|
436 class CTextLayout: public CBase |
|
437 |
|
438 { |
|
439 friend class CTestTextLayout; |
|
440 public: |
|
441 |
|
442 /**Flags used by CTextLayout::SetViewL(). Whether to reformat and redraw.*/ |
|
443 enum TDiscard |
|
444 { |
|
445 /** Discard all formatting; redraw. */ |
|
446 EFViewDiscardAllFormat = TRUE, |
|
447 /** Do not discard all formatting; redraw. */ |
|
448 EFViewDontDiscardFormat = FALSE |
|
449 }; |
|
450 |
|
451 /** Indicates whether blank space should scroll. |
|
452 Used by several CTextView and CTextLayout scrolling functions. */ |
|
453 enum TAllowDisallow |
|
454 { |
|
455 /** Allow blank space to scroll. */ |
|
456 EFAllowScrollingBlankSpace = TRUE, |
|
457 /** Disallow blank space from scrolling. */ |
|
458 EFDisallowScrollingBlankSpace = FALSE |
|
459 }; |
|
460 |
|
461 enum // flags for HandleCharEditL |
|
462 { |
|
463 /** Insert a character, (not a paragraph delimiter). */ |
|
464 EFCharacterInsert, |
|
465 /** Insert a paragraph delimiter. */ |
|
466 EFParagraphDelimiter, |
|
467 /** Delete single character to the left. */ |
|
468 EFLeftDelete, |
|
469 /** Delete single character to the right. */ |
|
470 EFRightDelete |
|
471 }; |
|
472 |
|
473 enum |
|
474 { |
|
475 /** A value greater than any possible display height indicates that the |
|
476 entire visible area, at least, was scrolled, and so there is no point |
|
477 in blitting text; a full redraw is needed. |
|
478 */ |
|
479 EFScrollRedrawWholeScreen = CLayoutData::EFLargeNumber, |
|
480 /** The maximum line width when wrapping is unset. */ |
|
481 EFMaximumLineWidth = CLayoutData::EFBodyWidthForNoWrapping, |
|
482 }; |
|
483 |
|
484 enum |
|
485 { |
|
486 /** Wrapping off; overrides the paragraph format. */ |
|
487 EFAllParagraphsNotWrapped = TRUE, |
|
488 /** Wrapping on, unless CParaFormat::iWrap is false. */ |
|
489 EFParagraphsWrappedByDefault = FALSE |
|
490 }; |
|
491 |
|
492 /** Amount to format. Used by CTextLayout::SetAmountToFormat(). */ |
|
493 enum TAmountFormatted |
|
494 { |
|
495 /** Format the whole document. */ |
|
496 EFFormatAllText = FALSE, |
|
497 /** Format the visible band only. */ |
|
498 EFFormatBand = TRUE, |
|
499 }; |
|
500 |
|
501 enum TScrollFlags |
|
502 { |
|
503 EFScrollOnlyToTopsOfLines = 1 |
|
504 }; |
|
505 |
|
506 /** Formatting information. */ |
|
507 enum TCurrentFormat |
|
508 { |
|
509 /** Returned by some CTextLayout enquiry functions to indicate that no |
|
510 formatting has taken place so that the requested value cannot be |
|
511 calculated. */ |
|
512 EFNoCurrentFormat = -1, |
|
513 /** Returned by CTextLayout::ParagraphHeight() when the paragraph is not formatted. */ |
|
514 EFNotInCurrentFormat = 0 |
|
515 }; |
|
516 public: |
|
517 class TRangeChange |
|
518 /** |
|
519 Specifies the range of characters involved when setting or clearing a |
|
520 text selection. |
|
521 |
|
522 This class is used in the CTextLayout::Highlight() function. The following |
|
523 code demonstrates how it should be used to clear an existing highlight and |
|
524 set a new one: |
|
525 |
|
526 @code |
|
527 CTextLayout::TRangeChange oldHighlight(anchorPos, old_cursorPos, |
|
528 CTextLayout::TRangeChange::EClear); // existing highlight |
|
529 CTextLayout::TRangeChange newHighlight(anchorPos, new_cursorPos, |
|
530 CTextLayout::TRangeChange::ESet); // new one |
|
531 newHighlight.OptimizeWith(oldHighlight); // doesn't matter which range is |
|
532 the parameter and which is the calling object |
|
533 layout.Highlight(oldHighlight,drawRect,context); // doesn't matter in which |
|
534 order this and following line occur |
|
535 layout.Highlight(newHighlight,drawRect,context); |
|
536 @endcode |
|
537 |
|
538 @see CTextLayout::Highlight() |
|
539 @publishedAll |
|
540 @released |
|
541 */ |
|
542 { |
|
543 public: |
|
544 /** Enumerates the possible change types. */ |
|
545 enum TChangeType |
|
546 { |
|
547 /** The object is being used to set a range. */ |
|
548 ESet, |
|
549 /** The object is being used to clear a range. */ |
|
550 EClear |
|
551 }; |
|
552 IMPORT_C TRangeChange(TInt aStart, TInt aEnd, TChangeType aChange); |
|
553 IMPORT_C TRangeChange(); |
|
554 IMPORT_C void Set(TInt aStart, TInt aEnd, TChangeType aChange); |
|
555 IMPORT_C TChangeType Get(TInt& aStart, TInt& aEnd) const; |
|
556 IMPORT_C void OptimizeWith(TRangeChange& aBuddy); |
|
557 IMPORT_C TBool NonNull() const; |
|
558 IMPORT_C TBool Clip(TInt aMin, TInt aMax); |
|
559 |
|
560 TBool IsJoinedTo(const TRangeChange aRange); |
|
561 void Join(const TRangeChange aRange); |
|
562 |
|
563 private: |
|
564 TInt iA; |
|
565 TInt iB; |
|
566 }; |
|
567 |
|
568 public: |
|
569 |
|
570 class TTagmaForwarder: public MTmTextLayoutForwarder |
|
571 /** |
|
572 A standard inquiry interface for the text formatting engine, built on |
|
573 top of a CTextView object. |
|
574 |
|
575 To use it, construct a TTagmaForwarder object, then call InitL(), which |
|
576 finishes background formatting, then call the MTmTextLayoutForwarder |
|
577 functions. |
|
578 |
|
579 The class should only be used internally by FORM component. |
|
580 @internalComponent |
|
581 */ |
|
582 { |
|
583 public: |
|
584 inline TTagmaForwarder(const CTextLayout& aLayout); |
|
585 |
|
586 private: |
|
587 // from MTmTextLayoutForwarder |
|
588 inline const CTmTextLayout& TextLayout() const; |
|
589 inline void GetOrigin(TPoint& aPoint) const; |
|
590 |
|
591 const CTextLayout& iLayout; |
|
592 }; |
|
593 |
|
594 /** |
|
595 Accesses text supplied by MTmSource. |
|
596 @internalComponent |
|
597 */ |
|
598 class TUtf32SourceCache |
|
599 { |
|
600 public: |
|
601 TUtf32SourceCache(const MTmSource& aSource); |
|
602 TUtf32SourceCache(const CTextLayout& aLayout); |
|
603 TText GetUtf16(TInt aIndex); |
|
604 TChar GetUtf32(TInt aIndex); |
|
605 private: |
|
606 const MTmSource* iSource; |
|
607 TPtrC16 iCurrentView; |
|
608 TInt iCurrentViewIndex; |
|
609 }; |
|
610 friend class TUtf32SourceCache; |
|
611 |
|
612 IMPORT_C static CTextLayout *NewL(MLayDoc *aDoc,TInt aWrapWidth); |
|
613 IMPORT_C ~CTextLayout(); |
|
614 IMPORT_C void DiscardFormat(); |
|
615 IMPORT_C void SetLayDoc(MLayDoc *aDoc); |
|
616 IMPORT_C void SetWrapWidth(TInt aWrapWidth); |
|
617 IMPORT_C void SetBandHeight(TInt aHeight); |
|
618 IMPORT_C TInt BandHeight() const; |
|
619 IMPORT_C void SetImageDeviceMap(MGraphicsDeviceMap *aGd); |
|
620 IMPORT_C void SetLabelsDeviceMap(MGraphicsDeviceMap *aDeviceMap); |
|
621 IMPORT_C void SetAmountToFormat(TAmountFormatted aAmountOfFormat = EFFormatBand); |
|
622 IMPORT_C TBool IsFormattingBand() const; |
|
623 IMPORT_C void SetFormatMode(CLayoutData::TFormatMode aFormatMode,TInt aWrapWidth,MGraphicsDeviceMap* aFormatDevice); |
|
624 IMPORT_C void ForceNoWrapping(TBool aNoWrapping = EFAllParagraphsNotWrapped); |
|
625 IMPORT_C TBool IsWrapping() const; |
|
626 IMPORT_C void SetTruncating(TBool aOn); |
|
627 IMPORT_C TBool Truncating() const; |
|
628 IMPORT_C void SetTruncatingEllipsis(TChar aEllipsis); |
|
629 IMPORT_C TChar TruncatingEllipsis() const; |
|
630 IMPORT_C void SetLabelsMarginWidth(TInt aWidth); |
|
631 IMPORT_C void SetNonPrintingCharsVisibility(TNonPrintingCharVisibility aVisibility); |
|
632 IMPORT_C TNonPrintingCharVisibility NonPrintingCharsVisibility() const; |
|
633 IMPORT_C TBool IsBackgroundFormatting() const; |
|
634 IMPORT_C void NotifyTerminateBackgroundFormatting(); |
|
635 // deprecated 7.0 |
|
636 IMPORT_C void SetExcludePartialLines(TBool aExcludePartialLines = TRUE); |
|
637 // deprecated 7.0 |
|
638 IMPORT_C TBool ExcludingPartialLines() const; |
|
639 IMPORT_C void SetFontHeightIncreaseFactor(TInt aPercentage); |
|
640 IMPORT_C TInt FontHeightIncreaseFactor() const; |
|
641 IMPORT_C void SetMinimumLineDescent(TInt aPixels); |
|
642 IMPORT_C TInt MinimumLineDescent() const; |
|
643 IMPORT_C TInt DocumentLength() const; |
|
644 IMPORT_C TInt ToParagraphStart(TInt& aDocPos) const; |
|
645 IMPORT_C TInt PixelsAboveBand() const; |
|
646 IMPORT_C TInt YBottomLastFormattedLine() const; |
|
647 IMPORT_C TInt FormattedHeightInPixels() const; |
|
648 IMPORT_C TInt PosRangeInBand(TInt& aDocPos) const; |
|
649 IMPORT_C TBool PosInBand(const TTmDocPos& aDocPos,TTmLineInfo* aLineInfo = NULL) const; |
|
650 IMPORT_C TBool PosInBand(TTmDocPos aDocPos,TPoint& aXyPos) const; |
|
651 IMPORT_C TBool PosInBand(TInt aDocPos,TPoint& aXyPos) const; |
|
652 IMPORT_C TBool PosIsFormatted(TInt aDocPos) const; |
|
653 IMPORT_C TInt FirstCharOnLine(TInt aLineNo) const; |
|
654 IMPORT_C TInt FormattedLength() const; |
|
655 IMPORT_C TInt FirstFormattedPos() const; |
|
656 IMPORT_C TInt NumFormattedLines() const; |
|
657 IMPORT_C TInt FirstLineInBand() const; |
|
658 IMPORT_C TInt GetLineRect(TInt aYPos,TRect& aLine) const; |
|
659 IMPORT_C TInt ParagraphHeight(TInt aDocPos) const; |
|
660 IMPORT_C TRect ParagraphRectL(TInt aDocPos) const; |
|
661 IMPORT_C TBool CalculateHorizontalExtremesL(TInt& aLeftX,TInt& aRightX,TBool aOnlyVisibleLines, |
|
662 TBool aIgnoreWrapCharacters = FALSE) const; |
|
663 IMPORT_C void GetCharacterHeightAndAscentL(TInt aDocPos,TInt& aHeight,TInt& aAscent) const; |
|
664 IMPORT_C void GetFontHeightAndAscentL(const TFontSpec& aFontSpec,TInt& aHeight,TInt& aAscent) const; |
|
665 IMPORT_C TInt XyPosToDocPosL(TPoint &aPos, TUint aFlags = 0) const; |
|
666 IMPORT_C TBool DocPosToXyPosL(TInt aDocPos, TPoint& aPos, TUint aFlags = 0) const; |
|
667 IMPORT_C TBool FindXyPos(const TPoint& aXyPos,TTmPosInfo2& aPosInfo,TTmLineInfo* aLineInfo = NULL) const; |
|
668 IMPORT_C TBool FindDocPos(const TTmDocPosSpec& aDocPos,TTmPosInfo2& aPosInfo,TTmLineInfo* aLineInfo = NULL) const; |
|
669 IMPORT_C TRect GetLineRectL(TInt aDocPos1,TInt aDocPos2) const; |
|
670 IMPORT_C TBool PictureRectangleL(TInt aDocPos,TRect& aPictureRect,TBool* aCanScaleOrCrop = NULL) const; |
|
671 IMPORT_C TBool PictureRectangleL(const TPoint& aXyPos,TRect& aPictureRect,TBool* aCanScaleOrCrop = NULL) const; |
|
672 IMPORT_C TInt FirstDocPosFullyInBand() const; |
|
673 IMPORT_C void GetMinimumSizeL(TInt aWrapWidth,TSize& aSize); |
|
674 IMPORT_C void GetMinimumSizeL(TInt aWrapWidth,TBool aAllowLegalLineBreaksOnly,TSize& aSize); |
|
675 IMPORT_C TInt MajorVersion() const; |
|
676 IMPORT_C TInt SetViewL(const TTmDocPos& aDocPos,TInt& aYPos,TViewYPosQualifier aYPosQualifier, |
|
677 TDiscard aDiscardFormat = EFViewDontDiscardFormat); |
|
678 IMPORT_C TInt SetViewL(TInt aDocPos,TInt& aYPos,TViewYPosQualifier aYPosQualifier, |
|
679 TDiscard aDiscardFormat = EFViewDontDiscardFormat); |
|
680 IMPORT_C void FormatBandL(); |
|
681 IMPORT_C void FormatCharRangeL(TInt aStartDocPos,TInt aEndDocPos); |
|
682 void FormatCharRangeL(TInt aStartDocPos,TInt aEndDocPos,TInt aPixelOffset); |
|
683 IMPORT_C TBool FormatNextLineL(TInt& aBotPixel); |
|
684 IMPORT_C TBool FormatLineL(CParaFormat* aParaFormat,TInt& aDocPos,TInt& aHeight,TBool& aPageBreak); |
|
685 IMPORT_C TInt ScrollParagraphsL(TInt& aNumParas,TAllowDisallow aScrollBlankSpace); |
|
686 IMPORT_C TInt ScrollLinesL(TInt& aNumLines,TAllowDisallow aScrollBlankSpace = EFDisallowScrollingBlankSpace); |
|
687 IMPORT_C TInt ChangeBandTopL(TInt& aPixels,TAllowDisallow aScrollBlankSpace = EFDisallowScrollingBlankSpace); |
|
688 IMPORT_C void ChangeBandTopNoLimitBorderL(TInt aPixels); |
|
689 IMPORT_C void PageUpL(TInt& aYCursorPos,TInt& aPixelsScrolled); |
|
690 IMPORT_C void PageDownL(TInt& aYCursorPos,TInt& aPixelsScrolled); |
|
691 IMPORT_C TBool HandleCharEditL(TUint aType,TInt& aCursorPos,TInt& aGood,TInt& aFormattedUpTo, |
|
692 TInt& aFormattedFrom,TInt& aScroll,TBool aFormatChanged); |
|
693 IMPORT_C void HandleBlockChangeL(TCursorSelection aSelection,TInt aOldCharsChanged,TViewRectChanges& aViewChanges, |
|
694 TBool aFormatChanged); |
|
695 IMPORT_C void HandleAdditionalCharactersAtEndL(TInt& aFirstPixel,TInt& aLastPixel); |
|
696 // deprecated 6.1 |
|
697 IMPORT_C void ReformatVerticalSpaceL(); |
|
698 IMPORT_C void AdjustVerticalAlignment(CParaFormat::TAlignment aVerticalAlignment); |
|
699 IMPORT_C static void DrawBorders(const MGraphicsDeviceMap* aGd,CGraphicsContext& aGc,const TRect& aRect, |
|
700 const TParaBorderArray& aBorder,const TRgb* aBackground = NULL, |
|
701 TRegion* aClipRegion = NULL,const TRect* aDrawRect = NULL); |
|
702 IMPORT_C void DrawL(const TRect& aDrawRect,const TDrawTextLayoutContext* aDrawTextLayoutContext, |
|
703 const TCursorSelection* aHighlight = NULL); |
|
704 IMPORT_C TBool GetNextVisualCursorPos(const TTmDocPosSpec& aDocPos, |
|
705 TTmPosInfo2& aPosInfo, TBool aToLeft) const; |
|
706 // deprecated 7.0 |
|
707 IMPORT_C void InvertRangeL(const TCursorSelection& aHighlight,const TRect& aDrawRect, |
|
708 const TDrawTextLayoutContext* aDrawTextLayoutContext); |
|
709 IMPORT_C void Highlight(const TRangeChange& aHighlight,const TRect& aDrawRect, |
|
710 const TDrawTextLayoutContext* aDrawTextLayoutContext); |
|
711 IMPORT_C void SetCustomDraw(const MFormCustomDraw* aCustomDraw); |
|
712 IMPORT_C const MFormCustomDraw* CustomDraw() const; |
|
713 IMPORT_C void SetCustomWrap(const MFormCustomWrap* aCustomWrap); |
|
714 IMPORT_C const MFormCustomWrap* CustomWrap() const; |
|
715 /* this function should only used by Symbian internally */ |
|
716 IMPORT_C void ExtendFormattingToCoverYL(TInt aYPos); |
|
717 IMPORT_C void ExtendFormattingToCoverPosL(TInt aDocPos); |
|
718 |
|
719 IMPORT_C TInt GetLineNumber(TInt aDocPos); |
|
720 IMPORT_C void SetHighlightExtensions(TInt aLeftExtension, TInt aRightExtension, TInt aTopExtension, TInt aBottomExtension); |
|
721 void SetExcessHeightRequired(TInt aExcessHeightRequired); |
|
722 IMPORT_C void SetInterfaceProvider( MFormCustomInterfaceProvider* aProvider ); |
|
723 inline const CTmTextLayout& TagmaTextLayout() const; |
|
724 inline void GetOrigin(TPoint& aPoint) const; |
|
725 |
|
726 |
|
727 inline void RestrictScrollToTopsOfLines(TBool aRestrict); |
|
728 |
|
729 |
|
730 // Non-exported public functions |
|
731 void DrawBackground(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect, |
|
732 const TLogicalRgb& aBackground) const; |
|
733 TBool CalculateHorizontalExtremes(TInt& aLeftX,TInt& aRightX,TBool aOnlyVisibleLines) const; |
|
734 TBool GetCursor(const TTmDocPos& aDocPos,TTmCursorPlacement aPlacement, |
|
735 TRect& aLineRect,TPoint& aOrigin,TInt& aWidth,TInt& aAscent,TInt& aDescent) const; |
|
736 void GetParagraphRect(const TTmDocPos& aDocPos,TRect& aRect) const; |
|
737 TInt ScrollDocPosIntoViewL(const TTmDocPos& aDocPos); |
|
738 TInt PictureRectangleAndPosL(const TPoint& aXyPos, TRect& aPictureRect, |
|
739 TBool* aCanScaleOrCrop = 0) const; |
|
740 void HighlightUsingExtensions(const CTextLayout::TRangeChange& aChangeHighlight,const TRangeChange& aFullHighlight, |
|
741 const TRect& aDrawRect, const TDrawTextLayoutContext* aDrawTextLayoutContext); |
|
742 inline const TTmHighlightExtensions& HighlightExtensions() const; |
|
743 void GetHighlightRemnants(const TRect& aRect, const TDrawTextLayoutContext& aDrawTextLayoutContext, TRect* aRemainderRects) const; |
|
744 TInt WrapWidth() const; |
|
745 |
|
746 void SetOpaqueLC(); |
|
747 |
|
748 IMPORT_C void SetCustomInvisibleCharacterRemapper(MFormCustomInvisibleCharacterRemapper* aInvisibleCharacterRemapper); |
|
749 IMPORT_C MFormCustomInvisibleCharacterRemapper* GetCustomInvisibleCharacterRemapper(); |
|
750 void SetTextViewCursorPos(TCursorPosition* aPos); // Put in for INC092568 |
|
751 |
|
752 void SetWindow(RWindow* aWnd); |
|
753 void SetReadyToRedraw(); |
|
754 void BeginRedraw(const TRect& aRect); |
|
755 void EndRedraw(); |
|
756 void SetExternalDraw(const TRect& aRect); |
|
757 void ResetExternalDraw(); |
|
758 TBool BeginRedrawCalled() const; |
|
759 IMPORT_C void MakeVisible(TBool aVisible); |
|
760 |
|
761 #ifdef _DEBUG |
|
762 TBool __DbgIsFormattingUpToDate() const; |
|
763 #endif |
|
764 |
|
765 enum TPanicNumber |
|
766 { |
|
767 EUnimplemented, |
|
768 ENoMemory, |
|
769 EDrawingBorderError, |
|
770 EFormatDeviceNotSet, |
|
771 EImageDeviceNotSet, |
|
772 EPixelNotInFormattedLine, |
|
773 EInvalidDocPos, |
|
774 ENoCharRangeToFormat, |
|
775 ECharacterNotFormatted, |
|
776 EPrintPreviewModeError, |
|
777 EBadCharacterEditType, |
|
778 EInvalidLineNumber, |
|
779 EPosNotFormatted, |
|
780 EMustFormatAllText, |
|
781 EPageScrollError, |
|
782 EInvalidRedraw |
|
783 }; |
|
784 static void Panic(TPanicNumber aNumber); |
|
785 |
|
786 private: |
|
787 IMPORT_C CTextLayout(); |
|
788 IMPORT_C void ConstructL(MLayDoc *aDoc,TInt aWrapWidth); |
|
789 void InitFormatParam(TTmFormatParamBase& aParam); |
|
790 TInt ScrollL(TInt aDy,TAllowDisallow aScrollBlankSpace,TBool aTopNoLimitBorder=EFalse,TBool aBottomNoLimitBorder=EFalse); |
|
791 void FormatBandL(TInt aStartDocPos,TInt aEndDocPos); |
|
792 void PruneFormatL(TBool aFromStart); |
|
793 TInt VisibleHeightInPixels() const; |
|
794 TInt BandHeightInPixels() const; |
|
795 TInt SuggestCursorPos(TInt aCurrentCursorPos) const; |
|
796 TInt SetBandTop(); |
|
797 TBool AddFormattingAtEndL(TTmFormatParamBase& aFormatParam, TInt& aHeightIncrease, TInt& aParagraphsIncrease); |
|
798 |
|
799 static void ResetOpaque(void* aThis); |
|
800 |
|
801 |
|
802 CTmTextLayout *iText; // the TAGMA object that contains the text layout |
|
803 TInt iDummyForIText[10]; // It is only here to add padding for maintain compatibility |
|
804 TInt iExcessHeightRequired; // The delta required to position the baseline so there is enough |
|
805 // space for the highset glyph in pixels |
|
806 RWindow *iWnd; // the window to be used to draw |
|
807 TBool iBeginRedrawCount; |
|
808 TRect iRedrawRect; |
|
809 TCursorPosition* iTextViewCursorPos; // From and owned by owning CTextView if it exists, |
|
810 // Null otherwise. Put in for INC092568 |
|
811 TBool iIsWndInExternalRedraw; // If ETrue, then iWnd->EndRedraw() will not be called |
|
812 // from within CTextLayout::EndRedraw() as the window redraw |
|
813 // has been initiated externally and will be ended externally as well |
|
814 TBool iReadyToRedraw; // If EFalse, disables CTextLayout::BeginRedraw() and |
|
815 // CTextLayout::EndRedraw() |
|
816 TInt iDummy[4]; // This dummy variable has been inserted to replace the original size of |
|
817 // a variable that had to be moved to avaid a BC break because it had |
|
818 // increased in size. Feel free to reuse this space - just reduce the size |
|
819 // of this variable by the size of any variable you insert in front of it. |
|
820 // Currently it occupies 5 words. |
|
821 TInt iBandTop; // effectively, scroll position: subtract this from CTmTextLayout y position |
|
822 // to give CTextLayout y position |
|
823 TInt iVisibleHeight;// in pixels if iFormatMode is EFScreenMode or EFWysiwygMode, otherwise twips |
|
824 TInt iBandHeight; // in pixels if iFormatMode is EFScreenMode or EFWysiwygMode, otherwise twips |
|
825 |
|
826 TInt iScrollFlags; // from CTextLayout::TScrollFlags |
|
827 TInt iUnformattedStart; // document position of the start of any unformatted text; |
|
828 // if < KMaxTInt, background formatting can be used |
|
829 // (by calling FormatNextLine) to format the remainder |
|
830 TBool iParInvalid; // if true and background formatting is happening, the remainder of the paragraph |
|
831 // containing iUnformattedStart is invalid and must be reformatted; |
|
832 // otherwise, formatting stops when line ends match |
|
833 TTmHighlightExtensions *iHighlightExtensions; |
|
834 TInt iDmmyForIHighlightExtensions[3]; // It is only here to add padding for maintain compatibility |
|
835 TLayDocTextSource* iSource; // the source of the text |
|
836 // before adding any new member variables to the end of this class, please |
|
837 // consider whether you can insert them before the iDummy member variable |
|
838 // further up, which currently represents wasted space. |
|
839 TInt iDmmyForISource[23]; // It is only here to add padding for maintain compatibility |
|
840 }; |
|
841 |
|
842 /** |
|
843 Cursor position. |
|
844 |
|
845 The TMovementType enum defined in this class is used to indicate the direction |
|
846 of a scroll or cursor movement. The remainder of this class does not form part |
|
847 of the API. |
|
848 @publishedAll |
|
849 @released |
|
850 */ |
|
851 class TCursorPosition |
|
852 |
|
853 { |
|
854 public: |
|
855 |
|
856 |
|
857 /** Direction of cursor movement. */ |
|
858 enum TMovementType |
|
859 { |
|
860 /** No cursor movement */ |
|
861 EFNoMovement, |
|
862 /** Single character cursor movement to the left */ |
|
863 EFLeft, |
|
864 /** Single character cursor movement to the right */ |
|
865 EFRight, |
|
866 /** Line up cursor movement */ |
|
867 EFLineUp, |
|
868 /** Line down cursor movement */ |
|
869 EFLineDown, |
|
870 /** Page up cursor movement */ |
|
871 EFPageUp, |
|
872 /** Page down cursor movement */ |
|
873 EFPageDown, |
|
874 /** Cursor movement to line start */ |
|
875 EFLineBeg, |
|
876 /** Cursor movement to line end */ |
|
877 EFLineEnd |
|
878 }; |
|
879 |
|
880 /** Selection of the left end or right end of a run of text. */ |
|
881 enum TVisualEnd |
|
882 { |
|
883 /** Leftmost end. */ |
|
884 EVisualLeft, |
|
885 /** Rightmost end. */ |
|
886 EVisualRight |
|
887 }; |
|
888 |
|
889 enum TPosHint |
|
890 { |
|
891 EPosHintUndefined = 0, |
|
892 /** Left to right typing expected. */ |
|
893 EInsertStrongL2R = 1, |
|
894 /** Right to left typing expected. */ |
|
895 EInsertStrongR2L = 2, |
|
896 |
|
897 // Maybe several more. |
|
898 //... |
|
899 EPosHintLast |
|
900 }; |
|
901 |
|
902 inline TCursorPosition(); |
|
903 inline void SetLayout(CTextLayout *aLayout); |
|
904 inline void UpdateLatentX(TInt aX); |
|
905 inline void SetToPreviousHighlight(); |
|
906 inline void SetToCurrentHighlight(); |
|
907 inline void CancelHighlight(); |
|
908 inline void SetDocPos(const TTmDocPos& aDocPos); |
|
909 void UpdateLatentPosition(); |
|
910 TInt SetSelectionL(const TCursorSelection& aSelection); |
|
911 void SetPendingSelection(const TCursorSelection& aSelection); |
|
912 void GetOldSelection(TCursorSelection& aSelection) const; |
|
913 void GetSelection(TCursorSelection& aSelection) const; |
|
914 TInt SetDocPosL(TBool aDragSelectOn,const TTmDocPos& aDocPos); |
|
915 TInt SetXyPosL(TBool aDragSelectOn,TPoint aPos,TBool aAllowPictureFrame); |
|
916 TInt MoveL(TBool aDragSelectOn,TMovementType& aMovement,TBool aAllowPictureFrame); |
|
917 const TTmDocPos& VisualEndOfRunL( |
|
918 const TTmDocPos& aStart, const TTmDocPos& aEnd, |
|
919 TVisualEnd aDirection); |
|
920 void TextMoveVertically(); |
|
921 inline void DontDrawOldPictureFrame(); |
|
922 |
|
923 // inquiry functions |
|
924 inline TBool IsSelection() const; |
|
925 inline TBool IsSelectionToDraw() const; |
|
926 TBool IsPictureFrame() const; |
|
927 TBool IsNewPictureFrame() const; |
|
928 inline const TTmDocPos& TmDocPos() const; |
|
929 inline TInt DocPos() const; |
|
930 inline TBool DrawHighlight() const; |
|
931 inline TBool DrawOldPictureFrame() const; |
|
932 inline TBool DrawNewPictureFrame() const; |
|
933 TBool GetCursor(TTmCursorPlacement aPlacement,TPoint& aOrigin,TInt& aWidth,TInt& aAscent,TInt& aDescent) const; |
|
934 TPosHint PositioningHint() const { return iPositioningHint; } |
|
935 void SetPositioningHint (TPosHint aHint) |
|
936 {iPositioningHint = aHint;} |
|
937 |
|
938 TTmPosInfo2& ChoosePosition(TTmPosInfo2& aPreferred, |
|
939 TTmPosInfo2& aBackup); |
|
940 |
|
941 private: |
|
942 enum |
|
943 { |
|
944 EFAbove = -1, |
|
945 EFInside = 0, |
|
946 EFBelow = 1 |
|
947 }; |
|
948 |
|
949 // bit values for iFlags |
|
950 enum |
|
951 { |
|
952 EDrawHighlight = 1, |
|
953 EDrawOldPictureFrame = 2, |
|
954 EDrawNewPictureFrame = 4, |
|
955 EReturnPreviousHighlight = 8, |
|
956 ESelected = 16 |
|
957 }; |
|
958 |
|
959 TInt ViewTopOfLineL(const TTmDocPos& aDocPos,TInt& aYPos); |
|
960 void CheckSelection(TBool aSelect); |
|
961 void CheckNullSelection(); |
|
962 inline void UpdateLatentY(TInt aY); |
|
963 TInt CheckCursorOnScreenL(TInt& aY); |
|
964 TBool LeftRightL(TTmPosInfo2& aPos, TTmLineInfo& aLine, TMovementType& aMove); |
|
965 void StartEnd(TTmPosInfo2& aPos, TTmLineInfo& aLine, TMovementType& aMove); |
|
966 void UpDownL(TTmPosInfo2& aPos, TTmLineInfo& aLine, TMovementType& aMove); |
|
967 TInt PageScrollL(TMovementType& aMove); |
|
968 TInt DoSetDocPosL(const TTmDocPos& aDocPos); |
|
969 TInt DoSetVisibleDocPosL(const TTmDocPos& aDocPos); |
|
970 void DoSetXyPos(TPoint& aXy); |
|
971 void SetPictureFrame(const TTmDocPos& aDocPos,TInt aAnchor,const TRect& aPictureRect); |
|
972 inline TBool CalculateCursorPos(TPoint& aCurPos); |
|
973 |
|
974 TTmDocPos iDocPos; |
|
975 TInt iAnchor; |
|
976 TInt iOldDocPos; |
|
977 TInt iOldAnchor; |
|
978 TUint iFlags; |
|
979 TInt iLatentX; |
|
980 TInt iLatentY; |
|
981 CTextLayout* iLayout; |
|
982 TPosHint iPositioningHint; |
|
983 }; |
|
984 |
|
985 // inline functions |
|
986 inline const CTmTextLayout& CTextLayout::TagmaTextLayout() const |
|
987 { |
|
988 return *iText; |
|
989 } |
|
990 |
|
991 inline void CTextLayout::GetOrigin(TPoint& aPoint) const |
|
992 { |
|
993 aPoint.iX = 0; |
|
994 aPoint.iY = -iBandTop; |
|
995 } |
|
996 |
|
997 inline CTextLayout::TTagmaForwarder::TTagmaForwarder(const CTextLayout& aLayout): |
|
998 iLayout(aLayout) |
|
999 { |
|
1000 } |
|
1001 |
|
1002 inline const CTmTextLayout& CTextLayout::TTagmaForwarder::TextLayout() const |
|
1003 { |
|
1004 return iLayout.TagmaTextLayout(); |
|
1005 } |
|
1006 |
|
1007 inline void CTextLayout::TTagmaForwarder::GetOrigin(TPoint& aPoint) const |
|
1008 { |
|
1009 iLayout.GetOrigin(aPoint); |
|
1010 } |
|
1011 |
|
1012 inline const TTmHighlightExtensions& CTextLayout::HighlightExtensions() const |
|
1013 { |
|
1014 return *iHighlightExtensions; |
|
1015 } |
|
1016 |
|
1017 /** |
|
1018 Dangerous function. Makes scroll operations set the top of the screen flush to |
|
1019 the top of a line. In general this might scroll the cursor off the screen. |
|
1020 */ |
|
1021 void CTextLayout::RestrictScrollToTopsOfLines(TBool a) |
|
1022 { |
|
1023 if (a) |
|
1024 iScrollFlags |= EFScrollOnlyToTopsOfLines; |
|
1025 else |
|
1026 iScrollFlags &= ~EFScrollOnlyToTopsOfLines; |
|
1027 } |
|
1028 |
|
1029 /**Constructs a fully initialized TViewYPosQualifier object. The hotspot is |
|
1030 initialized to be the baseline of the line, the screen is not filled, and the |
|
1031 top line is not forced to be fully visible. */ |
|
1032 inline TViewYPosQualifier::TViewYPosQualifier(): |
|
1033 iHotSpot(EFViewBaseLine), |
|
1034 iFillScreen(EFalse), |
|
1035 iFullyVisible(EFViewDontForceLineFullyVisible) |
|
1036 { |
|
1037 } |
|
1038 |
|
1039 |
|
1040 /**Constructs a TViewRectChanges object, initializing its iScrollAtTop and |
|
1041 iScrollAtBottom members to zero. */ |
|
1042 inline TViewRectChanges::TViewRectChanges(): |
|
1043 iScrollAtTop(0), |
|
1044 iScrollAtBottom(0) |
|
1045 { |
|
1046 } |
|
1047 |
|
1048 /**Constructs the TCursorSelection object initialising the cursor and anchor |
|
1049 positions to zero. */ |
|
1050 inline TCursorSelection::TCursorSelection(): |
|
1051 iCursorPos(0), |
|
1052 iAnchorPos(0) |
|
1053 { |
|
1054 } |
|
1055 |
|
1056 /** Constructs the TCursorSelection object with a cursor and anchor position. |
|
1057 @param aCursorPos The cursor position. |
|
1058 @param aAnchorPos The anchor position. */ |
|
1059 inline TCursorSelection::TCursorSelection(TInt aCursorPos,TInt aAnchorPos): |
|
1060 iCursorPos(aCursorPos), |
|
1061 iAnchorPos(aAnchorPos) |
|
1062 { |
|
1063 } |
|
1064 |
|
1065 /** Sets the cursor and anchor positions for the selection. |
|
1066 @param aCursorPos The new cursor position. |
|
1067 @param aAnchorPos The new anchor position. */ |
|
1068 inline void TCursorSelection::SetSelection(TInt aCursorPos,TInt aAnchorPos) |
|
1069 { |
|
1070 iCursorPos = aCursorPos; |
|
1071 iAnchorPos = aAnchorPos; |
|
1072 } |
|
1073 |
|
1074 /** Gets the lesser of the cursor and anchor positions. |
|
1075 @return The lesser of the cursor and anchor positions. */ |
|
1076 inline TInt TCursorSelection::LowerPos() const |
|
1077 { |
|
1078 return Min(iCursorPos,iAnchorPos); |
|
1079 } |
|
1080 |
|
1081 /** Gets the greater of the cursor and anchor positions. |
|
1082 @return The greater of the cursor and anchor positions. */ |
|
1083 inline TInt TCursorSelection::HigherPos() const |
|
1084 { |
|
1085 return Max(iCursorPos,iAnchorPos); |
|
1086 } |
|
1087 |
|
1088 /** Returns the number of characters in the selected range. |
|
1089 @return The length of the selection. */ |
|
1090 inline TInt TCursorSelection::Length() const |
|
1091 { |
|
1092 return Abs(iCursorPos - iAnchorPos); |
|
1093 } |
|
1094 |
|
1095 /** Constructs the TCursorPosition object, initializing its members |
|
1096 iAnchor, iOldDocPos, iOldAnchor, iFlags, iLatentX, iLatentY to |
|
1097 zero, iLayout to NULL, and iPositioningHint to undefined. |
|
1098 */ |
|
1099 inline TCursorPosition::TCursorPosition(): |
|
1100 iAnchor(0), |
|
1101 iOldDocPos(0), |
|
1102 iOldAnchor(0), |
|
1103 iFlags(0), |
|
1104 iLatentX(0), |
|
1105 iLatentY(0), |
|
1106 iLayout(NULL), |
|
1107 iPositioningHint(EPosHintUndefined) |
|
1108 { |
|
1109 } |
|
1110 |
|
1111 /** Sets the text layout which TCursorPosition is related. |
|
1112 @param aLayout The text layout. |
|
1113 */ |
|
1114 inline void TCursorPosition::SetLayout(CTextLayout *aLayout) |
|
1115 { |
|
1116 iLayout = aLayout; |
|
1117 } |
|
1118 |
|
1119 /** Tests whether there is currently a selected region. |
|
1120 @return True if there is a selected region. False if not. */ |
|
1121 inline TBool TCursorPosition::IsSelection() const |
|
1122 { |
|
1123 return iFlags & ESelected; |
|
1124 } |
|
1125 |
|
1126 /** Tests whether there is currently a highlighted region being drawn. |
|
1127 @return True if there is a selected region. False if not. */ |
|
1128 inline TBool TCursorPosition::IsSelectionToDraw() const |
|
1129 { |
|
1130 return iFlags & (EDrawHighlight | EDrawOldPictureFrame | EDrawNewPictureFrame); |
|
1131 } |
|
1132 |
|
1133 /** Sets the flag which directs <code>GetSelection()</code> and |
|
1134 <code>IsPictureFrame()</code> to operate on the previous highlight |
|
1135 instead of the current highlight. |
|
1136 */ |
|
1137 inline void TCursorPosition::SetToPreviousHighlight() |
|
1138 { |
|
1139 iFlags |= EReturnPreviousHighlight; |
|
1140 } |
|
1141 |
|
1142 /** Clears the special flag set in <code>SetToPreviousHighlight()</code> |
|
1143 so that <code>GetSelection()</code> and <code>IsPictureFrame()</code> |
|
1144 will operate on the current highlight. |
|
1145 */ |
|
1146 inline void TCursorPosition::SetToCurrentHighlight() |
|
1147 { |
|
1148 iFlags &= ~EReturnPreviousHighlight; |
|
1149 } |
|
1150 |
|
1151 /** Removes the selection, and redraws the affected part of the screen. |
|
1152 */ |
|
1153 inline void TCursorPosition::CancelHighlight() |
|
1154 { |
|
1155 iFlags &= ~(ESelected | EDrawHighlight | EDrawOldPictureFrame | EDrawNewPictureFrame); |
|
1156 } |
|
1157 |
|
1158 /** Sets the latent horizontal text cursor position. This is the horizontal |
|
1159 coordinate to which the text cursor will be moved. |
|
1160 @param aX The horizontal coordinate to which the text cursor should be moved |
|
1161 */ |
|
1162 inline void TCursorPosition::UpdateLatentX(TInt aX) |
|
1163 { |
|
1164 iLatentX = aX; |
|
1165 } |
|
1166 |
|
1167 /** Sets the latent vertical text cursor position. This is the vertical |
|
1168 coordinate to which the text cursor will be moved. |
|
1169 @param aY The vertical coordinate to which the text cursor should be moved |
|
1170 */ |
|
1171 inline void TCursorPosition::UpdateLatentY(TInt aY) |
|
1172 { |
|
1173 iLatentY = aY; |
|
1174 } |
|
1175 |
|
1176 /** Caculate x-y position of the cursor |
|
1177 If ETrue is returned, places the position of the intersection of |
|
1178 the character edge with the baseline in aPos |
|
1179 @param aPos On return, stores the position of the intersection of |
|
1180 the character edge with the baseline |
|
1181 @return ETrue if the document is in the formatted text, otherwise EFalse. |
|
1182 */ |
|
1183 inline TBool TCursorPosition::CalculateCursorPos(TPoint& aPos) |
|
1184 { |
|
1185 TTmPosInfo2 pos_info; |
|
1186 TBool result = iLayout->FindDocPos(iDocPos,pos_info); |
|
1187 aPos = pos_info.iEdge; |
|
1188 return result; |
|
1189 } |
|
1190 |
|
1191 /** Gets the document position, the structure for holding a raw document |
|
1192 position that can be converted to or from an x-y position and compared |
|
1193 ordinally, which cannot be done with the more abstract TTmDocPosSpec class. |
|
1194 @return the document position |
|
1195 */ |
|
1196 inline const TTmDocPos& TCursorPosition::TmDocPos() const |
|
1197 { |
|
1198 return iDocPos; |
|
1199 } |
|
1200 /** Gets the edge position in the document. |
|
1201 @return the edge position in the document. |
|
1202 */ |
|
1203 inline TInt TCursorPosition::DocPos() const |
|
1204 { |
|
1205 return iDocPos.iPos; |
|
1206 } |
|
1207 |
|
1208 /** Sets the document position, the structure for holding a raw document |
|
1209 position that can be converted to or from an x-y position and compared |
|
1210 ordinally, which cannot be done with the more abstract TTmDocPosSpec class. |
|
1211 @param aDocPos the document position |
|
1212 */ |
|
1213 inline void TCursorPosition::SetDocPos(const TTmDocPos& aDocPos) |
|
1214 { |
|
1215 iDocPos = aDocPos; |
|
1216 } |
|
1217 |
|
1218 /** Tests whether the highlighted region needs to be drawn. |
|
1219 The function will be called by CTextView::UpdateHighlightL() |
|
1220 to correct the highlight after a cursor movement |
|
1221 @return True if the highlighted region needs to be drawn. False if not. */ |
|
1222 inline TBool TCursorPosition::DrawHighlight() const |
|
1223 { |
|
1224 return iFlags & EDrawHighlight; |
|
1225 } |
|
1226 |
|
1227 /** Tests whether there is a previous picture frame that needs to be drawn. |
|
1228 The function will be called by CTextView::UpdateHighlightL() |
|
1229 to correct the highlight after a cursor movement |
|
1230 @return True if there is a previous picture frame that needs to be drawn. False if not. */ |
|
1231 inline TBool TCursorPosition::DrawOldPictureFrame() const |
|
1232 { |
|
1233 return iFlags & EDrawOldPictureFrame; |
|
1234 } |
|
1235 |
|
1236 /** Tests whether there is a new picture frame that needs to be drawn. |
|
1237 The function will be called by CTextView::UpdateHighlightL() |
|
1238 to correct the highlight after a cursor movement |
|
1239 @return True if there is a new picture frame that needs to be drawn. False if not. */ |
|
1240 inline TBool TCursorPosition::DrawNewPictureFrame() const |
|
1241 { |
|
1242 return iFlags & EDrawNewPictureFrame; |
|
1243 } |
|
1244 |
|
1245 /** Sets to not draw the previous picture frame |
|
1246 */ |
|
1247 inline void TCursorPosition::DontDrawOldPictureFrame() |
|
1248 { |
|
1249 iFlags &= ~EDrawOldPictureFrame; |
|
1250 } |
|
1251 |
|
1252 #endif |