webengine/widgetengine/inc/Menu.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 __MENU_H
       
    21 #define __MENU_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 MJSMenuCallbacks;
       
    38 
       
    39 /**
       
    40 *  CMenu
       
    41 *
       
    42 *  @lib widgetengine.dll
       
    43 *  @since 3.1
       
    44 */
       
    45 namespace KJS {
       
    46 
       
    47 class WidgetEventHandler;
       
    48 
       
    49 struct MenuPrivate
       
    50 {
       
    51     MenuPrivate(MJSMenuCallbacks* callbacks,
       
    52                 WidgetEventHandler* onShowCallback = NULL,
       
    53                 WidgetEventHandler* rightKeyCallback = NULL,
       
    54                 WidgetEventHandler* leftKeyCallback = NULL) : 
       
    55                     m_callbacks(callbacks),
       
    56                     m_onShowCallback(onShowCallback),
       
    57                     m_rightKeyCallback(rightKeyCallback),
       
    58                     m_leftKeyCallback(leftKeyCallback)
       
    59     {        
       
    60     }
       
    61 
       
    62     
       
    63     virtual ~MenuPrivate() { delete m_onShowCallback;
       
    64                              delete m_rightKeyCallback;
       
    65                              delete m_leftKeyCallback;}
       
    66     
       
    67     MJSMenuCallbacks* m_callbacks;
       
    68     WidgetEventHandler* m_onShowCallback;
       
    69     WidgetEventHandler* m_rightKeyCallback;        
       
    70     WidgetEventHandler* m_leftKeyCallback;
       
    71 };
       
    72 
       
    73 class JSMenu: public JSObject
       
    74     {
       
    75 
       
    76     public:
       
    77         JSMenu(MJSMenuCallbacks* aMenuCallbacks);
       
    78         virtual ~JSMenu();
       
    79 
       
    80     //From JSObject
       
    81     public:        
       
    82         JSType type() const;
       
    83 
       
    84         JSValue* getValueProperty(KJS::ExecState*, int token) const;
       
    85         bool getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot);
       
    86       
       
    87         bool canPut(ExecState *exec, const Identifier &propertyName) const;
       
    88         void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
       
    89 
       
    90         const ClassInfo* classInfo() const { return &info; }
       
    91         static const ClassInfo info;
       
    92 
       
    93         enum {
       
    94             Append,
       
    95             Remove,
       
    96             GetMenuItemById,
       
    97             GetMenuItemByName,
       
    98             SetRightSoftKeyLabel,
       
    99             OnShow,
       
   100             Clear,
       
   101             ToString,
       
   102             HideSoftkeys,
       
   103             ShowSoftkeys,
       
   104             Location,
       
   105             SetLeftSoftKeyLabel
       
   106             };
       
   107 
       
   108 
       
   109     public:
       
   110         virtual UString toString(ExecState *exec) const;
       
   111         void setRightKeyCallback( ExecState *exec, JSValue *value );
       
   112         WidgetEventHandler* rightKeyCallback() { return d->m_rightKeyCallback; };
       
   113         WidgetEventHandler* onShowCallback() { return d->m_onShowCallback; };    
       
   114         
       
   115         void setLeftKeyCallback( ExecState *exec, JSValue *value );
       
   116         WidgetEventHandler* leftKeyCallback() { return d->m_leftKeyCallback; };
       
   117 
       
   118     private:
       
   119         MenuPrivate* d;
       
   120     };
       
   121 
       
   122 };
       
   123 
       
   124 #include "Menu.lut.h"
       
   125 
       
   126 
       
   127 #endif