uifw/EikStd/dlgsrc/EIKDPSEL.CPP
changeset 0 2f259fa3e83a
child 18 fcdfafb36fe7
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 1999 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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <barsread.h>
       
    20 #include <eikenv.h>
       
    21 #include <eikappui.h>
       
    22 #include <eikdpsel.h>
       
    23 #include <eikdpage.h>
       
    24 #include <eikdialg.h>
       
    25 
       
    26 #include <AknTasHook.h> // for testability hooks
       
    27 // Include files for status pane.
       
    28 // These are from AVKON which introduces undesirable dependancies.
       
    29 #include <eikspane.h>
       
    30 #include <aknconsts.h>
       
    31 #include <akntitle.h>
       
    32 #include <akncontext.h>
       
    33 #include <akntabgrp.h>
       
    34 #include <aknnavi.h>
       
    35 #include <aknnavide.h>
       
    36 #include <akntabgrp.h>
       
    37 #include <avkon.hrh>
       
    38 #include <eikcba.h>
       
    39 // SERIES60 form laf includes
       
    40 #include <AknUtils.h>
       
    41 #include <avkon.rsg>
       
    42 //<SKIN>
       
    43 #include <AknsDrawUtils.h>
       
    44 #include <AknsUtils.h>
       
    45 #include <AknsListBoxBackgroundControlContext.h>
       
    46 #include "eikdialogext.h"
       
    47 //
       
    48 // Constants
       
    49 //
       
    50 
       
    51 #define KBorderType TGulBorder::EDeepRaisedWithOutline
       
    52 #define KFirstTab 0
       
    53 
       
    54 
       
    55 //
       
    56 // CEikTabPreStore.
       
    57 //
       
    58 
       
    59 class CEikTabPreStore : public CBase
       
    60     {
       
    61 public:	    
       
    62     // Takes ownership of aTabText and aBitmapFile
       
    63     CEikTabPreStore(TInt aPageId, HBufC* aTabText, HBufC* aBitmapFile, TInt aBitmapId, TInt aMaskId);
       
    64     ~CEikTabPreStore();
       
    65 
       
    66     TInt PageId() const;
       
    67     HBufC* TabText() const;
       
    68     HBufC* BitmapFile() const;
       
    69     TInt BitmapId() const;
       
    70     TInt MaskId() const;
       
    71 
       
    72 private:
       
    73     TInt iPageId;
       
    74     HBufC* iTabText;
       
    75     HBufC* iBitmapFile;
       
    76     TInt iBitmapId;
       
    77     TInt iMaskId;
       
    78     
       
    79     };
       
    80 
       
    81 CEikTabPreStore::CEikTabPreStore(
       
    82     TInt aPageId, HBufC* aTabText, HBufC* aBitmapFile, TInt aBitmapId, TInt aMaskId )
       
    83     : iPageId( aPageId ), 
       
    84       iTabText( aTabText ), 
       
    85       iBitmapFile( aBitmapFile ), 
       
    86       iBitmapId( aBitmapId ), 
       
    87       iMaskId( aMaskId )
       
    88     {
       
    89     }
       
    90     
       
    91 CEikTabPreStore::~CEikTabPreStore()
       
    92     {
       
    93     delete iTabText;
       
    94     delete iBitmapFile;
       
    95     }
       
    96 
       
    97 TInt CEikTabPreStore::PageId() const
       
    98     {
       
    99     return iPageId;
       
   100     }
       
   101     
       
   102 HBufC* CEikTabPreStore::TabText() const
       
   103     {
       
   104     return iTabText;
       
   105     }
       
   106     
       
   107 HBufC* CEikTabPreStore::BitmapFile() const
       
   108     {
       
   109     return iBitmapFile;
       
   110     }
       
   111     
       
   112 TInt CEikTabPreStore::BitmapId() const
       
   113     {
       
   114     return iBitmapId;
       
   115     }
       
   116     
       
   117 TInt CEikTabPreStore::MaskId() const
       
   118     {
       
   119     return iMaskId;
       
   120     }
       
   121 
       
   122 //
       
   123 // CEikDialogPageSelector.
       
   124 //
       
   125 
       
   126 CEikDialogPageSelector::~CEikDialogPageSelector()
       
   127     {
       
   128     AKNTASHOOK_REMOVE();
       
   129     AknsUtils::DeregisterControlPosition(this);
       
   130     delete iPageContainer;
       
   131     delete iTabPreStore;
       
   132 
       
   133     DestroyTabContainer() ;
       
   134 
       
   135     }
       
   136 
       
   137 CEikDialogPageSelector* CEikDialogPageSelector::NewL(const CCoeControl& aParent,CEikDialog* aDialog)
       
   138     {
       
   139     CEikDialogPageSelector* self=CEikDialogPageSelector::NewLC(aParent,aDialog);
       
   140     CleanupStack::Pop();
       
   141     return self;
       
   142     }
       
   143 
       
   144 CEikDialogPageSelector* CEikDialogPageSelector::NewLC(const CCoeControl& aParent,CEikDialog* aDialog)
       
   145     {
       
   146     CEikDialogPageSelector* self=new(ELeave) CEikDialogPageSelector;
       
   147     CleanupStack::PushL(self);
       
   148     self->SetDialg(aDialog);
       
   149     self->SetContainerWindowL(aParent); // Not window owning
       
   150     self->ConstructL(aDialog);
       
   151     AKNTASHOOK_ADDL( self, "CEikDialogPageSelector" );
       
   152     return self;
       
   153     }
       
   154 
       
   155 CEikDialogPageSelector* CEikDialogPageSelector::NewL(const CCoeControl& aParent,TResourceReader& aReader,CEikDialog* aDialog)
       
   156     {
       
   157     CEikDialogPageSelector* self=CEikDialogPageSelector::NewLC(aParent,aReader,aDialog);
       
   158     CleanupStack::Pop();
       
   159     return self;
       
   160     }
       
   161 
       
   162 CEikDialogPageSelector* CEikDialogPageSelector::NewLC(const CCoeControl& aParent,TResourceReader& aReader,CEikDialog* aDialog)
       
   163     {
       
   164     CEikDialogPageSelector* self=new(ELeave) CEikDialogPageSelector;
       
   165     CleanupStack::PushL(self);
       
   166     self->SetDialg(aDialog);
       
   167     self->SetContainerWindowL(aParent);
       
   168     self->ConstructFromResourceL(aReader,aDialog);
       
   169     AKNTASHOOK_ADDL( self, "CEikDialogPageSelector" );
       
   170     return self;
       
   171     }
       
   172 
       
   173 CEikDialogPageSelector::CEikDialogPageSelector()
       
   174     {
       
   175     iBorder.SetType(TGulBorder::ENone);
       
   176     }
       
   177 
       
   178 void CEikDialogPageSelector::ConstructL(MEikDialogPageObserver* aPageObserver)
       
   179     {
       
   180     iContext=this;
       
   181     iPageContainer=CEikDialogPageContainer::NewL(*this,aPageObserver);
       
   182     iPageContainer->SetObserver(this);
       
   183     RegisterPageSelectorWithPageContainer();
       
   184     }
       
   185 
       
   186 void CEikDialogPageSelector::CreatePreStoredTabL()
       
   187     {
       
   188     __ASSERT_ALWAYS( iTabContainer, User::Invariant() );
       
   189     
       
   190     // Create the first tab (if pre-stored) 
       
   191     if( iTabPreStore )
       
   192         {
       
   193         if (iTabPreStore->TabText() && iTabContainer)
       
   194             {
       
   195             // If the first tab contains text, tab layout with 2 long tabs is used
       
   196             // by default instead of 2 short tabs.           
       
   197             iTabContainer->SetTabFixedWidthL(KTabWidthWithTwoLongTabs);
       
   198             iFirstTabContainsText = ETrue;
       
   199             }
       
   200         if( ( iTabPreStore->BitmapFile() ) && 
       
   201             ( iTabPreStore->BitmapId() != -1 ) )
       
   202             {
       
   203             // Bitmapped tab..
       
   204             TFileName fileName( *(iTabPreStore->BitmapFile() ) );
       
   205             CompleteWithAppPath(fileName);                
       
   206 
       
   207             CFbsBitmap* bitmap;
       
   208             if( iTabPreStore->MaskId() != -1 )
       
   209                 {
       
   210                 // ..with mask..
       
   211                 CFbsBitmap* mask;
       
   212                 AknIconUtils::CreateIconLC( 
       
   213                     bitmap, 
       
   214                     mask, 
       
   215                     fileName,
       
   216                     iTabPreStore->BitmapId(), 
       
   217                     iTabPreStore->MaskId() );
       
   218                 
       
   219                 if( iTabPreStore->TabText() )
       
   220                     {
       
   221                     // ..and with text
       
   222                     iTabContainer->AddTabL(
       
   223                         iTabPreStore->PageId(),
       
   224                         *( iTabPreStore->TabText() ),
       
   225                         bitmap,
       
   226                         mask);
       
   227                     }
       
   228                 else                        
       
   229                     {
       
   230                     // ..and without text
       
   231                     iTabContainer->AddTabL(
       
   232                         iTabPreStore->PageId(),
       
   233                         bitmap,
       
   234                         mask);
       
   235                     }
       
   236 
       
   237                 // Note: ownership change at end of AddTabL
       
   238                 CleanupStack::Pop(); // bitmap
       
   239                 CleanupStack::Pop(); // mask
       
   240                 }
       
   241             else
       
   242                 {
       
   243                 // ..without mask..
       
   244                 bitmap = AknIconUtils::CreateIconL( fileName, iTabPreStore->BitmapId() );
       
   245                 CleanupStack::PushL( bitmap );
       
   246                 if( iTabPreStore->TabText() )
       
   247                     {
       
   248                     // ..and with text
       
   249                     iTabContainer->AddTabL(
       
   250                         iTabPreStore->PageId(),
       
   251                         *( iTabPreStore->TabText() ),
       
   252                         bitmap);
       
   253                     }
       
   254                 else
       
   255                     {
       
   256                     // ..and without text
       
   257                     iTabContainer->AddTabL(
       
   258                         iTabPreStore->PageId(),
       
   259                         bitmap);
       
   260                     }
       
   261 
       
   262                 // Note: ownership change at end of AddTabL
       
   263                 CleanupStack::Pop( bitmap );
       
   264                 }
       
   265             }
       
   266         else
       
   267             {
       
   268             if ( iTabPreStore->TabText() )
       
   269                 {
       
   270                 // Tab with text, no bitmap
       
   271                 iTabContainer->AddTabL( iTabPreStore->PageId(), *( iTabPreStore->TabText() ) );
       
   272                 }
       
   273             else
       
   274                 {
       
   275                 // Tab with no text, no bitmap.
       
   276                 iTabContainer->AddTabL( iTabPreStore->PageId(), KNullDesC );
       
   277                 }
       
   278             }
       
   279         }
       
   280         delete iTabPreStore;
       
   281         iTabPreStore = NULL;
       
   282     }   
       
   283 
       
   284 void CEikDialogPageSelector::CreateTabContainerL()
       
   285     {
       
   286     if( !iTabContainer )
       
   287         {
       
   288         // Get a Tab group from the status pane.
       
   289         CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane() ;
       
   290         if (statusPane)
       
   291             {
       
   292             CEikStatusPaneBase::TPaneCapabilities statusPaneCapabilities = statusPane->PaneCapabilities( TUid::Uid( EEikStatusPaneUidNavi ) ) ;
       
   293             if ( statusPaneCapabilities.IsPresent() && statusPaneCapabilities.IsAppOwned() )
       
   294                 {
       
   295                 iNaviContainer = (CAknNavigationControlContainer*)statusPane->ControlL( TUid::Uid( EEikStatusPaneUidNavi ))  ;
       
   296 
       
   297                 iNaviDecorator = iNaviContainer->CreateTabGroupL() ;
       
   298                 iTabContainer = (CAknTabGroup*)( iNaviDecorator->DecoratedControl() ) ;
       
   299                 iTabContainer->SetObserver(this);
       
   300 
       
   301                 STATIC_CAST(CCoeControl*,iNaviDecorator)->SetObserver(this); 
       
   302                 
       
   303                 CreatePreStoredTabL();
       
   304                 }
       
   305             }
       
   306         }
       
   307     }
       
   308 
       
   309 void CEikDialogPageSelector::ConstructFromResourceL(TResourceReader& aReader,MEikDialogPageObserver* aPageObserver)
       
   310     {
       
   311     ConstructL(aPageObserver);
       
   312 
       
   313     const TInt numPages=aReader.ReadInt16();
       
   314     for (TInt ii=0;ii<numPages;ii++)
       
   315         AddPageL(aReader);
       
   316 
       
   317     }
       
   318 
       
   319 void CEikDialogPageSelector::SetActivePageByIdL(TInt aPageId)
       
   320     {
       
   321     iPageContainer->SetActivePageByIdL(aPageId);
       
   322     if ( iTabContainer )
       
   323     iTabContainer->SetActiveTabById(aPageId);
       
   324     DrawNow();
       
   325     }
       
   326 
       
   327 void CEikDialogPageSelector::SetActivePageByIndexL(TInt aPageIndex)
       
   328     {
       
   329     iPageContainer->SetActivePageByIndexL(aPageIndex);
       
   330     if ( iTabContainer )
       
   331     iTabContainer->SetActiveTabByIndex(aPageIndex);
       
   332     DrawNow();
       
   333     }
       
   334 
       
   335 void CEikDialogPageSelector::ActivateFirstPageL()
       
   336     {
       
   337     delete iTabPreStore;
       
   338     iTabPreStore = NULL;
       
   339     
       
   340     if ( iTabContainer && iTabContainer->TabCount() < 2 )
       
   341         DestroyTabContainer() ;
       
   342     else
       
   343         {
       
   344         if ( iNaviContainer && iNaviDecorator )
       
   345             {
       
   346             iNaviContainer->Pop( iNaviDecorator );
       
   347             iNaviContainer->PushL( *iNaviDecorator ) ;
       
   348             iTabsVisible = ETrue ;
       
   349             }
       
   350         }
       
   351 
       
   352 #if defined(_DEBUG)
       
   353     iPageContainer->ActivateFirstPageL();
       
   354     if ( iTabContainer )
       
   355         iTabContainer->SetActiveTabByIndex( KFirstTab );  //<<-- AknTab
       
   356 #else
       
   357     iPageContainer->ActivateFirstPageL();
       
   358     if ( iTabContainer )
       
   359         iTabContainer->SetActiveTabByIndex( KFirstTab );  //<<-- AknTab
       
   360 #endif
       
   361     }
       
   362 
       
   363 void CEikDialogPageSelector::AddPageL(TResourceReader& aReader) 
       
   364     {
       
   365     TInt pageId;
       
   366     if( iPageContainer->NumPages() == 0 )
       
   367         {
       
   368         // This is the first page -- save tab details for delayed tab construction
       
   369         __ASSERT_ALWAYS( !iTabPreStore, User::Invariant() );
       
   370         
       
   371         pageId = aReader.ReadInt16(); // tab id
       
   372         HBufC* tabText = aReader.ReadHBufCL();
       
   373         CleanupStack::PushL( tabText );        
       
   374         HBufC* bitmapFile = aReader.ReadHBufCL();
       
   375         CleanupStack::PushL( bitmapFile );
       
   376         TInt bitmapId = aReader.ReadInt16();
       
   377         TInt maskId = aReader.ReadInt16();
       
   378         
       
   379         iTabPreStore = new (ELeave) CEikTabPreStore(
       
   380             pageId, tabText, bitmapFile, bitmapId, maskId );
       
   381             
       
   382         CleanupStack::Pop( bitmapFile );
       
   383         CleanupStack::Pop( tabText );
       
   384         }
       
   385     else
       
   386         {
       
   387         // Create tab container on second page
       
   388         CreateTabContainerL();
       
   389         
       
   390         if ( iTabContainer )
       
   391             {            
       
   392             pageId = iTabContainer->AddTabL(aReader); // Might need to read tab info from resource
       
   393             if (iFirstTabContainsText && iPageContainer->NumPages() == 2)
       
   394                 {
       
   395                 // Change the tab layout to 3 long tabs if there are 3 or more dialog pages.
       
   396                 iTabContainer->SetTabFixedWidthL(KTabWidthWithThreeLongTabs);                
       
   397                 }
       
   398             }
       
   399         else
       
   400             {
       
   401             pageId = aReader.ReadInt16(); // tab id
       
   402             aReader.ReadTPtrC(); // text
       
   403             aReader.ReadTPtrC(); // bmp filename
       
   404             aReader.ReadInt16(); // bmp id
       
   405             aReader.ReadInt16(); // bmp mask id
       
   406             }
       
   407         }
       
   408     
       
   409     TResourceReader pageReader;
       
   410 
       
   411     // This bit changed to check if  "lines=" exists
       
   412     // not correct yet as we still need to create a page!
       
   413     TInt32 pageReaderID = aReader.ReadInt32() ;
       
   414     if ( pageReaderID != 0 )
       
   415         {
       
   416         iCoeEnv->CreateResourceReaderLC( pageReader, pageReaderID ) ;
       
   417         iPageContainer->AddPageL(pageId,pageReader);
       
   418     CleanupStack::PopAndDestroy(); // pageReader
       
   419         }
       
   420     else
       
   421         iPageContainer->AddPageL( pageId ) ;
       
   422 
       
   423     AddFormToPageL(  pageId, aReader ) ;
       
   424     
       
   425     // read page flags, those are not used anywhere 
       
   426     aReader.ReadInt16();
       
   427     }
       
   428 
       
   429 void CEikDialogPageSelector::AddPageL(TInt aPageId,const TDesC& aTabText)
       
   430     {
       
   431     if( iPageContainer->NumPages() == 0 )
       
   432         {
       
   433         // This is the first page -- save tab details for delayed tab construction
       
   434         __ASSERT_ALWAYS( !iTabPreStore, User::Invariant() );
       
   435 
       
   436         HBufC* tabText = aTabText.AllocL();
       
   437         CleanupStack::PushL( tabText );
       
   438 
       
   439         iTabPreStore = new (ELeave) CEikTabPreStore(
       
   440             aPageId, tabText, NULL, -1, -1 );
       
   441             
       
   442         CleanupStack::Pop(tabText);
       
   443         }
       
   444     else
       
   445         {
       
   446         // Create tab container on second page
       
   447         CreateTabContainerL();
       
   448         
       
   449         if ( iTabContainer )
       
   450             iTabContainer->AddTabL(aPageId,aTabText);
       
   451         }
       
   452     
       
   453     iPageContainer->AddPageL(aPageId);
       
   454 
       
   455     if(iPageContainer->NumPages()>1)
       
   456         iBorder.SetType(KBorderType);
       
   457     }
       
   458 
       
   459 void CEikDialogPageSelector::AddPageL(TInt aPageId,const TDesC& aTabText,TResourceReader& aReader)
       
   460     {
       
   461     if( iPageContainer->NumPages() == 0 )
       
   462         {
       
   463         // This is the first page -- save tab details for delayed tab construction
       
   464         __ASSERT_ALWAYS( !iTabPreStore, User::Invariant() );
       
   465 
       
   466         HBufC* tabText = aTabText.AllocL();
       
   467         CleanupStack::PushL( tabText );
       
   468 
       
   469         iTabPreStore = new (ELeave) CEikTabPreStore(
       
   470             aPageId, tabText, NULL, -1, -1 );
       
   471 
       
   472         CleanupStack::Pop( tabText );
       
   473         }
       
   474     else
       
   475         {
       
   476         // Create tab container on second page
       
   477         CreateTabContainerL();
       
   478         
       
   479         if ( iTabContainer )
       
   480             iTabContainer->AddTabL(aPageId,aTabText);
       
   481         }
       
   482 
       
   483     iPageContainer->AddPageL(aPageId,aReader);
       
   484 
       
   485     AddFormToPageL(  aPageId, aReader ) ;
       
   486 
       
   487     if(iPageContainer->NumPages()>1)
       
   488         iBorder.SetType(KBorderType);
       
   489     }
       
   490 
       
   491 CEikCaptionedControl* CEikDialogPageSelector::Line(TInt aControlId) const
       
   492     {
       
   493     return iPageContainer->Line(aControlId);
       
   494     }
       
   495 
       
   496 CEikCaptionedControl* CEikDialogPageSelector::LineOrNull(TInt aControlId) const
       
   497     {
       
   498     return iPageContainer->LineOrNull(aControlId);
       
   499     }
       
   500 
       
   501 CEikCaptionedControl* CEikDialogPageSelector::CurrentLine() const
       
   502     {
       
   503     return iPageContainer->CurrentLine();
       
   504     }
       
   505 
       
   506 void CEikDialogPageSelector::SetPageDensePacked(TInt aPageId,TBool aDensePacked)
       
   507     {
       
   508     iPageContainer->SetPageDensePacked(aPageId,aDensePacked);
       
   509     }
       
   510 
       
   511 void CEikDialogPageSelector::SetAllPagesDensePacked(TBool aDensePacked)
       
   512     {
       
   513     iPageContainer->SetAllPagesDensePacked(aDensePacked);
       
   514     }
       
   515 
       
   516 void CEikDialogPageSelector::SetPageDimmed(TInt aPageId,TBool aDimmed,TDrawNow aDrawNow)
       
   517     {
       
   518     iPageContainer->SetPageDimmed(aPageId,aDimmed,aDrawNow);
       
   519     if ( iTabContainer )
       
   520         iTabContainer->DimTab(aPageId,aDimmed);  //<<-- AknTab
       
   521     }
       
   522 
       
   523 TInt CEikDialogPageSelector::LineId(const CCoeControl& aControl) const
       
   524     {
       
   525     return iPageContainer->LineId(aControl);
       
   526     }
       
   527 
       
   528 void CEikDialogPageSelector::DeleteLine(TInt aLineId,TBool aRedraw)
       
   529     {
       
   530     iPageContainer->DeleteLine(aLineId, aRedraw);
       
   531     }
       
   532 
       
   533 void CEikDialogPageSelector::InsertLineL(TInt aPosition,TInt aPageId,TInt aResourceId)
       
   534     {
       
   535     iPageContainer->InsertLineL(aPosition,aPageId,aResourceId);
       
   536     }
       
   537 
       
   538 void CEikDialogPageSelector::AdjustAllIds(TInt aPageId,TInt aControlIdDelta)
       
   539     {
       
   540     iPageContainer->AdjustAllIds(aPageId,aControlIdDelta);
       
   541     }
       
   542 
       
   543 CCoeControl* CEikDialogPageSelector::CreateLineByTypeL(const TDesC& aCaption,TInt aControlId,TInt aControlType,TAny* aReturnValue)
       
   544     {
       
   545     return iPageContainer->CreateLineByTypeL(aCaption,aControlId,aControlType,aReturnValue);
       
   546     }
       
   547 
       
   548 CCoeControl* CEikDialogPageSelector::CreateLineByTypeL(const TDesC& aCaption,TInt aPageId,TInt aControlId,TInt aControlType,TAny* aReturnValue)
       
   549     {
       
   550     return iPageContainer->CreateLineByTypeL(aCaption,aPageId,aControlId,aControlType,aReturnValue);
       
   551     }
       
   552 
       
   553 void CEikDialogPageSelector::FocusLineL(TInt aLineId)
       
   554     {
       
   555     TInt newPageIndex=iPageContainer->FindPageIndexForLineId(aLineId);
       
   556     
       
   557     if (newPageIndex>=0)
       
   558         {
       
   559         if ( iTabContainer )
       
   560         iTabContainer->SetFocus(EFalse);
       
   561         iPageContainer->SetFocus(EFalse);
       
   562         SetActivePageByIndexL(newPageIndex);
       
   563         }
       
   564 
       
   565     iPageContainer->FocusLineL(aLineId);
       
   566     }
       
   567 
       
   568 TInt CEikDialogPageSelector::FocusedLineId() const
       
   569     {
       
   570     return iPageContainer->FocusedLineId();
       
   571     }
       
   572 
       
   573 void CEikDialogPageSelector::GetAutoValues()
       
   574     {
       
   575     iPageContainer->GetAutoValues();
       
   576     }
       
   577 
       
   578 TInt CEikDialogPageSelector::ActivePageId() const
       
   579     {
       
   580     return iPageContainer->ActivePageId();
       
   581     }
       
   582 
       
   583 TInt CEikDialogPageSelector::ActivePageIndex() const
       
   584     {
       
   585     return iPageContainer->ActivePageIndex();
       
   586     }
       
   587 
       
   588 void CEikDialogPageSelector::SizeChanged()
       
   589     {
       
   590     const TInt borderThickness = iBorder.SizeDelta().iWidth;
       
   591     const TSize pageContainerSize( iSize.iWidth - borderThickness, iSize.iHeight - borderThickness / 2 );
       
   592 
       
   593     if ( iIsForm )
       
   594         {
       
   595         iPageContainer->SetPageFormSized();
       
   596         }
       
   597     else
       
   598         {
       
   599         iPageContainer->SetExtent( TPoint( iPosition.iX + borderThickness / 2, iPosition.iY ), pageContainerSize );
       
   600         }
       
   601 
       
   602     AknsUtils::RegisterControlPosition(this);
       
   603     }
       
   604 
       
   605 TKeyResponse CEikDialogPageSelector::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
       
   606     {
       
   607     if (Dialg()->DialogFlags() & EEikDialogFlagDontEatUpDownEvents)
       
   608         {
       
   609         // Forward up/down events...
       
   610         if (aType!=EEventKey)
       
   611         return iPageContainer->OfferKeyEventL(aKeyEvent,aType);
       
   612         }
       
   613     else
       
   614         {
       
   615         // ignore up/down events...
       
   616         if (aType!=EEventKey)
       
   617         return EKeyWasNotConsumed;
       
   618         }
       
   619 
       
   620     TKeyResponse keyResponse=EKeyWasNotConsumed;
       
   621 
       
   622     switch (aKeyEvent.iCode)
       
   623         {
       
   624         case EKeyUpArrow:
       
   625         case EKeyDownArrow:
       
   626       case EKeyPrevious:
       
   627 	  case EKeyNext:        
       
   628                 {   // Single page dialog.
       
   629                 keyResponse=iPageContainer->OfferUpDownKeyEventL(aKeyEvent,aType,CEikDialogPage::ENonCyclic);
       
   630                 }
       
   631             break;
       
   632         case EKeyLeftArrow:
       
   633         case EKeyRightArrow:
       
   634             if ( iTabContainer && ( iTabContainer->TabCount() > 1 ) && !iEditable )
       
   635                 keyResponse=iTabContainer->OfferKeyEventL(aKeyEvent,aType);
       
   636             else
       
   637                 keyResponse=iPageContainer->OfferKeyEventL(aKeyEvent,aType);
       
   638             break;
       
   639         default:
       
   640             keyResponse=iPageContainer->OfferKeyEventL(aKeyEvent,aType);
       
   641         }
       
   642 
       
   643     return keyResponse;
       
   644     }
       
   645 
       
   646 TSize CEikDialogPageSelector::MinimumSize()
       
   647     {
       
   648     const TSize pageContainerSize=iPageContainer->MinimumSize();
       
   649     const TSize minSize(pageContainerSize.iWidth,pageContainerSize.iHeight);
       
   650     return minSize;
       
   651     }
       
   652 
       
   653 TSize CEikDialogPageSelector::PreferredSize(const TSize& aMaxSize) const
       
   654     {
       
   655     const TInt borderThickness(iBorder.SizeDelta().iWidth);
       
   656 
       
   657     const TSize maxSize(aMaxSize.iWidth-borderThickness,aMaxSize.iHeight-borderThickness/2);
       
   658     const TSize pageContainerPreferredSize(iPageContainer->PreferredSize(maxSize));
       
   659 
       
   660     TSize preferredSize(pageContainerPreferredSize.iWidth,pageContainerPreferredSize.iHeight);
       
   661     preferredSize.iWidth=Min(preferredSize.iWidth+borderThickness,aMaxSize.iWidth);
       
   662     preferredSize.iHeight=Min(preferredSize.iHeight+borderThickness/2,aMaxSize.iHeight);
       
   663     return preferredSize;
       
   664     }
       
   665 
       
   666 TInt CEikDialogPageSelector::CountComponentControls() const
       
   667     {
       
   668     return 1 ;
       
   669     }
       
   670 
       
   671 CCoeControl* CEikDialogPageSelector::ComponentControl(TInt /*aIndex*/) const
       
   672     {
       
   673     return iPageContainer;
       
   674     }
       
   675 
       
   676 void CEikDialogPageSelector::PrepareContext(CWindowGc& aGc) const
       
   677     {
       
   678     if ( iIsForm && AknsUtils::AvkonSkinEnabled() )
       
   679         aGc.SetBrushStyle( CGraphicsContext::ENullBrush );
       
   680     else
       
   681         aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   682     }
       
   683 
       
   684 void CEikDialogPageSelector::Draw(const TRect& aRect) const
       
   685     {
       
   686     DrawBorder(aRect);
       
   687     DrawBackground(aRect);
       
   688     }
       
   689 
       
   690 void CEikDialogPageSelector::DrawBorder(const TRect& aRect) const
       
   691     {
       
   692     TRect innerRect(iPageContainer->Position(),iPageContainer->Size()) ;
       
   693     TRect rect=iBorder.OuterRect(innerRect);
       
   694     CWindowGc& gc=SystemGc();
       
   695     rect.Intersection(aRect); 
       
   696     iBorder.Draw(gc,rect);
       
   697     }
       
   698 
       
   699 void CEikDialogPageSelector::DrawBackground(const TRect& aRect) const
       
   700     { // if no arguments provided, redraw whole screen.
       
   701     // If the Page contains a form then form formatting is required.  A horizontal line is required between the
       
   702     // bottom item and the CBA below the data side (not the caption side).  It must not be in the scrolling area
       
   703     // hence it's drawn outside the page container.  Note that the page container is shrunk by 1 pixel in SizeChanged() to create
       
   704     // space for the line.  (TimW 18th May 2000)
       
   705     // <SKIN> This should be the first place to deal with skin stuff.  It is the parent area for the dialog and shows at the top and 
       
   706     // bottom.  There might be issues about the vertical line and tiling background bitmaps.  There might also be something about 
       
   707     // area underneath the horzontal line (not tiled)
       
   708     MAknsSkinInstance* skin = AknsUtils::SkinInstance() ;
       
   709     TBool drawSkin = AknsUtils::AvkonSkinEnabled() ;
       
   710     CAknsListBoxBackgroundControlContext* cc = iDialg->Extension()->iBgContext ;
       
   711 
       
   712     CWindowGc& gc=SystemGc();
       
   713     if ( iIsForm )
       
   714         {
       
   715         if (!iPageContainer->Page(iPageContainer->ActivePageId())->AnythingToDisplay())
       
   716             {
       
   717 // Added to obtain a clear screen to display "no data" text.
       
   718             if ( drawSkin )
       
   719                 {
       
   720                 TRect empty( TPoint( 0, 0 ), TPoint ( 0, 0 ) ) ;
       
   721                 cc->SetTiledRect( empty ) ;
       
   722                 AknsDrawUtils::Background( skin, cc, this, gc, aRect ) ;
       
   723                 }
       
   724             else
       
   725                 {
       
   726                 gc.Clear(aRect);
       
   727                 }
       
   728             return;
       
   729             }
       
   730 
       
   731         // Draw the vertical and horizontal lines on the page
       
   732         TAknLayoutRect iVertLine1, iVertLine2, iHoriLine;    
       
   733         CEikDialogPage* dialogPage = iPageContainer->Page( iPageContainer->ActivePageId() );
       
   734         if ( dialogPage )
       
   735             {
       
   736             if (dialogPage->FormLayout() == CEikDialogPage::ESingle )
       
   737                 {
       
   738                 // <SKIN> Get the bitmaps for tiling here.
       
   739                 if ( drawSkin )
       
   740                     cc->SetTiledBitmap( KAknsIIDQsnBgColumnAB ) ;
       
   741 
       
   742                 // List single heading pane uses BC columns (Table 65)
       
   743                 iVertLine1.LayoutRect( Rect(), AKN_LAYOUT_WINDOW_List_pane_lines__BC_columns__Line_1( 0 ) );
       
   744                 iVertLine2.LayoutRect( Rect(), AKN_LAYOUT_WINDOW_List_pane_lines__BC_columns__Line_1( 1 ) );
       
   745                 iHoriLine.LayoutRect( Rect(), AKN_LAYOUT_WINDOW_List_pane_lines__BC_columns__Line_2 );
       
   746                 }
       
   747         // For double line format 
       
   748             else
       
   749                 {
       
   750                 if (dialogPage->GetFormFlags()&EEikFormShowBitmaps) 
       
   751                     {
       
   752                     // <SKIN> Get the bitmaps for tiling here.
       
   753                     if ( drawSkin )
       
   754                         cc->SetTiledBitmap( KAknsIIDQsnBgColumnA ) ;
       
   755 
       
   756                     iVertLine1.LayoutRect( Rect(), AKN_LAYOUT_WINDOW_List_pane_lines__AB_columns__Line_1( 0 ) );
       
   757                     iVertLine2.LayoutRect( Rect(), AKN_LAYOUT_WINDOW_List_pane_lines__AB_columns__Line_1( 1 ) );
       
   758                     iHoriLine.LayoutRect( Rect(), AKN_LAYOUT_WINDOW_List_pane_lines__AB_columns__Line_2 );
       
   759                     }
       
   760                 else
       
   761                     {
       
   762                     // <SKIN> Get the bitmaps for tiling here.
       
   763                     if ( drawSkin )
       
   764                         cc->SetTiledBitmap( KAknsIIDQsnBgColumnA ) ;
       
   765 
       
   766                     iVertLine1.LayoutRect( Rect(), AKN_LAYOUT_WINDOW_List_pane_lines__A_column__Line_1( 0 ) );
       
   767                     iVertLine2.LayoutRect( Rect(), AKN_LAYOUT_WINDOW_List_pane_lines__A_column__Line_1( 1 ) );
       
   768                     iHoriLine.LayoutRect( Rect(), AKN_LAYOUT_WINDOW_List_pane_lines__A_column__Line_2);
       
   769                     }
       
   770                 }
       
   771 
       
   772             TBool skinDrawn = EFalse;
       
   773             if ( drawSkin )
       
   774                 {
       
   775                 // <SKIN> Drawing the background stuff.
       
   776                 TRect columnRect = Rect() ;
       
   777                 if ( AknLayoutUtils::LayoutMirrored() )
       
   778                     {
       
   779                     columnRect.iTl.iX = iVertLine1.Rect().iTl.iX ;
       
   780                     }
       
   781                 else
       
   782                     {
       
   783                     columnRect.iBr.iX = iVertLine1.Rect().iTl.iX ;
       
   784                     }
       
   785                 cc->SetTiledRect( columnRect ) ;
       
   786 
       
   787                 if ( AknsDrawUtils::Background( skin, cc, this, gc, Rect() ) )
       
   788                     {
       
   789                     skinDrawn = ETrue;
       
   790                     }
       
   791                 }
       
   792 
       
   793             if ( !skinDrawn )
       
   794                 {
       
   795                 iVertLine1.DrawRect(gc);
       
   796                 iVertLine2.DrawRect(gc);            
       
   797                 iHoriLine.DrawRect(gc);
       
   798                 }
       
   799 
       
   800             }
       
   801         }
       
   802     }
       
   803 
       
   804 void CEikDialogPageSelector::HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType)
       
   805     {
       
   806     switch (aEventType)
       
   807         {
       
   808         case EEventPrepareFocusTransition:
       
   809             PrepareForFocusTransitionL();
       
   810             break;
       
   811         case EEventRequestFocus:
       
   812             HandleRequestFocusL(aControl);
       
   813             break;
       
   814         case EEventStateChanged:
       
   815             if (aControl==iNaviDecorator) 
       
   816                 HandleTabStateChangedL((CAknTabGroup*)STATIC_CAST(CAknNavigationDecorator*,aControl)->DecoratedControl());
       
   817             else
       
   818                 PassOnEventL(aControl,aEventType);
       
   819             break;
       
   820         case EEventInteractionRefused:
       
   821             // *** ToDo
       
   822             break;
       
   823         default:
       
   824             break;
       
   825         }
       
   826     }
       
   827 
       
   828 void CEikDialogPageSelector::PrepareForFocusTransitionL()
       
   829     {
       
   830     if (iPageContainer && iPageContainer->IsFocused())
       
   831         iPageContainer->PrepareForFocusLossL();
       
   832     else if (iTabContainer && iTabContainer->IsFocused())
       
   833         iTabContainer->PrepareForFocusLossL();
       
   834     }
       
   835 
       
   836 void CEikDialogPageSelector::HandleRequestFocusL(CCoeControl* aControl)
       
   837     {
       
   838     if (aControl==iTabContainer)
       
   839         {
       
   840         if (iPageContainer) iPageContainer->SetFocus(EFalse,EDrawNow);
       
   841         if (iTabContainer) iTabContainer->SetFocus(ETrue,EDrawNow);
       
   842         }
       
   843     else
       
   844         {
       
   845         if (iTabContainer) iTabContainer->SetFocus(EFalse,EDrawNow);
       
   846         if (iPageContainer) iPageContainer->SetFocus(ETrue,EDrawNow);
       
   847         }
       
   848     }
       
   849 
       
   850 void CEikDialogPageSelector::HandleTabStateChangedL(CAknTabGroup* aTabContainer) //<<--AknTab
       
   851     {
       
   852     if(iPageContainer->ActivePageIndex() != aTabContainer->ActiveTabIndex())
       
   853         {
       
   854         iPageContainer->SetFocus(EFalse,EDrawNow);
       
   855         iPageContainer->SetActivePageByIndexL(aTabContainer->ActiveTabIndex());
       
   856         DrawDeferred();
       
   857         }
       
   858     }
       
   859 
       
   860 void CEikDialogPageSelector::PassOnEventL(CCoeControl* aControl,MCoeControlObserver::TCoeEvent aEvent)
       
   861     {
       
   862     MCoeControlObserver* observer=Observer();
       
   863     if (observer)
       
   864         observer->HandleControlEventL(aControl,aEvent);
       
   865     }
       
   866 
       
   867 void CEikDialogPageSelector::SetInitialFocus()
       
   868     {
       
   869     if ( iTabContainer && ( iTabContainer->TabCount() > 1 ) )
       
   870         iTabContainer->SetActiveTabByIndex( KFirstTab ); //<<--AknTab
       
   871 
       
   872     iPageContainer->SetInitialFocus();
       
   873     }
       
   874 
       
   875 void CEikDialogPageSelector::ResetLineMinimumSizes()
       
   876     {
       
   877     iPageContainer->ResetLineMinimumSizes();
       
   878     }
       
   879 
       
   880 TInt CEikDialogPageSelector::FindLineIndex(const CCoeControl& aControl) const
       
   881     {
       
   882     return iPageContainer->FindLineIndex(aControl);
       
   883     }
       
   884 
       
   885 TBool CEikDialogPageSelector::RotateFocusByL(TInt aDelta)
       
   886     {
       
   887     return iPageContainer->RotateFocusByL(aDelta);
       
   888     }
       
   889 
       
   890 TKeyResponse CEikDialogPageSelector::OfferHotKeysKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
       
   891     {
       
   892     return iPageContainer->OfferHotKeysKeyEventL(aKeyEvent,aType);
       
   893     }
       
   894 
       
   895 TBool CEikDialogPageSelector::TakesEnterKey()
       
   896     {
       
   897     return iPageContainer->TakesEnterKey();
       
   898     }
       
   899 
       
   900 
       
   901 void CEikDialogPageSelector::AddFormToPageL( TInt aPageId,TResourceReader& aReader ) 
       
   902     {
       
   903     // This function process FORM structures in the DIALOG resource
       
   904     // Is there a FORM on the page?
       
   905     TInt32 formReaderID ;
       
   906     formReaderID = aReader.ReadInt32()  ; 
       
   907     
       
   908     if ( formReaderID != 0 )
       
   909         {
       
   910         // SB creation moved here, 
       
   911         // because at the moment only forms use dialog's SB
       
   912         iPageContainer->CreateScrollBarL(*this);
       
   913         iIsForm = ETrue ;
       
   914         TResourceReader formReader ;
       
   915         iCoeEnv->CreateResourceReaderLC( formReader, formReaderID ) ;
       
   916         // Find the dialog page 
       
   917         CEikDialogPage* targetPage = iPageContainer->Page( aPageId ) ;
       
   918         // instruct it to create form controls
       
   919         targetPage->ConstructFormFromResourceL( formReader ) ;
       
   920         CleanupStack::PopAndDestroy() ; //formReader
       
   921         }
       
   922     }
       
   923 
       
   924 void CEikDialogPageSelector::SetEditableL( TBool aEditable) 
       
   925     {
       
   926 // These should be uncommented on submission 
       
   927 //  _LIT(KPanicNotDialog,"Form resource not used");
       
   928 //  __ASSERT_DEBUG(iIsForm,User::Panic(KPanicNotDialog,0));
       
   929 
       
   930     iEditable = aEditable ;
       
   931     if ( iEditable )
       
   932         { // In editable mode hide the tab container 
       
   933         if ( iNaviContainer && iTabContainer && iTabContainer->TabCount() > 1 && iTabsVisible )
       
   934             {
       
   935             iNaviContainer->Pop( iNaviDecorator ) ;
       
   936             iTabsVisible = EFalse ;
       
   937             }
       
   938         }
       
   939     else
       
   940         { // in View mode show the tab container
       
   941         if ( iNaviContainer && iNaviDecorator && iTabContainer && iTabContainer->TabCount() > 1 && !iTabsVisible )
       
   942             {
       
   943             iNaviContainer->PushL( *iNaviDecorator ) ;
       
   944             iTabsVisible = ETrue ;
       
   945             }
       
   946         }
       
   947     iPageContainer->SetEditableL( iEditable ) ;
       
   948     }
       
   949 
       
   950 TInt CEikDialogPageSelector::NumPages() const 
       
   951     {
       
   952     return iPageContainer->NumPages() ;
       
   953     }
       
   954 
       
   955 void CEikDialogPageSelector::DestroyTabContainer() 
       
   956     {
       
   957     if ( iNaviDecorator )
       
   958         {
       
   959         delete iNaviDecorator ;
       
   960         iNaviDecorator = NULL ;
       
   961         iTabContainer = NULL ;
       
   962         iTabsVisible = EFalse; // deletion will pop decorator from stack.
       
   963         }
       
   964     }
       
   965 
       
   966 CEikDialogPageContainer*  CEikDialogPageSelector::PageContainer()
       
   967     {
       
   968     return iPageContainer;
       
   969     }
       
   970 
       
   971 
       
   972 /**
       
   973  * Writes the internal state of the control and its components to aStream.
       
   974  * Does nothing in release mode.
       
   975  * Designed to be overidden and base called by subclasses.
       
   976  *
       
   977  * @internal
       
   978  * @since App-Framework_6.1
       
   979  */
       
   980 #ifndef _DEBUG
       
   981 void CEikDialogPageSelector::WriteInternalStateL(RWriteStream&) const
       
   982     {}
       
   983 #else
       
   984 void CEikDialogPageSelector::WriteInternalStateL(RWriteStream& aWriteStream) const
       
   985     {
       
   986     CCoeControl::WriteInternalStateL(aWriteStream);
       
   987     }
       
   988 #endif
       
   989 
       
   990 void  CEikDialogPageSelector::Reserved_2()
       
   991     {
       
   992     }
       
   993 
       
   994 void CEikDialogPageSelector::SetDialg(CEikDialog* aDialg)
       
   995     {
       
   996     iDialg=aDialg;
       
   997     };
       
   998 
       
   999 void CEikDialogPageSelector::RegisterPageSelectorWithPageContainer()
       
  1000     {
       
  1001     if (iPageContainer)
       
  1002         iPageContainer->SetPageSelector(this);
       
  1003     };
       
  1004 
       
  1005 CEikDialog* CEikDialogPageSelector::Dialg() const
       
  1006     {
       
  1007     return iDialg;
       
  1008     }
       
  1009 
       
  1010 TBool CEikDialogPageSelector::IsForm() const
       
  1011     {
       
  1012     return iIsForm;
       
  1013     }
       
  1014 
       
  1015 void CEikDialogPageSelector::TabChangedL(TInt aIndex)
       
  1016     {
       
  1017     iPageContainer->SetActivePageByIndexL(aIndex);
       
  1018     DrawNow();
       
  1019     }
       
  1020  
       
  1021 
       
  1022 
       
  1023 /* =====================================
       
  1024  * Tool Tip Manager.
       
  1025  * SERIES60 Forms have a tool tip feature allowing a piece of text
       
  1026  * to be displayed in the Navi Pane when an input control has the focus.
       
  1027  * This little class ensures that tool tip functionality is located in one
       
  1028  * place and that no memory is leaked.
       
  1029  * =====================================
       
  1030  */
       
  1031 
       
  1032 CEikDlgToolTipMgr::CEikDlgToolTipMgr( CEikonEnv* aEikonEnv ) :
       
  1033 iToolTip( NULL ) ,
       
  1034 iShowTips( EFalse ) ,
       
  1035 iIsTipShowing( EFalse )
       
  1036     {
       
  1037     CEikStatusPane* statusPane = aEikonEnv->AppUiFactory()->StatusPane() ;
       
  1038     if (statusPane)
       
  1039         {
       
  1040         CEikStatusPaneBase::TPaneCapabilities statusPaneCapabilities = statusPane->PaneCapabilities( TUid::Uid( EEikStatusPaneUidNavi ) ) ;
       
  1041         if ( statusPaneCapabilities.IsPresent() && statusPaneCapabilities.IsAppOwned() )
       
  1042             { // continue
       
  1043             TRAP_IGNORE(iNaviContainer = (MAknNavigationContainerInterface*)(CAknNavigationControlContainer*)statusPane->ControlL( TUid::Uid( EEikStatusPaneUidNavi ))) ;
       
  1044             }
       
  1045         }
       
  1046     }
       
  1047 
       
  1048 CEikDlgToolTipMgr::~CEikDlgToolTipMgr() 
       
  1049     {
       
  1050     if ( iIsTipShowing )
       
  1051         HideTip() ;
       
  1052     }
       
  1053 
       
  1054 void CEikDlgToolTipMgr::DisplayTipL( const TDesC* aTipText ) 
       
  1055     {
       
  1056     if ( iShowTips )
       
  1057         {
       
  1058         User::LeaveIfNull(iNaviContainer);
       
  1059 
       
  1060         MAknNavigationDecoratorInterface* newToolTip;
       
  1061 
       
  1062         //push the new tip
       
  1063         if ( aTipText  && aTipText->Length() )
       
  1064             newToolTip = iNaviContainer->CreateMessageLabelL( *aTipText ) ;
       
  1065         else
       
  1066             newToolTip = iNaviContainer->CreateMessageLabelL( _L("") ) ;
       
  1067          
       
  1068         CleanupStack::PushL(newToolTip);
       
  1069         iNaviContainer->PushL( (CAknNavigationDecorator&)*newToolTip ) ;
       
  1070         CleanupStack::Pop();
       
  1071 
       
  1072         //pop the new tip
       
  1073         HideTip();
       
  1074 
       
  1075         iToolTip = newToolTip;
       
  1076 
       
  1077         iIsTipShowing = ETrue ;
       
  1078         }
       
  1079     }
       
  1080 
       
  1081 void CEikDlgToolTipMgr::HideTip() 
       
  1082     {
       
  1083     if ( iIsTipShowing )
       
  1084         {
       
  1085         // Destroy the tip that's just been popped
       
  1086         delete iToolTip ;
       
  1087         iToolTip = NULL ;
       
  1088 
       
  1089         iIsTipShowing = EFalse ;
       
  1090         }
       
  1091     }
       
  1092 
       
  1093 void CEikDlgToolTipMgr::EnableTips( TBool aShowTips ) 
       
  1094     {
       
  1095     if ( iNaviContainer )
       
  1096         {
       
  1097         iShowTips = aShowTips ;
       
  1098         if ( !iShowTips )
       
  1099             // Hide the current tip if tips are being switched off
       
  1100             HideTip() ;
       
  1101         }
       
  1102     }