Re: how to resize window smaller



Carl Nygard writes:
 > 
 > Once I've used set_size_request to some size (x,y), I am unable to
 > resize the window to some smaller size.  Can someone tell me how to
 > accomplish this?  I've tried resize() on the Gdk::Window for both the
 > drawingarea and the main toplevel window, nothing seems to work.

I believe you can undo the size request by calling it again
with -1 for both coordinates.  Since the windows are already
visible you may have to call queue_resize() to renegotiate
widget sizes.

something on the order of

drawingarea.set_size_request(100, 100);

// now you're looking at a window that won't shrink below 100x100 ...
// but you want to resize it anyway

drawingarea.set_size_request(-1, -1);
windowholdingdrawingarea.queue_resize();

I haven't actually tried this, and I don't know how it affects
the window holding the drawing area. It would be the first thing I would
try if I had your problem.  Maybe call queue_resize() on the drawing
area instead.

I hope this is at least a pointer in the right direction instead of
off into the thicket. For what it's worth, here's what the gtk docs
have to say about Widget::queue_resize():

/*
 * This function is only for use in widget implementations.
 * Flags a widget to have its size renegotiated; should
 * be called when a widget for some reason has a new size request.
 * For example, when you change the text in a #GtkLabel, #GtkLabel
 * queues a resize to ensure there's enough space for the new text.
 **/

As an alternative to set_size_request() and undoing the call later,
consider overriding DrawingArea::on_size_request() or connecting to
its signal_size_request() and requesting 100x100 when applicable,
and other dimesions otherwise.



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