Resizing widgets and GtkScrolledWindow
- From: nicholas allen <nicholas allen ireland sun com>
- To: gtk-app-devel-list gnome org
- Subject: Resizing widgets and GtkScrolledWindow
- Date: Fri, 13 Jul 2001 11:52:10 +0100
Hi again,
Thanks to everyone for the help they have given us so far with our
problems. We am very grateful. Sorry to bother you again but hopefully
this will be the last time!
I am trying to write peers for Java AWT components using Gtk widgets. I
have managed to fix some problems I had with using gtk_widget_set_usize
and gtk_widget_set_uposition for setting the bounds of a widget. These
were the wrong functions to be using and now I have written a custom
widget container which I use as the peer for a Java panel. The custom
widget does nothing with the layout of its children so that this can be
left to the Java layout managers. I have basically used the approach in
the GtkFixed widget class as a starting point and stripped out things
that were unecessary. Everything is working great now and widgets are
also added in the correct Z order which was previously not possible
using GtkFixed widget. What happens now is that Java's layout managers
layout the components and this in turn causes the appropriate size and
location to be set on its native Gtk widget. This is now done by using
gtk_widget_size_allocate instead of gtk_widget_set_usize and
gtk_widget_set_uposition. This seems to work very well with only one
problem: any widget inside a GtkScrolledWindow does not show scrollbars.
For the text area and list compoinents in java I create GtkText and
GtkCList widgets respectively and put these inside a GtkScrolledWindow.
When the widget is resized and scrollbars should appear they aren't
displayed. This is now the only problem I have left for full AWT
implementation for Java so it would be cool to fix this.
As an example of how I'm creating these here is how the text area is
created:
scrollWindow = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(scrollWindow),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_widget_show (scrollWindow);
textArea = gtk_text_new(NULL, NULL);
/* TODO: We have to use line wrap as GTk does not support horizontal
scrolling in GtkText widgets yet.
This will need to be changed when this feature is supported. */
gtk_text_set_line_wrap (GTK_TEXT(textArea), TRUE);
gtk_text_set_word_wrap (GTK_TEXT(textArea), FALSE);
gtk_widget_show (textArea);
gtk_container_add (GTK_CONTAINER(scrollWindow), textArea);
eventBox = gtk_event_box_new ();
gtk_widget_show(eventBox);
gtk_container_add (GTK_CONTAINER(eventBox), scrollWindow);
Note that I place the scrolled window inside an event box to ensure that
I get GdkEvents generated for the widget so that I can easily intercept
these events and post them to Java's event queue. I don't think this has
anything to do with the problem. It is obviously something to do with my
new custom widget that does no layout of components and the change to
gtk_widget_size_allocate as mentioned above. However, not being 100%
familiar with the internals of Gtk I'm not sure with where to begin on
trying to solve this problem. Can any one give me some pointers on where
I may be going wrong or what I should be doing differently?
Thanks again for your previous help - particularly to Havoc Pennington
(BTW we now have your book on order so hopefully we'll be asking less
questions in the future!)
--
Nick Allen
Software Engineer
Sun Microsystems Ireland Ltd
Hamilton House
East Point Business Park
Dublin 3
email: nicholas allen ireland sun com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]