Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified examples/org.eclipse.swt.snippets/previews/Snippet382.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,34 @@ public int getGcStyle() {
final Image disabledImageWithTransparentGcDrawer = new Image (display, imageWithTransparentGcDrawer, SWT.IMAGE_DISABLE);
final Image greyImageWithTransparentGcDrawer = new Image (display, imageWithTransparentGcDrawer, SWT.IMAGE_GRAY);

Image imageWithPlainImageData = new Image(display, 16, 16);

GC plainImageGCDrawer = new GC(imageWithPlainImageData);
plainImageGCDrawer.setBackground(display.getSystemColor(SWT.COLOR_RED));
plainImageGCDrawer.fillRectangle(0, 0, 16, 16);
plainImageGCDrawer.setForeground(display.getSystemColor(SWT.COLOR_YELLOW));
plainImageGCDrawer.drawRectangle(4, 4, 8, 8);
plainImageGCDrawer.dispose();

Image disabledImageWithPlainImageData = new Image(display, imageWithPlainImageData, SWT.IMAGE_DISABLE);
Image greyImageWithPlainImageData = new Image(display, imageWithPlainImageData, SWT.IMAGE_GRAY);


Image imageWithPlainImageDataWithHandleAlreadyCreated = new Image (display, 16, 16);

GC plainImageWithHandleCreated = new GC (imageWithPlainImageDataWithHandleAlreadyCreated);
plainImageWithHandleCreated.setBackground(display.getSystemColor(SWT.COLOR_RED));
plainImageWithHandleCreated.fillRectangle(0, 0, 16, 16);
plainImageWithHandleCreated.setForeground(display.getSystemColor(SWT.COLOR_YELLOW));
plainImageWithHandleCreated.drawRectangle(4, 4, 8, 8);
plainImageWithHandleCreated.dispose();
// Force creation of the handle at 150% zoom
imageWithPlainImageDataWithHandleAlreadyCreated.getImageData(150);

Image disabledImageWithHandleCreated = new Image (display, imageWithPlainImageDataWithHandleAlreadyCreated, SWT.IMAGE_DISABLE);
Image greyImageWithHandleCreated = new Image (display, imageWithPlainImageDataWithHandleAlreadyCreated, SWT.IMAGE_GRAY);


final Shell shell = new Shell (display);
shell.setText("Snippet382");
shell.setLayout (new GridLayout (3, false));
Expand Down Expand Up @@ -149,6 +177,16 @@ public void handleEvent(Event e) {
drawImages(mainGC, gcData, "Normal", 740, imageWithTransparentGcDrawer);
drawImages(mainGC, gcData, "Disabled", 780, disabledImageWithTransparentGcDrawer);
drawImages(mainGC, gcData, "Greyed", 820, greyImageWithTransparentGcDrawer);

mainGC.drawText("--Image with PlainImageData--", 20, 850);
drawImages(mainGC, gcData, "Normal", 880, imageWithPlainImageData);
drawImages(mainGC, gcData, "Disabled", 920, disabledImageWithPlainImageData);
drawImages(mainGC, gcData, "Greyed", 960, greyImageWithPlainImageData);

mainGC.drawText("--Image with PlainImageData (Handle Created Before Grey or Disabled Image Created)--", 20, 1000);
drawImages(mainGC, gcData, "Normal", 1040, imageWithPlainImageDataWithHandleAlreadyCreated);
drawImages(mainGC, gcData, "Disabled", 1080, disabledImageWithHandleCreated);
drawImages(mainGC, gcData, "Greyed", 1120, greyImageWithHandleCreated);
} finally {
mainGC.dispose ();
}
Expand All @@ -168,7 +206,7 @@ private void drawImages(GC mainGC, GCData gcData, String text, int y, final Imag
};
shell.addListener(SWT.Paint, l);

shell.setSize(400, 750);
shell.setSize(400, 850);
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
Expand Down
Loading