Hello. 2012/3/7 Christopher Howard <christopher.how...@frigidcode.com>: > Hello again. So, I recently started a project to create a certain board > game (in C) using gtk+, and I just started learning gtk+. I was planning > to draw the board graphics, pieces, etc. all into one GtkDrawingArea. > So, how do I fix the size of the drawing area so it doesn't get larger > or smaller than my graphics?
I would add a wrapper GtkAlignment around my drawing area, set it's xalign and yalign propertes to 0.5, it's xscale and yscale to 0, pack GtkDrawingArea inside it and fix it's size using gtk_window_set_size_request(). Have a look at this simple app: #include <gtk/gtk.h> #define WIDTH 300 #define HEIGHT 400 static gboolean cb_draw (GtkWidget *w, GdkEventExpose *e) { cairo_t *cr = gdk_cairo_create (e->window); cairo_set_source_rgb (cr, 1.0, 1.0, 0.0); cairo_paint (cr); cairo_destroy (cr); return TRUE; } int main (int argc, char **argv) { GtkWidget *window, *align, *area; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (window, "destroy", gtk_main_quit, NULL); align = gtk_alignment_new (0.5, 0.5, 0, 0); gtk_container_add (GTK_CONTAINER (window), align); area = gtk_drawing_area_new (); gtk_widget_set_size_request (area, WIDTH, HEIGHT); g_signal_connect (area, "expose-event", G_CALLBACK (cb_draw), NULL); gtk_container_add (GTK_CONTAINER (align), area); gtk_widget_show_all (window); gtk_main (); return 0; } Cheers, Tadej -- Tadej Borovšak tadeboro.blogspot.com tadeb...@gmail.com tadej.borov...@gmail.com _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list