Exemplo n.º 1
0
/* does the drawing, safe(and recommended) to use {in, as} an exposure event */
void menu_draw(menu_st *menulist)
{
	int i;

	/* appearance changed, force a redraw */
	if(menulist->scheme_no != appearance_get_color_scheme() ||
			get_current_font() != menulist->font) {
		menu_update_menu(menulist);
	}

	/* first draw; init onscreen text items */
	if(menulist->init == 0) {
		for(i = (menulist->num_items > menulist->screen_items) ?
				menulist->screen_items : menulist->num_items;
				i; i--)
			menu_retext_pixmap(menulist, i - 1,
				&menulist->items[menulist->top_item + (i - 1)]);
		menulist->init = 1;
	}
#if 0
	else if(menulist->lastsel == menulist->sel) {
		Dprintf("Aborted draw because %d == %d\n", menulist->sel,
				menulist->lastsel);
		return;
	}
	Dprintf("Continuing, %d != %d\n", menulist->sel, menulist->lastsel);
#endif
	/* draw each pixmap */
	for(i = 0; i < menulist->screen_items; i++)
		menu_draw_item(menulist, i);

	/* erase the bottom unused part of the allocated screen */
	GrSetGCForeground(menulist->menu_gc, appearance_get_color( CS_BG ));
	GrFillRect(menulist->menu_wid, menulist->menu_gc, menulist->x,
			menulist->height * menulist->screen_items, menulist->w,
			menulist->h - (menulist->height *
			menulist->screen_items));

	GrSetGCForeground(menulist->menu_gc, BLACK);

	/* draw scrollbar if needed */
	if(menulist->num_items > menulist->screen_items) {
		menulist->scrollbar = 1;
		menu_draw_scrollbar(menulist);
	}
	else
		menulist->scrollbar = 0;

	/* deal with the timer */
	menu_handle_timer(menulist, 0);

	menulist->lastsel = menulist->sel;
}
Exemplo n.º 2
0
void generator_draw_volume()
{

	//erase just the volume bar (prevent flickering)
	GrSetGCForeground( generator_gc, WHITE);
	GrFillRect( generator_wid, generator_gc, 10, screen_info.rows - HEADER_TOPLINE - 16, screen_info.cols - 20, 8 );

	if( generator_mode==GENERATOR_MODE_VOLUME) {
		//get the volume
		int volume = dsp_get_volume(&dspz);	
		//calculate the bar length for the volume
		int volume_length = ((screen_info.cols - 22) * volume) / 100; 

		//draw the volume border
		GrSetGCForeground( generator_gc, BLACK);
		GrRect( generator_wid, generator_gc, 10, screen_info.rows - HEADER_TOPLINE - 16, screen_info.cols - 20, 8 );
		
		//draw the volume inside
		GrSetGCForeground( generator_gc, GRAY);		
		GrFillRect( generator_wid, generator_gc, 11, screen_info.rows - HEADER_TOPLINE - 15, volume_length, 6 );
	}
}
Exemplo n.º 3
0
/* flash selected item. ala apple fw */
void menu_flash_selected(menu_st * menulist)
{
	int item;
	item = menulist->sel - menulist->top_item;
	GrSetGCForeground(menulist->menu_gc, WHITE);
	GrFillRect(menulist->menu_wid, menulist->menu_gc, menulist->x,
			menulist->y + item * menulist->height,
			menulist->w - (menulist->scrollbar ? 8 : 0),
			menulist->height);
	GrSetGCForeground(menulist->menu_gc, BLACK);
	menulist->items[menulist->sel].op |= CFLASH;
	menu_handle_timer(menulist, 0);
}
Exemplo n.º 4
0
/* this would be much cleaner if raster ops worked properly; perhaps I just
 * misunderstand how they are supposed to be used */
void menu_draw_item(menu_st *menulist, int item)
{
	if(item < 0 || item > menulist->screen_items - 1) {
		Dprintf("menu_draw_item::No Such Pixmap\n");
		return;
	}
	/* xor the pixmap */
	if(item == (menulist->sel - menulist->top_item)) {
		GrSetGCMode(menulist->menu_gc, GR_MODE_XOR);
		if (hw_version == 0 || hw_version == 0x6 || hw_version == 0xc || hw_version == 0xb) {
			/* make sure that the xor works properly for devices with
			 * fbrev turned off (host, photo) */
			GrSetGCForeground(menulist->menu_gc, WHITE );
		}

			/* just xor the menu option for now */
			/* eventually, draw the correct colors... */
		GrFillRect(menulist->pixmaps[menulist->pixmap_pos[item]],
				menulist->menu_gc, 0, 0, menulist->w,
				menulist->height);
	}
	GrCopyArea(menulist->menu_wid, menulist->menu_gc, menulist->x,
			(item * menulist->height) + menulist->y,
			menulist->w - (menulist->scrollbar ? 8 : 0),
			menulist->height,
			menulist->pixmaps[menulist->pixmap_pos[item]],
			0, 0, 0);
	/* un umm xor the pixmap */
	if(item == (menulist->sel - menulist->top_item)) {
		GrFillRect(menulist->pixmaps[menulist->pixmap_pos[item]],
				menulist->menu_gc, 0, 0, menulist->w,
				menulist->height);
		GrSetGCMode(menulist->menu_gc, GR_MODE_SET);
		if (hw_version == 0 || hw_version == 0x6 || hw_version == 0xc || hw_version == 0xb) {
			/* reset fix for xor on certain devices (host, photo) */
			GrSetGCForeground(menulist->menu_gc, BLACK);
		}
	}
}
Exemplo n.º 5
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.º 6
0
static void video_status_message(char *msg)
{
	GR_SIZE txt_width, txt_height, txt_base;
	GR_COORD txt_x, txt_y;

	GrGetGCTextSize(video_gc, msg, -1, GR_TFASCII, &txt_width, &txt_height, &txt_base);
	txt_x = (screen_info.cols - (txt_width + 10)) >> 1;
	txt_y = (screen_info.rows - (txt_height + 10)) >> 1;
	GrSetGCForeground(video_gc, GR_RGB(255,255,255));
	GrFillRect(video_wid, video_gc, txt_x, txt_y, txt_width + 10, txt_height + 10);
	GrSetGCForeground(video_gc, GR_RGB(0,0,0));
	GrRect(video_wid, video_gc, txt_x, txt_y, txt_width + 10, txt_height + 10);
	GrText(video_wid, video_gc, txt_x + 5, txt_y + txt_base + 5, msg, -1, GR_TFASCII);
}
Exemplo n.º 7
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.º 8
0
void draw_score(nstate *state)
{
	char buf[32];

	GrFillRect(state->score_window, state->scoregcb, 0, 0,
			SCORE_WINDOW_WIDTH, SCORE_WINDOW_HEIGHT);

	sprintf(buf, "%d", state->score);
	GrText(state->score_window, state->scoregcf, TEXT_X_POSITION,
					TEXT2_Y_POSITION, buf, strlen(buf), 0);
	sprintf(buf, "%d", state->hiscore);
	GrText(state->score_window, state->scoregcf, TEXT_X_POSITION,
					TEXT_Y_POSITION, buf, strlen(buf), 0);
}
Exemplo n.º 9
0
static void draw_itunes_parse(int cnt)
{
	char str[10];
	sprintf(str, "%i", cnt);

	GrSetGCUseBackground(currentml->gc, GR_FALSE);
	GrSetGCMode(currentml->gc, GR_MODE_SET);
	GrSetGCForeground(currentml->gc, WHITE);
	GrFillRect(currentml->wid, currentml->gc, 0,
		   3 * currentml->gr_height,
		   currentml->screen_info.cols, currentml->gr_height);
	GrSetGCForeground(currentml->gc, BLACK);
	GrText(currentml->wid, currentml->gc, 8, 3 * currentml->gr_height - 3,
			str, -1, GR_TFASCII);
}
Exemplo n.º 10
0
//displays the type of wave being played or PAUSED
void generator_draw_text(char *text )
{
	int width;
	
	width = strlen(text)*7; 			

	//erase the previous 
	GrSetGCForeground( generator_gc, WHITE );
	GrFillRect( generator_wid, generator_gc, 0, 40, screen_info.cols, 30 );
	
	//draw  
	GrSetGCForeground( generator_gc, BLACK );
	GrText( generator_wid, generator_gc, (screen_info.cols-width)/2, 60, text, -1, GR_TFASCII );

}
Exemplo n.º 11
0
static void poddraw_cls( void )
{
	int x;

	GrSetGCForeground( poddraw_gc, colors[poddraw_color]);
	GrFillRect( poddraw_wid, poddraw_gc, 0, 0, 
		    screen_info.cols,
		    screen_info.rows - HEADER_TOPLINE );

	for( x=0 ; 
	     x< (screen_info.cols * (screen_info.rows - HEADER_TOPLINE)) ;
	     x++ )
	{
	    poddraw_buffer[x] = colors[poddraw_color];
	}
}
Exemplo n.º 12
0
/*
 * Here when an exposure event occurs.
 */
static void
do_exposure(GR_EVENT_EXPOSURE *ep)
{
	struct app_info	* act;
	int app_no;

	if (ep->wid == w1) {
		for(act=Apps,app_no=0;act->app_id[0]!='\0';act++,app_no++) {
			GrText(w1, gc, 2, 2 + fheight * (app_no + 1),
				act->app_id, -1, GR_TFBOTTOM);
		}
	} else if (ep->wid == GR_ROOT_WINDOW_ID) {
		GrFillRect(GR_ROOT_WINDOW_ID, bgc, ep->x, ep->y,
				ep->width, ep->height);
	}
}
Exemplo n.º 13
0
/*
 * Here when an exposure event occurs.
 */
void
do_exposure(GR_EVENT_EXPOSURE	*ep)
{
	GR_POINT	points[3];

	if (ep->wid != w1)
		return;
	points[0].x = 311;
	points[0].y = 119;
	points[1].x = 350;
	points[1].y = 270;
	points[2].x = 247;
	points[2].y = 147;

	GrFillRect(w1, gc2, 50, 50, 150, 200);
	GrFillPoly(w1, gc2, 3, points);
}
Exemplo n.º 14
0
/* redraw everything */
static void lights_do_draw( void )
{
	int w;
	int x, y;
	char buf[32];

	/* start clear */
	GrSetGCForeground( lights_gc, GR_RGB(0,0,0) );
	GrFillRect( lights_bufwid, lights_gc, 0, 0,
		    lights_screen_info.cols, lights_height );

	/* draw the buttons */
	w=0;
	for( y=0 ; y<lights_count ; y++ )
	{
		for( x=0 ; x<lights_count ; x++ )
		{
			lights_draw_button( lights_x+(lights_size*x),
				     1+(lights_size*y), w );
			w++;
		}
	}

	/* draw the stats */
	GrSetGCForeground( lights_gc, GR_RGB(255,255,255) );
	GrText( lights_bufwid, lights_gc, 3, 20, "Mov", 3, GR_TFASCII );
	snprintf( buf, 16, "%2d", lights_nmoves );
	GrText( lights_bufwid, lights_gc, 5, 35, buf, 3, GR_TFASCII );

	GrText( lights_bufwid, lights_gc, 3, 70, "Lit", 3, GR_TFASCII );
	snprintf( buf, 16, "%2d", lights_litcount );
	GrText( lights_bufwid, lights_gc, 5, 85, buf, 3, GR_TFASCII );

	/* copy the buffer into place */
	GrCopyArea( lights_wid, lights_gc, 0, 0,
		    lights_screen_info.cols, 
		    (screen_info.rows - (HEADER_TOPLINE + 1)),
		    lights_bufwid, 0, 0, MWROP_SRCCOPY);

	if( !lights_won && lights_litcount==0 )
	{
		lights_won = 1;
		snprintf( buf, 32, "You won in %d moves!", lights_nmoves );
		new_message_window( buf );
	}
}
Exemplo n.º 15
0
static void draw_volume()
{
	int vol;
	int bar_length;

	vol = dsp_get_volume(&dspz);
	bar_length = (vol * (rect_x2-rect_x1-4)) / 100;

	GrSetGCForeground(mp3_gc, GR_RGB(255,255,255));
	GrFillRect(mp3_wid, mp3_gc, rect_x1, rect_y1-12, rect_x2-rect_x1+1, 10);
	GrSetGCForeground(mp3_gc, GR_RGB(0,0,0));

	GrText(mp3_wid, mp3_gc, rect_x1, rect_y1-2, "0", -1, GR_TFASCII);
	GrText(mp3_wid, mp3_gc, rect_x2-20, rect_y1-2, "100", -1, GR_TFASCII);
	GrText(mp3_wid, mp3_gc, 50, rect_y1-2, "volume", -1, GR_TFASCII);
	draw_bar(bar_length);
}
Exemplo n.º 16
0
void
draw_clock(int x, int y, int w, int h, GR_WINDOW_ID pmap, GR_GC_ID gc,
	   GR_WINDOW_ID window)
{
    int i;

    GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_WINDOW));
    GrFillRect(pmap, gc, 0, 0, w, h);

    tick();
    push_matrix();
    translate(x + w / 2.0 - .5, y + h / 2.0 - .5);
    scale_xy((w - 1) / 28.0, (h - 1) / 28.0);
    if (type() == ROUND_CLOCK) {
	GrSetGCForeground(gc, BLACK);
	begin_polygon();
	circle(0, 0, 14, pmap, gc, w, h);
	end_polygon(pmap, gc);
	GrSetGCForeground(gc, BLACK);
	begin_loop();
	circle(0, 0, 14, pmap, gc, w, h);
	end_loop(pmap, gc);
    }
    //draw the shadows
    push_matrix();
    translate(0.60, 0.60);
    draw_clock_hands(LTGRAY, LTGRAY, pmap, gc);
    pop_matrix();
    //draw the tick marks
    push_matrix();
    GrSetGCForeground(gc, BLACK);
    for (i = 0; i < 12; i++) {
	if (6 == i)
	    rect(-0.5, 9, 1, 2, pmap, gc);
	else if (3 == i || 0 == i || 9 == i)
	    rect(-0.5, 9.5, 1, 1, pmap, gc);
	else
	    rect(-0.25, 9.5, .5, 1, pmap, gc);
	rotate(-30);
    }
    pop_matrix();
    //draw the hands
    draw_clock_hands(GRAY, BLACK, pmap, gc);
    pop_matrix();
    GrCopyArea(window, gc, 0, 0, w, h, pmap, 0, 0, MWROP_SRCCOPY);
}
Exemplo n.º 17
0
static void mp3_do_draw()
{
	GrSetGCForeground(mp3_gc, GR_RGB(255,255,255));
	GrFillRect(mp3_wid, mp3_gc, 0, 0, screen_info.cols, screen_info.rows);
	GrSetGCForeground(mp3_gc, GR_RGB(0,0,0));

	GrText(mp3_wid, mp3_gc, 8, 20, current_pos, -1, GR_TFASCII);
	GrText(mp3_wid, mp3_gc, 8, 34, current_title, -1, GR_TFASCII);
	GrText(mp3_wid, mp3_gc, 8, 48, current_artist, -1, GR_TFASCII);
	GrText(mp3_wid, mp3_gc, 8, 62, current_album, -1, GR_TFASCII);
	rect_x1 = 8;
	rect_x2 = screen_info.cols - 8;
	rect_y1 =  screen_info.rows - (HEADER_TOPLINE + 1) - 18;
	rect_y2 =  screen_info.rows - (HEADER_TOPLINE + 1) - 8;
	GrRect(mp3_wid, mp3_gc, rect_x1, rect_y1, rect_x2-rect_x1, rect_y2-rect_y1);

	rect_wait = 0;
	draw_time();
}
Exemplo n.º 18
0
// Draws a box with the score a person got and their high score.
static void draw_result()
{
	char strScore[30];
	char strHighScore[35];
	int height, width, base;
	sprintf(strScore, "Score:%li", score);
	if (highScore < score)
		highScore = score;
	sprintf(strHighScore, "High Score:%li", highScore);
	GrGetGCTextSize(tunnel_gc, strHighScore, -1, GR_TFASCII, &width, &height, &base);
	
	GrSetGCForeground(tunnel_gc, WHITE);
	GrFillRect(tunnel_wid, tunnel_gc, (wi.width - width) / 2 - 3, wi.height / 2 - height - 3, width + 8, height * 2 + 2);
	GrSetGCForeground(tunnel_gc, BLACK);
	GrRect(tunnel_wid, tunnel_gc, (wi.width - width) / 2 - 3, wi.height / 2 - height - 3, width + 8, height * 2 + 2);
	GrText (tunnel_wid, tunnel_gc, (wi.width - width) / 2, wi.height / 2 - height / 2 + 2, strScore, -1, GR_TFASCII );
	GrText (tunnel_wid, tunnel_gc, (wi.width - width) / 2, wi.height / 2 + height / 2 + 2, strHighScore, -1, GR_TFASCII );
	
}
Exemplo n.º 19
0
static void makemenu(void){
	char itiziteki[10];
	GrSetGCForeground(keyman_gc, WHITE);
	GrFillRect(mainmenu_pixmap,keyman_gc,0,0,160,128);
	
	GrCopyArea(mainmenu_pixmap,keyman_gc,40,16,80,16,yomipict_pixmap,48,64,0);
	
	GrCopyArea(mainmenu_pixmap,keyman_gc,26,46,32,48,yomipict_pixmap,0,32,0);
	GrCopyArea(mainmenu_pixmap,keyman_gc,58,46,32,48,yomipict_pixmap,8,32,0);
	GrCopyArea(mainmenu_pixmap,keyman_gc,90,46,40,48,yomipict_pixmap,8,32,0);
	
	GrCopyArea(mainmenu_pixmap,keyman_gc,26,78,32,32,yomipict_pixmap,0,48,0);
	GrCopyArea(mainmenu_pixmap,keyman_gc,58,78,32,32,yomipict_pixmap,8,48,0);
	GrCopyArea(mainmenu_pixmap,keyman_gc,90,78,40,32,yomipict_pixmap,8,48,0);
	
	//GrCopyArea(mainmenu_pixmap,keyman_gc,120,80,32,32,yomipict_pixmap,0,80,MWROP_BLACKNESS);
	
	GrSetGCForeground(keyman_gc, BLACK);
	GrText(mainmenu_pixmap,keyman_gc,81,32,"for iPod",-1,GR_TFASCII|GR_TFTOP);
	GrSetGCForeground(keyman_gc, BLACK);
	GrText(mainmenu_pixmap,keyman_gc,31,50,"Key ",-1,GR_TFASCII|GR_TFTOP);
	GrText(mainmenu_pixmap,keyman_gc,31,60,"Stage",-1,GR_TFASCII|GR_TFTOP);
	GrText(mainmenu_pixmap,keyman_gc,31,70,"Start",-1,GR_TFASCII|GR_TFTOP);
	GrText(mainmenu_pixmap,keyman_gc,31,80,"Training",-1,GR_TFASCII|GR_TFTOP);
	GrText(mainmenu_pixmap,keyman_gc,31,90,"Quit",-1,GR_TFASCII|GR_TFTOP);
	
	GrSetGCForeground(keyman_gc, BLACK);
	if (wmenukey.KEY==1){strcpy(itiziteki,"for G3 type");}
	else {strcpy(itiziteki,"for G4 type");}
	GrText(mainmenu_pixmap,keyman_gc,71,50,itiziteki,-1,GR_TFASCII|GR_TFTOP);
	sprintf(itiziteki,"%d",wmenukey.STAGE);
	GrText(mainmenu_pixmap,keyman_gc,101,60,itiziteki,-1,GR_TFASCII|GR_TFTOP);
			
			//GrText(mainmenu_pixmap,keyman_gc,-150,0,pathmap,-1,GR_TFASCII|GR_TFTOP);
			
	if (wmenukey.ANI<3){wmenukey.ANI++;}
	else {wmenukey.ANI=0;}
	GrCopyArea(mainmenu_pixmap,keyman_gc,85,73,32,32,yomipict_pixmap,(wmenukey.ANI*32),80,0);
			
	GrCopyArea(mainmenu_pixmap,keyman_gc,12,(48+(wmenukey.BA*10)),14,16,yomipict_pixmap,112,48,0);
	
	
}
Exemplo n.º 20
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.º 21
0
static void msg_do_draw()
{
	GR_WINDOW_INFO winfo;
	int i;

	GrGetWindowInfo(msg_wid, &winfo);

	/* fill the background */
	GrSetGCForeground(msg_gc, appearance_get_color( 
				(this_is_error)?CS_ERRORBG:CS_MESSAGEBG ));
	GrFillRect( msg_wid, msg_gc, 0, 0, winfo.width, winfo.height );

	GrSetGCForeground(msg_gc, appearance_get_color( CS_MESSAGELINE ));
	GrRect(msg_wid, msg_gc, 1, 1, winfo.width - 2, winfo.height - 2);

	GrSetGCForeground(msg_gc, appearance_get_color( CS_MESSAGEFG ));
	for(i=linenum; i; i--)
		GrText(msg_wid, msg_gc, 5, (((winfo.height-10) /
				linenum) * i), msglines[i-1], -1,
				GR_TFASCII);
}
Exemplo n.º 22
0
void draw_well(nstate *state, int forcedraw)
{
	int x, y;

	for(y = WELL_NOTVISIBLE; y < WELL_HEIGHT; y++) {
		for(x = 0; x < WELL_WIDTH; x++) {
			if(forcedraw || (state->blocks[0][y][x] !=
						state->blocks[1][y][x])) {
				state->blocks[1][y][x] = state->blocks[0][y][x];
				GrSetGCForeground(state->wellgc,
							state->blocks[0][y][x]);
				GrFillRect(state->well_window, state->wellgc,
					(BLOCK_SIZE * x),
					(BLOCK_SIZE * (y - WELL_NOTVISIBLE)),
						BLOCK_SIZE, BLOCK_SIZE);
			}
		}
	}

	GrFlush();
}
Exemplo n.º 23
0
static void update_score()
{
	char s[24];

	GrSetGCForeground(invaders_gc, GR_RGB(255,255,255));
	GrFillRect(invaders_score_pix, invaders_gc, 0, 0,
			screen_info.cols, 13);
	GrSetGCForeground(invaders_gc, GR_RGB(0,0,0));
	sprintf(s, "Score %.5d", score);
	vector_render_string(invaders_score_pix, invaders_gc, s, 1, 1, 2, 2);
	if(score > high_score)
		high_score = score;
	if(screen_info.cols < 150)
		sprintf(s, "Top: %.5d", high_score);
	else
		sprintf(s, "HiScore: %.5d", high_score);
	vector_render_string_right(invaders_score_pix, invaders_gc, s, 1, 1,
			screen_info.cols - 2, 2);
	GrCopyArea(invaders_wid, invaders_gc, 0, 0, screen_info.cols, 12,
			invaders_score_pix, 0, 0, 0);
}
Exemplo n.º 24
0
void CObjectRect::Draw()
{
	if(m_wid && m_gc)
	{
		GrSetGCForeground(m_gc, m_Color);
		if(m_isFill)
		{
			GrFillRect(m_wid, m_gc, m_rect.x, m_rect.y, m_rect.w, m_rect.h);
		}
		else if(m_isDash)
		{
			GrSetGCLineAttributes(m_gc, GR_LINE_ONOFF_DASH);
			GrSetGCDash(m_gc, g_dash_patern, 2);
			GrRect(m_wid, m_gc, m_rect.x, m_rect.y, m_rect.w, m_rect.h);
			GrSetGCLineAttributes(m_gc, GR_LINE_SOLID);
		}
		else
		{
			GrRect(m_wid, m_gc, m_rect.x, m_rect.y, m_rect.w, m_rect.h);
		}
	}
}
Exemplo n.º 25
0
static void draw_time()
{
	int bar_length, elapsed;
	char buf[256];
	struct tm *tm;
	time_t tot_time;

	elapsed= total_time - remaining_time;
	bar_length= (elapsed * (rect_x2-rect_x1-4)) / total_time;

	GrSetGCForeground(mp3_gc, GR_RGB(255,255,255));
	GrFillRect(mp3_wid, mp3_gc, rect_x1, rect_y1-12, rect_x2-rect_x1+1, 10);
	GrSetGCForeground(mp3_gc, GR_RGB(0,0,0));

	GrText(mp3_wid, mp3_gc, rect_x1, rect_y1-2, "0", -1, GR_TFASCII);
	tot_time = total_time / 1000;
	tm = gmtime(&tot_time);
	sprintf(buf, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
	GrText(mp3_wid, mp3_gc, rect_x2-43, rect_y1-2, buf, -1, GR_TFASCII);
	GrText(mp3_wid, mp3_gc, 50, rect_y1-2, "time", -1, GR_TFASCII);
	draw_bar(bar_length);
}
Exemplo n.º 26
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.º 27
0
void char_out(GR_CHAR ch)
{
	switch(ch) {
	case '\r':
		xpos = 0;
		return;
	case '\n':
		ypos += height;
		if(ypos > si.rows - 60 - height) {
			ypos -= height;
#if HAVEBLIT
			bogl_cfb8_blit(50, 30, si.cols-120,
				si.rows-60-height, 50, 30+height);
			GrFillRect(w1, gc3, 50, ypos, si.cols-120, height);
#else
			/* FIXME: changing FALSE to TRUE crashes nano-X*/
			/* clear screen, no scroll*/
			ypos = 0;
			GrClearWindow(w1, GR_FALSE);
#endif
		}
		return;
	case '\007':			/* bel*/
		return;
	case '\t':
		xpos += width;
		while((xpos/width) & 7)
			char_out(' ');
		return;
	case '\b':			/* assumes fixed width font!!*/
		if (xpos <= 0)
			return;
		char_del(xpos, ypos);
		return;
	}
	GrText(w1, gc1, xpos+1, ypos, &ch, 1, GR_TFTOP);
	xpos += width;
}
Exemplo n.º 28
0
void generator_dash( int x, int y )
{
	GrSetGCForeground( generator_gc, BLACK );
	GrFillRect( generator_wid, generator_gc, 2+x, 10+y, 13, 4 );

}
Exemplo n.º 29
0
int
main(int ac,char **av)
{
	GR_WINDOW_ID 	w;
	GR_GC_ID	gc;
	GR_FONT_ID	font;
	GR_WINDOW_INFO wi;

	if (GrOpen() < 0) {
		GrError("Can't open graphics\n");
		return 1;
	}

	//w = GrNewWindowEx(GR_WM_PROPS_APPWINDOW|GR_WM_PROPS_NOBACKGROUND, "Nano-X Demo2",
		//GR_ROOT_WINDOW_ID, 20, 20, 320, 240, BLACK);
	w = GrNewWindowEx(GR_WM_PROPS_BORDER|GR_WM_PROPS_NOBACKGROUND, "Nano-X Demo2",
		GR_ROOT_WINDOW_ID, 20, 20, 320, 240, BLACK);

	gc = GrNewGC();
	//font = GrCreateFontEx("lubI24.pcf", 0, 0, NULL);
	font = GrCreateFontEx("helvB12.pcf.gz", 0, 0, NULL);
	GrSetGCFont(gc, font);

	GrSelectEvents(w, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_CLOSE_REQ
		| GR_EVENT_MASK_BUTTON_DOWN | GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP);
	GrMapWindow(w);
	GrSetFocus(w);

	// pass errors through main loop
	GrSetErrorHandler(NULL);

	for (;;) {
		GR_EVENT 	event;

		GrGetNextEvent(&event);

		switch (event.type) {
		case GR_EVENT_TYPE_EXPOSURE:
			GrSetGCForeground(gc,GrGetSysColor(GR_COLOR_APPWINDOW));
			GrFillRect(w, gc, event.exposure.x, event.exposure.y,
				event.exposure.width, event.exposure.height);
			GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_APPTEXT));
			GrSetGCUseBackground(gc, GR_FALSE);
			GrText(w, gc, 10, 30, "Hello World", -1, GR_TFASCII);
            GrRect(w, gc, 5, 5, 300, 60);
			GrGetWindowInfo(w, &wi);
			GrError("Exposure:wi.width:%d,wi.height:%d,wi.x:%d,wi.y:%d,wi.parent:%d\n",wi.width,wi.height,wi.x,wi.y,wi.parent);
			break;

		case GR_EVENT_TYPE_BUTTON_DOWN:
			// FIXME unmap window is broken
			GrUnmapWindow(w);
			GrFlush();
			GrMapWindow(w);

			//uncomment to test server error on bad syscall
			//GrMoveWindow(GR_ROOT_WINDOW_ID, 0, 0);

			GrGetWindowInfo(w, &wi);
			GrError("Button:  wi.width:%d,wi.height:%d,wi.x:%d,wi.y:%d,wi.parent:%d\n",wi.width,wi.height,wi.x,wi.y,wi.parent);
			break;

		case GR_EVENT_TYPE_ERROR:
			GrError("demo2: Error (%s) ", event.error.name);
			GrError(nxErrorStrings[event.error.code], event.error.id);
			break;

		case GR_EVENT_TYPE_CLOSE_REQ:
			GrClose();
			return 0;
		}
	}
	return 0;
}
Exemplo n.º 30
0
void char_del(GR_COORD x, GR_COORD y)
{
	xpos -= width;
	GrFillRect(w1, gc3, x, y /*- height*/ /*+ base*/ + 1, width, height);
}