views:

440

answers:

1

Hi,

I have an Eclipse plugin that displays a view. What I want to do is display n images in the view in a single row with a centered label under each image. I want to view to be scrollable. I also want each image to be re-sized when the dimensions of the view (ScrolledComposite? Composite?) change so it utilizes the available vertical and horizontal client area.

I have implemented the following in the createViewPart method (declarations and error checking has been omitted):

    public void createPartControl(Composite parent) {

        ScrolledComposite myScrolledComposite = new ScrolledComposite(parent, 
     SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);

        myComposite = new Composite(myScrolledComposite, SWT.NONE);

        myScrolledComposite.setContent(myComposite);
    }

What's the best approach from this point forward?

  1. Should I subclass Composite and have that class draw a given image on itself and center a label under the image?
  2. What layout manager should I use to center the label under the image?
  3. Should the "parent" parameter of my subclass be "myComposite"?
  4. Which layout manager should I use with "myComposite"?
  5. When it comes to resizing the images, do I calculate the available width and height by using the getBounds of "myComposite" - my subclassed composite's getBounds?

Thanks for your assistance.

A: 

I suggest you take a look at the Gallery widget provided by the Eclipse Nebula project, maybe you can use it or at least get some ideas from how they implemented it.

Zsolt Török
Thanks I will check it out.
Dr. Faust
I did check out the Gallery Widget. It was just what I needed. Developers using SWT Widgets should definitely check out the Gallery Widget and the other Widgets that make up the Eclipse Nebula project.
Dr. Faust