|
1 /* |
|
2 * Copyright (c) 2003 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: Alert dialog implementation for Series 60 |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CMIDAlert.h" |
|
20 #include "CMIDAlertDialog.h" |
|
21 #include "CMIDDisplayable.h" |
|
22 #include "CMIDCommandList.h" |
|
23 #include "CMIDUtils.h" |
|
24 |
|
25 // using TAlertDialogLineId enumeration |
|
26 #include "lcdui.hrh" |
|
27 // macros definitions for resources |
|
28 #include <lcdui.rsg> |
|
29 |
|
30 // using CAknBitmapAnimation and CBitmapAnimClientData |
|
31 // - in CheckAndSetAnimationModeL and UpdateGaugeInAlertL functions |
|
32 // for animation in gauge |
|
33 #include <aknnotecontrol.h> |
|
34 #include <eikprogi.h> |
|
35 // using CEikCaptionedControl |
|
36 // - in CheckAndSetAnimationModeL and UpdateGaugeInAlertL functions |
|
37 #include <eikcapc.h> |
|
38 |
|
39 #include <AknDef.h> |
|
40 #include <aknappui.h> |
|
41 |
|
42 // macros definitions for outputing logs |
|
43 #include <j2me/jdebug.h> |
|
44 |
|
45 #ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK |
|
46 #include <touchfeedback.h> |
|
47 #endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK |
|
48 |
|
49 |
|
50 /** This macro is executed each time a trapped call returns an error code different than KErrNone */ |
|
51 #undef TRAP_INSTRUMENTATION_LEAVE |
|
52 #define TRAP_INSTRUMENTATION_LEAVE(aResult) DEBUG_INT2("In CMIDDisplayable.cpp, trapped method was called at line %D and got exception %D", __LINE__, aResult); |
|
53 |
|
54 |
|
55 /** CMIDAlertDialog::CMIDAlertDialog */ |
|
56 CMIDAlertDialog* CMIDAlertDialog::NewL(CMIDAlert* aAlert,CMIDDisplayable* aDisplayable) |
|
57 { |
|
58 CMIDAlertDialog* self = new(ELeave) CMIDAlertDialog(aAlert, aDisplayable); |
|
59 CleanupStack::PushL(self); |
|
60 self->ConstructL(); |
|
61 CleanupStack::Pop(self); |
|
62 return self; |
|
63 } |
|
64 // |
|
65 CMIDAlertDialog::CMIDAlertDialog(CMIDAlert* aAlert, CMIDDisplayable* aDisplayable) : |
|
66 iParent(aAlert), iDisplayable(aDisplayable) |
|
67 { |
|
68 iGaugeResourceType = EPopupFormUnknown; |
|
69 |
|
70 } |
|
71 |
|
72 /** CMIDAlertDialog::~CMIDAlertDialog */ |
|
73 CMIDAlertDialog::~CMIDAlertDialog() |
|
74 { |
|
75 if (iGauge) |
|
76 { |
|
77 iGauge->SetGaugeListenerFromAlert(NULL); |
|
78 iGauge = NULL; |
|
79 } |
|
80 } |
|
81 |
|
82 /** CMIDAlertDialog::PreLayoutDynInitL */ |
|
83 void CMIDAlertDialog::PreLayoutDynInitL() |
|
84 { |
|
85 // Check if there is a gauge.... and create it... |
|
86 // NOTE: the type and properties need to be set here also... |
|
87 CAknPopupForm::PreLayoutDynInitL(); |
|
88 } |
|
89 |
|
90 /** When showing dialogs set their CBA into CMIDDisplayable and then use |
|
91 the logic of CMIDDisplayable::InitializeCbasL() to set the correct CBA |
|
92 commands. However modeless dialogs always have empty CBAs. When not |
|
93 showing we must reset the parent CBAs. |
|
94 */ |
|
95 void CMIDAlertDialog::UpdateCbasL() |
|
96 { |
|
97 if (iShowing) |
|
98 { |
|
99 iDisplayable->SetCba(&ButtonGroupContainer()); |
|
100 |
|
101 if (iParent->IsModal()) |
|
102 { |
|
103 iDisplayable->InitializeCbasL(); |
|
104 } |
|
105 else |
|
106 { |
|
107 ButtonGroupContainer().SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY); |
|
108 } |
|
109 |
|
110 CCoeControl* cba = ButtonGroupContainer().ButtonGroup()->AsControl(); |
|
111 cba->DrawableWindow()->SetOrdinalPosition(0); |
|
112 cba->MakeVisible(ETrue); |
|
113 cba->DrawNow(); |
|
114 } |
|
115 else |
|
116 { |
|
117 //restore parent CBAs |
|
118 iDisplayable->SetCba(iDisplayable->MenuHandler()->Cba()); |
|
119 } |
|
120 } |
|
121 |
|
122 /** CMIDAlertDialog::PostLayoutDynInitL */ |
|
123 void CMIDAlertDialog::PostLayoutDynInitL() |
|
124 { |
|
125 CAknPopupForm::PostLayoutDynInitL(); |
|
126 // Above call is starting the animation. In case of updating gauge |
|
127 // we will stop it and midlet will update it later. |
|
128 CheckAndSetAnimationModeL(); |
|
129 } |
|
130 |
|
131 /** CMIDAlertDialog::InsertGaugeIntoDialogL |
|
132 Insert/remove the gauge in Alert */ |
|
133 void CMIDAlertDialog::InsertGaugeIntoDialogL() |
|
134 { |
|
135 DEBUG("CMIDAlertDialog::InsertGaugeIntoDialogL <"); |
|
136 |
|
137 TBool skipVisibilityChange = EFalse; |
|
138 |
|
139 // skipping disabling visibility change in case of error |
|
140 // where incremental update type gauge wasn't show |
|
141 if (iGauge) |
|
142 { |
|
143 if (iGauge->GetIndefiniteState() == MMIDGauge::EIncrementalUpdating |
|
144 && iShowing == EFalse) |
|
145 { |
|
146 skipVisibilityChange = ETrue; |
|
147 } |
|
148 } |
|
149 |
|
150 if (!skipVisibilityChange) |
|
151 { |
|
152 DisableVisibilityChange(ETrue); |
|
153 } |
|
154 |
|
155 |
|
156 TInt gaugeVal = iGauge ? iGauge->GetValue() : -1; |
|
157 |
|
158 //remove any existing gauge |
|
159 if (iGaugeResourceType != EPopupFormUnknown) |
|
160 { |
|
161 DeleteControl(iGaugeResourceType); |
|
162 iGaugeResourceType = EPopupFormUnknown; |
|
163 } |
|
164 |
|
165 //add the new gauge |
|
166 if (iGauge) |
|
167 { |
|
168 iGauge->SetGaugeListenerFromAlert(this); |
|
169 DEBUG("CMIDAlertDialog::InsertGaugeIntoDialogL - InsertControlL()"); |
|
170 |
|
171 if (iGauge->GetMaxValue() > 0) |
|
172 { // definite type Gauge |
|
173 // progressbar adding |
|
174 InsertControlL(0, R_MIDP_ALERT_PROGI_LINE, EFalse); |
|
175 iGaugeResourceType = EPopupFormProgbar; |
|
176 iGauge->UpdateProgressInfo(CAknPopupForm::ProgressInfo()); |
|
177 } |
|
178 else |
|
179 { |
|
180 iGaugeResourceType = EPopupFormWaitAnim; |
|
181 switch (iGauge->GetIndefiniteState()) |
|
182 { |
|
183 case MMIDGauge::EContinuousIdle: // continuous idle |
|
184 { //r_midp_alert_wait_animation_continouse_idle_line |
|
185 InsertControlL(0, R_MIDP_ALERT_WAIT_ANIMATION_CONTINUOUS_IDLE_LINE, ETrue); |
|
186 break; |
|
187 } |
|
188 case MMIDGauge::EContinuousRunning: // continuous running |
|
189 { |
|
190 InsertControlL(0, R_MIDP_ALERT_WAIT_ANIMATION_CONTINUOUS_RUNNING_LINE, ETrue); |
|
191 break; |
|
192 } |
|
193 case MMIDGauge::EIncrementalUpdating: //incremental updating |
|
194 { |
|
195 InsertControlL(0, R_MIDP_ALERT_WAIT_BAR_INCREM_LINE, ETrue); |
|
196 break; |
|
197 } |
|
198 case MMIDGauge::EIncrementalIdle: //incremental idle |
|
199 { |
|
200 InsertControlL(0, R_MIDP_ALERT_WAIT_BAR_INCREM_IDLE_LINE, ETrue); |
|
201 break; |
|
202 } |
|
203 default: |
|
204 ASSERT(EFalse); |
|
205 break; |
|
206 } |
|
207 } |
|
208 } |
|
209 |
|
210 DEBUG("CMIDAlertDialog::InsertGaugeIntoDialogL - UpdateGaugeInAlertL()"); |
|
211 |
|
212 UpdateGaugeInAlertL(gaugeVal); |
|
213 |
|
214 // skipping enabling visibility change in case of error |
|
215 // where incremental update type gauge wasn't show |
|
216 if (!skipVisibilityChange) |
|
217 { |
|
218 DisableVisibilityChange(EFalse); |
|
219 } |
|
220 |
|
221 DEBUG("CMIDAlertDialog::InsertGaugeIntoDialogL >"); |
|
222 } |
|
223 |
|
224 /** CMIDAlertDialog::CheckAndSetAnimationMode */ |
|
225 void CMIDAlertDialog::CheckAndSetAnimationModeL() |
|
226 { |
|
227 DEBUG("CMIDAlertDialog::CheckAndSetAnimationModeL <"); |
|
228 |
|
229 TBitFlags flags = Flags(); |
|
230 if (iGauge && (iGauge->GetIndefiniteState() == MMIDGauge::EIncrementalUpdating) |
|
231 && flags.IsSet(EPopupFormWaitAnim)) |
|
232 { |
|
233 CCoeControl* coe = GetControlByControlTypeL(EPopupFormWaitAnim)->iControl; |
|
234 CAknBitmapAnimation* ani = REINTERPRET_CAST(CAknBitmapAnimation*, coe); |
|
235 |
|
236 |
|
237 DEBUG("CMIDAlertDialog::CheckAndSetAnimationModeL - CancelAnimation()"); |
|
238 ani->CancelAnimation(); |
|
239 |
|
240 CBitmapAnimClientData* animClientData = ani->BitmapAnimData(); |
|
241 iGaugeFrameCount = animClientData->FrameArray().Count(); |
|
242 |
|
243 // A non-interactive Gauge that has indefinite range will exist in one of four states: |
|
244 // continuous-idle, incremental-idle, continuous-running, or incremental-updating. |
|
245 // These states are intended to indicate to the user that some level of activity is |
|
246 // occurring. With incremental-updating, progress can be indicated to the user even |
|
247 // though there is no known endpoint to the activity. |
|
248 if (iGauge->GetMaxValue() < 0) |
|
249 { //CBitmapAnimClientData::TPlayMode:: |
|
250 DEBUG("CMIDAlertDialog::CheckAndSetAnimationModeL - SetPlayModeL()"); |
|
251 ani->Animation().SetPlayModeL(CBitmapAnimClientData::ECycle); |
|
252 iIncrementalFrameCounter = 0; |
|
253 DEBUG("CMIDAlertDialog::CheckAndSetAnimationModeL - SetFrameIndexL()"); |
|
254 ani->SetFrameIndexL(iIncrementalFrameCounter++); |
|
255 } |
|
256 } |
|
257 DEBUG("CMIDAlertDialog::CheckAndSetAnimationModeL >"); |
|
258 } |
|
259 |
|
260 |
|
261 /** |
|
262 */ |
|
263 void CMIDAlertDialog::UpdateGaugeInAlertL(TInt aValue) |
|
264 { |
|
265 if (iGauge && aValue >= 0 && |
|
266 (iGauge->GetIndefiniteState() == MMIDGauge::EIncrementalUpdating || |
|
267 iGauge->GetMaxValue() > 0)) |
|
268 { |
|
269 TBitFlags flags = Flags(); |
|
270 if (flags.IsSet(EPopupFormWaitAnim)) |
|
271 { |
|
272 CCoeControl* coe = GetControlByControlTypeL(EPopupFormWaitAnim)->iControl; |
|
273 CAknBitmapAnimation* ani = REINTERPRET_CAST(CAknBitmapAnimation*, coe); |
|
274 if (iGaugeFrameCount < 1) |
|
275 iGaugeFrameCount = 1; |
|
276 ani->SetFrameIndexL(iIncrementalFrameCounter++ % iGaugeFrameCount); |
|
277 } |
|
278 else |
|
279 { |
|
280 // draw and update the progress bar |
|
281 SetProgressBarAndDraw(aValue); |
|
282 //draw of Alert |
|
283 DrawDeferred(); |
|
284 } |
|
285 } |
|
286 } |
|
287 |
|
288 |
|
289 void CMIDAlertDialog::GaugeTypeInAlertChangedL() |
|
290 { |
|
291 // create new gauge type in wait dialog |
|
292 InsertGaugeIntoDialogL(); |
|
293 CheckAndSetAnimationModeL(); |
|
294 |
|
295 // redraw gauge |
|
296 DrawDeferred(); |
|
297 } |
|
298 |
|
299 /** If the alert is timed (not modal) and if we receive a valid key event then |
|
300 we dismiss the dialog. Otherwise we pass on the key event to CAknPopupForm, |
|
301 which will take care of scrolling text for example. @see CMIDUtils::IgnoreKeyEvent() |
|
302 for key events that are ignored (eg. flip open or flip close key events. */ |
|
303 TKeyResponse CMIDAlertDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
304 { |
|
305 //DEBUG START |
|
306 if (aType == EEventKeyDown) |
|
307 { |
|
308 DEBUG_INT2("CMIDAlertDialog::OfferKeyEventL - key down, scan code %d key code %d", |
|
309 aKeyEvent.iScanCode, aKeyEvent.iCode); |
|
310 } |
|
311 else if (aType == EEventKey) |
|
312 { |
|
313 DEBUG_INT2("CMIDAlertDialog::OfferKeyEventL - key event, scan code %d key code %d", |
|
314 aKeyEvent.iScanCode, aKeyEvent.iCode); |
|
315 } |
|
316 else if (aType == EEventKeyUp) |
|
317 { |
|
318 DEBUG_INT2("CMIDAlertDialog::OfferKeyEventL - key up, scan code %d key code %d", |
|
319 aKeyEvent.iScanCode, aKeyEvent.iCode); |
|
320 } |
|
321 //DEBUG END |
|
322 |
|
323 if (!iParent->IsModal() && (aType == EEventKey) && !CMIDUtils::IgnoreKeyEvent(aKeyEvent.iCode)) |
|
324 { // if not modal then pressing any valid key should dismiss it |
|
325 iParent->TryToDismissDialog(); |
|
326 return EKeyWasConsumed; |
|
327 } |
|
328 //Enter_Key have a same function as Selection key. |
|
329 #ifdef RD_JAVA_S60_RELEASE_9_2 |
|
330 if (iParent->IsModal() && (aType == EEventKey) && (aKeyEvent.iCode == EKeyEnter || aKeyEvent.iCode == EKeyDevice3)) |
|
331 #else |
|
332 if (iParent->IsModal() && (aType == EEventKey) && aKeyEvent.iCode == EKeyEnter) |
|
333 #endif // RD_JAVA_S60_RELEASE_9_2 |
|
334 { |
|
335 OkToExitL(iDisplayable->MainCommandList()->CommandOffset()); |
|
336 return EKeyWasConsumed; |
|
337 } |
|
338 return CAknPopupForm::OfferKeyEventL(aKeyEvent, aType); |
|
339 } |
|
340 |
|
341 /** Modal dialogs must let the displayable handle commands whereas modeless |
|
342 dialogs can just exit on any key (including a CBA key). However we cannot |
|
343 exit directly, we must post a java side event and wait for the java request |
|
344 to dismiss the dialog. This is why we return EFalse. */ |
|
345 TBool CMIDAlertDialog::OkToExitL(TInt aCommandId) |
|
346 { |
|
347 if (iParent->IsModal()) |
|
348 { |
|
349 TInt offset = iDisplayable->MainCommandList()->CommandOffset(); |
|
350 |
|
351 if (aCommandId == EAknSoftkeyOptions) // 3000 |
|
352 { |
|
353 iDisplayable->MenuHandler()->ProcessCommandL(EAknSoftkeyOptions); |
|
354 } |
|
355 else if (aCommandId - offset < 0) // aCommandId value is over 3000 - used by MSK |
|
356 { |
|
357 iDisplayable->ProcessCommandL(aCommandId); |
|
358 } |
|
359 else // aCommandId value is 7000 and over - used by LSK, RSK and EnterKey |
|
360 { |
|
361 CMIDCommand* tempCmd = NULL; |
|
362 CMIDCommand* command = NULL; |
|
363 TBool isMaped = EFalse; |
|
364 TInt mapedCnt = ENone; |
|
365 TInt mapedId = ENone; |
|
366 |
|
367 // number of all commands |
|
368 TInt numberOfCommands = iDisplayable->CommandCount(); |
|
369 // number of Ok and Item commands |
|
370 TInt numberOfOkOptionsCommands = iDisplayable->NumCommandsForOkOptionsMenu(); |
|
371 // command ID which is get from aCommandId |
|
372 TInt commandId = aCommandId - offset; |
|
373 |
|
374 if (numberOfCommands > 0) |
|
375 { |
|
376 // Go through every midlet command, and save its ID if maped |
|
377 // and also count maped commands. |
|
378 for (TInt i = 0; i < numberOfCommands; i++) |
|
379 { |
|
380 tempCmd = iDisplayable->MainCommandList()->At(i).iCommand; |
|
381 if (tempCmd->IsMappedToSoftKey()) |
|
382 { |
|
383 mapedId = i; |
|
384 isMaped = ETrue; |
|
385 mapedCnt++; |
|
386 } |
|
387 } |
|
388 |
|
389 // If there are more than one maped command (LSK & RSK maped) |
|
390 // or maped command is different than commandId (EnterKey used), |
|
391 // set CMIDCommand command with this command, which index |
|
392 // is the same as commandId value. |
|
393 if (mapedCnt > 1 || mapedId != commandId) |
|
394 { |
|
395 command = iDisplayable->MainCommandList()->At(commandId).iCommand; |
|
396 } |
|
397 else // Else if there are one or zero command maped. |
|
398 { |
|
399 if (isMaped) // One command maped. |
|
400 { |
|
401 command = iDisplayable->MainCommandList()->At(mapedId).iCommand; |
|
402 } |
|
403 else // Zero commands maped. |
|
404 { |
|
405 command = iDisplayable->MainCommandList()->At(0).iCommand; |
|
406 } |
|
407 } |
|
408 |
|
409 // type of the command |
|
410 TInt commandType = command->CommandType(); |
|
411 |
|
412 // If there aren't any EExit, EBack, ECancel and EStop |
|
413 // command mapped and there are still some commands |
|
414 // show menu, else process with maped command. |
|
415 if (commandType != MMIDCommand::EExit && |
|
416 commandType != MMIDCommand::EBack && |
|
417 commandType != MMIDCommand::ECancel && |
|
418 commandType != MMIDCommand::EStop && |
|
419 numberOfOkOptionsCommands > 1) |
|
420 { |
|
421 iDisplayable->MenuHandler()->ShowMenuL(CMIDMenuHandler::EOkMenu); |
|
422 } |
|
423 else |
|
424 { |
|
425 iDisplayable->ProcessCommandL(aCommandId); |
|
426 } |
|
427 } |
|
428 } |
|
429 } |
|
430 else |
|
431 { |
|
432 iParent->TryToDismissDialog(); |
|
433 } |
|
434 |
|
435 //The dialog can only be dismissed java side or else we'll end |
|
436 //up with the alert displayed and no dialog |
|
437 return EFalse; |
|
438 } |
|
439 |
|
440 /** */ |
|
441 void CMIDAlertDialog::SetGaugeL(CMIDGaugeItem* aGauge) |
|
442 { |
|
443 DEBUG("CMIDAlertDialog::SetGaugeL <"); |
|
444 |
|
445 if (iGauge) |
|
446 { |
|
447 iGauge->SetGaugeListenerFromAlert(NULL); |
|
448 } |
|
449 iGauge = (CMIDNonInteractiveGauge*)(aGauge); |
|
450 |
|
451 DEBUG("CMIDAlertDialog::SetGaugeL - InsertGaugeIntoDialogL"); |
|
452 InsertGaugeIntoDialogL(); |
|
453 |
|
454 DEBUG("CMIDAlertDialog::SetGaugeL - CheckAndSetAnimationModeL"); |
|
455 CheckAndSetAnimationModeL(); |
|
456 |
|
457 DrawDeferred(); |
|
458 DEBUG("CMIDAlertDialog::SetGaugeL >"); |
|
459 } |
|
460 |
|
461 /** Show a pre-created dialog. Dialogs are created as soon |
|
462 as Alerts are created java side. This is not necessarily when |
|
463 the dialog must be displayed. */ |
|
464 void CMIDAlertDialog::ShowL(TBool aShow) |
|
465 { |
|
466 if (aShow != iShowing) |
|
467 { |
|
468 if (aShow) |
|
469 { |
|
470 iShowing = ETrue; |
|
471 RouseSleepingDialog(); |
|
472 |
|
473 #ifdef RD_SCALABLE_UI_V2 |
|
474 SetPointerCapture(ETrue); |
|
475 #endif |
|
476 } |
|
477 else |
|
478 { |
|
479 ExitSleepingDialog(); |
|
480 |
|
481 #ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK |
|
482 if (iButtonDownReceived) |
|
483 { |
|
484 //do feedback if alert was closed by tapping |
|
485 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
486 if (feedback) |
|
487 { |
|
488 feedback->InstantFeedback(ETouchFeedbackPopUp); |
|
489 } |
|
490 } |
|
491 #endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK |
|
492 |
|
493 #ifdef RD_SCALABLE_UI_V2 |
|
494 SetPointerCapture(EFalse); |
|
495 iButtonDownReceived = EFalse; |
|
496 #endif |
|
497 iShowing = EFalse; //attention: iShowing must be true when dismissing |
|
498 // a dialog or else MakeVisible() won't execute and |
|
499 // we won't update the fader's stack, @see MakeVisible() |
|
500 } |
|
501 |
|
502 UpdateCbasL(); |
|
503 } |
|
504 } |
|
505 |
|
506 /** Because CAknPopupForm calls MakeVisible(ETrue) in several |
|
507 places, including LayoutAndDraw() and because we don't want to |
|
508 become visible when we are not showing, we had to override the |
|
509 MakeVisible() method and pass on the call only when we are |
|
510 showing. Also, CMIDAlert can disable temporarily the MakeVisible |
|
511 calls by setting iVisibilityChangeDisabled via DisableVisibilityChange(). |
|
512 This is because when we call SetTitle() or SetImage() we must insert |
|
513 or remove controls into the dialog and popup form does MakeVisible(EFalse) |
|
514 and then MakeVisible(ETrue) after the control has been added or removed. |
|
515 This results in an unpleasant appearing and disappearing of the dialog |
|
516 because we add or remove more than one control. */ |
|
517 void CMIDAlertDialog::MakeVisible(TBool aVisible) |
|
518 { |
|
519 if (iShowing && !iVisibilityChangeDisabled) |
|
520 { |
|
521 if (aVisible) |
|
522 { |
|
523 //re-layouting done just before dialog is shown |
|
524 //to be sure layout is correct in CAknPopupForm |
|
525 CAknPopupForm::SizeChanged(); |
|
526 } |
|
527 CAknPopupForm::MakeVisible(aVisible); |
|
528 } |
|
529 } |
|
530 |
|
531 |
|
532 #ifdef RD_SCALABLE_UI_V2 |
|
533 /** |
|
534 * Closes timed alert on EButton1Up event. Detecting long taps is done through |
|
535 * CMIDAlert::TryDetectLongTapL. |
|
536 */ |
|
537 void CMIDAlertDialog::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
538 { |
|
539 if (AknLayoutUtils::PenEnabled()) |
|
540 { |
|
541 // Long tap may be canceled by dragging pointer out of alert area, |
|
542 // need to make sure that events are forwarded to long tap detector in this case. |
|
543 if ((AlertRegionContains(aPointerEvent.iPosition) || |
|
544 aPointerEvent.iType != TPointerEvent::EButton1Down) && |
|
545 iParent->TryDetectLongTapL(aPointerEvent)) |
|
546 { |
|
547 return; |
|
548 } |
|
549 |
|
550 switch (aPointerEvent.iType) |
|
551 { |
|
552 case TPointerEvent::EButton1Down: |
|
553 iButtonDownReceived = ETrue; |
|
554 break; |
|
555 case TPointerEvent::EButton1Up: |
|
556 if (!iParent->IsModal() && iButtonDownReceived) |
|
557 { |
|
558 iParent->TryToDismissDialog(); |
|
559 } |
|
560 break; |
|
561 case TPointerEvent::EDrag: |
|
562 break; |
|
563 default: |
|
564 break; |
|
565 } |
|
566 |
|
567 } |
|
568 } |
|
569 #endif |
|
570 |
|
571 |
|
572 /** Disable the MakeVisible() calls. See @MakeVisible() */ |
|
573 void CMIDAlertDialog::DisableVisibilityChange(TBool aDisable) |
|
574 { |
|
575 iVisibilityChangeDisabled = aDisable; |
|
576 } |
|
577 |
|
578 /** We disable unnecessary layout operation in an attempt to optimise because of |
|
579 defect OULM-6K4C2X. This would not be needed if CAknPopupForm::InsertControlL() |
|
580 would not call LayoutAndDraw() every time and also CAknPopupForm::SetSizeAndPosition() |
|
581 results in the execution of SizeChanged() 3 times. So a lot of layout operations get |
|
582 in the way of performance. */ |
|
583 void CMIDAlertDialog::SizeChanged() |
|
584 { |
|
585 if (!iVisibilityChangeDisabled || iShowing) |
|
586 { |
|
587 CAknPopupForm::SizeChanged(); |
|
588 } |
|
589 } |
|
590 |
|
591 void CMIDAlertDialog::HandleResourceChange(TInt aType) |
|
592 { |
|
593 if (aType == KEikDynamicLayoutVariantSwitch) |
|
594 { |
|
595 LayoutAndDraw(); |
|
596 |
|
597 TRAP_IGNORE(InsertGaugeIntoDialogL(); CheckAndSetAnimationModeL();); |
|
598 |
|
599 DrawDeferred(); |
|
600 } |
|
601 else |
|
602 { |
|
603 CAknPopupForm::HandleResourceChange(aType); |
|
604 } |
|
605 } |
|
606 |
|
607 #ifdef RD_SCALABLE_UI_V2 |
|
608 TBool CMIDAlertDialog::AlertRegionContains(const TPoint& aPoint) |
|
609 { |
|
610 return (aPoint.iX >= 0 && aPoint.iX <= iSize.iWidth && |
|
611 aPoint.iY >= 0 && aPoint.iY <= iSize.iHeight); |
|
612 } |
|
613 #endif |
|
614 |
|
615 // End of File |