uifw/AvKon/src/AknTransparentCameraSettingPage.cpp
changeset 0 2f259fa3e83a
child 4 8ca85d2f0db7
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002-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: 
       
    15 *  Support for transparent camera setting pages
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #include "AknTransparentCameraSettingPage.h"
       
    22 
       
    23 // For icon support
       
    24 #include <barsread.h>
       
    25 #include <gulicon.h>
       
    26 #include <AknIconArray.h>
       
    27 
       
    28 // lists
       
    29 #include <aknlists.h>
       
    30 
       
    31 #include <AknTasHook.h>
       
    32 // Used for setting  1 in the radio button 
       
    33 _LIT(KOneSlashT, "1\t");
       
    34 
       
    35 enum TAknTransparentCameraSettingPagePanicCodes
       
    36     {
       
    37     EAknPanicTransparentCameraSettingPageIndexOutOfRange
       
    38     };
       
    39 
       
    40 GLDEF_C void Panic(TAknTransparentCameraSettingPagePanicCodes aPanic)
       
    41     {
       
    42     _LIT(KPanicCat,"AknTransparentCameraSettingPage");
       
    43     User::Panic(KPanicCat, aPanic);
       
    44     }
       
    45 
       
    46 NONSHARABLE_CLASS(CAknTransparentCameraSettingPageExtension) : public CBase
       
    47     {
       
    48     friend class CAknTransparentCameraSettingPage;
       
    49 
       
    50 public:
       
    51     static CAknTransparentCameraSettingPageExtension* NewL(
       
    52         CCoeControl& aOwner );
       
    53     ~CAknTransparentCameraSettingPageExtension();
       
    54 
       
    55 private:
       
    56     CAknTransparentCameraSettingPageExtension( CCoeControl& aOwner );
       
    57     void ConstructL();
       
    58 public: //data
       
    59     
       
    60     CFbsBitmap* iBackground;
       
    61     // Background bitmap's top left corner.
       
    62     TPoint iBitmapPosition;
       
    63     // Background bitmap will be drawn inside this rect (ie. it will be cropped 
       
    64     // if the rect is smaller than the actual bitmap)
       
    65     TRect iBitmapClipRect;
       
    66     TBool iDrawFullBackground;
       
    67     TBool iDrawBackgroundBitmap;
       
    68     TBool iFullScreenMode;
       
    69 
       
    70     TBool iReplaceNaviPane; //replace navi pane with empty contents?
       
    71     TBool iReturn; //user select okay or cancel?
       
    72     TInt iUpdateMode;
       
    73     CActiveSchedulerWait iWait; //owned
       
    74 
       
    75     /**
       
    76      * Extension flags definition.
       
    77      */
       
    78     enum TFlags
       
    79         {
       
    80         ESingleClickEnabled
       
    81         };
       
    82 
       
    83     /**
       
    84      * Extension flags.
       
    85      */
       
    86     TBitFlags iFlags;
       
    87     };
       
    88 
       
    89 CAknTransparentCameraSettingPageExtension* CAknTransparentCameraSettingPageExtension::NewL(
       
    90     CCoeControl& aOwner )
       
    91     {
       
    92     CAknTransparentCameraSettingPageExtension* self =
       
    93         new (ELeave) CAknTransparentCameraSettingPageExtension( aOwner );
       
    94     CleanupStack::PushL(self);
       
    95     self->ConstructL();
       
    96     CleanupStack::Pop(self);
       
    97     return self;
       
    98     }
       
    99 
       
   100 CAknTransparentCameraSettingPageExtension::~CAknTransparentCameraSettingPageExtension()
       
   101     {
       
   102     if(iWait.IsStarted())
       
   103         {
       
   104         CAknEnv::StopSchedulerWaitWithBusyMessage(iWait);
       
   105         }
       
   106     }
       
   107 
       
   108 CAknTransparentCameraSettingPageExtension::CAknTransparentCameraSettingPageExtension(
       
   109     CCoeControl& aOwner )
       
   110     : iDrawFullBackground(ETrue), iDrawBackgroundBitmap(ETrue),
       
   111       iReplaceNaviPane(ETrue),
       
   112       iUpdateMode(CAknSettingPage::EUpdateWhenAccepted)
       
   113     {
       
   114     if ( static_cast<CAknAppUi*>(
       
   115             aOwner.ControlEnv()->AppUi() )->IsSingleClickCompatible() )
       
   116         {
       
   117         iFlags.Set( ESingleClickEnabled );
       
   118         }
       
   119     }
       
   120 
       
   121 void CAknTransparentCameraSettingPageExtension::ConstructL()
       
   122     {
       
   123     }
       
   124 
       
   125 //////////////////////////////////////////////////////////////////////
       
   126 // Construction/Destruction
       
   127 //////////////////////////////////////////////////////////////////////
       
   128 
       
   129 
       
   130 EXPORT_C CAknTransparentCameraSettingPage::CAknTransparentCameraSettingPage( TInt aResourceId, TInt& aCurrentSelectionItem, const MDesCArray* aItemArray):
       
   131     CAknListBoxSettingPage(aResourceId), iOldSelectionIndex(aCurrentSelectionItem), iCurrentSelectionIndex(aCurrentSelectionItem), iItemArray(aItemArray)
       
   132     {
       
   133     AKNTASHOOK_ADD( this, "CAknTransparentCameraSettingPage" );
       
   134     }
       
   135 
       
   136 
       
   137 EXPORT_C CAknTransparentCameraSettingPage::CAknTransparentCameraSettingPage(    
       
   138             const TDesC* aSettingText, 
       
   139             TInt aSettingNumber, 
       
   140             TInt aControlType,
       
   141             TInt aEditorResourceId, 
       
   142             TInt aSettingPageResourceId, 
       
   143             TInt& aCurrentSelectionIndex, 
       
   144             const MDesCArray* aItemArray )
       
   145             :   CAknListBoxSettingPage( 
       
   146                 aSettingText, 
       
   147                 aSettingNumber, 
       
   148                 aControlType, 
       
   149                 aEditorResourceId, 
       
   150                 aSettingPageResourceId ), 
       
   151                 iOldSelectionIndex(aCurrentSelectionIndex), 
       
   152                 iCurrentSelectionIndex(aCurrentSelectionIndex), 
       
   153                 iItemArray(aItemArray)
       
   154     {
       
   155     AKNTASHOOK_ADD( this, "CAknTransparentCameraSettingPage" );
       
   156     }
       
   157 
       
   158 
       
   159 /**
       
   160  * Destructor
       
   161  *
       
   162  */
       
   163 EXPORT_C CAknTransparentCameraSettingPage::~CAknTransparentCameraSettingPage()
       
   164     {   
       
   165     AKNTASHOOK_REMOVE();
       
   166     delete(iInternalItemArray);
       
   167     if (iExtension)
       
   168         delete iExtension;
       
   169     }
       
   170 
       
   171 EXPORT_C void CAknTransparentCameraSettingPage::ConstructL()
       
   172     {
       
   173     BaseConstructL( KAknSettingPageNoEmbeddedSoftKeys );
       
   174     
       
   175     SetDrawBackground(EFalse);  // Enable transparent drawing
       
   176     
       
   177     GenerateInternalArrayAndGiveToListBoxL();
       
   178     
       
   179     iExtension = CAknTransparentCameraSettingPageExtension::NewL( *this );
       
   180 
       
   181     // This updates the CBA 
       
   182     CheckAndSetDataValidity();
       
   183     UpdateCbaL();
       
   184 
       
   185     // Only a reference to the CBase object; not owned
       
   186     CAknSetStyleListBox* listBox = ListBoxControl();
       
   187 
       
   188     CreateBitmapArrayAndGiveToListBoxL();
       
   189         
       
   190     listBox->ItemDrawer()->FormattedCellData()->SetDrawBackground( EFalse );
       
   191     listBox->ItemDrawer()->FormattedCellData()->ToggleDropShadows( ETrue );
       
   192     
       
   193     // Range should be within the valid indices, or -1:
       
   194     // So valid range is >= -1 and also < Count.
       
   195     __ASSERT_ALWAYS( iCurrentSelectionIndex >= -1, Panic(   EAknPanicTransparentCameraSettingPageIndexOutOfRange) );
       
   196     __ASSERT_ALWAYS( iCurrentSelectionIndex < iInternalItemArray->Count(), Panic(   EAknPanicTransparentCameraSettingPageIndexOutOfRange) );
       
   197 
       
   198     listBox->View()->CalcBottomItemIndex();
       
   199     // Set initial highlight to the top element
       
   200     if (FocusToFirstItem())
       
   201         {// Set initial highlight to the top element
       
   202         if ( iInternalItemArray->Count() > 0 )
       
   203             listBox->SetCurrentItemIndex( 0 );
       
   204         }
       
   205     if (FocusToSelectedItem())
       
   206         {// Set initial highlight to the current element.
       
   207         if ( iInternalItemArray->Count() > 0 )
       
   208             {
       
   209             if (iCurrentSelectionIndex != -1)
       
   210                 listBox->SetCurrentItemIndex( iCurrentSelectionIndex );
       
   211             else
       
   212                 listBox->SetCurrentItemIndex( 0 ); // Set at the top if selected is -1
       
   213             }
       
   214         }
       
   215 
       
   216     listBox->SetListBoxObserver(this);
       
   217 
       
   218     // Set the current "pushed in" indication
       
   219     if ( iCurrentSelectionIndex != -1 )
       
   220         listBox->View()->SelectItemL( iCurrentSelectionIndex );
       
   221 
       
   222     // Set the scroller indication off
       
   223     listBox->CreateScrollBarFrameL(ETrue);
       
   224     listBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EOff);
       
   225 
       
   226     // Need to do this to set up the scroll bar model
       
   227     listBox->UpdateScrollBarsL();
       
   228     
       
   229     if(!IsBackgroundDrawingEnabled())
       
   230             listBox->ScrollBarFrame()->DrawBackground(EFalse, EFalse);
       
   231     
       
   232 
       
   233     // Force a size changed
       
   234     SizeChanged();
       
   235 
       
   236     // Construct an appropriate control context for the contained editor areas.
       
   237     // Context produced is owned by CAknSettingPage. 
       
   238     SetEditedItemFrameIID( KAknsIIDQsnFrSetOpt, KAknsIIDQsnFrSetOptCenter );
       
   239 }
       
   240 
       
   241 //---------------------------------------------------------------------------------------------
       
   242 // Note: please call CAknSettingPage::ConstructL() before call this function!
       
   243 //---------------------------------------------------------------------------------------------
       
   244 //
       
   245 EXPORT_C TBool CAknTransparentCameraSettingPage::ExecuteLD( 
       
   246         enum CAknSettingPage::TAknSettingPageUpdateMode aMode, 
       
   247         TBool aReplaceNaviPane )
       
   248     {
       
   249     iExtension->iReplaceNaviPane = aReplaceNaviPane;
       
   250     if(aReplaceNaviPane)
       
   251         {
       
   252         return CAknSettingPage::ExecuteLD( aMode );
       
   253         }
       
   254 
       
   255     CleanupStack::PushL( this ); // Matching Pop is in AttemptExitL
       
   256     iExtension->iUpdateMode = aMode;
       
   257 
       
   258     DynamicInitL();
       
   259     ActivateL();
       
   260     DrawNow();
       
   261 
       
   262     EditorControl()->SetObserver( this );
       
   263     iEikonEnv->EikAppUi()->AddToStackL(this,ECoeStackPriorityDialog);
       
   264 
       
   265     if ( PostDisplayCheckL() )
       
   266         {
       
   267         if (!iExtension->iWait.IsStarted())
       
   268             {
       
   269             iExtension->iWait.Start();
       
   270             }
       
   271         }
       
   272     else
       
   273         AttemptExitL(EFalse);
       
   274     
       
   275     iEikonEnv->EikAppUi()->RemoveFromStack(this);
       
   276     CleanupStack::Pop(); // this
       
   277 
       
   278     TBool res=iExtension->iReturn;
       
   279     delete (this);
       
   280 
       
   281     return res;
       
   282     }
       
   283 
       
   284 //---------------------------------------------------------------------------------------------
       
   285 // Set the flags in extension to indicate user accept settings or cancel it.
       
   286 //---------------------------------------------------------------------------------------------
       
   287 //
       
   288 void CAknTransparentCameraSettingPage::AttemptExitL(TBool aAccept)
       
   289     {
       
   290     if ( OkToExitL( aAccept ) )
       
   291         {
       
   292         DismissL( aAccept );
       
   293         iExtension->iReturn = aAccept;
       
   294 
       
   295         if ( iExtension->iWait.IsStarted() )
       
   296             {
       
   297             CAknEnv::StopSchedulerWaitWithBusyMessage( iExtension->iWait );
       
   298             }
       
   299         else
       
   300             {
       
   301             StopActiveScheduler();
       
   302             }
       
   303         }
       
   304     }
       
   305 
       
   306 //---------------------------------------------------------------------------------------------
       
   307 // Update settings according to update mode
       
   308 //---------------------------------------------------------------------------------------------
       
   309 //
       
   310 EXPORT_C void CAknTransparentCameraSettingPage::HandleControlEventL(
       
   311     CCoeControl* /*aControl*/,TCoeEvent aEventType)
       
   312     {
       
   313     if ( aEventType == EEventStateChanged && iExtension &&
       
   314          iExtension->iUpdateMode == EUpdateWhenChanged )
       
   315         {
       
   316         UpdateSettingL();
       
   317         }
       
   318     }
       
   319 
       
   320 //---------------------------------------------------------------------------------------------
       
   321 // Process user command by modifying flags in extension
       
   322 //---------------------------------------------------------------------------------------------
       
   323 //
       
   324 EXPORT_C void CAknTransparentCameraSettingPage::ProcessCommandL(TInt aCommandId)
       
   325     {
       
   326     if(iExtension->iReplaceNaviPane)
       
   327         {
       
   328         CAknSettingPage::ProcessCommandL(aCommandId);
       
   329         return;
       
   330         }
       
   331 
       
   332     if(!IsEditable() && !(aCommandId == EAknSoftkeyBack || aCommandId == EAknSoftkeyCancel))
       
   333         {
       
   334         return;
       
   335         }
       
   336     
       
   337     HideMenu();
       
   338 
       
   339     // Respond to softkey events
       
   340     switch (aCommandId)
       
   341         {
       
   342         case EAknSoftkeyOk:
       
   343         case EAknSoftkeySelect:  
       
   344         case EAknSoftkeyDone:
       
   345             SelectCurrentItemL(); // has non-trivial implemenations in listbox type 
       
   346                                         // controls to put the selection on the current item
       
   347             AttemptExitL(ETrue);
       
   348             break;
       
   349         case EAknSoftkeyBack:
       
   350         case EAknSoftkeyCancel:
       
   351             AttemptExitL(EFalse);
       
   352             break;
       
   353         case EAknSoftkeyOptions:
       
   354             DisplayMenuL();
       
   355             break;
       
   356         default:
       
   357             break;
       
   358         }
       
   359     }
       
   360 
       
   361 EXPORT_C void CAknTransparentCameraSettingPage::HandleListBoxEventL(CEikListBox* /*aListBox*/, 
       
   362         MEikListBoxObserver::TListBoxEvent aEventType)
       
   363     {
       
   364     switch ( aEventType )
       
   365         {
       
   366         case MEikListBoxObserver::EEventItemSingleClicked:
       
   367         case MEikListBoxObserver::EEventEnterKeyPressed:
       
   368         case MEikListBoxObserver::EEventItemDoubleClicked:
       
   369         case MEikListBoxObserver::EEventItemActioned:
       
   370             {
       
   371             SelectCurrentItemL();
       
   372             AttemptExitL( ETrue );
       
   373             break;
       
   374             }
       
   375             
       
   376         case MEikListBoxObserver::EEventFlickStopped:   // fallthrough
       
   377         case MEikListBoxObserver::EEventPanningStopped:
       
   378             {
       
   379             // The current item index (highlighted item) of the listbox control
       
   380             // has been changed when starting the dragging / flicking, so
       
   381             // it must be reverted back to represent the same item as
       
   382             // the current selection in the setting page.
       
   383             // Only in single click enabled applications.
       
   384             if ( iExtension &&
       
   385                  iExtension->iFlags.IsSet(
       
   386                          CAknTransparentCameraSettingPageExtension::ESingleClickEnabled ) )
       
   387                 {
       
   388                 ListBoxControl()->View()->SetCurrentItemIndex(
       
   389                     iCurrentSelectionIndex );
       
   390                 }
       
   391             break;
       
   392             }
       
   393 
       
   394         default:
       
   395             break;
       
   396         }
       
   397     }
       
   398 
       
   399 
       
   400 EXPORT_C void CAknTransparentCameraSettingPage::UpdateSettingL()
       
   401     {
       
   402     }
       
   403 
       
   404 EXPORT_C CAknSetStyleListBox* CAknTransparentCameraSettingPage::ListBoxControl() const
       
   405     {
       
   406     return STATIC_CAST( CAknSetStyleListBox*, EditorControl());
       
   407     }
       
   408 
       
   409 EXPORT_C void CAknTransparentCameraSettingPage::DynamicInitL()
       
   410     {
       
   411     }
       
   412 
       
   413 void CAknTransparentCameraSettingPage::SetRadioButtonSelectionL( TInt aPushed )
       
   414     {
       
   415     // reference listbox's view; not owned here
       
   416     CListBoxView* view = ListBoxControl()->View();
       
   417     view->SelectItemL( aPushed );
       
   418     if ( aPushed != iOldSelectionIndex )
       
   419         {
       
   420         view->DeselectItem( iOldSelectionIndex );
       
   421         iOldSelectionIndex = aPushed;
       
   422         }
       
   423     } 
       
   424 
       
   425 EXPORT_C void CAknTransparentCameraSettingPage::SelectCurrentItemL()
       
   426     {
       
   427     iCurrentSelectionIndex = ListBoxControl()->CurrentItemIndex();
       
   428     SetRadioButtonSelectionL( iCurrentSelectionIndex );
       
   429     UpdateSettingL();
       
   430     if( iSettingPageObserver )
       
   431         iSettingPageObserver->HandleSettingPageEventL(this, MAknSettingPageObserver::EEventSettingChanged);
       
   432     } 
       
   433 
       
   434 
       
   435 EXPORT_C void CAknTransparentCameraSettingPage::SetItemArrayAndSelectionL( const MDesCArray* aItemArray, TInt aPushed )
       
   436     {
       
   437     SetRadioButtonSelectionL(0);  // Put the selection into a known state
       
   438     iItemArray = aItemArray;
       
   439     GenerateInternalArrayAndGiveToListBoxL();
       
   440 
       
   441     // This updates the CBA 
       
   442     CheckAndSetDataValidity();
       
   443     UpdateCbaL();
       
   444     SizeChanged();
       
   445     SetRadioButtonSelectionL(aPushed);
       
   446 
       
   447     DrawDeferred();
       
   448     }
       
   449 
       
   450 void CAknTransparentCameraSettingPage::GenerateInternalArrayAndGiveToListBoxL()
       
   451     {
       
   452 
       
   453     delete iInternalItemArray;
       
   454     iInternalItemArray = 0;
       
   455     
       
   456     // Make a new owned text array from the input one with the "Pushed in" icon index:
       
   457     iInternalItemArray = new(ELeave)CDesCArrayFlat(1);
       
   458     TInt nItems = iItemArray->MdcaCount();
       
   459 
       
   460     for (TInt ii=0; ii<nItems; ii++)
       
   461         {
       
   462         // Fill up the control-owned space for the modified buffers:
       
   463         TInt newLen = (iItemArray->MdcaPoint(ii)).Length() + KOneSlashT().Length();
       
   464         HBufC* newText = HBufC::NewMaxLC( newLen ); 
       
   465         TPtr newTPtr = newText->Des();
       
   466         newTPtr.Copy( KOneSlashT );
       
   467         newTPtr.Append( iItemArray->MdcaPoint(ii) );
       
   468         // A copy of the new buffer goes to the internal itemarray:
       
   469         iInternalItemArray->AppendL(newTPtr); 
       
   470         CleanupStack::PopAndDestroy(); // newText
       
   471         }
       
   472 
       
   473     // Only a reference to the CBase object; not owned
       
   474     CAknSetStyleListBox* listBox = ListBoxControl();
       
   475 
       
   476     // Set the text data
       
   477     CTextListBoxModel* model=listBox->Model();
       
   478     model->SetItemTextArray(iInternalItemArray);
       
   479     model->SetOwnershipType(ELbmDoesNotOwnItemArray);
       
   480 
       
   481     }
       
   482 
       
   483 /**
       
   484  * Writes the internal state of the control and its components to aStream.
       
   485  * Does nothing in release mode.
       
   486  * Designed to be overidden and base called by subclasses.
       
   487  */
       
   488 #ifndef _DEBUG
       
   489 EXPORT_C void CAknTransparentCameraSettingPage::WriteInternalStateL(RWriteStream& /*aWriteStream*/) const
       
   490     {}
       
   491 #else
       
   492 EXPORT_C void CAknTransparentCameraSettingPage::WriteInternalStateL(RWriteStream& aWriteStream) const
       
   493     {
       
   494     CAknSettingPage::WriteInternalStateL(aWriteStream);
       
   495     }
       
   496 #endif
       
   497 
       
   498 /**
       
   499 * Handles the size change events.
       
   500 */
       
   501 EXPORT_C void CAknTransparentCameraSettingPage::SizeChanged()
       
   502     {
       
   503     CAknListBoxSettingPage::SizeChanged();    
       
   504     }      
       
   505 
       
   506 /**
       
   507 * Draws the setting page on top of the camera feed.
       
   508 */
       
   509 EXPORT_C void CAknTransparentCameraSettingPage::Draw(const TRect &/*aRect*/) const
       
   510     {
       
   511     
       
   512     // The draw is called only when setting page is drawn the first time
       
   513     // After first time, the drawing is only made on relevant parts in 
       
   514     // ChangeBackground-method
       
   515     
       
   516     TRect parentRect = Rect();  // this will be used a lot in this routine
       
   517 
       
   518 	CWindowGc& gc = SystemGc();
       
   519         
       
   520     MAknsControlContext* ccBg = AknsDrawUtils::ControlContext(this);
       
   521 	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   522 
       
   523     // Draw black background if full screen in use
       
   524 	if (iExtension->iFullScreenMode)
       
   525 	    {
       
   526         gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   527         gc.SetPenStyle(CGraphicsContext::ENullPen);
       
   528         gc.SetBrushColor(KRgbBlack);
       
   529         gc.DrawRect(parentRect); // in fullscreen control size is EScreen
       
   530         }
       
   531 	else // draw skinbackground
       
   532         {
       
   533 	    TRect mainPaneRect;
       
   534 	   	AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
       
   535         TRect bgRect(TPoint(0, 0), mainPaneRect.Size());
       
   536         
       
   537         if (iExtension->iDrawBackgroundBitmap && ccBg != NULL && skin != NULL)
       
   538             {
       
   539             AknsDrawUtils::DrawBackground (skin, 
       
   540                                            ccBg, 
       
   541                                            NULL, 
       
   542                                            gc,
       
   543                                            parentRect.iTl,
       
   544                                            parentRect,                                       
       
   545                                            KAknsDrawParamDefault);
       
   546             }
       
   547         else
       
   548             {
       
   549             gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   550             gc.SetPenStyle(CGraphicsContext::ENullPen);
       
   551             gc.SetBrushColor(KRgbWhite);
       
   552             gc.DrawRect (bgRect);
       
   553             }
       
   554         }
       
   555         
       
   556     // draw viewfinder if available
       
   557 	if(iExtension->iBackground)
       
   558         {         
       
   559         gc.SetClippingRect(iExtension->iBitmapClipRect);
       
   560         
       
   561         gc.BitBlt(iExtension->iBitmapPosition, iExtension->iBackground);
       
   562         gc.CancelClippingRect();
       
   563         }  
       
   564     }
       
   565 
       
   566 void CAknTransparentCameraSettingPage::CreateBitmapArrayAndGiveToListBoxL()
       
   567     {
       
   568     // This method is more or less a verbatim copy of
       
   569     // CAknPopupField::InitialiseRadioButtonBitmapsL
       
   570 
       
   571     CAknSetStyleListBox* listBox = ListBoxControl();
       
   572     
       
   573     // In case CAknPopupSettingList has already created the icons
       
   574     if ( listBox->ItemDrawer()->FormattedCellData()->IconArray() )
       
   575         {
       
   576         listBox->ItemDrawer()->FormattedCellData()->IconArray()->ResetAndDestroy();
       
   577         delete (listBox->ItemDrawer()->FormattedCellData()->IconArray());
       
   578         }
       
   579 
       
   580     TResourceReader reader;
       
   581     
       
   582     iCoeEnv->CreateResourceReaderLC(reader, R_AVKON_SETTING_PAGE_RADIOBUTTON_ICONS);
       
   583 
       
   584     reader.ReadInt16(); //not needed, simple or complex
       
   585 
       
   586     HBufC* bmpFile = reader.ReadHBufCL();
       
   587     TInt count = reader.ReadInt16(); // count
       
   588     
       
   589     if(count<2)
       
   590         User::Leave(KErrCorrupt);
       
   591     
       
   592     TInt32 bmpSelected = reader.ReadInt32();
       
   593     TInt32 bmpSelectedM = reader.ReadInt32();
       
   594     TInt32 bmp = reader.ReadInt32();
       
   595     TInt32 bmpM = reader.ReadInt32();
       
   596     CleanupStack::PopAndDestroy(); // reader
       
   597 
       
   598     if (bmpFile == NULL)
       
   599         User::Leave(KErrCorrupt);
       
   600     
       
   601     CleanupStack::PushL(bmpFile);
       
   602 
       
   603     CArrayPtr<CGulIcon>* icons = new(ELeave) CAknIconArray(4);
       
   604     // put on the cleanup stack until ownership is transferred
       
   605     CleanupStack::PushL( icons );
       
   606 
       
   607     // create normally colored icons
       
   608     CreateIconAndAddToArrayL( icons,
       
   609                               KAknsIIDQgnIndiRadiobuttOn,
       
   610                               EAknsCIQsnIconColorsCG14,
       
   611                               *bmpFile,
       
   612                               bmpSelected,
       
   613                               bmpSelectedM );
       
   614 
       
   615     CreateIconAndAddToArrayL( icons,
       
   616                               KAknsIIDQgnIndiRadiobuttOff,
       
   617                               EAknsCIQsnIconColorsCG14,
       
   618                               *bmpFile,
       
   619                               bmp,
       
   620                               bmpM );
       
   621 
       
   622     // create highlight colored icons
       
   623     CreateIconAndAddToArrayL( icons,
       
   624                               KAknsIIDQgnIndiRadiobuttOn,
       
   625                               EAknsCIQsnIconColorsCG18,
       
   626                               *bmpFile,
       
   627                               bmpSelected,
       
   628                               bmpSelectedM );
       
   629 
       
   630     CreateIconAndAddToArrayL( icons,
       
   631                               KAknsIIDQgnIndiRadiobuttOff,
       
   632                               EAknsCIQsnIconColorsCG18,
       
   633                               *bmpFile,
       
   634                               bmp,
       
   635                               bmpM );
       
   636 
       
   637 
       
   638     __ASSERT_DEBUG(listBox != NULL, Panic(EAknPanicRadioButtonSettingPageListDoesntExist));
       
   639     listBox->ItemDrawer()->FormattedCellData()->SetIconArrayL( icons ); // ownership transferred
       
   640     listBox->ItemDrawer()->FormattedCellData()->UseHighlightIconSwapping( ETrue );
       
   641     CleanupStack::Pop(); // icons - ownership now transferred; do not destroy
       
   642     CleanupStack::PopAndDestroy(); // bmpfile
       
   643     }
       
   644 /**
       
   645  *  Reserved method derived from CCoeControl
       
   646  */
       
   647 EXPORT_C void CAknTransparentCameraSettingPage::Reserved_2()
       
   648     {
       
   649     }
       
   650 
       
   651 /**
       
   652 * Setting Page reserved methods 
       
   653 */ 
       
   654 EXPORT_C void CAknTransparentCameraSettingPage::CAknSettingPage_Reserved_1()
       
   655     {
       
   656     }
       
   657 EXPORT_C void CAknTransparentCameraSettingPage::CAknSettingPage_Reserved_2()
       
   658     {
       
   659     }
       
   660 /**
       
   661 * CAknListBoxSettingPage-derived reserved methods
       
   662 */
       
   663 EXPORT_C void CAknTransparentCameraSettingPage::CAknListBoxSettingPage_Reserved_1()
       
   664     {
       
   665     }
       
   666     
       
   667 EXPORT_C void CAknTransparentCameraSettingPage::ChangeBackground(CFbsBitmap* aBitmap)
       
   668     {
       
   669     iExtension->iBackground = aBitmap;    
       
   670     
       
   671     if (iExtension->iBackground)
       
   672         {
       
   673         DrawNow();
       
   674         }       
       
   675     }
       
   676 
       
   677 EXPORT_C void CAknTransparentCameraSettingPage::SetBitmapPositionAndClipRect(
       
   678     const TPoint aPoint, const TRect aRect)
       
   679     {
       
   680     SetBitmapPositionAndClipRect(aPoint, aRect, EFalse);
       
   681     }
       
   682 
       
   683 EXPORT_C void CAknTransparentCameraSettingPage::SetBitmapPositionAndClipRect(
       
   684     const TPoint aPoint, const TRect aRect, const TBool aFullScreenUsed)
       
   685     {
       
   686     iExtension->iBitmapPosition = aPoint;
       
   687     iExtension->iBitmapClipRect = aRect;
       
   688     iExtension->iFullScreenMode = aFullScreenUsed;
       
   689 
       
   690 
       
   691     // cannot redraw here because the skin context is not updated
       
   692     if(aFullScreenUsed)
       
   693         {
       
   694         TRect newRect;
       
   695         iExtension->iDrawBackgroundBitmap = EFalse;
       
   696         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, newRect);
       
   697         SetRect(newRect);
       
   698         }
       
   699     else
       
   700         {
       
   701         iExtension->iDrawBackgroundBitmap = ETrue;
       
   702         }
       
   703     }
       
   704 
       
   705 EXPORT_C void CAknTransparentCameraSettingPage::HandleResourceChange(TInt aType)
       
   706     {
       
   707     if( aType == KAknsMessageSkinChange )
       
   708     	{
       
   709     	TRAP_IGNORE( CreateBitmapArrayAndGiveToListBoxL() );    	
       
   710     	}
       
   711     
       
   712     CAknListBoxSettingPage::HandleResourceChange(aType);
       
   713     }
       
   714 
       
   715 EXPORT_C TKeyResponse CAknTransparentCameraSettingPage::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType) 
       
   716     {
       
   717 
       
   718 	// Only handle other key events if we're focused
       
   719 	TKeyResponse response = CAknSettingPage::OfferKeyEventL(aKeyEvent, aType);
       
   720 
       
   721 	if (IsFocused())
       
   722 		{
       
   723 		if (EditorControl())
       
   724 			{
       
   725 			// Abstraction of key events: Escape is handled like Cancel 
       
   726 			// OK is handled like select.
       
   727 			if ( aType == EEventKey && response == EKeyWasConsumed)
       
   728 			    if ( aKeyEvent.iScanCode == EStdKeyUpArrow ||
       
   729                      aKeyEvent.iScanCode == EStdKeyDownArrow )
       
   730 			        ChangeBackground(iExtension->iBackground);
       
   731 			}
       
   732 		}
       
   733     
       
   734 	return response;	// Keys can fall through to menus
       
   735 
       
   736     }
       
   737 
       
   738 // End of File