📄 atbwapaui.c
字号:
/*******************************************************************************
$Function: ATB_wap_info_dialog_closed
$Description: Provides the answer of an info dialog.
$Returns: WAP_OK if successful, WAP_FAIL if otherwise
$Arguments: parameter - Dialog confirmation information
*******************************************************************************/
T_WAP_RES ATB_wap_info_dialog_closed(T_MMI_WAP_INFO_DIALOG_CNF *parameter)
{
#ifdef TRACE_ATBWAPAUI
TRACE_FUNCTION("ATB_wap_info_dialog_closed");
#endif
M_MMI_WAP_INFO_DIALOG_CNF(parameter);
return WAP_OK;
}
/*******************************************************************************
$Function: ATB_wap_options_menu_select
$Description: The AUI will notify to the WAP.ATB the id of the selected item
$Returns: WAP_OK if successful, WAP_FAIL if otherwise
$Arguments: View - the current view
*******************************************************************************/
T_WAP_RES ATB_wap_options_menu_select(T_WAP_VIEW *View)
{
#ifdef TRACE_ATBWAPAUI
TRACE_FUNCTION("ATB_wap_options_menu_select");
#endif
ATB_wap_card_key_event(View, WAP_KEY_SELECT);
return WAP_OK;
}
/*******************************************************************************
$Function: ATB_wap_buffer_add_element
$Description: Add a new element to the element chain
$Returns: Pointer to the element
$Arguments: object_id - the id of the session
type - the type of element (text, fieldset, image)
*******************************************************************************/
T_WAP_ELEMENT * ATB_wap_buffer_add_element(UBYTE object_id, WAP_ELEMENT_TYPE type)
{
T_WAP_VIEW *View;
T_WAP_ELEMENT *Element = (T_WAP_ELEMENT *)AUI_wap_memory_alloc(sizeof(T_WAP_ELEMENT));// Create the element
T_WAP_ELEMENT *ElementIndex;
static USHORT elementCount = 0;
#ifdef TRACE_ATBWAPAUI
TRACE_FUNCTION("ATB_wap_buffer_add_element");
#endif
if (!(View = ATB_wap_get_view(object_id)))
return;
if (View->NewElementHeader == NULL) // If it's the first item in the chain...
{
View->NewElementHeader = Element; // ...element goes at the start
elementCount = 0;
}
else
{
ElementIndex = View->NewElementHeader; // Otherwise, find the end of the chain
while(ElementIndex->NextElement !=NULL)
ElementIndex = ElementIndex->NextElement;
ElementIndex->NextElement = Element; // ...and put it there
}
Element->type = type;
Element->NextElement = NULL; // It will be the last item in the chain
elementCount++;
#ifdef TRACE_ATBWAPAUI
TRACE_EVENT_P1( "Element no.: %d", elementCount);
#endif
return Element;
}
/*******************************************************************************
$Function: ATB_wap_buffer_display
$Description: Displays the card from the buffer
$Returns:
$Arguments: View - the current view
*******************************************************************************/
void ATB_wap_buffer_display(T_WAP_VIEW *View)
{
T_WAP_ELEMENT *Element = View->ElementHeader;
USHORT elementCount = 0; // No. of element
SHORT titleX; // Position of title to centre it
SHORT titleWidth; // Width of the title in pixels
double doubleTemp;
SHORT scrollBarSize; // Size of scroll bar in pixels
SHORT scrollBarPos; // Y position of top of scroll bar
SHORT lineX; // First X position of line
SHORT lineY; // First Y position of line
char *cardTitle; // Title of the card
char *temp; // Temporary storage for text strings
UBYTE scrollIndex; // For drawing scrollbar
#ifdef TRACE_ATBWAPAUI
TRACE_FUNCTION("ATB_wap_buffer_display");
#endif
TRACE_EVENT("ATB_wap_buffer_display_zhaowm");
// Display the title of the card, centred, over the line
temp = (char *)AUI_wap_memory_alloc(((CARD_TITLE_MAX_LEN)*2+3)*sizeof(char)); // Allocate memory for card title
//temp = (char *)AUI_wap_memory_alloc((CARD_TITLE_MAX_LEN+1)*sizeof(char)); // Allocate memory for card title
/* SPR#1547 - SH - Replaced 'status' with 'browser_status' */
if (ATB_wap_status_get(View, ATB_WAP_DOWNLOADING)) // If the card is loading...
{
if ( *AUI_wap_string(WAP_STRING_DOWNLOADING) == 0x80) //zhaowm 2003.1.7
wstrcpy(temp, AUI_wap_string(WAP_STRING_DOWNLOADING));
else
strcpy(temp, AUI_wap_string(WAP_STRING_DOWNLOADING)); // ...display "Loading"...
}
else if (ATB_wap_status_get(View, ATB_WAP_CARD_READING)) // If the card is loading...
{
if ( *AUI_wap_string(WAP_STRING_UPDATING) == 0x80) //zhaowm 2003.1.7
//wstrcpy(temp, AUI_wap_string(WAP_STRING_UPDATING));
wstrcpy(temp, AUI_wap_string(WAP_STRING_DOWNLOADING));
else
strcpy(temp, AUI_wap_string(WAP_STRING_DOWNLOADING)); // ...display "Loading"...
}
else
{
if (View->Title[0] == 0x80) //zhaowm 2003.1.7
//wstrncpy(temp, View->Title, wstrlen(View->Title));
truncateString(temp,View->Title,14,1,".");
else
strcpy(temp,View->Title); // Otherwise, title is the card title
}
//titleWidth = ATB_textWidth(temp, strlen(temp));
titleWidth = ATB_textWidth(temp, wstrBitlen(temp)); // Width of the title
titleX = (WAP_TOTAL_WIDTH - titleWidth)/2; // Position of title to centre it
dspl_TextOut(titleX,0,DSPL_TXTATTR_SIGNED_COORDS, temp); // Draw title text
AUI_wap_memory_free((UBYTE *)temp, ((CARD_TITLE_MAX_LEN)*2+3)*sizeof(char)); // Free card title memory
//AUI_wap_memory_free((UBYTE *)temp, (CARD_TITLE_MAX_LEN+1)*sizeof(char)); // Free card title memory
// Horizontal scroll bar and top line
dspl_DrawLine(titleX-2, WAP_TOP_BORDER/2, 0, WAP_TOP_BORDER/2); // Line to left of title
dspl_DrawLine(WAP_TOTAL_WIDTH-titleX+1, WAP_TOP_BORDER/2,
WAP_TOTAL_WIDTH-WAP_VSCROLLBAR_WIDTH, WAP_TOP_BORDER/2); // Line to right of title
if (View->cardWidth>WAP_SCREEN_WIDTH)
{
doubleTemp = WAP_HSCROLLBAR_WIDTH*(double)WAP_SCREEN_WIDTH/(double)View->cardWidth;
scrollBarSize = (SHORT)(doubleTemp+0.5); // Round to nearest int
if (scrollBarSize>WAP_HSCROLLBAR_WIDTH)
scrollBarSize = WAP_HSCROLLBAR_WIDTH;
doubleTemp = WAP_HSCROLLBAR_WIDTH*(double)View->cardXPosition/(double)View->cardWidth;
scrollBarPos = (SHORT)(doubleTemp+0.5); // Round to nearest int
for (scrollIndex=0; scrollIndex<scrollBarSize; scrollIndex++)
{
dspl_DrawLine(scrollBarPos+scrollIndex, 0,
scrollBarPos+scrollIndex, WAP_TOP_BORDER/2);
}
if (WAP_HSCROLLBAR_WIDTH<(titleX-1))
dspl_DrawLine( WAP_HSCROLLBAR_WIDTH, 0, WAP_HSCROLLBAR_WIDTH, WAP_TOP_BORDER/2);
}
// Display the elements of the card one by one
while (Element!=NULL)
{
switch(Element->type)
{
case WAP_TEXT: // Text element
ATB_wap_buffer_text_draw((T_WAP_MMI_SEND_TEXT_IND *)Element->data);
break;
case WAP_TABLE: // Table/fieldset element
ATB_wap_buffer_table_draw((T_WAP_MMI_SEND_TABLE_IND *)Element->data);
break;
case WAP_IMAGE: // Image element
if (View->Status & WAP_STATUS_SCALEIMAGES) // Image is to be scaled
ATB_wap_buffer_image_scale((T_WAP_MMI_SEND_IMAGE_IND *)Element->data);
else // Display image normally
ATB_wap_buffer_image_display((T_WAP_MMI_SEND_IMAGE_IND *)Element->data);
break;
}
elementCount++;
Element = Element->NextElement; // Find the next element
}
// Vertical scroll bar and right frame
scrollBarSize = WAP_SCREEN_HEIGHT*WAP_SCREEN_HEIGHT/View->cardHeight;
if (scrollBarSize>WAP_SCREEN_HEIGHT)
scrollBarSize = WAP_SCREEN_HEIGHT;
scrollBarPos = WAP_SCREEN_HEIGHT*View->cardYPosition/View->cardHeight;
dspl_DrawLine(WAP_TOTAL_WIDTH-WAP_VSCROLLBAR_WIDTH, WAP_TOP_BORDER/2,
WAP_TOTAL_WIDTH-WAP_VSCROLLBAR_WIDTH, WAP_SCREEN_BOTTOM); // Line to top of bar
for (scrollIndex=1; scrollIndex<WAP_VSCROLLBAR_WIDTH; scrollIndex++)
{
dspl_DrawLine(WAP_TOTAL_WIDTH-WAP_VSCROLLBAR_WIDTH+scrollIndex, scrollBarPos+WAP_TOP_BORDER,
WAP_TOTAL_WIDTH-WAP_VSCROLLBAR_WIDTH+scrollIndex, scrollBarPos+WAP_TOP_BORDER+scrollBarSize);
}
#ifdef TRACE_ATBWAPAUI
TRACE_EVENT_P1( "Elements displayed: %d", elementCount);
#endif
return;
}
/*******************************************************************************
$Function: ATB_wap_buffer_text_draw
$Description: Draws text
$Returns:
$Arguments: parameter - the send text event
*******************************************************************************/
void ATB_wap_buffer_text_draw(T_WAP_MMI_SEND_TEXT_IND *parameter)
{
char *temp;
//char *temp1;
SHORT elementX;
SHORT elementY;
USHORT textWidth;
UINT32 oldColor;
//char buf[30]; //zhaowm
//USHORT k;
temp = (char *)AUI_wap_memory_alloc(((parameter->text_length)*2+3)*sizeof(char)); //zhaowm 2002.12.03 add two // Allocate memory for string
//temp1 = (char *)AUI_wap_memory_alloc(((parameter->text_length)*2+3)*sizeof(char));
ATB_ushort2char(temp, parameter->Text, (USHORT)parameter->text_length); // Convert text to CHAR
//ATB_ushort2char(temp1, parameter->Text, (USHORT)parameter->text_length); // Convert text to CHAR
textWidth = parameter->pWidth;
if ((textWidth + parameter->pX)>WAP_SCREEN_WIDTH) // if text goes off the screen,
textWidth = WAP_SCREEN_WIDTH-parameter->pX; // cut it down to size
elementX = (USHORT)parameter->pX+WAP_LEFT_BORDER; // Absolute position of text
elementY = (USHORT)parameter->pY+WAP_TOP_BORDER; // on screen
switch(parameter->type)
{
case WAP_TEXT_OPTION: // An options menu item - draw checkbox
dspl_DrawRect(elementX,
elementY+WAP_CHECKBOX_TOP, \
elementX+WAP_CHECKBOX_WIDTH-1, \
elementY+WAP_CHECKBOX_TOP+WAP_CHECKBOX_HEIGHT-1);
if (parameter->selected) // Option should be checked
{
dspl_DrawRect(elementX+WAP_CHECKBOX_INDENT, \
elementY+WAP_CHECKBOX_TOP+WAP_CHECKBOX_INDENT, \
elementX+WAP_CHECKBOX_WIDTH-1-WAP_CHECKBOX_INDENT, \
elementY+WAP_CHECKBOX_TOP+WAP_CHECKBOX_HEIGHT-1-WAP_CHECKBOX_INDENT);
}
elementX += (WAP_CHECKBOX_WIDTH+WAP_CHECKBOX_RIGHT); // Shift to right to make space
textWidth -= (WAP_CHECKBOX_WIDTH+WAP_CHECKBOX_RIGHT); // for checkbox
break;
case WAP_TEXT_OPTIONGROUP:
// Option group titles are currently not distinguished from normal text
break;
}
//ATB_crop_text((char*)temp, strlen(temp), textWidth); // Crop the text to the correct width
// truncateString((char*)temp,(char *)temp1,(unsigned int)textWidth,1,"."); //zhaowm temp
//zhaowm temp trace
/*
for (k=0;k< (parameter->text_length)*2+3;k++)
{
sprintf(buf," zhao=%u,%x",k, temp[k]);//
TRACE_EVENT(buf);//
}//temp
*/
if(parameter->is_link)
{
oldColor = dspl_SetFrgColor(0x0000ff);
}
if (!parameter->invert) // Text is inverted...
dspl_TextOut(elementX,elementY,DSPL_TXTATTR_SIGNED_COORDS,(char*)temp);
else // ...or isn't inverted
dspl_TextOut(elementX,elementY,DSPL_TXTATTR_INVERS | DSPL_TXTATTR_SIGNED_COORDS,(char*)temp);
if(parameter->is_link)
{
dspl_DrawLine(elementX , elementY + parameter->pHeight, elementX + parameter->pWidth, elementY + parameter->pHeight);
dspl_SetFrgColor(oldColor );
}
AUI_wap_memory_free((UBYTE *)temp, ((parameter->text_length)*2+3)*sizeof(char)); //zhaowm // Free the allocated memory
//AUI_wap_memory_free((UBYTE *)temp1, ((parameter->text_length)*2+3)*sizeof(char));
return;
}
/*******************************************************************************
$Function: ATB_wap_buffer_table_draw
$Description: Draws a table, or a fieldset
$Returns:
$Arguments: parameter - the send table event
*******************************************************************************/
void ATB_wap_buffer_table_draw(T_WAP_MMI_SEND_TABLE_IND *parameter)
{
SHORT elementX = parameter->pX+WAP_LEFT_BORDER; // Left edge position of table/fieldset
SHORT elementY = parameter->pY+WAP_TOP_BORDER; // Top edge position of table/fieldset
SHORT top = elementY+WAP_CHAR_HEIGHT/2; // Top of fieldset
SHORT bottom = elementY+parameter->pHeight-1; // Bottom of table/fieldset
SHORT right = elementX+parameter->pWidth-1; // Right side of table/fieldset
SHORT lineX; // X position of column line
SHORT lineY; // Y position of row line
char *temp; // Temp storage for title
USHORT titleWidth; // Width of the title in pixels
USHORT index; // Index for columns and rows
char *temp1; //zhaowm 2003.1.8
#ifdef TRACE_ATBWAPAUI
TRACE_FUNCTION("ATB_wap_buffer_table_draw");
TRACE_EVENT_P4( "Fieldset/table pX, pY, pWidth, pHeight: %d, %d, %d, %d",
parameter->pX, parameter->pY, parameter->pWidth, parameter->pHeight);
#endif
TRACE_EVENT("ATB_wap_buffer_table_draw_zhao");
// Title
temp = (char *)AUI_wap_memory_alloc(((parameter->title_length)*2+3)*sizeof(char));//zhaowm 2002.1203 add two// Allocate memory for text
temp1 = (char *)AUI_wap_memory_alloc(((parameter->title_length)*2+3)*sizeof(char));//zhaowm 2002.1203 add two// Allocate memory for text
//ATB_ushort2char(temp, parameter->Title, parameter->title_length); // Convert to char
ATB_ushort2char(temp1, parameter->Title, parameter->title_length); // Convert to char
// Crop title if it overshoots screen
if ((parameter->pX+gle_fieldset_spaceLeft+ATB_textWidth(temp1, wstrBitlen(temp1))) > WAP_SCREEN_WIDTH)
//ATB_crop_text(temp, strlen(temp), WAP_SCREEN_WIDTH-parameter->pX-gle_fieldset_spaceLeft);
truncateString(temp,(char *)temp1,(WAP_SCREEN_WIDTH-parameter->pX-gle_fieldset_spaceLeft)/(WAP_CHAR_WIDTH*2),1,".");
// Crop title if it overshoots edge of fieldset
if ((gle_fieldset_spaceLeft+ATB_textWidth(temp1, wstrBitlen(temp1))+gle_fieldset_spaceRight) > parameter->pWidth)
//ATB_crop_text(temp, strlen(temp), parameter->pWidth-gle_fieldset_spaceLeft-gle_fieldset_spaceRight);
truncateString(temp,(char *)temp1,(parameter->pWidth-gle_fieldset_spaceLeft-gle_fieldset_spaceRight)/(WAP_CHAR_WIDTH*2),1,".");
titleWidth = ATB_textWidth(temp,wstrBitlen(temp)); // Width of the title of the fieldset
if (parameter->pY >= 0 && parameter->pY < WAP_TEXT_LOWEST) // Provided title is on screen
{
dspl_TextOut(elementX+gle_fieldset_spaceLeft, elementY, DSPL_TXTATTR_SIGNED_COORDS, temp);
}
AUI_wap_memory_free((UBYTE *)temp, ((parameter->title_length)*2+3)*sizeof(char)); // Free allocated memory
AUI_wap_memory_free((UBYTE *)temp1, ((parameter->title_length)*2+3)*sizeof(char)); // Free allocated memory
// Horizontal lines
lineY = elementY+gle_cell_vBefore;
ATB_wap_buffer_line_draw(elementX, bottom, right, bottom); // Bottom line of table
if (parameter->rows_length > 0)
ATB_wap_buffer_line_draw(elementX, lineY, right, lineY); // Line under title
else
{
ATB_wap_buffer_line_draw(elementX+gle_fieldset_spaceLeft-2, top, elementX, top); // Line to left of title
ATB_wap_buffer_line_draw(elementX+gle_fieldset_spaceLeft+titleWidth+2, top, right, top);// right
}
if (parameter->rows_length > 1) // Row lines
{
for (index=0; index<(parameter->rows_length-1); index++)
{
lineY += parameter->RowHeight[index]+gle_cell_spaceToBorder;
ATB_wap_buffer_line_draw(elementX, lineY, right, lineY);
lineY += gle_cell_borderExtent+gle_cell_spaceToBorder;
}
}
// Vertical lines
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -