void* Java_java_awt_Toolkit_fntInitFont( JNIEnv* envP, jclass clazz, jstring jSpec, jint style, jint size ) { GR_FONT_ID fontid; #if 0 const char *spec,*newspec; if ( jSpec == NULL ) { spec = NULL; } else { spec = (*envP)->GetStringUTFChars(envP , jSpec, NULL); } if ( spec == NULL ) { fontid = GrCreateFont(GR_FONT_SYSTEM_VAR, 0, NULL); } else { newspec = getFontName(spec,style); fontid = GrCreateFont((char *)newspec, size, NULL); if ( fontid == NULL ) { fontid = GrCreateFont((char *)spec, size, NULL); } } #endif fontid = GrCreateFont(GR_FONT_SYSTEM_VAR, 0, NULL); return (void*)fontid; }
static void GrCreateFontWrapper(void *r) { nxCreateFontReq *req = r; GR_FONT_ID fontid; if(req->lf_used) fontid = GrCreateFont(NULL, 0, &req->lf); else fontid = GrCreateFont(req->lf.lfFaceName, req->height, NULL); GsWriteType(current_fd,GrNumCreateFont); GsWrite(current_fd, &fontid, sizeof(fontid)); }
/** * run action of init view */ static void run(void) { char initMessage[40] = "Initializing"; if (isTimerElapsed(initTimer)) { /* set new timer */ initTimer = setUpTimer(RUN_INTERVAL); if (intervals < 25) { intervals++; } for (int i = 1; i < intervals; i++) { strcat(initMessage,"."); } DisplayState *displaystate = getDisplayState(); /* Select fonts */ displaystate->font = GrCreateFont((unsigned char *) FONTNAME, 14, NULL); GrSetGCFont(displaystate->gContextID, displaystate->font); GrText(displaystate->gWinID, displaystate->gContextID, 120, 30, initMessage, -1, GR_TFASCII | GR_TFTOP); GrDestroyFont(displaystate->font); } /* Did someone turn the coffeemaker off? */ if (getSwitchState(POWER_SWITCH) == switch_off) { #ifdef DEBUG printf("Detected power switch to off\n"); #endif switchOff(); } }
void drawText(GR_WINDOW_ID id, char **text, int count) { int tw, th, tb; int xpos, ypos; int i; GR_GC_ID gc = GrNewGC(); GR_FONT_ID font = GrCreateFont(GR_FONT_GUI_VAR, 12, 0); GR_WINDOW_INFO info; GrGetWindowInfo(id, &info); GrSetGCFont(gc, font); GrSetGCForeground(gc, FGCOLOR); GrSetGCBackground(gc, BGCOLOR); /* Get the first line of text from the array, and check the size */ GrGetGCTextSize(gc, text[0], -1, GR_TFTOP, &tw, &th, &tb); ypos = (info.height - ((count * th)+ 3)) / 2; /* Draw each line of the instructions */ for(i = 0; i < count; i++) { GrGetGCTextSize(gc, text[i], -1, GR_TFTOP, &tw, &th, &tb); xpos = (info.width - tw) / 2; GrText(id, gc, xpos, ypos, text[i], -1, GR_TFTOP); ypos += th + 3; } GrDestroyGC(gc); GrDestroyFont(font); }
/** * activate action of init view */ static void activate(void) { /* turn of power led */ updateLed(POWER_LED,led_on); /* reset init wait intervals */ intervals = 0; /* start Timer */ initTimer = setUpTimer(RUN_INTERVAL); DisplayState *displaystate = getDisplayState(); displaystate->gContextID = GrNewGC(); /* Back- Foreground color related stuff */ GrSetGCForeground(displaystate->gContextID, YELLOW); GrSetGCUseBackground(displaystate->gContextID, GR_FALSE); /* Select fonts */ displaystate->font = GrCreateFont((unsigned char *) FONTNAME, 14, NULL); GrSetGCFont(displaystate->gContextID, displaystate->font); GrText(displaystate->gWinID, displaystate->gContextID, 120, 30, "Initializing", -1, GR_TFASCII | GR_TFTOP); GrDestroyFont(displaystate->font); }
static wxNativeFont wxLoadQueryFont(int pointSize, int family, int style, int weight, bool WXUNUSED(underlined), const wxString& facename, const wxString& xregistry, const wxString& xencoding, wxString* xFontName) { wxString xfamily; switch (family) { case wxDECORATIVE: xfamily = wxT("lucida"); break; case wxROMAN: xfamily = wxT("times"); break; case wxMODERN: xfamily = wxT("courier"); break; case wxSWISS: xfamily = wxT("helvetica"); break; case wxTELETYPE: xfamily = wxT("lucidatypewriter"); break; case wxSCRIPT: xfamily = wxT("utopia"); break; default: xfamily = wxT("*"); } #if wxUSE_NANOX int xweight; switch (weight) { case wxBOLD: { xweight = MWLF_WEIGHT_BOLD; break; } case wxLIGHT: { xweight = MWLF_WEIGHT_LIGHT; break; } case wxNORMAL: { xweight = MWLF_WEIGHT_NORMAL; break; } default: { xweight = MWLF_WEIGHT_DEFAULT; break; } } GR_SCREEN_INFO screenInfo; GrGetScreenInfo(& screenInfo); int yPixelsPerCM = screenInfo.ydpcm; // A point is 1/72 of an inch. // An inch is 2.541 cm. // So pixelHeight = (pointSize / 72) (inches) * 2.541 (for cm) * yPixelsPerCM (for pixels) // In fact pointSize is 10 * the normal point size so // divide by 10. int pixelHeight = (int) ( (((float)pointSize) / 720.0) * 2.541 * (float) yPixelsPerCM) ; // An alternative: assume that the screen is 72 dpi. //int pixelHeight = (int) (((float)pointSize / 720.0) * 72.0) ; //int pixelHeight = (int) ((float)pointSize / 10.0) ; GR_LOGFONT logFont; logFont.lfHeight = pixelHeight; logFont.lfWidth = 0; logFont.lfEscapement = 0; logFont.lfOrientation = 0; logFont.lfWeight = xweight; logFont.lfItalic = (style == wxNORMAL ? 0 : 1) ; logFont.lfUnderline = 0; logFont.lfStrikeOut = 0; logFont.lfCharSet = MWLF_CHARSET_DEFAULT; // TODO: select appropriate one logFont.lfOutPrecision = MWLF_TYPE_DEFAULT; logFont.lfClipPrecision = 0; // Not used logFont.lfRoman = (family == wxROMAN ? 1 : 0) ; logFont.lfSerif = (family == wxSWISS ? 0 : 1) ; logFont.lfSansSerif = !logFont.lfSerif ; logFont.lfModern = (family == wxMODERN ? 1 : 0) ; logFont.lfProportional = (family == wxTELETYPE ? 0 : 1) ; logFont.lfOblique = 0; logFont.lfSmallCaps = 0; logFont.lfPitch = 0; // 0 = default strcpy(logFont.lfFaceName, facename.c_str()); XFontStruct* fontInfo = (XFontStruct*) malloc(sizeof(XFontStruct)); fontInfo->fid = GrCreateFont((GR_CHAR*) facename.c_str(), pixelHeight, & logFont); GrGetFontInfo(fontInfo->fid, & fontInfo->info); return (wxNativeFont) fontInfo; #else wxString fontSpec; if (!facename.empty()) { fontSpec.Printf(wxT("-*-%s-*-*-normal-*-*-*-*-*-*-*-*-*"), facename.c_str()); if ( wxTestFontSpec(fontSpec) ) { xfamily = facename; } //else: no such family, use default one instead } wxString xstyle; switch (style) { case wxSLANT: fontSpec.Printf(wxT("-*-%s-*-o-*-*-*-*-*-*-*-*-*-*"), xfamily.c_str()); if ( wxTestFontSpec(fontSpec) ) { xstyle = wxT("o"); break; } // fall through - try wxITALIC now case wxITALIC: fontSpec.Printf(wxT("-*-%s-*-i-*-*-*-*-*-*-*-*-*-*"), xfamily.c_str()); if ( wxTestFontSpec(fontSpec) ) { xstyle = wxT("i"); } else if ( style == wxITALIC ) // and not wxSLANT { // try wxSLANT fontSpec.Printf(wxT("-*-%s-*-o-*-*-*-*-*-*-*-*-*-*"), xfamily.c_str()); if ( wxTestFontSpec(fontSpec) ) { xstyle = wxT("o"); } else { // no italic, no slant - leave default xstyle = wxT("*"); } } break; default: wxFAIL_MSG(wxT("unknown font style")); // fall back to normal case wxNORMAL: xstyle = wxT("r"); break; } wxString xweight; switch (weight) { case wxBOLD: { fontSpec.Printf(wxT("-*-%s-bold-*-*-*-*-*-*-*-*-*-*-*"), xfamily.c_str()); if ( wxTestFontSpec(fontSpec) ) { xweight = wxT("bold"); break; } fontSpec.Printf(wxT("-*-%s-heavy-*-*-*-*-*-*-*-*-*-*-*"), xfamily.c_str()); if ( wxTestFontSpec(fontSpec) ) { xweight = wxT("heavy"); break; } fontSpec.Printf(wxT("-*-%s-extrabold-*-*-*-*-*-*-*-*-*-*-*"), xfamily.c_str()); if ( wxTestFontSpec(fontSpec) ) { xweight = wxT("extrabold"); break; } fontSpec.Printf(wxT("-*-%s-demibold-*-*-*-*-*-*-*-*-*-*-*"), xfamily.c_str()); if ( wxTestFontSpec(fontSpec) ) { xweight = wxT("demibold"); break; } fontSpec.Printf(wxT("-*-%s-black-*-*-*-*-*-*-*-*-*-*-*"), xfamily.c_str()); if ( wxTestFontSpec(fontSpec) ) { xweight = wxT("black"); break; } fontSpec.Printf(wxT("-*-%s-ultrablack-*-*-*-*-*-*-*-*-*-*-*"), xfamily.c_str()); if ( wxTestFontSpec(fontSpec) ) { xweight = wxT("ultrablack"); break; } } break; case wxLIGHT: { fontSpec.Printf(wxT("-*-%s-light-*-*-*-*-*-*-*-*-*-*-*"), xfamily.c_str()); if ( wxTestFontSpec(fontSpec) ) { xweight = wxT("light"); break; } fontSpec.Printf(wxT("-*-%s-thin-*-*-*-*-*-*-*-*-*-*-*"), xfamily.c_str()); if ( wxTestFontSpec(fontSpec) ) { xweight = wxT("thin"); break; } } break; case wxNORMAL: { fontSpec.Printf(wxT("-*-%s-medium-*-*-*-*-*-*-*-*-*-*-*"), xfamily.c_str()); if ( wxTestFontSpec(fontSpec) ) { xweight = wxT("medium"); break; } fontSpec.Printf(wxT("-*-%s-normal-*-*-*-*-*-*-*-*-*-*-*"), xfamily.c_str()); if ( wxTestFontSpec(fontSpec) ) { xweight = wxT("normal"); break; } fontSpec.Printf(wxT("-*-%s-regular-*-*-*-*-*-*-*-*-*-*-*"), xfamily.c_str()); if ( wxTestFontSpec(fontSpec) ) { xweight = wxT("regular"); break; } xweight = wxT("*"); } break; default: xweight = wxT("*"); break; } // if pointSize is -1, don't specify any wxString sizeSpec; if ( pointSize == -1 ) { sizeSpec = wxT('*'); } else { sizeSpec.Printf(wxT("%d"), pointSize); } // construct the X font spec from our data fontSpec.Printf(wxT("-*-%s-%s-%s-normal-*-*-%s-*-*-*-*-%s-%s"), xfamily.c_str(), xweight.c_str(), xstyle.c_str(), sizeSpec.c_str(), xregistry.c_str(), xencoding.c_str()); if( xFontName ) *xFontName = fontSpec; return wxLoadFont(fontSpec); #endif // wxUSE_NANOX }
int main(int argc, char ** argv) { GR_BITMAP bitmap1fg[7]; /* mouse cursor */ GR_BITMAP bitmap1bg[7]; if (GrOpen() < 0) { fprintf(stderr, "cannot open graphics\n"); exit(1); } GrGetScreenInfo(&si); w1 = GrNewWindow(GR_ROOT_WINDOW_ID, 50, 30, si.cols - 120, si.rows - 60, 1, WHITE, LTBLUE); GrSelectEvents(w1, GR_EVENT_MASK_BUTTON_DOWN | GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_FOCUS_IN | GR_EVENT_MASK_FOCUS_OUT | GR_EVENT_MASK_CLOSE_REQ); GrMapWindow(w1); gc1 = GrNewGC(); gc3 = GrNewGC(); GrSetGCForeground(gc1, GRAY); GrSetGCBackground(gc1, LTBLUE); GrSetGCFont(gc1, GrCreateFont(GR_FONT_SYSTEM_FIXED, 0, NULL)); /*GrSetGCFont(gc1, GrCreateFont(GR_FONT_OEM_FIXED, 0, NULL));*/ GrSetGCForeground(gc3, WHITE); GrSetGCBackground(gc3, BLACK); bitmap1fg[0] = MASK(_,_,X,_,X,_,_); bitmap1fg[1] = MASK(_,_,_,X,_,_,_); bitmap1fg[2] = MASK(_,_,_,X,_,_,_); bitmap1fg[3] = MASK(_,_,_,X,_,_,_); bitmap1fg[4] = MASK(_,_,_,X,_,_,_); bitmap1fg[5] = MASK(_,_,_,X,_,_,_); bitmap1fg[6] = MASK(_,_,X,_,X,_,_); bitmap1bg[0] = MASK(_,X,X,X,X,X,_); bitmap1bg[1] = MASK(_,_,X,X,X,_,_); bitmap1bg[2] = MASK(_,_,X,X,X,_,_); bitmap1bg[3] = MASK(_,_,X,X,X,_,_); bitmap1bg[4] = MASK(_,_,X,X,X,_,_); bitmap1bg[5] = MASK(_,_,X,X,X,_,_); bitmap1bg[6] = MASK(_,X,X,X,X,X,_); GrSetCursor(w1, 7, 7, 3, 3, WHITE, BLACK, bitmap1fg, bitmap1bg); /*GrFillRect(GR_ROOT_WINDOW_ID, gc1, 0, 0, si.cols, si.rows);*/ GrSetGCForeground(gc1, BLACK); GrSetGCBackground(gc1, WHITE); text_init(); if (term_init() < 0) { GrClose(); exit(1); } /* we want tfd events also*/ GrRegisterInput(tfd); #if 1 GrMainLoop(HandleEvent); #else while(1) { GR_EVENT ev; GrGetNextEvent(&ev); HandleEvent(&ev); } #endif /* notreached*/ return 0; }
/* Set the contents of the state structure to default parameters. */ static void setup_default_state(nbstate *state) { int i; GR_FONT_ID fid; GR_FONT_INFO fi; state->state = STATE_TITLESCREEN; state->gamedir = DEFAULT_GAME_DIR; state->gamefile = DEFAULT_GAME_FILE; state->titlebackground = NULL; state->titlebackgroundtiled = DEFAULT_BACKGROUND_TILED; state->titlesplash = NULL; state->gamewonsplash = NULL; state->gamelostsplash = NULL; state->spritelist = NULL; state->background = NULL; state->backgroundtiled = 1; state->normalpoints = DEFAULT_NORMALPOINTS; state->smallbonuspoints = DEFAULT_SMALLBONUSPOINTS; state->mediumbonuspoints = DEFAULT_MEDIUMBONUSPOINTS; state->largebonuspoints = DEFAULT_LARGEBONUSPOINTS; state->hugebonuspoints = DEFAULT_HUGEBONUSPOINTS; state->poweruppoints = DEFAULT_POWERUPPOINTS; state->powerdownpoints = DEFAULT_POWERDOWNPOINTS; state->startballs = DEFAULT_STARTBALLS; state->newlevelballs = DEFAULT_NEWLEVELBALLS; state->brickwidth = DEFAULT_BRICK_WIDTH; state->brickheight = DEFAULT_BRICK_HEIGHT; state->bricks = NULL; state->brickalpha = 0; state->width = DEFAULT_WIDTH; state->height = DEFAULT_HEIGHT; state->batheight = DEFAULT_BAT_HEIGHT; state->batwidths[NORMALBAT] = DEFAULT_NORMALBAT_WIDTH; state->batwidths[SMALLBAT] = DEFAULT_SMALLBAT_WIDTH; state->batwidths[LARGEBAT] = DEFAULT_LARGEBAT_WIDTH; for(i = 0; i < NUMBATS; i++) state->bats[i] = NULL; state->bat = NORMALBAT; state->batx = 0; state->batv = DEFAULT_BAT_VELOCITY; state->powerv = DEFAULT_POWER_VELOCITY; state->animateperiod = DEFAULT_ANIMATE_PERIOD; for(i = 0; i < NUMPOWERS; i++) state->powersprites[i] = NULL; state->splash = NULL; state->poweruptime = DEFAULT_POWERUP_TIME; state->powerdowntime = DEFAULT_POWERDOWN_TIME; for(i = 0; i < NUMCHEATS; i++) state->cheats[i] = NULL; memset(state->cheatstate, 0, MAXCHEATLEN + 1); state->flags.sf = 0; state->flags.nb = 0; state->flags.npd = 0; state->flags.nputo = 0; state->flags.paused = 0; state->flags.left = 0; state->flags.right = 0; state->levels = NULL; state->level = 0; state->numlevels = 0; state->wid = 0; state->winx = 0; state->canvas = 0; state->canvaswidth = 0; state->canvasheight = 0; state->grid = NULL; state->numbricks = 0; state->powers = NULL; state->scores.s = 0; state->scores.hi = 0; state->scores.fhi = 0; state->scores.p = 0; state->gc = GrNewGC(); fid = GrCreateFont(SCORE_FONT, 0, NULL); GrGetFontInfo(fid, &fi); state->scores.h = (2 * SCORE_BORDER) + fi.height; GrSetGCFont(state->gc, fid); state->ball.x = 0; state->ball.y = 0; state->ball.d = 0; state->ball.v = DEFAULT_NORMAL_BALL_VELOCITY; state->ball.lx = 0; state->ball.ly = 0; state->ball.parked = 1; state->ball.s = NULL; state->ball.sv = DEFAULT_SLOW_BALL_VELOCITY; state->ball.nv = DEFAULT_NORMAL_BALL_VELOCITY; state->ball.fv = DEFAULT_FAST_BALL_VELOCITY; state->numballs = 0; gettimeofday(&state->lastanim, NULL); state->powertimes.widebat = 0; state->powertimes.slowmotion = 0; state->powertimes.stickybat = 0; state->powertimes.powerball = 0; state->powertimes.narrowbat = 0; state->powertimes.fastmotion = 0; state->faderate = DEFAULT_FADERATE; state->fadelevel = 0; state->nextstate = STATE_TITLESCREEN; }
int mvpw_load_font(char *file) { return GrCreateFont((unsigned char*)file, 0, NULL); }
void ecos_nx_init(CYG_ADDRWORD data) { GR_SCREEN_INFO si; /* window information */ GR_FONT_INFO fi; /* font information */ GR_WINDOW_ID mainwid; /* main window id */ GR_WM_PROPERTIES props; GR_GC_ID gct = 0; #if 0 NWIDGET *w; NBUTTON *b; NTEXTFIELD *t; #endif cyg_thread_delay(50); INIT_PER_THREAD_DATA(); test_file_io(); if(GrOpen() < 0) { fprintf(stderr, "Couldn't connect to Nano-X server\n"); exit(1); } #if (defined CYGPKG_HAL_ARM_SA11X0_IPAQ) && (!defined CYGBLD_MICROWINDOWS_VNC_DRIVERS) GrSetPortraitMode(MWPORTRAIT_RIGHT); #endif GrGetScreenInfo(&si); GrGetFontInfo(0, &fi); #if 1 mainwid = GrNewWindow(GR_ROOT_WINDOW_ID, 0, 0, si.cols, si.rows, 0, RED, WHITE); props.flags = GR_WM_FLAGS_PROPS; props.props = GR_WM_PROPS_BORDER; GrSetWMProperties(mainwid, &props); GrMapWindow(mainwid); GrFlush(); cyg_thread_delay(50); gct = GrNewGC(); GrSetGCForeground(gct, WHITE); #ifdef CYGPKG_IO_FILEIO { struct stat stat_data; if (0 == stat("/redhat.logo", &stat_data)) { GrDrawImageFromFile(mainwid, gct, 0, 0, si.cols, si.rows, "/redhat.logo", 0); } } #endif #if (defined CYGPKG_HAL_ARM) && (!defined CYGBLD_MICROWINDOWS_VNC_DRIVERS) // Touch sensitive screen calibration, only relevant on some // platforms. GrSetGCFont(gct, GrCreateFont(GR_FONT_GUI_VAR, 0, NULL)); GrText(mainwid, gct, 80, 350, "Tap all 4 corners", 17, GR_TFTOP); GrFlush(); printf("Tap all four corners\n"); cyg_thread_delay(10*100); #endif #else n_init_button_class(); n_init_textfield_class(); w = NEW_NOBJECT(widget); n_widget_init(w, 0); n_widget_resize(w, si.cols - 10, si.rows - 30); n_widget_background(w, "/redhat.logo"); n_widget_show(w); b = NEW_NOBJECT(button); n_button_init(b, w, "Close"); n_button_onclick(b, do_close); n_widget_resize(b, 40, 20); n_widget_move(b,180,260); n_widget_show(b); t = NEW_NOBJECT(textfield); n_textfield_init(t,w,"Tap all 4 corners"); n_widget_move(t,45,220); n_widget_resize(t,120,20); n_widget_show(t); t = NEW_NOBJECT(textfield); n_textfield_init(t,w,"Then press close"); n_widget_move(t,45,250); n_widget_resize(t,120,20); n_widget_show(t); while (!closed) { n_handle_event(); } n_widget_hide(w); n_object_cleanup(w); #endif GrClose(); }
int main(int argc, char **argv) { int t = 1; GR_EVENT event; /* current event */ while (t < argc) { if (!strcmp("-t", argv[t])) { bTextwin = GR_TRUE; ++t; continue; } } if (GrOpen() < 0) { fprintf(stderr, "cannot open graphics\n"); exit(1); } if (bTextwin) { /* create text output window for debugging*/ wt = GrNewWindow(GR_ROOT_WINDOW_ID, 50, 20, TEXTWIN_WIDTH, TEXTWIN_HEIGHT, 5, BLACK, GREEN); GrSelectEvents(wt, GR_EVENT_MASK_CLOSE_REQ | GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_EXPOSURE); GrMapWindow(wt); gct = GrNewGC(); GrSetGCForeground(gct, GREEN); GrGetGCTextSize(gct, "A",1, GR_TFASCII, &width, &height, &base); GrSetGCFont(gct, GrCreateFont(GR_FONT_SYSTEM_FIXED, 0, NULL)); gctb = GrNewGC(); GrSetGCForeground(gctb, BLACK); } /* create scribble input window*/ w = create_scribble(); while (1) { GrGetNextEvent(&event); switch (event.type) { case GR_EVENT_TYPE_BUTTON_DOWN: do_buttondown(&event.button); break; case GR_EVENT_TYPE_BUTTON_UP: do_buttonup(&event.button); break; case GR_EVENT_TYPE_MOUSE_POSITION: case GR_EVENT_TYPE_MOUSE_MOTION: do_motion(&event.mouse); break; case GR_EVENT_TYPE_FOCUS_IN: do_focusin(&event.general); break; case GR_EVENT_TYPE_KEY_DOWN: do_keystroke(&event.keystroke); break; case GR_EVENT_TYPE_EXPOSURE: do_exposure(&event.exposure); break; case GR_EVENT_TYPE_CLOSE_REQ: GrClose(); exit(0); } } }
int main(int argc, char **argv) { GR_WINDOW_ID window; GR_EVENT event; GR_GC_ID gc; GR_FONT_ID fontid; int x, y, rnd = 0; MWLOGFONT lf; char description[128]; srand(time(0)); GrOpen(); window = GrNewWindow(GR_ROOT_WINDOW_ID, 5, 5, MAXW, MAXH, 4, BLACK, BLUE); GrMapWindow(window); gc = GrNewGC(); GrSelectEvents(window,GR_EVENT_MASK_ALL); GrSetGCUseBackground(gc,GR_FALSE); GrSetGCBackground(gc, GR_RGB(0, 0, 0)); y = 30; x = 0; while(1) { GrCheckNextEvent(&event); if(event.type == GR_EVENT_TYPE_CLOSE_REQ) { GrClose(); exit(0); } sleep(1); MWLF_Clear(&lf); description[0] = '\0'; // lf.lfSerif = 1; if ( rnd & 1 ) { lf.lfWeight = MWLF_WEIGHT_BOLD; strcat(description,"Bold "); } if ( rnd & 2 ) { lf.lfItalic = 1; strcat(description,"Italics "); } if ( rnd & 4 ) { lf.lfOblique = 1; strcat(description,"Oblique "); } if ( rnd & 8 ) { lf.lfMonospace = 1; strcat(description,"°íÁ¤Æø Monospace "); } else { lf.lfProportional = 1; strcat(description,"Proportional "); } if ( argc > 1 ) strcpy(lf.lfFaceName,argv[1]); else strcpy(lf.lfFaceName,"fantasy"); fontid = GrCreateFont(0, 0, &lf); /* GrSetFontSize(fontid, 1+(int)(80.0 * rand() / (RAND_MAX+1.0))); */ GrSetFontSize(fontid,26); GrSetFontRotation(fontid, 330); /* 33 degrees*/ GrSetFontAttr(fontid, GR_TFKERNING | GR_TFANTIALIAS, 0); GrSetGCFont(gc, fontid); /*GrSetGCBackground(gc, rand() & 0xffffff);*/ GrSetGCForeground(gc, 0xffffff); /* x = (int) ((MAXW * 1.0) *rand()/(RAND_MAX+1.0)); y = (int) ((MAXH * 1.0) *rand()/(RAND_MAX+1.0)); */ GrText(window, gc,x,y, description, -1, GR_TFASCII); GrDestroyFont(fontid); rnd++; y += 30; if ( y > 460 ) y = 0; } GrClose(); }
int main(int ac, char **av) { GR_WINDOW_ID window; GR_GC_ID gc; GR_FONT_ID fontid; int x, y, fnum; GR_REGION_ID regionid; #if CLIP_POLYGON GR_POINT points[] = { {20, 20}, {300, 20}, {300, 300}, {20, 300} }; #else GR_RECT clip_rect = { 20, 20, 300, 300 }; #endif if (GrOpen() < 0) exit(1); window = GrNewWindowEx(GR_WM_PROPS_APPWINDOW, "t1demo loadable fonts (truetype, t1lib, pcf, mgl, hzk)", GR_ROOT_WINDOW_ID, 50, 50, WIDTH, HEIGHT, BLACK); GrSelectEvents(window, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_CLOSE_REQ); GrMapWindow(window); gc = GrNewGC(); GrSetGCUseBackground(gc, GR_FALSE); GrSetGCBackground(gc, BLACK); #if CLIP_POLYGON /* polygon clip region */ regionid = GrNewPolygonRegion(MWPOLY_EVENODD, 3, points); #else /* rectangle clip region */ regionid = GrNewRegion(); GrUnionRectWithRegion(regionid, &clip_rect); #endif GrSetGCRegion(gc, regionid); srand(time(0)); while (1) { GR_EVENT event; GrCheckNextEvent(&event); if (event.type == GR_EVENT_TYPE_CLOSE_REQ) { GrClose(); exit(0); } fontid = GrCreateFont(names[fnum=RAND(MAXFONTS)], 0, NULL); GrSetFontSize(fontid, RAND(80) + 1); GrSetFontRotation(fontid, 330); /* 33 degrees */ GrSetFontAttr(fontid, GR_TFKERNING | GR_TFANTIALIAS, 0); GrSetGCFont(gc, fontid); GrSetGCForeground(gc, rand() & 0xffffff); /*GrSetGCBackground(gc, rand() & 0xffffff); */ x = RAND(WIDTH); y = RAND(HEIGHT); #if HAVE_HZK_SUPPORT { #if HZKBIG5 /* hzk big5 unicode-16 test*/ static unsigned short buffer[] = { 0x9060, 0x898b, 0x79d1, 0x6280, 0x0061, 0x0041, 0 }; GrText(window, gc, x, y, buffer, 7, GR_TFUC16); /* hzk big5 dbcs test #1*/ x = RAND(WIDTH); y = RAND(HEIGHT); GrText(window, gc, x, y, "Microwindows,舧ㄏノい璣ゅ翴皚砰", -1, GR_TFASCII); /* hzk big5 dbcs test #2*/ x = RAND(WIDTH); y = RAND(HEIGHT); GrText(window, gc, x, y, "89:", -1, GR_TFASCII); #else #if 0 /* hzk test #1*/ static char buffer[] = { 0x6c, 0x49, 0x73, 0x8b, 0x79, 0xd1, 0x62, 0x80, 0x61, 0x00, 0x41, 0x00, 0x00, 0xa1, 0x00, 0xa6, 0x6c, 0x49, 0, 0 }; /* *static unsigned short buffer[] = { 0x496c, 0x8b73, 0xd179, 0x8062, 0x0061, 0x0041, 0xa100, 0xa600, 0x496c, 0 };***/ GrText(window, gc, x, y, buffer, 9, GR_TFUC16); #endif /* HZK Metrix font test, includes Chinese and English */ x = RAND(WIDTH); y = RAND(HEIGHT); GrText(window, gc, x, y, "Microwindows,欢迎使用中英文点阵字体", -1, GR_TFASCII); #endif /* HZKBIG5*/ } #elif HAVE_BIG5_SUPPORT /* encoding BIG5 test 61 B1 64 B1 64 61 */ GrText(window, gc, x, y, "\151\261\144\261\144\151", 6, MWTF_DBCS_BIG5); #elif HAVE_GB2312_SUPPORT /* encoding GB2312 test BD A1 BD A1 */ GrText(window, gc, x, y, "\275\241\275\241", 4, MWTF_DBCS_GB); #elif HAVE_EUCJP_SUPPORT /* encoding EUC_JP test A2 A1 */ GrText(window, gc, x, y, "\242\241", 2, MWTF_DBCS_EUCJP); #elif HAVE_JISX0213_SUPPORT /* encoding JISX0213 test A2 A1 */ GrText(window, gc, x, y, "\242\241", 2, MWTF_DBCS_JIS); #elif HAVE_KSC5601_SUPPORT /* encoding KSC5601 test B0 B0 */ GrText(window, gc, x, y, "\273\273", 2, MWTF_DBCS_KSC); #elif HAVE_FREETYPE_SUPPORT /* ASCII test */ GrText(window, gc, x, y, "Microwindows", -1, GR_TFASCII); #elif HAVE_PCF_SUPPORT /* note: large PCF fonts require XCHAR2B, this is not figured out yet for these fonts. FIXME */ if (fnum == 3) { /* japanese jiskan24*/ unsigned short text[] = { 0x213a, 0x213b, 0x2170, 0x2276, 0x2339 }; GrText(window, gc, x,y, text, 5, GR_TFUC16); } else if (fnum == 4) { /* chinese gb24st*/ unsigned short text[] = /* FIXME: why doesn't first row index correctly?*/ /*{ 0x7765, 0x7766, 0x7767, 0x777a, 0x777e };*/ { 0x2129, 0x212a, 0x212b, 0x212c, 0x212d }; GrText(window, gc, x,y, text, 5, GR_TFUC16); } else GrText(window, gc, x,y, "Microwindows", -1, GR_TFASCII); #elif HAVE_FNT_SUPPORT /* UC16 test */ if (fnum == 2 || fnum == 3) { /* japanese jiskan24, jiskan16-2000-1*/ unsigned short text[] = { 0x213a, 0x213b, 0x2170, 0x2276, 0x2339 }; GrText(window, gc, x,y, text, 5, GR_TFUC16); } else if (fnum == 4) { /* chinese gbk16-xke*/ unsigned short text[] = { 0x8144, 0x8147, 0x8148, 0xfe4e, 0xfe4f }; GrText(window, gc, x,y, text, 5, GR_TFUC16); } else GrText(window, gc, x,y, "Microwindows", -1, GR_TFASCII); #else /* ASCII test */ GrText(window, gc, x, y, "Microwindows", -1, GR_TFASCII); #endif GrFlush(); GrDestroyFont(fontid); } GrDestroyRegion(regionid); GrClose(); return 0; }
int main() { GR_WINDOW_ID window; GR_EVENT event; GR_GC_ID gc; GR_FONT_ID fontid; int i, x, y; GR_REGION_ID regionid = 0; #if CLIP_POLYGON GR_POINT points[]={ {100, 100}, {300, 100}, {300, 300}, {100, 300}}; #else GR_RECT clip_rect={100,100,300,300}; #endif srand(time(0)); GrOpen(); window = GrNewWindow(GR_ROOT_WINDOW_ID, 50,50, MAXW,MAXH, 4, BLACK,BLUE); GrMapWindow(window); gc = GrNewGC(); #if CLIP_POLYGON /* polygon clip region*/ regionid = GrNewPolygonRegion(MWPOLY_EVENODD, 3, points); #else /* rectangle clip region*/ regionid = GrNewRegion(); GrUnionRectWithRegion(regionid, &clip_rect); #endif GrSetGCRegion(gc, regionid); GrSelectEvents(window,GR_EVENT_MASK_ALL); GrSetGCUseBackground(gc,GR_FALSE); GrSetGCBackground(gc, GR_RGB(0, 0, 0)); while(1) { GrCheckNextEvent(&event); i = (int)((float)MAXFONTS * rand() / (RAND_MAX + 1.0)); fontid = GrCreateFont(names[i], 20, NULL); GrSetFontSize(fontid, 1+(int)(80.0 * rand() / (RAND_MAX+1.0))); GrSetFontRotation(fontid, 330); /* 33 degrees*/ GrSetFontAttr(fontid, GR_TFKERNING | GR_TFANTIALIAS, 0); GrSetGCFont(gc, fontid); /*GrSetGCBackground(gc, rand() & 0xffffff);*/ GrSetGCForeground(gc, rand() & 0xffffff); x = (int) ((MAXW * 1.0) *rand()/(RAND_MAX+1.0)); y = (int) ((MAXH * 1.0) *rand()/(RAND_MAX+1.0)); #if HAVE_HZK_SUPPORT { /* to test Unicode 16 chinese characters display ,use HZK font Bitmap font (Metrix font). */ #ifndef BIG5 char buffer[256]; buffer[0]=0x6c; buffer[1]=0x49; buffer[2]=0x73; buffer[3]=0x8b; buffer[4]=0x79; buffer[5]=0xd1; buffer[6]=0x62; buffer[7]=0x80; buffer[8]=0x61; buffer[9]=0x00; buffer[10]=0x41; buffer[11]=0x00; buffer[12]=0x00; buffer[13]=0xa1; buffer[14]=0x00; buffer[15]=0xa6; buffer[16]=0x6c; buffer[17]=0x49; buffer[18]=0x0; buffer[19]=0x0; GrText(window, gc,x,y+20, buffer,17, GR_TFUC16); x=0;y=16; GrText(window, gc,x,y+20, buffer,17, GR_TFUC16); #else unsigned short buffer[7]; buffer[0]=0x9060; buffer[1]=0x898b; buffer[2]=0x79d1; buffer[3]=0x6280; buffer[4]=0x0061; buffer[5]=0x0041; buffer[6]=0x0; GrText(window, gc,x,y+20, buffer,7, GR_TFUC16); x=0;y=16; GrText(window, gc,x,y+20, buffer,7, GR_TFUC16); #endif } #ifndef BIG5 x=0;y=16; /* HZK Metrix font test, includes Chinese and English*/ GrText(window, gc,x,y, "Microwindows,欢迎使用中英文点阵字体", -1, GR_TFASCII); #else GrText(window, gc,x,y, "Microwindows,舧ㄏノい璣ゅ翴皚砰", -1, GR_TFASCII); x=0;y=16*3+4; GrText(window, gc,x,y, "89:", -1, GR_TFASCII); #endif GrFlush(); #else /* !HZK_FONT_SUPPORT*/ #if HAVE_BIG5_SUPPORT /* ENCODING_BIG5 test*/ GrText(window, gc,x,y, "眃眃", -1, GR_TFASCII); #else #if HAVE_GB2312_SUPPORT /* ENCODING_GB2312 test*/ GrText(window, gc,x,y, "\275\241\275\241", -1, GR_TFASCII); #else /* ASCII test*/ GrText(window, gc,x,y, "Microwindows", -1, GR_TFASCII); #endif #endif #endif /* HZK_FONT_SUPPORT*/ GrDestroyFont(fontid); if(event.type == GR_EVENT_TYPE_CLOSE_REQ) { GrClose(); exit(0); } } GrDestroyRegion(regionid); GrClose(); }
void init_game(nstate *state) { GR_WM_PROPERTIES props; GR_COORD x = MAIN_WINDOW_X_POSITION; if(GrOpen() < 0) { fprintf(stderr, "Couldn't connect to Nano-X server\n"); exit(1); } state->fontid = GrCreateFont(NULL, 3, NULL); state->main_window = GrNewWindow(GR_ROOT_WINDOW_ID, x, MAIN_WINDOW_Y_POSITION, MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT, 0, MAIN_WINDOW_BACKGROUND_COLOUR, 0); /* set title */ props.flags = GR_WM_FLAGS_TITLE | GR_WM_FLAGS_PROPS; props.props = GR_WM_PROPS_BORDER | GR_WM_PROPS_CAPTION | GR_WM_PROPS_CLOSEBOX; props.title = "Nano-Tetris"; GrSetWMProperties(state->main_window, &props); GrSelectEvents(state->main_window, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_CLOSE_REQ | GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_TIMEOUT); state->score_window = GrNewWindow(state->main_window, SCORE_WINDOW_X_POSITION, SCORE_WINDOW_Y_POSITION, SCORE_WINDOW_WIDTH, SCORE_WINDOW_HEIGHT, 0, SCORE_WINDOW_BACKGROUND_COLOUR, 0); GrSelectEvents(state->score_window, GR_EVENT_MASK_EXPOSURE); GrMapWindow(state->score_window); state->scoregcf = GrNewGC(); GrSetGCFont(state->scoregcf, state->fontid); GrSetGCForeground(state->scoregcf, SCORE_WINDOW_FOREGROUND_COLOUR); GrSetGCBackground(state->scoregcf, SCORE_WINDOW_BACKGROUND_COLOUR); state->scoregcb = GrNewGC(); GrSetGCFont(state->scoregcb, state->fontid); GrSetGCForeground(state->scoregcb, SCORE_WINDOW_BACKGROUND_COLOUR); state->next_shape_window = GrNewWindow(state->main_window, NEXT_SHAPE_WINDOW_X_POSITION, NEXT_SHAPE_WINDOW_Y_POSITION, NEXT_SHAPE_WINDOW_WIDTH, NEXT_SHAPE_WINDOW_HEIGHT, 0, NEXT_SHAPE_WINDOW_BACKGROUND_COLOUR, 0); GrSelectEvents(state->next_shape_window, GR_EVENT_MASK_EXPOSURE); GrMapWindow(state->next_shape_window); state->nextshapegcf = GrNewGC(); state->nextshapegcb = GrNewGC(); GrSetGCForeground(state->nextshapegcb, NEXT_SHAPE_WINDOW_BACKGROUND_COLOUR); state->new_game_button = GrNewWindow(state->main_window, NEW_GAME_BUTTON_X_POSITION, NEW_GAME_BUTTON_Y_POSITION, NEW_GAME_BUTTON_WIDTH, NEW_GAME_BUTTON_HEIGHT, 0, BUTTON_BACKGROUND_COLOUR, 0); GrSelectEvents(state->new_game_button, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_BUTTON_DOWN); GrMapWindow(state->new_game_button); state->buttongcf = GrNewGC(); GrSetGCFont(state->buttongcf, state->fontid); GrSetGCForeground(state->buttongcf, BUTTON_FOREGROUND_COLOUR); GrSetGCBackground(state->buttongcf, BUTTON_BACKGROUND_COLOUR); state->buttongcb = GrNewGC(); GrSetGCFont(state->buttongcb, state->fontid); GrSetGCForeground(state->buttongcb, BUTTON_BACKGROUND_COLOUR); state->pause_continue_button = GrNewWindow(state->main_window, PAUSE_CONTINUE_BUTTON_X_POSITION, PAUSE_CONTINUE_BUTTON_Y_POSITION, PAUSE_CONTINUE_BUTTON_WIDTH, PAUSE_CONTINUE_BUTTON_HEIGHT, 0, BUTTON_BACKGROUND_COLOUR, 0); GrSelectEvents(state->pause_continue_button, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_BUTTON_DOWN); state->anticlockwise_button = GrNewWindow(state->main_window, ANTICLOCKWISE_BUTTON_X_POSITION, ANTICLOCKWISE_BUTTON_Y_POSITION, ANTICLOCKWISE_BUTTON_WIDTH, ANTICLOCKWISE_BUTTON_HEIGHT, 0, BUTTON_BACKGROUND_COLOUR, 0); GrSelectEvents(state->anticlockwise_button, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_BUTTON_DOWN); state->clockwise_button = GrNewWindow(state->main_window, CLOCKWISE_BUTTON_X_POSITION, CLOCKWISE_BUTTON_Y_POSITION, CLOCKWISE_BUTTON_WIDTH, CLOCKWISE_BUTTON_HEIGHT, 0, BUTTON_BACKGROUND_COLOUR, 0); GrSelectEvents(state->clockwise_button, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_BUTTON_DOWN); state->left_button = GrNewWindow(state->main_window, LEFT_BUTTON_X_POSITION, LEFT_BUTTON_Y_POSITION, LEFT_BUTTON_WIDTH, LEFT_BUTTON_HEIGHT, 0, BUTTON_BACKGROUND_COLOUR, 0); GrSelectEvents(state->left_button, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_BUTTON_DOWN); state->right_button = GrNewWindow(state->main_window, RIGHT_BUTTON_X_POSITION, RIGHT_BUTTON_Y_POSITION, RIGHT_BUTTON_WIDTH, RIGHT_BUTTON_HEIGHT, 0, BUTTON_BACKGROUND_COLOUR, 0); GrSelectEvents(state->right_button, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_BUTTON_DOWN); state->drop_button = GrNewWindow(state->main_window, DROP_BUTTON_X_POSITION, DROP_BUTTON_Y_POSITION, DROP_BUTTON_WIDTH, DROP_BUTTON_HEIGHT, 0, BUTTON_BACKGROUND_COLOUR, 0); GrSelectEvents(state->drop_button, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_BUTTON_DOWN); state->well_window = GrNewWindow(state->main_window, WELL_WINDOW_X_POSITION, WELL_WINDOW_Y_POSITION, WELL_WINDOW_WIDTH, WELL_WINDOW_HEIGHT, 0, WELL_WINDOW_BACKGROUND_COLOUR, 0); GrSelectEvents(state->well_window, GR_EVENT_MASK_EXPOSURE); GrMapWindow(state->well_window); state->wellgc = GrNewGC(); GrMapWindow(state->main_window); state->state = STATE_STOPPED; state->score = 0; read_hiscore(state); state->level = 0; state->running_buttons_mapped = 0; srandom(time(0)); choose_new_shape(state); new_game(state); }
void nxPaintNCArea(GR_DRAW_ID id, int w, int h, GR_CHAR *title, GR_BOOL active, GR_WM_PROPS props) { int x = 0; int y = 0; GR_GC_ID gc = GrNewGC(); GR_FONT_ID fontid; GR_RECT r; if (props & GR_WM_PROPS_APPFRAME) { /* draw 2-line 3d border around window*/ nxDraw3dOutset(id, x, y, w, h); x += 2; y += 2; w -= 4; h -= 4; /* draw 1-line inset inside border*/ GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_APPWINDOW)); GrRect(id, gc, x, y, w, h); x += 1; y += 1; w -= 2; h -= 2; } else if (props & GR_WM_PROPS_BORDER) { /* draw 1-line black border around window*/ GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_WINDOWFRAME)); GrRect(id, gc, x, y, w, h); x += 1; y += 1; w -= 2; h -= 2; } if (!(props & GR_WM_PROPS_CAPTION)) goto out; /* fill caption*/ GrSetGCForeground(gc, GrGetSysColor(active? GR_COLOR_ACTIVECAPTION: GR_COLOR_INACTIVECAPTION)); GrFillRect(id, gc, x, y, w, CYCAPTION); /* draw caption text*/ if (title) { GrSetGCForeground(gc, GrGetSysColor(active? GR_COLOR_ACTIVECAPTIONTEXT: GR_COLOR_INACTIVECAPTIONTEXT)); GrSetGCUseBackground(gc, GR_FALSE); fontid = GrCreateFont(GR_FONT_GUI_VAR, 0, NULL); GrSetGCFont(gc, fontid); GrText(id, gc, x+4, y-1, title, -1, GR_TFASCII|GR_TFTOP); GrDestroyFont(fontid); } y += CYCAPTION; /* draw one line under caption*/ if (props & GR_WM_PROPS_APPFRAME) { GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_APPWINDOW)); GrLine(id, gc, x, y, x+w-1, y); } if (props & GR_WM_PROPS_CLOSEBOX) { /* draw close box*/ r.x = x + w - CXCLOSEBOX - 2; r.y = y - CYCAPTION + 2; r.width = CXCLOSEBOX; r.height = CYCLOSEBOX; nxDraw3dBox(id, r.x, r.y, r.width, r.height, GrGetSysColor(GR_COLOR_BTNHIGHLIGHT), GrGetSysColor(GR_COLOR_WINDOWFRAME)); nxInflateRect(&r, -1, -1); GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_APPWINDOW)); GrFillRect(id, gc, r.x, r.y, r.width, r.height); nxInflateRect(&r, -1, -1); GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_BTNTEXT)); GrLine(id, gc, r.x, r.y, r.x+r.width-1, r.y+r.height-1); GrLine(id, gc, r.x, r.y+r.height-1, r.x+r.width-1, r.y); } #if 0 /* fill in client area*/ y++; h -= CYCAPTION+1; GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_APPWINDOW)); GrFillRect(id, gc, x, y, w, h); #endif out: GrDestroyGC(gc); }
static wxNativeFont wxLoadQueryFont(float pointSize, wxFontFamily family, wxFontStyle style, int weight, bool WXUNUSED(underlined), const wxString& facename, const wxString& xregistry, const wxString& xencoding, wxString* xFontName) { #if wxUSE_NANOX int xweight; switch (weight) { case wxFONTWEIGHT_BOLD: { xweight = MWLF_WEIGHT_BOLD; break; } case wxFONTWEIGHT_LIGHT: { xweight = MWLF_WEIGHT_LIGHT; break; } case wxFONTWEIGHT_NORMAL: { xweight = MWLF_WEIGHT_NORMAL; break; } default: { xweight = MWLF_WEIGHT_DEFAULT; break; } } GR_SCREEN_INFO screenInfo; GrGetScreenInfo(& screenInfo); int yPixelsPerCM = screenInfo.ydpcm; // A point is 1/72 of an inch. // An inch is 2.541 cm. // So pixelHeight = (pointSize / 72) (inches) * 2.541 (for cm) * yPixelsPerCM (for pixels) // In fact pointSize is 10 * the normal point size so // divide by 10. int pixelHeight = (int) ( (((float)pointSize) / 720.0) * 2.541 * (float) yPixelsPerCM) ; // An alternative: assume that the screen is 72 dpi. //int pixelHeight = (int) (((float)pointSize / 720.0) * 72.0) ; //int pixelHeight = (int) ((float)pointSize / 10.0) ; GR_LOGFONT logFont; logFont.lfHeight = pixelHeight; logFont.lfWidth = 0; logFont.lfEscapement = 0; logFont.lfOrientation = 0; logFont.lfWeight = xweight; logFont.lfItalic = (style == wxFONTSTYLE_ITALIC ? 0 : 1) ; logFont.lfUnderline = 0; logFont.lfStrikeOut = 0; logFont.lfCharSet = MWLF_CHARSET_DEFAULT; // TODO: select appropriate one logFont.lfOutPrecision = MWLF_TYPE_DEFAULT; logFont.lfClipPrecision = 0; // Not used logFont.lfRoman = (family == wxROMAN ? 1 : 0) ; logFont.lfSerif = (family == wxSWISS ? 0 : 1) ; logFont.lfSansSerif = !logFont.lfSerif ; logFont.lfModern = (family == wxMODERN ? 1 : 0) ; logFont.lfProportional = (family == wxTELETYPE ? 0 : 1) ; logFont.lfOblique = 0; logFont.lfSmallCaps = 0; logFont.lfPitch = 0; // 0 = default strcpy(logFont.lfFaceName, facename.c_str()); XFontStruct* fontInfo = (XFontStruct*) malloc(sizeof(XFontStruct)); fontInfo->fid = GrCreateFont((GR_CHAR*) facename.c_str(), pixelHeight, & logFont); GrGetFontInfo(fontInfo->fid, & fontInfo->info); return (wxNativeFont) fontInfo; #else wxNativeFontInfo info; info.SetFractionalPointSize(pointSize); if ( !facename.empty() ) { info.SetFaceName(facename); if ( !wxTestFontSpec(info.GetXFontName()) ) { // No such face name, use just the family (we assume this will // never fail). info.SetFamily(family); } } else { info.SetFamily(family); } wxNativeFontInfo infoWithStyle(info); infoWithStyle.SetStyle(style); if ( wxTestFontSpec(infoWithStyle.GetXFontName()) ) info = infoWithStyle; wxNativeFontInfo infoWithWeight(info); infoWithWeight.SetNumericWeight(weight); if ( wxTestFontSpec(infoWithWeight.GetXFontName()) ) info = infoWithWeight; // construct the X font spec from our data wxString fontSpec; fontSpec.Printf("-*-%s-%s-%s-normal-*-*-%s-*-*-*-*-%s-%s", info.GetXFontComponent(wxXLFD_FAMILY), info.GetXFontComponent(wxXLFD_WEIGHT), info.GetXFontComponent(wxXLFD_SLANT), info.GetXFontComponent(wxXLFD_POINTSIZE), xregistry, xencoding); if( xFontName ) *xFontName = fontSpec; return wxLoadFont(fontSpec); #endif // wxUSE_NANOX }
int main(int argc,char **argv) { GR_EVENT event; /* current event */ struct app_info * act; int width, height; #ifdef USE_WEIRD_POINTER GR_BITMAP bitmap1fg[7]; /* bitmaps for first cursor */ GR_BITMAP bitmap1bg[7]; #endif for(act = Apps; act->app_id[0] != '\0'; act++, num_apps++); if (GrOpen() < 0) { fprintf(stderr, "cannot open graphics\n"); exit(1); } GrGetScreenInfo(&si); signal(SIGCHLD, &reaper); gc = GrNewGC(); bgc = GrNewGC(); GrSetGCForeground(bgc, GRAY); GrSetGCFont(gc, GrCreateFont(GR_FONT_OEM_FIXED, 0, NULL)); GrGetGCTextSize(gc, "A", 1, GR_TFASCII, &fwidth, &fheight, &fbase); width = fwidth * 8 + 4; height = (fheight) * num_apps + 4; w1 = GrNewWindow(GR_ROOT_WINDOW_ID, 5, 5, width, height, 1, WHITE, BLACK); GrSelectEvents(w1, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_BUTTON_DOWN | GR_EVENT_MASK_CLOSE_REQ); GrSelectEvents(GR_ROOT_WINDOW_ID, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_CHLD_UPDATE); GrMapWindow(w1); #ifdef USE_WEIRD_POINTER bitmap1bg[0] = MASK(_,_,X,X,X,_,_); bitmap1bg[1] = MASK(_,X,X,X,X,X,_); bitmap1bg[2] = MASK(_,X,X,X,X,X,_); bitmap1bg[3] = MASK(_,X,X,X,X,X,_); bitmap1bg[4] = MASK(_,X,X,X,X,X,_); bitmap1bg[5] = MASK(_,X,X,X,X,X,_); bitmap1bg[6] = MASK(X,X,X,X,X,X,X); bitmap1fg[0] = MASK(_,_,_,_,_,_,_); bitmap1fg[1] = MASK(_,_,_,X,_,_,_); bitmap1fg[2] = MASK(_,_,X,X,X,_,_); bitmap1fg[3] = MASK(_,_,X,X,X,_,_); bitmap1fg[4] = MASK(_,_,X,X,X,_,_); bitmap1fg[5] = MASK(_,_,X,X,X,_,_); bitmap1fg[6] = MASK(_,X,X,X,X,X,_); GrSetCursor(w1, 7, 7, 3, 3, WHITE, BLACK, bitmap1fg, bitmap1bg); #endif GrFillRect(GR_ROOT_WINDOW_ID, bgc, 0, 0, si.cols, si.rows); GrSetGCForeground(gc, BLACK); GrSetGCBackground(gc, WHITE); while (1) { GrGetNextEvent(&event); switch (event.type) { case GR_EVENT_TYPE_EXPOSURE: do_exposure(&event.exposure); break; case GR_EVENT_TYPE_BUTTON_DOWN: do_buttondown(&event.button); break; case GR_EVENT_TYPE_BUTTON_UP: do_buttonup(&event.button); break; case GR_EVENT_TYPE_UPDATE: do_update(&event.update); break; case GR_EVENT_TYPE_MOUSE_POSITION: do_mouse(&event.mouse); break; case GR_EVENT_TYPE_CLOSE_REQ: GrClose(); exit(0); } } }