Exemplo n.º 1
0
void
draw_set(char *name, int mode)
{
	int x;
	int tw, th, tb;
	GR_POINT points[4];
	GR_GC_ID gc = GrNewGC();

	GrSetGCForeground(gc, WHITE);
	GrSetGCBackground(gc, GRAY);

	GrGetGCTextSize(gc, name, -1, GR_TFTOP, &tw, &th, &tb);

	x = g_x + (tw - 50) / 2;

	GrText(g_main, gc, g_x, 5, name, -1, GR_TFTOP);

	g_x += (tw + 10);

	GrSetGCFillMode(gc, mode);

	if (mode == GR_FILL_STIPPLE)
		GrSetGCForeground(gc, YELLOW);
	else {
		GrSetGCForeground(gc, WHITE);
		GrSetGCBackground(gc, BLUE);
	}

	if (mode == GR_FILL_TILE) {
		GrSetGCTile(gc, g_pixmap, 16, 16);
	}

	if (mode == GR_FILL_STIPPLE || mode == GR_FILL_OPAQUE_STIPPLE)
		GrSetGCStipple(gc, g_stipple2, 2, 2);

	GrFillRect(g_main, gc, x, 25, 50, 50);

	if (mode == GR_FILL_STIPPLE || mode == GR_FILL_OPAQUE_STIPPLE)
		GrSetGCStipple(gc, g_stipple1, 7, 7);

	GrFillEllipse(g_main, gc, x + 25, 105, 25, 25);

	if (mode == GR_FILL_STIPPLE || mode == GR_FILL_OPAQUE_STIPPLE)
		GrSetGCStipple(gc, g_stipple3, 3, 2);

	points[0].x = points[3].x = x;
	points[0].y = points[3].y = 165;

	points[1].x = x + 50;
	points[1].y = 165;

	points[2].x = x + 25;
	points[2].y = 215;

	GrFillPoly(g_main, gc, 4, points);

	GrDestroyGC(gc);
}
Exemplo n.º 2
0
static void
GrSetGCBackgroundWrapper(void *r)
{
	nxSetGCBackgroundReq *req = r;

	GrSetGCBackground(req->gcid, req->color);
}
Exemplo n.º 3
0
void new_invaders_window()
{

	invaders_gc = pz_get_gc(1);

	GrSetGCUseBackground(invaders_gc, GR_TRUE);
	GrSetGCBackground(invaders_gc, GR_RGB(255,255,255));
	GrSetGCForeground(invaders_gc, GR_RGB(0,0,0));
	
	invaders_score_pix = GrNewPixmap(screen_info.cols, 13, 0);

	invaders_wid = pz_new_window(0,
				HEADER_TOPLINE + 1,
				screen_info.cols,
				screen_info.rows - HEADER_TOPLINE - 1,
				invaders_do_draw,
				invaders_handle_event);

	GrSelectEvents(invaders_wid, GR_EVENT_MASK_TIMER |
			GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_KEY_UP |
			GR_EVENT_MASK_KEY_DOWN);
	
	score = 0;
	level = 0;
	aliens_rows = (screen_info.rows - 40) / 20;	
	
	game_status = GAME_STATUS_PLAY;
	invaders_create_board(level);

	invaders_timer_id = GrCreateTimer(invaders_wid, 50);

	GrMapWindow(invaders_wid);
	
	draw_first();
}
Exemplo n.º 4
0
static void credits_blit_char(const int col, int cha, GR_COLOR colour,
                              const int fillbg)
{
	static int centre;
		
	if (!centre) {
		centre = (credits_info.height / 2) - (COL_H / 2);
	}
	
	if (fillbg) {
		GrSetGCUseBackground(credits_gc, GR_TRUE);
		GrSetGCBackground(credits_gc, BLACK);
	} else {
		GrSetGCUseBackground(credits_gc, GR_FALSE);
	}
	
	/* TRANSMUTATEULATE THE HOTDOG */
	if (cha == ' ') {
		cha = 0;
	} else if (cha >= '0' && cha <= '9') {
		cha = cha - 47;
	} else if (cha >= 'A' && cha <= 'Z') {
		cha = cha - 54;
	} else if (cha >= 'a' && cha <= 'z') { // lowercase -> upper
		cha = cha - 86;
	} else if (cha >= 1 && cha <= 26) { // c0d3
		cha = cha + 36;
	} else {
		cha = 34; // 'X'
	}

    GrSetGCForeground(credits_gc, colour);
	GrBitmap (credits_wid, credits_gc, COL_W*col, centre, COL_W, COL_H,
	          matrix_code_font[cha]);
}
Exemplo n.º 5
0
/* Draw the message if it's a mini */ 
void draw_message(char *msg1, char *msg2)
{
	int offset;

	/* Clear the window */
	GrClearWindow(message_wid, GR_FALSE);

	/* Put the foreground and background in good shapes */
	GrSetGCForeground(tuxchess_gc, GR_RGB(0,0,0));
	GrSetGCBackground(tuxchess_gc, GR_RGB(255,255,255));

	/* Draw the "window" */
	GrLine(message_wid, tuxchess_gc, 1, 0, 34, 0);
	GrLine(message_wid, tuxchess_gc, 1, 16, 34, 16);
	GrLine(message_wid, tuxchess_gc, 1, 0, 1, 110);
	GrLine(message_wid, tuxchess_gc, 34, 0, 34, 110);
	GrLine(message_wid, tuxchess_gc, 1, 110, 34, 110);
	GrText(message_wid, tuxchess_gc, 3,13, 
		"Chess", -1, GR_TFASCII);  /* Title in the text box */

	GrText(message_wid, tuxchess_gc, 3,73, msg1, -1, GR_TFASCII);

	if ((strcmp(msg2, "Play") == 0) || (strcmp(msg2, "     ") == 0))
	{
		offset = 3;
		msg2 = "Play";
	}
	else
	{
		offset = 0;
	}

	GrText(message_wid, tuxchess_gc, 4+offset,53, msg2, -1, GR_TFASCII);
}
Exemplo n.º 6
0
void new_browser_window(char *initial_path)
{
	if (initial_path) {
		chdir(initial_path);
	}
	getcwd(current_dir, sizeof(current_dir));

	browser_gc = pz_get_gc(1);
	GrSetGCUseBackground(browser_gc, GR_FALSE);
	GrSetGCBackground(browser_gc, WHITE);
	GrSetGCForeground(browser_gc, BLACK);

	browser_wid = pz_new_window(0, HEADER_TOPLINE + 2, screen_info.cols,
                                    screen_info.rows - (HEADER_TOPLINE + 2),
                                    browser_do_draw, browser_do_keystroke);

	GrSelectEvents(browser_wid, GR_EVENT_MASK_EXPOSURE |
			GR_EVENT_MASK_KEY_UP | GR_EVENT_MASK_KEY_DOWN |
			GR_EVENT_MASK_TIMER);

	browser_menu = NULL;
	browser_menu_overlay = NULL;
	browser_mscandir("./");

	GrMapWindow(browser_wid);
}
Exemplo n.º 7
0
void new_ipobble_window()
{

	ipobble_gc = pz_get_gc(1);

	GrSetGCUseBackground(ipobble_gc, GR_TRUE);
	GrSetGCForeground(ipobble_gc, BLACK);
	GrSetGCBackground(ipobble_gc, WHITE);

	ipobble_wid = pz_new_window(0, HEADER_TOPLINE + 1,
			screen_info.cols,
			screen_info.rows - HEADER_TOPLINE - 1,
			ipobble_do_draw, ipobble_handle_event);

	GrSelectEvents(ipobble_wid, GR_EVENT_MASK_TIMER |
			GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_KEY_UP |
			GR_EVENT_MASK_KEY_DOWN);
	if( screen_info.bpp > 2) {
	    ipodc=1;
	}
	
	score = 0;
	level = 0;
	game_status = GAME_STATUS_PLAY;
	ipobble_create_board(level);

	ipobble_timer_id = GrCreateTimer(ipobble_wid, DELTA_TIME);

	GrMapWindow(ipobble_wid);
	
	draw_first();
}
Exemplo n.º 8
0
GR_GC_ID setup_multi_rect_region(void)
{
	GR_GC_ID gc;
	GR_RECT rect;
	GR_REGION_ID rg;

	gc = GrNewGC();
	GrSetGCForeground(gc, GR_COLOR_BLUE);
	GrSetGCBackground(gc, GR_COLOR_WHITE);
	rg = GrNewRegion();
	rect.x = 10;
	rect.y = 0;
	rect.width = 10;
	rect.height = 60;
	GrUnionRectWithRegion(rg, &rect);
	rect.x = 40;
	rect.y = 0;
	rect.width = 10;
	rect.height = 60;
	GrUnionRectWithRegion(rg, &rect);
	rect.x = 0;
	rect.y = 10;
	rect.width = 60;
	rect.height = 10;
	GrUnionRectWithRegion(rg, &rect);
	rect.x = 0;
	rect.y = 40;
	rect.width = 60;
	rect.height = 10;
	GrUnionRectWithRegion(rg, &rect);
	GrSetGCRegion(gc, rg);
	GrSetGCClipOrigin(gc, 105, 15);

	return gc;
}
Exemplo n.º 9
0
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);
}
Exemplo n.º 10
0
struct menulist *new_ml()
{
	struct menulist *ret =
		(struct menulist *) malloc(sizeof(struct menulist));
		
	GrGetScreenInfo(&ret->screen_info);

	ret->gc = pz_get_gc(1);
	GrSetGCUseBackground(ret->gc, GR_FALSE);
	GrSetGCForeground(ret->gc, BLACK);
	GrSetGCBackground(ret->gc, BLACK);

	ret->wid = pz_new_window(0, HEADER_TOPLINE + 1, ret->screen_info.cols,
			ret->screen_info.rows - (HEADER_TOPLINE + 1),
			itunes_do_draw, itunes_do_keystroke);

	GrSelectEvents(ret->wid, GR_EVENT_MASK_EXPOSURE|GR_EVENT_MASK_KEY_DOWN|GR_EVENT_MASK_KEY_UP|GR_EVENT_MASK_TIMER);

	GrGetGCTextSize(ret->gc, "M", -1, GR_TFASCII, &ret->gr_width,
			&ret->gr_height, &ret->gr_base);

	ret->gr_height += 4;

	GrMapWindow(ret->wid);
	ret->itunes_menu = menu_init(ret->wid, "Music", 0, 0,
			screen_info.cols, screen_info.rows -
			(HEADER_TOPLINE + 1), NULL, NULL, UTF8);
	ret->init = 0;
	ret->prevml = NULL;

	return ret;
}
Exemplo n.º 11
0
static void reset_board()
{
	int index;
	for(index = 0; index < 9; index++)
		board[index] = '-';
	
	difficulty = 6;
	gameRunning = 1;
	currSquare = 0;
	draw_header(); 
	
    /* Clear the window */
    GrClearWindow (tictactoe_wid, GR_FALSE);
	
	GrSetGCUseBackground(tictactoe_gc, GR_TRUE);
    GrSetGCBackground(tictactoe_gc, WHITE);
    GrSetGCForeground(tictactoe_gc, BLACK);
	
	GrLine(tictactoe_wid, tictactoe_gc, wi.width * .90, (wi.height / 2.) - (wi.height / 2. * .33), 
		   wi.width - wi.width * .90, (wi.height / 2.) - (wi.height / 2. * .33));
	GrLine(tictactoe_wid, tictactoe_gc, wi.width * .90, (wi.height / 2.) + (wi.height / 2. * .33), 
		   wi.width - wi.width * .90, (wi.height / 2.) + (wi.height / 2. * .33));
	
	GrLine(tictactoe_wid, tictactoe_gc, (wi.width / 2.) - (wi.width / 2. * .33), wi.height * .90, 
		   (wi.width / 2.) - (wi.width / 2. * .33), wi.height - wi.height * .90);
	GrLine(tictactoe_wid, tictactoe_gc, (wi.width / 2.) + (wi.width / 2. * .33), wi.height * .90, 
		   (wi.width / 2.) + (wi.width / 2. * .33), wi.height - wi.height * .90);
	currSquare = 0;
	drawXO(currSquare, GRAY, 'x');
}
Exemplo n.º 12
0
static void
RefreshWindow(void)
{
	int xpos, ypos;

	GrSetGCForeground(gc1, WHITE);
	GrSetGCBackground(gc1, RED);

	/* draw the buttons */
	GrRect(buttons, gc1, 0, 0, (calc_width - 12)/2, 34);
	GrRect(buttons, gc1, (calc_width - 8)/2, 0, (calc_width - 12)/2, 34);

#if 0	/* for when center align text works */
	GrText(buttons, gc1, (calc_width - 10)/4, 22, "Again", 5, 0);
	GrText(buttons, gc1, (calc_width - 10)*3/4, 22, "Quit", 4, 0);
#else
	GrText(buttons, gc1, 5, 22, "Again", 5, 0);
	GrText(buttons, gc1, (calc_width / 2) + 5, 22, "Quit", 4, 0);
#endif
	
	/* draw the tiles */
	for (ypos=0; ypos< HEIGHT_IN_TILES; ypos++){
		for (xpos=0; xpos< WIDTH_IN_TILES; xpos++){
			DrawTile(xpos, ypos);
		}
	}
}
Exemplo n.º 13
0
/* ***********************************************************/
void draw_historic(void)
{
	/* Clear the window */
	GrClearWindow (historic_wid, GR_FALSE);

	/* Put the foreground and background in good shapes */
	GrSetGCForeground(tuxchess_gc, GR_RGB(0,0,0));
	GrSetGCBackground(tuxchess_gc, GR_RGB(255,255,255));

	/* Draw the "window" */
	GrLine(historic_wid, tuxchess_gc, 1, 1, 55, 1);
	GrLine(historic_wid, tuxchess_gc, 1, 1, 1, 104);
	GrLine(historic_wid, tuxchess_gc, 1, 105, 55, 105);
	GrLine(historic_wid, tuxchess_gc, 55, 1, 55, 105);
	GrText(historic_wid, tuxchess_gc, 14,14, 
		"Moves", -1, GR_TFASCII);	/* Title in the text box */
	GrLine(historic_wid, tuxchess_gc, 1, 17, 56, 17);

	/* So ugly code since char* arrays seem to confuse my iPod - writes 6 lines */
	GrText(historic_wid, tuxchess_gc, 6, 33, historic_line1, -1, GR_TFASCII);
	GrText(historic_wid, tuxchess_gc, 6, 46, historic_line2, -1, GR_TFASCII);
	GrText(historic_wid, tuxchess_gc, 6, 59, historic_line3, -1, GR_TFASCII);
	GrText(historic_wid, tuxchess_gc, 6, 72, historic_line4, -1, GR_TFASCII);
	GrText(historic_wid, tuxchess_gc, 6, 85, historic_line5, -1, GR_TFASCII);
	GrText(historic_wid, tuxchess_gc, 6, 99, historic_line6, -1, GR_TFASCII);
}
Exemplo n.º 14
0
int
XSetBackground(Display *dpy, GC gc, unsigned long background)
{
	XGCValues *vp = (XGCValues *)gc->ext_data;
	GR_COLOR c = _nxColorvalFromPixelval(dpy, background);

	vp->background = background;
	GrSetGCBackground(gc->gid, c);
	return 1;
}
Exemplo n.º 15
0
void new_mp3_window(char *filename, char *album, char *artist, char *title, int len)
{
	if (album) {
		strncpy(current_album, album, sizeof(current_album)-1);
		current_album[sizeof(current_album)-1] = 0;
	}
	else
		current_album[0]=0;

	if (artist) {
		strncpy(current_artist, artist, sizeof(current_artist)-1);
		current_artist[sizeof(current_artist)-1] = 0;
	} else {
		current_artist[0]=0;
	}

	if (title) {
		strncpy(current_title, title, sizeof(current_title)-1);
		current_title[sizeof(current_title)-1] = 0;
	} else {
		current_title[0]=0;
	}

	sprintf(current_pos, _("Song %d of %d"), playlistpos, playlistlength);

	next_song_time = len;
	
	/* play another song when one isn't complete */
	if (window_open)
	{
	    strcpy(next_song, filename);
	    next_song_queued = 1;
	    return;
	}

	window_open = 1;

	mp3_gc = pz_get_gc(1);
	GrSetGCUseBackground(mp3_gc, GR_TRUE);
	GrSetGCBackground(mp3_gc, GR_RGB(255,255,255));
	GrSetGCForeground(mp3_gc, GR_RGB(0,0,0));

	mp3_wid = pz_new_window(0, HEADER_TOPLINE + 1, screen_info.cols, screen_info.rows - (HEADER_TOPLINE + 1), mp3_do_draw, mp3_do_keystroke);

	GrSelectEvents(mp3_wid, GR_EVENT_MASK_EXPOSURE|GR_EVENT_MASK_KEY_UP|GR_EVENT_MASK_KEY_DOWN|GR_EVENT_MASK_TIMER);

	GrMapWindow(mp3_wid);
	total_time = remaining_time = len;
	mp3_do_draw(0);

	start_mp3_playback(filename);
	window_open = 0;
}
Exemplo n.º 16
0
nxeyes_state *init(void)
{
	nxeyes_state *state;
	GR_REGION_ID rid1, rid2;
	GR_SCREEN_INFO si;
	GR_WM_PROPERTIES props;

	if(!(state = malloc(sizeof(nxeyes_state)))) return NULL;
	state->oldx = state->oldy = state->x = state->y = 0;
	state->button_down = state->eyes_closed = state->quit = 0;
	state->olx = state->orx = EYEMASK_WIDTH / 2;
	state->oly = state->ory = EYEMASK_HEIGHT / 2;
	GrGetScreenInfo(&si);
	state->mousex = si.xpos;
	state->mousey = si.ypos;
	state->mouse_moved = 1;
	state->gc = GrNewGC();
	GrSetGCForeground(state->gc, GR_COLOR_WHITE);
	GrSetGCBackground(state->gc, GR_COLOR_BLACK);

	state->wid = GrNewWindow(GR_ROOT_WINDOW_ID, 0, 0, (EYEFG_HEIGHT * 2) +
			EYE_SPACING, EYEFG_HEIGHT, 0, GR_COLOR_WHITE, 0);

	rid1 = GrNewBitmapRegion(eyemask_bits, EYEMASK_WIDTH, EYEMASK_HEIGHT);
	rid2 = GrNewBitmapRegion(eyemask_bits, EYEMASK_WIDTH, EYEMASK_HEIGHT);
	GrOffsetRegion(rid2, EYEMASK_WIDTH + EYE_SPACING, 0);
	GrUnionRegion(rid1, rid1, rid2);
	GrSetWindowRegion(state->wid, rid1, GR_WINDOW_BOUNDING_MASK);
	GrDestroyRegion(rid1);
	GrDestroyRegion(rid2);

	props.flags = GR_WM_FLAGS_PROPS;
	props.props = GR_WM_PROPS_NODECORATE;
	GrSetWMProperties(state->wid, &props);

	GrSelectEvents(state->wid, GR_EVENT_MASK_CLOSE_REQ |
			GR_EVENT_MASK_MOUSE_POSITION |
			GR_EVENT_MASK_BUTTON_UP |
			GR_EVENT_MASK_BUTTON_DOWN |
			GR_EVENT_MASK_EXPOSURE |
			GR_EVENT_MASK_TIMER);

	GrSelectEvents(GR_ROOT_WINDOW_ID, GR_EVENT_MASK_MOUSE_POSITION);

	GrMapWindow(state->wid);

	srand(123);
#if MW_FEATURE_TIMERS
	start_blink_timer(state);
#endif	
	return state;
}
Exemplo n.º 17
0
/* End of the game */
void draw_end(char col)
{
	int offset, off_x, off_y;

	if (end == 0) {
		end = 1;
		end_type = col;
	}
	else {
		end = 2;
		if (is_mini) {
			offset = 0;
			off_x = 11;
			off_y = 9;
		}
		else {
			offset = HEADER_TOPLINE+1;
			off_x = 0;
			off_y = 0;
		}

		end_wid = pz_new_window (0, offset, screen_info.cols,
			screen_info.rows - offset,
			tuxchess_do_draw, tuxchess_handle_event);
		GrSelectEvents(end_wid, GR_EVENT_MASK_KEY_DOWN |
				GR_EVENT_MASK_KEY_UP);

		GrMapWindow(end_wid);

		/* Put the foreground and background in good shapes */
		GrSetGCForeground(tuxchess_gc, GR_RGB(0,0,0));
		GrSetGCBackground(tuxchess_gc, GR_RGB(255,255,255));

		/* Clear the window */
		GrClearWindow(end_wid, GR_FALSE);

		if (col=='b') {
			GrText(end_wid, tuxchess_gc, 57-off_x,40-off_y, "You Lost", -1, GR_TFASCII);
		}
		else if (col=='w') {
			GrText(end_wid, tuxchess_gc, 54-off_x,40-off_y, "Well Done", -1, GR_TFASCII);
		}
		else if (col=='d') {
			GrText(end_wid, tuxchess_gc, 67-off_x,40-off_y, "Draw", -1, GR_TFASCII);
		}

		GrText(end_wid, tuxchess_gc, 52-off_x,65-off_y, 
			"Menu : Quit", -1, GR_TFASCII);
		GrText(end_wid, tuxchess_gc, 33-off_x,80-off_y, 
			"Action : New Game", -1, GR_TFASCII);
	}
}
Exemplo n.º 18
0
int
main(int ac, char **av)
{
    GR_EVENT event;
    GR_GC_ID gc;
    GR_WINDOW_ID pmap;
    GR_WINDOW_ID window;
    GR_WINDOW_INFO info;

    if (GrOpen() < 0) {
	fprintf(stderr, "cannot open graphics\n");
	exit(1);
    }

    window = nxCreateAppWindow(&ac, &av, args);
    gc = GrNewGC();
    GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_WINDOW));
    GrSetGCBackground(gc, GrGetSysColor(GR_COLOR_WINDOWTEXT));

    GrSelectEvents(window, GR_EVENT_MASK_EXPOSURE |
		   GR_EVENT_MASK_UPDATE | GR_EVENT_MASK_CLOSE_REQ);

    GrGetWindowInfo(window, &info);
    pmap = resize(info.width, info.height, 0);

    GrMapWindow(window);

    while (1) {
	GrGetNextEventTimeout(&event, 500L);

	switch (event.type) {
	case GR_EVENT_TYPE_EXPOSURE:
	case GR_EVENT_TYPE_TIMEOUT:
	    draw_clock(0, 0, width, height, pmap, gc, window);
	    break;

	case GR_EVENT_TYPE_CLOSE_REQ:
	    GrClose();
	    exit(0);

	case GR_EVENT_TYPE_UPDATE:
	    switch (event.update.utype) {
	    case GR_UPDATE_SIZE:
		pmap = resize(event.update.width, event.update.height, pmap);
		break;
	    }
	}
    }
    return 0;
}
Exemplo n.º 19
0
static void draw_help()
{
	//Hold:			Help Menu
	//Play/Pause:	Start/Stay
	//Action:		Hit
	//Wheel:		Dec/Inc Bid
	//Prev/Next:	Dec/Inc Bid
	//Version:		X.XX

	int i, width, height, depth;
	char *help[] =
	{
	"Hold:", "Help",
	"Play/Pause:", "Start/Stay",
	"Action:", "Hit",
	"Wheel:", "Dec/Inc Bid",
	"Prev/Next:", "Dec/Inc Bid",
	"", "",
	"Version:", VERSION,
	0
	};

	GrSetGCUseBackground(blackjack_gc, GR_TRUE);
	GrSetGCBackground(blackjack_gc, WHITE);

	GrSelectEvents(blackjack_wid, GR_EVENT_MASK_EXPOSURE|GR_EVENT_MASK_KEY_DOWN|
				   GR_EVENT_MASK_KEY_UP|GR_EVENT_MASK_TIMER);

	GrSetGCForeground(blackjack_gc, WHITE);

	GrFillRect(blackjack_wid, blackjack_gc, 0, 0,
			   screen_info.cols, screen_info.rows - HEADER_TOPLINE);


	GrSetGCForeground(blackjack_gc, BLACK);

	for(i=0; help[i] != 0; i++)
	{
		GrGetGCTextSize (blackjack_gc, help[i], -1, GR_TFASCII, &width, &height, &depth);

		if(i % 2 == 0)
		{
			GrText(blackjack_wid, blackjack_gc, 5, (i * 7) + 20, help[i], -1, GR_TFASCII);
		}else{
			GrText(blackjack_wid, blackjack_gc,
				   screen_info.cols - (width + 5),
				  ((i - 1) * 7) + 20, help[i],  -1, GR_TFASCII);
		}
	}
}
Exemplo n.º 20
0
/* ***********************************************************/
static void gprintf(char s[])
{
	static char lasttext[128];

        GrSetGCForeground(text_gc,BLACK);
        GrFillRect(text, text_gc, 0, 0, 394,20);
        GrSetGCForeground(text_gc,WHITE);
        GrSetGCBackground(text_gc,BLACK);
	if (!s)
		s = lasttext;
        GrText(text, text_gc, 5, 14, s, strlen(s),0);
	if (s != lasttext)
		strcpy(lasttext, s);
}     
Exemplo n.º 21
0
GR_GC_ID setup_bitmap_region(void)
{
	GR_GC_ID gc;
	GR_REGION_ID rg;

	gc = GrNewGC();
	GrSetGCForeground(gc, GR_COLOR_FORESTGREEN);
	GrSetGCBackground(gc, GR_COLOR_WHITE);
	rg = GrNewBitmapRegion(tuxmask_bits, TUXMASK_WIDTH, TUXMASK_HEIGHT);
	GrSetGCRegion(gc, rg);
	GrSetGCClipOrigin(gc, 100, 80);

	return gc;
}
Exemplo n.º 22
0
GR_GC_ID setup_simple_poly_region(void)
{
	GR_GC_ID gc;
	GR_REGION_ID rg;
	GR_POINT points[] = { {15, 0}, {45, 0}, {60, 15}, {60, 45}, {45, 60},
		{15, 60}, {0, 45}, {0, 15} };

	gc = GrNewGC();
	GrSetGCForeground(gc, GR_COLOR_PURPLE);
	GrSetGCBackground(gc, GR_COLOR_WHITE);
	rg = GrNewPolygonRegion(GR_POLY_WINDING, 8, points);
	GrSetGCRegion(gc, rg);
	GrSetGCClipOrigin(gc, 25, 95);

	return gc;
}
Exemplo n.º 23
0
GR_GC_ID setup_complex_poly_region(void)
{
	GR_GC_ID gc;
	GR_REGION_ID rg;
	GR_POINT points[] = { {0, 0}, {99, 0}, {99, 99}, {0, 99}, {0, 19},
		{79, 19}, {79, 79}, {19, 79}, {19, 39}, {59, 39}, {59, 49},
		{29, 49}, {29, 69}, {69, 69}, {69, 29}, {9, 29}, {9, 89},
		{89, 89}, {89, 9}, {0, 9} };

	gc = GrNewGC();
	GrSetGCForeground(gc, GR_COLOR_ORANGE);
	GrSetGCBackground(gc, GR_COLOR_WHITE);
	rg = GrNewPolygonRegion(GR_POLY_EVENODD, 20, points);
	GrSetGCRegion(gc, rg);
	GrSetGCClipOrigin(gc, 25, 180);

	return gc;
}
Exemplo n.º 24
0
        CRJinkeScreen( int width, int height )
        :  CRGUIScreenBase( width, height, true )
        {
            if( GrOpen() < 0 ) 
            {
                fprintf(stderr, "Couldn't connect to Nano-X server\n");
                return;
            }

            GR_WM_PROPERTIES props;
            //GR_SCREEN_INFO si;
            //GrGetScreenInfo(&si);
    
            _wid = GrNewWindow(GR_ROOT_WINDOW_ID,VIEWER_WINDOW_X,VIEWER_WINDOW_Y,
            VIEWER_WINDOW_WIDTH,VIEWER_WINDOW_HEIGHT, 0, GR_COLOR_WHITE, 0);
            _gc = GrNewGC();
            GrSetGCForeground(_gc, GR_COLOR_BLACK);
            GrSetGCBackground(_gc, GR_COLOR_WHITE);
        
            GrSelectEvents(_wid, GR_EVENT_MASK_BUTTON_DOWN | \
                GR_EVENT_MASK_BUTTON_UP | GR_EVENT_MASK_MOUSE_POSITION |\
                GR_EVENT_MASK_EXPOSURE |GR_EVENT_MASK_KEY_UP|\
                GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_CLOSE_REQ);

            //Set Windows style
            props.flags = GR_WM_FLAGS_PROPS;
            props.props = GR_WM_PROPS_NODECORATE;
            GrSetWMProperties(_wid, &props);
        //#ifndef USE_OLD_NANOX
            GrMapWindow(_wid);    
            GrSetFocus(_wid);
        //#endif

            _canvas = LVRef<LVDrawBuf>( new LVGrayDrawBuf( _width, _height, GRAY_BACKBUFFER_BITS ) );
            _front = LVRef<LVDrawBuf>( new LVGrayDrawBuf( _width, _height, GRAY_BACKBUFFER_BITS ) );
            
            _canvas->Clear(0xFFFFFF);
            //_front->Clear(0xFFFFFF);
            _front->Clear(0x000000);

            instance = this;
        }
Exemplo n.º 25
0
void new_periodic_window(void)
{
	periodic_gc = pz_get_gc(1);
	
	GrSetGCUseBackground(periodic_gc, GR_TRUE);
	GrSetGCForeground(periodic_gc, GR_RGB(0,0,0));
	GrSetGCBackground(periodic_gc, GR_RGB(255,255,255));
	
	periodic_wid = pz_new_window(0, HEADER_TOPLINE + 1,
		screen_info.cols, screen_info.rows - (HEADER_TOPLINE + 1),
		periodic_event_draw, periodic_handle_event);
	periodic_bufwid = GrNewPixmap(screen_info.cols, screen_info.rows - HEADER_TOPLINE, NULL);
	
	periodic_sel = -1;
	periodic_draw_table(periodic_bufwid, periodic_gc);
	periodic_sel = 0;
	
	GrSelectEvents(periodic_wid, GR_EVENT_MASK_EXPOSURE| GR_EVENT_MASK_KEY_UP| GR_EVENT_MASK_KEY_DOWN);
	GrMapWindow(periodic_wid);
}
Exemplo n.º 26
0
static void
draw_string(GR_WINDOW_ID wid)
{
	int count = 0;
	int x = border;
	int y = border;
	unsigned int start, end;
	unsigned int ch;
	GR_GC_ID gc = GrNewGC();

	GrSetGCBackground(gc, GR_RGB(0, 0, 0));
	GrSetGCFont(gc, font);

	if (first_char > finfo.lastchar)
		first_char = 0;
	if (first_char + chars_to_show <= finfo.firstchar)
		first_char = (finfo.firstchar / line_width) * line_width;

	start = first_char;
	end = first_char + chars_to_show;

	printf("drawing chars %d to %d\n", start, end - 1);

	for (ch = start; ch < end; ch++) {
		GrSetGCForeground(gc, GR_RGB(64, 64, 64));
		GrFillRect(wid, gc, x-1, y-1, finfo.maxwidth+2, finfo.height+2);
		GrSetGCForeground(gc, GR_RGB(255, 255, 255));

		if (ch >= finfo.firstchar && ch <= finfo.lastchar)
			GrText(wid, gc, x, y, &ch, 1, GR_TFTOP | GR_TFUC32);

		if (++count >= line_width) {
			x = border;
			y += finfo.height + spacer;
			count = 0;
		} else
			x += finfo.maxwidth + spacer;
	}

	GrDestroyGC(gc);
}
Exemplo n.º 27
0
void drawXO(int pos, int shade, char theChar)
{	
	int xPos, yPos, i;
	GrSetGCUseBackground(tictactoe_gc, GR_TRUE);
    GrSetGCBackground(tictactoe_gc, WHITE);
    GrSetGCForeground(tictactoe_gc, shade);
	
	xPos = wi.width * .25 * (pos % 3 + 1);
	yPos = wi.height * .25 * (pos / 3 + 1);
	
	if (theChar == 'o') {
		for ( i = 0; i < 4; i++)
			GrEllipse(tictactoe_wid, tictactoe_gc, xPos, yPos, wi.width * .03 + i, wi.height * .03 + i);
	} else if (theChar == 'x') {
		for ( i = 0; i < 4; i++) {
			GrLine(tictactoe_wid, tictactoe_gc, xPos - wi.width * .03 + i, yPos - wi.height * .03, 
				   xPos + wi.width * .03 + i, yPos + wi.height * .03);
			GrLine(tictactoe_wid, tictactoe_gc, xPos - wi.width * .03 + i, yPos+ wi.height * .03, 
				   xPos + wi.width * .03 + i, yPos - wi.height * .03);
		}
	}
}
Exemplo n.º 28
0
static void
DrawTile(int xpos, int ypos)
{
	char text[]="00";

	/* blank out old tile */
	GrSetGCForeground(gc1, RED);
	GrFillRect(tiles, gc1, (xpos* tile_width), (ypos*tile_height), tile_width, tile_height);

	if (value[xpos][ypos] != MAX_TILES ) {
		/* re-draw tile and number */
		GrSetGCForeground(gc1, WHITE);
		GrSetGCBackground(gc1, RED);
		GrRect(tiles, gc1, (xpos*tile_width), (ypos*tile_height), tile_width, tile_height);
		
#if USE_IMAGE
		if (using_image) {
			/* copy from image window */
			GrCopyArea(tiles, gc1, 1 + (xpos*tile_width), 1 + (ypos*tile_height), 
				tile_width - 2, tile_height - 2, image,
				1 + (((value[xpos][ypos] - 1) % WIDTH_IN_TILES) * tile_width), 
				1 + (((int)(value[xpos][ypos] - 1) / WIDTH_IN_TILES) * tile_height), 0);
		} else {
#endif
			/* label the tile with a number */
			if (value[xpos][ypos] > 9)
				text[0] = 48 + (int)(value[xpos][ypos]/10);
			else
				text[0] = 32;
	
			text[1] = 48 + value[xpos][ypos] % 10;
			
			GrText(tiles, gc1, (xpos*tile_width) + (tile_width /2) - 5, (ypos*tile_height) + (tile_height/2) + 5, &text, -1, 0);
#if USE_IMAGE
		}
#endif
	}
}
Exemplo n.º 29
0
void new_credits_window( void )
{
	credits_gc = pz_get_gc(1);


	GrSetGCUseBackground(credits_gc, GR_FALSE);
	GrSetGCBackground(credits_gc, BLACK);

	credits_wid = pz_new_window(0, 0/*HEADER_TOPLINE + 1*/, screen_info.cols,
	                           screen_info.rows /*- (HEADER_TOPLINE + 1)*/, 
	                           credits_do_draw, credits_handle_event);

	GrSelectEvents( credits_wid, GR_EVENT_MASK_TIMER|
	GR_EVENT_MASK_EXPOSURE|GR_EVENT_MASK_KEY_UP|GR_EVENT_MASK_KEY_DOWN);

	credits_init();
	credits_newtext();

    credits_timer = GrCreateTimer(credits_wid, 20);

	GrMapWindow(credits_wid);

	credits_clear_screen(0);
}
Exemplo n.º 30
0
int main(void)
{
    GR_WINDOW_ID wid;
    GR_GC_ID gc;
    GR_EVENT event;

    if(GrOpen() < 0) {
        fprintf(stderr, "Couldn't connect to the Nano-X server\n");
        return 1;
    }

    wid = GrNewWindow(GR_ROOT_WINDOW_ID, 0, 0, BITMAPWIDTH, BITMAPHEIGHT,
                      0, GR_COLOR_WHITE, 0);

    GrSelectEvents(wid, GR_EVENT_MASK_CLOSE_REQ | GR_EVENT_MASK_EXPOSURE);

    gc = GrNewGC();
    GrSetGCForeground(gc, GR_COLOR_BLACK);
    GrSetGCBackground(gc, GR_COLOR_WHITE);

    GrMapWindow(wid);

    while(1) {
        GrGetNextEvent(&event);
        switch(event.type) {
        case GR_EVENT_TYPE_EXPOSURE:
            redraw(wid, gc);
            break;
        case GR_EVENT_TYPE_CLOSE_REQ:
            GrClose();
            return 0;
        default:
            break;
        }
    }
}