Listbox Overview
16 Oct 2003 - 22:09
Keywords :

1.1. The ListBox MVC Paradigm

The Symbian ListBox control is, like many other Symbian controls, an implementation of the Model-View-Controller paradigm:
-  the MListBoxModel class represents the model (the data). It is an abstract class that only specifies an interface to access concrete model implementation.
-  the CListBoxView and CListItemDrawer classes represents the view (all the things the user can see).
-  the CEikListBox is the controller which connects the model and the view.

lb.png

1.2 The Model

lbmodel.pngThe MListBoxModel provides the bare bones of what a list box requires, it contains only two methods:
-  NumberOfItems() which returns the number of items in the model
-  MatchableTextArray() shall return an array of strings which is used by the list box for matching user keypresses incrementally.

//<eiklbm.h>
class MListBoxModel
{
public:
  IMPORT_C virtual ~MListBoxModel();
  virtual TInt NumberOfItems() const = 0;
  virtual const MDesCArray* MatchableTextArray() const = 0;
};

MListBoxModel is a completely generic class. A more specialised class is MTextListBoxModel. This interface, that inherits from MListBoxModel, represents a text based list model. It adds an abstract method, ItemText that returns the item content as a string:

//<eiklbm.h>
class MTextListBoxModel : public MListBoxModel
{
public:
  IMPORT_C ~MTextListBoxModel();
  virtual TPtrC ItemText(TInt aItemIndex) const = 0;
};

Symbian provides a default MTextListBoxModel implementation: CTextListBoxModel.

1.3 The View

The Listbox View takes care of the appearance of listbox items, maintaining and displaying a list of currently visible items. To display items, View uses concrete implementation of the Item Drawer and concrete implementation of the Model. Its members are, among others, a pointer to MListBoxModel-derived data source and a pointer to CListItemDrawer-derived drawer.

View also implements concepts like item selection and current item.

Unlike Model and Item Drawer, base CListBoxView class is directly used in text-based listboxes, without having to derive and implement text-specific variant. However, UIKON also offers a few specific CListBoxView implementations.

lbview.png


Part II :>:


AttachmentSize
lbdrawer.png3.77 KB
Tutorial posted October 16th, 2003 by eric

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Submitted by Stakshi on Wed, 2008-01-16 08:33.

Thanks to writter...
It was worth reading it as i am a beginner

Cheers
Sj



copyright 2003-2009 NewLC SARL