javauis/lcdui_akn/lcdui/src/CMIDAlert.cpp
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2003-2006 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 implementation for Series 60
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "CMIDAlert.h"
       
    21 #include "CMIDAlertDialog.h"
       
    22 #include "CMIDDisplayable.h"
       
    23 #include "CMIDGaugeItem.h"
       
    24 #include "CMIDUtils.h"
       
    25 
       
    26 // used for layouting
       
    27 // LAF - AknLayoutScalable_Avkon::popup_midp_note_alarm_window_g1
       
    28 #include <aknlayoutscalable_avkon.cdl.h>
       
    29 
       
    30 // using MMIDImage and MMIDBitmapImage
       
    31 #include <lcdgr.h>
       
    32 // macros definitions for resources
       
    33 #include <lcdui.rsg>
       
    34 
       
    35 // CEikCaptionedControl API used when setting image or animation
       
    36 // in SetImageOrAnimToDialogL function
       
    37 #include <eikcapc.h>
       
    38 // using CEikImage when setting image or animation
       
    39 // in SetImageOrAnimToDialogL function
       
    40 #include <eikimage.h>
       
    41 // macros for resources related to alert
       
    42 #include <avkon.rsg>
       
    43 #include <avkon.hrh>
       
    44 
       
    45 // macros definitions for outputing logs
       
    46 #include <j2me/jdebug.h>
       
    47 
       
    48 // sound files
       
    49 #include <aknappui.h>
       
    50 #include <aknsoundsystem.h>
       
    51 
       
    52 const TInt KMillToMicroSeconds = 1000;
       
    53 const TInt KAlertDefaultTimeout = 3000;
       
    54 const TInt KConfirmationNoteTimeout = 1500;
       
    55 
       
    56 CMIDAlert* CMIDAlert::NewL(
       
    57     MMIDEnv& aEnv,
       
    58     TAlertType aType,
       
    59     MMIDDisplayable& aDisplayable,
       
    60     const TDesC& aString,
       
    61     MMIDImage* aImage,
       
    62     MMIDUtils* aUtils)
       
    63 {
       
    64     CMIDAlert* alert = new(ELeave) CMIDAlert(aEnv, aType, aUtils);
       
    65     CleanupStack::PushL(alert);
       
    66     alert->ConstructL(aDisplayable,aString,aImage);
       
    67     CleanupStack::Pop(alert);
       
    68     return alert;
       
    69 }
       
    70 
       
    71 CMIDAlert::CMIDAlert(MMIDEnv& aEnv, TAlertType aType, MMIDUtils* aUtils)
       
    72         : iEnv(&aEnv), iAlertType(aType), iUtils(aUtils)
       
    73 {
       
    74 }
       
    75 
       
    76 CMIDAlert::~CMIDAlert()
       
    77 {
       
    78     if (iBitmapImage)
       
    79     {
       
    80         iBitmapImage->RemoveRef();
       
    81         iBitmapImage = NULL;
       
    82     }
       
    83 
       
    84     delete iUserText; //lint !1551
       
    85     delete iDefaultText;
       
    86 
       
    87     delete iDialog;
       
    88 
       
    89     delete iDialogTimer;
       
    90 
       
    91     // Displayable is notified about content control deletion
       
    92     if (iDisplayable)
       
    93     {
       
    94         iDisplayable->NotifyContentDestroyed();
       
    95     }
       
    96 
       
    97 }
       
    98 
       
    99 
       
   100 void CMIDAlert::ConstructL(MMIDDisplayable& aDisplayable,const TDesC& aString,MMIDImage* aImage)
       
   101 {
       
   102     CMIDDisplayable* dsp = (CMIDDisplayable*)(&aDisplayable);
       
   103     aDisplayable.SetComponentL(*this);
       
   104     iDisplayable = dsp;
       
   105 
       
   106     //Hide menu if visible
       
   107     CMIDMenuHandler* menuHandler = iDisplayable->MenuHandler();
       
   108 
       
   109     if (menuHandler)
       
   110     {
       
   111         menuHandler->HideMenuIfVisible();
       
   112     }
       
   113 
       
   114 
       
   115     SetStringL(aString);
       
   116     SetImageL(aImage);
       
   117 
       
   118     CreateDialogL();
       
   119 
       
   120     SetContainerWindowL(*dsp);
       
   121 
       
   122     iAlertTone = ENoTone;
       
   123     ASSERT(iUtils);
       
   124 }
       
   125 
       
   126 /** Play a sound. Called when the dialog is shown. */
       
   127 TInt CMIDAlert::PlaySound()
       
   128 {
       
   129     return iUtils->PlaySound(iAlertType);
       
   130 }
       
   131 
       
   132 /** Sets the dialog text to a user given text
       
   133 or to the default text. If the text is so long
       
   134 that it requires scrolling then the dialog must
       
   135 become modal, hence we call SetModalL() if that's
       
   136 the case. This method is also called by ConstructL()
       
   137 before creating the dialog so we must check there
       
   138 is a dialog before calling SetTextL() on the dialog.*/
       
   139 void CMIDAlert::SetStringL(const TDesC& aString)
       
   140 {
       
   141     DEBUG("CMIDAlert::SetStringL <");
       
   142 
       
   143     delete iUserText;
       
   144     iUserText = NULL;
       
   145 
       
   146     if (aString.Length() > 0)
       
   147     {
       
   148         iUserText = aString.AllocL();
       
   149     }
       
   150     if (iDialog)
       
   151     {
       
   152         iDialog->SetTextL(iUserText ? iUserText : iDefaultText);
       
   153         iDialog->DrawDeferred();
       
   154         iDialog->SizeChanged();
       
   155     }
       
   156 
       
   157     if (IsModal())
       
   158     {
       
   159         SetModalL();
       
   160     }
       
   161 
       
   162 
       
   163     DEBUG("CMIDAlert::SetStringL >");
       
   164 }
       
   165 
       
   166 /** Sets the dialog title or removes it. This is
       
   167 done by inserting or removing the heading and separator
       
   168 controls as well as calling CAknPopupForm::SetTitleL().
       
   169 See also DisableVisibilityChange(), which we must call
       
   170 to avoid the dialog disappearing and re-appearing each
       
   171 time we insert or remove a control. */
       
   172 void CMIDAlert::SetTitleL(const TDesC* aString)
       
   173 {
       
   174     TBitFlags flags = iDialog->Flags();
       
   175     iDialog->DisableVisibilityChange(ETrue);
       
   176 
       
   177     if (aString && aString->Length() > 0)
       
   178     { // Title is updated to dialog
       
   179 
       
   180         if (!flags.IsSet(EPopupFormHasHeading))
       
   181         {// Add headerline and extra empty line
       
   182             iDialog->InsertControlL(0, R_MIDP_ALERT_HEADING_LINE, EFalse);
       
   183             iDialog->InsertControlL(0, R_MIDP_ALERT_SPACER_LINE, EFalse);
       
   184         }
       
   185 
       
   186         iDialog->SetTitleL(*aString);
       
   187     }
       
   188     else // Title is removed from dialog
       
   189     {// Remove headerline and extra empty line
       
   190 
       
   191         if (flags.IsSet(EPopupFormHasHeading))
       
   192         {
       
   193             iDialog->DeleteControl(EEikCtLabel);
       
   194             iDialog->DeleteControl(EEikCtSpacer);
       
   195         }
       
   196     }
       
   197 
       
   198     iDialog->DisableVisibilityChange(EFalse);
       
   199     iDialog->DrawDeferred();
       
   200 }
       
   201 
       
   202 /** Either set or remove an image.  This
       
   203 method is also called in ConstructL() before creating the dialog
       
   204 and hence we must make sure we do not call SetImageToDialogL
       
   205 if there is not dialog. @see SetImageToDialogL(). */
       
   206 void CMIDAlert::SetImageL(MMIDImage* aImage)
       
   207 {
       
   208     if (iBitmapImage)
       
   209     {
       
   210         iBitmapImage->RemoveRef();
       
   211         iBitmapImage = NULL;
       
   212     }
       
   213 
       
   214     if (aImage)
       
   215     {
       
   216         iBitmapImage = aImage->BitmapImage();
       
   217     }
       
   218 
       
   219     if (iDialog)
       
   220     {
       
   221         SetImageOrAnimToDialogL();
       
   222     }
       
   223 }
       
   224 
       
   225 /** If we have an image, this image is set into the dialog. If the dialog had an
       
   226 animation then the animation is hidden. If we have no image we make sure the dialog
       
   227 does not have an image either (by calling SetImage(NULL). If the dialog has an
       
   228 animation we then make the animation visible again. */
       
   229 void CMIDAlert::SetImageOrAnimToDialogL()
       
   230 {
       
   231     ASSERT(iDialog);
       
   232     iDialog->DisableVisibilityChange(ETrue);
       
   233 
       
   234     if (iBitmapImage)
       
   235     { //remove animation if any and add image
       
   236         if (iDialog->Flags().IsSet(EPopupFormHasAnimation))
       
   237         {
       
   238             iDialog->DeleteControl(EPopupFormAnimation);
       
   239         }
       
   240 
       
   241         if (!iDialog->Flags().IsSet(EPopupFormHasImage))
       
   242         {
       
   243             iDialog->InsertControlL(0, R_MIDP_ALERT_IMAGE_LINE, EFalse);
       
   244         }
       
   245 
       
   246         CEikImage* newImage = CreateImageLC();
       
   247         CEikImage* dlgImage = (CEikImage*)(iDialog->GetControlByControlType(EEikCtImage)->iControl);
       
   248         newImage->SetPictureOwnedExternally(ETrue);
       
   249         dlgImage->SetBitmap(newImage->Bitmap());
       
   250         dlgImage->SetMask(newImage->Mask());
       
   251         CleanupStack::PopAndDestroy(newImage);
       
   252     }
       
   253     else if (iAlertAnimation > 0)
       
   254     { //or else remove image if any and add  animation
       
   255         if (iDialog->Flags().IsSet(EPopupFormHasImage))
       
   256         {
       
   257             iDialog->DeleteControl(EPopupFormImage);
       
   258         }
       
   259 
       
   260         if (iDialog->Flags().IsSet(EPopupFormHasAnimation))
       
   261         { //because animation may have changed
       
   262             iDialog->DeleteControl(EPopupFormAnimation);
       
   263         }
       
   264         iDialog->DisableVisibilityChange(EFalse);
       
   265         iDialog->InsertControlL(0, iAlertAnimation, EFalse);
       
   266         iDialog->DisableVisibilityChange(ETrue);
       
   267     }
       
   268     else
       
   269     { //remove any animation or image that should not be there anymore
       
   270         if (iDialog->Flags().IsSet(EPopupFormHasAnimation))
       
   271         {
       
   272             iDialog->DeleteControl(EPopupFormAnimation);
       
   273         }
       
   274 
       
   275         if (iDialog->Flags().IsSet(EPopupFormHasImage))
       
   276         {
       
   277             iDialog->DeleteControl(EPopupFormImage);
       
   278         }
       
   279     }
       
   280 
       
   281     iDialog->DisableVisibilityChange(EFalse);
       
   282     iDialog->DrawDeferred();
       
   283 }
       
   284 
       
   285 /** Creates a CEikImage starting from iBitmapImage. The CEikImage
       
   286 can then be inserted into the dialog. @see ResizeImage(), SetImageToDialogL() */
       
   287 CEikImage* CMIDAlert::CreateImageLC() const
       
   288 {
       
   289     ASSERT(iBitmapImage);
       
   290 
       
   291     CFbsBitmap* bmp = CMIDUtils::CopyBitmapL(iBitmapImage->ColorBitmap());
       
   292     CleanupStack::PushL(bmp);
       
   293 
       
   294     CFbsBitmap* mask = NULL;
       
   295     if (iBitmapImage->AlphaBitmap())
       
   296     {
       
   297         //alert fails to display transparent images of type EGray2 so we
       
   298         //force a EGray256, which we have verified to be working.
       
   299         mask = iBitmapImage->CreateAlphaBitmapL(EGray256, EFalse);
       
   300     }
       
   301 
       
   302     CleanupStack::PushL(mask);
       
   303 
       
   304     CEikImage* eikImage = new(ELeave) CEikImage;
       
   305     CleanupStack::Pop(mask);
       
   306     CleanupStack::Pop(bmp);
       
   307 
       
   308     ResizeImage(bmp,mask);
       
   309     eikImage->SetPicture(bmp, mask);
       
   310 
       
   311     CleanupStack::PushL(eikImage);
       
   312     return eikImage;
       
   313 }
       
   314 
       
   315 /** Resize the image (bitmap and mask if applicable). In theory the
       
   316 AVKON dialog should take care of this but there is panic in CEikCaptionedControl
       
   317 if we don't do this. If the image is smaller it ends up at the top left. If it is
       
   318 bigger it is clipped starting at top left. */
       
   319 void CMIDAlert::ResizeImage(CFbsBitmap* aImage, CFbsBitmap* aMask) const
       
   320 {
       
   321     CMIDMenuHandler* menuHandler = iDisplayable->MenuHandler();
       
   322 
       
   323 
       
   324     TAknWindowLineLayout lineLayout;
       
   325     lineLayout = AknLayoutScalable_Avkon::popup_midp_note_alarm_window_g1(0).LayoutLine();
       
   326 
       
   327     TSize goodSize = TSize(lineLayout.iW, lineLayout.iH);
       
   328     TSize imageSize = aImage->SizeInPixels();
       
   329 
       
   330     if (imageSize.iWidth > goodSize.iWidth ||
       
   331             imageSize.iHeight > goodSize.iHeight)
       
   332     {
       
   333         TSize newSize(Min(goodSize.iWidth, imageSize.iWidth),Min(goodSize.iHeight, imageSize.iHeight));
       
   334         aImage->Resize(newSize);
       
   335 
       
   336         if (aMask)
       
   337         {
       
   338             aMask->Resize(newSize);
       
   339         }
       
   340     }
       
   341 }
       
   342 
       
   343 /** Set a progress bar indicator. */
       
   344 void CMIDAlert::SetIndicatorL(MMIDGauge* aGauge)
       
   345 {
       
   346     DEBUG("CMIDAlert::SetIndicatorL <");
       
   347     iDialog->SetGaugeL(static_cast< CMIDGaugeItem* >(aGauge));
       
   348     DEBUG("CMIDAlert::SetIndicatorL >");
       
   349 }
       
   350 
       
   351 /** Deletes an existing dialog and creates a new one.
       
   352 
       
   353     Note: this should be called in ConstructL()
       
   354     or when the alert type changes. For everything else
       
   355     an existing dialog is updated.
       
   356  */
       
   357 void CMIDAlert::CreateDialogL()
       
   358 {
       
   359     DEBUG("CMIDAlert::CreateDialogL <");
       
   360     ASSERT(!iDialog);
       
   361 
       
   362     iDialog = CMIDAlertDialog::NewL(this, iDisplayable);
       
   363 
       
   364     TInt resource = SetAlertResourceIdsL();
       
   365     iDialog->SetTone(iAlertTone);
       
   366     iDialog->SetPopupFormType(EAknNote);
       
   367 
       
   368     iDialog->PrepareLC(resource);
       
   369     CleanupStack::Pop(iDialog);
       
   370     iEikonEnv->EikAppUi()->RemoveFromStack(iDialog);
       
   371 
       
   372     iDialog->ButtonGroupContainer().MakeVisible(EFalse);
       
   373 
       
   374     DEBUG("CMIDAlert::CreateDialogL - SetImageOrAnimToDialogL <");
       
   375     SetImageOrAnimToDialogL();
       
   376     DEBUG("CMIDAlert::CreateDialogL - SetImageOrAnimToDialogL <");
       
   377 
       
   378     iDialog->SetTextL(iUserText ? iUserText : iDefaultText);
       
   379     iDialog->DrawDeferred();
       
   380     iDialog->SizeChanged();
       
   381 
       
   382     if (IsModal())
       
   383     {
       
   384         SetModalL();
       
   385     }
       
   386     if (iDisplayable->HasTitle())
       
   387     {
       
   388         SetTitleL(iDisplayable->Title());
       
   389     }
       
   390 
       
   391     DEBUG("CMIDAlert::CreateDialogL >");
       
   392 }
       
   393 
       
   394 /** This is called when the owning displayable is asked to
       
   395 come to the foreground or to go to the background. If coming
       
   396 to the foreground, we set the timeout, play a sound and display
       
   397 the dialog. If going to the background we hide the dialog. */
       
   398 void CMIDAlert::HandleCurrentL(TBool aCurrent)
       
   399 {
       
   400     DEBUG_INT("CMIDAlert::HandleCurrentL < (%d)", aCurrent);
       
   401 
       
   402     if (aCurrent)
       
   403     {
       
   404         if (IsModal())
       
   405         {
       
   406             iTimeout = MMIDAlert::EForever;
       
   407         }
       
   408 
       
   409         SetTimeoutL(iTimeout);
       
   410         PlaySound();
       
   411 
       
   412         iEikonEnv->EikAppUi()->AddToStackL(iDialog,ECoeStackPriorityDialog);
       
   413 
       
   414         // The flag  flags |= CEikButtonGroupContainer::EDelayActivation
       
   415         // is set in CEikDialog::CreateButtonGroupContainerL , It means that button
       
   416         // will not be activeated automaticaly after it is create, it need to be activated
       
   417         iDialog->ButtonGroupContainer().ActivateL();
       
   418         iDialog->ShowL(ETrue);
       
   419     }
       
   420     else
       
   421     {
       
   422         iDialog->ShowL(EFalse);
       
   423         iEikonEnv->EikAppUi()->RemoveFromStack(iDialog);
       
   424     }
       
   425 
       
   426     DEBUG("CMIDAlert::HandleCurrentL >");
       
   427 }
       
   428 
       
   429 /** The alert type is used to present a
       
   430 visually different kind of alert to the user.
       
   431 If a diferent type is set we must reset the animation
       
   432 (unless an image has already been set and this is taken
       
   433 care of by SetImageOrAnimtoDialogL()),
       
   434 the tone and the text (unless a user text was given).
       
   435 Finally we draw the dialog.
       
   436 */
       
   437 void CMIDAlert::SetTypeL(TAlertType aType)
       
   438 {
       
   439     if (iAlertType != aType)
       
   440     {
       
   441         iAlertType = aType;
       
   442         SetAlertResourceIdsL();
       
   443 
       
   444         iDialog->SetTone(iAlertTone);
       
   445         SetImageOrAnimToDialogL();
       
   446 
       
   447         iDialog->SetTextL(iUserText ? iUserText : iDefaultText);
       
   448 
       
   449         iDialog->DrawDeferred();
       
   450     }
       
   451 }
       
   452 
       
   453 /** Return the alert default timeout. */
       
   454 TInt CMIDAlert::DefaultTimeout()
       
   455 {
       
   456     if (iAlertType == EConfirmation)
       
   457     {
       
   458         return KConfirmationNoteTimeout;
       
   459     }
       
   460     else
       
   461     {
       
   462         return KAlertDefaultTimeout;
       
   463     }
       
   464 }
       
   465 
       
   466 /** Sets the timeout for a timed alert. */
       
   467 void CMIDAlert::SetTimeoutL(TInt aTime)
       
   468 {
       
   469     iTimeout = aTime;
       
   470 
       
   471     if (!iDialog)
       
   472     {//no need to start the t.o. if dialog is not there yet
       
   473         return;
       
   474     }
       
   475 
       
   476     delete iDialogTimer;
       
   477     iDialogTimer = NULL;
       
   478 
       
   479     TTimeIntervalMicroSeconds32 interval = aTime * KMillToMicroSeconds;
       
   480     if (interval.Int() >= 0)
       
   481     {
       
   482         iDialogTimer = CPeriodic::NewL(CActive::EPriorityStandard);
       
   483         iDialogTimer->Start(interval, interval, TCallBack(TimerCallBack,this));
       
   484     }
       
   485 }
       
   486 
       
   487 TInt CMIDAlert::TimerCallBack(TAny* aThis)
       
   488 {
       
   489     CMIDAlert* self = STATIC_CAST(CMIDAlert*, aThis);
       
   490     if (self)
       
   491     {
       
   492         self->DoTimerCallBack();
       
   493     }
       
   494 
       
   495     return KErrNone;
       
   496 }
       
   497 
       
   498 /** When the timeout expires, try to dismiss the dialog.
       
   499 We cannot delete the dialog here because we need java
       
   500 side to set another Displayable first. If java side does
       
   501 not do this - because of a badly behaved midlet - we keep
       
   502 the dialog showing. */
       
   503 void CMIDAlert::DoTimerCallBack()
       
   504 {
       
   505     if (!IsModal())
       
   506     {// The dialog may have become modal whilst
       
   507         // the timer was running
       
   508         TryToDismissDialog();
       
   509     }
       
   510 
       
   511     if (iDialogTimer)
       
   512     {
       
   513         iDialogTimer->Cancel();
       
   514     }
       
   515 }
       
   516 
       
   517 /**
       
   518 * Handles a change to the control's resources.
       
   519 */
       
   520 void CMIDAlert::HandleResourceChange(TInt aType)
       
   521 {
       
   522     if (aType == KAknsMessageSkinChange)
       
   523     {
       
   524         TRAP_IGNORE(SetImageOrAnimToDialogL(); iDialog->InsertGaugeIntoDialogL(););
       
   525     }
       
   526 }
       
   527 
       
   528 /** Post a request java side to try and dismiss the dialog */
       
   529 void CMIDAlert::TryToDismissDialog()
       
   530 {
       
   531     if (iDialog)
       
   532     {
       
   533         iEnv->PostJavaEvent(*this,EDisplayable);
       
   534     }
       
   535 }
       
   536 
       
   537 #ifdef RD_SCALABLE_UI_V2
       
   538 TBool CMIDAlert::TryDetectLongTapL(const TPointerEvent& aPointerEvent)
       
   539 {
       
   540     return iDisplayable->TryDetectLongTapL(aPointerEvent);
       
   541 }
       
   542 #endif
       
   543 
       
   544 /** Return true if the alert is scrollable. */
       
   545 TBool CMIDAlert::IsScrollable()
       
   546 {
       
   547     if (iDialog)
       
   548     {
       
   549         return iDialog->TextIsScrollable();
       
   550     }
       
   551     else
       
   552     {
       
   553         return EFalse;
       
   554     }
       
   555 }
       
   556 
       
   557 /** -----------------------------------------------------------------------------
       
   558 // CMIDAlert::SetModalL
       
   559 //
       
   560 // A modal Alert has the timeout set to FOREVER and must be dismissed using a Command.
       
   561 // All Alerts have either the DISMISS_COMMAND or a command added by the application.
       
   562 //
       
   563 // An Alert becomes modal when:
       
   564 // - The timeout is set to FOREVER
       
   565 // - There are two or more commands
       
   566 // - The content becomes so large that it must scroll
       
   567 //
       
   568 // The java framework will call SetModal() when two or more commands are added.
       
   569 // The other two conditions are tested in CMIDAlert.
       
   570 //
       
   571 // When the reverse of all the above is true, the Alert reverts to being non modal.
       
   572 // In this case, the timer will only be re started when the Alert is made current
       
   573 // -----------------------------------------------------------------------------
       
   574 */
       
   575 void CMIDAlert::SetModalL()
       
   576 {
       
   577     iTimeout = MMIDAlert::EForever;
       
   578     SetTimeoutL(iTimeout);
       
   579 
       
   580     iDialog->UpdateCbasL();
       
   581 }
       
   582 
       
   583 /** Returns true if the alert is modal (not timed, scrollable or with more than one
       
   584 command). Otherwise it returns false.*/
       
   585 TBool CMIDAlert::IsModal()
       
   586 {
       
   587     return (IsScrollable()
       
   588             || (iTimeout == MMIDAlert::EForever)
       
   589             || (iDisplayable->CommandCount() >= KAlertModalCommandCount));
       
   590 }
       
   591 
       
   592 /** Return the resource ID depending on the dialog type. Also
       
   593 set the alert animation, tone, and default text according to
       
   594 the alert type. */
       
   595 TInt CMIDAlert::SetAlertResourceIdsL()
       
   596 {
       
   597     // More resource types might be needed if an alert wants to show a
       
   598     // gauge with correct layout....
       
   599     delete iDefaultText;
       
   600     iDefaultText = NULL;
       
   601 
       
   602     switch (iAlertType)
       
   603     {
       
   604     case EAlarm:
       
   605         iDefaultText = iEikonEnv->AllocReadResourceL(R_MIDP_ALERT_ALARM_DEFAULT_TEXT);
       
   606         iAlertAnimation = R_MIDP_ALARM_NOTE_ANIMATION;
       
   607         iAlertTone =  EInformationTone;
       
   608         return R_MIDP_ALARM_NOTE_DIALOG;
       
   609     case EConfirmation:
       
   610         iDefaultText = iEikonEnv->AllocReadResourceL(R_MIDP_ALERT_CONF_DEFAULT_TEXT);
       
   611         iAlertAnimation = R_MIDP_CONFIRMATION_NOTE_ANIMATION;
       
   612         iAlertTone =  EConfirmationTone;
       
   613         return R_MIDP_CONFIRMATION_NOTE_DIALOG;
       
   614     case EError:
       
   615         iDefaultText = iEikonEnv->AllocReadResourceL(R_MIDP_ALERT_ERROR_DEFAULT_TEXT);
       
   616         iAlertAnimation = R_MIDP_ERROR_NOTE_ANIMATION;
       
   617         iAlertTone =  EErrorTone;
       
   618         return R_MIDP_ERROR_NOTE_DIALOG;
       
   619     case EWarning:
       
   620         iDefaultText = iEikonEnv->AllocReadResourceL(R_MIDP_ALERT_WARNING_DEFAULT_TEXT);
       
   621         iAlertAnimation = R_MIDP_WARNING_NOTE_ANIMATION;
       
   622         iAlertTone =  EWarningTone;
       
   623         return R_MIDP_WARNING_NOTE_DIALOG;
       
   624     case EInfo:
       
   625         iDefaultText = iEikonEnv->AllocReadResourceL(R_MIDP_ALERT_INFO_DEFAULT_TEXT);
       
   626         iAlertAnimation = R_MIDP_INFORMATION_NOTE_ANIMATION;
       
   627         iAlertTone =  EInformationTone;
       
   628         return R_MIDP_INFORMATION_NOTE_DIALOG;
       
   629     case ENone: // No Alerttype set, use information note
       
   630         iDefaultText = iEikonEnv->AllocReadResourceL(R_MIDP_ALERT_NULL_DEFAULT_TEXT);
       
   631         iAlertAnimation = 0;
       
   632         iAlertTone = ENoTone;
       
   633         return R_MIDP_NONE_ALERTTYPE_DIALOG;
       
   634     default:
       
   635         ASSERT(EFalse);
       
   636         return R_MIDP_NONE_ALERTTYPE_DIALOG;
       
   637     }
       
   638 }
       
   639 
       
   640 /** Called java side to release the native implementation of the dialog, i.e. us */
       
   641 void CMIDAlert::Dispose()
       
   642 {
       
   643     delete this;
       
   644 }
       
   645 
       
   646 // End of File