uifw/EikStd/coctlsrc/aknitemactionmenu.cpp
branchRCL_3
changeset 19 aecbbf00d063
parent 18 fcdfafb36fe7
child 20 d48ab3b357f1
equal deleted inserted replaced
18:fcdfafb36fe7 19:aecbbf00d063
     1 /*
     1 /*
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    26 #include <eikpanic.h>
    26 #include <eikpanic.h>
    27 
    27 
    28 #include "akncollectionobserver.h"
    28 #include "akncollectionobserver.h"
    29 #include "aknitemactionmenudata.h"
    29 #include "aknitemactionmenudata.h"
    30 #include "aknitemactionmenuregister.h"
    30 #include "aknitemactionmenuregister.h"
    31 #include "akntrace.h"
       
    32 #include "aknmarkingmode.h"
       
    33 
    31 
    34 /**
    32 /**
    35  * Index for invalid list index.
    33  * Index for invalid list index.
    36  */
    34  */
    37 const TInt KInvalidListIndex( -1 );
    35 const TInt KInvalidListIndex( -1 );
    39 // ---------------------------------------------------------------------------
    37 // ---------------------------------------------------------------------------
    40 // CAknItemActionMenu::NewL
    38 // CAknItemActionMenu::NewL
    41 // ---------------------------------------------------------------------------
    39 // ---------------------------------------------------------------------------
    42 //
    40 //
    43 CAknItemActionMenu* CAknItemActionMenu::NewL(
    41 CAknItemActionMenu* CAknItemActionMenu::NewL(
    44         MAknCollection& aCollection, MObjectProvider* aOwner )
    42         MAknCollection& aCollection )
    45     {
    43     {
    46     _AKNTRACE_FUNC_ENTER;
    44     CAknItemActionMenu* self = CAknItemActionMenu::NewLC( aCollection );
    47     CAknItemActionMenu* self = CAknItemActionMenu::NewLC( 
       
    48             aCollection, aOwner );
       
    49     CleanupStack::Pop( self );
    45     CleanupStack::Pop( self );
    50     _AKNTRACE_FUNC_EXIT;
       
    51     return self;
    46     return self;
    52     }
    47     }
    53 
    48 
    54 
    49 
    55 // ---------------------------------------------------------------------------
    50 // ---------------------------------------------------------------------------
    56 // CAknItemActionMenu::NewLC
    51 // CAknItemActionMenu::NewLC
    57 // ---------------------------------------------------------------------------
    52 // ---------------------------------------------------------------------------
    58 //
    53 //
    59 CAknItemActionMenu* CAknItemActionMenu::NewLC(
    54 CAknItemActionMenu* CAknItemActionMenu::NewLC( MAknCollection& aCollection )
    60         MAknCollection& aCollection, MObjectProvider* aOwner )
    55     {
    61     {
    56     CAknItemActionMenu* self = new ( ELeave ) CAknItemActionMenu();
    62     _AKNTRACE_FUNC_ENTER;
       
    63     CAknItemActionMenu* self = new ( ELeave ) CAknItemActionMenu( aOwner );
       
    64     CleanupStack::PushL( self );
    57     CleanupStack::PushL( self );
    65     self->ConstructL( aCollection );
    58     self->ConstructL( aCollection );
    66     _AKNTRACE_FUNC_EXIT;
       
    67     return self;
    59     return self;
    68     }
    60     }
    69 
    61 
    70 
    62 
    71 // ---------------------------------------------------------------------------
    63 // ---------------------------------------------------------------------------
    72 // CAknItemActionMenu::~CAknItemActionMenu
    64 // CAknItemActionMenu::~CAknItemActionMenu
    73 // ---------------------------------------------------------------------------
    65 // ---------------------------------------------------------------------------
    74 //
    66 //
    75 CAknItemActionMenu::~CAknItemActionMenu()
    67 CAknItemActionMenu::~CAknItemActionMenu()
    76     {
    68     {
    77     _AKNTRACE_FUNC_ENTER;
       
    78     AKNTASHOOK_REMOVE();
    69     AKNTASHOOK_REMOVE();
    79     delete iPopupMenu;
    70     delete iPopupMenu;
    80     delete iMenuPane;
    71     delete iMenuPane;
    81     delete iMenuData;
    72     delete iMenuData;
    82     delete iMarking;
       
    83     iStates.Close();
    73     iStates.Close();
    84     
       
    85     for ( TInt i = 0; i < iObservers.Count(); ++i )
       
    86         {
       
    87         iObservers[i]->SetItemActionMenu( NULL );
       
    88         }
       
    89 
       
    90     iObservers.Close();
    74     iObservers.Close();
    91     _AKNTRACE_FUNC_EXIT;
       
    92     }
    75     }
    93 
    76 
    94 
    77 
    95 // ---------------------------------------------------------------------------
    78 // ---------------------------------------------------------------------------
    96 // CAknItemActionMenu::RegisterCollectionL
    79 // CAknItemActionMenu::RegisterCollectionL
    97 // ---------------------------------------------------------------------------
    80 // ---------------------------------------------------------------------------
    98 //
    81 //
    99 EXPORT_C CAknItemActionMenu* CAknItemActionMenu::RegisterCollectionL(
    82 EXPORT_C CAknItemActionMenu* CAknItemActionMenu::RegisterCollectionL(
   100         MAknCollection& aCollection )
    83         MAknCollection& aCollection )
   101     {
    84     {
   102     _AKNTRACE_FUNC_ENTER;
    85     return AknItemActionMenuRegister::RegisterCollectionL( aCollection );
   103     _AKNTRACE_FUNC_EXIT;
       
   104     return AknItemActionMenuRegister::RegisterCollectionL(
       
   105             aCollection, NULL );
       
   106     }
       
   107 
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // CAknItemActionMenu::RegisterCollectionL
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 EXPORT_C CAknItemActionMenu* CAknItemActionMenu::RegisterCollectionL(
       
   114         MAknCollection& aCollection, MObjectProvider* aMenuBarOwner )
       
   115     {
       
   116     _AKNTRACE_FUNC_ENTER;
       
   117     _AKNTRACE_FUNC_EXIT;
       
   118     return AknItemActionMenuRegister::RegisterCollectionL( 
       
   119             aCollection, aMenuBarOwner );
       
   120     }
    86     }
   121 
    87 
   122 
    88 
   123 // ---------------------------------------------------------------------------
    89 // ---------------------------------------------------------------------------
   124 // CAknItemActionMenu::RemoveCollection
    90 // CAknItemActionMenu::RemoveCollection
   125 // ---------------------------------------------------------------------------
    91 // ---------------------------------------------------------------------------
   126 //
    92 //
   127 EXPORT_C void CAknItemActionMenu::RemoveCollection(
    93 EXPORT_C void CAknItemActionMenu::RemoveCollection(
   128         MAknCollection& aCollection )
    94         MAknCollection& aCollection )
   129     {
    95     {
   130     _AKNTRACE_FUNC_ENTER;
       
   131     for ( TInt i = 0; i < iStates.Count(); i++ )
    96     for ( TInt i = 0; i < iStates.Count(); i++ )
   132         {
    97         {
   133         MAknCollection* state( iStates[ i ] );
    98         MAknCollection* state( iStates[ i ] );
   134         if ( state == &aCollection )
    99         if ( state == &aCollection )
   135             {
   100             {
   136             iStates.Remove( i );
   101             iStates.Remove( i );
   137             break;
   102             break;
   138             }
   103             }
   139         }
   104         }
   140     UnregisterMenu(); 
   105     UnregisterMenu(); 
   141     _AKNTRACE_FUNC_EXIT;
       
   142     }
   106     }
   143 
   107 
   144 
   108 
   145 // ---------------------------------------------------------------------------
   109 // ---------------------------------------------------------------------------
   146 // CAknItemActionMenu::InitMenuL
   110 // CAknItemActionMenu::InitMenuL
   147 // ---------------------------------------------------------------------------
   111 // ---------------------------------------------------------------------------
   148 //
   112 //
   149 EXPORT_C TBool CAknItemActionMenu::InitMenuL()
   113 EXPORT_C TBool CAknItemActionMenu::InitMenuL()
   150     {
   114     {
   151     _AKNTRACE_FUNC_ENTER;
       
   152     iMenuData->Reset();
   115     iMenuData->Reset();
   153     if ( !iMenuBar )
   116     if ( !iMenuBar )
   154         {
   117         {
   155         AknItemActionMenuRegister::RegisterItemActionMenuL( *this );
   118         AknItemActionMenuRegister::RegisterItemActionMenuL( *this );
   156         }
   119         }
   166     else
   129     else
   167         {
   130         {
   168         return EFalse;
   131         return EFalse;
   169         }
   132         }
   170 
   133 
   171     _AKNTRACE_FUNC_EXIT;
       
   172     return iMenuData->Count();
   134     return iMenuData->Count();
   173     }
   135     }
   174 
   136 
   175 
   137 
   176 // ---------------------------------------------------------------------------
   138 // ---------------------------------------------------------------------------
   179 //
   141 //
   180 EXPORT_C void CAknItemActionMenu::ShowMenuL(
   142 EXPORT_C void CAknItemActionMenu::ShowMenuL(
   181         const TPoint& aPosition,
   143         const TPoint& aPosition,
   182         TUint /*aFlags*/ )
   144         TUint /*aFlags*/ )
   183     {
   145     {
   184     _AKNTRACE_FUNC_ENTER;
       
   185     if ( iMenuData->Count() )
   146     if ( iMenuData->Count() )
   186         {
   147         {
   187         if ( !iPopupMenu )
   148         if ( !iPopupMenu )
   188             {
   149             {
   189             iPopupMenu = CAknStylusPopUpMenu::NewL( this, TPoint(), NULL,
   150             iPopupMenu = CAknStylusPopUpMenu::NewL( this, TPoint() );
   190                     CAknStylusPopUpMenu::EConsumeKeyEvents );
       
   191             }
   151             }
   192         iPopupMenu->Clear();
   152         iPopupMenu->Clear();
   193         iMenuData->AddMenuItemsToStylusPopupMenuL( iPopupMenu );
   153         iMenuData->AddMenuItemsToStylusPopupMenuL( iPopupMenu );
   194         iPopupMenu->SetPosition(
   154         iPopupMenu->SetPosition(
   195                 aPosition,
   155                 aPosition,
   196                 CAknStylusPopUpMenu::EPositionTypeRightBottom );
   156                 CAknStylusPopUpMenu::EPositionTypeRightBottom );
   197         iPopupMenu->ShowMenu();
   157         iPopupMenu->ShowMenu();
   198         }
   158         }
   199     _AKNTRACE_FUNC_EXIT;
       
   200     }
   159     }
   201 
   160 
   202 
   161 
   203 // ---------------------------------------------------------------------------
   162 // ---------------------------------------------------------------------------
   204 // CAknItemActionMenu::CollectionChanged
   163 // CAknItemActionMenu::CollectionChanged
   205 // ---------------------------------------------------------------------------
   164 // ---------------------------------------------------------------------------
   206 //
   165 //
   207 EXPORT_C void CAknItemActionMenu::CollectionChanged(
   166 EXPORT_C void CAknItemActionMenu::CollectionChanged(
   208         MAknCollection& aCollection )
   167         MAknCollection& aCollection )
   209     {
   168     {
   210     _AKNTRACE_FUNC_ENTER;
       
   211     if ( iObservers.Count() && iStates.Find( &aCollection ) != KErrNotFound )
   169     if ( iObservers.Count() && iStates.Find( &aCollection ) != KErrNotFound )
   212         {
   170         {
   213         TBool collectionVisible( aCollection.CollectionState()
   171         TBool collectionVisible( aCollection.CollectionState()
   214                 & MAknCollection::EStateCollectionVisible );
   172                 & MAknCollection::EStateCollectionVisible );
   215         NotifyChangeToActiveObserver( collectionVisible );
   173         NotifyChangeToActiveObserver( collectionVisible );
   216         }
   174         }
   217     _AKNTRACE_FUNC_EXIT;
       
   218     }
   175     }
   219 
   176 
   220 
   177 
   221 // ---------------------------------------------------------------------------
   178 // ---------------------------------------------------------------------------
   222 // CAknItemActionMenu::AddCollectionStateL
   179 // CAknItemActionMenu::AddCollectionStateL
   223 // ---------------------------------------------------------------------------
   180 // ---------------------------------------------------------------------------
   224 //
   181 //
   225 void CAknItemActionMenu::AddCollectionStateL(
   182 void CAknItemActionMenu::AddCollectionStateL(
   226         MAknCollection& aCollection )
   183         MAknCollection& aCollection )
   227     {
   184     {
   228     _AKNTRACE_FUNC_ENTER;
       
   229     if ( iStates.Find( &aCollection ) == KErrNotFound )
   185     if ( iStates.Find( &aCollection ) == KErrNotFound )
   230         {
   186         {
   231         iStates.InsertL( &aCollection, 0 );
   187         iStates.InsertL( &aCollection, 0 );
   232         }
   188         }
   233     _AKNTRACE_FUNC_EXIT;
       
   234     }
   189     }
   235 
   190 
   236 
   191 
   237 // ---------------------------------------------------------------------------
   192 // ---------------------------------------------------------------------------
   238 // CAknItemActionMenu::SetMenuBar
   193 // CAknItemActionMenu::SetMenuBar
   240 //
   195 //
   241 void CAknItemActionMenu::SetMenuBar(
   196 void CAknItemActionMenu::SetMenuBar(
   242         MEikMenuObserver* aMenuObserver,
   197         MEikMenuObserver* aMenuObserver,
   243         CEikMenuBar* aMenuBar )
   198         CEikMenuBar* aMenuBar )
   244     {
   199     {
   245     _AKNTRACE_FUNC_ENTER;
       
   246     iMenuBarObserver = aMenuObserver;
   200     iMenuBarObserver = aMenuObserver;
   247     iMenuBar = aMenuBar;
   201     iMenuBar = aMenuBar;
   248     _AKNTRACE_FUNC_EXIT;
       
   249     }
   202     }
   250 
   203 
   251 
   204 
   252 // ---------------------------------------------------------------------------
   205 // ---------------------------------------------------------------------------
   253 // CAknItemActionMenu::CollectionHighlightVisible
   206 // CAknItemActionMenu::CollectionHighlightVisible
   254 // ---------------------------------------------------------------------------
   207 // ---------------------------------------------------------------------------
   255 //
   208 //
   256 TBool CAknItemActionMenu::CollectionHighlightVisible() const
   209 TBool CAknItemActionMenu::CollectionHighlightVisible() const
   257     {
   210     {
   258     _AKNTRACE_FUNC_ENTER;
       
   259     TBool highlightVisible( ETrue );
   211     TBool highlightVisible( ETrue );
   260     for ( TInt i = 0; i < iStates.Count(); i++ )
   212     for ( TInt i = 0; i < iStates.Count(); i++ )
   261         {
   213         {
   262         MAknCollection* collection( iStates[ i ] );
   214         MAknCollection* state( iStates[ i ] );
   263         TUint state = collection->CollectionState();
   215         if ( state->CollectionState() &
   264 
   216                 MAknCollection::EStateCollectionVisible )
   265         highlightVisible = state & MAknCollection::EStateHighlightVisible;
   217             {
   266         
   218             highlightVisible = state->CollectionState()
   267         if ( highlightVisible )
   219                 & MAknCollection::EStateHighlightVisible;
   268             {
       
   269             // Highlight can't be visible if the collection is not visible.
       
   270             highlightVisible = state & MAknCollection::EStateCollectionVisible;
       
   271             break;
   220             break;
   272             }
   221             }
   273         }
   222         }
   274     _AKNTRACE_FUNC_EXIT;
       
   275     return highlightVisible;
   223     return highlightVisible;
   276     }
   224     }
   277 
   225 
   278 
   226 
   279 // ---------------------------------------------------------------------------
   227 // ---------------------------------------------------------------------------
   281 // ---------------------------------------------------------------------------
   229 // ---------------------------------------------------------------------------
   282 //
   230 //
   283 TBool CAknItemActionMenu::CollectionSoftkeyVisible(
   231 TBool CAknItemActionMenu::CollectionSoftkeyVisible(
   284         TBool aVisibleCollection ) const
   232         TBool aVisibleCollection ) const
   285     {
   233     {
   286     _AKNTRACE_FUNC_ENTER;
       
   287     TBool softkeyVisible( ETrue );
   234     TBool softkeyVisible( ETrue );
   288     for ( TInt i = 0; i < iStates.Count(); i++ )
   235     for ( TInt i = 0; i < iStates.Count(); i++ )
   289         {
   236         {
   290         TInt state( iStates[ i ]->CollectionState() );
   237         TInt state( iStates[ i ]->CollectionState() );
   291         if ( !aVisibleCollection
   238         if ( !aVisibleCollection
   302                     state & MAknCollection::EStateHighlightVisible;
   249                     state & MAknCollection::EStateHighlightVisible;
   303                 }
   250                 }
   304             break;
   251             break;
   305             }
   252             }
   306         }
   253         }
   307     _AKNTRACE_FUNC_EXIT;
       
   308     return softkeyVisible;
   254     return softkeyVisible;
   309     }
   255     }
   310 
   256 
   311 
   257 
   312 // ---------------------------------------------------------------------------
   258 // ---------------------------------------------------------------------------
   313 // CAknItemActionMenu::MenuData
   259 // CAknItemActionMenu::MenuData
   314 // ---------------------------------------------------------------------------
   260 // ---------------------------------------------------------------------------
   315 //
   261 //
   316 CAknItemActionMenuData& CAknItemActionMenu::MenuData()
   262 CAknItemActionMenuData& CAknItemActionMenu::MenuData()
   317     {
   263     {
   318     _AKNTRACE_FUNC_ENTER;
       
   319     _AKNTRACE_FUNC_EXIT;
       
   320     return *iMenuData;
   264     return *iMenuData;
   321     }
   265     }
   322 
   266 
   323 
   267 
   324 // ---------------------------------------------------------------------------
   268 // ---------------------------------------------------------------------------
   326 // ---------------------------------------------------------------------------
   270 // ---------------------------------------------------------------------------
   327 //
   271 //
   328 void CAknItemActionMenu::RegisterCollectionObserverL(
   272 void CAknItemActionMenu::RegisterCollectionObserverL(
   329         MAknCollectionObserver& aObserver )
   273         MAknCollectionObserver& aObserver )
   330     {
   274     {
   331     _AKNTRACE_FUNC_ENTER;
       
   332     if ( iObservers.Find( &aObserver ) == KErrNotFound )
   275     if ( iObservers.Find( &aObserver ) == KErrNotFound )
   333         {
   276         {
   334         iObservers.InsertL( &aObserver, 0 );
   277         iObservers.InsertL( &aObserver, 0 );
   335         aObserver.SetItemActionMenu( this );
   278         aObserver.SetItemActionMenu( this );
   336         }
   279         }
   337     _AKNTRACE_FUNC_EXIT;
       
   338     }
   280     }
   339 
   281 
   340 
   282 
   341 // ---------------------------------------------------------------------------
   283 // ---------------------------------------------------------------------------
   342 // CAknItemActionMenu::RemoveCollectionObserver
   284 // CAknItemActionMenu::RemoveCollectionObserver
   343 // ---------------------------------------------------------------------------
   285 // ---------------------------------------------------------------------------
   344 //
   286 //
   345 void CAknItemActionMenu::RemoveCollectionObserver(
   287 void CAknItemActionMenu::RemoveCollectionObserver(
   346         MAknCollectionObserver& aObserver )
   288         MAknCollectionObserver& aObserver )
   347     {
   289     {
   348     _AKNTRACE_FUNC_ENTER;
       
   349     TInt index( iObservers.Find( &aObserver ) );
   290     TInt index( iObservers.Find( &aObserver ) );
   350     if ( index != KErrNotFound )
   291     if ( index != KErrNotFound )
   351         {
   292         {
   352         iObservers.Remove( index );
   293         iObservers.Remove( index );
   353         UnregisterMenu(); 
   294         UnregisterMenu(); 
   354         }
   295         }
   355     _AKNTRACE_FUNC_EXIT;
       
   356     }
   296     }
   357 
   297 
   358 
   298 
   359 // ---------------------------------------------------------------------------
   299 // ---------------------------------------------------------------------------
   360 // CAknItemActionMenu::CollectionCount
   300 // CAknItemActionMenu::CollectionCount
   361 // ---------------------------------------------------------------------------
   301 // ---------------------------------------------------------------------------
   362 //
   302 //
   363 TInt CAknItemActionMenu::CollectionCount() const
   303 TInt CAknItemActionMenu::CollectionCount() const
   364     {
   304     {
   365     _AKNTRACE_FUNC_ENTER;
       
   366     _AKNTRACE_FUNC_EXIT;
       
   367     return iStates.Count();
   305     return iStates.Count();
   368     }
   306     }
   369 
   307 
   370 
   308 
   371 // ---------------------------------------------------------------------------
   309 // ---------------------------------------------------------------------------
   372 // CAknItemActionMenu::Owner
       
   373 // ---------------------------------------------------------------------------
       
   374 //
       
   375  MObjectProvider* CAknItemActionMenu::Owner() const
       
   376      {
       
   377     _AKNTRACE_FUNC_ENTER;
       
   378     _AKNTRACE_FUNC_EXIT;
       
   379      return iOwner;
       
   380      }
       
   381 
       
   382 
       
   383 // ---------------------------------------------------------------------------
       
   384 // CAknItemActionMenu::MarkingMode
       
   385 // ---------------------------------------------------------------------------
       
   386 //
       
   387 CAknMarkingMode& CAknItemActionMenu::MarkingMode()
       
   388     {
       
   389     _AKNTRACE_FUNC_ENTER;
       
   390     _AKNTRACE_FUNC_EXIT;
       
   391     return *iMarking;
       
   392     }
       
   393 
       
   394 
       
   395 // ---------------------------------------------------------------------------
       
   396 // CAknItemActionMenu::CollectionHasMarkedItems
       
   397 // ---------------------------------------------------------------------------
       
   398 //
       
   399 TBool CAknItemActionMenu::CollectionHasMarkedItems()
       
   400     {
       
   401     _AKNTRACE_FUNC_ENTER;
       
   402     TBool markedItems( EFalse );
       
   403     for ( TInt i = 0; i < iStates.Count(); i++ )
       
   404         {
       
   405         TInt state( iStates[ i ]->CollectionState() );
       
   406         if ( state & MAknCollection::EStateCollectionVisible )
       
   407             {
       
   408             if ( state & MAknCollection::EStateMarkedItems )
       
   409                 {
       
   410                 markedItems = ETrue;
       
   411                 }
       
   412             }
       
   413         }
       
   414     _AKNTRACE_FUNC_EXIT;
       
   415     return markedItems;
       
   416     }
       
   417 
       
   418 
       
   419 // ---------------------------------------------------------------------------
       
   420 // CAknItemActionMenu::HideMenu
       
   421 // ---------------------------------------------------------------------------
       
   422 //
       
   423 void CAknItemActionMenu::HideMenu()
       
   424     {
       
   425     if ( iPopupMenu && !iProcessingCommand )
       
   426         {
       
   427         iPopupMenu->HideMenu();
       
   428         }
       
   429     }
       
   430 
       
   431 
       
   432 // ---------------------------------------------------------------------------
       
   433 // CAknItemActionMenu::CAknItemActionMenu
   310 // CAknItemActionMenu::CAknItemActionMenu
   434 // ---------------------------------------------------------------------------
   311 // ---------------------------------------------------------------------------
   435 //
   312 //
   436 CAknItemActionMenu::CAknItemActionMenu( MObjectProvider* aOwner )
   313 CAknItemActionMenu::CAknItemActionMenu()
   437     : iPopupMenu( NULL ),
   314     : iPopupMenu( NULL ),
   438     iMenuBarObserver( NULL ),
   315     iMenuBarObserver( NULL ),
   439     iMenuBar( NULL ),
   316     iMenuBar( NULL ),
   440     iMenuPane( NULL ),
   317     iMenuPane( NULL ),
   441     iMenuData( NULL ),
   318     iMenuData( NULL )
   442     iOwner( aOwner ),
   319     {
   443     iMarking( NULL )
       
   444     {
       
   445     _AKNTRACE_FUNC_ENTER;
       
   446     AKNTASHOOK_ADD( this, "CAknItemActionMenu" );
   320     AKNTASHOOK_ADD( this, "CAknItemActionMenu" );
   447     _AKNTRACE_FUNC_EXIT;
       
   448     }
   321     }
   449 
   322 
   450 
   323 
   451 // ---------------------------------------------------------------------------
   324 // ---------------------------------------------------------------------------
   452 // CAknItemActionMenu::ConstructL
   325 // CAknItemActionMenu::ConstructL
   453 // ---------------------------------------------------------------------------
   326 // ---------------------------------------------------------------------------
   454 //
   327 //
   455 void CAknItemActionMenu::ConstructL( MAknCollection& aCollection )
   328 void CAknItemActionMenu::ConstructL( MAknCollection& aCollection )
   456     {
   329     {
   457     _AKNTRACE_FUNC_ENTER;
       
   458     AddCollectionStateL( aCollection );
   330     AddCollectionStateL( aCollection );
   459     iMenuData = CAknItemActionMenuData::NewL();
   331     iMenuData = CAknItemActionMenuData::NewL();
   460     iMarking = CAknMarkingMode::NewL( *this, iStates );
       
   461     _AKNTRACE_FUNC_EXIT;
       
   462     }
   332     }
   463 
   333 
   464 
   334 
   465 // ---------------------------------------------------------------------------
   335 // ---------------------------------------------------------------------------
   466 // CAknItemActionMenu::LaunchSubMenuQueryL
   336 // CAknItemActionMenu::LaunchSubMenuQueryL
   467 // ---------------------------------------------------------------------------
   337 // ---------------------------------------------------------------------------
   468 //
   338 //
   469 TInt CAknItemActionMenu::LaunchSubMenuQueryL( const TDesC& aHeading )
   339 TInt CAknItemActionMenu::LaunchSubMenuQueryL( const TDesC& aHeading )
   470     {
   340     {
   471     _AKNTRACE_FUNC_ENTER;
       
   472     TInt selectedIndex( KInvalidListIndex );
   341     TInt selectedIndex( KInvalidListIndex );
   473     if ( iMenuData->Count() )
   342     if ( iMenuData->Count() )
   474         {
   343         {
   475         CAknListQueryDialog* queryDialog
   344         CAknListQueryDialog* queryDialog
   476             = new ( ELeave ) CAknListQueryDialog( &selectedIndex );
   345             = new ( ELeave ) CAknListQueryDialog( &selectedIndex );
   482             {
   351             {
   483             queryDialog->QueryHeading()->SetTextL( aHeading );
   352             queryDialog->QueryHeading()->SetTextL( aHeading );
   484             }
   353             }
   485         queryDialog->RunLD();
   354         queryDialog->RunLD();
   486         }
   355         }
   487     _AKNTRACE_FUNC_EXIT;
       
   488     return ++selectedIndex;
   356     return ++selectedIndex;
   489     }
   357     }
   490 
   358 
   491 
   359 
   492 // ---------------------------------------------------------------------------
   360 // ---------------------------------------------------------------------------
   494 // ---------------------------------------------------------------------------
   362 // ---------------------------------------------------------------------------
   495 //
   363 //
   496 void CAknItemActionMenu::NotifyChangeToActiveObserver(
   364 void CAknItemActionMenu::NotifyChangeToActiveObserver(
   497         TBool aCollectionVisible )
   365         TBool aCollectionVisible )
   498     {
   366     {
   499     _AKNTRACE_FUNC_ENTER;
       
   500     for ( TInt i = 0; i < iObservers.Count(); i++ )
   367     for ( TInt i = 0; i < iObservers.Count(); i++ )
   501         {
   368         {
   502         MAknCollectionObserver* observer( iObservers[ i ] );
   369         MAknCollectionObserver* observer( iObservers[ i ] );
   503         if ( observer->Active() )
   370         if ( observer->Active() )
   504             {
   371             {
   505             observer->CollectionChanged( aCollectionVisible );
   372             observer->CollectionChanged( aCollectionVisible );
   506             break;
   373             break;
   507             }
   374             }
   508         }
   375         }
   509     _AKNTRACE_FUNC_EXIT;
       
   510     }
   376     }
   511 
   377 
   512 
   378 
   513 // ---------------------------------------------------------------------------
   379 // ---------------------------------------------------------------------------
   514 // CAknItemActionMenu::SetEmphasis
   380 // CAknItemActionMenu::SetEmphasis
   516 //
   382 //
   517 void CAknItemActionMenu::SetEmphasis(
   383 void CAknItemActionMenu::SetEmphasis(
   518         CCoeControl* /*aMenuControl*/,
   384         CCoeControl* /*aMenuControl*/,
   519         TBool /*aEmphasis*/ )
   385         TBool /*aEmphasis*/ )
   520     {
   386     {
   521     _AKNTRACE_FUNC_ENTER;
       
   522     _AKNTRACE_FUNC_EXIT;
       
   523     }
   387     }
   524 
   388 
   525 
   389 
   526 // ---------------------------------------------------------------------------
   390 // ---------------------------------------------------------------------------
   527 // CAknItemActionMenu::ProcessCommandL
   391 // CAknItemActionMenu::ProcessCommandL
   528 // ---------------------------------------------------------------------------
   392 // ---------------------------------------------------------------------------
   529 //
   393 //
   530 void CAknItemActionMenu::ProcessCommandL( TInt aCommandId )
   394 void CAknItemActionMenu::ProcessCommandL( TInt aCommandId )
   531     {
   395     {
   532     _AKNTRACE_FUNC_ENTER;
       
   533     MAknCollection* informState ( NULL );
   396     MAknCollection* informState ( NULL );
   534     // Store collection state before sending the command
   397     // Store collection state before sending the command
   535     for ( TInt i = 0; i < iStates.Count(); i++ )
   398     for ( TInt i = 0; i < iStates.Count(); i++ )
   536         {
   399         {
   537         MAknCollection* state( iStates[ i ] );
   400         MAknCollection* state( iStates[ i ] );
   548         TInt cascadeId( iMenuData->MenuItemCascadeId( aCommandId ) );
   411         TInt cascadeId( iMenuData->MenuItemCascadeId( aCommandId ) );
   549         if ( cascadeId && iMenuPane )
   412         if ( cascadeId && iMenuPane )
   550             {
   413             {
   551             TMenuItemTextBuf text = iMenuData->MenuItemText( aCommandId );
   414             TMenuItemTextBuf text = iMenuData->MenuItemText( aCommandId );
   552             iMenuData->Reset();
   415             iMenuData->Reset();
   553             iMenuPane->AddCascadeMenuItemsToMenuL(
   416             iMenuPane->AddCascadeMenuItemsToActionMenuL(
   554                     cascadeId, EFalse, ETrue, iMenuData );
   417                     cascadeId, EFalse, *iMenuData );
   555             aCommandId = LaunchSubMenuQueryL( text );
   418             aCommandId = LaunchSubMenuQueryL( text );
   556             }
   419             }
   557                 
   420                 
   558         if ( aCommandId > 0 && iMenuData->MenuItemCommandId( aCommandId ) 
   421         if ( aCommandId > 0 && iMenuBarObserver )
   559                 == EAknCmdMarkingModeMarkOne && iMenuBar )
       
   560             {
       
   561             MarkingMode().MarkCurrentItemL();
       
   562             }
       
   563         else if ( aCommandId > 0 && iMenuBarObserver )
       
   564             {
   422             {
   565             iProcessingCommand = ETrue; 
   423             iProcessingCommand = ETrue; 
   566             iMenuBarObserver->ProcessCommandL(
   424             iMenuBarObserver->ProcessCommandL(
   567                     iMenuData->MenuItemCommandId( aCommandId ) );
   425                     iMenuData->MenuItemCommandId( aCommandId ) );
   568             iProcessingCommand = EFalse; 
   426             iProcessingCommand = EFalse; 
   569             // Try exit marking mode
       
   570             MarkingMode().TryExitMarkingMode();
       
   571             }
   427             }
   572         }
   428         }
   573     // Inform collection that submenu was closed
   429     // Inform collection that submenu was closed
   574     if ( informState && iStates.Find( informState ) != KErrNotFound ) 
   430     if ( iStates.Find( informState ) != KErrNotFound ) 
   575         {
   431         {
   576         informState->ItemActionMenuClosed();
   432         informState->ItemActionMenuClosed();
   577         }
   433         }
   578     UnregisterMenu(); 
   434     UnregisterMenu(); 
   579     _AKNTRACE_FUNC_EXIT;
       
   580     }
   435     }
   581 
   436 
   582 
   437 
   583 // ---------------------------------------------------------------------------
   438 // ---------------------------------------------------------------------------
   584 // CAknItemActionMenu::UnregisterMenu
   439 // CAknItemActionMenu::UnregisterMenu
   585 // ---------------------------------------------------------------------------
   440 // ---------------------------------------------------------------------------
   586 //
   441 //
   587 void CAknItemActionMenu::UnregisterMenu()
   442 void CAknItemActionMenu::UnregisterMenu()
   588     {
   443     {
   589     _AKNTRACE_FUNC_ENTER;
       
   590     if ( !iProcessingCommand && !iStates.Count() && !iObservers.Count() )
   444     if ( !iProcessingCommand && !iStates.Count() && !iObservers.Count() )
   591         {
   445         {
   592         delete iPopupMenu;
   446         delete iPopupMenu;
   593         iPopupMenu = NULL;
   447         iPopupMenu = NULL;
   594         delete iMenuPane;
   448         delete iMenuPane;
   595         iMenuPane = NULL;
   449         iMenuPane = NULL;
   596         AknItemActionMenuRegister::UnregisterItemActionMenu( *this );
   450         AknItemActionMenuRegister::UnregisterItemActionMenu( *this );
   597         }
   451         }
   598     _AKNTRACE_FUNC_EXIT;
       
   599     }
   452     }
   600 
   453 
   601 // End of File
   454 // End of File
   602