|
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: CTruiMainViewContainer class of TrainingUI |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_TRUIMAINVIEWCONTAINER_H |
|
20 #define C_TRUIMAINVIEWCONTAINER_H |
|
21 |
|
22 #include "truicontainerbase.h" |
|
23 #include "truihwrboxobserver.h" |
|
24 |
|
25 class CAknButton; |
|
26 class CAknChoiceList; |
|
27 class CTruiHwrBox; |
|
28 class CAknCharMapDialog; |
|
29 class CAknsBasicBackgroundControlContext; |
|
30 class CEikLabel; |
|
31 class CAknPreviewPopUpController; |
|
32 |
|
33 const TInt KActiveCharSize = 1; |
|
34 const TInt KLabelTextLen = 100; |
|
35 /** |
|
36 * CTruiMainViewContainer container control |
|
37 * Used as the component to training ui main view |
|
38 * |
|
39 * @code |
|
40 * iContainer = CTruiMainViewContainer::NewL( ClientRect() ); |
|
41 * iContainer->SetMopParent( this ); |
|
42 * AppUi()->AddToStackL( *this, iContainer ); |
|
43 * @endcode |
|
44 * |
|
45 */ |
|
46 class CTruiMainViewContainer : public CTruiContainerBase, |
|
47 public MCoeControlObserver, |
|
48 public MTruiHwrBoxObserver |
|
49 { |
|
50 public: |
|
51 |
|
52 /** |
|
53 * Two-phased constructor. |
|
54 * @param aRect The rectangle that defines the control's extent. |
|
55 * The rectangle's origin is relative to the origin of its associated window. |
|
56 * @return Pointer to the component control |
|
57 */ |
|
58 static CTruiMainViewContainer* 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 of its associated window. |
|
64 * @return Pointer to the component control |
|
65 */ |
|
66 static CTruiMainViewContainer* NewLC( const TRect& aRect ); |
|
67 |
|
68 /** |
|
69 * Destructor. |
|
70 */ |
|
71 virtual ~CTruiMainViewContainer(); |
|
72 |
|
73 /** |
|
74 * Handles an event from an observed control. |
|
75 * |
|
76 * @param aControl The control that sent the event. |
|
77 * @param aEventType The event type. |
|
78 */ |
|
79 void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType ); |
|
80 |
|
81 /** |
|
82 * Handles language script changed. |
|
83 * |
|
84 * @param aScriptId The selected language script's Id |
|
85 */ |
|
86 void HandleLanguageScriptChangedL( TInt aScriptId ); |
|
87 |
|
88 /** |
|
89 * Handles character range changed. |
|
90 * |
|
91 * @param aIndex The index of range item in Menu "character range" or choicelist |
|
92 * @param aRangeId The range Id. |
|
93 */ |
|
94 void HandleCharRangeChangedL( TInt aIndex, TInt aRangeId ); |
|
95 |
|
96 /** |
|
97 * Handles choosing an active char from SCT. |
|
98 * |
|
99 */ |
|
100 void HandleChooseCharEventL(); |
|
101 |
|
102 /** |
|
103 * Preview character model |
|
104 * |
|
105 */ |
|
106 void PreviewCharacterModel(); |
|
107 |
|
108 /** |
|
109 * Set current trained character |
|
110 * |
|
111 * @param aChar the trained character |
|
112 */ |
|
113 void SetCurrentCharL( const TPtrC& aChar ); |
|
114 |
|
115 /** |
|
116 * Clear current model |
|
117 * |
|
118 */ |
|
119 void ClearCurrentModel(); |
|
120 |
|
121 /** |
|
122 * Delete model of current character |
|
123 * |
|
124 */ |
|
125 void DeleteModelL(); |
|
126 |
|
127 /** |
|
128 * Delete all models of current character |
|
129 * |
|
130 */ |
|
131 void DeleteAllModelL(); |
|
132 |
|
133 /** |
|
134 * Check if clear button has been dimmed |
|
135 * |
|
136 * @return ETrue: dimmed; EFalse: undimmed |
|
137 */ |
|
138 TBool IsButtonDimmed(); |
|
139 |
|
140 /** |
|
141 * Check if all delete button has been dimmed |
|
142 * |
|
143 * @return ETrue: dimmed; EFalse: undimmed |
|
144 */ |
|
145 TBool IsAllDelete(); |
|
146 |
|
147 /** |
|
148 * Get character set Id, used to choose which characters will be displayed in SCT |
|
149 * |
|
150 * @param aRangeId Character range Id for special character table |
|
151 * |
|
152 * @return Id of character set. |
|
153 */ |
|
154 TInt SctCharacterSetId( TInt aRangeId ); |
|
155 |
|
156 /** |
|
157 * Get cyrillic lower character set Id |
|
158 * |
|
159 * @param aInputLanguage Current input language |
|
160 * |
|
161 * @return Id of character set. |
|
162 */ |
|
163 TInt SctCyrillicLowerCharacterSetId( TLanguage aInputLanguage ); |
|
164 |
|
165 /** |
|
166 * Get cyrillic upper character set Id |
|
167 * |
|
168 * @param aInputLanguage Current input language |
|
169 * |
|
170 * @return Id of character set. |
|
171 */ |
|
172 TInt SctCyrillicUpperCharacterSetId( TLanguage aInputLanguage ); |
|
173 |
|
174 /** |
|
175 * Before exit, do some necessary operation |
|
176 * |
|
177 */ |
|
178 void PrepareToExitL(); |
|
179 |
|
180 /** |
|
181 * Handle size changed |
|
182 * |
|
183 * @param aVarity: Use aVarity to load different resulotion's LAF data. |
|
184 */ |
|
185 void DoSizeChanged( TInt aVarity ); |
|
186 |
|
187 private: |
|
188 |
|
189 /** |
|
190 * Constructor. |
|
191 */ |
|
192 CTruiMainViewContainer(); |
|
193 |
|
194 /** |
|
195 * Perform the second phase construction of a CTruiMainViewContainer object. |
|
196 * |
|
197 * @param aRect: The rectangle that defines the control's extent. |
|
198 */ |
|
199 void ConstructL( const TRect& aRect ); |
|
200 |
|
201 /** |
|
202 * Create controls to be displayed in this container. |
|
203 * |
|
204 */ |
|
205 void InitializeControlsL(); |
|
206 |
|
207 /** |
|
208 * Create label and display it in the container. |
|
209 * |
|
210 * @param aResourceID The resource ID |
|
211 * @param aParent The parent of the control. |
|
212 * @param aObserver The observer of the control. |
|
213 * @return The pointer to the label. |
|
214 */ |
|
215 CEikLabel* CreateLabelL( const TInt aResourceId, |
|
216 const CCoeControl* aParent, |
|
217 MCoeControlObserver* aObserver ); |
|
218 |
|
219 /** |
|
220 * Create choicelist and display it in the container. |
|
221 * |
|
222 * @param aParent The parent of the control. |
|
223 * @param aObserver The observer of the control. |
|
224 * @param aTextArray The content displayed in the control. |
|
225 * @param aButton The attached button. |
|
226 * @return The pointer to the choiclist. |
|
227 */ |
|
228 CAknChoiceList* CreateChoiceListL( CCoeControl* aParent, |
|
229 MCoeControlObserver* aObserver, |
|
230 CDesCArray* aTextArray, |
|
231 CAknButton* aButton ); |
|
232 |
|
233 /** |
|
234 * Create HWRBox and display it in the container. |
|
235 * |
|
236 * @param aParent The parent of the control. |
|
237 * @param aObserver The observer of the control. |
|
238 * @return The pointer to the choiclist. |
|
239 */ |
|
240 CTruiHwrBox* CreateHwrBoxL( CCoeControl* aParent, |
|
241 MTruiHwrBoxObserver* aObserver ); |
|
242 |
|
243 /** |
|
244 * Return button's resourceId by Character Range Id. |
|
245 * |
|
246 * @param aRangeId The character range ID. |
|
247 * @return Reource Id to be used to create button for choicelist. |
|
248 */ |
|
249 TInt ButtonResourceId( TInt aRangeId ) const; |
|
250 |
|
251 /** |
|
252 * Pop Sct dialog |
|
253 * |
|
254 * @param aCharCase Character case for special character table |
|
255 * |
|
256 * @param aSpecialChar Reference to the buffer where selected special characters are put. |
|
257 * @param aCharSetResourceId The resource ID of special character table |
|
258 * @return Id of the button used to dismiss dialog. |
|
259 * |
|
260 */ |
|
261 TInt PopupSctDialogL( TInt aCharCase, TDes& aSpecialChars, TInt aCharSetResourceId ); |
|
262 |
|
263 /** |
|
264 * Popup information note |
|
265 * |
|
266 * @param aText The text to be displayed in CAknInformationNote. |
|
267 */ |
|
268 void PopupInformationNoteL( const TDesC& aText ); |
|
269 |
|
270 /** |
|
271 * Adjust special behavior characters to displayable characters. |
|
272 * @param aResult Return result for adjustment. |
|
273 * |
|
274 */ |
|
275 void AdjustDisplayChars( TDes& aResult ); |
|
276 |
|
277 /** |
|
278 * From CoeControl. |
|
279 * Handles key event. |
|
280 * |
|
281 * @param aKeyEvent The key event. |
|
282 * @param aType The type of key event: EEventKey, EEventKeyUp or EEventKeyDown. |
|
283 * @return Indicates whether or not the key event was used by this control. |
|
284 */ |
|
285 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
286 |
|
287 /** |
|
288 * GetHelpContext() |
|
289 * Identify the help context so that the framework can look up |
|
290 * the corresponding help topic |
|
291 * @param aContext Returns the help context |
|
292 */ |
|
293 void GetHelpContext( TCoeHelpContext& aContext ) const; |
|
294 |
|
295 /** |
|
296 * From CoeControl. |
|
297 * Responds to changes to the size and position of the contents of this control. |
|
298 */ |
|
299 void SizeChanged(); |
|
300 |
|
301 /** |
|
302 * From CoeControl. |
|
303 * Responds to a change in focus. |
|
304 * |
|
305 * @param aRect Contains the value that was passed to it by SetFocus(). |
|
306 */ |
|
307 void FocusChanged( TDrawNow aDrawNow ); |
|
308 |
|
309 /** |
|
310 * From CoeControl. |
|
311 * Draws the container. |
|
312 * |
|
313 * @param aRect The region of the control to be redrawn. Co-ordinates are relative to the control's origin (top left corner). |
|
314 */ |
|
315 virtual void Draw( const TRect& aRect ) const; |
|
316 |
|
317 /** |
|
318 * From CoeControl. |
|
319 * Handles a change to the control's resources. |
|
320 * |
|
321 * @param aType A message UID value. |
|
322 */ |
|
323 void HandleResourceChange( TInt aType ); |
|
324 |
|
325 void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
326 |
|
327 // From MTruiHWRBoxObserver |
|
328 /** |
|
329 * From MTruiHWRBoxObserver. |
|
330 * Input times out |
|
331 * Handle the save model event |
|
332 */ |
|
333 void SaveNewModelL(); |
|
334 |
|
335 /** |
|
336 * From MTruiHWRBoxObserver. |
|
337 * HandleEventL |
|
338 * Handle the message event from the HWRBox |
|
339 * @param aMessage According to the aMessage to handle the event |
|
340 */ |
|
341 void HandleEventL( TMessageType aMessage ); |
|
342 |
|
343 private: // data |
|
344 |
|
345 /** |
|
346 * The current trained character |
|
347 */ |
|
348 TBuf<KActiveCharSize> iCurrentChar; |
|
349 |
|
350 /** |
|
351 * The current tip of training character |
|
352 */ |
|
353 HBufC* iLabeltext; |
|
354 |
|
355 /** |
|
356 * Store the wrapped text to indicate which character is being trained. |
|
357 * |
|
358 * Own |
|
359 */ |
|
360 HBufC* iWrappedLabelText; |
|
361 |
|
362 /** |
|
363 * This text helps a user understand that he / she is |
|
364 * teaching his / her own character models to HWR engine |
|
365 * Not own |
|
366 */ |
|
367 CEikLabel* iLabel; |
|
368 |
|
369 /** |
|
370 * The Clear button in toolbar, used to clean up the Writing Box |
|
371 * Not own |
|
372 */ |
|
373 CAknButton* iClearBtn; |
|
374 |
|
375 /** |
|
376 * The preview button in toolbar |
|
377 * Not own |
|
378 */ |
|
379 CAknButton* iPreviewBtn; |
|
380 |
|
381 /** |
|
382 * The button currently associated with choicelist. |
|
383 * Not own |
|
384 */ |
|
385 CAknButton* iCurChoiceListBtn; |
|
386 |
|
387 /** |
|
388 * Left buttons allow quick access to the previous character |
|
389 * in the selected character range. |
|
390 * Not own |
|
391 */ |
|
392 CAknButton* iLeftBtn; |
|
393 |
|
394 /** |
|
395 * Indicates which character is currently selected. |
|
396 * Not own |
|
397 */ |
|
398 CEikLabel* iIindicator; |
|
399 |
|
400 /** |
|
401 * Right buttons allow quick access to the Next character |
|
402 * in the selected character range. |
|
403 * Not own |
|
404 */ |
|
405 CAknButton* iRightBtn; |
|
406 |
|
407 /** |
|
408 * ChoiceList is used for switching between character ranges. |
|
409 * Not own |
|
410 */ |
|
411 CAknChoiceList* iChoicelist; |
|
412 |
|
413 /** |
|
414 * The Writing Box is used for drawing a character model. |
|
415 * Not own |
|
416 */ |
|
417 CTruiHwrBox* iHwrBox; |
|
418 |
|
419 /** |
|
420 * Pointer to background |
|
421 * Own |
|
422 */ |
|
423 CAknsBasicBackgroundControlContext* iBackGround; |
|
424 |
|
425 /** |
|
426 * Rect of parent pane of label |
|
427 */ |
|
428 TRect iLabelPaneRect; |
|
429 |
|
430 /** |
|
431 * MultiLineTextLayout of Label |
|
432 */ |
|
433 TAknMultiLineTextLayout iMultilineLayout; |
|
434 |
|
435 RArray<TInt> iLineWidthArray; |
|
436 }; |
|
437 |
|
438 #endif // C_TRUIMAINVIEWCONTAINER_H |
|
439 |