代码之家  ›  专栏  ›  技术社区  ›  JimmyD

E4中的工具栏缩放不正确

  •  0
  • JimmyD  · 技术社区  · 7 年前

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

    正确视图:

    启用缩放:

    application.e4xmi如下所示:

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

    < PrimeC类=“LangJavaPrTyPrimeRoopRead”>代码> public类OpenOrthDROP @注入 私有的ieclipsContext上下文; 私有组合组合; private static final string[]items=“default”,“planning”,“open joborders”,“stock units”,“to schedule”; @后建设 公共void createControls(最终复合父级){ rowlayout布局=new rowlayout(); parent.setlayout(布局); label label=新标签(父级,swt.left); label.settext(“视图:”); Combo=新的Combo(父级,swt.drop_down_swt.read_only); 组合项(项); 组合。选择(0); combo.addSelectionListener(new SelectionAdapter()){ @覆盖 已选择公共void小部件(SelectionEvent e){ ieventbroker eventbroker=context.get(ieventbroker.class); eventbroker.post(“openOrdersView”,combo.getText()); } })(二) } @注入 @可选 public void changeselection(@uieventtopic(“changeopenordersview”)字符串选择){ if(selection==null selection.isEmpty()){ selection=“默认”; } 如果(组合!=空!combo.isdisposed())中{ combo.select(combo.indexof(selection)); } } }

    有什么方法可以更改工具栏中小部件的高度吗?我知道如何计算dpi变化,但不能在任何组件上设置任何高度/宽度值。

    正确视图:

    enter image description here

    启用缩放时:

    enter image description here

    application.e4xmi如下所示: enter image description here

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

    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变化,但不能在任何组件上设置任何高度/宽度值。

    1 回复  |  直到 7 年前
        1
  •  1
  •   greg-449    7 年前

    推荐文章