/* draws the scrollbar; calculates it and all */ void menu_draw_scrollbar(menu_st *menulist) { int per = menulist->screen_items * 100 / menulist->num_items; int height = (menulist->h - 2) * (per < 3 ? 3 : per) / 100; int y_top = ((((menulist->h - 3) - height) * 100) * menulist->sel / (menulist->num_items - 1)) / 100 + menulist->y + 1; int y_bottom = y_top + height; /* only draw if appropriate */ if(menulist->screen_items >= menulist->num_items) return; /* draw the containing box */ GrSetGCForeground(menulist->menu_gc, appearance_get_color( CS_SCRLBDR )); GrRect(menulist->menu_wid, menulist->menu_gc, menulist->w - 8, menulist->y, 8, menulist->h - 1); /* erase the scrollbar */ GrSetGCForeground(menulist->menu_gc, appearance_get_color( CS_SCRLCTNR )); GrFillRect(menulist->menu_wid, menulist->menu_gc, menulist->w - (8 - 1), menulist->y + 1, (8 - 2), y_top - (menulist->y + 1)); GrFillRect(menulist->menu_wid, menulist->menu_gc, menulist->w - (8 - 1), y_bottom, (8 - 2), (menulist->h - 3) - y_bottom); /* draw the bar */ GrSetGCForeground(menulist->menu_gc, appearance_get_color( CS_SCRLKNOB )); GrFillRect(menulist->menu_wid, menulist->menu_gc, menulist->w - (8 - 1), y_top, (8 - 2), height); /* restore the fg */ GrSetGCForeground(menulist->menu_gc, BLACK); }
static void kmbitmap(void){ GrSetGCUseBackground(keyman_gc, GR_FALSE); GrSetGCForeground(keyman_gc, BLACK); switch(wnow.shupict){ case 0:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap1_black);break; case 1:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap2_black);break; case 2:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap3_black);break; } GrSetGCForeground(keyman_gc, GRAY); switch(wnow.shupict){ case 0:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap1_gray);break; case 1:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap2_gray);break; case 2:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap3_gray);break; } GrSetGCForeground(keyman_gc, LTGRAY); switch(wnow.shupict){ case 0:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap1_ltgray);break; case 1:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap2_ltgray);break; case 2:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap3_ltgray);break; } GrSetGCForeground(keyman_gc, WHITE); switch(wnow.shupict){ case 0:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap1_white);break; case 1:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap2_white);break; case 2:GrBitmap(mainmenu_pixmap, keyman_gc, wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)), 16, 16, keymap3_white);break; } }
/* Draw the rook */ void draw_rook(int coord_x, int coord_y, int color) { GR_POINT rook[] = { {coord_x+1, coord_y+1}, {coord_x+3, coord_y+1}, {coord_x+3, coord_y+3}, {coord_x+5, coord_y+3}, {coord_x+5, coord_y+1}, {coord_x+7, coord_y+1}, {coord_x+7, coord_y+3}, {coord_x+9, coord_y+3}, {coord_x+9, coord_y+1}, {coord_x+11, coord_y+1}, {coord_x+11, coord_y+4}, {coord_x+9, coord_y+4}, {coord_x+9, coord_y+8}, {coord_x+11, coord_y+8}, {coord_x+11, coord_y+11}, {coord_x+1, coord_y+11}, {coord_x+1, coord_y+8}, {coord_x+3, coord_y+8}, {coord_x+3, coord_y+4}, {coord_x+1, coord_y+4}, {coord_x+1, coord_y+1} }; if(color == 0) { GrSetGCForeground(tuxchess_gc,WHITE); GrFillPoly(tuxchess_wid,tuxchess_gc,21,rook); GrSetGCForeground(tuxchess_gc,BLACK); GrPoly(tuxchess_wid,tuxchess_gc,21,rook); } else { GrSetGCForeground(tuxchess_gc,BLACK); GrFillPoly(tuxchess_wid,tuxchess_gc,21,rook); } }
void periodic_draw_element(GR_WINDOW_ID wid, GR_GC_ID gc, int i, int bx, int by, int cellsize) { int ex = (bx+((periodic_elements[i].group-1)*cellsize)); int ey = (by+((periodic_elements[i].period-1)*cellsize)); int tx, ty; char tt[4]; if (i == periodic_sel) { GrSetGCForeground(gc, GR_RGB(0,0,0)); GrFillRect(wid, gc, ex, ey, cellsize+1, cellsize+1); GrSetGCForeground(gc, GR_RGB(255,255,255)); } else { if (screen_info.bpp < 8) { GrSetGCForeground(gc, periodic_color_palette_bw[periodic_elements[i].color]); } else { GrSetGCForeground(gc, periodic_color_palette[periodic_elements[i].color]); } GrFillRect(wid, gc, ex, ey, cellsize+1, cellsize+1); GrSetGCForeground(gc, GR_RGB(0,0,0)); GrRect(wid, gc, ex, ey, cellsize+1, cellsize+1); } if (cellsize >= 8) { strcpy(tt, periodic_elements[i].symbol); if (strlen(tt) > 2) { tt[1] = tt[strlen(tt)-1]; tt[2] = 0; tx = ex + cellsize/2 - 4; } else if (tt[1] != 0) { tx = ex + cellsize/2 - 4; } else { tx = ex + cellsize/2 - 2; } ty = ey + cellsize/2 - 4; periodic_tinyfont_draw_string(wid, gc, tx, ty, tt); } }
/* Draw the rook */ void draw_rook(int coord_x, int coord_y, char color) { GR_POINT rook[] = { {coord_x+1, coord_y+1}, {coord_x+3, coord_y+1}, {coord_x+3, coord_y+3}, {coord_x+5, coord_y+3}, {coord_x+5, coord_y+1}, {coord_x+7, coord_y+1}, {coord_x+7, coord_y+3}, {coord_x+9, coord_y+3}, {coord_x+9, coord_y+1}, {coord_x+11, coord_y+1}, {coord_x+11, coord_y+4}, {coord_x+9, coord_y+4}, {coord_x+9, coord_y+8}, {coord_x+11, coord_y+8}, {coord_x+11, coord_y+11}, {coord_x+1, coord_y+11}, {coord_x+1, coord_y+8}, {coord_x+3, coord_y+8}, {coord_x+3, coord_y+4}, {coord_x+1, coord_y+4}, {coord_x+1, coord_y+1} }; if(color == 'w') { GrSetGCForeground(tuxchess_gc,GR_RGB(255,255,255)); GrFillPoly(tuxchess_wid,tuxchess_gc,21,rook); GrSetGCForeground(tuxchess_gc,GR_RGB(0,0,0)); GrPoly(tuxchess_wid,tuxchess_gc,21,rook); } else { GrSetGCForeground(tuxchess_gc,GR_RGB(0,0,0)); GrFillPoly(tuxchess_wid,tuxchess_gc,21,rook); } }
// create the circular status animation static void create_status() { int i; int xpie[] = { 0, 3, 6, 3, 0, -3, -6, -3 }; int ypie[] = { -6, -3, 0, 3, 6, 3, 0, -3 }; // we need 16 frames GrSetGCForeground (mandel_gc, appearance_get_color( CS_TITLEBG )); for (i=0;i<16;i++) { status_image[i] = GrNewPixmap(12, 12, NULL); GrFillRect(status_image[i],mandel_gc,0,0,12,12); } // the background for (i=1;i<8;i++) { GrSetGCForeground(mandel_gc, appearance_get_color(CS_TITLEFG)); GrFillEllipse(status_image[i],mandel_gc,6,6,6,6); GrSetGCForeground(mandel_gc, appearance_get_color(CS_TITLEBG)); GrArc(status_image[i],mandel_gc,6,6,6,6,0,-6,xpie[i],ypie[i],MWPIE); } // the foreground part GrSetGCForeground(mandel_gc, appearance_get_color(CS_TITLEFG)); GrFillEllipse(status_image[8],mandel_gc,6,6,6,6); for (i=9;i<16;i++) GrArc(status_image[i],mandel_gc,6,6,6,6,0,-6,xpie[i-8],ypie[i-8],MWPIE); }
void saver4_animate(nstate *state) { int i, tail, newtip; s4state *s = state->priv; if(s->length == SAVER4_WORMLENGTH) tail = s->tip + 1; else tail = 0; if(tail == SAVER4_WORMLENGTH) tail = 0; newtip = s->tip + 1; if(newtip == SAVER4_WORMLENGTH) newtip = 0; for(i = 0; i < SAVER4_NUMWORMS; i++) { GrSetGCForeground(state->main_gc, GR_COLOR_BLACK); GrFillRect(state->main_window, state->main_gc, s->worms[i].points[tail].x, s->worms[i].points[tail].y, SAVER4_WORMTHICKNESS, SAVER4_WORMTHICKNESS); saver4_get_new_worm_position(state, i, newtip); GrSetGCForeground(state->main_gc, s->worms[i].colour); GrFillRect(state->main_window, state->main_gc, s->worms[i].points[newtip].x, s->worms[i].points[newtip].y, SAVER4_WORMTHICKNESS, SAVER4_WORMTHICKNESS); } s->tip = newtip; if(s->length < SAVER4_WORMLENGTH) s->length++; }
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); }
static void draw_bar(int bar_length) { if (!(bar_length < 0 || bar_length > rect_x2-rect_x1-4) ) { GrFillRect (mp3_wid, mp3_gc, rect_x1 + 2, rect_y1+2, bar_length, rect_y2-rect_y1-4); GrSetGCForeground(mp3_gc, GR_RGB(255,255,255)); GrFillRect(mp3_wid, mp3_gc, rect_x1 + 2 + bar_length, rect_y1+2, rect_x2-rect_x1-4 - bar_length, rect_y2-rect_y1-4); GrSetGCForeground(mp3_gc, GR_RGB(0,0,0)); } }
static void video_draw_pause() { GrSetGCForeground(video_gc, GR_RGB(255,255,255)); GrFillRect(video_wid, video_gc, 8, 8, 16, 32); GrFillRect(video_wid, video_gc, 32, 8, 16, 32); GrSetGCForeground(video_gc, GR_RGB(0,0,0)); GrRect(video_wid, video_gc, 8, 8, 16, 32); GrRect(video_wid, video_gc, 32, 8, 16, 32); }
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; }
/* clears specified pixmap, (GrClearWindow doesnt work properly for a pixmap) */ void menu_clear_pixmap(menu_st *menulist, int pos) { if(pos < 0 || pos > menulist->screen_items - 1) { Dprintf("menu_clear_pixmap::No Such Pixmap\n"); return; } GrSetGCForeground(menulist->menu_gc, appearance_get_color( CS_BG )); GrFillRect(menulist->pixmaps[menulist->pixmap_pos[pos]], menulist->menu_gc, 0, 0, 440, menulist->height); GrSetGCForeground(menulist->menu_gc, appearance_get_color( CS_FG )); }
static void draw_ball(int col,int row,int ibmp,int icolor) { if(ipodc == 0 ){ GrBitmap(ipobble_wid, ipobble_gc, col, row, BALL_WIDTH - 1, BALL_WIDTH - 1, balls_bmp[ibmp]); } else { if (icolor!=-1)GrSetGCForeground(ipobble_gc, BallColors[icolor]); GrBitmap(ipobble_wid, ipobble_gc, col, row, BALL_WIDTH - 1, BALL_WIDTH - 1, balls_bmp[ibmp]); } if(icolor!=-1)GrSetGCForeground(ipobble_gc, BLACK); }
/* Draw the king */ void draw_king(int coord_x, int coord_y, char color) { GrSetGCForeground(tuxchess_gc,GR_RGB(0,0,0)); GrLine(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+1,coord_x+6,coord_y+4); GrLine(tuxchess_wid,tuxchess_gc,coord_x+4,coord_y+2,coord_x+8,coord_y+2); if(color == 'w') GrSetGCForeground(tuxchess_gc,GR_RGB(255,255,255)); GrFillEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+8,4,4); GrSetGCForeground(tuxchess_gc,GR_RGB(0,0,0)); GrEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+8,4,4); }
/* does the drawing, safe(and recommended) to use {in, as} an exposure event */ void menu_draw(menu_st *menulist) { int i; /* appearance changed, force a redraw */ if(menulist->scheme_no != appearance_get_color_scheme() || get_current_font() != menulist->font) { menu_update_menu(menulist); } /* first draw; init onscreen text items */ if(menulist->init == 0) { for(i = (menulist->num_items > menulist->screen_items) ? menulist->screen_items : menulist->num_items; i; i--) menu_retext_pixmap(menulist, i - 1, &menulist->items[menulist->top_item + (i - 1)]); menulist->init = 1; } #if 0 else if(menulist->lastsel == menulist->sel) { Dprintf("Aborted draw because %d == %d\n", menulist->sel, menulist->lastsel); return; } Dprintf("Continuing, %d != %d\n", menulist->sel, menulist->lastsel); #endif /* draw each pixmap */ for(i = 0; i < menulist->screen_items; i++) menu_draw_item(menulist, i); /* erase the bottom unused part of the allocated screen */ GrSetGCForeground(menulist->menu_gc, appearance_get_color( CS_BG )); GrFillRect(menulist->menu_wid, menulist->menu_gc, menulist->x, menulist->height * menulist->screen_items, menulist->w, menulist->h - (menulist->height * menulist->screen_items)); GrSetGCForeground(menulist->menu_gc, BLACK); /* draw scrollbar if needed */ if(menulist->num_items > menulist->screen_items) { menulist->scrollbar = 1; menu_draw_scrollbar(menulist); } else menulist->scrollbar = 0; /* deal with the timer */ menu_handle_timer(menulist, 0); menulist->lastsel = menulist->sel; }
/* Draw the king */ void draw_king(int coord_x, int coord_y, int color) { GrSetGCForeground(tuxchess_gc,BLACK); GrLine(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+1,coord_x+6,coord_y+4); GrLine(tuxchess_wid,tuxchess_gc,coord_x+4,coord_y+2,coord_x+8,coord_y+2); if(color == 0) GrSetGCForeground(tuxchess_gc,WHITE); GrFillEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+8,4,4); GrSetGCForeground(tuxchess_gc,BLACK); GrEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+8,4,4); }
static void video_draw_searchbar() { int height = .1 * video_screenHeight; int offX; offX = (int)((double)((double)video_curPosition/mainHeader.dwTotalFrames) * (video_screenWidth-30)) + 16; GrSetGCForeground(video_gc, GR_RGB(255,255,255)); GrFillRect(video_wid, video_gc, 16, video_screenHeight-2 * height, video_screenWidth-30+6, height); GrSetGCForeground(video_gc, GR_RGB(0,0,0)); GrRect(video_wid, video_gc, 16, video_screenHeight-2 * height, video_screenWidth-30+6, height); GrFillRect(video_wid, video_gc, offX, video_screenHeight-2*height, 5, height); }
/* flash selected item. ala apple fw */ void menu_flash_selected(menu_st * menulist) { int item; item = menulist->sel - menulist->top_item; GrSetGCForeground(menulist->menu_gc, WHITE); GrFillRect(menulist->menu_wid, menulist->menu_gc, menulist->x, menulist->y + item * menulist->height, menulist->w - (menulist->scrollbar ? 8 : 0), menulist->height); GrSetGCForeground(menulist->menu_gc, BLACK); menulist->items[menulist->sel].op |= CFLASH; menu_handle_timer(menulist, 0); }
/* ***********************************************************/ static void gprintf(char s[]) { static char lasttext[128]; GrSetGCForeground(text_gc,BLACK); GrFillRect(text, text_gc, 0, 0, 394,20); GrSetGCForeground(text_gc,WHITE); GrSetGCBackground(text_gc,BLACK); if (!s) s = lasttext; GrText(text, text_gc, 5, 14, s, strlen(s),0); if (s != lasttext) strcpy(lasttext, s); }
// draw the selector rectangle static void draw_cursor() { show_cursor=1; cursor_x = level[current_depth].cursor_pos%selection_size; cursor_y = level[current_depth].cursor_pos/selection_size; // update the screen with last picture GrCopyArea(mandel_wid, mandel_gc, 0, 0, screen_width, screen_height, level[current_depth].mandel_buffer, 0, 0, MWROP_SRCCOPY); GrSetGCForeground(mandel_gc, GR_RGB(BLACK)); GrRect(mandel_wid, mandel_gc, cursor_x*selection_width-1, cursor_y*selection_height-1, selection_width+2, selection_height+2); GrSetGCForeground(mandel_gc, GR_RGB(WHITE)); GrRect(mandel_wid, mandel_gc, cursor_x*selection_width-2, cursor_y*selection_height-2, selection_width+4, selection_height+4); }
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); }
/* Draw the pawn */ void draw_pawn(int coord_x, int coord_y, char color) { if(color == 'w') { GrSetGCForeground(tuxchess_gc,GR_RGB(255,255,255)); GrFillEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+6,2,4); GrSetGCForeground(tuxchess_gc,GR_RGB(0,0,0)); GrEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+6,2,4); GrSetGCForeground(tuxchess_gc,GR_RGB(255,255,255)); GrFillRect(tuxchess_wid,tuxchess_gc,coord_x+3,coord_y+9,7,3); GrSetGCForeground(tuxchess_gc,GR_RGB(0,0,0)); GrRect(tuxchess_wid,tuxchess_gc,coord_x+3,coord_y+9,7,3); } else { GrSetGCForeground(tuxchess_gc,GR_RGB(0,0,0)); GrFillEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+6,2,4); GrSetGCForeground(tuxchess_gc,GR_RGB(160,160,160)); GrEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+6,2,4); GrSetGCForeground(tuxchess_gc,GR_RGB(0,0,0)); GrFillRect(tuxchess_wid,tuxchess_gc,coord_x+3,coord_y+9,7,3); GrSetGCForeground(tuxchess_gc,GR_RGB(160,160,160)); GrRect(tuxchess_wid,tuxchess_gc,coord_x+3,coord_y+9,7,3); } }
/* Draw the cursor */ void draw_cursor(char coord1, char coord2) { int x,y; x = (coord1-65)*13; y = 106-((coord2-48)*13); GrSetGCForeground(tuxchess_gc,GR_RGB(255,255,255)); GrRect(tuxchess_wid,tuxchess_gc,x,y,13,13); GrSetGCForeground(tuxchess_gc,GR_RGB(0,0,0)); GrRect(tuxchess_wid,tuxchess_gc,x+1,y+1,11,11); GrSetGCForeground(tuxchess_gc,GR_RGB(255,255,255)); GrRect(tuxchess_wid,tuxchess_gc,x+2,y+2,9,9); }
/* Draw the cursor */ void tuxchess_draw_cursor(int coord_x, int coord_y) { GR_COLOR colour; colour = (is_photo==0) ? WHITE : LIGHT_BLUE; GrSetGCForeground(tuxchess_gc,colour); GrRect(tuxchess_wid,tuxchess_gc,coord_x,coord_y,13,13); colour = (is_photo==0) ? BLACK : DARK_BLUE; GrSetGCForeground(tuxchess_gc,colour); GrRect(tuxchess_wid,tuxchess_gc,coord_x+1,coord_y+1,11,11); colour = (is_photo==0) ? WHITE : LIGHT_BLUE; GrSetGCForeground(tuxchess_gc,colour); GrRect(tuxchess_wid,tuxchess_gc,coord_x+2,coord_y+2,9,9); }
/* Draw the pawn */ void draw_pawn(int coord_x, int coord_y, int color) { if(color == 0) { GrSetGCForeground(tuxchess_gc,WHITE); GrFillEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+6,2,4); GrSetGCForeground(tuxchess_gc,BLACK); GrEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+6,2,4); GrSetGCForeground(tuxchess_gc,WHITE); GrFillRect(tuxchess_wid,tuxchess_gc,coord_x+3,coord_y+9,7,3); GrSetGCForeground(tuxchess_gc,BLACK); GrRect(tuxchess_wid,tuxchess_gc,coord_x+3,coord_y+9,7,3); } else { GrSetGCForeground(tuxchess_gc,BLACK); GrFillEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+6,2,4); GrSetGCForeground(tuxchess_gc,LTGRAY); GrEllipse(tuxchess_wid,tuxchess_gc,coord_x+6,coord_y+6,2,4); GrSetGCForeground(tuxchess_gc,BLACK); GrFillRect(tuxchess_wid,tuxchess_gc,coord_x+3,coord_y+9,7,3); GrSetGCForeground(tuxchess_gc,LTGRAY); GrRect(tuxchess_wid,tuxchess_gc,coord_x+3,coord_y+9,7,3); } }
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); } } }
static void draw_itunes_parse(int cnt) { char str[10]; sprintf(str, "%i", cnt); GrSetGCUseBackground(currentml->gc, GR_FALSE); GrSetGCMode(currentml->gc, GR_MODE_SET); GrSetGCForeground(currentml->gc, WHITE); GrFillRect(currentml->wid, currentml->gc, 0, 3 * currentml->gr_height, currentml->screen_info.cols, currentml->gr_height); GrSetGCForeground(currentml->gc, BLACK); GrText(currentml->wid, currentml->gc, 8, 3 * currentml->gr_height - 3, str, -1, GR_TFASCII); }
//displays the type of wave being played or PAUSED void generator_draw_text(char *text ) { int width; width = strlen(text)*7; //erase the previous GrSetGCForeground( generator_gc, WHITE ); GrFillRect( generator_wid, generator_gc, 0, 40, screen_info.cols, 30 ); //draw GrSetGCForeground( generator_gc, BLACK ); GrText( generator_wid, generator_gc, (screen_info.cols-width)/2, 60, text, -1, GR_TFASCII ); }
static void invaders_DrawScene() { aliens_slow--; if(aliens_slow <= 0) { GrSetGCForeground(invaders_gc, GR_RGB(255,255,255)); aliens_draw(itest); itest = (itest != 0) ? 0 : 1; aliens_update_position(); GrSetGCForeground(invaders_gc, GR_RGB(0,0,0)); aliens_draw(itest); aliens_slow = aliens_left / 4 - level + 4; } /* evaluate if fire or not */ if((rand() % 10) == 0 && alien_firing < ALIEN_MAX_FIRES) { /* find cols active and set relative row tostart */ int cols[ALIENS_COLS]; int i, j, ncol, hitcol; alien_firing++; ncol = 0; for(i = 0; i < ALIENS_COLS; i++){ for(j = aliens_rows - 1; j >= 0; j--){ if(alien_status[i * aliens_rows + j] > 0) { cols[ncol++] = j; break; } } } hitcol=rand() % ncol; Dprintf("%d\n", hitcol); alienfire[alien_firing - 1].posx = cell_minx + hitcol * ALIEN_CELL_WIDTH + ALIEN_CELL_WIDTH / 2; alienfire[alien_firing - 1].posy = cell_miny + cols[hitcol] * ALIEN_CELL_HEIGHT + ALIEN_CELL_HEIGHT; alienfire[alien_firing-1].dir = 1; } GrSetGCForeground(invaders_gc, GR_RGB(255,255,255)); me_draw(); fire_draw(); fire_update(); GrSetGCForeground(invaders_gc, GR_RGB(0,0,0)); me_draw(); fire_draw(); }
// Draws number sent over; clears the entire screen before drawing // Status: Done void generator_draw_number( int num ) { int i; //used for looping int width = (num > 999) ? 66 : (num > 99) ? 49 : (num > 9) ? 32 : 15; // width of drawn numbers int offset = (screen_info.cols - width) / 2; // x pos of numbers int top = 10; // y pos of numbers char str[sizeof(int)+1]; GrSetGCForeground( generator_gc, WHITE ); GrFillRect( generator_wid, generator_gc, 0, top, screen_info.cols, 25 ); sprintf( str, "%d", num ); for( i=0; i<4; i++ ) { switch( str[i] ) { case '0': generator_zero( offset, top ); break; case '1': generator_one( offset, top ); break; case '2': generator_two( offset, top ); break; case '3': generator_three( offset, top ); break; case '4': generator_four( offset, top ); break; case '5': generator_five( offset, top ); break; case '6': generator_six( offset, top ); break; case '7': generator_seven( offset, top ); break; case '8': generator_eight( offset, top ); break; case '9': generator_nine( offset, top ); break; case '-': generator_dash( offset, top ); break; } offset += 17; //increment the offset of one letter width + space } }