|
1 /* |
|
2 * Copyright (c) 2009, 2010 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: Helper class to handle virtual keypad text labels |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CDIALERKEYPADLABELMANAGER_H |
|
19 #define CDIALERKEYPADLABELMANAGER_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <e32std.h> |
|
23 #include <e32base.h> |
|
24 #include "cdialercenrepwrapper.h" |
|
25 |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CPtiEngine; |
|
29 class CEnvironmentChangeNotifier; |
|
30 |
|
31 |
|
32 // CALLBACK INTERFACE |
|
33 NONSHARABLE_CLASS( MDialerKeyPadLabelManagerCallback ) |
|
34 { |
|
35 public: |
|
36 /** |
|
37 * This event is given when change in system settings has |
|
38 * caused key label texts to change. All the TPtrC descriptors |
|
39 * previously returned by CDialerKeyPadLabelManager become |
|
40 * dangling references when this happens and they must not |
|
41 * be used after this method is called. |
|
42 */ |
|
43 virtual void KeyLabelsChanged() = 0; |
|
44 }; |
|
45 |
|
46 |
|
47 // CLASS DECLARATION |
|
48 |
|
49 /** |
|
50 * CDialerKeyPadLabelManager |
|
51 * |
|
52 */ |
|
53 NONSHARABLE_CLASS( CDialerKeyPadLabelManager ) : public CBase, public MDialerCenRepObserver |
|
54 { |
|
55 public: // Constructors and destructor |
|
56 |
|
57 /** |
|
58 * Destructor. |
|
59 */ |
|
60 ~CDialerKeyPadLabelManager(); |
|
61 |
|
62 /** |
|
63 * Two-phased constructor. |
|
64 */ |
|
65 static CDialerKeyPadLabelManager* NewL( CCoeEnv& aCoeEnv, |
|
66 MDialerKeyPadLabelManagerCallback& aObserver ); |
|
67 |
|
68 /** |
|
69 * Two-phased constructor. |
|
70 */ |
|
71 static CDialerKeyPadLabelManager* NewLC( CCoeEnv& aCoeEnv, |
|
72 MDialerKeyPadLabelManagerCallback& aObserver ); |
|
73 |
|
74 private: // consturctors |
|
75 |
|
76 /** |
|
77 * Constructor for performing 1st stage construction |
|
78 */ |
|
79 CDialerKeyPadLabelManager( CCoeEnv& aCoeEnv, |
|
80 MDialerKeyPadLabelManagerCallback& aObserver ); |
|
81 |
|
82 /** |
|
83 * Symbian default constructor for performing 2nd stage construction |
|
84 */ |
|
85 void ConstructL(); |
|
86 |
|
87 public: // methods |
|
88 |
|
89 /** |
|
90 * Get number label for the button. |
|
91 * @return Reference to the number text in current global number mode. |
|
92 * The reference is valid until this label manager is deleted or |
|
93 * global number mode is changed. Callback KeyLabelsChanged() |
|
94 * is given to observer in the latter case. |
|
95 */ |
|
96 TPtrC ButtonNumLabel( TInt aIndex ) const; |
|
97 |
|
98 /** |
|
99 * Get first row alphabet label for the button |
|
100 * @return Reference to descriptor containing text for the first |
|
101 * row of alphabets to be shown on the key. The reference is |
|
102 * valid until this label manager is deleted or input language |
|
103 * is changed. Callback KeyLabelsChanged() |
|
104 * is given to observer in the latter case. |
|
105 */ |
|
106 TPtrC ButtonFirstAlphaLabel( TInt aIndex ) const; |
|
107 |
|
108 /** |
|
109 * Get second row alphabet label for the button |
|
110 * @return Reference to descriptor containing text for the first |
|
111 * row of alphabets to be shown on the key. The reference is |
|
112 * valid until this label manager is deleted or input language |
|
113 * is changed. Callback KeyLabelsChanged() |
|
114 * is given to observer in the latter case. |
|
115 */ |
|
116 TPtrC ButtonSecondAlphaLabel( TInt aIndex ) const; |
|
117 |
|
118 public: // from MDialerCenRepObserver |
|
119 |
|
120 /** |
|
121 * Handle change in one of the observed repositories. |
|
122 */ |
|
123 void HandleRepositoryChange( TUid aRepository, TUint32 aId ); |
|
124 |
|
125 private: // methods |
|
126 |
|
127 /** |
|
128 * Handle environment change event. We are interested about digit |
|
129 * type changes in locale data. |
|
130 */ |
|
131 void HandleEnvChange(); |
|
132 |
|
133 /** |
|
134 * Static wrapper for HandleEnvChange() function to be passed in TCallBack object. |
|
135 */ |
|
136 static TInt EnvChangeCallback( TAny* aSelfPtr ); |
|
137 |
|
138 /** |
|
139 * Update button text labels to match current input and UI language. |
|
140 */ |
|
141 void UpdateTextLabelsL(); |
|
142 |
|
143 /** |
|
144 * Update button number labels to use current global number mode. |
|
145 */ |
|
146 void UpdateNumLabelsL(); |
|
147 |
|
148 /** |
|
149 * Get the full path of the keypad resource file to be used in current situation. |
|
150 * @param aFileName On return, contains the file name. Caller is responsible |
|
151 * of supplying large enough buffer. Maximum path length |
|
152 * in Symbian is 256 characters. |
|
153 */ |
|
154 void GetResourceFileNameL( TDes& aFileName ); |
|
155 |
|
156 /** |
|
157 * Returns code of the script to be used in current situation. |
|
158 * It depends on the current input language, current UI language, and all |
|
159 * available input languages on the device. |
|
160 */ |
|
161 TInt LabelScriptToUseL() const; |
|
162 |
|
163 /** |
|
164 * Returns code of the Chinese script to be used in key labels. |
|
165 * This depends on the currently active Chinese adaptive search mode. |
|
166 * This should be used only when current input language is Chinese. |
|
167 */ |
|
168 TInt ChineseScriptToUseL() const; |
|
169 |
|
170 private: // data |
|
171 |
|
172 /** Control environment to use for resource management */ |
|
173 CCoeEnv& iCoeEnv; |
|
174 |
|
175 /** Observer is notified when keypad labels are changed */ |
|
176 MDialerKeyPadLabelManagerCallback& iObserver; |
|
177 |
|
178 /** PtiEngine instance is needed to find out available input languages */ |
|
179 CPtiEngine* iPtiEngine; |
|
180 |
|
181 /** AknFep repository stores the current input language */ |
|
182 CDialerCenRepWrapper* iAknFepRepository; |
|
183 |
|
184 /** Avkon repository stores the current Chinese matching mode */ |
|
185 CDialerCenRepWrapper* iAvkonRepository; |
|
186 |
|
187 /** Helper to observe locale changes. Locale data contains digit type used for number labels. */ |
|
188 CEnvironmentChangeNotifier* iEnvChangeNotifier; |
|
189 |
|
190 /** |
|
191 * Array of number labels. Indexing matches that of the |
|
192 * CDialerKeypadContainer::iButtons array. Owned. |
|
193 */ |
|
194 CDesCArray* iKeypadNumLabelArray; |
|
195 |
|
196 /** |
|
197 * Array of first row alphabet labels. Indexing matches that of the |
|
198 * CDialerKeypadContainer::iButtons array. Owned. |
|
199 */ |
|
200 CDesCArray* iKeypadFirstLabelArray; |
|
201 |
|
202 /** |
|
203 * Array of second row alphabet labels. Indexing matches that of the |
|
204 * CDialerKeypadContainer::iButtons array. Owned. |
|
205 */ |
|
206 CDesCArray* iKeypadSecondLabelArray; |
|
207 |
|
208 /** |
|
209 * Offset value of currently loaded keypad resource. |
|
210 * 0 if there's no loaded resource. |
|
211 */ |
|
212 TInt iResourceOffset; |
|
213 |
|
214 /** Script ID of the current keypad labels */ |
|
215 TInt iLabelScriptInUse; |
|
216 |
|
217 /** Digit type currently used for keypad number labels */ |
|
218 TDigitType iDigitTypeInUse; |
|
219 }; |
|
220 |
|
221 #endif // CDIALERKEYPADLABELMANAGER_H |
|
222 |