|
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 __FRMTVIEW_H__ |
|
20 #define __FRMTVIEW_H__ |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <e32base.h> |
|
24 #include <w32std.h> |
|
25 #include <frmtlay.h> |
|
26 #include <frmframe.h> |
|
27 |
|
28 /** |
|
29 Internal class - not part of interface |
|
30 @internalComponent |
|
31 */ |
|
32 class RScreenDisplay |
|
33 |
|
34 { |
|
35 public: |
|
36 enum TClippingRects |
|
37 { |
|
38 EFClipTextArea = 0x0001, |
|
39 EFClipLineCursor = 0x0002, |
|
40 EFClipExtendedTextArea = 0x0004, |
|
41 EFClipViewRect = 0x0008, |
|
42 EFClipExtendedViewRect = 0x0010, |
|
43 EFClipInvalid = 0x0200, |
|
44 EFClipAllFlags = 0xFFFF |
|
45 }; |
|
46 public: |
|
47 RScreenDisplay(TDrawTextLayoutContext* const aDrawTextLayoutContext); |
|
48 void Close(); |
|
49 void Destroy(); |
|
50 void SetWindowsServer(RWsSession *aSession) { iSession = aSession; } |
|
51 void SetWindowGroup(RWindowGroup *aWin) { iGroupWin = aWin; } |
|
52 |
|
53 void SetWindow(RWindow *aWin); |
|
54 RWindow* Window() const { return iWin; } |
|
55 void SetBitmapContext(CBitmapContext* aGc) { iGc = aGc; } |
|
56 CBitmapContext* BitmapContext() const { return iGc; } |
|
57 RWsSession* WindowServerSession() { return iSession; } |
|
58 void SetGraphicsDeviceL(CBitmapDevice *aGd); |
|
59 CBitmapDevice* BitmapDevice() const {return iGd; } |
|
60 void CreateContextL(CBitmapDevice *aGd); |
|
61 void CreateContextL(); |
|
62 void SetInvalidRect(const TRect& aRect); |
|
63 void SetInvalidRect(TInt aHeight); |
|
64 void SetInvalidRectHorizontal(TInt aWidth); |
|
65 void SetRects(TUint aRects); |
|
66 TRect LineCursorMargin() const; |
|
67 TPoint TopLeftTextArea() const; |
|
68 TBool IsLineCursor() const; |
|
69 |
|
70 void AddRects(TUint aRects); |
|
71 void SubRects(TUint aRects); |
|
72 TRect ClippingRect(); |
|
73 void ResetClippingRect(); |
|
74 void Scroll(TRect aRect,const TPoint& aBy,TBool aScrollBackground); |
|
75 void Flush(); |
|
76 void ClearRect(const TRect& aRect); |
|
77 void InvertRect(TRect aRect,const TRgb aInvertColor); |
|
78 void SetTextCursor(TPoint aPos, const TTextCursor &aCursor); |
|
79 void RemoveTextCursor(); |
|
80 void BlastBitmap(const TPoint& aPoint,const CFbsBitmap* aBitmap,const TRect& aRect); |
|
81 void DrawPictureFrame(TFrameOverlay* aPictureFrame,const TRect& aLineRect); |
|
82 void Invalidate(TRect aRect); |
|
83 void ActivateContext(); |
|
84 void ActivateContext(CGraphicsContext *aGc); |
|
85 void DeactivateContext(); |
|
86 void DeactivateContext(CGraphicsContext *aGc); |
|
87 void SetLayout(CTextLayout* aLayout); |
|
88 CTextLayout* Layout(); |
|
89 TBool UseWindowGc() const; |
|
90 |
|
91 private: |
|
92 void DestroyContexts(); |
|
93 private: |
|
94 RWsSession *iSession; |
|
95 RWindowGroup *iGroupWin; |
|
96 RWindow *iWin; |
|
97 CBitmapContext *iGc; |
|
98 CBitmapDevice *iGd; |
|
99 TDrawTextLayoutContext* const iDrawTextLayoutContext; |
|
100 TUint iRects; |
|
101 TRect iInvalidRect; |
|
102 TLogicalRgb iBackground; |
|
103 CTextLayout* iTextLayout; |
|
104 }; |
|
105 |
|
106 /** Visibility of line and text cursor. |
|
107 |
|
108 The TVisibility enumeration defined in this class is used in calls to CTextView::SetCursorVisibilityL(). |
|
109 The remainder of this class does not form part of the API. |
|
110 @internalComponent |
|
111 */ |
|
112 class TCursor |
|
113 { |
|
114 public: |
|
115 enum TCursors |
|
116 { |
|
117 EFNeitherCursor = 0, |
|
118 EFTextCursor = 1, |
|
119 EFLineCursor = 2, |
|
120 EFBothCursors = EFTextCursor | EFLineCursor |
|
121 }; |
|
122 |
|
123 /** Cursor visibility */ |
|
124 enum TVisibility |
|
125 { |
|
126 /** Indicates that the cursor should be invisible. */ |
|
127 EFCursorInvisible = 0, |
|
128 /** Indicates that the cursor should be visible. */ |
|
129 EFCursorVisible, |
|
130 /** Indicates a flashing text cursor. When specified for the line |
|
131 cursor, is equivalent to EFCursorVisible, as the line cursor cannot |
|
132 flash. Note that a non-flashing text cursor should only be used when |
|
133 there is to be no editing, reformatting, scrolling or cursor movement. |
|
134 */ |
|
135 EFCursorFlashing |
|
136 }; |
|
137 |
|
138 TCursor(TCursorPosition& aCursorPos,RScreenDisplay& aDisplay); |
|
139 void SetLineCursorBitmap(const CFbsBitmap* aLineCursorBitmap); |
|
140 inline TUint LineCursorVisibility(); |
|
141 inline TUint TextCursorVisibility(); |
|
142 void Draw(TUint aCursors); |
|
143 |
|
144 void SetVisibility(TVisibility aLineCursor,TVisibility aTextCursor); |
|
145 void SetType(TTextCursor::EType aType); |
|
146 void SetPlacement(TTmCursorPlacement aPlacement); |
|
147 void SetAscentAndDescent(TInt aAscent,TInt aDescent); |
|
148 void SetWeight(TInt aWeight); |
|
149 void SetFlash(TBool aEnabled); |
|
150 void SetXorColor(TRgb aColor); |
|
151 void MatchCursorHeightToAdjacentChar(); |
|
152 void SetExtensions(TInt aFirstExtension, TInt aSecondExtension); |
|
153 private: |
|
154 enum |
|
155 { |
|
156 ELineCursorToLabelGap = 2, |
|
157 ETextCursorWeight = 3, |
|
158 ETextCursorInvertColor = 0xFFFFFF |
|
159 }; |
|
160 |
|
161 void DrawLineCursor(TInt aHeight); |
|
162 void RemoveLineCursor(); |
|
163 void DrawTextCursor(TPoint aOrigin,TInt aWidth,TInt aAscent,TInt aDescent); |
|
164 void RemoveTextCursor(); |
|
165 |
|
166 RScreenDisplay& iDisplay; // a reference to the object controlling drawing |
|
167 TCursorPosition& iCursorPos; // a reference to the object holding the cursor's document position |
|
168 TBool iVisible; // TRUE if the text cursor is currently visible in the displayed text |
|
169 TBool iFlash; // TRUE if the text cursor should flash |
|
170 TVisibility iLineCursor; // line cursor state |
|
171 TVisibility iTextCursor; // text cursor state |
|
172 const CFbsBitmap* iLineCursorBitmap; // if non-null, points to a non-owned bitmap representing the line cursor |
|
173 TInt iAscent; // if non-negative, ascent used for vertical cursors |
|
174 TInt iDescent; // if non-negative, descent used for vertical cursors |
|
175 TInt iWeight; // width of vertical cursors, height of horizontal ones |
|
176 TTextCursor::EType iType; // filled or hollow rectangle, etc. |
|
177 TRgb iXorColor; // colour XORed with the background when the cursor is drawn |
|
178 TTmCursorPlacement iPlacement; // vertical, underline, etc. |
|
179 TInt iFirstExtension; // customise the cursor, extends vertical cursors upwards, horizontal cursors leftwards |
|
180 TInt iSecondExtension; // customise the cursor, extends vertical cursors downwards, horizontal cursors rightwards |
|
181 TInt iReserved[2]; |
|
182 }; |
|
183 |
|
184 /** |
|
185 Lays out formatted text for display. |
|
186 |
|
187 The class provides functions to: |
|
188 |
|
189 convert between document positions and x,y coordinates |
|
190 |
|
191 set the dimensions of the rectangle in which text can be viewed (the view |
|
192 rectangle) |
|
193 |
|
194 set margin widths |
|
195 |
|
196 do horizontal and vertical scrolling |
|
197 |
|
198 do text selection |
|
199 |
|
200 set the cursor position and appearance |
|
201 |
|
202 After a change has been made to the text layout, a reformat and redraw should |
|
203 normally take place. CTextView provides functions which are optimised to reformat |
|
204 the minimum amount necessary. For example, when a global formatting parameter |
|
205 is changed (e.g. the wrap width), the whole document's layout needs to be |
|
206 recalculated, so HandleGlobalChangeL() should be called. If the change involves |
|
207 the insertion or deletion of a single character, only a single line may be |
|
208 affected; for this, HandleCharEditL() is appropriate. Most CTextView reformatting |
|
209 functions do scrolling (using block transfer), if necessary, and a redraw. |
|
210 |
|
211 For maximum responsiveness, CTextView uses an active object to carry out |
|
212 reformatting as a background task, so that the application can continue to |
|
213 receive user input. Many CTextView functions force background formatting to |
|
214 complete before they take effect. |
|
215 |
|
216 When scrolling vertically, positive numbers of pixels, lines, paragraphs, |
|
217 pages, etc., mean that the text moves down, and vice versa. When scrolling |
|
218 horizontally, positive numbers of pixels mean that the text moves left and |
|
219 vice versa. |
|
220 |
|
221 A text view can display up to two cursors and up to three margins. The cursors |
|
222 are the text cursor and the line cursor. The purpose of the line cursor is |
|
223 to make it easier to see which line the text cursor (or the selection extension |
|
224 point) is on. The three margins are the label margin (for paragraph labels), |
|
225 the line cursor margin (for the line cursor) and the left text margin (the |
|
226 gap between the edge of the page and the text). All are optional, but if present, |
|
227 they appear in that order, starting at the left edge of the view rectangle. |
|
228 |
|
229 An object of class CTextLayout is used by the text view to calculate changes |
|
230 to the layout. This object must be specified when constructing the text view. |
|
231 It is also used to set layout attributes, including the wrap width, the height |
|
232 of the visible portion of the document (the "band"), whether formatting is |
|
233 set to the band or to the whole document and the text object which is the |
|
234 source of the text and formatting information. |
|
235 |
|
236 The x-y pixel coordinates used by CTextView are called window coordinates. |
|
237 Window coordinates have their origin at the top left corner of the view window |
|
238 (unlike class CTextLayout whose coordinates have their origin at the top left |
|
239 corner of the area within the view rectangle in which text can appear). As |
|
240 in most bitmap graphics systems, x coordinates increase rightwards and y coordinates |
|
241 increase downwards. |
|
242 @publishedAll |
|
243 @released |
|
244 */ |
|
245 class CTextView : public CBase |
|
246 |
|
247 { |
|
248 friend class CTestTextView; |
|
249 public: |
|
250 enum TPriorities |
|
251 { |
|
252 EFBackgroundFormattingPriority = (CActive::EPriorityIdle + CActive::EPriorityLow) / 2 |
|
253 }; |
|
254 |
|
255 /** deprecated 8.0 */ |
|
256 enum |
|
257 { |
|
258 EFFirstCharOnLine = -1000000, |
|
259 EFLastCharOnLine = 1000000 |
|
260 }; |
|
261 |
|
262 /** Cursor height matching. |
|
263 |
|
264 Passed as an argument to MatchCursorHeightToAdjacentChar(). */ |
|
265 enum TBeforeAfter |
|
266 { |
|
267 /** Text cursor height is matched to preceding character. */ |
|
268 EFCharacterBefore = ETrue, |
|
269 /** Text cursor height is matched to following character. */ |
|
270 EFCharacterAfter = EFalse |
|
271 }; |
|
272 |
|
273 |
|
274 |
|
275 /** Whether to reformat and redraw. Argument to SetViewL(). */ |
|
276 enum TDiscard |
|
277 { |
|
278 /** Discard all formatting; redraw. */ |
|
279 EFViewDiscardAllFormat, |
|
280 /** Do not discard all formatting; redraw. */ |
|
281 EFViewDontDiscardFormat, |
|
282 /** Discard all formatting; no redraw. */ |
|
283 EFViewDiscardAllNoRedraw, |
|
284 /** Do not discard all formatting; redraw. */ |
|
285 EFViewDontDiscardFullRedraw |
|
286 }; |
|
287 |
|
288 /** |
|
289 Provides notification to the owner of the text view object of changes to the |
|
290 formatting. |
|
291 |
|
292 Its OnReformatL() function is called after reformatting but before redisplay, |
|
293 so that edit windows etc. can be resized. |
|
294 @publishedAll |
|
295 @released |
|
296 */ |
|
297 class MObserver |
|
298 |
|
299 { |
|
300 public: |
|
301 |
|
302 /** Called after reformatting but before redisplay, so that the height of edit windows, etc., |
|
303 can be adjusted. There is no need to adjust the width of displaying components as formatting |
|
304 is always done to fit the specified width. |
|
305 Implementers are not allowed to call any formatting functions while handling reformatting |
|
306 notifications as it may cause recursive loops leading to unexpected consequences. |
|
307 @param aTextView A pointer to the current text view object. */ |
|
308 virtual void OnReformatL(const CTextView* aTextView) = 0; |
|
309 }; |
|
310 |
|
311 // argument to SetViewL |
|
312 enum TDoHorizontalScroll |
|
313 { |
|
314 EFNoHorizontalScroll = EFalse, |
|
315 EFCheckForHorizontalScroll = ETrue |
|
316 }; |
|
317 |
|
318 |
|
319 /** |
|
320 A standard inquiry interface for the text formatting engine, built on |
|
321 top of a CTextView object. |
|
322 |
|
323 To use it, construct a TTagmaForwarder object, then call InitL(), which |
|
324 finishes background formatting, then call the MTmTextLayoutForwarder |
|
325 functions. |
|
326 |
|
327 The class should only be used internally by FORM component. |
|
328 @publishedAll |
|
329 @released |
|
330 */ |
|
331 class TTagmaForwarder: public MTmTextLayoutForwarder |
|
332 |
|
333 { |
|
334 public: |
|
335 inline TTagmaForwarder(); |
|
336 inline void InitL(CTextView* aView); |
|
337 |
|
338 private: |
|
339 // from MTmTextLayoutForwarder |
|
340 inline const CTmTextLayout& TextLayout() const; |
|
341 inline void GetOrigin(TPoint& aPoint) const; |
|
342 |
|
343 CTextView* iView; |
|
344 }; |
|
345 |
|
346 private: |
|
347 enum TDrawParameters |
|
348 { |
|
349 EFDrawAllWindow = CLayoutData::EFLargeNumber // must be larger than the pixel height of any window. |
|
350 }; |
|
351 |
|
352 // bit values used in iFlags |
|
353 enum |
|
354 { |
|
355 EFSelectionVisible = 1, |
|
356 EFPictureFrameEnabled = 2, |
|
357 EFEverythingVisible = 3, |
|
358 EFFlickerFreeRedraw = 4, |
|
359 EFTextVisible = 8 |
|
360 }; |
|
361 |
|
362 // horizontal scroll jump in pixels |
|
363 enum THorizontalScrollJump |
|
364 { |
|
365 EFDefaultHorizontalScrollJump = 20 |
|
366 #ifdef _DEBUG |
|
367 ,EFUnreasonablyLargeHorizontalScrollJump = 10000 |
|
368 #endif |
|
369 }; |
|
370 |
|
371 // picture frame blob widths in pixels |
|
372 enum TPictureFrameBlobWidths |
|
373 { |
|
374 EFFrameVisibleBlobWidth = 10, |
|
375 EFFrameActiveBlobWidth = 20 |
|
376 }; |
|
377 |
|
378 enum THorizontalScroll |
|
379 { |
|
380 EFNoPreviousHorizontalScroll = 0, |
|
381 EFPreviousHorizontalScroll |
|
382 }; |
|
383 |
|
384 enum TMemoryStatus |
|
385 { |
|
386 EFMemoryOK, |
|
387 EFOutOfMemory, |
|
388 EFRecovering |
|
389 }; |
|
390 |
|
391 enum TExtendedHighlightRedraw |
|
392 { |
|
393 EFTopEdge = 0x0001, |
|
394 EFBottomEdge = 0x0002 |
|
395 }; |
|
396 |
|
397 |
|
398 public: |
|
399 IMPORT_C static CTextView *NewL(CTextLayout* aLayout,const TRect &aDisplay,CBitmapDevice* aGd, |
|
400 MGraphicsDeviceMap* aDeviceMap,RWindow* aWin,RWindowGroup* aGroupWin, |
|
401 RWsSession* aSession); |
|
402 IMPORT_C ~CTextView(); |
|
403 IMPORT_C void SetDisplayContextL(CBitmapDevice* aGd,RWindow* aWin,RWindowGroup* aGroupWin,RWsSession* aSession); |
|
404 IMPORT_C void SetLayout(CTextLayout* aLayout); |
|
405 inline const CTextLayout* Layout() const; |
|
406 IMPORT_C void SetViewRect(const TRect& aDisplay); |
|
407 IMPORT_C void AlterViewRect(const TRect &aViewRect); |
|
408 IMPORT_C void SetMarginWidths(TInt aLabels,TInt aLineCursor); |
|
409 IMPORT_C void SetHorizontalScrollJump(TInt aScrollJump); |
|
410 IMPORT_C void SetLineCursorBitmap(const CFbsBitmap* aLineCursorBitmap); |
|
411 IMPORT_C void SetHighlightExtensions(TInt aLeftExtension, TInt aRightExtension, TInt aTopExtension, TInt aBottomExtension); |
|
412 IMPORT_C void SetExcessHeightRequired(TInt aExcessHeightRequired); |
|
413 IMPORT_C void SetBackgroundColor(TRgb aColor); |
|
414 IMPORT_C void SetTextColorOverride(const TRgb* aOverrideColor = NULL); |
|
415 IMPORT_C void SetCursorVisibilityL(TUint aLineCursor,TUint aTextCursor); |
|
416 IMPORT_C void SetSelectionVisibilityL(TBool aSelectionVisible); |
|
417 IMPORT_C TBool SelectionVisible() const; |
|
418 IMPORT_C void EnablePictureFrameL(TBool aEnabled); |
|
419 IMPORT_C const TRect& ViewRect() const; |
|
420 IMPORT_C const TRect& AlteredViewRect() const; |
|
421 IMPORT_C void MarginWidths(TInt& aLabels,TInt& aLineCursor) const; |
|
422 IMPORT_C TInt HorizontalScrollJump() const; |
|
423 IMPORT_C TInt LeftTextMargin() const; |
|
424 IMPORT_C void SetLatentXPosition(TInt aLatentX); |
|
425 // deprecated 7.0 |
|
426 IMPORT_C void SetParagraphFillTextOnly(TBool aFillTextOnly); |
|
427 IMPORT_C void SetCursorWidthTypeL(TTextCursor::EType aType,TInt aWidth = 0); |
|
428 IMPORT_C void SetCursorPlacement(TTmCursorPlacement aPlacement); |
|
429 IMPORT_C void SetCursorWeight(TInt aWeight); |
|
430 IMPORT_C void SetCursorFlash(TBool aEnabled); |
|
431 IMPORT_C void SetCursorXorColor(TRgb aColor); |
|
432 IMPORT_C void SetCursorExtensions(TInt aFirstExtension, TInt aSecondExtension); |
|
433 IMPORT_C TCursorSelection Selection() const; |
|
434 IMPORT_C TBool IsPictureFrameSelected(TRect& aPictureFrameRect,TInt& aDocPos) const; |
|
435 IMPORT_C TBool GetPictureRectangleL(TInt aDocPos,TRect& aPictureRect,TBool* aCanScaleOrCrop = NULL) const; |
|
436 IMPORT_C TBool GetPictureRectangleL(TPoint aXyPos,TRect& aPictureRect,TBool* aCanScaleOrCrop = NULL); |
|
437 IMPORT_C TBool FindXyPosL(const TPoint& aXyPos,TTmPosInfo2& aPosInfo,TTmLineInfo* aLineInfo = NULL); |
|
438 IMPORT_C TInt XyPosToDocPosL(TPoint& aPoint); |
|
439 IMPORT_C TBool FindDocPosL(const TTmDocPosSpec& aDocPos,TTmPosInfo2& aPosInfo,TTmLineInfo* aLineInfo = NULL); |
|
440 IMPORT_C TBool DocPosToXyPosL(TInt aDocPos,TPoint& aPoint); |
|
441 IMPORT_C TRect ParagraphRectL(TInt aDocPos) const; |
|
442 IMPORT_C void CalculateHorizontalExtremesL(TInt& aLeftX,TInt& aRightX,TBool aOnlyVisibleLines); |
|
443 IMPORT_C void MatchCursorHeightL(const TFontSpec& aFontSpec); |
|
444 IMPORT_C void MatchCursorHeightToAdjacentChar(TBeforeAfter aBasedOn = EFCharacterBefore); |
|
445 IMPORT_C TPoint SetSelectionL(const TCursorSelection& aSelection); |
|
446 IMPORT_C void CancelSelectionL(); |
|
447 IMPORT_C void ClearSelectionL(); |
|
448 IMPORT_C TPoint SetDocPosL(const TTmDocPosSpec& aDocPos,TBool aDragSelectOn = EFalse); |
|
449 IMPORT_C TPoint SetDocPosL(TInt aDocPos,TBool aDragSelectOn = EFalse); |
|
450 IMPORT_C TPoint SetXyPosL(TPoint aPos,TBool aDragSelectOn,TRect*& aPictureRect,TInt& aPictureFrameEdges); |
|
451 IMPORT_C TPoint MoveCursorL(TCursorPosition::TMovementType& aMovement,TBool aDragSelectOn); |
|
452 IMPORT_C TInt ScrollDisplayL(TCursorPosition::TMovementType aMovement, |
|
453 CTextLayout::TAllowDisallow aScrollBlankSpace=CTextLayout::EFDisallowScrollingBlankSpace); |
|
454 IMPORT_C TPoint SetViewLineAtTopL(TInt aLineNo); |
|
455 IMPORT_C void ScrollDisplayPixelsL(TInt& aDeltaY); |
|
456 IMPORT_C void ScrollDisplayPixelsNoLimitBorderL(TInt aDeltaY); |
|
457 IMPORT_C TInt ScrollDisplayLinesL(TInt& aDeltaLines, |
|
458 CTextLayout::TAllowDisallow aScrollBlankSpace = CTextLayout::EFDisallowScrollingBlankSpace); |
|
459 IMPORT_C TInt ScrollDisplayParagraphsL(TInt& aDeltaParas, |
|
460 CTextLayout::TAllowDisallow aScrollBlankSpace = CTextLayout::EFDisallowScrollingBlankSpace); |
|
461 IMPORT_C TPoint SetViewL(TInt aDocPos,TInt& aYPos,TViewYPosQualifier aYPosQualifier = TViewYPosQualifier(), |
|
462 TDiscard aDiscardFormat = EFViewDontDiscardFormat, |
|
463 TDoHorizontalScroll aDoHorizontalScroll = EFCheckForHorizontalScroll); |
|
464 IMPORT_C void SetLeftTextMargin(TInt aLeftMargin); |
|
465 IMPORT_C void DrawL(TRect aRect); |
|
466 IMPORT_C void DrawL(TRect aRect,CBitmapContext& aGc); |
|
467 inline void SetObserver(MObserver* aObserver); |
|
468 IMPORT_C void SetPendingSelection(const TCursorSelection& aSelection); |
|
469 inline void EnableFlickerFreeRedraw(); |
|
470 inline void DisableFlickerFreeRedraw(); |
|
471 inline TBool FlickerFreeRedraw() const; |
|
472 inline void GetOrigin(TPoint& aPoint) const; |
|
473 IMPORT_C TCursorSelection GetForwardDeletePositionL(); |
|
474 IMPORT_C TCursorSelection GetBackwardDeletePositionL(); |
|
475 |
|
476 // reformatting after changes to the content |
|
477 IMPORT_C void FormatTextL(); |
|
478 IMPORT_C TInt HandleCharEditL(TUint aType = CTextLayout::EFCharacterInsert,TBool aFormatChanged = EFalse); |
|
479 IMPORT_C TPoint HandleRangeFormatChangeL(TCursorSelection aSelection,TBool aFormatChanged = EFalse); |
|
480 IMPORT_C TPoint HandleInsertDeleteL(TCursorSelection aSelection,TInt aDeletedChars,TBool aFormatChanged = EFalse); |
|
481 IMPORT_C void HandleGlobalChangeL(TViewYPosQualifier aYPosQualifier = TViewYPosQualifier()); |
|
482 IMPORT_C void HandleGlobalChangeNoRedrawL(TViewYPosQualifier aYPosQualifier = TViewYPosQualifier()); |
|
483 IMPORT_C void HandleAdditionalCharactersAtEndL(); |
|
484 IMPORT_C void FinishBackgroundFormattingL(); |
|
485 |
|
486 IMPORT_C CBitmapContext* BitmapContext(); |
|
487 IMPORT_C const TTmDocPos& VisualEndOfRunL( |
|
488 const TTmDocPos& aStart, const TTmDocPos& aEnd, |
|
489 TCursorPosition::TVisualEnd aDirection); |
|
490 IMPORT_C void GetCursorPos(TTmDocPos& aPos) const; |
|
491 |
|
492 IMPORT_C TPoint SetDocPosL(const TTmDocPos& aDocPos,TBool aDragSelectOn = EFalse); |
|
493 |
|
494 IMPORT_C void SetCursorPositioningHintL(TCursorPosition::TPosHint aHint); |
|
495 |
|
496 IMPORT_C void SetOpaque(TBool aDrawOpaque); |
|
497 IMPORT_C void MakeVisible(TBool aVisible); |
|
498 |
|
499 private: |
|
500 IMPORT_C static TInt IdleL(TAny *aSelf); |
|
501 IMPORT_C CTextView(); |
|
502 IMPORT_C void ConstructL(CTextLayout* aLayout,const TRect &aDisplay,CBitmapDevice* aGd,MGraphicsDeviceMap* aDeviceMap, |
|
503 RWindow* aWin,RWindowGroup* aGroupWin,RWsSession* aSession); |
|
504 inline TInt TopViewRect() const; |
|
505 inline TBool IsFormatting() const; |
|
506 TBool NoMemoryCheckL(); |
|
507 void StartIdleObject(); |
|
508 inline void DrawWithPreviousHighlight(); |
|
509 inline void DrawWithCurrentHighlight(); |
|
510 TInt CalculateBaseLinePos(TTmDocPos& aDocPos); |
|
511 TInt DrawAfterCursorMoveL(TInt aVerticalScrollBy); |
|
512 TBool NextLineL(); |
|
513 void ClearRectAtBottom(TInt aHeight); |
|
514 void DrawTextL(TInt aFromHeight = 0,TInt aToHeight = EFDrawAllWindow); |
|
515 void DisplayNewLinesL(TInt aFrom,TInt aTo); |
|
516 void DrawCursor(TUint aCursors = TCursor::EFBothCursors); |
|
517 TPoint DoMoveCursorL(TBool aDragSelectOn,TCursorPosition::TMovementType& aMovement,TBool aAllowPictureFrame); |
|
518 void ScrollTextL(TInt aScrollY,TInt aFrom,TInt aScrollX,TBool aScrollBackground); |
|
519 void ScrollRect(TRect& aRect,TInt aScrollY,TInt aFrom,TInt aScrollX,TBool aScrollBackground); |
|
520 void ScrollRect(TInt aScrollY,TInt& aFrom,TInt& aTo); |
|
521 TPoint HandleBlockChangeL(TCursorSelection aSelection,TInt aOldCharsChanged,TBool aFormatChanged); |
|
522 void CheckScrollUpL(); |
|
523 TInt CheckHorizontalScroll(const TTmDocPos& aDocPos); |
|
524 TInt DoHorizontalScrollDisplayL(TCursorPosition::TMovementType aMovement, |
|
525 CTextLayout::TAllowDisallow aScrollBlankSpace); |
|
526 TInt DoScrollDisplayL(TCursorPosition::TMovementType aMovement,CTextLayout::TAllowDisallow aScrollBlankSpace); |
|
527 void ScrollDisplayL(); |
|
528 TPoint ViewTopOfLineL(const TTmDocPos& aDocPos,TInt& aYPos, |
|
529 CTextView::TDiscard aDiscardFormat = EFViewDontDiscardFormat, |
|
530 TDoHorizontalScroll aHorizontalScroll = EFCheckForHorizontalScroll); |
|
531 TPoint ViewL(const TTmDocPos& aDocPos,TInt& aYPos,TViewYPosQualifier aYPosQualifier = TViewYPosQualifier(), |
|
532 CTextView::TDiscard aDiscardFormat = EFViewDontDiscardFormat, |
|
533 TDoHorizontalScroll aHorizontalScroll = EFCheckForHorizontalScroll); |
|
534 TPoint DoHandleGlobalChangeL(TViewYPosQualifier aYPosQualifier,CTextView::TDiscard aDiscard); |
|
535 void UpdateHighlightL(); |
|
536 void HighlightUsingExtensions(CTextLayout::TRangeChange aOptimizedRange, CTextLayout::TRangeChange aOriginalRange); |
|
537 void UpdatePictureFrameL(); |
|
538 void RedrawPictureFrameRectL(TInt aPos); |
|
539 void DrawPictureFrameL(TRect& aClipRect); |
|
540 void DestroyWindowServerObjects(); |
|
541 void NoMemoryL(TInt aErr); |
|
542 void RecoverNoMemoryL(); |
|
543 void RecreateWindowServerObjectsL(); |
|
544 void DrawTextSupportL(const TRect& aRect,const TCursorSelection* aHighlight); |
|
545 void DoDrawTextSupportL(const TRect& aRect,const TCursorSelection* aHighlight); |
|
546 void DoDrawTextSupportOpaqueL(const TRect& aRect,const TCursorSelection* aHighlight); |
|
547 void DisplayLineRangeL(TInt aFrom,TInt aTo); |
|
548 inline void NotifyReformatL(); |
|
549 void CalculateHorizontalExtremes(TInt& aLeftX,TInt& aRightX,TBool aOnlyVisibleLines); |
|
550 TBool ExtendedHighlightExists() const; |
|
551 void DoClearSelectionL(const TCursorSelection& aSelection, TBool aIsPictureFrame); |
|
552 void AdjustRectForScrolling(TRect &aRect, TInt aScrollY, TInt aScrollX) const; |
|
553 static void ResetOffScreenBitmapContext(TAny* aTextView); |
|
554 static void ResetExternalDraw(TAny* aTextView); |
|
555 |
|
556 private: |
|
557 CIdle* iWrap; |
|
558 RScreenDisplay iDisplay; |
|
559 CTextLayout* iLayout; // must not be moved |
|
560 TDrawTextLayoutContext iDrawTextLayoutContext; // must not be moved |
|
561 TCursor iCursor; |
|
562 TCursorPosition iCursorPos; // must not be moved |
|
563 TFrameOverlay* iPictureFrame; |
|
564 TMemoryStatus iNoMemory; |
|
565 TUint iFlags; // must not be moved |
|
566 TUint iHorizontalScroll; |
|
567 TInt iGood; |
|
568 TInt iFormattedUpTo; |
|
569 TInt iHorizontalScrollJump; |
|
570 TInt iHeightNotDrawn; |
|
571 MObserver* iObserver; // must not be moved |
|
572 CBitmapContext* iOffScreenContext; //Explicit off-screen bitmap to draw to. |
|
573 TRect iReducedDrawingAreaRect; |
|
574 TUint iDummy;// was iRedrawExtendedHighlight; |
|
575 TBool iContextIsNavigation; |
|
576 TBool iDrawOpaque; |
|
577 }; |
|
578 |
|
579 inline TUint TCursor::LineCursorVisibility() |
|
580 { |
|
581 return iLineCursor; |
|
582 } |
|
583 |
|
584 inline TUint TCursor::TextCursorVisibility() |
|
585 { |
|
586 return iTextCursor; |
|
587 } |
|
588 |
|
589 /** Returns a pointer to the text layout object used by the text view. |
|
590 @return A pointer to the text layout object used by the text view. */ |
|
591 inline const CTextLayout* CTextView::Layout() const |
|
592 { |
|
593 return iLayout; |
|
594 } |
|
595 |
|
596 /** Sets a text view observer. This provides notification to the owner of the |
|
597 text view object of changes to the formatting. Its OnReformatL() function is |
|
598 called after reformatting but before redisplay, so that edit windows etc. can |
|
599 be resized. |
|
600 |
|
601 @param aObserver Pointer to text view observer object. */ |
|
602 inline void CTextView::SetObserver(MObserver* aObserver) |
|
603 { |
|
604 iObserver = aObserver; |
|
605 } |
|
606 |
|
607 inline void CTextView::EnableFlickerFreeRedraw() |
|
608 { |
|
609 iFlags |= EFFlickerFreeRedraw; |
|
610 } |
|
611 |
|
612 inline void CTextView::DisableFlickerFreeRedraw() |
|
613 { |
|
614 iFlags &= ~EFFlickerFreeRedraw; |
|
615 } |
|
616 |
|
617 inline TBool CTextView::FlickerFreeRedraw() const |
|
618 { |
|
619 return iFlags & EFFlickerFreeRedraw; |
|
620 } |
|
621 |
|
622 inline void CTextView::NotifyReformatL() |
|
623 { |
|
624 if (iObserver) |
|
625 iObserver->OnReformatL(this); |
|
626 } |
|
627 |
|
628 inline TBool CTextView::IsFormatting() const |
|
629 { |
|
630 return iLayout->IsBackgroundFormatting(); |
|
631 } |
|
632 |
|
633 inline TInt CTextView::TopViewRect() const |
|
634 { |
|
635 return iDrawTextLayoutContext.iViewRect.iTl.iY; |
|
636 } |
|
637 |
|
638 inline void CTextView::DrawWithPreviousHighlight() |
|
639 { |
|
640 iCursorPos.SetToPreviousHighlight(); |
|
641 } |
|
642 |
|
643 inline void CTextView::DrawWithCurrentHighlight() |
|
644 { |
|
645 iCursorPos.SetToCurrentHighlight(); |
|
646 } |
|
647 |
|
648 /** Gets the origin of the cursor. |
|
649 @param aPoint On return, the cursor origin. */ |
|
650 inline void CTextView::GetOrigin(TPoint& aPoint) const |
|
651 { |
|
652 iLayout->GetOrigin(aPoint); |
|
653 aPoint += iDrawTextLayoutContext.TopLeftText(); |
|
654 } |
|
655 |
|
656 /** This constructor deliberately does not take a pointer or reference to |
|
657 CTextView, to prevent the class from being used unless InitL() is called. */ |
|
658 inline CTextView::TTagmaForwarder::TTagmaForwarder(): |
|
659 iView(NULL) |
|
660 { |
|
661 } |
|
662 |
|
663 /** Called after construction, to complete background reformatting. |
|
664 @param aView A pointer to the text view object. */ |
|
665 inline void CTextView::TTagmaForwarder::InitL(CTextView* aView) |
|
666 { |
|
667 iView = aView; |
|
668 iView->FinishBackgroundFormattingL(); |
|
669 } |
|
670 |
|
671 inline const CTmTextLayout& CTextView::TTagmaForwarder::TextLayout() const |
|
672 { |
|
673 return iView->Layout()->TagmaTextLayout(); |
|
674 } |
|
675 |
|
676 inline void CTextView::TTagmaForwarder::GetOrigin(TPoint& aPoint) const |
|
677 { |
|
678 iView->GetOrigin(aPoint); |
|
679 } |
|
680 |
|
681 #endif |