1 /* |
|
2 * Copyright (c) 2007 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: CTruiShortcutEditContainer class of TrainingUI |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_TRUISHORTCUTEDITCONTAINER_H |
|
20 #define C_TRUISHORTCUTEDITCONTAINER_H |
|
21 |
|
22 #include <AknLayout2Def.h> |
|
23 #include "truicontainerbase.h" |
|
24 #include "truihwrboxobserver.h" |
|
25 #include "truiradiobuttonobserver.h" |
|
26 |
|
27 class CAknButton; |
|
28 class CTruiHwrBox; |
|
29 class CAknsBasicBackgroundControlContext; |
|
30 class CTruiRadioButton; |
|
31 class CAknCharMapDialog; |
|
32 |
|
33 /** |
|
34 * CTruiShortcutEditContainer container control |
|
35 * Used as the component to shortcut main view |
|
36 * |
|
37 * @code |
|
38 * iContainer = CTruiShortcutEditContainer::NewL( ClientRect() ); |
|
39 * iContainer->SetMopParent( this ); |
|
40 * AppUi()->AddToStackL( *this, iContainer ); |
|
41 * @endcode |
|
42 * |
|
43 */ |
|
44 class CTruiShortcutEditContainer : public CTruiContainerBase, |
|
45 public MCoeControlObserver, |
|
46 public MTruiHwrBoxObserver, |
|
47 public MTruiRadioButtonObserver |
|
48 { |
|
49 public: |
|
50 |
|
51 /** |
|
52 * Two-phased constructor. |
|
53 * @param aRect The rectangle that defines the control's extent. |
|
54 * The rectangle's origin is relative to the origin |
|
55 * of its associated window. |
|
56 * @return Pointer to the component control |
|
57 */ |
|
58 static CTruiShortcutEditContainer* NewL( const TRect& aRect ); |
|
59 |
|
60 /** |
|
61 * Two-phased constructor. |
|
62 * @param aRect The rectangle that defines the control's extent. |
|
63 * The rectangle's origin is relative to the origin |
|
64 * of its associated window. |
|
65 * @return Pointer to the component control |
|
66 */ |
|
67 static CTruiShortcutEditContainer* NewLC( const TRect& aRect ); |
|
68 |
|
69 /** |
|
70 * Destructor. |
|
71 */ |
|
72 virtual ~CTruiShortcutEditContainer(); |
|
73 |
|
74 /** |
|
75 * Switch app's active view to ShortcutView. |
|
76 */ |
|
77 void SwitchToShortcutViewL(); |
|
78 |
|
79 /** |
|
80 * Go back to the previous view. |
|
81 */ |
|
82 void BackToPreviousViewL(); |
|
83 |
|
84 /** |
|
85 * Query if shortcut model exist |
|
86 */ |
|
87 TBool HasShortcutModel(); |
|
88 |
|
89 /** |
|
90 * Preview shortcut model |
|
91 */ |
|
92 void PreviewShortcutModel(); |
|
93 |
|
94 /** |
|
95 * Before exit, do some necessary operation |
|
96 * |
|
97 * @retrun TBool if ready to exit, true will be return, |
|
98 * otherwise it will return false |
|
99 */ |
|
100 TBool PrepareToExitL(); |
|
101 |
|
102 /** |
|
103 * Clear current model |
|
104 * |
|
105 */ |
|
106 void ClearCurrentModelL(); |
|
107 |
|
108 /** |
|
109 * Return the currently selected index, which will be set in Shortcuts view. |
|
110 * |
|
111 * @param aItemList The shortcut list array in which will locate the aTex. |
|
112 * @param aText The shortcut item which will be located in aItemList |
|
113 * @return The index of aText in aItemList. |
|
114 * If it doesn't exist, it will return KErrNotFound. |
|
115 */ |
|
116 TInt DefaultSelectedIndex( const CDesCArray* aItemList, |
|
117 const TDesC& aText ); |
|
118 |
|
119 /** |
|
120 * Popup SCT dialog. |
|
121 * |
|
122 */ |
|
123 void PopupSctDialogL(); |
|
124 |
|
125 private: |
|
126 |
|
127 /** |
|
128 * Constructor. |
|
129 */ |
|
130 CTruiShortcutEditContainer(); |
|
131 |
|
132 /** |
|
133 * Two-phased constructor. Second phase |
|
134 * @param aRect The rectangle that defines the control's extent. |
|
135 * The rectangle's origin is relative to the origin |
|
136 * of its associated window. |
|
137 */ |
|
138 void ConstructL( const TRect& aRect ); |
|
139 |
|
140 /** |
|
141 * Create controls to be displayed in this container. |
|
142 */ |
|
143 void InitializeControlsL(); |
|
144 |
|
145 /** |
|
146 * Create radio button. |
|
147 */ |
|
148 void CreateRadioButtonL(); |
|
149 |
|
150 /** |
|
151 * Create HWRBox |
|
152 */ |
|
153 void CreateHwrBoxL(); |
|
154 |
|
155 /** |
|
156 * Create buttons |
|
157 */ |
|
158 void CcnstructButtonL(); |
|
159 |
|
160 /** |
|
161 * Create Label |
|
162 */ |
|
163 void CreateLabelL(); |
|
164 |
|
165 /** |
|
166 * Popup tooltip |
|
167 * |
|
168 * @param aResourceID The numeric ID of the resource string to be read. |
|
169 */ |
|
170 void PopupTooltipL( TInt aResourceID ); |
|
171 |
|
172 /** |
|
173 * Layout under landscape condition |
|
174 */ |
|
175 void DoLayoutLandscape(); |
|
176 |
|
177 /** |
|
178 * Layout under portait condition |
|
179 */ |
|
180 void DoLayoutPortait(); |
|
181 |
|
182 /** |
|
183 * Save own shortcut. |
|
184 * |
|
185 * @param aShortcut The shortcut text which to be stored. |
|
186 * @param aModel The points array assigned to the shortcut. |
|
187 * @param aErrMsg The error message for too similar. |
|
188 * Leave with code KErrAlreadyInUse |
|
189 */ |
|
190 void SaveOwnShortcutL( const TDesC& aShortcut, |
|
191 RArray<TPoint>& aModel, |
|
192 TDes& aErrMsg ); |
|
193 |
|
194 /** |
|
195 * Save preset shortcut |
|
196 * |
|
197 * @param aShortcut The shortcut text which to be stored. |
|
198 * @param aUnicode The unicode of preset symbol assigned to the shortcut. |
|
199 * Leave with code KErrAlreadyInUse |
|
200 */ |
|
201 void SavePresetShortcutL( const TDesC& aShortcut, TUint aUnicode ); |
|
202 |
|
203 /** |
|
204 * Backup shortcut model. It is probably to be restored when press Back to exit. |
|
205 * |
|
206 * @param aOriginalModel The shortcut model which to be backuped. |
|
207 * @param aOriginalUnicode The unicode of preset symbol which to be backuped. |
|
208 */ |
|
209 void BackupShortcutModel( const RArray<TPoint>& aOriginalModel, |
|
210 TUint aOriginalUnicode ); |
|
211 |
|
212 /** |
|
213 * Set active char. |
|
214 * |
|
215 * @param aUnicode The unicode which to be displayed. |
|
216 */ |
|
217 void SetActiveCharL( TUint aUnicode ); |
|
218 |
|
219 /** |
|
220 * Find the first available preset symbol. |
|
221 * |
|
222 * @param aStartPos The position from which to search |
|
223 * @param aDirection The direction of how to search in preset arrays, |
|
224 * Toward left or toward right |
|
225 * @param aUnicode The unicode of the first available preset symbol. |
|
226 * @return ETrue: search successfully; EFalse: Fail to seach, meaning all in use |
|
227 */ |
|
228 TBool FindFirstAvailableCharL( TInt aStartPos, TInt aEndPos, |
|
229 TInt aDirection, TUint& aUnicode ); |
|
230 |
|
231 /** |
|
232 * Return if the preset is in use |
|
233 * |
|
234 * @param aUnicode The preset's unicode |
|
235 * @return ETrue: in use |
|
236 */ |
|
237 TBool CheckPresetSymbolInUseL( TUint aUnicode ); |
|
238 |
|
239 /** |
|
240 * Do something to response to size changed |
|
241 * |
|
242 * @param aVarity Varity to decide which option will be retrieved from LAF data |
|
243 */ |
|
244 void DoSizeChanged( TInt aVarity ); |
|
245 |
|
246 // from base class CCoeControl |
|
247 /** |
|
248 * Draw the screen. |
|
249 * @param aRect the rectangle of this view that needs updating |
|
250 */ |
|
251 void Draw( const TRect& aRect ) const; |
|
252 |
|
253 /** |
|
254 * From CoeControl. |
|
255 * Responds to changes to the size and position of the contents of this control. |
|
256 */ |
|
257 void SizeChanged(); |
|
258 |
|
259 /** |
|
260 * From CoeControl. |
|
261 * Responds to a change in focus. |
|
262 * |
|
263 * @param aRect Contains the value that was passed to it by SetFocus(). |
|
264 */ |
|
265 void FocusChanged( TDrawNow aDrawNow ); |
|
266 |
|
267 /** |
|
268 * Handles a change to the control's resources. |
|
269 * |
|
270 * @param aType A message UID value. |
|
271 */ |
|
272 void HandleResourceChange( TInt aType ); |
|
273 |
|
274 // from MCoeControlObserver |
|
275 /** |
|
276 * Handles an event from an observed control. |
|
277 * This function is called when a control for which this control is the |
|
278 * observer calls CCoeControl::ReportEventL(). It should be implemented |
|
279 * by the observer control, and should handle all events sent by controls |
|
280 * it observes. |
|
281 * |
|
282 *@param aControl The control that sent the event. |
|
283 *@param aEventType The event type. |
|
284 */ |
|
285 void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType ); |
|
286 |
|
287 // From MTruiHWRBoxObserver |
|
288 /** |
|
289 * From MTruiHWRBoxObserver. |
|
290 * Input times out |
|
291 * Handle the save model event |
|
292 */ |
|
293 void SaveNewModelL(); |
|
294 |
|
295 /** |
|
296 * From MTruiHWRBoxObserver. |
|
297 * HandleEventL |
|
298 * Handle the message event from the HWRBox |
|
299 * @param aMessage According to the aMessage to handle the event |
|
300 */ |
|
301 void HandleEventL( TMessageType aMessage ); |
|
302 |
|
303 // from MTruiRadioButtonObserver |
|
304 /** |
|
305 * Notify that which radio button is selected. |
|
306 * @param aIndex The index of currently selected index. |
|
307 */ |
|
308 void SelectChangedL( TInt aIndex ); |
|
309 |
|
310 private: // data |
|
311 /** |
|
312 * The Writing Box is used for drawing a character model. |
|
313 * Not own |
|
314 */ |
|
315 CTruiHwrBox* iHwrBox; |
|
316 |
|
317 /** |
|
318 * Pointer to background |
|
319 * Own |
|
320 */ |
|
321 CAknsBasicBackgroundControlContext* iBackGround; |
|
322 |
|
323 /** |
|
324 * Pointer to radio button |
|
325 * Not own |
|
326 */ |
|
327 CTruiRadioButton* iRadioButtonContainer; |
|
328 |
|
329 /** |
|
330 * Pointer to the tip label |
|
331 * Not own |
|
332 */ |
|
333 CEikLabel* iLabelTip; |
|
334 |
|
335 /** |
|
336 * The current tip of training shortcut |
|
337 * Own |
|
338 */ |
|
339 HBufC* iLabeltext; |
|
340 |
|
341 /** |
|
342 * Store the wrapped text to give tips about own or preset. |
|
343 * Own |
|
344 */ |
|
345 HBufC* iWrappedLabelText; |
|
346 |
|
347 /** |
|
348 * Left button. |
|
349 * Not own |
|
350 */ |
|
351 CAknButton* iLeftBtn; |
|
352 |
|
353 /** |
|
354 * Right button. |
|
355 * Not own |
|
356 */ |
|
357 CAknButton* iRightBtn; |
|
358 |
|
359 /** |
|
360 * Active indicator. |
|
361 * Not own |
|
362 */ |
|
363 CEikLabel* iIndicator; |
|
364 |
|
365 /** |
|
366 * Current preset symbol. |
|
367 */ |
|
368 TUint iUnicode; |
|
369 |
|
370 /** |
|
371 * Current shortcut type. |
|
372 */ |
|
373 TInt iShortcutType; |
|
374 |
|
375 /** |
|
376 * Store the old points of the current shortcut. |
|
377 * own |
|
378 */ |
|
379 RArray<TPoint> iModelBak; |
|
380 |
|
381 /** |
|
382 * Store the old unicode of the current preset shortcut. |
|
383 */ |
|
384 TUint iUnicodeBak; |
|
385 |
|
386 /** |
|
387 * Check if need to restore old shortcut. |
|
388 */ |
|
389 TBool iIsRestored; |
|
390 |
|
391 /** |
|
392 * Check if the hwrbox is empty. |
|
393 */ |
|
394 TBool iIsEmptyHwrBox; |
|
395 |
|
396 /** |
|
397 * Store all presets from Engine. |
|
398 * Own |
|
399 */ |
|
400 RArray<TUint> iPresets; |
|
401 |
|
402 /** |
|
403 * Which char is active in preset array. |
|
404 */ |
|
405 TInt iActiveCharPos; |
|
406 |
|
407 TAknMultiLineTextLayout iMultilineLayout; |
|
408 |
|
409 /** |
|
410 * Line array. |
|
411 * Own |
|
412 */ |
|
413 RArray<TInt> iLineWidthArray; |
|
414 }; |
|
415 |
|
416 #endif // C_TRUISHORTCUTEDITCONTAINER_H |
|
417 |
|