#include #include #include "draw.h" GdkGC *gc = NULL; GdkColormap *colormap = NULL; GdkPixmap *main_pxm, *brick_pxm, *wall_pxm, *space_pxm; // Redraws the entire window. void Draw(GtkWidget *area) { gdk_draw_pixmap(area->window, gc, main_pxm, 0, 0, 0, 0, T_WIDTH*C_WIDTH, T_HEIGHT*C_HEIGHT); } // Initializes the data in the pixmaps void Init_pixmaps(GtkWidget *widget) { GdkColor wall_cl, brick_cl; main_pxm = gdk_pixmap_new(widget->window, T_WIDTH*C_WIDTH, T_HEIGHT*C_HEIGHT, -1); brick_pxm = gdk_pixmap_new(widget->window, C_WIDTH, C_HEIGHT, -1); wall_pxm = gdk_pixmap_new(widget->window, C_WIDTH, C_HEIGHT, -1); space_pxm = gdk_pixmap_new(widget->window, C_WIDTH, C_HEIGHT, -1); wall_cl.red = (gushort) 0x8FFF; wall_cl.green = (gushort) 0x0FFF; wall_cl.blue = (gushort) 0x0FFF; Draw_rect_border(wall_pxm, wall_cl, C_WIDTH, C_HEIGHT); brick_cl.red = (gushort) 0xFFFF; brick_cl.green = (gushort) brick_cl.red/2; brick_cl.blue = (gushort) 0; Draw_rect_border(brick_pxm, brick_cl, C_WIDTH, C_HEIGHT); Draw_space(space_pxm, C_WIDTH, C_HEIGHT); } // Initialize the graphical context based on the drawing area. void Init_gc(GtkWidget *area) { colormap = gdk_colormap_get_system(); gc = gdk_gc_new(area->window); } // A test function for the various pixmaps. void Test_pixmaps(GtkWidget *area) { //cout << 1 << endl; gdk_draw_pixmap(area->window, gc, space_pxm, 0, 0, 10, 10, C_WIDTH, C_HEIGHT); //cout << 2 << endl; gdk_draw_pixmap(area->window, gc, brick_pxm, 0, 0, 25, 10, C_WIDTH, C_HEIGHT); //cout << 3 << endl; gdk_draw_pixmap(area->window, gc, wall_pxm, 0, 0, 45, 10, C_WIDTH, C_HEIGHT); //cout << 4 << endl; } // Draws the table on the main pixmap. void Draw_table(Table_type table, int width, int height) { for (int x=0; x