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