Re: enlarge the scrollable area



Il 15/02/2011 18:55, Tristan Van Berkom ha scritto:
On Wed, Feb 16, 2011 at 1:49 AM, Stefano Facchini
<stefano facchini gmail com>  wrote:
Hi,

I'm trying to build a scrolled window in a such a way that the child widget
has always the same size, regardless of the size of the scrolled window
itself. I tried gtk_scrolled_window_set_min_content_width, but this also
sets the minimum size of the scrolled window. Basically, I need something to
force the size of the child widget (for example a TextView), or to enlarge
the scrollable area without enlarging the scrolled window. Is it possible to
have this behavior?
Sounds like you should be able to get away with just
gtk_widget_set_size_request()
on the child textview, that should ensure the child text view always
receives at least
the size you set for it's minimum request without restricting the size
of the parent
scrolled window.

Note: In GTK+ 2.x setting the size request of the child widget was acting like
gtk_scrolled_window_set_min_content_width/height() as a sort of implied hidden
feature, in GTK+ 3.x you can choose to force the size of the scrolled window
by using the new api or just force the size of the child by using
gtk_widget_set_size_request().

Cheers,
           -Tristan

Thanks for your answer, but I can't obtain what I need. Is the following code what you meant?

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  textview = gtk_text_view_new ();

  gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);

  gtk_container_add (GTK_CONTAINER (window), scrolled_window);
  gtk_container_add (GTK_CONTAINER (scrolled_window), textview);

  gtk_widget_set_size_request (textview, 600, -1);

I had the the following results:
gtk2: the window has a minimum width of 600 pixel
gtk3: the window is 400x300, and so is the textview!

I just want a 400x300 window with a 600x300 textview (or any other widget, this is just an example) inside the scrollable.

cheers
Stefano




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