// creates a new MandelPod window
void new_mandel_window(void)
{
	// get the graphics context
	mandel_gc = pz_get_gc(1);
		
	// create the main window
	mandel_wid = pz_new_window (0, 21,
				screen_info.cols, screen_info.rows - (HEADER_TOPLINE+1),
				draw_header, handle_event);
#ifdef MANDELPOD_STATUS
	// create the status window
	status_wid = pz_new_window (22, 4, 12, 12, draw_idle_status, handle_event);
#endif
	 // get screen info
	GrGetWindowInfo(mandel_wid, &wi);
	
	// select the event types
	GrSelectEvents (mandel_wid, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP | GR_EVENT_MASK_TIMER);
		
	// display the window
	GrMapWindow (mandel_wid);
#ifdef MANDELPOD_STATUS
	GrMapWindow (status_wid);
#endif

    // create the timer for the busy status animation
    mandel_timer_id = GrCreateTimer (mandel_wid, 250);

	// start main app
	init_values();
	create_status();
	draw_header();
	calculate_mandel();
}
Beispiel #2
0
// Creates a new tunnel "app" window
void new_tunnel_window(void)
{
	
    tunnel_gc = pz_get_gc(1);       /* Get the graphics context */
	
    /* Open the window: */
    tunnel_wid = pz_new_window (0,
								   21,
								   screen_info.cols,
								   screen_info.rows - (HEADER_TOPLINE+1),
								   draw_header,
								   handle_event);
	
	GrGetWindowInfo(tunnel_wid, &wi); /* Get screen info */	
	
    /* Select the types of events you need for your window: */
    GrSelectEvents (tunnel_wid, GR_EVENT_MASK_TIMER|GR_EVENT_MASK_EXPOSURE|GR_EVENT_MASK_KEY_DOWN|GR_EVENT_MASK_KEY_UP);
	
	// set up pixmap 
	temp_pixmap = GrNewPixmap(screen_info.cols,
							  (screen_info.rows - (HEADER_TOPLINE + 1)),
							  NULL);
	
    /* Display the window: */
    GrMapWindow (tunnel_wid);
	draw_header();
	readHighScore();
	reset();
}
Beispiel #3
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();
}
//Create the blackjack window
void new_blackjack_window(void)
{

	srand((unsigned int)time(NULL) / 2);  //Make a seed for our random # generator

    blackjack_gc = pz_get_gc(1);       /* Get the graphics context */

    /* Open the window: */
    blackjack_wid = pz_new_window (0,
								   21,
								   screen_info.cols,
								   screen_info.rows - (HEADER_TOPLINE+1),
								   draw_header,
								   handle_event);

	GrGetWindowInfo(blackjack_wid, &wi); /* Get screen info */

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

    /* Display the window: */
    GrMapWindow (blackjack_wid);

	readPot();
	reset();
}
Beispiel #5
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();	
}
/* create the window */
static PzWindow *new_truchet_window_common( )
{
	/* create the window */
	tglob.window = pz_new_window( "Truchet", PZ_WINDOW_NORMAL );

	tglob.w = tglob.window->w;
	tglob.h = tglob.window->h;
	tglob.fullscreen = 0;

	tglob.bw = (ttk_screen->w/16) +1;
	tglob.bh = (ttk_screen->h/16) +1;

	/* create the widget */
	tglob.widget = pz_add_widget( tglob.window, 
				draw_truchet, event_truchet );

	/* 1 second timeout */
	pz_widget_set_timer( tglob.widget, 250 );

	/* we're waaaay more important than anyone else */
	pz_set_priority(PZ_PRIORITY_VITAL); 

	fill_buffer();

	/* done in here! */
	return pz_finish_window( tglob.window );
}
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);
}
Beispiel #8
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;
}
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();
}
Beispiel #10
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
}
Beispiel #11
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();
}
Beispiel #12
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;
}
static TWindow *list_actions(const char *lpath)
{
	TWindow *ret;
	TWidget *menu;
	char path[MAXPATHLEN], cwd[MAXPATHLEN];

	snprintf( path, MAXPATHLEN, "%s/%s", getcwd(cwd, MAXPATHLEN), lpath);
	ret = pz_new_window(path, PZ_WINDOW_NORMAL);
	menu = pz_browser_get_actions(path);
	ttk_add_widget(ret, menu);
	return pz_finish_window(ret);
}
Beispiel #14
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);
	}
}
Beispiel #15
0
PzWindow *transfer_alt_menu(track_list *tlist, ipod_t src_ipod, queue_fcn qfunc, ttk_menu_item *qitem) {
	TWindow *ret;

	ret = pz_new_window(_("Transfer"), PZ_WINDOW_NORMAL);
    ret->data = 0x12345678;
    
	/* Show data up top: number of tracks, total size */	
	int num_tracks = 0, size=0;
	track_item *titem = tlist->head;
	
	while (titem) {
	   num_tracks++;
	   ipod_track_t track = ipod_track_get_by_track_id(src_ipod, titem->track_id);
	   size += ipod_track_get_attribute(track, IPOD_TRACK_SIZE);
       ipod_track_free(track);
	   titem = titem->next;
	}

	
	/* Add the status widget */
	PzWidget *stats_wid = pz_new_widget(transfer_alt_stat_draw, NULL);
	stat_data *stats = (stat_data *)malloc(sizeof(stat_data));
	stats->num_files = num_tracks;
	stats->total_bytes = size;
	stats_wid->data = stats;
	stats_wid->w = ret->w;
	ttk_add_widget(ret, stats_wid);
	
	
    /* Draw the Menu */	
    int menu_height = (ttk_text_height(ttk_menufont) + 4) * (qfunc? 3 : 2);
    TWidget *menu = ttk_new_menu_widget (transfer_menu_default, ttk_menufont, ttk_screen->w - ttk_screen->wx,
					menu_height);
	menu->y = ttk_screen->h - ttk_screen->wy - menu_height;
	transfer_menu_default[1].data = transfer_menu_default[3].data = tlist;
    if (remote_ipod)
		ttk_menu_append (menu, transfer_menu_default + 1);
	if (qfunc) {
		enqueue_data *eqdata = (enqueue_data *)malloc(sizeof(enqueue_data));		
		eqdata->qfunc = qfunc;
		eqdata->item = qitem;
		transfer_menu_default[2].data = eqdata;
		transfer_menu_default[2].free_data = 1;
		ttk_menu_append(menu, transfer_menu_default + 2);
	}
    ttk_menu_append (menu, transfer_menu_default + 3);
	ttk_add_widget(ret, menu);

	return pz_finish_window(ret);
}
Beispiel #16
0
void new_idw_window()
{
  idw_gc = GrNewGC();
	GrGetScreenInfo(&screen_info);

	init_defaults();
  init_drugs();
	init_screens();
	init_sheets();

	idw_wid = pz_new_window(0, HEADER_TOPLINE + 1, screen_info.cols, screen_info.rows - (HEADER_TOPLINE + 1), idw_do_draw, idw_do_keystroke);

	GrSelectEvents(idw_wid, GR_EVENT_MASK_EXPOSURE|GR_EVENT_MASK_KEY_DOWN);
	GrMapWindow(idw_wid);
}
Beispiel #17
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);
}
Beispiel #18
0
static PzWindow *set_Header()
{
        PzWindow * ret;
 	TWidget * wid;

        char headername[256];
        snprintf(headername, 256,
              pz_get_string_setting(pz_global_config, HEADERNAME));

        if(text_available()){
 	    ret = pz_new_window(_("Set Header Name"), PZ_WINDOW_NORMAL);
	    wid = textw(10, 40, ret->w-20, 10+ttk_text_height(ttk_textfont), 0, headername, pz_set_header);
	    ttk_add_widget(ret, wid);
	    textwstart(wid);
	   return pz_finish_window(ret);
        } 
         else { 
	    pz_warning("Install module text input");
	  return TTK_MENU_UPONE;
  }
}
Beispiel #19
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();
}
Beispiel #20
0
PzWindow *new_mymodule_window()
{
    static int calledyet = 0;
    PzWindow *ret;
    FILE *fp;
    
    if (!calledyet) {
	calledyet++;
	pz_message ("Select again to see the fun stuff.");
	return TTK_MENU_DONOTHING;
    }

    image = ttk_load_image (pz_module_get_datapath (module, "image.png"));
    if (!image) {
	pz_error ("Could not load %s: %s", pz_module_get_datapath (module, "image.png"),
		  strerror (errno));
	return TTK_MENU_DONOTHING;
    }
    ttk_surface_get_dimen (image, &imgw, &imgh);

    fp = fopen (pz_module_get_datapath (module, "message.txt"), "r");
    if (!fp) {
	pz_warning ("Could not read from %s: %s.", pz_module_get_datapath (module, "message.txt"),
		    strerror (errno));
	text = (char *)strdup ("Hi! I forgot to supply a message!");
    } else {
	long len;
	fseek (fp, 0, SEEK_END);
	len = ftell (fp);
	fseek (fp, 0, SEEK_SET);
	text = malloc (len + 1);
	fread (text, 1, len, fp);
	text[len] = 0;
    }

    ret = pz_new_window ("MyModule", PZ_WINDOW_NORMAL);
    pz_add_widget (ret, draw_mymodule, event_mymodule);
    return pz_finish_window (ret);
}
Beispiel #21
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" );
}
void new_tictactoe_window(void)
{
	
    tictactoe_gc = pz_get_gc(1);       /* Get the graphics context */
	
    /* Open the window: */
    tictactoe_wid = pz_new_window (0,
								   21,
								   screen_info.cols,
								   screen_info.rows - (HEADER_TOPLINE+1),
								   draw_header,
								   handle_event);
	
	GrGetWindowInfo(tictactoe_wid, &wi); /* Get screen info */	
	
    /* Select the types of events you need for your window: */
    GrSelectEvents (tictactoe_wid, GR_EVENT_MASK_EXPOSURE|GR_EVENT_MASK_KEY_DOWN|GR_EVENT_MASK_KEY_UP);
	
    /* Display the window: */
    GrMapWindow (tictactoe_wid);
	
	reset_board(); 
}
// 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();
}
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);
}
Beispiel #25
0
/* the entry point for the menu system */
void new_dialer_window()
{
    int ret = 0;

#ifdef __linux__
    ret = dsp_open(&dspz, DSP_LINEOUT);
#endif
    if (ret < 0) {
        pz_perror("/dev/dsp");
        return;
    }
#ifdef __linux__
    ret = dsp_setup(&dspz, 1, 44100);
#endif

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

    if (screen_info.cols < 160) { //mini
        cxgap = 3;
        cygap = 2;
        cbw = 22;
        cbh = 15;
    }

    dialer_wid = pz_new_window(0, HEADER_TOPLINE + 1,
                               screen_info.cols,
                               screen_info.rows - (HEADER_TOPLINE + 1),
                               dialer_do_draw, dialer_do_keystroke);

    GrSelectEvents(dialer_wid, GR_EVENT_MASK_EXPOSURE |
                   GR_EVENT_MASK_KEY_UP | GR_EVENT_MASK_KEY_DOWN);

    GrMapWindow(dialer_wid);
}
Beispiel #26
0
#include "pz.h"
#include <stdarg.h>

TWindow *pz_create_stringview(const char *buf, const char *title)
{
    TWindow *ret = ttk_new_window();
    ttk_add_widget (ret, ttk_new_textarea_widget (ret->w, ret->h, buf, ttk_textfont, ttk_text_height (ttk_textfont) + 2));
    ttk_window_title (ret, title);
    return ret;
}

PzWindow *pz_do_window (const char *name, int geometry,
			void (*draw)(PzWidget *this, ttk_surface srf),
			int (*event)(PzEvent *ev), int timer) 
{
    PzWindow *win = pz_new_window (name, geometry);
    PzWidget *wid = pz_add_widget (win, draw, event);
    pz_widget_set_timer (wid, timer);
    return pz_finish_window (win);
}

PzWindow *pz_new_window (const char *name, int geometry, ...) 
{
    PzWindow *ret = ttk_new_window();
    if (geometry == PZ_WINDOW_XYWH) {
	va_list ap;
	va_start (ap, geometry);
	ret->x = va_arg (ap, int);
	ret->y = va_arg (ap, int);
	ret->w = va_arg (ap, int);
	ret->h = va_arg (ap, int);
Beispiel #27
0
void new_chopper_window(void)
{

	int i,g;
	i=0;
	chopGC = pz_get_gc(1);       /* Get the graphics context */
	GrGetScreenInfo(&screen_info); /* Get screen info */
	
	/* Open the window: */
	chopWindow = pz_new_window (0,
					21,
					screen_info.cols,
					screen_info.rows - 21, /* Height of screen - header  */
					chopDrawScene,
					chopHandleEvent);
					
	chopBuffer = GrNewPixmap(screen_info.cols,
							(screen_info.rows - (HEADER_TOPLINE + 1)),
							NULL);
	
					
	iScreenX = screen_info.cols;
	iScreenY = screen_info.rows - 21;
	
	/* Select the types of events you need for your window: */
	GrSelectEvents (chopWindow,
			GR_EVENT_MASK_KEY_DOWN
			| GR_EVENT_MASK_TIMER | GR_EVENT_MASK_KEY_UP);
	
	/* Display the window: */
	GrMapWindow (chopWindow);
	
	/* Create the timer used for animating your application: */
	chopTimer = GrCreateTimer (chopWindow,
					75); /* Timer interval, millisecs */
					
	/*chopDrawScene();*/
	
	iRotorOffset = 0;
	//chopAddBlock(100,100,20,20);
	
		
	iPlayerPosX = 60;
	iPlayerPosY = iScreenY * 0.2;
	
	iLastBlockPlacedPosX = 0;
	iGravityTimerCountdown = 2;
	
	iPlayerAlive = 1;
	
	chopCounter = 0;
	
	
	
	while(i < NUMBER_OF_BLOCKS)
	{
		mBlocks[i].bIsActive = 0;
		i++;
	}
	
	g = iScreenY - 10;
	
	chopClearTerrain(&mGround);
	
	i=0;
	
	
	while(i < MAX_TERRAIN_NODES) //we could add less, probably.
	{
		chopAddTerrainNode(&mGround,i * 30,g - iR(0,20));
		
		i++;
	}
	
	if(chopUpdateTerrainRecycling(&mGround)==1)
		chopCopyTerrain(&mGround,&mRoof,0,-( iScreenY * 0.75)); //mirror the sky if we've changed the ground
	
	iLevelMode = iR(1,2);
	
	iPlayerSpeedX = 4;
	iPlayerSpeedY = 0;

	
	if(iLevelMode == LEVEL_MODE_NORMAL)
		iPlayerSpeedX*=2; //make it a bit more exciting, cause it's easy terrain...
	//printf("level mode: %d",iLevelMode);
	
	bWaitingToStart = 1;
}
Beispiel #28
0
int new_snake_window(int argc, char **argv)
{
  GR_SCREEN_INFO si;
  
  fin = 0;
  snake_count = 0;
  game_speed = start_speed;

  GrGetScreenInfo(&si); /* Get screen info */
      
  srand(time(0));
  
  game_state = SNAKE_START;

  /* Make the window */
 
  /*swindow = GrNewWindowEx(WM_PROPS, "nxsnake", GR_ROOT_WINDOW_ID, 
		       10, 10, WWIDTH, WHEIGHT, BLACK);*/
  swindow = pz_new_window (0,HEADER_TOPLINE+1,si.cols,si.rows-HEADER_TOPLINE-1,
                         do_draw,nxsnake_handle_event);
  
  GrSelectEvents(swindow, GR_EVENT_MASK_EXPOSURE | 
		 		GR_EVENT_MASK_KEY_DOWN|GR_EVENT_MASK_TIMER);

  nxsnake_timer = GrCreateTimer( swindow, 5 );
  
  offscreen = pz_new_window (0,HEADER_TOPLINE+1,si.cols,si.rows-HEADER_TOPLINE-1,
                    do_draw,nxsnake_handle_event);
                    
  //offscreen = GrNewPixmap(WWIDTH, WHEIGHT, 0);
  
  do_draw();
  GrMapWindow(swindow);
  GrMapWindow(offscreen);

  /* Draw the instructions into the buffer */
  draw_string( (char *) welcome, 1);

  while(fin != 1)
    {
      GR_EVENT event;

      /* We start at 130ms, but it goes down every */
      /* time a nibble is eaten */

      /* If they get this far, then they rock! */
      if (game_speed < 5) game_speed = 5;

      GrGetNextEventTimeout(&event, game_speed);
      
      switch(event.type)
        {
        case GR_EVENT_TYPE_EXPOSURE:
        case GR_EVENT_TYPE_KEY_DOWN:
          nxsnake_handle_event(&event);
          break;

        case GR_EVENT_TYPE_TIMER:
          handle_idle();
          break;
          
        }
    
    }
  return(1);
}
Beispiel #29
0
/* ***********************************************************/
void open_tuxchess_window (void)
{
	tuxchess_gc = pz_get_gc(1);	/* Get the graphics context */

	is_mini = (screen_info.cols == 138);

	if (is_mini) {
		/* Open the window for the board: */
		tuxchess_wid = pz_new_window(0, 2,
			104,
			screen_info.rows,
			tuxchess_do_draw,
			tuxchess_handle_event);

		/* Open the window for the message on the left : */
		message_wid = pz_new_window(104, 0,
			screen_info.cols,
			screen_info.rows,
			tuxchess_do_draw,
			tuxchess_handle_event); 

		GrSelectEvents(tuxchess_wid, GR_EVENT_MASK_KEY_DOWN |
				GR_EVENT_MASK_KEY_UP);
		GrSelectEvents(message_wid, GR_EVENT_MASK_KEY_DOWN |
				GR_EVENT_MASK_KEY_UP);
	} 
	else {
		/* Open the window for the board: */
		tuxchess_wid = pz_new_window(0, HEADER_TOPLINE + 1,
			104,
			screen_info.rows - HEADER_TOPLINE - 1,
			tuxchess_do_draw,
			tuxchess_handle_event);

		/* Open the window for the historic : */
		historic_wid = pz_new_window(104, HEADER_TOPLINE + 1,
			screen_info.cols,
			screen_info.rows - HEADER_TOPLINE - 1,
			tuxchess_do_draw,
			tuxchess_handle_event); 

		GrSelectEvents(tuxchess_wid, GR_EVENT_MASK_KEY_DOWN |
				GR_EVENT_MASK_KEY_UP);
		GrSelectEvents(historic_wid, GR_EVENT_MASK_KEY_DOWN |
				GR_EVENT_MASK_KEY_UP);
	}

	/* Display the windows : */
	if (is_mini) {
		GrMapWindow(message_wid);
		draw_message("A1-","Play");
	}
	else {
		GrMapWindow(historic_wid);
	}
	GrMapWindow(tuxchess_wid);

	tuxchess_do_draw();

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

	gen_moves();
	max_time = 100000;//1 << 25;
	max_depth = 1;
	end = 0;

	print_board();
	if (!is_mini) {
		draw_historic();
	}

	/* make sure the right window has focus so we get input events */
	// GrSetFocus(tuxchess_wid);
}
Beispiel #30
0
PzWindow *new_remote_ipod_info_window() {
	PzWindow *ret = pz_new_window("Remote iPod", PZ_WINDOW_NORMAL);
    pz_add_widget (ret, draw_about_remote_ipod_widget, event_remote_ipod_widget);
	return pz_finish_window(ret);
}