browserui/browser/FavouritesInc/CommandVisibility.h
changeset 0 84ad3b177aa3
equal deleted inserted replaced
-1:000000000000 0:84ad3b177aa3
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *      Declaration of class TCmdVisibility.
       
    16 *      
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef COMMAND_VISIBILITY_H
       
    22 #define COMMAND_VISIBILITY_H
       
    23 
       
    24 // INCLUDE FILES
       
    25 
       
    26 #include <e32base.h>
       
    27 
       
    28 // FORWARD DECLARATION
       
    29 
       
    30 struct TBrowserFavouritesSelectionState;
       
    31 
       
    32 // CLASS DECLARATION
       
    33 
       
    34 /**
       
    35 * Visibility info on one menu command. Unfortunately this cannot be put into
       
    36 * a class, since it is initialized statically. Commands of menu panes are
       
    37 * put into TCommandVisibilityMap-s (an array of TCommandVisibilityInfo).
       
    38 * One TCommandVisibilityInfo contains the following information:
       
    39 * 0. TInt The command.
       
    40 * 1-5. Visibility under different selection conditions.
       
    41 * TCommandVisibility::TIndex is used to index into the array.
       
    42 */
       
    43 typedef const TInt TCommandVisibilityInfo[6];
       
    44 
       
    45 /**
       
    46 * Variable length array of TCommandVisibilityInfo (i.e. commands and their
       
    47 * visibility); the array is terminated with -1. This array is handled by
       
    48 * TCommandVisibility.
       
    49 */
       
    50 typedef const TCommandVisibilityInfo* TCommandVisibilityMap;
       
    51 
       
    52 /*
       
    53 * This struct provides a way to initialize menu panes with using visibility
       
    54 * info arrays.
       
    55 */
       
    56 class TCommandVisibility
       
    57     {
       
    58     public:     // types
       
    59 
       
    60         /*
       
    61         * Indexes into the visibility info.
       
    62         */
       
    63         enum TIndex
       
    64             {
       
    65             ECommand = 0,   ///<      The command.
       
    66             ENothing,       ///< (0)  Visibility (nothing is selected).
       
    67             EOneItem,       ///< (1i) Visibility (one item is selected).
       
    68             EOneFolder,     ///< (1f) Visibility (one folder is selected).
       
    69             EMoreItems,     ///< (*i) Visibility (more selected no folders).
       
    70             EItemsFolders,  ///< (*)  Visibility (more selected, incl folders).
       
    71             EInvalid = -1   ///<      Unused (sanity checking).
       
    72             };
       
    73 
       
    74     public:     // new methods
       
    75 
       
    76         /**
       
    77         * Apply visibility to this menu pane (dim commands).
       
    78         * @param aMenuPane Menu pane to dim.
       
    79         * @param aCommandInfo Command visibility info to apply.
       
    80         * @param aIndex Index to use.
       
    81         */
       
    82         static void Apply
       
    83             (
       
    84             CEikMenuPane* aMenuPane,
       
    85             TCommandVisibilityMap aCommandInfo,
       
    86             TIndex aIndex
       
    87             );
       
    88 
       
    89         /**
       
    90         * Checks whether the menu item can be shown. As this method does not
       
    91         * get any menu panes, it will not dim menu items.
       
    92         * @param aCommandInfo Command visibility info to apply.
       
    93         * @param aIndex Index to use.
       
    94         * @return EFalse if the menu item for the appropriate command is not
       
    95         * to be shown. This method returns EFalse otherwise.
       
    96         */
       
    97         static TBool Apply
       
    98             (
       
    99             const TCommandVisibilityInfo& aCommandInfo,
       
   100             TIndex aIndex
       
   101             );
       
   102 
       
   103         /**
       
   104         * Calculate index into the visibility info, based on selection state.
       
   105         * @param aSelectionState Selection state.
       
   106         * @param aMarkedOnly If ETrue, consider only marked items.
       
   107         * @return The index.
       
   108         */
       
   109         static TIndex Index
       
   110             (
       
   111             const TBrowserFavouritesSelectionState& aSelectionState,
       
   112             TBool aMarkedOnly
       
   113             );
       
   114     };
       
   115 
       
   116 
       
   117 // CONSTANTS
       
   118 
       
   119 // Controlling the visibility.
       
   120 #define SHOW ETrue      ///< Show this command (do not dim).
       
   121 #define DIM EFalse      ///< Dim this command.
       
   122 #define CUSTOM ETrue    ///< Custom handling (for the moment, do not dim).
       
   123 #define VOID ETrue      ///< Never evaluated.
       
   124 
       
   125 #endif
       
   126 
       
   127 // End of file