textinput/peninputcommonctrls/inc/peninputbuttons/peninputdragbutton.h
changeset 27 694fa80c203c
parent 24 fc42a86c98e3
child 35 0f326f2e628e
equal deleted inserted replaced
24:fc42a86c98e3 27:694fa80c203c
     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_CAKNFEPCTRLDRAGBUTTON_H
       
    20 #define C_CAKNFEPCTRLDRAGBUTTON_H
       
    21 
       
    22 // system includes
       
    23 #include <AknsConstants.h>
       
    24 #include <AknLayout2Def.h>
       
    25 #include <peninputlayoutbasecontrol.h>
       
    26 #include <peninputlayoutbutton.h>
       
    27 
       
    28 // forward declarations
       
    29 class TResourceReader;
       
    30 
       
    31 /**
       
    32  *  Basic functionality for drag button
       
    33  *  It provides creation from resource and can react according to SizeChanged Msg
       
    34  *
       
    35  *  @lib fepcommonctrls.lib
       
    36  *  @since S60 v3.2
       
    37  */
       
    38 class CAknFepCtrlDragButton : public CDragBar
       
    39     {
       
    40 public:  
       
    41     
       
    42     /**
       
    43      * Symbian constructor.
       
    44      *
       
    45      * @since S60 v3.2
       
    46      * @param aUiLayout The Ui layout
       
    47      * @param aControlId The control id
       
    48      * @return Pointer to created CAknFepCtrlDragButton object
       
    49      */
       
    50     IMPORT_C static CAknFepCtrlDragButton* NewL(CFepUiLayout* aUiLayout, TInt aControlId);
       
    51     
       
    52     /**
       
    53      * Symbian constructor.
       
    54      *
       
    55      * @since S60 v3.2
       
    56      * @param aUiLayout The Ui layout
       
    57      * @param aControlId The control id
       
    58      * @return Pointer to created CAknFepCtrlDragButton object
       
    59      */
       
    60     IMPORT_C static CAknFepCtrlDragButton* NewLC(CFepUiLayout* aUiLayout, TInt aControlId);
       
    61    
       
    62     /**
       
    63      * destructor.
       
    64      *
       
    65      * @since S60 v3.2
       
    66      * @return None
       
    67      */
       
    68     IMPORT_C virtual ~CAknFepCtrlDragButton();
       
    69        
       
    70     /**
       
    71      * This function creates the button from resource.
       
    72      *
       
    73      * @since S60 v3.2
       
    74      * @param aReader A Reader which is created against the AKN_FEP_BUTTON resource type
       
    75      * @return None
       
    76      */
       
    77     IMPORT_C void ConstructFromResourceL(TResourceReader& aReader);
       
    78     
       
    79     /**
       
    80      * This function creates button from resource, before calling 
       
    81      * this function, caller should set resource id of button first
       
    82      * 
       
    83      * @since S60 v3.2
       
    84      * @return None
       
    85      */
       
    86     IMPORT_C void ConstructFromResourceL();
       
    87     
       
    88     /**
       
    89      * This function handles the SizeChanged event, it resizes all images and rects
       
    90      *
       
    91      * @since S60 v3.2
       
    92      * @param aRect New button extent
       
    93      * @param aIsReloadImages ETrue for resizing images; otherwise EFalse
       
    94      * @return None
       
    95      */
       
    96     IMPORT_C void SizeChanged(TRect aRect, TRect aInnerRect = TRect(), 
       
    97                               TBool aIsReloadImages = EFalse);
       
    98 
       
    99 	/**
       
   100      * Set Forground bitmap position
       
   101      *
       
   102      * @since S60 v3.2
       
   103      * @param aRect Forground bitmap position
       
   104      * @return None
       
   105      */
       
   106 	IMPORT_C void SetForgroundBmpRect(const TRect& aRect);
       
   107 
       
   108     IMPORT_C void SetForegroundBmpL(CFbsBitmap* aBmp,
       
   109 	                                  CFbsBitmap* aMaskBmp);
       
   110 
       
   111     /**
       
   112      * Draws UI
       
   113      *
       
   114      * @since S60 v3.2
       
   115      * @return None
       
   116      */
       
   117     IMPORT_C void Draw();
       
   118 
       
   119 	IMPORT_C void Move(const TPoint& aOffset);
       
   120 
       
   121     /**
       
   122      * From CFepUiBaseCtrl
       
   123      * Handle pointer down event
       
   124      *
       
   125      * @since S60 V4.0
       
   126      * @param aPoint The point position relative the layout
       
   127      * @return The control which handles the event.     
       
   128      */                                        
       
   129     IMPORT_C virtual CFepUiBaseCtrl* HandlePointerDownEventL(const TPoint& aPoint);
       
   130 
       
   131 	/**
       
   132      * Set text line layout
       
   133      *
       
   134      * @since S60 V4.0
       
   135      * @param aTextFormat Text line layout to be set
       
   136  	 * @return None
       
   137      */                  	
       
   138     inline void SetTextFormat(TAknTextLineLayout aTextFormat);
       
   139     
       
   140 	/**
       
   141      * Set text to be shown on button
       
   142      *
       
   143      * @since S60 V4.0
       
   144      * @param aText Text to be shown on button
       
   145  	 * @return None
       
   146      */
       
   147     inline void SetTextL(const TDesC& aText);
       
   148 
       
   149     inline void SetImageFrameId( TAknsItemID aNormalID,
       
   150     							 TAknsItemID aPressedID,
       
   151     							 TAknsItemID aInactiveID );
       
   152 protected:
       
   153 
       
   154     /**
       
   155      * C++ default constructor.
       
   156      *
       
   157      * @since S60 v3.2
       
   158      * @param aUiLayout The Ui layout
       
   159      * @param aControlId The control id
       
   160      * @return None
       
   161      */
       
   162     IMPORT_C CAknFepCtrlDragButton(CFepUiLayout* aUiLayout, TInt aControlId);
       
   163     
       
   164     
       
   165     
       
   166     void ResizeBitmaps(TSize aSize);
       
   167     
       
   168     void DeleteForgroundRes();
       
   169     
       
   170     void CreateDimmedMaskL( CFbsBitmap*& aDimmedMask,
       
   171                             const CFbsBitmap* aMask
       
   172                         	/*TScaleMode aScaleMode*/ );
       
   173     
       
   174 
       
   175 private:
       
   176     /**
       
   177      * Array of background bmp (not own)
       
   178      */
       
   179     RPointerArray<CFbsBitmap> iBmpList;
       
   180     
       
   181     /**
       
   182      * Array of background mask bmp (not own)
       
   183      */
       
   184     RPointerArray<CFbsBitmap> iMaskBmpList;
       
   185 
       
   186     /**
       
   187      * The first time construct flag of button
       
   188      */
       
   189     TBool iFirstTimeConstruct;
       
   190     
       
   191     /**
       
   192      * Froground bitmap and it's mask
       
   193      */
       
   194     CFbsBitmap* iForgroundBmp;
       
   195     CFbsBitmap* iForgroundBmpMask;
       
   196     
       
   197     /**
       
   198      * Froground Dimmed bitmap's mask
       
   199      */
       
   200     CFbsBitmap* iForgroundDimBmpMask;
       
   201     
       
   202     /**
       
   203      * Froground bitmap's position
       
   204      */
       
   205     TRect iForgroundBmpRect;
       
   206     
       
   207     /**
       
   208      * The img ID of button in various states
       
   209      */
       
   210     TAknsItemID iNormalImgID;
       
   211     TAknsItemID iPressedImgID;
       
   212     TAknsItemID iInactiveImgID;
       
   213 
       
   214     HBufC* iText;
       
   215     TAknTextLineLayout iTextFormat;    
       
   216     };
       
   217     
       
   218 
       
   219 inline void CAknFepCtrlDragButton::SetTextFormat(TAknTextLineLayout aTextFormat)
       
   220     {
       
   221     iTextFormat = aTextFormat;
       
   222     }
       
   223 
       
   224 inline void CAknFepCtrlDragButton::SetTextL(const TDesC& aText)
       
   225     {
       
   226     delete iText;
       
   227     iText = NULL;
       
   228     iText = aText.AllocL();
       
   229     }
       
   230 
       
   231 inline void CAknFepCtrlDragButton::SetImageFrameId( TAknsItemID aNormalID,
       
   232                                                       TAknsItemID aPressedID,
       
   233                                                       TAknsItemID aInactiveID )
       
   234     {
       
   235     iNormalImgID = aNormalID;
       
   236     iPressedImgID = aPressedID;
       
   237     iInactiveImgID = aInactiveID;
       
   238     }    
       
   239 
       
   240 #endif // C_CAKNFEPCTRLDRAGBUTTON_H
       
   241 
       
   242 // End Of File