/* Compile with gcc -g -Wall `gtk-config --cflags --libs` -o tile tile.c */ #include #include static gboolean expose (GtkWidget *widget, GdkEventExpose *event) { GtkStyle *style = widget->style; Pixmap pm; GC fillgc; Window window = GDK_WINDOW_XWINDOW (widget->window); Display *xdisplay = GDK_WINDOW_XDISPLAY (widget->window); XGCValues values; GC whitegc = GDK_GC_XGC (style->white_gc); GC blackgc = GDK_GC_XGC (style->black_gc); GC lightgc = GDK_GC_XGC (style->bg_gc[GTK_STATE_PRELIGHT]); int width = widget->allocation.width; int height = widget->allocation.height; pm = XCreatePixmap (xdisplay, window, 4, 4, DefaultDepth (xdisplay, DefaultScreen (xdisplay))); XFillRectangle (xdisplay, pm, whitegc, 0, 0, 4, 4); XDrawPoint (xdisplay, pm, blackgc, 0, 0); XDrawPoint (xdisplay, pm, lightgc, 1, 1); XDrawPoint (xdisplay, pm, blackgc, 2, 2); XDrawPoint (xdisplay, pm, lightgc, 3, 3); values.fill_style = FillTiled; values.tile = pm; fillgc = XCreateGC (xdisplay, window, GCFillStyle | GCTile, &values); XFillRectangle (xdisplay, window, fillgc, 0, 0, width, height); XFreeGC (xdisplay, fillgc); XFreePixmap (xdisplay, pm); return FALSE; } int main (int argc, char **argv) { GtkWidget *window; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_app_paintable (window, TRUE); gtk_signal_connect (GTK_OBJECT (window), "expose_event", GTK_SIGNAL_FUNC (expose), NULL); gtk_widget_show_all (window); gtk_main (); return 0; }