示例#1
0
/* Function: mb_leftext
 *
 *  Left justified text.
 */
static void
mb_leftext(Button *b, Pixel color, char *string)
{
    Vfont *f = b->root->font;

    if (string == NULL)
        return;

    gftext(b->root,f,string,
           b->x + (fchar_spacing(f," ")>>1) + 1,
           b->y + font_ycent_oset(f,b->height),
           color,TM_MASK1 );
}
示例#2
0
int mb_centext(Button *b,Pixel color,char *string)

/* centers text in menu button clips top and bottom of text */
{
    Raster *rast;
    Clipbox cb;
    Vfont *f = b->root->font;
    int txtwid;

    rast = (Raster *)(b->root);
    pj_clipbox_make(&cb, rast, 0, b->y, rast->width, b->height);
    txtwid = fstring_width(f,string);
    gftext(&cb,f,string,
           b->x + (1+b->width)/2 - txtwid/2,
           font_ycent_oset(f,b->height),
           color, TM_MASK1 );
    return(txtwid);
}
示例#3
0
Errcode build_qstrreq(Wscreen *s, 
					  Menuhdr **pmh,
					  char *hailing,     /* text at top of box */ 
					  char **ok_cancel,  /* text for buttons */
					  char *strbuf,
					  int strlength)
/* build a menu for a quick string requestor the first button in the 
 * menuhdr->mbs list will be the string request field for do_reqloop 
 * initialization */
{
Vfont *f;
Qstrwork *qw;
Button *b;
SHORT cheight;  /* character height */
SHORT lheight;	/* line height (char + interline space) */
SHORT spwidth;	/* width of space */
SHORT bwidth;   /* button width */
SHORT bheight;  /* button height */
SHORT temp;
SHORT hborder;  /* horiz border */
SHORT twidth;	/* non border width */
SHORT strwid;	/* width of string button */
SHORT strdchars;
SHORT yoff;

	if(NULL == (*pmh = pj_zalloc(sizeof(Qstrwork))))
		return(Err_no_memory);

	qw = (Qstrwork *)(*pmh);

	/* calculate font based sizes */
	f = s->mufont;
	cheight = tallest_char(f);
	lheight = font_cel_height(f);
	spwidth = fchar_spacing(f," ");
	bwidth = fchar_spacing(f,"9") * 7; /* minimum size */
	if(bwidth < (temp = widest_line(f,ok_cancel,2) + spwidth*2))
		bwidth = temp;
	bheight = (9*lheight)/5; /* 9/5 */
	hborder = (4*spwidth)/3;

	strdchars = strlength;
	if (strdchars > 32)
		strdchars = 32;
	strwid = fchar_spacing(f, "M")*strdchars + 2*spwidth;

	twidth = bwidth*3 + spwidth*4;
	if (twidth < strwid)
		twidth = strwid;
	strwid -= 2*spwidth;

	/* first button is for displaying hailing text */
	qw->hailb.x = hborder;
	qw->hailb.y = cheight;
	qw->hailb.width = twidth;
	qw->hailb.height = wwcount_lines(f,hailing,twidth,NULL)*lheight;
	qw->hailb.datme = hailing;
	qw->hailb.seeme = see_hailing;
	qw->hailb.flags = MB_NORESCALE;

	twidth += 2*hborder;

	/* make up the stringq structure */
	qw->sq.pxoff = spwidth/3;
	qw->sq.pyoff = font_ycent_oset(f,bheight);
	qw->sq.string = strbuf;
	qw->sq.dcount = strdchars;
	qw->sq.bcount = strlength;
	init_stq_string(&qw->sq);

	/* make up the stringq button */
	b = &(qw->stqb);
	b->x = (twidth - strwid)>>1;
	yoff = b->y = qw->hailb.y + qw->hailb.height + cheight;
	b->width = strwid;
	b->height = bheight;
	b->seeme = see_string_req;
	b->datme = &(qw->sq);
	b->feelme = string_close;
	b->flags = MB_NORESCALE;
	b->key_equiv = '\t';

	/* The ok button */
	yoff += bheight + cheight;
	b = &(qw->okb);
	b->feelme = mb_close_ok;
	b->width = bwidth;
	b->height = bheight;
	b->x = hborder;
	b->y = yoff;
	b->datme = *ok_cancel++;
	b->seeme = dcorner_text;
	b->flags = MB_NORESCALE;

	/* The cancel button */
	b = &(qw->canb);
	b->feelme = mb_close_cancel;
	b->width = bwidth;
	b->height = bheight;
	b->x = twidth - bwidth - hborder;
	b->y = yoff;
	b->datme = *ok_cancel;
	b->seeme = dcorner_text;
	b->flags = MB_NORESCALE;

	/* link 'em up */
	qw->mh.mbs = &(qw->stqb); /* note string field is first one */
	qw->stqb.next = &(qw->okb);
	qw->okb.next = &(qw->canb);
	qw->canb.next = &(qw->hailb);

	qw->mh.ioflags = (MBPEN|MBRIGHT|KEYHIT); /* any of this */
	qw->mh.flags = MENU_NORESCALE;
	qw->mh.seebg = seebg_white;
	qw->mh.width = twidth;
	qw->mh.height = b->y + bheight + lheight;
	menu_to_reqpos(s,&(qw->mh));
	return(0);
}