Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Creating a flickable list widget

This topic describes how to create a list widget with flickable contents.

The example code shown in this topic is from c_listwidgettouch_app. The list in this application uses a list widget that is associated with a vector model and a static widget as a list item widget.

To create a flickable list, an application needs to do the following:

  • Create a list widget
  • Create a list model and add the model elements
  • Set a model to the list widget
  • Create a list item widget
  • Set the list item widget to the list widget
  • Set the height of the list item widget of the list widget
  • Set the extent of the list widget
  • Set the LWF_LIVESCROLL and/or LWF_PIXELSCROLL flag to the list widget to enable panning and flicking capability
  • Insert the list widget in the root container

Examples of each of these steps are shown below.

Create a list widget

Create a list widget from the AEECLSID_CListWidget.

ERR_TRY(ISHELL_CreateInstance(me->piShell, AEECLSID_CListWidget, (void**)&piw));

Create a list model

Create a list model to be associated with the list widget.

ERR_TRY(ISHELL_CreateInstance(me->piShell, AEECLSID_CVectorModel, (void**)&pivm));

Set the model to the List widget

Set the created list model to the list widget:

ERR_TRY(IWidget_SetModel(piw, IVectorModel_to_IModel(pivm)));

Create a list item widget

Create a child widget as a list item widget. In this example, the application is creating a static widget as a list item.

ERR_TRY(ISHELL_CreateInstance(me->piShell, AEECLSID_CStaticWidget, (void**)&pisw));

Set the list item widget to the list widget

Set the list widget to decorate the list item widget.

   // set StaticWidget as the listitem widget
   IDecorator_SetWidget((IDecorator *)(void*) piw, pisw);

Set scroll flags

In this example, the application sets the LWF_PIXELSCROLL flag to enable the list to be scrolled pixel by pixel instead of line by line:

// Enable the flicking capacities of the list      
(void) IWidget_SetFlags(piw, LWF_PIXELSCROLL);

Insert the List widget in the root container

Insert the list widget in the root container, as follows:

   WidgetPos wpos;
   wpos.x = x;
   wpos.y = y;
   wpos.bVisible = bVisible;

   (void) IRootContainer_Insert(me->picRoot, piw, WIDGET_ZNORMAL, &wpos);
   (void) IWidget_MoveFocus(me->piwRoot, piw);

The menu list is inserted at 0,0 coordinates.