webengine/widgetengine/inc/MenuItem.h
changeset 0 dd21522fd290
child 13 10e98eab6f85
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2004 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 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __MENUITEM_H
       
    21 #define __MENUITEM_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include "config.h"
       
    25 #include <e32base.h>
       
    26 #include <kjs/object.h>
       
    27 
       
    28 // CONSTANTS
       
    29 
       
    30 // MACROS
       
    31 
       
    32 // DATA TYPES
       
    33 
       
    34 // FUNCTION PROTOTYPES
       
    35 
       
    36 // CLASS DECLARATION
       
    37 class MJSMenuItemCallbacks;
       
    38 
       
    39 /**
       
    40 *  CMenuItem
       
    41 *
       
    42 *  @lib widgetengine.dll
       
    43 *  @since 3.1
       
    44 */
       
    45 namespace KJS {
       
    46 
       
    47 class WidgetEventHandler;
       
    48 
       
    49 class JSMenuItemConstructor : public JSObject 
       
    50 {
       
    51 
       
    52 public:
       
    53     JSMenuItemConstructor(MJSMenuItemCallbacks* callbacks);
       
    54     virtual bool implementsConstruct() const;    
       
    55     virtual JSObject* construct( ExecState *exec, const List &args );
       
    56 
       
    57 private:
       
    58     MJSMenuItemCallbacks*  m_callbacks;
       
    59     int m_internalId;
       
    60 
       
    61 };
       
    62 
       
    63 
       
    64 struct MenuItemPrivate
       
    65 {
       
    66     MenuItemPrivate(MJSMenuItemCallbacks* callbacks,
       
    67                     int cmdId, int internalId,
       
    68                     WidgetEventHandler* selectCallback = NULL) : m_callbacks(callbacks),
       
    69                     m_cmdId(cmdId),
       
    70                     m_internalId(internalId),
       
    71                     m_dimmed(false),
       
    72                     m_show(false),
       
    73                     m_onSelectCallback(selectCallback)
       
    74     {        
       
    75     }
       
    76 
       
    77     
       
    78     virtual ~MenuItemPrivate() { delete m_onSelectCallback; }
       
    79     
       
    80     MJSMenuItemCallbacks*   m_callbacks;
       
    81     const int               m_cmdId;
       
    82     bool                    m_dimmed;
       
    83     bool                    m_show;
       
    84     WidgetEventHandler*     m_onSelectCallback;
       
    85     const int               m_internalId;    
       
    86 
       
    87 };
       
    88 
       
    89 
       
    90 class JSMenuItem : public JSObject
       
    91 {
       
    92 public:
       
    93     JSMenuItem(ExecState* exec, MJSMenuItemCallbacks* callbacks,
       
    94                 TDesC& text, int cmdId, int internalId,
       
    95                 WidgetEventHandler* selectCallback = NULL );
       
    96 
       
    97     virtual ~JSMenuItem();    
       
    98     
       
    99 //From JSObject
       
   100 public:
       
   101     JSValue* getValueProperty(ExecState*, int token) const;
       
   102     bool getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot);
       
   103   
       
   104     bool canPut(ExecState *exec, const Identifier &propertyName) const;
       
   105     void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
       
   106 
       
   107     const ClassInfo* classInfo() const { return &info; }
       
   108     static const ClassInfo info;
       
   109 
       
   110     enum {
       
   111         Append,
       
   112         Remove,
       
   113         SetDim,
       
   114         OnSelect,
       
   115         ToString
       
   116         };
       
   117 
       
   118     virtual UString toString(ExecState *exec) const;
       
   119 
       
   120 public:    
       
   121     int Id() const;
       
   122     int InternalId() const;
       
   123     bool Show() const;
       
   124     bool Dimmed() const;
       
   125     void SetShow(bool val);
       
   126     void SetDimmed(bool val);
       
   127     WidgetEventHandler* callback() const;
       
   128     
       
   129     void AddOptionsMenuItem(bool show);
       
   130     void DeleteMenuItem();        
       
   131 
       
   132 
       
   133 private:
       
   134     MenuItemPrivate *d;
       
   135 
       
   136 };
       
   137 
       
   138 };
       
   139 
       
   140 #include "MenuItem.lut.h"
       
   141 
       
   142 
       
   143 #endif