textinput/peninputcommonctrls/inc/peninputselectionlist/peninputscrollablelist.h
branchRCL_3
changeset 44 ecbabf52600f
equal deleted inserted replaced
43:ebd48d2de13c 44:ecbabf52600f
       
     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     void ScrollPageUp();
       
   125     
       
   126     void ScrollPageDown();
       
   127 
       
   128     IMPORT_C void Move(const TPoint& aOffset);
       
   129                             
       
   130 private:
       
   131     void CalcPageInfo();
       
   132 protected:
       
   133     //from MEventObserver
       
   134     IMPORT_C void HandleControlEvent(TInt aEventType, CFepUiBaseCtrl* aCtrl,
       
   135                             const TDesC& aEventData);
       
   136                             
       
   137     IMPORT_C void UpdatePageInfoL( TInt aCurrentPage, TInt aTotalPage );                        
       
   138 	
       
   139 #ifdef RD_TACTILE_FEEDBACK	
       
   140 	// Update tactile feedback area when scroll page up and down.
       
   141 	void UpdateFeedbackArea();
       
   142 #endif // RD_TACTILE_FEEDBACK
       
   143 	
       
   144 protected:
       
   145     TPoint iTopLeftPoint;
       
   146     TSize iItemSize;
       
   147     TSize iNaviSize;
       
   148     TSize iNaviInnerSize;
       
   149     TInt iHorizontalMargin;
       
   150     TInt iVerticalMargin;
       
   151     TInt iBaselineOffset;
       
   152     const CFont* iFont;
       
   153     TRgb iFontColor;
       
   154     TAknTextLineLayout iTextLine;
       
   155     TBool iTextLineSet;    
       
   156     TAknTextLineLayout iPageInfoTextLine;
       
   157     TBool iPageInfoLineSet;
       
   158 
       
   159     RPointerArray<CFbsBitmap> iBmpList;
       
   160 
       
   161     TAknsItemID iBgFrId;
       
   162     // used for special item
       
   163     TAknsItemID iItemFrId;
       
   164     TAknsItemID iItemActiveFrId;
       
   165 
       
   166     TBool iSpecialItemOn;
       
   167     TBool iNaviBtnShown;
       
   168 
       
   169     HBufC* iPageInfoFormat;
       
   170     HBufC* iPageInfo;
       
   171     TInt iCurrentPage;
       
   172     TInt iTotalPages;
       
   173 
       
   174     //TPoint iTlPos;
       
   175     TInt iOnePageItemCnt;
       
   176     TRect iContentRect;
       
   177     TRect iScrollRect;
       
   178     TRect iPageUpRect;
       
   179     TRect iPageDownRect;
       
   180     TRect iPageInfoRect;
       
   181     RArray<TRect> iItemRects;
       
   182     CAknFepCtrlCommonButton* iPageUp;
       
   183     CAknFepCtrlCommonButton* iPageDown;
       
   184     
       
   185     // List speration 
       
   186     TRect iSeperationRect;
       
   187     CFbsBitmap* iSeperationBmp;	//own
       
   188     CFbsBitmap* iSeperationMaskBmp; // own
       
   189     
       
   190     // Res ID of page info
       
   191     TInt iPageInfoResID;
       
   192     
       
   193     TRect iLastPageItemRect;
       
   194     TInt iInitItemWidth;
       
   195     };
       
   196 
       
   197 inline void CFepLayoutScrollableList::SetTextLineLayout(TAknTextLineLayout aTextLine)
       
   198     {
       
   199     iTextLine = aTextLine;
       
   200     iTextLineSet = ETrue;
       
   201     }
       
   202 inline void CFepLayoutScrollableList::SetPageInfoTextLineLayout(TAknTextLineLayout aTextLine)
       
   203     {
       
   204     iPageInfoTextLine = aTextLine;
       
   205     iPageInfoLineSet = ETrue;
       
   206     }
       
   207 
       
   208 inline void CFepLayoutScrollableList::SetPageInfoFormatL(const TDesC& aFormat)
       
   209     {
       
   210     delete iPageInfoFormat;
       
   211     iPageInfoFormat = NULL;
       
   212     iPageInfoFormat = aFormat.AllocL();
       
   213 
       
   214     // on the assumption that page info do not beyond 100
       
   215     delete iPageInfo;
       
   216     iPageInfo = NULL;
       
   217     iPageInfo = HBufC::NewL(aFormat.Length() + 6);
       
   218     }
       
   219 
       
   220 inline void CFepLayoutScrollableList::SetOnePageItemCount(TInt aItemCount)
       
   221     {
       
   222     iOnePageItemCnt = aItemCount;
       
   223     }
       
   224 
       
   225 inline void CFepLayoutScrollableList::SetSpecialItemOn(TBool aOn)
       
   226     {
       
   227     iSpecialItemOn = aOn;
       
   228     }
       
   229 
       
   230 inline TInt CFepLayoutScrollableList::CtrlWidthExceptItem()
       
   231     {
       
   232     return 4*iHorizontalMargin + iNaviSize.iWidth;
       
   233     }
       
   234 
       
   235 inline TInt CFepLayoutScrollableList::CtrlHeight()
       
   236     {
       
   237     return (iOnePageItemCnt + 1)*iVerticalMargin + iOnePageItemCnt*iItemSize.iHeight;
       
   238     }
       
   239 
       
   240 inline void CFepLayoutScrollableList::SetPageInfoResID( TInt aResID )	
       
   241 	{
       
   242 	iPageInfoResID = aResID;	
       
   243 	}
       
   244 #endif //C_FEPLAYOUTSCROLLABLELIST_H