gui_ems.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:414k
源码类别:

MTK

开发平台:

C/C++

  1.         case EMS_TYPE_PIC:
  2.             gui_EMS_input_box_display_object_pic(
  3.                         x,y,
  4.                         (U8*)o->data->picture.pdu,
  5.                         o->data->picture.pdu_length,
  6.                         o->data->picture.hDim,o->data->picture.vDim,
  7.                         o->data->picture.bitsPerPixel);
  8.             break;
  9.         case EMS_TYPE_USERDEF_ANM:
  10.             if (display_cursor)
  11.             {
  12.                 EMS_object_x = x;
  13.                 EMS_object_y = y;
  14.                 EMS_object_frame_counter = 0;
  15.                 EMS_object_repeat_counter = 0;
  16.                 EMS_current_object = o;
  17.             }
  18.             
  19.             EMS_object_current_frame_size = o->data->animation.pdu_length;
  20.             if (o->data->animation.cFrame != 0)
  21.                 EMS_object_current_frame_size /= o->data->animation.cFrame;
  22.             gui_EMS_input_box_display_object_pic(
  23.                     x,y,
  24.                     (U8*) o->data->animation.pdu,
  25.                     EMS_object_current_frame_size,
  26.                     o->data->animation.hDim,o->data->animation.vDim,
  27.                     o->data->animation.bitsPerPixel);
  28.             
  29.             if (display_cursor && playback_flag)
  30.             {
  31.                 EMS_object_animation_timer_flag = 1;
  32.                 gui_start_timer((o->data->animation.Duration + 1) * 100, EMS_input_box_show_animation_frame);
  33.             }
  34.             break;
  35.         case EMS_TYPE_PREDEF_ANM:
  36.         {
  37.             PU8 image = get_image(EMS_predefined_animations[o->PredefNo]);
  38.             gui_show_animated_image_frame(x, y, image, 0);
  39.             if (display_cursor && playback_flag)
  40.             {
  41.                 EMS_object_x = x;
  42.                 EMS_object_y = y;
  43.                 gui_measure_image(image, &EMS_object_width, &EMS_object_height);
  44.                 EMS_object_n_frames = gui_image_n_frames(image);
  45.                 EMS_object_frame_counter = 0;
  46.                 EMS_current_object = o;
  47.                 EMS_current_predefined_image = image;
  48.                 EMS_object_predefined_animation_timer_flag = 1;
  49.                 gui_start_timer(EMS_ANIMATION_TIME, EMS_input_box_show_predefined_animation_frame);
  50.             }
  51.         }
  52.             break;
  53.         case EMS_TYPE_PREDEF_SND:
  54.         {
  55.             gui_show_transparent_image(x, y, EMS_editor_sound_icon, 0);
  56.             if (display_cursor && playback_flag)
  57.             {
  58.                 EMS_object_pre_defined_sound_flag = 1;
  59.                 EMS_play_pre_defined_sound(o->PredefNo);
  60.             }
  61.         }
  62.             break;
  63.         case EMS_TYPE_USERDEF_SND:
  64.         {
  65.             gui_show_transparent_image(x, y, EMS_editor_melody_icon, 0);
  66.             if (display_cursor && playback_flag)
  67.             {
  68.                 EMS_object_user_defined_melody_flag = 1;
  69.                 /* MTK Joy added for customization, 1014 */
  70.             #if defined(__MMI_IMELODY_SUPPORT__)
  71.                 EMS_play_user_defined_melody(o->data->sound.pdu, o->data->sound.pdu_length);
  72.             #endif 
  73.                 /* MTK end */
  74.             }
  75.         }
  76.             break;
  77.     }
  78. }
  79. /*****************************************************************************
  80.  * FUNCTION
  81.  *  gui_EMS_playback_object
  82.  * DESCRIPTION
  83.  *  
  84.  * PARAMETERS
  85.  *  o       [?]     
  86.  * RETURNS
  87.  *  void
  88.  *****************************************************************************/
  89. void gui_EMS_playback_object(EMSObject *o)
  90. {
  91.     /*----------------------------------------------------------------*/
  92.     /* Local Variables                                                */
  93.     /*----------------------------------------------------------------*/
  94.     /*----------------------------------------------------------------*/
  95.     /* Code Body                                                      */
  96.     /*----------------------------------------------------------------*/
  97.     switch (o->Type)
  98.     {
  99.         case EMS_TYPE_PREDEF_SND:
  100.         {
  101.             EMS_object_pre_defined_sound_flag = 1;
  102.             EMS_play_pre_defined_sound(o->PredefNo);
  103.         }
  104.             break;
  105.             /* MTK Joy added for customization, 1014 */
  106.     #if defined(__MMI_IMELODY_SUPPORT__)
  107.         case EMS_TYPE_USERDEF_SND:
  108.         {
  109.             EMS_object_user_defined_melody_flag = 1;
  110.             EMS_play_user_defined_melody(o->data->sound.pdu, o->data->sound.pdu_length);
  111.         }
  112.             break;
  113.     #endif /* defined(__MMI_IMELODY_SUPPORT__) */ 
  114.             /* MTK end */
  115.     }
  116. }
  117. /*****************************************************************************
  118.  * FUNCTION
  119.  *  EMS_cancel_object_focus
  120.  * DESCRIPTION
  121.  *  
  122.  * PARAMETERS
  123.  *  void
  124.  * RETURNS
  125.  *  void
  126.  *****************************************************************************/
  127. void EMS_cancel_object_focus(void)
  128. {
  129.     /*----------------------------------------------------------------*/
  130.     /* Local Variables                                                */
  131.     /*----------------------------------------------------------------*/
  132.     /*----------------------------------------------------------------*/
  133.     /* Code Body                                                      */
  134.     /*----------------------------------------------------------------*/
  135.     if (EMS_object_animation_timer_flag)
  136.     {
  137.         gui_cancel_timer(EMS_input_box_show_animation_frame);
  138.         EMS_object_animation_timer_flag = 0;
  139.     }
  140.     else if (EMS_object_predefined_animation_timer_flag)
  141.     {
  142.         gui_cancel_timer(EMS_input_box_show_predefined_animation_frame);
  143.         EMS_object_predefined_animation_timer_flag = 0;
  144.     }
  145.     else if (EMS_object_pre_defined_sound_flag)
  146.     {
  147.         EMS_stop_pre_defined_sound();
  148.         EMS_object_pre_defined_sound_flag = 0;
  149.     }
  150.     else if (EMS_object_user_defined_melody_flag)
  151.     {
  152.         EMS_stop_user_defined_melody();
  153.         EMS_object_user_defined_melody_flag = 0;
  154.     }
  155. }
  156. /*****************************************************************************
  157.  * FUNCTION
  158.  *  gui_EMS_input_box_set_text_format
  159.  * DESCRIPTION
  160.  *  
  161.  * PARAMETERS
  162.  *  b       [?]     
  163.  *  o       [?]     
  164.  * RETURNS
  165.  *  void
  166.  *****************************************************************************/
  167. void gui_EMS_input_box_set_text_format(UI_EMS_input_box *b, EMSObject *o)
  168. {
  169.     /*----------------------------------------------------------------*/
  170.     /* Local Variables                                                */
  171.     /*----------------------------------------------------------------*/
  172.     U8 font_size = (U8) MEDIUM_FONT;
  173.     U8 font_bold = 0;
  174.     U8 font_italic = 0;
  175.     U8 font_underline = 0;
  176.     /*----------------------------------------------------------------*/
  177.     /* Code Body                                                      */
  178.     /*----------------------------------------------------------------*/
  179.     /* color        c={0,0,0,100}; */
  180.     /* UI_EMS_inputbox_text_color=c; */
  181.     if (o == NULL)
  182.     {
  183.         EMS_SET_FONT(&UI_EMS_inputbox_medium_font);
  184.         EMS_SET_TEXT_COLOR(UI_EMS_inputbox_text_color);
  185.         b->flags &=
  186.             ~(UI_EMS_INPUT_BOX_CURRENT_ALIGN_LEFT | UI_EMS_INPUT_BOX_CURRENT_ALIGN_RIGHT |
  187.               UI_EMS_INPUT_BOX_CURRENT_ALIGN_CENTER);
  188.     }
  189.     else
  190.     {
  191.         if (o->Type == EMS_TYPE_TEXT_FORMAT)
  192.         {
  193.             EMSTextFormat *t = &(o->data->text_format);
  194.             b->flags &=
  195.                 ~(UI_EMS_INPUT_BOX_CURRENT_ALIGN_LEFT | UI_EMS_INPUT_BOX_CURRENT_ALIGN_RIGHT |
  196.                   UI_EMS_INPUT_BOX_CURRENT_ALIGN_CENTER);
  197.             switch (t->Alignment)
  198.             {
  199.                 case EMS_ALIGN_LEFT:
  200.                     b->flags |= UI_EMS_INPUT_BOX_CURRENT_ALIGN_LEFT;
  201.                     break;
  202.                 case EMS_ALIGN_RIGHT:
  203.                     b->flags |= UI_EMS_INPUT_BOX_CURRENT_ALIGN_RIGHT;
  204.                     break;
  205.                 case EMS_ALIGN_CENTER:
  206.                     b->flags |= UI_EMS_INPUT_BOX_CURRENT_ALIGN_CENTER;
  207.                     break;
  208.                 case EMS_ALIGN_LANG_DEP:
  209.                     b->flags |= UI_EMS_INPUT_BOX_CURRENT_ALIGN_LEFT;
  210.                     break;
  211.             }
  212.             switch (t->FontSize)
  213.             {
  214.                 case EMS_FONTSIZE_NORMAL:
  215.                     font_size = (U8) UI_EMS_inputbox_medium_font.size;
  216.                     /* c.r=0;c.g=0;c.b=0; */
  217.                     break;
  218.                 case EMS_FONTSIZE_LARGE:
  219.                     font_size = (U8) UI_EMS_inputbox_large_font.size;
  220.                     /* c.r=255;c.g=0;c.b=0; */
  221.                     break;
  222.                 case EMS_FONTSIZE_SMALL:
  223.                     font_size = (U8) UI_EMS_inputbox_small_font.size;
  224.                     /* c.r=0;c.g=0;c.b=255; */
  225.                     break;
  226.             }
  227.         #ifndef __MMI_TEXT_FORMAT_WITHOUT_BOLD__
  228.             if (t->isBold)
  229.             {
  230.                 font_bold = 1;
  231.             }
  232.         #endif /* __MMI_TEXT_FORMAT_WITHOUT_BOLD__ */ 
  233.             if (t->isItalic)
  234.             {
  235.                 font_italic = 1;
  236.             }
  237.             if (t->isUnderline)
  238.             {
  239.                 font_underline = 1;
  240.             }
  241.             UI_EMS_inputbox_current_font.bold = font_bold;
  242.             UI_EMS_inputbox_current_font.italic = font_italic;
  243.             UI_EMS_inputbox_current_font.underline = font_underline;
  244.             UI_EMS_inputbox_current_font.size = font_size;
  245.             EMS_SET_FONT(&UI_EMS_inputbox_current_font);
  246.             /* UI_EMS_inputbox_text_color=c; */
  247.             EMS_SET_TEXT_COLOR(UI_EMS_inputbox_text_color);
  248.         }
  249.     }
  250. }
  251. #endif /* __MMI_MESSAGES_EMS__ */ 
  252. #define UI_EMS_INPUTBOX_N_BREAK_CHARACTERS   2
  253. UI_character_type EMS_input_box_break_characters[] = { ' ',
  254.     /*
  255.      * '.',
  256.      * ',',
  257.      * '\',
  258.      * '/',
  259.      * '-',
  260.      * ':',
  261.      * ';',
  262.      * '?',
  263.      * '!',
  264.      * '|',
  265.      * '+',
  266.      * '=',
  267.      * '_',
  268.      */
  269.     'n'
  270. };
  271. UI_character_type EMS_input_box_new_line_character = (UI_character_type) 'n';
  272. /*****************************************************************************
  273.  * FUNCTION
  274.  *  gui_EMS_breakable_character
  275.  * DESCRIPTION
  276.  *  
  277.  * PARAMETERS
  278.  *  c       [IN]        
  279.  * RETURNS
  280.  *  
  281.  *****************************************************************************/
  282. U8 gui_EMS_breakable_character(UI_character_type c)
  283. {
  284.     /*----------------------------------------------------------------*/
  285.     /* Local Variables                                                */
  286.     /*----------------------------------------------------------------*/
  287.     S32 i;
  288.     /*----------------------------------------------------------------*/
  289.     /* Code Body                                                      */
  290.     /*----------------------------------------------------------------*/
  291.     for (i = 0; i < UI_EMS_INPUTBOX_N_BREAK_CHARACTERS; i++)
  292.     {
  293.         if ((UI_character_type) c == EMS_input_box_break_characters[i])
  294.         {
  295.             return (1);
  296.         }
  297.     }
  298.     return (0);
  299. }
  300. #define UI_EMS_INPUT_BOX_BREAK_CHARACTER(c,flag)                                                      
  301.       {  S32 _ii_;                                                                                    
  302.          flag=0;                                                                                      
  303.          for(_ii_=0;_ii_<UI_EMS_INPUTBOX_N_BREAK_CHARACTERS;_ii_++)                                   
  304.          {  if((UI_character_type)c==(UI_character_type)EMS_input_box_break_characters[_ii_])         
  305.             {  flag=1;                                                                                
  306.                break;                                                                                 
  307.             }                                                                                         
  308.          }                                                                                            
  309.       }
  310. /*****************************************************************************
  311.  * FUNCTION
  312.  *  gui_EMS_new_line_character
  313.  * DESCRIPTION
  314.  *  
  315.  * PARAMETERS
  316.  *  c       [IN]        
  317.  * RETURNS
  318.  *  
  319.  *****************************************************************************/
  320. U8 gui_EMS_new_line_character(UI_character_type c)
  321. {
  322.     /*----------------------------------------------------------------*/
  323.     /* Local Variables                                                */
  324.     /*----------------------------------------------------------------*/
  325.     /*----------------------------------------------------------------*/
  326.     /* Code Body                                                      */
  327.     /*----------------------------------------------------------------*/
  328.     if ((UI_character_type) c == EMS_input_box_new_line_character)
  329.     {
  330.         return (1);
  331.     }
  332.     else
  333.     {
  334.         return (0);
  335.     }
  336. }
  337. #if(EMS_USE_CRLF_COMBINATION)
  338. /*****************************************************************************
  339.  * FUNCTION
  340.  *  gui_EMS_input_box_insert_new_line
  341.  * DESCRIPTION
  342.  *  
  343.  * PARAMETERS
  344.  *  b       [?]     
  345.  * RETURNS
  346.  *  
  347.  *****************************************************************************/
  348. U8 gui_EMS_input_box_insert_new_line(UI_EMS_input_box *b)
  349. {
  350.     /*----------------------------------------------------------------*/
  351.     /* Local Variables                                                */
  352.     /*----------------------------------------------------------------*/
  353.     U8 ret = EMS_OK;
  354. #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  355.     U8 s[4] = {0x00, 0x0D, 0x00, 0x0A};
  356. #else 
  357.     U8 s[4] = {0x0D, 0x00, 0x0A, 0x00};
  358. #endif 
  359.     S32 remaining_length;
  360.     /*----------------------------------------------------------------*/
  361.     /* Code Body                                                      */
  362.     /*----------------------------------------------------------------*/
  363. #ifdef __MMI_MESSAGES_EMS__
  364.     EMS_cancel_object_focus();
  365. #endif 
  366.     if (b->UCS2_count > 0)
  367.     {
  368.         remaining_length = (EMS_get_remaining_length(b->data) >> 1);
  369.     }
  370.     else
  371.     {
  372.         remaining_length = EMS_get_remaining_length(b->data);
  373.     }
  374.     if (remaining_length < 2)
  375.     {
  376.         UI_editor_play_tone_cannot_insert();
  377.         ret = EMS_NO_SPACE;
  378.         return ret;
  379.     }
  380.     /* Overwrite mode is un-implemented */
  381.     if (AddString(b->data, s, 2, NULL) == EMS_NO_SPACE)
  382.     {
  383.         UI_editor_play_tone_cannot_insert();
  384.         b->overflow_callback();
  385.         ret = EMS_NO_SPACE;
  386.     }
  387.     else
  388.     {
  389.         b->change_callback();
  390.     }
  391. b->text_format.Alignment = EMS_ALIGN_LANG_DEP; // reset alignment when input 'enter' symbol
  392.     gui_EMS_input_box_locate_cursor(b);
  393.     return ret;
  394. }
  395. #else /* (EMS_USE_CRLF_COMBINATION) */ 
  396. /*****************************************************************************
  397.  * FUNCTION
  398.  *  gui_EMS_input_box_insert_new_line
  399.  * DESCRIPTION
  400.  *  
  401.  * PARAMETERS
  402.  *  b       [?]     
  403.  * RETURNS
  404.  *  
  405.  *****************************************************************************/
  406. U8 gui_EMS_input_box_insert_new_line(UI_EMS_input_box *b)
  407. {
  408.     /*----------------------------------------------------------------*/
  409.     /* Local Variables                                                */
  410.     /*----------------------------------------------------------------*/
  411.     /*----------------------------------------------------------------*/
  412.     /* Code Body                                                      */
  413.     /*----------------------------------------------------------------*/
  414.     gui_EMS_input_box_insert_character(b, EMS_input_box_new_line_character);
  415.     return EMS_OK;
  416. }
  417. #endif /* (EMS_USE_CRLF_COMBINATION) */ 
  418. #if(0)
  419. UI_character_type TEMP_EMS_GET_OBJECT(EMSObject *o)
  420. { if((o!=NULL) && (o->Type==EMS_TYPE_PIC) && (o->data->picture.pdu!=NULL))
  421. { return((UI_character_type)((UI_character_type)'0'+(UI_character_type)(o->data->picture.pdu[0])));
  422. }
  423. else return((UI_character_type)' ');
  424. }
  425. void temp_print_object(EMSObject *o)
  426. {
  427. if(o==NULL) PRINT_INFORMATION(("-"));
  428. else if(o->Type==0) PRINT_INFORMATION(("*"));
  429. else if(o->Type==5) PRINT_INFORMATION(("%d",o->data->picture.pdu[0]));
  430. }
  431. void temp_print_next_object(EMSObject *o)
  432. {
  433. if(o==NULL) PRINT_INFORMATION(("-"));
  434. else if(o->next==NULL) PRINT_INFORMATION(("-"));
  435. else if(o->next->Type==0) PRINT_INFORMATION(("*"));
  436. else if(o->next->Type==5) PRINT_INFORMATION(("%d",o->next->data->picture.pdu[0]));
  437. }
  438. #endif /* (0) */ 
  439. #define EMS_SET_BREAK_POSITION()                                     
  440. {  break_line_width=line_width;                                      
  441.    break_line_height=line_height;                                    
  442.    break_line_object_count=line_object_count;                        
  443.    break_line_alignment=line_alignment;                              
  444.    break_line_text_object_count=line_text_object_count;              
  445. }
  446. #define EMS_SET_NEXT_BREAK_POSITION()                                
  447. {  break_line_width=line_width;                                      
  448.    break_line_height=line_height;                                    
  449.    break_line_object_count=line_object_count+1;                      
  450.    break_line_alignment=line_alignment;                              
  451.    break_line_text_object_count=line_text_object_count;              
  452. }
  453. /*****************************************************************************
  454.  * FUNCTION
  455.  *  EMS_handle_CRLF_navigation
  456.  * DESCRIPTION
  457.  *  
  458.  * PARAMETERS
  459.  *  data        [?]     
  460.  * RETURNS
  461.  *  void
  462.  *****************************************************************************/
  463. void EMS_handle_CRLF_navigation(EMSData *data)
  464. {
  465.     /*----------------------------------------------------------------*/
  466.     /* Local Variables                                                */
  467.     /*----------------------------------------------------------------*/
  468.     U8 r;
  469.     EMSPosition p;
  470.     UI_character_type c;
  471.     EMSObject *o;
  472.     /*----------------------------------------------------------------*/
  473.     /* Code Body                                                      */
  474.     /*----------------------------------------------------------------*/
  475. #if(EMS_USE_CRLF_COMBINATION)
  476.     p = data->CurrentPosition;
  477.     r = gui_EMS_input_box_get_next_object(data, &p, &c, &o);
  478.     if ((r == 1) && UI_TEST_LF_CHARACTER(c))
  479.     {
  480.         p = data->CurrentPosition;
  481.         r = gui_EMS_input_box_get_previous_object(data, &p, &c, &o);
  482.         if ((r == 1) && UI_TEST_CR_CHARACTER(c))
  483.         {
  484.             BackwardCurrentPosition(data, 1);
  485.             return;
  486.         }
  487.     }
  488. #endif /* (EMS_USE_CRLF_COMBINATION) */ 
  489. #if(EMS_USE_ESC_COMBINATION)
  490.     if (data->dcs == SMSAL_DEFAULT_DCS)
  491.     {
  492.         p = data->CurrentPosition;
  493.         r = gui_EMS_input_box_get_previous_object(data, &p, &c, &o);
  494.         if ((r == 1) && UI_TEST_ESC_CHARACTER(c))
  495.         {
  496.             BackwardCurrentPosition(data, 1);
  497.         }
  498.     }
  499. #endif /* (EMS_USE_ESC_COMBINATION) */ 
  500. }
  501. #define EMS_EDITOR_DRAW_DOTTED_LINE(x1,x2,y,c)                       
  502. {  S32 i,xx1=(x1),xx2=(x2),yy=(y);                                   
  503.    for(i=xx1;i<=xx2;i++)                                             
  504.    {  if(i&1) gui_putpixel(i,yy,c);                                  
  505.    }                                                                 
  506. }
  507. #define EMS_EDITOR_DRAW_LINE(x1,x2,y,c)                              
  508. {  S32 i,xx1=(x1),xx2=(x2),yy=(y);                                   
  509.    for(i=xx1;i<=xx2;i++)                                             
  510.    {  gui_putpixel(i,yy,c);                                          
  511.    }                                                                 
  512. }
  513. U8 EMS_object_width_cache[128];
  514. U8 EMS_object_height_cache[128];
  515. U16 EMS_object_str_cache[128];
  516. /* Gurinder - 03/15/2004 - EMS Input Box InfoBar BG Image */
  517. extern S32 wgui_EMS_inputbox_information_bar_height;
  518. #define MAX_EMS_DISP_CLUSTER_LEN 50
  519. /* START TARUN PMT 20050128 */
  520. #ifdef __MMI_HINDI_ALG__
  521. extern BOOL cancelWidth;
  522. #endif 
  523. //END TARUN PMT 20050128
  524. //W05.52 Fix Cursor Moviong issue for ESC character
  525. /*****************************************************************************
  526.  * FUNCTION
  527.  *  gui_EMS_input_box_back_cursor_for_ESC_character
  528.  * DESCRIPTION
  529.  *  
  530.  * PARAMETERS
  531.  *  data            [?]     
  532.  *  position        [?]     
  533.  * RETURNS
  534.  *  void
  535.  *****************************************************************************/
  536. void gui_EMS_input_box_back_cursor_for_ESC_character(EMSData *data, EMSPosition *position)
  537. {
  538.     /*----------------------------------------------------------------*/
  539.     /* Local Variables                                                */
  540.     /*----------------------------------------------------------------*/
  541.     EMSObject *current_object;
  542.     UI_character_type current_character;
  543.     U8 object_type;
  544.     /*----------------------------------------------------------------*/
  545.     /* Code Body                                                      */
  546.     /*----------------------------------------------------------------*/
  547.     object_type = gui_EMS_input_box_get_previous_object(data, position, &current_character, &current_object);   /* get next character */
  548.     if (1 == object_type)
  549.     {
  550.         if (UI_TEST_ESC_CHARACTER(current_character))
  551.         {
  552.             if (BackwardCurrentPositionSkipCR(data) != 1)
  553.             {
  554.                 UI_editor_play_tone_cannot_navigate();
  555.             }
  556.         }
  557.     }
  558. }
  559. #if defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__)
  560. /*****************************************************************************
  561.  * FUNCTION
  562.  *  gui_is_ems_object_can_display_in_editor
  563.  * DESCRIPTION
  564.  *  
  565.  * PARAMETERS
  566.  *  type        [IN]        
  567.  * RETURNS
  568.  *  
  569.  *****************************************************************************/
  570. MMI_BOOL gui_is_ems_object_can_display_in_editor(U8 type)
  571. {
  572.     /*----------------------------------------------------------------*/
  573.     /* Local Variables                                                */
  574.     /*----------------------------------------------------------------*/
  575.     /*----------------------------------------------------------------*/
  576.     /* Code Body                                                      */
  577.     /*----------------------------------------------------------------*/
  578.     if (type == EMS_TYPE_PREDEF_SND ||
  579.         type == EMS_TYPE_USERDEF_SND ||
  580.         type == EMS_TYPE_PREDEF_ANM || type == EMS_TYPE_USERDEF_ANM || type == EMS_TYPE_PIC)
  581.     {
  582.         return MMI_TRUE;
  583.     }
  584.     else
  585.     {
  586.         return MMI_FALSE;
  587.     }
  588. }
  589. /*****************************************************************************
  590.  * FUNCTION
  591.  *  gui_insert_character_into_buffer
  592.  * DESCRIPTION
  593.  *  
  594.  * PARAMETERS
  595.  *  buffer      [?]         
  596.  *  offset      [IN]        
  597.  *  c           [IN]        
  598.  * RETURNS
  599.  *  void
  600.  *****************************************************************************/
  601. void gui_insert_character_into_buffer(U16 *buffer, U16 offset, UI_character_type c)
  602. {
  603.     /*----------------------------------------------------------------*/
  604.     /* Local Variables                                                */
  605.     /*----------------------------------------------------------------*/
  606.     UI_buffer_type p1, p2;
  607.     UI_character_type old_c;
  608.     /*----------------------------------------------------------------*/
  609.     /* Code Body                                                      */
  610.     /*----------------------------------------------------------------*/
  611.     p1 = p2 = ((U8*) buffer) + offset;
  612.     while (!UI_STRING_END_OF_STRING_CHARACTER(c))
  613.     {
  614.         UI_STRING_GET_NEXT_CHARACTER(p1, old_c);
  615.         UI_STRING_INSERT_CHARACTER(p2, c);
  616.         c = old_c;
  617.     }
  618.     UI_STRING_INSERT_CHARACTER(p2, c);  /* insert character */
  619. }
  620. /*****************************************************************************
  621.  * FUNCTION
  622.  *  gui_delete_character_from_buffer
  623.  * DESCRIPTION
  624.  *  
  625.  * PARAMETERS
  626.  *  buffer      [?]         
  627.  *  offset      [IN]        
  628.  * RETURNS
  629.  *  void
  630.  *****************************************************************************/
  631. void gui_delete_character_from_buffer(U16 *buffer, U16 offset)
  632. {
  633.     /*----------------------------------------------------------------*/
  634.     /* Local Variables                                                */
  635.     /*----------------------------------------------------------------*/
  636.     UI_buffer_type p1, p2;
  637.     UI_character_type c, old_c;
  638.     /*----------------------------------------------------------------*/
  639.     /* Code Body                                                      */
  640.     /*----------------------------------------------------------------*/
  641.     p1 = p2 = ((U8*) buffer) + offset;
  642.     c = *p1;
  643.     p1 += 2;
  644.     while (!UI_STRING_END_OF_STRING_CHARACTER(c))
  645.     {
  646.         UI_STRING_GET_NEXT_CHARACTER(p1, c);
  647.         UI_STRING_INSERT_CHARACTER(p2, c);  /* insert character */
  648.     }
  649. }
  650. /*****************************************************************************
  651.  * FUNCTION
  652.  *  gui_get_ems_text_actual_idx
  653.  * DESCRIPTION
  654.  *  
  655.  * PARAMETERS
  656.  *  b                   [?]         
  657.  *  OffsetToText        [IN]        
  658.  * RETURNS
  659.  *  
  660.  *****************************************************************************/
  661. U16 gui_get_ems_text_actual_idx(UI_EMS_input_box *b, U16 OffsetToText)
  662. {
  663.     /*----------------------------------------------------------------*/
  664.     /* Local Variables                                                */
  665.     /*----------------------------------------------------------------*/
  666.     EMSData *data = b->data;
  667.     EMSObject *cur_obj = data->listHead;
  668.     U16 offset = 0;
  669.     /*----------------------------------------------------------------*/
  670.     /* Code Body                                                      */
  671.     /*----------------------------------------------------------------*/
  672.     while (cur_obj != NULL)
  673.     {
  674.         if (gui_is_ems_object_can_display_in_editor((U8) cur_obj->Type))
  675.         {
  676.             if (cur_obj->OffsetToText < OffsetToText)
  677.             {
  678.                 offset += 2;
  679.             }
  680.             else
  681.             {
  682.                 return (OffsetToText + offset);
  683.             }
  684.         }
  685.         cur_obj = cur_obj->next;
  686.     }
  687.     return (OffsetToText + offset);
  688. }
  689. #define dummy_char 0x01
  690. U16 object_position[128];
  691. U8 object_no = 0;
  692. /*****************************************************************************
  693.  * FUNCTION
  694.  *  gui_ems_data_apply_shaping
  695.  * DESCRIPTION
  696.  *  
  697.  * PARAMETERS
  698.  *  b                       [?]     
  699.  *  text_shaping_buffer     [?]     
  700.  * RETURNS
  701.  *  void
  702.  *****************************************************************************/
  703. void gui_ems_data_apply_shaping(UI_EMS_input_box *b, U16 *text_shaping_buffer)
  704. {
  705.     /*----------------------------------------------------------------*/
  706.     /* Local Variables                                                */
  707.     /*----------------------------------------------------------------*/
  708.     EMSData *data = b->data;
  709.     EMSObject *cur_obj = data->listHead;
  710.     S32 i = 0;
  711.     S32 text_len = (b->data->textLength / 2);
  712.     MMI_BOOL has_ems_display_object = MMI_FALSE;
  713.     /*----------------------------------------------------------------*/
  714.     /* Code Body                                                      */
  715.     /*----------------------------------------------------------------*/
  716.     object_no = 0;
  717.     while (cur_obj != NULL)
  718.     {
  719.         if (gui_is_ems_object_can_display_in_editor((U8) cur_obj->Type))
  720.         {
  721.             has_ems_display_object = MMI_TRUE;
  722.             gui_insert_character_into_buffer(
  723.                 text_shaping_buffer,
  724.                 cur_obj->OffsetToText + (object_no * 2),
  725.                 (UI_character_type) dummy_char);
  726.             text_len++;
  727.             object_position[object_no] = cur_obj->OffsetToText / 2 + object_no + 1;
  728.             object_no++;
  729.         }
  730.         cur_obj = cur_obj->next;
  731.     }
  732.     unshaped_text_len = text_len;
  733. #ifdef __MMI_ZI__
  734.     #ifdef __MMI_ZI_V7__
  735.         #if defined(__MMI_ZI_ARABIC__) && defined(__MMI_ZI_PERSIAN__)
  736.             ZiStringShapeEx(ZI8_LANG_FA, (U16*) & text_len, (U16*) text_shaping_buffer, (U16*) OrgToSha, NULL);      /* 19 is the Arabic id */
  737.         #elif defined(__MMI_ZI_PERSIAN__)
  738.             ZiStringShapeEx(ZI8_LANG_FA, (U16*) & text_len, (U16*) text_shaping_buffer, (U16*) OrgToSha, NULL);      /* 19 is the Arabic id */
  739.         #elif defined(__MMI_ZI_ARABIC__)
  740.             ZiStringShapeEx(ZI8_LANG_AR, (U16*) & text_len, (U16*) text_shaping_buffer, (U16*) OrgToSha, NULL);      /* 19 is the Arabic id */
  741.         #endif 
  742.     #else /* __MMI_ZI_V7__ */ 
  743.         ArabicStringShape2((U16*) & text_len, (U16*) text_shaping_buffer, (U16*) OrgToSha, NULL);
  744.     #endif /* __MMI_ZI_V7__ */ 
  745.   
  746. #else /* __MMI_ZI__ */ 
  747.     ArabicShapeEngine2((U16*) & text_len, (U16*) text_shaping_buffer, (U16*) OrgToSha, NULL);
  748. #endif /* __MMI_ZI__ */ 
  749. }
  750. #endif /* defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__) */ 
  751. /*****************************************************************************
  752.  * FUNCTION
  753.  *  gui_show_EMS_input_box
  754.  * DESCRIPTION
  755.  *  
  756.  * PARAMETERS
  757.  *  b       [?]     
  758.  * RETURNS
  759.  *  void
  760.  *****************************************************************************/
  761. void gui_show_EMS_input_box(UI_EMS_input_box *b)
  762. {
  763.     /*----------------------------------------------------------------*/
  764.     /* Local Variables                                                */
  765.     /*----------------------------------------------------------------*/
  766.     /*----------------------------------------------------------------*/
  767.     /* Code Body                                                      */
  768.     /*----------------------------------------------------------------*/
  769.     gui_show_EMS_input_box_ext(b, (-1), (-1));
  770. }
  771. /*****************************************************************************
  772.  * FUNCTION
  773.  *  gui_show_EMS_input_box_ext
  774.  * DESCRIPTION
  775.  *  
  776.  * PARAMETERS
  777.  *  b               [?]         
  778.  *  move_to_x       [IN]        
  779.  *  move_to_y       [IN]        
  780.  * RETURNS
  781.  *  void
  782.  *****************************************************************************/
  783. void gui_show_EMS_input_box_ext(UI_EMS_input_box *b, S32 move_to_x, S32 move_to_y)
  784. {
  785.     /*----------------------------------------------------------------*/
  786.     /* Local Variables                                                */
  787.     /*----------------------------------------------------------------*/
  788.     S32 x1, y1;                 /* x1,y1 -> left-top corner of the editor windows */
  789.     S32 x2, y2;                 /* x2,y2 -> right-bottom of the editor windows */
  790.     UI_filled_area f;           /* Gurinder - 03/15/2004 - EMS Input Box InfoBar BG Image */
  791.     U8 selection_flag = 0;
  792.     U8 overwrite_mode_flag = 0;
  793.     S32 tx = 0, ty;             /* specify the positon at which the text display starts */
  794.     EMSData *data = b->data;
  795.     UI_character_type current_character = 0, pre2_character = 0, pre_character = 0;
  796.     EMSPosition current_position;
  797.     EMSPosition line_start_position;
  798.     EMSPosition previous_position;
  799.     U8 object_type;
  800.     EMSObject *current_object;
  801.     S32 line_width, line_height;
  802.     S32 break_line_width, break_line_height;
  803.     S32 object_width, object_height;
  804.     U8 done = 0;
  805.     U8 display_done;
  806.     EMSObject *current_text_format;
  807.     EMSObject *line_start_text_format;
  808.     U32 flags = b->flags;
  809.     S32 set_cursor_flag = 0;
  810.     S32 center_x, box_width;
  811.     S32 line_object_count;
  812.     S32 cursor_ax, cursor_ay;   /* Absolute cursor co-ordinates  */
  813.     S32 break_line_object_count;
  814.     S32 text_format_object_count, break_text_format_object_count;
  815.     U8 disable_draw_flag = 0;
  816.     U8 *object_width_cache = EMS_object_width_cache;
  817.     U8 *object_height_cache = EMS_object_height_cache;
  818.     U8 word_highlight = 0;
  819.     /* byte                                 has_ems_boundary_flag   =       0;  //Gurinder - 03/15/2004 - EMS Input Box InfoBar BG Image */
  820.     S32 n_lines = 0;
  821.     U8 first_object_flag;
  822.     EMSPosition mapped_cursor_position;
  823.     EMSPosition mapped_current_position;
  824.     EMSPosition mapped_previous_position;
  825.     U8 cursor_displayed_flag = 0;
  826.     U8 alignment, break_line_alignment = EMS_ALIGN_LANG_DEP, line_alignment;
  827.     S32 line_text_object_count, break_line_text_object_count;
  828.     color normal_text_color = b->normal_text_color;
  829.     color selected_text_color = b->selected_text_color;
  830.     /* PMT LANGUAGE START 20051221 */
  831. #if defined __MMI_LANG_HINDI__ && (defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__)
  832.     U16 unicode = 0;
  833.     U16 clFill = 0;
  834. #endif /* defined __MMI_LANG_HINDI__ && (defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__) */ 
  835.     //PMT LANGUAGE END 20051221
  836.     //START PMT NEERAJ 20050916
  837. #if(EMS_SHOW_HORIZONTAL_RULE_FOR_ALL_LINES)
  838.     S32 minimum_line_height;
  839.     S32 last_line_y = 0;
  840. #endif /* (EMS_SHOW_HORIZONTAL_RULE_FOR_ALL_LINES) */ 
  841.     /* END PMT NEERAJ 20050916 */
  842. #if(EMS_ENABLE_SPECIAL_FONT_DISPLAY)
  843.     color underline_color = b->underline_color;
  844.     color strikethrough_color = b->strikethrough_color;
  845.     color paragraph_color = b->paragraph_color;
  846.     U8 underline_flag = 0, strikethrough_flag = 0;
  847. #endif /* (EMS_ENABLE_SPECIAL_FONT_DISPLAY) */ 
  848. #ifdef __MMI_HINDI_ALG__
  849.     PU8 move_ems_cursor_prev_p = data->textBuffer;
  850.     PU8 move_ems_cursor_curr_p = data->textBuffer;
  851.     PU8 temp_ems_cursor_p = data->textBuffer;
  852.     PU8 move_ems_cursor_disp_prev_p = data->textBuffer;
  853.     PU8 move_ems_cursor_disp_curr_p = data->textBuffer;
  854.     U16 disp_ems_cluster[MAX_EMS_DISP_CLUSTER_LEN];
  855.     S32 skip_ems_moves = 1;         /* for skipping by cluster */
  856.     S32 saved_ems_skip_moves = 1;
  857.     S32 display_ems_skip_moves = 1; /* for skipping by cluster while display */
  858.     S32 saved_ems_display_skip_moves = 0;
  859.     S32 ems_cluster_width = 0;
  860.     S32 ems_cursor_width = 0;
  861.     U8 kdx = 0;
  862.     S32 hindi_ems_cluster_counter = 0;
  863.     /* Performance related to store the cluster width */
  864.     S32 hindi_cluster_cache[50];
  865.     S32 hindi_cache_counter = 0;
  866.     /* MTK Begin Hindi patch 0425 */
  867.     BOOL set_hindi_text_format_flag = MMI_FALSE;
  868.     EMSObject *hindi_text_format = NULL;
  869.     /* MTK End Hindi patch 0425 */
  870. #endif /* __MMI_HINDI_ALG__ */ 
  871.     PMT_BIDI_TYPES default_direction = BIDI_L;
  872.     S32 vbar_x = 0, vbar_button_x = 0;
  873. #ifdef __MMI_BIDI_ALG__
  874.     U16 logical_cur_pos;
  875.     U8 *temp_text_pt;
  876.     U16 temp_text_position;
  877.     U8 temp_text_buffer[MAX_NUM_OF_CHAR_FOR_EACH_LINE];
  878.     U16 temp_cursor_position;
  879.     U16 visual_str_len;
  880.     U16 visual_cur_pos;
  881.     U16 logical_hilight_start;
  882.     U16 logical_hilight_end;
  883.     U16 visual_hilight_start;
  884.     U16 visual_hilight_end;
  885.     U16 temp_hilight_start;
  886.     U16 temp_hilight_end;
  887.     PMT_BIDI_TYPES default_line_direction = BIDI_L;
  888.     pBOOL reverse_flag;
  889.     S32 num_char;
  890.     U32 iCount;
  891.     pBOOL arabic_char_flag = MMI_FALSE;
  892.     U8 lastest_char_type;
  893.     UI_character_type test_current_character;
  894.     /* PMT NO_AR_SL_DU START 20050909 */
  895.     S32 text_len;
  896.     PU8 ptr_text_buffer;
  897.     /* PMT NO_AR_SL_DU END 20050909 */
  898. #endif /* __MMI_BIDI_ALG__ */ 
  899. #if defined(__MMI_LANG_VIETNAMESE__)
  900.     UI_character_type dummy_c = 0;
  901.     viet_tone_mark tone_mark = VIET_TONE_NONE;
  902.     viet_vowel_letter viet_vowel = VIET_VOWEL_NONE;
  903. #endif /* defined(__MMI_LANG_VIETNAMESE__) */ 
  904.     /*----------------------------------------------------------------*/
  905.     /* Code Body                                                      */
  906.     /*----------------------------------------------------------------*/
  907.     /* PMT RAKESH START 20061006 */
  908. #if defined __MMI_HINDI_ALG__
  909.     overwrite_current_language_for_hindi_rules_based_on_input_method();
  910. #endif 
  911.     /* PMT RAKESH END 20061006 */
  912.     if (((-1) != move_to_x) || ((-1) != move_to_y))
  913.     {
  914.         flags |= UI_EMS_INPUT_BOX_DISABLE_DRAW;
  915.     }
  916. #if defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__)
  917.     if ((b->data->textLength / ENCODING_LENGTH) != 0)
  918.     {
  919.         if (!(flags & UI_EMS_INPUT_BOX_VIEW_MODE))
  920.         {
  921.             pfnUnicodeStrncpy(
  922.                 (S8*) shaping_str,
  923.                 (const S8*)b->data->textBuffer,
  924.                 b->data->textLength / ENCODING_LENGTH);
  925.             gui_ems_data_apply_shaping(b, shaping_str);
  926.         }
  927.         else
  928.         {
  929.             pfnUnicodeStrncpy(
  930.                 (S8*) shaping_str,
  931.                 (const S8*)b->data->textBuffer,
  932.                 b->data->textLength / ENCODING_LENGTH);
  933.             gui_ems_data_apply_shaping(b, shaping_str);
  934.         #ifdef __MMI_HINDI_ALG__
  935.             move_ems_cursor_prev_p = data->textBuffer;
  936.             move_ems_cursor_curr_p = data->textBuffer;
  937.             temp_ems_cursor_p = data->textBuffer;
  938.             move_ems_cursor_disp_prev_p = data->textBuffer;
  939.             move_ems_cursor_disp_curr_p = data->textBuffer;
  940.         #endif /* __MMI_HINDI_ALG__ */ 
  941.         }
  942.     }
  943. #endif /* defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__) */ 
  944. #if defined __MMI_LANG_HINDI__ && (defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__)
  945.     /* U16 unicode        =  0;
  946.        U16 clFill        =  0; */
  947.     /* PMT LANGUAGE END 20051221 */
  948.     HINDI_PRESENT = 0;
  949.     ARABIC_PRESENT = 0;
  950.     while ((data->textBuffer[clFill] != '' || data->textBuffer[clFill + 1] != '') && !HINDI_PRESENT)
  951.     {
  952.         unicode = data->textBuffer[clFill];
  953.         unicode |= (data->textBuffer[clFill + 1] << 8);
  954.         if (UI_HINDI_CHARACTER_UCS2_RANGE(unicode))
  955.         {
  956.             HINDI_PRESENT = 1;
  957.             ARABIC_PRESENT = 0;
  958.         }
  959.         /* PMT LANGUAGE START 20051221 */
  960.         else if (IS_ARABIC_CHARACTER(unicode))
  961.         {
  962.             ARABIC_PRESENT = 1;
  963.             HINDI_PRESENT = 0;
  964.         }
  965.         /* PMT LANGUAGE END 20051221 */
  966.         clFill += 2;
  967.     }
  968. #endif /* defined __MMI_LANG_HINDI__ && (defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__) */ 
  969.     /* END PMTFARHAD  20050224 */
  970. #ifdef __MMI_BIDI_ALG__
  971.     if (!(flags & UI_EMS_INPUT_BOX_DISABLE_DRAW) && (data->textLength != 0))
  972.     {
  973.         bidi_get_char_type(data->textBuffer, (U8*) & default_direction);
  974.         if (default_direction == BIDI_R || default_direction == AL)
  975.         {
  976.             default_direction = BIDI_R;
  977.         }
  978.         else
  979.         {
  980.             default_direction = BIDI_L;
  981.         }
  982.         for (iCount = 0; iCount < (U32) (data->textLength >> 1); iCount++)
  983.         {
  984.             bidi_get_char_type((U8*) (data->textBuffer + iCount * ENCODING_LENGTH), (U8*) & lastest_char_type);
  985.             if ((lastest_char_type == AL) || (lastest_char_type == AN) || (lastest_char_type == BIDI_R))
  986.             {
  987.                 arabic_char_flag = MMI_TRUE;
  988.                 break;
  989.             }
  990.         }
  991.     }
  992. #endif /* __MMI_BIDI_ALG__ */ 
  993. #if 0
  994. #ifdef __MMI_BIDI_ALG__
  995. /* under construction !*/
  996. /* under construction !*/
  997. /* under construction !*/
  998. /* under construction !*/
  999. /* under construction !*/
  1000. /* under construction !*/
  1001. /* under construction !*/
  1002. /* under construction !*/
  1003. /* under construction !*/
  1004. /* under construction !*/
  1005. /* under construction !*/
  1006. /* under construction !*/
  1007. /* under construction !*/
  1008. /* under construction !*/
  1009. /* under construction !*/
  1010. /* under construction !*/
  1011. /* under construction !*/
  1012. /* under construction !*/
  1013. /* under construction !*/
  1014. /* under construction !*/
  1015. /* under construction !*/
  1016. /* under construction !*/
  1017. /* under construction !*/
  1018. /* under construction !*/
  1019. /* under construction !*/
  1020. /* under construction !*/
  1021. /* under construction !*/
  1022. /* under construction !*/
  1023. /* under construction !*/
  1024. /* under construction !*/
  1025. /* under construction !*/
  1026. /* under construction !*/
  1027. /* under construction !*/
  1028. /* under construction !*/
  1029. /* under construction !*/
  1030. /* under construction !*/
  1031. /* under construction !*/
  1032. /* under construction !*/
  1033. /* under construction !*/
  1034. #if defined __MMI_LANG_HINDI__ && ( defined __MMI_LANG_ARABIC__|| defined __MMI_LANG_PERSIAN__ )
  1035. /* under construction !*/
  1036. #endif
  1037. /* under construction !*/
  1038. /* under construction !*/
  1039. /* under construction !*/
  1040. /* under construction !*/
  1041. /* under construction !*/
  1042. /* under construction !*/
  1043. /* under construction !*/
  1044. /* under construction !*/
  1045. /* under construction !*/
  1046. /* under construction !*/
  1047. /* under construction !*/
  1048. /* under construction !*/
  1049. /* under construction !*/
  1050. /* under construction !*/
  1051. /* under construction !*/
  1052. /* under construction !*/
  1053. #if defined __MMI_LANG_HINDI__ && ( defined __MMI_LANG_ARABIC__|| defined __MMI_LANG_PERSIAN__ )
  1054. /* under construction !*/
  1055. #endif
  1056. /* under construction !*/
  1057. /* under construction !*/
  1058. /* under construction !*/
  1059. /* under construction !*/
  1060. /* under construction !*/
  1061. /* under construction !*/
  1062. /* under construction !*/
  1063. #if defined __MMI_LANG_HINDI__ && ( defined __MMI_LANG_ARABIC__|| defined __MMI_LANG_PERSIAN__ )
  1064. /* under construction !*/
  1065. #endif
  1066. /* under construction !*/
  1067. /* under construction !*/
  1068. /* under construction !*/
  1069. /* under construction !*/
  1070. /* under construction !*/
  1071. /* under construction !*/
  1072. /* under construction !*/
  1073. /* under construction !*/
  1074. /* under construction !*/
  1075. /* under construction !*/
  1076. /* under construction !*/
  1077. /* under construction !*/
  1078. /* under construction !*/
  1079. /* under construction !*/
  1080. /* under construction !*/
  1081. /* under construction !*/
  1082. #if defined __MMI_LANG_HINDI__ && ( defined __MMI_LANG_ARABIC__|| defined __MMI_LANG_PERSIAN__ )
  1083. /* under construction !*/
  1084. #endif
  1085. /* under construction !*/
  1086. /* under construction !*/
  1087. /* under construction !*/
  1088. /* under construction !*/
  1089. /* under construction !*/
  1090. /* under construction !*/
  1091. /* under construction !*/
  1092. /* under construction !*/
  1093. /* under construction !*/
  1094. /* under construction !*/
  1095. /* under construction !*/
  1096. #ifdef __MMI_HINDI_ALG__
  1097. /* under construction !*/
  1098. /* under construction !*/
  1099. /* under construction !*/
  1100. /* under construction !*/
  1101. /* under construction !*/
  1102. #endif
  1103. /* under construction !*/
  1104. /* under construction !*/
  1105. /* under construction !*/
  1106. /* under construction !*/
  1107. /* under construction !*/
  1108. /* under construction !*/
  1109. /* under construction !*/
  1110. /* under construction !*/
  1111. /* under construction !*/
  1112. /* under construction !*/
  1113. /* under construction !*/
  1114. /* under construction !*/
  1115. /* under construction !*/
  1116. /* under construction !*/
  1117. /* under construction !*/
  1118. /* under construction !*/
  1119. /* under construction !*/
  1120. /* under construction !*/
  1121. /* under construction !*/
  1122. /* under construction !*/
  1123. /* under construction !*/
  1124. /* under construction !*/
  1125. /* under construction !*/
  1126. /* under construction !*/
  1127. /* under construction !*/
  1128. /* under construction !*/
  1129. /* under construction !*/
  1130. /* under construction !*/
  1131. /* under construction !*/
  1132. /* under construction !*/
  1133. /* under construction !*/
  1134.   #endif
  1135. #endif /* 0 */ 
  1136.     if (r2lMMIFlag)
  1137.     {
  1138.         x1 = b->x + b->vbar.width;
  1139.     }
  1140.     else
  1141.     {
  1142.         x1 = b->x;
  1143.     }
  1144.     y1 = b->y;
  1145.     x2 = b->x /* x1 */  + b->width - 1;
  1146.     y2 = y1 + b->height - 1;
  1147.     b->display_height = 0;
  1148. #ifdef __MMI_HINDI_ALG__
  1149.     memset(disp_ems_cluster, 0, sizeof(disp_ems_cluster));
  1150. #endif 
  1151.     if (flags & UI_EMS_INPUT_BOX_DISABLE_DRAW)
  1152.     {
  1153.         disable_draw_flag = 1;
  1154.     }
  1155.     if (flags & UI_EMS_INPUT_BOX_VIEW_MODE)
  1156.     {
  1157.         EMS_view_mode = 1;
  1158.     }
  1159.     else
  1160.     {
  1161.         EMS_view_mode = 0;
  1162.     }
  1163.     if (!disable_draw_flag)
  1164.     {
  1165.         if (flags & UI_EMS_INPUT_BOX_STATE_SELECTED)
  1166.         {
  1167.             f = *b->selected_filler;
  1168.         }
  1169.         else if (flags & UI_EMS_INPUT_BOX_STATE_DISABLED)
  1170.         {
  1171.             f = *b->disabled_filler;
  1172.         }
  1173.         /* Gurinder - 03/15/2004 - EMS Input Box InfoBar BG Image */
  1174.         else
  1175.         {
  1176.             f = *b->normal_filler;
  1177.         }
  1178.         if (r2lMMIFlag)
  1179.         {
  1180.             gui_set_clip(x1 - b->vbar.width, y1, x2 + 2 /* +b->vbar.width */ , y2 + 2);
  1181.         }
  1182.         else
  1183.         {
  1184.             gui_set_clip(x1, y1, x2 + 2, y2 + 2);
  1185.         }
  1186.         /* Gurinder - 03/15/2004 - EMS Input Box InfoBar BG Image */
  1187.         if (!(flags & UI_EMS_INPUT_BOX_DISABLE_BACKGROUND)) /* if not disable background then do ... */
  1188.         {
  1189.             if (!(flags & UI_EMS_INPUT_BOX_INCLUDE_INFO_AREA))  /* not include info area */
  1190.             {
  1191.                 /* 070405 Calvin Start */
  1192.                 if (r2lMMIFlag)
  1193.                 {
  1194.                     if ((wgui_is_wallpaper_on_bottom() == MMI_TRUE) &&
  1195.                         (flags & UI_EMS_INPUT_BOX_TRANSPARENT_BACKGROUND))
  1196.                     {
  1197.                         gdi_draw_solid_rect(
  1198.                             x1 - b->vbar.width,
  1199.                             y1,
  1200.                             x2 /* +b->vbar.width */ ,
  1201.                             y2,
  1202.                             GDI_COLOR_TRANSPARENT);
  1203.                     }
  1204.                     else
  1205.                     {
  1206.                         gui_draw_filled_area(x1 - b->vbar.width, y1, x2 /* +b->vbar.width */ , y2, &f);
  1207.                     }
  1208.                 }
  1209.                 else
  1210.                 {
  1211.                     if ((wgui_is_wallpaper_on_bottom() == MMI_TRUE) &&
  1212.                         (flags & UI_EMS_INPUT_BOX_TRANSPARENT_BACKGROUND))
  1213.                     {
  1214.                         gdi_draw_solid_rect(x1, y1, x2, y2, GDI_COLOR_TRANSPARENT);
  1215.                     }
  1216.                     else
  1217.                     {
  1218.                         gui_draw_filled_area(x1, y1, x2, y2, &f);
  1219.                     }
  1220.                 }
  1221.                 /* 070405 Calvin End */
  1222.             }
  1223.             else    /* include info area */
  1224.             {
  1225.                 if (r2lMMIFlag)
  1226.                 {
  1227.                     gui_set_clip(
  1228.                         x1 - b->vbar.width,
  1229.                         y1 - wgui_EMS_inputbox_information_bar_height,
  1230.                         x2 /* +b->vbar.width */ ,
  1231.                         y2);
  1232.                 }
  1233.                 else
  1234.                 {
  1235.                     gui_set_clip(x1, y1 - wgui_EMS_inputbox_information_bar_height, x2, y2);
  1236.                 }
  1237.                 f.flags = UI_FILLED_AREA_TYPE_BITMAP;
  1238.                 f.b = get_image(WGUI_VOLUME_LEVEL1);
  1239.                 if (r2lMMIFlag)
  1240.                 {
  1241.                     /* 070405 Calvin Start */
  1242.                     if ((wgui_is_wallpaper_on_bottom() == MMI_TRUE) &&
  1243.                         (flags & UI_EMS_INPUT_BOX_TRANSPARENT_BACKGROUND))
  1244.                     {
  1245.                         gdi_draw_solid_rect(
  1246.                             x1 - b->vbar.width,
  1247.                             y1 - wgui_EMS_inputbox_information_bar_height,
  1248.                             x2 /* + b->vbar.width */ ,
  1249.                             y2,
  1250.                             GDI_COLOR_TRANSPARENT);
  1251.                     }
  1252.                     else
  1253.                     {
  1254.                         gui_draw_filled_area(
  1255.                             x1 - b->vbar.width,
  1256.                             y1 - wgui_EMS_inputbox_information_bar_height,
  1257.                             x2 /* + b->vbar.width */ ,
  1258.                             y2,
  1259.                             &f);
  1260.                     }
  1261.                     /* 070405 Calvin End */
  1262.                     gui_draw_rectangle(
  1263.                         x1 - b->vbar.width,
  1264.                         y1,
  1265.                         x2 /* + b->vbar.width */ ,
  1266.                         y2,
  1267.                         b->boundary_color);
  1268.                 }
  1269.                 else
  1270.                 {
  1271.                     /* 070405 Calvin Start */
  1272.                     if ((wgui_is_wallpaper_on_bottom() == MMI_TRUE) &&
  1273.                         (flags & UI_EMS_INPUT_BOX_TRANSPARENT_BACKGROUND))
  1274.                     {
  1275.                         gdi_draw_solid_rect(
  1276.                             x1,
  1277.                             y1 - wgui_EMS_inputbox_information_bar_height,
  1278.                             x2,
  1279.                             y2,
  1280.                             GDI_COLOR_TRANSPARENT);
  1281.                     }
  1282.                     else
  1283.                     {
  1284.                         gui_draw_filled_area(x1, y1 - wgui_EMS_inputbox_information_bar_height, x2, y2, &f);
  1285.                     }
  1286.                     /* 070405 Calvin End */
  1287.                     gui_draw_rectangle(x1, y1, x2, y2, b->boundary_color);
  1288.                 }
  1289.                 if (flags & UI_MULTI_LINE_INPUT_BOX_USE_PRESET_CLIPPING)
  1290.                 {
  1291.                     gui_set_clip_preset(x1, y1, x2 + 2, y2 + 2);
  1292.                 }
  1293.                 else
  1294.                 {
  1295.                     gui_set_clip(x1, y1, x2 + 2, y2 + 2);
  1296.                 }
  1297.             }
  1298.         }
  1299.     }
  1300.     if (!(flags & UI_EMS_INPUT_BOX_DISABLE_SCROLLBAR))
  1301.     {
  1302.         x2 -= b->vbar.width;
  1303.     }
  1304.     box_width = (x2 - x1 - 2);
  1305.     center_x = x1 + (box_width >> 1) + 1;
  1306.     ty = y1 + 2 + b->display_y;
  1307.     if (flags & UI_EMS_INPUT_BOX_DISPLAY_HEADER)
  1308.     {
  1309.         S32 h, ty1, ty2;
  1310.         h = b->measure_header();
  1311.         b->header_height = h;
  1312.         ty1 = ty - 2;
  1313.         ty2 = ty + h - 1;
  1314.         if (!disable_draw_flag && (ty2 > y1))
  1315.         {
  1316.             b->display_header(x1, ty1, x2, ty2);
  1317.         }
  1318.         ty += h;
  1319.     }
  1320.     else
  1321.     {
  1322.         b->header_height = 0;
  1323.     }
  1324.     if (!disable_draw_flag)
  1325.     {
  1326.         if (flags & UI_EMS_INPUT_BOX_STATE_MULTITAP)
  1327.         {
  1328.         #ifdef __MMI_BIDI_ALG__
  1329.             if (arabic_char_flag)
  1330.             {
  1331.                 selection_flag = 0;
  1332.             }
  1333.             else
  1334.         #endif /* __MMI_BIDI_ALG__ */ 
  1335.                 selection_flag = 1;
  1336.         }
  1337.         if ((flags & UI_EMS_INPUT_BOX_OVERWRITE_MODE) && (!selection_flag))
  1338.         {
  1339.             overwrite_mode_flag = 1;
  1340.         }
  1341.         gui_set_clip(x1 + 1, y1 + 1, x2, y2 - 1);
  1342.         EMS_SET_FONT(&UI_EMS_inputbox_medium_font);
  1343.         /* gui_set_text_clip(x1+2,y1+2,x2-2,y2-2); */
  1344.         EMS_SET_TEXT_COLOR(normal_text_color);
  1345.     }
  1346.     line_start_position.Object = NULL;
  1347.     line_start_position.OffsetToText = 0;
  1348.     current_text_format = NULL;
  1349.     cursor_ay = 0;
  1350.     text_format_object_count = 0;
  1351.     b->first_displayed_line = -1;
  1352.     b->last_displayed_line = -1;
  1353.     EMS_map_position(data, &data->CurrentPosition, &mapped_cursor_position);
  1354.     line_alignment = EMS_ALIGN_LANG_DEP;
  1355. #if defined(__MMI_LANG_VIETNAMESE__)
  1356.     /* W05.38 Fix Viet Tone Cursor Moving Issue */
  1357.     if ((flags & UI_EMS_INPUT_BOX_DISABLE_DRAW) && (data->textLength != 0))
  1358.     {
  1359.         EMSPosition temp_cursor_position;
  1360.         EMS_map_position(data, &data->CurrentPosition, &temp_cursor_position);
  1361.         object_type = gui_EMS_input_box_get_next_object(data, &temp_cursor_position, &current_character, &current_object);
  1362.         if (1 == object_type)
  1363.         {
  1364.             if ((current_character >= 0x0300) && (current_character <= 0x0323))
  1365.             {
  1366.                 EMS_map_position(data, &data->CurrentPosition, &temp_cursor_position);
  1367.                 object_type = gui_EMS_input_box_get_previous_object(data, &temp_cursor_position, &dummy_c, &current_object);    /* get next character */
  1368.                 if (1 == object_type)
  1369.                 {
  1370.                     viet_vowel = mmi_viet_vowel_letter(dummy_c);
  1371.                     if (VIET_VOWEL_NONE != viet_vowel)
  1372.                     {
  1373.                         tone_mark = mmi_viet_tone_mark(current_character);
  1374.                         if (VIET_TONE_NONE != tone_mark)
  1375.                         {
  1376.                             current_character = mmi_viet_combine_vowel_tone(viet_vowel, tone_mark);
  1377.                             gui_EMS_input_box_forward_cursor(b);
  1378.                         }
  1379.                     }
  1380.                 }
  1381.             }
  1382.         }
  1383.     }
  1384. #endif /* defined(__MMI_LANG_VIETNAMESE__) */ 
  1385.     while (!done)
  1386.     {   /* First Pass: Find the start and end of a line, line height and line width   */
  1387.         line_start_text_format = current_text_format;
  1388.     #ifdef __MMI_MESSAGES_EMS__
  1389.         gui_EMS_input_box_set_text_format(b, current_text_format);
  1390.     #else /* __MMI_MESSAGES_EMS__ */ 
  1391.         {
  1392.             EMS_SET_FONT(&UI_EMS_inputbox_medium_font);
  1393.             EMS_SET_TEXT_COLOR(UI_EMS_inputbox_text_color);
  1394.             b->flags &= ~(UI_EMS_INPUT_BOX_CURRENT_ALIGN_LEFT |
  1395.                           UI_EMS_INPUT_BOX_CURRENT_ALIGN_RIGHT | UI_EMS_INPUT_BOX_CURRENT_ALIGN_CENTER);
  1396.         }
  1397.     #endif /* __MMI_MESSAGES_EMS__ */ 
  1398.         break_line_height = line_height = gui_get_character_height();
  1399.         current_position = line_start_position;
  1400.         break_text_format_object_count = text_format_object_count;
  1401.         /* PMT SHAILESH START 20060619 */
  1402.     #ifdef __MMI_HINDI_ALG__
  1403.         break_line_width = line_width = 1;
  1404.     #else 
  1405.         break_line_width = line_width = 0;
  1406.     #endif 
  1407.         /* PMT SHAILESH END 20060619 */
  1408.         break_line_object_count = line_object_count = 0;
  1409.         break_line_text_object_count = line_text_object_count = 0;
  1410.     #ifdef __MMI_HINDI_ALG__
  1411.         hindi_cache_counter = 0;
  1412.         saved_ems_skip_moves = skip_ems_moves = 1;
  1413.         object_width = 0;
  1414.         move_ems_cursor_prev_p = (data->textBuffer + line_start_position.OffsetToText); /* TARUN */
  1415.     #endif /* __MMI_HINDI_ALG__ */ 
  1416.         first_object_flag = 1;
  1417.         while (!done)
  1418.         {
  1419.             previous_position = current_position;
  1420.             if (TestLastPosition(data, &current_position))
  1421.             {
  1422.                 current_character = 0;
  1423.                 EMS_SET_BREAK_POSITION();
  1424.                 /* MTK Terry for adjust the line width with italic style */
  1425.                 if (UI_EMS_inputbox_current_font.italic && pre_character != 0)
  1426.                 {
  1427.                     break_line_width += 3;
  1428.                 }
  1429.                 done = 1;
  1430.                 break;
  1431.             }
  1432.         #ifdef __MMI_HINDI_ALG__
  1433.             PRINT_INFORMATION_2((MMI_TRACE_INFO, "pixtel_UI_show_EMS_input_box[skip_ems_moves]:%d  ", skip_ems_moves));
  1434.             while (skip_ems_moves--)
  1435.             {
  1436.         #endif /* __MMI_HINDI_ALG__ */ 
  1437.                 object_type = gui_EMS_input_box_get_next_object(
  1438.                                 data,
  1439.                                 &current_position,
  1440.                                 &current_character,
  1441.                                 &current_object);
  1442.             #ifdef __MMI_HINDI_ALG__
  1443.                 /* MTK Begin Hindi patch 0425 */
  1444.                 if ((skip_ems_moves >= 1) && (object_type == 2) && (current_object->Type == EMS_TYPE_TEXT_FORMAT))
  1445.                 {
  1446.                     object_type = gui_EMS_input_box_get_next_object(
  1447.                                     data,
  1448.                                     &current_position,
  1449.                                     &current_character,
  1450.                                     &current_object);
  1451.                 }
  1452.                 /* MTK End Hindi patch 0425 */
  1453.             }
  1454.             /* Not when object is images */
  1455.             if (HF_HINDI_RANGE(current_character) && !(object_type == 2))
  1456.             {
  1457.                 object_type = 1;
  1458.             }
  1459.             #endif /* __MMI_HINDI_ALG__ */ 
  1460.             switch (object_type)
  1461.             {
  1462.                 case 0:
  1463.                     done = 1;
  1464.                     break;
  1465.                 case 1: /* character */
  1466.             #if(EMS_DISPLAY_SPECIAL_CHARACTERS)
  1467.                     if (UI_TEST_CR_CHARACTER(current_character) ||
  1468.                         UI_TEST_LF_CHARACTER(current_character) || UI_TEST_ESC_CHARACTER(current_character))
  1469.                     {
  1470.                         object_width = 10;
  1471.                         object_height = 10;
  1472.                     }
  1473.                     else
  1474.             #else /* (EMS_DISPLAY_SPECIAL_CHARACTERS) */ 
  1475.                 #if(EMS_USE_CRLF_COMBINATION)
  1476.                     if (UI_TEST_CR_CHARACTER(current_character) &&
  1477.                         (current_position.OffsetToText < data->textLength) &&
  1478.                         UI_TEST_LF_CHARACTER(data->textBuffer[current_position.OffsetToText]))
  1479.                     {
  1480.                     #ifdef __MMI_HINDI_ALG__
  1481.                         skip_ems_moves = 1;
  1482.                     #endif 
  1483.                         object_width = 0;
  1484.                         object_height = line_height;
  1485.                     }
  1486.                     else if (UI_TEST_LF_CHARACTER(current_character) || UI_TEST_CR_CHARACTER(current_character))
  1487.                     {
  1488.                     #ifdef __MMI_HINDI_ALG__
  1489.                         skip_ems_moves = 1;
  1490.                     #endif 
  1491.                         object_width = 0;
  1492.                         object_height = line_height;
  1493.                     }
  1494.                     else
  1495.                 #endif /* (EMS_USE_CRLF_COMBINATION) */ 
  1496.                 #if(EMS_USE_ESC_COMBINATION)
  1497.                     if (UI_TEST_ESC_CHARACTER(current_character))
  1498.                     {
  1499.                     #ifdef __MMI_HINDI_ALG__
  1500.                         skip_ems_moves = 1;
  1501.                     #endif 
  1502.                         object_width = 0;
  1503.                         object_height = line_height;
  1504.                     }
  1505.                     else
  1506.                 #endif /* (EMS_USE_ESC_COMBINATION) */ 
  1507.             #endif /* (EMS_DISPLAY_SPECIAL_CHARACTERS) */ 
  1508.                     if (UI_STRING_END_OF_STRING_CHARACTER(current_character))
  1509.                     {
  1510.                         /* PMT FARHAD START 20050708 */
  1511.                     #ifdef __MMI_HINDI_ALG__
  1512.                         skip_ems_moves = 1;
  1513.                         /* PMT Start 20060725 */
  1514.                         move_ems_cursor_prev_p += 2;
  1515.                         /* PMT End 20060725 */
  1516.                     #endif /* __MMI_HINDI_ALG__ */ 
  1517.                         /* PMT FARHAD END 20050708 */
  1518.                         object_width = 0;
  1519.                         object_height = line_height;
  1520.                     }
  1521.                     else
  1522.                     {
  1523.                     #if defined(__MMI_LANG_VIETNAMESE__)
  1524.                         if ((current_character > 0x0040) && (current_character < 0x01B1))
  1525.                         {
  1526.                             object_type = gui_EMS_input_box_get_next_object(data, &current_position, &dummy_c, &current_object);        /* get next character */
  1527.                             if (1 == object_type)
  1528.                             {
  1529.                                 tone_mark = mmi_viet_tone_mark(dummy_c);
  1530.                                 if (VIET_TONE_NONE != tone_mark)
  1531.                                 {
  1532.                                     viet_vowel = mmi_viet_vowel_letter(current_character);
  1533.                                     if (VIET_VOWEL_NONE != viet_vowel)
  1534.                                     {
  1535.                                         current_character = mmi_viet_combine_vowel_tone(viet_vowel, tone_mark);
  1536.                                     }
  1537.                                     else
  1538.                                     {
  1539.                                         object_type = gui_EMS_input_box_get_previous_object(
  1540.                                                         data,
  1541.                                                         &current_position,
  1542.                                                         &dummy_c,
  1543.                                                         &current_object);
  1544.                                     }
  1545.                                 }
  1546.                                 else
  1547.                                 {
  1548.                                     object_type = gui_EMS_input_box_get_previous_object(
  1549.                                                     data,
  1550.                                                     &current_position,
  1551.                                                     &dummy_c,
  1552.                                                     &current_object);
  1553.                                 }
  1554.                             }
  1555.                             else if (0 != object_type)
  1556.                             {
  1557.                                 object_type = gui_EMS_input_box_get_previous_object(
  1558.                                                 data,
  1559.                                                 &current_position,
  1560.                                                 &dummy_c,
  1561.                                                 &current_object);
  1562.                             }
  1563.                         }
  1564.                     #endif /* defined(__MMI_LANG_VIETNAMESE__) */ 
  1565.                     #if defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__)
  1566.                         if (IS_ARABIC_CHARACTER(current_character))
  1567.                         {
  1568.                             U32 idx = gui_get_ems_text_actual_idx(b, current_position.OffsetToText) / 2 - 1;
  1569.                             U32 ligature_move = 0;
  1570.                             UI_character_type dummy_c_arabic = 0;
  1571.                             current_character = (UI_character_type) shaping_str[OrgToSha[idx]];
  1572.                             while (idx < unshaped_text_len)
  1573.                             {
  1574.                                 if (OrgToSha[idx] == OrgToSha[idx + 1])
  1575.                                 {
  1576.                                     ligature_move++;
  1577.                                 }
  1578.                                 else
  1579.                                 {
  1580.                                     break;
  1581.                                 }
  1582.                                 idx++;
  1583.                             }
  1584.                             while (ligature_move > 0)
  1585.                             {
  1586.                                 object_type = gui_EMS_input_box_get_next_object(data, &current_position, &dummy_c_arabic, &current_object);     /* get next character */
  1587.                                 ligature_move--;
  1588.                             }
  1589.                         }
  1590.                     #endif /* defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__) */ 
  1591.                     #ifdef __MMI_HINDI_ALG__
  1592.                         /* MTK Terry for Cursor Height Issue */
  1593.                         if (UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
  1594.                         {
  1595.                             /* PMT START FIX HINDI ISSUES 20060604 */
  1596.                             gui_measure_character(current_character, &object_width, &object_height);
  1597.                             if (object_height > line_height)
  1598.                             {
  1599.                                 line_height = object_height;
  1600.                             }
  1601.                             object_height = gui_get_character_height();
  1602.                             /* PMT END FIX HINDI ISSUES 20060604 */
  1603.                         }
  1604.                         else
  1605.                         {
  1606.                             gui_measure_character(current_character, &object_width, &object_height);
  1607.                         }
  1608.                         PRINT_INFORMATION_2((MMI_TRACE_INFO, "pixtel_UI_show_EMS_input_box[object_height]:%d  ",
  1609.                                              object_height));
  1610.                     #else /* __MMI_HINDI_ALG__ */ 
  1611.                         gui_measure_character(current_character, &object_width, &object_height);
  1612.                     #endif /* __MMI_HINDI_ALG__ */ 
  1613.                         if (!RequireToMoveCursor(pre_character, current_character))
  1614.                         {
  1615.                             object_width = 0;
  1616.                         #ifdef __MMI_HINDI_ALG__
  1617.                             skip_ems_moves = 1;
  1618.                             /* START TARUN PMT 20050128 */
  1619.                             move_ems_cursor_prev_p += 2;
  1620.                             /* END TARUN PMT 20050128 */
  1621.                         #endif /* __MMI_HINDI_ALG__ */ 
  1622.                         }
  1623.                         else
  1624.                         {
  1625.                         #ifdef __MMI_HINDI_ALG__
  1626.                             /* Move pointer by the cluster width */
  1627.                             //For performance issue b->text is also assumed as current cluster pos
  1628.                             //move_ems_cursor_curr_p = hf_get_next_cluster_p(data->textBuffer,move_ems_cursor_prev_p);
  1629.                             move_ems_cursor_curr_p = hf_get_next_cluster_p(move_ems_cursor_prev_p, move_ems_cursor_prev_p);
  1630.                             skip_ems_moves = move_ems_cursor_curr_p - move_ems_cursor_prev_p;   /* Number of moves */
  1631.                             skip_ems_moves = skip_ems_moves >> 1;
  1632.                             saved_ems_skip_moves = skip_ems_moves;      /* Save moves to skip the current_text_p also */
  1633.                             /* Calculate the width of current cluster as well as english character */
  1634.                             /* object_width = hf_size_of_current_cluster(data->textBuffer,move_ems_cursor_curr_p,0); */
  1635.                             object_width = hf_size_of_current_cluster(move_ems_cursor_prev_p, move_ems_cursor_curr_p, 0);
  1636.                             /* for bold italic in hindi */
  1637.                             if (UI_EMS_inputbox_current_font.italic || UI_EMS_inputbox_current_font.bold)
  1638.                             {
  1639.                                 object_width += 1;
  1640.                             }
  1641.                             PRINT_INFORMATION_2((MMI_TRACE_INFO, "pixtel_UI_show_EMS_input_box[object_width]:%d  ",
  1642.                                                  object_width));
  1643.                             if (UI_TEST_CR_CHARACTER(current_character))
  1644.                             {
  1645.                                 object_width = 0;
  1646.                             }
  1647.                             move_ems_cursor_prev_p = move_ems_cursor_curr_p;
  1648.                         #else /* __MMI_HINDI_ALG__ */ 
  1649.                             /* Arabic Connectivity issue */    
  1650.                         #if defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__
  1651.                             if (!IS_ARABIC_CHARACTER(current_character))
  1652.                             {
  1653.                         #endif
  1654.                                 /* PMT START 17082006 */
  1655.                                 if (!UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
  1656.                                     /* PMT END 17082006 */
  1657.                                 {
  1658.                                     object_width += 1;
  1659.                                 }
  1660.                         #if defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__                        
  1661.                              }
  1662.                         #endif 
  1663.                         #endif /* __MMI_HINDI_ALG__ */ 
  1664.                         }
  1665.                     }
  1666.                     /* MTK Terry for adjust the line width with italic style */
  1667.                     if ((line_width + object_width + 1) > box_width ||
  1668.                         (UI_EMS_inputbox_current_font.italic && (line_width + object_width + 3) > box_width))
  1669.                     {
  1670.                         line_width += object_width;
  1671.                     }
  1672.                     else
  1673.                     {
  1674.                         U8 bflag;
  1675.                         UI_EMS_INPUT_BOX_BREAK_CHARACTER(current_character, bflag);
  1676.                         if (bflag)
  1677.                         {
  1678.                             EMS_SET_NEXT_BREAK_POSITION();
  1679.                         }
  1680.                         line_width += object_width;
  1681.                     #ifdef __MMI_HINDI_ALG__
  1682.                         if (UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
  1683.                         {
  1684.                             hindi_ems_cluster_counter = line_object_count;
  1685.                             while (saved_ems_skip_moves--)
  1686.                             {
  1687.                                 object_width_cache[hindi_ems_cluster_counter] = 0;
  1688.                                 object_height_cache[hindi_ems_cluster_counter] = (U8) object_height;
  1689.                                 hindi_ems_cluster_counter++;
  1690.                             }
  1691.                             hindi_cluster_cache[hindi_cache_counter] = object_width;
  1692.                         }
  1693.                         else
  1694.                     #endif /* __MMI_HINDI_ALG__ */ 
  1695.                         {
  1696.                             object_width_cache[line_object_count] = (U8) object_width;
  1697.                             /*
  1698.                              * #ifdef __MMI_BIDI_ALG__
  1699.                              * if(arabic_char_flag)
  1700.                              * object_height_cache[line_object_count]=(byte)gui_get_character_height()+2;
  1701.                              * else
  1702.                              * #endif
  1703.                              */
  1704.                             object_height_cache[line_object_count] = (U8) object_height;
  1705.                         }
  1706.                         if (object_height > line_height)
  1707.                         {
  1708.                             line_height = object_height;
  1709.                         }
  1710.                     #ifdef __MMI_HINDI_ALG__
  1711.                         line_object_count += skip_ems_moves;
  1712.                         line_text_object_count += skip_ems_moves;
  1713.                         hindi_cache_counter++;
  1714.                     #else /* __MMI_HINDI_ALG__ */ 
  1715.                         line_object_count++;
  1716.                         line_text_object_count++;
  1717.                     #endif /* __MMI_HINDI_ALG__ */ 
  1718.                         if (UI_STRING_LINE_BREAK_CHARACTER(current_character))
  1719.                         {
  1720.                             EMS_SET_BREAK_POSITION();
  1721.                             if (text_format_object_count <= 1)
  1722.                             {
  1723.                                 line_alignment = EMS_ALIGN_LANG_DEP;
  1724.                             }
  1725.                         }
  1726.                         if (text_format_object_count)
  1727.                         {
  1728.                             text_format_object_count--;
  1729.                             if ((text_format_object_count == 0) && (current_position.OffsetToText < data->textLength))
  1730.                             {
  1731.                             #ifdef __MMI_MESSAGES_EMS__
  1732.                                 gui_EMS_input_box_set_text_format(b, &UI_EMS_normal_text_format_object);
  1733.                             #else /* __MMI_MESSAGES_EMS__ */ 
  1734.                                 {
  1735.                                     EMS_SET_FONT(&UI_EMS_inputbox_medium_font);
  1736.                                     EMS_SET_TEXT_COLOR(UI_EMS_inputbox_text_color);
  1737.                                     b->flags &= ~(UI_EMS_INPUT_BOX_CURRENT_ALIGN_LEFT |
  1738.                                                   UI_EMS_INPUT_BOX_CURRENT_ALIGN_RIGHT |
  1739.                                                   UI_EMS_INPUT_BOX_CURRENT_ALIGN_CENTER);
  1740.                                 }
  1741.                             #endif /* __MMI_MESSAGES_EMS__ */ 
  1742.                                 object_height = gui_get_character_height();
  1743.                                 if (object_height > line_height)
  1744.                                 {
  1745.                                     line_height = object_height;
  1746.                                 }
  1747.                                 if (line_object_count == 0)
  1748.                                 {
  1749.                                     line_height = object_height;
  1750.                                 }
  1751.                             }
  1752.                         }
  1753.                         /* MTK Terry for FireFly#159 */
  1754.                     #ifdef __MMI_HINDI_ALG__
  1755.                         /* Hindi condition also added for word wrap issue */
  1756.                         if ((!UI_MULTI_LINE_INPUT_BOX_ALPHABETIC_CHARACTER(current_character)) &&
  1757.                             (!UI_HINDI_CHARACTER_UCS2_RANGE(current_character)))
  1758.                     #else /* __MMI_HINDI_ALG__ */ 
  1759.                         if ((!UI_MULTI_LINE_INPUT_BOX_ALPHABETIC_CHARACTER(current_character)))
  1760.                     #endif /* __MMI_HINDI_ALG__ */ 
  1761.                         {
  1762.                             break_line_object_count = 0;
  1763.                         }
  1764.                     }
  1765.                     pre2_character = pre_character;
  1766.                     pre_character = current_character;
  1767.                     /* MTK end */
  1768.                     break;
  1769.                 #ifdef __MMI_MESSAGES_EMS__
  1770.                 case 2: /* object */
  1771.                     if (current_object->Type == EMS_TYPE_TEXT_FORMAT)
  1772.                     {
  1773.                         line_alignment = current_object->data->text_format.Alignment;
  1774.                         gui_EMS_input_box_set_text_format(b, current_object);
  1775.                         text_format_object_count = ((current_object->data->text_format.textLength) >> 1);
  1776.                         object_height = gui_get_character_height();
  1777.                         if (object_height > line_height)
  1778.                         {
  1779.                             line_height = object_height;
  1780.                         }
  1781.                         if (line_object_count == 0)
  1782.                         {
  1783.                             line_height = object_height;
  1784.                         }
  1785.                     }
  1786.                     else
  1787.                     {
  1788.                         gui_EMS_input_box_measure_object(current_object, &object_width, &object_height);
  1789.                         object_width += 2;
  1790.                         if (first_object_flag)
  1791.                         {
  1792.                             object_width += 1;
  1793.                         }
  1794.                         else
  1795.                         {
  1796.                             line_width += 3;
  1797.                         }
  1798.                         object_height += 1; /* 1 pixel gap between lines  */
  1799.                         /* MTK Elvis 20040322 to avoid the cursor overlap with scroll bar */
  1800.                         if ((line_width + object_width + 1) > box_width)
  1801.                             /* MTK end */
  1802.                         {
  1803.                             line_width += object_width;
  1804.                             /* Removed line breaking rule for objects */
  1805.                             /* EMS_SET_BREAK_POSITION(); */
  1806.                         }
  1807.                         else
  1808.                         {
  1809.                             if (object_height > line_height)
  1810.                             {
  1811.                                 line_height = object_height;
  1812.                             }
  1813.                             line_width += object_width;
  1814.                             if (first_object_flag)
  1815.                             {
  1816.                                 object_width -= 2;
  1817.                             }
  1818.                             object_width_cache[line_object_count] = (S8) object_width;
  1819.                             object_height_cache[line_object_count] = (S8) object_height;
  1820.                             line_object_count++;
  1821.                             /* Removed line breaking rule for objects */
  1822.                             /* EMS_SET_BREAK_POSITION(); */
  1823.                         }
  1824.                     }
  1825.                     current_character = 0;
  1826.                 #ifdef __MMI_HINDI_ALG__
  1827.                     skip_ems_moves = 1;
  1828.                 #endif 
  1829.                     break;
  1830.                     /* PMT FARHAD START 20050708 */
  1831.                 #else /* __MMI_MESSAGES_EMS__ */ 
  1832.                 case 2: /* object */
  1833.                     current_character = 0;
  1834.                 #ifdef __MMI_HINDI_ALG__
  1835.                     skip_ems_moves = 1;
  1836.                 #endif 
  1837.                     break;
  1838.                     /* PMT FARHAD END 20050708 */
  1839.                 #endif /* __MMI_MESSAGES_EMS__ */ 
  1840.             }
  1841.             first_object_flag = 0;
  1842.             /* MTK Elvis to avoid the cursor overlap with scroll bar */
  1843.             /* MTK Terry for adjust the line width with italic style only for character type */
  1844.             if ((line_width + 1 > box_width) ||
  1845.                 (UI_EMS_inputbox_current_font.italic && (line_width + 3) > box_width) && (1 == object_type) ||
  1846.                 UI_STRING_LINE_BREAK_CHARACTER(current_character))
  1847.                 /* MTK end */
  1848.             {
  1849.                 if ((break_line_object_count == 0) && (line_object_count > 0))
  1850.                 {
  1851.                     EMS_SET_BREAK_POSITION();
  1852.                     break_line_width -= object_width;
  1853.                 }
  1854.                 /* MTK Terry for adjust the line width with italic style */
  1855.                 if ((UI_EMS_inputbox_current_font.italic && (line_width + 3) > box_width) && pre_character != 0)
  1856.                 {
  1857.                     break_line_width += 3;
  1858.                 }
  1859.                 break;
  1860.             }
  1861.         }
  1862.         /* Second pass: Display the line */
  1863.         pre2_character = 0;
  1864.         pre_character = 0;
  1865.     #ifdef __MMI_HINDI_ALG__
  1866.         ems_cluster_width = 0;
  1867.         ems_cursor_width = 0;
  1868.     #endif /* __MMI_HINDI_ALG__ */ 
  1869.         line_width = break_line_width;
  1870.         line_height = break_line_height;
  1871.         current_text_format = line_start_text_format;
  1872.         current_position = line_start_position;
  1873.         alignment = break_line_alignment;
  1874.         if ((alignment != b->text_format.Alignment) &&
  1875.             (break_line_text_object_count == 0) && (b->current_line == n_lines) && (EMS_view_mode == 0))
  1876.         {
  1877.             alignment = b->text_format.Alignment;
  1878.         }
  1879.         /*       Old code: For testing                  */
  1880.         /*       else if((break_line_text_object_count!=0) && (data->textLength==0))
  1881.            alignment=b->text_format.Alignment;    */
  1882.         switch (alignment)
  1883.         {
  1884.             case EMS_ALIGN_LEFT:
  1885.                 if (default_direction == BIDI_L)
  1886.                 {
  1887.                     tx = x1 + 2;
  1888.                 }
  1889.                 else
  1890.                 {
  1891.                     tx = x1 + line_width + 2;
  1892.                 }
  1893.                 break;
  1894.             case EMS_ALIGN_RIGHT:
  1895.                 if (default_direction == BIDI_L)
  1896.                 {
  1897.                     tx = x2 - line_width - 2;
  1898.                 }
  1899.                 else
  1900.                 {
  1901.                     tx = x1 + box_width;
  1902.                 }
  1903.                 break;
  1904.             case EMS_ALIGN_CENTER:
  1905.                 if (default_direction == BIDI_L)
  1906.                 {
  1907.                     tx = center_x - (line_width >> 1);
  1908.                 }
  1909.                 else
  1910.                 {
  1911.                     tx = center_x + (line_width >> 1);
  1912.                 }
  1913.                 break;
  1914.             case EMS_ALIGN_LANG_DEP:
  1915.                 if (default_direction == BIDI_L)
  1916.                 {
  1917.                     tx = x1 + 2;
  1918.                 }
  1919.                 else
  1920.                 {
  1921.                     tx = x1 + box_width;
  1922.                 }
  1923.                 break;
  1924.             default:
  1925.                 tx = x1 + 2;
  1926.                 break;
  1927.         }
  1928.         if (tx < (x1 + 2))
  1929.         {
  1930.             tx = x1 + 2;
  1931.         }
  1932.         cursor_ax = tx - (x1 + 2);
  1933.         if ((b->first_displayed_line == -1) && (ty >= (y1 + 2)))
  1934.         {
  1935.             b->first_displayed_line = n_lines;
  1936.         }
  1937.         if ((ty + line_height) <= y2)
  1938.         {
  1939.             b->last_displayed_line = n_lines;
  1940.         }
  1941.         b->line_positions[n_lines] = line_start_position;
  1942.         b->line_object_counts[n_lines] = (U8) break_line_object_count;
  1943.         b->line_x_positions[n_lines] = (U8) cursor_ax;
  1944.         n_lines++;
  1945.     #ifdef __MMI_MESSAGES_EMS__
  1946.         gui_EMS_input_box_set_text_format(b, current_text_format);
  1947.     #else /* __MMI_MESSAGES_EMS__ */ 
  1948.         {
  1949.             EMS_SET_FONT(&UI_EMS_inputbox_medium_font);
  1950.             EMS_SET_TEXT_COLOR(UI_EMS_inputbox_text_color);
  1951.             b->flags &= ~(UI_EMS_INPUT_BOX_CURRENT_ALIGN_LEFT |
  1952.                           UI_EMS_INPUT_BOX_CURRENT_ALIGN_RIGHT | UI_EMS_INPUT_BOX_CURRENT_ALIGN_CENTER);
  1953.         }
  1954.     #endif /* __MMI_MESSAGES_EMS__ */ 
  1955.         object_height = gui_get_character_height();
  1956.         text_format_object_count = break_text_format_object_count;
  1957.         display_done = 0;
  1958.         line_object_count = 0;
  1959.     #ifdef __MMI_HINDI_ALG__
  1960.         hindi_cache_counter = 0;
  1961.     #endif 
  1962.         first_object_flag = 1;
  1963.     #if(EMS_ENABLE_SPECIAL_FONT_DISPLAY)
  1964.         if (current_text_format != NULL)
  1965.         {
  1966.             if (current_text_format->data->text_format.isUnderline == KAL_TRUE)
  1967.             {
  1968.                 underline_flag = 1;
  1969.             }
  1970.             else
  1971.             {
  1972.                 underline_flag = 0;
  1973.             }
  1974.             if (current_text_format->data->text_format.isStrikethrough == KAL_TRUE)
  1975.             {
  1976.                 strikethrough_flag = 1;
  1977.             }
  1978.             else
  1979.             {
  1980.                 strikethrough_flag = 0;
  1981.             }
  1982.         }
  1983.     #endif /* (EMS_ENABLE_SPECIAL_FONT_DISPLAY) */ 
  1984.     #ifdef __MMI_BIDI_ALG__
  1985.         if (!(flags & UI_EMS_INPUT_BOX_DISABLE_DRAW) && arabic_char_flag)
  1986.         {
  1987.             /* get last character unicode of previous line */
  1988.             if (n_lines == 1)
  1989.             {
  1990.                 if (break_line_text_object_count < data->textLength / 2)
  1991.                 {
  1992.                 #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1993.                     test_current_character = (data->textBuffer[current_position.OffsetToText +
  1994.                                                                ((1 + break_line_text_object_count) * ENCODING_LENGTH) -
  1995.                                                                1] | (data->textBuffer[current_position.OffsetToText +
  1996.                                                                                       ((1 +
  1997.                                                                                         break_line_text_object_count) *
  1998.                                                                                        ENCODING_LENGTH) - 2] << 8));
  1999.                 #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2000.                     test_current_character = (data->textBuffer[current_position.OffsetToText +
  2001.                                                                ((1 + break_line_text_object_count) * ENCODING_LENGTH) -
  2002.                                                                2] | (data->textBuffer[current_position.OffsetToText +
  2003.                                                                                       ((1 +
  2004.                                                                                         break_line_text_object_count) *
  2005.                                                                                        ENCODING_LENGTH) - 1] << 8));
  2006.                 #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2007.                 }
  2008.                 else
  2009.                 {
  2010.                 #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2011.                     test_current_character = (data->textBuffer[current_position.OffsetToText +
  2012.                                                                ((break_line_text_object_count) * ENCODING_LENGTH) - 1] |
  2013.                                               (data->textBuffer[current_position.OffsetToText +
  2014.                                                                 ((break_line_text_object_count) * ENCODING_LENGTH) -
  2015.                                                                 2] << 8));
  2016.                 #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2017.                     test_current_character = (data->textBuffer[current_position.OffsetToText +
  2018.                                                                ((break_line_text_object_count) * ENCODING_LENGTH) - 2] |
  2019.                                               (data->textBuffer[current_position.OffsetToText +
  2020.                                                                 ((break_line_text_object_count) * ENCODING_LENGTH) -
  2021.                                                                 1] << 8));
  2022.                 #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2023.                 }
  2024.             }
  2025.             else
  2026.             {
  2027.             #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  2028.                 test_current_character = (data->textBuffer[current_position.OffsetToText - 1] |
  2029.                                           (data->textBuffer[current_position.OffsetToText - 2] << 8));
  2030.             #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2031.                 test_current_character = (data->textBuffer[current_position.OffsetToText - 2] |
  2032.                                           (data->textBuffer[current_position.OffsetToText - 1] << 8));
  2033.             #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  2034.             }
  2035.             if (line_text_object_count > break_line_text_object_count)
  2036.             {
  2037.                 num_char = break_line_text_object_count + 1;
  2038.             }
  2039.             else
  2040.             {
  2041.                 num_char = break_line_text_object_count;    /* line_text_object_count; */
  2042.             }
  2043.             MMI_ASSERT(!(num_char > ((MAX_NUM_OF_CHAR_FOR_EACH_LINE >> 1) - 1)));
  2044.             if (((mapped_cursor_position.OffsetToText) / ENCODING_LENGTH) <
  2045.                 ((current_position.OffsetToText) / ENCODING_LENGTH))
  2046.             {
  2047.                 logical_cur_pos = 0xFFFF;
  2048.             }
  2049.             else if ((((mapped_cursor_position.OffsetToText) - (current_position.OffsetToText)) / ENCODING_LENGTH) >
  2050.                      (num_char))
  2051.             {
  2052.                 logical_cur_pos = 0xFFFF;
  2053.             }
  2054.             else
  2055.             {
  2056.                 logical_cur_pos =
  2057.                     ((mapped_cursor_position.OffsetToText) - (current_position.OffsetToText)) / ENCODING_LENGTH;
  2058.             }
  2059.             if ((n_lines > 1 && logical_cur_pos == 0))
  2060.             {
  2061.                 /* pfnEncodingSchemeToUnicode(&test_current_character, (data->textBuffer + current_position.OffsetToText - ENCODING_LENGTH)); */
  2062.                 if (!UI_STRING_LINE_BREAK_CHARACTER(test_current_character))
  2063.                 {
  2064.                     logical_cur_pos = 0xFFFF;
  2065.                 }
  2066.             }
  2067.             //if(UI_STRING_LINE_BREAK_CHARACTER(current_character))
  2068.             //     logical_cur_pos = 0xFFFF;
  2069.         #if 0
  2070. /* under construction !*/
  2071. /* under construction !*/
  2072. /* under construction !*/
  2073. /* under construction !*/
  2074. /* under construction !*/
  2075. /* under construction !*/
  2076. /* under construction !*/
  2077. /* under construction !*/
  2078. /* under construction !*/
  2079. /* under construction !*/
  2080. /* under construction !*/
  2081. /* under construction !*/
  2082. /* under construction !*/
  2083. /* under construction !*/
  2084. /* under construction !*/
  2085. /* under construction !*/
  2086. /* under construction !*/
  2087. /* under construction !*/
  2088. /* under construction !*/
  2089. /* under construction !*/
  2090. /* under construction !*/
  2091. /* under construction !*/
  2092. /* under construction !*/
  2093. /* under construction !*/
  2094. /* under construction !*/
  2095.         #endif /* 0 */ 
  2096.             {
  2097.                 logical_hilight_start = 0;
  2098.                 logical_hilight_end = 0;
  2099.             }
  2100.             bidi_get_char_type(data->textBuffer + current_position.OffsetToText, (U8*) & default_line_direction);
  2101.             if (default_line_direction == BIDI_R || default_line_direction == AL)
  2102.             {
  2103.                 default_line_direction = BIDI_R;
  2104.             }
  2105.             else
  2106.             {
  2107.                 default_line_direction = BIDI_L;
  2108.             }
  2109.             if (default_direction == BIDI_R && default_line_direction == BIDI_R)
  2110.             {
  2111.                 reverse_flag = MMI_TRUE;
  2112.             }
  2113.             else if (default_direction == BIDI_R && default_line_direction == BIDI_L)
  2114.             {
  2115.                 reverse_flag = MMI_TRUE;
  2116.             }
  2117.             else if (default_direction == BIDI_L && default_line_direction == BIDI_R)
  2118.             {
  2119.                 reverse_flag = MMI_FALSE;
  2120.             }
  2121.             else if (default_direction == BIDI_L && default_line_direction == BIDI_L)
  2122.             {
  2123.                 reverse_flag = MMI_FALSE;
  2124.             }
  2125.             bidi_main(
  2126.                 data->textBuffer + current_position.OffsetToText,
  2127.                 (U16) num_char,
  2128.                 logical_cur_pos,
  2129.                 visual_str,
  2130.                 &visual_str_len,
  2131.                 &visual_cur_pos,
  2132.                 reverse_flag,
  2133.                 MMI_bidi_input_type,
  2134.                 logical_hilight_start,
  2135.                 logical_hilight_end,
  2136.                 &visual_hilight_start,
  2137.                 &visual_hilight_end);
  2138.             temp_text_position = current_position.OffsetToText;
  2139.             memcpy(
  2140.                 temp_text_buffer,
  2141.                 data->textBuffer + current_position.OffsetToText,
  2142.                 visual_str_len * ENCODING_LENGTH);
  2143.             memcpy(data->textBuffer + current_position.OffsetToText, visual_str, visual_str_len * ENCODING_LENGTH);
  2144.             temp_cursor_position = mapped_cursor_position.OffsetToText;
  2145.             if (visual_cur_pos != 0xFFFF)
  2146.             {
  2147.                 mapped_cursor_position.OffsetToText =
  2148.                     line_start_position.OffsetToText + (visual_cur_pos * ENCODING_LENGTH);
  2149.             }
  2150.             
  2151.             //if (default_line_direction == BIDI_L || (default_direction == BIDI_L && default_line_direction == BIDI_R))
  2152.             if(arabic_char_flag)
  2153.             {
  2154.                 pfnUnicodeStrncpy(
  2155.                     (S8*) shaping_str,
  2156.                     (const S8*)b->data->textBuffer,
  2157.                     b->data->textLength / ENCODING_LENGTH);
  2158.                 gui_ems_data_apply_shaping(b, shaping_str);
  2159.             }
  2160.            
  2161.         #if 0
  2162. /* under construction !*/
  2163. /* under construction !*/
  2164. /* under construction !*/
  2165. /* under construction !*/
  2166. /* under construction !*/
  2167. /* under construction !*/
  2168. /* under construction !*/
  2169. /* under construction !*/
  2170. /* under construction !*/
  2171. /* under construction !*/
  2172. /* under construction !*/
  2173. /* under construction !*/
  2174. /* under construction !*/
  2175. /* under construction !*/
  2176. /* under construction !*/
  2177. /* under construction !*/
  2178. /* under construction !*/
  2179. /* under construction !*/
  2180. /* under construction !*/
  2181. /* under construction !*/
  2182. /* under construction !*/
  2183. /* under construction !*/
  2184. /* under construction !*/
  2185. /* under construction !*/
  2186. /* under construction !*/
  2187. /* under construction !*/
  2188.         #endif /* 0 */ 
  2189.         }
  2190.     #endif /* __MMI_BIDI_ALG__ */ /* endif of __MMI_BIDI_ALG__ */
  2191.         while (!display_done)
  2192.         {
  2193.             previous_position = current_position;
  2194.             if (line_object_count >= break_line_object_count)
  2195.             {
  2196.                 break;
  2197.             }
  2198.             if (flags & UI_EMS_INPUT_BOX_WORD_HIGHLIGHT)
  2199.             {
  2200.                 if (current_position.OffsetToText == b->highlight_start_position.OffsetToText)
  2201.                 {
  2202.                 #ifdef __MMI_BIDI_ALG__
  2203.                     if (arabic_char_flag)
  2204.                     {
  2205.                         word_highlight = 0;
  2206.                     }
  2207.                     else
  2208.                 #endif /* __MMI_BIDI_ALG__ */ 
  2209.                         word_highlight = 1;
  2210.                 }
  2211.                 if (current_position.OffsetToText == b->highlight_end_position.OffsetToText)
  2212.                 {
  2213.                     word_highlight = 0;
  2214.                 }
  2215.             }
  2216.             object_type = gui_EMS_input_box_get_next_object(
  2217.                             data,
  2218.                             &current_position,
  2219.                             &current_character,
  2220.                             &current_object);
  2221.             EMS_map_position(data, &previous_position, &mapped_previous_position);
  2222.             EMS_map_position(data, &current_position, &mapped_current_position);
  2223.             switch (object_type)
  2224.             {
  2225.                     int no_show_char;
  2226.                 case 0:
  2227.                     current_character = 0;
  2228.                     display_done = 1;
  2229.                     break;
  2230.                 case 1: /* character */
  2231.                     /* MTK Steven for speed up Editor by only display the characters in the display area */
  2232.                     no_show_char = 0;
  2233.                     if (!(flags & UI_EMS_INPUT_BOX_DISABLE_DRAW))
  2234.                     {
  2235.                         if (((ty + line_height) < (y1 + 2)) || ((ty - line_height) > y2))
  2236.                         {
  2237.                             no_show_char = 1;
  2238.                         }
  2239.                     }
  2240.                 #ifdef __MMI_HINDI_ALG__
  2241.                     /* MTK Begin Hindi patch 0425 */
  2242.                     if (set_hindi_text_format_flag == MMI_TRUE)
  2243.                     {
  2244.                         gui_EMS_input_box_set_text_format(b, hindi_text_format);
  2245.                         set_hindi_text_format_flag = MMI_FALSE;
  2246.                         current_text_format = hindi_text_format;
  2247.                     }
  2248.                     /* MTK End Hindi patch 0425 */
  2249.                 #endif /* __MMI_HINDI_ALG__ */ 
  2250.                 #if defined(__MMI_LANG_VIETNAMESE__)
  2251.                     if ((current_character > 0x0040) && (current_character < 0x01B1))
  2252.                     {
  2253.                         object_type = gui_EMS_input_box_get_next_object(data, &current_position, &dummy_c, &current_object);    /* get next character */
  2254.                         if (1 == object_type)
  2255.                         {
  2256.                             tone_mark = mmi_viet_tone_mark(dummy_c);
  2257.                             if (VIET_TONE_NONE != tone_mark)
  2258.                             {
  2259.                                 viet_vowel = mmi_viet_vowel_letter(current_character);
  2260.                                 if (VIET_VOWEL_NONE != viet_vowel)
  2261.                                 {
  2262.                                     current_character = mmi_viet_combine_vowel_tone(viet_vowel, tone_mark);
  2263.                                 }
  2264.                                 else
  2265.                                 {
  2266.                                     object_type = gui_EMS_input_box_get_previous_object(
  2267.                                                     data,
  2268.                                                     &current_position,
  2269.                                                     &dummy_c,
  2270.                                                     &current_object);
  2271.                                 }
  2272.                             }
  2273.                             else
  2274.                             {
  2275.                                 object_type = gui_EMS_input_box_get_previous_object(
  2276.                                                 data,
  2277.                                                 &current_position,
  2278.                                                 &dummy_c,
  2279.                                                 &current_object);
  2280.                             }
  2281.                         }
  2282.                         else
  2283.                         {
  2284.                             object_type = gui_EMS_input_box_get_previous_object(
  2285.                                             data,
  2286.                                             &current_position,
  2287.                                             &dummy_c,
  2288.                                             &current_object);
  2289.                         }
  2290.                     }
  2291.                 #endif /* defined(__MMI_LANG_VIETNAMESE__) */ 
  2292.                 #if defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__)
  2293.                     if (IS_ARABIC_CHARACTER(current_character))
  2294.                     {
  2295.                         U32 idx = gui_get_ems_text_actual_idx(b, current_position.OffsetToText) / 2 - 1;
  2296.                         U32 ligature_move = 0;
  2297.                         UI_character_type dummy_c_arabic = 0;
  2298.                         current_character = (UI_character_type) shaping_str[OrgToSha[idx]];
  2299.                         while (idx < unshaped_text_len)
  2300.                         {
  2301.                             if (OrgToSha[idx] == OrgToSha[idx + 1])
  2302.                             {
  2303.                                 ligature_move++;
  2304.                             }
  2305.                             else
  2306.                             {
  2307.                                 break;
  2308.                             }
  2309.                             idx++;
  2310.                         }
  2311.                         while (ligature_move > 0)
  2312.                         {
  2313.                             object_type = gui_EMS_input_box_get_next_object(data, &current_position, &dummy_c_arabic, &current_object); /* get next character */
  2314.                             ligature_move--;
  2315.                         }
  2316.                     }
  2317.                 #endif /* defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__) */ 
  2318.                 #ifdef __MMI_BIDI_ALG__
  2319.                     if (!(flags & UI_EMS_INPUT_BOX_DISABLE_DRAW) && arabic_char_flag)
  2320.                     {
  2321.                         gui_measure_character(current_character, &object_width, &object_height);
  2322.                         if (!RequireToMoveCursor(pre_character, current_character))
  2323.                         {
  2324.                             object_width = 0;
  2325.                         }
  2326.                         else
  2327.                         {
  2328.                             /* Arabic Connectivity issue */
  2329.                         #if defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__)
  2330.                             /* PMT START 17082006 */
  2331.                             if (!UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
  2332.                                 /* PMT END 17082006 */
  2333.                                 if (!IS_ARABIC_CHARACTER(current_character))
  2334.                         #endif /* __MMI_LANG_ARABIC__ */ 
  2335.                                     object_width++;
  2336.                         }
  2337.                         object_width_cache[line_object_count] = object_width;
  2338.                     }
  2339.                 #endif /* __MMI_BIDI_ALG__ */ 
  2340.                     object_width = object_width_cache[line_object_count];
  2341.                     object_height = object_height_cache[line_object_count];
  2342.                 #ifdef __MMI_HINDI_ALG__
  2343.                     if (UI_HINDI_CHARACTER_UCS2_RANGE(current_character))       /* space shud have been added in the Hindi range */
  2344.                     {
  2345.                         if (!(TestLastPosition(data, &previous_position)))
  2346.                         {
  2347.                             //For performance issues first argument= second srgument
  2348.                             //move_ems_cursor_disp_curr_p = hf_get_next_cluster_p(data->textBuffer,move_ems_cursor_disp_prev_p);
  2349.                             move_ems_cursor_disp_curr_p = hf_get_next_cluster_p(move_ems_cursor_disp_prev_p, move_ems_cursor_disp_prev_p);
  2350.                             display_ems_skip_moves = move_ems_cursor_disp_curr_p - move_ems_cursor_disp_prev_p;
  2351.                             display_ems_skip_moves = display_ems_skip_moves >> 1;
  2352.                             /* ems_cluster_width=ems_cursor_width=hf_size_of_current_cluster(data->textBuffer,move_ems_cursor_disp_curr_p,0); */
  2353.                         #if 0
  2354. /* under construction !*/
  2355.                         #else /* 0 */ 
  2356.                             ems_cluster_width = ems_cursor_width = hindi_cluster_cache[hindi_cache_counter];
  2357.                         #endif /* 0 */ 
  2358.                             move_ems_cursor_disp_prev_p = move_ems_cursor_disp_curr_p;
  2359.                             saved_ems_display_skip_moves = display_ems_skip_moves;
  2360.                             display_ems_skip_moves--;
  2361.                             for (kdx = 0; kdx < display_ems_skip_moves; kdx++)
  2362.                             {
  2363.                                 object_type = gui_EMS_input_box_get_next_object(
  2364.                                                 data,
  2365.                                                 &current_position,
  2366.                                                 &current_character,
  2367.                                                 &current_object);
  2368.                                 /* MTK Begin Hindi patch 0425 */
  2369.                                 if (display_ems_skip_moves >= 1 && object_type == 2 &&
  2370.                                     current_object->Type == EMS_TYPE_TEXT_FORMAT)
  2371.                                 {
  2372.                                     hindi_text_format = current_object;
  2373.                                     set_hindi_text_format_flag = MMI_TRUE;
  2374.                                     object_type = gui_EMS_input_box_get_next_object(
  2375.                                                     data,
  2376.                                                     &current_position,
  2377.                                                     &current_character,
  2378.                                                     &current_object);
  2379.                                 }
  2380.                                 /* MTK End Hindi patch 0425 */
  2381.                             }
  2382.                         }
  2383.                     }
  2384.                     else
  2385.                     {
  2386.                         move_ems_cursor_disp_prev_p += 2;
  2387.                         saved_ems_display_skip_moves = 1;
  2388.                     }
  2389.                 #endif /* __MMI_HINDI_ALG__ */ 
  2390.                     if (!disable_draw_flag)
  2391.                     {
  2392.                         EMS_SET_TEXT_COLOR(normal_text_color);
  2393.                         if (default_direction == BIDI_R)
  2394.                         {
  2395.                             /* START FARHAD PMT 20050211 */
  2396.                         #ifdef __MMI_HINDI_ALG__
  2397.                             if (UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
  2398.                             {
  2399.                                 tx -= ems_cluster_width;
  2400.                                 cursor_ax -= ems_cursor_width;
  2401.                             }
  2402.                             else
  2403.                         #endif /* __MMI_HINDI_ALG__ */ 
  2404.                             {
  2405.                                 tx -= object_width;
  2406.                                 cursor_ax -= object_width;
  2407.                             }
  2408.                             /* END FARHAD PMT 20050211 */
  2409.                         }
  2410.                         /* MTK end */
  2411.                         if (word_highlight ||
  2412.                             (overwrite_mode_flag &&
  2413.                              !cursor_displayed_flag &&
  2414.                              (mapped_previous_position.OffsetToText == mapped_cursor_position.OffsetToText)) ||
  2415.                             (selection_flag &&
  2416.                              (mapped_current_position.OffsetToText == mapped_cursor_position.OffsetToText)))
  2417.                         {
  2418.                             S32 rx1, ry1, rx2, ry2;
  2419.                             rx1 = tx;
  2420.                             /* PMT START FIX HINDI ISSUES 20060604 */
  2421.                         #ifdef __MMI_HINDI_ALG__
  2422.                             if (UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
  2423.                             {
  2424.                                 S32 h, w;
  2425.                                 gui_measure_character(current_character, &w, &h);
  2426.                                 /* PMT BEGIN 29082006 */
  2427.                                 ry1 = ty;
  2428.                                 /* PMT END 29082006 */
  2429.                                 rx2 = rx1 + ems_cluster_width - 1;
  2430.                                 ry2 = ry1 + h - 1;
  2431.                                 PRINT_INFORMATION_2((MMI_TRACE_INFO,
  2432.                                                      "pixtel_UI_show_EMS_input_box[ems_cluster_width]:%d  ",
  2433.                                                      ems_cluster_width));
  2434.                             }
  2435.                             else
  2436.                         #endif /* __MMI_HINDI_ALG__ */ 
  2437.                             {
  2438.                                 ry1 = line_height - object_height + ty;
  2439.                                 rx2 = rx1 + object_width - 1;
  2440.                                 ry2 = ry1 + object_height - 1;
  2441.                             }
  2442.                             /* PMT END FIX HINDI ISSUES 20060604 */
  2443.                             EMS_SET_TEXT_COLOR(selected_text_color);
  2444.                         #ifdef __MMI_HINDI_ALG__
  2445.                             /* PMT START 17082006 */
  2446.                             if (MMI_current_input_mode == INPUT_MODE_SMART_HINDI)
  2447.                             {
  2448.                                 if (!UI_HINDI_CHARACTER_UCS2_RANGE(pre_character))
  2449.                                 {
  2450.                                     gui_fill_rectangle(rx1, ry1, rx2 + 2, ry2, b->selection_color);
  2451.                                 }
  2452.                                 else
  2453.                                 {
  2454.                                     gui_fill_rectangle(rx1 + 2, ry1, rx2 + 2, ry2, b->selection_color);
  2455.                                 }
  2456.                             }
  2457.                             else
  2458.                         #endif /* __MMI_HINDI_ALG__ */ 
  2459.                                 /* PMT END 17082006 */
  2460.                                 gui_fill_rectangle(rx1, ry1, rx2, ry2, b->selection_color);
  2461.                         }
  2462.                         /* PMT START FIX HINDI ISSUES 20060604 */
  2463.                     #ifdef __MMI_HINDI_ALG__
  2464.                         if (UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
  2465.                         {
  2466.                             /* PMT START 29082006 */
  2467.                             EMS_MOVE_TEXT_CURSOR(tx, ty);
  2468.                             /* PMT END 29082006 */
  2469.                         }
  2470.                         else
  2471.                     #endif /* __MMI_HINDI_ALG__ */ 
  2472.                             /* PMT END FIX HINDI ISSUES 20060604 */
  2473.                             EMS_MOVE_TEXT_CURSOR(tx, line_height - object_height + ty);
  2474.                     #if(EMS_DISPLAY_SPECIAL_CHARACTERS)
  2475.                         if (UI_TEST_CR_CHARACTER(current_character))
  2476.                         {
  2477.                             gui_show_transparent_image(
  2478.                                 tx,
  2479.                                 line_height - object_height + ty,
  2480.                                 (PU8) EMS_CR_display_character,
  2481.                                 0);
  2482.                         }
  2483.                         else if (UI_TEST_LF_CHARACTER(current_character))
  2484.                         {
  2485.                             gui_show_transparent_image(
  2486.                                 tx,
  2487.                                 line_height - object_height + ty,
  2488.                                 (PU8) EMS_LF_display_character,
  2489.                                 0);
  2490.                         }
  2491.                         else if (UI_TEST_ESC_CHARACTER(current_character))
  2492.                         {
  2493.                             gui_show_transparent_image(
  2494.                                 tx,
  2495.                                 line_height - object_height + ty,
  2496.                                 (PU8) EMS_ESC_display_character,
  2497.                                 0);
  2498.                         }
  2499.                         else
  2500.                     #endif /* (EMS_DISPLAY_SPECIAL_CHARACTERS) */ 
  2501.                         {
  2502.                             /* MTK Terry for Skip Special Character Issue */
  2503.                             if (!(
  2504.                         #if(EMS_USE_ESC_COMBINATION)
  2505.                                      UI_TEST_ESC_CHARACTER(current_character) ||
  2506.                         #endif 
  2507.                         #if(EMS_PREVENT_CRLF_DISPLAY)
  2508.                                      UI_TEST_LF_CHARACTER(current_character) || UI_TEST_CR_CHARACTER(current_character)
  2509.                                      ||
  2510.                         #endif /* (EMS_PREVENT_CRLF_DISPLAY) */ 
  2511.                                      UI_STRING_END_OF_STRING_CHARACTER(current_character)))
  2512.                             {
  2513.                                 /* gui_print_character(current_character); */
  2514.                             #ifdef __MMI_HINDI_ALG__
  2515.                                 PU8 prev_temp_ems_cursor_p;
  2516.                                 if (TestLastPosition(data, &previous_position))
  2517.                                 {
  2518.                                     goto end_ems_disp;
  2519.                                 }
  2520.                                 //Performance issues 
  2521.                                 //temp_ems_cursor_p = hf_get_next_cluster_p(data->textBuffer,temp_ems_cursor_p);
  2522.                                 prev_temp_ems_cursor_p = temp_ems_cursor_p;
  2523.                                 temp_ems_cursor_p = hf_get_next_cluster_p(temp_ems_cursor_p, temp_ems_cursor_p);
  2524.                                 /* if(hf_get_current_cluster(data->textBuffer,temp_ems_cursor_p,disp_ems_cluster)) */
  2525.                                 if (hf_get_current_cluster(prev_temp_ems_cursor_p, temp_ems_cursor_p, disp_ems_cluster))
  2526.                                 {
  2527.                                     S32 disp_len = pfnUnicodeStrlen((PS8) disp_ems_cluster);
  2528.                                     MMI_ASSERT(!(disp_len > MAX_EMS_DISP_CLUSTER_LEN));
  2529.                                     /* To avoid rule appln in showstring */
  2530.                                     hf_disable_hindi_rules_parsing();
  2531.                                     hf_padding_value(0);
  2532.                                     /* START TARUN PMT 20050128 */
  2533.                                     if (!UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
  2534.                                     {
  2535.                                         if (no_show_char != 1)
  2536.                                         {
  2537.                                             cancelWidth = 1;
  2538.                                             /* PMT MAUI_00015716 START FIX */
  2539.                                             if (underline_flag)
  2540.                                             {
  2541.                                                 UI_font->underline = 0;
  2542.                                             }
  2543.                                             /* PMT MAUI_00015716 END FIX */
  2544.                                             ShowString(
  2545.                                                 UI_text_x,
  2546.                                                 UI_text_y,
  2547.                                                 *UI_font,
  2548.                                                 0,
  2549.                                                 (U8*) (disp_ems_cluster),
  2550.                                             /* PMT MAUI_00015716 START FIX */ 
  2551.                                                  object_height);
  2552.                                             if (underline_flag)
  2553.                                             {
  2554.                                                 UI_font->underline = 1;
  2555.                                             }
  2556.                                             /* PMT MAUI_00015716 END FIX */
  2557.                                             cancelWidth = 0;
  2558.                                         }
  2559.                                     }
  2560.                                     else
  2561.                                     {
  2562.                                         if (no_show_char != 1)
  2563.                                         {
  2564.                                             cancelWidth = 1;
  2565.                                             /* PMT MAUI_00015716 START FIX */
  2566.                                             if (underline_flag)
  2567.                                             {
  2568.                                                 UI_font->underline = 0;
  2569.                                             }
  2570.                                             /* PMT MAUI_00015716 END FIX */
  2571.                                             ShowString(
  2572.                                                 UI_text_x,
  2573.                                                 UI_text_y,
  2574.                                                 *UI_font,
  2575.                                                 0,
  2576.                                                 (U8*) (disp_ems_cluster),
  2577.                                                 UI_text_height);
  2578.                                             /* PMT MAUI_00015716 START FIX */
  2579.                                             if (underline_flag)
  2580.                                             {
  2581.                                                 UI_font->underline = 1;
  2582.                                             }
  2583.                                             /* PMT MAUI_00015716 END FIX */
  2584.                                             cancelWidth = 0;
  2585.                                         }
  2586.                                     }
  2587.                                     //END TARUN PMT 20050128          
  2588.                                     //Open it again
  2589.                                     hf_enable_hindi_rules_parsing();
  2590.                                     hf_padding_def_value();
  2591.                                 }
  2592.                                 else
  2593.                             #endif /* __MMI_HINDI_ALG__ */ 
  2594.                                 {
  2595.                                     if (no_show_char != 1)
  2596.                                     {
  2597.                                         gui_print_stacked_character(current_character, pre2_character, pre_character);
  2598.                                     }
  2599.                                 }
  2600.                             #if(EMS_ENABLE_SPECIAL_FONT_DISPLAY)
  2601.                                 if (underline_flag)
  2602.                                 {
  2603.                                     /* PMT MAUI_00015716 START FIX */
  2604.                                 #ifdef __MMI_HINDI_ALG__
  2605.                                     if (UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
  2606.                                     {
  2607.                                         S32 h, w;
  2608.                                         gui_measure_character(current_character, &w, &h);
  2609.                                         UI_draw_horizontal_line(
  2610.                                             tx,
  2611.                                             tx + ems_cluster_width - 1,
  2612.                                             ty + h,
  2613.                                             underline_color);
  2614.                                     }
  2615.                                     else
  2616.                                 #endif /* __MMI_HINDI_ALG__ */ 
  2617.                                         /* PMT MAUI_00015716 END FIX */
  2618.                                         UI_draw_horizontal_line(
  2619.                                             tx,
  2620.                                             tx + object_width - 1,
  2621.                                             ty + line_height - 1,
  2622.                                             underline_color);
  2623.                                 }
  2624.                                 if (strikethrough_flag)
  2625.                                 {
  2626.                                 #ifdef __MMI_HINDI_ALG__
  2627.                                     if (UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
  2628.                                     {
  2629.                                         /* PMT MAUI_00015716 START FIX */
  2630.                                         S32 h, w;
  2631.                                         gui_measure_character(current_character, &w, &h);
  2632.                                         /* PMT MAUI_00015716 END FIX */
  2633.                                         UI_draw_horizontal_line(
  2634.                                             tx,
  2635.                                             tx + ems_cluster_width - 1,
  2636.                                             /* PMT MAUI_00015716 START FIX */ 
  2637.                                             ty + (h >> 1),
  2638.                                             /* PMT MAUI_00015716 END FIX */ 
  2639.                                             strikethrough_color);
  2640.                                     }
  2641.                                     else
  2642.                                 #endif /* __MMI_HINDI_ALG__ */ 
  2643.                                     {
  2644.                                         UI_draw_horizontal_line(
  2645.                                             tx,
  2646.                                             tx + object_width - 1,