20 #include "mesmrlistobserver.h" |
20 #include "mesmrlistobserver.h" |
21 #include "nmrbitmapmanager.h" |
21 #include "nmrbitmapmanager.h" |
22 #include "nmrlayoutmanager.h" |
22 #include "nmrlayoutmanager.h" |
23 #include "cmrlabel.h" |
23 #include "cmrlabel.h" |
24 #include "cmrimage.h" |
24 #include "cmrimage.h" |
|
25 #include "cesmrglobalnote.h" |
25 |
26 |
26 #include <eiklabel.h> |
27 #include <eiklabel.h> |
27 #include <caluser.h> |
28 #include <caluser.h> |
28 #include <calalarm.h> |
29 #include <calalarm.h> |
29 #include <avkon.rsg> |
30 #include <avkon.rsg> |
30 #include <calentry.h> |
31 #include <calentry.h> |
31 #include <eikenv.h> |
32 #include <eikenv.h> |
32 #include <eikedwin.h> |
33 #include <eikedwin.h> |
33 #include <StringLoader.h> |
34 #include <stringloader.h> |
34 #include <AknsConstants.h> |
35 #include <aknsconstants.h> |
35 #include <AknUtils.h> |
36 #include <aknutils.h> |
36 #include <AknLayout2ScalableDef.h> |
37 #include <aknlayout2scalabledef.h> |
37 #include <esmrgui.rsg> |
38 #include <esmrgui.rsg> |
38 // DEBUG |
39 // DEBUG |
39 #include "emailtrace.h" |
40 #include "emailtrace.h" |
40 |
41 |
41 //unnamed namespace for local constants functions |
42 //unnamed namespace for local constants functions |
42 namespace{ // codescanner::namespace |
43 namespace{ // codescanner::namespace |
43 |
44 |
44 const TInt KTimeBufferSize( 50 ); |
45 const TInt KTimeBufferSize( 50 ); |
|
46 |
45 const TInt KTempBufferSize( 20 ); |
47 const TInt KTempBufferSize( 20 ); |
46 |
48 |
|
49 // Literal for start and end time separator |
|
50 _LIT(KTimeSeparator," - "); |
|
51 |
47 }//namespace |
52 }//namespace |
48 |
53 |
49 // ======== MEMBER FUNCTIONS ======== |
54 // ======== MEMBER FUNCTIONS ======== |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // CESMRViewerTimeField::CESMRViewerTimeField() |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 CESMRViewerTimeField::CESMRViewerTimeField() |
|
61 { |
|
62 FUNC_LOG; |
|
63 |
|
64 SetFieldId( EESMRFieldMeetingTime ); |
|
65 SetFocusType( EESMRHighlightFocus ); |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // CESMRViewerTimeField::~CESMRViewerTimeField() |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 CESMRViewerTimeField::~CESMRViewerTimeField() |
|
73 { |
|
74 FUNC_LOG; |
|
75 delete iIcon; |
|
76 delete iLockIcon; |
|
77 } |
|
78 |
50 |
79 |
51 // --------------------------------------------------------------------------- |
80 // --------------------------------------------------------------------------- |
52 // CESMRViewerTimeField::NewL() |
81 // CESMRViewerTimeField::NewL() |
53 // --------------------------------------------------------------------------- |
82 // --------------------------------------------------------------------------- |
54 // |
83 // |
61 CleanupStack::Pop( self ); |
90 CleanupStack::Pop( self ); |
62 return self; |
91 return self; |
63 } |
92 } |
64 |
93 |
65 // --------------------------------------------------------------------------- |
94 // --------------------------------------------------------------------------- |
66 // CESMRViewerTimeField::~CESMRViewerTimeField() |
95 // CESMRViewerTimeField::ConstructL() |
67 // --------------------------------------------------------------------------- |
96 // --------------------------------------------------------------------------- |
68 // |
97 // |
69 CESMRViewerTimeField::~CESMRViewerTimeField() |
98 void CESMRViewerTimeField::ConstructL() |
70 { |
99 { |
71 FUNC_LOG; |
100 FUNC_LOG; |
72 delete iIcon; |
101 |
73 delete iLabel; |
102 iLabel = CMRLabel::NewL(); |
|
103 iLabel->SetParent( this ); |
|
104 CESMRField::ConstructL( iLabel ); // ownership transfered |
|
105 |
|
106 iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapClock ); |
|
107 iIcon->SetParent( this ); |
74 } |
108 } |
75 |
109 |
76 // --------------------------------------------------------------------------- |
110 // --------------------------------------------------------------------------- |
77 // CESMRViewerTimeField::InternalizeL() |
111 // CESMRViewerTimeField::InternalizeL() |
78 // --------------------------------------------------------------------------- |
112 // --------------------------------------------------------------------------- |
79 // |
113 // |
80 void CESMRViewerTimeField::InternalizeL( MESMRCalEntry& aEntry ) |
114 void CESMRViewerTimeField::InternalizeL( MESMRCalEntry& aEntry ) |
81 { |
115 { |
82 FUNC_LOG; |
116 FUNC_LOG; |
|
117 |
|
118 CCalEntry& entry = aEntry.Entry(); |
|
119 |
|
120 iStartTime = entry.StartTimeL().TimeLocalL(); |
|
121 iEndTime = entry.EndTimeL().TimeLocalL(); |
|
122 |
83 if ( aEntry.IsAllDayEventL() ) |
123 if ( aEntry.IsAllDayEventL() ) |
84 { |
124 { |
85 // set the field as hidden: |
125 // set the field as hidden: |
86 iObserver->RemoveControl( FieldId() ); |
126 iObserver->HideControl( FieldId() ); |
87 } |
127 } |
88 else |
128 else |
89 { |
129 { |
90 _LIT(KTimeSeparator," - "); |
130 FormatTimeFieldStringL(); |
91 CCalEntry& entry = aEntry.Entry(); |
|
92 |
|
93 TTime startTime = entry.StartTimeL().TimeLocalL(); |
|
94 TTime endTime = entry.EndTimeL().TimeLocalL(); |
|
95 |
|
96 HBufC* timeFormatString = |
|
97 iEikonEnv->AllocReadResourceLC( R_QTN_TIME_USUAL_WITH_ZERO ); |
|
98 HBufC* finalBuf = HBufC::NewLC( KTimeBufferSize ); |
|
99 HBufC* startBuf = HBufC::NewLC( KTempBufferSize ); |
|
100 HBufC* endBuf = HBufC::NewLC( KTempBufferSize ); |
|
101 const TInt KNumBuffers( 4 ); |
|
102 |
|
103 TPtr startPtr( startBuf->Des() ); |
|
104 startTime.FormatL( startPtr, *timeFormatString ); |
|
105 TPtr endPtr( endBuf->Des() ); |
|
106 endTime.FormatL( endPtr, *timeFormatString ); |
|
107 TPtr finalPtr( finalBuf->Des() ); |
|
108 finalPtr.Append( startPtr ); |
|
109 finalPtr.Append( KTimeSeparator ); |
|
110 finalPtr.Append( endPtr ); |
|
111 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( finalPtr ); |
|
112 iLabel->SetTextL( finalPtr ); |
|
113 CleanupStack::PopAndDestroy( KNumBuffers, timeFormatString ); |
|
114 } |
131 } |
115 } |
132 } |
116 |
133 |
117 // --------------------------------------------------------------------------- |
134 // --------------------------------------------------------------------------- |
118 // CESMRViewerTimeField::InitializeL() |
135 // CESMRViewerTimeField::InitializeL() |
119 // --------------------------------------------------------------------------- |
136 // --------------------------------------------------------------------------- |
120 // |
137 // |
121 void CESMRViewerTimeField::InitializeL() |
138 void CESMRViewerTimeField::InitializeL() |
122 { |
139 { |
123 TAknLayoutText text = NMRLayoutManager::GetLayoutText( |
140 FUNC_LOG; |
124 Rect(), |
141 |
|
142 TAknLayoutText text = NMRLayoutManager::GetLayoutText( |
|
143 Rect(), |
125 NMRLayoutManager::EMRTextLayoutTextEditor ); |
144 NMRLayoutManager::EMRTextLayoutTextEditor ); |
126 |
145 |
127 iLabel->SetFont( text.Font() ); |
146 iLabel->SetFont( text.Font() ); |
128 // This is called so that theme changes will apply when changing theme "on the fly" |
147 // This is called so that theme changes will apply when changing theme "on the fly" |
129 if ( IsFocused() ) |
148 if ( IsFocused() ) |
130 { |
149 { |
131 iLabel->FocusChanged( EDrawNow ); |
150 iLabel->FocusChanged( EDrawNow ); |
132 } |
151 } |
133 |
|
134 AknLayoutUtils::OverrideControlColorL ( *iLabel, EColorLabelText, |
|
135 KRgbBlack ); |
|
136 } |
152 } |
137 |
153 |
138 // --------------------------------------------------------------------------- |
154 // --------------------------------------------------------------------------- |
139 // CESMRViewerTimeField::SizeChanged() |
155 // CESMRViewerTimeField::SizeChanged() |
140 // --------------------------------------------------------------------------- |
156 // --------------------------------------------------------------------------- |
141 // |
157 // |
142 void CESMRViewerTimeField::SizeChanged() |
158 void CESMRViewerTimeField::SizeChanged() |
143 { |
159 { |
|
160 FUNC_LOG; |
|
161 |
144 TRect rect = Rect(); |
162 TRect rect = Rect(); |
145 TAknLayoutRect rowLayoutRect = |
163 TAknLayoutRect rowLayoutRect = |
146 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ); |
164 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ); |
147 rect = rowLayoutRect.Rect(); |
165 rect = rowLayoutRect.Rect(); |
148 |
166 |
149 TAknWindowComponentLayout iconLayout = |
167 TAknWindowComponentLayout iconLayout = |
150 NMRLayoutManager::GetWindowComponentLayout( |
168 NMRLayoutManager::GetWindowComponentLayout( |
151 NMRLayoutManager::EMRLayoutTextEditorIcon ); |
169 NMRLayoutManager::EMRLayoutTextEditorIcon ); |
152 AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout ); |
170 AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout ); |
153 |
171 |
154 TAknLayoutRect bgLayoutRect = |
172 // Layouting lock icon |
155 NMRLayoutManager::GetLayoutRect( |
173 if( iLockIcon ) |
156 rect, NMRLayoutManager::EMRLayoutTextEditorBg ); |
174 { |
157 TRect bgRect( bgLayoutRect.Rect() ); |
175 TAknWindowComponentLayout iconLayout( |
|
176 NMRLayoutManager::GetWindowComponentLayout( |
|
177 NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) ); |
|
178 AknLayoutUtils::LayoutImage( iLockIcon, rect, iconLayout ); |
|
179 } |
|
180 |
|
181 // Layouting label |
|
182 TAknLayoutText viewerLayoutText; |
|
183 if( iLockIcon ) |
|
184 { |
|
185 viewerLayoutText = NMRLayoutManager::GetLayoutText( rect, |
|
186 NMRLayoutManager::EMRTextLayoutSingleRowEditorText ); |
|
187 } |
|
188 else |
|
189 { |
|
190 viewerLayoutText = NMRLayoutManager::GetLayoutText( rect, |
|
191 NMRLayoutManager::EMRTextLayoutTextEditor ); |
|
192 } |
|
193 |
|
194 TRect viewerRect( viewerLayoutText.TextRect() ); |
|
195 iLabel->SetRect( viewerRect ); |
|
196 |
158 // Move focus rect so that it's relative to field's position. |
197 // Move focus rect so that it's relative to field's position. |
159 bgRect.Move( -Position() ); |
198 viewerRect.Move( -Position() ); |
160 SetFocusRect( bgRect ); |
199 SetFocusRect( viewerRect ); |
161 |
200 |
162 TAknLayoutText labelLayout = |
201 // Setting font also for the label |
163 NMRLayoutManager::GetLayoutText( |
202 iLabel->SetFont( viewerLayoutText.Font() ); |
164 rect, NMRLayoutManager::EMRTextLayoutTextEditor ); |
|
165 iLabel->SetRect( labelLayout.TextRect() ); |
|
166 } |
203 } |
167 |
204 |
168 // --------------------------------------------------------------------------- |
205 // --------------------------------------------------------------------------- |
169 // CESMRViewerTimeField::CountComponentControls() |
206 // CESMRViewerTimeField::CountComponentControls() |
170 // --------------------------------------------------------------------------- |
207 // --------------------------------------------------------------------------- |
171 // |
208 // |
172 TInt CESMRViewerTimeField::CountComponentControls() const |
209 TInt CESMRViewerTimeField::CountComponentControls() const |
173 { |
210 { |
174 TInt count( 2 ); |
211 FUNC_LOG; |
|
212 |
|
213 TInt count( 0 ); |
|
214 if ( iIcon ) |
|
215 { |
|
216 ++count; |
|
217 } |
|
218 |
|
219 if ( iLabel ) |
|
220 { |
|
221 ++count; |
|
222 } |
|
223 |
|
224 if ( iLockIcon ) |
|
225 { |
|
226 ++count; |
|
227 } |
175 return count; |
228 return count; |
176 } |
229 } |
177 |
230 |
178 // --------------------------------------------------------------------------- |
231 // --------------------------------------------------------------------------- |
179 // CESMRViewerTimeField::ComponentControl() |
232 // CESMRViewerTimeField::ComponentControl() |
180 // --------------------------------------------------------------------------- |
233 // --------------------------------------------------------------------------- |
181 // |
234 // |
182 CCoeControl* CESMRViewerTimeField::ComponentControl( TInt aIndex ) const |
235 CCoeControl* CESMRViewerTimeField::ComponentControl( TInt aIndex ) const |
183 { |
236 { |
|
237 FUNC_LOG; |
|
238 |
184 switch ( aIndex ) |
239 switch ( aIndex ) |
185 { |
240 { |
186 case 0: |
241 case 0: |
187 return iIcon; |
242 return iIcon; |
188 case 1: |
243 case 1: |
189 return iLabel; |
244 return iLabel; |
|
245 case 2: |
|
246 return iLockIcon; |
190 default: |
247 default: |
191 return NULL; |
248 return NULL; |
192 } |
249 } |
193 } |
250 } |
194 |
251 |
195 // --------------------------------------------------------------------------- |
252 // --------------------------------------------------------------------------- |
196 // CESMRViewerTimeField::CESMRViewerTimeField() |
|
197 // --------------------------------------------------------------------------- |
|
198 // |
|
199 CESMRViewerTimeField::CESMRViewerTimeField() |
|
200 { |
|
201 SetFieldId( EESMRFieldMeetingTime ); |
|
202 SetFocusType( EESMRHighlightFocus ); |
|
203 } |
|
204 |
|
205 // --------------------------------------------------------------------------- |
|
206 // CESMRViewerTimeField::ConstructL() |
|
207 // --------------------------------------------------------------------------- |
|
208 // |
|
209 void CESMRViewerTimeField::ConstructL() |
|
210 { |
|
211 iLabel = CMRLabel::NewL(); |
|
212 iLabel->SetParent( this ); |
|
213 iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapClock ); |
|
214 iIcon->SetParent( this ); |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------------------------- |
|
218 // CESMRViewerTimeField::SetOutlineFocusL() |
253 // CESMRViewerTimeField::SetOutlineFocusL() |
219 // --------------------------------------------------------------------------- |
254 // --------------------------------------------------------------------------- |
220 // |
255 // |
221 void CESMRViewerTimeField::SetOutlineFocusL( TBool aFocus ) |
256 void CESMRViewerTimeField::SetOutlineFocusL( TBool aFocus ) |
222 { |
257 { |
|
258 FUNC_LOG; |
|
259 |
223 CESMRField::SetOutlineFocusL ( aFocus ); |
260 CESMRField::SetOutlineFocusL ( aFocus ); |
224 |
261 |
225 iLabel->SetFocus( aFocus ); |
262 iLabel->SetFocus( aFocus ); |
226 |
263 } |
227 if ( !aFocus ) |
264 |
228 { |
265 // --------------------------------------------------------------------------- |
229 AknLayoutUtils::OverrideControlColorL ( *iLabel, EColorLabelText, |
266 // CESMRViewerTimeField::ExecuteGenericCommandL() |
230 KRgbBlack ); |
267 // --------------------------------------------------------------------------- |
231 } |
268 // |
|
269 TBool CESMRViewerTimeField::ExecuteGenericCommandL( TInt aCommand ) |
|
270 { |
|
271 FUNC_LOG; |
|
272 |
|
273 TBool retValue( EFalse ); |
|
274 |
|
275 if( (aCommand == EAknCmdOpen) && IsLocked() ) |
|
276 { |
|
277 HandleTactileFeedbackL(); |
|
278 |
|
279 CESMRGlobalNote::ExecuteL( |
|
280 CESMRGlobalNote::EESMRUnableToEdit ); |
|
281 retValue = ETrue; |
|
282 } |
|
283 |
|
284 if ( EMRCmdDoEnvironmentChange == aCommand ) |
|
285 { |
|
286 FormatTimeFieldStringL(); |
|
287 retValue = ETrue; |
|
288 } |
|
289 |
|
290 return retValue; |
|
291 } |
|
292 |
|
293 // --------------------------------------------------------------------------- |
|
294 // CESMRViewerTimeField::LockL() |
|
295 // --------------------------------------------------------------------------- |
|
296 // |
|
297 void CESMRViewerTimeField::LockL() |
|
298 { |
|
299 FUNC_LOG; |
|
300 if( IsLocked() ) |
|
301 { |
|
302 return; |
|
303 } |
|
304 |
|
305 CESMRField::LockL(); |
|
306 |
|
307 delete iLockIcon; |
|
308 iLockIcon = NULL; |
|
309 iLockIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapLockField, ETrue ); |
|
310 iLockIcon->SetParent( this ); |
|
311 } |
|
312 |
|
313 // --------------------------------------------------------------------------- |
|
314 // CESMRViewerTimeField::FormatTimeFieldStringL() |
|
315 // --------------------------------------------------------------------------- |
|
316 // |
|
317 void CESMRViewerTimeField::FormatTimeFieldStringL() |
|
318 { |
|
319 HBufC* timeFormatString = |
|
320 iEikonEnv->AllocReadResourceLC( R_QTN_TIME_USUAL_WITH_ZERO ); |
|
321 |
|
322 HBufC* finalBuf = HBufC::NewLC( KTimeBufferSize ); |
|
323 HBufC* startBuf = HBufC::NewLC( KTempBufferSize ); |
|
324 HBufC* endBuf = HBufC::NewLC( KTempBufferSize ); |
|
325 const TInt KNumBuffers( 4 ); |
|
326 |
|
327 TPtr startPtr( startBuf->Des() ); |
|
328 iStartTime.FormatL( startPtr, *timeFormatString ); |
|
329 TPtr endPtr( endBuf->Des() ); |
|
330 iEndTime.FormatL( endPtr, *timeFormatString ); |
|
331 TPtr finalPtr( finalBuf->Des() ); |
|
332 finalPtr.Append( startPtr ); |
|
333 finalPtr.Append( KTimeSeparator ); |
|
334 finalPtr.Append( endPtr ); |
|
335 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( finalPtr ); |
|
336 iLabel->SetTextL( finalPtr ); |
|
337 CleanupStack::PopAndDestroy( KNumBuffers, timeFormatString ); |
|
338 |
232 } |
339 } |
233 |
340 |
234 // EOF |
341 // EOF |