S60 3rd Edition API Reference: akngridview.h Source File

akngridview.h

Go to the documentation of this file.
00001 /*
00002 * ============================================================================
00003 *  Name     : AknGridView.h
00004 *  Part of  : Avkon
00005 *
00006 *  Description:
00007 *     CAknGridView handles the drawing, the mapping
00008 *     of the grid data index to the underlying listbox index (and
00009 *     visa versa) as well as the movement around the grid.
00010 *  Version:
00011 *
00012 *  Copyright © 2002 Nokia Corporation.
00013 *  This material, including documentation and any related 
00014 *  computer programs, is protected by copyright controlled by 
00015 *  Nokia Corporation. All rights are reserved. Copying, 
00016 *  including reproducing, storing,  adapting or translating, any 
00017 *  or all of this material requires the prior written consent of 
00018 *  Nokia Corporation. This material also contains confidential 
00019 *  information which may not be disclosed to others without the 
00020 *  prior written consent of Nokia Corporation.
00021 * ============================================================================
00022 */
00023 
00024 #if !defined(__AKNGRIDVIEW_H__)
00025 #define __AKNGRIDVIEW_H__
00026 
00027 // INCLUDES
00028 #include <eiklbv.h>
00029 #include <AknGridM.h>
00030 #include <eiklabel.h>
00031 
00032 // CLASS DECLARATION
00033 
00054 class CAknGridView : public CListBoxView 
00055         {
00056 public:
00058         enum TGridFlags
00059                 {
00061                 EPrimaryIsVertical      = 0x0001,
00063                 ETopToBottom            = 0x0002,
00065                 ELeftToRight            = 0x0004
00066                 };
00068         enum TScrollingType
00069                 {
00071                 EScrollFollowsItemsAndStops,
00073                 EScrollFollowsItemsAndLoops,
00075                 EScrollFollowsGrid,
00077                 EScrollStops,
00079                 EScrollIncrementLineAndStops,
00081                 EScrollIncrementLineAndLoops
00082                 };
00084         struct SGrid
00085                 {
00087                 TSize iGridDimensions;
00089                 TInt iGridFlags;
00091                 TInt iPageSize;
00093                 TInt iColsInView;
00095                 TInt iRowsInView;
00097                 TSize iSizeBetweenItems;
00099                 TSize iSizeOfItems;
00100                 };
00101 
00102 protected:
00104         enum TPageIndex 
00105                 {
00107                 EPreviousPage,
00109                 ENextPage,
00111                 EHome,
00113                 EEnd
00114                 };
00115         /* Enumeration of position of current index.*/
00116         enum TPositionCurrentIndex
00117                 {
00119                 EPage,
00121                 EColumn,
00123                 EOppositeCorner
00124                 };
00125 
00126 public:
00130         IMPORT_C CAknGridView();
00131         
00135         IMPORT_C virtual ~CAknGridView();
00136 
00137         // actual <-> listbox index conversion routines
00143         IMPORT_C TInt ActualDataIndex(TInt aListBoxIndex) const;
00144         
00150         IMPORT_C TInt ListBoxIndex(TInt aDataIndex) const;
00151 
00157         IMPORT_C TInt CurrentDataIndex() const;
00158         
00164         IMPORT_C void SetCurrentDataIndex(TInt aDataIndex);
00165 
00172         IMPORT_C void SetPrimaryScrollingType(TScrollingType aScrollingType);
00178         IMPORT_C void SetSecondaryScrollingType(TScrollingType aSecondaryScrolling);
00179 
00186         IMPORT_C void SetGridCellDimensions(TSize aGridDimensions);
00187         
00192         IMPORT_C TSize GridCellDimensions() const;
00197         IMPORT_C void SetSpacesBetweenItems(TSize aSizeOfSpaceBetweenItems);
00198         
00203         IMPORT_C TBool IsPrimaryVertical() const;
00204 
00213         IMPORT_C void DataIndexFromLogicalPos(
00214                 TInt& aItemIndex,
00215                 TInt aRowIndex,
00216                 TInt aColIndex) const;
00217         
00227         IMPORT_C void LogicalPosFromDataIndex(
00228                 TInt aItemIndex,
00229                 TInt& aRowIndex,
00230                 TInt& aColIndex) const;
00231         
00241         IMPORT_C void ListBoxIndexFromLogicalPos(
00242                 TInt& aItemIndex,
00243                 TInt aRowIndex,
00244                 TInt aColIndex) const;
00254         IMPORT_C void LogicalPosFromListBoxIndex(
00255                 TInt aItemIndex,
00256                 TInt& aRowIndex,
00257                 TInt& aColIndex) const;
00258 
00262         IMPORT_C virtual void DrawEmptyList() const;
00263 
00268         IMPORT_C void SetGridDetails(SGrid aGridDetails);
00269 
00275         IMPORT_C void MoveToItemIndexL(TInt aItemIndex, TSelectionMode aSelectionMode);
00276 
00281         IMPORT_C TInt NumberOfColsInView() const;
00282 
00287         IMPORT_C TInt NumberOfRowsInView() const;
00288 
00289 public: // from CListBoxView 
00294         IMPORT_C virtual void DrawMatcherCursor();
00295 
00301         IMPORT_C TInt CurrentItemIndex() const;
00302 
00303 protected:
00309         IMPORT_C TBool ItemExists(TInt aListBoxIndex) const;
00310 
00311 public: // code moved from CSnakingListBoxView
00318         IMPORT_C void SetColumnWidth(TInt aColumnWidth);
00319         
00327         IMPORT_C virtual void MoveCursorL(
00328                 TCursorMovement aCursorMovement,
00329                 TSelectionMode aSelectionMode);
00330 
00337         IMPORT_C virtual void Draw(const TRect* aClipRect = NULL) const;
00338 
00344         IMPORT_C virtual void DrawItem(TInt aItemIndex) const;
00345 
00352         IMPORT_C virtual TPoint ItemPos(TInt aItemIndex) const;
00353         
00359         IMPORT_C virtual void CalcBottomItemIndex();
00360         
00367         IMPORT_C virtual TInt CalcNewTopItemIndexSoItemIsVisible(TInt aItemIndex) const;
00368         
00375         IMPORT_C virtual void DrawItemRange(TInt aStartItemIndex, TInt aEndItemIndex) const;
00376 
00381         inline TInt ColumnWidth() const;
00382         
00388         IMPORT_C virtual void SetTopItemIndex(TInt aItemIndex);
00389         
00394         IMPORT_C virtual void SetItemHeight(TInt aItemHeight);
00395         
00396         /*
00397         * This function converts an (x, y) pixel position to an item index.
00398         * @param aPosition Pixel position in the viewing rectangle.
00399         * @param aItemIndex Reference to the item index.
00400         * @return Whether there was an item at aPosition.
00401         */      
00402         IMPORT_C virtual TBool XYPosToItemIndex(TPoint aPosition, TInt& aItemIndex) const;
00403 
00408         IMPORT_C virtual void CalcDataWidth();
00409         
00416         IMPORT_C virtual TInt VisibleWidth(const TRect& aRect) const;
00417         
00425         IMPORT_C virtual TBool ScrollToMakeItemVisible(TInt aItemIndex);
00426         
00435         IMPORT_C virtual TInt CalculateHScrollOffsetSoItemIsVisible(TInt aItemIndex);
00436         
00442         IMPORT_C virtual TSize ItemSize(TInt aItemIndex=0) const;
00443         
00450         IMPORT_C void CalcRowAndColIndexesFromItemIndex(TInt aItemIndex, TInt& aRowIndex, TInt& aColIndex) const;
00451         
00459         IMPORT_C void CalcItemIndexFromRowAndColIndexes(TInt& aItemIndex, TInt aRowIndex, TInt aColIndex) const;
00460 
00461 protected: // code moved from CSnakingListBoxView
00468         IMPORT_C void DrawColumnRange(TInt aStartColIndex, TInt aEndColIndex) const;
00469 
00476         IMPORT_C void ClearUnusedItemSpace(TInt aStartItemIndex, TInt aEndItemIndex) const;
00477 
00483         IMPORT_C void UpdateHScrollOffsetBasedOnTopItemIndex();
00484 
00485 protected:
00490         inline CAknGridM* GridModel() const;
00491 
00498         IMPORT_C void DoMoveL(TCursorMovement aCursorMovement, TSelectionMode aSelectionMode);
00499 
00500 private:
00501         // movement handling routines
00502         IMPORT_C TInt SearchByLines(TInt aX, TInt aY, TCursorMovement aCursorMovement, TBool aBeginSearchOnIndex = EFalse);
00503         IMPORT_C TInt FindNextItem(TInt aItemIndex, TBool aLookDown, TBool aLookRight, TBool aFirstLookHorizontal, TBool aBeginSearchOnIndex = EFalse);
00504         TBool IsEdgePassed(TInt aItemIndex, TBool aLookDown, TBool aLookRight, TBool aFirstLookHorizontal, TBool aBeginSearchOnIndex, TInt& aNewIndex);
00505 
00506         TBool IsMoveRight(TCursorMovement aCursorMovement);
00507         TBool IsMoveDown(TCursorMovement aCursorMovement);
00508 private: // overridden from CListBoxView
00509         IMPORT_C virtual TAny* Reserved_1();
00510 private:
00511         TScrollingType iScrollingType;
00512         TScrollingType iScrollInSecondaryDimension;
00513 
00514         SGrid iGridDetails;
00515     TInt iSpare[2];
00516         };
00517 
00518 inline CAknGridM* CAknGridView::GridModel() const
00519         {
00520         return STATIC_CAST(CAknGridM*,iModel);
00521         }
00522 
00523 inline TInt CAknGridView::ColumnWidth() const
00524         { return iGridDetails.iSizeOfItems.iWidth; }
00525 
00526 #endif

Copyright © Nokia Corporation 2001-2007
Back to top