summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ST.java21
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextPrintOptions.java29
3 files changed, 30 insertions, 46 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ST.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ST.java
index 3c84dc8e28..77a16da45e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ST.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ST.java
@@ -55,25 +55,4 @@ public class ST {
/* Miscellaneous */
public static final int TOGGLE_OVERWRITE = SWT.INSERT;
-
- /*
- * Print options used in StyledTextPrintOptions */
- /**
- * Print the text foreground color defined in style ranges
- * (value is 1). */
- public static final int TEXT_FOREGROUND = 1;
- /**
- * Print the text background color defined in style ranges
- * (value is 1<<1).
- */
- public static final int TEXT_BACKGROUND = 1 << 1;
- /**
- * Print the font style defined in style ranges
- * (value is 1&lt;&lt;2).
- */
- public static final int TEXT_FONT_STYLE = 1 << 2;
- /**
- * Print the line background color (value is 1&lt;&lt;3).
- */
- public static final int LINE_BACKGROUND = 1 << 3;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
index 34fc76ef7d..876e7b3a13 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
@@ -243,10 +243,12 @@ public class StyledText extends Canvas {
int lineOffset = printerContent.getOffsetAtLine(i);
String line = printerContent.getLine(i);
- if ((printOptions.options & ST.LINE_BACKGROUND) != 0) {
+ if (printOptions.printLineBackground) {
cacheLineBackground(lineOffset, line);
}
- if ((printOptions.options & (ST.TEXT_BACKGROUND | ST.TEXT_FOREGROUND | ST.TEXT_FONT_STYLE)) != 0) {
+ if (printOptions.printTextBackground ||
+ printOptions.printTextForeground ||
+ printOptions.printTextFontStyle) {
cacheLineStyle(lineOffset, line);
}
if (isBidi()) {
@@ -268,17 +270,17 @@ public class StyledText extends Canvas {
StyleRange[] styles = event.styles;
for (int i = 0; i < styles.length; i++) {
StyleRange styleCopy = null;
- if ((printOptions.options & ST.TEXT_BACKGROUND) == 0 && styles[i].background != null) {
+ if (printOptions.printTextBackground == false && styles[i].background != null) {
styleCopy = (StyleRange) styles[i].clone();
styleCopy.background = null;
}
- if ((printOptions.options & ST.TEXT_FOREGROUND) == 0 && styles[i].foreground != null) {
+ if (printOptions.printTextForeground == false && styles[i].foreground != null) {
if (styleCopy == null) {
styleCopy = (StyleRange) styles[i].clone();
}
styleCopy.foreground = null;
}
- if ((printOptions.options & ST.TEXT_FONT_STYLE) == 0 && styles[i].fontStyle != SWT.NORMAL) {
+ if (printOptions.printTextFontStyle == false && styles[i].fontStyle != SWT.NORMAL) {
if (styleCopy == null) {
styleCopy = (StyleRange) styles[i].clone();
}
@@ -5754,8 +5756,12 @@ void performPaint(GC gc,int startLine,int startY, int renderHeight) {
public void print() {
checkWidget();
Printer printer = new Printer();
- StyledTextPrintOptions options = new StyledTextPrintOptions(null, null, null, ST.TEXT_FOREGROUND | ST.TEXT_BACKGROUND | ST.TEXT_FONT_STYLE | ST.LINE_BACKGROUND);
+ StyledTextPrintOptions options = new StyledTextPrintOptions();
+ options.printTextForeground = true;
+ options.printTextBackground = true;
+ options.printTextFontStyle = true;
+ options.printLineBackground = true;
new Printing(this, printer, options).run();
printer.dispose();
}
@@ -5776,9 +5782,13 @@ public void print() {
* </ul>
*/
public Runnable print(Printer printer) {
- StyledTextPrintOptions options = new StyledTextPrintOptions(null, null, null, ST.TEXT_FOREGROUND | ST.TEXT_BACKGROUND | ST.TEXT_FONT_STYLE | ST.LINE_BACKGROUND);
-
+ StyledTextPrintOptions options = new StyledTextPrintOptions();
+
checkWidget();
+ options.printTextForeground = true;
+ options.printTextBackground = true;
+ options.printTextFontStyle = true;
+ options.printLineBackground = true;
if (printer == null) {
SWT.error(SWT.ERROR_NULL_ARGUMENT);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextPrintOptions.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextPrintOptions.java
index a7d74f0977..eb0bdbc723 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextPrintOptions.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextPrintOptions.java
@@ -41,24 +41,19 @@ public class StyledTextPrintOptions {
public String jobName = null;
/**
- * 0 or more of the following print options ORed together.
- * ST.TEXT_FOREGROUND, ST.TEXT_BACKGROUND, ST.TEXT_FONT_STYLE,
- * ST.LINE_BACKGROUND */
- public int options = 0;
-
+ * Print the text foreground color. Default value is <code>false</code>.
+ */
+ public boolean printTextForeground = false;
/**
- * Creates an object of the receiver initialized with default values.
- * By default, none of the text or line styles are printed.
+ * Print the text background color. Default value is <code>false</code>.
*/
- public StyledTextPrintOptions() {
- }
+ public boolean printTextBackground = false;
/**
- * Creates an object of the receiver initialized with the given print
- * options. */
- public StyledTextPrintOptions(String header, String footer, String jobName, int options) {
- this.header = header;
- this.footer = footer;
- this.jobName = jobName;
- this.options = options;
- }
+ * Print the font styles. Default value is <code>false</code>.
+ */
+ public boolean printTextFontStyle = false;
+ /**
+ * Print the line background color. Default value is <code>false</code>.
+ */
+ public boolean printLineBackground = false;
}