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 
00296     void MoveCursorWithRepeatsL( 
00297         TBool aNextOrPrev, 
00298         TSelectionMode aSelectionMode, 
00299         TInt aAmount );
00300     
00301 public: // from CListBoxView 
00306         IMPORT_C virtual void DrawMatcherCursor();
00307 
00313         IMPORT_C TInt CurrentItemIndex() const;
00314 
00315 protected:
00321         IMPORT_C TBool ItemExists(TInt aListBoxIndex) const;
00322 
00323 public: // code moved from CSnakingListBoxView
00330         IMPORT_C void SetColumnWidth(TInt aColumnWidth);
00331         
00339         IMPORT_C virtual void MoveCursorL(
00340                 TCursorMovement aCursorMovement,
00341                 TSelectionMode aSelectionMode);
00342 
00349         IMPORT_C virtual void Draw(const TRect* aClipRect = NULL) const;
00350 
00356         IMPORT_C virtual void DrawItem(TInt aItemIndex) const;
00357 
00364         IMPORT_C virtual TPoint ItemPos(TInt aItemIndex) const;
00365         
00371         IMPORT_C virtual void CalcBottomItemIndex();
00372         
00379         IMPORT_C virtual TInt CalcNewTopItemIndexSoItemIsVisible(TInt aItemIndex) const;
00380         
00387         IMPORT_C virtual void DrawItemRange(TInt aStartItemIndex, TInt aEndItemIndex) const;
00388 
00393         inline TInt ColumnWidth() const;
00394         
00400         IMPORT_C virtual void SetTopItemIndex(TInt aItemIndex);
00401         
00406         IMPORT_C virtual void SetItemHeight(TInt aItemHeight);
00407         
00408         /*
00409         * This function converts an (x, y) pixel position to an item index.
00410         * @param aPosition Pixel position in the viewing rectangle.
00411         * @param aItemIndex Reference to the item index.
00412         * @return Whether there was an item at aPosition.
00413         */      
00414         IMPORT_C virtual TBool XYPosToItemIndex(TPoint aPosition, TInt& aItemIndex) const;
00415 
00420         IMPORT_C virtual void CalcDataWidth();
00421         
00428         IMPORT_C virtual TInt VisibleWidth(const TRect& aRect) const;
00429         
00437         IMPORT_C virtual TBool ScrollToMakeItemVisible(TInt aItemIndex);
00438         
00447         IMPORT_C virtual TInt CalculateHScrollOffsetSoItemIsVisible(TInt aItemIndex);
00448         
00454         IMPORT_C virtual TSize ItemSize(TInt aItemIndex=0) const;
00455         
00462         IMPORT_C void CalcRowAndColIndexesFromItemIndex(TInt aItemIndex, TInt& aRowIndex, TInt& aColIndex) const;
00463         
00471         IMPORT_C void CalcItemIndexFromRowAndColIndexes(TInt& aItemIndex, TInt aRowIndex, TInt aColIndex) const;
00472 
00473 protected: // code moved from CSnakingListBoxView
00480         IMPORT_C void DrawColumnRange(TInt aStartColIndex, TInt aEndColIndex) const;
00481 
00488         IMPORT_C void ClearUnusedItemSpace(TInt aStartItemIndex, TInt aEndItemIndex) const;
00489 
00495         IMPORT_C void UpdateHScrollOffsetBasedOnTopItemIndex();
00496 
00497 protected:
00502         inline CAknGridM* GridModel() const;
00503 
00510         IMPORT_C void DoMoveL(TCursorMovement aCursorMovement, TSelectionMode aSelectionMode);
00511 
00512 private:
00513         // movement handling routines
00514         IMPORT_C TInt SearchByLines(TInt aX, TInt aY, TCursorMovement aCursorMovement, TBool aBeginSearchOnIndex = EFalse);
00515         IMPORT_C TInt FindNextItem(TInt aItemIndex, TBool aLookDown, TBool aLookRight, TBool aFirstLookHorizontal, TBool aBeginSearchOnIndex = EFalse);
00516         TBool IsEdgePassed(TInt aItemIndex, TBool aLookDown, TBool aLookRight, TBool aFirstLookHorizontal, TBool aBeginSearchOnIndex, TInt& aNewIndex);
00517 
00518         TBool IsMoveRight(TCursorMovement aCursorMovement);
00519         TBool IsMoveDown(TCursorMovement aCursorMovement);
00520 private: // overridden from CListBoxView
00521         IMPORT_C virtual TAny* Reserved_1();
00522 private:
00523         TScrollingType iScrollingType;
00524         TScrollingType iScrollInSecondaryDimension;
00525 
00526         SGrid iGridDetails;
00527     TInt iSpare[2];
00528         };
00529 
00530 inline CAknGridM* CAknGridView::GridModel() const
00531         {
00532         return STATIC_CAST(CAknGridM*,iModel);
00533         }
00534 
00535 inline TInt CAknGridView::ColumnWidth() const
00536         { return iGridDetails.iSizeOfItems.iWidth; }
00537 
00538 #endif

Copyright © Nokia Corporation 2001-2008
Back to top