how to decrease size of scrolledwindow, anybody? ... was: programatically resizing a scrolledwindow/viewport
- From: "Karl H. Beckers" <karl h beckers gmx net>
- To: gtk-app-devel-list gnome org
- Subject: how to decrease size of scrolledwindow, anybody? ... was: programatically resizing a scrolledwindow/viewport
- Date: Wed, 06 Oct 2004 16:42:50 +0200
Hi all,
I need to make a scrolledwindow smaller but can't find a way to do it.
It always retains its original size (unless, of course, resized
interactively). The scrolledwindow contains a
viewport>vbox>number_of_widgets and resides in a frame in a table in a
dialog. I've tried out everything that seemed promising like:
before showing the dialog:
// this is the maximum size we can have. Use this to make the dialog
position for worst case
gtk_widget_set_size_request( viewport1, -1, 400);
... after showing the dialog ...
{
// FIXME: this does not work as desired
GtkRequisition size;
GtkAllocation alloc;
int set_size;
gtk_widget_size_request(vbox2, &size);
set_size = ( size.height > 400 ? 400 : size.height );
alloc.x = -1;
alloc.y = -1;
alloc.width = size.width;
alloc.height = set_size + 4;
gtk_container_set_resize_mode (GTK_CONTAINER(viewport1),
GTK_RESIZE_IMMEDIATE);
gtk_container_set_resize_mode (GTK_CONTAINER(scrolledwindow1),
GTK_RESIZE_IMMEDIATE);
gtk_container_set_resize_mode (GTK_CONTAINER(frame1),
GTK_RESIZE_IMMEDIATE);
// actually I would like to get the right correction numbers from the
widget, but
// gtk_container_get_border_width always seems to return 0 ... more
research needed.
gtk_widget_set_size_request (viewport1, -1, ( set_size + 4 ) );
gtk_widget_set_size_request (scrolledwindow1, -1, ( set_size + 4 ) );
gtk_widget_set_usize(frame1, -1, ( set_size + 8 ));
gtk_widget_set_usize(scrolledwindow1, -1, ( set_size + 8 ));
gtk_widget_set_usize(frame1, -1, ( set_size + 8 ));
gtk_widget_size_allocate ( viewport1, &alloc );
gtk_widget_size_allocate ( scrolledwindow1, &alloc );
gtk_widget_size_allocate ( frame1, &alloc );
gtk_widget_queue_resize (viewport1);
gtk_widget_queue_resize (scrolledwindow1);
gtk_widget_queue_resize (frame1);
}
TIA,
Karl.
Hi all,
in a dialog window I'm trying to have a number of widgets (each
represents an error) in a vbox which is contained in a scrolledwindow
and a viewport. When I request a minimum width for the error widgets
the viewport nicely calculates its width to the error widget's width
and thus displays it without need to scroll.
This does not happen quite as nicely for height, though.
I always get a default height of smth. like 60 or so which isn't even
enough for one error widget (at a width of a couple of hundreds).
Now, my desired behaviour would be: If the size of all combined error
widgets is less than some sensible number (e.g. 400) make the viewport
exactly as large. If it exceeds this value set it to the maximum and scroll.
I don't get real values for the vbox's height until I show the dialog.
This is inconvenient because if I resize the viewport from 60 to 400
after the window has been positioned, it's probably going to grow out
of the lower end of the screen.
A workaround might be to first set the viewport's size to the maximum
value, thus causing the dialog to be positioned alright for a worst
case and making the viewport smaller after showing the window.
However, nothing I try seems to be able to make the
scrolledwindow/viewport smaller again.
Any hints?
Or do I have to go with a static viewport size?
TIA,
Karl.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]