idlehomescreen/xmluirendering/renderingplugins/xnmenufactory/src/xnmenuadapter.cpp
branchRCL_3
changeset 18 d05a55b217df
parent 12 9674c1a575e9
child 23 7be2816dbabd
equal deleted inserted replaced
17:b8fae6b8a148 18:d05a55b217df
    55 
    55 
    56 #undef _AVKON_CBA_LSC
    56 #undef _AVKON_CBA_LSC
    57 
    57 
    58 _LIT8( KEditMode, "Menu/EditMode" );
    58 _LIT8( KEditMode, "Menu/EditMode" );
    59 _LIT8( KNormalMode, "Menu/NormalMode" );
    59 _LIT8( KNormalMode, "Menu/NormalMode" );
       
    60 _LIT8( KContextEditMode, "ContextMenu/EditMode" );
       
    61 _LIT8( KContextNormalMode, "ContextMenu/NormalMode" );
    60 _LIT8( KAlwaysShown, "Menu/AlwaysShown" );
    62 _LIT8( KAlwaysShown, "Menu/AlwaysShown" );
       
    63 
    61 _LIT8( KHsShowHelp, "hs_show_help" );
    64 _LIT8( KHsShowHelp, "hs_show_help" );
    62 
    65 
    63 const TInt KMenuCommandFirst         = 6000;
    66 const TInt KMenuCommandFirst         = 6000;
    64 const TInt KMenuCommandLast          = 6199;
    67 const TInt KMenuCommandLast          = 6199;
    65 const TInt KCBACommandFirst          = EAknSoftkeyOptions;
    68 const TInt KCBACommandFirst          = EAknSoftkeyOptions;
  1477                
  1480                
  1478     RPointerArray< const TDesC8 > groups;
  1481     RPointerArray< const TDesC8 > groups;
  1479     CleanupClosePushL( groups );
  1482     CleanupClosePushL( groups );
  1480                
  1483                
  1481     if ( !iUiEngine->IsTextEditorActive() )
  1484     if ( !iUiEngine->IsTextEditorActive() )
  1482         {    
  1485         {  
  1483         if( iUiEngine->EditMode() )
  1486         if( iUiEngine->EditMode() )        
  1484             {
  1487             {
  1485             groups.AppendL( &KEditMode );
  1488             groups.AppendL( 
       
  1489                 iContextMenu ? &KContextEditMode : &KEditMode );
  1486             }
  1490             }
  1487         else
  1491         else
  1488             {
  1492             {
  1489             groups.Append( &KNormalMode );
  1493             groups.AppendL( 
  1490             }
  1494                 iContextMenu ? &KContextNormalMode : &KNormalMode );
  1491         }
  1495             }
  1492     
  1496         }
  1493     groups.AppendL( &KAlwaysShown );
  1497 
  1494          
  1498     if ( !iContextMenu )
       
  1499         {
       
  1500         groups.AppendL( &KAlwaysShown );
       
  1501         }
       
  1502             
  1495     // Recursively add menuitems
  1503     // Recursively add menuitems
  1496     AddMenuItemL( -1, iMenuBarNode, groups );
  1504     AddMenuItemL( -1, iMenuBarNode, groups );
  1497     
  1505     
  1498     CleanupStack::PopAndDestroy( &groups );
  1506     CleanupStack::PopAndDestroy( &groups );
  1499     }
  1507     }
  1512         
  1520         
  1513         iKeyEventNode = NULL;
  1521         iKeyEventNode = NULL;
  1514         
  1522         
  1515         return resp;
  1523         return resp;
  1516         }        
  1524         }        
  1517 
  1525     
  1518     const TDesC8* pos( &KNullDesC8 );
  1526     TInt pos( KErrNotFound );
  1519     
  1527            
  1520     if( aKeyEvent.iScanCode == EStdKeyDevice0 )
  1528     if( aKeyEvent.iScanCode == EStdKeyDevice0 )
  1521         {
  1529         {
  1522         pos = &XnPropertyNames::softkey::type::KLeft;
  1530         pos = CEikButtonGroupContainer::ELeftSoftkeyPosition;
  1523         }
  1531         }
  1524     else if( aKeyEvent.iScanCode == EStdKeyDevice1 )
  1532     else if( aKeyEvent.iScanCode == EStdKeyDevice1 )
  1525         {
  1533         {
  1526         pos = &XnPropertyNames::softkey::type::KRight;
  1534         pos = CEikButtonGroupContainer::ERightSoftkeyPosition;
  1527         }
  1535         }
  1528     else if( aKeyEvent.iScanCode == EStdKeyDevice3 )
  1536     else if( aKeyEvent.iScanCode == EStdKeyDevice3 )
  1529         {
  1537         {
  1530         pos = &XnPropertyNames::softkey::type::KMiddle;
  1538         pos = CEikButtonGroupContainer::EMiddleSoftkeyPosition;
  1531         }            
  1539         }            
  1532     
  1540     
  1533     if( aType == EEventKeyDown )
  1541     CXnSoftkeyItem* softkey( NULL );
  1534         {                                  
  1542     
  1535         iKeyEventNode = FindSoftkeyNodeL( *pos );           
  1543     if ( pos != KErrNotFound )
  1536         }
  1544         {
  1537             
  1545         softkey = SoftkeyItemL( pos );
  1538     if( aKeyEvent.iScanCode == EStdKeyDevice0 || 
  1546         }
  1539         aKeyEvent.iScanCode == EStdKeyDevice1 || 
  1547         
  1540         aKeyEvent.iScanCode == EStdKeyDevice3 )
  1548     if ( softkey )
  1541         {
  1549         {
  1542         CXnNodePluginIf* node(  FindSoftkeyNodeL( *pos ) );
  1550         CXnNodePluginIf* node( softkey->iNode );
  1543         
  1551         
       
  1552         if( aType == EEventKeyDown )
       
  1553             {                                  
       
  1554             iKeyEventNode = node;           
       
  1555             }
       
  1556                        
  1544         if( node && node == iKeyEventNode )
  1557         if( node && node == iKeyEventNode )
  1545             {
  1558             {
  1546             // Let base class handle the event           
  1559             // Let base class handle the event           
  1547             resp = CXnControlAdapter::OfferKeyEventL( aKeyEvent, aType );                                        
  1560             resp = CXnControlAdapter::OfferKeyEventL( aKeyEvent, aType );                                        
  1548             }            
  1561             }            
  1549         }
  1562         }
  1550         
  1563             
  1551     if( aType == EEventKeyUp )
  1564     if( aType == EEventKeyUp )
  1552         {
  1565         {
  1553         iKeyEventNode = NULL;
  1566         iKeyEventNode = NULL;
  1554         }
  1567         }
  1555         
  1568         
  1723 // CXnMenuAdapter::SetContainerL
  1736 // CXnMenuAdapter::SetContainerL
  1724 // 
  1737 // 
  1725 // -----------------------------------------------------------------------------
  1738 // -----------------------------------------------------------------------------
  1726 //
  1739 //
  1727 void CXnMenuAdapter::SetContainerL( CEikButtonGroupContainer& aContainer )
  1740 void CXnMenuAdapter::SetContainerL( CEikButtonGroupContainer& aContainer )
  1728     {
  1741     {    
  1729     
       
  1730     User::LeaveIfNull( &aContainer );
  1742     User::LeaveIfNull( &aContainer );
  1731     
  1743     
  1732     TBool updateNeeded( EFalse );
  1744     TBool updateNeeded( EFalse );
  1733     
  1745     
  1734     TInt statusPaneId( iAvkonAppUi->StatusPane()->CurrentLayoutResId() );
  1746     TInt statusPaneId( iAvkonAppUi->StatusPane()->CurrentLayoutResId() );
  1767     return iMenuShown;
  1779     return iMenuShown;
  1768     }
  1780     }
  1769 
  1781 
  1770 // -----------------------------------------------------------------------------
  1782 // -----------------------------------------------------------------------------
  1771 // CXnMenuAdapter::TryDisplayingMenuL
  1783 // CXnMenuAdapter::TryDisplayingMenuL
  1772 // Displays options menu if it is defined for the softkey item
  1784 // Displays options menu 
  1773 // -----------------------------------------------------------------------------
  1785 // -----------------------------------------------------------------------------
  1774 //
  1786 //
  1775 void CXnMenuAdapter::TryDisplayingMenuL( const TDesC& aMenuNodeId )
  1787 void CXnMenuAdapter::TryDisplayingMenuL( const TDesC& aMenuNodeId, 
       
  1788     TBool aContextMenu )
  1776     {
  1789     {
  1777     HBufC8* id = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aMenuNodeId );
  1790     HBufC8* id = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aMenuNodeId );
  1778     CleanupStack::PushL( id );
  1791     CleanupStack::PushL( id );
  1779     CXnNodePluginIf* node( iUiEngine->FindNodeByIdL( *id, iRootNode->Namespace() ) );
  1792     CXnNodePluginIf* node( iUiEngine->FindNodeByIdL( *id, iRootNode->Namespace() ) );
  1780     CleanupStack::PopAndDestroy( id );
  1793     CleanupStack::PopAndDestroy( id );
       
  1794     
       
  1795     iContextMenu = aContextMenu;
  1781     
  1796     
  1782     if( node && node->Type()->Type() == KXnMenu )
  1797     if( node && node->Type()->Type() == KXnMenu )
  1783         {
  1798         {
  1784         TryDisplayingMenuL();
  1799         TryDisplayingMenuL();
  1785         }
  1800         }
  1815 // -----------------------------------------------------------------------------
  1830 // -----------------------------------------------------------------------------
  1816 // CXnMenuAdapter::StopDisplayingMenu
  1831 // CXnMenuAdapter::StopDisplayingMenu
  1817 // -----------------------------------------------------------------------------
  1832 // -----------------------------------------------------------------------------
  1818 //
  1833 //
  1819 void CXnMenuAdapter::StopDisplayingMenu()
  1834 void CXnMenuAdapter::StopDisplayingMenu()
  1820     {
  1835     {       
  1821     if( iMenuShown && iMenuBar )
  1836     if( iMenuBar )
  1822         {
  1837         {
  1823         iMenuBar->StopDisplayingMenuBar();
  1838         iMenuBar->StopDisplayingMenuBar();
  1824         }
  1839         }
  1825     }
  1840     }
  1826 
  1841 
  2092     if(item)
  2107     if(item)
  2093         {
  2108         {
  2094         node = item->iNode;
  2109         node = item->iNode;
  2095         }
  2110         }
  2096     return node;
  2111     return node;
       
  2112     }
       
  2113 
       
  2114 // -----------------------------------------------------------------------------
       
  2115 // CXnMenuAdapter::KeyEventNode
       
  2116 // 
       
  2117 // -----------------------------------------------------------------------------
       
  2118 //
       
  2119 CXnNodePluginIf* CXnMenuAdapter::KeyEventNode()
       
  2120     {
       
  2121     return iKeyEventNode;
  2097     }
  2122     }
  2098 
  2123 
  2099 // -----------------------------------------------------------------------------
  2124 // -----------------------------------------------------------------------------
  2100 // CXnMenuAdapter::HandleScreenDeviceChangedL
  2125 // CXnMenuAdapter::HandleScreenDeviceChangedL
  2101 // 
  2126 //