Esempio n. 1
0
void drawText(GR_WINDOW_ID id, char **text, int count) {

    int tw, th, tb;
    int xpos, ypos;
    int i;

    GR_GC_ID gc = GrNewGC();
    GR_FONT_ID font = GrCreateFont(GR_FONT_GUI_VAR, 12, 0);
    GR_WINDOW_INFO info;

    GrGetWindowInfo(id, &info);

    GrSetGCFont(gc, font);
    GrSetGCForeground(gc, FGCOLOR);
    GrSetGCBackground(gc, BGCOLOR);

    /* Get the first line of text from the array, and check the size */
    GrGetGCTextSize(gc, text[0], -1, GR_TFTOP, &tw, &th, &tb);

    ypos = (info.height - ((count * th)+ 3)) / 2;

    /* Draw each line of the instructions */

    for(i = 0; i < count; i++) {
        GrGetGCTextSize(gc, text[i], -1, GR_TFTOP, &tw, &th, &tb);
        xpos = (info.width - tw) / 2;
        GrText(id, gc, xpos, ypos, text[i], -1, GR_TFTOP);

        ypos += th + 3;
    }

    GrDestroyGC(gc);
    GrDestroyFont(font);
}
Esempio n. 2
0
static void idw_draw_screen() {
  int i, dif=0, max=0;
  GR_SIZE width, height, base;
  	
	// This white line is printed because the sheet leaves two pixels
  GrSetGCForeground(idw_gc, WHITE);
  GrLine(idw_wid, idw_gc, 0, 0, screen_info.cols, 0);
  GrSetGCForeground(idw_gc, BLACK);
	
	// calculate the biggest space you can leave for the right-side column
	for (i=0; i < game.screen->count; i++)
	{
	  GrGetGCTextSize(idw_gc, game.screen->menuitems[i].value, -1, GR_TFASCII, &width, &height, &base);
    width+=5;
    
    if (width > max) max = width;
	}

  GrGetGCTextSize(idw_gc, "M", -1, GR_TFASCII, &width, &height, &base);
	height += 4;

  
  // print all the menus
  for (i=0; i < game.screen->count; i++)
  {
    if ((game.select == i) && (game.screen->menuitems[i].sheet)) {
			GrSetGCForeground(idw_gc, BLACK);
			GrFillRect(idw_wid, idw_gc, 0, 1 + i * height, screen_info.cols, height);
			GrSetGCForeground(idw_gc, WHITE);
			GrSetGCUseBackground(idw_gc, GR_TRUE);
		} else
		{
			GrSetGCUseBackground(idw_gc, GR_FALSE);
			GrSetGCForeground(idw_gc, WHITE);
			GrFillRect(idw_wid, idw_gc, 0, 1 + i * height, screen_info.cols, height);
			GrSetGCForeground(idw_gc, BLACK);
		}
		
		// highlite drug's name if you can make a positive sale
		if ((game.screen == &sell) && (game.drugs[i])) {
      dif = (game.price[i]*game.drugs[i] - game.old_price[i]);
    
      if (dif > 0) {
        GrText(idw_wid, idw_gc, 9, 1 + ((i + 1) * height - 4), game.screen->menuitems[i].caption, -1, GR_TFASCII);
      }
    }
    
    GrText(idw_wid, idw_gc, 8, 1 + ((i + 1) * height - 4), game.screen->menuitems[i].caption, -1, GR_TFASCII);
    
    // right-side column
    GrText(idw_wid, idw_gc, screen_info.cols - max, 1 + ((i + 1) * height - 4), game.screen->menuitems[i].value, -1, GR_TFASCII);
  }
}
Esempio n. 3
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. 4
0
/*
 * Draw a cell on the board.
 */
static void
drawcell(POS pos)
{
    GR_COORD	x;
    GR_COORD	y;
    GR_SIZE		chwidth;
    GR_SIZE		chheight;
    GR_SIZE		chbase;
    CELL		cell;
    GR_CHAR		ch;

    cell = board[pos];
    if (!isknown(cell))
        return;

    ch = displaychar(cell);
    if (ch == F_WRONG) {
        drawbomb(pos, greengc, GR_FALSE);
        return;
    }

    if (isold(cell)) {
        clearcell(pos);
        cellcenter(pos, &x, &y);
        GrGetGCTextSize(boardgc, &ch, 1, GR_TFASCII, &chwidth,
                        &chheight, &chbase);
        GrText(boardwid, boardgc, x - chwidth / 2 + 1,
               y + chheight / 2, &ch, 1, GR_TFBOTTOM);
        return;
    }

    drawbomb(pos, redgc, GR_FALSE);
}
Esempio n. 5
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. 6
0
/*
 * Here when a keyboard press occurs.
 */
void
do_keystroke(GR_EVENT_KEYSTROKE	*kp)
{
	GR_SIZE		width;		/* width of character */
	GR_SIZE		height;		/* height of character */
	GR_SIZE		base;		/* height of baseline */

	if (kp->wid == w4) {
		if (lineok) {
			GrLine(w4, gc4, xorxpos, xorypos, linexpos, lineypos);
			lineok = GR_FALSE;
		}
		return;
	}

	GrGetGCTextSize(gc1, &kp->ch, 1, GR_TFASCII, &width, &height, &base);
	if ((kp->ch == '\r') || (kp->ch == '\n')) {
		xpos = begxpos;
		ypos += height;
		return;
	}
	if (kp->ch == '\b') {		/* assumes fixed width font!! */
		if (xpos <= begxpos)
			return;
		xpos -= width;
		GrSetGCForeground(gc3, BROWN);
		GrFillRect(w1, gc3, xpos, ypos - height + base + 1,
			width, height);
		return;
	}
	GrText(w1, gc1, xpos, ypos + base, &kp->ch, 1, 0);
	xpos += width;
}
Esempio n. 7
0
void
draw_set(char *name, int mode)
{
	int x;
	int tw, th, tb;
	GR_POINT points[4];
	GR_GC_ID gc = GrNewGC();

	GrSetGCForeground(gc, WHITE);
	GrSetGCBackground(gc, GRAY);

	GrGetGCTextSize(gc, name, -1, GR_TFTOP, &tw, &th, &tb);

	x = g_x + (tw - 50) / 2;

	GrText(g_main, gc, g_x, 5, name, -1, GR_TFTOP);

	g_x += (tw + 10);

	GrSetGCFillMode(gc, mode);

	if (mode == GR_FILL_STIPPLE)
		GrSetGCForeground(gc, YELLOW);
	else {
		GrSetGCForeground(gc, WHITE);
		GrSetGCBackground(gc, BLUE);
	}

	if (mode == GR_FILL_TILE) {
		GrSetGCTile(gc, g_pixmap, 16, 16);
	}

	if (mode == GR_FILL_STIPPLE || mode == GR_FILL_OPAQUE_STIPPLE)
		GrSetGCStipple(gc, g_stipple2, 2, 2);

	GrFillRect(g_main, gc, x, 25, 50, 50);

	if (mode == GR_FILL_STIPPLE || mode == GR_FILL_OPAQUE_STIPPLE)
		GrSetGCStipple(gc, g_stipple1, 7, 7);

	GrFillEllipse(g_main, gc, x + 25, 105, 25, 25);

	if (mode == GR_FILL_STIPPLE || mode == GR_FILL_OPAQUE_STIPPLE)
		GrSetGCStipple(gc, g_stipple3, 3, 2);

	points[0].x = points[3].x = x;
	points[0].y = points[3].y = 165;

	points[1].x = x + 50;
	points[1].y = 165;

	points[2].x = x + 25;
	points[2].y = 215;

	GrFillPoly(g_main, gc, 4, points);

	GrDestroyGC(gc);
}
Esempio n. 8
0
static void draw_dialer() {
    GR_SIZE width, height, base;

    GrSetGCUseBackground(dialer_gc, GR_FALSE);
    GrSetGCForeground(dialer_gc, GR_RGB(0,0,0));
    GrGetGCTextSize(dialer_gc, digitdisplay, -1, GR_TFASCII, &width, &height, &base);
    /*
    GrRect(dialer_wid, dialer_gc, CXOFF, CYOFF, CWIDTH, cbh);
    GrSetGCForeground(dialer_gc, GR_RGB(255,255,255));
    GrFillRect(dialer_wid, dialer_gc, CXOFF+1, CYOFF+1, CWIDTH-2, cbh-2);
    GrSetGCForeground(dialer_gc, GR_RGB(0,0,0));
    GrText(dialer_wid, dialer_gc, CXOFF+(CWIDTH-width-4),
    	CYOFF+((cbh/2)-(height/2)), digitdisplay, -1, GR_TFASCII|GR_TFTOP);
    */

    /* range check */
    if(current_dialer_button < 0)
        current_dialer_button = 15;
    else if(current_dialer_button >= 16)
        current_dialer_button = 0;

    /* compute button sizings */
    xlocal=CXOFF+((cbw+cxgap)*(current_dialer_button%4));
    ylocal=CBYOFF+((cbh+cygap)*(current_dialer_button/4));
    lastxlocal=CXOFF+((cbw+cxgap)*(last_bouvet_item%4));
    lastylocal=CBYOFF+((cbh+cygap)*(last_bouvet_item/4));

    GrSetGCForeground(dialer_gc, GR_RGB(255,255,255));
    GrFillRect(dialer_wid, dialer_gc, lastxlocal+1, lastylocal+1, cbw-2, cbh-2);
    GrSetGCForeground(dialer_gc, GR_RGB(0,0,0));
    GrGetGCTextSize(dialer_gc, dialerpad[last_bouvet_item], -1, GR_TFASCII,
                    &width, &height, &base);
    GrText(dialer_wid, dialer_gc,
           lastxlocal+((cbw/2)-(width/2)), lastylocal+((cbh/2)-(height/2)),
           dialerpad[last_bouvet_item], -1, GR_TFASCII|GR_TFTOP);
    GrFillRect(dialer_wid, dialer_gc, xlocal, ylocal, cbw, cbh);
    GrSetGCForeground(dialer_gc, GR_RGB(255,255,255));
    GrGetGCTextSize(dialer_gc, dialerpad[current_dialer_button], -1, GR_TFASCII,
                    &width, &height, &base);
    GrText(dialer_wid, dialer_gc,
           xlocal+((cbw/2)-(width/2)), ylocal+((cbh/2)-(height/2)),
           dialerpad[current_dialer_button], -1, GR_TFASCII|GR_TFTOP);
    GrSetGCUseBackground(dialer_gc, GR_FALSE);
    GrSetGCMode(dialer_gc, GR_MODE_SET);
}
Esempio n. 9
0
static void msg_build_msg(char *msg_message)
{
	char *curtextptr;
	int currentLine = 0;

	curtextptr = msg_message;
	if((msglines = (char **)malloc(sizeof(char *) * 8))==NULL) {
		fprintf(stderr, "malloc failed");
		return;
	}
	
	while(*curtextptr != '\0' || currentLine > 8) {
		char *sol;

		sol = curtextptr;
		while (1) {
			GR_SIZE width, height, base;

			if(*curtextptr == '\r') /* ignore '\r' */
				curtextptr++;
			if(*curtextptr == '\n') {
				curtextptr++;
				break;
			}
			else if(*curtextptr == '\0')
				break;

			GrGetGCTextSize(msg_gc, sol, curtextptr - sol +
					1, GR_TFASCII, &width, &height, &base);

			if(width > screen_info.cols - 15) {
				char *optr;
		
				/* backtrack to the last word */
				for(optr=curtextptr; optr>sol; optr--) {
					if(isspace(*optr)||*optr=='\t') {
						curtextptr=optr;
						curtextptr++;
						break;
					}
				}
				break;
			}
			curtextptr++;
		}

		if((msglines[currentLine] = malloc((curtextptr-sol + 1) *
						sizeof(char)))==NULL) {
			fprintf(stderr, "malloc failed");
			return;
		}
		snprintf(msglines[currentLine], curtextptr-sol+1, "%s", sol);
		currentLine++;
	}
	linenum = currentLine;
}
Esempio n. 10
0
static void idw_draw_sheet(TSheet *sheet) {
  GR_SIZE width, height, base;
  char str[50], *ap;
  int i;
	
	if (sheet == NULL) {
    sheet = game.screen->menuitems[game.select].sheet;
  }
	
	// draw the title
  pz_draw_header (sheet->title);

  GrGetGCTextSize(idw_gc, sheet->button, -1, GR_TFASCII, &width, &height, &base);
  height+=4;  
  
  // (left, top, right, bottom)
  GrSetGCForeground(idw_gc, BLACK);
  GrLine(idw_wid, idw_gc, 20, 0, 20, screen_info.rows-44);
  GrLine(idw_wid, idw_gc, 20, screen_info.rows-44, screen_info.cols-20, screen_info.rows-44);
  GrLine(idw_wid, idw_gc, screen_info.cols-20, 0, screen_info.cols-20, screen_info.rows-44);
  
	GrSetGCForeground(idw_gc, WHITE);
  GrFillRect(idw_wid, idw_gc, 21, 0, screen_info.cols-41, screen_info.rows-44);
	GrSetGCForeground(idw_gc, BLACK);
  GrSetGCUseBackground(idw_gc, GR_FALSE);
  GrSetGCMode(idw_gc, GR_MODE_SET);
  
  ap = strtok(sheet->text, "\n");
  for (i=0; ap != NULL; i++) {
    GrText(idw_wid, idw_gc, 30, 1 + ((i + 1) * height - 4), ap, -1, GR_TFASCII);
    ap = strtok(NULL, "\n");
  }
  
	if (sheet->ammount != -1)
	{
    // print ammount
    sprintf(str, "Ammount: %d", game.ammount);
    GrText(idw_wid, idw_gc, 30, 50, str, -1, GR_TFASCII);
  } else {
    // the next time the user presses the middle button the sheet will disappear
    game.dismiss_sheet = 1;
  }

  // print the single menu option
  GrSetGCForeground(idw_gc, BLACK);
  GrFillRect(idw_wid, idw_gc, 21, 1 + 4 * height-4, screen_info.cols-41, height-1);
  GrSetGCForeground(idw_gc, WHITE);
  GrSetGCUseBackground(idw_gc, GR_TRUE);

  GrText(idw_wid, idw_gc, (screen_info.cols/2)-width+4, (5 * height - 8), sheet->button, -1, GR_TFASCII);

  // we're in a transaction
  game.in_transaction = 1;  
}
Esempio n. 11
0
/*
 * Draw a button which has a specified label string centered in it.
 */
static void
drawbutton(GR_WINDOW_ID window, char *label)
{
    GR_SIZE		width;
    GR_SIZE		height;
    GR_SIZE		base;

    GrGetGCTextSize(buttongc, label, strlen(label), GR_TFASCII, &width,
                    &height, &base);
    GrText(window, buttongc, (BUTTONWIDTH - width) / 2,
           (BUTTONHEIGHT - height) / 2 + height - 1,
           label, -1, GR_TFBOTTOM);
}
Esempio n. 12
0
static void draw_msg()
{
	char buf[128];
	int width, height, depth;

	strcpy(buf, "");

	if(winner != NONE)
	{
		switch(winner)
		{
			case PLAYER:
				strcpy(buf, "You Win!");
			break;

			case DEALER:
				strcpy(buf, "Dealer Wins!");
			break;

			case TIE:
				strcpy(buf, "Tie Game!");
			break;
		}
	}

	if(msg != NONE)
	{
		switch(msg)
		{
			case BET:
				strcpy(buf, "Place Your Bet");
			break;

			case GAMEOVER:
				strcpy(buf, "Game Over");
			break;

			case DEALER_HIT:
				strcpy(buf, "Dealer Drew Card");
			break;

			case DEALER_STAY:
				strcpy(buf, "Dealer Chose To Stay");
			break;
		}
	}

	GrGetGCTextSize (blackjack_gc, buf, -1, GR_TFASCII, &width, &height, &depth);
	GrText(blackjack_wid, blackjack_gc,
	(screen_info.cols / 2) - (width / 2), 15, buf,  -1, GR_TFASCII);
}
Esempio n. 13
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. 14
0
static void
GrGetGCTextSizeWrapper(void *r)
{
	nxGetGCTextSizeReq *req = r;
	GR_SIZE             retwidth, retheight, retbase;

	GrGetGCTextSize(req->gcid, GetReqData(req), req->charcount,
		req->flags, &retwidth, &retheight, &retbase);

 	GsWriteType(current_fd,GrNumGetGCTextSize);
	GsWrite(current_fd, &retwidth, sizeof(retwidth));
	GsWrite(current_fd, &retheight, sizeof(retheight));
	GsWrite(current_fd, &retbase, sizeof(retbase));
}
Esempio n. 15
0
static void video_status_message(char *msg)
{
	GR_SIZE txt_width, txt_height, txt_base;
	GR_COORD txt_x, txt_y;

	GrGetGCTextSize(video_gc, msg, -1, GR_TFASCII, &txt_width, &txt_height, &txt_base);
	txt_x = (screen_info.cols - (txt_width + 10)) >> 1;
	txt_y = (screen_info.rows - (txt_height + 10)) >> 1;
	GrSetGCForeground(video_gc, GR_RGB(255,255,255));
	GrFillRect(video_wid, video_gc, txt_x, txt_y, txt_width + 10, txt_height + 10);
	GrSetGCForeground(video_gc, GR_RGB(0,0,0));
	GrRect(video_wid, video_gc, txt_x, txt_y, txt_width + 10, txt_height + 10);
	GrText(video_wid, video_gc, txt_x + 5, txt_y + txt_base + 5, msg, -1, GR_TFASCII);
}
Esempio n. 16
0
void draw_item(lstate *state, litem *item)
{
	GR_SIZE width, height, base, x, len;

	GrDrawImageToFit(item->wid, state->gc, ICON_X_POSITION, ICON_Y_POSITION,
				ICON_WIDTH, ICON_HEIGHT, item->iconid);

	len = strlen(item->name);
	GrGetGCTextSize(state->gc, item->name, len, 0, &width, &height, &base);
	if(width >= ITEM_WIDTH) x = 0;
	else x = (ITEM_WIDTH - width) / 2;

	GrText(item->wid, state->gc, x, TEXT_Y_POSITION, item->name, len, 0);
}
Esempio n. 17
0
//------------------------------------------------------------------------------
// Function Name  : ui_draw_text_window()
// Description    : 
//------------------------------------------------------------------------------
void ui_draw_text_window(GR_WINDOW_ID wid, int x, int y, int w, int h,
			u32 size, u32 co, u32 align, char *str)
{
	int align_x, align_y, len, width, height, base;
	GR_GC_INFO gc_info;
	
	GrGetGCInfo(g_gc, &gc_info);
	GrSetGCUseBackground(g_gc, FALSE);
	GrSetGCForeground(g_gc, co);
	GrSetFontSizeEx(g_font, size, size);

	len = strlen(str);

	align_x = x;
	align_y = y;
	if (align != TXT_ALIGN_NONE) {
		GrGetGCTextSize(g_gc, str, len, MWTF_DBCS_EUCKR,
			&width, &height, &base);

		// horizontal align
		if (align & TXT_HALIGN_CENTER) {
			if (width < w) 
				align_x = x + ((w - width) / 2);
		} else if (align & TXT_HALIGN_RIGHT) {
			if (width < w) 
				align_x = x + (w - width);
		}

		// vertical align
		if (align & TXT_VALIGN_MIDDLE) {
			if (height < h) 
				align_y = y + ((h - height) / 2);
		} else if (align & TXT_VALIGN_BOTTOM) {
			if (height < h) 
				align_y = y + (h - height);
		}
	}

	GrText(wid, g_gc, align_x, align_y, str, len, MWTF_DBCS_EUCKR|GR_TFTOP);

	//Recover GC Info
	GrSetGCUseBackground(g_gc, gc_info.usebackground);
	GrSetGCForeground(g_gc, gc_info.foreground);
}
Esempio n. 18
0
// Draws a box with the score a person got and their high score.
static void draw_result()
{
	char strScore[30];
	char strHighScore[35];
	int height, width, base;
	sprintf(strScore, "Score:%li", score);
	if (highScore < score)
		highScore = score;
	sprintf(strHighScore, "High Score:%li", highScore);
	GrGetGCTextSize(tunnel_gc, strHighScore, -1, GR_TFASCII, &width, &height, &base);
	
	GrSetGCForeground(tunnel_gc, WHITE);
	GrFillRect(tunnel_wid, tunnel_gc, (wi.width - width) / 2 - 3, wi.height / 2 - height - 3, width + 8, height * 2 + 2);
	GrSetGCForeground(tunnel_gc, BLACK);
	GrRect(tunnel_wid, tunnel_gc, (wi.width - width) / 2 - 3, wi.height / 2 - height - 3, width + 8, height * 2 + 2);
	GrText (tunnel_wid, tunnel_gc, (wi.width - width) / 2, wi.height / 2 - height / 2 + 2, strScore, -1, GR_TFASCII );
	GrText (tunnel_wid, tunnel_gc, (wi.width - width) / 2, wi.height / 2 + height / 2 + 2, strHighScore, -1, GR_TFASCII );
	
}
Esempio n. 19
0
void menu_update_menu(menu_st *menulist)
{
	int i;

	/* wipe all of the pixmaps */
	for (i = 0; i < menulist->screen_items; i++) {
		menu_clear_pixmap(menulist, i);
	}

	if (get_current_font() != menulist->font) {
		int items;
		int h = menulist->height;
		GrDestroyGC(menulist->menu_gc);
		menulist->menu_gc = pz_get_gc(1);
		GrGetGCTextSize(menulist->menu_gc, "abcdefghijhlmnopqrstuvwxyz"
				"ABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, GR_TFASCII,
				&menulist->width, &menulist->height,
				&menulist->base);
		/* add a 2px padding to the text */
		menulist->height += 4;
		items = (int)menulist->h/menulist->height;
		if (menulist->height != h) {
			for (i = 0; i < menulist->screen_items; i++)
				GrDestroyWindow(menulist->pixmaps[i]);
			free(menulist->pixmaps);
			free(menulist->pixmap_pos);
			create_pixmaps(menulist, items);
		}
		menulist->screen_items = items;
		menulist->font = get_current_font();
		if (menulist->sel > menulist->top_item + menulist->screen_items)
			menu_select_item(menulist, menulist->sel);

	}
	
	/* force the rest of the redraw */
	menulist->scheme_no = appearance_get_color_scheme();
	/* NOTE: if "color scheme" is anywhere other than on the first
	   screen's worth of menu items, this doesn't work correctly,
	   but that's not an issue right now */
	menulist->init = 0;
}
Esempio n. 20
0
static void dialer_do_draw() {
    int i;
    GR_SIZE width, height, base;
    pz_draw_header(_("Rose Quartz Box"));
    digitdisplay[0]='\0';
    numfull = 0;
    littr = 0;
    GrSetGCForeground(dialer_gc, GR_RGB(0,0,0));
    for(i=0; i<=15; i++) {
        GrGetGCTextSize(dialer_gc, dialerpad[i], -1, GR_TFASCII,
                        &width, &height, &base);
        GrRect(dialer_wid, dialer_gc,CXOFF+((cbw+cxgap)*(i%4)),
               CBYOFF+((cbh+cygap)*(i/4)), cbw, cbh);
        GrText(dialer_wid, dialer_gc,
               CXOFF+((cbw+cxgap)*(i%4))+((cbw/2)-(width/2)),
               CBYOFF+((cbh+cygap)*(i/4))+((cbh/2)-(height/2)),
               dialerpad[i], -1, GR_TFASCII|GR_TFTOP);
    }
    draw_dialer();
}
Esempio n. 21
0
static void
lstCalcHeight(HWND hwnd)
{
	int xw, xh, xb;
	PLISTBOXDATA pData = (PLISTBOXDATA) hwnd->userdata;
	BOOL other = FALSE;
	if (ISOWNERDRAW(GetWindowLong(hwnd, GWL_STYLE)))
		other = lbAskMeasureItem(hwnd, -1, &pData->itemHeight);

	if (!other || pData->itemHeight == 0) {
		HDC hdc = GetDC(hwnd);
#if MWCLIENT			/* nanox client */
		GrSetGCFont(hdc->gc, hdc->font->fontid);
		GrGetGCTextSize(hdc->gc, "X", 1, MWTF_ASCII, &xw, &xh, &xb);
#else
		SelectObject(hdc, GET_WND_FONT(hwnd));
		GdGetTextSize(hdc->font->pfont, "X", 1, &xw, &xh, &xb, MWTF_ASCII);
#endif
		ReleaseDC(hwnd, hdc);
		pData->itemHeight = xh + 1;
	} else
		pData->dwFlags |= LBF_USERMEASURE;
}
Esempio n. 22
0
void periodic_draw(void)
{
	int cellsize = (screen_info.cols-1)/18;
	int bx = (screen_info.cols-(cellsize*18 + 1))/2;
	int by = 4;
	
	char buf[40];
	
	int tw, th, tb;
	int ty = by + cellsize*11 + 4;
	GrGetGCTextSize(periodic_gc, " ", 1, GR_TFASCII, &tw, &th, &tb);
	ty += (th-tb);
	
	/* copy the table */
	GrCopyArea(periodic_wid, periodic_gc, 0, 0, screen_info.cols, screen_info.rows - HEADER_TOPLINE, periodic_bufwid, 0, 0, MWROP_SRCCOPY);
	
	/* draw the element */
	periodic_draw_element(periodic_wid, periodic_gc, periodic_sel, bx, by, cellsize);
	
	/* draw element text */
	snprintf(buf, 40, _("#%d - %s - %s"), (periodic_sel+1), periodic_elements[periodic_sel].symbol, periodic_elements[periodic_sel].name);
	GrSetGCForeground(periodic_gc, GR_RGB(0,0,0));
	GrText(periodic_wid, periodic_gc, bx, ty, buf, -1, GR_TFASCII);
}
Esempio n. 23
0
void text_init()
{
	GrGetGCTextSize(gc1, "A", 1, GR_TFASCII, &width, &height, &base);
}
Esempio n. 24
0
/* Assign an arbitrary char to the cursor */
Cursor
XCreateGlyphCursor(Display * display, Font source_font, Font mask_font,
		   unsigned int source_char, unsigned int mask_char,
		   XColor XCONST * foreground, XColor XCONST * background)
{
	Cursor		ret;
	int		tw[2], th[2], tb[2];
	unsigned char	ch[2];
	GR_GC_ID	gc;
	GR_WINDOW_ID	cursor;
	GR_COLOR	fc, bc;
	GR_RECT		cbb, mbb;
	GR_FONT_INFO	srcinfo, maskinfo;

	gc = GrNewGC();
	/*GrSetGCUseBackground(gc, GR_FALSE);*/ /* assume NewGC defaults TRUE*/
	GrSetGCForeground(gc, GR_RGB(255, 255, 255));
	GrSetGCBackground(gc, GR_RGB(  0,   0,   0));

	/* Draw both the fonts into their appropriate pixmap, and create the cursor */
	GrGetFontInfo((GR_FONT_ID) source_font, &srcinfo);
	GrGetFontInfo((GR_FONT_ID) mask_font, &maskinfo);

	ch[0] = srcinfo.firstchar + source_char;
	ch[1] = maskinfo.firstchar + mask_char;

	/* Use the mask as the determining size */
	GrSetGCFont(gc, (GR_FONT_ID) mask_font);

	GrGetGCTextSize(gc, &ch[0], 1, GR_TFTOP, &tw[0], &th[0], &tb[0]);
	GrGetGCTextSize(gc, &ch[1], 1, GR_TFTOP, &tw[1], &th[1], &tb[1]);

	cursor = GrNewPixmap(tw[1] * 2, th[1], 0);

	/* Draw the mask first, to avoid having to switch fonts in the GC */
	GrText(cursor, gc, tw[1], 0, &ch[1], 1, GR_TFTOP|GR_TFASCII);

	/* Offset the first char by 1 1 */
	GrSetGCFont(gc, (GR_FONT_ID) source_font);
	GrText(cursor, gc, 1, 1, &ch[0], 1, GR_TFTOP|GR_TFASCII);

	/* Calculate the bounding box */
	cbb.x = 0;
	cbb.y = 0;
	cbb.width = tw[0];
	cbb.height = th[0];

	mbb.x = tw[1];
	mbb.y = 0;
	mbb.width = tw[1];
	mbb.height = th[1];

	fc = GR_RGB(foreground->red >> 8, foreground->green >> 8,
			foreground->blue >> 8);
	bc = GR_RGB(background->red >> 8, background->green >> 8,
			background->blue >> 8);
	/* cursor hotspot is (leftbearing, ascent)*/
	ret = _nxCreateCursor(cursor, &cbb, cursor, &mbb, 0, tb[1],
			fc, bc);

	GrDestroyWindow(cursor);
	GrDestroyGC(gc);
	return ret;
}
Esempio n. 25
0
//Draws the main GUI
static void draw_window()
{
	/**0**************************/
	/**1*XXX    BlackJack    XXX**/
	/**2*******XXXXX Wins!********/
	/**3**************************/
	/**4**************************/
	/**5**************************/
	/**6**************************/
	/**7**************************/
	/**8***Dealer*****Your Hand***/
	/**9***#######****#######*****/
	/*10*****(##)*******(##)******/
	/*11**************************/
	/*12*Bid      STAY       Pot**/
	/*13*110               11100**/
	/*14**************************/

	char buf[128];
	int i, width, height, depth;

	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);

	/*1*/		draw_header();

	/*2*/		draw_msg();


	/*8-9-10*/	if(gameRunning == 1)
				{
					/*8-1*/	GrGetGCTextSize (blackjack_gc, "Dealer", -1, GR_TFASCII, &width, &height, &depth);
							GrText(blackjack_wid, blackjack_gc,
								  (screen_info.cols / 3.5) - (width / 2),
								   45, "Dealer",  -1, GR_TFASCII);

					/*9-1*/ strcpy(buf, " ");

							for(i=0;i<dealer_ncards;i++)
							{
								if(winner == NONE)
								{
									sprintf(buf, "%s%s ", buf, (i == 1) ? cardLetter(dealer_cards[i]) : "X");
								}else{
									sprintf(buf, "%s%s ", buf, cardLetter(dealer_cards[i]));
								}
							}

							GrGetGCTextSize (blackjack_gc, buf, -1, GR_TFASCII, &width, &height, &depth);
							GrText(blackjack_wid, blackjack_gc,
								  (screen_info.cols / 3.5) - (width / 2),
								   58, buf,  -1, GR_TFASCII);

					/*10-1*/if(winner != NONE)
							{
								sprintf(buf, "(%i)", dealer_hand);
								GrGetGCTextSize (blackjack_gc, buf, -1, GR_TFASCII, &width, &height, &depth);
								GrText(blackjack_wid, blackjack_gc,
									  (screen_info.cols / 3.5) - (width / 2),
									   70, buf,  -1, GR_TFASCII);
							}


					/*8-2*/	GrGetGCTextSize (blackjack_gc, "You Hand", -1, GR_TFASCII, &width, &height, &depth);
							GrText(blackjack_wid, blackjack_gc,
								  (screen_info.cols / 1.5) - (width / 2),
								   45, "Your Hand",  -1, GR_TFASCII);

					/*9-2*/ strcpy(buf, " ");

							for(i=0;i<player_ncards;i++)
							{
								sprintf(buf, "%s%s ", buf, cardLetter(player_cards[i]));
							}

							GrGetGCTextSize (blackjack_gc, buf, -1, GR_TFASCII, &width, &height, &depth);
							GrText(blackjack_wid, blackjack_gc,
								  (screen_info.cols / 1.5) - (width / 2),
								   58, buf,  -1, GR_TFASCII);

					/*10-2*/sprintf(buf, "(%i)", player_hand);
							GrGetGCTextSize (blackjack_gc, buf, -1, GR_TFASCII, &width, &height, &depth);
								GrText(blackjack_wid, blackjack_gc,
								  	  (screen_info.cols / 1.5) - (width / 2),
								   	   70, buf,  -1, GR_TFASCII);
				}


	/*12-1*/	GrText(blackjack_wid, blackjack_gc, 1,
				   screen_info.rows - 37, "Bet",  -1, GR_TFASCII);

	/*12-2*/	if(player_stay == 1 && winner == NONE)
				{
					GrGetGCTextSize (blackjack_gc, "STAY", -1, GR_TFASCII, &width, &height, &depth);
					GrText(blackjack_wid, blackjack_gc,
						  (screen_info.cols / 2) - (width / 2),
						   screen_info.rows - 37, "STAY",  -1, GR_TFASCII);
				}

	/*12-3*/	GrText(blackjack_wid, blackjack_gc,
					   screen_info.cols - 18,
					   screen_info.rows - 37, "Pot",  -1, GR_TFASCII);


	/*13-1*/		sprintf(buf, "%ld", player_bet);
				GrText(blackjack_wid, blackjack_gc, 1,
				screen_info.rows - 25, buf,  -1, GR_TFASCII);

	/*13-2*/		sprintf(buf, "%ld", player_pot);
				GrGetGCTextSize (blackjack_gc, buf, -1, GR_TFASCII, &width, &height, &depth);
				GrText(blackjack_wid, blackjack_gc,
					   screen_info.cols - (width + 2),
					   screen_info.rows - 25, buf,  -1, GR_TFASCII);

}
Esempio n. 26
0
int
main(int argc, char **argv)
{
	int		t = 1;
	GR_EVENT	event;		/* current event */

	while (t < argc) {
		if (!strcmp("-t", argv[t])) {
			bTextwin = GR_TRUE;
			++t;
			continue;
		}
	}

	if (GrOpen() < 0) {
		fprintf(stderr, "cannot open graphics\n");
		exit(1);
	}

	if (bTextwin) {
		/* create text output window for debugging*/
		wt = GrNewWindow(GR_ROOT_WINDOW_ID, 50, 20,
				TEXTWIN_WIDTH, TEXTWIN_HEIGHT, 5, BLACK, GREEN);
		GrSelectEvents(wt, 
			GR_EVENT_MASK_CLOSE_REQ | GR_EVENT_MASK_KEY_DOWN
			| GR_EVENT_MASK_EXPOSURE);
		GrMapWindow(wt);
		gct = GrNewGC();
		GrSetGCForeground(gct, GREEN);
		GrGetGCTextSize(gct, "A",1, GR_TFASCII, &width, &height, &base);
		GrSetGCFont(gct, GrCreateFont(GR_FONT_SYSTEM_FIXED, 0, NULL));
		gctb = GrNewGC();
		GrSetGCForeground(gctb, BLACK);
	}

	/* create scribble input window*/
	w = create_scribble();

	while (1) {
		GrGetNextEvent(&event);

		switch (event.type) {
			case GR_EVENT_TYPE_BUTTON_DOWN:
				do_buttondown(&event.button);
				break;

			case GR_EVENT_TYPE_BUTTON_UP:
				do_buttonup(&event.button);
				break;

			case GR_EVENT_TYPE_MOUSE_POSITION:
			case GR_EVENT_TYPE_MOUSE_MOTION:
				do_motion(&event.mouse);
				break;

			case GR_EVENT_TYPE_FOCUS_IN:
				do_focusin(&event.general);
				break;

			case GR_EVENT_TYPE_KEY_DOWN:
				do_keystroke(&event.keystroke);
				break;

			case GR_EVENT_TYPE_EXPOSURE:
				do_exposure(&event.exposure);
				break;

			case GR_EVENT_TYPE_CLOSE_REQ:
				GrClose();
				exit(0);
		}
	}
}
Esempio n. 27
0
int
main(int argc,char **argv)
{
	GR_EVENT	event;		/* current event */
	struct app_info	* act;
	int		width, height;

#ifdef USE_WEIRD_POINTER
	GR_BITMAP	bitmap1fg[7];	/* bitmaps for first cursor */
	GR_BITMAP	bitmap1bg[7];
#endif

	for(act = Apps; act->app_id[0] != '\0'; act++, num_apps++);

	if (GrOpen() < 0) {
		GrError("cannot open graphics\n");
		return 1;
	}
	
	GrGetScreenInfo(&si);

	signal(SIGCHLD, &reaper);

	gc = GrNewGC();
	bgc = GrNewGC();

	GrSetGCForeground(bgc, GRAY);
	GrSetGCFont(gc, GrCreateFontEx(GR_FONT_SYSTEM_FIXED, 0, 0, NULL));

	GrGetGCTextSize(gc, "A", 1, GR_TFASCII, &fwidth, &fheight, &fbase);
	width = fwidth * 8 + 4;
	height = (fheight) * num_apps + 4;

	w1 = GrNewWindow(GR_ROOT_WINDOW_ID, 5, 5, width,
		height, 1, WHITE, BLACK);

	GrSelectEvents(w1, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_BUTTON_DOWN
			| GR_EVENT_MASK_CLOSE_REQ);
	GrSelectEvents(GR_ROOT_WINDOW_ID, GR_EVENT_MASK_EXPOSURE |
					GR_EVENT_MASK_CHLD_UPDATE);

	GrMapWindow(w1);

#ifdef USE_WEIRD_POINTER
	bitmap1bg[0] = MASK(_,_,X,X,X,_,_);
	bitmap1bg[1] = MASK(_,X,X,X,X,X,_);
	bitmap1bg[2] = MASK(_,X,X,X,X,X,_);
	bitmap1bg[3] = MASK(_,X,X,X,X,X,_);
	bitmap1bg[4] = MASK(_,X,X,X,X,X,_);
	bitmap1bg[5] = MASK(_,X,X,X,X,X,_);
	bitmap1bg[6] = MASK(X,X,X,X,X,X,X);

	bitmap1fg[0] = MASK(_,_,_,_,_,_,_);
	bitmap1fg[1] = MASK(_,_,_,X,_,_,_);
	bitmap1fg[2] = MASK(_,_,X,X,X,_,_);
	bitmap1fg[3] = MASK(_,_,X,X,X,_,_);
	bitmap1fg[4] = MASK(_,_,X,X,X,_,_);
	bitmap1fg[5] = MASK(_,_,X,X,X,_,_);
	bitmap1fg[6] = MASK(_,X,X,X,X,X,_);

	GrSetCursor(w1, 7, 7, 3, 3, WHITE, BLACK, bitmap1fg, bitmap1bg);
#endif

	GrFillRect(GR_ROOT_WINDOW_ID, bgc, 0, 0, si.cols, si.rows);

	GrSetGCForeground(gc, BLACK);
	GrSetGCBackground(gc, WHITE);

	while (1) {
		GrGetNextEvent(&event);

		switch (event.type) {
			case GR_EVENT_TYPE_EXPOSURE:
				do_exposure(&event.exposure);
				break;
			case GR_EVENT_TYPE_BUTTON_DOWN:
				do_buttondown(&event.button);
				break;
			case GR_EVENT_TYPE_BUTTON_UP:
				do_buttonup(&event.button);
				break;
			case GR_EVENT_TYPE_UPDATE:
				do_update(&event.update);
				break;
			case GR_EVENT_TYPE_MOUSE_POSITION:
				do_mouse(&event.mouse);
				break;
			case GR_EVENT_TYPE_CLOSE_REQ:
				GrClose();
				return 0;
		}
	}
}
Esempio n. 28
0
/* menu initialization, make sure to do a menu_destroy when you are finished */
menu_st *menu_init(GR_WINDOW_ID menu_wid, char *title, int x, int y, int w,
		int h, menu_st *parent, item_st *items, int op)
{
	menu_st *menulist;
	int i;

	menulist = (menu_st *)malloc(sizeof(menu_st));
	if (!menulist) {
		return NULL;
	}

	/* starting with an empty slate */
	if(items == NULL) {
		menulist->items = (item_st *)malloc(20 * sizeof(item_st));
		menulist->num_items = 0;
		menulist->alloc_items = 20;
	}
	/* starting with a static menu */
	else {
		menulist->items = items;
		for(i = 0; items[i].text != 0; i++)
			items[i].orig_pos = i;
		menulist->num_items = i;
		menulist->alloc_items = 0;
	}
	
	menulist->title = title;
	menulist->op = op;
	menulist->sel = 0;
	menulist->init = 0;
	menulist->timer = 0;
	menulist->top_item = 0;
	menulist->scheme_no = -1; 
	menulist->scrollbar = 0;
	menulist->timer_step = 0;
	menulist->parent = parent;
	menulist->lastsel = -1;
	menulist->menu_gc = pz_get_gc(1); 
	GrGetGCTextSize(menulist->menu_gc, "abcdefghijhlmnopqrstuvwxyz"
			"ABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, GR_TFASCII,
			&menulist->width, &menulist->height, &menulist->base);
	/* add a 2px padding to the text */
	menulist->height += 4;

	/* determine how many items can fit on a screen */
	menulist->screen_items = (int)h/menulist->height;
	menulist->x = x;
	menulist->y = y;
	menulist->w = w;
	menulist->h = h;

	menulist->menu_wid = menu_wid; 
	menulist->font = get_current_font(); 

	create_pixmaps(menulist, menulist->screen_items);

	menulist->transition = GrNewPixmap(menulist->w*2, menulist->h, NULL);
#if 0
	Dprintf("Init::%d items per screen at %dpx\n\tbecause %d/%d == %d\n",
			menulist->screen_items, menulist->height, menulist->h,
			menulist->height, menulist->screen_items);
#endif
	return menulist;
}
Esempio n. 29
0
/* simply erases and redoes the text on the pixmap */
void menu_retext_pixmap(menu_st *menulist, int pixmap, item_st *item)
{
	int op;
	char *text;

	if(pixmap < 0 || pixmap > menulist->screen_items - 1) {
		Dprintf("menu_retext_pixmap::No Such Pixmap\n");
		return;
	}
	if(item < 0) {
		Dprintf("menu_retext_pixmap::Item non-existent\n");
		return;
	}

	text = (TRANSLATE & menulist->op) ? gettext(item->text) : item->text;

	/* set the bit for a checked long item */
	if(!(LONG_ITEM & item->op)) {
		GR_SIZE width, height, base;
		GrGetGCTextSize(menulist->menu_gc, text, -1, GR_TFASCII,
				&width, &height, &base);
		item->text_width = width;

		item->op |= LONG_ITEM; 
	}

	menu_clear_pixmap(menulist, pixmap);

	if (UTF8 & menulist->op)
		op = GR_TFUTF8;
	else if (UC16 & menulist->op)
		op = GR_TFUC16;
	else if (ASCII & menulist->op)
		op = GR_TFASCII;
	/* this makes the text draw without outlines */
	GrSetGCUseBackground(menulist->menu_gc, GR_FALSE);
	GrText(menulist->pixmaps[menulist->pixmap_pos[pixmap]],
			menulist->menu_gc, 8, 1, text, strlen(text),
			op | GR_TFTOP);

	
	if(BOOLEAN_MENU & item->op) {
		GR_SIZE width, height, base;
		char option[4];
		/* get setting info */
		if(item->setting != 0)
			item->sel_option = ipod_get_setting(item->setting);
		/* draw boolean text */	
		strcpy(option, (item->sel_option ? _("On") : _("Off")));
		GrGetGCTextSize(menulist->menu_gc, option, -1, GR_TFASCII,
				&width,	&height, &base);
		GrText(menulist->pixmaps[menulist->pixmap_pos[pixmap]],
				menulist->menu_gc, (menulist->w - width) -
				(8 + 2), 1, option, -1, GR_TFASCII| GR_TFTOP);
	}
	else if(OPTION_MENU & item->op) {
		GR_SIZE width, height, base;
		char **option;
		/* get setting info */
		if(item->setting != 0)
			item->sel_option = ipod_get_setting(item->setting);
		/* draw option text */
		option = (char **)item->action;
		text = gettext(option[item->sel_option]);
		GrGetGCTextSize(menulist->menu_gc, text, -1, GR_TFASCII,
				&width,	&height, &base);
		GrText(menulist->pixmaps[menulist->pixmap_pos[pixmap]],
				menulist->menu_gc, (menulist->w - width) -
				(8 + 2), 1, text, -1, GR_TFASCII | GR_TFTOP);
	}
	else if((SUB_MENU_HEADER & item->op || ARROW_MENU & item->op) &&
			(item->text_width < (menulist->w - 8) - 8)) {
		GrSetGCUseBackground(menulist->menu_gc, GR_FALSE);
		GrText(menulist->pixmaps[menulist->pixmap_pos[pixmap]],
				menulist->menu_gc, (menulist->w - 8) - 7,
				2, ">", -1, GR_TFASCII | GR_TFTOP);
		GrText(menulist->pixmaps[menulist->pixmap_pos[pixmap]],
				menulist->menu_gc, (menulist->w - 8) - 6,
				2, ">", -1, GR_TFASCII | GR_TFTOP);
		GrSetGCUseBackground(menulist->menu_gc, GR_TRUE);
	}
	
	menu_draw_item(menulist, pixmap);
}
Esempio n. 30
0
void draw_string(char *array, int mode)
{
  char *txtptr = array;
  
  int xpos, ypos;

  int maxwidth = 0, maxheight = 0;

  int i = 0;
  int count = 0;

  GR_GC_ID gc = GrNewGC();
  //GR_FONT_ID font = GrCreateFont((GR_CHAR *) GR_FONT_GUI_VAR, 0, 0);
  
  //GrSetGCFont(gc, font);

  /* Count how many lines we have */
  while(txtptr)
    {
      int tw, th, tb;
      
      if (strlen(txtptr) == 0) break;
      
      GrGetGCTextSize(gc, txtptr, -1, 0,
		      &tw, &th, &tb);

      if (maxwidth < tw) maxwidth = tw;
      if (maxheight < th) maxheight = th;

      txtptr += 50;
      count++;
    }

  txtptr = array;
  maxwidth += 10;
  maxheight += 10;

  /* mode == 1, clear the screen,
     mode == 2, draw a box
  */

  if (mode == 1)
    {
      GrSetGCForeground(gc, BLACK);
      GrFillRect(offscreen, gc, 0, 0, WWIDTH, WHEIGHT);

      GrSetGCForeground(gc, WHITE);
      GrSetGCBackground(gc, BLACK);
    }
  else
    {
      xpos = (PWIDTH / 2) - (maxwidth / 2);
      ypos = (PHEIGHT / 2) - ((count * maxheight) / 2);

      /* Draw a box */
      GrSetGCForeground(gc, BLACK);

      GrFillRect(offscreen, gc, 
		 xpos, 
		 ypos,
		 maxwidth, (count * maxheight));
      
      GrSetGCForeground(gc, WHITE);

      GrRect(offscreen, gc, 
		 xpos, 
		 ypos,
		 maxwidth, (count * maxheight));

      GrSetGCBackground(gc, BLACK);
    }
  
  ypos = (WHEIGHT / 2) - ((count * maxheight) / 2) + 5;

  while(1)
    {
      int tw, th, tb;
      if (strlen(txtptr) == 0) break;

      GrGetGCTextSize(gc, txtptr, -1, 0,
		      &tw, &th, &tb);

      GrText(offscreen, gc, (WWIDTH / 2) - (tw / 2), 
	     ypos + (i  * th), txtptr, -1, 0);
      i++;
      txtptr += 50;
    }
  
  GrDestroyGC(gc);
  //GrDestroyFont(font);
}