📄 wml_mmi.c
字号:
/*
* Copyright (C) Ericsson Mobile Communications AB, 2000.
* Licensed to AU-System AB.
* All rights reserved.
*
* This software is covered by the license agreement between
* the end user and AU-System AB, and may be used and copied
* only in accordance with the terms of the said agreement.
*
* Neither Ericsson Mobile Communications AB nor AU-System AB
* assumes any responsibility or liability for any errors or inaccuracies in
* this software, or any consequential, incidental or indirect damage arising
* out of the use of the Generic WAP Client software.
*/
#ifndef WML_MMI_C
#define WML_MMI_C
#include "wmlif.h"
#include "wae_cmmn.h"
#include "wmltoken.h"
#include "aapimmi.h"
#include "aapiclnt.h"
#include "capiclnt.h"
#include "history.h"
#include "wml_uafn.h"
#include "wml_mmi.h"
void SDL_ShowCard(void *pUser)
{
#ifdef WAE_DEBUG
PrintChar("---SHOWCARD--\n");
#endif
if (pUser)
MMIa_showCard(((UA*)pUser)->iViewID);
}
void SDL_CancelCard(void *pUser)
{
#ifdef WAE_DEBUG
PrintChar("---CANCELCARD--\n");
#endif
if (pUser)
MMIa_cancelCard(((UA*)pUser)->iViewID);
}
/*-------------------------------------------------------------------
CreateCard is called by the SDL system when a new
card should be created.
----------------------------------------------------------------------*/
void SDL_CreateCard(void* pUserAgent, void *pCard, BOOL fRefresh, void* pbURL, BOOL fNewContext)
{
UA *pUser=NULL;
WCHAR** ppHistory=NULL;
WCHAR* pwchTitle=NULL;
BOOL fStyleIsList=FALSE;
#ifdef WAE_DEBUG
WCHAR** ppTempHistory=NULL;
#endif
pUser = (UA*)pUserAgent;
#ifdef WAE_DEBUG
PrintChar("--------------------------NEW CARD--------------------------\n");
#endif
if (pCard!=NULL)
{
pwchTitle = WML_GetCardTitle (pUser, (ELEMENTTYPE*) pCard);
#ifdef WAE_DEBUG
PrintChar("Title:");
WMLUA_PrintWS(pwchTitle);
#endif
ppHistory = WML_GetHistoryListTitles (pUser);
/* TODOjex */
fStyleIsList = ( (CARDELEMENT*)(pCard) )->fOrdered;
#ifdef WAE_DEBUG
PrintChar("----------- HISTORY ---------\n");
PrintChar("Cardtitles:");
if (ppHistory!=NULL)
{
ppTempHistory = ppHistory;
while (*ppTempHistory != NULL)
{
WMLUA_PrintWS(*ppTempHistory);
ppTempHistory++;
}
}
PrintChar("------------:");
#endif
MMIa_newCard(pUser->iViewID, pwchTitle, fStyleIsList, fRefresh, (CHAR*)pbURL, fNewContext, ppHistory);
DEALLOC(&pwchTitle);
}
else
{
MMIa_newCard(pUser->iViewID, NULL, 0, 0, NULL, TRUE, NULL);
}
DEALLOC(& ppHistory);
}
/* clears the current card */
void SDL_ClearCard(void* pUserAgent, BOOL fNewContext )
{
WCHAR** ppHistory=NULL;
BYTE* pURL =NULL;
if (pUserAgent)
{
if (!fNewContext)
{
ppHistory = WML_GetHistoryListTitles ((UA*)pUserAgent);
pURL = ((UA*)(pUserAgent))->pbURLBase;
}
MMIa_newCard(((UA*)pUserAgent)->iViewID, NULL, TRUE, FALSE, (CHAR*)pURL, fNewContext, ppHistory);
MMIa_showCard(((UA*)pUserAgent)->iViewID);
}
DEALLOC(& ppHistory);
}
BOOL SDL_CreateText(void *pUserAgent,void* pTextElement, int iTextID, int iEmphMode, void* pLinkElement, int iWhiteSpace, int fPreformatted )
{
UA *pUser;
WCHAR* pwchText=NULL;
WCHAR* pLinkTitle=NULL;
BOOL fIsLink=FALSE;
BOOL fRes=FALSE;
WCHAR wchAccessKey=0;
pUser = (UA*)pUserAgent;
if (pTextElement !=NULL)
pwchText = (WCHAR*)SDL_GetText(pUser, (ELEMENTTYPE*)pTextElement);
else
{
pwchText = NEWARRAY(WCHAR,1);
pwchText[0]=0;
}
#ifdef WAE_DEBUG
PrintChar("--Text--\n");
WMLUA_PrintWS(pwchText);
#endif
/* if a linkelement is present the title is retrieved */
if (pLinkElement)
{
fIsLink = TRUE;
if ( ((ELEMENTTYPE*)pLinkElement)->iType == Type_A)
{
pLinkTitle = (WCHAR*) SDL_GetText(pUser, ((AELEMENT*)(pLinkElement))->pTitle );
wchAccessKey = ((AELEMENT*)(pLinkElement))->wchAccessKey;
}
else
{
pLinkTitle = (WCHAR*) SDL_GetText(pUser, ( (ANCHORELEMENT*)(pLinkElement) )->pTitle );
wchAccessKey = ((ANCHORELEMENT*)(pLinkElement))->wchAccessKey;
}
}
else
fIsLink = FALSE;
/* whitespace criteria
If the element is a text and the flag is set, trim the text with the
parameter set to left. Also, if the text ends with a white space, set
the flag. Otherwise clear it.
else
If the element is a text and the flag is not set, trim the text with
the parameter set to right. Also, if the text ends with a white
space, set the flag. Otherwise clear it.
*/
if (pwchText && !fPreformatted)
{
if (iWhiteSpace)
fRes = WML_TrimTextWCHAR( pwchText, TRIMTEXT_LEFT);
else
fRes = WML_TrimTextWCHAR( pwchText, TRIMTEXT_NONE);
}
MMIa_newText ((UINT8)(pUser->iViewID), (UINT8)iTextID, pwchText, fIsLink, pLinkTitle, wchAccessKey,(INT8)iEmphMode);
DEALLOC(&pLinkTitle);
DEALLOC(&pwchText);
return fRes;
/* NOTE: TextID is always 0 if it磗 not a link */
}
int SDL_UpdateEmph(void* pEmphElement, BYTE* pEmphMode, BOOL fModeOn)
{
UINT16 iType=0;
UINT8 iEmph =0;
UINT8 iResult=0;
INT8 i=0;
if (pEmphElement)
{
iType = ((ELEMENTTYPE*)pEmphElement)->iType;
switch (iType)
{
case Type_SMALL:
iEmph = TXT_SMALL;
break;
case Type_BIG:
iEmph = TXT_BIG;
break;
case Type_B:
iEmph = TXT_BOLD;
break;
case Type_I:
iEmph = TXT_ITALIC;
break;
case Type_U:
iEmph = TXT_UNDERLINE;
break;
case Type_EM:
iEmph = TXT_EMPHASIS;
break;
case Type_STRONG:
iEmph = TXT_STRONG;
break;
default :
break;
}
/* find byte nr */
i=0;
iEmph = iEmph>>1;
while (iEmph)
{
iEmph = iEmph>>1;
i++;
}
/* set/clear the emphmode */
if (fModeOn)
pEmphMode[i]++; /* set emphmode */
else
{
if (pEmphMode[i])
pEmphMode[i]--; /* clear emphmode */
}
i=7;
while (i>=0)
{
iResult = iResult<<1;
if ( pEmphMode[i] )
iResult = iResult | 0x01;
i--;
}
}
else
{
while (i<8)
{
pEmphMode[i]=0;
i++;
}
/* empty pEmphMode */
}
return iResult;
}
void SDL_CreateInput(void *pUser, void* pElement, int iInputId)
{
WCHAR* pwchTitle=NULL;
WCHAR* pwchText=NULL;
INPUTELEMENT *pInputElm=NULL;
BOOL fIsPassword=FALSE;
WCHAR wchAccessKey=0;
if (pElement !=NULL)
{
if (((ELEMENTTYPE*)pElement)->iType==Type_INPUT)
{
pInputElm=(INPUTELEMENT*)pElement;
pwchTitle = (WCHAR*) SDL_GetText((UA*)pUser, pInputElm->pTitle);
pwchText = WML_GetInputKeyValue((UA*)pUser, (ELEMENTTYPE*)pElement);
wchAccessKey = pInputElm->wchAccessKey;
if (pInputElm->iInputType==DEF_TYPE_PASSWORD)
fIsPassword = TRUE;
MMIa_newInput (((UA*)pUser)->iViewID, (UINT8)iInputId, pwchTitle , pwchText, fIsPassword, pInputElm->fEmptyOK, pInputElm->pchFormat, (INT8)(pInputElm->iSize), (INT8)(pInputElm->iMaxLength), pInputElm->iTabIndex, wchAccessKey );
#ifdef WAE_DEBUG
PrintChar("--Input--\n");
PrintChar("Title:");
PrintChar("Text");
WMLUA_PrintWS(pwchText);
#endif
DEALLOC(&pwchTitle);
DEALLOC(&pwchText);
}
}
}
/*---------------------------------------------------------------------
Handle tables SDL_CreateTable, SDL_CloseTable,SDL_CreateTableCell
----------------------------------------------------------------------*/
void SDL_CreateTable(void* pUserAgent, void* pElement)
{
WCHAR* pwchTitle=NULL;
BYTE* pbAlign=NULL;
BOOL fDummy;
TABLEELEMENT *pTableElm=NULL;
if (pElement !=NULL)
{
if (((ELEMENTTYPE*)pElement)->iType==Type_TABLE)
{
pTableElm=(TABLEELEMENT*)pElement;
pwchTitle = (WCHAR*) SDL_GetText((UA*)pUserAgent, pTableElm->pTitle);
pbAlign = wip_wchar2byte( pTableElm->pchAlign, & fDummy);
MMIa_newTable (((UA*)pUserAgent)->iViewID, pwchTitle, pTableElm->iColumns, (CHAR*)pbAlign);
DEALLOC(&pbAlign);
#ifdef WAE_DEBUG
PrintChar("--Table--\n");
#endif
DEALLOC(&pwchTitle);
}
}
}
void SDL_CloseTable(void* pUserAgent)
{
if (pUserAgent)
MMIa_closeTable(((UA*)pUserAgent)->iViewID);
}
void SDL_CreateTableCell(void* pUserAgent )
{
if (pUserAgent)
MMIa_newTableData(((UA*)pUserAgent)->iViewID);
}
/*---------------------------------------------------------------------
SDL_CreateSelect,SDL_CreateOptGrp,SDL_CloseOptGrp,SDL_CreateOption
----------------------------------------------------------------------*/
void SDL_CreateSelect(void *pUserAgent, void* pElement)
{
WCHAR* pwchTitle=NULL;
SELECTELEMENT *pSelectElm=NULL;
if (pElement)
{
pSelectElm=(SELECTELEMENT*)pElement;
pwchTitle = (WCHAR*) SDL_GetText((UA*)pUserAgent, pSelectElm->pTitle);
MMIa_newSelect(((UA*)pUserAgent)->iViewID, pwchTitle, pSelectElm->fMultiple, (INT8)(pSelectElm->iTabIndex) );
#ifdef WAE_DEBUG
PrintChar("--Select--\n");
#endif
DEALLOC(&pwchTitle);
}
}
void SDL_CloseSelect(void *pUser)
{
#ifdef WAE_DEBUG
PrintChar("--CloseSelect--\n");
#endif
if (pUser)
MMIa_closeSelect(((UA*)pUser)->iViewID);
}
void SDL_CreateOptGrp(void *pUser, void* pElement)
{
WCHAR* pwchTitle=NULL;
if (pElement !=NULL)
{
pwchTitle = (WCHAR*) SDL_GetText((UA*)pUser, ((OPTGROUPELEMENT*)pElement)->pTitle);
#ifdef WAE_DEBUG
PrintChar("--OptGrp--\n");
#endif
MMIa_newOptionGroup ( ((UA*)pUser)->iViewID, pwchTitle);
DEALLOC(&pwchTitle);
}
}
void SDL_CloseOptGrp(void *pUser)
{
#ifdef WAE_DEBUG
PrintChar("--CloseOptGrp--\n");
#endif
if (pUser)
MMIa_closeOptionGroup (((UA*)pUser)->iViewID);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -