📄 sliderwidgetdemo_old.c
字号:
IWIDGET_GetModel(pMe->sliderDemo_1, AEEIID_VALUEMODEL, (IModel**)&zjz_ValueModel);
nPos = 8;
IVALUEMODEL_SetValue(zjz_ValueModel, (void*)nPos, 10, NULL);
nPos3 = (int)IVALUEMODEL_GetValue(zjz_ValueModel,NULL);//&nPos2);
// nPos3 = *((int*)nnnp);
zjz_wpos.x = 30;
zjz_wpos.y = 30;
zjz_wpos.bVisible = TRUE;
//IXYCONTAINER_Insert(pMe->mainContainer, pMe->sliderDemo_1, WIDGET_ZNORMAL, &zjz_wpos);
//IWIDGET_GetSliderMaxPos(pMe->sliderDemo_1,&zjz_uint16);
// ===
//set static widget properties
IWIDGET_SetBorderColor(pMe->numberStatic, MAKE_RGB(100, 100, 100));
IWIDGET_SetBorderWidth(pMe->numberStatic, 1);
IWIDGET_SetFlags(pMe->numberStatic, IDF_ALIGN_RIGHT | IDF_ALIGN_MIDDLE);
// IWIDGET_SetBorderColor(pMe->opStatic, MAKE_RGB(100, 100, 100));
// IWIDGET_SetBorderWidth(pMe->opStatic, 1);
// IWIDGET_SetFlags(pMe->opStatic, IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE);
//insert static widgets into the prop container
wp.bVisible = TRUE;
// zjz [5/16/2006]
wp.prop = 10;//WIDGET_SIZE_TO_FIT;
IPROPCONTAINER_Insert(propContainer, pMe->sliderDemo_1, WIDGET_ZNORMAL, &wp);
// ====
// wp.prop = 4;
// IPROPCONTAINER_Insert(propContainer, pMe->numberStatic, WIDGET_ZNORMAL, &wp);
// wp.prop = 3;
// IPROPCONTAINER_Insert(propContainer, pMe->opStatic, WIDGET_ZNORMAL, &wp);
// set the properties and extent of the prop container
result = IPROPCONTAINER_QueryInterface(propContainer, AEEIID_WIDGET, (void**)&containerWidget);
if(result == 0) {
IWIDGET_SetLayoutStyle(containerWidget, LAYOUT_HORZ);
IWIDGET_SetBorderColor(containerWidget, RGB_BLACK);
IWIDGET_SetBorderWidth(containerWidget, 1);
we.height = 100;
we.width = 20;
IWIDGET_SetExtent(containerWidget, &we);
}
if(result == 0) {
//insert prop container into main container
wpos.x = 0;
wpos.y = 0;
wpos.bVisible = TRUE;
// IXYCONTAINER_Insert(pMe->mainContainer, containerWidget, /*WIDGET_ZNORMAL*/WIDGET_ZBOTTOMMOST, &wpos);
IXYCONTAINER_Insert(pMe->mainContainer, pMe->sliderDemo_1, WIDGET_ZNORMAL, &zjz_wpos);
IWIDGET_Release(containerWidget);
}
wpos.x = 60;
wpos.y = 20;
wpos.bVisible = TRUE;
IXYCONTAINER_Insert(pMe->mainContainer, pMe->numberStatic, WIDGET_ZTOPMOST, &wpos);
wpos.x = 100;
wpos.y = 10;
wpos.bVisible = TRUE;
IXYCONTAINER_Insert(pMe->mainContainer, pMe->sliderDemo_1, WIDGET_ZTOPMOST, &wpos);
//release the prop container
if(propContainer)
IPROPCONTAINER_Release(propContainer);
// result = ISHELL_CreateInstance(pMe->piShell, AEECLSID_PICKWIDGET, (void**)&opPickList);
// result += ISHELL_CreateInstance(pMe->piShell, AEECLSID_ARRAYMODEL, (void**)&opPickArrayModel);
// result += ISHELL_CreateInstance(pMe->piShell, AEECLSID_STATICWIDGET, (void**)&pickItemWidget);
// if(result != 0)
// return EFAILED;
// //set the array model items
// pMe->operatorString = (AECHAR*) MALLOC(12);
// ISHELL_LoadResString(pMe->piShell, CALCULATOR_RES_FILE, OPERATORSTRING, pMe->operatorString, 12);
// IARRAYMODEL_SetItems(opPickArrayModel, (void*)pMe->operatorString, 5, sizeof(AECHAR));
// IWIDGET_SetModel(opPickList, (IModel*)opPickArrayModel);
//
// //set the picklist widget properties
// IWIDGET_SetBorderWidth(opPickList, 1);
// IWIDGET_SetItemHeight(opPickList, 15);
// IWIDGET_SetItemWidth(opPickList, 15);
// IWIDGET_SetHintCols(opPickList, 2);
// //IWIDGET_GetHintCols(opPickList, &zjz_uint16);
// IWIDGET_GetPreferredExtent(opPickList, &we);
// IWIDGET_SetExtent(opPickList, &we);
//
// IWIDGET_SetBorderWidth(pickItemWidget, 1);
// IWIDGET_SetBorderColor(pickItemWidget, RGB_BLACK);
// IWIDGET_SetSelectedBorderColor(pickItemWidget, RGB_WHITE);
// IWIDGET_SetFlags(pickItemWidget, SWF_NOSHORTENTEXT | IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE);
//
// IDECORATOR_SetWidget((IDecorator*)opPickList, pickItemWidget);
//
// IWIDGET_GetModel(pickItemWidget, AEEIID_VALUEMODEL, (IModel**)&pickItemValueModel);
// IVALUEMODEL_AdaptGet(pickItemValueModel, (PFNADAPTGET)PickAdapter, 0);
//
// if(pickItemWidget)
// IWIDGET_Release(pickItemWidget);
// if(pickItemValueModel)
// IVALUEMODEL_Release(pickItemValueModel);
//
// // get the view model of the opPickList and register a listener
// // in order to to pick up operator selection
// {
// IModel* pickListViewModel = NULL;
// IWIDGET_GetViewModel(opPickList, &pickListViewModel);
// IMODEL_AddListenerEx(pickListViewModel, &pMe->pickVmListener, (PFNLISTENER)PickWidget_ViewModelHandler, pMe);
// IMODEL_Release(pickListViewModel);
// }
// //insert the opPickList widget into the main container
// wpos.x = 10;
// wpos.y = 110;
// wpos.bVisible = TRUE;
// IXYCONTAINER_Insert(pMe->mainContainer, opPickList, WIDGET_ZTOPMOST, &wpos);
//set WID_FORM to the container
result = IXYCONTAINER_QueryInterface(pMe->mainContainer, AEEIID_WIDGET, (void**)&containerWidget);
if(result ==0) {
IFORM_SetWidget(pMe->mainForm, WID_FORM, containerWidget);
//IWIDGET_MoveFocus(containerWidget, opPickList);//pMe->sliderDemo_1);
IWIDGET_Release(containerWidget);
}
// if(opPickList)
// IWIDGET_Release(opPickList);
// if(opPickArrayModel)
// IARRAYMODEL_Release(opPickArrayModel);
return result;
}
//=====================================================================================
//
//=====================================================================================
int sliderDemo_1AppForm_New(IForm** ppo, IShell *piShell, IRootForm *pRootForm/*, IDisplay *piDisplay*/) {
int result=0;
//allocate space for the form
sliderDemo_1AppForm *pMe = MALLOCREC(sliderDemo_1AppForm);
if(!pMe)
return ENOMEMORY;
pMe->piShell = piShell;
pMe->rootForm = pRootForm;
result = ISHELL_CreateInstance(pMe->piShell, AEECLSID_FORM, (void**) &pMe->mainForm);
if(result==0) {
*ppo = pMe->mainForm;
}
if(result==0) {
// result = IFORM_SetSoftkeys(pMe->mainForm, CALCULATOR_RES_FILE, MAINFORMSOFTKEY1, MAINFORMSOFTKEY2);
result = IFORM_SetResText(pMe->mainForm, FID_TITLE, "SliderWidgetDemo.bar", MAINFORMTITLE);
HANDLERDESC_Init(&pMe->mainFormHandler, sliderDemo_1AppForm_HandleEvent, pMe, sliderDemo_1AppForm_Delete);
IFORM_SetHandler(pMe->mainForm, &pMe->mainFormHandler);
}
if(result==0)
result = sliderDemo_1AppForm_PopulateMainContainer(pMe);
return result;
}
//=====================================================================================
/* Initialize applet data*/
//=====================================================================================
int sliderDemo_1_InitAppData(sliderDemo_1App* pMe) {
int result = 0;
pMe->mainForm = NULL;
//create rootForm
result = ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_ROOTFORM, (void**) &pMe->rootForm);
//set the theme
if(result == 0)
result = IROOTFORM_SetThemeFileName(pMe->rootForm, "theme.bar");
return result;
}
//=====================================================================================
// Free app data
//=====================================================================================
static void sliderDemo_1_FreeAppData(sliderDemo_1App* pMe) {
if(pMe->rootForm) {
IROOTFORM_Release(pMe->rootForm);
pMe->rootForm = NULL;
}
if(pMe->mainForm) {
IFORM_Release(pMe->mainForm);
pMe->mainForm = NULL;
}
}
//=====================================================================================
// App handle event
//=====================================================================================
static boolean sliderDemo_1_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
int result=0;
sliderDemo_1App* pMe = (sliderDemo_1App*) pi;
// Allow rootform to handle event first
if(IROOTFORM_HandleEvent(pMe->rootForm, eCode, wParam, dwParam)) {
return TRUE;
}
switch(eCode) {
case EVT_APP_START:
// create main app form and push it onto the stack
if(sliderDemo_1AppForm_New(&pMe->mainForm, pMe->a.m_pIShell, pMe->rootForm) == 0) {
IROOTFORM_PushForm(pMe->rootForm, pMe->mainForm);
return TRUE;
}
break;
case EVT_APP_STOP:
return TRUE;
default:
break;
}
return FALSE;
}
//=====================================================================================
//
//=====================================================================================
int AEEClsCreateInstance(AEECLSID ClsId,IShell * pIShell,IModule * po,void ** ppObj)
{
sliderDemo_1App* pMe=NULL;
*ppObj = NULL;
if(!AEEApplet_New(sizeof(sliderDemo_1App),
ClsId, pIShell,po,(IApplet**)ppObj,
(AEEHANDLER)sliderDemo_1_HandleEvent,
(PFNFREEAPPDATA) sliderDemo_1_FreeAppData))
return ENOMEMORY;
pMe = (sliderDemo_1App*) *ppObj;
if(sliderDemo_1_InitAppData(pMe) != 0)
return EFAILED;
return AEE_SUCCESS;
}
//=====================================================================================
//================================The end==============================================
//=====================================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -