Esempio n. 1
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;
}
Esempio n. 2
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. 3
0
void wm_init(void)
{
	GR_WM_PROPERTIES props;
	win window;
	static int init = 0;
  
	if(!init) {
		init = 1;

		/* add root window*/
		window.wid = GR_ROOT_WINDOW_ID;
		window.pid = GR_ROOT_WINDOW_ID;
		window.type = WINDOW_TYPE_ROOT;
		window.clientid = 1;
		window.sizing = GR_FALSE;
		window.active = 0;
		window.data = NULL;
		wm_add_window(&window);

		GrSelectEvents(GR_ROOT_WINDOW_ID, GR_EVENT_MASK_CHLD_UPDATE);

		/* Set new root window background color*/
		props.flags = GR_WM_FLAGS_BACKGROUND;
		props.background = GrGetSysColor(GR_COLOR_DESKTOP);
		GrSetWMProperties(GR_ROOT_WINDOW_ID, &props);
	}
}
Esempio n. 4
0
static void
GrSelectEventsWrapper(void *r)
{
	nxSelectEventsReq *req = r;

	GrSelectEvents(req->windowid, req->eventmask);
}
Esempio n. 5
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. 6
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. 7
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. 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;
}
Esempio n. 9
0
// 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();
}
Esempio n. 10
0
static void create_aux_windows (_THIS)
{
    GR_WM_PROPERTIES props ;

    Dprintf ("enter create_aux_windows\n") ;

    // Don't create any extra windows if we are being managed
    if (SDL_windowid) {
        FSwindow = 0 ;
        return ;
    }
    
    if (FSwindow && FSwindow != GR_ROOT_WINDOW_ID) {
        GrDestroyWindow (FSwindow) ;
    }
    
    FSwindow = GrNewWindow (GR_ROOT_WINDOW_ID, 0, 0, 1, 1, 0, BLACK, BLACK) ;
    props.flags = GR_WM_FLAGS_PROPS ;
    props.props = GR_WM_PROPS_NODECORATE ;
    GrSetWMProperties (FSwindow, & props) ;

    GrSelectEvents (FSwindow, (GR_EVENT_MASK_EXPOSURE         |
        GR_EVENT_MASK_BUTTON_DOWN  | GR_EVENT_MASK_BUTTON_UP  |
        GR_EVENT_MASK_FOCUS_IN     | GR_EVENT_MASK_FOCUS_OUT  |
        GR_EVENT_MASK_KEY_DOWN     | GR_EVENT_MASK_KEY_UP     |
        GR_EVENT_MASK_MOUSE_ENTER  | GR_EVENT_MASK_MOUSE_EXIT |
        GR_EVENT_MASK_MOUSE_MOTION | GR_EVENT_MASK_UPDATE     |
        GR_EVENT_MASK_CLOSE_REQ)) ;

    Dprintf ("leave create_aux_windows\n") ;
}
Esempio n. 11
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. 12
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();
}
Esempio n. 13
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. 14
0
int
main(int argc, char **argv)
{
	int COLS, ROWS;

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

	COLS = 350;
	ROWS = 300;

	g_main = GrNewWindowEx(GR_WM_PROPS_APPWINDOW, "dashdemo",
		GR_ROOT_WINDOW_ID, 100, 50, COLS - 120, ROWS - 60, BLUE);

	GrSelectEvents(g_main, GR_EVENT_MASK_EXPOSURE|GR_EVENT_MASK_CLOSE_REQ);
	GrMapWindow(g_main);

	while (1) {
		GR_EVENT event;
		GrGetNextEvent(&event);

		switch (event.type) {
		case GR_EVENT_TYPE_EXPOSURE:
			draw_screen();
			break;

		case GR_EVENT_TYPE_CLOSE_REQ:
			GrClose();
			return 0;
		}
	}
}
Esempio n. 15
0
//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();
}
Esempio n. 16
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. 17
0
int
mvpw_init(void)
{
	GR_SCREEN_INFO si;

	if (GrOpen() < 0)
		return -1;

	GrGetScreenInfo(&si);

	root = malloc(sizeof(*root));
	memset(root, 0, sizeof(*root));

	root->type = MVPW_ROOT;
	root->wid = GR_ROOT_WINDOW_ID;
	root->width = si.cols;
	root->height = si.rows;
	add_widget(root);

	GrSetWindowBackgroundColor(GR_ROOT_WINDOW_ID, 0);

	root->event_mask = GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_TIMER |
		GR_EVENT_MASK_SCREENSAVER | GR_EVENT_MASK_FDINPUT;
	GrSelectEvents(GR_ROOT_WINDOW_ID, root->event_mask);

	return 0;
}
Esempio n. 18
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. 19
0
/*
 * Initialize graphics and open a window for the viewer
 */
Bool
CreateXWindow(void)
{
    int fd;
    GR_SIZE w, h;
    GR_SCREEN_INFO si;

    if ((fd = GrOpen()) < 0)
        return(False);
    nx_dpy.fd = fd;
    dpy = &nx_dpy;

    GrGetScreenInfo(&si);
    /* pass screen details to RFB handler */
    myFormat.bitsPerPixel = si.bpp;
    myFormat.depth = si.bpp;	/* is this right? */
    myFormat.bigEndian = 0;		/* how do I find this out? */
    myFormat.trueColour = (myFormat.depth == 8 && !useBGR233) ? 0 : 1;
    if (myFormat.trueColour) {
        myFormat.redMax = myFormat.greenMax = 7;
        myFormat.blueMax = 3;
        myFormat.redShift = 0;
        myFormat.greenShift = 3;
        myFormat.blueShift = 6;
    }
    pixtype = si.pixtype;
    /* get the initial server palette */
    GrGetSystemPalette(&srv_pal);
#if 0
    /* DEBUG */
    for (i = 0; i < srv_pal.count; i++) {
        printf("0x%02x  %03d  %03d  %03d\n", i, \
               srv_pal.palette[i].r, srv_pal.palette[i].g, \
               srv_pal.palette[i].b );
    }
#endif
    /* create the top-level window */
    w = (VW_WIDTH > (si.cols - VW_X)) ? (si.cols - VW_X) : VW_WIDTH;
    h = (VW_HEIGHT > (si.rows - VW_Y)) ? (si.rows - VW_Y) : VW_HEIGHT;
    if ((wid = GrNewWindow(GR_ROOT_WINDOW_ID, VW_X, VW_Y, w, h,
                           2, LTGRAY, BLACK)) == 0) {
        fprintf(stderr, "Unable to create top-level window\n");
        GrClose();
        return False;
    }
    /* select events to receive */
    GrSelectEvents(wid, GR_EVENT_MASK_BUTTON_DOWN |
                   GR_EVENT_MASK_BUTTON_UP | GR_EVENT_MASK_KEY_DOWN |
                   GR_EVENT_MASK_KEY_UP | GR_EVENT_MASK_MOUSE_POSITION);
    /* make thw window visible */
    GrMapWindow(wid);
    canvas = wid;
    /* create the graphics contexts */
    gc = GrNewGC();
    srcGC = GrNewGC();
    dstGC = GrNewGC();

    return True;
}
Esempio n. 20
0
void
mvpw_set_fdinput(mvp_widget_t *widget, void (*callback)(mvp_widget_t*, int))
{
	widget->event_mask |= GR_EVENT_MASK_FDINPUT;
	GrSelectEvents(widget->wid, widget->event_mask);

	widget->callback_fdinput = callback;
}	
Esempio n. 21
0
void
mvpw_set_key(mvp_widget_t *widget, void (*callback)(mvp_widget_t*, char))
{
	widget->event_mask |= GR_EVENT_MASK_KEY_DOWN;
	GrSelectEvents(widget->wid, widget->event_mask);

	widget->callback_key = callback;
}
Esempio n. 22
0
static void
do_update(GR_EVENT_UPDATE *ep)
{
	mwin *	mwp;
	mwin *	tmwp;
	GR_WINDOW_INFO winfo;

	if (IsDecoration(ep->wid)) return;

	if ((mwp = FindWindow(ep->wid)) == NULL) {
		/* We have a new window */
		if (ep->utype != GR_UPDATE_MAP) return;
		if ((mwp = NewWindow(ep->wid)) == NULL) {
			GrError("malloc failed\n");
			return;
		}
		GrGetWindowInfo(ep->wid, &winfo);
		mwp->x = ep->x - winfo.bordersize;
		mwp->y = ep->y - winfo.bordersize;
		mwp->width = ep->width + 2 * winfo.bordersize;
		GrMoveWindow(mwp->wid, mwp->x + winfo.bordersize,
					mwp->y + DEC_HEIGHT +
						2 * winfo.bordersize);
		mwp->fid = GrNewWindow(GR_ROOT_WINDOW_ID, mwp->x + 1,
				mwp->y + 1, mwp->width - 2,
				DEC_HEIGHT - 2, 1, BLUE, BLACK);
		GrSelectEvents(mwp->fid, GR_EVENT_MASK_BUTTON_DOWN |
			GR_EVENT_MASK_BUTTON_UP | GR_EVENT_MASK_MOUSE_POSITION);
		GrMapWindow(mwp->fid);
	} else {
		switch (ep->utype) {
			case GR_UPDATE_UNMAP:
				GrUnmapWindow(mwp->fid);
				GrDestroyWindow(mwp->fid);
				if (mwins == mwp) {
					mwins = mwp->next;
				} else for(tmwp = mwins; tmwp; tmwp = tmwp->next) {
					if (tmwp->next == mwp) {
						tmwp->next = mwp->next;
					}
				}
				free(mwp);
				break;
			case GR_UPDATE_MOVE:
				GrGetWindowInfo(ep->wid, &winfo);
				if ((ep->x == (mwp->x + winfo.bordersize)) &&
					(ep->y == (mwp->y + winfo.bordersize
							+ DEC_HEIGHT))) {
					return;
				}
				mwp->x = ep->x - winfo.bordersize;
				mwp->y = ep->y - winfo.bordersize - DEC_HEIGHT;
				GrMoveWindow(mwp->fid, mwp->x + 1, mwp->y + 1);
			default:
				break;
		}
	}
}
Esempio n. 23
0
int
XSelectInput(Display * dpy, Window w, long mask)
{
    GR_EVENT_MASK nxmask;

    nxmask = _nxTranslateEventMask(mask);
    GrSelectEvents(w, nxmask);
    return 1;
}
Esempio n. 24
0
void
mvpw_set_timer(mvp_widget_t *widget, void (*callback)(mvp_widget_t*),
	       uint32_t timeout)
{
	if (widget->callback_timer) {
		widget->event_mask &= ~GR_EVENT_MASK_TIMER;
		GrSelectEvents(widget->wid, widget->event_mask);
		GrDestroyTimer(widget->tid);
	}

	widget->callback_timer = callback;

	if (callback) {
		widget->event_mask |= GR_EVENT_MASK_TIMER;
		GrSelectEvents(widget->wid, widget->event_mask);
		widget->tid = GrCreateTimer(widget->wid, timeout);
	}

}
Esempio n. 25
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. 26
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);
	}
}
Esempio n. 27
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. 28
0
mvp_widget_t*
mvpw_create(mvp_widget_t *parent,
	    GR_COORD x, GR_COORD y,
	    unsigned int width, unsigned int height,
	    GR_COLOR bg, GR_COLOR border_color, int border_size)
{
	mvp_widget_t *widget;
	GR_WINDOW_ID wid, pwid;

	if (parent)
		pwid = parent->wid;
	else
		pwid = GR_ROOT_WINDOW_ID;

	wid = GrNewWindow(pwid, x, y, width, height,
			  border_size, bg, border_color);

	if (wid == 0)
		return NULL;

	if ((widget=(mvp_widget_t*)malloc(sizeof(*widget))) == NULL)
		return NULL;
	memset(widget, 0, sizeof(*widget));

	widget->wid = wid;
	widget->parent = parent;
	widget->x = x;
	widget->y = y;
	widget->width = width;
	widget->height = height;
	widget->bg = bg;
	widget->border_color = border_color;
	widget->border_size = border_size;
	widget->user_data = NULL;

	if (add_widget(widget) < 0)
		goto err;

	widget->event_mask = GR_EVENT_MASK_EXPOSURE;

	GrSelectEvents(wid, widget->event_mask);

	return widget;

 err:
	if (widget)
		mvpw_destroy(widget);

	return NULL;
}
Esempio n. 29
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;
}
Esempio n. 30
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);
}