|
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 __MENUCLIENT |
|
19 #define __MENUCLIENT |
|
20 |
|
21 // INCLUDES |
|
22 #include <eikenv.h> |
|
23 #include <avkon.hrh> |
|
24 #include <widgetmenu.rsg> |
|
25 |
|
26 #include "BrCtlInterface.h" |
|
27 #include "MenuCallbacks.h" |
|
28 #include "MenuItemCallbacks.h" |
|
29 #include "WidgetEngineCallbacks.h" |
|
30 |
|
31 // CONSTANTS |
|
32 |
|
33 // MACROS |
|
34 |
|
35 // DATA TYPES |
|
36 enum TMenuItemState |
|
37 { |
|
38 EReal=0, //in real tree |
|
39 EVirtual, //in virtual tree |
|
40 ERealOrVirtual //either real or virtual |
|
41 }; |
|
42 |
|
43 // FUNCTION PROTOTYPES |
|
44 |
|
45 // FORWARD DECLARATION |
|
46 |
|
47 // CLASS DECLARATION |
|
48 class CMenuItem; |
|
49 |
|
50 namespace KJS { |
|
51 class JSMenu; |
|
52 class JSMenuItemConstructor; |
|
53 } |
|
54 |
|
55 |
|
56 /** |
|
57 * CWidgetExtension |
|
58 * |
|
59 * @lib browserengine.dll |
|
60 * @since 3.2 |
|
61 */ |
|
62 class CMenuClient : public CBase, public MJSMenuCallbacks, public MJSMenuItemCallbacks |
|
63 { |
|
64 |
|
65 public: |
|
66 static CMenuClient* NewL(MWidgetCallback& aWidgetCallback, MWidgetEngineCallbacks& aWidgetEngineCallback); |
|
67 virtual ~CMenuClient(); |
|
68 |
|
69 public: |
|
70 KJS::JSMenu* jsmenu(); |
|
71 KJS::JSMenuItemConstructor* jsmenuitem(); |
|
72 |
|
73 void addOptionMenuItemsL( CEikMenuPane& aMenuPane,TInt aResourceId ); |
|
74 void menuShowed(); |
|
75 void menuItemSelected( TInt aInternalId ); |
|
76 |
|
77 |
|
78 public: // From MWidgetExtension |
|
79 TBool HandleCommandL( TInt aCommandId ); |
|
80 |
|
81 public: //From MJSMenuCallbacks |
|
82 void* getFromMenuItemCollection( TInt aCmdId ); |
|
83 void* getFromMenuItemCollection( const TDesC& aTextVal ); |
|
84 void hideSoftkeys(); |
|
85 void showSoftkeys(); |
|
86 void setRightSoftKeyLabel( const TDesC& aText ); |
|
87 void setLeftSoftKeyLabel( const TDesC& aText ); |
|
88 void clearMenuItems(); |
|
89 |
|
90 public://From MJSMenuItemCallbacks |
|
91 TInt createOptionsMenuItem( const TDesC& aText, TInt aCmdId, TInt aInternalId, void* aObj ); |
|
92 TInt addOptionsMenuItem( TInt aInternalId, TInt aParentInternalId, TBool aShow=ETrue ); |
|
93 void deleteMenuItem( TInt aInternalId ); |
|
94 void setDimmed( TInt aInternalId, TBool aValue ); |
|
95 KJS::WidgetEventHandler* menuItemObserver( TInt aInternalId, TInt& aCmdId ); |
|
96 void setMenuItemObserver( TInt aInternalId, KJS::WidgetEventHandler* aOnSelectCallback ); |
|
97 |
|
98 private: |
|
99 void deleteTree( CMenuItem* aNode ); |
|
100 void insertTree( CMenuItem* aParent, CMenuItem* aItem ); |
|
101 void rearrangeTree( CMenuItem* aParent, CMenuItem* aItem, TBool aShow ); |
|
102 void showTree( CMenuItem* aNode, TBool aShow ); |
|
103 void deleteItem( CMenuItem* aItem ); |
|
104 void deleteSibling( CMenuItem* aRoot, CMenuItem* aItem ); |
|
105 |
|
106 private: |
|
107 void addMenuItem( CEikMenuPane& aMenuPane, CMenuItem* aNode , TInt aIsRootMenuPane = EFalse); |
|
108 TInt append( CMenuItem* root, CMenuItem* item ); |
|
109 void appendSibling( CMenuItem* root, CMenuItem* item ); |
|
110 CMenuItem* findNodeById( CMenuItem* node, TInt aInternalId, TMenuItemState aState ); |
|
111 TBool isDuplicate( CMenuItem* node ); |
|
112 CMenuItem* findNodeByCmdId( CMenuItem* node, TInt aCmdId ); |
|
113 CMenuItem* findNodeByText( CMenuItem* node, const TDesC& aText ); |
|
114 |
|
115 private: |
|
116 CMenuClient(MWidgetCallback& aWidgetCallback, MWidgetEngineCallbacks& aWidgetEngineCallback); |
|
117 void ConstructL(); |
|
118 |
|
119 private: |
|
120 |
|
121 struct TCascadeIDMap |
|
122 { |
|
123 TInt iResourceId; |
|
124 TInt parentInternalId; |
|
125 }; |
|
126 |
|
127 RArray<TCascadeIDMap> iCascadeArr; |
|
128 TInt iResourceId; |
|
129 CMenuItem* iMenuRoot; |
|
130 |
|
131 private: |
|
132 MWidgetCallback* iWidgetCallback; |
|
133 MWidgetEngineCallbacks* m_widgetenginecallback; |
|
134 |
|
135 KJS::JSMenu* m_jsmenu; |
|
136 KJS::JSMenuItemConstructor* m_jsmenuitemctr; |
|
137 |
|
138 }; |
|
139 |
|
140 |
|
141 #endif |