00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __AKNBUTTON_H__
00021 #define __AKNBUTTON_H__
00022
00023
00024 #include <akncontrol.h>
00025 #include <akniconutils.h>
00026 #include <aknutils.h>
00027
00028
00029 class CGulIcon;
00030 class CAknButton;
00031 class CAknButtonExtension;
00032 class CAknInfoPopupNoteController;
00033 class CAknButtonStateExtension;
00034 class CAknPictographInterface;
00035 class CAknsFrameBackgroundControlContext;
00036 class CAknResourceProvider;
00037
00038
00039
00046 class CAknButtonState : public CBase
00047 {
00048 public:
00049
00053 IMPORT_C ~CAknButtonState();
00054
00055 protected:
00056
00062 IMPORT_C CAknButtonState( const TInt aFlags );
00063
00074 IMPORT_C void ConstructL( CGulIcon* aIcon,
00075 CGulIcon* aDimmedIcon,
00076 CGulIcon* aPressedIcon,
00077 CGulIcon* aHoverIcon,
00078 const TDesC& aText,
00079 const TDesC& aHelpText );
00080
00104 IMPORT_C void ConstructL( const TDesC& aFilePath,
00105 const TInt aBmpId,
00106 const TInt aMaskId,
00107 const TInt aDimmedBmpId,
00108 const TInt aDimmedMaskId,
00109 const TInt aPressedBmpId,
00110 const TInt aPressedMaskId,
00111 const TInt aHoverBmpId,
00112 const TInt aHoverMaskId,
00113 const TDesC& aText,
00114 const TDesC& aHelpText,
00115 const TAknsItemID& aId = KAknsIIDNone,
00116 const TAknsItemID& aDimmedId = KAknsIIDNone,
00117 const TAknsItemID& aPressedId = KAknsIIDNone,
00118 const TAknsItemID& aHoverId = KAknsIIDNone );
00119
00120 public:
00121
00127 IMPORT_C const CGulIcon* Icon() const;
00128
00134 IMPORT_C const CGulIcon* DimmedIcon() const;
00135
00141 IMPORT_C const CGulIcon* PressedIcon() const;
00142
00148 IMPORT_C const CGulIcon* HoverIcon() const;
00149
00155 IMPORT_C const TDesC& Text() const;
00156
00162 IMPORT_C const TDesC& HelpText() const;
00163
00169 IMPORT_C TInt Flags() const;
00170
00176 IMPORT_C void SetIcon( CGulIcon* aIcon );
00177
00183 IMPORT_C void SetDimmedIcon( CGulIcon* aDimmedIcon );
00184
00190 IMPORT_C void SetPressedIcon( CGulIcon* aPressedIcon );
00191
00197 IMPORT_C void SetHoverIcon( CGulIcon* aHoverIcon );
00198
00204 IMPORT_C void SetTextL( const TDesC& aText );
00205
00211 IMPORT_C void SetHelpTextL( const TDesC& aHelpText );
00212
00218 IMPORT_C void SetFlags( const TInt aFlags );
00219
00225 void UpdateIconL( const TDesC& aFilePath,
00226 const TInt aBmpId,
00227 const TInt aMaskId,
00228 const TInt aDimmedBmpId,
00229 const TInt aDimmedMaskId,
00230 const TInt aPressedBmpId,
00231 const TInt aPressedMaskId,
00232 const TInt aHoverBmpId,
00233 const TInt aHoverMaskId,
00234 const TAknsItemID& aId = KAknsIIDNone,
00235 const TAknsItemID& aDimmedId = KAknsIIDNone,
00236 const TAknsItemID& aPressedId = KAknsIIDNone,
00237 const TAknsItemID& aHoverId = KAknsIIDNone );
00238
00239
00240
00241 protected:
00242
00248 IMPORT_C virtual void ConstructFromResourceL( TResourceReader& aReader );
00249
00257 IMPORT_C virtual void SizeChanged( const TRect& aRect,
00258 TScaleMode aScaleMode );
00259
00263 IMPORT_C TBool HasText() const;
00264
00269 IMPORT_C TBool HasHelp() const;
00270
00277 void HandleResourceChange( TInt aType );
00278
00285 void SetIconScaleMode( const TScaleMode aScaleMode );
00286
00287 private:
00288
00300 void CreateButtonIconL( CGulIcon*& aIcon, const TDesC& aFilePath,
00301 TInt aBmpId, TInt aMaskId,
00302 const TAknsItemID& aId = KAknsIIDNone ) const;
00303
00317 void LoadButtonIcon( CGulIcon*& aIcon ) const;
00318
00325 void ReplaceIcon( CGulIcon*& aIcon, CGulIcon* aNewIcon );
00326
00335 TInt ScaleIcons( const TSize& aSize, TScaleMode aScaleMode );
00336
00340 CAknButtonStateExtension* Extension() const;
00341
00345 TScaleMode ScaleMode() const;
00346
00351 void SetGeneratedDimmedIcon( TBool aDimmedIconCreatedByButton );
00352
00353 friend class CAknButton;
00354
00355 protected:
00356 CGulIcon* iIcon;
00357 CGulIcon* iDimmedIcon;
00358 CGulIcon* iPressedIcon;
00359 CGulIcon* iHoverIcon;
00360 HBufC* iText;
00361 HBufC* iHelpText;
00362 TInt iFlags;
00363 CAknButtonStateExtension* iExtension;
00364 };
00365
00366
00367
00368
00375 class CAknButton : public CAknControl
00376 {
00377 public:
00378
00379 enum TAlignment
00380 {
00381 ECenter,
00382 ETop,
00383 EBottom,
00384 ERight,
00385 ELeft
00386 };
00387
00388 enum TTooltipPosition
00389 {
00390 EPositionTop = 1,
00391 EPositionBottom,
00392 EPositionLeft,
00393 EPositionRight
00394 };
00395
00396 enum TTextAndIconAlignment
00397 {
00398 EIconBeforeText,
00399 EIconAfterText,
00400 EIconUnderText,
00401 EIconOverText,
00402 EOverlay
00403 };
00404
00405 enum TButtonEvent
00406 {
00407 ELongPressEvent = 100,
00408 ELongPressEndedEvent
00409 };
00410
00411 public:
00412
00417 IMPORT_C static CAknButton* NewL();
00418
00422 IMPORT_C static CAknButton* NewLC();
00423
00430 IMPORT_C static CAknButton* NewL( TResourceReader& aReader );
00431
00438 IMPORT_C static CAknButton* NewLC( TResourceReader& aReader );
00439
00445 IMPORT_C static CAknButton* NewL( const TInt aResourceId );
00446
00452 IMPORT_C static CAknButton* NewLC( const TInt aResourceId );
00453
00466 IMPORT_C static CAknButton* NewL( CGulIcon* aIcon,
00467 CGulIcon* aDimmedIcon,
00468 CGulIcon* aPressedIcon,
00469 CGulIcon* aHoverIcon,
00470 const TDesC& aText,
00471 const TDesC& aHelpText,
00472 const TInt aButtonFlags,
00473 const TInt aStateFlags );
00474
00487 IMPORT_C static CAknButton* NewLC( CGulIcon* aIcon,
00488 CGulIcon* aDimmedIcon,
00489 CGulIcon* aPressedIcon,
00490 CGulIcon* aHoverIcon,
00491 const TDesC& aText,
00492 const TDesC& aHelpText,
00493 const TInt aFlags,
00494 const TInt aStateFlags );
00495
00521 IMPORT_C static CAknButton* NewL( const TDesC& aFilePath,
00522 const TInt aBmpId,
00523 const TInt aMaskId,
00524 const TInt aDimmedBmpId,
00525 const TInt aDimmedMaskId,
00526 const TInt aPressedBmpId,
00527 const TInt aPressedMaskId,
00528 const TInt aHoverBmpId,
00529 const TInt aHoverMaskId,
00530 const TDesC& aText,
00531 const TDesC& aHelpText,
00532 const TInt aButtonFlags,
00533 const TInt aStateFlags,
00534 const TAknsItemID& aId = KAknsIIDNone,
00535 const TAknsItemID& aDimmedId = KAknsIIDNone,
00536 const TAknsItemID& aPressedId = KAknsIIDNone,
00537 const TAknsItemID& aHoverId = KAknsIIDNone );
00538
00564 IMPORT_C static CAknButton* NewLC( const TDesC& aFilePath,
00565 const TInt aBmpId,
00566 const TInt aMaskId,
00567 const TInt aDimmedBmpId,
00568 const TInt aDimmedMaskId,
00569 const TInt aPressedBmpId,
00570 const TInt aPressedMaskId,
00571 const TInt aHoverBmpId,
00572 const TInt aHoverMaskId,
00573 const TDesC& aText,
00574 const TDesC& aHelpText,
00575 const TInt aButtonFlags,
00576 const TInt aStateFlags,
00577 const TAknsItemID& aId = KAknsIIDNone,
00578 const TAknsItemID& aDimmedId = KAknsIIDNone,
00579 const TAknsItemID& aPressedId = KAknsIIDNone,
00580 const TAknsItemID& aHoverId = KAknsIIDNone );
00581
00585 IMPORT_C virtual ~CAknButton();
00586
00587 public:
00588
00592 IMPORT_C void ActivateL();
00593
00600 IMPORT_C void ConstructFromResourceL( TResourceReader& aReader );
00601
00607 IMPORT_C void HandleResourceChange( TInt aType );
00608
00617 IMPORT_C TSize MinimumSize();
00618
00628 IMPORT_C void SetDimmed( TBool aDimmed );
00629
00637 IMPORT_C TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,
00638 TEventCode aType );
00639
00646 IMPORT_C void MakeVisible( TBool aVisible );
00647
00653 IMPORT_C void PrepareForFocusLossL();
00654
00660 IMPORT_C void PrepareForFocusGainL();
00661
00667 IMPORT_C void HandlePointerEventL( const TPointerEvent& aPointerEvent );
00668
00672 IMPORT_C virtual void PositionChanged();
00673
00674 public:
00675
00681 IMPORT_C void ConstructFromResourceL( const TInt aResourceId );
00682
00689 IMPORT_C virtual void SetCurrentState( const TInt aStateIndex,
00690 const TBool aDrawNow );
00691
00707 IMPORT_C virtual void AddStateL( CGulIcon* aIcon,
00708 CGulIcon* aDimmedIcon,
00709 CGulIcon* aPressedIcon,
00710 CGulIcon* aHoverIcon,
00711 const TDesC& aText,
00712 const TDesC& aHelpText,
00713 const TInt aStateFlags );
00714
00741 IMPORT_C virtual void AddStateL( const TDesC& aFilePath,
00742 const TInt aBmpId,
00743 const TInt aMaskId,
00744 const TInt aDimmedBmpId,
00745 const TInt aDimmedMaskId,
00746 const TInt aPressedBmpId,
00747 const TInt aPressedMaskId,
00748 const TInt aHoverBmpId,
00749 const TInt aHoverMaskId,
00750 const TDesC& aText,
00751 const TDesC& aHelpText,
00752 const TInt aStateFlags,
00753 const TAknsItemID& aId,
00754 const TAknsItemID& aDimmedId,
00755 const TAknsItemID& aPressedId,
00756 const TAknsItemID& aHoverId );
00757
00776 void AddStateL( CGulIcon* aIcon,
00777 CGulIcon* aDimmedIcon,
00778 CGulIcon* aPressedIcon,
00779 CGulIcon* aHoverIcon,
00780 const TDesC& aText,
00781 const TDesC& aHelpText,
00782 const TInt aStateFlags,
00783 const TInt aCommandId );
00784
00793 IMPORT_C void SetButtonFlags( const TInt aFlags );
00794
00820 IMPORT_C void SetFrameAndCenterIds( const TAknsItemID& aFrameId,
00821 const TAknsItemID& aCenterId,
00822 const TAknsItemID& aLatchedFrameId,
00823 const TAknsItemID& aLatchedCenterId,
00824 const TAknsItemID& aDimmedFrameId,
00825 const TAknsItemID& aDimmedCenterId,
00826 const TAknsItemID& aPressedFrameId,
00827 const TAknsItemID& aPressedCenterId,
00828 const TAknsItemID& aLatchedDimmedFrameId,
00829 const TAknsItemID& aLatchedDimmedCenterId );
00830
00851 IMPORT_C void SetBackgroundIds( const TAknsItemID& aBackgroundId,
00852 const TAknsItemID& aLatchedBackgroundId,
00853 const TAknsItemID& aDimmedBackgroundId,
00854 const TAknsItemID& aPressedBackgroundId,
00855 const TAknsItemID& aLatchedDimmedBackgroundId );
00856
00863 IMPORT_C void SetTextFont( const CFont* aFont );
00864
00873 IMPORT_C void SetTextColorIds( const TAknsItemID& aTextColorTableId,
00874 const TInt aTextColorIndex );
00875
00883 IMPORT_C void SetTextHorizontalAlignment(
00884 const CGraphicsContext::TTextAlign aHorizontalAlignment );
00885
00893 IMPORT_C void SetTextVerticalAlignment(
00894 const CAknButton::TAlignment aVerticalAlignment );
00895
00901 IMPORT_C void SetTextAndIconAlignment(
00902 const CAknButton::TTextAndIconAlignment aAlignment );
00903
00910 IMPORT_C void SetTextUnderlineStyle( TFontUnderline aUnderlineStyle );
00911
00918 IMPORT_C void SetIconScaleMode( const TScaleMode aScaleMode );
00919
00926 IMPORT_C void SetIconHorizontalAlignment(
00927 const CAknButton::TAlignment aHorizontalAlignment );
00928
00935 IMPORT_C void SetIconVerticalAlignment(
00936 const CAknButton::TAlignment aVerticalAlignment );
00937
00947 IMPORT_C void SetHelpNoteTimeouts( const TInt aBeforeTimeout,
00948 const TInt aInViewTimeout );
00949
00958 IMPORT_C void SetKeyRepeatInterval( const TInt aKeyRepeatDelay,
00959 const TInt aKeyRepeatInterval );
00960
00971 IMPORT_C void SetLongPressInterval( const TInt aLongPressInterval );
00972
00976 IMPORT_C TInt StateIndex() const;
00977
00985 IMPORT_C void EnablePictographsL( CAknPictographInterface& aInterface );
00986
00992 IMPORT_C void DisablePictographs();
00993
01000 IMPORT_C void SetHighlightRect( const TRect& aRect );
01001
01007 IMPORT_C TRect HighlightRect() const;
01008
01014 IMPORT_C void SetTooltipPosition( const TTooltipPosition aPosition );
01015
01022 IMPORT_C void SetRequestExit( const TBool aRequestExit );
01023
01031 IMPORT_C TBool IsDimmed() const;
01032
01038 IMPORT_C void SetDimmedHelpTextL( const TDesC& aHelpText );
01039
01048 TBool HitAreaContainsL( const TPoint& aPoint, TBool aCheckHitArea ) const;
01049
01055 IMPORT_C CAknButtonState* State() const;
01056
01063 IMPORT_C CAknButtonState* State( const TInt aStateIndex ) const;
01064
01070 IMPORT_C TInt ButtonFlags() const;
01071
01082 IMPORT_C void SetMargins( const TMargins8& aMargins );
01083
01094 IMPORT_C TInt SetIconSize( const TSize& aSize );
01095
01103 TBool UsesDefaultMargins() const;
01104
01111 void HideTooltipWhenAppFaded( TBool aHide );
01112
01113
01116 void CheckHitArea();
01117
01123 IMPORT_C void ResetState();
01124
01133 void UseMaskedDraw( TBool aMaskedDraw );
01134
01139 void RegisterResourceProvider( CAknResourceProvider* aProvider );
01140
01144 void UnregisterResourceProvider();
01145
01146 CAknsFrameBackgroundControlContext* BgContext();
01147
01152 void RemoveCurrentState();
01153
01160 TRect TouchArea() const;
01161
01162 protected:
01163
01169 IMPORT_C CAknButton( const TInt aFlags );
01170
01174 IMPORT_C void ConstructL();
01175
01187 IMPORT_C void ConstructL( CGulIcon* aIcon,
01188 CGulIcon* aDimmedIcon,
01189 CGulIcon* aPressedIcon,
01190 CGulIcon* aHoverIcon,
01191 const TDesC& aText,
01192 const TDesC& aHelpText,
01193 const TInt aStateFlags );
01194
01219 IMPORT_C void ConstructL( const TDesC& aFilePath,
01220 const TInt aBmpId,
01221 const TInt aMaskId,
01222 const TInt aDimmedBmpId,
01223 const TInt aDimmedMaskId,
01224 const TInt aPressedBmpId,
01225 const TInt aPressedMaskId,
01226 const TInt aHoverBmpId,
01227 const TInt aHoverMaskId,
01228 const TDesC& aText,
01229 const TDesC& aHelpText,
01230 const TInt aStateFlags,
01231 const TAknsItemID& aId = KAknsIIDNone,
01232 const TAknsItemID& aDimmedId = KAknsIIDNone,
01233 const TAknsItemID& aPressedId = KAknsIIDNone,
01234 const TAknsItemID& aHoverId = KAknsIIDNone );
01235
01236 protected:
01237
01242 IMPORT_C void SizeChanged();
01243
01249 IMPORT_C void FocusChanged( TDrawNow aDrawNow );
01250
01256 IMPORT_C void* ExtensionInterface( TUid aInterface );
01257
01258 protected:
01259
01265 IMPORT_C TInt ChangeState( TBool aDrawNow );
01266
01271 IMPORT_C const TDesC& GetCurrentText() const;
01272
01276 IMPORT_C const CGulIcon* GetCurrentIcon() const;
01277
01281 IMPORT_C void ShowHelpL();
01282
01286 IMPORT_C void HideHelp();
01287
01288
01289 private:
01290
01294 IMPORT_C void Draw( const TRect& aRect ) const;
01295
01296 private:
01297
01301 void DrawTextButton( CWindowGc& aGc ) const;
01302
01306 void DrawIconButton( CWindowGc& aGc ) const;
01307
01311 void DrawTextAndIconButton( CWindowGc& aGc ) const;
01312
01316 void DrawMaskedL( CWindowGc& aGc ) const;
01317
01321 void StartLongPressTimerL();
01322
01326 void StopLongPressTimer();
01327
01331 void StartKeyRepeatTimerL();
01332
01336 void StopKeyRepeatTimer();
01337
01341 static TInt ReportKeyRepeatL( TAny* aThis );
01342
01348 CAknButtonExtension* Extension() const;
01349
01353 void UpdateTooltipPosition();
01354
01361 TBool RequestExit() const;
01362
01368 TRect ContentRect() const;
01369
01375 TBool NeedsRedrawWhenPressed() const;
01376
01380 TAknsItemID SkinIID( const TInt aIndex ) const;
01381
01385 void CalculateDefaultMargins();
01386
01392 TInt ScaleIcons();
01393
01399 TRgb TextColor() const;
01400
01405 void CreatePressedDownFrameL();
01406
01410 TInt CalculateLuminance( const TRgb& aColor ) const;
01411
01418 void ConvertColorsForOutlineEffect( TRgb& aFillColor, TRgb& aOutlineColor ) const;
01419
01426 void GetTextColors( TRgb& aPenColor, TRgb& aBrushColor ) const;
01427
01433 void SetStateIndexL( TInt aNewIndex );
01434
01435 protected:
01436
01437
01438 CArrayPtrFlat<CAknButtonState>* iStates;
01439
01440
01441 TInt iFlags;
01442
01443
01444 TInt iStateIndex;
01445
01446
01447 TBool iButtonPressed;
01448
01449
01450
01451 TInt iNumberOfDragEvents;
01452
01453
01454
01455
01456
01457 TBool iKeyDownReported;
01458
01459
01460 CAknsFrameBackgroundControlContext* iBgContext;
01461
01462
01463
01464 TRect iHighlightRect;
01465
01466
01467 const CFont* iFont;
01468 TAlignment iVerticalAlignment;
01469 CGraphicsContext::TTextAlign iHorizontalAlignment;
01470 TAknsItemID iTextColorTableId;
01471 TInt iTextColorIndex;
01472
01473
01474 TScaleMode iScaleMode;
01475
01476
01477 TInt iHelpNoteWaitInterval;
01478 TInt iHelpNoteInViewInterval;
01479 CAknInfoPopupNoteController* iHelpNote;
01480 HBufC* iDimmedHelpText;
01481 TBool iShowHelp;
01482
01483
01484 CPeriodic* iKeyRepeatTimer;
01485 TInt iKeyRepeatDelay;
01486 TInt iKeyRepeatInterval;
01487
01488 private:
01489 CAknButtonExtension* iExtension;
01490
01491 };
01492
01493
01494 #endif // __AKNBUTTON_H__
01495
01496