Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Tree selection rendering questions
Tree selection rendering questions [message #631937] Sun, 10 October 2010 16:29 Go to next message
Bjorn Gustafsson is currently offline Bjorn Gustafsson
Messages: 7
Registered: July 2009
Junior Member
Hi,
I develop a planning editor that has a widget with a Tree and a Canvas side-by-side. For each tree item in the Tree, there's a timebox item drawn on the Canvas, aligned so they appear to be part of the same "widget row".

I have two problems in relation to rendering of Tree selection. I'm hoping someone can help me with this this - any input is more than welcome!

1. I want to draw the background of the row in the Canvas in the same color as the Tree selection (both focused and non-focused) so that when user selects a row in the Tree, I can render the Canvas background in the same color. How can I get hold of the Tree selection colors and use them in the Canvas?

2. When the user selects a "widget row" in the Canvas I also select the corresponding tree item so the whole "widget row" appears selected. However, since the Canvas receives focus, the Tree loses focus and the Tree selection is rendered as grey non-focused. Is there a way to override the Tree behaviour and render as selected/focused even though it does not have focus?

With Best Regards,
Bjorn Gustafsson


Re: Tree selection rendering questions [message #632030 is a reply to message #631937] Mon, 11 October 2010 05:35 Go to previous message
Lakshmi Shanmugam
Messages: 274
Registered: July 2009
Location: India
Senior Member
Hi,

You can solve both 1 & 2 by Custom drawing using the SWT.EraseItem Listener.
You can read about Custom drawing here --> Article on Custom Drawing
Please see the eraseListener in Snippet234. It seems to do exactly what you are looking for. You can use the same color used in the eraseListener i.e, display.getSystemColor(SWT.COLOR_LIST_SELECTION) to set the color in the canvas.

HTH,


Lakshmi P Shanmugam
Previous Topic:Simulating some Combo behavior for Text
Next Topic:JDK 7 on Windows: No aero styled widgets
Goto Forum:
  


Current Time: Sun Apr 20 23:00:57 EDT 2014

Powered by FUDForum. Page generated in 0.01697 seconds