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

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  *
  37.  * Filename:
  38.  * ---------
  39.  * EditorPen.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   This file is intends for Pen Function in Editor
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * removed!
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * removed!
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * removed!
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * removed!
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * removed!
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * removed!
  86.  *
  87.  * removed!
  88.  * removed!
  89.  * removed!
  90.  *
  91.  * removed!
  92.  * removed!
  93.  * removed!
  94.  *
  95.  * removed!
  96.  * removed!
  97.  * removed!
  98.  *
  99.  * removed!
  100.  * removed!
  101.  * removed!
  102.  *
  103.  * removed!
  104.  * removed!
  105.  * removed!
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * removed!
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * removed!
  114.  *
  115.  * removed!
  116.  * removed!
  117.  * removed!
  118.  *
  119.  * removed!
  120.  * removed!
  121.  * removed!
  122.  *
  123.  * removed!
  124.  * removed!
  125.  * removed!
  126.  *
  127.  * removed!
  128.  * removed!
  129.  * removed!
  130.  *
  131.  * removed!
  132.  * removed!
  133.  * removed!
  134.  *
  135.  * removed!
  136.  * removed!
  137.  * removed!
  138.  *
  139.  * removed!
  140.  * removed!
  141.  * removed!
  142.  *
  143.  * removed!
  144.  * removed!
  145.  * removed!
  146.  *
  147.  * removed!
  148.  * removed!
  149.  * removed!
  150.  *
  151.  * removed!
  152.  * removed!
  153.  * removed!
  154.  *
  155.  * removed!
  156.  * removed!
  157.  * removed!
  158.  *
  159.  * removed!
  160.  * removed!
  161.  * removed!
  162.  *
  163.  * removed!
  164.  * removed!
  165.  * removed!
  166.  *
  167.  * removed!
  168.  * removed!
  169.  * removed!
  170.  *
  171.  * removed!
  172.  * removed!
  173.  * removed!
  174.  *
  175.  * removed!
  176.  * removed!
  177.  * removed!
  178.  *
  179.  * removed!
  180.  * removed!
  181.  * removed!
  182.  *
  183.  * removed!
  184.  * removed!
  185.  * removed!
  186.  *
  187.  * removed!
  188.  * removed!
  189.  * removed!
  190.  *
  191.  * removed!
  192.  * removed!
  193.  * removed!
  194.  *
  195.  * removed!
  196.  * removed!
  197.  * removed!
  198.  *
  199.  * removed!
  200.  * removed!
  201.  * removed!
  202.  *
  203.  * removed!
  204.  * removed!
  205.  * removed!
  206.  *
  207.  * removed!
  208.  * removed!
  209.  * removed!
  210.  *
  211.  * removed!
  212.  * removed!
  213.  * removed!
  214.  *
  215.  * removed!
  216.  * removed!
  217.  * removed!
  218.  *
  219.  * removed!
  220.  * removed!
  221.  * removed!
  222.  *
  223.  * removed!
  224.  * removed!
  225.  * removed!
  226.  *
  227.  * removed!
  228.  * removed!
  229.  * removed!
  230.  *
  231.  * removed!
  232.  * removed!
  233.  * removed!
  234.  *
  235.  * removed!
  236.  * removed!
  237.  * removed!
  238.  *
  239.  * removed!
  240.  * removed!
  241.  * removed!
  242.  *
  243.  * removed!
  244.  * removed!
  245.  * removed!
  246.  *
  247.  * removed!
  248.  * removed!
  249.  * removed!
  250.  *
  251.  * removed!
  252.  * removed!
  253.  * removed!
  254.  *
  255.  * removed!
  256.  * removed!
  257.  * removed!
  258.  *
  259.  * removed!
  260.  * removed!
  261.  * removed!
  262.  *
  263.  * removed!
  264.  * removed!
  265.  * removed!
  266.  *
  267.  * removed!
  268.  * removed!
  269.  * removed!
  270.  *
  271.  * removed!
  272.  * removed!
  273.  * removed!
  274.  *
  275.  * removed!
  276.  * removed!
  277.  * removed!
  278.  *
  279.  * removed!
  280.  * removed!
  281.  * removed!
  282.  *
  283.  * removed!
  284.  * removed!
  285.  * removed!
  286.  *
  287.  * removed!
  288.  * removed!
  289.  * removed!
  290.  *
  291.  * removed!
  292.  * removed!
  293.  * removed!
  294.  *
  295.  * removed!
  296.  * removed!
  297.  * removed!
  298.  *
  299.  * removed!
  300.  * removed!
  301.  * removed!
  302.  *
  303.  * removed!
  304.  * removed!
  305.  * removed!
  306.  *
  307.  * removed!
  308.  * removed!
  309.  * removed!
  310.  *
  311.  * removed!
  312.  * removed!
  313.  * removed!
  314.  *
  315.  * removed!
  316.  * removed!
  317.  * removed!
  318.  *
  319.  * removed!
  320.  * removed!
  321.  * removed!
  322.  *
  323.  * removed!
  324.  * removed!
  325.  * removed!
  326.  *
  327.  * removed!
  328.  * removed!
  329.  * removed!
  330.  *
  331.  * removed!
  332.  * removed!
  333.  * removed!
  334.  *
  335.  * removed!
  336.  * removed!
  337.  * removed!
  338.  *
  339.  * removed!
  340.  * removed!
  341.  * removed!
  342.  *
  343.  * removed!
  344.  * removed!
  345.  * removed!
  346.  *
  347.  * removed!
  348.  * removed!
  349.  * removed!
  350.  *
  351.  * removed!
  352.  * removed!
  353.  * removed!
  354.  *
  355.  * removed!
  356.  * removed!
  357.  * removed!
  358.  *
  359.  * removed!
  360.  * removed!
  361.  * removed!
  362.  *
  363.  * removed!
  364.  * removed!
  365.  * removed!
  366.  *
  367.  * removed!
  368.  * removed!
  369.  * removed!
  370.  *
  371.  * removed!
  372.  * removed!
  373.  * removed!
  374.  *
  375.  * removed!
  376.  * removed!
  377.  * removed!
  378.  *
  379.  * removed!
  380.  * removed!
  381.  * removed!
  382.  *
  383.  * removed!
  384.  * removed!
  385.  * removed!
  386.  *
  387.  * removed!
  388.  * removed!
  389.  * removed!
  390.  *
  391.  * removed!
  392.  * removed!
  393.  * removed!
  394.  *
  395.  * removed!
  396.  * removed!
  397.  * removed!
  398.  *
  399.  * removed!
  400.  * removed!
  401.  * removed!
  402.  *
  403.  * removed!
  404.  * removed!
  405.  * removed!
  406.  *
  407.  * removed!
  408.  * removed!
  409.  * removed!
  410.  *
  411.  * removed!
  412.  * removed!
  413.  * removed!
  414.  *
  415.  * removed!
  416.  * removed!
  417.  * removed!
  418.  *
  419.  * removed!
  420.  * removed!
  421.  * removed!
  422.  *
  423.  * removed!
  424.  * removed!
  425.  * removed!
  426.  *
  427.  * removed!
  428.  * removed!
  429.  * removed!
  430.  *
  431.  * removed!
  432.  * removed!
  433.  * removed!
  434.  *
  435.  * removed!
  436.  * removed!
  437.  * removed!
  438.  *
  439.  * removed!
  440.  * removed!
  441.  * removed!
  442.  *
  443.  * removed!
  444.  * removed!
  445.  * removed!
  446.  *
  447.  * removed!
  448.  * removed!
  449.  * removed!
  450.  *
  451.  * removed!
  452.  * removed!
  453.  * removed!
  454.  *
  455.  * removed!
  456.  * removed!
  457.  * removed!
  458.  *
  459.  * removed!
  460.  * removed!
  461.  * removed!
  462.  *
  463.  *
  464.  * removed!
  465.  * removed!
  466.  * removed!
  467.  *
  468.  * removed!
  469.  * removed!
  470.  * removed!
  471.  *
  472.  * removed!
  473.  * removed!
  474.  * removed!
  475.  *
  476.  * removed!
  477.  * removed!
  478.  * removed!
  479.  *
  480.  * removed!
  481.  * removed!
  482.  * removed!
  483.  *
  484.  * removed!
  485.  * removed!
  486.  * removed!
  487.  *
  488.  * removed!
  489.  * removed!
  490.  * removed!
  491.  *
  492.  * removed!
  493.  * removed!
  494.  * removed!
  495.  *
  496.  * removed!
  497.  * removed!
  498.  * removed!
  499.  *
  500.  * removed!
  501.  * removed!
  502.  * removed!
  503.  *
  504.  * removed!
  505.  * removed!
  506.  * removed!
  507.  *
  508.  * removed!
  509.  * removed!
  510.  * removed!
  511.  *
  512.  * removed!
  513.  * removed!
  514.  * removed!
  515.  *
  516.  * removed!
  517.  * removed!
  518.  * removed!
  519.  *
  520.  * removed!
  521.  * removed!
  522.  * removed!
  523.  *
  524.  *------------------------------------------------------------------------------
  525.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  526.  *============================================================================
  527.  ****************************************************************************/
  528. /*  Include: MMI header file */
  529. #include "MMI_features.h"
  530. #if defined(__MMI_TOUCH_SCREEN__) || defined(__MMI_HANDWRITING_PAD__)
  531. #include "EditorPen.h"
  532. #include "wgui_categories_util.h"
  533. #include "gui_fixed_menus.h"
  534. #include "DebugInitDef.h"
  535. #include "gdi_include.h"
  536. #include "lcd_sw_rnd.h"
  537. #include "GlobalDefs.h"
  538. #include "wgui_softkeys.h"
  539. #include "PhoneSetupGprots.h"
  540. #include "ScrMemMgrGprot.h"
  541. #ifdef UI_SMALL_PIN_EDITOR_SCREEN
  542. #include "HistoryGprot.h"
  543. #endif
  544. /***************************************************************************** 
  545. * Define
  546. *****************************************************************************/
  547. // #defined __MMI_HAND_WRITING_GET_STROKES__
  548. #define WGUI_MAX_SOFTKEY_FUNCTIONS 3
  549. // #ifdef DEMO_PROJECT
  550. #define __MMI_HAND_WRITING_EXCLUDE_VK_AREA__
  551. // #endif
  552. #ifdef __MMI_MAINLCD_240X320__
  553.     #define PEN_EDITOR_BLOCK_HEIGHT 108
  554. #else
  555.     #define PEN_EDITOR_BLOCK_HEIGHT 80    
  556. #endif
  557. /***************************************************************************** 
  558. * Typedef 
  559. *****************************************************************************/
  560. /***************************************************************************** 
  561. * Local Variable
  562. *****************************************************************************/
  563. /* The candidate is in selection state or not */
  564. static BOOL gPenEditorSelectCandidate = MMI_FALSE;
  565. /* Enable Hand Writing or not (needed ?) */
  566. static BOOL gPenEditorEnableHandWriting = MMI_FALSE;
  567. /* The state of candidate above virtual keyboard */
  568. static BOOL gPenEditorVKCandidate = MMI_FALSE;
  569. /* The buffer to store points of stroke */
  570. static mmi_pen_point_struct gPenEditorStrokeBuffer[PEN_EDITOR_STROKE_BUFFER_SIZE];
  571. /* The point used to draw the stroke */
  572. static mmi_pen_point_struct gPenEditorPreviousPoint;
  573. /* The color of the stroke */
  574. static color gPenEditorStrokeColor = {0, 0, 0, 100};
  575. /* The single line input box for the candidates */
  576. static single_line_input_box gPenEditorCandidateInputBox;
  577. /* The text buffer for the candidates */
  578. static UI_character_type gPenEditorCandidateBuffer[PEN_EDITOR_MAX_CANDIDATE_SIZE];
  579. /* Which kind of input box */
  580. static mmi_pen_editor_input_box_type_enum gPenEditorInputBoxType = PEN_EDITOR_NONE_INPUT_BOX;
  581. /* To record the type of virtual keyboard for Symbol Keyboard switch (Need to revise) */
  582. static gui_virtual_keyboard_language_enum gPenEditorPreviousVirtualKeyboardType = GUI_VIRTUAL_KEYBOARD_MAX_LANG;
  583. /* The State of Virtual Keyboard */
  584. static mmi_pen_editor_virtual_keyboard_state_enum gPenEditorVKState = PEN_EDITOR_VK_NONE;
  585. /* Which kind of controls are in the category */
  586. static mmi_pen_editor_control_set_struct gPenEditorControlSet;
  587. /* The Active Control to process Pen Event (Activated by Pen Pown) */
  588. static mmi_pen_editor_control_type_enum gPenEditorActiveControl;
  589. /* To strore the content of the Virtual Keyboard Text in Display Area */
  590. static mmi_pen_editor_vk_text_struct gPenEditorVKText;
  591. /* Pointer to the GDI handler, used by Draw Manager */
  592. static gdi_handle *gPenEditorGDIHandler = NULL;
  593. //Layer Buffer for Stroke
  594. //static U32 gPenEditorStrokeGDIBuffer[(GDI_LCD_WIDTH *
  595. //              GDI_LCD_HEIGHT * (GDI_MAINLCD_BIT_PER_PIXEL>>3) + 3) / 4];
  596. static U8 *gPenEditorStrokeGDIBuffer = NULL;
  597. /* Used for Multitap (need to revise) */
  598. static multitap_input *gPenEditorMultitapInput;
  599. /* Used for Multitap (need to revise) */
  600. static BOOL gPenEditorMultitapInputState = MMI_FALSE;
  601. /* The First Stroke or not */
  602. static BOOL gPenEditorFirstStroke = MMI_TRUE;
  603. /* Display th evirtual Keyboard or not */
  604. static BOOL gPenEditorShowVK = MMI_TRUE;
  605. /* LSK function from Application */
  606. static void (*gPenEditorLSKfunction) (void);
  607. /* The Index NO. of the Selected Candidate */
  608. static S32 gPenEditorCandidateIndex = 0;
  609. /* The Page NO. of the candidates (In Chinese Input Method) */
  610. static S32 gPenEditorCandidatePage = 0;
  611. /* To Store the text of LSK */
  612. static UI_string_type gPenEditorLSKText;
  613. /* To Store Virtual Keyboard Lang. Type in History */
  614. static gui_virtual_keyboard_language_enum gPenEditorHistoryVirtualKeyboardType = GUI_VIRTUAL_KEYBOARD_MAX_LANG;
  615. /* The valid characters for INPUT_TYPE_PHONE_NUMBER */
  616. const UI_character_type gPenEditorPhoneNumberValidCharacters[] =
  617.     { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', 'p', 'w', '#', '*', '' };
  618. /* The valid characters for INPUT_TYPE_KEYPAD_NUMERIC */
  619. const UI_character_type gPenEditorKeyPadNumbericValidCharacters[] =
  620.     { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '#', '*', '' };
  621. /* The valid characters for INPUT_TYPE_EXT_SIM_NUMERIC */
  622. const UI_character_type gPenEditorPhoneNumberSIMValidCharacters[] =
  623.     { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '#', '*', '' };
  624. /* The valid characters for INPUT_TYPE_DECIMAL_NUMERIC */
  625. const UI_character_type gPenEditorDecimalNumericValidCharacters[] =
  626.     { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '' };
  627. /* The invalid characters array */
  628. const UI_character_type gPenEditorPhoneNumberInvalidCharacters[] = { '(', ')', '-', ' ', '' };
  629. const UI_character_type gPenEditorKeyPadNumbericInvalidCharacters[] = { '(', ')', 'p', 'w', '+', '-', ' ', '' };
  630. const UI_character_type gPenEditorPhoneNumberSIMInvalidCharacters[] = { '(', ')', 'p', 'w', '-', ' ', '' };
  631. const UI_character_type gPenEditorUCS2InvalidCharacters[] = {0x20ac, '' };
  632. const UI_character_type gPenEditorEmptyInvalidCharacters[] = { '' };
  633. const gui_virtual_keyboard_pen_enum gPenEditorVKDisableSpace[] = {GUI_VKBD_PEN_SPACE, GUI_VKBD_PEN_NONE};
  634. const gui_virtual_keyboard_pen_enum gPenEditorVKDisableNewLine[] = {GUI_VKBD_PEN_NEWLINE, GUI_VKBD_PEN_NONE};
  635. const gui_virtual_keyboard_pen_enum gPenEditorVKDisableNewLineCapsLock[] =
  636.     {GUI_VKBD_PEN_NEWLINE, GUI_VKBD_PEN_CAPSLOCK, GUI_VKBD_PEN_NONE};
  637. const gui_virtual_keyboard_pen_enum gPenEditorVKDisableEmpty[] = {GUI_VKBD_PEN_NONE};
  638. const gui_virtual_keyboard_pen_enum gPenEditorVKDisableHideSpace[] =
  639.     {GUI_VKBD_PEN_HIDE, GUI_VKBD_PEN_SPACE, GUI_VKBD_PEN_NONE};
  640. /* To store the height of list menu for in line editor */
  641. static S32 gPenEditorListMenuHeight = 0;
  642. /* The pen speed from PhnsetGetHandwritingSpeed */
  643. static PHNSET_HANDWRITING_SPEED_ENUM gPenEditorHWSpeed = PHNSET_HANDWRITING_MEDIUM;
  644. static multiline_inputbox_category_history gPenEditorInlineEditHistory;
  645. /* Stoke Area for execlude Virtual Keyboard Area */
  646. static mmi_pen_handwriting_area_struct g_pen_editor_original_handwriting_area;
  647. const S32 gPenEditorHWSpeedSet[3][2] = 
  648. {
  649.     {750, 2000},
  650.     {1000, 3000},
  651.     {1250, 4000}
  652. };
  653. /* The Filler for candidate input box */
  654. UI_filled_area candidate_inputbox_BG_filler = 
  655. {
  656.     UI_FILLED_AREA_TYPE_COLOR | UI_FILLED_AREA_ROUNDED_BORDER | UI_FILLED_AREA_SINGLE_BORDER,
  657.     UI_NULL_IMAGE,
  658.     NULL,
  659.     {192, 240, 248, 100},
  660.     {0, 0, 0, 0},
  661.     {64, 96, 176, 100},
  662.     {255, 0, 0, 100},
  663.     0
  664. };
  665. /* The theme for candidate input box */
  666. UI_single_line_input_box_theme candidate_singleline_inputbox_theme = 
  667. {
  668.     &candidate_inputbox_BG_filler,
  669.     &candidate_inputbox_BG_filler,
  670.     &candidate_inputbox_BG_filler,
  671.     {0, 0, 0, 100},
  672.     {128, 128, 128, 100},
  673.     {0, 0, 0, 100},
  674.     {255, 255, 255, 100},
  675.     {51, 88, 171, 100},
  676.     {255, 0, 0, 100},
  677.     &MMI_large_font,
  678.     1,
  679.     UI_SINGLE_LINE_INPUT_BOX_CENTER_Y,
  680.     '*'
  681. };
  682. /* W06.09 Touch Screen With Keypad V1 */
  683. multitap_input g_pen_editor_bpmf_pinyin_active_multitap[MAX_MULTITAPS];
  684. S32 g_pen_editor_active_multitap_index = -1;
  685. UI_character_type g_pen_editor_bpmf_pinyin_previous_valid_character = 0;
  686. #ifdef __MMI_EDITOR_PEN_VK_UNFOLD__
  687. /* flag for checking if current VK status is tray when re-entry setup function */
  688. BOOL gPenEditorHideToTray = MMI_FALSE;
  689. static MMI_BOOL gPenEditorOnlyRedrawInputBox = MMI_FALSE;
  690. #endif
  691. /* W06.11 Do not lock GDI buffer when process wgui_general_pen_up_hdlr */
  692. BOOL g_pen_editor_hold_confirm = MMI_FALSE;
  693. BOOL g_pen_editor_vk_show_at_start = MMI_FALSE;
  694. BOOL g_pen_editor_disable_handwriting = MMI_FALSE;
  695. BOOL g_pen_editor_disable_virtual_keyboard = MMI_FALSE;
  696. BOOL g_pen_editor_disable_keypad = MMI_FALSE;
  697. mmi_pen_editor_key_sequence_struct g_pen_editor_key_sequence;
  698. U32 g_pen_editor_smart_latin_pre_candidate_length = 0;
  699. S32 g_pen_editor_smart_latin_candidate_index = 0;
  700. static single_line_input_box g_pen_editor_composition_input_box;
  701. static UI_character_type g_pen_editor_composition_buffer[PEN_EDITOR_MAX_COMPOSITION_SIZE];
  702. static U32 g_pen_editor_composition_index = 0;
  703. static U32 g_pen_editor_composition_page = 0;
  704. static UI_character_type g_pen_editor_syllable_table[PEN_EDITOR_MAX_SYLLABLE_CANDIDATE_SIZE+1][PEN_EDITOR_MAX_PINYIN_SIZE
  705.                                                                                              + 1];
  706. static S32 g_pen_editor_candidate_x;
  707. static mmi_pen_editor_candidate_state_struct g_pen_editor_candidate_state;
  708. static mmi_pen_editor_candidate_state_struct g_pen_editor_composition_state;
  709. static mmi_pen_editor_vk_keys_set_struct g_pen_editor_vk_keys_set;
  710. static UI_character_type g_pen_editor_vk_characters_disable_list[PEN_EDITOR_VK_MAX_DISABLE_KEYS + 1];
  711. static gui_virtual_keyboard_pen_enum g_pen_editor_vk_event_keys_disable_list[PEN_EDITOR_VK_MAX_DISABLE_KEYS + 1];
  712. static mmi_pen_editor_handwriting_style_enum g_pen_editor_handwriting_style;
  713. static S32 g_pen_editor_active_block = 0;
  714. static mmi_pen_handwriting_area_struct g_multi_block_stroke_area[2];
  715. static MMI_BOOL g_pen_editor_resized_by_vk = MMI_FALSE;
  716. /***************************************************************************** 
  717. * Local Function
  718. *****************************************************************************/
  719. void mmi_pen_editor_enable_multi_block_handwriting(void);
  720. void mmi_pen_editor_disable_multi_block_handwriting(void);
  721. void mmi_pen_editor_handwriting_direct_input(void);
  722. void mmi_pen_editor_multi_block_stroke_down_handler(mmi_pen_point_struct pos);
  723. void mmi_pen_editor_multi_block_stroke_move_handler(mmi_pen_point_struct pos);
  724. void mmi_pen_editor_multi_block_stroke_up_handler(mmi_pen_point_struct pos);
  725. S32 mmi_pen_editor_handwriting_check_block(mmi_pen_point_struct pos);
  726. void mmi_pen_editor_draw_handwriting_block(void);
  727. /***************************************************************************** 
  728. * Global Variable
  729. *****************************************************************************/
  730. extern UI_EMS_input_box MMI_EMS_inputbox;
  731. extern multi_line_input_box MMI_multiline_inputbox;
  732. extern UI_theme *current_UI_theme;
  733. extern UI_multitap_input_theme *current_multitap_input_theme;
  734. extern IP4_input *current_IP4_input;
  735. extern date_input *current_date_input;
  736. extern single_line_input_box MMI_inline_singleline_inputbox;
  737. extern time_period_input *current_time_period_input;
  738. extern time_input *current_time_input;
  739. extern S32 UI_device_width;
  740. extern S32 wgui_EMS_inputbox_information_bar_x;
  741. extern S32 wgui_EMS_inputbox_information_bar_y;
  742. extern S32 wgui_EMS_inputbox_information_bar_width;
  743. extern S32 wgui_EMS_inputbox_information_bar_height;
  744. extern S16 MMI_current_input_type;
  745. extern fixed_list_menu MMI_fixed_list_menu;
  746. extern S32(*cat200_search_function) (U8 *);
  747. extern S32 wgui_inline_item_highlighted_index;
  748. extern S32 UI_cursor_x1;
  749. extern S32 UI_cursor_y1;
  750. extern void handle_category28_change_input_mode(void);
  751. extern void (*EMS_inputbox_input_callback) (void);
  752. extern void (*multiline_inputbox_input_callback) (void);
  753. extern void (*singleline_inputbox_input_callback) (void);
  754. extern void (*inline_singleline_inputbox_input_callback) (void);
  755. extern U8 wgui_inline_singleline_inputbox_decimal_input_mode_flag;
  756. extern U8 wgui_multiline_inputbox_decimal_input_mode_flag;
  757. extern U8 wgui_singleline_inputbox_decimal_input_mode_flag;
  758. extern U8 wgui_inline_item_handled;
  759. extern void (*complete_inline_item_edit) (void);
  760. extern U8 wgui_inputbox_RSK_label_clear;
  761. extern U8 category28_RSK_label_clear;
  762. extern U8 wgui_singleline_inputbox_RSK_label_clear;
  763. extern icontext_button MMI_softkeys[];
  764. extern void (*wgui_inline_edit_DONE_function) (void);
  765. extern void (*softkey_functions[WGUI_MAX_SOFTKEYS][WGUI_MAX_SOFTKEY_FUNCTIONS]) (void);
  766. extern S16 MMI_current_input_ext_type;
  767. extern U8 numeric_leading_zero;
  768. extern void register_inline_text_edit_handle_right_softkey_up(void);
  769. extern UI_string_type inline_text_edit_RSK_label_string;
  770. extern PU8 inline_text_edit_RSK_label_icon;
  771. extern U8 wgui_inline_list_menu_changed;
  772. extern U8 wgui_inline_list_menu_disable_done;
  773. extern void handle_inline_text_edit_right_softkey_long_press(void);
  774. extern void wgui_inline_text_edit_set_RSK_BACK_function(void);
  775. extern UI_string_type wgui_inline_edit_get_RSK_string(void);
  776. extern void handle_inline_text_edit_right_softkey_down(void);
  777. extern void (*redraw_current_inline_item) (void);
  778. extern void register_EMS_inputbox_keys(void);
  779. extern void wgui_set_EMS_inputbox_RSK(void);
  780. extern void wgui_set_RSK(void);
  781. extern void inline_edit_singleline_inputbox_multitap_input_complete(void);
  782. extern void EMS_inputbox_multitap_input_complete(void);
  783. extern void set_leading_zero(U8 u8type);
  784. extern void gui_multi_line_input_box_set_pen_scroll_delay(multi_line_input_box *b, S32 delay_time);
  785. extern void gui_EMS_input_box_set_pen_scroll_delay(UI_EMS_input_box *b, S32 delay_time);
  786. extern void EMS_inputbox_multitap_input(UI_character_type c);
  787. extern void redraw_EMS_inputbox(void);
  788. extern void show_inline_singleline_inputbox(void);
  789. extern void date_input_move_to_x_y(date_input *d, S32 x, S32 y);
  790. extern void IP4_input_move_to_x_y(IP4_input *ip4, S32 x, S32 y);
  791. extern void time_input_move_to_x_y(time_input *t, S32 x, S32 y);
  792. extern void time_period_input_move_to_x_y(time_period_input *tp, S32 x, S32 y);
  793. extern void wgui_multiline_inputbox_decimal_numeric_handle_pound_key_down(void);
  794. extern void EMS_inputbox_direct_input(UI_character_type c);
  795. extern void refresh_search_list(U8 *name);
  796. extern void wgui_singleline_inputbox_decimal_numeric_handle_pound_key_down(void);
  797. extern void inline_edit_singleline_inputbox_multitap_input(UI_character_type c);
  798. extern void wgui_inline_singleline_inputbox_decimal_numeric_handle_pound_key_down(void);
  799. extern void inline_edit_singleline_inputbox_direct_input(UI_character_type c);
  800. extern void date_input_direct_input_nodraw(UI_character_type c);
  801. extern S32 date_input_test_last_position(date_input *d);
  802. extern void IP4_input_direct_input_nodraw(UI_character_type c);
  803. extern S32 IP4_input_test_last_position(IP4_input *ip4);
  804. extern void time_input_direct_input_nodraw(UI_character_type c);
  805. extern S32 time_input_test_last_position(time_input *t);
  806. extern void time_period_input_direct_input_nodraw(UI_character_type c);
  807. extern S32 time_period_input_test_last_position(time_period_input *tp);
  808. extern void wgui_handle_inputbox_right_softkey_down(void);
  809. extern void EMS_inputbox_backspace(void);
  810. extern void wgui_handle_singleline_inputbox_right_softkey_down(void);
  811. extern void inline_edit_singleline_inputbox_delete_character(void);
  812. extern int gui_multi_line_input_box_get_remaining_length(multi_line_input_box *b);
  813. extern void EMS_inputbox_previous(void);
  814. extern int gui_single_line_input_box_get_remaining_length(single_line_input_box *b);
  815. extern void inline_edit_singleline_inputbox_previous_character(void);
  816. extern void redraw_inline_singleline_inputbox(void);
  817. extern void EMS_inputbox_insert_new_line(void);
  818. extern S32 mmi_ime_get_candidates_by_composition(UI_character_type *composition, UI_character_type *candidatebuffer);
  819. extern S32 mmi_ime_get_candidates_by_phrase(UI_character_type phrase, UI_character_type *candidatebuffer);
  820. extern S32 mmi_ime_get_candidates_by_page(S32 page, UI_character_type *candidatebuffer);
  821. extern S32 mmi_ime_smart_latin_get_candidates_by_key_sequence(
  822.             mmi_keypads_enum *key_sequence,
  823.             S32 key_sequence_length,
  824.             UI_character_type *candidatebuffer);
  825. extern S32 mmi_ime_smart_latin_get_candidates_by_index(S32 *index, UI_character_type *candidatebuffer);
  826. extern S32 mmi_ime_smart_bpmf_pinyin_get_syllable_by_key_sequence(
  827.             mmi_keypads_enum *key_sequence,
  828.             S32 key_sequence_length,
  829.             UI_character_type *syllable_buffer,
  830.             S32 start_index,
  831.             S32 end_index);
  832. extern S32 mmi_ime_chinese_stroke_get_candidates_by_key_sequence(
  833.             mmi_keypads_enum *key_sequence,
  834.             S32 key_sequence_length,
  835.             UI_character_type *candidatebuffer,
  836.             UI_character_type *strokebuffer);
  837. extern void wgui_set_singleline_RSK(void);
  838. extern void handle_category28_input(void);
  839. extern void wgui_handle_inputbox_input(void);
  840. extern void wgui_handle_qsearch_singleline_inputbox_change_input_mode(void);
  841. extern void cat200_virtual_keypad_callback(void);
  842. extern void RedrawCategoryControlledArea200Screen(dm_coordinates *coordinate);
  843. extern void wgui_redraw_input_information_bar(void);
  844. extern void change_EMS_inputbox_mode(U8 mode);
  845. extern void wgui_EMS_redraw_input_information_bar(void);
  846. extern void wgui_inline_edit_default_list_highlight_handler(S32 item_index);
  847. extern void wgui_handle_singleline_inputbox_change_input_mode(void);
  848. extern void wgui_handle_inline_singleline_inputbox_change_input_mode(void);
  849. extern MMI_BOOL get_multitap_state(void);
  850. extern void inline_edit_change_singleline_inputbox_mode(U8 mode);
  851. extern U8 *wgui_inline_edit_get_current_item_history(U8 *history_buffer);
  852. /* W06.09 Touch Screen With Keypad V1 */
  853. extern FuncPtr currKeyFuncPtrs[MAX_KEYS][MAX_KEY_TYPE];
  854. extern UI_character_type *get_bpmf_multitap_string(S32 i);
  855. extern const UI_character_type numberless_lowercase_multitap_strings[MAX_MULTITAPS][32];
  856. extern void handle_inline_text_edit_right_softkey_up(void);
  857. extern void cat201_register_key_func(void);
  858. extern void RedrawCategoryControlledArea201Screen(void);
  859. extern S32 handwriting_stroke_layer_mem;
  860. extern S32 gui_EMS_input_box_highlight_cursor_number(UI_EMS_input_box *b, S32 numOfChar);
  861. extern void gui_single_line_input_box_locate_cursor(single_line_input_box *b);
  862. extern void draw_resizeable_arrow(S32 x, S32 y, U8 arrow_type, color c, S32 width, S32 height);
  863. extern S32 UI_get_font_height(UI_font_type f);
  864. extern void wgui_EMS_set_text_format(EMSTextFormat text_format);
  865. extern S32 wgui_information_bar_input_mode_display_width;
  866. /***************************************************************************** 
  867. * Global Function
  868. *****************************************************************************/
  869. extern void mmi_pen_editor_hand_writing_initailize(void);
  870. extern S32 mmi_pen_editor_hand_writing_get_candidates(
  871.             U16 *stroke_buffer,
  872.             UI_character_type *candidate_array,
  873.             mmi_pen_editor_input_type_enum h_w_type,
  874.             S32 number);
  875. #if !defined(__MMI_T9__) && !defined(__MMI_ZI__) && !defined(__MMI_CSTAR__)     //KP Jerry add "__MMI_CSTAR__" on 2007-3-8
  876. /*****************************************************************************
  877.  * FUNCTION
  878.  *  mmi_ime_get_candidates_by_phrase
  879.  * DESCRIPTION
  880.  *      Get the Chinese candidates as phrase
  881.  * PARAMETERS
  882.  *  phrase              [IN]        The last character of the phrase
  883.  *  candidatebuffer     [OUT]         Buffer to ctore candidates
  884.  * RETURNS
  885.  *  Number of the Candidates
  886.  *****************************************************************************/
  887. S32 mmi_ime_get_candidates_by_phrase(UI_character_type phrase, UI_character_type *candidatebuffer)
  888. {
  889.     /*----------------------------------------------------------------*/
  890.     /* Local Variables                                                */
  891.     /*----------------------------------------------------------------*/
  892.     /*----------------------------------------------------------------*/
  893.     /* Code Body                                                      */
  894.     /*----------------------------------------------------------------*/
  895.     return 0;
  896. }
  897. /*****************************************************************************
  898.  * FUNCTION
  899.  *  mmi_ime_get_candidates_by_composition
  900.  * DESCRIPTION
  901.  *      Get the Chinese candidates from BPMF/PinYin composition
  902.  * PARAMETERS
  903.  *  composition         [IN]     The BPMF/PinYin composition
  904.  *  candidatebuffer     [OUT]     Buffer to store candidates
  905.  * RETURNS
  906.  *      Number of the Candidates
  907.  *****************************************************************************/
  908. S32 mmi_ime_get_candidates_by_composition(UI_character_type *composition, UI_character_type *candidatebuffer)
  909. {
  910.     /*----------------------------------------------------------------*/
  911.     /* Local Variables                                                */
  912.     /*----------------------------------------------------------------*/
  913.     /*----------------------------------------------------------------*/
  914.     /* Code Body                                                      */
  915.     /*----------------------------------------------------------------*/
  916.     return 0;
  917. }
  918. /*****************************************************************************
  919.  * FUNCTION
  920.  *  mmi_ime_get_candidates_by_page
  921.  * DESCRIPTION
  922.  *      Get the candidates according to the page index
  923.  * PARAMETERS
  924.  *  page                [IN]        The page index
  925.  *  candidatebuffer     [OUT]         Buffer to store candidates
  926.  * RETURNS
  927.  *  Number of the candidates
  928.  *****************************************************************************/
  929. S32 mmi_ime_get_candidates_by_page(S32 page, UI_character_type *candidatebuffer)
  930. {
  931.     /*----------------------------------------------------------------*/
  932.     /* Local Variables                                                */
  933.     /*----------------------------------------------------------------*/
  934.     /*----------------------------------------------------------------*/
  935.     /* Code Body                                                      */
  936.     /*----------------------------------------------------------------*/
  937.     return 0;
  938. }
  939. /*****************************************************************************
  940.  * FUNCTION
  941.  *  mmi_ime_smart_latin_get_candidates_by_key_sequence
  942.  * DESCRIPTION
  943.  *      Get the latin candidate by key sequence
  944.  * PARAMETERS
  945.  *  key_sequence            [IN]         The key sequence
  946.  *  key_sequence_length     [IN]        The length of the key sequence
  947.  *  candidatebuffer         [OUT]         Buffer to store candidates
  948.  * RETURNS
  949.  *  The length of the candidate
  950.  *****************************************************************************/
  951. S32 mmi_ime_smart_latin_get_candidates_by_key_sequence(
  952.         mmi_keypads_enum *key_sequence,
  953.         S32 key_sequence_length,
  954.         UI_character_type *candidatebuffer)
  955. {
  956.     /*----------------------------------------------------------------*/
  957.     /* Local Variables                                                */
  958.     /*----------------------------------------------------------------*/
  959.     /*----------------------------------------------------------------*/
  960.     /* Code Body                                                      */
  961.     /*----------------------------------------------------------------*/
  962.     return 0;
  963. }
  964. /*****************************************************************************
  965.  * FUNCTION
  966.  *  mmi_ime_smart_latin_get_candidates_by_index
  967.  * DESCRIPTION
  968.  *      Get the candidate according to the index
  969.  * PARAMETERS
  970.  *  index               [IN/OUT]     The index of the candidate
  971.  *  candidatebuffer     [OUT]     Buffer to store candidates
  972.  * RETURNS
  973.  *  The length of the candidate
  974.  *****************************************************************************/
  975. S32 mmi_ime_smart_latin_get_candidates_by_index(S32 *index, UI_character_type *candidatebuffer)
  976. {
  977.     /*----------------------------------------------------------------*/
  978.     /* Local Variables                                                */
  979.     /*----------------------------------------------------------------*/
  980.     /*----------------------------------------------------------------*/
  981.     /* Code Body                                                      */
  982.     /*----------------------------------------------------------------*/
  983.     return 0;
  984. }
  985. /*****************************************************************************
  986.  * FUNCTION
  987.  *  mmi_ime_chinese_stroke_get_candidates_by_key_sequence
  988.  * DESCRIPTION
  989.  *      Get the candidates and strokes from  the stroke key sequence
  990.  * PARAMETERS
  991.  *  key_sequence            [IN]         The stroke key sequence
  992.  *  key_sequence_length     [IN]        The length of the stroke key sequence
  993.  *  candidatebuffer         [OUT]         Buffer to store candidates
  994.  *  strokebuffer            [OUT]         Buffer to store stroke sequence
  995.  * RETURNS
  996.  *  Number of the candidates
  997.  *****************************************************************************/
  998. S32 mmi_ime_chinese_stroke_get_candidates_by_key_sequence(
  999.         mmi_keypads_enum *key_sequence,
  1000.         S32 key_sequence_length,
  1001.         UI_character_type *candidatebuffer,
  1002.         UI_character_type *strokebuffer)
  1003. {
  1004.     /*----------------------------------------------------------------*/
  1005.     /* Local Variables                                                */
  1006.     /*----------------------------------------------------------------*/
  1007.     /*----------------------------------------------------------------*/
  1008.     /* Code Body                                                      */
  1009.     /*----------------------------------------------------------------*/
  1010.     return 0;
  1011. }
  1012. /*****************************************************************************
  1013.  * FUNCTION
  1014.  *  mmi_ime_smart_bpmf_pinyin_get_syllable_by_key_sequence
  1015.  * DESCRIPTION
  1016.  *      Get the syllables from  the key sequence
  1017.  * PARAMETERS
  1018.  *  key_sequence            [IN]         The key sequence
  1019.  *  key_sequence_length     [IN]        The length of the key sequence
  1020.  *  syllable_buffer         [OUT]         Buffer to store syllables
  1021.  *  start_index             [IN]        The first index of the syllables
  1022.  *  end_index               [IN]        The last index of the syllables
  1023.  * RETURNS
  1024.  *  Number of the syllables
  1025.  *****************************************************************************/
  1026. S32 mmi_ime_smart_bpmf_pinyin_get_syllable_by_key_sequence(
  1027.         mmi_keypads_enum *key_sequence,
  1028.         S32 key_sequence_length,
  1029.         UI_character_type *syllable_buffer,
  1030.         S32 start_index,
  1031.         S32 end_index)
  1032. {
  1033.     /*----------------------------------------------------------------*/
  1034.     /* Local Variables                                                */
  1035.     /*----------------------------------------------------------------*/
  1036.     /*----------------------------------------------------------------*/
  1037.     /* Code Body                                                      */
  1038.     /*----------------------------------------------------------------*/
  1039.     return 0;
  1040. }
  1041. #endif /* !defined(__MMI_T9__) && !defined(__MMI_ZI__) */ 
  1042. #if !defined(__MMI_HANWANG__) && !defined(__MMI_PENPOWER__)
  1043. /*****************************************************************************
  1044.  * FUNCTION
  1045.  *  mmi_pen_editor_hand_writing_initailize
  1046.  * DESCRIPTION
  1047.  *  Initialize handwriting module
  1048.  * PARAMETERS
  1049.  *  void
  1050.  * RETURNS
  1051.  *  void
  1052.  *****************************************************************************/
  1053. void mmi_pen_editor_hand_writing_initailize(void)
  1054. {
  1055.     /*----------------------------------------------------------------*/
  1056.     /* Local Variables                                                */
  1057.     /*----------------------------------------------------------------*/
  1058.     /*----------------------------------------------------------------*/
  1059.     /* Code Body                                                      */
  1060.     /*----------------------------------------------------------------*/
  1061. }
  1062. /*****************************************************************************
  1063.  * FUNCTION
  1064.  *  mmi_pen_editor_hand_writing_get_candidates
  1065.  * DESCRIPTION
  1066.  *  Get the candidates from the handwriting strokes
  1067.  * PARAMETERS
  1068.  *  stroke_buffer       [IN]         Stokes data passed to handwriting module
  1069.  *  candidate_array     [OUT]         Buffer to store candidates
  1070.  *  h_w_type            [IN]        Which kind of candidates to return, Chinese, English, Symbol (need to revise)
  1071.  *  number              [IN]        The wished number of candidate
  1072.  * RETURNS
  1073.  *  The number of the candidates
  1074.  *****************************************************************************/
  1075. S32 mmi_pen_editor_hand_writing_get_candidates(
  1076.         U16 *stroke_buffer,
  1077.         UI_character_type *candidate_array,
  1078.         mmi_pen_editor_input_type_enum h_w_type,
  1079.         S32 number)
  1080. {
  1081.     /*----------------------------------------------------------------*/
  1082.     /* Local Variables                                                */
  1083.     /*----------------------------------------------------------------*/
  1084.     /*----------------------------------------------------------------*/
  1085.     /* Code Body                                                      */
  1086.     /*----------------------------------------------------------------*/
  1087.     return 0;
  1088. }
  1089. #endif /* !defined(__MMI_HANWANG__) && !defined(__MMI_PENPOWER__) */ 
  1090. /*****************************************************************************
  1091.  * FUNCTION
  1092.  *  mmi_pen_editor_compute_candidate_input_box_height
  1093.  * DESCRIPTION
  1094.  *  To compute the height of the candidate input box
  1095.  * PARAMETERS
  1096.  *  void
  1097.  * RETURNS
  1098.  *  The height of the candidate input box
  1099.  *****************************************************************************/
  1100. S32 mmi_pen_editor_compute_candidate_input_box_height(void)
  1101. {
  1102.     /*----------------------------------------------------------------*/
  1103.     /* Local Variables                                                */
  1104.     /*----------------------------------------------------------------*/
  1105.     int height;
  1106.     /*----------------------------------------------------------------*/
  1107.     /* Code Body                                                      */
  1108.     /*----------------------------------------------------------------*/
  1109.     height = UI_get_font_height(candidate_singleline_inputbox_theme.text_font) + 2;
  1110.     if (height < MMI_multitap_height)
  1111.     {
  1112.         height = MMI_multitap_height;
  1113.     }
  1114.     return height;
  1115. }
  1116. /*****************************************************************************
  1117.  * FUNCTION
  1118.  *  mmi_pen_editor_change_handwriting_area
  1119.  * DESCRIPTION
  1120.  *  Change the handwriting area according the virtual keyboard, composition box, and candidate box
  1121.  * PARAMETERS
  1122.  *  void
  1123.  * RETURNS
  1124.  *  void
  1125.  *****************************************************************************/
  1126. static void mmi_pen_editor_change_handwriting_area(void)
  1127. {
  1128. #ifdef __MMI_HAND_WRITING_EXCLUDE_VK_AREA__
  1129.     /*----------------------------------------------------------------*/
  1130.     /* Local Variables                                                */
  1131.     /*----------------------------------------------------------------*/
  1132.     /*----------------------------------------------------------------*/
  1133.     /* Code Body                                                      */
  1134.     /*----------------------------------------------------------------*/
  1135.     if (!(PEN_EDITOR_HANDWRITING_STYLE_MULTI_BLOCK == mmi_pen_editor_get_handwriting_style()))
  1136.     {
  1137.         if (gPenEditorEnableHandWriting)
  1138.         {
  1139.             mmi_pen_handwriting_area_struct ext_stroke;
  1140.             ext_stroke.x1 = 0;
  1141.             ext_stroke.y1 = 0;
  1142.             ext_stroke.x2 = UI_device_width - 1;
  1143.             ext_stroke.y2 = UI_device_height - 1;
  1144.             g_pen_editor_original_handwriting_area.y2 = MMI_virtual_keyboard.y;
  1145.             if (gPenEditorSelectCandidate || gPenEditorVKCandidate)
  1146.             {
  1147.                 g_pen_editor_original_handwriting_area.y2 = gPenEditorCandidateInputBox.y;
  1148.             }
  1149.             if (PEN_EDITOR_CANDIDATE_OFF != g_pen_editor_composition_state.candidate_state)
  1150.             {
  1151.                 g_pen_editor_original_handwriting_area.y2 = g_pen_editor_composition_input_box.y;
  1152.             }
  1153.             mmi_pen_change_handwriting_area(1, &g_pen_editor_original_handwriting_area, &ext_stroke);
  1154.         }
  1155.     }
  1156. #endif /* __MMI_HAND_WRITING_EXCLUDE_VK_AREA__ */ 
  1157. }
  1158. /*****************************************************************************
  1159.  * FUNCTION
  1160.  *  mmi_pen_editor_set_left_soft_key
  1161.  * DESCRIPTION
  1162.  *  Change Left Soft Key text according to previous
  1163.  * PARAMETERS
  1164.  *  void
  1165.  * RETURNS
  1166.  *  void
  1167.  *****************************************************************************/
  1168. static void mmi_pen_editor_set_left_soft_key(void)
  1169. {
  1170.     /*----------------------------------------------------------------*/
  1171.     /* Local Variables                                                */
  1172.     /*----------------------------------------------------------------*/
  1173.     /*----------------------------------------------------------------*/
  1174.     /* Code Body                                                      */
  1175.     /*----------------------------------------------------------------*/
  1176.     set_left_softkey_label(gPenEditorLSKText);
  1177.     set_left_softkey_icon(NULL);
  1178.     redraw_left_softkey();
  1179.     register_left_softkey_handler();
  1180. }
  1181. /*****************************************************************************
  1182.  * FUNCTION
  1183.  *  mmi_pen_editor_set_left_soft_key_select
  1184.  * DESCRIPTION
  1185.  *  Change Left Soft Key text to STR_GLOBAL_SELECT for selecting candidate purpose
  1186.  * PARAMETERS
  1187.  *  void
  1188.  * RETURNS
  1189.  *  void
  1190.  *****************************************************************************/
  1191. static void mmi_pen_editor_set_left_soft_key_select(void)
  1192. {
  1193.     /*----------------------------------------------------------------*/
  1194.     /* Local Variables                                                */
  1195.     /*----------------------------------------------------------------*/
  1196.     /*----------------------------------------------------------------*/
  1197.     /* Code Body                                                      */
  1198.     /*----------------------------------------------------------------*/
  1199.     set_left_softkey_label((UI_string_type) get_string(STR_GLOBAL_SELECT));
  1200.     set_left_softkey_icon(NULL);
  1201.     redraw_left_softkey();
  1202.     register_left_softkey_handler();
  1203. }
  1204. /*****************************************************************************
  1205.  * FUNCTION
  1206.  *  mmi_pen_editor_set_right_soft_key_inline_text
  1207.  * DESCRIPTION
  1208.  *  Set Right Soft Key for in-line text control according its status
  1209.  * PARAMETERS
  1210.  *  void
  1211.  * RETURNS
  1212.  *  void
  1213.  *****************************************************************************/
  1214. static void mmi_pen_editor_set_right_soft_key_inline_text(void)
  1215. {
  1216.     /*----------------------------------------------------------------*/
  1217.     /* Local Variables                                                */
  1218.     /*----------------------------------------------------------------*/
  1219.     /*----------------------------------------------------------------*/
  1220.     /* Code Body                                                      */
  1221.     /*----------------------------------------------------------------*/
  1222.     if (gui_single_line_input_box_get_text_length(&MMI_inline_singleline_inputbox) > 0)
  1223.     {
  1224.         set_right_softkey_label((UI_string_type) get_string(WGUI_CATEGORY_CLEAR_STRING_ID));
  1225.         set_right_softkey_icon(NULL);
  1226.         register_right_softkey_handler();
  1227.         redraw_right_softkey();
  1228.         set_right_softkey_function(UI_dummy_function, KEY_EVENT_UP);
  1229.         set_right_softkey_function(handle_inline_text_edit_right_softkey_down, KEY_EVENT_DOWN);
  1230.         set_right_softkey_function(handle_inline_text_edit_right_softkey_long_press, KEY_EVENT_LONG_PRESS);
  1231.     }
  1232.     else
  1233.     {
  1234.         if (wgui_inline_list_menu_changed)
  1235.         {
  1236.             wgui_inline_text_edit_set_RSK_BACK_function();
  1237.             /* W06.11 Set RSK as handle_inline_text_edit_right_softkey_up when buffer is empty */
  1238.             set_right_softkey_function(handle_inline_text_edit_right_softkey_up, KEY_EVENT_UP);
  1239.         }
  1240.         else
  1241.         {
  1242.             set_right_softkey_label(inline_text_edit_RSK_label_string);
  1243.             set_right_softkey_icon(inline_text_edit_RSK_label_icon);
  1244.             register_right_softkey_handler();
  1245.             redraw_right_softkey();
  1246.             set_right_softkey_function(register_inline_text_edit_handle_right_softkey_up, KEY_EVENT_UP);
  1247.             set_right_softkey_function(UI_dummy_function, KEY_EVENT_DOWN);
  1248.         }
  1249.     }
  1250. }
  1251. /*****************************************************************************
  1252.  * FUNCTION
  1253.  *  mmi_pen_editor_set_right_softkey
  1254.  * DESCRIPTION
  1255.  *  Set Right Soft Key according to the state
  1256.  * PARAMETERS
  1257.  *  rsk_type        [IN]        PEN_EDITOR_RSK_BY_STATE : The candidate box is on and set RSK to CLEAR if the candidate is in input control
  1258.  *                              PEN_EDITOR_RSK_BACK : Set RSK to STR_GLOBAL_BACK
  1259.  *                              PEN_EDITOR_RSK_CLEAR : Set RSK to STR_GLOBAL_CLEAR
  1260.  *  
  1261.  * RETURNS
  1262.  *  void
  1263.  *****************************************************************************/
  1264. static void mmi_pen_editor_set_right_softkey(mmi_pen_editor_rsk_type_enum rsk_type)
  1265. {
  1266.     /*----------------------------------------------------------------*/
  1267.     /* Local Variables                                                */
  1268.     /*----------------------------------------------------------------*/
  1269.     /*----------------------------------------------------------------*/
  1270.     /* Code Body                                                      */
  1271.     /*----------------------------------------------------------------*/
  1272.     switch (rsk_type)
  1273.     {
  1274.         case PEN_EDITOR_RSK_BY_STATE:
  1275.             if (get_multitap_state())
  1276.             {
  1277.                 set_right_softkey_label((UI_string_type) get_string(STR_GLOBAL_CLEAR));
  1278.             }
  1279.             else
  1280.             {
  1281.                 set_right_softkey_label((UI_string_type) get_string(STR_GLOBAL_BACK));
  1282.             }
  1283.             break;
  1284.         case PEN_EDITOR_RSK_BACK:
  1285.             set_right_softkey_label((UI_string_type) get_string(STR_GLOBAL_BACK));
  1286.             break;
  1287.         case PEN_EDITOR_RSK_CLEAR:
  1288.             set_right_softkey_label((UI_string_type) get_string(STR_GLOBAL_CLEAR));
  1289.             break;
  1290.         default:
  1291.             MMI_DBG_ASSERT(0);
  1292.     }
  1293.     set_right_softkey_icon(NULL);
  1294.     redraw_right_softkey();
  1295.     register_right_softkey_handler();
  1296.     /* W06.10 Fix Right Soft Key Issue */
  1297.     set_right_softkey_function(mmi_pen_editor_right_soft_key_handler, KEY_EVENT_UP);
  1298.     set_right_softkey_function(mmi_pen_editor_hold_confirm, KEY_EVENT_DOWN);
  1299.     set_right_softkey_function(UI_dummy_function, KEY_LONG_PRESS);
  1300. }
  1301. #if defined(__MMI_HAND_WRITING_GET_STROKES__)
  1302. /*****************************************************************************
  1303.  * FUNCTION
  1304.  *  mmi_pen_editor_save_stroke_to_file
  1305.  * DESCRIPTION
  1306.  *  Save the stroke data to the file
  1307.  * PARAMETERS
  1308.  *  void
  1309.  * RETURNS
  1310.  *  void
  1311.  *****************************************************************************/
  1312. static void mmi_pen_editor_save_stroke_to_file(void)
  1313. {
  1314. #if defined(MMI_ON_HARDWARE_P)
  1315.     /*----------------------------------------------------------------*/
  1316.     /* Local Variables                                                */
  1317.     /*----------------------------------------------------------------*/
  1318.     {
  1319.         FS_HANDLE stroke_out;
  1320.         U32 write_len;
  1321.         int i = 0;
  1322.         /*----------------------------------------------------------------*/
  1323.         /* Code Body                                                      */
  1324.         /*----------------------------------------------------------------*/
  1325.         stroke_out = FS_Open(L"Stroke_Out.str", FS_CREATE | FS_READ_WRITE);
  1326.         if (stroke_out <= 0)
  1327.         {
  1328.             MMI_ASSERT(0);
  1329.         }
  1330.         FS_Seek(stroke_out, 0, FS_FILE_END);
  1331.         for (i = 0; i < PEN_EDITOR_STROKE_BUFFER_SIZE; i++)
  1332.         {
  1333.             FS_Write(stroke_out, &(gPenEditorStrokeBuffer[i].x), sizeof(S16), (U32*) & write_len);
  1334.             FS_Write(stroke_out, &(gPenEditorStrokeBuffer[i].y), sizeof(S16), (U32*) & write_len);
  1335.         #if defined(__MMI_HANWANG__)
  1336.             if ((-1) == gPenEditorStrokeBuffer[i].x && (-1) == gPenEditorStrokeBuffer[i].y)
  1337.             {
  1338.                 break;
  1339.             }
  1340.         #elif defined(__MMI_PENPOWER__)
  1341.             if ((-1) == gPenEditorStrokeBuffer[i].x && (0) == gPenEditorStrokeBuffer[i].y)
  1342.             {
  1343.                 break;
  1344.             }
  1345.         #else 
  1346.             if ((-1) == gPenEditorStrokeBuffer[i].x && (-1) == gPenEditorStrokeBuffer[i].y)
  1347.             {
  1348.                 break;
  1349.             }
  1350.         #endif 
  1351.         }
  1352.         FS_Close(stroke_out);
  1353.     }
  1354. #else /* defined(MMI_ON_HARDWARE_P) */ 
  1355.     {
  1356.         FILE *stroke_out;
  1357.         int i = 0;
  1358.         if ((stroke_out = fopen("Stroke_Out.str", "a+")) == NULL)
  1359.         {
  1360.             fprintf(stderr, "Cannot open output file.n");
  1361.         }
  1362.         fseek(stroke_out, 0, SEEK_END);
  1363.         for (i = 0; i < PEN_EDITOR_STROKE_BUFFER_SIZE; i++)
  1364.         {
  1365.             fwrite(&(gPenEditorStrokeBuffer[i].x), sizeof(S16), 1, stroke_out);
  1366.             fwrite(&(gPenEditorStrokeBuffer[i].y), sizeof(S16), 1, stroke_out);
  1367.             if ((-1) == gPenEditorStrokeBuffer[i].x && (-1) == gPenEditorStrokeBuffer[i].y)
  1368.             {
  1369.                 break;
  1370.             }
  1371.         }
  1372.         fclose(stroke_out);
  1373.     }
  1374. #endif /* defined(MMI_ON_HARDWARE_P) */ 
  1375. }
  1376. #endif /* defined(__MMI_HAND_WRITING_GET_STROKES__) */ 
  1377. /*****************************************************************************
  1378.  * FUNCTION
  1379.  *  mmi_pen_editor_disable_input
  1380.  * DESCRIPTION
  1381.  *  To Disable the way to input characters at the beginning
  1382.  * PARAMETERS
  1383.  *  disable_input_flag      [IN]        PEN_EDITOR_DISABLE_HANDWRITNG : Disable Handwriting
  1384.  *                                      PEN_EDITOR_DISABLE_VIRTUAL_KEYBOARD : Disable Virtual Keyboard
  1385.  *                                      PEN_EDITOR_DISABLE_KEYPAD : Not Implemented
  1386.  * RETURNS
  1387.  *  void
  1388.  *****************************************************************************/
  1389. void mmi_pen_editor_disable_input(U32 disable_input_flag)
  1390. {
  1391.     /*----------------------------------------------------------------*/
  1392.     /* Local Variables                                                */
  1393.     /*----------------------------------------------------------------*/
  1394.     /*----------------------------------------------------------------*/
  1395.     /* Code Body                                                      */
  1396.     /*----------------------------------------------------------------*/
  1397.     if (disable_input_flag & PEN_EDITOR_DISABLE_HANDWRITNG)
  1398.     {
  1399.         g_pen_editor_disable_handwriting = MMI_TRUE;
  1400.     }
  1401.     if (disable_input_flag & PEN_EDITOR_DISABLE_VIRTUAL_KEYBOARD)
  1402.     {
  1403.         g_pen_editor_disable_virtual_keyboard = MMI_TRUE;
  1404.     }
  1405.     if (disable_input_flag & PEN_EDITOR_DISABLE_KEYPAD)
  1406.     {
  1407.         g_pen_editor_disable_keypad = MMI_TRUE;
  1408.     }
  1409. }
  1410. /*****************************************************************************
  1411.  * FUNCTION
  1412.  *  mmi_pen_editor_check_phrase
  1413.  * DESCRIPTION
  1414.  *  Check the character is able to be phrase-completed or not. If yes, do the related action
  1415.  * PARAMETERS
  1416.  *  ch      [IN]        The character to be checked
  1417.  * RETURNS
  1418.  *  void
  1419.  *****************************************************************************/
  1420. void mmi_pen_editor_check_phrase(UI_character_type ch)
  1421. {
  1422.     /*----------------------------------------------------------------*/
  1423.     /* Local Variables                                                */
  1424.     /*----------------------------------------------------------------*/
  1425.     /*----------------------------------------------------------------*/
  1426.     /* Code Body                                                      */
  1427.     /*----------------------------------------------------------------*/
  1428.     if (ch >= 0x4e00 && ch <= 0x9fff)
  1429.     {
  1430.         /* W05.35 Temp Solution for Candidate Index Issue */
  1431.         mmi_pen_editor_reset_candidate_index();
  1432.         if (g_pen_editor_composition_state.candidate_state != PEN_EDITOR_CANDIDATE_OFF)
  1433.         {
  1434.             int change_height = g_pen_editor_composition_input_box.height;
  1435.             g_pen_editor_composition_state.candidate_state = PEN_EDITOR_CANDIDATE_OFF;
  1436.             mmi_pen_editor_resize_content_area(change_height);
  1437.             mmi_pen_editor_reset_key_sequence(&g_pen_editor_key_sequence);
  1438.         }
  1439.         if (mmi_pen_editor_get_candidates_by_phrase(ch))
  1440.         {
  1441.             gPenEditorSelectCandidate = MMI_TRUE;
  1442.             /* Temp Solution for LSK Text Update */
  1443.             //W05.35 For LSK Text Issue
  1444.             //mmi_pen_editor_store_LSK_Text();
  1445.             mmi_pen_editor_set_left_soft_key_select();
  1446.             set_left_softkey_function(mmi_pen_editor_left_soft_key_handler, KEY_EVENT_UP);
  1447.             set_left_softkey_function(mmi_pen_editor_hold_confirm, KEY_EVENT_DOWN);
  1448.             mmi_pen_editor_register_arrow_keys();
  1449.             if (PEN_EDITOR_HANDWRITING_STYLE_MULTI_BLOCK == mmi_pen_editor_get_handwriting_style())
  1450.             {
  1451.                 if (GUI_VIRTUAL_KEYBOARD_TRAY == MMI_virtual_keyboard.lang_type)
  1452.                 {
  1453.                     gPenEditorVKState = PEN_EDITOR_VK_OFF;
  1454.                 }
  1455.             }
  1456.             else
  1457.             {
  1458.                 if (gPenEditorCandidateInputBox.y >= (PEN_EDITOR_Y_OF_CANDIDATE_INPUT_BOX_IN_BOTTOM))
  1459.                 {
  1460.                     gPenEditorVKState = PEN_EDITOR_VK_OFF;
  1461.                 }
  1462.             }
  1463.             mmi_pen_editor_set_right_softkey(PEN_EDITOR_RSK_BY_STATE);
  1464.         }
  1465.     }
  1466. }
  1467. /*****************************************************************************
  1468.  * FUNCTION
  1469.  *  mmi_pen_editor_hide_candidate_area
  1470.  * DESCRIPTION
  1471.  *  Clear the area of the candidate box
  1472.  * PARAMETERS
  1473.  *  void
  1474.  * RETURNS
  1475.  *  void
  1476.  *****************************************************************************/
  1477. void mmi_pen_editor_hide_candidate_area(void)
  1478. {
  1479.     /*----------------------------------------------------------------*/
  1480.     /* Local Variables                                                */
  1481.     /*----------------------------------------------------------------*/
  1482.     color c;
  1483.     /*----------------------------------------------------------------*/
  1484.     /* Code Body                                                      */
  1485.     /*----------------------------------------------------------------*/
  1486.     c.r = 255;
  1487.     c.g = 255;
  1488.     c.b = 255;
  1489.     c.alpha = 100;
  1490.     gui_reset_clip();
  1491.     gdi_layer_lock_frame_buffer();
  1492.     if (wgui_is_wallpaper_on_bottom() == MMI_TRUE)
  1493.     {
  1494.         gdi_draw_solid_rect(
  1495.             0,
  1496.             gPenEditorCandidateInputBox.y - 1,
  1497.             UI_device_width,
  1498.             gPenEditorCandidateInputBox.y + gPenEditorCandidateInputBox.height - 1,
  1499.             GDI_COLOR_TRANSPARENT);
  1500.     }
  1501.     else
  1502.     {
  1503.         gui_fill_rectangle(
  1504.             0,
  1505.             gPenEditorCandidateInputBox.y - 1,
  1506.             UI_device_width,
  1507.             gPenEditorCandidateInputBox.y + gPenEditorCandidateInputBox.height - 1,
  1508.             c);
  1509.     }
  1510.     gdi_layer_unlock_frame_buffer();
  1511.     gui_BLT_double_buffer(
  1512.         0,
  1513.         gPenEditorCandidateInputBox.y,
  1514.         UI_device_width - 1,
  1515.         gPenEditorCandidateInputBox.y + gPenEditorCandidateInputBox.height - 1);
  1516. }   /* end of mmi_pen_editor_hide_candidate_area */
  1517. /*****************************************************************************
  1518.  * FUNCTION
  1519.  *  mmi_pen_editor_draw_arrow
  1520.  * DESCRIPTION
  1521.  *  Darw the arrows for the composition box or the candidate box
  1522.  * PARAMETERS
  1523.  *  arrow_direction     [IN]        The direction of the arrow. Now we only support PEN_EDITOR_ARROW_DIRECTION_RIGHT and PEN_EDITOR_ARROW_DIRECTION_LEFT
  1524.  *  arrow_state         [IN]        The state of the arrow. PEN_EDITOR_ARROW_DISABLE, PEN_EDITOR_ARROW_PRESS_DOWN, and PEN_EDITOR_ARROW_PRESS_UP
  1525.  *  arrow_type          [IN]        The arrow is for the composition box and the candidate box. PEN_EDITOR_ARROW_FOR_CANDIDATE and PEN_EDITOR_ARROW_FOR_COMPOSITION
  1526.  * RETURNS
  1527.  *  void
  1528.  *****************************************************************************/
  1529. void mmi_pen_editor_draw_arrow(
  1530.         mmi_pen_editor_arrow_direction_enum arrow_direction,
  1531.         mmi_pen_editor_arrow_state_enum arrow_state,
  1532.         mmi_pen_editor_arrow_type_enum arrow_type)
  1533. {
  1534.     /*----------------------------------------------------------------*/
  1535.     /* Local Variables                                                */
  1536.     /*----------------------------------------------------------------*/
  1537.     color arrow_color;
  1538.     S32 x = 0, y = 0, width = 0, height = 0;
  1539.     S32 input_box_x = 0, input_box_width = 0, input_box_grid_width = 0;
  1540.     U8 direction = 0;
  1541.     /*----------------------------------------------------------------*/
  1542.     /* Code Body                                                      */
  1543.     /*----------------------------------------------------------------*/
  1544.     if (PEN_EDITOR_ARROW_FOR_CANDIDATE == arrow_type)
  1545.     {
  1546.         input_box_x = gPenEditorCandidateInputBox.x;
  1547.         input_box_width = gPenEditorCandidateInputBox.width;
  1548.         input_box_grid_width = gPenEditorCandidateInputBox.grid_width;
  1549.         y = gPenEditorCandidateInputBox.y + (gPenEditorCandidateInputBox.height >> 3) + 1;
  1550.         width = gPenEditorCandidateInputBox.grid_width >> 1;
  1551.         height = ((gPenEditorCandidateInputBox.height << 1) + gPenEditorCandidateInputBox.height) >> 2;
  1552.     }
  1553.     else if (PEN_EDITOR_ARROW_FOR_COMPOSITION == arrow_type)
  1554.     {
  1555.         input_box_x = g_pen_editor_composition_input_box.x;
  1556.         input_box_width = g_pen_editor_composition_input_box.width;
  1557.         input_box_grid_width = g_pen_editor_composition_input_box.grid_width;
  1558.         y = g_pen_editor_composition_input_box.y + (g_pen_editor_composition_input_box.height >> 3) + 1;
  1559.         width = g_pen_editor_composition_input_box.grid_width >> 1;
  1560.         height = ((g_pen_editor_composition_input_box.height << 1) + g_pen_editor_composition_input_box.height) >> 2;
  1561.     }
  1562.     if (PEN_EDITOR_ARROW_DISABLE == arrow_state)
  1563.     {
  1564.         arrow_color = gui_color(200, 200, 200);
  1565.     }
  1566.     else
  1567.     {
  1568.         arrow_color = gui_color(0, 102, 204);
  1569.     }
  1570.     if (PEN_EDITOR_ARROW_DIRECTION_RIGHT == arrow_direction)
  1571.     {
  1572.         x = input_box_x + input_box_width + (input_box_grid_width >> 2);
  1573.         direction = 1;
  1574.         if (PEN_EDITOR_ARROW_DISABLE == arrow_state || PEN_EDITOR_ARROW_PRESS_UP == arrow_state)
  1575.         {
  1576.         }
  1577.         else if (PEN_EDITOR_ARROW_PRESS_DOWN == arrow_state)
  1578.         {
  1579.             x++;
  1580.             y++;
  1581.         }
  1582.     }
  1583.     else if (PEN_EDITOR_ARROW_DIRECTION_LEFT == arrow_direction)
  1584.     {
  1585.         x = input_box_x - (((input_box_grid_width << 1) + input_box_grid_width) >> 2) - 2;
  1586.         direction = 0;
  1587.         if (PEN_EDITOR_ARROW_DISABLE == arrow_state || PEN_EDITOR_ARROW_PRESS_UP == arrow_state)
  1588.         {
  1589.         }
  1590.         else if (PEN_EDITOR_ARROW_PRESS_DOWN == arrow_state)
  1591.         {
  1592.             x--;
  1593.             y++;
  1594.         }
  1595.     }
  1596.     draw_resizeable_arrow(x, y, direction, arrow_color, width, height);
  1597. }
  1598. /*****************************************************************************
  1599.  * FUNCTION
  1600.  *  mmi_pen_editor_candidate_is_able_to_next_page
  1601.  * DESCRIPTION
  1602.  *  Is it able to jump to the next page in the candidate box
  1603.  * PARAMETERS
  1604.  *  void
  1605.  * RETURNS
  1606.  *  MMI_TRUE : yes
  1607.  *  MMI_FALSE : no
  1608.  *****************************************************************************/
  1609. MMI_BOOL mmi_pen_editor_candidate_is_able_to_next_page(void)
  1610. {
  1611.     /*----------------------------------------------------------------*/
  1612.     /* Local Variables                                                */
  1613.     /*----------------------------------------------------------------*/
  1614.     UI_character_type candidate_buffer[PEN_EDITOR_MAX_CANDIDATE_SIZE];
  1615.     int num = 0;
  1616.     /*----------------------------------------------------------------*/
  1617.     /* Code Body                                                      */
  1618.     /*----------------------------------------------------------------*/
  1619.     /*----------------------------------------------------------------*/
  1620.     /* Code Body                                                      */
  1621.     /*----------------------------------------------------------------*/
  1622.     gPenEditorCandidatePage++;
  1623.     num = mmi_ime_get_candidates_by_page(gPenEditorCandidatePage, candidate_buffer);
  1624.     if (!num)
  1625.     {
  1626.         gPenEditorCandidatePage--;
  1627.         return MMI_FALSE;
  1628.     }
  1629.     else
  1630.     {
  1631.         gPenEditorCandidatePage--;
  1632.         return MMI_TRUE;
  1633.     }
  1634. }   /* end of mmi_pen_editor_candidate_is_able_to_next_page */
  1635. /*****************************************************************************
  1636.  * FUNCTION
  1637.  *  mmi_pen_editor_candidate_is_able_to_prev_page
  1638.  * DESCRIPTION
  1639.  *  Is it able to jump to the previous page in the candidate box
  1640.  * PARAMETERS
  1641.  *  void
  1642.  * RETURNS
  1643.  *  MMI_TRUE : yes
  1644.  *  MMI_FALSE : no
  1645.  *****************************************************************************/
  1646. MMI_BOOL mmi_pen_editor_candidate_is_able_to_prev_page(void)
  1647. {
  1648.     /*----------------------------------------------------------------*/
  1649.     /* Local Variables                                                */
  1650.     /*----------------------------------------------------------------*/
  1651.     /*----------------------------------------------------------------*/
  1652.     /* Code Body                                                      */
  1653.     /*----------------------------------------------------------------*/
  1654.     if (gPenEditorCandidatePage)
  1655.     {
  1656.         return MMI_TRUE;
  1657.     }
  1658.     return MMI_FALSE;
  1659. }   /* end of mmi_pen_editor_candidate_is_able_to_prev_page */
  1660. /*****************************************************************************
  1661.  * FUNCTION
  1662.  *  mmi_pen_editor_composition_is_able_to_next
  1663.  * DESCRIPTION
  1664.  *  Is it able to jump to the next syllable in the composition box
  1665.  * PARAMETERS
  1666.  *  void
  1667.  * RETURNS
  1668.  *  MMI_TRUE : yes
  1669.  *  MMI_FALSE : no
  1670.  *****************************************************************************/
  1671. MMI_BOOL mmi_pen_editor_composition_is_able_to_next(void)
  1672. {
  1673.     /*----------------------------------------------------------------*/
  1674.     /* Local Variables                                                */
  1675.     /*----------------------------------------------------------------*/
  1676.     /*----------------------------------------------------------------*/
  1677.     /* Code Body                                                      */
  1678.     /*----------------------------------------------------------------*/
  1679.     if ((g_pen_editor_composition_index < PEN_EDITOR_MAX_SYLLABLE_CANDIDATE_SIZE - 1) &&
  1680.         g_pen_editor_syllable_table[g_pen_editor_composition_index + 1][0] != '')
  1681.     {
  1682.         return MMI_TRUE;
  1683.     }
  1684.     else if (g_pen_editor_composition_index == PEN_EDITOR_MAX_SYLLABLE_CANDIDATE_SIZE - 1)
  1685.     {
  1686.         S32 num = 0;
  1687.         g_pen_editor_composition_index = 0;
  1688.         g_pen_editor_composition_page++;
  1689.         num = mmi_pen_editor_smart_bpmf_pinyin_get_candidates_by_key_sequence(&g_pen_editor_key_sequence, MMI_FALSE);
  1690.         g_pen_editor_composition_index = PEN_EDITOR_MAX_SYLLABLE_CANDIDATE_SIZE - 1;
  1691.         g_pen_editor_composition_page--;
  1692.         mmi_pen_editor_smart_bpmf_pinyin_get_candidates_by_key_sequence(&g_pen_editor_key_sequence, MMI_FALSE);
  1693.         if (num)
  1694.         {
  1695.             return MMI_TRUE;
  1696.         }
  1697.         else
  1698.         {
  1699.             return MMI_FALSE;
  1700.         }
  1701.     }
  1702.     else
  1703.     {
  1704.         return MMI_FALSE;
  1705.     }
  1706. }   /* end of mmi_pen_editor_composition_is_able_to_next */
  1707. /*****************************************************************************
  1708.  * FUNCTION
  1709.  *  mmi_pen_editor_composition_is_able_to_prev
  1710.  * DESCRIPTION
  1711.  *  Is it able to jump to the previous syllable in the composition box
  1712.  * PARAMETERS
  1713.  *  void
  1714.  * RETURNS
  1715.  *  MMI_TRUE : yes
  1716.  *  MMI_FALSE : no
  1717.  *****************************************************************************/
  1718. MMI_BOOL mmi_pen_editor_composition_is_able_to_prev(void)
  1719. {
  1720.     /*----------------------------------------------------------------*/
  1721.     /* Local Variables                                                */
  1722.     /*----------------------------------------------------------------*/
  1723.     /*----------------------------------------------------------------*/
  1724.     /* Code Body                                                      */
  1725.     /*----------------------------------------------------------------*/
  1726.     if (g_pen_editor_composition_index || g_pen_editor_composition_page)
  1727.     {
  1728.         return MMI_TRUE;
  1729.     }
  1730.     else
  1731.     {
  1732.         return MMI_FALSE;
  1733.     }
  1734. }   /* end of mmi_pen_editor_composition_is_able_to_prev */
  1735. /*****************************************************************************
  1736.  * FUNCTION
  1737.  *  mmi_pen_editor_show_candidate_area
  1738.  * DESCRIPTION
  1739.  *  Draw the candidate box according to its state
  1740.  * PARAMETERS
  1741.  *  arrow_enable        [IN]        Draw the arrows or not. MMI_TRUE : yes MMI_FALSE : no
  1742.  *  candiate_state      [IN]        PEN_EDITOR_CANDIDATE_ON_AND_FOCUS : Focus on the candidate box
  1743.  *                                  PEN_EDITOR_CANDIDATE_ON_NOT_FOCUS : Not focus on the candidate box
  1744.  * RETURNS
  1745.  *  void
  1746.  *****************************************************************************/
  1747. void mmi_pen_editor_show_candidate_area(MMI_BOOL arrow_enable, mmi_pen_editor_candidate_state_enum candiate_state)
  1748. {
  1749.     /*----------------------------------------------------------------*/
  1750.     /* Local Variables                                                */
  1751.     /*----------------------------------------------------------------*/
  1752.     /*----------------------------------------------------------------*/
  1753.     /* Code Body                                                      */
  1754.     /*----------------------------------------------------------------*/
  1755.     mmi_pen_editor_hide_candidate_area();
  1756.     if (PEN_EDITOR_CANDIDATE_ON_AND_FOCUS == candiate_state)
  1757.     {
  1758.         gPenEditorCandidateInputBox.flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW;
  1759.     }
  1760.     else if (PEN_EDITOR_CANDIDATE_ON_NOT_FOCUS == candiate_state)
  1761.     {
  1762.         gPenEditorCandidateInputBox.flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW;
  1763.     }
  1764.     gPenEditorCandidateInputBox.flags |= UI_SINGLE_LINE_INPUT_BOX_STATE_MULTITAP;
  1765.     gPenEditorCandidateInputBox.flags |= UI_SINGLE_LINE_INPUT_BOX_FULL_HEIGHT_BLOCK_CURSOR;
  1766.     gPenEditorCandidateInputBox.flags |= UI_SINGLE_LINE_INPUT_BOX_CHARACTER_HIGHLIGHT;
  1767.     if (!arrow_enable)
  1768.     {
  1769.         gui_resize_single_line_input_box(
  1770.             &gPenEditorCandidateInputBox,
  1771.             gPenEditorCandidateInputBox.grid_width * PEN_EDITOR_CANDIDATE_SIZE,
  1772.             gPenEditorCandidateInputBox.height);
  1773.         gui_move_single_line_input_box(&gPenEditorCandidateInputBox, MMI_multitap_x, gPenEditorCandidateInputBox.y);
  1774.         g_pen_editor_candidate_state.arrow_enable = MMI_FALSE;
  1775.         g_pen_editor_candidate_state.left_arrow_state = PEN_EDITOR_ARROW_DISABLE;
  1776.         g_pen_editor_candidate_state.right_arrow_state = PEN_EDITOR_ARROW_DISABLE;
  1777.     }
  1778.     else
  1779.     {
  1780.         g_pen_editor_candidate_state.arrow_enable = MMI_TRUE;
  1781.         g_pen_editor_candidate_state.left_arrow_state = PEN_EDITOR_ARROW_DISABLE;
  1782.         g_pen_editor_candidate_state.right_arrow_state = PEN_EDITOR_ARROW_DISABLE;
  1783.         if (mmi_pen_editor_candidate_is_able_to_next_page() &&
  1784.             !(UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW & gPenEditorCandidateInputBox.flags))
  1785.         {
  1786.             g_pen_editor_candidate_state.right_arrow_state = PEN_EDITOR_ARROW_PRESS_UP;
  1787.         }
  1788.         if (mmi_pen_editor_candidate_is_able_to_prev_page() &&
  1789.             !(UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW & gPenEditorCandidateInputBox.flags))
  1790.         {
  1791.             g_pen_editor_candidate_state.left_arrow_state = PEN_EDITOR_ARROW_PRESS_UP;
  1792.         }
  1793.         gui_resize_single_line_input_box(
  1794.             &gPenEditorCandidateInputBox,
  1795.             gPenEditorCandidateInputBox.grid_width * PEN_EDITOR_CANDIDATE_SIZE_WITH_ARROWS,
  1796.             gPenEditorCandidateInputBox.height);
  1797.         gui_move_single_line_input_box(
  1798.             &gPenEditorCandidateInputBox,
  1799.             MMI_multitap_x + gPenEditorCandidateInputBox.grid_width,
  1800.             gPenEditorCandidateInputBox.y);
  1801.         mmi_pen_editor_draw_arrow(
  1802.             PEN_EDITOR_ARROW_DIRECTION_RIGHT,
  1803.             g_pen_editor_candidate_state.right_arrow_state,
  1804.             PEN_EDITOR_ARROW_FOR_CANDIDATE);
  1805.         mmi_pen_editor_draw_arrow(
  1806.             PEN_EDITOR_ARROW_DIRECTION_LEFT,
  1807.             g_pen_editor_candidate_state.left_arrow_state,
  1808.             PEN_EDITOR_ARROW_FOR_CANDIDATE);
  1809.     }
  1810.     gui_show_single_line_input_box(&gPenEditorCandidateInputBox);
  1811. }   /* end of mmi_pen_editor_show_candidate_area */
  1812. /*****************************************************************************
  1813.  * FUNCTION
  1814.  *  mmi_pen_editor_hide_composition_area
  1815.  * DESCRIPTION
  1816.  *  Clear the area of the composition box
  1817.  * PARAMETERS
  1818.  *  void
  1819.  * RETURNS
  1820.  *  void
  1821.  *****************************************************************************/
  1822. void mmi_pen_editor_hide_composition_area(void)
  1823. {
  1824.     /*----------------------------------------------------------------*/
  1825.     /* Local Variables                                                */
  1826.     /*----------------------------------------------------------------*/
  1827.     color c;
  1828.     /*----------------------------------------------------------------*/
  1829.     /* Code Body                                                      */
  1830.     /*----------------------------------------------------------------*/
  1831.     c.r = 255;
  1832.     c.g = 255;
  1833.     c.b = 255;
  1834.     c.alpha = 100;
  1835.     gui_reset_clip();
  1836.     gdi_layer_lock_frame_buffer();
  1837.     if (wgui_is_wallpaper_on_bottom() == MMI_TRUE)
  1838.     {
  1839.         gdi_draw_solid_rect(
  1840.             0,
  1841.             g_pen_editor_composition_input_box.y,
  1842.             UI_device_width,
  1843.             g_pen_editor_composition_input_box.y + g_pen_editor_composition_input_box.height - 1,
  1844.             GDI_COLOR_TRANSPARENT);
  1845.     }
  1846.     else
  1847.     {
  1848.         gui_fill_rectangle(
  1849.             0,
  1850.             g_pen_editor_composition_input_box.y,
  1851.             UI_device_width,
  1852.             g_pen_editor_composition_input_box.y + g_pen_editor_composition_input_box.height - 1,
  1853.             c);
  1854.     }
  1855.     gdi_layer_unlock_frame_buffer();
  1856.     gui_BLT_double_buffer(
  1857.         0,
  1858.         g_pen_editor_composition_input_box.y,
  1859.         UI_device_width - 1,
  1860.         g_pen_editor_composition_input_box.y + g_pen_editor_composition_input_box.height - 1);
  1861. }   /* end of mmi_pen_editor_hide_composition_area */
  1862. /*****************************************************************************
  1863.  * FUNCTION
  1864.  *  mmi_pen_editor_show_composition_area
  1865.  * DESCRIPTION
  1866.  *  Draw the composition box according to its state
  1867.  * PARAMETERS
  1868.  *  arrow_enable        [IN]        Draw the arrows or not. MMI_TRUE : yes MMI_FALSE : no
  1869.  *  candiate_state      [IN]        PEN_EDITOR_CANDIDATE_ON_AND_FOCUS : Focus on the composition box
  1870.  *                                  PEN_EDITOR_CANDIDATE_ON_NOT_FOCUS : Not focus on the composition box
  1871.  * RETURNS
  1872.  *  void
  1873.  *****************************************************************************/
  1874. void mmi_pen_editor_show_composition_area(MMI_BOOL arrow_enable, mmi_pen_editor_candidate_state_enum candiate_state)
  1875. {
  1876.     /*----------------------------------------------------------------*/
  1877.     /* Local Variables                                                */
  1878.     /*----------------------------------------------------------------*/
  1879.     /*----------------------------------------------------------------*/
  1880.     /* Code Body                                                      */
  1881.     /*----------------------------------------------------------------*/
  1882.     mmi_pen_editor_hide_composition_area();
  1883.     g_pen_editor_composition_input_box.flags |= UI_SINGLE_LINE_INPUT_BOX_STATE_MULTITAP;
  1884.     g_pen_editor_composition_input_box.flags |= UI_SINGLE_LINE_INPUT_BOX_FULL_HEIGHT_BLOCK_CURSOR;
  1885.     g_pen_editor_composition_input_box.flags |= UI_SINGLE_LINE_INPUT_BOX_CHARACTER_HIGHLIGHT;
  1886.     if (PEN_EDITOR_CANDIDATE_ON_AND_FOCUS == candiate_state)
  1887.     {
  1888.         g_pen_editor_composition_input_box.flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW;
  1889.         g_pen_editor_composition_input_box.flags |= UI_SINGLE_LINE_INPUT_BOX_WORD_HIGHLIGHT;
  1890.         g_pen_editor_composition_input_box.flags |= UI_SINGLE_LINE_INPUT_BOX_FULL_HEIGHT_BLOCK_CURSOR;
  1891.     }
  1892.     else if (PEN_EDITOR_CANDIDATE_ON_NOT_FOCUS == candiate_state)
  1893.     {
  1894.         g_pen_editor_composition_input_box.flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW;
  1895.         g_pen_editor_composition_input_box.flags &= ~UI_SINGLE_LINE_INPUT_BOX_STATE_MULTITAP;
  1896.         g_pen_editor_composition_input_box.flags &= ~UI_SINGLE_LINE_INPUT_BOX_FULL_HEIGHT_BLOCK_CURSOR;
  1897.         g_pen_editor_composition_input_box.flags &= ~UI_SINGLE_LINE_INPUT_BOX_CHARACTER_HIGHLIGHT;
  1898.         g_pen_editor_composition_input_box.flags &= ~UI_SINGLE_LINE_INPUT_BOX_WORD_HIGHLIGHT;
  1899.     }
  1900.     if (!arrow_enable)
  1901.     {
  1902.         gui_resize_single_line_input_box(
  1903.             &g_pen_editor_composition_input_box,
  1904.             g_pen_editor_composition_input_box.grid_width * PEN_EDITOR_CANDIDATE_SIZE,
  1905.             g_pen_editor_composition_input_box.height);
  1906.         gui_move_single_line_input_box(
  1907.             &g_pen_editor_composition_input_box,
  1908.             MMI_multitap_x,
  1909.             g_pen_editor_composition_input_box.y);
  1910.         g_pen_editor_composition_state.arrow_enable = MMI_FALSE;
  1911.         g_pen_editor_composition_state.left_arrow_state = PEN_EDITOR_ARROW_DISABLE;
  1912.         g_pen_editor_composition_state.right_arrow_state = PEN_EDITOR_ARROW_DISABLE;
  1913.     }
  1914.     else
  1915.     {
  1916.         g_pen_editor_composition_state.arrow_enable = MMI_TRUE;
  1917.         g_pen_editor_composition_state.left_arrow_state = PEN_EDITOR_ARROW_DISABLE;
  1918.         g_pen_editor_composition_state.right_arrow_state = PEN_EDITOR_ARROW_DISABLE;
  1919.         if (mmi_pen_editor_composition_is_able_to_next() && PEN_EDITOR_CANDIDATE_ON_AND_FOCUS == candiate_state)
  1920.         {
  1921.             g_pen_editor_composition_state.right_arrow_state = PEN_EDITOR_ARROW_PRESS_UP;
  1922.         }
  1923.         if (mmi_pen_editor_composition_is_able_to_prev() && PEN_EDITOR_CANDIDATE_ON_AND_FOCUS == candiate_state)
  1924.         {
  1925.             g_pen_editor_composition_state.left_arrow_state = PEN_EDITOR_ARROW_PRESS_UP;
  1926.         }
  1927.         gui_resize_single_line_input_box(
  1928.             &g_pen_editor_composition_input_box,
  1929.             g_pen_editor_composition_input_box.grid_width * PEN_EDITOR_CANDIDATE_SIZE_WITH_ARROWS,
  1930.             g_pen_editor_composition_input_box.height);
  1931.         gui_move_single_line_input_box(
  1932.             &g_pen_editor_composition_input_box,
  1933.             MMI_multitap_x + g_pen_editor_composition_input_box.grid_width,
  1934.             g_pen_editor_composition_input_box.y);
  1935.         mmi_pen_editor_draw_arrow(
  1936.             PEN_EDITOR_ARROW_DIRECTION_RIGHT,
  1937.             g_pen_editor_composition_state.right_arrow_state,
  1938.             PEN_EDITOR_ARROW_FOR_COMPOSITION);
  1939.         mmi_pen_editor_draw_arrow(
  1940.             PEN_EDITOR_ARROW_DIRECTION_LEFT,
  1941.             g_pen_editor_composition_state.left_arrow_state,
  1942.             PEN_EDITOR_ARROW_FOR_COMPOSITION);
  1943.     }
  1944.     gui_show_single_line_input_box(&g_pen_editor_composition_input_box);
  1945. }   /* end of mmi_pen_editor_show_composition_area */
  1946. /*****************************************************************************
  1947.  * FUNCTION
  1948.  *  mmi_pen_editor_vk_append_disable_keys
  1949.  * DESCRIPTION
  1950.  *  To append the default disabled keys in the virtual keyboard 
  1951.  * PARAMETERS
  1952.  *  vk_keys_set             [OUT]         The struct to record the disabled and enabled keys in the virtual keyboard
  1953.  *  disable_characters      [IN]          The disabled characters keys
  1954.  *  disable_event_keys      [IN]          The disabled event keys
  1955.  * RETURNS
  1956.  *  void
  1957.  *****************************************************************************/
  1958. void mmi_pen_editor_vk_append_disable_keys(
  1959.         mmi_pen_editor_vk_keys_set_struct *vk_keys_set,
  1960.         const UI_character_type *disable_characters,
  1961.         const gui_virtual_keyboard_pen_enum *disable_event_keys)
  1962. {
  1963.     /*----------------------------------------------------------------*/
  1964.     /* Local Variables                                                */
  1965.     /*----------------------------------------------------------------*/
  1966.     /*----------------------------------------------------------------*/
  1967.     /* Code Body                                                      */
  1968.     /*----------------------------------------------------------------*/
  1969.     if (disable_characters)
  1970.     {
  1971.         S32 i = 0;
  1972.         while (disable_characters[i])
  1973.         {
  1974.             S32 j = 0;
  1975.             while (vk_keys_set->characters_list[j])
  1976.             {
  1977.                 if (disable_characters[i] == vk_keys_set->characters_list[j])
  1978.                 {
  1979.                     break;
  1980.                 }
  1981.                 j++;
  1982.             }
  1983.             if (!vk_keys_set->characters_list[j])
  1984.             {
  1985.                 vk_keys_set->characters_list[j] = disable_characters[i];
  1986.                 vk_keys_set->characters_list[j + 1] = '';
  1987.             }
  1988.             i++;
  1989.         }
  1990.     }
  1991.     if (disable_event_keys)
  1992.     {
  1993.         S32 i = 0;
  1994.         while (disable_event_keys[i])
  1995.         {
  1996.             S32 j = 0;
  1997.             while (vk_keys_set->event_keys_list[j])
  1998.             {
  1999.                 if (disable_event_keys[i] == vk_keys_set->event_keys_list[j])
  2000.                 {
  2001.                     break;
  2002.                 }
  2003.                 j++;
  2004.             }
  2005.             if (!vk_keys_set->event_keys_list[j])
  2006.             {
  2007.                 vk_keys_set->event_keys_list[j] = disable_event_keys[i];
  2008.                 vk_keys_set->event_keys_list[j + 1] = '';
  2009.             }
  2010.             i++;
  2011.         }
  2012.     }
  2013. }
  2014. /*****************************************************************************
  2015.  * FUNCTION
  2016.  *  mmi_pen_editor_vk_disable_keys
  2017.  * DESCRIPTION
  2018.  *  Disable the keys on the virtual keyboard according to the input type and the situation
  2019.  * PARAMETERS
  2020.  *  void
  2021.  * RETURNS
  2022.  *  void
  2023.  *****************************************************************************/
  2024. void mmi_pen_editor_vk_disable_keys(void)
  2025. {
  2026.     /*----------------------------------------------------------------*/
  2027.     /* Local Variables                                                */
  2028.     /*----------------------------------------------------------------*/
  2029.     /* W06.11 Disable Hide Key in Phone Number Keyboard */
  2030.     const UI_character_type *DisableCharacters = gPenEditorEmptyInvalidCharacters;
  2031.     const gui_virtual_keyboard_pen_enum *DisableSymbols = gPenEditorVKDisableEmpty;
  2032.     /*----------------------------------------------------------------*/
  2033.     /* Code Body                                                      */
  2034.     /*----------------------------------------------------------------*/
  2035.     if ((gPenEditorInputBoxType == PEN_EDITOR_INLINE_TEXT) ||
  2036.         (gPenEditorInputBoxType == PEN_EDITOR_SINGLE_LINE_INPU_BOX) ||
  2037.         (MMI_current_input_ext_type & INPUT_TYPE_EXT_NO_SHOW_NEW_LINE_SYMBOL))
  2038.     {
  2039.         DisableSymbols = gPenEditorVKDisableNewLine;
  2040.     }
  2041.     /* W06.06 Disable Caps Lock in Quick Search */
  2042.     if ((gPenEditorInputBoxType == PEN_EDITOR_QUICK_SEARCH_SINGLE_LINE_INPU_BOX))
  2043.     {
  2044.         DisableSymbols = gPenEditorVKDisableNewLineCapsLock;
  2045.     }
  2046.     if (INPUT_TYPE_PHONE_NUMBER == (MMI_current_input_type & INPUT_TYPE_MASK))
  2047.     {
  2048.         if (MMI_current_input_ext_type & INPUT_TYPE_EXT_SIM_NUMERIC)
  2049.         {
  2050.             DisableCharacters = gPenEditorPhoneNumberSIMInvalidCharacters;
  2051.             DisableSymbols = gPenEditorVKDisableHideSpace;
  2052.         }
  2053.         else
  2054.         {
  2055.             DisableCharacters = gPenEditorPhoneNumberInvalidCharacters;
  2056.             DisableSymbols = gPenEditorVKDisableHideSpace;
  2057.         }
  2058.     }
  2059.     else if (INPUT_TYPE_KEYPAD_NUMERIC == (MMI_current_input_type & INPUT_TYPE_MASK)
  2060.              || INPUT_TYPE_SAT_NUMERIC_PASSWORD == (MMI_current_input_type & INPUT_TYPE_MASK))
  2061.     {
  2062.         DisableCharacters = gPenEditorKeyPadNumbericInvalidCharacters;
  2063.         DisableSymbols = gPenEditorVKDisableHideSpace;
  2064.     }
  2065.     else if (MMI_allow_only_english_input_modes)
  2066.     {
  2067.         DisableCharacters = gPenEditorUCS2InvalidCharacters;
  2068.     }
  2069.     if (g_pen_editor_disable_virtual_keyboard)
  2070.     {
  2071.         wgui_set_virtual_keyboard_allowed_characters(gPenEditorEmptyInvalidCharacters);
  2072.     }
  2073.     else if (g_pen_editor_vk_keys_set.is_changed)
  2074.     {
  2075.         if (g_pen_editor_vk_keys_set.is_allowed)
  2076.         {
  2077.             wgui_set_virtual_keyboard_allowed_characters((const UI_character_type*)g_pen_editor_vk_keys_set.
  2078.                                                          characters_list);
  2079.         }
  2080.         else
  2081.         {
  2082.             mmi_pen_editor_vk_append_disable_keys(&g_pen_editor_vk_keys_set, DisableCharacters, DisableSymbols);
  2083.             wgui_set_virtual_keyboard_disabled_list(
  2084.                 (const UI_character_type*)g_pen_editor_vk_keys_set.characters_list,
  2085.                 (const gui_virtual_keyboard_pen_enum*)g_pen_editor_vk_keys_set.event_keys_list);
  2086.         }
  2087.     }
  2088.     else
  2089.     {
  2090.         wgui_set_virtual_keyboard_disabled_list(DisableCharacters, DisableSymbols);
  2091.     }
  2092. }
  2093. /*****************************************************************************
  2094.  * FUNCTION
  2095.  *  mmi_pen_editor_set_vk_keys
  2096.  * DESCRIPTION
  2097.  *  To set the keys in the virtual keyboard
  2098.  * PARAMETERS
  2099.  *  is_allowed                  [IN]        MMI_TRUE : The enabled keys list MMI_FALSE : The Disabled keys list
  2100.  *  characters_lsit             [IN]        The character keys
  2101.  *  disable_event_keys_list     [IN]        The event keys
  2102.  * RETURNS
  2103.  *  void
  2104.  *****************************************************************************/
  2105. void mmi_pen_editor_set_vk_keys(
  2106.         MMI_BOOL is_allowed,
  2107.         const UI_character_type *characters_lsit,
  2108.         const gui_virtual_keyboard_pen_enum *disable_event_keys_list)
  2109. {
  2110.     /*----------------------------------------------------------------*/
  2111.     /* Local Variables                                                */
  2112.     /*----------------------------------------------------------------*/
  2113.     /*----------------------------------------------------------------*/
  2114.     /* Code Body                                                      */
  2115.     /*----------------------------------------------------------------*/
  2116.     g_pen_editor_vk_keys_set.is_allowed = is_allowed;
  2117.     g_pen_editor_vk_keys_set.is_changed = MMI_TRUE;
  2118.     if (is_allowed)
  2119.     {
  2120.         g_pen_editor_vk_keys_set.characters_list = (UI_character_type*) characters_lsit;
  2121.         g_pen_editor_vk_keys_set.event_keys_list = NULL;
  2122.     }
  2123.     else
  2124.     {
  2125.         U32 num = 0;
  2126.         if (characters_lsit)
  2127.         {
  2128.             num = 0;
  2129.             for (;; num++)
  2130.             {
  2131.                 if ('' == characters_lsit[num])
  2132.                 {
  2133.                     break;
  2134.                 }
  2135.                 g_pen_editor_vk_characters_disable_list[num] = characters_lsit[num];
  2136.             }
  2137.         }
  2138.         if (disable_event_keys_list)
  2139.         {
  2140.             num = 0;
  2141.             for (;; num++)
  2142.             {
  2143.                 if (GUI_VKBD_PEN_NONE == disable_event_keys_list[num])
  2144.                 {
  2145.                     break;
  2146.                 }
  2147.                 g_pen_editor_vk_event_keys_disable_list[num] = disable_event_keys_list[num];
  2148.             }
  2149.         }
  2150.         g_pen_editor_vk_keys_set.characters_list = g_pen_editor_vk_characters_disable_list;
  2151.         g_pen_editor_vk_keys_set.event_keys_list = g_pen_editor_vk_event_keys_disable_list;
  2152.     }
  2153. }
  2154. /*****************************************************************************
  2155.  * FUNCTION
  2156.  *  mmi_pen_editor_clear_and_show_virtual_keyboard_area
  2157.  * DESCRIPTION
  2158.  *  Clear the area of the virtual keyboard and draw it
  2159.  * PARAMETERS
  2160.  *  void
  2161.  * RETURNS
  2162.  *  void
  2163.  *****************************************************************************/
  2164. void mmi_pen_editor_clear_and_show_virtual_keyboard_area(void)
  2165. {
  2166.     /*----------------------------------------------------------------*/
  2167.     /* Local Variables                                                */
  2168.     /*----------------------------------------------------------------*/
  2169.     color c;
  2170.     int changed_height = 0;
  2171.     /*----------------------------------------------------------------*/
  2172.     /* Code Body                                                      */
  2173.     /*----------------------------------------------------------------*/
  2174.     c.r = 255;
  2175.     c.g = 255;
  2176.     c.b = 255;
  2177.     c.alpha = 100;
  2178.     /* W06.02 Disable invalid keys in Virtual Keyboard */
  2179.     mmi_pen_editor_vk_disable_keys();
  2180.     gui_reset_clip();
  2181.     gdi_layer_lock_frame_buffer();
  2182. //KP Jerry disable for avoid softkey area been overlaied by virtual keyboard on 2007-4-23 start
  2183. /*
  2184.     if (MMI_virtual_keyboard.height < gPenEditorCandidateInputBox.height)
  2185.     {
  2186.         changed_height = gPenEditorCandidateInputBox.height - MMI_virtual_keyboard.height;
  2187.     }
  2188. */    
  2189. //KP Jerry disable for avoid softkey area been overlaied by virtual keyboard on 2007-4-23 end
  2190.     if (wgui_is_wallpaper_on_bottom() == MMI_TRUE)
  2191.     {
  2192.         gdi_draw_solid_rect(
  2193.             0,
  2194.             MMI_virtual_keyboard.y - changed_height - 2,
  2195.             UI_device_width,
  2196.             MMI_virtual_keyboard.y + MMI_virtual_keyboard.height + changed_height - 1,
  2197.             GDI_COLOR_TRANSPARENT);
  2198.     }
  2199.     else
  2200.     {
  2201.         /* To Display Background in the area of the virtual keyboard when list menu */
  2202.         if (((PEN_EDITOR_INLINE_TEXT == gPenEditorInputBoxType) && (!(MMI_fixed_list_menu.flags & UI_LIST_MENU_DISABLE_BACKGROUND)))
  2203.             || PEN_EDITOR_INLINE_MULTILINE_INPUT_BOX == gPenEditorInputBoxType)
  2204.         {
  2205.             gui_show_list_menu_background_outside_area(&MMI_fixed_list_menu,
  2206.                 0,
  2207.                 MMI_virtual_keyboard.y - changed_height - 2,
  2208.                 UI_device_width,
  2209.                 MMI_virtual_keyboard.y + MMI_virtual_keyboard.height + changed_height - 1);
  2210.         }
  2211.         else
  2212.         {
  2213.             gui_fill_rectangle(
  2214.                 0,
  2215.                 MMI_virtual_keyboard.y - changed_height - 2,
  2216.                 UI_device_width,
  2217.                 MMI_virtual_keyboard.y + MMI_virtual_keyboard.height + changed_height - 1,
  2218.                 c);
  2219.         }
  2220.     }
  2221.     gui_show_virtual_keyboard(&MMI_virtual_keyboard);
  2222.     gdi_layer_unlock_frame_buffer();
  2223.     gdi_lcd_repaint_all();
  2224. }   /* end of mmi_pen_editor_hide_candidate_area */
  2225. /*****************************************************************************
  2226.  * FUNCTION
  2227.  *  mmi_pen_editor_hide_virtual_keyboard_area
  2228.  * DESCRIPTION
  2229.  *  Clear the area of the virtual keyboard
  2230.  * PARAMETERS
  2231.  *  void
  2232.  * RETURNS
  2233.  *  void
  2234.  *****************************************************************************/
  2235. void mmi_pen_editor_hide_virtual_keyboard_area(void)
  2236. {
  2237.     /*----------------------------------------------------------------*/
  2238.     /* Local Variables                                                */
  2239.     /*----------------------------------------------------------------*/
  2240.     color c;
  2241.     int changed_height = 0;
  2242.     /*----------------------------------------------------------------*/
  2243.     /* Code Body                                                      */
  2244.     /*----------------------------------------------------------------*/
  2245.     c.r = 255;
  2246.     c.g = 255;
  2247.     c.b = 255;
  2248.     c.alpha = 100;
  2249.     gui_reset_clip();
  2250.     gdi_layer_lock_frame_buffer();
  2251. //KP Jerry disable for avoid softkey area been overlaied by virtual keyboard on 2007-4-23 start
  2252. /*
  2253.     if (MMI_virtual_keyboard.height < gPenEditorCandidateInputBox.height)
  2254.     {
  2255.         changed_height = gPenEditorCandidateInputBox.height - MMI_virtual_keyboard.height;
  2256.     }
  2257. */    
  2258. //KP Jerry disable for avoid softkey area been overlaied by virtual keyboard on 2007-4-23 end
  2259.     
  2260.     if (wgui_is_wallpaper_on_bottom() == MMI_TRUE)
  2261.     {
  2262.         gdi_draw_solid_rect(
  2263.             0,
  2264.             MMI_virtual_keyboard.y - changed_height - 2,
  2265.             UI_device_width,
  2266.             MMI_virtual_keyboard.y + MMI_virtual_keyboard.height + changed_height - 1,
  2267.             GDI_COLOR_TRANSPARENT);
  2268.     }
  2269.     else
  2270.     {
  2271.         /* To Display Background in the area of the virtual keyboard when list menu */
  2272.         if (((PEN_EDITOR_INLINE_TEXT == gPenEditorInputBoxType) && (!(MMI_fixed_list_menu.flags & UI_LIST_MENU_DISABLE_BACKGROUND)))
  2273.             || PEN_EDITOR_INLINE_MULTILINE_INPUT_BOX == gPenEditorInputBoxType)
  2274.         {
  2275.             gui_show_list_menu_background_outside_area(&MMI_fixed_list_menu,
  2276.                 0,
  2277.                 MMI_virtual_keyboard.y - changed_height - 2,
  2278.                 UI_device_width,
  2279.                 MMI_virtual_keyboard.y + MMI_virtual_keyboard.height + changed_height - 1);
  2280.         }
  2281.         else
  2282.         {
  2283.             gui_fill_rectangle(
  2284.                 0,
  2285.                 MMI_virtual_keyboard.y - changed_height - 2,
  2286.                 UI_device_width,
  2287.                 MMI_virtual_keyboard.y + MMI_virtual_keyboard.height + changed_height - 1,
  2288.                 c);
  2289.         }
  2290.     }
  2291.     gdi_layer_unlock_frame_buffer();
  2292.     gui_BLT_double_buffer(
  2293.         0,
  2294.         MMI_virtual_keyboard.y - 2,
  2295.         UI_device_width - 1,
  2296.         MMI_virtual_keyboard.y + MMI_virtual_keyboard.height - 1);
  2297. }   /* end of mmi_pen_editor_hide_candidate_area */
  2298. /*****************************************************************************
  2299.  * FUNCTION
  2300.  *  mmi_pen_editor_stroke_down_handler
  2301.  * DESCRIPTION
  2302.  *  When receiving the stroke down event, do the related action according to the current situation
  2303.  * PARAMETERS
  2304.  *  pos     [IN]        The position of the stroke down event
  2305.  * RETURNS
  2306.  *  void
  2307.  *****************************************************************************/
  2308. void mmi_pen_editor_stroke_down_handler(mmi_pen_point_struct pos)
  2309. {
  2310.     /*----------------------------------------------------------------*/
  2311.     /* Local Variables                                                */
  2312.     /*----------------------------------------------------------------*/
  2313.     int changed_height;
  2314.     /*----------------------------------------------------------------*/
  2315.     /* Local Variables Initializing                                   */
  2316.     /*----------------------------------------------------------------*/
  2317.     changed_height = 0;
  2318.     /*----------------------------------------------------------------*/
  2319.     /* Code Body                                                      */
  2320.     /*----------------------------------------------------------------*/
  2321.     /* if hand writing is not enabled, it should not go here */
  2322.     if (!gPenEditorEnableHandWriting)
  2323.     {
  2324.         MMI_DBG_ASSERT(0);
  2325.         return;
  2326.     }
  2327.     if (g_pen_editor_smart_latin_pre_candidate_length)
  2328.     {
  2329.         mmi_pen_editor_smart_latin_confirm_select();
  2330.         mmi_pen_editor_set_left_soft_key();
  2331.     }
  2332.     if (g_pen_editor_composition_state.candidate_state != PEN_EDITOR_CANDIDATE_OFF)
  2333.     {
  2334.         int change_height = 0;
  2335.         g_pen_editor_composition_state.candidate_state = PEN_EDITOR_CANDIDATE_OFF;
  2336.         change_height += g_pen_editor_composition_input_box.height;
  2337.         mmi_pen_editor_resize_content_area(change_height);
  2338.         mmi_pen_editor_reset_key_sequence(&g_pen_editor_key_sequence);
  2339.     }
  2340.     /* create new layer for stroke through Draw Manager// */
  2341.     if (gPenEditorGDIHandler == NULL || *gPenEditorGDIHandler == GDI_ERROR_HANDLE)
  2342.     {
  2343.         gPenEditorStrokeGDIBuffer = (U8*) mmi_frm_scrmem_alloc(handwriting_stroke_layer_mem);
  2344.         MMI_ASSERT(gPenEditorStrokeGDIBuffer);
  2345.         if (GDI_LAYER_SUCCEED != dm_create_layer_using_outside_memory(
  2346.                                     0,
  2347.                                     0,
  2348.                                     UI_device_width,
  2349.                                     UI_device_height,
  2350.                                     &gPenEditorGDIHandler,
  2351.                                     (U8*) gPenEditorStrokeGDIBuffer,
  2352.                                     handwriting_stroke_layer_mem,
  2353.                                     DM_LAYER_TOP))
  2354.         {
  2355.             MMI_ASSERT(0);
  2356.         }
  2357.         gdi_layer_push_and_set_active(*gPenEditorGDIHandler);
  2358.         gdi_layer_set_source_key(TRUE, GDI_COLOR_TRANSPARENT);
  2359.         gdi_layer_clear(GDI_COLOR_TRANSPARENT);
  2360.         gdi_layer_pop_and_restore_active();
  2361.     }
  2362.     /* W05.47 If Chinese Symbol Keyboard, set to PinYin or Zhuyin Virtual Keyboard */
  2363.     /* W06.08 Avoid changing handwriting area when stroke down */
  2364.     //if (GUI_VIRTUAL_KEYBOARD_CHINESE_SYMBOL==MMI_virtual_keyboard.lang_type)
  2365.     //{
  2366.     //   mmi_pen_editor_vk_symbol_picker();
  2367.     //}