uifw/AvKon/src/AknRadioButtonSettingPage.cpp
branchRCL_3
changeset 56 d48ab3b357f1
parent 55 aecbbf00d063
child 59 978afdc0236f
equal deleted inserted replaced
55:aecbbf00d063 56:d48ab3b357f1
     1 /*
     1 /*
     2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    73 
    73 
    74     /**
    74     /**
    75      * Extension flags.
    75      * Extension flags.
    76      */
    76      */
    77     TBitFlags iFlags;
    77     TBitFlags iFlags;
       
    78 
       
    79     /**
       
    80      * Item that received pen down event
       
    81      */
       
    82     TInt iPenDownOnItem;
       
    83     
       
    84     /**
       
    85      * Is selection valid
       
    86      */
       
    87     TBool iIsValidSelection;
       
    88     
    78     };
    89     };
    79 // end of CAknRadioButtonSettingPageExtension class definition
    90 // end of CAknRadioButtonSettingPageExtension class definition
    80 
    91 
    81 
    92 
    82 CAknRadioButtonSettingPageExtension::CAknRadioButtonSettingPageExtension(
    93 CAknRadioButtonSettingPageExtension::CAknRadioButtonSettingPageExtension(
    83     CCoeControl& aOwner ) :
    94     CCoeControl& aOwner ) :
    84     iOldFocusedItemIndex(-1), iIsDragged( EFalse )
    95     iOldFocusedItemIndex( -1 ),
       
    96     iIsDragged( EFalse ),
       
    97     iPenDownOnItem ( KErrNotFound ),
       
    98     iIsValidSelection( ETrue )
    85     {
    99     {
    86     if ( static_cast<CAknAppUi*>(
   100     if ( static_cast<CAknAppUi*>(
    87             aOwner.ControlEnv()->AppUi() )->IsSingleClickCompatible() )
   101             aOwner.ControlEnv()->AppUi() )->IsSingleClickCompatible() )
    88         {
   102         {
    89         iFlags.Set( ESingleClickEnabled );
   103         iFlags.Set( ESingleClickEnabled );
   227         iExtension = new (ELeave) CAknRadioButtonSettingPageExtension( *this );
   241         iExtension = new (ELeave) CAknRadioButtonSettingPageExtension( *this );
   228 		}
   242 		}
   229 		
   243 		
   230     switch ( aEventType )
   244     switch ( aEventType )
   231         {
   245         {
       
   246         case MEikListBoxObserver::EEventPenDownOnItem:
       
   247             {
       
   248             if ( iExtension )
       
   249                 {
       
   250                 iExtension->iPenDownOnItem = ListBoxControl()->CurrentItemIndex();
       
   251                 }
       
   252             break;
       
   253             }
   232         case MEikListBoxObserver::EEventItemSingleClicked:
   254         case MEikListBoxObserver::EEventItemSingleClicked:
   233         case MEikListBoxObserver::EEventItemDoubleClicked:
   255         case MEikListBoxObserver::EEventItemDoubleClicked:
   234             {
   256             {
   235             SelectCurrentItemL();
   257             SelectCurrentItemL();
   236             AttemptExitL( ETrue );
   258             AttemptExitL( ETrue );
   245             // it must be reverted back to represent the same item as
   267             // it must be reverted back to represent the same item as
   246             // the current selection in the setting page.
   268             // the current selection in the setting page.
   247             // Only in single click enabled applications.
   269             // Only in single click enabled applications.
   248             if ( iExtension &&
   270             if ( iExtension &&
   249                  iExtension->iFlags.IsSet(
   271                  iExtension->iFlags.IsSet(
   250                      CAknRadioButtonSettingPageExtension::ESingleClickEnabled ) )
   272                      CAknRadioButtonSettingPageExtension::ESingleClickEnabled ) &&
       
   273                  iCurrentSelectionIndex >= 0 &&
       
   274                  iCurrentSelectionIndex < ListBoxControl()->Model()->NumberOfItems() )
   251                 {
   275                 {
   252                 ListBoxControl()->View()->SetCurrentItemIndex(
   276                 ListBoxControl()->View()->SetCurrentItemIndex(
   253                     iCurrentSelectionIndex );
   277                     iCurrentSelectionIndex );
   254                 }
   278                 }
   255             break;
   279             break;
   283 		view->SelectItemL( aPushed );
   307 		view->SelectItemL( aPushed );
   284 		}
   308 		}
   285 	} 
   309 	} 
   286 
   310 
   287 EXPORT_C void CAknRadioButtonSettingPage::SelectCurrentItemL()
   311 EXPORT_C void CAknRadioButtonSettingPage::SelectCurrentItemL()
   288 	{
   312 	{   
   289     iCurrentSelectionIndex = ListBoxControl()->CurrentItemIndex();
   313     if ( ListBoxControl()->IsHighlightEnabled() || 
       
   314             ( iExtension && iExtension->iIsValidSelection ) )
       
   315         {
       
   316         iCurrentSelectionIndex = ListBoxControl()->CurrentItemIndex();
       
   317         }
       
   318     else
       
   319         {
       
   320         ListBoxControl()->SetCurrentItemIndex ( iCurrentSelectionIndex );
       
   321         }
       
   322 
   290     SetRadioButtonSelectionL( iCurrentSelectionIndex );
   323     SetRadioButtonSelectionL( iCurrentSelectionIndex );
   291 	UpdateSettingL();
   324 	UpdateSettingL();
   292 	if( iSettingPageObserver )
   325 	if( iSettingPageObserver )
   293 		iSettingPageObserver->HandleSettingPageEventL(this, MAknSettingPageObserver::EEventSettingChanged);
   326 		iSettingPageObserver->HandleSettingPageEventL(this, MAknSettingPageObserver::EEventSettingChanged);
   294 	} 
   327 	} 
   452 EXPORT_C void CAknRadioButtonSettingPage::HandlePointerEventL(const TPointerEvent& aPointerEvent)
   485 EXPORT_C void CAknRadioButtonSettingPage::HandlePointerEventL(const TPointerEvent& aPointerEvent)
   453     {
   486     {
   454     TPointerEvent& event = const_cast<TPointerEvent&>( aPointerEvent );
   487     TPointerEvent& event = const_cast<TPointerEvent&>( aPointerEvent );
   455     event.iModifiers &= ~EModifierShift;
   488     event.iModifiers &= ~EModifierShift;
   456     event.iModifiers &= ~EModifierCtrl;
   489     event.iModifiers &= ~EModifierCtrl;
   457 
   490     
       
   491     if ( iExtension )
       
   492         {
       
   493         TInt index ( KErrNotFound );
       
   494         ListBoxControl()->View()->XYPosToItemIndex( 
       
   495             aPointerEvent.iPosition, index );
       
   496         if ( index == iExtension->iPenDownOnItem 
       
   497                 && iExtension->iPenDownOnItem != KErrNotFound )
       
   498             {
       
   499             iExtension->iIsValidSelection = ETrue;
       
   500             }
       
   501         else
       
   502             {
       
   503             iExtension->iIsValidSelection = EFalse;
       
   504             }
       
   505         }
   458     CAknListBoxSettingPage::HandlePointerEventL( aPointerEvent );
   506     CAknListBoxSettingPage::HandlePointerEventL( aPointerEvent );
   459     }
   507     }
   460 
   508 
   461 EXPORT_C void* CAknRadioButtonSettingPage::ExtensionInterface( TUid /*aInterface*/ ) 
   509 EXPORT_C void* CAknRadioButtonSettingPage::ExtensionInterface( TUid /*aInterface*/ ) 
   462     { 
   510     { 
   475 * Setting Page reserved methods 
   523 * Setting Page reserved methods 
   476 */ 
   524 */ 
   477 EXPORT_C void CAknRadioButtonSettingPage::HandleResourceChange(TInt aType)
   525 EXPORT_C void CAknRadioButtonSettingPage::HandleResourceChange(TInt aType)
   478 	{
   526 	{
   479     if( aType == KAknsMessageSkinChange )
   527     if( aType == KAknsMessageSkinChange )
   480     	{
   528         {
   481     	TRAP_IGNORE( InitialiseRadioButtonBitmapsL() );    	
   529         TRAP_IGNORE( InitialiseRadioButtonBitmapsL() );    	
   482     	}
   530         }
   483 	
   531     else if( aType == KEikMessageFadeAllWindows )
       
   532         {
       
   533         if ( iExtension )
       
   534             {
       
   535             iExtension->iIsValidSelection = EFalse;
       
   536             }
       
   537         }
   484 	CAknListBoxSettingPage::HandleResourceChange(aType);
   538 	CAknListBoxSettingPage::HandleResourceChange(aType);
   485 	}
   539 	}
   486 
   540 
   487 EXPORT_C void CAknRadioButtonSettingPage::CAknSettingPage_Reserved_1()
   541 EXPORT_C void CAknRadioButtonSettingPage::CAknSettingPage_Reserved_1()
   488 	{
   542 	{
   496 */
   550 */
   497 EXPORT_C void CAknRadioButtonSettingPage::CAknListBoxSettingPage_Reserved_1()
   551 EXPORT_C void CAknRadioButtonSettingPage::CAknListBoxSettingPage_Reserved_1()
   498 	{
   552 	{
   499 	}
   553 	}
   500 
   554 
       
   555 //---------------------------------------------------------------------------------------
       
   556 // CAknRadioButtonSettingPage::ProcessCommandL()
       
   557 // Processes events from the softkeys. (Or translated from key events)
       
   558 //---------------------------------------------------------------------------------------
       
   559 //
       
   560 EXPORT_C void CAknRadioButtonSettingPage::ProcessCommandL( TInt aCommandId )
       
   561     {
       
   562     if ( !EnableSingleClickHighlight( aCommandId ) )
       
   563         {
       
   564         // no single click mode was enabled, just call the base class method
       
   565         CAknSettingPage::ProcessCommandL( aCommandId );
       
   566         }
       
   567     }
       
   568 
   501 // End of File
   569 // End of File