|
1 /* |
|
2 * Copyright (c) 2002-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: MsgExpandableControl declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CMSGEXPANDABLECONTROL_H |
|
21 #define CMSGEXPANDABLECONTROL_H |
|
22 |
|
23 // ========== INCLUDE FILES ================================ |
|
24 |
|
25 #include <eikedwob.h> // for MEikEdwinSizeObserver |
|
26 #include <aknenv.h> // for CAknEnv |
|
27 #include <AknUtils.h> |
|
28 #include <eikcapc.h> |
|
29 #include <fepbase.h> |
|
30 |
|
31 #include "MsgExpandableTextEditorControl.h" // for CMsgBaseControl |
|
32 |
|
33 // ========== CONSTANTS ==================================== |
|
34 |
|
35 // ========== MACROS ======================================= |
|
36 |
|
37 // ========== DATA TYPES =================================== |
|
38 |
|
39 // ========== FUNCTION PROTOTYPES ========================== |
|
40 |
|
41 // ========== FORWARD DECLARATIONS ========================= |
|
42 |
|
43 class CMsgExpandableControlEditor; |
|
44 class CEikLabel; |
|
45 class CRichText; |
|
46 class CGlobalText; |
|
47 class CEikRichTextEditor; |
|
48 class CAknButton; |
|
49 |
|
50 // ========== CLASS DECLARATION ============================ |
|
51 |
|
52 /** |
|
53 * Defines an expandable control for message editors/viewers. |
|
54 */ |
|
55 class CMsgExpandableControl : public CMsgExpandableTextEditorControl, |
|
56 public MCoeCaptionRetrieverForFep |
|
57 { |
|
58 public: |
|
59 |
|
60 /** |
|
61 * Constructor. |
|
62 */ |
|
63 IMPORT_C CMsgExpandableControl(); |
|
64 |
|
65 /** |
|
66 * Constructor. |
|
67 */ |
|
68 IMPORT_C CMsgExpandableControl( MMsgBaseControlObserver& aBaseControlObserver ); |
|
69 |
|
70 /** |
|
71 * Destructor. |
|
72 */ |
|
73 IMPORT_C ~CMsgExpandableControl(); |
|
74 |
|
75 /** |
|
76 * Returns a reference to the editor control. |
|
77 * @return |
|
78 */ |
|
79 IMPORT_C CEikRichTextEditor& Editor() const; |
|
80 |
|
81 /** |
|
82 * Returns a reference to the label control. |
|
83 * @return |
|
84 */ |
|
85 IMPORT_C CEikLabel& Caption() const; |
|
86 |
|
87 /** |
|
88 * Sets text content of the control editor from the contents of |
|
89 * a rich text object. Old content is discarded. Copies also |
|
90 * formatting from given rich text object if plain text mode |
|
91 * is disabled. |
|
92 * |
|
93 * @param aText New text content. |
|
94 */ |
|
95 IMPORT_C void SetTextContentL( CRichText& aText ); |
|
96 |
|
97 /** |
|
98 * Sets text content of the control editor from the contents of |
|
99 * a descriptor. Old content is discarded. |
|
100 * |
|
101 * @since 3.2 |
|
102 * |
|
103 * @param aText New text content. |
|
104 */ |
|
105 IMPORT_C void SetTextContentL( const TDesC& aText ); |
|
106 |
|
107 /** |
|
108 * Copies stripped content to aBuf. Control chars, newlines and if |
|
109 * aNoExtraSemicolons is ETrue, also two consecutive semicolons are |
|
110 * replaced with semicolon and space. |
|
111 * @param aBuf buffer where stripped content will be copied. |
|
112 * @param aMaxLen max length of aBuf. |
|
113 * @param aNoExtraSemicolons ETrue if two consecutive semicolons must be handled. |
|
114 */ |
|
115 IMPORT_C void TextContentStrippedL( TDes& aBuf, TInt aMaxLen, TBool aNoExtraSemicolons = ETrue ); |
|
116 |
|
117 /** |
|
118 * Calls iEditors HandleFrameSizeChangeL trapped |
|
119 */ |
|
120 void HandleFrameSizeChange(); |
|
121 |
|
122 /** |
|
123 * Returns a pointer to the button control. |
|
124 * |
|
125 * @since 3.2 |
|
126 * |
|
127 * @return Pointer to button control if available, otherwise NULL. |
|
128 */ |
|
129 CAknButton* Button() const; |
|
130 |
|
131 public: // from CMsgBaseControl |
|
132 |
|
133 /** |
|
134 * Creates this control from resource. |
|
135 * @param aResourceId |
|
136 */ |
|
137 void ConstructFromResourceL( TInt aResourceId ); |
|
138 |
|
139 /** |
|
140 * Prepares control for viewing. |
|
141 * @param aEvent |
|
142 * @param aParam |
|
143 */ |
|
144 void NotifyViewEvent( TMsgViewEvent aEvent, TInt aParam ); |
|
145 |
|
146 /** |
|
147 * Resets (= clears) contents of the control. |
|
148 */ |
|
149 IMPORT_C void Reset(); |
|
150 |
|
151 /** |
|
152 * Calculates and sets the size of the control and returns new size as |
|
153 * reference aSize. |
|
154 * @param aSize |
|
155 */ |
|
156 IMPORT_C void SetAndGetSizeL( TSize& aSize ); |
|
157 |
|
158 /** |
|
159 * Checks if the focus change up or down is possible and |
|
160 * returns ETrue if it is. |
|
161 * @param aDirection |
|
162 * @return |
|
163 */ |
|
164 IMPORT_C TBool IsFocusChangePossible( TMsgFocusDirection aDirection ) const; |
|
165 |
|
166 public: // from CCoeControl |
|
167 |
|
168 /** |
|
169 * Sets container window. |
|
170 * @param aContainer |
|
171 */ |
|
172 IMPORT_C void SetContainerWindowL( const CCoeControl& aContainer ); |
|
173 |
|
174 /** |
|
175 * Handles key events. |
|
176 * @param aKeyEvent |
|
177 * @param aType |
|
178 * @return |
|
179 */ |
|
180 IMPORT_C TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
181 TEventCode aType ); |
|
182 |
|
183 /** |
|
184 * Returns minimum size of the control. |
|
185 * @return |
|
186 */ |
|
187 IMPORT_C TSize MinimumSize(); |
|
188 |
|
189 /** |
|
190 * Returns control's input capabilities. |
|
191 * @return |
|
192 */ |
|
193 IMPORT_C TCoeInputCapabilities InputCapabilities() const; |
|
194 |
|
195 /** |
|
196 * For handling dynamic layout switch. |
|
197 */ |
|
198 IMPORT_C void HandleResourceChange( TInt aType ); |
|
199 |
|
200 public: // from MCoeControlObserver |
|
201 |
|
202 /** |
|
203 * Handle control event. |
|
204 * @param aControl |
|
205 * @param aEventType |
|
206 */ |
|
207 IMPORT_C void HandleControlEventL( CCoeControl* aControl, |
|
208 TCoeEvent aEventType ); |
|
209 public: // from MCoeCaptionRetrieverForFep |
|
210 |
|
211 /** |
|
212 * Returns a caption for called |
|
213 * @param aCaption On return, contains the caption. |
|
214 */ |
|
215 void GetCaptionForFep( TDes &aCaption ) const; |
|
216 protected: |
|
217 |
|
218 /** |
|
219 * Creates the editor for the control. |
|
220 * @return |
|
221 */ |
|
222 CMsgExpandableControlEditor* CreateEditorL(); |
|
223 |
|
224 /** |
|
225 * Reads control properties from resource. |
|
226 * @param aReader |
|
227 */ |
|
228 virtual void ReadControlPropertiesFromResourceL( TResourceReader& aReader ); |
|
229 |
|
230 /** |
|
231 * Creates caption for the control from resource. |
|
232 * @param aReader |
|
233 * @return |
|
234 */ |
|
235 virtual CEikLabel* CreateCaptionFromResourceL( TResourceReader& aReader ); |
|
236 |
|
237 /** |
|
238 * Creates editor for the control from resource. |
|
239 * @param aReader |
|
240 * @return |
|
241 */ |
|
242 virtual CMsgExpandableControlEditor* CreateEditorFromResourceL( |
|
243 TResourceReader& aReader ); |
|
244 |
|
245 /** |
|
246 * Sets the correct layout for button. |
|
247 */ |
|
248 virtual void LayoutButton(); |
|
249 |
|
250 protected: // from CMsgBaseControl |
|
251 |
|
252 /** |
|
253 * Prepares for read only or non read only state. |
|
254 * @param aReadOnly |
|
255 */ |
|
256 void PrepareForReadOnly( TBool aReadOnly ); |
|
257 |
|
258 /** |
|
259 * Reads layout data from "LAF". |
|
260 */ |
|
261 virtual void ResolveLayoutsL(); |
|
262 |
|
263 protected: // from CCoeControl |
|
264 |
|
265 /** |
|
266 * Returns a number of controls. |
|
267 * @return |
|
268 */ |
|
269 IMPORT_C TInt CountComponentControls() const; |
|
270 |
|
271 /** |
|
272 * Returns a control of index aIndex. |
|
273 * @param aIndex |
|
274 * @return |
|
275 */ |
|
276 IMPORT_C CCoeControl* ComponentControl( TInt aIndex ) const; |
|
277 |
|
278 /** |
|
279 * Sets new position for all the controls. |
|
280 */ |
|
281 IMPORT_C void SizeChanged(); |
|
282 |
|
283 /** |
|
284 * This is called when the focus of the control is changed. |
|
285 * @param aDrawNow |
|
286 */ |
|
287 IMPORT_C void FocusChanged( TDrawNow aDrawNow ); |
|
288 |
|
289 /** |
|
290 * Draw control. |
|
291 * @param aRect |
|
292 */ |
|
293 IMPORT_C void Draw( const TRect& aRect ) const; |
|
294 |
|
295 /** |
|
296 * Sets the control as ready to be drawn. This implementation |
|
297 * should be called by the derived classes implementing their |
|
298 * own ActivateL function. |
|
299 */ |
|
300 IMPORT_C void ActivateL(); |
|
301 |
|
302 private: |
|
303 |
|
304 /** |
|
305 * Performs view event handling. |
|
306 */ |
|
307 void DoNotifyViewEventL( TMsgViewEvent aEvent, TInt aParam ); |
|
308 |
|
309 /** |
|
310 * Updates text color for caption from current skin. |
|
311 */ |
|
312 void UpdateCaptionTextColorL(); |
|
313 |
|
314 protected: |
|
315 |
|
316 CEikLabel* iCaption; |
|
317 |
|
318 TAknLayoutText iCaptionLayout; |
|
319 |
|
320 // Offset between control and caption. Used for highlight etc. |
|
321 TInt iCaptionTop; |
|
322 |
|
323 TAknLayoutText iEditorLayout; |
|
324 |
|
325 // Offset between control and editor. Used for highlight etc. |
|
326 TAknLayoutRect iFrameLayout; |
|
327 |
|
328 CAknButton* iButton; |
|
329 TAknLayoutRect iButtonLayout; |
|
330 TInt iButtonTop; |
|
331 TInt iCtrltype; |
|
332 }; |
|
333 |
|
334 #endif // CMSGEXPANDABLECONTROL_H |
|
335 |
|
336 // End of File |