gui_inputs.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:662k
源码类别:
MTK
开发平台:
C/C++
- b->width = string_width + 4;
- b->height = string_height + 4;
- b->text_y = 2;
- x2 = x1 + b->width - 1; /* end x position of single line input box */
- y2 = y1 + b->height - 1; /* end y position of single line input box */
- gui_draw_rectangle(x1 + 1, y1 + 1, x2 - 1, y2 - 1, UI_COLOR_BLACK);
- }
- if (!(flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW) && !(flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_BACKGROUND))
- {
- gui_draw_filled_area(x1, y1, x2, y2, f);
- }
- /* PMT VIKAS START 20050524 */
- #ifdef __MMI_UI_TRANSPARENT_EFFECT__
- //PMT VIKAS START 20050630
- // remove the function call.
- // gui_single_line_enable_transparent_effect(&f); // to enable transparent effect flag for rest program
- //PMT VIKAS END 20050630
- #endif /* __MMI_UI_TRANSPARENT_EFFECT__ */
- /* PMT VIKAS END */
- gui_push_text_clip();
- switch (border_type)
- {
- case 0:
- gui_set_text_clip(x1, y1, x2, y2);
- gui_set_clip(x1, y1, x2, y2);
- break;
- case 1:
- gui_set_text_clip(x1 + 1, y1, x2 - 1, y2);
- gui_set_clip(x1 + 1, y1 + 1, x2 - 1, y2 - 1);
- break;
- case 2:
- gui_set_text_clip(x1 + 2, y1, x2 - 2, y2);
- gui_set_clip(x1 + 2, y1 + 2, x2 - 2, y2 - 2);
- break;
- }
- /* set text font */
- #if defined(__MMI_TOUCH_SCREEN__)
- gui_set_font(b->text_font);
- #else
- gui_set_font(&MMI_medium_font);
- #endif
- box_width = (x2 - x1 - 6);
- cy = y1 + 2;
- ch = y2 - y1 - 3;
- if (flags & UI_SINGLE_LINE_INPUT_BOX_FULL_HEIGHT_BLOCK_CURSOR)
- {
- sy1 -= 1;
- sy2 += 1;
- }
- if (current_text_p != NULL)
- {
- if (flags & UI_SINGLE_LINE_INPUT_BOX_STATE_MULTITAP)
- {
- selection_flag = 1;
- #ifdef __MMI_BIDI_ALG__
- if(arabic_char_flag) selection_flag = 0;
- #endif
- }
- if ((flags & UI_SINGLE_LINE_INPUT_BOX_OVERWRITE_MODE) && (!selection_flag))
- {
- overwrite_mode_flag = 1;
- #ifdef __MMI_BIDI_ALG__
- if(arabic_char_flag) selection_flag = 0;
- #endif
- }
- gui_measure_string_w((UI_string_type) current_text_p, text_gap, ¤t_text_width, &text_height);
- text_y = b->text_y = (b->height >> 1) - (gui_get_character_height() >> 1);
- if (text_y == 0)
- {
- text_y = 1;
- b->text_y = 1;
- }
- /* MTK added by Elvis and Manju */
- if (flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW)
- {
- /* MTK Elvis for R2L characters */
- if (default_direction == BIDI_L)
- {
- text_x = b->text_x;
- }
- else
- {
- text_x = box_width;
- }
- /* MTK end */
- }
- else
- {
- /* MTK Elvis for R2L characters */
- if (flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_SCROLLING)
- {
- if (default_direction == BIDI_L)
- {
- text_x = b->text_x;
- }
- else
- {
- text_x = box_width;
- }
- }
- else
- {
- if (default_direction == BIDI_L)
- {
- text_x = b->text_x + b->text_offset_x;
- }
- else
- {
- text_x = box_width - b->text_offset_x;
- }
- }
- /* MTK end */
- }
- /* MTK end */
- if (current_text_width <= box_width)
- {
- if (flags & UI_SINGLE_LINE_INPUT_BOX_CENTER_JUSTIFY)
- {
- text_x = (b->width >> 1) - (current_text_width >> 1);
- }
- else if (flags & UI_SINGLE_LINE_INPUT_BOX_RIGHT_JUSTIFY)
- {
- text_x = (box_width - current_text_width + 4);
- }
- }
- if ((flags & UI_SINGLE_LINE_INPUT_BOX_RIGHT_JUSTIFY) && (text_x + current_text_width) < box_width)
- {
- text_x = box_width - current_text_width + 4;
- }
- total_width = 0;
- #ifdef __MMI_HINDI_ALG__
- single_editor_moves = 1;
- #endif
- while (!done)
- {
- previous_text_p = current_text_p;
- if (flags & UI_SINGLE_LINE_INPUT_BOX_WORD_HIGHLIGHT)
- {
- if (current_text_p == b->highlight_start_position)
- {
- #ifdef __MMI_BIDI_ALG__
- if(arabic_char_flag)
- word_highlight=0;
- else
- #endif
- word_highlight = 1;
- }
- if (current_text_p == b->highlight_end_position)
- {
- word_highlight = 0;
- }
- }
- /* MTK Elvis for second word highlight */
- if (flags & UI_SINGLE_LINE_INPUT_BOX_SECOND_WORD_HIGHLIGHT)
- {
- if (current_text_p == (b->second_highlight_start_position))
- {
- second_word_highlight = 1;
- }
- if (current_text_p == (b->second_highlight_end_position))
- {
- second_word_highlight = 0;
- }
- }
- /* MTK end */
- #ifdef __MMI_HINDI_ALG__
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "pixtel_UI_show_single_line_input_box[single_editor_moves]:%d ",
- single_editor_moves));
- while (single_editor_moves--)
- #endif /* __MMI_HINDI_ALG__ */
- {
- UI_STRING_GET_NEXT_CHARACTER(current_text_p, current_character); /* get next character */
- }
- #if defined (__MMI_LANG_ARABIC__) || defined (__MMI_LANG_PERSIAN__)
- temp_p = current_text_p;
- UI_STRING_GET_NEXT_CHARACTER(temp_p, next_char);
- if (IS_ARABIC_CHARACTER(current_character) && IS_ARABIC_CHARACTER(next_char))
- {
- text_gap = 0;
- }
- else
- {
- text_gap = b->text_gap;
- }
- #endif /* defined (__MMI_LANG_ARABIC__) || defined (__MMI_LANG_PERSIAN__) */
- /* MTK end */
- #if defined(__MMI_LANG_VIETNAMESE__)
- if ((current_character > 0x0040) && (current_character < 0x01B1))
- {
- UI_STRING_GET_NEXT_CHARACTER(current_text_p, next_character); /* get next character */
- tone_mark = mmi_viet_tone_mark(next_character);
- if (VIET_TONE_NONE != tone_mark)
- {
- viet_vowel = mmi_viet_vowel_letter(current_character);
- if (VIET_VOWEL_NONE != viet_vowel)
- {
- current_character = mmi_viet_combine_vowel_tone(viet_vowel, tone_mark);
- }
- else
- {
- UI_STRING_GET_PREVIOUS_CHARACTER(current_text_p, next_character);
- }
- }
- else
- {
- UI_STRING_GET_PREVIOUS_CHARACTER(current_text_p, next_character);
- }
- }
- #endif /* defined(__MMI_LANG_VIETNAMESE__) */
- #if defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__)
- if (IS_ARABIC_CHARACTER(current_character))
- {
- U32 idx = 0;
- U32 ligature_move = 0;
- UI_character_type dummy_c_arabic = 0;
- if(BIDI_done_flag)
- {
- idx =(current_text_p - visual_str)/2-1;
- }
- else
- {
- idx =(current_text_p - b->text)/2-1;
- }
- current_character = (UI_character_type)shaping_str[OrgToSha[idx]];
- while(idx < unshaped_text_len-1)
- {
- if(OrgToSha[idx] == OrgToSha[idx+1])
- {
- ligature_move++;
- }
- else
- {
- break;
- }
- idx++;
- }
- while(ligature_move > 0)
- {
- UI_STRING_GET_NEXT_CHARACTER(current_text_p, dummy_c_arabic);
- ligature_move--;
- }
- }
- #endif /* defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__) */
- if (UI_STRING_END_OF_STRING_CHARACTER(current_character))
- {
- break;
- }
- if (!UI_STRING_LINE_BREAK_CHARACTER(current_character)) /* check for null or space character */
- {
- if (flags & UI_SINGLE_LINE_INPUT_BOX_MASK_CHARACTERS) /* check if current caharcter is a mask character */
- { /* single line passwd support */
- if (!((flags & UI_SINGLE_LINE_INPUT_BOX_STATE_MULTITAP) && (current_text_p == b_current_text_p)))
- {
- current_character = mask_character;
- }
- }
- if (RequireToMoveCursor(pre_character, current_character))
- {
- #ifdef __MMI_HINDI_ALG__
- /* Move pointer by the cluster width */
- single_line_curr_p = hf_get_next_cluster_p(single_line_prev_p, single_line_prev_p);
- single_editor_moves = single_line_curr_p - single_line_prev_p; /* Number of moves */
- if (single_editor_moves <= 0)
- {
- single_editor_moves = 1; /* At least 1 */
- }
- else
- {
- single_editor_moves = single_editor_moves >> 1;
- }
- /* Calculate the width of current cluster as well as english character */
- if (flags & UI_SINGLE_LINE_INPUT_BOX_MASK_CHARACTERS) /* check if current caharcter is a mask character */
- {
- character_width = gui_get_character_width(mask_character);
- }
- else
- {
- character_width = hf_size_of_current_cluster(single_line_prev_p, single_line_curr_p, 0);
- }
- PRINT_INFORMATION_2((MMI_TRACE_INFO, "pixtel_UI_show_single_line_input_box[character_width]:%d ",
- character_width));
- previous_text_p = single_line_prev_p;
- single_line_prev_p = single_line_curr_p;
- #else /* __MMI_HINDI_ALG__ */
- /* single line passwd support */
- if (flags & UI_SINGLE_LINE_INPUT_BOX_MASK_CHARACTERS) /* check if current caharcter is a mask character */
- {
- character_width = gui_get_character_width(mask_character);
- }
- else
- {
- character_width = gui_get_character_width(current_character); /* get character width in pixels */
- }
- #endif /* __MMI_HINDI_ALG__ */
- }
- else
- {
- character_width = 0;
- }
- if (!(flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW))
- {
- text_color = b_normal_text_color;
- if(default_direction != BIDI_L)
- {
- cx=x1+text_x-character_width;
- }
- else
- {
- cx=x1+text_x;
- }
- if (word_highlight)
- {
- if (flags & UI_SINGLE_LINE_INPUT_BOX_SWITCH_WORD_HIGHLIGHT_COLOR)
- {
- gui_fill_rectangle(
- cx,
- sy1,
- cx + character_width,
- sy2,
- gui_color(255, 0, 0));
- }
- else
- {
- gui_fill_rectangle(cx, sy1, cx + character_width, sy2, b_selection_color);
- }
- text_color = b_selection_text_color;
- }
- if (second_word_highlight)
- {
- gui_fill_rectangle(cx, sy1, cx + character_width, sy2, b_selection_color);
- text_color = b_selection_text_color;
- }
- if (!(flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW))
- {
- if (flags & UI_SINGLE_LINE_INPUT_BOX_SHOW_BLOCK_CURSOR)
- {
- if (previous_text_p == b_current_text_p)
- {
- if (overwrite_mode_flag) /* if overwrite mode */
- {
- gui_fill_rectangle(
- x1 + text_x,
- sy1,
- x1 + text_x + character_width,
- sy2,
- b_selection_color);
- text_color = b_selection_text_color;
- }
- if (default_direction == BIDI_L)
- {
- b->cursor_x = text_x - 1;
- }
- else
- {
- b->cursor_x = text_x + 1;
- }
- cursor_displayed_flag = 1;
- }
- else if (current_text_p == b_current_text_p)
- {
- if (selection_flag)
- {
- gui_fill_rectangle(
- x1 + text_x,
- sy1,
- x1 + text_x + character_width,
- sy2,
- b_selection_color);
- text_color = b_selection_text_color;
- }
- }
- }
- else
- {
- if (previous_text_p == b_current_text_p)
- {
- if (overwrite_mode_flag)
- {
- gui_fill_rectangle(
- x1 + text_x,
- sy1,
- x1 + text_x + character_width,
- sy2,
- b_selection_color);
- text_color = b_selection_text_color;
- }
- /* Added condition to disable vertical cursor drawing in character highlight mode */
- if (!(flags & UI_SINGLE_LINE_INPUT_BOX_CHARACTER_HIGHLIGHT))
- {
- gui_single_line_input_box_show_cursor(b, x1 + text_x - 1, cy, ch); /* show cursor */
- }
- if (default_direction == BIDI_L)
- {
- b->cursor_x = text_x - 1;
- }
- else
- {
- b->cursor_x = text_x + 1;
- }
- cursor_displayed_flag = 1;
- }
- else if (current_text_p == b_current_text_p)
- {
- if (selection_flag)
- {
- if (b->ext_flags & UI_SINGLE_LINE_INPUT_BOX_EXT_FIXED_GRID)
- {
- gui_fill_rectangle(
- x1 + text_x,
- sy1,
- x1 + text_x + b->grid_width,
- sy2,
- b_selection_color);
- }
- else
- {
- gui_fill_rectangle(
- x1 + text_x,
- sy1,
- x1 + text_x + character_width,
- sy2,
- b_selection_color);
- }
- text_color = b_selection_text_color;
- }
- }
- }
- }
- if (flags & UI_SINGLE_LINE_INPUT_BOX_VIEW_FULL_CHARACTERS)
- {
- if ((cx >= x1) && ((cx + character_width) <= x2))
- {
- if (b->ext_flags & UI_SINGLE_LINE_INPUT_BOX_EXT_FIXED_GRID)
- {
- gui_move_text_cursor(cx + ((b->grid_width - character_width) >> 1), y1 + text_y);
- gdi_draw_line(
- cx + b->grid_width,
- sy1,
- cx + b->grid_width,
- sy2,
- gdi_act_color_from_rgb(255, 112, 125, 240));
- }
- else
- {
- gui_move_text_cursor(cx, y1 + text_y);
- }
- gui_set_text_color(text_color);
- //gui_print_character((UI_character_type)current_character);
- //MTK Elvis for stacked character
- gui_print_stacked_character(current_character, pre2_character, pre_character);
- pre2_character = pre_character;
- pre_character = current_character;
- /* MTK end */
- }
- } /* MTK Leo add 1125, trucate too long number/name in call list. */
- else if (flags & UI_SINGLE_LINE_INPUT_BOX_TRUNCATE_CONTENT)
- {
- if ((cx >= x1) && (cx + 21) >= x2)
- {
- gui_set_text_color(text_color);
- gui_move_text_cursor(cx, y1 + text_y);
- gui_print_character((UI_character_type) '.');
- gui_move_text_cursor(cx + 7, y1 + text_y);
- gui_print_character((UI_character_type) '.');
- gui_move_text_cursor(cx + 14, y1 + text_y);
- gui_print_character((UI_character_type) '.');
- break;
- }
- else if ((cx >= x1) && ((cx + character_width) <= x2))
- {
- gui_move_text_cursor(cx, y1 + text_y);
- gui_set_text_color(text_color);
- //gui_print_character((UI_character_type)current_character);
- //MTK Elvis for stacked character
- gui_print_stacked_character(current_character, pre2_character, pre_character);
- pre2_character = pre_character;
- pre_character = current_character;
- /* MTK end */
- }
- /* MTK Leo end 1125 */
- }
- else if (flags & UI_SINGLE_LINE_INPUT_BOX_TRUNCATE_CONTENT_NO_BRIEF) /* 022405 Calvin added */
- {
- if ((cx >= x1) && (cx + 7) >= x2)
- {
- gui_set_text_color(text_color);
- gui_move_text_cursor(cx, y1 + text_y);
- if (character_width < 7 &&
- UI_STRING_END_OF_STRING_CHARACTER1((UI_character_type)
- ((*((current_text_p) + 0)) |
- ((*((current_text_p) + 1)) << 8))))
- {
- gui_print_stacked_character(current_character, pre2_character, pre_character);
- pre2_character = pre_character;
- pre_character = current_character;
- }
- else
- {
- gui_print_character((UI_character_type) ' ');
- }
- break;
- }
- else if ((cx >= x1) && ((cx + character_width) <= x2))
- {
- gui_move_text_cursor(cx, y1 + text_y);
- gui_set_text_color(text_color);
- //gui_print_character((UI_character_type)current_character);
- //MTK Elvis for stacked character
- gui_print_stacked_character(current_character, pre2_character, pre_character);
- pre2_character = pre_character;
- pre_character = current_character;
- /* MTK end */
- }
- }
- else
- {
- if ((cx + character_width) >= x1 && (cx <= x2))
- {
- #if defined(__MMI_HINDI_ALG__)
- PU8 prev_single_line_temp_p;
- if (parse_hindi)
- {
- reset_hindi_bordered_params();
- }
- get_bordered_text_x(&cx, current_character, text_y);
- parse_hindi = 0;
- #endif /* defined(__MMI_HINDI_ALG__) */
- gui_move_text_cursor(cx, y1 + text_y); /* move text cursor */
- gui_set_text_color(text_color); /* set text color */
- /* gui_print_character((UI_character_type)current_character);//print text */
- #ifdef __MMI_HINDI_ALG__
- if (single_line_temp_p == (b->last_position_p))
- {
- goto enddisp;
- }
- /* Performance issue */
- prev_single_line_temp_p = single_line_temp_p;
- single_line_temp_p = hf_get_next_cluster_p(single_line_temp_p, single_line_temp_p);
- if (hf_get_current_cluster
- (prev_single_line_temp_p, single_line_temp_p, single_line_disp_cluster))
- {
- S32 disp_clus_len = pfnUnicodeStrlen((PS8) single_line_disp_cluster);
- MMI_ASSERT(!(disp_clus_len > MAX_EDITOR_DISP_LEN));
- /* To avoid rule appln in showstring */
- hf_disable_hindi_rules_parsing();
- hf_padding_value(0);
- if (!UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
- {
- if (flags & UI_SINGLE_LINE_INPUT_BOX_MASK_CHARACTERS) /* check if current caharcter is a mask character */
- {
- S32 str_len = UCS2Strlen((const S8*)single_line_disp_cluster);
- S32 i;
- for (i = 0; i < str_len; i++)
- { /* single line passwd support */
- if ((flags & UI_SINGLE_LINE_INPUT_BOX_STATE_MULTITAP) &&
- (current_text_p == b_current_text_p))
- {
- single_line_disp_cluster[i] = current_character;
- }
- else
- {
- single_line_disp_cluster[i] = mask_character;
- }
- }
- }
- /* START FARHAD PMT 20050211 */
- cancelWidth = 1;
- ShowString(
- UI_text_x,
- UI_text_y,
- *UI_font,
- 0,
- (U8*) (single_line_disp_cluster),
- UI_text_height);
- cancelWidth = 0;
- /* END FARHAD PMT 20050211 */
- }
- else
- {
- if (flags & UI_SINGLE_LINE_INPUT_BOX_MASK_CHARACTERS) /* check if current caharcter is a mask character */
- {
- S32 str_len = UCS2Strlen((const S8*)single_line_disp_cluster);
- S32 i;
- for (i = 0; i < str_len; i++)
- { /* single line passwd support */
- if ((flags & UI_SINGLE_LINE_INPUT_BOX_STATE_MULTITAP) &&
- (current_text_p == b_current_text_p))
- {
- single_line_disp_cluster[i] = current_character;
- }
- else
- {
- single_line_disp_cluster[i] = mask_character;
- }
- }
- }
- /* START FARHAD PMT 20050211 */
- cancelWidth = 1;
- ShowString(
- UI_text_x,
- UI_text_y,
- *UI_font,
- 0,
- (U8*) (single_line_disp_cluster),
- UI_text_height);
- cancelWidth = 0;
- /* END FARHAD PMT 20050211 */
- }
- /* Open it again */
- hf_enable_hindi_rules_parsing();
- hf_padding_def_value();
- }
- else
- #endif /* __MMI_HINDI_ALG__ */
- {
- gui_print_stacked_character(current_character, pre2_character, pre_character);
- }
- #ifdef __MMI_HINDI_ALG__
- enddisp:
- memset(single_line_disp_cluster, 0, sizeof(single_line_disp_cluster));
- #endif /* __MMI_HINDI_ALG__ */
- }
- /* START FARHAD PIXTELMTK 20050217 */
- #if defined __MMI_HINDI_ALG__
- else
- {
- single_line_temp_p += (single_editor_moves * 2);
- }
- #endif /* defined __MMI_HINDI_ALG__ */
- /* END FARHAD PIXTELMTK 20050217 */
- }
- }
- else if ((previous_text_p == b_current_text_p) && (((-1) == move_to_x) && ((-1) == move_to_y)))
- {
- if (default_direction == BIDI_L)
- {
- b->cursor_x = text_x - 1;
- }
- else
- {
- b->cursor_x = text_x + 1;
- }
- cursor_displayed_flag = 1;
- }
- else if ((((-1) != move_to_x) || ((-1) != move_to_y)) && (!set_cursor_flag))
- {
- int cursor_with = 0;
- if (b->ext_flags & UI_SINGLE_LINE_INPUT_BOX_EXT_FIXED_GRID)
- {
- cursor_with = b->grid_width;
- }
- else
- {
- cursor_with = character_width;
- }
- if ((b->text_offset_x + b->x + text_x + text_gap + cursor_with /* character_width */ ) > move_to_x)
- {
- b->current_text_p = previous_text_p;
- if (default_direction == BIDI_L)
- {
- b->cursor_x = text_x - 1;
- }
- else
- {
- b->cursor_x = text_x + 1;
- }
- set_cursor_flag = 1;
- }
- }
- if (default_direction == BIDI_L)
- {
- if (RequireToMoveCursor(pre_character, current_character))
- {
- #ifdef __MMI_HINDI_ALG__
- if (UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
- {
- if (b->ext_flags & UI_SINGLE_LINE_INPUT_BOX_EXT_FIXED_GRID)
- {
- }
- else
- {
- text_x += character_width;
- total_width += character_width;
- }
- }
- else
- #endif /* __MMI_HINDI_ALG__ */
- {
- if (b->ext_flags & UI_SINGLE_LINE_INPUT_BOX_EXT_FIXED_GRID)
- {
- text_x += b->grid_width;
- total_width += b->grid_width;
- }
- else
- {
- text_x += text_gap + character_width;
- total_width += text_gap + character_width;
- }
- }
- }
- else
- {
- if (b->ext_flags & UI_SINGLE_LINE_INPUT_BOX_EXT_FIXED_GRID)
- {
- text_x += b->grid_width;
- total_width += b->grid_width;
- }
- else
- {
- text_x += /* text_gap */ +character_width;
- total_width += /* text_gap */ +character_width;
- }
- }
- }
- else
- {
- text_x -= (character_width + text_gap);
- total_width += text_gap + character_width;
- }
- pre2_character = pre_character;
- pre_character = current_character;
- }
- }
- if ((((-1) != move_to_x) || ((-1) != move_to_y)) && (!set_cursor_flag))
- {
- b->current_text_p = previous_text_p;
- if (default_direction == BIDI_L)
- {
- b->cursor_x = text_x - 1;
- }
- else
- {
- b->cursor_x = text_x + 1;
- }
- set_cursor_flag = 1;
- }
- b->last_position_p = current_text_p;
- /* W06.15 b->cursor_x is not correct when moving cursor by pen */
- if (!cursor_displayed_flag && (((-1) == move_to_x) && ((-1) == move_to_y)))
- {
- if (!(flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW) &&
- !(flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW))
- {
- if (flags & UI_SINGLE_LINE_INPUT_BOX_SHOW_BLOCK_CURSOR)
- {
- gui_fill_rectangle(x1 + text_x, sy1, x1 + text_x + character_width, sy2, b_selection_color);
- }
- else
- {
- /* Added condition to disable vertical cursor drawing in character highlight mode */
- if (!(flags & UI_SINGLE_LINE_INPUT_BOX_CHARACTER_HIGHLIGHT))
- {
- gui_single_line_input_box_show_cursor(b, x1 + text_x - 1, cy, ch); /* show cursor of single line input box */
- }
- }
- }
- if (default_direction == BIDI_L)
- {
- b->cursor_x = text_x - 1;
- }
- else
- {
- b->cursor_x = text_x + 1;
- }
- }
- }
- b->text_width = total_width;
- gui_pop_text_clip();
- gui_pop_clip();
- /* MTK Elvis for R2L characters */
- /* PMT RAKESH START 20061006 */
- #if defined __MMI_HINDI_ALG__
- restore_current_language_for_hindi_rules();
- #endif
- /* PMT RAKESH END 20061006 */
- #ifdef __MMI_BIDI_ALG__
- if (!(flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW) && (((b->text_length >> 1) - 1) != 0) && arabic_char_flag)
- {
- b->text = temp_text_pt;
- b->current_text_p = temp_cursor_p;
- b->last_position_p = b->text + (current_text_p - visual_str);
- if (flags & UI_SINGLE_LINE_INPUT_BOX_WORD_HIGHLIGHT)
- {
- b->highlight_start_position = temp_hilight_start;
- b->highlight_end_position = temp_hilight_end;
- }
- }
- #endif /* __MMI_BIDI_ALG__ */
- }
- /*****************************************************************************
- * FUNCTION
- * gui_destroy_single_line_input_box
- * DESCRIPTION
- * frees the buffer allocated for the box and resets the input box
- *
- * This doesn't free the single-line inputbox object. It only
- * frees the buffer that is used to store the text.
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_destroy_single_line_input_box(single_line_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- b->text_length = 0;
- b->allocated_length = 0;
- b->available_length = 0;
- b->UCS2_count = 0;
- gui_free(b->text);
- b->current_text_p = b->text;
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_locate_cursor
- * DESCRIPTION
- * calculate the position ofcusror of single line input box
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_single_line_input_box_locate_cursor(single_line_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /* MTK Elvis for R2L characters */
- #ifdef __MMI_BIDI_ALG__
- PMT_BIDI_TYPES default_direction = BIDI_L;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- bidi_get_char_type(b->text, (U8*) & default_direction);
- #endif /* __MMI_BIDI_ALG__ */
- #ifdef __MMI_BIDI_ALG__
- if (default_direction != BIDI_R && default_direction != AL)
- {
- #endif /* __MMI_BIDI_ALG__ */
- if ((b->cursor_x + (b->width >> 2) + b->text_offset_x) > (b->width - b->text_x))
- {
- b->text_offset_x = -(b->cursor_x + (b->width >> 2) - (b->width - b->text_x));
- if ((b->text_offset_x + b->text_width) < (b->width - 6))
- {
- b->text_offset_x = (b->width - 6) - (b->text_width);
- }
- }
- else if ((b->cursor_x + b->text_offset_x + 2) < (b->text_x + (b->width >> 2)))
- {
- b->text_offset_x = -(b->cursor_x - 2 - (b->width >> 2));
- }
- if (b->text_offset_x > 0)
- {
- b->text_offset_x = 0;
- }
- #ifdef __MMI_BIDI_ALG__
- }
- else
- {
- if ((b->cursor_x + b->text_offset_x) < 2)
- {
- b->text_offset_x = (b->width - 10) - (b->text_width);
- }
- }
- #endif /* __MMI_BIDI_ALG__ */
- /* MTK end */
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_delete_character
- * DESCRIPTION
- * Deletes a character before the current cursor position (Backspace)
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_single_line_input_box_delete_character(single_line_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- UI_buffer_type current_text_p;
- UI_buffer_type previous_text_p;
- UI_character_type current_character = (UI_character_type) - 1;
- UI_character_type dummy_c = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- current_text_p = b->current_text_p;
- previous_text_p = b->current_text_p;
- if (previous_text_p == b->text)
- {
- if (!(b->flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_TONES))
- {
- UI_editor_play_tone_cannot_change();
- }
- return;
- }
- UI_STRING_GET_PREVIOUS_CHARACTER(previous_text_p, dummy_c); /* get previous caharcter */
- b->text_length -= ((S32) current_text_p - (S32) previous_text_p); /* update text length ..decrease value */
- b->current_text_p = previous_text_p; /* set teh current_tet_p equalto previous */
- if (b->flags & UI_SINGLE_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
- {
- UI_TEST_UCS2_DECREMENT_COUNT_SET_LENGTH(dummy_c, b->UCS2_count, b->allocated_length, b->available_length);
- }
- while (!UI_STRING_END_OF_STRING_CHARACTER(current_character))
- {
- UI_STRING_GET_NEXT_CHARACTER(current_text_p, current_character);
- UI_STRING_INSERT_CHARACTER(previous_text_p, current_character);
- }
- if (b->flags & UI_SINGLE_LINE_INPUT_BOX_STATE_MULTITAP)
- {
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_STATE_MULTITAP;
- }
- b->flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- #ifdef __MMI_HINDI_ALG__
- /* For handling the inbetweeen halanth deletion */
- if ((b->current_text_p - b->text) >= 4)
- {
- UI_buffer_type temp_single_line_cursor_p;
- temp_single_line_cursor_p = b->current_text_p;
- if ((UI_CHK_CONSONANT(*(temp_single_line_cursor_p - 4))) && (UI_CHK_CONSONANT(*(temp_single_line_cursor_p))) &&
- (*(temp_single_line_cursor_p - 2) == 0x4d))
- {
- U8 single_deletion = 0;
- PU8 single_line_first_pos_p = temp_single_line_cursor_p;
- PU8 single_line_second_pos_p;
- single_line_second_pos_p = hf_get_next_cluster_p(single_line_first_pos_p, single_line_first_pos_p);
- single_deletion = single_line_second_pos_p - single_line_first_pos_p; /* Number of moves */
- single_deletion = single_deletion >> 1;
- while (single_deletion--)
- {
- UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
- }
- }
- }
- #endif /* __MMI_HINDI_ALG__ */
- gui_show_single_line_input_box(b); /* show single line input box */
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_single_line_input_box_locate_cursor(b); /* locate the cursor position of single lie input box */
- b->validation_callback(b->text, b->current_text_p, (b->text_length >> 1) - 1);
- b->change_callback();
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_delete_current_character
- * DESCRIPTION
- * Deletes a character at the current cursor position (Delete)
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_single_line_input_box_delete_current_character(single_line_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- UI_buffer_type current_text_p;
- UI_buffer_type previous_text_p;
- UI_character_type current_character = (UI_character_type) - 1;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- current_text_p = b->current_text_p;
- previous_text_p = b->current_text_p;
- UI_STRING_GET_NEXT_CHARACTER(current_text_p, current_character); /* get next character */
- if (!UI_STRING_END_OF_STRING_CHARACTER(current_character)) /* check for end of string */
- {
- if (b->flags & UI_SINGLE_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
- {
- UI_TEST_UCS2_DECREMENT_COUNT_SET_LENGTH(
- current_character,
- b->allocated_length,
- b->UCS2_count,
- b->available_length);
- }
- while (!UI_STRING_END_OF_STRING_CHARACTER(current_character))
- {
- UI_STRING_GET_NEXT_CHARACTER(current_text_p, current_character);
- UI_STRING_INSERT_CHARACTER(previous_text_p, current_character);
- }
- b->text_length -= ((S32) current_text_p - (S32) previous_text_p);
- if (b->flags & UI_SINGLE_LINE_INPUT_BOX_STATE_MULTITAP)
- {
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_STATE_MULTITAP;
- }
- b->flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_show_single_line_input_box(b); /* show single line input box */
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_single_line_input_box_locate_cursor(b); /* locate cursor postion */
- b->validation_callback(b->text, b->current_text_p, (b->text_length >> 1) - 1); /* call validation callback func */
- b->change_callback();
- }
- else
- {
- if (!(b->flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_TONES))
- {
- UI_editor_play_tone_cannot_change(); /* play tone */
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_delete_all
- * DESCRIPTION
- * Deletes all characters
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_single_line_input_box_delete_all(single_line_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- UI_character_type c;
- UI_buffer_type p = b->text;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- UI_STRING_GET_NEXT_CHARACTER(p, c);
- UI_UNUSED_PARAMETER(c);
- /* MTK Elvis 20040611 donot play tone while text buffer is zero */
- #if 0
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #endif /* 0 */
- /* MTK end */
- gui_single_line_input_box_clear(b); /* initialize single line input box to default */
- b->flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_show_single_line_input_box(b); /* show single line input box */
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_single_line_input_box_locate_cursor(b); /* locate cursor position of sigle lien input box */
- b->validation_callback(b->text, b->current_text_p, (b->text_length >> 1) - 1);
- b->change_callback();
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_toggle_insert_mode
- * DESCRIPTION
- * Toggles between Insert and Overwrite modes
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_single_line_input_box_toggle_insert_mode(single_line_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (b->flags & UI_SINGLE_LINE_INPUT_BOX_OVERWRITE_MODE)
- {
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_OVERWRITE_MODE;
- }
- else
- {
- b->flags |= UI_SINGLE_LINE_INPUT_BOX_OVERWRITE_MODE;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_insert_character
- * DESCRIPTION
- * Inserts a character at the current cursor position
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * c [IN] Is the character to be inserted
- * RETURNS
- * void
- *****************************************************************************/
- void gui_single_line_input_box_insert_character(single_line_input_box *b, UI_character_type c)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- UI_buffer_type p1, p2;
- UI_character_type old_c, dummy_c = 0;
- U8 flag = 0;
- U32 b_flags = b->flags;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if ((b_flags & UI_SINGLE_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH) && (b->UCS2_count == 0) &&
- UI_TEST_UCS2_CHARACTER(c))
- {
- if ((b_flags & UI_SINGLE_LINE_INPUT_BOX_ONE_LESS_CHARACTER) &&
- (b->text_length >= UI_UCS2_STRING_HALF_LENGTH_MINUS_ONE(b->available_length)))
- {
- if (!(b->flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_TONES))
- {
- UI_editor_play_tone_cannot_insert();
- }
- return;
- }
- else if (b->text_length >= UI_UCS2_STRING_HALF_LENGTH(b->available_length))
- {
- if (!(b->flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_TONES))
- {
- UI_editor_play_tone_cannot_insert();
- }
- return;
- }
- }
- p1 = p2 = b->current_text_p;
- if (b_flags & UI_SINGLE_LINE_INPUT_BOX_OVERWRITE_MODE)
- {
- UI_STRING_GET_NEXT_CHARACTER(p1, old_c); /* get next caharater */
- if ((p1 == b->last_position_p) && ((b->last_position_p - b->text) >= b->available_length))
- {
- return;
- }
- if (!UI_STRING_END_OF_STRING_CHARACTER(old_c)) /* check for end of character */
- {
- UI_STRING_INSERT_CHARACTER(p2, c); /* insert caharactr */
- if (b_flags & UI_SINGLE_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
- {
- if (b_flags & UI_SINGLE_LINE_INPUT_BOX_ONE_LESS_CHARACTER)
- {
- UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE2(
- old_c,
- c,
- b->UCS2_count,
- b->allocated_length,
- b->available_length);
- }
- else
- {
- UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH(
- old_c,
- c,
- b->UCS2_count,
- b->allocated_length,
- b->available_length);
- }
- }
- b->current_text_p = p2;
- //MTK Elvis for R2L characters
- //It is not required to increase the length while in overwrite mode
- //b->text_length+=ENCODING_LENGTH; //incraese length of text
- //MTK end
- }
- else
- {
- p1 = b->current_text_p;
- UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c); /* get next character */
- while (!UI_STRING_END_OF_STRING_CHARACTER(c)) /* check for end of character */
- {
- UI_STRING_GET_NEXT_CHARACTER(p1, old_c); /* get next character */
- UI_STRING_INSERT_CHARACTER(p2, c); /* insert character */
- c = old_c;
- }
- UI_STRING_INSERT_CHARACTER(p2, c);
- if (b_flags & UI_SINGLE_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
- {
- if (b_flags & UI_SINGLE_LINE_INPUT_BOX_ONE_LESS_CHARACTER)
- {
- UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE2(
- old_c,
- c,
- b->UCS2_count,
- b->allocated_length,
- b->available_length);
- }
- else
- {
- UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH(
- old_c,
- c,
- b->UCS2_count,
- b->allocated_length,
- b->available_length);
- }
- }
- b->text_length += ((S32) p2 - (S32) p1);
- }
- }
- else
- {
- if ((b->last_position_p - b->text) >= (b->available_length))
- {
- if (!(b->flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_TONES))
- {
- UI_editor_play_tone_cannot_insert();
- }
- return;
- }
- /* check if leading zero flag is set or not ,
- if leading zero flag is false and lengthis equal to 4 and if character is not zero then a chatracter is insert */
- if ((numeric_leading_zero == FALSE) && (b->text_length == 4))
- {
- if (b->text[0] == 48 && (c != 46))
- {
- p1 = b->text;
- flag = 1;
- UI_STRING_INSERT_CHARACTER(p1, c); /* insert a charcter */
- }
- }
- if (flag == 0)
- {
- UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c); /* get next character */
- if (b_flags & UI_SINGLE_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
- {
- if (b_flags & UI_SINGLE_LINE_INPUT_BOX_ONE_LESS_CHARACTER)
- {
- UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH_TYPE2(
- c,
- b->UCS2_count,
- b->allocated_length,
- b->available_length);
- }
- else
- {
- UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH(c, b->UCS2_count, b->allocated_length, b->available_length);
- }
- }
- while (!UI_STRING_END_OF_STRING_CHARACTER(c)) /* check for end of string */
- {
- UI_STRING_GET_NEXT_CHARACTER(p1, old_c); /* get next character */
- UI_STRING_INSERT_CHARACTER(p2, c);
- c = old_c;
- }
- UI_STRING_INSERT_CHARACTER(p2, c);
- b->text_length += ((S32) p2 - (S32) p1);
- }
- }
- b->flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_show_single_line_input_box(b); /* show single lien input box */
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_single_line_input_box_locate_cursor(b); /* locate cursor psotion */
- b->validation_callback(b->text, b->current_text_p, (b->text_length >> 1) - 1);
- b->change_callback();
- UI_UNUSED_PARAMETER(dummy_c);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_test_overflow
- * DESCRIPTION
- * check for overflow..if the length is equal to availabel lengt or not
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * RETURNS
- * byte return true if length is equa to available length else false
- *****************************************************************************/
- U8 gui_single_line_input_box_test_overflow(single_line_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* MTK Elvis to allow user to change the current hilighted multitap character */
- if (b->flags & UI_SINGLE_LINE_INPUT_BOX_STATE_MULTITAP)
- {
- if ((b->last_position_p - b->text) == (b->available_length))
- {
- return (0);
- }
- else if ((b->last_position_p - b->text) > (b->available_length))
- {
- return (1);
- }
- }
- else
- {
- if ((b->last_position_p - b->text) >= (b->available_length))
- {
- return (1);
- }
- }
- /* MTK end */
- return (0);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_test_first_position
- * DESCRIPTION
- * check for overflow..if the length is equal to availabel lengt or not
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * RETURNS
- * byte return true if length is equa to available length else false
- *****************************************************************************/
- U8 gui_single_line_input_box_test_first_position(single_line_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (b->current_text_p == b->text)
- {
- return (1);
- }
- return (0);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_test_last_position
- * DESCRIPTION
- * check for overflow..if the length is equal to availabel lengt or not
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * RETURNS
- * byte return true if length is equa to available length else false
- *****************************************************************************/
- U8 gui_single_line_input_box_test_last_position(single_line_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- UI_character_type dummy_c = 0;
- UI_buffer_type current_text_p = b->current_text_p;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- UI_STRING_GET_NEXT_CHARACTER(current_text_p, dummy_c);
- UI_UNUSED_PARAMETER(dummy_c);
- if (current_text_p == b->last_position_p)
- {
- return (1);
- }
- return (0);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_test_last_character_position
- * DESCRIPTION
- *
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * RETURNS
- * byte
- *****************************************************************************/
- U8 gui_single_line_input_box_test_last_character_position(single_line_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- UI_character_type dummy_c = 0;
- UI_buffer_type current_text_p = b->current_text_p;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- UI_STRING_GET_NEXT_CHARACTER(current_text_p, dummy_c);
- if (current_text_p == b->last_position_p)
- {
- return (1);
- }
- UI_STRING_GET_NEXT_CHARACTER(current_text_p, dummy_c);
- UI_UNUSED_PARAMETER(dummy_c);
- if (current_text_p == b->last_position_p)
- {
- return (1);
- }
- return (0);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_test_last_position_overflow
- * DESCRIPTION
- *
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * RETURNS
- * byte
- *****************************************************************************/
- U8 gui_single_line_input_box_test_last_position_overflow(single_line_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 flag1 = 0;
- U8 flag2 = 0;
- UI_character_type dummy_c = 0;
- UI_buffer_type current_text_p = b->current_text_p;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- UI_STRING_GET_NEXT_CHARACTER(current_text_p, dummy_c);
- UI_UNUSED_PARAMETER(dummy_c);
- if (current_text_p == b->last_position_p)
- {
- flag1 = 1;
- }
- if ((b->last_position_p - b->text) >= (b->available_length))
- {
- flag2 = 1;
- }
- if (flag1 && flag2)
- {
- return (1);
- }
- return (0);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_get_text_length
- * DESCRIPTION
- * Return text length
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * RETURNS
- * S32 :- return text length
- *****************************************************************************/
- S32 gui_single_line_input_box_get_text_length(single_line_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return (((b->text_length) >> 1) - 1);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_insert_multitap_character
- * DESCRIPTION
- * Inserts a multitap character at the current cursor position
- *
- * This function is normally used as the input_callback
- * function with multitap input objects
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * c [IN] Is the character to be inserted
- * RETURNS
- * void
- *****************************************************************************/
- void gui_single_line_input_box_insert_multitap_character(single_line_input_box *b, UI_character_type c)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- UI_buffer_type p1, p2;
- UI_character_type old_c, dummy_c = 0;
- U32 b_flags = b->flags;
- #ifdef __MMI_HINDI_ALG__
- UI_buffer_type middle_p, first_cons_p, second_cons_p;
- static U8 single_line_cursor_pos = 0;
- #endif /* __MMI_HINDI_ALG__ */
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if ((b_flags & UI_SINGLE_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH) && (b->UCS2_count == 0) &&
- UI_TEST_UCS2_CHARACTER(c))
- {
- if ((b_flags & UI_SINGLE_LINE_INPUT_BOX_ONE_LESS_CHARACTER) &&
- (b->text_length >= UI_UCS2_STRING_HALF_LENGTH_MINUS_ONE(b->available_length)))
- {
- if (!(b->flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_TONES))
- {
- UI_editor_play_tone_cannot_insert();
- }
- return;
- }
- else if (b->text_length >= UI_UCS2_STRING_HALF_LENGTH(b->available_length))
- {
- if (!(b->flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_TONES))
- {
- UI_editor_play_tone_cannot_insert();
- }
- return;
- }
- }
- if (b_flags & UI_SINGLE_LINE_INPUT_BOX_STATE_MULTITAP)
- {
- UI_STRING_GET_PREVIOUS_CHARACTER(b->current_text_p, dummy_c);
- #ifdef __MMI_HINDI_ALG__
- if (single_line_cursor_pos && ((c == 49) || (c == 0x901) || (c == 0x902))) /* Only when multitap input is 1 */
- {
- UI_STRING_GET_PREVIOUS_CHARACTER(save_cursor_text_p, dummy_c);
- b->current_text_p = save_cursor_text_p;
- single_line_cursor_pos = 0;
- }
- single_line_cursor_pos = 0;
- #endif /* __MMI_HINDI_ALG__ */
- p1 = p2 = b->current_text_p;
- #ifdef __MMI_HINDI_ALG__
- middle_p = p1;
- first_cons_p = p1 - 2;
- #endif /* __MMI_HINDI_ALG__ */
- UI_STRING_GET_NEXT_CHARACTER(p1, old_c); /* get next xharacter */
- if (!UI_STRING_END_OF_STRING_CHARACTER(old_c)) /* check for end of string */
- {
- UI_STRING_INSERT_CHARACTER(p2, c); /* insert character */
- if (b_flags & UI_SINGLE_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
- {
- if (b_flags & UI_SINGLE_LINE_INPUT_BOX_ONE_LESS_CHARACTER)
- {
- UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE2(
- old_c,
- c,
- b->UCS2_count,
- b->allocated_length,
- b->available_length);
- }
- else
- {
- UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH(
- old_c,
- c,
- b->UCS2_count,
- b->allocated_length,
- b->available_length);
- }
- }
- b->current_text_p = p2;
- #ifdef __MMI_HINDI_ALG__
- second_cons_p = b->current_text_p;
- if ((UI_CHK_CONSONANT(*first_cons_p)) && (UI_CHK_CONSONANT(*second_cons_p)) && (*middle_p == 0x4d)) /* tarun4 */
- {
- U8 single_line_skip_moves = 0;
- PU8 single_line_first_ptr = second_cons_p;
- PU8 single_line_second_ptr;
- save_cursor_text_p = b->current_text_p;
- single_line_second_ptr = hf_get_next_cluster_p(single_line_first_ptr, single_line_first_ptr);
- single_line_skip_moves = single_line_second_ptr - single_line_first_ptr; /* Number of moves */
- single_line_skip_moves = single_line_skip_moves >> 1;
- while (single_line_skip_moves--)
- {
- UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
- }
- single_line_cursor_pos = 1;
- }
- #endif /* __MMI_HINDI_ALG__ */
- }
- else
- {
- p1 = b->current_text_p;
- UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c); /* get next character */
- while (!UI_STRING_END_OF_STRING_CHARACTER(c))
- {
- UI_STRING_GET_NEXT_CHARACTER(p1, old_c);
- UI_STRING_INSERT_CHARACTER(p2, c);
- c = old_c;
- }
- UI_STRING_INSERT_CHARACTER(p2, c);
- if (b_flags & UI_SINGLE_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
- {
- if (b_flags & UI_SINGLE_LINE_INPUT_BOX_ONE_LESS_CHARACTER)
- {
- UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE2(
- old_c,
- c,
- b->UCS2_count,
- b->allocated_length,
- b->available_length);
- }
- else
- {
- UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH(
- old_c,
- c,
- b->UCS2_count,
- b->allocated_length,
- b->available_length);
- }
- }
- b->text_length += ((S32) p2 - (S32) p1);
- }
- }
- else
- {
- #ifdef __MMI_HINDI_ALG__
- single_line_cursor_pos = 0;
- #endif
- p1 = p2 = b->current_text_p;
- if (b_flags & UI_SINGLE_LINE_INPUT_BOX_OVERWRITE_MODE)
- {
- UI_STRING_GET_NEXT_CHARACTER(p1, old_c);
- if ((p1 == b->last_position_p) && ((b->last_position_p - b->text) >= b->available_length))
- {
- if (!(b->flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_TONES))
- {
- UI_editor_play_tone_cannot_insert();
- }
- return;
- }
- if (!UI_STRING_END_OF_STRING_CHARACTER(old_c))
- {
- UI_STRING_INSERT_CHARACTER(p2, c);
- if (b_flags & UI_SINGLE_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
- {
- if (b_flags & UI_SINGLE_LINE_INPUT_BOX_ONE_LESS_CHARACTER)
- {
- UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE2(
- old_c,
- c,
- b->UCS2_count,
- b->allocated_length,
- b->available_length);
- }
- else
- {
- UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH(
- old_c,
- c,
- b->UCS2_count,
- b->allocated_length,
- b->available_length);
- }
- }
- b->current_text_p = p2;
- }
- else
- {
- p1 = b->current_text_p;
- UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
- while (!UI_STRING_END_OF_STRING_CHARACTER(c))
- {
- UI_STRING_GET_NEXT_CHARACTER(p1, old_c);
- UI_STRING_INSERT_CHARACTER(p2, c);
- c = old_c;
- }
- UI_STRING_INSERT_CHARACTER(p2, c);
- if (b_flags & UI_SINGLE_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
- {
- if (b_flags & UI_SINGLE_LINE_INPUT_BOX_ONE_LESS_CHARACTER)
- {
- UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE2(
- old_c,
- c,
- b->UCS2_count,
- b->allocated_length,
- b->available_length);
- }
- else
- {
- UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH(
- old_c,
- c,
- b->UCS2_count,
- b->allocated_length,
- b->available_length);
- }
- }
- b->text_length += ((S32) p2 - (S32) p1);
- }
- }
- else
- {
- int flag = 0;
- if ((b->last_position_p - b->text) >= (b->available_length))
- {
- if (!(b->flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_TONES))
- {
- UI_editor_play_tone_cannot_insert();
- }
- return;
- }
- /* W05.33 if leading zero flag is false and lengthis equal to 4 and if character is not zero then a chatracter is insert */
- if ((numeric_leading_zero == FALSE) && (b->text_length == 4))
- {
- if (b->text[0] == 48 && (c != 46))
- {
- p1 = b->text;
- flag = 1;
- UI_STRING_INSERT_CHARACTER(p1, c); /* insert a charcter */
- }
- }
- if (0 == flag)
- {
- UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
- if (b_flags & UI_SINGLE_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
- {
- if (b_flags & UI_SINGLE_LINE_INPUT_BOX_ONE_LESS_CHARACTER)
- {
- UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH_TYPE2(
- c,
- b->UCS2_count,
- b->allocated_length,
- b->available_length);
- }
- else
- {
- UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH(
- c,
- b->UCS2_count,
- b->allocated_length,
- b->available_length);
- }
- }
- while (!UI_STRING_END_OF_STRING_CHARACTER(c))
- {
- UI_STRING_GET_NEXT_CHARACTER(p1, old_c);
- UI_STRING_INSERT_CHARACTER(p2, c);
- c = old_c;
- }
- UI_STRING_INSERT_CHARACTER(p2, c);
- b->text_length += ((S32) p2 - (S32) p1);
- }
- }
- b->flags |= UI_SINGLE_LINE_INPUT_BOX_STATE_MULTITAP;
- }
- b->flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_show_single_line_input_box(b);
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_single_line_input_box_locate_cursor(b);
- b->validation_callback(b->text, b->current_text_p, (b->text_length >> 1) - 1);
- b->change_callback();
- UI_UNUSED_PARAMETER(dummy_c);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_confirm_multitap_character
- * DESCRIPTION
- * Completes the multitap input sequence.
- *
- * This function is normally used as the input_complete_callback
- * function with multitap input objects
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_single_line_input_box_confirm_multitap_character(single_line_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_STATE_MULTITAP;
- }
- /* PMT dara added for multitap thai */
- #ifdef __MMI_MULTITAP_THAI__
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_get_previous_character
- * DESCRIPTION
- * get the previous character
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * c [?]
- * means(?) [OUT] None, 1 means have one, save in c
- * RETURNS
- * void
- *****************************************************************************/
- U8 gui_single_line_input_box_get_previous_character(single_line_input_box *b, UI_character_type *c)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (b->text == NULL)
- {
- return 0;
- }
- if (b->current_text_p == b->text)
- {
- return 0;
- }
- *c = (*(b->current_text_p - 2)) | (*(b->current_text_p - 1)) << 8;
- return 1;
- }
- #endif /* __MMI_MULTITAP_THAI__ */
- /* msz065_20050420 Peng Hua add for multitap thai input method end */
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_previous
- * DESCRIPTION
- * Moves the cursor to the previous character
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_single_line_input_box_previous(single_line_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- UI_character_type dummy_c = 0;
- #if defined(__MMI_LANG_VIETNAMESE__)
- UI_character_type previous_unicode = 0;
- viet_tone_mark tone_mark = VIET_TONE_NONE;
- viet_vowel_letter viet_vowel = VIET_VOWEL_NONE;
- #endif /* defined(__MMI_LANG_VIETNAMESE__) */
- /* MTK Steven 20050505 */
- #if defined(__MMI_LANG_THAI__)
- UI_character_type pre_one_char = 0;
- UI_character_type pre_two_char = 0;
- UI_character_type pre_three_char = 0;
- #endif /* defined(__MMI_LANG_THAI__) */
- /* MTK End */
- #ifdef __MMI_HINDI_ALG__
- UI_buffer_type single_line_check_text_p = b->current_text_p;
- #endif
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (b->text == NULL)
- {
- if (!(b->flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_TONES))
- {
- UI_editor_play_tone_cannot_navigate();
- }
- return;
- }
- if (b->current_text_p == b->text)
- {
- if (!(b->flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_TONES))
- {
- UI_editor_play_tone_cannot_navigate();
- }
- return;
- }
- #ifdef __MMI_HINDI_ALG__
- UI_STRING_GET_PREVIOUS_CHARACTER(single_line_check_text_p, dummy_c); /* get previous character */
- /* If Hindi Character */
- if (UI_HINDI_CHARACTER_UCS2_RANGE(dummy_c))
- {
- /* Move by a syllable rather than by a character as in English */
- b->current_text_p = (U8*) hf_get_prev_cluster_p(b->text, b->current_text_p);
- }
- else
- #endif /* __MMI_HINDI_ALG__ */
- {
- UI_STRING_GET_PREVIOUS_CHARACTER(b->current_text_p, dummy_c); /* get previous character */
- }
- #if defined(__MMI_LANG_VIETNAMESE__)
- if ((dummy_c >= 0x0300) && (dummy_c <= 0x0323))
- {
- UI_STRING_GET_PREVIOUS_CHARACTER(b->current_text_p, previous_unicode); /* get next character */
- viet_vowel = mmi_viet_vowel_letter(previous_unicode);
- if (VIET_VOWEL_NONE != viet_vowel)
- {
- tone_mark = mmi_viet_tone_mark(dummy_c);
- if (VIET_TONE_NONE != tone_mark)
- {
- dummy_c = mmi_viet_combine_vowel_tone(viet_vowel, tone_mark);
- }
- else
- {
- UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, previous_unicode);
- }
- }
- else
- {
- UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, previous_unicode);
- }
- }
- #endif /* defined(__MMI_LANG_VIETNAMESE__) */
- /* MTK Steven 20050505 */
- #if defined(__MMI_LANG_THAI__)
- if (isThaiChar(dummy_c))
- {
- UI_STRING_GET_PREVIOUS_CHARACTER(b->current_text_p, pre_one_char);
- if (isThaiChar(pre_one_char))
- {
- if (!RequireToMoveCursor(pre_one_char, dummy_c))
- {
- if (b->current_text_p != b->text)
- {
- UI_STRING_GET_PREVIOUS_CHARACTER(b->current_text_p, pre_two_char);
- if (isThaiChar(pre_two_char))
- {
- if (!RequireToMoveCursor(pre_two_char, pre_one_char))
- {
- if (b->current_text_p != b->text)
- {
- UI_STRING_GET_PREVIOUS_CHARACTER(b->current_text_p, pre_three_char);
- if (isThaiChar(pre_three_char))
- {
- if (RequireToMoveCursor(pre_three_char, pre_two_char))
- {
- UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
- }
- }
- else
- {
- UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
- }
- }
- }
- else
- {
- UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
- }
- }
- else
- {
- UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
- }
- }
- }
- else
- {
- UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
- }
- }
- else
- {
- UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
- }
- }
- #endif /* defined(__MMI_LANG_THAI__) */
- /* MTK End */
- /* Begin BIRD arabic 0908 */
- #if defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__)
- if (IS_ARABIC_CHARACTER(dummy_c))
- {
- U16 idx;
- idx = (b->current_text_p - b->text + 2 )/2-1;
- while(idx > 0)
- {
- if(OrgToSha[idx] == OrgToSha[idx-1])
- {
- UI_STRING_GET_PREVIOUS_CHARACTER(b->current_text_p, dummy_c);
- }
- else
- {
- break;
- }
- idx--;
- }
- }
- #endif
- /* End BIRD arabic 0908 */
- b->flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_show_single_line_input_box(b); /* show single line input box */
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_single_line_input_box_locate_cursor(b); /* locate cursor */
- UI_UNUSED_PARAMETER(dummy_c);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_previous_steps
- * DESCRIPTION
- * Moves the cursor to the character
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * steps [IN]
- * RETURNS
- * S32
- *****************************************************************************/
- S32 gui_single_line_input_box_previous_steps(single_line_input_box *b, S32 steps)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- UI_character_type dummy_c;
- S32 count = 0;
- U8 done = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (b->text == NULL)
- {
- if (!(b->flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_TONES))
- {
- UI_editor_play_tone_cannot_navigate();
- }
- return (count);
- }
- if (b->current_text_p == b->text)
- {
- if (!(b->flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_TONES))
- {
- UI_editor_play_tone_cannot_navigate();
- }
- return (count);
- }
- while (!done)
- {
- if (b->current_text_p == b->text)
- {
- break;
- }
- UI_STRING_GET_PREVIOUS_CHARACTER(b->current_text_p, dummy_c);
- count++;
- if (count >= steps)
- {
- break;
- }
- }
- if (count != steps)
- {
- if (!(b->flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_TONES))
- {
- UI_editor_play_tone_cannot_navigate();
- }
- }
- b->flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_show_single_line_input_box(b);
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_single_line_input_box_locate_cursor(b);
- UI_UNUSED_PARAMETER(dummy_c);
- return (count);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_next
- * DESCRIPTION
- * Moves the cursor to the next character
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_single_line_input_box_next(single_line_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- UI_buffer_type current_text_p = b->current_text_p;
- UI_character_type current_character;
- #if defined(__MMI_LANG_VIETNAMESE__)
- UI_character_type next_unicode = 0;
- viet_tone_mark tone_mark = VIET_TONE_NONE;
- viet_vowel_letter viet_vowel = VIET_VOWEL_NONE;
- #endif /* defined(__MMI_LANG_VIETNAMESE__) */
- /* MTK Steven 20050505 */
- #if defined(__MMI_LANG_THAI__)
- UI_character_type next_one_char = 0;
- UI_character_type next_two_char = 0;
- UI_character_type next_three_char = 0;
- #endif /* defined(__MMI_LANG_THAI__) */
- /* MTK End */
- #ifdef __MMI_HINDI_ALG__
- UI_buffer_type check_single_line_text_p = b->current_text_p;
- #endif
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* text buffer is empty and want to navigate next --> play error tone if not disable tones */
- if (b->text == NULL)
- {
- if (!(b->flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_TONES))
- {
- UI_editor_play_tone_cannot_navigate();
- }
- return;
- }
- #ifdef __MMI_HINDI_ALG__
- UI_STRING_GET_NEXT_CHARACTER(check_single_line_text_p, current_character); /* get previous character */
- /* If Hindi Character */
- if (UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
- {
- /* Move by a syllable rather than by a character as in English */
- current_text_p = hf_get_next_cluster_p(b->current_text_p, b->current_text_p);
- }
- else
- #endif /* __MMI_HINDI_ALG__ */
- {
- UI_STRING_GET_NEXT_CHARACTER(current_text_p, current_character); /* get next character */
- }
- #if defined(__MMI_LANG_VIETNAMESE__)
- if ((current_character > 0x0040) && (current_character < 0x01B1))
- {
- UI_STRING_GET_NEXT_CHARACTER(current_text_p, next_unicode); /* get next character */
- tone_mark = mmi_viet_tone_mark(next_unicode);
- if (VIET_TONE_NONE != tone_mark)
- {
- viet_vowel = mmi_viet_vowel_letter(current_character);
- if (VIET_VOWEL_NONE != viet_vowel)
- {
- current_character = mmi_viet_combine_vowel_tone(viet_vowel, tone_mark);
- }
- else
- {
- UI_STRING_GET_PREVIOUS_CHARACTER(current_text_p, next_unicode);
- }
- }
- else
- {
- UI_STRING_GET_PREVIOUS_CHARACTER(current_text_p, next_unicode);
- }
- }
- #endif /* defined(__MMI_LANG_VIETNAMESE__) */
- /* MTK Steven 20050505 */
- #if defined(__MMI_LANG_THAI__)
- if (isThaiChar(current_character) && *current_text_p != ' ')
- {
- UI_STRING_GET_NEXT_CHARACTER(current_text_p, next_one_char);
- if (isThaiChar(next_one_char))
- {
- if (!RequireToMoveCursor(current_character, next_one_char))
- {
- if (*current_text_p == ' ')
- {
- current_character = next_one_char;
- }
- else
- {
- UI_STRING_GET_NEXT_CHARACTER(current_text_p, next_two_char);
- if (isThaiChar(next_two_char))
- {
- if (!RequireToMoveCursor(next_one_char, next_two_char))
- {
- if (*current_text_p == ' ')
- {
- current_character = next_two_char;
- }
- else
- {
- UI_STRING_GET_NEXT_CHARACTER(current_text_p, next_three_char);
- if (isThaiChar(next_three_char))
- {
- if (!RequireToMoveCursor(next_two_char, next_three_char))
- {
- current_character = next_three_char;
- }
- else
- {
- UI_STRING_GET_PREVIOUS_CHARACTER(current_text_p, current_character);
- }
- }
- else
- {
- UI_STRING_GET_PREVIOUS_CHARACTER(current_text_p, current_character);
- }
- }
- }
- else
- {
- UI_STRING_GET_PREVIOUS_CHARACTER(current_text_p, current_character);
- }
- }
- else
- {
- UI_STRING_GET_PREVIOUS_CHARACTER(current_text_p, current_character);
- }
- }
- }
- else
- {
- UI_STRING_GET_PREVIOUS_CHARACTER(current_text_p, current_character);
- }
- }
- else
- {
- UI_STRING_GET_PREVIOUS_CHARACTER(current_text_p, current_character);
- }
- }
- #endif /* defined(__MMI_LANG_THAI__) */
- /* MTK End */
- #if defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__)
- if (IS_ARABIC_CHARACTER(current_character))
- {
- U16 idx;
- idx = (current_text_p - b->text)/2-1;
- while(idx < unshaped_text_len)
- {
- if(OrgToSha[idx] == OrgToSha[idx+1])
- {
- UI_STRING_GET_NEXT_CHARACTER(current_text_p, current_character);
- }
- else
- {
- break;
- }
- idx++;
- }
- }
- #endif
- /* if current character is end of string and want to navigate next --> play error tone if not disable tones */
- if (UI_STRING_END_OF_STRING_CHARACTER(current_character))
- {
- if (!(b->flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_TONES))
- {
- UI_editor_play_tone_cannot_navigate();
- }
- return;
- }
- b->current_text_p = current_text_p;
- b->flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_show_single_line_input_box(b);
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_single_line_input_box_locate_cursor(b);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_next_steps
- * DESCRIPTION
- * Moves the cursor to the next character
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * steps [IN]
- * RETURNS
- * S32
- *****************************************************************************/
- S32 gui_single_line_input_box_next_steps(single_line_input_box *b, S32 steps)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- UI_buffer_type current_text_p = b->current_text_p;
- UI_character_type current_character;
- S32 count = 0;
- U8 done = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (0 == steps)
- {
- return 0;
- }
- if (b->text == NULL)
- {
- if (!(b->flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_TONES))
- {
- UI_editor_play_tone_cannot_navigate();
- }
- return (count);
- }
- while (!done)
- {
- UI_STRING_GET_NEXT_CHARACTER(current_text_p, current_character);
- if (UI_STRING_END_OF_STRING_CHARACTER(current_character))
- {
- break;
- }
- count++;
- if (count >= steps)
- {
- break;
- }
- }
- if (count != steps)
- {
- if (!(b->flags & UI_SINGLE_LINE_INPUT_BOX_DISABLE_TONES))
- {
- UI_editor_play_tone_cannot_navigate();
- }
- }
- b->current_text_p = current_text_p;
- b->flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_show_single_line_input_box(b);
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_single_line_input_box_locate_cursor(b);
- return (count);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_resize_single_line_input_box
- * DESCRIPTION
- * Changes the size of the single-line inputbox.
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * width [IN] Is the new width
- * height [IN] Is the new height
- * RETURNS
- * void
- *****************************************************************************/
- void gui_resize_single_line_input_box(single_line_input_box *b, S32 width, S32 height)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- b->width = width;
- b->height = height;
- /* Autocalculate the text position based on font */
- if (b->flags & UI_SINGLE_LINE_INPUT_BOX_CENTER_Y)
- {
- S32 string_height;
- gui_set_font(b->text_font);
- string_height = gui_get_character_height();
- b->text_y = (height >> 1) - (string_height >> 1);
- }
- else
- {
- b->text_y = 2;
- }
- b->flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_show_single_line_input_box(b); /* show single inout box */
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_single_line_input_box_locate_cursor(b); /* locate cursor */
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_goto_first_character
- * DESCRIPTION
- * Move the cursor to first chahrcter
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_single_line_input_box_goto_first_character(single_line_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- b->current_text_p = b->text;
- b->flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_show_single_line_input_box(b); /* show single line input box */
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_single_line_input_box_locate_cursor(b); /* locate cursor */
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_goto_last_character
- * DESCRIPTION
- * Move the cursor to last chahrcter
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_single_line_input_box_goto_last_character(single_line_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- UI_character_type dummy_c = 0;
- U8 done = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- b->current_text_p = b->text;
- if (b->text != NULL)
- {
- while (!done)
- {
- UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
- if (UI_STRING_END_OF_STRING_CHARACTER(dummy_c))
- {
- break;
- }
- }
- if (b->current_text_p != b->text)
- {
- UI_STRING_GET_PREVIOUS_CHARACTER(b->current_text_p, dummy_c);
- }
- }
- b->flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_show_single_line_input_box(b); /* show single line inut box */
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_single_line_input_box_locate_cursor(b); /* locate cursor */
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_highlight_cursor_end
- * DESCRIPTION
- * Move the cursor to last chahrcter
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * RETURNS
- * S32 count return the number of charcters traverse
- *****************************************************************************/
- S32 gui_single_line_input_box_highlight_cursor_end(single_line_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- UI_buffer_type saved_current_position = b->current_text_p;
- UI_buffer_type current_position = b->current_text_p;
- UI_buffer_type previous_position;
- UI_buffer_type last_position_p = b->last_position_p;
- U8 done = 0;
- UI_character_type current_character;
- S32 count = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- UI_STRING_GET_PREVIOUS_CHARACTER(last_position_p, current_character);
- /* Move cursor backwards until a break character is encountered */
- while (!done)
- {
- previous_position = current_position;
- if (current_position == b->text)
- {
- break;
- }
- UI_STRING_GET_PREVIOUS_CHARACTER(current_position, current_character);
- count++;
- if (UI_STRING_SPACE_CHARACTER(current_character))
- {
- break; /* check for space */
- }
- }
- b->highlight_start_position = previous_position;
- current_position = saved_current_position;
- /* Move cursor forwards until a break character is encountered */
- if (current_position >= last_position_p)
- {
- done = 1;
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_WORD_HIGHLIGHT;
- }
- else
- {
- UI_STRING_GET_NEXT_CHARACTER(current_position, current_character); /* get next character */
- UI_STRING_GET_PREVIOUS_CHARACTER(current_position, current_character); /* get previous charcter */
- if (UI_STRING_SPACE_CHARACTER(current_character)) /* check for space */
- {
- done = 1;
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_WORD_HIGHLIGHT;
- }
- else
- {
- done = 0;
- b->flags |= UI_SINGLE_LINE_INPUT_BOX_WORD_HIGHLIGHT;
- }
- }
- while (!done)
- {
- if (current_position >= last_position_p)
- {
- break;
- }
- UI_STRING_GET_NEXT_CHARACTER(current_position, current_character);
- count++;
- if (UI_STRING_SPACE_CHARACTER(current_character))
- {
- UI_STRING_GET_PREVIOUS_CHARACTER(current_position, current_character);
- break;
- }
- }
- b->highlight_end_position = current_position;
- b->current_text_p = current_position;
- b->flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_show_single_line_input_box(b); /* show single line input box */
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_single_line_input_box_locate_cursor(b); /* locate cursor */
- return (count);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_highlight_cursor_number
- * DESCRIPTION
- * Move the cursor to last chahrcter
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * numOfChar [IN]
- * RETURNS
- * S32 count return the number of charcters traverse
- *****************************************************************************/
- S32 gui_single_line_input_box_highlight_cursor_number(single_line_input_box *b, S32 numOfChar)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- UI_buffer_type saved_current_position = b->current_text_p;
- UI_buffer_type current_position = b->current_text_p;
- /* UI_buffer_type previous_position; */
- UI_character_type current_character;
- S32 count = 0, i;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (i = 0; i < numOfChar; i++)
- {
- /* previous_position=current_position; */
- if (current_position == b->text)
- {
- break;
- }
- UI_STRING_GET_PREVIOUS_CHARACTER(current_position, current_character); /* get previous charcter */
- count++;
- }
- b->highlight_start_position = current_position;
- current_position = saved_current_position;
- b->highlight_end_position = current_position;
- b->current_text_p = current_position;
- b->flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_show_single_line_input_box(b); /* show single lien input box */
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_single_line_input_box_locate_cursor(b); /* locate cursor */
- UI_UNUSED_PARAMETER(current_character);
- return (count);
- }
- /* for second word highlight */
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_highlight_cursor_number_backward
- * DESCRIPTION
- *
- * PARAMETERS
- * b [?]
- * numOfChar [IN]
- * RETURNS
- *
- *****************************************************************************/
- S32 gui_single_line_input_box_highlight_cursor_number_backward(single_line_input_box *b, S32 numOfChar)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- UI_buffer_type saved_current_position = b->current_text_p;
- UI_buffer_type current_position = b->current_text_p;
- /* UI_buffer_type previous_position; */
- UI_character_type current_character = 0xff;
- S32 count = 0, i;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (i = 0; i < numOfChar; i++)
- {
- /* previous_position=current_position; */
- if (UI_STRING_END_OF_STRING_CHARACTER(current_character))
- {
- break;
- }
- UI_STRING_GET_NEXT_CHARACTER(current_position, current_character); /* get previous charcter */
- count++;
- }
- b->second_highlight_end_position = current_position;
- current_position = saved_current_position;
- b->second_highlight_start_position = current_position;
- b->current_text_p = current_position;
- b->flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_show_single_line_input_box(b); /* show single lien input box */
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_single_line_input_box_locate_cursor(b); /* locate cursor */
- return (count);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_highlight_cursor_start
- * DESCRIPTION
- * Move the cursor to last chahrcter
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * RETURNS
- * S32 count return the number of charcters traverse
- *****************************************************************************/
- S32 gui_single_line_input_box_highlight_cursor_start(single_line_input_box *b)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- UI_buffer_type saved_current_position = b->current_text_p;
- UI_buffer_type current_position = b->current_text_p;
- UI_buffer_type previous_position;
- UI_buffer_type last_position_p = b->last_position_p;
- U8 done = 0;
- UI_character_type current_character;
- S32 count = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (current_position == b->text)
- {
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_WORD_HIGHLIGHT;
- return (0);
- }
- UI_STRING_GET_PREVIOUS_CHARACTER(current_position, current_character); /* get previous charcter */
- /* Move cursor forwards until a break character is encountered */
- while (!done)
- {
- if (current_position >= last_position_p)
- {
- break;
- }
- UI_STRING_GET_NEXT_CHARACTER(current_position, current_character);
- count++;
- if (UI_STRING_SPACE_CHARACTER(current_character))
- {
- UI_STRING_GET_PREVIOUS_CHARACTER(current_position, current_character);
- break;
- }
- }
- b->highlight_end_position = current_position;
- current_position = saved_current_position;
- /* Move cursor backwards until a break character is encountered */
- if (current_position == b->text)
- {
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_WORD_HIGHLIGHT;
- return (0);
- }
- UI_STRING_GET_PREVIOUS_CHARACTER(current_position, current_character);
- if (UI_STRING_SPACE_CHARACTER(current_character)) /* check for space */
- {
- UI_STRING_GET_NEXT_CHARACTER(current_position, current_character);
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_WORD_HIGHLIGHT;
- return (0);
- }
- else
- {
- done = 0;
- b->flags |= UI_SINGLE_LINE_INPUT_BOX_WORD_HIGHLIGHT;
- }
- while (!done)
- {
- previous_position = current_position;
- if (current_position == b->text)
- {
- break;
- }
- UI_STRING_GET_PREVIOUS_CHARACTER(current_position, current_character);
- count++;
- if (UI_STRING_SPACE_CHARACTER(current_character))
- {
- break;
- }
- }
- b->highlight_start_position = previous_position;
- b->current_text_p = previous_position;
- b->flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_show_single_line_input_box(b); /* show single line input box */
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_single_line_input_box_locate_cursor(b); /* locate cursor */
- return (count);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_single_line_input_box_insert_string
- * DESCRIPTION
- * insert a string in single lien input box at particular poistion
- * PARAMETERS
- * b [IN] Is the single-line inputbox object
- * s [IN] String to insert
- * o [IN] Index
- * RETURNS
- * S32
- *****************************************************************************/
- S32 gui_single_line_input_box_insert_string(single_line_input_box *b, UI_string_type s, S32 o)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- UI_buffer_type p1, p2;
- UI_character_type old_c, dummy_c = 0;
- U32 b_flags = b->flags;
- U8 done = 0;
- S32 count = 0;
- UI_character_type c;
- UI_buffer_type text = (UI_buffer_type) s;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- while (!done)
- {
- UI_STRING_GET_NEXT_CHARACTER(text, c);
- if (UI_STRING_END_OF_STRING_CHARACTER(c))
- {
- done = 1;
- break;
- }
- if ((b_flags & UI_SINGLE_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH) && (b->UCS2_count == 0) &&
- UI_TEST_UCS2_CHARACTER(c))
- {
- if ((b_flags & UI_SINGLE_LINE_INPUT_BOX_ONE_LESS_CHARACTER) &&
- (b->text_length >= UI_UCS2_STRING_HALF_LENGTH_MINUS_ONE(b->available_length)))
- {
- done = 1;
- break;
- }
- else if (b->text_length >= UI_UCS2_STRING_HALF_LENGTH(b->available_length))
- {
- done = 1;
- break;
- }
- }
- p1 = p2 = b->current_text_p;
- if ((b->last_position_p - b->text) >= (b->available_length))
- {
- done = 1;
- break;
- }
- UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
- if (b_flags & UI_SINGLE_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
- {
- if (b_flags & UI_SINGLE_LINE_INPUT_BOX_ONE_LESS_CHARACTER)
- {
- UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH_TYPE2(
- c,
- b->UCS2_count,
- b->allocated_length,
- b->available_length);
- }
- else
- {
- UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH(c, b->UCS2_count, b->allocated_length, b->available_length);
- }
- }
- while (!UI_STRING_END_OF_STRING_CHARACTER(c))
- {
- UI_STRING_GET_NEXT_CHARACTER(p1, old_c);
- /* MTK Add By Elvis */
- UI_STRING_INSERT_CHARACTER(p2, c - o);
- /* MTK end */
- c = old_c;
- }
- UI_STRING_INSERT_CHARACTER(p2, c);
- count++;
- b->text_length += ((S32) p2 - (S32) p1);
- }
- b->flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_show_single_line_input_box(b); /* show single line input box */
- b->flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_DRAW;
- gui_single_line_input_box_locate_cursor(b); /* locate cursor */
- b->validation_callback(b->text, b->current_text_p, (b->text_length >> 1) - 1);
- b->change_callback();
- UI_UNUSED_PARAMETER(dummy_c);
- return (count);
- }
- /* GUI: multiline input box functions */
- UI_multi_line_input_box_theme *current_multi_line_input_box_theme = NULL;
- #define UI_MULTI_LINE_INPUT_BOX_NUMBER_OF_BREAK_CHARACTERS 2 /* 15 */
- #define MULTILINE_INPUTBOX_DISPLAY_WHOLE_LINES 1
- #define MULTILINE_INPUTBOX_USE_CRLF_COMBINATION 1