Search in sources :

Example 11 with CoolItem

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);
}
Also used : CoolBar(org.eclipse.swt.widgets.CoolBar) ToolBar(org.eclipse.swt.widgets.ToolBar) Point(org.eclipse.swt.graphics.Point) CoolItem(org.eclipse.swt.widgets.CoolItem) Point(org.eclipse.swt.graphics.Point) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 12 with CoolItem

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);
}
Also used : Control(org.eclipse.swt.widgets.Control) CoolBar(org.eclipse.swt.widgets.CoolBar) Button(org.eclipse.swt.widgets.Button) CoolItem(org.eclipse.swt.widgets.CoolItem) Test(org.junit.Test)

Example 13 with CoolItem

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);
}
Also used : CoolBar(org.eclipse.swt.widgets.CoolBar) Button(org.eclipse.swt.widgets.Button) Point(org.eclipse.swt.graphics.Point) CoolItem(org.eclipse.swt.widgets.CoolItem) Test(org.junit.Test)

Example 14 with CoolItem

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());
}
Also used : CoolBar(org.eclipse.swt.widgets.CoolBar) Button(org.eclipse.swt.widgets.Button) Point(org.eclipse.swt.graphics.Point) CoolItem(org.eclipse.swt.widgets.CoolItem) Test(org.junit.Test)

Example 15 with CoolItem

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());
}
Also used : CoolBar(org.eclipse.swt.widgets.CoolBar) Button(org.eclipse.swt.widgets.Button) Point(org.eclipse.swt.graphics.Point) CoolItem(org.eclipse.swt.widgets.CoolItem) Test(org.junit.Test)

Aggregations

CoolBar (org.eclipse.swt.widgets.CoolBar)20 CoolItem (org.eclipse.swt.widgets.CoolItem)20 Point (org.eclipse.swt.graphics.Point)15 Button (org.eclipse.swt.widgets.Button)14 Test (org.junit.Test)13 ToolBar (org.eclipse.swt.widgets.ToolBar)6 ToolItem (org.eclipse.swt.widgets.ToolItem)6 Control (org.eclipse.swt.widgets.Control)5 Text (org.eclipse.swt.widgets.Text)5 StyledText (org.eclipse.swt.custom.StyledText)4 Rectangle (org.eclipse.swt.graphics.Rectangle)4 Combo (org.eclipse.swt.widgets.Combo)4 Label (org.eclipse.swt.widgets.Label)4 CCombo (org.eclipse.swt.custom.CCombo)3 FillLayout (org.eclipse.swt.layout.FillLayout)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Canvas (org.eclipse.swt.widgets.Canvas)3 Composite (org.eclipse.swt.widgets.Composite)3 Display (org.eclipse.swt.widgets.Display)3