Resources | Resources |



Using a list container

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

  1. Call ISHELL_CreateInstance() with a class ID of either AEECLSID_CListContainer, AEECLSID_CPickListContainer, or AEECLSID_CGridListContainer.
  2. Create a model for the list container.
  3. Call IWidget_SetModel() to attach the model to the list.
  4. Set properties, if needed.
  5. Optionally call IWidget_SetRows()/IWidget_SetCols() or IWidget_SetHintRows()/IWidget_SetHintCols()
  6. Get the list container's preferred extent by callilng IWidget_GetPreferredExtent().
  7. Call IWidget_SetExtent() on the list container widget with the desired extent.
  8. Insert the list container into a container.

The following example is from MainMenu_Display() in the image_app sample code. It creates a list container and a list container model, attaches the model to the list container, sets the extent and properties for the list container, and inserts it into the root container.

   IWidget* pLCWgt = NULL;
   IListContainerModelFactory* pLCMFactory = NULL;
   IListContainerModel* pLCM = NULL;
   WidgetExtent we;
   AEEResult nErr;

   // Create a list container widget
   ERR_TRY(ISHELL_CreateInstance(pMe->m_pIShell, AEECLSID_CListContainer,

   // Set list container padding
   ERR_TRY(IWidget_SetPadding(pLCWgt, SIZE_MAIN_MENU_PAD));

   // Create a list container model factory

   // Create a ListContainerModel instance using the
   // CreateCallbackBased method of ListContainerModelFactory

   // Attach the list container model to the list container
   ERR_TRY(IWidget_SetModel(pLCWgt, IListContainerModel_to_IModel(pLCM)));

   // Set list container widget appearance
   (void)IWidget_SetBGColor(pLCWgt, RGBA_MENU_BG);
   (void)IWidget_SetGradientStyle(pLCWgt, GRADIENT_STYLE_CENTERHORZ);
   (void)IWidget_SetGradientColor(pLCWgt, RGBA_MENU_BG_G);

   // Set the extent of the list container widget
   we.width = pMe->m_rcClient.dx;
   we.height = pMe->m_rcClient.dy;
   IWidget_SetExtent(pLCWgt, &we);

   // Insert the list container widget into the applet's root container
   ERR_TRY(ImageApp_InsertPageWidget(pMe, pLCWgt, NULL, 0, 0));

When a ListContainerModel is created by calling IListContainerModelFactory_CreateCallbackBased(), the developer supplies callback functions that the model uses to get new widgets and data to display.