【问题标题】:Toolbar does not scale correctly in E4工具栏在 E4 中无法正确缩放
【发布时间】:2018-07-11 08:14:20
【问题描述】:

我有一个带有一些自定义工具栏小部件的 E4 应用程序。当应用程序在没有 DPI 缩放的情况下在 WINdows 10 中运行时,一切看起来都很好。更改 DPI 设置后,无法完全查看应用程序工具栏。

正确的观点:

启用缩放:

application.e4xmi 看起来像:

负责创建小部件的类如下所示:

public class OpenOrderDropDown {

  @Inject
  private IEclipseContext context;

  private Combo combo;

  private static final String[] ITEMS = {"Default", "Planning", "Open JobOrders", "Stock Units", "To Schedule"};

  @PostConstruct
  public void createControls(final Composite parent) {

    RowLayout layout = new RowLayout();
    parent.setLayout(layout);

    Label label = new Label(parent, SWT.LEFT);
    label.setText("View: ");

    combo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
    combo.setItems(ITEMS);

    combo.select(0);

    combo.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {

        IEventBroker eventBroker = context.get(IEventBroker.class);
        eventBroker.post("openOrdersView", combo.getText());

      }
    });
  }

  @Inject
  @Optional
  public void changeSelection(@UIEventTopic("changeOpenOrdersView") String selection) {
    if (selection == null || selection.isEmpty()) {
      selection = "Default";
    }

    if (combo != null && !combo.isDisposed()) {
      combo.select(combo.indexOf(selection));
    }

  }

}

有没有办法改变工具栏中小部件的高度?我知道如何计算 DPI 变化,但无法在任何组件上设置任何高度/宽度值。

【问题讨论】:

    标签: eclipse-rcp scaling e4


    【解决方案1】:

    将 ToolControl 项移动到工具栏之外。 ToolBar 内的控件不会调整栏的大小,但在 ToolBar 之外时,它们应该调整 TrimBar 的大小。

    【讨论】:

    • 好的,现在正在缩放。但是我的工具栏的布局现在很糟糕。有没有办法向修剪栏添加网格布局或行布局?
    • “废话”是什么意思?最好提出一个新问题来展示你所看到的
    • 所有工具控件都位于彼此下方,而不是彼此相邻。换句话说,只有最顶层的控件被查看,其他控件不可见,因为它们位于顶部控件之下。
    • 这可能是因为您在 parent 复合上设置 RowLayout - 该复合不属于您的代码,您不应该触摸它。创建一个新的 Composite 作为父级的子级来保存您的控件,不要在父级上设置布局。
    猜你喜欢
    • 2011-09-22
    • 2019-10-16
    • 1970-01-01
    • 2018-06-22
    • 2019-05-18
    • 1970-01-01
    • 1970-01-01
    • 2013-09-24
    • 2011-05-08
    相关资源
    最近更新 更多