45 } // unnamed namespace |
47 } // unnamed namespace |
46 |
48 |
47 // ======== MEMBER FUNCTIONS ======== |
49 // ======== MEMBER FUNCTIONS ======== |
48 |
50 |
49 // ----------------------------------------------------------------------------- |
51 // ----------------------------------------------------------------------------- |
|
52 // CESMRViewerStartDateField::CESMRViewerStartDateField() |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CESMRViewerStartDateField::CESMRViewerStartDateField() |
|
56 { |
|
57 FUNC_LOG; |
|
58 |
|
59 SetFieldId ( EESMRFieldStartDate ); |
|
60 SetFocusType( EESMRHighlightFocus ); |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CESMRViewerStartDateField::~CESMRViewerStartDateField() |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 CESMRViewerStartDateField::~CESMRViewerStartDateField() |
|
68 { |
|
69 FUNC_LOG; |
|
70 |
|
71 delete iIcon; |
|
72 delete iLockIcon; |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
50 // CESMRViewerStartDateField::NewL() |
76 // CESMRViewerStartDateField::NewL() |
51 // ----------------------------------------------------------------------------- |
77 // ----------------------------------------------------------------------------- |
52 // |
78 // |
53 CESMRViewerStartDateField* CESMRViewerStartDateField::NewL() |
79 CESMRViewerStartDateField* CESMRViewerStartDateField::NewL() |
54 { |
80 { |
55 CESMRViewerStartDateField* self = new (ELeave) CESMRViewerStartDateField(); |
81 FUNC_LOG; |
|
82 |
|
83 CESMRViewerStartDateField* self = |
|
84 new (ELeave) CESMRViewerStartDateField(); |
56 CleanupStack::PushL( self ); |
85 CleanupStack::PushL( self ); |
57 self->ConstructL(); |
86 self->ConstructL(); |
58 CleanupStack::Pop( self ); |
87 CleanupStack::Pop( self ); |
59 return self; |
88 return self; |
60 } |
89 } |
61 |
90 |
62 // ----------------------------------------------------------------------------- |
91 // ----------------------------------------------------------------------------- |
63 // CESMRViewerStartDateField::~CESMRViewerStartDateField() |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 CESMRViewerStartDateField::~CESMRViewerStartDateField() |
|
67 { |
|
68 delete iLabel; |
|
69 delete iIcon; |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CESMRViewerStartDateField::CESMRViewerStartDateField() |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 CESMRViewerStartDateField::CESMRViewerStartDateField() |
|
77 { |
|
78 SetFieldId ( EESMRFieldStartDate ); |
|
79 SetFocusType( EESMRHighlightFocus ); |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CESMRViewerStartDateField::ConstructL() |
92 // CESMRViewerStartDateField::ConstructL() |
84 // ----------------------------------------------------------------------------- |
93 // ----------------------------------------------------------------------------- |
85 // |
94 // |
86 void CESMRViewerStartDateField::ConstructL() |
95 void CESMRViewerStartDateField::ConstructL() |
87 { |
96 { |
|
97 FUNC_LOG; |
|
98 |
88 iLabel = CMRLabel::NewL(); |
99 iLabel = CMRLabel::NewL(); |
89 iLabel->SetParent( this ); |
100 iLabel->SetParent( this ); |
|
101 CESMRField::ConstructL( iLabel ); // ownership transfered |
|
102 |
90 iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapDateStart ); |
103 iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapDateStart ); |
91 iIcon->SetParent( this ); |
104 iIcon->SetParent( this ); |
92 } |
105 } |
93 |
106 |
94 // --------------------------------------------------------------------------- |
|
95 // CESMRViewerStartDateField::InitializeL() |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 void CESMRViewerStartDateField::InitializeL() |
|
99 { |
|
100 TAknLayoutText text = NMRLayoutManager::GetLayoutText( |
|
101 Rect(), |
|
102 NMRLayoutManager::EMRTextLayoutTextEditor ); |
|
103 |
|
104 iLabel->SetFont( text.Font() ); |
|
105 // This is called so that theme changes will apply when changing theme "on the fly" |
|
106 if ( IsFocused() ) |
|
107 { |
|
108 iLabel->FocusChanged( EDrawNow ); |
|
109 } |
|
110 |
|
111 AknLayoutUtils::OverrideControlColorL ( *iLabel, EColorLabelText, |
|
112 KRgbBlack ); |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
107 // ----------------------------------------------------------------------------- |
116 // CESMRViewerStartDateField::InternalizeL() |
108 // CESMRViewerStartDateField::InternalizeL() |
117 // ----------------------------------------------------------------------------- |
109 // ----------------------------------------------------------------------------- |
118 // |
110 // |
119 void CESMRViewerStartDateField::InternalizeL( MESMRCalEntry& aEntry ) |
111 void CESMRViewerStartDateField::InternalizeL( MESMRCalEntry& aEntry ) |
120 { |
112 { |
121 // Read format string from AVKON resource |
113 FUNC_LOG; |
122 HBufC* dateFormatString = iEikonEnv->AllocReadResourceLC |
114 |
123 (R_QTN_DATE_USUAL_WITH_ZERO); |
115 CCalEntry& entry = aEntry.Entry(); |
124 TBuf<KMaxTimeBuffer> buf; |
116 iStartTime = entry.StartTimeL().TimeLocalL(); |
125 CCalEntry& entry = aEntry.Entry(); |
117 |
126 TTime startTime = entry.StartTimeL().TimeLocalL(); |
118 FormatDateStringL(); |
127 |
|
128 startTime.FormatL(buf,*dateFormatString); |
|
129 |
|
130 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( buf ); |
|
131 iLabel->SetTextL( buf ); |
|
132 CleanupStack::PopAndDestroy( dateFormatString ); |
|
133 } |
119 } |
134 |
120 |
135 // --------------------------------------------------------------------------- |
121 // --------------------------------------------------------------------------- |
136 // CESMRViewerStartDateField::SizeChanged() |
122 // CESMRViewerStartDateField::SizeChanged() |
137 // --------------------------------------------------------------------------- |
123 // --------------------------------------------------------------------------- |
138 // |
124 // |
139 void CESMRViewerStartDateField::SizeChanged() |
125 void CESMRViewerStartDateField::SizeChanged() |
140 { |
126 { |
|
127 FUNC_LOG; |
|
128 |
141 TRect rect = Rect(); |
129 TRect rect = Rect(); |
142 TAknLayoutRect rowLayoutRect = |
130 TAknLayoutRect rowLayoutRect = |
143 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ); |
131 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ); |
144 rect = rowLayoutRect.Rect(); |
132 rect = rowLayoutRect.Rect(); |
145 |
133 |
146 TAknWindowComponentLayout iconLayout = |
134 TAknWindowComponentLayout iconLayout = |
147 NMRLayoutManager::GetWindowComponentLayout( |
135 NMRLayoutManager::GetWindowComponentLayout( |
148 NMRLayoutManager::EMRLayoutTextEditorIcon ); |
136 NMRLayoutManager::EMRLayoutTextEditorIcon ); |
149 AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout ); |
137 AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout ); |
150 |
138 |
151 TAknLayoutRect bgLayoutRect = |
139 // Layouting lock icon |
152 NMRLayoutManager::GetLayoutRect( |
140 if( iLockIcon ) |
153 rect, NMRLayoutManager::EMRLayoutTextEditorBg ); |
141 { |
154 TRect bgRect( bgLayoutRect.Rect() ); |
142 TAknWindowComponentLayout iconLayout( |
155 bgRect.SetHeight( bgRect.Height() + 1 ); |
143 NMRLayoutManager::GetWindowComponentLayout( |
|
144 NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) ); |
|
145 AknLayoutUtils::LayoutImage( iLockIcon, rect, iconLayout ); |
|
146 } |
|
147 |
|
148 // Layouting label |
|
149 TAknLayoutText viewerLayoutText; |
|
150 if( iLockIcon ) |
|
151 { |
|
152 viewerLayoutText = NMRLayoutManager::GetLayoutText( rect, |
|
153 NMRLayoutManager::EMRTextLayoutSingleRowEditorText ); |
|
154 } |
|
155 else |
|
156 { |
|
157 viewerLayoutText = NMRLayoutManager::GetLayoutText( rect, |
|
158 NMRLayoutManager::EMRTextLayoutTextEditor ); |
|
159 } |
|
160 |
|
161 // Layouting viewer field |
|
162 TRect viewerRect( viewerLayoutText.TextRect() ); |
|
163 iLabel->SetRect( viewerRect ); |
|
164 |
156 // Move focus rect so that it's relative to field's position. |
165 // Move focus rect so that it's relative to field's position. |
157 bgRect.Move( -Position() ); |
166 viewerRect.Move( -Position() ); |
158 SetFocusRect( bgRect ); |
167 SetFocusRect( viewerRect ); |
159 |
168 |
160 TAknLayoutText labelLayout = |
169 // Setting font also for the label |
161 NMRLayoutManager::GetLayoutText( |
170 iLabel->SetFont( viewerLayoutText.Font() ); |
162 rect, NMRLayoutManager::EMRTextLayoutTextEditor ); |
|
163 iLabel->SetRect( labelLayout.TextRect() ); |
|
164 } |
171 } |
165 |
172 |
166 // --------------------------------------------------------------------------- |
173 // --------------------------------------------------------------------------- |
167 // CESMRViewerStartDateField::CountComponentControls() |
174 // CESMRViewerStartDateField::CountComponentControls() |
168 // --------------------------------------------------------------------------- |
175 // --------------------------------------------------------------------------- |
169 // |
176 // |
170 TInt CESMRViewerStartDateField::CountComponentControls() const |
177 TInt CESMRViewerStartDateField::CountComponentControls() const |
171 { |
178 { |
|
179 FUNC_LOG; |
|
180 |
172 TInt count( KComponentCount ); |
181 TInt count( KComponentCount ); |
|
182 if( iLockIcon ) |
|
183 { |
|
184 ++count; |
|
185 } |
173 return count; |
186 return count; |
174 } |
187 } |
175 |
188 |
176 // --------------------------------------------------------------------------- |
189 // --------------------------------------------------------------------------- |
177 // CESMRViewerStartDateField::ComponentControl() |
190 // CESMRViewerStartDateField::ComponentControl() |
178 // --------------------------------------------------------------------------- |
191 // --------------------------------------------------------------------------- |
179 // |
192 // |
180 CCoeControl* CESMRViewerStartDateField::ComponentControl( TInt aIndex ) const |
193 CCoeControl* CESMRViewerStartDateField::ComponentControl( TInt aIndex ) const |
181 { |
194 { |
|
195 FUNC_LOG; |
|
196 |
182 switch ( aIndex ) |
197 switch ( aIndex ) |
183 { |
198 { |
184 case 0: |
199 case 0: |
185 return iIcon; |
200 return iIcon; |
186 case 1: |
201 case 1: |
187 return iLabel; |
202 return iLabel; |
|
203 case 2: |
|
204 return iLockIcon; |
188 default: |
205 default: |
189 return NULL; |
206 return NULL; |
190 } |
207 } |
191 } |
208 } |
192 |
209 |
194 // CESMRViewerStartDateField::SetOutlineFocusL() |
211 // CESMRViewerStartDateField::SetOutlineFocusL() |
195 // --------------------------------------------------------------------------- |
212 // --------------------------------------------------------------------------- |
196 // |
213 // |
197 void CESMRViewerStartDateField::SetOutlineFocusL( TBool aFocus ) |
214 void CESMRViewerStartDateField::SetOutlineFocusL( TBool aFocus ) |
198 { |
215 { |
|
216 FUNC_LOG; |
|
217 |
199 CESMRField::SetOutlineFocusL ( aFocus ); |
218 CESMRField::SetOutlineFocusL ( aFocus ); |
200 |
|
201 iLabel->SetFocus( aFocus ); |
219 iLabel->SetFocus( aFocus ); |
202 |
220 } |
203 if ( !aFocus ) |
221 |
|
222 // --------------------------------------------------------------------------- |
|
223 // CESMRViewerStartDateField::ExecuteGenericCommandL() |
|
224 // --------------------------------------------------------------------------- |
|
225 // |
|
226 TBool CESMRViewerStartDateField::ExecuteGenericCommandL( TInt aCommand ) |
|
227 { |
|
228 FUNC_LOG; |
|
229 |
|
230 TBool retValue( EFalse ); |
|
231 |
|
232 if( (aCommand == EAknCmdOpen) && IsLocked() ) |
|
233 { |
|
234 HandleTactileFeedbackL(); |
|
235 |
|
236 CESMRGlobalNote::ExecuteL( |
|
237 CESMRGlobalNote::EESMRUnableToEdit ); |
|
238 retValue = ETrue; |
|
239 } |
|
240 |
|
241 if ( EMRCmdDoEnvironmentChange == aCommand ) |
204 { |
242 { |
205 AknLayoutUtils::OverrideControlColorL ( *iLabel, EColorLabelText, |
243 FormatDateStringL(); |
206 KRgbBlack ); |
244 retValue = ETrue; |
207 } |
245 } |
208 } |
246 |
|
247 return retValue; |
|
248 } |
|
249 |
|
250 // --------------------------------------------------------------------------- |
|
251 // CESMRViewerStartDateField::LockL() |
|
252 // --------------------------------------------------------------------------- |
|
253 // |
|
254 void CESMRViewerStartDateField::LockL() |
|
255 { |
|
256 FUNC_LOG; |
|
257 if( IsLocked() ) |
|
258 { |
|
259 return; |
|
260 } |
|
261 |
|
262 CESMRField::LockL(); |
|
263 |
|
264 delete iLockIcon; |
|
265 iLockIcon = NULL; |
|
266 iLockIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapLockField, ETrue ); |
|
267 iLockIcon->SetParent( this ); |
|
268 } |
|
269 |
|
270 // --------------------------------------------------------------------------- |
|
271 // CESMRViewerStartDateField::FormatDateStringL() |
|
272 // --------------------------------------------------------------------------- |
|
273 // |
|
274 void CESMRViewerStartDateField::FormatDateStringL() |
|
275 { |
|
276 FUNC_LOG; |
|
277 |
|
278 // Read format string from AVKON resource |
|
279 HBufC* dateFormatString = |
|
280 iEikonEnv->AllocReadResourceLC( |
|
281 R_QTN_DATE_USUAL_WITH_ZERO); |
|
282 |
|
283 TBuf<KMaxTimeBuffer> buf; |
|
284 iStartTime.FormatL(buf, *dateFormatString); |
|
285 |
|
286 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( buf ); |
|
287 iLabel->SetTextL( buf ); |
|
288 CleanupStack::PopAndDestroy( dateFormatString ); |
|
289 } |
|
290 |
209 // EOF |
291 // EOF |