`
louisling
  • 浏览: 145272 次
  • 性别: Icon_minigender_1
  • 来自: ZhuHai
社区版块
存档分类
最新评论

To show a custom area for toolbar.

    博客分类:
  • RCP
 
阅读更多
To show a custom area for toolbar.

public void postWindowOpen() {
    //...
}

//Add to postWindowOpen()
final IWorkbenchWindow window = getWindowConfigurer().getWindow();

Listener listener = new Listener() {
    private Shell toolbar;

    public void handleEvent(Event event) {
    Control control = (Control) event.widget;
    Point mouse = control.toDisplay(event.x, event.y);
    final Shell shell = window.getShell();
    Point location = shell.getLocation();
    Point size = shell.getSize();
    int xIndent = 2;
    int yIndent = 24;
    int height = 30;
    if (mouse.x > location.x 
        && mouse.y > location.y + yIndent
        && location.x + size.x > mouse.x
        && location.y + yIndent + height > mouse.y) {
        if (toolbar == null) {
        toolbar = new Shell(shell, SWT.NO_TRIM);
        toolbar.setSize(size.x - 2 * xIndent, height);
        toolbar.setLocation(location.x + xIndent, location.y + yIndent);
        GridLayout layout = new GridLayout(24, false);
        layout.marginLeft = 0;
        layout.marginTop = 0;
        toolbar.setLayout(layout);
        new Button(toolbar, SWT.PUSH).setText("action 1");
        new Button(toolbar, SWT.PUSH).setText("action 2");
        new Button(toolbar, SWT.PUSH).setText("action 3");
        toolbar.setVisible(true);
        }
    } else {
        if (toolbar != null) {
        toolbar.dispose();
        toolbar = null;
        }
    }
    }
};

window.getShell().getDisplay().addFilter(SWT.MouseMove, listener);
分享到:
评论

相关推荐

    WPTools.v6.29.1.Pro

    - Update to RTF reader to load landscape flag for sections better - when page mirror was used, after a page break the text indentation was sometimes wrong - hyphenation code was broken - workaround ...

    VB编程资源大全(英文源码 其它)

    "This technique allows a program to save hierarchical information like the data in a TreeView in a way that is easy to understand."<END><br>11 , OLE.zip Demonstrates the use of OLE.<END><br>12 , ...

    VB编程资源大全(英文源码 控制)

    1.x/6.0 (Java) <END><br>6 , ocxex.zip "This is a quick example I made to show you how to use Events and properties in a OCX."<END><br>7 , news.exe This control aids as a complete Newsgroup ...

    VB编程资源大全(英文控件)

    supports drawing of external graphics on the text area...useful for html editors etc<END><br>63,Player.zip A multimedia ocx to replace mediaplayer ocx<END><br>64,Audio.zip This ActiveX Control ...

    曲线拟合工具CurveExpert 1.0

    + A plot that was copied to the clipboard failed to "clip" data points that were outside of the graphing pane, resulting in points being drawn outside of the intended area. Fixed. + The ...

    Visual C++ 编程资源大全(英文源码 表单)

    18.zip Color Dialog with Persistent Custom Colors 对话框继承了上一次的颜色风格(12KB)<END><br>19,19.zip A Base Dialog Class for Modal/Modeless Dialog with Custom Background Color 自定义背景...

    proe3.0所有操纵面板的说明(工具条)

    - **Note** / **Hyperlink** / **Repeat Formatting** / **Geometric Tolerance** / **Standard Symbol** / **Custom Symbol** / **Move Special** / **Table** / **Update Table** / **Cleanup Balloons** / **...

Global site tag (gtag.js) - Google Analytics