1 /* |
|
2 * Copyright (c) 2003-2005 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: Declares LIW Menu utilities for providers to access consumer menu. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 #ifndef LIW_MENU_H |
|
25 #define LIW_MENU_H |
|
26 |
|
27 // INCLUDES |
|
28 #include <eikmenup.h> |
|
29 #include <liwserviceifbase.h> |
|
30 |
|
31 // CONSTANTS |
|
32 |
|
33 // MACROS |
|
34 |
|
35 // DATA TYPES |
|
36 |
|
37 // FUNCTION PROTOTYPES |
|
38 |
|
39 // FORWARD DECLARATIONS |
|
40 |
|
41 // CLASS DECLARATION |
|
42 |
|
43 /** |
|
44 * CLiwMenuPane for providers to have limited access to consumer menu. |
|
45 * |
|
46 * LIW provider can get a reference to CLiwMenuPane in its InitializeMenuPaneL() |
|
47 * method, which is derived from CLiwServiceIfMenu. With this reference, |
|
48 * the provider can e.g. insert menu items to the consumer application's menu. |
|
49 * |
|
50 * @lib ServiceHandler.lib |
|
51 * @since Series 60 2.6 |
|
52 */ |
|
53 class CLiwMenuPane: public CBase |
|
54 { |
|
55 public: |
|
56 /** |
|
57 * Constructor. |
|
58 * |
|
59 * @param aMenuPane Consumer's menu pane handle. |
|
60 * @param aBaseCmdId Base command ID for new menu items, specified by consumer. |
|
61 */ |
|
62 IMPORT_C CLiwMenuPane(CEikMenuPane& aMenuPane, TInt aBaseCmdId); |
|
63 |
|
64 /** |
|
65 * Destructor. |
|
66 */ |
|
67 IMPORT_C virtual ~CLiwMenuPane(); |
|
68 |
|
69 public: |
|
70 /** |
|
71 * Adds a menu item to consumer menu. For each addition a mapping element |
|
72 * is created. This method should normally be called from provider's |
|
73 * InitializeMenuPaneL(). |
|
74 * |
|
75 * @param aServiceCmd The LIW service command the provider implements. |
|
76 * @param aMenuItem The menu item data. |
|
77 * @param aIndex Position of item where to add menu items. |
|
78 */ |
|
79 IMPORT_C void AddMenuItemL( |
|
80 TInt aServiceCmd, |
|
81 CEikMenuPaneItem::SData& aMenuItem, |
|
82 TInt aIndex); |
|
83 |
|
84 /** |
|
85 * Adds a menu item to consumer menu. For each addition a mapping element |
|
86 * is created. This method should normally be called from provider's |
|
87 * InitializeMenuPaneL(). |
|
88 * |
|
89 * @param aServiceCmd The LIW service command the provider implements. |
|
90 * @param aMenuItem The menu item data. |
|
91 * @param aIndex Position of item where to add menu items. |
|
92 * @param aExtraText Altenative menu item text, if it is placed to a submenu. |
|
93 */ |
|
94 IMPORT_C void AddMenuItemL( |
|
95 TInt aServiceCmd, |
|
96 CEikMenuPaneItem::SData& aMenuItem, |
|
97 TInt aIndex, |
|
98 const TDesC& aExtraText); |
|
99 |
|
100 /** |
|
101 * Adds a menu item(s) to consumer menu from provider resource. This method |
|
102 * should normally be called from provider's InitializeMenuPaneL(). |
|
103 * |
|
104 * @param aReader Resource reader pointing to the menu resource. |
|
105 * @param aServiceCmd The LIW service command the provider implements. |
|
106 * @param aIndex Position of item where to add menu items. |
|
107 * @param aAddSeparator Currently not in use. |
|
108 */ |
|
109 IMPORT_C void AddMenuItemsL( |
|
110 TResourceReader& aReader, |
|
111 TInt aServiceCmd, |
|
112 TInt aIndex, |
|
113 TBool aAddSeperator = EFalse); |
|
114 |
|
115 /** |
|
116 * Adds a menu item(s) to consumer menu from provider resource. This method |
|
117 * should normally be called from provider's InitializeMenuPaneL(). |
|
118 * |
|
119 * @param aFileName The provider's resource where menu item(s) are defined. |
|
120 * @param aResId Resource id of a MENU_PANE. |
|
121 * @param aServiceCmd The LIW service command the provider implements. |
|
122 * @param aIndex Position of item where to add menu items. |
|
123 * @param aAddSeperator Currently not in use. |
|
124 */ |
|
125 IMPORT_C void AddMenuItemsL( |
|
126 TFileName& aFileName, |
|
127 TInt aResId, |
|
128 TInt aServiceCmd, |
|
129 TInt aIndex, |
|
130 TBool aAddSeperator = EFalse); |
|
131 |
|
132 public: |
|
133 /** |
|
134 * Gets the provider's original menu command ID from the dynamic menu command |
|
135 * ID (generated by the LIW framework). |
|
136 * |
|
137 * @param aDynCmdId Dynamic menu command ID. |
|
138 * @return Found provider's original menu command ID, KErrNotFound if not found. |
|
139 */ |
|
140 IMPORT_C TInt MenuCmdId(TInt aDynCmdId) const; |
|
141 |
|
142 /** |
|
143 * Gets the dynamic menu command ID (generated by the LIW framework) from the |
|
144 * provider's original menu command ID. There are usually multiple matching |
|
145 * dynamic menu command IDs, so this method returns the first item found. |
|
146 * |
|
147 * @param aMenuCmdId Provider's original menu command ID. |
|
148 * @return Found dynamic menu command ID, KErrNotFound if not found. |
|
149 */ |
|
150 IMPORT_C TInt DynCmdId(TInt aMenuCmdId) const; |
|
151 |
|
152 /** |
|
153 * Gets the LIW service command ID from the dynamic menu command ID (generated |
|
154 * by the LIW framework). |
|
155 * |
|
156 * @param aDynCmdId Dynamic menu command ID. |
|
157 * @return Found LIW service command ID, KErrNotFound if not found. |
|
158 */ |
|
159 IMPORT_C TInt ServiceCmdId(TInt aDynCmdId) const; |
|
160 |
|
161 /** |
|
162 * Add sub menu title item. This item will not be visible in menus, |
|
163 * but will be used as title for comsumer's LIW submenu (if consumer |
|
164 * requests that). |
|
165 * |
|
166 * @param aTitle Title text |
|
167 * @param aIndex Position of title item in menu (can be anything, but |
|
168 * if there is several title item definitions in menu, |
|
169 * then the last one will be used). |
|
170 * @since 2.8 |
|
171 */ |
|
172 IMPORT_C void AddTitleItemL(const TDesC& aTitle, TInt aIndex); |
|
173 |
|
174 friend class CLiwServiceHandlerImpl; |
|
175 |
|
176 private: |
|
177 struct SMenuIdMap |
|
178 { |
|
179 TInt serviceCmdId; // LIW service command ID. |
|
180 TInt origCmdId; // Original menu ID used by provider SW |
|
181 TInt dynMenuCmdId; // The dynamic command ID generated by LIWFW |
|
182 CLiwServiceIfBase* owner; // A pointer to the provider object. |
|
183 RBuf extraText; // Alternative submenu text is stored here. |
|
184 }; |
|
185 |
|
186 private: |
|
187 TInt FindCmdId(TInt aIndex); |
|
188 inline CEikMenuPane& MenuPane(); |
|
189 inline void SetResourceSlotId(TInt aSlot); |
|
190 inline TInt ResourceSlotId() const; |
|
191 inline void SetPaneOffset(TInt aOffset); |
|
192 inline TInt PaneOffset() const; |
|
193 inline TInt MenuResourceId() const; |
|
194 inline void SetMenuResourceId(TInt aMenuResourceId); |
|
195 TBool IsCmdInRange(TInt aCmdSpaceSize, TInt aCmd); |
|
196 CLiwServiceIfBase* CommandOwner(TInt aDynId) const; |
|
197 inline CLiwServiceIfBase* InitializingOwner() const; |
|
198 inline void SetInitializingOwner(CLiwServiceIfBase* aOwner); |
|
199 const TDesC& ExtraText(TInt aDynMenuCmdId); |
|
200 |
|
201 private: |
|
202 // Original menu pane. |
|
203 CEikMenuPane* iMenuPane; |
|
204 |
|
205 // Base ID to generate menu IDs for placeholders. From constructor. |
|
206 TInt iBaseCmdId; |
|
207 |
|
208 // Map needed to map provider cmd IDs to dynamic command Ids |
|
209 RArray<SMenuIdMap> iIdMap; |
|
210 |
|
211 TInt iNextCmdId; // The next free command ID to use |
|
212 TInt iResourceSlotId; |
|
213 TInt iPaneOffset; |
|
214 TInt iMenuResourceId; |
|
215 CLiwServiceIfBase* iInitializingOwner; // Owner that is currently initializing. |
|
216 |
|
217 TInt iReserved_1; |
|
218 void *iExtension; // reserved for future use |
|
219 }; |
|
220 |
|
221 |
|
222 inline CEikMenuPane& CLiwMenuPane::MenuPane() |
|
223 { |
|
224 return *iMenuPane; |
|
225 } |
|
226 |
|
227 |
|
228 inline void CLiwMenuPane::SetResourceSlotId(TInt aSlot) |
|
229 { |
|
230 iResourceSlotId = aSlot; |
|
231 } |
|
232 |
|
233 |
|
234 inline TInt CLiwMenuPane::ResourceSlotId() const |
|
235 { |
|
236 return iResourceSlotId; |
|
237 } |
|
238 |
|
239 |
|
240 inline void CLiwMenuPane::SetPaneOffset(TInt aOffset) |
|
241 { |
|
242 iPaneOffset = aOffset; |
|
243 } |
|
244 |
|
245 |
|
246 inline TInt CLiwMenuPane::PaneOffset() const |
|
247 { |
|
248 return iPaneOffset; |
|
249 } |
|
250 |
|
251 |
|
252 inline CLiwServiceIfBase* CLiwMenuPane::InitializingOwner() const |
|
253 { |
|
254 return iInitializingOwner; |
|
255 } |
|
256 |
|
257 |
|
258 inline void CLiwMenuPane::SetInitializingOwner(CLiwServiceIfBase* aOwner) |
|
259 { |
|
260 iInitializingOwner = aOwner; |
|
261 } |
|
262 |
|
263 |
|
264 inline TInt CLiwMenuPane::MenuResourceId() const |
|
265 { |
|
266 return iMenuResourceId; |
|
267 } |
|
268 |
|
269 |
|
270 inline void CLiwMenuPane::SetMenuResourceId(TInt aMenuResourceId) |
|
271 { |
|
272 iMenuResourceId = aMenuResourceId; |
|
273 } |
|
274 |
|
275 #endif // LIW_MENU_H |
|
276 |
|
277 // END of File |
|