Search in sources :

Example 16 with CoolBar

use of org.eclipse.swt.widgets.CoolBar 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 17 with CoolBar

use of org.eclipse.swt.widgets.CoolBar 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)

Example 18 with CoolBar

use of org.eclipse.swt.widgets.CoolBar in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_CoolItem method test_ConstructorLorg_eclipse_swt_widgets_CoolBarI.

@Test
public void test_ConstructorLorg_eclipse_swt_widgets_CoolBarI() {
    CoolBar coolBar = new CoolBar(shell, 0);
    new CoolItem(coolBar, 0);
    try {
        new CoolItem(null, 0);
        fail("No exception thrown for parent == null");
    } catch (IllegalArgumentException e) {
    }
}
Also used : CoolBar(org.eclipse.swt.widgets.CoolBar) CoolItem(org.eclipse.swt.widgets.CoolItem) Test(org.junit.Test)

Example 19 with CoolBar

use of org.eclipse.swt.widgets.CoolBar in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_CoolItem method test_setSizeII.

@Test
public void test_setSizeII() {
    CoolBar coolBar = new CoolBar(shell, 0);
    CoolItem coolItem = new CoolItem(coolBar, 0);
    Button button = new Button(coolBar, SWT.PUSH);
    button.setText("foo");
    coolItem.setControl(button);
    coolItem.setSize(50, 50);
    assertEquals(new Point(50, 50), coolItem.getSize());
    coolItem.setSize(0, 0);
    Point smallest = coolItem.getSize();
    coolItem.setSize(1, 1);
    assertEquals(smallest, coolItem.getSize());
    Rectangle rect = coolItem.getBounds();
    Point size = coolItem.getSize();
    coolItem.setSize(rect.width, rect.height);
    assertEquals(size, coolItem.getSize());
}
Also used : CoolBar(org.eclipse.swt.widgets.CoolBar) Button(org.eclipse.swt.widgets.Button) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) CoolItem(org.eclipse.swt.widgets.CoolItem) Test(org.junit.Test)

Example 20 with CoolBar

use of org.eclipse.swt.widgets.CoolBar in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_CoolItem method test_getSize.

@Test
public void test_getSize() {
    CoolBar coolBar = new CoolBar(shell, 0);
    CoolItem coolItem = new CoolItem(coolBar, 0);
    Button button = new Button(coolBar, SWT.PUSH);
    button.setText("foo");
    coolItem.setControl(button);
    Point size = coolItem.getSize();
    Rectangle rect = coolItem.getBounds();
    assertEquals(rect.width, size.x);
    assertEquals(rect.height, size.y);
}
Also used : CoolBar(org.eclipse.swt.widgets.CoolBar) Button(org.eclipse.swt.widgets.Button) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) CoolItem(org.eclipse.swt.widgets.CoolItem) Test(org.junit.Test)

Aggregations

CoolBar (org.eclipse.swt.widgets.CoolBar)22 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 GridData (org.eclipse.swt.layout.GridData)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 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