textinput/peninputcommonctrls/inc/peninputselectionlist/peninputscrollablelist.h
changeset 40 2cb9bae34d17
parent 31 f1bdd6b078d1
child 49 37f5d84451bd
equal deleted inserted replaced
31:f1bdd6b078d1 40:2cb9bae34d17
     1 /*
       
     2 * Copyright (c) 2008-2008 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:  header file of button and dragbar
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef C_FEPLAYOUTSCROLLABLELIST_H
       
    19 #define C_FEPLAYOUTSCROLLABLELIST_H
       
    20 
       
    21 #include <peninputlayoutchoicelist.h>
       
    22 #include <AknLayout2Def.h>
       
    23 #include <AknsConstants.h>
       
    24 #include <e32cmn.h>
       
    25 
       
    26 #define FORMATPAGEINFO(des, ktxt, parm...) {des.Format(ktxt, parm);};
       
    27 
       
    28 class CAknFepCtrlCommonButton;
       
    29 
       
    30 class CFepLayoutScrollableList : public CFepLayoutChoiceList, public MEventObserver
       
    31     {
       
    32 public:
       
    33     IMPORT_C static CFepLayoutScrollableList* NewL(CFepUiLayout* aUiLayout,
       
    34                                                    TInt aControlId,
       
    35                                                    TSize aItemSize,
       
    36                                                    TInt aHorizontalMargin,
       
    37                                                    TInt aVerticalMargin,
       
    38                                                    TSize aNaviSize,
       
    39                                                    TSize aNaviInnerSize);
       
    40 
       
    41     IMPORT_C static CFepLayoutScrollableList* NewLC(CFepUiLayout* aUiLayout,
       
    42                                                     TInt aControlId,
       
    43                                                     TSize aItemSize,
       
    44                                                     TInt aHorizontalMargin,
       
    45                                                     TInt aVerticalMargin,
       
    46                                                     TSize aNaviSize,
       
    47                                                     TSize aNaviInnerSize);
       
    48 
       
    49     IMPORT_C virtual ~CFepLayoutScrollableList();
       
    50 
       
    51     IMPORT_C void ConstructFromResourceL();
       
    52 
       
    53     IMPORT_C void SizeChanged(TSize aItemSize,
       
    54                               TInt aHorizontalMargin,
       
    55                               TInt aVerticalMargin,
       
    56                               TSize aNaviSize,
       
    57                               TSize aNaviInnerSize);
       
    58 
       
    59     IMPORT_C void SetTextProperty(const CFont* aFont,
       
    60                                   TRgb aFontColor);
       
    61 
       
    62     IMPORT_C void SetImgFrId(TAknsItemID aBgFrId, 
       
    63                            TAknsItemID aNaviFrId,
       
    64                            TAknsItemID aNaviActiveFrId,
       
    65                            TAknsItemID aNaviDimFrId,
       
    66                            TAknsItemID aItemFrId,
       
    67                            TAknsItemID aItemActiveFrId);
       
    68 
       
    69     inline void SetTextLineLayout(TAknTextLineLayout aTextLine);
       
    70 
       
    71     inline void SetPageInfoTextLineLayout(TAknTextLineLayout aTextLine);
       
    72     inline void SetPageInfoFormatL(const TDesC& aFormat);
       
    73 
       
    74     // if current page include special item, the count also include
       
    75     // special item
       
    76     inline void SetOnePageItemCount(TInt aItemCount);
       
    77 
       
    78     inline void SetSpecialItemOn(TBool aOn);
       
    79 
       
    80     // get whole control width except item width
       
    81     inline TInt CtrlWidthExceptItem();
       
    82 
       
    83     // get whole control height
       
    84     inline TInt CtrlHeight();
       
    85 
       
    86     IMPORT_C void Draw();
       
    87     
       
    88     IMPORT_C void ReCalcLayout();
       
    89     
       
    90     IMPORT_C void UpdateNaviButtonStates();
       
    91 	
       
    92 	IMPORT_C void SetListSeperationRect( const TRect& aRect );
       
    93 	
       
    94 	inline void SetPageInfoResID( TInt aResID );
       
    95 
       
    96     /**
       
    97      * Hide or shoe control. A hiden control will not handle the event.
       
    98      *
       
    99      * @since S60 V4.0
       
   100      * @param aFlag ETrue if want to hide the control.
       
   101      */                                               
       
   102     IMPORT_C virtual void Hide(TBool aFlag);
       
   103     
       
   104 protected:
       
   105 
       
   106     IMPORT_C CFepLayoutScrollableList(CFepUiLayout* aUiLayout,
       
   107                              TInt aControlId,
       
   108                              TSize aItemSize,
       
   109                              TInt aHorizontalMargin,                             
       
   110                              TInt aVerticalMargin,
       
   111                              TSize aNaviSize,
       
   112                              TSize aNaviInnerSize);
       
   113 
       
   114     IMPORT_C void ConstructL(); 
       
   115     
       
   116     IMPORT_C TInt HitTest(const TPoint& aPoint);
       
   117 
       
   118     IMPORT_C virtual void DrawItem(TInt aItemIndex, TBool aItemActive = EFalse);
       
   119 
       
   120     IMPORT_C virtual void CalculateItemWidth();
       
   121     
       
   122     IMPORT_C virtual void DrawPageInfo();
       
   123 
       
   124 
       
   125     void ScrollPageUp();
       
   126     
       
   127     void ScrollPageDown();
       
   128 
       
   129     IMPORT_C void Move(const TPoint& aOffset);
       
   130                             
       
   131 private:
       
   132     void CalcPageInfo();
       
   133 protected:
       
   134     //from MEventObserver
       
   135     IMPORT_C void HandleControlEvent(TInt aEventType, CFepUiBaseCtrl* aCtrl,
       
   136                             const TDesC& aEventData);
       
   137                             
       
   138     IMPORT_C void UpdatePageInfoL( TInt aCurrentPage, TInt aTotalPage );                        
       
   139 	
       
   140 #ifdef RD_TACTILE_FEEDBACK	
       
   141 	// Update tactile feedback area when scroll page up and down.
       
   142 	void UpdateFeedbackArea();
       
   143 #endif // RD_TACTILE_FEEDBACK
       
   144 	
       
   145 protected:
       
   146     TPoint iTopLeftPoint;
       
   147     TSize iItemSize;
       
   148     TSize iNaviSize;
       
   149     TSize iNaviInnerSize;
       
   150     TInt iHorizontalMargin;
       
   151     TInt iVerticalMargin;
       
   152     TInt iBaselineOffset;
       
   153     const CFont* iFont;
       
   154     TRgb iFontColor;
       
   155     TAknTextLineLayout iTextLine;
       
   156     TBool iTextLineSet;    
       
   157     TAknTextLineLayout iPageInfoTextLine;
       
   158     TBool iPageInfoLineSet;
       
   159 
       
   160     RPointerArray<CFbsBitmap> iBmpList;
       
   161 
       
   162     TAknsItemID iBgFrId;
       
   163     // used for special item
       
   164     TAknsItemID iItemFrId;
       
   165     TAknsItemID iItemActiveFrId;
       
   166 
       
   167     TBool iSpecialItemOn;
       
   168     TBool iNaviBtnShown;
       
   169 
       
   170     HBufC* iPageInfoFormat;
       
   171     HBufC* iPageInfo;
       
   172     TInt iCurrentPage;
       
   173     TInt iTotalPages;
       
   174 
       
   175     //TPoint iTlPos;
       
   176     TInt iOnePageItemCnt;
       
   177     TRect iContentRect;
       
   178     TRect iScrollRect;
       
   179     TRect iPageUpRect;
       
   180     TRect iPageDownRect;
       
   181     TRect iPageInfoRect;
       
   182     RArray<TRect> iItemRects;
       
   183     CAknFepCtrlCommonButton* iPageUp;
       
   184     CAknFepCtrlCommonButton* iPageDown;
       
   185     
       
   186     // List speration 
       
   187     TRect iSeperationRect;
       
   188     CFbsBitmap* iSeperationBmp;	//own
       
   189     CFbsBitmap* iSeperationMaskBmp; // own
       
   190     
       
   191     // Res ID of page info
       
   192     TInt iPageInfoResID;
       
   193     
       
   194     TRect iLastPageItemRect;
       
   195     TInt iInitItemWidth;
       
   196     };
       
   197 
       
   198 inline void CFepLayoutScrollableList::SetTextLineLayout(TAknTextLineLayout aTextLine)
       
   199     {
       
   200     iTextLine = aTextLine;
       
   201     iTextLineSet = ETrue;
       
   202     }
       
   203 inline void CFepLayoutScrollableList::SetPageInfoTextLineLayout(TAknTextLineLayout aTextLine)
       
   204     {
       
   205     iPageInfoTextLine = aTextLine;
       
   206     iPageInfoLineSet = ETrue;
       
   207     }
       
   208 
       
   209 inline void CFepLayoutScrollableList::SetPageInfoFormatL(const TDesC& aFormat)
       
   210     {
       
   211     delete iPageInfoFormat;
       
   212     iPageInfoFormat = NULL;
       
   213     iPageInfoFormat = aFormat.AllocL();
       
   214 
       
   215     // on the assumption that page info do not beyond 100
       
   216     delete iPageInfo;
       
   217     iPageInfo = NULL;
       
   218     iPageInfo = HBufC::NewL(aFormat.Length() + 6);
       
   219     }
       
   220 
       
   221 inline void CFepLayoutScrollableList::SetOnePageItemCount(TInt aItemCount)
       
   222     {
       
   223     iOnePageItemCnt = aItemCount;
       
   224     }
       
   225 
       
   226 inline void CFepLayoutScrollableList::SetSpecialItemOn(TBool aOn)
       
   227     {
       
   228     iSpecialItemOn = aOn;
       
   229     }
       
   230 
       
   231 inline TInt CFepLayoutScrollableList::CtrlWidthExceptItem()
       
   232     {
       
   233     return 4*iHorizontalMargin + iNaviSize.iWidth;
       
   234     }
       
   235 
       
   236 inline TInt CFepLayoutScrollableList::CtrlHeight()
       
   237     {
       
   238     return (iOnePageItemCnt + 1)*iVerticalMargin + iOnePageItemCnt*iItemSize.iHeight;
       
   239     }
       
   240 
       
   241 inline void CFepLayoutScrollableList::SetPageInfoResID( TInt aResID )	
       
   242 	{
       
   243 	iPageInfoResID = aResID;	
       
   244 	}
       
   245 #endif //C_FEPLAYOUTSCROLLABLELIST_H