Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeronika Irvine2002-04-01 15:55:16 +0000
committerVeronika Irvine2002-04-01 15:55:16 +0000
commit26c313b27e519ff6cadcf58e3a1d510e4b77f91c (patch)
treeadd0a8b0c3e9a05ebe4d041a23751bc914ccb85f
parent788ef97f1cb02796ff15e391a570cd7ca6b3261f (diff)
downloadeclipse.platform.swt-26c313b27e519ff6cadcf58e3a1d510e4b77f91c.tar.gz
eclipse.platform.swt-26c313b27e519ff6cadcf58e3a1d510e4b77f91c.tar.xz
eclipse.platform.swt-26c313b27e519ff6cadcf58e3a1d510e4b77f91c.zip
*** empty log message ***v2032_fragments
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java1694
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextPrinter.java373
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/WrappedContent.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/common_j2me/org/eclipse/swt/internal/Library.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/common_j2se/org/eclipse/swt/internal/Library.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/eclipsefixed.h2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/structs.c30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gdk.c73
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtklists.c10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkmenu.c15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkwidget.c329
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkwindow.c6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-pango.c119
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt.c72
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkText.java29
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java160
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/make_aix.mak18
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.c54
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.h17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IAccessible.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/REBARBANDINFO.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/library/make_common.mak4
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/version.txt2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolBar.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/emulated/tabfolder/org/eclipse/swt/widgets/TabFolder.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Cursor.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java113
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Font.java116
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontData.java338
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontMetrics.java20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java226
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GCData.java3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java62
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java45
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java213
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java136
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java350
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java526
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java267
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java26
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java117
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java65
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java52
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java200
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java209
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java91
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java333
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java175
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java202
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java469
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java157
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java95
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java50
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java190
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java172
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Trim.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/UtilFuncs.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java58
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/DirectoryDialog.java1
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java41
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java5
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java28
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java54
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DirectoryDialog.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java4
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java4
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java7
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java4
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java4
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java36
-rwxr-xr-xbundles/org.eclipse.swt/buildnotes_swt.html32
-rwxr-xr-xbundles/org.eclipse.swt/readme_swt.html28
84 files changed, 3867 insertions, 4702 deletions
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 8c8e3716ca..8ad3af58ef 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
@@ -86,6 +86,7 @@ public class StyledText extends Canvas {
StyledTextContent logicalContent; // native content (default or user specified)
StyledTextContent content; // line wrapping content, same as logicalContent if word wrap is off
+ DisplayRenderer renderer;
TextChangeListener textChangeListener; // listener for TextChanging, TextChanged and TextSet events from StyledTextContent
DefaultLineStyler defaultLineStyler;// used for setStyles API when no LineStyleListener is registered
LineCache lineCache;
@@ -100,7 +101,6 @@ public class StyledText extends Canvas {
// if line wrap needs to be recalculated
int lineHeight; // line height=font height
int tabLength = 4; // number of characters in a tab
- int tabWidth; // width of a tab character in the current GC
int lineEndSpaceWidth; // space, in pixel, used to indicated a selected line break
int leftMargin = 1;
int topMargin = 1;
@@ -117,8 +117,6 @@ public class StyledText extends Canvas {
boolean overwrite = false; // insert/overwrite edit mode
int textLimit = -1; // limits the number of characters the user can type in the widget. Unlimited by default.
Hashtable keyActionMap = new Hashtable();
- Font boldFont;
- Font regularFont;
Color background = null; // workaround for bug 4791
Color foreground = null; //
Clipboard clipboard;
@@ -129,7 +127,6 @@ public class StyledText extends Canvas {
int lastTextChangeNewCharCount; // event for use in the
int lastTextChangeReplaceLineCount; // text changed handler
int lastTextChangeReplaceCharCount;
-
boolean isBidi;
boolean bidiColoring = false; // apply the BIDI algorithm on text segments of the same color
Image leftCaretBitmap = null;
@@ -138,10 +135,286 @@ public class StyledText extends Canvas {
PaletteData caretPalette = null;
int lastCaretDirection = SWT.NULL;
- //TEMPORARY CODE
- Runnable updater = null;
+ // optimization flag for non-Windows platforms
+ boolean drawDirect = false;
/**
+ * The Printing class implements printing of a range of text.
+ * An instance of <class>Printing </class> is returned in the
+ * StyledText#print(Printer) API. The run() method may be
+ * invoked from any thread.
+ */
+ class Printing implements Runnable {
+ Printer printer;
+ PrintRenderer renderer;
+ StyledTextContent printerContent; // copy of the widget content
+ Rectangle clientArea; // client area to print on
+ Font printerFont;
+ FontData displayFontData;
+ Hashtable printerColors; // printer color cache for line backgrounds and style
+ Hashtable lineBackgrounds = new Hashtable(); // cached line backgrounds
+ Hashtable lineStyles = new Hashtable(); // cached line styles
+ Hashtable bidiSegments = new Hashtable(); // cached bidi segments when running on a bidi platform
+ GC gc; // printer GC
+ int startPage; // first page to print
+ int endPage; // last page to print
+ int pageSize; // number of lines on a page
+ int startLine; // first (wrapped) line to print
+ int endLine; // last (wrapped) line to print
+ boolean singleLine; // widget single line mode
+
+ /**
+ * Creates an instance of <class>Printing</class>.
+ * Copies the widget content and rendering data that needs
+ * to be requested from listeners.
+ * </p>
+ * @param parent StyledText widget to print.
+ * @param printer printer device to print on.
+ */
+ Printing(StyledText parent, Printer printer) {
+ PrinterData data = printer.getPrinterData();
+
+ this.printer = printer;
+ singleLine = parent.isSingleLine();
+ startPage = 1;
+ endPage = Integer.MAX_VALUE;
+ if (data.scope == PrinterData.PAGE_RANGE) {
+ startPage = data.startPage;
+ endPage = data.endPage;
+ }
+ displayFontData = getFont().getFontData()[0];
+ copyContent(parent.getContent());
+ cacheLineData(printerContent);
+ }
+ /**
+ * Caches the bidi segments of the given line.
+ * </p>
+ * @param lineOffset offset of the line to cache bidi segments for.
+ * Relative to the start of the document.
+ * @param line line to cache bidi segments for.
+ */
+ void cacheBidiSegments(int lineOffset, String line) {
+ int[] segments = getBidiSegments(lineOffset, line);
+
+ if (segments != null) {
+ bidiSegments.put(new Integer(lineOffset), segments);
+ }
+ }
+ /**
+ * Caches the line background color of the given line.
+ * </p>
+ * @param lineOffset offset of the line to cache the background
+ * color for. Relative to the start of the document.
+ * @param line line to cache the background color for
+ */
+ void cacheLineBackground(int lineOffset, String line) {
+ StyledTextEvent event = getLineBackgroundData(lineOffset, line);
+
+ if (event != null) {
+ lineBackgrounds.put(new Integer(lineOffset), event);
+ }
+ }
+ /**
+ * Caches all line data that needs to be requested from a listener.
+ * </p>
+ * @param printerContent <class>StyledTextContent</class> to request
+ * line data for.
+ */
+ void cacheLineData(StyledTextContent printerContent) {
+ for (int i = 0; i < printerContent.getLineCount(); i++) {
+ int lineOffset = printerContent.getOffsetAtLine(i);
+ String line = printerContent.getLine(i);
+
+ cacheLineBackground(lineOffset, line);
+ cacheLineStyle(lineOffset, line);
+ if (isBidi()) {
+ cacheBidiSegments(lineOffset, line);
+ }
+ }
+ }
+ /**
+ * Caches all line styles of the given line.
+ * </p>
+ * @param lineOffset offset of the line to cache the styles for.
+ * Relative to the start of the document.
+ * @param line line to cache the styles for.
+ */
+ void cacheLineStyle(int lineOffset, String line) {
+ StyledTextEvent event = getLineStyleData(lineOffset, line);
+
+ if (event != null) {
+ lineStyles.put(new Integer(lineOffset), event);
+ }
+ }
+ /**
+ * Copies the text of the specified <class>StyledTextContent</class>.
+ * </p>
+ * @param original the <class>StyledTextContent</class> to copy.
+ */
+ void copyContent(StyledTextContent original) {
+ int lineCount = original.getLineCount();
+ int insertOffset = 0;
+ printerContent = new DefaultContent();
+ for (int i = 0; i < original.getLineCount(); i++) {
+ int insertEndOffset;
+ if (i < original.getLineCount() - 1) {
+ insertEndOffset = original.getOffsetAtLine(i + 1);
+ }
+ else {
+ insertEndOffset = original.getCharCount();
+ }
+ printerContent.replaceTextRange(insertOffset, 0, original.getTextRange(insertOffset, insertEndOffset - insertOffset));
+ insertOffset = insertEndOffset;
+ }
+ }
+ /**
+ * Disposes of the resources and the <class>PrintRenderer</class>.
+ */
+ void dispose() {
+ if (printerColors != null) {
+ Iterator colors = printerColors.values().iterator();
+
+ while (colors.hasNext()) {
+ Color color = (Color) colors.next();
+ color.dispose();
+ }
+ printerColors = null;
+ }
+ if (gc != null) {
+ gc.dispose();
+ gc = null;
+ }
+ if (printerFont != null) {
+ printerFont.dispose();
+ printerFont = null;
+ }
+ if (renderer != null) {
+ renderer.dispose();
+ renderer = null;
+ }
+ }
+ /**
+ * Creates a <class>PrintRenderer</class> and calculate the line range
+ * to print.
+ */
+ void initializeRenderer() {
+ Rectangle trim = printer.computeTrim(0, 0, 0, 0);
+ Point dpi = printer.getDPI();
+
+ printerFont = new Font(printer, displayFontData.getName(), displayFontData.getHeight(), SWT.NORMAL);
+ clientArea = printer.getClientArea();
+ // one inch margin around text
+ clientArea.x = dpi.x + trim.x;
+ clientArea.y = dpi.y + trim.y;
+ clientArea.width -= (clientArea.x + trim.width);
+ clientArea.height -= (clientArea.y + trim.height);
+
+ gc = new GC(printer);
+ gc.setFont(printerFont);
+ renderer = new PrintRenderer(
+ printer, printerFont, isBidi(), gc, printerContent,
+ lineBackgrounds, lineStyles, bidiSegments,
+ tabLength, clientArea);
+ pageSize = clientArea.height / renderer.getLineHeight();
+ startLine = (startPage - 1) * pageSize;
+ endLine = Math.max(Integer.MAX_VALUE, endPage * pageSize);
+ }
+ /**
+ * Returns the printer color for the given display color.
+ * </p>
+ * @param color display color
+ * @return color create on the printer with the same RGB values
+ * as the display color.
+ */
+ Color getPrinterColor(Color color) {
+ Color printerColor = null;
+
+ if (color != null) {
+ printerColor = (Color) printerColors.get(color);
+ if (printerColor == null) {
+ printerColor = new Color(printer, color.getRGB());
+ printerColors.put(color, printerColor);
+ }
+ }
+ return printerColor;
+ }
+ /**
+ * Replaces all display colors in the cached line backgrounds and
+ * line styles with printer colors.
+ */
+ void createPrinterColors() {
+ Iterator values = lineBackgrounds.values().iterator();
+ printerColors = new Hashtable();
+ while (values.hasNext()) {
+ StyledTextEvent event = (StyledTextEvent) values.next();
+ event.lineBackground = getPrinterColor(event.lineBackground);
+ }
+
+ values = lineStyles.values().iterator();
+ while (values.hasNext()) {
+ StyledTextEvent event = (StyledTextEvent) values.next();
+ for (int i = 0; i < event.styles.length; i++) {
+ StyleRange style = event.styles[i];
+ Color printerBackground = getPrinterColor(style.background);
+ Color printerForeground = getPrinterColor(style.foreground);
+
+ if (printerBackground != style.background ||
+ printerForeground != style.foreground) {
+ style = (StyleRange) style.clone();
+ style.background = printerBackground;
+ style.foreground = printerForeground;
+ event.styles[i] = style;
+ }
+ }
+ }
+ }
+ /**
+ * Starts a print job and prints the pages specified in the constructor.
+ */
+ public void run() {
+ if (printer.startJob("Printing")) {
+ createPrinterColors();
+ initializeRenderer();
+ print();
+ dispose();
+ printer.endJob();
+ }
+ }
+ /**
+ * Prints the lines in the specified page range.
+ */
+ void print() {
+ StyledTextContent content = renderer.getContent();
+ FontData printerFontData = gc.getFont().getFontData()[0];
+ Color background = gc.getBackground();
+ Color foreground = gc.getForeground();
+ int lineHeight = renderer.getLineHeight();
+ int lineCount = content.getLineCount();
+ int paintY = clientArea.y;
+
+ if (singleLine) {
+ lineCount = 1;
+ }
+ if (startPage == 1) {
+ printer.startPage();
+ }
+ for (int i = startLine; i < lineCount && i < endLine; i++, paintY += lineHeight) {
+ String line = content.getLine(i);
+
+ if (paintY + lineHeight > clientArea.y + clientArea.height) {
+ printer.endPage();
+ printer.startPage();
+ paintY = clientArea.y;
+ }
+ renderer.drawLine(
+ line, i, paintY, gc, background, foreground, printerFontData, true);
+ }
+ if (paintY > clientArea.y && paintY <= clientArea.y + clientArea.height) {
+ printer.endPage();
+ }
+ }
+ }
+ /**
* The <code>RTFWriter</code> class is used to write widget content as
* rich text. The implementation complies with the RTF specification
* version 1.5.
@@ -272,11 +545,11 @@ public class StyledText extends Canvas {
if (isClosed()) {
SWT.error(SWT.ERROR_IO);
}
- event = getLineStyleData(lineOffset, line);
+ event = renderer.getLineStyleData(lineOffset, line);
if (event != null) {
styles = event.styles;
}
- event = getLineBackgroundData(lineOffset, line);
+ event = renderer.getLineBackgroundData(lineOffset, line);
if (event != null) {
lineBackground = event.lineBackground;
}
@@ -592,7 +865,6 @@ public class StyledText extends Canvas {
write(lineDelimiter);
}
}
-
/**
* LineCache provides an interface to calculate and invalidate
* line based data.
@@ -754,15 +1026,14 @@ public class StyledText extends Canvas {
width = bidi.getTextWidth();
}
else {
- StyledTextEvent event = getLineStyleData(lineOffset, line);
+ StyledTextEvent event = renderer.getLineStyleData(lineOffset, line);
StyleRange[] styles = null;
-
if (event != null) {
- styles = filterLineStyles(event.styles);
+ styles = renderer.filterLineStyles(event.styles);
}
- width = textWidth(line, lineOffset, 0, line.length(), styles, 0, gc, currentFont);
+ width = renderer.textWidth(line, lineOffset, 0, line.length(), styles, 0, gc, currentFont);
}
- return width;
+ return width + leftMargin;
}
/**
* Grows the <code>lineWidth</code> array to accomodate new line width
@@ -899,7 +1170,6 @@ public class StyledText extends Canvas {
public void textChanged(int startOffset, int newLineCount, int replaceLineCount, int newCharCount, int replaceCharCount) {
int startLine = parent.getLineAtOffset(startOffset);
boolean removedMaxLine = (maxWidthLineIndex > startLine && maxWidthLineIndex <= startLine + replaceLineCount);
-
// entire text deleted?
if (startLine == 0 && replaceLineCount == lineCount) {
lineCount = newLineCount;
@@ -933,7 +1203,6 @@ public class StyledText extends Canvas {
}
}
}
-
/**
* Updates the line wrapping of the content.
* The line wrapping must always be in a consistent state.
@@ -1048,20 +1317,19 @@ public class StyledText extends Canvas {
parent.internalRedraw();
}
}
-
public StyledText(Composite parent, int style) {
super(parent, checkStyle(style | SWT.NO_REDRAW_RESIZE | SWT.NO_BACKGROUND));
Display display = getDisplay();
isBidi = StyledTextBidi.isBidiPlatform();
-
if ((style & SWT.READ_ONLY) != 0) {
setEditable(false);
}
+ if ((style & SWT.BORDER) == 0 || (style & SWT.SINGLE) == 0) {
+ leftMargin = topMargin = rightMargin = bottomMargin = 0;
+ }
clipboard = new Clipboard(display);
- calculateLineHeight();
- calculateTabWidth();
installDefaultContent();
- initializeFonts();
+ initializeRenderer();
if ((style & SWT.WRAP) != 0) {
setWordWrap(true);
}
@@ -1085,9 +1353,6 @@ public StyledText(Composite parent, int style) {
};
StyledTextBidi.addLanguageListener(this, runnable);
}
- if ((style & SWT.BORDER) == 0 || (style & SWT.SINGLE) == 0) {
- leftMargin = topMargin = rightMargin = bottomMargin = 0;
- }
// set the caret width, the height of the caret will default to the line height
calculateScrollBars();
createKeyBindings();
@@ -1337,32 +1602,6 @@ public void append(String string) {
replaceTextRange(lastChar, 0, string);
}
/**
- * Returns the width of the specified text.
- * <p>
- *
- * @param text text to be measured.
- * @param startOffset offset of the character to start measuring and
- * expand tabs.
- * @param length number of characters to measure. Tabs are counted
- * as one character in this parameter.
- * @param startXOffset x position of "startOffset" in "text". Used for
- * calculating tab stops
- * @param bidi the bidi object to use for measuring text in bidi locales.
- * @return width of the text with tabs expanded to tab stops or 0 if the
- * startOffset or length is outside the specified text.
- */
-int bidiTextWidth(String text, int startOffset, int length, int startXOffset, StyledTextBidi bidi) {
- int endOffset = startOffset + length;
- int textLength = text.length();
-
- if (startOffset < 0 || startOffset >= textLength || endOffset > textLength) {
- return 0;
- }
- // Use lastCaretDirection in order to get same results as during
- // caret positioning (setBidiCaretLocation). Fixes 1GKU4C5.
- return bidi.getCaretPosition(endOffset, lastCaretDirection) - startXOffset;
-}
-/**
* Calculates the width of the widest visible line.
*/
void calculateContentWidth() {
@@ -1372,27 +1611,6 @@ void calculateContentWidth() {
}
}
/**
- * Calculates the line height
- */
-void calculateLineHeight() {
- GC gc = new GC(this);
- lineHeight = gc.getFontMetrics().getHeight();
- gc.dispose();
-}
-/**
- * Calculates the width in pixel of a tab character
- */
-void calculateTabWidth() {
- StringBuffer tabBuffer = new StringBuffer(tabLength);
- GC gc = new GC(this);
-
- for (int i = 0; i < tabLength; i++) {
- tabBuffer.append(' ');
- }
- tabWidth = gc.stringExtent(tabBuffer.toString()).x;
- gc.dispose();
-}
-/**
* Calculates the scroll bars
*/
void calculateScrollBars() {
@@ -1567,7 +1785,6 @@ public void copy(){
TextWriter plainTextWriter = new TextWriter(selection.x, length);
String rtfText = getPlatformDelimitedText(rtfWriter);
String plainText = getPlatformDelimitedText(plainTextWriter);
-
try {
clipboard.setContents(
new String[]{rtfText, plainText},
@@ -1660,7 +1877,6 @@ void createKeyBindings() {
setKeyBinding(SWT.END | SWT.CTRL, ST.TEXT_END);
setKeyBinding(SWT.PAGE_UP | SWT.CTRL, ST.WINDOW_START);
setKeyBinding(SWT.PAGE_DOWN | SWT.CTRL, ST.WINDOW_END);
-
// Selection
setKeyBinding(SWT.ARROW_UP | SWT.SHIFT, ST.SELECT_LINE_UP);
setKeyBinding(SWT.ARROW_DOWN | SWT.SHIFT, ST.SELECT_LINE_DOWN);
@@ -1676,7 +1892,6 @@ void createKeyBindings() {
setKeyBinding(SWT.END | SWT.CTRL | SWT.SHIFT, ST.SELECT_TEXT_END);
setKeyBinding(SWT.PAGE_UP | SWT.CTRL | SWT.SHIFT, ST.SELECT_WINDOW_START);
setKeyBinding(SWT.PAGE_DOWN | SWT.CTRL | SWT.SHIFT, ST.SELECT_WINDOW_END);
-
// Modification
// Cut, Copy, Paste
// CUA style
@@ -1687,7 +1902,6 @@ void createKeyBindings() {
setKeyBinding(SWT.DEL | SWT.SHIFT, ST.CUT);
setKeyBinding(SWT.INSERT | SWT.CTRL, ST.COPY);
setKeyBinding(SWT.INSERT | SWT.SHIFT, ST.PASTE);
-
setKeyBinding(SWT.BS | SWT.SHIFT, ST.DELETE_PREVIOUS);
setKeyBinding(SWT.BS, ST.DELETE_PREVIOUS);
setKeyBinding(SWT.DEL, ST.DELETE_NEXT);
@@ -1704,7 +1918,6 @@ void createBidiCaret() {
if (caret == null) {
caret = new Caret(this, SWT.NULL);
}
-
int direction = StyledTextBidi.getKeyboardLanguageDirection();
if (direction == caretDirection) {
return;
@@ -1734,7 +1947,6 @@ void createCaretBitmaps() {
leftCaretBitmap.dispose();
}
ImageData imageData = new ImageData(caretWidth, lineHeight, 1, caretPalette);
-
leftCaretBitmap = new Image(display, imageData);
GC gc = new GC (leftCaretBitmap);
gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
@@ -1787,7 +1999,7 @@ void doAutoScroll(Event event) {
doAutoScroll(SWT.UP);
}
else
- if (event.x < 0 && wordWrap == false) {
+ if (event.x < leftMargin && wordWrap == false) {
doAutoScroll(SWT.LEFT);
}
else
@@ -1868,7 +2080,6 @@ void doAutoScroll(int direction) {
*/
void doBackspace() {
Event event = new Event();
-
event.text = "";
if (selection.x != selection.y) {
event.start = selection.x;
@@ -2048,7 +2259,7 @@ void doColumnRight() {
if (isBidi()) {
GC gc = new GC(this);
StyledTextBidi bidi = getStyledTextBidi(lineText, lineOffset, gc);
- if (bidi.getTextWidth() > horizontalScrollOffset + getClientArea().width ||
+ if (bidi.getTextWidth() + leftMargin > horizontalScrollOffset + getClientArea().width ||
offsetInLine < lineLength) {
if (bidi.isRightToLeft(offsetInLine) == false &&
offsetInLine < lineLength) {
@@ -2069,7 +2280,7 @@ void doColumnRight() {
else
if (offsetInLine > 0 &&
(bidi.isRightToLeft(offsetInLine) ||
- bidi.getTextWidth() > horizontalScrollOffset + getClientArea().width ||
+ bidi.getTextWidth() + leftMargin > horizontalScrollOffset + getClientArea().width ||
offsetInLine < lineLength)) {
// advance caret visually if in R2L segment or logically at line end
// but right end of line is not fully visible yet
@@ -2112,14 +2323,14 @@ void doColumnRight() {
if (offsetInLine > 0 && offsetInLine < lineLength - 1) {
int clientAreaEnd = horizontalScrollOffset + getClientArea().width;
boolean directionChange = bidi.isRightToLeft(offsetInLine - 1) == false && bidi.isRightToLeft(offsetInLine);
- int textWidth = bidi.getTextWidth();
+ int textWidth = bidi.getTextWidth() + leftMargin;
// between L2R and R2L segment and second character of R2L segment is
// left of right border and logical line end is left of right border
// but visual line end is not left of right border
if (directionChange &&
bidi.isRightToLeft(offsetInLine + 1) &&
- bidi.getCaretPosition(offsetInLine + 1) < clientAreaEnd &&
- bidi.getCaretPosition(lineLength) < clientAreaEnd && textWidth > clientAreaEnd) {
+ bidi.getCaretPosition(offsetInLine + 1) + leftMargin < clientAreaEnd &&
+ bidi.getCaretPosition(lineLength) + leftMargin < clientAreaEnd && textWidth > clientAreaEnd) {
// make visual line end visible
scrollHorizontalBar(textWidth - clientAreaEnd);
}
@@ -2250,7 +2461,6 @@ void doCursorNext() {
*/
void doDelete() {
Event event = new Event();
-
event.text = "";
if (selection.x != selection.y) {
event.start = selection.x;
@@ -2308,7 +2518,6 @@ void doLineEnd() {
void doLineStart() {
int line = content.getLineAtOffset(caretOffset);
int lineOffset = content.getOffsetAtLine(line);
-
if (caretOffset > lineOffset && line == caretLine) {
caretOffset = lineOffset;
showCaret();
@@ -2332,7 +2541,6 @@ void doLineUp() {
int lineOffset = content.getOffsetAtLine(line);
int offsetInLine = caretOffset - lineOffset;
int caretX = getXAtOffset(lineText, line, offsetInLine);
-
caretLine = --line;
if (isBidi()) {
caretOffset = getBidiOffsetAtMouseLocation(caretX, line);
@@ -2482,7 +2690,6 @@ void doPageStart() {
*/
void doPageUp() {
int line = content.getLineAtOffset(caretOffset);
-
if (line > 0) {
int offsetInLine = caretOffset - content.getOffsetAtLine(line);
int scrollLines = Math.max(1, Math.min(line, getLineCountWhole()));
@@ -2723,14 +2930,14 @@ void doWordPrevious() {
*/
void draw(int x, int y, int width, int height, boolean clearBackground) {
if (clearBackground) {
- redraw(x, y, width, height, true);
+ redraw(x + leftMargin, y + topMargin, width, height, true);
}
else {
int startLine = (y + verticalScrollOffset) / lineHeight;
int endY = y + height;
int paintYFromTopLine = (startLine - topIndex) * lineHeight;
int topLineOffset = (topIndex * lineHeight - verticalScrollOffset);
- int paintY = paintYFromTopLine + topLineOffset; // adjust y position for pixel based scrolling
+ int paintY = paintYFromTopLine + topLineOffset + topMargin; // adjust y position for pixel based scrolling
int lineCount = content.getLineCount();
Color background = getBackground();
Color foreground = getForeground();
@@ -2745,348 +2952,17 @@ void draw(int x, int y, int width, int height, boolean clearBackground) {
}
for (int i = startLine; paintY < endY && i < lineCount; i++, paintY += lineHeight) {
String line = content.getLine(i);
- drawLine(line, i, paintY, gc, background, foreground, fontData, clearBackground);
+ renderer.drawLine(line, i, paintY, gc, background, foreground, fontData, clearBackground);
}
gc.dispose();
}
}
/**
- * Draws a line of text at the specified location.
- * <p>
- *
- * @param line the line to draw
- * @param lineIndex index of the line to draw
- * @param paintY y location to draw at
- * @param gc GC to draw on
- * @param widgetBackground the widget background color.
- * Used as the default rendering color.
- * @param widgetForeground the widget foreground color.
- * Used as the default rendering color.
- * @param currentFont the font currently set in gc. Cached for better performance.
- */
-void drawLine(String line, int lineIndex, int paintY, GC gc, Color widgetBackground, Color widgetForeground, FontData currentFont, boolean clearBackground) {
- int lineOffset = content.getOffsetAtLine(lineIndex);
- int lineLength = line.length();
- int selectionStart = selection.x;
- int selectionEnd = selection.y;
- StyleRange[] styles = new StyleRange[0];
- Color lineBackground = null;
- StyledTextEvent event = getLineStyleData(lineOffset, line);
- StyledTextBidi bidi = null;
-
- if (event != null) {
- styles = event.styles;
- }
- if (isBidi()) {
- setLineFont(gc, currentFont, SWT.NORMAL);
- bidi = getStyledTextBidi(line, lineOffset, gc, styles);
- }
- event = getLineBackgroundData(lineOffset, line);
- if (event != null) {
- lineBackground = event.lineBackground;
- }
- if (lineBackground == null) {
- lineBackground = widgetBackground;
- }
- if (clearBackground &&
- ((getStyle() & SWT.FULL_SELECTION) == 0 ||
- selectionStart > lineOffset ||
- selectionEnd <= lineOffset + lineLength)) {
- // draw background if full selection is off or if line is not
- // completely selected
- gc.setBackground(lineBackground);
- gc.setForeground(lineBackground);
- gc.fillRectangle(0, paintY, getClientArea().width, lineHeight);
- }
- if (selectionStart != selectionEnd) {
- drawLineSelectionBackground(line, lineOffset, styles, paintY, gc, currentFont, bidi);
- }
- if (selectionStart != selectionEnd &&
- ((selectionStart >= lineOffset && selectionStart < lineOffset + lineLength) ||
- (selectionStart < lineOffset && selectionEnd > lineOffset))) {
- styles = getSelectionLineStyles(styles);
- }
- if (isBidi()) {
- int paintX = bidiTextWidth(line, 0, 0, 0, bidi);
- drawStyledLine(line, lineOffset, 0, styles, paintX, paintY, gc, lineBackground, widgetForeground, currentFont, bidi);
- }
- else {
- drawStyledLine(line, lineOffset, 0, styles, 0, paintY, gc, lineBackground, widgetForeground, currentFont, bidi);
- }
-}
-/**
- * Draws the background of the line selection.
- * <p>
- *
- * @param line the line to draw
- * @param lineOffset offset of the first character in the line.
- * Relative to the start of the document.
- * @param styles line styles
- * @param paintY y location to draw at
- * @param gc GC to draw on
- * @param currentFont the font currently set in gc. Cached for
- * better performance.
- * @param bidi the bidi object to use for measuring and rendering
- * text in bidi locales. null when not in bidi mode.
- */
-void drawLineSelectionBackground(String line, int lineOffset, StyleRange[] styles, int paintY, GC gc, FontData currentFont, StyledTextBidi bidi) {
- 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;
-
- if (selectionEnd == selectionStart || selectionEnd < 0 || selectionStart > lineLength) {
- return;
- }
- if (bidi != null) {
- paintX = bidiTextWidth(line, 0, selectionStart, 0, bidi);
- }
- else {
- paintX = textWidth(line, lineOffset, 0, selectionStart, filterLineStyles(styles), 0, gc, currentFont);
- }
- // selection extends past end of line?
- if (selectionEnd > lineLength) {
- if ((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;
- }
- }
- gc.setBackground(getSelectionBackground());
- gc.setForeground(getSelectionForeground());
- if (selectionBackgroundWidth == -1) {
- boolean isWrappedLine = false;
-
- if (wordWrap) {
- 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?
- if (lineIndex < content.getLineCount() - 1 &&
- content.getOffsetAtLine(lineIndex + 1) == lineEnd) {
- isWrappedLine = true;
- }
- }
- if (bidi != null) {
- selectionBackgroundWidth = bidiTextWidth(line, selectionStart, selectionLength, paintX, bidi);
- }
- else {
- selectionBackgroundWidth = textWidth(line, lineOffset, selectionStart, selectionLength, styles, paintX, gc, currentFont);
- }
- 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)) {
- int lineEndX = bidi.getTextWidth();
- gc.fillRectangle(lineEndX - horizontalScrollOffset, paintY, lineEndSpaceWidth, lineHeight);
- }
- else {
- selectionBackgroundWidth += lineEndSpaceWidth;
- }
- }
- }
- // handle empty line case
- if (bidi != null && (paintX == 0)) {
- paintX = XINSET;
- }
- // fill the background first since expanded tabs are not
- // drawn as spaces. tabs just move the draw position.
- gc.fillRectangle(paintX - horizontalScrollOffset, paintY, selectionBackgroundWidth, lineHeight);
-}
-/**
- * Draws the line at the specified location.
- * <p>
- *
- * @param line the line to draw
- * @param lineOffset offset of the first character in the line.
- * Relative to the start of the document.
- * @param renderOffset offset of the first character that should
- * be rendered. Relative to the start of the line.
- * @param styles the styles to use for rendering line segments.
- * May be empty but not null.
- * @param paintX x location to draw at, not used in bidi mode
- * @param paintY y location to draw at
- * @param gc GC to draw on
- * @param lineBackground line background color, used when no style
- * is specified for a line segment.
- * @param lineForeground line foreground color, used when no style
- * is specified for a line segment.
- * @param currentFont the font currently set in gc. Cached for better
- * performance.
- * @param bidi the bidi object to use for measuring and rendering
- * text in bidi locales. null when not in bidi mode.
- */
-void drawStyledLine(String line, int lineOffset, int renderOffset, StyleRange[] styles, int paintX, int paintY, GC gc, Color lineBackground, Color lineForeground, FontData currentFont, StyledTextBidi bidi) {
- int lineLength = line.length();
- Color background = gc.getBackground();
- Color foreground = gc.getForeground();
- StyleRange style = null;
- StyleRange[] filteredStyles = filterLineStyles(styles);
- int renderStopX = getClientArea().width + horizontalScrollOffset;
-
- // Always render the entire line when in a bidi locale.
- // Since we render the line in logical order we may start past the end
- // of the visual right border of the client area and work towards the
- // left.
- for (int i = 0; i < styles.length && (paintX < renderStopX || bidi != null); i++) {
- int styleLineLength;
- int styleLineStart;
- int styleLineEnd;
- style = styles[i];
- styleLineEnd = style.start + style.length - lineOffset;
- styleLineStart = Math.max(style.start - lineOffset, 0);
- // render unstyled text between the start of the current
- // style range and the end of the previously rendered
- // style range
- if (styleLineStart > renderOffset) {
- background = setLineBackground(gc, background, lineBackground);
- foreground = setLineForeground(gc, foreground, lineForeground);
- setLineFont(gc, currentFont, SWT.NORMAL);
- // don't try to render more text than requested
- styleLineStart = Math.min(lineLength, styleLineStart);
- paintX = drawText(line, renderOffset, styleLineStart - renderOffset, paintX, paintY, gc, bidi);
- renderOffset = styleLineStart;
- }
- else
- if (styleLineEnd <= renderOffset) {
- // style ends before render start offset
- // skip to the next style
- continue;
- }
- if (styleLineStart >= lineLength) {
- // there are line styles but no text for those styles
- // possible when called with partial line text
- break;
- }
- styleLineLength = Math.min(styleLineEnd, lineLength) - renderOffset;
- // set style background color if specified
- if (style.background != null) {
- background = setLineBackground(gc, background, style.background);
- foreground = setLineForeground(gc, foreground, style.background);
- if (bidi != null) {
- bidi.fillBackground(renderOffset, styleLineLength, -horizontalScrollOffset, paintY, lineHeight);
- }
- else {
- int fillWidth = textWidth(line, lineOffset, renderOffset, styleLineLength, filteredStyles, paintX, gc, currentFont);
- gc.fillRectangle(paintX - horizontalScrollOffset, paintY, fillWidth, lineHeight);
- }
- }
- else {
- background = setLineBackground(gc, background, lineBackground);
- }
- // set style foreground color if specified
- if (style.foreground != null) {
- foreground = setLineForeground(gc, foreground, style.foreground);
- }
- else {
- foreground = setLineForeground(gc, foreground, lineForeground);
- }
- setLineFont(gc, currentFont, style.fontStyle);
- paintX = drawText(line, renderOffset, styleLineLength, paintX, paintY, gc, bidi);
- renderOffset += styleLineLength;
- }
- // render unstyled text at the end of the line
- if ((style == null || renderOffset < lineLength) &&
- (paintX < renderStopX || bidi != null)) {
- setLineBackground(gc, background, lineBackground);
- setLineForeground(gc, foreground, lineForeground);
- setLineFont(gc, currentFont, SWT.NORMAL);
- drawText(line, renderOffset, lineLength - renderOffset, paintX, paintY, gc, bidi);
- }
-}
-/**
- * Draws the text at the specified location. Expands tabs to tab
- * stops using the widget tab width.
- * <p>
- *
- * @param text text to draw
- * @param startOffset offset of the first character in text to draw
- * @param length number of characters to draw
- * @param paintX x location to start drawing at, not used in bidi mode
- * @param paintY y location to draw at. Unused when draw is false
- * @param gc GC to draw on
- * location where drawing would stop
- * @param bidi the bidi object to use for measuring and rendering
- * text in bidi locales. null when not in bidi mode.
- * @return x location where drawing stopped or 0 if the startOffset or
- * length is outside the specified text. In bidi mode this value is
- * the same as the paintX input parameter.
- */
-int drawText(String text, int startOffset, int length, int paintX, int paintY, GC gc, StyledTextBidi bidi) {
- int endOffset = startOffset + length;
- int textLength = text.length();
-
- if (startOffset < 0 || startOffset >= textLength || startOffset + length > textLength) {
- return paintX;
- }
- for (int i = startOffset; i < endOffset; i++) {
- int tabIndex = text.indexOf(TAB, i);
- // is tab not present or past the rendering range?
- if (tabIndex == -1 || tabIndex > endOffset) {
- tabIndex = endOffset;
- }
- if (tabIndex != i) {
- String tabSegment = text.substring(i, tabIndex);
- if (bidi != null) {
- bidi.drawBidiText(i, tabIndex - i, -horizontalScrollOffset, paintY);
- }
- else {
- gc.drawString(tabSegment, paintX - horizontalScrollOffset, paintY, true);
- paintX += gc.stringExtent(tabSegment).x;
- if (tabIndex != endOffset && tabWidth > 0) {
- paintX = getTabStop(paintX);
- }
- }
- i = tabIndex;
- }
- else // is tab at current rendering offset?
- if (tabWidth > 0 && isBidi() == false) {
- paintX = getTabStop(paintX);
- }
- }
- return paintX;
-}
-/**
* Ends the autoscroll process.
*/
void endAutoScroll() {
autoScrollDirection = SWT.NULL;
}
-/**
- * Filter the given style ranges based on the font style and
- * return the unchanged styles only if there is at least one
- * non-regular (e.g., bold) font.
- * <p>
- *
- * @param styles styles that may contain font styles.
- * @return null if the styles contain only regular font styles, the
- * unchanged styles otherwise.
- */
-StyleRange[] filterLineStyles(StyleRange[] styles) {
- if (styles != null) {
- int styleIndex = 0;
- while (styleIndex < styles.length && styles[styleIndex].fontStyle == SWT.NORMAL) {
- styleIndex++;
- }
- if (styleIndex == styles.length) {
- styles = null;
- }
- }
- return styles;
-}
/**
* @see org.eclipse.swt.widgets.Control#getBackground
*/
@@ -3133,9 +3009,8 @@ int getBidiOffsetAtMouseLocation(int x, int line) {
StyledTextBidi bidi = getStyledTextBidi(lineText, lineOffset, gc);
int[] values;
int offsetInLine;
-
x += horizontalScrollOffset;
- values = bidi.getCaretOffsetAndDirectionAtX(x);
+ values = bidi.getCaretOffsetAndDirectionAtX(x - leftMargin);
offsetInLine = values[0];
lastCaretDirection = values[1];
gc.dispose();
@@ -3188,18 +3063,18 @@ int getCaretOffsetAtX(String line, int lineOffset, int lineXOffset) {
GC gc = new GC(this);
FontData currentFont = gc.getFont().getFontData()[0];
StyleRange[] styles = null;
- StyledTextEvent event = getLineStyleData(lineOffset, line);
+ StyledTextEvent event = renderer.getLineStyleData(lineOffset, line);
lineXOffset += horizontalScrollOffset;
if (event != null) {
- styles = filterLineStyles(event.styles);
+ styles = renderer.filterLineStyles(event.styles);
}
int low = -1;
int high = line.length();
while (high - low > 1) {
offset = (high + low) / 2;
- int x = textWidth(line, lineOffset, 0, offset, styles, 0, gc, currentFont);
- int charWidth = textWidth(line, lineOffset, 0, offset + 1, styles, 0, gc, currentFont) - x;
+ int x = renderer.textWidth(line, lineOffset, 0, offset, styles, 0, gc, currentFont) + leftMargin;
+ int charWidth = renderer.textWidth(line, lineOffset, 0, offset + 1, styles, 0, gc, currentFont) + leftMargin - x;
if (lineXOffset <= x + charWidth / 2) {
high = offset;
}
@@ -3252,7 +3127,6 @@ public StyledTextContent getContent() {
*/
public boolean getDoubleClickEnabled() {
checkWidget();
-
return doubleClickEnabled;
}
/**
@@ -3267,55 +3141,9 @@ public boolean getDoubleClickEnabled() {
*/
public boolean getEditable() {
checkWidget();
-
return editable;
}
/**
- * Returns an array of text ranges that have a font style specified (e.g., SWT.BOLD).
- * <p>
- * @param styles style ranges in the line
- * @param lineOffset start index of the line, relative to the start of the document
- * @param length of the line
- * @return StyleRange[], array of ranges with a font style specified,
- * null if styles parameter is null
- */
-StyleRange[] getFontStyleRanges(StyleRange[] styles, int lineOffset, int lineLength) {
- int count = 0;
- StyleRange[] ranges = null;
-
- if (styles == null) {
- return null;
- }
- // figure out the number of ranges with font styles
- for (int i = 0; i < styles.length; i++) {
- StyleRange style = styles[i];
- if (style.start - lineOffset < lineLength) {
- if (style.fontStyle == SWT.BOLD) {
- count++;
- }
- }
- }
- // get the style information
- if (count > 0) {
- ranges = new StyleRange[count];
- count = 0;
- for (int i = 0; i < styles.length; i++) {
- StyleRange style = styles[i];
- int styleLineStart = style.start - lineOffset;
- if (styleLineStart < lineLength) {
- if (style.fontStyle == SWT.BOLD) {
- StyleRange newStyle = new StyleRange();
- newStyle.start = Math.max(0, styleLineStart);
- newStyle.length = (Math.min(styleLineStart + style.length, lineLength)) - newStyle.start;
- ranges[count] = newStyle;
- count++;
- }
- }
- }
- }
- return ranges;
-}
-/**
* @see org.eclipse.swt.widgets.Control#getForeground
*/
public Color getForeground() {
@@ -3351,7 +3179,6 @@ int getHorizontalIncrement() {
*/
public int getHorizontalIndex() {
checkWidget();
-
return horizontalScrollOffset / getHorizontalIncrement();
}
/**
@@ -3367,7 +3194,6 @@ public int getHorizontalIndex() {
*/
public int getHorizontalPixel() {
checkWidget();
-
return horizontalScrollOffset;
}
/**
@@ -3409,7 +3235,6 @@ public int getKeyBinding(int key) {
*/
public int getCharCount() {
checkWidget();
-
return content.getCharCount();
}
/**
@@ -3441,6 +3266,18 @@ public Color getLineBackground(int index) {
}
return lineBackground;
}
+/**
+ * Returns the line background data for the given line or null if
+ * there is none.
+ * <p>
+ * @param lineOffset offset of the line start relative to the start
+ * of the content.
+ * @param line line to get line background data for
+ * @return line background data for the given line.
+ */
+StyledTextEvent getLineBackgroundData(int lineOffset, String line) {
+ return sendLineEvent(LineGetBackground, lineOffset, line);
+}
/**
* Gets the number of text lines.
* <p>
@@ -3513,25 +3350,9 @@ public int getLineAtOffset(int offset) {
*/
public String getLineDelimiter() {
checkWidget();
-
return content.getLineDelimiter();
}
/**
- * Returns the line height.
- * <p>
- *
- * @return line height in pixel.
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public int getLineHeight() {
- checkWidget();
-
- return lineHeight;
-}
-/**
* Returns a StyledTextEvent that can be used to request data such
* as styles and background color for a line.
* The specified line may be a visual (wrapped) line if in word
@@ -3546,141 +3367,39 @@ public int getLineHeight() {
* @return StyledTextEvent that can be used to request line data
* for the given line.
*/
-StyledTextEvent getLineEvent(int lineOffset, String line) {
- StyledTextEvent event = new StyledTextEvent(logicalContent);
-
- if (wordWrap) {
- // if word wrap is on, the line offset and text may be visual (wrapped)
- int lineIndex = logicalContent.getLineAtOffset(lineOffset);
-
- event.detail = logicalContent.getOffsetAtLine(lineIndex);
- event.text = logicalContent.getLine(lineIndex);
- }
- else {
- event.detail = lineOffset;
- event.text = line;
- }
- return event;
-}
-/**
- * Returns styles for the specified visual (wrapped) line.
- * <p>
- *
- * @param logicalStyles the styles for a logical (unwrapped) line
- * @param lineOffset offset of the visual line
- * @param lineLength length of the visual line
- * @return styles in the logicalStyles array that are at least
- * partially on the specified visual line.
- */
-StyleRange[] getVisualLineStyleData(StyleRange[] logicalStyles, int lineOffset, int lineLength) {
- int lineEnd = lineOffset + lineLength;
- int oldStyleCount = logicalStyles.length;
- int newStyleCount = 0;
+StyledTextEvent sendLineEvent(int eventType, int lineOffset, String line) {
+ StyledTextEvent event = null;
- for (int i = 0; i < oldStyleCount; i++) {
- StyleRange style = logicalStyles[i];
- if (style.start < lineEnd && style.start + style.length > lineOffset) {
- newStyleCount++;
- }
- }
- if (newStyleCount != oldStyleCount) {
- StyleRange[] newStyles = new StyleRange[newStyleCount];
- for (int i = 0, j = 0; i < oldStyleCount; i++) {
- StyleRange style = logicalStyles[i];
- if (style.start < lineEnd && style.start + style.length > lineOffset) {
- newStyles[j++] = logicalStyles[i];
- }
- }
- logicalStyles = newStyles;
- }
- return logicalStyles;
-}
-/**
- * Returns the line style data for the given line or null if there is
- * none. If there is a LineStyleListener but it does not set any styles,
- * the StyledTextEvent.styles field will be initialized to an empty
- * array.
- * <p>
- *
- * @param lineOffset offset of the line start relative to the start of
- * the content.
- * @param line line to get line styles for
- * @return line style data for the given line. Styles may start before
- * line start and end after line end
- */
-StyledTextEvent getLineStyleData(int lineOffset, String line) {
- if (isListening(LineGetStyle)) {
- StyledTextEvent event = getLineEvent(lineOffset, line);
-
- notifyListeners(LineGetStyle, event);
- if (event.styles != null && wordWrap) {
- event.styles = getVisualLineStyleData(event.styles, lineOffset, line.length());
- }
- if (event.styles == null) {
- event.styles = new StyleRange[0];
+ if (isListening(eventType)) {
+ event = new StyledTextEvent(logicalContent);
+ if (wordWrap) {
+ // if word wrap is on, the line offset and text may be visual (wrapped)
+ int lineIndex = logicalContent.getLineAtOffset(lineOffset);
+
+ event.detail = logicalContent.getOffsetAtLine(lineIndex);
+ event.text = logicalContent.getLine(lineIndex);
}
- else
- if (isBidi()) {
- GC gc = new GC(this);
- if (StyledTextBidi.isLigated(gc)) {
- // Check for ligatures that are partially styled, if one is found
- // automatically apply the style to the entire ligature.
- // Since ligatures can't extend over multiple lines (they aren't
- // ligatures if they are separated by a line delimiter) we can ignore
- // style starts or ends that are not on the current line.
- // Note that there is no need to deal with segments when checking for
- // the ligatures.
- int lineLength = line.length();
- StyledTextBidi bidi = new StyledTextBidi(gc, line, new int[] {0, lineLength});
- for (int i=0; i<event.styles.length; i++) {
- StyleRange range = event.styles[i];
- StyleRange newRange = null;
- int relativeStart = range.start - lineOffset;
- if (relativeStart >= 0) {
- int startLigature = bidi.getLigatureStartOffset(relativeStart);
- if (startLigature != relativeStart) {
- newRange = (StyleRange) range.clone();
- range = event.styles[i] = newRange;
- range.start = range.start - (relativeStart - startLigature);
- range.length = range.length + (relativeStart - startLigature);
- }
- }
- int rangeEnd = range.start + range.length;
- int relativeEnd = rangeEnd - lineOffset - 1;
- if (relativeEnd < lineLength) {
- int endLigature = bidi.getLigatureEndOffset(relativeEnd);
- if (endLigature != relativeEnd) {
- if (newRange == null) {
- newRange = (StyleRange) range.clone();
- range = event.styles[i] = newRange;
- }
- range.length = range.length + (endLigature - relativeEnd);
- }
- }
- }
- }
- gc.dispose();
+ else {
+ event.detail = lineOffset;
+ event.text = line;
}
- return event;
+ notifyListeners(eventType, event);
}
- return null;
+ return event;
}
/**
- * Returns the line background data for the given line or null if
- * there is none.
+ * Returns the line height.
* <p>
- * @param lineOffset offset of the line start relative to the start
- * of the content.
- * @param line line to get line background data for
- * @return line background data for the given line.
+ *
+ * @return line height in pixel.
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-StyledTextEvent getLineBackgroundData(int lineOffset, String line) {
- if (isListening(LineGetBackground)) {
- StyledTextEvent event = getLineEvent(lineOffset, line);
- notifyListeners(LineGetBackground, event);
- return event;
- }
- return null;
+public int getLineHeight() {
+ checkWidget();
+ return lineHeight;
}
/**
* Returns a LineCache implementation. Depending on whether or not
@@ -3703,6 +3422,22 @@ LineCache getLineCache(StyledTextContent content) {
return lineCache;
}
/**
+ * Returns the line style data for the given line or null if there is
+ * none. If there is a LineStyleListener but it does not set any styles,
+ * the StyledTextEvent.styles field will be initialized to an empty
+ * array.
+ * <p>
+ *
+ * @param lineOffset offset of the line start relative to the start of
+ * the content.
+ * @param line line to get line styles for
+ * @return line style data for the given line. Styles may start before
+ * line start and end after line end
+ */
+StyledTextEvent getLineStyleData(int lineOffset, String line) {
+ return sendLineEvent(LineGetStyle, lineOffset, line);
+}
+/**
* Returns the x, y location of the upper left corner of the character
* bounding box at the specified offset in the text. The point is
* relative to the upper left corner of the widget client area.
@@ -3826,7 +3561,6 @@ int getOffsetAtMouseLocation(int x, int line) {
String lineText = content.getLine(line);
int lineOffset = content.getOffsetAtLine(line);
int offsetInLine = getCaretOffsetAtX(lineText, lineOffset, x);
-
return lineOffset + offsetInLine;
}
/**
@@ -3844,7 +3578,7 @@ int getOffsetAtX(String line, int lineOffset, int lineXOffset) {
GC gc = new GC(this);
int offset;
- lineXOffset += horizontalScrollOffset;
+ lineXOffset += (horizontalScrollOffset - leftMargin);
if (isBidi()) {
StyledTextBidi bidi = getStyledTextBidi(line, lineOffset, gc);
offset = bidi.getOffsetAtX(lineXOffset);
@@ -3852,10 +3586,10 @@ int getOffsetAtX(String line, int lineOffset, int lineXOffset) {
else {
FontData currentFont = gc.getFont().getFontData()[0];
StyleRange[] styles = null;
- StyledTextEvent event = getLineStyleData(lineOffset, line);
+ StyledTextEvent event = renderer.getLineStyleData(lineOffset, line);
if (event != null) {
- styles = filterLineStyles(event.styles);
+ styles = renderer.filterLineStyles(event.styles);
}
int low = -1;
int high = line.length();
@@ -3863,7 +3597,7 @@ int getOffsetAtX(String line, int lineOffset, int lineXOffset) {
offset = (high + low) / 2;
// Restrict right/high search boundary only if x is within searched text segment.
// Fixes 1GL4ZVE.
- if (lineXOffset < textWidth(line, lineOffset, 0, offset + 1, styles, 0, gc, currentFont)) {
+ if (lineXOffset < renderer.textWidth(line, lineOffset, 0, offset + 1, styles, 0, gc, currentFont)) {
high = offset;
}
else
@@ -3887,7 +3621,6 @@ int getOffsetAtX(String line, int lineOffset, int lineXOffset) {
*/
int getPartialBottomIndex() {
int partialLineCount = Compatibility.ceil(getClientArea().height, lineHeight);
-
return Math.min(content.getLineCount(), topIndex + partialLineCount) - 1;
}
/**
@@ -3952,222 +3685,9 @@ public Point getSelection() {
*/
public Point getSelectionRange() {
checkWidget();
-
return new Point(selection.x, selection.y - selection.x);
}
/**
- * Merges the selection into the styles that are passed in.
- * The font style of existing style ranges is preserved in the selection.
- * <p>
- * @param styles the existing styles that the selection should be
- * applied to.
- * @return the selection style range merged with the existing styles
- */
-/*
-Pseudo code for getSelectionLineStyles
- for each style {
- if (style ends before selection start) {
- add style to list
- }
- else
- if (style overlaps selection start (i.e., starts before selection start, ends after selection start) {
- change style end
- create new selection style with same font style starting at selection start ending at style end
- add selection style
- // does style extend beyond selection?
- if (selection style end > selection end) {
- selection style end = selection end
- // preserve rest (unselected part) of old style
- style start = selection end
- style length = old style end - selection end
- add style
- }
- }
- else
- if (style starts within selection) {
- if (no selection style created) {
- create selection style with regular font style, starting at selection start, ending at style start
- add selection style
- if (style start == selection start) {
- set selection style font to style font
- }
- }
- // gap between current selection style end and new style start?
- if (style start > selection styke end && selection style font style != NORMAL) {
- create selection style with regular font style, starting at selection style end, ending at style start
- add selection style
- }
- if (selection style font != style font) {
- selection style end = style start
- add selection style
- create selection style with style font style, starting at style start, ending at style end
- }
- else {
- selection style end = style end
- }
- // does style extend beyond selection?
- if (selection style end > selection end) {
- selection style end = selection end
- // preserve rest (unselected part) of old style
- style start = selection end
- style length = old style end - selection end
- style start = selection end
- add style
- }
- }
- else {
- if (no selection style created) {
- create selection style with regular font style, starting at selection start, ending at selection end
- add selection style
- }
- else
- if (selection style end < selection end) {
- if (selection style font style != NORMAL) {
- create selection style with regular font style, starting at selection style end, ending at selection end
- add selection style
- }
- else {
- selection style end = selection end
- }
- }
- add style
- }
- }
- if (no selection style created) {
- create selection style with regular font style, starting at selection start, ending at selection end
- add selection style to list
- }
- else
- if (selection style end < selection end) {
- if (selection style font style != NORMAL) {
- create selection style with regular font style, starting at selection style end, ending at selection end
- add selection style
- }
- else {
- selection style end = selection end
- }
- }
-*/
-StyleRange[] getSelectionLineStyles(StyleRange[] styles) {
- int selectionStart = selection.x;
- int selectionEnd = selection.y;
- Vector newStyles = new Vector(styles.length);
- StyleRange selectionStyle = null;
- Color foreground = getSelectionForeground();
- Color background = getSelectionBackground();
-
- // potential optimization: ignore styles if there is no bold style and the entire line is selected
- for (int i = 0; i < styles.length; i++) {
- StyleRange style = styles[i];
- int styleEnd = style.start + style.length;
-
- if (styleEnd <= selectionStart) {
- newStyles.addElement(style);
- }
- else // style overlaps selection start? (i.e., starts before selection start, ends after selection start
- if (style.start < selectionStart && styleEnd > selectionStart) {
- StyleRange newStyle = (StyleRange) style.clone();
- newStyle.length -= styleEnd - selectionStart;
- newStyles.addElement(newStyle);
- // create new selection style with same font style starting at selection start ending at style end
- selectionStyle = new StyleRange(selectionStart, styleEnd - selectionStart, foreground, background, newStyle.fontStyle);
- newStyles.addElement(selectionStyle);
- // if style extends beyond selection a new style is returned for the unselected part of the style
- newStyle = setSelectionStyleEnd(selectionStyle, style);
- if (newStyle != null) {
- newStyles.addElement(newStyle);
- }
- }
- else // style starts within selection?
- if (style.start >= selectionStart && style.start < selectionEnd) {
- StyleRange newStyle;
- int selectionStyleEnd;
- // no selection style created yet?
- if (selectionStyle == null) {
- // create selection style with regular font style, starting at selection start, ending at style start
- selectionStyle = new StyleRange(selectionStart, style.start - selectionStart, foreground, background);
- newStyles.addElement(selectionStyle);
- if (style.start == selectionStart) {
- selectionStyle.fontStyle = style.fontStyle;
- }
- }
- selectionStyleEnd = selectionStyle.start + selectionStyle.length;
- // gap between current selection style end and style start?
- if (style.start > selectionStyleEnd && selectionStyle.fontStyle != SWT.NORMAL) {
- // create selection style with regular font style, starting at selection style end, ending at style start
- selectionStyle = new StyleRange(selectionStyleEnd, style.start - selectionStyleEnd, foreground, background);
- newStyles.addElement(selectionStyle);
- }
- if (selectionStyle.fontStyle != style.fontStyle) {
- // selection style end = style start
- selectionStyle.length = style.start - selectionStyle.start;
- // create selection style with style font style, starting at style start, ending at style end
- selectionStyle = new StyleRange(style.start, style.length, foreground, background, style.fontStyle);
- newStyles.addElement(selectionStyle);
- }
- else {
- // selection style end = style end
- selectionStyle.length = styleEnd - selectionStyle.start;
- }
- // if style extends beyond selection a new style is returned for the unselected part of the style
- newStyle = setSelectionStyleEnd(selectionStyle, style);
- if (newStyle != null) {
- newStyles.addElement(newStyle);
- }
- }
- else {
- // no selection style created yet?
- if (selectionStyle == null) {
- // create selection style with regular font style, starting at selection start, ending at selection end
- selectionStyle = new StyleRange(selectionStart, selectionEnd - selectionStart, foreground, background);
- newStyles.addElement(selectionStyle);
- }
- else // does the current selection style end before the selection end?
- if (selectionStyle.start + selectionStyle.length < selectionEnd) {
- if (selectionStyle.fontStyle != SWT.NORMAL) {
- int selectionStyleEnd = selectionStyle.start + selectionStyle.length;
- // create selection style with regular font style, starting at selection style end, ending at selection end
- selectionStyle = new StyleRange(selectionStyleEnd, selectionEnd - selectionStyleEnd, foreground, background);
- newStyles.addElement(selectionStyle);
- }
- else {
- selectionStyle.length = selectionEnd - selectionStyle.start;
- }
- }
- newStyles.addElement(style);
- }
- }
- if (selectionStyle == null) {
- // create selection style with regular font style, starting at selection start, ending at selection end
- selectionStyle = new StyleRange(selectionStart, selectionEnd - selectionStart, foreground, background);
- newStyles.addElement(selectionStyle);
- }
- else // does the current selection style end before the selection end?
- if (selectionStyle.start + selectionStyle.length < selectionEnd) {
- if (selectionStyle.fontStyle != SWT.NORMAL) {
- int selectionStyleEnd = selectionStyle.start + selectionStyle.length;
- // create selection style with regular font style, starting at selection style end, ending at selection end
- selectionStyle = new StyleRange(selectionStyleEnd, selectionEnd - selectionStyleEnd, foreground, background);
- newStyles.addElement(selectionStyle);
- }
- else {
- selectionStyle.length = selectionEnd - selectionStyle.start;
- }
- }
- styles = new StyleRange[newStyles.size()];
- newStyles.copyInto(styles);
- return styles;
-}
-/**
- * Returns the background color to be used for rendering selected text.
- * <p>
- *
- * @return background color to be used for rendering selected text
- */
-Color getSelectionBackground() {
- return getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION);
-}
-/**
* Gets the number of selected characters.
* <p>
*
@@ -4182,15 +3702,6 @@ public int getSelectionCount() {
return getSelectionRange().y;
}
/**
- * Returns the foreground color to be used for rendering selected text.
- * <p>
- *
- * @return foreground color to be used for rendering selected text
- */
-Color getSelectionForeground() {
- return getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);
-}
-/**
* Returns the selected text.
* <p>
*
@@ -4202,7 +3713,6 @@ Color getSelectionForeground() {
*/
public String getSelectionText() {
checkWidget();
-
return content.getTextRange(selection.x, selection.y - selection.x);
}
/**
@@ -4227,12 +3737,10 @@ int [] getBidiSegments(int lineOffset, String line) {
if (isListening(LineGetSegments) == false) {
return getBidiSegmentsCompatibility(line, lineOffset);
}
- StyledTextEvent event = getLineEvent(lineOffset, line);
+ StyledTextEvent event = sendLineEvent(LineGetSegments, lineOffset, line);
int lineLength = line.length();
int[] segments;
-
- notifyListeners(LineGetSegments, event);
- if (event.segments == null || event.segments.length == 0) {
+ if (event == null || event.segments == null || event.segments.length == 0) {
segments = new int[] {0, lineLength};
}
else {
@@ -4267,11 +3775,10 @@ int [] getBidiSegmentsCompatibility(String line, int lineOffset) {
StyledTextEvent event;
StyleRange [] styles = new StyleRange [0];
int lineLength = line.length();
-
if (bidiColoring == false) {
return new int[] {0, lineLength};
}
- event = getLineStyleData(lineOffset, line);
+ event = renderer.getLineStyleData(lineOffset, line);
if (event != null) {
styles = event.styles;
}
@@ -4399,18 +3906,7 @@ StyledTextBidi getStyledTextBidi(String lineText, int lineOffset, GC gc) {
* @return a StyledTextBidi object for the specified line.
*/
StyledTextBidi getStyledTextBidi(String lineText, int lineOffset, GC gc, StyleRange[] styles) {
- StyleRange[] fontStyles = null;
-
- if (styles == null) {
- StyledTextEvent event = getLineStyleData(lineOffset, lineText);
- if (event != null) {
- fontStyles = getFontStyleRanges(event.styles, lineOffset, lineText.length());
- }
- }
- else {
- fontStyles = getFontStyleRanges(styles, lineOffset, lineText.length());
- }
- return new StyledTextBidi(gc, tabWidth, lineText, fontStyles, boldFont, getBidiSegments(lineOffset, lineText));
+ return renderer.getStyledTextBidi(lineText, lineOffset, gc, styles);
}
/**
* Returns the tab width measured in characters.
@@ -4423,29 +3919,9 @@ StyledTextBidi getStyledTextBidi(String lineText, int lineOffset, GC gc, StyleRa
*/
public int getTabs() {
checkWidget();
-
return tabLength;
}
/**
- * Returns the next tab stop for the specified x location.
- * <p>
- *
- * @param x the x location in front of a tab
- * @return the next tab stop for the specified x location.
- */
-int getTabStop(int x) {
- int spaceWidth = tabWidth / tabLength;
-
- // make sure tab stop is at least one space width apart
- // from the last character. fixes 4844.
- if (tabWidth - x % tabWidth < spaceWidth) {
- x += tabWidth;
- }
- x += tabWidth;
- x -= x % tabWidth;
- return x;
-}
-/**
* Returns a copy of the widget content.
* <p>
*
@@ -4457,7 +3933,6 @@ int getTabStop(int x) {
*/
public String getText() {
checkWidget();
-
return content.getTextRange(0, getCharCount());
}
/**
@@ -4563,7 +4038,6 @@ public int getTopIndex() {
*/
public int getTopPixel() {
checkWidget();
-
return verticalScrollOffset;
}
/**
@@ -4738,13 +4212,12 @@ public boolean getWordWrap() {
*/
int getXAtOffset(String line, int lineIndex, int lineOffset) {
int x;
-
if (lineOffset == 0 && isBidi() == false) {
- x = 0;
+ x = leftMargin;
}
else {
GC gc = new GC(this);
- x = textWidth(line, lineIndex, Math.min(line.length(), lineOffset), gc);
+ x = textWidth(line, lineIndex, Math.min(line.length(), lineOffset), gc) + leftMargin;
gc.dispose();
if (lineOffset > line.length()) {
// offset is not on the line. return an x location one character
@@ -4879,6 +4352,24 @@ void installListeners() {
});
}
}
+StyledTextContent internalGetContent() {
+ return content;
+}
+int internalGetHorizontalPixel() {
+ return horizontalScrollOffset;
+}
+int internalGetLastCaretDirection() {
+ return lastCaretDirection;
+}
+LineCache internalGetLineCache() {
+ return lineCache;
+}
+Point internalGetSelection() {
+ return selection;
+}
+boolean internalGetWordWrap() {
+ return wordWrap;
+}
/**
* Used by WordWrapCache to bypass StyledText.redraw which does
* an unwanted cache reset.
@@ -4909,7 +4400,6 @@ void internalRedrawRange(int start, int length, boolean clearBackground) {
int offsetInFirstLine;
int partialBottomIndex = getPartialBottomIndex();
int partialTopIndex = verticalScrollOffset / lineHeight;
-
// do nothing if redraw range is completely invisible
if (firstLine > partialBottomIndex || lastLine < partialTopIndex) {
return;
@@ -4954,7 +4444,6 @@ void internalRedrawRange(int start, int length, boolean clearBackground) {
String getRtf(){
checkWidget();
RTFWriter rtfWriter = new RTFWriter(0, getCharCount());
-
return getPlatformDelimitedText(rtfWriter);
}
/**
@@ -4963,17 +4452,20 @@ String getRtf(){
void handleDispose() {
clipboard.dispose();
ibeamCursor.dispose();
- if (boldFont != null) {
- boldFont.dispose();
+ if (renderer != null) {
+ renderer.dispose();
+ renderer = null;
}
if (content != null) {
content.removeTextChangeListener(textChangeListener);
}
if (leftCaretBitmap != null) {
leftCaretBitmap.dispose();
+ leftCaretBitmap = null;
}
if (rightCaretBitmap != null) {
rightCaretBitmap.dispose();
+ rightCaretBitmap = null;
}
if (isBidi()) {
StyledTextBidi.removeLanguageListener(this);
@@ -4987,7 +4479,6 @@ void handleMouseDoubleClick(Event event) {
if (event.button != 1 || doubleClickEnabled == false) {
return;
}
- event.x -= leftMargin;
event.y -= topMargin;
mouseDoubleClick = true;
caretOffset = getWordEndNoSpaces(caretOffset);
@@ -5008,7 +4499,6 @@ void handleMouseDown(Event event) {
return;
}
mouseDoubleClick = false;
- event.x -= leftMargin;
event.y -= topMargin;
if (isBidi()) {
doBidiMouseLocationChange(event.x, event.y, select);
@@ -5021,7 +4511,6 @@ void handleMouseDown(Event event) {
* Autoscrolling ends when the mouse button is released.
*/
void handleMouseUp(Event event) {
- event.x -= leftMargin;
event.y -= topMargin;
endAutoScroll();
}
@@ -5033,7 +4522,6 @@ void handleMouseMove(Event event) {
if (mouseDoubleClick == true || (event.stateMask & SWT.BUTTON1) == 0) {
return;
}
- event.x -= leftMargin;
event.y -= topMargin;
if (isBidi()) {
doBidiMouseLocationChange(event.x, event.y, true);
@@ -5104,13 +4592,34 @@ void handleKey(Event event) {
* @param event paint event
*/
void handlePaint(Event event) {
- int startLine = (event.y - topMargin + verticalScrollOffset) / lineHeight;
+ int startLine = Math.max(0, (event.y - topMargin + verticalScrollOffset) / lineHeight);
int paintYFromTopLine = (startLine - topIndex) * lineHeight;
int topLineOffset = topIndex * lineHeight - verticalScrollOffset;
int startY = paintYFromTopLine + topLineOffset; // adjust y position for pixel based scrolling
int renderHeight = event.y + event.height - startY;
- int paintY = 0;
+ Rectangle clientArea = getClientArea();
+
+ // Check if there is work to do. clientArea.width should never be 0
+ // if we receive a paint event but we never want to try and create
+ // an Image with 0 width.
+ if (clientArea.width == 0 || event.height == 0) {
+ return;
+ }
+ performPaint(event.gc, startLine, startY, renderHeight);
+}
+/**
+ * Render the specified area. Broken out as its own method to support
+ * direct drawing.
+ * <p>
+ *
+ * @param gc
+ * @param startLine
+ * @param startY
+ * @param renderHeight
+ */
+void performPaint(GC gc,int startLine,int startY, int renderHeight) {
int lineCount = content.getLineCount();
+ int paintY = topMargin;
Rectangle clientArea = getClientArea();
Color background = getBackground();
Color foreground = getForeground();
@@ -5119,10 +4628,9 @@ void handlePaint(Event event) {
Font font;
FontData fontData;
- // Check if there is work to do. clientArea.width should never be 0
- // if we receive a paint event but we never want to try and create
- // an Image with 0 width.
- if (clientArea.width == 0 || event.height == 0) {
+ // Check if there is work to do. We never want to try and create
+ // an Image with 0 width or 0 height.
+ if (clientArea.width == 0 || renderHeight == 0) {
return;
}
if (isSingleLine()) {
@@ -5131,35 +4639,47 @@ void handlePaint(Event event) {
startLine = 1;
}
}
- font = event.gc.getFont();
+ font = gc.getFont();
fontData = font.getFontData()[0];
- if (clientArea.width > (leftMargin + rightMargin)) {
- lineBuffer = new Image(getDisplay(), clientArea.width - leftMargin - rightMargin, renderHeight);
+ // Do double buffering on direct draw operations only
+ if (drawDirect || SWT.getPlatform().equals("win32")) {
+ lineBuffer = new Image(getDisplay(), clientArea.width, renderHeight);
lineGC = new GC(lineBuffer);
lineGC.setFont(font);
lineGC.setForeground(foreground);
lineGC.setBackground(background);
for (int i = startLine; paintY < renderHeight && i < lineCount; i++, paintY += lineHeight) {
String line = content.getLine(i);
- drawLine(line, i, paintY, lineGC, background, foreground, fontData, true);
+ renderer.drawLine(line, i, paintY, lineGC, background, foreground, fontData, true);
}
if (paintY < renderHeight) {
lineGC.setBackground(background);
lineGC.setForeground(background);
lineGC.fillRectangle(0, paintY, clientArea.width, renderHeight - paintY);
}
- event.gc.drawImage(lineBuffer, leftMargin, topMargin + startY);
+ gc.drawImage(lineBuffer, 0, startY);
lineGC.dispose();
lineBuffer.dispose();
+ } else {
+ for (int i = startLine; paintY < renderHeight && i < lineCount; i++, paintY += lineHeight) {
+ String line = content.getLine(i);
+ renderer.drawLine(line, i, paintY + startY, gc, background, foreground, fontData, true);
+ }
+ if (paintY < renderHeight) {
+ gc.setBackground(background);
+ gc.setForeground(background);
+ gc.fillRectangle(0, paintY + startY, clientArea.width, renderHeight - paintY);
+ }
}
+
// clear the margin background
- event.gc.setBackground(background);
- event.gc.fillRectangle(0, 0, clientArea.width, topMargin);
- event.gc.fillRectangle(0, 0, leftMargin, renderHeight);
- event.gc.fillRectangle(
+ gc.setBackground(background);
+ gc.fillRectangle(0, 0, clientArea.width, topMargin);
+ gc.fillRectangle(0, 0, leftMargin, renderHeight);
+ gc.fillRectangle(
0, clientArea.height - bottomMargin,
clientArea.width, bottomMargin);
- event.gc.fillRectangle(
+ gc.fillRectangle(
clientArea.width - rightMargin, 0,
rightMargin, renderHeight);
}
@@ -5173,7 +4693,6 @@ void handlePaint(Event event) {
void handleResize(Event event) {
int oldHeight = clientAreaHeight;
int oldWidth = clientAreaWidth;
-
clientAreaHeight = getClientArea().height;
clientAreaWidth = getClientArea().width;
if (wordWrap) {
@@ -5259,12 +4778,15 @@ void handleTextChanging(TextChangingEvent event) {
lastTextChangeReplaceLineCount = event.replaceLineCount;
lastTextChangeReplaceCharCount = event.replaceCharCount;
firstLine = content.getLineAtOffset(event.start);
- textChangeY = firstLine * lineHeight - verticalScrollOffset;
+ textChangeY = firstLine * lineHeight - verticalScrollOffset + topMargin;
if (isMultiLineChange) {
redrawMultiLineChange(textChangeY, event.newLineCount, event.replaceLineCount);
}
else {
- super.redraw(leftMargin, textChangeY + topMargin, getClientArea().width - leftMargin - rightMargin, lineHeight, true);
+ // Optimization for non-Windows platforms. Do direct drawing during typing.
+ if (drawDirect == false) {
+ super.redraw(leftMargin, textChangeY, getClientArea().width - leftMargin - rightMargin, lineHeight, true);
+ }
}
// notify default line styler about text change
if (defaultLineStyler != null) {
@@ -5301,35 +4823,20 @@ void handleTraverse(Event event) {
* Scrolls the widget vertically.
*/
void handleVerticalScroll(Event event) {
- //TEMPORARY CODE
- if (event.detail == SWT.DRAG && !SWT.getPlatform().equals("win32")) {
- if (updater != null) return;
- updater = new Runnable(){
- public void run(){
- if (isDisposed()) return;
- setVerticalScrollOffset(getVerticalBar().getSelection(), false);
- updater = null;
- }
- };
- getDisplay().timerExec(100, updater);
- return;
- }
setVerticalScrollOffset(getVerticalBar().getSelection(), false);
}
/**
* Initializes the fonts used to render font styles.
* Presently only regular and bold fonts are supported.
*/
-void initializeFonts() {
- FontData fontData;
- GC gc = new GC(this);
-
- lineEndSpaceWidth = gc.stringExtent(" ").x;
- regularFont = getFont();
- fontData = regularFont.getFontData()[0];
- fontData.setStyle(fontData.getStyle() | SWT.BOLD);
- boldFont = new Font(getDisplay(), fontData);
- gc.dispose();
+void initializeRenderer() {
+ if (renderer != null) {
+ renderer.dispose();
+ }
+ renderer = new DisplayRenderer(
+ getDisplay(), getFont(), isBidi(), leftMargin, this, tabLength);
+ lineHeight = renderer.getLineHeight();
+ lineEndSpaceWidth = renderer.getLineEndSpaceWidth();
}
/**
* Executes the action.
@@ -5496,7 +5003,6 @@ boolean isLineDelimiter(int offset) {
int line = content.getLineAtOffset(offset);
int lineOffset = content.getOffsetAtLine(line);
int offsetInLine = offset - lineOffset;
-
// offsetInLine will be greater than line length if the line
// delimiter is longer than one character and the offset is set
// in between parts of the line delimiter.
@@ -5582,6 +5088,10 @@ void modifyContent(Event event, boolean updateCaret) {
styledTextEvent.end = event.start + event.text.length();
styledTextEvent.text = content.getTextRange(event.start, replacedLength);
}
+ // Optimization for non-Windows platforms. Do direct drawing during typing.
+ if (SWT.getPlatform().equals("win32") == false) {
+ drawDirect = (event.text.length() == 1) || (replacedLength == 1);
+ }
content.replaceTextRange(event.start, replacedLength, event.text);
// set the caret position prior to sending the modify event.
// fixes 1GBB8NJ
@@ -5603,6 +5113,15 @@ void modifyContent(Event event, boolean updateCaret) {
showCaret();
}
}
+ // Optimization for non-Windows platforms. Do direct drawing during typing.
+ if (drawDirect) {
+ int startLine = content.getLineAtOffset(event.start);
+ int startY = startLine * lineHeight - verticalScrollOffset;
+ GC gc = new GC(this);
+ performPaint(gc, startLine, startY, lineHeight);
+ drawDirect = false;
+ gc.dispose();
+ }
notifyListeners(SWT.Modify, event);
if (isListening(ExtendedModify)) {
notifyListeners(ExtendedModify, styledTextEvent);
@@ -5626,7 +5145,6 @@ public void paste(){
checkWidget();
TextTransfer transfer = TextTransfer.getInstance();
String text;
-
text = (String) clipboard.getContents(transfer);
if (text != null && text.length() > 0) {
Event event = new Event();
@@ -5646,7 +5164,9 @@ public void paste(){
*/
public void print() {
checkWidget();
- StyledTextPrinter.print(this);
+ Printer printer = new Printer();
+ new Printing(this, printer).run();
+ printer.dispose();
}
/**
* Returns a runnable that will print the widget's text
@@ -5669,7 +5189,7 @@ public Runnable print(Printer printer) {
if (printer == null) {
SWT.error(SWT.ERROR_NULL_ARGUMENT);
}
- return new StyledTextPrinter(this, printer);
+ return new Printing(this, printer);
}
/**
* Causes the entire bounds of the receiver to be marked
@@ -5729,8 +5249,6 @@ public void redraw() {
* @see Control#update
*/
public void redraw(int x, int y, int width, int height, boolean all) {
- x += leftMargin;
- y += topMargin;
super.redraw(x, y, width, height, all);
if (height > 0) {
int lineCount = content.getLineCount();
@@ -5768,16 +5286,18 @@ void redrawBidiLines(int firstLine, int offsetInFirstLine, int lastLine, int end
GC gc = new GC(this);
StyledTextBidi bidi = getStyledTextBidi(line, firstLineOffset, gc);
- bidi.redrawRange(this, offsetInFirstLine, Math.min(line.length(), endOffset) - offsetInFirstLine, -horizontalScrollOffset, redrawY, lineHeight);
+ bidi.redrawRange(
+ this, offsetInFirstLine,
+ Math.min(line.length(), endOffset) - offsetInFirstLine,
+ leftMargin - horizontalScrollOffset, redrawY + topMargin, lineHeight);
// redraw line break marker (either space or full client area width)
// if redraw range extends over more than one line and background should be redrawn
if (lastLine > firstLine && clearBackground) {
int lineBreakWidth;
int lineBreakStartX = bidi.getTextWidth();
-
// handle empty line case
- if (lineBreakStartX == 0) {
- lineBreakStartX = XINSET;
+ if (lineBreakStartX == leftMargin) {
+ lineBreakStartX += XINSET;
}
lineBreakStartX = lineBreakStartX - horizontalScrollOffset;
if ((getStyle() & SWT.FULL_SELECTION) != 0) {
@@ -5797,7 +5317,10 @@ void redrawBidiLines(int firstLine, int offsetInFirstLine, int lastLine, int end
line = content.getLine(lastLine);
redrawY = lastLine * lineHeight - verticalScrollOffset;
bidi = getStyledTextBidi(line, lastLineOffset, gc);
- bidi.redrawRange(this, 0, offsetInLastLine, -horizontalScrollOffset, redrawY, lineHeight);
+ bidi.redrawRange(
+ this, 0, offsetInLastLine,
+ leftMargin - horizontalScrollOffset,
+ redrawY + topMargin, lineHeight);
}
}
gc.dispose();
@@ -5817,17 +5340,16 @@ void redrawBidiLines(int firstLine, int offsetInFirstLine, int lastLine, int end
void redrawLines(int firstLine, int offsetInFirstLine, int lastLine, int endOffset, boolean clearBackground) {
String line = content.getLine(firstLine);
int lineCount = lastLine - firstLine + 1;
- int redrawX = getXAtOffset(line, firstLine, offsetInFirstLine);
+ int redrawX = getXAtOffset(line, firstLine, offsetInFirstLine) - leftMargin;
int redrawStopX;
int redrawY = firstLine * lineHeight - verticalScrollOffset;
int firstLineOffset = content.getOffsetAtLine(firstLine);
-
// calculate redraw stop location
if ((getStyle() & SWT.FULL_SELECTION) != 0 && lastLine > firstLine) {
- redrawStopX = getClientArea().width;
+ redrawStopX = getClientArea().width - leftMargin;
}
else {
- redrawStopX = getXAtOffset(line, firstLine, endOffset - firstLineOffset);
+ redrawStopX = getXAtOffset(line, firstLine, endOffset - firstLineOffset) - leftMargin;
}
draw(redrawX, redrawY, redrawStopX - redrawX, lineHeight, clearBackground);
// redraw last line if more than one line needs redrawing
@@ -5836,7 +5358,7 @@ void redrawLines(int firstLine, int offsetInFirstLine, int lastLine, int endOffs
// no redraw necessary if redraw offset is 0
if (offsetInLastLine > 0) {
line = content.getLine(lastLine);
- redrawStopX = getXAtOffset(line, lastLine, offsetInLastLine);
+ redrawStopX = getXAtOffset(line, lastLine, offsetInLastLine) - leftMargin;
redrawY = lastLine * lineHeight - verticalScrollOffset;
draw(0, redrawY, redrawStopX, lineHeight, clearBackground);
}
@@ -6156,7 +5678,6 @@ public void replaceTextRange(int start, int length, String text) {
void reset() {
ScrollBar verticalBar = getVerticalBar();
ScrollBar horizontalBar = getHorizontalBar();
-
caretOffset = 0;
caretLine = 0;
topIndex = 0;
@@ -6290,7 +5811,6 @@ void sendKeyEvent(Event event) {
*/
void sendSelectionEvent() {
Event event = new Event();
-
event.x = selection.x;
event.y = selection.y;
notifyListeners(SWT.Selection, event);
@@ -6312,7 +5832,7 @@ public void setWordWrap(boolean wrap) {
wordWrap = wrap;
if (wordWrap) {
logicalContent = content;
- content = new WrappedContent(this, logicalContent);
+ content = new WrappedContent(renderer, logicalContent);
}
else {
content = logicalContent;
@@ -6340,9 +5860,8 @@ void showBidiCaret() {
boolean scrolled = false;
GC gc = new GC(this);
StyledTextBidi bidi = getStyledTextBidi(lineText, lineOffset, gc);
-
// getXAtOffset, inlined for better performance
- xAtOffset = bidiTextWidth(lineText, 0, offsetInLine, 0, bidi);
+ xAtOffset = renderer.bidiTextWidth(lineText, 0, offsetInLine, 0, bidi) + leftMargin;
if (offsetInLine > lineText.length()) {
// offset is not on the line. return an x location one character
// after the line to indicate the line delimiter.
@@ -6410,9 +5929,9 @@ void setBidiCaretLocation(StyledTextBidi bidi) {
bidi = getStyledTextBidi(lineText, lineStartOffset, gc);
}
if (lastCaretDirection == SWT.NULL) {
- caretX = bidi.getCaretPosition(offsetInLine);
+ caretX = bidi.getCaretPosition(offsetInLine) + leftMargin;
} else {
- caretX = bidi.getCaretPosition(offsetInLine, lastCaretDirection);
+ caretX = bidi.getCaretPosition(offsetInLine, lastCaretDirection) + leftMargin;
}
caretX = caretX - horizontalScrollOffset;
if (StyledTextBidi.getKeyboardLanguageDirection() == SWT.RIGHT) {
@@ -6420,7 +5939,7 @@ void setBidiCaretLocation(StyledTextBidi bidi) {
}
createBidiCaret();
caret.setLocation(
- caretX + leftMargin,
+ caretX,
caretLine * lineHeight - verticalScrollOffset + topMargin);
if (gc != null) {
gc.dispose();
@@ -6456,7 +5975,6 @@ void setBidiKeyboardLanguage() {
GC gc = new GC(this);
StyledTextBidi bidi;
int lineLength = lineText.length();
-
// Don't supply the bold styles/font since we don't want to measure anything
bidi = new StyledTextBidi(gc, lineText, getBidiSegments(lineStartOffset, lineText));
if (offsetInLine == 0) {
@@ -6495,7 +6013,7 @@ void setCaretLocation(int caretX, int line) {
Caret caret = getCaret();
if (caret != null) {
caret.setLocation(
- caretX + leftMargin,
+ caretX,
line * lineHeight - verticalScrollOffset + topMargin);
}
}
@@ -6515,7 +6033,7 @@ void setCaretLocation() {
content.getLine(caretLine),
caretLine, caretOffset - lineStartOffset);
caret.setLocation(
- caretX + leftMargin,
+ caretX,
caretLine * lineHeight - verticalScrollOffset + topMargin);
}
}
@@ -6579,22 +6097,22 @@ public void setCaretOffset(int offset) {
* <li>ERROR_NULL_ARGUMENT when listener is null</li>
* </ul>
*/
-public void setContent(StyledTextContent content) {
+public void setContent(StyledTextContent newContent) {
checkWidget();
- if (content == null) {
+ if (newContent == null) {
SWT.error(SWT.ERROR_NULL_ARGUMENT);
}
- if (this.content != null) {
- this.content.removeTextChangeListener(textChangeListener);
+ if (content != null) {
+ content.removeTextChangeListener(textChangeListener);
}
- logicalContent = content;
+ logicalContent = newContent;
if (wordWrap) {
- this.content = new WrappedContent(this, logicalContent);
+ content = new WrappedContent(renderer, logicalContent);
}
else {
- this.content = logicalContent;
+ content = logicalContent;
}
- this.content.addTextChangeListener(textChangeListener);
+ content.addTextChangeListener(textChangeListener);
reset();
}
/**
@@ -6610,7 +6128,6 @@ public void setContent(StyledTextContent content) {
*/
public void setDoubleClickEnabled(boolean enable) {
checkWidget();
-
doubleClickEnabled = enable;
}
/**
@@ -6626,7 +6143,6 @@ public void setDoubleClickEnabled(boolean enable) {
*/
public void setEditable(boolean editable) {
checkWidget();
-
this.editable = editable;
}
/**
@@ -6644,15 +6160,10 @@ public void setEditable(boolean editable) {
*/
public void setFont(Font font) {
checkWidget();
- int oldLineHeight;
+ int oldLineHeight = lineHeight;
super.setFont(font);
- if (boldFont != null) {
- boldFont.dispose();
- }
- initializeFonts();
- oldLineHeight = lineHeight;
- calculateLineHeight();
+ initializeRenderer();
// keep the same top line visible. fixes 5815
if (lineHeight != oldLineHeight) {
setVerticalScrollOffset(verticalScrollOffset * lineHeight / oldLineHeight, true);
@@ -6660,7 +6171,6 @@ public void setFont(Font font) {
}
calculateContentWidth();
calculateScrollBars();
- calculateTabWidth();
if (isBidi()) {
caretDirection = SWT.NULL;
createCaretBitmaps();
@@ -6703,7 +6213,6 @@ public void setForeground(Color color) {
public void setHorizontalIndex(int offset) {
checkWidget();
int clientAreaWidth = getClientArea().width;
-
if (getCharCount() == 0) {
return;
}
@@ -6745,7 +6254,6 @@ public void setHorizontalIndex(int offset) {
public void setHorizontalPixel(int pixel) {
checkWidget();
int clientAreaWidth = getClientArea().width;
-
if (getCharCount() == 0) {
return;
}
@@ -6777,7 +6285,6 @@ void setHorizontalScrollBar() {
if (horizontalBar != null && horizontalBar.getVisible()) {
final int INACTIVE = 1;
Rectangle clientArea = getClientArea();
-
// only set the real values if the scroll bar can be used
// (ie. because the thumb size is less than the scroll maximum)
// avoids flashing on Motif, fixes 1G7RE1J and 1G5SE92
@@ -6856,58 +6363,6 @@ public void setLineBackground(int startLine, int lineCount, Color background) {
leftMargin, startLine * lineHeight + topMargin,
getClientArea().width - leftMargin - rightMargin, lineCount * lineHeight, true);
}
-/**
- * Sets the background of the specified GC for a line rendering operation,
- * if it is not already set.
- * </p>
- *
- * @param gc GC to set the background color in
- * @param currentBackground background color currently set in gc
- * @param newBackground new background color of gc
- */
-Color setLineBackground(GC gc, Color currentBackground, Color newBackground) {
- if (currentBackground.equals(newBackground) == false) {
- gc.setBackground(newBackground);
- }
- return newBackground;
-}
-/**
- * Sets the font of the specified GC if it is not already set.
- * </p>
- *
- * @param gc GC to set the font in
- * @param currentFont font data of font currently set in gc
- * @param style desired style of the font in gc. Can be one of
- * SWT.NORMAL, SWT.BOLD
- */
-void setLineFont(GC gc, FontData currentFont, int style) {
- if (currentFont.getStyle() != style) {
- if (style == SWT.BOLD) {
- currentFont.setStyle(style);
- gc.setFont(boldFont);
- }
- else
- if (style == SWT.NORMAL) {
- currentFont.setStyle(style);
- gc.setFont(regularFont);
- }
- }
-}
-/**
- * Sets the foreground of the specified GC for a line rendering operation,
- * if it is not already set.
- * </p>
- *
- * @param gc GC to set the foreground color in
- * @param currentForeground foreground color currently set in gc
- * @param newForeground new foreground color of gc
- */
-Color setLineForeground(GC gc, Color currentForeground, Color newForeground) {
- if (currentForeground.equals(newForeground) == false) {
- gc.setForeground(newForeground);
- }
- return newForeground;
-}
/**
* Adjusts the maximum and the page size of the scroll bars to
* reflect content width/length changes.
@@ -7229,7 +6684,6 @@ public void setStyleRanges(StyleRange[] ranges) {
int lastEnd = last.start + last.length;
int firstLine = content.getLineAtOffset(ranges[0].start);
int lastLine;
-
if (lastEnd > content.getCharCount()) {
SWT.error(SWT.ERROR_INVALID_RANGE);
}
@@ -7248,35 +6702,6 @@ public void setStyleRanges(StyleRange[] ranges) {
// fixes 1G8FODP
setCaretLocation();
}
-/**
- * Ensures that the selection style ends at the selection end.
- * <code>selectionStyle</code> is assumed to be created based on the style
- * range of <code>style</code>. If <code>selectionStyle</code> does extend
- * beyond the selection range a new style is returned to preserve the style
- * passed in with <code>style</code>.
- * <p>
- * @param selectionStyle the selection style based on the style range in
- * <code>style</code>
- * @param style the existing style that is to be merged with the selection
- * @return a new style that preserves the style passed in with <code>style</code>
- * if the selection does not fully extend over the existing style range.
- * null otherwise.
- */
-StyleRange setSelectionStyleEnd(StyleRange selectionStyle, StyleRange style) {
- int selectionEnd = selection.y;
- StyleRange newStyle = null;
-
- // does style extend beyond selection?
- if (selectionStyle.start + selectionStyle.length > selectionEnd) {
- int styleEnd = style.start + style.length;
- selectionStyle.length = selectionEnd - selectionStyle.start;
- // preserve rest (unselected part) of old style
- newStyle = (StyleRange) style.clone();
- newStyle.start = selectionEnd;
- newStyle.length = styleEnd - selectionEnd;
- }
- return newStyle;
-}
/**
* Sets the tab width.
* <p>
@@ -7290,7 +6715,7 @@ StyleRange setSelectionStyleEnd(StyleRange selectionStyle, StyleRange style) {
public void setTabs(int tabs) {
checkWidget();
tabLength = tabs;
- calculateTabWidth();
+ renderer.setTabLength(tabLength);
if (caretOffset > 0) {
caretOffset = 0;
caretLine = 0;
@@ -7506,7 +6931,7 @@ boolean showLocation(int x, int line) {
int horizontalIncrement = clientAreaWidth / 4;
boolean scrolled = false;
- if (x < 0) {
+ if (x < leftMargin) {
// always make 1/4 of a page visible
x = Math.max(horizontalScrollOffset * -1, x - horizontalIncrement);
scrollHorizontalBar(x);
@@ -7594,131 +7019,24 @@ int textWidth(String line, int lineIndex, int length, GC gc) {
int lineOffset = content.getOffsetAtLine(lineIndex);
int lineLength = line.length();
int width;
-
if (lineLength == 0 || length > lineLength) {
return 0;
}
if (isBidi()) {
- StyledTextBidi bidi = getStyledTextBidi(line, lineOffset, gc);
- width = bidiTextWidth(line, 0, length, 0, bidi);
+ StyledTextBidi bidi = getStyledTextBidi(line, lineOffset, gc, null);
+ width = renderer.bidiTextWidth(line, 0, length, 0, bidi);
}
else {
- StyledTextEvent event = getLineStyleData(lineOffset, line);
+ StyledTextEvent event = renderer.getLineStyleData(lineOffset, line);
StyleRange[] styles = null;
-
if (event != null) {
- styles = filterLineStyles(event.styles);
+ styles = renderer.filterLineStyles(event.styles);
}
- width = textWidth(line, lineOffset, 0, length, styles, 0, gc, gc.getFont().getFontData()[0]);
+ width = renderer.textWidth(line, lineOffset, 0, length, styles, 0, gc, gc.getFont().getFontData()[0]);
}
return width;
}
/**
- * Returns the width of the specified text. Expand tabs to tab stops using
- * the widget tab width.
- * <p>
- *
- * @param text text to be measured.
- * @param lineOffset offset of the first character in the line.
- * @param startOffset offset of the character to start measuring and
- * expand tabs.
- * @param length number of characters to measure. Tabs are counted
- * as one character in this parameter.
- * @param styles line styles
- * @param startXOffset x position of "startOffset" in "text". Used for
- * calculating tab stops
- * @param gc GC to use for measuring text
- * @param fontData the font currently set in gc. Cached for better performance.
- * @return width of the text with tabs expanded to tab stops or 0 if the
- * startOffset or length is outside the specified text.
- */
-int textWidth(String text, int lineOffset, int startOffset, int length, StyleRange[] lineStyles, int startXOffset, GC gc, FontData fontData) {
- int paintX = 0;
- int endOffset = startOffset + length;
- int textLength = text.length();
-
- if (startOffset < 0 || startOffset >= textLength || endOffset > textLength) {
- return paintX;
- }
- for (int i = startOffset; i < endOffset; i++) {
- int tabIndex = text.indexOf(TAB, i);
- // is tab not present or past the rendering range?
- if (tabIndex == -1 || tabIndex > endOffset) {
- tabIndex = endOffset;
- }
- if (tabIndex != i) {
- String tabSegment = text.substring(i, tabIndex);
- if (lineStyles != null) {
- paintX = styledTextWidth(tabSegment, lineOffset + i, lineStyles, paintX, gc, fontData);
- }
- else {
- setLineFont(gc, fontData, SWT.NORMAL);
- paintX += gc.stringExtent(tabSegment).x;
- }
- if (tabIndex != endOffset && tabWidth > 0) {
- paintX = getTabStop(startXOffset + paintX) - startXOffset;
- }
- i = tabIndex;
- }
- else
- if (tabWidth > 0) {
- paintX = getTabStop(startXOffset + paintX) - startXOffset;
- }
- }
- return paintX;
-}
-/**
- * Measures the text as rendered at the specified location. Expand tabs to tab stops using
- * the widget tab width.
- * <p>
- *
- * @param text text to draw
- * @param textStartOffset offset of the first character in text relative
- * to the first character in the document
- * @param lineStyles styles of the line
- * @param paintX x location to start drawing at
- * @param gc GC to draw on
- * @param fontData the font data of the font currently set in gc
- * @return x location where drawing stopped or 0 if the startOffset or
- * length is outside the specified text.
- */
-int styledTextWidth(String text, int textStartOffset, StyleRange[] lineStyles, int paintX, GC gc, FontData fontData) {
- String textSegment;
- int textLength = text.length();
- int textIndex = 0;
-
- for (int styleIndex = 0; styleIndex < lineStyles.length; styleIndex++) {
- StyleRange style = lineStyles[styleIndex];
- int textEnd;
- int styleSegmentStart = style.start - textStartOffset;
- if (styleSegmentStart + style.length < 0) {
- continue;
- }
- if (styleSegmentStart >= textLength) {
- break;
- }
- // is there a style for the current string position?
- if (textIndex < styleSegmentStart) {
- setLineFont(gc, fontData, SWT.NORMAL);
- textSegment = text.substring(textIndex, styleSegmentStart);
- paintX += gc.stringExtent(textSegment).x;
- textIndex = styleSegmentStart;
- }
- textEnd = Math.min(textLength, styleSegmentStart + style.length);
- setLineFont(gc, fontData, style.fontStyle);
- textSegment = text.substring(textIndex, textEnd);
- paintX += gc.stringExtent(textSegment).x;
- textIndex = textEnd;
- }
- // is there unmeasured and unstyled text?
- if (textIndex < textLength) {
- setLineFont(gc, fontData, SWT.NORMAL);
- textSegment = text.substring(textIndex, textLength);
- paintX += gc.stringExtent(textSegment).x;
- }
- return paintX;
-}
-/**
* Updates the caret direction when a delete operation occured based on
* the type of the delete operation (next/previous character) and the
* caret location (at a direction boundary or inside a direction segment).
@@ -7815,7 +7133,6 @@ void wordWrapResize(int oldClientAreaWidth) {
int topOffset = content.getOffsetAtLine(topIndex) + topLine.length();
int newTopIndex;
WrappedContent wrappedContent = (WrappedContent) content;
-
// all lines are wrapped and no rewrap required if widget has already
// been visible, client area is now wider and visual (wrapped) line
// count equals logical line count.
@@ -7856,5 +7173,4 @@ void wordWrapResize(int oldClientAreaWidth) {
// word wrap may have changed on one of the visible lines
super.redraw();
}
-
} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextPrinter.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextPrinter.java
deleted file mode 100755
index b333851d67..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextPrinter.java
+++ /dev/null
@@ -1,373 +0,0 @@
-package org.eclipse.swt.custom;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved
- */
-
-import java.io.*;
-import java.util.Vector;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.custom.*;
-import org.eclipse.swt.printing.*;
-import org.eclipse.swt.internal.Compatibility;
-
-class StyledTextPrinter implements Runnable {
- class RTFState {
- int fontStyle;
- int foreground;
- int background;
- }
- Vector savedState = new Vector();
-
- Printer printer;
- GC gc;
- String rtf;
- StringBuffer wordBuffer;
- int startPage, endPage, currentPage;
- int index, end;
- String tabs = "";
- int tabWidth = 0;
- int lineHeight = 0;
- int leftMargin, rightMargin, topMargin, bottomMargin;
- int x, y;
-
- /* We can optimize for fonts because we know styledText only has one font.
- * As soon as we know the font name and point size, we will create and store
- * fonts for the following styles: normal, bold, italic, and bold italic.
- */
- Font fontTable[][] = new Font[1][4];
- boolean creatingFontTable = false;
- String fontName;
- int fontSize;
- int currentFontStyle = SWT.NORMAL;
- int currentFont = -1;
- int defaultFont = -1;
-
- Vector colorTable = new Vector();
- boolean creatingColorTable = false;
- int red, green, blue;
- int currentForeground = -1;
- int currentBackground = -1;
-
- static void print(StyledText styledText) {
- Printer printer = new Printer();
- new StyledTextPrinter(styledText, printer).run();
- printer.dispose();
- }
-
- StyledTextPrinter(StyledText styledText, Printer printer) {
- this.printer = printer;
- PrinterData data = printer.getPrinterData();
- startPage = 1;
- endPage = Integer.MAX_VALUE;
- if (data.scope == PrinterData.PAGE_RANGE) {
- startPage = data.startPage;
- endPage = data.endPage;
- }
-
- /* Create a buffer for computing tab width. */
- int tabSize = styledText.getTabs();
- StringBuffer tabBuffer = new StringBuffer(tabSize);
- for (int i = 0; i < tabSize; i++) tabBuffer.append(' ');
- tabs = tabBuffer.toString();
-
- /* Get RTF from the StyledText.*/
- rtf = styledText.getRtf();
- }
-
- public void run() {
- if (printer.startJob("Printing")) {
- Rectangle clientArea = printer.getClientArea();
- Rectangle trim = printer.computeTrim(0, 0, 0, 0);
- Point dpi = printer.getDPI();
- leftMargin = dpi.x + trim.x; // one inch from left side of paper
- rightMargin = clientArea.width - dpi.x + trim.x + trim.width; // one inch from right side of paper
- topMargin = dpi.y + trim.y; // one inch from top edge of paper
- bottomMargin = clientArea.height - dpi.y + trim.y + trim.height; // one inch from bottom edge of paper
-
- /* Create a printer GC and print the RTF to it. */
- gc = new GC(printer);
- x = leftMargin;
- y = topMargin;
- currentPage = 1;
- if (startPage == 1) {
- printer.startPage();
- }
- end = rtf.length();
- index = 0;
- wordBuffer = new StringBuffer();
- while (index < end) {
- char c = rtf.charAt(index);
- index++;
- switch (c) {
- case '\\':
- printWordBuffer();
- parseControlWord();
- break;
- case '{':
- printWordBuffer();
- saveState();
- break;
- case '}':
- printWordBuffer();
- restoreState();
- break;
- case 0x0a:
- case 0x0d:
- printWordBuffer();
- break;
- default:
- parseChar(c);
- }
- }
- if (y + lineHeight <= bottomMargin) {
- printer.endPage();
- }
- printer.endJob();
-
- /* Cleanup */
- gc.dispose();
- for (int i = 0; i < 4; i++) {
- fontTable[currentFont][i].dispose();
- }
- for (int i = 0; i < colorTable.size(); i++) {
- ((Color)colorTable.elementAt(i)).dispose();
- }
- }
- }
-
- void parseControlWord() {
- if (index >= end) return;
- char c = rtf.charAt(index);
- index++;
- if (!Compatibility.isLetter(c)) {
- handleControlSymbol(c);
- return;
- }
- StringBuffer controlWord = new StringBuffer();
- controlWord.append(c);
- while (index < end) {
- c = rtf.charAt(index);
- index++;
- if (!Compatibility.isLetter(c)) break;
- controlWord.append(c);
- }
- boolean isNegative = false;
- if (c == '-') {
- isNegative = true;
- c = rtf.charAt(index);
- index++;
- }
- boolean hasParameter = false;
- StringBuffer paramBuffer = new StringBuffer();
- int parameter = 0;
- if (Character.isDigit(c)) {
- hasParameter = true;
- paramBuffer.append(c);
- while (index < end) {
- c = rtf.charAt(index);
- index++;
- if (!Character.isDigit(c)) break;
- paramBuffer.append(c);
- }
- try {
- parameter = Integer.valueOf(paramBuffer.toString()).intValue();
- } catch (NumberFormatException e) {}
- if (isNegative) parameter = -parameter;
- }
- if (c != ' ') index--;
- if (hasParameter) {
- handleControlWord(controlWord.toString(), parameter);
- } else {
- handleControlWord(controlWord.toString());
- }
- }
-
- void parseChar(char c) {
- if (c == 0) return;
- if (c == ';') {
- if (creatingFontTable) {
- fontName = wordBuffer.toString();
- wordBuffer = new StringBuffer();
- creatingFontTable = false;
- return;
- }
- if (creatingColorTable) {
- colorTable.addElement(new Color(printer, red, green, blue));
- red = green = blue = 0;
- return;
- }
- }
- if (c != '\t') {
- wordBuffer.append(c);
- }
- if (!Compatibility.isLetterOrDigit(c) && !creatingFontTable) {
- printWordBuffer();
- if (c == '\t') {
- x += tabWidth;
- }
- }
- }
-
- void printWordBuffer() {
- if (wordBuffer.length() > 0) {
- String word = wordBuffer.toString();
- int wordWidth = gc.stringExtent(word).x;
- if (x + wordWidth > rightMargin) {
- /* word doesn't fit on current line, so wrap */
- newline();
- }
- if (currentPage >= startPage && currentPage <= endPage) {
- gc.drawString(word, x, y, true);
- }
- x += wordWidth;
- wordBuffer = new StringBuffer();
- }
- }
-
- void handleControlSymbol(char c) {
- switch (c) {
- case '\\':
- case '{':
- case '}':
- parseChar(c);
- }
- }
-
- void handleControlWord(String controlWord) {
- if (controlWord.equals("par")) newline();
- else if (controlWord.equals("b")) setFontStyle(currentFontStyle | SWT.BOLD);
- else if (controlWord.equals("i")) setFontStyle(currentFontStyle | SWT.ITALIC);
- else if (controlWord.equals("fnil")) setFont(defaultFont);
- else if (controlWord.equals("fonttbl")) createFontTable();
- else if (controlWord.equals("colortbl")) createColorTable();
- }
-
- void handleControlWord(String controlWord, int parameter) {
- if (controlWord.equals("highlight")) setBackground(parameter);
- else if (controlWord.equals("cf")) setForeground(parameter);
- else if (controlWord.equals("b")) setFontStyle(currentFontStyle & ~SWT.BOLD);
- else if (controlWord.equals("i")) setFontStyle(currentFontStyle & ~SWT.ITALIC);
- else if (controlWord.equals("f")) setFont(parameter);
- else if (controlWord.equals("fs")) setFontSize(parameter);
- else if (controlWord.equals("red")) red = parameter;
- else if (controlWord.equals("green")) green = parameter;
- else if (controlWord.equals("blue")) blue = parameter;
- else if (controlWord.equals("deff")) setDefaultFont(parameter);
- }
-
- void setDefaultFont(int number) {
- defaultFont = number;
- }
-
- void setFont(int number) {
- currentFont = number;
- }
-
- void createFontTable() {
- creatingFontTable = true;
- currentFont = 0;
- }
-
- void setFontSize(int size) {
- fontSize = size / 2;
- createFonts();
- }
-
- void createFonts() {
- if (fontName != null && fontSize != -1) {
- // currentFont must already be set
- fontTable[currentFont][0] = new Font(printer, fontName, fontSize, SWT.NORMAL);
- fontTable[currentFont][1] = new Font(printer, fontName, fontSize, SWT.BOLD);
- fontTable[currentFont][2] = new Font(printer, fontName, fontSize, SWT.ITALIC);
- fontTable[currentFont][3] = new Font(printer, fontName, fontSize, SWT.BOLD | SWT.ITALIC);
- setFontStyle(SWT.NORMAL);
- }
- }
-
- void setFontStyle(int style) {
- // currentFont must already be set
- Font font;
- if ((style & SWT.BOLD) != 0) {
- if ((style & SWT.ITALIC) != 0) {
- font = fontTable[currentFont][3];
- } else {
- font = fontTable[currentFont][1];
- }
- } else if ((style & SWT.ITALIC) != 0) {
- font = fontTable[currentFont][2];
- } else {
- font = fontTable[currentFont][0];
- }
- gc.setFont(font);
- tabWidth = gc.stringExtent(tabs).x;
- lineHeight = gc.getFontMetrics().getHeight();
- currentFontStyle = style;
- }
-
- void createColorTable() {
- creatingColorTable = true;
- red = green = blue = 0;
- }
-
- void setForeground(int color) {
- if (color != currentForeground) {
- // colors must already be in table
- gc.setForeground((Color)colorTable.elementAt(color));
- currentForeground = color;
- }
- }
-
- void setBackground(int color) {
- if (color != currentBackground) {
- // colors must already be in table
- gc.setBackground((Color)colorTable.elementAt(color));
- currentBackground = color;
- }
- }
-
- void newline() {
- x = leftMargin;
- y += lineHeight;
- if (y + lineHeight > bottomMargin) {
- printer.endPage();
- if (index + 1 < end) {
- y = topMargin;
- currentPage++;
- if (currentPage >= startPage && currentPage <= endPage) {
- printer.startPage();
- }
- }
- }
- }
-
- void saveState() {
- RTFState state = new RTFState();
- state.fontStyle = currentFontStyle;
- state.foreground = currentForeground;
- state.background = currentBackground;
- savedState.addElement(state);
- }
-
- void restoreState() {
- if (savedState.isEmpty()) return;
- if (creatingColorTable) {
- setForeground(0);
- setBackground(1);
- creatingColorTable = false;
- }
-
- int index = savedState.size() - 1;
- RTFState state = (RTFState)savedState.elementAt(index);
- savedState.removeElementAt(index);
-
- setFontStyle(state.fontStyle);
- if (state.foreground != -1) setForeground(state.foreground);
- if (state.background != -1) setBackground(state.background);
- }
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/WrappedContent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/WrappedContent.java
index ad66908e37..9ae45c389e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/WrappedContent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/WrappedContent.java
@@ -30,7 +30,7 @@ class WrappedContent implements StyledTextContent {
final static int WRAP_LINE_LENGTH = 0;
final static int WRAP_LINE_WIDTH = 1;
- StyledText parent;
+ StyledTextRenderer renderer;
StyledTextContent logicalContent;
int[][] visualLines; // start and length of each visual line
int visualLineCount = 0;
@@ -38,13 +38,13 @@ class WrappedContent implements StyledTextContent {
/**
* Create a new instance.
*
- * @param styledText StyledText widget that displays the lines
- * wrapped by the new instance.
+ * @param renderer <class>StyledTextRenderer</class> that renders
+ * the lines wrapped by the new instance.
* @param logicalContent StyledTextContent that provides the line
* data.
*/
-WrappedContent(StyledText styledText, StyledTextContent logicalContent) {
- parent = styledText;
+WrappedContent(StyledTextRenderer renderer, StyledTextContent logicalContent) {
+ this.renderer = renderer;
this.logicalContent = logicalContent;
}
/**
@@ -460,15 +460,15 @@ private int textWidth(String line, int logicalLineOffset, int visualLineOffset,
// while wrapping a line, the logcial line styles may contain
// style ranges that don't apply (i.e., completely on the previous/next
// visual line). Therefore we need to filter the logical lines.
- styles = parent.getVisualLineStyleData(styles, logicalLineOffset + visualLineOffset, visualLineLength);
+ styles = renderer.getVisualLineStyleData(styles, logicalLineOffset + visualLineOffset, visualLineLength);
}
- if (parent.isBidi()) {
+ if (renderer.isBidi()) {
String wrappedLine = line.substring(visualLineOffset, visualLineOffset + visualLineLength);
- StyledTextBidi bidi = parent.getStyledTextBidi(wrappedLine, logicalLineOffset + visualLineOffset, gc, styles);
+ StyledTextBidi bidi = renderer.getStyledTextBidi(wrappedLine, logicalLineOffset + visualLineOffset, gc, styles);
width = bidi.getTextWidth();
}
else {
- width = parent.textWidth(line, logicalLineOffset, visualLineOffset, visualLineLength, styles, startX, gc, fontData);
+ width = renderer.textWidth(line, logicalLineOffset, visualLineOffset, visualLineLength, styles, startX, gc, fontData);
}
return width;
}
@@ -569,7 +569,7 @@ private int[] wrapLine(String line, int logicalLineOffset, int visualLineOffset,
private int wrapLineRange(int startLine, int endLine, int visualLineIndex) {
int emptyLineCount = 0;
- visualLineIndex = wrapLineRange(startLine, endLine, visualLineIndex, parent.getClientArea().width);
+ visualLineIndex = wrapLineRange(startLine, endLine, visualLineIndex, renderer.getClientArea().width);
// is there space left for more visual lines? can happen if there are fewer
// visual lines for a given logical line than before
for (int i = visualLineIndex; i < visualLines.length; i++, emptyLineCount++) {
@@ -597,7 +597,7 @@ private int wrapLineRange(int startLine, int endLine, int visualLineIndex) {
* @return index of last wrapped line
*/
private int wrapLineRange(int startLine, int endLine, int visualLineIndex, int width) {
- GC gc = new GC(parent);
+ GC gc = renderer.getGC();
FontData fontData = gc.getFont().getFontData()[0];
int numChars = Math.max(1, width / gc.getFontMetrics().getAverageCharWidth());
@@ -618,12 +618,12 @@ private int wrapLineRange(int startLine, int endLine, int visualLineIndex, int w
continue;
}
StyleRange[] styles = null;
- StyledTextEvent event = parent.getLineStyleData(lineOffset, line);
+ StyledTextEvent event = renderer.getLineStyleData(lineOffset, line);
int startOffset = 0;
int startX = 0;
if (event != null) {
- styles = parent.filterLineStyles(event.styles);
+ styles = renderer.filterLineStyles(event.styles);
}
while (startOffset < lineLength) {
int[] result = wrapLine(line, lineOffset, startOffset, startX, width, numChars, styles, gc, fontData);
@@ -634,7 +634,7 @@ private int wrapLineRange(int startLine, int endLine, int visualLineIndex, int w
visualLineIndex++;
}
}
- gc.dispose();
+ renderer.disposeGC(gc);
return visualLineIndex;
}
/**
@@ -642,7 +642,7 @@ private int wrapLineRange(int startLine, int endLine, int visualLineIndex, int w
* StyledText widget
*/
void wrapLines() {
- wrapLines(parent.getClientArea().width);
+ wrapLines(renderer.getClientArea().width);
}
/**
* Wrap all logical lines at the given width.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2me/org/eclipse/swt/internal/Library.java b/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2me/org/eclipse/swt/internal/Library.java
index 4e2fab37d2..466dddda29 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2me/org/eclipse/swt/internal/Library.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2me/org/eclipse/swt/internal/Library.java
@@ -17,7 +17,7 @@ public class Library {
/**
* SWT Minor version number (must be in the range 0..999)
*/
- static int MINOR_VERSION = 31;
+ static int MINOR_VERSION = 32;
/**
* SWT revision number (must be >= 0)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2se/org/eclipse/swt/internal/Library.java b/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2se/org/eclipse/swt/internal/Library.java
index a9da8371b5..e9b94380f5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2se/org/eclipse/swt/internal/Library.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/common_j2se/org/eclipse/swt/internal/Library.java
@@ -17,7 +17,7 @@ public class Library {
/**
* SWT Minor version number (must be in the range 0..999)
*/
- static int MINOR_VERSION = 31;
+ static int MINOR_VERSION = 32;
/**
* SWT revision number (must be >= 0)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/eclipsefixed.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/eclipsefixed.h
index 0cb59eb892..a4136ca5fa 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/eclipsefixed.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/eclipsefixed.h
@@ -39,7 +39,7 @@
#define ECLIPSE_FIXED(obj) (GTK_CHECK_CAST ((obj), ECLIPSE_TYPE_FIXED, EclipseFixed))
#define ECLIPSE_FIXED_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), ECLIPSE_TYPE_FIXED, EclipseFixedClass))
#define GTK_IS_ECLIPSE_FIXED(obj) (GTK_CHECK_TYPE ((obj), ECLIPSE_TYPE_FIXED))
-#define GTK_IS_FIXED_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), ECLIPSE_TYPE_FIXED))
+#define GTK_IS_ECLIPSE_FIXED_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), ECLIPSE_TYPE_FIXED))
typedef struct _EclipseFixed EclipseFixed;
typedef struct _EclipseFixedClass EclipseFixedClass;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/structs.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/structs.c
index 3430fbc3e0..b1228fae94 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/structs.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/structs.c
@@ -572,7 +572,6 @@ void cacheGtkCTreeFids(JNIEnv *env, jobject lpGtkCTree, PGtkCTree_FID_CACHE lpCa
if (lpCache->cached) return;
lpCache->GtkCTreeClass = (*env)->GetObjectClass(env, lpGtkCTree);
- cacheGtkCListFids(env, lpGtkCTree, &PGLOB(GtkCListFc));
lpCache->tree_indent = (*env)->GetFieldID(env, lpCache->GtkCTreeClass, "tree_indent", "I");
lpCache->tree_column = (*env)->GetFieldID(env, lpCache->GtkCTreeClass, "tree_column", "I");
@@ -585,7 +584,6 @@ void cacheGtkCTreeRowFids(JNIEnv *env, jobject lpGtkCTreeRow, PGtkCTreeRow_FID_C
if (lpCache->cached) return;
lpCache->GtkCTreeRowClass = (*env)->GetObjectClass(env, lpGtkCTreeRow);
- cacheGtkCListRowFids(env, lpGtkCTreeRow, &PGLOB(GtkCListRowFc));
lpCache->parent = (*env)->GetFieldID(env, lpCache->GtkCTreeRowClass, "parent", "I");
lpCache->sibling = (*env)->GetFieldID(env, lpCache->GtkCTreeRowClass, "sibling", "I");
lpCache->children = (*env)->GetFieldID(env, lpCache->GtkCTreeRowClass, "children", "I");
@@ -1362,23 +1360,23 @@ void setGtkStyleClassFields(JNIEnv *env, jobject lpObject, GtkStyleClass *lpGtkS
void getGtkAdjustmentFields(JNIEnv *env, jobject lpObject, GtkAdjustment *lpGtkAdjustment, GtkAdjustment_FID_CACHE *lpGtkAdjustmentFc)
{
DECL_GLOB(pGlob)
- lpGtkAdjustment->lower = (*env)->GetFloatField(env, lpObject, lpGtkAdjustmentFc->lower);
- lpGtkAdjustment->upper = (*env)->GetFloatField(env, lpObject, lpGtkAdjustmentFc->upper);
- lpGtkAdjustment->value = (*env)->GetFloatField(env, lpObject, lpGtkAdjustmentFc->value);
- lpGtkAdjustment->step_increment = (*env)->GetFloatField(env, lpObject, lpGtkAdjustmentFc->step_increment);
- lpGtkAdjustment->page_increment = (*env)->GetFloatField(env, lpObject, lpGtkAdjustmentFc->page_increment);
- lpGtkAdjustment->page_size = (*env)->GetFloatField(env, lpObject, lpGtkAdjustmentFc->page_size);
+ lpGtkAdjustment->lower = (gdouble)(*env)->GetDoubleField(env, lpObject, lpGtkAdjustmentFc->lower);
+ lpGtkAdjustment->upper = (gdouble)(*env)->GetDoubleField(env, lpObject, lpGtkAdjustmentFc->upper);
+ lpGtkAdjustment->value = (gdouble)(*env)->GetDoubleField(env, lpObject, lpGtkAdjustmentFc->value);
+ lpGtkAdjustment->step_increment = (gdouble)(*env)->GetDoubleField(env, lpObject, lpGtkAdjustmentFc->step_increment);
+ lpGtkAdjustment->page_increment = (gdouble)(*env)->GetDoubleField(env, lpObject, lpGtkAdjustmentFc->page_increment);
+ lpGtkAdjustment->page_size = (gdouble)(*env)->GetDoubleField(env, lpObject, lpGtkAdjustmentFc->page_size);
}
void setGtkAdjustmentFields(JNIEnv *env, jobject lpObject, GtkAdjustment *lpGtkAdjustment, GtkAdjustment_FID_CACHE *lpGtkAdjustmentFc)
{
DECL_GLOB(pGlob)
- (*env)->SetFloatField(env, lpObject, lpGtkAdjustmentFc->lower, (jfloat)lpGtkAdjustment->lower);
- (*env)->SetFloatField(env, lpObject, lpGtkAdjustmentFc->upper, (jfloat)lpGtkAdjustment->upper);
- (*env)->SetFloatField(env, lpObject, lpGtkAdjustmentFc->value, (jfloat)lpGtkAdjustment->value);
- (*env)->SetFloatField(env, lpObject, lpGtkAdjustmentFc->step_increment, (jfloat)lpGtkAdjustment->step_increment);
- (*env)->SetFloatField(env, lpObject, lpGtkAdjustmentFc->page_increment, (jfloat)lpGtkAdjustment->page_increment);
- (*env)->SetFloatField(env, lpObject, lpGtkAdjustmentFc->page_size, (jfloat)lpGtkAdjustment->page_size);
+ (*env)->SetDoubleField(env, lpObject, lpGtkAdjustmentFc->lower, (jdouble)lpGtkAdjustment->lower);
+ (*env)->SetDoubleField(env, lpObject, lpGtkAdjustmentFc->upper, (jdouble)lpGtkAdjustment->upper);
+ (*env)->SetDoubleField(env, lpObject, lpGtkAdjustmentFc->value, (jdouble)lpGtkAdjustment->value);
+ (*env)->SetDoubleField(env, lpObject, lpGtkAdjustmentFc->step_increment, (jdouble)lpGtkAdjustment->step_increment);
+ (*env)->SetDoubleField(env, lpObject, lpGtkAdjustmentFc->page_increment, (jdouble)lpGtkAdjustment->page_increment);
+ (*env)->SetDoubleField(env, lpObject, lpGtkAdjustmentFc->page_size, (jdouble)lpGtkAdjustment->page_size);
}
void getGtkCListRowFields(JNIEnv *env, jobject lpObject, GtkCListRow *lpGtkCListRow, GtkCListRow_FID_CACHE *lpGtkCListRowFc)
@@ -1464,7 +1462,6 @@ void setGtkCListColumnFields(JNIEnv *env, jobject lpObject, GtkCListColumn *lpGt
void getGtkCTreeFields(JNIEnv *env, jobject lpObject, GtkCTree *lpGtkCTree, GtkCTree_FID_CACHE *lpGtkCTreeFc)
{
DECL_GLOB(pGlob)
- getGtkCListFields(env, lpObject, &lpGtkCTree->clist, &PGLOB(GtkCListFc));
lpGtkCTree->tree_indent = (*env)->GetIntField(env, lpObject, lpGtkCTreeFc->tree_indent);
lpGtkCTree->tree_column = (*env)->GetIntField(env, lpObject, lpGtkCTreeFc->tree_column);
}
@@ -1472,7 +1469,6 @@ void getGtkCTreeFields(JNIEnv *env, jobject lpObject, GtkCTree *lpGtkCTree, GtkC
void setGtkCTreeFields(JNIEnv *env, jobject lpObject, GtkCTree *lpGtkCTree, GtkCTree_FID_CACHE *lpGtkCTreeFc)
{
DECL_GLOB(pGlob)
- setGtkCListFields(env, lpObject, &lpGtkCTree->clist, &PGLOB(GtkCListFc));
(*env)->SetIntField(env, lpObject, lpGtkCTreeFc->tree_indent, (jint)lpGtkCTree->tree_indent);
(*env)->SetIntField(env, lpObject, lpGtkCTreeFc->tree_column, (jint)lpGtkCTree->tree_column);
}
@@ -1480,7 +1476,6 @@ void setGtkCTreeFields(JNIEnv *env, jobject lpObject, GtkCTree *lpGtkCTree, GtkC
void getGtkCTreeRowFields(JNIEnv *env, jobject lpObject, GtkCTreeRow *lpGtkCTreeRow, GtkCTreeRow_FID_CACHE *lpGtkCTreeRowFc)
{
DECL_GLOB(pGlob)
- getGtkCListRowFields(env, lpObject, &lpGtkCTreeRow->row, &PGLOB(GtkCListRowFc));
lpGtkCTreeRow->parent = (GtkCTreeNode*)(*env)->GetIntField(env, lpObject, lpGtkCTreeRowFc->parent);
lpGtkCTreeRow->sibling = (GtkCTreeNode*)(*env)->GetIntField(env, lpObject, lpGtkCTreeRowFc->sibling);
lpGtkCTreeRow->children = (GtkCTreeNode*)(*env)->GetIntField(env, lpObject, lpGtkCTreeRowFc->children);
@@ -1496,7 +1491,6 @@ void getGtkCTreeRowFields(JNIEnv *env, jobject lpObject, GtkCTreeRow *lpGtkCTree
void setGtkCTreeRowFields(JNIEnv *env, jobject lpObject, GtkCTreeRow *lpGtkCTreeRow, GtkCTreeRow_FID_CACHE *lpGtkCTreeRowFc)
{
DECL_GLOB(pGlob)
- setGtkCListRowFields(env, lpObject, &lpGtkCTreeRow->row, &PGLOB(GtkCListRowFc));
(*env)->SetIntField(env, lpObject, lpGtkCTreeRowFc->parent, (jint)lpGtkCTreeRow->parent);
(*env)->SetIntField(env, lpObject, lpGtkCTreeRowFc->sibling, (jint)lpGtkCTreeRow->sibling);
(*env)->SetIntField(env, lpObject, lpGtkCTreeRowFc->children, (jint)lpGtkCTreeRow->children);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gdk.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gdk.c
index 767fdbc0e6..faa4fa4ee8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gdk.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gdk.c
@@ -380,6 +380,35 @@ JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1draw_1drawable
gdk_draw_drawable((GdkDrawable*)drawable, (GdkGC*)gc, (GdkDrawable*)src, xsrc, ysrc, xdest, ydest, width, height);
}
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1draw_1layout
+ (JNIEnv *env, jclass that, jint drawable, jint gc, jint x, jint y, jint layout)
+{
+ gdk_draw_layout((GdkDrawable*)drawable, (GdkGC*)gc, x, y, (PangoLayout*)layout);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1draw_1layout_1with_1colors
+ (JNIEnv *env, jclass that, jint drawable, jint gc, jint x, jint y, jint layout, jobject foreground, jobject background)
+{
+ GdkColor foreground_struct, *foreground1 = NULL;
+ GdkColor background_struct, *background1 = NULL;
+ if (foreground) {
+ foreground1 = &foreground_struct;
+ cacheGdkColorFids(env, foreground, &PGLOB(GdkColorFc));
+ getGdkColorFields(env, foreground, foreground1, &PGLOB(GdkColorFc));
+ }
+ if (background) {
+ background1 = &background_struct;
+ cacheGdkColorFids(env, background, &PGLOB(GdkColorFc));
+ getGdkColorFields(env, background, background1, &PGLOB(GdkColorFc));
+ }
+ gdk_draw_layout_with_colors((GdkDrawable*)drawable, (GdkGC*)gc, x, y, (PangoLayout*)layout, foreground1, background1);
+ if (foreground) {
+ setGdkColorFields(env, foreground, foreground1, &PGLOB(GdkColorFc));
+ }
+ if (background) {
+ setGdkColorFields(env, background, background1, &PGLOB(GdkColorFc));
+ }
+}
/* ***** Bitmaps and Pixmaps ***** */
@@ -505,6 +534,21 @@ JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1color_1allo
return rc;
}
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1colormap_1query_1color
+ (JNIEnv *env, jclass that, jint colormap, jint pixel, jobject result)
+{
+ DECL_GLOB(pGlob)
+ GdkColor result_struct, *result1 = NULL;
+ if (result) {
+ result1 = &result_struct;
+ cacheGdkColorFids(env, result, &PGLOB(GdkColorFc));
+ getGdkColorFields(env, result, result1, &PGLOB(GdkColorFc));
+ }
+ gdk_colormap_query_color((GdkColormap*)colormap, pixel, (GdkColor*)result1);
+ if (result) {
+ setGdkColorFields(env, result, result1, &PGLOB(GdkColorFc));
+ }
+}
/* ***** Visuals ***** */
@@ -950,6 +994,12 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1event_1key_1get
return (jint) (((GdkEventKey*)event) -> keyval);
}
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1event_1key_1get_1string
+ (JNIEnv *env, jclass that, jint event)
+{
+ return (jint) (((GdkEventKey*)event) -> string);
+}
+
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1event_1key_1get_1length
(JNIEnv *env, jclass that, jint event)
{
@@ -1141,3 +1191,26 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1window_1process
{
gdk_window_process_updates((GdkWindow*)window, (gboolean)update_children);
}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1pango_1context_1get
+ (JNIEnv *env, jclass that)
+{
+ return (jint)gdk_pango_context_get();
+}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1pointer_1grab
+ (JNIEnv *env, jclass that, jint window, jboolean owner_events, jint event_mask, jint confine_to, jint cursor, jint time)
+{
+ return (jint)gdk_pointer_grab((GdkWindow*) window,
+ (gboolean) owner_events,
+ (GdkEventMask) event_mask,
+ (GdkWindow*) confine_to,
+ (GdkCursor*) cursor,
+ (guint32) time);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1pointer_1ungrab
+ (JNIEnv *env, jclass that, jint time)
+{
+ gdk_pointer_ungrab((guint32) time);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtklists.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtklists.c
index 8508a7a871..2c104bc12a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtklists.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtklists.c
@@ -41,21 +41,21 @@ JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1ctree_1post_1re
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1clist_1get_1pixtext
- (JNIEnv *env, jclass that, jint clist, jint row, jint column, jintArray text, jintArray spacing, jintArray pixmap, jintArray mask)
+ (JNIEnv *env, jclass that, jint clist, jint row, jint column, jintArray text, jbyteArray spacing, jintArray pixmap, jintArray mask)
{
jint *text1 = NULL;
- jint *spacing1 = NULL;
+ jbyte *spacing1 = NULL;
jint *pixmap1 = NULL;
jint *mask1 = NULL;
int rc;
if (text) text1 = (*env)->GetIntArrayElements(env, text, NULL);
- if (spacing) spacing1 = (*env)->GetIntArrayElements(env, spacing, NULL);
+ if (spacing) spacing1 = (*env)->GetByteArrayElements(env, spacing, NULL);
if (pixmap) pixmap1 = (*env)->GetIntArrayElements(env, pixmap, NULL);
if (mask) mask1 = (*env)->GetIntArrayElements(env, mask, NULL);
rc = gtk_clist_get_pixtext((GtkCList*)clist, row, column, (gchar**)text1, (guint8*)spacing1, (GdkPixmap**)pixmap1, (GdkBitmap**)mask1);
if (text) (*env)->ReleaseIntArrayElements(env, text, text1, 0);
- if (spacing) (*env)->ReleaseIntArrayElements(env, spacing, spacing1, 0);
+ if (spacing) (*env)->ReleaseByteArrayElements(env, spacing, spacing1, 0);
if (pixmap) (*env)->ReleaseIntArrayElements(env, pixmap, pixmap1, 0);
if (mask) (*env)->ReleaseIntArrayElements(env, mask, mask1, 0);
@@ -609,6 +609,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1clist_1get_1tex
* Method: gtk_clist_set_pixmap
* Signature:
*/
+ /*
JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1clist_1set_1pixmap
(JNIEnv *env, jclass that, jint clist, jint row, jint column, jint pixmap, jint mask)
{
@@ -618,6 +619,7 @@ JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1clist_1set_1pix
gtk_clist_set_pixmap((GtkCList*)clist, (gint)row, (gint)column, (GdkPixmap*)pixmap, (GdkBitmap*)mask);
}
+*/
/*
* Class: org_eclipse_swt_internal_gtk_OS
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkmenu.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkmenu.c
index 6592ad34a3..efb0e18d9c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkmenu.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkmenu.c
@@ -94,7 +94,18 @@ JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1check_1menu_1it
gtk_check_menu_item_set_show_toggle((GtkCheckMenuItem*)menu_item, (gboolean)always);
}
+/*
+ * Class: org_eclipse_swt_internal_gtk_OS
+ * Method: gtk_check_menu_item_set_active
+ * Signature:
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1check_1menu_1item_1get_1active
+ (JNIEnv *env, jclass that, jint check_menu_item)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gtk_check_menu_item_set_active");
+#endif
-
-
+ return (jboolean) gtk_check_menu_item_get_active((GtkCheckMenuItem*)check_menu_item);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkwidget.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkwidget.c
index e5a63c1951..2d65fd09db 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkwidget.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkwidget.c
@@ -281,3 +281,332 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1widget_1get_1de
return (jint)gtk_widget_get_default_style();
}
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1widget_1get_1pango_1context
+ (JNIEnv *env, jclass that, jint widget)
+{
+ return (jint)gtk_widget_get_pango_context((GtkWidget *)widget);
+}
+
+/*
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1widget_1translate_1coordinates
+ (JNIEnv *env, jclass that, jint src_widget, jint dest_widget, jint src_x, jint src_y, jintArray dest_x, jintArray dest_y)
+{
+ jboolean result;
+ jint * dest_x1 = NULL;
+ jint * dest_y1 = NULL;
+ if (dest_x) {
+ dest_x1 = (*env)->GetIntArrayElements(env, dest_x, NULL);
+ }
+ if (dest_y) {
+ dest_y1 = (*env)->GetIntArrayElements(env, dest_y, NULL);
+ }
+ result = (jboolean) gtk_widget_translate_coordinates((GtkWidget*)src_widget, (GtkWidget*)dest_widget, (gint)src_x, (gint) src_y, (gint *)dest_x1, (gint *)dest_y1);
+ if (dest_x) {
+ (*env)->ReleaseIntArrayElements(env, dest_x, dest_x1, 0);
+ }
+ if (dest_y) {
+ (*env)->ReleaseIntArrayElements(env, dest_y, dest_y1, 0);
+ }
+ return result;
+}
+*/
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1widget_1set_1size_1request
+ (JNIEnv *env, jclass that, jint widget, jint width, jint height)
+{
+ gtk_widget_set_size_request((GtkWidget*)widget, (gint)width, (gint)height);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1widget_1get_1size_1request
+ (JNIEnv *env, jclass that, jint widget, jintArray width, jintArray height)
+{
+ jboolean result;
+ jint * width1 = NULL;
+ jint * height1 = NULL;
+ if (width) {
+ width1 = (*env)->GetIntArrayElements(env, width, NULL);
+ }
+ if (height) {
+ height1 = (*env)->GetIntArrayElements(env, height, NULL);
+ }
+ gtk_widget_get_size_request((GtkWidget*)widget, (gint *)width1, (gint *)height1);
+ if (width) {
+ (*env)->ReleaseIntArrayElements(env, width, width1, 0);
+ }
+ if (height) {
+ (*env)->ReleaseIntArrayElements(env, height, height1, 0);
+ }
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1widget_1get_1child_1requisition
+ (JNIEnv *env, jclass that, jint widget, jobject requisition)
+{
+ DECL_GLOB(pGlob)
+ GtkRequisition requisition_struct, *requisition1 = NULL;
+ if (requisition) {
+ requisition1 = &requisition_struct;
+ cacheGtkRequisitionFids(env, requisition, &PGLOB(GtkRequisitionFc));
+ getGtkRequisitionFields(env, requisition, requisition1, &PGLOB(GtkRequisitionFc));
+ }
+ gtk_widget_get_child_requisition((GtkWidget*)widget, (GtkRequisition*)requisition1);
+ if (requisition) {
+ setGtkRequisitionFields(env, requisition, requisition1, &PGLOB(GtkRequisitionFc));
+ }
+}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_GTK_1WIDGET_1X
+ (JNIEnv *env, jclass that, jint wid)
+{
+ return ((GtkWidget*)wid)->allocation.x;
+}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_GTK_1WIDGET_1Y
+ (JNIEnv *env, jclass that, jint wid)
+{
+ return ((GtkWidget*)wid)->allocation.y;
+}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_GTK_1WIDGET_1WIDTH
+ (JNIEnv *env, jclass that, jint wid)
+{
+ return ((GtkWidget*)wid)->allocation.width;
+}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_GTK_1WIDGET_1HEIGHT
+ (JNIEnv *env, jclass that, jint wid)
+{
+ return ((GtkWidget*)wid)->allocation.height;
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1container_1resize_1children
+ (JNIEnv *env, jclass that, jint container)
+{
+ gtk_container_resize_children((GtkContainer*)container);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1container_1set_1resize_1mode
+ (JNIEnv *env, jclass that, jint container, jint mode)
+{
+ gtk_container_set_resize_mode((GtkContainer*)container, (gint)mode);
+}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1fixed_1new
+ (JNIEnv *env, jclass that)
+{
+ return (jint)gtk_fixed_new();
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1fixed_1move
+ (JNIEnv *env, jclass that, jint fixed, jint child, jint x, jint y)
+{
+ gtk_fixed_move((GtkFixed*)fixed, (GtkWidget*)child, (gint)x, (gint)y);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1fixed_1set_1has_1window
+ (JNIEnv *env, jclass that, jint fixed, jboolean has_window)
+{
+ gtk_fixed_set_has_window((GtkFixed*)fixed, (gboolean)has_window);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1scrolled_1window_1add_1with_1viewport
+ (JNIEnv *env, jclass that, jint scrolled_window, jint child)
+{
+ gtk_scrolled_window_add_with_viewport((GtkScrolledWindow*)scrolled_window, (GtkWidget*)child);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_GTK_1BIN_1SET_1CHILD
+ (JNIEnv *env, jclass that, jint bin, jint child)
+{
+ ((GtkBin*)bin)->child = (GtkWidget*)child;
+}
+
+JNIEXPORT jdouble JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1adjustment_1get_1value
+ (JNIEnv *env, jclass that, jint widget)
+{
+ return (jdouble)gtk_adjustment_get_value((GtkAdjustment*)widget);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1widget_1modify_1bg
+ (JNIEnv *env, jclass that, jint widget, jint state, jobject color)
+{
+ DECL_GLOB(pGlob)
+ GdkColor color_struct, *color1 = NULL;
+ if (color) {
+ color1 = &color_struct;
+ cacheGdkColorFids(env, color, &PGLOB(GdkColorFc));
+ getGdkColorFields(env, color, color1, &PGLOB(GdkColorFc));
+ }
+ gtk_widget_modify_bg((GtkWidget*)widget, (GtkStateType)state, (GdkColor*)color1);
+ if (color) {
+ setGdkColorFields(env, color, color1, &PGLOB(GdkColorFc));
+ }
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1scrolled_1window_1set_1shadow_1type
+ (JNIEnv *env, jclass that, jint scroll, jint type)
+{
+ gtk_scrolled_window_set_shadow_type((GtkScrolledWindow*)scroll, (GtkShadowType)type);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1text_1set_1editable
+ (JNIEnv *env, jclass that, jint entry, jboolean editable)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gtk_text_set_editable");
+#endif
+
+ gtk_text_set_editable((GtkEntry*)entry, (gboolean)editable);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1widget_1queue_1resize
+ (JNIEnv *env, jclass that, jint widget)
+{
+ gtk_widget_queue_resize((GtkWidget*)widget);
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_gtk_OS
+ * Method: gtk_editable_select_region
+ * Signature:
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1editable_1select_1region
+ (JNIEnv *env, jclass that, jint editable, jint start, jint end)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gtk_editable_select_region");
+#endif
+
+ gtk_editable_select_region((GtkEditable*)editable, (gint)start, (gint)end);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_gtk_OS
+ * Method: gtk_editable_insert_text
+ * Signature:
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1editable_1insert_1text
+ (JNIEnv *env, jclass that, jint editable, jbyteArray new_text, jint new_text_length, jintArray position)
+{
+ jbyte *new_text1 = NULL;
+ jint *position1 = NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gtk_editable_insert_text");
+#endif
+
+ if (new_text) {
+ new_text1 = (*env)->GetByteArrayElements(env, new_text, NULL);
+ }
+ if (position) {
+ position1 = (*env)->GetIntArrayElements(env, position, NULL);
+ }
+ gtk_editable_insert_text((GtkEditable*)editable, (gchar*)new_text1, (gint)new_text_length, (gint*)position1);
+ if (new_text) {
+ (*env)->ReleaseByteArrayElements(env, new_text, new_text1, 0);
+ }
+ if (position) {
+ (*env)->ReleaseIntArrayElements(env, position, position1, 0);
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_gtk_OS
+ * Method: gtk_editable_delete_text
+ * Signature:
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1editable_1delete_1text
+ (JNIEnv *env, jclass that, jint editable, jint start_pos, jint end_pos)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gtk_editable_delete_text");
+#endif
+
+ gtk_editable_delete_text((GtkEditable*)editable, (gint)start_pos, (gint)end_pos);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_gtk_OS
+ * Method: gtk_editable_get_chars
+ * Signature:
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1editable_1get_1chars
+ (JNIEnv *env, jclass that, jint editable, jint start_pos, jint end_pos)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gtk_editable_get_chars");
+#endif
+
+ return (jint)gtk_editable_get_chars((GtkEditable*)editable, (gint)start_pos, (gint)end_pos);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_gtk_OS
+ * Method: gtk_editable_delete_selection
+ * Signature:
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1editable_1delete_1selection
+ (JNIEnv *env, jclass that, jint editable)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gtk_editable_delete_selection");
+#endif
+
+ gtk_editable_delete_selection((GtkEditable*)editable);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_gtk_OS
+ * Method: gtk_editable_set_position
+ * Signature:
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1editable_1set_1position
+ (JNIEnv *env, jclass that, jint editable, jint position)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gtk_editable_set_position");
+#endif
+
+ gtk_editable_set_position((GtkEditable*)editable, (gint)position);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_gtk_OS
+ * Method: gtk_editable_get_position
+ * Signature:
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1editable_1get_1position
+ (JNIEnv *env, jclass that, jint editable)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gtk_editable_get_position");
+#endif
+
+ return (jint)gtk_editable_get_position((GtkEditable*)editable);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_gtk_OS
+ * Method: gtk_editable_set_editable
+ * Signature:
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1editable_1set_1editable
+ (JNIEnv *env, jclass that, jint editable, jboolean is_editable)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gtk_editable_set_editable");
+#endif
+
+ gtk_editable_set_editable((GtkEditable*)editable, (gboolean)is_editable);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1widget_1set_1redraw_1on_1allocate
+ (JNIEnv *env, jclass that, jint widget, jboolean redraw)
+{
+ gtk_widget_set_redraw_on_allocate((GtkWidget*)widget, (gboolean)redraw);
+}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_GTK_1WIDGET_1MAPPED
+ (JNIEnv *env, jclass that, jint wid)
+{
+ return GTK_WIDGET_MAPPED((GtkWidget*)wid);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkwindow.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkwindow.c
index 0e2b5d2c5f..39279e3354 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkwindow.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gtkwindow.c
@@ -355,3 +355,9 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_GTK_1FONT_1SELECTION
*/
return (jint) (((GtkFontSelectionDialog*)fsd)->cancel_button);
}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1window_1set_1default
+ (JNIEnv *env, jclass that, jint window, jint widget)
+{
+ gtk_window_set_default((GtkWindow*)window, (GtkWidget*)widget);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-pango.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-pango.c
index 286e09fe1f..647c9669bb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-pango.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-pango.c
@@ -54,6 +54,12 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_PANGO_1SCALE
return (jint)PANGO_SCALE;
}
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_PANGO_1PIXELS
+ (JNIEnv *env, jclass that, jint dimension)
+{
+ return (jint)PANGO_PIXELS(dimension);
+}
+
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_PANGO_1STRETCH_1NORMAL
(JNIEnv *env, jclass that)
{
@@ -72,27 +78,23 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_pango_1font_1descrip
}
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_pango_1font_1description_1from_1string
- (JNIEnv *env, jclass that, jstring str)
+ (JNIEnv *env, jclass that, jbyteArray str)
{
- const jbyte *str1 = NULL;
+ jbyte *str1 = NULL;
jint rc;
- if (str != NULL) str1 = (*env)->GetStringUTFChars(env, str, NULL);
+ if (str != NULL) str1 = (*env)->GetByteArrayElements(env, str, NULL);
rc = (jint)pango_font_description_from_string(str1);
- if (str != NULL) (*env)->ReleaseStringUTFChars(env, str, str1);
+ if (str != NULL) (*env)->ReleaseByteArrayElements(env, str, str1, 0);
return rc;
}
-JNIEXPORT jstring JNICALL
+JNIEXPORT jint JNICALL
Java_org_eclipse_swt_internal_gtk_OS_pango_1font_1description_1to_1string
(JNIEnv *env, jclass that, jint descr)
{
- jstring rc;
- char *canswer = pango_font_description_to_string((PangoFontDescription*)descr);
- rc = (*env)->NewStringUTF(env, canswer);
- g_free(canswer);
- return rc;
+ return (jint)pango_font_description_to_string((PangoFontDescription*)descr);
}
JNIEXPORT jboolean JNICALL
@@ -109,24 +111,22 @@ Java_org_eclipse_swt_internal_gtk_OS_pango_1font_1description_1free
pango_font_description_free((PangoFontDescription*)descr);
}
-JNIEXPORT jstring JNICALL
+JNIEXPORT jint JNICALL
Java_org_eclipse_swt_internal_gtk_OS_pango_1font_1description_1get_1family
(JNIEnv *env, jclass that, jint descr)
{
- const char *canswer = pango_font_description_get_family((PangoFontDescription*)descr);
- return (*env)->NewStringUTF(env, canswer);
- /* don't free */
+ return (jint)pango_font_description_get_family((PangoFontDescription*)descr);
}
JNIEXPORT void JNICALL
Java_org_eclipse_swt_internal_gtk_OS_pango_1font_1description_1set_1family
(JNIEnv *env, jclass that, jint descr, jstring family)
{
- const jbyte *family1 = NULL;
+ jbyte *family1 = NULL;
- if (family != NULL) family1 = (*env)->GetStringUTFChars(env, family, NULL);
+ if (family != NULL) family1 = (*env)->GetByteArrayElements(env, family, NULL);
pango_font_description_set_family((PangoFontDescription*)descr, family1);
- if (family != NULL) (*env)->ReleaseStringUTFChars(env, family, family1);
+ if (family != NULL) (*env)->ReleaseByteArrayElements(env, family, family1, 0);
}
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_pango_1font_1description_1get_1size
@@ -191,10 +191,16 @@ JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_pango_1context_1set_
pango_context_set_font_description((PangoContext*)context, (PangoFontDescription*)descr);
}
-JNIEXPORT int JNICALL Java_org_eclipse_swt_internal_gtk_OS_pango_1context_1get_1metrics
- (JNIEnv *env, jclass that, jint context, jint descr)
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_pango_1context_1get_1metrics
+ (JNIEnv *env, jclass that, jint context, jint descr, jint language)
+{
+ return (jint)pango_context_get_metrics((PangoContext*)context, (PangoFontDescription*)descr, (PangoLanguage*)language);
+}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_pango_1context_1get_1language
+ (JNIEnv *env, jclass that, jint context)
{
- return (jint)pango_context_get_metrics((PangoContext*)context, (PangoFontDescription*)descr, NULL);
+ return (jint)pango_context_get_language((PangoContext*)context);
}
/* metrics */
@@ -217,3 +223,76 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_pango_1font_1metrics
return (jint)pango_font_metrics_get_approximate_char_width((PangoFontMetrics*)metrics);
}
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_pango_1layout_1new
+ (JNIEnv *env, jclass that, jint context)
+{
+ return (jint)pango_layout_new((PangoContext*)context);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_pango_1layout_1set_1text
+ (JNIEnv *env, jclass that, jint layout, jbyteArray text, jint length)
+{
+ jbyte *text1 = NULL;
+
+ if (text != NULL) text1 = (*env)->GetByteArrayElements(env, text, NULL);
+ pango_layout_set_text((PangoLayout*)layout, (const char *)text1, length);
+ if (text != NULL) (*env)->ReleaseByteArrayElements(env, text, text1, 0);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_pango_1layout_1get_1size
+ (JNIEnv *env, jclass that, jint layout, jintArray width, jintArray height)
+{
+ jint *width1 = NULL;
+ jint *height1 = NULL;
+
+ if (width != NULL) width1 = (*env)->GetIntArrayElements(env, width, NULL);
+ if (height != NULL) height1 = (*env)->GetIntArrayElements(env, height, NULL);
+ pango_layout_get_size((PangoLayout*)layout, (int *)width1, (int *)height1);
+ if (width != NULL) (*env)->ReleaseIntArrayElements(env, width, width1, 0);
+ if (height != NULL) (*env)->ReleaseIntArrayElements(env, height, height1, 0);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_pango_1context_1list_1families
+ (JNIEnv *env, jclass that, jint context, jintArray families, jintArray n_families)
+{
+ jint *families1 = NULL;
+ jint *n_families1 = NULL;
+
+ if (families != NULL) families1 = (*env)->GetIntArrayElements(env, families, NULL);
+ if (n_families != NULL) n_families1 = (*env)->GetIntArrayElements(env, n_families, NULL);
+ pango_context_list_families((PangoContext*)context, (PangoFontFamily***)families1, (int *)n_families1);
+ if (families != NULL) (*env)->ReleaseIntArrayElements(env, families, families1, 0);
+ if (n_families != NULL) (*env)->ReleaseIntArrayElements(env, n_families, n_families1, 0);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_pango_1font_1family_1list_1faces
+ (JNIEnv *env, jclass that, jint family, jintArray faces, jintArray n_faces)
+{
+ jint *faces1 = NULL;
+ jint *n_faces1 = NULL;
+
+ if (faces != NULL) faces1 = (*env)->GetIntArrayElements(env, faces, NULL);
+ if (n_faces != NULL) n_faces1 = (*env)->GetIntArrayElements(env, n_faces, NULL);
+ pango_font_family_list_faces((PangoFontFamily*)family, (PangoFontFace***)faces1, (int *)n_faces1);
+ if (faces != NULL) (*env)->ReleaseIntArrayElements(env, faces, faces1, 0);
+ if (n_faces != NULL) (*env)->ReleaseIntArrayElements(env, n_faces, n_faces1, 0);
+}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_pango_1font_1face_1describe
+ (JNIEnv *env, jclass that, jint face)
+{
+ return (jint)pango_font_face_describe((PangoFontFace*)face);
+}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_pango_1language_1from_1string
+ (JNIEnv *env, jclass that, jbyteArray language)
+{
+ jbyte *language1 = NULL;
+ jint rc;
+
+ if (language != NULL) language1 = (*env)->GetByteArrayElements(env, language, NULL);
+ rc = (jint)pango_language_from_string((const char *)language1);
+ if (language != NULL) (*env)->ReleaseByteArrayElements(env, language, language1, 0);
+ return rc;
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt.c
index 46d184a194..29beaf1716 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt.c
@@ -1168,33 +1168,59 @@ JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1style_1unref
gtk_style_unref((GtkStyle*)style);
}
+
/*
- * Class: org_eclipse_swt_internal_gtk_OS
- * Method: gtk_text_new
- * Signature:
+ * GtkEditable
*/
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1text_1new
- (JNIEnv *env, jclass that, jint hadj, jint vadj)
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1editable_1get_1selection_1start
+ (JNIEnv *env, jclass that, jint editable)
{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "gtk_text_new");
-#endif
+ return (jint)gtk_editable_get_selection_start((GtkEditable*)editable);
+}
- return (jint)gtk_text_new((GtkAdjustment*)hadj, (GtkAdjustment*)vadj);
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1editable_1get_1selection_1end
+ (JNIEnv *env, jclass that, jint editable)
+{
+ return (jint)gtk_editable_get_selection_end((GtkEditable*)editable);
+}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1editable_1get_1editable
+ (JNIEnv *env, jclass that, jint editable)
+{
+ return gtk_editable_get_editable ((GtkEditable*)editable);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1editable_1copy_1clipboard
+ (JNIEnv *env, jclass that, jint editable)
+{
+ gtk_editable_copy_clipboard((GtkEditable*)editable);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1editable_1cut_1clipboard
+ (JNIEnv *env, jclass that, jint editable)
+{
+ gtk_editable_cut_clipboard((GtkEditable*)editable);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1editable_1paste_1clipboard
+ (JNIEnv *env, jclass that, jint editable)
+{
+ gtk_editable_paste_clipboard((GtkEditable*)editable);
}
+
/*
- * Class: org_eclipse_swt_internal_gtk_OS
- * Method: gtk_text_set_word_wrap
- * Signature:
+ * GtkText
*/
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1text_1new
+ (JNIEnv *env, jclass that, jint hadj, jint vadj)
+{
+ return (jint)gtk_text_new((GtkAdjustment*)hadj, (GtkAdjustment*)vadj);
+}
+
JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1text_1set_1word_1wrap
(JNIEnv *env, jclass that, jint text, jint word_wrap)
{
-#ifdef DEBUG_CALL_PRINTS
- fprintf(stderr, "gtk_text_set_word_wrap");
-#endif
-
gtk_text_set_word_wrap((GtkText*)text, (gint)word_wrap);
}
@@ -1726,3 +1752,17 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_XListFonts
return rc;
}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_g_1signal_1connect_1swapped
+ (JNIEnv *env, jclass that, jint instance, jbyteArray detailed_signal, jint c_handler, jint data)
+{
+ jint rc;
+ jbyte *detailed_signal1 = NULL;
+ if (detailed_signal) detailed_signal1 = (*env)->GetByteArrayElements(env, detailed_signal, NULL);
+
+ rc = (jint)gtk_signal_connect((gpointer)instance, (const char*)detailed_signal1, (GCallback)c_handler, (gpointer)data);
+
+ if (detailed_signal) (*env)->ReleaseByteArrayElements(env, detailed_signal, detailed_signal1, 0);
+ return rc;
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkText.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkText.java
deleted file mode 100644
index 005e7e62e9..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GtkText.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.eclipse.swt.internal.gtk;
-
-/*
- * Copyright (c) IBM Corp. 2000, 2001. All rights reserved.
- *
- * The contents of this file are made available under the terms
- * of the GNU Lesser General Public License (LGPL) Version 2.1 that
- * accompanies this distribution (lgpl-v21.txt). The LGPL is also
- * available at http://www.gnu.org/licenses/lgpl.html. If the version
- * of the LGPL at http://www.gnu.org is different to the version of
- * the LGPL accompanying this distribution and there is any conflict
- * between the two license versions, the terms of the LGPL accompanying
- * this distribution shall govern.
- */
-
-public class GtkText {
- public int first_line_start_index;
- public int first_onscreen_hor_pixel;
- public int first_onscreen_ver_pixel;
- public int default_tab_width;
- public int cursor_pos_x;
- public int cursor_pos_y;
- public int cursor_virtual_x;
-
- private GtkText() {}
- public GtkText(int ptr) {
-// OS.memmove(this, ptr);
- }
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
index 339dbbcac8..2a2735bf79 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
@@ -156,29 +156,52 @@ public class OS {
public static final int GDK_KEY_PRESS = 8;
public static final int GDK_KEY_RELEASE = 9;
public static final int GDK_NO_EXPOSE = 30;
- public static final int GDK_EXPOSURE_MASK = 1 << 1;
- public static final int GDK_POINTER_MOTION_MASK = 1 << 2;
+
+ /* The values for the GdkModifierType constants are specified in the
+ * documentation, therefore there is no need to get them from the OS.
+ */
+ public static final int GDK_SHIFT_MASK = 1 << 0;
+ public static final int GDK_LOCK_MASK = 1 << 1;
+ public static final int GDK_CONTROL_MASK = 1 << 2;
+ public static final int GDK_MOD1_MASK = 1 << 3;
+ public static final int GDK_MOD2_MASK = 1 << 4;
+ public static final int GDK_MOD3_MASK = 1 << 5;
+ public static final int GDK_MOD4_MASK = 1 << 6;
+ public static final int GDK_MOD5_MASK = 1 << 7;
+ public static final int GDK_BUTTON1_MASK = 1 << 8;
+ public static final int GDK_BUTTON2_MASK = 1 << 9;
+ public static final int GDK_BUTTON3_MASK = 1 << 10;
+ public static final int GDK_BUTTON4_MASK = 1 << 11;
+ public static final int GDK_BUTTON5_MASK = 1 << 12;
+ public static final int GDK_RELEASE_MASK = 1 << 30;
+ public static final int GDK_MODIFIER_MASK = GDK_RELEASE_MASK | 0x1fff;
+
+ /* The values for the GdkEventMask constants are specified in the
+ * documentation, therefore there is no need to get them from the OS.
+ */
+ public static final int GDK_EXPOSURE_MASK = 1 << 1;
+ public static final int GDK_POINTER_MOTION_MASK = 1 << 2;
public static final int GDK_POINTER_MOTION_HINT_MASK = 1 << 3;
- public static final int GDK_BUTTON_MOTION_MASK = 1 << 4;
- public static final int GDK_BUTTON1_MOTION_MASK = 1 << 5;
- public static final int GDK_BUTTON2_MOTION_MASK = 1 << 6;
- public static final int GDK_BUTTON3_MOTION_MASK = 1 << 7;
- public static final int GDK_BUTTON_PRESS_MASK = 1 << 8;
- public static final int GDK_BUTTON_RELEASE_MASK = 1 << 9;
- public static final int GDK_KEY_PRESS_MASK = 1 << 10;
- public static final int GDK_KEY_RELEASE_MASK = 1 << 11;
- public static final int GDK_ENTER_NOTIFY_MASK = 1 << 12;
- public static final int GDK_LEAVE_NOTIFY_MASK = 1 << 13;
- public static final int GDK_FOCUS_CHANGE_MASK = 1 << 14;
- public static final int GDK_SHIFT_MASK = 1 << 0;
- public static final int GDK_LOCK_MASK = 1 << 1;
- public static final int GDK_CONTROL_MASK = 1 << 2;
- public static final int GDK_MOD1_MASK = 1 << 3;
- public static final int GDK_BUTTON1_MASK = 1 << 8;
- public static final int GDK_BUTTON2_MASK = 1 << 9;
- public static final int GDK_BUTTON3_MASK = 1 << 10;
- public static final int GDK_RELEASE_MASK = 1 << 13;
- public static final int GDK_MODIFIER_MASK = 0x3fff;
+ public static final int GDK_BUTTON_MOTION_MASK = 1 << 4;
+ public static final int GDK_BUTTON1_MOTION_MASK = 1 << 5;
+ public static final int GDK_BUTTON2_MOTION_MASK = 1 << 6;
+ public static final int GDK_BUTTON3_MOTION_MASK = 1 << 7;
+ public static final int GDK_BUTTON_PRESS_MASK = 1 << 8;
+ public static final int GDK_BUTTON_RELEASE_MASK = 1 << 9;
+ public static final int GDK_KEY_PRESS_MASK = 1 << 10;
+ public static final int GDK_KEY_RELEASE_MASK = 1 << 11;
+ public static final int GDK_ENTER_NOTIFY_MASK = 1 << 12;
+ public static final int GDK_LEAVE_NOTIFY_MASK = 1 << 13;
+ public static final int GDK_FOCUS_CHANGE_MASK = 1 << 14;
+ public static final int GDK_STRUCTURE_MASK = 1 << 15;
+ public static final int GDK_PROPERTY_CHANGE_MASK = 1 << 16;
+ public static final int GDK_VISIBILITY_NOTIFY_MASK = 1 << 17;
+ public static final int GDK_PROXIMITY_IN_MASK = 1 << 18;
+ public static final int GDK_PROXIMITY_OUT_MASK = 1 << 19;
+ public static final int GDK_SUBSTRUCTURE_MASK = 1 << 20;
+ public static final int GDK_SCROLL_MASK = 1 << 21;
+ public static final int GDK_ALL_EVENTS_MASK = 0x3FFFFE;
+
public static final int GDK_INCLUDE_INFERIORS = 1;
public static final int GDK_DECOR_ALL = 1 << 0;
public static final int GDK_DECOR_BORDER = 1 << 1;
@@ -241,6 +264,7 @@ public class OS {
public static final int GTK_SENSITIVE = 1 << 9;
public static final int GTK_CAN_FOCUS = 1 << 11;
public static final int GTK_HAS_FOCUS = 1 << 12;
+ public static final int GTK_CAN_DEFAULT = 1 << 13;
public static final int GTK_CLIST_SHOW_TITLES = 1 << 2;
public static final int GTK_PROGRESS_CONTINUOUS = 0;
public static final int GTK_PROGRESS_DISCRETE = 1;
@@ -248,6 +272,16 @@ public class OS {
public static final int GTK_PROGRESS_RIGHT_TO_LEFT = 1;
public static final int GTK_PROGRESS_BOTTOM_TO_TOP = 2;
public static final int GTK_PROGRESS_TOP_TO_BOTTOM = 3;
+
+ /* The values for the GdkGrabStatus constants are specified in
+ * the documentation, therefore there is no need to get them from the OS.
+ */
+ public static final int GDK_GRAB_SUCCESS = 0;
+ public static final int GDK_GRAB_ALREADY_GRABBED = 1;
+ public static final int GDK_GRAB_INVALID_TIME = 2;
+ public static final int GDK_GRAB_NOT_VIEWABLE = 3;
+ public static final int GDK_GRAB_FROZEN = 4;
+
public static final native int GTK_TOOLBAR_CHILD_SPACE();
public static final native int GTK_TOOLBAR_CHILD_BUTTON();
@@ -335,13 +369,13 @@ public static final native void gtk_check_menu_item_set_active(int wid, boolean
/* Containers */
-public static final native int eclipse_fixed_new();
-public static final native void eclipse_fixed_get_location(int fixed, int child, int[] loc);
-public static final native boolean eclipse_fixed_get_size(int fixed, int child, int[] sz);
-public static final native void eclipse_fixed_set_location(int fixed, int child, int x, int y);
-public static final native void eclipse_fixed_set_size(int fixed, int child, int width, int height);
-public static final native void eclipse_fixed_move_above(int fixed, int child, int sibling);
-public static final native void eclipse_fixed_move_below(int fixed, int child, int sibling);
+//public static final native int eclipse_fixed_new();
+//public static final native void eclipse_fixed_get_location(int fixed, int child, int[] loc);
+//public static final native boolean eclipse_fixed_get_size(int fixed, int child, int[] sz);
+//public static final native void eclipse_fixed_set_location(int fixed, int child, int x, int y);
+//public static final native void eclipse_fixed_set_size(int fixed, int child, int width, int height);
+//public static final native void eclipse_fixed_move_above(int fixed, int child, int sibling);
+//public static final native void eclipse_fixed_move_below(int fixed, int child, int sibling);
/* GDK */
@@ -384,6 +418,7 @@ public static final native int gdk_colormap_get_system();
public static final native void gdk_colors_free(int colormap, int[] pixels, int npixels, int planes);
public static final native boolean gdk_color_alloc(int colormap, GdkColor color);
public static final native boolean gdk_colormap_alloc_color(int colormap, GdkColor color, boolean writeable, boolean best_match);
+public static final native void gdk_colormap_query_color(int colormap, int pixel, GdkColor result);
public static final native void gdk_colormap_free_colors(int colormap, GdkColor colors, int ncolors);
public static final native int gdk_cursor_new(int cursor_type);
public static final native int gdk_bitmap_create_from_data(int window, byte[] data, int width, int height);
@@ -411,6 +446,8 @@ public static final native void gdk_gc_set_function(int gc, int function);
public static final native void gdk_draw_line(int drawable, int gc, int x1, int y1, int x2, int y2);
public static final native void gdk_draw_arc(int drawable, int gc, int filled, int x, int y, int width, int height, int angle1, int angle2);
public static final native void gdk_draw_drawable(int drawable, int gc, int src, int xsrc, int ysrc, int xdest, int ydest, int width, int height);
+public static final native void gdk_draw_layout(int drawable, int gc, int x, int y, int layout);
+public static final native void gdk_draw_layout_with_colors(int drawable, int gc, int x, int y, int layout, GdkColor foreground, GdkColor background);
public static final native void gdk_draw_rectangle(int drawable, int gc, int filled, int x, int y, int width, int height);
public static final native void gdk_draw_lines(int drawable, int gc, int[] points, int npoints);
public static final native void gdk_draw_polygon(int drawable, int gc, int filled, int[] points, int npoints);
@@ -433,7 +470,7 @@ public static final native boolean gdk_event_get_coords(int event, double[] px,
public static final native boolean gdk_event_get_root_coords(int event, double[] px, double[] py);
public static final native int gdk_event_key_get_keyval(int event);
public static final native int gdk_event_key_get_length(int event);
-public static final native String gdk_event_key_get_string(int event);
+public static final native int gdk_event_key_get_string(int event);
public static final native int gdk_event_button_get_button(int event);
@@ -508,7 +545,7 @@ public static final native void gtk_clist_column_title_passive(int clist, int co
public static final native void gtk_clist_column_titles_show(int clist);
public static final native void gtk_clist_column_titles_hide(int clist);
public static final native void gtk_clist_freeze(int clist);
-public static final native void gtk_clist_get_pixtext(int clist, int row, int column, int[] text, int[] spacing, int[] pixmap, int[] mask);
+public static final native void gtk_clist_get_pixtext(int clist, int row, int column, int[] text, byte[] spacing, int[] pixmap, int[] mask);
public static final native void gtk_check_menu_item_set_show_toggle(int menu_item, boolean always);
public static final native void gtk_clist_column_titles_passive(int clist);
public static final native int gtk_clist_insert(int clist, int row, int[] text);
@@ -526,7 +563,7 @@ public static final native void gtk_clist_set_column_justification(int clist, in
public static final native void gtk_clist_set_column_resizeable(int clist, int column, boolean resizeable);
public static final native void gtk_clist_set_column_width(int clist, int column, int width);
public static final native void gtk_clist_set_pixtext(int clist, int row, int column, byte[] text, byte spacing, int pixmap, int mask);
-public static final native void gtk_clist_set_pixmap(int clist, int row, int column, int pixmap, int mask);
+//public static final native void gtk_clist_set_pixmap(int clist, int row, int column, int pixmap, int mask);
public static final native void gtk_container_add(int container, int widget);
public static final native int gtk_container_children(int container);
public static final native int gtk_color_selection_dialog_new(byte[] title);
@@ -562,6 +599,13 @@ public static final native void gtk_ctree_set_node_info(int ctree, int node, byt
public static final native int gtk_drawing_area_new();
public static final native int gtk_dialog_new();
public static final native int gtk_event_box_new();
+
+public static final native int gtk_editable_get_selection_start(int editable);
+public static final native int gtk_editable_get_selection_end(int editable);
+public static final native boolean gtk_editable_get_editable(int editable);
+public static final native void gtk_editable_copy_clipboard(int editable);
+public static final native void gtk_editable_cut_clipboard(int editable);
+public static final native void gtk_editable_paste_clipboard(int editable);
public static final native int gtk_editable_get_position(int editable);
public static final native void gtk_editable_set_position(int editable, int position);
public static final native void gtk_entry_set_editable(int entry, boolean editable);
@@ -579,7 +623,7 @@ public static final native void gtk_file_selection_complete(int filesel, byte[]
public static final native int gtk_font_selection_dialog_get_font_name(int fsd);
public static final native int gtk_font_selection_dialog_new(byte[] title);
public static final native boolean gtk_font_selection_dialog_set_font_name(int fsd, byte[] fontname);
-public static final native void gtk_editable_set_editable(int editable, boolean is_editable);
+public static final native void gtk_text_set_editable(int editable, boolean is_editable);
public static final native int gtk_entry_new();
public static final native void gtk_entry_append_text(int entry, byte[] text);
public static final native void gtk_editable_delete_selection(int editable);
@@ -676,6 +720,7 @@ public static final native int gtk_vbox_new(boolean homogeneous, int spacing);
public static final native int gtk_vscale_new(int adjustment);
public static final native int gtk_vscrollbar_new(int adjustment);
public static final native void gtk_tooltips_set_tip(int tooltips, int widget, byte[] tip_text, byte[] tip_private);
+public static final native int gtk_widget_get_pango_context(int widget);
public static final native int gtk_widget_get_default_style();
public static final native void gtk_widget_add_events(int widget, int events);
public static final native void gtk_widget_destroy(int widget);
@@ -739,19 +784,29 @@ public static final native int PANGO_STRETCH_NORMAL();
public static final native int PANGO_PIXELS(int dimension);
-public static final native int pango_context_new();
-public static final native int pango_context_get_font_description(int context);
+public static final native int gdk_pango_context_get();
+public static final native int pango_context_new();
+public static final native int pango_context_get_font_description(int context);
public static final native void pango_context_set_font_description(int context, int descr);
-public static final native int pango_context_get_metrics(int context, int desc, String language);
+public static final native int pango_context_get_metrics(int context, int desc, int language);
+public static final native int pango_context_get_language(int context);
+public static final native void pango_context_list_families(int context, int[] families, int[] n_families);
+public static final native void pango_font_family_list_faces(int family, int[] faces, int[] n_faces);
+public static final native int pango_font_face_describe(int face);
+
+public static final native int pango_language_from_string(byte[] language);
+public static final native int pango_layout_new(int context);
+public static final native void pango_layout_set_text(int layout, byte[] text, int length);
+public static final native void pango_layout_get_size(int layout, int[] width, int[] height);
public static final native int pango_font_description_new();
-public static final native int pango_font_description_from_string(String str);
-public static final native String pango_font_description_to_string(int desc);
+public static final native int pango_font_description_from_string(byte[] str);
+public static final native int pango_font_description_to_string(int desc);
public static final native boolean pango_font_description_equal(int desc1, int desc2);
public static final native void pango_font_description_free(int desc);
-public static final native String pango_font_description_get_family(int desc);
-public static final native void pango_font_description_set_family(int desc, String style);
+public static final native int pango_font_description_get_family(int desc);
+public static final native void pango_font_description_set_family(int desc, byte[] family);
public static final native int pango_font_description_get_size(int desc);
public static final native void pango_font_description_set_size(int desc, int size);
public static final native void pango_font_description_set_stretch(int desc, int stretch);
@@ -839,7 +894,6 @@ static final native void memmove(GtkCTree dest, int src);
/* Write memmoves */
public static final native void memmove(int dest, GtkEditable src, int size);
-public static final native void memmove(int dest, GtkText src, int size);
public static final native void memmove(int dest, GtkStyle src, int size);
public static final native void memmove(int dest, GtkAdjustment src); // sure needed
public static final native void memmove(int dest, GtkCListColumn src, int size);
@@ -852,4 +906,28 @@ public static final native void gdk_window_process_updates(int window, boolean u
public static final native void gtk_label_set_text_with_mnemonic(int label, byte[] str);
public static final native int gtk_label_new_with_mnemonic(byte[] str);
public static final native int gtk_frame_get_label_widget(int frame);
+
+public static final native void gtk_widget_set_size_request(int widget, int width, int height);
+public static final native void gtk_widget_get_size_request(int widget, int [] width, int [] height);
+public static final native void gtk_widget_get_child_requisition(int widget, GtkRequisition requisition);
+public static final native int GTK_WIDGET_X(int wid);
+public static final native int GTK_WIDGET_Y(int wid);
+public static final native int GTK_WIDGET_WIDTH(int wid);
+public static final native int GTK_WIDGET_HEIGHT(int wid);
+public static final native void gtk_container_resize_children(int container);
+public static final native void gtk_container_set_resize_mode(int container, int mode);
+public static final native int gtk_fixed_new();
+public static final native void gtk_fixed_move(int fixed, int widget, int x, int y);
+public static final native void gtk_fixed_set_has_window(int fixed, boolean has_window);
+public static final native void gtk_scrolled_window_add_with_viewport (int scrolled_window, int child);
+public static final native void gtk_widget_modify_bg (int widget, int state, GdkColor color);
+public static final native void GTK_BIN_SET_CHILD (int bin, int child);
+public static final native void gtk_scrolled_window_set_shadow_type(int scrolled_window, int type);
+public static final native void gtk_widget_queue_resize(int widget);
+public static final native void memmove(GtkAllocation dest, int src);
+public static final native void gtk_widget_set_redraw_on_allocate(int widget, boolean redraw);
+public static final native int gdk_pointer_grab(int window, boolean owner_events, int event_mask, int confine_to, int cursor, int time);
+public static final native int gdk_pointer_ungrab(int time);
+public static final native int g_signal_connect_swapped(int instance, byte[] detailed_sigal, int c_handler, int data);
+public static final native void gtk_window_set_default(int window, int widget);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/make_aix.mak b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/make_aix.mak
index ffe63f534e..b32e3106a9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/make_aix.mak
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/library/make_aix.mak
@@ -10,10 +10,10 @@ SWT_VERSION=$(maj_ver)$(min_ver)
CC=cc_r
# Define the installation directories for various products.
-# IVE_HOME - IBM's version of Java (J9)
+# JAVA_HOME - IBM's version of Java
# CDE_HOME - CDE includes and libraries
# MOTIF_HOME - Motif includes and libraries
-IVE_HOME = /bluebird/teamswt/swt-builddir/ive/bin
+JAVA_HOME = /usr/java131
MOTIF_HOME = /bluebird/teamswt/swt-builddir/motif21
CDE_HOME = /usr/dt
@@ -21,14 +21,14 @@ CDE_HOME = /usr/dt
SWT_PREFIX = swt
WS_PREFIX = motif
-SWT_DLL = lib$(SWT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+SWT_DLL = lib$(SWT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).a
SWT_OBJ = callback.o structs.o swt.o
-SWT_LIB = -L$(MOTIF_HOME) -G -bnoentry -lc_r -lC_r -lm -bexpall -lXm -lMrm -lXt -lX11 -lXext
+SWT_LIB = -L$(MOTIF_HOME) -G -bnoentry -lc_r -lC_r -lm -bexpall -lXm -lMrm -lXt -lX11 -lXext -liconv
CDE_PREFIX = swt-cde
-CDE_DLL = lib$(CDE_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+CDE_DLL = lib$(CDE_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).a
CDE_OBJ = cde.o
-CDE_LIB = -L$(CDE_HOME)/lib -G -lc -bnoentry -bexpall -lDtSvc
+CDE_LIB = -L$(CDE_HOME)/lib -bnoentry -bexpall -lDtSvc -lc
#
# The following CFLAGS are for compiling both the SWT library and the CDE
@@ -37,8 +37,8 @@ CDE_LIB = -L$(CDE_HOME)/lib -G -lc -bnoentry -bexpall -lDtSvc
CFLAGS = -O -s \
-DSWT_VERSION=$(SWT_VERSION) \
-DAIX -DMOTIF -DCDE -DNO_XPRINTING_EXTENSIONS \
- -q mbcs -qlanglvl=extended -qarch=ppc -qtune=604 -qmaxmem=8192 \
- -I$(IVE_HOME)/include \
+ -q mbcs -qlanglvl=extended -qmaxmem=8192 \
+ -I$(JAVA_HOME)/include \
-I$(MOTIF_HOME)/include \
-I$(CDE_HOME)/include
@@ -56,4 +56,4 @@ $(CDE_DLL): $(CDE_OBJ)
clean:
- rm -f *.o *.so
+ rm -f *.o *.so *.a
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java
index 03597b153a..7efdb08060 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/motif/org/eclipse/swt/internal/motif/OS.java
@@ -622,6 +622,8 @@ public class OS {
public static final int XmN_OF_MANY = 0x1;
public static final int XmNONE = 0x0;
// public static final int XmNUMERIC = 0x3;
+ public static final int XmPATH_MODE_FULL = 0x0;
+// public static final int XmPATH_MODE_RELATIVE = 0x1;
/* byte */
public static final int XmNancestorSensitive = malloc ("ancestorSensitive", 1);
@@ -772,6 +774,7 @@ public class OS {
public static final int XmNpageDecrementCallback = malloc ("pageDecrementCallback", 4);
public static final int XmNpageIncrement = malloc ("pageIncrement", 4);
public static final int XmNpageIncrementCallback = malloc ("pageIncrementCallback", 4);
+ public static final int XmNpathMode = malloc ("pathMode", 4);
public static final int XmNpattern = malloc ("pattern", 4);
// public static final int XmNpopupEnabled = malloc ("popupEnabled", 4);
// public static final int XmNpopupHandlerCallback = malloc ("popupHandlerCallback", 4);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.c
index 2a83da7f19..d0d8b24511 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.c
@@ -68,6 +68,7 @@ WNDCLASS_FID_CACHE WNDCLASSFc;
GRADIENT_RECT_FID_CACHE GRADIENT_RECTFc;
HELPINFO_FID_CACHE HELPINFOFc;
MENUINFO_FID_CACHE MENUINFOFc;
+ NMREBARCHEVRON_FID_CACHE NMREBARCHEVRONFc;
NMTTDISPINFO_FID_CACHE NMTTDISPINFOFc;
NONCLIENTMETRICS_FID_CACHE NONCLIENTMETRICSFc;
PRINTDLG_FID_CACHE PRINTDLGFc;
@@ -1798,6 +1799,59 @@ void setNMLISTVIEWFields(JNIEnv *env, jobject lpObject, NMLISTVIEW *lpStruct, PN
(*env)->SetIntField(env, lpObject, lpCache->lParam, lpStruct->lParam);
}
+#ifndef _WIN32_WCE
+void cacheNMREBARCHEVRONFids(JNIEnv *env, jobject lpObject, PNMREBARCHEVRON_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->hwndFrom = (*env)->GetFieldID(env, lpCache->clazz, "hwndFrom", "I");
+ lpCache->idFrom = (*env)->GetFieldID(env, lpCache->clazz, "idFrom", "I");
+ lpCache->code = (*env)->GetFieldID(env, lpCache->clazz, "code", "I");
+ lpCache->uBand = (*env)->GetFieldID(env, lpCache->clazz, "uBand", "I");
+ lpCache->wID = (*env)->GetFieldID(env, lpCache->clazz, "wID", "I");
+ lpCache->lParam = (*env)->GetFieldID(env, lpCache->clazz, "lParam", "I");
+ lpCache->left = (*env)->GetFieldID(env, lpCache->clazz, "left", "I");
+ lpCache->top = (*env)->GetFieldID(env, lpCache->clazz, "top", "I");
+ lpCache->right = (*env)->GetFieldID(env, lpCache->clazz, "right", "I");
+ lpCache->bottom = (*env)->GetFieldID(env, lpCache->clazz, "bottom", "I");
+ lpCache->lParamNM = (*env)->GetFieldID(env, lpCache->clazz, "lParamNM", "I");
+ lpCache->cached = 1;
+}
+
+NMREBARCHEVRON* getNMREBARCHEVRONFields(JNIEnv *env, jobject lpObject, NMREBARCHEVRON *lpStruct, PNMREBARCHEVRON_FID_CACHE lpCache)
+{
+ if (!lpCache->cached) cacheNMREBARCHEVRONFids(env, lpObject, lpCache);
+ lpStruct->hdr.hwndFrom = (HWND)(*env)->GetIntField(env, lpObject, lpCache->hwndFrom);
+ lpStruct->hdr.idFrom = (*env)->GetIntField(env, lpObject, lpCache->idFrom);
+ lpStruct->hdr.code = (*env)->GetIntField(env, lpObject, lpCache->code);
+ lpStruct->uBand = (*env)->GetIntField(env, lpObject, lpCache->uBand);
+ lpStruct->wID = (*env)->GetIntField(env, lpObject, lpCache->wID);
+ lpStruct->lParam = (*env)->GetIntField(env, lpObject, lpCache->lParam);
+ lpStruct->rc.left = (*env)->GetIntField(env, lpObject, lpCache->left);
+ lpStruct->rc.top = (*env)->GetIntField(env, lpObject, lpCache->top);
+ lpStruct->rc.right = (*env)->GetIntField(env, lpObject, lpCache->right);
+ lpStruct->rc.bottom = (*env)->GetIntField(env, lpObject, lpCache->bottom);
+ lpStruct->lParamNM = (*env)->GetIntField(env, lpObject, lpCache->lParamNM);
+ return lpStruct;
+}
+
+void setNMREBARCHEVRONFields(JNIEnv *env, jobject lpObject, NMREBARCHEVRON *lpStruct, PNMREBARCHEVRON_FID_CACHE lpCache)
+{
+ if (!lpCache->cached) cacheNMREBARCHEVRONFids(env, lpObject, lpCache);
+ (*env)->SetIntField(env, lpObject, lpCache->hwndFrom, (jint)lpStruct->hdr.hwndFrom);
+ (*env)->SetIntField(env, lpObject, lpCache->idFrom, lpStruct->hdr.idFrom);
+ (*env)->SetIntField(env, lpObject, lpCache->code, lpStruct->hdr.code);
+ (*env)->SetIntField(env, lpObject, lpCache->uBand, lpStruct->uBand);
+ (*env)->SetIntField(env, lpObject, lpCache->wID, lpStruct->wID);
+ (*env)->SetIntField(env, lpObject, lpCache->lParam, lpStruct->lParam);
+ (*env)->SetIntField(env, lpObject, lpCache->left, lpStruct->rc.left);
+ (*env)->SetIntField(env, lpObject, lpCache->top, lpStruct->rc.top);
+ (*env)->SetIntField(env, lpObject, lpCache->right, lpStruct->rc.right);
+ (*env)->SetIntField(env, lpObject, lpCache->bottom, lpStruct->rc.bottom);
+ (*env)->SetIntField(env, lpObject, lpCache->lParamNM, lpStruct->lParamNM);
+}
+#endif // _WIN32_WCE
+
void cacheNMTOOLBARFids(JNIEnv *env, jobject lpObject, PNMTOOLBAR_FID_CACHE lpCache)
{
if (lpCache->cached) return;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.h
index a3140d3a5c..7229f0c86d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.h
@@ -485,6 +485,20 @@ void cacheNMLISTVIEWFids(JNIEnv *env, jobject lpObject, PNMLISTVIEW_FID_CACHE lp
NMLISTVIEW* getNMLISTVIEWFields(JNIEnv *env, jobject lpObject, NMLISTVIEW *lpStruct, PNMLISTVIEW_FID_CACHE lpCache);
void setNMLISTVIEWFields(JNIEnv *env, jobject lpObject, NMLISTVIEW *lpStruct, PNMLISTVIEW_FID_CACHE lpCache);
+#ifndef _WIN32_WCE
+/* NMREBARCHEVRON struct */
+typedef struct NMREBARCHEVRON_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID hwndFrom, idFrom, code, uBand, wID, lParam, left, top, right, bottom, lParamNM;
+} NMREBARCHEVRON_FID_CACHE;
+typedef NMREBARCHEVRON_FID_CACHE *PNMREBARCHEVRON_FID_CACHE;
+
+void cacheNMREBARCHEVRONFids(JNIEnv *env, jobject lpObject, PNMREBARCHEVRON_FID_CACHE lpCache);
+NMREBARCHEVRON* getNMREBARCHEVRONFields(JNIEnv *env, jobject lpObject, NMREBARCHEVRON *lpStruct, PNMREBARCHEVRON_FID_CACHE lpCache);
+void setNMREBARCHEVRONFields(JNIEnv *env, jobject lpObject, NMREBARCHEVRON *lpStruct, PNMREBARCHEVRON_FID_CACHE lpCache);
+#endif // _WIN32_WCE
+
/* NMTOOLBAR struct */
typedef struct NMTOOLBAR_FID_CACHE {
int cached;
@@ -1176,6 +1190,7 @@ extern GCP_RESULTS_FID_CACHE GCP_RESULTSFc;
extern GRADIENT_RECT_FID_CACHE GRADIENT_RECTFc;
extern HELPINFO_FID_CACHE HELPINFOFc;
extern MENUINFO_FID_CACHE MENUINFOFc;
+extern NMREBARCHEVRON_FID_CACHE NMREBARCHEVRONFc;
extern NMTTDISPINFO_FID_CACHE NMTTDISPINFOFc;
extern NONCLIENTMETRICS_FID_CACHE NONCLIENTMETRICSFc;
extern PRINTDLG_FID_CACHE PRINTDLGFc;
@@ -1186,7 +1201,7 @@ extern WINDOWPLACEMENT_FID_CACHE WINDOWPLACEMENTFc;
extern DROPFILES_FID_CACHE DROPFILESFc;
extern OLECMD_FID_CACHE OLECMDFc;
extern OLECMDTEXT_FID_CACHE OLECMDTEXTFc;
-#endif
+#endif // _WIN32_WCE
/* OLE globals */
extern CAUUID_FID_CACHE CAUUIDFc;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c
index 28777820fa..d4053b3115 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c
@@ -4013,6 +4013,23 @@ JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__Lorg_e
if (arg0) setNMLISTVIEWFields(env, arg0, lparg0, &PGLOB(NMLISTVIEWFc));
}
+#ifndef _WIN32_WCE
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__Lorg_eclipse_swt_internal_win32_NMREBARCHEVRON_2II
+ (JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+ DECL_GLOB(pGlob)
+ NMREBARCHEVRON _arg0, *lparg0=NULL;
+
+ DEBUG_CALL("MoveMemory\n")
+
+ if (arg0) lparg0 = &_arg0;
+
+ MoveMemory((PVOID)lparg0, (CONST VOID *)arg1, arg2);
+
+ if (arg0) setNMREBARCHEVRONFields(env, arg0, lparg0, &PGLOB(NMREBARCHEVRONFc));
+}
+#endif // _WIN32_WCE
+
JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__Lorg_eclipse_swt_internal_win32_NMHEADER_2II
(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
{
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IAccessible.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IAccessible.java
index 329ad25852..ca5f2d1844 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IAccessible.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/IAccessible.java
@@ -5,8 +5,6 @@ package org.eclipse.swt.internal.ole.win32;
* All Rights Reserved
*/
-import org.eclipse.swt.ole.win32.*;
-
public class IAccessible extends IDispatch {
public IAccessible(int address) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
index 369523ac99..47add521da 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
@@ -117,6 +117,7 @@ public class OS {
public static final int BF_BOTTOM = 0x8;
public static final int BF_RIGHT = 0x4;
public static final int BIF_EDITBOX = 0x10;
+ public static final int BIF_NEWDIALOGSTYLE = 0x40;
public static final int BIF_RETURNONLYFSDIRS = 0x1;
public static final int BIF_VALIDATE = 0x20;
public static final int BITSPIXEL = 0xc;
@@ -669,9 +670,11 @@ public class OS {
public static final int RBBIM_TEXT = 0x4;
public static final int RBBS_BREAK = 0x1;
public static final int RBBS_GRIPPERALWAYS = 0x80;
+ public static final int RBBS_NOGRIPPER = 0x00000100;
public static final int RBBS_VARIABLEHEIGHT = 0x40;
public static final int RBN_FIRST = 0xfffffcc1;
public static final int RBN_HEIGHTCHANGE = 0xfffffcc1;
+ public static final int RBS_DBLCLKTOGGLE = 0x8000;
public static final int RBS_BANDBORDERS = 0x400;
public static final int RBS_VARHEIGHT = 0x200;
public static final int RB_DELETEBAND = 0x402;
@@ -2131,6 +2134,7 @@ public static final native void MoveMemory (int Destination, NMLVCUSTOMDRAW Sour
public static final native void MoveMemory (int Destination, NMTVCUSTOMDRAW Source, int Length);
public static final native void MoveMemory (NMHEADER Destination, int Source, int Length);
public static final native void MoveMemory (NMLISTVIEW Destination, int Source, int Length);
+public static final native void MoveMemory (NMREBARCHEVRON Destination, int Source, int Length);
public static final native void MoveMemory (NMTOOLBAR Destination, int Source, int Length);
public static final native void MoveMemoryW (NMTTDISPINFO Destination, int Source, int Length);
public static final native void MoveMemoryA (NMTTDISPINFO Destination, int Source, int Length);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/REBARBANDINFO.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/REBARBANDINFO.java
index 77309f2515..43aa7e336f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/REBARBANDINFO.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/REBARBANDINFO.java
@@ -25,5 +25,5 @@ public class REBARBANDINFO {
public int cxIdeal;
public int lParam;
public int cxHeader;
- public static final int sizeof = 80;
+ public static final int sizeof = OS.IsWinCE ? 76 : 80;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/library/make_common.mak b/bundles/org.eclipse.swt/Eclipse SWT/common/library/make_common.mak
index 31aea220bc..050aa5efd8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/library/make_common.mak
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/library/make_common.mak
@@ -1,4 +1,4 @@
maj_ver=2
-min_ver=031
+min_ver=032
bld_num=0
-comma_ver=2,0,3,1
+comma_ver=2,0,3,2
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/version.txt b/bundles/org.eclipse.swt/Eclipse SWT/common/version.txt
index df3d6424fe..a6dbf21ba8 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/version.txt
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/version.txt
@@ -1 +1 @@
-version 2.031
+version 2.032
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolBar.java
index 6e7eefb832..fb29cc89f6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolBar.java
@@ -849,6 +849,21 @@ void setItemSizes (Point[] sizes) {
}
}
/**
+ * Returns whether or not the coolbar is 'locked'. When a coolbar
+ * is locked, its items cannot be repositioned.
+ *
+ * @return true if the coolbar is locked, false otherwise
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getLocked () {
+ checkWidget ();
+ return false; // currently cannot lock an emulated coolbar
+}
+/**
* Returns an array of ints which describe the zero-relative
* row number of the row which each of the items in the
* receiver occurs in.
@@ -872,6 +887,21 @@ public int[] getWrapIndices () {
return data;
}
/**
+ * Sets whether the reciever is 'locked' or not. When a coolbar
+ * is locked, its items cannot be repositioned.
+ *
+ * @param locked lock the coolbar if true, otherwise unlock the coolbar
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLocked (boolean locked) {
+ checkWidget ();
+ // currently cannot lock an emulated coolbar
+}
+/**
* Sets the row that each of the receiver's items will be
* displayed in to the given array of ints which describe
* the zero-relative row number of the row for each item.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/tabfolder/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/tabfolder/org/eclipse/swt/widgets/TabFolder.java
index 8a5cbef93d..2c9b7677d3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/tabfolder/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/tabfolder/org/eclipse/swt/widgets/TabFolder.java
@@ -515,9 +515,7 @@ public TabItem getItem (int index) {
*/
public int getItemCount(){
checkWidget();
- if (items == null)
- return 0;
- else return items.length;
+ return items == null ? 0 : items.length;
}
/**
* Returns an array of <code>TabItem</code>s which are the items
@@ -1077,6 +1075,7 @@ boolean pageTraversal(Event event) {
}
boolean mnemonicTraversal (Event event) {
+ if (items == null) return false;
char key = event.character;
for (int i = 0; i < items.length; i++) {
if (items[i] != null) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Cursor.java
index 425196c8c4..b389d1a769 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Cursor.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Cursor.java
@@ -134,8 +134,8 @@ public Cursor(Device display, int style) {
default:
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
- if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
this.handle = OS.gdk_cursor_new(osFlag);
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
index a7953b3750..1cebfcc0b1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
@@ -28,9 +28,10 @@ public abstract class Device implements Drawable {
/* Warning and Error Handlers */
int logProc;
Callback logCallback;
- String [] log_domains = {"Gtk", /*"Gdk", "GLib", "GdkPixbuf"*/};
+ //NOT DONE - get list of valid names
+ String [] log_domains = {"GLib-GObject", "GLib", "GObject", "Pango", "ATK", "GdkPixbuf", "Gdk", "Gtk"};
int [] handler_ids = new int [log_domains.length];
- boolean warnings = true;
+ int warningLevel;
/*
* The following colors are listed in the Windows
@@ -40,6 +41,9 @@ public abstract class Device implements Drawable {
Color COLOR_BLACK, COLOR_DARK_RED, COLOR_DARK_GREEN, COLOR_DARK_YELLOW, COLOR_DARK_BLUE;
Color COLOR_DARK_MAGENTA, COLOR_DARK_CYAN, COLOR_GRAY, COLOR_DARK_GRAY, COLOR_RED;
Color COLOR_GREEN, COLOR_YELLOW, COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE;
+
+ /* System Font */
+ Font systemFont;
/*
* TEMPORARY CODE. When a graphics object is
@@ -94,6 +98,9 @@ public Device(DeviceData data) {
errors = new Error [128];
objects = new Object [128];
}
+
+ /* Initialize the system font slot */
+ systemFont = getSystemFont ();
}
protected void checkDevice () {
@@ -149,7 +156,6 @@ protected void destroy () {
*/
public Rectangle getBounds () {
checkDevice ();
- SWT.error (SWT.ERROR_NOT_IMPLEMENTED);
return new Rectangle(0, 0, 0, 0);
}
@@ -220,7 +226,6 @@ public Rectangle getClientArea () {
*/
public int getDepth () {
checkDevice ();
- SWT.error (SWT.ERROR_NOT_IMPLEMENTED);
return 0;
}
@@ -237,7 +242,6 @@ public int getDepth () {
*/
public Point getDPI () {
checkDevice ();
- SWT.error (SWT.ERROR_NOT_IMPLEMENTED);
return new Point (72, 72);
}
@@ -256,29 +260,45 @@ public Point getDPI () {
*/
public FontData[] getFontList (String faceName, boolean scalable) {
checkDevice ();
-
- /* Temporary code.
- * For now, we know that on Pango at least three font families are guaranteed
- * to be present: Sans, Serif, and Monspace.
- */
- if (scalable) return getScalableFontList(faceName);
- return getNonScalableFontList(faceName);
-}
-FontData[] getScalableFontList(String faceName) {
- FontData[] answer;
-// if (faceName==null) {
- answer = new FontData[2];
- answer[0] = new FontData("helvetica", 12, SWT.ROMAN);
-// }
- return answer;
-}
-FontData[] getNonScalableFontList(String faceName) {
- FontData[] answer;
-// if (faceName==null) {
- answer = new FontData[1];
- answer[0] = new FontData("fixed", 12, SWT.ROMAN);
-// }
- return answer;
+
+ //FIXME - check scalable flag
+ int[] family = new int[1];
+ int[] face = new int[1];
+ int[] families = new int[1];
+ int[] n_families = new int[1];
+ int[] faces = new int[1];
+ int[] n_faces = new int[1];
+ int context = OS.gdk_pango_context_get();
+ OS.pango_context_list_families(context, families, n_families);
+ int nFds = 0;
+ FontData[] fds = new FontData[faceName != null ? 4 : n_families[0]];
+ for (int i=0; i<n_families[0]; i++) {
+ OS.memmove(family, families[0] + i * 4, 4);
+ OS.pango_font_family_list_faces(family[0], faces, n_faces);
+ for (int j=0; j<n_faces[0]; j++) {
+ OS.memmove(face, faces[0] + j * 4, 4);
+ int fontDesc = OS.pango_font_face_describe(face[0]);
+ Font font = Font.gtk_new(this, fontDesc);
+ FontData data = font.getFontData()[0];
+ if (faceName == null || Compatibility.equalsIgnoreCase(faceName, data.name)) {
+ if (nFds == fds.length) {
+ FontData[] newFds = new FontData[fds.length + n_families[0]];
+ System.arraycopy(fds, 0, newFds, 0, nFds);
+ fds = newFds;
+ }
+ fds[nFds++] = data;
+ }
+ OS.pango_font_description_free(fontDesc);
+ }
+ OS.g_free(faces[0]);
+ }
+ OS.g_free(families[0]);
+ OS.g_object_unref(context);
+
+ if (nFds == fds.length) return fds;
+ FontData[] result = new FontData[nFds];
+ System.arraycopy(fds, 0, result, 0, nFds);
+ return result;
}
/**
@@ -344,7 +364,7 @@ public Color getSystemColor (int id) {
*/
public Font getSystemFont () {
checkDevice ();
- return null;
+ return systemFont;
}
/**
@@ -360,7 +380,7 @@ public Font getSystemFont () {
*/
public boolean getWarnings () {
checkDevice ();
- return this.warnings;
+ return warningLevel == 0;
}
protected void init () {
@@ -447,7 +467,7 @@ public boolean isDisposed () {
}
int logProc (int log_domain, int log_level, int message, int user_data) {
- if (DEBUG || (debug && warnings)) {
+ if (DEBUG || (debug && warningLevel == 0)) {
new Error ().printStackTrace ();
OS.g_log_default_handler (log_domain, log_level, message, 0);
}
@@ -498,6 +518,7 @@ protected void release () {
if (handler_ids [i] != 0) {
byte [] log_domain = Converter.wcsToMbcs (null, log_domains [i], true);
OS.g_log_remove_handler (log_domain, handler_ids [i]);
+ handler_ids [i] = 0;
}
}
logCallback.dispose (); logCallback = null;
@@ -519,19 +540,25 @@ protected void release () {
*/
public void setWarnings (boolean warnings) {
checkDevice ();
- this.warnings = warnings;
- if (debug) return;
- for (int i=0; i<handler_ids.length; i++) {
- if (handler_ids [i] != 0) {
- byte [] log_domain = Converter.wcsToMbcs (null, log_domains [i], true);
- OS.g_log_remove_handler (log_domain, handler_ids [i]);
- }
- }
if (warnings) {
- int flags = OS.G_LOG_LEVEL_MASK | OS.G_LOG_FLAG_FATAL | OS.G_LOG_FLAG_RECURSION;
- for (int i=0; i<log_domains.length; i++) {
- byte [] log_domain = Converter.wcsToMbcs (null, log_domains [i], true);
- handler_ids [i] = OS.g_log_set_handler (log_domain, flags, logProc, 0);
+ if (--warningLevel == 0) {
+ if (debug) return;
+ for (int i=0; i<handler_ids.length; i++) {
+ if (handler_ids [i] != 0) {
+ byte [] log_domain = Converter.wcsToMbcs (null, log_domains [i], true);
+ OS.g_log_remove_handler (log_domain, handler_ids [i]);
+ handler_ids [i] = 0;
+ }
+ }
+ }
+ } else {
+ if (warningLevel++ == 0) {
+ if (debug) return;
+ int flags = OS.G_LOG_LEVEL_MASK | OS.G_LOG_FLAG_FATAL | OS.G_LOG_FLAG_RECURSION;
+ for (int i=0; i<log_domains.length; i++) {
+ byte [] log_domain = Converter.wcsToMbcs (null, log_domains [i], true);
+ handler_ids [i] = OS.g_log_set_handler (log_domain, flags, logProc, 0);
+ }
}
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Font.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Font.java
index c2fcb65fa6..285f873d1f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Font.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Font.java
@@ -8,7 +8,6 @@ package org.eclipse.swt.graphics;
import org.eclipse.swt.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.widgets.*;
/**
* Instances of this class manage operating system resources that
@@ -29,8 +28,15 @@ public final class Font {
* (Warning: This field is platform dependent)
*/
public int handle;
+
+ /**
+ * The device where this image was created.
+ */
+ Device device;
+
Font() {
}
+
/**
* Constructs a new font given a device and font data
* which describes the desired font's appearance.
@@ -49,16 +55,12 @@ Font() {
* </ul>
*/
public Font(Device display, FontData fd) {
- if (fd == null) error(SWT.ERROR_NULL_ARGUMENT);
- /* FIXME */
- String xlfd = fd.getXlfd();
- byte[] buffer = Converter.wcsToMbcs(null, xlfd, true);
- handle = OS.gdk_font_load(buffer);
- if (handle == 0) {
- handle = OS.gdk_font_load(Converter.wcsToMbcs(null, "fixed", true));
- if (handle == 0) error(SWT.ERROR_NO_HANDLES);
- }
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (fd == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, fd.getName(), fd.getHeight(), fd.getStyle());
}
+
/**
* Constructs a new font given a device, a font name,
* the height of the desired font in points, and a font
@@ -80,27 +82,22 @@ public Font(Device display, FontData fd) {
* <li>ERROR_NO_HANDLES - if a font could not be created from the given arguments</li>
* </ul>
*/
-public Font(Device display, String fontFamily, int height, int style) {
- if (fontFamily == null) error(SWT.ERROR_NULL_ARGUMENT);
- FontData fd = new FontData(fontFamily, height, style);
- byte[] buffer = Converter.wcsToMbcs(null, fd.getXlfd(), true);
- handle = OS.gdk_font_load(buffer);
- if (handle == 0) {
- /* Temporary, FIXME */
- buffer = Converter.wcsToMbcs(null, "fixed", true);
- handle = OS.gdk_font_load(buffer);
- if (handle == 0) error(SWT.ERROR_NO_HANDLES);
- }
+public Font(Device display, String name, int height, int style) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, name, height, style);
}
+
/**
* Disposes of the operating system resources associated with
* the font. Applications must dispose of all fonts which
* they allocate.
*/
public void dispose() {
- if (handle != 0) OS.gdk_font_unref(handle);
+ if (handle != 0) OS.pango_font_description_free(handle);
handle = 0;
}
+
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -116,9 +113,6 @@ public boolean equals(Object object) {
if (!(object instanceof Font)) return false;
return OS.gdk_font_equal(handle, ((Font)object).handle);
}
-void error(int code) {
- throw new SWTError (code);
-}
/**
* Returns an array of <code>FontData</code>s representing the receiver.
@@ -133,29 +127,47 @@ void error(int code) {
* </ul>
*/
public FontData[] getFontData() {
- if (handle==0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- /* REWRITE ME.
- * THIS WILL NEVER WORK CORRECTLY.
- * WE USED TO REACH DOWN TO GDK INTERNAL MEMORY
- */
- FontData[] answer = new FontData[1];
- FontData data = new FontData();
- data.fontFamily = "fixed";
- data.weight = "normal";
- data.points = 120;
- answer[0] = data;
- return answer;
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+
+ int family = OS.pango_font_description_get_family(handle);
+ int length = OS.strlen(family);
+ byte[] buffer = new byte[length];
+ OS.memmove(buffer, family, length);
+ String name = new String(Converter.mbcsToWcs(null, buffer));
+ int height = OS.pango_font_description_get_size(handle) / OS.PANGO_SCALE();
+ int pangoStyle = OS.pango_font_description_get_style(handle);
+ int pangoWeight = OS.pango_font_description_get_weight(handle);
+ int style = SWT.NORMAL;
+ if (pangoStyle == OS.PANGO_STYLE_ITALIC()) style |= SWT.ITALIC;
+ if (pangoStyle == OS.PANGO_STYLE_OBLIQUE()) style |= SWT.ROMAN;
+ /* Anything bolder than NORMAL, is BOLD */
+ if (pangoWeight > OS.PANGO_WEIGHT_NORMAL()) style |= SWT.BOLD;
+ return new FontData[]{new FontData(name, height, style)};
}
-public static Font gtk_new(int handle) {
- if (handle == 0) {
- handle = OS.gdk_font_load(Converter.wcsToMbcs(null, "fixed", true));
- if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- }
+/**
+ * Invokes platform specific functionality to allocate a new font.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Font</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param device the device on which to allocate the color
+ * @param handle the handle for the font
+ *
+ * @private
+ */
+public static Font gtk_new(Device device, int handle) {
+ if (device == null) device = Device.getDevice();
Font font = new Font();
font.handle = handle;
+ font.device = device;
return font;
}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -169,6 +181,26 @@ public static Font gtk_new(int handle) {
public int hashCode() {
return handle;
}
+
+void init(Device device, String name, int height, int style) {
+ if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (height < 0) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+
+ handle = OS.pango_font_description_new();
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ byte[] buffer = Converter.wcsToMbcs(null, name, true);
+ OS.pango_font_description_set_family(handle, buffer);
+ OS.pango_font_description_set_size(handle, height * OS.PANGO_SCALE());
+ OS.pango_font_description_set_stretch(handle, OS.PANGO_STRETCH_NORMAL());
+ int pangoStyle = OS.PANGO_STYLE_NORMAL();
+ int pangoWeight = OS.PANGO_WEIGHT_NORMAL();
+ if ((style & SWT.ITALIC) != 0) pangoStyle = OS.PANGO_STYLE_ITALIC();
+ if ((style & SWT.ROMAN) != 0) pangoStyle = OS.PANGO_STYLE_OBLIQUE();
+ if ((style & SWT.BOLD) != 0) pangoWeight = OS.PANGO_WEIGHT_BOLD();
+ OS.pango_font_description_set_style(handle, pangoStyle);
+ OS.pango_font_description_set_weight(handle, pangoWeight);
+}
+
/**
* Returns <code>true</code> if the font has been disposed,
* and <code>false</code> otherwise.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontData.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontData.java
index 4006adc083..ab85955e87 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontData.java
@@ -34,75 +34,23 @@ import org.eclipse.swt.*;
*/
public final class FontData {
/**
- * The company that produced the font
- * Warning: This field is platform dependent.
+ * the font name
+ * (Warning: This field is platform dependent)
*/
- public String foundry;
- /**
- * The common name of the font
- * Warning: This field is platform dependent.
- */
- public String fontFamily;
- /**
- * The weight ("normal", "bold")
- * Warning: This field is platform dependent.
- */
- public String weight;
- /**
- * The slant ("o" for oblique, "i" for italic)
- * Warning: This field is platform dependent.
- */
- public String slant;
- /**
- * The set width of the font
- * Warning: This field is platform dependent.
- */
- public String setWidth;
- /**
- * Additional font styles
- * Warning: This field is platform dependent.
- */
- public String addStyle;
- /**
- * The height of the font in pixels
- * Warning: This field is platform dependent.
- */
- public int pixels;
- /**
- * The height of the font in tenths of a point
- * Warning: This field is platform dependent.
- */
- public int points;
- /**
- * The horizontal screen resolution for which the font was designed
- * Warning: This field is platform dependent.
- */
- public int horizontalResolution;
- /**
- * The vertical screen resolution for which the font was designed
- * Warning: This field is platform dependent.
- */
- public int verticalResolution;
- /**
- * The font spacing ("m" for monospace, "p" for proportional)
- * Warning: This field is platform dependent.
- */
- public String spacing;
- /**
- * The average character width for the font
- * Warning: This field is platform dependent.
- */
- public int averageWidth;
+ public String name;
+
/**
- * The ISO character set registry
- * Warning: This field is platform dependent.
+ * The height of the font data in points
+ * (Warning: This field is platform dependent)
*/
- public String characterSetRegistry;
+ public int height;
+
/**
- * The ISO character set name
- * Warning: This field is platform dependent.
+ * the font style
+ * (Warning: This field is platform dependent)
*/
- public String characterSetName;
+ public int style;
+
/**
* The locales of the font
* (Warning: These fields are platform dependent)
@@ -113,7 +61,9 @@ public final class FontData {
* Constructs a new un-initialized font data.
*/
public FontData () {
+ this("", 12, SWT.NORMAL);
}
+
/**
* Constructs a new FontData given a string representation
* in the form generated by the <code>FontData.toString</code>
@@ -134,74 +84,55 @@ public FontData () {
* @see #toString
*/
public FontData(String string) {
- if (string == null) error(SWT.ERROR_NULL_ARGUMENT);
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
int start = 0;
int end = string.indexOf('|');
- if (end == -1) error(SWT.ERROR_NULL_ARGUMENT);
+ if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
String version1 = string.substring(start, end);
start = end + 1;
end = string.indexOf('|', start);
- if (end == -1) error(SWT.ERROR_NULL_ARGUMENT);
+ if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
String name = string.substring(start, end);
start = end + 1;
end = string.indexOf('|', start);
- if (end == -1) error(SWT.ERROR_NULL_ARGUMENT);
+ if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
int height = 0;
try {
height = Integer.parseInt(string.substring(start, end));
} catch (NumberFormatException e) {
- error(SWT.ERROR_NULL_ARGUMENT);
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
start = end + 1;
end = string.indexOf('|', start);
- if (end == -1) error(SWT.ERROR_NULL_ARGUMENT);
+ if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
int style = 0;
try {
style = Integer.parseInt(string.substring(start, end));
} catch (NumberFormatException e) {
- error(SWT.ERROR_NULL_ARGUMENT);
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
start = end + 1;
end = string.indexOf('|', start);
- if (end == -1) {
- setName(name);
- setHeight(height);
- setStyle(style);
- return;
- }
+ setName(name);
+ setHeight(height);
+ setStyle(style);
+ if (end == -1) return;
String platform = string.substring(start, end);
start = end + 1;
end = string.indexOf('|', start);
- if (end == -1) {
- setName(name);
- setHeight(height);
- setStyle(style);
- return;
- }
+ if (end == -1) return;
String version2 = string.substring(start, end);
- if (platform.equals("MOTIF") && version2.equals("1")) {
- start = end + 1;
- end = string.length();
- if (end == -1) {
- setName(name);
- setHeight(height);
- setStyle(style);
- return;
- }
- String xlfd = string.substring(start, end);
- setXlfd(xlfd);
+ if (platform.equals("GTK") && version2.equals("1")) {
return;
}
- setName(name);
- setHeight(height);
- setStyle(style);
}
+
/**
* Constructs a new font data given a font name,
* the height of the desired font in points,
@@ -217,33 +148,27 @@ public FontData(String string) {
* </ul>
*/
public FontData(String name, int height, int style) {
- if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (height < 0) error(SWT.ERROR_INVALID_ARGUMENT);
- int dash = name.indexOf('-');
- if (dash != -1) {
- foundry = name.substring(0, dash);
- fontFamily = name.substring(dash + 1);
- } else {
- fontFamily = name;
- }
- points = height * 10;
- if ((style & SWT.BOLD) != 0) {
- weight = "bold";
- } else {
- weight = "medium";
- }
- if ((style & SWT.ITALIC) != 0) {
- slant = "i";
- } else {
- slant = "r";
- }
+ setName(name);
+ setHeight(height);
+ setStyle(style);
}
-
-
-/*
- * Public getters
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode
*/
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof FontData)) return false;
+ FontData data = (FontData)object;
+ return name == name && height == data.height && style == data.style;
+}
/**
* Returns the height of the receiver in points.
@@ -253,7 +178,7 @@ public FontData(String name, int height, int style) {
* @see #setHeight
*/
public int getHeight() {
- return points / 10;
+ return height;
}
/**
@@ -266,13 +191,7 @@ public int getHeight() {
* @see #setName
*/
public String getName() {
- StringBuffer buffer = new StringBuffer();
- if (foundry != null) {
- buffer.append(foundry);
- buffer.append("-");
- }
- if (fontFamily != null) buffer.append(fontFamily);
- return buffer.toString();
+ return name;
}
/**
@@ -285,51 +204,9 @@ public String getName() {
* @see #setStyle
*/
public int getStyle() {
- int style = 0;
- if (weight!=null)
- if (weight.equals("bold")) style |= SWT.BOLD;
- if (slant!=null)
- if (slant.equals("i"))
- style |= SWT.ITALIC;
return style;
}
-/**
- * We need this in FontDialog, so we can't just get rid of it or make it private.
- */
-public String gtk_getXlfd() { return getXlfd(); }
-
-String getXlfd() {
- String s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14;
- s1 = s2 = s3 = s4 = s5 = s6 = s7 = s8 = s9 = s10 = s11 = s12 = s13 = s14 = "*";
-
- if (foundry != null) s1 = foundry;
- if (fontFamily != null) s2 = fontFamily;
- if (weight != null) s3 = weight;
- if (slant != null) s4 = slant;
- if (setWidth != null) s5 = setWidth;
- if (addStyle != null) s6 = addStyle;
- if (pixels != 0) s7 = Integer.toString(pixels);
- if (points != 0) s8 = Integer.toString(points);
- if (horizontalResolution != 0) s9 = Integer.toString(horizontalResolution);
- if (verticalResolution != 0) s10 = Integer.toString(verticalResolution);
- if (spacing != null) s11 = spacing;
-// The following line has been intentionally commented.
-// we don not know the exact average width as in the font definition,
-// so if someone tries to get a similar font, they'd get something weird
-// if (averageWidth != 0) s12 = Integer.toString(averageWidth);
- if (characterSetRegistry != null) s13 = characterSetRegistry;
- if (characterSetName != null) s14 = characterSetName;
-
- String xlfd = "-" + s1+ "-" + s2 + "-" + s3 + "-" + s4 + "-" + s5 + "-" + s6 + "-" + s7 + "-" + s8 + "-"
- + s9 + "-" + s10 + "-" + s11 + "-" + s12 + "-" + s13 + "-" + s14;
- return xlfd;
-}
-public static FontData gtk_new(String xlfd) {
- FontData fontData = new FontData();
- fontData.setXlfd(xlfd);
- return fontData;
-}
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -341,8 +218,9 @@ public static FontData gtk_new(String xlfd) {
* @see #equals
*/
public int hashCode () {
- return getXlfd().hashCode();
+ return name.hashCode() ^ height ^ style;
}
+
/**
* Sets the height of the receiver. The parameter is
* specified in terms of points, where a point is one
@@ -357,8 +235,8 @@ public int hashCode () {
* @see #getHeight
*/
public void setHeight(int height) {
- if (height < 0) error(SWT.ERROR_INVALID_ARGUMENT);
- points = height * 10;
+ if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ this.height = height;
}
/**
@@ -397,6 +275,7 @@ public void setLocale(String locale) {
if (length > secondSep + 1) variant = locale.substring(secondSep + 1);
}
}
+
/**
* Sets the name of the receiver.
* <p>
@@ -424,14 +303,9 @@ public void setLocale(String locale) {
*/
public void setName(String name) {
if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- int dash = name.indexOf('-');
- if (dash != -1) {
- foundry = name.substring(0, dash);
- fontFamily = name.substring(dash + 1);
- } else {
- fontFamily = name;
- }
+ this.name = name;
}
+
/**
* Sets the style of the receiver to the argument which must
* be a bitwise OR of one or more of the <code>SWT</code>
@@ -442,78 +316,9 @@ public void setName(String name) {
* @see #getStyle
*/
public void setStyle(int style) {
- if ((style & SWT.BOLD) == SWT.BOLD)
- weight = "bold";
- else
- weight = "medium";
- if ((style & SWT.ITALIC) == SWT.ITALIC)
- slant = "i";
- else
- slant = "r";
-}
-void setXlfd(String xlfd) {
- int start, stop;
- start = 1;
- stop = xlfd.indexOf ("-", start);
- foundry = xlfd.substring(start, stop);
- if (foundry.equals("*")) foundry = null;
- start = stop + 1;
- stop = xlfd.indexOf ("-", start);
- fontFamily = xlfd.substring(start, stop);
- if (fontFamily.equals("*")) fontFamily = null;
- start = stop + 1;
- stop = xlfd.indexOf ("-", start);
- weight = xlfd.substring(start, stop);
- if (weight.equals("*")) weight = null;
- start = stop + 1;
- stop = xlfd.indexOf ("-", start);
- slant = xlfd.substring(start, stop);
- if (slant.equals("*")) slant = null;
- start = stop + 1;
- stop = xlfd.indexOf ("-", start);
- setWidth = xlfd.substring(start, stop);
- if (setWidth.equals("*")) setWidth = null;
- start = stop + 1;
- stop = xlfd.indexOf ("-", start);
- addStyle = xlfd.substring(start, stop);
- if (addStyle.equals("*")) addStyle = null;
- start = stop + 1;
- stop = xlfd.indexOf ("-", start);
- String s = xlfd.substring(start, stop);
- if (!s.equals("") && !s.equals("*"))
- pixels = Integer.parseInt(s);
- start = stop + 1;
- stop = xlfd.indexOf ("-", start);
- s = xlfd.substring(start, stop);
- if (!s.equals("") && !s.equals("*"))
- points = Integer.parseInt(s);
- start = stop + 1;
- stop = xlfd.indexOf ("-", start);
- s = xlfd.substring(start, stop);
- if (!s.equals("") && !s.equals("*"))
- horizontalResolution = Integer.parseInt(s);
- start = stop + 1;
- stop = xlfd.indexOf ("-", start);
- s = xlfd.substring(start, stop);
- if (!s.equals("") && !s.equals("*"))
- verticalResolution = Integer.parseInt(s);
- start = stop + 1;
- stop = xlfd.indexOf ("-", start);
- spacing = xlfd.substring(start, stop);
- start = stop + 1;
- stop = xlfd.indexOf ("-", start);
- s = xlfd.substring(start, stop);
- if (!s.equals("") && !s.equals("*"))
- averageWidth = Integer.parseInt(s);
- start = stop + 1;
- stop = xlfd.indexOf ("-", start);
- characterSetRegistry = xlfd.substring(start, stop);
- if (characterSetRegistry.equals("*")) characterSetRegistry = null;
- start = stop + 1;
- stop = xlfd.indexOf ("-", start);
- characterSetName = xlfd.substring(start);
- if (characterSetName.equals("*")) characterSetName = null;
+ this.style = style;
}
+
/**
* Returns a string representation of the receiver which is suitable
* for constructing an equivalent instance using the
@@ -524,25 +329,16 @@ void setXlfd(String xlfd) {
* @see FontData
*/
public String toString() {
- return "1|" + fontFamily + "|" + getHeight() + "|" + getStyle() + "|" +
- "GTK|1|" + getXlfd();
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("1|");
+ buffer.append(getName());
+ buffer.append("|");
+ buffer.append(getHeight());
+ buffer.append("|");
+ buffer.append(getStyle());
+ buffer.append("|");
+ buffer.append("GTK|1|");
+ return buffer.toString();
}
-/**
- * Compares the argument to the receiver, and returns true
- * if they represent the <em>same</em> object using a class
- * specific comparison.
- *
- * @param object the object to compare with this object
- * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
- *
- * @see #hashCode
- */
-public boolean equals (Object object) {
- return (object == this) || ((object instanceof FontData) &&
- getXlfd().equals(((FontData)object).getXlfd()));
-}
-void error(int code) {
- throw new SWTError(code);
-}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontMetrics.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontMetrics.java
index b514f317ec..edd587f478 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontMetrics.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/FontMetrics.java
@@ -5,8 +5,6 @@ package org.eclipse.swt.graphics;
* All Rights Reserved
*/
-import org.eclipse.swt.internal.gtk.*;
-
/**
* Instances of this class provide measurement information
* about fonts including ascent, descent, height, leading
@@ -19,8 +17,10 @@ import org.eclipse.swt.internal.gtk.*;
public final class FontMetrics {
int ascent, descent, averageCharWidth, leading, height;
+
FontMetrics() {
}
+
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -39,6 +39,7 @@ public boolean equals (Object object) {
averageCharWidth == metrics.averageCharWidth && leading == metrics.leading &&
height == metrics.height;
}
+
/**
* Returns the ascent of the font described by the receiver. A
* font's <em>ascent</em> is the distance from the baseline to the
@@ -50,6 +51,7 @@ public boolean equals (Object object) {
public int getAscent() {
return ascent;
}
+
/**
* Returns the average character width, measured in pixels,
* of the font described by the receiver.
@@ -59,6 +61,7 @@ public int getAscent() {
public int getAverageCharWidth() {
return averageCharWidth;
}
+
/**
* Returns the descent of the font described by the receiver. A
* font's <em>descent</em> is the distance from the baseline to the
@@ -70,6 +73,7 @@ public int getAverageCharWidth() {
public int getDescent() {
return descent;
}
+
/**
* Returns the height of the font described by the receiver,
* measured in pixels. A font's <em>height</em> is the sum of
@@ -84,6 +88,7 @@ public int getDescent() {
public int getHeight() {
return height;
}
+
/**
* Returns the leading area of the font described by the
* receiver. A font's <em>leading area</em> is the space
@@ -94,15 +99,7 @@ public int getHeight() {
public int getLeading() {
return leading;
}
-public static FontMetrics gtk_new(int gdk_font) {
- FontMetrics fontMetrics = new FontMetrics();
- fontMetrics.ascent = OS.GDK_FONT_ASCENT(gdk_font);
- fontMetrics.descent = OS.GDK_FONT_DESCENT(gdk_font);
- fontMetrics.averageCharWidth = OS.gdk_char_width(gdk_font, (byte)'a');
- fontMetrics.leading = 3;
- fontMetrics.height = fontMetrics.ascent+fontMetrics.descent+3;
- return fontMetrics;
-}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -116,4 +113,5 @@ public static FontMetrics gtk_new(int gdk_font) {
public int hashCode() {
return ascent ^ descent ^ averageCharWidth ^ leading ^ height;
}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
index a9c145cda3..8f8e4537d9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
@@ -9,7 +9,6 @@ import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.*;
-
/**
* Class <code>GC</code> is where all of the drawing capabilities that are
* supported by SWT are located. Instances are used to draw on either an
@@ -160,11 +159,16 @@ public void dispose() {
if (clipRgn != 0) OS.gdk_region_destroy(clipRgn);
Image image = data.image;
if (image != null) image.memGC = null;
+
+ int context = data.context;
+ if (context != 0) OS.g_object_unref(context);
+ int layout = data.layout;
+ if (layout != 0) OS.g_object_unref(layout);
/* Dispose the GC */
drawable.internal_dispose_GC(handle, data);
- data.drawable = data.clipRgn = 0;
+ data.layout = data.context = data.drawable = data.clipRgn = 0;
drawable = null;
data.image = null;
data = null;
@@ -719,34 +723,11 @@ public void drawString (String string, int x, int y) {
public void drawString(String string, int x, int y, boolean isTransparent) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ //FIXME - need to avoid delimiter and tabs
+ int layout = data.layout;
byte[] buffer = Converter.wcsToMbcs(null, string, true);
- byte[] buffer1 = Converter.wcsToMbcs(null, "Y", true);
- int[] unused = new int[1];
- int[] width = new int[1];
- int[] ascent = new int[1];
- int[] average_ascent = new int [1];
- int fontHandle = _getGCFont();
- OS.gdk_string_extents(fontHandle, buffer, unused, unused, width, ascent, unused);
- OS.gdk_string_extents(fontHandle, buffer1, unused, unused, unused, average_ascent, unused);
- if (ascent[0]<average_ascent[0]) ascent[0] = average_ascent[0];
- if (!isTransparent) {
- int height = OS.gdk_string_height(fontHandle, buffer);
- GdkGCValues values = new GdkGCValues();
- OS.gdk_gc_get_values(handle, values);
- GdkColor color = new GdkColor();
- color.pixel = values.background_pixel;
- color.red = values.background_red;
- color.green = values.background_green;
- color.blue = values.background_blue;
- OS.gdk_gc_set_foreground(handle, color);
- OS.gdk_draw_rectangle(data.drawable, handle, 1, x, y, width[0], height);
- color.pixel = values.foreground_pixel;
- color.red = values.foreground_red;
- color.green = values.foreground_green;
- color.blue = values.foreground_blue;
- OS.gdk_gc_set_foreground(handle, color);
- }
- OS.gdk_draw_string(data.drawable, fontHandle, handle, x, y + ascent[0], buffer);
+ OS.pango_layout_set_text(layout, buffer, buffer.length - 1);
+ OS.gdk_draw_layout(data.drawable, handle, x, y, layout);
}
/**
@@ -768,7 +749,7 @@ public void drawString(String string, int x, int y, boolean isTransparent) {
* </ul>
*/
public void drawText(String string, int x, int y) {
- drawText(string, x, y, false);
+ drawText(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
}
/**
@@ -792,36 +773,9 @@ public void drawText(String string, int x, int y) {
* </ul>
*/
public void drawText(String string, int x, int y, boolean isTransparent) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- byte[] buffer = Converter.wcsToMbcs(null, string, true);
- byte[] buffer1 = Converter.wcsToMbcs(null, "Y", true);
- int fontHandle = _getGCFont();
- int[] unused = new int[1];
- int[] width = new int[1];
- int[] ascent = new int[1];
- int[] average_ascent = new int [1];
- OS.gdk_string_extents(fontHandle, buffer, unused, unused, width, ascent, unused);
- OS.gdk_string_extents(fontHandle, buffer1, unused, unused, unused, average_ascent, unused);
- if (ascent[0]<average_ascent[0]) ascent[0] = average_ascent[0];
- if (!isTransparent) {
- int height = OS.gdk_string_height(fontHandle, buffer);
- GdkGCValues values = new GdkGCValues();
- OS.gdk_gc_get_values(handle, values);
- GdkColor color = new GdkColor();
- color.pixel = values.background_pixel;
- color.red = values.background_red;
- color.green = values.background_green;
- color.blue = values.background_blue;
- OS.gdk_gc_set_foreground(handle, color);
- OS.gdk_draw_rectangle(data.drawable, handle, 1, x, y, width[0], height);
- color.pixel = values.foreground_pixel;
- color.red = values.foreground_red;
- color.green = values.foreground_green;
- color.blue = values.foreground_blue;
- OS.gdk_gc_set_foreground(handle, color);
- }
- OS.gdk_draw_string(data.drawable, fontHandle, handle, x, y + ascent[0], buffer);
+ int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB;
+ if (isTransparent) flags |= SWT.DRAW_TRANSPARENT;
+ drawText(string, x, y, flags);
}
/**
@@ -859,8 +813,13 @@ public void drawText(String string, int x, int y, boolean isTransparent) {
* </ul>
*/
public void drawText (String string, int x, int y, int flags) {
- // NOT IMPLEMENTED
- drawText(string, x, y, (flags & SWT.DRAW_TRANSPARENT) != 0);
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ //FIXME - check flags
+ int layout = data.layout;
+ byte[] buffer = Converter.wcsToMbcs(null, string, true);
+ OS.pango_layout_set_text(layout, buffer, buffer.length - 1);
+ OS.gdk_draw_layout(data.drawable, handle, x, y, layout);
}
/**
@@ -931,15 +890,9 @@ public void fillArc(int x, int y, int width, int height, int startAngle, int end
OS.gdk_gc_get_values(handle, values);
GdkColor color = new GdkColor();
color.pixel = values.background_pixel;
- color.red = values.background_red;
- color.green = values.background_green;
- color.blue = values.background_blue;
OS.gdk_gc_set_foreground(handle, color);
OS.gdk_draw_arc(data.drawable, handle, 1, x, y, width, height, startAngle * 64, endAngle * 64);
color.pixel = values.foreground_pixel;
- color.red = values.foreground_red;
- color.green = values.foreground_green;
- color.blue = values.foreground_blue;
OS.gdk_gc_set_foreground(handle, color);
}
@@ -1031,15 +984,9 @@ public void fillOval(int x, int y, int width, int height) {
OS.gdk_gc_get_values(handle, values);
GdkColor color = new GdkColor();
color.pixel = values.background_pixel;
- color.red = values.background_red;
- color.green = values.background_green;
- color.blue = values.background_blue;
OS.gdk_gc_set_foreground(handle, color);
OS.gdk_draw_arc(data.drawable, handle, 1, x, y, width, height, 0, 23040);
color.pixel = values.foreground_pixel;
- color.red = values.foreground_red;
- color.green = values.foreground_green;
- color.blue = values.foreground_blue;
OS.gdk_gc_set_foreground(handle, color);
}
@@ -1069,15 +1016,9 @@ public void fillPolygon(int[] pointArray) {
OS.gdk_gc_get_values(handle, values);
GdkColor color = new GdkColor();
color.pixel = values.background_pixel;
- color.red = values.background_red;
- color.green = values.background_green;
- color.blue = values.background_blue;
OS.gdk_gc_set_foreground(handle, color);
OS.gdk_draw_polygon(data.drawable, handle, 1, pointArray, pointArray.length / 2);
color.pixel = values.foreground_pixel;
- color.red = values.foreground_red;
- color.green = values.foreground_green;
- color.blue = values.foreground_blue;
OS.gdk_gc_set_foreground(handle, color);
}
@@ -1110,15 +1051,9 @@ public void fillRectangle(int x, int y, int width, int height) {
OS.gdk_gc_get_values(handle, values);
GdkColor color = new GdkColor();
color.pixel = values.background_pixel;
- color.red = values.background_red;
- color.green = values.background_green;
- color.blue = values.background_blue;
OS.gdk_gc_set_foreground(handle, color);
OS.gdk_draw_rectangle(data.drawable, handle, 1, x, y, width, height);
color.pixel = values.foreground_pixel;
- color.red = values.foreground_red;
- color.green = values.foreground_green;
- color.blue = values.foreground_blue;
OS.gdk_gc_set_foreground(handle, color);
}
@@ -1189,9 +1124,6 @@ public void fillRoundRectangle(int x, int y, int width, int height, int arcWidth
OS.gdk_gc_get_values(handle, values);
GdkColor color = new GdkColor();
color.pixel = values.background_pixel;
- color.red = values.background_red;
- color.green = values.background_green;
- color.blue = values.background_blue;
OS.gdk_gc_set_foreground(handle, color);
int drawable = data.drawable;
@@ -1220,9 +1152,6 @@ public void fillRoundRectangle(int x, int y, int width, int height, int arcWidth
}
color.pixel = values.foreground_pixel;
- color.red = values.foreground_red;
- color.green = values.foreground_green;
- color.blue = values.foreground_blue;
OS.gdk_gc_set_foreground(handle, color);
}
@@ -1243,9 +1172,8 @@ public void fillRoundRectangle(int x, int y, int width, int height, int arcWidth
*/
public int getAdvanceWidth(char ch) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
-// byte[] charBuffer = Converter.wcsToMbcs(null, new char[] { ch });
-// return OS.gdk_char_width(_getGCFont(), charBuffer[0]);
- return 0;
+ //BOGUS
+ return stringExtent(new String(new char[]{ch})).x;
}
/**
@@ -1262,10 +1190,8 @@ public Color getBackground() {
GdkGCValues values = new GdkGCValues();
OS.gdk_gc_get_values(handle, values);
GdkColor color = new GdkColor();
- color.pixel = values.background_pixel;
- color.red = values.background_red;
- color.green = values.background_green;
- color.blue = values.background_blue;
+ int colormap = OS.gdk_colormap_get_system();
+ OS.gdk_colormap_query_color(colormap, values.background_pixel, color);
return Color.gtk_new(data.device, color);
}
@@ -1287,13 +1213,8 @@ public Color getBackground() {
*/
public int getCharWidth(char ch) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
-// byte[] charBuffer = Converter.wcsToMbcs(null, new char[] { ch });
-// int[] lbearing = new int[1];
-// int[] rbearing = new int[1];
-// int[] unused = new int[1];
-// OS.gdk_string_extents(_getGCFont(), charBuffer, lbearing, rbearing, unused, unused, unused);
-// return rbearing[0] - lbearing[0];
- return 0;
+ //BOGUS
+ return stringExtent(new String(new char[]{ch})).x;
}
/**
@@ -1363,8 +1284,8 @@ public void getClipping(Region region) {
*/
public Font getFont() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
-// return Font.gtk_new(_getGCFont());
- return null;
+ int font = OS.pango_context_get_font_description(data.context);
+ return Font.gtk_new(data.device, font);
}
/**
@@ -1380,12 +1301,19 @@ public Font getFont() {
*/
public FontMetrics getFontMetrics() {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
-// int fontHandle = _getGCFont();
-// if (fontHandle==0) {
-// SWT.error(SWT.ERROR_UNSPECIFIED);
-// }
-// return FontMetrics.gtk_new(fontHandle);
- return null;
+ int context = data.context;
+ int font = OS.pango_context_get_font_description(context);
+ //FIXME - figure out correct language
+ byte[] buffer = Converter.wcsToMbcs(null, "en_US");
+ int lang = OS.pango_language_from_string(buffer);
+// int lang = OS.pango_context_get_language(context);
+ int metrics = OS.pango_context_get_metrics(context, font, lang);
+ FontMetrics fm = new FontMetrics();
+ fm.ascent = OS.PANGO_PIXELS(OS.pango_font_metrics_get_ascent(metrics));
+ fm.descent = OS.PANGO_PIXELS(OS.pango_font_metrics_get_descent(metrics));
+ fm.averageCharWidth = OS.PANGO_PIXELS(OS.pango_font_metrics_get_approximate_char_width(metrics));
+ fm.height = fm.ascent + fm.descent;
+ return fm;
}
/**
@@ -1402,10 +1330,8 @@ public Color getForeground() {
GdkGCValues values = new GdkGCValues();
OS.gdk_gc_get_values(handle, values);
GdkColor color = new GdkColor();
- color.pixel = values.foreground_pixel;
- color.red = values.foreground_red;
- color.green = values.foreground_green;
- color.blue = values.foreground_blue;
+ int colormap = OS.gdk_colormap_get_system();
+ OS.gdk_colormap_query_color(colormap, values.foreground_pixel, color);
return Color.gtk_new(data.device, color);
}
@@ -1485,10 +1411,20 @@ public int hashCode() {
}
void init(Drawable drawable, GCData data, int gdkGC) {
+ int context = OS.gdk_pango_context_get();
+ if (context == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ data.context = context;
+ int layout = OS.pango_layout_new(context);
+ if (context == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ data.layout = layout;
+
GdkColor foreground = data.foreground;
if (foreground != null) OS.gdk_gc_set_foreground(gdkGC, foreground);
GdkColor background = data.background;
- if (background != null) OS.gdk_gc_set_background (gdkGC, background);
+ if (background != null) OS.gdk_gc_set_background (gdkGC, background);
+ int font = data.font;
+ if (font != 0) OS.pango_context_set_font_description(context, font);
+
Image image = data.image;
if (image != null) {
image.memGC = this;
@@ -1659,16 +1595,9 @@ public void setClipping(Region region) {
*/
public void setFont(Font font) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
-/* int fontHandle = 0;
- if (font == null) {
- GtkStyle gtkStyle = new GtkStyle();
- int style = OS.gtk_widget_get_default_style();
- OS.memmove(gtkStyle, style, GtkStyle.sizeof);
- fontHandle = gtkStyle.font;
- } else {
- fontHandle = font.handle;
- }
- OS.gdk_gc_set_font(handle, fontHandle);*/
+ if (font == null) font = data.device.systemFont;
+ if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ OS.pango_context_set_font_description(data.context, font.handle);
}
/**
@@ -1792,10 +1721,14 @@ public void setXORMode(boolean val) {
public Point stringExtent(String string) {
if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ //FIXME - need to avoid delimiter and tabs
+ int layout = data.layout;
byte[] buffer = Converter.wcsToMbcs(null, string, true);
- int width = OS.gdk_string_width(_getGCFont(), buffer);
- int height = OS.gdk_string_height(_getGCFont(), buffer);
- return new Point(width, height);
+ OS.pango_layout_set_text(layout, buffer, buffer.length - 1);
+ int[] width = new int[1];
+ int[] height = new int[1];
+ OS.pango_layout_get_size(layout, width, height);
+ return new Point(width[0] / OS.PANGO_SCALE(), height[0] / OS.PANGO_SCALE());
}
/**
@@ -1818,12 +1751,7 @@ public Point stringExtent(String string) {
* </ul>
*/
public Point textExtent(String string) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- byte[] buffer = Converter.wcsToMbcs(null, string, true);
- int width = OS.gdk_string_width(_getGCFont(), buffer);
- int height = OS.gdk_string_height(_getGCFont(), buffer);
- return new Point(width, height);
+ return textExtent(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
}
/**
@@ -1858,8 +1786,16 @@ public Point textExtent(String string) {
* </ul>
*/
public Point textExtent(String string, int flags) {
- //NOT IMPLEMENTED
- return textExtent(string);
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ //FIXME - check flags
+ int layout = data.layout;
+ byte[] buffer = Converter.wcsToMbcs(null, string, true);
+ OS.pango_layout_set_text(layout, buffer, buffer.length - 1);
+ int[] width = new int[1];
+ int[] height = new int[1];
+ OS.pango_layout_get_size(layout, width, height);
+ return new Point(width[0] / OS.PANGO_SCALE(), height[0] / OS.PANGO_SCALE());
}
/**
@@ -1873,14 +1809,4 @@ public String toString () {
return "GC {" + handle + "}";
}
-private int _getGCFont() {
- GdkGCValues values = new GdkGCValues();
- OS.gdk_gc_get_values(handle, values);
- if (values.font==0) {
- values.font = OS.gdk_font_load(Converter.wcsToMbcs(null, "fixed", true));
- if (values.font == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- }
- return values.font;
-}
-
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GCData.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GCData.java
index 6e9651e452..6b24edd50c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GCData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GCData.java
@@ -26,6 +26,9 @@ public final class GCData {
public int drawable;
public GdkColor foreground;
public GdkColor background;
+ public int font;
+ public int context;
+ public int layout;
public int clipRgn;
public int lineStyle = SWT.LINE_SOLID;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
index a9b1aaf5aa..59b056528e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
@@ -371,6 +371,7 @@ public Image(Device device, ImageData data) {
* </ul>
*/
public Image(Device display, ImageData source, ImageData mask) {
+ if (device == null) device = Device.getDevice();
if (source == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (mask == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (source.width != mask.width || source.height != mask.height) {
@@ -804,6 +805,7 @@ public int internal_new_GC (GCData data) {
if (data != null) {
data.device = device;
data.drawable = pixmap;
+ data.font = device.systemFont.handle;
data.image = this;
}
return gdkGC;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
index 3b62919112..31bf01d7ef 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
@@ -27,7 +27,6 @@ import org.eclipse.swt.events.*;
* </p>
*/
public class Button extends Control {
- int boxHandle;
Image image;
String text;
@@ -112,9 +111,9 @@ public void addSelectionListener (SelectionListener listener) {
void createHandle (int index) {
state |= HANDLE;
int bits = SWT.ARROW | SWT.TOGGLE | SWT.CHECK | SWT.RADIO | SWT.PUSH;
-
- boxHandle = OS.gtk_event_box_new ();
- if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ fixedHandle = OS.gtk_fixed_new ();
+ if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_fixed_set_has_window (fixedHandle, true);
switch (style & bits) {
case SWT.ARROW:
handle = OS.gtk_button_new ();
@@ -137,22 +136,15 @@ void createHandle (int index) {
break;
}
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
-}
-
-void setHandleStyle() {}
-
-void configure() {
- parent._connectChild(topHandle());
- OS.gtk_container_add (boxHandle, handle);
-}
-
-void showHandle() {
- OS.gtk_widget_show (boxHandle);
+ int parentHandle = parent.parentingHandle ();
+ OS.gtk_container_add (parentHandle, fixedHandle);
+ OS.gtk_container_add (fixedHandle, handle);
+ OS.gtk_widget_show (fixedHandle);
OS.gtk_widget_show (handle);
- OS.gtk_widget_realize (handle);
}
void hookEvents () {
+ //TEMPORARY CODE
super.hookEvents();
/*
* Feature in GTK. For some reason, when the widget
@@ -160,26 +152,29 @@ void hookEvents () {
* release events are not signaled. The fix is to
* look for them on the parent.
*/
- if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
- int mask = OS.GDK_POINTER_MOTION_MASK | OS.GDK_KEY_RELEASE_MASK;
- OS.gtk_widget_add_events (boxHandle, mask);
- signal_connect_after (boxHandle, "motion_notify_event", SWT.MouseMove, 3);
- signal_connect_after (boxHandle, "key_release_event", SWT.KeyUp, 3);
- }
+// if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
+// int mask = OS.GDK_POINTER_MOTION_MASK | OS.GDK_KEY_RELEASE_MASK;
+// OS.gtk_widget_add_events (boxHandle, mask);
+// signal_connect_after (boxHandle, "motion_notify_event", SWT.MouseMove, 3);
+// signal_connect_after (boxHandle, "key_release_event", SWT.KeyUp, 3);
+// }
signal_connect (handle, "clicked", SWT.Selection, 2);
}
-void register () {
- super.register ();
- WidgetTable.put (boxHandle, this);
-}
-
void createWidget (int index) {
super.createWidget (index);
text = "";
}
-int topHandle () { return boxHandle; }
+int fontHandle () {
+ //FIX ME - font lost when no text
+ int list = OS.gtk_container_children (handle);
+ if (list != 0) {
+ int widget = OS.g_list_nth_data (list, 0);
+ if (widget != 0) return widget;
+ }
+ return super.fontHandle ();
+}
/**
* Returns a value which describes the position of the
@@ -459,20 +454,9 @@ int processSelection (int int0, int int1, int int2) {
return 0;
}
-void deregister () {
- super.deregister ();
- WidgetTable.remove (boxHandle);
-}
-
void releaseWidget () {
super.releaseWidget ();
image = null;
text = null;
}
-
-void releaseHandle () {
- super.releaseHandle ();
- boxHandle = 0;
-}
-
} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java
index 9284802004..e164015820 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java
@@ -29,14 +29,8 @@ import org.eclipse.swt.graphics.*;
* @see Composite
*/
public class Canvas extends Composite {
-
Caret caret;
-/*
- * === CONSTRUCTORS ===
- */
-
-
Canvas () {}
/**
@@ -167,6 +161,7 @@ public void scroll (int destX, int destY, int x, int y, int width, int height, b
/* Show the caret */
if (isVisible) caret.showCaret ();
}
+
/**
* Sets the receiver's caret.
* <p>
@@ -198,58 +193,26 @@ public void setCaret (Caret caret) {
if (newCaret != null) newCaret.setFocus ();
}
}
+
public boolean setFocus () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if ((style & SWT.NO_FOCUS) != 0) return false;
return super.setFocus ();
}
+
int processFocusIn (int int0, int int1, int int2) {
int result = super.processFocusIn (int0, int1, int2);
if (caret != null) caret.setFocus ();
return result;
}
+
int processFocusOut(int int0, int int1, int int2) {
int result = super.processFocusOut (int0, int1, int2);
if (caret != null) caret.killFocus ();
return result;
}
-/*
-int processMouseDown (int callData, int arg1, int int2) {
- if ((UtilFuncs.GTK_WIDGET_GET_FLAGS(handle) & OS.GTK_HAS_FOCUS) == 0)
- OS.gtk_widget_grab_focus(handle);
- GdkEventButton gdkEvent = new GdkEventButton ();
- OS.memmove (gdkEvent, callData, GdkEventButton.sizeof);
- int eventType = SWT.MouseDown;
- if (gdkEvent.type == OS.GDK_2BUTTON_PRESS) eventType = SWT.MouseDoubleClick;
- sendMouseEvent (eventType, gdkEvent.button, gdkEvent.state, gdkEvent.time, (int)gdkEvent.x, (int)gdkEvent.y);
- if (gdkEvent.button == 3 && menu != null) {
- menu.setVisible (true);
- }
- return 1;
-}
-int processMouseUp (int callData, int arg1, int int2) {
- GdkEventButton gdkEvent = new GdkEventButton ();
- OS.memmove (gdkEvent, callData, GdkEventButton.sizeof);
- sendMouseEvent (SWT.MouseUp, gdkEvent.button, gdkEvent.state, gdkEvent.time, (int)gdkEvent.x, (int)gdkEvent.y);
- return 1;
-}
-*/
-int processPaint (int callData, int arg1, int int2) {
- //if (!hooks (SWT.Paint)) return 0;
-
- GdkEventExpose gdkEvent = new GdkEventExpose (callData);
- Event event = new Event ();
- event.count = gdkEvent.count;
- event.x = gdkEvent.x; event.y = gdkEvent.y;
- event.width = gdkEvent.width; event.height = gdkEvent.height;
- GC gc = event.gc = new GC (this);
- sendEvent (SWT.Paint, event);
- gc.dispose ();
- event.gc = null;
- return 0;
-}
void releaseWidget () {
if (caret != null) caret.releaseWidget ();
caret = null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java
index babeb98591..fc1b33b96b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java
@@ -66,6 +66,14 @@ public Caret (Canvas parent, int style) {
this.parent = parent;
createWidget (0);
}
+
+boolean blinkCaret () {
+ if (!isVisible) return true;
+ if (!isShowing) return showCaret ();
+ if (blinkRate == 0) return true;
+ return hideCaret ();
+}
+
void createWidget (int index) {
super.createWidget (index);
isVisible = true;
@@ -74,26 +82,13 @@ void createWidget (int index) {
}
}
-boolean blinkCaret () {
- if (!isVisible) return true;
- if (!isShowing) return showCaret();
- if (blinkRate==0) return true;
- return hideCaret();
-}
-
boolean drawCaret () {
if (parent == null) return false;
if (parent.isDisposed ()) return false;
- /* The parent is a Canvas; its handle is a GtkDrawingArea.
- * Get the DA's GDK window to draw on.
- */
- int window = OS.GTK_WIDGET_WINDOW(parent.handle);
+ int window = OS.GTK_WIDGET_WINDOW (parent.handle);
+ int gc = OS.gdk_gc_new (window);
- /* Create the GC, and set the working color and rop. */
- int gc = OS.gdk_gc_new(window);
- GdkGCValues gcvalues = new GdkGCValues();
- OS.gdk_gc_get_values(gc, gcvalues);
/* Actually, we should look at the background and foreground colors.
* This would require distinguishing between the cases when the GC
* gives the color as RGB or Pixel, and in the case of Pixel, we
@@ -101,19 +96,25 @@ boolean drawCaret () {
* In general, it's not easy to find out the RGB value of a GdkColor
* (somebody please correct me if I am wrong).
*/
- GdkColor c = new GdkColor();
- c.red = c.green = c.blue = (short)0xFFFF;
- OS.gdk_color_alloc(OS.gdk_colormap_get_system(), c);
- OS.gdk_gc_set_foreground(gc, c);
- OS.gdk_gc_set_function(gc, OS.GDK_XOR);
+ GdkColor c = new GdkColor ();
+ c.red = c.green = c.blue = (short) 0xFFFF;
+ OS.gdk_color_alloc (OS.gdk_colormap_get_system (), c);
+ OS.gdk_gc_set_foreground (gc, c);
+ OS.gdk_gc_set_function (gc, OS.GDK_XOR);
/* Draw the caret */
- int nWidth = width;
+ int nWidth = width, nHeight = height;
+ if (image != null) {
+ Rectangle rect = image.getBounds ();
+ nWidth = rect.width;
+ nHeight = rect.height;
+ }
if (nWidth <= 0) nWidth = 2;
- OS.gdk_draw_rectangle(window, gc, 1, x, y, nWidth, height);
- OS.g_object_unref(gc);
+ OS.gdk_draw_rectangle (window, gc, 1, x, y, nWidth, nHeight);
+ OS.g_object_unref (gc);
return true;
}
+
/**
* Returns a rectangle describing the receiver's size and location
* relative to its parent (or its display if its parent is null).
@@ -126,15 +127,20 @@ boolean drawCaret () {
* </ul>
*/
public Rectangle getBounds () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
+ if (image != null) {
+ Rectangle rect = image.getBounds ();
+ return new Rectangle (x, y, rect.width, rect.height);
+ }
return new Rectangle (x, y, width, height);
}
+
public Display getDisplay () {
Composite parent = this.parent;
if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
return parent.getDisplay ();
}
+
/**
* Returns the font that the receiver will use to paint textual information.
*
@@ -146,10 +152,25 @@ public Display getDisplay () {
* </ul>
*/
public Font getFont () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return parent.getFont ();
}
+
+/**
+ * Returns the image that the receiver will use to paint the caret.
+ *
+ * @return the receiver's image
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getImage () {
+ checkWidget();
+ return image;
+}
+
/**
* Returns a point describing the receiver's location relative
* to its parent (or its display if its parent is null).
@@ -162,10 +183,10 @@ public Font getFont () {
* </ul>
*/
public Point getLocation () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return new Point (x, y);
}
+
/**
* Returns the receiver's parent, which must be a <code>Canvas</code>.
*
@@ -177,10 +198,10 @@ public Point getLocation () {
* </ul>
*/
public Canvas getParent () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return parent;
}
+
/**
* Returns a point describing the receiver's size.
*
@@ -192,10 +213,14 @@ public Canvas getParent () {
* </ul>
*/
public Point getSize () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
+ if (image != null) {
+ Rectangle rect = image.getBounds ();
+ return new Point (rect.width, rect.height);
+ }
return new Point (width, height);
}
+
/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.
@@ -214,17 +239,18 @@ public Point getSize () {
* </ul>
*/
public boolean getVisible () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return isVisible;
}
+
boolean hideCaret () {
-// Display display = getDisplay ();
-// if (display.currentCaret != this) return false;
+ Display display = getDisplay ();
+ if (display.currentCaret != this) return false;
if (!isShowing) return true;
isShowing = false;
return drawCaret ();
}
+
/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.
@@ -243,37 +269,33 @@ boolean hideCaret () {
* </ul>
*/
public boolean isVisible () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return isVisible && parent.isVisible (); // && parent.hasFocus ();
+ checkWidget();
+ return isVisible && parent.isVisible () && parent.isFocusControl ();
}
+
void killFocus () {
-// OS.DestroyCaret ();
-// self restoreFont.
-}
-void move () {
- showCaret();
- moved = false;
+ Display display = getDisplay ();
+ if (display.currentCaret != this) return;
+ if (isVisible) hideCaret ();
+ display.setCurrentCaret (null);
}
+
void releaseChild () {
super.releaseChild ();
if (this == parent.getCaret ()) parent.setCaret (null);
}
+
void releaseWidget () {
super.releaseWidget ();
+ Display display = getDisplay ();
+ if (display.currentCaret == this) {
+ if (isVisible) hideCaret ();
+ display.setCurrentCaret (null);
+ }
parent = null;
+ image = null;
}
-void resize () {
- int hwnd = parent.handle;
- if (hwnd == 0) return;
-// OS.DestroyCaret ();
-// OS.CreateCaret (hwnd, 0, width, height);
-// OS.SetCaretPos (x, y);
-// OS.ShowCaret (hwnd);
-// self move.
-// showCaret();
- resized = false;
-}
+
/**
* Sets the receiver's size and location to the rectangular
* area specified by the arguments. The <code>x</code> and
@@ -291,25 +313,29 @@ void resize () {
* </ul>
*/
public void setBounds (int x, int y, int width, int height) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
boolean samePosition, sameExtent, showing;
samePosition = (this.x == x) && (this.y == y);
sameExtent = (this.width == width) && (this.height == height);
- if (samePosition && sameExtent) return;
+ if ((samePosition) && (sameExtent)) return;
if (isShowing) hideCaret ();
this.x = x; this.y = y;
this.width = width; this.height = height;
if (sameExtent) {
- moved = true;
- if (isVisible ()) move ();
+ moved = true;
+ if (isVisible ()) {
+ moved = false;
+ }
} else {
- resized = true;
- if (isVisible ()) resize ();
+ resized = true;
+ if (isVisible ()) {
+ moved = false;
+ resized = false;
+ }
}
- if(isVisible())
- showCaret ();
+ if (isShowing) showCaret ();
}
+
/**
* Sets the receiver's size and location to the rectangular
* area specified by the argument. The <code>x</code> and
@@ -324,13 +350,15 @@ public void setBounds (int x, int y, int width, int height) {
* </ul>
*/
public void setBounds (Rectangle rect) {
+ checkWidget();
if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
setBounds (rect.x, rect.y, rect.width, rect.height);
}
+
void setFocus () {
- Display display = getDisplay();
- if (display.currentCaret==this) return;
- display.setCurrentCaret(this);
+ Display display = getDisplay ();
+ if (display.currentCaret == this) return;
+ display.setCurrentCaret (this);
if (isVisible) showCaret ();
}
@@ -350,28 +378,13 @@ void setFocus () {
* </ul>
*/
public void setFont (Font font) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (font != null && font.isDisposed ()) {
error (SWT.ERROR_INVALID_ARGUMENT);
}
}
/**
- * Returns the image that the receiver will use to paint the caret.
- *
- * @return the receiver's image
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Image getImage () {
- checkWidget();
- return image;
-}
-/**
* Sets the image that the receiver will use to paint the caret
* to the image specified by the argument, or to the default
* which is a filled rectangle if the argument is null
@@ -395,6 +408,7 @@ public void setImage (Image image) {
this.image = image;
if (isShowing) showCaret ();
}
+
/**
* Sets the receiver's location to the point specified by
* the arguments which are relative to the receiver's
@@ -409,10 +423,10 @@ public void setImage (Image image) {
* </ul>
*/
public void setLocation (int x, int y) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
setBounds (x, y, width, height);
}
+
/**
* Sets the receiver's location to the point specified by
* the argument which is relative to the receiver's
@@ -426,11 +440,11 @@ public void setLocation (int x, int y) {
* </ul>
*/
public void setLocation (Point location) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
setLocation (location.x, location.y);
}
+
/**
* Sets the receiver's size to the point specified by the arguments.
*
@@ -443,13 +457,10 @@ public void setLocation (Point location) {
* </ul>
*/
public void setSize (int width, int height) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- if (this.width == width && this.height == height) return;
- this.width = width; this.height = height;
- resized = true;
- if (isVisible ()) resize ();
+ checkWidget();
+ setBounds (x, y, width, height);
}
+
/**
* Sets the receiver's size to the point specified by the argument.
*
@@ -465,11 +476,11 @@ public void setSize (int width, int height) {
* </ul>
*/
public void setSize (Point size) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
setSize (size.x, size.y);
}
+
/**
* Marks the receiver as visible if the argument is <code>true</code>,
* and marks it invisible otherwise.
@@ -487,20 +498,20 @@ public void setSize (Point size) {
* </ul>
*/
public void setVisible (boolean visible) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (visible == isVisible) return;
if (isVisible = visible) {
showCaret ();
} else {
hideCaret ();
}
-
}
+
boolean showCaret () {
-// if (getDisplay ().currentCaret != this) return false;
+ if (getDisplay ().currentCaret != this) return false;
if (isShowing) return true;
isShowing = true;
return drawCaret ();
}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
index f11e1ca89f..186892a509 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
@@ -46,7 +46,6 @@ import org.eclipse.swt.events.*;
*/
public class Combo extends Composite {
- int fixedHandle;
int entryHandle, listHandle;
int glist;
int textLimit = LIMIT;
@@ -271,33 +270,25 @@ public void clearSelection () {
void createHandle (int index) {
state |= HANDLE;
- fixedHandle = OS.eclipse_fixed_new();
+ fixedHandle = OS.gtk_fixed_new ();
if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_fixed_set_has_window (fixedHandle, true);
handle = OS.gtk_combo_new ();
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
GtkCombo combo = new GtkCombo (handle);
entryHandle = combo.entry;
listHandle = combo.list;
-}
-void setHandleStyle() {
- boolean isEditable = (style & SWT.READ_ONLY) == 0;
- OS.gtk_entry_set_editable (entryHandle, isEditable);
-}
-
-void configure () {
- parent._connectChild(topHandle());
- OS.gtk_container_add(fixedHandle, handle);
-}
-
-void showHandle() {
- OS.gtk_widget_show(fixedHandle);
- OS.gtk_widget_show(handle);
- OS.gtk_widget_realize (handle);
+ boolean editable = (style & SWT.READ_ONLY) == 0;
+ OS.gtk_entry_set_editable (entryHandle, editable);
+ int parentHandle = parent.parentingHandle ();
+ OS.gtk_container_add (parentHandle, fixedHandle);
+ OS.gtk_container_add (fixedHandle, handle);
+ OS.gtk_widget_show (fixedHandle);
+ OS.gtk_widget_show (handle);
}
void deregister () {
super.deregister ();
- WidgetTable.remove (fixedHandle);
WidgetTable.remove (entryHandle);
WidgetTable.remove (listHandle);
}
@@ -312,54 +303,26 @@ void hookEvents () {
OS.GDK_POINTER_MOTION_MASK |
OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK |
OS.GDK_KEY_PRESS_MASK | OS.GDK_KEY_RELEASE_MASK;
-
- OS.gtk_widget_add_events (entryHandle, mask);
- OS.gtk_widget_add_events (listHandle, mask);
-
- signal_connect_after (entryHandle, "motion_notify_event", SWT.MouseMove, 3);
- signal_connect_after (entryHandle, "button_press_event", SWT.MouseDown, 3);
- signal_connect_after (entryHandle, "button_release_event", SWT.MouseUp, 3);
- signal_connect_after (entryHandle, "key_press_event", SWT.KeyDown, 3);
- signal_connect_after (entryHandle, "key_release_event", SWT.KeyUp, 3);
-
- signal_connect_after (listHandle, "motion_notify_event", SWT.MouseMove, 3);
- signal_connect_after (listHandle, "button_press_event", SWT.MouseDown, 3);
- signal_connect_after (listHandle, "button_release_event", SWT.MouseUp, 3);
- signal_connect_after (listHandle, "key_press_event", SWT.KeyDown, 3);
- signal_connect_after (listHandle, "key_release_event", SWT.KeyUp, 3);
-
- signal_connect_after (handle, "motion_notify_event", SWT.MouseMove, 3);
- signal_connect_after (handle, "button_press_event", SWT.MouseDown, 3);
- signal_connect_after (handle, "button_release_event", SWT.MouseUp, 3);
- signal_connect_after (handle, "key_press_event", SWT.KeyDown, 3);
- signal_connect_after (handle, "key_release_event", SWT.KeyUp, 3);
-}
-
-int topHandle() { return fixedHandle; }
-int parentingHandle() { return fixedHandle; }
-boolean isMyHandle(int h) {
- if (h==fixedHandle) return true;
- if (h==handle) return true;
- if (h== entryHandle) return true;
- if (h== listHandle) return true;
- return false;
-}
-
-Point _getClientAreaSize () {
- //return _getSize();
- /* FIXME */
- return new Point(70, 20);
-}
-
-void _setSize(int width, int height) {
- width = 70; height = 20;
- super._setSize(width, height);
- OS.eclipse_fixed_set_size(fixedHandle, handle, width, height);
+ //FIXME - missing button handle
+ int [] handles = new int [] {entryHandle, listHandle, /*combo.button*/};
+ for (int i=0; i<handles.length; i++) {
+ int handle = handles [i];
+ if (!OS.GTK_WIDGET_NO_WINDOW (handle)) {
+ OS.gtk_widget_add_events (handle, mask);
+ }
+ signal_connect_after (handle, "event", SWT.MouseDown, 3);
+ signal_connect_after (handle, "motion_notify_event", SWT.MouseMove, 3);
+// signal_connect_after (handle, "button_press_event", SWT.MouseDown, 3);
+// signal_connect_after (handle, "button_release_event", SWT.MouseUp, 3);
+ signal_connect_after (handle, "key_press_event", SWT.KeyDown, 3);
+ signal_connect_after (handle, "key_release_event", SWT.KeyUp, 3);
+ }
}
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
- return new Point (70,20);
+ //FIXME - hardcoded and wrong for SIMPLE
+ return new Point (50, 20);
}
/**
@@ -398,13 +361,6 @@ public void deselectAll () {
setItems (getItems ());
}
-/*
- * FIXME
-protected boolean hasFocus () {
- return super.hasFocus();
-}
-*/
-
/**
* Returns the item at the given, zero-relative index in the
* receiver's list. Throws an exception if the index is out
@@ -559,16 +515,14 @@ public int getSelectionIndex () {
*/
public String getText () {
checkWidget();
+ /*
+ * The GTK documentation explicitly states
+ * that this address should not be freed.
+ */
int address = OS.gtk_entry_get_text (entryHandle);
int length = OS.strlen (address);
byte [] buffer1 = new byte [length];
OS.memmove (buffer1, address, length);
- /*
- * This code is intentionally commented.
- * The GTK documentation explicitly states
- * that this address should not be freed.
- */
-// OS.g_free (address);
char [] buffer2 = Converter.mbcsToWcs (null, buffer1);
return new String (buffer2, 0, buffer2.length);
}
@@ -597,13 +551,8 @@ String getText (int start, int stop) {
*/
public int getTextHeight () {
checkWidget();
- /* A native approach, just measuring the entry:
- * return UtilFuncs.getSize(_entryHandle).y;
- * does not work - the entry is the same size as
- * the whole combo.
- */
- error (SWT.ERROR_CANNOT_GET_ITEM_HEIGHT);
- return 0;
+ //FIXME
+ return 20;
}
/**
@@ -674,6 +623,10 @@ public int indexOf (String string, int start) {
return -1;
}
+int parentingHandle() {
+ return fixedHandle;
+}
+
int processModify (int arg0, int arg1, int int2) {
sendEvent (SWT.Modify);
return 0;
@@ -685,15 +638,14 @@ int processSelection (int int0, int int1, int int2) {
}
void register () {
- WidgetTable.put (handle, this);
- WidgetTable.put (fixedHandle, this);
+ super.register ();
WidgetTable.put (entryHandle, this);
WidgetTable.put (listHandle, this);
}
void releaseHandle () {
super.releaseHandle ();
- int padHandle = 0;
+ entryHandle = listHandle = 0;
}
void releaseWidget () {
@@ -881,6 +833,12 @@ public void select (int index) {
OS.gtk_signal_handler_unblock_by_data (listHandle, SWT.Selection);
}
+boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ checkWidget();
+ int newHeight = (resize && (style & SWT.DROP_DOWN) != 0) ? getTextHeight() : height;
+ return super.setBounds (x, y, width, newHeight, move, resize);
+}
+
/**
* Sets the text of the item in the receiver's list at the given
* zero-relative index to the string argument. This is equivalent
@@ -928,7 +886,7 @@ public void setItem (int index, String string) {
*/
public void setItems (String [] items) {
checkWidget();
- /*if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
if (items.length == 0) {
OS.gtk_list_clear_items (listHandle, 0, -1);
//LEAK
@@ -961,7 +919,7 @@ public void setItems (String [] items) {
}
OS.gtk_signal_handler_block_by_data (entryHandle, SWT.Modify);
OS.gtk_editable_delete_text (entryHandle, 0, -1);
- OS.gtk_signal_handler_unblock_by_data (entryHandle, SWT.Modify);*/
+ OS.gtk_signal_handler_unblock_by_data (entryHandle, SWT.Modify);
}
/**
@@ -987,10 +945,6 @@ public void setSelection (Point selection) {
OS.gtk_editable_select_region (entryHandle, selection.x, selection.y);*/
}
-protected boolean setTabGroupFocus () {
- return setFocus ();
-}
-
/**
* Sets the contents of the receiver's text field to the
* given string.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
index 936ead72fa..cd7385c6f4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
@@ -28,14 +28,9 @@ import org.eclipse.swt.graphics.*;
* @see Canvas
*/
public class Composite extends Scrollable {
- /* boxHandle is temporarily here, until eclipsefixed gets fixed */
- int boxHandle, fixedHandle, radioHandle;
+ int radioHandle;
Layout layout;
-/*
- * === CONSTRUCTORS ===
- */
-
Composite () {
/* Do nothing */
}
@@ -72,121 +67,105 @@ public Composite (Composite parent, int style) {
super (parent, style);
}
-/*
- * === Handle code begins ===
- */
void createHandle (int index) {
state |= HANDLE | CANVAS;
-
- scrolledHandle = OS.gtk_scrolled_window_new(0,0);
- if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
-
- boxHandle = OS.gtk_event_box_new();
- if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES);
-
- fixedHandle = OS.eclipse_fixed_new();
- if (fixedHandle == 0) SWT.error (SWT.ERROR_NO_HANDLES);
-
- handle = OS.gtk_drawing_area_new();
+ createScrolledHandle (parent.parentingHandle ());
+}
+
+void createScrolledHandle (int parentHandle) {
+ //TEMPORARY CODE
+// boolean isScrolled = (style & (SWT.H_SCROLL | SWT.V_SCROLL)) != 0;
+ boolean isScrolled = true;
+ if (isScrolled) {
+ fixedHandle = OS.gtk_fixed_new ();
+ if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_fixed_set_has_window (fixedHandle, true);
+ int vadj = OS.gtk_adjustment_new (0, 0, 100, 1, 10, 10);
+ if (vadj == 0) error (SWT.ERROR_NO_HANDLES);
+ int hadj = OS.gtk_adjustment_new (0, 0, 100, 1, 10, 10);
+ if (hadj == 0) error (SWT.ERROR_NO_HANDLES);
+ scrolledHandle = OS.gtk_scrolled_window_new (hadj, vadj);
+ if (scrolledHandle == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+ }
+ handle = OS.gtk_fixed_new ();
if (handle == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_fixed_set_has_window (handle, true);
OS.GTK_WIDGET_SET_FLAGS(handle, OS.GTK_CAN_FOCUS);
+ if (isScrolled) {
+ OS.gtk_container_add (parentHandle, fixedHandle);
+ OS.gtk_container_add (fixedHandle, scrolledHandle);
+
+// /*
+// * Force the scrolledWindow to have a single child that is
+// * not scrolled automatically. Calling gtk_container_add
+// * seems to add the child correctly but cause a warning.
+// */
+// OS.GTK_BIN_SET_CHILD(scrolledHandle, handle);
+// OS.gtk_widget_set_parent(handle, scrolledHandle);
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.gtk_container_add (scrolledHandle, handle);
+ display.setWarnings (warnings);
+
+ OS.gtk_widget_show (fixedHandle);
+ OS.gtk_widget_show (scrolledHandle);
+ int hsp = (style & SWT.H_SCROLL) == 0 ? OS.GTK_POLICY_NEVER : OS.GTK_POLICY_ALWAYS;
+ int vsp = (style & SWT.V_SCROLL) == 0 ? OS.GTK_POLICY_NEVER : OS.GTK_POLICY_ALWAYS;
+ OS.gtk_scrolled_window_set_policy (scrolledHandle, hsp, vsp);
+ //CHECK WITH IS THERE ALREADY THEN DON'T SET
+ if ((style & SWT.BORDER) != 0) {
+ OS.gtk_scrolled_window_set_shadow_type(scrolledHandle, OS.GTK_SHADOW_ETCHED_IN);
+ }
+ } else {
+ OS.gtk_container_add (parentHandle, handle);
+ }
+ OS.gtk_widget_show (handle);
+
+ //DOESN'T WORK RIGHT NOW
+ if ((style & SWT.NO_REDRAW_RESIZE) != 0) {
+ OS.gtk_widget_set_redraw_on_allocate (handle, false);
+ }
}
-void configure() {
- parent._connectChild(scrolledHandle);
- OS.gtk_container_add(scrolledHandle, boxHandle);
- OS.gtk_container_add(boxHandle, fixedHandle);
- OS.gtk_container_add(fixedHandle, handle);
-}
-
-void setHandleStyle() {
- setScrollingPolicy();
-}
-
-void showHandle() {
- OS.gtk_widget_show_now (scrolledHandle);
- OS.gtk_widget_show_now (boxHandle);
- OS.gtk_widget_show_now (fixedHandle);
- OS.gtk_widget_realize (handle);
- OS.gtk_widget_show_now (handle);
-}
-
-void hookEvents () {
- signal_connect_after (handle, "expose_event", SWT.Paint, 3);
- int mask =
- OS.GDK_POINTER_MOTION_MASK |
- OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK |
- OS.GDK_ENTER_NOTIFY_MASK | OS.GDK_LEAVE_NOTIFY_MASK |
- OS.GDK_KEY_PRESS_MASK | OS.GDK_KEY_RELEASE_MASK |
- OS.GDK_FOCUS_CHANGE_MASK;
- OS.gtk_widget_add_events (handle, mask);
- signal_connect_after (handle, "motion_notify_event", SWT.MouseMove, 3);
- signal_connect_after (handle, "button_press_event", SWT.MouseDown, 3);
- signal_connect_after (handle, "button_release_event", SWT.MouseUp, 3);
- signal_connect_after (handle, "enter_notify_event", SWT.MouseEnter, 3);
- signal_connect_after (handle, "leave_notify_event", SWT.MouseExit, 3);
- signal_connect_after (handle, "key_press_event", SWT.KeyDown, 3);
- signal_connect_after (handle, "key_release_event", SWT.KeyUp, 3);
- signal_connect_after (handle, "focus_in_event", SWT.FocusIn, 3);
- signal_connect_after (handle, "focus_out_event", SWT.FocusOut, 3);
-}
-
-int topHandle() { return scrolledHandle; }
-int parentingHandle() { return fixedHandle; }
-boolean isMyHandle(int h) {
- if (h==boxHandle) return true;
- if (h==fixedHandle) return true;
- return super.isMyHandle(h);
-}
-
-
-/*
- * === GEOMETRY - PHYSICAL ===
- */
-
-
-public void setBounds (int x, int y, int width, int height) {
- super.setBounds (x, y, width, height);
- layout();
-}
-
-public void setSize (int width, int height) {
- super.setSize(width, height);
- layout();
-}
-Point getScrollableTrim() {
- /*
- * This is very tricky.
- * In SWT/GTK, layout is not managed by the GtkContainers.
- * Therefore, the native preferred minimum sizes are
- * generally ignored. This allows us to set the native
- * size of the fixed to whatever value we want, and it is
- * guaranteed to be disregarded by the layout code.
- * At this point, that size is requested by the Scrollable,
- * gets added to by whatever is between the scrollable
- * and the fixed, and serves as the basis for the native
- * Scrollable size requisition (which is also guaranteed
- * to be thrown away).
- */
- OS.GTK_WIDGET_SET_FLAGS(parentingHandle(), OS.GTK_VISIBLE);
- OS.GTK_WIDGET_SET_FLAGS(boxHandle, OS.GTK_VISIBLE);
- GtkRequisition clientReq = new GtkRequisition();
- GtkRequisition req = new GtkRequisition();
- OS.gtk_widget_size_request(parentingHandle(), clientReq);
- OS.gtk_widget_size_request(scrolledHandle, req);
- if ((style&SWT.H_SCROLL&SWT.V_SCROLL)!=0) return new Point (req.width-clientReq.width, req.height-clientReq.height);
- if ((style&SWT.H_SCROLL)!=0) return new Point (0, req.height-clientReq.height);
- if ((style&SWT.V_SCROLL)!=0) return new Point (req.width-clientReq.width, 0);
- return new Point (0,0);
-}
-void _setSize(int width, int height) {
- OS.eclipse_fixed_set_size(parent.parentingHandle(), topHandle(), width, height);
- /* This is the trim on the right caused by the scrollbars */
- Point st = getScrollableTrim();
- if ((style&SWT.V_SCROLL) != 0) width -= st.x; width = Math.max(width, 0);
- if ((style&SWT.H_SCROLL) != 0) height -= st.y; height = Math.max(height, 0);
- OS.eclipse_fixed_set_size(fixedHandle, handle, width, height);
-}
+int parentingHandle () {
+ if ((state & CANVAS) != 0) return handle;
+ return fixedHandle != 0 ? fixedHandle : handle;
+}
+
+boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ boolean changed = super.setBounds (x, y, width, height, move, resize);
+ if (changed && resize && layout != null) layout.layout (this, false);
+ return changed;
+}
+
+// USE FOR TRIM ????
+//
+//Point getScrollableTrim() {
+// /*
+// * This is very tricky.
+// * In SWT/GTK, layout is not managed by the GtkContainers.
+// * Therefore, the native preferred minimum sizes are
+// * generally ignored. This allows us to set the native
+// * size of the fixed to whatever value we want, and it is
+// * guaranteed to be disregarded by the layout code.
+// * At this point, that size is requested by the Scrollable,
+// * gets added to by whatever is between the scrollable
+// * and the fixed, and serves as the basis for the native
+// * Scrollable size requisition (which is also guaranteed
+// * to be thrown away).
+// */
+// OS.GTK_WIDGET_SET_FLAGS(parentingHandle(), OS.GTK_VISIBLE);
+// OS.GTK_WIDGET_SET_FLAGS(boxHandle, OS.GTK_VISIBLE);
+// GtkRequisition clientReq = new GtkRequisition();
+// GtkRequisition req = new GtkRequisition();
+// OS.gtk_widget_size_request(parentingHandle(), clientReq);
+// OS.gtk_widget_size_request(scrolledHandle, req);
+// if ((style&SWT.H_SCROLL&SWT.V_SCROLL)!=0) return new Point (req.width-clientReq.width, req.height-clientReq.height);
+// if ((style&SWT.H_SCROLL)!=0) return new Point (0, req.height-clientReq.height);
+// if ((style&SWT.V_SCROLL)!=0) return new Point (req.width-clientReq.width, 0);
+// return new Point (0,0);
+//}
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
@@ -208,11 +187,6 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
return new Point (trim.width, trim.height);
}
-
-/*
- * === GEOMETRY - LAYOUT ===
- */
-
/**
* Returns layout which is associated with the receiver, or
* null if one has not been set.
@@ -278,57 +252,34 @@ public void setLayout (Layout layout) {
*/
public Control [] getChildren () {
checkWidget();
- return _getChildren(parentingHandle());
-}
-
-/**
- * Answer the array of the children of the specified handle,
- * filtering out widgets we don't consider our children.
- * That is, the OS may return some children that don't qualify
- * as such under SWT terminology - e.g., Items are not children.
- */
-Control [] _getChildren (int h) {
- if (h==0) {
- error(SWT.ERROR_UNSPECIFIED);
- }
- int list = OS.gtk_container_children (h);
- int count = OS.g_list_length (list);
- java.util.Vector children = new java.util.Vector();
- for (int i=0; i<count; i++) {
- int data = OS.g_list_nth_data (list, i);
- if (!isMyHandle(data)) {
- Control child = _childFromHandle(data);
- if (child != null) children.addElement(child);
+ return _getChildren ();
+}
+
+Control [] _getChildren () {
+ int parentHandle = parentingHandle ();
+ int list = OS.gtk_container_children (parentHandle);
+ int count = (list != 0) ? OS.g_list_length (list) : 0;
+ if (count == 0) return new Control [0];
+ Control [] children = new Control [count];
+ int i = 0, j = 0;
+ while (i < count) {
+ int handle = OS.g_list_nth_data (list, i);
+ if (handle != 0) {
+ Widget widget = WidgetTable.get (handle);
+ if (widget != null && widget != this) {
+ if (widget instanceof Control) {
+ children [j++] = (Control) widget;
+ }
+ }
}
+ i++;
}
- Control[] answer = new Control[children.size()];
- children.copyInto(answer);
- return answer;
-}
-/**
- * Consider the argument a handle of one of the receiver's children.
- * If the argument is not a handle to a widget, or the widget is
- * not our child in SWT (not OS) terminology, return null.
- */
-Control _childFromHandle(int h) {
- Widget child = WidgetTable.get(h);
- return (Control)child;
-}
-
-public Rectangle getClientArea () {
- checkWidget();
- /* We can not measure the actual size of the client area,
- * because it may not have propagated down yet.
- */
- Point size = _getSize();
- /* FIXME - this code assumes the scrollbars are to the right */
- /* FIXME - I just measured the size on one particular theme. */
- if ((style & SWT.V_SCROLL) != 0) size.x -= 18;
- if ((style & SWT.H_SCROLL) != 0) size.y -= 18;
- return new Rectangle(0,0, size.x, size.y);
+ if (i == j) return children;
+ Control [] newChildren = new Control [j];
+ System.arraycopy (children, 0, newChildren, 0, j);
+ return newChildren;
}
-
/**
* If the receiver has a layout, asks the layout to <em>lay out</em>
* (that is, set the size and location of) the receiver's children.
@@ -345,6 +296,7 @@ public Rectangle getClientArea () {
public void layout () {
layout (true);
}
+
/**
* If the receiver has a layout, asks the layout to <em>lay out</em>
* (that is, set the size and location of) the receiver's children.
@@ -369,7 +321,7 @@ public void layout (boolean changed) {
}
Point minimumSize () {
- Control [] children = _getChildren (parentingHandle());
+ Control [] children = _getChildren ();
int width = 0, height = 0;
for (int i=0; i<children.length; i++) {
Rectangle rect = children [i].getBounds ();
@@ -392,15 +344,8 @@ void _initializeRadioGroup() {
radioHandle = OS.gtk_radio_button_new(0);
}
-/**
- * Adopt the widget h as our child.
- */
-void _connectChild (int h) {
- OS.gtk_container_add (parentingHandle(), h);
-}
-
void releaseChildren () {
- Control [] children = _getChildren (parentingHandle());
+ Control [] children = _getChildren ();
for (int i=0; i<children.length; i++) {
Control child = children [i];
if (child != null && !child.isDisposed ()) {
@@ -416,19 +361,37 @@ void releaseWidget () {
}
void releaseHandle () {
super.releaseHandle ();
- boxHandle = radioHandle = 0;
+ radioHandle = 0;
}
int processMouseDown (int callData, int arg1, int int2) {
- //NOT DONE - only grab when not already grabbing
- if ((state & CANVAS) != 0) OS.gtk_grab_add (handle);
- return super.processMouseDown (callData, arg1, int2);
+ int result = super.processMouseDown (callData, arg1, int2);
+ if ((state & CANVAS) != 0) {
+ //NOT DONE - only grab when not already grabbing
+ OS.gtk_grab_add (handle);
+ if ((style & SWT.NO_FOCUS) == 0) {
+ int list = OS.gtk_container_children (handle);
+ int count = list != 0 ? OS.g_list_length (list) : 0;
+ if (count == 0) OS.gtk_widget_grab_focus (handle);
+ }
+ return 1;
+ }
+ return result;
+}
+
+int processMouseMove (int callData, int arg1, int int2) {
+ int result = super.processMouseMove (callData, arg1, int2);
+ return (state & CANVAS) != 0 ? 1 : result;
}
int processMouseUp (int callData, int arg1, int int2) {
+ int result = super.processMouseUp (callData, arg1, int2);
//NOT DONE - only release when last button goes up
- if ((state & CANVAS) != 0) OS.gtk_grab_remove (handle);
- return super.processMouseUp (callData, arg1, int2);
+ if ((state & CANVAS) != 0) {
+ OS.gtk_grab_remove (handle);
+ return 1;
+ }
+ return result;
}
int processFocusIn(int int0, int int1, int int2) {
@@ -442,7 +405,7 @@ int processFocusOut(int int0, int int1, int int2) {
public boolean setFocus () {
checkWidget();
- Control [] children = _getChildren (parentingHandle());
+ Control [] children = _getChildren ();
for (int i=0; i<children.length; i++) {
Control child = children [i];
if (child.getVisible () && child.setFocus ()) return true;
@@ -450,6 +413,27 @@ public boolean setFocus () {
return super.setFocus ();
}
+void setInitialSize () {
+ if (scrolledHandle != 0) {
+ super.setInitialSize ();
+ return;
+ }
+ /*
+ * Bug in GTK. The scrollbars are not visible when a scrolled window
+ * is resize and then shown. The fix is to change the scrolling policy
+ * before and after resizing.
+ */
+ if ((state & CANVAS) != 0) {
+ OS.gtk_scrolled_window_set_policy (scrolledHandle, OS.GTK_POLICY_NEVER, OS.GTK_POLICY_NEVER);
+ }
+ super.setInitialSize ();
+ if ((state & CANVAS) != 0) {
+ int hsp = (style & SWT.H_SCROLL) == 0 ? OS.GTK_POLICY_NEVER : OS.GTK_POLICY_ALWAYS;
+ int vsp = (style & SWT.V_SCROLL) == 0 ? OS.GTK_POLICY_NEVER : OS.GTK_POLICY_ALWAYS;
+ OS.gtk_scrolled_window_set_policy (scrolledHandle, hsp, vsp);
+ }
+}
+
/**
* Sets the tabbing order for the specified controls to
* match the order that they occur in the argument list.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index a31a6b57f6..ea20d31f67 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -28,17 +28,13 @@ import org.eclipse.swt.accessibility.*;
* </p>
*/
public abstract class Control extends Widget implements Drawable {
-
+ int fixedHandle;
Composite parent;
Menu menu;
String toolTipText;
Object layoutData;
Accessible accessible;
-/*
- * === CONSTRUCTORS ===
- */
-
Control () {
}
@@ -76,16 +72,19 @@ public Control (Composite parent, int style) {
createWidget (0);
}
-/*
- * === HANDLE CODE ===
- */
-
-abstract void createHandle(int index);
+void deregister () {
+ super.deregister ();
+ if (fixedHandle != 0) WidgetTable.remove (fixedHandle);
+}
int eventHandle () {
return handle;
}
+int fontHandle () {
+ return handle;
+}
+
/**
* Connect the appropriate signal handlers.
*
@@ -114,65 +113,45 @@ int eventHandle () {
* </ul>
*/
void hookEvents () {
- signal_connect_after (handle, "expose_event", SWT.Paint, 3);
- int mask =
- OS.GDK_POINTER_MOTION_MASK |
- OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK |
- OS.GDK_ENTER_NOTIFY_MASK | OS.GDK_LEAVE_NOTIFY_MASK |
- OS.GDK_KEY_PRESS_MASK | OS.GDK_KEY_RELEASE_MASK |
- OS.GDK_FOCUS_CHANGE_MASK;
- if (!OS.GTK_WIDGET_NO_WINDOW (handle)) {
- OS.gtk_widget_add_events (handle, mask);
+ int eventHandle = eventHandle ();
+ signal_connect_after (eventHandle, "expose_event", SWT.Paint, 3);
+ //TEMPORARY CODE - always attempt to add events
+ if (true || !OS.GTK_WIDGET_NO_WINDOW (eventHandle)) {
+ int mask =
+// OS.GDK_EXPOSURE_MASK |
+ OS.GDK_POINTER_MOTION_MASK |
+ OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK |
+ OS.GDK_ENTER_NOTIFY_MASK | OS.GDK_LEAVE_NOTIFY_MASK |
+ OS.GDK_KEY_PRESS_MASK | OS.GDK_KEY_RELEASE_MASK |
+ OS.GDK_FOCUS_CHANGE_MASK;
+ OS.gtk_widget_add_events (eventHandle, mask);
}
- signal_connect_after (handle, "motion_notify_event", SWT.MouseMove, 3);
- signal_connect_after (handle, "button_press_event", SWT.MouseDown, 3);
- signal_connect_after (handle, "button_release_event", SWT.MouseUp, 3);
- signal_connect_after (handle, "enter_notify_event", SWT.MouseEnter, 3);
- signal_connect_after (handle, "leave_notify_event", SWT.MouseExit, 3);
- signal_connect_after (handle, "key_press_event", SWT.KeyDown, 3);
- signal_connect_after (handle, "key_release_event", SWT.KeyUp, 3);
- signal_connect_after (handle, "focus_in_event", SWT.FocusIn, 3);
- signal_connect_after (handle, "focus_out_event", SWT.FocusOut, 3);
+ signal_connect_after (eventHandle, "event", SWT.MouseDown, 3);
+// signal_connect_after (eventHandle, "button_press_event", SWT.MouseDown, 3);
+// signal_connect_after (eventHandle, "button_release_event", SWT.MouseUp, 3);
+ signal_connect_after (eventHandle, "motion_notify_event", SWT.MouseMove, 3);
+ signal_connect_after (eventHandle, "enter_notify_event", SWT.MouseEnter, 3);
+ signal_connect_after (eventHandle, "leave_notify_event", SWT.MouseExit, 3);
+ signal_connect_after (eventHandle, "key_press_event", SWT.KeyDown, 3);
+ signal_connect_after (eventHandle, "key_release_event", SWT.KeyUp, 3);
+ signal_connect_after (eventHandle, "focus_in_event", SWT.FocusIn, 3);
+ signal_connect_after (eventHandle, "focus_out_event", SWT.FocusOut, 3);
}
-abstract void setHandleStyle ();
-void setInitialSize() { _setSize(5,5); }
-void configure () {
- // Do NOT directly use fixed_put in configure():
- // surprisingly, not all composites have Fixed as their
- // parenting (bottom) handle. Should investigate further.
- parent._connectChild(topHandle());
+int topHandle() {
+ if (fixedHandle != 0) return fixedHandle;
+ return super.topHandle ();
}
-/**
- * Every Control must implement this to map the gtk widgets,
- * and also realize those that have to be realized - this means
- * create the actual X window so that there are no surprizes
- * if the user calls a method expecting the X window to be there.
- * Widgets normally do it by invoking gtk_widget_show() on all
- * handles, and then doing gtk_widget_realize() on bottommost
- * handle, which will realize everything above as well.
- * An exception to this is the Shell, which we do NOT realize
- * at this point.
- */
-void showHandle() {
- OS.gtk_widget_show (handle);
- OS.gtk_widget_realize (handle);
+int paintHandle () {
+ return handle;
}
-/**
- * This is the handle by which our parent holds us
- */
-int topHandle() { return handle; }
-/**
- * This is where we draw. Every widget must guarantee
- * that its paint handle has a Gdk window associated with it.
- */
-public int paintHandle() { return handle; } /* REALLY BROKEN, PENDING PANGO */
-boolean isMyHandle(int h) { return h==handle; }
-/*
- * === GEOMETRY ===
- */
+int paintWindow () {
+ int paintHandle = paintHandle ();
+ OS.gtk_widget_realize (paintHandle);
+ return OS.GTK_WIDGET_WINDOW (paintHandle);
+}
/**
* Returns the preferred size of the receiver.
@@ -200,6 +179,11 @@ public Point computeSize (int wHint, int hHint) {
return computeSize (wHint, hHint, true);
}
+void createWidget (int index) {
+ super.createWidget (index);
+ setInitialSize ();
+}
+
/**
* Returns the preferred size of the receiver.
* <p>
@@ -235,10 +219,14 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
}
Point computeNativeSize (int h, int wHint, int hHint, boolean changed) {
+ int width = OS.GTK_WIDGET_WIDTH (h);
+ int height = OS.GTK_WIDGET_HEIGHT (h);
+ OS.gtk_widget_set_size_request (h, -1, -1);
GtkRequisition requisition = new GtkRequisition ();
OS.gtk_widget_size_request (h, requisition);
- int width = wHint == SWT.DEFAULT ? requisition.width : wHint;
- int height = hHint == SWT.DEFAULT ? requisition.height : hHint;
+ OS.gtk_widget_set_size_request (h, width, height);
+ width = wHint == SWT.DEFAULT ? requisition.width : wHint;
+ height = hHint == SWT.DEFAULT ? requisition.height : hHint;
return new Point (width, height);
}
@@ -278,10 +266,12 @@ public Accessible getAccessible () {
*/
public Rectangle getBounds () {
checkWidget();
- Point location = _getLocation();
- Point size = _getSize();
- return new Rectangle(location.x, location.y, size.x, size.y);
-
+ int topHandle = topHandle ();
+ int x = OS.GTK_WIDGET_X (topHandle);
+ int y = OS.GTK_WIDGET_Y (topHandle);
+ int width = OS.GTK_WIDGET_WIDTH (topHandle);
+ int height = OS.GTK_WIDGET_HEIGHT (topHandle);
+ return new Rectangle (x, y, width, height);
}
/**
@@ -303,6 +293,7 @@ public Rectangle getBounds () {
* </ul>
*/
public void setBounds (Rectangle rect) {
+ checkWidget ();
if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
setBounds (rect.x, rect.y, rect.width, rect.height);
}
@@ -330,12 +321,60 @@ public void setBounds (Rectangle rect) {
*/
public void setBounds (int x, int y, int width, int height) {
checkWidget();
- Point old_location = _getLocation();
- Point old_size = _getSize();
- _setLocation (x, y);
- _setSize (width, height);
- if ((x!=old_location.x) || (y!=old_location.y)) sendEvent (SWT.Move);
- if ((width!=old_size.x) || (height!=old_size.y)) sendEvent (SWT.Resize);
+ setBounds (x, y, width, height, true, true);
+}
+
+void moveHandle (int x, int y) {
+ int topHandle = topHandle ();
+ int parentHandle = parent.parentingHandle ();
+ OS.gtk_fixed_move (parentHandle, topHandle, x, y);
+}
+
+void resizeHandle (int width, int height) {
+ int topHandle = topHandle ();
+ int flags = OS.GTK_WIDGET_FLAGS (topHandle);
+ OS.GTK_WIDGET_SET_FLAGS(topHandle, OS.GTK_VISIBLE);
+ OS.gtk_widget_set_size_request (topHandle, width, height);
+ if (topHandle != handle) {
+ OS.gtk_widget_set_size_request (handle, width, height);
+ }
+ //FIXME - causes scrollbar problems when button child of table
+ int parentHandle = parent.parentingHandle ();
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.gtk_container_resize_children (parentHandle);
+ display.setWarnings (warnings);
+
+ if ((flags & OS.GTK_VISIBLE) == 0) {
+ OS.GTK_WIDGET_UNSET_FLAGS(topHandle, OS.GTK_VISIBLE);
+ }
+}
+
+boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ int topHandle = topHandle ();
+ boolean sameOrigin = true, sameExtent = true;
+ if (move) {
+ int oldX = OS.GTK_WIDGET_X (topHandle);
+ int oldY = OS.GTK_WIDGET_Y (topHandle);
+ sameOrigin = x == oldX && y == oldY;
+ if (!sameOrigin) {
+ moveHandle (x, y);
+ sendEvent(SWT.Move);
+ }
+ }
+ if (resize) {
+ width = Math.max (1, width);
+ height = Math.max (1, height);
+ int oldWidth = OS.GTK_WIDGET_WIDTH (topHandle);
+ int oldHeight = OS.GTK_WIDGET_HEIGHT (topHandle);
+ sameExtent = width == oldWidth && height == oldHeight;
+ if (!sameExtent) {
+ resizeHandle (width, height);
+ sendEvent(SWT.Resize);
+ }
+ }
+ return !sameOrigin || !sameExtent;
}
/**
@@ -351,12 +390,10 @@ public void setBounds (int x, int y, int width, int height) {
*/
public Point getLocation () {
checkWidget();
- return _getLocation();
-}
-Point _getLocation () {
- int[] loc = new int[2];
- OS.eclipse_fixed_get_location(parent.parentingHandle(), topHandle(), loc);
- return new Point(loc[0], loc[1]);
+ int topHandle = topHandle ();
+ int x = OS.GTK_WIDGET_X (topHandle);
+ int y = OS.GTK_WIDGET_Y (topHandle);
+ return new Point (x, y);
}
/**
@@ -372,6 +409,7 @@ Point _getLocation () {
* </ul>
*/
public void setLocation (Point location) {
+ checkWidget ();
if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
setLocation (location.x, location.y);
}
@@ -391,13 +429,7 @@ public void setLocation (Point location) {
*/
public void setLocation(int x, int y) {
checkWidget();
- Point old_location = _getLocation();
- if ((x==old_location.x) && (y==old_location.y)) return;
- _setLocation(x,y);
- sendEvent(SWT.Move);
-}
-void _setLocation(int x, int y) {
- OS.eclipse_fixed_set_location(parent.parentingHandle(), topHandle(), x,y);
+ setBounds (x, y, 0, 0, true, false);
}
/**
@@ -415,12 +447,10 @@ void _setLocation(int x, int y) {
*/
public Point getSize () {
checkWidget();
- return _getSize();
-}
-Point _getSize() {
- int[] sz = new int[2];
- OS.eclipse_fixed_get_size(parent.parentingHandle(), topHandle(), sz);
- return new Point(sz[0], sz[1]);
+ int topHandle = topHandle ();
+ int width = OS.GTK_WIDGET_WIDTH (topHandle);
+ int height = OS.GTK_WIDGET_HEIGHT (topHandle);
+ return new Point (width, height);
}
/**
@@ -443,6 +473,7 @@ Point _getSize() {
* </ul>
*/
public void setSize (Point size) {
+ checkWidget ();
if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
setSize (size.x, size.y);
}
@@ -465,15 +496,7 @@ public void setSize (Point size) {
*/
public void setSize (int width, int height) {
checkWidget();
- width = Math.max(width, 0);
- height = Math.max(height, 0);
- Point old_size = _getSize();
- if ( (width==old_size.x) && (height==old_size.y) ) return;
- _setSize(width, height);
- sendEvent(SWT.Resize);
-}
-void _setSize(int width, int height) {
- OS.eclipse_fixed_set_size(parent.parentingHandle(), topHandle(), width, height);
+ setBounds (0, 0, width, height, false, true);
}
/**
@@ -495,9 +518,11 @@ void _setSize(int width, int height) {
*/
public void moveAbove (Control control) {
checkWidget();
- int siblingHandle = 0;
- if (control != null) siblingHandle = control.topHandle();
- OS.eclipse_fixed_move_above(parent.parentingHandle(), topHandle(), siblingHandle);
+// int siblingHandle = 0;
+// if (control != null) siblingHandle = control.topHandle();
+ int topHandle = topHandle ();
+ int window = OS.GTK_WIDGET_WINDOW (topHandle);
+ if (window != 0) OS.gdk_window_raise (window);
}
/**
@@ -519,9 +544,11 @@ public void moveAbove (Control control) {
*/
public void moveBelow (Control control) {
checkWidget();
- int siblingHandle = 0;
- if (control != null) siblingHandle = control.topHandle();
- OS.eclipse_fixed_move_below(parent.parentingHandle(), topHandle(), siblingHandle);
+// int siblingHandle = 0;
+// if (control != null) siblingHandle = control.topHandle();
+ int topHandle = topHandle ();
+ int window = OS.GTK_WIDGET_WINDOW (topHandle);
+ if (window != 0) OS.gdk_window_lower (window);
}
/**
@@ -1206,14 +1233,15 @@ public boolean getEnabled () {
*/
public Font getFont () {
checkWidget();
- return Font.gtk_new(_getFontHandle());
+ int fontHandle = fontHandle ();
+ int context = OS.gtk_widget_get_pango_context (fontHandle);
+ int font = OS.pango_context_get_font_description (context);
+ return Font.gtk_new (getDisplay (), font);
}
/*
* Subclasses should override this, passing a meaningful handle
*/
-int _getFontHandle () {
- return UtilFuncs.getFont(handle);
-}
+
/**
* Returns the foreground color that the receiver will use to draw.
@@ -1375,16 +1403,15 @@ public boolean getVisible () {
*/
public int internal_new_GC (GCData data) {
if (data == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (paintHandle() == 0) error(SWT.ERROR_UNSPECIFIED);
- int window = OS.GTK_WIDGET_WINDOW(paintHandle());
- int gdkGC = OS.gdk_gc_new(window);
- if (gdkGC == 0) error(SWT.ERROR_NO_HANDLES);
+ int window = paintWindow ();
+ int gdkGC = OS.gdk_gc_new (window);
+ if (gdkGC == 0) error (SWT.ERROR_NO_HANDLES);
if (data != null) {
data.drawable = window;
data.device = getDisplay ();
data.background = _getBackgroundGdkColor ();
data.foreground = _getForegroundGdkColor ();
-// OS.gdk_gc_set_font(gc, _getFontHandle ());
+ data.font = getFont().handle;
}
return gdkGC;
}
@@ -1487,12 +1514,11 @@ Decorations menuShell () {
}
int processKeyDown (int callData, int arg1, int int2) {
- int keyval = OS.gdk_event_key_get_keyval(callData);
- int[] pMods = new int[1];
- OS.gdk_event_get_state(callData, pMods);
- boolean accelResult = OS.gtk_accel_groups_activate(_getShell().topHandle(),
- keyval,
- pMods[0]);
+ int keyval = OS.gdk_event_key_get_keyval (callData);
+ int [] state = new int [1];
+ OS.gdk_event_get_state (callData, state);
+ int shellHandle = _getShell ().topHandle ();
+ boolean accelResult = OS.gtk_accel_groups_activate (shellHandle, keyval, state [0]);
if (!accelResult) sendKeyEvent (SWT.KeyDown, callData);
return 1;
}
@@ -1503,19 +1529,12 @@ int processKeyUp (int callData, int arg1, int int2) {
}
int processMouseDown (int callData, int arg1, int int2) {
- OS.gtk_widget_grab_focus(handle);
- int eventType = SWT.MouseDown;
- if (OS.GDK_EVENT_TYPE(callData) == OS.GDK_2BUTTON_PRESS) eventType = SWT.MouseDoubleClick;
- int[] pMod = new int[1];
- OS.gdk_event_get_state(callData, pMod);
- int time = OS.gdk_event_get_time(callData);
- double[] px = new double[1];
- double[] py = new double[1];
- OS.gdk_event_get_coords(callData, px, py);
- int button = OS.gdk_event_button_get_button(callData);
- sendMouseEvent (eventType, button, pMod[0], time, (int)(px[0]), (int)(py[0]));
+ int type = OS.GDK_EVENT_TYPE (callData);
+ int eventType = type != OS.GDK_2BUTTON_PRESS ? SWT.MouseDown : SWT.MouseDoubleClick;
+ int button = OS.gdk_event_button_get_button (callData);
+ sendMouseEvent (eventType, button, callData);
if (button == 3 && menu != null) menu.setVisible (true);
- return 1;
+ return 0;
}
int processMouseEnter (int arg0, int arg1, int int2) {
@@ -1530,27 +1549,14 @@ int processMouseExit (int arg0, int arg1, int int2) {
}
int processMouseUp (int callData, int arg1, int int2) {
- int[] pMod = new int[1];
- OS.gdk_event_get_state(callData, pMod);
- int time = OS.gdk_event_get_time(callData);
- double[] px = new double[1];
- double[] py = new double[1];
- OS.gdk_event_get_coords(callData, px, py);
- int button = OS.gdk_event_button_get_button(callData);
- sendMouseEvent (SWT.MouseUp, button, pMod[0], time, (int)(px[0]), (int)(py[0]));
- return 1;
+ int button = OS.gdk_event_button_get_button (callData);
+ sendMouseEvent (SWT.MouseUp, button, callData);
+ return 0;
}
int processMouseMove (int callData, int arg1, int int2) {
- /*
- GdkEvent gdkEvent = new GdkEvent (callData);
- int[] px = new int[1], py = new int[1];
- OS.gdk_window_get_pointer(_gdkWindow(), px, py, 0);
- int time = OS.gdk_event_get_time(callData);
- int[] pMods = new int[1];
- OS.gdk_event_get_state(callData, pMods);
- sendMouseEvent (SWT.MouseMove, 0, pMods[0], time, px[0], py[0]);*/
- return 1;
+ sendMouseEvent (SWT.MouseMove, 0, callData);
+ return 0;
}
int processFocusIn(int int0, int int1, int int2) {
@@ -1564,7 +1570,6 @@ int processFocusOut(int int0, int int1, int int2) {
int processPaint (int callData, int int2, int int3) {
if (!hooks (SWT.Paint)) return 1;
-
GdkEventExpose gdkEvent = new GdkEventExpose (callData);
Event event = new Event ();
event.count = gdkEvent.count;
@@ -1575,13 +1580,18 @@ int processPaint (int callData, int int2, int int3) {
rect.x = gdkEvent.x; rect.y = gdkEvent.y;
rect.width = gdkEvent.width; rect.height = gdkEvent.height;
OS.gdk_gc_set_clip_rectangle (gc.handle, rect);
- gc.fillRectangle(rect.x, rect.y, rect.width, rect.height);
sendEvent (SWT.Paint, event);
gc.dispose ();
event.gc = null;
return 1;
}
+void register () {
+ super.register ();
+ if (fixedHandle != 0) WidgetTable.put (fixedHandle, this);
+}
+
+
/**
* Causes the entire bounds of the receiver to be marked
* as needing to be redrawn. The next time a paint request
@@ -1596,8 +1606,10 @@ int processPaint (int callData, int int2, int int3) {
*/
public void redraw () {
checkWidget();
- Point size = _getSize();
- _redraw(0, 0, size.x, size.y, true);
+ int topHandle = topHandle ();
+ int width = OS.GTK_WIDGET_WIDTH (topHandle);
+ int height = OS.GTK_WIDGET_HEIGHT (topHandle);
+ redraw (0, 0, width, height, true);
}
/**
* Causes the rectangular area of the receiver specified by
@@ -1624,22 +1636,14 @@ public void redraw () {
*/
public void redraw (int x, int y, int width, int height, boolean all) {
checkWidget();
- _redraw(x, y, width, height, all);
+ //?? TRANSLATE COORDINATES
+ int window = paintWindow ();
+ OS.gdk_window_clear_area_e (window, x, y, width, height);
}
-protected void _redraw(int x, int y, int width, int height, boolean all) {
- /* FIXME */
- /*
- OS.gdk_window_clear_area_e (_gdkWindow(), x, y, width, height);
-
-GdkRectangle rect = new GdkRectangle();
-rect.x = (short)x;
-rect.y = (short)y;
-rect.width = (short)width;
-rect.height =(short) height;
-OS.gtk_widget_queue_draw(handle);*/
-
+void releaseHandle () {
+ super.releaseHandle ();
+ fixedHandle = 0;
}
-
void releaseWidget () {
super.releaseWidget ();
toolTipText = null;
@@ -1648,63 +1652,44 @@ void releaseWidget () {
layoutData = null;
}
-void sendKeyEvent (int type, int pEventKey) {
- Event event = new Event();
- event.time = OS.gdk_event_get_time(pEventKey);
-
- int size = OS.gdk_event_key_get_length(pEventKey);
- if (size==0) { /* No composed string - send the keyvalue */
- int keyval = OS.gdk_event_key_get_keyval(pEventKey) ;
- if (keyval==0) return;
+void sendKeyEvent (int type, int gdkEvent) {
+ int time = OS.gdk_event_get_time (gdkEvent);
+ int length = OS.gdk_event_key_get_length (gdkEvent);
+ if (length == 0) {
+ Event event = new Event ();
+ event.time = time;
+ setInputState (event, gdkEvent);
+ int keyval = OS.gdk_event_key_get_keyval (gdkEvent);
event.keyCode = Display.translateKey (keyval);
- event.character = (char) event.keyCode; //no character sent
- int[] pModifier = new int[1];
- OS.gdk_event_get_state(pEventKey, pModifier);
- int state = pModifier[0];
- if ((state & OS.GDK_MOD1_MASK) != 0) event.stateMask |= SWT.ALT;
- if ((state & OS.GDK_SHIFT_MASK) != 0) event.stateMask |= SWT.SHIFT;
- if ((state & OS.GDK_CONTROL_MASK) != 0) event.stateMask |= SWT.CONTROL;
- if ((state & OS.GDK_BUTTON1_MASK) != 0) event.stateMask |= SWT.BUTTON1;
- if ((state & OS.GDK_BUTTON2_MASK) != 0) event.stateMask |= SWT.BUTTON2;
- if ((state & OS.GDK_BUTTON3_MASK) != 0) event.stateMask |= SWT.BUTTON3;
- postEvent (type, event);
- return;
- }
-
- if (size==1) {
- int keyval = OS.gdk_event_key_get_keyval(pEventKey) ;
- if (keyval==0) return;
- event.keyCode = keyval;
- event.character = (char) event.keyCode; //no character sent
- int[] pModifier = new int[1];
- OS.gdk_event_get_state(pEventKey, pModifier);
- int state = pModifier[0];
- if ((state & OS.GDK_MOD1_MASK) != 0) event.stateMask |= SWT.ALT;
- if ((state & OS.GDK_SHIFT_MASK) != 0) event.stateMask |= SWT.SHIFT;
- if ((state & OS.GDK_CONTROL_MASK) != 0) event.stateMask |= SWT.CONTROL;
- if ((state & OS.GDK_BUTTON1_MASK) != 0) event.stateMask |= SWT.BUTTON1;
- if ((state & OS.GDK_BUTTON2_MASK) != 0) event.stateMask |= SWT.BUTTON2;
- if ((state & OS.GDK_BUTTON3_MASK) != 0) event.stateMask |= SWT.BUTTON3;
postEvent (type, event);
- return;
+ } else {
+ int string = OS.gdk_event_key_get_string (gdkEvent);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, string, length);
+ char [] result = Converter.mbcsToWcs (null, buffer);
+ int index = 0;
+ while (index < result.length) {
+ if (result [index] == 0) break;
+ Event event = new Event ();
+ event.time = time;
+ event.character = result [index];
+ setInputState (event, gdkEvent);
+ postEvent (type, event);
+ index++;
+ }
}
-
- /* Multi-byte key */
- /* The implementation in the GTK1.2 stream, is not correct here. */
- error(SWT.ERROR_NOT_IMPLEMENTED);
}
-void sendMouseEvent (int type, int button, int mask, int time, int x, int y) {
+void sendMouseEvent (int type, int button, int gdkEvent) {
Event event = new Event ();
- event.time = time;
+ event.time = OS.gdk_event_get_time (gdkEvent);
event.button = button;
- event.x = x; event.y = y;
- if ((mask & OS.GDK_MOD1_MASK) != 0) event.stateMask |= SWT.ALT;
- if ((mask & OS.GDK_SHIFT_MASK) != 0) event.stateMask |= SWT.SHIFT;
- if ((mask & OS.GDK_CONTROL_MASK) != 0) event.stateMask |= SWT.CONTROL;
- if ((mask & OS.GDK_BUTTON1_MASK) != 0) event.stateMask |= SWT.BUTTON1;
- if ((mask & OS.GDK_BUTTON2_MASK) != 0) event.stateMask |= SWT.BUTTON2;
- if ((mask & OS.GDK_BUTTON3_MASK) != 0) event.stateMask |= SWT.BUTTON3;
+ double [] x_win = new double [1];
+ double [] y_win = new double [1];
+ OS.gdk_event_get_coords (gdkEvent, x_win, y_win);
+ event.x = (int) x_win [0];
+ event.y = (int) y_win [0];
+ setInputState (event, gdkEvent);
postEvent (type, event);
}
@@ -1724,64 +1709,11 @@ void sendMouseEvent (int type, int button, int mask, int time, int x, int y) {
* </ul>
*/
public void setBackground (Color color) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- int hDefaultStyle = OS.gtk_widget_get_default_style ();
- int hStyle = OS.gtk_widget_get_style (handle);
- boolean makeCopy = hStyle == hDefaultStyle;
- hStyle = OS.gtk_style_copy (makeCopy ? hDefaultStyle : hStyle);
- GtkStyle style = new GtkStyle (hStyle);
- if (color == null) {
- GtkStyle defaultStyle = new GtkStyle (hDefaultStyle);
- style.bg0_pixel = defaultStyle.bg0_pixel;
- style.bg0_red = defaultStyle.bg0_red;
- style.bg0_green = defaultStyle.bg0_green;
- style.bg0_blue = defaultStyle.bg0_blue;
- style.bg1_pixel = defaultStyle.bg1_pixel;
- style.bg1_red = defaultStyle.bg1_red;
- style.bg1_green = defaultStyle.bg1_green;
- style.bg1_blue = defaultStyle.bg1_blue;
- style.bg2_pixel = defaultStyle.bg2_pixel;
- style.bg2_red = defaultStyle.bg2_red;
- style.bg2_green = defaultStyle.bg2_green;
- style.bg2_blue = defaultStyle.bg2_blue;
- style.bg3_pixel = defaultStyle.bg3_pixel;
- style.bg3_red = defaultStyle.bg3_red;
- style.bg3_green = defaultStyle.bg3_green;
- style.bg3_blue = defaultStyle.bg3_blue;
- style.bg4_pixel = defaultStyle.bg4_pixel;
- style.bg4_red = defaultStyle.bg4_red;
- style.bg4_green = defaultStyle.bg4_green;
- style.bg4_blue = defaultStyle.bg4_blue;
- } else {
- style.bg0_pixel = color.handle.pixel;
- style.bg0_red = color.handle.red;
- style.bg0_green = color.handle.green;
- style.bg0_blue = color.handle.blue;
- style.bg1_pixel = color.handle.pixel;
- style.bg1_red = color.handle.red;
- style.bg1_green = color.handle.green;
- style.bg1_blue = color.handle.blue;
- style.bg2_pixel = color.handle.pixel;
- style.bg2_red = color.handle.red;
- style.bg2_green = color.handle.green;
- style.bg2_blue = color.handle.blue;
- style.bg3_pixel = color.handle.pixel;
- style.bg3_red = color.handle.red;
- style.bg3_green = color.handle.green;
- style.bg3_blue = color.handle.blue;
- style.bg4_pixel = color.handle.pixel;
- style.bg4_red = color.handle.red;
- style.bg4_green = color.handle.green;
- style.bg4_blue = color.handle.blue;
- }
- /* FIXME */
- /* I believe there is now something like set_color? */
- /*OS.memmove (hStyle, style, GtkStyle.sizeof);
- OS.gtk_widget_set_style (handle, hStyle);*/
- if (makeCopy) {
- OS.gtk_style_unref (hStyle);
- }
+ checkWidget ();
+ //TEMPORARY CODE - should fix setBackground()/setForeground() everywhere
+ //NULL CHECK
+ if (color == null) return;
+ OS.gtk_widget_modify_bg (handle, 0, color.handle);
}
/**
@@ -1897,26 +1829,11 @@ public boolean setFocus () {
public void setFont (Font font) {
checkWidget();
- /* The non-null font case */
- if (font != null) {
- if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- int fontHandle = OS.gdk_font_ref(font.handle);
- _setFontHandle(fontHandle);
- return;
- }
-
- /* The font argument is null, revert to default font */
- /* FIXME */
-/* GtkStyle style = new GtkStyle();
- OS.memmove (style, OS.gtk_widget_get_default_style(), GtkStyle.sizeof);
- int fontHandle = OS.gdk_font_ref(style.font);
- if (fontHandle==0) error(SWT.ERROR_NO_HANDLES);
- _setFontHandle(fontHandle);*/
-}
-void _setFontHandle (int f) {
- UtilFuncs.setFont(handle, f);
+ int fontHandle = fontHandle ();
+ OS.gtk_widget_modify_font (fontHandle, font.handle);
}
+
/**
* Sets the receiver's foreground color to the color specified
* by the argument, or to the default system color for the control
@@ -1988,6 +1905,21 @@ public void setForeground (Color color) {
OS.gtk_widget_set_style (handle, hStyle);*/
}
+void setInitialSize () {
+ resizeHandle (1, 1);
+}
+
+void setInputState (Event event, int gdkEvent) {
+ int [] state = new int [1];
+ OS.gdk_event_get_state (gdkEvent, state);
+ if ((state [0] & OS.GDK_MOD1_MASK) != 0) event.stateMask |= SWT.ALT;
+ if ((state [0] & OS.GDK_SHIFT_MASK) != 0) event.stateMask |= SWT.SHIFT;
+ if ((state [0] & OS.GDK_CONTROL_MASK) != 0) event.stateMask |= SWT.CONTROL;
+ if ((state [0] & OS.GDK_BUTTON1_MASK) != 0) event.stateMask |= SWT.BUTTON1;
+ if ((state [0] & OS.GDK_BUTTON2_MASK) != 0) event.stateMask |= SWT.BUTTON2;
+ if ((state [0] & OS.GDK_BUTTON3_MASK) != 0) event.stateMask |= SWT.BUTTON3;
+}
+
/**
* Sets the receiver's pop up menu to the argument.
* All controls may optionally have a pop up
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java
index ab475d0904..42f0fedb3b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Decorations.java
@@ -318,7 +318,15 @@ void releaseWidget () {
*/
public void setDefaultButton (Button button) {
checkWidget();
+ if (button != null) {
+ if (button.isDisposed()) return;
+ OS.GTK_WIDGET_SET_FLAGS(button.handle, OS.GTK_CAN_DEFAULT);
+ OS.gtk_window_set_default(topHandle(), button.handle);
+ return;
+ }
+ else OS.gtk_window_set_default(topHandle(), 0);
}
+
/**
* Sets the receiver's image to the argument, which may
* be null. The image is typically displayed by the window
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index 6b44200fd4..c5abf34dfb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -112,12 +112,11 @@ public class Display extends Device {
int textHighlightThickness = 1; /* for emulated widgets */
/* Colors */
- Color NORMAL_fg, NORMAL_bg, NORMAL_dark, NORMAL_mid, NORMAL_light, NORMAL_text, NORMAL_base;
- Color ACTIVE_fg, ACTIVE_bg, ACTIVE_dark, ACTIVE_mid, ACTIVE_light, ACTIVE_text, ACTIVE_base;
- Color PRELIGHT_fg, PRELIGHT_bg, PRELIGHT_dark, PRELIGHT_mid, PRELIGHT_light, PRELIGHT_text, PRELIGHT_base;
- Color SELECTED_fg, SELECTED_bg, SELECTED_dark, SELECTED_mid, SELECTED_light, SELECTED_text, SELECTED_base;
- Color INSENSITIVE_fg, INSENSITIVE_bg, INSENSITIVE_dark, INSENSITIVE_mid, INSENSITIVE_light, INSENSITIVE_text, INSENSITIVE_base;
-
+ GdkColor COLOR_WIDGET_DARK_SHADOW, COLOR_WIDGET_NORMAL_SHADOW, COLOR_WIDGET_LIGHT_SHADOW;
+ GdkColor COLOR_WIDGET_HIGHLIGHT_SHADOW, COLOR_WIDGET_BACKGROUND, COLOR_WIDGET_FOREGROUND, COLOR_WIDGET_BORDER;
+ GdkColor COLOR_LIST_FOREGROUND, COLOR_LIST_BACKGROUND, COLOR_LIST_SELECTION, COLOR_LIST_SELECTION_TEXT;
+ GdkColor COLOR_INFO_BACKGROUND;
+
/* Key Mappings */
static final int [] [] KeyTable = {
@@ -764,143 +763,129 @@ public Thread getSyncThread () {
*/
public Color getSystemColor (int id) {
checkDevice ();
+ GdkColor gdkColor = null;
switch (id) {
- case SWT.COLOR_INFO_FOREGROUND: return NORMAL_fg;
- case SWT.COLOR_INFO_BACKGROUND: return NORMAL_bg;
-
- case SWT.COLOR_TITLE_FOREGROUND: return SELECTED_text;
- case SWT.COLOR_TITLE_BACKGROUND: return SELECTED_bg;
- case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: return SELECTED_light;
- case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: return INSENSITIVE_fg;
- case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: return INSENSITIVE_bg;
- case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: return INSENSITIVE_light;
-
- case SWT.COLOR_WIDGET_DARK_SHADOW: return NORMAL_dark;
- case SWT.COLOR_WIDGET_NORMAL_SHADOW: return NORMAL_mid;
- case SWT.COLOR_WIDGET_LIGHT_SHADOW: return NORMAL_light;
- case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: return NORMAL_light;
- case SWT.COLOR_WIDGET_BACKGROUND: return NORMAL_bg;
- case SWT.COLOR_WIDGET_FOREGROUND: return NORMAL_fg;
- case SWT.COLOR_WIDGET_BORDER: return super.getSystemColor (SWT.COLOR_BLACK);
-
- case SWT.COLOR_LIST_FOREGROUND: return super.getSystemColor (SWT.COLOR_BLACK);
- case SWT.COLOR_LIST_BACKGROUND: return super.getSystemColor (SWT.COLOR_WHITE);
- case SWT.COLOR_LIST_SELECTION: return SELECTED_bg;
- case SWT.COLOR_LIST_SELECTION_TEXT: return SELECTED_text;
+ case SWT.COLOR_INFO_FOREGROUND: return super.getSystemColor (SWT.COLOR_BLACK);
+ case SWT.COLOR_INFO_BACKGROUND: gdkColor = COLOR_INFO_BACKGROUND;
+ case SWT.COLOR_TITLE_FOREGROUND: return super.getSystemColor (SWT.COLOR_WHITE);
+ case SWT.COLOR_TITLE_BACKGROUND: return super.getSystemColor (SWT.COLOR_DARK_BLUE);
+ case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: return super.getSystemColor (SWT.COLOR_BLUE);
+ case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: return super.getSystemColor (SWT.COLOR_BLACK);
+ case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: return super.getSystemColor (SWT.COLOR_DARK_GRAY);
+ case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: return super.getSystemColor (SWT.COLOR_GRAY);
+ case SWT.COLOR_WIDGET_DARK_SHADOW: gdkColor = COLOR_WIDGET_DARK_SHADOW; break;
+ case SWT.COLOR_WIDGET_NORMAL_SHADOW: gdkColor = COLOR_WIDGET_NORMAL_SHADOW; break;
+ case SWT.COLOR_WIDGET_LIGHT_SHADOW: gdkColor = COLOR_WIDGET_LIGHT_SHADOW; break;
+ case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: gdkColor = COLOR_WIDGET_HIGHLIGHT_SHADOW; break;
+ case SWT.COLOR_WIDGET_BACKGROUND: gdkColor = COLOR_WIDGET_BACKGROUND; break;
+ case SWT.COLOR_WIDGET_FOREGROUND: gdkColor = COLOR_WIDGET_FOREGROUND; break;
+ case SWT.COLOR_WIDGET_BORDER: gdkColor = COLOR_WIDGET_BORDER; break;
+ case SWT.COLOR_LIST_FOREGROUND: gdkColor = COLOR_LIST_FOREGROUND; break;
+ case SWT.COLOR_LIST_BACKGROUND: gdkColor = COLOR_LIST_BACKGROUND; break;
+ case SWT.COLOR_LIST_SELECTION: gdkColor = COLOR_LIST_SELECTION; break;
+ case SWT.COLOR_LIST_SELECTION_TEXT: gdkColor = COLOR_LIST_SELECTION_TEXT; break;
+ default:
+ return super.getSystemColor (id);
}
- return super.getSystemColor (id);
+ if (gdkColor == null) return super.getSystemColor (SWT.COLOR_BLACK);
+ return Color.gtk_new (this, gdkColor);
}
final void initializeSystemColors() {
/* Get the theme colors */
- GtkStyle defaultStyle = new GtkStyle(OS.gtk_widget_get_default_style());
-
- GdkColor gdk_NORMAL_dark = new GdkColor();
- gdk_NORMAL_dark.pixel = defaultStyle.dark0_pixel;
- gdk_NORMAL_dark.red = defaultStyle.dark0_red;
- gdk_NORMAL_dark.green = defaultStyle.dark0_green;
- gdk_NORMAL_dark.blue = defaultStyle.dark0_blue;
- NORMAL_dark = Color.gtk_new(this, gdk_NORMAL_dark);
-
- GdkColor gdk_NORMAL_mid = new GdkColor();
- gdk_NORMAL_mid.pixel = defaultStyle.mid0_pixel;
- gdk_NORMAL_mid.red = defaultStyle.mid0_red;
- gdk_NORMAL_mid.green = defaultStyle.mid0_green;
- gdk_NORMAL_mid.blue = defaultStyle.mid0_blue;
- NORMAL_mid = Color.gtk_new(this, gdk_NORMAL_mid);
-
- GdkColor gdk_NORMAL_light = new GdkColor();
- gdk_NORMAL_light.pixel = defaultStyle.light0_pixel;
- gdk_NORMAL_light.red = defaultStyle.light0_red;
- gdk_NORMAL_light.green = defaultStyle.light0_green;
- gdk_NORMAL_light.blue = defaultStyle.light0_blue;
- NORMAL_light = Color.gtk_new(this, gdk_NORMAL_light);
-
- GdkColor gdk_NORMAL_fg = new GdkColor();
- gdk_NORMAL_fg.pixel = defaultStyle.fg0_pixel;
- gdk_NORMAL_fg.red = defaultStyle.fg0_red;
- gdk_NORMAL_fg.green = defaultStyle.fg0_green;
- gdk_NORMAL_fg.blue = defaultStyle.fg0_blue;
- NORMAL_fg = Color.gtk_new(this, gdk_NORMAL_fg);
-
- GdkColor gdk_NORMAL_bg = new GdkColor();
- gdk_NORMAL_bg.pixel = defaultStyle.bg0_pixel;
- gdk_NORMAL_bg.red = defaultStyle.bg0_red;
- gdk_NORMAL_bg.green = defaultStyle.bg0_green;
- gdk_NORMAL_bg.blue = defaultStyle.bg0_blue;
- NORMAL_bg = Color.gtk_new(this, gdk_NORMAL_bg);
-
- GdkColor gdk_NORMAL_text = new GdkColor();
- gdk_NORMAL_text.pixel = defaultStyle.text0_pixel;
- gdk_NORMAL_text.red = defaultStyle.text0_red;
- gdk_NORMAL_text.green = defaultStyle.text0_green;
- gdk_NORMAL_text.blue = defaultStyle.text0_blue;
- NORMAL_text = Color.gtk_new(this, gdk_NORMAL_text);
-
- GdkColor gdk_NORMAL_base = new GdkColor();
- gdk_NORMAL_base.pixel = defaultStyle.base0_pixel;
- gdk_NORMAL_base.red = defaultStyle.base0_red;
- gdk_NORMAL_base.green = defaultStyle.base0_green;
- gdk_NORMAL_base.blue = defaultStyle.base0_blue;
- NORMAL_base = Color.gtk_new(this, gdk_NORMAL_base);
-
- GdkColor gdk_SELECTED_text = new GdkColor();
- gdk_SELECTED_text.pixel = defaultStyle.text3_pixel;
- gdk_SELECTED_text.red = defaultStyle.text3_red;
- gdk_SELECTED_text.green = defaultStyle.text3_green;
- gdk_SELECTED_text.blue = defaultStyle.text3_blue;
- SELECTED_text = Color.gtk_new(this, gdk_SELECTED_text);
-
- GdkColor gdk_SELECTED_bg = new GdkColor();
- gdk_SELECTED_bg.pixel = defaultStyle.bg3_pixel;
- gdk_SELECTED_bg.red = defaultStyle.bg3_red;
- gdk_SELECTED_bg.green = defaultStyle.bg3_green;
- gdk_SELECTED_bg.blue = defaultStyle.bg3_blue;
- SELECTED_bg = Color.gtk_new(this, gdk_SELECTED_bg);
-
- GdkColor gdk_SELECTED_base = new GdkColor();
- gdk_SELECTED_base.pixel = defaultStyle.base3_pixel;
- gdk_SELECTED_base.red = defaultStyle.base3_red;
- gdk_SELECTED_base.green = defaultStyle.base3_green;
- gdk_SELECTED_base.blue = defaultStyle.base3_blue;
- SELECTED_base = Color.gtk_new(this, gdk_SELECTED_base);
-
- GdkColor gdk_SELECTED_light = new GdkColor();
- gdk_SELECTED_light.pixel = defaultStyle.light3_pixel;
- gdk_SELECTED_light.red = defaultStyle.light3_red;
- gdk_SELECTED_light.green = defaultStyle.light3_green;
- gdk_SELECTED_light.blue = defaultStyle.light3_blue;
- SELECTED_light = Color.gtk_new(this, gdk_SELECTED_light);
-
-
- GdkColor gdk_PRELIGHT_light = new GdkColor();
- gdk_PRELIGHT_light.pixel = defaultStyle.light2_pixel;
- gdk_PRELIGHT_light.red = defaultStyle.light2_red;
- gdk_PRELIGHT_light.green = defaultStyle.light2_green;
- gdk_PRELIGHT_light.blue = defaultStyle.light2_blue;
- PRELIGHT_light = Color.gtk_new(this, gdk_PRELIGHT_light);
-
- GdkColor gdk_INSENSITIVE_light = new GdkColor();
- gdk_INSENSITIVE_light.pixel = defaultStyle.light4_pixel;
- gdk_INSENSITIVE_light.red = defaultStyle.light4_red;
- gdk_INSENSITIVE_light.green = defaultStyle.light4_green;
- gdk_INSENSITIVE_light.blue = defaultStyle.light4_blue;
- INSENSITIVE_light = Color.gtk_new(this, gdk_INSENSITIVE_light);
-
- GdkColor gdk_INSENSITIVE_fg = new GdkColor();
- gdk_INSENSITIVE_fg.pixel = defaultStyle.fg4_pixel;
- gdk_INSENSITIVE_fg.red = defaultStyle.fg4_red;
- gdk_INSENSITIVE_fg.green = defaultStyle.fg4_green;
- gdk_INSENSITIVE_fg.blue = defaultStyle.fg4_blue;
- INSENSITIVE_fg = Color.gtk_new(this, gdk_INSENSITIVE_fg);
-
- GdkColor gdk_INSENSITIVE_bg = new GdkColor();
- gdk_INSENSITIVE_bg.pixel = defaultStyle.bg4_pixel;
- gdk_INSENSITIVE_bg.red = defaultStyle.bg4_red;
- gdk_INSENSITIVE_bg.green = defaultStyle.bg4_green;
- gdk_INSENSITIVE_bg.blue = defaultStyle.bg4_blue;
- INSENSITIVE_bg = Color.gtk_new(this, gdk_INSENSITIVE_bg);
+ int colormap = OS.gdk_colormap_get_system();
+ GtkStyle style = new GtkStyle(OS.gtk_widget_get_default_style());
+
+ GdkColor gdkColor;
+
+ gdkColor = new GdkColor();
+ gdkColor.pixel = style.dark0_pixel;
+ gdkColor.red = style.dark0_red;
+ gdkColor.green = style.dark0_green;
+ gdkColor.blue = style.dark0_blue;
+ OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
+ COLOR_WIDGET_DARK_SHADOW = gdkColor;
+
+ gdkColor = new GdkColor();
+ gdkColor.pixel = style.mid0_pixel;
+ gdkColor.red = style.mid0_red;
+ gdkColor.green = style.mid0_green;
+ gdkColor.blue = style.mid0_blue;
+ OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
+ COLOR_WIDGET_NORMAL_SHADOW = gdkColor;
+
+ gdkColor = new GdkColor();
+ gdkColor.pixel = style.light0_pixel;
+ gdkColor.red = style.light0_red;
+ gdkColor.green = style.light0_green;
+ gdkColor.blue = style.light0_blue;
+ OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
+ COLOR_WIDGET_LIGHT_SHADOW = gdkColor;
+
+ gdkColor = new GdkColor();
+ gdkColor.pixel = style.light0_pixel;
+ gdkColor.red = style.light0_red;
+ gdkColor.green = style.light0_green;
+ gdkColor.blue = style.light0_blue;
+ OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
+ COLOR_WIDGET_HIGHLIGHT_SHADOW = gdkColor;
+
+ gdkColor = new GdkColor();
+ gdkColor.pixel = style.fg0_pixel;
+ gdkColor.red = style.fg0_red;
+ gdkColor.green = style.fg0_green;
+ gdkColor.blue = style.fg0_blue;
+ OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
+ COLOR_WIDGET_FOREGROUND = gdkColor;
+
+ gdkColor = new GdkColor();
+ gdkColor.pixel = style.bg0_pixel;
+ gdkColor.red = style.bg0_red;
+ gdkColor.green = style.bg0_green;
+ gdkColor.blue = style.bg0_blue;
+ OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
+ COLOR_WIDGET_BACKGROUND = gdkColor;
+
+ gdkColor = new GdkColor();
+ gdkColor.pixel = style.text0_pixel;
+ gdkColor.red = style.text0_red;
+ gdkColor.green = style.text0_green;
+ gdkColor.blue = style.text0_blue;
+ OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
+ COLOR_LIST_FOREGROUND = gdkColor;
+
+ gdkColor = new GdkColor();
+ gdkColor.pixel = style.base0_pixel;
+ gdkColor.red = style.base0_red;
+ gdkColor.green = style.base0_green;
+ gdkColor.blue = style.base0_blue;
+ OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
+ COLOR_LIST_BACKGROUND = gdkColor;
+
+ gdkColor = new GdkColor();
+ gdkColor.pixel = style.fg3_pixel;
+ gdkColor.red = style.fg3_red;
+ gdkColor.green = style.fg3_green;
+ gdkColor.blue = style.fg3_blue;
+ OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
+ COLOR_LIST_SELECTION_TEXT = gdkColor;
+
+ gdkColor = new GdkColor();
+ gdkColor.pixel = style.bg3_pixel;
+ gdkColor.red = style.bg3_red;
+ gdkColor.green = style.bg3_green;
+ gdkColor.blue = style.bg3_blue;
+ OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
+ COLOR_LIST_SELECTION = gdkColor;
+
+ gdkColor = new GdkColor();
+ gdkColor.pixel = style.base3_pixel;
+ gdkColor.red = style.base3_red;
+ gdkColor.green = style.base3_green;
+ gdkColor.blue = style.base3_blue;
+ OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
+ COLOR_INFO_BACKGROUND = gdkColor;
}
/**
@@ -1154,12 +1139,10 @@ void releaseDisplay () {
messages = null; messageLock = null; thread = null;
messagesSize = windowProc2 = windowProc3 = windowProc4 = windowProc5 = 0;
- NORMAL_fg = NORMAL_bg = NORMAL_dark = NORMAL_mid = NORMAL_light = NORMAL_text = NORMAL_base =
- ACTIVE_fg = ACTIVE_bg = ACTIVE_dark = ACTIVE_mid = ACTIVE_light = ACTIVE_text = ACTIVE_base =
- PRELIGHT_fg = PRELIGHT_bg = PRELIGHT_dark = PRELIGHT_mid = PRELIGHT_light = PRELIGHT_text = PRELIGHT_base =
- SELECTED_fg = SELECTED_bg = SELECTED_dark = SELECTED_mid = SELECTED_light = SELECTED_text = SELECTED_base =
- INSENSITIVE_fg = INSENSITIVE_bg = INSENSITIVE_dark = INSENSITIVE_mid = INSENSITIVE_light = INSENSITIVE_text =
- INSENSITIVE_base = null;
+ COLOR_WIDGET_DARK_SHADOW = COLOR_WIDGET_NORMAL_SHADOW = COLOR_WIDGET_LIGHT_SHADOW =
+ COLOR_WIDGET_HIGHLIGHT_SHADOW = COLOR_WIDGET_BACKGROUND = COLOR_WIDGET_BORDER =
+ COLOR_LIST_FOREGROUND = COLOR_LIST_BACKGROUND = COLOR_LIST_SELECTION = COLOR_LIST_SELECTION_TEXT =
+ COLOR_INFO_BACKGROUND = null;
}
RunnableLock removeFirst () {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java
index 7f9a64ee09..aa7eb83fbe 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java
@@ -98,12 +98,15 @@ public FontData getFontData() {
return fontData;
}
int okFunc (int widget, int callData) {
- int hFontName = OS.gtk_font_selection_dialog_get_font_name (callData);
- int fontSize = OS.strlen (hFontName);
- byte [] buffer = new byte [fontSize];
- OS.memmove (buffer, hFontName, fontSize);
- char [] fontName = Converter.mbcsToWcs (null, buffer);
- //fontData = FontData.gtk_new(new String (fontName));
+ int fontName = OS.gtk_font_selection_dialog_get_font_name (callData);
+ int length = OS.strlen (fontName);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, fontName, length);
+ int fontDesc = OS.pango_font_description_from_string (buffer);
+ Display display = parent != null ? parent.getDisplay () : Display.getCurrent ();
+ Font font = Font.gtk_new (display, fontDesc);
+ fontData = font.getFontData () [0];
+ OS.pango_font_description_free (fontDesc);
OS.gtk_widget_destroy (callData);
return 0;
}
@@ -129,8 +132,15 @@ public FontData open () {
OS.gtk_window_set_transient_for(handle, parent.topHandle());
}
if (fontData != null) {
- byte[] buffer = Converter.wcsToMbcs(null, fontData.gtk_getXlfd(), true);
- OS.gtk_font_selection_dialog_set_font_name(handle, buffer);
+ Display display = parent != null ? parent.getDisplay () : Display.getCurrent ();
+ Font font = new Font (display, fontData);
+ int fontName = OS.pango_font_description_to_string (font.handle);
+ int length = OS.strlen (fontName);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, fontName, length);
+ font.dispose();
+ OS.g_free (fontName);
+ OS.gtk_font_selection_dialog_set_font_name (handle, buffer);
}
Callback destroyCallback = new Callback (this, "destroyFunc", 2);
int destroyFunc = destroyCallback.getAddress ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
index 48550f2e11..8051ce9316 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
@@ -29,8 +29,8 @@ import org.eclipse.swt.graphics.*;
* </p>
*/
public class Group extends Composite {
- int frameHandle;
- String text=""; int bogus;
+ int clientHandle;
+ String text = "";
/**
* Constructs a new instance of this class given its parent
@@ -63,6 +63,7 @@ public class Group extends Composite {
public Group (Composite parent, int style) {
super (parent, checkStyle (style));
}
+
static int checkStyle (int style) {
/*
* Even though it is legal to create this widget
@@ -76,47 +77,43 @@ static int checkStyle (int style) {
void createHandle(int index) {
state |= HANDLE;
-
- frameHandle = OS.gtk_frame_new(null);
- if (frameHandle == 0) error (SWT.ERROR_NO_HANDLES);
-
- boxHandle = OS.gtk_event_box_new();
- if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES);
-
- handle = OS.eclipse_fixed_new();
+ fixedHandle = OS.gtk_fixed_new ();
+ if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_fixed_set_has_window (fixedHandle, true);
+ handle = OS.gtk_frame_new(null);
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
-}
-
-void _setHandleStyle() {
- int shadow = OS.GTK_SHADOW_IN;
- if ((style & SWT.SHADOW_IN) != 0) shadow = OS.GTK_SHADOW_IN;
- if ((style & SWT.SHADOW_OUT) != 0) shadow = OS.GTK_SHADOW_OUT;
- if ((style & SWT.SHADOW_ETCHED_IN) != 0) shadow = OS.GTK_SHADOW_ETCHED_IN;
- if ((style & SWT.SHADOW_ETCHED_OUT) != 0) shadow = OS.GTK_SHADOW_ETCHED_OUT;
- OS.gtk_frame_set_shadow_type(frameHandle, shadow);
-}
-
-void configure() {
- parent._connectChild(frameHandle);
- OS.gtk_container_add(frameHandle, boxHandle);
- OS.gtk_container_add(boxHandle, handle);
-}
-
-void showHandle() {
- OS.gtk_widget_show (frameHandle);
- OS.gtk_widget_show (boxHandle);
+ clientHandle = OS.gtk_fixed_new();
+ if (clientHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ int parentHandle = parent.parentingHandle ();
+ OS.gtk_container_add (parentHandle, fixedHandle);
+ OS.gtk_container_add (fixedHandle, handle);
+ OS.gtk_container_add (handle, clientHandle);
OS.gtk_widget_show (handle);
- OS.gtk_widget_realize (handle);
+ OS.gtk_widget_show (clientHandle);
+ OS.gtk_widget_show (fixedHandle);
+
+ if ((style & SWT.SHADOW_IN) != 0) {
+ OS.gtk_frame_set_shadow_type (handle, OS.GTK_SHADOW_IN);
+ }
+ if ((style & SWT.SHADOW_OUT) != 0) {
+ OS.gtk_frame_set_shadow_type (handle, OS.GTK_SHADOW_OUT);
+ }
+ if ((style & SWT.SHADOW_ETCHED_IN) != 0) {
+ OS.gtk_frame_set_shadow_type (handle, OS.GTK_SHADOW_ETCHED_IN);
+ }
+ if ((style & SWT.SHADOW_ETCHED_OUT) != 0) {
+ OS.gtk_frame_set_shadow_type (handle, OS.GTK_SHADOW_ETCHED_OUT);
+ }
}
void register () {
super.register ();
- WidgetTable.put (frameHandle, this);
+ WidgetTable.put (clientHandle, this);
}
void releaseHandle () {
super.releaseHandle ();
- frameHandle = 0;
+ clientHandle = 0;
}
void releaseWidget () {
@@ -126,17 +123,16 @@ void releaseWidget () {
void deregister () {
super.deregister ();
- WidgetTable.remove (frameHandle);
+ WidgetTable.remove (clientHandle);
}
-int topHandle () { return frameHandle; }
-int parentingHandle() { return handle; }
-
-
-/*
- * === GEOMETRY ===
- */
+int parentingHandle() {
+ return clientHandle;
+}
+int clientHandle () {
+ return clientHandle;
+}
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
@@ -177,26 +173,22 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget();
int[] trims = new int[4];
- OS.swt_frame_get_trim(frameHandle, trims);
+ //FIXME - custom C code and wrong X,Y
+ OS.swt_frame_get_trim(handle, trims);
return new Rectangle (x-trims[1], y-trims[0], width+trims[1]+trims[2], height+trims[0]+trims[3]);
}
public Rectangle getClientArea () {
checkWidget();
- /* The Group coordinates originate at the client area */
- int width, height;
- Point size = _getSize();
- int[] trims = new int[4];
- OS.swt_frame_get_trim(frameHandle, trims);
- return new Rectangle(0,0, size.x - trims[1] - trims[2], size.y - trims[0] - trims[3]);
+ int width = OS.GTK_WIDGET_WIDTH (clientHandle);
+ int height = OS.GTK_WIDGET_HEIGHT (clientHandle);
+ return new Rectangle (0, 0, width, height);
}
-
-/* ========= Model Logic ========= */
-
String getNameText () {
return getText ();
}
+
/**
* Returns the receiver's text, which is the string that the
* is used as the <em>title</em>. If the text has not previously
@@ -214,6 +206,22 @@ public String getText () {
return text;
}
+void resizeHandle (int width, int height) {
+ int topHandle = topHandle ();
+ int flags = OS.GTK_WIDGET_FLAGS (topHandle);
+ OS.GTK_WIDGET_SET_FLAGS(topHandle, OS.GTK_VISIBLE);
+ int parentHandle = parent.parentingHandle ();
+ OS.gtk_widget_set_size_request (fixedHandle, width, height);
+ OS.gtk_widget_set_size_request (handle, width, height);
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.gtk_container_resize_children (parentHandle);
+ display.setWarnings (warnings);
+ if ((flags & OS.GTK_VISIBLE) == 0) {
+ OS.GTK_WIDGET_UNSET_FLAGS(topHandle, OS.GTK_VISIBLE);
+ }
+}
/**
* Sets the receiver's text, which is the string that will
@@ -240,8 +248,13 @@ public void setText (String string) {
for (int i=0; i<length; i++) {
if (text [i] == '&') text [i] = '_';
}
- int label = OS.gtk_frame_get_label_widget (frameHandle);
+ //FIXME - create label widget when frame handle is created
byte [] buffer = Converter.wcsToMbcs (null, text);
+ int label = OS.gtk_frame_get_label_widget (handle);
+ if (label == 0) {
+ OS.gtk_frame_set_label (handle, buffer);
+ label = OS.gtk_frame_get_label_widget (handle);
+ }
OS.gtk_label_set_text_with_mnemonic (label, buffer);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
index f8a467f80c..d5d5cf2094 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
@@ -72,22 +72,31 @@ static int checkStyle (int style) {
void createHandle (int index) {
state |= HANDLE;
-
+ fixedHandle = OS.gtk_fixed_new ();
+ if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_fixed_set_has_window (fixedHandle, true);
frameHandle = OS.gtk_frame_new(null);
if (frameHandle == 0) error (SWT.ERROR_NO_HANDLES);
-
- handle = ((style&SWT.SEPARATOR) != 0)? (((style&SWT.HORIZONTAL)!= 0)?
- OS.gtk_hseparator_new() : OS.gtk_vseparator_new()):
- OS.gtk_label_new (null);
+ if ((style & SWT.SEPARATOR) != 0) {
+ if ((style & SWT.HORIZONTAL)!= 0) {
+ handle = OS.gtk_hseparator_new();
+ } else {
+ handle = OS.gtk_vseparator_new();
+ }
+ } else {
+ handle = OS.gtk_label_new (null);
+ }
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
-}
-
-void createWidget (int index) {
- super.createWidget (index);
- text = "";
-}
+
+ int parentHandle = parent.parentingHandle ();
+ OS.gtk_container_add(parentHandle, fixedHandle);
+ OS.gtk_container_add(fixedHandle, frameHandle);
+ OS.gtk_container_add(frameHandle, handle);
+ OS.gtk_widget_show (fixedHandle);
+ OS.gtk_widget_show (frameHandle);
+ OS.gtk_widget_show (handle);
-void setHandleStyle () {
+ // CHECK THEME
int type = (style & SWT.BORDER) != 0 ? OS.GTK_SHADOW_ETCHED_IN : OS.GTK_SHADOW_NONE;
OS.gtk_frame_set_shadow_type (frameHandle, type);
if ((style & SWT.SEPARATOR) != 0) return;
@@ -109,15 +118,9 @@ void setHandleStyle () {
}
}
-void configure() {
- parent._connectChild(topHandle());
- OS.gtk_container_add(frameHandle, handle);
-}
-
-void showHandle() {
- OS.gtk_widget_show (frameHandle);
- OS.gtk_widget_show (handle);
- OS.gtk_widget_realize (handle);
+void createWidget (int index) {
+ super.createWidget (index);
+ text = "";
}
void register () {
@@ -141,8 +144,6 @@ void releaseHandle () {
frameHandle = 0;
}
-int topHandle () { return frameHandle; }
-
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
if ((style&SWT.SEPARATOR) != 0) {
@@ -352,4 +353,22 @@ public void setText (String string) {
OS.gtk_label_set_text_with_mnemonic (handle, buffer);
}
+void resizeHandle (int width, int height) {
+ int topHandle = topHandle ();
+ int flags = OS.GTK_WIDGET_FLAGS (topHandle);
+ OS.GTK_WIDGET_SET_FLAGS(topHandle, OS.GTK_VISIBLE);
+ OS.gtk_widget_set_size_request (fixedHandle, width, height);
+ OS.gtk_widget_set_size_request (frameHandle, width, height);
+ //FIXME - causes scrollbar problems when button child of table
+ int parentHandle = parent.parentingHandle ();
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.gtk_container_resize_children (parentHandle);
+ display.setWarnings (warnings);
+ if ((flags & OS.GTK_VISIBLE) == 0) {
+ OS.GTK_WIDGET_UNSET_FLAGS(topHandle, OS.GTK_VISIBLE);
+ }
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
index 054e369425..a62deabc96 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
@@ -170,33 +170,31 @@ static int checkStyle (int style) {
void createHandle (int index) {
state |= HANDLE;
+ fixedHandle = OS.gtk_fixed_new ();
+ if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_fixed_set_has_window (fixedHandle, true);
scrolledHandle = OS.gtk_scrolled_window_new (0, 0);
if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
handle = OS.gtk_clist_new (1);
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
-}
-
-void setHandleStyle() {
- int selectionMode = ((style & SWT.MULTI) != 0)?
- OS.GTK_SELECTION_EXTENDED :
- OS.GTK_SELECTION_BROWSE;
- OS.gtk_clist_set_selection_mode (handle, selectionMode);
+ int parentHandle = parent.parentingHandle ();
+ OS.gtk_container_add (parentHandle, fixedHandle);
+ OS.gtk_container_add (fixedHandle, scrolledHandle);
+ OS.gtk_container_add (scrolledHandle, handle);
+ OS.gtk_widget_show (fixedHandle);
+ OS.gtk_widget_show (scrolledHandle);
+ OS.gtk_widget_show (handle);
- int border = OS.GTK_SHADOW_NONE;
- if ((style&SWT.BORDER)!=0) {
- border = OS.GTK_SHADOW_ETCHED_IN;
- if ((style&SWT.SHADOW_IN)!=0) border = OS.GTK_SHADOW_IN;
- if ((style&SWT.SHADOW_OUT)!=0) border = OS.GTK_SHADOW_OUT;
- if ((style&SWT.SHADOW_ETCHED_IN)!=0) border = OS.GTK_SHADOW_ETCHED_IN;
- if ((style&SWT.SHADOW_ETCHED_OUT)!=0) border = OS.GTK_SHADOW_ETCHED_OUT;
+ int mode = (style & SWT.MULTI) != 0 ? OS.GTK_SELECTION_EXTENDED :OS.GTK_SELECTION_BROWSE;
+ OS.gtk_clist_set_selection_mode (handle, mode);
+
+ //CHECK POLICY
+ if ((style & SWT.BORDER) != 0) {
+ OS.gtk_clist_set_shadow_type(handle, OS.GTK_SHADOW_ETCHED_IN);
}
- OS.gtk_clist_set_shadow_type(handle, border);
- setScrollingPolicy();
-}
-
-void configure() {
- parent._connectChild(topHandle());
- OS.gtk_container_add (scrolledHandle, handle);
+ int hsp = (style & SWT.H_SCROLL) == 0 ? OS.GTK_POLICY_NEVER : OS.GTK_POLICY_AUTOMATIC;
+ int vsp = (style & SWT.V_SCROLL) == 0 ? OS.GTK_POLICY_NEVER : OS.GTK_POLICY_AUTOMATIC;
+ OS.gtk_scrolled_window_set_policy (scrolledHandle, hsp, vsp);
}
void hookEvents () {
@@ -206,12 +204,6 @@ void hookEvents () {
signal_connect (handle, "unselect_row", SWT.Selection, 5);
}
-void showHandle() {
- OS.gtk_widget_show (scrolledHandle);
- OS.gtk_widget_show (handle);
- OS.gtk_widget_realize (handle);
-}
-
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
if (wHint == SWT.DEFAULT) wHint = 200;
@@ -626,6 +618,12 @@ public boolean isSelected (int index) {
return false;
}
+int paintWindow () {
+ OS.gtk_widget_realize (handle);
+ GtkCList clist = new GtkCList (handle);
+ return clist.clist_window;
+}
+
int processMouseDown (int callData, int arg1, int int2) {
if ((style & SWT.MULTI) != 0) selected = true;
return super.processMouseDown (callData, arg1, int2);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
index 34e9f1e38e..029f509bd0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java
@@ -26,14 +26,18 @@ import org.eclipse.swt.events.*;
*/
public class Menu extends Widget {
+ int x, y;
+ boolean hasLocation;
MenuItem cascade;
Decorations parent;
+
/**
* Creates a new instance of the widget.
*/
public Menu (Control parent) {
this (parent.getShell (), SWT.POP_UP);
}
+
/**
* Creates a new instance of the widget.
*/
@@ -42,81 +46,84 @@ public Menu (Decorations parent, int style) {
this.parent = parent;
createWidget (0);
}
+
/**
* Creates a new instance of the widget.
*/
public Menu (Menu parentMenu) {
this (parentMenu.parent, SWT.DROP_DOWN);
}
+
/**
* Creates a new instance of the widget.
*/
public Menu (MenuItem parentItem) {
this (parentItem.parent);
}
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the help events are generated for the control, by sending
- * it one of the messages defined in the <code>MenuListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see MenuListener
- * @see #removeMenuListener
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.POP_UP, SWT.BAR, SWT.DROP_DOWN, 0, 0, 0);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the help events are generated for the control, by sending
+ * it one of the messages defined in the <code>MenuListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MenuListener
+ * @see #removeMenuListener
*/
public void addMenuListener (MenuListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Hide,typedListener);
addListener (SWT.Show,typedListener);
}
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the help events are generated for the control, by sending
- * it one of the messages defined in the <code>HelpListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see HelpListener
- * @see #removeHelpListener
- */
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the help events are generated for the control, by sending
+ * it one of the messages defined in the <code>HelpListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see HelpListener
+ * @see #removeHelpListener
+ */
public void addHelpListener (HelpListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Help, typedListener);
}
-static int checkStyle (int style) {
- return checkBits (style, SWT.POP_UP, SWT.BAR, SWT.DROP_DOWN, 0, 0, 0);
-}
void createHandle (int index) {
state |= HANDLE;
if ((style & SWT.BAR) != 0) {
handle = OS.gtk_menu_bar_new ();
- OS.gtk_widget_show (handle);
+ int parentHandle = parent.fixedHandle;
+ OS.gtk_container_add (parentHandle, handle);
} else {
handle = OS.gtk_menu_new ();
}
@@ -141,15 +148,16 @@ void createWidget (int index) {
* </ul>
*/
public MenuItem getDefaultItem () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return null;
}
+
public Display getDisplay () {
Decorations parent = this.parent;
if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
return parent.getDisplay ();
}
+
/**
* Returns <code>true</code> if the receiver is enabled, and
* <code>false</code> otherwise. A disabled control is typically
@@ -165,11 +173,9 @@ public Display getDisplay () {
*/
public boolean getEnabled () {
checkWidget();
- /* FIXME - this just checks for the SENSITIVE flag in the widget.
- * SN: Should we look at the effective sensitivity instead?
- */
- return OS.GTK_WIDGET_SENSITIVE(handle);
+ return OS.GTK_WIDGET_SENSITIVE (handle);
}
+
/**
* Returns the item at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
@@ -186,13 +192,14 @@ public boolean getEnabled () {
* </ul>
*/
public MenuItem getItem (int index) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int list = OS.gtk_container_children (handle);
+ if (list == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
int data = OS.g_list_nth_data (list, index);
if (data == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
return (MenuItem) WidgetTable.get (data);
}
+
/**
* Returns the number of items contained in the receiver.
*
@@ -204,11 +211,11 @@ public MenuItem getItem (int index) {
* </ul>
*/
public int getItemCount () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int list = OS.gtk_container_children (handle);
- return OS.g_list_length (list);
+ return list != 0 ? OS.g_list_length (list) : 0;
}
+
/**
* Returns an array of <code>MenuItem</code>s which are the items
* in the receiver.
@@ -226,10 +233,9 @@ public int getItemCount () {
* </ul>
*/
public MenuItem [] getItems () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
int list = OS.gtk_container_children (handle);
- int count = OS.g_list_length (list);
+ int count = list != 0 ? OS.g_list_length (list) : 0;
MenuItem [] items = new MenuItem [count];
for (int i=0; i<count; i++) {
int data = OS.g_list_nth_data (list, i);
@@ -237,6 +243,7 @@ public MenuItem [] getItems () {
}
return items;
}
+
/**
* Returns the receiver's parent, which must be a <code>Decorations</code>.
*
@@ -248,10 +255,10 @@ public MenuItem [] getItems () {
* </ul>
*/
public Decorations getParent () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return parent;
}
+
/**
* Returns the receiver's parent item, which must be a
* <code>MenuItem</code> or null when the receiver is a
@@ -265,10 +272,10 @@ public Decorations getParent () {
* </ul>
*/
public MenuItem getParentItem () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return cascade;
}
+
/**
* Returns the receiver's parent item, which must be a
* <code>Menu</code> or null when the receiver is a
@@ -282,11 +289,11 @@ public MenuItem getParentItem () {
* </ul>
*/
public Menu getParentMenu () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (cascade == null) return null;
return cascade.getParent ();
}
+
/**
* Returns the receiver's shell. For all controls other than
* shells, this simply returns the control's nearest ancestor
@@ -303,10 +310,10 @@ public Menu getParentMenu () {
* @see #getParent
*/
public Shell getShell () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return parent.getShell ();
}
+
/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.
@@ -326,8 +333,15 @@ public Shell getShell () {
*/
public boolean getVisible () {
checkWidget();
- return OS.GTK_WIDGET_MAPPED(handle);
+ return OS.GTK_WIDGET_MAPPED (handle);
}
+
+int GtkMenuPositionFunc (int menu, int x, int y, int push_in, int user_data) {
+ if (x != 0) OS.memmove (x, new int [] {this.x}, 4);
+ if (y != 0) OS.memmove (y, new int [] {this.y}, 4);
+ return 0;
+}
+
/**
* Searches the receiver's list starting at the first item
* (index 0) until an item is found that is equal to the
@@ -346,8 +360,7 @@ public boolean getVisible () {
* </ul>
*/
public int indexOf (MenuItem item) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
MenuItem [] items = getItems ();
for (int i=0; i<items.length; i++) {
@@ -355,6 +368,7 @@ public int indexOf (MenuItem item) {
}
return -1;
}
+
/**
* Returns <code>true</code> if the receiver is enabled, and
* <code>false</code> otherwise. A disabled control is typically
@@ -369,10 +383,10 @@ public int indexOf (MenuItem item) {
* </ul>
*/
public boolean isEnabled () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return getEnabled () && getParent ().getEnabled ();
}
+
/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.
@@ -391,10 +405,10 @@ public boolean isEnabled () {
* </ul>
*/
public boolean isVisible () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
return getVisible ();
}
+
void releaseChild () {
super.releaseChild ();
if (cascade != null) cascade.setMenu (null);
@@ -402,6 +416,7 @@ void releaseChild () {
parent.setMenuBar (null);
}
}
+
void releaseWidget () {
MenuItem [] items = getItems ();
for (int i=0; i<items.length; i++) {
@@ -416,6 +431,7 @@ void releaseWidget () {
parent = null;
cascade = null;
}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the menu events are generated for the control.
@@ -434,8 +450,7 @@ void releaseWidget () {
* @see #addMenuListener
*/
public void removeMenuListener (MenuListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.Hide, listener);
@@ -460,8 +475,7 @@ public void removeMenuListener (MenuListener listener) {
* @see #addHelpListener
*/
public void removeHelpListener (HelpListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.Help, listener);
@@ -482,9 +496,9 @@ public void removeHelpListener (HelpListener listener) {
* </ul>
*/
public void setDefaultItem (MenuItem item) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
}
+
/**
* Enables the receiver if the argument is <code>true</code>,
* and disables it otherwise. A disabled control is typically
@@ -499,8 +513,7 @@ public void setDefaultItem (MenuItem item) {
* </ul>
*/
public void setEnabled (boolean enabled) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
OS.gtk_widget_set_sensitive (handle, enabled);
}
@@ -521,12 +534,11 @@ public void setEnabled (boolean enabled) {
* </ul>
*/
public void setLocation (int x, int y) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
-// OS.gtk_widget_set_uposition(handle, x, y);
-// OS.gtk_widget_set_uposition(handle, 0, 0);
- sendEvent(SWT.Move);
+ this.x = x;
+ this.y = y;
+ hasLocation = true;
}
/**
@@ -546,12 +558,18 @@ public void setLocation (int x, int y) {
* </ul>
*/
public void setVisible (boolean visible) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- if ((style & SWT.BAR) != 0) return;
+ checkWidget();
+ if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
if (visible) {
+ int address = 0;
+ Callback GtkMenuPositionFunc = null;
+ if (hasLocation) {
+ GtkMenuPositionFunc = new Callback (this, "GtkMenuPositionFunc", 5);
+ address = GtkMenuPositionFunc.getAddress ();
+ }
sendEvent(SWT.Show);
- OS.gtk_menu_popup (handle, 0, 0, 0, 0, 3, 0);
+ OS.gtk_menu_popup (handle, 0, 0, address, 0, 0, 0);
+ if (GtkMenuPositionFunc != null) GtkMenuPositionFunc.dispose ();
} else {
OS.gtk_menu_popdown (handle);
sendEvent(SWT.Hide);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java
index b5b36ce79a..481e7dfdda 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java
@@ -70,20 +70,15 @@ void createHandle (int index) {
handle = OS.gtk_progress_bar_new ();
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
OS.gtk_progress_configure (handle, value, min, max);
-}
-
-void setHandleStyle() {
+ int parentHandle = parent.parentingHandle ();
+ OS.gtk_container_add (parentHandle, handle);
+ OS.gtk_widget_show (handle);
int orientation = (style & SWT.VERTICAL) != 0 ? OS.GTK_PROGRESS_TOP_TO_BOTTOM : OS.GTK_PROGRESS_LEFT_TO_RIGHT;
OS.gtk_progress_bar_set_orientation (handle, orientation);
int style = (this.style & SWT.SMOOTH) == 0 ? OS.GTK_PROGRESS_DISCRETE : OS.GTK_PROGRESS_CONTINUOUS;
OS.gtk_progress_bar_set_bar_style (handle, style);
}
-void showHandle() {
- OS.gtk_widget_show (handle);
- OS.gtk_widget_realize (handle);
-}
-
/**
* Returns the maximum value which the receiver will allow.
*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
index 3911e13761..4eb5c23fae 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
@@ -27,10 +27,9 @@ import org.eclipse.swt.events.*;
* </p>
*/
public class Sash extends Control {
- boolean dragging, drawing;
- int startX, startY, lastX, lastY, drawX, drawY;
- int start_root_x, start_root_y;
- int last_root_x, last_root_y;
+ boolean dragging;
+ int originX, originY;
+ int lastX, lastY; /* relative to the receiver, not the parent */
int cursor;
/**
@@ -67,23 +66,16 @@ public Sash (Composite parent, int style) {
void createHandle (int index) {
state |= HANDLE;
- handle=OS.gtk_drawing_area_new();
+ handle = OS.gtk_drawing_area_new();
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
-}
-
-void setHandleStyle() {}
-
-void showHandle() {
- createCursor();
- OS.gtk_widget_show(handle);
- OS.gtk_widget_realize(handle);
-}
-
-private void createCursor() {
- int cursorType = ((style&SWT.VERTICAL)!=0)?
- OS.GDK_SB_H_DOUBLE_ARROW:OS.GDK_SB_V_DOUBLE_ARROW;
- cursor = OS.gdk_cursor_new(cursorType);
- OS.gdk_window_set_cursor(OS.GTK_WIDGET_WINDOW(handle), cursor);
+ int parentHandle = parent.parentingHandle ();
+ OS.gtk_container_add (parentHandle, handle);
+ OS.gtk_widget_show (handle);
+ int type = (style & SWT.VERTICAL) != 0 ? OS.GDK_SB_H_DOUBLE_ARROW:OS.GDK_SB_V_DOUBLE_ARROW;
+ cursor = OS.gdk_cursor_new (type);
+ OS.gtk_widget_realize (handle);
+ int window = OS.GTK_WIDGET_WINDOW (handle);
+ OS.gdk_window_set_cursor (window, cursor);
}
public Point computeSize (int wHint, int hHint, boolean changed) {
@@ -100,8 +92,6 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
return new Point (width, height);
}
-
-
/**
* Adds the listener to the collection of listeners who will
* be notified when the control is selected, by sending
@@ -128,8 +118,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
* @see SelectionEvent
*/
public void addSelectionListener (SelectionListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Selection,typedListener);
@@ -154,8 +143,7 @@ public void addSelectionListener (SelectionListener listener) {
* @see #addSelectionListener
*/
public void removeSelectionListener(SelectionListener listener) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (SWT.Selection, listener);
@@ -163,111 +151,96 @@ public void removeSelectionListener(SelectionListener listener) {
}
int processMouseDown (int callData, int arg1, int int2) {
-/* OS.gtk_grab_add(handle);
- dragging = true;
- int button = OS.gdk_event_button_get_button(callData);
- if (button != 1) return 0;
- double[] px = new double[1];
- double[] py = new double[1];
- OS.gdk_event_get_coords(callData, px, py);
- startX = (int)(px[0]); startY = (int)(py[0]);
- OS.gdk_event_get_root_coords(callData, px, py);
- start_root_x=(int)(px[0]); start_root_y=(int)(py[0]);
- drawX=startX; drawY=startY;
- GtkWidget gtkwidget = new GtkWidget();
- OS.memmove(gtkwidget, handle, GtkWidget.sizeof);
- int border = 0, width = gtkwidget.alloc_width+border*2, height = gtkwidget.alloc_height+border*2;
- lastX = gtkwidget.alloc_x - border; lastY = gtkwidget.alloc_y - border;
+ super.processMouseDown (callData,arg1,int2);
+ if (OS.gdk_event_button_get_button(callData) != 1) return 0;
+
+ originX = OS.GTK_WIDGET_X(handle);
+ originY = OS.GTK_WIDGET_Y(handle);
+ lastX = 0;
+ lastY = 0;
+
+ /* The event must be sent because its doit flag is used. */
Event event = new Event ();
event.detail = SWT.DRAG;
event.time = OS.gdk_event_get_time(callData);
- event.x = lastX; event.y = lastY;
- event.width = width; event.height = height;
- sendEvent (SWT.MouseDown, event);*/
+ event.x = originX;
+ event.y = originY;
+ event.width = OS.GTK_WIDGET_WIDTH (handle);
+ event.height = OS.GTK_WIDGET_HEIGHT (handle);
+ /*
+ * It is possible (but unlikely) that client code could have disposed
+ * the widget in the selection event. If this happens end the processing
+ * of this message by returning.
+ */
+ sendEvent (SWT.Selection, event);
+ if (isDisposed ()) return 0;
+ if (event.doit) {
+ dragging = true;
+ drawBand (originX, originY, event.width, event.height);
+ }
return 0;
}
int processMouseMove (int callData, int arg1, int int2) {
+ super.processMouseMove (callData, arg1, int2);
if (!dragging) return 0;
-/* GtkWidget gtkwidget = new GtkWidget();
- OS.memmove(gtkwidget, handle, GtkWidget.sizeof);
- int border = 0, width = gtkwidget.alloc_width+border*2, height = gtkwidget.alloc_height+border*2;
- int x = gtkwidget.alloc_x - border, y = gtkwidget.alloc_y - border;
- Rectangle rect = parent.getClientArea();
- int parentWidth = rect.width - 2;
- int parentHeight = rect.height - 2;
- double px[] = new double[1];
- double py[] = new double[1];
- OS.gdk_event_get_root_coords(callData, px, py);
- last_root_x=(int)(px[0]); last_root_y=(int)(py[0]);
- int newX = lastX, newY = lastY;
+ /* Get the coordinates where the event happened, relative to the receiver */
+ double[] px = new double[1];
+ double[] py = new double[1];
+ OS.gdk_event_get_coords(callData, px, py);
+ int x = (int)(px[0]);
+ int y = (int)(py[0]);
+
+ int width = OS.GTK_WIDGET_WIDTH(handle);
+ int height = OS.GTK_WIDGET_HEIGHT(handle);
+
if ((style & SWT.VERTICAL) != 0) {
- if (last_root_x<=start_root_x)
- newX = Math.min (Math.max (0, x - (start_root_x-last_root_x) - startX ), parentWidth - width);
- else
- newX = Math.min (Math.max (0, x + (last_root_x-start_root_x) - startX ), parentWidth - width);
+ /* Erase the old one */
+ int oldDrawX = originX + lastX;
+ drawBand(oldDrawX, originY, width, height);
+ /* Draw the new */
+ int drawX = originX + x;
+ drawBand(drawX, originY, width, height);
+ lastX = x;
} else {
- if (last_root_y<=start_root_y)
- newY = Math.min (Math.max (0, y - (start_root_y-last_root_y) - startY ), parentHeight - height);
- else
- newY = Math.min (Math.max (0, y + (last_root_y-start_root_y) - startY ), parentHeight - height);
+ /* Erase the old one */
+ int oldDrawY = originY + lastY;
+ drawBand(originX, oldDrawY, width, height);
+ /* Draw the new */
+ int drawY = originY + y;
+ drawBand(originX, drawY, width, height);
+ lastY = y;
}
- if ((newX == lastX) && (newY == lastY)) return 0;
- drawBand(newX, newY, width, height);*/
return 0;
}
int processMouseUp (int callData, int arg1, int int2) {
-/* int button = OS.gdk_event_button_get_button(callData);
+ super.processMouseUp(callData, arg1,int2);
+ int button = OS.gdk_event_button_get_button(callData);
if (button != 1) return 0;
if (!dragging) return 0;
- GtkWidget gtkwidget = new GtkWidget();
- OS.memmove(gtkwidget, handle, GtkWidget.sizeof);
- int border = 0, width = gtkwidget.alloc_width+border*2, height = gtkwidget.alloc_height+border*2;
- int x = gtkwidget.alloc_x - border, y = gtkwidget.alloc_y - border;
- Rectangle rect = parent.getClientArea();
- int parentWidth = rect.width - 2;
- int parentHeight = rect.height - 2;
- double[] px = new double[1];
- double[] py = new double[1];
- OS.gdk_event_get_coords(callData, px, py);
- last_root_x=(int)(px[0]); last_root_y=(int)(py[0]);
- int newX = lastX, newY = lastY;
- if ((style & SWT.VERTICAL) != 0) {
- if (last_root_x<=start_root_x)
- newX = Math.min (Math.max (0, x - (start_root_x-last_root_x) - startX ), parentWidth - width);
- else
- newX = Math.min (Math.max (0, x + (last_root_x-start_root_x) - startX ), parentWidth - width);
- } else {
- if (last_root_y<=start_root_y)
- newY = Math.min (Math.max (0, y - (start_root_y-last_root_y) - startY ), parentHeight - height);
- else
- newY = Math.min (Math.max (0, y + (last_root_y-start_root_y) - startY ), parentHeight - height);
- }
- if ((newX == lastX) && (newY == lastY)) return 0;
+ int width = OS.GTK_WIDGET_WIDTH(handle);
+ int height = OS.GTK_WIDGET_HEIGHT(handle);
+ int x = lastX + originX;
+ int y = lastY + originY;
+ drawBand(x, y, width, height);
+ dragging = false;
Event event = new Event ();
event.time = OS.gdk_event_get_time(callData);
- event.x = newX; event.y = newY;
+ event.x = x; event.y = y;
event.width = width; event.height = height;
- dragging = false;
- drawBand(newX, newY, width, height);
- drawing = false;
- OS.gtk_grab_remove(handle);
- sendEvent (SWT.Selection, event);*/
+ sendEvent (SWT.Selection, event);
return 0;
}
-/*
+
int processMouseEnter (int callData, int arg1, int int2) {
- GdkEventMotion gdkEvent = new GdkEventMotion ();
- OS.memmove (gdkEvent, callData, GdkEventMotion.sizeof);
- GtkWidget gtkwidget = new GtkWidget();
- OS.memmove(gtkwidget, handle, GtkWidget.sizeof);
- int border = 0, width = gtkwidget.alloc_width+border*2, height = gtkwidget.alloc_height+border*2;
- lastX = gtkwidget.alloc_x - border; lastY = gtkwidget.alloc_y - border;
+ int width = OS.GTK_WIDGET_WIDTH (handle);
+ int height = OS.GTK_WIDGET_HEIGHT (handle);
+ lastX = OS.GTK_WIDGET_X(handle); lastY = OS.GTK_WIDGET_Y(handle);
Event event = new Event ();
- event.time = gdkEvent.time;
+ event.time = OS.gdk_event_get_time(callData);
event.detail = SWT.DRAG;
event.x = lastX; event.y = lastY;
event.width = width; event.height = height;
@@ -281,43 +254,33 @@ int processMouseEnter (int callData, int arg1, int int2) {
sendEvent (SWT.Selection, event);
return 0;
}
-*/
+
int processMouseExit (int callData, int arg1, int int2) {
-/* GtkWidget gtkwidget = new GtkWidget();
- OS.memmove(gtkwidget, handle, GtkWidget.sizeof);
- int border = 0, width = gtkwidget.alloc_width+border*2, height = gtkwidget.alloc_height+border*2;
+ int width = OS.GTK_WIDGET_WIDTH (handle);
+ int height = OS.GTK_WIDGET_HEIGHT (handle);
Event event = new Event ();
event.time = OS.gdk_event_get_time(callData);
event.x = lastX; event.y = lastY;
event.width = width; event.height = height;
- sendEvent (SWT.MouseExit, event);*/
+ sendEvent (SWT.MouseExit, event);
return 0;
}
void drawBand (int x, int y, int width, int height) {
- if (x == drawX && y == drawY) return;
Display display= parent.getDisplay ();
if (display == null) return;
- int window = OS.GTK_WIDGET_WINDOW(parent.topHandle());
+ int window = OS.GTK_WIDGET_WINDOW(parent.paintHandle());
if (window == 0) return;
byte [] bits = {-86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0};
int stipplePixmap = OS.gdk_bitmap_create_from_data (window, bits, 8, 8);
int gc = OS.gdk_gc_new(window);
- Color color = new Color(display, 0xFF, 0, 0);
- OS.gdk_gc_set_background(gc, color.handle);
- Color color1 = new Color(display, 0, 0xFF, 0);
- OS.gdk_gc_set_foreground(gc, color1.handle);
+ Color color = getDisplay().getSystemColor(SWT.COLOR_WHITE);
+ OS.gdk_gc_set_foreground(gc, color.handle);
OS.gdk_gc_set_stipple(gc, stipplePixmap);
OS.gdk_gc_set_subwindow(gc, OS.GDK_INCLUDE_INFERIORS);
OS.gdk_gc_set_fill(gc, OS.GDK_STIPPLED);
OS.gdk_gc_set_function(gc, OS.GDK_XOR);
-
- if (drawing)
- OS.gdk_draw_rectangle(window, gc, 1, drawX, drawY, width, height);
- else
- drawing = true;
- drawX=x;drawY=y;
OS.gdk_draw_rectangle(window, gc, 1, x, y, width, height);
OS.g_object_unref(stipplePixmap);
OS.g_object_unref(gc);
@@ -328,7 +291,7 @@ static int checkStyle (int style) {
void releaseWidget () {
super.releaseWidget ();
- OS.gdk_cursor_destroy (cursor);
+ if (cursor != 0) OS.gdk_cursor_destroy (cursor);
cursor = 0;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java
index f0357f25cb..69ff6e0c7a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java
@@ -94,6 +94,9 @@ static int checkStyle (int style) {
void createHandle (int index) {
state |= HANDLE;
+ fixedHandle = OS.gtk_fixed_new ();
+ if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_fixed_set_has_window (fixedHandle, true);
int hAdjustment = OS.gtk_adjustment_new (0, 0, 100, 1, 10, 0);
if (hAdjustment == 0) error (SWT.ERROR_NO_HANDLES);
if ((style & SWT.HORIZONTAL) != 0) {
@@ -102,18 +105,15 @@ void createHandle (int index) {
handle = OS.gtk_vscale_new (hAdjustment);
}
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
-}
-
-void setHandleStyle() {
+ int parentHandle = parent.parentingHandle ();
+ OS.gtk_container_add (parentHandle, fixedHandle);
+ OS.gtk_container_add (fixedHandle, handle);
+ OS.gtk_widget_show (fixedHandle);
+ OS.gtk_widget_show (handle);
OS.gtk_scale_set_digits (handle, 0);
OS.gtk_scale_set_draw_value (handle, false);
}
-void showHandle() {
- OS.gtk_widget_show (handle);
- OS.gtk_widget_realize (handle);
-}
-
void hookEvents () {
super.hookEvents ();
int hAdjustment = OS.gtk_range_get_adjustment (handle);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
index e612fc7fba..a8f0985af8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
@@ -152,6 +152,7 @@ public Display getDisplay () {
*/
public boolean getEnabled () {
checkWidget ();
+ //NOT DONE
return true;
}
@@ -268,8 +269,8 @@ public int getSelection () {
*/
public Point getSize () {
checkWidget ();
- /* FIXME - NOT_IMPLEMENTED. We can no longer look at the allocation. */
- return new Point (10,10);
+ //FIXME - NOT_IMPLEMENTED
+ return new Point (10, 10);
}
/**
@@ -310,10 +311,12 @@ public int getThumb () {
*/
public boolean getVisible () {
checkWidget ();
+ //NOT DONE
return true;
}
void hookEvents () {
+ super.hookEvents ();
signal_connect (handle, "value_changed", SWT.Selection, 2);
}
@@ -418,6 +421,7 @@ public void removeSelectionListener (SelectionListener listener) {
*/
public void setEnabled (boolean enabled) {
checkWidget ();
+ //NOT DONE
}
/**
@@ -621,6 +625,7 @@ public void setValues (int selection, int minimum, int maximum, int thumb, int i
*/
public void setVisible (boolean visible) {
checkWidget ();
+ //NOT DONE
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
index 289ddb8553..a74d9dd822 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java
@@ -25,7 +25,6 @@ import org.eclipse.swt.graphics.*;
*/
public abstract class Scrollable extends Control {
-
int scrolledHandle;
ScrollBar horizontalBar, verticalBar;
@@ -66,6 +65,10 @@ public Scrollable (Composite parent, int style) {
super (parent, style);
}
+int clientHandle () {
+ return handle;
+}
+
/**
* Given a desired <em>client area</em> for the receiver
* (as described by the arguments), returns the bounding
@@ -90,7 +93,7 @@ public Scrollable (Composite parent, int style) {
* @see #getClientArea
*/
public Rectangle computeTrim (int x, int y, int width, int height) {
- checkWidget();
+ checkWidget ();
int hs=0, vs=0;
/* FIXME - just measured the width on one particular theme */
if ((style&SWT.H_SCROLL)!=0) hs=18;
@@ -98,24 +101,6 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
return new Rectangle (x, y, width+vs, height+hs);
}
-void _fillBin(int binHandle, int childHandle) {
- /*
- GtkBin bin = new GtkBin();
- OS.memmove(bin, binHandle, GtkBin.sizeof);
- bin.child = childHandle;
- OS.memmove(binHandle, bin, GtkBin.sizeof);
- OS.gtk_widget_set_parent(childHandle, binHandle);
- */
- OS.gtk_container_add(binHandle, childHandle);}
-
-/*
- * Subclasses must only use super.configure()
- * to connect their topHandle to the parent.
- * It is the responsibility of the conrete subclass
- * to configure the scrolled handles.
- */
-abstract void configure ();
-
ScrollBar createScrollBar (int style) {
if (scrolledHandle == 0) return null;
ScrollBar bar = new ScrollBar ();
@@ -131,17 +116,18 @@ ScrollBar createScrollBar (int style) {
bar.register ();
return bar;
}
+
void createWidget (int index) {
super.createWidget (index);
if ((style & SWT.H_SCROLL) != 0) horizontalBar = createScrollBar (SWT.H_SCROLL);
if ((style & SWT.V_SCROLL) != 0) verticalBar = createScrollBar (SWT.V_SCROLL);
}
+
void deregister () {
super.deregister ();
- if (scrolledHandle != 0) {
- WidgetTable.remove (scrolledHandle);
- }
+ if (scrolledHandle != 0) WidgetTable.remove (scrolledHandle);
}
+
/**
* Returns a rectangle which describes the area of the
* receiver which is capable of displaying data (that is,
@@ -157,9 +143,17 @@ void deregister () {
* @see #computeTrim
*/
public Rectangle getClientArea () {
- checkWidget();
- /* FIXME. Why do we do it here, in the first place? Scrollable is abstract... */
- return new Rectangle (0, 0, 10, 10);
+ checkWidget ();
+ //FIXME - List, Table, Tree, ...
+ int clientHandle = clientHandle ();
+ int width = OS.GTK_WIDGET_WIDTH (clientHandle);
+ int height = OS.GTK_WIDGET_HEIGHT (clientHandle);
+ if ((state & CANVAS) != 0) {
+ return new Rectangle (0, 0, width, height);
+ }
+ int x = OS.GTK_WIDGET_X (clientHandle);
+ int y = OS.GTK_WIDGET_Y (clientHandle);
+ return new Rectangle (x, y, width, height);
}
/**
* Returns the receiver's horizontal scroll bar if it has
@@ -173,8 +167,7 @@ public Rectangle getClientArea () {
* </ul>
*/
public ScrollBar getHorizontalBar () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
return horizontalBar;
}
/**
@@ -189,23 +182,13 @@ public ScrollBar getHorizontalBar () {
* </ul>
*/
public ScrollBar getVerticalBar () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
return verticalBar;
}
-void setScrollingPolicy() {
- if (scrolledHandle==0) return;
- int hsp = ((style&SWT.H_SCROLL)==0)? OS.GTK_POLICY_NEVER : OS.GTK_POLICY_ALWAYS;
- int vsp = ((style&SWT.V_SCROLL)==0)? OS.GTK_POLICY_NEVER : OS.GTK_POLICY_ALWAYS;
- OS.gtk_scrolled_window_set_policy(scrolledHandle, hsp,vsp);
-}
-
void register () {
super.register ();
- if (scrolledHandle != 0) {
- WidgetTable.put (scrolledHandle, this);
- }
+ if (scrolledHandle != 0) WidgetTable.put (scrolledHandle, this);
}
void releaseHandle () {
@@ -225,8 +208,34 @@ void releaseWidget () {
horizontalBar = verticalBar = null;
super.releaseWidget ();
}
+
+void resizeHandle (int width, int height) {
+ int topHandle = topHandle ();
+ int flags = OS.GTK_WIDGET_FLAGS (topHandle);
+ OS.GTK_WIDGET_SET_FLAGS(topHandle, OS.GTK_VISIBLE);
+ int parentHandle = parent.parentingHandle ();
+ if (fixedHandle != 0) {
+ OS.gtk_widget_set_size_request (fixedHandle, width, height);
+ }
+ if (scrolledHandle != 0) {
+ OS.gtk_widget_set_size_request (scrolledHandle, width, height);
+ } else {
+ OS.gtk_widget_set_size_request (handle, width, height);
+ }
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.gtk_container_resize_children (parentHandle);
+ display.setWarnings (warnings);
+ if ((flags & OS.GTK_VISIBLE) == 0) {
+ OS.GTK_WIDGET_UNSET_FLAGS(topHandle, OS.GTK_VISIBLE);
+ }
+}
+
int topHandle () {
+ if (fixedHandle != 0) return fixedHandle;
if (scrolledHandle != 0) return scrolledHandle;
- return handle;
+ return super.topHandle ();
}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
index 802c0f3fdb..53b3177b5f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
@@ -92,14 +92,11 @@ import org.eclipse.swt.events.*;
*/
public class Shell extends Decorations {
Display display;
- int shellHandle, vboxHandle;
+ int shellHandle;
int modal;
int accelGroup;
boolean hasFocus;
-
-/*
- * === CONSTRUCTORS ===
- */
+ int oldX, oldY, oldWidth, oldHeight;
/**
* Constructs a new instance of this class. This is equivalent
@@ -366,76 +363,20 @@ void closeWidget () {
if (event.doit && !isDisposed ()) dispose ();
}
-
-/*
- * === Handle code I: The createWidget() cycle.
- */
-
void createHandle (int index) {
- state |= HANDLE;
- shellHandle = OS.gtk_window_new((parent==null)? OS.GTK_WINDOW_TOPLEVEL:OS.GTK_WINDOW_DIALOG);
+ state |= HANDLE | CANVAS;
+ int type = true || parent == null ? OS.GTK_WINDOW_TOPLEVEL : OS.GTK_WINDOW_DIALOG;
+ shellHandle = OS.gtk_window_new (type);
if (shellHandle == 0) SWT.error (SWT.ERROR_NO_HANDLES);
- if (parent!=null) OS.gtk_window_set_transient_for(shellHandle, parent.topHandle());
-
- vboxHandle = OS.gtk_vbox_new(false,0);
- if (vboxHandle == 0) SWT.error (SWT.ERROR_NO_HANDLES);
-
- boxHandle = OS.gtk_event_box_new();
- if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES);
-
- fixedHandle = OS.eclipse_fixed_new();
- if (fixedHandle == 0) SWT.error (SWT.ERROR_NO_HANDLES);
-
- handle = OS.gtk_drawing_area_new();
- if (handle == 0) SWT.error (SWT.ERROR_NO_HANDLES);
-
- accelGroup = OS.gtk_accel_group_new ();
- OS.gtk_window_add_accel_group (shellHandle, accelGroup);
+ OS.gtk_window_set_policy (shellHandle, 1, 1, 0);
OS.gtk_window_set_title (shellHandle, new byte [1]);
-}
-
-void configure () {
- OS.gtk_container_add (shellHandle, vboxHandle);
- OS.gtk_box_pack_end(vboxHandle, boxHandle, true,true,0);
- OS.gtk_container_add(boxHandle, fixedHandle);
- OS.gtk_container_add(fixedHandle, handle);
-}
-
-void showHandle() {
- OS.gtk_widget_realize (shellHandle); // careful: NOT show
- _setStyle();
-
- OS.gtk_widget_realize (vboxHandle);
- OS.gtk_widget_show_now (vboxHandle);
- OS.gtk_widget_realize (boxHandle);
- OS.gtk_widget_show_now (boxHandle);
- OS.gtk_widget_realize (fixedHandle);
- OS.gtk_widget_show_now (fixedHandle);
- OS.gtk_widget_realize (handle);
- OS.gtk_widget_show_now (handle);
-}
-
-void hookEvents () {
- super.hookEvents ();
- signal_connect_after(shellHandle, "map-event", SWT.Deiconify, 3);
- signal_connect_after(shellHandle, "unmap-event", SWT.Iconify, 3);
- signal_connect(shellHandle, "size-allocate", SWT.Resize, 3);
- signal_connect(shellHandle, "delete-event", SWT.Dispose, 3);
-}
-
-void register () {
- super.register ();
- WidgetTable.put (vboxHandle, this);
- WidgetTable.put (shellHandle, this);
-}
+ if (parent != null) {
+ OS.gtk_window_set_transient_for (shellHandle, parent.topHandle ());
+ }
+ createScrolledHandle (shellHandle);
-private void _setStyle() {
- boolean modal = (
- ((style&SWT.PRIMARY_MODAL) != 0) ||
- ((style&SWT.APPLICATION_MODAL) != 0) ||
- ((style&SWT.SYSTEM_MODAL) != 0));
- OS.gtk_window_set_modal(shellHandle, modal);
-
+ boolean modal = (style & (SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL)) != 0;
+ OS.gtk_window_set_modal (shellHandle, modal);
int decorations = 0;
if ((style & SWT.NO_TRIM) == 0) {
if ((style & SWT.MIN) != 0) decorations |= OS.GDK_DECOR_MINIMIZE;
@@ -451,75 +392,46 @@ private void _setStyle() {
* kind of border is requested.
*/
if ((style & SWT.RESIZE) != 0) decorations |= OS.GDK_DECOR_BORDER;
- }
- OS.gdk_window_set_decorations(OS.GTK_WIDGET_WINDOW(shellHandle), decorations);
+ }
+ OS.gtk_widget_realize (shellHandle);
+ int window = OS.GTK_WIDGET_WINDOW (shellHandle);
+ // TEMPORARY CODE - trim does not work for dialogs
+// OS.gdk_window_set_decorations (window, decorations);
+
+ accelGroup = OS.gtk_accel_group_new ();
+ OS.gtk_window_add_accel_group (shellHandle, accelGroup);
}
-int topHandle () { return shellHandle; }
-int parentingHandle() { return fixedHandle; }
-boolean isMyHandle(int h) {
- if (h == shellHandle) return true;
- if (h == vboxHandle) return true;
- return super.isMyHandle(h);
+void hookEvents () {
+ super.hookEvents ();
+ signal_connect_after(shellHandle, "map-event", SWT.Deiconify, 3);
+ signal_connect_after(shellHandle, "unmap-event", SWT.Iconify, 3);
+ signal_connect(shellHandle, "size-allocate", SWT.Resize, 3);
+ signal_connect(shellHandle, "configure-event", SWT.Move, 3);
+ signal_connect(shellHandle, "delete-event", SWT.Dispose, 3);
}
+void register () {
+ super.register ();
+ WidgetTable.put (shellHandle, this);
+}
-/*
- * === GEOMETRY ===
- */
+int topHandle () {
+ return shellHandle;
+}
-Point _getLocation() {
+public Point getLocation () {
int [] x = new int [1], y = new int [1];
- OS.gtk_window_get_position(shellHandle, x,y);
- return new Point(x[0], y[0]);
+ OS.gtk_window_get_position (shellHandle, x,y);
+ return new Point (x [0], y [0]);
}
-Point _getSize() {
+public Point getSize () {
int [] width = new int [1], height = new int [1];
OS.gtk_window_get_size (shellHandle, width, height);
return new Point (width [0] + trimWidth (), height [0] + trimHeight ());
}
-public Rectangle getClientArea () {
- checkWidget();
- Point totalSize = _getSize();
- /* FIXME - subtract trim */
- return new Rectangle (0, 0, totalSize.x, totalSize.y);
-}
-
-void _setSize(int width, int height) {
- OS.gtk_signal_handler_block_by_data (shellHandle, SWT.Resize);
- OS.gtk_window_resize (shellHandle, width - trimWidth (), height - trimHeight ());
- OS.gtk_signal_handler_unblock_by_data (shellHandle, SWT.Resize);
-}
-
-void _setLocation (int x, int y) {
- OS.gtk_window_move(shellHandle, x, y);
-}
-
-void setInitialSize() {
- int width = OS.gdk_screen_width () * 5 / 8;
- int height = OS.gdk_screen_height () * 5 / 8;
- _setSize(width, height);
- OS.gtk_window_set_policy (shellHandle, 1,1,0);
-}
-
-/*
- * We can't setInitialSize() before showHandle() in the case of Shell,
- * because we operate on the actual X window, so the shell must be
- * realized by that time.
- * This is a workaround until gtk_window_resize().
- */
-void createWidget (int index) {
- createHandle (index);
- hookEvents ();
- configure ();
- setHandleStyle ();
- register ();
- showHandle ();
- setInitialSize ();
-}
-
public Display getDisplay () {
if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
return display;
@@ -559,20 +471,6 @@ public int getImeInputMode () {
return SWT.NONE;
}
-/**
-* Get the modal state.
-* <p>
-* @return the modal state
-*
-* @exception SWTError(ERROR_ERROR_INVALID_PARENT)
-* when the parent is invalid
-* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
-*/
-public int getModal () {
- checkWidget();
- return modal;
-}
-
Shell _getShell () {
return this;
}
@@ -650,27 +548,25 @@ int processFocusOut(int int0, int int1, int int2) {
return 0;
}
-int processPaint (int callData, int int2, int int3) {
-/* GdkEventExpose gdkEvent = new GdkEventExpose (callData);
- Event event = new Event ();
- event.count = gdkEvent.count;
- event.x = gdkEvent.x; event.y = gdkEvent.y;
- event.width = gdkEvent.width; event.height = gdkEvent.height;
- GC gc = event.gc = new GC (this);
- GdkRectangle rect = new GdkRectangle ();
- rect.x = gdkEvent.x; rect.y = gdkEvent.y;
- rect.width = gdkEvent.width; rect.height = gdkEvent.height;
- OS.gdk_gc_set_clip_rectangle (gc.handle, rect);
- gc.fillRectangle(rect.x, rect.y, rect.width, rect.height);
- sendEvent (SWT.Paint, event);
- gc.dispose ();
- event.gc = null;*/
+int processMove (int int0, int int1, int int2) {
+ int [] x = new int [1], y = new int [1];
+ OS.gtk_window_get_position (shellHandle, x, y);
+ if (oldX != x [0] || oldY != y [0]) {
+ oldX = x [0];
+ oldY = y [0];
+ sendEvent (SWT.Move);
+ }
return 0;
}
int processResize (int int0, int int1, int int2) {
- sendEvent (SWT.Resize);
- layout();
+ int [] width = new int [1], height = new int [1];
+ OS.gtk_window_get_size (shellHandle, width, height);
+ if (oldWidth != width [0] || oldHeight != height [0]) {
+ oldWidth = width [0];
+ oldHeight = height [0];
+ resizeBounds (width [0], height [0], true);
+ }
return 0;
}
@@ -702,6 +598,48 @@ public void removeShellListener (ShellListener listener) {
eventTable.unhook (SWT.Deactivate, listener);
}
+void resizeBounds (int width, int height, boolean notify) {
+ int menuHeight = 0;
+ if (menuBar != null) {
+ int menuHandle = menuBar.handle;
+ OS.gtk_widget_set_size_request (menuHandle, -1, -1);
+ GtkRequisition requisition = new GtkRequisition ();
+ OS.gtk_widget_size_request (menuHandle, requisition);
+ menuHeight = requisition.height;
+ OS.gtk_widget_set_size_request (menuHandle, width, menuHeight);
+ height = height - menuHeight;
+ }
+ OS.gtk_fixed_move (fixedHandle, scrolledHandle, 0, menuHeight);
+ OS.gtk_widget_set_size_request (scrolledHandle, width, height);
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.gtk_container_resize_children (fixedHandle);
+ display.setWarnings (warnings);
+ if (notify) {
+ sendEvent (SWT.Resize);
+ if (layout != null) layout.layout (this, false);
+ }
+}
+
+boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ if (move) {
+ int [] x_pos = new int [1], y_pos = new int [1];
+ OS.gtk_window_get_position (shellHandle, x_pos, y_pos);
+ oldX = x_pos [0]; oldY = y_pos [0];
+ OS.gtk_window_move (shellHandle, x, y);
+ }
+ if (resize) {
+ int [] w = new int [1], h = new int [1];
+ OS.gtk_window_get_size (shellHandle, w, h);
+ oldWidth = w [0]; oldHeight = h [0];
+ width -= trimWidth (); height -= trimHeight ();
+ OS.gtk_window_resize (shellHandle, width, height);
+ resizeBounds (width, height, true);
+ }
+ return move || resize;
+}
+
/**
* Sets the input method editor mode to the argument which
* should be the result of bitwise OR'ing together one or more
@@ -722,52 +660,52 @@ public void setImeInputMode (int mode) {
checkWidget();
}
+void setInitialSize () {
+ int width = OS.gdk_screen_width () * 5 / 8;
+ int height = OS.gdk_screen_height () * 5 / 8;
+ OS.gtk_widget_set_size_request (scrolledHandle, width, height);
+ OS.gtk_window_resize (shellHandle, width, height);
+ OS.gtk_container_resize_children (fixedHandle);
+}
+
public void setMaximized (boolean maximized) {
checkWidget();
- if (maximized) OS.gtk_window_maximize(shellHandle);
- else OS.gtk_window_unmaximize(shellHandle);
+ if (maximized) {
+ OS.gtk_window_maximize (shellHandle);
+ } else {
+ OS.gtk_window_unmaximize (shellHandle);
+ }
}
public void setMenuBar (Menu menu) {
checkWidget();
-
if (menuBar == menu) return;
+ boolean both = menu != null && menuBar != null;
if (menu != null) {
if ((menu.style & SWT.BAR) == 0) error (SWT.ERROR_MENU_NOT_BAR);
if (menu.parent != this) error (SWT.ERROR_INVALID_PARENT);
}
- if (menu == null) {
- if (menuBar != null) {
- OS.gtk_object_ref (menuBar.handle);
- OS.gtk_container_remove (vboxHandle, menuBar.handle);
- }
+ if (menuBar != null) {
+ int menuHandle = menuBar.handle;
+ OS.gtk_widget_hide (menuHandle);
}
menuBar = menu;
if (menuBar != null) {
int menuHandle = menu.handle;
- OS.gtk_box_pack_start (vboxHandle, menuHandle, false, false, 0);
+ OS.gtk_widget_show (menuHandle);
}
+ int [] width = new int [1], height = new int [1];
+ OS.gtk_window_get_size (shellHandle, width, height);
+ resizeBounds (width [0], height [0], !both);
}
public void setMinimized (boolean minimized) {
checkWidget();
- if (minimized) OS.gtk_window_iconify(shellHandle);
- else OS.gtk_window_deiconify(shellHandle);
-}
-
-/**
-* Set the modal state.
-* <p>
-* @param modal the new modal state
-*
-* @exception SWTError(ERROR_ERROR_INVALID_PARENT)
-* when the parent is invalid
-* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
-*/
-public void setModal (int modal) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- this.modal = modal;
+ if (minimized) {
+ OS.gtk_window_iconify (shellHandle);
+ } else {
+ OS.gtk_window_deiconify (shellHandle);
+ }
}
public void setText (String string) {
@@ -777,11 +715,22 @@ public void setText (String string) {
byte [] buffer = Converter.wcsToMbcs (null, string, true);
OS.gtk_window_set_title (shellHandle, buffer);
}
+
public void setVisible (boolean visible) {
checkWidget();
if (visible) {
sendEvent (SWT.Show);
- OS.gtk_widget_show_now (shellHandle);
+
+ //TEMPORARY CODE
+ int [] width = new int [1], height = new int [1];
+ OS.gtk_window_get_size (shellHandle, width, height);
+ resizeBounds (width [0], height [0], true);
+
+ // NOT DONE - shell should be fully drawn before setVisible()
+ // returns. Note we cannot use gtk_widget_show_now because
+ // it dispatches events.
+// OS.gtk_widget_show_now (shellHandle);
+ OS.gtk_widget_show (shellHandle);
display.update();
adjustTrim ();
} else {
@@ -822,18 +771,22 @@ int trimWidth () {
return 0;
}
-/*
- * === DESTRUCTION ===
- */
-
void deregister () {
super.deregister ();
- WidgetTable.remove (vboxHandle);
+ WidgetTable.remove (shellHandle);
+}
+
+public Rectangle getBounds () {
+ int [] x = new int [1], y = new int [1];
+ OS.gtk_window_get_position (shellHandle, x, y);
+ int [] width = new int [1], height = new int [1];
+ OS.gtk_window_get_size (shellHandle, width, height);
+ return new Rectangle (x [0], y [0], width [0] + trimWidth (), height [0] + trimHeight ());
}
void releaseHandle () {
super.releaseHandle ();
- vboxHandle = 0;
+ shellHandle = 0;
}
void releaseShells () {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java
index 91d2a5fd16..d33541818b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java
@@ -137,6 +137,9 @@ static int checkStyle (int style) {
void createHandle (int index) {
state |= HANDLE;
+ fixedHandle = OS.gtk_fixed_new ();
+ if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_fixed_set_has_window (fixedHandle, true);
int hAdjustment = OS.gtk_adjustment_new (0, 0, 100, 1, 10, 10);
if (hAdjustment == 0) error (SWT.ERROR_NO_HANDLES);
if ((style & SWT.HORIZONTAL) != 0) {
@@ -145,13 +148,11 @@ void createHandle (int index) {
handle = OS.gtk_vscrollbar_new (hAdjustment);
}
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
-}
-
-void setHandleStyle() {}
-
-void showHandle() {
+ int parentHandle = parent.parentingHandle ();
+ OS.gtk_container_add (parentHandle, fixedHandle);
+ OS.gtk_container_add (fixedHandle, handle);
+ OS.gtk_widget_show (fixedHandle);
OS.gtk_widget_show (handle);
- OS.gtk_widget_realize (handle);
}
void hookEvents () {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
index d4ea81235a..a653383855 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
@@ -34,14 +34,8 @@ import org.eclipse.swt.events.*;
* </p>
*/
public class TabFolder extends Composite {
-
- int topHandle;
TabItem [] items;
-/*
- * == CONSTRUCTORS ==
- */
-
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -74,36 +68,18 @@ public TabFolder (Composite parent, int style) {
super (parent, checkStyle (style));
}
-/*
- * == Handle code ==
- */
-
void createHandle (int index) {
state |= HANDLE;
- topHandle = OS.eclipse_fixed_new();
+ fixedHandle = OS.gtk_fixed_new ();
+ if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_fixed_set_has_window (fixedHandle, true);
handle = OS.gtk_notebook_new ();
- boxHandle = OS.gtk_event_box_new();
- fixedHandle = OS.eclipse_fixed_new ();
-}
-
-void configure () {
- parent._connectChild(topHandle);
- OS.gtk_container_add(topHandle, handle);
- OS.gtk_container_add(topHandle, boxHandle);
- OS.gtk_container_add(boxHandle, fixedHandle);
- OS.eclipse_fixed_set_location(topHandle, boxHandle, 2, 33); /* FIXME */
-}
-
-void showHandle() {
- OS.gtk_widget_show(topHandle);
- OS.gtk_widget_show(handle);
- OS.gtk_widget_show(boxHandle);
- OS.gtk_widget_show(fixedHandle);
-}
-
-void register () {
- super.register ();
- WidgetTable.put (topHandle, this);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ int parentHandle = parent.parentingHandle ();
+ OS.gtk_container_add (parentHandle, fixedHandle);
+ OS.gtk_container_add (fixedHandle, handle);
+ OS.gtk_widget_show (handle);
+ OS.gtk_widget_show (fixedHandle);
}
void hookEvents () {
@@ -116,14 +92,6 @@ void createWidget (int index) {
items = new TabItem [4];
}
-int topHandle () { return topHandle; }
-public int paintHandle () { return boxHandle; } /* can't do much :-( */
-int parentingHandle () { return fixedHandle; }
-boolean isMyHandle(int h) {
- if (h==topHandle) return true;
- return super.isMyHandle(h);
-}
-
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
//notebookHandle
@@ -148,6 +116,11 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
return new Point(300,300);
}
+int clientHandle () {
+ if (items [0] != null) return items [0].pageHandle;
+ return handle;
+}
+
/**
* Computes the widget trim.
*/
@@ -156,38 +129,24 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
return new Rectangle(x-2, y-33, width+4, height+35);
}
-/*
- * === Layout code ===
- */
-
-void _setSize(int width, int height) {
- OS.eclipse_fixed_set_size(parent.parentingHandle(), topHandle(), width, height);
- /* FIXME */
- int w = Math.max(width - 4, 1);
- int h = Math.max(height - 35, 1);
- OS.eclipse_fixed_set_size(topHandle, handle, w, h);
- layoutCurrent();
-}
-
-public Rectangle getClientArea () {
- checkWidget();
- int[] sz = new int[2];
- OS.eclipse_fixed_get_size(topHandle, boxHandle, sz);
- return new Rectangle(0,0, sz[0], sz[1]);
-}
-
-void layoutCurrent() {
- int index=getSelectionIndex();
- if (index==-1) return;
- Control control = items[index].control;
- if (control==null) return;
- if (control.isDisposed()) return;
- control.setBounds(getClientArea());
+boolean setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ boolean changed = super.setBounds (x, y, width, height, move, resize);
+ if (changed && resize) {
+ int index = getSelectionIndex ();
+ if (index != -1) {
+ TabItem item = items [index];
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getClientArea ());
+ }
+ }
+ }
+ return changed;
}
void createItem (TabItem item, int index) {
int list = OS.gtk_container_children (handle);
- int itemCount = OS.g_list_length (list);
+ int itemCount = (list != 0) ? OS.g_list_length (list) : 0;
if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_ITEM_NOT_ADDED);
if (itemCount == items.length) {
TabItem [] newItems = new TabItem [items.length + 4];
@@ -197,20 +156,23 @@ void createItem (TabItem item, int index) {
// create a new label
int labelHandle = OS.gtk_label_new ("");
+ if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
// create a new fake page
- int stubPage = OS.eclipse_fixed_new();
+ int pageHandle = OS.gtk_fixed_new();
+ if (pageHandle == 0) error (SWT.ERROR_NO_HANDLES);
// put the label and the fake page inside the notebook
OS.gtk_signal_handler_block_by_data (handle, SWT.Selection);
- OS.gtk_notebook_append_page(handle, stubPage, labelHandle);
+ OS.gtk_notebook_append_page(handle, pageHandle, labelHandle);
OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
OS.gtk_widget_show(labelHandle);
- OS.gtk_widget_show(stubPage);
+ OS.gtk_widget_show(pageHandle);
item.state |= HANDLE;
item.handle = labelHandle;
+ item.pageHandle = pageHandle;
System.arraycopy (items, index, items, index + 1, itemCount++ - index);
items [index] = item;
OS.gtk_notebook_set_show_tabs (handle, true);
@@ -262,6 +224,7 @@ void destroyItem (TabItem item) {
items [itemCount] = null;
item.handle = 0;
}
+
/**
* Returns the item at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
@@ -281,10 +244,11 @@ void destroyItem (TabItem item) {
public TabItem getItem (int index) {
checkWidget();
int list = OS.gtk_container_children (handle);
- int itemCount = OS.g_list_length (list);
+ int itemCount = list != 0 ? OS.g_list_length (list) : 0;
if (!(0 <= index && index < itemCount)) error (SWT.ERROR_CANNOT_GET_ITEM);
return items [index];
}
+
/**
* Returns the number of items contained in the receiver.
*
@@ -297,10 +261,10 @@ public TabItem getItem (int index) {
*/
public int getItemCount () {
checkWidget();
- //return itemCount;
int list = OS.gtk_container_children (handle);
- return OS.g_list_length (list);
+ return list != 0 ? OS.g_list_length (list) : 0;
}
+
/**
* Returns an array of <code>TabItem</code>s which are the items
* in the receiver.
@@ -320,11 +284,12 @@ public int getItemCount () {
public TabItem [] getItems () {
checkWidget();
int list = OS.gtk_container_children (handle);
- int itemCount = OS.g_list_length (list);
- TabItem [] result = new TabItem [itemCount];
- System.arraycopy (items, 0, result, 0, itemCount);
+ int count = list != 0 ? OS.g_list_length (list) : 0;
+ TabItem [] result = new TabItem [count];
+ System.arraycopy (items, 0, result, 0, count);
return result;
}
+
/**
* Returns an array of <code>TabItem</code>s that are currently
* selected in the receiver. An empty array indicates that no
@@ -347,6 +312,7 @@ public TabItem [] getSelection () {
if (index == -1) return new TabItem [0];
return new TabItem [] {items [index]};
}
+
/**
* Returns the zero-relative index of the item which is currently
* selected in the receiver, or -1 if no item is selected.
@@ -384,8 +350,8 @@ public int indexOf (TabItem item) {
checkWidget();
if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
int list = OS.gtk_container_children (handle);
- int itemCount = OS.g_list_length (list);
- for (int i=0; i<itemCount; i++) {
+ int count = list != 0 ? OS.g_list_length (list) : 0;
+ for (int i=0; i<count; i++) {
if (items [i] == item) return i;
}
return -1;
@@ -481,55 +447,16 @@ public void setSelection (TabItem [] items) {
}
}
-/*
- * == DESTRUCTION ===
- */
-
-void deregister () {
- super.deregister ();
- WidgetTable.remove (topHandle);
-}
-
-void releaseChildren() {
- int list = OS.gtk_container_children (handle);
- int itemCount = OS.g_list_length (list);
- for (int i=0; i<itemCount; i++) {
+void releaseWidget () {
+ int count = getItemCount ();
+ for (int i=0; i<count; i++) {
TabItem item = items [i];
- if (!item.isDisposed ()) {
- item.releaseWidget ();
- item.releaseHandle ();
- }
+ if (!item.isDisposed ()) item.releaseWidget ();
}
-
- // Now, the non-item children
- list = OS.gtk_container_children(parentingHandle());
- int childCount = OS.g_list_length (list);
- for (int i=0; i<childCount; i++) {
- int childHandle = OS.g_list_nth_data(list, i);
- if (!isMyHandle(childHandle)) {
- Widget w = WidgetTable.get(childHandle);
- if (!(w==null) && !(w.isDisposed())) {
- w.releaseWidget();
- w.releaseHandle();
- }
- }
- }
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- boxHandle = 0;
-}
-
-void releaseWidget () {
- super.releaseWidget();
items = null;
+ super.releaseWidget ();
}
-/*
- * == AS YET UNCLASSIFIED ===
- */
-
static int checkStyle (int style) {
/*
* Even though it is legal to create this widget
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
index ac67526950..e6cb3b5acb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
@@ -25,8 +25,10 @@ import org.eclipse.swt.graphics.*;
*/
public class TabItem extends Item {
+ int pageHandle;
Control control;
TabFolder parent;
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>TabFolder</code>) and a style value
@@ -62,6 +64,7 @@ public TabItem (TabFolder parent, int style) {
this.parent = parent;
parent.createItem (this, parent.getItemCount ());
}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>TabFolder</code>), a style value
@@ -98,6 +101,7 @@ public TabItem (TabFolder parent, int style, int index) {
this.parent = parent;
parent.createItem (this, index);
}
+
/**
* Returns the control that is used to fill the client area of
* the tab folder when the user selects the tab item. If no
@@ -115,11 +119,13 @@ public Control getControl () {
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
return control;
}
+
public Display getDisplay () {
TabFolder parent = this.parent;
if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
return parent.getDisplay ();
}
+
/**
* Returns the receiver's parent, which must be a <code>TabFolder</code>.
*
@@ -135,6 +141,7 @@ public TabFolder getParent () {
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
return parent;
}
+
/**
* Returns the receiver's tool tip text, or null if it has
* not been set.
@@ -151,14 +158,17 @@ public String getToolTipText () {
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
return "";
}
+
void releaseChild () {
super.releaseChild ();
parent.destroyItem (this);
}
+
void releaseWidget () {
super.releaseWidget ();
parent = null;
}
+
/**
* Sets the control that is used to fill the client area of
* the tab folder when the user selects the tab item.
@@ -180,18 +190,23 @@ public void setControl (Control control) {
Control oldControl = this.control, newControl = control;
this.control = control;
int index = parent.indexOf (this);
- if (index != parent.getSelectionIndex ()) return;
+ if (index != parent.getSelectionIndex ()) {
+ if (newControl != null) newControl.setVisible (false);
+ return;
+ }
if (newControl != null) {
newControl.setBounds (parent.getClientArea ());
newControl.setVisible (true);
}
if (oldControl != null) oldControl.setVisible (false);
}
+
public void setImage (Image image) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
super.setImage (image);
}
+
public void setText (String string) {
checkWidget ();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -205,6 +220,7 @@ public void setText (String string) {
byte [] buffer = Converter.wcsToMbcs (null, text);
OS.gtk_label_set_text_with_mnemonic (handle, buffer);
}
+
/**
* Sets the receiver's tool tip text to the argument, which
* may be null indicating that no tool tip text should be shown.
@@ -220,4 +236,5 @@ public void setToolTipText (String string) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
index 25ac0f9fb4..7754fd015b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
@@ -74,40 +74,26 @@ public Table (Composite parent, int style) {
super (parent, checkStyle (style));
}
-
-
-
-/*
- * === HANDLE CODE 1 ===
- */
-
void createHandle (int index) {
state |= HANDLE;
-
- boxHandle = OS.gtk_event_box_new();
- if (boxHandle==0) error(SWT.ERROR_NO_HANDLES);
-
- fixedHandle = OS.eclipse_fixed_new();
+ fixedHandle = OS.gtk_fixed_new ();
if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
-
- handle = OS.gtk_clist_new (MAX_COLUMNS);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
-
+ OS.gtk_fixed_set_has_window (fixedHandle, true);
scrolledHandle = OS.gtk_scrolled_window_new (0, 0);
if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
-}
-void configure() {
- parent._connectChild(topHandle());
- OS.gtk_container_add (boxHandle, fixedHandle);
+ handle = OS.gtk_clist_new (MAX_COLUMNS);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ int parentHandle = parent.parentingHandle ();
+ OS.gtk_container_add (parentHandle, fixedHandle);
OS.gtk_container_add (fixedHandle, scrolledHandle);
OS.gtk_container_add (scrolledHandle, handle);
-}
-void setHandleStyle () {
+ OS.gtk_widget_show (fixedHandle);
+ OS.gtk_widget_show (scrolledHandle);
+ OS.gtk_widget_show (handle);
+
/* Single or Multiple Selection */
- int selectionMode;
- if ((style & SWT.MULTI) != 0) selectionMode = OS.GTK_SELECTION_EXTENDED;
- else selectionMode = OS.GTK_SELECTION_BROWSE;
- OS.gtk_clist_set_selection_mode (handle, selectionMode);
+ int mode = (style & SWT.MULTI) != 0 ? OS.GTK_SELECTION_EXTENDED : OS.GTK_SELECTION_BROWSE;
+ OS.gtk_clist_set_selection_mode (handle, mode);
/* We fake the number of columns, because we have to know beforehand.
* Initially all those fake columns are invisible
@@ -122,21 +108,14 @@ void setHandleStyle () {
int hscrollbar_policy = (style & SWT.H_SCROLL) != 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_AUTOMATIC;
int vscrollbar_policy = (style & SWT.V_SCROLL) != 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_AUTOMATIC;
OS.gtk_scrolled_window_set_policy (scrolledHandle, hscrollbar_policy, vscrollbar_policy);
-}
-
-void showHandle() {
- OS.gtk_widget_show (boxHandle);
- OS.gtk_widget_show (fixedHandle);
- OS.gtk_widget_show (scrolledHandle);
- OS.gtk_widget_show (handle);
- OS.gtk_widget_realize (handle);
-
if ((style & SWT.CHECK) != 0) {
+ OS.gtk_widget_realize (handle);
uncheck = createCheckPixmap(false);
check = createCheckPixmap(true);
}
}
+
void hookEvents () {
//TO DO - get rid of enter/exit for mouse crossing border
super.hookEvents ();
@@ -144,49 +123,48 @@ void hookEvents () {
}
int createCheckPixmap(boolean checked) {
- /*
- * The box will occupy the whole item width.
- */
- GtkCList clist = new GtkCList (handle);
- check_height = clist.row_height-1;
- check_width = check_height;
+ /*
+ * The box will occupy the whole item width.
+ */
+ GtkCList clist = new GtkCList (handle);
+ check_height = clist.row_height-1;
+ check_width = check_height;
- GdkVisual visual = new GdkVisual(OS.gdk_visual_get_system());
- int pixmap = OS.gdk_pixmap_new(0, check_width, check_height, visual.depth);
-
- int gc = OS.gdk_gc_new(pixmap);
-
- GdkColor fgcolor = new GdkColor();
- fgcolor.pixel = 0xFFFFFFFF;
- fgcolor.red = (short) 0xFFFF;
- fgcolor.green = (short) 0xFFFF;
- fgcolor.blue = (short) 0xFFFF;
- OS.gdk_gc_set_foreground(gc, fgcolor);
- OS.gdk_draw_rectangle(pixmap, gc, 1, 0,0, check_width,check_height);
+ GdkVisual visual = new GdkVisual(OS.gdk_visual_get_system());
+ int pixmap = OS.gdk_pixmap_new(0, check_width, check_height, visual.depth);
+
+ int gc = OS.gdk_gc_new(pixmap);
+
+ GdkColor fgcolor = new GdkColor();
+ fgcolor.pixel = 0xFFFFFFFF;
+ fgcolor.red = (short) 0xFFFF;
+ fgcolor.green = (short) 0xFFFF;
+ fgcolor.blue = (short) 0xFFFF;
+ OS.gdk_gc_set_foreground(gc, fgcolor);
+ OS.gdk_draw_rectangle(pixmap, gc, 1, 0,0, check_width,check_height);
- fgcolor = new GdkColor();
- fgcolor.pixel = 0;
- fgcolor.red = (short) 0;
- fgcolor.green = (short) 0;
- fgcolor.blue = (short) 0;
- OS.gdk_gc_set_foreground(gc, fgcolor);
-
- OS.gdk_draw_line(pixmap, gc, 0,0, 0,check_height-1);
- OS.gdk_draw_line(pixmap, gc, 0,check_height-1, check_width-1,check_height-1);
- OS.gdk_draw_line(pixmap, gc, check_width-1,check_height-1, check_width-1,0);
- OS.gdk_draw_line(pixmap, gc, check_width-1,0, 0,0);
+ fgcolor = new GdkColor();
+ fgcolor.pixel = 0;
+ fgcolor.red = (short) 0;
+ fgcolor.green = (short) 0;
+ fgcolor.blue = (short) 0;
+ OS.gdk_gc_set_foreground(gc, fgcolor);
+
+ OS.gdk_draw_line(pixmap, gc, 0,0, 0,check_height-1);
+ OS.gdk_draw_line(pixmap, gc, 0,check_height-1, check_width-1,check_height-1);
+ OS.gdk_draw_line(pixmap, gc, check_width-1,check_height-1, check_width-1,0);
+ OS.gdk_draw_line(pixmap, gc, check_width-1,0, 0,0);
- /* now the cross check */
- if (checked) {
- OS.gdk_draw_line(pixmap, gc, 0,0, check_width-1,check_height-1);
- OS.gdk_draw_line(pixmap, gc, 0,check_height-1, check_width-1,0);
- }
-
- OS.g_object_unref(gc);
- return pixmap;
+ /* now the cross check */
+ if (checked) {
+ OS.gdk_draw_line(pixmap, gc, 0,0, check_width-1,check_height-1);
+ OS.gdk_draw_line(pixmap, gc, 0,check_height-1, check_width-1,0);
+ }
+
+ OS.g_object_unref(gc);
+ return pixmap;
}
-
void createWidget (int index) {
super.createWidget (index);
items = new TableItem [4];
@@ -194,22 +172,6 @@ void createWidget (int index) {
itemCount = columnCount = 0;
}
-/*
- * HANDLE CODE 2
- */
-int topHandle() { return boxHandle; }
-int parentingHandle() { return fixedHandle; }
-
-
-/*
- * === GEOMETRY ===
- */
-
-void _setSize(int width, int height) {
- OS.eclipse_fixed_set_size(parent.parentingHandle(), topHandle(), width, height);
- OS.eclipse_fixed_set_size(fixedHandle, scrolledHandle, width, height);
-}
-
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
if (wHint == SWT.DEFAULT) wHint = 200;
@@ -250,7 +212,6 @@ public void addSelectionListener (SelectionListener listener) {
addListener (SWT.DefaultSelection,typedListener);
}
-
/* The real work to create a new column */
void createItem (TableColumn column, int index) {
if (!(0 <= index && index <= columnCount)) error (SWT.ERROR_ITEM_NOT_ADDED);
@@ -264,6 +225,7 @@ void createItem (TableColumn column, int index) {
System.arraycopy (columns, index, columns, index + 1, columnCount++ - index);
columns [index] = column;
}
+
void createItem (TableItem item, int index) {
if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_ITEM_NOT_ADDED);
if (itemCount == items.length) {
@@ -279,6 +241,11 @@ void createItem (TableItem item, int index) {
int result = OS.gtk_clist_insert (handle, index, strings);
OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
// OS.g_free (ptr);
+ if ((style & SWT.CHECK) != 0) {
+ byte [] spacing = new byte [1];
+ OS.gtk_clist_get_pixtext (handle, index, 0, null, spacing, null, null);
+ OS.gtk_clist_set_pixtext (handle, index, 0, null, spacing [0], uncheck, 0);
+ }
System.arraycopy (items, index, items, index + 1, itemCount++ - index);
items [index] = item;
}
@@ -473,12 +440,9 @@ public TableColumn [] getColumns () {
*/
public int getGridLineWidth () {
checkWidget();
- /* FIXME */
return 0;
}
-
-
/**
* Returns the item at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
@@ -585,12 +549,6 @@ public TableItem [] getItems () {
return result;
}
-
-
-/*
- * === SELECTION STORY ===
- */
-
/**
* Returns an array of <code>TableItem</code>s that are currently
* selected in the receiver. An empty array indicates that no
@@ -622,10 +580,8 @@ private TableItem[] _getNativeSelection () {
case OS.GTK_SELECTION_BROWSE: return getSelection_browse();
case OS.GTK_SELECTION_MULTIPLE: return getSelection_multiple();
case OS.GTK_SELECTION_EXTENDED: return getSelection_extended();
- default: error(SWT.ERROR_UNSPECIFIED);
}
- /* can never get here */
- return null;
+ return new TableItem [0];
}
private TableItem[] getSelection_single () {
GtkCList clist = new GtkCList(handle);
@@ -756,10 +712,6 @@ public boolean isSelected (int index) {
return false;
}
-
-
-
-
/**
* Returns the zero-relative index of the item which is currently
* at the top of the receiver. This index can change when items are
@@ -830,14 +782,11 @@ public int indexOf (TableItem item) {
}
void releaseWidget () {
- int columnCount = 0;
for (int i=0; i<columnCount; i++) {
TableColumn column = columns [i];
-// if (!column.isDisposed ()) column.releaseWidget ();
- if (column != null && !column.isDisposed ()) column.releaseWidget ();
+ if (!column.isDisposed ()) column.releaseWidget ();
}
columns = null;
- int itemCount = 0;
for (int i=0; i<itemCount; i++) {
TableItem item = items [i];
if (!item.isDisposed ()) item.releaseWidget ();
@@ -1118,11 +1067,11 @@ public void setHeaderVisible (boolean show) {
* VERY WEIRD.
*/
-/* if (show) {
+ if (show) {
OS.gtk_clist_column_titles_show (handle);
} else {
OS.gtk_clist_column_titles_hide (handle);
- }*/
+ }
}
/**
* Returns <code>true</code> if the receiver's lines are visible,
@@ -1327,7 +1276,14 @@ int processSelection (int int0, int int1, int int2) {
return 0;
}
+int paintWindow () {
+ OS.gtk_widget_realize (handle);
+ GtkCList clist = new GtkCList (handle);
+ return clist.clist_window;
+}
+
int processMouseDown (int callData, int arg1, int int2) {
+ int result = super.processMouseDown (callData, arg1, int2);
OS.gtk_widget_grab_focus(handle);
// First, see if we have a single or double click
@@ -1344,41 +1300,35 @@ int processMouseDown (int callData, int arg1, int int2) {
event.item=itemBeingSelected;
event.x = ppx[0]; event.y = ppy[0];
sendEvent (SWT.DefaultSelection, event);
- return 1;
+ return result;
}
eventType = SWT.MouseDown;
- int[] pMod = new int[1];
- OS.gdk_event_get_state(callData, pMod);
- int time = OS.gdk_event_get_time(callData);
- double[] px = new double[1];
- double[] py = new double[1];
- OS.gdk_event_get_coords(callData, px, py);
int button = OS.gdk_event_button_get_button(callData);
- sendMouseEvent (eventType, button, pMod[0], time, (int)(px[0]), (int)(py[0]));
+ sendMouseEvent (eventType, button, callData);
if (button == 3 && menu != null) menu.setVisible (true);
if ((style&SWT.CHECK) != 0) {
GtkCList clist = new GtkCList (handle);
int clientX = ppx[0];
int clientY = ppy[0] - clist.column_title_area_height;
- if (clientY <= 0) return 1;
+ if (clientY <= 0) return result;
int[] row = new int[1], column = new int[1];
row[0] = -1;
OS.gtk_clist_get_selection_info(handle, clientX, clientY, row, column);
- if (row[0] == -1) return -1;
+ if (row[0] == -1) return result;
int leftmost = 2;
- if (clientX < leftmost) return 1;
- if (clientX > leftmost+check_width) return 1;
+ if (clientX < leftmost) return result;
+ if (clientX > leftmost+check_width) return result;
TableItem item = items [row[0]];
- item._setChecked(!item._getChecked());
+ item.setChecked(!item.getChecked());
Event event = new Event ();
event.detail = SWT.CHECK;
event.item = item;
postEvent (SWT.Selection, event);
}
- return 1;
+ return result;
}
static int checkStyle (int style) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
index e31be21f4c..5d97b50005 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
@@ -27,6 +27,44 @@ import org.eclipse.swt.graphics.*;
public class TableItem extends Item {
Table parent;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Table</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * for all SWT widget classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TableItem (Table parent, int style, int index) {
+ super (parent, style);
+ this.parent = parent;
+ parent.createItem (this, index);
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Table</code>) and a style value
@@ -61,56 +99,38 @@ public TableItem (Table parent, int style) {
super (parent, style);
this.parent = parent;
parent.createItem (this, parent.getItemCount ());
- _setChecked(false);
}
-/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Table</code>), a style value
- * describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * for all SWT widget classes should include a comment which
- * describes the style constants which are applicable to the class.
- * </p>
- *
- * @param parent a composite control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
- * @param index the index to store the receiver in its parent
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
-public TableItem (Table parent, int style, int index) {
- super (parent, style);
- this.parent = parent;
- parent.createItem (this, index);
- _setChecked(false);
+
+/**
+ * Returns the receiver's background color.
+ *
+ * @return the background color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public Color getBackground () {
+ checkWidget ();
+ Table parent = getParent();
+ return parent.getBackground();
}
-/**
- * Returns a rectangle describing the receiver's size and location
- * relative to its parent at a column in the table.
- *
- * @param index the index that specifies the column
- * @return the receiver's bounding column rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent at a column in the table.
+ *
+ * @param index the index that specifies the column
+ * @return the receiver's bounding column rectangle
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public Rectangle getBounds (int index) {
checkWidget();
@@ -119,7 +139,6 @@ public Rectangle getBounds (int index) {
int columnHandle = table.column;
columnHandle= columnHandle+index*GtkCListColumn.sizeof;
GtkCListColumn column=new GtkCListColumn(columnHandle);
-
double haj = OS.gtk_adjustment_get_value(table.hadjustment);
double vaj = OS.gtk_adjustment_get_value(table.vadjustment);
int x=(short)column.area_x+table.hoffset;
@@ -131,43 +150,26 @@ public Rectangle getBounds (int index) {
}
/**
- * Return whether or not the receiver has a check box and can
- * be checked.
- */
-boolean isCheckable() {
- return (parent.style & SWT.CHECK) != 0;
-}
-
-/**
- * Returns <code>true</code> if the receiver is checked,
- * and false otherwise. When the parent does not have
- * the <code>CHECK style, return false.
- *
- * @return the checked state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+ * Returns <code>true</code> if the receiver is checked,
+ * and false otherwise. When the parent does not have
+ * the <code>CHECK style, return false.
+ *
+ * @return the checked state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
public boolean getChecked () {
checkWidget();
if ((parent.style & SWT.CHECK) == 0) return false;
- return _getChecked();
-}
-
-boolean _getChecked () {
int row = parent.indexOf (this);
if (row == -1) return false;
int clist = parent.handle;
-
- int[] text = new int[1];
- int[] spacing = new int[1];
- int[] pixmap = new int[1];
- int[] mask = new int[1];
- OS.gtk_clist_get_pixtext(clist, row, 0, text, spacing, pixmap, mask);
-
- return pixmap[0]==parent.check;
+ int [] pixmap = new int [1];
+ OS.gtk_clist_get_pixtext (clist, row, 0, null, null, pixmap, null);
+ return pixmap [0] == parent.check;
}
public Display getDisplay () {
@@ -175,6 +177,26 @@ public Display getDisplay () {
if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
return parent.getDisplay ();
}
+
+/**
+ * Returns the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public Color getForeground () {
+ checkWidget ();
+ Table parent = getParent();
+ return parent.getForeground();
+}
+
/**
* Returns <code>true</code> if the receiver is grayed,
* and false otherwise. When the parent does not have
@@ -188,8 +210,8 @@ public Display getDisplay () {
* </ul>
*/
public boolean getGrayed () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
+ //NOT DONE
if ((parent.style & SWT.CHECK) == 0) return false;
return false;
}
@@ -212,10 +234,17 @@ public boolean getGrayed () {
* when the widget has been disposed
*/
public Image getImage (int index) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return null;
+ checkWidget ();
+ if (index == 0) return getImage ();
+ int row = parent.indexOf (this);
+ if (row == -1) return null;
+ int clist = parent.handle;
+ int [] pixmap = new int [1], mask = new int [1];
+ OS.gtk_clist_get_pixtext (clist, row, index, null, null, pixmap, null);
+ Display display = getDisplay ();
+ return Image.gtk_new (display, mask [0] == 0 ? SWT.BITMAP : SWT.ICON, pixmap [0], mask [0]);
}
+
/**
* Returns a rectangle describing the size and location
* relative to its parent of an image at a column in the
@@ -230,10 +259,11 @@ public Image getImage (int index) {
* </ul>
*/
public Rectangle getImageBounds (int index) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
+ //NOT IMPLEMENTED
return new Rectangle (0, 0, 0, 0);
}
+
/**
* Gets the image indent.
*
@@ -245,10 +275,11 @@ public Rectangle getImageBounds (int index) {
* </ul>
*/
public int getImageIndent () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
+ /* Image indent is not supported on GTK */
return 0;
}
+
/**
* Returns the receiver's parent, which must be a <code>Table</code>.
*
@@ -260,10 +291,10 @@ public int getImageIndent () {
* </ul>
*/
public Table getParent () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
return parent;
}
+
/**
* Gets the item text at an index.
* <p>
@@ -284,18 +315,56 @@ public Table getParent () {
* when the operation fails
*/
public String getText (int index) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return "";
+ checkWidget ();
+ if (index == 0) return getText ();
+ int row = parent.indexOf (this);
+ if (row == -1) return null;
+ int clist = parent.handle;
+// int ptr = 0;
+ int ptr = OS.g_malloc (256);
+ int [] address = new int [] {ptr};
+ OS.gtk_clist_get_pixtext (clist, row, index, address, null, null, null);
+ byte [] buffer = new byte [OS.strlen (address [0])];
+ OS.memmove (buffer, address [0], buffer.length);
+ OS.g_free (ptr);
+ return new String (Converter.mbcsToWcs (null, buffer));
}
+
void releaseChild () {
super.releaseChild ();
parent.destroyItem (this);
}
+
void releaseWidget () {
super.releaseWidget ();
parent = null;
}
+
+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public void setBackground (Color color) {
+ checkWidget ();
+ if (color != null && color.isDisposed ()) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+}
+
/**
* Sets the checked state of the receiver.
*
@@ -308,17 +377,39 @@ void releaseWidget () {
*/
public void setChecked (boolean checked) {
checkWidget();
- _setChecked (checked);
-}
-void _setChecked (boolean checked) {
- if ((parent.style & SWT.CHECK) == 0) return; /* needed here because we don't verify in the constructor */
-
int row = parent.indexOf (this);
if (row == -1) return;
int ctable = parent.handle;
byte [] buffer = Converter.wcsToMbcs (null, text, true);
- if (checked) OS.gtk_clist_set_pixtext (ctable, row, 0, buffer, (byte) 2, parent.check, 0);
- else OS.gtk_clist_set_pixtext (ctable, row, 0, buffer, (byte) 2, parent.uncheck, 0);
+ int pixmap = checked ? parent.check : parent.uncheck;
+ byte [] spacing = new byte [1];
+ OS.gtk_clist_get_pixtext(ctable, row, 0, null, spacing, null, null);
+ OS.gtk_clist_set_pixtext (ctable, row, 0, buffer, spacing [0], pixmap, 0);
+}
+
+/**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public void setForeground (Color color){
+ checkWidget ();
+ if (color != null && color.isDisposed ()) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
}
/**
@@ -333,7 +424,9 @@ void _setChecked (boolean checked) {
*/
public void setGrayed (boolean grayed) {
checkWidget();
+ //NOT IMPLEMENTED
}
+
/**
* Sets the receiver's image at a column.
*
@@ -349,46 +442,41 @@ public void setGrayed (boolean grayed) {
* </ul>
*/
public void setImage (int index, Image image) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
-// if (index == 0) {
-// setImage (image);
-// return;
-// }
+ checkWidget ();
+ if (index == 0) {
+ setImage (image);
+ return;
+ }
int row = parent.indexOf (this);
if (row == -1) return;
- int pixmap = 0, mask = 0;
- if (image != null) {
- pixmap = image.pixmap;
- mask = image.mask;
- }
- int ctable = parent.handle;
- if (text != null) {
- byte [] buffer = Converter.wcsToMbcs (null, text, true);
- OS.gtk_clist_set_pixtext (ctable, row, index, buffer, (byte) 2, pixmap, mask);
+ int clist = parent.handle;
+ byte [] buffer = Converter.wcsToMbcs (null, text, true);
+ if (image == null) {
+ OS.gtk_clist_set_text (clist, row, 0, buffer);
} else {
- OS.gtk_clist_set_pixmap (ctable, row, index, pixmap, mask);
+ byte [] spacing = new byte [1];
+ OS.gtk_clist_get_pixtext(clist, row, index, null, spacing, null, null);
+ OS.gtk_clist_set_pixtext(clist, row, index, buffer, spacing [0], image.pixmap, image.mask);
}
}
+
public void setImage (Image image) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
+ if ((parent.style & SWT.CHECK) != 0) return;
int row = parent.indexOf (this);
if (row == -1) return;
super.setImage (image);
- int ctable = parent.handle;
- int pixmap = 0, mask = 0;
- if (image != null) {
- pixmap = image.pixmap;
- mask = image.mask;
- }
- if (text != null) {
- byte [] buffer = Converter.wcsToMbcs (null, text, true);
- OS.gtk_clist_set_pixtext (ctable, row, 0, buffer, (byte) 2, pixmap, mask);
+ int clist = parent.handle;
+ byte [] buffer = Converter.wcsToMbcs (null, text, true);
+ if (image == null) {
+ OS.gtk_clist_set_text (clist, row, 0, buffer);
} else {
- OS.gtk_clist_set_pixmap (ctable, row, 0, pixmap, mask);
+ byte [] spacing = new byte [1];
+ OS.gtk_clist_get_pixtext(clist, row, 0, null, spacing, null, null);
+ OS.gtk_clist_set_pixtext(clist, row, 0, buffer, spacing [0], image.pixmap, image.mask);
}
}
+
/**
* Sets the image for multiple columns in the Table.
*
@@ -404,13 +492,13 @@ public void setImage (Image image) {
* </ul>
*/
public void setImage (Image [] images) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
if (images == null) error (SWT.ERROR_NULL_ARGUMENT);
for (int i=0; i<images.length; i++) {
setImage (i, images [i]);
}
}
+
/**
* Sets the image indent.
*
@@ -423,9 +511,10 @@ public void setImage (Image [] images) {
* </ul>
*/
public void setImageIndent (int indent) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
+ /* Image indent is not supported on GTK */
}
+
/**
* Sets the receiver's text at a column
*
@@ -441,8 +530,7 @@ public void setImageIndent (int indent) {
* </ul>
*/
public void setText (int index, String string) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
if (index == 0) {
setText (string);
@@ -450,29 +538,36 @@ public void setText (int index, String string) {
}
int row = parent.indexOf (this);
if (row == -1) return;
- int ctree = parent.handle;
+ int clist = parent.handle;
byte [] buffer = Converter.wcsToMbcs (null, string, true);
- if (image != null) {
- OS.gtk_clist_set_pixtext(ctree, row, index, buffer, (byte) 2, image.pixmap, image.mask);
+ byte [] spacing = new byte [1];
+ int [] pixmap = new int [1], mask = new int [1];
+ OS.gtk_clist_get_pixtext (clist, row, index, null, spacing, pixmap, mask);
+ if (pixmap [0] == 0) {
+ OS.gtk_clist_set_text (clist, row, index, buffer);
} else {
- OS.gtk_clist_set_text (ctree, row, index, buffer);
+ OS.gtk_clist_set_pixtext (clist, row, index, buffer, spacing [0], pixmap [0], mask [0]);
}
}
+
public void setText (String string) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
int row = parent.indexOf (this);
if (row == -1) return;
super.setText (string);
- int ctree = parent.handle;
+ int clist = parent.handle;
byte [] buffer = Converter.wcsToMbcs (null, string, true);
- if (image != null) {
- OS.gtk_clist_set_pixtext(ctree, row, 0, buffer, (byte) 2, image.pixmap, image.mask);
+ byte [] spacing = new byte [1];
+ int [] pixmap = new int [1], mask = new int [1];
+ OS.gtk_clist_get_pixtext (clist, row, 0, new int [1], spacing, pixmap, mask);
+ if (pixmap [0] == 0) {
+ OS.gtk_clist_set_text (clist, row, 0, buffer);
} else {
- OS.gtk_clist_set_text (ctree, row, 0, buffer);
+ OS.gtk_clist_set_pixtext (clist, row, 0, buffer, spacing [0], pixmap [0], mask [0]);
}
}
+
/**
* Sets the text for multiple columns in the table.
*
@@ -487,94 +582,12 @@ public void setText (String string) {
* </ul>
*/
public void setText (String [] strings) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ checkWidget ();
if (strings == null) error (SWT.ERROR_NULL_ARGUMENT);
for (int i=0; i<strings.length; i++) {
String string = strings [i];
if (string != null) setText (i, string);
}
}
-/**
- * Returns the foreground color that the receiver will use to draw.
- *
- * @return the receiver's foreground color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public Color getForeground () {
- checkWidget ();
- Table parent = getParent();
- return parent.getForeground();
-}
-/**
- * Sets the receiver's foreground color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public void setForeground (Color color){
- checkWidget ();
- if (color != null && color.isDisposed ())
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
-}
-/**
- * Returns the receiver's background color.
- *
- * @return the background color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public Color getBackground () {
- checkWidget ();
- Table parent = getParent();
- return parent.getBackground();
-}
-/**
- * Sets the receiver's background color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public void setBackground (Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ())
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
-}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
index f9169e60e7..d0430ab450 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
@@ -74,44 +74,41 @@ public Text (Composite parent, int style) {
void createHandle (int index) {
state |= HANDLE;
+ int parentHandle = parent.parentingHandle ();
if ((style & SWT.SINGLE) != 0) {
handle = OS.gtk_entry_new ();
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_container_add (parentHandle, handle);
+ OS.gtk_entry_set_editable (handle, (style & SWT.READ_ONLY) == 0);
} else {
+ fixedHandle = OS.gtk_fixed_new ();
+ if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_fixed_set_has_window (fixedHandle, true);
scrolledHandle = OS.gtk_scrolled_window_new (0, 0);
if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
handle = OS.gtk_text_new (0, 0);
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_container_add (parentHandle, fixedHandle);
+ OS.gtk_container_add (fixedHandle, scrolledHandle);
+ OS.gtk_container_add (scrolledHandle, handle);
+ OS.gtk_widget_show (fixedHandle);
+ OS.gtk_widget_show (scrolledHandle);
+ OS.gtk_text_set_editable (handle, (style & SWT.READ_ONLY) == 0);
+ OS.gtk_text_set_word_wrap (handle, (style & SWT.WRAP) != 0 ? 1 : 0);
+ int hsp = (style & SWT.H_SCROLL) == 0 ? OS.GTK_POLICY_NEVER : OS.GTK_POLICY_AUTOMATIC;
+ int vsp = (style & SWT.V_SCROLL) == 0 ? OS.GTK_POLICY_NEVER : OS.GTK_POLICY_AUTOMATIC;
+ OS.gtk_scrolled_window_set_policy (scrolledHandle, hsp, vsp);
}
-}
-
-void setHandleStyle() {
- /*OS.gtk_editable_set_editable (handle, (style & SWT.READ_ONLY) == 0);
- if ((style & SWT.SINGLE) == 0)
- OS.gtk_text_set_word_wrap (handle, (style & SWT.WRAP) != 0 ? 1 : 0);
- if (scrolledHandle!=0) setScrollingPolicy();
- // When 2.0 arrives, we'll be able to set the flat appearance*/
-
-}
-
-void configure() {
- parent._connectChild(topHandle());
- if (scrolledHandle != 0) OS.gtk_container_add (scrolledHandle, handle);
-}
-
-void showHandle() {
- if (scrolledHandle != 0) OS.gtk_widget_show (scrolledHandle);
OS.gtk_widget_show (handle);
- OS.gtk_widget_realize (handle);
}
void hookEvents () {
//TO DO - get rid of enter/exit for mouse crossing border
-/* super.hookEvents();
+ super.hookEvents();
signal_connect_after (handle, "changed", SWT.Modify, 2);
signal_connect (handle, "insert-text", SWT.Verify, 5);
signal_connect (handle, "delete-text", SWT.Verify, 4);
- signal_connect (handle, "activate", SWT.Selection, 2);*/
+ signal_connect (handle, "activate", SWT.Selection, 2);
}
/**
@@ -215,7 +212,7 @@ public void addVerifyListener (VerifyListener listener) {
*/
public void append (String string) {
checkWidget ();
- /*if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
byte [] buffer = Converter.wcsToMbcs (null, string);
if ((style & SWT.SINGLE) != 0) {
OS.gtk_entry_append_text(handle, buffer);
@@ -224,7 +221,7 @@ public void append (String string) {
int [] position = new int [] {length};
OS.gtk_editable_insert_text (handle, buffer, buffer.length, position);
OS.gtk_editable_set_position (handle, position [0]);
- }*/
+ }
}
/**
@@ -237,9 +234,9 @@ public void append (String string) {
*/
public void clearSelection () {
checkWidget ();
- /*int position = OS.gtk_editable_get_position (handle);
+ int position = OS.gtk_editable_get_position (handle);
OS.gtk_editable_delete_selection(handle);
- OS.gtk_editable_set_position (handle, position);*/
+ OS.gtk_editable_set_position (handle, position);
}
/**
@@ -255,14 +252,7 @@ public void clearSelection () {
*/
public void copy () {
checkWidget ();
- /*byte [] clipboard = Converter.wcsToMbcs (null, "CLIPBOARD", true);
- OS.gtk_selection_owner_set(handle, OS.gdk_atom_intern(clipboard, 0), 0);
- GtkEditable widget = new GtkEditable ();
- OS.memmove(widget, handle, GtkEditable.sizeof);
- int start = Math.min(widget.selection_start_pos, widget.selection_end_pos);
- int end = Math.max(widget.selection_start_pos, widget.selection_end_pos);
- widget.clipboard_text = OS.gtk_editable_get_chars(handle, start, end);
- OS.memmove (handle, widget, GtkEditable.sizeof);*/
+ OS.gtk_editable_copy_clipboard(handle);
}
/**
* Cuts the selected text.
@@ -281,15 +271,7 @@ public void copy () {
*/
public void cut () {
checkWidget ();
- /*byte [] clipboard = Converter.wcsToMbcs (null, "CLIPBOARD", true);
- OS.gtk_selection_owner_set(handle, OS.gdk_atom_intern(clipboard, 0), 0);
- GtkEditable widget = new GtkEditable ();
- OS.memmove (widget, handle, GtkEditable.sizeof);
- int start = Math.min(widget.selection_start_pos, widget.selection_end_pos);
- int end = Math.max(widget.selection_start_pos, widget.selection_end_pos);
- widget.clipboard_text = OS.gtk_editable_get_chars(handle, start, end);
- OS.memmove (handle, widget, GtkEditable.sizeof);
- OS.gtk_editable_delete_text(handle, start, end);*/
+ OS.gtk_editable_cut_clipboard(handle);
}
/**
@@ -310,10 +292,9 @@ public void cut () {
*/
public int getCaretLineNumber () {
checkWidget ();
- /*int addr_index=getCaretPosition();
+ int addr_index=getCaretPosition();
String tmpString= new String(getText(0,addr_index));
- return getLineNumberInString(tmpString,'\n');*/
- return 0;
+ return getLineNumberInString(tmpString,'\n');
}
/**
@@ -352,8 +333,7 @@ public Point getCaretLocation () {
*/
public int getCaretPosition () {
checkWidget ();
-// return OS.gtk_editable_get_position (handle);
-return 0;
+ return OS.gtk_editable_get_position (handle);
}
@@ -369,14 +349,14 @@ return 0;
*/
public int getCharCount () {
checkWidget ();
- /*if ((style & SWT.SINGLE) != 0) {
- int address = OS.gtk_editable_get_chars (handle, 0, -1);
- int length = OS.strlen (address);
- OS.g_free (address);
- return length;
+ if ((style & SWT.SINGLE) != 0) {
+ int address = OS.gtk_entry_get_text (handle);
+ /*
+ * FIXME - confusing size and length
+ */
+ return OS.strlen (address);
}
- return OS.gtk_text_get_length (handle);*/
- return 0;
+ return OS.gtk_text_get_length (handle);
}
/**
@@ -438,10 +418,7 @@ public char getEchoChar () {
*/
public boolean getEditable () {
checkWidget ();
- /*GtkEditable widget = new GtkEditable ();
- OS.memmove (widget, handle, GtkEditable.sizeof);
- return widget.editable!=0;*/
- return true;
+ return OS.gtk_editable_get_editable(handle);
}
/**
@@ -456,8 +433,7 @@ public boolean getEditable () {
*/
public int getLineCount () {
checkWidget ();
- /*return getLineNumberInString(new String(getText()),'\n') + 1;*/
- return 0;
+ return getLineNumberInString(new String(getText()),'\n') + 1;
}
/**
* Gets the height of a line.
@@ -499,8 +475,10 @@ public Point getSelection () {
/*GtkEditable widget = new GtkEditable ();
OS.memmove (widget, handle, GtkEditable.sizeof);
return new Point (widget.selection_start_pos, widget.selection_end_pos);*/
- return new Point(0,0);
+ return new Point (OS.gtk_editable_get_selection_start(handle),
+ OS.gtk_editable_get_selection_end(handle));
}
+
/**
* Gets the number of selected characters.
*
@@ -513,12 +491,8 @@ public Point getSelection () {
*/
public int getSelectionCount () {
checkWidget ();
- /*GtkEditable widget = new GtkEditable ();
- OS.memmove (widget, handle, GtkEditable.sizeof);
- int start = Math.min(widget.selection_start_pos, widget.selection_end_pos);
- int end = Math.max(widget.selection_start_pos, widget.selection_end_pos);
- return end - start;*/
- return 0;
+ Point sel = getSelection();
+ return Math.abs(sel.y - sel.x);
}
/**
* Gets the selected text.
@@ -585,12 +559,14 @@ public int getTabs () {
public String getText () {
checkWidget ();
if ((style & SWT.SINGLE) != 0) {
- /* FIXME - MIXING LENGTH WITH SIZE! */
+ /*
+ * The GTK documentation explicitly states
+ * that this address should not be freed.
+ */
int address = OS.gtk_entry_get_text (handle);
int length = OS.strlen (address);
byte [] buffer1 = new byte [length];
OS.memmove (buffer1, address, length);
- OS.g_free (address);
char [] buffer2 = Converter.mbcsToWcs (null, buffer1);
return new String (buffer2, 0, buffer2.length);
}
@@ -662,8 +638,8 @@ public int getTextLimit () {
*/
public int getTopIndex () {
checkWidget ();
- /*if ((style & SWT.SINGLE) != 0) return 0;
- GtkText widget = new GtkText ();
+ if ((style & SWT.SINGLE) != 0) return 0;
+ /*GtkText widget = new GtkText ();
OS.memmove (widget, handle, GtkText.sizeof);
int topCharIndex=widget.first_line_start_index;
return (getLineNumberInString(getText(0,topCharIndex), '\n'));
@@ -745,11 +721,7 @@ public void insert (String string) {
*/
public void paste () {
checkWidget ();
- /*byte [] clipboard = Converter.wcsToMbcs (null, "CLIPBOARD", true);
- byte [] compound = Converter.wcsToMbcs (null, "COMPOUND_TEXT", true);
- int clipboard_atom = OS.gdk_atom_intern (clipboard, 0);
- int compound_atom = OS.gdk_atom_intern (compound, 0);
- OS.gtk_selection_convert(handle, clipboard_atom, compound_atom, 0);*/
+ OS.gtk_editable_paste_clipboard(handle);
}
int processModify (int arg0, int arg1, int int2) {
@@ -934,9 +906,9 @@ public void setDoubleClickEnabled (boolean doubleClick) {
*/
public void setEchoChar (char echo) {
checkWidget ();
- /*if ((style & SWT.SINGLE) != 0) {
+ if ((style & SWT.SINGLE) != 0) {
OS.gtk_entry_set_visibility (handle, visibility = echo == '\0');
- }*/
+ }
}
/**
@@ -982,7 +954,7 @@ public void setEditable (boolean editable) {
*/
public void setSelection (int start) {
checkWidget ();
- /*OS.gtk_editable_set_position (handle, start);*/
+ OS.gtk_editable_set_position (handle, start);
}
/**
@@ -1014,8 +986,8 @@ public void setSelection (int start) {
*/
public void setSelection (int start, int end) {
checkWidget ();
- /*OS.gtk_editable_set_position (handle, start);
- OS.gtk_editable_select_region (handle, start, end);*/
+ OS.gtk_editable_set_position (handle, start);
+ OS.gtk_editable_select_region (handle, start, end);
}
/**
@@ -1047,8 +1019,8 @@ public void setSelection (int start, int end) {
public void setSelection (Point selection) {
checkWidget ();
if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
- /*OS.gtk_editable_set_position (handle, selection.x);
- OS.gtk_editable_select_region (handle, selection.x, selection.y);*/
+ OS.gtk_editable_set_position (handle, selection.x);
+ OS.gtk_editable_select_region (handle, selection.x, selection.y);
}
/**
@@ -1089,12 +1061,12 @@ public void setTabs (int tabs) {
*/
public void setText (String string) {
checkWidget ();
- /*if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
OS.gtk_editable_delete_text (handle, 0, -1);
int [] position = new int [1];
byte [] buffer = Converter.wcsToMbcs (null, string);
OS.gtk_editable_insert_text (handle, buffer, buffer.length, position);
- OS.gtk_editable_set_position (handle, 0);*/
+ OS.gtk_editable_set_position (handle, 0);
}
/**
@@ -1113,11 +1085,11 @@ public void setText (String string) {
*/
public void setTextLimit (int limit) {
checkWidget ();
- /*if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
+ if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
if ((style & SWT.SINGLE) != 0) {
textLimit = (short) limit;
OS.gtk_entry_set_max_length (handle, (short) limit);
- }*/
+ }
}
/**
@@ -1134,7 +1106,7 @@ public void setTextLimit (int limit) {
*/
public void setTopIndex (int index) {
checkWidget ();
- /*if ((style & SWT.SINGLE) != 0) return;
+ if ((style & SWT.SINGLE) != 0) return;
if (index > getLineCount()) return;
int adjustmentHandle = OS.gtk_scrolled_window_get_vadjustment(scrolledHandle);
GtkAdjustment adjustment = new GtkAdjustment(adjustmentHandle);
@@ -1153,12 +1125,12 @@ public void setTopIndex (int index) {
verticalBar.setSelection(adjust+lineheight);
OS.gtk_adjustment_value_changed(verticalBar.handle);
topindex=getTopIndex();
- } */
+ }
}
void setWrap (boolean wrap) {
checkWidget ();
- /*OS.gtk_text_set_word_wrap(handle, wrap ? 1 : 0);*/
+ OS.gtk_text_set_word_wrap(handle, wrap ? 1 : 0);
}
/**
@@ -1209,14 +1181,13 @@ public void showSelection () {
}
String verifyText (String string, int start, int end) {
- /*Event event = new Event ();
+ Event event = new Event ();
event.text = string;
event.start = start;
event.end = end;
sendEvent (SWT.Verify, event);
if (!event.doit) return null;
- return event.text;*/
- return "";
+ return event.text;
}
int getLineNumberInString( String string,char delimiter) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
index 813963ed12..49b2a09e34 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
@@ -63,71 +63,31 @@ public class ToolBar extends Composite {
*/
public ToolBar (Composite parent, int style) {
super (parent, checkStyle (style));
+ /*
+ * Ensure that either of HORIZONTAL or VERTICAL is set.
+ * NOTE: HORIZONTAL and VERTICAL have the same values
+ * as H_SCROLL and V_SCROLL so it is necessary to first
+ * clear these bits to avoid scroll bars and then reset
+ * the bits using the original style supplied by the
+ * programmer.
+ */
+ this.style = checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+ int orientation = (style & SWT.VERTICAL) != 0 ? OS.GTK_ORIENTATION_VERTICAL : OS.GTK_ORIENTATION_HORIZONTAL;
+ OS.gtk_toolbar_set_orientation (handle, orientation);
}
-/*
- * === Handle code ===
- */
void createHandle (int index) {
state |= HANDLE;
-
- boxHandle = OS.gtk_event_box_new();
- if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES);
-
- fixedHandle = OS.eclipse_fixed_new();
- if (fixedHandle == 0) SWT.error (SWT.ERROR_NO_HANDLES);
-
- int orientation = ((style&SWT.VERTICAL)!=0)?
- OS.GTK_ORIENTATION_VERTICAL : OS.GTK_ORIENTATION_HORIZONTAL;
+ fixedHandle = OS.gtk_fixed_new ();
+ if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_fixed_set_has_window (fixedHandle, true);
handle = OS.gtk_toolbar_new ();
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- OS.gtk_toolbar_set_orientation(handle, orientation);
-}
-
-void setHandleStyle() {
-/* int relief = ((style&SWT.FLAT)!=0)? OS.GTK_RELIEF_NONE : OS.GTK_RELIEF_NORMAL;
- OS.gtk_toolbar_set_button_relief(handle, relief);*/
-}
-
-void configure() {
- parent._connectChild(boxHandle);
- OS.gtk_container_add(boxHandle, fixedHandle);
- OS.gtk_container_add(fixedHandle, handle);
-}
-
-void showHandle() {
- OS.gtk_widget_show (boxHandle);
+ int parentHandle = parent.parentingHandle ();
+ OS.gtk_container_add (parentHandle, fixedHandle);
+ OS.gtk_container_add (fixedHandle, handle);
OS.gtk_widget_show (fixedHandle);
OS.gtk_widget_show (handle);
- OS.gtk_widget_realize (handle);
-}
-
-void register() {
- super.register ();
-}
-
-void deregister() {
- super.deregister ();
-}
-
-void releaseHandle () {
- super.releaseHandle ();
-}
-
-int topHandle() { return boxHandle; }
-int parentingHandle() { return fixedHandle; }
-boolean isMyHandle(int h) {
- return super.isMyHandle(h);
-}
-
-
-/*
- * === GEOMETRY ===
- */
-
-void _setSize (int width, int height) {
- OS.eclipse_fixed_set_size(parent.parentingHandle(), boxHandle, width, height);
- OS.eclipse_fixed_set_size(fixedHandle, handle, width, height);
}
public Point computeSize (int wHint, int hHint, boolean changed) {
@@ -136,7 +96,6 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
return computeNativeSize(handle, wHint, hHint, changed);
}
-
/**
* Returns the item at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
@@ -157,8 +116,6 @@ public ToolItem getItem (int index) {
return getItems()[index];
}
-
-
/**
* Returns the item at the given point in the receiver
* or null if no such item exists. The point is in the
@@ -192,7 +149,7 @@ public ToolItem getItem (Point point) {
public int getItemCount () {
checkWidget();
int list = OS.gtk_container_children (handle);
- return OS.g_list_length (list);
+ return list != 0 ? OS.g_list_length (list) : 0;
}
/**
@@ -213,14 +170,13 @@ public int getItemCount () {
*/
public ToolItem [] getItems () {
checkWidget();
- int count = 0;
int list = OS.gtk_container_children (handle);
- int length = OS.g_list_length (list);
- ToolItem [] result = new ToolItem [length];
- for (int i=0; i<length; i++) {
+ int count = list != 0 ? OS.g_list_length (list) : 0;
+ ToolItem [] result = new ToolItem [count];
+ for (int i=0; i<count; i++) {
int data = OS.g_list_nth_data (list, i);
Widget widget = WidgetTable.get (data);
- result [count++] = (ToolItem) widget;
+ result [i] = (ToolItem) widget;
}
return result;
}
@@ -243,13 +199,6 @@ public int getRowCount () {
return 1; /* On GTK, toolbars never wrap */
}
-Control _childFromHandle(int h) {
- Widget child = WidgetTable.get(h);
- if (child==null) return null;
- if (child instanceof ToolItem) return null; // ToolItems are not our children
- return (Control)child;
-}
-
/**
* Searches the receiver's list starting at the first item
* (index 0) until an item is found that is equal to the
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
index fdb41d18fe..ca396a85cf 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
@@ -192,9 +192,6 @@ void createHandle (int index) {
}
}
-/* Already done in createHandle() */
-void configure() {}
-void showHandle() {}
void register() {
super.register ();
@@ -206,10 +203,9 @@ void deregister() {
}
int topHandle() {
- return (boxHandle==0)? handle : boxHandle;
+ return boxHandle == 0 ? handle : boxHandle;
}
-
/**
* Returns a rectangle describing the receiver's size and location
* relative to its parent.
@@ -223,9 +219,11 @@ int topHandle() {
*/
public Rectangle getBounds () {
checkWidget();
- /*GtkWidget widget = new GtkWidget (handle);
- return new Rectangle (widget.alloc_x, widget.alloc_y, widget.alloc_width, widget.alloc_height);*/
- return new Rectangle(2,2, 15,15);
+ int x = OS.GTK_WIDGET_X (handle);
+ int y = OS.GTK_WIDGET_Y (handle);
+ int width = OS.GTK_WIDGET_WIDTH (handle);
+ int height = OS.GTK_WIDGET_HEIGHT (handle);
+ return new Rectangle (x, y, width, height);
}
/**
@@ -375,6 +373,7 @@ public int getWidth () {
return 15;
}
void hookEvents () {
+ super.hookEvents ();
if ((style & SWT.SEPARATOR) != 0) return;
signal_connect(handle, "clicked", SWT.Selection, 2);
signal_connect(handle, "enter-notify-event", SWT.MouseEnter, 3);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
index 8ce2b87b52..4ae2a3ee4a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
@@ -27,8 +27,11 @@ import org.eclipse.swt.events.*;
public class Tracker extends Widget {
Composite parent;
Display display;
+ int cursor, lastCursor;
boolean tracking, stippled;
Rectangle [] rectangles = new Rectangle [0];
+ int xWindow;
+ int ptrGrabResult;
/**
@@ -60,9 +63,10 @@ public class Tracker extends Widget {
* @see Widget#getStyle
*/
public Tracker (Composite parent, int style) {
- super (parent, style);
+ super (parent, checkStyle(style));
this.parent = parent;
display = parent.getDisplay ();
+ xWindow = calculateWindow();
}
/**
@@ -100,12 +104,12 @@ public Tracker (Display display, int style) {
if (!display.isValidThread ()) {
error (SWT.ERROR_THREAD_INVALID_ACCESS);
}
- this.style = style;
+ this.style = checkStyle (style);
this.display = display;
+ xWindow = calculateWindow();
}
-
/*
* === ADD / REMOVE LISTENERS ===
*/
@@ -260,7 +264,6 @@ public void close () {
*/
public boolean open () {
checkWidget();
- int xWindow = calculateWindow();
boolean cancelled=false;
tracking = true;
drawRectangles ();
@@ -270,13 +273,18 @@ public boolean open () {
int[] oldX = new int[1];
int[] oldY = new int[1];
OS.gdk_window_get_pointer(xWindow, oldX,oldY, 0);
+ grab();
+ /*
+ * Tracker behaves like a Dialog with its own OS event loop.
+ */
while (tracking) {
if (parent != null && parent.isDisposed ()) break;
int eventType = waitEvent();
switch (eventType) {
case OS.GDK_BUTTON_RELEASE:
case OS.GDK_MOTION_NOTIFY:
+ if (cursor != lastCursor) { ungrab(); grab(); }
OS.gdk_window_get_pointer(xWindow, newX,newY, 0);
if (oldX [0] != newX [0] || oldY [0] != newY [0]) {
drawRectangles ();
@@ -308,15 +316,15 @@ public boolean open () {
break;
} // switch
} // while
- drawRectangles(); // clean up our mess
+ drawRectangles();
tracking = false;
+ ungrab();
return !cancelled;
}
private void drawRectangles () {
- int xWindow = calculateWindow();
if (parent != null) {
if (parent.isDisposed ()) return;
parent.getShell ().update ();
@@ -374,15 +382,35 @@ private int waitEvent() {
*/
private int calculateWindow() {
int answer;
- if (parent == null) {
- answer = OS.GDK_ROOT_PARENT();
- } else {
- answer = /*parent._gdkWindow();*/ 0;
- }
+ if (parent == null) answer = OS.GDK_ROOT_PARENT();
+ else answer = OS.GTK_WIDGET_WINDOW(parent.paintHandle());
if (answer==0) error(SWT.ERROR_UNSPECIFIED);
return answer;
}
public void setCursor (Cursor value) {
+ checkWidget ();
+ cursor = 0;
+ if (value != null) cursor = value.handle;
+}
+void grab() {
+ ptrGrabResult = OS.gdk_pointer_grab(xWindow,
+ false,
+ OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_RELEASE_MASK,
+ xWindow,
+ cursor,
+ OS.GDK_CURRENT_TIME());
+ lastCursor = cursor;
+}
+void ungrab() {
+ if (ptrGrabResult == OS.GDK_GRAB_SUCCESS)
+ OS.gdk_pointer_ungrab(OS.GDK_CURRENT_TIME());
+
+}
+static int checkStyle (int style) {
+ if ((style & (SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN)) == 0) {
+ style |= SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN;
+ }
+ return style;
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
index 2790cd8ada..7cfdb44ce9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
@@ -89,11 +89,6 @@ static int checkStyle (int style) {
return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
}
-void _setSize(int width, int height) {
- OS.eclipse_fixed_set_size(parent.parentingHandle(), topHandle(), width, height);
- OS.eclipse_fixed_set_size(fixedHandle, scrolledHandle, width, height);
-}
-
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver's selection changes, by sending
@@ -163,24 +158,35 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
void createHandle (int index) {
state |= HANDLE;
-
- boxHandle = OS.gtk_event_box_new();
- if (boxHandle == 0) SWT.error (SWT.ERROR_NO_HANDLES);
-
- fixedHandle = OS.eclipse_fixed_new ();
- if (fixedHandle == 0) SWT.error (SWT.ERROR_NO_HANDLES);
-
- scrolledHandle = OS.gtk_scrolled_window_new(0,0);
+ fixedHandle = OS.gtk_fixed_new ();
+ if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.gtk_fixed_set_has_window (fixedHandle, true);
+ scrolledHandle = OS.gtk_scrolled_window_new (0, 0);
if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
-
handle = OS.gtk_ctree_new (1, 0);
if (handle == 0) SWT.error (SWT.ERROR_NO_HANDLES);
-}
-void configure() {
- parent._connectChild(topHandle());
- OS.gtk_container_add (boxHandle, fixedHandle);
+ int parentHandle = parent.parentingHandle ();
+ OS.gtk_container_add (parentHandle, fixedHandle);
OS.gtk_container_add (fixedHandle, scrolledHandle);
OS.gtk_container_add (scrolledHandle, handle);
+ OS.gtk_widget_show (fixedHandle);
+ OS.gtk_widget_show (scrolledHandle);
+ OS.gtk_widget_show (handle);
+
+ int mode = (style & SWT.MULTI) != 0 ? OS.GTK_SELECTION_EXTENDED : OS.GTK_SELECTION_BROWSE;
+ OS.gtk_clist_set_selection_mode (handle, mode);
+
+ //BUG - need realize to get scrollbars
+ OS.gtk_widget_realize (handle);
+ int hsp = (style & SWT.H_SCROLL) == 0 ? OS.GTK_POLICY_NEVER : OS.GTK_POLICY_ALWAYS;
+ int vsp = (style & SWT.V_SCROLL) == 0 ? OS.GTK_POLICY_NEVER : OS.GTK_POLICY_ALWAYS;
+ OS.gtk_scrolled_window_set_policy (scrolledHandle, hsp, vsp);
+
+ if ((style & SWT.CHECK) != 0) {
+ OS.gtk_widget_realize (handle);
+ uncheck = createCheckPixmap (false);
+ check = createCheckPixmap (true);
+ }
}
void hookEvents () {
@@ -192,50 +198,47 @@ void hookEvents () {
signal_connect (handle, "tree_collapse", SWT.Collapse, 3);
}
-int topHandle() { return boxHandle; }
-int parentingHandle() { return fixedHandle; }
-
int createCheckPixmap(boolean checked) {
- /*
- * The box will occupy the whole item width.
- */
- GtkCList clist = new GtkCList (handle);
- int check_height = clist.row_height-1;
- int check_width = check_height;
-
- GdkVisual visual = new GdkVisual(OS.gdk_visual_get_system());
- int pixmap = OS.gdk_pixmap_new(0, check_width, check_height, visual.depth);
-
- int gc = OS.gdk_gc_new(pixmap);
-
- GdkColor fgcolor = new GdkColor();
- fgcolor.pixel = 0xFFFFFFFF;
- fgcolor.red = (short) 0xFFFF;
- fgcolor.green = (short) 0xFFFF;
- fgcolor.blue = (short) 0xFFFF;
- OS.gdk_gc_set_foreground(gc, fgcolor);
- OS.gdk_draw_rectangle(pixmap, gc, 1, 0,0, check_width,check_height);
-
- fgcolor = new GdkColor();
- fgcolor.pixel = 0;
- fgcolor.red = (short) 0;
- fgcolor.green = (short) 0;
- fgcolor.blue = (short) 0;
- OS.gdk_gc_set_foreground(gc, fgcolor);
-
- OS.gdk_draw_line(pixmap, gc, 0,0, 0,check_height-1);
- OS.gdk_draw_line(pixmap, gc, 0,check_height-1, check_width-1,check_height-1);
- OS.gdk_draw_line(pixmap, gc, check_width-1,check_height-1, check_width-1,0);
- OS.gdk_draw_line(pixmap, gc, check_width-1,0, 0,0);
-
- /* now the cross check */
- if (checked) {
- OS.gdk_draw_line(pixmap, gc, 0,0, check_width-1,check_height-1);
- OS.gdk_draw_line(pixmap, gc, 0,check_height-1, check_width-1,0);
- }
-
- OS.g_object_unref(gc);
- return pixmap;
+ /*
+ * The box will occupy the whole item width.
+ */
+ GtkCList clist = new GtkCList (handle);
+ int check_height = clist.row_height-1;
+ int check_width = check_height;
+
+ GdkVisual visual = new GdkVisual(OS.gdk_visual_get_system());
+ int pixmap = OS.gdk_pixmap_new(0, check_width, check_height, visual.depth);
+
+ int gc = OS.gdk_gc_new(pixmap);
+
+ GdkColor fgcolor = new GdkColor();
+ fgcolor.pixel = 0xFFFFFFFF;
+ fgcolor.red = (short) 0xFFFF;
+ fgcolor.green = (short) 0xFFFF;
+ fgcolor.blue = (short) 0xFFFF;
+ OS.gdk_gc_set_foreground(gc, fgcolor);
+ OS.gdk_draw_rectangle(pixmap, gc, 1, 0,0, check_width,check_height);
+
+ fgcolor = new GdkColor();
+ fgcolor.pixel = 0;
+ fgcolor.red = (short) 0;
+ fgcolor.green = (short) 0;
+ fgcolor.blue = (short) 0;
+ OS.gdk_gc_set_foreground(gc, fgcolor);
+
+ OS.gdk_draw_line(pixmap, gc, 0,0, 0,check_height-1);
+ OS.gdk_draw_line(pixmap, gc, 0,check_height-1, check_width-1,check_height-1);
+ OS.gdk_draw_line(pixmap, gc, check_width-1,check_height-1, check_width-1,0);
+ OS.gdk_draw_line(pixmap, gc, check_width-1,0, 0,0);
+
+ /* now the cross check */
+ if (checked) {
+ OS.gdk_draw_line(pixmap, gc, 0,0, check_width-1,check_height-1);
+ OS.gdk_draw_line(pixmap, gc, 0,check_height-1, check_width-1,0);
+ }
+
+ OS.g_object_unref(gc);
+ return pixmap;
}
void createItem (TreeItem item, int node, int index) {
@@ -255,17 +258,17 @@ void createItem (TreeItem item, int node, int index) {
* selectionMode field just for the insertion. Do not use the policy
* changing API because this will cause a selection callback.
*/
-// GtkCTree ctree = new GtkCTree ();
-// OS.memmove (ctree, handle, GtkCTree.sizeof);
-// int selection_mode = ctree.selection_mode;
-// ctree.selection_mode = OS.GTK_SELECTION_MULTIPLE;
-// OS.memmove (handle, ctree, GtkCTree.sizeof);
- int [] sm = new int [1];
- OS.memmove (sm, handle+148, 1);
- int selectionMode = sm[0];
- sm [0] = OS.GTK_SELECTION_MULTIPLE;
- OS.memmove (handle+148, sm, 1);
-// FIXME
+//// GtkCTree ctree = new GtkCTree ();
+//// OS.memmove (ctree, handle, GtkCTree.sizeof);
+//// int selection_mode = ctree.selection_mode;
+//// ctree.selection_mode = OS.GTK_SELECTION_MULTIPLE;
+//// OS.memmove (handle, ctree, GtkCTree.sizeof);
+// int [] sm = new int [1];
+// OS.memmove (sm, handle+148, 1);
+// int selectionMode = sm[0];
+// sm [0] = OS.GTK_SELECTION_MULTIPLE;
+// OS.memmove (handle+148, sm, 1);
+//// FIXME
int sibling = index == -1 ? 0 : findSibling (node, index);
OS.gtk_signal_handler_block_by_data (handle, SWT.Selection);
item.handle = OS.gtk_ctree_insert_node (handle, node, sibling, null, (byte) 2, uncheck, 0, uncheck, 0, false, false);
@@ -276,8 +279,8 @@ void createItem (TreeItem item, int node, int index) {
// OS.memmove (ctree, handle, GtkCTree.sizeof);
// ctree.selection_mode = selection_mode;
// OS.memmove (handle, ctree, GtkCTree.sizeof);
- sm [0] = selectionMode;
- OS.memmove (handle+148, sm, 1);
+// sm [0] = selectionMode;
+// OS.memmove (handle+148, sm, 1);
items [id] = item;
}
@@ -554,6 +557,12 @@ int GtkCTreeDispose (int ctree, int node, int data) {
return 0;
}
+int paintWindow () {
+ OS.gtk_widget_realize (handle);
+ GtkCList clist = new GtkCList (handle);
+ return clist.clist_window;
+}
+
int processCollapse (int int0, int int1, int int2) {
int index = OS.gtk_ctree_node_get_row_data (handle, int0) - 1;
Event event = new Event ();
@@ -589,10 +598,9 @@ int processExpand (int int0, int int1, int int2) {
int processMouseDown (int callData, int arg1, int int2) {
doubleSelected = false;
int result = super.processMouseDown (callData, arg1, int2);
-/* if ((style & SWT.MULTI) != 0) selected = true;
- double[] px = new double[1];
- double[] py = new double[1];
- OS.gdk_event_get_coords(callData, px, py);
+ if ((style & SWT.MULTI) != 0) selected = true;
+ double [] px = new double [1], py = new double [1];
+ OS.gdk_event_get_coords (callData, px, py);
int x = (int)(px[0]), y = (int)(py[0]);
if ((style & SWT.CHECK) != 0) {
if (!OS.gtk_ctree_is_hot_spot (handle, x, y)) {
@@ -602,11 +610,14 @@ int processMouseDown (int callData, int arg1, int int2) {
int node = OS.gtk_ctree_node_nth (handle, row [0]);
int crow = OS.g_list_nth_data (node, 0);
GtkCTreeRow row_data = new GtkCTreeRow (crow);
- GtkCTree ctree = new GtkCTree(handle);
- int nX = ctree.hoffset + ctree.tree_indent * row_data.level - 2;
- int nY = ctree.voffset + (ctree.row_height + 1) * row [0] + 2;
- int [] unused = new int [1], check_width = new int [1], check_height = new int [1];
- OS.gdk_window_get_geometry (check, unused, unused, check_width, check_height, unused);
+ GtkCTree ctree = new GtkCTree (handle);
+ GtkCList clist = new GtkCList (handle);
+ int nX = clist.hoffset + ctree.tree_indent * row_data.level - 2;
+ int nY = clist.voffset + (clist.row_height + 1) * row [0] + 2;
+// int [] unused = new int [1], check_width = new int [1], check_height = new int [1];
+// OS.gdk_window_get_geometry (check, unused, unused, check_width, check_height, unused);
+ int [] check_width = new int [1], check_height = new int [1];
+ OS.gdk_drawable_get_size (check, check_width, check_height);
if (nX <= x && x <= nX + check_width [0]) {
if (nY <= y && y <= nY + check_height [0]) {
byte [] spacing = new byte [1];
@@ -626,14 +637,13 @@ int processMouseDown (int callData, int arg1, int int2) {
}
}
}
- GdkEvent gdkEvent = new GdkEvent(callData);
- if (gdkEvent.type == OS.GDK_2BUTTON_PRESS) {
+ if (OS.GDK_EVENT_TYPE (callData) == OS.GDK_2BUTTON_PRESS) {
if (!OS.gtk_ctree_is_hot_spot (handle, x, y)) {
int [] row = new int [1], column = new int [1];
int code = OS.gtk_clist_get_selection_info (handle, x, y, row, column);
if (code != 0) doubleSelected = true;
}
- }*/
+ }
return result;
}
@@ -651,8 +661,7 @@ int processMouseUp (int callData, int arg1, int int2) {
* that caused the select signal is not included when the select
* signal is issued.
*/
- double[] px = new double[1];
- double[] py = new double[1];
+ double[] px = new double [1], py = new double [1];
OS.gdk_event_get_coords(callData, px, py);
int x = (int)(px[0]), y = (int)(py[0]);
if (!OS.gtk_ctree_is_hot_spot (handle, x, y)) {
@@ -820,11 +829,6 @@ public void selectAll () {
OS.gtk_signal_handler_unblock_by_data (handle, SWT.Selection);
}
-void setHandleStyle () {
- int mode = (style & SWT.MULTI) != 0 ? OS.GTK_SELECTION_EXTENDED : OS.GTK_SELECTION_BROWSE;
- OS.gtk_clist_set_selection_mode (handle, mode);
-}
-
/**
* Sets the receiver's selection to be the given array of items.
* The current selected is first cleared, then the new items are
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
index 51e69b8f53..a2d68063fc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
@@ -26,7 +26,6 @@ import org.eclipse.swt.graphics.*;
*/
public class TreeItem extends Item {
Tree parent;
- int index;
/**
* Constructs a new instance of this class given its parent
@@ -138,6 +137,25 @@ public TreeItem (TreeItem parentItem, int style) {
parent.createItem (this, parentItem.handle, -1);
}
+/**
+ * Returns the receiver's background color.
+ *
+ * @return the background color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public Color getBackground () {
+ checkWidget ();
+ Tree parent = getParent();
+ return parent.getBackground();
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Tree</code> or a <code>TreeItem</code>),
@@ -285,6 +303,25 @@ public boolean getExpanded () {
return buffer [0];
}
+/**
+ * Returns the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public Color getForeground () {
+ checkWidget ();
+ Tree parent = getParent();
+ return parent.getForeground();
+}
+
/**
* Returns <code>true</code> if the receiver is grayed,
* and false otherwise. When the parent does not have
@@ -387,6 +424,31 @@ void releaseWidget () {
parent = null;
}
+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public void setBackground (Color color) {
+ checkWidget ();
+ if (color != null && color.isDisposed ()) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+}
+
/**
* Sets the checked state of the receiver.
* <p>
@@ -453,6 +515,31 @@ public void setExpanded (boolean expanded) {
}
}
+/**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ *
+ */
+public void setForeground (Color color){
+ checkWidget ();
+ if (color != null && color.isDisposed ()) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+}
+
public void setImage (Image image) {
checkWidget();
if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
@@ -488,86 +575,5 @@ public void setText (String string) {
OS.gtk_ctree_get_node_info (ctree, handle, null, spacing, pixmap_closed, mask_closed, pixmap_opened, mask_opened, is_leaf, expanded);
OS.gtk_ctree_set_node_info (ctree, handle, buffer, spacing [0], pixmap_closed [0], mask_closed [0], pixmap_opened [0], mask_opened [0], is_leaf [0], expanded [0]);
}
-/**
- * Returns the foreground color that the receiver will use to draw.
- *
- * @return the receiver's foreground color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public Color getForeground () {
- checkWidget ();
- Tree parent = getParent();
- return parent.getForeground();
-}
-/**
- * Sets the receiver's foreground color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public void setForeground (Color color){
- checkWidget ();
- if (color != null && color.isDisposed ())
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
-}
-/**
- * Returns the receiver's background color.
- *
- * @return the background color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public Color getBackground () {
- checkWidget ();
- Tree parent = getParent();
- return parent.getBackground();
-}
-/**
- * Sets the receiver's background color to the color specified
- * by the argument, or to the default system color for the item
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- *
- */
-public void setBackground (Color color) {
- checkWidget ();
- if (color != null && color.isDisposed ())
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
-}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Trim.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Trim.java
deleted file mode 100644
index 8f37202228..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Trim.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.eclipse.swt.widgets;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved
- */
-
-class Trim {
- int top=0, bottom=0, left=0, right=0;
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/UtilFuncs.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/UtilFuncs.java
deleted file mode 100644
index afe935eaa7..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/UtilFuncs.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.eclipse.swt.widgets;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.gtk.*;
-
-/**
- * This class contains static helpers wrapping some common
- * widget-inspecific operations like get the size of a gtk widget.
- */
-class UtilFuncs {
-
-static int getFont(int widget) {
- /* FIXME */
- return 0;
-}
-
-static void setFont(int handle, int font) {
- /* FIXME */
-}
-
-}
-
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
index 508b95505f..415d1a520f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
@@ -38,7 +38,6 @@ import org.eclipse.swt.events.*;
*/
public abstract class Widget {
-
public int handle;
int style, state;
EventTable eventTable;
@@ -64,7 +63,6 @@ public abstract class Widget {
/* Default widths for widgets */
static final int DEFAULT_WIDTH = 64;
static final int DEFAULT_HEIGHT = 64;
- static final char Mnemonic = '&';
/**
* Prevents uninitialized instances from being created outside the package.
@@ -229,20 +227,10 @@ protected void checkWidget () {
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
}
-/*
- * HANDLE CODE
- *
- * HANDLE CODE 1: HANDLE CREATION CODE - The createWidget() cycle.
- */
-
void createWidget (int index) {
- createHandle (index);
- hookEvents ();
- configure ();
- setHandleStyle ();
- register ();
- setInitialSize ();
- showHandle ();
+ createHandle (index);
+ hookEvents ();
+ register ();
}
void register () {
@@ -250,22 +238,17 @@ void register () {
if ((state & HANDLE) != 0) WidgetTable.put (handle, this);
}
-void createHandle (int index) {}
-void configure () {}
-void setHandleStyle () {}
-void setInitialSize () {}
-void hookEvents () {}
-void showHandle () {}
-int paintHandle () { return 0; }
+void createHandle (int index) {
+}
-/* HANDLE CODE 3:
- * Handle Destruction
- */
+void hookEvents () {
+}
void deregister () {
if (handle == 0) return;
if ((state & HANDLE) != 0) WidgetTable.remove (handle);
}
+
void destroyWidget () {
int topHandle = topHandle ();
releaseHandle ();
@@ -273,6 +256,7 @@ void destroyWidget () {
OS.gtk_widget_destroy (topHandle);
}
}
+
/**
* Disposes of the operating system resources associated with
* the receiver and all its descendents. After this method has
@@ -565,12 +549,14 @@ int processEvent (int eventNumber, int int0, int int1, int int2) {
case SWT.Iconify: return processIconify (int0, int1, int2);
case SWT.Deiconify: return processDeiconify (int0, int1, int2);
case SWT.Modify: return processModify (int0, int1, int2);
- case SWT.MouseDown: return processMouseDown (int0, int1, int2);
+// case SWT.MouseDown: return processMouseDown (int0, int1, int2);
+ case SWT.MouseDown: return processMouse (int0, int1, int2);
case SWT.MouseEnter: return processMouseEnter (int0, int1, int2);
case SWT.MouseExit: return processMouseExit (int0, int1, int2);
case SWT.MouseHover: return processMouseHover (int0, int1, int2);
case SWT.MouseMove: return processMouseMove (int0, int1, int2);
- case SWT.MouseUp: return processMouseUp (int0, int1, int2);
+// case SWT.MouseUp: return processMouseUp (int0, int1, int2);
+ case SWT.Move: return processMove (int0, int1, int2);
case SWT.Paint: return processPaint (int0, int1, int2);
case SWT.Resize: return processResize (int0, int1, int2);
case SWT.Show: return processShow (int0, int1, int2);
@@ -633,6 +619,16 @@ int processKeyUp (int arg0, int arg1, int int2) {
int processModify (int arg0, int arg1, int int2) {
return 0;
}
+int processMouse (int callData, int arg1, int int2) {
+ switch (OS.GDK_EVENT_TYPE(callData)) {
+ case OS.GDK_BUTTON_PRESS:
+ case OS.GDK_2BUTTON_PRESS:
+ return processMouseDown (callData, arg1, int2);
+ case OS.GDK_BUTTON_RELEASE:
+ return processMouseUp (callData, arg1, int2);
+ }
+ return 0;
+}
int processMouseDown (int arg0, int arg1, int int2) {
return 0;
}
@@ -659,6 +655,11 @@ int processMouseMove (int arg0, int arg1, int int2) {
int processMouseUp (int arg0, int arg1, int int2) {
return 0;
}
+
+int processMove (int arg0, int arg1, int int2) {
+ return 0;
+}
+
int processPaint (int int0, int int1, int int2) {
return 0;
}
@@ -897,9 +898,11 @@ public String toString () {
}
return getName () + " {" + string + "}";
}
+
int topHandle () {
return handle;
}
+
char wcsToMbcs (char ch) {
int key = ch & 0xFFFF;
if (key <= 0x7F) return ch;
@@ -910,4 +913,5 @@ char wcsToMbcs (char ch) {
}
return 0;
}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/DirectoryDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/DirectoryDialog.java
index 19c97575e4..85520a7c47 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/DirectoryDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/DirectoryDialog.java
@@ -192,6 +192,7 @@ public String open () {
OS.XmNdialogTitle, xmStringPtr1,
OS.XmNpattern, xmStringPtr2,
OS.XmNdirectory, xmStringPtr3,
+ OS.XmNpathMode, OS.XmPATH_MODE_FULL,
OS.XmNfilterLabelString, xmStringPtr4
};
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java
index afa9ca8ba2..5942acef31 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java
@@ -269,8 +269,9 @@ public void copyArea(int x, int y, int width, int height, int destX, int destY)
delta.y = (short)deltaY;
int clipRects = data.clipRects;
short[] unused = new short[1];
- int[] child_tiles = new int[1];
- int child_clip = getClipping(widget, data.topWidget, true, true, child_tiles);
+ int[] child_tiles_buffer = new int[1];
+ int child_clip = getClipping(widget, data.topWidget, true, true, child_tiles_buffer);
+ int child_tiles = child_tiles_buffer[0];
if (clipRects == 0 && child_clip == 0) {
OS.PhBlit(rid, rect, delta);
} else {
@@ -298,7 +299,9 @@ public void copyArea(int x, int y, int width, int height, int destX, int destY)
OS.PhTranslateTiles(dest_tiles, inverseDelta);
/* Exclude rectangles obscured by widgets. */
- dest_tiles = OS.PhClipTilings(dest_tiles, child_tiles[0], null);
+ if (child_tiles != 0) {
+ dest_tiles = OS.PhClipTilings(dest_tiles, child_tiles, null);
+ }
/* Copy rectangles. */
int[] src_rects_count = new int[1];
@@ -318,8 +321,11 @@ public void copyArea(int x, int y, int width, int height, int destX, int destY)
*/
int src = OS.PhGetTile();
OS.memmove(src, rect, PhRect_t.sizeof);
- int widget_damage_tiles = OS.PhIntersectTilings(src, child_tiles[0], unused);
- OS.PhTranslateTiles(widget_damage_tiles, delta);
+ int widget_damage_tiles = 0;
+ if (child_tiles != 0) {
+ widget_damage_tiles = OS.PhIntersectTilings(src, child_tiles, unused);
+ OS.PhTranslateTiles(widget_damage_tiles, delta);
+ }
/*
* Damage the source rectangle excluding the intersecting area
@@ -337,12 +343,25 @@ public void copyArea(int x, int y, int width, int height, int destX, int destY)
}
/* Merge all damage rectangles. */
- int damage_tiles = OS.PhAddMergeTiles(src_damage_tiles, widget_damage_tiles, null);
+ int damage_tiles = src_damage_tiles;
+ if (widget_damage_tiles != 0) {
+ damage_tiles = OS.PhAddMergeTiles(src_damage_tiles, widget_damage_tiles, null);
+ }
+
+// NOT SURE
+// src = OS.PhGetTile();
+// OS.memmove(src, rect, PhRect_t.sizeof);
+// int widget_tile = OS.PhGetTile();
+// OS.PtWidgetCanvas(widget, widget_tile); // NOTE: widget_tile->rect
+// OS.PhDeTranslateTiles(widget_tile, widget_tile); // NOTE: widget_tile->rect.ul
+// src = OS.PhClipTilings(src, widget_tile, null);
+// OS.PhTranslateTiles(src, delta);
+// damage_tiles = OS.PhAddMergeTiles(damage_tiles, src, null);
/* Exclude damage rectangles obscured by widgets. */
- damage_tiles = OS.PhClipTilings(damage_tiles, child_tiles[0], null);
+ damage_tiles = OS.PhClipTilings(damage_tiles, child_tiles, null);
- OS.PhFreeTiles (child_tiles[0]);
+ OS.PhFreeTiles (child_tiles);
/* Damage rectangles. */
int[] damage_rects_count = new int[1];
@@ -2373,12 +2392,14 @@ int getClipping(int widget, int topWidget, boolean clipChildren, boolean clipSib
OS.PtWidgetCanvas(widget, widget_tile); // NOTE: widget_tile->rect
OS.PhDeTranslateTiles(widget_tile, widget_tile); // NOTE: widget_tile->rect.ul
- if (child_tiles != null) child_tiles[0] = child_tile;
/* Clip the widget's rectangle from the child/siblings rectangle's */
if (child_tile != 0) {
+ if (child_tiles != null) {
+ child_tiles[0] = OS.PhIntersectTilings(widget_tile, child_tile, new short[1]);
+ }
int clip_tile = OS.PhClipTilings(widget_tile, child_tile, null);
- if (child_tiles == null) OS.PhFreeTiles(child_tile);
+ OS.PhFreeTiles(child_tile);
return clip_tile;
}
return widget_tile;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java
index c166fe0323..a12129e195 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java
@@ -704,11 +704,11 @@ public Color getSystemColor (int id) {
case SWT.COLOR_INFO_FOREGROUND: color = INFO_FOREGROUND; break;
case SWT.COLOR_INFO_BACKGROUND: color = INFO_BACKGROUND; break;
case SWT.COLOR_TITLE_FOREGROUND: color = 0xFFFFFF; break;
- case SWT.COLOR_TITLE_BACKGROUND: color = 0x6493E7; break;
- case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: color = 0x0000FF; break;
+ case SWT.COLOR_TITLE_BACKGROUND: color = 0x5281D5; break;
+ case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: color = 0x74A3FF; break;
case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: color = 0x000000; break;
case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: color = 0xABBBD3; break;
- case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: color = 0x0000FF; break;
+ case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: color = 0xCDDDFF; break;
case SWT.COLOR_WIDGET_DARK_SHADOW: color = WIDGET_DARK_SHADOW; break;
case SWT.COLOR_WIDGET_NORMAL_SHADOW: color = WIDGET_NORMAL_SHADOW; break;
case SWT.COLOR_WIDGET_LIGHT_SHADOW: color = WIDGET_LIGHT_SHADOW; break;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
index 8b443bc956..5eb7edd878 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
@@ -307,6 +307,11 @@ public String getText () {
return buffer.toString (0, length);
}
+boolean isTabItem () {
+ if ((style & SWT.PUSH) != 0) return true;
+ return super.isTabItem ();
+}
+
boolean mnemonicHit (char ch) {
if (!setFocus ()) return false;
/*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
index 3a85f997e3..fc8f7d2e6f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
@@ -3256,16 +3256,29 @@ LRESULT WM_LBUTTONDBLCLK (int wParam, int lParam) {
}
LRESULT WM_LBUTTONDOWN (int wParam, int lParam) {
- boolean dragging = false;
+ boolean dragging = false, mouseDown = true;
if (hooks (SWT.DragDetect)) {
POINT pt = new POINT ();
pt.x = (short) (lParam & 0xFFFF);
pt.y = (short) (lParam >> 16);
- if (!OS.IsWinCE) dragging = OS.DragDetect (handle, pt);
+ if (!OS.IsWinCE) {
+ /*
+ * Feature in Windows. It's possible that the drag
+ * operation will not be started while the mouse is
+ * down, meaning that the mouse should be captured.
+ * This can happen when the user types the ESC key
+ * to cancel the drag. The fix is to query the state
+ * of the mouse and capture the mouse accordingly.
+ */
+ dragging = OS.DragDetect (handle, pt);
+ mouseDown = OS.GetKeyState (OS.VK_LBUTTON) < 0;
+ }
}
sendMouseEvent (SWT.MouseDown, 1, OS.WM_LBUTTONDOWN, wParam, lParam);
int result = callWindowProc (OS.WM_LBUTTONDOWN, wParam, lParam);
- if (OS.GetCapture () != handle) OS.SetCapture (handle);
+ if (mouseDown) {
+ if (OS.GetCapture () != handle) OS.SetCapture (handle);
+ }
if (dragging) {
postEvent (SWT.DragDetect);
} else {
@@ -3301,8 +3314,9 @@ LRESULT WM_LBUTTONDOWN (int wParam, int lParam) {
LRESULT WM_LBUTTONUP (int wParam, int lParam) {
sendMouseEvent (SWT.MouseUp, 1, OS.WM_LBUTTONUP, wParam, lParam);
int result = callWindowProc (OS.WM_LBUTTONUP, wParam, lParam);
- if ((wParam & (OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON)) == 0)
+ if ((wParam & (OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON)) == 0) {
if (OS.GetCapture () == handle) OS.ReleaseCapture ();
+ }
return new LRESULT (result);
}
@@ -3337,8 +3351,9 @@ LRESULT WM_MBUTTONDOWN (int wParam, int lParam) {
LRESULT WM_MBUTTONUP (int wParam, int lParam) {
sendMouseEvent (SWT.MouseUp, 2, OS.WM_MBUTTONUP, wParam, lParam);
int result = callWindowProc (OS.WM_MBUTTONUP, wParam, lParam);
- if ((wParam & (OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON)) == 0)
+ if ((wParam & (OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON)) == 0) {
if (OS.GetCapture () == handle) OS.ReleaseCapture ();
+ }
return new LRESULT (result);
}
@@ -3654,8 +3669,9 @@ LRESULT WM_RBUTTONDOWN (int wParam, int lParam) {
LRESULT WM_RBUTTONUP (int wParam, int lParam) {
sendMouseEvent (SWT.MouseUp, 3, OS.WM_RBUTTONUP, wParam, lParam);
int result = callWindowProc (OS.WM_RBUTTONUP, wParam, lParam);
- if ((wParam & (OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON)) == 0)
+ if ((wParam & (OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON)) == 0) {
if (OS.GetCapture () == handle) OS.ReleaseCapture ();
+ }
return new LRESULT (result);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java
index 100b819f22..ff66f0d951 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java
@@ -361,6 +361,30 @@ public Point [] getItemSizes () {
}
/**
+ * Returns whether or not the coolbar is 'locked'. When a coolbar
+ * is locked, its items cannot be repositioned.
+ *
+ * @return true if the coolbar is locked, false otherwise
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getLocked () {
+ checkWidget ();
+ int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_STYLE;
+ for (int i=0; i<count; i++) {
+ OS.SendMessage (handle, OS.RB_GETBANDINFO, i, rbBand);
+ if ((rbBand.fStyle & OS.RBBS_NOGRIPPER) == 0) return false;
+ }
+ return true;
+}
+
+/**
* Returns an array of ints which describe the zero-relative
* row number of the row which each of the items in the
* receiver occurs in.
@@ -544,6 +568,34 @@ void setItemSizes (Point [] sizes) {
}
/**
+ * Sets whether the reciever is 'locked' or not. When a coolbar
+ * is locked, its items cannot be repositioned.
+ *
+ * @param locked lock the coolbar if true, otherwise unlock the coolbar
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLocked (boolean locked) {
+ checkWidget ();
+ int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_STYLE;
+ for (int i=0; i<count; i++) {
+ OS.SendMessage (handle, OS.RB_GETBANDINFO, i, rbBand);
+ if (locked) {
+ rbBand.fStyle |= OS.RBBS_NOGRIPPER;
+ } else {
+ rbBand.fStyle &= ~OS.RBBS_NOGRIPPER;
+ }
+ OS.SendMessage (handle, OS.RB_SETBANDINFO, i, rbBand);
+ }
+}
+
+/**
* Sets the row that each of the receiver's items will be
* displayed in to the given array of ints which describe
* the zero-relative row number of the row for each item.
@@ -582,7 +634,7 @@ public void setWrapIndices (int [] indices) {
int widgetStyle () {
int bits = super.widgetStyle () | OS.CCS_NODIVIDER | OS.CCS_NORESIZE;
- bits |= OS.RBS_VARHEIGHT | OS.RBS_BANDBORDERS;
+ bits |= OS.RBS_VARHEIGHT | OS.RBS_BANDBORDERS | OS.RBS_DBLCLKTOGGLE;
return bits;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DirectoryDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DirectoryDialog.java
index ae85be6b07..b1bf473f64 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DirectoryDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DirectoryDialog.java
@@ -174,7 +174,7 @@ public String open () {
BROWSEINFO lpbi = new BROWSEINFO ();
lpbi.hwndOwner = hwndOwner;
lpbi.lpszTitle = lpszTitle;
- lpbi.ulFlags = OS.BIF_RETURNONLYFSDIRS | OS.BIF_EDITBOX | OS.BIF_VALIDATE;
+ lpbi.ulFlags = OS.BIF_NEWDIALOGSTYLE | OS.BIF_RETURNONLYFSDIRS | OS.BIF_EDITBOX | OS.BIF_VALIDATE;
lpbi.lpfn = address;
int lpItemIdList = OS.SHBrowseForFolder (lpbi);
if (lpItemIdList != 0) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
index 0c43805266..da7aa8f0c0 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
@@ -227,10 +227,6 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
return new Point (width, height);
}
-ScrollBar createScrollBar (int type) {
- return new ScrollBar (this, type);
-}
-
int defaultBackground () {
return OS.GetSysColor (OS.COLOR_WINDOW);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java
index 43e49acdb4..b301554724 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java
@@ -755,7 +755,9 @@ public void setEnabled (boolean enabled) {
*/
public void setLocation (int x, int y) {
checkWidget ();
- this.x = x; this.y = y;
+ if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
+ this.x = x;
+ this.y = y;
hasLocation = true;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java
index 1245853849..ecea612ac8 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java
@@ -25,7 +25,6 @@ import org.eclipse.swt.graphics.*;
*/
public abstract class Scrollable extends Control {
-
ScrollBar horizontalBar, verticalBar;
/**
@@ -108,8 +107,10 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
ScrollBar createScrollBar (int type) {
ScrollBar bar = new ScrollBar (this, type);
- bar.setMaximum (100);
- bar.setThumb (10);
+ if ((state & CANVAS) != 0) {
+ bar.setMaximum (100);
+ bar.setThumb (10);
+ }
return bar;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
index 563f3c9cf1..6e07c5eb3f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
@@ -335,10 +335,6 @@ void createItem (TableItem item, int index) {
items [index] = item;
}
-ScrollBar createScrollBar (int type) {
- return new ScrollBar (this, type);
-}
-
void createWidget () {
super.createWidget ();
items = new TableItem [4];
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
index 9d123eff85..1208e5fedb 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
@@ -328,10 +328,6 @@ public void copy () {
OS.SendMessage (handle, OS.WM_COPY, 0, 0);
}
-ScrollBar createScrollBar (int type) {
- return new ScrollBar (this, type);
-}
-
void createWidget () {
super.createWidget ();
doubleClick = true;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
index 6ad25aae5a..4cdf88edf7 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
@@ -269,10 +269,6 @@ void createItem (TreeItem item, int hParent, int hInsertAfter) {
}
}
-ScrollBar createScrollBar (int type) {
- return new ScrollBar (this, type);
-}
-
void createWidget () {
super.createWidget ();
items = new TreeItem [4];
@@ -517,6 +513,7 @@ public TreeItem [] getSelection () {
return new TreeItem [] {items [tvItem.lParam]};
}
int count = 0;
+ TreeItem [] guess = new TreeItem [8];
TVITEM tvItem = new TVITEM ();
tvItem.mask = OS.TVIF_PARAM | OS.TVIF_STATE;
int oldProc = OS.GetWindowLong (handle, OS.GWL_WNDPROC);
@@ -526,20 +523,29 @@ public TreeItem [] getSelection () {
if (item != null) {
tvItem.hItem = item.handle;
OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
- if ((tvItem.state & OS.TVIS_SELECTED) != 0) count++;
+ if ((tvItem.state & OS.TVIS_SELECTED) != 0) {
+ if (count < guess.length) guess [count] = item;
+ count++;
+ }
}
}
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, oldProc);
+ if (count == 0) return new TreeItem [0];
+ if (count == guess.length) return guess;
TreeItem [] result = new TreeItem [count];
- if (count != 0) {
- int index = 0;
- for (int i=0; i<items.length; i++) {
- TreeItem item = items [i];
- if (item != null) {
- tvItem.hItem = item.handle;
- OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
- if ((tvItem.state & OS.TVIS_SELECTED) != 0) {
- result [index++] = item;
- }
+ if (count < guess.length) {
+ System.arraycopy (guess, 0, result, 0, count);
+ return result;
+ }
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, TreeProc);
+ int index = 0;
+ for (int i=0; i<items.length; i++) {
+ TreeItem item = items [i];
+ if (item != null) {
+ tvItem.hItem = item.handle;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ if ((tvItem.state & OS.TVIS_SELECTED) != 0) {
+ result [index++] = item;
}
}
}
diff --git a/bundles/org.eclipse.swt/buildnotes_swt.html b/bundles/org.eclipse.swt/buildnotes_swt.html
index 688a4d9e3e..b0d0721698 100755
--- a/bundles/org.eclipse.swt/buildnotes_swt.html
+++ b/bundles/org.eclipse.swt/buildnotes_swt.html
@@ -11,6 +11,24 @@
<h1>
Eclipse Platform Build Notes<br>
SWT</h1>
+SWT Build 2.0 032 - Tueday March 28, 2002
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+4467: DCR - Tree missing keyboard support (1FJH5GY)
+<br>4525: Property viewer doesn't adapt to bg color changes (1FX8XL1)
+<br>10317: StyledText - bidi printing support
+<br>10483: SWT ControlExample DirectoryDialog does not choose directories
+<br>11081: Java Source Editing with Greek Locale no longer works
+<br>11549: Create project does not allow creation of folder in its project selection
+<br>12099: Accessibility : JAWS can not read TabItem's text
+<br>12231: DND : Drag and Drop busted (mouse capture not released)
+</blockquote>
+
+<h1>
+Eclipse Platform Build Notes<br>
+SWT</h1>
SWT Build 2.0 031 - Monday March 18, 2002
<h2>
@@ -24,13 +42,13 @@ SWT Build 2.0 031 - Monday March 18, 2002
<h2>
<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
<blockquote>
-7500 Display.getBounds() calls from another thread give incorrect results
-<br>10273 NPEs caused by unitialized 'item' field in event
-<br>10481 View will not Size via Pull Down
-<br>10511 add programmatic scrolling to ScrolledComposite
-<br>10942 Launcher should autodetect gtk only installation.
-<br>11051 invalid token pasting in callback.c
-<br>11090 CLabel Javadoc says SmartLabel
+7500: Display.getBounds() calls from another thread give incorrect results
+<br>10273: NPEs caused by unitialized 'item' field in event
+<br>10481: View will not Size via Pull Down
+<br>10511: Add programmatic scrolling to ScrolledComposite
+<br>10942: Launcher should autodetect gtk only installation.
+<br>11051: Invalid token pasting in callback.c
+<br>11090: CLabel Javadoc says SmartLabel
</blockquote>
<h1>
diff --git a/bundles/org.eclipse.swt/readme_swt.html b/bundles/org.eclipse.swt/readme_swt.html
index a94c92216c..d6eb47d43f 100755
--- a/bundles/org.eclipse.swt/readme_swt.html
+++ b/bundles/org.eclipse.swt/readme_swt.html
@@ -21,9 +21,9 @@ Notices</h3>
Table Of Contents</h3>
&nbsp;1. Known Issues
<h3>
-99.1 Known Issues</h3>
+1 Known Issues</h3>
<h4>
-99.1.1 Available Colors on 8-bit Linux</h4>
+1.1 Available Colors on 8-bit Linux</h4>
Typically, in Gnome Linux installs running with 8 bitplain visuals (i.e. 256 color mode), before the
Eclipse application is started, you already do not have any free colors. This may mean that Eclipse
@@ -31,7 +31,7 @@ is unable to allocate the default widget background color causing it to display
The functionality, however, is not affected.
<h4>
-99.1.2 Printing Support</h4>
+1.2 Printing Support</h4>
The X printing extension implementation on Linux is currently disabled because
it can take up to 7 seconds to determine that the X print server is not running.
@@ -39,27 +39,27 @@ Until this is rectified, <code>Printer.getPrinterList()</code> will always retur
an empty array on the Linux platform.</dd>
<h4>
-99.1.3 Disposing in a Focus Event</h4>
+1.3 Disposing in a Focus Event</h4>
Applications should not dispose widgets in focus changing events. Doing so on Motif may cause Eclipse to terminate,
since Motif accesses the disposed widget within their internal focus change event handler.
Similar but less serious issues exist on Windows such that occasionally an SWT exception can be thrown.
<h4>
-99.1.4 List and ComboBox on Windows NT</h4>
+1.4 List and ComboBox on Windows NT</h4>
On Windows NT only, you should avoid creating items in a List or ComboBox with strings longer than 1000 characters.
Doing so may result in a General Protection Fault. This has been fixed in more recent versions of Windows.
<h4>
-99.1.5 BiDi Support</h4>
+1.5 BiDi Support</h4>
The StyledText widget now provides bidirectional language support for Hebrew and Arabic locales.
Currently, this support is available only on win32, and has several known problems. It should be
considered to be a preliminary implementation only.
<h4>
-99.1.6 Cursor constructor arguments</h4>
+1.6 Cursor constructor arguments</h4>
In the constructor <code>Cursor(Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY)</code>,
when both a source and mask argument are specified (i.e. mask is not null), the meaning of the two arguments is
@@ -68,28 +68,20 @@ mask image. This problem was discovered too late in the development cycle to be
fix this in a future release, potentially by introducing a new more general constructor.
<h4>
-99.1.7 Use of the "&" character in TabFolder</h4>
-
-The "&" character is not currently supported in TabFolder labels. Doing so on win32, will cause the
-character which follows the "&" to be underlined as if it was a mnemonic, even though mnemonics are
-not available for TabFolders. On other platforms, the "&" character will be displayed correctly, but
-for portability reasons, it should be avoided.
-
-<h4>
-99.1.8 ToolBar on Windows</h4>
+1.7 ToolBar on Windows</h4>
On Windows, you must create all tool bars with the FLAT style bit set. If you do not do this,
the "hot" (rollover) images of <em>all</em> toolbars may display incorrectly.
This will be fixed in a future release.
<h4>
-99.1.9 Non ASCII strings on Linux</h4>
+1.8 Non ASCII strings on Linux</h4>
On Linux RedHat 6.2 only, you will not be able to display text that contains non
ASCII characters. This limitation is not present on Linux RedHat 7.1 or higher.
<h4>
-99.1.10 Using J9 VM on Photon and AIX</h4>
+1.9 Using J9 VM on Photon and AIX</h4>
On Photon and AIX, the SWT library will not be found when running with
the J9 VM (version 1.5). This is a bug in the J9 classes library. You

Back to the top