📄 wap_gle.c
字号:
parameter.is_link = isLink;
parameter.formatstring_length = 0;
parameter.Formatstring = NULL;
parameter.deltaY = deltaY;
W_WAP_MMI_SEND_TEXT_IND(¶meter);
return;
}
/*******************************************************************************
$Function: GLEa_imageConvert
$Description: This function allocates memory and converts an image to a platform
image format.
SPR#2486 - SH - Now call image scaling routine with actual image
dimensions, and specified on-screen dimensions
$Returns: a pointer to the converted image
$Arguments: identical to MMIa_newImage
*******************************************************************************/
GleBitmap* GLEa_imageConvert(const CHAR *imageData, UINT16 imageSize, const CHAR *imageType, INT8* vSpace, INT8* hSpace, INT16* width, INT16* height, INT8 isPercent)
{
UINT16 index;
UINT16 shift;
GleBitmap *Image;
INT16 origWidth; /* Original width of image (from image data) */
INT16 origHeight; /* Original width of image (from image data) */
INT16 newWidth;
INT16 newHeight;
#ifdef TRACE_WAP_GLE
TRACE_EVENT("GLEa_imageConvert");
#endif
index = 0;
/* First byte should be 0 */
if (imageData[index] != 0)
{
TRACE_EVENT("** ERROR - Image not WBMP ***");
return NULL;
}
/* If fixed header is not 0, return */
if (imageData[++index] != 0)
{
TRACE_EVENT("*** ERROR - Fixed header not in place ***");
return NULL;
}
origWidth = 0;
shift = 1;
do
{
index++;
origWidth |= ((imageData[index] & 0x7F)*shift);
shift *= 0x80;
}
while (imageData[index] & 0x80);
origHeight = 0;
shift = 1;
do
{
index++;
origHeight |= ((imageData[index] & 0x7F)*shift);
shift *= 0x80;
}
while (imageData[index] & 0x80);
index++;
/* If a width and height are provided, and they're different from the actual
* width and height of the image, then the image will need to be scaled */
if (*width!=0 && *height!=0)
{
newWidth = *width;
newHeight = *height;
}
else
{
newWidth = origWidth;
newHeight = origHeight;
}
Image = WAP_ImageCopy(
(UBYTE *)&imageData[index],
origWidth,
origHeight,
newWidth,
newHeight);
*width = newWidth;
*height = newHeight;
return Image;
}
/*******************************************************************************
$Function: GLEa_imageDraw
$Description: Draws an image
$Returns: None.
$Arguments: viewId - The view id
image - pointer to the image to draw
invert - If the argument is TRUE, the image should be drawn
marked, otherwise not
imageBounds - The position of the upper left hand corner and the
allowed width and height.
*******************************************************************************/
VOID GLEa_imageDraw(UINT8 viewId, const GleBitmap *image, BOOL invert, GleRectangleType* imageBounds)
{
T_WAP_MMI_SEND_IMAGE_IND parameter;
SHORT byteWidth;
#ifdef TRACE_WAP_GLE
TRACE_EVENT("GLEa_imageDraw");
#endif
/* If our image is off the edge of the screen, don't send the event */
if (imageBounds->topLeft.x > view_width || imageBounds->topLeft.y > view_height
|| (imageBounds->topLeft.x+imageBounds->extent.x)<0 || (imageBounds->topLeft.y+imageBounds->extent.y) < 0 )
return;
/* Otherwise, send the event */
parameter.object_id = viewId;
byteWidth = imageBounds->extent.x/8;
if (imageBounds->extent.x % 8)
byteWidth++;
parameter.image_length = byteWidth * imageBounds->extent.y;
parameter.Image = (UBYTE *)image;
/* Skip out leading space of string */
parameter.invert = invert;
parameter.pX = imageBounds->topLeft.x;
parameter.pY = imageBounds->topLeft.y;
parameter.pWidth = imageBounds->extent.x;
parameter.pHeight = imageBounds->extent.y;
parameter.selected = invert;
W_WAP_MMI_SEND_IMAGE_IND(¶meter);
return;
}
/*******************************************************************************
$Function: GLEa_imageFree
$Description: Deallocates memory occupied by an image
$Returns: None.
$Arguments: image - pointer to the image to deallocate
*******************************************************************************/
VOID GLEa_imageFree(GleBitmap *image)
{
#ifdef TRACE_WAP_GLE
TRACE_EVENT("GLEa_imageFree");
#endif
wip_free((void *)image);
return;
}
/*******************************************************************************
$Function: GLEa_fieldSetDraw
$Description: Draw a field set in the view
$Returns: None.
$Arguments: viewId - the current view
title - the title of the fieldset
fieldSetBounds - the area of the content that the fieldset shall
enclose.
*******************************************************************************/
VOID GLEa_fieldSetDraw(UINT8 viewId, const GLE_STRING title, GleRectangleType *fieldSetBounds)
{
T_WAP_MMI_SEND_TABLE_IND parameter;
#ifdef TRACE_WAP_GLE
TRACE_EVENT("GLEa_fieldSetDraw");
#endif
/* If our fieldset element is off the edge of the screen, don't send the event */
if (fieldSetBounds->topLeft.x > view_width
|| fieldSetBounds->topLeft.y > (view_height-font_height)
|| (fieldSetBounds->topLeft.x+fieldSetBounds->extent.x)<0
|| (fieldSetBounds->topLeft.y+fieldSetBounds->extent.y)<0)
return;
parameter.object_id = viewId;
parameter.title_length = (UINT16) GLEa_strlen((GLE_STRING)title);
parameter.Title = (USHORT*)title;
parameter.pX = fieldSetBounds->topLeft.x;
parameter.pY = fieldSetBounds->topLeft.y;
parameter.pWidth = fieldSetBounds->extent.x;
parameter.pHeight = fieldSetBounds->extent.y;
parameter.cols_length = 0;
parameter.ColWidth = NULL;
parameter.rows_length = 0;
parameter.RowHeight = NULL;
parameter.noOfCells = 0;
W_WAP_MMI_SEND_TABLE_IND(¶meter);
return;
}
/*******************************************************************************
$Function: GLEa_inputSize
$Description: Sets the dimensions of an input field
$Returns: None.
$Arguments: size - how many characters should be visible
nChars - how many characters the input field should be able
to handle
maxWidth - maximum width possible (or -1 for no maximum)
width - the width in pixels
height - the height in pixels
ascent - the ascent in pixels. Should be the number of
pixels of the input field above the baseline
(<=height)
*******************************************************************************/
VOID GLEa_inputSize(INT8 size, INT8 nChars, INT16 maxWidth, INT16 *width, INT16 *height, UINT16 *ascent)
{
#ifdef TRACE_WAP_GLE
TRACE_EVENT("GLEa_inputSize");
TRACE_EVENT_P3("size %d nChars %d maxWidth %d",size,nChars,maxWidth);
#endif
/* Include '[' and ']' in width */
if (size>0)
{
*width += (INT16) (size+2)*font_max_width;
}
else
*width = view_width;
*height = (INT16) GLEa_textFontLineHeight (0, TRUE);
*ascent = (INT16) GLEa_textFontAscent (0, TRUE);
/* currently no border provided for */
/*if (*width>maxWidth && maxWidth!=-1)
*width = maxWidth;*/
#ifdef TRACE_WAP_GLE
TRACE_EVENT_P3("Width %d Height %d Ascent %d",*width,*height,*ascent);
#endif
return;
}
/*******************************************************************************
$Function: GLEa_inputDraw
$Description: Draws an input field
$Returns: None.
$Arguments: viewId - the id of the view
text - the input field text
invert - if TRUE, the text should be drawn marked, otherwise
not
size - how many characters should be visible
nChars - how many characters the input field should be able
to handle
isPassword - true if the input field is for a password
format - the format of the text
inputBounds - the position of the upper left hand corner and the
allowed width and height.
*******************************************************************************/
VOID GLEa_inputDraw(UINT8 viewId, const GLE_STRING text, BOOL invert, INT8 size, INT8 nChars, BOOL isPassword, const GLE_STRING format, GleRectangleType *inputBounds)
{
T_WAP_MMI_SEND_TEXT_IND parameter;
USHORT textIndex;
#ifdef TRACE_WAP_GLE
TRACE_EVENT("GLEa_inputDraw");
TRACE_EVENT_P5("size %d Px %d Py %d Width %d Height %d",size, inputBounds->topLeft.x, inputBounds->topLeft.y, inputBounds->extent.x, inputBounds->extent.y);
TRACE_EVENT_P3("size %d nChars %d isPassword %d", size, nChars, isPassword);
#endif
/* If our input element is off the edge of the screen, don't send the event */
if (inputBounds->topLeft.x > view_width || inputBounds->topLeft.y > (view_height-font_height)
|| (inputBounds->topLeft.x+inputBounds->extent.x)<0 || inputBounds->topLeft.y<0)
return;
parameter.object_id = viewId;
parameter.type = WAP_TEXT_INPUT;
parameter.text_length = (UINT16) GLEa_strlen((GLE_STRING)text)+2;
parameter.Text = (USHORT *)wip_malloc((parameter.text_length+1)*sizeof(USHORT));
/* If the text is a password, make it '*'s */
GLEa_strcpyGle2Gle((GLE_STRING)(parameter.Text+1), text);
if (isPassword)
{
for (textIndex=0; textIndex<parameter.text_length; textIndex++)
parameter.Text[textIndex] = (USHORT) '*';
}
parameter.Text[0] = (USHORT) '[';
parameter.Text[parameter.text_length-1] = (USHORT) ']';
parameter.Text[parameter.text_length] = (USHORT) '\0';
parameter.invert = invert;
parameter.pX = inputBounds->topLeft.x;
parameter.pY = inputBounds->topLeft.y;
parameter.pWidth = inputBounds->extent.x;
parameter.pHeight = inputBounds->extent.y;
parameter.formatstring_length = (UINT16) GLEa_strlen((GLE_STRING)format);
parameter.Formatstring = (USHORT*)format;
parameter.selected = invert;
parameter.is_link = FALSE;
W_WAP_MMI_SEND_TEXT_IND(¶meter);
wip_free((void *)parameter.Text);
return;
}
/*******************************************************************************
$Function: GLEa_inputDialog
$Description: Opens an editor to edit the text of the input field. The platform
mustn't change the text of the input; instead when the user is done
editing, the platform calls GLEc_inputDialogResponse with the edited
text as a parameter.
$Returns: None.
$Arguments: inputPtr - the attributes of the input field
*******************************************************************************/
VOID GLEa_inputDialog(GleInput* inputPtr)
{
T_WAP_MMI_INPUT_DIALOG_REQ parameter;
#ifdef TRACE_WAP_GLE
TRACE_EVENT("GLEa_inputDialog");
#endif
/* SPR#2393 - SH - Now set length of NULL strings to 0 */
parameter.object_id = inputPtr->viewId;
parameter.dialog_id = inputPtr->inputId;
parameter.is_password = inputPtr->isPassword;
parameter.empty_ok = inputPtr->emptyOK;
parameter.visible = inputPtr->size;
parameter.size = inputPtr->nChars;
parameter.dialog_pointer = (void*)inputPtr;
/* Title of input dialog */
parameter.Title = (USHORT*)inputPtr->title;
if (inputPtr->title==NULL)
parameter.title_length = 0;
else
parameter.title_length = (U32) GLEa_strlen((GLE_STRING)inputPtr->title);
/* Contents of input buffer */
parameter.Input = (USHORT*)inputPtr->text;
if (inputPtr->text==NULL)
parameter.input_length = 0;
else
parameter.input_length = (U32) GLEa_strlen((GLE_STRING)inputPtr->text);
/* Input format string */
parameter.Format = (USHORT*)inputPtr->format;
if (inputPtr->format==NULL)
parameter.format_length = 0;
else
parameter.format_length= (U32) GLEa_strlen((GLE_STRING)inputPtr->format);
W_WAP_MMI_INPUT_DIALOG_REQ(¶meter);
return;
}
#ifdef SHOW_KEYS_IN_CONTENT
/*******************************************************************************
$Function: GLEa_newKey
$Description: Lets the WAP application choose if the GLE shall take care of a key.
$Returns: TRUE if the key is to be handled by the WAP application, FALSE if
it is to be handled by the GLE
$Arguments: Same as MMIa_newKey
*******************************************************************************/
BOOL GLEa_newKey (UINT8 viewId, UINT8 keyId, const WCHAR *eventType, const WCHAR *label, BOOL isOptional)
{
T_WAP_MMI_NEW_KEY_IND parameter;
USHORT prevString[] = {'p', 'r', 'e', 'v', '\0'};
#ifdef TRACE_WAP_GLE
TRACE_EVENT("GLEa_newKey");
#endif
if (memcmp((void *)eventType, (void *)prevString, 4)!=0) /* If the key is not "prev" */
return FALSE; /* Tell GLE to draw keys inline */
parameter.object_id = viewId;
parameter.keyId = (UINT16) keyId;
parameter.key_type = WAP_KEY_PREV;
parameter.Label = (USHORT*)label;
if (label)
{
parameter.label_length = (U32)GLEa_strlen((GLE_STRING)label);
}
else
{
parameter.label_length = 0;
}
#ifdef TRACE_WAP_GLE
WAP_trace_ushort_string(parameter.Label, parameter.label_length);
#endif
W_WAP_MMI_NEW_KEY_IND(¶meter);
return TRUE; /* TRUE - key handled by WAP application, FALSE - let GLE show keys inline */
}
/*******************************************************************************
$Function: GLEa_keySize
$Description: Sets the dimensions of a key
$Returns: None.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -