home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #include <stdio.h>
- #include <gl.h>
- #include "screenfont.h"
- #include "exglobals.h"
- #include "exbookglo.h"
-
- extern int find_blank(char *s);
-
- /***********************************************************************
- *
- * draw_demoname draws the name of each icon. If a name is more
- * than 10 characters long, it is chopped at the first blank and
- * drawn on two lines. Before draw_demoname is called, we are
- * translated to the left side of the box where the name will be drawn.
- *
- ***********************************************************************/
- void draw_demoname(struct icntmpltstruct *iconptr)
- {
- float x_offset;
- int len;
- char *s1, *s2, *s3;
- int blankpos1, blankpos2;
-
- c3s(morecolors[Black]);
-
- len = strlen(iconptr->nameptr->string);
- /* A square on the page = 2 inches. 10 characters fit inside
- the highlight box. Each highlight box is scaled .9 in x & y.
- = 1.8 inches = .18 units per character */
- if (len < 11)
- {
- x_offset = 1.0 - (float)len/2.0 *.18;
- stroke(x_offset, 0.0, 0.0, .02, .02, .02, iconptr->nameptr->string);
- }
- else
- {
- blankpos1 = find_blank(iconptr->nameptr->string);
- if (blankpos1 >= 0)
- {
- blankpos2 = find_blank(&(iconptr->nameptr->string[blankpos1+1]));
- if (blankpos2 > 0 && blankpos1 + blankpos2 < 12)
- blankpos1 = blankpos2 + blankpos1+1;
- s1 = (char *)malloc(blankpos1+1);
- strncpy(s1, iconptr->nameptr->string, blankpos1);
- s1[blankpos1] = '\0';
- s2 = (char *)malloc(len - blankpos1);
- strcpy(s2, &(iconptr->nameptr->string[blankpos1+1]) );
- x_offset = 1.0 - (float)(blankpos1-1)/2.0 *.18;
- stroke(x_offset, 0.28, 0.0, .017, .017, .017, s1);
-
- len = strlen(s2);
- if (len > 11)
- {
- s2[7] = '.';
- s2[8] = '.';
- s2[9] = '.';
- s2[10] = '\0';
- len = 10;
- }
- x_offset = 1.0 - (float)(len-1)/2.0 *.18;
- stroke(x_offset, 0.0, 0.0, .017, .017, .017, s2);
- free(s1);
- free(s2);
- }
- else /* no blanks in the name */
- {
- s1 = (char *)malloc(11);
- strncpy(s1, iconptr->nameptr->string, 7);
- s1[7] = '.';
- s1[8] = '.';
- s1[9] = '.';
- s1[10] = '\0';
- x_offset = 1.0 - 10.0/2.0 *.18;
- stroke(x_offset, 0.0, 0.0, .02, .02, .02, s1);
- }
- }
- }
-
- stroke(tx,ty,tz,sx,sy,sz,str)
- float tx,ty,tz,sx,sy,sz;
- char *str;
- {
- register int i, mode;
-
- pushmatrix();
- translate(tx,ty,tz);
- scale(sx,sy,sz);
- for (; *str; str++) {
- if (chrtbl[*str][0][0]) {
- for (i=0; mode = chrtbl[*str][i][0]; i++) {
- switch (mode) {
- case 1:
- translate(
- (float)chrtbl[*str][i][1],
- (float)chrtbl[*str][i][2],
- 0.0);
- break;
- case 2:
- bgnline();
- v2i(&chrtbl[*str][i][1]);
- break;
- case 3:
- v2i(&chrtbl[*str][i][1]);
- break;
- case 4:
- v2i(&chrtbl[*str][i][1]);
- endline();
- break;
- case 5:
- bgnpolygon();
- v2i(&chrtbl[*str][i][1]);
- break;
- case 6:
- v2i(&chrtbl[*str][i][1]);
- endpolygon();
- break;
- }
- }
- }
- }
- popmatrix();
- }
-