同时切换到windows经典主题组合贡献项目shirnks

时间:2023-01-12 13:53:26

I do have a problem with IToolbarManager. I have added a combo & spinner ot toolbar of a view like this

我确实遇到了IToolbarManager的问题。我添加了一个这样的视图的组合和微调器工具栏

IToolbarManager mgr = getViewSite().getActionBars().getToolBarManager();
mgr.add(spinnerCntrAction);

spinnerCntrAction = new ControContribution(){

 public Control createControl(){
        //Creates composite
        //Create a spinner and add that to composite
        //return composite
 }


};

In windows XP/Vista themes this spinner is shown correctly. But when program is run under windows classic theme , the spinner is shrinked and not shown correctly.

在Windows XP / Vista主题中,此微调器正确显示。但是当程序在Windows经典主题下运行时,微调器会缩小并且无法正确显示。

Is this a known problem ? Do you know any workaround/patch for this ?

这是一个已知的问题吗?你知道任何解决方法/补丁吗?

Thanks Jijoy

1 个解决方案

#1


This is a bug in SWT. See http://dev.eclipse.org/newslists/news.eclipse.platform.swt/msg44671.html

这是SWT中的一个错误。见http://dev.eclipse.org/newslists/news.eclipse.platform.swt/msg44671.html

Here is a workaround:

这是一个解决方法:

mgr.add(new DummyAction());

private static class DummyAction extends Action {
   DummyAction() {
      setEnabled(false);
      setText("     ");
   }
}
...
mgr.add(spinnerCntrAction);

This will cause the toolbar manager to make all control contributions the same size as the Action, so adjust the number of spaces in the Action text to get the desired result.

这将使工具栏管理器使所有控件贡献与Action的大小相同,因此调整Action文本中的空格数以获得所需的结果。

#1


This is a bug in SWT. See http://dev.eclipse.org/newslists/news.eclipse.platform.swt/msg44671.html

这是SWT中的一个错误。见http://dev.eclipse.org/newslists/news.eclipse.platform.swt/msg44671.html

Here is a workaround:

这是一个解决方法:

mgr.add(new DummyAction());

private static class DummyAction extends Action {
   DummyAction() {
      setEnabled(false);
      setText("     ");
   }
}
...
mgr.add(spinnerCntrAction);

This will cause the toolbar manager to make all control contributions the same size as the Action, so adjust the number of spaces in the Action text to get the desired result.

这将使工具栏管理器使所有控件贡献与Action的大小相同,因此调整Action文本中的空格数以获得所需的结果。