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

Developer

resources

Setting up the root container

Before an application creates widgets, it should create a root container, provide it with a drawing canvas, set the extent of the container, and enable touch support (optional), as described in the following procedure:

  1. Create the root container by calling ISHELL_CreateInstance(), as follows:
    if (AEE_SUCCESS != ISHELL_CreateInstance(pMe->piShell,
                AEECLSID_CRootContainer, (void**)&pMe->picRoot)) {
       pMe->picRoot = NULL;
       return FALSE;
    }
  2. Call IRootContainer_QueryInterface() to get the IWidget interface for the root container:
    if (AEE_SUCCESS != IRootContainer_QueryInterface(pMe->picRoot,
                AEEIID_IWidget, (void**)&pMe->piwRoot)) {
     		pMe->piwRoot = NULL;
     		return FALSE;
    }
  3. Create a canvas, which provides a drawing surface for widgets and other components to draw upon. For example:
    if (AEE_SUCCESS != ISHELL_CreateInstance(pMe->piShell,
                AEECLSID_DisplayCanvas,(void**)&pMe->piCanvas)) {
     		pMe->piCanvas = NULL;
     		return FALSE;
    }
  4. Assign a display to the canvas. For example:
    // Set IDisplay object for the canvas
    if (AEE_SUCCESS != IDisplayCanvas_SetDisplay(pMe->piCanvas,
                pMe->piDisplay)) {
     		return FALSE;
    }
  5. Get the device bitmap and get the device information (the size) from the bitmap. Then use the bitmap size to set extent of the root container with the SETAEERECT macro. For example:
    if (AEE_SUCCESS != IDISPLAY_GetDeviceBitmap(pMe->piDisplay, &pb)) {
       pb = NULL;
       return FALSE;
    }
    // get the device info (size of the bitmap)
    (void) IBITMAP_GetInfo(pb, &biDevice, sizeof(biDevice));
    (void) IBITMAP_Release(pb);
    SETAEERECT(&pMe->rcContainer, 0, 0, (short) biDevice.cx,
                   (short) biDevice.cy);
    	
  6. Set the canvas and the extent for the root container, as follows:
       IRootContainer_SetCanvas(me->picRoot, (ICanvas*) (void*) piCanvas,
                   &me->rcContainer);
    

    The root container extent is specified by the third parameter to IRootContainer_SetCanvas(), which was set in step 5 above.

  7. Set properties for root container, if needed. For example, the background color is set by calling IWidget_SetBGColor():
    (void) IWidget_SetBGColor(me->piwRoot, RGB_TEAL);

    RGB_TEAL is defined using the MAKE_RGBA macro, which is defined in AEERGBVAL.h. It creates an RGBVAL from red, green, and blue values:

    #define RGB_TEAL    MAKE_RGBA(0,200,200,255)
  8. If the application will provide touch support, enable touch on the root container. For example:
    if (AEE_SUCCESS != IWidget_EnableTouch(pMe->piwRoot)) {
     		return FALSE;
    }