Image Widget not showing... | developer.brewmp.com Image Widget not showing... | developer.brewmp.com

Developer

Image Widget not showing...

Hi all,

I'm trying to create an image widget and apply the viewport decorator to it to allow for panning. However I'm having problems just trying to get the image to load in the widget and hope someone can help me out. This is part of the code I'm using:

int FORM_PopulateMapContainer(inet2* pMe)
{

int result = 0;
WidgetPos wpos;
IWidget* containerWidget = NULL;

result = ISHELL_CreateInstance(pMe->pIShell, AEECLSID_XYCONTAINER, (void**)&pMe->mainContainer);
result += ISHELL_CreateInstance(pMe->pIShell, AEECLSID_IMAGEWIDGET, (void**)&pMe->wImage);
result += ISHELL_CreateInstance(pMe->pIShell, AEECLSID_VIEWPORTWIDGET, (void**)&pMe->viewPort);

if(result != 0)
return EFAILED;

// set the image widget through a callback
pMe->pImage = ISHELL_LoadImage(pMe->pIShell, "map.jpg");
result = IWIDGET_SetImage(pMe->wImage, pMe->pImage);

// Add to image widget to the container
wpos.x = 0;
wpos.y = 0;
wpos.bVisible = TRUE;

result = IXYCONTAINER_Insert(pMe->mainContainer, pMe->wImage, WIDGET_ZNORMAL, &wpos);

// set WID_FORM to the container
result = IXYCONTAINER_QueryInterface(pMe->mainContainer, AEEIID_WIDGET, (void**)&containerWidget);

if(result == 0)
{
IFORM_SetWidget(pMe->mapForm, WID_FORM, containerWidget);
IWIDGET_Release(containerWidget);

return result;

}

If all the above works the form is pushed onto the root form. I've put debug statements everywhere and found that the image is being loaded from file, it's loaded into the image widget and the widget is loaded onto the container etc.

i encountered the same problem while inserting list into the container, the list does not show.
maybe the way you mount the container on form is wrong?

i encountered the same problem while inserting list into the container, the list does not show.
maybe the way you mount the container on form is wrong?

Thanks for the reply bellyjuice, I've tried to change the way I mount onto the XY container but nothing seemed to work. Since I'm only using one widget I decided to get rid of the container and now the image shows :confused: If I'm going to add several widgets, then I'll probably have the same problem again. :mad:

Thanks for the reply bellyjuice, I've tried to change the way I mount onto the XY container but nothing seemed to work. Since I'm only using one widget I decided to get rid of the container and now the image shows :confused: If I'm going to add several widgets, then I'll probably have the same problem again. :mad:

not 100% sure..but could ull try setting the Extent
just give it a try (IWidget_SetExtent) to the image widget

not 100% sure..but could ull try setting the Extent
just give it a try (IWidget_SetExtent) to the image widget

thanks viral, I tried Set_Extent before and after inserting into the XY container, but nothing happened and I still see a blank screen where the image should be. I even checked via Get_Extent the values of the image widget, which returned valid numbers (128, 160)... but on another note, it solved the problem when I wrapped the image widget with the decorator :D
ETA: You're not going to believe this :confused: The reason why nothing was showing up was because I was loading a jpg on the simulator. I changed this to a bmp and now I can see it fine, no problem whatsoever! :confused:

thanks viral, I tried Set_Extent before and after inserting into the XY container, but nothing happened and I still see a blank screen where the image should be. I even checked via Get_Extent the values of the image widget, which returned valid numbers (128, 160)... but on another note, it solved the problem when I wrapped the image widget with the decorator :D
ETA: You're not going to believe this :confused: The reason why nothing was showing up was because I was loading a jpg on the simulator. I changed this to a bmp and now I can see it fine, no problem whatsoever! :confused:

thanks viral 2
i have tried the method, it works!

thanks viral 2
i have tried the method, it works!

Thanks to viral, I'm able to load the viewport and image into the XY container, but now the viewport doesn't seem to be handling the up, down, left, right events like before, it enters the handler but the image doesn't change... I've tried several approaches but still can't figure anything out... help :D
This is the approach I'm taking at the moment
1. Create the image widget and load a file into it
2. Decorate using viewport
3. Insert the viewport into the XY container
4. Load the XY container as WID_FORM into the form

Thanks to viral, I'm able to load the viewport and image into the XY container, but now the viewport doesn't seem to be handling the up, down, left, right events like before, it enters the handler but the image doesn't change... I've tried several approaches but still can't figure anything out... help :D
This is the approach I'm taking at the moment
1. Create the image widget and load a file into it
2. Decorate using viewport
3. Insert the viewport into the XY container
4. Load the XY container as WID_FORM into the form

post the handler...i think u can use iwidget_handleevent

post the handler...i think u can use iwidget_handleevent

hey Vallie, here's the code:
int FORM_PopulateMapContainer(inet2* pMe)
{
int result = 0;
WidgetPos wpos;
IWidget* containerWidget = NULL;
WExtent extent;
AEEImageInfo pi;
result = ISHELL_CreateInstance(pMe->pIShell, AEECLSID_XYCONTAINER, (void**)&pMe->mainContainer);
result += ISHELL_CreateInstance(pMe->pIShell, AEECLSID_IMAGEWIDGET, (void**)&pMe->wImage);
result += ISHELL_CreateInstance(pMe->pIShell, AEECLSID_VIEWPORTWIDGET, (void**)&pMe->viewPort);
if(result != 0)
return EFAILED;
// set the image widget through a callback
pMe->pImage = ISHELL_LoadImage(pMe->pIShell, "map.jpg");
//pMe->pImage = ISHELL_LoadImage(pMe->pIShell, "zaku.bmp");
IIMAGE_Notify(pMe->pImage, IMAGE_Finished, (void*)pMe);
IIMAGE_GetInfo(pMe->pImage, &pi);
extent.height = pi.cy;
extent.width = pi.cx;
IWIDGET_SetExtent(pMe->wImage, &extent);
// Set the viewport handler
HANDLERDESC_Init(&pMe->viewPortHandler, VIEWPORT_HandleEvent, pMe, 0);
IDECORATOR_SetHandler(pMe->viewPort, &pMe->viewPortHandler);
// Add a viewport decorator to the image widget
IDECORATOR_SetWidget(pMe->viewPort, pMe->wImage);
// Add to image widget to the container
wpos.x = 0;
wpos.y = 0;
wpos.bVisible = TRUE;
//result = IXYCONTAINER_Insert(pMe->mainContainer, pMe->wImage, WIDGET_ZNORMAL, &wpos);
IWIDGET_SetExtent(IDECORATOR_TO_IWIDGET(pMe->viewPort), &extent);
result = IXYCONTAINER_Insert(pMe->mainContainer, IDECORATOR_TO_IWIDGET(pMe->viewPort), WIDGET_ZNORMAL, &wpos);
// set WID_FORM to the container
result = IXYCONTAINER_QueryInterface(pMe->mainContainer, AEEIID_WIDGET, (void**)&containerWidget);
if(result == 0)
{
IFORM_SetWidget(pMe->mapForm, WID_FORM, containerWidget);
IWIDGET_Release(containerWidget);
}
return result;
Handler Code
static boolean VIEWPORT_HandleEvent(void* po, AEEEvent evt, uint16 wParam, uint32 dwParam)
{
inet2* pMe = (inet2*)po;
DBGPRINTF("----> In viewport handle event");
return HANDLERDESC_Call(&pMe->viewPortHandler, evt, wParam, dwParam);

I know the handler code is empty, but even though it was like this the viewport decorator worked when I didn't try to put it in the XY container.

hey Vallie, here's the code:
int FORM_PopulateMapContainer(inet2* pMe)
{
int result = 0;
WidgetPos wpos;
IWidget* containerWidget = NULL;
WExtent extent;
AEEImageInfo pi;
result = ISHELL_CreateInstance(pMe->pIShell, AEECLSID_XYCONTAINER, (void**)&pMe->mainContainer);
result += ISHELL_CreateInstance(pMe->pIShell, AEECLSID_IMAGEWIDGET, (void**)&pMe->wImage);
result += ISHELL_CreateInstance(pMe->pIShell, AEECLSID_VIEWPORTWIDGET, (void**)&pMe->viewPort);
if(result != 0)
return EFAILED;
// set the image widget through a callback
pMe->pImage = ISHELL_LoadImage(pMe->pIShell, "map.jpg");
//pMe->pImage = ISHELL_LoadImage(pMe->pIShell, "zaku.bmp");
IIMAGE_Notify(pMe->pImage, IMAGE_Finished, (void*)pMe);
IIMAGE_GetInfo(pMe->pImage, &pi);
extent.height = pi.cy;
extent.width = pi.cx;
IWIDGET_SetExtent(pMe->wImage, &extent);
// Set the viewport handler
HANDLERDESC_Init(&pMe->viewPortHandler, VIEWPORT_HandleEvent, pMe, 0);
IDECORATOR_SetHandler(pMe->viewPort, &pMe->viewPortHandler);
// Add a viewport decorator to the image widget
IDECORATOR_SetWidget(pMe->viewPort, pMe->wImage);
// Add to image widget to the container
wpos.x = 0;
wpos.y = 0;
wpos.bVisible = TRUE;
//result = IXYCONTAINER_Insert(pMe->mainContainer, pMe->wImage, WIDGET_ZNORMAL, &wpos);
IWIDGET_SetExtent(IDECORATOR_TO_IWIDGET(pMe->viewPort), &extent);
result = IXYCONTAINER_Insert(pMe->mainContainer, IDECORATOR_TO_IWIDGET(pMe->viewPort), WIDGET_ZNORMAL, &wpos);
// set WID_FORM to the container
result = IXYCONTAINER_QueryInterface(pMe->mainContainer, AEEIID_WIDGET, (void**)&containerWidget);
if(result == 0)
{
IFORM_SetWidget(pMe->mapForm, WID_FORM, containerWidget);
IWIDGET_Release(containerWidget);
}
return result;
Handler Code
static boolean VIEWPORT_HandleEvent(void* po, AEEEvent evt, uint16 wParam, uint32 dwParam)
{
inet2* pMe = (inet2*)po;
DBGPRINTF("----> In viewport handle event");
return HANDLERDESC_Call(&pMe->viewPortHandler, evt, wParam, dwParam);

I know the handler code is empty, but even though it was like this the viewport decorator worked when I didn't try to put it in the XY container.

extent.height = 50;
extent.width = 50;
IWIDGET_SetExtent(pMe->viewPort, &extent);
this is the code thats missing before u set the decorator
IDECORATOR_SetWidget(pMe->viewPort, pMe->wImage);

extent.height = 50;
extent.width = 50;
IWIDGET_SetExtent(pMe->viewPort, &extent);
this is the code thats missing before u set the decorator
IDECORATOR_SetWidget(pMe->viewPort, pMe->wImage);

Thanks again vallie worked like a treat! As a rule of thumb do we have to set the extent of each widget or container?

Thanks again vallie worked like a treat! As a rule of thumb do we have to set the extent of each widget or container?

ya u can say that

ya u can say that