(转)ListBox详解一

转自:http://www.newlc.com/article.php3?id_article=136

 

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

转载于:https://www.cnblogs.com/candyboy/archive/2010/04/20/1716421.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值