Location:
eiklbv.h
Link against:
eikcoctl.lib
CListBoxView
Supported from 6.0
List box view.
A list box view displays the list items which are currently visible in a list box. List box views draw each of the items for display using methods defined in their associated list box drawer.
Together with its list item drawer, a CListBoxView
encapsulates the on-screen appearance of data in a list box.
List box views also encapsulate item selection, the current item, and the fundamentals of how the selection and the current item are updated according to user input. Input events themselves are handled by CEikListBox
, which calls member functions of CListBoxView
appropriately.
This class is sufficient for plain list box views, and may be derived from in order to provide more complex list views. Uikon supplies and uses the classes CHierarchicalListBoxView
and CSnakingListBoxView
, which provide two kinds of indented list views.
|
Defined in CListBoxView
:
BackColor()
, BottomItemIndex()
, CListBoxView()
, CSelectionIndexArray
, CalcBottomItemIndex()
, CalcDataWidth()
, CalcNewTopItemIndexSoItemIsVisible()
, ClearFlags()
, ClearSelection()
, ClearSelectionAnchorAndActiveIndex()
, ConstructL()
, CurrentItemIndex()
, DataWidth()
, DeselectItem()
, Draw()
, DrawItem()
, DrawMatcherCursor()
, EAnchorExists
, EContiguousSelection
, ECursorFirstItem
, ECursorLastItem
, ECursorNextColumn
, ECursorNextItem
, ECursorNextPage
, ECursorPreviousColumn
, ECursorPreviousItem
, ECursorPreviousPage
, EDimmed
, EDisableRedraw
, EDisjointSelection
, EEmphasized
, EHasMatcherCursor
, ENoSelection
, ESingleSelection
, Flags()
, GetSelectionIndexesL()
, HScroll()
, HScrollOffset()
, HideMatcherCursor()
, IsVisible()
, ItemDrawer()
, ItemIsSelected()
, ItemIsVisible()
, ItemPos()
, ItemSize()
, MatcherCursorPos()
, MoveCursorL()
, NumberOfItemsThatFitInRect()
, RedrawDisabled()
, ScrollToMakeItemVisible()
, SelectItemL()
, SelectRangeL()
, SelectionIndexes()
, SetAnchor()
, SetBackColor()
, SetCurrentItemIndex()
, SetDimmed()
, SetDisableRedraw()
, SetEmphasized()
, SetFlags()
, SetHScrollOffset()
, SetItemHeight()
, SetMatcherCursor()
, SetMatcherCursorColor()
, SetMatcherCursorPos()
, SetPaintedSelection()
, SetSelectionIndexesL()
, SetTextColor()
, SetTopItemIndex()
, SetViewRect()
, SetVisibilityObserver()
, TCursorMovement
, TFlags
, TSelectionMode
, TextColor()
, ToggleItemL()
, TopItemIndex()
, UpdateSelectionL()
, VScrollTo()
, VerticalMoveToItemL()
, ViewRect()
, VisibleWidth()
, XYPosToItemIndex()
, iBottomItemIndex
, iCurrentItemIndex
, iDataWidth
, iFlags
, iGc
, iGroupWin
, iHScrollOffset
, iItemDrawer
, iItemHeight
, iModel
, iTopItemIndex
, iViewRect
, iWin
, ~CListBoxView()
Inherited from CBase
:
operator new()
CListBoxView();
Default constructor.
Allocates an area of memory for a CListBoxView
, and begins its initialisation.
virtual void ConstructL
(MListBoxModel* aListBoxModel,
CListItemDrawer* aItemDrawer,
CWsScreenDevice* aScreen,
RWindowGroup* aGroupWin,
RWindow* aWsWindow,
const TRect& aDisplayArea,
TInt aItemHeight);
Second-phase constructor.
This function completes the initialisation of a default-constructed list box view. The item drawer’s graphics context is created on aScreen
, and the list item drawer’s graphics context is set to this. See CListItemDrawer::SetGc()
.
|
~CListBoxView();
Destructor.
The destructor destroys this list box view, its item drawer, its graphics context and its selection list.
One item, usually visible in the view, is current at any time. Moving the current item in a list box control may also change the box’s selection state: see TSelectionMode
below.
TInt CurrentItemIndex() const;
Gets the current item’s index.
|
virtual void MoveCursorL(TCursorMovement aCursorMovement,TSelectionMode aSelectionMode);
Moves the current item cursor in the specified direction. This function is called by CEikListBox
in response to user input.
|
void VerticalMoveToItemL(TInt aTargetItemIndex, TSelectionMode aSelectionMode);
Moves to the specified item, sets it as the current item and scrolls the display to make the item visible.
|
void SetCurrentItemIndex(TInt aItemIndex);
Set the index of the current item. This function changes the current item, but does not redraw the list view or update the selection.
|
Multiple items can be selected in a list box at a time if the appropriate flags are set.
const CSelectionIndexArray* SelectionIndexes() const;
Gets a pointer to the selection list of this view.
|
void GetSelectionIndexesL(CSelectionIndexArray* aSelectionArray) const;
Gets a copy of the array of currently selected items.
|
void SetSelectionIndexesL
(const CSelectionIndexArray* aSelectionIndexes);
Sets the currently selected items of this view from a selection index array.
|
void ToggleItemL(TInt aItemIndex);
Toggles the selection of an item.
|
void SelectItemL(TInt aItemIndex);
Selects an item by index.
This function leaves if memory could not be allocated for an extra item in the array of selected items.
|
void DeselectItem(TInt aItemIndex);
Deselects an item by index.
|
void SelectRangeL(TInt aItemIndex1, TInt aItemIndex2);
Selects all items in the list between the two specified indices, inclusively.
|
TRect ViewRect() const;
Gets the list box’s view rectangle.
|
void SetViewRect(const TRect& aRect);
Sets the area within the list window in which the view can draw itself.
|
TInt TopItemIndex() const;
Gets the index of the item at the top of the view.
|
virtual void SetTopItemIndex(TInt aItemIndex);
Sets the item at the top of the view by its index in the list of all items. This function also invokes CalcBottomItemIndex()
.
|
TInt BottomItemIndex() const;
Gets the index of the item at the bottom of this view.
|
virtual void CalcBottomItemIndex();
Recalculates the index of the bottom item in the list from the top item index and the size of the display.
This function is called by the owning list box control when either the size of the list box or the number of items in its model changes.
virtual void SetItemHeight(TInt aItemHeight);
Sets the item height.
|
void SetCurrentItemIndex(TInt aItemIndex);
Sets the item at the specified index to be the current item. The function panics if the specified item index is not valid.
|
void ClearSelectionAnchorAndActiveIndex();
Sets the anchor index and active end index to NULL
, clears the EAnchorExists
flag.
void SetAnchor(TInt aItemIndex);
Sets the anchor to the specified item.
|
const CSelectionIndexArray* SelectionIndexes() const;
Gets the selection index array.
|
void SetBackColor(TRgb aColor);
Sets the background colour.
|
void SetPaintedSelection( TBool aPaintedSelection );
Sets the painted selection flag.
|
void SetTextColor(TRgb aColor);
Sets the colour in which to display text.
|
TRgb TextColor() const;
Gets the colour in which text is to be displayed.
|
virtual void UpdateSelectionL(TSelectionMode aSelectionMode);
Updates item selection.
|
Functions for getting and setting information about the state of the incremental match cursor in this view. Pixel-level positioning of the matching cursor is implemented in a list box’s item drawer (see CListItemDrawer
).
void SetMatcherCursorColor(TRgb aColor);
Sets the match cursor’s colour.
|
void SetMatcherCursorPos(TInt aPosWithinCurrentItem);
Sets the match cursor’s position.
|
TInt MatcherCursorPos() const;
Gets the match cursor’s position.
|
void DrawMatcherCursor();
Draws the match cursor in its current screen position if the matcher cursor flag has been set.
void SetMatcherCursor(TBool aMatcherCursor);
Sets or resets the matcher cursor flag to specify whether the match cursor is drawn.
|
void SetEmphasized(TBool aEmphasized);
Sets whether or not items are drawn emphasised.
The function sets or resets the emphasised flag.
|
void SetDimmed(TBool aDimmed);
Sets whether or not items will be drawn dimmed.
The function sets or resets the dim flag.
|
void SetDisableRedraw(TBool aDisableRedraw);
Disables or enables redraws.
If this flag is set to ETrue
, all member functions which draw items will return immediately without drawing anything. Functions which update the internal state of the list box will still work, but nothing will be drawn or updated on the screen.
|
TBool RedrawDisabled() const;
Tests whether redraw is disabled.
|
void VScrollTo(TInt aNewTopItemIndex);
Scroll vertically to the specified item. Scrolls the contents of this list view so that the specified item is the top item, and redraws the view.
|
void VScrollTo(TInt aNewTopItemIndex, TRect& aMinRedrawRect);
Scroll vertically to the specified item and get the minimum rectangle to redraw. Scrolls the contents of this list view so that the specified item is the top item, and redraws the view.
This two argument version returns the area which needs redrawing via aMinRedrawRect&
.
|
virtual TBool ScrollToMakeItemVisible(TInt aItemIndex);
Scrolls vertically to make a particular item visible.
|
|
void VScrollTo(TInt aNewTopItemIndex);
Sets the index of the item to be the top item.
|
void VScrollTo(TInt aNewTopItemIndex,TRect& aMinRedrawRect);
Sets the index of the item to be the top item.
This two argument version returns the area which needs redrawing via aMinRedrawRect&
. This function does not perform the redraw.
|
virtual void HScroll(TInt aHScrollAmount);
Scrolls horizontally by the specified number of pixels.
|
TInt HScrollOffset() const;
Gets the offset of the visible portion of the data from the left margin in pixels.
|
void SetHScrollOffset(TInt aHorizontalOffset);
Sets the horizontal scroll offset in pixels.
|
TInt DataWidth() const;
Gets the width of the widest item in the list in pixels.
|
virtual void CalcDataWidth();
Recalculates the data width of this list box view from the item width of its list item drawer. This method is called directly by CEikListBox
when the list box’s size changes or when data is added.
virtual TInt VisibleWidth(const TRect& aRect) const;
Gets the visible width of the specified rectangle in pixels. This function is called by CListBoxView
itself on its own viewing rectangle.
|
|
virtual TInt CalcNewTopItemIndexSoItemIsVisible(TInt aItemIndex) const;
Calculates which item should be scrolled to in order to make a particular item visible. Calling VScrollTo(CalcNewTopItemIndexSoItemIsVisible(idx))
, for example, would make the item whose index is idx
visible.
|
|
virtual void Draw(const TRect* aClipRect = NULL) const;
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()
.
|
virtual void DrawItem(TInt aItemIndex) const;
Draws the specified item via CListBoxDrawer::DrawItem()
if it is visible.
|
Functions for querying an item’s position and size, selection status, and visibility status.
virtual TBool XYPosToItemIndex(TPoint aPosition,TInt& aItemIndex) const;
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.
|
|
TBool ItemIsSelected(TInt aItemIndex) const;
Tests whether an item is selected.
|
|
TBool ItemIsVisible(TInt aItemIndex) const;
Tests whether an item is visible.
|
|
virtual TPoint ItemPos(TInt aItemIndex) const;
Gets the on-screen position of an item.
|
|
virtual TSize ItemSize(TInt aItemIndex=0) const;
Gets the on-screen size of an item.
As implemented in CListBoxView
, all items report the same size. The size returned may be larger than the width of the list box view, but will not be smaller.
|
|
TInt NumberOfItemsThatFitInRect (const Trect& aRect);
Gets the number of items that will fit into a given rectangle.
|
|
void SetVisibilityObserver(MListVisibilityObserver* aObserver);
Sets the visibility observer.
|
TBool IsVisible() const;
Tests if this view is visible.
|
CListItemDrawer* ItemDrawer() const;
Gets the object used by this list box view to draw its items.
|
TRgb BackColor() const;
Gets the background colour for this view.
|
protected: TInt Flags() const;
Gets this view’s flags.
|
protected: void SetFlags(TInt aMask);
Sets this view’s flags according to a bitmask.
|
protected: void ClearFlags(TInt aMask);
Clears this view’s flags according to a bitmask.
|
The following protected
member data may be accessed by classes derived from CListBoxView
, or through the member functions above. Private data members are not documented.
TInt iFlags
The flags for this list box; these flags are defined by the nested enum TFlags
(below).
TInt iTopItemIndex
Index of the item at the top of the view. This is not necessarily the item at the start of the list.
TInt iBottomItemIndex
Index of the item at the bottom of the view. This is not necessarily the item at the end of the list.
TInt iHScrollOffset
Pixel offset of the visible portion of the data from the left margin.
enum TSelectionMode;
Modes for modifying the selection.
Changing the current item of a list box view may also affect which items are selected. The selection mode of such an action describes how (or if) the selection is altered by the action.
Each function of CListBoxView
which affects the current item is passed an appropriate selection mode by the calling input handler method of CEikListBox
. The mode is varied according to the keyboard modifiers held down by the user, or whether a pointer action was a tap or a sweep.
Note that the behaviour of list box views may vary with the target platform due to the wide range of possible input devices. The following description assumes a device with a pointer and a keyboard.
|
enum TCursorMovement;
Cursor movement flags. These describe the cursor movements recognised by MoveCursorL()
.
|
enum TFlags;
List box view flags
These flags may be combined with a logical OR to get a combination of effects.
|
typedef CArrayFix<TInt> CSelectionIndexArray;
The items which are selected within a list box list.