-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
multi zoom level support for pattern for win32
This commit contributes to multi zoom level support of pattern using a map of zoom levels with relevant patterns. Contributes to #62 and #131
- Loading branch information
1 parent
61c6bc2
commit 24473af
Showing
3 changed files
with
133 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...g.eclipse.swt.tests.win32/ManualTests/org/eclipse/swt/widgets/PatternWin32ManualTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.eclipse.swt.widgets; | ||
|
||
import org.eclipse.swt.graphics.Color; | ||
import org.eclipse.swt.graphics.Pattern; | ||
import org.eclipse.swt.internal.DPIUtil; | ||
|
||
public class PatternWin32ManualTest { | ||
private static Display display = Display.getDefault(); | ||
|
||
public static void main (String [] args) { | ||
int zoom = DPIUtil.getDeviceZoom(); | ||
int scaledZoom = zoom * 3; | ||
int width = 400; | ||
int height = 300; | ||
final Pattern pat = new Pattern(display, 0, 0, width, height, new Color(null, 200, 200, 200), 0, new Color(null, 255, 0, 0), 255); | ||
|
||
Shell shell = new Shell(display); | ||
shell.setText("Unscaled shell"); | ||
shell.setSize(width, height); | ||
shell.addPaintListener(e -> { | ||
e.gc.setBackground(new Color(null, 100, 200, 0)); | ||
e.gc.fillRectangle(0, 0, shell.getBounds().width, shell.getBounds().height); | ||
e.gc.setBackground(new Color(null, 255, 0, 0)); | ||
e.gc.setBackgroundPattern(pat); | ||
e.gc.fillRectangle(0, 0, shell.getBounds().width, shell.getBounds().height); | ||
}); | ||
shell.open(); | ||
|
||
DPIUtil.setDeviceZoom(scaledZoom); | ||
Shell shell2 = new Shell(display); | ||
shell2.nativeZoom = scaledZoom; | ||
shell2.setText("Scaled shell"); | ||
shell2.setSize(width, height); | ||
shell2.addPaintListener(e -> { | ||
e.gc.setBackground(new Color(null, 100, 200, 0)); | ||
e.gc.fillRectangle(0, 0, shell2.getBounds().width, shell2.getBounds().height); | ||
e.gc.setBackground(new Color(null, 255, 0, 0)); | ||
e.gc.setBackgroundPattern(pat); | ||
e.gc.fillRectangle(0, 0, shell2.getBounds().width, shell2.getBounds().height); | ||
}); | ||
shell2.open(); | ||
|
||
while (!shell.isDisposed() || !shell2.isDisposed()) { | ||
if (!display.readAndDispatch()) | ||
display.sleep(); | ||
} | ||
pat.dispose(); | ||
shell.dispose(); | ||
shell2.dispose(); | ||
} | ||
} |