Пример #1
0
int Field::isTouched(const touchPosition& touch) {
    if( mode == POKEBALLMODE ) {
        const std::string BALLTEXTURE = ExtDataManager::getBasePath() + "/textures/ball.png";
        const int XLABELPOS = posx + 5;
        const int XBALLPOS = XLABELPOS;
        const int YBALLPOS = posy + 2;

        Drawable ball(TextureManager::getTexture(BALLTEXTURE), XBALLPOS, YBALLPOS, active, id);
        return ball.isTouched(touch);
    }

    if( mode == ARROWMODE) {
        const int XDOWNPOS = posx + 5;
        const int YDOWNPOS = posy + 2;
        const std::string DOWNARROW = ExtDataManager::getBasePath() + "/textures/downarrow.png";

        const std::string FONTPATH = ExtDataManager::getBasePath() + "/fonts/roboto_bold.ttf";
        const int XLABELARROWPOS = posx + 5 + TextureManager::getTexture(DOWNARROW)->width + 5;
        const int XUPPOS = XLABELARROWPOS + getTextWidth(FontManager::getFont(FONTPATH), 9, label+" "+textfield) + 5;
        const int YUPPOS = YDOWNPOS;
        const std::string UPARROW = ExtDataManager::getBasePath() + "/textures/uparrow.png";

        Drawable downarrow(TextureManager::getTexture(DOWNARROW), XDOWNPOS, YDOWNPOS, active, id);
        Drawable uparrow(TextureManager::getTexture(UPARROW), XUPPOS, YUPPOS, active, id+1);

        if( downarrow.isTouched(touch) )
            return id;

        if( uparrow.isTouched(touch) )
            return id+1;

        return 0;
    }

    return 0;
}
Пример #2
0
int analyze(void)
{
    static int use = 1;

    static Objects objects[] = {
	MENU("DONE", done, &use),
	MENU("PRINT", to_printer, &use),
	MENU("FILE", to_file, &use),
	MENU("OVERLAY", do_warp, &use),
	MENU(delete_msg, delete_mark, &use),
	INFO("Transform->", &use),
	MENU(order_msg, get_order, &use),
	INFO(pick_msg, &use),
	OTHER(pick, &use),
	{0}
    };

    int color;
    int tsize;
    int cury;
    int len;
    int line;
    int top, bottom, left, right, width, middle, nums;

    /* to give user a response of some sort */
    Menu_msg("Preparing analysis ...");

    /*
     * build a popup window at center of the screen.
     * 35% the height and wide enough to hold the report
     *
     */

    /* height of 1 line, based on NLINES taking up 35% vertical space */
    height = (.35 * (SCREEN_BOTTOM - SCREEN_TOP)) / NLINES + 1;

    /* size of text, 80% of line height */
    tsize = .8 * height;
    size = tsize - 2;		/* fudge for computing pixels width of text */

    /* indent for the text */
    edge = .1 * height + 1;

    /* determine the length, in chars, of printed line */
    FMT0(buf, 0);
    nums = strlen(buf) * size;
    FMT1(buf, 0.0, 0.0, 0.0);
    len = strlen(buf);
    middle = len * size;
    FMT2(buf, 0.0, 0.0, 0.0, 0.0);
    len += strlen(buf);

    /* width is for max chars plus sidecar for more/less */
    width = len * size + nums + 2 * height;
    if ((SCREEN_RIGHT - SCREEN_LEFT) < width)
	width = SCREEN_RIGHT - SCREEN_LEFT;


    /* define the window */
    bottom = VIEW_MENU->top - 1;
    top = bottom - height * NLINES;


    left = SCREEN_LEFT;
    right = left + width;
    middle += left + nums;
    nums += left;

    /* save what is under this area, so it can be restored */
    R_panel_save(tempfile1, top, bottom + 1, left, right + 1);


    /* fill it with white */
    R_standard_color(BACKGROUND);
    R_box_abs(left, top, right, bottom);

    right -= 2 * height;	/* reduce it to exclude sidecar */

    /* print messages in message area */
    R_text_size(tsize, tsize);


    /* setup the more/less boxes in the sidecar */
    R_standard_color(BLACK);
    less.top = top;
    less.bottom = top + 2 * height;
    less.left = right;
    less.right = right + 2 * height;
    Outline_box(less.top, less.bottom, less.left, less.right);

    more.top = bottom - 2 * height;
    more.bottom = bottom;
    more.left = right;
    more.right = right + 2 * height;
    Outline_box(more.top, more.bottom, more.left, more.right);

    /*
     * top two lines are for column labels
     * last two line is for overall rms error.
     */
    nlines = NLINES - 3;
    first_point = 0;

    /* allocate predicted values */
    xres = (double *)G_calloc(group.points.count, sizeof(double));
    yres = (double *)G_calloc(group.points.count, sizeof(double));
    gnd = (double *)G_calloc(group.points.count, sizeof(double));

    /* compute transformation for the first time */
    compute_transformation();

    /* put head on the report */
    cury = top;
    dotext(LHEAD1, cury, cury + height, left, middle, 0, BLACK);
    dotext(RHEAD1, cury, cury + height, middle, right - 1, 0, BLACK);
    cury += height;
    dotext(LHEAD2, cury, cury + height, left, middle, 0, BLACK);
    dotext(RHEAD2, cury, cury + height, middle, right - 1, 0, BLACK);
    cury += height;
    R_move_abs(left, cury - 1);
    R_cont_abs(right, cury - 1);

    /* isolate the sidecar */
    R_move_abs(right, top);
    R_cont_abs(right, bottom);

    /* define report box */
    report.top = cury;
    report.left = left;
    report.right = right;

    /* lets do it */

    pager = 1;
    while (1) {
	R_text_size(tsize, tsize);
	line = 0;
	curp = first_point;
	cury = top + 2 * height;
	while (1) {
	    if (line >= nlines || curp >= group.points.count)
		break;
	    line++;

	    if (!delete_mode)
		color = BLACK;
	    else
		color = BLUE;

	    if (group.equation_stat > 0 && group.points.status[curp] > 0) {
		/* color = BLACK; */
		FMT1(buf, xres[curp], yres[curp], gnd[curp]);
		if (curp == xmax || curp == ymax || curp == gmax)
		    color = RED;
		dotext(buf, cury, cury + height, nums, middle, 0, color);
	    }
	    else if (group.points.status[curp] > 0)
		dotext("?", cury, cury + height, nums, middle, 1, color);
	    else
		dotext("not used", cury, cury + height, nums, middle, 1,
		       color);

	    if (pager) {
		FMT0(buf, curp + 1);
		dotext(buf, cury, cury + height, left, nums, 0, color);
		FMT2(buf,
		     group.points.e1[curp],
		     group.points.n1[curp],
		     group.points.e2[curp], group.points.n2[curp]);
		dotext(buf, cury, cury + height, middle, right - 1, 0, color);
	    }
	    cury += height;
	    curp++;
	}
	report.bottom = cury;
	downarrow(&more, curp < group.points.count ? color : BACKGROUND);
	uparrow(&less, first_point > 0 ? color : BACKGROUND);
	R_standard_color(BACKGROUND);
	R_box_abs(left, cury, right - 1, bottom);
	if (group.equation_stat < 0) {

	    if (group.equation_stat == -1) {
		color = RED;
		strcpy(buf, "Poorly placed control points");
	    }
	    else {
		if (group.equation_stat == -2)
		    G_fatal_error("NOT ENOUGH MEMORY");
		else
		    G_fatal_error("PARAMETER ERROR");
	    }

	}
	else if (group.equation_stat == 0) {
	    color = RED;
	    strcpy(buf, "No active control points");
	}
	else {
	    color = BLACK;
	    sprintf(buf, "Overall rms error: %.2f", rms);
	}
	dotext(buf, bottom - height, bottom, left, right - 1, 0, color);
	R_standard_color(BLACK);
	R_move_abs(left, bottom - height);
	R_cont_abs(right - 1, bottom - height);

	pager = 0;
	which = -1;
	if (Input_pointer(objects) < 0)
	    break;
	display_points(1);
    }

    /* all done. restore what was under the window */
    right += 2 * height;	/* move it back over the sidecar */
    R_standard_color(BACKGROUND);
    R_box_abs(left, top, right, bottom);
    R_panel_restore(tempfile1);
    R_panel_delete(tempfile1);
    R_flush();

    G_free(xres);
    G_free(yres);
    G_free(gnd);
    I_put_control_points(group.name, &group.points);
    display_points(1);
    return 0;			/* return but don't QUIT */
}
Пример #3
0
/** Default constructor */
MainWindow::MainWindow() : QWidget()
{
	/** constructor() that has in input file for scores */
	ifstream fin;
	fin.open("scores.txt");
	if(fin.fail())
	{
		cout << "Could not find the scores file" << endl;
	}
	else
	{
	  string temp;
	  int temp2;
	  getline(fin,temp,'|');
	  fin >> temp2;
		while(fin.good())
		{
			scorenames.push_back(temp);
			scores.push_back(temp2);
			getline(fin,temp,'|');
			fin >> temp2;
		}
	}
	  
	/** Set the Pixmaps */
	ez=new QPixmap("ezreal.png");
		*ez=ez->scaled(75,75,Qt::KeepAspectRatioByExpanding);
	melee=new QPixmap("meleeminion.png");
		*melee=melee->scaled(50,50,Qt::KeepAspectRatioByExpanding);
	caster=new QPixmap("casterminion.png");
		*caster=caster->scaled(45,45,Qt::KeepAspectRatioByExpanding);
	siege=new QPixmap("siegeminion.png");
		*siege=siege->scaled(65,65,Qt::KeepAspectRatioByExpanding);
	basic=new QPixmap("basicattack.gif");
		*basic=basic->scaled(10,10,Qt::KeepAspectRatioByExpanding);
	mystic=new QPixmap("basicattack.gif");
		*mystic=mystic->scaled(30,30,Qt::KeepAspectRatioByExpanding);
	trueshot=new QPixmap("trueshot.png");
		*trueshot=trueshot->scaled(75,75,Qt::KeepAspectRatioByExpanding);
	heal=new QPixmap("heal.png");
		*heal=heal->scaled(50,50,Qt::KeepAspectRatioByExpanding);
	clarity=new QPixmap("clarity.png");
		*clarity=clarity->scaled(50,50,Qt::KeepAspectRatioByExpanding);
	ignite=new QPixmap("ignite.png");
		*ignite=ignite->scaled(50,50,Qt::KeepAspectRatioByExpanding);
	energy=new QPixmap("energybolt.gif");
		*energy=energy->scaled(50,50,Qt::KeepAspectRatioByExpanding);
	cannon=new QPixmap("cannonshot.png");
		*cannon=cannon->scaled(55,55,Qt::KeepAspectRatioByExpanding);
	/** color is the default color set for spacers and background of widgets*/
	color.setRgb(240,240,240,255);
	/** MainWidget which holds everything */
	mainwidget= new QWidget;
	mainwidget->setFixedSize(1200,800);
	/** Main Layout for MainWindow */
	mainLayout = new QVBoxLayout;
	mainwidget->setLayout(mainLayout);
	  /** TITLE above row1*/
	  row0 = new QHBoxLayout;
	  	/** IconObject used to display QPixmap */
	    	hold_spacer0 = new IconObject;
	  	/** Used to hold a space */
	  	spacer0 = new QPixmap(100,64);
	  	spacer0->fill(color);
	  	/** IconObject used to display QPixmap */
	    	hold_title = new IconObject;
	    	/** Ability display icon */
	  	title = new QPixmap("title.png");
	  	/** IconObject used to display QPixmap */
	    	hold_spacer01 = new IconObject;
	  	/** Used to hold a space */
	  	spacer01 = new QPixmap(100,64);
	  	spacer01->fill(color);
	  	// set pixmaps
	  	hold_spacer0->setPixmap(*spacer0);
	  	hold_title->setPixmap(title->scaled(700,40,Qt::KeepAspectRatioByExpanding));
	  	hold_spacer0->setPixmap(*spacer01);
	  	//add to layout row0
	  	row0->addWidget(hold_spacer0);
	  	row0->addWidget(hold_title);
	  	row0->addWidget(hold_spacer01);
	  	mainLayout->addLayout(row0);
	  /** Horizontal box for row 1*/
	  row1= new QHBoxLayout;
	  	/** Button which initiates/restarts game*/
		start= new QPushButton("Start");
		/** Button which pauses/continues game*/
		pause = new QPushButton("Pause");
		/** quits the game*/
		quit = new QPushButton("Quit");
		/** Score display*/
		name = new QTextEdit("Name");
		name->setMaximumHeight(30);
		name->setMaximumWidth(200);
		/** level display*/
		level = new QLabel("LEVEL: 00");
		/** score display*/
		score = new QLabel("SCORE: 00");
	    row1->addWidget(start);
	    row1->addWidget(pause);
	    row1->addWidget(quit);
	    row1->addWidget(name);
	    row1->addWidget(level);
	    row1->addWidget(score);
	    mainLayout->addLayout(row1);
	  /** Horizontal box for row 2*/
	  row2 = new QHBoxLayout;
	  	/** Scene which holds monsters, player and powerups*/
	  	scene = new QGraphicsScene;
	  	/** View which holds gameplay*/
	  	view = new GameWindow(scene);
	    row2->addWidget(view);
	    mainLayout->addLayout(row2);
	  /** Horizontal box for row 3*/
	  row3 = new QHBoxLayout;
	    //left
	    	/** IconObject used to display QPixmap */
	    	hold_basicattackicon = new IconObject;
	    	/** Ability display icon */
	  	basicattackicon = new QPixmap("basicattack.gif");
	  	/** IconObject used to display QPixmap */
	    	hold_mysticshoticon = new IconObject;
	  	/** Ability display icon */
	  	mysticshoticon = new QPixmap("basicattack.gif");
	  	//mysticshoticon->scaledToHeight(64,Qt::FastTransformation);
	  	/** IconObject used to display QPixmap */
	    	hold_trueshoticon = new IconObject;
	  	/** Ability display icon */
	  	trueshoticon = new QPixmap("trueshot.png");
	  	/** IconObject used to display QPixmap */
	    	hold_spacer1 = new IconObject;
	  	/** Used to hold a space */
	  	spacer1 = new QPixmap(400,64);
	  	spacer1->fill(color);
	    //midleft
	    	/** IconObject used to display QPixmap */
	    	hold_heart = new IconObject;
	    	/** Heart Icon */
	    	heart = new QPixmap("heart.gif");
	    	/** Health display */
	    	health = new QLabel("200");
	    	health->setMaximumHeight(25);
	    	/** IconObject used to display QPixmap */
	    	hold_spacer2 = new IconObject;
	    	/** Used to hold a space */
	  	spacer2 = new QPixmap(64,64);
	  	spacer2->fill(color);
	    //midright
	    	/** IconObject used to display QPixmap */
	    	hold_potion = new IconObject;
	    	/** Mana Icon */
	    	potion = new QPixmap("mana.gif");
	    	/** Mana display */
	    	mana= new QLabel("50");
	    	mana->setMaximumHeight(25);
	    	
	    /*Add the Pixmaps to the IconObjects*/
	    hold_basicattackicon->setPixmap(basicattackicon->scaledToHeight(10));
	    hold_mysticshoticon->setPixmap(mysticshoticon->scaledToHeight(20));
	    hold_trueshoticon->setPixmap(trueshoticon->scaled(40,60,Qt::KeepAspectRatioByExpanding));
	    hold_spacer1->setPixmap(*spacer1);
	    hold_heart->setPixmap(*heart);
	    hold_spacer2->setPixmap(*spacer2);
	    hold_potion->setPixmap(*potion);
	    /* Add IconObjects to row3 */
	    row3->addWidget(hold_basicattackicon);
	    row3->addWidget(hold_mysticshoticon);
	    row3->addWidget(hold_trueshoticon);
	    row3->addWidget(hold_spacer1);
	    row3->addWidget(hold_heart);
	    row3->addWidget(health);
	    row3->addWidget(hold_spacer2);
	    row3->addWidget(hold_potion);
	    row3->addWidget(mana);
	    /* Add layout to main widget*/
	    mainLayout->addLayout(row3);
	    
	// set player
	  //objects.push_back(
	//set bool variables
	trueshotfiring = false;
	inGame = false;
	gamePaused = false;
	playerAlive = false;
	up = false;
	down = false;
	left = false;
	right = false;
	grabbedignite=false;
	lostgame=false;
	//set counters
	/** Level identifies which level the game is at */
	levelff=1;
	/** Leftclickcounter determines how many times left click is pressed */
	leftclickcounter=0;
	/** Leftclickholdcounter determines how long left click is pressed */
	leftclickholdcounter=0;
	/** Spawn counter for a meleeminoin */
	spawnmelee=0;
	/** Spawn counter for a Siegeminion*/
	spawnsiege=0;	
	/** Spawn counter for a Casterminion*/
	spawncaster=0;
	/** Ez can not be hurt immediately at next clock 
	  *giving the player time to move out of the way*/
	ezhurt=0;
	/** Points scored*/
	points=0;
	/** Icon spawning at 200*/
	iconspawn=0;
	
	// set timer
	timer = new QTimer(this);// timer->start(val) later on in show()
	//connections
	connect(start,SIGNAL(clicked()),this,SLOT(clickedStart()));
	connect(pause,SIGNAL(clicked()),this,SLOT(clickedPause()));
	connect(view,SIGNAL(leftButtonClicked()),this,SLOT(leftClick()));
	connect(view,SIGNAL(rightButtonClicked()),this,SLOT(rightClick()));
	connect(view,SIGNAL(leftButtonHoldStart()),this,SLOT(leftHoldstart()));
	connect(view,SIGNAL(leftButtonHoldCancel()),this,SLOT(leftHoldcancel()));
	connect(view,SIGNAL(uparrow()),this,SLOT(moveup()));
	connect(view,SIGNAL(downarrow()),this,SLOT(movedown()));
	connect(view,SIGNAL(leftarrow()),this,SLOT(moveleft()));
	connect(view,SIGNAL(rightarrow()),this,SLOT(moveright()));
	connect(timer,SIGNAL(timeout()),this,SLOT(handleTimer()));
	connect(quit,SIGNAL(clicked()),this,SLOT(clickedQuit()));
}
Пример #4
0
void iSpecialKeyboard(unsigned char key)
{
	selflag = 0;
	//retrieve charactre index in terms of cursor position
	j = x/ charSpace;
	i = ((height-15-lineSpace - y)/lineSpace) + s;

	if (glutGetModifiers() == GLUT_ACTIVE_ALT && key == GLUT_KEY_F4 )
	{
		FILE *fp;
		char tempfile[80];
		strcpy(tempfile, syspath);
		strcat(tempfile, ":\\Program Files\\Rword\\settings.dat");
		fp = fopen(tempfile, "wb");
		fwrite(&flebel, sizeof(int), 1, fp);
		fclose(fp);

		free(str);
		exit(0);			//exit action
	}
	else if(key == GLUT_KEY_LEFT)			//aroow keys
	{
		upArrow=0;
		downArrow=0;
		leftarrow();
	}
	else if(key == GLUT_KEY_RIGHT)
	{
		upArrow=0;
		downArrow=0;
		rightarrow();
	}

	else if(key == GLUT_KEY_UP)
	{
		uparrow();
	}

	else if (key == GLUT_KEY_DOWN)
	{
		downarrow();
	}
	else if (key == GLUT_KEY_F1)			//help option
	{
		char tempfile[80];
		strcpy(tempfile, syspath);
		strcat(tempfile, ":\\Program Files\\Rword\\Rhelp.chm");
		ShellExecute(NULL,"open", tempfile, NULL,NULL, SW_SHOW);
		menuflag =0;
	}
	else if (key == GLUT_KEY_F3)			//selection shortcut
	{
		selectText();
	}
	
	else if (key == GLUT_KEY_PAGE_UP)		//page keys
	{
		pageUp();
	}

	else if (key == GLUT_KEY_PAGE_DOWN)
	{
		pageDown();
	}

	else if (key == GLUT_KEY_HOME)
	{
			j = 0;
			x = 0;
	}

	else if (key == GLUT_KEY_END)
	{
		j = strlen(str+i*charMax*sizeof(char));
		x = j*charSpace;
	}

	else if (key == GLUT_KEY_INSERT)
	{
		insert = (insert)?0:1;
	}
}
Пример #5
0
int
ask_gis_files(char *type, char *file, char *xname, char *xmapset,
	      int position)
{
    static int use = 1;
    static Objects objects[] = {
	OTHER(pick, &use),
	{0}
    };

    char msg[100];
    FILE *fd;
    int width;
    int len1, len2, len;
    long offset;
    long *page_offset;
    int col, nlist;
    int line;
    int stat;
    char buf[100];
    int top, bottom, left, right, center;
    int topx, bottomx, leftx, rightx, widthx;
    char name[GNAME_MAX], mapset[GMAPSET_MAX], cur_mapset[GMAPSET_MAX];
    int new_mapset;

    Menu_msg("");

    fd = fopen(file, "r");
    if (fd == NULL)
	G_fatal_error("ask_gis_files: can't read tempfile");
    if (fread(&len1, sizeof(len1), 1, fd) != 1
	|| fread(&len2, sizeof(len2), 1, fd) != 1 || len1 <= 0 || len2 <= 0) {
	fclose(fd);
	return 0;
    }

    sprintf(msg, "Double click on %s file to be plotted", type);

    /*
     * build a popup window at center of the screen.
     * 35% the height and wide enough to hold 2 columms of file names
     *
     * the window is for choosing file names and will be laid out in 2 columns
     *
     *             ------------------------------------------
     *             |     CANCEL           | (MORE) | (LESS) | 
     *             ------------------------------------------
     *             |             mapset                     |
     *             ------------------------------------------
     *             |      name1        |   name2            |
     *             ------------------------------------------
     *             |      name3        |   name4            |
     *             ------------------------------------------
     *             |      name5        |   name6            |
     *             |                   .                    |
     *             |                   .                    |
     *             |                   .                    |
     *             ------------------------------------------
     */

    /* height of 1 line, based on NLINES taking up 35% vertical space */
    height = (.35 * (SCREEN_BOTTOM - SCREEN_TOP)) / NLINES + 1;

    /* size of text, 80% of line height */
    text_size = .8 * height;
    size = text_size - 1;	/* fudge for computing pixels width of text */

    /* indent for the text */
    edge = .1 * height + 1;

    /* this is a fudge to determine the length of the largest text */
    len1 = 2 * len1;		/* name in 2 columns */
    len2 += strlen("mapset ");
    len = (len1 > len2 ? len1 : len2);

    /* width is for max chars plus sidecar for more/less */
    width = len * size + height;
    widthx = strlen(msg) * size;
    if (widthx < width)
	widthx = width;

    /* define the window */
    top = (SCREEN_TOP + SCREEN_BOTTOM - height * NLINES) / 2;
    bottom = top + height * NLINES;

    center = (SCREEN_LEFT + SCREEN_RIGHT) / 2;
    if (position > 0) {
	right = (center + SCREEN_RIGHT + width) / 2;
	if (right >= SCREEN_RIGHT)
	    right = SCREEN_RIGHT - 1;
	left = right - width;
    }
    else if (position < 0) {
	left = (center + SCREEN_LEFT - width) / 2;
	if (left <= SCREEN_LEFT)
	    left = SCREEN_LEFT + 1;
	right = left + width;
    }
    else {
	left = center + width / 2;
	right = left + width;
    }

    topx = top - 3 * height;
    bottomx = topx + 2 * height;
    leftx = (left + right - widthx) / 2;
    if (leftx < SCREEN_LEFT)
	leftx = SCREEN_LEFT;
    rightx = leftx + widthx;

    /* save what is under these areas, so they can be restored */
    R_panel_save(tempfile1, top, bottom + 1, left, right + 1);
    R_panel_save(tempfile2, topx, bottomx + 1, leftx, rightx + 1);

    /* fill it top with GREY, pick area with white */
    R_standard_color(WHITE);
    R_box_abs(left, top, right, bottom);
    R_standard_color(GREY);
    R_box_abs(leftx, topx, rightx, bottomx);

    R_standard_color(BLACK);
    Outline_box(top, bottom, left, right);
    right -= height;		/* reduce it to exclude sidecar */
    Outline_box(top, bottom, left, right);

    /* print messages above the files */
    dotext(msg, topx, topx + height, leftx, rightx, 1);
    dotext("Double click here to cancel", topx + height, bottomx, leftx,
	   rightx, 1);
    cancel.top = topx;
    cancel.bottom = bottomx;
    cancel.left = leftx;
    cancel.right = rightx;

    /* start the mouse in the cancel box */
    Set_mouse_xy((leftx + rightx) / 2, (topx + bottomx) / 2);

    dobox(&less, "", WHITE, top, right, right + height, 0);
    dobox(&more, "", WHITE, bottom - height, right, right + height, 0);

    /* as we read the file of names, keep track of pages so we can
     * page backward
     */
    page = 0;
    page_offset = (long *)G_calloc(npages = 1, sizeof(long));
    *page_offset = G_ftell(fd);

    nlist = sizeof(list) / sizeof(list[0]);
    for (stat = -1; stat < 0;) {
	line = 0;
	count = 0;
	*cur_mapset = 0;
	col = 0;
	while (1) {
	    offset = G_ftell(fd);
	    if (fgets(buf, sizeof buf, fd) == NULL
		|| sscanf(buf, "%s %s", name, mapset) != 2)
		break;
	    if (new_mapset = (strcmp(cur_mapset, mapset) != 0)) {
		if (line)
		    line++;
		if (col)
		    line++;
		col = 0;
	    }
	    if (count >= nlist || line + new_mapset >= NLINES) {
		if (page + 1 == npages) {
		    npages++;
		    page_offset =
			(long *)G_realloc(page_offset, npages * sizeof(long));
		    page_offset[npages - 1] = offset;
		}
		break;
	    }
	    if (new_mapset) {
		struct box dummy;
		char label[GMAPSET_MAX + 7];

		strcpy(cur_mapset, mapset);
		sprintf(label, "Mapset %s", mapset);
		dobox(&dummy, label, WHITE, top + line * height, left, right,
		      0);
		line++;
	    }
	    if (col) {
		dobox(&list[count].box, name, GREY, top + line * height,
		      left + width / 2, right, 0);
		line++;
		col = 0;
	    }
	    else {
		dobox(&list[count].box, name, GREY, top + line * height, left,
		      left + width / 2, 0);
		col = 1;
	    }
	    strcpy(list[count].name, name);
	    strcpy(list[count].mapset, mapset);
	    count++;
	}
	downarrow(&more, page + 1 < npages ? BLACK : WHITE);
	uparrow(&less, page > 0 ? BLACK : WHITE);
	which = -1;
	switch (Input_pointer(objects)) {
	case -1:		/* more or less */
	    break;
	case -2:		/* cancel */
	    stat = 0;
	    continue;
	default:		/* file picked */
	    strcpy(xname, list[which].name);
	    strcpy(xmapset, list[which].mapset);
	    stat = 1;
	    continue;
	}
	G_fseek(fd, page_offset[page], 0);
	R_standard_color(WHITE);
	R_box_abs(left + 1, top + 1, right - 1, bottom - 1);
    }

    /* all done. restore what was under the window */
    right += height;		/* move it back over the sidecar */
    R_standard_color(WHITE);
    R_box_abs(left, top, right, bottom);
    R_panel_restore(tempfile1);
    R_panel_restore(tempfile2);
    R_panel_delete(tempfile1);
    R_panel_delete(tempfile2);
    R_flush();

    G_free(page_offset);
    return stat;
}