menufw/menufwui/matrixmenu/src/mmappui.cpp
branchRCL_3
changeset 28 d721605b30d0
parent 26 1b758917cafc
equal deleted inserted replaced
26:1b758917cafc 28:d721605b30d0
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  Application UI class
    14 * Description:  Application UI class
    15 *  Version     : %version: MM_176.1.28.1.82 % << Don't touch! Updated by Synergy at check-out.
    15 *  Version     : %version: MM_176.1.28.1.83 % << Don't touch! Updated by Synergy at check-out.
    16 *  Version     : %version: MM_176.1.28.1.82 % << Don't touch! Updated by Synergy at check-out.
    16 *  Version     : %version: MM_176.1.28.1.83 % << Don't touch! Updated by Synergy at check-out.
    17 *
    17 *
    18 */
    18 */
    19 
    19 
    20 #include <e32base.h>
    20 #include <e32base.h>
    21 #include <e32cmn.h>
    21 #include <e32cmn.h>
  1227 // ---------------------------------------------------------------------------
  1227 // ---------------------------------------------------------------------------
  1228 //
  1228 //
  1229 // ---------------------------------------------------------------------------
  1229 // ---------------------------------------------------------------------------
  1230 //
  1230 //
  1231 void CMmAppUi::HandleLongTapEventL( const TPoint& aPenEventLocation )
  1231 void CMmAppUi::HandleLongTapEventL( const TPoint& aPenEventLocation )
  1232   {
  1232     {
  1233     TBool popupMenuDisplayed(EFalse);
  1233     TBool popupMenuDisplayed(EFalse);
  1234   if (iPopupMenu)
  1234     if (iPopupMenu)
  1235       {
  1235         {
  1236       delete iPopupMenu;
  1236         delete iPopupMenu;
  1237       iPopupMenu = NULL;
  1237         iPopupMenu = NULL;
  1238       }
  1238         }
  1239     iPopupMenu = CAknStylusPopUpMenu::NewL(this,aPenEventLocation);
  1239     iPopupMenu = CAknStylusPopUpMenu::NewL(this,aPenEventLocation);
  1240 
  1240 
  1241     if ( AknLayoutUtils::LayoutMirrored() )
  1241     if ( AknLayoutUtils::LayoutMirrored() )
  1242         {
  1242         {
  1243         iPopupMenu->SetPosition( aPenEventLocation,
  1243         iPopupMenu->SetPosition( aPenEventLocation,
  1248         iPopupMenu->SetPosition( aPenEventLocation,
  1248         iPopupMenu->SetPosition( aPenEventLocation,
  1249                 CAknStylusPopUpMenu::EPositionTypeLeftBottom );
  1249                 CAknStylusPopUpMenu::EPositionTypeLeftBottom );
  1250         }
  1250         }
  1251 
  1251 
  1252     if( iCurrentSuiteModel == iHNInterface->GetLastSuiteModelL()
  1252     if( iCurrentSuiteModel == iHNInterface->GetLastSuiteModelL()
  1253         && iCurrentContainer->IsHighlightVisible()
  1253             && iCurrentContainer->IsHighlightVisible()
  1254         && iCurrentContainer->GetSuiteModelL()->GetItemModelsCount() > 1 )
  1254             && iCurrentContainer->GetSuiteModelL()->GetItemModelsCount() > 1 )
  1255       {
  1255         {
  1256     MMPERF(("CMmAppUi::DynInitMenuPaneL - START"));
  1256         MMPERF(("CMmAppUi::DynInitMenuPaneL - START"));
  1257     //fill the main menu structure, look for cascade menus
  1257         //fill the main menu structure, look for cascade menus
  1258     //reset the helper hash map
  1258         //reset the helper hash map
  1259     iCascadeMenuMap.Close();
  1259         iCascadeMenuMap.Close();
  1260 
  1260 
  1261     MHnMenuItemModelIterator* menuIterator =
  1261         MHnMenuItemModelIterator* menuIterator =
  1262       iCurrentSuiteModel->GetMenuStructureL(
  1262                 iCurrentSuiteModel->GetMenuStructureL(
  1263         iCurrentSuiteModel->IdByIndex(
  1263                         iCurrentSuiteModel->IdByIndex(
  1264             iCurrentContainer->GetHighlight() ) );
  1264                                 iCurrentContainer->GetHighlight() ) );
  1265 
  1265 
  1266     // check if there is a menu structure available
  1266         // check if there is a menu structure available
  1267     // for the specified item
  1267         // for the specified item
  1268     if ( menuIterator )
  1268         if ( menuIterator )
  1269       {
  1269             {
  1270       //create item sorting helper objects
  1270             //create item sorting helper objects
  1271       RArray<TInt> positionArray;
  1271             RArray<TInt> positionArray;
  1272       CleanupClosePushL( positionArray );
  1272             CleanupClosePushL( positionArray );
  1273       RHashMap<TInt, CEikMenuPaneItem::SData> menuItemMap;
  1273             RHashMap<TInt, CEikMenuPaneItem::SData> menuItemMap;
  1274       CleanupClosePushL( menuItemMap );
  1274             CleanupClosePushL( menuItemMap );
  1275 
  1275 
  1276       while ( menuIterator->HasNextSpecific() )
  1276             while ( menuIterator->HasNextSpecific() )
  1277           {
  1277                 {
  1278           CHnMenuItemModel* childItem = menuIterator->GetNextSpecific();
  1278                 CHnMenuItemModel* childItem = menuIterator->GetNextSpecific();
  1279           CEikMenuPaneItem::SData childData;
  1279                 CEikMenuPaneItem::SData childData;
  1280           childData.iCommandId = childItem->Command();
  1280                 childData.iCommandId = childItem->Command();
  1281           childData.iText = childItem->NameL().
  1281                 childData.iText = childItem->NameL().
  1282                   Left( CEikMenuPaneItem::SData::ENominalTextLength );
  1282                         Left( CEikMenuPaneItem::SData::ENominalTextLength );
  1283           childData.iFlags = 0;
  1283                 childData.iFlags = 0;
  1284           childData.iCascadeId = 0;
  1284                 childData.iCascadeId = 0;
  1285 
  1285 
  1286           positionArray.AppendL( childItem->Position() );
  1286                 positionArray.AppendL( childItem->Position() );
  1287           menuItemMap.InsertL( childItem->Position(), childData );
  1287                 menuItemMap.InsertL( childItem->Position(), childData );
  1288           }
  1288                 }
  1289 
  1289 
  1290       positionArray.Sort();
  1290             positionArray.Sort();
  1291 
  1291 
  1292       //add items in correct order
  1292             //add items in correct order
  1293       for ( TInt i = 0; i < positionArray.Count(); ++i )
  1293             for ( TInt i = 0; i < positionArray.Count(); ++i )
  1294         {
  1294                 {
  1295         iPopupMenu->
  1295                 iPopupMenu->AddMenuItemL(
  1296           AddMenuItemL(
  1296                         menuItemMap.FindL( positionArray[i] ).iText,
  1297             menuItemMap.FindL( positionArray[i] ).iText,
  1297                         menuItemMap.FindL( positionArray[i] ).iCommandId );
  1298             menuItemMap.FindL( positionArray[i] ).iCommandId );
  1298                 }
  1299         }
  1299 
  1300 
  1300             if (positionArray.Count()>0)
  1301       if (positionArray.Count()>0)
  1301                 {
  1302         {
  1302                 iPopupMenu->ShowMenu();
  1303         iPopupMenu->ShowMenu();
  1303                 popupMenuDisplayed = ETrue;
  1304         popupMenuDisplayed = ETrue;
  1304                 }
  1305         }
  1305             CleanupStack::PopAndDestroy( &menuItemMap );
  1306       CleanupStack::PopAndDestroy( &menuItemMap );
  1306             CleanupStack::PopAndDestroy( &positionArray );
  1307       CleanupStack::PopAndDestroy( &positionArray );
  1307             }
  1308       }
  1308         MMPERF(("CMmAppUi::DynInitMenuPaneL - STOP"));
  1309     MMPERF(("CMmAppUi::DynInitMenuPaneL - STOP"));
  1309         }
  1310     }
       
  1311 
  1310 
  1312     if ( !popupMenuDisplayed && iCurrentContainer )
  1311     if ( !popupMenuDisplayed && iCurrentContainer )
  1313         {
  1312         {
  1314         iCurrentContainer->EndLongTapL( ETrue );
  1313         iCurrentContainer->EndLongTapL( ETrue );
  1315         HandleHighlightItemSingleClickedL(
  1314         HandleHighlightItemSingleClickedL(
  1316             iCurrentContainer->Widget()->CurrentItemIndex() );
  1315                 iCurrentContainer->Widget()->CurrentItemIndex() );
  1317         }
  1316         }
  1318     }
  1317     }
  1319 
  1318 
  1320 // ---------------------------------------------------------------------------
  1319 // ---------------------------------------------------------------------------
  1321 //
  1320 //