gui_ems.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:414k
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * gui_ems.c
- *
- * Project:
- * --------
- * MAUI
- *
- * Description:
- * ------------
- * EMS editor - UI component
- *
- * Author:
- * -------
- * -------
- * -------
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- /**********************************************************************************
- Filename: gui_ems.c
- Author: manju
- Date Created: March-25-2003
- Contains: EMS input box
- **********************************************************************************/
- #include "SettingProfile.h"
- #include "KeyBrd.h"
- #include "gui_ems.h"
- #include "gui_inputs.h"
- #include "wgui_categories_defs.h"
- #include "DebugInitDef.h"
- #include "wgui_categories_inputs.h"
- #ifdef __MMI_HINDI_ALG__
- #include "hf_rules.h"
- #include "gui.h"
- #endif /* __MMI_HINDI_ALG__ */
- #include "MMI_features.h"
- #include "TimerEvents.h"
- #ifdef __MMI_LANG_VIETNAMESE__
- #include "gui_lang_viet.h"
- #endif
- #ifdef __MMI_ZI_V7__
- #include "ezicmn.h"
- #endif
- #if defined(__MMI_ZI_ARABIC__) || defined(__MMI_ZI_PERSIAN__)
- #include "zi8ARshape.h"
- #endif /* defined(__MMI_ZI_ARABIC__) || defined(__MMI_ZI_PERSIAN__) */
- /* for R2L characters */
- #include "BIDIDEF.h"
- #include "BIDIProt.h"
- /* for R2L characters */
- extern BOOL r2lMMIFlag;
- #ifdef __MMI_BIDI_ALG__
- extern U8 visual_str[];
- extern U8 MMI_bidi_input_type;
- #endif /* __MMI_BIDI_ALG__ */
- /* MTK Steven 20050505 */
- #ifdef __MMI_LANG_THAI__
- #define isThaiChar(ch) (((ch >= 0x0E01) && (ch <= 0x0E7F))? (1):(0))
- #endif
- /* MTK End */
- extern U16 StopMyTimer(U16 nTimerId);
- extern U16 StartMyTimerInt(U16 nTimerId, U32 nTimeDuration, oslTimerFuncPtr TimerExpiry, U8 alignment);
- extern U8 mmi_msg_get_seg_num(void);
- extern void UI_set_current_text_color(color c);
- extern S32 UI_cursor_x1; /* cursor x1 postioon */
- extern S32 UI_cursor_y1; /* cursor y1 position */
- extern void UI_draw_horizontal_line(S32 x1, S32 x2, S32 y, color c);
- #if defined(__MMI_T9__)
- extern void T9SynT9WithInputBoxForEMSInputBox(void);
- #endif
- #ifdef __MMI_ARSHAPING_ENGINE__
- extern void ArabicShapeEngine2(PU16 , PU16 , PU16 , PU16 );
- #endif
- #if defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__)
- extern U16 shaping_str[];
- extern S32 unshaped_text_len;
- extern U16 gui_get_ems_text_actual_idx(UI_EMS_input_box *b, U16 OffsetToText);
- extern U16 OrgToSha[];
- #endif /* defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__) */
- /* PMT END LANGUAGE 20060104 */
- #if(0)
- #include "DebugInitDef.h"
- #endif /* (0) */
- #ifdef __MMI_HINDI_ALG__
- #define UI_CHK_CONSONANT(ch) (( (ch >= 0x15 && ch <= 0x39) || (ch >= 0x58 && ch <= 0x5f) || ch==0x50 )? (1):(0))
- #endif
- #define EMS_SHOW_HORIZONTAL_RULE_FOR_NEWLINE 0
- /* START PMT NEERAJ 20050916 */
- #define EMS_SHOW_HORIZONTAL_RULE_FOR_ALL_LINES 1
- /* END PMT NEERAJ 20050916 */
- #define EMS_ENABLE_EDITOR_OBJECT_PLAYBACK 0
- #define EMS_PREVENT_CRLF_DISPLAY 1
- #define EMS_USE_CRLF_COMBINATION 1
- #define EMS_USE_ESC_COMBINATION 1
- #define EMS_USE_GSM_EXTENDED 0
- #define EMS_DISPLAY_SPECIAL_CHARACTERS 0
- #define EMS_ENABLE_GRAPHICAL_CURSOR_MOVEMENT 1
- #define EMS_INPUTBOX_PARAGRAPH_BREAK_CHARACTER 0x0A
- #define EMS_ENABLE_SPECIAL_FONT_DISPLAY 1
- #define EMS_HEADER_SCROLL_SIZE 20
- #define EMS_ENABLE_TESTFIX_OBJECT_ORDERING 1
- #define EMS_DEFAULT_DCS_ALLOCATED_LENGTH mmi_msg_get_seg_num() * 153
- #define EMS_UCS2_DCS_ALLOCATED_LENGTH mmi_msg_get_seg_num() * 67
- #if defined(__MMI_MESSAGES_CONCAT_SMS__)
- #define EMS_DEFAULT_DCS_AVAILABLE_LENGTH mmi_msg_get_seg_num() * 153
- #define EMS_UCS2_DCS_AVAILABLE_LENGTH mmi_msg_get_seg_num() * 67
- #else /* defined(__MMI_MESSAGES_CONCAT_SMS__) */
- #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 /* (EMS_DISPLAY_SPECIAL_CHARACTERS) */
- #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 /* __MMI_MESSAGES_EMS__ */
- #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))
- 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);
- U8 TestLastPosition(EMSData *data, EMSPosition *p);
- U8 TestFirstPosition(EMSData *data, EMSPosition *p);
- U8 BackwardCurrentPositionObject(EMSData *data, EMSPosition *dst);
- U8 ForwardCurrentPositionObject(EMSData *data, EMSPosition *dst);
- void EMS_move_graphical_cursor(EMSData *data, S32 start_x, S32 cursor_x, S32 max_count);
- /*****************************************************************************
- * FUNCTION
- * gui_intialize_EMS
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void gui_intialize_EMS(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- 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
- }
- /*****************************************************************************
- * FUNCTION
- * gui_set_EMS_input_box_theme
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * t [?]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_set_EMS_input_box_theme(UI_EMS_input_box *b, UI_EMS_input_box_theme *t)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- 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;
- }
- /*****************************************************************************
- * FUNCTION
- * gui_set_EMS_input_box_current_theme
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_set_EMS_input_box_current_theme(UI_EMS_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- 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;
- /*****************************************************************************
- * FUNCTION
- * gui_create_EMS_input_box
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * x [IN]
- * y [IN]
- * width [IN]
- * height [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_create_EMS_input_box(UI_EMS_input_box *b, S32 x, S32 y, S32 width, S32 height)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- b->x = x;
- b->y = y;
- b->width = width;
- b->height = height;
- b->flags = 0;
- MMI_current_input_ext_type = 0;
- gui_set_EMS_input_box_current_theme(b);
- b->overflow_callback = UI_dummy_function;
- b->change_callback = UI_dummy_function;
- gui_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 = gui_color(0, 0, 128);
- b->strikethrough_color = gui_color(192, 0, 0);
- b->paragraph_color = gui_color(0, 128, 0);
-
- b->locate_cursor_flag = 1;
-
- }
- #if(EMS_USE_DCS)
- /*****************************************************************************
- * FUNCTION
- * gui_EMS_change_DCS
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_EMS_change_DCS(UI_EMS_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- 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 /* (EMS_USE_DCS) */
- /*****************************************************************************
- * FUNCTION
- * gui_set_EMS_input_box_data
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * d [?]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_set_EMS_input_box_data(UI_EMS_input_box *b, EMSData *d)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- EMSObject *text_format_object;
- U8 done = 0;
- EMSPosition current_position;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- 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))
- {
- U8 r;
- EMSPosition p = b->data->CurrentPosition;
- EMSObject *current_object;
- UI_character_type c;
- p.OffsetToText = 0;
- p.Object = b->data->listHead;
- while (!done)
- {
- r = gui_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;
- }
- }
- }
- gui_EMS_change_DCS(b);
- #endif /* (EMS_USE_DCS) */
- 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;
- }
- /*****************************************************************************
- * FUNCTION
- * EMS_get_remaining_length
- * DESCRIPTION
- *
- * PARAMETERS
- * data [?]
- * RETURNS
- *
- *****************************************************************************/
- S32 EMS_get_remaining_length(EMSData *data)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- 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 /* defined(__MMI_MESSAGES_CONCAT_SMS__) */
- return (data->Reminder.totalRemainingOctet -
- (EMS_DEFAULT_DCS_ALLOCATED_LENGTH - EMS_DEFAULT_DCS_AVAILABLE_LENGTH));
- #endif /* defined(__MMI_MESSAGES_CONCAT_SMS__) */
- 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 /* defined(__MMI_MESSAGES_CONCAT_SMS__) */
- return (data->Reminder.totalRemainingOctet -
- ((EMS_UCS2_DCS_ALLOCATED_LENGTH << 1) - (EMS_UCS2_DCS_AVAILABLE_LENGTH << 1)));
- #endif /* defined(__MMI_MESSAGES_CONCAT_SMS__) */
- }
- #ifdef __MMI_MESSAGES_EMS__
- /*****************************************************************************
- * FUNCTION
- * gui_EMS_input_box_set_text_format_object
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * f [?]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_EMS_input_box_set_text_format_object(UI_EMS_input_box *b, EMSTextFormat *f)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (f != NULL)
- {
- b->text_format = *f;
- }
- }
- #endif /* __MMI_MESSAGES_EMS__ */
- /*****************************************************************************
- * FUNCTION
- * gui_EMS_input_box_locate_cursor
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_EMS_input_box_locate_cursor(UI_EMS_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 box_height = b->height - 4;
- S32 cursory;
- S32 content_h;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- b->flags |= UI_EMS_INPUT_BOX_DISABLE_DRAW;
- gui_show_EMS_input_box(b);
- b->flags &= ~UI_EMS_INPUT_BOX_DISABLE_DRAW;
- if (b->flags & UI_EMS_INPUT_BOX_DISPLAY_HEADER)
- {
- cursory = b->cursor_ay + b->header_height;
- content_h = b->display_height + b->header_height;
- }
- else
- {
- cursory = b->cursor_ay;
- content_h = b->display_height;
- }
- /* 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 (cursory < (-b->display_y))
- {
- b->display_y = -cursory;
- }
- else if ((cursory + b->cursor_line_height) > ((-b->display_y) + box_height))
- {
- b->display_y -= (cursory + b->cursor_line_height) - ((-b->display_y) + box_height);
- }
- if ((b->display_y + content_h) < box_height)
- {
- b->display_y = (box_height) - content_h;
- }
- if (b->display_y > 0)
- {
- b->display_y = 0;
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_EMS_input_box_reset_cursor_position
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_EMS_input_box_reset_cursor_position(UI_EMS_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (b->data != NULL)
- {
- ResetCurrentPosition(b->data);
- gui_EMS_input_box_locate_cursor(b);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_EMS_input_box_get_previous_text_alignment
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * p [?]
- * RETURNS
- *
- *****************************************************************************/
- U8 gui_EMS_input_box_get_previous_text_alignment(UI_EMS_input_box *b, EMSPosition *p)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 done = 0;
- UI_character_type c;
- EMSObject *o;
- U8 r;
- EMSPosition current_position = *p;
- U8 alignment = UI_EMS_normal_text_format_object.data->text_format.Alignment;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- while (!done)
- {
- r = gui_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 */
- /*****************************************************************************
- * FUNCTION
- * gui_EMS_input_box_set_paragraph_text_alignment
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * p [?]
- * alignment [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_EMS_input_box_set_paragraph_text_alignment(UI_EMS_input_box *b, EMSPosition *p, U8 alignment)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 done = 0;
- UI_character_type c;
- EMSObject *o;
- U8 r;
- EMSPosition current_position = *p;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- while (!done)
- {
- r = gui_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 */
- /*****************************************************************************
- * FUNCTION
- * gui_EMS_input_box_test_paragraph_start
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * p [?]
- * RETURNS
- *
- *****************************************************************************/
- U8 gui_EMS_input_box_test_paragraph_start(UI_EMS_input_box *b, EMSPosition *p)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 paragraph_flag = 0;
- UI_character_type c;
- EMSObject *o;
- U8 r;
- EMSPosition current_position = *p;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (TestFirstPosition(b->data, ¤t_position))
- {
- paragraph_flag = 1;
- }
- else
- {
- if (BackwardCurrentPosition(b->data, 1) == 1)
- {
- current_position = b->data->CurrentPosition;
- r = gui_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);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_EMS_input_box_set_text_format_cursor_position
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_EMS_input_box_set_text_format_cursor_position(UI_EMS_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 done = 0;
- EMSPosition current_position;
- EMSObject *current_text_format_object;
- UI_character_type c;
- EMSObject *o;
- U8 r;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- 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 (gui_EMS_input_box_test_paragraph_start(b, ¤t_position))
- {
- while (!done)
- {
- r = gui_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 = gui_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)
- {
- b->text_format.Alignment = o->data->text_format.Alignment;
- done = 1;
- }
- break;
- }
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_EMS_input_box_set_cursor_position
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * p [?]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_EMS_input_box_set_cursor_position(UI_EMS_input_box *b, EMSPosition *p)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (b->data != NULL)
- {
- ResetCurrentPosition(b->data);
- while (!
- ((b->data->CurrentPosition.OffsetToText == p->OffsetToText) &&
- (b->data->CurrentPosition.Object == p->Object)))
- {
- if (ForwardCurrentPosition(b->data, 1) != 1)
- {
- break;
- }
- }
- gui_EMS_input_box_locate_cursor(b);
- }
- }
- /* Macros for graphics functions */
- extern stFontAttribute *UI_font;
- extern U8 SetFont(stFontAttribute Font, U8 arrCount);
- extern S32 UI_clip_x1, UI_clip_x2, UI_clip_y1, UI_clip_y2;
- extern S32 UI_text_x, UI_text_y;
- extern color UI_text_color;
- #define EMS_SET_FONT(f)
- { UI_font=(f);
- SetFont(*(f),0);
- }
- #define EMS_MOVE_TEXT_CURSOR(x,y)
- { UI_text_x=x;
- UI_text_y=y;
- }
- #define EMS_SET_TEXT_COLOR(c)
- { UI_text_color=c;
- UI_set_current_text_color(UI_text_color);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_EMS_input_box_equal_text_format
- * DESCRIPTION
- *
- * PARAMETERS
- * t1 [?]
- * t2 [?]
- * RETURNS
- *
- *****************************************************************************/
- U8 gui_EMS_input_box_equal_text_format(EMSTextFormat *t1, EMSTextFormat *t2)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (t1->Alignment != t2->Alignment)
- {
- return (0);
- }
- if (t1->bgColor != t2->bgColor)
- {
- return (0);
- }
- if (t1->fgColor != t2->fgColor)
- {
- return (0);
- }
- if (t1->FontSize != t2->FontSize)
- {
- return (0);
- }
- if (t1->isBold != t2->isBold)
- {
- return (0);
- }
- if (t1->isItalic != t2->isItalic)
- {
- return (0);
- }
- if (t1->isStrikethrough != t2->isStrikethrough)
- {
- return (0);
- }
- if (t1->isUnderline != t2->isUnderline)
- {
- return (0);
- }
- if (t1->textLength != t2->textLength)
- {
- return (0);
- }
- return (1);
- }
- #define EMS_EQUAL_TEXT_FORMAT(t1,t2) (~(memcmp((t1),(t2),sizeof(EMSTextFormat)))
- #define EMS_ESCAPE_CHARACTER (27)
- /*****************************************************************************
- * FUNCTION
- * gui_EMS_input_box_remove_extension_character
- * DESCRIPTION
- *
- * PARAMETERS
- * data [?]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_EMS_input_box_remove_extension_character(EMSData *data)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 c, OffsetToText;
- U8 *textBuffer = data->textBuffer;
- U16 textBufferLength = data->textLength;
- EMSPosition currposition = data->CurrentPosition;
- #if defined(__MMI_T9__)
- /* PMT VIKAS GUPTA START 20051129 */
- EMSPosition backupcurrposition = data->CurrentPosition;
- /* PMT VIKAS GUPTA END 20051129 */
- #endif /* defined(__MMI_T9__) */
- kal_uint16 ret_char;
- EMSPosition dummyposition;
- EMSObject *ret_object;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (textBuffer == NULL)
- {
- return;
- }
- ResetCurrentPosition(data);
- if (data->dcs == SMSAL_DEFAULT_DCS)
- {
- while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
- {
- #if(EMS_BYTE_ORDER_BIG_ENDIAN)
- c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
- #else
- c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
- #endif
- if (c == EMS_ESCAPE_CHARACTER)
- {
- dummyposition = data->CurrentPosition;
- while (EMSGetNextObject(data, &dummyposition, &ret_char, &ret_object) == 2)
- {
- ForwardCurrentPosition(data, 1);
- dummyposition = data->CurrentPosition;
- if (ret_object->Type == EMS_TYPE_TEXT_FORMAT)
- {
- if (EMSGetPreviousObject(data, &dummyposition, &ret_char, &ret_object) == 1)
- {
- BackwardCurrentPosition(data, 1);
- break;
- }
- dummyposition = data->CurrentPosition;
- }
- }
- #if(EMS_BYTE_ORDER_BIG_ENDIAN)
- if (ForwardCurrentPosition(data, 1) != 1)
- {
- break;
- }
- CancelCurrentPosition(data, 1);
- if (OffsetToText <= currposition.OffsetToText)
- {
- currposition.OffsetToText--;
- }
- OffsetToText = data->CurrentPosition.OffsetToText;
- textBufferLength -= ENCODING_LENGTH;
- #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */
- if (ForwardCurrentPosition(data, 1) != 1)
- {
- break;
- }
- CancelCurrentPosition(data, 1);
- if (OffsetToText <= currposition.OffsetToText)
- {
- currposition.OffsetToText -= ENCODING_LENGTH;
- }
- OffsetToText = data->CurrentPosition.OffsetToText;
- textBufferLength -= ENCODING_LENGTH;
- #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */
- }
- if (ForwardCurrentPosition(data, 1) != 1)
- {
- break;
- }
- }
- }
- MoveCursorToPosition(data, &currposition);
- #if defined(__MMI_T9__)
- /* PMT VIKAS GUPTA START 20051129 */
- if (memcmp((const void*)&backupcurrposition, (const void*)&currposition, sizeof(EMSPosition)) == 0)
- {
- return;
- }
- /* PMT VIKAS GUPTA END 20051129 */
- T9SynT9WithInputBoxForEMSInputBox();
- #endif /* defined(__MMI_T9__) */
- }
- /* Call before EMSPack */
- /*****************************************************************************
- * FUNCTION
- * gui_EMS_input_box_insert_extension_character
- * DESCRIPTION
- *
- * PARAMETERS
- * data [?]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_EMS_input_box_insert_extension_character(EMSData *data)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 c, OffsetToText;
- U8 *textBuffer = data->textBuffer;
- U16 textBufferLength = data->textLength;
- EMSPosition currposition = data->CurrentPosition;
- #if defined(__MMI_T9__)
- /* PMT VIKAS GUPTA START 20051129 */
- EMSPosition backupcurrposition = data->CurrentPosition;
- /* PMT VIKAS GUPTA END 20051129 */
- #endif /* defined(__MMI_T9__) */
- #if(EMS_BYTE_ORDER_BIG_ENDIAN)
- U8 ESC_string[] = {0x00, 0x1B};
- #else
- U8 ESC_string[] = {0x1B, 0x00};
- #endif
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (textBuffer == NULL)
- {
- return;
- }
- ResetCurrentPosition(data);
- if (data->dcs == SMSAL_DEFAULT_DCS)
- {
- while ((OffsetToText = data->CurrentPosition.OffsetToText) < textBufferLength)
- {
- #if(EMS_BYTE_ORDER_BIG_ENDIAN)
- c = (U16) (textBuffer[OffsetToText + 1] | (textBuffer[OffsetToText] << 8));
- #else
- c = (U16) (textBuffer[OffsetToText] | (textBuffer[OffsetToText + 1] << 8));
- #endif
- if (UI_TEST_GSM_EXTENDED(c))
- {
- AddString(data, ESC_string, 1, NULL);
- if (OffsetToText <= currposition.OffsetToText)
- {
- currposition.OffsetToText += ENCODING_LENGTH;
- }
- OffsetToText = data->CurrentPosition.OffsetToText;
- /* MTK Elvis 20031126 */
- textBufferLength += ENCODING_LENGTH;
- /* MTK end */
- }
- if (ForwardCurrentPosition(data, 1) != 1)
- {
- break;
- }
- }
- }
- MoveCursorToPosition(data, &currposition);
- #if defined(__MMI_T9__)
- /* PMT VIKAS GUPTA START 20051129 */
- if (memcmp((const void*)&backupcurrposition, (const void*)&currposition, sizeof(EMSPosition)) == 0)
- {
- return;
- }
- /* PMT VIKAS GUPTA END 20051129 */
- T9SynT9WithInputBoxForEMSInputBox();
- #endif /* defined(__MMI_T9__) */
- }
- #if(EMS_USE_DCS)
- #if(EMS_USE_CRLF_COMBINATION || EMS_USE_ESC_COMBINATION)
- /* Deletes one object/character before cursor position and updates UCS2 and Object counters */
- /* Also handles CRLF combination */
- /*****************************************************************************
- * FUNCTION
- * gui_EMS_cancel_current_position
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * RETURNS
- *
- *****************************************************************************/
- U8 gui_EMS_cancel_current_position(UI_EMS_input_box *b)
- {
- #ifdef __MMI_HINDI_ALG__
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 lst_pos = 0;
- S32 cancel_two_pos = 0;
- UI_character_type current_character1 = 0;
- U8 object_type_check1 = 0;
- EMSObject *o1;
- EMSPosition p1 = b->data->CurrentPosition;
- EMSData *data_chk_type1 = b->data;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (TestLastPosition(b->data, &(b->data->CurrentPosition)))
- {
- lst_pos = 1;
- }
- #endif /* __MMI_HINDI_ALG__ */
- if (BackwardCurrentPosition(b->data, 1) == 1)
- {
- EMSPosition p = b->data->CurrentPosition;
- EMSObject *current_object;
- UI_character_type c;
- U8 r;
- S32 count;
- U8 dcs_change = 0;
- r = gui_EMS_input_box_get_next_object(b->data, &p, &c, ¤t_object);
- #ifdef __MMI_HINDI_ALG__
- if (lst_pos)
- {
- if (b->data->CurrentPosition.OffsetToText >= 4 &&
- UI_TEST_LF_CHARACTER(b->data->textBuffer[b->data->CurrentPosition.OffsetToText]) &&
- UI_TEST_CR_CHARACTER(b->data->textBuffer[b->data->CurrentPosition.OffsetToText - 2]))
- {
- b->data->textBuffer[b->data->CurrentPosition.OffsetToText - 2] = 0;
- b->data->textBuffer[b->data->CurrentPosition.OffsetToText - 1] = 0;
- cancel_two_pos = 1;
- }
- b->data->textBuffer[b->data->CurrentPosition.OffsetToText] = 0;
- b->data->textBuffer[b->data->CurrentPosition.OffsetToText + 1] = 0;
- }
- #endif /* __MMI_HINDI_ALG__ */
- ForwardCurrentPosition(b->data, 1);
- switch (r)
- {
- case 0:
- break;
- case 1:
- #if(EMS_USE_CRLF_COMBINATION)
- if (UI_TEST_LF_CHARACTER(c))
- {
- count = BackwardCurrentPosition(b->data, 2);
- if (count == 2)
- {
- p = b->data->CurrentPosition;
- r = gui_EMS_input_box_get_next_object(b->data, &p, &c, ¤t_object);
- if ((r == 1) && UI_TEST_CR_CHARACTER(c))
- {
- ForwardCurrentPosition(b->data, 2);
- CancelCurrentPosition(b->data, 1);
- count = 0;
- }
- }
- ForwardCurrentPosition(b->data, (U16) count);
- }
- else
- #endif /* (EMS_USE_CRLF_COMBINATION) */
- if (UI_TEST_UCS2_CHARACTER(c))
- {
- if (b->UCS2_count > 0)
- {
- b->UCS2_count--;
- if (b->UCS2_count == 0)
- {
- dcs_change = 1;
- gui_EMS_change_DCS(b);
- }
- }
- }
- else if (UI_TEST_GSM_EXTENDED(c))
- {
- if (b->GSM_ext_count > 0)
- {
- b->GSM_ext_count--;
- }
- }
- break;
- case 2:
- /* MTK Joy added for text format case, get the character and set the parameters accordingly, 1230 */
- if (current_object->Type == 0)
- {
- r = gui_EMS_input_box_get_next_object(b->data, &p, &c, ¤t_object);
- if ((r == 1) && UI_TEST_UCS2_CHARACTER(c))
- {
- if (b->UCS2_count > 0)
- {
- b->UCS2_count--;
- if (b->UCS2_count == 0)
- {
- dcs_change = 1;
- gui_EMS_change_DCS(b);
- }
- }
- }
- else if (UI_TEST_GSM_EXTENDED(c))
- {
- if (b->GSM_ext_count > 0)
- {
- b->GSM_ext_count--;
- }
- }
- break;
- }
- /* MTK end */
- if (b->object_count > 0)
- {
- b->object_count--;
- if (b->object_count == 0)
- {
- gui_EMS_change_DCS(b);
- }
- }
- break;
- }
- CancelCurrentPosition(b->data, 1);
- #ifdef __MMI_HINDI_ALG__
- b->data->textBuffer[b->data->textLength] = 0;
- b->data->textBuffer[b->data->textLength + 1] = 0;
- if (cancel_two_pos)
- {
- CancelCurrentPosition(b->data, 1);
- }
- if (b->data->CurrentPosition.OffsetToText >= 4)
- {
- if ((UI_CHK_CONSONANT(b->data->textBuffer[b->data->CurrentPosition.OffsetToText]))
- && (UI_CHK_CONSONANT(b->data->textBuffer[b->data->CurrentPosition.OffsetToText - 4]))
- && (b->data->textBuffer[b->data->CurrentPosition.OffsetToText - 2] == 0x4d)
- && ((b->data->textBuffer[b->data->CurrentPosition.OffsetToText + 1]) == 0x09)
- && ((b->data->textBuffer[b->data->CurrentPosition.OffsetToText - 3]) == 0x09))
- {
- EMSObject *bb;
- U8 fwd_positions = 0;
- U8 saved_fwd_positions = 0;
- PU8 dest_pos;
- PU8 src_pos = &b->data->textBuffer[b->data->CurrentPosition.OffsetToText];
- p1 = b->data->CurrentPosition;
- object_type_check1 = gui_EMS_input_box_get_next_object(data_chk_type1, &p1, ¤t_character1, &o1);
- /* dest_pos = hf_get_next_cluster_p(b->data->textBuffer,src_pos); */
- dest_pos = hf_get_next_cluster_p(src_pos, src_pos);
- fwd_positions = dest_pos - src_pos; /* Number of moves */
- fwd_positions = fwd_positions >> 1;
- saved_fwd_positions = fwd_positions;
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "pixtel_UI_EMS_cancel_current_position[fwd_positions]:%d ",
- fwd_positions));
- while (fwd_positions--)
- {
- ForwardCurrentPosition(b->data, 1);
- }
- if (object_type_check1 == 2)
- {
- if (saved_fwd_positions == 1)
- {
- /* To shift the images on cluster completion */
- bb = b->data->listTail;
- do
- {
- if (bb->OffsetToText == b->data->CurrentPosition.Object->OffsetToText)
- {
- bb->OffsetToText += (saved_fwd_positions) * 2;
- }
- bb = bb->prev;
- } while (bb != NULL);
- ForwardCurrentPosition(b->data, saved_fwd_positions);
- BackwardCurrentPositionSkipCR(b->data);
- }
- else if (saved_fwd_positions > 1)
- {
- /* To shift the images on cluster completion */
- bb = b->data->listHead;
- do
- {
- if (bb->OffsetToText == b->data->CurrentPosition.Object->OffsetToText)
- {
- bb->OffsetToText += (saved_fwd_positions) * 2;
- }
- bb = bb->next;
- } while (bb != NULL);
- ForwardCurrentPosition(b->data, saved_fwd_positions);
- if (b->data->listHead == b->data->listTail)
- {
- BackwardCurrentPositionSkipCR(b->data);
- }
- else
- {
- BackwardCurrentPositionSkipCR(b->data);
- BackwardCurrentPositionSkipCR(b->data);
- }
- }
- }
- }
- }
- #endif /* __MMI_HINDI_ALG__ */
- if (dcs_change)
- {
- gui_EMS_input_box_insert_extension_character(b->data);
- }
- #if(EMS_USE_ESC_COMBINATION)
- if (b->UCS2_count == 0)
- {
- p = b->data->CurrentPosition;
- r = gui_EMS_input_box_get_previous_object(b->data, &p, &c, ¤t_object);
- if ((r == 1) && UI_TEST_ESC_CHARACTER(c))
- {
- CancelCurrentPosition(b->data, 1);
- }
- }
- #endif /* (EMS_USE_ESC_COMBINATION) */
- return (1);
- }
- return (0);
- }
- #else /* (EMS_USE_CRLF_COMBINATION || EMS_USE_ESC_COMBINATION) */
- /* Deletes one object/character before cursor position and updates UCS2 and Object counters */
- /*****************************************************************************
- * FUNCTION
- * gui_EMS_cancel_current_position
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * RETURNS
- *
- *****************************************************************************/
- U8 gui_EMS_cancel_current_position(UI_EMS_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (BackwardCurrentPosition(b->data, 1) == 1)
- {
- EMSPosition p = b->data->CurrentPosition;
- EMSObject *current_object;
- UI_character_type c;
- U8 r;
- r = gui_EMS_input_box_get_next_object(b->data, &p, &c, ¤t_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)
- {
- gui_EMS_change_DCS(b);
- }
- }
- }
- break;
- case 2:
- if (b->object_count > 0)
- {
- b->object_count--;
- if (b->object_count == 0)
- {
- gui_EMS_change_DCS(b);
- }
- }
- break;
- }
- CancelCurrentPosition(b->data, 1);
- return (1);
- }
- return (0);
- }
- #endif /* (EMS_USE_CRLF_COMBINATION || EMS_USE_ESC_COMBINATION) */
- #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 */
- /*****************************************************************************
- * FUNCTION
- * ArrangeEMSObjects
- * DESCRIPTION
- *
- * PARAMETERS
- * data [?]
- * RETURNS
- * void
- *****************************************************************************/
- void ArrangeEMSObjects(EMSData *data)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- EMSObject *current = data->listHead;
- EMSObject *start;
- U8 done;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- 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;
- }
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_EMS_input_box_add_string
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * s [?]
- * text_format [?]
- * RETURNS
- *
- *****************************************************************************/
- EMSTATUS gui_EMS_input_box_add_string(UI_EMS_input_box *b, U8 *s, EMSTextFormat *text_format)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 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;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (text_format == NULL)
- {
- r = AddString(b->data, s, num_char, NULL);
- }
- else if (b->data->CurrentTextFormatObj == NULL)
- {
- if (gui_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++;
- gui_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)
- {
- gui_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)
- {
- gui_EMS_cancel_current_position(b);
- r = EMS_NO_SPACE;
- }
- }
- #endif /* (EMS_USE_GSM_EXTENDED) */
- }
- else
- {
- /* MTK Terry for EMS_NO_MEMORY or other error cause */
- gui_EMS_change_DCS(b);
- }
- /* Temporary */
- /* ArrangeEMSObjects(b->data); */
- return (r);
- }
- #else /* (EMS_USE_DCS) */
- /*****************************************************************************
- * FUNCTION
- * gui_EMS_input_box_add_string
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * s [?]
- * text_format [?]
- * RETURNS
- *
- *****************************************************************************/
- EMSTATUS gui_EMS_input_box_add_string(UI_EMS_input_box *b, U8 *s, EMSTextFormat *text_format)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 num_char = 1;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (text_format == NULL)
- {
- return (AddString(b->data, s, num_char, NULL));
- }
- else if (b->data->CurrentTextFormatObj == NULL)
- {
- if (gui_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 /* (EMS_USE_DCS) */
- /*****************************************************************************
- * FUNCTION
- * gui_EMS_inputbox_add_object
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * type [IN]
- * objData [?]
- * predefined_object_number [IN]
- * RETURNS
- *
- *****************************************************************************/
- EMSTATUS gui_EMS_inputbox_add_object(UI_EMS_input_box *b, U8 type, EMSObjData *objData, U8 predefined_object_number)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- EMSTATUS r;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- r = AddObject(b->data, type, objData, (U8) 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 /* __MMI_HINDI_ALG__ */ // #ifdef __MMI_HINDI_ALG__
- #if(EMS_USE_DCS)
- if (r == EMS_OK)
- {
- S32 remaining_length;
- if (b->object_count == 0)
- {
- b->object_count++;
- gui_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)
- {
- gui_EMS_change_DCS(b);
- }
- UI_editor_play_tone_cannot_insert();
- return (EMS_NO_SPACE);
- }
- }
- #endif /* (EMS_USE_DCS) */
- b->saved_cursor_ax = -1;
- return (r);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_EMS_input_box_insert_character
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * c [IN]
- * RETURNS
- *
- *****************************************************************************/
- U8 gui_EMS_input_box_insert_character(UI_EMS_input_box *b, UI_character_type c)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- //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
- U16 ch = (U16) c;
- U8 s[2] = {0, 0};
- S32 remaining_length;
- U8 ret = EMS_OK;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- #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))
- {
- gui_EMS_input_box_remove_extension_character(b->data);
- if (EMSSetDCS(b->data, SMSAL_UCS2_DCS) != EMS_OK)
- {
- EMSSetDCS(b->data, SMSAL_DEFAULT_DCS);
- gui_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);
- gui_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 (gui_EMS_input_box_forward_cursor(b) == 1)
- {
- gui_EMS_cancel_current_position(b);
- }
- }
- #if(EMS_BYTE_ORDER_BIG_ENDIAN)
- s[0] = (ch & 0xff00) >> 8;
- s[1] = (ch & 0x00ff);
- #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */
- s[1] = (U8) (ch >> 8);
- s[0] = (U8) ch;
- #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */
- if (gui_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();
- }
-
- if (b->locate_cursor_flag)
- {
- gui_EMS_input_box_locate_cursor(b);
- }
-
- b->saved_cursor_ax = -1;
- return ret;
- }
- #ifdef __MMI_HINDI_ALG__
- U8 saved_last_skip_pos = 0;
- #endif
- //END TARUN PMT 20050128
- //START PMTFARHAD 20050224
- #if defined __MMI_LANG_HINDI__ && (defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__)
- S32 HINDI_PRESENT = 0;
- S32 ARABIC_PRESENT = 0;
- #endif /* defined __MMI_LANG_HINDI__ && defined __MMI_LANG_ARABIC__ */
- /* END PMTFARHAD 20050224 */
- /*****************************************************************************
- * FUNCTION
- * gui_EMS_input_box_insert_multitap_character
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * c [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_EMS_input_box_insert_multitap_character(UI_EMS_input_box *b, UI_character_type c)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 ch = (U16) c;
- U8 s[2] = {0, 0};
- EMSTextFormat text_format;
- S32 remaining_length;
- #ifdef __MMI_HINDI_ALG__
- EMSObject *bb;
- UI_character_type current_character1 = 0;
- U8 object_type_check1 = 0;
- EMSObject *o1;
- EMSPosition p1 = b->data->CurrentPosition;
- EMSData *data_chk_type1 = b->data;
- UI_character_type current_character2 = 0;
- U8 object_type_check2 = 0;
- /* PMT VIKAS GUPTA START 20051129 */
- U8 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__ */
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- #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 /* (0) */
- 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 /* (EMS_BYTE_ORDER_BIG_ENDIAN) */
- s[1] = (U8) (ch >> 8);
- s[0] = (U8) ch;
- #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */
- 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;
- U8 r;
- object_and_halant_check = b->data->listHead;
- /* r=gui_EMS_input_box_get_previous_object(b->data,&p,&c,¤t_object); */
- halant_after_object = gui_EMS_input_box_get_previous_object(b->data, &p, &c, ¤t_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);
- gui_EMS_cancel_current_position(b);
- }
- else
- #endif /* __MMI_HINDI_ALG__ */
- /* PMT VIKAS GUPTA END 20051129 */
- gui_EMS_cancel_current_position(b);
- #ifdef __MMI_HINDI_ALG__
- ems_cursor_pos_flag = 0;
- saved_last_skip_pos = 0;
- middle_ems_position = &(b->data->textBuffer[b->data->CurrentPosition.OffsetToText]);
- first_cons_ems_position = &(b->data->textBuffer[b->data->CurrentPosition.OffsetToText - 2]);
- #endif /* __MMI_HINDI_ALG__ */
- text_format = b->text_format;
- /* MTK Terry for EMS_NO_MEMORY or other error cause */
- if (gui_EMS_input_box_add_string(b, s, &text_format) != EMS_OK /*==EMS_NO_SPACE */ )
- {
- UI_editor_play_tone_cannot_insert();
- b->overflow_callback();
- }
- else
- {
- #ifdef __MMI_HINDI_ALG__
- if (!TestLastPosition(b->data, &(b->data->CurrentPosition)))
- {
- object_type_check1 = gui_EMS_input_box_get_next_object(data_chk_type1, &p1, ¤t_character1, &o1);
- }
- if ((UI_CHK_CONSONANT(*first_cons_ems_position)) && (UI_CHK_CONSONANT(*second_cons_ems_position))
- && (*middle_ems_position == 0x4d)
- && (*(first_cons_ems_position + 1) == 0x09) && (*(second_cons_ems_position + 1) == 0x09))
- {
- U8 skip_positions = 0;
- PU8 src_ems_pos = second_cons_ems_position;
- PU8 dest_ems_pos;
- /* dest_ems_pos = hf_get_next_cluster_p(b->data->textBuffer,src_ems_pos); */
- dest_ems_pos = hf_get_next_cluster_p(src_ems_pos, src_ems_pos);
- skip_positions = dest_ems_pos - src_ems_pos; /* Number of moves */
- skip_positions = skip_positions >> 1;
- saved_last_skip_pos = skip_positions;
- PRINT_INFORMATION_2((MMI_TRACE_INFO,
- "pixtel_UI_EMS_input_box_insert_multitap_character[skip_positions]:%d ",
- skip_positions));
- while (skip_positions--)
- {
- ForwardCurrentPosition(b->data, 1);
- }
- ems_cursor_pos_flag = 1;
- if (object_type_check1 == 2)
- {
- /* START TARUN 20050106 : */
- if (saved_last_skip_pos == 1)
- {
- /* To shift the images on cluster completion */
- bb = b->data->listTail;
- do
- {
- if (bb->OffsetToText == b->data->CurrentPosition.Object->OffsetToText)
- {
- bb->OffsetToText += (saved_last_skip_pos) * 2;
- }
- bb = bb->prev;
- } while (bb != NULL);
- ForwardCurrentPosition(b->data, saved_last_skip_pos);
- BackwardCurrentPositionSkipCR(b->data);
- }
- else if (saved_last_skip_pos > 1)
- {
- bb = b->data->listHead;
- do
- {
- if (bb->OffsetToText == b->data->CurrentPosition.Object->OffsetToText)
- {
- bb->OffsetToText += (saved_last_skip_pos) * 2;
- }
- bb = bb->next;
- } while (bb != NULL);
- ForwardCurrentPosition(b->data, saved_last_skip_pos);
- if (b->data->listHead == b->data->listTail)
- {
- BackwardCurrentPositionSkipCR(b->data);
- }
- else
- {
- BackwardCurrentPositionSkipCR(b->data);
- BackwardCurrentPositionSkipCR(b->data);
- }
- }
- }
- }
- /* PMT VIKAS GUPTA START 20051129 */
- if (check_for_halant)
- {
- ForwardCurrentPosition(b->data, total_no_of_objects);
- check_for_halant = 0;
- }
- /* PMT VIKAS GUPTA END 20051129 */
- #endif /* __MMI_HINDI_ALG__ */
- b->change_callback();
- }
- }
- else
- {
- #ifdef __MMI_HINDI_ALG__
- ems_cursor_pos_flag = 0;
- saved_last_skip_pos = 0;
- second_cons_ems_position = &(b->data->textBuffer[b->data->CurrentPosition.OffsetToText - 2]);
- object_type_check2 = gui_EMS_input_box_get_previous_object(data_chk_type2, &p2, ¤t_character2, &o2);
- /* PMT VIKAS GUPTA START 20051129 */
- if ((*second_cons_ems_position == 0x4d) && (object_type_check2 == 2))
- {
- check_for_halant = 1;
- }
- //PMT VIKAS GUPTA END 20051129
- //START TARUN PMT 20050128
- if ((object_type_check2 == 2) && (*second_cons_ems_position == 0x4d) && UI_CHK_CONSONANT(s[0]) && s[1] == 0x09)
- /* END TARUN PMT 20050128 */
- {
- {
- U8 skip_positions = 0;
- PU8 src_ems_pos = second_cons_ems_position;
- PU8 dest_ems_pos;
- dest_ems_pos = hf_get_next_cluster_p(src_ems_pos, src_ems_pos);
- skip_positions = dest_ems_pos - src_ems_pos;
- skip_positions = skip_positions >> 1;
- /* To shift the images on cluster completion */
- bb = b->data->listHead;
- do
- {
- if (bb->OffsetToText == b->data->CurrentPosition.Object->OffsetToText)
- {
- bb->OffsetToText += (skip_positions) * 2;
- }
- bb = bb->next;
- } while (bb != NULL);
- //START TARUN PMT 20050128
- //ForwardCurrentPosition(b->data,1);
- //END TARUN PMT 20050128
- }
- }
- #endif /* __MMI_HINDI_ALG__ */
- if (b->flags & UI_EMS_INPUT_BOX_OVERWRITE_MODE)
- {
- if (gui_EMS_input_box_forward_cursor(b) == 1)
- {
- gui_EMS_cancel_current_position(b);
- text_format = b->text_format;
- /* MTK Terry for EMS_NO_MEMORY or other error cause */
- if (gui_EMS_input_box_add_string(b, s, &text_format) != EMS_OK /*==EMS_NO_SPACE */ )
- {
- UI_editor_play_tone_cannot_insert();
- b->overflow_callback();
- }
- else
- {
- b->change_callback();
- }
- }
- /* to prevent to enable the multitap flag while reaching the max length(cannot add any char) */
- b->flags |= UI_EMS_INPUT_BOX_STATE_MULTITAP;
- }
- else
- {
- /* MTK Terry for EMS_NO_MEMORY or other error cause */
- if (gui_EMS_input_box_add_string(b, s, &b->text_format) != EMS_OK /*==EMS_NO_SPACE */ )
- {
- UI_editor_play_tone_cannot_insert();
- b->overflow_callback();
- }
- else
- {
- b->change_callback();
- /* MTK Elvis */
- b->flags |= UI_EMS_INPUT_BOX_STATE_MULTITAP;
- /* MTK end */
- }
- }
- //MTK Elvis
- //b->flags|=UI_EMS_INPUT_BOX_STATE_MULTITAP;
- //MTK end
- }
- #ifdef __MMI_HINDI_ALG__
- if (TestLastPosition(b->data, &(b->data->CurrentPosition)))
- {
- b->data->textBuffer[b->data->CurrentPosition.OffsetToText] = 0;
- b->data->textBuffer[b->data->CurrentPosition.OffsetToText + 1] = 0;
- }
- #endif /* __MMI_HINDI_ALG__ */
- gui_EMS_input_box_locate_cursor(b);
- b->saved_cursor_ax = -1;
- }
- /*****************************************************************************
- * FUNCTION
- * gui_EMS_input_box_confirm_multitap_character
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_EMS_input_box_confirm_multitap_character(UI_EMS_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- b->flags &= ~UI_EMS_INPUT_BOX_STATE_MULTITAP;
- }
- extern EMSTextFormat wgui_EMS_text_format;
- /*****************************************************************************
- * FUNCTION
- * gui_EMS_input_box_delete_all
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_EMS_input_box_delete_all(UI_EMS_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- #ifdef __MMI_MESSAGES_EMS__
- EMS_cancel_object_focus();
- #endif
- ResetCurrentPosition(b->data);
- /* MTK Elvis 20040611 donot plan tone while the EMS data is empty. */
- #if 0
- /* under construction !*/
- #endif /* 0 */
- /* MTK end */
- /* Probably a better way of doing this is to have a EMS library API */
- GoToEndPosition(b->data);
- /* START TARUN 20041230 */
- memset(b->data->textBuffer, 0, b->data->CurrentPosition.OffsetToText);
- /* END TARUN 20041230 */
- #if defined(__MMI_MESSAGES_CONCAT_SMS__)
- CancelCurrentPosition(b->data, (U16) (b->data->Reminder.maxUsableLenPerSeg * mmi_msg_get_seg_num()));
- #else
- CancelCurrentPosition(b->data, (U16) (EMS_DEFAULT_DCS_ALLOCATED_LENGTH));
- #endif
- gui_EMS_input_box_set_text_format_cursor_position(b);
- gui_EMS_input_box_locate_cursor(b);
- b->UCS2_count = 0;
- b->object_count = 0;
- /* MTK Joy added for clear all, 1228 */
- b->GSM_ext_count = 0;
- /* MTK end */
- gui_EMS_change_DCS(b);
- b->saved_cursor_ax = -1;