⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gui_ems.c

📁 The font library converting tool MCT mainly introduces the process of the font formats to give us a
💻 C
📖 第 1 页 / 共 5 页
字号:
#else

/*	Deletes one object/character before cursor position and updates UCS2 and Object counters	*/

byte pixtel_UI_EMS_cancel_current_position(UI_EMS_input_box *b)
{	if(BackwardCurrentPosition(b->data,1)==1)
	{	EMSPosition p=b->data->CurrentPosition;
		EMSObject*	current_object;
		UI_character_type c;
		byte r;
		r=pixtel_UI_EMS_input_box_get_next_object(b->data,&p,&c,&current_object);
		ForwardCurrentPosition(b->data,1);
		switch(r)
		{	case 0:	break;
			case 1:	if(UI_TEST_UCS2_CHARACTER(c))
					{	if(b->UCS2_count>0)
						{	b->UCS2_count--;
							if(b->UCS2_count==0) pixtel_UI_EMS_change_DCS(b);
						}
					}
					break;
			case 2:	if(b->object_count>0)
					{	b->object_count--;
						if(b->object_count==0) pixtel_UI_EMS_change_DCS(b);
					}
					break;
		}
		CancelCurrentPosition(b->data,1);
		return(1);
	}
	return(0);
}

#endif

#define	EMSSWAP(t,a,b)	\
{	t temp=a;			\
	a=b;				\
	b=temp;				\
}

/*	Temporary function: Will be removed later										*/
/*	For testing purpose only: Using this will cause an assertion in the EMS library	*/

void ArrangeEMSObjects(EMSData *data)
{
	EMSObject	*current=data->listHead;
	EMSObject	*start;
	byte		done;

	while(current!=NULL)
	{	done=0;
		start=current;
		while(!done)
		{	current=current->next;
			if(current==NULL)
			{	done=1;
				break;
			}
			if(current->OffsetToText!=start->OffsetToText)
			{	done=1;
				break;
			}
			if(current->Type==EMS_TYPE_TEXT_FORMAT)
			{
				EMSSWAP(EMSObject,*current,*start);
				EMSSWAP(kal_uint16,current->OffsetToText,start->OffsetToText);
				EMSSWAP(struct _EMSObject *,current->prev,start->prev);
				EMSSWAP(struct _EMSObject *,current->next,start->next);
				break;
			}
		}
	}
}

EMSTATUS pixtel_UI_EMS_input_box_add_string(UI_EMS_input_box *b,byte *s,EMSTextFormat *text_format)
{	word	num_char=1;
#if(EMS_BYTE_ORDER_BIG_ENDIAN)
	UI_character_type	c=((UI_character_type)s[1])|(((UI_character_type)s[0])<<8);
#else
	UI_character_type	c=((UI_character_type)s[0])|(((UI_character_type)s[1])<<8);
#endif
	EMSTATUS r;
	if(text_format==NULL)
	{	r=AddString(b->data,s,num_char,NULL);
	}
	else if(b->data->CurrentTextFormatObj==NULL)
	{	if(pixtel_UI_EMS_input_box_equal_text_format(&b->text_format,&UI_EMS_normal_text_format_object.data->text_format))
		{	r=AddString(b->data,s,num_char,NULL);
		}
		else
		{	r=AddString(b->data,s,num_char,text_format);
		}
	}
	else
	{	r=AddString(b->data,s,num_char,text_format);
	}
	if(r==EMS_OK)
	{	if(UI_TEST_UCS2_CHARACTER(c))
		{	if(b->UCS2_count==0)
			{	b->UCS2_count++;
				pixtel_UI_EMS_change_DCS(b);
			}
			else b->UCS2_count++;
		}
		else if(UI_TEST_GSM_EXTENDED(c))
		{	b->GSM_ext_count++;
		}
		if(b->UCS2_count>0)
		{	s32 remaining_length=(EMS_get_remaining_length(b->data)>>1);
			if(remaining_length<0)
			{	pixtel_UI_EMS_cancel_current_position(b);
				r=EMS_NO_SPACE;
			}
		}
#if(EMS_USE_GSM_EXTENDED)
		else if(b->GSM_ext_count>0)
		{	s32 remaining_length=EMS_get_remaining_length(b->data);
//			s32 available_length=b->available_length;
			if(remaining_length<0)
			{	pixtel_UI_EMS_cancel_current_position(b);
				r=EMS_NO_SPACE;
			}
		}
#endif
	}
	else
	{
	   /*MTK Terry for EMS_NO_MEMORY or other error cause*/
	   pixtel_UI_EMS_change_DCS(b);
	}

	/*	Temporary	*/
	//ArrangeEMSObjects(b->data);

	return(r);
}

#else

EMSTATUS pixtel_UI_EMS_input_box_add_string(UI_EMS_input_box *b,byte *s,EMSTextFormat *text_format)
{	word num_char=1;

	if(text_format==NULL)
	{	return(AddString(b->data,s,num_char,NULL));
	}
	else if(b->data->CurrentTextFormatObj==NULL)
	{	if(pixtel_UI_EMS_input_box_equal_text_format(&b->text_format,&UI_EMS_normal_text_format_object.data.text_format))
		{	return(AddString(b->data,s,num_char,NULL));
		}
		else
		{	return(AddString(b->data,s,num_char,text_format));
		}
	}
	else
	{	return(AddString(b->data,s,num_char,text_format));
	}
}

#endif

EMSTATUS pixtel_UI_EMS_inputbox_add_object(UI_EMS_input_box *b,byte type,EMSObjData *objData,byte predefined_object_number)
{
	EMSTATUS r;

	r=AddObject(b->data,type,objData,(byte)predefined_object_number);
#ifdef __MMI_HINDI_ALG__
	//START TARUN 20050103
	//if ((b->data->CurrentPosition.OffsetToText >= 4)  && (b->data->textBuffer[b->data->CurrentPosition.OffsetToText-1] == 0x09)
	//	&& (b->data->textBuffer[b->data->CurrentPosition.OffsetToText-2] == 0x4d))
	//{
	//	b->data->textBuffer[b->data->CurrentPosition.OffsetToText]=0x20;
	//	b->data->textBuffer[b->data->CurrentPosition.OffsetToText+1]=0x00;
	//	ForwardCurrentPosition(b->data,1);
	//	b->data->listTail->OffsetToText += 2;
	//}

#endif //#ifdef __MMI_HINDI_ALG__
#if(EMS_USE_DCS)
	if(r==EMS_OK)
	{	s32 remaining_length;
		if(b->object_count==0)
		{	b->object_count++;
			pixtel_UI_EMS_change_DCS(b);
		}
		else b->object_count++;
		if(b->UCS2_count>0) remaining_length=(EMS_get_remaining_length(b->data)>>1);
		else remaining_length=EMS_get_remaining_length(b->data);
		if(remaining_length<0)
		{	CancelCurrentPosition(b->data,1);
			b->object_count--;
			if(b->object_count==0) pixtel_UI_EMS_change_DCS(b);
			UI_editor_play_tone_cannot_insert();
			return(EMS_NO_SPACE);
		}
	}
#endif
	b->saved_cursor_ax=-1;
	return(r);
}

U8 pixtel_UI_EMS_input_box_insert_character(UI_EMS_input_box *b,UI_character_type c)
{
	//W06.03 EMS_get_remaining_length > 0 does not make sure that we could insert one more character
	//Return EMS_OK if we insert the character successfully
	word	ch=(word)c;
	byte	s[2]={0,0};
	s32				remaining_length;
	U8 ret = EMS_OK;

#ifdef __MMI_MESSAGES_EMS__
	EMS_cancel_object_focus();
#endif
	if(b->UCS2_count>0) remaining_length=(EMS_get_remaining_length(b->data)>>1);
	else
	{	remaining_length=EMS_get_remaining_length(b->data);
	}
	if(remaining_length<=0)
	{	UI_editor_play_tone_cannot_insert();
		return EMS_NO_SPACE;
	}
	//MTK Elvis
    /*if((b->UCS2_count==0) && UI_TEST_UCS2_CHARACTER(c) && remaining_length<=344))
	{	UI_editor_play_tone_cannot_insert();
		return;
    } */
    if(b->UCS2_count==0)
	{	if(UI_TEST_UCS2_CHARACTER(c))
		{
			pixtel_UI_EMS_input_box_remove_extension_character(b->data);
			if(EMSSetDCS(b->data,SMSAL_UCS2_DCS) != EMS_OK)
			{
			   EMSSetDCS(b->data,SMSAL_DEFAULT_DCS);
			   pixtel_UI_EMS_input_box_insert_extension_character(b->data);
			   UI_editor_play_tone_cannot_insert();
			   return  EMS_NO_SPACE;
			}
			else
			{
			   if(EMS_get_remaining_length(b->data)<2)
			   {
				 EMSSetDCS(b->data,SMSAL_DEFAULT_DCS);
				pixtel_UI_EMS_input_box_insert_extension_character(b->data);
				 UI_editor_play_tone_cannot_insert();
				 return  EMS_NO_SPACE;
			   }
			}
		}
		else if(UI_TEST_GSM_EXTENDED(c))
		{	if(EMS_get_remaining_length(b->data)<2)
			{	UI_editor_play_tone_cannot_insert();
				return  EMS_NO_SPACE;
			}
		}
    }
	//MTK end

	/*	If in Overwrite mode, delete the current character/object and insert the new one	*/
	if(b->flags & UI_EMS_INPUT_BOX_OVERWRITE_MODE)
	{	if(pixtel_UI_EMS_input_box_forward_cursor(b)==1)
		{	pixtel_UI_EMS_cancel_current_position(b);
		}
	}
#if(EMS_BYTE_ORDER_BIG_ENDIAN)
	s[0]=(ch & 0xff00)>>8;
	s[1]=(ch & 0x00ff);
#else
	s[1]=(byte)(ch>>8);
	s[0]=(byte)ch;
#endif
	if(pixtel_UI_EMS_input_box_add_string(b,s,&b->text_format)==EMS_NO_SPACE)
	{	UI_editor_play_tone_cannot_insert();
		b->overflow_callback();
		ret = EMS_NO_SPACE;
	}
	else b->change_callback();
	pixtel_UI_EMS_input_box_locate_cursor(b);
	b->saved_cursor_ax=-1;
	return ret;
}
#ifdef __MMI_HINDI_ALG__
U8 saved_last_skip_pos = 0;
#endif /*__MMI_HINDI_ALG__*/
//END TARUN PMT 20050128
//START PMTFARHAD 20050224
#if defined __MMI_LANG_HINDI__  && defined __MMI_LANG_ARABIC__
S32 HINDI_PRESENT = 0;
S32 ARABIC_PRESENT = 0;
#endif
//END PMTFARHAD  20050224
void pixtel_UI_EMS_input_box_insert_multitap_character(UI_EMS_input_box *b,UI_character_type c)
{	word			ch=(word)c;
	byte			s[2]={0,0};
	EMSTextFormat	text_format;
	s32				remaining_length;
#ifdef __MMI_HINDI_ALG__
	EMSObject *bb;
	UI_character_type current_character1 = 0;
	byte object_type_check1=0;
   EMSObject				*o1;
	EMSPosition				p1=b->data->CurrentPosition;
	EMSData *data_chk_type1 = b->data;
	UI_character_type current_character2 = 0;
	byte object_type_check2=0;
//PMT VIKAS GUPTA START 20051129
	byte halant_after_object=0;
//PMT VIKAS GUPTA END 20051129
   EMSObject				*o2;
	EMSPosition				p2=b->data->CurrentPosition;
	EMSData *data_chk_type2 = b->data;
//PMT VIKAS GUPTA START 20051129
	UI_buffer_type		middle_ems_position,first_cons_ems_position,second_cons_ems_position,halant_check_position;
//PMT VIKAS GUPTA END 20051129
	static U8			ems_cursor_pos_flag=0;
//PMT VIKAS GUPTA START 20051129
	U8 total_no_of_objects=0;
//PMT VIKAS GUPTA END 20051129
#endif /*__MMI_HINDI_ALG__*/
#ifdef __MMI_MESSAGES_EMS__
	EMS_cancel_object_focus();
#endif
	if(b->UCS2_count>0) remaining_length=(EMS_get_remaining_length(b->data)>>1);
	else
	{	remaining_length=EMS_get_remaining_length(b->data);
	}
	if((remaining_length<=0) && !(b->flags & UI_EMS_INPUT_BOX_STATE_MULTITAP) && !(b->flags & UI_EMS_INPUT_BOX_OVERWRITE_MODE))
	{	UI_editor_play_tone_cannot_insert();
		return;
	}
#if(0)
	if((b->UCS2_count==0) && UI_TEST_UCS2_CHARACTER(c) && (remaining_length<=344))
	{	UI_editor_play_tone_cannot_insert();
		return;
	}
#endif
	if(b->UCS2_count==0)
	{	if(UI_TEST_UCS2_CHARACTER(c))
		{
			if(EMSSetDCS(b->data,SMSAL_UCS2_DCS) != EMS_OK)
			{
			   EMSSetDCS(b->data,SMSAL_DEFAULT_DCS);
			   UI_editor_play_tone_cannot_insert();
			   return;
			}
			else
			{
			   if(EMS_get_remaining_length(b->data)<2)
			   {
				 EMSSetDCS(b->data,SMSAL_DEFAULT_DCS);
				 UI_editor_play_tone_cannot_insert();
				 return;
			   }
			}
		}
		else if(UI_TEST_GSM_EXTENDED(c))
		{	if(EMS_get_remaining_length(b->data)<2)
			{	UI_editor_play_tone_cannot_insert();
				return;
			}
		}
    }
#if(EMS_BYTE_ORDER_BIG_ENDIAN)
	s[0]=(ch & 0xff00)>>8;
	s[1]=(ch & 0x00ff);
#else
	s[1]=(byte)(ch>>8);
	s[0]=(byte)ch;
#endif
	if(b->flags & UI_EMS_INPUT_BOX_STATE_MULTITAP)
	{
#ifdef __MMI_HINDI_ALG__
		second_cons_ems_position = &(b->data->textBuffer[b->data->CurrentPosition.OffsetToText]);
//PMT VIKAS GUPTA START 20051129
		halant_check_position=&(b->data->textBuffer[b->data->CurrentPosition.OffsetToText-4]);
//PMT VIKAS GUPTA END 20051129
		if ((ems_cursor_pos_flag) && ((c==49)|| (c==0x901) ||(c==0x902)) )//Only when multitap input is 1
		{
			BackwardCurrentPosition(b->data,saved_last_skip_pos);
			ems_cursor_pos_flag =0 ;
			saved_last_skip_pos = 0;
		}
//PMT VIKAS GUPTA START 20051129
{
			
			EMSObject *object_and_halant_check;
			
			
			EMSPosition			p=b->data->CurrentPosition;
			UI_character_type	c;
         EMSObject            *current_object;
			byte				r;		
			object_and_halant_check=b->data->listHead;
			//r=pixtel_UI_EMS_input_box_get_previous_object(b->data,&p,&c,&current_object);
			halant_after_object=pixtel_UI_EMS_input_box_get_previous_object(b->data,&p,&c,&current_object);
			while(object_and_halant_check!=NULL && halant_after_object==2)
			{
					total_no_of_objects++;
					object_and_halant_check=object_and_halant_check->next;
			}
		}
		if(*halant_check_position==0x4D&&halant_after_object==2)
				check_for_halant=1;
//PMT VIKAS GUPTA END 20051129
#endif //__MMI_HINDI_ALG__
//PMT VIKAS GUPTA START 20051129
#ifdef __MMI_HINDI_ALG__
		if(check_for_halant)
		{
				BackwardCurrentPosition(b->data,total_no_of_objects);
				pixtel_UI_EMS_cancel_current_position(b);				
				
		}
		else
#endif
//PMT VIKAS GUPTA END 20051129
		pixtel_UI_EMS_cancel_current_position(b);
	#ifdef __MMI_HINDI_ALG__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -