uifw/AvKon/src/AknPopupField.cpp
branchRCL_3
changeset 55 aecbbf00d063
parent 51 fcdfafb36fe7
child 56 d48ab3b357f1
equal deleted inserted replaced
51:fcdfafb36fe7 55:aecbbf00d063
   206     }
   206     }
   207 
   207 
   208 
   208 
   209 void CAknPopupField::SetUpScrollBarL()
   209 void CAknPopupField::SetUpScrollBarL()
   210     {
   210     {
   211     __ASSERT_DEBUG( iCba, Panic( EAknPanicPopupFieldCBADoesntExist ) );
   211     if ( !iExtension || !iExtension->iSingleClickEnabled )
       
   212         {
       
   213         __ASSERT_DEBUG( iCba, Panic( EAknPanicPopupFieldCBADoesntExist ) );
       
   214         }
   212     __ASSERT_DEBUG(iSelectionList != NULL, Panic(EAknPanicPopupFieldSelectionListDoesntExist));
   215     __ASSERT_DEBUG(iSelectionList != NULL, Panic(EAknPanicPopupFieldSelectionListDoesntExist));
   213     iSelectionList->SetMopParent(this); // to get remote scb
   216     iSelectionList->SetMopParent(this); // to get remote scb
   214     iSelectionList->CreateScrollBarFrameL(ETrue, ETrue);
   217     iSelectionList->CreateScrollBarFrameL(ETrue, ETrue);
   215     iSelectionList->SetMopParent(NULL);
   218     iSelectionList->SetMopParent(NULL);
   216     iSelectionList->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
   219     iSelectionList->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
   217     }
   220     }
   218 
   221 
   219 void CAknPopupField::SetScrollBarSelectionL()
   222 void CAknPopupField::SetScrollBarSelectionL()
   220     {
   223     {
   221     TInt selection = iValue->CurrentValueIndex();
   224     TInt selection = iValue->CurrentValueIndex();
   222     //iOldItemIndex should be saved as original value.
       
   223     if ( iExtension )
       
   224         {
       
   225         iExtension->iOldItemIndex = selection;
       
   226         }
       
   227     if (IsInvalid()) selection = 0;
   225     if (IsInvalid()) selection = 0;
   228     __ASSERT_DEBUG(iSelectionList != NULL, Panic(EAknPanicPopupFieldSelectionListDoesntExist));
   226     __ASSERT_DEBUG(iSelectionList != NULL, Panic(EAknPanicPopupFieldSelectionListDoesntExist));
   229     iSelectionList->SetCurrentItemIndex(selection);
   227     iSelectionList->SetCurrentItemIndex(selection);
   230     iSelectionList->View()->SelectItemL(selection);
   228     iSelectionList->View()->SelectItemL(selection);
       
   229 
       
   230     if ( iExtension )
       
   231         {
       
   232         iExtension->iOldItemIndex = iSelectionList->CurrentItemIndex();
       
   233         }
   231     }
   234     }
   232 
   235 
   233 
   236 
   234 void CAknPopupField::InitialiseRadioButtonBitmapsL()
   237 void CAknPopupField::InitialiseRadioButtonBitmapsL()
   235     {
   238     {
   438             break;
   441             break;
   439             }
   442             }
   440     case EAknPopupFieldSelectionListMode:
   443     case EAknPopupFieldSelectionListMode:
   441             {
   444             {
   442             __ASSERT_DEBUG(iSelectionList != NULL, Panic(EAknPanicPopupFieldSelectionListDoesntExist));
   445             __ASSERT_DEBUG(iSelectionList != NULL, Panic(EAknPanicPopupFieldSelectionListDoesntExist));
   443             // When Form loses focus, If its child control listbox's size or position is not changed, 
   446             iSelectionList->SetRect(rect);
   444             // do not invoke "iSelectionList->SetRect(rect);". 
       
   445             if ((iSelectionList->Position() != rect.iTl) || (iSelectionList->Size() != rect.Size()))
       
   446                 {
       
   447                 iSelectionList->SetRect(rect);
       
   448                 SetScrollBarSelectionL();
       
   449                 }
       
   450             AknsUtils::RegisterControlPosition(this);
   447             AknsUtils::RegisterControlPosition(this);
   451             AknsUtils::RegisterControlPosition(iSelectionList);
   448             AknsUtils::RegisterControlPosition(iSelectionList);
   452             TRect listBoxRect = iExtension->iFormFieldRect; //iSelectionList->Rect();
   449             TRect listBoxRect = iExtension->iFormFieldRect; //iSelectionList->Rect();
   453             listBoxRect.iTl = TPoint(0,0);
   450             listBoxRect.iTl = TPoint(0,0);
   454             // Cannot use KAknsIIDNone here because highlight animation
   451             // Cannot use KAknsIIDNone here because highlight animation
   654         switch ( aEventType )
   651         switch ( aEventType )
   655             {
   652             {
   656             case MEikListBoxObserver::EEventItemSingleClicked:
   653             case MEikListBoxObserver::EEventItemSingleClicked:
   657                 {
   654                 {
   658                 CListBoxView* view = iSelectionList->View();
   655                 CListBoxView* view = iSelectionList->View();
   659                 TInt selection = view->CurrentItemIndex(); 
   656                 
   660                 if ( selection != iExtension->iOldItemIndex )
   657                 if ( view->CurrentItemIndex() != iExtension->iOldItemIndex )
   661                     {
   658                     {
   662                     view->DeselectItem( iExtension->iOldItemIndex );
   659                     view->DeselectItem( iExtension->iOldItemIndex );
   663                     iExtension->iOldItemIndex = selection;
   660                     iExtension->iOldItemIndex = view->CurrentItemIndex();
   664                     view->SelectItemL( selection );
   661                     view->SelectItemL( iExtension->iOldItemIndex );
   665 
       
   666                     TInt decoratedIndex;
       
   667                     TBool decorated = iDecorator.DecoratedIndex( decoratedIndex );
       
   668                     if ( decorated && ( selection  == decoratedIndex ) )
       
   669                         {
       
   670                         TBool accepted = iValue->CreateEditorL();
       
   671                         if ( !accepted )
       
   672                             {
       
   673                             break; 
       
   674                             }
       
   675                         }
       
   676                     else
       
   677                         {
       
   678                         iValue->SetCurrentValueIndex( selection );
       
   679                         }
       
   680                     }
   662                     }
   681                 }
   663                 }
   682             // fall through
   664 
   683             case MEikListBoxObserver::EEventItemDoubleClicked:
   665             case MEikListBoxObserver::EEventItemDoubleClicked:
   684             case MEikListBoxObserver::EEventEnterKeyPressed:
   666             case MEikListBoxObserver::EEventEnterKeyPressed:
   685                 {
   667                 {
   686                 // We can't delete the selection list until it's finished
   668                 // We can't delete the selection list until it's finished
   687                 // processing the event, so call ourselves back and do it when
   669                 // processing the event, so call ourselves back and do it when
   843     return keyResponse;
   825     return keyResponse;
   844     }
   826     }
   845 
   827 
   846 void CAknPopupField::CreatePopoutL()
   828 void CAknPopupField::CreatePopoutL()
   847     {
   829     {
   848     CreateCbaL();
   830     if ( !iExtension || !iExtension->iSingleClickEnabled )
       
   831         {
       
   832         CreateCbaL();
       
   833         }
   849     ConstructSelectionListL();
   834     ConstructSelectionListL();
   850     ChangeMode(EAknPopupFieldSelectionListMode);
   835     ChangeMode(EAknPopupFieldSelectionListMode);
   851     SetUpScrollBarL();
   836     SetUpScrollBarL();
   852     // need to initialize the selection so that the list box is drawn in the correct place
   837     // need to initialize the selection so that the list box is drawn in the correct place
   853     SetScrollBarSelectionL();
   838     SetScrollBarSelectionL();
   930         if ( iSelectionList && notEditable
   915         if ( iSelectionList && notEditable
   931                 && iSelectionMode == EAknPopupFieldSelectionListMode
   916                 && iSelectionMode == EAknPopupFieldSelectionListMode
   932                 && iExtension && iExtension->iSingleClickEnabled )
   917                 && iExtension && iExtension->iSingleClickEnabled )
   933             {
   918             {
   934             // Edit mode to view while popup is open -> first cancel popup
   919             // Edit mode to view while popup is open -> first cancel popup
   935             TRAP_IGNORE(AttemptExitL( EFalse ));
   920             AttemptExitL( EFalse );
   936             }
   921             }
   937         else
   922         else
   938             {
   923             {
   939             __ASSERT_DEBUG( iSelectionMode == EAknPopupFieldLabelMode,
   924             __ASSERT_DEBUG( iSelectionMode == EAknPopupFieldLabelMode,
   940                     Panic( EAknPanicPopupFieldWrongMode ) );
   925                     Panic( EAknPanicPopupFieldWrongMode ) );
  1173         iLabel->SetTextL(*iInvalidText);
  1158         iLabel->SetTextL(*iInvalidText);
  1174         iLabel->CropText();
  1159         iLabel->CropText();
  1175         }
  1160         }
  1176     }
  1161     }
  1177 
  1162 
  1178 EXPORT_C void CAknPopupField::CloseSelectionListL()
       
  1179     {
       
  1180     if (  iSelectionMode == EAknPopupFieldSelectionListMode 
       
  1181           && iSelectionList )
       
  1182         {
       
  1183         AttemptExitL( EFalse );
       
  1184         }
       
  1185     }
       
  1186 
  1163 
  1187 void CAknPopupField::ConfigureDecorator()
  1164 void CAknPopupField::ConfigureDecorator()
  1188     {
  1165     {
  1189     __ASSERT_DEBUG(iOtherText, Panic(EAknPanicPopupFieldUninitialisedMember));
  1166     __ASSERT_DEBUG(iOtherText, Panic(EAknPanicPopupFieldUninitialisedMember));
  1190 
  1167 
  1219     __ASSERT_DEBUG(iSelectionList != NULL, Panic(EAknPanicPopupFieldSelectionListDoesntExist));
  1196     __ASSERT_DEBUG(iSelectionList != NULL, Panic(EAknPanicPopupFieldSelectionListDoesntExist));
  1220     TBool finished = ETrue;
  1197     TBool finished = ETrue;
  1221 
  1198 
  1222     if (aAccept)
  1199     if (aAccept)
  1223         {
  1200         {
  1224         if ( iSelectionList->IsHighlightEnabled() )
  1201         // get current selection
  1225             {
  1202         const TInt selection=iSelectionList->CurrentItemIndex();
  1226             // get current selection
  1203         TInt decoratedIndex;
  1227             const TInt selection=iSelectionList->CurrentItemIndex();
  1204         TBool decorated = iDecorator.DecoratedIndex(decoratedIndex);
  1228             TInt decoratedIndex;
  1205         if (decorated && (selection == decoratedIndex))
  1229             TBool decorated = iDecorator.DecoratedIndex(decoratedIndex);
  1206             {
  1230             if (decorated && (selection == decoratedIndex))
  1207             TBool accepted = iValue->CreateEditorL();
  1231                 {
  1208             if (!accepted)
  1232                 TBool accepted = iValue->CreateEditorL();
  1209                 {
  1233                 if (!accepted)
  1210                 // dialog was cancelled, so popup list must remain
  1234                     {
  1211                 finished = EFalse;
  1235                     // dialog was cancelled, so popup list must remain
  1212                 }
  1236                     finished = EFalse;
  1213             }
  1237                     }
  1214         else
  1238                 }
  1215             iValue->SetCurrentValueIndex(selection);
  1239             else
  1216         }
  1240                 {
  1217 
  1241                 iValue->SetCurrentValueIndex(selection);
       
  1242                 }
       
  1243             }
       
  1244         }
       
  1245     if (finished)
  1218     if (finished)
  1246         {
  1219         {
  1247         delete iCba;
  1220         delete iCba;
  1248         iCba = NULL;
  1221         iCba = NULL;
  1249         DestroyPopout();
  1222         DestroyPopout();