|
1 /* |
|
2 * Copyright (c) 2009 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: ESMR time (start-end) field implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CMRTIMECONTAINER_H |
|
19 #define CMRTIMECONTAINER_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <coecntrl.h> |
|
23 #include "esmrdef.h" |
|
24 |
|
25 // FORWARD DECLARATIONS |
|
26 class MAknsControlContext; |
|
27 class CAknsFrameBackgroundControlContext; |
|
28 class MESMRFieldValidator; |
|
29 class CESMRLayoutManager; |
|
30 class CEikTimeEditor; |
|
31 class CMRLabel; |
|
32 class CAknsBasicBackgroundControlContext; |
|
33 |
|
34 /** |
|
35 * Container control for the time fields and the separator. |
|
36 */ |
|
37 NONSHARABLE_CLASS( CMRTimeContainer ): public CCoeControl |
|
38 { |
|
39 |
|
40 public: |
|
41 /** |
|
42 * Creates new CMRTimeContainer object. Ownership |
|
43 * is transferred to caller. |
|
44 * @param aValidator validator object |
|
45 * @param aParent parent control |
|
46 * @param aFieldId CESMRField id of the control/container |
|
47 * @return Pointer to created object, |
|
48 */ |
|
49 static CMRTimeContainer* NewL( |
|
50 MESMRFieldValidator* aValidator, |
|
51 CCoeControl* aParent, |
|
52 TESMREntryFieldId aFieldId ); |
|
53 |
|
54 /** |
|
55 * Destructor. |
|
56 */ |
|
57 ~CMRTimeContainer(); |
|
58 |
|
59 public: // From CCoeControl |
|
60 void SetContainerWindowL( const CCoeControl& aControl ); |
|
61 TInt CountComponentControls() const; |
|
62 CCoeControl* ComponentControl( TInt aInd ) const; |
|
63 void SizeChanged(); |
|
64 TKeyResponse OfferKeyEventL(const TKeyEvent& aEvent, TEventCode aType); |
|
65 void FocusChanged(TDrawNow aDrawNow); |
|
66 void HandlePointerEventL( const TPointerEvent &aPointerEvent ); |
|
67 void ActivateL(); |
|
68 |
|
69 public: // interface |
|
70 |
|
71 /** |
|
72 * Returns currently focused editor. |
|
73 * |
|
74 * @return currently focused editor |
|
75 */ |
|
76 CEikTimeEditor* FocusedEditor(); |
|
77 |
|
78 /** |
|
79 * Returns ETrue if its ok to change focus. |
|
80 * |
|
81 * @param current field id |
|
82 * @param next field id |
|
83 * @return ETrue if its ok to change focus |
|
84 */ |
|
85 TBool OkToLoseFocusL( TESMREntryFieldId aFrom, TESMREntryFieldId aTo ); |
|
86 |
|
87 /** |
|
88 * Sets Background rect of Time editor field. |
|
89 * |
|
90 * @param current background rect of time field |
|
91 */ |
|
92 void SetBgRect( TRect bgRect ); |
|
93 |
|
94 /** |
|
95 * Sets Field valiator |
|
96 * |
|
97 * @param aValidator |
|
98 */ |
|
99 void SetValidatorL( MESMRFieldValidator* aValidator ); |
|
100 |
|
101 /** |
|
102 * Called when locale environemnt has changed |
|
103 */ |
|
104 void EnvironmentChangedL(); |
|
105 |
|
106 private: // Implementation |
|
107 /** |
|
108 * Constructor. |
|
109 * |
|
110 * @param aValidator validator object |
|
111 */ |
|
112 CMRTimeContainer( MESMRFieldValidator* aValidator, TESMREntryFieldId aFieldId ); |
|
113 |
|
114 /** |
|
115 * Second phase constructor. |
|
116 * |
|
117 * @param aParent parent control |
|
118 */ |
|
119 void ConstructL( CCoeControl* aParent ); |
|
120 |
|
121 /** |
|
122 * Changes focus to left if its possible. |
|
123 * |
|
124 * @param aEvent key event |
|
125 * @param aType event code |
|
126 */ |
|
127 TKeyResponse ChangeFocusLeftL(const TKeyEvent& aEvent, TEventCode aType); |
|
128 |
|
129 /** |
|
130 * Changes focus to right if its possible. |
|
131 * |
|
132 * @param aEvent key event |
|
133 * @param aType event code |
|
134 */ |
|
135 TKeyResponse ChangeFocusRightL(const TKeyEvent& aEvent, TEventCode aType); |
|
136 |
|
137 void CheckIfValidatingNeededL( |
|
138 TBool aStartFocusedBefore, |
|
139 TInt aStartFieldIndex, |
|
140 TBool aEndFocusedBefore, |
|
141 TInt aEndFieldIndex ); |
|
142 |
|
143 void TriggerStartTimeChangedL(); |
|
144 void TriggerEndTimeChangedL(); |
|
145 |
|
146 void InitializeL(); |
|
147 void Reset(); |
|
148 |
|
149 private: // data |
|
150 /** |
|
151 * Own. Start time editor. |
|
152 */ |
|
153 CEikTimeEditor* iStartTime; |
|
154 |
|
155 /** |
|
156 * Own. End time editor. |
|
157 */ |
|
158 CEikTimeEditor* iEndTime; |
|
159 |
|
160 /** |
|
161 * Own. Separator label between start and end fields. |
|
162 */ |
|
163 CMRLabel* iSeparator; |
|
164 |
|
165 /** |
|
166 * Not owned. Validator class for time and sanity checks. |
|
167 */ |
|
168 |
|
169 MESMRFieldValidator* iValidator; |
|
170 // Own: Field Id |
|
171 TESMREntryFieldId iFieldId; |
|
172 // Background control context |
|
173 MAknsControlContext* iBackground; |
|
174 // Actual background for the start time editor |
|
175 CAknsFrameBackgroundControlContext* iStartTimeBgContext; |
|
176 // Actual background for the end time editor |
|
177 CAknsFrameBackgroundControlContext* iEndTimeBgContext; |
|
178 // Not owned. Layout manager. |
|
179 CESMRLayoutManager* iLayout; |
|
180 // Own. Field background control context. |
|
181 CAknsBasicBackgroundControlContext* iBgCtrlContext; |
|
182 /// Own: Focus rect |
|
183 TRect iBgRect; |
|
184 /// Ref: Pointer to container window |
|
185 const CCoeControl* iContainerWindow; |
|
186 }; |
|
187 |
|
188 #endif // CMRTIMECONTAINER_H |
|
189 // End of file |
|
190 |