|
1 /* |
|
2 * Copyright (c) 2005-2006 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: header file of base class for Edwin-like editing area |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CFEPLAYOUTEDITAREABASE_H |
|
20 #define C_CFEPLAYOUTEDITAREABASE_H |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <e32base.h> |
|
24 #include <w32std.h> |
|
25 #include <frmtlay.h> |
|
26 #include <fepbase.h> |
|
27 #include <fepitfr.h> |
|
28 #include <eikdialg.h> |
|
29 #include <eikenv.h> |
|
30 |
|
31 #include "peninputlayoutbasecontrol.h" |
|
32 #include <bidivisual.h> |
|
33 |
|
34 // FORWARD DECLARATIONS |
|
35 class CInsertionPoint; |
|
36 |
|
37 const TInt KCursorSelectionGap = 4; |
|
38 |
|
39 /** |
|
40 * Base class for lightweight Edwin-like editing area |
|
41 * |
|
42 * This is not an actual |
|
43 * control and it never actually gains focus, but it simulates it with its |
|
44 * own cursor. This is because the FEP must never take focus, because otherwise |
|
45 * it will mess up the functionality of the underlying application. |
|
46 * |
|
47 * @lib feplayouteng.lib |
|
48 * @since S60 v4.0 |
|
49 */ |
|
50 class CFepLayoutEditAreaBase : public CFepUiBaseCtrl |
|
51 { |
|
52 public: |
|
53 // Constructors and destructor |
|
54 /** |
|
55 * Destructor. |
|
56 * |
|
57 * @since S60 v4.0 |
|
58 */ |
|
59 IMPORT_C virtual ~CFepLayoutEditAreaBase(); |
|
60 |
|
61 /** |
|
62 * Draws the text buffer into the given graphic context |
|
63 * |
|
64 * @since S60 v4.0 |
|
65 * @param aGc The graphic context |
|
66 * @param aRect Invalid rectangle. Edit area is redrawn only if |
|
67 * the invalid rectangle intersects with the rectangle of the edit area |
|
68 */ |
|
69 IMPORT_C virtual void DrawContent(CBitmapContext* aGc, const TRect& aRect); |
|
70 |
|
71 /** |
|
72 * Sets the position, where caret is in the buffer. |
|
73 * |
|
74 * @since S60 v4.0 |
|
75 * @param aPositionOfInsertionPointInBuffer The position |
|
76 */ |
|
77 IMPORT_C void SetPositionOfInsertionPointInBuffer( |
|
78 TInt& aPositionOfInsertionPointInBuffer); |
|
79 |
|
80 /** |
|
81 * Sets the position, where caret is in the buffer, |
|
82 * including the start of the selection. |
|
83 * |
|
84 * @since S60 v4.0 |
|
85 * @param aPositionOfInsertionPointInBuffer The position |
|
86 */ |
|
87 void SetPositionOfInsertionPointInBuffer( |
|
88 TInt& aPositionOfInsertionPointInBuffer, |
|
89 TInt& aPositionOfAnchorInBuffer); |
|
90 |
|
91 |
|
92 /** |
|
93 * Adjust cursor position when pointer down or move |
|
94 * |
|
95 * @since S60 v4.0 |
|
96 * @param aPositionOfInsertionPointInBuffer The position |
|
97 * @return None |
|
98 */ |
|
99 IMPORT_C virtual void AdjustSelectedCompositionText(TInt& aPositionOfInsertionPointInBuffer); |
|
100 |
|
101 /** |
|
102 * Returns the cursor position relative to parent window |
|
103 * |
|
104 * @since S60 v4.0 |
|
105 * @return Postition of cursor as pixels |
|
106 */ |
|
107 IMPORT_C TPoint PositionOfInsertionPointOnWindow(); |
|
108 |
|
109 /** |
|
110 * Returns the selected text. |
|
111 * |
|
112 * @since S60 v4.0 |
|
113 * @return Selection range of the text |
|
114 */ |
|
115 inline TCursorSelection Selection() const; |
|
116 |
|
117 /** |
|
118 * Sets the text color. |
|
119 * |
|
120 * @since S60 v4.0 |
|
121 * @param aColor RGB-value of the text color |
|
122 */ |
|
123 IMPORT_C void SetTextColor(const TRgb aColor); |
|
124 |
|
125 /** |
|
126 * Tests if the field has focus. |
|
127 * |
|
128 * @since S60 v4.0 |
|
129 * @return ETrue if it has focus, otherwise EFalse |
|
130 */ |
|
131 IMPORT_C TBool IsFocused(); |
|
132 |
|
133 IMPORT_C void SetTextAlignmentL(TInt aAlignment); |
|
134 |
|
135 /** |
|
136 * Sets the text to be displayed |
|
137 * |
|
138 * @since S60 v4.0 |
|
139 * @param cursorSel Current cursor selection |
|
140 * @param aText The text to be set in fep ui |
|
141 * @return None |
|
142 */ |
|
143 IMPORT_C void SetTextL( const TFepInputContextFieldData& aData ); |
|
144 |
|
145 /** |
|
146 * Sets dim |
|
147 * |
|
148 * @since S60 v4.0 |
|
149 * @param aDimFlag Dim flag, ETrue for dim |
|
150 * @return None |
|
151 */ |
|
152 IMPORT_C void SetDimmed(TBool aDimFlag); |
|
153 |
|
154 /** |
|
155 * Get dim |
|
156 * |
|
157 * @since S60 v4.0 |
|
158 * @return ETrue for dim otherwise EFlase |
|
159 */ |
|
160 inline TBool IsDimmed() const; |
|
161 |
|
162 /** |
|
163 * Sets the cursor |
|
164 * |
|
165 * @since S60 v4.0 |
|
166 * @param cursorSel Current cursor selection |
|
167 * @return None |
|
168 */ |
|
169 IMPORT_C void UpdateCursorSelection(const TCursorSelection& aCursorSel); |
|
170 |
|
171 /** |
|
172 * Update content when scrolling |
|
173 * |
|
174 * @since S60 v4.0 |
|
175 * @param cursorSel Current cursor selection |
|
176 * @return None |
|
177 */ |
|
178 virtual void UpdateContent(const TCursorSelection& aCursorSel) = 0; |
|
179 |
|
180 /** |
|
181 * Set the font for text drawing |
|
182 * |
|
183 * @since S60 v4.0 |
|
184 * @param aFontSpect font information |
|
185 */ |
|
186 IMPORT_C void SetFont(const TFontSpec& aFontSpec); |
|
187 |
|
188 /** |
|
189 * Set the font for text drawing |
|
190 * |
|
191 * @since S60 v4.0 |
|
192 * @param aFont The font to be used.Ownership not transferred |
|
193 */ |
|
194 IMPORT_C void SetFont(const CFont* aFont); |
|
195 |
|
196 /** |
|
197 * Set editor focus |
|
198 * |
|
199 * @since S60 v4.0 |
|
200 * @param aFlag current focus. Default value is ETrue |
|
201 */ |
|
202 IMPORT_C void SetFocus(TBool aFlag = ETrue); |
|
203 |
|
204 /** |
|
205 * Set cursor visibility |
|
206 * |
|
207 * @since S60 v4.0 |
|
208 * @param aFlag ETrue for visisble, EFalse for invisible |
|
209 */ |
|
210 IMPORT_C void SetCursorVisible(TBool aCursorVisibleFlag = ETrue, |
|
211 TBool aCursorSelVisibleFlag = EFalse); |
|
212 |
|
213 /** |
|
214 * Get the text length of buffer |
|
215 * |
|
216 * @since S60 v4.0 |
|
217 * @return The buffer length |
|
218 */ |
|
219 inline TInt TextLength() const; |
|
220 |
|
221 /** |
|
222 * Get cursor visibility |
|
223 * |
|
224 * @since S60 v4.0 |
|
225 * @return ETrue for visisble, EFalse for invisible |
|
226 */ |
|
227 IMPORT_C TBool CursorVisible() const; |
|
228 |
|
229 //from base class CFepUiBaseCtrl |
|
230 /** |
|
231 * From CFepUiBaseCtrl |
|
232 * Draw control |
|
233 * |
|
234 * @since S60 v4.0 |
|
235 */ |
|
236 IMPORT_C void Draw(); |
|
237 |
|
238 /** |
|
239 * From CFepUiBaseCtrl |
|
240 * Sets the rectangle for the edit area. |
|
241 * |
|
242 * @since S60 v4.0 |
|
243 * @param aRect The rectangle |
|
244 */ |
|
245 IMPORT_C void SetRect(TRect aRect); |
|
246 |
|
247 /** |
|
248 * From CFepUiBaseCtrl |
|
249 * Move conntrol |
|
250 * |
|
251 * @since S60 V4.0 |
|
252 * @param aOffset The offset to be moved |
|
253 */ |
|
254 IMPORT_C void Move(const TPoint& aOffset); |
|
255 |
|
256 /** |
|
257 * From CFepUiBaseCtrl |
|
258 * Handle pointer down event |
|
259 * |
|
260 * @since S60 4.0 |
|
261 * @param aPoint The point position relative the layout |
|
262 * @return The control which handles the event. |
|
263 */ |
|
264 IMPORT_C virtual CFepUiBaseCtrl* HandlePointerDownEventL(const TPoint& aPoint); |
|
265 |
|
266 /** |
|
267 * From CFepUiBaseCtrl |
|
268 * Handle pointer move event |
|
269 * |
|
270 * @since S60 v4.0 |
|
271 * @param aPoint The point position relative the layout |
|
272 * @return The control which handles the event. |
|
273 */ |
|
274 IMPORT_C virtual CFepUiBaseCtrl* HandlePointerMoveEventL(const TPoint& aPoint); |
|
275 |
|
276 /** |
|
277 * From CFepUiBaseCtrl |
|
278 * Handle pointer up event |
|
279 * |
|
280 * @since S60 v4.0 |
|
281 * @param aPoint The point position relative the layout |
|
282 * @return The control which handles the event. |
|
283 */ |
|
284 IMPORT_C virtual CFepUiBaseCtrl* HandlePointerUpEventL(const TPoint& aPoint); |
|
285 |
|
286 /** |
|
287 * From CFepUiBaseCtrl |
|
288 * Update rect area |
|
289 * |
|
290 * @since S60 v4.0 |
|
291 * @param aRect the rect to be flushed in screen |
|
292 * @param aUpdateFlag ETrue if full update. |
|
293 */ |
|
294 //void UpdateArea(const TRect& aRect,TBool aUpdateFlag = EFalse); |
|
295 |
|
296 |
|
297 /** |
|
298 * From CFepUiBaseCtrl |
|
299 * Cancel pointer down event. |
|
300 * This will be called when a control has pointer down but pointer up |
|
301 * event happens in other ways. |
|
302 * |
|
303 * @since S60 V4.0 |
|
304 * @param aFocusedFlag ETrue if got focused, otherwise EFalse |
|
305 */ |
|
306 IMPORT_C virtual void CancelPointerDownL(); |
|
307 |
|
308 /** |
|
309 * From CFepUiBaseCtrl |
|
310 * Handle pointer levae event. |
|
311 * This will be called only when it's got pointer down event before and |
|
312 * now pointer leaves without pointer up event |
|
313 * |
|
314 * @since S60 V4.0 |
|
315 * @param aPoint current pointer position |
|
316 */ |
|
317 IMPORT_C virtual void HandlePointerLeave(const TPoint& aPoint); |
|
318 |
|
319 /** |
|
320 * From CFepUiBaseCtrl |
|
321 * Handle pointer enter event. |
|
322 * This will be called only when it's got pointer down event before and |
|
323 * pointer leaves but now comes back without pointer up event. |
|
324 * |
|
325 * @since S60 V4.0 |
|
326 * @param aPoint current pointer position |
|
327 */ |
|
328 // IMPORT_C virtual void HandlePointerEnter(const TPoint& aPoint); |
|
329 |
|
330 /** |
|
331 * OnActivate. Called when the layout is going to be shown. |
|
332 * |
|
333 * @since S60 v4.0 |
|
334 */ |
|
335 IMPORT_C void OnActivate(); |
|
336 |
|
337 /** |
|
338 * OnDeActivate. Called when the layout is going to be hidden |
|
339 * |
|
340 * @since S60 v4.0 |
|
341 */ |
|
342 IMPORT_C void OnDeActivate(); |
|
343 |
|
344 /** |
|
345 * From CFepUiBaseCtrl |
|
346 * Call back function when layout starts dragging |
|
347 * |
|
348 * @since S60 V4.0 |
|
349 */ |
|
350 IMPORT_C void OnLayoutDraggingStart(); |
|
351 |
|
352 /** |
|
353 * From CFepUiBaseCtrl |
|
354 * Call back function when layout ends dragging |
|
355 * |
|
356 * @since S60 V4.0 |
|
357 */ |
|
358 IMPORT_C void OnLayoutDraggingEnd(); |
|
359 |
|
360 /** |
|
361 * Get the editor max length. |
|
362 * This is the max char length which this editor can holds |
|
363 * |
|
364 * @since S60 V4.0 |
|
365 * @return The editor max length |
|
366 */ |
|
367 IMPORT_C virtual TInt GetEditorFieldMaxLen(); |
|
368 |
|
369 /** |
|
370 * Update control's valid region when other control hiding or displaying. |
|
371 * This is usually used for HWR window to change it's writing area. |
|
372 * |
|
373 * @since S60 V4.0 |
|
374 * @param aCtrl The control whose displaying status changed |
|
375 * @param bFlag ETrue if control is hiden, otherwise EFalse |
|
376 */ |
|
377 IMPORT_C virtual void UpdateValidRegion(CFepUiBaseCtrl* aCtrl,TBool aRemoveFlag); |
|
378 |
|
379 |
|
380 inline void SetTextIsSecret( TBool aIsSecret ); |
|
381 |
|
382 inline TBool TextIsSecret() const; |
|
383 |
|
384 protected: // Methods |
|
385 |
|
386 /** |
|
387 * C++ default constructor. |
|
388 * |
|
389 * @since S60 v4.0 |
|
390 * @param aRect Control area |
|
391 * @param aUiLayout The layout which contains this control |
|
392 * @param aControlId The control Id |
|
393 */ |
|
394 IMPORT_C CFepLayoutEditAreaBase(TRect aRect,CFepUiLayout* aUiLayout,TInt aControlId); |
|
395 |
|
396 /** |
|
397 * By default Symbian 2nd phase constructor is private. |
|
398 * |
|
399 * @since S60 v4.0 |
|
400 * @param aVisibleCursor ETrue if visible cursor is required |
|
401 */ |
|
402 IMPORT_C void BaseConstructL(); |
|
403 |
|
404 /** |
|
405 * Handles taps, i.e. moves insertion point and selects text. |
|
406 * |
|
407 * @since S60 v4.0 |
|
408 * @param aPointerEvent Information about the pointer event. |
|
409 */ |
|
410 //IMPORT_C virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
411 |
|
412 /** |
|
413 * Prepares the field for losing focus. |
|
414 * |
|
415 * @since S60 v4.0 |
|
416 */ |
|
417 IMPORT_C virtual void PrepareForFocusLoss(); |
|
418 |
|
419 /** |
|
420 * Prepares the field for gaining focus. |
|
421 * |
|
422 * @since S60 v4.0 |
|
423 * @return The operation status. ETrue if successfully. |
|
424 */ |
|
425 IMPORT_C virtual TBool PrepareForFocusGain(); |
|
426 |
|
427 /** |
|
428 * Returns the position in buffer for given x-coordinate |
|
429 * |
|
430 * @since S60 v4.0 |
|
431 * @param aX X-coordinate |
|
432 * @return Position in buffer |
|
433 */ |
|
434 IMPORT_C TInt PositionInDisplayText(TInt aX) const; |
|
435 |
|
436 /** |
|
437 * Calcuate display text |
|
438 * |
|
439 * @since S60 v4.0 |
|
440 * @return None |
|
441 */ |
|
442 void CalculateDisplayTextL(); |
|
443 |
|
444 /** |
|
445 * Gives coordinates of the character relative to the parent |
|
446 * window. |
|
447 * |
|
448 * @since S60 v4.0 |
|
449 * @param aCharacterIndex index of the character in iRenderBuffer |
|
450 * @return Position as TPoint relative to the parent window, |
|
451 */ |
|
452 IMPORT_C TPoint PositionInWindow(TInt aCharacterIndex); |
|
453 |
|
454 /** |
|
455 * Scrolls selection to the left exposing more text |
|
456 * |
|
457 * @since S60 v4.0 |
|
458 */ |
|
459 void ScrollLeft(); |
|
460 |
|
461 /** |
|
462 * Scrolls selection to the right exposing more text |
|
463 * |
|
464 * @since S60 v4.0 |
|
465 */ |
|
466 void ScrollRight(); |
|
467 |
|
468 private: // Methods |
|
469 |
|
470 /** |
|
471 * Draw selected text |
|
472 * |
|
473 * @since S60 v4.0 |
|
474 */ |
|
475 TRect DrawSelection(); |
|
476 |
|
477 void UpdateText( const TFepInputContextFieldData& aData ); |
|
478 |
|
479 static TInt UpdateSecretText( TAny* aEditArea ); |
|
480 |
|
481 void IncreaseBufferL(TInt aLength); |
|
482 |
|
483 TInt PositionInVisualText(TInt aX); |
|
484 |
|
485 TPoint PositionInVisualWindow(TInt aCharacterIndex) const; |
|
486 |
|
487 TInt CursorDistance(TInt aX) const; |
|
488 |
|
489 TBidiText::TDirectionality CharDirection( TChar aChar ) const; |
|
490 |
|
491 void AdjustPostionInVisualText( const TInt cursorDistance, TInt& retVal ); |
|
492 |
|
493 |
|
494 |
|
495 /** |
|
496 * Save current cursor state |
|
497 * |
|
498 * @since S60 v4.0 |
|
499 * @param aCtrl The control which may affects the cursor shown state |
|
500 */ |
|
501 void SaveCursorState(CFepUiBaseCtrl* aCtrl); |
|
502 |
|
503 /** |
|
504 * Restore cursor state when overlapped area is removed. |
|
505 * |
|
506 * @since S60 v4.0 |
|
507 * @param aCtrl The control which may affects the cursor shown state |
|
508 */ |
|
509 void RestoreCursorState(CFepUiBaseCtrl* aCtrl); |
|
510 |
|
511 /** |
|
512 * Restore cursor state when overlapped area is removed. |
|
513 * |
|
514 * @since S60 v4.0 |
|
515 * @param aIndex The control index in the list which may affects the cursor shown state |
|
516 */ |
|
517 void RestoreCursorState(TInt aIndex); |
|
518 |
|
519 /** |
|
520 * Find whether the given control is one of the overlapped control. |
|
521 * |
|
522 * @since S60 v4.0 |
|
523 * @return The index in the list. KErrNotFound if not fouond |
|
524 */ |
|
525 TInt FindOverlappedCtrl(CFepUiBaseCtrl* aCtrl); |
|
526 |
|
527 TInt TextWidth( TInt aStart, TInt aEnd ); |
|
528 |
|
529 protected: // Data |
|
530 |
|
531 /** |
|
532 * cursor information for the selected txt |
|
533 */ |
|
534 TCursorSelection iSelectedCompositionText; |
|
535 |
|
536 /** |
|
537 * Corrected Rect of edit area. |
|
538 *This have to be used when calculating width or does charachters fit |
|
539 */ |
|
540 TRect iCorrectedRect; |
|
541 |
|
542 /** |
|
543 * Display text start position in the original text |
|
544 */ |
|
545 TInt iDisplayTextOffset; |
|
546 |
|
547 /** |
|
548 * Color of letters in the keyboard |
|
549 */ |
|
550 TRgb iTextColor; |
|
551 |
|
552 /** |
|
553 * The part of iBuffer that is shown in the edit area rectancle |
|
554 */ |
|
555 TPtrC iDisplayText; |
|
556 |
|
557 TPtrC iVisualText; |
|
558 |
|
559 TCursorSelection iDisplayTextCurSel; |
|
560 |
|
561 /** |
|
562 * Flag to indicate that text is being scrolled |
|
563 */ |
|
564 TBool iScrolling; |
|
565 |
|
566 /** |
|
567 * Flag telling whether the field has focus |
|
568 */ |
|
569 TBool iHasFocus; |
|
570 |
|
571 /** |
|
572 * Font spec for text drawing |
|
573 */ |
|
574 TFontSpec iFontSpec; |
|
575 |
|
576 /** |
|
577 * Pointer down flag -- should be removed??? |
|
578 */ |
|
579 //TBool iPointerDown; |
|
580 |
|
581 /** |
|
582 * Buffer for text to display |
|
583 * Own |
|
584 */ |
|
585 HBufC* iBuffer; |
|
586 |
|
587 HBufC* iVisualBuffer; |
|
588 |
|
589 /** |
|
590 * the insertion point, i.e. caret |
|
591 * Own |
|
592 */ |
|
593 CInsertionPoint* iInsertionPoint; |
|
594 |
|
595 /** |
|
596 * Font for text drawing. Ownership depends on iFontOwnership flag. |
|
597 */ |
|
598 CFont* iFont; |
|
599 |
|
600 /** |
|
601 * The control which captures the pointer before |
|
602 */ |
|
603 CFepUiBaseCtrl* iPreCaptureCtrl; |
|
604 |
|
605 /** |
|
606 * Flag ownership flag. ETrue if CFont object is owned by this control. |
|
607 */ |
|
608 TBool iFontOwnership; |
|
609 |
|
610 /* |
|
611 * Cursor visibility |
|
612 */ |
|
613 TBool iCursorVisible; |
|
614 |
|
615 /* |
|
616 * Cursor selection |
|
617 */ |
|
618 TBool iCursorSelVisible; |
|
619 |
|
620 /* |
|
621 * Editor is dimmed |
|
622 */ |
|
623 TBool iDimmed; |
|
624 |
|
625 /* |
|
626 * Editor is in dragging state |
|
627 */ |
|
628 TBool iInDragging; |
|
629 |
|
630 CPeriodic* iSecretTextTimer; |
|
631 |
|
632 TCursorSelection iUncommittedText; |
|
633 |
|
634 TInt iRelativePos; |
|
635 |
|
636 TBool iTextIsSecret; |
|
637 |
|
638 TBidiText::TDirectionality iTextDirection; |
|
639 |
|
640 TBool iMfneEditor; |
|
641 |
|
642 TBool isCenter; |
|
643 |
|
644 private: |
|
645 struct TOverlappedInfo |
|
646 { |
|
647 /* |
|
648 * The control overlapped with ICF cursor |
|
649 */ |
|
650 CFepUiBaseCtrl* iCtrl; |
|
651 |
|
652 /* |
|
653 * keep the cursor on state. |
|
654 */ |
|
655 TBool iCursorStateBeforeOverlapped; |
|
656 } ; |
|
657 |
|
658 /** |
|
659 * list of controls which overlapped with ICF |
|
660 */ |
|
661 RArray<TOverlappedInfo> iOverlappedCtrlList; |
|
662 |
|
663 /** |
|
664 * Reserved item1 |
|
665 */ |
|
666 TInt iReserved1; |
|
667 |
|
668 /** |
|
669 * Reserved item2 |
|
670 */ |
|
671 TInt iReserved2; |
|
672 }; |
|
673 |
|
674 #include <peninputlayouteditareabase.inl> |
|
675 #endif // C_CFEPLAYOUTEDITAREABASE_H |
|
676 |
|
677 // End of File |