Re: [gtk-list] Re: Text Widget: getting number of lines?



Michael J. Hammel wrote:
> 
> In a previous message, Todd Dukes says:
...
> > Is there any way to get the number of lines text that were generated by
> > the word-wrap so I can set the size of the Gtk_Text widget?
> 
> Not to my knowledge, but you can try embedding newlines ("\n") in the text
> and using a label with left justification instead.  That will make the
> widget about the same size as the text, except you have to know ahead of
> time where to stuff the newlines.  This works if the text for the label is
> statically defined, but could be problematic (re: you'll have to write
> extra code to stuff in newlines manually) if the text changes dynamically.
> 
> Of course if you need to be able to edit this text, then this method won't
> help, unfortunately.
> --
> Michael J. Hammel           |
> The Graphics Muse           | Error, no keyboard - press F1 to continue.
> mjhammel@graphics-muse.org  |
> http://www.graphics-muse.org
> 
> --
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null

There are a couple of difficulties I see. They are not
insurmountable, just tedious. The case I have I do not
know the text beforehand, it is read from a file. Also
in order to insert the line breaks in a good spot I would
have to use the same algorithm the text widget must use
because the font is perportional. If I have to do that I
could just count the \n's I would insert, but not insert
them, then I would know how many lines were used. 

I guess I will look at the text widget again. It is pretty
big and I couldn't figure out exactly where the word wrap
stuff was calculated. I may try to change the text widget so
this information is accessable. I can't be the only person
who would need this, can I?

thanks
Todd

-- 
-----------------------------------------
Todd & Lisa Dukes
tjdukes@flash.net



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