|
1 /* |
|
2 * Copyright (c) 2002-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 "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 _XNMENUADAPTER_H |
|
21 #define _XNMENUADAPTER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include "xncontroladapter.h" |
|
25 #include <eikmobs.h> |
|
26 #include <eikmenup.h> |
|
27 #include "xnmenu.h" |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class TXnUiEnginePluginIf; |
|
31 class CXnNodePluginIf; |
|
32 |
|
33 // CONSTANTS |
|
34 |
|
35 _LIT8(KXnMenuBar, "menubar"); |
|
36 _LIT8(KXnMenuItem, "menuitem"); |
|
37 _LIT8(KXnDynMenuItem, "dynmenuitem"); |
|
38 _LIT8(KXnWidgetMenuItem, "widgetmenuitem"); |
|
39 _LIT8(KXnWidgetSoftkey, "widgetsoftkey"); |
|
40 _LIT8(KXnMenu, "menu"); |
|
41 _LIT8(KXnLabel, "label"); |
|
42 _LIT8(KXnImage, "image"); |
|
43 _LIT8(KXnImagePath, "path"); |
|
44 _LIT8(KXnMenuExtension, "menuextension"); |
|
45 _LIT8(KXnMenuItemSettings, "hs_widget_menuitem_settings"); |
|
46 _LIT8(KXnSource, "source"); |
|
47 _LIT8(KXnTarget, "target"); |
|
48 |
|
49 // CLASS DECLARATION |
|
50 class TXnMenuItem |
|
51 { |
|
52 public : |
|
53 CXnNodePluginIf* iNode; |
|
54 TBool iAutomaticSP; |
|
55 TInt iParentIndex; |
|
56 CEikMenuPaneItem::SData iData; |
|
57 TBool iIsCascade; |
|
58 }; |
|
59 |
|
60 // CLASS DECLARATION |
|
61 |
|
62 class CXnSoftkeyItem; |
|
63 /** |
|
64 * @ingroup group_xnmenufactory |
|
65 * @lib xn3menufactory.dll |
|
66 * @since S60 3.1 |
|
67 */ |
|
68 class CXnMenuAdapter : public CXnControlAdapter, public MEikMenuObserver |
|
69 { |
|
70 public: // Constructors and destructor |
|
71 |
|
72 /** |
|
73 * Two-phased constructor. |
|
74 */ |
|
75 static CXnMenuAdapter* NewL( CXnControlAdapter* aParent, CXnNodePluginIf& aNode ); |
|
76 |
|
77 /** |
|
78 * Destructor. |
|
79 */ |
|
80 virtual ~CXnMenuAdapter(); |
|
81 |
|
82 public: // new functions |
|
83 virtual void SetContainerL(CEikButtonGroupContainer& aContainer); |
|
84 virtual TBool IsMenuFocused(); |
|
85 |
|
86 /** |
|
87 * Closes the menu, if it is open. |
|
88 * @since Series 60 3.2 |
|
89 */ |
|
90 virtual void StopDisplayingMenu(); |
|
91 |
|
92 /** |
|
93 * Sets soft key image. If there was no leave, menu takes |
|
94 * bitmap and mask ownership. |
|
95 * @since Series 60 3.2 |
|
96 * @param aBitmap Bitmap to draw |
|
97 * @param aMask Mask to use |
|
98 * @param aPos Softkey position |
|
99 * @param aPreserveAspectRatio ETrue if image's aspect ratio is preserved |
|
100 * @param aInvertMask ETrue if white mask is used, EFalse if black mask is used |
|
101 * @param aTransferOwnership ETrue if bitmap and mask ownerhsip is transferred to menuadapter |
|
102 */ |
|
103 void SetSoftKeyImageL( |
|
104 CFbsBitmap* aBitmap, |
|
105 CFbsBitmap* aMask, |
|
106 XnMenuInterface::MXnMenuInterface::TSoftKeyPosition aPos, |
|
107 CXnNodeAppIf* aNode, |
|
108 TBool aPreserveAspectRatio, TBool aInvertMask,TBool aTransferOwnership); |
|
109 |
|
110 #if 0 // MSK icon change |
|
111 /** |
|
112 * Sets soft key image. |
|
113 * @param aId icon bitmap IID |
|
114 * @param aBmpFile file path. |
|
115 * @param aBmp Bitmap ID. |
|
116 * @param aBmpM Bitmap mask ID. |
|
117 * @param aPos Softkey position. |
|
118 * @param aEnable ETrue for set icon, EFalse for use default icon. |
|
119 */ |
|
120 void SetSoftKeyImageL( const TAknsItemID& aId, |
|
121 const TDesC& aBmpFile, |
|
122 const TInt32 aBmp, |
|
123 const TInt32 aBmpM, |
|
124 XnMenuInterface::MXnMenuInterface::TSoftKeyPosition aPos, |
|
125 TBool aEnable ); |
|
126 #endif // MSK icon change |
|
127 |
|
128 /** |
|
129 * Sets softkey text. |
|
130 * @since Series 60 3.2 |
|
131 * @param aText Text to draw |
|
132 * @param aPos Softkey position |
|
133 */ |
|
134 void SetSoftKeyTextL( const TDesC& aText, |
|
135 XnMenuInterface::MXnMenuInterface::TSoftKeyPosition aPos ); |
|
136 |
|
137 /** |
|
138 * Sets softkey. |
|
139 * @param aNode Softey node. |
|
140 * @param aPos Softkey position. |
|
141 */ |
|
142 void SetSoftKeyL( CXnNodePluginIf* aSoftkeyNode, |
|
143 XnMenuInterface::MXnMenuInterface::TSoftKeyPosition aPos ); |
|
144 |
|
145 /** |
|
146 * Gets currently visible softkey. |
|
147 * @param aPos Softkey position. |
|
148 * @return Softey node. |
|
149 */ |
|
150 CXnNodePluginIf* SoftKeyL( XnMenuInterface::MXnMenuInterface::TSoftKeyPosition aPos ); |
|
151 |
|
152 /** |
|
153 * Finds softkey node by given position |
|
154 * @since Series 60 5.0 |
|
155 */ |
|
156 virtual TBool FindSoftKeyNodeByPosition( const TPoint& aPosition, CXnNodePluginIf*& aNode ); |
|
157 |
|
158 /** |
|
159 * Tries to display menubar |
|
160 * @since Series 60 5.1 |
|
161 * @param aMenuNodeId the menu node id |
|
162 */ |
|
163 void TryDisplayingMenuL( const TDesC& aMenuNodeId ); |
|
164 |
|
165 public: // from CCoeControl |
|
166 |
|
167 /** |
|
168 * See CCoeControl documentation |
|
169 */ |
|
170 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); |
|
171 |
|
172 /** |
|
173 * See CCoeControl documentation |
|
174 */ |
|
175 virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
176 |
|
177 /** |
|
178 * See CCoeControl documentation |
|
179 */ |
|
180 virtual void HandleResourceChange(TInt aType); |
|
181 |
|
182 /** |
|
183 * From CCoeAppUiBase. Informs the components about the screen layout switch. |
|
184 */ |
|
185 virtual void HandleScreenDeviceChangedL(); |
|
186 |
|
187 public: // from MEikMenuObserver |
|
188 |
|
189 |
|
190 /** |
|
191 * Will panic if we don't override it, because we don't have any resource for it. |
|
192 * Default implementation will read resources |
|
193 */ |
|
194 virtual void RestoreMenuL(CCoeControl* aMenuControl,TInt aResourceId,TMenuType aType); |
|
195 |
|
196 /** |
|
197 * Initialize menu pane dynamically |
|
198 */ |
|
199 virtual void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane); |
|
200 |
|
201 /** |
|
202 * See CCoeControl documentation |
|
203 */ |
|
204 virtual void SetEmphasis(CCoeControl* aMenuControl,TBool aEmphasis); |
|
205 |
|
206 /** |
|
207 * See CCoeControl documentation |
|
208 */ |
|
209 virtual void ProcessCommandL(TInt aCommandId); |
|
210 |
|
211 /** |
|
212 * This is done when application goes to background. |
|
213 */ |
|
214 void DoEnterPowerSaveModeL(TModeEvent aEvent); |
|
215 |
|
216 /** |
|
217 * This is done when application goes to foreground. |
|
218 */ |
|
219 void DoExitPowerSaveModeL(TModeEvent aEvent); |
|
220 |
|
221 /* |
|
222 * Handles menu property change |
|
223 */ |
|
224 virtual void HandleMenuPropertyChangeL(CXnNodePluginIf* aNode, CXnProperty* aProperty); |
|
225 |
|
226 /* |
|
227 * Sets a dynamic menuitem initialisation observer |
|
228 */ |
|
229 void SetObserver( XnMenuInterface::MXnMenuObserver& aObserver ); |
|
230 |
|
231 /* |
|
232 * Removes the dynamic menuitem initialisation observer |
|
233 */ |
|
234 void RemoveObserver(); |
|
235 |
|
236 private: |
|
237 |
|
238 /** |
|
239 * C++ default constructor. |
|
240 */ |
|
241 CXnMenuAdapter(); |
|
242 |
|
243 /** |
|
244 * By default Symbian 2nd phase constructor is private. |
|
245 */ |
|
246 void ConstructL( CXnControlAdapter* aParent, CXnNodePluginIf& aNode ); |
|
247 |
|
248 /** |
|
249 * Populate menu from nodes |
|
250 */ |
|
251 void PopulateMenuL(); |
|
252 |
|
253 /** |
|
254 * Create menu items. Recursive function |
|
255 */ |
|
256 TInt AddMenuItemL( TInt aParentIndex, CXnNodePluginIf* aNode, |
|
257 RPointerArray< const TDesC8 >& aGroups ); |
|
258 |
|
259 /** |
|
260 * Finds softkey item by position |
|
261 */ |
|
262 CXnNodePluginIf* FindSoftkeyItemByPosition( const TPoint& aPosition ); |
|
263 |
|
264 /** |
|
265 * Prepare image for softkey |
|
266 */ |
|
267 CEikImage* PrepareSoftkeyImageL( const CXnSoftkeyItem& aItem, const TSize& aSize ); |
|
268 |
|
269 /** |
|
270 * Sets appearance to softkey, either text or image |
|
271 */ |
|
272 void SetSoftkeyAppearanceL( CXnSoftkeyItem& aItem ); |
|
273 |
|
274 /** |
|
275 * Initializes softkey items array |
|
276 */ |
|
277 void InitSoftkeyItemsL(); |
|
278 |
|
279 /** |
|
280 * Initializes single softkey item image |
|
281 */ |
|
282 void InitSoftkeyItemImageL( CXnSoftkeyItem& aItem ); |
|
283 |
|
284 /** |
|
285 * Check wheter msk is available in this layout |
|
286 */ |
|
287 TBool IsMskAvailable(); |
|
288 |
|
289 /* |
|
290 * Resolves the softkey node which is in this pointer event location |
|
291 */ |
|
292 CXnNodePluginIf* ResolvePointerEventReceiver( const TPoint aPosition ); |
|
293 |
|
294 /** |
|
295 * Tries to display menubar |
|
296 */ |
|
297 void TryDisplayingMenuL(); |
|
298 |
|
299 /** |
|
300 * Get cba button rect from laf |
|
301 */ |
|
302 TRect ButtonTouchableRectByPosition( TInt aPosition ); |
|
303 /** |
|
304 * Finds softkey from node tree |
|
305 */ |
|
306 CXnNodePluginIf* FindSoftkeyNodeL(const TDesC8& aNodeType); |
|
307 /** |
|
308 * Creates menu bar |
|
309 */ |
|
310 void CreateMenuBarL(); |
|
311 /** |
|
312 * Updates softkeys if their "need update" state is on |
|
313 */ |
|
314 void UpdateSoftkeyAppearancesL(); |
|
315 /** |
|
316 * Creates image with right size and set it to left or right softkey |
|
317 */ |
|
318 void ChangeSoftkeyImageL(const CXnSoftkeyItem& aSoftkey); |
|
319 /** |
|
320 * Inserts menu items to menu pane |
|
321 */ |
|
322 void AddItemsToMenuPaneL(CEikMenuPane* aMenuPane, TInt aResourceId); |
|
323 |
|
324 /** |
|
325 * Creates and initialized softkey item (TXnSoftkeyItem holds data for softkey) |
|
326 * if not created yet and appends it to the array |
|
327 */ |
|
328 CXnSoftkeyItem* AppendSoftkeyItemL(CXnNodePluginIf* aNode); |
|
329 |
|
330 /** |
|
331 * Dig type attribute from softkey node. |
|
332 * Return KNullDesC if not found |
|
333 */ |
|
334 const TDesC8& SoftkeyPlaceL(CXnNodePluginIf& aNode); |
|
335 |
|
336 /** |
|
337 * Finds softkey item by position. |
|
338 */ |
|
339 CXnNodePluginIf* DoFindSoftkeyItemByPositionL( const TPoint& aPosition ); |
|
340 |
|
341 /** |
|
342 * Get visible softkey item based on position. |
|
343 */ |
|
344 CXnSoftkeyItem* SoftkeyItemL(TInt aPosition); |
|
345 |
|
346 /** |
|
347 * Get softkey item based on given node |
|
348 */ |
|
349 CXnSoftkeyItem* SoftkeyItemL(CXnNodePluginIf* aNode); |
|
350 |
|
351 /** |
|
352 * Get softkey item based on given node |
|
353 */ |
|
354 CXnSoftkeyItem* SoftkeyItemL(CXnNodeAppIf* aNode); |
|
355 |
|
356 /** |
|
357 * Set member flag true based on item. |
|
358 */ |
|
359 void SetUpdateAppearanceL(CXnSoftkeyItem* aItem); |
|
360 |
|
361 /** |
|
362 * Finds menu item from focused widget. |
|
363 */ |
|
364 CXnNodePluginIf* FindWidgetMenuItemL( CXnNodePluginIf* aNode ); |
|
365 |
|
366 /** |
|
367 * Finds a <widgetsoftkey> node from view which 'source' arrtibure matches with the 'target' attribute |
|
368 * of given node and returns its label. |
|
369 */ |
|
370 HBufC* FindSoftkeyLabelL( CXnNodePluginIf* aNode ); |
|
371 |
|
372 private: // Data |
|
373 TXnUiEnginePluginIf* iUiEngine; |
|
374 CXnNodePluginIf* iRootNode; |
|
375 CXnNodePluginIf* iMenuBarNode; |
|
376 CXnNodePluginIf* iPointerEventNode; |
|
377 CXnNodePluginIf* iKeyEventNode; |
|
378 CArrayFixFlat< TXnMenuItem > iMenuItems; |
|
379 TInt iIdCounter; |
|
380 CEikButtonGroupContainer* iContainer; |
|
381 CEikMenuBar* iMenuBar; |
|
382 XnMenuInterface::MXnMenuObserver* iObserver; |
|
383 TBool iMenuShown; |
|
384 RPointerArray<CXnSoftkeyItem> iSoftkeyItems; |
|
385 TInt iPreviousMenuPaneId; |
|
386 TBool iUpdateLskAppearance; |
|
387 TBool iUpdateMskAppearance; |
|
388 TBool iUpdateRskAppearance; |
|
389 CXnSoftkeyItem* iVisibleLSK; |
|
390 CXnSoftkeyItem* iVisibleRSK; |
|
391 CXnSoftkeyItem* iVisibleMSK; |
|
392 }; |
|
393 |
|
394 |
|
395 |
|
396 #endif // _XNMENUADAPTER_H |
|
397 |
|
398 // End of File |