13 * |
13 * |
14 * Description: ESMR All day event checkbox field implementation |
14 * Description: ESMR All day event checkbox field implementation |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "emailtrace.h" |
|
19 #include "cesmrcheckbox.h" |
18 #include "cesmrcheckbox.h" |
20 |
|
21 #include <eiklabel.h> |
|
22 #include <AknIconUtils.h> |
|
23 #include <fbs.h> |
|
24 #include <eikimage.h> |
|
25 #include <StringLoader.h> |
|
26 #include <avkon.hrh> |
|
27 #include <AknUtils.h> |
|
28 #include <AknsUtils.h> |
|
29 #include <data_caging_path_literals.hrh> |
|
30 |
|
31 #include <esmrgui.rsg> |
|
32 #include "cesmrborderlayer.h" |
|
33 #include "mesmrlistobserver.h" |
19 #include "mesmrlistobserver.h" |
34 #include "mesmrmeetingrequestentry.h" |
20 #include "mesmrmeetingrequestentry.h" |
35 #include "mesmrfieldvalidator.h" |
21 #include "mesmrfieldvalidator.h" |
36 #include "esmrconfig.hrh" |
22 #include "esmrconfig.hrh" |
37 #include "cesmriconfield.h" |
|
38 #include "esmrhelper.h" |
23 #include "esmrhelper.h" |
39 #include "cesmrlayoutmgr.h" |
24 #include "nmrbitmapmanager.h" |
40 |
25 #include "cmrimage.h" |
41 using namespace ESMRLayout; |
26 #include "cmrlabel.h" |
|
27 #include "nmrlayoutmanager.h" |
|
28 #include "mesmrfieldeventqueue.h" |
|
29 #include "cesmrgenericfieldevent.h" |
|
30 |
|
31 #include <esmrgui.rsg> |
|
32 #include <stringloader.h> |
|
33 #include <data_caging_path_literals.hrh> |
|
34 |
|
35 // DEBUG |
|
36 #include "emailtrace.h" |
|
37 |
42 |
38 |
43 // ======== MEMBER FUNCTIONS ======== |
39 // ======== MEMBER FUNCTIONS ======== |
44 |
40 |
45 // --------------------------------------------------------------------------- |
41 // --------------------------------------------------------------------------- |
46 // CESMRCheckbox::NewL |
42 // CESMRCheckbox::NewL |
47 // --------------------------------------------------------------------------- |
43 // --------------------------------------------------------------------------- |
48 // |
44 // |
49 CESMRCheckBox* CESMRCheckBox::NewL( MESMRFieldValidator* aValidator ) |
45 CESMRCheckBox* CESMRCheckBox::NewL( MESMRFieldValidator* aValidator ) |
50 { |
46 { |
51 FUNC_LOG; |
47 FUNC_LOG; |
52 CESMRCheckBox* self = new (ELeave) CESMRCheckBox( aValidator ); |
48 CESMRCheckBox* self = new( ELeave )CESMRCheckBox( aValidator ); |
53 CleanupStack::PushL ( self ); |
49 CleanupStack::PushL( self ); |
54 self->ConstructL ( ); |
50 self->ConstructL(); |
55 CleanupStack::Pop ( self ); |
51 CleanupStack::Pop( self ); |
56 return self; |
52 return self; |
57 } |
53 } |
58 |
54 |
59 // --------------------------------------------------------------------------- |
55 // --------------------------------------------------------------------------- |
|
56 // CESMRCheckbox::CESMRCheckbox |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 CESMRCheckBox::CESMRCheckBox( MESMRFieldValidator* aValidator ) |
|
60 : iChecked( EFalse ) |
|
61 { |
|
62 FUNC_LOG; |
|
63 |
|
64 iValidator = aValidator; |
|
65 |
|
66 SetFieldId( EESMRFieldAllDayEvent ); |
|
67 SetFocusType ( EESMRHighlightFocus ); |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // CESMRCheckbox::ConstructL |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 void CESMRCheckBox::ConstructL() |
|
75 { |
|
76 FUNC_LOG; |
|
77 iLabel = CMRLabel::NewL(); |
|
78 iLabel->SetParent( this ); |
|
79 |
|
80 CESMRField::ConstructL( iLabel ); //ownership transfered |
|
81 |
|
82 HBufC* txt = StringLoader::LoadLC ( R_QTN_MEET_REQ_ALL_DAY_EVENT ); |
|
83 iLabel->SetTextL( *txt ); |
|
84 CleanupStack::PopAndDestroy( txt ); |
|
85 |
|
86 // Creating field icon |
|
87 SetIconL ( iChecked ); |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------------------------- |
60 // CESMRCheckbox::~CESMRCheckbox |
91 // CESMRCheckbox::~CESMRCheckbox |
61 // --------------------------------------------------------------------------- |
92 // --------------------------------------------------------------------------- |
62 // |
93 // |
63 CESMRCheckBox::~CESMRCheckBox( ) |
94 CESMRCheckBox::~CESMRCheckBox( ) |
64 { |
95 { |
65 FUNC_LOG; |
96 FUNC_LOG; |
66 delete iIcon; |
97 delete iFieldIcon; |
67 delete iBitmap; |
|
68 delete iBitmapMask; |
|
69 } |
98 } |
70 |
99 |
71 // --------------------------------------------------------------------------- |
100 // --------------------------------------------------------------------------- |
72 // CESMRCheckbox::SetOutlineFocusL |
101 // CESMRCheckbox::SetOutlineFocusL |
73 // --------------------------------------------------------------------------- |
102 // --------------------------------------------------------------------------- |
86 |
115 |
87 // --------------------------------------------------------------------------- |
116 // --------------------------------------------------------------------------- |
88 // CESMRCheckbox::ExecuteGenericCommandL |
117 // CESMRCheckbox::ExecuteGenericCommandL |
89 // --------------------------------------------------------------------------- |
118 // --------------------------------------------------------------------------- |
90 // |
119 // |
91 void CESMRCheckBox::ExecuteGenericCommandL( TInt aCommand ) |
120 TBool CESMRCheckBox::ExecuteGenericCommandL( TInt aCommand ) |
92 { |
121 { |
93 FUNC_LOG; |
122 FUNC_LOG; |
94 if(aCommand == EESMRCmdCheckEvent) |
123 TBool isUsed( EFalse ); |
|
124 // EAknCmdOpen is added for the Pointer events, see ListPane |
|
125 if( aCommand == EESMRCmdCheckEvent || aCommand == EAknCmdOpen ) |
95 { |
126 { |
96 HandleCheckEventL(); |
127 HandleCheckEventL(); |
97 SwitchMSKLabelL(); |
128 SwitchMSKLabelL(); |
98 } |
129 SendFieldChangeEventL( EESMRFieldAllDayEvent ); |
|
130 isUsed = ETrue; |
|
131 |
|
132 HandleTactileFeedbackL(); |
|
133 } |
|
134 return isUsed; |
99 } |
135 } |
100 |
136 |
101 // --------------------------------------------------------------------------- |
137 // --------------------------------------------------------------------------- |
102 // CESMRCheckbox::OfferKeyEventL |
138 // CESMRCheckbox::OfferKeyEventL |
103 // --------------------------------------------------------------------------- |
139 // --------------------------------------------------------------------------- |
124 // --------------------------------------------------------------------------- |
161 // --------------------------------------------------------------------------- |
125 // |
162 // |
126 TInt CESMRCheckBox::CountComponentControls( ) const |
163 TInt CESMRCheckBox::CountComponentControls( ) const |
127 { |
164 { |
128 FUNC_LOG; |
165 FUNC_LOG; |
129 TInt count = CESMRField::CountComponentControls ( ); |
166 TInt count( 0 ); |
130 if ( iIcon ) |
167 if ( iFieldIcon ) |
131 { |
168 { |
132 ++count; |
169 ++count; |
133 } |
170 } |
|
171 if ( iLabel ) |
|
172 { |
|
173 ++count; |
|
174 } |
134 return count; |
175 return count; |
135 } |
176 } |
136 |
177 |
137 // --------------------------------------------------------------------------- |
178 // --------------------------------------------------------------------------- |
138 // CESMRCheckbox::ComponentControl |
179 // CESMRCheckbox::ComponentControl |
139 // --------------------------------------------------------------------------- |
180 // --------------------------------------------------------------------------- |
140 // |
181 // |
141 CCoeControl* CESMRCheckBox::ComponentControl( TInt aInd ) const |
182 CCoeControl* CESMRCheckBox::ComponentControl( TInt aInd ) const |
142 { |
183 { |
143 FUNC_LOG; |
184 FUNC_LOG; |
144 if ( aInd == 0 ) |
185 switch ( aInd ) |
145 { |
186 { |
146 return iIcon; |
187 case 0: |
147 } |
188 return iFieldIcon; |
148 return CESMRField::ComponentControl ( aInd ); |
189 case 1: |
|
190 return iLabel; |
|
191 default: |
|
192 return NULL; |
|
193 } |
149 } |
194 } |
150 |
195 |
151 // --------------------------------------------------------------------------- |
196 // --------------------------------------------------------------------------- |
152 // CESMRCheckbox::SizeChanged |
197 // CESMRCheckbox::SizeChanged |
153 // --------------------------------------------------------------------------- |
198 // --------------------------------------------------------------------------- |
154 // |
199 // |
155 void CESMRCheckBox::SizeChanged( ) |
200 void CESMRCheckBox::SizeChanged() |
156 { |
201 { |
157 FUNC_LOG; |
202 FUNC_LOG; |
158 TRect rect = Rect ( ); |
203 TRect rect = Rect(); |
159 |
204 |
160 TInt iconTopMargin = ( rect.Height() - KIconSize.iHeight ) / 2; |
205 TAknLayoutRect rowLayoutRect = |
161 |
206 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ); |
162 TPoint iconPos( rect.iTl.iX + KIconSize.iWidth + KIconBorderMargin, |
207 rect = rowLayoutRect.Rect(); |
163 rect.iTl.iY + iconTopMargin ); |
208 |
164 |
209 TAknWindowComponentLayout iconLayout = |
165 |
210 NMRLayoutManager::GetWindowComponentLayout( |
166 TPoint borderPos( iconPos.iX + KIconSize.iWidth + KIconBorderMargin, |
211 NMRLayoutManager::EMRLayoutTextEditorIcon ); |
167 rect.iTl.iY); |
212 AknLayoutUtils::LayoutImage( iFieldIcon, rect, iconLayout ); |
168 |
213 |
169 TSize borderSize( rect.Width() - |
214 TAknLayoutRect bgLayoutRect = |
170 (2 * KIconSize.iWidth + 2 * KIconBorderMargin ), |
215 NMRLayoutManager::GetLayoutRect( |
171 rect.Height ( )); |
216 rect, NMRLayoutManager::EMRLayoutTextEditorBg ); |
172 |
217 TRect bgRect( bgLayoutRect.Rect() ); |
173 if ( CESMRLayoutManager::IsMirrored ( ) ) |
218 // Move focus rect so that it's relative to field's position. |
174 { |
219 bgRect.Move( -Position() ); |
175 iconPos.iX = rect.iBr.iX - ( 2 * KIconSize.iWidth ); |
220 SetFocusRect( bgRect ); |
176 borderPos.iX = iconPos.iX - borderSize.iWidth - KIconBorderMargin; |
221 |
177 } |
222 TAknLayoutText labelLayout = |
178 |
223 NMRLayoutManager::GetLayoutText( |
179 if ( iIcon ) |
224 rect, NMRLayoutManager::EMRTextLayoutTextEditor ); |
180 { |
225 iLabel->SetRect( labelLayout.TextRect() ); |
181 iIcon->SetPosition ( iconPos ); |
226 |
182 iIcon->SetSize ( KIconSize ); |
227 // Setting font also for the label |
183 } |
228 iLabel->SetFont( labelLayout.Font() ); |
184 |
|
185 if ( iBorder ) |
|
186 { |
|
187 iBorder->SetPosition ( borderPos ); |
|
188 iBorder->SetSize ( borderSize ); |
|
189 } |
|
190 } |
|
191 |
|
192 // --------------------------------------------------------------------------- |
|
193 // CESMRCheckbox::InitializeL |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 void CESMRCheckBox::InitializeL() |
|
197 { |
|
198 FUNC_LOG; |
|
199 iLabel->SetFont( iLayout->Font( iCoeEnv, iFieldId ) ); |
|
200 AknLayoutUtils::OverrideControlColorL( |
|
201 *iLabel, |
|
202 EColorLabelText, |
|
203 iLayout->GeneralListAreaTextColor() ); |
|
204 } |
229 } |
205 |
230 |
206 // --------------------------------------------------------------------------- |
231 // --------------------------------------------------------------------------- |
207 // CESMRCheckbox::InternalizeL |
232 // CESMRCheckbox::InternalizeL |
208 // --------------------------------------------------------------------------- |
233 // --------------------------------------------------------------------------- |
238 // --------------------------------------------------------------------------- |
263 // --------------------------------------------------------------------------- |
239 // |
264 // |
240 void CESMRCheckBox::SetIconL( TBool aChecked ) |
265 void CESMRCheckBox::SetIconL( TBool aChecked ) |
241 { |
266 { |
242 FUNC_LOG; |
267 FUNC_LOG; |
243 delete iIcon; |
268 delete iFieldIcon; |
244 iIcon = NULL; |
269 iFieldIcon = NULL; |
245 delete iBitmap; |
270 |
246 iBitmap = NULL; |
271 NMRBitmapManager::TMRBitmapId iconID; |
247 delete iBitmapMask; |
|
248 iBitmapMask = NULL; |
|
249 |
|
250 TAknsItemID iconID; |
|
251 TInt fileIndex(KErrNotFound); |
|
252 TInt fileMaskIndex(KErrNotFound); |
|
253 |
|
254 if( aChecked ) |
272 if( aChecked ) |
255 { |
273 { |
256 iconID = KAknsIIDQgnMeetReqIndiCheckboxMark; |
274 iconID = NMRBitmapManager::EMRBitmapCheckBoxOn; |
257 } |
275 } |
258 else |
276 else |
259 { |
277 { |
260 iconID = KAknsIIDQgnMeetReqIndiCheckboxUnmark; |
278 iconID = NMRBitmapManager::EMRBitmapCheckBoxOff; |
261 } |
279 } |
262 |
280 |
263 CESMRLayoutManager::SetBitmapFallback( iconID, fileIndex, fileMaskIndex ); |
281 iFieldIcon = CMRImage::NewL( iconID ); |
264 |
282 iFieldIcon->SetParent( this ); |
265 TFileName bitmapFilePath; |
283 |
266 ESMRHelper::LocateResourceFile( |
284 SizeChanged(); |
267 KESMRMifFile, |
|
268 KDC_APP_BITMAP_DIR, |
|
269 bitmapFilePath); |
|
270 |
|
271 TRAPD( err, AknsUtils::CreateIconL( AknsUtils::SkinInstance(), |
|
272 iconID, |
|
273 iBitmap, |
|
274 iBitmapMask, |
|
275 bitmapFilePath, |
|
276 fileIndex, |
|
277 fileMaskIndex |
|
278 ) ); |
|
279 |
|
280 if (err == KErrNotFound) |
|
281 { |
|
282 User::Leave(KErrNotFound); |
|
283 } |
|
284 |
|
285 // Even if creating mask failed, bitmap can be used (background is just not displayed correctly) |
|
286 if( iBitmap ) |
|
287 { |
|
288 AknIconUtils::SetSize( iBitmap, KIconSize, EAspectRatioPreserved ); |
|
289 iIcon = new (ELeave) CEikImage; |
|
290 iIcon->SetPictureOwnedExternally(ETrue); |
|
291 iIcon->SetPicture( iBitmap, iBitmapMask ); |
|
292 } |
|
293 } |
285 } |
294 |
286 |
295 // --------------------------------------------------------------------------- |
287 // --------------------------------------------------------------------------- |
296 // CESMRCheckbox::HandleCheckEventL |
288 // CESMRCheckbox::HandleCheckEventL |
297 // --------------------------------------------------------------------------- |
289 // --------------------------------------------------------------------------- |
313 */ |
305 */ |
314 if ( iChecked ) |
306 if ( iChecked ) |
315 { |
307 { |
316 // start - end time should be removed |
308 // start - end time should be removed |
317 // relateive alarm should be removed |
309 // relateive alarm should be removed |
318 iObserver->RemoveControl ( EESMRFieldMeetingTime ); |
310 iObserver->HideControl ( EESMRFieldMeetingTime ); |
319 iObserver->RemoveControl ( EESMRFieldAlarm ); |
311 iObserver->HideControl ( EESMRFieldAlarm ); |
320 // absolute alarm should be inserted |
312 // absolute alarm should be inserted |
321 iObserver->InsertControl ( EESMRFieldAlarmOnOff ); |
313 iObserver->ShowControl ( EESMRFieldAlarmOnOff ); |
322 } |
314 } |
323 else |
315 else |
324 { |
316 { |
325 iObserver->InsertControl ( EESMRFieldMeetingTime ); |
317 iObserver->ShowControl ( EESMRFieldMeetingTime ); |
326 iObserver->InsertControl ( EESMRFieldAlarm ); |
318 iObserver->ShowControl ( EESMRFieldAlarm ); |
327 iObserver->RemoveControl ( EESMRFieldAlarmOnOff ); |
319 iObserver->HideControl ( EESMRFieldAlarmOnOff ); |
328 iObserver->RemoveControl ( EESMRFieldAlarmTime ); |
320 iObserver->HideControl ( EESMRFieldAlarmTime ); |
329 iObserver->RemoveControl ( EESMRFieldAlarmDate ); |
321 iObserver->HideControl ( EESMRFieldAlarmDate ); |
330 } |
322 } |
331 } |
323 } |
332 |
324 |
333 // --------------------------------------------------------------------------- |
325 // --------------------------------------------------------------------------- |
334 // CESMRCheckbox::SwitchMSKLabelL |
326 // CESMRCheckbox::SwitchMSKLabelL |
335 // --------------------------------------------------------------------------- |
327 // --------------------------------------------------------------------------- |
336 // |
328 // |
337 void CESMRCheckBox::SwitchMSKLabelL() |
329 void CESMRCheckBox::SwitchMSKLabelL() |
338 { |
330 { |
339 FUNC_LOG; |
331 FUNC_LOG; |
340 if(iChecked) |
332 if( iChecked ) |
341 { |
333 { |
342 ChangeMiddleSoftKeyL(EESMRCmdCheckEvent, R_QTN_MSK_UNMARK); |
334 ChangeMiddleSoftKeyL(EESMRCmdCheckEvent, R_QTN_MSK_UNMARK); |
343 } |
335 } |
344 else |
336 else |
345 { |
337 { |
346 ChangeMiddleSoftKeyL(EESMRCmdCheckEvent, R_QTN_MSK_MARK); |
338 ChangeMiddleSoftKeyL(EESMRCmdCheckEvent, R_QTN_MSK_MARK); |
347 } |
339 } |
348 } |
340 } |
349 |
341 |
350 // --------------------------------------------------------------------------- |
342 // --------------------------------------------------------------------------- |
351 // CESMRCheckbox::CESMRCheckbox |
343 // CESMRCheckbox::SetContainerWindowL |
352 // --------------------------------------------------------------------------- |
344 // --------------------------------------------------------------------------- |
353 // |
345 // |
354 CESMRCheckBox::CESMRCheckBox( MESMRFieldValidator* aValidator ) : |
346 void CESMRCheckBox::SetContainerWindowL( |
355 iValidator( aValidator), iChecked( EFalse) |
347 const CCoeControl& aContainer ) |
356 { |
348 { |
357 FUNC_LOG; |
349 CCoeControl::SetContainerWindowL( aContainer ); |
358 //do nothing |
350 iLabel->SetContainerWindowL( aContainer ); |
359 } |
351 iLabel->SetParent( this ); |
360 |
352 } |
361 // --------------------------------------------------------------------------- |
353 // --------------------------------------------------------------------------- |
362 // CESMRCheckbox::ConstructL |
354 // CESMRCheckBox::SendFieldChangeEventL |
363 // --------------------------------------------------------------------------- |
355 // --------------------------------------------------------------------------- |
364 // |
356 // |
365 void CESMRCheckBox::ConstructL( ) |
357 void CESMRCheckBox::SendFieldChangeEventL( |
366 { |
358 TESMREntryFieldId aFieldId ) |
367 FUNC_LOG; |
359 { |
368 SetFieldId( EESMRFieldAllDayEvent ); |
360 FUNC_LOG; |
369 iLabel = new (ELeave) CEikLabel; |
361 if ( iEventQueue ) |
370 iLabel->SetLabelAlignment( CESMRLayoutManager::IsMirrored() |
362 { |
371 ? ELayoutAlignRight : ELayoutAlignLeft ); |
363 CESMRGenericFieldEvent* event = |
372 |
364 CESMRGenericFieldEvent::NewLC( NULL, |
373 HBufC* txt = StringLoader::LoadLC ( R_QTN_MEET_REQ_ALL_DAY_EVENT ); |
365 MESMRFieldEvent::EESMRFieldChangeEvent ); |
374 iLabel->SetTextL( *txt ); |
366 TInt fieldId = aFieldId; |
375 CleanupStack::PopAndDestroy( txt ); |
367 CESMRFieldEventValue* field = CESMRFieldEventValue::NewLC( |
376 |
368 CESMRFieldEventValue::EESMRInteger, &fieldId ); |
377 iIcon = new (ELeave) CEikImage; |
369 event->AddParamL( field ); |
378 |
370 CleanupStack::Pop( field ); |
379 CESMRField::ConstructL( iLabel ); |
371 CESMRFieldEventValue* checked = CESMRFieldEventValue::NewLC( |
380 } |
372 CESMRFieldEventValue::EESMRInteger, &iChecked ); |
381 |
373 event->AddParamL( checked ); |
|
374 CleanupStack::Pop( checked ); |
|
375 iEventQueue->NotifyEventL( *event ); |
|
376 CleanupStack::PopAndDestroy( event ); |
|
377 } |
|
378 } |
382 // EOF |
379 // EOF |
383 |
|