GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Apr 21, 2015 8:18 am

All times are UTC

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Mysterious margin around drawing area
PostPosted: Tue Oct 23, 2012 8:37 am 
Familiar Face

Joined: Tue Oct 23, 2012 8:13 am
Posts: 5
I am a novice to GTK+ development, and I am trying to port the XBoard Chess interface from the old Xt/Xaw widget setto GTK. ButI run into a pesky problem that I don't understand at all:

Whenever I pack a gtk_drawing_area into something else (be it a table cell or a frame) there is this extra space at the bottom of it. Even when I specify the height of the gtk_drawing_area explicitly with gtk_widget_set_size_request, the frame doesn't fit tightly around it, but there is this extra empty space below it, which can then be squeezed out by sizing the window. Until the frame touches the drawing area, after which it refuses to size any smaller (as expected).


After creation of the window I used gtk_widget_get_allocation to get the sizes of the drawing_area, and it tells me that it indeed has the small size (i.e. not including the empty space). I really have no idea what makes GTK think it would be a good idea to just throw in some extra space. This problem is very annoying to me, because WinBoard uses the sizes of the top-level window and the board image to calculate the margin that is needed for the rest (clock widgets, menu bar, window decorations), so that it can calculate later (after the user resizes the window) how large it should draw the pieces ad board squares to have the board fit. It has no way to know that part of that difference is just unnecessary filler, so it always draws the board too small:


The code I use to create the drawing area (on Ubuntu 10.04) is:

          case Graph:
            option[i].handle = (void*) (graph = gtk_drawing_area_new());
//            gtk_widget_set_size_request(graph, option[i].max, option[i].value);
            g_signal_connect (graph, "expose-event", G_CALLBACK (GraphEventProc), (gpointer) &option[i]);
            g_signal_connect (graph, "button-press-event", G_CALLBACK (GraphEventProc), (gpointer) &option[i]);
            g_signal_connect (graph, "button-release-event", G_CALLBACK (GraphEventProc), (gpointer) &option[i]);
            g_signal_connect (graph, "motion-notify-event", G_CALLBACK (GraphEventProc), (gpointer) &option[i]);
            if(1) { // Surround by frame, to isolate the sizing problem and make it visually obvious
                GtkWidget *frame = gtk_frame_new(NULL);
                gtk_container_add(GTK_CONTAINER(frame), graph);
                graph = frame;
            Pack(hbox, table, graph, left, left+r, top, GTK_EXPAND);

Any help or suggestions on this would be welcome, as I am currently at a total loss.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: Google [Bot] and 4 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group