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

📄 nativegui.c

📁 用于移动设备上的java虚拟机源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
    case KEY_POWER:    case KEY_SEND:    case KEY_END:    case KEY_CLEAR:        return 0;    default:        return -1;    }}intLCDUIgetSystemKey(int keyCode){    switch (keyCode) {    case KEY_POWER: return 1;    case KEY_SEND:  return 2;    case KEY_END:   return 3;    case KEY_CLEAR: return 4;    default:        return 0;    }}/* * Return the key name corresponding to the given key code. */char *LCDUIgetKeyName(int keyCode){    switch (keyCode) {    case KEY_POWER:    return Keys[0].name;    case KEY_SEND:     return Keys[8].name;    case KEY_END:      return Keys[9].name;    case KEY_CLEAR:    return Keys[10].name;    case KEY_SOFT1:    return Keys[1].name;    case KEY_SOFT2:    return Keys[2].name;    case KEY_UP:       return Keys[3].name;    case KEY_DOWN:     return Keys[4].name;    case KEY_LEFT:     return Keys[5].name;    case KEY_RIGHT:    return Keys[6].name;    case KEY_SELECT:   return Keys[7].name;    case KEY_1:        return Keys[11].name;    case KEY_2:        return Keys[12].name;    case KEY_3:        return Keys[13].name;    case KEY_4:        return Keys[14].name;    case KEY_5:        return Keys[15].name;    case KEY_6:        return Keys[16].name;    case KEY_7:        return Keys[17].name;    case KEY_8:        return Keys[18].name;    case KEY_9:        return Keys[19].name;    case KEY_ASTERISK: return Keys[20].name;    case KEY_0:        return Keys[21].name;    case KEY_POUND:    return Keys[22].name;    default:           return NULL;    }}/* The two functions setBrush and setPen are used by other .c files    and  are kept here to prevent creation of a new file. */HBRUSHsetBrush(HDC hdc, int pixel){    return SelectObject(hdc, CreateSolidBrush(pixel));}HPENsetPen(HDC hdc, int pixel, int dotted){    SetBkMode(hdc, OPAQUE);    SetBkColor(hdc, backgroundColor);    if (dotted) {        SetBkMode(hdc, TRANSPARENT);        return SelectObject(hdc, CreatePen(PS_DOT, 1, pixel));    } else {        return SelectObject(hdc, CreatePen(PS_SOLID, 1, pixel));    }}voidsetupFont(HDC hdc, FONTPARAMS_PROTO){    int faceIndex  = (face == FACE_PROPORTIONAL) ? 2 : (face == FACE_MONOSPACE) ? 1 : 0;    int sizeIndex  = (size == SIZE_SMALL) ? 0 : (size == SIZE_LARGE) ? 2 : 1;    int styleIndex = 0;    int height = "\011\013\017"[sizeIndex];    int pitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;    switch (faceIndex) {    case 0: pitchAndFamily = DEFAULT_PITCH  | FF_DONTCARE; break;    case 1: pitchAndFamily = FIXED_PITCH    | FF_MODERN;   break;    case 2: pitchAndFamily = VARIABLE_PITCH | FF_ROMAN;    break;    }    if (style & STYLE_BOLD) styleIndex += 1;    if (style & STYLE_ITALIC) styleIndex += 2;    if (style & STYLE_UNDERLINED) styleIndex += 4;    if (fonts[faceIndex][sizeIndex][styleIndex] == NULL) {#ifdef INCLUDE_I18N        /* currently the only supported locale is Japanese. */        DWORD cs = strncmp(getSystemProp("microedition.locale"), "ja", 2) ?                   ANSI_CHARSET: SHIFTJIS_CHARSET;#else        DWORD cs = ANSI_CHARSET;#endif        int weight = FW_NORMAL;        int width  = (height - 1) >> 1; /* generate narrow fonts */        if (style & STYLE_BOLD) {            weight = FW_EXTRABOLD;            /* ++width; */        }        if ((face == FACE_MONOSPACE) || (size == SIZE_SMALL)) {            width = 0;          /* use default width */        }        fonts[faceIndex][sizeIndex][styleIndex] =             CreateFont(          /* height */ -height,           /* width */ width,      /* escapement */ 0,     /* orientation */ 0,          /* weight */ weight,          /* italic */ (style & STYLE_ITALIC) ? 1 : 0,       /* underline */ (style & STYLE_UNDERLINED) ? 1 : 0,       /* strikeout */ 0,   /* character set */ cs,       /* precision */ OUT_STROKE_PRECIS,        /* clipping */ CLIP_DEFAULT_PRECIS,         /* quality */ NONANTIALIASED_QUALITY,/* pitch and family */ pitchAndFamily,     /* family name */ "");    }    SelectObject(hdc, fonts[faceIndex][sizeIndex][styleIndex]);}void LCDUIrefresh(int x1, int y1, int x2, int y2){    refreshPaintWindow(x1, y1, x2 + 1, y2 + 1);}/* * Get parameters describing the window system's capabilities */void LCDUIgetDisplayParams(int *width, int *height, int *adornedHeight,                           int *eraseColor, int *depth, int *flags, int *alphaLevels){    *width  = PAINT_WIDTH;    *height = DISPLAY_HEIGHT - TOP_BAR_HEIGHT;    *adornedHeight = DISPLAY_HEIGHT - TOP_BAR_HEIGHT - BOTTOM_BAR_HEIGHT;    *eraseColor = 0x00ffffff;    *depth  = (numColors == 16) ? 4 : (numColors == 256) ? 8 : numColors / 2;    *flags  = ((numColors > 16) ? 1 : 0)             | SUPPORTS_POINTER             | SUPPORTS_MOTION            | (doubleBuffer ? SUPPORTS_DOUBLEBUFFER : 0);    *alphaLevels = numColors;}intLCDUIsetVerticalScroll(int scrollPosition, int scrollProportion){    static int vScrollPosition, vScrollProportion;    int tmp1 = vScrollPosition;    int tmp2 = vScrollProportion;    HDC hdc;    vScrollPosition = scrollPosition;    vScrollProportion = scrollProportion;    hdc = getBitmapDC(UNTRANSLATED_SCREEN_BITMAP);    paintVerticalScroll(hdc, scrollPosition, scrollProportion);    releaseBitmapDC(hdc);    REFRESHBOTTOMBAR();    return tmp1;}jboolean LCDUIplaySound(int soundType){    switch (soundType) {    case ALERT_INFO:        /* MessageBeep(MB_OK); */        /* return KNI_TRUE; */        return KNI_FALSE;    case ALERT_WARNING:        MessageBeep(MB_ICONEXCLAMATION);        return KNI_TRUE;    case ALERT_ERROR:        MessageBeep(MB_ICONHAND);        return KNI_TRUE;    case ALERT_ALARM:        MessageBeep(MB_ICONASTERISK);        return KNI_TRUE;    case ALERT_CONFIRMATION:        /* MessageBeep(MB_ICONQUESTION); */        /* return KNI_TRUE; */        return KNI_FALSE;    default:        return KNI_FALSE;    }}/* * Requests a flashing effect for the device's backlight.  */ jboolean LCDUIshowBacklight(jboolean mode){     drawBackLight(mode);     return KNI_TRUE;}void LCDUIsetSoftButton(int index, const unicode *label, int len) {    HDC hdcMem;    int x, y, i, width;    /* 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 (len > MAX_SOFTBUTTON_CHARS) {        len = MAX_SOFTBUTTON_CHARS;    }    hdcMem = getBitmapDC(UNTRANSLATED_SCREEN_BITMAP);    SelectClipRgn(hdcMem, NULL);    if (index == 0) {        x = x_offset;     } else if (index == 1) {        x = x_offset + ((PAINT_WIDTH + ARROWS_WIDTH)/2) + 1;    }    y = y_offset + paintHeight;    /* draw top border of menu */    DrawMenuBarBorder(hdcMem);    CHECK_RETURN(SelectObject(hdcMem, BACKGROUND_BRUSH));    CHECK_RETURN(SelectObject(hdcMem, BACKGROUND_PEN));    CHECK_RETURN(SelectObject(hdcMem, GetStockObject(SYSTEM_FONT)));    Rectangle(hdcMem, x, y + MENUBAR_BORDER_HEIGHT,               x + ((PAINT_WIDTH - ARROWS_WIDTH)/2),               y + bottomBarHeight);        if (label == NULL) {        releaseBitmapDC(hdcMem);        REFRESHBOTTOMBAR();        if (index == 1) {            rlabel.num = 0;            rlabel.label[0] = 0;        } else {            llabel.num = 0;            llabel.label[0] = 0;        }        return;    }     if (index == 1) {        rlabel.num = i = len;        while (--i >= 0) {            rlabel.label[i] = label[i];        }    } else {        llabel.num = i = len;        while (--i >= 0) {            llabel.label[i] = label[i];        }    }    /*    setupFont(hdcMem, FACE_SYSTEM, STYLE_UNDERLINED, SIZE_MEDIUM);*/    setupFont(hdcMem, FACE_SYSTEM, STYLE_PLAIN, SIZE_MEDIUM);    width = 0;    for (i = 0; i < len; ++i) {      SIZE size;        GetTextExtentPoint32W(hdcMem, &label[i], 1, &size);        width += size.cx;        if (width > ((PAINT_WIDTH - ARROWS_WIDTH)/2)) {            len = i;            width -= size.cx;            break;        }    }        if (index == 0) {        x = x_offset + 2; /* left justified */        SetTextAlign(hdcMem, TA_BOTTOM | TA_LEFT);    } else if (index == 1) {        x = x_offset + PAINT_WIDTH - 2; /*right justified */        SetTextAlign(hdcMem, TA_BOTTOM | TA_RIGHT);    }    y = y_offset + paintHeight + bottomBarHeight;    SetBkMode(hdcMem, OPAQUE);     SetTextColor(hdcMem, foregroundColor);    SetBkColor(hdcMem, backgroundColor);    TextOutW(hdcMem, x, y, label, len);        releaseBitmapDC(hdcMem);    REFRESHBOTTOMBAR();}voidLCDUIsetInputMode(int mode){    static const BYTE ABC_bits[] = {        0x98, 0xe3,        0x6b, 0x5b,        0x6b, 0x5f,        0x68, 0xdf,        0x0b, 0x5f,        0x6b, 0x5f,        0x68, 0xe3};    static const BYTE abc_bits[] = {        0xfb, 0xff,        0xfb, 0xff,        0xab, 0xff,        0xe8, 0xe3,        0x8b, 0x5f,        0x6b, 0x5f,        0x88, 0xe3};    static const BYTE num_bits[] = {        0xb1, 0x9f,        0x36, 0xef,        0xbe, 0xef,        0xbd, 0x9f,        0xbb, 0xef,        0xbf, 0xef,        0x10, 0x9f};    static const BYTE SYM_bits[] = {        0x95, 0x77,        0x75, 0x27,        0x75, 0x57,        0xb5, 0x77,        0xdb, 0x77,        0xdb, 0x77,        0x3b, 0x77};#ifdef INCLUDE_I18N    #include "inputmodes_ja.bmp"#endif    static RECT r;    HDC hdc;    BYTE *icon = NULL;    hdc = getBitmapDC(UNTRANSLATED_SCREEN_BITMAP);    if (r.left == 0) {        r.left   = x_offset - 1 + 82; /* was 30 */        r.top    = y_offset - topBarHeight + (topBarHeight - 7) / 2;        r.right  = r.left + 15;        r.bottom = r.top + 7;    }    CHECK_RETURN(SelectObject(hdc, BACKGROUND_BRUSH));    CHECK_RETURN(SelectObject(hdc, BACKGROUND_PEN));    Rectangle(hdc, r.left, r.top, r.right, r.bottom);    switch (mode) {    case 1:        icon = (BYTE *) ABC_bits;        break;    case 2:        icon = (BYTE *) abc_bits;        break;    case 3:        icon = (BYTE *) num_bits;        break;    case 4:        icon = (BYTE *) SYM_bits;        break;#ifdef INCLUDE_I18N    case 5:        icon = (BYTE *) hira_bits;        break;    case 6:        icon = (BYTE *) kana_bits;        break;#endif    case 0:    default:        break;    }    if (icon != NULL) {        HBITMAP hb = CreateBitmap(15, 7, 1, 1, icon);        DrawBitmap(hdc, hb, r.left, r.top, MERGECOPY);        DeleteObject(hb);    }    releaseBitmapDC(hdc);    InvalidateRect(hMainWindow, &r, KNI_TRUE);}static jboolean suppressedCodes[256];static voidsuppressCode(LPARAM lParam) {    int scanCode = (lParam >> 16) & 0xff;    suppressedCodes[scanCode] = 1;}static jbooleanisSuppressedCode(LPARAM lParam) {    int scanCode = (lParam >> 16) & 0xff;    return suppressedCodes[scanCode];}

⌨️ 快捷键说明

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