webengine/widgetengine/inc/MenuItemClient.h
changeset 0 dd21522fd290
child 36 0ed94ceaa377
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2006 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:  This class represents the Widget Extension object
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __MENUITEMCLIENT_
       
    19 #define __MENUITEMCLIENT_
       
    20 
       
    21 //  INCLUDES
       
    22 #include <e32base.h>
       
    23 #include "BrCtlInterface.h"
       
    24 
       
    25 // CONSTANTS
       
    26 
       
    27 // MACROS
       
    28 
       
    29 // DATA TYPES
       
    30 
       
    31 // FUNCTION PROTOTYPES
       
    32 
       
    33 // CLASS DECLARATION
       
    34 namespace KJS {
       
    35     class WidgetEventHandler;
       
    36 }
       
    37 
       
    38 class CMenuItem : public CBase
       
    39 {
       
    40 public:
       
    41         /**
       
    42         * Constructor
       
    43         */
       
    44         static CMenuItem* NewL( const TDesC16& aText, TInt aCmdId, 
       
    45             TInt aInternalId, TBool aDimmed = EFalse, CMenuItem* aParent=NULL, 
       
    46             void* aObj = NULL, TBool aShow = EFalse );
       
    47 
       
    48         /**
       
    49         * Destructor.
       
    50         */
       
    51         virtual ~CMenuItem();
       
    52 
       
    53 protected:
       
    54         /**
       
    55         * 2nd phase constructor.
       
    56         */
       
    57         void ConstructL();
       
    58 
       
    59         /**
       
    60         * C++ constructor.
       
    61         */
       
    62         CMenuItem( const TDesC16& aText, TInt aCmdId, TInt aInternalId, 
       
    63             TBool aDimmed, CMenuItem* aParent = NULL, void* aObj = NULL, 
       
    64             TBool aShow = EFalse );
       
    65 public:
       
    66 
       
    67         /*
       
    68         * Method text()
       
    69         * @since 3.2
       
    70         * @param none
       
    71         * @return text of menu item
       
    72         */
       
    73         const TDesC& text()
       
    74             {
       
    75             if ( iText ) 
       
    76                 return *iText;
       
    77             else 
       
    78                 return KNullDesC();
       
    79             }
       
    80 
       
    81         /*
       
    82         * Method cmdId()
       
    83         * @since 3.2
       
    84         * @param none
       
    85         * @return command id of menu item
       
    86         */
       
    87         TInt cmdId() { return iCmdId; }
       
    88 
       
    89         /*
       
    90         * Method internalId()
       
    91         * @since 3.2
       
    92         * @param none
       
    93         * @return internal id of menu item
       
    94         */
       
    95         TInt internalId() { return iInternalId; }
       
    96 
       
    97         /*
       
    98         * Method firstChild()
       
    99         * @since 3.2
       
   100         * @param none
       
   101         * @return first child of menu item
       
   102         */
       
   103         CMenuItem* firstChild() { return iFirstChild; }
       
   104 
       
   105         /*
       
   106         * Method nextSibling()
       
   107         * @since 3.2
       
   108         * @param none
       
   109         * @return next sibling of menu item
       
   110         */
       
   111         CMenuItem* nextSibling() { return iNextSibling; }
       
   112 
       
   113         /*
       
   114         * Method dimmed()
       
   115         * @since 3.2
       
   116         * @param none
       
   117         * @return dimmed status of menu item
       
   118         */
       
   119         TBool dimmed() { return iDimmed; }
       
   120 
       
   121         /*
       
   122         * Method show()
       
   123         * @since 3.2
       
   124         * @param none
       
   125         * @return Show status of menu item
       
   126         */
       
   127         TBool show() { return iShow; }
       
   128 
       
   129         /*
       
   130         * Method Callback()
       
   131         * @since 3.2
       
   132         * @param none
       
   133         * @return onselect callback function of menu item
       
   134         */
       
   135         KJS::WidgetEventHandler* callback() { return iCallback; }
       
   136 
       
   137         /*
       
   138         * Method obj()
       
   139         * @since 3.2
       
   140         * @param none
       
   141         * @return menu item javascript object
       
   142         */
       
   143         void* obj() { return iObj; }
       
   144 
       
   145         /*
       
   146         * Method parent()
       
   147         * @since 3.2
       
   148         * @param none
       
   149         * @return parent menu item
       
   150         */
       
   151         CMenuItem* parent() { return iParent; }
       
   152 
       
   153         /*
       
   154         * Method setText()
       
   155         * @since 3.2
       
   156         * @param text of menu item
       
   157         * @return none
       
   158         */
       
   159         void setText( const TDesC& aText )
       
   160             {
       
   161             HBufC* tmpText = HBufC::NewL( aText.Length() );
       
   162             tmpText->Des().Append( aText );
       
   163             delete iText;
       
   164             iText = tmpText;
       
   165             }
       
   166 
       
   167         /*
       
   168         * Method setCmdId()
       
   169         * @since 3.2
       
   170         * @param command id of menu item
       
   171         * @return none
       
   172         */
       
   173         void setCmdId( TInt aCmdId ) { iCmdId = aCmdId; }
       
   174 
       
   175         /*
       
   176         * Method setFirstChild()
       
   177         * @since 3.2
       
   178         * @param first child of menu item
       
   179         * @return none
       
   180         */
       
   181         void setFirstChild( CMenuItem* aFirstChild ) { iFirstChild = aFirstChild; }
       
   182 
       
   183         /*
       
   184         * Method setNextSibling()
       
   185         * @since 3.2
       
   186         * @param next sibling of menu item
       
   187         * @return none
       
   188         */
       
   189         void setNextSibling( CMenuItem* aNextSibling ) { iNextSibling = aNextSibling; }
       
   190 
       
   191         /*
       
   192         * Method setDimmed()
       
   193         * @since 3.2
       
   194         * @param dimmed status
       
   195         * @return none
       
   196         */
       
   197         void setDimmed( TBool aDimmed ) { iDimmed = aDimmed; }
       
   198 
       
   199         /*
       
   200         * Method setShow()
       
   201         * @since 3.2
       
   202         * @param show status
       
   203         * @return none
       
   204         */
       
   205         void setShow( TBool aShow ) { iShow = aShow; }
       
   206 
       
   207         /*
       
   208         * Method setCallback()
       
   209         * @since 3.2
       
   210         * @param callback function
       
   211         * @return none
       
   212         */
       
   213         void setCallback( KJS::WidgetEventHandler* aCallback ) { iCallback = aCallback; }
       
   214 
       
   215         /*
       
   216         * Method setObj()
       
   217         * @since 3.2
       
   218         * @param menu item javascript object
       
   219         * @return none
       
   220         */
       
   221         void setObj( void* aObj ) { iObj = aObj; }
       
   222 
       
   223 private:
       
   224         HBufC*                  iText;//data
       
   225         TInt                    iCmdId;//data
       
   226         TInt                    iInternalId;//data
       
   227         CMenuItem*              iParent;//data
       
   228         CMenuItem*              iFirstChild;//left node
       
   229         CMenuItem*              iNextSibling;//right node
       
   230         TBool                   iDimmed;//ETrue to dim this menu item. EFalse to un-dim this menu item.
       
   231         KJS::WidgetEventHandler*     iCallback;
       
   232         void*                   iObj;
       
   233         TBool                   iShow;
       
   234 };
       
   235 
       
   236 #endif