|
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: Decleares the softkey controller class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef IPSSETUICTRLSOFTKEY_H |
|
20 #define IPSSETUICTRLSOFTKEY_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <eikcmobs.h> // MEikCommandObserver |
|
24 |
|
25 class CEikButtonGroupContainer; |
|
26 |
|
27 /** |
|
28 * Class to control softkeys. |
|
29 * |
|
30 * @since FS v1.0 |
|
31 * @lib IpsSosSettings.lib |
|
32 */ |
|
33 NONSHARABLE_CLASS( CIpsSetUiCtrlSoftkey ) : |
|
34 public CBase, |
|
35 public MEikCommandObserver |
|
36 { |
|
37 public: |
|
38 |
|
39 /** |
|
40 * Flags to track, which softkeys are used. |
|
41 */ |
|
42 enum TIpsSetUiSoftkeyFlags |
|
43 { |
|
44 /** Observed key. */ |
|
45 EObservingLeftSoftkey = 0x01, |
|
46 /** Temp key. */ |
|
47 EObservingUnknownKey = 0x02, |
|
48 /** Observed key. */ |
|
49 EObservingRightSoftkey = 0x04, |
|
50 /** Observed key. */ |
|
51 EObservingMiddleSoftkey = 0x08, |
|
52 /** Allow MSK label change. */ |
|
53 EAllowMiddleSoftkeyLabelChange = 0x10, |
|
54 /** Absorb key presses. */ |
|
55 EAbsorbing = 0x20, |
|
56 /** Keep this last. */ |
|
57 ELastFlag |
|
58 }; |
|
59 |
|
60 /** |
|
61 * Keys that are observed |
|
62 */ |
|
63 enum TIpsSetUiObservedKeys |
|
64 { |
|
65 ELeftSoftkey = 0, |
|
66 EUnknownKey, |
|
67 ERightSoftkey, |
|
68 EMiddleSoftkey |
|
69 }; |
|
70 |
|
71 public: // Constructors and destructor |
|
72 |
|
73 /** |
|
74 * Creates object from CIpsSetUiCtrlSoftkey and leaves it to cleanup stack |
|
75 * |
|
76 * @return, Constructed object |
|
77 */ |
|
78 static CIpsSetUiCtrlSoftkey* NewLC( |
|
79 CEikButtonGroupContainer& aSoftkeys ); |
|
80 |
|
81 /** |
|
82 * Create object from CIpsSetUiCtrlSoftkey |
|
83 * |
|
84 * @return, Constructed object |
|
85 */ |
|
86 static CIpsSetUiCtrlSoftkey* NewL( |
|
87 CEikButtonGroupContainer& aSoftkeys ); |
|
88 |
|
89 /** |
|
90 * Destructor |
|
91 */ |
|
92 virtual ~CIpsSetUiCtrlSoftkey(); |
|
93 |
|
94 public: // New operators |
|
95 |
|
96 /** |
|
97 * Get a direct access to softkeys |
|
98 * |
|
99 * @return Reference to softkey container |
|
100 */ |
|
101 CEikButtonGroupContainer& operator()(); |
|
102 |
|
103 public: // New functions |
|
104 |
|
105 |
|
106 /** |
|
107 * Sets the observer to the specific key |
|
108 * |
|
109 * @param aSoftkey Key to be observed |
|
110 * @param aCommandObserver The observer for the key events |
|
111 * @return KErrNone, when setting the observer is succesful |
|
112 */ |
|
113 TInt SetObserver( |
|
114 const TIpsSetUiObservedKeys aSoftkey, |
|
115 MEikCommandObserver& aCommandObserver ); |
|
116 |
|
117 /** |
|
118 * Sets/Removes the observers for the softkeys |
|
119 * |
|
120 * @param aLeftSoftkey Set/Remove left softkey observer |
|
121 * @param aRightSoftkey Set/Remove right softkey observer |
|
122 * @param aMiddleSoftkey Set/Remove middle softkey observer |
|
123 * @param aCommandObserver The observer for the key events |
|
124 * @return KErrNone, when setting the observer is succesful |
|
125 */ |
|
126 TInt SetObserver( |
|
127 const TBool aLeftSoftkey, |
|
128 const TBool aRightSoftkey, |
|
129 const TBool aMiddleSoftkey, |
|
130 MEikCommandObserver& aCommandObserver ); |
|
131 |
|
132 /** |
|
133 * Removes the observer |
|
134 * |
|
135 * @param aSoftkey |
|
136 */ |
|
137 void RemoveObserver( |
|
138 const TIpsSetUiObservedKeys aSoftkey ); |
|
139 |
|
140 /** |
|
141 * Defines a new softkey |
|
142 * |
|
143 * @param aLabelResource Resource of the text for the softkey label |
|
144 * @param aSoftkeyPos Position of the softkey |
|
145 * @param aSoftkeyCmd Command executed by pressing the softkey |
|
146 * @param aCommandObserver Observer to receive the events |
|
147 */ |
|
148 void DefineCustomSoftkeyL( |
|
149 const TInt aLabelResource, |
|
150 const TIpsSetUiObservedKeys aSoftkeyPos, |
|
151 const TInt aSoftkeyCmd, |
|
152 MEikCommandObserver* aCommandObserver ); |
|
153 |
|
154 /** |
|
155 * Defines a new softkey |
|
156 * |
|
157 * @param aSoftkeyLabel Text for the softkey label |
|
158 * @param aSoftkeyPos Position of the softkey |
|
159 * @param aSoftkeyCmd Command executed by pressing the softkey |
|
160 * @param aCommandObserver Observer to receive the events |
|
161 */ |
|
162 void DefineCustomSoftkeyL( |
|
163 const TDesC& aSoftkeyLabel, |
|
164 const TIpsSetUiObservedKeys aSoftkeyPos, |
|
165 const TInt aSoftkeyCmd, |
|
166 MEikCommandObserver* aCommandObserver ); |
|
167 |
|
168 /** |
|
169 * Checks the current status of MSK label updating availability |
|
170 * |
|
171 * @return ETrue, when MSK label change is allowed |
|
172 * @return EFalse, when MSK label change is not allowed |
|
173 */ |
|
174 TBool MSKLabelling(); |
|
175 |
|
176 /** |
|
177 * Sets the status of MSK label updating |
|
178 * |
|
179 * @param aNewState Allow/Disallow MSK label change |
|
180 */ |
|
181 void SetMSKLabelling( const TBool aNewState ); |
|
182 |
|
183 /** |
|
184 * Changes the label of the middle softkey |
|
185 * |
|
186 * @param aLabelResource Resource of the text for the softkey label |
|
187 * @param aCommandId Command executed by pressing the softkey |
|
188 * @param aCommandObserver Observer to receive the events |
|
189 */ |
|
190 void UpdateMiddleSoftkeyLabelL( |
|
191 const TInt aLabelResource, |
|
192 const TInt aCommandId, |
|
193 MEikCommandObserver* aCommandObserver ); |
|
194 |
|
195 /** |
|
196 * @param aParam Absorption on/off |
|
197 */ |
|
198 void SetAbsorb( const TBool aAbsorb ); |
|
199 |
|
200 protected: // Constructors |
|
201 |
|
202 /** |
|
203 * Default constructor for classCIpsSetUiCtrlSoftkey |
|
204 * |
|
205 * @return, Constructed object |
|
206 */ |
|
207 CIpsSetUiCtrlSoftkey( |
|
208 CEikButtonGroupContainer& aSoftkeys ); |
|
209 |
|
210 /** |
|
211 * Symbian 2-phase constructor |
|
212 */ |
|
213 void ConstructL(); |
|
214 |
|
215 private: // New functions |
|
216 |
|
217 /** |
|
218 * Changes observer status. |
|
219 * |
|
220 * @param aOn Turn observing On/Off. |
|
221 * @param aSoftkey Key to be controlled. |
|
222 * @param aCommandObserver Observer for the key. |
|
223 * @return Result of the assignment. |
|
224 */ |
|
225 TInt ChangeObserver( |
|
226 const TBool aOn, |
|
227 const TIpsSetUiObservedKeys aSoftkey, |
|
228 MEikCommandObserver& aCommandObserver ); |
|
229 |
|
230 // From base class MEikCommandObserver |
|
231 |
|
232 /** |
|
233 * Handle commands. Dummy for absroption. |
|
234 * |
|
235 * @param aCommandId Executed command. |
|
236 */ |
|
237 void ProcessCommandL( TInt aCommandId ); |
|
238 |
|
239 private: // Data |
|
240 |
|
241 /** |
|
242 * Softkey container |
|
243 */ |
|
244 CEikButtonGroupContainer& iSoftkeys; |
|
245 |
|
246 /** |
|
247 * Container for the flags |
|
248 */ |
|
249 TUint64 iFlags; |
|
250 |
|
251 /** |
|
252 * Container for the last used resource for MSK |
|
253 */ |
|
254 TInt iPreviousMskLabelResource; |
|
255 |
|
256 }; |
|
257 |
|
258 #endif /* IPSSETUICTRLSOFTKEY_H */ |
|
259 |
|
260 // End of File |
|
261 |