CAknGridView Class Reference

API published in: S60 1st Ed

Link against: avkon.lib

Capability Information

Required Capabilities

None


#include <akngridview.h>

Inherits CListBoxView.

Inherited by CAknGMSStyleGridView.


Detailed Description

CAknGridView handles the drawing, the mapping of the grid data index to the underlying listbox index (and visa versa) as well as the movement around the grid.

Differentiation is needed between a data index and the list box index since the inherited list box code handles the top, bottom and current indexes as though everything is order topdown and left to right. This is no good for grid that maybe order in 8 different ways so need conversion between list box index and actual data index. List box index is the index for the data item according to the snaking list box format of numbering data items. Data index is the actual index in the grid according to the ordering applied to the data by the user. Note: the logical position is the intermediate form used to map from a list box index to a data index or vi sa versa. It is essentialy the position of the item in relation to the top left corner of the grid. I.e. the top left position has logical position 0,0.


Public Types

enum   TGridFlags { EPrimaryIsVertical = 0x0001, ETopToBottom = 0x0002, ELeftToRight = 0x0004 }
  Enumeration flags for grid. More...
enum   TScrollingType {
  EScrollFollowsItemsAndStops, EScrollFollowsItemsAndLoops, EScrollFollowsGrid, EScrollStops,
  EScrollIncrementLineAndStops, EScrollIncrementLineAndLoops
}
  Enumeration for different scrolling types. More...

Public Member Functions

IMPORT_C  CAknGridView ()
  Default C++ constructor.
virtual IMPORT_C  ~CAknGridView ()
  Destructor.
IMPORT_C TInt  ActualDataIndex (TInt aListBoxIndex) const
  Returns the actual index of given listbox index.
IMPORT_C TInt  ListBoxIndex (TInt aDataIndex) const
  Returns the listbox index of given data index.
IMPORT_C TInt  CurrentDataIndex () const
  Returns the current data index with respect to the ordering of the cells in the grid.
IMPORT_C void  SetCurrentDataIndex (TInt aDataIndex)
  Sets the current data index with a value given with respect to the ordering of the cells in the grid.
IMPORT_C void  SetPrimaryScrollingType (TScrollingType aScrollingType)
  Sets the form of scroll to activate upon reaching the limit when moving in the primary direction of grid, primary meaning whether the items are organised vertically or horizontally.
IMPORT_C void  SetSecondaryScrollingType (TScrollingType aSecondaryScrolling)
  Sets the form of scroll to activate upon reaching the limit when moving in the secondary direction of grid.
IMPORT_C void  SetGridCellDimensions (TSize aGridDimensions)
  Checks that number of cells in the grid is always enough to fill the current grid dimensions.
IMPORT_C TSize  GridCellDimensions () const
  Returns the current grid dimensions.
IMPORT_C void  SetSpacesBetweenItems (TSize aSizeOfSpaceBetweenItems)
  Sets the size of the spaces between items.
IMPORT_C TBool  IsPrimaryVertical () const
  Returns ETrue if the primary dimension of the grid is vertical.
IMPORT_C void  DataIndexFromLogicalPos (TInt &aItemIndex, TInt aRowIndex, TInt aColIndex) const
  Converts a logical position on the grid, where the co-ordinates are with respect to the top left hand corner of the grid, to an index for the cell with respect to the ordering of the cells in the grid.
IMPORT_C void  LogicalPosFromDataIndex (TInt aItemIndex, TInt &aRowIndex, TInt &aColIndex) const
  Converts an index for a cell in the grid, given with respect to the ordering of the cells in the grid, to a logical position on the grid, where the co-ordinates are with respect to the top left hand corner of the grid.
IMPORT_C void  ListBoxIndexFromLogicalPos (TInt &aItemIndex, TInt aRowIndex, TInt aColIndex) const
  Converts a CEikListBox index for a cell in the grid, given with respect to the snaking listbox top down, left to right structure underlying the grid structure, to a logical position on the grid, where the co-ordinates are with respect to the top left hand corner of the grid.
IMPORT_C void  LogicalPosFromListBoxIndex (TInt aItemIndex, TInt &aRowIndex, TInt &aColIndex) const
  Converts a logical position on the grid, where the co-ordinates are with respect to the top left hand corner of the grid, to a CEikListBox index for the cell with respect to the snaking listbox top down, left to right structure underlying the grid structure.
virtual IMPORT_C void  DrawEmptyList () const
  Draws empty grid list.
IMPORT_C void  SetGridDetails (SGrid aGridDetails)
  Grid initialisation function.
IMPORT_C void  MoveToItemIndexL (TInt aItemIndex, TSelectionMode aSelectionMode)
  This moves to the item and draws the grid in the right place.
IMPORT_C TInt  NumberOfColsInView () const
  This function returns the number of visible columns.
IMPORT_C TInt  NumberOfRowsInView () const
  This function returns the number of visible rows.
void  MoveCursorWithRepeatsL (TBool aNextOrPrev, TSelectionMode aSelectionMode, TInt aAmount)
  Moves cursor with repeats.
virtual IMPORT_C void  DrawMatcherCursor ()
  From CListBoxView.
IMPORT_C TInt  CurrentItemIndex () const
  From CListBoxView.
IMPORT_C void  SetColumnWidth (TInt aColumnWidth)
  This function sets the width of the grid column.
virtual IMPORT_C void  MoveCursorL (TCursorMovement aCursorMovement, TSelectionMode aSelectionMode)
  Overloaded MoveCursorL method to process cursor movement according to orientation of the grid.
virtual IMPORT_C void  Draw (const TRect *aClipRect=NULL) const
  This function draws every visible item into the specified rectangle.
virtual IMPORT_C void  DrawItem (TInt aItemIndex) const
  This has been overloaded to ensure that only valid cells are drawn and not the empty cells.
virtual IMPORT_C TPoint  ItemPos (TInt aItemIndex) const
  This function gets the position of the top left corner of the specified item, in pixels.
virtual IMPORT_C void  CalcBottomItemIndex ()
  This function has been overloaded to draw items correctly.
virtual IMPORT_C TInt  CalcNewTopItemIndexSoItemIsVisible (TInt aItemIndex) const
  This function gets the item the view would need to be moved to in order to make the specified item visible.
virtual IMPORT_C void  DrawItemRange (TInt aStartItemIndex, TInt aEndItemIndex) const
  This function draws every item between the start and end indices inclusively.
TInt  ColumnWidth () const
  This function gets the width of all columns in the view.
virtual IMPORT_C void  SetTopItemIndex (TInt aItemIndex)
  Sets which item appears at the top left corner of the view.
virtual IMPORT_C void  SetItemHeight (TInt aItemHeight)
  This function sets item height in pixels.
virtual IMPORT_C TBool  XYPosToItemIndex (TPoint aPosition, TInt &aItemIndex) const
  Converts a pixel position into an item index.
virtual IMPORT_C void  CalcDataWidth ()
  Calculates the data width in columns.
virtual IMPORT_C TInt  VisibleWidth (const TRect &aRect) const
  Gets the visible width of the specified rectangle in pixels.
virtual IMPORT_C TBool  ScrollToMakeItemVisible (TInt aItemIndex)
  Makes the specified item visible by moving the view location and redrawing the control.
virtual IMPORT_C TInt  CalculateHScrollOffsetSoItemIsVisible (TInt aItemIndex)
  Gets the number of columns that this view would need to be scrolled by to make the specified item visible.
virtual IMPORT_C TSize  ItemSize (TInt aItemIndex=0) const
  Gets the size of the specified item.
IMPORT_C void  CalcRowAndColIndexesFromItemIndex (TInt aItemIndex, TInt &aRowIndex, TInt &aColIndex) const
  Converts an item index into the (row, column) pair describing that item.
IMPORT_C void  CalcItemIndexFromRowAndColIndexes (TInt &aItemIndex, TInt aRowIndex, TInt aColIndex) const
  This function converts a row/column pair into the item index for that item.

Protected Types

enum   TPageIndex { EPreviousPage, ENextPage, EHome, EEnd }
  Enumeration flags for pages. More...
enum   TPositionCurrentIndex { EPage, EColumn, EOppositeCorner }

Protected Member Functions

IMPORT_C TBool  ItemExists (TInt aListBoxIndex) const
  This function tests whether an item exists.
IMPORT_C void  DrawColumnRange (TInt aStartColIndex, TInt aEndColIndex) const
  This function draws every item in every column between the start and end columns inclusively.
IMPORT_C void  ClearUnusedItemSpace (TInt aStartItemIndex, TInt aEndItemIndex) const
  This function clears each item’s rectangle between the specified start and finish item’s indexes.
IMPORT_C void  UpdateHScrollOffsetBasedOnTopItemIndex ()
  This function updates the horizontal scroll offset (iHScrollOffset) based on the top item’s index.
CAknGridM GridModel () const
  This inline function is grid model helper.
IMPORT_C void  DoMoveL (TCursorMovement aCursorMovement, TSelectionMode aSelectionMode)
  This function handles movement routines.

Data Structures

struct   SGrid
  Enumeration flags for different layouts. More...

Member Enumeration Documentation

enum CAknGridView::TGridFlags
 

Enumeration flags for grid.

Enumerator:
EPrimaryIsVertical  Vertical is primary direction.
ETopToBottom  From top to bottom.
ELeftToRight  From left to right.
enum CAknGridView::TPageIndex [protected]
 

Enumeration flags for pages.

Enumerator:
EPreviousPage  Previous page.
ENextPage  Next page.
EHome  First page.
EEnd  Last page.
enum CAknGridView::TPositionCurrentIndex [protected]
 
Enumerator:
EPage  Page.
EColumn  Column.
EOppositeCorner  Opposite corner.
enum CAknGridView::TScrollingType
 

Enumeration for different scrolling types.

Enumerator:
EScrollFollowsItemsAndStops  Scrolling follows items and stops.
EScrollFollowsItemsAndLoops  Scrolling follows items and loops.
EScrollFollowsGrid  Scrolling follows grid.
EScrollStops  Scrolling stops.
EScrollIncrementLineAndStops  Scrolls one line and stops.
EScrollIncrementLineAndLoops  Scrolls one line and loops.

Constructor & Destructor Documentation

IMPORT_C CAknGridView::CAknGridView  ) 
 

Default C++ constructor.

virtual IMPORT_C CAknGridView::~CAknGridView  )  [virtual]
 

Destructor.


Member Function Documentation

IMPORT_C TInt CAknGridView::ActualDataIndex TInt  aListBoxIndex  )  const
 

Returns the actual index of given listbox index.

Parameters:
aListBoxIndex  The index of the listbox.
Returns:
The actual data index.
virtual IMPORT_C void CAknGridView::CalcBottomItemIndex  )  [virtual]
 

This function has been overloaded to draw items correctly.

Recalculates the bottom item’s index. This is called by the list box control when either the size or the number of items in its model changes.

Reimplemented from CListBoxView.

virtual IMPORT_C void CAknGridView::CalcDataWidth  )  [virtual]
 

Calculates the data width in columns.

iDataWidth is calculated based on model and drawer information.

Reimplemented from CListBoxView.

IMPORT_C void CAknGridView::CalcItemIndexFromRowAndColIndexes TInt &  aItemIndex,
TInt  aRowIndex,
TInt  aColIndex
const
 

This function converts a row/column pair into the item index for that item.

Parameters:
aItemIndex  Reference to the item index.
aRowIndex  Row index of the item.
aColIndex  Column index of the item.
virtual IMPORT_C TInt CAknGridView::CalcNewTopItemIndexSoItemIsVisible TInt  aItemIndex  )  const [virtual]
 

This function gets the item the view would need to be moved to in order to make the specified item visible.

Parameters:
aItemIndex  The item to make visible.
Returns:
The item to scroll to to make aItemIndex visible.

Reimplemented from CListBoxView.

IMPORT_C void CAknGridView::CalcRowAndColIndexesFromItemIndex TInt  aItemIndex,
TInt &  aRowIndex,
TInt &  aColIndex
const
 

Converts an item index into the (row, column) pair describing that item.

Parameters:
aItemIndex  The item index.
aRowIndex  Reference to the row index.
aColIndex  Reference the column index.
virtual IMPORT_C TInt CAknGridView::CalculateHScrollOffsetSoItemIsVisible TInt  aItemIndex  )  [virtual]
 

Gets the number of columns that this view would need to be scrolled by to make the specified item visible.

The function returns 0 if no scrolling is needed. ScrollToMakeItemVisible() uses this function.

Parameters:
aItemIndex  Item to make visible.
Returns:
The number of columns to scroll, or zero if no scrolling is needed.
IMPORT_C void CAknGridView::ClearUnusedItemSpace TInt  aStartItemIndex,
TInt  aEndItemIndex
const [protected]
 

This function clears each item’s rectangle between the specified start and finish item’s indexes.

Parameters:
aStartItemIndex  The first item to clear.
aEndItemIndex  The last item to clear.
TInt CAknGridView::ColumnWidth  )  const [inline]
 

This function gets the width of all columns in the view.

Returns:
The width of all columns in the view, in pixels.
IMPORT_C TInt CAknGridView::CurrentDataIndex  )  const
 

Returns the current data index with respect to the ordering of the cells in the grid.

Returns:
Current data index.
IMPORT_C TInt CAknGridView::CurrentItemIndex  )  const [virtual]
 

From CListBoxView.

This function returns the current item in the grid and -1 if there is no current item,

Returns:
The current item.

Reimplemented from CListBoxView.

IMPORT_C void CAknGridView::DataIndexFromLogicalPos TInt &  aItemIndex,
TInt  aRowIndex,
TInt  aColIndex
const
 

Converts a logical position on the grid, where the co-ordinates are with respect to the top left hand corner of the grid, to an index for the cell with respect to the ordering of the cells in the grid.

Parameters:
aItemIndex  Reference to the index for the cell in the grid.
aRowIndex  The row in the grid.
aColIndex  The column in the grid.
IMPORT_C void CAknGridView::DoMoveL TCursorMovement  aCursorMovement,
TSelectionMode  aSelectionMode
[protected]
 

This function handles movement routines.

Parameters:
aCursorMovement  Handles cursor movements etc. ECursorNextItem and ECursorPreviousItem.
aSelectionMode  Modes for modifying the selection.
virtual IMPORT_C void CAknGridView::Draw const TRect *  aClipRect = NULL  )  const [virtual]
 

This function draws every visible item into the specified rectangle.

As implemented in CListBoxView, this function's argument is ignored and the internal viewing rectangle is used. See SetViewRect().

Parameters:
@c  TRect* aClipRect = NULL The rectangle to draw into.

Reimplemented from CListBoxView.

Reimplemented in CAknGMSStyleGridView.

IMPORT_C void CAknGridView::DrawColumnRange TInt  aStartColIndex,
TInt  aEndColIndex
const [protected]
 

This function draws every item in every column between the start and end columns inclusively.

Parameters:
aStartColIndex  The first column to draw.
aEndColIndex  The last column to draw.
virtual IMPORT_C void CAknGridView::DrawEmptyList  )  const [virtual]
 

Draws empty grid list.

virtual IMPORT_C void CAknGridView::DrawItem TInt  aItemIndex  )  const [virtual]
 

This has been overloaded to ensure that only valid cells are drawn and not the empty cells.

Parameters:
aItemIndex  Index number of the item to draw.

Reimplemented from CListBoxView.

virtual IMPORT_C void CAknGridView::DrawItemRange TInt  aStartItemIndex,
TInt  aEndItemIndex
const [virtual]
 

This function draws every item between the start and end indices inclusively.

Parameters:
aStartItemIndex  The first item to draw.
aEndItemIndex  The final item to draw.
virtual IMPORT_C void CAknGridView::DrawMatcherCursor  )  [virtual]
 

From CListBoxView.

Basically empty implementation of CListBoxView::DrawMatcherCursor.

Reimplemented from CListBoxView.

IMPORT_C TSize CAknGridView::GridCellDimensions  )  const
 

Returns the current grid dimensions.

Returns:
The size of the current grid.
CAknGridM * CAknGridView::GridModel  )  const [inline, protected]
 

This inline function is grid model helper.

Returns:
A pointer to CAknGridM object.
IMPORT_C TBool CAknGridView::IsPrimaryVertical  )  const
 

Returns ETrue if the primary dimension of the grid is vertical.

Returns:
if vertical is set as primary, otherwise EFalse.
IMPORT_C TBool CAknGridView::ItemExists TInt  aListBoxIndex  )  const [protected]
 

This function tests whether an item exists.

Parameters:
aListBoxIndex  Index to test.
Returns:
ETrue if the specified item exists, EFalse otherwise.
virtual IMPORT_C TPoint CAknGridView::ItemPos TInt  aItemIndex  )  const [virtual]
 

This function gets the position of the top left corner of the specified item, in pixels.

Parameters:
aItemIndex  An item in the model.
Returns:
TPoint position of the top left corner of the item, in pixels.

Reimplemented from CListBoxView.

virtual IMPORT_C TSize CAknGridView::ItemSize TInt  aItemIndex = 0  )  const [virtual]
 

Gets the size of the specified item.

Parameters:
aItemIndex=0  The index of the item whose size this call is to get.
Returns:
TSize The size of the item in pixels.

Reimplemented from CListBoxView.

IMPORT_C TInt CAknGridView::ListBoxIndex TInt  aDataIndex  )  const
 

Returns the listbox index of given data index.

Parameters:
aDataIndex  The index of the actual data.
Returns:
The index in listbox.
IMPORT_C void CAknGridView::ListBoxIndexFromLogicalPos TInt &  aItemIndex,
TInt  aRowIndex,
TInt  aColIndex
const
 

Converts a CEikListBox index for a cell in the grid, given with respect to the snaking listbox top down, left to right structure underlying the grid structure, to a logical position on the grid, where the co-ordinates are with respect to the top left hand corner of the grid.

Parameters:
aItemIndex  Reference to the index for the cell in the grid.
aRowIndex  The row in the grid.
aColIndex  The column in the grid.
IMPORT_C void CAknGridView::LogicalPosFromDataIndex TInt  aItemIndex,
TInt &  aRowIndex,
TInt &  aColIndex
const
 

Converts an index for a cell in the grid, given with respect to the ordering of the cells in the grid, to a logical position on the grid, where the co-ordinates are with respect to the top left hand corner of the grid.

Parameters:
aItemIndex  The index for the cell in the grid.
aRowIndex  Reference to the row in the grid.
aColIndex  Reference to the column in the grid.
IMPORT_C void CAknGridView::LogicalPosFromListBoxIndex TInt  aItemIndex,
TInt &  aRowIndex,
TInt &  aColIndex
const
 

Converts a logical position on the grid, where the co-ordinates are with respect to the top left hand corner of the grid, to a CEikListBox index for the cell with respect to the snaking listbox top down, left to right structure underlying the grid structure.

Parameters:
aItemIndex  The index for the cell in the grid.
aRowIndex  Reference to the row in the grid.
aColIndex  Reference to the column in the grid.
virtual IMPORT_C void CAknGridView::MoveCursorL TCursorMovement  aCursorMovement,
TSelectionMode  aSelectionMode
[virtual]
 

Overloaded MoveCursorL method to process cursor movement according to orientation of the grid.

Parameters:
aCursorMovement  The cursor movement to apply etc. ECursorNextItem and ECursorPreviousItem.
aSelectionMode  The selection mode of the calling list box.
void CAknGridView::MoveCursorWithRepeatsL TBool  aNextOrPrev,
TSelectionMode  aSelectionMode,
TInt  aAmount
 

Moves cursor with repeats.

Parameters:
aNext  ETrue if next, EFalse if previous.
aSelectionMode  selection mode.
aAmount  Amount of steps to move.
IMPORT_C void CAknGridView::MoveToItemIndexL TInt  aItemIndex,
TSelectionMode  aSelectionMode
 

This moves to the item and draws the grid in the right place.

Parameters:
aItemIndex  The wanted item index.
aSelectionMode  Mode for modifying the selection.
IMPORT_C TInt CAknGridView::NumberOfColsInView  )  const
 

This function returns the number of visible columns.

Returns:
The number of visible columns in view.
IMPORT_C TInt CAknGridView::NumberOfRowsInView  )  const
 

This function returns the number of visible rows.

Returns:
The number of visible rows in view.
virtual IMPORT_C TBool CAknGridView::ScrollToMakeItemVisible TInt  aItemIndex  )  [virtual]
 

Makes the specified item visible by moving the view location and redrawing the control.

Index of the item to make visible.

Parameters:
aItemIndex  Index of the item to make visible.
Returns:
ETrue if the control was redrawn, EFalse if no redraw happened (i.e. the item was already visible, or redraw was disabled).

Reimplemented from CListBoxView.

IMPORT_C void CAknGridView::SetColumnWidth TInt  aColumnWidth  ) 
 

This function sets the width of the grid column.

This should only be called via the selection box class's SetColumnWidth method.

Parameters:
aColumnWidth  The required width of all columns in the view, in pixels.
IMPORT_C void CAknGridView::SetCurrentDataIndex TInt  aDataIndex  ) 
 

Sets the current data index with a value given with respect to the ordering of the cells in the grid.

Parameters:
aDataIndex  The index to be set.
IMPORT_C void CAknGridView::SetGridCellDimensions TSize  aGridDimensions  ) 
 

Checks that number of cells in the grid is always enough to fill the current grid dimensions.

This method should be called after any method that may alter the amount of data within the grid.

Parameters:
aGridDimensions  Grid diemnsions.
IMPORT_C void CAknGridView::SetGridDetails SGrid  aGridDetails  ) 
 

Grid initialisation function.

Parameters:
aGridDetails  Struct of grid details.
virtual IMPORT_C void CAknGridView::SetItemHeight TInt  aItemHeight  )  [virtual]
 

This function sets item height in pixels.

Parameters:
aItemHeight  New height in pixels for this view’s items.

Reimplemented from CListBoxView.

IMPORT_C void CAknGridView::SetPrimaryScrollingType TScrollingType  aScrollingType  ) 
 

Sets the form of scroll to activate upon reaching the limit when moving in the primary direction of grid, primary meaning whether the items are organised vertically or horizontally.

Parameters:
aScrollingType  The primary scrolling type.
IMPORT_C void CAknGridView::SetSecondaryScrollingType TScrollingType  aSecondaryScrolling  ) 
 

Sets the form of scroll to activate upon reaching the limit when moving in the secondary direction of grid.

Parameters:
aSecondaryScrolling  The secondary scrolling type.
IMPORT_C void CAknGridView::SetSpacesBetweenItems TSize  aSizeOfSpaceBetweenItems  ) 
 

Sets the size of the spaces between items.

Parameters:
aSizeOfSpaceBetweenItems  The size of the spaces between items.
virtual IMPORT_C void CAknGridView::SetTopItemIndex TInt  aItemIndex  )  [virtual]
 

Sets which item appears at the top left corner of the view.

The function changes items displayed in the view appropriately.

Parameters:
aItemIndex  Index of the item to set at the top left.

Reimplemented from CListBoxView.

IMPORT_C void CAknGridView::UpdateHScrollOffsetBasedOnTopItemIndex  )  [protected]
 

This function updates the horizontal scroll offset (iHScrollOffset) based on the top item’s index.

This function is called internally by CEikSnakingListBoxes when needed.

virtual IMPORT_C TInt CAknGridView::VisibleWidth const TRect &  aRect  )  const [virtual]
 

Gets the visible width of the specified rectangle in pixels.

Parameters:
aRect  Reference to the rectangle for which to get the visible width.
Returns:
Visible width of aRect in pixels.

Reimplemented from CListBoxView.

virtual IMPORT_C TBool CAknGridView::XYPosToItemIndex TPoint  aPosition,
TInt &  aItemIndex
const [virtual]
 

Converts a pixel position into an item index.

The function returns ETrue and sets aItemIndex to the index of the item whose bounding box contains aPosition. Returns EFalse if no such item exists.

Parameters:
aPosition  A position relative to the origin of the list box control.
aItemIndex  Is set to the item at that position.
Returns:
ETrue if there was an item at aPosition.

Reimplemented from CListBoxView.


The documentation for this class was generated from the following file:

Copyright © Nokia Corporation 2001-2008
Back to top