Thursday, March 22, 2012

Re: How to format custom TreeItems with images?

Instead of constructing your TreeItems with html, write your own
custom tree item renderer and pass it in to the TreeItem(Widget)
constructor.

http://google-web-toolkit.googlecode.com/svn/javadoc/2.4/com/google/gwt/user/client/ui/TreeItem.html

My TreeItemRenderer extends HorizontalPanel, but you can use any
Widget that works for you.

On Mar 22, 2:40 pm, dhoffer <dhoff...@gmail.com> wrote:
> I have a GWT Tree that contains custom TreeItems that consist of a
> leading image (ImageResource), then some text, and followed with
> another optional image.  The later image is a URL not an ImageResource
> because the contents are dynamic at runtime.
>
> Currently I'm building some custom SafeHtml just appending three
> SafeHtml's together.  I use ImageResourceRenderer for the first image,
> then SimpleSafeHtmlRenderer for the text, and then Template for the
> URL image.
>
> However the results are not good.  The first image is top aligned
> instead of centered with the text and the selection rectangle.  (I
> haven't even gotten to testing with the trailing image yet.)
>
> I do have my custom HTML wrapped in a span with custom class name so I
> can configure with CSS but I have a feeling I'm not doing this the
> right way.
>
> How can I have better control over the vertical alignment of things?
> Specifically the ImageResource needs to be centered.
>
> -Dave

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment