|
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: CTruiContainerBase class of TrainingUI |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_TRUICONTAINERBASE_H |
|
20 #define C_TRUICONTAINERBASE_H |
|
21 |
|
22 |
|
23 #include <coecntrl.h> |
|
24 #include <eiklabel.h> |
|
25 |
|
26 class CTruiAppUi; |
|
27 class CTruiEngine; |
|
28 class MCoeControlObserver; |
|
29 class CAknButton; |
|
30 class CAknToolbar; |
|
31 class TAknLayoutText; |
|
32 class CAknView; |
|
33 |
|
34 // Varity of landscape |
|
35 const TInt KLandscapeVarity = 1; |
|
36 |
|
37 // Varity of portrait |
|
38 const TInt KPortraitVarity = 0; |
|
39 |
|
40 const TInt KLabelMaxLines = 20; |
|
41 |
|
42 /* Key lead to the setting of always displaying wizard view*/ |
|
43 const TUint32 KAlwaysDisplayWizardKey = 0x00000001; |
|
44 |
|
45 _LIT( KLineBreak, "\n" ); |
|
46 |
|
47 const TUid KAknfepUID = { 0x100056de }; |
|
48 |
|
49 const TInt KExtraSize = 10; |
|
50 |
|
51 /** |
|
52 * Base class for contrainers |
|
53 * All contrainer need to be inherited from this class |
|
54 * |
|
55 */ |
|
56 class CTruiContainerBase : public CCoeControl |
|
57 { |
|
58 public: |
|
59 |
|
60 /** |
|
61 * Destructor. |
|
62 */ |
|
63 virtual ~CTruiContainerBase(); |
|
64 |
|
65 /** |
|
66 * Get the origin size in which input the model for preset symbols. |
|
67 * |
|
68 * @return The size in which to input preset symbols. |
|
69 */ |
|
70 static TSize OriginSymbolSize(); |
|
71 inline void SetView( CAknView* aView ) |
|
72 { |
|
73 iView = aView; |
|
74 }; |
|
75 protected: |
|
76 CTruiContainerBase(); |
|
77 |
|
78 /** |
|
79 * Wrap the text to fit the minisize of Label |
|
80 * |
|
81 * @param aLabel The pointer to the label. |
|
82 * @param aText The origin text |
|
83 * @param aMaxLines The max line of the wrapped text. |
|
84 * @param aWrappedText Store the wrapped text. |
|
85 * @return The number of lines. |
|
86 */ |
|
87 TInt WrapLabelText( const CEikLabel* aLabel, const TDesC& aText, |
|
88 TInt aMaxLines, HBufC* aWrappedText ); |
|
89 |
|
90 /** |
|
91 * Wrap the text to fit the minisize of Label |
|
92 * |
|
93 * @param aLayoutText Layout of text. |
|
94 * @param aText The origin text |
|
95 * @param aMaxLines The max line of the wrapped text. |
|
96 * @param aWrappedText Store the wrapped text. |
|
97 * @return The number of lines. |
|
98 */ |
|
99 TInt WrapLabelText( const TAknLayoutText& aLayoutText, const TDesC& aText, |
|
100 TInt aMaxLines, HBufC* aWrappedText ); |
|
101 |
|
102 /** |
|
103 * Wrap the text to fit Label |
|
104 * |
|
105 * @param aFont Font of text. |
|
106 * @param aText The origin text need to be wrapped |
|
107 * @param aLineWidthArray Line width array. |
|
108 * @param aWrappedText Store the wrapped text. |
|
109 */ |
|
110 void WrapLabelTextL( const CFont* aFont, const TDesC& aText, |
|
111 const RArray<TInt>& aLineWidthArray, |
|
112 HBufC* aWrappedText ); |
|
113 |
|
114 |
|
115 /** |
|
116 * Create skin specified button from resource |
|
117 * |
|
118 * @param aResourceId The resource Id. |
|
119 * @param aParent The parent of control |
|
120 * @param aObserver The observer of control |
|
121 * @return Instance of aknbutton. |
|
122 */ |
|
123 CAknButton* CreateButtonL( TInt aResourceId, |
|
124 const CCoeControl* aParent, |
|
125 MCoeControlObserver* aObserver ); |
|
126 |
|
127 /** |
|
128 * Add skin specified buttons into toolbar |
|
129 * |
|
130 * @param aToolbar The toolbar will contain skin-specified buttons. |
|
131 * @param aResourceId Button groups resource id. |
|
132 */ |
|
133 void AddButtonsToToolbarL( CAknToolbar* aToolbar, TInt aResourceId ); |
|
134 |
|
135 /** |
|
136 * Return current keyboard mode. |
|
137 * |
|
138 * @return 0: ITU-T; 1: QWERTY. |
|
139 */ |
|
140 TInt CurrentKeyBoardModeL(); |
|
141 |
|
142 /** |
|
143 * Read setting from ini file to decide if display wizard view. |
|
144 * |
|
145 * @param aKey Key value in ini file. |
|
146 * @param aValue Value of the key. |
|
147 */ |
|
148 void GetSettingFromIniFileL( TUint32 aKey, TInt& aValue ); |
|
149 |
|
150 /** |
|
151 * Save settings into file |
|
152 * |
|
153 * @param aKey Key value to specify one setting |
|
154 * @param aValue Value to be stored |
|
155 */ |
|
156 void SaveSettingIntoIniFileL( TUint32 aKey, TInt aValue ); |
|
157 |
|
158 /** |
|
159 * Get cached color of skin for label control |
|
160 * |
|
161 * @param aColor The color of Label will be set |
|
162 */ |
|
163 TInt GetCachedLabelTextColor( TRgb& aColor ); |
|
164 |
|
165 /** |
|
166 * Get cached color of skin for icon |
|
167 * |
|
168 * @param aColorId The color id of icon color group |
|
169 * @param aColorIndex The color index in the color group |
|
170 * @param aColor On return, the catched color. |
|
171 */ |
|
172 TInt GetCachedIcontColor( TRgb& aColor, const TAknsItemID& aColorId, TInt aColorIndex ); |
|
173 |
|
174 /** |
|
175 * Construct icons from resource. |
|
176 * |
|
177 * @param aResourceId Resource Id. |
|
178 * @return The constructed icon |
|
179 */ |
|
180 CGulIcon* ConstructIconFromResourceL( TInt aResourceId ); |
|
181 |
|
182 /** |
|
183 * From CoeControl. |
|
184 * Handles a change to the control's resources. |
|
185 * |
|
186 * @param aType A message UID value. |
|
187 */ |
|
188 void HandleResourceChange( TInt aType ); |
|
189 |
|
190 private: |
|
191 /** |
|
192 * Create skin specified button from resource |
|
193 * |
|
194 * @param aReader The resource reader. |
|
195 * @return Instance of aknbutton. |
|
196 */ |
|
197 CAknButton* ConstructButtonFromResourceL( TResourceReader& aReader ); |
|
198 |
|
199 /** |
|
200 * Wrap the text to fit the minisize of Label |
|
201 * |
|
202 * @param aFont Font of text. |
|
203 * @param aWidth Width of text. |
|
204 * @param aText The origin text |
|
205 * @param aMaxLines The max line of the wrapped text. |
|
206 * @param aWrappedText Store the wrapped text. |
|
207 * @return The number of lines. |
|
208 */ |
|
209 TInt DoWrapLabelText( const CFont* aFont, TInt aWidth, |
|
210 const TDesC& aText, |
|
211 TInt aMaxLines, |
|
212 HBufC* aWrappedText ); |
|
213 |
|
214 |
|
215 protected: // data |
|
216 |
|
217 /** |
|
218 * Point to the controlor class of the application. |
|
219 * Not Own. |
|
220 */ |
|
221 CTruiAppUi* iAppUi; |
|
222 |
|
223 /** |
|
224 * hand writing engine |
|
225 * Not Own. |
|
226 */ |
|
227 CTruiEngine* iEngine; |
|
228 CAknView* iView; |
|
229 }; |
|
230 |
|
231 #endif // C_TRUICONTAINERBASE_H |
|
232 |