akngridview.h

Go to the documentation of this file.
00001 /*
00002 * ============================================================================
00003 *  Name        : AknGridView.h
00004 *  Part of     : UI Framework Core / AVKON
00005 *  Description : CAknGridView handles the drawing, the mapping
00006 *                of the grid data index to the underlying listbox index (and
00007 *                vice versa) as well as the movement around the grid.
00008 *  Version     : %version: tr1s60#8.1.1 %
00009 *
00010 *  Copyright © 2002-2009 Nokia.  All rights reserved.
00011 *  This material, including documentation and any related computer
00012 *  programs, is protected by copyright controlled by Nokia.  All
00013 *  rights are reserved.  Copying, including reproducing, storing,
00014 *  adapting or translating, any or all of this material requires the
00015 *  prior written consent of Nokia.  This material also contains
00016 *  confidential information which may not be disclosed to others
00017 *  without the prior written consent of Nokia.
00018 * ============================================================================
00019 */
00020 
00021 #ifndef __AKNGRIDVIEW_H__
00022 #define __AKNGRIDVIEW_H__
00023 
00024 // INCLUDES
00025 #include <eiklbv.h>
00026 #include <akngridm.h>
00027 #include <eiklabel.h>
00028 
00029 // CLASS DECLARATION
00030 
00053 class CAknGridView : public CListBoxView 
00054         {
00055 public:
00057         enum TGridFlags
00058                 {
00060                 EPrimaryIsVertical      = 0x0001,
00062                 ETopToBottom            = 0x0002,
00064                 ELeftToRight            = 0x0004
00065                 };
00067         enum TScrollingType
00068                 {
00070                 EScrollFollowsItemsAndStops,
00072                 EScrollFollowsItemsAndLoops,
00074                 EScrollFollowsGrid,
00076                 EScrollStops,
00078                 EScrollIncrementLineAndStops,
00080                 EScrollIncrementLineAndLoops
00081                 };
00083         struct SGrid
00084                 {
00086                 TSize iGridDimensions;
00088                 TInt iGridFlags;
00090                 TInt iPageSize;
00092                 TInt iColsInView;
00094                 TInt iRowsInView;
00096                 TSize iSizeBetweenItems;
00098                 TSize iSizeOfItems;
00099                 };
00100 
00101 protected:
00103         enum TPageIndex 
00104                 {
00106                 EPreviousPage,
00108                 ENextPage,
00110                 EHome,
00112                 EEnd
00113                 };
00114         /* Enumeration of position of current index.*/
00115         enum TPositionCurrentIndex
00116                 {
00118                 EPage,
00120                 EColumn,
00122                 EOppositeCorner
00123                 };
00124 
00125 public:
00129         IMPORT_C CAknGridView();
00130         
00134         IMPORT_C virtual ~CAknGridView();
00135 
00136         // actual <-> listbox index conversion routines
00142         IMPORT_C TInt ActualDataIndex(TInt aListBoxIndex) const;
00143         
00149         IMPORT_C TInt ListBoxIndex(TInt aDataIndex) const;
00150 
00156         IMPORT_C TInt CurrentDataIndex() const;
00157         
00163         IMPORT_C void SetCurrentDataIndex(TInt aDataIndex);
00164 
00171         IMPORT_C void SetPrimaryScrollingType(TScrollingType aScrollingType);
00177         IMPORT_C void SetSecondaryScrollingType(TScrollingType aSecondaryScrolling);
00178 
00185         IMPORT_C void SetGridCellDimensions(TSize aGridDimensions);
00186         
00191         IMPORT_C TSize GridCellDimensions() const;
00196         IMPORT_C void SetSpacesBetweenItems(TSize aSizeOfSpaceBetweenItems);
00197         
00202         IMPORT_C TBool IsPrimaryVertical() const;
00203 
00212         IMPORT_C void DataIndexFromLogicalPos(
00213                 TInt& aItemIndex,
00214                 TInt aRowIndex,
00215                 TInt aColIndex) const;
00216         
00226         IMPORT_C void LogicalPosFromDataIndex(
00227                 TInt aItemIndex,
00228                 TInt& aRowIndex,
00229                 TInt& aColIndex) const;
00230         
00240         IMPORT_C void ListBoxIndexFromLogicalPos(
00241                 TInt& aItemIndex,
00242                 TInt aRowIndex,
00243                 TInt aColIndex) const;
00253         IMPORT_C void LogicalPosFromListBoxIndex(
00254                 TInt aItemIndex,
00255                 TInt& aRowIndex,
00256                 TInt& aColIndex) const;
00257 
00261         IMPORT_C virtual void DrawEmptyList() const;
00262 
00267         IMPORT_C void SetGridDetails(SGrid aGridDetails);
00268 
00274         IMPORT_C void MoveToItemIndexL(TInt aItemIndex, TSelectionMode aSelectionMode);
00275 
00280         IMPORT_C TInt NumberOfColsInView() const;
00281 
00286         IMPORT_C TInt NumberOfRowsInView() const;
00287 
00295     void MoveCursorWithRepeatsL( 
00296         TBool aNextOrPrev, 
00297         TSelectionMode aSelectionMode, 
00298         TInt aAmount );
00299     
00300 public: // from CListBoxView 
00305         IMPORT_C virtual void DrawMatcherCursor();
00306 
00312         IMPORT_C TInt CurrentItemIndex() const;
00313 
00314 protected:
00320         IMPORT_C TBool ItemExists(TInt aListBoxIndex) const;
00321 
00322 public: // code moved from CSnakingListBoxView
00329         IMPORT_C void SetColumnWidth(TInt aColumnWidth);
00330         
00338         IMPORT_C virtual void MoveCursorL(
00339                 TCursorMovement aCursorMovement,
00340                 TSelectionMode aSelectionMode);
00341 
00348         IMPORT_C virtual void Draw(const TRect* aClipRect = NULL) const;
00349 
00355         IMPORT_C virtual void DrawItem(TInt aItemIndex) const;
00356 
00363         IMPORT_C virtual TPoint ItemPos(TInt aItemIndex) const;
00364         
00370         IMPORT_C virtual void CalcBottomItemIndex();
00371         
00378         IMPORT_C virtual TInt CalcNewTopItemIndexSoItemIsVisible(TInt aItemIndex) const;
00379         
00386         IMPORT_C virtual void DrawItemRange(TInt aStartItemIndex, TInt aEndItemIndex) const;
00387 
00392         inline TInt ColumnWidth() const;
00393         
00399         IMPORT_C virtual void SetTopItemIndex(TInt aItemIndex);
00400         
00405         IMPORT_C virtual void SetItemHeight(TInt aItemHeight);
00406         
00407         /*
00408         * This function converts an (x, y) pixel position to an item index.
00409         * @param aPosition Pixel position in the viewing rectangle.
00410         * @param aItemIndex Reference to the item index.
00411         * @return Whether there was an item at aPosition.
00412         */      
00413         IMPORT_C virtual TBool XYPosToItemIndex(TPoint aPosition, TInt& aItemIndex) const;
00414 
00419         IMPORT_C virtual void CalcDataWidth();
00420         
00427         IMPORT_C virtual TInt VisibleWidth(const TRect& aRect) const;
00428         
00436         IMPORT_C virtual TBool ScrollToMakeItemVisible(TInt aItemIndex);
00437         
00446         IMPORT_C virtual TInt CalculateHScrollOffsetSoItemIsVisible(TInt aItemIndex);
00447         
00453         IMPORT_C virtual TSize ItemSize(TInt aItemIndex=0) const;
00454         
00461         IMPORT_C void CalcRowAndColIndexesFromItemIndex(TInt aItemIndex, TInt& aRowIndex, TInt& aColIndex) const;
00462         
00470         IMPORT_C void CalcItemIndexFromRowAndColIndexes(TInt& aItemIndex, TInt aRowIndex, TInt aColIndex) const;
00471 
00472 protected: // code moved from CSnakingListBoxView
00479         IMPORT_C void DrawColumnRange(TInt aStartColIndex, TInt aEndColIndex) const;
00480 
00487         IMPORT_C void ClearUnusedItemSpace(TInt aStartItemIndex, TInt aEndItemIndex) const;
00488 
00494         IMPORT_C void UpdateHScrollOffsetBasedOnTopItemIndex();
00495 
00496 protected:
00501         inline CAknGridM* GridModel() const;
00502 
00509         IMPORT_C void DoMoveL(TCursorMovement aCursorMovement, TSelectionMode aSelectionMode);
00510 
00511 private:
00512         // movement handling routines
00513         IMPORT_C TInt SearchByLines(TInt aX, TInt aY, TCursorMovement aCursorMovement, TBool aBeginSearchOnIndex = EFalse);
00514         IMPORT_C TInt FindNextItem(TInt aItemIndex, TBool aLookDown, TBool aLookRight, TBool aFirstLookHorizontal, TBool aBeginSearchOnIndex = EFalse);
00515         TBool IsEdgePassed(TInt aItemIndex, TBool aLookDown, TBool aLookRight, TBool aFirstLookHorizontal, TBool aBeginSearchOnIndex, TInt& aNewIndex);
00516 
00517         TBool IsMoveRight(TCursorMovement aCursorMovement);
00518         TBool IsMoveDown(TCursorMovement aCursorMovement);
00519 
00520 private: // overridden from CListBoxView
00521         IMPORT_C virtual TAny* Reserved_1();
00522 
00523 private:
00524     
00528     void DrawUnusedViewPortion() const;
00529     
00530 private:
00531         TScrollingType iScrollingType;
00532         TScrollingType iScrollInSecondaryDimension;
00533 
00534         SGrid iGridDetails;
00535     TInt iSpare[2];
00536         };
00537 
00538 inline CAknGridM* CAknGridView::GridModel() const
00539         {
00540         return STATIC_CAST(CAknGridM*,iModel);
00541         }
00542 
00543 inline TInt CAknGridView::ColumnWidth() const
00544         { return iGridDetails.iSizeOfItems.iWidth; }
00545 
00546 #endif // __AKNGRIDVIEW_H__

Copyright © Nokia Corporation 2001-2007
Back to top