javauis/lcdui_akn/lcdui/src/CMIDChoiceGroupModel.cpp
branchRCL_3
changeset 77 7cee158cb8cd
parent 19 04becd199f91
child 83 26b2b12093af
equal deleted inserted replaced
71:d5e927d5853b 77:7cee158cb8cd
    69     }
    69     }
    70 
    70 
    71     // Delete icons
    71     // Delete icons
    72     delete iIconSelected;
    72     delete iIconSelected;
    73     delete iIconNotSelected;
    73     delete iIconNotSelected;
       
    74 #ifdef RD_JAVA_S60_RELEASE_9_2
       
    75     delete iIconSelectedHighlighted;
       
    76     delete iIconNotSelectedHighlighted;
       
    77 #endif // RD_JAVA_S60_RELEASE_9_2
    74     delete iIconDummy;
    78     delete iIconDummy;
    75 }
    79 }
    76 
    80 
    77 
    81 
    78 // Two-phase constructor, initialises member arrays and stuff
    82 // Two-phase constructor, initialises member arrays and stuff
   126     // layout in respect of the whole screen as only the icon size is needed
   130     // layout in respect of the whole screen as only the icon size is needed
   127     layoutRect.LayoutRect(screenRect, AknLayoutScalable_Avkon::list_single_2graphic_pane_g2_cp4().LayoutLine());
   131     layoutRect.LayoutRect(screenRect, AknLayoutScalable_Avkon::list_single_2graphic_pane_g2_cp4().LayoutLine());
   128 
   132 
   129     TSize iconSize(layoutRect.Rect().Width(), layoutRect.Rect().Height());
   133     TSize iconSize(layoutRect.Rect().Width(), layoutRect.Rect().Height());
   130 
   134 
       
   135     // create icons for non-highlighted mode
       
   136 
   131     AknsUtils::CreateColorIconLC(skin, notSelectedSkinId, KAknsIIDQsnIconColors,
   137     AknsUtils::CreateColorIconLC(skin, notSelectedSkinId, KAknsIIDQsnIconColors,
   132                                  EAknsCIQsnIconColorsCG14, bitmap, mask, avkonbmpFilename, notSelectedIconId,
   138                                  EAknsCIQsnIconColorsCG14, bitmap, mask, avkonbmpFilename, notSelectedIconId,
   133                                  notSelectedMaskId, KRgbBlue, iconSize, EAspectRatioPreservedAndUnusedSpaceRemoved);
   139                                  notSelectedMaskId, KRgbBlue, iconSize, EAspectRatioPreservedAndUnusedSpaceRemoved);
   134 
   140 
   135     CGulIcon* iconNotSelected = CGulIcon::NewL(bitmap, mask);
   141     CGulIcon* iconNotSelected = CGulIcon::NewL(bitmap, mask);
   145     CGulIcon* iconSelected = CGulIcon::NewL(bitmap, mask);
   151     CGulIcon* iconSelected = CGulIcon::NewL(bitmap, mask);
   146     CleanupStack::Pop(2); //bitmap, mask
   152     CleanupStack::Pop(2); //bitmap, mask
   147 
   153 
   148     delete iIconSelected;
   154     delete iIconSelected;
   149     iIconSelected = iconSelected;
   155     iIconSelected = iconSelected;
       
   156 
       
   157     // create icons for highlighted mode
       
   158 #ifdef RD_JAVA_S60_RELEASE_9_2
       
   159     AknsUtils::CreateColorIconLC(skin, notSelectedSkinId, KAknsIIDQsnIconColors,
       
   160                                  EAknsCIQsnIconColorsCG15, bitmap, mask, avkonbmpFilename, notSelectedIconId,
       
   161                                  notSelectedMaskId, KRgbBlue, iconSize, EAspectRatioPreservedAndUnusedSpaceRemoved);
       
   162 
       
   163     CGulIcon* iconNotSelectedHighlighted = CGulIcon::NewL(bitmap, mask);
       
   164     CleanupStack::Pop(2); //bitmap, mask
       
   165 
       
   166     delete iIconNotSelectedHighlighted;
       
   167     iIconNotSelectedHighlighted = iconNotSelectedHighlighted;
       
   168 
       
   169     AknsUtils::CreateColorIconLC(skin, selectedSkinId, KAknsIIDQsnIconColors,
       
   170                                  EAknsCIQsnIconColorsCG15, bitmap, mask, avkonbmpFilename, selectedIconId,
       
   171                                  selectedMaskId, KRgbBlue, iconSize, EAspectRatioPreservedAndUnusedSpaceRemoved);
       
   172 
       
   173     CGulIcon* iconSelectedHighlighted = CGulIcon::NewL(bitmap, mask);
       
   174     CleanupStack::Pop(2); //bitmap, mask
       
   175 
       
   176     delete iIconSelectedHighlighted;
       
   177     iIconSelectedHighlighted = iconSelectedHighlighted;
       
   178 #endif // RD_JAVA_S60_RELEASE_9_2
   150 }
   179 }
   151 
   180 
   152 // Base class overrides
   181 // Base class overrides
   153 
   182 
   154 // The model contains more than just the strings - need to override
   183 // The model contains more than just the strings - need to override
   210 
   239 
   211     // If not in the middle of an update, refresh a bit
   240     // If not in the middle of an update, refresh a bit
   212     if (!iUpdating)
   241     if (!iUpdating)
   213     {
   242     {
   214         // Refresh icon array
   243         // Refresh icon array
       
   244 #ifdef RD_JAVA_S60_RELEASE_9_2
       
   245         if (iObserver)
       
   246         {
       
   247             UpdateIconArrayL(iObserver->IsControlOnFormHighlighted());
       
   248         }
       
   249 #else
   215         UpdateIconArrayL();
   250         UpdateIconArrayL();
       
   251 #endif // RD_JAVA_S60_RELEASE_9_2
   216 
   252 
   217         // Report event
   253         // Report event
   218         ReportEventL(MMIDChoiceGroupModelObserver::EElementAdded);
   254         ReportEventL(MMIDChoiceGroupModelObserver::EElementAdded);
   219     }
   255     }
   220 }
   256 }
   238 
   274 
   239         // If not in the middle of an update, refresh a bit
   275         // If not in the middle of an update, refresh a bit
   240         if (!iUpdating)
   276         if (!iUpdating)
   241         {
   277         {
   242             // Refresh icon array
   278             // Refresh icon array
       
   279 #ifdef RD_JAVA_S60_RELEASE_9_2
       
   280             if (iObserver)
       
   281             {
       
   282                 UpdateIconArrayL(iObserver->IsControlOnFormHighlighted());
       
   283             }
       
   284 #else
   243             UpdateIconArrayL();
   285             UpdateIconArrayL();
       
   286 #endif // RD_JAVA_S60_RELEASE_9_2
   244 
   287 
   245             // Report element addition
   288             // Report element addition
   246             ReportEventL(MMIDChoiceGroupModelObserver::EElementAdded);
   289             ReportEventL(MMIDChoiceGroupModelObserver::EElementAdded);
   247         }
   290         }
   248     }
   291     }
   290 
   333 
   291         // If not in the middle of an update, refresh a bit
   334         // If not in the middle of an update, refresh a bit
   292         if (!iUpdating)
   335         if (!iUpdating)
   293         {
   336         {
   294             // Refresh icon array.
   337             // Refresh icon array.
       
   338 #ifdef RD_JAVA_S60_RELEASE_9_2
       
   339             if (iObserver)
       
   340             {
       
   341                 UpdateIconArrayL(iObserver->IsControlOnFormHighlighted());
       
   342             }
       
   343 #else
   295             UpdateIconArrayL();
   344             UpdateIconArrayL();
       
   345 #endif // RD_JAVA_S60_RELEASE_9_2
   296 
   346 
   297             // Update the looks of the control
   347             // Update the looks of the control
   298             ReportEventL(MMIDChoiceGroupModelObserver::EElementDeleted);
   348             ReportEventL(MMIDChoiceGroupModelObserver::EElementDeleted);
   299         }
   349         }
   300     }
   350     }
   314 
   364 
   315         // If not updating, refresh now
   365         // If not updating, refresh now
   316         if (!iUpdating)
   366         if (!iUpdating)
   317         {
   367         {
   318             // Recreate icon array
   368             // Recreate icon array
       
   369 #ifdef RD_JAVA_S60_RELEASE_9_2
       
   370             if (iObserver)
       
   371             {
       
   372                 UpdateIconArrayL(iObserver->IsControlOnFormHighlighted());
       
   373             }
       
   374 #else
   319             UpdateIconArrayL();
   375             UpdateIconArrayL();
       
   376 #endif // RD_JAVA_S60_RELEASE_9_2
   320 
   377 
   321             // Report event
   378             // Report event
   322             ReportEventL(MMIDChoiceGroupModelObserver::EElementDeleted);
   379             ReportEventL(MMIDChoiceGroupModelObserver::EElementDeleted);
   323         }
   380         }
   324     }
   381     }
   349 
   406 
   350         // Refresh stuff, if not in the middle of an update
   407         // Refresh stuff, if not in the middle of an update
   351         if (!iUpdating)
   408         if (!iUpdating)
   352         {
   409         {
   353             // Icon may have changed, recreate array.
   410             // Icon may have changed, recreate array.
       
   411 #ifdef RD_JAVA_S60_RELEASE_9_2
       
   412             if (iObserver)
       
   413             {
       
   414                 UpdateIconArrayL(iObserver->IsControlOnFormHighlighted());
       
   415             }
       
   416 #else
   354             UpdateIconArrayL();
   417             UpdateIconArrayL();
       
   418 #endif // RD_JAVA_S60_RELEASE_9_2
   355 
   419 
   356             // Report event
   420             // Report event
   357             ReportEventL(MMIDChoiceGroupModelObserver::EElementModified);
   421             ReportEventL(MMIDChoiceGroupModelObserver::EElementModified);
   358         }
   422         }
   359     }
   423     }
   388 CArrayPtr<CGulIcon>* CMIDChoiceGroupModel::IconArray(TBool aReCreate)
   452 CArrayPtr<CGulIcon>* CMIDChoiceGroupModel::IconArray(TBool aReCreate)
   389 {
   453 {
   390     if (aReCreate)
   454     if (aReCreate)
   391     {
   455     {
   392         // Recreate, trap & ignore leaves
   456         // Recreate, trap & ignore leaves
       
   457 #ifdef RD_JAVA_S60_RELEASE_9_2
       
   458         if (iObserver)
       
   459         {
       
   460             TRAP_IGNORE(
       
   461                 UpdateIconArrayL(iObserver->IsControlOnFormHighlighted()));
       
   462         }
       
   463 #else
   393         TRAP_IGNORE(UpdateIconArrayL());
   464         TRAP_IGNORE(UpdateIconArrayL());
       
   465 #endif // RD_JAVA_S60_RELEASE_9_2
   394     }
   466     }
   395 
   467 
   396     return iIconArray;
   468     return iIconArray;
   397 }
   469 }
   398 
   470 
   453 void CMIDChoiceGroupModel::EndUpdate()
   525 void CMIDChoiceGroupModel::EndUpdate()
   454 {
   526 {
   455     iUpdating = EFalse;
   527     iUpdating = EFalse;
   456 
   528 
   457     // Create array, refresh control
   529     // Create array, refresh control
   458     TRAPD(ignore, UpdateIconArrayL());
   530 #ifdef RD_JAVA_S60_RELEASE_9_2
       
   531     if (iObserver)
       
   532     {
       
   533         TRAP_IGNORE(UpdateIconArrayL(iObserver->IsControlOnFormHighlighted()));
       
   534     }
       
   535 #else
       
   536     TRAP_IGNORE(UpdateIconArrayL());
       
   537 #endif // RD_JAVA_S60_RELEASE_9_2
   459 
   538 
   460     // Report update end (observer should redraw)
   539     // Report update end (observer should redraw)
   461     TRAP(ignore, ReportEventL(MMIDChoiceGroupModelObserver::EUpdateEnded));
   540     TRAP_IGNORE(ReportEventL(MMIDChoiceGroupModelObserver::EUpdateEnded));
   462 }
   541 }
   463 
   542 
   464 
   543 
   465 // Returns the index of the selected element in an exclusive
   544 // Returns the index of the selected element in an exclusive
   466 // choice, or -1
   545 // choice, or -1
   529 // This should be done every time the contents of the model are changed,
   608 // This should be done every time the contents of the model are changed,
   530 // or icon array is retrieved with the create flag set.
   609 // or icon array is retrieved with the create flag set.
   531 // NOTE that the indices in the array and the item strings should
   610 // NOTE that the indices in the array and the item strings should
   532 // be synchronised. The selection icon is always at index
   611 // be synchronised. The selection icon is always at index
   533 // 0 (selected) and 1 (not selected)
   612 // 0 (selected) and 1 (not selected)
       
   613 #ifdef RD_JAVA_S60_RELEASE_9_2
       
   614 void CMIDChoiceGroupModel::UpdateIconArrayL(TBool aHighlighted)
       
   615 #else
   534 void CMIDChoiceGroupModel::UpdateIconArrayL()
   616 void CMIDChoiceGroupModel::UpdateIconArrayL()
       
   617 #endif // RD_JAVA_S60_RELEASE_9_2
   535 {
   618 {
   536     ASSERT(iElements);
   619     ASSERT(iElements);
   537     ASSERT(iIconArray);
   620     ASSERT(iIconArray);
   538 
   621 
   539     // Clear array, DO NOT DELETE icons
   622     // Clear array, DO NOT DELETE icons
   545     {
   628     {
   546         return;
   629         return;
   547     }
   630     }
   548 
   631 
   549     // First add the selection icons
   632     // First add the selection icons
       
   633 #ifdef RD_JAVA_S60_RELEASE_9_2
       
   634     if (aHighlighted)
       
   635     {
       
   636         iIconArray->AppendL(iIconSelectedHighlighted);
       
   637         iIconArray->AppendL(iIconNotSelectedHighlighted);
       
   638     }
       
   639     else
       
   640     {
       
   641         iIconArray->AppendL(iIconSelected);
       
   642         iIconArray->AppendL(iIconNotSelected);
       
   643     }
       
   644 #else
   550     iIconArray->AppendL(iIconSelected);
   645     iIconArray->AppendL(iIconSelected);
   551     iIconArray->AppendL(iIconNotSelected);
   646     iIconArray->AppendL(iIconNotSelected);
       
   647 #endif // RD_JAVA_S60_RELEASE_9_2
   552 
   648 
   553     // Then loop through the elements and add their icons
   649     // Then loop through the elements and add their icons
   554     for (TInt i = 0; i < nCount; i++)
   650     for (TInt i = 0; i < nCount; i++)
   555     {
   651     {
   556         CMIDChoiceGroupElement *pElement = ElementAt(i);
   652         CMIDChoiceGroupElement *pElement = ElementAt(i);