|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Popup toolbar component |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __AKNTOOLBAR_H__ |
|
21 #define __AKNTOOLBAR_H__ |
|
22 |
|
23 // INCLUDES |
|
24 #include <avkon.hrh> // TAknOrientation |
|
25 #include <AknControl.h> // CCoeControl |
|
26 #include <coecobs.h> // MCoeControlObserver |
|
27 #include <eikcmobs.h> // MEikCommandObserver |
|
28 #include <AknPopupFader.h> |
|
29 #include <babitflags.h> |
|
30 #include <AknsItemID.h> |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CAknButton; |
|
34 class CAknToolbarItem; |
|
35 class CAknToolbarExtension; |
|
36 class MAknToolbarObserver; |
|
37 class CEikButtonGroupContainer; |
|
38 class TAknWindowComponentLayout; |
|
39 class CAknsFrameBackgroundControlContext; |
|
40 class CAknsBasicBackgroundControlContext; |
|
41 |
|
42 |
|
43 // DisableToolbarL leaves with this value if toolbar is shown, since toolbar |
|
44 // should not be shown when disabling/enabling toolbar. |
|
45 const TInt KErrToolbarShown = -101; |
|
46 |
|
47 // CLASS DECLARATION |
|
48 |
|
49 /** |
|
50 * The class to provide toolbar for the application |
|
51 * |
|
52 * @lib eikcoctl.lib |
|
53 * @since Series 60 3.1 |
|
54 */ |
|
55 class CAknToolbar : public CAknControl, public MCoeControlObserver, |
|
56 public MCoeControlBackground, public MEikCommandObserver, |
|
57 public MAknFadedComponent |
|
58 { |
|
59 public: //Enumerations: |
|
60 |
|
61 enum TEventModifiers { |
|
62 ELongPress = 1, |
|
63 ELongPressEnded = 2, |
|
64 }; |
|
65 |
|
66 public: // Constructors and destructor |
|
67 |
|
68 /** |
|
69 * Two-phased constructor. |
|
70 * |
|
71 * @param aResourceId The ID for this component's resource |
|
72 * @return Pointer to the created toolbar object |
|
73 */ |
|
74 IMPORT_C static CAknToolbar* NewL( const TInt aResourceId ); |
|
75 |
|
76 /** |
|
77 * Two-phased constructor. |
|
78 * |
|
79 * @param aResourceId The ID for this component's resource |
|
80 * @return Pointer to the created toolbar object |
|
81 */ |
|
82 IMPORT_C static CAknToolbar* NewLC( const TInt aResourceId ); |
|
83 |
|
84 /** |
|
85 * Destructor |
|
86 */ |
|
87 ~CAknToolbar(); |
|
88 |
|
89 public: // From base class |
|
90 |
|
91 /** |
|
92 * From CCoeControl. |
|
93 * Gets the number of controls contained in a compound control. |
|
94 * |
|
95 * @return The number of component controls contained by this control. |
|
96 */ |
|
97 IMPORT_C TInt CountComponentControls() const; |
|
98 |
|
99 /** |
|
100 * From CCoeControl. |
|
101 * Gets the specified component of a compound control. |
|
102 * |
|
103 * @param aIndex The index of the control to get |
|
104 * @return The component control with an index of aIndex. |
|
105 */ |
|
106 IMPORT_C CCoeControl* ComponentControl( TInt aIndex ) const ; |
|
107 |
|
108 /** |
|
109 * From CCoeControl. |
|
110 * Handles pointer events. |
|
111 * |
|
112 * @param aPointerEvent The pointer event. |
|
113 */ |
|
114 IMPORT_C void HandlePointerEventL( const TPointerEvent& aPointerEvent ); |
|
115 |
|
116 /** |
|
117 * From CCoeControl. |
|
118 * Handles a change to the control's resources. |
|
119 * |
|
120 * @param aType A message UID value. |
|
121 */ |
|
122 IMPORT_C void HandleResourceChange( TInt aType ); |
|
123 |
|
124 /** |
|
125 * From MCoeControlObserver. |
|
126 * Handles an event from an observed toolbar item. |
|
127 * |
|
128 * @param aControl The control which sent the event |
|
129 * @param aEventType The event type |
|
130 */ |
|
131 IMPORT_C void HandleControlEventL( CCoeControl* aControl, |
|
132 TCoeEvent aEventType ); |
|
133 |
|
134 /** |
|
135 * From CCoeControl. |
|
136 * Responds to changes in the position of a toolbar. |
|
137 */ |
|
138 IMPORT_C void PositionChanged(); |
|
139 |
|
140 /** |
|
141 * From MEikCommandObserver. |
|
142 * Processes user commands. |
|
143 * |
|
144 * @param TInt aCommandId ID of the command to respond to. |
|
145 */ |
|
146 IMPORT_C void ProcessCommandL( TInt aCommandId ); |
|
147 |
|
148 /** |
|
149 * From CCoeControl. |
|
150 * Sets toolbar dimmed. Doesn't redraw. |
|
151 * |
|
152 * @param aDimmed is ETrue to dim the toolbar, |
|
153 * EFalse to set the toolbar as not dimmed |
|
154 */ |
|
155 IMPORT_C void SetDimmed( TBool aDimmed ); |
|
156 |
|
157 /** |
|
158 * From CCoeControl. |
|
159 * Handles key events. |
|
160 * |
|
161 * @param aKeyEvent The key event |
|
162 * @param aType The type of key event: EEventKey, EEventKeyUp |
|
163 * or EEventKeyDown. |
|
164 * @return TKeyResponse Indicates whether or not the key event was used |
|
165 * by this control. |
|
166 */ |
|
167 IMPORT_C TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
168 TEventCode aType ); |
|
169 |
|
170 /** |
|
171 * From CCoeControl. |
|
172 * Gets the control's input capabilities. |
|
173 * |
|
174 * @return The control's input capabilities. |
|
175 */ |
|
176 IMPORT_C TCoeInputCapabilities InputCapabilities() const; |
|
177 |
|
178 /** |
|
179 * From MCoeControlBackground. |
|
180 * Draw the background for a given control. |
|
181 * The text drawer that shall be used to draw text on the specific |
|
182 * background can be fetched through the GetTextDrawer() method. |
|
183 * |
|
184 * @param aGc Graphics context used for drawing. |
|
185 * @param aControl The control being drawn (may be a child of the drawer). |
|
186 * @param aRect The area to be redrawn. |
|
187 */ |
|
188 IMPORT_C void Draw( CWindowGc& aGc, |
|
189 const CCoeControl& aControl, |
|
190 const TRect& aRect ) const; |
|
191 |
|
192 public: // New functions |
|
193 |
|
194 /** |
|
195 * Gets a pointer to the specified control. |
|
196 * |
|
197 * @param aControlId The ID of the control for which a pointer is |
|
198 * required. |
|
199 * @return Pointer to the control with the specified ID. |
|
200 */ |
|
201 IMPORT_C CCoeControl* ControlOrNull( const TInt aControlId ) const; |
|
202 |
|
203 /** |
|
204 * Shows or hides toolbar. Position of the top left corner should be set |
|
205 * in advance. Toolbar set visible with this method is by default focusing. |
|
206 * Does nothing if toolbar is disabled. |
|
207 * @param aVisible ETrue to show it, EFalse to hide it. |
|
208 */ |
|
209 IMPORT_C void SetToolbarVisibility( const TBool aVisible ); |
|
210 |
|
211 /** |
|
212 * Shows or hides toolbar. Position of the top left corner should be set |
|
213 * in advance. This overload of the method allows toolbar to be set |
|
214 * non-focusing. Does nothing if toolbar is disabled. |
|
215 * @param aVisible ETrue to show it, EFalse to hide it. |
|
216 * @param aFocusing ETrue to set toolbar focusing, otherwise EFalse. |
|
217 */ |
|
218 IMPORT_C void SetToolbarVisibility( const TBool aVisible, |
|
219 const TBool aFocusing ); |
|
220 |
|
221 /** |
|
222 * Dims (greys out) or undims a toolbar item. |
|
223 * |
|
224 * @param aCommandId The command (as defined in an .hrh file) |
|
225 * associated with this toolbar item. This identifies the toolbar |
|
226 * item, whose text is to be dimmed or un-dimmed. |
|
227 * @param aDimmed Use ETrue to dim this toolbar item or EFalse to |
|
228 * un-dim this toolbar item. |
|
229 * @param aDrawNow Should be ETrue for the item to be redrawn. |
|
230 */ |
|
231 IMPORT_C void SetItemDimmed( const TInt aCommandId, |
|
232 const TBool aDimmed, |
|
233 const TBool aDrawNow ); |
|
234 |
|
235 /** |
|
236 * Hides or unhides a toolbar item. |
|
237 * |
|
238 * @param aCommandId The command (as defined in an .hrh file) |
|
239 * associated with this toolbar item. This identifies the toolbar |
|
240 * item, which will be set to hidden or unhidden. |
|
241 * @param aHide Use ETrue to hide this toolbar item or EFalse to |
|
242 * unhide this toolbar item. |
|
243 * @param aDrawNow Should be ETrue for the toolbar to be redrawn. |
|
244 */ |
|
245 IMPORT_C void HideItem( const TInt aCommandId, |
|
246 const TBool aHide, |
|
247 const TBool aDrawNow ); |
|
248 |
|
249 /** |
|
250 * Sets the observer for the toolbar. |
|
251 * |
|
252 * @param aObserver A pointer to the observer. Ownership is not changed. |
|
253 */ |
|
254 IMPORT_C void SetToolbarObserver( MAknToolbarObserver* aObserver ); |
|
255 |
|
256 /** |
|
257 * Returns a pointer to the toolbar observer. |
|
258 * |
|
259 * @return Pointer to the toolbar observer. |
|
260 */ |
|
261 IMPORT_C MAknToolbarObserver* ToolbarObserver(); |
|
262 |
|
263 /** |
|
264 * Adds one item to the end of the toolbar. Takes ownership. |
|
265 * Leaves with value KErrNotSupported, if the control type is not |
|
266 * supported by toolbar (see CAknToolbar::IsSupportedItemType()). |
|
267 * |
|
268 * @param aItem The control. |
|
269 * @param aType The type of the new toolbar item. |
|
270 * @param aCommandId The command ID for this item. |
|
271 * @param aFlags The flags. |
|
272 */ |
|
273 IMPORT_C void AddItemL( CCoeControl* aItem, |
|
274 const TInt aType, |
|
275 const TInt aCommandId, |
|
276 const TInt aFlags ); |
|
277 |
|
278 /** |
|
279 * Adds one item to the specified place. Takes ownership. |
|
280 * Leaves with value KErrNotSupported, if the control type is not |
|
281 * supported by toolbar (see CAknToolbar::IsSupportedItemType()). |
|
282 * |
|
283 * @param aItem The control. |
|
284 * @param aType The type of the new toolbar item. |
|
285 * @param aCommandId The command ID for this item. |
|
286 * @param aFlags The flags. |
|
287 * @param aIndex The index in array at which item should be added. |
|
288 */ |
|
289 IMPORT_C void AddItemL( CCoeControl* aItem, |
|
290 const TInt aType, |
|
291 const TInt aCommandId, |
|
292 const TInt aFlags, |
|
293 const TInt aIndex ); |
|
294 |
|
295 /** |
|
296 * Removes one item from the toolbar. |
|
297 * |
|
298 * @param aCommandId The ID of the item which should be removed. |
|
299 */ |
|
300 IMPORT_C void RemoveItem( const TInt aCommandId ); |
|
301 |
|
302 /** |
|
303 * Returns ETrue if the type of the item can be included in the |
|
304 * toolbar. |
|
305 * |
|
306 * @return ETrue for the supported type, otherwise EFalse. |
|
307 */ |
|
308 IMPORT_C TBool IsSupportedItemType( const TInt aType ) const; |
|
309 |
|
310 /** |
|
311 * Changes the command ID for the initially focused item when toolbar is |
|
312 * shown or gain focus. Notice that, if this item is not visible, then |
|
313 * focus will be according default behaviour. Normally, focus will be on |
|
314 * the first item, if KAknToolbarMiddleItemFocused flag was not used. |
|
315 * |
|
316 * @param aCommandId The command ID for the item to get focus. |
|
317 */ |
|
318 IMPORT_C void SetInitialFocusedItem( const TInt aCommandId ); |
|
319 |
|
320 /** |
|
321 * Called by the framework to handle the emphasising or |
|
322 * de-emphasising of a toolbar window when it is needed. |
|
323 * |
|
324 * @param aEmphasis ETrue to emphasize the menu, EFalse otherwise. |
|
325 */ |
|
326 IMPORT_C void SetEmphasis( const TBool aEmphasis ); |
|
327 |
|
328 /** |
|
329 * Returns toolbar visibility at this moment |
|
330 * |
|
331 * @return ETrue, if toolbar is shown. |
|
332 */ |
|
333 IMPORT_C TBool IsShown() const; |
|
334 |
|
335 /** |
|
336 * Specifies whether toolbar should be shown with sliding effect or not. |
|
337 * By default toolbar is shown with sliding. |
|
338 * |
|
339 * @param aSlide ETrue for sliding effect, EFalse without sliding. |
|
340 */ |
|
341 IMPORT_C void SetWithSliding( const TBool aSlide ); |
|
342 |
|
343 /** |
|
344 * Sets whether the toolbar should be closed or remain open after the |
|
345 * specified command is issued from the toolbar. |
|
346 * |
|
347 * @param aCommandId The command. |
|
348 * @param aClose ETrue, if toolbar should be close. |
|
349 */ |
|
350 IMPORT_C void SetCloseOnCommand( const TInt aCommandId, |
|
351 const TBool aClose ); |
|
352 |
|
353 /** |
|
354 * Sets whether the toolbar should be closed after a command is issued |
|
355 * from the toolbar. This method affects every command on the toolbar. |
|
356 * |
|
357 * @param aClose ETrue, if toolbar should be closed. |
|
358 */ |
|
359 IMPORT_C void SetCloseOnAllCommands( const TBool aClose ); |
|
360 |
|
361 /** |
|
362 * Sets toolbar orientation. |
|
363 * |
|
364 * @param aOrientation Orientation that should be used for toolbar. |
|
365 * @since 3.2 |
|
366 */ |
|
367 IMPORT_C void SetOrientation( const TAknOrientation aOrientation ); |
|
368 |
|
369 /** |
|
370 * Updates transparent toolbar's background. |
|
371 * @since 3.2 |
|
372 */ |
|
373 IMPORT_C void UpdateBackground(); |
|
374 |
|
375 /** |
|
376 * Shows toolbar again after it has been hidden for background changing |
|
377 * purposes |
|
378 * |
|
379 * @since 3.2 |
|
380 */ |
|
381 void ShowToolbarForBackgroundUpdate(); |
|
382 |
|
383 /** |
|
384 * Disables/Enables toolbar so that it cannot/can be activated from e.g. |
|
385 * touch pane. Needed especially if a dialog is on the screen and |
|
386 * toolbar is not wished to be shown. Leaves with value KErrToolbarShown |
|
387 * if called when toolbar is shown. |
|
388 * |
|
389 * @param aDisable ETrue if toolbar should be disabled |
|
390 * |
|
391 * @since S60 3.2 |
|
392 */ |
|
393 IMPORT_C void DisableToolbarL( TBool aDisable ); |
|
394 |
|
395 /** |
|
396 * Checks if toolbar is disabled. |
|
397 * |
|
398 * @return ETrue if toolbar is disabled, EFalse if not |
|
399 * |
|
400 * @since S60 3.2 |
|
401 */ |
|
402 IMPORT_C TBool IsToolbarDisabled() const; |
|
403 |
|
404 /** |
|
405 * Moves highlight from one item to another. Leaves with |
|
406 * value KErrNotFound if item not found. |
|
407 * |
|
408 * @param aCommandId command id of the item to be focused. |
|
409 * |
|
410 * @since S60 3.2 |
|
411 */ |
|
412 IMPORT_C void SetFocusedItemL( const TInt aCommandId ); |
|
413 |
|
414 /** |
|
415 * Returns command id of focused item. |
|
416 * |
|
417 * @return command id of focused item. Returns KErrNotFound if |
|
418 * no item is focused. |
|
419 * |
|
420 * @since S60 3.2 |
|
421 */ |
|
422 IMPORT_C TInt FocusedItem() const; |
|
423 |
|
424 /** |
|
425 * Takes focus away from edwin or other controls if needed. Called by |
|
426 * AknAppUi from HandleWsEventL when a pointer event is targeted to |
|
427 * other control than toolbar. |
|
428 * |
|
429 * @since S60 3.2 |
|
430 */ |
|
431 void PrepareForFocusLossL(); |
|
432 |
|
433 /** |
|
434 * Returns event modifiers defined in TEventModifiers in this header. |
|
435 * This can be used by applications in OfferToolbarEventL to know if |
|
436 * the event sent was for example a long press event. Information is |
|
437 * valid only during OfferToolbarEventL. |
|
438 * |
|
439 * @return event modifiers |
|
440 * @since S60 3.2 |
|
441 */ |
|
442 IMPORT_C TInt EventModifiers() const; |
|
443 |
|
444 /** |
|
445 * Returns the flags of toolbar. Flags are defined in eikon.hrh. |
|
446 * @return toolbar flags |
|
447 * @since S60 3.2 |
|
448 */ |
|
449 IMPORT_C TInt ToolbarFlags() const; |
|
450 |
|
451 /* |
|
452 * Count faded components |
|
453 * @return then number of faded components |
|
454 */ |
|
455 TInt CountFadedComponents(); |
|
456 |
|
457 /* |
|
458 * Returns faded components by index |
|
459 * @return faded component |
|
460 */ |
|
461 CCoeControl* FadedComponent( TInt aIndex ); |
|
462 |
|
463 /* |
|
464 * Reduces main pane rect if it intersects with toolbar's rect |
|
465 * @param aBoundingRect the rect to reduce |
|
466 */ |
|
467 void ReduceRect( TRect& aBoundingRect ) const; |
|
468 |
|
469 /** |
|
470 * Sets the resource id for toolbar softkeys. If cba allready exists |
|
471 * then changes the existing softkeys and redraws toolbar cba. |
|
472 * @param aSoftkeyResourceId ID of the resource structure specifying |
|
473 * the command buttons. |
|
474 * @since S60 3.2 |
|
475 */ |
|
476 IMPORT_C void SetSoftkeyResourceIdL( TInt aSoftkeyResourceId ); |
|
477 |
|
478 /** |
|
479 * Extension notifies of its events using this method |
|
480 * aCommandId command id of the button |
|
481 */ |
|
482 void ExtensionEventL( TInt aCommandId ); |
|
483 |
|
484 /** |
|
485 * Returns the index of the toolbar item inside of the iVisibleItems |
|
486 * array. |
|
487 * |
|
488 * @param aControl The control which index is needed. |
|
489 * @return Index of the toolbar item. |
|
490 */ |
|
491 TInt ToolbarVisibleIndexByControl( const CCoeControl* aControl ) const; |
|
492 |
|
493 /** |
|
494 * Returns pointer to toolbar extension if available |
|
495 * @return toolbar extension or NULL |
|
496 */ |
|
497 IMPORT_C CAknToolbarExtension* ToolbarExtension() const; |
|
498 |
|
499 /** |
|
500 * Calls DynInitToolbar with extensions commmand id |
|
501 * |
|
502 */ |
|
503 void DynInitExtensionL( CCoeControl* aControl ); |
|
504 |
|
505 /** |
|
506 * Callback for sliding toolbar. |
|
507 */ |
|
508 static TInt ReadyToSlide( TAny* aThis ); |
|
509 |
|
510 /** |
|
511 * Slide toolbar |
|
512 */ |
|
513 void SlideWithIdle(); |
|
514 |
|
515 /** |
|
516 * Hides/Unhides toolbar items temporarily. When called with ETrue |
|
517 * toolbar draws just background in landscape and is hidden in portrait. |
|
518 * Calling with EFalse returns the situation to normal, so drawing the |
|
519 * items normally in portrait and landscape. Use this method only with |
|
520 * fixed toolbar! |
|
521 * |
|
522 * @param aHide ETrue if hiding items, EFalse if unhiding. |
|
523 */ |
|
524 IMPORT_C void HideItemsAndDrawOnlyBackground( TBool aHide ); |
|
525 |
|
526 /** |
|
527 * Hides/Unhides toolbar items temporarily. When called with ETrue |
|
528 * toolbar draws just background in landscape and is hidden in portrait. |
|
529 * Toolbar window priority is changed to priority passed in parameter. |
|
530 * Priority should be one of the window priority values defined in |
|
531 * TCoeWinPriority. Default priority is ECoeWinPriorityLow. |
|
532 * Note that if toolbar is already hidden, the toolbar window priority |
|
533 * is still changed to priority passed in parameter. |
|
534 * Calling the function HideItemsAndDrawOnlyBackground with EFalse returns |
|
535 * the situation to normal, so drawing the items normally in portrait |
|
536 * and landscape. Use this method only with fixed toolbar! |
|
537 * |
|
538 * @param aHide ETrue if hiding items, EFalse if unhiding. |
|
539 * @param aPriority Ordinal priority of toolbar window. |
|
540 */ |
|
541 IMPORT_C void HideItemsAndDrawOnlyBackground( TBool aHide, TInt aPriority ); |
|
542 /** |
|
543 * Sets the skin background for fixed toolbar. The new background is used |
|
544 * for all the subsequent drawing operations. This method does not itself |
|
545 * cause a repaint. |
|
546 * |
|
547 * @internal |
|
548 * |
|
549 * @param aIID Skin item ID of the new background. This is one of the constants |
|
550 * defined in AknsConstants.h, and the usual values are KAknsIIDQsnBgScreen |
|
551 * @since S60 5.0 |
|
552 */ |
|
553 IMPORT_C void SetSkinBackgroundId( const TAknsItemID& aIID ); |
|
554 |
|
555 |
|
556 protected: // From base class |
|
557 |
|
558 /** |
|
559 * From CCoeControl. |
|
560 * Responds to size changes to sets the size and position of |
|
561 * the contents of this control. |
|
562 */ |
|
563 IMPORT_C void SizeChanged(); |
|
564 |
|
565 /** |
|
566 * From CCoeControl. |
|
567 * This function is called whenever a control gains or loses focus. |
|
568 * |
|
569 * @param aDrawNow Contains the value that was passed to it by SetFocus(). |
|
570 */ |
|
571 IMPORT_C void FocusChanged( TDrawNow aDrawNow ); |
|
572 |
|
573 /** |
|
574 * From CAknControl. |
|
575 * For future extensions. |
|
576 * |
|
577 * @param aInterface The ID for the extension interface. |
|
578 */ |
|
579 IMPORT_C void* ExtensionInterface( TUid aInterface ); |
|
580 |
|
581 /** |
|
582 * From CCoeControl. |
|
583 * Retrieves an object of the same type as that encapsulated in aId. |
|
584 * |
|
585 * @param aId An encapsulated object type ID. |
|
586 * @return Encapsulated pointer to the object provided. |
|
587 * Note that the encapsulated pointer may be NULL. |
|
588 */ |
|
589 IMPORT_C TTypeUid::Ptr MopSupplyObject( TTypeUid aId ); |
|
590 |
|
591 private: // Constructors |
|
592 |
|
593 /** |
|
594 * C++ default constructor. |
|
595 */ |
|
596 CAknToolbar(); |
|
597 |
|
598 /** |
|
599 * Symbian 2nd phase constructor. |
|
600 */ |
|
601 void ConstructL(); |
|
602 |
|
603 private: // From base class |
|
604 |
|
605 /** |
|
606 * From CCoeControl. |
|
607 * Constructs controls from a resource file. |
|
608 * Hides the one defined in base class. |
|
609 * |
|
610 * @param aReader The resource reader with which to access |
|
611 * the control's resource values. |
|
612 */ |
|
613 IMPORT_C void ConstructFromResourceL( TResourceReader& aReader ); |
|
614 |
|
615 /** |
|
616 * From CCoeControl. |
|
617 * Draw a control called by window server. |
|
618 * |
|
619 * @param aRect The region of the control to be redrawn. |
|
620 * Co-ordinates are relative to the control's origin (top left corner). |
|
621 */ |
|
622 IMPORT_C void Draw( const TRect& aRect ) const; |
|
623 |
|
624 private: // New functions |
|
625 |
|
626 /** |
|
627 * Constructs controls from a resource file. |
|
628 * |
|
629 * @param aResourceId The ID for this component's resource. |
|
630 */ |
|
631 void ConstructFromResourceL( const TInt aResourceId ); |
|
632 |
|
633 /** |
|
634 * Constructs one of the toolbar items. |
|
635 * |
|
636 * @param aReader The resource reader with which to access the control's |
|
637 * resource values. |
|
638 * @return Constructed toolbar item. |
|
639 */ |
|
640 CAknToolbarItem* ConstructControlLC( TResourceReader& aReader ); |
|
641 |
|
642 /** |
|
643 * Calculates size and position of the toolbar depending on the |
|
644 * number and size of the toolbar items. |
|
645 * |
|
646 * @return Toolbar rectangular. |
|
647 */ |
|
648 TRect CalculateSizeAndPosition(); |
|
649 |
|
650 /** |
|
651 * Calculates rects that are used in calculating the size |
|
652 * and position of the toolbar items |
|
653 * |
|
654 * @param aMainPaneRect main pane rect |
|
655 * @param aToolbarRect rect for toolbar |
|
656 * @param aGridPaneRect rect for grid pane |
|
657 * @param aCellPaneRect rect for cell pane |
|
658 */ |
|
659 void CalculateRects( TRect& aMainPaneRect, TRect& aToolbarRect, |
|
660 TRect& aGridPaneRect, TRect& aCellPaneRect ); |
|
661 |
|
662 /** |
|
663 * Calculates the position and size of the control rect |
|
664 * |
|
665 * @param aCurrentCellPaneRect current cell pane rect is needed to |
|
666 * get correct control rect from layout data. |
|
667 * @return control rect for the toolbar item |
|
668 */ |
|
669 TRect CalculateControlRect( TRect& aCurrentCellPaneRect ); |
|
670 |
|
671 /** |
|
672 * Checks the number of visible items, and if too few the toolbar CBA is |
|
673 * deleted. If last time there were too few items then toolbar CBA is |
|
674 * created again. Also the ordinal position of the toolbar is set if |
|
675 * there are changes to previous situation. |
|
676 * |
|
677 * @return ETrue if too few items are visible, EFalse if not |
|
678 */ |
|
679 TBool TooFewItemsVisible(); |
|
680 |
|
681 /** |
|
682 * Returns toolbar item object for the specified control. |
|
683 * |
|
684 * @param aControl Pointer to the control. |
|
685 * @return Pointer to the toolbar item. |
|
686 */ |
|
687 CAknToolbarItem* ToolbarItemByControl( const CCoeControl* aControl ) const; |
|
688 |
|
689 /** |
|
690 * Returns toolbar item object for the specified command ID. |
|
691 * |
|
692 * @param aId The command ID of the item. |
|
693 * @return Pointer to the toolbar item. |
|
694 */ |
|
695 CAknToolbarItem* ToolbarItemById( const TInt aId ) const; |
|
696 |
|
697 /** |
|
698 * Returns the index of the toolbar item inside of the iItems array. |
|
699 * |
|
700 * @param aId The command ID of the item |
|
701 * @return Index of the toolbar item. |
|
702 */ |
|
703 TInt ToolbarItemIndexById( const TInt aId ) const; |
|
704 |
|
705 /** |
|
706 * Returns the index of the toolbar item inside of the iItems array. |
|
707 * |
|
708 * @param aControl The control which index is needed. |
|
709 * @return Index of the toolbar item. |
|
710 */ |
|
711 TInt ToolbarItemIndexByControl( const CCoeControl* aControl ) const; |
|
712 |
|
713 /** |
|
714 * Returns the index of the toolbar item inside of the iVisibleItems |
|
715 * array. |
|
716 * |
|
717 * @param aId The command ID of the item. |
|
718 * @return Index of the toolbar item. |
|
719 */ |
|
720 TInt ToolbarVisibleIndexById( const TInt aId ) const; |
|
721 |
|
722 /** |
|
723 * Draws toolbar with sliding effect. |
|
724 * |
|
725 * @param aEndPos The position of the top left corner of toolbar at |
|
726 * the end of animation. |
|
727 */ |
|
728 void SlideToolbar( const TPoint& aEndPos ); |
|
729 |
|
730 /** |
|
731 * Changes CBA text if all items are dimmed. |
|
732 */ |
|
733 void SetRightCbaTextL(); |
|
734 |
|
735 /** |
|
736 * Returns next non-dimmed and non-hidden control index. |
|
737 * |
|
738 * @param aStartIndex The index of the item from which the search |
|
739 * should be started. |
|
740 * @param aMoveForward ETrue if search is done from lower index to |
|
741 * the higher one. |
|
742 * @return The index of next non-dimmed and non-hidden item. |
|
743 */ |
|
744 TInt GetNextSelectableItemIndex( TInt aStartIndex, |
|
745 TBool aMoveForward ); |
|
746 |
|
747 /** |
|
748 * Moves highlight from one item to another. It also will change |
|
749 * softkey text for the focused toolbar. |
|
750 * |
|
751 * @param aItemIndex The index for the newly focused item. |
|
752 * @param aDrawNow Specifies whether the item should be redrawn. |
|
753 * @param aMoveForward Specifies whether the next item in the array |
|
754 * should be selected when the item with aItemIndex is dimmed. |
|
755 * @param aPrepareControl Specifies whether PrepareForFocusLossL() or |
|
756 * PrepareForFocusGainL() functions should be called. |
|
757 */ |
|
758 void MoveHighlightL( TInt aItemIndex, |
|
759 const TBool aDrawNow, |
|
760 const TBool aMoveForward = ETrue, |
|
761 const TBool aPrepareControl = ETrue ); |
|
762 |
|
763 /** |
|
764 * Makes toolbar visible and activates it. Position of the top left |
|
765 * corner should be set in advance. Also use SetFocus() to specify |
|
766 * whether toolbar gets key events or not. |
|
767 */ |
|
768 void ShowToolbarL(); |
|
769 |
|
770 /** |
|
771 * Hides toolbar. |
|
772 */ |
|
773 void HideToolbarL(); |
|
774 |
|
775 /** |
|
776 * Sets the focus to the middle or the first item, depending on the |
|
777 * toolbar flags. |
|
778 * |
|
779 * @param aDrawNow if the newly focused item should be redrawn. |
|
780 */ |
|
781 void InitFocusedItemL( const TBool aDrawNow ); |
|
782 |
|
783 /** |
|
784 * Sets the flag to be on or off and also calls |
|
785 * CCoeControl::MakeVisible(). |
|
786 */ |
|
787 void SetShown( const TBool aShown ); |
|
788 |
|
789 /** |
|
790 * Selects/deselects the toolbar item at given index. |
|
791 */ |
|
792 void SelectItemL( const TInt aIndex, const TBool aSelect ); |
|
793 |
|
794 /** |
|
795 * Gets rect from layout data. |
|
796 */ |
|
797 TRect RectFromLayout( const TRect& aParent, |
|
798 const TAknWindowComponentLayout& aComponentLayout ) const; |
|
799 |
|
800 /** |
|
801 * Callback to get notified when ready to show toolbar again |
|
802 */ |
|
803 static TInt WaitForScreenSwitch(TAny* aThis); |
|
804 |
|
805 /** |
|
806 * Hides toolbar so that screen capture can be taken from the |
|
807 * background in order to update it. |
|
808 */ |
|
809 void HideToolbarForBackgroundUpdate(); |
|
810 |
|
811 /** |
|
812 * Updates control positions so that tooltips are positioned correctly |
|
813 */ |
|
814 void UpdateControlPositions(); |
|
815 |
|
816 /** |
|
817 * Shows toolbar via CIdle. As a result, toolbar's window priority is |
|
818 * setted after the application's container window. This places toolbar |
|
819 * to the right place in the window tree. |
|
820 */ |
|
821 void ShowViaIdle(); |
|
822 |
|
823 /** |
|
824 * Callback for delayed toolbar showing. |
|
825 */ |
|
826 static TInt ShowDelayedToolbar( TAny* aThis ); |
|
827 |
|
828 |
|
829 /** |
|
830 * Fades behind toolbar |
|
831 * @param aFade if ETrue then fade |
|
832 */ |
|
833 void FadeBehindPopup( TBool aFade ); |
|
834 |
|
835 /** |
|
836 * Sets buttons to check their touchable areas when tapped |
|
837 */ |
|
838 void CheckHitAreas( ); |
|
839 |
|
840 /** |
|
841 * Counts buttons of fixed tool bar and adds button(s) if needed |
|
842 * There has to bee at leas three buttons in fixed toolbar. |
|
843 */ |
|
844 void CheckFixedToolbarButtonsL(); |
|
845 |
|
846 /** |
|
847 * Draws backgrounds of fixed toolbar |
|
848 * @param aGc Graphics context used for drawing. |
|
849 * @param aControl The control being drawn (may be a child of the drawer). |
|
850 * @param aRect The area to be drawn. |
|
851 */ |
|
852 void DrawFixedBackgroundL( CWindowGc& aGc, |
|
853 const CCoeControl& aControl, |
|
854 const TRect& aRect ) const; |
|
855 |
|
856 /** |
|
857 * Adjusts button's properties depending on the toolbar's features. |
|
858 */ |
|
859 void AdjustButton( CAknButton& aButton ); |
|
860 |
|
861 /** |
|
862 * Adjusts all buttons' properties depending on the toolbar's features. |
|
863 */ |
|
864 void AdjustAllButtons(); |
|
865 |
|
866 /** |
|
867 * Adjusts toolbar's and overlying dialog's window positions so that |
|
868 * dialog is displayed on top of the toolbar. |
|
869 */ |
|
870 void SetOrdinalPositions() const; |
|
871 |
|
872 /** |
|
873 * Updates control visibility based on toolbar visibility and |
|
874 * buttons visibility inside toolbar. |
|
875 */ |
|
876 void UpdateControlVisibility(); |
|
877 |
|
878 /* |
|
879 * Update item tooltip position |
|
880 */ |
|
881 void UpdateItemTooltipPosition(); |
|
882 |
|
883 private: // Member variables |
|
884 |
|
885 // Array for toolbar items |
|
886 RPointerArray<CAknToolbarItem> iItems; |
|
887 |
|
888 // Array for visible toolbar items |
|
889 RPointerArray<CAknToolbarItem> iVisibleItems; |
|
890 |
|
891 // Toolbar flags |
|
892 TInt iFlags; |
|
893 |
|
894 // Observer to report toolbar item events, not owned |
|
895 MAknToolbarObserver* iToolbarObserver; |
|
896 |
|
897 // Index of focused item, used with focusable toolbar |
|
898 TInt iFocusedItem; |
|
899 |
|
900 // Index of selected item, used with focusable and non-focusable toolbar |
|
901 TInt iSelectedItem; |
|
902 |
|
903 // Toolbar cba, used with focusable toolbar |
|
904 // own |
|
905 CEikButtonGroupContainer* iToolbarCba; |
|
906 |
|
907 // Resource id for toolbar |
|
908 TInt iToolbarResourceId; |
|
909 |
|
910 // The default focused item |
|
911 TInt iInitialFocusedItem; |
|
912 |
|
913 // Last focused item before focus was lost |
|
914 TInt iLastFocusedItem; |
|
915 |
|
916 // Toolbar frame context |
|
917 // own |
|
918 CAknsFrameBackgroundControlContext* iFrameContext; |
|
919 |
|
920 // Toolbar background context |
|
921 // own |
|
922 CAknsBasicBackgroundControlContext* iBgContext; |
|
923 |
|
924 // Toolbar orientation |
|
925 TAknOrientation iOrientation; |
|
926 |
|
927 // Transparency bitmap |
|
928 // own |
|
929 // this member variable is deserted |
|
930 CFbsBitmap* iBgBitmap; |
|
931 |
|
932 // This is used to call ShowToolbarForBackgroundChange after toolbar has |
|
933 // been hidden |
|
934 // own |
|
935 CIdle* iIdle; |
|
936 |
|
937 // Highlight bitmap |
|
938 // this member variable is deserted |
|
939 CFbsBitmap* iHighlightBitmap; |
|
940 |
|
941 // Highlight mask |
|
942 // this member variable is deserted |
|
943 CFbsBitmap* iHighlightMask; |
|
944 |
|
945 // event modifiers |
|
946 TInt iEventModifiers; |
|
947 |
|
948 // Background fader |
|
949 TAknPopupFader iFader; |
|
950 |
|
951 // Softkey resource |
|
952 TInt iSoftkeyResource; |
|
953 |
|
954 // Used to store previous item that had pointerevents |
|
955 TInt iPreviousItem; |
|
956 |
|
957 // Item that catches point down event |
|
958 TInt iDownItem; |
|
959 |
|
960 // Step for toolbar sliding |
|
961 TInt iStep; |
|
962 |
|
963 // End position for toolbar sliding |
|
964 TInt iEndPos; |
|
965 |
|
966 // Internal flags used to store toolbar's properties |
|
967 TBitFlags iInternalFlags; |
|
968 |
|
969 // Background area to be drawn when not enough visible items |
|
970 // to cover the toolbar area |
|
971 TRect iBgRect; |
|
972 |
|
973 // Toolbar window priority if set in HideItemsAndDrawOnlyBackground |
|
974 TInt iDrawingPriority; |
|
975 |
|
976 /* |
|
977 * Background theme ID user defined. And in default, its value is |
|
978 * KAknsIIDNone is used and toolbar draw background with the current skin |
|
979 */ |
|
980 TAknsItemID iBgIID; |
|
981 }; |
|
982 |
|
983 #endif // __AKNTOOLBAR_H__ |
|
984 |
|
985 // End of File |