📄 nativegui.c
字号:
XSetWindowBackgroundPixmap(display, paintWindow, paintDrawable); drawEmulatorScreen(inFullScreenMode); /* Create the Backlight window */ valuemask = 0; BackLightWindow = XCreateWindow(display, outerWindow, Bklite_xposition, Bklite_yposition, Bklite_width, Bklite_height, 0, visualDepth, InputOutput, visual, valuemask, &attributes); gc = XCreateGC(display, BackLightWindow, GCbase, &vals); /*the same event mask as the outer window*/ XSelectInput(display, BackLightWindow, outerEvtMask); XDefineCursor(display, BackLightWindow, stylusCursor = XCreateFontCursor(display, XC_pencil)); /*Load the BackLight images*/ BackLightAttributes.valuemask = XpmVisual | XpmDepth | XpmReturnPixels | XpmCloseness | XpmSize | XpmColormap; BackLightAttributes.closeness = 40000; BackLightAttributes.visual = visual; BackLightAttributes.depth = visualDepth; BackLightAttributes.colormap = colormap; status = XpmCreatePixmapFromData(display, BackLightWindow, backLight_xpm, &backLightPixmap, NULL, &BackLightAttributes); status = XpmCreatePixmapFromData(display, BackLightWindow, backLight_Off_xpm, &backLightOffPixmap, NULL, &BackLightAttributes); BackLight_off_Image = XGetImage(display, backLightOffPixmap, 0, 0, 241, 232, 0xffffffff, XYPixmap); BackLight_on_Image = XGetImage(display, backLightPixmap, 0, 0, 241, 232, 0xffffffff, XYPixmap); /* We keep the XImages around, so we don't need the pixmaps...*/ if (backLightOffPixmap != None) { XFreePixmap(display,backLightOffPixmap); backLightOffPixmap = None; } if (backLightPixmap != None) { XFreePixmap(display,backLightPixmap); backLightPixmap = None; } /* * We need a separate bitmap to serve as the drawable for the screen area */ BackLightDrawable = XCreatePixmap(display, BackLightWindow, Bklite_width, Bklite_height, visualDepth); XFillRectangle(display, BackLightDrawable, gcErase, 0, 0, Bklite_width, Bklite_height); XSetWindowBackgroundPixmap(display, BackLightWindow, BackLightDrawable); XPutImage(display, BackLightDrawable, gcNormal, BackLight_off_Image, 0, 0, 0, 0, Bklite_width, Bklite_height); /* Create the "LED" window for the network indicator */ valuemask = 0; LEDWindow = XCreateWindow(display, outerWindow, LED_xposition, LED_yposition, LED_width, LED_height, 0, visualDepth, InputOutput, visual, valuemask, &attributes); gc = XCreateGC(display, LEDWindow, GCbase, &vals); /*the same event mask as the outer window*/ XSelectInput(display, LEDWindow, outerEvtMask); XDefineCursor(display, LEDWindow, stylusCursor = XCreateFontCursor(display, XC_pencil)); /*Load the LED images*/ LEDAttributes.valuemask = XpmVisual | XpmDepth | XpmReturnPixels | XpmCloseness | XpmSize | XpmColormap; LEDAttributes.closeness = 40000; LEDAttributes.visual = visual; LEDAttributes.depth = visualDepth; LEDAttributes.colormap = colormap; status = XpmCreatePixmapFromData(display, LEDWindow, grayLED_xpm, &grayLEDPixmap, NULL, &LEDAttributes); status = XpmCreatePixmapFromData(display, LEDWindow, greenLED_xpm, &greenLEDPixmap, NULL, &LEDAttributes); LED_on_Image = XGetImage(display, greenLEDPixmap, 0, 0, 20, 20, 0xffffffff, XYPixmap); LED_off_Image = XGetImage(display, grayLEDPixmap, 0, 0, 20, 20, 0xffffffff, XYPixmap); /* We keep the XImages around, so we don't need the pixmaps...*/ if (grayLEDPixmap != None) { XFreePixmap(display,grayLEDPixmap); grayLEDPixmap = None; } if (greenLEDPixmap != None) { XFreePixmap(display, greenLEDPixmap); greenLEDPixmap = None; } XpmFreeAttributes(&LEDAttributes); /* * We need a separate bitmap to serve as the drawable for the screen area */ LEDDrawable = XCreatePixmap(display, LEDWindow, LED_width, LED_height, visualDepth); XSetWindowBackgroundPixmap(display, LEDWindow, LEDDrawable); drawNetIndicator(KNI_FALSE); if (trustedicon == None) { /* Load the topbar image */ trustediconAttributes.valuemask = XpmVisual | XpmDepth | XpmReturnPixels | XpmCloseness | XpmSize | XpmColormap; trustediconAttributes.closeness = 40000; trustediconAttributes.visual = visual; trustediconAttributes.depth = visualDepth; trustediconAttributes.colormap = colormap; status = XpmCreatePixmapFromData(display, backgroundDrawable, trustedicon_xpm, &trustediconPixmap, NULL, &trustediconAttributes); trustedicon = XGetImage(display, trustediconPixmap, 0, 0, TrustIcon_width, TrustIcon_height, 0xffffffff, XYPixmap); /* We keep the XImages around, so we don't need the pixmaps...*/ if (trustediconPixmap != None) { XFreePixmap(display, trustediconPixmap); trustediconPixmap = None; } XpmFreeAttributes(&trustediconAttributes); } /* TEMPORARY */ systemFontInfo = XLoadQueryFont(display, DEFAULT_FONT_NAME); /* Let the window manager tell us about close events */ deleteAtom = XInternAtom(display, "WM_DELETE_WINDOW", KNI_FALSE); XSetWMProtocols(display, outerWindow, &deleteAtom, 1); /* Indicate that we don't want to be resized. */ setWMHints(outerWindow, "lcdui", "lcdui", EMULATOR_WIDTH, EMULATOR_HEIGHT); /* Create timer atom */ timerAtom = XInternAtom(display, "MIDP_CLIENT_TIMER_ATOM", KNI_FALSE); /* create mmEOM atom */ mmEOMAtom = XInternAtom(display, "MM_EOM_ATOM", KNI_FALSE); /* Create underlining atoms */ underlinePositionAtom = XInternAtom(display, "UNDERLINE_POSITION", KNI_FALSE); underlineThicknessAtom = XInternAtom(display, "UNDERLINE_THICKNESS", KNI_FALSE); rawPositionAtom = XInternAtom(display, "RAW_UNDERLINE_POSITION", KNI_FALSE); rawThicknessAtom = XInternAtom(display, "RAW_UNDERLINE_THICKNESS", KNI_FALSE);#ifdef INCLUDE_I18N if (lcWin) { lcWin->init(display); } { unsigned long fevent; xim = XOpenIM(display, NULL, NULL, NULL); if (xim) { xic = XCreateIC(xim, XNInputStyle, (XIMPreeditNothing | XIMStatusNothing), XNClientWindow, outerWindow, XNFocusWindow, outerWindow, NULL); if (xic) { XGetICValues(xic, XNFilterEvents, &fevent, NULL); outerEvtMask |= fevent; XSelectInput(display, outerWindow, outerEvtMask); } } }#endif /* Make sure that everything is visible */ XMapRaised(display, outerWindow); XMapRaised(display, BackLightWindow); XMapRaised(display, backgroundWindow); XMapRaised(display, paintWindow); XMapRaised(display, LEDWindow); /* XMapSubwindows(display, outerWindow); */ XFlush(display);}voidrefreshPaintWindow(int x1, int y1, int x2, int y2){ if (x1 > x2) { int t = x1; x1 = x2; x2 = t; } if (y1 > y2) { int t = y1; y1 = y2; y2 = t; } XClearArea(display, paintWindow, x1, y1, x2 - x1 + 1, y2 - y1 + 1, 0); XFlush(display);}static Pixmap stipple33 = None;static Pixmap stipple50 = None;static Pixmap stipple66 = None;DrawablesetupGC(GC gc, int pixel, short *clip, void* dst, int dotted){ /* static char dash33[] = {2, 1}; static char dash50[] = {1, 1}; static char dash66[] = {1, 2}; static char dotted[] = {3, 2, 2, 3}; if (lineStyle == DOTTED) { XSetDashes(display, gc, 0, dotted, 4); XSetLineAttributes(display, gc, 1, LineOnOffDash, CapButt, JoinMiter); } else { XSetLineAttributes(display, gc, 1, LineSolid, CapButt, JoinMiter); } if (numColors == 2) { if ((gray >= 115) && (gray <= 140)) { XSetForeground(display, gc, getGrayPixel(0)); XSetStipple(display, gc, stipple50); XSetFillStyle(display, gc, FillStippled); XSetDashes(display, gc, 0, dash50, 2); XSetLineAttributes(display, gc, 1, LineOnOffDash, CapButt, JoinMiter); } else { switch (gray >> 6) { case 0: case 3: XSetForeground(display, gc, getGrayPixel(gray)); XSetFillStyle(display, gc, FillSolid); XSetLineAttributes(display, gc, 1, LineSolid, CapButt, JoinMiter); break; case 1: XSetForeground(display, gc, getGrayPixel(0)); XSetStipple(display, gc, stipple33); XSetDashes(display, gc, 0, dash33, 2); XSetLineAttributes(display, gc, 1, LineOnOffDash, CapButt, JoinMiter); break; case 2: XSetForeground(display, gc, getGrayPixel(0)); XSetStipple(display, gc, stipple66); XSetDashes(display, gc, 0, dash66, 2); XSetLineAttributes(display, gc, 1, LineOnOffDash, CapButt, JoinMiter); break; } } if (lineStyle == DOTTED) { XSetDashes(display, gc, 0, dotted, 4); XSetLineAttributes(display, gc, 1, LineOnOffDash, CapButt, JoinMiter); } } else if (numColors == 256) { XSetForeground(display, gc, getColorPixel(color)); } else { XSetForeground(display, gc, getGrayPixel(gray)); } */ XSetForeground(display, gc, pixel); if (clip) { XSetClipRectangles(display, gc, 0, 0, (XRectangle*)clip, 1, YXBanded); } else { XSetClipMask(display, gc, None); } if (dotted) { static char dotted[] = {1, 1}; XSetDashes(display, gc, 0, dotted, 2); XSetLineAttributes(display, gc, 1, LineOnOffDash, CapButt, JoinMiter); } else { XSetLineAttributes(display, gc, 1, LineSolid, CapButt, JoinMiter); } if (dst == NULL) { return paintDrawable; } else { return *((Pixmap *)dst); }}/* * Return the key code corresponding to the given abstract game action. */int LCDUIgetKeyCode(int gameAction){ switch (gameAction) { case 1: return KEY_UP; case 6: return KEY_DOWN; case 2: return KEY_LEFT; case 5: return KEY_RIGHT; case 8: return KEY_SELECT; case 9: return KEY_1; case 10: return KEY_3; case 11: return KEY_7; case 12: return KEY_9; default: return 0; }}/* * Return the abstract game action corresponding to the given key code. */int LCDUIgetGameAction(int keyCode){ switch (keyCode) { case KEY_UP: case KEY_2: return 1; case KEY_DOWN: case KEY_8: return 6; case KEY_LEFT: case KEY_4: return 2; case KEY_RIGHT: case KEY_6: return 5; case KEY_SELECT: case KEY_5: return 8; case KEY_1: return 9; case KEY_3: return 10; case KEY_7: return 11; case KEY_9: return 12; case KEY_SOFT1: case KEY_SOFT2: case KEY_0: case KEY_ASTERISK: case KEY_POUND: 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; }}#define NUM_FONTS 36 XFontStruct *fonts[NUM_FONTS];XFontStruct *findFontStruct(Font font){ int i;#ifdef INCLUDE_I18N if (lcWin) { return lcWin->getFontStruct(font); }#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -