1.1 --- a/epoc32/include/mw/aknbutton.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/mw/aknbutton.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,1496 @@
1.4 -aknbutton.h
1.5 +/*
1.6 +* Copyright (c) 2005-2008 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: Button component.
1.19 +*
1.20 +*/
1.21 +
1.22 +
1.23 +
1.24 +#ifndef __AKNBUTTON_H__
1.25 +#define __AKNBUTTON_H__
1.26 +
1.27 +// INCLUDES
1.28 +#include <akncontrol.h>
1.29 +#include <akniconutils.h>
1.30 +#include <aknutils.h>
1.31 +
1.32 +// FORWARD DECLARATIONS
1.33 +class CGulIcon;
1.34 +class CAknButton;
1.35 +class CAknButtonExtension;
1.36 +class CAknInfoPopupNoteController;
1.37 +class CAknButtonStateExtension;
1.38 +class CAknPictographInterface;
1.39 +class CAknsFrameBackgroundControlContext;
1.40 +class CAknResourceProvider;
1.41 +
1.42 +// CLASS DECLARATION
1.43 +
1.44 +/**
1.45 +* Class which represents one of the button states.
1.46 +*
1.47 +* @lib eikcoctl.lib
1.48 +* @since Series 60 3.1
1.49 +*/
1.50 +class CAknButtonState : public CBase
1.51 + {
1.52 + public: // Constructors and destructors
1.53 +
1.54 + /**
1.55 + * Destructor.
1.56 + */
1.57 + IMPORT_C ~CAknButtonState();
1.58 +
1.59 + protected: // Constructors and destructors
1.60 +
1.61 + /**
1.62 + * Constructor.
1.63 + *
1.64 + * @param aFlags The flags for the button state
1.65 + */
1.66 + IMPORT_C CAknButtonState( const TInt aFlags );
1.67 +
1.68 + /**
1.69 + * Symbian 2nd phase constructor.
1.70 + *
1.71 + * @param aIcon The icon for the normal state. Takes ownership.
1.72 + * @param aDimmedIcon The icon for the dimmed state. Takes ownership.
1.73 + * @param aPressedIcon The icon for the pressed down. Takes ownership.
1.74 + * @param aHoverIcon The icon for the hover state. Takes ownership.
1.75 + * @param aText The text inside the button.
1.76 + * @param aHelpText The text for the tooltip.
1.77 + */
1.78 + IMPORT_C void ConstructL( CGulIcon* aIcon,
1.79 + CGulIcon* aDimmedIcon,
1.80 + CGulIcon* aPressedIcon,
1.81 + CGulIcon* aHoverIcon,
1.82 + const TDesC& aText,
1.83 + const TDesC& aHelpText );
1.84 +
1.85 + /**
1.86 + * Symbian 2nd phase constructor.
1.87 + *
1.88 + * @param aFilePath The path to the file which contains icons.
1.89 + * @param aBmpId The bitmap ID for the normal state icon.
1.90 + * @param aMaskId The mask ID for the normal state icon.
1.91 + * @param aDimmedBmpId The bitmap ID for the dimmed state icon.
1.92 + * @param aDimmedMaskId The mask ID for the dimmed state icon.
1.93 + * @param aPressedBmpId The bitmap ID for the pressed down state.
1.94 + * @param aPressedMaskId The mask ID for the pressed down state.
1.95 + * @param aHoverBmpId The bitmap ID for the hover state icon.
1.96 + * @param aHoverMaskId The mask ID for the hover state icon.
1.97 + * @param aText The text inside the button.
1.98 + * @param aHelpText The text for the tooltip.
1.99 + * @param aId Item ID of the masked bitmap to be created for skin
1.100 + * specific icon.
1.101 + * @param aDimmedId Item ID of the dimmed masked bitmap to be created
1.102 + * for skin specific icon.
1.103 + * @param aPressedId Item ID of the pressed masked bitmap to be created
1.104 + * for skin specific icon.
1.105 + * @param aHoverId Item ID of the masked hover bitmap to be created
1.106 + * for skin specific icon.
1.107 + */
1.108 + IMPORT_C void ConstructL( const TDesC& aFilePath,
1.109 + const TInt aBmpId,
1.110 + const TInt aMaskId,
1.111 + const TInt aDimmedBmpId,
1.112 + const TInt aDimmedMaskId,
1.113 + const TInt aPressedBmpId,
1.114 + const TInt aPressedMaskId,
1.115 + const TInt aHoverBmpId,
1.116 + const TInt aHoverMaskId,
1.117 + const TDesC& aText,
1.118 + const TDesC& aHelpText,
1.119 + const TAknsItemID& aId = KAknsIIDNone,
1.120 + const TAknsItemID& aDimmedId = KAknsIIDNone,
1.121 + const TAknsItemID& aPressedId = KAknsIIDNone,
1.122 + const TAknsItemID& aHoverId = KAknsIIDNone );
1.123 +
1.124 + public: // New functions
1.125 +
1.126 + /**
1.127 + * Provides the icon for the normal state.
1.128 + *
1.129 + * @return The icon for the normal state.
1.130 + */
1.131 + IMPORT_C const CGulIcon* Icon() const;
1.132 +
1.133 + /**
1.134 + * Provides the icon for the dimmed state.
1.135 + *
1.136 + * @return The icon for the dimmed state.
1.137 + */
1.138 + IMPORT_C const CGulIcon* DimmedIcon() const;
1.139 +
1.140 + /**
1.141 + * Provides the icon for the pressed down (not released) state.
1.142 + *
1.143 + * @return The icon for the pressed down (not released) state.
1.144 + */
1.145 + IMPORT_C const CGulIcon* PressedIcon() const;
1.146 +
1.147 + /**
1.148 + * Provides the icon for the hover state.
1.149 + *
1.150 + * @return The icon for the hover state.
1.151 + */
1.152 + IMPORT_C const CGulIcon* HoverIcon() const;
1.153 +
1.154 + /**
1.155 + * Provides the text inside the button.
1.156 + *
1.157 + * @return The button text.
1.158 + */
1.159 + IMPORT_C const TDesC& Text() const;
1.160 +
1.161 + /**
1.162 + * Provides the text inside the help note.
1.163 + *
1.164 + * @return The tooltip text.
1.165 + */
1.166 + IMPORT_C const TDesC& HelpText() const;
1.167 +
1.168 + /**
1.169 + * Provides the flags for the state.
1.170 + *
1.171 + * @return The state flags.
1.172 + */
1.173 + IMPORT_C TInt Flags() const;
1.174 +
1.175 + /**
1.176 + * Sets the icon for the normal state. Takes ownership.
1.177 + *
1.178 + * @param aIcon The icon for the normal state.
1.179 + */
1.180 + IMPORT_C void SetIcon( CGulIcon* aIcon );
1.181 +
1.182 + /**
1.183 + * Sets the icon for the dimmed state. Takes ownership.
1.184 + *
1.185 + * @param aDimmedIcon The icon for the dimmed state.
1.186 + */
1.187 + IMPORT_C void SetDimmedIcon( CGulIcon* aDimmedIcon );
1.188 +
1.189 + /**
1.190 + * Sets the icon for the pressed down state. Takes ownership.
1.191 + *
1.192 + * @param aPressedIcon The icon for the pressed down state.
1.193 + */
1.194 + IMPORT_C void SetPressedIcon( CGulIcon* aPressedIcon );
1.195 +
1.196 + /**
1.197 + * Sets the icon for the hover state. Takes ownership.
1.198 + *
1.199 + * @param aHoverIcon The icon for the hover state.
1.200 + */
1.201 + IMPORT_C void SetHoverIcon( CGulIcon* aHoverIcon );
1.202 +
1.203 + /**
1.204 + * Sets the text inside the button.
1.205 + *
1.206 + * @param aText The text inside the button.
1.207 + */
1.208 + IMPORT_C void SetTextL( const TDesC& aText );
1.209 +
1.210 + /**
1.211 + * Sets the text inside the help note.
1.212 + *
1.213 + * @param aHelpText The text inside the tooltip.
1.214 + */
1.215 + IMPORT_C void SetHelpTextL( const TDesC& aHelpText );
1.216 +
1.217 + /**
1.218 + * Sets the flags for the state.
1.219 + *
1.220 + * @param aFlags The flags for the state.
1.221 + */
1.222 + IMPORT_C void SetFlags( const TInt aFlags );
1.223 +
1.224 + /**
1.225 + * Sets the icon for the normal state
1.226 + *
1.227 + * @param aFlags The flags for the state.
1.228 + */
1.229 + void UpdateIconL( const TDesC& aFilePath,
1.230 + const TInt aBmpId,
1.231 + const TInt aMaskId,
1.232 + const TInt aDimmedBmpId,
1.233 + const TInt aDimmedMaskId,
1.234 + const TInt aPressedBmpId,
1.235 + const TInt aPressedMaskId,
1.236 + const TInt aHoverBmpId,
1.237 + const TInt aHoverMaskId,
1.238 + const TAknsItemID& aId = KAknsIIDNone,
1.239 + const TAknsItemID& aDimmedId = KAknsIIDNone,
1.240 + const TAknsItemID& aPressedId = KAknsIIDNone,
1.241 + const TAknsItemID& aHoverId = KAknsIIDNone );
1.242 +
1.243 +
1.244 +
1.245 + protected: // New functions
1.246 +
1.247 + /**
1.248 + * Constructs controls from a resource file.
1.249 + * @param aReader The resource reader with which to access the
1.250 + * control's resource values.
1.251 + */
1.252 + IMPORT_C virtual void ConstructFromResourceL( TResourceReader& aReader );
1.253 +
1.254 + /**
1.255 + * Updates the size of icons. Called from CAknButton::SizeChanged()
1.256 + * function.
1.257 + *
1.258 + * @param aRect The new rectangle for the icons.
1.259 + * @param aScaleMode The scale mode which was set for the button.
1.260 + */
1.261 + IMPORT_C virtual void SizeChanged( const TRect& aRect,
1.262 + TScaleMode aScaleMode );
1.263 +
1.264 + /**
1.265 + * @return ETrue if the button has valid text (not empty and not space).
1.266 + */
1.267 + IMPORT_C TBool HasText() const;
1.268 +
1.269 + /**
1.270 + * @return ETrue if the button has valid tooltip text (not empty and
1.271 + * not space).
1.272 + */
1.273 + IMPORT_C TBool HasHelp() const;
1.274 +
1.275 + /**
1.276 + * Handles changes in state's environment.
1.277 + *
1.278 + * @since S60 3.2.
1.279 + * @param aType Resource change's type.
1.280 + */
1.281 + void HandleResourceChange( TInt aType );
1.282 +
1.283 + /**
1.284 + * Sets default scaling mode.
1.285 + *
1.286 + * @since S60 3.2
1.287 + * @param aScaleMode Scaling mode.
1.288 + */
1.289 + void SetIconScaleMode( const TScaleMode aScaleMode );
1.290 +
1.291 + private: // new functions
1.292 +
1.293 + /**
1.294 + * Creates one icon based on the specified file path and IDs.
1.295 + *
1.296 + * @param aIcon The icon object which is created and returned.
1.297 + * Will be deleted if it is not NULL on entry.
1.298 + * @param aFilePath The path to the file which contains icons.
1.299 + * @param aBmpId The bitmap ID for the icon.
1.300 + * @param aMaskId The mask ID for the icon.
1.301 + * @param aId Item ID of the masked bitmap to be created for skin
1.302 + * specific icon.
1.303 + */
1.304 + void CreateButtonIconL( CGulIcon*& aIcon, const TDesC& aFilePath,
1.305 + TInt aBmpId, TInt aMaskId,
1.306 + const TAknsItemID& aId = KAknsIIDNone ) const;
1.307 +
1.308 + /**
1.309 + * Loads one icon based on the specified file path and IDs. If the icon
1.310 + * is already loaded it is deleted and replaced with a reloaded copy.
1.311 + *
1.312 + * @since S60 3.2
1.313 + * @param aIcon The icon object which is created and returned.
1.314 + * Will be deleted if it is not NULL on entry.
1.315 + * @param aFilePath The path to the file which contains icons.
1.316 + * @param aBmpId The bitmap ID for the icon.
1.317 + * @param aMaskId The mask ID for the icon.
1.318 + * @param aId Item ID of the masked bitmap to be created for skin
1.319 + * specific icon.
1.320 + */
1.321 + void LoadButtonIcon( CGulIcon*& aIcon ) const;
1.322 +
1.323 + /**
1.324 + * Replaces the given icon with a new one. If the original icon had its
1.325 + * size set then the new icon is scaled to that size.
1.326 + *
1.327 + * @since S60 3.2
1.328 + */
1.329 + void ReplaceIcon( CGulIcon*& aIcon, CGulIcon* aNewIcon );
1.330 +
1.331 + /**
1.332 + * Scales all icons.
1.333 + *
1.334 + * @since S60 3.2
1.335 + * @param aSize New icon size.
1.336 + * @param aScaleMode Scaling mode.
1.337 + * @return KErrNone or an error code.
1.338 + */
1.339 + TInt ScaleIcons( const TSize& aSize, TScaleMode aScaleMode );
1.340 +
1.341 + /**
1.342 + * @return The extension object.
1.343 + */
1.344 + CAknButtonStateExtension* Extension() const;
1.345 +
1.346 + /**
1.347 + * @return The scalemode of the ButtonState
1.348 + */
1.349 + TScaleMode ScaleMode() const;
1.350 +
1.351 + /**
1.352 + * @param aDimmedIconCreatedByButton ETrue, if the dimmed icon of the state is
1.353 + * created by owning Button
1.354 + */
1.355 + void SetGeneratedDimmedIcon( TBool aDimmedIconCreatedByButton );
1.356 +
1.357 + friend class CAknButton;
1.358 +
1.359 + protected: // data
1.360 + CGulIcon* iIcon; // bitmaps for normal state
1.361 + CGulIcon* iDimmedIcon; // bitmaps for dimmed icon
1.362 + CGulIcon* iPressedIcon; // bitmaps for pressed but not activated state
1.363 + CGulIcon* iHoverIcon; // bitmaps for hover icon
1.364 + HBufC* iText; // text for normal state
1.365 + HBufC* iHelpText; // text which is shown as a help
1.366 + TInt iFlags; // flags for the state
1.367 + CAknButtonStateExtension* iExtension; // for future extensions
1.368 + };
1.369 +
1.370 +
1.371 +// CLASS DECLARATION
1.372 +
1.373 +/**
1.374 +* Generic button class.
1.375 +*
1.376 +* @lib eikcoctl.lib
1.377 +* @since Series 60 3.1
1.378 +*/
1.379 +class CAknButton : public CAknControl
1.380 + {
1.381 + public: // Enumerations
1.382 +
1.383 + enum TAlignment
1.384 + {
1.385 + ECenter, /* align center vertically or horizontally */
1.386 + ETop, /* align to top vertically */
1.387 + EBottom, /* align to bottom vertically */
1.388 + ERight, /* align to right horizontally */
1.389 + ELeft /* align to left horixontally */
1.390 + };
1.391 +
1.392 + enum TTooltipPosition
1.393 + {
1.394 + EPositionTop = 1, /* Tool tip alignment vertically to top */
1.395 + EPositionBottom, /* Tool tip alignment vertically to bottom */
1.396 + EPositionLeft, /* Tool tip alignment horizontally to left */
1.397 + EPositionRight /* Tool tip alignment horizontally to right */
1.398 + };
1.399 +
1.400 + enum TTextAndIconAlignment
1.401 + {
1.402 + EIconBeforeText, /* Icon and text side by side Icon first */
1.403 + EIconAfterText, /* Icon and text side by side Text first */
1.404 + EIconUnderText, /* Icon and text one upon the other Icon under the text */
1.405 + EIconOverText, /* Icon and text one upon the other Icon over the text */
1.406 + EOverlay /* Icon and text overlaid */
1.407 + };
1.408 +
1.409 + enum TButtonEvent
1.410 + {
1.411 + ELongPressEvent = 100, /* Observer event for long press event */
1.412 + ELongPressEndedEvent /* Observer event for long press ended event */
1.413 + };
1.414 +
1.415 + public: // Constructors and destructors
1.416 +
1.417 + /**
1.418 + * Two-phased constructor.
1.419 + * Constructs an empty button.
1.420 + */
1.421 + IMPORT_C static CAknButton* NewL();
1.422 +
1.423 + /**
1.424 + * Two-phased constructor. Constructs an empty button.
1.425 + */
1.426 + IMPORT_C static CAknButton* NewLC();
1.427 +
1.428 + /**
1.429 + * Two-phased constructor. Constructs the button from resources.
1.430 + *
1.431 + * @param aReader is the resource reader with which to access
1.432 + * the control's resource values.
1.433 + */
1.434 + IMPORT_C static CAknButton* NewL( TResourceReader& aReader );
1.435 +
1.436 + /**
1.437 + * Two-phased constructor. Constructs the button from resources.
1.438 + *
1.439 + * @param aReader is the resource reader with which to access
1.440 + * the control's resource values.
1.441 + */
1.442 + IMPORT_C static CAknButton* NewLC( TResourceReader& aReader );
1.443 +
1.444 + /**
1.445 + * Two-phased constructor. Constructs the button from resources.
1.446 + *
1.447 + * @param aResourceId is the ID for this component's resource.
1.448 + */
1.449 + IMPORT_C static CAknButton* NewL( const TInt aResourceId );
1.450 +
1.451 + /**
1.452 + * Two-phased constructor. Constructs the button from resources.
1.453 + *
1.454 + * @param aResourceId is the ID for this component's resource.
1.455 + */
1.456 + IMPORT_C static CAknButton* NewLC( const TInt aResourceId );
1.457 +
1.458 + /**
1.459 + * Two-phased constructor. Constructs one state button.
1.460 + *
1.461 + * @param aIcon The icon for the normal state. Takes ownership.
1.462 + * @param aDimmedIcon The icon for the dimmed state. Takes ownership.
1.463 + * @param aPressedIcon The icon for the pressed down. Takes ownership.
1.464 + * @param aHoverIcon The icon for the hover state. Takes ownership.
1.465 + * @param aText The text inside the button.
1.466 + * @param aHelpText The text for the tooltip.
1.467 + * @param aButtonFlags The flags for the button.
1.468 + * @param aStateFlags The flags for the first state.
1.469 + */
1.470 + IMPORT_C static CAknButton* NewL( CGulIcon* aIcon,
1.471 + CGulIcon* aDimmedIcon,
1.472 + CGulIcon* aPressedIcon,
1.473 + CGulIcon* aHoverIcon,
1.474 + const TDesC& aText,
1.475 + const TDesC& aHelpText,
1.476 + const TInt aButtonFlags,
1.477 + const TInt aStateFlags );
1.478 +
1.479 + /**
1.480 + * Two-phased constructor. Constructs one state button.
1.481 + *
1.482 + * @param aIcon The icon for the normal state. Takes ownership.
1.483 + * @param aDimmedIcon The icon for the dimmed state. Takes ownership.
1.484 + * @param aPressedIcon The icon for the pressed down. Takes ownership.
1.485 + * @param aHoverIcon The icon for the hover state. Takes ownership.
1.486 + * @param aText The text inside the button.
1.487 + * @param aHelpText The text for the tooltip.
1.488 + * @param aButtonFlags The flags for the button.
1.489 + * @param aStateFlags The flags for the first state.
1.490 + */
1.491 + IMPORT_C static CAknButton* NewLC( CGulIcon* aIcon,
1.492 + CGulIcon* aDimmedIcon,
1.493 + CGulIcon* aPressedIcon,
1.494 + CGulIcon* aHoverIcon,
1.495 + const TDesC& aText,
1.496 + const TDesC& aHelpText,
1.497 + const TInt aFlags,
1.498 + const TInt aStateFlags );
1.499 +
1.500 + /**
1.501 + * Two-phased constructor. Constructs one state button.
1.502 + *
1.503 + * @param aFilePath The path to the file which contains icons.
1.504 + * @param aBmpId The bitmap ID for the normal state icon.
1.505 + * @param aMaskId The mask ID for the normal state icon.
1.506 + * @param aDimmedBmpId The bitmap ID for the dimmed state icon.
1.507 + * @param aDimmedMaskId The mask ID for the dimmed state icon.
1.508 + * @param aPressedBmpId The bitmap ID for the pressed down state.
1.509 + * @param aPressedMaskId The mask ID for the pressed down state.
1.510 + * @param aHoverBmpId The bitmap ID for the hover state.
1.511 + * @param aHoverMaskId The mask ID for the hover state.
1.512 + * @param aText The text inside the button.
1.513 + * @param aHelpText The text for the tooltip.
1.514 + * @param aButtonFlags The flags for the button.
1.515 + * @param aStateFlags The flags for the first state.
1.516 + * @param aId Item ID of the masked bitmap to be created for skin
1.517 + * specific icon.
1.518 + * @param aDimmedId Item ID of the dimmed masked bitmap to be created
1.519 + * for skin specific icon.
1.520 + * @param aPressedId Item ID of the pressed masked bitmap to be created
1.521 + * for skin specific icon.
1.522 + * @param aHoverId Item ID of the masked hover bitmap to be created
1.523 + * for skin specific icon.
1.524 + */
1.525 + IMPORT_C static CAknButton* NewL( const TDesC& aFilePath,
1.526 + const TInt aBmpId,
1.527 + const TInt aMaskId,
1.528 + const TInt aDimmedBmpId,
1.529 + const TInt aDimmedMaskId,
1.530 + const TInt aPressedBmpId,
1.531 + const TInt aPressedMaskId,
1.532 + const TInt aHoverBmpId,
1.533 + const TInt aHoverMaskId,
1.534 + const TDesC& aText,
1.535 + const TDesC& aHelpText,
1.536 + const TInt aButtonFlags,
1.537 + const TInt aStateFlags,
1.538 + const TAknsItemID& aId = KAknsIIDNone,
1.539 + const TAknsItemID& aDimmedId = KAknsIIDNone,
1.540 + const TAknsItemID& aPressedId = KAknsIIDNone,
1.541 + const TAknsItemID& aHoverId = KAknsIIDNone );
1.542 +
1.543 + /**
1.544 + * Two-phased constructor. Constructs one state button.
1.545 + *
1.546 + * @param aFilePath The path to the file which contains icons.
1.547 + * @param aBmpId The bitmap ID for the normal state icon.
1.548 + * @param aMaskId The mask ID for the normal state icon.
1.549 + * @param aDimmedBmpId The bitmap ID for the dimmed state icon.
1.550 + * @param aDimmedMaskId The mask ID for the dimmed state icon.
1.551 + * @param aPressedBmpId The bitmap ID for the pressed down state.
1.552 + * @param aPressedMaskId The mask ID for the pressed down state.
1.553 + * @param aHoverBmpId The bitmap ID for the hover state.
1.554 + * @param aHoverMaskId The mask ID for the hover state.
1.555 + * @param aText The text inside the button.
1.556 + * @param aHelpText The text for the tooltip.
1.557 + * @param aButtonFlags The flags for the button.
1.558 + * @param aStateFlags The flags for the first state.
1.559 + * @param aId Item ID of the masked bitmap to be created for skin
1.560 + * specific icon.
1.561 + * @param aDimmedId Item ID of the dimmed masked bitmap to be created
1.562 + * for skin specific icon.
1.563 + * @param aPressedId Item ID of the pressed masked bitmap to be created
1.564 + * for skin specific icon.
1.565 + * @param aHoverId Item ID of the hover state masked bitmap to be
1.566 + * created for skin specific icon.
1.567 + */
1.568 + IMPORT_C static CAknButton* NewLC( const TDesC& aFilePath,
1.569 + const TInt aBmpId,
1.570 + const TInt aMaskId,
1.571 + const TInt aDimmedBmpId,
1.572 + const TInt aDimmedMaskId,
1.573 + const TInt aPressedBmpId,
1.574 + const TInt aPressedMaskId,
1.575 + const TInt aHoverBmpId,
1.576 + const TInt aHoverMaskId,
1.577 + const TDesC& aText,
1.578 + const TDesC& aHelpText,
1.579 + const TInt aButtonFlags,
1.580 + const TInt aStateFlags,
1.581 + const TAknsItemID& aId = KAknsIIDNone,
1.582 + const TAknsItemID& aDimmedId = KAknsIIDNone,
1.583 + const TAknsItemID& aPressedId = KAknsIIDNone,
1.584 + const TAknsItemID& aHoverId = KAknsIIDNone );
1.585 +
1.586 + /**
1.587 + * Destructor.
1.588 + */
1.589 + IMPORT_C virtual ~CAknButton();
1.590 +
1.591 + public: // Functions from base class
1.592 +
1.593 + /**
1.594 + * Sets control as ready to be drawn.
1.595 + */
1.596 + IMPORT_C void ActivateL();
1.597 +
1.598 + /**
1.599 + * Constructs controls from a resource file.
1.600 + *
1.601 + * @param aReader The resource reader, with which to access the
1.602 + * control's resource values.
1.603 + */
1.604 + IMPORT_C void ConstructFromResourceL( TResourceReader& aReader );
1.605 +
1.606 + /**
1.607 + * Handles a change to the control's resources.
1.608 + *
1.609 + * @param aType is a message UID value.
1.610 + */
1.611 + IMPORT_C void HandleResourceChange( TInt aType );
1.612 +
1.613 + /**
1.614 + * Returns the control's minimum required size. It does not include the
1.615 + * size of the highlight. However, it includes current margins.
1.616 + * Use HighlightRect() function to get highlight rectangle for the
1.617 + * focused button.
1.618 + *
1.619 + * @return The minimum size required by the control.
1.620 + */
1.621 + IMPORT_C TSize MinimumSize();
1.622 +
1.623 + /**
1.624 + * Sets button dimmed. Does not redraw the button. Note: This function
1.625 + * does not affect the flag set with function CCoeControl::SetDimmed(),
1.626 + * since button needs to get pointer events, even if it is dimmed.
1.627 + * The value of the flag can be enquired using CAknButotn::IsDimmed().
1.628 + *
1.629 + * @param aDimmed is ETrue to dim the button, EFalse to set the button
1.630 + * as not dimmed.
1.631 + */
1.632 + IMPORT_C void SetDimmed( TBool aDimmed );
1.633 +
1.634 + /**
1.635 + * Handles key events.
1.636 + *
1.637 + * @param aKeyEvent The key event.
1.638 + * @param aType The type of key event: EEventKey, EEventKeyUp or
1.639 + * EEventKeyDown.
1.640 + */
1.641 + IMPORT_C TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,
1.642 + TEventCode aType );
1.643 +
1.644 + /**
1.645 + * Sets this control as visible or invisible.
1.646 + *
1.647 + * @param aVisible ETrue to make the control visible, EFalse to make
1.648 + * it invisible.
1.649 + */
1.650 + IMPORT_C void MakeVisible( TBool aVisible );
1.651 +
1.652 + /**
1.653 + * This function is called by the dialog framework immediately before
1.654 + * it removes keyboard focus from a control within a dialog.
1.655 + * Currently has empty implementation.
1.656 + */
1.657 + IMPORT_C void PrepareForFocusLossL();
1.658 +
1.659 + /**
1.660 + * Prepares the control for gaining focus.
1.661 + * Must be used before calling SetFocus() function in case when help
1.662 + * note should be shown.
1.663 + */
1.664 + IMPORT_C void PrepareForFocusGainL();
1.665 +
1.666 + /**
1.667 + * Handles pointer events.
1.668 + *
1.669 + * @param aPointerEvent The pointer event.
1.670 + */
1.671 + IMPORT_C void HandlePointerEventL( const TPointerEvent& aPointerEvent );
1.672 +
1.673 + /**
1.674 + * Responds to changes in the position of a control.
1.675 + */
1.676 + IMPORT_C virtual void PositionChanged();
1.677 +
1.678 + public: // New functions
1.679 +
1.680 + /**
1.681 + * Constructs controls from a resource file.
1.682 + *
1.683 + * @param aResourceId The ID for this component's resource.
1.684 + */
1.685 + IMPORT_C void ConstructFromResourceL( const TInt aResourceId );
1.686 +
1.687 + /**
1.688 + * Sets button state.
1.689 + *
1.690 + * @param aStateIndex The index for the state, starts from 0.
1.691 + * @param aDrawNow ETrue to redraw the button.
1.692 + */
1.693 + IMPORT_C virtual void SetCurrentState( const TInt aStateIndex,
1.694 + const TBool aDrawNow );
1.695 +
1.696 + /**
1.697 + * Adds one more state for the button to the end of state array.
1.698 + *
1.699 + * @param aIcon The icon object containing a bitmap and a mask (if
1.700 + * there is one) for the button.
1.701 + * @param aDimmedIcon The icon object containing a bitmap and a mask
1.702 + * (if there is one) for the dimmed case.
1.703 + * @param aPressedIcon The icon object containing a bitmap and a mask
1.704 + * (if there is one) for the case when button is pressed.
1.705 + * @param aHoverIcon The icon object containingg a bitmap and a mask
1.706 + * for the case when the pointer is hovering over the button.
1.707 + * @param aText is the text.
1.708 + * @param aHelpText is the text for the tooltip.
1.709 + * @param aStateFlags The flags for the state.
1.710 + */
1.711 + IMPORT_C virtual void AddStateL( CGulIcon* aIcon,
1.712 + CGulIcon* aDimmedIcon,
1.713 + CGulIcon* aPressedIcon,
1.714 + CGulIcon* aHoverIcon,
1.715 + const TDesC& aText,
1.716 + const TDesC& aHelpText,
1.717 + const TInt aStateFlags );
1.718 +
1.719 + /**
1.720 + * Adds one more state for the button.
1.721 + *
1.722 + * @param aFilePath The path to the file which contains icons.
1.723 + * @param aBmpId The bitmap ID for the normal state icon.
1.724 + * @param aMaskId The mask ID for the normal state icon.
1.725 + * @param aDimmedBmpId The bitmap ID for the dimmed state icon.
1.726 + * @param aDimmedMaskId The mask ID for the dimmed state icon.
1.727 + * @param aPressedBmpId The bitmap ID for the pressed down state.
1.728 + * @param aPressedMaskId The mask ID for the pressed down state.
1.729 + * @param aHoverBmpId The bitmap ID for the hover state.
1.730 + * @param aHoverMaskId The mask ID for the hover state.
1.731 + * @param aHoverId Item ID of the hover state masked bitmap to be
1.732 + * created for skin specific icon.
1.733 + * @param aText is the text.
1.734 + * @param aHelpText is the text for the tooltip.
1.735 + * @param aStateFlags The flags for the state.
1.736 + * @param aId Item ID of the masked bitmap to be created for skin
1.737 + * specific icon. Use KAknsIIDNone when it is not needed.
1.738 + * @param aDimmedId Item ID of the dimmed masked bitmap to be created
1.739 + * for skin specific icon. Use KAknsIIDNone when it is not needed.
1.740 + * @param aPressedId Item ID of the pressed masked bitmap to be created
1.741 + * for skin specific icon. Use KAknsIIDNone when it is not needed.
1.742 + * @param aHoverId Item ID of the hover state masked bitmap to be
1.743 + * created for skin specific icon.
1.744 + */
1.745 + IMPORT_C virtual void AddStateL( const TDesC& aFilePath,
1.746 + const TInt aBmpId,
1.747 + const TInt aMaskId,
1.748 + const TInt aDimmedBmpId,
1.749 + const TInt aDimmedMaskId,
1.750 + const TInt aPressedBmpId,
1.751 + const TInt aPressedMaskId,
1.752 + const TInt aHoverBmpId,
1.753 + const TInt aHoverMaskId,
1.754 + const TDesC& aText,
1.755 + const TDesC& aHelpText,
1.756 + const TInt aStateFlags,
1.757 + const TAknsItemID& aId,
1.758 + const TAknsItemID& aDimmedId,
1.759 + const TAknsItemID& aPressedId,
1.760 + const TAknsItemID& aHoverId );
1.761 +
1.762 + /**
1.763 + * Adds one more state for the button to the end of state array.
1.764 + *
1.765 + * @param aIcon The icon object containing a bitmap and
1.766 + * a mask (if there is one) for the button.
1.767 + * @param aDimmedIcon The icon object containing a bitmap and a mask
1.768 + * (if there is one) for the dimmed case.
1.769 + * @param aPressedIcon The icon object containing a bitmap and a mask
1.770 + * (if there is one) for the case when
1.771 + * button is pressed.
1.772 + * @param aHoverIcon The icon object containingg a bitmap and
1.773 + * a mask for the case when the pointer is
1.774 + * hovering over the button.
1.775 + * @param aText is the text.
1.776 + * @param aHelpText is the text for the tooltip.
1.777 + * @param aStateFlags The flags for the state.
1.778 + * @param aCommandId Command to be attached with the state.
1.779 + */
1.780 + void AddStateL( CGulIcon* aIcon,
1.781 + CGulIcon* aDimmedIcon,
1.782 + CGulIcon* aPressedIcon,
1.783 + CGulIcon* aHoverIcon,
1.784 + const TDesC& aText,
1.785 + const TDesC& aHelpText,
1.786 + const TInt aStateFlags,
1.787 + const TInt aCommandId );
1.788 +
1.789 + /**
1.790 + * Sets the button flags.
1.791 + *
1.792 + * @param aFlags which can be combination of: KAknButtonTextLeft,
1.793 + * KAknButtonSizeFitText, KAknButtonNoFrame, KAknButtonKeyRepeat,
1.794 + * KAknButtonReportOnKeyDown, KAknButtonNoFramePressEvent,
1.795 + * KAknButtonRequestExitOnButtonUpEvent, KAknButtonReportOnLongPress.
1.796 + */
1.797 + IMPORT_C void SetButtonFlags( const TInt aFlags );
1.798 +
1.799 + /**
1.800 + * Sets specified frame IDs. Can be used when default frame is not
1.801 + * suitable. Use KAknsIIDNone value in case when some frame or center
1.802 + * drawing is not needed or KAknsIIDDefault when the default button
1.803 + * frame should be used.
1.804 + *
1.805 + * @param aFrameId The item ID of the entire frame.
1.806 + * @param aCenterId The item ID of the center part of the frame.
1.807 + * @param aLatchedFrameId The item ID of the entire frame for button
1.808 + * in latched state.
1.809 + * @param aLatchedCenterId The item ID of the center part of the
1.810 + * frame for button in latched state.
1.811 + * @param aDimmedFrameId The item ID of the entire frame for a button
1.812 + * in dimmed state.
1.813 + * @param aDimmedCenterId The item ID of the center part of the frame
1.814 + * for a button in dimmed state.
1.815 + * @param aPressedFrameId The item ID of the entire frame for a
1.816 + * button in pressed state.
1.817 + * @param aPressedCenterId is the item ID of the center part of the
1.818 + * frame for a button in pressed state.
1.819 + * @param aLatchedDimmedFrameId The item ID of the entire frame for
1.820 + * a button in latched and dimmed state.
1.821 + * @param aLatchedDimmedCenterId The item ID of the center part of
1.822 + * the frame for a button in latched and dimmed state.
1.823 + */
1.824 + IMPORT_C void SetFrameAndCenterIds( const TAknsItemID& aFrameId,
1.825 + const TAknsItemID& aCenterId,
1.826 + const TAknsItemID& aLatchedFrameId,
1.827 + const TAknsItemID& aLatchedCenterId,
1.828 + const TAknsItemID& aDimmedFrameId,
1.829 + const TAknsItemID& aDimmedCenterId,
1.830 + const TAknsItemID& aPressedFrameId,
1.831 + const TAknsItemID& aPressedCenterId,
1.832 + const TAknsItemID& aLatchedDimmedFrameId,
1.833 + const TAknsItemID& aLatchedDimmedCenterId );
1.834 +
1.835 + /**
1.836 + * Sets specified background IDs. Can be used when default frame is not
1.837 + * suitable and the backgound is composed of only single image instead
1.838 + * of frame and center. SetFrameAndCenterIds() function can also be used
1.839 + * for this purpose by giving the same backround ID for both frame and
1.840 + * center. This allows also some of the states to be composed of frames
1.841 + * and the others from single backgound images. Use KAknsIIDNone value
1.842 + * in case when some backgound drawing is not needed or KAknsIIDDefault
1.843 + * when the default button frame should be used.
1.844 + *
1.845 + * @param aBackgroundId The item ID of the entire frame.
1.846 + * @param aLatchedBackgroundId The item ID of the background for the
1.847 + * button in latched state.
1.848 + * @param aDimmedBackgroundId The item ID of the background for the
1.849 + * button in dimmed state.
1.850 + * @param aPressedBackgroundId The item ID of the background for the
1.851 + * button in pressed state.
1.852 + * @param aLatchedDimmedBackgroundId The item ID of the background for
1.853 + * the button in latched and dimmed state.
1.854 + */
1.855 + IMPORT_C void SetBackgroundIds( const TAknsItemID& aBackgroundId,
1.856 + const TAknsItemID& aLatchedBackgroundId,
1.857 + const TAknsItemID& aDimmedBackgroundId,
1.858 + const TAknsItemID& aPressedBackgroundId,
1.859 + const TAknsItemID& aLatchedDimmedBackgroundId );
1.860 +
1.861 + /**
1.862 + * Sets some specific text font.
1.863 + *
1.864 + * @param aFont The font, which should be used for the text inside the
1.865 + * text button.
1.866 + */
1.867 + IMPORT_C void SetTextFont( const CFont* aFont );
1.868 +
1.869 + /**
1.870 + * Sets the color table and color index for the button text. It will be
1.871 + * used on button drawing, if color of the text shouldn't be taken from
1.872 + * text layout.
1.873 + *
1.874 + * @param aTextColorTableId Id for the color table
1.875 + * @param aTextColorIndex Index of the color inside color table.
1.876 + */
1.877 + IMPORT_C void SetTextColorIds( const TAknsItemID& aTextColorTableId,
1.878 + const TInt aTextColorIndex );
1.879 +
1.880 + /**
1.881 + * Sets the horizontal alignment for the text inside the button. It
1.882 + * will be used, if alignment shouldn't be taken from text layout. By
1.883 + * default it will be centered.
1.884 + *
1.885 + * @param aHorizontalAlignment The horizontal alignment for the text.
1.886 + */
1.887 + IMPORT_C void SetTextHorizontalAlignment(
1.888 + const CGraphicsContext::TTextAlign aHorizontalAlignment );
1.889 +
1.890 + /**
1.891 + * Sets the vertical alignment for the text inside the button. It will
1.892 + * be used if alignment shouldn't be taken from text layout. By default
1.893 + * it will be centered.
1.894 + *
1.895 + * @param aVerticalAlignment The vertical alignment for the text.
1.896 + */
1.897 + IMPORT_C void SetTextVerticalAlignment(
1.898 + const CAknButton::TAlignment aVerticalAlignment );
1.899 +
1.900 + /**
1.901 + * Sets the icon and text alignment for a button having both
1.902 + *
1.903 + * @param aAlignment. TTextAndIconAlignment
1.904 + */
1.905 + IMPORT_C void SetTextAndIconAlignment(
1.906 + const CAknButton::TTextAndIconAlignment aAlignment );
1.907 +
1.908 + /**
1.909 + * Sets the text underline style for the text inside the button. By
1.910 + * default no underline is used.
1.911 + *
1.912 + * @param aUnderlineStyle The style of underline.
1.913 + */
1.914 + IMPORT_C void SetTextUnderlineStyle( TFontUnderline aUnderlineStyle );
1.915 +
1.916 + /**
1.917 + * Sets the scale mode for the icon inside the button.
1.918 + * The default is EAspectRatioNotPreserved.
1.919 + *
1.920 + * @param aScaleMode The scale mode.
1.921 + */
1.922 + IMPORT_C void SetIconScaleMode( const TScaleMode aScaleMode );
1.923 +
1.924 + /**
1.925 + * Sets the horizontal alignment for the icon inside the button.
1.926 + * By default it will be centered.
1.927 + *
1.928 + * @param aHorizontalAlignment The horizontal alignment for the icon.
1.929 + */
1.930 + IMPORT_C void SetIconHorizontalAlignment(
1.931 + const CAknButton::TAlignment aHorizontalAlignment );
1.932 +
1.933 + /**
1.934 + * Sets the vertical alignment for the icon inside the button.
1.935 + * By default it will be centered.
1.936 + *
1.937 + * @param aVerticalAlignment The vertical alignment for the icon.
1.938 + */
1.939 + IMPORT_C void SetIconVerticalAlignment(
1.940 + const CAknButton::TAlignment aVerticalAlignment );
1.941 +
1.942 + /**
1.943 + * Sets the delay before the help text is shown and also specifies the
1.944 + * time for how long help text is visible.
1.945 + *
1.946 + * @param aBeforeTimeout The delay in milliseconds before text help note
1.947 + * is shown. The default is 150 milliseconds.
1.948 + * @param aInViewTimeout The interval in milliseconds during which help
1.949 + * text note is shown. The default is 3000 milliseconds.
1.950 + */
1.951 + IMPORT_C void SetHelpNoteTimeouts( const TInt aBeforeTimeout,
1.952 + const TInt aInViewTimeout );
1.953 +
1.954 + /**
1.955 + * Sets the interval for key repeat.
1.956 + *
1.957 + * @param aKeyRepeatDelay The initial delay, after which the key repeat is
1.958 + started. The default is 500 milliseconds.
1.959 + * @param aKeyRepeatInterval The interval in milliseconds, in which key
1.960 + * repeat events should be reported. The default is 500 milliseconds.
1.961 + */
1.962 + IMPORT_C void SetKeyRepeatInterval( const TInt aKeyRepeatDelay,
1.963 + const TInt aKeyRepeatInterval );
1.964 +
1.965 + /**
1.966 + * Sets the interval for long press. When KAknButtonReportOnLongPress
1.967 + * flag is set for the button, button will notify observer with
1.968 + * KAknButtonLongPressEvent as the event type, after button has been
1.969 + * pressed for the specified time.
1.970 + *
1.971 + * @param aLongPressInterval The time interval in milliseconds, after
1.972 + * which the long press event should be reported. The default
1.973 + * value is 800 milliseconds.
1.974 + */
1.975 + IMPORT_C void SetLongPressInterval( const TInt aLongPressInterval );
1.976 +
1.977 + /**
1.978 + * Returns the index of the button state.
1.979 + */
1.980 + IMPORT_C TInt StateIndex() const;
1.981 +
1.982 + /**
1.983 + * Enables pictograph drawing in the button text.
1.984 + * Only effective in Japanese variant.
1.985 + * By default, it is disabled.
1.986 + *
1.987 + * @param aInterface Used pictograph interface owned by the caller.
1.988 + */
1.989 + IMPORT_C void EnablePictographsL( CAknPictographInterface& aInterface );
1.990 +
1.991 + /**
1.992 + * Disables pictograph drawing in the button text.
1.993 + * Only effective in Japanese variant.
1.994 + * By default, it is disabled.
1.995 + */
1.996 + IMPORT_C void DisablePictographs();
1.997 +
1.998 + /**
1.999 + * It will change the default highlight rectangle around
1.1000 + * the focused button.
1.1001 + *
1.1002 + * @param aRect The highlight rectangle.
1.1003 + */
1.1004 + IMPORT_C void SetHighlightRect( const TRect& aRect );
1.1005 +
1.1006 + /**
1.1007 + * Gets the highlight rectangle around the button.
1.1008 + *
1.1009 + * @return The higlight rectangle around the button.
1.1010 + */
1.1011 + IMPORT_C TRect HighlightRect() const;
1.1012 +
1.1013 + /**
1.1014 + * Sets the tooltip position.
1.1015 + *
1.1016 + * @param aPosition The position of the tooltip.
1.1017 + */
1.1018 + IMPORT_C void SetTooltipPosition( const TTooltipPosition aPosition );
1.1019 +
1.1020 + /**
1.1021 + * Sets whether button should send an EEventRequestExit event to command
1.1022 + * observer on button up event.
1.1023 + *
1.1024 + * @param aRequestExit ETrue if button should request exit.
1.1025 + */
1.1026 + IMPORT_C void SetRequestExit( const TBool aRequestExit );
1.1027 +
1.1028 + /**
1.1029 + * Tests if the control is dimmed. This function overrides the function
1.1030 + * declared in CCoeControl, and returns the value which is set and unset
1.1031 + * using CAknButton::SetDimmed().
1.1032 + *
1.1033 + * @return ETrue if the control is dimmed, EFalse if it is not dimmed.
1.1034 + */
1.1035 + IMPORT_C TBool IsDimmed() const;
1.1036 +
1.1037 + /**
1.1038 + * Sets the help text for dimmed button.
1.1039 + *
1.1040 + * @param aHelpText The text inside the tooltip.
1.1041 + */
1.1042 + IMPORT_C void SetDimmedHelpTextL( const TDesC& aHelpText );
1.1043 +
1.1044 + /**
1.1045 + * Check if point is within buttons visible area, when
1.1046 + * KAknButtonHitTest flag is enabled
1.1047 + *
1.1048 + * @param aPoint Location to check.
1.1049 + * @param aCheckHitArea if need to check the hit area for fixed
1.1050 + * toolbar button
1.1051 + */
1.1052 + TBool HitAreaContainsL( const TPoint& aPoint, TBool aCheckHitArea ) const;
1.1053 +
1.1054 + /**
1.1055 + * Returns the current state of the button.
1.1056 + *
1.1057 + * @return the current state of the button
1.1058 + */
1.1059 + IMPORT_C CAknButtonState* State() const;
1.1060 +
1.1061 + /**
1.1062 + * Returns the state of the button under specified index.
1.1063 + *
1.1064 + * @param aStateIndex The index for the state.
1.1065 + * @return the state of the button.
1.1066 + */
1.1067 + IMPORT_C CAknButtonState* State( const TInt aStateIndex ) const;
1.1068 +
1.1069 + /**
1.1070 + * Returns the flags of button. The flags are defined in eikon.hrh.
1.1071 + * @return Button flags.
1.1072 + * @since S60 3.2
1.1073 + */
1.1074 + IMPORT_C TInt ButtonFlags() const;
1.1075 +
1.1076 + /**
1.1077 + * Sets button's margins. These define the free area inside the button
1.1078 + * where content is placed. Note that calling this function overrides
1.1079 + * default margins that are scaled automatically depending on the
1.1080 + * current screen layout. If this function is called then the caller
1.1081 + * is responsible for updating margins whenever the layout changes.
1.1082 + *
1.1083 + * @since S60 3.2
1.1084 + * @param aMargins New marginals.
1.1085 + */
1.1086 + IMPORT_C void SetMargins( const TMargins8& aMargins );
1.1087 +
1.1088 + /**
1.1089 + * Sets icon size for the button. Calling this function overrides the
1.1090 + * default size that is scaled automatically depending on the current
1.1091 + * screen layout. If this function is called then the caller is
1.1092 + * responsible for updating icon size whenever the layout changes.
1.1093 + *
1.1094 + * @since S60 3.2
1.1095 + * @param aSize New icon size.
1.1096 + * @return KErrNone if the operation succeeded, otherwise an error code.
1.1097 + */
1.1098 + IMPORT_C TInt SetIconSize( const TSize& aSize );
1.1099 +
1.1100 + /**
1.1101 + * Checks if the button uses default margins.
1.1102 + *
1.1103 + * @since S60 3.2
1.1104 + *
1.1105 + * @return ETrue if default margins are used.
1.1106 + */
1.1107 + TBool UsesDefaultMargins() const;
1.1108 +
1.1109 + /**
1.1110 + * Sets tooltip to hide or show itself when background faded.
1.1111 + *
1.1112 + * @since S60 3.2
1.1113 + * @param aHide should be ETrue if hiding, EFalse if showing
1.1114 + */
1.1115 + void HideTooltipWhenAppFaded( TBool aHide );
1.1116 +
1.1117 +
1.1118 + /**
1.1119 + */
1.1120 + void CheckHitArea();
1.1121 +
1.1122 + /**
1.1123 + * Resets button to unpressed state.
1.1124 + *
1.1125 + * @since S60 5.0
1.1126 + */
1.1127 + IMPORT_C void ResetState();
1.1128 +
1.1129 + /**
1.1130 + * Sets button to use additional masks during drawing. Calling this
1.1131 + * method forces button to bypass the normal drawing routine i.e.
1.1132 + * method DrawMaskedL is executed instead of Draw.
1.1133 + *
1.1134 + * @since S60 5.0
1.1135 + * @param aMaskedDraw ETrue to use additional mask.
1.1136 + */
1.1137 + void UseMaskedDraw( TBool aMaskedDraw );
1.1138 +
1.1139 + /**
1.1140 + * Registers resource provider.
1.1141 + * @param aProvider New resource provider.
1.1142 + */
1.1143 + void RegisterResourceProvider( CAknResourceProvider* aProvider );
1.1144 +
1.1145 + /**
1.1146 + * Unregisters resource provider.
1.1147 + */
1.1148 + void UnregisterResourceProvider();
1.1149 +
1.1150 + CAknsFrameBackgroundControlContext* BgContext();
1.1151 +
1.1152 + /**
1.1153 + * Removes the currently active state from the button,
1.1154 + * and sets the current state to the previous one.
1.1155 + */
1.1156 + void RemoveCurrentState();
1.1157 +
1.1158 + /**
1.1159 + * Returns the button touchable area.
1.1160 + *
1.1161 + * @since S60 5.0
1.1162 + * @return Button touch area
1.1163 + */
1.1164 + TRect TouchArea() const;
1.1165 +
1.1166 + protected: // Constructors
1.1167 +
1.1168 + /**
1.1169 + * C++ constructor for the one state button.
1.1170 + *
1.1171 + * @param aFlags The flags for the button
1.1172 + */
1.1173 + IMPORT_C CAknButton( const TInt aFlags );
1.1174 +
1.1175 + /**
1.1176 + * Symbian 2nd phase constructor.
1.1177 + */
1.1178 + IMPORT_C void ConstructL();
1.1179 +
1.1180 + /**
1.1181 + * Symbian 2nd phase constructor.
1.1182 + *
1.1183 + * @param aIcon The icon for the normal state. Takes ownership.
1.1184 + * @param aDimmedIcon The icon for the dimmed state. Takes ownership.
1.1185 + * @param aPressedIcon The icon for the pressed down. Takes ownership.
1.1186 + * @param aHoverIcon The icon for the hover state.
1.1187 + * @param aText The text inside the button.
1.1188 + * @param aHelpText The text for the tooltip.
1.1189 + * @param aStateFlags The flags for the first state.
1.1190 + */
1.1191 + IMPORT_C void ConstructL( CGulIcon* aIcon,
1.1192 + CGulIcon* aDimmedIcon,
1.1193 + CGulIcon* aPressedIcon,
1.1194 + CGulIcon* aHoverIcon,
1.1195 + const TDesC& aText,
1.1196 + const TDesC& aHelpText,
1.1197 + const TInt aStateFlags );
1.1198 +
1.1199 + /**
1.1200 + * Symbian 2nd phase constructor.
1.1201 + *
1.1202 + * @param aFilePath The path to the file which contains icons.
1.1203 + * @param aBmpId The bitmap ID for the normal state icon.
1.1204 + * @param aMaskId The mask ID for the normal state icon.
1.1205 + * @param aDimmedBmpId The bitmap ID for the dimmed state icon.
1.1206 + * @param aDimmedMaskId The mask ID for the dimmed state icon.
1.1207 + * @param aPressedBmpId The bitmap ID for the pressed down state.
1.1208 + * @param aPressedMaskId The mask ID for the pressed down state.
1.1209 + * @param aHoverBmpId The bitmap ID for the hover state icon.
1.1210 + * @param aHoverMaskId The mask ID for the hover state icon.
1.1211 + * @param aText The text inside the button.
1.1212 + * @param aHelpText The text for the tooltip.
1.1213 + * @param aStateFlags The flags for the first state.
1.1214 + * @param aId Item ID of the masked bitmap to be created for skin
1.1215 + * specific icon.
1.1216 + * @param aDimmedId Item ID of the dimmed masked bitmap to be created
1.1217 + * for skin specific icon.
1.1218 + * @param aPressedId Item ID of the pressed masked bitmap to be created
1.1219 + * for skin specific icon.
1.1220 + * @param aHoverId Item ID of the masked hover bitmap to be created
1.1221 + * for skin specific icon.
1.1222 + */
1.1223 + IMPORT_C void ConstructL( const TDesC& aFilePath,
1.1224 + const TInt aBmpId,
1.1225 + const TInt aMaskId,
1.1226 + const TInt aDimmedBmpId,
1.1227 + const TInt aDimmedMaskId,
1.1228 + const TInt aPressedBmpId,
1.1229 + const TInt aPressedMaskId,
1.1230 + const TInt aHoverBmpId,
1.1231 + const TInt aHoverMaskId,
1.1232 + const TDesC& aText,
1.1233 + const TDesC& aHelpText,
1.1234 + const TInt aStateFlags,
1.1235 + const TAknsItemID& aId = KAknsIIDNone,
1.1236 + const TAknsItemID& aDimmedId = KAknsIIDNone,
1.1237 + const TAknsItemID& aPressedId = KAknsIIDNone,
1.1238 + const TAknsItemID& aHoverId = KAknsIIDNone );
1.1239 +
1.1240 + protected: // Functions from base class
1.1241 +
1.1242 + /**
1.1243 + * Responds to size changes to sets the size and position of the
1.1244 + * contents of this control.
1.1245 + */
1.1246 + IMPORT_C void SizeChanged();
1.1247 +
1.1248 + /**
1.1249 + * This function is called whenever a control gains or loses focus.
1.1250 + *
1.1251 + * @param aDrawNow Contains the value that was passed to it by SetFocus().
1.1252 + */
1.1253 + IMPORT_C void FocusChanged( TDrawNow aDrawNow );
1.1254 +
1.1255 + /**
1.1256 + * For future extensions
1.1257 + *
1.1258 + * @param aInterface The ID for the extension interface.
1.1259 + */
1.1260 + IMPORT_C void* ExtensionInterface( TUid aInterface );
1.1261 +
1.1262 + protected: // New functions
1.1263 +
1.1264 + /**
1.1265 + * Changes the state of the button to the next one.
1.1266 + *
1.1267 + * @return the current state index
1.1268 + */
1.1269 + IMPORT_C TInt ChangeState( TBool aDrawNow );
1.1270 +
1.1271 + /**
1.1272 + * Returns the text, which will be displayed inside the button
1.1273 + * for the current state.
1.1274 + */
1.1275 + IMPORT_C const TDesC& GetCurrentText() const;
1.1276 +
1.1277 + /**
1.1278 + * Returns icon for the current state.
1.1279 + */
1.1280 + IMPORT_C const CGulIcon* GetCurrentIcon() const;
1.1281 +
1.1282 + /**
1.1283 + * Shows help text for a certain period of time.
1.1284 + */
1.1285 + IMPORT_C void ShowHelpL();
1.1286 +
1.1287 + /**
1.1288 + * Hides help text after certain interval.
1.1289 + */
1.1290 + IMPORT_C void HideHelp();
1.1291 +
1.1292 +
1.1293 + private: // Functions from base class
1.1294 +
1.1295 + /**
1.1296 + * From CCoeControl. Draws the control. Called by window server.
1.1297 + */
1.1298 + IMPORT_C void Draw( const TRect& aRect ) const;
1.1299 +
1.1300 + private: // New functions
1.1301 +
1.1302 + /**
1.1303 + * Continues drawing of the button which has only text.
1.1304 + */
1.1305 + void DrawTextButton( CWindowGc& aGc ) const;
1.1306 +
1.1307 + /**
1.1308 + * Continues drawing of the button which has only an icon in it.
1.1309 + */
1.1310 + void DrawIconButton( CWindowGc& aGc ) const;
1.1311 +
1.1312 + /**
1.1313 + * Continues drawing of the button which has both text and icon.
1.1314 + */
1.1315 + void DrawTextAndIconButton( CWindowGc& aGc ) const;
1.1316 +
1.1317 + /**
1.1318 + * Draws a button with additional mask.
1.1319 + */
1.1320 + void DrawMaskedL( CWindowGc& aGc ) const;
1.1321 +
1.1322 + /**
1.1323 + * Starts the long press timer.
1.1324 + */
1.1325 + void StartLongPressTimerL();
1.1326 +
1.1327 + /**
1.1328 + * Stops the long press timer.
1.1329 + */
1.1330 + void StopLongPressTimer();
1.1331 +
1.1332 + /**
1.1333 + * Starts the timer for the key repeat.
1.1334 + */
1.1335 + void StartKeyRepeatTimerL();
1.1336 +
1.1337 + /**
1.1338 + * Stops the key repeat timer.
1.1339 + */
1.1340 + void StopKeyRepeatTimer();
1.1341 +
1.1342 + /**
1.1343 + * Called after timeout is over.
1.1344 + */
1.1345 + static TInt ReportKeyRepeatL( TAny* aThis );
1.1346 +
1.1347 + /**
1.1348 + * Asserts that extension class object exists.
1.1349 + *
1.1350 + * @return Extension object.
1.1351 + */
1.1352 + CAknButtonExtension* Extension() const;
1.1353 +
1.1354 + /**
1.1355 + * Updates tooltip position.
1.1356 + */
1.1357 + void UpdateTooltipPosition();
1.1358 +
1.1359 + /**
1.1360 + * Checks whether toolbar should send an EEventRequestExit event to
1.1361 + * command observe on button up event.
1.1362 + *
1.1363 + * @return ETrue if event should be sent, EFalse otherwise.
1.1364 + */
1.1365 + TBool RequestExit() const;
1.1366 +
1.1367 + /**
1.1368 + * Gets the rectangele reserved for button content excluding frame.
1.1369 + *
1.1370 + * @return Content rectangle.
1.1371 + */
1.1372 + TRect ContentRect() const;
1.1373 +
1.1374 + /**
1.1375 + * Checks whether button needs redrawing when it is pressed or released.
1.1376 + *
1.1377 + * @return ETrue, if redraw is needed, othewise EFalse.
1.1378 + */
1.1379 + TBool NeedsRedrawWhenPressed() const;
1.1380 +
1.1381 + /**
1.1382 + * Returns the ID of specified skin item.
1.1383 + */
1.1384 + TAknsItemID SkinIID( const TInt aIndex ) const;
1.1385 +
1.1386 + /**
1.1387 + * Calculates default margins.
1.1388 + */
1.1389 + void CalculateDefaultMargins();
1.1390 +
1.1391 + /**
1.1392 + * Scales all icons.
1.1393 + *
1.1394 + * @return KErrNone or an error code.
1.1395 + */
1.1396 + TInt ScaleIcons();
1.1397 +
1.1398 + /**
1.1399 + * Gets the correct text color.
1.1400 + *
1.1401 + * @return Text color.
1.1402 + */
1.1403 + TRgb TextColor() const;
1.1404 +
1.1405 + /**
1.1406 + * Generates the pressed down bitmaps
1.1407 + * if flag KAknButtonPressedDownFrame is set and button has no frame
1.1408 + */
1.1409 + void CreatePressedDownFrameL();
1.1410 +
1.1411 + /**
1.1412 + * Calculates color's luminance.
1.1413 + */
1.1414 + TInt CalculateLuminance( const TRgb& aColor ) const;
1.1415 +
1.1416 + /**
1.1417 + * Converts outline color, if fill color is too similar to outline color
1.1418 + *
1.1419 + * @aFillColor fill color
1.1420 + * @aOutlineColor outline color
1.1421 + */
1.1422 + void ConvertColorsForOutlineEffect( TRgb& aFillColor, TRgb& aOutlineColor ) const;
1.1423 +
1.1424 + /**
1.1425 + * Gets text colors
1.1426 + *
1.1427 + * @aPenColor pen color
1.1428 + * @aBrushColor brush color
1.1429 + */
1.1430 + void GetTextColors( TRgb& aPenColor, TRgb& aBrushColor ) const;
1.1431 +
1.1432 + /**
1.1433 + * Sets new state index
1.1434 + *
1.1435 + * @param aNewIndex New state index
1.1436 + */
1.1437 + void SetStateIndexL( TInt aNewIndex );
1.1438 +
1.1439 + protected: // Data
1.1440 +
1.1441 + // array to keep states
1.1442 + CArrayPtrFlat<CAknButtonState>* iStates;
1.1443 +
1.1444 + // button flags
1.1445 + TInt iFlags;
1.1446 +
1.1447 + // current button state index
1.1448 + TInt iStateIndex;
1.1449 +
1.1450 + // flag to define whether the button is pressed
1.1451 + TBool iButtonPressed;
1.1452 +
1.1453 + // number of drag events, needed to distinguish when it is outside
1.1454 + // the button.
1.1455 + TInt iNumberOfDragEvents;
1.1456 +
1.1457 + // Flag which shows whether key down event was reported before key up
1.1458 + // event was sent to the button, because some controls consume key down
1.1459 + // but don't consume key up events which might cause of button state
1.1460 + // when it is not expected
1.1461 + TBool iKeyDownReported;
1.1462 +
1.1463 + // Background control context for button's frame
1.1464 + CAknsFrameBackgroundControlContext* iBgContext;
1.1465 +
1.1466 + // Customized highlight rectangular around the button if the default one
1.1467 + // won't be used
1.1468 + TRect iHighlightRect;
1.1469 +
1.1470 + // text button specific data
1.1471 + const CFont* iFont; // font for the text inside the button
1.1472 + TAlignment iVerticalAlignment; // vertical alignment for the text. Centered by default
1.1473 + CGraphicsContext::TTextAlign iHorizontalAlignment; // horizontal alignment for the text. Centered by default
1.1474 + TAknsItemID iTextColorTableId; // id for the color table
1.1475 + TInt iTextColorIndex; // index of the color in color table
1.1476 +
1.1477 + // icon button specific data
1.1478 + TScaleMode iScaleMode; // scale mode for the icon, by default it is EAspectRatioNotPreserved
1.1479 +
1.1480 + // tooltip specific data
1.1481 + TInt iHelpNoteWaitInterval; // interval in milliseconds between the time when the button got focused and the help text is shown
1.1482 + TInt iHelpNoteInViewInterval; // interval during which help text is shown in milliseconds
1.1483 + CAknInfoPopupNoteController* iHelpNote; // component to show help text
1.1484 + HBufC* iDimmedHelpText; // help text in case if the button is dimmed, not used currently
1.1485 + TBool iShowHelp; // flag which specifies whether help note should be shown
1.1486 +
1.1487 + // Key repeat handling
1.1488 + CPeriodic* iKeyRepeatTimer; // timer to report key repeats
1.1489 + TInt iKeyRepeatDelay; // initial delay for key repeats
1.1490 + TInt iKeyRepeatInterval; // time interval for key repeats
1.1491 +
1.1492 + private:
1.1493 + CAknButtonExtension* iExtension;
1.1494 +
1.1495 + };
1.1496 +
1.1497 +
1.1498 +#endif // __AKNBUTTON_H__
1.1499 +
1.1500 +// End of File