Unabale to attach scrollbar on Form | developer.brewmp.com Unabale to attach scrollbar on Form | developer.brewmp.com

Developer

Unabale to attach scrollbar on Form

Hi

I am making a user information Form which contains multiple static and text widgets .So due to small size of screen i want to attach a scrollbar on this Form to view all fields.But when i insert scrollbar into a constraint container i get an exception "Stack overflow."Here is my code.

IShell *pIShell = pThis->piShell;
IConstraintContainer *pIConstraintContainer;
IWidget *pIWidget, *pIConstraintContainerWidget;
IWidget *pIScrollBar;
WExtent extent;
AEERect rc;
IFont *piFont;
WidgetProp wp;

WidgetConstraint widgetContraint = { pThis->rc.x + 10, pThis->rc.y + 10, TRUE };
WExtent size = { pThis->rc.dx - 20, (pThis->rc.dy - 20)/2 };
int result = ENOMEMORY;

result = ISHELL_CreateInstance( pIShell, AEECLSID_CONSTRAINTCONTAINER, (void**)&pIConstraintContainer );
if ( result != SUCCESS ) goto error;

result = ICONSTRAINTCONTAINER_QueryInterface( pIConstraintContainer, AEEIID_WIDGET, (void**)&pIConstraintContainerWidget );
if ( result != SUCCESS ) goto error;
pThis->pIConstraintContainerWidget= pIConstraintContainerWidget;

IROOTFORM_GetClientRect(pThis->pIRootForm, NULL, &rc);

SETWEXTENT(&extent, rc.dx, rc.dy);
IWIDGET_SetExtent(pIConstraintContainerWidget, &extent);
IFORM_SetWidget(pThis->pIAccountSettingForm, WID_FORM, pIConstraintContainerWidget);

IFORM_SetText( pThis->pIAccountSettingForm, FID_TITLE, L" Account Setting" );
IFORM_SetText( pThis->pIAccountSettingForm, FID_SOFTKEY1, L"*" );
IFORM_SetText( pThis->pIAccountSettingForm, FID_SOFTKEY2, L"#" );

ISHELL_CreateInstance(pThis->piShell , AEECLSID_FONT_BASIC10 , &piFont);
IFORM_GetWidget(IROOTFORM_TO_IFORM(pThis->pIRootForm),WID_SOFTKEYS,&pIWidget);
IWIDGET_SetFont(pIWidget, piFont);
IWIDGET_SetBGColor(pIWidget,MAKE_RGB(227,227,221));
IWIDGET_Release( pIWidget );

widgetContraint.constraint.top.type = CONSTRAINT_PARENT_TOP;
widgetContraint.constraint.top.offset = 0;
widgetContraint.constraint.left.type = CONSTRAINT_PARENT_LEFT;
widgetContraint.constraint.left.offset = 0;
widgetContraint.constraint.right.type = CONSTRAINT_PARENT_RIGHT;
widgetContraint.constraint.right.offset = -10;
widgetContraint.constraint.bottom.type = WIDGET_SIZE_TO_FIT;
widgetContraint.constraint.bottom.offset = 0;
widgetContraint.bVisible = TRUE;

///Account Name label widget
result = ISHELL_CreateInstance( pIShell, AEECLSID_STATICWIDGET, (void**)&pIWidget );
if ( result != SUCCESS ) goto error;
IWIDGET_SetExtent( pIWidget, &size );
IWIDGET_SetText( pIWidget, L"AccountName:", FALSE );
result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIWidget, WIDGET_ZNORMAL, &widgetContraint );
IWIDGET_MoveFocus( pIConstraintContainerWidget, pIWidget );
IWIDGET_SetFocus(pIWidget,TRUE);
IWIDGET_Release( pIWidget );

///Account Name input widget
widgetContraint.constraint.top.type = CONSTRAINT_PREV_BOTTOM;
result = ISHELL_CreateInstance( pIShell, AEECLSID_TEXTWIDGET, (void**)&pIWidget );
if ( result != SUCCESS ) goto error;
IWIDGET_SetExtent( pIWidget, &size );
result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIWidget, WIDGET_ZNORMAL, &widgetContraint );
IWIDGET_SetBGColor(pIWidget,MAKE_RGB(227,227,223));
pThis->pIFirstWidget=pIWidget;
IWIDGET_SetFocus(pIWidget,TRUE);
RELEASEIF( pIWidget );

//Access Password label widget
widgetContraint.constraint.top.type = CONSTRAINT_PREV_BOTTOM;
result = ISHELL_CreateInstance( pIShell, AEECLSID_STATICWIDGET, (void**)&pIWidget );
if ( result != SUCCESS ) goto error;
IWIDGET_SetExtent( pIWidget, &size );
IWIDGET_SetText( pIWidget, L"Access Password:", FALSE );
result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIWidget, WIDGET_ZNORMAL, &widgetContraint );
IWIDGET_Release( pIWidget );

//Access Password input widget
widgetContraint.constraint.top.type = CONSTRAINT_PREV_BOTTOM;
result = ISHELL_CreateInstance( pIShell, AEECLSID_TEXTWIDGET, (void**)&pIWidget );
if ( result != SUCCESS ) goto error;
IWIDGET_SetExtent( pIWidget, &size );
result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIWidget, WIDGET_ZNORMAL, &widgetContraint );
IWIDGET_SetBGColor(pIWidget,MAKE_RGB(227,227,223));
IWIDGET_SetFlags(pIWidget,TWF_PASSWORD);
pThis->pISecondWidget=pIWidget;
IWIDGET_Release( pIWidget );
result = ISHELL_CreateInstance( pIShell, AEECLSID_TEXTMODEL, (void**)&pThis->passwordTextModel);
if ( result != SUCCESS ) goto error;
IWIDGET_SetModel(pIWidget,pThis->passwordTextModel);

///Email address label widget
result = ISHELL_CreateInstance( pIShell, AEECLSID_STATICWIDGET, (void**)&pIWidget );
if ( result != SUCCESS ) goto error;
IWIDGET_SetExtent( pIWidget, &size );
IWIDGET_SetText( pIWidget, L"Email Address:", FALSE );
result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIWidget, WIDGET_ZNORMAL, &widgetContraint );
IWIDGET_Release( pIWidget );

widgetContraint.constraint.top.type = CONSTRAINT_PREV_BOTTOM;

///Email address input widget
result = ISHELL_CreateInstance( pIShell, AEECLSID_TEXTWIDGET, (void**)&pIWidget );
if ( result != SUCCESS ) goto error;
IWIDGET_SetExtent( pIWidget, &size );
result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIWidget, WIDGET_ZNORMAL, &widgetContraint );
IWIDGET_SetBGColor(pIWidget,MAKE_RGB(227,227,223));
IWIDGET_Release( pIWidget );

///User Name label widget
widgetContraint.constraint.top.type = CONSTRAINT_PREV_BOTTOM;
result = ISHELL_CreateInstance( pIShell, AEECLSID_STATICWIDGET, (void**)&pIWidget );
if ( result != SUCCESS ) goto error;
IWIDGET_SetExtent( pIWidget, &size );
IWIDGET_SetText( pIWidget, L"User Name:", FALSE );
result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIWidget, WIDGET_ZNORMAL, &widgetContraint );
IWIDGET_Release( pIWidget );

widgetContraint.constraint.top.type = CONSTRAINT_PREV_BOTTOM;
///User Name input widget
result = ISHELL_CreateInstance( pIShell, AEECLSID_TEXTWIDGET, (void**)&pIWidget );
if ( result != SUCCESS ) goto error;
IWIDGET_SetExtent( pIWidget, &size );
result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIWidget, WIDGET_ZNORMAL, &widgetContraint );
IWIDGET_SetBGColor(pIWidget,MAKE_RGB(227,227,223));
IWIDGET_Release( pIWidget );
// Password label widget
widgetContraint.constraint.top.type = CONSTRAINT_PREV_BOTTOM;
result = ISHELL_CreateInstance( pIShell, AEECLSID_STATICWIDGET, (void**)&pIWidget );
if ( result != SUCCESS ) goto error;
IWIDGET_SetExtent( pIWidget, &size );
IWIDGET_SetText( pIWidget, L"Password:", FALSE );
result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIWidget, WIDGET_ZNORMAL, &widgetContraint );
IWIDGET_Release( pIWidget );

// Password input widget
widgetContraint.constraint.top.type = CONSTRAINT_PREV_BOTTOM;
result = ISHELL_CreateInstance( pIShell, AEECLSID_TEXTWIDGET, (void**)&pIWidget );
if ( result != SUCCESS ) goto error;
IWIDGET_SetExtent( pIWidget, &size );
result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIWidget, WIDGET_ZNORMAL, &widgetContraint );
IWIDGET_SetBGColor(pIWidget,MAKE_RGB(227,227,223));
IWIDGET_SetFlags(pIWidget,TWF_PASSWORD);
IWIDGET_Release( pIWidget );
result = ISHELL_CreateInstance( pIShell, AEECLSID_TEXTMODEL, (void**)&pThis->passwordTextModel);
if ( result != SUCCESS ) goto error;
IWIDGET_SetModel(pIWidget,pThis->passwordTextModel);

/**************************** ScrollBar **************************/
result=ISHELL_CreateInstance(pIShell, AEECLSID_SCROLLBARWIDGET, (void**)&pIScrollBar );
if(result!=SUCCESS)goto error;
IWIDGET_SetFlags(pIScrollBar,SBWF_NOAUTOHIDE|SBWF_ARROWS);
IWIDGET_SetProperty(pIScrollBar,PROP_SCROLLPAD ,0);
IWIDGET_SetProperty(pIScrollBar,PROP_SCROLLCOLOR ,MAKE_RGB(82,137,213));
IWIDGET_SetProperty(pIScrollBar,PROP_SCROLLFILLCOLOR,MAKE_RGB(82,137,213));
IWIDGET_SetProperty(pIScrollBar,PROP_SCROLLHANDLECOLOR,MAKE_RGB(181,207,243));
IDECORATOR_SetWidget((IDecorator*)pIScrollBar, pIConstraintContainerWidget);
IFORM_SetWidget(pThis->pIAccountSettingForm,AEECLSID_CONSTRAINTCONTAINER,pIConstraintContainerWidget);
result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIScrollBar ,WIDGET_ZTOPMOST, &widgetContraint);

IWIDGET_Release(pIScrollBar);

Now I am able to see the scrollbar but scrollbar is not scrolling (enven if i use 5 staticwidgets and 5 textwidgets on the screen) .i have done the following change in scrollbar code.
result=ISHELL_CreateInstance(pIShell, AEECLSID_SCROLLBARWIDGET, (void**)&pIScrollBar );
if(result!=SUCCESS)goto error;
IWIDGET_SetFlags(pIScrollBar,SBWF_NOAUTOHIDE|SBWF_ARROWS);
IWIDGET_SetProperty(pIScrollBar,PROP_SCROLLPAD ,0);
IWIDGET_SetProperty(pIScrollBar,PROP_SCROLLCOLOR ,MAKE_RGB(82,137,213));
IWIDGET_SetProperty(pIScrollBar,PROP_SCROLLFILLCOLOR,MAKE_RGB(82,137,213));
IWIDGET_SetProperty(pIScrollBar,PROP_SCROLLHANDLECOLOR,MAKE_RGB(181,207,243));
widgetContraint.constraint.top.type = CONSTRAINT_PARENT_TOP;
widgetContraint.constraint.top.offset = 0;
widgetContraint.constraint.left.type = CONSTRAINT_PARENT_LEFT;
widgetContraint.constraint.left.offset = 0;
widgetContraint.constraint.right.type = CONSTRAINT_PARENT_RIGHT;
widgetContraint.constraint.right.offset = 0;
widgetContraint.constraint.bottom.type =CONSTRAINT_PARENT_BOTTOM;
widgetContraint.constraint.bottom.offset = 0;
widgetContraint.bVisible = TRUE;
IFORM_SetWidget(pThis->pIAccountSettingForm,AEECLSID_CONSTRAINTCONTAINER,pIConstraintContainerWidget);
result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIScrollBar ,WIDGET_ZTOPMOST, &widgetContraint);
IWIDGET_Release(pIScrollBar);

Now I am able to see the scrollbar but scrollbar is not scrolling (enven if i use 5 staticwidgets and 5 textwidgets on the screen) .i have done the following change in scrollbar code.
result=ISHELL_CreateInstance(pIShell, AEECLSID_SCROLLBARWIDGET, (void**)&pIScrollBar );
if(result!=SUCCESS)goto error;
IWIDGET_SetFlags(pIScrollBar,SBWF_NOAUTOHIDE|SBWF_ARROWS);
IWIDGET_SetProperty(pIScrollBar,PROP_SCROLLPAD ,0);
IWIDGET_SetProperty(pIScrollBar,PROP_SCROLLCOLOR ,MAKE_RGB(82,137,213));
IWIDGET_SetProperty(pIScrollBar,PROP_SCROLLFILLCOLOR,MAKE_RGB(82,137,213));
IWIDGET_SetProperty(pIScrollBar,PROP_SCROLLHANDLECOLOR,MAKE_RGB(181,207,243));
widgetContraint.constraint.top.type = CONSTRAINT_PARENT_TOP;
widgetContraint.constraint.top.offset = 0;
widgetContraint.constraint.left.type = CONSTRAINT_PARENT_LEFT;
widgetContraint.constraint.left.offset = 0;
widgetContraint.constraint.right.type = CONSTRAINT_PARENT_RIGHT;
widgetContraint.constraint.right.offset = 0;
widgetContraint.constraint.bottom.type =CONSTRAINT_PARENT_BOTTOM;
widgetContraint.constraint.bottom.offset = 0;
widgetContraint.bVisible = TRUE;
IFORM_SetWidget(pThis->pIAccountSettingForm,AEECLSID_CONSTRAINTCONTAINER,pIConstraintContainerWidget);
result = ICONSTRAINTCONTAINER_Insert( pIConstraintContainer, pIScrollBar ,WIDGET_ZTOPMOST, &widgetContraint);
IWIDGET_Release(pIScrollBar);

Where is your call to IDECORATOR_SetWidget(pIScrollBar, pSomeWidget)?
-Erik

Where is your call to IDECORATOR_SetWidget(pIScrollBar, pSomeWidget)?
-Erik