Eclipse RCP图像应用程序:如何布置我的图像?

时间:2022-09-22 19:01:00

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.

我有一个显示视图的Eclipse插件。我想要做的是在视图中以单行显示n个图像,每个图像下面都有一个居中标签。我想查看可滚动。我还希望在视图的尺寸(ScrolledComposite?Composite?)发生变化时重新调整每个图像的大小,以便利用可用的垂直和水平客户区域。

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

我在createViewPart方法中实现了以下内容(省略了声明和错误检查):

    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. 我应该将Composite子类化并让该类在自身上绘制一个给定的图像并将图像置于图像下面?

  3. What layout manager should I use to center the label under the image?
  4. 我应该使用什么布局管理器将标签置于图像下方?

  5. Should the "parent" parameter of my subclass be "myComposite"?
  6. 我的子类的“父”参数应该是“myComposite”吗?

  7. Which layout manager should I use with "myComposite"?
  8. 我应该在“myComposite”中使用哪个布局管理器?

  9. 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?
  10. 在调整图像大小时,使用“myComposite”的getBounds - 我的子类复合的getBounds来计算可用的宽度和高度吗?

Thanks for your assistance.

谢谢你的协助。

1 个解决方案

#1


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.

我建议你看一下Eclipse Nebula项目提供的Gallery小部件,也许你可以使用它,或者至少从它们实现它的方式中得到一些想法。

#1


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.

我建议你看一下Eclipse Nebula项目提供的Gallery小部件,也许你可以使用它,或者至少从它们实现它的方式中得到一些想法。