问题
I have a E4 application with some custom toolbar widgets. When the application ran in WIndows 10 without DPI scaling, everything looks fine. After chaning the DPI settings the application toolbar is not fully viewed.
Correct view:
With scaling enabled:
The application.e4xmi looks like:
The class that is responsible for creating the widget looks like:
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));
}
}
}
Is there some way to change the heigt of the widgets in the toolbar? I know how to calculate the DPI change but cannot set any heigt/width values on any of the components.
回答1:
Move the ToolControl items to be outside of the ToolBar. Controls inside a ToolBar don't resize the bar but when outside of the ToolBar they should resize the TrimBar ok.
来源:https://stackoverflow.com/questions/51280425/toolbar-does-not-scale-correctly-in-e4