Resources | Resources |



Using list, pick, and grid widget

This example shows how to create a list widget and the associated item widget and model.

  1. Call ISHELL_CreateInstance() with a ClassID of either AEECLSID_CListWidget, AEECLSID_CPickWidget, or AEECLSID_CGridWidget.
    ERR_TRY( ISHELL_CreateInstance(me->piShell, AEECLSID_CListWidget, 
  2. Create the item widget that will be inserted in the list widget. In this example a static widget is created.
    ERR_TRY( ISHELL_CreateInstance(me->piShell, AEECLSID_CStaticWidget, 
  3. Create a vector model that will supply data to the list widget, and call IWidget_SetModel() to attach the vector model to the list.
    ERR_TRY( ISHELL_CreateInstance(me->piShell, AEECLSID_CVectorModel  
    ERR_TRY( IWidget_SetModel(piw, IVectorModel_TO_IMODEL(pivm)));
  4. Call IDecorator_SetWidget() to insert the static widget into the list widget.
    // StaticWidget to use as 'item' widget 
    IDecorator_SetWidget((IDecorator *)(void*) piw, pisw);
  5. Retrieve the height of the item widget by calling IWidget_GetPreferredExtent(), then set the height of the list item by calling IWidget_SetItemHeight().
    IWidget_GetPreferredExtent(pisw, &weStatic); 
    ERR_TRY( IWidget_SetItemHeight(piw, weStatic.height));

    Note: For a vertical list (list widget), the application sets the item height. For a horizontal list, the application sets the item width.