Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

Hi ,

Can someone tell me how to use Viewport Widget correctly?

I tried the following code snippet , but nothing gets displayed on the simulator except a white blank screen:( Can some one tell me what is goin wrong here????
Thanks in advance

IDisplayCanvas *piDisplayCanvas = NULL;

// create viewport widget since it handles scroll events
nErr = ISHELL_CreateInstance(pMe->piShell, AEECLSID_ViewportWidget, (void**)&pMe->piwViewport);
if (AEE_SUCCESS != nErr) {
return nErr;

// create the scrollbar widget
nErr = ISHELL_CreateInstance(pMe->piShell, AEECLSID_ScrollbarWidget, (void**)&pMe->pidScrollbar);
if (AEE_SUCCESS != nErr) {
return nErr;

nErr =ISHELL_CreateInstance(pMe->piShell,AEECLSID_XYContainer,(void **)&pMe->piXY);
if (AEE_SUCCESS != nErr) {
return nErr;

nErr =ISHELL_CreateInstance(pMe->piShell,AEECLSID_RootContainer,(void **)&pMe->picRoot);
if (AEE_SUCCESS != nErr) {
return nErr;

nErr =ISHELL_CreateInstance(pMe->piShell,AEECLSID_GRIDVIEWWIDGET,(void **)&pMe->m_pGridWidget);
if (AEE_SUCCESS != nErr) {
return nErr;

nErr =ISHELL_CreateInstance(pMe->piShell,AEECLSID_ImageWidget,(void **)&imgWidget);
if (AEE_SUCCESS != nErr) {
return nErr;

// set extent for the XY Container
we.height = 440; // the height of the container is larger than the display.
we.width = pMe->deviceInfo.cxScreen;
IXYContainer_QueryInterface(pMe->piXY, AEEIID_IWidget, &pMe->piwXY);
IWidget_SetExtent(pMe->piwXY, &we);
CreateGrid(pMe);
dwpos.x = 30;
dwpos.y = 150;
dwpos.bVisible = TRUE;
IXYContainer_Insert(pMe->piXY, pMe->m_pGridWidget->piListWidget, WIDGET_ZNORMAL,&dwpos);

// wrap the viewport around the XY Container
IDecorator_SetWidget((IDecorator*)(void*)pMe->piwViewport, pMe->piwXY);

// adjust the scroll increment. default is 1 pixel.
IWidget_SetIncrement(pMe->piwViewport, 10);

// set extent for the viewport
we.width = (pMe->deviceInfo).cxScreen - 2;
we.height = (pMe->deviceInfo).cyScreen;
IWidget_SetExtent(pMe->piwViewport, &we);

// wrap the scrollbar around the viewport
IDecorator_SetWidget(pMe->pidScrollbar, pMe->piwViewport);

// tailor the scrollbar look & extent
IWidget_SetScrollStyle(IDecorator_to_IWidget(pMe->pidScrollbar), SCROLL_VERT);
IWidget_SetScrollColor(IDecorator_to_IWidget(pMe->pidScrollbar), MAKE_RGB(0,245,025));
IWidget_SetActiveScrollHandleColor(IDecorator_to_IWidget(pMe->pidScrollbar), MAKE_RGB(255,0,0));
IWidget_SetInactiveScrollHandleColor(IDecorator_to_IWidget(pMe->pidScrollbar), MAKE_RGB(0,0,24));
IWidget_SetActiveScrollColor(IDecorator_to_IWidget(pMe->pidScrollbar), MAKE_RGB(0,0,50));
IWidget_SetInactiveScrollColor(IDecorator_to_IWidget(pMe->pidScrollbar), MAKE_RGB(100,0,120));
IWidget_SetFlags(IDecorator_to_IWidget(pMe->pidScrollbar), 3);
IWidget_SetExtent(IDecorator_to_IWidget(pMe->pidScrollbar), &we);

// insert widget into root container
dwpos.x = 40;
dwpos.y = 40;
dwpos.bVisible = TRUE;

bgImage = ISHELL_LoadResImage(pMe->piShell, TEST_RES_FILE,5001);
IWIDGET_SetImage(imgWidget,bgImage);

// Create the display canvas.
ISHELL_CreateInstance(pMe->piShell, AEECLSID_DisplayCanvas,(void **)&(piDisplayCanvas)) ;
IDisplayCanvas_SetDisplay(piDisplayCanvas, pMe->piDisplay);
// Create the root container.
IRootContainer_Insert(pMe->picRoot, IDecorator_to_IWidget(pMe->pidScrollbar), WIDGET_ZNORMAL,&dwpos);

// Get root container's widget interface.
IRootContainer_QueryInterface(pMe->picRoot, AEEIID_IWidget,(void**) &pMe->piwRoot) ;
IRootContainer_SetCanvas(pMe->picRoot, CAST(ICanvas*, piDisplayCanvas),&rect);
IDisplay_Update (pMe->piDisplay);

Hi,
To narrow down the problem, have you tried creating and displaying just one simple widget (I'd suggest a static widget with some text)? This would be useful to help determine whether the problem is with the creation and set up of the root container, or with the code creating the XY container and decorators.
I have similar code, which works, so I know what you're trying to do is possible.
Essentially, all you need to do is create an XY container, QI it to get its IWidget interface, set the extent (and perhaps a background colour so it can be seen). You then create a viewport widget, set its extent, and use its IDecorator interface to set the widget it decorates to be the XY container's widget. Finally, you insert the viewport widget into the root container.
Sam.

Hi,
To narrow down the problem, have you tried creating and displaying just one simple widget (I'd suggest a static widget with some text)? This would be useful to help determine whether the problem is with the creation and set up of the root container, or with the code creating the XY container and decorators.
I have similar code, which works, so I know what you're trying to do is possible.
Essentially, all you need to do is create an XY container, QI it to get its IWidget interface, set the extent (and perhaps a background colour so it can be seen). You then create a viewport widget, set its extent, and use its IDecorator interface to set the widget it decorates to be the XY container's widget. Finally, you insert the viewport widget into the root container.
Sam.

Thanks Sam,
It works now:-)

Thanks Sam,
It works now:-)

Hi Atul,
Thanks for your reply.but can you tell me what is "picRootText" while you are creating the instance of root container.
Regards
Priya Prakash

Hi Atul,
Thanks for your reply.but can you tell me what is "picRootText" while you are creating the instance of root container.
Regards
Priya Prakash