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

📄 jui_editor.c

📁 java 1.1 gemini 08_16
💻 C
📖 第 1 页 / 共 2 页
字号:
    else
    {
        x_pos = x;
    }

    if (anchor & VCENTER)
    {
        y_pos = y - height / 2;
    }
    else if (anchor & TOP)
    {
        y_pos = y;
    }
    else if (anchor & BOTTOM)
    {
        y_pos = y - height;
    }
    else if (anchor & BASELINE)
    {
        y_pos = y - height;
    }
    else
    {
        y_pos = y;
    }

    /* Check and set clip region */
    clip_reg[0] = (clip[0] < 0) ? 0 : clip[0];
    clip_reg[1] = (clip[1] < 0) ? 0 : clip[1];

    if (dst)
    {
        clip_reg[2] = ((clip[0] + clip[2] - 1) >= dst_width) ? (dst_width - 1) : (clip[0] + clip[2] - 1);
        clip_reg[3] = ((clip[1] + clip[3] - 1) >= dst_height) ? (dst_height - 1) : (clip[1] + clip[3] - 1);

        /* using one layer to display the text */
        {
            gdi_handle text_handle;

        #if DATACACHE_FBBR_ON
            dst = (unsigned short*)FBBR_invalid_l1_cache_img(dst, x_pos, y_pos, width, height, dst_width);
        #endif /* #if DATACACHE_FBBR_ON */

            gdi_layer_create_using_outside_memory(
                0,
                0,
                dst_width,
                dst_height,
                &text_handle,
                (U8*) dst,
                (kal_int32) buffer_size);

            gdi_layer_push_and_set_active(text_handle);
            gdi_layer_set_clip(clip_reg[0], clip_reg[1], clip_reg[2], clip_reg[3]);
            UI_set_current_text_color(font_color);
            if (r2lMMIFlag)
            {
                ShowString(x_pos + width - 1, y_pos, J2ME_font, 0, (unsigned char*)jui_text_buffer, height);
            }
            else
            {
                ShowString(x_pos, y_pos, J2ME_font, 0, (unsigned char*)jui_text_buffer, height);
            }
            gdi_layer_pop_and_restore_active();
            gdi_layer_free(text_handle);
        }

    }
    else
    {
        clip_reg[2] = ((clip[0] + clip[2] - 1) >= jui_ui_device_width) ? (jui_ui_device_width - 1) : (clip[0] + clip[2] - 1);
        clip_reg[3] = ((clip[1] + clip[3] - 1) >= jui_ui_device_height) ? (jui_ui_device_height - 1) : (clip[1] + clip[3] - 1);

        if (!jvm_is_own_screen())
        {
            gdi_handle text_handle;
            gdi_layer_create_using_outside_memory(
                0,
                0,
                jui_ui_device_width,
                jui_ui_device_height,
                &text_handle,
                (U8*) jui_lcd_buffer,
                (kal_int32)((jui_ui_device_width * jui_ui_device_height) << 1));

            gdi_layer_push_and_set_active(text_handle);
            gdi_layer_set_clip(clip_reg[0], clip_reg[1], clip_reg[2], clip_reg[3]);
            UI_set_current_text_color(font_color);
            if (r2lMMIFlag)
            {
                ShowString(x_pos + width - 1, y_pos, J2ME_font, 0, (unsigned char*)jui_text_buffer, height);
            }
            else
            {
                ShowString(x_pos, y_pos, J2ME_font, 0, (unsigned char*)jui_text_buffer, height);
            }
            gdi_layer_pop_and_restore_active();
            gdi_layer_free(text_handle);
        }
        else
        {
            UI_set_current_text_color(font_color);
            gdi_layer_set_clip(clip_reg[0], clip_reg[1], clip_reg[2], clip_reg[3]);

            if (r2lMMIFlag)
            {
                ShowString(x_pos + width - 1, y_pos, J2ME_font, 0, (unsigned char*)jui_text_buffer, height);
            }
            else
            {
                ShowString(x_pos, y_pos, J2ME_font, 0, (unsigned char*)jui_text_buffer, height);
            }
            gdi_layer_reset_clip();
        }
    }

    if (!jvm_is_own_screen())
    {
        if (UI_font)
        {
           gui_set_font(&org_font);
        }
        gui_set_text_color(org_color);
    }
    
    kal_trace(TRACE_GROUP_5, 
        FUNC_J2ME_JUI_FONT,
        __LINE__,
        gnCurrentFont,
        jvm_is_own_screen(),
        UI_font);
    
    jui_lcd_mutex_unlock();
}


/*****************************************************************************
 * FUNCTION
 *  jui_string_get_font_info
 * DESCRIPTION
 *  Get the ascent, descent and leading info for the J2ME_font indicated
 *  by FONTPARAMS.
 * PARAMETERS
 *  face        [IN]        
 *  style       [IN]        
 *  size        [IN]        
 *  ascent      [?]         
 *  descent     [?]         
 *  leading     [?]         
 * RETURNS
 *  void
 *****************************************************************************/
void jui_string_get_font_info(
        kal_int32 face,
        kal_int32 style,
        kal_int32 size,
        kal_int32 *ascent,
        kal_int32 *descent,
        kal_int32 *leading)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    stFontAttribute font = {0};
    stFontAttribute org_font = {0};

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    jui_lcd_mutex_lock();

    kal_trace(TRACE_GROUP_5, 
        FUNC_J2ME_JUI_FONT,
        __LINE__,
        gnCurrentFont,
        jvm_is_own_screen(),
        UI_font);
    
    if (!jvm_is_own_screen() && UI_font)
    {
        memcpy(&org_font, UI_font, sizeof(stFontAttribute));
    }

    jui_string_set_font(&font, face, style, size);

    *ascent = Get_CharDisplayHeightofAllType();
    *descent = 0;

    /* REMIND: is there a way to get the leading from an X J2ME_font? */
    *leading = 0;

    if (!jvm_is_own_screen() && UI_font)
    {
        gui_set_font(&org_font);
    }

    kal_trace(TRACE_GROUP_5, 
        FUNC_J2ME_JUI_FONT,
        __LINE__,
        gnCurrentFont,
        jvm_is_own_screen(),
        UI_font);
    
    jui_lcd_mutex_unlock();
}


/*****************************************************************************
 * FUNCTION
 *  jui_string_get_width
 * DESCRIPTION
 *  Get the width for the first n characters in charArray if
 *  they were to be drawn in the J2ME_font indicated by given font attributes.
 * PARAMETERS
 *  face            [IN]        Font attribute-face
 *  style           [IN]        Font attribute-style
 *  size            [IN]        Font attribute-size
 *  charArray       [IN]        Array of chars
 *  n               [IN]        Size of the array
 * RETURNS
 *  
 *****************************************************************************/
kal_int32 jui_string_get_width(
            kal_int32 face,
            kal_int32 style,
            kal_int32 size,
            const kal_uint16 *charArray,
            kal_int32 n)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    stFontAttribute font = {0};
    stFontAttribute org_font = {0};
    kal_int32 string_width;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    jui_lcd_mutex_lock();

    kal_trace(TRACE_GROUP_5, 
        FUNC_J2ME_JUI_FONT,
        __LINE__,
        gnCurrentFont,
        jvm_is_own_screen(),
        UI_font);
    
    if (!jvm_is_own_screen() && UI_font)
    {
        memcpy(&org_font, UI_font, sizeof(stFontAttribute));
    }
    jui_string_set_font(&font, face, style, size);
    string_width = gui_get_string_width_n((UI_string_type) charArray, n);

    if (!jvm_is_own_screen() && UI_font)
    {
        gui_set_font(&org_font);
    }

    kal_trace(TRACE_GROUP_5, 
        FUNC_J2ME_JUI_FONT,
        __LINE__,
        gnCurrentFont,
        jvm_is_own_screen(),
        UI_font);

    jui_lcd_mutex_unlock();

    return string_width;
}


/*****************************************************************************
 * FUNCTION
 *  jui_editor_entry_editor
 * DESCRIPTION
 *  enter full screen editor
 * PARAMETERS
 *  must_input          [IN]        User must give some input or not
 *  text_buf            [IN]        Buffer for user input
 *  text_buf_length     [IN]        Length of buffer
 *  input_type          [IN]        Input type
 * RETURNS
 *  void
 *****************************************************************************/
void jui_editor_entry_editor(
        kal_bool must_input,
        kal_uint16 *text_buf,
        kal_int32 text_buf_length,
        kal_int32 input_type)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
      /************************************************
      IMPORTANT NOTICE:
         Before using this function, remember to pause Java VM.
      *************************************************/
    kal_int32 ime_type = 0;
    mmiapi_ui_enter_fullscreen_editor_req_struct *msg = NEW_LOCAL_PTR(mmiapi_ui_enter_fullscreen_editor_req_struct);

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    switch (input_type)
    {
        case JUI_INPUT_TYPE_NUMERIC:
            ime_type = INPUT_TYPE_SIGNED_NUMERIC;
            break;

        case JUI_INPUT_TYPE_PHONE_NUMBER:
            ime_type = INPUT_TYPE_PHONE_NUMBER;
            break;

        case JUI_INPUT_TYPE_ALPHANUMERIC_LOWERCASE:
            ime_type = INPUT_TYPE_ALPHANUMERIC_LOWERCASE;
            break;

        case JUI_INPUT_TYPE_NUMERIC_PASSWORD:
            ime_type = INPUT_TYPE_SIGNED_NUMERIC_PASSWORD;
            break;

        case JUI_INPUT_TYPE_ALPHANUMERIC_PASSWORD:
            ime_type = INPUT_TYPE_ALPHANUMERIC_PASSWORD;
            break;

        case JUI_INPUT_TYPE_DECIMAL_NUMERIC:
            ime_type = INPUT_TYPE_SIGNED_DECIMAL_NUMERIC;
            break;

        case JUI_INPUT_TYPE_DECIMAL_NUMERIC_PASSWORD:
            ime_type = INPUT_TYPE_SIGNED_DECIMAL_NUMERIC_PASSWORD;
            break;
    }
    ime_type |= INPUT_TYPE_OVERRIDE_DEFAULT;

    msg->blocking_data = NULL;
    msg->editor_buffer = (kal_uint8*) text_buf;
    msg->is_must_input = must_input;
    msg->maxlen = text_buf_length + 1;
    msg->type = ime_type;

    SEND_MESSAGE(MOD_J2ME, MOD_MMI, MMI_J2ME_SAP, MSG_ID_MMIAPI_UI_ENTER_FULLSCREEN_EDITOR_REQ, msg, NULL);

}


/*****************************************************************************
 * FUNCTION
 *  jui_string_set_font
 * DESCRIPTION
 *  set font using given font attribute
 * PARAMETERS
 *  J2ME_font       [?]         
 *  face            [IN]        Font attribute-face
 *  style           [IN]        Font attribute-style
 *  size            [IN]        Font attribute-size
 * RETURNS
 *  void
 *****************************************************************************/
void jui_string_set_font(stFontAttribute *J2ME_font, kal_int32 face, kal_int32 style, kal_int32 size)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_uint16 language_index = 0;//020207 java font

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    /* Dotted not used. Need MMI support */
    kal_mem_set(J2ME_font, 0, sizeof(stFontAttribute));

    if (face == FACE_SYSTEM)
    {
        J2ME_font->type = 1;
    }
    else if (face == FACE_MONOSPACE)
    {
        J2ME_font->type = 2;
    }
    else
    {
        J2ME_font->type = 3;
    }

    if (style & STYLE_BOLD)
    {
        J2ME_font->bold = 1;
    }
    else
    {
        J2ME_font->bold = 0;
    }

    if (style & STYLE_ITALIC)
    {
        J2ME_font->italic = 1;
    }
    else
    {
        J2ME_font->italic = 0;
    }

    if (style & STYLE_UNDERLINED)
    {
        J2ME_font->underline = 1;
    }
    else
    {
        J2ME_font->underline = 0;
    }

    if (size == SIZE_SMALL)
    {
        J2ME_font->size = SMALL_FONT;
        language_index = jui_small_font_lang_indx;
    }
    else if (size == SIZE_MEDIUM)
    {
        J2ME_font->size = MEDIUM_FONT;
        language_index = jui_default_font_lang_indx;
    }
    else if (size == SIZE_LARGE)
    {
        J2ME_font->size = LARGE_FONT;
        language_index = jui_large_font_lang_indx;
    }

    SetFont(*J2ME_font, (kal_uint8)language_index);
}

⌨️ 快捷键说明

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