Lists API: API description

Listbox architecture follows the Model-View-Controller (MVC) design pattern; a listbox-specific representation of the MVC design pattern is introduced.

The listbox layouts presented here provide a graphical representation of the various listbox outlooks. Listbox items consist of columns into which each item is placed. These column structures define the item format of the listbox items, and therefore the presentation of the listbox. Listbox columns may consist of text strings and graphics (small and large icons).

Listbox resource files define the resource data used to create lists. The resource data consists of listbox layout and listbox item arrays.

Lists can also be created at run time without resource files.

Listbox architecture

The listbox control, is an implementation of the MVC design pattern. CEikListBox is the base class for all lists in the S60 platform. It also acts as the controller. CListBoxView represents the view and MListBoxModel the data.

The model, class MListBoxModel, is an abstract class that specifies the interface to access the data. The model does not contain any information about the appearance of the listbox.

The view, class CListBoxView, handles the appearance of the listbox and displays the items on the listbox that are currently visible.

The controller, class CEikListBox, acts as the controller between the model and the view, connecting them and communicating between them.

Figure 2: MVC representation of a listbox.

Listbox types

Lists are divided into the following types based on their functionality.

Menu listbox

Menu lists, also known as pop-up lists, provide a simple vertical list view and are used to select one item from a list. The Options command is not available while browsing the menu listbox. Only Select and Cancel actions can be performed on the menu listbox.

Figure 3: Menu listbox

Selection listbox

A selection listbox is a generic way of displaying and accessing data in an application. While browsing the selection listbox, the Options menu can also be accessed for additional functions.

Figure 4: Selection listbox

Multiselection listbox

Multiselection lists allow the user to select multiple items and perform an action on those items simultaneously. Selection is done with the selection key and acceptance with the OK softkey. The Options menu is not available while browsing and selecting items on the multiselection listbox, the user can only check and uncheck items, and accept the selections (OK) or cancel (Back).

Figure 5: Multiselection listbox

Markable listbox

A markable listbox is essentially a selection listbox with an added feature that allows list items to be marked. Any number of items can be marked on the list. A command applies to all of the marked items. The Options menu is available for additional functions while browsing and selecting items on the markable listbox.

The marking feature is usually applied to operations that handle a set of data simultaneously, such as deleting or moving items. By marking the items, the user can easily handle sets of data requiring identical actions, instead of performing the action individually on each item.

Figure 6: Markable listbox

Setting listbox

The setting listbox is a selection listbox containing items whose value can be adjusted. A setting listbox item is displayed as an attribute title text with an attribute value below it, which can be altered. The Options menu is available for additional functions while browsing the setting listbox.

Figure 7: Setting listbox

Listbox types in listbox resource definition

The listbox types are defined by the flags parameter in the LISTBOX structure. This section presents the values for the flags parameter. These identifiers are defined in the avkon.hrh file.

The flags that can be combined with any of the previous choices:

Listbox format

The listbox format and layout is defined by using string formatting for the listbox columns. The following section describes the column structures and the listbox layout types that can be used.

Listbox item column structure

Each listbox item is divided into three columns: A, B, and C. The columns can be combined so it is not necessary to have the columns separated. The following column combinations are possible for listbox items: AB, BC, and ABC.

The listbox columns are defined as follows:

An additional icon can be displayed to the right of column C, also referred to as column D.

Figure 8: Listbox item column structure

Listbox item layouts

The listbox item can be represented in the following layouts. The examples shown provide a graphical representation of the listbox layouts.

The listbox item formatting string consists of listbox item columns that are separated by the tab character (\t). Therefore tab character is not allowed in listbox string anywhere else. It has to be removed before passing to listbox.

The listbox item layouts that contain graphics (icons) specify the icon to be used when displaying the listbox item. For layouts containing graphics (icons), the listbox item formatting string contains a number defining the index of the icon to be displayed for the specific listbox item.

The following section shows the possible listbox item layouts, their graphical representation, and the formatting string.

Single-line item

Figure 9: Single-line item

Class name: CAknSingleStyleListBox

Column usage: Main text (columns ABC)

String format: “\tMeeting\t\t”

Single-line item with number

Figure 10: Single-line item with number

Class name: CAknSingleNumberStyleListBox

Column usage: Number (column A), main text (columns BC)

String format: “8\tMeeting\t\t”

Single-line item with heading

Figure 11: Single-line item with heading

Class name: CAknSingleHeadingStyleListBox

Column usage: Heading text (column A), main text (columns BC)

String format: “job\tAstronaut\t\t”

Single-line item with small graphic

Figure 12: Single-line item with small graphic

Class name: CAknSingleGraphicStyleListBox

Column usage: Small graphic (column A), main text (columns BC)

String format: “0\tDownload themes\t\t”

Please note that the first column in the item string defines the index of the icon to be displayed for the specific listbox item. See Creating a selection listbox with a large graphic a primary and a secondary text for example code on how to use the icons in the listbox.

Single-line item with small graphic and heading

Figure 13: Single-line item with small graphic and heading

Class name: CAknSingleGraphicHeadingStyleListBox

Column usage: Small graphic (column A), heading text (column B), main text (column C)

String format: “1\t21/10\tMeeting\t”

Please note that the first column in the item string defines the index of the icon to be displayed for the specific listbox item. See Creating a selection listbox with a large graphic a primary and a secondary text for example code on how to use the icons in the listbox.

Single-line item with large graphic

Figure 14: Single-line item with large graphic

Class name: CAknSingleLargeStyleListBox

Column usage: Large graphic (column A), main text (columns BC)

String format: “1\tValid keys\t\t”

Please note that the first column in the item string defines the index of the icon to be displayed for the specific listbox item. See Creating a selection listbox with a large graphic a primary and a secondary text for example code on how to use the icons in the listbox.

Two-line item

Figure 15: Two-line item

Class name: CAknDoubleStyle2ListBox

Column usage: Main text (columns ABC)

String format: “\tCertificate management\t\t”

Double item

Figure 16: Double item

Class name: CAknDoubleStyleListBox

Column usage: Primary text (columns AB), secondary text (column C)

String format: “\tActivate\tvia Bluetooth\t”

Double item with number

Figure 17: Double item with number

Class name: CAknDoubleNumberStyleListBox

Column usage: Number (column A), primary text (column B), secondary text (column C)

String format: “1\tActivate\tvia Bluetooth\t”

Please note that the first column in the item string defines the index of the icon to be displayed for the specific listbox item. See Creating a selection listbox with a large graphic a primary and a secondary text for example code on how to use the icons in the listbox.

Double item with small graphic

Figure 18: Double item with small graphic

Class name: CAknDoubleGraphicStyleListBox

Column usage: Small graphic (column A), primary text (column B), secondary text (column C)

String format: “1\tTemplates\t10 Templates\t”

Please note that the first column in the item string defines the index of the icon to be displayed for the specific listbox item. See Creating a selection listbox with a large graphic a primary and a secondary text for example code on how to use the icons in the listbox.

Double item with large graphic

Figure 19: Double item with large graphic

Class name: CAknDoubleLargeStyleListBox

Column usage: Large graphic (column A), primary text (column B), secondary text (column C)

String format: “1\Activate\tvia Bluetooth\t”

Please note that the first column in the item string defines the index of the icon to be displayed for the specific listbox item. See Creating a selection listbox with a large graphic a primary and a secondary text for example code on how to use the icons in the listbox.

Double item style 2

Figure 20: Double item style 2

Class name: CAknFormDoubleGraphicStyleListBox

Column usage: Graphic (column A), heading text (column B), main text (column C)

String format: “0\tMobile number\t+358 50 1234 7890\t”

Please note that the first column in the item string defines the index of the icon to be displayed for the specific listbox item. See Creating a selection listbox with a large graphic a primary and a secondary text for example code on how to use the icons in the listbox.

Setting item

Figure 21: Setting item

Class name: CAknSettingStyleListBox

Column usage: Attribute text (columns BC), value text (column D)

String format: “\tInput text language\t\tAutomatic”

Setting item with number

Figure 22: Setting item with number

Class name: CAknSettingNumberStyleListBox

Column usage: Number (column A), attribute text (columns BC), value text (column D)

String format: “1\tInput text language\t\tAutomatic”

Please note that the first column in the item string defines the index of the icon to be displayed for the specific listbox item. See Creating a selection listbox with a large graphic a primary and a secondary text for example code on how to use the icons in the listbox.

Use cases

The main use cases of Lists API are:

  1. Defining a listbox in resource file
  2. Creating a selection listbox from resource
  3. Creating a selection listbox runtime
  4. Creating a selection listbox with a large graphic a primary and a secondary text
  5. Getting the selected item of a selection listbox
  6. Creating a multiselection listbox
  7. Select and deselect an item in a multiselection listbox
  8. Creating a markable listbox
  9. Mark and unmark an item in a markable listbox
  10. Getting the selected items of a markable or multiselection list
  11. Creating a settings style listbox
  12. Adding an item to listbox
  13. Removing an item from listbox
  14. Getting the number of items in listbox
  15. Offering key events to listbox
  16. Handling listbox events
  17. Creating animated highlight

API class structure

This diagram shows the general structure of Lists API.

Figure 23: Ggeneral class diagram of Lists API

General structure of lists

The functionality in lists has been divided into four parts: Model, Item Drawer and View, and then Listbox that connects them together. The list items are stored in an array inside of Model. Item Drawer asks for the items to draw individual items. View asks Item Drawer to draw items, and manages drawing of many items and browsing between the items. Finally, Listbox chooses concrete instances of Model, Item Drawer and View, and handles creation of them and the communication with clients. (However, often applications need to use interfaces in classes derived from Model or ItemDrawer(), for example to set the icon array).

Figure 24: Diagram of listbox functionality


Copyright © Nokia Corporation 2001-2008
Back to top