|
1 /* |
|
2 * Copyright (c) 2008 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: smiley utility class |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_SMILEYMANAGER_H |
|
19 #define C_SMILEYMANAGER_H |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <e32std.h> |
|
23 |
|
24 class CCoeControl; |
|
25 class CBitmapContext; |
|
26 class CSmileyModel; |
|
27 class CSmileyInfoReader; |
|
28 class CSmileyDrawer; |
|
29 class TRgb; |
|
30 class CEikEdwin; |
|
31 class CSmileyIconRecord; |
|
32 |
|
33 _LIT( KSmileyString, "\xf8e4i" ); |
|
34 |
|
35 /** |
|
36 * smiley engine class, manage smiley character strings and icons |
|
37 * |
|
38 * @lib ?library |
|
39 * @since S60 v5.0 |
|
40 */ |
|
41 NONSHARABLE_CLASS( CSmileyManager ) : public CBase |
|
42 { |
|
43 public: |
|
44 static const TText KPlaceHolder = 0xfff0; |
|
45 static const TInt KMaxLength = 5; |
|
46 static const TInt KMinLength = 2; |
|
47 static const TText KZeroCode = 0; |
|
48 static const TText KCompensateChar = 'i'; |
|
49 static const TUint KSmileyCodeMin = 0xf880; |
|
50 static const TUint KSmileyCodeMax = 0xf8e4; |
|
51 |
|
52 enum TOperationType |
|
53 { |
|
54 EDelete = 0, |
|
55 EInsert, |
|
56 ESetCursor, |
|
57 ESelection |
|
58 }; |
|
59 |
|
60 //static constructors |
|
61 static CSmileyManager* NewL( CEikEdwin& aEdwin ); |
|
62 static CSmileyManager* NewLC( CEikEdwin& aEdwin ); |
|
63 |
|
64 virtual ~CSmileyManager(); |
|
65 |
|
66 //new functions |
|
67 TBool ConvertTextForSmileyL( TInt aStart, TDes& aText, |
|
68 TBool aStringToCodes = ETrue ); |
|
69 void SetVisibleRange( TInt aDocPos, TInt aLength ); |
|
70 |
|
71 void DrawIconL( CBitmapContext& aGc, const TRect& aRect, |
|
72 TInt aDocPos ); |
|
73 |
|
74 void HandleDeleteL( TInt aStart, TInt aLength ); |
|
75 void HandleInsertL( TInt aStart, TInt aLength ); |
|
76 void HandleSetCursor( TInt aOldCursor, TInt& aNewCursor ); |
|
77 void HandleSelection( TInt aStart, TInt aLength ); |
|
78 |
|
79 void SetHighlightColor( TRgb aColor ); |
|
80 |
|
81 void SetAnimationPlayTimes( TInt aPlayTimes ); |
|
82 TText SmileyCodeByPos( TInt aDocPos ); |
|
83 TInt SmileyLength( TInt aDocPos ); |
|
84 |
|
85 static TBool IsSmileyCode( TText aCode ); |
|
86 void RemoveIconsInRange( TInt aStart, TInt aLength ); |
|
87 |
|
88 TBool HasSmileyIconsInText(); |
|
89 TBool IsDisabledSmileyIcon( TInt aDocPos ); |
|
90 void DisableSmileyIcon( TInt aDocPos ); |
|
91 |
|
92 private: |
|
93 //constructors |
|
94 CSmileyManager(); |
|
95 void ConstructL( CEikEdwin& aEdwin ); |
|
96 TBool ConvertCodesToTextL( TDes& aText, TInt aStart ); |
|
97 TBool ConvertTextToCodesL( TDes& aText, TInt aStart ); |
|
98 void AddSmileyToRecordL( const TDesC& aSmileyText, TInt aDocPos, |
|
99 TText aCode ); |
|
100 |
|
101 private: // data |
|
102 // own |
|
103 CSmileyModel* iModel; |
|
104 // own |
|
105 CSmileyInfoReader* iReader; |
|
106 // own |
|
107 CSmileyDrawer* iDrawer; |
|
108 // own |
|
109 CSmileyIconRecord* iIconRecord; |
|
110 |
|
111 TInt iSelStart; |
|
112 TInt iSelLength; |
|
113 TInt iVisibleStart; |
|
114 TInt iVisibleLength; |
|
115 }; |
|
116 |
|
117 #endif // C_SMILEYMANAGER_H |