EIKLBV.H

Go to the documentation of this file.
00001 // EIKLBV.H
00002 //
00003 // Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
00004 //
00005 
00006 
00007 #if !defined(__EIKLBV_H__)
00008 #define __EIKLBV_H__
00009 
00010 #if !defined(__E32BASE_H__)
00011 #include <e32base.h>
00012 #endif
00013 
00014 #if !defined(__GDI_H__)
00015 #include <gdi.h>
00016 #endif
00017 
00018 class CListItemDrawer;
00019 class MListBoxModel;
00020 class CWindowGc;
00021 class RWindowGroup;
00022 class CWsScreenDevice;
00023 class CWindowGc;
00024 class RWindow;
00025 class CListBoxViewExtension;
00026 class CEikListBox;
00027 
00028 //
00029 // class MListVisibiltyObserver
00030 //
00031 
00032 class MListVisibilityObserver 
00033         {
00034 public:
00035         virtual TBool IsVisible() const = 0;
00036         };
00037 
00058 class CListBoxView : public CBase
00059         {
00060 public:
00061 
00066     enum TCursorMovement 
00067                 {
00069         ECursorNextItem,        
00070 
00072         ECursorPreviousItem,
00073 
00075         ECursorNextColumn,  
00076 
00078         ECursorPreviousColumn,  
00079 
00081         ECursorPreviousPage, 
00082 
00084         ECursorNextPage,
00085 
00087         ECursorFirstItem,
00088 
00090         ECursorLastItem,
00091 
00093         ECursorNextScreen,
00094 
00096         ECursorPrevScreen
00097         };  
00098 
00105         enum TFlags
00106                 {
00108                 EAnchorExists   = 0x0001,
00109 
00111                 EEmphasized     = 0x0002,
00112 
00114                 EDimmed         = 0x0004,
00115 
00117                 EHasMatcherCursor = 0x0008,
00118 
00120                 EDisableRedraw  = 0x0010,
00121 
00123                 EPaintedSelection = 0x0020,
00124 
00126                 EMarkSelection  = 0x0040,
00127 
00129                 EUnmarkSelection = 0x0080,
00130 
00132                 EItemCountModified = 0x0100
00133                 };
00134                 
00152     enum TSelectionMode 
00153         {
00158         ENoSelection,
00159     
00165         ESingleSelection,
00166 
00172         EContiguousSelection,
00173 
00179         EDisjointSelection,
00180 
00185         EDisjointMarkSelection,
00186 
00191         EPenMultiselection,
00192 
00198         EChangeMarkMode
00199         };
00200 
00202         typedef CArrayFix<TInt> CSelectionIndexArray;
00203 
00204 public:
00205 
00209         IMPORT_C ~CListBoxView();
00210 
00217     IMPORT_C CListBoxView();
00218 
00235     IMPORT_C virtual void ConstructL(MListBoxModel* aListBoxModel, 
00236                                      CListItemDrawer* aItemDrawer, 
00237                                      CWsScreenDevice* aScreen, 
00238                                      RWindowGroup* aGroupWin, 
00239                                      RWindow* aWsWindow, 
00240                                      const TRect& aDisplayArea, 
00241                                      TInt aItemHeight);
00242 
00243     // functions for accessing the view rect (the area of the host window in 
00244     // which the items are drawn)
00250     IMPORT_C TRect ViewRect() const;
00251 
00257         IMPORT_C void SetViewRect(const TRect& aRect);  
00258 
00259         // misc. access functions for the main attributes 
00265         IMPORT_C virtual TInt CurrentItemIndex() const; 
00266 
00275         IMPORT_C void SetCurrentItemIndex(TInt aItemIndex); 
00276 
00282         IMPORT_C TInt TopItemIndex() const;             
00283 
00292         IMPORT_C virtual void SetTopItemIndex(TInt aItemIndex);
00293 
00299         IMPORT_C TInt BottomItemIndex() const;
00300 
00308         IMPORT_C virtual void CalcBottomItemIndex();
00309 
00315         IMPORT_C virtual void SetItemHeight(TInt aItemHeight);
00316 
00317         // functions that support incremental matching 
00324         IMPORT_C void SetMatcherCursorColor(TRgb aColor);
00325 
00333         IMPORT_C void SetMatcherCursorPos(TInt aPosWithinCurrentItem);
00334 
00342         IMPORT_C TInt MatcherCursorPos() const;
00343 
00352         IMPORT_C virtual void DrawMatcherCursor();
00353 
00359         IMPORT_C void HideMatcherCursor();
00360 
00368         IMPORT_C void SetMatcherCursor(TBool aMatcherCursor);
00369 
00378         IMPORT_C void SetEmphasized(TBool aEmphasized);
00379 
00388         IMPORT_C void SetDimmed(TBool aDimmed);
00389 
00400         IMPORT_C void SetDisableRedraw(TBool aDisableRedraw);
00401 
00407         IMPORT_C TBool RedrawDisabled() const;
00408 
00417         IMPORT_C void SetPaintedSelection( TBool aPaintedSelection );
00418 
00419         // functions that support selection
00427     IMPORT_C const CSelectionIndexArray* SelectionIndexes() const;
00428 
00439         IMPORT_C void GetSelectionIndexesL(
00440                                 CSelectionIndexArray* aSelectionArray) const;
00441         
00450     IMPORT_C void SetSelectionIndexesL(const CSelectionIndexArray* 
00451                                        aSelectionIndexes);
00452         
00459     IMPORT_C void ClearSelection();             
00460         
00461     // select/highlight items without moving the cursor
00467     IMPORT_C virtual void UpdateSelectionL(TSelectionMode aSelectionMode);  
00468         
00476     IMPORT_C void ToggleItemL(TInt aItemIndex);
00477         
00488     IMPORT_C void SelectItemL(TInt aItemIndex);
00489         
00497     IMPORT_C void DeselectItem(TInt aItemIndex);
00498         
00504     IMPORT_C void SetAnchor(TInt aItemIndex);
00505         
00509     IMPORT_C void ClearSelectionAnchorAndActiveIndex();
00510 
00511         // functions that support scrolling
00519         IMPORT_C virtual TBool ScrollToMakeItemVisible(TInt aItemIndex);
00520     
00526         IMPORT_C virtual void VScrollTo(TInt aNewTopItemIndex);
00527 
00537     IMPORT_C virtual void VScrollTo(TInt aNewTopItemIndex, 
00538                                     TRect& aMinRedrawRect);
00539         
00546     IMPORT_C virtual void HScroll(TInt aHScrollAmount);
00547         
00554     IMPORT_C TInt HScrollOffset() const;
00555 
00562         IMPORT_C void SetHScrollOffset(TInt aHorizontalOffset);
00563 
00569         IMPORT_C TInt DataWidth() const;
00570 
00576         IMPORT_C virtual void CalcDataWidth();
00577 
00586         IMPORT_C virtual TInt VisibleWidth(const TRect& aRect) const;
00587 
00597     IMPORT_C virtual TInt CalcNewTopItemIndexSoItemIsVisible(
00598                                                         TInt aItemIndex) const;
00599 
00600         // functions that support drawing
00612         IMPORT_C virtual void Draw(const TRect* aClipRect = NULL) const;
00613 
00620         IMPORT_C virtual void DrawItem(TInt aItemIndex) const;
00621 
00628         IMPORT_C void SetListEmptyTextL(const TDesC& aText);
00629 
00635         inline const TDesC* EmptyListText() const;
00636 
00643     IMPORT_C TBool ItemIsSelected(TInt aItemIndex) const; 
00644 
00651         IMPORT_C TBool ItemIsVisible(TInt aItemIndex) const;
00652 
00659         IMPORT_C virtual TPoint ItemPos(TInt aItemIndex) const;
00660 
00671         IMPORT_C virtual TSize ItemSize(TInt aItemIndex=0) const;
00672 
00678         IMPORT_C void SetTextColor(TRgb aColor);
00679 
00685         IMPORT_C void SetBackColor(TRgb aColor);
00686         
00692     IMPORT_C TRgb TextColor() const;
00693 
00699         IMPORT_C TRgb BackColor() const;
00700 
00708         IMPORT_C virtual void MoveCursorL(TCursorMovement aCursorMovement, 
00709                                       TSelectionMode aSelectionMode);
00710         
00718     IMPORT_C virtual void VerticalMoveToItemL(TInt aTargetItemIndex, 
00719                                               TSelectionMode aSelectionMode);
00720         
00733     IMPORT_C virtual TBool XYPosToItemIndex(TPoint aPosition, 
00734                                             TInt& aItemIndex) const;   
00735     
00742     IMPORT_C virtual TInt NumberOfItemsThatFitInRect(const TRect& aRect) const;
00743 
00749     void SetVisibilityObserver(MListVisibilityObserver* aObserver);
00750 
00757         IMPORT_C TBool IsVisible() const;
00758 
00764         inline CListItemDrawer* ItemDrawer() const;
00765 
00771         IMPORT_C virtual void DrawEmptyList(const TRect &aClientRect) const;
00772 
00773     // disables vertical line drawing, useful only for certain 
00774     //custom list boxes
00780     void DisableVerticalLineDrawing( TBool aDisable );
00781 
00789     IMPORT_C void DeselectRangeL(TInt aItemIndex1, TInt aItemIndex2);
00790 
00797     IMPORT_C void SetItemOffsetInPixels(TInt aOffset);
00798     
00805     IMPORT_C TInt ItemOffsetInPixels() const;
00806     
00810     void SetScrolling( TBool aIsScrolling );
00811          
00812     TInt ItemHeight() const { return iItemHeight; }
00813 
00814      
00815 protected:
00816 
00817         // functions for accessing the flags
00825         inline TInt Flags() const;
00826 
00834         inline void SetFlags(TInt aMask);
00835 
00843         inline void ClearFlags(TInt aMask);
00844 
00849     friend class CEikListBox; 
00850 
00851         // misc. functions
00859         IMPORT_C void SelectRangeL(TInt aItemIndex1, TInt aItemIndex2);
00860 
00861 private:
00867     void SetItemIndex( TInt aItemIndex );
00868 
00869 protected:
00870 
00875         TInt iFlags;    
00876 
00881         CListItemDrawer* iItemDrawer;
00882 
00887         MListBoxModel* iModel;
00888 
00892         TInt iDataWidth;                        
00893     
00898     TInt iTopItemIndex;
00899         
00904     TInt iBottomItemIndex;
00905         
00909     TInt iHScrollOffset; 
00910         
00914     TInt iCurrentItemIndex;
00915         
00919     TInt iItemHeight;
00920         
00924     RWindow* iWin;
00925         
00929     RWindowGroup* iGroupWin;
00930         
00934     CWindowGc* iGc;
00935         
00939     TRect iViewRect;
00940 
00944         HBufC *iListEmptyText;
00945     
00949     TBool iDisableVerticalLineDrawing /*TInt iSpare*/;
00950 
00951 private:
00952         TInt iMatcherCursorPos;
00953         TRgb iMatcherCursorColor; 
00954         TRgb iBackColor;
00955         TRgb iTextColor;
00956         TInt iAnchorIndex;  
00957         TInt iActiveEndIndex;
00958         CSelectionIndexArray* iSelectionIndexes;
00959         MListVisibilityObserver* iVisibilityObserver;
00960 protected:
00964     TInt iVerticalOffset;
00965 
00966         CListBoxViewExtension* iExtension;
00967     TInt iSpare[4];
00968         };
00969 
00970 NONSHARABLE_CLASS( CListBoxViewExtension ) : public CBase
00971     {
00972     public:
00973         static CListBoxViewExtension* NewL();
00974         
00975         ~CListBoxViewExtension();
00976         
00977     private:
00978         void ConstructL();
00979         
00980     public:
00981         CEikListBox* iListBox;
00982         TBool iScrolling;
00983         TBool iScrollingDisabled;
00984     };
00985 
00986 
00990 inline const TDesC* CListBoxView::EmptyListText() const
00991         { return(iListEmptyText); }
00992 
00993 
00994 class CSnakingListBoxView : public CListBoxView
00995         {
00996 public:
00997         IMPORT_C ~CSnakingListBoxView();
00998         IMPORT_C CSnakingListBoxView();
00999         inline TInt ColumnWidth() const;
01000         IMPORT_C void SetColumnWidth(TInt aColumnWidth);
01001         IMPORT_C virtual void MoveCursorL(TCursorMovement aCursorMovement, TSelectionMode aSelectionMode);
01002         IMPORT_C virtual void SetTopItemIndex(TInt aItemIndex);
01003         IMPORT_C virtual void SetItemHeight(TInt aItemHeight);
01004         IMPORT_C virtual TBool XYPosToItemIndex(TPoint aPosition, TInt& aItemIndex) const;
01005         IMPORT_C virtual TInt NumberOfItemsThatFitInRect(const TRect& aRect) const;
01006         IMPORT_C virtual void HScroll(TInt aHScrollAmount);
01007         IMPORT_C virtual void CalcDataWidth();
01008         IMPORT_C virtual void CalcBottomItemIndex();
01009         IMPORT_C virtual void Draw(const TRect* aClipRect = NULL) const;
01010         IMPORT_C virtual TInt VisibleWidth(const TRect& aRect) const;
01011         IMPORT_C virtual TBool ScrollToMakeItemVisible(TInt aItemIndex);
01012         IMPORT_C virtual TInt CalculateHScrollOffsetSoItemIsVisible(TInt aItemIndex);
01013         IMPORT_C virtual TInt CalcNewTopItemIndexSoItemIsVisible(TInt aItemIndex) const;
01014         IMPORT_C virtual TPoint ItemPos(TInt aItemIndex) const;
01015         IMPORT_C virtual TSize ItemSize(TInt aItemIndex=0) const;
01016         IMPORT_C void CalcRowAndColIndexesFromItemIndex(TInt aItemIndex, TInt& aRowIndex, TInt& aColIndex) const;
01017         IMPORT_C void CalcItemIndexFromRowAndColIndexes(TInt& aItemIndex, TInt aRowIndex, TInt aColIndex) const;
01018         IMPORT_C virtual TInt NumberOfItemsPerColumn() const;
01019 protected:
01020         IMPORT_C virtual void DrawItemRange(TInt aStartItemIndex, TInt aEndItemIndex) const;
01021         IMPORT_C void DrawColumnRange(TInt aStartColIndex, TInt aEndColIndex) const;
01022         IMPORT_C void MoveToPreviousColumnL(TSelectionMode aSelectionMode);
01023         IMPORT_C void MoveToNextColumnL(TSelectionMode aSelectionMode);
01024         IMPORT_C void ClearUnusedItemSpace(TInt aStartItemIndex, TInt aEndItemIndex) const;
01025         IMPORT_C void UpdateHScrollOffsetBasedOnTopItemIndex();
01026 private: // overridden from CListBoxView
01027         IMPORT_C virtual TAny* Reserved_1();
01028 protected:
01029         TInt iColumnWidth;
01030         };
01031 
01032 
01033 
01034 inline TInt CListBoxView::Flags() const
01035         { return iFlags; }
01036 
01037 inline void CListBoxView::SetFlags(TInt aMask)
01038         { iFlags|=aMask; }
01039  
01040 inline void CListBoxView::ClearFlags(TInt aMask)
01041         { iFlags&=(~aMask); }
01042 
01043 inline CListItemDrawer* CListBoxView::ItemDrawer() const
01044         { return iItemDrawer; }
01045 
01046 inline TInt CSnakingListBoxView::ColumnWidth() const
01047         { return iColumnWidth; }
01048 
01049 
01050 #endif  // __EIKLBV_H__

Copyright © Nokia Corporation 2001-2007
Back to top