📄 loginscreen.c
字号:
#include "loginscreen.h"
void spm_loginformInit(IRootForm *pIRootForm,IShell *pIShell,IDisplay *pIDisplay)
{
loginscreen *pMe=(loginscreen*)MALLOCREC(loginscreen);
pMe->pIShell=pIShell;
pMe->pIDisplay=pIDisplay;
pMe->DeviceInfo.wStructSize = sizeof(pMe->DeviceInfo);
ISHELL_GetDeviceInfo(pMe->pIShell,&pMe->DeviceInfo);
pMe->pIRootForm=pIRootForm;
//creation of the Login form
spm_createLoginForm(pMe);
}
void spm_createLoginForm(loginscreen *pMe)
{
int nErr=0;
IWidget *pIWTitle=NULL;
IWidget *pIWSoft=NULL;
IImage *pIImage=NULL;
WidgetPos wPos;
WExtent wex;
//*Instance Creation*/
pIImage=ISHELL_LoadResImage(pMe->pIShell,RES_FILE,TITLE_ICON);
nErr=ISHELL_CreateInstance(pMe->pIShell,AEECLSID_FORM,(void**)&pMe->pIForm);
nErr=ISHELL_CreateInstance(pMe->pIShell,AEECLSID_XYCONTAINER,(void**)&pMe->pIXYContainer);
IFORM_GetWidget(IROOTFORM_TO_IFORM(pMe->pIRootForm),WID_FORM,&pMe->pIWBack);
IXYCONTAINER_QueryInterface(pMe->pIXYContainer,AEEIID_WIDGET,(void**)&pMe->pIWBack);
/*Back Widget Properties*/
IFORM_SetWidget(pMe->pIForm,WID_FORM,pMe->pIWBack);
IWIDGET_SetBGColor(pMe->pIWBack,RGB_ITEMBACKCOLOR);
IWIDGET_SetBorderColor(pMe->pIWBack,RGB_BORDERCOLOR);
IWIDGET_SetBorderWidth(pMe->pIWBack,1);
/*Setting the title widget*/
IFORM_GetWidget(IROOTFORM_TO_IFORM(pMe->pIRootForm),WID_TITLE,&pIWTitle);
IFORM_SetTitleImage(pMe->pIForm,pIImage);
IWIDGET_SetBGColor(pIWTitle,RGB_BACKCOLOR);
IWIDGET_SetFGColor(pIWTitle,RGB_FORECOLOR);
IFORM_SetResText(pMe->pIForm,FID_TITLE,RES_FILE,TITLE_TEXT);
/*Setting the Soft key widget*/
IFORM_GetWidget(IROOTFORM_TO_IFORM(pMe->pIRootForm),WID_TITLE,&pIWTitle);
IFORM_SetTitleImage(pMe->pIForm,pIImage);
IWIDGET_SetBGColor(pIWTitle,RGB_BACKCOLOR);
IWIDGET_SetFGColor(pIWTitle,RGB_FORECOLOR);
IFORM_SetResText(pMe->pIForm,FID_SOFTKEY1,RES_FILE,IDS_LOGINSOFT1);
IFORM_SetResText(pMe->pIForm,FID_SOFTKEY2,RES_FILE,IDS_LOGINSOFT2);
wex.height=20;wex.width=pMe->DeviceInfo.cxScreen-30;
/*Creating the Login title*/
{
IWidget *pIWStatic;
AECHAR *str=NULL;
wPos.x=15;wPos.y=30;wPos.bVisible=TRUE;
str=(AECHAR*)MALLOC(STRLEN(" Login Detail")*2+1);
STRTOWSTR(" Login Detail",str,(STRLEN(" Login Detail")*2+1));
ISHELL_CreateInstance(pMe->pIShell,AEECLSID_STATICWIDGET,(void**)&pIWStatic);
IWIDGET_SetText(pIWStatic,str,FALSE);
IWIDGET_SetExtent(pIWStatic,&wex);
IWIDGET_SetBGColor(pIWStatic,RGB_BACKCOLOR);
IWIDGET_SetFGColor(pIWStatic,RGB_FORECOLOR);
//IWIDGET_SetGradientStyle(pIWStatic,1);
IXYCONTAINER_Insert(pMe->pIXYContainer,pIWStatic,WIDGET_ZNORMAL,&wPos);
IWIDGET_Release(pIWStatic);
}
/*designing of the Login label*/
{
IWidget *pIWStatic;
AECHAR *str=NULL;
wPos.x=15;wPos.y=wPos.y+wex.height;wPos.bVisible=TRUE;
str=(AECHAR*)MALLOC(STRLEN(" User Name")*2+1);
STRTOWSTR(" User Name",str,(STRLEN(" User Name")*2+1));
ISHELL_CreateInstance(pMe->pIShell,AEECLSID_STATICWIDGET,(void**)&pIWStatic);
IWIDGET_SetText(pIWStatic,str,FALSE);
IWIDGET_SetExtent(pIWStatic,&wex);
IWIDGET_SetBGColor(pIWStatic,RGB_BACKCOLOR);
IWIDGET_SetFGColor(pIWStatic,RGB_FORECOLOR);
IWIDGET_SetGradientStyle(pIWStatic,1);
IXYCONTAINER_Insert(pMe->pIXYContainer,pIWStatic,WIDGET_ZNORMAL,&wPos);
IWIDGET_Release(pIWStatic);
}
/*user name text box*/
{
//IWidget *pIWStatic;
wPos.x=15;wPos.y=wPos.y+wex.height;wPos.bVisible=TRUE;
ISHELL_CreateInstance(pMe->pIShell,AEECLSID_TEXTWIDGET,(void**)&pMe->pIWUserName);
IWIDGET_SetExtent(pMe->pIWUserName,&wex);
IWIDGET_SetBorderWidth(pMe->pIWUserName,1);
IWIDGET_SetBorderColor(pMe->pIWUserName,RGB_BACKCOLOR);
IXYCONTAINER_Insert(pMe->pIXYContainer,pMe->pIWUserName,WIDGET_ZNORMAL,&wPos);
//IWIDGET_Release(pIWStatic);
}
/*password Label*/
{
IWidget *pIWStatic;
AECHAR *str=NULL;
wPos.x=15;wPos.y=wPos.y+wex.height;wPos.bVisible=TRUE;
str=(AECHAR*)MALLOC(STRLEN(" Password")*2+1);
STRTOWSTR(" Password",str,(STRLEN(" Password")*2+1));
ISHELL_CreateInstance(pMe->pIShell,AEECLSID_STATICWIDGET,(void**)&pIWStatic);
IWIDGET_SetText(pIWStatic,str,FALSE);
IWIDGET_SetExtent(pIWStatic,&wex);
IWIDGET_SetBGColor(pIWStatic,RGB_BACKCOLOR);
IWIDGET_SetFGColor(pIWStatic,RGB_FORECOLOR);
IWIDGET_SetGradientStyle(pIWStatic,1);
IXYCONTAINER_Insert(pMe->pIXYContainer,pIWStatic,WIDGET_ZNORMAL,&wPos);
IWIDGET_Release(pIWStatic);
}
/*password Text box*/
{
wPos.x=15;wPos.y=wPos.y+wex.height;wPos.bVisible=TRUE;
ISHELL_CreateInstance(pMe->pIShell,AEECLSID_TEXTWIDGET,(void**)&pMe->pIWPassword);
IWIDGET_SetExtent(pMe->pIWPassword,&wex);
IWIDGET_SetBorderWidth(pMe->pIWPassword,1);
IWIDGET_SetBorderColor(pMe->pIWPassword,RGB_BACKCOLOR);
IWIDGET_SetFlags(pMe->pIWPassword,TWF_PASSWORD);
IXYCONTAINER_Insert(pMe->pIXYContainer,pMe->pIWPassword,WIDGET_ZNORMAL,&wPos);
}
HANDLERDESC_Init(&pMe->loginHandler,spm_loginEventHandler,pMe,NULL);
IFORM_SetHandler(pMe->pIForm,&pMe->loginHandler);
IWIDGET_MoveFocus(pMe->pIWBack,(IWidget*)WIDGET_FOCUS_FIRST);
IROOTFORM_PushForm(pMe->pIRootForm,pMe->pIForm);
}
boolean spm_loginEventHandler(loginscreen *pMe,AEEEvent eCode,uint16 wParam,uint32 dwParam)
{
AECHAR *uname,*pword;
char *username,*password;
int length=0;
if(eCode==EVT_KEY)
{
switch(wParam)
{
case AVK_SOFT1:
IWIDGET_GetTextWidgetText(pMe->pIWUserName,&uname);
IWIDGET_GetTextWidgetText(pMe->pIWPassword,&pword);
length=WSTRLEN(uname);
username=(char*)MALLOC(length+1);
WSTRTOSTR(uname,username,length+1);
length=WSTRLEN(pword);
password=(char*)MALLOC(length+1);
WSTRTOSTR(pword,password,length+1);
DBGPRINTF("press login form soft1...........user name: %s",username);
DBGPRINTF("press login form soft1...........password: %s",password);
spm_connectingAnimation(pMe);
FREE(uname);FREE(pword);
return TRUE;
case AVK_SOFT2:
IROOTFORM_PopForm(pMe->pIRootForm);
DBGPRINTF("press login form soft2...........");
return TRUE;
case AVK_UP:
IWIDGET_MoveFocus(pMe->pIWBack,(IWidget*)WIDGET_FOCUS_PREV);
DBGPRINTF("You pres the up key................");
return TRUE;
case AVK_DOWN:
IWIDGET_MoveFocus(pMe->pIWBack,(IWidget*)WIDGET_FOCUS_NEXT);
DBGPRINTF("You pres the up key................");
return TRUE;
}
}
//DBGPRINTF("in login form handler");
return HANDLERDESC_Call(&pMe->loginHandler,eCode,wParam,dwParam);
}
void spm_connectingAnimation(loginscreen *pMe)
{
IWidget *pIWStatic,*pIWImage;
WidgetPos wPos;
WExtent wex;
AECHAR *str;
IImage *pIImage=NULL;
str=(AECHAR*)MALLOC(STRLEN(" Connecting")*2+1);
STRTOWSTR(" Connecting",str,(STRLEN(" Connecting")*2+1));
wPos.x=15;wPos.y=pMe->DeviceInfo.cyScreen/4;wPos.bVisible=TRUE;
wex.height=20;wex.width=pMe->DeviceInfo.cxScreen-30;
/*Releasing and removing the previesus login screen*/
IWIDGET_Release(pMe->pIWUserName);
IWIDGET_Release(pMe->pIWPassword);
IXYCONTAINER_Remove(pMe->pIXYContainer,WIDGET_ZTOPMOST);
IXYCONTAINER_Remove(pMe->pIXYContainer,WIDGET_ZTOPMOST);
IXYCONTAINER_Remove(pMe->pIXYContainer,WIDGET_ZTOPMOST);
IXYCONTAINER_Remove(pMe->pIXYContainer,WIDGET_ZTOPMOST);
IXYCONTAINER_Remove(pMe->pIXYContainer,WIDGET_ZTOPMOST);
ISHELL_CreateInstance(pMe->pIShell,AEECLSID_STATICWIDGET,(void**)&pIWStatic);
ISHELL_CreateInstance(pMe->pIShell,AEECLSID_IMAGEWIDGET,(void**)&pIWImage);
pIImage=ISHELL_LoadResImage(pMe->pIShell,RES_FILE,IDI_CONNECTANIM);
IWIDGET_SetText(pIWStatic,str,FALSE);
IWIDGET_SetBGColor(pIWStatic,RGB_BACKCOLOR);
IWIDGET_SetFGColor(pIWStatic,RGB_FORECOLOR);
//IWIDGET_SetGradientStyle(pIWStatic,1);
IWIDGET_SetExtent(pIWStatic,&wex);
IWIDGET_SetBGColor(pIWImage,RGB_BACKCOLOR);
//IWIDGET_SetGradientStyle(pIWImage,1);
IWIDGET_SetImage(pIWImage,pIImage);
IWIDGET_Animate(pIWImage,TRUE);
IWIDGET_SetExtent(pIWImage,&wex);
wPos.y=wPos.y+wex.height;
IXYCONTAINER_Insert(pMe->pIXYContainer,pIWImage,WIDGET_ZNORMAL,&wPos);
wPos.y=wPos.y-(wex.height/2-4);
IXYCONTAINER_Insert(pMe->pIXYContainer,pIWStatic,WIDGET_ZNORMAL,&wPos);
IWIDGET_Release(pIWImage);
IWIDGET_Release(pIWStatic);
ISHELL_SetTimer(pMe->pIShell,4000,(PFNNOTIFY)spm_callingServerResponse,pMe);
}
void spm_callingServerResponse(loginscreen *pMe)
{
IROOTFORM_PopForm(pMe->pIRootForm);
IFORM_Release(pMe->pIForm);
DBGPRINTF("Calling the server page");
spm_responsescreenInit(pMe->pIRootForm,pMe->pIShell,pMe->pIDisplay);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -