1 eikmenup.h |
1 /* |
|
2 * Copyright (c) 1997-1999 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 "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #if !defined(__EIKMENUP_H__) |
|
20 #define __EIKMENUP_H__ |
|
21 |
|
22 #if !defined(__EIKBCTRL_H__) |
|
23 #include <eikbctrl.h> |
|
24 #endif |
|
25 |
|
26 #if !defined(__EIKDEF_H__) |
|
27 #include <eikdef.h> |
|
28 #endif |
|
29 |
|
30 #if !defined(__EIKSBOBS_H__) |
|
31 #include <eiksbobs.h> // for TEikScrollEvent |
|
32 #endif |
|
33 |
|
34 #include <bidi.h> |
|
35 |
|
36 // FORWARD DECLARATIONS |
|
37 class MEikMenuObserver; |
|
38 class CEikHotKeyTable; |
|
39 class CEikMenuPaneTitle; |
|
40 class CEikButtonBase; |
|
41 class CEikScrollBarFrame; |
|
42 class CEikScrollBar; |
|
43 class TEikScrollBarModel; |
|
44 class CGulIcon; |
|
45 class CEikMenuPaneExtension ; |
|
46 |
|
47 // CONSTANTS |
|
48 const TInt KScaleableTextSeparator = 0x0001; |
|
49 |
|
50 /** |
|
51 * A helper class for extending CEikMenuPaneItem without breaking binary |
|
52 * compability. |
|
53 */ |
|
54 class CExtendedItemData : public CBase |
|
55 { |
|
56 |
|
57 public: |
|
58 |
|
59 /** |
|
60 * Destructor. |
|
61 */ |
|
62 ~CExtendedItemData(); |
|
63 |
|
64 public: |
|
65 |
|
66 /** Two packaked bitmaps: bitmap icon and mask for it. */ |
|
67 CGulIcon* iIcon; |
|
68 |
|
69 /** Scalable text buffer. */ |
|
70 HBufC* iScaleableText; |
|
71 }; |
|
72 |
|
73 |
|
74 /** |
|
75 * The @c CEikMenuPaneItem class encapsulates the data needed to define a menu |
|
76 * pane item and provides some of the functionality required to display the |
|
77 * item. |
|
78 * |
|
79 * @since ER5U |
|
80 */ |
|
81 class CEikMenuPaneItem : public CBase |
|
82 { |
|
83 |
|
84 public: |
|
85 |
|
86 /** Struct to menu pane item. */ |
|
87 struct SData |
|
88 { |
|
89 |
|
90 /** Nominal text length.*/ |
|
91 enum { ENominalTextLength=40 }; |
|
92 |
|
93 /** |
|
94 * ID of the command to issue when the menu item using this @c SData is |
|
95 * selected. |
|
96 */ |
|
97 TInt iCommandId; |
|
98 |
|
99 /** Resource ID of a menu pane to cascade from this item. */ |
|
100 TInt iCascadeId; |
|
101 |
|
102 /** |
|
103 * Flags used internally by @c CEikMenuPane and accessible through |
|
104 * functions such as @c CEikMenuPane::SetItemDimmed(). |
|
105 */ |
|
106 TInt iFlags; |
|
107 |
|
108 /** The text buffer displayed in the main area of the menu item. */ |
|
109 TBuf<ENominalTextLength> iText; // less than this actually stored |
|
110 |
|
111 /** |
|
112 * Additional descriptive text about the item. This is used by @c |
|
113 * CEikMenuPane to display hotkey names. |
|
114 */ |
|
115 TBuf<1> iExtraText; |
|
116 }; |
|
117 |
|
118 public: |
|
119 |
|
120 /** |
|
121 * C++ default constructor. |
|
122 */ |
|
123 IMPORT_C CEikMenuPaneItem(); |
|
124 |
|
125 /** |
|
126 * Destructor. |
|
127 */ |
|
128 IMPORT_C ~CEikMenuPaneItem(); |
|
129 |
|
130 /** |
|
131 * Sets a menu item icon. This replaces any icon already set for the menu |
|
132 * item. |
|
133 * |
|
134 * @param aIcon Menu item icon consisting of a picture bitmap and a mask |
|
135 * bitmap. |
|
136 */ |
|
137 IMPORT_C void SetIcon(CGulIcon* aIcon); |
|
138 |
|
139 /** |
|
140 * Draws the menu item icon. |
|
141 * |
|
142 * @param aGc Graphics context to which the icon is drawn. |
|
143 * @param aRect Rectangle in which the icon is drawn. |
|
144 * @param aDimmed If @c ETrue the icon is drawn dimmed. |
|
145 * @param aBitmapSpaceRequired Length of one side of the square required to |
|
146 * contain the bitmap. |
|
147 */ |
|
148 IMPORT_C void DrawItemIcon(CWindowGc& aGc, |
|
149 TRect aRect, |
|
150 TBool aDimmed, |
|
151 TInt aBitmapSpaceRequired) const; |
|
152 |
|
153 /** |
|
154 * Construct an icon from bitmaps. |
|
155 * |
|
156 * Constructs a new icon for the menu item, taking ownership of the picture |
|
157 * bitmap aBitmap and the mask bitmap aMask unless the bitmaps are |
|
158 * externally owned. |
|
159 * |
|
160 * @param aBitmap Picture bitmap. |
|
161 * @param aMask Mask bitmap. |
|
162 */ |
|
163 IMPORT_C void CreateIconL(CFbsBitmap* aBitmap, |
|
164 CFbsBitmap* aMask); |
|
165 |
|
166 /** |
|
167 * Gets a pointer to the menu item's icon picture bitmap. This does not |
|
168 * imply transfer of ownership. |
|
169 * |
|
170 * @return Picture bitmap. |
|
171 */ |
|
172 IMPORT_C CFbsBitmap* IconBitmap() const; |
|
173 |
|
174 /** |
|
175 * Gets a pointer to the menu item's icon mask bitmap. This does not imply |
|
176 * transfer of ownership. |
|
177 * |
|
178 * @return Mask bitmap. |
|
179 */ |
|
180 IMPORT_C CFbsBitmap* IconMask() const; |
|
181 |
|
182 /** |
|
183 * Sets icon bitmap ownership. |
|
184 * Sets the menu item's icon bitmaps as externally owned if @c |
|
185 * aOwnedExternally is @c ETrue. |
|
186 * |
|
187 * @param aOwnedExternally If @c ETrue bitmaps are set as externally owned. |
|
188 * @c If EFalse bitmaps are set as not being externally owned. |
|
189 */ |
|
190 IMPORT_C void SetBitmapsOwnedExternally(TBool aOwnedExternally); |
|
191 |
|
192 /** |
|
193 * Sets the picture bitmap. Transfers ownership unless the bitmaps are |
|
194 * already owned externally. |
|
195 * |
|
196 * @param aBitmap Picture bitmap. |
|
197 */ |
|
198 IMPORT_C void SetIconBitmapL(CFbsBitmap* aBitmap); |
|
199 |
|
200 /** |
|
201 * Sets the mask bitmap. Transfers ownership unless the bitmaps are already |
|
202 * owned externally. |
|
203 * |
|
204 * @param aMask Mask bitmap. |
|
205 */ |
|
206 IMPORT_C void SetIconMaskL(CFbsBitmap* aMask); |
|
207 |
|
208 /** |
|
209 * Returns scaleable text. If there isn't scaleable text available then |
|
210 * this method returns @c iData.iText. |
|
211 * |
|
212 * @return Pointer to TPtrC object that contains scaleable text. |
|
213 */ |
|
214 IMPORT_C TPtrC ScaleableText() const; |
|
215 |
|
216 /** |
|
217 * Sets scaleable text. @c iData.iText is set to first text version. |
|
218 * |
|
219 * @param aText Scalable text. |
|
220 */ |
|
221 IMPORT_C void SetScaleableTextL(const TDesC& aText); |
|
222 |
|
223 private: |
|
224 inline void CreateExtendedDataBlock(); |
|
225 inline TBool IsScaleableText(const TDesC& aText) const; |
|
226 TPtrC GetNominalText(const TDesC& aText); |
|
227 |
|
228 public: |
|
229 |
|
230 /** The y position of the menu pane item. */ |
|
231 TInt iPos; |
|
232 |
|
233 /** The menu pane item's hotkey text. */ |
|
234 TInt iHotKeyCode; |
|
235 |
|
236 /** Information from an SData struct. */ |
|
237 SData iData; |
|
238 |
|
239 private: |
|
240 CExtendedItemData* iExtendedData; |
|
241 }; |
|
242 |
|
243 |
|
244 inline void CEikMenuPaneItem::CreateExtendedDataBlock() |
|
245 { |
|
246 if (!iExtendedData) |
|
247 { |
|
248 TRAPD(err, ( iExtendedData = new (ELeave) CExtendedItemData() ) ); |
|
249 } |
|
250 } |
|
251 |
|
252 |
|
253 inline TBool CEikMenuPaneItem::IsScaleableText(const TDesC& aText) const |
|
254 { |
|
255 return (aText.Locate(TChar(KScaleableTextSeparator)) == KErrNotFound ? EFalse : ETrue); |
|
256 } |
|
257 |
|
258 |
|
259 /** |
|
260 * Menu panes are opened by activating the menu title |
|
261 * @c (CEikMenuPaneTitle / MENU_TITLE) which is displayed in the menu bar @c |
|
262 * (CEikMenuBar / MENU_BAR). They can also be cascaded from a menu item @c |
|
263 * (CEikMenuPaneItem / MENU_ITEM) or launched by a menu button @c |
|
264 * (CEikMenuButton). |
|
265 * |
|
266 * Menu panes may be defined using a @c MENU_PANE resource. |
|
267 */ |
|
268 class CEikMenuPane : public CEikBorderedControl |
|
269 { |
|
270 private: |
|
271 enum {ENothingSelected=-1}; |
|
272 class CMenuScroller; |
|
273 friend class CMenuScroller; |
|
274 friend class CEikMenuPaneExtension; |
|
275 public: |
|
276 |
|
277 /** The text to be displayed for a hotkey. */ |
|
278 typedef TBuf<20> THotKeyDisplayText; |
|
279 |
|
280 public: |
|
281 |
|
282 /** |
|
283 * This class provides a constructor to create an array of menu pane items |
|
284 * and a destructor to destroy an array of menu pane items. |
|
285 */ |
|
286 class CItemArray:public CArrayPtrFlat<CEikMenuPaneItem> |
|
287 { |
|
288 |
|
289 public: |
|
290 |
|
291 /** |
|
292 * C++ default constructor that creates a flat array of menu pane |
|
293 * items. |
|
294 */ |
|
295 IMPORT_C CItemArray(); |
|
296 |
|
297 /** |
|
298 * Destructor. |
|
299 */ |
|
300 IMPORT_C ~CItemArray(); |
|
301 |
|
302 /** |
|
303 * Appends @c CEikMenuPaneItem class object to array. |
|
304 * |
|
305 * @param aMenuItem The menu item to add. |
|
306 */ |
|
307 IMPORT_C void AddItemL(CEikMenuPaneItem* aMenuItem); |
|
308 }; |
|
309 |
|
310 public: |
|
311 |
|
312 /** |
|
313 * Destructor. |
|
314 */ |
|
315 IMPORT_C ~CEikMenuPane(); |
|
316 |
|
317 /** |
|
318 * C++ default constructor. Constructs a menu pane object with the |
|
319 * specified observer. |
|
320 * |
|
321 * @param aMenuObserver Menu observer. |
|
322 */ |
|
323 IMPORT_C CEikMenuPane(MEikMenuObserver* aMenuObserver); |
|
324 |
|
325 /** |
|
326 * Handles 2nd base construction. Completes construction of a menu pane object. |
|
327 * |
|
328 * @param aOwner Menu pane owner ( for cascade menu ). |
|
329 * @param aEditMenuObserver Observer for the edit menu. In default this is |
|
330 * @c NULL. |
|
331 */ |
|
332 IMPORT_C void ConstructL(CEikMenuPane* aOwner, |
|
333 MEikMenuObserver* aEditMenuObserver = NULL); |
|
334 |
|
335 /** |
|
336 * Destroys the menu pane's item array. |
|
337 */ |
|
338 IMPORT_C void Reset(); |
|
339 |
|
340 public: // framework |
|
341 |
|
342 /** |
|
343 * From @c CcoeControl. |
|
344 * |
|
345 * Handles key events offered to the menu by the control environment and |
|
346 * provides an appropriate implementation of @c |
|
347 * CCoeControl::OfferKeyEventL(). |
|
348 * |
|
349 * @param aKeyEvent The key event. |
|
350 * @param aType The type of key event: @c EEventKey, @c EEventKeyUp or @c |
|
351 * EEventKeyDown. |
|
352 */ |
|
353 IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, |
|
354 TEventCode aType); |
|
355 |
|
356 /** |
|
357 * From @c CcoeControl. |
|
358 * |
|
359 * Handles a pointer event on the menu. |
|
360 * |
|
361 * @param aPointerEvent The pointer event to handle. |
|
362 */ |
|
363 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
364 |
|
365 /** |
|
366 * From @c CcoeControl. |
|
367 * |
|
368 * Gets the list of logical colours employed in the drawing of the control, |
|
369 * paired with an explanation of how they are used. Appends the list into |
|
370 * @c aColorUseList. |
|
371 * |
|
372 * @since 005u |
|
373 * @param aColorUseList The list of colours paired with explanations. |
|
374 */ |
|
375 IMPORT_C virtual void GetColorUseListL( |
|
376 CArrayFix<TCoeColorUse>& aColorUseList) const; |
|
377 |
|
378 /** |
|
379 * From @c CcoeControl. |
|
380 * |
|
381 * Handles a change to the menu's resources which are shared across the |
|
382 * environment. For example, colours or fonts. |
|
383 * |
|
384 * @since 005u |
|
385 * @param aType The type of resource that has changed. |
|
386 */ |
|
387 IMPORT_C virtual void HandleResourceChange(TInt aType); // not available before Release 005u |
|
388 |
|
389 private: // from base class |
|
390 |
|
391 /** |
|
392 * Not implemented. |
|
393 * |
|
394 * @param Not used. |
|
395 * @return NULL |
|
396 */ |
|
397 IMPORT_C void* ExtensionInterface( TUid aInterface ); |
|
398 |
|
399 public: // from MCoeInputObserver |
|
400 |
|
401 /** |
|
402 * From @c CCoeControl. |
|
403 * |
|
404 * Gets the list boxs input capabilities as set through the list box flags. |
|
405 * |
|
406 * @return List box input capabilities. |
|
407 */ |
|
408 IMPORT_C TCoeInputCapabilities InputCapabilities() const; |
|
409 |
|
410 protected: // from base class |
|
411 |
|
412 /** |
|
413 * From @c CCoeControl |
|
414 * |
|
415 * Draw a control called by window server. |
|
416 * |
|
417 * All controls, except blank controls, should implement this function. The |
|
418 * default implementation draws a blank control. This function is used for |
|
419 * window server-initiated redrawing of controls, and for some |
|
420 * application-initiated drawing. It should be implemented by each control, |
|
421 * but is only called from within @c CCoeControl's member functions, and |
|
422 * not from the derived class. For this reason it is a private member |
|
423 * function of @c CCoeControl. |
|
424 * |
|
425 * The rectangle aRect indicates the region of the control that needs to be |
|
426 * redrawn. The implementation of @c Draw() must always draw to every pixel |
|
427 * within this rectangle. |
|
428 * |
|
429 * @param aRect The region of the control to be redrawn. |
|
430 * Co-ordinates are relative to the control's origin (top left |
|
431 * corner). Optional, not used currently. |
|
432 */ |
|
433 IMPORT_C void Draw(const TRect& aRect) const; |
|
434 |
|
435 /** |
|
436 * From @c CCoeControl. |
|
437 * |
|
438 * Takes any action required when the menu pane gains or loses focus, |
|
439 * to change its appearance for example. |
|
440 * |
|
441 * @param aDrawNow If @c EDrawNow the menu pane is redrawn. If @c |
|
442 * ENoDrawNow the menu pane is not redrawn. |
|
443 */ |
|
444 IMPORT_C void FocusChanged(TDrawNow aDrawNow); |
|
445 |
|
446 /** |
|
447 * From @c CCoeControl. |
|
448 * |
|
449 * Constructs the menu pane using the specified resource reader. |
|
450 * Fills the menu item array with the list of menu items provided by the |
|
451 * resource file. |
|
452 * |
|
453 * @param aReader The resource reader to use. |
|
454 * @leave KErrNoMemory Memory allocation failure earlier construction. |
|
455 */ |
|
456 IMPORT_C void ConstructFromResourceL(TResourceReader& aReader); |
|
457 |
|
458 public: // new functions |
|
459 |
|
460 /** |
|
461 * Adds a menu item dynamically by creating a new menu item, setting its |
|
462 * data to @c aMenuItem and appending it to the pane's menu item array. |
|
463 * Updates the menu's scroll bar to take account of the new item. |
|
464 * |
|
465 * @param aMenuItem The menu item to add. |
|
466 * NOTICE that @c SData is a structure so all fields in it should be |
|
467 * set to avoid any unexpected behaviour. |
|
468 */ |
|
469 IMPORT_C void AddMenuItemL(const CEikMenuPaneItem::SData& aMenuItem); |
|
470 |
|
471 /** |
|
472 * Adds a menu item dynamically by creating a new menu item, setting its |
|
473 * data to @c aMenuItem and inserting it into the pane's menu item array. |
|
474 * Updates the menu's scroll bar to take account of the new item. |
|
475 * |
|
476 * @param aMenuItem The menu item to add. NOTICE that @c SData is a |
|
477 * structure so all fields in it should be set to avoid any |
|
478 * unexpected behaviour. |
|
479 * @param aPreviousId The id of the item after which the new item should be |
|
480 * added. |
|
481 */ |
|
482 IMPORT_C void AddMenuItemL(const CEikMenuPaneItem::SData& aMenuItem, |
|
483 TInt aPreviousId); |
|
484 |
|
485 /** |
|
486 * Adds menu items dynamically by creating new menu items from resource |
|
487 * and inserts them into the pane's menu item array. |
|
488 * |
|
489 * @param aResourceId The ID of the resource for the menu item. |
|
490 * @param aPreviousId The ID of the previous menu item, after which this |
|
491 * newly created item should be added. |
|
492 * @param aAddSeperator Shouldn't be used as separator is not not supported |
|
493 * anymore. |
|
494 */ |
|
495 IMPORT_C void AddMenuItemsL(TInt aResourceId, |
|
496 TInt aPreviousId = 0, |
|
497 TBool aAddSeperator = EFalse); |
|
498 |
|
499 /** |
|
500 * Deletes the specified item in the menu pane. |
|
501 * |
|
502 * @param aCommandId The ID for the item to be deleted. |
|
503 */ |
|
504 IMPORT_C void DeleteMenuItem(TInt aCommandId); |
|
505 |
|
506 /** |
|
507 * Deletes the items between specified items. |
|
508 * |
|
509 * @param aStartIndex The index of the item after which items should be |
|
510 * deleted. |
|
511 * @param aEndIndex The index of the item up to which items should be |
|
512 * deleted. |
|
513 */ |
|
514 IMPORT_C void DeleteBetweenMenuItems(TInt aStartIndex, |
|
515 TInt aEndIndex); |
|
516 |
|
517 /** |
|
518 * Gets a reference to the data in the specified menu item. |
|
519 * |
|
520 * @param aCommandId The command ID of the menu item for which data is |
|
521 * obtained. |
|
522 * @return Reference to struct that contains command id. |
|
523 */ |
|
524 IMPORT_C CEikMenuPaneItem::SData& ItemData(TInt aCommandId); |
|
525 |
|
526 /** |
|
527 * Gets a pointer to the specified menu item. Also gets the position of the |
|
528 * item within the menu pane. Panics if there are no menu items in the menu |
|
529 * pane. Panics if the menu pane id does not identify any menu pane item in |
|
530 * the array. |
|
531 * |
|
532 * @param aCommandId The ID of the menu item for which a pointer is |
|
533 * returned. |
|
534 * @param aPos On return, the position of the menu item with an ID of |
|
535 * aCommandId. |
|
536 * @return A pointer to the menu item. |
|
537 * @panic EEikPanicNoSuchMenuItem Panics if there are no menu items in the |
|
538 * menu pane or if the menu pane id does not |
|
539 * identify any menu pane item in the array. |
|
540 */ |
|
541 IMPORT_C CEikMenuPaneItem* ItemAndPos(TInt aCommandId,TInt& aPos); |
|
542 |
|
543 /** |
|
544 * Displays the menu pane with the corner identified by @c aTargetType in |
|
545 * the position specified by @c aTargetPos. This function uses @c |
|
546 * aMinTitleWidth to calculate the area required to display the menu pane, |
|
547 * taking into account whether the menu is a cascading menu or popup menu. |
|
548 * |
|
549 * @param aHotKeyTable Optional hotkey table. |
|
550 * @param aTargetPos Position of the corner of the menu pane identified by |
|
551 * @c aTargetType. |
|
552 * @param aMenuPaneTitle The menu pane's title. |
|
553 * @param aMinWidth Minimum width of the menu's title. |
|
554 * @param aTargetType The corner of the menu pane to which @c aTargetPos |
|
555 * relates. The default is the top left corner. Possible: @c |
|
556 * EPopupTargetTopLeft, @c EPopupTargetTopRight, |
|
557 * @cEPopupTargetBottomLeft, @c EPopupTargetBottomRight. |
|
558 */ |
|
559 IMPORT_C void StartDisplayingMenuPane( |
|
560 const CEikHotKeyTable* aHotKeyTable, |
|
561 const TPoint& aTargetPos, |
|
562 const CEikMenuPaneTitle* aMenuPaneTitle, |
|
563 TInt aMinWidth, |
|
564 TPopupTargetPosType aTargetType = EPopupTargetTopLeft); |
|
565 |
|
566 /** |
|
567 * Sets the text in a menu item. |
|
568 * |
|
569 * @param aCommandId The command (as defined in an .hrh file) associated |
|
570 * with this menu item. This identifies the menu item whose text is |
|
571 * to be set. |
|
572 * @param aDes New item text. |
|
573 */ |
|
574 IMPORT_C void SetItemTextL(TInt aCommandId, |
|
575 const TDesC& aDes); |
|
576 |
|
577 /** |
|
578 * Sets the text in a menu item from resource. |
|
579 * |
|
580 * @param aCommandId The command (as defined in an .hrh file) associated |
|
581 * with this menu item. This identifies the menu item whose text is |
|
582 * to be set. |
|
583 * @param aRid The resource ID of the menu item text. |
|
584 */ |
|
585 IMPORT_C void SetItemTextL(TInt aCommandId, |
|
586 TInt aRid); |
|
587 |
|
588 /** |
|
589 * Dims (greys out) or undims a menu item. Dimming indicates that user |
|
590 * input is not accepted. |
|
591 * |
|
592 * @param aCommandId The command (as defined in an .hrh file) associated |
|
593 * with this menu item. This identifies the menu item whose text is |
|
594 * to be dimmed or un-dimmed. |
|
595 * @param aDimmed @c ETrue to dim this menu item. @c EFalse to un-dim this |
|
596 * menu item. |
|
597 */ |
|
598 IMPORT_C void SetItemDimmed(TInt aCommandId, |
|
599 TBool aDimmed); |
|
600 |
|
601 /** |
|
602 * Sets the item to be indicated or not. It should be used to change the |
|
603 * state of radio buttons or check box items. It has real effect only |
|
604 * starting from S60 v3.0. |
|
605 * |
|
606 * @param aCommandId The command (as defined in an .hrh file) associated |
|
607 * with this menu item. This identifies the menu item for which the |
|
608 * state is set or unset. |
|
609 * @param aButtonState should be @c EEikMenuItemSymbolOn or @c |
|
610 * EEikMenuItemSymbolIndeterminate |
|
611 */ |
|
612 IMPORT_C void SetItemButtonState(TInt aCommandId, |
|
613 TInt aButtonState); |
|
614 |
|
615 /** |
|
616 * Sets the selected menu item. |
|
617 * |
|
618 * @param aSelectedItem The index of the item to get selected |
|
619 */ |
|
620 IMPORT_C void SetSelectedItem(TInt aSelectedItem); |
|
621 |
|
622 /** |
|
623 * Gets the position of the selected menu item. |
|
624 * |
|
625 * @return The position of the selected menu item. |
|
626 */ |
|
627 IMPORT_C TInt SelectedItem() const; |
|
628 |
|
629 /** |
|
630 * Closes and destroys any current cascade menu and takes focus back. Does |
|
631 * nothing if no cascade menu exists. |
|
632 */ |
|
633 IMPORT_C void CloseCascadeMenu(); |
|
634 |
|
635 /** |
|
636 * Sets the array containing the list of menu items for the current menu |
|
637 * pane. |
|
638 * |
|
639 * @param aItemArray The menu item array for the menu pane. |
|
640 */ |
|
641 IMPORT_C void SetItemArray(CItemArray* aItemArray); |
|
642 |
|
643 /** |
|
644 * Set menu item array ownership. |
|
645 * |
|
646 * @param aOwnedExternally If @c ETrue the menu pane's menu item array is |
|
647 * set as externally owned. If @c EFalse the menu pane's menu item |
|
648 * array is set as not externally owned. |
|
649 */ |
|
650 IMPORT_C void SetItemArrayOwnedExternally(TBool aOwnedExternally); |
|
651 |
|
652 /** |
|
653 * Sets the specified button to launch the menu pane. Doesn't have any |
|
654 * effect in current implementation. |
|
655 * |
|
656 * @param aButton The button to set as launching the menu. |
|
657 */ |
|
658 IMPORT_C void SetLaunchingButton(CEikButtonBase* aButton); |
|
659 |
|
660 /** |
|
661 * Moves the menu pane highlight to a newly selected menu item identified |
|
662 * by @c aNewSelectedItem. Scrolls the menu to show the new selected item |
|
663 * if necessary and redraws only the newly selected item and the currently |
|
664 * selected item if possible. |
|
665 * |
|
666 * @param aNewSelectedItem The newly selected menu item index. |
|
667 */ |
|
668 IMPORT_C void MoveHighlightTo(TInt aNewSelectedItem); |
|
669 |
|
670 /** |
|
671 * Gets the number of menu items within the menu pane. |
|
672 * |
|
673 * @return Number of menu items within menu pane. |
|
674 */ |
|
675 IMPORT_C TInt NumberOfItemsInPane() const; |
|
676 |
|
677 /** |
|
678 * Closes the menu pane. |
|
679 */ |
|
680 IMPORT_C void Close(); |
|
681 |
|
682 /** |
|
683 * From @ CCoeControl |
|
684 * |
|
685 * Handles key events offered to the menu by the control environment. |
|
686 * |
|
687 * @since Platform 004. |
|
688 * @param aKeyEvent The key event. |
|
689 * @param aType The type of key event: @c EEventKey, @c EEventKeyUp or @c |
|
690 * EEventKeyDown. |
|
691 * @param aConsumeAllKeys If @c ETrue this function returns @c |
|
692 * EKeyWasConsumed regardless of whether it was used. If @c EFalse |
|
693 * the key event is consumed if possible and either @c |
|
694 * EKeyWasConsumed or @c EKeyWasNotConsumed is returned as |
|
695 * appropriate. |
|
696 */ |
|
697 IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, |
|
698 TEventCode aType, |
|
699 TBool aConsumeAllKeys); // not available before Platform 004 |
|
700 |
|
701 /** |
|
702 * Sets whether the scroll bar occupies the left side of the menu pane. |
|
703 * |
|
704 * @param aOnLeft If @c ETrue the scroll bar will occupy the left side of |
|
705 * the menu pane. |
|
706 */ |
|
707 IMPORT_C void SetScrollBarOnLeft(TBool aOnLeft); |
|
708 |
|
709 /** |
|
710 * Sets whether the menu pane uses an arrow head scroll bar. |
|
711 * |
|
712 * @param aArrowHead If @c ETrue the menu pane uses an arrow head scroll |
|
713 * bar. |
|
714 */ |
|
715 IMPORT_C void SetArrowHeadScrollBar(TBool aArrowHead); |
|
716 |
|
717 // new for AVKON |
|
718 |
|
719 /** |
|
720 * Moves highlight to the next item or to the first one if last item is |
|
721 * selected. |
|
722 */ |
|
723 IMPORT_C void NavigateToNextItem(); |
|
724 |
|
725 /** |
|
726 * Inserts the menu item to the specified position. |
|
727 * |
|
728 * @param aMenuItem The menu item to add. NOTICE @c SData is the structure |
|
729 * and all fileds should be initialized. |
|
730 * @param aPosition The position of newly created item in the array. |
|
731 */ |
|
732 IMPORT_C void InsertMenuItemL(const CEikMenuPaneItem::SData& aMenuItem, |
|
733 TInt aPosition); |
|
734 |
|
735 /** |
|
736 * Checks whether menu pane contains the menu item and returns position of |
|
737 * it if the item is found. |
|
738 * |
|
739 * @param[in] aCommandId The command ID of the item to be searched for. |
|
740 * @param[out] aPosition On return contains position of the item. |
|
741 * @return @c ETrue if item was found. Otherwise @c EFalse. |
|
742 */ |
|
743 IMPORT_C TBool MenuItemExists(TInt aCommandId, |
|
744 TInt& aPosition); |
|
745 |
|
746 /** |
|
747 * Checks whether the menu pane is a cascade menu or a main menu. |
|
748 * |
|
749 * @return @c ETrue if the menu pane is cascade menu and @c EFalse if the |
|
750 * menu pane is the main menu. |
|
751 */ |
|
752 IMPORT_C TBool IsCascadeMenuPane() const; |
|
753 |
|
754 /** |
|
755 * Enables or disables text scrolling functionality. It is disabled by |
|
756 * default. |
|
757 * |
|
758 * @param aEnable @c ETrue to enable text scrolling functionality. |
|
759 */ |
|
760 IMPORT_C void EnableMarqueeL(const TBool aEnable); |
|
761 |
|
762 /** |
|
763 * Report that selection was done for the currently highlighted item. |
|
764 */ |
|
765 void ActivateCurrentItemL(); |
|
766 |
|
767 /** |
|
768 * Closes cascade menu if there is one and it is active. |
|
769 */ |
|
770 TBool CancelActiveMenuPane(); |
|
771 |
|
772 /** |
|
773 * Deletes dimmed items from the menu item array. |
|
774 */ |
|
775 void FilterDimmedItems(); |
|
776 |
|
777 /** |
|
778 * Not implemented. |
|
779 * |
|
780 * @param aWidth Not used. |
|
781 */ |
|
782 void ClipMenuItems(TInt aWidth); |
|
783 |
|
784 /** |
|
785 * Gets the menu pane for the cascade menu. |
|
786 * |
|
787 * @return The menu pane for the cascade menu. |
|
788 */ |
|
789 IMPORT_C CEikMenuPane* CascadeMenuPane(); |
|
790 |
|
791 /** |
|
792 * Gets a reference to the data in the specified menu item. |
|
793 * |
|
794 * @since S60 3.1 |
|
795 * @param aItemIndex The index of the item in the items array. |
|
796 * @return The menu item's data. |
|
797 * @leave KErrArgument Wrong @aItemIndex. |
|
798 */ |
|
799 IMPORT_C CEikMenuPaneItem::SData& ItemDataByIndexL(TInt aItemIndex); |
|
800 |
|
801 /** |
|
802 * Checks if the position of the menu was set from outside. |
|
803 * |
|
804 * @since S60 3.1 |
|
805 * @return @c ETrue in case when position of the menu was set from outside. |
|
806 */ |
|
807 TBool IsPositionToBeForced() const; |
|
808 |
|
809 /** |
|
810 * Creates and enables a special characters row to be used in the edit |
|
811 * menu. |
|
812 * |
|
813 * @since S60 3.1 |
|
814 * @param aSpecialChars Buffer that holds the selected characters after |
|
815 * user has selected them. |
|
816 */ |
|
817 IMPORT_C void ConstructMenuSctRowL( TDes& aSpecialChars ); |
|
818 |
|
819 /** |
|
820 * Returns the command id of the specified menu item. The function panics |
|
821 * if aIndex doesn't exist or is out of range. |
|
822 * @param aIndex The index of the menu item for which the command ID is returned. |
|
823 * @since 3.1 |
|
824 */ |
|
825 IMPORT_C TInt MenuItemCommandId( TInt aIndex ) const; |
|
826 |
|
827 |
|
828 /** |
|
829 * Creates and enables a special characters row to be used in the edit menu. |
|
830 * The special character row is constructed from the given special character table. |
|
831 * |
|
832 * @param aSpecialChars Buffer that holds the selected characters after |
|
833 * user has selected them. |
|
834 * @param aResourceId The special character table resource id to define the |
|
835 * characters in the row. |
|
836 * |
|
837 * @since S60 3.1 |
|
838 */ |
|
839 IMPORT_C void ConstructMenuSctRowL( TDes& aSpecialChars, TInt aResourceId ); |
|
840 |
|
841 /** |
|
842 * Creates and enables a special characters row to be used in the edit menu. |
|
843 * The special character row is constructed from the given special character dialog. |
|
844 * |
|
845 * @param aSpecialChars Buffer that holds the selected characters after |
|
846 * user has selected them. |
|
847 * @param aResourceId The special character dialog resource id that contains a special character table |
|
848 * |
|
849 * @since S60 3.2 |
|
850 */ |
|
851 IMPORT_C void ConstructMenuSctRowFromDialogL( TDes& aSpecialChars, TInt aResourceId ); |
|
852 |
|
853 /** |
|
854 * Creates and enables a special characters row to be used in the edit menu. |
|
855 * The special character row is constructed from the given special character dialog. |
|
856 * |
|
857 * @param aCharCase the charcase used by menu sct |
|
858 * @param aSpecialChars Buffer that holds the selected characters after |
|
859 * user has selected them. |
|
860 * @param aResourceId The special character dialog resource id that contains a special character table |
|
861 * |
|
862 * @since S60 3.2 |
|
863 */ |
|
864 IMPORT_C void ConstructMenuSctRowFromDialogL( TInt aCharCase, TDes& aSpecialChars, TInt aResourceId ); |
|
865 |
|
866 private: |
|
867 enum { EInvalidCurrentSize=0x01, EBackgroundFaded=0x02 }; |
|
868 |
|
869 private: // new functions |
|
870 TRect CalculateSizeAndPosition() ; |
|
871 enum THighlightType {ENoHighlight,EDrawHighlight,ERemoveHighlight}; |
|
872 void DrawItem(CWindowGc& aGc,TInt aItem, THighlightType aHighlight) const; |
|
873 void FindHotKeyDisplayText(TDes& aDes,const CEikMenuPaneItem& aItem) const; |
|
874 void ReportSelectionMadeL( TBool aAbortTransition = ETrue ); |
|
875 void ReportCanceled(); |
|
876 void GiveVisualFeedback(); |
|
877 void LaunchCascadeMenuL(TInt aCascadeMenuId); |
|
878 void DoLaunchCascadeMenuL(TInt aCascadeMenuId); |
|
879 void TryLaunchCascadeMenuL(const CEikMenuPaneItem& aItem); |
|
880 void PrepareGcForDrawingItems(CGraphicsContext& aGc) const; |
|
881 TBool ItemArrayOwnedExternally() const; |
|
882 TBool IsHotKeyL(const TInt modifiers,const TInt aCode); |
|
883 TBool MoveToItemL(TInt aCode, TInt aModifiers); |
|
884 void HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType); |
|
885 void CreateScrollBarFrame(); |
|
886 void UpdateScrollBar(); |
|
887 void DoUpdateScrollBarL(); |
|
888 void UpdateScrollBarThumbs(); |
|
889 static TInt UpdateScrollBarCallBackL(TAny* aObj); |
|
890 TRect ViewRect() const; |
|
891 // TInt NumberOfItemsThatFitInView() const; |
|
892 TInt TotalItemHeight() const; |
|
893 void ScrollToMakeItemVisible(TInt aItemIndex); |
|
894 void Scroll(TInt aAmount); |
|
895 TBool CheckCreateScroller(); |
|
896 void CheckCreateScrollerL(); |
|
897 void ResetItemArray(); |
|
898 void CreateItemArrayL(); |
|
899 void SetVScrollBarFlag(); |
|
900 TInt TopHighlightGap() const; |
|
901 TInt BottomHighlightGap() const; |
|
902 TInt EvaluateMaxIconWidth() const; |
|
903 void CreateIconFromResourceL(TResourceReader& aReader, CEikMenuPaneItem& aItem) const; |
|
904 // new for AVKON |
|
905 void AnimateMenuPane(const TPoint& aNewPos); |
|
906 |
|
907 // To make layout correct |
|
908 TRect ListMenuPane() const; |
|
909 TRect PopupMenuWindow() const; |
|
910 TRect PopupSubmenuWindow() const; |
|
911 |
|
912 // Skin support for menu |
|
913 void UpdateBackgroundContext(const TRect& aWindowRect); |
|
914 |
|
915 // Support method for highlight animation |
|
916 void RepaintHighlight() const; |
|
917 |
|
918 private: // from CCoeControl |
|
919 IMPORT_C void Reserved_1(); |
|
920 IMPORT_C void Reserved_2(); |
|
921 |
|
922 private : // new functions |
|
923 void LoadCascadeBitmapL() ; |
|
924 |
|
925 // Support for check mark, from v3.0 |
|
926 void LoadCheckMarkBitmapL(); |
|
927 TBool MenuHasCheckBoxOn() const; |
|
928 // Support for radio button, from v3.0 |
|
929 void LoadRadioButtonBitmapL(); |
|
930 TBool IsItemMemberOfRadioButtonGroup(TInt aItem) const ; |
|
931 // for drawing,from v3.0 |
|
932 TBool MenuHasIcon() const; |
|
933 |
|
934 TRect CalculateSizeAndPositionScalable( const TRect& aWindowRect, TInt aNumItemsInPane ) ; |
|
935 TRect HighlightRect() const; |
|
936 void PrepareHighlightFrame() const; |
|
937 void SetCascadedIconSize() const; |
|
938 |
|
939 // fixes marquee flickering |
|
940 friend class CAknMarqueeControl; |
|
941 static TInt RedrawMarqueeEvent( TAny* aControl ); |
|
942 |
|
943 CEikMenuPaneExtension* Extension() const; |
|
944 |
|
945 protected: // from CoeControl |
|
946 |
|
947 /** |
|
948 * From @c CCoeControl. |
|
949 * |
|
950 * Retrieves an object of the same type as that encapsulated in aId. Other |
|
951 * than in the case where @c NULL is returned, the object returned must be |
|
952 * of the same object type - that is, the @c ETypeId member of the object |
|
953 * pointed to by the pointer returned by this function must be equal to the |
|
954 * @c iUid member of @c aId. |
|
955 * |
|
956 * @since SDK 7.0s |
|
957 * @param aId An encapsulated object type ID. |
|
958 * @return Encapsulates the pointer to the object provided. Note that the |
|
959 * encapsulated pointer may be @c NULL. |
|
960 */ |
|
961 IMPORT_C TTypeUid::Ptr MopSupplyObject(TTypeUid aId); |
|
962 |
|
963 public: // From CoeControl. |
|
964 |
|
965 /** |
|
966 * From @c CoeControl. |
|
967 * |
|
968 * Gets the number of controls contained in a compound control. This |
|
969 * function should be implemented by all compound controls. |
|
970 * |
|
971 * Note: |
|
972 * In SDK 6.1 this was changed from protected to public. |
|
973 * |
|
974 * @return The number of component controls contained by this control. |
|
975 */ |
|
976 IMPORT_C TInt CountComponentControls() const; |
|
977 |
|
978 /** |
|
979 * From @c CoeControl. |
|
980 * |
|
981 * Gets the specified component of a compound control. This function shouldŽ |
|
982 * be implemented by all compound controls. |
|
983 * |
|
984 * Note: |
|
985 * Within a compound control, each component control is identified by an |
|
986 * index, where the index depends on the order the controls were added: the |
|
987 * first is given an index of 0, the next an index of 1, and so on. |
|
988 * |
|
989 * @param[in, out] aIndex The index of the control to get. |
|
990 * @return The component control with an index of @c aIndex. |
|
991 */ |
|
992 IMPORT_C CCoeControl* ComponentControl(TInt aIndex) const; |
|
993 |
|
994 protected: // new functions |
|
995 |
|
996 /** |
|
997 * Disables sliding effect |
|
998 * By default is enabled if there is enough memory. |
|
999 * |
|
1000 * @since 3.1 |
|
1001 */ |
|
1002 void DisableAnimation(); |
|
1003 |
|
1004 /** |
|
1005 * The position of the menu will be changed according to the one |
|
1006 * which is specified by arguments in StartDisplayingMenuPane() |
|
1007 * By default those arguments are not used. |
|
1008 * |
|
1009 * @since 3.1 |
|
1010 * @param aForced @c Etrue if arguments are used. |
|
1011 */ |
|
1012 void SetPositionToBeForced(TBool aForced); |
|
1013 |
|
1014 /** |
|
1015 * Gets the maximum number of items which can be seen simultaneously. |
|
1016 * |
|
1017 * @return The maximum number of items which can be seen simultaneously. |
|
1018 */ |
|
1019 TInt NumberOfItemsThatFitInView() const; |
|
1020 |
|
1021 void DrawNow(); |
|
1022 |
|
1023 private: // data |
|
1024 friend class CEikMenuButton; |
|
1025 MEikMenuObserver* iMenuObserver; |
|
1026 MEikMenuObserver* iEditMenuObserver; |
|
1027 CEikMenuPane* iCascadeMenuPane; |
|
1028 const CEikMenuPaneTitle* iMenuPaneTitle; |
|
1029 const CEikHotKeyTable* iHotKeyTable; |
|
1030 CEikMenuPane* iOwner; |
|
1031 CItemArray* iItemArray; |
|
1032 TBool iArrayOwnedExternally; |
|
1033 TBool iAllowPointerUpEvents; |
|
1034 TInt iNumberOfDragEvents; |
|
1035 TInt iSelectedItem; |
|
1036 TInt iItemHeight; |
|
1037 TInt iBaseLine; |
|
1038 TInt iHotkeyColWidth; |
|
1039 TInt iFlags; |
|
1040 CEikScrollBarFrame* iSBFrame; |
|
1041 CMenuScroller* iScroller; |
|
1042 CEikButtonBase* iLaunchingButton; // for popouts only |
|
1043 TInt iSubPopupWidth; // 0..2 |
|
1044 TBool iEnableAnimation; |
|
1045 CEikMenuPaneExtension* iExtension ; // iSpare used for extension class pointer. |
|
1046 |
|
1047 }; |
|
1048 |
|
1049 #endif |
|
1050 |