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

Developer

Forums

I am creating a list having 3 items, with each list item having a checkbox and a static text. But the problems that i am facing are:
1) The last text is getting printed in all the 3 list items.
2) On clicking softkey, the selected checkbox is not getting marked.

Steps followed:

ListStructure structure contains:
IWidget *pListStaticWidget[3];
IPropContainer *pPropContainer;
IVectorModel *pVectorModel;
.......
.......

List structure contains:
boolean bChecked;
AECHAR pwText[15];

Applet structure contains:
ListStructure ListViewItem;
List *ListItem[3];

1) Created an array of check widgets and an array of static widgets.

pMe->ListItem[0] = (List*)malloc(sizeof(List));
WSTRCPY(pMe->ListItem[0]->pwText, L"List Item 1");
pMe->ListItem[1] = (List*)malloc(sizeof(List));
WSTRCPY(pMe->ListItem[0]->pwText, L"List Item 2");
pMe->ListItem[2] = (List*)malloc(sizeof(List));
WSTRCPY(pMe->ListItem[0]->pwText, L"List Item 3");

pMe->ListItem[0]->bChecked = 0;
pMe->ListItem[1]->bChecked = 0;
pMe->ListItem[2]->bChecked = 0;

2) List items Added to model and set to list widget

for(i = 0; i < 3 ; i++)
{
IVECTORMODEL_Add(pMe->ListViewItem.pVectorModel, (void *) (pMe->ListItem[i]));
}

IWIDGET_SetModel (pMe->pListWid, IVECTORMODEL_TO_IMODEL (pMe->ListViewItem.pVectorModel));

3) Inserting Check Widget and Static Widget into XY container. (Total we will have 3 XYcontainers). Also adding each XY container into the list widget.

for(i = 0; i < 3; i++)
{
// Static Widget
IWIDGET_SetText (pMe->ListViewItem.pListStaticWidget[i], pMe->ListItem[i]->pwText, TRUE);
SETWEXTENT(&extent,87,25);
IWIDGET_SetExtent(pMe->ListViewItem.pListStaticWidget[i], &extent);

// CheckBox Widget
SETWEXTENT(&extent,20,24);
IWIDGET_SetExtent(pMe->pChkWid[i],&extent);

IXYCONTAINER_Insert(pMe->pIcon[i],pMe->pChkWid[i], WIDGET_ZNORMAL,&pos1);
IXYCONTAINER_Insert(pMe->pIcon[i],pMe->ListViewItem.pListStaticWidget[i],WIDGET_ZNORMAL,&pos2);

IXYCONTAINER_QueryInterface(pMe->pIcon[i],AEEIID_WIDGET,&pMe->pIConWid[i]);

IDECORATOR_SetWidget ((IDecorator*)pMe->pListWid, pMe->pIConWid[i]);
}

4) Attaching Scrollbar To the List and inserting it into the Prop Container

IWIDGET_QueryInterface (pMe->pListScrollWid, AEEIID_DECORATOR, (void **) &pIDecorator);
IDECORATOR_SetWidget (pIDecorator, pMe->pListWid);

wProp.prop = 1;
wProp.bVisible = TRUE;
IPROPCONTAINER_Insert (pMe->ListViewItem.pPropContainer, pMe->pListScrollWid, WIDGET_ZNORMAL, &wProp);
IPROPCONTAINER_QueryInterface(pMe->ListViewItem.pPropContainer,AEEIID_WIDGET,(void **) &pIWidget);

IFORM_SetWidget(pMe->pIForm,WID_FORM ,pIWidget);
IROOTFORM_PushForm(pMe->App->pIRootForm, pMe->pIForm);

Instead of taking an array of containers [including array of static and check widgets] (for the list) what is the alternative?

Instead of taking an array of containers [including array of static and check widgets] (for the list) what is the alternative?

A list widget only uses one item widget, while you are trying to use 3.
Create one item widget (the XY container with the check widget and static widget), then create a value model and set it as the item widget's model. Then add a listener to this model. When the list widget draws, it will set the item widget's model three times, once with each piece of data in the list's vector model. The item widget's model will be notified each time, and your listener will be called. When the listener is called, get the list item from the model and set the check and static widgets appropriately.
-Erik

A list widget only uses one item widget, while you are trying to use 3.
Create one item widget (the XY container with the check widget and static widget), then create a value model and set it as the item widget's model. Then add a listener to this model. When the list widget draws, it will set the item widget's model three times, once with each piece of data in the list's vector model. The item widget's model will be notified each time, and your listener will be called. When the listener is called, get the list item from the model and set the check and static widgets appropriately.
-Erik

Thanks Erik. I made the changes but now the list cannot be seen. Please let me know my mistake.
for(i = 0; i < 3 ; i++)
{
IVALUEMODEL_SetValue(pMe->pIValueModel, (void *) (pMe->ListItem[i]), sizeof(pMe->ListItem[i]), NULL);

SETWEXTENT(&extent,87,25);
IWIDGET_SetExtent(pMe->ListViewItem.pListStaticWidget,&extent);
SETWEXTENT(&extent,20,24);
IWIDGET_SetExtent(pMe->pChkWid,&extent);
IXYCONTAINER_Insert(pMe->pIcon,pMe->pChkWid,WIDGET_ZNORMAL,&pos1);
IXYCONTAINER_Insert(pMe->pIcon,pMe->ListViewItem.pListStaticWidget, IWIDGET_ZNORMAL,&pos2);
IXYCONTAINER_QueryInterface(pMe->pIcon,AEEIID_WIDGET,&pMe->pIConWid);
IDECORATOR_SetWidget ((IDecorator*)pMe->pListWid, pMe->pIConWid);
IWIDGET_SetModel (pMe->pIConWid, IVALUEMODEL_TO_IMODEL (pMe->pIValueModel));

Thanks Erik. I made the changes but now the list cannot be seen. Please let me know my mistake.
for(i = 0; i < 3 ; i++)
{
IVALUEMODEL_SetValue(pMe->pIValueModel, (void *) (pMe->ListItem[i]), sizeof(pMe->ListItem[i]), NULL);

SETWEXTENT(&extent,87,25);
IWIDGET_SetExtent(pMe->ListViewItem.pListStaticWidget,&extent);
SETWEXTENT(&extent,20,24);
IWIDGET_SetExtent(pMe->pChkWid,&extent);
IXYCONTAINER_Insert(pMe->pIcon,pMe->pChkWid,WIDGET_ZNORMAL,&pos1);
IXYCONTAINER_Insert(pMe->pIcon,pMe->ListViewItem.pListStaticWidget, IWIDGET_ZNORMAL,&pos2);
IXYCONTAINER_QueryInterface(pMe->pIcon,AEEIID_WIDGET,&pMe->pIConWid);
IDECORATOR_SetWidget ((IDecorator*)pMe->pListWid, pMe->pIConWid);
IWIDGET_SetModel (pMe->pIConWid, IVALUEMODEL_TO_IMODEL (pMe->pIValueModel));

Thanks a lot Erik. I have got the list with check and static widgets!!
Thankyou so much.
I realised my mistakes in the code and rectified them.

Thanks a lot Erik. I have got the list with check and static widgets!!
Thankyou so much.
I realised my mistakes in the code and rectified them.

BREWdoubts wrote:Thanks a lot Erik. I have got the list with check and static widgets!!
Thankyou so much.
I realised my mistakes in the code and rectified them.
Hi,
I am facing the same problem. What was the solution. Moreover I don't find a scroll bar for it.

BREWdoubts wrote:Thanks a lot Erik. I have got the list with check and static widgets!!
Thankyou so much.
I realised my mistakes in the code and rectified them.
Hi,
I am facing the same problem. What was the solution. Moreover I don't find a scroll bar for it.

Please suggest as what should if the approach if not the following.
Code is as follows:
struct listItem{
boolean bChecked;
AECHAR* aeText;
;
ISHELL_CreateInstance(pMe->shell, AEECLSID_LISTWIDGET, (void**)&pMe->listWidget);
IDECORATOR_QueryInterface((IDecorator*)pMe->listWidget, AEEIID_WIDGET, (void**)&pMe->listContainerWidget);
IXYContainer* xycont;
ISHELL_CreateInstance(pMe->shell, AEECLSID_XYCONTAINER, (void**)&xycont);
IXYCONTAINER_QueryInterface(xycont, AEEIID_WIDGET, (void**)&pMe->listItemWidget);
IWidget* checkBoxWidget;
IWidget* staticWidget;
ISHELL_CreateInstance(pMe->shell, AEECLSID_CHECKWIDGET, (void**)&checkBoxWidget);
ISHELL_CreateInstance(pMe->shell, AEECLSID_STATICWIDGET, (void**)&staticWidget);
WidgetPos wPos;
wPos.bVisible = TRUE;
wPos.x = 0;
wPos.y = 0;
IXYCONTAINER_Insert(xycont, checkBoxWidget, WIDGET_ZNORMAL, &wPos);
wPos.x = 20;
wPos.y = 0;
IXYCONTAINER_Insert(xycont, staticWidget, WIDGET_ZNORMAL, &wPos);
WExtent listExtent;
listExtent.width = pMe->DeviceInfo.cxScreen - 4;
listExtent.height = 40;
IWIDGET_SetExtent(pMe->listContainerWidget, &listExtent);
ISHELL_CreateInstance(pMe->shell, AEECLSID_VALUEMODEL, (void**)&pMe->valueModel);
AECHAR* checkbox1 = (AECHAR*)MALLOC(20);
STRTOWSTR("CHECK BOX 1", checkbox1, 26);
AECHAR* checkbox2 = (AECHAR*)MALLOC(20);
STRTOWSTR("CHECK 2", checkbox2, 18);
AECHAR* checkbox3 = (AECHAR*)MALLOC(20);
STRTOWSTR("CHECK 3", checkbox3, 18);
boolean bCheck1 = TRUE;
boolean bCheck2 = FALSE;
boolean bCheck3 = FALSE;
listItem* item1 = (_listItem*)MALLOC(sizeof(_listItem));
item1->aeText = checkbox1;
item1->bChecked = bCheck1;
IVALUEMODEL_SetValue(pMe->valueModel, (void*)item1, sizeof(item1), NULL);
item1 = (_listItem*)MALLOC(sizeof(_listItem));
item1->aeText = checkbox2;
item1->bChecked = bCheck2;
IVALUEMODEL_SetValue(pMe->valueModel, (void*)item1, sizeof(item1), NULL);
item1 = (_listItem*)MALLOC(sizeof(_listItem));
item1->aeText = checkbox3;
item1->bChecked = bCheck3;
IVALUEMODEL_SetValue(pMe->valueModel, (void*)item1, sizeof(item1), NULL);
IWIDGET_SetModel(pMe->listContainerWidget, IVALUEMODEL_TO_IMODEL(pMe->valueModel));
IDECORATOR_SetWidget((IDecorator*)pMe->listWidget, pMe->listItemWidget);

Please suggest as what should if the approach if not the following.
Code is as follows:
struct listItem{
boolean bChecked;
AECHAR* aeText;
;
ISHELL_CreateInstance(pMe->shell, AEECLSID_LISTWIDGET, (void**)&pMe->listWidget);
IDECORATOR_QueryInterface((IDecorator*)pMe->listWidget, AEEIID_WIDGET, (void**)&pMe->listContainerWidget);
IXYContainer* xycont;
ISHELL_CreateInstance(pMe->shell, AEECLSID_XYCONTAINER, (void**)&xycont);
IXYCONTAINER_QueryInterface(xycont, AEEIID_WIDGET, (void**)&pMe->listItemWidget);
IWidget* checkBoxWidget;
IWidget* staticWidget;
ISHELL_CreateInstance(pMe->shell, AEECLSID_CHECKWIDGET, (void**)&checkBoxWidget);
ISHELL_CreateInstance(pMe->shell, AEECLSID_STATICWIDGET, (void**)&staticWidget);
WidgetPos wPos;
wPos.bVisible = TRUE;
wPos.x = 0;
wPos.y = 0;
IXYCONTAINER_Insert(xycont, checkBoxWidget, WIDGET_ZNORMAL, &wPos);
wPos.x = 20;
wPos.y = 0;
IXYCONTAINER_Insert(xycont, staticWidget, WIDGET_ZNORMAL, &wPos);
WExtent listExtent;
listExtent.width = pMe->DeviceInfo.cxScreen - 4;
listExtent.height = 40;
IWIDGET_SetExtent(pMe->listContainerWidget, &listExtent);
ISHELL_CreateInstance(pMe->shell, AEECLSID_VALUEMODEL, (void**)&pMe->valueModel);
AECHAR* checkbox1 = (AECHAR*)MALLOC(20);
STRTOWSTR("CHECK BOX 1", checkbox1, 26);
AECHAR* checkbox2 = (AECHAR*)MALLOC(20);
STRTOWSTR("CHECK 2", checkbox2, 18);
AECHAR* checkbox3 = (AECHAR*)MALLOC(20);
STRTOWSTR("CHECK 3", checkbox3, 18);
boolean bCheck1 = TRUE;
boolean bCheck2 = FALSE;
boolean bCheck3 = FALSE;
listItem* item1 = (_listItem*)MALLOC(sizeof(_listItem));
item1->aeText = checkbox1;
item1->bChecked = bCheck1;
IVALUEMODEL_SetValue(pMe->valueModel, (void*)item1, sizeof(item1), NULL);
item1 = (_listItem*)MALLOC(sizeof(_listItem));
item1->aeText = checkbox2;
item1->bChecked = bCheck2;
IVALUEMODEL_SetValue(pMe->valueModel, (void*)item1, sizeof(item1), NULL);
item1 = (_listItem*)MALLOC(sizeof(_listItem));
item1->aeText = checkbox3;
item1->bChecked = bCheck3;
IVALUEMODEL_SetValue(pMe->valueModel, (void*)item1, sizeof(item1), NULL);
IWIDGET_SetModel(pMe->listContainerWidget, IVALUEMODEL_TO_IMODEL(pMe->valueModel));
IDECORATOR_SetWidget((IDecorator*)pMe->listWidget, pMe->listItemWidget);

uvwx wrote:Please suggest as what should if the approach if not the following.
Let me explain the problem further:
Requirement is listItem in a listbox should be a checkbox with a static text.
The way I tried:
1.created a listWidget,
2. with listWidget as decorator queried for container widget.
IDECORATOR_QueryInterface(....);
3. Created a XYContainer and inserted checkWidget as well as staticWidget.
4. Created a structure:
Struct ListItem{
boolean bChecked;
AECHAR* text;
;
5. Created a ValueModel. Added elements into it :
IVALUEMODEL_SetValue(valModel, listItem1, sizeof(listItem1), NULL);
6. Set the model for the listWidget's container Widget.
IWIDGET_SetModel(listContainerWidget, IVALUEMODEL_TO_IMODEL(valModel));
6. Queried Interface for XYContainer and set the container widget as the listItemWidget for listWidget.
IDECORATOR_SetWidget(........);
The output I am getting is an empty listbox with width as set but height as default height of textbox.

uvwx wrote:Please suggest as what should if the approach if not the following.
Let me explain the problem further:
Requirement is listItem in a listbox should be a checkbox with a static text.
The way I tried:
1.created a listWidget,
2. with listWidget as decorator queried for container widget.
IDECORATOR_QueryInterface(....);
3. Created a XYContainer and inserted checkWidget as well as staticWidget.
4. Created a structure:
Struct ListItem{
boolean bChecked;
AECHAR* text;
;
5. Created a ValueModel. Added elements into it :
IVALUEMODEL_SetValue(valModel, listItem1, sizeof(listItem1), NULL);
6. Set the model for the listWidget's container Widget.
IWIDGET_SetModel(listContainerWidget, IVALUEMODEL_TO_IMODEL(valModel));
6. Queried Interface for XYContainer and set the container widget as the listItemWidget for listWidget.
IDECORATOR_SetWidget(........);
The output I am getting is an empty listbox with width as set but height as default height of textbox.

The list widget's model should be a menu model or vector model, not a value model. The XY container's model should be a value model.
-Erik

The list widget's model should be a menu model or vector model, not a value model. The XY container's model should be a value model.
-Erik

The checkbox and static text does not work for me. The static text widget seems to be overlapping the checkbox; and clicking on OK button on simulator does not show checkbox clicked. Is a listener required even to show the default/hardcoded values? How does one check/uncheck a checkbox widget? Can someone let me know what is going wrong here?
struct ListItem{ boolean bChecked; AECHAR* text; };
// create a list widget
IDecorator* listWidget;
int nErr;
IWidget* listContainerWidget;
nErr = ISHELL_CreateInstance(_shell, AEECLSID_LISTWIDGET, (void**)&listWidget);
IDECORATOR_QueryInterface((IDecorator*)listWidget, AEEIID_WIDGET, (void**)&listContainerWidget);
// create a check widget for the check box
IWidget* checkBoxWidget;
ISHELL_CreateInstance(_shell, AEECLSID_CHECKWIDGET, (void**)&checkBoxWidget);
// create a static text widget for the text in front of check box
IWidget* staticWidget;
ISHELL_CreateInstance(_shell, AEECLSID_STATICWIDGET, (void**)&staticWidget);
// create XYContainer
IXYContainer* xycont;
ISHELL_CreateInstance(_shell, AEECLSID_XYCONTAINER, (void**)&xycont);
IWidget* listItemWidget;
IXYCONTAINER_QueryInterface(xycont, AEEIID_WIDGET, (void**)&listItemWidget);
// insert static widgets into XY container
WidgetPos wPos;
wPos.bVisible = TRUE;
wPos.x = 0;
wPos.y = 0;
IXYCONTAINER_Insert(xycont, checkBoxWidget, WIDGET_ZNORMAL, &wPos);
wPos.x = 20;
wPos.y = 0;
IXYCONTAINER_Insert(xycont, staticWidget, WIDGET_ZNORMAL, &wPos);
IDECORATOR_SetWidget((IDecorator*)listWidget, listItemWidget);
// Create a value model and attach the model to the prop container widget
IValueModel* valueModel;
ISHELL_CreateInstance(_shell, AEECLSID_VALUEMODEL, (void**)&valueModel);
IWIDGET_SetModel(listItemWidget, IVALUEMODEL_TO_IMODEL(valueModel));
// Create a vector model and attach the model to the list widget
IVectorModel* vectorModel;
ISHELL_CreateInstance(_shell, AEECLSID_VECTORMODEL, (void**)&vectorModel);
IWIDGET_SetModel(listContainerWidget, IVECTORMODEL_TO_IMODEL(vectorModel));
// start populating data
ListItem* item1 = (ListItem*)MALLOC(sizeof(ListItem));
AECHAR* checkbox1 = (AECHAR*)MALLOC(20);
STRTOWSTR("CHECK BOX 1", checkbox1, 26);
boolean bCheck1 = TRUE;
item1->text = checkbox1;
item1->bChecked = bCheck1;
int rc = IVECTORMODEL_Add(vectorModel, item1);
/*
ListItem* item2 = (ListItem*)MALLOC(sizeof(ListItem));
AECHAR* checkbox2 = (AECHAR*)MALLOC(20);
STRTOWSTR("CHECK BOX 2", checkbox2, 26);
boolean bCheck2 = TRUE;
item2->text = checkbox2;
item2->bChecked = bCheck2;
rc = IVECTORMODEL_Add(vectorModel, item2);
*/
WidgetConstraint wcons;
wcons.constraint.top.type = CONSTRAINT_PREV_BOTTOM;
wcons.constraint.top.offset = 0;
wcons.constraint.left.type = CONSTRAINT_PARENT_LEFT;
wcons.constraint.left.offset = 2;
wcons.constraint.right.type = wcons.constraint.bottom.type = WIDGET_SIZE_TO_FIT;
wcons.constraint.right.offset = wcons.constraint.bottom.offset = 0;
wcons.bVisible = TRUE;
ICONSTRAINTCONTAINER_Insert(_mainContainer, listContainerWidget, WIDGET_ZNORMAL, &wcons);

The checkbox and static text does not work for me. The static text widget seems to be overlapping the checkbox; and clicking on OK button on simulator does not show checkbox clicked. Is a listener required even to show the default/hardcoded values? How does one check/uncheck a checkbox widget? Can someone let me know what is going wrong here?
struct ListItem{ boolean bChecked; AECHAR* text; };
// create a list widget
IDecorator* listWidget;
int nErr;
IWidget* listContainerWidget;
nErr = ISHELL_CreateInstance(_shell, AEECLSID_LISTWIDGET, (void**)&listWidget);
IDECORATOR_QueryInterface((IDecorator*)listWidget, AEEIID_WIDGET, (void**)&listContainerWidget);
// create a check widget for the check box
IWidget* checkBoxWidget;
ISHELL_CreateInstance(_shell, AEECLSID_CHECKWIDGET, (void**)&checkBoxWidget);
// create a static text widget for the text in front of check box
IWidget* staticWidget;
ISHELL_CreateInstance(_shell, AEECLSID_STATICWIDGET, (void**)&staticWidget);
// create XYContainer
IXYContainer* xycont;
ISHELL_CreateInstance(_shell, AEECLSID_XYCONTAINER, (void**)&xycont);
IWidget* listItemWidget;
IXYCONTAINER_QueryInterface(xycont, AEEIID_WIDGET, (void**)&listItemWidget);
// insert static widgets into XY container
WidgetPos wPos;
wPos.bVisible = TRUE;
wPos.x = 0;
wPos.y = 0;
IXYCONTAINER_Insert(xycont, checkBoxWidget, WIDGET_ZNORMAL, &wPos);
wPos.x = 20;
wPos.y = 0;
IXYCONTAINER_Insert(xycont, staticWidget, WIDGET_ZNORMAL, &wPos);
IDECORATOR_SetWidget((IDecorator*)listWidget, listItemWidget);
// Create a value model and attach the model to the prop container widget
IValueModel* valueModel;
ISHELL_CreateInstance(_shell, AEECLSID_VALUEMODEL, (void**)&valueModel);
IWIDGET_SetModel(listItemWidget, IVALUEMODEL_TO_IMODEL(valueModel));
// Create a vector model and attach the model to the list widget
IVectorModel* vectorModel;
ISHELL_CreateInstance(_shell, AEECLSID_VECTORMODEL, (void**)&vectorModel);
IWIDGET_SetModel(listContainerWidget, IVECTORMODEL_TO_IMODEL(vectorModel));
// start populating data
ListItem* item1 = (ListItem*)MALLOC(sizeof(ListItem));
AECHAR* checkbox1 = (AECHAR*)MALLOC(20);
STRTOWSTR("CHECK BOX 1", checkbox1, 26);
boolean bCheck1 = TRUE;
item1->text = checkbox1;
item1->bChecked = bCheck1;
int rc = IVECTORMODEL_Add(vectorModel, item1);
/*
ListItem* item2 = (ListItem*)MALLOC(sizeof(ListItem));
AECHAR* checkbox2 = (AECHAR*)MALLOC(20);
STRTOWSTR("CHECK BOX 2", checkbox2, 26);
boolean bCheck2 = TRUE;
item2->text = checkbox2;
item2->bChecked = bCheck2;
rc = IVECTORMODEL_Add(vectorModel, item2);
*/
WidgetConstraint wcons;
wcons.constraint.top.type = CONSTRAINT_PREV_BOTTOM;
wcons.constraint.top.offset = 0;
wcons.constraint.left.type = CONSTRAINT_PARENT_LEFT;
wcons.constraint.left.offset = 2;
wcons.constraint.right.type = wcons.constraint.bottom.type = WIDGET_SIZE_TO_FIT;
wcons.constraint.right.offset = wcons.constraint.bottom.offset = 0;
wcons.bVisible = TRUE;
ICONSTRAINTCONTAINER_Insert(_mainContainer, listContainerWidget, WIDGET_ZNORMAL, &wcons);

You need to add a listener to the value model which sets the state of the check widget and the static widget's text when the data in the value model changes (the listener gets the EVT_MDL_VALUE event).
-Erik

You need to add a listener to the value model which sets the state of the check widget and the static widget's text when the data in the value model changes (the listener gets the EVT_MDL_VALUE event).
-Erik

I added the listener to the value model, but I don't the EVT_MDL_VALUE event getting there when I step through the debugger. The only event that seems to be coming there is EVT_MDL_FOCUS_CHANGE; and even for that IValueModel_GetValue is returning NULL. I see just an 2 empty checkboxes (and maybe static text, which is invisible); but the data is not rendered. Is the initial data also supposed to be rendered in the listener to value model? Doesn't IVECTORMODEL_Add automatically render the data that is added? Thought listeners are needed just to monitor data changes; and not the initial upload of data. In any case, the listener also did not seem to do the job for me. Not sure where I am going wrong.
Here is the complete code (giving me sleepless nights; and lots of Brew curses):
struct ListItem{
boolean bChecked;
AECHAR* text;
;
int XContainer::addCheckBox() {
WExtent extent;
AEEDeviceInfo deviceInfo;
deviceInfo.wStructSize = sizeof(AEEDeviceInfo);
ISHELL_GetDeviceInfo(_shell, &deviceInfo);
extent.height = deviceInfo.cyScreen;
extent.width = deviceInfo.cxScreen;
// 1. create a list widget
// IDecorator* listWidget;
// IWidget* listw;
int nErr;
nErr = TTUtility::createObject(_shell, AEECLSID_LISTWIDGET, (void**)&listw);
// 2. checkbox and static text now
IWidget* checkBoxWidget;
nErr = TTUtility::createObject(_shell, AEECLSID_CHECKWIDGET, (void**)&checkBoxWidget);
// create a static text widget for the text in front of check box
IWidget* staticWidget;
nErr += TTUtility::createObject(_shell, AEECLSID_STATICWIDGET, (void**)&staticWidget);
// create a constraint container
IConstraintContainer* constCont = NULL;
int rc;
if ( (rc = TTUtility::createObject(_shell, AEECLSID_CONSTRAINTCONTAINER, (void**)&constCont)) != SUCCESS){
DBGPRINTF("XContainer- cannot create constraint container rc = %d", rc);
}
// insert the checkbox and static widgets in the container
int topOffset = 5;
WidgetConstraint wcons;
wcons.constraint.top.type = CONSTRAINT_PREV_BOTTOM;
wcons.constraint.top.offset = topOffset;
wcons.constraint.left.type = CONSTRAINT_PARENT_LEFT;
wcons.constraint.left.offset = 2;
wcons.constraint.right.type = wcons.constraint.bottom.type = WIDGET_SIZE_TO_FIT;
wcons.constraint.right.offset = wcons.constraint.bottom.offset = 0;
wcons.bVisible = TRUE;
// insert checkbox into the container
nErr = ICONSTRAINTCONTAINER_Insert( constCont, checkBoxWidget, WIDGET_ZNORMAL, &wcons);
if(nErr != SUCCESS) return nErr;
wcons.constraint.top.type = CONSTRAINT_PREV_TOP;
wcons.constraint.left.type = CONSTRAINT_PREV_RIGHT;
wcons.constraint.right.type = CONSTRAINT_PARENT_RIGHT;
wcons.constraint.right.offset = -1;
wcons.constraint.bottom.type = WIDGET_SIZE_TO_FIT;
wcons.constraint.top.offset = 0;
// insert static text into the container
nErr = ICONSTRAINTCONTAINER_Insert( constCont, staticWidget, WIDGET_ZNORMAL, &wcons);
// 4. get the widget of the constraint container
if (rc == SUCCESS && (rc = ICONSTRAINTCONTAINER_QueryInterface(constCont, AEEIID_WIDGET, (void**)&listItemWidget)) != SUCCESS){
DBGPRINTF("XContainer- cannot create constraint containter widget rc = %d", rc);
}
// 5. set the listItemWidget as the item for listWidget
WExtent we;
IWIDGET_GetPreferredExtent(listItemWidget, &we);
IWIDGET_SetItemHeight(listw, we.height);
IDECORATOR_SetWidget((IDecorator*)listw, listItemWidget);
// 6. create a value model and attach it to the list item widget
nErr += TTUtility::createObject(_shell, AEECLSID_VALUEMODEL, (void**)&pCheckBoxValueModel);
IWIDGET_SetModel(listItemWidget, IVALUEMODEL_TO_IMODEL(pCheckBoxValueModel));
// 7. add a listener to the value model
IModel* tempModel;
IWIDGET_GetViewModel(listItemWidget, &tempModel);
_checkBoxListener = (ModelListener*)MALLOC(sizeof(ModelListener));
LISTENER_Init(_checkBoxListener, (PFNLISTENER)checkBoxHandler, this);
IMODEL_AddListener(tempModel, _checkBoxListener);
// 8. Create a vector model and attach the model to the list widget
nErr += TTUtility::createObject(_shell, AEECLSID_VECTORMODEL, (void**)&pCheckBoxListVectorModel);
// IWIDGET_SetModel(listContainerWidget, IVECTORMODEL_TO_IMODEL(pCheckBoxListVectorModel));
IWIDGET_SetModel(listw, IVECTORMODEL_TO_IMODEL(pCheckBoxListVectorModel));
IWIDGET_GetPreferredExtent(listw, &we);
IWIDGET_SetExtent(listw, &we);
// 9. add data to the vector model
ListItem* item1 = (ListItem*)MALLOC(sizeof(ListItem));
AECHAR* checkbox1 = (AECHAR*)MALLOC(20);
STRTOWSTR("CHECK BOX 1", checkbox1, 26);
boolean bCheck1 = TRUE;
item1->text = checkbox1;
item1->bChecked = TRUE;
rc = IVECTORMODEL_Add(pCheckBoxListVectorModel, item1);
ListItem* item2 = (ListItem*)MALLOC(sizeof(ListItem));
AECHAR* checkbox2 = (AECHAR*)MALLOC(20);
STRTOWSTR("CHECK BOX 2", checkbox2, 26);
boolean bCheck2 = TRUE;
item2->text = checkbox2;
item2->bChecked = TRUE;
rc = IVECTORMODEL_Add(pCheckBoxListVectorModel, item2);
// insert into our main container
wcons.constraint.top.type = CONSTRAINT_PARENT_TOP;
wcons.constraint.top.offset = 2;
wcons.constraint.left.type = CONSTRAINT_PARENT_LEFT;
wcons.constraint.left.offset = 2;
wcons.constraint.right.type = CONSTRAINT_PARENT_RIGHT;
wcons.constraint.right.offset = -8;
wcons.constraint.bottom.type = CONSTRAINT_PARENT_BOTTOM;
wcons.constraint.bottom.offset = -4;
wcons.bVisible = TRUE;
// insert into our main container
nErr = ICONSTRAINTCONTAINER_Insert( _container, listw, WIDGET_ZNORMAL, &wcons);
return nErr;
}
void XContainer::checkBoxHandler(void *pMe, ModelEvent *pev)
{
DBGPRINTF("Entered XContainer::checkBoxHandler");
XContainer* thisform = (XContainer*)pMe;
if(pev->evCode == EVT_MDL_VALUE)
{
uint16 cmdId;
uint16 flags;
int nLen = 0;
ListItem* listItem = (ListItem*)IVALUEMODEL_GetValue(thisform->pCheckBoxValueModel, &nLen);
// how do I get hold of the checkbox and static widget if at all I get here
}
return;

I added the listener to the value model, but I don't the EVT_MDL_VALUE event getting there when I step through the debugger. The only event that seems to be coming there is EVT_MDL_FOCUS_CHANGE; and even for that IValueModel_GetValue is returning NULL. I see just an 2 empty checkboxes (and maybe static text, which is invisible); but the data is not rendered. Is the initial data also supposed to be rendered in the listener to value model? Doesn't IVECTORMODEL_Add automatically render the data that is added? Thought listeners are needed just to monitor data changes; and not the initial upload of data. In any case, the listener also did not seem to do the job for me. Not sure where I am going wrong.
Here is the complete code (giving me sleepless nights; and lots of Brew curses):
struct ListItem{
boolean bChecked;
AECHAR* text;
;
int XContainer::addCheckBox() {
WExtent extent;
AEEDeviceInfo deviceInfo;
deviceInfo.wStructSize = sizeof(AEEDeviceInfo);
ISHELL_GetDeviceInfo(_shell, &deviceInfo);
extent.height = deviceInfo.cyScreen;
extent.width = deviceInfo.cxScreen;
// 1. create a list widget
// IDecorator* listWidget;
// IWidget* listw;
int nErr;
nErr = TTUtility::createObject(_shell, AEECLSID_LISTWIDGET, (void**)&listw);
// 2. checkbox and static text now
IWidget* checkBoxWidget;
nErr = TTUtility::createObject(_shell, AEECLSID_CHECKWIDGET, (void**)&checkBoxWidget);
// create a static text widget for the text in front of check box
IWidget* staticWidget;
nErr += TTUtility::createObject(_shell, AEECLSID_STATICWIDGET, (void**)&staticWidget);
// create a constraint container
IConstraintContainer* constCont = NULL;
int rc;
if ( (rc = TTUtility::createObject(_shell, AEECLSID_CONSTRAINTCONTAINER, (void**)&constCont)) != SUCCESS){
DBGPRINTF("XContainer- cannot create constraint container rc = %d", rc);
}
// insert the checkbox and static widgets in the container
int topOffset = 5;
WidgetConstraint wcons;
wcons.constraint.top.type = CONSTRAINT_PREV_BOTTOM;
wcons.constraint.top.offset = topOffset;
wcons.constraint.left.type = CONSTRAINT_PARENT_LEFT;
wcons.constraint.left.offset = 2;
wcons.constraint.right.type = wcons.constraint.bottom.type = WIDGET_SIZE_TO_FIT;
wcons.constraint.right.offset = wcons.constraint.bottom.offset = 0;
wcons.bVisible = TRUE;
// insert checkbox into the container
nErr = ICONSTRAINTCONTAINER_Insert( constCont, checkBoxWidget, WIDGET_ZNORMAL, &wcons);
if(nErr != SUCCESS) return nErr;
wcons.constraint.top.type = CONSTRAINT_PREV_TOP;
wcons.constraint.left.type = CONSTRAINT_PREV_RIGHT;
wcons.constraint.right.type = CONSTRAINT_PARENT_RIGHT;
wcons.constraint.right.offset = -1;
wcons.constraint.bottom.type = WIDGET_SIZE_TO_FIT;
wcons.constraint.top.offset = 0;
// insert static text into the container
nErr = ICONSTRAINTCONTAINER_Insert( constCont, staticWidget, WIDGET_ZNORMAL, &wcons);
// 4. get the widget of the constraint container
if (rc == SUCCESS && (rc = ICONSTRAINTCONTAINER_QueryInterface(constCont, AEEIID_WIDGET, (void**)&listItemWidget)) != SUCCESS){
DBGPRINTF("XContainer- cannot create constraint containter widget rc = %d", rc);
}
// 5. set the listItemWidget as the item for listWidget
WExtent we;
IWIDGET_GetPreferredExtent(listItemWidget, &we);
IWIDGET_SetItemHeight(listw, we.height);
IDECORATOR_SetWidget((IDecorator*)listw, listItemWidget);
// 6. create a value model and attach it to the list item widget
nErr += TTUtility::createObject(_shell, AEECLSID_VALUEMODEL, (void**)&pCheckBoxValueModel);
IWIDGET_SetModel(listItemWidget, IVALUEMODEL_TO_IMODEL(pCheckBoxValueModel));
// 7. add a listener to the value model
IModel* tempModel;
IWIDGET_GetViewModel(listItemWidget, &tempModel);
_checkBoxListener = (ModelListener*)MALLOC(sizeof(ModelListener));
LISTENER_Init(_checkBoxListener, (PFNLISTENER)checkBoxHandler, this);
IMODEL_AddListener(tempModel, _checkBoxListener);
// 8. Create a vector model and attach the model to the list widget
nErr += TTUtility::createObject(_shell, AEECLSID_VECTORMODEL, (void**)&pCheckBoxListVectorModel);
// IWIDGET_SetModel(listContainerWidget, IVECTORMODEL_TO_IMODEL(pCheckBoxListVectorModel));
IWIDGET_SetModel(listw, IVECTORMODEL_TO_IMODEL(pCheckBoxListVectorModel));
IWIDGET_GetPreferredExtent(listw, &we);
IWIDGET_SetExtent(listw, &we);
// 9. add data to the vector model
ListItem* item1 = (ListItem*)MALLOC(sizeof(ListItem));
AECHAR* checkbox1 = (AECHAR*)MALLOC(20);
STRTOWSTR("CHECK BOX 1", checkbox1, 26);
boolean bCheck1 = TRUE;
item1->text = checkbox1;
item1->bChecked = TRUE;
rc = IVECTORMODEL_Add(pCheckBoxListVectorModel, item1);
ListItem* item2 = (ListItem*)MALLOC(sizeof(ListItem));
AECHAR* checkbox2 = (AECHAR*)MALLOC(20);
STRTOWSTR("CHECK BOX 2", checkbox2, 26);
boolean bCheck2 = TRUE;
item2->text = checkbox2;
item2->bChecked = TRUE;
rc = IVECTORMODEL_Add(pCheckBoxListVectorModel, item2);
// insert into our main container
wcons.constraint.top.type = CONSTRAINT_PARENT_TOP;
wcons.constraint.top.offset = 2;
wcons.constraint.left.type = CONSTRAINT_PARENT_LEFT;
wcons.constraint.left.offset = 2;
wcons.constraint.right.type = CONSTRAINT_PARENT_RIGHT;
wcons.constraint.right.offset = -8;
wcons.constraint.bottom.type = CONSTRAINT_PARENT_BOTTOM;
wcons.constraint.bottom.offset = -4;
wcons.bVisible = TRUE;
// insert into our main container
nErr = ICONSTRAINTCONTAINER_Insert( _container, listw, WIDGET_ZNORMAL, &wcons);
return nErr;
}
void XContainer::checkBoxHandler(void *pMe, ModelEvent *pev)
{
DBGPRINTF("Entered XContainer::checkBoxHandler");
XContainer* thisform = (XContainer*)pMe;
if(pev->evCode == EVT_MDL_VALUE)
{
uint16 cmdId;
uint16 flags;
int nLen = 0;
ListItem* listItem = (ListItem*)IVALUEMODEL_GetValue(thisform->pCheckBoxValueModel, &nLen);
// how do I get hold of the checkbox and static widget if at all I get here
}
return;

I further fixed the code by attaching the listener to the value model instead of the view model; now the listener is not getting called at all. Can someone please help?
// 6. create a value model and attach it to the list item widget
nErr += TTUtility::createObject(_shell, AEECLSID_VALUEMODEL, (void**)&pCheckBoxValueModel);
IWIDGET_SetModel(listItemWidget, IVALUEMODEL_TO_IMODEL(pCheckBoxValueModel));
// 7. add a listener to the value model
_checkBoxListener = (ModelListener*)MALLOC(sizeof(ModelListener));
LISTENER_Init(_checkBoxListener, (PFNLISTENER)checkBoxHandler, this);
IMODEL_AddListener(pCheckBoxValueModel, _checkBoxListener);

I further fixed the code by attaching the listener to the value model instead of the view model; now the listener is not getting called at all. Can someone please help?
// 6. create a value model and attach it to the list item widget
nErr += TTUtility::createObject(_shell, AEECLSID_VALUEMODEL, (void**)&pCheckBoxValueModel);
IWIDGET_SetModel(listItemWidget, IVALUEMODEL_TO_IMODEL(pCheckBoxValueModel));
// 7. add a listener to the value model
_checkBoxListener = (ModelListener*)MALLOC(sizeof(ModelListener));
LISTENER_Init(_checkBoxListener, (PFNLISTENER)checkBoxHandler, this);
IMODEL_AddListener(pCheckBoxValueModel, _checkBoxListener);

Hi,
I am facing the same problem.I Follow all the steps as suggested in the forums.Still i am not able to show the list with different staic informaton.My listener function associated with value model is not called .
Please help...
here is my code..
typedef struct _custWdgData
{
boolean bChecked;
AECHAR *pText;
custWdgData;
typedef struct __ListItem
{
IWidget* pCheckboxWidget;
IWidget* pStaticWidget ;
IWidget* pValueModel;
ListItem;
void ValueModelLisner(void *pUserData, ModelEvent *pEvent)
{
void* pStaticWidget = NULL;
int Len = 0;
ListItem* pData = (ListItem*)pUserData;
pStaticWidget = IValueModel_GetValue(pData->pValueModel,NULL);

IWidget* CreateCustomList()
{
ListItem Item;
custWdgData Data;
ModelListener LisModel;
WidgetPos PostionStatic;
IWidget* pListWidget = NULL;
IWidget* pContainerWidget = NULL;
IWidget* pVectorModel =NULL;
AEEApplet* pMe = (AEEApplet*) GETAPPINSTANCE();
IPropContainer* pLocalPropContainer = NULL;
if(ISHELL_CreateInstance(pMe->m_pIShell,AEECLSID_ListWidget,&pListWidget) != AEE_SUCCESS)
{
goto Release;
}
if(ISHELL_CreateInstance(pMe->m_pIShell,AEECLSID_PropContainer,&pLocalPropContainer) != AEE_SUCCESS)
{
goto Release;
}
if(ISHELL_CreateInstance(pMe->m_pIShell,AEECLSID_StaticWidget,&Item.pStaticWidget) != AEE_SUCCESS)
{
goto Release;
}
if(ISHELL_CreateInstance(pMe->m_pIShell,AEECLSID_ValueModel,&Item.pValueModel) != AEE_SUCCESS)
{
goto Release;
}
if(ISHELL_CreateInstance(pMe->m_pIShell,AEECLSID_VectorModel,&pVectorModel) != AEE_SUCCESS)
{
goto Release;
}
if(ISHELL_CreateInstance(pMe->m_pIShell,AEECLSID_CheckWidget,&Item.pCheckboxWidget) != AEE_SUCCESS)
{
goto Release;
}
// Set the listener
LisModel.pListenerData = &Item;
LisModel.pfnCancel = NULL;
LisModel.pfnListener = ValueModelLisner;
PostionStatic.bVisible = TRUE;
PostionStatic.x = 5;
PostionStatic.y = 5;
IWidget_SetBGColor(Item.pStaticWidget,MAKE_RGBA(255,255,0,255));
IPROPCONTAINER_Insert(pLocalPropContainer,Item.pStaticWidget,WIDGET_ZNORMAL,&PostionStatic);
IPROPCONTAINER_Insert(pLocalPropContainer,Item.pCheckboxWidget,WIDGET_ZNORMAL,&PostionStatic);
if(IPropContainer_QueryInterface(pLocalPropContainer,AEEIID_WIDGET,&pContainerWidget)!= AEE_SUCCESS)
{
goto Release;
}
IDecorator_SetWidget((IDecorator*)pListWidget,pContainerWidget);
IWidget_SetModel(pContainerWidget,IValueModel_to_IModel(Item.pValueModel));
IValueModel_AddListener(Item.pValueModel,&LisModel);
IWidget_SetModel(pListWidget,IVectorModel_to_IModel(pVectorModel));
Data.bChecked = TRUE;
Data.pText = L"Hello world";
IVectorModel_Add(pVectorModel,&Data);
return pListWidget;
Release:
return NULL;

Hi,
I am facing the same problem.I Follow all the steps as suggested in the forums.Still i am not able to show the list with different staic informaton.My listener function associated with value model is not called .
Please help...
here is my code..
typedef struct _custWdgData
{
boolean bChecked;
AECHAR *pText;
custWdgData;
typedef struct __ListItem
{
IWidget* pCheckboxWidget;
IWidget* pStaticWidget ;
IWidget* pValueModel;
ListItem;
void ValueModelLisner(void *pUserData, ModelEvent *pEvent)
{
void* pStaticWidget = NULL;
int Len = 0;
ListItem* pData = (ListItem*)pUserData;
pStaticWidget = IValueModel_GetValue(pData->pValueModel,NULL);

IWidget* CreateCustomList()
{
ListItem Item;
custWdgData Data;
ModelListener LisModel;
WidgetPos PostionStatic;
IWidget* pListWidget = NULL;
IWidget* pContainerWidget = NULL;
IWidget* pVectorModel =NULL;
AEEApplet* pMe = (AEEApplet*) GETAPPINSTANCE();
IPropContainer* pLocalPropContainer = NULL;
if(ISHELL_CreateInstance(pMe->m_pIShell,AEECLSID_ListWidget,&pListWidget) != AEE_SUCCESS)
{
goto Release;
}
if(ISHELL_CreateInstance(pMe->m_pIShell,AEECLSID_PropContainer,&pLocalPropContainer) != AEE_SUCCESS)
{
goto Release;
}
if(ISHELL_CreateInstance(pMe->m_pIShell,AEECLSID_StaticWidget,&Item.pStaticWidget) != AEE_SUCCESS)
{
goto Release;
}
if(ISHELL_CreateInstance(pMe->m_pIShell,AEECLSID_ValueModel,&Item.pValueModel) != AEE_SUCCESS)
{
goto Release;
}
if(ISHELL_CreateInstance(pMe->m_pIShell,AEECLSID_VectorModel,&pVectorModel) != AEE_SUCCESS)
{
goto Release;
}
if(ISHELL_CreateInstance(pMe->m_pIShell,AEECLSID_CheckWidget,&Item.pCheckboxWidget) != AEE_SUCCESS)
{
goto Release;
}
// Set the listener
LisModel.pListenerData = &Item;
LisModel.pfnCancel = NULL;
LisModel.pfnListener = ValueModelLisner;
PostionStatic.bVisible = TRUE;
PostionStatic.x = 5;
PostionStatic.y = 5;
IWidget_SetBGColor(Item.pStaticWidget,MAKE_RGBA(255,255,0,255));
IPROPCONTAINER_Insert(pLocalPropContainer,Item.pStaticWidget,WIDGET_ZNORMAL,&PostionStatic);
IPROPCONTAINER_Insert(pLocalPropContainer,Item.pCheckboxWidget,WIDGET_ZNORMAL,&PostionStatic);
if(IPropContainer_QueryInterface(pLocalPropContainer,AEEIID_WIDGET,&pContainerWidget)!= AEE_SUCCESS)
{
goto Release;
}
IDecorator_SetWidget((IDecorator*)pListWidget,pContainerWidget);
IWidget_SetModel(pContainerWidget,IValueModel_to_IModel(Item.pValueModel));
IValueModel_AddListener(Item.pValueModel,&LisModel);
IWidget_SetModel(pListWidget,IVectorModel_to_IModel(pVectorModel));
Data.bChecked = TRUE;
Data.pText = L"Hello world";
IVectorModel_Add(pVectorModel,&Data);
return pListWidget;
Release:
return NULL;

You can't add local variables (like Data) to the vector model, since the variable will go away when the function returns. You must MALLOC memory for the items you insert in your vector model.
-Erik

You can't add local variables (like Data) to the vector model, since the variable will go away when the function returns. You must MALLOC memory for the items you insert in your vector model.
-Erik

Hi erik,
Thanks for your reply. I made what u suggested. My value model listner is called but when i want to get the data using IValueModel_GetValue(pData->pValueModel,NULL); it returns me NULL.Can u please suggest me, what wrong i am doing?

Hi erik,
Thanks for your reply. I made what u suggested. My value model listner is called but when i want to get the data using IValueModel_GetValue(pData->pValueModel,NULL); it returns me NULL.Can u please suggest me, what wrong i am doing?

Hi All
I am very new to Brew and I am facing problems to display a list with 'n' number of Items with each Item having an Image and two Static Widgets.
Following is the procedure which I followed
1. Created a Menu Model
nErr = ISHELL_CreateInstance(pMe->pIShell, AEECLSID_MenuModel, (void**)&pMe->piListModel);
if(SUCCESS != nErr){
return nErr;
}
IMenuModel_SetPfnFree(pMe->piListModel, (PFNNOTIFY) VF_FREE);//Free_ListData);
for(I=0;IListItem->piwListItem_Container[I]);
//Adding the menu model with the constraint container widgets
nErr = IMenuModel_Add(pMe->piListModel, (void*)pMe->ListItem->piwListItem_Container[I], I, MMF_SEPARATOR);
if(SUCCESS != nErr){
return nErr;
}
}
2. Created List Item which contains creating a Image Widget and two Static Widgets and inserting them in a Constraint Container.
3. Created List Item Model i.e. Created a value Model (= to the number of items in the list) and set the structure which has the following data to the value model
typedef struct _list_item_data{
IImage* piImage;
AECHAR* piImageText;
AECHAR* AddrEdit;
ListItemData;
using IValueModel_SetValue(pMe->ListItem->pListItemModel[I], (void*)pMe->ItemData[I],sizeof(pMe->ItemData[I]), NULL);
4. Set the constraint container widget with the value model IWidget_SetModel(piwContainer, IValueModel_to_IModel(pMe->ListItem->pListItemModel[I]));
5. Created the List Widget and the set the Menu Model to it
nErr = ISHELL_CreateInstance(pMe->pIShell, AEECLSID_ListWidget, &pMe->piwListWidget);
if(SUCCESS != nErr){
return nErr;
}
IWidget_SetModel(pMe->piwListWidget, IMenuModel_to_IModel(pMe->piListModel));
IWidget_SetPreferredExtent(pMe->piwListWidget, NULL);
IDecorator_SetWidget((IDecorator*)(void*)pMe->piwListWidget, piwContainer);
6. Finally configured the properties of the List Widget and added it to the root container
With the above procedure I am not able to see any of the widgets I have added.
Please correct me with the procedure, kindly let me know if I am not clear in explaining the problem
Please reply to this or do reach me @ eval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6e%61%76%65%65%6e%32%36%31%32%38%40%67%6d%61%69%6c%2e%63%6f%6d%22%20%63%6c%61%73%73%3d%22%62%62%2d%65%6d%61%69%6c%22%3e%6e%61%76%65%65%6e%32%36%31%32%38%40%67%6d%61%69%6c%2e%63%6f%6d%3c%2f%61%3e%27%29%3b'))
Thanks in Advance

Hi All
I am very new to Brew and I am facing problems to display a list with 'n' number of Items with each Item having an Image and two Static Widgets.
Following is the procedure which I followed
1. Created a Menu Model
nErr = ISHELL_CreateInstance(pMe->pIShell, AEECLSID_MenuModel, (void**)&pMe->piListModel);
if(SUCCESS != nErr){
return nErr;
}
IMenuModel_SetPfnFree(pMe->piListModel, (PFNNOTIFY) VF_FREE);//Free_ListData);
for(I=0;IListItem->piwListItem_Container[I]);
//Adding the menu model with the constraint container widgets
nErr = IMenuModel_Add(pMe->piListModel, (void*)pMe->ListItem->piwListItem_Container[I], I, MMF_SEPARATOR);
if(SUCCESS != nErr){
return nErr;
}
}
2. Created List Item which contains creating a Image Widget and two Static Widgets and inserting them in a Constraint Container.
3. Created List Item Model i.e. Created a value Model (= to the number of items in the list) and set the structure which has the following data to the value model
typedef struct _list_item_data{
IImage* piImage;
AECHAR* piImageText;
AECHAR* AddrEdit;
ListItemData;
using IValueModel_SetValue(pMe->ListItem->pListItemModel[I], (void*)pMe->ItemData[I],sizeof(pMe->ItemData[I]), NULL);
4. Set the constraint container widget with the value model IWidget_SetModel(piwContainer, IValueModel_to_IModel(pMe->ListItem->pListItemModel[I]));
5. Created the List Widget and the set the Menu Model to it
nErr = ISHELL_CreateInstance(pMe->pIShell, AEECLSID_ListWidget, &pMe->piwListWidget);
if(SUCCESS != nErr){
return nErr;
}
IWidget_SetModel(pMe->piwListWidget, IMenuModel_to_IModel(pMe->piListModel));
IWidget_SetPreferredExtent(pMe->piwListWidget, NULL);
IDecorator_SetWidget((IDecorator*)(void*)pMe->piwListWidget, piwContainer);
6. Finally configured the properties of the List Widget and added it to the root container
With the above procedure I am not able to see any of the widgets I have added.
Please correct me with the procedure, kindly let me know if I am not clear in explaining the problem
Please reply to this or do reach me @ eval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6e%61%76%65%65%6e%32%36%31%32%38%40%67%6d%61%69%6c%2e%63%6f%6d%22%20%63%6c%61%73%73%3d%22%62%62%2d%65%6d%61%69%6c%22%3e%6e%61%76%65%65%6e%32%36%31%32%38%40%67%6d%61%69%6c%2e%63%6f%6d%3c%2f%61%3e%27%29%3b'))
Thanks in Advance

A list widget uses one list item widget (which you set with IDECORATOR_SetWidget()) to draw all the items. The menu model doesn't contain a list of widgets, it contains the data to be displayed (in your case, you would be adding ListItemData structures to the menu model).
Please reread the list widget documentation.
-Erik

A list widget uses one list item widget (which you set with IDECORATOR_SetWidget()) to draw all the items. The menu model doesn't contain a list of widgets, it contains the data to be displayed (in your case, you would be adding ListItemData structures to the menu model).
Please reread the list widget documentation.
-Erik

Hi,
I want to cretae a list widget in which each row will contain a container consisting of 3 static widgets.
The steps i have done are:
1. Create a prop container and add 3 static widgets into it.
2. Create a list box and add vector model to it
3. Set value model to the container
4. Insert data into listbox using IVectorModel_Add
4. Add a callback ValueModelListener function
5. Set the data of static widgets in this listener function.
Part of the code is as follows:
typedef struct {
AECHAR pwData1[700]; // widget text for
AECHAR pwData2[700]; // widget text
AECHAR pwData3[700]; // widget text
List_Data;
typedef struct
{
IWidget *pwStatic_Widget1;
IWidget *pwStatic_Widget2;
IWidget *pwStatic_Widget3;
IValueModel * pValueModel;
List_Widgets;
In the structure I have given following declarations:
typedef struct _Box
{
. . .
List_Data *List_Item[8];
List_Widgets Item;
. . .

IWidget_SetModel( pMe->pWPropContainer , IVALUEMODEL_TO_IMODEL(pMe->Item.pValueModel));
//Add data to listbox
place_index = 0;
for (loop=0; loop<8; loop++)
{
pMe->List_Item[loop] = (List_Data*)malloc(sizeof(List_Data));
WSTRCPY(pMe->List_Item[loop]->pwData1, pMe->data[place_index++]);
WSTRCPY(pMe->List_Item[loop]->pwData2, pMe->data[place_index++]);
WSTRCPY(pMe->List_Item[loop]->pwData3, pMe->data[place_index++]);
IVectorModel_Add(pMe->pMenuModel , pMe->List_Item[loop]);
IValueModel_AddListener(pMe->Item.pValueModel,&pMe->LisValueModel);

//The Value Model Listener to add data to widgets of each container
void ValueModelLisner(void *pUserData, ModelEvent *pEvent)
{
static int loop=0;
List_Widgets* pData = (List_Widgets*)pUserData;
List_Data *pFinal= NULL;
if(pEvent->evCode == EVT_MDL_VALUE)
{
if(loop < 8)
{
IVECTORMODEL_GetAt(pMe->pMenuModel, loop,&pFinal) ;
IWIDGET_SetText(pData->pwStatic_Widget1,pFinal->pwData1, FALSE);
IWIDGET_SetText(pData->pwStatic_Widget2,pFinal->pwData2, FALSE);
IWIDGET_SetText(pData->pwStatic_Widget3,pFinal->pwData3, FALSE);
loop ++;
}

}
But for each row, the data from the last container is replicated.
Please help me in solving this problem.
Thanks.

Hi,
I want to cretae a list widget in which each row will contain a container consisting of 3 static widgets.
The steps i have done are:
1. Create a prop container and add 3 static widgets into it.
2. Create a list box and add vector model to it
3. Set value model to the container
4. Insert data into listbox using IVectorModel_Add
4. Add a callback ValueModelListener function
5. Set the data of static widgets in this listener function.
Part of the code is as follows:
typedef struct {
AECHAR pwData1[700]; // widget text for
AECHAR pwData2[700]; // widget text
AECHAR pwData3[700]; // widget text
List_Data;
typedef struct
{
IWidget *pwStatic_Widget1;
IWidget *pwStatic_Widget2;
IWidget *pwStatic_Widget3;
IValueModel * pValueModel;
List_Widgets;
In the structure I have given following declarations:
typedef struct _Box
{
. . .
List_Data *List_Item[8];
List_Widgets Item;
. . .

IWidget_SetModel( pMe->pWPropContainer , IVALUEMODEL_TO_IMODEL(pMe->Item.pValueModel));
//Add data to listbox
place_index = 0;
for (loop=0; loop<8; loop++)
{
pMe->List_Item[loop] = (List_Data*)malloc(sizeof(List_Data));
WSTRCPY(pMe->List_Item[loop]->pwData1, pMe->data[place_index++]);
WSTRCPY(pMe->List_Item[loop]->pwData2, pMe->data[place_index++]);
WSTRCPY(pMe->List_Item[loop]->pwData3, pMe->data[place_index++]);
IVectorModel_Add(pMe->pMenuModel , pMe->List_Item[loop]);
IValueModel_AddListener(pMe->Item.pValueModel,&pMe->LisValueModel);

//The Value Model Listener to add data to widgets of each container
void ValueModelLisner(void *pUserData, ModelEvent *pEvent)
{
static int loop=0;
List_Widgets* pData = (List_Widgets*)pUserData;
List_Data *pFinal= NULL;
if(pEvent->evCode == EVT_MDL_VALUE)
{
if(loop < 8)
{
IVECTORMODEL_GetAt(pMe->pMenuModel, loop,&pFinal) ;
IWIDGET_SetText(pData->pwStatic_Widget1,pFinal->pwData1, FALSE);
IWIDGET_SetText(pData->pwStatic_Widget2,pFinal->pwData2, FALSE);
IWIDGET_SetText(pData->pwStatic_Widget3,pFinal->pwData3, FALSE);
loop ++;
}

}
But for each row, the data from the last container is replicated.
Please help me in solving this problem.
Thanks.