📄 nativegui.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:
* ---------
* nativeGUI.c
*
* Project:
* --------
* Maui_Software
*
* Description:
* ------------
* This file implements JAM native GUI
*
* 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!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
/*************************************************************************
* Include header files
*************************************************************************/
#include <kni.h>
#include <defaultLCDUI.h>
#include <nativeGUI.h>
#include <configuration.h>
#include <midpMalloc.h>
#include <midpServices.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
/*************************************************************************
* MTK include header files
*************************************************************************/
#include "kal_release.h"
#include "staticGraphics.h"
#include "lcd_sw.h"
#include "lcd_if.h"
#include "gui.h"
#include "wgui_categories.h"
#include "jam_msg_handler.h"
#include "settingprofile.h"
#include "jvm_adaptor.h"
#include "jal.h"
extern kal_uint16 *MainLCD_ShadowBuf_p;
/*************************************************************************
* Global Constant Definition
*************************************************************************/
/*************************************************************************
* Structure Definition
*************************************************************************/
typedef struct _Rectangle {
int x;
int y;
int width;
int height;
} XRectangle;
typedef struct {
KeyType button;
XRectangle bounds;
char *name;
} Key;
/*************************************************************************
* Static Variable
*************************************************************************/
/* fn prototypes */
void updateNetIndicator(void);
void drawNetIndicator(jboolean active);
extern kal_bool J2ME_is_own_screen;
extern kal_uint16 *jui_lcd_buffer;
BYTEARRAY canvas = NULL;
/* NOTE :
* trusted midlet icon x position is =
* right corner (screenoffset+paintwidth)
* - widht of battery (17 pixels)
* - space between battery and right edge of icon (10 pixels)
* - the width of the trusted icon
*/
int visualDepth;
jboolean doubleBuffer = KNI_TRUE;
/* Network Indicator status info */
int latestNICount = 0;
jboolean isLED_on = KNI_FALSE;
static const Key keys[] = {
#ifdef NO_POWER_BUTTON
/*
* Add -DNO_POWER_BUTTON to the Makefile if you want to disable
* the power button during user testing.
*/
{J2ME_KEY_POWER, {-10, -10, 1, 1}, "POWER"},
#else
{J2ME_KEY_POWER, {160, 59, 24, 24}, "POWER"},
#endif
{J2ME_KEY_SOFT1, {32, 347, 36, 27}, "SOFT1"},
{J2ME_KEY_SOFT2, {174, 347, 36, 27}, "SOFT2"},
{J2ME_KEY_UP, {105, 343, 30, 25}, "UP"},
{J2ME_KEY_DOWN, {105, 399, 30, 25}, "DOWN"},
{J2ME_KEY_LEFT, {72, 370, 25, 25}, "LEFT"},
{J2ME_KEY_RIGHT, {148, 370, 25, 25}, "RIGHT"},
{J2ME_KEY_SELECT, {110, 371, 24, 24}, "SELECT"},
{J2ME_KEY_SEND, {27, 387, 31, 36}, "SEND"},
{J2ME_KEY_END, {187, 387, 31, 36}, "END"},
{J2ME_KEY_CLEAR, {93, 427, 56, 29}, "CLEAR"},
{J2ME_KEY_1, {36, 462, 39, 31}, "1"},
{J2ME_KEY_2, {101, 466, 44, 28}, "2"},
{J2ME_KEY_3, {170, 462, 39, 31}, "3"},
{J2ME_KEY_4, {40, 499, 39, 31}, "4"},
{J2ME_KEY_5, {101, 505, 44, 28}, "5"},
{J2ME_KEY_6, {166, 500, 39, 31}, "6"},
{J2ME_KEY_7, {46, 539, 39, 31}, "7"},
{J2ME_KEY_8, {101, 543, 44, 28}, "8"},
{J2ME_KEY_9, {158, 539, 39, 31}, "9"},
{J2ME_KEY_ASTERISK, {50, 582, 41, 23}, "*"},
{J2ME_KEY_0, {101, 580, 44, 28}, "0"},
{J2ME_KEY_POUND, {153, 582, 41, 23}, "#"},
} ;
#ifdef __SUN_RI__
static int x_offset = 0;
static int y_offset = 0;
static int vScrollPosition, vScrollProportion;
//#else /* __SUN_RI__ */
static int eraseColor = 0xffff;
#else /* __SUN_RI__ */
#endif
static jboolean inFullScreenMode;
static jboolean requestedFullScreenMode;
// static jboolean drawTrustedMIDletIcon;
/* Sets the top bar to display a trusted MIDlet icon,
* then calls drawEmulatorScreen to cause an invalidate of
* the top bar
*/
void LCDUIdrawTrustedIcon(jboolean trusted)
{
// drawTrustedMIDletIcon = trusted;
/* For emulator only */
}
void setScreenMode(jboolean fullscreen)
{
inFullScreenMode = fullscreen;
}
void restoreScreenMode()
{
if (inFullScreenMode != requestedFullScreenMode) {
setScreenMode(requestedFullScreenMode);
}
}
void LCDUISetFullScreenMode(int mode)
{
/* defined as static in defaultLCDUI.c */
if(mode != 0){
requestedFullScreenMode = KAL_FALSE;
setScreenMode(KAL_FALSE);
}else{
requestedFullScreenMode = KAL_TRUE;
setScreenMode(KAL_TRUE);
}
setCommandsFullScreenMode(mode);
}
/*
* Return the key code corresponding to the given abstract game action.
*/
int LCDUIgetKeyCode(int gameAction)
{
switch (gameAction) {
case 1: return J2ME_KEY_UP;
case 6: return J2ME_KEY_DOWN;
case 2: return J2ME_KEY_LEFT;
case 5: return J2ME_KEY_RIGHT;
case 8: return J2ME_KEY_SELECT;
case 9: return J2ME_KEY_1;
case 10: return J2ME_KEY_3;
case 11: return J2ME_KEY_7;
case 12: return J2ME_KEY_9;
default: return 0;
}
}
/*
* Return the abstract game action corresponding to the given key code.
*/
int
LCDUIgetGameAction(int keyCode)
{
switch (keyCode) {
case J2ME_KEY_UP:
case J2ME_KEY_2:
return 1;
case J2ME_KEY_DOWN:
case J2ME_KEY_8:
return 6;
case J2ME_KEY_LEFT:
case J2ME_KEY_4:
return 2;
case J2ME_KEY_RIGHT:
case J2ME_KEY_6:
return 5;
case J2ME_KEY_SELECT:
case J2ME_KEY_5:
return 8;
case J2ME_KEY_1: return 9;
case J2ME_KEY_3: return 10;
case J2ME_KEY_7: return 11;
case J2ME_KEY_9: return 12;
case J2ME_KEY_SOFT1:
case J2ME_KEY_SOFT2:
case J2ME_KEY_0:
case J2ME_KEY_ASTERISK:
case J2ME_KEY_POUND:
case J2ME_KEY_POWER:
case J2ME_KEY_SEND:
case J2ME_KEY_END:
case J2ME_KEY_CLEAR:
return 0;
default:
return -1;
}
}
int
LCDUIgetSystemKey(int keyCode)
{
switch (keyCode) {
case J2ME_KEY_POWER: return 1;
case J2ME_KEY_SEND: return 2;
case J2ME_KEY_END: return 3;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -