📄 gui_ems.c
字号:
#else
#define EMS_DEFAULT_DCS_AVAILABLE_LENGTH 160
#define EMS_UCS2_DCS_AVAILABLE_LENGTH 70
#endif // defined(__MMI_MESSAGES_CONCAT_SMS__)
UI_EMS_input_box_theme *current_EMS_input_box_theme=NULL;
stFontAttribute UI_EMS_inputbox_small_font={0,0,0,SMALL_FONT,0,0};
stFontAttribute UI_EMS_inputbox_medium_font={0,0,0,MEDIUM_FONT,0,0};
#ifdef __MMI_DIALLING_FONT__
stFontAttribute UI_EMS_inputbox_large_font={0,0,0,MEDIUM_FONT,0,0};
#else
stFontAttribute UI_EMS_inputbox_large_font={0,0,0,LARGE_FONT,0,0};
#endif
//PMT VIKAS GUPTA START 20051129
U8 check_for_halant=0;
//PMT VIKAS GUPTA END 20051129
stFontAttribute UI_EMS_inputbox_current_font={0,0,0,MEDIUM_FONT,0,0};
color UI_EMS_inputbox_text_color={0,0,0,100};
#if(EMS_DISPLAY_SPECIAL_CHARACTERS)
/* Temporary data for debugging */
const U8 EMS_CR_display_character[]=
{
0x04, 0x00, 0xAF, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0C, 0x12, 0x00, 0x00, 0x00,
0x34, 0x12, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20,
0x34, 0x12, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20,
0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0x04, 0x20,
0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0xFF, 0xFF, 0xFF, 0xFF,
0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0xFF, 0xFF,
0xFF, 0xFF, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20,
0x04, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20,
0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20,
0x34, 0x12, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x20,
0x34, 0x12,
};
const U8 EMS_LF_display_character[]=
{
0x04, 0x00, 0xAF, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0C, 0x12, 0x00, 0x00, 0x00,
0x34, 0x12, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00,
0x34, 0x12, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00,
0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0xC0, 0x00,
0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00,
0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xFF, 0xFF,
0xFF, 0xFF, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00,
0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00,
0x34, 0x12, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00,
0x34, 0x12,
};
const U8 EMS_ESC_display_character[]=
{
0x04, 0x00, 0xAF, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0C, 0x12, 0x00, 0x00, 0x00,
0x34, 0x12, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F,
0x34, 0x12, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F,
0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0xFF, 0xFF, 0x42, 0x1F, 0x42, 0x1F,
0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0xFF, 0xFF,
0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F,
0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F,
0x34, 0x12, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F, 0x42, 0x1F,
0x34, 0x12,
};
#endif
#if(!UI_DISABLE_EMS_INPUT_BOX)
EMSObjData UI_EMS_normal_text_format_object_data;
EMSObject UI_EMS_normal_text_format_object;
#ifdef __MMI_MESSAGES_EMS__
extern void EMS_cancel_object_focus(void);
extern U16 EMS_predefined_animations[];
#endif
#define EMS_DATA_END_OFFSET(x) ((x))
/* Basic Latin,Latin 1,Latin Extended A, Latin Extended B */
/* Cyrillic */
/* Latin Extended Additional */
/* Combining Marks */
/* Basic Arabic */
/* Arabic Presentation Forms-A */
/* Arabic Presentation Forms-B */
#define UI_MULTI_LINE_INPUT_BOX_ALPHABETIC_CHARACTER(c) \
((((UI_character_type)(c)<=(UI_character_type)0x0240) || \
( ((UI_character_type)(c)>=(UI_character_type)0x0400) && ((UI_character_type)(c)<=(UI_character_type)0x04FF) ) || \
( ((UI_character_type)(c)>=(UI_character_type)0x1E00) && ((UI_character_type)(c)<=(UI_character_type)0x1EFF) ) || \
( ((UI_character_type)(c)>=(UI_character_type)0x0300) && ((UI_character_type)(c)<=(UI_character_type)0x036F) ) || \
( ((UI_character_type)(c)>=(UI_character_type)0x0621) && ((UI_character_type)(c)<=(UI_character_type)0x0653) ) || \
( ((UI_character_type)(c)>=(UI_character_type)0xFB50) && ((UI_character_type)(c)<=(UI_character_type)0xFDFF) ) || \
( ((UI_character_type)(c)>=(UI_character_type)0xFE70) && ((UI_character_type)(c)<=(UI_character_type)0xFEFF) ) )?(1):(0))
//Arabic Connectivity issue
#ifdef __MMI_LANG_ARABIC__
#define IS_ARABIC_CHARACTER(c) \
(( ( ((UI_character_type)(c)>=(UI_character_type)0x0621) && ((UI_character_type)(c)<=(UI_character_type)0x0653) ) || \
( ((UI_character_type)(c)>=(UI_character_type)0xFB50) && ((UI_character_type)(c)<=(UI_character_type)0xFDFF) ) || \
( ((UI_character_type)(c)>=(UI_character_type)0xFE70) && ((UI_character_type)(c)<=(UI_character_type)0xFEFF) ) )?(1):(0))
#endif
kal_uint16 BackwardCurrentPositionSkipCR(EMSData *data);
kal_uint16 ForwardCurrentPositionSkipCR(EMSData *data);
void MoveCurrentPosition(EMSData *data,EMSPosition *start,EMSPosition *end,kal_uint16 steps);
void EMS_map_position(EMSData *data,EMSPosition *src,EMSPosition *dst);
void MoveCursorToPosition(EMSData *data,EMSPosition *dst);
byte TestLastPosition(EMSData *data,EMSPosition *p);
byte TestFirstPosition(EMSData *data,EMSPosition *p);
byte BackwardCurrentPositionObject(EMSData *data,EMSPosition *dst);
byte ForwardCurrentPositionObject(EMSData *data,EMSPosition *dst);
void EMS_move_graphical_cursor(EMSData *data,s32 start_x,s32 cursor_x,s32 max_count);
void pixtel_UI_intialize_EMS(void)
{ UI_EMS_normal_text_format_object.Type=EMS_TYPE_TEXT_FORMAT;
UI_EMS_normal_text_format_object.next=NULL;
UI_EMS_normal_text_format_object.prev=NULL;
UI_EMS_normal_text_format_object.OffsetToText=0;
UI_EMS_normal_text_format_object.data=&UI_EMS_normal_text_format_object_data;
ResetTextFormat(&UI_EMS_normal_text_format_object.data->text_format);
#ifdef __MMI_MESSAGES_TEXT_FORMAT_ALIGN_LEFT__
UI_EMS_normal_text_format_object.data->text_format.Alignment=EMS_ALIGN_LEFT;
#else
UI_EMS_normal_text_format_object.data->text_format.Alignment=EMS_ALIGN_LANG_DEP;
#endif
}
void pixtel_UI_set_EMS_input_box_theme(UI_EMS_input_box *b,UI_EMS_input_box_theme *t)
{ b->normal_filler=t->normal_filler;
b->disabled_filler=t->disabled_filler;
b->selected_filler=t->selected_filler;
b->normal_text_color=t->normal_text_color;
b->selected_text_color=t->selected_text_color;
b->selection_color=t->selection_color;
b->cursor_color=t->cursor_color;
b->boundary_color=t->boundary_color;//Pixtel - Gurinder - 3/14/2004 - Editor With BG Image
b->flags|=t->flags;
}
void pixtel_UI_set_EMS_input_box_current_theme(UI_EMS_input_box *b)
{ b->normal_filler=current_EMS_input_box_theme->normal_filler;
b->disabled_filler=current_EMS_input_box_theme->disabled_filler;
b->selected_filler=current_EMS_input_box_theme->selected_filler;
b->normal_text_color=current_EMS_input_box_theme->normal_text_color;
b->selected_text_color=current_EMS_input_box_theme->selected_text_color;
b->selection_color=current_EMS_input_box_theme->selection_color;
b->cursor_color=current_EMS_input_box_theme->cursor_color;
b->boundary_color=current_EMS_input_box_theme->boundary_color;//Pixtel - Gurinder - 3/14/2004 - Editor With BG Image
b->flags|=current_EMS_input_box_theme->flags;
}
extern s16 MMI_current_input_ext_type;
void pixtel_UI_create_EMS_input_box(UI_EMS_input_box *b,s32 x,s32 y,s32 width,s32 height)
{ b->x=x;
b->y=y;
b->width=width;
b->height=height;
b->flags=0;
MMI_current_input_ext_type = 0;
pixtel_UI_set_EMS_input_box_current_theme(b);
b->overflow_callback=UI_dummy_function;
b->change_callback=UI_dummy_function;
pixtel_UI_create_vertical_scrollbar(&b->vbar,b->x+b->width-current_EMS_input_box_theme->vbar_width-1,b->y+1,current_EMS_input_box_theme->vbar_width,b->height-2);
b->data=NULL;
b->start_position.Object=NULL;
b->start_position.OffsetToText=0;
b->end_position.Object=NULL;
b->end_position.OffsetToText=0;
b->display_y=0;
ResetTextFormat(&b->text_format);
#if defined(__MMI_HINDI_ALG__)
reset_use_multitap();
#endif
b->text_format.Alignment=UI_EMS_normal_text_format_object.data->text_format.Alignment;
b->saved_cursor_ax=-1;
b->underline_color=pixtel_UI_color(0,0,128);
b->strikethrough_color=pixtel_UI_color(192,0,0);
b->paragraph_color=pixtel_UI_color(0,128,0);
}
#if(EMS_USE_DCS)
void pixtel_UI_EMS_change_DCS(UI_EMS_input_box *b)
{ if(b->UCS2_count>0)
{ EMSSetDCS(b->data,SMSAL_UCS2_DCS);
#if defined(__MMI_MESSAGES_CONCAT_SMS__)
b->available_length=b->data->Reminder.maxUsableLenPerSeg*mmi_msg_get_seg_num()>>1;
#else
b->available_length=EMS_UCS2_DCS_AVAILABLE_LENGTH;
#endif
}
else
{ EMSSetDCS(b->data,SMSAL_DEFAULT_DCS);
#if defined(__MMI_MESSAGES_CONCAT_SMS__)
b->available_length=b->data->Reminder.maxUsableLenPerSeg*mmi_msg_get_seg_num();
#else
b->available_length=EMS_DEFAULT_DCS_AVAILABLE_LENGTH;
#endif
}
}
#endif
void pixtel_UI_set_EMS_input_box_data(UI_EMS_input_box *b,EMSData *d)
{ EMSObject *text_format_object;
byte done=0;
EMSPosition current_position;
b->data=d;
if(d==NULL) return;
// ResetCurrentPosition(b->data);
b->UCS2_count=0;
b->object_count=0;
b->GSM_ext_count=0;
#if(EMS_USE_DCS)
if((b->data->textLength>0)||(b->data->listHead!=NULL))
{ byte r;
EMSPosition p=b->data->CurrentPosition;
EMSObject *current_object;
UI_character_type c;
p.OffsetToText=0;
p.Object=b->data->listHead;
while(!done)
{ r=pixtel_UI_EMS_input_box_get_next_object(d,&p,&c,¤t_object);
switch(r)
{ case 0: done=1;
break;
case 1: if(UI_TEST_UCS2_CHARACTER(c)) b->UCS2_count++;
if(UI_TEST_GSM_EXTENDED(c)) b->GSM_ext_count++;
break;
case 2: b->object_count++;
break;
}
}
}
pixtel_UI_EMS_change_DCS(b);
#endif
current_position.OffsetToText=0;
current_position.Object=NULL;
text_format_object=GetTextFormatObjectAtPosition(b->data,¤t_position);
if(text_format_object!=NULL) b->text_format=text_format_object->data->text_format;
b->saved_cursor_ax=-1;
}
s32 EMS_get_remaining_length(EMSData *data)
{ if(data->dcs==SMSAL_DEFAULT_DCS)
#if defined(__MMI_MESSAGES_CONCAT_SMS__)
return(data->Reminder.totalRemainingOctet-(data->Reminder.maxUsableLenPerSeg*mmi_msg_get_seg_num()-data->Reminder.maxUsableLenPerSeg*mmi_msg_get_seg_num()));
#else
return(data->Reminder.totalRemainingOctet-(EMS_DEFAULT_DCS_ALLOCATED_LENGTH-EMS_DEFAULT_DCS_AVAILABLE_LENGTH));
#endif
else
#if defined(__MMI_MESSAGES_CONCAT_SMS__)
return(data->Reminder.totalRemainingOctet-(data->Reminder.maxUsableLenPerSeg*mmi_msg_get_seg_num()-data->Reminder.maxUsableLenPerSeg*mmi_msg_get_seg_num()));
#else
return(data->Reminder.totalRemainingOctet-((EMS_UCS2_DCS_ALLOCATED_LENGTH<<1)-(EMS_UCS2_DCS_AVAILABLE_LENGTH<<1)));
#endif
}
#ifdef __MMI_MESSAGES_EMS__
void pixtel_UI_EMS_input_box_set_text_format_object(UI_EMS_input_box *b,EMSTextFormat *f)
{ if(f!=NULL) b->text_format=*f;
}
#endif
void pixtel_UI_EMS_input_box_locate_cursor(UI_EMS_input_box *b)
{ s32 box_height=b->height-4;
b->flags|=UI_EMS_INPUT_BOX_DISABLE_DRAW;
pixtel_UI_show_EMS_input_box(b);
b->flags&=~UI_EMS_INPUT_BOX_DISABLE_DRAW;
if(b->flags & UI_EMS_INPUT_BOX_DISPLAY_HEADER)
{ if((b->cursor_ay+b->header_height) < (-b->display_y))
{ b->display_y=-b->cursor_ay-b->header_height;
}
else if((b->cursor_ay+b->header_height+b->cursor_line_height) > ((-b->display_y)+(box_height)))
{ b->display_y-=(b->cursor_ay+b->cursor_line_height)-((-b->display_y)+(box_height-b->header_height));
}
if(b->display_y>0) b->display_y=0;
}
else
{ if(b->cursor_ay < (-b->display_y))
{ b->display_y=-b->cursor_ay;
}
else if((b->cursor_ay+b->cursor_line_height) > ((-b->display_y)+box_height))
{ b->display_y-=(b->cursor_ay+b->cursor_line_height)-((-b->display_y)+box_height);
}
if((b->display_y+b->display_height)<box_height) b->display_y=(box_height)-b->display_height;
if(b->display_y>0) b->display_y=0;
}
}
void pixtel_UI_EMS_input_box_reset_cursor_position(UI_EMS_input_box *b)
{ if(b->data!=NULL)
{ ResetCurrentPosition(b->data);
pixtel_UI_EMS_input_box_locate_cursor(b);
}
}
byte pixtel_UI_EMS_input_box_get_previous_text_alignment(UI_EMS_input_box *b,EMSPosition *p)
{ byte done=0;
UI_character_type c;
EMSObject *o;
byte r;
EMSPosition current_position=*p;
byte alignment=UI_EMS_normal_text_format_object.data->text_format.Alignment;
while(!done)
{ r=pixtel_UI_EMS_input_box_get_previous_object(b->data,¤t_position,&c,&o);
switch(r)
{ case 0: done=1;
break;
case 1: if(c==EMS_INPUTBOX_PARAGRAPH_BREAK_CHARACTER) done=1;
break;
case 2: if(o->Type==EMS_TYPE_TEXT_FORMAT)
{ alignment=o->data->text_format.Alignment;
}
break;
}
}
return(alignment);
}
/* Sets the alignment of the whole paragraph to the value specified.
Starts from the given cursor position.
The cursor position given must be at the first position on the paragraph */
void pixtel_UI_EMS_input_box_set_paragraph_text_alignment(UI_EMS_input_box *b,EMSPosition *p,byte alignment)
{ byte done=0;
UI_character_type c;
EMSObject *o;
byte r;
EMSPosition current_position=*p;
while(!done)
{ r=pixtel_UI_EMS_input_box_get_next_object(b->data,¤t_position,&c,&o);
switch(r)
{ case 0: done=1;
break;
case 1: if(c==EMS_INPUTBOX_PARAGRAPH_BREAK_CHARACTER) done=1;
break;
case 2: if(o->Type==EMS_TYPE_TEXT_FORMAT) o->data->text_format.Alignment=(EMSALIGNMENT)alignment;
break;
}
}
}
/* Checks if the cursor is at the beginning of a paragraph */
byte pixtel_UI_EMS_input_box_test_paragraph_start(UI_EMS_input_box *b,EMSPosition *p)
{ byte paragraph_flag=0;
UI_character_type c;
EMSObject *o;
byte r;
EMSPosition current_position=*p;
if(TestFirstPosition(b->data,¤t_position)) paragraph_flag=1;
else
{ if(BackwardCurrentPosition(b->data,1)==1)
{ current_position=b->data->CurrentPosition;
r=pixtel_UI_EMS_input_box_get_next_object(b->data,¤t_position,&c,&o);
ForwardCurrentPosition(b->data,1);
if((r==1) && (c==EMS_INPUTBOX_PARAGRAPH_BREAK_CHARACTER)) paragraph_flag=1;
}
}
return(paragraph_flag);
}
void pixtel_UI_EMS_input_box_set_text_format_cursor_position(UI_EMS_input_box *b)
{ byte done=0;
EMSPosition current_position;
EMSObject *current_text_format_object;
UI_character_type c;
EMSObject *o;
byte r;
b->text_format=UI_EMS_normal_text_format_object.data->text_format;
if(b->data==NULL) return;
current_position=b->data->CurrentPosition;
current_text_format_object=b->data->CurrentTextFormatObj;
if((current_text_format_object!=NULL)
&& (current_position.OffsetToText>=current_text_format_object->OffsetToText)
&& (current_position.OffsetToText<=(current_text_format_object->OffsetToText+current_text_format_object->data->text_format.textLength)))
b->text_format=current_text_format_object->data->text_format;
/* At the beginning of a paragraph ? Then locate the text alignment to be used */
if(pixtel_UI_EMS_input_box_test_paragraph_start(b,¤t_position))
{ while(!done)
{ r=pixtel_UI_EMS_input_box_get_next_object(b->data,¤t_position,&c,&o);
switch(r)
{ case 0:
b->text_format.Alignment = UI_EMS_normal_text_format_object.data->text_format.Alignment;
done=1;
break;
case 1: if(c==EMS_INPUTBOX_PARAGRAPH_BREAK_CHARACTER) done=1;
break;
case 2: if(o->Type==EMS_TYPE_TEXT_FORMAT)
{ b->text_format.Alignment=o->data->text_format.Alignment;
done=1;
}
break;
}
}
}
else
{
while(!done)
{ r=pixtel_UI_EMS_input_box_get_previous_object(b->data,¤t_position,&c,&o);
switch(r)
{ case 0: done=1;
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -