Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] is it a bug of jface toolBar?


Does this sound like the problem?
https://bugs.eclipse.org/bugs/show_bug.cgi?id=99984
Carolyn



"刘锦" <bbkills@xxxxxxx>
Sent by: platform-swt-dev-bounces@xxxxxxxxxxx

10/23/2005 01:13 AM

Please respond to
"Eclipse Platform SWT component developers list."

To
platform-swt-dev@xxxxxxxxxxx
cc
Subject
[platform-swt-dev] is it a bug of jface toolBar?





hello ,all,
I encounter a strange problem in window.
when I put a toolItem with a drop down menu and
a ToolItem with a image together into the toolBarManager of a jface
application,
and I find the former is enlarged by the height of the image of the later.
This is the snippt below:

import org.eclipse.jface.action.ContributionItem;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;


public class MyApplicationWindow extends ApplicationWindow {
public MyApplicationWindow() {
super(null);
addToolBar(SWT.FLAT);

}

protected ToolBarManager createToolBarManager(int style) {
// Create the toolbar manager
ToolBarManager toolBarManager = new ToolBarManager(style);

toolBarManager.add(new ContributionItem() {
public void fill(final ToolBar toolBar, int index) {
final Menu menu = new Menu (toolBar.getShell(), SWT.POP_UP);
for (int i=0; i<8; i++) {
MenuItem item = new MenuItem (menu, SWT.PUSH);
item.setText ("Item " + i);
}
final ToolItem item = new ToolItem (toolBar, SWT.DROP_DOWN);
item.setText("Item");
item.addListener (SWT.Selection, new Listener () {
public void handleEvent (Event event) {
if (event.detail == SWT.ARROW) {
Rectangle rect = item.getBounds ();
Point pt = new Point (rect.x, rect.y + rect.height);
pt = toolBar.toDisplay (pt);
menu.setLocation (pt.x, pt.y);
menu.setVisible (true);
}
}
});
}
});

toolBarManager.add(new ContributionItem() {
public void fill(ToolBar toolBar, int index) {
ToolItem item = new ToolItem(toolBar,SWT.FLAT);
Image image = new
Image(toolBar.getDisplay(),"D:\\IBM\\virgoFTP\\icons\\refresh.gif");
item.setImage(image);
}
});
return toolBarManager;
}

public static void main(String[] args) {
MyApplicationWindow window = new MyApplicationWindow();
// Don't return from open() until window closes
window.setBlockOnOpen(true);

// Open the main window
window.open();

// Dispose the display
Display.getCurrent().dispose();
}
}

Thank you for your advice !



===============================================
快来和我一起享受TOM免费邮箱吧! 看看除了1.5G,还有什么?

在线杀毒!安全稳定!超强防御!

明星送祝福(
http://sr.tom.com): 周杰伦  蔡依林  王力宏  田震  代您送去生日祝福

万首金曲免费送(
http://mm.tom.com/ivr/) : 你到底爱谁   千年之恋  我是真的爱你   一辈子做你的女孩

全部彩铃免费送(
http://mm.tom.com/cailing/): 我发财了发财了  你喜欢 我就说嘛  两只蝴蝶   冲动的惩罚
===============================================

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev


Back to the top