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

Developer

resources

Using a frame widget

To use a frame widget to view images from a camera, an application would do the following:

  1. Create an instance of the frame widget by calling ISHELL_CreateInstance() with the AEECLSID_CFrameWidget ClassID.
    nErr = ISHELL_CreateInstance(me->piShell, AEECLSID_CFrameWidget,
                (void**)&me->piwFrame);
  2. Set properties for the frame widget. In this case, the application sets the background color. Set the extent by calling IWidget_SetExtent().
    if (!nErr) {
       IWidget_SetExtentEx(me->piwFrame, me->rcContainer.dx,
                   me->rcContainer.dy - BUTTON_WIDTH);
       (void)IWidget_SetBGColor(me->piwFrame, MAKE_RGB(0,0,0));
    }
  3. Create an instance of ICamera and set its size:
    if (!nErr) {
       nErr = ISHELL_CreateInstance(me->piShell, AEECLSID_CCAMERA,
                   (void**)&me->piCamera);
    }
    
    if (!nErr) {
       AEESize size;
       size.cx = me->rcContainer.dx;
       size.cy = me->rcContainer.dy - BUTTON_WIDTH;
       (void)ICAMERA_SetSize(me->piCamera, &size);
       (void)ICAMERA_SetDisplaySize(me->piCamera, &size);
    }
  4. Create an instance of IFrameModel by calling ISHELL_CreateInstance() with the AEECLSID_CCameraFrameModel ClassID:
    if (!nErr) {
       nErr = ISHELL_CreateInstance(me->piShell, AEECLSID_CCameraFrameModel,
                   (void**)&piModel);
    }
  5. Register for camera notifications and insert the ICamera instance into the camera frame model, as follows:
    if (!nErr && NULL != piModel) {
       ICameraFrameModel_RegisterNotify(piModel, CameraApp_Notify, me);
    }
    
    if (!nErr && NULL != piModel) {
       nErr = ICameraFrameModel_SetICamera(piModel, me->piCamera);
    }
  6. Set the camera frame model on the frame widget:
    if (!nErr) {
          (void)IWidget_SetModel(me->piwFrame, (IModel*)(void *)piModel);
       }

Typically, widget sets the frame size based on its own extent by calling IFrameModel_SetSize(). However, the frame size could be different because of underlying media object limitations or applications changing the frame size explicitly by calling IFrameModel_SetSize(). If the frame size is smaller than the widget extent, the frame is drawn at the center of the widget. If the frame size is larger than the widget extent, the bottom or the right portion of the frame will be clipped to the widget's extent.