Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Heidrich2003-09-09 21:03:58 +0000
committerFelipe Heidrich2003-09-09 21:03:58 +0000
commit84d7c3d9ff0b39062d650f0956f90676f57ae9e4 (patch)
tree55093cf858e0d72853a2a8d1d515afdf0d846044
parent70a784b179fbea69720ec286ca6c2ce3db492b26 (diff)
downloadeclipse.platform.swt-84d7c3d9ff0b39062d650f0956f90676f57ae9e4.tar.gz
eclipse.platform.swt-84d7c3d9ff0b39062d650f0956f90676f57ae9e4.tar.xz
eclipse.platform.swt-84d7c3d9ff0b39062d650f0956f90676f57ae9e4.zip
back port 40006 & 42724
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DisplayRenderer.java85
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/PrintRenderer.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/BidiUtil.java26
5 files changed, 49 insertions, 84 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DisplayRenderer.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DisplayRenderer.java
index 38aeda8c10..b33d7c812a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DisplayRenderer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DisplayRenderer.java
@@ -11,10 +11,10 @@
package org.eclipse.swt.custom;
-import java.util.*;
+import java.util.Vector;
-import org.eclipse.swt.*;
-import org.eclipse.swt.custom.StyledText.*;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText.LineCache;
import org.eclipse.swt.graphics.*;
/**
@@ -49,7 +49,7 @@ protected void disposeGC(GC gc) {
gc.dispose();
}
/**
- * Draws the background of the line selection.
+ * Draws the line delimiter selection if the selection extends beyond the given line.
* </p>
*
* @param line the line to draw
@@ -61,91 +61,58 @@ protected void disposeGC(GC gc) {
* @param bidi the bidi object to use for measuring and rendering text in bidi
* locales. null when not in bidi mode.
*/
-protected void drawLineSelectionBackground(String line, int lineOffset, StyleRange[] styles, int paintY, GC gc, StyledTextBidi bidi) {
+protected void drawLineBreakSelection(String line, int lineOffset, StyleRange[] styles, int paintY, GC gc, StyledTextBidi bidi) {
Point selection = parent.internalGetSelection();
- LineCache lineCache = parent.internalGetLineCache();
- StyledTextContent content = getContent();
int lineLength = line.length();
int paintX;
- int selectionBackgroundWidth = -1;
int selectionStart = Math.max(0, selection.x - lineOffset);
int selectionEnd = selection.y - lineOffset;
- int selectionLength = selectionEnd - selectionStart;
int horizontalScrollOffset = parent.internalGetHorizontalPixel();
int leftMargin = getLeftMargin();
int lineEndSpaceWidth = getLineEndSpaceWidth();
int lineHeight = getLineHeight();
- boolean wordWrap = parent.internalGetWordWrap();
- boolean isRightOriented = (parent.getStyle() & SWT.MIRRORED) != 0;
- if (selectionEnd == selectionStart || selectionEnd < 0 || selectionStart > lineLength) {
+ if (selectionEnd == selectionStart || selectionEnd < 0 || selectionStart > lineLength || selectionEnd <= lineLength) {
return;
}
if (bidi != null) {
- paintX = parent.getBidiTextPosition(line, selectionStart, bidi);
+ paintX = bidi.getTextWidth();
+ // handle empty line case
+ if (paintX == 0) {
+ paintX = StyledText.XINSET;
+ }
}
else {
- paintX = getTextPosition(line, lineOffset, selectionStart, filterLineStyles(styles), gc);
- }
- // selection extends past end of line?
- if (selectionEnd > lineLength) {
- if ((parent.getStyle() & SWT.FULL_SELECTION) != 0) {
- // use the greater of the client area width and the content
- // width. fixes 1G8IYRD
- selectionBackgroundWidth = Math.max(getClientArea().width, lineCache.getWidth());
- }
- else {
- selectionLength = lineLength - selectionStart;
- }
+ paintX = getTextPosition(line, lineOffset, lineLength, filterLineStyles(styles), gc);
}
gc.setBackground(parent.getSelectionBackground());
gc.setForeground(parent.getSelectionForeground());
- if (selectionBackgroundWidth == -1) {
+ if ((parent.getStyle() & SWT.FULL_SELECTION) != 0) {
+ LineCache lineCache = parent.internalGetLineCache();
+ // use the greater of the client area width and the content
+ // width. fixes 1G8IYRD
+ int selectionBackgroundWidth = Math.max(getClientArea().width, lineCache.getWidth());
+ gc.fillRectangle(paintX - horizontalScrollOffset + leftMargin, paintY, selectionBackgroundWidth, lineHeight);
+ }
+ else {
boolean isWrappedLine = false;
-
- if (wordWrap) {
+ if (parent.internalGetWordWrap()) {
+ StyledTextContent content = getContent();
int lineEnd = lineOffset + lineLength;
int lineIndex = content.getLineAtOffset(lineEnd);
// is the start offset of the next line the same as the end
- // offset of this line?
+ // offset of this line?
if (lineIndex < content.getLineCount() - 1 &&
content.getOffsetAtLine(lineIndex + 1) == lineEnd) {
isWrappedLine = true;
}
}
- if (bidi != null) {
- selectionBackgroundWidth = parent.getBidiTextPosition(line, selectionStart + selectionLength, bidi) - paintX;
- }
- else {
- selectionBackgroundWidth = getTextWidth(line, lineOffset, selectionStart, selectionLength, styles, paintX, gc);
- }
- if (selectionBackgroundWidth < 0) {
- // width can be negative when in R2L bidi segment
- paintX += selectionBackgroundWidth;
- selectionBackgroundWidth *= -1;
- }
- if (selectionEnd > lineLength && isWrappedLine == false) {
- selectionEnd = selectionStart + selectionLength;
- // if the selection extends past this line, render an additional
- // whitespace background at the end of the line to represent the
- // selected line break
- if (bidi != null && selectionEnd > 0 && (bidi.isRightToLeft(selectionEnd - 1) || (isRightOriented && bidi.isRightToLeft(selectionEnd - 1) == false))) {
- int lineEndX = bidi.getTextWidth();
- gc.fillRectangle(lineEndX - horizontalScrollOffset + leftMargin, paintY, lineEndSpaceWidth, lineHeight);
- }
- else {
- selectionBackgroundWidth += lineEndSpaceWidth;
- }
+ if (isWrappedLine == false) {
+ // render the line break selection
+ gc.fillRectangle(paintX - horizontalScrollOffset + leftMargin, paintY, lineEndSpaceWidth, lineHeight);
}
}
- // handle empty line case
- if (bidi != null && paintX == 0) {
- paintX = StyledText.XINSET;
- }
- // fill the background first since expanded tabs are not
- // drawn as spaces. tabs just move the draw position.
- gc.fillRectangle(paintX - horizontalScrollOffset + leftMargin, paintY, selectionBackgroundWidth, lineHeight);
}
/**
* Returns the text segments that should be treated as if they
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/PrintRenderer.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/PrintRenderer.java
index afd492c039..6b834b9b74 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/PrintRenderer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/PrintRenderer.java
@@ -84,7 +84,7 @@ protected void disposeGC(GC gc) {
* Do not print the selection.
* @see StyledTextRenderer#drawLineSelectionBackground
*/
-protected void drawLineSelectionBackground(String line, int lineOffset, StyleRange[] styles, int paintY, GC gc, StyledTextBidi bidi) {
+protected void drawLineBreakSelection(String line, int lineOffset, StyleRange[] styles, int paintY, GC gc, StyledTextBidi bidi) {
}
/**
* Returns from cache the text segments that should be treated as
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 03513c4915..5fbfc91851 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
@@ -6056,12 +6056,7 @@ public void redraw() {
* @see Control#update
*/
public void redraw(int x, int y, int width, int height, boolean all) {
- if (isBidi()) {
- // workaround for bug 4776
- super.redraw(x, y, width + 1, height, all);
- } else {
- super.redraw(x, y, width, height, all);
- }
+ super.redraw(x, y, width, height, all);
if (height > 0) {
int lineCount = content.getLineCount();
int startLine = (getTopPixel() + y) / lineHeight;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java
index d9ee51ec8c..800c03b4ab 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java
@@ -128,12 +128,11 @@ void drawLine(String line, int lineIndex, int paintY, GC gc, Color widgetBackgro
gc.fillRectangle(leftMargin, paintY, getClientArea().width, lineHeight);
}
if (selectionStart != selectionEnd) {
- drawLineSelectionBackground(line, lineOffset, styles, paintY, gc, bidi);
- }
- if (selectionStart != selectionEnd &&
- ((selectionStart >= lineOffset && selectionStart < lineOffset + lineLength) ||
- (selectionStart < lineOffset && selectionEnd > lineOffset))) {
- styles = mergeSelectionLineStyles(styles);
+ drawLineBreakSelection(line, lineOffset, styles, paintY, gc, bidi);
+ if ((selectionStart >= lineOffset && selectionStart < lineOffset + lineLength) ||
+ (selectionStart < lineOffset && selectionEnd > lineOffset)) {
+ styles = mergeSelectionLineStyles(styles);
+ }
}
drawStyledLine(line, lineOffset, 0, styles, 0, paintY, gc, lineBackground, widgetForeground, bidi);
}
@@ -151,7 +150,7 @@ void drawLine(String line, int lineIndex, int paintY, GC gc, Color widgetBackgro
* @param bidi the bidi object to use for measuring and rendering text in bidi
* locales. null when not in bidi mode.
*/
-protected abstract void drawLineSelectionBackground(String line, int lineOffset, StyleRange[] styles, int paintY, GC gc, StyledTextBidi bidi);
+protected abstract void drawLineBreakSelection(String line, int lineOffset, StyleRange[] styles, int paintY, GC gc, StyledTextBidi bidi);
/**
* Draws the line at the specified location.
* </p>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/BidiUtil.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/BidiUtil.java
index 3de536dd9a..27cd786f66 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/BidiUtil.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/BidiUtil.java
@@ -11,13 +11,11 @@
package org.eclipse.swt.internal;
+import java.util.Hashtable;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.internal.win32.GCP_RESULTS;
-import org.eclipse.swt.internal.win32.OS;
-import org.eclipse.swt.internal.win32.RECT;
-import org.eclipse.swt.internal.win32.TCHAR;
-import java.util.Hashtable;
+import org.eclipse.swt.internal.win32.*;
/*
* Wraps Win32 API used to bidi enable the StyledText widget.
*/
@@ -67,6 +65,7 @@ public class BidiUtil {
static final int GCPGLYPH_LINKBEFORE = 0x8000;
static final int GCPGLYPH_LINKAFTER = 0x4000;
// ExtTextOut constants
+ static final int ETO_CLIPPED = 0x4;
static final int ETO_GLYPH_INDEX = 0x0010;
// Windows primary language identifiers
static final int LANG_ARABIC = 0x01;
@@ -104,7 +103,7 @@ public class BidiUtil {
* @param runnable the code that should be executed when a keyboard language change
* occurs
*/
-public static void addLanguageListener(int hwnd, Runnable runnable) {
+public static void addLanguageListener (int hwnd, Runnable runnable) {
languageMap.put(new Integer(hwnd), runnable);
subclass(hwnd);
}
@@ -133,12 +132,17 @@ static int EnumSystemLanguageGroupsProc(int lpLangGrpId, int lpLangGrpIdString,
* @param y y position to start rendering
*/
public static void drawGlyphs(GC gc, char[] renderBuffer, int[] renderDx, int x, int y) {
- RECT rect = null;
+ int length = renderDx.length;
+
if (OS.GetLayout (gc.handle) != 0) {
reverse(renderDx);
+ renderDx[length-1]--; //fixes bug 40006
reverse(renderBuffer);
- }
- OS.ExtTextOutW(gc.handle, x, y, ETO_GLYPH_INDEX, rect, renderBuffer, renderBuffer.length, renderDx);
+ }
+ // render transparently to avoid overlapping segments. fixes bug 40006
+ int oldBkMode = OS.SetBkMode(gc.handle, OS.TRANSPARENT);
+ OS.ExtTextOutW(gc.handle, x, y, ETO_GLYPH_INDEX , null, renderBuffer, renderBuffer.length, renderDx);
+ OS.SetBkMode(gc.handle, oldBkMode);
}
/**
* Return ordering and rendering information for the given text. Wraps the GetFontLanguageInfo
@@ -478,7 +482,7 @@ public static boolean isKeyboardBidi() {
*
* @param hwnd the handle of the Control that is listening for keyboard language changes
*/
-public static void removeLanguageListener(int hwnd) {
+public static void removeLanguageListener (int hwnd) {
languageMap.remove(new Integer(hwnd));
unsubclass(hwnd);
}
@@ -630,7 +634,7 @@ static int windowProc (int hwnd, int msg, int wParam, int lParam) {
Runnable runnable = (Runnable) languageMap.get (key);
if (runnable != null) runnable.run ();
break;
- }
+ }
Integer oldProc = (Integer)oldProcMap.get(key);
return OS.CallWindowProc (oldProc.intValue(), hwnd, msg, wParam, lParam);
}

Back to the top