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

Developer

Forums

Forums:

HI All

 

I am trying to add button widget to the list container where there are  two images, two text and 1 button.

So i want full focus to the list and in that focused list when i press button , I want some action to happen..

But the problem what i am facing is , whenever focus changes the button widget get highlighted... so if i press again the button the effect wont change. 

 

can anyone tell how to come up with this?????????/

 

Regards

Gautam

I am not clear on your exact requirements but here is how I would do it:
//--------------------------------------------------------------------
// ButtonWidget
//--------------------------------------------------------------------
#define BUTTON_OFFSETX 1
#define BUTTON_OFFSETY 1

static int listcontainerapp_CreateButtonWidget(IShell *piShell, IWidget **ppo,
const AECHAR *pwszText, int nWidth)
{
IController *pitc = 0;
WidgetExtent we;
int nErr = 0;

// button widget is actually a static widget
ERR_TRY( ISHELL_CreateInstance(piShell, AEECLSID_StaticWidget, (void**)ppo) );

// setup button widget
(void) IWIDGET_SetText(*ppo, pwszText, 0);
(void) IWidget_SetFontClass(*ppo, AEECLSID_FONTSYSBOLD);
(void) IWidget_SetFlags(*ppo, IDF_ALIGN_CENTER|IDF_ALIGN_MIDDLE);
(void) IWidget_SetBorderWidth(*ppo, 2);
(void) IWidget_SetBorderStyle(*ppo, BORDERSTYLE_ROUNDED);
(void) IWidget_SetBorderRadius(*ppo, 12);
(void) IWidget_SetPadding(*ppo, 1);

(void) IWidget_SetShadowOffsetX(*ppo, BUTTON_OFFSETX);
(void) IWidget_SetSelectedShadowOffsetX(*ppo, -BUTTON_OFFSETX);
(void) IWidget_SetShadowOffsetY(*ppo, BUTTON_OFFSETY);
(void) IWidget_SetSelectedShadowOffsetY(*ppo, -BUTTON_OFFSETY);

(void) IWidget_SetGradientStyle(*ppo, GRADIENT_STYLE_HORZ);

(void) IWidget_SetBorderColor(*ppo, RGB_DLGBUTTON_BDR);
(void) IWidget_SetSelectedBorderColor(*ppo, RGB_DLGBUTTON_SELBDR);

(void) IWidget_SetBGColor(*ppo, RGB_DLGBUTTON_BG);
(void) IWidget_SetProperty(*ppo, PROP_GRADIENT, RGB_DLGBUTTON_BGEND);

(void) IWidget_SetSelectedBGColor(*ppo, RGB_DLGBUTTON_SELBG);
(void) IWidget_SetProperty(*ppo, PROP_SELECTED_GRADIENT, RGB_DLGBUTTON_SELBGEND);

(void) IWidget_SetFGColor(*ppo, RGB_DLGBUTTON_FG);
(void) IWidget_SetSelectedFGColor(*ppo, RGB_DLGBUTTON_SELFG);

IWidget_GetPreferredExtent(*ppo, &we);
if (nWidth > 0) {
we.width = nWidth;
}
IWidget_SetExtent(*ppo, &we);

ERR_TRY(ISHELL_CreateInstance(piShell, AEECLSID_ButtonTC, (void **)&pitc));
ERR_TRY( IWidget_SetTouchController(*ppo, pitc) );

ERR_CATCH:
RELEASEIF(pitc);
return nErr;

static void listcontainerapp_OKListener(userContext *me, ModelEvent *pEvent)
{
if (EVT_MDL_WIDGETELEM_CLICK == pEvent->evCode)
{
//handle click event and do the required action.
DBGPRINTF("EVT_MDL_WIDGETELEM_CLICK");
}

listcontainerapp_GetItemWidget()
{
....
IWidget *piwOK = NULL;

ERR_TRY( listcontainerapp_CreateButtonWidget(pData->piShell, &piwOK, L"OK", 60) );
pData->piwList[pData->nmlCount].piwOK = piwOK;

// add a listener for the OK button
{
IModel *pivmOK = 0;
(void) IWidget_GetViewModel(piwOK, &pivmOK);
(void) IModel_AddListenerEx(pivmOK, &pData->mlOK[pData->nmlCount], (PFNLISTENER)listcontainerapp_OKListener, pData);
RELEASEIF(pivmOK);
}
//Insert Button in a container (list item container)
ERR_TRY( IPropContainer_InsertEx(picMainContainer, piwOK, WIDGET_KEEP_EXTENT, TRUE, 10, 0) );
.....

I am not clear on your exact requirements but here is how I would do it:
//--------------------------------------------------------------------
// ButtonWidget
//--------------------------------------------------------------------
#define BUTTON_OFFSETX 1
#define BUTTON_OFFSETY 1

static int listcontainerapp_CreateButtonWidget(IShell *piShell, IWidget **ppo,
const AECHAR *pwszText, int nWidth)
{
IController *pitc = 0;
WidgetExtent we;
int nErr = 0;

// button widget is actually a static widget
ERR_TRY( ISHELL_CreateInstance(piShell, AEECLSID_StaticWidget, (void**)ppo) );

// setup button widget
(void) IWIDGET_SetText(*ppo, pwszText, 0);
(void) IWidget_SetFontClass(*ppo, AEECLSID_FONTSYSBOLD);
(void) IWidget_SetFlags(*ppo, IDF_ALIGN_CENTER|IDF_ALIGN_MIDDLE);
(void) IWidget_SetBorderWidth(*ppo, 2);
(void) IWidget_SetBorderStyle(*ppo, BORDERSTYLE_ROUNDED);
(void) IWidget_SetBorderRadius(*ppo, 12);
(void) IWidget_SetPadding(*ppo, 1);

(void) IWidget_SetShadowOffsetX(*ppo, BUTTON_OFFSETX);
(void) IWidget_SetSelectedShadowOffsetX(*ppo, -BUTTON_OFFSETX);
(void) IWidget_SetShadowOffsetY(*ppo, BUTTON_OFFSETY);
(void) IWidget_SetSelectedShadowOffsetY(*ppo, -BUTTON_OFFSETY);

(void) IWidget_SetGradientStyle(*ppo, GRADIENT_STYLE_HORZ);

(void) IWidget_SetBorderColor(*ppo, RGB_DLGBUTTON_BDR);
(void) IWidget_SetSelectedBorderColor(*ppo, RGB_DLGBUTTON_SELBDR);

(void) IWidget_SetBGColor(*ppo, RGB_DLGBUTTON_BG);
(void) IWidget_SetProperty(*ppo, PROP_GRADIENT, RGB_DLGBUTTON_BGEND);

(void) IWidget_SetSelectedBGColor(*ppo, RGB_DLGBUTTON_SELBG);
(void) IWidget_SetProperty(*ppo, PROP_SELECTED_GRADIENT, RGB_DLGBUTTON_SELBGEND);

(void) IWidget_SetFGColor(*ppo, RGB_DLGBUTTON_FG);
(void) IWidget_SetSelectedFGColor(*ppo, RGB_DLGBUTTON_SELFG);

IWidget_GetPreferredExtent(*ppo, &we);
if (nWidth > 0) {
we.width = nWidth;
}
IWidget_SetExtent(*ppo, &we);

ERR_TRY(ISHELL_CreateInstance(piShell, AEECLSID_ButtonTC, (void **)&pitc));
ERR_TRY( IWidget_SetTouchController(*ppo, pitc) );

ERR_CATCH:
RELEASEIF(pitc);
return nErr;

static void listcontainerapp_OKListener(userContext *me, ModelEvent *pEvent)
{
if (EVT_MDL_WIDGETELEM_CLICK == pEvent->evCode)
{
//handle click event and do the required action.
DBGPRINTF("EVT_MDL_WIDGETELEM_CLICK");
}

listcontainerapp_GetItemWidget()
{
....
IWidget *piwOK = NULL;

ERR_TRY( listcontainerapp_CreateButtonWidget(pData->piShell, &piwOK, L"OK", 60) );
pData->piwList[pData->nmlCount].piwOK = piwOK;

// add a listener for the OK button
{
IModel *pivmOK = 0;
(void) IWidget_GetViewModel(piwOK, &pivmOK);
(void) IModel_AddListenerEx(pivmOK, &pData->mlOK[pData->nmlCount], (PFNLISTENER)listcontainerapp_OKListener, pData);
RELEASEIF(pivmOK);
}
//Insert Button in a container (list item container)
ERR_TRY( IPropContainer_InsertEx(picMainContainer, piwOK, WIDGET_KEEP_EXTENT, TRUE, 10, 0) );
.....