Esempio n. 1
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]);
}
Esempio n. 2
0
static void idw_draw_sheet(TSheet *sheet) {
  GR_SIZE width, height, base;
  char str[50], *ap;
  int i;
	
	if (sheet == NULL) {
    sheet = game.screen->menuitems[game.select].sheet;
  }
	
	// draw the title
  pz_draw_header (sheet->title);

  GrGetGCTextSize(idw_gc, sheet->button, -1, GR_TFASCII, &width, &height, &base);
  height+=4;  
  
  // (left, top, right, bottom)
  GrSetGCForeground(idw_gc, BLACK);
  GrLine(idw_wid, idw_gc, 20, 0, 20, screen_info.rows-44);
  GrLine(idw_wid, idw_gc, 20, screen_info.rows-44, screen_info.cols-20, screen_info.rows-44);
  GrLine(idw_wid, idw_gc, screen_info.cols-20, 0, screen_info.cols-20, screen_info.rows-44);
  
	GrSetGCForeground(idw_gc, WHITE);
  GrFillRect(idw_wid, idw_gc, 21, 0, screen_info.cols-41, screen_info.rows-44);
	GrSetGCForeground(idw_gc, BLACK);
  GrSetGCUseBackground(idw_gc, GR_FALSE);
  GrSetGCMode(idw_gc, GR_MODE_SET);
  
  ap = strtok(sheet->text, "\n");
  for (i=0; ap != NULL; i++) {
    GrText(idw_wid, idw_gc, 30, 1 + ((i + 1) * height - 4), ap, -1, GR_TFASCII);
    ap = strtok(NULL, "\n");
  }
  
	if (sheet->ammount != -1)
	{
    // print ammount
    sprintf(str, "Ammount: %d", game.ammount);
    GrText(idw_wid, idw_gc, 30, 50, str, -1, GR_TFASCII);
  } else {
    // the next time the user presses the middle button the sheet will disappear
    game.dismiss_sheet = 1;
  }

  // print the single menu option
  GrSetGCForeground(idw_gc, BLACK);
  GrFillRect(idw_wid, idw_gc, 21, 1 + 4 * height-4, screen_info.cols-41, height-1);
  GrSetGCForeground(idw_gc, WHITE);
  GrSetGCUseBackground(idw_gc, GR_TRUE);

  GrText(idw_wid, idw_gc, (screen_info.cols/2)-width+4, (5 * height - 8), sheet->button, -1, GR_TFASCII);

  // we're in a transaction
  game.in_transaction = 1;  
}
Esempio n. 3
0
static void idw_draw_screen() {
  int i, dif=0, max=0;
  GR_SIZE width, height, base;
  	
	// This white line is printed because the sheet leaves two pixels
  GrSetGCForeground(idw_gc, WHITE);
  GrLine(idw_wid, idw_gc, 0, 0, screen_info.cols, 0);
  GrSetGCForeground(idw_gc, BLACK);
	
	// calculate the biggest space you can leave for the right-side column
	for (i=0; i < game.screen->count; i++)
	{
	  GrGetGCTextSize(idw_gc, game.screen->menuitems[i].value, -1, GR_TFASCII, &width, &height, &base);
    width+=5;
    
    if (width > max) max = width;
	}

  GrGetGCTextSize(idw_gc, "M", -1, GR_TFASCII, &width, &height, &base);
	height += 4;

  
  // print all the menus
  for (i=0; i < game.screen->count; i++)
  {
    if ((game.select == i) && (game.screen->menuitems[i].sheet)) {
			GrSetGCForeground(idw_gc, BLACK);
			GrFillRect(idw_wid, idw_gc, 0, 1 + i * height, screen_info.cols, height);
			GrSetGCForeground(idw_gc, WHITE);
			GrSetGCUseBackground(idw_gc, GR_TRUE);
		} else
		{
			GrSetGCUseBackground(idw_gc, GR_FALSE);
			GrSetGCForeground(idw_gc, WHITE);
			GrFillRect(idw_wid, idw_gc, 0, 1 + i * height, screen_info.cols, height);
			GrSetGCForeground(idw_gc, BLACK);
		}
		
		// highlite drug's name if you can make a positive sale
		if ((game.screen == &sell) && (game.drugs[i])) {
      dif = (game.price[i]*game.drugs[i] - game.old_price[i]);
    
      if (dif > 0) {
        GrText(idw_wid, idw_gc, 9, 1 + ((i + 1) * height - 4), game.screen->menuitems[i].caption, -1, GR_TFASCII);
      }
    }
    
    GrText(idw_wid, idw_gc, 8, 1 + ((i + 1) * height - 4), game.screen->menuitems[i].caption, -1, GR_TFASCII);
    
    // right-side column
    GrText(idw_wid, idw_gc, screen_info.cols - max, 1 + ((i + 1) * height - 4), game.screen->menuitems[i].value, -1, GR_TFASCII);
  }
}
Esempio n. 4
0
static void kmbitmap(void){
	
	GrSetGCUseBackground(keyman_gc, GR_FALSE); 
	GrSetGCForeground(keyman_gc, BLACK); 
	switch(wnow.shupict){
		case 0:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap1_black);break;
		case 1:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap2_black);break;
		case 2:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap3_black);break;
	}
	GrSetGCForeground(keyman_gc, GRAY); 
	switch(wnow.shupict){
		case 0:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap1_gray);break;
		case 1:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap2_gray);break;
		case 2:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap3_gray);break;
	} 
	GrSetGCForeground(keyman_gc, LTGRAY); 
	switch(wnow.shupict){
		case 0:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap1_ltgray);break;
		case 1:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap2_ltgray);break;
		case 2:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap3_ltgray);break;
	}
	GrSetGCForeground(keyman_gc, WHITE); 
	switch(wnow.shupict){
		case 0:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap1_white);break;
		case 1:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap2_white);break;
		case 2:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap3_white);break;
	}

}
Esempio n. 5
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();
}
Esempio n. 6
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();
}
Esempio n. 7
0
void new_video_window(char *filename)
{
#ifndef IPOD
	pz_error("No video support on the desktop.");
#else /* IPOD */

	if (full_hw_version==0)
	{
		full_hw_version = ipod_get_hw_version();
	}
	outl(1, VAR_VIDEO_ON);
	outl(0, VAR_VIDEO_MODE);
	cop_wakeup();
	init_variables();
	video_status = VIDEO_CONTROL_MODE_STARTING; 
	video_curPosition = 0;
	video_gc = pz_get_gc(1);
	GrSetGCUseBackground(video_gc, GR_FALSE);
	GrSetGCForeground(video_gc, GR_RGB(0,0,0));
//nes_window("Create win");
	video_wid = pz_new_window(0, 0, screen_info.cols, screen_info.rows, video_do_draw, video_do_keystroke);

	GrSelectEvents(video_wid, 
			GR_EVENT_MASK_KEY_DOWN| GR_EVENT_MASK_KEY_UP);
	GrMapWindow(video_wid);

	GrClearWindow(video_wid, GR_FALSE);
//nes_window("Load");
	video_status_message("Loading video...");
//nes_window("Play");	
playVideo(filename);
	outl(0, VAR_VIDEO_ON);
#endif
}
Esempio n. 8
0
void new_cube_window( void )
{
	if (screen_info.cols==220) {
		photo = 1;
		if (!z_off) z_off = 400;
	} else if (screen_info.cols==138) {
		if (!z_off) z_off = 800;
	} else {
		if (!z_off) z_off = 600;
	}

	cube_gc = pz_get_gc(1);
	GrSetGCUseBackground(cube_gc, GR_FALSE);
	GrSetGCForeground(cube_gc, BLACK);

	cube_wid = pz_new_window(0, HEADER_TOPLINE + 1, 
	screen_info.cols, screen_info.rows - (HEADER_TOPLINE + 1), 
	cube_do_draw, cube_handle_event);

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

    cube_timer = GrCreateTimer( cube_wid, 100 );

	GrMapWindow( cube_wid );

	x_off = screen_info.cols/2;
	y_off = (screen_info.rows - (HEADER_TOPLINE + 1))/2;

	temp_pixmap = GrNewPixmap(screen_info.cols,
								(screen_info.rows - (HEADER_TOPLINE + 1)),
						 		NULL);
	
	cube_init();	
}
Esempio n. 9
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;
}
Esempio n. 10
0
void new_message_common_window(char *message)
{
	GR_SIZE width, height, base;
	int i, maxwidth;

	if (msg_wid) {
		msg_destroy_msg();
	}

	msg_gc = pz_get_gc(1);
	GrSetGCUseBackground(msg_gc, GR_FALSE);
	GrSetGCForeground(msg_gc, appearance_get_color( CS_MESSAGEFG ));

	msg_build_msg(message);
	maxwidth = 0;
	for(i=linenum; i; i--) {
		GrGetGCTextSize(msg_gc, msglines[i-1], -1, GR_TFASCII, &width,
				&height, &base);
		if(width > maxwidth)
			maxwidth = width;
	}

	msg_wid = pz_new_window((screen_info.cols - (maxwidth + 10)) >> 1,
		(screen_info.rows - (((height + 3) * linenum) + 10)) >> 1,
		maxwidth + 10, ((height + 3) * linenum) + 10,
		msg_do_draw, msg_do_keystroke);

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

	GrMapWindow(msg_wid);

	/* window will auto-close after 6 seconds */
	msg_timer = GrCreateTimer(msg_wid, 6000);
}
Esempio 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');
}
Esempio n. 12
0
int main (void)
{
    if (GrOpen() < 0)
    {
        GrError("GrOpen failed");
        return 1;
    }

    gc = GrNewGC();
    GrSetGCUseBackground (gc, GR_FALSE);
    GrSetGCForeground (gc, RED);

    wid = GrNewWindowEx (GR_WM_PROPS_APPFRAME |
                         GR_WM_PROPS_CAPTION  |
                         GR_WM_PROPS_CLOSEBOX,
                         "Hello Window",
                         GR_ROOT_WINDOW_ID, 
                         50, 50, 200, 100, WHITE);

    GrSelectEvents (wid, GR_EVENT_MASK_EXPOSURE | 
                         GR_EVENT_MASK_CLOSE_REQ);

    GrMapWindow (wid);
    GrMainLoop (event_handler);
}
Esempio n. 13
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);
}
Esempio n. 14
0
/* note: unused Drawable d */
GC
XCreateGC(Display *dpy, Drawable d, unsigned long valuemask, XGCValues *values)
{
	GC gc;
	XGCValues *vp;

	if ((gc = (GC) Xmalloc(sizeof(struct _XGC))) == NULL)
		return NULL;
	if ((vp = (XGCValues *)Xmalloc(sizeof(XGCValues))) == NULL) {
		Xfree(gc);
		return NULL;
	}
	gc->ext_data = (XExtData *)vp;
	memcpy(vp, &initial_GC, sizeof(initial_GC));
	gc->gid = GrNewGC();

	/* X11 doesn't draw background, must set on all GrNewGC's*/
	GrSetGCUseBackground(gc->gid, GR_FALSE);

	/* X11 defaults to fg=black, bg=white, NX is opposite...*/
	if (!(valuemask & GCForeground))
		XSetForeground(dpy, gc, 0L);	/* black*/
	if (!(valuemask & GCBackground))
		XSetBackground(dpy, gc, ~0L);	/* white*/

	setupGC(dpy, gc, valuemask, values);
	return gc;
}
Esempio n. 15
0
static void
GrSetGCUseBackgroundWrapper(void *r)
{
	nxSetGCUseBackgroundReq *req = r;

	GrSetGCUseBackground(req->gcid, req->flag);
}
Esempio n. 16
0
/* initialize the window */
void new_lights_window(void)
{
	/* Init randomizer */
	srand(time(NULL));

	lights_gc = pz_get_gc (1);
        GrSetGCUseBackground(lights_gc, GR_FALSE);
        GrSetGCForeground(lights_gc, GR_RGB(0,0,0));

	lights_height = (lights_screen_info.rows - (HEADER_TOPLINE + 1));

	lights_wid = pz_new_window( 0, HEADER_TOPLINE + 1,
		    screen_info.cols, lights_height,
		    lights_do_draw, lights_handle_event );

	lights_bufwid = GrNewPixmap( lights_screen_info.cols, 
					lights_height, NULL );

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

	lights_timer = GrCreateTimer( lights_wid, 300 );

	GrMapWindow( lights_wid );

	/* intialize game state */
	lights_new_game();
}
Esempio n. 17
0
static void draw_dialer() {
    GR_SIZE width, height, base;

    GrSetGCUseBackground(dialer_gc, GR_FALSE);
    GrSetGCForeground(dialer_gc, GR_RGB(0,0,0));
    GrGetGCTextSize(dialer_gc, digitdisplay, -1, GR_TFASCII, &width, &height, &base);
    /*
    GrRect(dialer_wid, dialer_gc, CXOFF, CYOFF, CWIDTH, cbh);
    GrSetGCForeground(dialer_gc, GR_RGB(255,255,255));
    GrFillRect(dialer_wid, dialer_gc, CXOFF+1, CYOFF+1, CWIDTH-2, cbh-2);
    GrSetGCForeground(dialer_gc, GR_RGB(0,0,0));
    GrText(dialer_wid, dialer_gc, CXOFF+(CWIDTH-width-4),
    	CYOFF+((cbh/2)-(height/2)), digitdisplay, -1, GR_TFASCII|GR_TFTOP);
    */

    /* range check */
    if(current_dialer_button < 0)
        current_dialer_button = 15;
    else if(current_dialer_button >= 16)
        current_dialer_button = 0;

    /* compute button sizings */
    xlocal=CXOFF+((cbw+cxgap)*(current_dialer_button%4));
    ylocal=CBYOFF+((cbh+cygap)*(current_dialer_button/4));
    lastxlocal=CXOFF+((cbw+cxgap)*(last_bouvet_item%4));
    lastylocal=CBYOFF+((cbh+cygap)*(last_bouvet_item/4));

    GrSetGCForeground(dialer_gc, GR_RGB(255,255,255));
    GrFillRect(dialer_wid, dialer_gc, lastxlocal+1, lastylocal+1, cbw-2, cbh-2);
    GrSetGCForeground(dialer_gc, GR_RGB(0,0,0));
    GrGetGCTextSize(dialer_gc, dialerpad[last_bouvet_item], -1, GR_TFASCII,
                    &width, &height, &base);
    GrText(dialer_wid, dialer_gc,
           lastxlocal+((cbw/2)-(width/2)), lastylocal+((cbh/2)-(height/2)),
           dialerpad[last_bouvet_item], -1, GR_TFASCII|GR_TFTOP);
    GrFillRect(dialer_wid, dialer_gc, xlocal, ylocal, cbw, cbh);
    GrSetGCForeground(dialer_gc, GR_RGB(255,255,255));
    GrGetGCTextSize(dialer_gc, dialerpad[current_dialer_button], -1, GR_TFASCII,
                    &width, &height, &base);
    GrText(dialer_wid, dialer_gc,
           xlocal+((cbw/2)-(width/2)), ylocal+((cbh/2)-(height/2)),
           dialerpad[current_dialer_button], -1, GR_TFASCII|GR_TFTOP);
    GrSetGCUseBackground(dialer_gc, GR_FALSE);
    GrSetGCMode(dialer_gc, GR_MODE_SET);
}
Esempio n. 18
0
//------------------------------------------------------------------------------
// Function Name  : ui_draw_text_window()
// Description    : 
//------------------------------------------------------------------------------
void ui_draw_text_window(GR_WINDOW_ID wid, int x, int y, int w, int h,
			u32 size, u32 co, u32 align, char *str)
{
	int align_x, align_y, len, width, height, base;
	GR_GC_INFO gc_info;
	
	GrGetGCInfo(g_gc, &gc_info);
	GrSetGCUseBackground(g_gc, FALSE);
	GrSetGCForeground(g_gc, co);
	GrSetFontSizeEx(g_font, size, size);

	len = strlen(str);

	align_x = x;
	align_y = y;
	if (align != TXT_ALIGN_NONE) {
		GrGetGCTextSize(g_gc, str, len, MWTF_DBCS_EUCKR,
			&width, &height, &base);

		// horizontal align
		if (align & TXT_HALIGN_CENTER) {
			if (width < w) 
				align_x = x + ((w - width) / 2);
		} else if (align & TXT_HALIGN_RIGHT) {
			if (width < w) 
				align_x = x + (w - width);
		}

		// vertical align
		if (align & TXT_VALIGN_MIDDLE) {
			if (height < h) 
				align_y = y + ((h - height) / 2);
		} else if (align & TXT_VALIGN_BOTTOM) {
			if (height < h) 
				align_y = y + (h - height);
		}
	}

	GrText(wid, g_gc, align_x, align_y, str, len, MWTF_DBCS_EUCKR|GR_TFTOP);

	//Recover GC Info
	GrSetGCUseBackground(g_gc, gc_info.usebackground);
	GrSetGCForeground(g_gc, gc_info.foreground);
}
Esempio n. 19
0
void CObjectButton::Draw()
{
//	printf("+%s\r\n", __func__);
	if(m_wid && m_gc && m_Image)
	{
		GrSetGCUseBackground(m_gc, FALSE);
		GrDrawImageToFit(m_wid, m_gc, m_rect.x, m_rect.y, m_rect.w, m_rect.h, m_Image[m_idxImage]);
	}
//	printf("-%s\r\n", __func__);
}
Esempio n. 20
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;
}
Esempio n. 21
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);
		}
	}
}
Esempio n. 22
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);
}
Esempio n. 23
0
//------------------------------------------------------------------------------
// Function Name  : init_ui_manager()
// Description    : 
//------------------------------------------------------------------------------
BOOL init_ui_manager(void)
{
	CObject* pObject;
	UINT id;

	PRINT_FUNC_CO();
	
	// start nano-x service
	if (GrOpen() < 0) {
	//	DBGMSG(DBG_MAIN, "[Failure]\r\n--> %s: GrOpen Failed!!\r\n", __func__);
		return FALSE;
	}

	GrSetErrorHandler(error_handler);
	GrGetScreenInfo(&g_scr_info);

	// prepare g_font
	g_font = GrCreateFontEx((GR_CHAR *)FONT_PATH, 18, 18, NULL);
	GrSetFontAttr(g_font, (GR_TFKERNING | GR_TFANTIALIAS), 0);

	g_wid = GrNewWindow(GR_ROOT_WINDOW_ID, 0, 0, g_scr_info.cols, g_scr_info.rows, 0, BLACK, 0);
	if (g_wid == 0) {
	//	DBGMSG(DBG_MAIN, "[Failure]\r\n--> %s: GrNewWindow failure\r\n", __func__);
		GrClose();
		return FALSE;
	}

	g_gc = GrNewGC();

	GrRaiseWindow(g_wid);
	GrMapWindow(g_wid);

	GrSelectEvents(g_wid, GR_EVENT_MASK_BUTTON_DOWN | GR_EVENT_MASK_EXPOSURE);

	GrSetGCUseBackground(g_gc, FALSE);
//	GrSetGCUseBackground(g_gc, TRUE);
	GrSetGCFont(g_gc, g_font);

//	GrSetGCBackground(g_gc, BLACK);
	GrSetGCForeground(g_gc, WHITE);

//	BuildObject();

	return TRUE;
}
Esempio n. 24
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);
}
Esempio n. 25
0
void new_keyman_window( void )
{
	
    keyman_gc = GrNewGC();
    GrSetGCUseBackground(keyman_gc, GR_FALSE);
    GrSetGCForeground(keyman_gc, WHITE);
	GrGetScreenInfo(&screen_info);
	
	yomipict_pixmap=GrNewPixmap(384,128,NULL);
	mainmenu_pixmap=GrNewPixmap(160,128,NULL);
	shu_pixmap=GrNewPixmap(16,16,NULL);
	dialogall_pixmap=GrNewPixmap(96,80,NULL);
	dialog_pixmap=GrNewPixmap(96,80,NULL);
	
	
    keyman_wid = pz_new_window(0, 0, 
	screen_info.cols, screen_info.rows, 
	keyman_do_draw, keyman_handle_event);

		
	if (!(kmimage_id=GrLoadImageFromFile(pathimage,0))){
		GAMEN=NODATA;
		
	}
	else {
		GAMEN=MENU;
		GrDrawImageToFit(yomipict_pixmap,keyman_gc,0,0,384,128,kmimage_id);
		makedialog();
	}
	
	

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

    keyman_timer = GrCreateTimer( keyman_wid, 90 );
    GrMapWindow( keyman_wid );
    pz_draw_header( "KeyMan" );
}
Esempio n. 26
0
void new_poddraw_window( void )
{
	poddraw_alloc_buffer();
	poddraw_gc = pz_get_gc(1);
	GrSetGCUseBackground(poddraw_gc, GR_FALSE);
	GrSetGCForeground(poddraw_gc, BLACK);

	poddraw_wid = pz_new_window(0, HEADER_TOPLINE + 1, 
	    screen_info.cols, screen_info.rows - (HEADER_TOPLINE + 1), 
	    poddraw_do_draw, poddraw_handle_event);

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

	poddraw_timer = GrCreateTimer( poddraw_wid, 100 );

	GrMapWindow( poddraw_wid );
	poddraw_color = 0;
	poddraw_x = screen_info.cols/2;
	poddraw_y = (screen_info.rows - (HEADER_TOPLINE + 1))/2;
	poddraw_cls();
}
Esempio n. 27
0
/**
 * 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);
}
Esempio n. 28
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);
		}
	}
}
Esempio n. 29
0
// Creates window
// Status: Done
void new_generator_window (void)
{
	// Get a copy of the root graphics context
	generator_gc = pz_get_gc( 1 );   
	
	// Set foreground color
	GrSetGCUseBackground( generator_gc, GR_FALSE );
	GrSetGCForeground( generator_gc, BLACK);

	// Open the window
	generator_wid = pz_new_window (0, HEADER_TOPLINE + 1,
				screen_info.cols,  
				screen_info.rows - (HEADER_TOPLINE + 1),
				generator_do_draw,
				generator_handle_event);

	// Select the types of events you need for your window:
	GrSelectEvents( generator_wid, GR_EVENT_MASK_EXPOSURE | 
				GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP );

	// Map the window to the screen:
	GrMapWindow( generator_wid );
	generator_construct();
}
Esempio n. 30
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);
}