|
1 /* |
|
2 * Copyright (c) 2002 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: This class creates message editor |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CCAMESSAGEEDITOR_H |
|
21 #define CCAMESSAGEEDITOR_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <eikrted.h> |
|
25 #include <eikedwin.h> |
|
26 #include <aknutils.h> |
|
27 |
|
28 // FORWARD DECLERATIONS |
|
29 |
|
30 class CCAMessageExtensionsHandler; |
|
31 class CAknsBasicBackgroundControlContext; |
|
32 class MCATapEventObserver; |
|
33 class CCAEditIndicator; |
|
34 |
|
35 // CLASS DECLARATION |
|
36 |
|
37 /** |
|
38 * Helper class to get editor content events. |
|
39 * @since S60 v3.2 |
|
40 */ |
|
41 class MCAMessageEditorObserver |
|
42 { |
|
43 public: // Enumerations |
|
44 enum TEditorEvent |
|
45 { |
|
46 EEditorContentCleared = 0, |
|
47 EEditorFirstContentAdded |
|
48 }; |
|
49 |
|
50 public: // New methods |
|
51 |
|
52 /** |
|
53 * Handle editor event. |
|
54 */ |
|
55 virtual void HandleMessageEditorEventL( TEditorEvent aEvent ) = 0; |
|
56 |
|
57 protected: |
|
58 |
|
59 /** |
|
60 * Destructor for protection. |
|
61 */ |
|
62 virtual ~MCAMessageEditorObserver() {}; |
|
63 }; |
|
64 |
|
65 /** |
|
66 * Chat application's message editor |
|
67 * |
|
68 * @lib chat.app |
|
69 * @since 1.2 |
|
70 */ |
|
71 class CCAMessageEditor : public CEikRichTextEditor |
|
72 { |
|
73 public: // Constructors and destructor |
|
74 |
|
75 /** |
|
76 * C++ default constructor. |
|
77 * @param aMessageHandler Helper message handler for copy/paste feature. |
|
78 */ |
|
79 CCAMessageEditor( CCAMessageExtensionsHandler& aMessageHandler ); |
|
80 |
|
81 /** |
|
82 * Default Symbian OS constructor. |
|
83 * @param aParent Handle to parent control |
|
84 * @param aNumberOfLines Number of lines |
|
85 * @param aTextLimit Text limit |
|
86 * @param aEdwinFlags Edwin flags |
|
87 * @param aFontControlFlags Control flags |
|
88 * @param aFontNameFlags Font name flags |
|
89 */ |
|
90 void ConstructL( const CCoeControl* aParent, TInt aNumberOfLines, |
|
91 TInt aTextLimit, TInt aEdwinFlags, |
|
92 TInt aFontControlFlags = EGulFontControlAll, |
|
93 TInt aFontNameFlags = EGulNoSymbolFonts ); |
|
94 |
|
95 /** |
|
96 * Destructor. |
|
97 */ |
|
98 virtual ~CCAMessageEditor(); |
|
99 |
|
100 public: // New functions |
|
101 |
|
102 /** |
|
103 * This method returns number of lines |
|
104 * @return Number of lines ( if editor is expanded or reduced ) |
|
105 */ |
|
106 TInt NumberOfLines( ) const; |
|
107 |
|
108 /** |
|
109 * This method clears the editor |
|
110 */ |
|
111 void ResetL(); |
|
112 |
|
113 /** |
|
114 * This method sets the font, that is used by editor |
|
115 * @param aFont desired for editor |
|
116 */ |
|
117 void SetFontL( const CFont* aFont ); |
|
118 |
|
119 /** |
|
120 * This method sets the font color, that is used by editor |
|
121 * @param aFontColor desired font color for the editor |
|
122 */ |
|
123 void SetFontColor( const TRgb aFontColor ); |
|
124 |
|
125 /** |
|
126 * This method sets the baseline of font |
|
127 * @param aBaseLine desired baseline |
|
128 */ |
|
129 void SetBaseLine( const TInt aBaseLine ); |
|
130 |
|
131 /** |
|
132 * This method deletes private icon in editor |
|
133 * @param aFormatHasChanged ETrue if format is changed |
|
134 * @param aSelection Selection if somethig is selected |
|
135 * @param aCode Event code |
|
136 * @param aIsPicture ETrue if picture is deleted |
|
137 */ |
|
138 void DeletePictureL( TBool& aFormatHasChanged, |
|
139 const TCursorSelection& aSelection, TBool aCode, |
|
140 TBool aIsPicture ); |
|
141 |
|
142 /** |
|
143 * This method sets the view rect. This is the "rect" where editor is located |
|
144 * @param aRect Parent control's view rect |
|
145 */ |
|
146 void SetViewRect( const TRect& aRect ); |
|
147 |
|
148 /** |
|
149 * Sets skinned background context for editor. |
|
150 * @param aForceUpdate ETrue causes full update of skin context, |
|
151 * ETrue used when display flipped from portrait to |
|
152 * landscape and vice versa. |
|
153 */ |
|
154 void SetupSkinContextL( TBool aForceUpdate = EFalse ); |
|
155 |
|
156 /** |
|
157 * Force editor update so that correct vertical alignment for smiley |
|
158 * icons will be used. Called by container which owns this editor. |
|
159 * @since 3.0 |
|
160 */ |
|
161 void RefreshEditorL(); |
|
162 |
|
163 /** |
|
164 * Sets message editor observer. |
|
165 * @since S60 v3.2 |
|
166 * @param aObserver Pointer to observer, ownership not transfered. |
|
167 */ |
|
168 void SetMessageEditorObserver( MCAMessageEditorObserver* aObserver ); |
|
169 |
|
170 /** |
|
171 * Set observer for handling tap events. |
|
172 * Supports only single observer. |
|
173 * @param aObserver observer to handle tap events |
|
174 * @param aId control id which is used by the observer to |
|
175 * identify this object. |
|
176 */ |
|
177 void SetTapObserver( MCATapEventObserver* aObserver, TUint aId ); |
|
178 |
|
179 private: |
|
180 |
|
181 /** |
|
182 * Notifies message editor observer when needed. |
|
183 * @since S60 v3.2 |
|
184 * @param aOldLen Editor content length before editing. |
|
185 * @param aCurLen Editor content current length |
|
186 */ |
|
187 void NotifyObserverIfNeededL( TInt aOldLen, TInt aCurLen ) ; |
|
188 |
|
189 public: // from CCoeControl |
|
190 |
|
191 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
192 |
|
193 /** |
|
194 * @see CCoeControl |
|
195 */ |
|
196 void HandlePointerEventL( const TPointerEvent& aPointerEvent ); |
|
197 |
|
198 public: |
|
199 /** |
|
200 * Shows edit indicator |
|
201 */ |
|
202 void ShowIndicator(); |
|
203 |
|
204 /** |
|
205 * Hides edit indicator |
|
206 */ |
|
207 void HideIndicator(); |
|
208 |
|
209 /** |
|
210 * Sets the active object which has called show/hide of |
|
211 * edit indicator |
|
212 */ |
|
213 void SetActiveObject( CCAEditIndicator* aActiveObject ); |
|
214 |
|
215 /** |
|
216 * ReSets the active object which has called show/hide of |
|
217 * edit indicator |
|
218 */ |
|
219 void ReSetActiveObject(); |
|
220 |
|
221 private: // from MEikCcpuEditor |
|
222 |
|
223 /** |
|
224 * Handle needed extension modififications for cut feature. |
|
225 * @since 2.6 |
|
226 * @see MEikCcpuEditor |
|
227 */ |
|
228 void CcpuCutL(); |
|
229 |
|
230 /** |
|
231 * Handle needed extension modififications for copy feature. |
|
232 * @since 2.6 |
|
233 * @see MEikCcpuEditor |
|
234 */ |
|
235 void CcpuCopyL(); |
|
236 |
|
237 /** |
|
238 * Handle needed extension modififications for paste feature. |
|
239 * @since 2.6 |
|
240 * @see MEikCcpuEditor |
|
241 */ |
|
242 void CcpuPasteL(); |
|
243 |
|
244 private: // from CEikRichTextEditor |
|
245 |
|
246 /** |
|
247 * @see CEikRichTextEditor |
|
248 */ |
|
249 void EditObserver( TInt aStartEdit, TInt aEditLength ); |
|
250 |
|
251 private: // From MObjectProvider |
|
252 |
|
253 /** |
|
254 * @see MObjectProvider |
|
255 */ |
|
256 TTypeUid::Ptr MopSupplyObject( TTypeUid aId ); |
|
257 |
|
258 private: // New helper methods |
|
259 |
|
260 /** |
|
261 * Constructs clipboard buffer if needed and |
|
262 * sets its content and selection correctly, |
|
263 * method called before copying or cutting. |
|
264 * @since S60 v3.1 |
|
265 */ |
|
266 void ConstructAndSetUpClipboardBufferL(); |
|
267 |
|
268 private: |
|
269 |
|
270 TInt iBaseLine; |
|
271 TRgb iFontColor; |
|
272 TRect iViewRect; |
|
273 |
|
274 TAknLayoutRect iTextLine1; |
|
275 TAknLayoutRect iTextLine2; |
|
276 |
|
277 // Does not own. Extension handler for messages |
|
278 CCAMessageExtensionsHandler& iMessageHandler; |
|
279 |
|
280 // Owns |
|
281 CAknsBasicBackgroundControlContext* iBgContext; |
|
282 // Owns |
|
283 CAknsBasicBackgroundControlContext* iFgContext; |
|
284 |
|
285 // Not owned. |
|
286 MCAMessageEditorObserver* iEditorObserver; |
|
287 |
|
288 // Not owned. Pointer to observer |
|
289 MCATapEventObserver* iTapObserver; |
|
290 |
|
291 // ID which needs to be reported back to TapObserver |
|
292 TUint iTapControlId; |
|
293 |
|
294 // Owned. Editor to be used when copying or |
|
295 // cutting. Perform extension conversions in |
|
296 // in this buffer editor to avoid flickering |
|
297 // and crashes on UI. |
|
298 CEikEdwin* iClipboardBuffer; |
|
299 |
|
300 //doesnt own |
|
301 CCAEditIndicator* iEditIndicatorActiveObj; |
|
302 }; |
|
303 |
|
304 #endif // CCAMESSAGEEDITOR_H |
|
305 |
|
306 // End of File |