uifw/AvKon/src/AknRadioButtonSettingPage.cpp
branchRCL_3
changeset 38 c52421ed5f07
parent 15 08e69e956a8c
child 51 fcdfafb36fe7
equal deleted inserted replaced
29:a8834a2e9a96 38:c52421ed5f07
    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), iIsDragged( EFalse ), 
       
    96     iIsValidSelection( ETrue ),
       
    97     iPenDownOnItem ( KErrNotFound )
    85     {
    98     {
    86     if ( static_cast<CAknAppUi*>(
    99     if ( static_cast<CAknAppUi*>(
    87             aOwner.ControlEnv()->AppUi() )->IsSingleClickCompatible() )
   100             aOwner.ControlEnv()->AppUi() )->IsSingleClickCompatible() )
    88         {
   101         {
    89         iFlags.Set( ESingleClickEnabled );
   102         iFlags.Set( ESingleClickEnabled );
   227         iExtension = new (ELeave) CAknRadioButtonSettingPageExtension( *this );
   240         iExtension = new (ELeave) CAknRadioButtonSettingPageExtension( *this );
   228 		}
   241 		}
   229 		
   242 		
   230     switch ( aEventType )
   243     switch ( aEventType )
   231         {
   244         {
       
   245         case MEikListBoxObserver::EEventPenDownOnItem:
       
   246             {
       
   247             if ( iExtension )
       
   248                 {
       
   249                 iExtension->iPenDownOnItem = ListBoxControl()->CurrentItemIndex();
       
   250                 }
       
   251             break;
       
   252             }
   232         case MEikListBoxObserver::EEventItemSingleClicked:
   253         case MEikListBoxObserver::EEventItemSingleClicked:
   233         case MEikListBoxObserver::EEventItemDoubleClicked:
   254         case MEikListBoxObserver::EEventItemDoubleClicked:
   234             {
   255             {
   235             SelectCurrentItemL();
   256             SelectCurrentItemL();
   236             AttemptExitL( ETrue );
   257             AttemptExitL( ETrue );
   285 		view->SelectItemL( aPushed );
   306 		view->SelectItemL( aPushed );
   286 		}
   307 		}
   287 	} 
   308 	} 
   288 
   309 
   289 EXPORT_C void CAknRadioButtonSettingPage::SelectCurrentItemL()
   310 EXPORT_C void CAknRadioButtonSettingPage::SelectCurrentItemL()
   290 	{
   311 	{   
   291     iCurrentSelectionIndex = ListBoxControl()->CurrentItemIndex();
   312     if ( ListBoxControl()->IsHighlightEnabled() || 
       
   313             ( iExtension && iExtension->iIsValidSelection ) )
       
   314         {
       
   315         iCurrentSelectionIndex = ListBoxControl()->CurrentItemIndex();
       
   316         }
       
   317     else
       
   318         {
       
   319         ListBoxControl()->SetCurrentItemIndex ( iCurrentSelectionIndex );
       
   320         }
       
   321 
   292     SetRadioButtonSelectionL( iCurrentSelectionIndex );
   322     SetRadioButtonSelectionL( iCurrentSelectionIndex );
   293 	UpdateSettingL();
   323 	UpdateSettingL();
   294 	if( iSettingPageObserver )
   324 	if( iSettingPageObserver )
   295 		iSettingPageObserver->HandleSettingPageEventL(this, MAknSettingPageObserver::EEventSettingChanged);
   325 		iSettingPageObserver->HandleSettingPageEventL(this, MAknSettingPageObserver::EEventSettingChanged);
   296 	} 
   326 	} 
   454 EXPORT_C void CAknRadioButtonSettingPage::HandlePointerEventL(const TPointerEvent& aPointerEvent)
   484 EXPORT_C void CAknRadioButtonSettingPage::HandlePointerEventL(const TPointerEvent& aPointerEvent)
   455     {
   485     {
   456     TPointerEvent& event = const_cast<TPointerEvent&>( aPointerEvent );
   486     TPointerEvent& event = const_cast<TPointerEvent&>( aPointerEvent );
   457     event.iModifiers &= ~EModifierShift;
   487     event.iModifiers &= ~EModifierShift;
   458     event.iModifiers &= ~EModifierCtrl;
   488     event.iModifiers &= ~EModifierCtrl;
   459 
   489     
       
   490     if ( iExtension )
       
   491         {
       
   492         TInt index ( KErrNotFound );
       
   493         ListBoxControl()->View()->XYPosToItemIndex( 
       
   494             aPointerEvent.iPosition, index );
       
   495         if ( index == iExtension->iPenDownOnItem 
       
   496                 && iExtension->iPenDownOnItem != KErrNotFound )
       
   497             {
       
   498             iExtension->iIsValidSelection = ETrue;
       
   499             }
       
   500         else
       
   501             {
       
   502             iExtension->iIsValidSelection = EFalse;
       
   503             }
       
   504         }
   460     CAknListBoxSettingPage::HandlePointerEventL( aPointerEvent );
   505     CAknListBoxSettingPage::HandlePointerEventL( aPointerEvent );
   461     }
   506     }
   462 
   507 
   463 EXPORT_C void* CAknRadioButtonSettingPage::ExtensionInterface( TUid /*aInterface*/ ) 
   508 EXPORT_C void* CAknRadioButtonSettingPage::ExtensionInterface( TUid /*aInterface*/ ) 
   464     { 
   509     {