Re: [Java-gnome-developer] Word wrap in a CellRenderText
Brought to you by:
afcowie
From: Joao V. <jvi...@ya...> - 2005-02-02 16:48:03
|
Hmmmm Here's a quick hack: if you put <br> tags, it'll break lines... but of course it won't be as dynamic as you want :P So... the *real* solution to your problem, i believe, would be this: write a custom cell renderer. Now that's the challenge: how hard is it to write a custom cell renderer with JG? Maybe JG should provide some base class for custom cell renderers (*hint hint*). Here's a C tutorial on how to write custom cell renderers: http://scentric.net/tutorial/sec-custom-cell-renderers.html#sec-custom-cell-renderer-example Cheers, J.V. --- Andrew Cowie <an...@op...> escreveu: > Hey there, > > I'm in the process of using a simple single-column ListStore backed > TreeView to display a summarized version of some data, and I'm having a > little trouble fine tuning the rendering - I need word wrap. > > As some of you know, I'm working on something which, broadly stated, > involves displaying XML data. This particular window is a high level > summary, which simplifies navigation around the more specific details of > the document in other windows. As such, I've just read in selected XML > nodes, and composed a single string - with Pango markup - for display in > the TreeView widget. > > Pango obviously provides for wrapping text in Labels; and likewise > TreeView (care of TreeViewColumn and CellRendererText.Attribute.MARKUP) > provides for displaying text with pango markup, so text of > > This is <big>some huge</big> text, and <span > size=small>this is small</span> > > works. The trouble is that there's no markup code (that I can find) for > word wrap. > > I looked up the GNOME manual, and Labels definitely have a wrap > property, and java-gnome lets you at it with Label.setLineWrap(true). > However, the text cells in a TreeView are not Labels, even though the > same pango engine is used to render them. > > CellRendererText has a method called setAttributes(AttrList attr). That > seems to be the way to Pango, but when I look at the org.gnu.pango > classes, I can't figure out how to create the Attribute objects which it > uses. > > Within org.gnu.pango there's a Layout class, which has > setWrapStyle(WrapMode.WORD), but I can't figure out how to get to > Attribute from Layout, or vice versa - for that matter, I can't figure > out what generates Layout objects. > > So obviously I'm way off in left field here. If <span wrap="true"> > worked, then this would be easy, but that doesn't work (and, in fact, > throws quite the error :)). > > If I wasn't using a TreeView, then it would just be labels and would be > easy - but if I was forced to do that then it would mean trying to > manually duplicate the effect of the TreeView widget, and that's going > to be near impossible. > > Help? :) > > A small screenshot of what I'm fighting against is attached. The lines > in italics are all much longer, and the ones that need to be wrapped > instead of cut off. _______________________________________________________ Yahoo! Acesso Grátis - Instale o discador do Yahoo! agora. http://br.acesso.yahoo.com/ - Internet rápida e grátis |