textinput/peninputcommonctrls/inc/peninputbuttons/peninputcommonbutton.h
changeset 40 2cb9bae34d17
parent 31 f1bdd6b078d1
child 49 37f5d84451bd
equal deleted inserted replaced
31:f1bdd6b078d1 40:2cb9bae34d17
     1 /*
       
     2 * Copyright (c) 2002-2005 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:  Interface of normal button and multidisplay button
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CAKNFEPCTRLCOMMONBUTTON_H
       
    20 #define C_CAKNFEPCTRLCOMMONBUTTON_H
       
    21 
       
    22 // system includes
       
    23 #include <AknsConstants.h>
       
    24 #include <peninputlayoutbasecontrol.h>
       
    25 #include <peninputlayoutbutton.h>
       
    26 #include <AknLayout2Def.h>
       
    27 #include <peninputpluginutils.h>
       
    28 
       
    29 // forward declarations
       
    30 class TResourceReader;
       
    31 
       
    32 struct TDraw3PiecesFrame
       
    33 	{
       
    34     TAknsItemID iImgLeftID;
       
    35     TAknsItemID iImgMiddleID;
       
    36     TAknsItemID iImgRightID;
       
    37 	TRect iInnerRect;
       
    38 	    
       
    39     TDraw3PiecesFrame(TAknsItemID aImgLeftID,
       
    40     					  TAknsItemID aImgMiddleID,
       
    41     					  TAknsItemID aImgRightID,
       
    42     					  TRect aInnerRect)
       
    43     	{
       
    44     	
       
    45     	iImgLeftID = aImgLeftID;
       
    46     	iImgMiddleID = aImgMiddleID;
       
    47     	iImgRightID = aImgRightID;
       
    48     		 
       
    49     	iInnerRect = aInnerRect;
       
    50     		
       
    51     	};
       
    52     	
       
    53     TDraw3PiecesFrame()
       
    54     	{
       
    55     	
       
    56     	};
       
    57 	};    
       
    58 
       
    59 // class declarations
       
    60 /**
       
    61  *  Basic functionality for graphic buttons
       
    62  *  It provides creation from resource and can react according to SizeChanged Msg
       
    63  *
       
    64  *  @lib fepcommonctrls.lib
       
    65  *  @since S60 v3.2
       
    66  */
       
    67 class CAknFepCtrlCommonButton : public CButtonBase
       
    68     {
       
    69 public: 
       
    70         
       
    71     /**
       
    72      * Two-phased constructor.
       
    73      *
       
    74      * @since S60 v3.2
       
    75      * @param aUiLayout An instance of CFepUiLayout
       
    76      * @param aControlId The control id of input range button
       
    77      * @return The pointer point to CAknFepCtrlCommonButton type object
       
    78      */
       
    79     IMPORT_C static CAknFepCtrlCommonButton* NewL(CFepUiLayout* aUiLayout, 
       
    80     						TInt aControlId,
       
    81     						TAknsItemID aNormalID,
       
    82     						TAknsItemID aPressedID,
       
    83     						TAknsItemID aInactiveID);
       
    84         
       
    85     /**
       
    86      * Two-phased constructor.
       
    87      *
       
    88      * @since S60 v3.2
       
    89      * @param aUiLayout An instance of CFepUiLayout
       
    90      * @param aControlId The control id of input range button
       
    91      * @return The pointer point to CAknFepCtrlCommonButton type object
       
    92      */
       
    93     IMPORT_C static CAknFepCtrlCommonButton* NewLC(CFepUiLayout* aUiLayout, 
       
    94     						TInt aControlId,
       
    95 							TAknsItemID aNormalID,
       
    96     						TAknsItemID aPressedID,
       
    97     						TAknsItemID aInactiveID);
       
    98     /**
       
    99      * Destructor.
       
   100      *
       
   101      * @since S60 v3.2
       
   102      */
       
   103     IMPORT_C virtual ~CAknFepCtrlCommonButton();
       
   104 
       
   105     /**
       
   106      * This function creates the input range button from resource.
       
   107      *
       
   108      * @since S60 v3.2
       
   109      * @param aReader A Reader which is created against the AKN_FEP_BUTTON resource type
       
   110      * @return None
       
   111      */
       
   112     IMPORT_C void ConstructFromResourceL(TResourceReader& aReader);
       
   113     
       
   114     /**
       
   115      * This function creates the input range button from resource,
       
   116      * before calling this function, caller should set resource id of 
       
   117      * range button first
       
   118      * 
       
   119      * @since S60 v3.2
       
   120      * @return None
       
   121      */
       
   122     IMPORT_C void ConstructFromResourceL();
       
   123 
       
   124     /**
       
   125      * This function handles the SizeChanged event, it resizes all images and rects
       
   126      *
       
   127      * @since S60 v3.2
       
   128      * @param aRect New button extent
       
   129      * @param aInnerRect New button inner
       
   130      * @param aIsReloadImages Whether resize images as well, 
       
   131      * if only the position of the button changed, no need to reset the images as well
       
   132      * @return Nothing
       
   133      */
       
   134     IMPORT_C void SizeChanged(TRect aRect, TRect aInnerRect, TBool aIsReloadImages = EFalse);
       
   135 
       
   136     /**
       
   137      * Draws UI
       
   138      *
       
   139      * @since S60 v3.2
       
   140      * @return None
       
   141      */
       
   142     IMPORT_C void Draw();
       
   143 
       
   144     /**
       
   145      * Set active for this button
       
   146      *
       
   147      * @since S60 v3.2
       
   148      * @param aActiveFlag active the button or desactive it
       
   149      * @return None
       
   150      */
       
   151     IMPORT_C void SetActive(TBool aActiveFlag);
       
   152 
       
   153     /**
       
   154      * Set high light for the button
       
   155      *
       
   156      * @since S60 v3.2
       
   157      * @param aIsHighlight highlight the button or cancel high light it
       
   158      * @return None
       
   159      */
       
   160     IMPORT_C void SetHighlight(TBool aIsHighlight);
       
   161 	
       
   162 	/**
       
   163      * Set Forground bitmap position
       
   164      *
       
   165      * @since S60 v3.2
       
   166      * @param aRect Forground bitmap position
       
   167      * @return None
       
   168      */
       
   169 	IMPORT_C void SetForgroundBmpRect(const TRect& aRect);
       
   170 
       
   171     IMPORT_C void SetForegroundBmpL(CFbsBitmap* aBmp,
       
   172 	                                  CFbsBitmap* aMaskBmp);
       
   173 	         
       
   174     IMPORT_C void SetDraw3PieceFrameInfo(TDraw3PiecesFrame a3PiecesFrameInfo);
       
   175     
       
   176 	/**
       
   177      * Cancel pointer down state
       
   178      *
       
   179      * @since S60 v3.2
       
   180      * @return None
       
   181      */
       
   182     IMPORT_C void CancelPointerDownL();
       
   183     
       
   184 	/**
       
   185      * Set text line layout
       
   186      *
       
   187      * @since S60 V4.0
       
   188      * @param aTextFormat Text line layout to be set
       
   189  	 * @return None
       
   190      */                  	
       
   191     inline void SetTextFormat(TAknTextLineLayout aTextFormat);
       
   192     
       
   193 	/**
       
   194      * Set text to be shown on button
       
   195      *
       
   196      * @since S60 V4.0
       
   197      * @param aText Text to be shown on button
       
   198  	 * @return None
       
   199      */
       
   200     inline void SetTextL(const TDesC& aText);
       
   201 
       
   202     inline void SetImageFrameId( TAknsItemID aNormalID,
       
   203     							 TAknsItemID aPressedID,
       
   204     							 TAknsItemID aInactiveID );
       
   205     
       
   206     							 
       
   207 	inline void Set3PiecesColorIcons( CPenInput3PiecesColorIcons* aColorIcons ); 
       
   208 	
       
   209 	/**
       
   210      * Set text color group
       
   211      *
       
   212      * @since S60 V4.0
       
   213      * @param aColorGroup Text color group
       
   214  	 * @return None
       
   215      */
       
   216 	inline void SetTextColorIndex( TInt aColorGroup );   							 
       
   217 	inline TInt TextColorIndex() const;
       
   218 	
       
   219 	inline CFbsBitmap* ForgroundBmp();
       
   220     inline CFbsBitmap* ForgroundBmpMask();
       
   221     inline const TRect& ForgroundBmpRect() const;
       
   222 protected:
       
   223 
       
   224     /**
       
   225      * C++ default constructor.
       
   226      *
       
   227      * @since S60 v3.2
       
   228      * @param aUiLayout An instance of CFepUiLayout
       
   229      * @param aControlId The control id of input range button
       
   230      */
       
   231     IMPORT_C CAknFepCtrlCommonButton(CFepUiLayout* aUiLayout, 
       
   232     								 TInt aControlId,
       
   233     								 TAknsItemID aNormalID,
       
   234     								 TAknsItemID aPressedID,
       
   235     								 TAknsItemID aInactiveID);
       
   236 			
       
   237     
       
   238     void ResizeBitmaps(TSize aInnerSize);
       
   239     
       
   240     void DeleteForgroundRes();
       
   241     
       
   242     void CreateDimmedMaskL( CFbsBitmap*& aDimmedMask,
       
   243                             const CFbsBitmap* aMask
       
   244                         	/*TScaleMode aScaleMode*/ );
       
   245                         	
       
   246     /**
       
   247      * From CFepUiBaseCtrl
       
   248      * Handle pointer down event
       
   249      *
       
   250      * @since S60 V4.0
       
   251      * @param aPoint The point position relative the layout
       
   252      * @return The control which handles the event.     
       
   253      */                                        
       
   254     IMPORT_C virtual CFepUiBaseCtrl* HandlePointerDownEventL(const TPoint& aPoint);
       
   255 	
       
   256 	/**
       
   257      * From CFepUiBaseCtrl
       
   258      * Handle pointer up event
       
   259      *
       
   260      * @since S60 V4.0
       
   261      * @param aPoint The point position relative the layout
       
   262  	 * @return The control which handles the event
       
   263      */                  
       
   264     IMPORT_C virtual CFepUiBaseCtrl* HandlePointerUpEventL(const TPoint& aPoint);
       
   265 	
       
   266 	/**
       
   267      * From CFepUiBaseCtrl
       
   268      * Handle pointer up event
       
   269      *
       
   270      * @since S60 V4.0
       
   271      * @param aPoint The point position relative the layout
       
   272  	 * @return The control which handles the event
       
   273      */                  	
       
   274     IMPORT_C virtual void HandlePointerLeave(const TPoint& aPt);
       
   275     
       
   276     IMPORT_C virtual void HandlePointerEnter(const TPoint& aPt);
       
   277 	
       
   278     IMPORT_C void Move(const TPoint& aOffset);
       
   279 protected:
       
   280 
       
   281     /**
       
   282      * The first time construct flag of button
       
   283      */
       
   284     TBool iFirstTimeConstruct;
       
   285 
       
   286     /**
       
   287      * The highlight flag of the button
       
   288      */
       
   289     TBool iHighlight;
       
   290     
       
   291     TBool iPressed;
       
   292 
       
   293 private:
       
   294 
       
   295     /**
       
   296      * Froground bitmap and it's mask
       
   297      */
       
   298     CFbsBitmap* iForgroundBmp;
       
   299     CFbsBitmap* iForgroundBmpMask;
       
   300     
       
   301     /**
       
   302      * Froground Dimmed bitmap's mask
       
   303      */
       
   304     CFbsBitmap* iForgroundDimBmpMask;
       
   305     
       
   306     /**
       
   307      * Froground bitmap's position
       
   308      */
       
   309     TRect iForgroundBmpRect;
       
   310     
       
   311     /**
       
   312      * The img ID of button in various states
       
   313      */
       
   314     TAknsItemID iNormalImgID;
       
   315     TAknsItemID iPressedImgID;
       
   316     TAknsItemID iInactiveImgID;    
       
   317 
       
   318     HBufC* iText;
       
   319     TAknTextLineLayout iTextFormat;
       
   320     
       
   321     TDraw3PiecesFrame iDraw3PiecesInfo;
       
   322     /**
       
   323      * The 3 pieces color icon (owned)
       
   324      */    
       
   325     CPenInput3PiecesColorIcons* iColorIcons;
       
   326     /**
       
   327      * Text color index
       
   328      */
       
   329     TInt iTextColorIndex;
       
   330     };
       
   331 
       
   332 inline void CAknFepCtrlCommonButton::SetTextFormat(TAknTextLineLayout aTextFormat)
       
   333     {
       
   334     iTextFormat = aTextFormat;
       
   335     }
       
   336 
       
   337 inline void CAknFepCtrlCommonButton::SetTextL(const TDesC& aText)
       
   338     {
       
   339     delete iText;
       
   340     iText = NULL;
       
   341     iText = aText.AllocL();
       
   342     }
       
   343 
       
   344 inline void CAknFepCtrlCommonButton::SetImageFrameId( TAknsItemID aNormalID,
       
   345                                                       TAknsItemID aPressedID,
       
   346                                                       TAknsItemID aInactiveID )
       
   347     {
       
   348     iNormalImgID = aNormalID;
       
   349     iPressedImgID = aPressedID;
       
   350     iInactiveImgID = aInactiveID;
       
   351     }
       
   352     
       
   353 inline void CAknFepCtrlCommonButton::
       
   354 			Set3PiecesColorIcons( CPenInput3PiecesColorIcons* aColorIcons )
       
   355 	{
       
   356 	delete iColorIcons;
       
   357 	iColorIcons = aColorIcons;
       
   358 	}
       
   359 
       
   360 inline void CAknFepCtrlCommonButton::SetTextColorIndex( TInt aColorGroup )
       
   361 	{
       
   362 	iTextColorIndex = aColorGroup;
       
   363 	}
       
   364 	
       
   365 inline TInt CAknFepCtrlCommonButton::TextColorIndex() const
       
   366 	{
       
   367 	return iTextColorIndex;
       
   368 	}
       
   369 	
       
   370 inline CFbsBitmap* CAknFepCtrlCommonButton::ForgroundBmp()
       
   371     {
       
   372     return iForgroundBmp;
       
   373     }
       
   374 
       
   375 inline CFbsBitmap* CAknFepCtrlCommonButton::ForgroundBmpMask()
       
   376     {
       
   377     return iForgroundBmpMask;
       
   378     }
       
   379     		
       
   380 inline const TRect& CAknFepCtrlCommonButton::ForgroundBmpRect() const
       
   381 	{
       
   382 	return iForgroundBmpRect;
       
   383 	}    		
       
   384 #endif // C_CAKNFEPCTRLCOMMONBUTTON_H
       
   385             
       
   386 // End Of File