1 29 30 31 package swingwtx.custom; 32 33 import org.eclipse.swt.SWT; 34 import org.eclipse.swt.widgets.Control; 35 import org.eclipse.swt.widgets.CoolBar; 36 import org.eclipse.swt.widgets.CoolItem; 37 38 import swingwtx.swing.JComponent; 39 import swingwtx.swing.SwingUtilities; 40 import swingwtx.swing.SwingWTUtils; 41 42 49 public class JCoolBar extends JComponent { 50 51 protected CoolBar ppeer = null; 52 protected boolean pFloatable = true; 53 54 public JCoolBar() {} 55 56 public Control getPeer() { return ppeer; } 57 58 62 public swingwt.awt.Component add(swingwt.awt.Component c) { 63 64 super.add(c); 66 67 if (SwingWTUtils.isSWTControlAvailable(c.getPeer())) { 76 CoolItem cool = new CoolItem(ppeer, SWT.NONE); 77 cool.setControl(c.getPeer()); 78 cool.setMinimumSize(c.getPeer().computeSize(-1, -1)); 79 cool.setSize(c.getPeer().computeSize(-1, -1)); 80 } 81 82 return c; 83 } 84 85 public boolean isFloatable() { return pFloatable; } 86 public void setFloatable(final boolean b) { 87 pFloatable = b; 88 if (SwingWTUtils.isSWTControlAvailable(ppeer)) { 89 SwingUtilities.invokeSync(new Runnable () { 90 public void run() { 91 ppeer.setLocked(!b); 92 } 93 }); 94 } 95 } 96 97 98 public void setLayout(swingwt.awt.LayoutManager l) { } 99 public void setLayout(swingwt.awt.LayoutManager2 l) { } 100 101 public void setSwingWTParent(swingwt.awt.Container parent) throws Exception { 102 descendantHasPeer = true; 103 ppeer = new CoolBar(parent.getComposite(), SWT.BORDER); 104 peer = ppeer; 105 composite = ppeer; 106 this.parent = parent; 107 ppeer.setLocked(!pFloatable); 108 super.setSwingWTParent(parent); 109 } 110 111 } 112 | Popular Tags |