📄 jui_editor.c
字号:
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2001
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* jui_editor.c
*
* Project:
* --------
* Maui_Software
*
* Description:
* ------------
* This file implements Font adaption APIs
*
* Author:
* -------
* -------
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
/*************************************************************************
* Include header files
*************************************************************************/
#include "kal_release.h"
#include <FontRes.h>
#include "gdi_include.h"
#include "gui_buttons.h"
#include "wgui_categories_inputsenum.h"
#include "wgui_categories_inputs.h"
#define MMIAPI_USING_UI
#include "mmiapi_struct.h"
#include "mmiapi.h"
/*************************************************************************
* Use log string buffer to reduce memory usage
*************************************************************************/
#include "jal.h"
#include "jal_internal.h"
#include "jvm_internal.h"
/* reference point locations, from Graphics.java */
#define HCENTER 1
#define VCENTER 2
#define LEFT 4
#define RIGHT 8
#define TOP 16
#define BOTTOM 32
#define BASELINE 64
/* flags for font descriptors */
#define STYLE_PLAIN 0
#define STYLE_BOLD 1
#define STYLE_ITALIC 2
#define STYLE_UNDERLINED 4
/* flags for line types */
#define SOLID 0
#define DOTTED 1
#define SIZE_SMALL 8
#define SIZE_MEDIUM 0
#define SIZE_LARGE 16
#define FACE_SYSTEM 0
#define FACE_MONOSPACE 32
#define FACE_PROPORTIONAL 64
#define MAX_MIDP_FONT_DISPLAY 128
static char jui_text_buffer[MAX_MIDP_FONT_DISPLAY * sizeof(kal_uint16)];
extern void UI_set_current_text_color(color c);
extern void j2me_lcd_mutex_lock(void);
extern void j2me_lcd_mutex_unlock(void);
void jui_string_set_font(stFontAttribute *J2ME_font, kal_int32 face, kal_int32 style, kal_int32 size);
extern kal_uint16 gCurrLangIndex;
extern kal_uint32 gnCurrentFont;
extern const kal_uint16 mtk_gMaxDeployedLangs;
extern BOOL r2lMMIFlag;
extern kal_uint16 *jui_lcd_buffer;
static kal_uint16 jui_default_font_lang_indx = 0;
static kal_uint16 jui_small_font_lang_indx = 0;//020207 java font
static kal_uint16 jui_large_font_lang_indx = 0;
void j2me_custom_hw_to_mmi_color(kal_uint32 RGB, kal_int32 alpha, color *c);
void jvm_check_event_over(void);
/*****************************************************************************
* FUNCTION
* jui_string_init
* DESCRIPTION
* initialize font info.
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void jui_string_init(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
stFontAttribute J2ME_font = {0};
kal_int32 font_height, max_font_height = 0;
kal_uint16 i;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
J2ME_font.type = 1;
J2ME_font.bold = 0;
J2ME_font.italic = 0;
J2ME_font.underline = 0;
J2ME_font.size = MEDIUM_FONT;
J2ME_font.type = 1;
J2ME_font.oblique = 0;
kal_trace(TRACE_GROUP_5,
FUNC_J2ME_JUI_FONT,
__LINE__,
gnCurrentFont,
jvm_is_own_screen(),
UI_font);
for (i = 0; i < mtk_gMaxDeployedLangs; i++)
{
SetFont(J2ME_font, (kal_uint8)i);
font_height = gui_get_character_height();
if (font_height > max_font_height)
{
jui_default_font_lang_indx = i;
max_font_height = font_height;
}
}
J2ME_font.size = SMALL_FONT;
font_height = 0;
max_font_height = 0;
for (i = 0; i < mtk_gMaxDeployedLangs; i++)
{
SetFont(J2ME_font, (kal_uint8)i);
font_height = gui_get_character_height();
if (font_height > max_font_height)
{
jui_small_font_lang_indx = i;
max_font_height = font_height;
}
}
J2ME_font.size = LARGE_FONT;
font_height = 0;
max_font_height = 0;
for (i = 0; i < mtk_gMaxDeployedLangs; i++)
{
SetFont(J2ME_font, (kal_uint8)i);
font_height = gui_get_character_height();
if (font_height > max_font_height)
{
jui_large_font_lang_indx = i;
max_font_height = font_height;
}
}
kal_trace(TRACE_GROUP_5,
FUNC_J2ME_JUI_FONT,
__LINE__,
gnCurrentFont,
jvm_is_own_screen(),
UI_font);
}
/*****************************************************************************
* FUNCTION
* jui_string_draw_string
* DESCRIPTION
* Draw the first n characters in chararray, with the anchor point of the
* entire (sub)string located at x, y.
* PARAMETERS
* pixel [IN]
* clip [?]
* dst [?]
* dst_width [IN]
* dst_height [IN]
* buffer_size [IN]
* dotted [IN]
* face [IN]
* style [IN]
* size [IN]
* x [IN]
* y [IN]
* anchor [IN]
* chararray [IN]
* n [IN]
* RETURNS
* void
*****************************************************************************/
void jui_string_draw_string(
kal_int32 pixel,
short *clip,
unsigned short *dst,
kal_int32 dst_width,
kal_int32 dst_height,
kal_int32 buffer_size,
kal_int32 dotted,
kal_int32 face,
kal_int32 style,
kal_int32 size,
kal_int32 x,
kal_int32 y,
kal_int32 anchor,
const kal_uint16 *chararray,
kal_int32 n)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
stFontAttribute J2ME_font = {0};
color font_color, org_color;
kal_int32 width, height;
kal_int32 x_pos, y_pos;
kal_int32 clip_reg[4];
stFontAttribute org_font = {0};
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
kal_trace(TRACE_GROUP_5,
FUNC_J2ME_JUI_DRAW_STRING,
clip[0],
clip[1],
clip[2],
clip[3],
anchor,
x,
y,
n);
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())
{
if (UI_font)
{
memcpy(&org_font, UI_font, sizeof(stFontAttribute));
}
org_color = UI_text_color;
}
j2me_custom_hw_to_mmi_color(pixel, 100, &font_color);
jui_string_set_font(&J2ME_font, face, style, size);
/* Copy to temp string buffer, and append NULL */
if (n >= (MAX_MIDP_FONT_DISPLAY - 1))
{
n = MAX_MIDP_FONT_DISPLAY - 2;
}
kal_mem_cpy(jui_text_buffer, chararray, n * sizeof(kal_uint16));
jui_text_buffer[n * sizeof(kal_uint16)] = '\0';
jui_text_buffer[n * sizeof(kal_uint16) + 1] = '\0';
height = gui_get_character_height();
width = gui_get_string_width_n((UI_string_type) chararray, n);
/* Determine position */
if (anchor & HCENTER)
{
x_pos = x - width / 2;
}
else if (anchor & LEFT)
{
x_pos = x;
}
else if (anchor & RIGHT)
{
x_pos = x - width;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -