1.1 --- a/epoc32/include/mw/akntoolbarextension.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/mw/akntoolbarextension.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,277 @@
1.4 -akntoolbarextension.h
1.5 +/*
1.6 +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
1.7 +* All rights reserved.
1.8 +* This component and the accompanying materials are made available
1.9 +* 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
1.10 +* which accompanies this distribution, and is available
1.11 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.12 +*
1.13 +* Initial Contributors:
1.14 +* Nokia Corporation - initial contribution.
1.15 +*
1.16 +* Contributors:
1.17 +*
1.18 +* Description: Toolbar extension component
1.19 +*
1.20 +*/
1.21 +
1.22 +
1.23 +#ifndef CAKNTOOLBAREXTENSION_H
1.24 +#define CAKNTOOLBAREXTENSION_H
1.25 +
1.26 +#include <aknbutton.h>
1.27 +
1.28 +class CAknToolbarItem;
1.29 +class CAknToolbarExtensionView;
1.30 +class CAknToolbar;
1.31 +
1.32 +
1.33 +/**
1.34 + * Toolbar extension.
1.35 + *
1.36 + * Toolbar extension component. Opens an extension view when this extension
1.37 + * is pressed.
1.38 + *
1.39 + * @lib eikcoctl
1.40 + * @since S60 v5.0
1.41 + */
1.42 +NONSHARABLE_CLASS( CAknToolbarExtension ) : public CAknButton,
1.43 + public MCoeControlObserver
1.44 + {
1.45 +
1.46 +public:
1.47 +
1.48 + /**
1.49 + * Creates toolbar extension
1.50 + *
1.51 + * @return extension
1.52 + */
1.53 + static CAknToolbarExtension* NewL( );
1.54 +
1.55 +
1.56 + /**
1.57 + * Creates toolbar extension
1.58 + *
1.59 + * @param aResourceid The ID for this component's resource
1.60 + * @return extension
1.61 + */
1.62 + IMPORT_C static CAknToolbarExtension* NewL( TInt aResourceId );
1.63 +
1.64 +
1.65 + /**
1.66 + * Creates toolbar extension
1.67 + *
1.68 + * @param aResourceid The ID for this component's resource
1.69 + * @return extension
1.70 + */
1.71 + IMPORT_C static CAknToolbarExtension* NewLC( TInt aResourceId );
1.72 +
1.73 + /**
1.74 + * Destructor
1.75 + */
1.76 + ~CAknToolbarExtension();
1.77 +
1.78 +// from base class CCoeControl
1.79 +
1.80 + /**
1.81 + * From CAknButton
1.82 + * constructs the extension from resource
1.83 + *
1.84 + * @param aReader resource reader
1.85 + */
1.86 + void ConstructFromResourceL( TResourceReader& aReader );
1.87 +
1.88 + /**
1.89 + * From CCoeControl
1.90 + *
1.91 + * @param aKeyEvent information about the key event
1.92 + * @param aType type of the key event
1.93 + * @return boolean indicating if key event was consumed or not
1.94 + */
1.95 + TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
1.96 +
1.97 + /**
1.98 + * From CCoeControl
1.99 + * Handles resource changes
1.100 + *
1.101 + * @param aType the type of the resource change
1.102 + */
1.103 + void HandleResourceChange( TInt aType );
1.104 +
1.105 + /**
1.106 + * From CCoeControl.
1.107 + * Makes extension and extension view visible or hides them
1.108 + *
1.109 + * @param aVisible boolean to tell if showing or hiding
1.110 + */
1.111 + void MakeVisible( TBool aVisible );
1.112 +
1.113 +
1.114 +// from base class MCoeControlObserver
1.115 +
1.116 + /**
1.117 + * From MCoeControlObserver.
1.118 + * Here the events from the extension itself and extension view components
1.119 + * are handled
1.120 + *
1.121 + * @param aControl control that sent this event
1.122 + * @param aEventType type of the event
1.123 + */
1.124 + void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType );
1.125 +
1.126 +
1.127 +// new functions
1.128 +
1.129 + /**
1.130 + * Using this the extension view can get extension position in fixed toolbar
1.131 + *
1.132 + * @return index of the position
1.133 + */
1.134 + TInt ExtensionPosition();
1.135 +
1.136 + /**
1.137 + * Creates idle if it does not exist yet and calls it by giving
1.138 + * a callback for notifying when ready to draw extension view.
1.139 + */
1.140 + void ShowViewViaIdle();
1.141 +
1.142 + /**
1.143 + * Callback to get notified when ready to show extension view again
1.144 + * @param aThis pointer to this object
1.145 + * @return error code
1.146 + */
1.147 + static TInt ShowView( TAny* aThis );
1.148 +
1.149 + /**
1.150 + * Extension view tells extension to change state using this method. This is
1.151 + * used when tapping outside extension view.
1.152 + */
1.153 + void ViewClosed();
1.154 +
1.155 + /**
1.156 + * Gets a pointer to the specified control.
1.157 + *
1.158 + * @param aControlId The ID of the control for which a pointer is required.
1.159 + * @return Pointer to the control with the specified ID.
1.160 + */
1.161 + IMPORT_C CCoeControl* ControlOrNull( TInt aCommandId ) const;
1.162 +
1.163 + /**
1.164 + * Adds one item to the specified place. Takes ownership. Leaves with
1.165 + * value KErrNotSupported, if called when extension view is shown and
1.166 + * with KErrArgument if aItem does not exist or aIndex is out of bound.
1.167 + *
1.168 + * @param aItem The control.
1.169 + * @param aType The type of the new toolbar item.
1.170 + * @param aCommandId The command ID for this item.
1.171 + * @param aFlags The flags.
1.172 + * @param aIndex The index in array at which item should be added.
1.173 + */
1.174 + IMPORT_C void AddItemL( CCoeControl* aItem,
1.175 + TInt aType,
1.176 + TInt aCommandId,
1.177 + TInt aFlags,
1.178 + TInt aIndex );
1.179 +
1.180 +
1.181 + /**
1.182 + * Removes one item from the extension view. Leaves with value
1.183 + * KErrNotSupported if called when extension view is shown.
1.184 + *
1.185 + * @param aCommandId The ID of the item which should be removed.
1.186 + */
1.187 + IMPORT_C void RemoveItemL( TInt aCommandId );
1.188 +
1.189 + /**
1.190 + * Gets extension flags
1.191 + *
1.192 + * @return extension flags
1.193 + */
1.194 + TInt ExtensionFlags();
1.195 +
1.196 + /**
1.197 + * Returns boolean indicating if extension view is shown.
1.198 + *
1.199 + * @return ETrue if shown, EFalse if not
1.200 + */
1.201 + IMPORT_C TBool IsShown() const;
1.202 +
1.203 + /**
1.204 + * Shows or hides extension view.
1.205 + *
1.206 + * @param aShown to show or to hide
1.207 + */
1.208 + IMPORT_C void SetShown( TBool aShown );
1.209 +
1.210 + /**
1.211 + * Returns pointer to extension view
1.212 + *
1.213 + * @return pointer to extension view
1.214 + */
1.215 + CCoeControl* ExtensionView();
1.216 +
1.217 + /**
1.218 + * Sets item dimmed or undimmed
1.219 + *
1.220 + * @param aCommandId command id of the item to be dimmed/undimmed
1.221 + * @param aDimmed to dim or undim
1.222 + */
1.223 + IMPORT_C void SetItemDimmed( TInt aCommandId, TBool aDimmed );
1.224 +
1.225 + /**
1.226 + * Hides or unhides item. Leaves with value KErrNotSupported if called
1.227 + * when extension view is shown.
1.228 + *
1.229 + * @param aCommandId command id of the item to be hidden/unhidden
1.230 + * @param aHide to hide or unhide
1.231 + */
1.232 + IMPORT_C void HideItemL( TInt aCommandId, TBool aHide );
1.233 +
1.234 +private:
1.235 +
1.236 + /**
1.237 + * Constructor
1.238 + */
1.239 + CAknToolbarExtension();
1.240 +
1.241 + /**
1.242 + * Constructs the extension button by adding button states with icons
1.243 + */
1.244 + void BaseConstructL();
1.245 +
1.246 + /**
1.247 + * Constructs a control from resource
1.248 + *
1.249 + * @param aResourceId The id for this component's resource.
1.250 + */
1.251 + void ConstructFromResourceL( const TInt aResourceId );
1.252 +
1.253 +private: // data
1.254 +
1.255 + /**
1.256 + * Pointer to extension view.
1.257 + * Own.
1.258 + */
1.259 + CAknToolbarExtensionView* iView;
1.260 +
1.261 + /**
1.262 + * Pointer to toolbar, so that extension can notify toolbar about
1.263 + * extension events
1.264 + * Not own.
1.265 + */
1.266 + CAknToolbar* iToolbar;
1.267 +
1.268 + /**
1.269 + * idle to show extension again on top of other components when
1.270 + * extension is shown when coming back to view.
1.271 + * Own.
1.272 + */
1.273 + CIdle* iIdle;
1.274 +
1.275 + /**
1.276 + * Extension flags
1.277 + */
1.278 + TInt iFlags;
1.279 + };
1.280 +
1.281 +#endif // CAKNTOOLBAREXTENSION_H