Re: Using a TextView as a sort of "Hbox with wrapping"



On Tue, 2014-01-28 at 01:56 +1100, Chris Angelico wrote:
On Tue, Jan 28, 2014 at 1:30 AM, Tristan Van Berkom
<tristan upstairslabs com> wrote:
You can get the behavior you are looking for with EggWrapBox:
  https://git.gnome.org/browse/libegg/tree/libegg/wrapbox

Just copy the eggwrapbox.[ch] and compile it as a part of your
code (or compile a libegg separately and link to it if LGPL is
a problem for you).

That looks fairly decent! Unfortunately I can't compile in extra C
code (I'm doing this in a high level language, Pike, and I want this
to work on an unmodified install of Pike - I do build my own Pike on
Linux, but my clients generally use a pre-built), so I can't use this
directly. And... that is a LOT of code (2641 lines), though a lot of
it looks like stuff that would be way shorter in a high level
language. I don't know that I want to port it to Pike, even if it's
possible to do that.

But it does look good, and it answers the big question ("I can't be
the first person to want this, so what did other people do?").

... also the EggWrapBox
handles height-for-width geometry well for it's children,
while textview itself does some height-for-width, I'm not
sure it is done well for embedded child widgets

What do you mean by "height-for-width" here? I just tried on GTK
2.24.10 on Windows and it failed to wrap the way I expected, so I'm
not sure what's going on (the same version of GTK on Linux worked
fine). Is that the sort of issue you mean?

Sorry I did not take into account that you were working with the
GTK+2 library and not GTK+3.

height for width is a geometry management system which says to
the widget:
  o What is your minimum width and what is your natural width ?
  o Oh... so you can fit into 40 pixels but you would prefer 80 !
  o Ok I've decided that, taking into account all horizontal space, you
    will receive 60 pixels in width, how much height do you need for
    a width of 60 pixels ?
  o Ah, you want 20 height ? we're done here, you will receive 60 
    pixels in width and 20 pixels in height.

This geometry management is more complex than just:
    "what is your width & height"
but allows dynamic content such as wrapping labels to unwrap
and fit the window allocation, leaving more vertical space
for other widgets above or below a wrapping label which might
desire that space.

GtkTextView had it's own way of doing height-for-width internally,
insomuch that it would eventually ask for enough height to fit the
wrapping text into whatever width you had given it.

GTK+3 has this geometry management built-in, but GTK+2 does not
(so doing things like EggWrapBox with GTK+2 is more tricky).

If you are stuck with GTK+2, I suggest you take a look into
GtkToolPalette, you might be able to trick your statusbar
items into being GtkToolItems and use the wrapping behaviour
of GtkToolPalette to achieve the same effect (or at least use
some prior art in there, I think you are stuck with the
expanders if you use GtkToolPalette directly... GtkToolItemGroup
would have the precise code you are looking for).

Cheers,
    -Tristan


ChrisA
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




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