34
|
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 |
/**
|
|
111 |
* Sets soft key image.
|
|
112 |
* @param aId icon bitmap IID
|
|
113 |
* @param aBmpFile file path.
|
|
114 |
* @param aBmp Bitmap ID.
|
|
115 |
* @param aBmpM Bitmap mask ID.
|
|
116 |
* @param aPos Softkey position.
|
|
117 |
* @param aEnable ETrue for set icon, EFalse for use default icon.
|
|
118 |
*/
|
|
119 |
void SetSoftKeyImageL( const TAknsItemID& aId,
|
|
120 |
const TDesC& aBmpFile,
|
|
121 |
const TInt32 aBmp,
|
|
122 |
const TInt32 aBmpM,
|
|
123 |
XnMenuInterface::MXnMenuInterface::TSoftKeyPosition aPos,
|
|
124 |
TBool aEnable );
|
|
125 |
|
|
126 |
/**
|
|
127 |
* Sets softkey text.
|
|
128 |
* @since Series 60 3.2
|
|
129 |
* @param aText Text to draw
|
|
130 |
* @param aPos Softkey position
|
|
131 |
*/
|
|
132 |
void SetSoftKeyTextL( const TDesC& aText,
|
|
133 |
XnMenuInterface::MXnMenuInterface::TSoftKeyPosition aPos );
|
|
134 |
|
|
135 |
/**
|
|
136 |
* Sets softkey.
|
|
137 |
* @param aNode Softey node.
|
|
138 |
* @param aPos Softkey position.
|
|
139 |
*/
|
|
140 |
void SetSoftKeyL( CXnNodePluginIf* aSoftkeyNode,
|
|
141 |
XnMenuInterface::MXnMenuInterface::TSoftKeyPosition aPos );
|
|
142 |
|
|
143 |
/**
|
|
144 |
* Gets currently visible softkey.
|
|
145 |
* @param aPos Softkey position.
|
|
146 |
* @return Softey node.
|
|
147 |
*/
|
|
148 |
CXnNodePluginIf* SoftKeyL( XnMenuInterface::MXnMenuInterface::TSoftKeyPosition aPos );
|
|
149 |
|
|
150 |
/**
|
|
151 |
* Returns softkey node, which should handle key event.
|
|
152 |
* @return softkey node which should handle key event, NULL if not available.
|
|
153 |
*/
|
|
154 |
CXnNodePluginIf* KeyEventNode();
|
|
155 |
|
|
156 |
/**
|
|
157 |
* Finds softkey node by given position
|
|
158 |
* @since Series 60 5.0
|
|
159 |
*/
|
|
160 |
virtual TBool FindSoftKeyNodeByPosition( const TPoint& aPosition, CXnNodePluginIf*& aNode );
|
|
161 |
|
|
162 |
/**
|
|
163 |
* Tries to display menubar
|
|
164 |
* @since Series 60 5.2
|
|
165 |
* @param aMenuNodeId the menu node id
|
|
166 |
* @param aContextMenu ETrue if context menu should be displayed, EFalse otherwise
|
|
167 |
*/
|
|
168 |
void TryDisplayingMenuL( const TDesC& aMenuNodeId, TBool aContextMenu );
|
|
169 |
|
|
170 |
public: // from CCoeControl
|
|
171 |
|
|
172 |
/**
|
|
173 |
* See CCoeControl documentation
|
|
174 |
*/
|
|
175 |
TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
|
|
176 |
|
|
177 |
/**
|
|
178 |
* See CCoeControl documentation
|
|
179 |
*/
|
|
180 |
virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);
|
|
181 |
|
|
182 |
/**
|
|
183 |
* See CCoeControl documentation
|
|
184 |
*/
|
|
185 |
virtual void HandleResourceChange(TInt aType);
|
|
186 |
|
|
187 |
/**
|
|
188 |
* From CCoeAppUiBase. Informs the components about the screen layout switch.
|
|
189 |
*/
|
|
190 |
virtual void HandleScreenDeviceChangedL();
|
|
191 |
|
|
192 |
public: // from MEikMenuObserver
|
|
193 |
|
|
194 |
|
|
195 |
/**
|
|
196 |
* Will panic if we don't override it, because we don't have any resource for it.
|
|
197 |
* Default implementation will read resources
|
|
198 |
*/
|
|
199 |
virtual void RestoreMenuL(CCoeControl* aMenuControl,TInt aResourceId,TMenuType aType);
|
|
200 |
|
|
201 |
/**
|
|
202 |
* Initialize menu pane dynamically
|
|
203 |
*/
|
|
204 |
virtual void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
|
|
205 |
|
|
206 |
/**
|
|
207 |
* See CCoeControl documentation
|
|
208 |
*/
|
|
209 |
virtual void SetEmphasis(CCoeControl* aMenuControl,TBool aEmphasis);
|
|
210 |
|
|
211 |
/**
|
|
212 |
* See CCoeControl documentation
|
|
213 |
*/
|
|
214 |
virtual void ProcessCommandL(TInt aCommandId);
|
|
215 |
|
|
216 |
/**
|
|
217 |
* This is done when application goes to background.
|
|
218 |
*/
|
|
219 |
void DoEnterPowerSaveModeL(TModeEvent aEvent);
|
|
220 |
|
|
221 |
/**
|
|
222 |
* This is done when application goes to foreground.
|
|
223 |
*/
|
|
224 |
void DoExitPowerSaveModeL(TModeEvent aEvent);
|
|
225 |
|
|
226 |
/*
|
|
227 |
* Handles menu property change
|
|
228 |
*/
|
|
229 |
virtual void HandleMenuPropertyChangeL(CXnNodePluginIf* aNode, CXnProperty* aProperty);
|
|
230 |
|
|
231 |
/*
|
|
232 |
* Sets a dynamic menuitem initialisation observer
|
|
233 |
*/
|
|
234 |
void SetObserver( XnMenuInterface::MXnMenuObserver& aObserver );
|
|
235 |
|
|
236 |
/*
|
|
237 |
* Removes the dynamic menuitem initialisation observer
|
|
238 |
*/
|
|
239 |
void RemoveObserver();
|
|
240 |
|
|
241 |
private:
|
|
242 |
|
|
243 |
/**
|
|
244 |
* C++ default constructor.
|
|
245 |
*/
|
|
246 |
CXnMenuAdapter();
|
|
247 |
|
|
248 |
/**
|
|
249 |
* By default Symbian 2nd phase constructor is private.
|
|
250 |
*/
|
|
251 |
void ConstructL( CXnControlAdapter* aParent, CXnNodePluginIf& aNode );
|
|
252 |
|
|
253 |
/**
|
|
254 |
* Populate menu from nodes
|
|
255 |
*/
|
|
256 |
void PopulateMenuL();
|
|
257 |
|
|
258 |
/**
|
|
259 |
* Create menu items. Recursive function
|
|
260 |
*/
|
|
261 |
TInt AddMenuItemL( TInt aParentIndex, CXnNodePluginIf* aNode,
|
|
262 |
RPointerArray< const TDesC8 >& aGroups );
|
|
263 |
|
|
264 |
/**
|
|
265 |
* Finds softkey item by position
|
|
266 |
*/
|
|
267 |
CXnNodePluginIf* FindSoftkeyItemByPosition( const TPoint& aPosition );
|
|
268 |
|
|
269 |
/**
|
|
270 |
* Prepare image for softkey
|
|
271 |
*/
|
|
272 |
CEikImage* PrepareSoftkeyImageL( const CXnSoftkeyItem& aItem, const TSize& aSize );
|
|
273 |
|
|
274 |
/**
|
|
275 |
* Sets appearance to softkey, either text or image
|
|
276 |
*/
|
|
277 |
void SetSoftkeyAppearanceL( CXnSoftkeyItem& aItem );
|
|
278 |
|
|
279 |
/**
|
|
280 |
* Initializes softkey items array
|
|
281 |
*/
|
|
282 |
void InitSoftkeyItemsL();
|
|
283 |
|
|
284 |
/**
|
|
285 |
* Initializes single softkey item image
|
|
286 |
*/
|
|
287 |
void InitSoftkeyItemImageL( CXnSoftkeyItem& aItem );
|
|
288 |
|
|
289 |
/**
|
|
290 |
* Check wheter msk is available in this layout
|
|
291 |
*/
|
|
292 |
TBool IsMskAvailable();
|
|
293 |
|
|
294 |
/*
|
|
295 |
* Resolves the softkey node which is in this pointer event location
|
|
296 |
*/
|
|
297 |
CXnNodePluginIf* ResolvePointerEventReceiver( const TPoint aPosition );
|
|
298 |
|
|
299 |
/**
|
|
300 |
* Tries to display menubar
|
|
301 |
*/
|
|
302 |
void TryDisplayingMenuL();
|
|
303 |
|
|
304 |
/**
|
|
305 |
* Get cba button rect from laf
|
|
306 |
*/
|
|
307 |
TRect ButtonTouchableRectByPosition( TInt aPosition );
|
|
308 |
/**
|
|
309 |
* Finds softkey from node tree
|
|
310 |
*/
|
|
311 |
CXnNodePluginIf* FindSoftkeyNodeL(const TDesC8& aNodeType);
|
|
312 |
/**
|
|
313 |
* Creates menu bar
|
|
314 |
*/
|
|
315 |
void CreateMenuBarL();
|
|
316 |
/**
|
|
317 |
* Updates softkeys if their "need update" state is on
|
|
318 |
*/
|
|
319 |
void UpdateSoftkeyAppearancesL();
|
|
320 |
/**
|
|
321 |
* Creates image with right size and set it to left or right softkey
|
|
322 |
*/
|
|
323 |
void ChangeSoftkeyImageL(const CXnSoftkeyItem& aSoftkey);
|
|
324 |
/**
|
|
325 |
* Inserts menu items to menu pane
|
|
326 |
*/
|
|
327 |
void AddItemsToMenuPaneL(CEikMenuPane* aMenuPane, TInt aResourceId);
|
|
328 |
|
|
329 |
/**
|
|
330 |
* Creates and initialized softkey item (TXnSoftkeyItem holds data for softkey)
|
|
331 |
* if not created yet and appends it to the array
|
|
332 |
*/
|
|
333 |
CXnSoftkeyItem* AppendSoftkeyItemL(CXnNodePluginIf* aNode);
|
|
334 |
|
|
335 |
/**
|
|
336 |
* Dig type attribute from softkey node.
|
|
337 |
* Return KNullDesC if not found
|
|
338 |
*/
|
|
339 |
const TDesC8& SoftkeyPlaceL(CXnNodePluginIf& aNode);
|
|
340 |
|
|
341 |
/**
|
|
342 |
* Finds softkey item by position.
|
|
343 |
*/
|
|
344 |
CXnNodePluginIf* DoFindSoftkeyItemByPositionL( const TPoint& aPosition );
|
|
345 |
|
|
346 |
/**
|
|
347 |
* Get visible softkey item based on position.
|
|
348 |
*/
|
|
349 |
CXnSoftkeyItem* SoftkeyItemL(TInt aPosition);
|
|
350 |
|
|
351 |
/**
|
|
352 |
* Get softkey item based on given node
|
|
353 |
*/
|
|
354 |
CXnSoftkeyItem* SoftkeyItemL(CXnNodePluginIf* aNode);
|
|
355 |
|
|
356 |
/**
|
|
357 |
* Get softkey item based on given node
|
|
358 |
*/
|
|
359 |
CXnSoftkeyItem* SoftkeyItemL(CXnNodeAppIf* aNode);
|
|
360 |
|
|
361 |
/**
|
|
362 |
* Set member flag true based on item.
|
|
363 |
*/
|
|
364 |
void SetUpdateAppearanceL(CXnSoftkeyItem* aItem);
|
|
365 |
|
|
366 |
/**
|
|
367 |
* Finds menu item from focused widget.
|
|
368 |
*/
|
|
369 |
CXnNodePluginIf* FindWidgetMenuItemL( CXnNodePluginIf* aNode );
|
|
370 |
|
|
371 |
/**
|
|
372 |
* Finds a <widgetsoftkey> node from view which 'source' arrtibure matches with the 'target' attribute
|
|
373 |
* of given node and returns its label.
|
|
374 |
*/
|
|
375 |
HBufC* FindSoftkeyLabelL( CXnNodePluginIf* aNode );
|
|
376 |
|
|
377 |
private: // Data
|
|
378 |
TXnUiEnginePluginIf* iUiEngine;
|
|
379 |
CXnNodePluginIf* iRootNode;
|
|
380 |
CXnNodePluginIf* iMenuBarNode;
|
|
381 |
CXnNodePluginIf* iPointerEventNode;
|
|
382 |
CXnNodePluginIf* iKeyEventNode;
|
|
383 |
CArrayFixFlat< TXnMenuItem > iMenuItems;
|
|
384 |
TInt iIdCounter;
|
|
385 |
CEikButtonGroupContainer* iContainer;
|
|
386 |
CEikMenuBar* iMenuBar;
|
|
387 |
XnMenuInterface::MXnMenuObserver* iObserver;
|
|
388 |
TBool iMenuShown;
|
|
389 |
RPointerArray<CXnSoftkeyItem> iSoftkeyItems;
|
|
390 |
TInt iPreviousMenuPaneId;
|
|
391 |
TBool iUpdateLskAppearance;
|
|
392 |
TBool iUpdateMskAppearance;
|
|
393 |
TBool iUpdateRskAppearance;
|
|
394 |
TBool iContextMenu;
|
|
395 |
CXnSoftkeyItem* iVisibleLSK;
|
|
396 |
CXnSoftkeyItem* iVisibleRSK;
|
|
397 |
CXnSoftkeyItem* iVisibleMSK;
|
|
398 |
};
|
|
399 |
|
|
400 |
|
|
401 |
|
|
402 |
#endif // _XNMENUADAPTER_H
|
|
403 |
|
|
404 |
// End of File
|