uifw/AvKon/src/AknListBoxSettingPage.cpp
changeset 0 2f259fa3e83a
child 15 08e69e956a8c
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002 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 * Intermediate class for setting pages with listboxes in them
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include "AknListBoxSettingPage.h"
       
    21 #include "AknUtils.h"
       
    22 
       
    23 #include <gulicon.h>
       
    24 
       
    25 #include <AknTasHook.h>
       
    26 // Skins support
       
    27 #include <AknsDrawUtils.h>
       
    28 
       
    29 #include <AknLayout2ScalableDef.h>
       
    30 #include <aknlayoutscalable_avkon.cdl.h>
       
    31 #include <layoutmetadata.cdl.h>
       
    32 
       
    33 #include <aknlists.h>
       
    34 
       
    35 //
       
    36 // Constructor for CAknListBoxSettingPage
       
    37 //
       
    38 
       
    39 /**
       
    40 *
       
    41 * Empty implementation of constructors for the ancestor of listbox-hosting setting pages
       
    42 *
       
    43 */
       
    44 CAknListBoxSettingPage::CAknListBoxSettingPage( TInt aSettingPageResourceId ) : CAknSettingPage( aSettingPageResourceId )
       
    45 	{
       
    46 	AKNTASHOOK_ADD( this, "CAknListBoxSettingPage" );
       
    47 	}
       
    48 
       
    49 CAknListBoxSettingPage::CAknListBoxSettingPage(	
       
    50 					const TDesC* aSettingText, 
       
    51 					TInt aSettingNumber, 
       
    52 					TInt aControlType,
       
    53 					TInt aEditorResourceId, 
       
    54 					TInt aSettingPageResourceId )
       
    55 					:	CAknSettingPage( 
       
    56 						aSettingText, 
       
    57 						aSettingNumber, 
       
    58 						aControlType, 
       
    59 						aEditorResourceId, 
       
    60 						aSettingPageResourceId ) 
       
    61 						
       
    62 	{
       
    63 	AKNTASHOOK_ADD( this, "CAknListBoxSettingPage" );
       
    64 	}
       
    65 
       
    66 EXPORT_C void CAknListBoxSettingPage::HandleListBoxEventL(CEikListBox* /*aListBox*/, MEikListBoxObserver::TListBoxEvent /*aEventType*/)
       
    67 	{
       
    68 	}
       
    69 
       
    70 EXPORT_C void CAknListBoxSettingPage::CheckAndSetDataValidity()
       
    71 	{
       
    72 	if ( ListBoxControl() )
       
    73 		{
       
    74 		SetDataValidity( ListBoxControl()->Model()->NumberOfItems()  > 0 ); // Even 1 item is OK. Might not be selected!
       
    75 		}
       
    76 	}
       
    77 
       
    78 EXPORT_C void CAknListBoxSettingPage::UpdateCbaL()
       
    79 	{
       
    80 	CAknSettingPage::UpdateCbaL();
       
    81 	}
       
    82 
       
    83 
       
    84 
       
    85 EXPORT_C void CAknListBoxSettingPage::SizeChanged ()
       
    86 	{
       
    87 	StandardSettingPageLayout();  // Must be part of any re-implementation
       
    88 
       
    89 	CEikListBox* listbox = ListBoxControl();
       
    90 
       
    91     TRect rect( SettingItemContentRect( ETrue ) );
       
    92 	TRect totalRect( rect );
       
    93 
       
    94 	if ( listbox )
       
    95 	    {
       
    96 	    // The maximum lines for the listbox.
       
    97         TAknLayoutScalableParameterLimits listBoxLimits(
       
    98             AknLayoutScalable_Avkon::list_set_graphic_pane_copy1_ParamLimits() );
       
    99 
       
   100         TInt maxNumberOfRows = listBoxLimits.LastRow() + 1;
       
   101         TInt numItemsShown = Min( listbox->Model()->NumberOfItems(),
       
   102                                   maxNumberOfRows );
       
   103 
       
   104         // The layout for max items is used for empty note display.
       
   105         if ( numItemsShown == 0 )
       
   106             {
       
   107             numItemsShown = maxNumberOfRows;
       
   108             }
       
   109         
       
   110         // Transparent setting page has different layout data
       
   111         // for both portrait and landscape
       
   112         if ( !IsBackgroundDrawingEnabled() )
       
   113             {
       
   114             // Transparent does not have as many items as normal list.
       
   115             if ( numItemsShown > 6 )
       
   116                 {
       
   117                 numItemsShown = 6;
       
   118                 }
       
   119             
       
   120             numItemsShown += 6; // skip the normal varieties
       
   121             }
       
   122         else
       
   123             {
       
   124             if ( numItemsShown > 6 )
       
   125                 {
       
   126                 numItemsShown += 12; // skip the transparent varieties
       
   127                 }
       
   128             }
       
   129         
       
   130         AknLayoutUtils::LayoutControl(
       
   131             listbox,
       
   132             rect, 
       
   133             AknLayoutScalable_Avkon::list_set_pane_copy1(
       
   134                 numItemsShown - 1 ) );
       
   135         
       
   136         totalRect = listbox->Rect();
       
   137         
       
   138         // Note the scrollbar is not showing in transparent setting page.
       
   139         AknLayoutUtils::LayoutVerticalScrollBar(
       
   140             listbox->ScrollBarFrame(),
       
   141             Rect(),
       
   142             TAknWindowComponentLayout::Compose(
       
   143                 AknLayoutScalable_Avkon::settings_container_pane(),
       
   144                 TAknWindowComponentLayout::Compose(
       
   145                     AknLayoutScalable_Avkon::listscroll_set_pane_copy1(),
       
   146                     AknLayoutScalable_Avkon::scroll_pane_cp121_copy1() ) ) );
       
   147 	    }
       
   148 	
       
   149 	TAknLayoutRect layoutRect;
       
   150 	layoutRect.LayoutRect(
       
   151 	    totalRect,
       
   152         AknLayoutScalable_Avkon::set_opt_bg_pane_g1_copy1() );
       
   153     SetEditedItemFrameRects( totalRect, layoutRect.Rect() );
       
   154 	}
       
   155 
       
   156 EXPORT_C void CAknListBoxSettingPage::Draw(const TRect& aRect) const
       
   157 	{
       
   158 	CAknSettingPage::BaseDraw(aRect);
       
   159 	}
       
   160 
       
   161 TBool CAknListBoxSettingPage::FocusToSelectedItem()
       
   162 	{
       
   163 	return !FocusToFirstItem(); // This determines whether to use FocusToFirstItem or FocusToSelectedItem.
       
   164 	}
       
   165 
       
   166 TBool CAknListBoxSettingPage::FocusToFirstItem()
       
   167 	{
       
   168 	return EFalse; 
       
   169 	}
       
   170 
       
   171 void CAknListBoxSettingPage::CreateIconAndAddToArrayL(
       
   172     CArrayPtr<CGulIcon>*& aIconArray,
       
   173     const TAknsItemID& aId,
       
   174     const TInt aColorIndex,
       
   175     const TDesC& aBmpFile,
       
   176     const TInt32 aBmp,
       
   177     const TInt32 aBmpM )
       
   178     {
       
   179     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   180 
       
   181     CFbsBitmap* bitmap = 0;
       
   182     CFbsBitmap* mask = 0;
       
   183 
       
   184     AknsUtils::CreateColorIconLC( skin,
       
   185                                   aId,
       
   186                                   KAknsIIDQsnIconColors,
       
   187                                   aColorIndex,
       
   188                                   bitmap,
       
   189                                   mask,
       
   190                                   aBmpFile,
       
   191                                   aBmp,
       
   192                                   aBmpM,
       
   193                                   KRgbBlack );
       
   194 
       
   195     CGulIcon* gulicon = CGulIcon::NewL( bitmap, mask ); // ownership passed
       
   196     CleanupStack::PushL( gulicon );
       
   197     
       
   198     aIconArray->AppendL( gulicon );
       
   199     CleanupStack::Pop( 3 ); // mask, bitmap, gulicon
       
   200     }
       
   201 
       
   202 
       
   203 /**
       
   204 * CAknListBoxSettingPage reserved methods
       
   205 */
       
   206 EXPORT_C void CAknListBoxSettingPage::CAknListBoxSettingPage_Reserved_1()
       
   207 	{
       
   208 	}
       
   209 
       
   210 // End of File