calendarui/multicaluidialog/src/multicaluidialogimpl.cpp
changeset 0 f979ecb2b13e
child 10 38571fd2a704
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2  * Copyright (c) 2009 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 : Implemrntation class for calenlistdialog .
       
    15  */
       
    16 
       
    17 //System include
       
    18 #include <calsession.h>
       
    19 #include <calentryview.h>
       
    20 #include <calcalendarinfo.h>
       
    21 #include <StringLoader.h>
       
    22 #include <AknsBasicBackgroundControlContext.h>
       
    23 #include <aknconsts.h>
       
    24 #include <AknIconArray.h>
       
    25 #include <aknlists.h>
       
    26 #include <akntitle.h>
       
    27 #include <eikclbd.h>
       
    28 #include <aknnavi.h>
       
    29 #include <aknlayoutscalable_apps.cdl.h>
       
    30 #include <layoutmetadata.cdl.h>
       
    31 #include <data_caging_path_literals.hrh>
       
    32 #include <pathinfo.h>
       
    33 #include <bautils.h>
       
    34 #include <aknenv.h>
       
    35 #include <eikapp.h>
       
    36 #include <eikenv.h>
       
    37 #include <gulicon.h>
       
    38 #include <multicaluidialog.rsg>
       
    39 #include <multicaluidialog.mbg>
       
    40 #include <avkon.rsg>
       
    41 #include <eikcapc.h> 
       
    42 
       
    43 //User include
       
    44 #include "multicaluidialogimpl.h"
       
    45 #include "multicaluidialogmodel.h"
       
    46 #include "calendarui_debug.h"
       
    47 #include "calendar.hrh"
       
    48 #include <aknPopup.h>
       
    49 
       
    50 
       
    51 // ----------------------------------------------------------------------------
       
    52 // CMultiCalUiDialogImpl::CMultiCalUiDialogImpl
       
    53 // (other items were commented in a header).
       
    54 // ----------------------------------------------------------------------------
       
    55 //
       
    56 CMultiCalUiDialogImpl::CMultiCalUiDialogImpl()
       
    57     {
       
    58     TRACE_ENTRY_POINT
       
    59     
       
    60     TRACE_EXIT_POINT
       
    61     }
       
    62 
       
    63 // ----------------------------------------------------------------------------
       
    64 // CMultiCalUiDialogImpl::NewL
       
    65 // (other items were commented in a header).
       
    66 // ----------------------------------------------------------------------------
       
    67 //
       
    68 CMultiCalUiDialogImpl* CMultiCalUiDialogImpl::NewL(const RPointerArray<CCalEntry>& 
       
    69         aCalEntries)
       
    70     {
       
    71     TRACE_ENTRY_POINT
       
    72     CMultiCalUiDialogImpl* self = CMultiCalUiDialogImpl::NewLC(aCalEntries);
       
    73     CleanupStack::Pop(self);
       
    74     TRACE_EXIT_POINT
       
    75     return self;
       
    76     }
       
    77 
       
    78 // ----------------------------------------------------------------------------
       
    79 // CMultiCalUiDialogImpl::NewLC
       
    80 // (other items were commented in a header).
       
    81 // ----------------------------------------------------------------------------
       
    82 //
       
    83 CMultiCalUiDialogImpl* CMultiCalUiDialogImpl::NewLC(const RPointerArray<CCalEntry>& 
       
    84         aCalEntries)
       
    85     {
       
    86     TRACE_ENTRY_POINT
       
    87     CMultiCalUiDialogImpl* self = new(ELeave) CMultiCalUiDialogImpl();
       
    88     CleanupStack::PushL(self);
       
    89     self->ConstructL(aCalEntries);
       
    90     TRACE_EXIT_POINT
       
    91     return self;
       
    92     }
       
    93 
       
    94 // ----------------------------------------------------------------------------
       
    95 // CMultiCalUiDialogImpl::~CMultiCalUiDialogImpl
       
    96 // (other items were commented in a header).
       
    97 // ----------------------------------------------------------------------------
       
    98 //
       
    99 CMultiCalUiDialogImpl::~CMultiCalUiDialogImpl()
       
   100     {
       
   101     TRACE_ENTRY_POINT
       
   102     
       
   103 	if(iListBox)
       
   104 		{
       
   105 		iListBox->Reset();
       
   106 		delete iListBox; 
       
   107 		}
       
   108     
       
   109     if( iResourceFileOffset )
       
   110         {
       
   111         CCoeEnv::Static()->DeleteResourceFile( iResourceFileOffset );
       
   112         }
       
   113     
       
   114     // Don't set the title pane text.
       
   115     TRAP_IGNORE( SetTitlePaneL( EFalse ) );
       
   116   
       
   117     if(iMultiCalUiDialogModel)
       
   118         {
       
   119         delete iMultiCalUiDialogModel;
       
   120         iMultiCalUiDialogModel = NULL;
       
   121         }
       
   122     
       
   123     iColorUidArray.Reset();
       
   124     
       
   125     delete iDesArray;
       
   126     
       
   127     delete iBgContext;
       
   128 
       
   129     TRACE_EXIT_POINT
       
   130     }
       
   131 
       
   132 // ----------------------------------------------------------------------------
       
   133 // CMultiCalUiDialogImpl::ConstructL
       
   134 // (other items were commented in a header).
       
   135 // ----------------------------------------------------------------------------
       
   136 //
       
   137 void CMultiCalUiDialogImpl::ConstructL(const RPointerArray<CCalEntry>& aCalEntries)
       
   138     {
       
   139     TRACE_ENTRY_POINT
       
   140     
       
   141     TFileName fileName;
       
   142     // Get the complate path of the DLL from where it is currently loaded
       
   143     Dll::FileName( fileName );
       
   144     
       
   145     TFileName resFile;
       
   146     TFileName iconFile;
       
   147     
       
   148     // Append the Drive letters ex., Z: or C:
       
   149     resFile.Append(fileName.Mid(0,2));
       
   150     resFile.Append(KDC_RESOURCE_FILES_DIR);
       
   151     resFile.Append(KResourceFile);
       
   152     
       
   153     BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(), resFile );
       
   154     
       
   155     iResourceFileOffset = CEikonEnv::Static()->AddResourceFileL( resFile );
       
   156     
       
   157     iIconFile.Append(fileName.Mid(0,2));
       
   158     iIconFile.Append(KDC_APP_BITMAP_DIR);
       
   159     iIconFile.Append(KIconFile);
       
   160     
       
   161     //iIconFile = ((CEikAppUi*)CCoeEnv::Static()->AppUi())->Application()->BitmapStoreName();
       
   162     
       
   163     iMultiCalUiDialogModel = CMultiCalUiDialogModel::NewL();
       
   164     
       
   165     iMultiCalUiDialogModel->SetCalEntry(aCalEntries); 
       
   166     
       
   167     CAknDialog::ConstructL (R_CALENDB_LIST_MENUBAR);
       
   168     TRACE_EXIT_POINT
       
   169     }
       
   170 
       
   171 // ----------------------------------------------------------------------------
       
   172 // CMultiCalUiDialogImpl::LaunchCalenDbListDialogL
       
   173 // (other items were commented in a header).
       
   174 // ----------------------------------------------------------------------------
       
   175 //
       
   176 TInt CMultiCalUiDialogImpl::LaunchCalenDbListDialogL()
       
   177     {
       
   178     TRACE_ENTRY_POINT
       
   179     
       
   180     TInt returnVal( KErrNone );
       
   181     
       
   182     returnVal =  CAknDialog::ExecuteLD( R_CALENDB_LIST_DIALOG );
       
   183     
       
   184     TRACE_EXIT_POINT
       
   185     return returnVal;
       
   186     }
       
   187 
       
   188 // ----------------------------------------------------------------------------
       
   189 // CMultiCalUiDialogImpl::FocusChanged
       
   190 // (other items were commented in a header).
       
   191 // ----------------------------------------------------------------------------
       
   192 //
       
   193 void CMultiCalUiDialogImpl::FocusChanged( TDrawNow aDrawNow )
       
   194     {
       
   195     TRACE_ENTRY_POINT;
       
   196     
       
   197     CAknDialog::FocusChanged( aDrawNow );    
       
   198     
       
   199     TRACE_EXIT_POINT;
       
   200     }
       
   201 
       
   202 // ----------------------------------------------------------------------------
       
   203 // CMultiCalUiDialogImpl::ConstructListL
       
   204 // (other items were commented in a header).  
       
   205 // ----------------------------------------------------------------------------
       
   206 //
       
   207 void CMultiCalUiDialogImpl::ConstructListL()
       
   208     {
       
   209     TRACE_ENTRY_POINT;
       
   210     
       
   211     if(iDesArray && iListBox)
       
   212         {
       
   213         return;
       
   214         }
       
   215 
       
   216     iDesArray = new (ELeave) CDesCArrayFlat(5);
       
   217     iListBox = new (ELeave) CCalenDbListbox(iColorUidArray);    
       
   218     iListBox->SetContainerWindowL( *this );
       
   219     iListBox->ConstructL(this, EAknListBoxSelectionList );
       
   220 
       
   221     //Create scroll bar
       
   222     iListBox->CreateScrollBarFrameL(ETrue);
       
   223     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   224             CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
       
   225 
       
   226     CTextListBoxModel* model = iListBox->Model();
       
   227     model->SetItemTextArray(iDesArray);
       
   228     model->SetOwnershipType(ELbmDoesNotOwnItemArray);
       
   229     
       
   230     iListBox->SetListBoxObserver( this );
       
   231     
       
   232     PrepareIconsL();
       
   233 
       
   234     iListBox->View()->SetListEmptyTextL( _L("No Items") );
       
   235 
       
   236     TRACE_EXIT_POINT;
       
   237     }
       
   238 
       
   239 // ----------------------------------------------------------------------------
       
   240 // CCalenMultipleDbUi::UpdateListboxL
       
   241 // (other items were commented in a header).
       
   242 // ----------------------------------------------------------------------------
       
   243 //
       
   244 void CMultiCalUiDialogImpl::UpdateListboxL()
       
   245     {
       
   246     TRACE_ENTRY_POINT;
       
   247     
       
   248     iListBox->View()->SetDisableRedraw( ETrue );
       
   249     iDesArray->Reset();
       
   250     iColorUidArray.Close();
       
   251     
       
   252     RPointerArray<CCalCalendarInfo>& calendarInfoArray = 
       
   253                                 iMultiCalUiDialogModel->GetCalendarInfoArray();
       
   254     
       
   255     if( calendarInfoArray.Count() > 0 )
       
   256         {
       
   257         iListBox->ItemDrawer()->ColumnData()->SetIconArray( iIconsList );
       
   258 
       
   259         for(TInt i = 0 ; i < calendarInfoArray.Count() ; i++)
       
   260             {
       
   261             TBuf<KMultiDbMaxLength> tempString;
       
   262             CCalCalendarInfo* calendarInfo = calendarInfoArray[i];
       
   263 
       
   264             TPtrC nameBuf = calendarInfo->NameL();
       
   265 
       
   266             //"%d\t%S\t%S\t%d"
       
   267             TBuf<10> icon;
       
   268             TInt iconIndex(1);
       
   269             icon.Format(KIconFormat,iconIndex);
       
   270             
       
   271             tempString.Append(icon);
       
   272            
       
   273             tempString.Append(KListSeparatorFormat);
       
   274             tempString.Append(nameBuf);
       
   275             tempString.Append(KListSeparatorFormat);
       
   276 
       
   277             HBufC* strTemp = NULL; 
       
   278             if(calendarInfo->Enabled())
       
   279                 {
       
   280                 strTemp = StringLoader::LoadLC(R_CALEN_DB_VISIBLE,iCoeEnv);
       
   281                 }
       
   282             else
       
   283                 {
       
   284                 strTemp = StringLoader::LoadLC(R_CALEN_DB_HIDDEN,iCoeEnv);
       
   285                 }
       
   286 
       
   287             tempString.Append(strTemp->Des());
       
   288             CleanupStack::PopAndDestroy(strTemp);
       
   289 
       
   290             tempString.Append(KListSeparatorFormat);
       
   291 
       
   292             //Collect color info to be used in itemdrawer for painting strip
       
   293             iColorUidArray.Append(calendarInfo->Color().Value());
       
   294             
       
   295             iDesArray->AppendL(tempString);
       
   296             }
       
   297         }
       
   298     
       
   299     iListBox->View()->SetDisableRedraw( EFalse );
       
   300     iListBox->HandleItemAdditionL(); //Update and draw listbox
       
   301 
       
   302     TRACE_EXIT_POINT;
       
   303     }
       
   304 
       
   305 // ----------------------------------------------------------------------------
       
   306 // CMultiCalUiDialogImpl::PrepareIconsL
       
   307 // (other items were commented in a header).
       
   308 // ----------------------------------------------------------------------------
       
   309 //
       
   310 void CMultiCalUiDialogImpl::PrepareIconsL()
       
   311     {
       
   312     TRACE_ENTRY_POINT;
       
   313     
       
   314     iIconsList = CreateIconsL();
       
   315     
       
   316     TRACE_EXIT_POINT;
       
   317     }
       
   318 
       
   319 // ----------------------------------------------------------------------------
       
   320 // CMultiCalUiDialogImpl::GetIconL
       
   321 // (other items were commented in a header).
       
   322 // ----------------------------------------------------------------------------
       
   323 //
       
   324 CGulIcon* CMultiCalUiDialogImpl::GetIconL( TCalenListDbIcons aIndex )
       
   325     {
       
   326     TRACE_ENTRY_POINT;
       
   327     
       
   328     CGulIcon* icon;
       
   329     TRgb nonSkinColor = AKN_LAF_COLOR(215);
       
   330     CFbsBitmap* bitmap = NULL;
       
   331     CFbsBitmap* mask = NULL;
       
   332     
       
   333     switch( aIndex )
       
   334         {
       
   335         case ECalenListDbIconUnMarked:
       
   336             {
       
   337             icon = CreateBitmapSkinnedIconL( 
       
   338                     KAknsIIDQgnPropCheckboxOn,
       
   339                     iIconFile,
       
   340                     EMbmMulticaluidialogQgn_prop_checkbox_off,
       
   341                     EMbmMulticaluidialogQgn_prop_checkbox_off_mask );
       
   342             }
       
   343             break;
       
   344 
       
   345         case ECalenListDbIconMarked:
       
   346             {
       
   347             icon = CreateBitmapSkinnedIconL( 
       
   348                                 KAknsIIDQgnPropCheckboxOn,
       
   349                                 iIconFile, 
       
   350                                 EMbmMulticaluidialogQgn_prop_checkbox_on,
       
   351                                 EMbmMulticaluidialogQgn_prop_checkbox_on_mask );
       
   352             }
       
   353             break;
       
   354             
       
   355         default:
       
   356             {
       
   357             icon = CGulIcon::NewL( bitmap, mask );
       
   358             }
       
   359             break;
       
   360         }
       
   361 
       
   362     TRACE_EXIT_POINT;
       
   363     return icon;
       
   364     }
       
   365 
       
   366 // ----------------------------------------------------------------------------
       
   367 // CMultiCalUiDialogImpl::CreateIconsL
       
   368 // (other items were commented in header.)
       
   369 // ----------------------------------------------------------------------------
       
   370 //
       
   371 CAknIconArray* CMultiCalUiDialogImpl::CreateIconsL()
       
   372     {
       
   373     TRACE_ENTRY_POINT;
       
   374     const TInt iconCount( 2 );
       
   375     CAknIconArray* icons = new(ELeave) CAknIconArray( iconCount );
       
   376     CleanupStack::PushL( icons );
       
   377     icons->SetReserveL( iconCount );
       
   378 
       
   379     for( TInt i=0; i<iconCount; ++i )
       
   380         {
       
   381         icons->AppendL( GetIconL( ECalenListDbIconMarked ) );
       
   382         icons->AppendL( GetIconL( ECalenListDbIconUnMarked ) );
       
   383         }
       
   384     CleanupStack::Pop( icons );
       
   385     TRACE_EXIT_POINT;
       
   386     return icons;
       
   387     }
       
   388 
       
   389 // -----------------------------------------------------------------------------
       
   390 // CMultiCalUiDialogImpl::CreateBitmapSkinnedIconL
       
   391 // (other items were commented in a header).
       
   392 // -----------------------------------------------------------------------------
       
   393 //
       
   394 CGulIcon* CMultiCalUiDialogImpl::CreateBitmapSkinnedIconL(const TAknsItemID& aSkinIconId,
       
   395                         const TDesC& aFilename,
       
   396                         TInt aNormalIconId,
       
   397                         TInt aNormalMaskId) const
       
   398     {
       
   399     TRACE_ENTRY_POINT;
       
   400     
       
   401     CFbsBitmap* bitmap = NULL;
       
   402     CFbsBitmap* mask = NULL;
       
   403     
       
   404     AknsUtils::CreateIconLC(AknsUtils::SkinInstance(), aSkinIconId,
       
   405                 bitmap, mask, 
       
   406                 aFilename, aNormalIconId, aNormalMaskId);
       
   407     
       
   408     CGulIcon* icon = CGulIcon::NewL(bitmap, mask);
       
   409     
       
   410     // Ownership of bitmap and mask transferred
       
   411     CleanupStack::Pop(2); // bitmap, mask
       
   412     
       
   413     TRACE_EXIT_POINT;
       
   414     return icon;
       
   415     }
       
   416 
       
   417 // -----------------------------------------------------------------------------
       
   418 // CMultiCalUiDialogImpl::MarkUnmarkCalendarL
       
   419 // (other items were commented in a header).
       
   420 // -----------------------------------------------------------------------------
       
   421 //
       
   422 void CMultiCalUiDialogImpl::MarkUnmarkCalendarL()
       
   423     {
       
   424     TRACE_ENTRY_POINT
       
   425     
       
   426     TInt index = iListBox->CurrentItemIndex();
       
   427     
       
   428     TBool status = EFalse;
       
   429     status = iMultiCalUiDialogModel->GetCalendarStatus(index);
       
   430     
       
   431     if(status)
       
   432         {
       
   433         status = EFalse;
       
   434         }
       
   435     else
       
   436         {
       
   437         status = ETrue;
       
   438         }
       
   439     
       
   440     iMultiCalUiDialogModel->SetCalendarStatus(index,status);
       
   441     
       
   442     TPtrC indexText = iDesArray->MdcaPoint(index);
       
   443     HBufC* formatText = indexText.AllocLC();
       
   444     TPtr modified = formatText->Des();
       
   445     modified[0] = status ? '0' : '1';
       
   446     
       
   447     indexText.Set(modified);
       
   448     iDesArray->Delete(index);
       
   449     iDesArray->InsertL(index,indexText);
       
   450     CleanupStack::PopAndDestroy(formatText);
       
   451     
       
   452     iListBox->RedrawItem(index);
       
   453     UpdateCbaL();
       
   454     
       
   455     TRACE_EXIT_POINT
       
   456     }
       
   457 
       
   458 // ----------------------------------------------------------------------------
       
   459 // CMultiCalUiDialogImpl::UpdateCbaL
       
   460 // (other items were commented in header.)
       
   461 // ----------------------------------------------------------------------------
       
   462 //
       
   463 void CMultiCalUiDialogImpl::UpdateCbaL()
       
   464     {    
       
   465     TRACE_ENTRY_POINT;
       
   466     CEikButtonGroupContainer&  cba = ButtonGroupContainer ();    
       
   467     
       
   468     if(!iMultiCalUiDialogModel->MarkedCalendarsCount())
       
   469         {
       
   470         cba.MakeCommandVisible( EAknSoftkeyOptions, EFalse );
       
   471         }
       
   472     else
       
   473         {
       
   474         cba.MakeCommandVisible( EAknSoftkeyOptions, ETrue );
       
   475         }
       
   476     cba.DrawNow(); 
       
   477     
       
   478     TRACE_EXIT_POINT;
       
   479     }
       
   480 
       
   481 // ----------------------------------------------------------------------------
       
   482 // CMultiCalUiDialogImpl::SetTitlePaneL
       
   483 // (other items were commented in header.)
       
   484 // ----------------------------------------------------------------------------
       
   485 //
       
   486 void CMultiCalUiDialogImpl::SetTitlePaneL( TBool aCurrentState )
       
   487     {
       
   488     TRACE_ENTRY_POINT;
       
   489     CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane();
       
   490 
       
   491     // Set empty navi pane label
       
   492     iNaviContainer = static_cast<CAknNavigationControlContainer*>(
       
   493                                  sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
   494     iNaviContainer->PushDefaultL();
       
   495 
       
   496    // Set title text
       
   497     CAknTitlePane* tp = static_cast<CAknTitlePane*>(
       
   498                                  sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   499 
       
   500     if( aCurrentState )
       
   501         {
       
   502         iTitlepaneText = ( *tp->Text() ); 
       
   503         HBufC* titleText = StringLoader::LoadLC( R_CALEN_DB_LIST_TITLE , iCoeEnv );
       
   504         tp->SetTextL( *titleText );  
       
   505         CleanupStack::PopAndDestroy( titleText );
       
   506         }
       
   507     else
       
   508         {
       
   509         tp->SetTextL(iTitlepaneText);
       
   510         }
       
   511     TRACE_EXIT_POINT;
       
   512     }
       
   513 
       
   514 // ----------------------------------------------------------------------------
       
   515 // CMultiCalUiDialogImpl::DynInitMenuPaneL
       
   516 // (other items were commented in header.)
       
   517 // ----------------------------------------------------------------------------
       
   518 //
       
   519 void CMultiCalUiDialogImpl::DynInitMenuPaneL( TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/ )
       
   520     {
       
   521     TRACE_ENTRY_POINT;
       
   522     
       
   523      
       
   524     TRACE_EXIT_POINT;  
       
   525     }
       
   526 
       
   527 // ----------------------------------------------------------------------------
       
   528 // CMultiCalUiDialogImpl::ProcessCommandL
       
   529 // (other items were commented in header.)
       
   530 // ----------------------------------------------------------------------------
       
   531 //
       
   532 void  CMultiCalUiDialogImpl::ProcessCommandL( TInt aCommandId )
       
   533     {
       
   534     TRACE_ENTRY_POINT;
       
   535     
       
   536     CAknDialog::ProcessCommandL(aCommandId);
       
   537     
       
   538     switch(aCommandId)
       
   539         {
       
   540         case EAknSoftkeyOptions:
       
   541         case EAknSoftkeyUnmark:
       
   542             {
       
   543             MarkUnmarkCalendarL();
       
   544             }
       
   545             break;
       
   546             
       
   547         default:
       
   548             {
       
   549             // No implementation yet.
       
   550             }
       
   551             break;
       
   552         }
       
   553     
       
   554     TRACE_EXIT_POINT;
       
   555     }
       
   556 
       
   557 // ----------------------------------------------------------------------------
       
   558 // CMultiCalUiDialogImpl::OfferKeyEventL
       
   559 // (other items were commented in header.) 
       
   560 // ----------------------------------------------------------------------------
       
   561 //
       
   562 TKeyResponse CMultiCalUiDialogImpl::OfferKeyEventL(const TKeyEvent& aKeyEvent,
       
   563                                                                      TEventCode aType)
       
   564     { 
       
   565     
       
   566     TRACE_ENTRY_POINT;
       
   567     TKeyResponse exitCode(EKeyWasNotConsumed);
       
   568     
       
   569     if(aType == EEventKey )
       
   570         {
       
   571         if( aKeyEvent.iCode == EKeyEscape )
       
   572             {
       
   573             TryExitL( EKeyEscape );
       
   574             return exitCode; 
       
   575             }
       
   576         else if(aType == EKeyOK)
       
   577             {
       
   578             MarkUnmarkCalendarL();
       
   579             }
       
   580         else if(aKeyEvent.iCode == EKeyBackspace)
       
   581             {
       
   582             return exitCode;
       
   583             }
       
   584         else 
       
   585             {
       
   586             exitCode = EKeyWasConsumed;
       
   587             iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   588 
       
   589             // Draw because pressing up/down means we have to redraw the backgrouns skin.
       
   590             DrawDeferred();
       
   591             }
       
   592         }
       
   593     TRACE_EXIT_POINT;
       
   594     return exitCode;
       
   595     }
       
   596 
       
   597 // ----------------------------------------------------------------------------
       
   598 // CMultiCalUiDialogImpl::HandlePointerEventL
       
   599 // (other items were commented in header.) 
       
   600 // ----------------------------------------------------------------------------
       
   601 //
       
   602 void CMultiCalUiDialogImpl::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
   603     {
       
   604     // single click 
       
   605     TRACE_ENTRY_POINT;
       
   606     
       
   607     if( !AknLayoutUtils::PenEnabled() )
       
   608            {
       
   609            return;
       
   610            }
       
   611       TInt index = iListBox->CurrentItemIndex();
       
   612       iListBox->HandlePointerEventL(aPointerEvent);      
       
   613        
       
   614     TRACE_EXIT_POINT;
       
   615     }
       
   616 
       
   617 // ----------------------------------------------------------------------------
       
   618 // CMultiCalUiDialogImpl::OkToExitL
       
   619 // (other items were commented in header.)
       
   620 // ----------------------------------------------------------------------------
       
   621 //
       
   622 TBool CMultiCalUiDialogImpl::OkToExitL( TInt aButtonId )
       
   623     {
       
   624     TRACE_ENTRY_POINT;
       
   625     
       
   626     TBool okExit = EFalse;
       
   627     
       
   628     switch(aButtonId)
       
   629         {   
       
   630         case EKeyEscape:
       
   631         case EAknSoftkeyCancel:
       
   632             {
       
   633             okExit = ETrue;
       
   634             }
       
   635             break;           
       
   636  
       
   637         case EAknSoftkeyOk:
       
   638         case ECalenSelectCmdOk:    
       
   639             {
       
   640             TInt index = iListBox->CurrentItemIndex();
       
   641             
       
   642             if(!iMultiCalUiDialogModel->MarkedCalendarsCount())
       
   643                 {
       
   644                 iMultiCalUiDialogModel->SetCalendarStatus(index,ETrue);
       
   645                 }
       
   646             
       
   647             iMultiCalUiDialogModel->StoreCalEntryL();
       
   648             
       
   649             okExit = ETrue;
       
   650             }
       
   651             break;
       
   652 
       
   653         default:
       
   654             {
       
   655             okExit = CAknDialog::OkToExitL(aButtonId);
       
   656             }
       
   657             break;
       
   658         }
       
   659     TRACE_EXIT_POINT;
       
   660     
       
   661     return okExit;
       
   662     }
       
   663 
       
   664 // ----------------------------------------------------------------------------
       
   665 // CMultiCalUiDialogImpl::SizeChanged
       
   666 // Set the rect to dialog and listbox
       
   667 // ----------------------------------------------------------------------------
       
   668 //
       
   669 void CMultiCalUiDialogImpl::SizeChanged()
       
   670     {
       
   671     TRACE_ENTRY_POINT;
       
   672     
       
   673     CAknDialog::SizeChanged();
       
   674     
       
   675     TRect rect = iRect = Rect();
       
   676     
       
   677     if( iBgContext )
       
   678         {
       
   679         iBgContext->SetRect( rect );
       
   680         }
       
   681     
       
   682     if( iListBox )
       
   683         {
       
   684         TInt orientation = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
       
   685         TAknLayoutRect application_window;
       
   686         
       
   687         if( ( !orientation ) && AknLayoutUtils::PenEnabled() )
       
   688             {
       
   689             TRect appWindow;
       
   690             TAknLayoutRect application_window;
       
   691             AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow, 
       
   692                                                appWindow );
       
   693             application_window.LayoutRect( 
       
   694                     appWindow, 
       
   695                 AknLayoutScalable_Apps::application_window().LayoutLine() ); 
       
   696                 
       
   697             // Find the size of the main pane.
       
   698             TAknLayoutRect main_pane;                    
       
   699                                 
       
   700             main_pane.LayoutRect( 
       
   701             application_window.Rect(), 
       
   702             AknLayoutScalable_Apps::main_pane( orientation ).LayoutLine() );
       
   703             
       
   704             TRect listboxRect;
       
   705             listboxRect.SetWidth( main_pane.Rect().Width() );
       
   706             listboxRect.SetHeight( main_pane.Rect().Height() );
       
   707             iListBox->SetRect( listboxRect );
       
   708             }
       
   709         else
       
   710             {
       
   711             iListBox->SetRect( rect );
       
   712             }
       
   713         }
       
   714     
       
   715     TRACE_EXIT_POINT;
       
   716     }
       
   717 
       
   718 // ----------------------------------------------------------------------------
       
   719 // CMultiCalUiDialogImpl::ComponentControl
       
   720 // (other items were commented in a header).
       
   721 // ----------------------------------------------------------------------------
       
   722 //
       
   723 CCoeControl* CMultiCalUiDialogImpl::ComponentControl( TInt /*aIndex*/) const
       
   724     {
       
   725     TRACE_ENTRY_POINT;
       
   726     
       
   727     if(iListBox)
       
   728         {
       
   729         TRACE_EXIT_POINT;
       
   730         return iListBox;
       
   731         }
       
   732     
       
   733     TRACE_EXIT_POINT;   
       
   734     return NULL;
       
   735     }
       
   736 
       
   737 // ----------------------------------------------------------------------------
       
   738 // CMultiCalUiDialogImpl::CountComponentControls
       
   739 // (other items were commented in a header).
       
   740 // ----------------------------------------------------------------------------
       
   741 //
       
   742 TInt CMultiCalUiDialogImpl::CountComponentControls() const
       
   743     {
       
   744     TRACE_ENTRY_POINT;
       
   745     
       
   746     if(iListBox)
       
   747         {
       
   748         TRACE_EXIT_POINT;
       
   749         return 1;
       
   750         }
       
   751     
       
   752     TRACE_EXIT_POINT;
       
   753     return 0;
       
   754     }
       
   755 
       
   756 // ----------------------------------------------------------------------------
       
   757 // CMultiCalUiDialogImpl::PreLayoutDynInitL
       
   758 // (other items were commented in a header).
       
   759 // ----------------------------------------------------------------------------
       
   760 //
       
   761 void  CMultiCalUiDialogImpl::PreLayoutDynInitL()
       
   762     {
       
   763     TRACE_ENTRY_POINT;
       
   764     iBgContext = 
       
   765     CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain,iRect,ETrue );
       
   766     
       
   767     SetTitlePaneL( ETrue );
       
   768     ConstructListL();
       
   769     UpdateListboxL();
       
   770     //UpdateCbaL();
       
   771     
       
   772     
       
   773     TInt orientation = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;      
       
   774     if( AknLayoutUtils::PenEnabled() )   
       
   775         {
       
   776         // Find the size of the main pane.
       
   777         // Find the application window
       
   778         TRect appWindow;
       
   779         TAknLayoutRect application_window;
       
   780         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow, 
       
   781                                            appWindow );
       
   782         application_window.LayoutRect( 
       
   783                 appWindow, 
       
   784             AknLayoutScalable_Apps::application_window().LayoutLine() ); 
       
   785             
       
   786         // Find the size of the main pane.
       
   787         TAknLayoutRect main_pane;                    
       
   788                             
       
   789         main_pane.LayoutRect( 
       
   790         application_window.Rect(), 
       
   791         AknLayoutScalable_Apps::main_pane( orientation ).LayoutLine() );
       
   792         
       
   793         TRect listboxRect;
       
   794         listboxRect.SetWidth( main_pane.Rect().Width() );
       
   795         listboxRect.SetHeight( main_pane.Rect().Height() );
       
   796         iListBox->SetRect( listboxRect );
       
   797         }
       
   798     
       
   799     TRACE_EXIT_POINT;
       
   800     }
       
   801 
       
   802 // ----------------------------------------------------------------------------
       
   803 // CMultiCalUiDialogImpl::PostLayoutDynInitL
       
   804 // (other items were commented in a header).
       
   805 // ----------------------------------------------------------------------------
       
   806 //
       
   807 void CMultiCalUiDialogImpl::PostLayoutDynInitL()
       
   808     {
       
   809     TRACE_ENTRY_POINT;        
       
   810     UpdateCbaL();    
       
   811     TRACE_EXIT_POINT;
       
   812     }
       
   813 
       
   814 // ----------------------------------------------------------------------------
       
   815 // CMultiCalUiDialogImpl::MopSupplyObject
       
   816 // (other items were commented in a header).
       
   817 // ----------------------------------------------------------------------------
       
   818 //
       
   819 TTypeUid::Ptr CMultiCalUiDialogImpl::MopSupplyObject(TTypeUid aId)
       
   820     {
       
   821     TRACE_ENTRY_POINT;
       
   822     
       
   823     if(aId.iUid == MAknsControlContext::ETypeId )
       
   824         {
       
   825         MAknsControlContext* cc = iBgContext;
       
   826         if ( cc )
       
   827             {
       
   828             return MAknsControlContext::SupplyMopObject( aId, cc );
       
   829             }
       
   830         }
       
   831     
       
   832     TRACE_EXIT_POINT;
       
   833     
       
   834     return CAknDialog::MopSupplyObject( aId );
       
   835     }
       
   836 
       
   837 // ----------------------------------------------------------------------------
       
   838 // CMultiCalUiDialogImpl::HandleResourceChange
       
   839 // (other items were commented in a header).
       
   840 // ----------------------------------------------------------------------------
       
   841 //
       
   842 void CMultiCalUiDialogImpl::HandleResourceChange(TInt aType)
       
   843     {
       
   844     TRACE_ENTRY_POINT;
       
   845     
       
   846     if ( aType == KAknsMessageSkinChange || aType == KEikDynamicLayoutVariantSwitch )
       
   847         {
       
   848         SizeChanged();
       
   849         TRAP_IGNORE(UpdateListboxL());
       
   850         }
       
   851     
       
   852     CAknDialog::HandleResourceChange( aType );
       
   853     TRACE_EXIT_POINT;
       
   854     }
       
   855 
       
   856 // ----------------------------------------------------------------------------
       
   857 // CMultiCalUiDialogImpl::Draw
       
   858 // (other items were commented in a header).
       
   859 // ----------------------------------------------------------------------------
       
   860 //
       
   861 void CMultiCalUiDialogImpl::Draw(const TRect& aRect) const
       
   862     {
       
   863     TRACE_ENTRY_POINT;
       
   864     
       
   865     CWindowGc& gc = SystemGc();
       
   866     TRect mainPane;
       
   867     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane );
       
   868     TRect zerodRect( TPoint(0, 0), mainPane.Size() );
       
   869     iBgContext->SetRect( zerodRect );
       
   870     iBgContext->SetParentPos( mainPane.iTl );
       
   871     AknsDrawUtils::Background( AknsUtils::SkinInstance(), iBgContext, this, gc, aRect );
       
   872     
       
   873     TRACE_EXIT_POINT;
       
   874     }
       
   875 
       
   876 // ----------------------------------------------------------------------------
       
   877 // CMultiCalUiDialogImpl::HandleListBoxEventL 
       
   878 // (other items were commented in a header).
       
   879 // ----------------------------------------------------------------------------
       
   880 //
       
   881 void CMultiCalUiDialogImpl::HandleListBoxEventL(CEikListBox* /*aListBox */,
       
   882         TListBoxEvent aEventType)
       
   883     {
       
   884     switch (aEventType)
       
   885         {
       
   886         //Single click integration
       
   887         case EEventItemSingleClicked:
       
   888         case EEventEnterKeyPressed:
       
   889             {
       
   890             const TInt index(iListBox->CurrentItemIndex());
       
   891             if (index != KErrNotFound)
       
   892                 {
       
   893                 MarkUnmarkCalendarL();
       
   894                 }
       
   895             }
       
   896             break;
       
   897         }
       
   898     }
       
   899 
       
   900 
       
   901 // ----------------------------------------------------------------------------
       
   902 // CMultiCalUiDialogImpl::CallBackFor select
       
   903 // (other items were commented in a header).
       
   904 // ----------------------------------------------------------------------------
       
   905 //
       
   906 TInt CMultiCalUiDialogImpl::DoAsyncExit(TAny* aPtr)
       
   907     {
       
   908     TRACE_ENTRY_POINT
       
   909     CMultiCalUiDialogImpl* self = static_cast<CMultiCalUiDialogImpl*>(aPtr);
       
   910     self->TryExitL(self->iAsyncExitCmd);
       
   911     TRACE_EXIT_POINT
       
   912     return 0;
       
   913     }
       
   914 
       
   915 // End of file.