Header Sep
Symbian OS Tips, Tricks & Code
Score
Login to rate page

August 2005
Displaying a list of any kind of control

[Back]

There are a number of predefined list boxes in UIQ, for example CEikColumnListBox, CEikSnakingTextListBox and CeikHierarchicalListBox.

These list controls are very useful for displaying texts and images in a list-like fashion, but there are occasions when a more generic list box would be appropriate. The following example application shows how arbitrary controls can be put in a list.

Download application example>>

The screen shot below shows the example application running.

In this example, the generic list is represented by the template class CGenericList. The template parameter represents the controls that are put in the list.

The public interface to this class includes the following methods:

template <class T>
class CGenericList : public CCoeControl 
{
public:
 ~CGenericList();
 void ConstructL(TInt width, TInt rowheight);
 TRect AddControlL(T* control);
 TInt CurrentItemIndex() const; 
 T* GetItem(TInt num) const; 
 TInt NumItems() const;
}

In the example application, the control which is displayed by the generic list is called CThreeTexts. An individual instance of this control might have the following appearance:

 

Score
Login to rate page