use of org.eclipse.swt.widgets.CoolItem in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_CoolBar method createCoolBar.
private void createCoolBar(List<String> events) {
tearDown();
super.setUp();
String test = getTestName();
coolBar = new CoolBar(shell, SWT.FLAT);
ToolBar[] coolItemToolBar = new ToolBar[2];
for (int i = 0; i < 2; i++) {
CoolItem coolItem = new CoolItem(coolBar, SWT.DROP_DOWN);
coolItemToolBar[i] = new ToolBar(coolBar, SWT.FLAT);
hookExpectedEvents(coolItem, test, events);
hookExpectedEvents(coolItemToolBar[i], test, events);
int toolItemWidth = 0;
for (int j = 0; j < 2; j++) {
ToolItem item = new ToolItem(coolItemToolBar[i], SWT.CHECK);
item.setText("CB" + ((i * 2) + j));
item.setToolTipText("ToolItem ToolTip" + i + j);
if (item.getWidth() > toolItemWidth)
toolItemWidth = item.getWidth();
hookExpectedEvents(item, test, events);
}
coolItem.setControl(coolItemToolBar[i]);
Point size;
if (i == 1)
size = coolItemToolBar[i].computeSize(20, SWT.DEFAULT);
else
size = coolItemToolBar[i].computeSize(SWT.DEFAULT, SWT.DEFAULT);
Point coolSize = coolItem.computeSize(size.x, size.y);
coolItem.setMinimumSize(toolItemWidth / 3, coolSize.y);
coolItem.setPreferredSize(coolSize);
coolItem.setSize(coolSize.x / 3, coolSize.y);
coolItem.addSelectionListener(new CoolItemSelectionListener());
}
setWidget(coolBar);
}
use of org.eclipse.swt.widgets.CoolItem in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_CoolItem method test_getControl.
@Test
public void test_getControl() {
CoolBar coolBar = new CoolBar(shell, 0);
CoolItem coolItem = new CoolItem(coolBar, 0);
assertNull(coolItem.getControl());
Button button = new Button(coolBar, SWT.PUSH);
coolItem.setControl(button);
Control control = coolItem.getControl();
assertEquals(button, control);
button = new Button(coolBar, SWT.PUSH);
coolItem.setControl(button);
control = coolItem.getControl();
assertEquals(button, control);
}
use of org.eclipse.swt.widgets.CoolItem in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_CoolItem method test_computeSizeII.
@Test
public void test_computeSizeII() {
CoolBar coolBar = new CoolBar(shell, 0);
CoolItem coolItem = new CoolItem(coolBar, 0);
Button button = new Button(coolBar, SWT.PUSH);
button.setText("foo");
Point size = coolItem.computeSize(SWT.DEFAULT, SWT.DEFAULT);
coolItem.setControl(button);
Point size2 = coolItem.computeSize(SWT.DEFAULT, SWT.DEFAULT);
assertTrue(size2.x == size.x);
size = coolItem.computeSize(50, 25);
size2 = coolItem.computeSize(100, 25);
assertEquals(size.x + 50, size2.x);
assertEquals(size.y, size2.y);
size = coolItem.computeSize(1, 1);
size2 = coolItem.computeSize(26, 26);
assertEquals(25, size2.x - size.x);
}
use of org.eclipse.swt.widgets.CoolItem in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_CoolItem method test_getPreferredSize.
@Test
public void test_getPreferredSize() {
CoolBar coolBar = new CoolBar(shell, 0);
CoolItem coolItem = new CoolItem(coolBar, 0);
Button button = new Button(coolBar, SWT.PUSH);
button.setText("foobar");
coolItem.setControl(button);
Point pref = coolItem.getPreferredSize();
coolItem.setPreferredSize(pref);
assertEquals(pref, coolItem.getPreferredSize());
}
use of org.eclipse.swt.widgets.CoolItem in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_CoolItem method test_setPreferredSizeLorg_eclipse_swt_graphics_Point.
@Test
public void test_setPreferredSizeLorg_eclipse_swt_graphics_Point() {
CoolBar coolBar = new CoolBar(shell, 0);
CoolItem coolItem = new CoolItem(coolBar, 0);
Button button = new Button(coolBar, SWT.PUSH);
button.setText("foobar");
coolItem.setControl(button);
Point size = new Point(50, 30);
coolItem.setPreferredSize(size);
Point size2 = coolItem.getPreferredSize();
coolItem.setPreferredSize(50, 30);
assertEquals(size2, coolItem.getPreferredSize());
}
Aggregations