javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/inc/swtcommandcontainer.h
branchRCL_3
changeset 14 04becd199f91
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*******************************************************************************
       
     2  * Copyright (c) 2005, 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved. This program and the accompanying materials
       
     4  * are made available under the terms of the Eclipse Public License v1.0
       
     5  * which accompanies this distribution, and is available at
       
     6  * http://www.eclipse.org/legal/epl-v10.html
       
     7  *
       
     8  * Contributors:
       
     9  *     Nokia Corporation - S60 implementation
       
    10  *******************************************************************************/
       
    11 
       
    12 
       
    13 #ifndef SWTCOMMANDCONTAINER_H
       
    14 #define SWTCOMMANDCONTAINER_H
       
    15 
       
    16 
       
    17 #include "eswtmobileextensions.h"
       
    18 
       
    19 
       
    20 /**
       
    21  * CSwtSubCommandContainer
       
    22  * @lib eswt
       
    23  */
       
    24 NONSHARABLE_CLASS(CSwtSubCommandContainer)
       
    25         : public CBase
       
    26 {
       
    27 // Methods
       
    28 public:
       
    29     static CSwtSubCommandContainer* NewL(TBool aFindOperationNeeded,
       
    30     TLinearOrder<CSwtSubCommandContainer> &aSubContainerOrder);
       
    31     ~CSwtSubCommandContainer();
       
    32     void SetParentCommand(const MSwtCommand& aCommand);
       
    33     inline const MSwtCommand* ParentCommand() const;
       
    34     inline const RPointerArray<MSwtCommand>& SubCommands() const;
       
    35     const CSwtSubCommandContainer& SubSubCommandContainer(
       
    36         const MSwtCommand& aCommand) const;
       
    37     TInt InsertCommandInOrder(const MSwtCommand& aCommand,
       
    38                               const TLinearOrder<MSwtCommand>& aOrder, TInt aParentalDepth);
       
    39     void Remove(const MSwtCommand& aCommand, TInt aParentalDepth);
       
    40 
       
    41 private:
       
    42     inline CSwtSubCommandContainer(TLinearOrder<CSwtSubCommandContainer> &aSubContainerOrder);
       
    43     void ConstructL(TBool aFindOperationNeeded);
       
    44 
       
    45 // Data
       
    46 private:
       
    47     const MSwtCommand*                     iParentCommand;               // Parent command of sub commands, not owned
       
    48     RPointerArray<MSwtCommand>             iSubCommands;                 // Sub commands
       
    49     RPointerArray<CSwtSubCommandContainer> iSubSubCommandContainers;     // Containers of sub sub commands
       
    50     CSwtSubCommandContainer*               iSearchedSubCommandContainer; // Utility container used to perform find operation
       
    51     TLinearOrder<CSwtSubCommandContainer>  &iSubContainerOrder;
       
    52 };
       
    53 
       
    54 /**
       
    55  * Returns the parent command of the sub command container
       
    56  */
       
    57 inline const MSwtCommand* CSwtSubCommandContainer::ParentCommand() const
       
    58 {
       
    59     return iParentCommand;
       
    60 }
       
    61 
       
    62 /**
       
    63  * Returns the list of commands of the sub command container
       
    64  */
       
    65 inline const RPointerArray<MSwtCommand>& CSwtSubCommandContainer::SubCommands() const
       
    66 {
       
    67     return iSubCommands;
       
    68 }
       
    69 
       
    70 
       
    71 /**
       
    72  * CSwtCommandContainer
       
    73  * @lib eswt
       
    74  */
       
    75 NONSHARABLE_CLASS(CSwtCommandContainer)
       
    76         : public CBase
       
    77 {
       
    78 // Methods
       
    79 public:
       
    80     static CSwtCommandContainer* NewL();
       
    81     ~CSwtCommandContainer();
       
    82     void SetParentControl(const MSwtControl& aControl);
       
    83     void SetDefaultCommand(const MSwtCommand& aCommand);
       
    84     void ClearDefaultCommand();
       
    85     inline const MSwtControl* Control() const;
       
    86     inline const MSwtCommand* DefaultCommand() const;
       
    87     inline RPointerArray<MSwtCommand>& Commands();
       
    88     const CSwtSubCommandContainer& SubCommandContainer(
       
    89         const MSwtCommand& aCommand);
       
    90     TInt InsertCommandInOrder(const MSwtCommand& aCommand,
       
    91                               const TLinearOrder<MSwtCommand>& aOrder);
       
    92     void Remove(const MSwtCommand& aCommand);
       
    93 
       
    94 private:
       
    95     inline CSwtCommandContainer();
       
    96     void ConstructL();
       
    97     static TInt SubCommandContainerCompare(
       
    98         const CSwtSubCommandContainer& aFirst,
       
    99         const CSwtSubCommandContainer& aSecond);
       
   100 
       
   101 // Data
       
   102 private:
       
   103     const MSwtControl*                     iControl;                     // Parent control of commands, not owned
       
   104     RPointerArray<MSwtCommand>             iCommands;                    // Commands belonging to parent control
       
   105     RPointerArray<CSwtSubCommandContainer> iSubCommandContainers;        // Containers of sub commands (commands that are children of commandgroup commands)
       
   106     const MSwtCommand*                     iDefaultCommand;              // Default command of parent control, not owned, may be null
       
   107     CSwtSubCommandContainer*               iSearchedSubCommandContainer; // Utility container used to perform find operation
       
   108     TLinearOrder<CSwtSubCommandContainer>  iSubContainerOrder;
       
   109 };
       
   110 
       
   111 
       
   112 /**
       
   113  * Returns the parent control of the command container
       
   114  */
       
   115 inline const MSwtControl* CSwtCommandContainer::Control() const
       
   116 {
       
   117     return iControl;
       
   118 }
       
   119 
       
   120 /**
       
   121  * Returns the list of commands of the command container
       
   122  */
       
   123 inline RPointerArray<MSwtCommand>& CSwtCommandContainer::Commands()
       
   124 {
       
   125     return iCommands;
       
   126 }
       
   127 
       
   128 /**
       
   129  * Returns the default command of the command container
       
   130  */
       
   131 inline const MSwtCommand* CSwtCommandContainer::DefaultCommand() const
       
   132 {
       
   133     return iDefaultCommand;
       
   134 }
       
   135 
       
   136 
       
   137 #endif // SWTCOMMANDCONTAINER_H