2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Toolbar extension component
19 #ifndef CAKNTOOLBAREXTENSION_H
20 #define CAKNTOOLBAREXTENSION_H
22 #include <aknbutton.h>
24 class CAknToolbarItem;
25 class CAknToolbarExtensionView;
32 * Toolbar extension component. Opens an extension view when this extension
38 NONSHARABLE_CLASS( CAknToolbarExtension ) : public CAknButton,
39 public MCoeControlObserver
45 * Creates toolbar extension
49 static CAknToolbarExtension* NewL( );
53 * Creates toolbar extension
55 * @param aResourceid The ID for this component's resource
58 IMPORT_C static CAknToolbarExtension* NewL( TInt aResourceId );
62 * Creates toolbar extension
64 * @param aResourceid The ID for this component's resource
67 IMPORT_C static CAknToolbarExtension* NewLC( TInt aResourceId );
72 ~CAknToolbarExtension();
74 // from base class CCoeControl
78 * constructs the extension from resource
80 * @param aReader resource reader
82 void ConstructFromResourceL( TResourceReader& aReader );
87 * @param aKeyEvent information about the key event
88 * @param aType type of the key event
89 * @return boolean indicating if key event was consumed or not
91 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
95 * Handles resource changes
97 * @param aType the type of the resource change
99 void HandleResourceChange( TInt aType );
103 * Makes extension and extension view visible or hides them
105 * @param aVisible boolean to tell if showing or hiding
107 void MakeVisible( TBool aVisible );
110 // from base class MCoeControlObserver
113 * From MCoeControlObserver.
114 * Here the events from the extension itself and extension view components
117 * @param aControl control that sent this event
118 * @param aEventType type of the event
120 void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType );
126 * Using this the extension view can get extension position in fixed toolbar
128 * @return index of the position
130 TInt ExtensionPosition();
133 * Creates idle if it does not exist yet and calls it by giving
134 * a callback for notifying when ready to draw extension view.
136 void ShowViewViaIdle();
139 * Callback to get notified when ready to show extension view again
140 * @param aThis pointer to this object
143 static TInt ShowView( TAny* aThis );
146 * Extension view tells extension to change state using this method. This is
147 * used when tapping outside extension view.
152 * Gets a pointer to the specified control.
154 * @param aControlId The ID of the control for which a pointer is required.
155 * @return Pointer to the control with the specified ID.
157 IMPORT_C CCoeControl* ControlOrNull( TInt aCommandId ) const;
160 * Adds one item to the specified place. Takes ownership. Leaves with
161 * value KErrNotSupported, if called when extension view is shown and
162 * with KErrArgument if aItem does not exist or aIndex is out of bound.
164 * @param aItem The control.
165 * @param aType The type of the new toolbar item.
166 * @param aCommandId The command ID for this item.
167 * @param aFlags The flags.
168 * @param aIndex The index in array at which item should be added.
170 IMPORT_C void AddItemL( CCoeControl* aItem,
178 * Removes one item from the extension view. Leaves with value
179 * KErrNotSupported if called when extension view is shown.
181 * @param aCommandId The ID of the item which should be removed.
183 IMPORT_C void RemoveItemL( TInt aCommandId );
186 * Gets extension flags
188 * @return extension flags
190 TInt ExtensionFlags();
193 * Returns boolean indicating if extension view is shown.
195 * @return ETrue if shown, EFalse if not
197 IMPORT_C TBool IsShown() const;
200 * Shows or hides extension view.
202 * @param aShown to show or to hide
204 IMPORT_C void SetShown( TBool aShown );
207 * Returns pointer to extension view
209 * @return pointer to extension view
211 CCoeControl* ExtensionView();
214 * Sets item dimmed or undimmed
216 * @param aCommandId command id of the item to be dimmed/undimmed
217 * @param aDimmed to dim or undim
219 IMPORT_C void SetItemDimmed( TInt aCommandId, TBool aDimmed );
222 * Hides or unhides item. Leaves with value KErrNotSupported if called
223 * when extension view is shown.
225 * @param aCommandId command id of the item to be hidden/unhidden
226 * @param aHide to hide or unhide
228 IMPORT_C void HideItemL( TInt aCommandId, TBool aHide );
235 CAknToolbarExtension();
238 * Constructs the extension button by adding button states with icons
240 void BaseConstructL();
243 * Constructs a control from resource
245 * @param aResourceId The id for this component's resource.
247 void ConstructFromResourceL( const TInt aResourceId );
252 * Pointer to extension view.
255 CAknToolbarExtensionView* iView;
258 * Pointer to toolbar, so that extension can notify toolbar about
262 CAknToolbar* iToolbar;
265 * idle to show extension again on top of other components when
266 * extension is shown when coming back to view.
277 #endif // CAKNTOOLBAREXTENSION_H