mpx/tsrc/public/basic/common/testviewframework/inc/testbaseview.h
changeset 62 b276843a15ba
equal deleted inserted replaced
58:c76ea6caa649 62:b276843a15ba
       
     1 /*
       
     2 * Copyright (c) 2002 - 2007 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 "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:  A console for menu selection
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef TESTBASEVIEW_H
       
    19 #define TESTBASEVIEW_H
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <aknlists.h>
       
    23 #include <badesca.h>
       
    24 #include <e32cons.h>
       
    25 
       
    26 // FORWARD DECLARATION
       
    27 template <class T> class RRefArray;
       
    28 class CConsoleMain;
       
    29 
       
    30 // CLASS DECLARATION
       
    31 
       
    32 /**
       
    33 *  Abstract View class - contains functions which must be derived
       
    34 *
       
    35 *  @lib TestViewFramework.lib
       
    36 */
       
    37 class MTestBaseView
       
    38     {
       
    39     public:
       
    40     
       
    41         /**
       
    42         * Initialize the view before display view
       
    43         * NOTE: Must be derived
       
    44         */
       
    45         virtual void InitializeViewL() = 0;
       
    46         
       
    47         /**
       
    48         * Cleanup the child view before deactivate/destroy view
       
    49         * NOTE: Must be derived
       
    50         */
       
    51         virtual void CleanupViewL() = 0;
       
    52         
       
    53         /**
       
    54         * Display this view 
       
    55         * NOTE: Must be derived
       
    56         */
       
    57         virtual void DisplayViewL() = 0;
       
    58         
       
    59         /** 
       
    60         * Process keypresses on this view - called by ConsoleMain
       
    61         * @param aSelection, key pressed
       
    62         * @param aContinue, whether to continue or stop scheduler
       
    63         * NOTE: Must be derived
       
    64         */
       
    65         virtual void SelectL( TKeyCode aSelection, TBool& aContinue ) = 0;
       
    66         
       
    67         /** 
       
    68         * Update display from timer - called by ConsoleMain
       
    69         * NOTE: Must be derived
       
    70         */
       
    71         virtual void TimerUpdate() = 0;
       
    72         
       
    73     };
       
    74 
       
    75 
       
    76 /**
       
    77 *  View class - Console base
       
    78 *
       
    79 *  @lib TestViewFramework.lib
       
    80 */
       
    81 class CTestBaseView :public CBase, public MTestBaseView
       
    82     {
       
    83     public:
       
    84         /**
       
    85         * Destructor
       
    86         */
       
    87         IMPORT_C virtual ~CTestBaseView();
       
    88 
       
    89         /** 
       
    90         * Return menu name
       
    91         * @return descriptor of current menu's name
       
    92         */
       
    93         IMPORT_C const TDesC& Name() const;
       
    94 
       
    95         /** 
       
    96         * Set the menu name
       
    97         * @param aName, menu name to be set
       
    98         */
       
    99         IMPORT_C void SetName( const TDesC& aName );
       
   100 
       
   101         /** 
       
   102         * Set parent menu
       
   103         * @param aMenu, parent menu of current menu
       
   104         */
       
   105         IMPORT_C void SetParent( CTestBaseView* aView );
       
   106         
       
   107         /**
       
   108         * Get the parent view
       
   109         * @return reference of parent view
       
   110         */
       
   111         IMPORT_C CTestBaseView* Parent();
       
   112         
       
   113         
       
   114     protected:
       
   115         /**
       
   116         * Make sure DisplayViewBase() is call in the beginning
       
   117         * of DisplayViewL() call
       
   118         */
       
   119         void DisplayViewBase()
       
   120             { if(iChild) { CleanupViewL(); delete iChild; iChild = NULL; }};
       
   121         
       
   122         /**
       
   123         * C++ default constructor
       
   124         */
       
   125         IMPORT_C CTestBaseView(CConsoleMain* aConsoleMain,
       
   126                                CTestBaseView* aParent,
       
   127                                const TDesC& aName);
       
   128 
       
   129         /**
       
   130         * Signal CConsoleMain that a new child view is created
       
   131         */
       
   132         IMPORT_C void NextViewL(CTestBaseView* aChild);
       
   133         
       
   134         /**
       
   135         * Signal CConsoleMain that current view is done, go back parent
       
   136         */
       
   137         IMPORT_C void CurrentViewDoneL();
       
   138 
       
   139     protected:  // Data
       
   140         CConsoleBase*           iConsole;      // Pointer to console
       
   141         CConsoleMain*           iConsoleMain;  // Pointer to console main
       
   142         CTestBaseView*          iParent;       // Pointer to parent view
       
   143         CTestBaseView*          iChild;         //Pointer to child view
       
   144         TName                   iName;         // View name
       
   145 
       
   146     };
       
   147 
       
   148 #endif  //TESTVIEW_H