Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » GalleryItem & DefaultGalleryItemRenderer Problem
GalleryItem & DefaultGalleryItemRenderer Problem [message #52792] Mon, 12 May 2008 12:24 Go to next message
Eclipse UserFriend
Originally posted by: sandeep.goel.barco.com

Hi,
I am using nebula widgets (Gallery) to give view like ICON view in
Windows.
by the following code.
public static void main (final String[] args)
{
final Display display = new Display();
final Image itemImage = new Image(display,
Program.findProgram("gif").getImageData());

final Shell shell = new Shell(display);
shell.setSize(400, 300);
shell.setLayout(new FillLayout());
final Gallery gallery = new Gallery(shell, SWT.V_SCROLL | SWT.MULTI);
// Renderers
final NoGroupRenderer gr = new NoGroupRenderer();
gr.setMinMargin(2);
gr.setItemSize(76, 56);
gr.setAutoMargin(true);
gallery.setGroupRenderer(gr);

final DefaultGalleryItemRenderer ir = new DefaultGalleryItemRenderer();
gallery.setItemRenderer(ir);

for (int g = 0; g {
final GalleryItem group = new GalleryItem(gallery, SWT.NONE);
group.setText("Group " + g);
group.setExpanded(true);

for (int i = 0; i {
final GalleryItem item = new GalleryItem(group, SWT.NONE);
if (itemImage != null)
{
item.setImage(itemImage);
}
item.setText("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
}
}

shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
{
display.sleep();
}
}

if (itemImage != null)
{
itemImage.dispose();
}
display.dispose();
}

here problem is that when I select an item I get a rectanle around it.(By
modifying implementation of render class I removed that recatangle.) But
now I need to make that image of the selected item must be selected as in
the windows means only image must get a thin blue layer on it which makes
it as selected.

Can any body help me??
Thanks..
With BR
Sandeep Goel...
Re: GalleryItem & DefaultGalleryItemRenderer Problem [message #53676 is a reply to message #52792] Thu, 22 May 2008 07:11 Go to previous message
Nicolas Richeton is currently offline Nicolas RichetonFriend
Messages: 179
Registered: July 2009
Senior Member
Hi,

You'll have to create a custom item renderer, paint the image first and
then draw a rectangle on it with the right pattern / transparency /
color settings.

There was an anwser to your post on the rcp group, saying that you can
use SWT.COLOR_LIST_SELECTION to get the right color

see fillRectancle(...), setBackground(), setBackgroundPattern()
in
http://help.eclipse.org/stable/nftopic/org.eclipse.platform. doc.isv/reference/api/org/eclipse/swt/graphics/GC.html

--
Nicolas

Sandeep Goel a écrit :
> Hi, I am using nebula widgets (Gallery) to give view like ICON view in
> Windows. by the following code. public static void main (final String[]
> args) { final Display display = new Display(); final Image itemImage =
> new Image(display, Program.findProgram("gif").getImageData());
> final Shell shell = new Shell(display); shell.setSize(400, 300);
> shell.setLayout(new FillLayout()); final Gallery gallery = new
> Gallery(shell, SWT.V_SCROLL | SWT.MULTI); // Renderers final
> NoGroupRenderer gr = new NoGroupRenderer(); gr.setMinMargin(2);
> gr.setItemSize(76, 56); gr.setAutoMargin(true);
> gallery.setGroupRenderer(gr);
> final DefaultGalleryItemRenderer ir = new DefaultGalleryItemRenderer();
> gallery.setItemRenderer(ir);
> for (int g = 0; g { final GalleryItem group = new GalleryItem(gallery,
> SWT.NONE); group.setText("Group " + g); group.setExpanded(true);
> for (int i = 0; i { final GalleryItem item = new GalleryItem(group,
> SWT.NONE); if (itemImage != null) { item.setImage(itemImage); }
> item.setText("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); } }
> shell.open(); while (!shell.isDisposed()) { if
> (!display.readAndDispatch()) { display.sleep(); } }
> if (itemImage != null) { itemImage.dispose(); } display.dispose(); }
> here problem is that when I select an item I get a rectanle around
> it.(By modifying implementation of render class I removed that
> recatangle.) But now I need to make that image of the selected item must
> be selected as in the windows means only image must get a thin blue
> layer on it which makes it as selected.
> Can any body help me?? Thanks.. With BR Sandeep Goel...
Re: GalleryItem & DefaultGalleryItemRenderer Problem [message #590057 is a reply to message #52792] Thu, 22 May 2008 07:11 Go to previous message
Nicolas Richeton is currently offline Nicolas RichetonFriend
Messages: 179
Registered: July 2009
Senior Member
Hi,

You'll have to create a custom item renderer, paint the image first and
then draw a rectangle on it with the right pattern / transparency /
color settings.

There was an anwser to your post on the rcp group, saying that you can
use SWT.COLOR_LIST_SELECTION to get the right color

see fillRectancle(...), setBackground(), setBackgroundPattern()
in
http://help.eclipse.org/stable/nftopic/org.eclipse.platform. doc.isv/reference/api/org/eclipse/swt/graphics/GC.html

--
Nicolas

Sandeep Goel a écrit :
> Hi, I am using nebula widgets (Gallery) to give view like ICON view in
> Windows. by the following code. public static void main (final String[]
> args) { final Display display = new Display(); final Image itemImage =
> new Image(display, Program.findProgram("gif").getImageData());
> final Shell shell = new Shell(display); shell.setSize(400, 300);
> shell.setLayout(new FillLayout()); final Gallery gallery = new
> Gallery(shell, SWT.V_SCROLL | SWT.MULTI); // Renderers final
> NoGroupRenderer gr = new NoGroupRenderer(); gr.setMinMargin(2);
> gr.setItemSize(76, 56); gr.setAutoMargin(true);
> gallery.setGroupRenderer(gr);
> final DefaultGalleryItemRenderer ir = new DefaultGalleryItemRenderer();
> gallery.setItemRenderer(ir);
> for (int g = 0; g { final GalleryItem group = new GalleryItem(gallery,
> SWT.NONE); group.setText("Group " + g); group.setExpanded(true);
> for (int i = 0; i { final GalleryItem item = new GalleryItem(group,
> SWT.NONE); if (itemImage != null) { item.setImage(itemImage); }
> item.setText("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); } }
> shell.open(); while (!shell.isDisposed()) { if
> (!display.readAndDispatch()) { display.sleep(); } }
> if (itemImage != null) { itemImage.dispose(); } display.dispose(); }
> here problem is that when I select an item I get a rectanle around
> it.(By modifying implementation of render class I removed that
> recatangle.) But now I need to make that image of the selected item must
> be selected as in the windows means only image must get a thin blue
> layer on it which makes it as selected.
> Can any body help me?? Thanks.. With BR Sandeep Goel...
Previous Topic:NumberFormatter can't handle NULL values
Next Topic:PGroup - Ability to add controls to the title-bar
Goto Forum:
  


Current Time: Thu Nov 27 02:53:39 GMT 2014

Powered by FUDForum. Page generated in 0.02229 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software