Resources | Resources |



XY container

The XY container manages widgets that are placed at absolute locations (x, y coordinates) in the container. The coordinates of each child object are relative to the extent of the XY container. Therefore, a widget placed at (2, 5) within an XY container would be placed 2 pixels from the container's left edge, and 5 pixels from the top. Objects are positioned by specifying their point of origin, with the object extent entirely under the control of the object itself (unlike objects placed in card, prop, or constraint containers, where the container grants an extent to each object).

Objects within an XY container may overlap one another with the widgets at the top of the widget stack being those that appear to lay "on top" of lower objects.

The XY container is the simplest container among all available containers and does not set extent on its child widget, but relies on the extent the application has set on the widget. The XY container does not do any layout, which makes it the most efficient container. It depends on the application to insert a child at a particular (x, y) position within the widget.

To use an XY container, an application needs to explicitly provide the location and size for each child widget. The application also needs to have logic to layout the screen contents based on screen resolution. The XY container is described in greater detail in AEEIXYContainer.h in the

Using XY container

The following sample code shows how an XY container is created and how child widgets are inserted into the XY container.

AEEResult SampleTouchApp_AddScrollIndicator(IWidget *piw,
            IWidget **ppXYCont, IXYContainer **ppcXYCont, IShell *piShell)
   IWidget* piwScrollbar;
   int nErr;
   WidgetExtent weScroll;
   WidgetExtent weTarget;
   WidgetPos wpos;

   ERR_TRY( ISHELL_CreateInstance(piShell, AEECLSID_SimpleScrollIndicatorWidget,
               (void**)&piwScrollbar) );

   // set up scrollbar properties
   ERR_TRY( IWidget_SetTargetWidget(piwScrollbar, piw) );
   // overriding the default width, 3 pixels is way too litle
   ERR_TRY( IWidget_SetScrollHandleWidth(piwScrollbar, 10) );
   IWidget_GetExtent(piw, &weTarget);
   IWidget_GetPreferredExtent(piwScrollbar, &weScroll);
   weScroll.height = weTarget.height;
   IWidget_SetExtent(piwScrollbar, &weScroll);

   // create container
   ERR_TRY( ISHELL_CreateInstance(piShell, AEECLSID_CXYContainer,
              (void**)ppcXYCont) );

   ERR_TRY( IXYContainer_QueryInterface(*ppcXYCont, AEEIID_IWidget,
              (void**)ppXYCont) );
   IWidget_SetExtent(*ppXYCont, &weTarget);
   wpos.x = 0;
   wpos.y = 0;
   wpos.bVisible = TRUE;
   ERR_TRY( IXYContainer_Insert(*ppcXYCont, piw, WIDGET_ZNORMAL, &wpos) );
   wpos.x = weTarget.width - weScroll.width;
   wpos.y = 0;
   wpos.bVisible = TRUE;
   ERR_TRY( IXYContainer_Insert(*ppcXYCont, piwScrollbar,
                                WIDGET_ZNORMAL, &wpos) );

   return nErr;