17 |
17 |
18 |
18 |
19 #ifndef CESMRTIMEFIELD_H |
19 #ifndef CESMRTIMEFIELD_H |
20 #define CESMRTIMEFIELD_H |
20 #define CESMRTIMEFIELD_H |
21 |
21 |
22 #include "cesmriconfield.h" |
22 // INCLUDES |
|
23 #include "cesmrfield.h" |
23 |
24 |
24 //Forward declarations |
25 //Forward declarations |
25 class CEikLabel; |
26 class CMRImage; |
26 class CTimeContainer; |
27 class CMRTimeContainer; |
27 class MESMRFieldValidator; |
28 class MESMRFieldValidator; |
28 class CEikTimeEditor; |
|
29 |
29 |
30 /** |
30 /** |
31 * Time field for ESMR editor. Time field has start and end time |
31 * Time field for ESMR editor. Time field has start and end time |
32 * separated by a '-'. Focus traverses from left to right and right |
32 * separated by a '-'. Focus traverses from left to right and right |
33 * to left. |
33 * to left. |
34 */ |
34 */ |
35 NONSHARABLE_CLASS( CESMRTimeField ): public CESMRIconField |
35 NONSHARABLE_CLASS( CESMRTimeField ): public CESMRField |
36 { |
36 { |
37 public: |
37 public: |
38 /** |
38 /** |
39 * Creates new CESMRTimeField object. Ownership |
39 * Creates new CESMRTimeField object. Ownership |
40 * is transferred to caller. |
40 * is transferred to caller. |
49 ~CESMRTimeField(); |
49 ~CESMRTimeField(); |
50 |
50 |
51 public: // From CCoeControl |
51 public: // From CCoeControl |
52 void SetContainerWindowL( const CCoeControl& aControl ); |
52 void SetContainerWindowL( const CCoeControl& aControl ); |
53 TKeyResponse OfferKeyEventL(const TKeyEvent& aEvent, TEventCode aType); |
53 TKeyResponse OfferKeyEventL(const TKeyEvent& aEvent, TEventCode aType); |
|
54 TInt CountComponentControls() const; |
|
55 CCoeControl* ComponentControl( TInt aIndex ) const; |
|
56 void SizeChanged(); |
54 |
57 |
55 public: // From ESMRField |
58 public: // From ESMRField |
56 void InitializeL(); |
|
57 TBool OkToLoseFocusL( TESMREntryFieldId aNext ); |
59 TBool OkToLoseFocusL( TESMREntryFieldId aNext ); |
58 void SetOutlineFocusL( TBool aFocus ); |
60 void SetOutlineFocusL( TBool aFocus ); |
59 |
61 void SetValidatorL( MESMRFieldValidator* aValidator ); |
|
62 TBool ExecuteGenericCommandL( TInt aCommand ); |
|
63 |
60 private: |
64 private: |
61 /** |
65 /** |
62 * Constructor. |
66 * Constructor. |
63 */ |
67 */ |
64 CESMRTimeField(); |
68 CESMRTimeField(); |
70 */ |
74 */ |
71 void ConstructL( MESMRFieldValidator* aValidator ); |
75 void ConstructL( MESMRFieldValidator* aValidator ); |
72 |
76 |
73 private: |
77 private: |
74 /** |
78 /** |
75 * Own. Container for the time fields. |
79 * Ref: Container for the time fields. |
|
80 * Created by this class but deleted by base class. |
76 */ |
81 */ |
77 CTimeContainer* iContainer; |
82 CMRTimeContainer* iContainer; |
78 }; |
|
79 |
|
80 |
|
81 //Forward declarations |
|
82 class MAknsControlContext; |
|
83 class CAknsFrameBackgroundControlContext; |
|
84 |
|
85 /** |
|
86 * Container control for the time fields and the separator. |
|
87 */ |
|
88 NONSHARABLE_CLASS( CTimeContainer ): public CCoeControl |
|
89 { |
|
90 |
|
91 public: |
|
92 /** |
|
93 * Creates new CTimeContainer object. Ownership |
|
94 * is transferred to caller. |
|
95 * @param aValidator validator object |
|
96 * @param aParent parent control |
|
97 * @param aFieldId CESMRField id of the control/container |
|
98 * @return Pointer to created object, |
|
99 */ |
|
100 static CTimeContainer* NewL( |
|
101 MESMRFieldValidator* aValidator, |
|
102 CCoeControl* aParent, |
|
103 TESMREntryFieldId aFieldId ); |
|
104 |
|
105 /** |
|
106 * Destructor. |
|
107 */ |
|
108 ~CTimeContainer(); |
|
109 |
|
110 public: // From CCoeControl |
|
111 void SetContainerWindowL( const CCoeControl& aControl ); |
|
112 TInt CountComponentControls() const; |
|
113 CCoeControl* ComponentControl( TInt aInd ) const; |
|
114 void SizeChanged(); |
|
115 TKeyResponse OfferKeyEventL(const TKeyEvent& aEvent, TEventCode aType); |
|
116 void FocusChanged(TDrawNow aDrawNow); |
|
117 void ActivateL(); |
|
118 void PositionChanged(); |
|
119 |
|
120 public: // interface |
|
121 /** |
|
122 * Sets font and font color for editors. |
|
123 * |
|
124 * @param aFont new font |
|
125 * @param aLayout pointer to layoutmanager |
|
126 */ |
|
127 void SetFontL( const CFont* aFont, CESMRLayoutManager* aLayout ); |
|
128 |
|
129 /** |
|
130 * Returns currently focused editor. |
|
131 * |
|
132 * @return currently focused editor |
|
133 */ |
|
134 CEikTimeEditor* FocusedEditor(); |
|
135 |
|
136 /** |
|
137 * Returns ETrue if its ok to change focus. |
|
138 * |
|
139 * @param current field id |
|
140 * @param next field id |
|
141 * @return ETrue if its ok to change focus |
|
142 */ |
|
143 TBool OkToLoseFocusL( TESMREntryFieldId aFrom, TESMREntryFieldId aTo ); |
|
144 |
|
145 private: // Implementation |
|
146 /** |
|
147 * Constructor. |
|
148 * |
|
149 * @param aValidator validator object |
|
150 */ |
|
151 CTimeContainer( MESMRFieldValidator* aValidator, TESMREntryFieldId aFieldId ); |
|
152 |
|
153 /** |
|
154 * Second phase constructor. |
|
155 * |
|
156 * @param aParent parent control |
|
157 */ |
|
158 void ConstructL( CCoeControl* aParent ); |
|
159 |
|
160 /** |
|
161 * Changes focus to left if its possible. |
|
162 * |
|
163 * @param aEvent key event |
|
164 * @param aType event code |
|
165 */ |
|
166 TKeyResponse ChangeFocusLeftL(const TKeyEvent& aEvent, TEventCode aType); |
|
167 |
|
168 /** |
|
169 * Changes focus to right if its possible. |
|
170 * |
|
171 * @param aEvent key event |
|
172 * @param aType event code |
|
173 */ |
|
174 TKeyResponse ChangeFocusRightL(const TKeyEvent& aEvent, TEventCode aType); |
|
175 |
|
176 void CheckIfValidatingNeededL( |
|
177 TBool aStartFocusedBefore, |
|
178 TInt aStartFieldIndex, |
|
179 TBool aEndFocusedBefore, |
|
180 TInt aEndFieldIndex ); |
|
181 |
|
182 void TriggerStartTimeChangedL(); |
|
183 void TriggerEndTimeChangedL(); |
|
184 |
|
185 private: // data |
|
186 /** |
|
187 * Own. Start time editor. |
|
188 */ |
|
189 CEikTimeEditor* iStartTime; |
|
190 |
|
191 /** |
|
192 * Own. End time editor. |
|
193 */ |
|
194 CEikTimeEditor* iEndTime; |
|
195 |
|
196 /** |
|
197 * Own. Separator label between start and end fields. |
|
198 */ |
|
199 CEikLabel* iSeparator; |
|
200 |
|
201 /** |
|
202 * Not owned. Validator class for time and sanity checks. |
|
203 */ |
|
204 |
83 |
205 MESMRFieldValidator* iValidator; |
84 /// Own: Field icon |
206 // Own: Field Id |
85 CMRImage* iFieldIcon; |
207 TESMREntryFieldId iFieldId; |
|
208 // Background control context |
|
209 MAknsControlContext* iBackground; |
|
210 // Actual background for the start time editor |
|
211 CAknsFrameBackgroundControlContext* iStartTimeBgContext; |
|
212 // Actual background for the end time editor |
|
213 CAknsFrameBackgroundControlContext* iEndTimeBgContext; |
|
214 // Not owned. Layout manager. |
|
215 CESMRLayoutManager* iLayout; |
|
216 }; |
86 }; |
217 |
87 |
218 #endif // CESMRTIMEFIELD_H |
88 #endif // CESMRTIMEFIELD_H |
219 |
89 |