📄 nativegui.c
字号:
case J2ME_KEY_CLEAR: return 4;
default: return 0;
}
}
/*
* Return the key name corresponding to the given key code.
*/
char *
LCDUIgetKeyName(int keyCode)
{
switch (keyCode) {
case J2ME_KEY_POWER: return keys[0].name;
case J2ME_KEY_SEND: return keys[8].name;
case J2ME_KEY_END: return keys[9].name;
case J2ME_KEY_CLEAR: return keys[10].name;
case J2ME_KEY_SOFT1: return keys[1].name;
case J2ME_KEY_SOFT2: return keys[2].name;
case J2ME_KEY_UP: return keys[3].name;
case J2ME_KEY_DOWN: return keys[4].name;
case J2ME_KEY_LEFT: return keys[5].name;
case J2ME_KEY_RIGHT: return keys[6].name;
case J2ME_KEY_SELECT: return keys[7].name;
case J2ME_KEY_1: return keys[11].name;
case J2ME_KEY_2: return keys[12].name;
case J2ME_KEY_3: return keys[13].name;
case J2ME_KEY_4: return keys[14].name;
case J2ME_KEY_5: return keys[15].name;
case J2ME_KEY_6: return keys[16].name;
case J2ME_KEY_7: return keys[17].name;
case J2ME_KEY_8: return keys[18].name;
case J2ME_KEY_9: return keys[19].name;
case J2ME_KEY_ASTERISK: return keys[20].name;
case J2ME_KEY_0: return keys[21].name;
case J2ME_KEY_POUND: return keys[22].name;
default: return NULL;
}
}
void LCDUIgetDisplayParams(int *width, int *height, int *adornedHeight,
int *fg_color, int *erase_color, int *depth, int *flags, int *alphaLevels)
{
jui_widget_get_display_properties(width, height, adornedHeight, fg_color, erase_color, depth, alphaLevels);
*flags = ((*depth >= 8 ) ? SUPPORTS_COLOR : 0)
| SUPPORTS_REPEAT
#ifdef __MMI_TOUCH_SCREEN__
| SUPPORTS_POINTER | SUPPORTS_MOTION
#endif
| (doubleBuffer ? SUPPORTS_DOUBLEBUFFER : 0);
/* | SUPPORTS_POINTER | SUPPORTS_MOTION */
}
extern kal_bool isCommandMustUpdate;
void LCDUIsetSoftButton(int index, const unicode *label, int numChars)
{
#ifndef __SUN_RI__
jui_widget_set_softkey(index,label,numChars,isCommandMustUpdate);
#else
int x, y;
short clip[4];
/* Check to see that we are being called in full screen mode.
In such a case we should return without doing anything.
Ideally we shouldn't be being called at all. However,
there is at least one place in the code (in menus.c)
where we are called from within a code block
that is executed if we are in fullscreen mode.
*/
if (KNI_TRUE == inFullScreenMode)
return;
if ((index < 0) || (index >= 2))
return;
if (index == 0) x = x_offset;
else if (index == 1) x = x_offset + jui_widget_get_display_width()/2;
y = y_offset + (jui_widget_get_display_height() - jui_widget_get_button_bar_height());
clip[0] = 0;
clip[1] = y - 1;
clip[2] = jui_widget_get_display_width();
clip[3] = jui_widget_get_display_height() - y + 1;
/* Clean softbutton region */
LCDUIfillRect(eraseColor, clip, NULL, 0, x, y - 1, jui_widget_get_display_width()/2 ,
jui_widget_get_button_bar_height() + 1);
jui_widget_refresh_screen(x, y - 1, jui_widget_get_display_width()/2, jui_widget_get_display_height() + 1);
if (label == NULL) return;
if (index == 0) x = x_offset;
else if (index == 1) x = x_offset + jui_widget_get_display_width()/2 + 10;
y = y_offset + (jui_widget_get_display_height() - jui_widget_get_button_bar_height());
/* light gray */
LCDUIfillRect(0xafafaf, clip, NULL, 0, x, y, jui_widget_get_display_width()/2 - 10 ,
jui_widget_get_button_bar_height());
/* draw top border */
LCDUIdrawLine(0x606060, clip, NULL, 0, x, y,
x + jui_widget_get_display_width()/2 - 10 - 1, y);
LCDUIdrawLine(eraseColor, clip, NULL, 0, x, y + 1, x + jui_widget_get_display_width()/2 - 10 - 1, y + 1);
if (index == 0) {
/* draw left border */
LCDUIdrawLine(0x606060, clip, NULL, 0, x + jui_widget_get_display_width()/2 - 10 - 1, y,
x + jui_widget_get_display_width()/2 - 10 - 1, y + jui_widget_get_button_bar_height());
LCDUIdrawLine(eraseColor, clip, NULL, 0, x + jui_widget_get_display_width()/2 - 10 - 2, y + 1,
x + jui_widget_get_display_width()/2 - 10 - 2, y + jui_widget_get_button_bar_height());
} else if (index == 1) {
/* draw left border */
LCDUIdrawLine(0x606060, clip, NULL, 0, x, y,
x, y + jui_widget_get_button_bar_height());
LCDUIdrawLine(eraseColor, clip, NULL, 0, x + 1, y+1,
x + 1, y + jui_widget_get_button_bar_height());
}
y = y_offset + (jui_widget_get_display_height() - jui_widget_get_button_bar_height()) + 2;
if (index == 0) {
x = x_offset + 6;
clip[0] = x;
clip[1] = y - 1;
clip[2] = jui_widget_get_display_width()/2 - 5 - 5 - 6; /* 5 for scrall, 5 for margin, 6 for char offset */
clip[3] = jui_widget_get_display_height() - y + 1;
/* If width is over softbutton region, use small font */
if (jui_string_get_width(FACE_SYSTEM, STYLE_PLAIN, SIZE_MEDIUM, label, numChars) > clip[2]) {
LCDUIdrawChars(0x000000, clip, NULL, 0,
FACE_SYSTEM, STYLE_PLAIN, SIZE_SMALL,
x, y + 2, LEFT | TOP, label, numChars);
} else {
LCDUIdrawChars(0x000000, clip, NULL, 0,
FACE_SYSTEM, STYLE_PLAIN, SIZE_MEDIUM,
x, y, LEFT | TOP, label, numChars);
}
} else if (index == 1) {
x = jui_widget_get_display_width() - 6 - x_offset - 2;
clip[0] = jui_widget_get_display_width()/2 + 5 + 2;
clip[1] = y - 1;
clip[2] = jui_widget_get_display_width()/2 - 5 - 5 - 6; /* 5 for scrall, 5 for margin */
clip[3] = jui_widget_get_display_height() - y + 1;
if (jui_string_get_width(FACE_SYSTEM, STYLE_PLAIN, SIZE_MEDIUM, label, numChars) > clip[2]) {
LCDUIdrawChars(0x000000, clip, NULL, 0,
FACE_SYSTEM, STYLE_PLAIN, SIZE_SMALL,
x, y + 2, RIGHT | TOP, label, numChars);
} else {
LCDUIdrawChars(0x000000, clip, NULL, 0,
FACE_SYSTEM, STYLE_PLAIN, SIZE_MEDIUM,
x, y, RIGHT | TOP, label, numChars);
}
}
if (index == 0) x = x_offset;
else if (index == 1) x = x_offset + jui_widget_get_display_width()/2 + 10;
jui_widget_refresh_screen(x, y, x + jui_widget_get_display_width()/2 - 5 + 1, y + jui_widget_get_button_bar_height());
#endif
}
int LCDUIsetVerticalScroll(int scrollPosition, int scrollProportion)
{
#ifndef __SUN_RI__
return 0;
#else
int tmp1 = vScrollPosition;
short clip[4] = {SOFTBUTTON_WIDTH , jui_widget_get_display_height()-jui_widget_get_button_bar_height(), ARROWS_WIDTH, jui_widget_get_button_bar_height()};
vScrollPosition = scrollPosition;
vScrollProportion = scrollProportion;
if (KNI_TRUE == inFullScreenMode) return 0;
/* If the scrollable is 100% the proportion of the viewport, */
/* there's no need for any scrolling, clear the arrows and */
/* return. */
if (scrollProportion >= 100 || scrollProportion == 0) {
LCDUIfillRect(eraseColor, clip, NULL, 0,
SOFTBUTTON_WIDTH, jui_widget_get_display_height()-jui_widget_get_button_bar_height(), ARROWS_WIDTH, ARROWS_HEIGHT);
LCDUIfillRect(eraseColor, clip, NULL, 0,
SOFTBUTTON_WIDTH, jui_widget_get_display_height()-ARROWS_HEIGHT, ARROWS_WIDTH, ARROWS_HEIGHT);
jui_widget_refresh_screen(SOFTBUTTON_WIDTH, jui_widget_get_display_height()-jui_widget_get_button_bar_height(), jui_widget_get_display_width(), jui_widget_get_display_height());
return 0;
}
/* If we're somewhere between the top and bottom, */
/* add both scroll arrows */
if (scrollPosition > 0 && scrollPosition < 100) {
LCDUIdrawRegionTransform(clip, NULL, NULL,
SOFTBUTTON_WIDTH, jui_widget_get_display_height()-jui_widget_get_button_bar_height(), 20,
0, 0,
ARROWS_WIDTH, ARROWS_HEIGHT,
0, 7);
LCDUIdrawRegionTransform(clip, NULL, NULL,
SOFTBUTTON_WIDTH, jui_widget_get_display_height()-ARROWS_HEIGHT, 20,
0, 0,
ARROWS_WIDTH, ARROWS_HEIGHT,
1, 7);
/* If we're at the top, add the down arrow, clear the */
/* up arrow */
} else if (scrollPosition == 0) {
LCDUIdrawRegionTransform(clip, NULL, NULL,
SOFTBUTTON_WIDTH, jui_widget_get_display_height()-ARROWS_HEIGHT, 20,
0, 0,
ARROWS_WIDTH, ARROWS_HEIGHT,
1, 7);
LCDUIfillRect(eraseColor, clip, NULL, 0,
SOFTBUTTON_WIDTH, jui_widget_get_display_height()-jui_widget_get_button_bar_height(), ARROWS_WIDTH, ARROWS_HEIGHT);
/* We're at the bottom, add the up arrow, clear the */
/* down arrow */
} else {
LCDUIdrawRegionTransform(clip, NULL, NULL,
SOFTBUTTON_WIDTH, jui_widget_get_display_height()-jui_widget_get_button_bar_height(), 20,
0, 0,
ARROWS_WIDTH, ARROWS_HEIGHT,
0, 7);
LCDUIfillRect(eraseColor, clip, NULL, 0,
SOFTBUTTON_WIDTH, jui_widget_get_display_height()-ARROWS_HEIGHT, ARROWS_WIDTH, ARROWS_HEIGHT);
}
jui_widget_refresh_screen(SOFTBUTTON_WIDTH, jui_widget_get_display_height()-jui_widget_get_button_bar_height(), jui_widget_get_display_width(), jui_widget_get_display_height());
return tmp1;
#endif
}
void LCDUIsetInputMode(int mode)
{
/* Need to port */
}
extern int vm_is_force_terminated;
extern jboolean g_video_repaint;
void InitializeWindowSystem()
{
int i,j,k;
int lcd_width = 0;
int lcd_height = 0;
int ret = 0;
unsigned short *rawData;
ret = jui_widget_init_layer();
/* VM should not progress until layer is initialized */
while(ret == -1)
{
ret = jui_widget_init_layer();
if(vm_is_force_terminated)
{
ERROR_THROW(0);
}
}
/* Initialize for canvas is covered by another canvas */
g_video_repaint = KNI_TRUE;
/* 2003 0818 Hsu */
/* set up the offsets for non-full screen mode*/
inFullScreenMode = KNI_FALSE;
jui_widget_set_screen_mode(JUI_SCREEN_MODE_NORMAL);
requestedFullScreenMode = KNI_FALSE;
/* Java only support 2bytes per pixel now */
#if USING_LCD_SHADOW_BUFFER
canvas = (BYTEARRAY)midpMalloc( SIZEOF_ARRAY((sizeof(ImageGC)+3)>>2) << 2);
#if USING_JAVAHEAP_AS_IMAGEBUFFER
((pImageGC)(canvas->bdata))->u.datap=(unsigned short *)jui_lcd_buffer;
rawData = ((pImageGC)(canvas->bdata))->u.datap;
#else
((pImageGC)(canvas->bdata))->data=(unsigned short *)jui_lcd_buffer;
rawData = ((pImageGC)(canvas->bdata))->data;
#endif /* USING_JAVAHEAP_AS_IMAGEBUFFER */
#else
canvas = (BYTEARRAY)midpMalloc( SIZEOF_ARRAY((jui_widget_get_display_width() * jui_widget_get_display_height() * 2 + sizeof(ImageGC)+3)>>2) << 2);
#if USING_JAVAHEAP_AS_IMAGEBUFFER
rawData = ((pImageGC)(canvas->bdata))->u.data;
#else
((pImageGC)(canvas->bdata))->data=(unsigned short *)(((pImageGC)canvas->bdata)+1);
rawData = ((pImageGC)(canvas->bdata))->data;
#endif /* USING_JAVAHEAP_AS_IMAGEBUFFER */
#endif /* USING_LCD_SHADOW_BUFFER */
((pImageGC)(canvas->bdata))->TAG = 0;
((pImageGC)(canvas->bdata))->width = jui_widget_get_display_width();
((pImageGC)(canvas->bdata))->height = jui_widget_get_display_height();
k = 0;
lcd_width = jui_widget_get_display_width();
lcd_height = jui_widget_get_display_height();
for (j=0; j<lcd_height; j++) {
for (i=0; i<lcd_width; i++) {
rawData[k++] = j2me_custom_lcd_hw_format(0xff, 0xff, 0xff);
}
}
jui_widget_register_lcd(KAL_TRUE); // register lcd again
jui_widget_refresh_lcd(0,0,lcd_width,lcd_height);
LCDUIinitPopupMenu();
LCDUIinitMenus();
}
/*
* Finalize the use of the window system by returning all allocated
* graphics data structures to the free list. e.g. close, destroy or free
* X, Xt and xpm library resources.
*/
void FinalizeWindowSystem()
{
if (canvas) {
midpFree(canvas);
canvas = NULL;
}
jui_widget_deinit_layer();
LCDUIfinalizeMenus();
LCDUIfinalizePopupMenu();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -