About layouts



First of all, thanks for your suggestions.

Actually my app. uses a static layout and the GtkLabels inside this, don't
grown when the text becomes longer. The same GtkLabel behaves ok if it is
inside a GtkTable. So I think I will change the static container.

My app uses a menu bar and a GtkNotebook. In every tab, I have several
GtkLabels and ProgressBars. So if I choose to use non-static containers I
think I'll need two or three GtkTables for each tab.I have three tabs now
but it is expected to have at least five.

If I change the static layout + label for a deeper containers hierarchy
(three levels for example)... will I have a lack of performance when loading
the UI?

Thanks in advance!!!



---------- Forwarded message ----------
From: Gus Koppel <gtk spamkiller bytechase cx>
Date: 14-feb-2006 14:30
Subject: Re: About layouts
To: gtk-app-devel-list gnome org

Fernando Apesteguía wrote:

I'm developing an app with gtk. I use glade for GUI development. My
question
is about the different kinds of layouts. I would like my app resizes by
itself when a label text is really long. I've noticed I can do this by
placing a table layout (I think vbox and hbox work well too).
In fact, this behaves well even when changing fonts dpi (This is the
answer
to my question  that you can see at

http://mail.gnome.org/archives/gtk-app-devel-list/2006-January/msg00064.html
)

But my app has a lot of labels and buttons so I estimated I need a lot of
layouts creating a complex hierarchy (vbox inside a table layout, inside a
hbox, inside a table layout again...)

Did I forget a simply way to make this??

Your question is not quite clear to me. It seems to be about two issues:
1. auto-resizing of labels, 2, what containers to use for your layout.

Regarding GtkLabels: automatic resizing is their default behaviour,
regardless of which sort of container (Gtktable, GtkVBox, etc.) it is
being put into.

Example: when working with Glade, just create an empty dialog window.
Drop a new GtkLabel into it (directly into the window, without
additional layout containers). Make the window as small as possible (not
via the "minimizie" button). You will see that you can't make the window
smaller than the dimensions needed by the GtkLabel to have its text
(should be "label1" or similar) fully visible. In Glade's "properties"
window, when you type in additional text into the "Label" property of
the GtkLabel, you can see the window grow as you type. Again, this is
the default behaviour of GtkLabel (and most other types of widgets as
well) and is not bound to particular containers like GtkTables or Boxes.

However, if your texts may get "really long", this behaviour shouldn't
actually be what you want. Especially if the label has disabled its
wrapping property, restricting the label text to just one line, the
horizontal size requirement by the label may easily exceed the screen's
dimensions, making the window wider than the screen as well. This would
make your application basically useless.

There are three common strategies to consider if you're planning to deal
with display of really long texts. They aim at avoiding unrestricted
size requests by the GtkLabel:
1. enable the "wrap text" property of the GtkLabel
2. put the GtkLabel into a GtkScrolledWindow
3. use GtkTextView instead of GtkLabel, with "editable" property unset.

Regarding the other aspect of your question: what layout containers to
use and the extent of complexity is determined solely by what layout you
actually want to achieve. For instance, having 20 rows with each one
consisting of a GtkButton and a GtkLabel next to it, and all widgets
aligned vertically, is quite a simple layout. You would only need one
GtkTable with 2 columns and 20 rows for it. You could also easily use 10
rows with 4 columns (button, label, button, label) each with the same
single table.

More complex layouts require additional layout containers, of course.
You didn't provide any idea what sort of complex layout hierarchy you
want to achieve so I can't give more detailed recommendations.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



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