camerauis/cameraapp/generic/src/CamInfoListBoxContainer.cpp
changeset 19 d9aefe59d544
parent 3 8b2d6d0384b0
child 21 fa6d9f75d6a6
child 28 3075d9b614e6
equal deleted inserted replaced
3:8b2d6d0384b0 19:d9aefe59d544
     1 /*
       
     2 * Copyright (c) 2007-2008 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:  Setting page for Image/Video quality.*
       
    15 */
       
    16 
       
    17 #include "CamInfoListBoxContainer.h"
       
    18 #include "CamUtility.h"
       
    19 #include <AknBidiTextUtils.h>
       
    20 #include <AknsUtils.h>
       
    21 #include <AknsDrawUtils.h>
       
    22 #include <AknUtils.h>
       
    23 #include <barsread.h>    // resource reader
       
    24 #include <aknview.h> 
       
    25 #include <aknlayoutscalable_apps.cdl.h>
       
    26 #include <touchfeedback.h> 
       
    27 #include <akntoolbar.h>
       
    28 
       
    29 
       
    30 #include "CamAppUi.h"
       
    31 
       
    32 #include "CamInfoListBox.h"
       
    33 #include "CamInfoListBoxModel.h"
       
    34 #include "CamPanic.h"
       
    35 #include <AknInfoPopupNoteController.h>  // CAknInfoPopupNoteController
       
    36 
       
    37 #include <cameraapp.rsg>
       
    38 #include <vgacamsettings.rsg>
       
    39 
       
    40 // CONSTANTS
       
    41 const TInt KInfoTooltipDelay = 0; // time (milliseconds) delay when showing the tooltip
       
    42 const TInt KInfoTooltipDisplayTime = 5000; // maximum time (milliseconds) the tooltip is displayed
       
    43 const TInt KExplTxtGranularity = 6;
       
    44 
       
    45 // ================= MEMBER FUNCTIONS =======================
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // CCamInfoListBoxContainer::NewL
       
    49 // Symbian OS two-phased constructor
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 CCamInfoListBoxContainer* CCamInfoListBoxContainer::NewL( const TRect& aRect, 
       
    53                                                             CAknView& aView,                                                            
       
    54                                                             CCamAppController& aController,
       
    55                                                             TInt aListBoxResource,
       
    56                                                             TInt aSummaryResource,
       
    57                                                             TInt aSettingValue,
       
    58                                                             TInt aTitleResource  )
       
    59     {
       
    60     CCamInfoListBoxContainer* self = 
       
    61                   new( ELeave ) CCamInfoListBoxContainer(  aController,
       
    62                                                            aView,
       
    63                                                            aSettingValue );
       
    64     CleanupStack::PushL( self );
       
    65     self->ConstructL( aRect, aListBoxResource, aSummaryResource, aTitleResource);
       
    66     CleanupStack::Pop( self );
       
    67     return self;
       
    68     }
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // CCamInfoListBoxContainer::~CCamInfoListBoxContainer
       
    72 // Destructor
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 CCamInfoListBoxContainer::~CCamInfoListBoxContainer()
       
    76   {
       
    77     PRINT( _L( "Camera => ~CCamInfoListBoxContainer" ) );
       
    78 
       
    79     iSummaryBitmapArray.ResetAndDestroy();
       
    80     iTitleArray.ResetAndDestroy();
       
    81     iDescArray.ResetAndDestroy();
       
    82     iExplTxtLinesLayout.Close();  
       
    83 
       
    84     if ( iFeedback ) 
       
    85         {
       
    86         iFeedback->RemoveFeedbackForControl( iListBox );
       
    87         } 
       
    88 
       
    89     delete iListBox;
       
    90 
       
    91     if ( iTooltipController )
       
    92         {
       
    93         delete iTooltipController;
       
    94         iTooltipController = NULL;
       
    95         }
       
    96     
       
    97     if ( iListboxTitle )
       
    98         {
       
    99         delete iListboxTitle;
       
   100         iListboxTitle = NULL;
       
   101         }
       
   102 
       
   103     if ( iCurrentDescLineArray ) 
       
   104         {
       
   105         iCurrentDescLineArray->Reset();
       
   106         delete iCurrentDescLineArray;
       
   107         }
       
   108         	
       
   109 	PRINT( _L( "Camera <= ~CCamInfoListBoxContainer" ) );    
       
   110   }
       
   111   
       
   112 // ---------------------------------------------------------
       
   113 // CCamInfoListBoxContainer::ConstructL
       
   114 // Symbian OS 2nd phase constructor
       
   115 // ---------------------------------------------------------
       
   116 //
       
   117 void CCamInfoListBoxContainer::ConstructL( const TRect& aRect, TInt aListBoxResource, TInt aSummaryResource, TInt aTitleResource )
       
   118     {
       
   119 	PRINT(_L("Camera => CCamInfoListBoxContainer::ConstructL") )
       
   120     
       
   121     CCamContainerBase::BaseConstructL( aRect );
       
   122 
       
   123     if ( iController.IsTouchScreenSupported() )
       
   124         {
       
   125         CCamAppUi* appUi = static_cast<CCamAppUi*>( iEikonEnv->AppUi() );
       
   126         CAknToolbar* fixedToolbar = appUi->CurrentFixedToolbar();
       
   127         if ( fixedToolbar )
       
   128             {
       
   129             // Hide toolbar from Light sensitivity etc. settings view 
       
   130             fixedToolbar->SetToolbarVisibility( EFalse );
       
   131             }
       
   132         }
       
   133 
       
   134     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
       
   135                                        iLayoutAreaRect );
       
   136     
       
   137     // layout area rectangle contains the area, where components need to be 
       
   138     // drawn to. the container size is the whole screen, but the layouts are 
       
   139     // for the client area. aRect is the container size that might include or
       
   140     // might not include statuspane area. calculating area self will
       
   141     // go around the problem
       
   142 
       
   143     // Construct the listbox
       
   144     iListBox =  new( ELeave ) CCamInfoListBox( this, iController );                           
       
   145     iListBox->ConstructL( iController, this, iTitleArray, iDescArray, aListBoxResource );
       
   146     iListBox->DisableSingleClick( ETrue );
       
   147 
       
   148     // Highlight the currently active setting value
       
   149     iListBox->InitializeL( iSettingValue );
       
   150 
       
   151     iListBox->SetContainerWindowL( *this );
       
   152     iListBox->CreateScrollBarFrameL( ETrue );
       
   153     
       
   154     CCamAppUi* appUi = static_cast<CCamAppUi*>( iEikonEnv->AppUi() ); 
       
   155     TRect listboxRect; 
       
   156     if ( CamUtility::IsNhdDevice() ) 
       
   157         {
       
   158         listboxRect = TouchLayout();
       
   159         }
       
   160     else
       
   161         {
       
   162         iCurrentDescLineArray  = 
       
   163                      new( ELeave ) CArrayFixFlat<TPtrC>( KExplTxtGranularity ); 
       
   164         appUi->StatusPane()->MakeVisible( ETrue ); 
       
   165         SetRect( appUi->ClientRect() );
       
   166         listboxRect = NonTouchLayout();
       
   167         }
       
   168     ConstructSummaryDetailsFromResourceL( aSummaryResource );   
       
   169 
       
   170     // Determine the height of the listbox; 
       
   171     // Height needs to be based on the number of items, because the layout
       
   172     // height (maxListBoxHeight )might be different 
       
   173     // than combined height of the max visible listbox items
       
   174     
       
   175     CEikScrollBarFrame::TScrollBarVisibility visibility = 
       
   176                                                       CEikScrollBarFrame::EOff;
       
   177     TInt listBoxHeight = iListBox->CalcHeightBasedOnNumOfItems( 
       
   178                                           iListBox->Model()->NumberOfItems() );
       
   179     if ( listboxRect.Height() < listBoxHeight )
       
   180         {
       
   181         // there are more items than would fit to the listbox rectangle
       
   182         
       
   183         // the maximum height is the total height of items 
       
   184         // that can fit to the maxlistboxheight
       
   185         TInt itemHeight = iListBox->ItemHeight();
       
   186         TInt itemsVisible = listboxRect.Height() / itemHeight;
       
   187         listBoxHeight = itemsVisible * itemHeight;
       
   188         
       
   189         // the scrollbar needs to be turned on
       
   190         visibility = CEikScrollBarFrame::EOn;
       
   191         }  
       
   192     
       
   193     // calculate the layout for the listbox with changed height
       
   194     const AknLayoutUtils::SAknLayoutControl listboxLayout =
       
   195     {   ELayoutEmpty, listboxRect.iTl.iX, listboxRect.iTl.iY, 
       
   196         ELayoutEmpty, ELayoutEmpty, 
       
   197         iListboxLayoutRect.Rect().Width(), listBoxHeight };
       
   198     
       
   199     AknLayoutUtils::LayoutControl( iListBox, iLayoutAreaRect, listboxLayout);
       
   200 
       
   201     // set scrollbars for the listbox
       
   202     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, 
       
   203                                                          visibility );
       
   204     iListBox->MakeVisible( ETrue );
       
   205     iListBox->SetFocus( EFalse, ENoDrawNow );
       
   206     iListBox->UpdateScrollBarsL();
       
   207     iListBox->ScrollBarFrame()->DrawScrollBarsNow();
       
   208     iListBox->SetListBoxObserver(this); 
       
   209     appUi->SetActivePaletteVisibility( EFalse );
       
   210 
       
   211     // Prevents the system filling invalidated areas with the background colour - 
       
   212     // helps reduce flicker.
       
   213     Window().SetBackgroundColor();
       
   214        
       
   215     ConstructContainerTitleFromResourceL( aTitleResource ); 
       
   216        
       
   217     if ( !iTooltipController )
       
   218         {
       
   219         iTooltipController = CAknInfoPopupNoteController::NewL();
       
   220         }
       
   221         
       
   222     iTooltipController->SetTimeDelayBeforeShow( KInfoTooltipDelay );
       
   223     iTooltipController->SetTimePopupInView( KInfoTooltipDisplayTime );
       
   224     
       
   225     // Position the tooltip
       
   226     TPoint position;
       
   227     if ( AknsUtils::GetControlPosition( this, position ) != KErrNone )
       
   228         {
       
   229         position = PositionRelativeToScreen();
       
   230         }
       
   231     TRect rect( position, Size() );
       
   232     TPoint center = rect.Center();
       
   233     iTooltipController->SetPositionAndAlignment( TPoint( center.iX, rect.iTl.iY ), EHLeftVBottom );
       
   234      
       
   235     iTooltipController->SetTimeDelayBeforeShow( KInfoTooltipDelay );
       
   236     iTooltipController->SetTimePopupInView( KInfoTooltipDisplayTime );
       
   237 
       
   238     iFeedback = MTouchFeedback::Instance();  
       
   239     if ( iFeedback ) 
       
   240         {
       
   241         iFeedback->SetFeedbackArea( iListBox, 0, iListBox->Rect(), 
       
   242                                   ETouchFeedbackBasic, ETouchEventStylusDown );
       
   243         }
       
   244 
       
   245 	PRINT(_L("Camera <= CCamInfoListBoxContainer::ConstructL") )    
       
   246     }
       
   247    
       
   248 // ---------------------------------------------------------------------------
       
   249 // CCamInfoListBoxContainer::CCamInfoListBoxContainer
       
   250 // C++ constructor
       
   251 // ---------------------------------------------------------------------------
       
   252 //
       
   253 CCamInfoListBoxContainer::CCamInfoListBoxContainer(     CCamAppController& aController,
       
   254                                                         CAknView& aView,
       
   255                                                         TInt aSettingValue )
       
   256 : CCamContainerBase( aController, aView ), iSettingValue( aSettingValue ),
       
   257 iTooltipController(NULL),
       
   258 iShowTooltip(EFalse),
       
   259 iTooltipIndex(-1),
       
   260 iActivateOnTouchRelease(EFalse)
       
   261 
       
   262     {
       
   263     }
       
   264 
       
   265      
       
   266 // -----------------------------------------------------------------------------
       
   267 // CCamInfoListBoxContainer::CurrentSettingItemValue
       
   268 // Returns the Current item's setting value ID
       
   269 // -----------------------------------------------------------------------------
       
   270 TInt CCamInfoListBoxContainer::CurrentSettingItemValue() const
       
   271     {
       
   272     return static_cast<MCamListboxModel*>(iListBox->Model())->ItemValue(iListBox->CurrentItemIndex());
       
   273     }
       
   274     
       
   275     
       
   276 TBool CCamInfoListBoxContainer::SettingValueChanged() const
       
   277 		{
       
   278 		return CurrentSettingItemValue() != iSettingValue;
       
   279 		}    
       
   280     
       
   281 // -----------------------------------------------------------------------------
       
   282 // CCamInfoListBoxContainer::IndexForValueId() const
       
   283 // Returns the index of the item in the array with the specified ValueId
       
   284 // -----------------------------------------------------------------------------   
       
   285 TInt 
       
   286 CCamInfoListBoxContainer::IndexForValueId( TInt aValueId ) const
       
   287     {
       
   288     return static_cast<MCamListboxModel*>( iListBox->Model() )->ValueIndex( aValueId );
       
   289     } 
       
   290 
       
   291 // -----------------------------------------------------------------------------
       
   292 // CCamInfoListBoxContainer::HandleSettingValueUpdateL
       
   293 // Handles a change to the setting value of the slider
       
   294 // -----------------------------------------------------------------------------
       
   295 //
       
   296 void CCamInfoListBoxContainer::HandleSettingValueUpdateL( TInt /*aNewValue*/ )
       
   297     {   
       
   298     }
       
   299     
       
   300 // ---------------------------------------------------------
       
   301 // CCamInfoListBoxContainer::CountComponentControls 
       
   302 // Returns the number of controls owned
       
   303 // ---------------------------------------------------------
       
   304 //
       
   305 TInt CCamInfoListBoxContainer::CountComponentControls() const
       
   306     {
       
   307     return 1;
       
   308     }
       
   309 
       
   310 // ---------------------------------------------------------
       
   311 // CCamInfoListBoxContainer::ComponentControl
       
   312 // Returns the requested component control
       
   313 // ---------------------------------------------------------
       
   314 //
       
   315 CCoeControl* CCamInfoListBoxContainer::ComponentControl( TInt /*aIndex*/ ) const
       
   316     {
       
   317     return iListBox;
       
   318     }
       
   319 
       
   320 // ---------------------------------------------------------
       
   321 // CCamInfoListBoxContainer::Draw
       
   322 // Draw control
       
   323 // ----------------------------------------------------------
       
   324 //
       
   325 void CCamInfoListBoxContainer::Draw( const TRect& aRect ) const
       
   326     {
       
   327 	PRINT(_L("Camera => CCamInfoListBoxContainer::Draw") )
       
   328 
       
   329 	CWindowGc& gc = SystemGc();
       
   330     if ( CamUtility::IsNhdDevice() )
       
   331         {
       
   332         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   333         AknsDrawUtils::Background( skin, iBgContext, gc, aRect );
       
   334         // draw the title text   
       
   335         TRgb color;
       
   336         AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors,
       
   337                                                 EAknsCIQsnTextColorsCG6 );
       
   338         iTitleTextRectLayout.DrawText( gc, *iListboxTitle, ETrue, color );        
       
   339         }
       
   340     else
       
   341         { 
       
   342         TRAP_IGNORE( DrawSummaryTextL( gc ) ); 
       
   343         }
       
   344     
       
   345 	PRINT(_L("Camera <= CCamInfoListBoxContainer::Draw") )
       
   346     }
       
   347 
       
   348 // ----------------------------------------------------------------
       
   349 // CCamInfoListBoxContainer::OfferKeyEventL
       
   350 // Handles this application view's command keys. Forwards other
       
   351 // keys to child control(s).
       
   352 // ----------------------------------------------------------------
       
   353 //
       
   354 TKeyResponse CCamInfoListBoxContainer::OfferKeyEventL( 
       
   355     const TKeyEvent& aKeyEvent,
       
   356     TEventCode aType )
       
   357     {
       
   358     iController.StartIdleTimer();
       
   359 
       
   360     // If the Ok button is pressed, select the current item
       
   361     if ( aKeyEvent.iCode == EKeyOK && aKeyEvent.iRepeats == 0 && aType == EEventKey )
       
   362         {
       
   363         TKeyResponse response = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   364         iView.HandleCommandL( EAknSoftkeySelect );
       
   365         return response;
       
   366         }
       
   367     
       
   368     TKeyResponse returnvalue = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   369 
       
   370     if ( CamUtility::IsNhdDevice() )
       
   371         {
       
   372         // for non touch, we use key presses to scroll thru the scene modes
       
   373         // for touch with keyboard, key pressing can also scroll thru the scene modes            
       
   374         // after every up and down key presses we display the tool tip
       
   375         if ( EStdKeyUpArrow == aKeyEvent.iScanCode ||
       
   376              EStdKeyDownArrow == aKeyEvent.iScanCode )
       
   377             {
       
   378             ShowTooltipL();
       
   379             }
       
   380         }
       
   381     else // No tooltip
       
   382         {
       
   383         DrawDeferred(); // Update explanation text
       
   384         }
       
   385         
       
   386     return returnvalue;
       
   387     }
       
   388 
       
   389 // -----------------------------------------------------------------
       
   390 // CCamInfoListBoxContainer::ConstructSummaryDetailsFromResourceL
       
   391 // Sets up the layouts of the summary items
       
   392 // -----------------------------------------------------------------
       
   393 void CCamInfoListBoxContainer::ConstructSummaryDetailsFromResourceL(TInt aResourceId)
       
   394     {
       
   395      // Find the name and path of the MBM file for bitmaps
       
   396     TFileName mbmFileName;
       
   397     CamUtility::ResourceFileName( mbmFileName );
       
   398      
       
   399     TResourceReader reader;                                                                                     
       
   400     iEikonEnv->CreateResourceReaderLC( reader, aResourceId ); 
       
   401     const TInt count = reader.ReadInt16();
       
   402 
       
   403     TInt i;
       
   404     TInt bitmapId;
       
   405 
       
   406     // Read all of the summary entries from the resource file
       
   407     for ( i = 0; i < count; i++ )
       
   408         {
       
   409         reader.ReadInt16(); // The current item enum is not needed
       
   410         bitmapId = reader.ReadInt32();
       
   411         User::LeaveIfError( iSummaryBitmapArray.Append( AknIconUtils::CreateIconL( mbmFileName, bitmapId ) ) );
       
   412        
       
   413         User::LeaveIfError( iTitleArray.Append( reader.ReadHBufC16L() ) );
       
   414         User::LeaveIfError( iDescArray.Append( reader.ReadHBufC16L() ) );        
       
   415         } 
       
   416            
       
   417     CleanupStack::PopAndDestroy();         
       
   418     }
       
   419 
       
   420 
       
   421 // --------------------------------------------------------------------------
       
   422 // CCamInfoListBoxContainer::HandlePointerEventL
       
   423 // --------------------------------------------------------------------------
       
   424 //    
       
   425 void CCamInfoListBoxContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent ) 
       
   426     {
       
   427     
       
   428     RDebug::Print(_L("CCamInfoListBoxContainer::HandlePointerEventL iType=%d iPosition=(%d, %d)"),
       
   429             aPointerEvent.iType,
       
   430             aPointerEvent.iPosition.iX,
       
   431             aPointerEvent.iPosition.iY );
       
   432     iListBox->HandlePointerEventL(aPointerEvent);
       
   433     /*TInt oldListItemIndex = -1;
       
   434     TInt newListItemIndex = -1;
       
   435     TBool handleItemActivation = EFalse;
       
   436    
       
   437     if ( iListBox )
       
   438         {
       
   439         oldListItemIndex = iListBox->CurrentItemIndex();
       
   440         }
       
   441    
       
   442     // send to coecontrol -> will inform controls in this container about pointer events
       
   443     // (listbox will handle focus changes and scrolling)
       
   444     CCoeControl::HandlePointerEventL( aPointerEvent );       
       
   445        
       
   446     if ( iListBox )
       
   447         {
       
   448         newListItemIndex = iListBox->CurrentItemIndex();
       
   449         }
       
   450        
       
   451     // figure out if item was activated by touch down + release combination on same item
       
   452     if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
   453         {
       
   454 
       
   455         if ( iListBox->Rect().Contains( aPointerEvent.iPosition )  ) 
       
   456             {
       
   457             if ( newListItemIndex != oldListItemIndex )
       
   458                 {
       
   459                 iActivateOnTouchRelease = EFalse;
       
   460                 }
       
   461             else 
       
   462                 {
       
   463                 // set the current item to be activated on touch release
       
   464                 iActivateOnTouchRelease = ETrue;
       
   465                 }
       
   466              
       
   467             // show tooltip always when touch event down happens inside listbox
       
   468             ShowTooltipL();
       
   469             }
       
   470         else
       
   471             {
       
   472             iActivateOnTouchRelease = EFalse;
       
   473             }
       
   474         
       
   475         
       
   476         }
       
   477     else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
       
   478         {
       
   479         if ( iActivateOnTouchRelease && ( newListItemIndex == oldListItemIndex ) )
       
   480             {
       
   481             // only if list item index has not changed during event 
       
   482             // and iActivateOnTouchRelease is true
       
   483             TInt pointedItemIndex = 0;
       
   484             TBool focusableItemPointed = 
       
   485                 iListBox->View()->XYPosToItemIndex( aPointerEvent.iPosition, 
       
   486                                                     pointedItemIndex );
       
   487             // check that pointer is in focusable area
       
   488             if ( focusableItemPointed )
       
   489                 {
       
   490                 handleItemActivation = ETrue;
       
   491                 iActivateOnTouchRelease = EFalse;                       
       
   492                 }
       
   493             else
       
   494                 {
       
   495                 iActivateOnTouchRelease = EFalse;                       
       
   496                 }
       
   497             }
       
   498         }
       
   499     else 
       
   500         {
       
   501         // aPointerEvent.iType == TPointerEvent::EDrag
       
   502         
       
   503         if ( newListItemIndex != oldListItemIndex )
       
   504             {
       
   505             // change only when drag event changes the listitem index
       
   506             iActivateOnTouchRelease = EFalse;
       
   507 
       
   508             // with drag always update the tooltip
       
   509             ShowTooltipL();
       
   510             }
       
   511 
       
   512         }
       
   513 
       
   514 
       
   515     if ( handleItemActivation )
       
   516         {
       
   517         iView.HandleCommandL( EAknSoftkeySelect ); 
       
   518         }*/
       
   519    }
       
   520             
       
   521 // --------------------------------------------------------------------------
       
   522 // CCamInfoListBoxContainer::HandleListBoxEventL
       
   523 //  Handles Listbox events
       
   524 // --------------------------------------------------------------------------
       
   525 // 
       
   526 
       
   527 void CCamInfoListBoxContainer::HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType )
       
   528     {
       
   529     switch( aEventType )
       
   530         {
       
   531         case EEventEnterKeyPressed:
       
   532         case EEventItemDoubleClicked:
       
   533               {
       
   534               iView.HandleCommandL( EAknSoftkeySelect ); 
       
   535               }
       
   536               break;  
       
   537         
       
   538         case EEventItemClicked:
       
   539         case EEventItemSingleClicked:
       
   540             {
       
   541             ShowTooltipL();
       
   542             }
       
   543             break;
       
   544         default:
       
   545             break;
       
   546         }
       
   547     }
       
   548 
       
   549 // --------------------------------------------------------------------------
       
   550 // CCamInfoListBoxContainer::ShowTooltipL
       
   551 // --------------------------------------------------------------------------
       
   552 //
       
   553 void CCamInfoListBoxContainer::ShowTooltipL()
       
   554     {
       
   555     
       
   556     if ( !iTooltipController || ( iDescArray[iListBox->CurrentItemIndex()]->Length() <= 0 ) )
       
   557            {
       
   558            return;
       
   559            }
       
   560        
       
   561     if ( iTooltipIndex != iListBox->CurrentItemIndex() )
       
   562         {
       
   563         // make sure that possible already open tooltip is hidden
       
   564         iTooltipController->HideInfoPopupNote();
       
   565 
       
   566         iTooltipController->SetTextL( *iDescArray[iListBox->CurrentItemIndex()] );     
       
   567         iTooltipController->SetPositionByHighlight( iListBox->HighlightRect() );
       
   568         
       
   569         iTooltipIndex = iListBox->CurrentItemIndex();
       
   570         }
       
   571     
       
   572 
       
   573     iTooltipController->ShowInfoPopupNote(); 
       
   574     
       
   575     }
       
   576     
       
   577  
       
   578 // --------------------------------------------------------------------------
       
   579 // CCamInfoListBoxContainer::ConstructContainerTitleFromResourceL
       
   580 // --------------------------------------------------------------------------
       
   581 //
       
   582 void CCamInfoListBoxContainer::ConstructContainerTitleFromResourceL( TInt aResourceId )
       
   583     {
       
   584     TResourceReader reader;
       
   585     iEikonEnv->CreateResourceReaderLC( reader, aResourceId ); // cleanupstack
       
   586     
       
   587     iListboxTitle = reader.ReadHBufC16L();    
       
   588     
       
   589     CleanupStack::PopAndDestroy(); // reader
       
   590     }
       
   591 
       
   592 
       
   593 // -----------------------------------------------------------------
       
   594 // CCamInfoListBoxContainer::DrawSummaryText (ISO setting)
       
   595 // Draws summary title and description text
       
   596 // -----------------------------------------------------------------
       
   597 
       
   598 void CCamInfoListBoxContainer::DrawSummaryTextL( CWindowGc& aGc ) const
       
   599     {
       
   600     CCamAppUi* appUi = static_cast<CCamAppUi*>( iEikonEnv->AppUi() );
       
   601     appUi->SetTitleL( *iListboxTitle );     
       
   602     
       
   603     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   604     AknsDrawUtils::Background( skin, iBgContext, aGc, Rect() );
       
   605   
       
   606     // Draw summary frame
       
   607     TRect explTxtRect = iExplanationRect;
       
   608     TInt border = iExplIconLayout.Rect().iTl.iX - iExplanationRect.iTl.iX;
       
   609     explTxtRect.Shrink( border/2 , border/2 );
       
   610     AknsDrawUtils::DrawFrame( skin, aGc, iExplanationRect, explTxtRect,
       
   611                               KAknsIIDQsnFrInput, KAknsIIDNone );   //frame
       
   612     
       
   613     AknIconUtils::SetSize( iSummaryBitmapArray[iListBox->CurrentItemIndex()], 
       
   614                            iExplIconLayout.Rect().Size() ); 
       
   615     iExplIconLayout.DrawImage( aGc, 
       
   616                    iSummaryBitmapArray[ iListBox->CurrentItemIndex() ], NULL );
       
   617     
       
   618     TRgb explTitleTxtColor; // same as list highlight text
       
   619     TRgb explTxtColor;      // same as main area text
       
   620     AknsUtils::GetCachedColor( skin, explTitleTxtColor, KAknsIIDQsnTextColors,
       
   621                                EAknsCIQsnTextColorsCG10 );
       
   622     AknsUtils::GetCachedColor( skin, explTxtColor, KAknsIIDQsnTextColors, 
       
   623                                EAknsCIQsnTextColorsCG6 );
       
   624     iExplTitleLayout.DrawText( aGc, 
       
   625                             iTitleArray[ iListBox->CurrentItemIndex() ]->Des(), 
       
   626                             ETrue, explTitleTxtColor ); 
       
   627     AknTextUtils::WrapToArrayL( *iDescArray[iListBox->CurrentItemIndex()],
       
   628                                 iExplTxtLinesLayout[0].TextRect().Width(),
       
   629                                 *iExplTxtLinesLayout[0].Font(), 
       
   630                                 *iCurrentDescLineArray );
       
   631     TInt lCount = Min( iExplLineCount, iCurrentDescLineArray->Count() );                               
       
   632     for ( TInt i = 0; i < lCount; i++ )  
       
   633         {
       
   634         iExplTxtLinesLayout[i].DrawText( aGc, (*iCurrentDescLineArray)[i], 
       
   635                                          ETrue, explTxtColor ); 
       
   636         }     
       
   637     }
       
   638 
       
   639 // --------------------------------------------------------------------------
       
   640 // CCamInfoListBoxContainer::TouchLayout
       
   641 // --------------------------------------------------------------------------
       
   642 //
       
   643 TRect CCamInfoListBoxContainer::TouchLayout()  
       
   644     {
       
   645     TRect statusPaneRect;
       
   646     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane, 
       
   647                                        statusPaneRect );
       
   648     iLayoutAreaRect.BoundingRect( statusPaneRect );
       
   649     // get the rect size for listbox in the layout
       
   650     TAknLayoutRect wholeListboxLayoutRect;
       
   651     wholeListboxLayoutRect.LayoutRect( iLayoutAreaRect, 
       
   652                       AknLayoutScalable_Apps::main_cset_listscroll_pane( 3 ) );   
       
   653     TInt listBoxHeight = iListBox->CalcHeightBasedOnNumOfItems( 
       
   654                                           iListBox->Model()->NumberOfItems() );
       
   655     // get layout for the listbox rect
       
   656     if ( wholeListboxLayoutRect.Rect().Height() < listBoxHeight )
       
   657         {
       
   658         // if scrollbars are used, use scrollbar layout
       
   659         iListboxLayoutRect.LayoutRect( wholeListboxLayoutRect.Rect(), 
       
   660                             AknLayoutScalable_Apps::main_cset_list_pane( 0 ) );
       
   661         }
       
   662     else
       
   663         {
       
   664         iListboxLayoutRect.LayoutRect( wholeListboxLayoutRect.Rect(), 
       
   665                             AknLayoutScalable_Apps::main_cset_list_pane( 1 ) ); 
       
   666         }
       
   667  
       
   668     iTitleTextRectLayout.LayoutText( iLayoutAreaRect, 
       
   669                            AknLayoutScalable_Apps::main_cam_set_pane_t1( 3 ) );
       
   670     
       
   671     return wholeListboxLayoutRect.Rect();
       
   672     }
       
   673 
       
   674 // --------------------------------------------------------------------------
       
   675 // CCamInfoListBoxContainer::NonTouchLayout
       
   676 // --------------------------------------------------------------------------
       
   677 //
       
   678 TRect CCamInfoListBoxContainer::NonTouchLayout()
       
   679     {
       
   680     TAknLayoutRect wholeListboxLayoutRect;
       
   681     wholeListboxLayoutRect.LayoutRect( iLayoutAreaRect, 
       
   682                      AknLayoutScalable_Apps::main_cset6_listscroll_pane( 3 ) );
       
   683     TAknLayoutRect listLayoutRect;
       
   684     listLayoutRect.LayoutRect( iLayoutAreaRect, //1
       
   685                      AknLayoutScalable_Apps::main_cset6_listscroll_pane( 4 ) );
       
   686     TInt listBoxHeight = iListBox->CalcHeightBasedOnNumOfItems( 
       
   687                                           iListBox->Model()->NumberOfItems() );
       
   688     if ( wholeListboxLayoutRect.Rect().Height() < listBoxHeight )
       
   689         {
       
   690         // if scrollbars are used, use scrollbar layout
       
   691         iListboxLayoutRect.LayoutRect( listLayoutRect.Rect(),
       
   692                       AknLayoutScalable_Apps::main_cset_list_pane_copy1( 0 ) );
       
   693         AknLayoutUtils::LayoutVerticalScrollBar( iListBox->ScrollBarFrame(), 
       
   694                         listLayoutRect.Rect(),
       
   695                         AknLayoutScalable_Apps::scroll_pane_cp028_copy1( 0 ) );
       
   696         }
       
   697     else
       
   698         {
       
   699         iListboxLayoutRect.LayoutRect( listLayoutRect.Rect(), 
       
   700                       AknLayoutScalable_Apps::main_cset_list_pane_copy1( 1 ) );  
       
   701         }
       
   702     
       
   703     // Explanation ikon, title, and text layout
       
   704     TAknLayoutRect explParent;
       
   705     explParent.LayoutRect( iLayoutAreaRect,//2
       
   706                           AknLayoutScalable_Apps::main_cset6_text2_pane( 0 ) );
       
   707     TAknLayoutRect explLayoutRect;
       
   708     explLayoutRect.LayoutRect( explParent.Rect(), 
       
   709               AknLayoutScalable_Apps::bg_popup_preview_window_pane_cp03( 0 ) );
       
   710     iExplanationRect = explLayoutRect.Rect();
       
   711 
       
   712     TRect statusPaneRect;
       
   713     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane, 
       
   714                                        statusPaneRect );
       
   715     iExplanationRect.Move( 0, -statusPaneRect.Height() );
       
   716     
       
   717     iExplIconLayout.LayoutRect( iExplanationRect, 
       
   718             AknLayoutScalable_Apps::main_cset6_text2_pane_g1( 0 ) );  
       
   719     iExplTitleLayout.LayoutText( iExplanationRect, 
       
   720             AknLayoutScalable_Apps::main_cset6_text2_pane_t1( 0 ) ); 
       
   721     iExplTitleLayout.LayoutText( iExplanationRect, 
       
   722             AknLayoutScalable_Apps::main_cset6_text2_pane_t1( 0 ) ); 
       
   723 
       
   724     TAknLayoutRect explTxtParent;
       
   725     explTxtParent.LayoutRect( iExplanationRect,
       
   726                              AknLayoutScalable_Apps::list_cset_text2_pane(0) );
       
   727     TAknLayoutScalableParameterLimits listLimits = 
       
   728               AknLayoutScalable_Apps::list_cset_text2_pane_t1_ParamLimits( 0 );
       
   729     iExplLineCount = listLimits.LastRow() + 1;
       
   730     for ( TInt i = 0; i < iExplLineCount; i++ )
       
   731         {
       
   732         TAknLayoutText layoutText;
       
   733         layoutText.LayoutText( explTxtParent.Rect(), 
       
   734                   AknLayoutScalable_Apps::list_cset_text2_pane_t1( 0, 0, i ) );
       
   735         (void) iExplTxtLinesLayout.Append( layoutText ); // Errors are ignored
       
   736         } 
       
   737     
       
   738     TRect ret = wholeListboxLayoutRect.Rect();
       
   739     // Non-touch has a visible title & status panes
       
   740     TRect titlePaneRect;
       
   741     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::ETitlePane, 
       
   742                                        titlePaneRect );
       
   743     ret.Move( 0, -titlePaneRect.Height() - statusPaneRect.Height() );
       
   744     return ret;
       
   745     }
       
   746 // End of File