Re: GtkTable cells resizing



On 15/05/12 14:45, Tristan Van Berkom wrote:
On Mon, May 14, 2012 at 10:29 PM, James Steward
<jamessteward optusnet com au>  wrote:
On 15/05/12 11:56, Tristan Van Berkom wrote:
... perhaps it's worth trying an extra call to gtk_widget_queue_resize()
after modifying your table.


I'm trying that.   I have signals connected thus;

    g_signal_connect(G_OBJECT(p->canvas), "expose-event",
             G_CALLBACK(&plot_expose_event), p);

    g_signal_connect(G_OBJECT(p->canvas), "select-item",
             G_CALLBACK(&plot_select_event), p);

and get the plot_select_event() routine to calculate and set new canvas
sizes with

gtk_plot_canvas_set_size(GTK_PLOT_CANVAS(p->canvas), width, height);

then call gtk_widget_queue_resize(GTK_WIDGET(p->table));

This causes plot_expose_event() to get called, which calls
gtk_plot_canvas_paint(GTK_PLOT_CANVAS(canvas));

But the table rows seem to expand to the largest canvas and don't seem to
take on variable heights.

Feel I've been around and around the mulberry bush on this ;-)

Hard to say whats going on here, I wonder who is responding
to the size requests for these items which are getting drawn.

It seems you connect to a signal to draw on a widget, which
means the content is not the widget, so probably you need
to also connect a signal to override the size request of the
said widget you intend painting onto ?

Perhaps you are using forced size requests to accomplish
this (using gtk_widget_set_size_request() or such), and
have somehow mixed up the size requests while swapping
your content onto new rows/columns ?

Other than that, child 'expand' properties will be considered
by the GtkTable (if all children can expand, then it's quite
possible that after reaching a large window size the content
will be evenly  spread).
Thanks for your ideas. I had another. I could define the table as having twice as many rows, then (hopefully) just reassigning the attach points. I.e. where I now have;

gtk_table_attach_defaults(table1, canvas1, 0, 1, 0, 1);
gtk_table_attach_defaults(table1, canvas2, 0, 1, 1, 2);
gtk_table_attach_defaults(table1, canvas3, 0, 1, 2, 3);

instead I'll define a 6 row table and initialise as;

gtk_table_attach_defaults(table1, canvas1, 0, 1, 0, 2);
gtk_table_attach_defaults(table1, canvas2, 0, 1, 2, 4);
gtk_table_attach_defaults(table1, canvas3, 0, 1, 4, 6);

Then to zoom canvas2, I can hopefully somehow move the attachment points to;

gtk_table_attach_defaults(table1, canvas1, 0, 1, 0, 1);
gtk_table_attach_defaults(table1, canvas2, 0, 1, 1, 5);
gtk_table_attach_defaults(table1, canvas3, 0, 1, 5, 6);

I'd obviously need to fix the row size by making the table homogeneous.

What do you think?

Regards,
James.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]