*** empty log message ***
diff --git a/bundles/org.eclipse.swt/.classpath_motif b/bundles/org.eclipse.swt/.classpath_motif
index d89e2d3..9446ffe 100755
--- a/bundles/org.eclipse.swt/.classpath_motif
+++ b/bundles/org.eclipse.swt/.classpath_motif
@@ -2,7 +2,6 @@
 <classpath>
     <classpathentry kind="var" path="JRE_LIB"/>
     <classpathentry kind="src" path="Eclipse SWT/motif"/>
-    <classpathentry kind="src" path="Eclipse SWT/emulated"/>
     <classpathentry kind="src" path="Eclipse SWT/common"/>
     <classpathentry kind="src" path="Eclipse SWT Printing/motif"/>
     <classpathentry kind="src" path="Eclipse SWT Printing/common"/>
diff --git a/bundles/org.eclipse.swt/.classpath_photon b/bundles/org.eclipse.swt/.classpath_photon
index 89aa3ff..c061bdb 100755
--- a/bundles/org.eclipse.swt/.classpath_photon
+++ b/bundles/org.eclipse.swt/.classpath_photon
@@ -2,7 +2,6 @@
 <classpath>
     <classpathentry kind="var" path="JRE_LIB"/>
     <classpathentry kind="src" path="Eclipse SWT/photon"/>
-    <classpathentry kind="src" path="Eclipse SWT/emulated"/>
     <classpathentry kind="src" path="Eclipse SWT/common"/>
     <classpathentry kind="src" path="Eclipse SWT Printing/photon"/>
     <classpathentry kind="src" path="Eclipse SWT Printing/common"/>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/SWT_AWT.java b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/SWT_AWT.java
index d6f2606..d6777ad 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/SWT_AWT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/SWT_AWT.java
@@ -25,8 +25,6 @@
 import java.awt.Dimension;

 import java.awt.event.ComponentAdapter;

 import java.awt.event.ComponentEvent;

-import java.awt.event.WindowEvent;

-import java.awt.event.FocusEvent;

 

 public class SWT_AWT {

 

@@ -35,18 +33,6 @@
 	final WEmbeddedFrame frame = new WEmbeddedFrame (handle);

 	Panel panel = new Panel ();

 	frame.add (panel);

-	parent.addListener (SWT.Activate, new Listener () {

-		public void handleEvent (Event e) {

-			frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_ACTIVATED));

-			frame.dispatchEvent (new FocusEvent (frame, FocusEvent.FOCUS_GAINED));

-		}

-	});

-	parent.addListener (SWT.Deactivate, new Listener () {

-		public void handleEvent (Event e) {

-			frame.dispatchEvent (new WindowEvent(frame, WindowEvent.WINDOW_DEACTIVATED));

-			frame.dispatchEvent (new FocusEvent(frame, FocusEvent.FOCUS_LOST));

-		}

-	});

 	parent.addListener (SWT.Resize, new Listener () {

 		public void handleEvent (Event e) {

 			Rectangle rect = parent.getClientArea ();

@@ -54,11 +40,6 @@
 			frame.validate ();

 		}

 	});

-	parent.addListener (SWT.Dispose, new Listener () {

-		public void handleEvent (Event e) {

-			frame.dispose ();

-		}

-	});

 	return panel;

 }

 

diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BusyIndicator.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BusyIndicator.java
index fc640a5..404ff47 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BusyIndicator.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BusyIndicator.java
@@ -15,6 +15,8 @@
  */

 public class BusyIndicator {

 

+	static Display[] displays = new Display[0];

+	static Cursor[] cursors = new Cursor[0];

 	static int nextBusyId = 1;

 	static final String BUSYID_NAME = "SWT BusyIndicator";

 

@@ -39,15 +41,40 @@
 		}

 	}

 	

+	int index = 0;

+	while (index < displays.length) {

+		if (displays[index] == display) break;

+		index++;

+	}

+	if (index == displays.length) {

+		Display[] newDisplays = new Display[displays.length + 1];

+		System.arraycopy(displays, 0, newDisplays, 0, displays.length);

+		displays = newDisplays;

+		displays[index] = display;

+		final Display d = display;

+		display.disposeExec( new Runnable() {

+			public void run() {

+				clear (d);

+			}

+		});

+		

+		Cursor[] newCursors = new Cursor[cursors.length + 1];

+		System.arraycopy(cursors, 0, newCursors, 0, cursors.length);

+		cursors = newCursors;

+	}

+	

+	if (cursors[index] == null) {

+		cursors[index] = new Cursor(display, SWT.CURSOR_WAIT);

+	}

+	

 	Integer busyId = new Integer(nextBusyId);

-	nextBusyId++;

-	Cursor cursor = new Cursor(display, SWT.CURSOR_WAIT);

+	nextBusyId = (++nextBusyId) % 65536;

 	

 	Shell[] shells = display.getShells();

 	for (int i = 0; i < shells.length; i++) {

 		Integer id = (Integer)shells[i].getData(BUSYID_NAME);

 		if (id == null) {

-			shells[i].setCursor(cursor);

+			shells[i].setCursor(cursors[index]);

 			shells[i].setData(BUSYID_NAME, busyId);

 		}

 	}

@@ -63,9 +90,22 @@
 				shells[i].setData(BUSYID_NAME, null);

 			}

 		}

-		if (cursor != null && !cursor.isDisposed()) {

-			cursor.dispose();

-		}

 	}

 }

+

+static void clear(Display display) {

+	int index = 0;

+	while (index < displays.length) {

+		if (displays[index] == display) break;

+		index++;

+	}

+	

+	if (index == displays.length) return;

+	

+	if (cursors[index] != null) {

+		cursors[index].dispose();

+	}

+	cursors[index] = null;

+	displays[index] = null;

+}

 }
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java
index de94692..ca80b50 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java
@@ -81,19 +81,19 @@
 		}

 	};

 	

-	int [] comboEvents = {SWT.Dispose, SWT.Move, SWT.Resize};

-	for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener);

-	

-	int [] popupEvents = {SWT.Close, SWT.Paint, SWT.Deactivate};

+	int [] popupEvents = {SWT.Close, SWT.Paint, SWT.Activate, SWT.Deactivate};

 	for (int i=0; i<popupEvents.length; i++) popup.addListener (popupEvents [i], listener);

 	

-	int [] textEvents = {SWT.KeyDown, SWT.KeyUp, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.Traverse, SWT.FocusIn, SWT.FocusOut};

+	int [] textEvents = {SWT.KeyDown, SWT.KeyUp, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.Traverse};

 	for (int i=0; i<textEvents.length; i++) text.addListener (textEvents [i], listener);

 	

-	int [] listEvents = {SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.FocusOut};

+	int [] listEvents = {SWT.MouseUp, SWT.Selection};

 	for (int i=0; i<listEvents.length; i++) list.addListener (listEvents [i], listener);

 	

-	int [] arrowEvents = {SWT.MouseDown, SWT.FocusIn, SWT.FocusOut};

+	int [] comboEvents = {SWT.Dispose, SWT.Move, SWT.Resize, SWT.Activate, SWT.Deactivate};

+	for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener);

+	

+	int [] arrowEvents = {SWT.MouseDown};

 	for (int i=0; i<arrowEvents.length; i++) arrow.addListener (arrowEvents [i], listener);

 	

 }

@@ -185,31 +185,8 @@
 	addListener (SWT.DefaultSelection,typedListener);

 }

 void arrowEvent (Event event) {

-	switch (event.type) {

-		case SWT.FocusIn: {

-			if (hasFocus) return;

-			hasFocus = true;

-			if (getEditable ()) text.selectAll ();

-			Event e = new Event();

-			e.time = event.time;

-			notifyListeners(SWT.FocusIn, e);

-			break;

-		}

-		case SWT.FocusOut: {

-			Control focusControl = getDisplay ().getFocusControl();

-			if (focusControl == list || focusControl == text) return;

-			hasFocus = false;

-			Event e = new Event();

-			e.time = event.time;

-			notifyListeners(SWT.FocusOut, e);

-			break;

-		}

-		case SWT.MouseDown: {

-			if (event.button != 1) return;

-			dropDown (!isDropped ());

-			break;

-		}

-	}

+	if (event.type != SWT.MouseDown || event.button != 1) return;

+	dropDown (!isDropped ());

 }

 /**

 * Clears the current selection.

@@ -227,18 +204,38 @@
 void comboEvent (Event event) {

 	switch (event.type) {

 		case SWT.Dispose:

-			if (popup != null && !popup.isDisposed ()) popup.dispose ();

+			if (popup != null && !popup.isDisposed ())

+				popup.dispose ();

 			popup = null;  

 			text = null;  

 			list = null;  

 			arrow = null;

 			break;

+			

 		case SWT.Move:

 			dropDown(false);

 			break;

 		case SWT.Resize:

 			internalLayout();

 			break;

+		case SWT.Activate: {

+			if (hasFocus) return;

+			hasFocus = true;

+			if (getEditable ()) text.selectAll ();

+			Event e = new Event();

+			e.time = event.time;

+			notifyListeners(SWT.FocusIn, e);

+			break;

+		}

+		case SWT.Deactivate: {

+			Control focusControl = getDisplay ().getFocusControl();

+			if (focusControl == list) return;

+			hasFocus = false;

+			Event e = new Event();

+			e.time = event.time;

+			notifyListeners(SWT.FocusOut, e);

+			break;

+		}

 	}

 }

 

@@ -534,30 +531,9 @@
 }

 void listEvent (Event event) {

 	switch (event.type) {

-		case SWT.FocusIn: {

-			if (hasFocus) return;

-			hasFocus = true;

-			if (getEditable ()) text.selectAll ();

-			Event e = new Event();

-			e.time = event.time;

-			notifyListeners(SWT.FocusIn, e);

-			break;

-		}

-		case SWT.FocusOut: {

-			Control focusControl = getDisplay ().getFocusControl();

-			if (focusControl == text || focusControl == arrow) return;

-			hasFocus = false;

-			Event e = new Event();

-			e.time = event.time;

-			notifyListeners(SWT.FocusOut, e);

-			break;

-		}

 		case SWT.MouseUp: {

 			if (event.button != 1) return;

 			dropDown (false);

-			Event e = new Event();

-			e.time = event.time;

-			notifyListeners(SWT.DefaultSelection, e);

 			break;

 		}

 		case SWT.Selection: {

@@ -568,63 +544,16 @@
 			list.setSelection(index);

 			Event e = new Event();

 			e.time = event.time;

-			e.stateMask = event.stateMask;

+			e.x = event.x;

+			e.y = event.y;

+			e.width = event.width;

+			e.height = event.height;

+			e.detail = event.detail;

 			e.doit = event.doit;

 			notifyListeners(SWT.Selection, e);

 			event.doit = e.doit;

 			break;

 		}

-		case SWT.Traverse: {

-			switch (event.detail) {

-				case SWT.TRAVERSE_TAB_NEXT:

-				case SWT.TRAVERSE_RETURN:

-				case SWT.TRAVERSE_ESCAPE:

-				case SWT.TRAVERSE_ARROW_PREVIOUS:

-				case SWT.TRAVERSE_ARROW_NEXT:

-					event.doit = false;

-					break;

-			}

-			Event e = new Event();

-			e.time = event.time;

-			e.detail = event.detail;

-			e.doit = event.doit;

-			e.keyCode = event.keyCode;

-			notifyListeners(SWT.Traverse, e);

-			event.doit = e.doit;

-			break;

-		}

-		case SWT.KeyUp: {		

-			Event e = new Event();

-			e.time = event.time;

-			e.character = event.character;

-			e.keyCode = event.keyCode;

-			e.stateMask = event.stateMask;

-			notifyListeners(SWT.KeyUp, e);

-			break;

-		}

-		case SWT.KeyDown: {

-			if (event.character == SWT.ESC) { 

-				// escape key cancels popup list

-				dropDown (false);

-			}

-			if (event.character == SWT.CR || event.character == '\t') {

-				// Enter and Tab cause default selection

-				dropDown (false);

-				Event e = new Event();

-				e.time = event.time;

-				e.stateMask = event.stateMask;

-				notifyListeners(SWT.DefaultSelection, e);

-			}

-			

-			Event e = new Event();

-			e.time = event.time;

-			e.character = event.character;

-			e.keyCode = event.keyCode;

-			e.stateMask = event.stateMask;

-			notifyListeners(SWT.KeyDown, e);

-			break;

-			

-		}

 	}

 }

 void popupEvent(Event event) {

@@ -640,6 +569,14 @@
 			event.doit = false;

 			dropDown (false);

 			break;

+		case SWT.Activate:

+			if (hasFocus) return;

+			hasFocus = true;

+			if (getEditable ()) text.selectAll ();

+			Event e = new Event();

+			e.time = event.time;

+			notifyListeners(SWT.FocusIn, e);

+			break;

 		case SWT.Deactivate:

 			dropDown (false);

 			break;

@@ -944,35 +881,11 @@
 }

 void textEvent (Event event) {

 	switch (event.type) {

-		case SWT.FocusIn: {

-			if (hasFocus) return;

-			hasFocus = true;

-			if (getEditable ()) text.selectAll ();

-			Event e = new Event();

-			e.time = event.time;

-			notifyListeners(SWT.FocusIn, e);

-			break;

-		}

-		case SWT.FocusOut: {

-			Control focusControl = getDisplay ().getFocusControl();

-			if (focusControl == list || focusControl == arrow) return;

-			hasFocus = false;

-			Event e = new Event();

-			e.time = event.time;

-			notifyListeners(SWT.FocusOut, e);

-			break;

-		}

 		case SWT.KeyDown: {

 			

 			if (event.character == SWT.ESC) { // escape key cancels popup list

 				dropDown (false);

-			}

-			if (event.character == SWT.CR || event.character == '\t') {

-				dropDown (false);

-				Event e = new Event();

-				e.time = event.time;

-				e.stateMask = event.stateMask;

-				notifyListeners(SWT.DefaultSelection, e);

+				return;

 			}

 			if (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN) {

 				int oldIndex = getSelectionIndex ();

@@ -985,13 +898,11 @@
 				if (oldIndex != getSelectionIndex ()) {

 					Event e = new Event();

 					e.time = event.time;

-					e.stateMask = event.stateMask;

 					notifyListeners(SWT.Selection, e);

 				}

 			}

 			

-			// Further work : Need to add support for incremental search in 

-			// pop up list as characters typed in text widget

+			// Further work : Need to add support for incremental search in pop up list as characters typed in text widget

 						

 			Event e = new Event();

 			e.time = event.time;

@@ -1034,11 +945,18 @@
 		}

 		case SWT.Traverse: {		

 			switch (event.detail) {

+				case SWT.TRAVERSE_RETURN:

 				case SWT.TRAVERSE_TAB_NEXT:

+					// allow "return" and "tab" to have their usual effect

+					break;

+				case SWT.TRAVERSE_ESCAPE:

+					// escape key is used to close the list so

+					// do not use it for traversal

+					event.doit = false;

+					break;

 				case SWT.TRAVERSE_ARROW_PREVIOUS:

 				case SWT.TRAVERSE_ARROW_NEXT:

-					// The tab key causes default selection and

-					// the arrow keys are used to manipulate the list contents so

+					// arrow keys are used to manipulate the list contents so

 					// do not use them for traversal.

 					event.doit = false;

 					break;

diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java
index 799891d..0afada5 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java
@@ -53,6 +53,7 @@
 	private String appToolTipText;

 	

 	private Image backgroundImage;

+	private Image gradientImage;

 	private Color[] gradientColors;

 	private int[] gradientPercents;

 

@@ -191,6 +192,10 @@
 	}

 }

 private void onDispose(DisposeEvent event) {

+	if (gradientImage != null) {

+		gradientImage.dispose();

+	}

+	gradientImage = null;

 	gradientColors = null;

 	gradientPercents = null;

 	backgroundImage = null;

@@ -204,12 +209,12 @@
 	

 	boolean shortenText = false;

 	String t = text;

-	Image img = image;

+	Image i = image;

 	int availableWidth = rect.width - 2*hIndent;

-	Point extent = getTotalSize(img, t);

+	Point extent = getTotalSize(i, t);

 	if (extent.x > availableWidth) {

-		img = null;

-		extent = getTotalSize(img, t);

+		i = null;

+		extent = getTotalSize(i, t);

 		if (extent.x > availableWidth) {

 			shortenText = true;

 		}

@@ -220,7 +225,7 @@
 	// shorten the text

 	if (shortenText) {

 		t = shortenText(gc, text, availableWidth);

-		extent = getTotalSize(img, t);

+		extent = getTotalSize(i, t);

 		if (appToolTipText == null) {

 			super.setToolTipText(text);

 		}

@@ -238,52 +243,28 @@
 	}

 	

 	// draw a background image behind the text

-	try {

-		if (backgroundImage != null) {

-			// draw a background image behind the text

-			Rectangle imageRect = backgroundImage.getBounds();

+	if (backgroundImage != null) {

+		Rectangle imageRect = backgroundImage.getBounds();

+		try {

 			gc.drawImage(backgroundImage, 0, 0, imageRect.width, imageRect.height,

-				0, 0, rect.width, rect.height);

-		} else if (gradientColors != null) {

-			// draw a gradient behind the text

-			final Color oldBackground = gc.getBackground();

-			if (gradientColors.length == 1) {

-				if (gradientColors[0] != null) gc.setBackground(gradientColors[0]);

-				gc.fillRectangle(0, 0, rect.width, rect.height);

-			} else {

-				final Color oldForeground = gc.getForeground();

-				Color lastColor = gradientColors[0];

-				if (lastColor == null) lastColor = oldBackground;

-				for (int i = 0, pos = 0; i < gradientPercents.length; ++i) {

-					gc.setForeground(lastColor);

-					lastColor = gradientColors[i + 1];

-					if (lastColor == null) lastColor = oldBackground;

-					gc.setBackground(lastColor);

-					final int gradientWidth = (gradientPercents[i] * rect.width / 100) - pos;

-					gc.fillGradientRectangle(pos, 0, gradientWidth, rect.height, false);

-					pos += gradientWidth;

-				}

-				gc.setForeground(oldForeground);

-			}

-			gc.setBackground(oldBackground);

-		} else {

+			                              0, 0, rect.width, rect.height);

+		} catch(SWTException e) {

 			gc.setBackground(getBackground());

 			gc.fillRectangle(rect);

 		}

-	} catch (SWTException e) {

+	} else {

 		gc.setBackground(getBackground());

 		gc.fillRectangle(rect);

 	}

-

 	// draw border

 	int style = getStyle();

 	if ((style & SWT.SHADOW_IN) != 0 || (style & SWT.SHADOW_OUT) != 0) {

 		paintBorder(gc, rect);

 	}

 	// draw the image		

-	if (img != null) {

-		Rectangle imageRect = img.getBounds();

-		gc.drawImage(img, 0, 0, imageRect.width, imageRect.height, 

+	if (i != null) {

+		Rectangle imageRect = i.getBounds();

+		gc.drawImage(i, 0, 0, imageRect.width, imageRect.height, 

 		                x, (rect.height-imageRect.height)/2, imageRect.width, imageRect.height);

 		x += imageRect.width + GAP;

 	}

@@ -327,68 +308,113 @@
  *                 of the widget at which the color should change.  The size of the percents array must be one 

  *                 less than the size of the colors array.

  */

-public void setBackground(Color[] colors, int[] percents) {	

+public void setBackground(Color[] colors, int[] percents) {

 	if (colors != null) {

-		if (percents == null || percents.length != colors.length - 1) {

+		if (percents == null || percents.length != colors.length - 1) 

 			SWT.error(SWT.ERROR_INVALID_ARGUMENT);

-		}

-		if (getDisplay().getDepth() < 15) {

-			// Don't use gradients on low color displays

-			colors = new Color[] { colors[0] };

-			percents = new int[] { };

-		}

 		for (int i = 0; i < percents.length; i++) {

-			if (percents[i] < 0 || percents[i] > 100) {

+			if (percents[i] < 0 || percents[i] > 100)

 				SWT.error(SWT.ERROR_INVALID_ARGUMENT);

-			}

-			if (i > 0 && percents[i] < percents[i-1]) {

+			if (i > 0 && percents[i] < percents[i-1])

 				SWT.error(SWT.ERROR_INVALID_ARGUMENT);

-			}

 		}

 	}

 	

 	// Are these settings the same as before?

-	final Color background = getBackground();

-	if (backgroundImage == null) {

-		if ((gradientColors != null) && (colors != null) && 

-			(gradientColors.length == colors.length)) {

-			boolean same = false;

-			for (int i = 0; i < gradientColors.length; i++) {

-				same = (gradientColors[i] == colors[i]) ||

-					((gradientColors[i] == null) && (colors[i] == background)) ||

-					((gradientColors[i] == background) && (colors[i] == null));

+	if (gradientImage == null && gradientColors == null && colors == null) {

+		if (backgroundImage != null) {

+			backgroundImage = null;

+			redraw();

+		}

+		return;

+	}

+	if (gradientColors != null && colors != null 

+	    && gradientColors.length == colors.length) {

+		boolean same = false;

+		for (int i = 0; i < gradientColors.length; i++) {

+			same = gradientColors[i].equals(colors[i]);

+			if (!same) break;

+		}

+		if (same) {

+			for (int i = 0; i < gradientPercents.length; i++) {

+				same = gradientPercents[i] == percents[i];

 				if (!same) break;

 			}

-			if (same) {

-				for (int i = 0; i < gradientPercents.length; i++) {

-					same = gradientPercents[i] == percents[i];

-					if (!same) break;

-				}

-			}

-			if (same) return;

 		}

-	} else {

-		backgroundImage = null;

+		if (same) return;

 	}

-	// Store the new settings

-	if (colors == null) {

-		gradientColors = null;

-		gradientPercents = null;

-	} else {

-		gradientColors = new Color[colors.length];

-		for (int i = 0; i < colors.length; ++i)

-			gradientColors[i] = (colors[i] != null) ? colors[i] : background;

-		gradientPercents = new int[percents.length];

-		for (int i = 0; i < percents.length; ++i)

-			gradientPercents[i] = percents[i];

+	

+	// Cleanup

+	if (gradientImage != null) {

+		gradientImage.dispose();

 	}

-	// Refresh with the new settings

+	gradientImage = null;

+	gradientColors = null;

+	gradientPercents = null;

+	backgroundImage = null;

+	

+	// Draw gradient onto an image

+	if (colors != null) {

+		Color[] colorsCopy = null;

+		Display display = getDisplay();

+		if (display.getDepth() < 15) {

+			colorsCopy = new Color[]{colors[0]};

+		} else {

+			colorsCopy = colors;

+		}

+		

+		int x = 0; int y = 0;

+		int width = 100; int height = 10;

+		Image temp = new Image(display, width, height);

+		GC gc = new GC(temp);

+		if (colorsCopy.length == 1) {

+			gc.setBackground(colorsCopy[0]);

+			gc.fillRectangle(temp.getBounds());

+		}

+		int start = 0;

+		int end = 0;

+		for (int j = 0; j < colorsCopy.length - 1; j++) {

+			Color startColor = colorsCopy[j];

+			if (startColor == null) startColor = getBackground();

+			RGB rgb1 = startColor.getRGB();

+			Color endColor = colorsCopy[j+1];

+			if (endColor == null) endColor = getBackground();

+			RGB rgb2   = endColor.getRGB();

+			start = end;

+			end = (width) * percents[j] / 100;

+			int range = Math.max(1, end - start);

+			for (int k = 0; k < (end - start); k++) {

+				int r = rgb1.red + k*(rgb2.red - rgb1.red)/range;

+				r = (rgb2.red > rgb1.red) ? Math.min(r, rgb2.red) : Math.max(r, rgb2.red);

+				int g = rgb1.green + k*(rgb2.green - rgb1.green)/range;

+				g = (rgb2.green > rgb1.green) ? Math.min(g, rgb2.green) : Math.max(g, rgb2.green);

+				int b = rgb1.blue + k*(rgb2.blue - rgb1.blue)/range;

+				b = (rgb2.blue > rgb1.blue) ? Math.min(b, rgb2.blue) : Math.max(b, rgb2.blue);

+				Color color = new Color(display, r, g, b); 

+				gc.setBackground(color);					

+				gc.fillRectangle(start + k,y,1,height);

+				gc.setBackground(getBackground());

+				color.dispose();

+			}

+		}

+		gc.dispose();

+		gradientImage = temp;

+		gradientColors = colorsCopy;

+		gradientPercents = percents;

+		backgroundImage = temp;

+	}

+	

 	redraw();

 }

 public void setBackground(Image image) {

-	if (image == backgroundImage) return;	

-	gradientColors = null;

-	gradientPercents = null;

+	if (image == backgroundImage) return;

+	

+	if (gradientImage != null) {

+		gradientImage.dispose();

+		gradientImage = null;

+		gradientColors = null;

+		gradientPercents = null;

+	}

 	backgroundImage = image;

 	redraw();

 	

diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
index ce89107..2d10a97 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
@@ -88,8 +88,9 @@
 	

 	/* Color appearance */

 	Image backgroundImage;

-	Color[] gradientColors;

-	int[] gradientPercents;

+	private Image gradientImage;

+	private Color[] gradientColors;

+	private int[] gradientPercents;

 	Color selectionForeground;

 

 	// internal constants

@@ -458,6 +459,10 @@
 		tip = null;

 	}

 	

+	if (gradientImage != null){

+		gradientImage.dispose();

+		gradientImage = null;

+	}

 	gradientColors = null;

 	gradientPercents = null;

 	backgroundImage = null;

@@ -659,10 +664,8 @@
 				inactiveItem = null;

 			}

 			if (event.widget == inactiveCloseBar) {

-				if (inactiveItem != null) {

-					Rectangle itemBounds = inactiveItem.getBounds();

-					if (itemBounds.contains(event.x, event.y)) return;

-				}

+				Rectangle bounds = getBounds();

+				if (bounds.contains(event.x, event.y)) return;

 				inactiveCloseBar.setVisible(false);

 				inactiveItem = null;

 			}

@@ -952,7 +955,7 @@
 		y = item.y;

 		Rectangle area = super.getClientArea();

 		width = area.x + area.width - x;

-		height = item.height;

+		height = area.y + area.height - y;

 	}

 	redraw(x, y, width, height, false);

 }

@@ -1102,11 +1105,6 @@
 		if (percents == null || percents.length != colors.length - 1) {

 			SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 		}

-		if (getDisplay().getDepth() < 15) {

-			// Don't use gradients on low color displays

-			colors = new Color[] { colors[0] };

-			percents = new int[] { };

-		}

 		for (int i = 0; i < percents.length; i++) {

 			if (percents[i] < 0 || percents[i] > 100) {

 				SWT.error(SWT.ERROR_INVALID_ARGUMENT);

@@ -1118,49 +1116,105 @@
 	}

 	

 	// Are these settings the same as before?

-	final Color background = getBackground();

-	if (backgroundImage == null) {

-		if ((gradientColors != null) && (colors != null) && 

-			(gradientColors.length == colors.length)) {

-			boolean same = false;

-			for (int i = 0; i < gradientColors.length; i++) {

-				same = (gradientColors[i] == colors[i]) ||

-					((gradientColors[i] == null) && (colors[i] == background)) ||

-					((gradientColors[i] == background) && (colors[i] == null));

+	if (gradientImage == null && gradientColors == null && colors == null) {

+		if (backgroundImage != null) {

+			backgroundImage = null;

+			redrawTabArea(selectedIndex);

+		}

+		return;

+	}

+	if (gradientColors != null && colors != null 

+	    && gradientColors.length == colors.length) {

+		boolean same = false;

+		for (int i = 0; i < gradientColors.length; i++) {

+			same = (gradientColors[i] == colors[i]);

+			if (!same) break;

+		}

+		if (same) {

+			for (int i = 0; i < gradientPercents.length; i++) {

+				same = gradientPercents[i] == percents[i];

 				if (!same) break;

 			}

-			if (same) {

-				for (int i = 0; i < gradientPercents.length; i++) {

-					same = gradientPercents[i] == percents[i];

-					if (!same) break;

-				}

-			}

-			if (same) return;

 		}

-	} else {

-		backgroundImage = null;

+		if (same) return;

 	}

-	// Store the new settings

-	if (colors == null) {

-		gradientColors = null;

-		gradientPercents = null;

-		closeBar.setBackground(background);

-	} else {

-		gradientColors = new Color[colors.length];

-		for (int i = 0; i < colors.length; ++i)

-			gradientColors[i] = (colors[i] != null) ? colors[i] : background;

-		gradientPercents = new int[percents.length];

-		for (int i = 0; i < percents.length; ++i)

-			gradientPercents[i] = percents[i];

-		if (getDisplay().getDepth() < 15) closeBar.setBackground(background);

-		else closeBar.setBackground(gradientColors[gradientColors.length - 1]);

+	

+	// Cleanup

+	if (gradientImage != null) {

+		gradientImage.dispose();

+		gradientImage = null;

 	}

-

-	// Refresh with the new settings

+	gradientColors = null;

+	gradientPercents = null;

+	backgroundImage = null;

+	

+	// Draw gradient onto an image

+	if (colors != null) {

+		Color[] colorsCopy = null;

+		Display display = getDisplay();

+		if (display.getDepth() < 15) {

+			colorsCopy = new Color[]{colors[0]};

+		} else {

+			colorsCopy = colors;

+		}

+		

+		int x = 0; int y = 0;

+		int width = 100; int height = 10;

+		Image temp = new Image(display, width, height);

+		GC gc = new GC(temp);

+		int start = 0;

+		int end = 0;

+		Color background = getBackground();

+		if (colorsCopy.length == 1) {

+			gc.setBackground(colorsCopy[0]);

+			gc.fillRectangle(temp.getBounds());

+		}

+		for (int j = 0; j < colorsCopy.length - 1; j++) {

+			Color startColor = colorsCopy[j];

+			if (startColor == null) startColor = getBackground();

+			RGB rgb1 = startColor.getRGB();

+			Color endColor = colorsCopy[j+1];

+			if (endColor == null) endColor = getBackground();

+			RGB rgb2   = endColor.getRGB();

+			start = end;

+			end = (width) * percents[j] / 100;

+			int range = Math.max(1, end - start);

+			for (int k = 0; k < (end - start); k++) {

+				int r = rgb1.red + k*(rgb2.red - rgb1.red)/range;

+				r = (rgb2.red > rgb1.red) ? Math.min(r, rgb2.red) : Math.max(r, rgb2.red);

+				int g = rgb1.green + k*(rgb2.green - rgb1.green)/range;

+				g = (rgb2.green > rgb1.green) ? Math.min(g, rgb2.green) : Math.max(g, rgb2.green);

+				int b = rgb1.blue + k*(rgb2.blue - rgb1.blue)/range;

+				b = (rgb2.blue > rgb1.blue) ? Math.min(b, rgb2.blue) : Math.max(b, rgb2.blue);

+				Color color = new Color(display, r, g, b); 

+				gc.setBackground(color);					

+				gc.fillRectangle(start + k,y,1,height);

+				gc.setBackground(background);

+				color.dispose();

+			}

+		}

+		gc.dispose();

+		gradientImage = temp;

+		gradientColors = colorsCopy;

+		gradientPercents = percents;

+		backgroundImage = temp;

+		

+		Color closeBackground = colorsCopy[colorsCopy.length - 1];

+		if (closeBackground == null || display.getDepth() < 15){

+			closeBackground = background;

+		}

+		closeBar.setBackground(closeBackground);

+	} else {

+		closeBar.setBackground(getBackground());

+	}

 	if (selectedIndex > -1) redrawTabArea(selectedIndex);

 }

 public void setSelectionBackground(Image image) {

 	if (image == backgroundImage) return;

+	if (gradientImage != null) {

+		gradientImage.dispose();

+		gradientImage = null;

+	}

 	gradientColors = null;

 	gradientPercents = null;

 	backgroundImage = image;

diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java
index 5a20b66..db93a6b 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java
@@ -134,39 +134,17 @@
 	int index = parent.indexOf(this);

 	

 	if (isSelected) {

-		final Rectangle bounds;

-		if (index == parent.topTabIndex) {

-			bounds = new Rectangle(x + 1, y, width - 2, height);

-		} else {

-			bounds = new Rectangle(x + 2, y, width - 3, height);

-		}

+		// draw a background image behind the text

 		if (parent.backgroundImage != null) {

-			// draw a background image behind the text

-			Rectangle imageRect = parent.backgroundImage.getBounds();

-			gc.drawImage(parent.backgroundImage, 0, 0, imageRect.width, imageRect.height,

-				bounds.x, bounds.y, bounds.width, bounds.height);

-		} else if (parent.gradientColors != null) {

-			// draw a gradient behind the text

-			final Color oldBackground = gc.getBackground();

-			if (parent.gradientColors.length == 1) {

-				if (parent.gradientColors[0] != null) gc.setBackground(parent.gradientColors[0]);

-				gc.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height);

+			if (index == parent.topTabIndex){

+				Rectangle imageRect = parent.backgroundImage.getBounds();

+				gc.drawImage(parent.backgroundImage, 0, 0, imageRect.width, imageRect.height, 

+				                                   x + 1, y, width - 3, height);

 			} else {

-				final Color oldForeground = gc.getForeground();

-				Color lastColor = parent.gradientColors[0];

-				if (lastColor == null) lastColor = oldBackground;

-				for (int i = 0, pos = 0; i < parent.gradientPercents.length; ++i) {

-					gc.setForeground(lastColor);

-					lastColor = parent.gradientColors[i + 1];

-					if (lastColor == null) lastColor = oldBackground;

-					gc.setBackground(lastColor);

-					final int gradientWidth = (parent.gradientPercents[i] * bounds.width / 100) - pos;

-					gc.fillGradientRectangle(bounds.x + pos, bounds.y, gradientWidth, bounds.height, false);

-					pos += gradientWidth;

-				}

-				gc.setForeground(oldForeground);

+				Rectangle imageRect = parent.backgroundImage.getBounds();

+				gc.drawImage(parent.backgroundImage, 0, 0, imageRect.width, imageRect.height, 

+				                                   x + 2, y, width - 4, height);

 			}

-			gc.setBackground(oldBackground);

 		}

 

 		// draw tab lines

@@ -177,9 +155,9 @@
 				gc.drawLine(x,     y + 1,          x,     y + height - 2);

 				gc.drawLine(x,     y + height - 1, x,     y + height - 1);

 			}

-			gc.drawLine(x + width - 1, y,              x + width - 1, y);

-			gc.drawLine(x + width,     y + 1,          x + width,     y + height - 2);

-			gc.drawLine(x + width,     y + height - 1, x + width,     y + height - 1);

+			gc.drawLine(x + width - 2, y,              x + width - 2, y);

+			gc.drawLine(x + width - 1, y + 1,          x + width - 1, y + height - 2);

+			gc.drawLine(x + width - 1, y + height - 1, x + width - 1, y + height - 1);

 	

 			gc.setForeground(highlightShadow);

 			if (index != parent.topTabIndex) {

@@ -190,15 +168,15 @@
 				gc.drawLine(x, y, x, y + height - 1);

 			}

 			

-			gc.drawLine(x + width - 2, y,              x + width - 2, y);

-			gc.drawLine(x + width - 1, y + 1,          x + width - 1, y + height - 2);

-			gc.drawLine(x + width - 1, y + height - 1, x + width - 1, y + height - 1);

+			gc.drawLine(x + width - 3, y,              x + width - 3, y);

+			gc.drawLine(x + width - 2, y + 1,          x + width - 2, y + height - 2);

+			gc.drawLine(x + width - 2, y + height - 1, x + width - 2, y + height - 1);

 	

 			// light line across top

 			if (index != parent.topTabIndex) {

-				gc.drawLine(x + 3, y, x + width - 3, y);

+				gc.drawLine(x + 3, y, x + width - 4, y);

 			} else {

-				gc.drawLine(x + 1, y, x + width - 3, y);

+				gc.drawLine(x + 1, y, x + width - 4, y);

 			}

 		} else {

 			gc.setForeground(normalShadow);

@@ -207,9 +185,9 @@
 				gc.drawLine(x,     y + 1,          x,     y + height - 2);

 				gc.drawLine(x + 1, y + height - 1, x + 1, y + height - 1);

 			}

-			gc.drawLine(x + width,     y,              x + width,     y);

-			gc.drawLine(x + width,     y + 1,          x + width,     y + height - 2);

-			gc.drawLine(x + width - 1, y + height - 1, x + width - 1, y + height - 1);

+			gc.drawLine(x + width - 1, y,              x + width - 1, y);

+			gc.drawLine(x + width - 1, y + 1,          x + width - 1, y + height - 2);

+			gc.drawLine(x + width - 2, y + height - 1, x + width - 2, y + height - 1);

 	

 			gc.setForeground(highlightShadow);

 			if (index != parent.topTabIndex) {

@@ -220,32 +198,19 @@
 				gc.drawLine(x, y, x, y + height - 1);

 			}

 			

-			gc.drawLine(x + width - 1, y,              x + width - 1, y);

-			gc.drawLine(x + width - 1, y + 1,          x + width - 1, y + height - 2);

-			gc.drawLine(x + width - 2, y + height - 1, x + width - 2, y + height - 1);

+			gc.drawLine(x + width - 2, y,              x + width - 2, y);

+			gc.drawLine(x + width - 2, y + 1,          x + width - 2, y + height - 2);

+			gc.drawLine(x + width - 3, y + height - 1, x + width - 3, y + height - 1);

 	

 			// light line across top and bottom

 			if (index != parent.topTabIndex) {

 				gc.drawLine(x + 1, y, x + width - 2, y);

-				gc.drawLine(x + 2, y + height - 1, x + width - 3, y + height - 1);

+				gc.drawLine(x + 2, y + height - 1, x + width - 4, y + height - 1);

 			} else {

 				gc.drawLine(x + 1, y, x + width - 2, y);

-				gc.drawLine(x + 1, y + height - 1, x + width - 3, y + height - 1);

+				gc.drawLine(x + 1, y + height - 1, x + width - 4, y + height - 1);

 			}			

 		}

-	} else {

-		// draw tab lines for unselected items

-		gc.setForeground(normalShadow);

-		if (!parent.onBottom) {

-			if (index != parent.topTabIndex && index != parent.getSelectionIndex() + 1) {

-				gc.drawLine(x, y, x, y + (height / 2));

-			}

-		} else {

-			if (index != parent.topTabIndex && index != parent.getSelectionIndex() + 1) {

-				gc.drawLine(x, y + (height / 2), x, y + height - 1);

-			}

-		}

-		

 	}

 

 	// draw Image

diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ControlEditor.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ControlEditor.java
index 9dfd02a..0d6cd7a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ControlEditor.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ControlEditor.java
@@ -168,6 +168,7 @@
  * composite and the editor Control are <b>not</b> disposed.

  */

 public void dispose () {

+

 	if (!parent.isDisposed()) {

 		parent.removeListener (SWT.Resize, internalListener);

 		ScrollBar hBar = parent.getHorizontalBar ();

diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultContent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultContent.java
index 5092566..51b9066 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultContent.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultContent.java
@@ -162,46 +162,6 @@
 	return false;

 }	

 /**

- * Determine whether or not the replace operation is valid.  DefaultContent will not allow

- * the /r/n line delimiter to be split or partially deleted.

- * <p>

- *

- * @param start	start offset of text to replace

- * @param replaceLength start offset of text to replace

- * @param newText start offset of text to replace

- */

-protected boolean isValidReplace(int start, int replaceLength, String newText){

-	if (replaceLength == 0) {

-		// inserting text, see if the \r\n line delimiter is being split

-		if (start == 0) return true;

-		if (start == getCharCount()) return true;

-		char before = getTextRange(start - 1, 1).charAt(0);

-		if (before == '\r') {

-			char after = getTextRange(start, 1).charAt(0);

-			if (after == '\n') return false;

-		}

-	} else {

-		// deleting text, see if part of a \r\n line delimiter is being deleted

-		char startChar = getTextRange(start, 1).charAt(0);

-		if (startChar == '\n') {

-			// see if char before delete position is \r

-			if (start != 0) {

-				char before = getTextRange(start - 1, 1).charAt(0);

-				if (before == '\r') return false;

-			}

-		}

-		char endChar = getTextRange(start + replaceLength - 1, 1).charAt(0);

-		if (endChar == '\r') {

-			// see if char after delete position is \n

-			if (start + replaceLength != getCharCount()) {

-				char after = getTextRange(start + replaceLength, 1).charAt(0);

-				if (after == '\n') return false;

-			}

-		}

-	} 

-	return true;

-}

-/**

  * Calculates the indexes of each line of text in the given range.

  * <p>

  *

@@ -753,18 +713,8 @@
  * @param start	start offset of text to replace

  * @param replaceLength start offset of text to replace

  * @param newText start offset of text to replace

- * 

- * @exception SWTException <ul>

- *   <li>ERROR_INVALID_ARGUMENT when the text change results in a multi byte

- *      line delimiter being split or partially deleted.  Splitting a line 

- *      delimiter by inserting text between the CR and LF characters of the 

- *      \r\n delimiter or deleting part of this line delimiter is not supported</li>

- * </ul>

  */

 public void replaceTextRange(int start, int replaceLength, String newText){

-	// check for invalid replace operations

-	if (!isValidReplace(start, replaceLength, newText)) SWT.error(SWT.ERROR_INVALID_ARGUMENT);		

-

 	// inform listeners

 	StyledTextEvent event = new StyledTextEvent(this);

 	event.type = StyledText.TextChanging;

diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java
index daadb8f..fced63b 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java
@@ -33,8 +33,6 @@
 	private int minWidth = 0;

 	private boolean expandHorizontal = false;

 	private boolean expandVertical = false;

-	private boolean alwaysShowScroll = false;

-	private boolean inResize = false;

 	

 public ScrolledComposite(Composite parent, int style) {

 	super(parent, checkStyle(style));

@@ -88,76 +86,9 @@
 	int hSelection = hBar.getSelection ();

 	content.setLocation (-hSelection, location.y);

 }

-private boolean needHScroll(Rectangle contentRect, boolean vVisible) {

-	ScrollBar hBar = getHorizontalBar();

-	if (hBar == null) return false;

-	

-	Rectangle hostRect = getBounds();

-	int border = getBorderWidth();

-	hostRect.width -= 2*border;

-	ScrollBar vBar = getVerticalBar();

-	if (vVisible && vBar != null) hostRect.width -= vBar.getSize().x;

-	

-	if (!expandHorizontal && contentRect.width > hostRect.width) return true;

-	if (expandHorizontal && minWidth > hostRect.width) return true;

-	return false;

-}

-private boolean needVScroll(Rectangle contentRect, boolean hVisible) {

-	ScrollBar vBar = getVerticalBar();

-	if (vBar == null) return false;

-	

-	Rectangle hostRect = getBounds();

-	int border = getBorderWidth();

-	hostRect.height -= 2*border;

-	ScrollBar hBar = getHorizontalBar();

-	if (hVisible && hBar != null) hostRect.height -= hBar.getSize().y;

-	

-	if (!expandHorizontal && contentRect.height > hostRect.height) return true;

-	if (expandHorizontal && minHeight > hostRect.height) return true;

-	return false;

-}

-

-/**

- * Returns the Always Show Scrollbars flag.  True if the scrollbars are 

- * always shown even if they are not required.  False if the scrollbars are only 

- * visible when some part of the composite needs to be scrolled to be seen.

- * The H_SCROLL and V_SCROLL style bits are also required to enable scrollbars in the 

- * horizontal and vertical directions.

- * 

- * @return the Always Show Scrollbars flag value

- */

-public boolean getAlwaysShowScrollBars() {

-	return alwaysShowScroll;

-}

-

-/**

- * Set the Always Show Scrollbars flag.  True if the scrollbars are 

- * always shown even if they are not required.  False if the scrollbars are only 

- * visible when some part of the composite needs to be scrolled to be seen.

- * The H_SCROLL and V_SCROLL style bits are also required to enable scrollbars in the 

- * horizontal and vertical directions.

- */

-public void setAlwaysShowScrollBars(boolean show) {

-	alwaysShowScroll = show;

-	resize();

-}

-

 private void resize() {

-	if (content == null || inResize) return;

-	inResize = true;

-	ScrollBar hBar = getHorizontalBar ();

-	ScrollBar vBar = getVerticalBar ();

+	if (content == null) return;

 	Rectangle contentRect = content.getBounds();

-	contentRect.x = contentRect.y = 0;

-	

-	if (!alwaysShowScroll) {

-		boolean hVisible = needHScroll(contentRect, false);

-		boolean vVisible = needVScroll(contentRect, hVisible);

-		if (!hVisible && vVisible) hVisible = needHScroll(contentRect, vVisible);

-		if (hBar != null) hBar.setVisible(hVisible);

-		if (vBar != null) vBar.setVisible(vVisible);

-	}

-

 	Rectangle hostRect = getClientArea();

 	if (expandHorizontal) {

 		contentRect.width = Math.max(minWidth, hostRect.width);	

@@ -165,7 +96,8 @@
 	if (expandVertical) {

 		contentRect.height = Math.max(minHeight, hostRect.height);

 	}

-

+	

+	ScrollBar hBar = getHorizontalBar ();

 	if (hBar != null) {

 		hBar.setMaximum (contentRect.width);

 		hBar.setThumb (Math.min (contentRect.width, hostRect.width));

@@ -176,7 +108,8 @@
 			contentRect.x = -hSelection;

 		}

 	}

-

+	

+	ScrollBar vBar = getVerticalBar ();

 	if (vBar != null) {

 		vBar.setMaximum (contentRect.height);

 		vBar.setThumb (Math.min (contentRect.height, hostRect.height));

@@ -189,9 +122,7 @@
 	}

 	

 	content.setBounds (contentRect);

-	inResize = false;

 }

-

 /**

  * Set the content that will be scrolled.

  */

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 5487dce..c65cfd4 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
@@ -9,7 +9,6 @@
 import org.eclipse.swt.events.*;

 import org.eclipse.swt.graphics.*;

 import org.eclipse.swt.widgets.*;

-import org.eclipse.swt.printing.*;

 import java.util.*;

 

 /**

@@ -3385,33 +3384,16 @@
 }

 /** 

  * Prints the widget's text to the default printer.

+ * <p>

  *

  * @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 print() {

-	checkWidget();

-	StyledTextPrinter.print(this);

-}

-

-/** 

- * Returns a runnable that will print the widget's text

- * to the specified printer.

- * <p>

- * The runnable may be run in a non-UI thread.

- * </p>

- * 

- * @param printer the printer to print to

- * @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 Runnable print(Printer printer) {

-	checkWidget();

-	return new StyledTextPrinter(this, printer);

+public void print()  {

+	checkWidget();	

+	new StyledTextPrinter(this).print();

 }

 

 /** 

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
index bc90308..27e6785 100755
--- 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
@@ -15,7 +15,7 @@
 import org.eclipse.swt.custom.*;

 import org.eclipse.swt.printing.*;

 

-class StyledTextPrinter implements Runnable {

+class StyledTextPrinter {

 	class RTFState {

 		int fontStyle;

 		int foreground;

@@ -23,20 +23,17 @@
 	}

 	Vector savedState = new Vector();

 	

+	StyledText styledText;

 	Printer printer;

 	GC gc;

+	

 	String rtf;

-	StringBuffer wordBuffer;

 	int index, end;

-	String tabs = "";

-	int tabWidth = 0;

-	int lineHeight = 0;

-	int leftMargin, rightMargin, topMargin, bottomMargin;

-	int x, y;

+	StringBuffer wordBuffer;

 

 	/* 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.

+	 * Fonts for the following styles: normal, bold, italic, and bold italic.

 	 */

 	Font fontTable[][] = new Font[1][4];

 	boolean creatingFontTable = false;

@@ -52,27 +49,19 @@
 	int currentForeground = -1;

 	int currentBackground = -1;

 	

-	static void print(StyledText styledText) {

-		Printer printer = new Printer();

-		new StyledTextPrinter(styledText, printer).run();

-		printer.dispose();

+	String tabs = "";

+	int lineHeight = 0;

+	int tabWidth = 0;

+	int leftMargin, rightMargin, topMargin, bottomMargin;

+	int x, y;

+

+	public StyledTextPrinter(StyledText styledText) {

+		this.styledText = styledText;

 	}

 	

-	StyledTextPrinter(StyledText styledText, Printer printer) {

-		this.printer = printer;

-

-		/* 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")) {

+	public void print() {

+		printer = new Printer();

+		if (printer.startJob("StyledText")) {

 			Rectangle clientArea = printer.getClientArea();

 			Rectangle trim = printer.computeTrim(0, 0, 0, 0);

 			Point dpi = printer.getDPI();

@@ -81,41 +70,17 @@
 			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. */

+			/* 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, determine what fonts and colors we need, and print. */

 			gc = new GC(printer);

 			x = leftMargin;

 			y = topMargin;

-			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();

-			}

+			printStyledTextRTF();

 			printer.endJob();

 

 			/* Cleanup */

@@ -127,6 +92,38 @@
 				((Color)colorTable.elementAt(i)).dispose();

 			}

 		}

+		printer.dispose();

+	}

+	

+	void printStyledTextRTF() {

+		rtf = styledText.getRtf();

+		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);

+			}

+		}

 	}

 	

 	void parseControlWord() {

@@ -217,12 +214,12 @@
 	}

 	

 	void handleControlSymbol(char c) {

-		switch (c) {

-			case '\\':

-			case '{':

-			case '}':

-				parseChar(c);

-		}

+			switch (c) {

+				case '\\':

+				case '{':

+				case '}':

+					parseChar(c);

+			}

 	}

 	

 	void handleControlWord(String controlWord) {

diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Clipboard.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Clipboard.java
index 4bf7a12..424a799 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Clipboard.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Clipboard.java
@@ -95,7 +95,6 @@
 	// Pass data to transfer agent for conversion to a Java Object

 	// Memory is allocated here to emulate the way Drag and Drop transfers data.

 	TransferData transferData = new TransferData();

-	/* Use the character encoding for the default locale */

 	byte[] bName = Converter.wcsToMbcs (null, type, false);

 	transferData.type = OS.XmInternAtom (xDisplay, bName, false);

 	transferData.pValue = OS.XtMalloc(data.length);

@@ -146,7 +145,6 @@
 		for (int j = 0; j < names.length; j++) {

 		

 			TransferData transferData = new TransferData();

-			/* Use the character encoding for the default locale */

 			byte[] bName = Converter.wcsToMbcs (null, names[j], false);

 			transferData.type    = OS.XmInternAtom (xDisplay, bName, false);

 			transferAgents[i].javaToNative(data[i], transferData);

diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Transfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Transfer.java
index adfd307..9de9048 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Transfer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Transfer.java
@@ -54,7 +54,6 @@
 public static int registerType(String formatName){

 

 	int xDisplay = Display.getDefault().xDisplay; // using default because we don't have a particular widget

-	/* Use the character encoding for the default locale */

 	byte[] bName = Converter.wcsToMbcs (null, formatName, false);

 	int atom = OS.XmInternAtom (xDisplay, bName, false); 

 	return atom;

diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/ByteArrayTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/ByteArrayTransfer.java
index 0786eb5..63f1eb6 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/ByteArrayTransfer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/ByteArrayTransfer.java
@@ -30,19 +30,19 @@
 		return;

 	}

 	byte[] buffer = (byte[])object;	

-	transferData.pData = OS.malloc(buffer.length);

-	OS.memmove(transferData.pData, buffer, buffer.length);

+//	transferData.pValue = OS.XtMalloc(buffer.length + 1);

+//	OS.memmove(transferData.pValue, buffer, buffer.length);

 	transferData.length = buffer.length;

+	transferData.format = 8;

 	transferData.result = 1;

 }

 protected Object nativeToJava(TransferData transferData){

 

-	if (transferData.pData == 0 || !(isSupportedType(transferData))) return null;

+	if (transferData.pValue == 0 || !(isSupportedType(transferData))) return null;

 	

-	int size = transferData.length;

-	if (size == 0) return null;

+	int size = transferData.format * transferData.length / 8;

 	byte[] buffer = new byte[size];

-	OS.memmove(buffer, transferData.pData, size);

+//	OS.memmove(buffer, transferData.pValue, size);

 	return buffer;

 }

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Clipboard.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Clipboard.java
index 217166c..bd8b75d 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Clipboard.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Clipboard.java
@@ -19,6 +19,7 @@
 	

 	private Display display;

 	private final int MAX_RETRIES = 10;

+	private int shellHandle;

 

 

 public Clipboard(Display display) {	

@@ -33,6 +34,11 @@
 		SWT.error(SWT.ERROR_THREAD_INVALID_ACCESS);

 	}

 	this.display = display;

+	

+//	int widgetClass = OS.TopLevelShellWidgetClass ();

+//	shellHandle = OS.XtAppCreateShell (null, null, widgetClass, display.xDisplay, null, 0);

+//	OS.XtSetMappedWhenManaged (shellHandle, false);

+//	OS.XtRealizeWidget (shellHandle);

 }

 protected void checkSubclass () {

 	String name = getClass().getName ();

@@ -42,92 +48,15 @@
 	}

 }

 public void dispose () {

+//	if (shellHandle != 0) OS.XtDestroyWidget (shellHandle);

+//	shellHandle = 0;

 	display = null;

 }

 public Object getContents(Transfer transfer) {

 	if (display.isDisposed() ) return null;

-	

-	Object result = null;

-	

-	int ig = OS.PhInputGroup(0);

-	int cbdata = OS.PhClipboardPasteStart((short)ig);

-	if (cbdata == 0) return result;

-	try {

-		String[] types = transfer.getTypeNames();

-		int[] ids = transfer.getTypeIds();

-		for (int i = 0; i < types.length; i++) {

-			byte[] type = Converter.wcsToMbcs(null, types[i], true);

-			int pClipHeader = OS.PhClipboardPasteType(cbdata, type);

-			if (pClipHeader != 0) {

-				PhClipHeader clipHeader = new PhClipHeader();

-				OS.memmove(clipHeader, pClipHeader, PhClipHeader.sizeof);

-				TransferData data = new TransferData();

-				data.pData = clipHeader.data;

-				data.length = clipHeader.length;

-				data.type = ids[i];

-				result = transfer.nativeToJava(data);

-				break;

-			}

-		}

-	} finally {

-		OS.PhClipboardPasteFinish(cbdata);

-	}

-	

-	return result;

+	return null;

 }

 public void setContents(Object[] data, Transfer[] transferAgents){

-	if (display.isDisposed() ) return;

-	

-	if (data == null) {

-		int ig = OS.PhInputGroup(0);

-		if (OS.PhClipboardCopy((short)ig, 0, null) != 0) {

-			DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);

-		}

-		return;

-	}

-	if (transferAgents == null || data.length != transferAgents.length) {

-		DND.error(SWT.ERROR_INVALID_ARGUMENT);

-	}

-	

-	byte[] clips = new byte[0];

-	int count = 0;

-	for (int i = 0; i < transferAgents.length; i++) {

-		String[] names = transferAgents[i].getTypeNames();

-		int[] ids = transferAgents[i].getTypeIds();

-		for (int j = 0; j < names.length; j++) {

-			TransferData transferData = new TransferData();

-			transferData.type = ids[j];

-			transferAgents[i].javaToNative(data[i], transferData);

-			PhClipHeader clip = new PhClipHeader();

-			clip.data = transferData.pData;

-			clip.length = (short)transferData.length;

-			byte[] temp = Converter.wcsToMbcs(null, names[j], false);

-			byte[] type = new byte[8];

-			System.arraycopy(temp, 0, type, 0, Math.min(type.length, temp.length));

-			clip.type_0 = type[0];

-			clip.type_1 = type[1];

-			clip.type_2 = type[2];

-			clip.type_3 = type[3];

-			clip.type_4 = type[4];

-			clip.type_5 = type[5];

-			clip.type_6 = type[6];

-			clip.type_7 = type[7];

-			byte[] buffer = new byte[PhClipHeader.sizeof];

-			OS.memmove(buffer, clip, PhClipHeader.sizeof);

-			byte[] newClips = new byte[clips.length + buffer.length];

-			System.arraycopy(clips, 0, newClips, 0, clips.length);

-			System.arraycopy(buffer, 0, newClips, clips.length, buffer.length);

-			clips = newClips;

-			count++;

-		}

-	}

-	

-	if (count > 0){

-		int ig = OS.PhInputGroup(0);

-		if (OS.PhClipboardCopy((short)ig, count, clips) != 0) {

-			DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);

-		}

-	}

 }

 /*

  * Note: getAvailableTypeNames is a tool for writing a Transfer sub-class only.  It should

@@ -135,35 +64,31 @@
  * information.

  */

 public String[] getAvailableTypeNames() {

-	String[] types = new String[0];

-	int ig = OS.PhInputGroup(0);

-	int cbdata = OS.PhClipboardPasteStart((short)ig);

-	if (cbdata == 0) return types;

-	try {

-		int pClipHeader = 0;

-		int n = 0;

-		while ((pClipHeader = OS.PhClipboardPasteTypeN(cbdata, n++)) != 0) {

-			PhClipHeader clipHeader = new PhClipHeader();

-			OS.memmove(clipHeader, pClipHeader, PhClipHeader.sizeof);

-			byte[] buffer = new byte[8];

-			buffer[0] = clipHeader.type_0;

-			buffer[1] = clipHeader.type_1;

-			buffer[2] = clipHeader.type_2;

-			buffer[3] = clipHeader.type_3;

-			buffer[4] = clipHeader.type_4;

-			buffer[5] = clipHeader.type_5;

-			buffer[6] = clipHeader.type_6;

-			buffer[7] = clipHeader.type_7;

-			char [] unicode = Converter.mbcsToWcs (null, buffer);

-			

-			String[] newTypes = new String[types.length + 1];

-			System.arraycopy(types, 0, newTypes, 0, types.length);

-			newTypes[types.length] = new String (unicode).trim();

-			types = newTypes;

-		}

-	} finally {

-		OS.PhClipboardPasteFinish(cbdata);

-	}

+	int[] count = new int[1];

+	int[] max_length = new int[1];

+//	int xDisplay = OS.XtDisplay (shellHandle);

+//	if (xDisplay == 0)

+//		DND.error(SWT.ERROR_UNSPECIFIED);

+//	int xWindow = OS.XtWindow (shellHandle);

+//	if (xWindow == 0)

+//		DND.error(SWT.ERROR_UNSPECIFIED);

+//	if (OS.XmClipboardInquireCount(xDisplay, xWindow, count, max_length) != OS.XmClipboardSuccess)

+//		DND.error(SWT.ERROR_UNSPECIFIED);

+	String[] types = new String[count[0]];

+//	for (int i = 0; i < count[0]; i++) {

+//		byte[] buffer = new byte[max_length[0]];

+//		int[] copied_length = new int[1];

+//		int rc = OS.XmClipboardInquireFormat(xDisplay, xWindow, i + 1, buffer, buffer.length, copied_length);

+//		if (rc == OS.XmClipboardNoData){

+//			types[i] = "";

+//			continue;

+//		}

+//		if (rc != OS.XmClipboardSuccess)

+//			DND.error(SWT.ERROR_UNSPECIFIED);

+//		byte[] buffer2 = new byte[copied_length[0]];

+//		System.arraycopy(buffer, 0, buffer2, 0, copied_length[0]);

+//		types[i] = new String(buffer2);

+//	}

 	return types;

 }

 }
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/FileTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/FileTransfer.java
index f311c62..54044a0 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/FileTransfer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/FileTransfer.java
@@ -8,7 +8,7 @@
 public class FileTransfer extends ByteArrayTransfer {

 	

 	private static FileTransfer _instance = new FileTransfer();

-	private static final String TYPENAME = "files";

+	private static final String TYPENAME = "text/uri-list\0";

 	private static final int TYPEID = registerType(TYPENAME);

 

 private FileTransfer() {}

@@ -16,11 +16,46 @@
 	return _instance;

 }

 public void javaToNative(Object object, TransferData transferData) {

-	DND.error(org.eclipse.swt.SWT.ERROR_NOT_IMPLEMENTED);

+

+	if (object == null || !(object instanceof String[])) return;

+		

+	// build a byte array from data

+	String[] files = (String[])object;

+	

+	// create a string separated by "new lines" to represent list of files

+	String nativeFormat = "file:";

+	for (int i = 0, length = files.length; i < length; i++){

+		nativeFormat += files[i]+"\r";

+	}

+	nativeFormat += "\0";

+	// pass byte array on to super to convert to native

+	super.javaToNative(nativeFormat.getBytes(), transferData);

 }

 public Object nativeToJava(TransferData transferData) {

-	DND.error(org.eclipse.swt.SWT.ERROR_NOT_IMPLEMENTED);

-	return null;

+

+	byte[] data = (byte[])super.nativeToJava(transferData);

+	if (data == null) return null;

+	String string  = new String(data);

+	// parse data and convert string to array of files

+	int start = string.indexOf("file:");

+	if (start == -1) return null;

+	start += 5;

+	String[] fileNames = new String[0];

+	while (start < string.length()) { 

+		int end = string.indexOf("\r", start);

+		if (end == -1) end = string.length() - 1;

+		

+		String fileName = string.substring(start, end);

+		String[] newFileNames = new String[fileNames.length + 1];

+		System.arraycopy(fileNames, 0, newFileNames, 0, fileNames.length);

+		newFileNames[fileNames.length] = fileName;

+		fileNames = newFileNames;

+

+		start = string.indexOf("file:", end);

+		if (start == -1) break;

+		start += 5;

+	}

+	return fileNames;

 }

 protected String[] getTypeNames(){

 	return new String[]{TYPENAME};

diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/RTFTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/RTFTransfer.java
index 4092a3f..d36e656 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/RTFTransfer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/RTFTransfer.java
@@ -1,6 +1,5 @@
 package org.eclipse.swt.dnd;

 

-import org.eclipse.swt.internal.Converter;

 /*

  * (c) Copyright IBM Corp. 2000, 2001.

  * All Rights Reserved

@@ -9,8 +8,12 @@
 public class RTFTransfer extends ByteArrayTransfer {

 

 	private static RTFTransfer _instance = new RTFTransfer();

-	private static final String TYPENAME = "RTF";

-	private static final int TYPEID = registerType(TYPENAME);

+	private static final String TYPENAME1 = "text/rtf\0";

+	private static final int TYPEID1 = registerType(TYPENAME1);

+	private static final String TYPENAME2 = "TEXT/RTF\0";

+	private static final int TYPEID2 = registerType(TYPENAME2);

+	private static final String TYPENAME3 = "application/rtf\0";

+	private static final int TYPEID3 = registerType(TYPENAME3);

 

 private RTFTransfer() {

 }

@@ -19,21 +22,21 @@
 }

 public void javaToNative (Object object, TransferData transferData){

 	if (object == null || !(object instanceof String)) return;

-	byte [] buffer = Converter.wcsToMbcs (null, (String)object, false);

-	super.javaToNative(buffer, transferData);

+

+	String text = (String)object;

+	super.javaToNative(text.getBytes(), transferData);

 }

 public Object nativeToJava(TransferData transferData){

-	/// get byte array from super

+	// get byte array from super

 	byte[] buffer = (byte[])super.nativeToJava(transferData);

 	if (buffer == null) return null;

 	// convert byte array to a string

-	char [] unicode = Converter.mbcsToWcs (null, buffer);

-	return new String (unicode);

+	return new String(buffer);

 }

 protected String[] getTypeNames(){

-	return new String[]{TYPENAME};

+	return new String[]{TYPENAME1, TYPENAME2, TYPENAME3};

 }

 protected int[] getTypeIds(){

-	return new int[]{TYPEID};

+	return new int[]{TYPEID1, TYPEID2, TYPEID3};

 }

 }
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TextTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TextTransfer.java
index 685aabc..e658794 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TextTransfer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TextTransfer.java
@@ -1,8 +1,5 @@
 package org.eclipse.swt.dnd;

 

-import org.eclipse.swt.internal.Converter;

-import org.eclipse.swt.internal.photon.OS;

-

 /*

  * (c) Copyright IBM Corp. 2000, 2001.

  * All Rights Reserved

@@ -11,8 +8,12 @@
 public class TextTransfer extends ByteArrayTransfer {

 

 	private static TextTransfer _instance = new TextTransfer();

-	private static final String TYPENAME = "TEXT";

-	private static final int TYPEID = registerType(TYPENAME);

+	private static final String TYPENAME1 = "STRING\0";

+	private static final int TYPEID1 = registerType(TYPENAME1);

+	private static final String TYPENAME2 = "text/plain\0";

+	private static final int TYPEID2 = registerType(TYPENAME2);

+	private static final String TYPENAME3 = "text/text\0";

+	private static final int TYPEID3 = registerType(TYPENAME3);

 

 private TextTransfer() {

 }

@@ -21,21 +22,21 @@
 }

 public void javaToNative (Object object, TransferData transferData){

 	if (object == null || !(object instanceof String)) return;

-	byte [] buffer = Converter.wcsToMbcs (null, (String)object, false);

-	super.javaToNative(buffer, transferData);

+

+	String text = (String)object;

+	super.javaToNative(text.getBytes(), transferData);

 }

 public Object nativeToJava(TransferData transferData){

 	// get byte array from super

 	byte[] buffer = (byte[])super.nativeToJava(transferData);

 	if (buffer == null) return null;

 	// convert byte array to a string

-	char [] unicode = Converter.mbcsToWcs (null, buffer);

-	return new String (unicode);

+	return new String(buffer);

 }

 protected String[] getTypeNames(){

-	return new String[]{TYPENAME};

+	return new String[]{TYPENAME1, TYPENAME2, TYPENAME3};

 }

 protected int[] getTypeIds(){

-	return new int[]{TYPEID};

+	return new int[]{TYPEID1, TYPEID2, TYPEID3};

 }

 }
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Transfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Transfer.java
index 95d9283..3634d35 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Transfer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Transfer.java
@@ -13,9 +13,6 @@
 abstract protected void javaToNative (Object object, TransferData transferData);

 abstract protected Object nativeToJava(TransferData transferData);

 public static int registerType(String formatName){

-	if (formatName == "TEXT") return 10;

-	if (formatName == "files") return 11;

-	if (formatName == "RTF") return 12;

 	return 0;

 }

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TransferData.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TransferData.java
index ae75ee6..50eabd1 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TransferData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TransferData.java
@@ -9,7 +9,10 @@
 	public int type;

 	

 	// attributes specific to set/get

-	int pData;

 	int length;

+	int format;

+	int pValue;

+

 	int result;

+	

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java
index 63c3318..dd6d8e8 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java
@@ -359,7 +359,6 @@
 	

 	if (extension.charAt (0) != '.') extension = "." + extension;

 

-	/* Use the character encoding for the default locale */

 	byte[] extensionKey = Converter.wcsToMbcs(0, extension, true);

 	String result = getKeyValue(extensionKey);

 	if (result != null) {

@@ -386,7 +385,6 @@
 	if (OS.RegQueryValueEx (phkResult [0], null, 0, null, null, lpcbData) == 0) {

 		byte [] lpData = new byte [lpcbData [0]];

 		if (OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData) == 0) {

-			/* Use the character encoding for the default locale */

 			char[] charArray  = Converter.mbcsToWcs (0, lpData);

 			result =  new String(charArray, 0, charArray.length - 1);

 		}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java
index ed6c498..87d4432 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java
@@ -199,9 +199,6 @@
 				if (site.handle == hwnd) {

 					OleFrame frame = site.frame;

 					if (frame.translateOleAccelerator(msg)) {

-						// In order to prevent this message from also being processed

-						// by the application, zero out message, wParam and lParam

-						OS.MoveMemory(lParam + 4, new int[] {OS.WM_NULL, 0, 0}, 12);

 						return 0;

 					}

 				}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/motif/org/eclipse/swt/printing/Printer.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/motif/org/eclipse/swt/printing/Printer.java
index 8153f26..b3685e7 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/motif/org/eclipse/swt/printing/Printer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/motif/org/eclipse/swt/printing/Printer.java
@@ -77,7 +77,6 @@
 			int length = OS.strlen(address);

 			byte[] buffer = new byte [length];

 			OS.memmove(buffer, address, length);

-			/* Use the character encoding for the default locale */

 			name = new String(Converter.mbcsToWcs(null, buffer));

 		}

 		printerList[i] = new PrinterData(Device.XDefaultPrintServer, name);

@@ -151,7 +150,6 @@
 	super.init();

 	

 	/* Create the printContext for the printer */

-	/* Use the character encoding for the default locale */

 	byte[] name = Converter.wcsToMbcs(null, data.name, true);

 	printContext = OS.XpCreateContext(xDisplay, name);

 	if (printContext == OS.None) {

@@ -172,7 +170,6 @@
 	OS.XtDestroyWidget(shellHandle);

 	

 	/* Initialize the default font */

-	/* Use the character encoding for the default locale */

 	byte [] buffer = Converter.wcsToMbcs(null, "-*-courier-medium-r-*-*-*-120-*-*-*-*-*-*", true);

 	int fontListEntry = OS.XmFontListEntryLoad(xDisplay, buffer, 0, OS.XmFONTLIST_DEFAULT_TAG);

 	if (fontListEntry == 0) SWT.error(SWT.ERROR_NO_HANDLES);

@@ -254,7 +251,6 @@
  */
 public boolean startJob(String jobName) {

 	checkDevice();

-	/* Use the character encoding for the default locale */

 	byte [] buffer = Converter.wcsToMbcs(null, "*job-name: " + jobName, true);

 	OS.XpSetAttributes(xDisplay, printContext, OS.XPJobAttr, buffer, OS.XPAttrMerge);

 	OS.XpStartJob(xDisplay, OS.XPSpool);

@@ -352,7 +348,6 @@
  */
 public Point getDPI() {

 	checkDevice();

-	/* Use the character encoding for the default locale */

 	byte [] buffer = Converter.wcsToMbcs(null, "default-printer-resolution", true);

 	int pool = OS.XpGetOneAttribute(xDisplay, printContext, OS.XPDocAttr, buffer);

     int length = OS.strlen(pool);

@@ -363,7 +358,6 @@
 	int res = 300; // default

 	if (resolution.length() == 0) {

 		/* If we can't get the info from the DocAttrs, ask the printer. */

-		/* Use the character encoding for the default locale */

 		buffer = Converter.wcsToMbcs(null, "printer-resolutions-supported", true);

 		pool = OS.XpGetOneAttribute(xDisplay, printContext, OS.XPPrinterAttr, buffer);

     		length = OS.strlen(pool);

@@ -463,12 +457,14 @@
 	return new Rectangle(x - rect.x, y - rect.y, width + hTrim, height + vTrim);

 }

 

-/**

- * Returns a <code>PrinterData</code> object representing the

- * target printer for this print job.

- * 

- * @return a PrinterData object describing the receiver

- */

+/**
+ * Returns an array of <code>FontData</code>s representing the receiver.
+ * On Windows, only one FontData will be returned per font. On X however, 
+ * a <code>Font</code> object <em>may</em> be composed of multiple X 
+ * fonts. To support this case, we return an array of font data objects.
+ *
+ * @return an array of font data objects describing the receiver
+ */
 public PrinterData getPrinterData() {

 	return data;

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/photon/org/eclipse/swt/printing/Printer.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/photon/org/eclipse/swt/printing/Printer.java
index 9e19c3c..5e4b195 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/photon/org/eclipse/swt/printing/Printer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/photon/org/eclipse/swt/printing/Printer.java
@@ -79,12 +79,6 @@
 	return new Rectangle(0,0,0,0);

 }

 

-/**

- * Returns a <code>PrinterData</code> object representing the

- * target printer for this print job.

- * 

- * @return a PrinterData object describing the receiver

- */

 public PrinterData getPrinterData() {

 	return data;

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java
index a59c5d6..4554b3c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java
@@ -186,7 +186,6 @@
  */

 protected void create(DeviceData deviceData) {

 	data = (PrinterData)deviceData;

-	/* Use the character encoding for the default locale */

 	byte[] driver = Converter.wcsToMbcs(0, data.driver, true);

 	byte[] device = Converter.wcsToMbcs(0, data.name, true);

 	int lpInitData = 0;

@@ -273,7 +272,6 @@
 	int hHeap = OS.GetProcessHeap();

 	int lpszDocName = 0;

 	if (jobName != null && jobName.length() != 0) {

-		/* Use the character encoding for the default locale */

 		byte [] buffer = Converter.wcsToMbcs(0, jobName, true);

 		lpszDocName = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, buffer.length);

 		OS.MoveMemory(lpszDocName, buffer, buffer.length);

@@ -281,7 +279,6 @@
 	}

 	int lpszOutput = 0;

 	if (data.printToFile && data.fileName != null) {

-		/* Use the character encoding for the default locale */

 		byte [] buffer = Converter.wcsToMbcs(0, data.fileName, true);

 		lpszOutput = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, buffer.length);

 		OS.MoveMemory(lpszOutput, buffer, buffer.length);

@@ -462,10 +459,12 @@
 }

 

 /**

- * Returns a <code>PrinterData</code> object representing the

- * target printer for this print job.

- * 

- * @return a PrinterData object describing the receiver

+ * Returns an array of <code>FontData</code>s representing the receiver.

+ * On Windows, only one FontData will be returned per font. On X however, 

+ * a <code>Font</code> object <em>may</em> be composed of multiple X 

+ * fonts. To support this case, we return an array of font data objects.

+ *

+ * @return an array of font data objects describing the receiver

  */

 public PrinterData getPrinterData() {

 	return data;

diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/motif/org/eclipse/swt/program/Program.java b/bundles/org.eclipse.swt/Eclipse SWT Program/motif/org/eclipse/swt/program/Program.java
index 5f58b97..52f5f9b 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Program/motif/org/eclipse/swt/program/Program.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Program/motif/org/eclipse/swt/program/Program.java
@@ -1,1065 +1,700 @@
-package org.eclipse.swt.program;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved
- */
- 
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-import org.eclipse.swt.widgets.Display;
-
-import java.io.*;
-import java.util.Iterator;
-import java.util.Hashtable;
-import java.util.Vector;
-
+package org.eclipse.swt.program;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+ 

+import org.eclipse.swt.internal.*;

+import org.eclipse.swt.internal.motif.*;

+import org.eclipse.swt.*;

+import org.eclipse.swt.graphics.*;

+

+import org.eclipse.swt.widgets.Display;

+

+import java.io.*;

+import java.util.Iterator;

+import java.util.Hashtable;

+import java.util.Vector;

+

 /**
  * Instances of this class represent programs and
  * their assoicated file extensions in the operating
  * system.
- */
-public final class Program {	
-	String name;
-	String extension;
-	String command;
-	Display display;
-
-	static private final String   cdeShell = "Program_CDE_SHELL";  // hidden shell used for DtAppInitialize and DtActionInvoke
-	static private final String[] cdeIconExt = { ".m.pm",   ".l.pm",   ".s.pm",   ".t.pm" };
-	static private final String[] cdeMaskExt = { ".m_m.bm", ".l_m.bm", ".s_m.bm", ".t_m.bm" };
-	static private final String   desktopData = "Program_DESKTOP";
-		
-	static final int DESKTOP_UNKNOWN = 0;
-	static final int DESKTOP_KDE = 1;
-	static final int DESKTOP_GNOME = 2;
-    static final int DESKTOP_CDE = 3;
-	
-/**
- * Prevents uninitialized instances from being created outside the package.
- */
-Program () {
-}
-
-/* Determine the desktop for the given display. */
-static int getDesktop( Display display ) {
-	if (display == null) return DESKTOP_UNKNOWN;
-	
-	// If the desktop type for this display is already known, return it.
-	Integer desktopValue = (Integer) display.getData( desktopData );
-	if (desktopValue != null) {
-		return desktopValue.intValue();
-	}
-	
-	// Obtain the atoms for the various window manager signature properties.
-	int desktop = DESKTOP_UNKNOWN;
-	int xDisplay = display.xDisplay;
-	/* Use the character encoding for the default locale */
-	byte[] gnomeName = Converter.wcsToMbcs (null, "GNOME_NAME_SERVER", true);
-	byte[] cdeName   = Converter.wcsToMbcs (null, "DTWM_IS_RUNNING", true);
-	byte[] kdeName   = Converter.wcsToMbcs (null, "KWIN_RUNNING", true);
-	int gnome = OS.XInternAtom( xDisplay, gnomeName, true );
-	int cde   = OS.XInternAtom( xDisplay, cdeName, true );
-	int kde   = OS.XInternAtom( xDisplay, kdeName, true );
-	
-	// Get the list of properties on the root window.
-	int   rootWindow = OS.XDefaultRootWindow( xDisplay );
-	int[] numProp = new int[1];
-	int   propList = OS.XListProperties( xDisplay, rootWindow, numProp );
-	if (propList == 0) return DESKTOP_UNKNOWN;
-	int[] property = new int[ numProp[0] ];
-	OS.memmove( property, propList, (property.length * 4) );
-	OS.XFree( propList );
-	
-	// A given WM (desktop) is active if the property exists on the root window.
-	for (int index = 0; desktop == DESKTOP_UNKNOWN && index < property.length; index++) {
-		if (property[ index ] == OS.None) continue; // do not match atoms that do not exist
-		if (property[ index ] == gnome) {
-			if (gnome_init()) desktop = DESKTOP_GNOME;		
-		}
-		if (property[ index ] == cde) {
-			if (cde_init( display )) desktop = DESKTOP_CDE;
-		}	
-		if (property[ index ] == kde) {
-			if (kde_init()) desktop = DESKTOP_KDE;
-		}	
-	}
-	
-	// Save the desktop type on the display itself.
-	display.setData( desktopData, new Integer(desktop) );
-	return desktop;
-}
-
-/**
- * Finds the program that is associated with an extension.
- * The extension may or may not begin with a '.'.
- *
- * @param extension the program extension
- * @return the program or nil
- *
- * @exception SWTError <ul>
- *		<li>ERROR_NULL_ARGUMENT when extension is null</li>
- *	</ul>
- */
-public static Program findProgram (String extension) {
-	return findProgram( Display.getCurrent(), extension );
-}
-
-/*
- *  API: When support for multiple displays is added, this method will
- *       become public and the original method above can be deprecated.
- */
-private static Program findProgram( Display display, String extension ) {
-	if (extension == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
-	if (extension.length () == 0) return null;
-	if (extension.charAt (0) != '.') extension = "." + extension;
-	String command = null;
-	String name = null;
-	int desktop = getDesktop( display );
-	Hashtable mimeInfo = null;
-	if (desktop == DESKTOP_KDE)   mimeInfo = kde_getMimeInfo();
-	if (desktop == DESKTOP_GNOME) mimeInfo = gnome_getMimeInfo();
-	if (desktop == DESKTOP_CDE)   mimeInfo = cde_getDataTypeInfo();
-	if (mimeInfo == null) return null;
-
-	// Find the data type matching the extension.
-	Iterator keys = mimeInfo.keySet().iterator();
-	while (name == null && keys.hasNext()) {
-		String mimeType = (String) keys.next();
-		Vector mimeExts = (Vector) mimeInfo.get( mimeType );
-		for (int index = 0; index < mimeExts.size(); index++){
-			if (extension.equals( mimeExts.elementAt( index ) )) {
-				name = mimeType;
-			}
-		}
-	}			
-	if (name == null) return null;
-
-	// Get the corresponding command for the mime type.
-	if (desktop == DESKTOP_KDE)   command = kde_getMimeTypeCommand( name );
-	if (desktop == DESKTOP_GNOME) command = gnome_getMimeValue( name, "open" );
-	if (desktop == DESKTOP_CDE)   command = cde_getAction( name );
-	if (command == null) return null;
-	
-	// Return the corresponding program.
-	Program program   = new Program ();
-	program.name      = name;
-	program.command   = command;
-	program.extension = extension;
-	program.display   = display;
-	return program;
-}
-
-/**
- * Answer all program extensions in the operating system.
- *
- * @return an array of extensions
- */
-public static String [] getExtensions () {
-	return getExtensions( Display.getCurrent() );
-}
-
-/*
- *  API: When support for multiple displays is added, this method will
- *       become public and the original method above can be deprecated.
- */
-private static String[] getExtensions( Display display ) {
-	int desktop = getDesktop( display );
-	Hashtable mimeInfo = null;
-	if (desktop == DESKTOP_KDE)   mimeInfo = kde_getMimeInfo();
-	if (desktop == DESKTOP_GNOME) mimeInfo = gnome_getMimeInfo();
-	if (desktop == DESKTOP_CDE)   mimeInfo = cde_getDataTypeInfo();
-	if (mimeInfo == null) return new String[0];
-
-			
-	// Create a unique set of the file extensions.
-	Vector extensions = new Vector();
-	Iterator keys = mimeInfo.keySet().iterator();
-	while (keys.hasNext()) {
-		String mimeType = (String) keys.next();
-		Vector mimeExts = (Vector) mimeInfo.get( mimeType );
-		for (int index = 0; index < mimeExts.size(); index++){
-			if (!extensions.contains( mimeExts.elementAt( index ) )) {
-				extensions.add( mimeExts.elementAt( index ) );
-			}
-		}
-	}
-			
-	// Return the list of extensions.
-	String[] extStrings = new String[ extensions.size() ];
-	for (int index = 0; index < extensions.size(); index++) {
-		extStrings[ index ] = (String) extensions.elementAt( index );
-	}			
-	return extStrings;
-}
-
-/**
- * Answers all available programs in the operating system.
- *
- * @return an array of programs
- */
-public static Program [] getPrograms () {
-	return getPrograms( Display.getCurrent() );
-}
-
-/*
- *  API: When support for multiple displays is added, this method will
- *       become public and the original method above can be deprecated.
- */
-private static Program[] getPrograms( Display display ) {
-	int desktop = getDesktop( display );
-	Hashtable mimeInfo = null;
-	if (desktop == DESKTOP_KDE)   mimeInfo = kde_getMimeInfo();
-	if (desktop == DESKTOP_GNOME) mimeInfo = gnome_getMimeInfo();
-	if (desktop == DESKTOP_CDE)   mimeInfo = cde_getDataTypeInfo();
-	if (mimeInfo == null) return new Program[0];
-			
-	// Create a list of programs with commands.
-	Vector programs = new Vector();
-	Iterator keys = mimeInfo.keySet().iterator();
-	while (keys.hasNext()) {
-		String mimeType  = (String) keys.next();
-		Vector mimeExts  = (Vector) mimeInfo.get( mimeType );
-		String extension = "";
-		if (mimeExts.size() > 0){
-			extension = (String) mimeExts.elementAt( 0 );
-		}
-		String command = null;
-		if (desktop == DESKTOP_KDE)   command = kde_getMimeTypeCommand( mimeType );
-		if (desktop == DESKTOP_GNOME) command = gnome_getMimeValue( mimeType, "open" );
-		if (desktop == DESKTOP_CDE)   command = cde_getAction( mimeType );
-		if (command != null) {
-			Program program   = new Program ();
-			program.name      = mimeType;
-			program.command   = command;
-			program.extension = extension;
-			program.display   = display;
-			programs.add( program );
-		}
-	}
-			
-	// Return the list of programs to the user.
-	Program[] programList = new Program[ programs.size() ];
-	for (int index = 0; index < programList.length; index++) {
-		programList[ index ] = (Program) programs.elementAt( index );
-	}
-	return programList;
-}
-
-/*
- * Obtain the registered mime type information and
- * return it in a map. The key of each entry
- * in the map is the mime type name. The value is
- * a vector of the associated file extensions.
- */
-  
-private static Hashtable gnome_getMimeInfo() {
-	Hashtable mimeInfo = new Hashtable();
-	
-	// Extract the mime info from the system directory.
-	String mimeDirectory = gnome_getDataDirectory ("mime-info");
-	gnome_getMimeInfoFromDirectory( mimeInfo, new File( mimeDirectory ) );
-	
-	// Append the mime info from the user's directory (if it exists).
-	String userDirectory = gnome_getHomeDirectory();
-	if (userDirectory != null) {
-		userDirectory = userDirectory + File.separator + ".gnome" + File.separator + "mime-info";
-		gnome_getMimeInfoFromDirectory( mimeInfo, new File( userDirectory ) );
-	}
-
-	return mimeInfo;
-}
-
-// Given a map and a directory, find all of the 
-// mime information files (*.mime) and parse them for
-// relavent mime type information. Each entry in the
-// map corresponds to one mime type, and its
-// associated file extensions.
-
-private static void gnome_getMimeInfoFromDirectory( Hashtable info, File directory ) {
-	// For each entry in the given directory (if it exists)
-	if (directory.exists()) {
-		File[] files = directory.listFiles();
-		for (int i = 0; i < files.length; i++) {
-		
-			// If the entry is a subdirectory, process it and
-			// merge the mime type into the given map.
-			if (files[i].isDirectory()) {
-				gnome_getMimeInfoFromDirectory( info, files[i] );
-			}
-		
-			// else if the entry is a mime info file (*.mime)
-			else if (files[i].getName().endsWith(".mime")) {
-				try {
-					// Parse the mime file and merge the info
-					// into the given map.
-					FileReader in = new FileReader( files[i] );
-					BufferedReader reader = new BufferedReader( in );
-					gnome_parseMimeFile( info, reader );
-					reader.close();
-					in.close();
-				}
-				catch (IOException e) {
-					// Ignore file exceptions silently. If we
-					// can't read it, the info is not available.
-				}
-			}
-		}
-	}
-}
-
-private static void gnome_parseMimeFile( Hashtable info, BufferedReader reader ) {
-	Vector  mimeExts = null;
-	String  mimeType = null;
-	boolean saveType = false;
-	String  line     = "#";
-	while (line != null) {
-		
-		// Determine if the line contains a mime type name.
-		boolean newType = (line.length() > 0 && Character.isLetter( line.charAt(0) ));
-				  
-		// If there is valid data on this line to be processed
-		String data = line.trim();
-		if (data.length() > 0 && data.charAt(0) != '#') {
-			
-			// If this line defines a new mime type
-			if (newType) {
-				
-				// If a previous mime type has not be saved yet
-				if (mimeType != null) {
-					// Save the type and process this line again.
-					saveType = true;
-				}
-				// else initialize the mime type info
-				else {
-					int colon = data.indexOf( ':' );
-					if (colon != -1) {
-						mimeType = data.substring( 0, colon );
-					}
-					else {
-						mimeType = data;
-					}
-					mimeExts = new Vector();
-				}
-			}
-			
-			// else if the line defines a list of extensions
-			else if (data.indexOf( "ext" ) == 0 && mimeType != null) {
-				
-				// Get the extensions defined on the line
-				String exts = "";
-				int colon = data.indexOf( ':' );
-				if ((colon != -1) && ((colon+1) < data.length())) {
-					exts = data.substring( (colon+1) ).trim();
-				}
-				
-				// While there are extensions to be processed (use space as separator)
-				exts = exts.replace( '\t', ' ' );
-				exts = exts.replace( ',', ' ' );
-				while (exts.length() != 0) {
-					// Extract the next entension from the list
-					String newExt;
-					int  space = exts.indexOf( ' ' );
-					if (space != -1) {
-						newExt = exts.substring( 0, space );
-						exts = exts.substring( space ).trim();
-					}
-					else {
-						newExt = exts;
-						exts = "";
-					}
-					
-					// Prefix an extension with a period.
-					if (newExt.charAt(0) != '.') {
-						newExt = "." + newExt;
-					}
-					mimeExts.add( newExt );
-				} 
-			}
-			
-			// else if the line defines a list of regular expressions
-			else if (data.indexOf( "regex" ) == 0 && mimeType != null) {
-				// Do nothing with these right now.
-			}
-		}
-		
-		
-		// If the current mime type is still being processed
-		if (!saveType) {
-			// Get the next line			
-			try {
-				line = reader.readLine();
-			}
-			catch (IOException e) {
-				line = null;
-			}
-		}
-		
-		// If the current type should be saved or if the end
-		// of the file was reached
-		if (saveType || (line == null)) {
-			// If there is a mime type to be saved
-			if (mimeType != null) {
-			
-				// If the mime type does not exist in the map, add it.
-				Vector prevExts = (Vector) info.get( mimeType );
-				if (prevExts == null) {
-					info.put( mimeType, mimeExts );
-				}
-		
-				// else append the new list of extensions.
-				else {
-					for (int i = 0; i < mimeExts.size(); i++) {
-						prevExts.add( mimeExts.elementAt( i ) );
-					}
-				}
-			}
-			mimeType = null;
-			mimeExts = null;
-			saveType = false;
-		}
-	}
-}
-
-// Private method for parsing a command line into its arguments.
-private static String[] parseCommand( String cmd ) {
-	Vector args = new Vector();
-	int sIndex = 0;
-	int eIndex;
-	while (sIndex < cmd.length()) {
-		// Trim initial white space of argument.
-		while (sIndex < cmd.length() && Character.isWhitespace( cmd.charAt(sIndex) )) {
-			sIndex++;
-		}
-		if (sIndex < cmd.length()) {
-			// If the command is a quoted string
-			if (cmd.charAt(sIndex) == '"' || cmd.charAt(sIndex) == '\''){
-				// Find the terminating quote (or end of line).
-				// This code currently does not handle escaped characters (e.g., " a\"b").
-				eIndex = sIndex + 1;
-				while (eIndex < cmd.length() && cmd.charAt(eIndex) != cmd.charAt(sIndex)) {
-					eIndex++;
-				}
-				if (eIndex >= cmd.length()) { // the terminating quote was not found
-					// Add the argument as is with only one initial quote.
-					args.add( cmd.substring( sIndex, eIndex ) );
-				}
-				// else add the argument, trimming off the quotes.
-				else {
-					args.add( cmd.substring( sIndex+1, eIndex ) );
-				}
-				sIndex = eIndex + 1;
-			}
-			
-			// else use white space for the delimiters.
-			else {
-				eIndex = sIndex;
-				while (eIndex < cmd.length() && !Character.isWhitespace( cmd.charAt(eIndex) )) {
-					eIndex++;
-				}
-				args.add( cmd.substring( sIndex, eIndex ) );
-				sIndex = eIndex + 1;
-			}
-		}
-	}
-	
-	String[] strings = new String[ args.size() ];
-	for (int index =0; index < args.size(); index++) {
-		strings[ index ] = (String) args.elementAt( index );
-	}
-	return strings;
-}
-
-
-static String gnome_getDataDirectory(String dirName) {
-	/* Use the character encoding for the default locale */
-	byte [] nameBuffer = Converter.wcsToMbcs (null, dirName, true);
-	int ptr = GNOME.gnome_datadir_file(nameBuffer);
-	if (ptr == 0) return null;
-	int length = OS.strlen(ptr);
-	byte[] dirBuffer = new byte[length];
-	OS.memmove(dirBuffer, ptr, length);
-	/* Use the character encoding for the default locale */
-	return new String(Converter.mbcsToWcs(null, dirBuffer));
-}
-
-static String gnome_getHomeDirectory() {
-	int ptr = GNOME.g_get_home_dir();
-	if (ptr == 0) return null;
-	int length = OS.strlen(ptr);
-	byte[] homeDirBuffer = new byte[length];
-	OS.memmove(homeDirBuffer, ptr, length);
-	/* Use the character encoding for the default locale */
-	return new String(Converter.mbcsToWcs(null, homeDirBuffer));
-}
-
-static String gnome_getMimeType(String name) {
-	/* Use the character encoding for the default locale */
-	byte [] nameBuffer = Converter.wcsToMbcs (null, name, true);
-	int ptr = GNOME.gnome_mime_type(nameBuffer);
-	if (ptr == 0) return null;
-	int length = OS.strlen(ptr);
-	byte[] mimeBuffer = new byte[length];
-	OS.memmove(mimeBuffer, ptr, length);
-	/* Use the character encoding for the default locale */
-	return new String(Converter.mbcsToWcs(null, mimeBuffer));
-}
-
-static String gnome_getMimeValue(String mimeType, String key) {
-	/* Use the character encoding for the default locale */
-	byte [] typeBuffer = Converter.wcsToMbcs (null, mimeType, true);
-	byte [] keyBuffer = Converter.wcsToMbcs (null, key, true);
-	int ptr = GNOME.gnome_mime_get_value(typeBuffer, keyBuffer);
-	if (ptr == 0) return null;
-	
-	StringBuffer stringBuffer = new StringBuffer();
-	int length = OS.strlen(ptr);
-	byte[] valueBuffer = new byte[length];
-	OS.memmove(valueBuffer, ptr, length);
-	/* Use the character encoding for the default locale */
-	return new String(Converter.mbcsToWcs(null, valueBuffer));
-}
-
-static boolean kde_init () {
-	try {
-		Callback.loadLibrary("swt-kde");
-	} catch (UnsatisfiedLinkError e) {
-		return false;
-	}
-
-	/* Use the character encoding for the default locale */
-	byte [] nameBuffer = Converter.wcsToMbcs( null, "SWT", true );
-	int qcString = KDE.QCString_new( nameBuffer );
-	KDE.KApplication_new( qcString );
-	KDE.QCString_delete( qcString );
-	return true;
-}
-
-private static String kde_getMimeTypeCommand( String mimeType ) {
-	/* Use the character encoding for the default locale */
-	byte [] buffer = Converter.wcsToMbcs (null, mimeType, true);
-	int qMimeType = KDE.QString_new( buffer );
-	int serviceList = KDE.KMimeType_offers( qMimeType );
-	KDE.QString_delete( qMimeType );
-	if (serviceList == 0) return null;
-	KDE.KServiceList_delete( serviceList );
-	return "KRun::runURL(url,mimeType)";
-}
-/*
- * Obtain the registered mime type information and
- * return it in a map. The key of each entry
- * in the map is the mime type name. The value is
- * a vector of the associated file extensions.
- */
-  
-private static Hashtable kde_getMimeInfo() {
-	Hashtable mimeInfo = new Hashtable();
-	Vector    mimeExts = null;
-	String    mimeType;
-	
-	// Get the list of all mime types available.
-	int mimeTypeList = KDE.KMimeType_allMimeTypes();
-	int iterator = KDE.KMimeTypeList_begin( mimeTypeList );
-	int listEnd  = KDE.KMimeTypeList_end( mimeTypeList );
-	while (KDE.KMimeTypeListIterator_equals( iterator, listEnd ) == 0) {
-		// Get the next KMimeType from the list.
-		int kMimeType = KDE.KMimeTypeListIterator_dereference( iterator );
-		
-		// Get the mime type name.
-		int mimeName = KDE.KMimeType_name( kMimeType );
-		mimeType = kde_convertQStringAndFree( mimeName );
-		
-		// Get the list of extension patterns.
-		mimeExts = new Vector();
-		String extension;
-		
-		// Add the mime type to the hash table with its extensions.
-		int patternList = KDE.KMimeType_patterns( kMimeType );
-		int patIterator = KDE.QStringList_begin( patternList );
-		int patListEnd  = KDE.QStringList_end( patternList );
-		while (KDE.QStringListIterator_equals( patIterator, patListEnd ) == 0) {
-			// Get the next extension pattern from the list.
-			int patString = KDE.QStringListIterator_dereference( patIterator );
-			extension = kde_convertQStringAndFree( patString );
-			int period = extension.indexOf( '.' );
-			if (period != -1) {
-				mimeExts.add( extension.substring( period ) );
-			}
-
-			// Advance to the next pattern.		
-			KDE.QStringListIterator_increment( patIterator );
-		}
-		KDE.QStringListIterator_delete( patIterator );
-		KDE.QStringListIterator_delete( patListEnd );
-		KDE.QStringList_delete( patternList );
-		
-		// If there is at least one extension, save the mime type.
-		if (mimeExts.size() > 0) {
-			mimeInfo.put( mimeType, mimeExts );
-		}
-
-		// Advance to the next mime type.		
-		KDE.KMimeTypeListIterator_increment( iterator );
-	}
-	KDE.KMimeTypeListIterator_delete( iterator );
-	KDE.KMimeTypeListIterator_delete( listEnd );
-	KDE.KMimeTypeList_delete( mimeTypeList );
-	
-	return mimeInfo;
-}
-
-static String kde_convertQStringAndFree (int qString) {
-	int qCString = KDE.QString_utf8 (qString);
-	int charString = KDE.QCString_data (qCString);
-	
-	StringBuffer stringBuffer = new StringBuffer ();
-	int length = KDE.strlen (charString);
-	byte[] buffer = new byte [length];
-	KDE.memmove (buffer, charString, length);
-	/* Use the character encoding for the default locale */
-	String answer = new String (Converter.mbcsToWcs (null, buffer));
-		
-	KDE.QCString_delete (qCString);
-	KDE.QString_delete (qString);
-	return answer;
-}
-
-/**
- * Launches the executable associated with the file in
- * the operating system.  If the file is an executable,
- * then the executable is launched.
- *
- * @param fileName the file or program name
- * @return <code>true</code> if the file is launched, otherwise <code>false</code>
- * 
- * @exception SWTError <ul>
- *		<li>ERROR_NULL_ARGUMENT when fileName is null</li>
- *	</ul>
- */
-public static boolean launch (String fileName) {
-	return launch( Display.getCurrent(), fileName );
-}
-
-/*
- *  API: When support for multiple displays is added, this method will
- *       become public and the original method above can be deprecated.
- */
-private static boolean launch( Display display, String fileName ) {
-	if (fileName == null) SWT.error( SWT.ERROR_NULL_ARGUMENT );
-	
-	// If the argument appears to be a data file (it has an extension)
-	int index = fileName.lastIndexOf(".");
-	if (index > 0) {
-		
-		// Find the associated program, if one is defined.
-		String extension = fileName.substring( index );
-		Program program = Program.findProgram( display, extension ); 
-		
-		// If the associated program is defined and can be executed, return.
-		if (program != null && program.execute( fileName )) return true;
-	}
-	
-	// Otherwise, the argument was the program itself.
-	try {
-		Runtime.getRuntime().exec( fileName );
-		return true;
-	} catch (IOException e) {
-		return false;
-	}
-}
-
-/**
- * Executes the program with the file as the single argument
- * in the operating system.  It is the responsibility of the
- * programmer to ensure that the file contains valid data for 
- * this program.  
- *
- * @param fileName is the argument (typically a file) for the program
- * @return <code>true</code> if the file is launched, otherwise <code>false</code>
- * 
- * @exception SWTError <ul>
- *		<li>ERROR_NULL_ARGUMENT when fileName is null</li>
- *	</ul>
- */
-public boolean execute (String fileName) {
-	if (fileName == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
-	
-	switch (getDesktop( display )) {
-		case DESKTOP_KDE: {
-			String urlString = "file://" + fileName;
-			/* Use the character encoding for the default locale */
-			byte[] buffer = Converter.wcsToMbcs( null, urlString, true );
-			int qString = KDE.QString_new( buffer );
-			int url = KDE.KURL_new( qString );
-			KDE.QString_delete( qString );
-			/* Use the character encoding for the default locale */
-			buffer = Converter.wcsToMbcs (null, name, true);
-			int mimeTypeName = KDE.QString_new( buffer );
-			int pid = KDE.KRun_runURL( url, mimeTypeName );
-			KDE.KURL_delete( url );
-			KDE.QString_delete( mimeTypeName );
-			return (pid != 0);
-		}
-		
-		case DESKTOP_GNOME: {
-			// Parse the command into its individual arguments.
-			String[]  args = parseCommand( command );
-			int       fileArg = -1;
-			int       index;
-			for (index=0; index < args.length; index++) {
-				int j = args[ index ].indexOf( "%f" );
-				if (j != -1) {
-					String value = args[ index ];
-					fileArg = index;
-					args[ index ] = value.substring(0,j) + fileName + value.substring(j+2);
-				}
-			}
-	
-			// If a file name was given but the command did not have "%f"
-			if ((fileName.length() > 0) && (fileArg < 0)) {
-				String[] newArgs = new String[ args.length + 1 ];
-				for (index=0; index < args.length; index++)
-					newArgs[ index ] = args[ index ];
-				newArgs[ args.length ] = fileName;
-				args = newArgs;
-			}
-	
-			// Execute the command.
-			try {
-				Runtime.getRuntime().exec( args );
-			} catch (IOException e) {
-				return false;
-			}
-			return true;
-		}
-		
-		case DESKTOP_CDE: {
-			/* Use the character encoding for the default locale */
-			byte[] action = Converter.wcsToMbcs( null, command, true );
-			byte[] fileArg = Converter.wcsToMbcs( null, fileName, true );
-			Integer shell = (Integer) display.getData( cdeShell );
-			int actionID = 0;
-			if (shell != null) {
-				actionID = CDE.DtActionInvoke( shell.intValue(), action, fileArg, 1, null, null, null, 1, 0, 0 );
-			}
-			return (actionID != 0);
-		}
-	}
-
-	return false;
-}
-
-/**
- * Returns the receiver's image data.  This is the icon
- * that is associated with the reciever in the operating
- * system.
- *
- * @return the image data for the program, may be null
- */
-public ImageData getImageData () {
-	String iconPath = null;
-	switch (getDesktop( display )) {
-		case DESKTOP_KDE: {
-			/* Use the character encoding for the default locale */
-			byte [] buffer = Converter.wcsToMbcs (null, name, true);
-			int mimeTypeName = KDE.QString_new( buffer );
-			int mimeType = KDE.KMimeType_mimeType( mimeTypeName );
-			KDE.QString_delete( mimeTypeName );			
-			if (mimeType == 0) return null;			
-			int mimeIcon = KDE.KMimeType_icon(mimeType, 0, 0);
-			int loader = KDE.KGlobal_iconLoader();
-			int path = KDE.KIconLoader_iconPath(loader, mimeIcon, KDE.KICON_SMALL, 1);
-			if (path == 0) return null;
-			iconPath = kde_convertQStringAndFree(path);
-			break;
-		}
-		
-		case DESKTOP_GNOME: {
-			String fakeFileName = "file" + extension;
-			String mime = gnome_getMimeType(fakeFileName);
-			if (mime == null) return null;
-			iconPath = gnome_getMimeValue(mime, "icon-filename");
-			if (iconPath == null) return null;
-			break;
-		}
-		
-		case DESKTOP_CDE: {
-			return cde_getImageData();
-		}
-		
-		case DESKTOP_UNKNOWN: {
-			return null;
-		}
-	}
-	if (iconPath.endsWith ("xpm")) {
-		int xDisplay = display.xDisplay;
-		int screen  = OS.XDefaultScreenOfDisplay( xDisplay );
-		int fgPixel = OS.XWhitePixel( display.xDisplay, OS.XDefaultScreen( xDisplay ) );
-		int bgPixel = OS.XBlackPixel( display.xDisplay, OS.XDefaultScreen( xDisplay ) );
-		/* Use the character encoding for the default locale */
-		byte [] iconName = Converter.wcsToMbcs (null, iconPath, true);
-		int pixmap = OS.XmGetPixmap( screen, iconName, fgPixel, bgPixel );
-    	if (pixmap == OS.XmUNSPECIFIED_PIXMAP) return null;
-		Image image = Image.motif_new (display, SWT.BITMAP, pixmap, 0);
-		ImageData imageData = image.getImageData ();
-		
-		// The pixmap returned from XmGetPixmap is cached by Motif
-		// and must be deleted by XmDestroyPixmap. Because it cannot
-		// be deleted directly by XFreePixmap, image.dispose() must not
-		// be called. The following code should do an equivalent image.dispose().
-		OS.XmDestroyPixmap( screen, pixmap );
-		return imageData;		
-	}
-	try {
-		return new ImageData (iconPath);
-	} catch (Exception e) {
-		return null;
-	}
-}
-
-/**
- * Returns the receiver's name.  This is as short and
- * descriptive a name as possible for the program.  If
- * the program has no descriptive name, this string may
- * be the executable name, path or empty.
- *
- * @return an the name of the program
- */
-public String getName () {
-	return name;
-}
-
-/**
- * Returns true if the receiver and the argument represent
- * the same program.
- * 
- * @return true if the programs are the same
- */
-public boolean equals(Object other) {
-	if (this == other) return true;
-	if (other instanceof Program) {
-		final Program program = (Program) other;
-		return display == program.display && extension.equals(program.extension) &&
-			name.equals(program.name) && command.equals(program.command);
-	}
-	return false;
-}
-
-/**
- * Returns a hash code suitable for this object.
- * 
- * @return a hash code
- */
-public int hashCode() {
-	return extension.hashCode() ^ name.hashCode() ^ command.hashCode() ^ display.hashCode();
-}
-
-public String toString () {
-	return "Program {" + name + "}";
-}
-static boolean gnome_init () {
-	try {
-		Callback.loadLibrary("swt-gnome");
-	} catch (UnsatisfiedLinkError e) {
-		return false;
-	}
-	return true;
-}
-
-/* CDE - Get Attribute Value
- * 
- * This method takes a data type name and an attribute name, and returns
- * the corresponding attribute value.
- */
-
-static String cde_getAttribute(String dataType, String attrName) {
-	/* Use the character encoding for the default locale */
-	byte [] dataTypeBuf = Converter.wcsToMbcs (null, dataType, true);
-    byte [] attrNameBuf = Converter.wcsToMbcs (null, attrName, true);
-    byte [] optNameBuf  = null;
-	int attrValue = CDE.DtDtsDataTypeToAttributeValue( dataTypeBuf, attrNameBuf, optNameBuf );
-	if (attrValue == 0) return null;
-    int length = OS.strlen(attrValue);
-    byte[] attrValueBuf = new byte[length];
-    OS.memmove(attrValueBuf, attrValue, length);
-    CDE.DtDtsFreeAttributeValue( attrValue );
-	/* Use the character encoding for the default locale */
-    return new String(Converter.mbcsToWcs(null, attrValueBuf));
-}
-
-/* CDE - Get Default Action of Data Type
- * 
- * This method takes a data type and returns the corresponding default action.
- * By default, the "Open" action is used if it is available. If it is not
- * available, the first action in the list is used. Typically, if Open is not
- * available, there is usually only one action anyways.
- */
-
-static String cde_getAction(String dataType) {
-	String action  = null;
-	String actions = cde_getAttribute( dataType, CDE.DtDTS_DA_ACTION_LIST );
-	if (actions != null) {
-		int index = actions.indexOf( "Open" );
-		if (index != -1) {
-			action = actions.substring( index, index+4 );
-		}
-		else {
-			index = actions.indexOf( "," );
-			if (index != -1) {
-				action = actions.substring( 0, index );
-			}
-			else {
-				action = actions;
-			}
-		}
-	}
-	return action;
-}
-
-/* CDE - Get Extension of Data Type
- * 
- * This method takes a data type and returns the corresponding extension.
- * The extension is obtained from the NAME TEMPLATE attribute.
- */
-
-static String cde_getExtension(String dataType) {
-    String fileExt = cde_getAttribute( dataType, CDE.DtDTS_DA_NAME_TEMPLATE );
-    if (fileExt == null || fileExt.indexOf( "%s." ) == -1) return null;
-    int dot = fileExt.indexOf( "." );
-    return fileExt.substring( dot );
-}
-
-/* CDE - Get Data Types
- * 
- * This method returns the list of data type names available.
- * Each data type returned is valid, meaning it has an action and
- * an extension. 
- */
-
-static Hashtable cde_getDataTypeInfo() {
-	Hashtable dataTypeInfo = new Hashtable();
-	int index;
-	int dataTypeList = CDE.DtDtsDataTypeNames();
-	if (dataTypeList != 0) {
-		// For each data type name in the list
-		index = 0; 
-		int dataType = CDE.listElementAt( dataTypeList, index++ );
-		while (dataType != 0) {
-    		int length = OS.strlen(dataType);
-    		byte[] dataTypeBuf = new byte[length];
-    		OS.memmove(dataTypeBuf, dataType, length);
-			/* Use the character encoding for the default locale */
-     		String dataTypeName = new String(Converter.mbcsToWcs(null, dataTypeBuf));
-     		
-	   		// The data type is valid if it is not an action, and it has an extension and an action.
-      		String extension = cde_getExtension( dataTypeName );
-   			if (!CDE.DtDtsDataTypeIsAction( dataTypeBuf ) &&
-				extension != null && cde_getAction( dataTypeName ) != null) {
-				Vector exts = new Vector();
-				exts.add( extension );
-				dataTypeInfo.put( dataTypeName, exts );
-	   		}
-			dataType = CDE.listElementAt( dataTypeList, index++ );
-		}
-		CDE.DtDtsFreeDataTypeNames( dataTypeList );
-	}
-	
-    return dataTypeInfo;
-}
-
-/* CDE - Get Image Data
- * 
- * This method returns the image data of the icon associated with
- * the data type. Since CDE supports multiple sizes of icons, several
- * attempts are made to locate an icon of the desired size and format.
- * CDE supports the sizes: tiny, small, medium and large. The best
- * search order is medium, large, small and then tiny. Althoug CDE supports
- * colour and monochrome bitmaps, only colour icons are tried. (The order is
- * defined by the  cdeIconExt and cdeMaskExt arrays above.)
- */
-
-ImageData cde_getImageData() {
-	int	xDisplay = display.xDisplay;
-	int screen  = OS.XDefaultScreenOfDisplay( xDisplay );
-	int fgPixel = OS.XWhitePixel( display.xDisplay, OS.XDefaultScreen( xDisplay ) );
-	int bgPixel = OS.XBlackPixel( display.xDisplay, OS.XDefaultScreen( xDisplay ) );
-	
-    String icon = cde_getAttribute( name, CDE.DtDTS_DA_ICON );
-    byte [] iconName;
-    byte [] maskName = null;
-    int    pixmap = 0;
-    for (int index = 0; index < cdeIconExt.length && pixmap == 0; index++) {
-		/* Use the character encoding for the default locale */
-    	iconName = Converter.wcsToMbcs (null, icon + cdeIconExt[ index ], true);
-    	maskName = Converter.wcsToMbcs (null, icon + cdeMaskExt[ index ], true);
-		pixmap = OS.XmGetPixmap( screen, iconName, fgPixel, bgPixel );
-    	if (pixmap == OS.XmUNSPECIFIED_PIXMAP) pixmap = 0;
-   }
-    
-    if (pixmap != 0) {
-    	int type = SWT.ICON;
-    	// When creating the mask pixmap, do not use the screen's white and black
-    	// pixel for the foreground and background respectively, because on some
-    	// X servers (e.g., Solaris) pixel 0 is white and pixel 1 is black. Passing
-    	// (screen, name, whitePixel, blackPixel, 1) to get the mask pixmap will
-    	// result in an inverted mask. Instead explicitly use 1 (FG) and 0 (BG).
-   		int mask = OS.XmGetPixmapByDepth( screen, maskName, 1, 0, 1 );
-    	if (mask == OS.XmUNSPECIFIED_PIXMAP) {
-    		type = SWT.BITMAP;
-    		mask = 0;
-    	}
-		Image image = Image.motif_new (display, type, pixmap, mask );
-		ImageData imageData = image.getImageData();
-		
-		// The pixmaps returned from XmGetPixmap... are cached by Motif
-		// and must be deleted by XmDestroyPixmap. Because they cannot
-		// be deleted directly by XFreePixmap, image.dispose() must not
-		// be called. The following code should do an equivalent image.dispose().
-		OS.XmDestroyPixmap( screen, pixmap );
-		if (mask != 0) OS.XmDestroyPixmap( screen, mask ); 
-		return imageData;		
-    }
-    return null;	
-}
-
-/* CDE - Initialize
- * 
- * This method loads the swt-cde library and initializes CDE itself.
- * The shell created fo DtAppInitialize is kept for DtActionInvoke calls.
- */
-static boolean cde_init( Display display ) {
-	try {
-		Callback.loadLibrary("swt-cde");
-	} catch (UnsatisfiedLinkError e) {
-		return false;
-	}
-
-	/* Use the character encoding for the default locale */
-	byte[] appName = Converter.wcsToMbcs( null, "SWT", true );
-	int xtContext  = OS.XtDisplayToApplicationContext( display.xDisplay );
-	int widgetClass = OS.TopLevelShellWidgetClass();
-	int shell = OS.XtAppCreateShell( appName, appName, widgetClass, display.xDisplay, null, 0 );
-	boolean initOK  = CDE.DtAppInitialize( xtContext, display.xDisplay, shell, appName, appName );
-	if (!initOK) {
-		OS.XtDestroyWidget( shell );
-	}
-	else {
-		CDE.DtDbLoad();
-		display.setData( cdeShell, new Integer(shell) );
-		display.disposeExec( new Runnable() {
-			public void run() {
-				// This logic assumes that when the corresponding display is
-				// being disposed, it must be the current one.
-				Integer shell = (Integer) Display.getCurrent().getData( cdeShell );
-				if (shell != null) {
-					OS.XtDestroyWidget( shell.intValue() );
-				}
-			}
-		});
-	}	
-	return initOK;
-}
-}
+ */

+public final class Program {	

+	String name;

+	String extension;

+	String command;

+

+	static final int DESKTOP_UNKNOWN = 0;

+	static final int DESKTOP_KDE = 1;

+	static final int DESKTOP_GNOME = 2;

+	static final int Desktop = getDesktop ();

+	

+/**

+ * Prevents uninitialized instances from being created outside the package.

+ */

+Program () {

+}

+

+static int getDesktop () {

+	File root = new File ("/proc");

+	if (!root.exists () || !root.isDirectory ()) return DESKTOP_UNKNOWN;

+	File [] procDirs = root.listFiles ();

+	for (int i=0; i<procDirs.length; i++) {

+		String directory = procDirs [i].getAbsolutePath ();

+		File file = new File (directory + "/stat");

+		if (file.exists ()) {

+			String procName = getProcName (file);

+			if (procName.indexOf ("gnome") >= 0) {

+				return gnome_init() ? DESKTOP_GNOME : DESKTOP_UNKNOWN;		

+			}

+			if (procName.indexOf ("kdeinit") >= 0) {

+				return kde_init () ? DESKTOP_KDE : DESKTOP_UNKNOWN;

+			}	

+		}

+	}

+	return DESKTOP_UNKNOWN;

+}

+

+static String getProcName (File file) {

+	try {

+		FileInputStream stream = new FileInputStream (file);

+		while (true) {

+			char ch = (char) stream.read ();

+			if (ch < 0 || ch == 0xFF) return null;

+			if (ch == '(') break;

+		}

+		String name = "";

+		while (true) {

+			char ch = (char) stream.read ();

+			if (ch < 0 || ch == 0xFF) return null;

+			if (ch == ')') break;

+			name += ch;

+		}

+		stream.close ();

+		return name;	

+	} catch (IOException e) {

+		return null;		

+	}

+}

+/*

+ * Finds the program that is associated with an extension.

+ * The extension may or may not begin with a '.'.

+ *

+ * @param extension the program extension

+ * @return the program or nil

+ *

+ * @exception SWTError <ul>

+ *		<li>ERROR_NULL_ARGUMENT when extension is null</li>

+ *	</ul>

+ */

+public static Program findProgram (String extension) {

+	if (extension == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);

+	if (extension.length () == 0) return null;

+	if (extension.charAt (0) != '.') extension = "." + extension;

+	String command = null;

+	String name = "";

+	switch (Desktop) {

+		case DESKTOP_KDE: {

+			String urlString = "file://any." + extension;

+			byte [] buffer = Converter.wcsToMbcs (null, urlString, true);

+			int qString = KDE.QString_new (buffer);

+			int url = KDE.KURL_new (qString);

+			KDE.QString_delete (qString);

+			int mimeType = KDE.KMimeType_findByURL (url);

+			int mimeName = KDE.KMimeType_name (mimeType);

+			int service = KDE.KServiceTypeProfile_preferredService (mimeName, 1);

+			if (service == 0) return null;

+			int execQString = KDE.KService_exec (service);

+			command = kde_convertQStringAndFree (execQString);

+			break;	

+		}

+		

+		case DESKTOP_GNOME: {

+			String fileName = "file" + extension;

+			String mimeType = gnome_getMimeType (fileName);

+			if (mimeType == null) return null;

+			command = gnome_getMimeValue (mimeType, "open");

+			if (command == null) return null;

+			name = mimeType;

+			break;

+		}

+		

+		case DESKTOP_UNKNOWN:

+			return null;

+	}

+	Program program   = new Program ();

+	program.name      = name;

+	program.command   = command;

+	program.extension = extension;

+	return program;

+}

+

+/*

+ * Answer all program extensions in the operating system.

+ *

+ * @return an array of extensions

+ */

+public static String [] getExtensions () {

+	switch (Desktop) {

+		case DESKTOP_KDE:

+			Vector names = new Vector ();

+			int serviceList = KDE.KService_allServices ();

+			int listBeginning = KDE.KServiceList_begin (serviceList);

+			int listEnd = KDE.KServiceList_end (serviceList);

+			int iterator = KDE.KServiceListIterator_new (listBeginning);

+			while (true) {

+				if (KDE.KServiceListIterator_equals (iterator, listEnd) != 0) break;

+				int kService = KDE.KServiceListIterator_dereference (iterator);

+				int serviceType = KDE.KService_type (kService);

+				byte [] applicationType = Converter.wcsToMbcs (null, "Application", true);

+				int appString = KDE.QString_new (applicationType);

+				if (KDE.QString_equals (serviceType, appString) != 0) {

+					int appName = KDE.KService_name (kService);

+					names.addElement (kde_convertQStringAndFree (appName));

+				}

+				KDE.QString_delete (appString);

+				KDE.KServiceListIterator_increment (iterator);

+			}

+			KDE.KServiceListIterator_delete (iterator);

+			KDE.KServiceList_delete (serviceList);

+			String[] appNames = new String [names.size ()];

+			for (int i=0; i <names.size (); i++) {

+				appNames [i] = (String) names.elementAt (i);

+			}

+			return appNames;

+

+		case DESKTOP_GNOME:

+			// Obtain the mime type/extension information.

+			Hashtable mimeInfo = gnome_getMimeInfo();

+			int  index;

+			

+			// Create a sorted set of the file extensions.

+			Vector extensions = new Vector();

+			Iterator keys = mimeInfo.keySet().iterator();

+			while (keys.hasNext()) {

+				String mimeType = (String) keys.next();

+				Vector mimeExts = (Vector) mimeInfo.get( mimeType );

+				for (index = 0; index < mimeExts.size(); index++){

+					if (!extensions.contains( mimeExts.elementAt( index ) )) {

+						extensions.add( mimeExts.elementAt( index ) );

+					}

+				}

+			}

+			

+			// Return the list of extensions.

+			String[] extStrings = new String[ extensions.size() ];

+			for (index = 0; index < extensions.size(); index++) {

+				extStrings[ index ] = (String) extensions.elementAt( index );

+			}

+			

+			return extStrings;

+	}

+	return new String[0];

+}

+

+/*

+ * Answers all available programs in the operating system.

+ *

+ * @return an array of programs

+ */

+public static Program [] getPrograms () {

+	switch (Desktop) {

+		case DESKTOP_KDE:

+			return new Program[0]; // TBD

+

+		case DESKTOP_GNOME:

+			// Obtain the mime type/extension information.

+			Hashtable mimeInfo = gnome_getMimeInfo();

+			Vector programs = new Vector();

+			

+			// Create a list of programs with commands.

+			Iterator keys = mimeInfo.keySet().iterator();

+			while (keys.hasNext()) {

+				String mimeType  = (String) keys.next();

+				String extension = "";

+				Vector mimeExts  = (Vector) mimeInfo.get( mimeType );

+				if (mimeExts.size() > 0){

+					extension = (String) mimeExts.elementAt( 0 );

+				}

+				String command  = gnome_getMimeValue( mimeType, "open" );

+				if (command != null) {

+					Program program   = new Program ();

+					program.name      = mimeType;

+					program.command   = command;

+					program.extension = extension;

+					programs.add( program );

+				}

+			}

+			

+			// Return the list of programs to the user.

+			Program[] programList = new Program[ programs.size() ];

+			for (int index = 0; index < programList.length; index++) {

+				programList[ index ] = (Program) programs.elementAt( index );

+			}

+			return programList;

+	}

+	return new Program[0];

+}

+

+/*

+ * Obtain the registered mime type information and

+ * return it in a map. The key of each entry

+ * in the map is the mime type name. The value is

+ * a vector of the associated file extensions.

+ */

+  

+private static Hashtable gnome_getMimeInfo() {

+	Hashtable mimeInfo = new Hashtable();

+	

+	// Extract the mime info from the system directory.

+	String mimeDirectory = gnome_getDataDirectory ("mime-info");

+	gnome_getMimeInfoFromDirectory( mimeInfo, new File( mimeDirectory ) );

+	

+	// Append the mime info from the user's directory (if it exists).

+	String userDirectory = gnome_getHomeDirectory();

+	if (userDirectory != null) {

+		userDirectory = userDirectory + File.separator + ".gnome" + File.separator + "mime-info";

+		gnome_getMimeInfoFromDirectory( mimeInfo, new File( userDirectory ) );

+	}

+

+	return mimeInfo;

+}

+

+// Given a map and a directory, find all of the 

+// mime information files (*.mime) and parse them for

+// relavent mime type information. Each entry in the

+// map corresponds to one mime type, and its

+// associated file extensions.

+

+private static void gnome_getMimeInfoFromDirectory( Hashtable info, File directory ) {

+	// For each entry in the given directory (if it exists)

+	if (directory.exists()) {

+		File[] files = directory.listFiles();

+		for (int i = 0; i < files.length; i++) {

+		

+			// If the entry is a subdirectory, process it and

+			// merge the mime type into the given map.

+			if (files[i].isDirectory()) {

+				gnome_getMimeInfoFromDirectory( info, files[i] );

+			}

+		

+			// else if the entry is a mime info file (*.mime)

+			else if (files[i].getName().endsWith(".mime")) {

+				try {

+					// Parse the mime file and merge the info

+					// into the given map.

+					FileReader in = new FileReader( files[i] );

+					BufferedReader reader = new BufferedReader( in );

+					gnome_parseMimeFile( info, reader );

+					reader.close();

+					in.close();

+				}

+				catch (IOException e) {

+					// Ignore file exceptions silently. If we

+					// can't read it, the info is not available.

+				}

+			}

+		}

+	}

+}

+

+private static void gnome_parseMimeFile( Hashtable info, BufferedReader reader ) {

+	Vector  mimeExts = null;

+	String  mimeType = null;

+	boolean saveType = false;

+	String  line     = "#";

+	while (line != null) {

+		

+		// Determine if the line contains a mime type name.

+		boolean newType = (line.length() > 0 && Character.isLetter( line.charAt(0) ));

+				  

+		// If there is valid data on this line to be processed

+		String data = line.trim();

+		if (data.length() > 0 && data.charAt(0) != '#') {

+			

+			// If this line defines a new mime type

+			if (newType) {

+				

+				// If a previous mime type has not be saved yet

+				if (mimeType != null) {

+					// Save the type and process this line again.

+					saveType = true;

+				}

+				// else initialize the mime type info

+				else {

+					int colon = data.indexOf( ':' );

+					if (colon != -1) {

+						mimeType = data.substring( 0, colon );

+					}

+					else {

+						mimeType = data;

+					}

+					mimeExts = new Vector();

+				}

+			}

+			

+			// else if the line defines a list of extensions

+			else if (data.indexOf( "ext" ) == 0 && mimeType != null) {

+				

+				// Get the extensions defined on the line

+				String exts = "";

+				int colon = data.indexOf( ':' );

+				if ((colon != -1) && ((colon+1) < data.length())) {

+					exts = data.substring( (colon+1) ).trim();

+				}

+				

+				// While there are extensions to be processed

+				exts = exts.replace( '\t', ' ' );

+				while (exts.length() != 0) {

+					// Extract the next entension from the list

+					String newExt;

+					int  space = exts.indexOf( ' ' );

+					if (space != -1) {

+						newExt = exts.substring( 0, space );

+						exts = exts.substring( space ).trim();

+					}

+					else {

+						newExt = exts;

+						exts = "";

+					}

+					

+					// Prefix an extension with a period.

+					if (newExt.charAt(0) != '.') {

+						newExt = "." + newExt;

+					}

+					mimeExts.add( newExt );

+				} 

+			}

+			

+			// else if the line defines a list of regular expressions

+			else if (data.indexOf( "regex" ) == 0 && mimeType != null) {

+				// Do nothing with these right now.

+			}

+		}

+		

+		

+		// If the current mime type is still being processed

+		if (!saveType) {

+			// Get the next line			

+			try {

+				line = reader.readLine();

+			}

+			catch (IOException e) {

+				line = null;

+			}

+		}

+		

+		// If the current type should be saved or if the end

+		// of the file was reached

+		if (saveType || (line == null)) {

+

+			// If there is a mime type to be saved

+			if (mimeType != null) {

+			

+				// If the mime type does not exist in the map, add it.

+				Vector prevExts = (Vector) info.get( mimeType );

+				if (prevExts == null) {

+					info.put( mimeType, mimeExts );

+				}

+		

+				// else append the new list of extensions.

+				else {

+					for (int i = 0; i < mimeExts.size(); i++) {

+						prevExts.add( mimeExts.elementAt( i ) );

+					}

+				}

+				mimeType = null;

+				mimeExts = null;

+				saveType = false;

+			}

+		}

+	}

+}

+

+// Private method for parsing a command line into its arguments.

+private static String[] parseCommand( String cmd ) {

+	Vector args = new Vector();

+	int sIndex = 0;

+	int eIndex;

+	while (sIndex < cmd.length()) {

+		// Trim initial white space of argument.

+		while (sIndex < cmd.length() && Character.isWhitespace( cmd.charAt(sIndex) )) {

+			sIndex++;

+		}

+		if (sIndex < cmd.length()) {

+			// If the command is a quoted string

+			if (cmd.charAt(sIndex) == '"' || cmd.charAt(sIndex) == '\''){

+				// Find the terminating quote (or end of line).

+				// This code currently does not handle escaped characters (e.g., " a\"b").

+				eIndex = sIndex + 1;

+				while (eIndex < cmd.length() && cmd.charAt(eIndex) != cmd.charAt(sIndex)) {

+					eIndex++;

+				}

+				if (eIndex >= cmd.length()) { // the terminating quote was not found

+					// Add the argument as is with only one initial quote.

+					args.add( cmd.substring( sIndex, eIndex ) );

+				}

+				// else add the argument, trimming off the quotes.

+				else {

+					args.add( cmd.substring( sIndex+1, eIndex ) );

+				}

+				sIndex = eIndex + 1;

+			}

+			

+			// else use white space for the delimiters.

+			else {

+				eIndex = sIndex;

+				while (eIndex < cmd.length() && !Character.isWhitespace( cmd.charAt(eIndex) )) {

+					eIndex++;

+				}

+				args.add( cmd.substring( sIndex, eIndex ) );

+				sIndex = eIndex + 1;

+			}

+		}

+	}

+	

+	String[] strings = new String[ args.size() ];

+	for (int index =0; index < args.size(); index++) {

+		strings[ index ] = (String) args.elementAt( index );

+	}

+	return strings;

+}

+

+

+static String gnome_getDataDirectory(String dirName) {

+	byte [] nameBuffer = Converter.wcsToMbcs (null, dirName, true);

+	int ptr = GNOME.gnome_datadir_file(nameBuffer);

+	if (ptr == 0) return null;

+	int length = OS.strlen(ptr);

+	byte[] dirBuffer = new byte[length];

+	OS.memmove(dirBuffer, ptr, length);

+	return new String(Converter.mbcsToWcs(null, dirBuffer));

+}

+

+static String gnome_getHomeDirectory() {

+	int ptr = GNOME.g_get_home_dir();

+	if (ptr == 0) return null;

+	int length = OS.strlen(ptr);

+	byte[] homeDirBuffer = new byte[length];

+	OS.memmove(homeDirBuffer, ptr, length);

+	return new String(Converter.mbcsToWcs(null, homeDirBuffer));

+}

+

+static String gnome_getMimeType(String name) {

+	byte [] nameBuffer = Converter.wcsToMbcs (null, name, true);

+	int ptr = GNOME.gnome_mime_type(nameBuffer);

+	if (ptr == 0) return null;

+	int length = OS.strlen(ptr);

+	byte[] mimeBuffer = new byte[length];

+	OS.memmove(mimeBuffer, ptr, length);

+	return new String(Converter.mbcsToWcs(null, mimeBuffer));

+}

+

+static String gnome_getMimeValue(String mimeType, String key) {

+	byte [] typeBuffer = Converter.wcsToMbcs (null, mimeType, true);

+	byte [] keyBuffer = Converter.wcsToMbcs (null, key, true);

+	int ptr = GNOME.gnome_mime_get_value(typeBuffer, keyBuffer);

+	if (ptr == 0) return null;

+	

+	StringBuffer stringBuffer = new StringBuffer();

+	int length = OS.strlen(ptr);

+	byte[] valueBuffer = new byte[length];

+	OS.memmove(valueBuffer, ptr, length);

+	return new String(Converter.mbcsToWcs(null, valueBuffer));

+}

+

+static boolean kde_init () {

+	try {

+		Callback.loadLibrary("swt-kde");

+	} catch (UnsatisfiedLinkError e) {

+		return false;

+	}

+	String appName = "KDE Platform Support";

+	byte [] nameBuffer = Converter.wcsToMbcs (null, appName, true);

+	int qcString = KDE.QCString_new (nameBuffer);

+	KDE.KApplication_new (qcString);

+	KDE.QCString_delete (qcString);

+	return true;

+}

+

+static String kde_convertQStringAndFree (int qString) {

+	int qCString = KDE.QString_utf8 (qString);

+	int charString = KDE.QCString_data (qCString);

+	

+	StringBuffer stringBuffer = new StringBuffer ();

+	int length = KDE.strlen (charString);

+	byte[] buffer = new byte [length];

+	KDE.memmove (buffer, charString, length);

+	String answer = new String (Converter.mbcsToWcs (null, buffer));

+		

+	KDE.QCString_delete (qCString);

+	KDE.QString_delete (qString);

+	return answer;

+}

+

+/*

+ * Launches the executable associated with the file in

+ * the operating system.  If the file is an executable,

+ * then the executable is launched.

+ *

+ * @param fileName the file or program name

+ * @return <code>true</code> if the file is launched, otherwise <code>false</code>

+ * 

+ * @exception SWTError <ul>

+ *		<li>ERROR_NULL_ARGUMENT when fileName is null</li>

+ *	</ul>

+ */

+public static boolean launch (String fileName) {

+	if (fileName == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);

+	

+	// If the argument appears to be a data file (it has an extension)

+	int index = fileName.lastIndexOf (".");

+	if (index > 0) {

+		

+		// Find the associated program, if one is defined.

+		String extension = fileName.substring (index);

+		Program program = Program.findProgram (extension);

+		

+		// If the associated program is defined and can be executed, return.

+		if (program != null && program.execute (fileName)) return true;

+	}

+	

+	// Otherwise, the argument was the program itself.

+	try {

+		Runtime.getRuntime().exec (fileName);

+		return true;

+	} catch (IOException e) {

+		return false;

+	}

+}

+

+/*

+ * Executes the program with the file as the single argument

+ * in the operating system.  It is the responsibility of the

+ * programmer to ensure that the file contains valid data for 

+ * this program.  

+ *

+ * @param fileName is the argument (typically a file) for the program

+ * @return <code>true</code> if the file is launched, otherwise <code>false</code>

+ * 

+ * @exception SWTError <ul>

+ *		<li>ERROR_NULL_ARGUMENT when fileName is null</li>

+ *	</ul>

+ */

+public boolean execute (String fileName) {

+	if (fileName == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

+	

+	// Parse the command into its individual arguments.

+	String[]  args = parseCommand( command );

+	int       fileArg = -1;

+	int       index;

+	for (index=0; index < args.length; index++) {

+		int j = args[ index ].indexOf( "%f" );

+		if (j != -1) {

+			String value = args[ index ];

+			fileArg = index;

+			args[ index ] = value.substring(0,j) + fileName + value.substring(j+2);

+		}

+	}

+	

+	// If a file name was given but the command did not have "%f"

+	if ((fileName.length() > 0) && (fileArg < 0)) {

+		String[] newArgs = new String[ args.length + 1 ];

+		for (index=0; index < args.length; index++)

+			newArgs[ index ] = args[ index ];

+		newArgs[ args.length ] = fileName;

+		args = newArgs;

+	}

+	

+	// Execute the command.

+	try {

+		Runtime.getRuntime().exec( args );

+	} catch (IOException e) {

+		return false;

+	}

+

+	return true;

+}

+

+/*

+ * Returns the receiver's image data.  This is the icon

+ * that is associated with the reciever in the operating

+ * system.

+ *

+ * @return the image data for the program

+ */

+public ImageData getImageData () {

+	String iconPath = null;

+	switch (Desktop) {

+		case DESKTOP_KDE:	

+			String urlString = "file://any." + extension;

+			byte [] buffer = Converter.wcsToMbcs (null, urlString, true);

+			int qString = KDE.QString_new(buffer);

+			int url = KDE.KURL_new(qString);

+			KDE.QString_delete(qString);			

+			int mimeType = KDE.KMimeType_findByURL(url);

+			if (mimeType == 0) return null;			

+			int mimeIcon = KDE.KMimeType_icon(mimeType, 0, 0);

+			int loader = KDE.KGlobal_iconLoader();

+			int path = KDE.KIconLoader_iconPath(loader, mimeIcon, KDE.KICON_SMALL, 1);

+			iconPath = kde_convertQStringAndFree(path);

+			break;

+		case DESKTOP_GNOME:

+			String fakeFileName = "file." + extension;

+			String mime = gnome_getMimeType(fakeFileName);

+			if (mime == null) return null;

+			iconPath = gnome_getMimeValue(mime, "icon-filename");

+			if (iconPath == null) return null;

+			break;

+		case DESKTOP_UNKNOWN:

+			return null;

+	}

+	if (iconPath.endsWith ("xpm")) {

+		//BAD

+		Display display = Display.getCurrent (); 

+		int xDisplay = display.xDisplay;

+		int drawable = OS.XDefaultRootWindow (xDisplay);		

+		int [] pixmap_ptr = new int [1], mask_ptr = new int [1];

+		byte [] buffer = Converter.wcsToMbcs (null, iconPath, true);

+		int result = OS.XpmReadFileToPixmap (xDisplay, drawable, buffer, pixmap_ptr, mask_ptr, 0);

+		if (result < 0) return null;

+		Image image = Image.motif_new (display, SWT.BITMAP, pixmap_ptr[0], mask_ptr [0]);

+		ImageData imageData = image.getImageData ();

+		image.dispose ();

+		return imageData;		

+	}

+	try {

+		return new ImageData (iconPath);

+	} catch (Exception e) {

+		return null;

+	}

+}

+

+/*

+ * Returns the receiver's name.  This is as short and

+ * descriptive a name as possible for the program.  If

+ * the program has no descriptive name, this string may

+ * be the executable name, path or empty.

+ *

+ * @return an the name of the program

+ */

+public String getName () {

+	return name;

+}

+

+public String toString () {

+	return "Program {" + name + "}";

+}

+static boolean gnome_init () {

+	try {

+		Callback.loadLibrary("swt-gnome");

+	} catch (UnsatisfiedLinkError e) {

+		return false;

+	}

+	return true;

+}

+

+}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/photon/org/eclipse/swt/program/Program.java b/bundles/org.eclipse.swt/Eclipse SWT Program/photon/org/eclipse/swt/program/Program.java
index 07e4589..319ecc5 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Program/photon/org/eclipse/swt/program/Program.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Program/photon/org/eclipse/swt/program/Program.java
@@ -31,7 +31,7 @@
 Program () {

 }

 

-/**

+/*

  * Finds the program that is associated with an extension.

  * The extension may or may not begin with a '.'.

  *

@@ -48,7 +48,7 @@
 	return null;

 }

 

-/**

+/*

  * Answer all program extensions in the operating system.

  *

  * @return an array of extensions

@@ -57,7 +57,7 @@
 	return new String[0];

 }

 

-/**

+/*

  * Answers all available programs in the operating system.

  *

  * @return an array of programs

@@ -86,7 +86,7 @@
 	return programs;

 }

 

-/**

+/*

  * Launches the executable associated with the file in

  * the operating system.  If the file is an executable,

  * then the executable is launched.

@@ -113,7 +113,7 @@
 	}

 }

 

-/**

+/*

  * Executes the program with the file as the single argument

  * in the operating system.  It is the responsibility of the

  * programmer to ensure that the file

@@ -139,18 +139,18 @@
 	return true;

 }

 

-/**

+/*

  * Returns the receiver's image data.  This is the icon

  * that is associated with the reciever in the operating

  * system.

  *

- * @return the image data for the program, may be null

+ * @return the image data for the program

  */

 public ImageData getImageData () {

 	return null;

 }

 

-/**

+/*

  * Returns the receiver's name.  This is as short and

  * descriptive a name as possible for the program.  If

  * the program has no descriptive name, this string may

@@ -162,31 +162,6 @@
 	return name;

 }

 

-/**

- * Returns true if the receiver and the argument represent

- * the same program.

- * 

- * @return true if the programs are the same

- */

-public boolean equals(Object other) {

-	if (this == other) return true;

-	if (other instanceof Program) {

-		final Program program = (Program) other;

-		return extension.equals(program.extension) && name.equals(program.name) &&

-			command.equals(program.command);

-	}

-	return false;

-}

-

-/**

- * Returns a hash code suitable for this object.

- * 

- * @return a hash code

- */

-public int hashCode() {

-	return extension.hashCode() ^ name.hashCode() ^ command.hashCode();

-}

-

 public String toString () {

 	return "Program {" + name + "}";

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java b/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java
index ce917ea..46925c3 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java
@@ -28,7 +28,7 @@
 Program () {

 }

 

-/**

+/*

  * Finds the program that is associated with an extension.

  * The extension may or may not begin with a '.'.

  *

@@ -43,7 +43,6 @@
 	if (extension == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);

 	if (extension.length () == 0) return null;

 	if (extension.charAt (0) != '.') extension = "." + extension;

-	/* Use the character encoding for the default locale */

 	byte [] key = Converter.wcsToMbcs (0, extension, true);

 	int [] phkResult = new int [1];

 	if (OS.RegOpenKeyEx (OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult) != 0) {

@@ -57,7 +56,7 @@
 	return getProgram (lpData);

 }

 

-/**

+/*

  * Answer all program extensions in the operating system.

  *

  * @return an array of extensions

@@ -72,7 +71,6 @@
 			while (length < key.length && key [length] != 0) length++;

 			byte [] buffer = new byte [length];

 			System.arraycopy (key, 0, buffer, 0, length);

-			/* Use the character encoding for the default locale */

 			String extension = new String (Converter.mbcsToWcs (0, buffer));

 			if (count == extensions.length) {

 				String [] newExtensions = new String [extensions.length + 1024];

@@ -101,7 +99,6 @@
 	if (OS.RegQueryValueEx (phkResult [0], null, 0, null, null, lpcbData) == 0) {

 		byte [] lpData = new byte [lpcbData [0]];

 		if (OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData) == 0) {

-			/* Use the character encoding for the default locale */

 			char [] charArray = Converter.mbcsToWcs (0, lpData);

 			result = new String (charArray, 0, charArray.length - 1);

 		}

@@ -113,7 +110,6 @@
 static Program getProgram (byte [] key) {

 

 	/* Command */

-	/* Use the character encoding for the default locale */

 	byte [] COMMAND = Converter.wcsToMbcs (0, "\\shell\\open\\command", true);

 	int length = 0;

 	while (length < key.length && key [length] != 0) length++;

@@ -128,7 +124,6 @@
 	if (name == null || name.length () == 0) return null;

 		

 	/* Icon */

-	/* Use the character encoding for the default locale */

 	byte [] DEFAULT_ICON = Converter.wcsToMbcs (0, "\\DefaultIcon", true);

 	for (int i=0; i<DEFAULT_ICON.length; i++) key [length + i] = DEFAULT_ICON [i];

 	key [length + DEFAULT_ICON.length] = 0;

@@ -142,7 +137,7 @@
 	return program;

 }

 

-/**

+/*

  * Answers all available programs in the operating system.

  *

  * @return an array of programs

@@ -171,7 +166,7 @@
 	return programs;

 }

 

-/**

+/*

  * Launches the executable associated with the file in

  * the operating system.  If the file is an executable,

  * then the executable is launched.

@@ -185,13 +180,12 @@
  */

 public static boolean launch (String fileName) {

 	if (fileName == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);

-	/* Use the character encoding for the default locale */

 	byte [] OPEN = Converter.wcsToMbcs (0, "open", true);

 	byte [] lpFile = Converter.wcsToMbcs (0, fileName, true);

 	return OS.ShellExecute (0, OPEN, lpFile, null, null, OS.SW_SHOW) > 32;

 }

 

-/**

+/*

  * Executes the program with the file as the single argument

  * in the operating system.  It is the responsibility of the

  * programmer to ensure that the file contains valid data for 

@@ -229,12 +223,12 @@
 	return true;

 }

 

-/**

+/*

  * Returns the receiver's image data.  This is the icon

  * that is associated with the reciever in the operating

  * system.

  *

- * @return the image data for the program, may be null

+ * @return the image data for the program

  */

 public ImageData getImageData () {

 	int nIconIndex = 0;

@@ -247,7 +241,6 @@
 			nIconIndex = Integer.parseInt (iconIndex);

 		} catch (NumberFormatException e) {};

 	}

-	/* Use the character encoding for the default locale */

 	byte [] lpszFile = Converter.wcsToMbcs (0, fileName, true);

 	int [] phiconSmall = new int[1], phiconLarge = null;

 	OS.ExtractIconEx (lpszFile, nIconIndex, phiconLarge, phiconSmall, 1);

@@ -258,7 +251,7 @@
 	return imageData;

 }

 

-/**

+/*

  * Returns the receiver's name.  This is as short and

  * descriptive a name as possible for the program.  If

  * the program has no descriptive name, this string may

@@ -270,31 +263,6 @@
 	return name;

 }

 

-/**

- * Returns true if the receiver and the argument represent

- * the same program.

- * 

- * @return true if the programs are the same

- */

-public boolean equals(Object other) {

-	if (this == other) return true;

-	if (other instanceof Program) {

-		final Program program = (Program) other;

-		return name.equals(program.name) && command.equals(program.command)

-			&& iconName.equals(program.iconName);

-	}

-	return false;

-}

-

-/**

- * Returns a hash code suitable for this object.

- * 

- * @return a hash code

- */

-public int hashCode() {

-	return name.hashCode() ^ command.hashCode() ^ iconName.hashCode();

-}

-

 public String toString () {

 	return "Program {" + name + "}";

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c b/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c
index d1bdfd6..5e98e3c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c
@@ -152,8 +152,8 @@
     isStatic = (*env)->GetBooleanField(env,lpCallback,PGLOB(isStaticID));

     argCount = (*env)->GetIntField(env,lpCallback,PGLOB(argCountID));

     isArrayBased = (*env)->GetBooleanField(env,lpCallback,PGLOB(isArrayBasedID));

-    methodString = (const char *) (*env)->GetStringUTFChars(env, javaMethod, NULL);

-    sigString = (const char *) (*env)->GetStringUTFChars(env, javaSignature, NULL);

+    methodString = (*env)->GetStringUTFChars(env, javaMethod, NULL);

+    sigString = (*env)->GetStringUTFChars(env, javaSignature, NULL);

     if (isStatic) {

         mid = (*env)->GetStaticMethodID(env, javaObject, methodString, sigString);

     } else {

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
index b7b1e8c..b8747c6 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
@@ -20,7 +20,6 @@
  * <code>disposalMethod</code> and <code>delayTime</code> are

  * typically only used when the image is in a set of images used

  * for animation.

- * </p>

  *

  * @see Image

  * @see ImageLoader

@@ -40,40 +39,24 @@
 

 	/**

 	 * the color depth of the image, in bits per pixel

-	 * <p>

-	 * Note that a depth of 8 or less does not necessary

-	 * mean that the image is palette indexed, or

-	 * conversely that a depth greater than 8 means that

-	 * the image is direct color.  Check the associated

-	 * PaletteData's isDirect field for such determinations.

 	 */

 	public int depth;

 

 	/**

-	 * the scanline padding

-	 * <p>

-	 * If one scanline of the image is not a multiple of

-	 * this number, it will be padded with zeros until it is.

-	 * </p>

+	 * the scanline padding. If one scanline of the image

+	 * is not a multiple of this number, it will be padded

+	 * with zeros until it is

 	 */

 	public int scanlinePad;

 

 	/**

-	 * the number of bytes per scanline

-	 * <p>

-	 * This is a multiple of the scanline padding.

-	 * </p>

+	 * the number of bytes per scanline. This is a multiple

+	 * of the scanline padding

 	 */

 	public int bytesPerLine;

 

 	/**

 	 * the pixel data of the image

-	 * <p>

-	 * Note that for 16 bit depth images the pixel data is stored

-	 * in least significant byte order; however, for 24bit and

-	 * 32bit depth images the pixel data is stored in most

-	 * significant byte order.

-	 * </p>

 	 */

 	public byte[] data;

 

@@ -83,58 +66,33 @@
 	public PaletteData palette;

 

 	/**

-	 * the transparent pixel

-	 * <p>

-	 * Pixels with this value are transparent.

-	 * </p><p>

-	 * The default is -1 which means 'no transparent pixel'.

-	 * </p>

+	 * the transparent pixel. Pixels with this value are transparent.

+	 * The default is -1 which means 'no transparency'

 	 */

 	public int transparentPixel;

 

 	/**

 	 * icon-specific field containing the data from the icon mask

-	 * <p>

-	 * This is a 1 bit bitmap stored with the most significant

-	 * bit first.  The number of bytes per scanline is

-	 * '((width + 7) / 8 + (maskPad - 1)) / maskPad * maskPad'.

-	 * </p><p>

-	 * The default is null which means 'no transparency mask'.

-	 * </p>

 	 */

 	public byte[] maskData;

 

 	/**

 	 * icon-specific field containing the scanline pad of the mask

-	 * <p>

-	 * If one scanline of the transparency mask is not a

-	 * multiple of this number, it will be padded with zeros until

-	 * it is.

-	 * </p>

 	 */

 	public int maskPad;

 	

 	/**

-	 * the alpha data of the image

-	 * <p>

-	 * Every pixel can have an <em>alpha blending</em> value that

-	 * varies from 0, meaning fully transparent, to 255 meaning

-	 * fully opaque.  The number of bytes per scanline is

-	 * 'width'.

-	 * </p>

+	 * the alpha data of the image.  Every pixel can have an

+	 * <em>alpha blending</em> value that varies from 0, meaning

+	 * fully transparent, to 255 meaning fully opaque

 	 */

 	public byte[] alphaData;

 	

 	/**

-	 * the global alpha value to be used for every pixel

-	 * <p>

-	 * If this value is set, the <code>alphaData</code> field

-	 * is ignored and when the image is rendered each pixel

-	 * will be blended with the background an amount

-	 * proportional to this value.

-	 * </p><p>

-	 * The default is -1 which means 'no global alpha value'

-	 * </p>

+	 * the global alpha value to be used for every pixel.

+	 * If this value is set the <code>alphaData</code> field

+	 * is ignored. The default is -1 which means 'no global alpha

+	 * value'

 	 */

 	public int alpha;

 

@@ -196,36 +154,7 @@
 	 * Delay Time value)

 	 */

 	public int delayTime;

-

-	/**

-	 * Arbitrary channel width data to 8-bit conversion table

-	 */

-	static final byte[][] ANY_TO_EIGHT = new byte[9][];

-	static {

-		for (int b = 0; b < 9; ++b) {

-			byte[] data = ANY_TO_EIGHT[b] = new byte[1 << b];

-			if (b == 0) continue;

-			int inc = 0;

-			for (int bit = 0x10000; (bit >>= b) != 0;) inc |= bit;

-			for (int v = 0, p = 0; v < 0x10000; v+= inc) data[p++] = (byte)(v >> 8);

-		}

-	}

-	static final byte[] ONE_TO_ONE_MAPPING = ANY_TO_EIGHT[8];

-

-	/**

-	 * Scaled 8x8 Bayer dither matrix

-	 */

-	static final int[][] DITHER_MATRIX = {

-		{ 0xfc0000, 0x7c0000, 0xdc0000, 0x5c0000, 0xf40000, 0x740000, 0xd40000, 0x540000 },

-		{ 0x3c0000, 0xbc0000, 0x1c0000, 0x9c0000, 0x340000, 0xb40000, 0x140000, 0x940000 },

-		{ 0xcc0000, 0x4c0000, 0xec0000, 0x6c0000, 0xc40000, 0x440000, 0xe40000, 0x640000 },

-		{ 0x0c0000, 0x8c0000, 0x2c0000, 0xac0000, 0x040000, 0x840000, 0x240000, 0xa40000 },

-		{ 0xf00000, 0x700000, 0xd00000, 0x500000, 0xf80000, 0x780000, 0xd80000, 0x580000 },

-		{ 0x300000, 0xb00000, 0x100000, 0x900000, 0x380000, 0xb80000, 0x180000, 0x980000 },

-		{ 0xc00000, 0x400000, 0xe00000, 0x600000, 0xc80000, 0x480000, 0xe80000, 0x680000 },

-		{ 0x000000, 0x800000, 0x200000, 0xa00000, 0x080000, 0x880000, 0x280000, 0xa80000 }

-	};

-

+	

 /**

  * Constructs a new, empty ImageData with the given width, height,

  * depth and palette. The data will be initialized to an (all zero)

@@ -556,7 +485,7 @@
  * </ul>

  */

 public int getAlpha(int x, int y) {

-	if (x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

+	if (x > width || y > height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 

 	if (alphaData == null) return 255;

 	return alphaData[y * width + x] & 0xFF;

@@ -573,17 +502,15 @@
  * @param alphas the buffer in which to put the alpha values

  * @param startIndex the offset into the image to begin getting alpha values

  *

- * @exception IndexOutOfBoundsException if getWidth is too large

  * @exception IllegalArgumentException <ul>

  *    <li>ERROR_NULL_ARGUMENT - if pixels is null</li>

- *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>

- *    <li>ERROR_INVALID_ARGUMENT - if getWidth is negative</li>

+ *    <li>ERROR_INVALID_ARGUMENT - if <code>x</code> or <code>y</code> is out of bounds</li>

  * </ul>

  */

 public void getAlphas(int x, int y, int getWidth, byte[] alphas, int startIndex) {

 	if (alphas == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

-	if (getWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

-	if (getWidth == 0) return;

+	if (getWidth <= 0) return;

+	if (x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 

 	if (alphaData == null) {

 		int endIndex = startIndex + getWidth;

@@ -592,7 +519,6 @@
 		}

 		return;

 	}

-	// may throw an IndexOutOfBoundsException

 	System.arraycopy(alphaData, y * width + x, alphas, startIndex, getWidth);

 }

 

@@ -612,7 +538,7 @@
  * </ul>

  */

 public int getPixel(int x, int y) {

-	if (x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

+	if (x > width || y > height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 	int index;

 	int theByte;

 	int mask;

@@ -675,11 +601,9 @@
  * @param pixels the buffer in which to put the pixels

  * @param startIndex the offset into the byte array to begin storing pixels

  *

- * @exception IndexOutOfBoundsException if getWidth is too large

  * @exception IllegalArgumentException <ul>

  *    <li>ERROR_NULL_ARGUMENT - if pixels is null</li>

  *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>

- *    <li>ERROR_INVALID_ARGUMENT - if getWidth is negative</li>

  * </ul>

  * @exception SWTException <ul>

  *    <li>ERROR_UNSUPPORTED_DEPTH - if the depth is not one of 1, 2, 4 or 8

@@ -688,8 +612,8 @@
  */

 public void getPixels(int x, int y, int getWidth, byte[] pixels, int startIndex) {

 	if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

-	if (getWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

-	if (getWidth == 0) return;

+	if (getWidth <= 0) return;

+	if (x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 	int index;

 	int theByte;

 	int mask = 0;

@@ -824,11 +748,9 @@
  * @param pixels the buffer in which to put the pixels

  * @param startIndex the offset into the buffer to begin storing pixels

  *

- * @exception IndexOutOfBoundsException if getWidth is too large

  * @exception IllegalArgumentException <ul>

  *    <li>ERROR_NULL_ARGUMENT - if pixels is null</li>

  *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>

- *    <li>ERROR_INVALID_ARGUMENT - if getWidth is negative</li>

  * </ul>

  * @exception SWTException <ul>

  *    <li>ERROR_UNSUPPORTED_DEPTH - if the depth is not one of 1, 2, 4, 8, 16, 24 or 32</li>

@@ -836,8 +758,8 @@
  */

 public void getPixels(int x, int y, int getWidth, int[] pixels, int startIndex) {

 	if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

-	if (getWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

-	if (getWidth == 0) return;

+	if (getWidth <= 0) return;

+	if (x > width || y > height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 	int index;

 	int theByte;

 	int mask;

@@ -1053,15 +975,6 @@
 }

 

 /**

- * Returns the byte order of the receiver.

- * 

- * @return MSB_FIRST or LSB_FIRST

- */

-int getByteOrder() {

-	return (depth != 16) ? MSB_FIRST : LSB_FIRST;

-}

-

-/**

  * Returns a copy of the receiver which has been stretched or

  * shrunk to the specified size. If either the width or height

  * is negative, the resulting image will be inverted in the

@@ -1072,54 +985,97 @@
  * @return a scaled copy of the image

  */

 public ImageData scaledTo(int width, int height) {

-	/* Create a destination image with no data */

-	final boolean flipX = (width < 0);

-	if (flipX) width = - width;

-	final boolean flipY = (height < 0);

-	if (flipY) height = - height;

-

-	ImageData dest = new ImageData(

+	/* Create a destination image with no data,

+	 * and then scale all of the data. */

+	ImageData destImage = new ImageData(

 		width, height, depth, palette,

 		scanlinePad, null, 0, null,

 		null, -1, transparentPixel, type,

 		x, y, disposalMethod, delayTime);

+	scaleImage(destImage, 0, 0, this.width, this.height, 0, 0, width, height);

+	return destImage;

+}

 

-	/* Scale the image contents */

-	if (palette.isDirect) blit(BLIT_SRC,

-		this.data, this.depth, this.bytesPerLine, this.getByteOrder(), 0, 0, this.width, this.height, 0, 0, 0,

-		ALPHA_OPAQUE, null, 0,

-		dest.data, dest.depth, dest.bytesPerLine, dest.getByteOrder(), 0, 0, dest.width, dest.height, 0, 0, 0,

-		flipX, flipY);

-	else blit(BLIT_SRC,

-		this.data, this.depth, this.bytesPerLine, this.getByteOrder(), 0, 0, this.width, this.height, null, null, null,

-		ALPHA_OPAQUE, null, 0,

-		dest.data, dest.depth, dest.bytesPerLine, dest.getByteOrder(), 0, 0, dest.width, dest.height, null, null, null,

-		flipX, flipY);

-	

-	/* Scale the image mask or alpha */

-	if (maskData != null) {

-		dest.maskPad = this.maskPad;

-		int destBpl = (dest.width + 7) / 8;

-		destBpl = (destBpl + (dest.maskPad - 1)) / dest.maskPad * dest.maskPad;

-		dest.maskData = new byte[destBpl * dest.height];

-		int srcBpl = (this.width + 7) / 8;

-		srcBpl = (srcBpl + (this.maskPad - 1)) / this.maskPad * this.maskPad;

-		blit(BLIT_SRC,

-			this.maskData, 1, srcBpl, MSB_FIRST, 0, 0, this.width, this.height, null, null, null,

-			ALPHA_OPAQUE, null, 0,

-			dest.maskData, 1, destBpl, MSB_FIRST, 0, 0, dest.width, dest.height, null, null, null,

-			flipX, flipY);

-	} else if (alpha != -1) {

-		dest.alpha = this.alpha;

-	} else if (alphaData != null) {

-		dest.alphaData = new byte[dest.width * dest.height];

-		blit(BLIT_SRC,

-			this.alphaData, 8, this.width, MSB_FIRST, 0, 0, this.width, this.height, null, null, null,

-			ALPHA_OPAQUE, null, 0,

-			dest.alphaData, 8, dest.width, MSB_FIRST, 0, 0, dest.width, dest.height, null, null, null,

-			flipX, flipY);

+void scaleImage(ImageData destImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {

+	boolean flipX, flipY;

+	/* Flip rects if necessary so that src width and height are positive. */

+	if (srcWidth < 0) {

+		srcWidth = -srcWidth;

+		srcX = srcX - srcWidth;

+		destWidth = -destWidth;

+		destX = destX - destWidth;

 	}

-	return dest;

+	if (srcHeight < 0) {

+		srcHeight = -srcHeight;

+		srcY = srcY - srcHeight;

+		destHeight = -destHeight;

+		destY = destY - destHeight;

+	}

+	/* Ensure dest width and height are positive, remembering whether to flip. */

+	flipX = destWidth < 0;

+	if (flipX) {

+		destWidth = -destWidth;

+		destX = destX - destWidth;

+	}

+	flipY = destHeight < 0;

+	if (flipY) {

+		destHeight = -destHeight;

+		destY = destY - destHeight;

+	}

+	/* Check source rect bounds. Succeed with 0 if out of bounds, rather

+	 * than failing.

+	 */

+	if (srcX < 0 || srcY < 0 || (srcX + srcWidth > width) ||

+		(srcY + srcHeight > height)) {

+		return;

+	}

+	if (destX < 0 || destY < 0 || (destX + destWidth > destImage.width) ||

+		(destY + destHeight > destImage.height)) {

+		return;

+	}

+	/* If dest rect is 0, there is nothing to do. */

+	if (destWidth == 0 || destHeight == 0) {

+		return;

+	}

+	switch (depth) {

+		case 1:

+			stretch1(data, bytesPerLine, MSB_FIRST, srcX, srcY, srcWidth, srcHeight, destImage.data, destImage.bytesPerLine, MSB_FIRST, destX, destY, destWidth, destHeight, flipX, flipY);

+			break;

+		case 2:

+			stretch2(data, bytesPerLine, srcX, srcY, srcWidth, srcHeight, destImage.data, destImage.bytesPerLine, destX, destY, destWidth, destHeight, null, flipX, flipY);

+			break;

+		case 4:

+			stretch4(data, bytesPerLine, srcX, srcY, srcWidth, srcHeight, destImage.data, destImage.bytesPerLine, destX, destY, destWidth, destHeight, null, flipX, flipY);

+			break;

+		case 8:

+			stretch8(data, bytesPerLine, srcX, srcY, srcWidth, srcHeight, destImage.data, destImage.bytesPerLine, destX, destY, destWidth, destHeight, null, flipX, flipY);

+			break;

+		case 16:

+			stretch16(data, bytesPerLine, srcX, srcY, srcWidth, srcHeight, destImage.data, destImage.bytesPerLine, destX, destY, destWidth, destHeight, flipX, flipY);

+			break;

+		case 24:		

+			stretch24(data, bytesPerLine, srcX, srcY, srcWidth, srcHeight, destImage.data, destImage.bytesPerLine, destX, destY, destWidth, destHeight, flipX, flipY);

+			break;

+		case 32:

+			stretch32(data, bytesPerLine, srcX, srcY, srcWidth, srcHeight, destImage.data, destImage.bytesPerLine, destX, destY, destWidth, destHeight, flipX, flipY);

+			break;

+		default:

+			SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);

+	}

+	if (getTransparencyType() == SWT.TRANSPARENCY_MASK) {

+		destImage.maskPad = maskPad;

+		int destBpl = (destWidth + 7) / 8;

+		destBpl = (destBpl + (maskPad - 1)) / maskPad * maskPad;

+		destImage.maskData = new byte[destBpl * destHeight];

+		int srcBpl = (srcWidth + 7) / 8;

+		srcBpl = (srcBpl + (maskPad - 1)) / maskPad * maskPad;

+		stretch1(maskData, srcBpl, MSB_FIRST, srcX, srcY, srcWidth, srcHeight, destImage.maskData, destBpl, MSB_FIRST, destX, destY, destWidth, destHeight, flipX, flipY);

+	} else if (alpha != -1) {

+		destImage.alpha = alpha;

+	} else if (alphaData != null) {

+		destImage.alphaData = new byte[destImage.width * destImage.height];

+		stretch8(alphaData, width, srcX, srcY, srcWidth, srcHeight, destImage.alphaData, destImage.width, destX, destY, destWidth, destHeight, null, flipX, flipY);

+	}

 }

 

 /**

@@ -1135,7 +1091,7 @@
  *  </ul>

  */

 public void setAlpha(int x, int y, int alpha) {

-	if (x >= width || y >= height || x < 0 || y < 0 || alpha < 0 || alpha > 255)

+	if (x > width || y > height || x < 0 || y < 0 || alpha < 0 || alpha > 255)

 		SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 	

 	if (alphaData == null) alphaData = new byte[width * height];

@@ -1154,20 +1110,17 @@
  * @param alphas the alpha values to set

  * @param startIndex the index at which to begin setting

  *

- * @exception IndexOutOfBoundsException if putWidth is too large

  * @exception IllegalArgumentException <ul>

  *    <li>ERROR_NULL_ARGUMENT - if pixels is null</li>

  *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>

- *    <li>ERROR_INVALID_ARGUMENT - if putWidth is negative</li>

  * </ul>

  */

 public void setAlphas(int x, int y, int putWidth, byte[] alphas, int startIndex) {

 	if (alphas == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

-	if (putWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

-	if (putWidth == 0) return;

+	if (putWidth <= 0) return;

+	if (x > width || y > height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 	

 	if (alphaData == null) alphaData = new byte[width * height];

-	// may throw an IndexOutOfBoundsException

 	System.arraycopy(alphas, startIndex, alphaData, y * width + x, putWidth);

 }

 

@@ -1187,7 +1140,7 @@
  * </ul>

  */

 public void setPixel(int x, int y, int pixelValue) {

-	if (x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

+	if (x > width || y > height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 	int index;

 	byte theByte;

 	int mask;

@@ -1260,11 +1213,9 @@
  * @param pixels the pixels to set

  * @param startIndex the index at which to begin setting

  *

- * @exception IndexOutOfBoundsException if putWidth is too large

  * @exception IllegalArgumentException <ul>

  *    <li>ERROR_NULL_ARGUMENT - if pixels is null</li>

  *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>

- *    <li>ERROR_INVALID_ARGUMENT - if putWidth is negative</li>

  * </ul>

  * @exception SWTException <ul>

  *    <li>ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8

@@ -1273,8 +1224,8 @@
  */

 public void setPixels(int x, int y, int putWidth, byte[] pixels, int startIndex) {

 	if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

-	if (putWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

-	if (putWidth == 0) return;

+	if (putWidth <= 0) return;

+	if (x > width || y > height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 	int index;

 	int theByte;

 	int mask;

@@ -1388,11 +1339,9 @@
  * @param pixels the pixels to set

  * @param startIndex the index at which to begin setting

  *

- * @exception IndexOutOfBoundsException if putWidth is too large

  * @exception IllegalArgumentException <ul>

  *    <li>ERROR_NULL_ARGUMENT - if pixels is null</li>

  *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>

- *    <li>ERROR_INVALID_ARGUMENT - if putWidth is negative</li>

  * </ul>

  * @exception SWTException <ul>

  *    <li>ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8, 16, 24 or 32</li>

@@ -1400,8 +1349,8 @@
  */

 public void setPixels(int x, int y, int putWidth, int[] pixels, int startIndex) {

 	if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

-	if (putWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

-	if (putWidth == 0) return;

+	if (putWidth <= 0) return;

+	if (x > width || y > height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 	int index;

 	int theByte;

 	int mask;

@@ -1569,6 +1518,43 @@
 }

 

 /**

+ * Blit operations.

+ */

+static final int BLIT_SRC = 1;

+static final int BLIT_ALPHA = 2;

+/**

+ * Byte and bit order constants.

+ */

+static final int MSB_FIRST = 1;

+static final int LSB_FIRST = 2;

+

+/**

+ * Masks for blitting.

+ */

+static final byte[] msbMasks1 = {

+	(byte)0x80, (byte)0x40, (byte)0x20, (byte)0x10, 

+	(byte)0x08, (byte)0x04, (byte)0x02, (byte)0x01

+};

+static final byte[] lsbMasks1 = {

+	(byte)0x01, (byte)0x02, (byte)0x04, (byte)0x08,

+	(byte)0x10, (byte)0x20, (byte)0x40, (byte)0x80

+};

+static final byte[] msbInverseMasks1 = {

+	(byte)0x7F, (byte)0xBF, (byte)0xDF, (byte)0xEF,

+	(byte)0xF7, (byte)0xFB, (byte)0xFD, (byte)0xFE

+};

+static final byte[] lsbInverseMasks1 = {

+	(byte)0xFE, (byte)0xFD, (byte)0xFB, (byte)0xF7,

+	(byte)0xEF, (byte)0xDF, (byte)0xBF, (byte)0x7F

+};

+static final byte[] masks2 = {

+	(byte)0x03, (byte)0x0C, (byte)0x30, (byte)0xC0

+};

+static final byte[] inverseMasks2 = {

+	(byte)0xFC, (byte)0xF3, (byte)0xCF, (byte)0x3F

+};

+

+/**

  * Gets the offset of the most significant bit for

  * the given mask.

  */

@@ -1610,1931 +1596,1856 @@
 }

 

 /**

- * Blit operation bits to be OR'ed together to specify the desired operation.

- */

-static final int

-	BLIT_SRC = 1,     // copy source directly, else applies logic operations

-	BLIT_ALPHA = 2,   // enable alpha blending

-	BLIT_DITHER = 4;  // enable dithering in low color modes

-

-/**

- * Alpha mode, values 0 - 255 specify global alpha level

- */

-static final int

-	ALPHA_OPAQUE = 255,           // Fully opaque (ignores any alpha data)

-	ALPHA_TRANSPARENT = 0,        // Fully transparent (ignores any alpha data)

-	ALPHA_CHANNEL_SEPARATE = -1,  // Use alpha channel from separate alphaData

-	ALPHA_CHANNEL_SOURCE = -2,    // Use alpha channel embedded in sourceData

-	ALPHA_MASK_UNPACKED = -3,     // Use transparency mask formed by bytes in alphaData (non-zero is opaque)

-	ALPHA_MASK_PACKED = -4,       // Use transparency mask formed by packed bits in alphaData

-	ALPHA_MASK_INDEX = -5,        // Consider source palette indices transparent if in alphaData array

-	ALPHA_MASK_RGB = -6;          // Consider source RGBs transparent if in RGB888 format alphaData array

-

-/**

- * Byte and bit order constants.

- */

-static final int MSB_FIRST = 1;

-static final int LSB_FIRST = 2;

-

-/**

- * Data types (internal)

- */

-private static final int

-	// direct / true color formats with arbitrary masks & shifts

-	TYPE_GENERIC_8 = 0,

-	TYPE_GENERIC_16_MSB = 1,

-	TYPE_GENERIC_16_LSB = 2,

-	TYPE_GENERIC_24 = 3,

-	TYPE_GENERIC_32_MSB = 4,

-	TYPE_GENERIC_32_LSB = 5,

-	// palette indexed color formats

-	TYPE_INDEX_8 = 6,

-	TYPE_INDEX_4 = 7,

-	TYPE_INDEX_2 = 8,

-	TYPE_INDEX_1_MSB = 9,

-	TYPE_INDEX_1_LSB = 10;

-

-/**

  * Blits a direct palette image into a direct palette image.

- * <p>

- * Note: When the source and destination depth, order and masks

- * are pairwise equal and the blitter operation is BLIT_SRC,

- * the masks are ignored.  Hence when not changing the image

- * data format, 0 may be specified for the masks.

- * </p>

- * 

- * @param op the blitter operation: a combination of BLIT_xxx flags

- *        (see BLIT_xxx constants)

- * @param srcData the source byte array containing image data

- * @param srcDepth the source depth: one of 8, 16, 24, 32

- * @param srcStride the source number of bytes per line

- * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;

- *        ignored if srcDepth is not 16 or 32

- * @param srcX the top-left x-coord of the source blit region

- * @param srcY the top-left y-coord of the source blit region

- * @param srcWidth the width of the source blit region

- * @param srcHeight the height of the source blit region

- * @param srcRedMask the source red channel mask

- * @param srcGreenMask the source green channel mask

- * @param srcBlueMask the source blue channel mask

- * @param alphaMode the alpha blending or mask mode, may be

- *        an integer 0-255 for global alpha; ignored if BLIT_ALPHA

- *        not specified in the blitter operations

- *        (see ALPHA_MODE_xxx constants)

- * @param alphaData the alpha blending or mask data, varies depending

- *        on the value of alphaMode and sometimes ignored

- * @param destData the destination byte array containing image data

- * @param destDepth the destination depth: one of 8, 16, 24, 32

- * @param destStride the destination number of bytes per line

- * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;

- *        ignored if destDepth is not 16 or 32

- * @param destX the top-left x-coord of the destination blit region

- * @param destY the top-left y-coord of the destination blit region

- * @param destWidth the width of the destination blit region

- * @param destHeight the height of the destination blit region

- * @param destRedMask the destination red channel mask

- * @param destGreenMask the destination green channel mask

- * @param destBlueMask the destination blue channel mask

- * @param flipX if true the resulting image is flipped along the vertical axis

- * @param flipY if true the resulting image is flipped along the horizontal axis

  */

-static void blit(int op,

-	byte[] srcData, int srcDepth, int srcStride, int srcOrder,

-	int srcX, int srcY, int srcWidth, int srcHeight,

-	int srcRedMask, int srcGreenMask, int srcBlueMask,

-	int alphaMode, byte[] alphaData, int alphaStride,

-	byte[] destData, int destDepth, int destStride, int destOrder,

-	int destX, int destY, int destWidth, int destHeight,

-	int destRedMask, int destGreenMask, int destBlueMask,

-	boolean flipX, boolean flipY) {

-	if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;

-

-	// these should be supplied as params later

-	final int srcAlphaMask = 0, destAlphaMask = 0;

-

-	/*** Prepare scaling data ***/

-	final int dwm1 = destWidth - 1;

-	final int sfxi = (dwm1 != 0) ? ((srcWidth << 16) - 1) / dwm1 : 0;

-	final int dhm1 = destHeight - 1;

-	final int sfyi = (dhm1 != 0) ? ((srcHeight << 16) - 1) / dhm1 : 0;

-

-	/*** Prepare source-related data ***/

-	final int sbpp, stype;

-	switch (srcDepth) {

-		case 8:

-			sbpp = 1;

-			stype = TYPE_GENERIC_8;

-			break;

-		case 16:

-			sbpp = 2;

-			stype = (srcOrder == MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;

-			break;

-		case 24:

-			sbpp = 3;

-			stype = TYPE_GENERIC_24;

-			break;

-		case 32:

-			sbpp = 4;

-			stype = (srcOrder == MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;

-			break;

-		default:

-			//throw new IllegalArgumentException("Invalid source type");

-			return;

-	}			

-	int spr = srcY * srcStride + srcX * sbpp;

-

-	/*** Prepare destination-related data ***/

-	final int dbpp, dtype;

-	switch (destDepth) {

-		case 8:

-			dbpp = 1;

-			dtype = TYPE_GENERIC_8;

-			break;

-		case 16:

-			dbpp = 2;

-			dtype = (destOrder == MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;

-			break;

-		case 24:

-			dbpp = 3;

-			dtype = TYPE_GENERIC_24;

-			break;

-		case 32:

-			dbpp = 4;

-			dtype = (destOrder == MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;

-			break;

-		default:

-			//throw new IllegalArgumentException("Invalid destination type");

-			return;

-	}			

-	int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX) * dbpp;

-	final int dprxi = (flipX) ? -dbpp : dbpp;

-	final int dpryi = (flipY) ? -destStride : destStride;

-

-	/*** Prepare special processing data ***/

-	int apr;

-	if ((op & BLIT_ALPHA) != 0) {

-		switch (alphaMode) {

-			case ALPHA_MASK_UNPACKED:

-			case ALPHA_CHANNEL_SEPARATE:

-				if (alphaData == null) alphaMode = 0x10000;

-				apr = srcY * alphaStride + srcX;

+static void blit(int op, byte[] srcData, int srcDepth, int srcStride, int srcOrder, int srcX, int srcY, int srcWidth, int srcHeight, int srcRedMask, int srcGreenMask, int srcBlueMask, int srcGlobalAlpha, byte[] srcAlphaData, int srcAlphaStride, byte[] destData, int destDepth, int destStride, int destOrder, int destX, int destY, int destWidth, int destHeight, int destRedMask, int destGreenMask, int destBlueMask, boolean flipX, boolean flipY) {

+	int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;

+	int dyd, dys, ey, dy, dyd2, dys2, ys, yd;

+	short syd, sys;

+	int dxd, dxs, ex, dx, dxd2, dxs2;

+	short sxd, sxs, sas;

+	int sp, dp, sap = 0;

+	int sr = 0, sg = 0, sb = 0, sa = 0, dr = 0, dg = 0, db = 0, da = 0;

+	int srcPixel = 0, destPixel = 0;

+	short so0 = 0, so1 = 1, so2 = 2, so3 = 3;

+	short do0 = 0, do1 = 1, do2 = 2, do3 = 3;

+	int srcRedShift, srcGreenShift, srcBlueShift;

+	int destRedShift, destGreenShift, destBlueShift;

+	

+	if (op == BLIT_SRC && srcDepth == destDepth &&

+		srcRedMask == destRedMask &&

+		srcGreenMask == destGreenMask &&

+		srcBlueMask == destBlueMask)

+	{

+		switch (srcDepth) {

+			case 16:

+				stretch16(srcData, srcStride, srcX, srcY, srcWidth, srcHeight, destData, destStride, destX, destY, destWidth, destHeight, flipX, flipY);

 				break;

-			case ALPHA_MASK_PACKED:

-				if (alphaData == null) alphaMode = 0x10000;

-				alphaStride <<= 3;

-				apr = srcY * alphaStride + srcX;

+			case 24:

+				stretch24(srcData, srcStride, srcX, srcY, srcWidth, srcHeight, destData, destStride, destX, destY, destWidth, destHeight, flipX, flipY);

 				break;

-			case ALPHA_MASK_INDEX:

-				//throw new IllegalArgumentException("Invalid alpha type");

-				return;

-			case ALPHA_MASK_RGB:

-				if (alphaData == null) alphaMode = 0x10000;

-				apr = 0;

-				break;

-			default:

-				alphaMode = (alphaMode << 16) / 255; // prescale

-			case ALPHA_CHANNEL_SOURCE:

-				apr = 0;

-				break;

-		}

-	} else {

-		alphaMode = 0x10000;

-		apr = 0;

-	}

-

-	/*** Blit ***/

-	int dp = dpr;

-	int sp = spr;

-	if ((alphaMode == 0x10000) && (stype == dtype) &&

-		(srcRedMask == destRedMask) && (srcGreenMask == destGreenMask) &&

-		(srcBlueMask == destBlueMask) && (srcAlphaMask == destAlphaMask)) {

-		/*** Fast blit (straight copy) ***/

-		switch (sbpp) {

-			case 1:

-				for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {

-					for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {

-						destData[dp] = srcData[sp];

-						sp += (sfx >>> 16);

-					}

-				}

-				break;					

-			case 2:

-				for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {

-					for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {

-						destData[dp] = srcData[sp];

-						destData[dp + 1] = srcData[sp + 1];

-						sp += (sfx >>> 16) * 2;

-					}

-				}

-				break;

-			case 3:

-				for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {

-					for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {

-						destData[dp] = srcData[sp];

-						destData[dp + 1] = srcData[sp + 1];

-						destData[dp + 2] = srcData[sp + 2];

-						sp += (sfx >>> 16) * 3;

-					}

-				}

-				break;

-			case 4:

-				for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {

-					for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {

-						destData[dp] = srcData[sp];

-						destData[dp + 1] = srcData[sp + 1];

-						destData[dp + 2] = srcData[sp + 2];

-						destData[dp + 3] = srcData[sp + 3];

-						sp += (sfx >>> 16) * 4;

-					}

-				}

+			case 32:

+				stretch32(srcData, srcStride, srcX, srcY, srcWidth, srcHeight, destData, destStride, destX, destY, destWidth, destHeight, flipX, flipY);

 				break;

 		}

 		return;

+	}	

+	

+	srcRedShift = 32 - getMSBOffset(srcRedMask);

+	srcGreenShift = 32 - getMSBOffset(srcGreenMask);

+	srcBlueShift = 32 - getMSBOffset(srcBlueMask);

+	destRedShift = 32 - getMSBOffset(destRedMask);

+	destGreenShift = 32 - getMSBOffset(destGreenMask);

+	destBlueShift = 32 - getMSBOffset(destBlueMask);

+	if (srcOrder == LSB_FIRST) {

+		switch (srcDepth) {

+			case 16: so0 = 1; so1 = 0; break;

+			case 24: so0 = 2; so1 = 1; so2 = 0; break;

+			case 32: so0 = 3; so1 = 2; so2 = 1; so3 = 0; break;

+		}

 	}

-	/*** Comprehensive blit (apply transformations) ***/

-	final int srcRedShift = getChannelShift(srcRedMask);

-	final byte[] srcReds = ANY_TO_EIGHT[getChannelWidth(srcRedMask, srcRedShift)];

-	final int srcGreenShift = getChannelShift(srcGreenMask);

-	final byte[] srcGreens = ANY_TO_EIGHT[getChannelWidth(srcGreenMask, srcGreenShift)];

-	final int srcBlueShift = getChannelShift(srcBlueMask);

-	final byte[] srcBlues = ANY_TO_EIGHT[getChannelWidth(srcBlueMask, srcBlueShift)];

-	final int srcAlphaShift = getChannelShift(srcAlphaMask);

-	final byte[] srcAlphas = ANY_TO_EIGHT[getChannelWidth(srcAlphaMask, srcAlphaShift)];

-

-	final int destRedShift = getChannelShift(destRedMask);

-	final int destRedWidth = getChannelWidth(destRedMask, destRedShift);

-	final byte[] destReds = ANY_TO_EIGHT[destRedWidth];

-	final int destRedPreShift = 8 - destRedWidth;

-	final int destGreenShift = getChannelShift(destGreenMask);

-	final int destGreenWidth = getChannelWidth(destGreenMask, destGreenShift);

-	final byte[] destGreens = ANY_TO_EIGHT[destGreenWidth];

-	final int destGreenPreShift = 8 - destGreenWidth;

-	final int destBlueShift = getChannelShift(destBlueMask);

-	final int destBlueWidth = getChannelWidth(destBlueMask, destBlueShift);

-	final byte[] destBlues = ANY_TO_EIGHT[destBlueWidth];

-	final int destBluePreShift = 8 - destBlueWidth;

-	final int destAlphaShift = getChannelShift(destAlphaMask);

-	final int destAlphaWidth = getChannelWidth(destAlphaMask, destAlphaShift);

-	final byte[] destAlphas = ANY_TO_EIGHT[destAlphaWidth];

-	final int destAlphaPreShift = 8 - destAlphaWidth;

-

-	int ap = apr, alpha = alphaMode;

-	int r = 0, g = 0, b = 0, a = 0;

-	int rq = 0, gq = 0, bq = 0, aq = 0;

-	for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,

-			sp = spr += (sfy >>> 16) * srcStride,

-			ap = apr += (sfy >>> 16) * alphaStride,

-			sfy = (sfy & 0xffff) + sfyi,

-			dp = dpr += dpryi) {

-		for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,

-				dp += dprxi,

-				sfx = (sfx & 0xffff) + sfxi) {

-			/*** READ NEXT PIXEL ***/

-			switch (stype) {

-				case TYPE_GENERIC_8: {

-					final int data = srcData[sp] & 0xff;

-					sp += (sfx >>> 16);

-					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;

-					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;

-					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;

-					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;

-				} break;

-				case TYPE_GENERIC_16_MSB: {

-					final int data = ((srcData[sp] & 0xff) << 8) | (srcData[sp + 1] & 0xff);

-					sp += (sfx >>> 16) * 2;

-					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;

-					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;

-					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;

-					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;

-				} break;

-				case TYPE_GENERIC_16_LSB: {

-					final int data = ((srcData[sp + 1] & 0xff) << 8) | (srcData[sp] & 0xff);

-					sp += (sfx >>> 16) * 2;

-					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;

-					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;

-					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;

-					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;

-				} break;

-				case TYPE_GENERIC_24: {

-					final int data = (( ((srcData[sp] & 0xff) << 8) |

-						(srcData[sp + 1] & 0xff)) << 8) |

-						(srcData[sp + 2] & 0xff);

-					sp += (sfx >>> 16) * 3;

-					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;

-					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;

-					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;

-					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;

-				} break;

-				case TYPE_GENERIC_32_MSB: {

-					final int data = (( (( ((srcData[sp] & 0xff) << 8) |

-						(srcData[sp + 1] & 0xff)) << 8) |

-						(srcData[sp + 2] & 0xff)) << 8) |

-						(srcData[sp + 3] & 0xff);

-					sp += (sfx >>> 16) * 4;

-					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;

-					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;

-					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;

-					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;

-				} break;

-				case TYPE_GENERIC_32_LSB: {

-					final int data = (( (( ((srcData[sp + 3] & 0xff) << 8) |

-						(srcData[sp + 2] & 0xff)) << 8) |

-						(srcData[sp + 1] & 0xff)) << 8) |

-						(srcData[sp] & 0xff);

-					sp += (sfx >>> 16) * 4;

-					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;

-					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;

-					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;

-					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;

-				} break;

-			}

-

-			/*** DO SPECIAL PROCESSING IF REQUIRED ***/

-			switch (alphaMode) {

-				case ALPHA_CHANNEL_SEPARATE:

-					alpha = ((alphaData[ap] & 0xff) << 16) / 255;

-					ap += (sfx >> 16);

-					break;

-				case ALPHA_CHANNEL_SOURCE:

-					alpha = (a << 16) / 255;

-					break;

-				case ALPHA_MASK_UNPACKED:

-					alpha = (alphaData[ap] != 0) ? 0x10000 : 0;

-					ap += (sfx >> 16);

-					break;						

-				case ALPHA_MASK_PACKED:

-					alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;

-					ap += (sfx >> 16);

-					break;

-				case ALPHA_MASK_RGB:

-					alpha = 0x10000;

-					for (int i = 0; i < alphaData.length; i += 3) {

-						if ((r == alphaData[i]) && (g == alphaData[i + 1]) && (b == alphaData[i + 2])) {

-							alpha = 0x0000;

-							break;

-						}

-					}

-					break;

-			}

-			if (alpha != 0x10000) {

-				if (alpha == 0x0000) continue;

-				switch (dtype) {

-					case TYPE_GENERIC_8: {

-						final int data = destData[dp] & 0xff;

-						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;

-						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;

-						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;

-						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;

-					} break;

-					case TYPE_GENERIC_16_MSB: {

-						final int data = ((destData[dp] & 0xff) << 8) | (destData[dp + 1] & 0xff);

-						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;

-						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;

-						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;

-						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;

-					} break;

-					case TYPE_GENERIC_16_LSB: {

-						final int data = ((destData[dp + 1] & 0xff) << 8) | (destData[dp] & 0xff);

-						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;

-						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;

-						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;

-						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;

-					} break;

-					case TYPE_GENERIC_24: {

-						final int data = (( ((destData[dp] & 0xff) << 8) |

-							(destData[dp + 1] & 0xff)) << 8) |

-							(destData[dp + 2] & 0xff);

-						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;

-						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;

-						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;

-						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;

-					} break;

-					case TYPE_GENERIC_32_MSB: {

-						final int data = (( (( ((destData[dp] & 0xff) << 8) |

-							(destData[dp + 1] & 0xff)) << 8) |

-							(destData[dp + 2] & 0xff)) << 8) |

-							(destData[dp + 3] & 0xff);

-						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;

-						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;

-						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;

-						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;

-					} break;

-					case TYPE_GENERIC_32_LSB: {

-						final int data = (( (( ((destData[dp + 3] & 0xff) << 8) |

-							(destData[dp + 2] & 0xff)) << 8) |

-							(destData[dp + 1] & 0xff)) << 8) |

-							(destData[dp] & 0xff);

-						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;

-						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;

-						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;

-						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;

-					} break;

-				}

-				// Perform alpha blending

-				a = aq + ((a - aq) * alpha >> 16);

-				r = rq + ((r - rq) * alpha >> 16);

-				g = gq + ((g - gq) * alpha >> 16);

-				b = bq + ((b - bq) * alpha >> 16);

-			}

-

-			/*** WRITE NEXT PIXEL ***/

-			final int data = 

-				(r >>> destRedPreShift << destRedShift) |

-				(g >>> destGreenPreShift << destGreenShift) |

-				(b >>> destBluePreShift << destBlueShift) |

-				(a >>> destAlphaPreShift << destAlphaShift);

-			switch (dtype) {

-				case TYPE_GENERIC_8: {

-					destData[dp] = (byte) data;

-				} break;

-				case TYPE_GENERIC_16_MSB: {

-					destData[dp] = (byte) (data >>> 8);

-					destData[dp + 1] = (byte) (data & 0xff);

-				} break;

-				case TYPE_GENERIC_16_LSB: {

-					destData[dp] = (byte) (data & 0xff);

-					destData[dp + 1] = (byte) (data >>> 8);

-				} break;

-				case TYPE_GENERIC_24: {

-					destData[dp] = (byte) (data >>> 16);

-					destData[dp + 1] = (byte) (data >>> 8);

-					destData[dp + 2] = (byte) (data & 0xff);

-				} break;

-				case TYPE_GENERIC_32_MSB: {

-					destData[dp] = (byte) (data >>> 24);

-					destData[dp + 1] = (byte) (data >>> 16);

-					destData[dp + 2] = (byte) (data >>> 8);

-					destData[dp + 3] = (byte) (data & 0xff);

-				} break;

-				case TYPE_GENERIC_32_LSB: {

-					destData[dp] = (byte) (data & 0xff);

-					destData[dp + 1] = (byte) (data >>> 8);

-					destData[dp + 2] = (byte) (data >>> 16);

-					destData[dp + 3] = (byte) (data >>> 24);

-				} break;

-			}

+	if (destOrder == LSB_FIRST) {

+		switch (destDepth) {

+			case 16: do0 = 1; do1 = 0; break;

+			case 24: do0 = 2; do1 = 1; do2 = 0; break;

+			case 32: do0 = 3; do1 = 2; do2 = 1; do3 = 0; break;

 		}

-	}			

-}

+	}

 

-/**

- * Blits an index palette image into an index palette image.

- * <p>

- * Note: The source and destination red, green, and blue

- * arrays may be null if no alpha blending or dither is to be

- * performed.

- * </p>

- * 

- * @param op the blitter operation: a combination of BLIT_xxx flags

- *        (see BLIT_xxx constants)

- * @param srcData the source byte array containing image data

- * @param srcDepth the source depth: one of 1, 2, 4, 8

- * @param srcStride the source number of bytes per line

- * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;

- *        ignored if srcDepth is not 1

- * @param srcX the top-left x-coord of the source blit region

- * @param srcY the top-left y-coord of the source blit region

- * @param srcWidth the width of the source blit region

- * @param srcHeight the height of the source blit region

- * @param srcReds the source palette red component intensities

- * @param srcGreens the source palette green component intensities

- * @param srcBlues the source palette blue component intensities

- * @param alphaMode the alpha blending or mask mode, may be

- *        an integer 0-255 for global alpha; ignored if BLIT_ALPHA

- *        not specified in the blitter operations

- *        (see ALPHA_MODE_xxx constants)

- * @param alphaData the alpha blending or mask data, varies depending

- *        on the value of alphaMode and sometimes ignored

- * @param destData the destination byte array containing image data

- * @param destDepth the destination depth: one of 1, 2, 4, 8

- * @param destStride the destination number of bytes per line

- * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;

- *        ignored if destDepth is not 1

- * @param destX the top-left x-coord of the destination blit region

- * @param destY the top-left y-coord of the destination blit region

- * @param destWidth the width of the destination blit region

- * @param destHeight the height of the destination blit region

- * @param destReds the destination palette red component intensities

- * @param destGreens the destination palette green component intensities

- * @param destBlues the destination palette blue component intensities

- * @param flipX if true the resulting image is flipped along the vertical axis

- * @param flipY if true the resulting image is flipped along the horizontal axis

- */

-static void blit(int op,

-	byte[] srcData, int srcDepth, int srcStride, int srcOrder,

-	int srcX, int srcY, int srcWidth, int srcHeight,

-	byte[] srcReds, byte[] srcGreens, byte[] srcBlues,

-	int alphaMode, byte[] alphaData, int alphaStride,

-	byte[] destData, int destDepth, int destStride, int destOrder,

-	int destX, int destY, int destWidth, int destHeight,

-	byte[] destReds, byte[] destGreens, byte[] destBlues,

-	boolean flipX, boolean flipY) {

-	if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;

-

-	/*** Prepare scaling data ***/

-	final int dwm1 = destWidth - 1;

-	final int sfxi = (dwm1 != 0) ? ((srcWidth << 16) - 1) / dwm1 : 0;

-	final int dhm1 = destHeight - 1;

-	final int sfyi = (dhm1 != 0) ? ((srcHeight << 16) - 1) / dhm1 : 0;

-

-	/*** Prepare source-related data ***/

-	final int stype;

-	switch (srcDepth) {

-		case 8:

-			stype = TYPE_INDEX_8;

-			break;

-		case 4:

-			srcStride <<= 1;

-			stype = TYPE_INDEX_4;

-			break;

-		case 2:

-			srcStride <<= 2;

-			stype = TYPE_INDEX_2;

-			break;

-		case 1:

-			srcStride <<= 3;

-			stype = (srcOrder == MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;

-			break;

-		default:

-			//throw new IllegalArgumentException("Invalid source type");

-			return;		

-	}			

-	int spr = srcY * srcStride + srcX;

-

-	/*** Prepare destination-related data ***/

-	final int dtype;

-	switch (destDepth) {

-		case 8:

-			dtype = TYPE_INDEX_8;

-			break;

-		case 4:

-			destStride <<= 1;

-			dtype = TYPE_INDEX_4;

-			break;

-		case 2:

-			destStride <<= 2;

-			dtype = TYPE_INDEX_2;

-			break;

-		case 1:

-			destStride <<= 3;

-			dtype = (destOrder == MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;

-			break;

-		default:

-			//throw new IllegalArgumentException("Invalid source type");

-			return;

-	}			

-	int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX);

-	final int dprxi = (flipX) ? -1 : 1;

-	final int dpryi = (flipY) ? -destStride : destStride;

-

-	/*** Prepare special processing data ***/

-	int apr;

-	if ((op & BLIT_ALPHA) != 0) {

-		switch (alphaMode) {

-			case ALPHA_MASK_UNPACKED:

-			case ALPHA_CHANNEL_SEPARATE:

-				if (alphaData == null) alphaMode = 0x10000;

-				apr = srcY * alphaStride + srcX;

-				break;

-			case ALPHA_MASK_PACKED:

-				if (alphaData == null) alphaMode = 0x10000;

-				alphaStride <<= 3;

-				apr = srcY * alphaStride + srcX;

-				break;

-			case ALPHA_MASK_INDEX:

-			case ALPHA_MASK_RGB:

-				if (alphaData == null) alphaMode = 0x10000;

-				apr = 0;

-				break;

-			default:

-				alphaMode = (alphaMode << 16) / 255; // prescale

-			case ALPHA_CHANNEL_SOURCE:

-				apr = 0;

-				break;

-		}

+	xs1 = srcX; xs2 = srcX + srcWidth - 1;

+	ys1 = srcY; ys2 = srcY + srcHeight - 1;

+	if (flipX) {

+		xd1 = destX + destWidth - 1;

+		xd2 = destX;

 	} else {

-		alphaMode = 0x10000;

-		apr = 0;

+		xd1 = destX;

+		xd2 = destX + destWidth - 1;

 	}

-	final boolean ditherEnabled = (op & BLIT_DITHER) != 0;

+	if (flipY) {

+		yd1 = destY + destHeight - 1;

+		yd2 = destY;

+	} else {

+		yd1 = destY;

+		yd2 = destY + destHeight - 1;

+	}

 

-	/*** Blit ***/

-	int dp = dpr;

-	int sp = spr;

-	int ap = apr;

-	int destPaletteSize = 1 << destDepth;

-	if ((destReds != null) && (destReds.length < destPaletteSize)) destPaletteSize = destReds.length;

-	byte[] paletteMapping = null;

-	boolean isExactPaletteMapping = true;

-	switch (alphaMode) {

-		case 0x10000:

-			/*** If the palettes and formats are equivalent use a one-to-one mapping ***/

-			if ((stype == dtype) &&

-				(srcReds == destReds) && (srcGreens == destGreens) && (srcBlues == destBlues)) {

-				paletteMapping = ONE_TO_ONE_MAPPING;

-				break;

-			/*** If palettes have not been supplied, supply a suitable mapping ***/

-			} else if ((srcReds == null) || (destReds == null)) {

-				if (srcDepth <= destDepth) {

-					paletteMapping = ONE_TO_ONE_MAPPING;

-				} else {

-					paletteMapping = new byte[1 << srcDepth];

-					int mask = (0xff << destDepth) >>> 8;

-					for (int i = 0; i < paletteMapping.length; ++i) paletteMapping[i] = (byte)(i & mask);

-				}

-				break;

-			}

-		case ALPHA_MASK_UNPACKED:

-		case ALPHA_MASK_PACKED:

-		case ALPHA_MASK_INDEX:

-		case ALPHA_MASK_RGB:

-			/*** Generate a palette mapping ***/

-			int srcPaletteSize = 1 << srcDepth;

-			paletteMapping = new byte[srcPaletteSize];

-			if ((srcReds != null) && (srcReds.length < srcPaletteSize)) srcPaletteSize = srcReds.length;

-			for (int i = 0, r, g, b, index; i < srcPaletteSize; ++i) {

-				r = srcReds[i] & 0xff;

-				g = srcGreens[i] & 0xff;

-				b = srcBlues[i] & 0xff;

-				index = 0;

-				int minDistance = 0x7fffffff;

-				for (int j = 0, dr, dg, db, distance; j < destPaletteSize; ++j) {

-					dr = (destReds[j] & 0xff) - r;

-					dg = (destGreens[j] & 0xff) - g;

-					db = (destBlues[j] & 0xff) - b;

-					distance = dr * dr + dg * dg + db * db;

-					if (distance < minDistance) {

-						index = j;

-						if (distance == 0) break;

-						minDistance = distance;

-					}

-				}

-				paletteMapping[i] = (byte)index;

-				if (minDistance != 0) isExactPaletteMapping = false;

-			}

-			break;

-	}

-	if ((paletteMapping != null) && (isExactPaletteMapping || ! ditherEnabled)) {

-		if ((stype == dtype) && (alphaMode == 0x10000)) {

-			/*** Fast blit (copy w/ mapping) ***/

-			switch (stype) {

-				case TYPE_INDEX_8:

-					for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {

-						for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {

-							destData[dp] = paletteMapping[srcData[sp] & 0xff];

-							sp += (sfx >>> 16);

-						}

-					}

-					break;					

-				case TYPE_INDEX_4:

-					for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {

-						for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {

-							final int v;

-							if ((sp & 1) != 0) v = paletteMapping[srcData[sp >> 1] & 0x0f];

-							else v = (srcData[sp >> 1] >>> 4) & 0x0f;

-							sp += (sfx >>> 16);

-							if ((dp & 1) != 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | v);

-							else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (v << 4));

-						}

-					}

+	/* Y preliminary calculations */

+	dyd = yd2 - yd1;

+	if (dyd < 0) dyd = -dyd;

+	dys = ys2 - ys1;

+	if (dys < 0) dys = -dys;

+	dyd2 = dyd << 1;

+	dys2 = dys << 1;

+	syd = (short)((yd2 - yd1) > 0 ? 1 : -1);

+	sys = (short)((ys2 - ys1) > 0 ? 1 : -1);

+	ey = dys2 - dyd;

+	ys = ys1;

+	yd = yd1;

+	/* X preliminary calculations */

+	dxd = xd2 - xd1;

+	if (dxd < 0) dxd = -dxd;

+	dxs = xs2 - xs1;

+	if (dxs < 0) dxs = -dxs;

+	dxs2 = dxs << 1;

+	dxd2 = dxd << 1;

+	sxs = sas = (short)((xs2 - xs1) > 0 ? 1 : -1);

+	sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);

+

+	sxs *= srcDepth / 8;

+	xs1 *= srcDepth / 8;

+	sxd *= destDepth / 8;

+	xd1 *= destDepth / 8;

+	

+	if (srcGlobalAlpha != -1) srcAlphaData = null;

+	sa = srcGlobalAlpha;

+	for (dy = 0; dy <= dyd; dy++) {

+		/* X stretch starts here */

+		ex = dxs2 - dxd;

+		sp = ys * srcStride + xs1;

+		dp = yd * destStride + xd1;

+		if (srcAlphaData != null) sap = ys * srcAlphaStride + xs1;

+		for (dx = 0; dx < dxd; dx++) {

+			if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;

+			switch (srcDepth) {

+				case 16:

+					srcPixel = ((srcData[sp+so0] & 0xFF) << 8) | (srcData[sp+so1] & 0xFF);

 					break;

-				case TYPE_INDEX_2:

-					for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {

-						for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {

-							final int index = paletteMapping[(srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03];

-							sp += (sfx >>> 16);

-							final int shift = 6 - (dp & 3) * 2;

-							destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (index << shift));

-						}

-					}

-					break;					

-				case TYPE_INDEX_1_MSB:

-					for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {

-						for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {

-							final int index = paletteMapping[(srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01];

-							sp += (sfx >>> 16);

-							final int shift = 7 - (dp & 7);

-							destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));

-						}

-					}

-					break;					

-				case TYPE_INDEX_1_LSB:

-					for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {

-						for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {

-							final int index = paletteMapping[(srcData[sp >> 3] >>> (sp & 7)) & 0x01];

-							sp += (sfx >>> 16);

-							final int shift = dp & 7;

-							destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));

-						}

-					}

+				case 24:

+					srcPixel = ((srcData[sp+so0] & 0xFF) << 16) | ((srcData[sp+so1] & 0xFF) << 8) | 

+						(srcData[sp+so2] & 0xFF);

+					break;

+				case 32:

+					srcPixel = ((srcData[sp+so0] & 0xFF) << 24) | ((srcData[sp+so1] & 0xFF) << 16) |

+						((srcData[sp+so2] & 0xFF) << 8) | (srcData[sp+so3] & 0xFF);

 					break;

 			}

-		} else {

-			/*** Convert between indexed modes using mapping and mask ***/

-			for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,

-					sp = spr += (sfy >>> 16) * srcStride,

-					sfy = (sfy & 0xffff) + sfyi,

-					dp = dpr += dpryi) {

-				for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,

-						dp += dprxi,

-						sfx = (sfx & 0xffff) + sfxi) {

-					int index;

-					/*** READ NEXT PIXEL ***/

-					switch (stype) {

-						case TYPE_INDEX_8:

-							index = srcData[sp] & 0xff;

-							sp += (sfx >>> 16);

-							break;					

-						case TYPE_INDEX_4:

-							if ((sp & 1) != 0) index = srcData[sp >> 1] & 0x0f;

-							else index = (srcData[sp >> 1] >>> 4) & 0x0f;

-							sp += (sfx >>> 16);

-							break;					

-						case TYPE_INDEX_2:

-							index = (srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03;

-							sp += (sfx >>> 16);

-							break;					

-						case TYPE_INDEX_1_MSB:

-							index = (srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01;

-							sp += (sfx >>> 16);

-							break;					

-						case TYPE_INDEX_1_LSB:

-							index = (srcData[sp >> 3] >>> (sp & 7)) & 0x01;

-							sp += (sfx >>> 16);

-							break;

-						default:

-							return;

-					}

-					/*** APPLY MASK ***/

-					switch (alphaMode) {

-						case ALPHA_MASK_UNPACKED: {

-							final byte mask = alphaData[ap];

-							ap += (sfx >> 16);

-							if (mask == 0) continue;

-						} break;

-						case ALPHA_MASK_PACKED: {

-							final int mask = alphaData[ap >> 3] & (1 << (ap & 7));

-							ap += (sfx >> 16);

-							if (mask == 0) continue;

-						} break;

-						case ALPHA_MASK_INDEX: {

-							int i = 0;

-							while (i < alphaData.length) {

-								if (index == (alphaData[i] & 0xff)) break;

-							}

-							if (i < alphaData.length) continue;

-						} break;

-						case ALPHA_MASK_RGB: {

-							final byte r = srcReds[index], g = srcGreens[index], b = srcBlues[index];

-							int i = 0;

-							while (i < alphaData.length) {

-								if ((r == alphaData[i]) && (g == alphaData[i + 1]) && (b == alphaData[i + 2])) break;

-								i += 3;

-							}

-							if (i < alphaData.length) continue;

-						} break;

-					}

-					index = paletteMapping[index] & 0xff;

-			

-					/*** WRITE NEXT PIXEL ***/

-					switch (dtype) {

-						case TYPE_INDEX_8:

-							destData[dp] = (byte) index;

-							break;

-						case TYPE_INDEX_4:

-							if ((dp & 1) != 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | index);

-							else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (index << 4));

-							break;					

-						case TYPE_INDEX_2: {

-							final int shift = 6 - (dp & 3) * 2;

-							destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (index << shift));

-						} break;					

-						case TYPE_INDEX_1_MSB: {

-							final int shift = 7 - (dp & 7);

-							destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));

-						} break;

-						case TYPE_INDEX_1_LSB: {

-							final int shift = dp & 7;

-							destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));

-						} break;					

-					}

+			dr = sr = ((srcPixel & srcRedMask) << srcRedShift) >>> 24;

+			dg = sg = ((srcPixel & srcGreenMask) << srcGreenShift) >>> 24;

+			db = sb = ((srcPixel & srcBlueMask) << srcBlueShift) >>> 24;

+			if (op != BLIT_SRC) {

+				switch (destDepth) {

+					case 16:

+						destPixel = ((destData[dp+do0] & 0xFF) << 8) | (destData[dp+do1] & 0xFF);

+						break;

+					case 24:

+						destPixel = ((destData[dp+do0] & 0xFF) << 16) | ((destData[dp+do1] & 0xFF) << 8) | 

+							(destData[dp+do2] & 0xFF);

+						break;

+					case 32:

+						destPixel = ((destData[dp+do0] & 0xFF) << 24) | ((destData[dp+do1] & 0xFF) << 16) |

+							((destData[dp+do2] & 0xFF) << 8) | (destData[dp+do3] & 0xFF);

+						break;

+				}

+				dr = ((destPixel & destRedMask) << destRedShift) >>> 24;

+				dg = ((destPixel & destGreenMask) << destGreenShift) >>> 24;

+				db = ((destPixel & destBlueMask) << destBlueShift) >>> 24;

+				switch (op) {

+					case BLIT_ALPHA:

+						dr += (sr - dr) * sa / 255;

+						dg += (sg - dg) * sa / 255;

+						db += (sb - db) * sa / 255;

+					break;

 				}

 			}

+			destPixel =

+				(((dr << 24) >> destRedShift) & destRedMask) |

+				(((dg << 24) >> destGreenShift) & destGreenMask) |

+				(((db << 24) >> destBlueShift) & destBlueMask);

+			switch (destDepth) {

+				case 16:

+					destData[dp + do0] = (byte)((destPixel >> 8) & 0xFF);

+					destData[dp + do1] = (byte)(destPixel & 0xFF);

+					break;

+				case 24:

+					destData[dp + do0] = (byte)((destPixel >> 16) & 0xFF);

+					destData[dp + do1] = (byte)((destPixel >> 8) & 0xFF);

+					destData[dp + do2] = (byte)(destPixel & 0xFF);

+					break;

+				case 32:

+					destData[dp + do0]  = (byte)((destPixel >> 24) & 0xFF);

+					destData[dp + do1] = (byte)((destPixel >> 16) & 0xFF);

+					destData[dp + do2] = (byte)((destPixel >> 8) & 0xFF);

+					destData[dp + do3] = (byte)(destPixel & 0xFF);

+					break;

+			}

+			while (ex >= 0) {

+				sp += sxs;

+				ex -= dxd2;

+				if (srcAlphaData != null) sap += sas;

+			}

+			dp += sxd;

+			ex += dxs2;

 		}

-		return;

-	}

 		

-	/*** Comprehensive blit (apply transformations) ***/

-	int alpha = alphaMode;

-	int index = 0;

-	int indexq = 0;

-	int lastindex = 0, lastr = -1, lastg = -1, lastb = -1;

-	final int[] rerr, gerr, berr;

-	if (ditherEnabled) {

-		rerr = new int[destWidth + 2];

-		gerr = new int[destWidth + 2];

-		berr = new int[destWidth + 2];

-	} else {

-		rerr = null; gerr = null; berr = null;

-	}

-	for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,

-			sp = spr += (sfy >>> 16) * srcStride,

-			ap = apr += (sfy >>> 16) * alphaStride,

-			sfy = (sfy & 0xffff) + sfyi,

-			dp = dpr += dpryi) {

-		int lrerr = 0, lgerr = 0, lberr = 0;

-		for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,

-				dp += dprxi,

-				sfx = (sfx & 0xffff) + sfxi) {

-			/*** READ NEXT PIXEL ***/

-			switch (stype) {

-				case TYPE_INDEX_8:

-					index = srcData[sp] & 0xff;

-					sp += (sfx >>> 16);

+		if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;

+		switch (srcDepth) {

+			case 16:

+				srcPixel = ((srcData[sp+so0] & 0xFF) << 8) | (srcData[sp+so1] & 0xFF);

+				break;

+			case 24:

+				srcPixel = ((srcData[sp+so0] & 0xFF) << 16) | ((srcData[sp+so1] & 0xFF) << 8) | 

+					(srcData[sp+so2] & 0xFF);

+				break;

+			case 32:

+				srcPixel = ((srcData[sp+so0] & 0xFF) << 24) | ((srcData[sp+so1] & 0xFF) << 16) |

+					((srcData[sp+so2] & 0xFF) << 8) | (srcData[sp+so3] & 0xFF);

+				break;

+		}

+		dr = sr = ((srcPixel & srcRedMask) << srcRedShift) >>> 24;

+		dg = sg = ((srcPixel & srcGreenMask) << srcGreenShift) >>> 24;

+		db = sb = ((srcPixel & srcBlueMask) << srcBlueShift) >>> 24;

+		if (op != BLIT_SRC) {

+			switch (destDepth) {

+				case 16:

+					destPixel = ((destData[dp+do0] & 0xFF) << 8) | (destData[dp+do1] & 0xFF);

 					break;

-				case TYPE_INDEX_4:

-					if ((sp & 1) != 0) index = srcData[sp >> 1] & 0x0f;

-					else index = (srcData[sp >> 1] >>> 4) & 0x0f;

-					sp += (sfx >>> 16);

+				case 24:

+					destPixel = ((destData[dp+do0] & 0xFF) << 16) | ((destData[dp+do1] & 0xFF) << 8) | 

+						(destData[dp+do2] & 0xFF);

 					break;

-				case TYPE_INDEX_2:

-					index = (srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03;

-					sp += (sfx >>> 16);

-					break;

-				case TYPE_INDEX_1_MSB:

-					index = (srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01;

-					sp += (sfx >>> 16);

-					break;

-				case TYPE_INDEX_1_LSB:

-					index = (srcData[sp >> 3] >>> (sp & 7)) & 0x01;

-					sp += (sfx >>> 16);

+				case 32:

+					destPixel = ((destData[dp+do0] & 0xFF) << 24) | ((destData[dp+do1] & 0xFF) << 16) |

+						((destData[dp+do2] & 0xFF) << 8) | (destData[dp+do3] & 0xFF);

 					break;

 			}

-

-			/*** DO SPECIAL PROCESSING IF REQUIRED ***/

-			int r = srcReds[index] & 0xff, g = srcGreens[index] & 0xff, b = srcBlues[index] & 0xff;

-			switch (alphaMode) {

-				case ALPHA_CHANNEL_SEPARATE:

-					alpha = ((alphaData[ap] & 0xff) << 16) / 255;

-					ap += (sfx >> 16);

-					break;

-				case ALPHA_MASK_UNPACKED:

-					alpha = (alphaData[ap] != 0) ? 0x10000 : 0;

-					ap += (sfx >> 16);

-					break;						

-				case ALPHA_MASK_PACKED:

-					alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;

-					ap += (sfx >> 16);

-					break;

-				case ALPHA_MASK_INDEX: { // could speed up using binary search if we sorted the indices

-					int i = 0;

-					while (i < alphaData.length) {

-						if (index == (alphaData[i] & 0xff)) break;

-					}

-					if (i < alphaData.length) continue;

-				} break;

-				case ALPHA_MASK_RGB: {

-					int i = 0;

-					while (i < alphaData.length) {

-						if ((r == (alphaData[i] & 0xff)) &&

-							(g == (alphaData[i + 1] & 0xff)) &&

-							(b == (alphaData[i + 2] & 0xff))) break;

-						i += 3;

-					}

-					if (i < alphaData.length) continue;

-				} break;

-			}

-			if (alpha != 0x10000) {

-				if (alpha == 0x0000) continue;

-				switch (dtype) {

-					case TYPE_INDEX_8:

-						indexq = destData[dp] & 0xff;

-						break;

-					case TYPE_INDEX_4:

-						if ((dp & 1) != 0) indexq = destData[dp >> 1] & 0x0f;

-						else indexq = (destData[dp >> 1] >>> 4) & 0x0f;

-						break;

-					case TYPE_INDEX_2:

-						indexq = (destData[dp >> 2] >>> (6 - (dp & 3) * 2)) & 0x03;

-						break;

-					case TYPE_INDEX_1_MSB:

-						indexq = (destData[dp >> 3] >>> (7 - (dp & 7))) & 0x01;

-						break;

-					case TYPE_INDEX_1_LSB:

-						indexq = (destData[dp >> 3] >>> (dp & 7)) & 0x01;

-						break;

-				}

-				// Perform alpha blending

-				final int rq = destReds[indexq] & 0xff;

-				final int gq = destGreens[indexq] & 0xff;

-				final int bq = destBlues[indexq] & 0xff;

-				r = rq + ((r - rq) * alpha >> 16);

-				g = gq + ((g - gq) * alpha >> 16);

-				b = bq + ((b - bq) * alpha >> 16);

-			}

-

-			/*** MAP COLOR TO THE PALETTE ***/

-			if (ditherEnabled) {

-				// Floyd-Steinberg error diffusion

-				r += rerr[dx] >> 4;

-				if (r < 0) r = 0; else if (r > 255) r = 255;

-				g += gerr[dx] >> 4;

-				if (g < 0) g = 0; else if (g > 255) g = 255;

-				b += berr[dx] >> 4;

-				if (b < 0) b = 0; else if (b > 255) b = 255;

-				rerr[dx] = lrerr;

-				gerr[dx] = lgerr;

-				berr[dx] = lberr;

-			}

-			if (r != lastr || g != lastg || b != lastb) {

-				// moving the variable declarations out seems to make the JDK JIT happier...

-				for (int j = 0, dr, dg, db, distance, minDistance = 0x7fffffff; j < destPaletteSize; ++j) {

-					dr = (destReds[j] & 0xff) - r;

-					dg = (destGreens[j] & 0xff) - g;

-					db = (destBlues[j] & 0xff) - b;

-					distance = dr * dr + dg * dg + db * db;

-					if (distance < minDistance) {

-						lastindex = j;

-						if (distance == 0) break;

-						minDistance = distance;

-					}

-				}

-				lastr = r; lastg = g; lastb = b;

-			}

-			if (ditherEnabled) {

-				// Floyd-Steinberg error diffusion, cont'd...

-				final int dxm1 = dx - 1, dxp1 = dx + 1;

-				int acc;

-				rerr[dxp1] += acc = (lrerr = r - (destReds[lastindex] & 0xff)) + lrerr + lrerr;

-				rerr[dx] += acc += lrerr + lrerr;

-				rerr[dxm1] += acc + lrerr + lrerr;

-				gerr[dxp1] += acc = (lgerr = g - (destGreens[lastindex] & 0xff)) + lgerr + lgerr;

-				gerr[dx] += acc += lgerr + lgerr;

-				gerr[dxm1] += acc + lgerr + lgerr;

-				berr[dxp1] += acc = (lberr = b - (destBlues[lastindex] & 0xff)) + lberr + lberr;

-				berr[dx] += acc += lberr + lberr;

-				berr[dxm1] += acc + lberr + lberr;

-			}

-

-			/*** WRITE NEXT PIXEL ***/

-			switch (dtype) {

-				case TYPE_INDEX_8:

-					destData[dp] = (byte) lastindex;

-					break;

-				case TYPE_INDEX_4:

-					if ((dp & 1) != 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | lastindex);

-					else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (lastindex << 4));

-					break;

-				case TYPE_INDEX_2: {

-					final int shift = 6 - (dp & 3) * 2;

-					destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (lastindex << shift));

-				} break;					

-				case TYPE_INDEX_1_MSB: {

-					final int shift = 7 - (dp & 7);

-					destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));

-				} break;

-				case TYPE_INDEX_1_LSB: {

-					final int shift = dp & 7;

-					destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));

-				} break;					

+			dr = ((destPixel & destRedMask) << destRedShift) >>> 24;

+			dg = ((destPixel & destGreenMask) << destGreenShift) >>> 24;

+			db = ((destPixel & destBlueMask) << destBlueShift) >>> 24;

+			switch (op) {

+				case BLIT_ALPHA:

+					dr += (sr - dr) * sa / 255;

+					dg += (sg - dg) * sa / 255;

+					db += (sb - db) * sa / 255;

+				break;

 			}

 		}

+		destPixel =

+			(((dr << 24) >> destRedShift) & destRedMask) |

+			(((dg << 24) >> destGreenShift) & destGreenMask) |

+			(((db << 24) >> destBlueShift) & destBlueMask);

+		switch (destDepth) {

+			case 16:

+				destData[dp + do0] = (byte)((destPixel >> 8) & 0xFF);

+				destData[dp + do1] = (byte)(destPixel & 0xFF);

+				break;

+			case 24:

+				destData[dp + do0] = (byte)((destPixel >> 16) & 0xFF);

+				destData[dp + do1] = (byte)((destPixel >> 8) & 0xFF);

+				destData[dp + do2] = (byte)(destPixel & 0xFF);

+				break;

+			case 32:

+				destData[dp + do0]  = (byte)((destPixel >> 24) & 0xFF);

+				destData[dp + do1] = (byte)((destPixel >> 16) & 0xFF);

+				destData[dp + do2] = (byte)((destPixel >> 8) & 0xFF);

+				destData[dp + do3] = (byte)(destPixel & 0xFF);

+				break;

+		}

+		/* X stretch ends here */

+		if (dy == dyd)

+			break;

+		while (ey >= 0) {

+			ys += sys;

+			ey -= dyd2;

+		}

+		yd += syd;

+		ey += dys2;

 	}

 }

 

 /**

  * Blits an index palette image into a direct palette image.

- * <p>

- * Note: The source and destination masks and palettes must

- * always be fully specified.

- * </p>

- * 

- * @param op the blitter operation: a combination of BLIT_xxx flags

- *        (see BLIT_xxx constants)

- * @param srcData the source byte array containing image data

- * @param srcDepth the source depth: one of 1, 2, 4, 8

- * @param srcStride the source number of bytes per line

- * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;

- *        ignored if srcDepth is not 1

- * @param srcX the top-left x-coord of the source blit region

- * @param srcY the top-left y-coord of the source blit region

- * @param srcWidth the width of the source blit region

- * @param srcHeight the height of the source blit region

- * @param srcReds the source palette red component intensities

- * @param srcGreens the source palette green component intensities

- * @param srcBlues the source palette blue component intensities

- * @param alphaMode the alpha blending or mask mode, may be

- *        an integer 0-255 for global alpha; ignored if BLIT_ALPHA

- *        not specified in the blitter operations

- *        (see ALPHA_MODE_xxx constants)

- * @param alphaData the alpha blending or mask data, varies depending

- *        on the value of alphaMode and sometimes ignored

- * @param destData the destination byte array containing image data

- * @param destDepth the destination depth: one of 8, 16, 24, 32

- * @param destStride the destination number of bytes per line

- * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;

- *        ignored if destDepth is not 16 or 32

- * @param destX the top-left x-coord of the destination blit region

- * @param destY the top-left y-coord of the destination blit region

- * @param destWidth the width of the destination blit region

- * @param destHeight the height of the destination blit region

- * @param destRedMask the destination red channel mask

- * @param destGreenMask the destination green channel mask

- * @param destBlueMask the destination blue channel mask

- * @param flipX if true the resulting image is flipped along the vertical axis

- * @param flipY if true the resulting image is flipped along the horizontal axis

  */

-static void blit(int op,

-	byte[] srcData, int srcDepth, int srcStride, int srcOrder,

-	int srcX, int srcY, int srcWidth, int srcHeight,

-	byte[] srcReds, byte[] srcGreens, byte[] srcBlues,

-	int alphaMode, byte[] alphaData, int alphaStride,

-	byte[] destData, int destDepth, int destStride, int destOrder,

-	int destX, int destY, int destWidth, int destHeight,

-	int destRedMask, int destGreenMask, int destBlueMask,

-	boolean flipX, boolean flipY) {

-	if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;

-

-	// these should be supplied as params later

-	final int destAlphaMask = 0;

-

-	/*** Prepare scaling data ***/

-	final int dwm1 = destWidth - 1;

-	final int sfxi = (dwm1 != 0) ? ((srcWidth << 16) - 1) / dwm1 : 0;

-	final int dhm1 = destHeight - 1;

-	final int sfyi = (dhm1 != 0) ? ((srcHeight << 16) - 1) / dhm1 : 0;

-

-	/*** Prepare source-related data ***/

-	final int stype;

-	switch (srcDepth) {

-		case 8:

-			stype = TYPE_INDEX_8;

-			break;

-		case 4:

-			srcStride <<= 1;

-			stype = TYPE_INDEX_4;

-			break;

-		case 2:

-			srcStride <<= 2;

-			stype = TYPE_INDEX_2;

-			break;

-		case 1:

-			srcStride <<= 3;

-			stype = (srcOrder == MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;

-			break;

-		default:

-			//throw new IllegalArgumentException("Invalid source type");

-			return;

-	}			

-	int spr = srcY * srcStride + srcX;

-

-	/*** Prepare destination-related data ***/

-	final int dbpp, dtype;

-	switch (destDepth) {

-		case 8:

-			dbpp = 1;

-			dtype = TYPE_GENERIC_8;

-			break;

-		case 16:

-			dbpp = 2;

-			dtype = (destOrder == MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;

-			break;

-		case 24:

-			dbpp = 3;

-			dtype = TYPE_GENERIC_24;

-			break;

-		case 32:

-			dbpp = 4;

-			dtype = (destOrder == MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;

-			break;

-		default:

-			//throw new IllegalArgumentException("Invalid destination type");

-			return;

-	}			

-	int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX) * dbpp;

-	final int dprxi = (flipX) ? -dbpp : dbpp;

-	final int dpryi = (flipY) ? -destStride : destStride;

-

-	/*** Prepare special processing data ***/

-	int apr;

-	if ((op & BLIT_ALPHA) != 0) {

-		switch (alphaMode) {

-			case ALPHA_MASK_UNPACKED:

-			case ALPHA_CHANNEL_SEPARATE:

-				if (alphaData == null) alphaMode = 0x10000;

-				apr = srcY * alphaStride + srcX;

-				break;

-			case ALPHA_MASK_PACKED:

-				if (alphaData == null) alphaMode = 0x10000;

-				alphaStride <<= 3;

-				apr = srcY * alphaStride + srcX;

-				break;

-			case ALPHA_MASK_INDEX:

-			case ALPHA_MASK_RGB:

-				if (alphaData == null) alphaMode = 0x10000;

-				apr = 0;

-				break;

-			default:

-				alphaMode = (alphaMode << 16) / 255; // prescale

-			case ALPHA_CHANNEL_SOURCE:

-				apr = 0;

-				break;

+static void blit(int op, byte[] srcData, int srcDepth, int srcStride, int srcOrder, int srcX, int srcY, int srcWidth, int srcHeight, byte[] srcReds, byte[] srcGreens, byte[] srcBlues, int srcGlobalAlpha, byte[] srcAlphaData, int srcAlphaStride, byte[] destData, int destDepth, int destStride, int destOrder, int destX, int destY, int destWidth, int destHeight, int destRedMask, int destGreenMask, int destBlueMask, boolean flipX, boolean flipY) {

+	int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;

+	int dyd, dys, ey, dy, dyd2, dys2, ys, yd;

+	short syd, sys;

+	int dxd, dxs, ex, dx, dxd2, dxs2, xs;

+	short sxd, sxs, sas;

+	int sp, dp, sap = 0;

+	int sr = 0, sg = 0, sb = 0, sa = 0, dr = 0, dg = 0, db = 0, da = 0;

+	int srcPixel = 0, destPixel = 0;

+	short do0 = 0, do1 = 1, do2 = 2, do3 = 3;

+	int destRedShift, destGreenShift, destBlueShift;

+	int i, offset = 0;

+	byte[] srcMasks = null;

+	int srcN = 1 << srcDepth;

+	int[] mapping = null;

+	

+	destRedShift = 32 - getMSBOffset(destRedMask);

+	destGreenShift = 32 - getMSBOffset(destGreenMask);

+	destBlueShift = 32 - getMSBOffset(destBlueMask);

+	if (srcReds != null && srcN > srcReds.length) srcN = srcReds.length;

+	if (op == BLIT_SRC) {

+		mapping = new int[srcN];		

+		for (i = 0; i < srcN; i++) {

+			dr = srcReds[i] & 0xFF;

+			dg = srcGreens[i] & 0xFF;

+			db = srcBlues[i] & 0xFF;

+			mapping[i] = 

+				(((dr << 24) >>> destRedShift) & destRedMask) | 

+				(((dg << 24) >>> destGreenShift) & destGreenMask) |

+				(((db << 24) >>> destBlueShift) & destBlueMask);

 		}

-	} else {

-		alphaMode = 0x10000;

-		apr = 0;

+	}

+	switch (srcDepth) {

+		case 1: srcMasks = msbMasks1; break;

+		case 2: srcMasks = masks2; break;

+	}

+	if (srcOrder == LSB_FIRST) {

+		switch (srcDepth) {

+			case 1: srcMasks = lsbMasks1; break;

+		}

+	}

+	if (destOrder == LSB_FIRST) {

+		switch (destDepth) {

+			case 16: do0 = 1; do1 = 0; break;

+			case 24: do0 = 2; do1 = 1; do2 = 0; break;

+			case 32: do0 = 3; do1 = 2; do2 = 1; do3 = 0; break;

+		}

 	}

 

-	/*** Comprehensive blit (apply transformations) ***/

-	final int destRedShift = getChannelShift(destRedMask);

-	final int destRedWidth = getChannelWidth(destRedMask, destRedShift);

-	final byte[] destReds = ANY_TO_EIGHT[destRedWidth];

-	final int destRedPreShift = 8 - destRedWidth;

-	final int destGreenShift = getChannelShift(destGreenMask);

-	final int destGreenWidth = getChannelWidth(destGreenMask, destGreenShift);

-	final byte[] destGreens = ANY_TO_EIGHT[destGreenWidth];

-	final int destGreenPreShift = 8 - destGreenWidth;

-	final int destBlueShift = getChannelShift(destBlueMask);

-	final int destBlueWidth = getChannelWidth(destBlueMask, destBlueShift);

-	final byte[] destBlues = ANY_TO_EIGHT[destBlueWidth];

-	final int destBluePreShift = 8 - destBlueWidth;

-	final int destAlphaShift = getChannelShift(destAlphaMask);

-	final int destAlphaWidth = getChannelWidth(destAlphaMask, destAlphaShift);

-	final byte[] destAlphas = ANY_TO_EIGHT[destAlphaWidth];

-	final int destAlphaPreShift = 8 - destAlphaWidth;

+	xs1 = srcX; xs2 = srcX + srcWidth - 1;

+	ys1 = srcY; ys2 = srcY + srcHeight - 1;

+	if (flipX) {

+		xd1 = destX + destWidth - 1;

+		xd2 = destX;

+	} else {

+		xd1 = destX;

+		xd2 = destX + destWidth - 1;

+	}

+	if (flipY) {

+		yd1 = destY + destHeight - 1;

+		yd2 = destY;

+	} else {

+		yd1 = destY;

+		yd2 = destY + destHeight - 1;

+	}

 

-	int dp = dpr;

-	int sp = spr;

-	int ap = apr, alpha = alphaMode;

-	int r = 0, g = 0, b = 0, a = 0, index = 0;

-	int rq = 0, gq = 0, bq = 0, aq = 0;

-	for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,

-			sp = spr += (sfy >>> 16) * srcStride,

-			ap = apr += (sfy >>> 16) * alphaStride,

-			sfy = (sfy & 0xffff) + sfyi,

-			dp = dpr += dpryi) {

-		int lrerr = 0, lgerr = 0, lberr = 0;

-		for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,

-				dp += dprxi,

-				sfx = (sfx & 0xffff) + sfxi) {

-			/*** READ NEXT PIXEL ***/

-			switch (stype) {

-				case TYPE_INDEX_8:

-					index = srcData[sp] & 0xff;

-					sp += (sfx >>> 16);

+	/* Y preliminary calculations */

+	dyd = yd2 - yd1;

+	if (dyd < 0) dyd = -dyd;

+	dys = ys2 - ys1;

+	if (dys < 0) dys = -dys;

+	dyd2 = dyd << 1;

+	dys2 = dys << 1;

+	syd = (short)((yd2 - yd1) > 0 ? 1 : -1);

+	sys = (short)((ys2 - ys1) > 0 ? 1 : -1);

+	ey = dys2 - dyd;

+	ys = ys1;

+	yd = yd1;

+	/* X preliminary calculations */

+	dxd = xd2 - xd1;

+	if (dxd < 0) dxd = -dxd;

+	dxs = xs2 - xs1;

+	if (dxs < 0) dxs = -dxs;

+	dxs2 = dxs << 1;

+	dxd2 = dxd << 1;

+	sxs = sas = (short)((xs2 - xs1) > 0 ? 1 : -1);

+	sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);

+

+	sxd *= destDepth / 8;

+	xd1 *= destDepth / 8;

+	

+	if (srcGlobalAlpha != -1) srcAlphaData = null;

+	sa = srcGlobalAlpha;

+	for (dy = 0; dy <= dyd; dy++) {

+		/* X stretch starts here */

+		offset = 3 - (srcX % 4);

+		ex = dxs2 - dxd;

+		xs = xs1;

+		sp = ys * srcStride;

+		dp = yd * destStride + xd1;

+		if (srcAlphaData != null) sap = ys * srcAlphaStride + xs1;

+		for (dx = 0; dx < dxd; dx++) {

+			if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;

+			switch (srcDepth) {

+				case  1:

+					srcPixel = (srcData[sp + (xs >> 3)] & srcMasks[xs & 7]) == 0 ? 0 : 1;

 					break;

-				case TYPE_INDEX_4:

-					if ((sp & 1) != 0) index = srcData[sp >> 1] & 0x0f;

-					else index = (srcData[sp >> 1] >>> 4) & 0x0f;

-					sp += (sfx >>> 16);

+				case  2:

+					srcPixel = ((srcData[sp + (xs >> 2)] & srcMasks[offset]) & 0xFF) >> (offset * 2);

 					break;

-				case TYPE_INDEX_2:

-					index = (srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03;

-					sp += (sfx >>> 16);

+				case  4:

+					srcPixel = srcData[sp + (xs >> 1)] & 0xFF;

+					if ((xs & 0x1) == 0) {

+						srcPixel = srcPixel >> 4;

+					} else {

+						srcPixel = srcPixel & 0x0F;

+					}

 					break;

-				case TYPE_INDEX_1_MSB:

-					index = (srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01;

-					sp += (sfx >>> 16);

-					break;

-				case TYPE_INDEX_1_LSB:

-					index = (srcData[sp >> 3] >>> (sp & 7)) & 0x01;

-					sp += (sfx >>> 16);

+				case  8:

+					srcPixel = srcData[sp + xs] & 0xFF;

 					break;

 			}

-

-			/*** DO SPECIAL PROCESSING IF REQUIRED ***/

-			r = srcReds[index] & 0xff;

-			g = srcGreens[index] & 0xff;

-			b = srcBlues[index] & 0xff;

-			switch (alphaMode) {

-				case ALPHA_CHANNEL_SEPARATE:

-					alpha = ((alphaData[ap] & 0xff) << 16) / 255;

-					ap += (sfx >> 16);

-					break;

-				case ALPHA_MASK_UNPACKED:

-					alpha = (alphaData[ap] != 0) ? 0x10000 : 0;

-					ap += (sfx >> 16);

-					break;						

-				case ALPHA_MASK_PACKED:

-					alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;

-					ap += (sfx >> 16);

-					break;

-				case ALPHA_MASK_INDEX: { // could speed up using binary search if we sorted the indices

-					int i = 0;

-					while (i < alphaData.length) {

-						if (index == (alphaData[i] & 0xff)) break;

+			if (mapping != null) {

+				destPixel = mapping[srcPixel];

+			} else {

+				dr = sr = srcReds[srcPixel] & 0xFF;

+				dg = sg = srcGreens[srcPixel] & 0xFF;

+				db = sb = srcBlues[srcPixel] & 0xFF;

+				if (op != BLIT_SRC) {

+					switch (destDepth) {

+						case 16:

+							destPixel = ((destData[dp+do0] & 0xFF) << 8) | (destData[dp+do1] & 0xFF);

+							break;

+						case 24:

+							destPixel = ((destData[dp+do0] & 0xFF) << 16) | ((destData[dp+do1] & 0xFF) << 8) | 

+								(destData[dp+do2] & 0xFF);

+							break;

+						case 32:

+							destPixel = ((destData[dp+do0] & 0xFF) << 24) | ((destData[dp+do1] & 0xFF) << 16) |

+								((destData[dp+do2] & 0xFF) << 8) | (destData[dp+do3] & 0xFF);

+							break;

 					}

-					if (i < alphaData.length) continue;

-				} break;

-				case ALPHA_MASK_RGB: {

-					int i = 0;

-					while (i < alphaData.length) {

-						if ((r == (alphaData[i] & 0xff)) &&

-							(g == (alphaData[i + 1] & 0xff)) &&

-							(b == (alphaData[i + 2] & 0xff))) break;

-						i += 3;

+					dr = ((destPixel & destRedMask) << destRedShift) >>> 24;

+					dg = ((destPixel & destGreenMask) << destGreenShift) >>> 24;

+					db = ((destPixel & destBlueMask) << destBlueShift) >>> 24;

+					switch (op) {

+						case BLIT_ALPHA:

+							dr += (sr - dr) * sa / 255;

+							dg += (sg - dg) * sa / 255;

+							db += (sb - db) * sa / 255;

+						break;

 					}

-					if (i < alphaData.length) continue;

-				} break;

-			}

-			if (alpha != 0x10000) {

-				if (alpha == 0x0000) continue;

-				switch (dtype) {

-					case TYPE_GENERIC_8: {

-						final int data = destData[dp] & 0xff;

-						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;

-						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;

-						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;

-						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;

-					} break;

-					case TYPE_GENERIC_16_MSB: {

-						final int data = ((destData[dp] & 0xff) << 8) | (destData[dp + 1] & 0xff);

-						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;

-						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;

-						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;

-						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;

-					} break;

-					case TYPE_GENERIC_16_LSB: {

-						final int data = ((destData[dp + 1] & 0xff) << 8) | (destData[dp] & 0xff);

-						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;

-						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;

-						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;

-						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;

-					} break;

-					case TYPE_GENERIC_24: {

-						final int data = (( ((destData[dp] & 0xff) << 8) |

-							(destData[dp + 1] & 0xff)) << 8) |

-							(destData[dp + 2] & 0xff);

-						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;

-						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;

-						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;

-						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;

-					} break;

-					case TYPE_GENERIC_32_MSB: {

-						final int data = (( (( ((destData[dp] & 0xff) << 8) |

-							(destData[dp + 1] & 0xff)) << 8) |

-							(destData[dp + 2] & 0xff)) << 8) |

-							(destData[dp + 3] & 0xff);

-						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;

-						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;

-						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;

-						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;

-					} break;

-					case TYPE_GENERIC_32_LSB: {

-						final int data = (( (( ((destData[dp + 3] & 0xff) << 8) |

-							(destData[dp + 2] & 0xff)) << 8) |

-							(destData[dp + 1] & 0xff)) << 8) |

-							(destData[dp] & 0xff);

-						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;

-						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;

-						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;

-						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;

-					} break;

 				}

-				// Perform alpha blending

-				a = aq + ((a - aq) * alpha >> 16);

-				r = rq + ((r - rq) * alpha >> 16);

-				g = gq + ((g - gq) * alpha >> 16);

-				b = bq + ((b - bq) * alpha >> 16);

+				destPixel =

+					(((dr << 24) >>> destRedShift) & destRedMask) |

+					(((dg << 24) >>> destGreenShift) & destGreenMask) |

+					(((db << 24) >>> destBlueShift) & destBlueMask);

 			}

-

-			/*** WRITE NEXT PIXEL ***/

-			final int data = 

-				(r >>> destRedPreShift << destRedShift) |

-				(g >>> destGreenPreShift << destGreenShift) |

-				(b >>> destBluePreShift << destBlueShift) |

-				(a >>> destAlphaPreShift << destAlphaShift);

-			switch (dtype) {

-				case TYPE_GENERIC_8: {

-					destData[dp] = (byte) data;

-				} break;

-				case TYPE_GENERIC_16_MSB: {

-					destData[dp] = (byte) (data >>> 8);

-					destData[dp + 1] = (byte) (data & 0xff);

-				} break;

-				case TYPE_GENERIC_16_LSB: {

-					destData[dp] = (byte) (data & 0xff);

-					destData[dp + 1] = (byte) (data >>> 8);

-				} break;

-				case TYPE_GENERIC_24: {

-					destData[dp] = (byte) (data >>> 16);

-					destData[dp + 1] = (byte) (data >>> 8);

-					destData[dp + 2] = (byte) (data & 0xff);

-				} break;

-				case TYPE_GENERIC_32_MSB: {

-					destData[dp] = (byte) (data >>> 24);

-					destData[dp + 1] = (byte) (data >>> 16);

-					destData[dp + 2] = (byte) (data >>> 8);

-					destData[dp + 3] = (byte) (data & 0xff);

-				} break;

-				case TYPE_GENERIC_32_LSB: {

-					destData[dp] = (byte) (data & 0xff);

-					destData[dp + 1] = (byte) (data >>> 8);

-					destData[dp + 2] = (byte) (data >>> 16);

-					destData[dp + 3] = (byte) (data >>> 24);

-				} break;

+			switch (destDepth) {

+				case 16:

+					destData[dp + do0] = (byte)((destPixel >> 8) & 0xFF);

+					destData[dp + do1] = (byte)(destPixel & 0xFF);

+					break;

+				case 24:

+					destData[dp + do0] = (byte)((destPixel >> 16) & 0xFF);

+					destData[dp + do1] = (byte)((destPixel >> 8) & 0xFF);

+					destData[dp + do2] = (byte)(destPixel & 0xFF);

+					break;

+				case 32:

+					destData[dp + do0]  = (byte)((destPixel >> 24) & 0xFF);

+					destData[dp + do1] = (byte)((destPixel >> 16) & 0xFF);

+					destData[dp + do2] = (byte)((destPixel >> 8) & 0xFF);

+					destData[dp + do3] = (byte)(destPixel & 0xFF);

+					break;

+			}

+			while (ex >= 0) {

+				xs += sxs;

+				ex -= dxd2;

+				if (srcAlphaData != null) sap += sas;

+			}

+			dp += sxd;

+			ex += dxs2;

+			if (offset == 0) {

+				offset = 3;

+			} else {

+				offset--;

 			}

 		}

-	}			

+		

+		if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;

+		switch (srcDepth) {

+			case  1:

+				srcPixel = (srcData[sp + (xs >> 3)] & srcMasks[xs & 7]) == 0 ? 0 : 1;

+				break;

+			case  2:

+				srcPixel = ((srcData[sp + (xs >> 2)] & srcMasks[offset]) & 0xFF) >> (offset * 2);

+				break;

+			case  4:

+				srcPixel = srcData[sp + (xs >> 1)] & 0xFF;

+				if ((xs & 0x1) == 0) {

+					srcPixel = srcPixel >> 4;

+				} else {

+					srcPixel = srcPixel & 0x0F;

+				}

+				break;

+			case  8:

+				srcPixel = srcData[sp + xs] & 0xFF;

+				break;

+		}

+		if (mapping != null) {

+			destPixel = mapping[srcPixel];

+		} else {

+			dr = sr = srcReds[srcPixel] & 0xFF;

+			dg = sg = srcGreens[srcPixel] & 0xFF;

+			db = sb = srcBlues[srcPixel] & 0xFF;

+			if (op != BLIT_SRC) {

+				switch (destDepth) {

+					case 16:

+						destPixel = ((destData[dp+do0] & 0xFF) << 8) | (destData[dp+do1] & 0xFF);

+						break;

+					case 24:

+						destPixel = ((destData[dp+do0] & 0xFF) << 16) | ((destData[dp+do1] & 0xFF) << 8) | 

+							(destData[dp+do2] & 0xFF);

+						break;

+					case 32:

+						destPixel = ((destData[dp+do0] & 0xFF) << 24) | ((destData[dp+do1] & 0xFF) << 16) |

+							((destData[dp+do2] & 0xFF) << 8) | (destData[dp+do3] & 0xFF);

+						break;

+				}

+				dr = ((destPixel & destRedMask) << destRedShift) >>> 24;

+				dg = ((destPixel & destGreenMask) << destGreenShift) >>> 24;

+				db = ((destPixel & destBlueMask) << destBlueShift) >>> 24;

+				switch (op) {

+					case BLIT_ALPHA:

+						dr += (sr - dr) * sa / 255;

+						dg += (sg - dg) * sa / 255;

+						db += (sb - db) * sa / 255;

+					break;

+				}

+			}

+			destPixel =

+				(((dr << 24) >>> destRedShift) & destRedMask) |

+				(((dg << 24) >>> destGreenShift) & destGreenMask) |

+				(((db << 24) >>> destBlueShift) & destBlueMask);

+		}

+		switch (destDepth) {

+			case 16:

+				destData[dp + do0] = (byte)((destPixel >> 8) & 0xFF);

+				destData[dp + do1] = (byte)(destPixel & 0xFF);

+				break;

+			case 24:

+				destData[dp + do0] = (byte)((destPixel >> 16) & 0xFF);

+				destData[dp + do1] = (byte)((destPixel >> 8) & 0xFF);

+				destData[dp + do2] = (byte)(destPixel & 0xFF);

+				break;

+			case 32:

+				destData[dp + do0]  = (byte)((destPixel >> 24) & 0xFF);

+				destData[dp + do1] = (byte)((destPixel >> 16) & 0xFF);

+				destData[dp + do2] = (byte)((destPixel >> 8) & 0xFF);

+				destData[dp + do3] = (byte)(destPixel & 0xFF);

+				break;

+		}

+		/* X stretch ends here */

+		if (dy == dyd)

+			break;

+		while (ey >= 0) {

+			ys += sys;

+			ey -= dyd2;

+		}

+		yd += syd;

+		ey += dys2;

+	}

 }

 

 /**

- * Blits a direct palette image into an index palette image.

- * <p>

- * Note: The source and destination masks and palettes must

- * always be fully specified.

- * </p>

- * 

- * @param op the blitter operation: a combination of BLIT_xxx flags

- *        (see BLIT_xxx constants)

- * @param srcData the source byte array containing image data

- * @param srcDepth the source depth: one of 8, 16, 24, 32

- * @param srcStride the source number of bytes per line

- * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;

- *        ignored if srcDepth is not 16 or 32

- * @param srcX the top-left x-coord of the source blit region

- * @param srcY the top-left y-coord of the source blit region

- * @param srcWidth the width of the source blit region

- * @param srcHeight the height of the source blit region

- * @param srcRedMask the source red channel mask

- * @param srcGreenMask the source green channel mask

- * @param srcBlueMask the source blue channel mask

- * @param alphaMode the alpha blending or mask mode, may be

- *        an integer 0-255 for global alpha; ignored if BLIT_ALPHA

- *        not specified in the blitter operations

- *        (see ALPHA_MODE_xxx constants)

- * @param alphaData the alpha blending or mask data, varies depending

- *        on the value of alphaMode and sometimes ignored

- * @param destData the destination byte array containing image data

- * @param destDepth the destination depth: one of 1, 2, 4, 8

- * @param destStride the destination number of bytes per line

- * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;

- *        ignored if destDepth is not 1

- * @param destX the top-left x-coord of the destination blit region

- * @param destY the top-left y-coord of the destination blit region

- * @param destWidth the width of the destination blit region

- * @param destHeight the height of the destination blit region

- * @param destReds the destination palette red component intensities

- * @param destGreens the destination palette green component intensities

- * @param destBlues the destination palette blue component intensities

- * @param flipX if true the resulting image is flipped along the vertical axis

- * @param flipY if true the resulting image is flipped along the horizontal axis

+ * Blits an index palette image into an index palette image.

  */

-static void blit(int op,

-	byte[] srcData, int srcDepth, int srcStride, int srcOrder,

-	int srcX, int srcY, int srcWidth, int srcHeight,

-	int srcRedMask, int srcGreenMask, int srcBlueMask,

-	int alphaMode, byte[] alphaData, int alphaStride,

-	byte[] destData, int destDepth, int destStride, int destOrder,

-	int destX, int destY, int destWidth, int destHeight,

-	byte[] destReds, byte[] destGreens, byte[] destBlues,

-	boolean flipX, boolean flipY) {

-	if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;

+static void blit(int op, byte[] srcData, int srcDepth, int srcStride, int srcOrder, int srcX, int srcY, int srcWidth, int srcHeight, byte[] srcReds, byte[] srcGreens, byte[] srcBlues, int srcGlobalAlpha, byte[] srcAlphaData, int srcAlphaStride, byte[] destData, int destDepth, int destStride, int destOrder, int destX, int destY, int destWidth, int destHeight, byte[] destReds, byte[] destGreens, byte[] destBlues, boolean flipX, boolean flipY) {

+	int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;

+	int dyd, dys, ey, dy, dyd2, dys2, ys, yd;

+	short syd, sys;

+	int dxd, dxs, ex, dx, dxd2, dxs2, xs, xd;

+	short sxd, sxs, sas;

+	int sp, dp, sap = 0;

+	int sr = 0, sg = 0, sb = 0, sa = 0, dr = 0, dg = 0, db = 0, da = 0;

+	int srcPixel = 0, destPixel = 0;

+	int i, j, offset = 0;

+	byte[] srcMasks = null, destMasks = null, destInverseMasks = null;

+	int destN = 1 << destDepth, srcN = 1 << srcDepth;

+	int r, g, b, nearestPixel = 0, lastPixel = -1;

+	int distance, minDistance;

+	int[] mapping = null;

+	boolean samePalette = srcReds == destReds && srcGreens == destGreens && srcBlues == srcBlues;

+	boolean sameAsSrc = op == BLIT_SRC && samePalette && srcDepth <= destDepth;

 

-	// these should be supplied as params later

-	final int srcAlphaMask = 0;

-

-	/*** Prepare scaling data ***/

-	final int dwm1 = destWidth - 1;

-	final int sfxi = (dwm1 != 0) ? ((srcWidth << 16) - 1) / dwm1 : 0;

-	final int dhm1 = destHeight - 1;

-	final int sfyi = (dhm1 != 0) ? ((srcHeight << 16) - 1) / dhm1 : 0;

-

-	/*** Prepare source-related data ***/

-	final int sbpp, stype;

-	switch (srcDepth) {

-		case 8:

-			sbpp = 1;

-			stype = TYPE_GENERIC_8;

-			break;

-		case 16:

-			sbpp = 2;

-			stype = (srcOrder == MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;

-			break;

-		case 24:

-			sbpp = 3;

-			stype = TYPE_GENERIC_24;

-			break;

-		case 32:

-			sbpp = 4;

-			stype = (srcOrder == MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;

-			break;

-		default:

-			//throw new IllegalArgumentException("Invalid source type");

-			return;

-	}			

-	int spr = srcY * srcStride + srcX * sbpp;

-

-	/*** Prepare destination-related data ***/

-	final int dtype;

-	switch (destDepth) {

-		case 8:

-			dtype = TYPE_INDEX_8;

-			break;

-		case 4:

-			destStride <<= 1;

-			dtype = TYPE_INDEX_4;

-			break;

-		case 2:

-			destStride <<= 2;

-			dtype = TYPE_INDEX_2;

-			break;

-		case 1:

-			destStride <<= 3;

-			dtype = (destOrder == MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;

-			break;

-		default:

-			//throw new IllegalArgumentException("Invalid source type");

-			return;

-	}			

-	int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX);

-	final int dprxi = (flipX) ? -1 : 1;

-	final int dpryi = (flipY) ? -destStride : destStride;

-

-	/*** Prepare special processing data ***/

-	int apr;

-	if ((op & BLIT_ALPHA) != 0) {

-		switch (alphaMode) {

-			case ALPHA_MASK_UNPACKED:

-			case ALPHA_CHANNEL_SEPARATE:

-				if (alphaData == null) alphaMode = 0x10000;

-				apr = srcY * alphaStride + srcX;

+	if (srcReds != null && srcN > srcReds.length) srcN = srcReds.length;

+	if (destReds != null && destN > destReds.length) destN = destReds.length;

+	if (op == BLIT_SRC && srcReds != null) {

+		mapping = new int[srcN];		

+		for (i = 0; i < srcN; i++) {

+			minDistance = 0x7FFFFFFF;

+			nearestPixel = 0;

+			for (j = 0; j < destN; j++) {

+				r = (destReds[j] & 0xFF) - (srcReds[i] & 0xFF);

+				g = (destGreens[j] & 0xFF) - (srcGreens[i] & 0xFF);

+				b = (destBlues[j] & 0xFF) - (srcBlues[i] & 0xFF);

+				distance = r*r + g*g + b*b;

+				if (distance < minDistance) {

+					nearestPixel = j;

+					if (distance == 0) break;

+					minDistance = distance;

+				}

+			}

+			mapping[i] = nearestPixel;

+		}

+	}

+	if (op == BLIT_SRC && srcDepth == destDepth && (mapping != null || samePalette))

+	{

+		switch (srcDepth) {

+			case 1:

+				stretch1(srcData, srcStride, srcOrder, srcX, srcY, srcWidth, srcHeight, destData, destStride, destOrder, destX, destY, destWidth, destHeight, flipX, flipY);

 				break;

-			case ALPHA_MASK_PACKED:

-				if (alphaData == null) alphaMode = 0x10000;

-				alphaStride <<= 3;

-				apr = srcY * alphaStride + srcX;

+			case 2:

+				stretch2(srcData, srcStride, srcX, srcY, srcWidth, srcHeight, destData, destStride, destX, destY, destWidth, destHeight, mapping, flipX, flipY);

 				break;

-			case ALPHA_MASK_INDEX:

-				//throw new IllegalArgumentException("Invalid alpha type");

-				return;

-			case ALPHA_MASK_RGB:

-				if (alphaData == null) alphaMode = 0x10000;

-				apr = 0;

+			case 4:

+				stretch4(srcData, srcStride, srcX, srcY, srcWidth, srcHeight, destData, destStride, destX, destY, destWidth, destHeight, mapping, flipX, flipY);

 				break;

-			default:

-				alphaMode = (alphaMode << 16) / 255; // prescale

-			case ALPHA_CHANNEL_SOURCE:

-				apr = 0;

+			case 8:

+				stretch8(srcData, srcStride, srcX, srcY, srcWidth, srcHeight, destData, destStride, destX, destY, destWidth, destHeight, mapping, flipX, flipY);

 				break;

 		}

-	} else {

-		alphaMode = 0x10000;

-		apr = 0;

+		return;

 	}

-	final boolean ditherEnabled = (op & BLIT_DITHER) != 0;

-

-	/*** Comprehensive blit (apply transformations) ***/

-	final int srcRedShift = getChannelShift(srcRedMask);

-	final byte[] srcReds = ANY_TO_EIGHT[getChannelWidth(srcRedMask, srcRedShift)];

-	final int srcGreenShift = getChannelShift(srcGreenMask);

-	final byte[] srcGreens = ANY_TO_EIGHT[getChannelWidth(srcGreenMask, srcGreenShift)];

-	final int srcBlueShift = getChannelShift(srcBlueMask);

-	final byte[] srcBlues = ANY_TO_EIGHT[getChannelWidth(srcBlueMask, srcBlueShift)];

-	final int srcAlphaShift = getChannelShift(srcAlphaMask);

-	final byte[] srcAlphas = ANY_TO_EIGHT[getChannelWidth(srcAlphaMask, srcAlphaShift)];

-

-	int dp = dpr;

-	int sp = spr;

-	int ap = apr, alpha = alphaMode;

-	int r = 0, g = 0, b = 0, a = 0;

-	int indexq = 0;

-	int lastindex = 0, lastr = -1, lastg = -1, lastb = -1;

-	final int[] rerr, gerr, berr;

-	int destPaletteSize = 1 << destDepth;

-	if ((destReds != null) && (destReds.length < destPaletteSize)) destPaletteSize = destReds.length;

-	if (ditherEnabled) {

-		rerr = new int[destWidth + 2];

-		gerr = new int[destWidth + 2];

-		berr = new int[destWidth + 2];

-	} else {

-		rerr = null; gerr = null; berr = null;

+	switch (srcDepth) {

+		case 1: srcMasks = msbMasks1; break;

+		case 2: srcMasks = masks2; break;

 	}

-	for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,

-			sp = spr += (sfy >>> 16) * srcStride,

-			ap = apr += (sfy >>> 16) * alphaStride,

-			sfy = (sfy & 0xffff) + sfyi,

-			dp = dpr += dpryi) {

-		int lrerr = 0, lgerr = 0, lberr = 0;

-		for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,

-				dp += dprxi,

-				sfx = (sfx & 0xffff) + sfxi) {

-			/*** READ NEXT PIXEL ***/

-			switch (stype) {

-				case TYPE_GENERIC_8: {

-					final int data = srcData[sp] & 0xff;

-					sp += (sfx >>> 16);

-					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;

-					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;

-					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;

-					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;

-				} break;

-				case TYPE_GENERIC_16_MSB: {

-					final int data = ((srcData[sp] & 0xff) << 8) | (srcData[sp + 1] & 0xff);

-					sp += (sfx >>> 16) * 2;

-					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;

-					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;

-					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;

-					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;

-				} break;

-				case TYPE_GENERIC_16_LSB: {

-					final int data = ((srcData[sp + 1] & 0xff) << 8) | (srcData[sp] & 0xff);

-					sp += (sfx >>> 16) * 2;

-					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;

-					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;

-					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;

-					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;

-				} break;

-				case TYPE_GENERIC_24: {

-					final int data = (( ((srcData[sp] & 0xff) << 8) |

-						(srcData[sp + 1] & 0xff)) << 8) |

-						(srcData[sp + 2] & 0xff);

-					sp += (sfx >>> 16) * 3;

-					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;

-					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;

-					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;

-					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;

-				} break;

-				case TYPE_GENERIC_32_MSB: {

-					final int data = (( (( ((srcData[sp] & 0xff) << 8) |

-						(srcData[sp + 1] & 0xff)) << 8) |

-						(srcData[sp + 2] & 0xff)) << 8) |

-						(srcData[sp + 3] & 0xff);

-					sp += (sfx >>> 16) * 4;

-					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;

-					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;

-					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;

-					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;

-				} break;

-				case TYPE_GENERIC_32_LSB: {

-					final int data = (( (( ((srcData[sp + 3] & 0xff) << 8) |

-						(srcData[sp + 2] & 0xff)) << 8) |

-						(srcData[sp + 1] & 0xff)) << 8) |

-						(srcData[sp] & 0xff);

-					sp += (sfx >>> 16) * 4;

-					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;

-					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;

-					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;

-					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;

-				} break;

-			}

+	switch (destDepth) {

+		case 1: destMasks = msbMasks1; destInverseMasks = msbInverseMasks1; break;

+		case 2: destMasks = masks2; destInverseMasks = inverseMasks2; break;

+	}

+	if (srcOrder == LSB_FIRST) {

+		switch (srcDepth) {

+			case 1: srcMasks = lsbMasks1; break;

+		}

+	}

+	if (destOrder == LSB_FIRST) {

+		switch (destDepth) {

+			case 1: destMasks = lsbMasks1; destInverseMasks = lsbInverseMasks1; break;

+		}

+	}

 

-			/*** DO SPECIAL PROCESSING IF REQUIRED ***/

-			switch (alphaMode) {

-				case ALPHA_CHANNEL_SEPARATE:

-					alpha = ((alphaData[ap] & 0xff) << 16) / 255;

-					ap += (sfx >> 16);

+	xs1 = srcX; xs2 = srcX + srcWidth - 1;

+	ys1 = srcY; ys2 = srcY + srcHeight - 1;

+	if (flipX) {

+		xd1 = destX + destWidth - 1;

+		xd2 = destX;

+	} else {

+		xd1 = destX;

+		xd2 = destX + destWidth - 1;

+	}

+	if (flipY) {

+		yd1 = destY + destHeight - 1;

+		yd2 = destY;

+	} else {

+		yd1 = destY;

+		yd2 = destY + destHeight - 1;

+	}

+

+	/* Y preliminary calculations */

+	dyd = yd2 - yd1;

+	if (dyd < 0) dyd = -dyd;

+	dys = ys2 - ys1;

+	if (dys < 0) dys = -dys;

+	dyd2 = dyd << 1;

+	dys2 = dys << 1;

+	syd = (short)((yd2 - yd1) > 0 ? 1 : -1);

+	sys = (short)((ys2 - ys1) > 0 ? 1 : -1);

+	ey = dys2 - dyd;

+	ys = ys1;

+	yd = yd1;

+	/* X preliminary calculations */

+	dxd = xd2 - xd1;

+	if (dxd < 0) dxd = -dxd;

+	dxs = xs2 - xs1;

+	if (dxs < 0) dxs = -dxs;

+	dxs2 = dxs << 1;

+	dxd2 = dxd << 1;

+	sxs = sas = (short)((xs2 - xs1) > 0 ? 1 : -1);

+	sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);

+	

+	if (srcGlobalAlpha != -1) srcAlphaData = null;

+	sa = srcGlobalAlpha;

+	for (dy = 0; dy <= dyd; dy++) {

+		/* X stretch starts here */

+		offset = 3 - (srcX % 4);

+		ex = dxs2 - dxd;

+		xs = xs1;

+		xd = xd1;

+		sp = ys * srcStride;

+		dp = yd * destStride;

+		if (srcAlphaData != null) sap = ys * srcAlphaStride;

+		for (dx = 0; dx < dxd; dx++) {

+			if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;

+			switch (srcDepth) {

+				case  1:

+					srcPixel = (srcData[sp + (xs >> 3)] & srcMasks[xs & 7]) == 0 ? 0 : 1;

 					break;

-				case ALPHA_CHANNEL_SOURCE:

-					alpha = (a << 16) / 255;

+				case  2:

+					srcPixel = ((srcData[sp + (xs >> 2)] & srcMasks[offset]) & 0xFF) >> (offset * 2);

 					break;

-				case ALPHA_MASK_UNPACKED:

-					alpha = (alphaData[ap] != 0) ? 0x10000 : 0;

-					ap += (sfx >> 16);

-					break;						

-				case ALPHA_MASK_PACKED:

-					alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;

-					ap += (sfx >> 16);

-					break;

-				case ALPHA_MASK_RGB:

-					alpha = 0x10000;

-					for (int i = 0; i < alphaData.length; i += 3) {

-						if ((r == alphaData[i]) && (g == alphaData[i + 1]) && (b == alphaData[i + 2])) {

-							alpha = 0x0000;

-							break;

-						}

+				case  4:

+					srcPixel = srcData[sp + (xs >> 1)] & 0xFF;

+					if ((xs & 0x1) == 0) {

+						srcPixel = srcPixel >> 4;

+					} else {

+						srcPixel = srcPixel & 0x0F;

 					}

 					break;

+				case  8:

+					srcPixel = srcData[sp + xs] & 0xFF;

+					break;

 			}

-			if (alpha != 0x10000) {

-				if (alpha == 0x0000) continue;

-				switch (dtype) {

-					case TYPE_INDEX_8:

-						indexq = destData[dp] & 0xff;

+			if (mapping != null) {

+				destPixel = mapping[srcPixel];

+			} else if (sameAsSrc) {

+				destPixel = srcPixel;

+			} else {

+				dr = sr = srcReds[srcPixel] & 0xFF;

+				dg = sg = srcGreens[srcPixel] & 0xFF;

+				db = sb = srcBlues[srcPixel] & 0xFF;

+				if (op != BLIT_SRC) {

+					switch (destDepth) {

+						case  1:

+							destPixel = (destData[dp + (xd >> 3)] & destMasks[xd & 7]) == 0 ? 0 : 1;

+							break;

+						case  2:

+							destPixel = ((destData[dp + (xd >> 2)] & destMasks[offset]) & 0xFF) >> (offset * 2);

+							break;

+						case  4:

+							destPixel = destData[dp + (xd >> 1)] & 0xFF;

+							if ((xs & 0x1) == 0) {

+								destPixel = destPixel >> 4;

+							} else {

+								destPixel = destPixel & 0x0F;

+							}

+							break;

+						case  8:

+							destPixel = destData[dp + xd] & 0xFF;

+							break;

+					}

+					dr = destReds[destPixel] & 0xFF;

+					dg = destGreens[destPixel] & 0xFF;

+					db = destBlues[destPixel] & 0xFF;

+					switch (op) {

+						case BLIT_ALPHA:

+							dr += (sr - dr) * sa / 255;

+							dg += (sg - dg) * sa / 255;

+							db += (sb - db) * sa / 255;

 						break;

-					case TYPE_INDEX_4:

-						if ((dp & 1) != 0) indexq = destData[dp >> 1] & 0x0f;

-						else indexq = (destData[dp >> 1] >>> 4) & 0x0f;

+					}

+				}

+				if (lastPixel == -1 || lastPixel != srcPixel) {

+					minDistance = 0x7FFFFFFF;

+					nearestPixel = 0;

+					for (j = 0; j < destN; j++) {

+						r = (destReds[j] & 0xFF) - dr;

+						g = (destGreens[j] & 0xFF) - dg;

+						b = (destBlues[j] & 0xFF) - db;

+						distance = r*r + g*g + b*b;

+						if (distance < minDistance) {

+							nearestPixel = j;

+							if (distance == 0) break;

+							minDistance = distance;

+						}

+					}

+					lastPixel = srcPixel;

+				}

+				destPixel = nearestPixel;

+			}

+			switch (destDepth) {

+				case  1:

+					if ((destPixel & 0x1) == 1) {

+						destData[dp + (xd >> 3)] |= destInverseMasks[xd & 7];

+					} else {

+						destData[dp + (xd >> 3)] &= destInverseMasks[xd & 7] ^ -1;

+					}

+					break;

+				case  2:

+					destData[dp + (xd >> 2)] = (byte)((destData[dp + (xd >> 2)] & destInverseMasks[offset]) | (destPixel << (offset * 2)));

+					break;

+				case  4:

+					if ((xd & 0x1) == 0) {

+						destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0x0F) | ((destPixel & 0x0F) << 4));

+					} else {

+						destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0xF0) | (destPixel & 0x0F));

+					}

+					break;

+				case  8:

+					destData[dp + xd] = (byte)(destPixel & 0xFF);

+					break;

+			}

+			while (ex >= 0) {

+				xs += sxs;

+				ex -= dxd2;

+				if (srcAlphaData != null) sap += sas;

+			}

+			xd += sxd;

+			ex += dxs2;

+			if (offset == 0) {

+				offset = 3;

+			} else {

+				offset--;

+			}

+		}

+		

+		if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;

+		switch (srcDepth) {

+			case  1:

+				srcPixel = (srcData[sp + (xs >> 3)] & srcMasks[xs & 7]) == 0 ? 0 : 1;

+				break;

+			case  2:

+				srcPixel = ((srcData[sp + (xs >> 2)] & srcMasks[offset]) & 0xFF) >> (offset * 2);

+				break;

+			case  4:

+				srcPixel = srcData[sp + (xs >> 1)] & 0xFF;

+				if ((xs & 0x1) == 0) {

+					srcPixel = srcPixel >> 4;

+				} else {

+					srcPixel = srcPixel & 0x0F;

+				}

+				break;

+			case  8:

+				srcPixel = srcData[sp + xs] & 0xFF;

+				break;

+		}

+		if (mapping != null) {

+			destPixel = mapping[srcPixel];

+		} else if (sameAsSrc) {

+			destPixel = srcPixel;

+		} else {

+			dr = sr = srcReds[srcPixel] & 0xFF;

+			dg = sg = srcGreens[srcPixel] & 0xFF;

+			db = sb = srcBlues[srcPixel] & 0xFF;

+			if (op != BLIT_SRC) {

+				switch (destDepth) {

+					case  1:

+						destPixel = (destData[dp + (xd >> 3)] & destMasks[xd & 7]) == 0 ? 0 : 1;

 						break;

-					case TYPE_INDEX_2:

-						indexq = (destData[dp >> 2] >>> (6 - (dp & 3) * 2)) & 0x03;

+					case  2:

+						destPixel = ((destData[dp + (xd >> 2)] & destMasks[offset]) & 0xFF) >> (offset * 2);

 						break;

-					case TYPE_INDEX_1_MSB:

-						indexq = (destData[dp >> 3] >>> (7 - (dp & 7))) & 0x01;

+					case  4:

+						destPixel = destData[dp + (xd >> 1)] & 0xFF;

+						if ((xs & 0x1) == 0) {

+							destPixel = destPixel >> 4;

+						} else {

+							destPixel = destPixel & 0x0F;

+						}

 						break;

-					case TYPE_INDEX_1_LSB:

-						indexq = (destData[dp >> 3] >>> (dp & 7)) & 0x01;

+					case  8:

+						destPixel = destData[dp + xd] & 0xFF;

 						break;

 				}

-				// Perform alpha blending

-				final int rq = destReds[indexq] & 0xff;

-				final int gq = destGreens[indexq] & 0xff;

-				final int bq = destBlues[indexq] & 0xff;

-				r = rq + ((r - rq) * alpha >> 16);

-				g = gq + ((g - gq) * alpha >> 16);

-				b = bq + ((b - bq) * alpha >> 16);

+				dr = destReds[destPixel] & 0xFF;

+				dg = destGreens[destPixel] & 0xFF;

+				db = destBlues[destPixel] & 0xFF;

+				switch (op) {

+					case BLIT_ALPHA:

+						dr += (sr - dr) * sa / 255;

+						dg += (sg - dg) * sa / 255;

+						db += (sb - db) * sa / 255;

+					break;

+				}

 			}

-

-			/*** MAP COLOR TO THE PALETTE ***/

-			if (ditherEnabled) {

-				// Floyd-Steinberg error diffusion

-				r += rerr[dx] >> 4;

-				if (r < 0) r = 0; else if (r > 255) r = 255;

-				g += gerr[dx] >> 4;

-				if (g < 0) g = 0; else if (g > 255) g = 255;

-				b += berr[dx] >> 4;

-				if (b < 0) b = 0; else if (b > 255) b = 255;

-				rerr[dx] = lrerr;

-				gerr[dx] = lgerr;

-				berr[dx] = lberr;

-			}

-			if (r != lastr || g != lastg || b != lastb) {

-				// moving the variable declarations out seems to make the JDK JIT happier...

-				for (int j = 0, dr, dg, db, distance, minDistance = 0x7fffffff; j < destPaletteSize; ++j) {

-					dr = (destReds[j] & 0xff) - r;

-					dg = (destGreens[j] & 0xff) - g;

-					db = (destBlues[j] & 0xff) - b;

-					distance = dr * dr + dg * dg + db * db;

+			if (lastPixel == -1 || lastPixel != srcPixel) {

+				minDistance = 0x7FFFFFFF;

+				nearestPixel = 0;

+				for (j = 0; j < destN; j++) {

+					r = (destReds[j] & 0xFF) - dr;

+					g = (destGreens[j] & 0xFF) - dg;

+					b = (destBlues[j] & 0xFF) - db;

+					distance = r*r + g*g + b*b;

 					if (distance < minDistance) {

-						lastindex = j;

+						nearestPixel = j;

 						if (distance == 0) break;

 						minDistance = distance;

 					}

 				}

-				lastr = r; lastg = g; lastb = b;

+				lastPixel = srcPixel;

 			}

-			if (ditherEnabled) {

-				// Floyd-Steinberg error diffusion, cont'd...

-				final int dxm1 = dx - 1, dxp1 = dx + 1;

-				int acc;

-				rerr[dxp1] += acc = (lrerr = r - (destReds[lastindex] & 0xff)) + lrerr + lrerr;

-				rerr[dx] += acc += lrerr + lrerr;

-				rerr[dxm1] += acc + lrerr + lrerr;

-				gerr[dxp1] += acc = (lgerr = g - (destGreens[lastindex] & 0xff)) + lgerr + lgerr;

-				gerr[dx] += acc += lgerr + lgerr;

-				gerr[dxm1] += acc + lgerr + lgerr;

-				berr[dxp1] += acc = (lberr = b - (destBlues[lastindex] & 0xff)) + lberr + lberr;

-				berr[dx] += acc += lberr + lberr;

-				berr[dxm1] += acc + lberr + lberr;

-			}

-

-			/*** WRITE NEXT PIXEL ***/

-			switch (dtype) {

-				case TYPE_INDEX_8:

-					destData[dp] = (byte) lastindex;

-					break;

-				case TYPE_INDEX_4:

-					if ((dp & 1) != 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | lastindex);

-					else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (lastindex << 4));

-					break;

-				case TYPE_INDEX_2: {

-					final int shift = 6 - (dp & 3) * 2;

-					destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (lastindex << shift));

-				} break;					

-				case TYPE_INDEX_1_MSB: {

-					final int shift = 7 - (dp & 7);

-					destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));

-				} break;

-				case TYPE_INDEX_1_LSB: {

-					final int shift = dp & 7;

-					destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));

-				} break;					

-			}

+			destPixel = nearestPixel;

 		}

-	}

-}

-

-/**

- * Computes the required channel shift from a mask.

- */

-static int getChannelShift(int mask) {

-	if (mask == 0) return 0;

-	int i;

-	for (i = 0; ((mask & 1) == 0) && (i < 32); ++i) {

-		mask >>>= 1;

-	}

-	return i;

-}

-

-/**

- * Computes the required channel width (depth) from a mask.

- */

-static int getChannelWidth(int mask, int shift) {

-	if (mask == 0) return 0;

-	int i;

-	mask >>>= shift;

-	for (i = shift; ((mask & 1) != 0) && (i < 32); ++i) {

-		mask >>>= 1;

-	}

-	return i - shift;

-}

-

-/**

- * Extracts a field from packed RGB data given a mask for that field.

- */

-static byte getChannelField(int data, int mask) {

-	final int shift = getChannelShift(mask);

-	return ANY_TO_EIGHT[getChannelWidth(mask, shift)][(data & mask) >>> shift];

-}

-

-/**

- * Creates an ImageData containing one band's worth of a gradient filled

- * block.  If <code>vertical</code> is true, the band must be tiled

- * horizontally to fill a region, otherwise it must be tiled vertically.

- *

- * @param width the width of the region to be filled

- * @param height the height of the region to be filled

- * @param vertical if true sweeps from top to bottom, else

- *        sweeps from left to right

- * @param fromRGB the color to start with

- * @param toRGB the color to end with

- * @param redBits the number of significant red bits, 0 for palette modes

- * @param greenBits the number of significant green bits, 0 for palette modes

- * @param blueBits the number of significant blue bits, 0 for palette modes

- * @return the new ImageData

- */

-static ImageData createGradientBand(

-	int width, int height, boolean vertical,

-	RGB fromRGB, RGB toRGB,

-	int redBits, int greenBits, int blueBits) {

-	/* Gradients are drawn as tiled bands */

-	final int bandWidth, bandHeight, bitmapDepth;

-	final byte[] bitmapData;

-	final PaletteData paletteData;

-	/* Select an algorithm depending on the depth of the screen */

-	if (redBits != 0 && greenBits != 0 && blueBits != 0) {

-		paletteData = new PaletteData(0x0000ff00, 0x00ff0000, 0xff000000);

-		bitmapDepth = 32;

-		if (redBits >= 8 && greenBits >= 8 && blueBits >= 8) {

-			/* Precise color */

-			final int steps;

-			if (vertical) {

-				bandWidth = 1;

-				bandHeight = height;

-				steps = bandHeight > 1 ? bandHeight - 1 : 1;

-			} else {

-				bandWidth = width;

-				bandHeight = 1;

-				steps = bandWidth > 1 ? bandWidth - 1 : 1;

-			}

-			final int bytesPerLine = bandWidth * 4;

-			bitmapData = new byte[bandHeight * bytesPerLine];

-			buildPreciseGradientChannel(fromRGB.blue, toRGB.blue, steps, bandWidth, bandHeight, vertical, bitmapData, 0, bytesPerLine);

-			buildPreciseGradientChannel(fromRGB.green, toRGB.green, steps, bandWidth, bandHeight, vertical, bitmapData, 1, bytesPerLine);

-			buildPreciseGradientChannel(fromRGB.red, toRGB.red, steps, bandWidth, bandHeight, vertical, bitmapData, 2, bytesPerLine);

-		} else {

-			/* Dithered color */

-			final int steps;

-			if (vertical) {

-				bandWidth = (width < 8) ? width : 8;

-				bandHeight = height;

-				steps = bandHeight > 1 ? bandHeight - 1 : 1;

-			} else {

-				bandWidth = width;

-				bandHeight = (height < 8) ? height : 8;

-				steps = bandWidth > 1 ? bandWidth - 1 : 1;

-			}

-			final int bytesPerLine = bandWidth * 4;

-			bitmapData = new byte[bandHeight * bytesPerLine];

-			buildDitheredGradientChannel(fromRGB.blue, toRGB.blue, steps, bandWidth, bandHeight, vertical, bitmapData, 0, bytesPerLine, blueBits);

-			buildDitheredGradientChannel(fromRGB.green, toRGB.green, steps, bandWidth, bandHeight, vertical, bitmapData, 1, bytesPerLine, greenBits);

-			buildDitheredGradientChannel(fromRGB.red, toRGB.red, steps, bandWidth, bandHeight, vertical, bitmapData, 2, bytesPerLine, redBits);			

-		}

-	} else {

-		/* Dithered two tone */

-		paletteData = new PaletteData(new RGB[] { fromRGB, toRGB });

-		bitmapDepth = 8;

-		final int blendi;

-		if (vertical) {

-			bandWidth = (width < 8) ? width : 8;

-			bandHeight = height;

-			blendi = (bandHeight > 1) ? 0x1040000 / (bandHeight - 1) + 1 : 1;

-		} else {

-			bandWidth = width;

-			bandHeight = (height < 8) ? height : 8;

-			blendi = (bandWidth > 1) ? 0x1040000 / (bandWidth - 1) + 1 : 1;

-		}

-		final int bytesPerLine = (bandWidth + 3) & -4;

-		bitmapData = new byte[bandHeight * bytesPerLine];

-		if (vertical) {

-			for (int dy = 0, blend = 0, dp = 0; dy < bandHeight;

-				++dy, blend += blendi, dp += bytesPerLine) {

-				for (int dx = 0; dx < bandWidth; ++dx) {

-					bitmapData[dp + dx] = (blend + DITHER_MATRIX[dy & 7][dx]) <

-						0x1000000 ? (byte)0 : (byte)1;

+		switch (destDepth) {

+			case  1:

+				if ((destPixel & 0x1) == 1) {

+					destData[dp + (xd >> 3)] |= destInverseMasks[xd & 7];

+				} else {

+					destData[dp + (xd >> 3)] &= destInverseMasks[xd & 7] ^ -1;

 				}

-			}		

-		} else {

-			for (int dx = 0, blend = 0; dx < bandWidth; ++dx, blend += blendi) {

-				for (int dy = 0, dptr = dx; dy < bandHeight; ++dy, dptr += bytesPerLine) {

-					bitmapData[dptr] = (blend + DITHER_MATRIX[dy][dx & 7]) <

-						0x1000000 ? (byte)0 : (byte)1;

+				break;

+			case  2:

+				destData[dp + (xd >> 2)] = (byte)((destData[dp + (xd >> 2)] & destInverseMasks[offset]) | (destPixel << (offset * 2)));

+				break;

+			case  4:

+				if ((xd & 0x1) == 0) {

+					destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0x0F) | ((destPixel & 0x0F) << 4));

+				} else {

+					destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0xF0) | (destPixel & 0x0F));

+				}

+				break;

+			case  8:

+				destData[dp + xd] = (byte)(destPixel & 0xFF);

+				break;

+		}

+		/* X stretch ends here */

+		if (dy == dyd)

+			break;

+		while (ey >= 0) {

+			ys += sys;

+			ey -= dyd2;

+		}

+		yd += syd;

+		ey += dys2;

+	}

+}

+

+/**

+ * Blits a direct palette image into an index palette image.

+ */

+static void blit(int op, byte[] srcData, int srcDepth, int srcStride, int srcOrder, int srcX, int srcY, int srcWidth, int srcHeight, int srcRedMask, int srcGreenMask, int srcBlueMask, int srcGlobalAlpha, byte[] srcAlphaData, int srcAlphaStride, byte[] destData, int destDepth, int destStride, int destOrder, int destX, int destY, int destWidth, int destHeight, byte[] destReds, byte[] destGreens, byte[] destBlues, boolean flipX, boolean flipY) {

+	int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;

+	int dyd, dys, ey, dy, dyd2, dys2, ys, yd;

+	short syd, sys;

+	int dxd, dxs, ex, dx, dxd2, dxs2, xd;

+	short sxd, sxs, sas;

+	int sp, dp, sap = 0;

+	int sr = 0, sg = 0, sb = 0, sa = 0, dr = 0, dg = 0, db = 0, da = 0;

+	int srcPixel = 0, destPixel = 0;

+	short so0 = 0, so1 = 1, so2 = 2, so3 = 3;

+	int srcRedShift, srcGreenShift, srcBlueShift;

+	int j, offset = 0;

+	byte[] destMasks = null, destInverseMasks = null;

+	int destN = 1 << destDepth;

+	int r, g, b, nearestPixel = 0, lastPixel = -1;

+	int distance, minDistance;

+	

+	srcRedShift = 32 - getMSBOffset(srcRedMask);

+	srcGreenShift = 32 - getMSBOffset(srcGreenMask);

+	srcBlueShift = 32 - getMSBOffset(srcBlueMask);

+	if (destReds != null && destN > destReds.length) destN = destReds.length;

+	switch (destDepth) {

+		case 1: destMasks = msbMasks1; destInverseMasks = msbInverseMasks1; break;

+		case 2: destMasks = masks2; destInverseMasks = inverseMasks2; break;

+	}

+	if (srcOrder == LSB_FIRST) {

+		switch (srcDepth) {

+			case 16: so0 = 1; so1 = 0; break;

+			case 24: so0 = 2; so1 = 1; so2 = 0; break;

+			case 32: so0 = 3; so1 = 2; so2 = 1; so3 = 0; break;

+		}

+	}

+	if (destOrder == LSB_FIRST) {

+		switch (destDepth) {

+			case 1: destMasks = lsbMasks1; destInverseMasks = lsbInverseMasks1; break;

+		}

+	}

+

+	xs1 = srcX; xs2 = srcX + srcWidth - 1;

+	ys1 = srcY; ys2 = srcY + srcHeight - 1;

+	if (flipX) {

+		xd1 = destX + destWidth - 1;

+		xd2 = destX;

+	} else {

+		xd1 = destX;

+		xd2 = destX + destWidth - 1;

+	}

+	if (flipY) {

+		yd1 = destY + destHeight - 1;

+		yd2 = destY;

+	} else {

+		yd1 = destY;

+		yd2 = destY + destHeight - 1;

+	}

+

+	/* Y preliminary calculations */

+	dyd = yd2 - yd1;

+	if (dyd < 0) dyd = -dyd;

+	dys = ys2 - ys1;

+	if (dys < 0) dys = -dys;

+	dyd2 = dyd << 1;

+	dys2 = dys << 1;

+	syd = (short)((yd2 - yd1) > 0 ? 1 : -1);

+	sys = (short)((ys2 - ys1) > 0 ? 1 : -1);

+	ey = dys2 - dyd;

+	ys = ys1;

+	yd = yd1;

+	/* X preliminary calculations */

+	dxd = xd2 - xd1;

+	if (dxd < 0) dxd = -dxd;

+	dxs = xs2 - xs1;

+	if (dxs < 0) dxs = -dxs;

+	dxs2 = dxs << 1;

+	dxd2 = dxd << 1;

+	sxs = sas = (short)((xs2 - xs1) > 0 ? 1 : -1);

+	sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);

+

+	sxs *= srcDepth / 8;

+	xs1 *= srcDepth / 8;

+	

+	if (srcGlobalAlpha != -1) srcAlphaData = null;

+	sa = srcGlobalAlpha;

+	for (dy = 0; dy <= dyd; dy++) {

+		/* X stretch starts here */

+		offset = 3 - (srcX % 4);

+		ex = dxs2 - dxd;

+		xd = xd1;

+		sp = ys * srcStride + xs1;

+		dp = yd * destStride;

+		if (srcAlphaData != null) sap = ys * srcAlphaStride + xs1;

+		for (dx = 0; dx < dxd; dx++) {

+			if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;

+			switch (srcDepth) {

+				case 16:

+					srcPixel = ((srcData[sp+so0] & 0xFF) << 8) | (srcData[sp+so1] & 0xFF);

+					break;

+				case 24:

+					srcPixel = ((srcData[sp+so0] & 0xFF) << 16) | ((srcData[sp+so1] & 0xFF) << 8) | 

+						(srcData[sp+so2] & 0xFF);

+					break;

+				case 32:

+					srcPixel = ((srcData[sp+so0] & 0xFF) << 24) | ((srcData[sp+so1] & 0xFF) << 16) |

+						((srcData[sp+so2] & 0xFF) << 8) | (srcData[sp+so3] & 0xFF);

+					break;

+			}

+			dr = sr = ((srcPixel & srcRedMask) << srcRedShift) >>> 24;

+			dg = sg = ((srcPixel & srcGreenMask) << srcGreenShift) >>> 24;

+			db = sb = ((srcPixel & srcBlueMask) << srcBlueShift) >>> 24;

+			if (op != BLIT_SRC) {

+				switch (destDepth) {

+					case  1:

+						destPixel = (destData[dp + (xd >> 3)] & destMasks[xd & 7]) == 0 ? 0 : 1;

+						break;

+					case  2:

+						destPixel = ((destData[dp + (xd >> 2)] & destMasks[offset]) & 0xFF) >> (offset * 2);

+						break;

+					case  4:

+						destPixel = destData[dp + (xd >> 1)] & 0xFF;

+						if ((xd & 0x1) == 0) {

+							destPixel = destPixel >> 4;

+						} else {

+							destPixel = destPixel & 0x0F;

+						}

+						break;

+					case  8:

+						destPixel = destData[dp + xd] & 0xFF;

+						break;

+				}

+				dr = destReds[destPixel] & 0xFF;

+				dg = destGreens[destPixel] & 0xFF;

+				db = destBlues[destPixel] & 0xFF;

+				switch (op) {

+					case BLIT_ALPHA:

+						dr += (sr - dr) * sa / 255;

+						dg += (sg - dg) * sa / 255;

+						db += (sb - db) * sa / 255;

+					break;

 				}

 			}

-		}

-	}

-	return new ImageData(bandWidth, bandHeight, bitmapDepth, paletteData, 4, bitmapData);

-}

-

-/* 

- * Fill in gradated values for a color channel

- */

-static final void buildPreciseGradientChannel(int from, int to, int steps,

-	int bandWidth, int bandHeight, boolean vertical,

-	byte[] bitmapData, int dp, int bytesPerLine) {

-	int val = from << 16;

-	final int inc = ((to << 16) - val) / steps + 1;

-	if (vertical) {

-		for (int dy = 0; dy < bandHeight; ++dy, dp += bytesPerLine) {

-			bitmapData[dp] = (byte)(val >>> 16);

-			val += inc;

-		}

-	} else {

-		for (int dx = 0; dx < bandWidth; ++dx, dp += 4) {

-			bitmapData[dp] = (byte)(val >>> 16);

-			val += inc;

-		}

-	}		

-}

-

-/* 

- * Fill in dithered gradated values for a color channel

- */

-static final void buildDitheredGradientChannel(int from, int to, int steps,

-	int bandWidth, int bandHeight, boolean vertical,

-	byte[] bitmapData, int dp, int bytesPerLine, int bits) {

-	final int mask = 0xff00 >>> bits;

-	int val = from << 16;

-	final int inc = ((to << 16) - val) / steps + 1;

-	if (vertical) {

-		for (int dy = 0; dy < bandHeight; ++dy, dp += bytesPerLine) {

-			for (int dx = 0, dptr = dp; dx < bandWidth; ++dx, dptr += 4) {

-				final int thresh = DITHER_MATRIX[dy & 7][dx] >>> bits;

-				int temp = val + thresh;

-				if (temp > 0xffffff) bitmapData[dptr] = -1;

-				else bitmapData[dptr] = (byte)((temp >>> 16) & mask);

+			if (lastPixel == -1 || lastPixel != srcPixel) {

+				minDistance = 0x7FFFFFFF;

+				nearestPixel = 0;

+				for (j = 0; j < destN; j++) {

+					r = (destReds[j] & 0xFF) - dr;

+					g = (destGreens[j] & 0xFF) - dg;

+					b = (destBlues[j] & 0xFF) - db;

+					distance = r*r + g*g + b*b;

+					if (distance < minDistance) {

+						nearestPixel = j;

+						if (distance == 0) break;

+						minDistance = distance;

+					}

+				}

+				lastPixel = srcPixel;

 			}

-			val += inc;

-		}

-	} else {

-		for (int dx = 0; dx < bandWidth; ++dx, dp += 4) {

-			for (int dy = 0, dptr = dp; dy < bandHeight; ++dy, dptr += bytesPerLine) {

-				final int thresh = DITHER_MATRIX[dy][dx & 7] >>> bits;

-				int temp = val + thresh;

-				if (temp > 0xffffff) bitmapData[dptr] = -1;

-				else bitmapData[dptr] = (byte)((temp >>> 16) & mask);

+			destPixel = nearestPixel;

+			switch (destDepth) {

+				case  1:

+					if ((destPixel & 0x1) == 1) {

+						destData[dp + (xd >> 3)] |= destInverseMasks[xd & 7];

+					} else {

+						destData[dp + (xd >> 3)] &= destInverseMasks[xd & 7] ^ -1;

+					}

+					break;

+				case  2:

+					destData[dp + (xd >> 2)] = (byte)((destData[dp + (xd >> 2)] & destInverseMasks[offset]) | (destPixel << (offset * 2)));

+					break;

+				case  4:

+					if ((xd & 0x1) == 0) {

+						destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0x0F) | ((destPixel & 0x0F) << 4));

+					} else {

+						destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0xF0) | (destPixel & 0x0F));

+					}

+					break;

+				case  8:

+					destData[dp + xd] = (byte)(destPixel & 0xFF);

+					break;

 			}

-			val += inc;

+			while (ex >= 0) {

+				sp += sxs;

+				ex -= dxd2;

+				if (srcAlphaData != null) sap += sas;

+			}

+			xd += sxd;

+			ex += dxs2;

+			if (offset == 0) {

+				offset = 3;

+			} else {

+				offset--;

+			}

 		}

+		

+		if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;

+		switch (srcDepth) {

+			case 16:

+				srcPixel = ((srcData[sp+so0] & 0xFF) << 8) | (srcData[sp+so1] & 0xFF);

+				break;

+			case 24:

+				srcPixel = ((srcData[sp+so0] & 0xFF) << 16) | ((srcData[sp+so1] & 0xFF) << 8) | 

+					(srcData[sp+so2] & 0xFF);

+				break;

+			case 32:

+				srcPixel = ((srcData[sp+so0] & 0xFF) << 24) | ((srcData[sp+so1] & 0xFF) << 16) |

+					((srcData[sp+so2] & 0xFF) << 8) | (srcData[sp+so3] & 0xFF);

+				break;

+		}

+		dr = sr = ((srcPixel & srcRedMask) << srcRedShift) >>> 24;

+		dg = sg = ((srcPixel & srcGreenMask) << srcGreenShift) >>> 24;

+		db = sb = ((srcPixel & srcBlueMask) << srcBlueShift) >>> 24;

+		if (op != BLIT_SRC) {

+			switch (destDepth) {

+				case  1:

+					destPixel = (destData[dp + (xd >> 3)] & destMasks[xd & 7]) == 0 ? 0 : 1;

+					break;

+				case  2:

+					destPixel = ((destData[dp + (xd >> 2)] & destMasks[offset]) & 0xFF) >> (offset * 2);

+					break;

+				case  4:

+					destPixel = destData[dp + (xd >> 1)] & 0xFF;

+					if ((xd & 0x1) == 0) {

+						destPixel = destPixel >> 4;

+					} else {

+						destPixel = destPixel & 0x0F;

+					}

+					break;

+				case  8:

+					destPixel = destData[dp + xd] & 0xFF;

+					break;

+			}

+			dr = destReds[destPixel] & 0xFF;

+			dg = destGreens[destPixel] & 0xFF;

+			db = destBlues[destPixel] & 0xFF;

+			switch (op) {

+				case BLIT_ALPHA:

+					dr += (sr - dr) * sa / 255;

+					dg += (sg - dg) * sa / 255;

+					db += (sb - db) * sa / 255;

+				break;

+			}

+		}

+		if (lastPixel == -1 || lastPixel != srcPixel) {

+			minDistance = 0x7FFFFFFF;

+			nearestPixel = 0;

+			for (j = 0; j < destN; j++) {

+				r = (destReds[j] & 0xFF) - dr;

+				g = (destGreens[j] & 0xFF) - dg;

+				b = (destBlues[j] & 0xFF) - db;

+				distance = r*r + g*g + b*b;

+				if (distance < minDistance) {

+					nearestPixel = j;

+					if (distance == 0) break;

+					minDistance = distance;

+				}

+			}

+			lastPixel = srcPixel;

+		}

+		destPixel = nearestPixel;

+		switch (destDepth) {

+			case  1:

+				if ((destPixel & 0x1) == 1) {

+					destData[dp + (xd >> 3)] |= destInverseMasks[xd & 7];

+				} else {

+					destData[dp + (xd >> 3)] &= destInverseMasks[xd & 7] ^ -1;

+				}

+				break;

+			case  2:

+				destData[dp + (xd >> 2)] = (byte)((destData[dp + (xd >> 2)] & destInverseMasks[offset]) | (destPixel << (offset * 2)));

+				break;

+			case  4:

+				if ((xd & 0x1) == 0) {

+					destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0x0F) | ((destPixel & 0x0F) << 4));

+				} else {

+					destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0xF0) | (destPixel & 0x0F));

+				}

+				break;

+			case  8:

+				destData[dp + xd] = (byte)(destPixel & 0xFF);

+				break;

+		}

+		/* X stretch ends here */

+		if (dy == dyd)

+			break;

+		while (ey >= 0) {

+			ys += sys;

+			ey -= dyd2;

+		}

+		yd += syd;

+		ey += dys2;

 	}

 }

 

 /**

- * Renders a gradient onto a GC.

- * <p>

- * This is a GC helper.

- * </p>

- *

- * @param gc the GC to render the gradient onto

- * @param device the device the GC belongs to

- * @param x the top-left x coordinate of the region to be filled

- * @param y the top-left y coordinate of the region to be filled

- * @param width the width of the region to be filled

- * @param height the height of the region to be filled

- * @param vertical if true sweeps from top to bottom, else

- *        sweeps from left to right

- * @param fromRGB the color to start with

- * @param toRGB the color to end with

- * @param redBits the number of significant red bits, 0 for palette modes

- * @param greenBits the number of significant green bits, 0 for palette modes

- * @param blueBits the number of significant blue bits, 0 for palette modes

+ * Stretches the source, a 1-bit image, into the destination, a 1-bit image.

  */

-static void fillGradientRectangle(GC gc, Device device,

-	int x, int y, int width, int height, boolean vertical,

-	RGB fromRGB, RGB toRGB,

-	int redBits, int greenBits, int blueBits) {

-	/* Create the bitmap and tile it */

-	ImageData band = createGradientBand(width, height, vertical,

-		fromRGB, toRGB, redBits, greenBits, blueBits);

-	Image image = new Image(device, band);

-	if ((band.width == 1) || (band.height == 1)) {

-		gc.drawImage(image, 0, 0, band.width, band.height, x, y, width, height);

+static void stretch1(byte[] srcData, int srcStride, int srcOrder, int srcX, int srcY, int srcWidth, int srcHeight, byte[] destData, int destStride, int destOrder, int destX, int destY, int destWidth, int destHeight, boolean flipX, boolean flipY) {

+	int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;

+	int dyd, dys, ey, dy, dyd2, dys2, ys, yd;

+	short syd, sys;

+	int dxd, dxs, ex, dx, dxd2, dxs2, xs, xd;

+	short sxd, sxs;

+	byte pixel;

+	int sp, dp;

+	byte[] masks, inverseMasks;

+	

+	if (srcOrder == LSB_FIRST) {

+		masks = lsbMasks1;

 	} else {

-		if (vertical) {

-			for (int dx = 0; dx < width; dx += band.width) {

-				int blitWidth = width - dx;

-				if (blitWidth > band.width) blitWidth = band.width;

-				gc.drawImage(image, 0, 0, blitWidth, band.height, dx + x, y, blitWidth, band.height);

-			}

-		} else {

-			for (int dy = 0; dy < height; dy += band.height) {

-				int blitHeight = height - dy;

-				if (blitHeight > band.height) blitHeight = band.height;

-				gc.drawImage(image, 0, 0, band.width, blitHeight, x, dy + y, band.width, blitHeight);

-			}

-		}

+		masks = msbMasks1;

 	}

-	image.dispose();

+	if (destOrder == LSB_FIRST) {

+		inverseMasks = lsbInverseMasks1;

+	} else {

+		inverseMasks = msbInverseMasks1;

+	}

+	

+	xs1 = srcX; xs2 = srcX + srcWidth - 1;

+	ys1 = srcY; ys2 = srcY + srcHeight - 1;

+	if (flipX) {

+		xd1 = destX + destWidth - 1;

+		xd2 = destX;

+	} else {

+		xd1 = destX;

+		xd2 = destX + destWidth - 1;

+	}

+	if (flipY) {

+		yd1 = destY + destHeight - 1;

+		yd2 = destY;

+	} else {

+		yd1 = destY;

+		yd2 = destY + destHeight - 1;

+	}

+

+	/* Y preliminary calculations */

+	dyd = yd2 - yd1;

+	if (dyd < 0) dyd = -dyd;

+	dys = ys2 - ys1;

+	if (dys < 0) dys = -dys;

+	dyd2 = dyd << 1;

+	dys2 = dys << 1;

+	syd = (short)((yd2 - yd1) > 0 ? 1 : -1);

+	sys = (short)((ys2 - ys1) > 0 ? 1 : -1);

+	ey = dys2 - dyd;

+	ys = ys1;

+	yd = yd1;

+	/* X preliminary calculations */

+	dxd = xd2 - xd1;

+	if (dxd < 0) dxd = -dxd;

+	dxs = xs2 - xs1;

+	if (dxs < 0) dxs = -dxs;

+	dxd2 = dxd << 1;

+	dxs2 = dxs << 1;

+	sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);

+	sxs = (short)((xs2 - xs1) > 0 ? 1 : -1);

+	

+	for (dy = 0; dy <= dyd; dy++) {

+		/* X stretch starts here */

+		ex = dxs2 - dxd;

+		xs = xs1;

+		xd = xd1;

+		sp = ys * srcStride;

+		dp = yd * destStride;

+		pixel = (byte)(srcData[sp + (xs >> 3)] & masks[xs & 7]);

+		for (dx = 0; dx < dxd; dx++) {

+			if (pixel != 0)

+				destData[dp + (xd >> 3)] |= masks[xd & 7];

+			else

+				destData[dp + (xd >> 3)] &= inverseMasks[xd & 7];

+			if (ex >= 0) {

+				do {

+					xs += sxs;

+					ex -= dxd2;

+				} while (ex >= 0);

+				pixel = (byte)(srcData[sp + (xs >> 3)] & masks[xs & 7]);

+			}

+			xd += sxd;

+			ex += dxs2;

+		}

+		if (pixel != 0)

+			destData[dp + (xd >> 3)] |= masks[xd & 7];

+		else

+			destData[dp + (xd >> 3)] &= inverseMasks[xd & 7];

+		/* X stretch ends here */

+		if (dy == dyd)

+			break;

+		while (ey >= 0) {

+			ys += sys;

+			ey -= dyd2;

+		}

+		yd += syd;

+		ey += dys2;

+	}

 }

 

-}
\ No newline at end of file
+/**

+ * Stretches the source, a 16-bit image, into the destination, a 16-bit image.

+ * The images are assumed to have the same red, green, and blue masks.

+ *

+ * Untested - would need an X server with the same red, green and blue

+ * masks as the file has, namely, 0x7C00, 0x3E0, 0x1F. Most 16-bit X servers

+ * have masks of 0xF800, 0x7E0, 0x1F.

+ */

+static void stretch16(byte[] srcData, int srcStride, int srcX, int srcY, int srcWidth, int srcHeight, byte[] destData, int destStride, int destX, int destY, int destWidth, int destHeight, boolean flipX, boolean flipY) {

+	int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;

+	int dyd, dys, ey, dy, dyd2, dys2, yd, ys;

+	short syd, sys;

+	int dxd, dxs, ex, dx, dxd2, dxs2, xs, xd;

+	short sxd, sxs;

+	byte pixel0, pixel1;

+	int sp, dp;

+	

+	xs1 = srcX; xs2 = srcX + srcWidth - 1;

+	ys1 = srcY; ys2 = srcY + srcHeight - 1;

+	if (flipX) {

+		xd1 = destX + destWidth - 1;

+		xd2 = destX;

+	} else {

+		xd1 = destX;

+		xd2 = destX + destWidth - 1;

+	}

+	if (flipY) {

+		yd1 = destY + destHeight - 1;

+		yd2 = destY;

+	} else {

+		yd1 = destY;

+		yd2 = destY + destHeight - 1;

+	}

+

+	/* Y preliminary calculations */

+	dyd = yd2 - yd1;

+	if (dyd < 0) dyd = -dyd;

+	dys = ys2 - ys1;

+	if (dys < 0) dys = -dys;

+	dyd2 = dyd << 1;

+	dys2 = dys << 1;

+	syd = (short)((yd2 - yd1) > 0 ? 1 : -1);

+	sys = (short)((ys2 - ys1) > 0 ? 1 : -1);

+	ey = dys2 - dyd;

+	ys = ys1;

+	yd = yd1;

+	/* X preliminary calculations */

+	dxd = xd2 - xd1;

+	if (dxd < 0) dxd = -dxd;

+	dxs = xs2 - xs1;

+	if (dxs < 0) dxs = -dxs;

+	dxd2 = dxd << 1;

+	dxs2 = dxs << 1;

+	sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);

+	sxs = (short)((xs2 - xs1) > 0 ? 1 : -1);

+	

+	for (dy = 0; dy <= dyd; dy++) {

+		/* X stretch starts here */

+		ex = dxs2 - dxd;

+		xs = xs1;

+		xd = xd1;

+		sp = ys * srcStride;

+		dp = yd * destStride;

+		pixel0 = srcData[sp + xs];

+		pixel1 = srcData[sp + xs + 1];

+		for (dx = 0; dx < dxd; dx++) {

+			destData[dp + xd] = pixel0;

+			destData[dp + xd + 1] = pixel1;

+			if (ex >= 0) {

+				do {

+					xs += (sxs << 1);

+					ex -= dxd2;

+				} while (ex >= 0);

+				pixel0 = srcData[sp + xs];

+				pixel1 = srcData[sp + xs + 1];

+			}

+			xd += (sxd << 1);

+			ex += dxs2;

+		}

+		destData[dp + xd] = pixel0;

+		destData[dp + xd + 1] = pixel1;

+		/* X stretch ends here */

+		if (dy == dyd)

+			break;

+		while (ey >= 0) {

+			ys += sys;

+			ey -= dyd2;

+		}

+		yd += syd;

+		ey += dys2;

+	}

+}

+

+/**

+ * Stretches the source, a 2-bit image, into the destination, a 2-bit image.

+ */

+static void stretch2(byte[] srcData, int srcStride, int srcX, int srcY, int srcWidth, int srcHeight, byte[] destData, int destStride, int destX, int destY, int destWidth, int destHeight, int[] mapping, boolean flipX, boolean flipY) {

+	int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;

+	int dyd, dys, ey, dy, dyd2, dys2, yd, ys;

+	short syd, sys;

+	int dxd, dxs, ex, dx, dxd2, dxs2, xs, xd;

+	short sxd, sxs;

+	byte pixel;

+	int sp, dp, x;

+	byte [] masks = { (byte)0x03, (byte)0x0C, (byte)0x30, (byte)0xC0 };

+	byte [] inverseMasks = { (byte)0xFC, (byte)0xF3, (byte)0xCF, (byte)0x3F };

+	

+	xs1 = srcX; xs2 = srcX + srcWidth - 1;

+	ys1 = srcY; ys2 = srcY + srcHeight - 1;

+	if (flipX) {

+		xd1 = destX + destWidth - 1;

+		xd2 = destX;

+	} else {

+		xd1 = destX;

+		xd2 = destX + destWidth - 1;

+	}

+	if (flipY) {

+		yd1 = destY + destHeight - 1;

+		yd2 = destY;

+	} else {

+		yd1 = destY;

+		yd2 = destY + destHeight - 1;

+	}

+

+	/* Y preliminary calculations */

+	dyd = yd2 - yd1;

+	if (dyd < 0) dyd = -dyd;

+	dys = ys2 - ys1;

+	if (dys < 0) dys = -dys;

+	dyd2 = dyd << 1;

+	dys2 = dys << 1;

+	syd = (short)((yd2 - yd1) > 0 ? 1 : -1);

+	sys = (short)((ys2 - ys1) > 0 ? 1 : -1);

+	ey = dys2 - dyd;

+	ys = ys1;

+	yd = yd1;

+	/* X preliminary calculations */

+	dxd = xd2 - xd1;

+	if (dxd < 0) dxd = -dxd;

+	dxs = xs2 - xs1;

+	if (dxs < 0) dxs = -dxs;

+	dxd2 = dxd << 1;

+	dxs2 = dxs << 1;

+	sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);

+	sxs = (short)((xs2 - xs1) > 0 ? 1 : -1);

+	

+	for (dy = 0; dy <= dyd; dy++) {

+		/* X stretch starts here */

+		int offset = 3 - (srcX % 4);

+		ex = dxs2 - dxd;

+		xs = xs1;

+		xd = xd1;

+		sp = ys * srcStride;

+		dp = yd * destStride;

+		x = (byte)(((srcData[sp + (xs >> 2)] & masks[offset]) & 0xFF) >> (offset * 2));

+		pixel = (byte)(mapping == null ? x : mapping[x]);

+		for (dx = 0; dx < dxd; dx++) {

+			destData[dp + (xd >> 2)] = (byte)((destData[dp + (xd >> 2)] & inverseMasks[offset]) | (pixel << (offset * 2)));

+			if (ex >= 0) {

+				do {

+					xs += sxs;

+					ex -= dxd2;

+				} while (ex >= 0);

+				x = (byte)(((srcData[sp + (xs >> 2)] & masks[offset]) & 0xFF) >> (offset * 2));

+				pixel = (byte)(mapping == null ? x : mapping[x]);

+			}

+			xd += sxd;

+			ex += dxs2;

+			if (offset == 0) {

+				offset = 3;

+			} else {

+				offset--;

+			}

+		}

+		destData[dp + (xd >> 2)] = (byte)((destData[dp + (xd >> 2)] & inverseMasks[offset]) | (pixel << (offset * 2)));

+		/* X stretch ends here */

+		if (dy == dyd)

+			break;

+		while (ey >= 0) {

+			ys += sys;

+			ey -= dyd2;

+		}

+		yd += syd;

+		ey += dys2;

+	}

+}

+

+/**

+ * Stretches the source, a 24-bit image, into the destination, a 24-bit image.

+ * The images must have the same red, green, and blue masks.

+ * The image are assumed to have 24 bits per pixel; many 24-bit images

+ * use 32 bits per pixel.

+ *

+ * Untested. Would require an X server with a depth of 24 which has 24 bits per

+ * pixel. Most X servers with depth 24 actually have 32 bits per pixel.

+ */

+static void stretch24(byte[] srcData, int srcStride, int srcX, int srcY, int srcWidth, int srcHeight, byte[] destData, int destStride, int destX, int destY, int destWidth, int destHeight, boolean flipX, boolean flipY) {

+	int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;

+	int dyd, dys, ey, dy, dyd2, dys2, ys, yd;

+	short syd, sys;

+	int dxd, dxs, ex, dx, dxd2, dxs2;

+	short sxd, sxs;

+	byte r, g, b;

+	int sp, dp;

+	

+	xs1 = srcX; xs2 = srcX + srcWidth - 1;

+	ys1 = srcY; ys2 = srcY + srcHeight - 1;

+	if (flipX) {

+		xd1 = destX + destWidth - 1;

+		xd2 = destX;

+	} else {

+		xd1 = destX;

+		xd2 = destX + destWidth - 1;

+	}

+	if (flipY) {

+		yd1 = destY + destHeight - 1;

+		yd2 = destY;

+	} else {

+		yd1 = destY;

+		yd2 = destY + destHeight - 1;

+	}

+

+	/* Y preliminary calculations */

+	dyd = yd2 - yd1;

+	if (dyd < 0) dyd = -dyd;

+	dys = ys2 - ys1;

+	if (dys < 0) dys = -dys;

+	dyd2 = dyd << 1;

+	dys2 = dys << 1;

+	syd = (short)((yd2 - yd1) > 0 ? 1 : -1);

+	sys = (short)((ys2 - ys1) > 0 ? 1 : -1);

+	ey = dys2 - dyd;

+	ys = ys1;

+	yd = yd1;

+	/* X preliminary calculations */

+	dxd = xd2 - xd1;

+	if (dxd < 0) dxd = -dxd;

+	dxs = xs2 - xs1;

+	if (dxs < 0) dxs = -dxs;

+	dxd2 = dxd << 1;

+	dxs2 = dxs << 1;

+	sxd = (short)((xd2 - xd1) > 0 ? 3 : -3);

+	sxs = (short)((xs2 - xs1) > 0 ? 3 : -3);

+	xs1 *= 3;

+	xd1 *= 3;

+	

+	for (dy = 0; dy <= dyd; dy++) {

+		/* X stretch starts here */

+		ex = dxs2 - dxd;

+		sp = ys * srcStride + xs1;

+		dp = yd * destStride + xd1;

+		r = srcData[sp];

+		g = srcData[sp + 1];

+		b = srcData[sp + 2];

+		for (dx = 0; dx < dxd; dx++) {

+			destData[dp] = r;

+			destData[dp + 1] = g;

+			destData[dp + 2] = b;

+			if (ex >= 0) {

+				while (ex >= 0) {

+					sp += sxs;

+					ex -= dxd2;

+				}

+				r = srcData[sp];

+				g = srcData[sp + 1];

+				b = srcData[sp + 2];

+			}

+			dp += sxd;

+			ex += dxs2;

+		}

+		destData[dp] = r;

+		destData[dp + 1] = g;

+		destData[dp + 2] = b;

+		/* X stretch ends here */

+		if (dy == dyd)

+			break;

+		while (ey >= 0) {

+			ys += sys;

+			ey -= dyd2;

+		}

+		yd += syd;

+		ey += dys2;

+	}

+}

+

+/**

+ * Stretches the source, a 32-bit image, into the destination, a 32-bit image.

+ * The images must have the same red, green, and blue masks.

+ */

+static void stretch32(byte[] srcData, int srcStride, int srcX, int srcY, int srcWidth, int srcHeight, byte[] destData, int destStride, int destX, int destY, int destWidth, int destHeight, boolean flipX, boolean flipY) {

+	int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;

+	int dyd, dys, ey, dy, dyd2, dys2, ys, yd;

+	short syd, sys;

+	int dxd, dxs, ex, dx, dxd2, dxs2;

+	short sxd, sxs;

+	byte r, g, b, a;

+	int sp, dp;

+	

+	xs1 = srcX; xs2 = srcX + srcWidth - 1;

+	ys1 = srcY; ys2 = srcY + srcHeight - 1;

+	if (flipX) {

+		xd1 = destX + destWidth - 1;

+		xd2 = destX;

+	} else {

+		xd1 = destX;

+		xd2 = destX + destWidth - 1;

+	}

+	if (flipY) {

+		yd1 = destY + destHeight - 1;

+		yd2 = destY;

+	} else {

+		yd1 = destY;

+		yd2 = destY + destHeight - 1;

+	}

+

+	/* Y preliminary calculations */

+	dyd = yd2 - yd1;

+	if (dyd < 0) dyd = -dyd;

+	dys = ys2 - ys1;

+	if (dys < 0) dys = -dys;

+	dyd2 = dyd << 1;

+	dys2 = dys << 1;

+	syd = (short)((yd2 - yd1) > 0 ? 1 : -1);

+	sys = (short)((ys2 - ys1) > 0 ? 1 : -1);

+	ey = dys2 - dyd;

+	ys = ys1;

+	yd = yd1;

+	/* X preliminary calculations */

+	dxd = xd2 - xd1;

+	if (dxd < 0) dxd = -dxd;

+	dxs = xs2 - xs1;

+	if (dxs < 0) dxs = -dxs;

+	dxd2 = dxd << 1;

+	dxs2 = dxs << 1;

+	sxd = (short)((xd2 - xd1) > 0 ? 4 : -4);

+	sxs = (short)((xs2 - xs1) > 0 ? 4 : -4);

+	xs1 *= 4;

+	xd1 *= 4;

+	

+	for (dy = 0; dy <= dyd; dy++) {

+		/* X stretch starts here */

+		ex = dxs2 - dxd;

+		sp = ys * srcStride + xs1;

+		dp = yd * destStride + xd1;

+		r = srcData[sp];

+		g = srcData[sp + 1];

+		b = srcData[sp + 2];

+		a = srcData[sp + 3];

+		for (dx = 0; dx < dxd; dx++) {

+			destData[dp] = r;

+			destData[dp + 1] = g;

+			destData[dp + 2] = b;

+			destData[dp + 3] = a;

+			if (ex >= 0) {

+				while (ex >= 0) {

+					sp += sxs;

+					ex -= dxd2;

+				}

+				r = srcData[sp];

+				g = srcData[sp + 1];

+				b = srcData[sp + 2];

+				a = srcData[sp + 3];

+			}

+			dp += sxd;

+			ex += dxs2;

+		}

+		destData[dp] = r;

+		destData[dp + 1] = g;

+		destData[dp + 2] = b;

+		destData[dp + 3] = a;

+		/* X stretch ends here */

+		if (dy == dyd)

+			break;

+		while (ey >= 0) {

+			ys += sys;

+			ey -= dyd2;

+		}

+		yd += syd;

+		ey += dys2;

+	}

+}

+

+/**

+ * Stretches the source, a 4-bit image, into the destination, a 4-bit image.

+ */

+static void stretch4(byte[] srcData, int srcStride, int srcX, int srcY, int srcWidth, int srcHeight, byte[] destData, int destStride, int destX, int destY, int destWidth, int destHeight, int[] mapping, boolean flipX, boolean flipY) {

+	int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;

+	int dyd, dys, ey, dy, dyd2, dys2, yd, ys;

+	short syd, sys;

+	int dxd, dxs, ex, dx, dxd2, dxs2, xs, xd;

+	short sxd, sxs;

+	byte pixel;

+	int sp, dp;

+	

+	xs1 = srcX; xs2 = srcX + srcWidth - 1;

+	ys1 = srcY; ys2 = srcY + srcHeight - 1;

+	if (flipX) {

+		xd1 = destX + destWidth - 1;

+		xd2 = destX;

+	} else {

+		xd1 = destX;

+		xd2 = destX + destWidth - 1;

+	}

+	if (flipY) {

+		yd1 = destY + destHeight - 1;

+		yd2 = destY;

+	} else {

+		yd1 = destY;

+		yd2 = destY + destHeight - 1;

+	}

+

+	/* Y preliminary calculations */

+	dyd = yd2 - yd1;

+	if (dyd < 0) dyd = -dyd;

+	dys = ys2 - ys1;

+	if (dys < 0) dys = -dys;

+	dyd2 = dyd << 1;

+	dys2 = dys << 1;

+	syd = (short)((yd2 - yd1) > 0 ? 1 : -1);

+	sys = (short)((ys2 - ys1) > 0 ? 1 : -1);

+	ey = dys2 - dyd;

+	ys = ys1;

+	yd = yd1;

+	/* X preliminary calculations */

+	dxd = xd2 - xd1;

+	if (dxd < 0) dxd = -dxd;

+	dxs = xs2 - xs1;

+	if (dxs < 0) dxs = -dxs;

+	dxd2 = dxd << 1;

+	dxs2 = dxs << 1;

+	sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);

+	sxs = (short)((xs2 - xs1) > 0 ? 1 : -1);

+	

+	for (dy = 0; dy <= dyd; dy++) {

+		/* X stretch starts here */

+		ex = dxs2 - dxd;

+		xs = xs1;

+		xd = xd1;

+		sp = ys * srcStride;

+		dp = yd * destStride;

+		int x = srcData[sp + (xs >> 1)];

+		if ((xs & 1) != 0) {

+			pixel = (byte)((mapping == null) ? (x & 0x0F) : (mapping[x & 0x0F] & 0x0F));

+		} else {

+			pixel = (byte)((mapping == null) ? (x >> 4) : (mapping[x >> 4] & 0x0F));

+		}

+		for (dx = 0; dx < dxd; dx++) {

+			if ((xd & 1) != 0)

+				destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0xF0) | pixel);

+			else

+				destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0x0F) | (pixel << 4));

+			if (ex >= 0) {

+				do {

+					xs += sxs;

+					ex -= dxd2;

+				} while (ex >= 0);

+				x = srcData[sp + (xs >> 1)];

+				if ((xd & 1) != 0) {

+					pixel = (byte)((mapping == null) ? (x & 0x0F) : (mapping[x & 0x0F] & 0x0F));

+				} else {

+					pixel = (byte)((mapping == null) ? ((x >> 4) & 0x0F) : (mapping[x >> 4] & 0x0F));

+				}

+			}

+			xd += sxd;

+			ex += dxs2;

+		}

+		if ((xd & 1) != 0)

+			destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0xF0) | pixel);

+		else

+			destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0x0F) | (pixel << 4));

+		/* X stretch ends here */

+		if (dy == dyd)

+			break;

+		while (ey >= 0) {

+			ys += sys;

+			ey -= dyd2;

+		}

+		yd += syd;

+		ey += dys2;

+	}

+}

+

+/**

+ * Stretches the source, an 8-bit image, into the destination, an 8-bit image.

+ */

+static void stretch8(byte[] srcData, int srcStride, int srcX, int srcY, int srcWidth, int srcHeight, byte[] destData, int destStride, int destX, int destY, int destWidth, int destHeight, int[] mapping, boolean flipX, boolean flipY) {

+	int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;

+	int dyd, dys, ey, dy, dyd2, dys2, yd, ys;

+	short syd, sys;

+	int dxd, dxs, ex, dx, dxd2, dxs2, xs, xd;

+	short sxd, sxs;

+	byte pixel;

+	int sp, dp, x;

+	

+	xs1 = srcX; xs2 = srcX + srcWidth - 1;

+	ys1 = srcY; ys2 = srcY + srcHeight - 1;

+	if (flipX) {

+		xd1 = destX + destWidth - 1;

+		xd2 = destX;

+	} else {

+		xd1 = destX;

+		xd2 = destX + destWidth - 1;

+	}

+	if (flipY) {

+		yd1 = destY + destHeight - 1;

+		yd2 = destY;

+	} else {

+		yd1 = destY;

+		yd2 = destY + destHeight - 1;

+	}

+

+	/* Y preliminary calculations */

+	dyd = yd2 - yd1;

+	if (dyd < 0) dyd = -dyd;

+	dys = ys2 - ys1;

+	if (dys < 0) dys = -dys;

+	dyd2 = dyd << 1;

+	dys2 = dys << 1;

+	syd = (short)((yd2 - yd1) > 0 ? 1 : -1);

+	sys = (short)((ys2 - ys1) > 0 ? 1 : -1);

+	ey = dys2 - dyd;

+	ys = ys1;

+	yd = yd1;

+	/* X preliminary calculations */

+	dxd = xd2 - xd1;

+	if (dxd < 0) dxd = -dxd;

+	dxs = xs2 - xs1;

+	if (dxs < 0) dxs = -dxs;

+	dxd2 = dxd << 1;

+	dxs2 = dxs << 1;

+	sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);

+	sxs = (short)((xs2 - xs1) > 0 ? 1 : -1);

+	

+	for (dy = 0; dy <= dyd; dy++) {

+		/* X stretch starts here */

+		ex = dxs2 - dxd;

+		xs = xs1;

+		xd = xd1;

+		sp = ys * srcStride;

+		dp = yd * destStride;

+		x = srcData[sp + xs] & 0xFF;

+		pixel = (byte)(mapping == null ? x : mapping[x]);

+		for (dx = 0; dx < dxd; dx++) {

+			destData[dp + xd] = pixel;

+			if (ex >= 0) {

+				do {

+					xs += sxs;

+					ex -= dxd2;

+				} while (ex >= 0);

+				x = srcData[sp + xs] & 0xFF;

+				pixel = (byte)(mapping == null ? x : mapping[x]);

+			}

+			xd += sxd;

+			ex += dxs2;

+		}

+		destData[dp + xd] = pixel;

+		/* X stretch ends here */

+		if (dy == dyd)

+			break;

+		while (ey >= 0) {

+			ys += sys;

+			ey -= dyd2;

+		}

+		yd += syd;

+		ey += dys2;

+	}

+}

+

+}

+

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoader.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoader.java
index a892742..1528cf3 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoader.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoader.java
@@ -140,17 +140,10 @@
 	InputStream stream = null;

 	try {

 		stream = new FileInputStream(filename);

-		return load(stream);

 	} catch (IOException e) {

 		SWT.error(SWT.ERROR_IO, e);

-	} finally {

-		try {

-			if (stream != null) stream.close();

-		} catch (IOException e) {

-			// Ignore error

-		}

 	}

-	return null;

+	return load(stream);

 }

 

 /**

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/Callback.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/Callback.java
index ea91b4a..412fb6f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/Callback.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/Callback.java
@@ -31,12 +31,12 @@
 	/**

 	 * SWT Major version number (must be >= 0)

 	 */

-	public static int MAJOR_VERSION = 2;

+	public static int MAJOR_VERSION = 0;

 	

 	/**

 	 * SWT Minor version number (must be in the range 0..999)

 	 */

-	public static int MINOR_VERSION = 2;

+	public static int MINOR_VERSION = 125;

 	

 	/**

 	 * SWT revision number (must be >= 0)

@@ -158,18 +158,6 @@
 public static native String getPlatform ();

 

 /**

- * Returns the OS name.

- *

- * @return the os name of the currently running SWT

- */

-static String getOS () {

-	String name = System.getProperty("os.name");

-	if (name.regionMatches(true, 0, "win", 0, 3)) return "win32";

-	if (name.regionMatches(true, 0, "sun", 0, 3)) return "solaris";

-	return name.toLowerCase();

-}

-

-/**

  * Returns the SWT revision number as an integer. Revision changes

  * occur as a result of non-API breaking bug fixes.

  *

@@ -239,10 +227,7 @@
  * @param name the name of the library to load

  */

 public static void loadLibrary (String name) {

-	/* Include os name to support same window system on 

-	 * different operating systems 

-	 */

-	String newName = name + "-" + getOS () + "-" + MAJOR_VERSION;

+	String newName = name + MAJOR_VERSION;

 

 	/* Force 3 digits in minor version number */

 	if (MINOR_VERSION < 10) {

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Dialog.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Dialog.java
index 6754225..1b692b2 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Dialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Dialog.java
@@ -188,7 +188,7 @@
 /**

  * Sets the receiver's text, which is the string that the

  * window manager will typically display as the receiver's

- * <em>title</em>, to the argument, which must not be null. 

+ * <em>title</em>, to the argument, which may not be null. 

  *

  * @param text the new text

  *

@@ -201,7 +201,6 @@
  * </ul>

  */

 public void setText (String string) {

-	if (string == null) error(SWT.ERROR_NULL_ARGUMENT);

 	title = string;

 }

 

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Item.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Item.java
index f80c033..e6c7b68 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Item.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Item.java
@@ -79,9 +79,6 @@
  *

  * @param image the image to display on the receiver (may be null)

  *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the image 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>

@@ -89,7 +86,6 @@
  */

 public void setImage (Image image) {

 	checkWidget ();

-	if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 	this.image = image;

 }

 

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/version.txt b/bundles/org.eclipse.swt/Eclipse SWT/common/version.txt
index eb91d2a..1c3227e 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.002
\ No newline at end of file
+version 0.125
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/build.csh b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/build.csh
index fef01d3..5a14d0d 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/build.csh
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/build.csh
Binary files differ
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/kde.cc b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/kde.cc
index 6c7e251..79cb99f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/kde.cc
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/kde.cc
@@ -11,13 +11,11 @@
 #define NDEBUG 
 
 #include <stdio.h>
-#include <signal.h>
 #include "jni.h"
 
 #include <kapp.h>
 #include <kservice.h>
 #include <kmimetype.h>
-#include <krun.h>
 #include <kuserprofile.h>
 #include <kurl.h>
 #include <qstring.h>
@@ -32,37 +30,13 @@
 JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KApplication_1new
   (JNIEnv *env, jclass that, int appName)
 {
-	int myArgc = 1;
-	char* myArgv[2] = { "SWT", 0 };  // KApplication requires a NULL terminated list
+	int myArgc = 0;
+	char* myArgv[1];
 #ifdef DEBUG_CALL_PRINTS
 	fprintf(stderr, "KApplication_1new\n");
 #endif
 	QCString qcString = *((QCString*) appName);
-	
-	// NOTE: When a KDE application is initialized, it installs its own
-	// SIGSEGV signal handler so that it can pop up a dialogue box and
-	// display an error message should SIGSEGV occur. After the dialogue
-	// box is closed, it terminates the program. The Hursley Java VM (on Linux)
-	// happens to catch SIGSEGV signals so that it can throw a null pointer
-	// exception. Thus when KDE is initialized, the Java try ... catch 
-	// mechanism for null pointers does not work. Eclipse code relies upon
-	// this try ... catch feature.
-	//
-	// The solution is to obtain the Java VM's signal handler before initializing
-	// KDE and to reinstall that handler after the initialization. The method
-	// sigaction() must be used instead of signal() because it returns more
-	// information on how to handle the signal.
-	
-	// Obtain the current signal handling logic for SIGSEGV.
-	struct sigaction prev;
-	sigaction( SIGSEGV, NULL, &prev );
-	
-	// Initialize KDE, which installs its own signal handler.
 	KApplication* app = new KApplication(myArgc, myArgv, qcString);
-	
-	// Replace the Java VM signal handler.
-	sigaction( SIGSEGV, &prev, NULL );
-	
 	return (jint) app;
 }
 
@@ -86,12 +60,12 @@
  * Signature: (IIII)I
  */
 JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KIconLoader_1iconPath
-  (JNIEnv *env, jclass that, jint kloader, jint iconQString, jint iconType, jint canReturnNull)
+  (JNIEnv *env, jclass that, jint receiver, jint iconQString, jint iconType, jint canReturnNull)
 {
 #ifdef DEBUG_CALL_PRINTS
 	fprintf(stderr, "KIconLoader_1iconPath\n");
 #endif
-	KIconLoader* loader = (KIconLoader*) kloader;
+	KIconLoader* loader = (KIconLoader*) receiver;
 	QString iconName = *((QString*) iconQString);
 	QString iconPath = loader->iconPath(iconName, iconType, canReturnNull);
 	if (iconPath == 0) return 0;
@@ -102,18 +76,18 @@
 
 /*
  * Class:     org_eclipse_swt_internal_motif_KDE
- * Method:    KMimeType_1mimeType
+ * Method:    KMimeType_1findByURL
  * Signature: (I)I
  */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeType_1mimeType
-  (JNIEnv *env, jclass that, jint mimeTypeName)
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeType_1findByURL
+  (JNIEnv *env, jclass that, jint kurl)
 {
 #ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "KMimeType_1mimeType\n");
+	fprintf(stderr, "KMimeType_1findByURL\n");
 #endif
+	KURL url = *((KURL*) kurl);
   	KSharedPtr<KMimeType>* mimeType = new KSharedPtr<KMimeType>();
-  	QString qMimeType = *((QString*) mimeTypeName);
-  	*mimeType = KMimeType::mimeType( qMimeType );
+  	*mimeType = KMimeType::findByURL(url);
   	return (jint) mimeType;
 }
 
@@ -123,12 +97,12 @@
  * Signature: (III)I
  */
 JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeType_1icon
-  (JNIEnv *env, jclass that, jint mimeTypePtr, jint unused1, jint unused2)
+  (JNIEnv *env, jclass that, jint receiver, jint unused1, jint unused2)
 {
 #ifdef DEBUG_CALL_PRINTS
 	fprintf(stderr, "KMimeType_1icon\n");
 #endif
-	KSharedPtr<KMimeType> mimeType = *((KSharedPtr<KMimeType>*) mimeTypePtr);
+	KSharedPtr<KMimeType> mimeType = *((KSharedPtr<KMimeType>*) receiver);
 	QString* answer = new QString();
 	*answer = mimeType->icon((const QString&) NULL, 0);
 	return (jint) answer;
@@ -140,294 +114,137 @@
  * Signature: (I)I
  */
 JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeType_1name
-  (JNIEnv *env, jclass that, jint mimeTypePtr)
+  (JNIEnv *env, jclass that, jint receiver)
 {
 #ifdef DEBUG_CALL_PRINTS
 	fprintf(stderr, "KMimeType_1name\n");
 #endif
-	KSharedPtr<KMimeType> mimeType = *((KSharedPtr<KMimeType>*) mimeTypePtr);
-	QString* name = new QString();
-	*name = mimeType->name(); 
-	return (jint) name;
+	KSharedPtr<KMimeType> mimeType = *((KSharedPtr<KMimeType>*) receiver);
+	QString* answer = new QString();
+	*answer = mimeType->name(); 
+	return (jint) answer;
 }
 
 /*
  * Class:     org_eclipse_swt_internal_motif_KDE
- * Method:    KMimeType_1patterns
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeType_1patterns
-  (JNIEnv *env, jclass that, jint mimeTypePtr)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "KMimeType_1patterns\n");
-#endif
-	KSharedPtr<KMimeType> mimeType = *((KSharedPtr<KMimeType>*) mimeTypePtr);
-	QStringList* patternList = new QStringList();
-	*patternList = mimeType->patterns(); 
-	return (jint) patternList;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_KDE
- * Method:    KMimeType_1offers
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeType_1offers
-  (JNIEnv *env, jclass that, jint mimeTypeName)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "KMimeType_1offers\n");
-#endif
-	QString qMimeType = *((QString*) mimeTypeName);
-	KService::List* serviceList = new KService::List();
-	*serviceList = KMimeType::offers( qMimeType ); 
-	return (jint) serviceList;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_KDE
- * Method:    KMimeType_1allMimeTypes
+ * Method:    KService_1allServices
  * Signature: ()I
  */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeType_1allMimeTypes
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KService_1allServices
   (JNIEnv *env, jclass that)
 {
 #ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "KMimeType_1allMimeTypes\n");
+	fprintf(stderr, "KService_1allServices\n");
 #endif
- 	KMimeType::List* mimeTypeList = new KMimeType::List();
-	*mimeTypeList = KMimeType::allMimeTypes();
-  	return (jint) mimeTypeList;
+	KService::List* pointer = new KService::List();
+	*pointer = KService::allServices();
+	return (jint) pointer;
 }
 
 /*
  * Class:     org_eclipse_swt_internal_motif_KDE
- * Method:    KMimeTypeList_1begin
+ * Method:    KService_1exec
  * Signature: (I)I
  */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeTypeList_1begin
-  (JNIEnv *env, jclass that, jint mimeTypeList)
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KService_1exec
+  (JNIEnv *env, jclass that, jint receiver)
 {
 #ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "KMimeTypeList_1begin\n");
+	fprintf(stderr, "KService_1exec\n");
 #endif
-	KMimeType::List *list= (KMimeType::List*) mimeTypeList;
-	QValueListIterator<KMimeType::Ptr>* iterator = new QValueListIterator<KMimeType::Ptr>();
-  	*iterator = list->begin();
-	return (jint) iterator;
+	KSharedPtr<KService> service = *((KSharedPtr<KService>*) receiver);
+	QString* answer = new QString();
+	*answer = service->exec();
+	return (jint) answer;
 }
 
 /*
  * Class:     org_eclipse_swt_internal_motif_KDE
- * Method:    KMimeTypeList_1delete
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeTypeList_1delete
-  (JNIEnv *env, jclass that, jint mimeTypeList)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "KMimeTypeList_1delete\n");
-#endif
-	delete (KMimeType::List*) mimeTypeList;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_KDE
- * Method:    KMimeTypeList_1end
+ * Method:    KService_1icon
  * Signature: (I)I
  */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeTypeList_1end
-  (JNIEnv *env, jclass that, jint mimeTypeList)
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KService_1icon
+  (JNIEnv *env, jclass that, jint receiver)
 {
 #ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "KMimeTypeList_1end\n");
+	fprintf(stderr, "KService_1icon\n");
 #endif
-	KMimeType::List *list = (KMimeType::List*) mimeTypeList;
-	QValueListIterator<KMimeType::Ptr>* iterator = new QValueListIterator<KMimeType::Ptr>();
-  	*iterator = list->end();
-	return (jint) iterator;
+	KSharedPtr<KService> service = *((KSharedPtr<KService>*) receiver);
+	QString* answer = new QString();
+	*answer = service->icon();
+	return (jint) answer;
 }
 
 /*
  * Class:     org_eclipse_swt_internal_motif_KDE
- * Method:    KMimeTypeListIterator_1delete
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeTypeListIterator_1delete
-  (JNIEnv *env, jclass that, jint iterator)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "KMimeTypeListIterator_1delete\n");
-#endif
-	delete (QValueListIterator<KMimeType::Ptr>*) iterator;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_KDE
- * Method:    KMimeTypeListIterator_1dereference
+ * Method:    KService_1name
  * Signature: (I)I
  */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeTypeListIterator_1dereference
-  (JNIEnv *env, jclass that, jint iterator)
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KService_1name
+  (JNIEnv *env, jclass that, jint receiver)
 {
 #ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "KMimeTypeListIterator_1dereference\n");
+	fprintf(stderr, "KService_1name\n");
 #endif
-	KSharedPtr<KMimeType>* mimeType = new KSharedPtr<KMimeType>();
-	*mimeType = *(*((QValueListIterator<KMimeType::Ptr>*) iterator));
-	return (jint) mimeType;
+	KSharedPtr<KService> service = *((KSharedPtr<KService>*) receiver);
+	QString* answer = new QString();
+	*answer = service->name();
+	return (jint) answer;
 }
 
 /*
  * Class:     org_eclipse_swt_internal_motif_KDE
- * Method:    KMimeTypeListIterator_1equals
+ * Method:    KService_1serviceByName
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KService_1serviceByName
+  (JNIEnv *env, jclass that, jint serviceName)
+{
+#ifdef DEBUG_CALL_PRINTS
+	fprintf(stderr, "KService_1serviceByName\n");
+#endif
+	QString* name = (QString*) serviceName;
+	KSharedPtr<KService> service = KService::serviceByName(*name);
+	if (service == 0) return 0;
+	KSharedPtr<KService>* pointer = new KSharedPtr<KService>();
+	*pointer = service;
+	return (jint) pointer;
+}
+
+/*
+ * Class:     org_eclipse_swt_internal_motif_KDE
+ * Method:    KService_1type
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KService_1type
+  (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+	fprintf(stderr, "KService_1type\n");
+#endif
+	KSharedPtr<KService> service = *((KSharedPtr<KService>*) receiver);
+	QString* answer = new QString();
+	*answer = service->type();
+	return (jint) answer;
+}
+
+/*
+ * Class:     org_eclipse_swt_internal_motif_KDE
+ * Method:    KServiceTypeProfile_1preferredService
  * Signature: (II)I
  */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeTypeListIterator_1equals
-  (JNIEnv *env, jclass that, jint iterator, jint iterator2)
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceTypeProfile_1preferredService
+  (JNIEnv *env, jclass that, jint mimeTypeQString, jint needApp)
 {
 #ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "KMimeTypeListIterator_1equals\n");
+	fprintf(stderr, "KServiceTypeProfile_1preferredService\n");
 #endif
-	return *((QValueListIterator<KMimeType::Ptr>*) iterator) == 
-		   *((QValueListIterator<KMimeType::Ptr>*) iterator2);
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_KDE
- * Method:    KMimeTypeListIterator_1increment
- * Signature: (I)I
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeTypeListIterator_1increment
-  (JNIEnv *env, jclass that, jint iterator)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "KMimeTypeListIterator_1increment\n");
-#endif
-	++(*((QValueListIterator<KMimeType::Ptr>*) iterator));
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_KDE
- * Method:    QStringList_1begin
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QStringList_1begin
-  (JNIEnv *env, jclass that, jint qstringList)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "QStringList_1begin\n");
-#endif
-	QStringList *list= (QStringList*) qstringList;
-	QValueListIterator<QString>* iterator = new QValueListIterator<QString>();
-  	*iterator = list->begin();
-	return (jint) iterator;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_KDE
- * Method:    QStringList_1delete
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_QStringList_1delete
-  (JNIEnv *env, jclass that, jint qstringList)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "QStringList_1delete\n");
-#endif
-	delete (QStringList*) qstringList;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_KDE
- * Method:    QStringList_1end
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QStringList_1end
-  (JNIEnv *env, jclass that, jint qstringList)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "QStringList_1end\n");
-#endif
-	QStringList *list = (QStringList*) qstringList;
-	QValueListIterator<QString>* iterator = new QValueListIterator<QString>();
-  	*iterator = list->end();
-	return (jint) iterator;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_KDE
- * Method:    QStringListIterator_1delete
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_QStringListIterator_1delete
-  (JNIEnv *env, jclass that, jint iterator)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "QStringListIterator_1delete\n");
-#endif
-	delete (QValueListIterator<QString>*) iterator;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_KDE
- * Method:    QStringListIterator_1dereference
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QStringListIterator_1dereference
-  (JNIEnv *env, jclass that, jint iterator)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "QStringListIterator_1dereference\n");
-#endif
-	QString* qstring = new QString();
-	*qstring = *(*((QValueListIterator<QString>*) iterator));
-	return (jint) qstring;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_KDE
- * Method:    QStringListIterator_1equals
- * Signature: (II)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QStringListIterator_1equals
-  (JNIEnv *env, jclass that, jint iterator, jint iterator2)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "QStringListIterator_1equals\n");
-#endif
-	return *((QValueListIterator<QString>*) iterator) == 
-		   *((QValueListIterator<QString>*) iterator2);
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_KDE
- * Method:    QStringListIterator_1increment
- * Signature: (I)I
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_QStringListIterator_1increment
-  (JNIEnv *env, jclass that, jint iterator)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "QStringListIterator_1increment\n");
-#endif
-	++(*((QValueListIterator<QString>*) iterator));
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_KDE
- * Method:    KURL_1new
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KURL_1new
-  (JNIEnv *env, jclass that, jint qURLString)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "KURL_1new\n");
-#endif
-	QString urlString = *((QString*) qURLString);
-	return (jint) new KURL(urlString);
+	QString mimeTypeName = *((QString*) mimeTypeQString);
+	KSharedPtr<KService> service = KServiceTypeProfile::preferredService(mimeTypeName, needApp);
+	if (service == 0) return 0;
+	KSharedPtr<KService>* pointer = new KSharedPtr<KService>();
+	*pointer = service;
+	return (jint) pointer;
 }
 
 /*
@@ -436,28 +253,44 @@
  * Signature: (I)V
  */
 JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_KURL_1delete
-  (JNIEnv *env, jclass that, jint url)
+  (JNIEnv *env, jclass that, jint receiver)
 {
 #ifdef DEBUG_CALL_PRINTS
 	fprintf(stderr, "KURL_1delete\n");
 #endif
-	delete (KURL*) url;
+	delete (KURL*) receiver;
 }
 
 /*
  * Class:     org_eclipse_swt_internal_motif_KDE
- * Method:    KRun_1runURL
- * Signature: (II)I
+ * Method:    KURL_1new
+ * Signature: (I)I
  */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KRun_1runURL
-  (JNIEnv *env, jclass that, jint kurl, jint mimeTypeName)
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KURL_1new
+  (JNIEnv *env, jclass that, jint qString)
 {
 #ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "KRun_1runURL\n");
+	fprintf(stderr, "KURL_1new\n");
 #endif
-	KURL url = *((KURL*) kurl);
-  	QString qMimeType = *((QString*) mimeTypeName);
-	return (jint) KRun::runURL( url, qMimeType );
+	QString urlString = *((QString*) qString);
+	return (jint) new KURL(urlString);
+}
+
+/*
+ * Class:     org_eclipse_swt_internal_motif_KDE
+ * Method:    KServiceList_1begin
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceList_1begin
+  (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+	fprintf(stderr, "KServiceList_1begin\n");
+#endif
+	KService::List *list= (KService::List*) receiver;
+	QValueListConstIterator<KService::Ptr>* beginning = new QValueListConstIterator<KService::Ptr>();
+  	*beginning = list->begin();
+	return (jint) beginning;
 }
 
 /*
@@ -466,12 +299,29 @@
  * Signature: (I)V
  */
 JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceList_1delete
-  (JNIEnv *env, jclass that, jint serviceList)
+  (JNIEnv *env, jclass that, jint receiver)
 {
 #ifdef DEBUG_CALL_PRINTS
 	fprintf(stderr, "KServiceList_1delete\n");
 #endif
-	delete (KService::List*) serviceList;
+	delete (KService::List*) receiver;
+}
+
+/*
+ * Class:     org_eclipse_swt_internal_motif_KDE
+ * Method:    KServiceList_1end
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceList_1end
+  (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+	fprintf(stderr, "KServiceList_1end\n");
+#endif
+	KService::List *list = (KService::List*) receiver;
+	QValueListConstIterator<KService::Ptr>* end = new QValueListConstIterator<KService::Ptr>();
+  	*end = list->end();
+	return (jint) end;
 }
 
 /*
@@ -480,12 +330,12 @@
  * Signature: (I)I
  */
 JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QCString_1data
-  (JNIEnv *env, jclass that, jint qcString)
+  (JNIEnv *env, jclass that, jint receiver)
 {
 #ifdef DEBUG_CALL_PRINTS
 	fprintf(stderr, "QCString_1data\n");
 #endif
-	return (jint) ((QCString*) qcString)->data();
+	return (jint) ((QCString*) receiver)->data();
 }
 
 /*
@@ -494,12 +344,12 @@
  * Signature: (I)V
  */
 JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_QCString_1delete
-  (JNIEnv *env, jclass that, jint qcString)
+  (JNIEnv *env, jclass that, jint receiver)
 {
 #ifdef DEBUG_CALL_PRINTS
 	fprintf(stderr, "QCString_1delete\n");
 #endif
-	delete (QCString*) qcString;
+	delete (QCString*) receiver;
 }
 
 /*
@@ -526,12 +376,12 @@
  * Signature: (I)V
  */
 JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_QString_1delete
-  (JNIEnv *env, jclass that, jint qString)
+  (JNIEnv *env, jclass that, jint receiver)
 {
 #ifdef DEBUG_CALL_PRINTS
 	fprintf(stderr, "QString_1delete\n");
 #endif
-	delete (QString*) qString;
+	delete (QString*) receiver;
 }
 
 /*
@@ -540,12 +390,12 @@
  * Signature: (I[B)I
  */
 JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QString_1equals
-  (JNIEnv *env, jclass that, jint qString, jint qString2)
+  (JNIEnv *env, jclass that, jint receiver, jint object)
 {
 #ifdef DEBUG_CALL_PRINTS
 	fprintf(stderr, "QString_1equals\n");
 #endif
-	return *((QString*) qString) == *((QString*) qString2);
+	return *((QString*) receiver) == *((QString*) object);
 }
 
 /*
@@ -572,16 +422,93 @@
  * Signature: (I)I
  */
 JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QString_1utf8
-  (JNIEnv *env, jclass that, jint qString)
+  (JNIEnv *env, jclass that, jint receiver)
 {
 #ifdef DEBUG_CALL_PRINTS
 	fprintf(stderr, "QString_1utf8\n");
 #endif
-	QString string = *((QString*) qString);
+	QString string = *((QString*) receiver);
 	QCString* qcString = new QCString();
 	*qcString = string.utf8();
 	return (jint) qcString;
 }
 
 
+/*
+ * Class:     org_eclipse_swt_internal_motif_KDE
+ * Method:    KServiceListIterator_1delete
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceListIterator_1delete
+  (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+	fprintf(stderr, "KServiceListIterator_1delete\n");
+#endif
+	delete (QValueListIterator<KService::Ptr>*) receiver;
+}
+
+/*
+ * Class:     org_eclipse_swt_internal_motif_KDE
+ * Method:    KServiceListIterator_1dereference
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceListIterator_1dereference
+  (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+	fprintf(stderr, "KServiceListIterator_1dereference\n");
+#endif
+	KSharedPtr<KService>* service = new KSharedPtr<KService>();
+	*service = *(*((QValueListIterator<KService::Ptr>*) receiver));
+	return (jint) service;
+}
+
+/*
+ * Class:     org_eclipse_swt_internal_motif_KDE
+ * Method:    KServiceListIterator_1increment
+ * Signature: (I)I
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceListIterator_1increment
+  (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+	fprintf(stderr, "KServiceListIterator_1increment\n");
+#endif
+	++(*((QValueListIterator<KService::Ptr>*) receiver));
+}
+
+/*
+ * Class:     org_eclipse_swt_internal_motif_KDE
+ * Method:    KServiceListIterator_1new
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceListIterator_1new
+  (JNIEnv *env, jclass that, jint listBeginning)
+{
+#ifdef DEBUG_CALL_PRINTS
+	fprintf(stderr, "KServiceListIterator_1new\n");
+#endif
+	const QValueListIterator<KService::Ptr> *iterator =
+		(const QValueListIterator<KService::Ptr> *) listBeginning;
+
+	return (jint) new QValueListIterator<KService::Ptr>(*iterator);
+}
+
+/*
+ * Class:     org_eclipse_swt_internal_motif_KDE
+ * Method:    KServiceListIterator_1equals
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceListIterator_1equals
+  (JNIEnv *env, jclass that, jint receiver, jint object)
+{
+#ifdef DEBUG_CALL_PRINTS
+	fprintf(stderr, "KServiceListIterator_1equals\n");
+#endif
+	return *((QValueListIterator<KService::Ptr>*) receiver) == 
+		*((QValueListIterator<KService::Ptr>*) object);
+}
+
+
 } /* extern "C" */
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/make_linux.mak b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/make_linux.mak
index f326f3b..def0e62 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/make_linux.mak
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/make_linux.mak
@@ -18,29 +18,28 @@
 #    QT_HOME    - identifier namespace package (used by KDE)
 IVE_HOME   = /bluebird/teamswt/swt-builddir/ive/bin
 MOTIF_HOME = /bluebird/teamswt/swt-builddir/motif21
-QT_HOME    = /usr/lib/qt-2.2.4
+QT_HOME    = /usr/lib/qt-2.2.0
 
 
 # Define the various DLL (shared) libraries to be made.
 
 SWT_PREFIX   = swt
-OS_PREFIX    = linux
-SWT_DLL      = lib$(SWT_PREFIX)-$(OS_PREFIX)-$(DLL_VERSION).so
+SWT_DLL      = lib$(SWT_PREFIX)$(DLL_VERSION).so
 SWT_OBJ      = callback.o globals.o library.o structs.o swt.o
 SWT_LIB      = -L$(MOTIF_HOME)/lib -lXm -L/usr/lib -L/usr/X11R6/lib \
-	           -rpath . -x -shared -lX11 -lm -lXext -lXt -lXp -ldl
+	       -x -shared -lX11 -lm -lXext -lXt -lXp -lXpm -ldl
 
 GNOME_PREFIX = swt-gnome
-GNOME_DLL    = lib$(GNOME_PREFIX)-$(OS_PREFIX)-$(DLL_VERSION).so
+GNOME_DLL    = lib$(GNOME_PREFIX)$(DLL_VERSION).so
 GNOME_OBJ    = gnome.o 
 GNOME_LIB    = -x -shared \
-	           `gnome-config --libs gnome`
+	       `gnome-config --libs gnome`
 
 KDE_PREFIX   = swt-kde
-KDE_DLL      = lib$(KDE_PREFIX)-$(OS_PREFIX)-$(DLL_VERSION).so
+KDE_DLL      = lib$(KDE_PREFIX)$(DLL_VERSION).so
 KDE_OBJ      = kde.o
 KDE_LIB      = -L/usr/lib  -L$(QT_HOME)/lib \
-	           -shared -lksycoca -lkdecore -lqt
+	       -shared -lksycoca -lkdecore -lq
 
 #
 # The following CFLAGS are for compiling both the SWT library and the GNOME
@@ -49,7 +48,7 @@
 CFLAGS = -O -s \
 	-DSWT_LIBRARY_MAJOR_VERSION=$(MAJOR_VER) \
 	-DSWT_LIBRARY_MINOR_VERSION=$(MINOR_VER) \
-	-DLINUX -DMOTIF -DGNOME \
+	-DLINUX -DMOTIF -DGNOME -DXPM \
 	-fpic \
 	-I./ \
 	-I$(IVE_HOME)/include \
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/swt.c b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/swt.c
index feab065..99d9712 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/swt.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/swt.c
@@ -15,9 +15,6 @@
 
 #include <stdio.h>
 #include <assert.h>
-#include <langinfo.h>
-#include <iconv.h>
-#include <stdlib.h>
 
 JNIEXPORT int JNICALL Java_org_eclipse_swt_internal_motif_OS_getSharedLibraryMajorVersionNumber
   (JNIEnv *env, jclass that)
@@ -1866,35 +1863,6 @@
 
 /*
  * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    XInternAtom
- * Signature: (I[BZ)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XInternAtom
-  (JNIEnv *env, jclass that, jint display, jbyteArray name, jboolean ifExists)
-{
-    jbyte *name1 = NULL;
-    jint rc;
-
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "XInternAtom\n");
-#endif
-    if (name)    
-        name1 = (*env)->GetByteArrayElements(env, name, NULL);
-    
-    rc = (jint) XInternAtom((Display *)display, (char *)name1, ifExists);
-
-#ifdef PRINT_FAILED_RCODES
-    if (rc == 0)
-        fprintf(stderr, "XInternAtom: call failed rc = %d\n", rc);
-#endif
-
-    if (name)
-        (*env)->ReleaseByteArrayElements(env, name, name1, 0);
-    return rc;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
  * Method:    XKeysymToString
  * Signature: (I)I
  */
@@ -1943,35 +1911,6 @@
 
 /*
  * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    XListProperties
- * Signature: (II[I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XListProperties
-  (JNIEnv *env, jclass that, jint display, jint window, jintArray num_prop_return)
-{
-    jint *num_prop_return1=NULL;
-    jint  rc;
-
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "XListProperties\n");
-#endif
-    if (num_prop_return)    
-        num_prop_return1 = (*env)->GetIntArrayElements(env, num_prop_return, NULL);
-    
-    rc = (jint) XListProperties((Display *)display, (Window)window, (int *)num_prop_return1);
-
-#ifdef PRINT_FAILED_RCODES
-    if (rc == 0)
-        fprintf(stderr, "XListProperties: call failed rc = %d\n", rc);
-#endif
-
-    if (num_prop_return)
-        (*env)->ReleaseIntArrayElements(env, num_prop_return, num_prop_return1, 0);
-    return rc;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
  * Method:    XLookupString
  * Signature: (Lorg/eclipse/swt/internal/motif/XKeyEvent;[BI[I[I)I
  */
@@ -2000,7 +1939,7 @@
     if (status)
         status1 = (*env)->GetIntArrayElements(env, status, NULL);    
     rc  = (jint) XLookupString((XKeyEvent *)lpxEvent, (char *)string1, size, (KeySym *)keysym1, (XComposeStatus *)status1);
-	
+
 #ifdef PRINT_FAILED_RCODES
     if (rc < 0)
         fprintf(stderr, "XLookupString: call failed rc = %d\n", rc);
@@ -4123,27 +4062,6 @@
 
 /*
  * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    XmGetPixmap
- * Signature: (I[BII)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmGetPixmap
-  (JNIEnv *env, jclass that, jint screen, jbyteArray name, jint fgPixel, jint bgPixel)
-{
-    jbyte* name1 = NULL;
- 	jint   pixmap;
- 	
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "XmGetPixmap\n");
-#endif
-
-    if (name) name1 = (*env)->GetByteArrayElements(env, name, NULL); 
-    pixmap = (jint) XmGetPixmap((Screen*)screen, (char*)name1, (Pixel)fgPixel, (Pixel)bgPixel);
-    if (name) (*env)->ReleaseByteArrayElements(env, name, name1, 0);
-    return pixmap;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
  * Method:    XmGetXmDisplay
  * Signature: (I)I
  */
@@ -5318,9 +5236,8 @@
  * Method:    XmbLookupString
  * Signature: (ILorg/eclipse/swt/internal/motif/XInputEvent;[BI[I[I)I
  */
-/*
 JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmbLookupString
-  (JNIEnv *env, jclass that, jint ic, jobject event, jbyteArray string, jint size, jintArray keysym, jintArray status)
+  (JNIEnv *env, jclass that, jint widget, jobject event, jbyteArray string, jint size, jintArray keysym, jintArray status)
 {
 	DECL_GLOB(pGlob)
 	XEvent xEvent, *lpxEvent=NULL;
@@ -5343,11 +5260,11 @@
     if (status)
         status1 = (*env)->GetIntArrayElements(env, status, NULL);
 
-    rc = (jint)XmbLookupString((XIC)ic, (XKeyPressedEvent *)lpxEvent, (char *)string1, size, (KeySym *)keysym1, (int *)status1);
+    rc = (jint)XmImMbLookupString((Widget)widget, (XKeyPressedEvent *)lpxEvent, (char *)string1, size, (KeySym *)keysym1, (int *)status1);
 
 #ifdef PRINT_FAILED_RCODES
     if (rc == 0)
-        fprintf(stderr, "XmbLookupString: call failed rc = %d\n", rc);
+        fprintf(stderr, "XmImMbLookupString: call failed rc = %d\n", rc);
 #endif
 
     if (event) {
@@ -5361,7 +5278,6 @@
         (*env)->ReleaseIntArrayElements(env, status, status1, 0);
 	return rc;
 }
-*/
 
 /*
  * Class:     org_eclipse_swt_internal_motif_OS
@@ -6598,6 +6514,43 @@
 
 /*
  * Class:     org_eclipse_swt_internal_motif_OS
+ * Method:    XpmReadFileToPixmap
+ * Signature: (II[B[I[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XpmReadFileToPixmap
+  (JNIEnv *env, jclass that, jint display, jint drawable, jbyteArray fileName, jintArray pixmap_return, jintArray shapemask_return, jint attributes)
+{
+#ifdef XPM
+	jint rc;
+	jbyte *fileName1 = NULL;
+	jint *pixmap_return1 = NULL;
+	jint *shapemask_return1 = NULL;
+#ifdef DEBUG_CALL_PRINTS
+	fprintf(stderr, "XpmReadFileToPixmap\n");
+#endif
+	if (fileName) fileName1 = (*env)->GetByteArrayElements(env, fileName, NULL);
+	if (pixmap_return) pixmap_return1 = (*env)->GetIntArrayElements(env, pixmap_return, NULL);
+	if (shapemask_return) shapemask_return1 = (*env)->GetIntArrayElements(env, shapemask_return, NULL);
+	
+	rc = (jint) XpmReadFileToPixmap((Display *)display, 
+		drawable, 
+		fileName1, 
+		(Pixmap*) pixmap_return1, 
+		(Pixmap*) shapemask_return1, 
+		attributes);
+	
+  	if (fileName) (*env)->ReleaseByteArrayElements(env, fileName, fileName1, 0);
+	if (pixmap_return) (*env)->ReleaseIntArrayElements(env, pixmap_return, pixmap_return1, 0);
+	if (shapemask_return) (*env)->ReleaseIntArrayElements(env, shapemask_return, shapemask_return1, 0);
+  	return rc;
+#endif
+#ifndef XPM
+	return -1;
+#endif
+}
+
+/*
+ * Class:     org_eclipse_swt_internal_motif_OS
  * Method:    XmCreateDrawnButton
  * Signature: (I[B[II)I
  */
@@ -7035,7 +6988,7 @@
  * Method:    XmDestroyPixmap
  * Signature: (II)Z
  */
-JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmDestroyPixmap
+/* JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmDestroyPixmap
   (JNIEnv *env, jclass that, jint screen, jint pixmap)
 {
 #ifdef DEBUG_CALL_PRINTS
@@ -7043,13 +6996,14 @@
 #endif
 	return (jboolean) XmDestroyPixmap((Screen *)screen, pixmap);
 }
+*/
 
 /*
  * Class:     org_eclipse_swt_internal_motif_OS
  * Method:    XmGetPixmapByDepth
  * Signature: (I[BIII)I
  */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmGetPixmapByDepth
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmGetPixmapByDepth
   (JNIEnv *env, jclass that, jint screen, jbyteArray image_name, jint foreground, jint background, jint depth)
 {
     jbyte *image_name1=NULL;
@@ -7072,7 +7026,7 @@
         (*env)->ReleaseByteArrayElements(env, image_name, image_name1, 0);
 	return rc;
 }
-
+*/
 
 /*
  * Class:     org_eclipse_swt_internal_motif_OS
@@ -7641,8 +7595,6 @@
  * ======== Start printing functions ========
  */
  
-#ifndef NO_XPRINTING_EXTENSIONS
-
 /*
  * Class:     org_eclipse_swt_internal_motif_OS
  * Method:    XpCreateContext
@@ -7909,35 +7861,6 @@
 
 /*
  * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    XpQueryVersion
- * Signature: (I[S[S)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XpQueryVersion
-  (JNIEnv *env, jclass that, jint display, jshortArray major_version, jshortArray minor_version)
-{
-    jshort *major_version1=NULL, *minor_version1=NULL;
-    jint rc;
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "XpQueryVersion\n");
-#endif
-
-    if (major_version)
-    	major_version1 = (*env)->GetShortArrayElements(env, major_version, NULL);
-    if (minor_version)
-    	minor_version1 = (*env)->GetShortArrayElements(env, minor_version, NULL);    
-    rc = (jint) XpQueryVersion((Display *)display, (short *)major_version1, (short *)minor_version1);
-    if (major_version)
-    	(*env)->ReleaseShortArrayElements(env, major_version, major_version1, 0);
-    if (minor_version)
-    	(*env)->ReleaseShortArrayElements(env, minor_version, minor_version1, 0);
-
-    return rc;
-}
-
-#endif /* ! NO_XPRINTING_EXTENSIONS */
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
  * Method:    XDefaultGCOfScreen
  * Signature: (I)I
  */
@@ -8023,6 +7946,33 @@
 }
 
 /*
+ * Class:     org_eclipse_swt_internal_motif_OS
+ * Method:    XpQueryVersion
+ * Signature: (I[S[S)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XpQueryVersion
+  (JNIEnv *env, jclass that, jint display, jshortArray major_version, jshortArray minor_version)
+{
+    jshort *major_version1=NULL, *minor_version1=NULL;
+    jint rc;
+#ifdef DEBUG_CALL_PRINTS
+	fprintf(stderr, "XpQueryVersion\n");
+#endif
+
+    if (major_version)
+    	major_version1 = (*env)->GetShortArrayElements(env, major_version, NULL);
+    if (minor_version)
+    	minor_version1 = (*env)->GetShortArrayElements(env, minor_version, NULL);    
+    rc = (jint) XpQueryVersion((Display *)display, (short *)major_version1, (short *)minor_version1);
+    if (major_version)
+    	(*env)->ReleaseShortArrayElements(env, major_version, major_version1, 0);
+    if (minor_version)
+    	(*env)->ReleaseShortArrayElements(env, minor_version, minor_version1, 0);
+
+    return rc;
+}
+
+/*
  * ======== End printing functions ========
  */
  
@@ -8065,7 +8015,7 @@
 
     if (buf) 
         buf1 = (*env)->GetByteArrayElements(env, buf, NULL);
-    rc = (jint) read(filedes, (char *)buf1, nbyte);
+    rc = (jint) read(filedes, (char *)buf, nbyte);
     if (buf)
     	(*env)->ReleaseByteArrayElements(env, buf, buf1, 0);
 
@@ -8088,7 +8038,7 @@
 
     if (buf) 
         buf1 = (*env)->GetByteArrayElements(env, buf, NULL);
-    rc = (jint) write(filedes, (char *)buf1, nbyte);
+    rc = (jint) write(filedes, (char *)buf, nbyte);
     if (buf)
     	(*env)->ReleaseByteArrayElements(env, buf, buf1, 0);
 
@@ -8139,484 +8089,3 @@
 
     XtRemoveInput((XtInputId)id);
 }
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    XmImGetXIC
- * Signature: (II[II)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmImGetXIC
-  (JNIEnv *env, jclass that, jint widget, jint input_policy, jintArray args, jint num_args)
-{
-    jint *args1=NULL;
-    jint rc;
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "XmImGetXIC\n");
-#endif
-    if (args) 
-        args1 = (*env)->GetIntArrayElements(env, args, NULL);
-   rc = (jint)  XmImGetXIC((Widget)widget, (XmInputPolicy)input_policy, (ArgList)args1, num_args);
-    if (args)
-    	(*env)->ReleaseIntArrayElements(env, args, args1, 0);
-    	
-    return rc;   
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    XmImGetXIM
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmImGetXIM
-  (JNIEnv *env, jclass that, jint widget)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "XmImGetXIM\n");
-#endif
-
-    return (jint) XmImGetXIM((Widget)widget);
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    XmImRegister
- * Signature: (II)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmImRegister
-  (JNIEnv *env, jclass that, jint widget, jint reserved)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "XmImRegister\n");
-#endif
-
-    XmImRegister((Widget)widget, reserved);
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    XmImSetFocusValues
- * Signature: (I[II)V
- */
-/*
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmImSetFocusValues
-  (JNIEnv *env, jclass that, jint widget, jintArray args, jint num_args)
-{
-    jint *args1=NULL;
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "XmImSetFocusValues\n");
-#endif
-    if (args) 
-        args1 = (*env)->GetIntArrayElements(env, args, NULL);
-	XmImSetFocusValues((Widget)widget, (ArgList)args1, num_args);
-    if (args)
-    	(*env)->ReleaseIntArrayElements(env, args, args1, 0);
-}
-*/
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    XmImVaSetFocusValues
- * Signature: (IIIIIIIIII)I
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmImVaSetFocusValues
-  (JNIEnv *env, jclass that, jint widget, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "XmImVaSetFocusValues\n");
-#endif
-	XmImVaSetFocusValues((Widget)widget, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    XmImSetValues
- * Signature: (I[II)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmImSetValues
-  (JNIEnv *env, jclass that, jint widget, jintArray args, jint num_args)
-{
-    jint *args1=NULL;
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "XmImSetValues\n");
-#endif
-    if (args) 
-        args1 = (*env)->GetIntArrayElements(env, args, NULL);
-	XmImSetValues((Widget)widget, (ArgList)args1, num_args);
-    if (args)
-    	(*env)->ReleaseIntArrayElements(env, args, args1, 0);
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    XmImUnregister
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmImUnregister
-  (JNIEnv *env, jclass that, jint widget)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "XmImUnregister\n");
-#endif
-
-    XmImUnregister((Widget)widget);
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    XmImUnsetFocus
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmImUnsetFocus
-  (JNIEnv *env, jclass that, jint widget)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "XmImUnsetFocus\n");
-#endif
-
-    XmImUnsetFocus((Widget)widget);
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    XCreateIC
- * Signature: (IIIIIIII)I
- */
-/*
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XCreateIC
-  (JNIEnv *env, jclass that, jint im, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "XCreateIC\n");
-#endif
-
-    return (jint)XCreateIC((XIM)im, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
-}
-*/
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    XSetICValues
- * Signature: (IIII)I
- */
-/*
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetICValues
-  (JNIEnv *env, jclass that, jint ic, jint arg1, jint arg2, jint arg3)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "XSetICValues\n");
-#endif
-
-    return (jint)XSetICValues((XIC)ic, arg1, arg2, arg3);
-}
-*/
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    XGetICValues
- * Signature: (IIII)I
- */
-/*
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XGetICValues
-  (JNIEnv *env, jclass that, jint ic, jint arg1, jint arg2, jint arg3)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "XGetICValues\n");
-#endif
-
-    return (jint)XGetICValues((XIC)ic, arg1, arg2, arg3);
-}
-*/
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    XSetICFocus
- * Signature: (I)V
- */
-/*
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetICFocus
-  (JNIEnv *env, jclass that, jint ic)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "XSetICFocus\n");
-#endif
-
-    XSetICFocus((XIC)ic);
-}
-*/
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    XUnsetICFocus
- * Signature: (I)V
- */
-/*
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XUnsetICFocus
-  (JNIEnv *env, jclass that, jint ic)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "XUnsetICFocus\n");
-#endif
-
-    XUnsetICFocus((XIC)ic);
-}
-*/
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    XGetIMValues
- * Signature: (IIII)I
- */
-/*
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XGetIMValues
-  (JNIEnv *env, jclass that, jint im, jint arg1, jint arg2, jint arg3)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "XGetIMValues\n");
-#endif
-
-    return (jint)XGetIMValues((XIM)im, arg1, arg2, arg3);
-}
-*/
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    memmove
- * Signature: (I[SI)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__I_3SI
-  (JNIEnv *env, jclass that, jint dest, jshortArray src, jint count)
-{
-    jshort *src1;
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "memmove__I_3SI\n");
-#endif
-
-    /* don't do anything if src pointer is NULL */
-    if (src) {
-        src1 = (*env)->GetShortArrayElements(env, src, NULL);
-        memmove((void *)dest, (void *)src1, count);
-        (*env)->ReleaseShortArrayElements(env, src, src1, 0);
-    }
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    nl_langinfo
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_nl_1langinfo
-  (JNIEnv *env, jclass that, jint item)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "nl_langinfo\n");
-#endif
-
-    return (jint)nl_langinfo(item);
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    iconv_open
- * Signature: ([B[B)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_iconv_1open
-  (JNIEnv *env, jclass that, jbyteArray tocode, jbyteArray fromcode)
-{
-    jbyte *tocode1=NULL, *fromcode1=NULL;
-    jint result;
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "iconv_open\n");
-#endif
-    if (tocode) 
-        tocode1 = (*env)->GetByteArrayElements(env, tocode, NULL);
-    if (fromcode) 
-        fromcode1 = (*env)->GetByteArrayElements(env, fromcode, NULL);
-	result = (jint)iconv_open(tocode1, fromcode1);
-    if (tocode)
-    	(*env)->ReleaseByteArrayElements(env, tocode, tocode1, 0);
-    if (fromcode)
-    	(*env)->ReleaseByteArrayElements(env, fromcode, fromcode1, 0);
-    	
-    return result;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    iconv_close
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_iconv_1close
-  (JNIEnv *env, jclass that, jint cd)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "iconv_close\n");
-#endif
-
-    return (jint)iconv_close((iconv_t)cd);
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    iconv
- * Signature: (I[BI[BI)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_iconv
-  (JNIEnv *env, jclass that, jint cd, jintArray inBuf, jintArray inBytesLeft, jintArray outBuf, jintArray outBytesLeft)
-{
-    jint *inBuf1=NULL, *outBuf1=NULL, *inBytesLeft1=NULL, *outBytesLeft1=NULL;
-    jint result;
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "iconv\n");
-#endif
-    if (inBuf)
-        inBuf1 = (*env)->GetIntArrayElements(env, inBuf, NULL);
-    if (outBuf) 
-        outBuf1 = (*env)->GetIntArrayElements(env, outBuf, NULL);
-    if (inBytesLeft) 
-        inBytesLeft1 = (*env)->GetIntArrayElements(env, inBytesLeft, NULL);
-    if (outBytesLeft) 
-        outBytesLeft1 = (*env)->GetIntArrayElements(env, outBytesLeft, NULL);
-    result = (jint)iconv((iconv_t)cd, (void *)inBuf1, (size_t *)inBytesLeft1, (char **)outBuf1, (size_t *)outBytesLeft1);
-    if (inBuf)
-    	(*env)->ReleaseIntArrayElements(env, inBuf, inBuf1, 0);
-    if (outBuf)
-    	(*env)->ReleaseIntArrayElements(env, outBuf, outBuf1, 0);
-    if (inBytesLeft)
-    	(*env)->ReleaseIntArrayElements(env, inBytesLeft, inBytesLeft1, 0);
-    if (outBytesLeft)
-    	(*env)->ReleaseIntArrayElements(env, outBytesLeft, outBytesLeft1, 0);
-    return result;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    MB_1CUR_1MAX
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_MB_1CUR_1MAX
-  (JNIEnv *env, jclass that)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "MB_1CUR_1MAX\n");
-#endif
-
-    return (jint)MB_CUR_MAX;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    memmove
- * Signature: ([CII)V
- */
-/*
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove___3CII
-  (JNIEnv *env, jclass that, jcharArray dest, jint src, jint count)
-{
-    jchar *dest1;
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "memmove___3CII\n");
-#endif
-
-    if (dest) {
-        dest1 = (*env)->GetCharArrayElements(env, dest, NULL);
-        memmove((void *)dest1, (void *)src, count);
-        (*env)->ReleaseCharArrayElements(env, dest, dest1, 0);
-    }
-}
-*/
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    memmove
- * Signature: (I[CI)V
- */
-/*
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__I_3CI
-  (JNIEnv *env, jclass that, jint dest, jcharArray src, jint count)
-{
-    jchar *src1;
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "memmove__I_3CI\n");
-#endif
-
-    if (src) {
-    	int i;
-    	unsigned char *dest1 = (unsigned char *)dest;
-        src1 = (*env)->GetCharArrayElements(env, src, NULL);
-        memmove((void *)dest, (void *)src1, count);
-        (*env)->ReleaseCharArrayElements(env, src, src1, 0);
-    }
-}
-*/
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    XCreateFontSet
- * Signature: (I[B[I[I[I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XCreateFontSet
-  (JNIEnv *env, jclass that, jint display, jbyteArray base_font_name_list, jintArray missing_charset_list_return, jintArray missing_charset_count_return, jintArray def_string_return)
-{
-	jbyte *base_font_name_list1=NULL;
-    jint *missing_charset_list_return1=NULL, *missing_charset_count_return1=NULL, *def_string_return1=NULL;
-    jint result;
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "XCreateFontSet\n");
-#endif
-    if (base_font_name_list)
-        base_font_name_list1 = (*env)->GetByteArrayElements(env, base_font_name_list, NULL);
-    if (missing_charset_list_return) 
-       missing_charset_list_return1 = (*env)->GetIntArrayElements(env, missing_charset_list_return, NULL);
-    if (missing_charset_count_return) 
-        missing_charset_count_return1 = (*env)->GetIntArrayElements(env, missing_charset_count_return, NULL);
-    if (def_string_return) 
-       def_string_return1 = (*env)->GetIntArrayElements(env, def_string_return, NULL);
-    result = (jint)XCreateFontSet((Display *)display, (char *)base_font_name_list1, (char ***)missing_charset_list_return1, (int *)missing_charset_count_return1, (char **)def_string_return1);
-    if (base_font_name_list)
-    	(*env)->ReleaseByteArrayElements(env, base_font_name_list, base_font_name_list1, 0);
-    if (missing_charset_list_return)
-    	(*env)->ReleaseIntArrayElements(env, missing_charset_list_return, missing_charset_list_return1, 0);
-    if (missing_charset_count_return)
-    	(*env)->ReleaseIntArrayElements(env, missing_charset_count_return, missing_charset_count_return1, 0);
-    if (def_string_return)
-    	(*env)->ReleaseIntArrayElements(env, def_string_return, def_string_return1, 0);
-    return result;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    XLocaleOfFontSet
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XLocaleOfFontSet
-  (JNIEnv *env, jclass that, jint fontSet)
-{
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "XLocaleOfFontSet\n");
-#endif
-
-    return (jint)XLocaleOfFontSet((XFontSet)fontSet);
-}
-
-/*
- * Class:     org_eclipse_swt_internal_motif_OS
- * Method:    setlocale
- * Signature: (I[B)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_setlocale
-  (JNIEnv *env, jclass that, int category, jbyteArray locale)
-{
-    jbyte *locale1=NULL;
-    jint rc;
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "setlocale\n");
-#endif
-
-    if (locale) 
-        locale1 = (*env)->GetByteArrayElements(env, locale, NULL);
-    rc = (jint) setlocale(category, (char *)locale1);
-    if (locale)
-    	(*env)->ReleaseByteArrayElements(env, locale, locale1, 0);
-
-    return rc;
-}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Device.java
index 5dc1701..07ff9ce 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Device.java
@@ -306,7 +306,6 @@
 			xlfd = "-" + faceName + "-*-*-*-*-*-*-*-*-*-*-*-*";

 		}

 	}

-	/* Use the character encoding for the default locale */

 	byte [] buffer1 = Converter.wcsToMbcs (null, xlfd, true);

 	int [] ret = new int [1];

 	int listPtr = OS.XListFonts (xDisplay, buffer1, 65535, ret);

@@ -320,7 +319,6 @@
 		int length = OS.strlen (charPtr);

 		byte [] buffer2 = new byte [length];

 		OS.memmove (buffer2, charPtr, length);

-		/* Use the character encoding for the default locale */

 		char [] chars = Converter.mbcsToWcs (null, buffer2);

 		FontData data = FontData.motif_new (new String (chars));

 		boolean isScalable = data.averageWidth == 0 && data.pixels == 0 && data.points == 0;

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Font.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Font.java
index 838b61b..3345d70 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Font.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Font.java
@@ -8,7 +8,6 @@
 import org.eclipse.swt.internal.*;

 import org.eclipse.swt.internal.motif.*;

 import org.eclipse.swt.*;

-import java.util.Locale;

 

 /**
  * Instances of this class manage operating system resources that
@@ -175,7 +174,6 @@
 					int length = OS.strlen(ptr);

 					byte[] nameBuf = new byte[length];

 					OS.memmove(nameBuf, ptr, length);

-					/* Use the character encoding for the default locale */

 					String xlfd = new String(Converter.mbcsToWcs(null, nameBuf)).toLowerCase();

 					/* Add the xlfd to the array */

 					String[] newXlfds = new String[xlfds.length + 1];

@@ -253,35 +251,26 @@
 	return handle;

 }

 int loadFont(int xDisplay, FontData fd) {

-	/* Use the character encoding for the default locale */

 	byte[] buffer = Converter.wcsToMbcs(null, fd.getXlfd(), true);

 	return OS.XLoadQueryFont(xDisplay, buffer);

 }

-int loadFontSet(int xDisplay, FontData fd) {

-	/* Use the character encoding for the default locale */

-	byte[] buffer = Converter.wcsToMbcs(null, fd.getXlfd(), true);

-	int [] missing_charset = new int [1];

-	int [] missing_charset_count = new int [1];

-	int [] def_string = new int [1];

-	return OS.XCreateFontSet(xDisplay, buffer, missing_charset, missing_charset_count, def_string);

-}

-int matchFont(int xDisplay, FontData fd, boolean fontSet) {	

-	int font = fontSet ? loadFontSet(xDisplay, fd) : loadFont(xDisplay, fd);

-	if (font != 0) return font;

+int matchFont(int xDisplay, FontData fd) {	

+	int fontStruct = loadFont(xDisplay, fd);

+	if (fontStruct != 0) return fontStruct;

 	if (fd.slant != null) {

 		fd.slant = null;

-		font = fontSet ? loadFontSet(xDisplay, fd) : loadFont(xDisplay, fd);

-		if (font != 0) return font;

+		fontStruct = loadFont(xDisplay, fd);

+		if (fontStruct != 0) return fontStruct;

 	}

 	if (fd.weight != null) {

 		fd.weight = null;

-		font = fontSet ? loadFontSet(xDisplay, fd) : loadFont(xDisplay, fd);

-		if (font != 0) return font;

+		fontStruct = loadFont(xDisplay, fd);

+		if (fontStruct != 0) return fontStruct;

 	}

 	if (fd.points != 0) {

 		fd.points = 0;

-		font = fontSet ? loadFontSet(xDisplay, fd) : loadFont(xDisplay, fd);

-		if (font != 0) return font;

+		fontStruct = loadFont(xDisplay, fd);

+		if (fontStruct != 0) return fontStruct;

 	}

 	return 0;

 }

@@ -290,53 +279,8 @@
 	if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

 	this.device = device;

 	int xDisplay = device.xDisplay;

-	int fontListEntry;

-//	int fontStruct = loadFont(xDisplay, fd);

-//	if (fontStruct == 0) {

-//		/*

-//		* If the desired font can not be loaded, the XLFD fields are wildcard

-//		* in order to preserve the font style and height. If there is no

-//		* font with the desired style and height, the slant, weight and points

-//		* are wildcard in that order, until a font can be loaded.

-//		*/

-//		FontData newFD = new FontData();

-//		newFD.slant = fd.slant;

-//		newFD.weight = fd.weight;

-//		newFD.points = fd.points;

-//		newFD.characterSetName = fd.characterSetName;

-//		if (newFD.characterSetName == null) {

-//			newFD.characterSetName = device.characterSetName;

-//		}

-//		newFD.characterSetRegistry = fd.characterSetRegistry;

-//		if (newFD.characterSetRegistry == null) {

-//			newFD.characterSetRegistry = device.characterSetRegistry;

-//		}

-//		fontStruct = matchFont(xDisplay, newFD, false);

-//

-//		/* Failed to load any font. Use the system font. */

-//		if (fontStruct == 0) {

-//			handle = device.systemFont;

-//			if (handle != 0) return;

-//		}

-//	}

-//	fontListEntry = OS.XmFontListEntryCreate(OS.XmFONTLIST_DEFAULT_TAG, OS.XmFONT_IS_FONT, fontStruct);

-	Locale locale = fd.locale;

-	if (locale != null) {

-		String lang = locale.getLanguage();

-		String country = locale.getCountry();

-		String variant = locale.getVariant();

-		String osLocale =  lang;

-		if (country != null && country.length() > 0) osLocale += "_" + country;

-		if (variant != null && variant.length() > 0) osLocale += "." + variant;

-		int length = osLocale.length();

-		byte [] buffer = new byte[length + 1];

-		for (int i=0; i<length; i++) {

-			buffer[i] = (byte)osLocale.charAt(i);

-		}

-		OS.setlocale (OS.LC_CTYPE, buffer);

-	}		

-	int fontSet = loadFontSet(xDisplay, fd);

-	if (fontSet == 0) {

+	int fontStruct = loadFont(xDisplay, fd);

+	if (fontStruct == 0) {

 		/*

 		* If the desired font can not be loaded, the XLFD fields are wildcard

 		* in order to preserve the font style and height. If there is no

@@ -355,16 +299,16 @@
 		if (newFD.characterSetRegistry == null) {

 			newFD.characterSetRegistry = device.characterSetRegistry;

 		}

-		fontSet = matchFont(xDisplay, newFD, true);

+		fontStruct = matchFont(xDisplay, newFD);

+

+		/* Failed to load any font. Use the system font. */

+		if (fontStruct == 0) {

+			handle = device.systemFont;

+			if (handle != 0) return;

+		}

 	}

-	if (locale != null) OS.setlocale (OS.LC_CTYPE, new byte [0]);

-	

-	/* Failed to load any font. Use the system font. */

-	if (fontSet == 0) {

-		handle = device.systemFont;

-		if (handle != 0) return;

-	}

-	fontListEntry = OS.XmFontListEntryCreate(OS.XmFONTLIST_DEFAULT_TAG, OS.XmFONT_IS_FONTSET, fontSet);

+	if (fontStruct == 0) SWT.error(SWT.ERROR_NO_HANDLES);

+	int fontListEntry = OS.XmFontListEntryCreate(OS.XmFONTLIST_DEFAULT_TAG, OS.XmFONT_IS_FONT, fontStruct);

 	if (fontListEntry == 0) SWT.error(SWT.ERROR_NO_HANDLES);

 	handle = OS.XmFontListAppendEntry(0, fontListEntry);

 	OS.XmFontListEntryFree(new int[]{fontListEntry});

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontData.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontData.java
index 977b0e0..ac4958a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontData.java
@@ -6,7 +6,6 @@
  */

 

 import org.eclipse.swt.*;

-import java.util.Locale;

  

 /**
  * Instances of this class describe operating system fonts.
@@ -104,12 +103,6 @@
 	 * Warning: This field is platform dependent.

 	 */

 	public String characterSetName;

-

-	/**

-	 * The locale of the font

-	 * (Warning: This field is platform dependent)

-	 */

-	Locale locale;

 /**	 
  * Constructs a new un-initialized font data.
  */
@@ -388,15 +381,6 @@
 		fontFamily = name;

 	}

 }

-/**

- * Sets the locale of the receiver.

- *

- * @param locale the Locale of the <code>FontData</code>

- *

- */

-public void setLocale(Locale locale) {

-	this.locale = locale;

-}

 /**
  * Sets the style of the receiver to the argument which must
  * be a bitwise OR of one or more of the <code>SWT</code> 
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java
index a6af8a5..36f1186 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java
@@ -413,14 +413,12 @@
 				blues[i] = (byte)((color.blue >> 8) & 0xFF);

 			}

 			ImageData.blit(ImageData.BLIT_ALPHA,

-				srcData, xSrcImage.bits_per_pixel, xSrcImage.bytes_per_line, srcOrder, 0, 0, srcWidth, srcHeight, reds, greens, blues,

-				srcImage.alpha, srcImage.alphaData, imgWidth,

+				srcData, xSrcImage.bits_per_pixel, xSrcImage.bytes_per_line, srcOrder, 0, 0, srcWidth, srcHeight, reds, greens, blues, srcImage.alpha, srcImage.alphaData, imgWidth,

 				destData, xDestImage.bits_per_pixel, xDestImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, reds, greens, blues,

 				false, false);

 		} else {

 			ImageData.blit(ImageData.BLIT_ALPHA,

-				srcData, xSrcImage.bits_per_pixel, xSrcImage.bytes_per_line, srcOrder, 0, 0, srcWidth, srcHeight, xDestImage.red_mask, xDestImage.green_mask, xDestImage.blue_mask,

-				srcImage.alpha, srcImage.alphaData, imgWidth,

+				srcData, xSrcImage.bits_per_pixel, xSrcImage.bytes_per_line, srcOrder, 0, 0, srcWidth, srcHeight, xDestImage.red_mask, xDestImage.green_mask, xDestImage.blue_mask, srcImage.alpha, srcImage.alphaData, imgWidth,

 				destData, xDestImage.bits_per_pixel, xDestImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, xDestImage.red_mask, xDestImage.green_mask, xDestImage.blue_mask,

 				false, false);

 		}

@@ -518,11 +516,7 @@
 			int bplX = ((destWidth + 7) / 8 + 3) & 0xFFFC;

 			int bufSize = bplX * destHeight;

 			byte[] buf = new byte[bufSize];

-			ImageData.blit(ImageData.BLIT_SRC,

-				srcData, 1, xSrcImage.bytes_per_line, bitOrder, 0, 0, srcWidth, srcHeight, null, null, null,

-				ImageData.ALPHA_OPAQUE, null, 0,

-				buf, 1, bplX, bitOrder, 0, 0, destWidth, destHeight, null, null, null,

-				flipX, flipY);

+			ImageData.stretch1(srcData, xSrcImage.bytes_per_line, bitOrder, 0, 0, srcWidth, srcHeight, buf, bplX, bitOrder, 0, 0, destWidth, destHeight, flipX, flipY);

 			int bufPtr = OS.XtMalloc(bufSize);

 			OS.memmove(bufPtr, buf, bufSize);

 			xImagePtr = OS.XCreateImage(display, visual, 1, OS.XYBitmap, 0, bufPtr, destWidth, destHeight, 32, bplX);

@@ -540,11 +534,7 @@
 			int bplX = (destWidth + 3) & 0xFFFC;

 			int bufSize = bplX * destHeight;

 			byte[] buf = new byte[bufSize];

-			ImageData.blit(ImageData.BLIT_SRC,

-				srcData, 4, xSrcImage.bytes_per_line, ImageData.MSB_FIRST, 0, 0, srcWidth, srcHeight, null, null, null,

-				ImageData.ALPHA_OPAQUE, null, 0,

-				buf, 4, bplX, ImageData.MSB_FIRST, 0, 0, destWidth, destHeight, null, null, null,

-				flipX, flipY);

+			ImageData.stretch4(srcData, xSrcImage.bytes_per_line, 0, 0, srcWidth, srcHeight, buf, bplX, 0, 0, destWidth, destHeight, null, flipX, flipY);

 			int bufPtr = OS.XtMalloc(bufSize);

 			OS.memmove(bufPtr, buf, bufSize);

 			xImagePtr = OS.XCreateImage(display, visual, 4, OS.ZPixmap, 0, bufPtr, destWidth, destHeight, 32, bplX);

@@ -554,11 +544,7 @@
 			int bplX = (destWidth + 3) & 0xFFFC;

 			int bufSize = bplX * destHeight;

 			byte[] buf = new byte[bufSize];

-			ImageData.blit(ImageData.BLIT_SRC,

-				srcData, 8, xSrcImage.bytes_per_line, ImageData.MSB_FIRST, 0, 0, srcWidth, srcHeight, null, null, null,

-				ImageData.ALPHA_OPAQUE, null, 0,

-				buf, 8, bplX, ImageData.MSB_FIRST, 0, 0, destWidth, destHeight, null, null, null,

-				flipX, flipY);

+			ImageData.stretch8(srcData, xSrcImage.bytes_per_line, 0, 0, srcWidth, srcHeight, buf, bplX, 0, 0, destWidth, destHeight, null, flipX, flipY);

 			int bufPtr = OS.XtMalloc(bufSize);

 			OS.memmove(bufPtr, buf, bufSize);

 			xImagePtr = OS.XCreateImage(display, visual, 8, OS.ZPixmap, 0, bufPtr, destWidth, destHeight, 32, bplX);

@@ -571,11 +557,7 @@
 			OS.memmove(xImage, xImagePtr, XImage.sizeof);

 			int bufSize = xImage.bytes_per_line * destHeight;

 			byte[] buf = new byte[bufSize];

-			ImageData.blit(ImageData.BLIT_SRC,

-				srcData, 16, xSrcImage.bytes_per_line, ImageData.MSB_FIRST, 0, 0, srcWidth, srcHeight, 0, 0, 0,

-				ImageData.ALPHA_OPAQUE, null, 0,

-				buf, 16, xImage.bytes_per_line, ImageData.MSB_FIRST, 0, 0, destWidth, destHeight, 0, 0, 0,

-				flipX, flipY);

+			ImageData.stretch16(srcData, xSrcImage.bytes_per_line, 0, 0, srcWidth, srcHeight, buf, xImage.bytes_per_line, 0, 0, destWidth, destHeight, flipX, flipY);

 			int bufPtr = OS.XtMalloc(bufSize);

 			OS.memmove(bufPtr, buf, bufSize);

 			xImage.data = bufPtr;

@@ -589,11 +571,7 @@
 			OS.memmove(xImage, xImagePtr, XImage.sizeof);

 			int bufSize = xImage.bytes_per_line * destHeight;

 			byte[] buf = new byte[bufSize];

-			ImageData.blit(ImageData.BLIT_SRC,

-				srcData, 24, xSrcImage.bytes_per_line, ImageData.MSB_FIRST, 0, 0, srcWidth, srcHeight, 0, 0, 0,

-				ImageData.ALPHA_OPAQUE, null, 0,

-				buf, 24, xImage.bytes_per_line, ImageData.MSB_FIRST, 0, 0, destWidth, destHeight, 0, 0, 0,

-				flipX, flipY);

+			ImageData.stretch24(srcData, xSrcImage.bytes_per_line, 0, 0, srcWidth, srcHeight, buf, xImage.bytes_per_line, 0, 0, destWidth, destHeight, flipX, flipY);

 			int bufPtr = OS.XtMalloc(bufSize);

 			OS.memmove(bufPtr, buf, bufSize);

 			xImage.data = bufPtr;

@@ -607,11 +585,7 @@
 			OS.memmove(xImage, xImagePtr, XImage.sizeof);

 			int bufSize = xImage.bytes_per_line * destHeight;

 			byte[] buf = new byte[bufSize];

-			ImageData.blit(ImageData.BLIT_SRC,

-				srcData, 32, xSrcImage.bytes_per_line, ImageData.MSB_FIRST, 0, 0, srcWidth, srcHeight, 0, 0, 0,

-				ImageData.ALPHA_OPAQUE, null, 0,

-				buf, 32, xImage.bytes_per_line, ImageData.MSB_FIRST, 0, 0, destWidth, destHeight, 0, 0, 0,

-				flipX, flipY);

+			ImageData.stretch32(srcData, xSrcImage.bytes_per_line, 0, 0, srcWidth, srcHeight, buf, xImage.bytes_per_line, 0, 0, destWidth, destHeight, flipX, flipY);

 			int bufPtr = OS.XtMalloc(bufSize);

 			OS.memmove(bufPtr, buf, bufSize);

 			xImage.data = bufPtr;

@@ -849,7 +823,7 @@
 	}

 	if (nh < 0) {

 		nh = 0 - nh;

-		ny = ny - nh;

+		ny = ny -nh;

 	}

 	if (naw < 0) 

 		naw = 0 - naw;

@@ -861,33 +835,14 @@
 

 	int xDisplay = data.display;

 	int xDrawable = data.drawable;

-	

-	if (nw > naw) {

-		if (nh > nah) {

-			OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny, naw, nah, 5760, 5760);

-			OS.XDrawLine(xDisplay, xDrawable, handle, nx + naw2, ny, nx + nw - naw2, ny);

-			OS.XDrawArc(xDisplay, xDrawable, handle, nx + nw - naw, ny, naw, nah, 0, 5760);

-			OS.XDrawLine(xDisplay, xDrawable, handle, nx + nw, ny + nah2, nx + nw, ny + nh - nah2);

-			OS.XDrawArc(xDisplay, xDrawable, handle, nx + nw - naw, ny + nh - nah, naw, nah, 17280, 5760);

-			OS.XDrawLine(xDisplay,xDrawable,handle, nx + naw2, ny + nh, nx + nw - naw2, ny + nh);

-			OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny + nh - nah, naw, nah, 11520, 5760);

-			OS.XDrawLine(xDisplay, xDrawable, handle, nx, ny + nah2, nx, ny + nh - nah2);

-		} else {

-			OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny, naw, nh, 5760, 11520);

-			OS.XDrawLine(xDisplay, xDrawable, handle, nx + naw2, ny, nx + nw - naw2, ny);

-			OS.XDrawArc(xDisplay, xDrawable, handle, nx + nw - naw, ny, naw, nh, 17280, 11520);

-			OS.XDrawLine(xDisplay,xDrawable,handle, nx + naw2, ny + nh, nx + nw - naw2, ny + nh);

-		}

-	} else {

-		if (nh > nah) {

-			OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny, nw, nah, 0, 11520);

-			OS.XDrawLine(xDisplay, xDrawable, handle, nx + nw, ny + nah2, nx + nw, ny + nh - nah2);

-			OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny + nh - nah, nw, nah, 11520, 11520);

-			OS.XDrawLine(xDisplay,xDrawable,handle, nx, ny + nah2, nx, ny + nh - nah2);

-		} else {

-			OS.XDrawArc(xDisplay, xDrawable, handle, nx, ny, nw, nh, 0, 23040);

-		}

-	}

+	OS.XDrawArc(xDisplay,xDrawable,handle,nx,ny,naw,nah,5760,5760);

+	OS.XDrawArc(xDisplay,xDrawable,handle,nx,ny + nh - nah,naw,nah,11520,5760);

+	OS.XDrawArc(xDisplay,xDrawable,handle,nx + nw - naw, ny + nh - nah, naw, nah,17280,5760);

+	OS.XDrawArc(xDisplay,xDrawable,handle,nx + nw - naw, ny, naw, nah, 0, 5760);

+	OS.XDrawLine(xDisplay,xDrawable,handle,nx + naw2, ny, nx + nw - naw2, ny);

+	OS.XDrawLine(xDisplay,xDrawable,handle,nx,ny + nah2, nx, ny + nh - nah2);

+	OS.XDrawLine(xDisplay,xDrawable,handle,nx + naw2, ny + nh, nx + nw - naw2, ny + nh);

+	OS.XDrawLine(xDisplay,xDrawable,handle,nx + nw, ny + nah2, nx + nw, ny + nh - nah2);

 }

 /** 
  * Draws the given string, using the receiver's current font and
@@ -933,7 +888,7 @@
 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);

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (null, string, true);

 	int xmString = OS.XmStringCreate (buffer, OS.XmFONTLIST_DEFAULT_TAG);

 	if (isTransparent) {

 		OS.XmStringDraw (data.display, data.drawable, data.fontList, xmString, handle, x, y, 0x7FFFFFFF, OS.XmALIGNMENT_BEGINNING, 0, null);

@@ -1041,7 +996,7 @@
 	if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

 	if (data.renderTable == 0) createRenderTable();

 	int renderTable = data.renderTable;

-	byte [] textBuffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] textBuffer = Converter.wcsToMbcs (null, string, true);

 	int xmString = OS.XmStringGenerate(textBuffer, null, OS.XmCHARSET_TEXT, _MOTIF_DEFAULT_LOCALE);

 	if (isTransparent) {

 		OS.XmStringDraw (data.display, data.drawable, renderTable, xmString, handle, x, y, 0x7FFFFFFF, OS.XmALIGNMENT_BEGINNING, 0, null);

@@ -1121,105 +1076,6 @@
 	OS.XFillArc(xDisplay,data.drawable,handle,x,y,width,height,startAngle * 64 ,endAngle * 64);

 	OS.XSetForeground (xDisplay, handle, values.foreground);

 }

-

-/**

- * Fills the interior of the specified rectangle with a gradient

- * sweeping from left to right or top to bottom progressing

- * from the receiver's foreground color to its background color.

- *

- * @param x the x coordinate of the rectangle to be filled

- * @param y the y coordinate of the rectangle to be filled

- * @param width the width of the rectangle to be filled, may be negative

- *        (inverts direction of gradient if horizontal)

- * @param height the height of the rectangle to be filled, may be negative

- *        (inverts direction of gradient if vertical)

- * @param vertical if true sweeps from top to bottom, else 

- *        sweeps from left to right

- *

- * @exception SWTException <ul>

- *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>

- * </ul>

- *

- * @see #drawRectangle

- */

-public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {

-	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

-	if ((width == 0) || (height == 0)) return;

-	int xDisplay = data.display;

-	int xScreenNum = OS.XDefaultScreen(xDisplay);

-	XGCValues values = new XGCValues();

-	int fromColor, toColor;

-	OS.XGetGCValues(xDisplay, handle, OS.GCForeground | OS.GCBackground, values);

-	fromColor = values.foreground;

-	toColor = values.background;

-	boolean swapColors = false;

-	if (width < 0) {

-		x += width; width = -width;

-		if (! vertical) swapColors = true;

-	}

-	if (height < 0) {

-		y += height; height = -height;

-		if (vertical) swapColors = true;

-	}

-	if (swapColors) {

-		final int t = fromColor;

-		fromColor = toColor;

-		toColor = t;

-	}

-	if (fromColor == toColor) {

-		OS.XFillRectangle(xDisplay, data.drawable, handle, x, y, width, height);

-		return;

-	}

-	/* X Window deals with a virtually limitless array of color formats

-	 * but we only distinguish between paletted and direct modes

-	 */	

-	final int xScreen = OS.XDefaultScreenOfDisplay(xDisplay);

-	final int xVisual = OS.XDefaultVisual(xDisplay, xScreenNum);

-	Visual visual = new Visual();

-	OS.memmove(visual, xVisual, visual.sizeof);

-	final int depth = OS.XDefaultDepthOfScreen(xScreen);

-	final boolean directColor = (depth > 8);

-

-	// This code is intentionally commented since elsewhere in SWT we

-	// assume that depth <= 8 means we are in a paletted mode though

-	// this is not always the case.

-	//final boolean directColor = (visual.c_class == OS.TrueColor) || (visual.c_class == OS.DirectColor);

-

-	XColor xColor = new XColor();

-	xColor.pixel = fromColor;

-	OS.XQueryColor(xDisplay, data.colormap, xColor);

-	final RGB fromRGB = new RGB((xColor.red & 0xffff) >>> 8, (xColor.green & 0xffff) >>> 8, (xColor.blue & 0xffff) >>> 8);

-	xColor.pixel = toColor;

-	OS.XQueryColor(xDisplay, data.colormap, xColor);

-	final RGB toRGB = new RGB((xColor.red & 0xffff) >>> 8, (xColor.green & 0xffff) >>> 8, (xColor.blue & 0xffff) >>> 8);

-

-	final int redBits, greenBits, blueBits;

-	if (directColor) {

-		// RGB mapped display

-		redBits = getChannelWidth(visual.red_mask);

-		greenBits = getChannelWidth(visual.green_mask);

-		blueBits = getChannelWidth(visual.blue_mask);

-	} else {

-		// Index display

-		redBits = greenBits = blueBits = 0;

-	}

-	ImageData.fillGradientRectangle(this, data.device,

-		x, y, width, height, vertical, fromRGB, toRGB,

-		redBits, greenBits, blueBits);

-}

-

-/**

- * Computes the required channel width (depth) from a mask.

- */

-static int getChannelWidth(int mask) {

-	int width = 0;

-	while (mask != 0) {

-		width += (mask & 1);

-		mask >>>= 1;

-	}

-	return width;

-}

-

 /** 
  * Fills the interior of an oval, within the specified
  * rectangular area, with the receiver's background
@@ -1283,7 +1139,7 @@
 	XGCValues values = new XGCValues ();

 	OS.XGetGCValues (xDisplay, handle, OS.GCForeground | OS.GCBackground, values);

 	OS.XSetForeground (xDisplay, handle, values.background);

-	OS.XFillPolygon(xDisplay, data.drawable, handle,xPoints, xPoints.length / 2, OS.Complex, OS.CoordModeOrigin);

+	OS.XFillPolygon(xDisplay, data.drawable, handle,xPoints, xPoints.length / 2, OS.Convex, OS.CoordModeOrigin);

 	OS.XSetForeground (xDisplay, handle, values.foreground);

 }

 /** 
@@ -1376,6 +1232,9 @@
 	if (nah < 0)

 		nah = 0 - nah;

 

+	naw = naw < nw ? naw : nw;

+	nah = nah < nh ? nah : nh;

+		

 	int naw2 = naw / 2;

 	int nah2 = nah / 2;

 

@@ -1384,30 +1243,13 @@
 	XGCValues values = new XGCValues ();

 	OS.XGetGCValues(xDisplay, handle, OS.GCForeground | OS.GCBackground, values);

 	OS.XSetForeground(xDisplay, handle, values.background);

-

-	if (nw > naw) {

-		if (nh > nah) {

-			OS.XFillArc(xDisplay, xDrawable, handle, nx, ny, naw, nah, 5760, 5760);

-			OS.XFillRectangle(xDisplay, xDrawable, handle, nx + naw2, ny, nw - naw, nah2);

-			OS.XFillArc(xDisplay, xDrawable, handle, nx + nw - naw, ny, naw, nah, 0, 5760);

-			OS.XFillRectangle(xDisplay, xDrawable, handle, nx, ny + nah2, nw, nh - nah);

-			OS.XFillArc(xDisplay, xDrawable, handle, nx + nw - naw, ny + nh - nah, naw, nah, 17280, 5760);

-			OS.XFillRectangle(xDisplay, xDrawable, handle, nx + naw2, ny + nh - nah2, nw - naw, nah2);

-			OS.XFillArc(xDisplay, xDrawable, handle, nx, ny + nh - nah, naw, nah, 11520, 5760);

-		} else {

-			OS.XFillArc(xDisplay, xDrawable, handle, nx, ny, naw, nh, 5760, 11520);

-			OS.XFillRectangle(xDisplay, xDrawable, handle, nx + naw2, ny, nw - naw, nh);

-			OS.XFillArc(xDisplay, xDrawable, handle, nx + nw - naw, ny, naw, nh, 17280, 11520);

-		}

-	} else {

-		if (nh > nah) {

-			OS.XFillArc(xDisplay, xDrawable, handle, nx, ny, nw, nah, 0, 11520);

-			OS.XFillRectangle(xDisplay, xDrawable, handle, nx, ny + nah2, nw, nh - nah);

-			OS.XFillArc(xDisplay, xDrawable, handle, nx, ny + nh - nah, nw, nah, 11520, 11520);

-		} else {

-			OS.XFillArc(xDisplay, xDrawable, handle, nx, ny, nw, nh, 0, 23040);

-		}

-	}

+	OS.XFillArc(xDisplay,xDrawable,handle,nx,ny,naw,nah,5760,5760);

+	OS.XFillArc(xDisplay,xDrawable,handle,nx,ny + nh - nah,naw,nah,11520,5760);

+	OS.XFillArc(xDisplay,xDrawable,handle,nx + nw - naw, ny + nh - nah, naw, nah,17280,5760);

+	OS.XFillArc(xDisplay,xDrawable,handle,nx + nw - naw, ny, naw, nah, 0, 5760);

+	OS.XFillRectangle(xDisplay,xDrawable,handle,nx + naw2, ny, nw - naw, nh);

+	OS.XFillRectangle(xDisplay,xDrawable,handle,nx,ny + nah2, naw2, nh - nah);

+	OS.XFillRectangle(xDisplay,xDrawable,handle,nx + nw - (naw / 2), ny + nah2, naw2, nh -nah);

 	OS.XSetForeground(xDisplay, handle, values.foreground);

 }

 /**
@@ -1428,7 +1270,7 @@
 public int getAdvanceWidth(char ch) {

 	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

 	int fontList  = data.fontList;

-	byte[] charBuffer = Converter.wcsToMbcs(getCodePage (), new char[] { ch }, false);

+	byte[] charBuffer = Converter.wcsToMbcs(null, new char[] { ch }, false);

 	int val = charBuffer[0] & 0xFF;

 	/* Create a font context to iterate over each element in the font list */

 	int[] buffer = new int[1];

@@ -1526,7 +1368,11 @@
 	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

 	int xDisplay = data.display;

 	XGCValues values = new XGCValues();

-	OS.XGetGCValues(xDisplay, handle, OS.GCBackground, values);

+	if (OS.XGetGCValues(xDisplay, handle, OS.GCBackground, values) == 0) {

+		// Check error case here. If a palette has been set we may be able

+		// to do a better job. 

+		return null;

+	}

 	XColor xColor = new XColor();

 	xColor.pixel = values.background;

 	OS.XQueryColor(xDisplay,data.colormap,xColor);

@@ -1552,7 +1398,7 @@
 public int getCharWidth(char ch) {

 	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

 	int fontList = data.fontList;

-	byte[] charBuffer = Converter.wcsToMbcs(getCodePage (), new char[] { ch }, false);

+	byte[] charBuffer = Converter.wcsToMbcs(null, new char[] { ch }, false);

 	int val = charBuffer[0] & 0xFF;

 	/* Create a font context to iterate over each element in the font list */

 	int[] buffer = new int[1];

@@ -1694,9 +1540,6 @@
 	OS.XSubtractRegion (hRegion, hRegion, hRegion);

 	OS.XUnionRegion (clipRgn, hRegion, hRegion);

 }

-String getCodePage () {

-	return Converter.getCodePage(data.display, data.fontList);

-}

 /** 
  * Returns the font currently being used by the receiver
  * to draw and measure text.
@@ -1929,7 +1772,11 @@
 	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

 	int xDisplay = data.display;

 	XGCValues values = new XGCValues();

-	OS.XGetGCValues(xDisplay, handle, OS.GCForeground, values);

+	if (OS.XGetGCValues(xDisplay, handle, OS.GCForeground, values) == 0) {

+		// Check error case here. If a palette has been set we may be able

+		// to do a better job. 

+		return null;

+	}

 	XColor xColor = new XColor();

 	xColor.pixel = values.foreground;

 	OS.XQueryColor(xDisplay,data.colormap,xColor);

@@ -2307,7 +2154,7 @@
 	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

 	if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

 	if (string.length () == 0) return new Point(0, getFontHeight());

-	byte[] buffer = Converter.wcsToMbcs(getCodePage (), string, true);

+	byte[] buffer = Converter.wcsToMbcs(null, string, true);

 	int xmString = OS.XmStringCreate(buffer, OS.XmFONTLIST_DEFAULT_TAG);

 	int fontList = data.fontList;

 	int width = OS.XmStringWidth(fontList, xmString);

@@ -2338,7 +2185,7 @@
 	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

 	if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

 	if (string.length () == 0) return new Point(0, getFontHeight());

-	byte [] textBuffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] textBuffer = Converter.wcsToMbcs (null, string, true);

 	int xmString = OS.XmStringGenerate(textBuffer, null, OS.XmCHARSET_TEXT, _MOTIF_DEFAULT_LOCALE);

 	if (data.renderTable == 0) createRenderTable();

 	int renderTable = data.renderTable;

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Image.java
index d3594e9..70d84c9 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Image.java
@@ -453,7 +453,6 @@
  *
  * @exception IllegalArgumentException <ul>
  *    <li>ERROR_NULL_ARGUMENT - if the bounds rectangle is null</li>
- *    <li>ERROR_INVALID_ARGUMENT - if either the rectangle's width or height is negative</li>

  * </ul>
  */
 public Image(Device device, Rectangle bounds) {

@@ -690,11 +689,6 @@
 	OS.memmove(xSrcImage, xSrcImagePtr, XImage.sizeof);

 	/* Calculate the palette depending on the display attributes */

 	PaletteData palette = null;

-	

-	/* Get the data for the source image. */

-	int length = xSrcImage.bytes_per_line * xSrcImage.height;

-	byte[] srcData = new byte[length];

-	OS.memmove(srcData, xSrcImage.data, length);

 	switch (xSrcImage.depth) {

 		case 1:

 			palette = new PaletteData(new RGB[] {

@@ -709,40 +703,13 @@
 			 */

 			SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);

 		case 8:

-			/* Normalize the pixels in the source image data (by making the 

-			 * pixel values sequential starting at pixel 0). Reserve normalized 

-			 * pixel 0 so that it maps to real pixel 0. This assumes pixel 0 is 

-			 * always used in the image.

-			 */

-			byte[] normPixel = new byte[ 256 ];

-			for (int index = 0; index < normPixel.length; index++) {

-				normPixel[ index ] = 0;

-			}

-			int numPixels = 1;

-			int index = 0;

-			for (int y = 0; y < xSrcImage.height; y++) {

-				for (int x = 0; x < xSrcImage.bytes_per_line; x++) {

-					int srcPixel = srcData[ index + x ] & 0xFF;

-					if (srcPixel != 0 && normPixel[ srcPixel ] == 0) {

-						normPixel[ srcPixel ] = (byte)numPixels++;

-					}

-					srcData[ index + x ] = normPixel[ srcPixel ];

-				}

-				index += xSrcImage.bytes_per_line;

-			}

-			

-			/* Create a palette with only the RGB values used in the image. */

-			int colormap = OS.XDefaultColormap(xDisplay, OS.XDefaultScreen(xDisplay));

-			RGB[] rgbs = new RGB[ numPixels ];

-			XColor color = new XColor();

-			for (int srcPixel = 0; srcPixel < normPixel.length; srcPixel++) {

-				// If the pixel value was used in the image, get its RGB values.

-				if (srcPixel == 0 || normPixel[ srcPixel ] != 0) {

-					color.pixel = srcPixel;

-					OS.XQueryColor(xDisplay, colormap, color);

-					int rgbIndex = normPixel[ srcPixel ] & 0xFF;

-					rgbs[ rgbIndex ] = new RGB((color.red >> 8) & 0xFF, (color.green >> 8) & 0xFF, (color.blue >> 8) & 0xFF);

-				}

+			/* Use the RGBs from the display to make the palette */

+			XColor[] xcolors = device.xcolors;

+			RGB[] rgbs = new RGB[xcolors.length];

+			for (int i = 0; i < rgbs.length; i++) {

+				XColor xcolor = xcolors[i];

+				if (xcolor == null) rgbs[i] = new RGB(0, 0, 0);

+				else rgbs[i] = new RGB((xcolor.red >> 8) & 0xFF, (xcolor.green >> 8) & 0xFF, (xcolor.blue >> 8) & 0xFF);

 			}

 			palette = new PaletteData(rgbs);

 			break;

@@ -764,7 +731,9 @@
 			SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);

 	}

 	ImageData data = new ImageData(width, height, xSrcImage.depth, palette);

-	data.data = srcData;

+	int length = xSrcImage.bytes_per_line * xSrcImage.height;

+	data.data = new byte[length];

+	OS.memmove(data.data, xSrcImage.data, length);

 	if (xSrcImage.bits_per_pixel == 32) {

 		/**

 		 * If bits per pixel is 32, scale the data down to 24, since we do not

@@ -778,7 +747,7 @@
 		int srcIndex = 0;

 		int rOffset = 0, gOffset = 1, bOffset = 2;

 		if (xSrcImage.byte_order == OS.MSBFirst) {

-			rOffset = 3; gOffset = 2; bOffset = 1;

+			rOffset = 2; gOffset = 1; bOffset = 0;

 		}

 		for (int y = 0; y < height; y++) {

 			destIndex = y * bytesPerLine;

@@ -985,7 +954,6 @@
  * @private
  */
 public int internal_new_GC (GCData data) {

-	if (pixmap == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

 	if (type != SWT.BITMAP || memGC != null) {

 		SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 	}

@@ -1053,7 +1021,7 @@
 static int putImage(ImageData image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, int display, int visual, int screenDepth, XColor[] xcolors, int[] transparentPixel, int drawable, int gc) {

 	PaletteData palette = image.palette;

 	if (!(((image.depth == 1 || image.depth == 2 || image.depth == 4 || image.depth == 8) && !palette.isDirect) ||

-		((image.depth == 8) || (image.depth == 16 || image.depth == 24 || image.depth == 32) && palette.isDirect)))

+		((image.depth == 16 || image.depth == 24) && palette.isDirect)))

 			return SWT.ERROR_UNSUPPORTED_DEPTH;

 

 	boolean flipX = destWidth < 0;

@@ -1067,7 +1035,7 @@
 		destY = destY - destHeight;

 	}

 	byte[] srcReds = null, srcGreens = null, srcBlues = null;

-	if (! palette.isDirect) {

+	if (image.depth <= 8) {

 		int length = palette.getRGBs().length;

 		srcReds = new byte[length];

 		srcGreens = new byte[length];

@@ -1083,7 +1051,6 @@
 	}

 	byte[] destReds = null, destGreens = null, destBlues = null;

 	int destRedMask = 0, destGreenMask = 0, destBlueMask = 0;

-	final boolean screenDirect;

 	if (screenDepth <= 8) {

 		if (xcolors == null) return SWT.ERROR_UNSUPPORTED_DEPTH;

 		destReds = new byte[xcolors.length];

@@ -1096,14 +1063,12 @@
 			destGreens[i] = (byte)((color.green >> 8) & 0xFF);

 			destBlues[i] = (byte)((color.blue >> 8) & 0xFF);

 		}

-		screenDirect = false;

 	} else {

 		Visual xVisual = new Visual();

 		OS.memmove(xVisual, visual, Visual.sizeof);

 		destRedMask = xVisual.red_mask;

 		destGreenMask = xVisual.green_mask;

 		destBlueMask = xVisual.blue_mask;

-		screenDirect = true;

 	}

 	if (transparentPixel != null) {

 		RGB rgb = image.palette.getRGB(transparentPixel[0]);

@@ -1122,7 +1087,15 @@
 			OS.XtFree(bufPtr);

 			return SWT.ERROR_NO_HANDLES;

 		}

-		int foreground = 1, background = 0;

+		int foreground = 0, background = 0;

+		if (srcReds.length > 1) {

+			foreground = ImageData.closestMatch(screenDepth, srcReds[1], srcGreens[1], srcBlues[1],

+				destRedMask, destGreenMask, destBlueMask, destReds, destGreens, destBlues);

+		}

+		if (srcReds.length > 0) {

+			background = ImageData.closestMatch(screenDepth, srcReds[0], srcGreens[0], srcBlues[0],

+				destRedMask, destGreenMask, destBlueMask, destReds, destGreens, destBlues);

+		}

 		XImage xImage = new XImage();

 		OS.memmove(xImage, xImagePtr, XImage.sizeof);

 		xImage.byte_order = OS.MSBFirst;

@@ -1130,11 +1103,8 @@
 		xImage.bitmap_bit_order = OS.MSBFirst;

 		OS.memmove(xImagePtr, xImage, XImage.sizeof);

 		int destOrder = ImageData.MSB_FIRST;

-		ImageData.blit(ImageData.BLIT_SRC,

-			image.data, 1, image.bytesPerLine, image.getByteOrder(), srcX, srcY, srcWidth, srcHeight, null, null, null,

-			ImageData.ALPHA_OPAQUE, null, 0,

-			buf, 1, bplX, destOrder, 0, 0, destWidth, destHeight, null, null, null,

-			flipX, flipY);

+		ImageData.stretch1(image.data, image.bytesPerLine, ImageData.MSB_FIRST, srcX, srcY, srcWidth, srcHeight,

+			buf, bplX, ImageData.MSB_FIRST, 0, 0, destWidth, destHeight, flipX, flipY);

 		OS.memmove(xImage.data, buf, bufSize);

 		XGCValues values = new XGCValues();

 		OS.XGetGCValues(display, gc, OS.GCForeground | OS.GCBackground, values);

@@ -1157,76 +1127,61 @@
 	int bufPtr = OS.XtMalloc(bufSize);

 	xImage.data = bufPtr;

 	OS.memmove(xImagePtr, xImage, XImage.sizeof);

-	int srcOrder = image.getByteOrder();

+	int srcOrder = image.depth == 16 ? ImageData.LSB_FIRST : ImageData.MSB_FIRST;

 	int destOrder = xImage.byte_order == OS.MSBFirst ? ImageData.MSB_FIRST : ImageData.LSB_FIRST;

-	if (palette.isDirect) {

-		if (screenDirect) {

-			ImageData.blit(ImageData.BLIT_SRC,

-				image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, palette.redMask, palette.greenMask, palette.blueMask,

-				ImageData.ALPHA_OPAQUE, null, 0,

-				buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, xImage.red_mask, xImage.green_mask, xImage.blue_mask,

-				flipX, flipY);

-		} else {

-			ImageData.blit(ImageData.BLIT_SRC,

-				image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, palette.redMask, palette.greenMask, palette.blueMask,

-				ImageData.ALPHA_OPAQUE, null, 0,

-				buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, destReds, destGreens, destBlues,

-				flipX, flipY);

-		}

-	} else {

-		if (screenDirect) {

-			ImageData.blit(ImageData.BLIT_SRC,

-				image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, srcReds, srcGreens, srcBlues,

-				ImageData.ALPHA_OPAQUE, null, 0,

-				buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, xImage.red_mask, xImage.green_mask, xImage.blue_mask,

-				flipX, flipY);

-		} else {

-			ImageData.blit(ImageData.BLIT_SRC,

-				image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, srcReds, srcGreens, srcBlues,

-				ImageData.ALPHA_OPAQUE, null, 0,

-				buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, destReds, destGreens, destBlues,

-				flipX, flipY);

-		}

+	if (image.depth > 8 && screenDepth > 8) {

+		ImageData.blit(ImageData.BLIT_SRC,

+			image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, palette.redMask, palette.greenMask, palette.blueMask, -1, null, 0,

+			buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, xImage.red_mask, xImage.green_mask, xImage.blue_mask,

+			flipX, flipY);

+	} else if (image.depth <= 8 && screenDepth > 8) {

+		ImageData.blit(ImageData.BLIT_SRC,

+			image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, srcReds, srcGreens, srcBlues, -1, null, 0,

+			buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, xImage.red_mask, xImage.green_mask, xImage.blue_mask,

+			flipX, flipY);

+	} else if (image.depth > 8 && screenDepth <= 8) {

+		ImageData.blit(ImageData.BLIT_SRC,

+			image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, palette.redMask, palette.greenMask, palette.blueMask, -1, null, 0,

+			buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, destReds, destGreens, destBlues,

+			flipX, flipY);

+	} else if (image.depth <= 8 && screenDepth <= 8) {

+		ImageData.blit(ImageData.BLIT_SRC,

+			image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, srcReds, srcGreens, srcBlues, -1, null, 0,

+			buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, destReds, destGreens, destBlues,

+			flipX, flipY);

 	}

 	OS.memmove(xImage.data, buf, bufSize);

 	OS.XPutImage(display, drawable, gc, xImagePtr, 0, 0, destX, destY, destWidth, destHeight);

 	OS.XDestroyImage(xImagePtr);

 	return 0;

 }

-/**

- * Sets the color to which to map the transparent pixel.

- * <p>

- * There are certain uses of <code>Images</code> that do not support

- * transparency (for example, setting an image into a button or label).

- * In these cases, it may be desired to simulate transparency by using

- * the background color of the widget to paint the transparent pixels

- * of the image. This method specifies the color that will be used in

- * these cases. For example:

- * <pre>

- *    Button b = new Button();

- *    image.setBackground(b.getBackground());>

- *    b.setImage(image);

- * </pre>

- * </p><p>

- * The image may be modified by this operation (in effect, the

- * transparent regions may be filled with the supplied color).  Hence

- * this operation is not reversible and it is not legal to call

- * this function twice or with a null argument.

- * </p><p>

- * This method has no effect if the receiver does not have a transparent

- * pixel value.

- * </p>

- *

- * @param color the color to use when a transparent pixel is specified

- *

- * @exception IllegalArgumentException <ul>

+/**
+ * Sets the color to which to map the transparent pixel.
+ * <p>
+ * There are certain uses of <code>Images</code> that do not support
+ * transparency (for example, setting an image into a button or label).
+ * In these cases, it may be desired to simulate transparency by using
+ * the background color of the widget to paint the transparent pixels
+ * of the image. This method specifies the color that will be used in
+ * these cases. For example:
+ * <pre>
+ *    Button b = new Button();
+ *    image.setBackground(b.getBackground());>
+ *    b.setImage(image);
+ * </pre>
+ * This method has no effect if the receiver does not have a transparent
+ * pixel value.
+ *
+ * @param color the color to use when a transparent pixel is specified
+ *
+ * @exception IllegalArgumentException <ul>
  *    <li>ERROR_NULL_ARGUMENT - if the color is null</li>

  *    <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>

- * </ul>

+ * </ul>
  * @exception SWTException <ul>

  *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>

  * </ul>

- */

+ */
 public void setBackground(Color color) {

 	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

 	if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Region.java
index ccd0a97..b314d0f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Region.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Region.java
@@ -41,7 +41,6 @@
  *
  * @exception IllegalArgumentException <ul>
  *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
- *    <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>

  * </ul>
  * @exception SWTException <ul>

  *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>

@@ -50,8 +49,6 @@
 public void add (Rectangle rect) {

 	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

 	if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

-	if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

-

 	XRectangle xRect = new XRectangle();

 	xRect.x = (short)rect.x;

 	xRect.y = (short)rect.y;

@@ -67,8 +64,7 @@
  * @param region the region to merge
  *
  * @exception IllegalArgumentException <ul>
- *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>

- *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
  * </ul>
  * @exception SWTException <ul>

  *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>

@@ -77,7 +73,6 @@
 public void add (Region region) {

 	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

 	if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

-	if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 	OS.XUnionRegion(handle, region.handle, handle);

 }

 /**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/Converter.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/Converter.java
index f9e73e6..cf248bd 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/Converter.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/Converter.java
@@ -5,396 +5,82 @@
  * All Rights Reserved

  */

 

-import org.eclipse.swt.internal.motif.*;

-import java.util.*;

-

-/**

- * This class implements the conversions between unicode characters

- * and the <em>platform supported</em> representation for characters.

- * <p>

- * Note that, unicode characters which can not be found in the platform

- * encoding will be converted to an arbitrary platform specific character.

- * </p>

- */

+/**
+ * This class implements the conversions between unicode characters
+ * and the <em>platform supported</em> representation for characters.
+ * <p>
+ * Note that, unicode characters which can not be found in the platform
+ * encoding will be converted to an arbitrary platform specific character.
+ * </p>
+ */
  

 public final class Converter {

-

-	static final byte [] NULL_BYTE_ARRAY = new byte [1];

-	static final byte [] EMPTY_BYTE_ARRAY = new byte [0];

-	static final char [] EMPTY_CHAR_ARRAY = new char [0];

-	

-	static String CodePage;

-	static byte[] Unicode;

-	

-	/* Converter cache */

-	static String LastMBToWCCodePage;

-	static String LastWCToMBCodePage;

-	static int LastWCToMB;

-	static int LastMBToWC;

-	

-	/* Buffers cache */

-	static int BufferSize;

-	static int BufferTimes2;

-	static int BufferTimes4;

-	

-	static {	

-		Unicode = getAsciiBytes("UCS-2");

-

-		int length, item = OS.nl_langinfo (OS.CODESET);

-		if (item != 0 && (length = OS.strlen (item)) > 0) {

-			byte [] buffer = new byte [length];

-			OS.memmove (buffer, item, length);

-			CodePage = new String (buffer);

-			if (OS.IsSunOS) {

-				if (length > 3 && CodePage.indexOf ("ISO") == 0) {

-					CodePage = CodePage.substring (3, length - 3);

-				}

-			}

-		} else {

-			if (OS.IsLinux) CodePage = "ISO-8859-1";

-			else if (OS.IsAIX) CodePage = "ISO8859-1";

-			else if (OS.IsSunOS) CodePage = "8859-1";

-			else CodePage = "iso8859_1";

-		}

-		

-		BufferSize = 512;

-		BufferTimes2 = OS.XtMalloc (BufferSize * 2);

-		BufferTimes4 = OS.XtMalloc (BufferSize * 4);

-	}

-

-/**

- * Returns the default code page for the platform where the

- * application is currently running.

- *

- * @return the default code page

- */	

+	public static final byte [] NullByteArray = new byte [1];

+	public static final char [] NullCharArray = new char [1];

+	public static final byte [] EmptyByteArray = new byte [0];

+	public static final char [] EmptyCharArray = new char [0];

+/**
+ * Returns the default code page for the platform where the
+ * application is currently running.
+ *
+ * @return the default code page
+ */
 public static String defaultCodePage () {

-	return CodePage;

+	/*

+	| ptr cp |

+	DefaultCodePage == nil ifFalse: [^DefaultCodePage].

+	cp := ''. "$NON-NLS$"

+	(ptr := OSStringZ address: (NlLanginfo callWith: 49)) isNull

+		ifFalse: [cp := String copyFromOSMemory: ptr].

+	cp isEmpty ifFalse: [

+		IsSunOS ifTrue: [

+			(cp size > 3 and: [(cp copyFrom: 1 to: 3) = 'ISO'])

+				ifTrue: [cp := cp copyFrom: 4 to: cp size]].

+		^DefaultCodePage := cp].

+	IsAIX ifTrue: [^DefaultCodePage := 'ISO8859-1'].

+	IsSunOS ifTrue: [^DefaultCodePage := '8859-1'].

+	^DefaultCodePage := 'iso8859_1'

+	*/

+	return null;

 }

-

-/**

- * Returns the code page for the specified font list.

- * (Warning this method is platform dependent.)

- *

- * @return the code page for the font list

- */	

-public static String getCodePage (int xDisplay, int fontList) {

-	int[] buffer = new int[1];

-	if (!OS.XmFontListInitFontContext(buffer, fontList)) return null;

-	int context = buffer[0];

-	XFontStruct fontStruct = new XFontStruct();

-	int fontListEntry;

-	int[] fontStructPtr = new int[1];

-	int[] fontNamePtr = new int[1];

-	String codePage = null;

-	/* Go through each entry in the font list */

-	while ((fontListEntry = OS.XmFontListNextEntry(context)) != 0) {

-		int fontPtr = OS.XmFontListEntryGetFont(fontListEntry, buffer);

-		if (buffer[0] == OS.XmFONT_IS_FONT) { 

-			/* FontList contains a single font */

-			OS.memmove(fontStruct,fontPtr,20 * 4);

-			int propPtr = fontStruct.properties;

-			for (int i = 0; i < fontStruct.n_properties; i++) {

-				/* Reef through properties looking for XAFONT */

-				int[] prop = new int[2];

-				OS.memmove(prop, propPtr, 8);

-				if (prop[0] == OS.XA_FONT) {

-					/* Found it, prop[1] points to the string */

-					StringBuffer stringBuffer = new StringBuffer();

-					int ptr = OS.XmGetAtomName(xDisplay, prop[1]);

-					int length = OS.strlen(ptr);

-					byte[] nameBuf = new byte[length];

-					OS.memmove(nameBuf, ptr, length);

-					/* Use the character encoding for the default locale */

-					String xlfd = new String(Converter.mbcsToWcs(null, nameBuf)).toLowerCase();

-					int start = xlfd.lastIndexOf ('-');

-					if (start != -1 && start > 0) {

-						start = xlfd.lastIndexOf ('-', start - 1);

-						if (start != -1) {

-							codePage = xlfd.substring (start + 1, xlfd.length ());

-							if (codePage.indexOf ("iso") == 0) {

-								if (OS.IsLinux) {

-									codePage = "ISO-" + codePage.substring (3, codePage.length ());

-								}

-							}

-						}

-					}

-					OS.XtFree(ptr);

-					break;

-				}

-				propPtr += 8;

-			}

-		}

-		else { 

-			/* FontList contains a fontSet */

-			

-			/* Get the font set locale */

-			int localePtr = OS.XLocaleOfFontSet(fontPtr);

-			int length = OS.strlen (localePtr);

-			byte [] locale = new byte [length + 1];

-			OS.memmove (locale, localePtr, length);

-			

-			/* Get code page for the font set locale */

-			OS.setlocale (OS.LC_CTYPE,  locale);

-			int codesetPtr = OS.nl_langinfo (OS.CODESET);

-			length = OS.strlen (codesetPtr);

-			byte [] codeset = new byte [length];

-			OS.memmove (codeset, codesetPtr, length);

-			codePage = getAsciiString (codeset);

-			

-			/* Reset the locale */

-			OS.setlocale (OS.LC_CTYPE, new byte[1]);

-		}

+static boolean is7BitAscii (byte [] buffer) {

+	for (int i=0; i<buffer.length; i++) {

+		if ((buffer [i] & 0xFF) > 0x7F) return false;

 	}

-	OS.XmFontListFreeFontContext(context);

-	return codePage;

+	return true;

 }

-

-static byte[] getAsciiBytes (String str) {

-	int length = str.length ();

-	byte [] buffer = new byte [length + 1];

-	for (int i=0; i<length; i++) {

-		buffer [i] = (byte)str.charAt (i);

+static boolean is7BitAscii (char [] buffer) {

+	for (int i=0; i<buffer.length; i++) {

+		if (buffer [i] > 0x7F) return false;

 	}

-	return buffer;

+	return true;

 }

-

-static String getAsciiString (byte [] buffer) {

-	int length = buffer.length;

-	char [] chars = new char [length];

-	for (int i=0; i<length; i++) {

-		chars [i] = (char)buffer [i];

-	}

-	return new String (chars);

-}

-

-/**

- * Converts an array of bytes representing the platform's encoding,

- * in the given code page, of some character data into an array of

- * matching unicode characters.

- *

- * @param codePage the code page to use for conversion

- * @param buffer the array of bytes to be converted

- * @return the unicode conversion

- */

 public static char [] mbcsToWcs (String codePage, byte [] buffer) {

-

-	/* Check for the simple cases */

-	if (buffer == null) {

-		return EMPTY_CHAR_ARRAY;

-	}

-	int length = buffer.length;

-	if (length == 0) {

-		return EMPTY_CHAR_ARRAY;

-	}

-	

-	/*

-	 * Optimize for English ASCII encoding.  If no conversion is

-	 * performed, it is safe to return any object that will also not

-	 * be converted if this routine is called again with the result.

-	 * This ensures that double conversion will not be performed

-	 * on the same bytes.  Note that this relies on the fact that

-	 * lead bytes are never in the range 0..0x7F.

-	 */	

-	char [] wideCharStr = new char [length];

-	for (int i=0; i<length; i++) {

-		if ((buffer [i] & 0xFF) <= 0x7F) {

-			wideCharStr [i] = (char) buffer [i]; // all bytes <= 0x7F, so no ((char) (buffer[i]&0xFF)) needed

-		} else {

-			synchronized (Converter.class) {

-				String cp = codePage != null ? codePage : CodePage;

-				if (LastMBToWC != 0 && !cp.equals (LastMBToWCCodePage)) {

-					OS.iconv_close (LastMBToWC);

-					LastMBToWC = 0;

-				}

-				if (LastMBToWC == 0) {

-					LastMBToWCCodePage = cp;

-					LastMBToWC = OS.iconv_open (Unicode, getAsciiBytes (cp));

-				}

-				int cd = LastMBToWC;

-				if (cd == 0) return EMPTY_CHAR_ARRAY;

-				int inBytes = length;

-				int outBytes = length * 2;

-				int ptr1, ptr2;

-				if (length <= BufferSize * 2) {

-					ptr1 = BufferTimes2;

-					ptr2 = BufferTimes4;

-				} else {

-					ptr1 = OS.XtMalloc (inBytes);

-					ptr2 = OS.XtMalloc (outBytes);

-				}

-				int [] inBuf = {ptr1};

-				int [] inBytesLeft = {inBytes};

-				int [] outBuf = {ptr2};

-				int [] outBytesLeft = {outBytes};

-				OS.memmove (ptr1, buffer, inBytes);

-				int result = OS.iconv (cd, inBuf, inBytesLeft, outBuf, outBytesLeft);

-				outBytes = outBuf [0] - ptr2;

-				wideCharStr = new char [outBytes / 2];

-				

-				/* Memmove can not be used because of the endianess */

-//				OS.memmove (wideCharStr, ptr2, outBytesLeft [0]);

-				byte[] b = new byte [outBytes];

-				OS.memmove (b, ptr2, outBytes);

-				for (int j=0; j<outBytes; j+=2) {

-					wideCharStr [j >> 1] = (char)(((b [j] & 0xFF) << 8) | (b [j + 1] & 0xFF));

-				}

-				

-				if (ptr1 != BufferTimes2) OS.XtFree (ptr1);

-				if (ptr2 != BufferTimes4) OS.XtFree (ptr2);

-			}

-			return wideCharStr;

-		}

-	}

-	return wideCharStr;

+	//SLOW AND BOGUS

+	return new String (buffer).toCharArray ();

 }

-

-/**

- * Free any cached resources.

- */	

-public static void release () {

-	synchronized (Converter.class) {

-		if (BufferTimes2 != 0) OS.XtFree (BufferTimes2);

-		if (BufferTimes4 != 0) OS.XtFree (BufferTimes4);

-		if (LastWCToMB != 0) OS.iconv_close (LastWCToMB);

-		if (LastMBToWC != 0) OS.iconv_close (LastMBToWC);

-		LastMBToWC = LastWCToMB = BufferTimes4 = BufferTimes2 = 0;

-	}

-}

-

-/**

- * Converts an array of chars (containing unicode data) to an array

- * of bytes representing the platform's encoding, of those characters

- * in the given code page.

- *

- * @param codePage the code page to use for conversion

- * @param buffer the array of chars to be converted

- * @return the platform encoding

- */

-public static byte [] wcsToMbcs (String codePage, char [] buffer) {

-	return wcsToMbcs (codePage, buffer, false);

-}

-

-/**

- * Converts an array of chars (containing unicode data) to an array

- * of bytes representing the platform's encoding, of those characters

- * in the given code page. If the termination flag is true, the resulting

- * byte data will be null (zero) terminated.

- *

- * @param codePage the code page to use for conversion

- * @param buffer the array of chars to be converted

- * @param terminate <code>true</code> if the result should be null terminated and false otherwise.

- * @return the platform encoding

- */

-public static byte [] wcsToMbcs (String codePage, char [] buffer, boolean terminate) {

-

-	/* Check for the simple cases */

-	if (buffer == null) {

-		return (terminate) ? NULL_BYTE_ARRAY : EMPTY_BYTE_ARRAY;

-	}

-	int length = buffer.length;

-	if (length == 0) {

-		return (terminate) ? NULL_BYTE_ARRAY : EMPTY_BYTE_ARRAY;

-	}

-

-	/*

-	 * Optimize for English ASCII encoding.  This optimization

-	 * relies on the fact that lead bytes can never be in the

-	 * range 0..0x7F.

-	 */

-	byte [] mbcs = new byte [(terminate) ? length + 1 : length];

-	for (int i=0; i<length; i++) {

-		if ((buffer [i] & 0xFFFF) <= 0x7F) {

-			mbcs [i] = (byte) buffer [i];

-		} else {

-			synchronized (Converter.class) {

-				String cp = codePage != null ? codePage : CodePage;

-				if (LastWCToMB != 0 && !cp.equals (LastWCToMBCodePage)) {

-					OS.iconv_close (LastWCToMB);

-					LastWCToMB = 0;

-				}

-				if (LastWCToMB == 0) {

-					LastWCToMBCodePage = cp;

-					LastWCToMB = OS.iconv_open (getAsciiBytes (cp), Unicode);

-				}

-				int cd = LastWCToMB;

-				if (cd == 0) return (terminate) ? NULL_BYTE_ARRAY : EMPTY_BYTE_ARRAY;

-				int inBytes = length * 2;

-				int outBytes = length * 4;

-				int ptr1, ptr2;

-				if (length <= BufferSize) {

-					ptr1 = BufferTimes2;

-					ptr2 = BufferTimes4;

-				} else {

-					ptr1 = OS.XtMalloc (inBytes);

-					ptr2 = OS.XtMalloc (outBytes);

-				}

-				int [] inBuf = {ptr1};

-				int [] inBytesLeft = {inBytes};

-				int [] outBuf = {ptr2};

-				int [] outBytesLeft = {outBytes};

-				

-				/* Memmove can not be used because of the endianess */

-//				OS.memmove (ptr1, buffer, inBytes);

-				byte[] b = new byte[inBytes];

-				for (int j=0; j<inBytes; j+=2) {

-					int c = buffer [j >> 1];

-					b [j] = (byte)(c >> 8);

-					b [j + 1] = (byte)(c & 0xFF);

-				}

-				OS.memmove (ptr1, b, inBytes);

-				

-				int result = OS.iconv (cd, inBuf, inBytesLeft, outBuf, outBytesLeft);

-				outBytes = outBuf [0] - ptr2;

-				mbcs = new byte [outBytes];

-				OS.memmove (mbcs, ptr2, outBytes);

-				if (ptr1 != BufferTimes2) OS.XtFree (ptr1);

-				if (ptr2 != BufferTimes4) OS.XtFree (ptr2);

-			}

-			return mbcs;

-		}

-	}

-	return mbcs;

-}

-

-/**

- * Converts a String (containing unicode data) to an array

- * of bytes representing the platform's encoding, of those characters

- * in the given code page.

- *

- * @param codePage the code page to use for conversion

- * @param string the string to be converted

- * @return the platform encoding

- */

+/* TEMPORARY CODE */

 public static byte [] wcsToMbcs (String codePage, String string) {

 	return wcsToMbcs (codePage, string, false);

 }

-

-/**

- * Converts a String (containing unicode data) to an array

- * of bytes representing the platform's encoding, of those characters

- * in the given code page. If the termination flag is true, the resulting

- * byte data will be null (zero) terminated.

- *

- * @param codePage the code page to use for conversion

- * @param string the string to be converted

- * @param terminate <code>true</code> if the result should be null terminated and false otherwise.

- * @return the platform encoding

- */

 public static byte [] wcsToMbcs (String codePage, String string, boolean terminate) {

-	if (terminate) {

-		if (string == null) return NULL_BYTE_ARRAY;

-		int count = string.length ();

-		char [] buffer = new char [count + 1];

-		string.getChars (0, count, buffer, 0);

-		return wcsToMbcs (codePage, buffer, false);

-	} else {

-		if (string == null) return EMPTY_BYTE_ARRAY;

-		int count = string.length ();

-		char [] buffer = new char [count];

-		string.getChars (0, count, buffer, 0);

-		return wcsToMbcs (codePage, buffer, false);

-	}

+	//SLOW AND BOGUS

+	int count = string.length ();

+	if (terminate) count++;

+	char [] buffer = new char [count];

+	string.getChars (0, string.length (), buffer, 0);

+	return wcsToMbcs (codePage, buffer, false);

 }

-

+/* TEMPORARY CODE */

+public static byte [] wcsToMbcs (String codePage, char [] buffer) {

+	return wcsToMbcs (codePage, buffer, false);

+}

+public static byte [] wcsToMbcs (String codePage, char [] buffer, boolean terminate) {

+	//SLOW AND BOGUS

+	if (!terminate) return new String (buffer).getBytes ();

+	byte [] buffer1 = new String (buffer).getBytes ();

+	byte [] buffer2 = new byte [buffer1.length + 1];

+	System.arraycopy (buffer1, 0, buffer2, 0, buffer1.length);

+	return buffer2;

+}

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/KDE.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/KDE.java
index eeb4c65..949c48c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/KDE.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/KDE.java
@@ -9,50 +9,46 @@
 

 public static final int KICON_SMALL = 0;

 

-public static final native int  KApplication_new(int qcString);

+public static final native int KApplication_new(int qcString);

 

-public static final native int  KGlobal_iconLoader();

+public static final native int KGlobal_iconLoader();

 

-public static final native int  KIconLoader_iconPath(int loader, int iconQString, int iconType, int canReturnNull);

+public static final native int KIconLoader_iconPath(int receiver, int iconQString, int iconType, int canReturnNull);

 

-public static final native int  KMimeType_mimeType(int mimeTypeName);

-public static final native int  KMimeType_icon(int mimeType, int unused1, int unused2);

-public static final native int  KMimeType_name(int mimeType);

-public static final native int  KMimeType_patterns(int mimeType);

-public static final native int  KMimeType_offers(int mimeTypeName);

-public static final native int  KMimeType_allMimeTypes();

+public static final native int KMimeType_findByURL(int kurl);

+public static final native int KMimeType_icon(int receiver, int unused1, int unused2);

+public static final native int KMimeType_name(int receiver);

 

-public static final native int  KMimeTypeList_begin(int mimeTypeList);

-public static final native int  KMimeTypeList_delete(int mimeTypeList);

-public static final native int  KMimeTypeList_end(int mimeTypeList);

+public static final native int KService_allServices();

+public static final native int KService_exec(int receiver);

+public static final native int KService_icon(int receiver);

+public static final native int KService_name(int receiver);

+public static final native int KService_serviceByName(int serviceName);

+public static final native int KService_type(int receiver);

 

-public static final native int  KMimeTypeListIterator_delete(int iterator);

-public static final native int  KMimeTypeListIterator_dereference(int iterator);

-public static final native int  KMimeTypeListIterator_equals(int iterator, int iterator2);

-public static final native void KMimeTypeListIterator_increment(int iterator);

+public static final native int KServiceTypeProfile_preferredService(int mimeTypeQString, int needApp);

 

-public static final native int  QStringList_begin(int qstringList);

-public static final native int  QStringList_delete(int qstringList);

-public static final native int  QStringList_end(int qstringList);

+public static final native void KURL_delete(int receiver);

 

-public static final native int  QStringListIterator_delete(int iterator);

-public static final native int  QStringListIterator_dereference(int iterator);

-public static final native int  QStringListIterator_equals(int iterator, int iterator2);

-public static final native void QStringListIterator_increment(int iterator);

+public static final native int KURL_new(int qString);

 

-public static final native int  KURL_new( int qURLString );

-public static final native void KURL_delete( int url );

-public static final native int  KRun_runURL( int url, int mimeTypeName );

+public static final native int KServiceList_begin(int receiver);

+public static final native int KServiceList_delete(int receiver);

+public static final native int KServiceList_end(int receiver);

 

-public static final native int  KServiceList_delete(int serviceList);

+public static final native int QCString_data(int receiver);

+public static final native int QCString_delete(int receiver);

+public static final native int QCString_new(byte[] string);

 

-public static final native int  QCString_data(int qcString);

-public static final native int  QCString_delete(int qcString);

-public static final native int  QCString_new(byte[] string);

+public static final native int QString_delete(int receiver);

+public static final native int QString_equals(int receiver, int object);

+public static final native int QString_new(byte[] string);

+public static final native int QString_utf8(int receiver);

 

-public static final native int  QString_delete(int qString);

-public static final native int  QString_equals(int qString, int qString2);

-public static final native int  QString_new(byte[] string);

-public static final native int  QString_utf8(int qString);

+public static final native int KServiceListIterator_delete(int receiver);

+public static final native int KServiceListIterator_dereference(int receiver);

+public static final native void KServiceListIterator_increment(int receiver);

+public static final native int KServiceListIterator_new(int listBeginning);

+public static final native int KServiceListIterator_equals(int receiver, int object);

 

 }
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/OS.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/OS.java
index 6caa14e..c311603 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/OS.java
@@ -14,44 +14,6 @@
 		Callback.loadLibrary ();

 	}

 

-	/* OS and locale Constants*/

-	public static final boolean IsAIX, IsSunOS, IsLinux;

-	public static final int CODESET;

-	public static final int LC_CTYPE;

-	static {

-		

-		/* Initialize the OS flags and locale constants */

-		String osName = System.getProperty ("os.name");

-		if (osName.equals("Linux")) {

-			IsLinux = true;

-			IsAIX = IsSunOS = false;

-		} else {

-			if (osName.equals("AIX")) {

-				IsAIX = true;

-				IsLinux = IsSunOS = false;

-			} else {

-				if (osName.equals("Solaris")) {

-					IsSunOS = true;

-					IsLinux = IsAIX = false;

-				} else {

-					IsLinux = IsSunOS = IsAIX = false;

-				}

-			}

-		}

-		

-		CODESET = OS.IsLinux ? 14 : 49;

-		LC_CTYPE = OS.IsAIX ? 1 : 0;

-	}

-	

-	/* BEGIN Visual classes */

-	//public static final int StaticGray = 0;

-	//public static final int GrayScale = 1;

-	//public static final int StaticColor = 2;

-	//public static final int PseudoColor = 3;

-	//public static final int TrueColor = 4;

-	//public static final int DirectColor = 5;

-	/* END Visual clases */

-

 	/* X/Xt/Xm Constants */

 	public static final byte [] XmFONTLIST_DEFAULT_TAG = {0x46, 0x4F, 0x4E, 0x54, 0x4C, 0x49, 0x53, 0x54, 0x5F, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4C, 0x54, 0x5F, 0x54, 0x41, 0x47, 0x5F, 0x53, 0x54, 0x52, 0x49, 0x4E, 0x47, 0x0};

 	public static final int Above = 0;

@@ -87,7 +49,7 @@
 //	public static final int ClipByChildren = 0x0;

 //	public static final int ColormapChangeMask = 1 << 23;

 //	public static final int ColormapNotify = 32;

-	public static final int Complex = 0;

+//	public static final int Complex = 0;

 	public static final int ConfigureNotify = 22;

 //	public static final int ConfigureRequest = 23;

 	public static final int ControlMask = (1<<2);

@@ -198,7 +160,7 @@
 //	public static final int LeaveNotify = 8;

 	public static final int LeaveWindowMask	= 1 << 5;

 	public static final int LineDoubleDash = 0x2;

-	public static final int LineOnOffDash = 0x1;

+//	public static final int LineOnOffDash = 0x1;

 	public static final int LineSolid = 0x0;

 //	public static final int LockMask = (1<<1);

 	public static final int LSBFirst = 0;

@@ -417,7 +379,7 @@
 	public static final int XK_Shift_L = 0xFFE1;

 	public static final int XK_Shift_R = 0xFFE2;

 	public static final int XK_Tab = 0xFF09;

-	public static final int XK_Up = 0xFF52;

+	public static final int XK_Up = 0xFF52;
 	public static final int XK_VoidSymbol = 0xFFFFFF;

 //	public static final int XLookupBoth = 0x4;

 //	public static final int XLookupChars = 0x2;

@@ -613,7 +575,7 @@
 	public static final int XmNdragInitiatorProtocolStyle = malloc ("dragInitiatorProtocolStyle");

 	public static final int XmNdragReceiverProtocolStyle = malloc ("dragReceiverProtocolStyle");

 	public static final int XmNdragOperations = malloc ("dragOperations");

-	public static final int XmNeditable = malloc ("editable");

+	public static final int XmNeditable = malloc ("editable");
 	public static final int XmNenableThinThickness = malloc ("enableThinThickness");

 	public static final int XmNiconic = malloc ("iconic");

 	public static final int XmNlabelType = malloc ("labelType");

@@ -771,11 +733,6 @@
 	public static final int XmNvisibleItemCount = malloc ("visibleItemCount");

 	public static final int XmNdropTransfers  = malloc ("dropTransfers");

 	public static final int XmNshowArrows = malloc ("showArrows");

-	public static final int XmNspotLocation = malloc ("spotLocation");

-//	public static final int XNFocusWindow = malloc ("focusWindow");

-//	public static final int XNInputStyle = malloc ("inputStyle");

-//	public static final int XNClientWindow = malloc ("clientWindow");

-//	public static final int XNQueryInputStyle = malloc ("queryInputStyle");

 			

 	/* Unknown */	

 	public static final int XmNdropSiteActivity = malloc("dropSiteActivity");

@@ -863,7 +820,9 @@
 	public static final native int XmCreateDrawnButton (int parent, byte [] name, int [] arglist, int argcount);

 	public static final native int XmCreateRowColumn (int parent, byte [] name, int [] arglist, int argcount);

 	public static final native int XmCreateScrolledWindow (int parent, byte [] name, int [] arglist, int argcount);

+	public static final native boolean XmDestroyPixmap (int screen, int pixmap);

 	public static final native int XmGetFocusWidget (int widget);

+	public static final native int XmGetPixmapByDepth (int screen, byte [] image_name, int foreground, int background, int depth);

 	public static final native void XmListAddItemsUnselected (int list, int xmStringTable, int item_count, int position);

 	public static final native void XmListDeleteItem (int list, int item);

 	public static final native void XmListDeselectItem (int list, int xmString);

@@ -954,10 +913,8 @@
 	int cursor,

 	int time);

 public static final native int XInitThreads ();	

-public static final native int XInternAtom( int display, byte [] name, boolean ifExists );

 public static final native int XKeysymToString (int keysym);

 public static final native int XListFonts(int display, byte[] pattern, int maxnames, int[] actual_count_return);

-public static final native int XListProperties(int display, int window, int[] num_prop_return);

 public static final native int XLookupString (XKeyEvent event, byte [] string, int size, int [] keysym, int [] status);

 public static final native int XLowerWindow (int display, int window);

 public static final native boolean XPointInRegion (int region, int x, int y);

@@ -1049,7 +1006,6 @@
 public static final native int XmCreateToggleButton (int parent, byte [] name, int [] arglist, int argcount);

 public static final native int XmCreateToggleButtonGadget (int parent, byte [] name, int [] arglist, int argcount);

 public static final native int XmCreateWarningDialog (int parent, byte [] name, int [] arglist, int argcount);

-public static final native boolean XmDestroyPixmap (int screen, int pixmap);

 public static final native void XmDragCancel(int dragcontext);

 public static final native int XmDragStart(int widget, XAnyEvent event, int[] arglist, int argcount);

 public static final native void XmDropSiteRegister(int widget, int [] arglist, int argcount);

@@ -1070,8 +1026,6 @@
 public static final native int XmGetAtomName (int display, int atom);

 public static final native int XmGetDragContext (int widget, int timestamp);

 public static final native int XmGetFocusWidget (int widget);

-public static final native int XmGetPixmap( int screen, byte [] name, int fgPixel, int bgPixel );

-public static final native int XmGetPixmapByDepth (int screen, byte [] image_name, int foreground, int background, int depth);

 public static final native int XmGetXmDisplay (int display);

 public static final native int XmImMbLookupString (int widget, XKeyEvent event, byte [] string, int size, int [] keysym, int [] status);

 public static final native int XmInternAtom (int display, byte [] name, boolean only_if_exists);

@@ -1148,7 +1102,7 @@
 public static final native void XmTextShowPosition (int widget, int position);

 public static final native void XmUpdateDisplay (int widget);

 public static final native boolean XmWidgetGetDisplayRect (int region, XRectangle rectangle);

-//public static final native int XmbLookupString (int ic, XKeyEvent event, byte [] string, int size, int [] keysym, int [] status);

+public static final native int XmbLookupString (int ic, XKeyEvent event, byte [] string, int size, int [] keysym, int [] status);

 public static final native void XtAddCallback (int widget, int callback_name, int callback, int client_data);

 public static final native void XtAddEventHandler (int widget, int event_mask, boolean nonmaskable, int proc, int client_data);

 public static final native void XtAddExposureToRegion (int event, int region);

@@ -1258,6 +1212,7 @@
 public static final native void memmove (byte [] dest, int src, int count);

 public static final native void memmove (int [] dest, int src, int count);

 public static final native int strlen (int string);

+public static final native int XpmReadFileToPixmap(int display, int drawable, byte[] fileName, int[] pixmap_return, int[] shapemask_return, int attributes);

 public static final native int XmCreateDrawnButton (int parent, byte [] name, int [] arglist, int argcount);

 public static final native int XCheckIfEvent (int display, XAnyEvent event_return, int predicate, int arg);

 public static final native boolean XtToolkitThreadInitialize ();

@@ -1302,47 +1257,19 @@
 /*

  * ======== End of printing constants and functions ========

  */

-

-public static final native int pipe (int [] filedes);

-public static final native int read (int filedes, byte [] buf, int nbyte);

-public static final native int write (int filedes, byte [] buf, int nbyte);

-public static final native int close (int filedes);

-public static final native int XtAppAddInput (int app_context, int source, int condition, int proc, int client_data);

-public static final native void XtRemoveInput (int id);

-//	public static final int XtInputNoneMask = 0;

-	public static final int XtInputReadMask = 1;

-//	public static final int XtInputWriteMask = 2;

+
+public static final native int pipe (int [] filedes);
+public static final native int read (int filedes, byte [] buf, int nbyte);
+public static final native int write (int filedes, byte [] buf, int nbyte);
+public static final native int close (int filedes);
+public static final native int XtAppAddInput (int app_context, int source, int condition, int proc, int client_data);
+public static final native void XtRemoveInput (int id);
+//	public static final int XtInputNoneMask = 0;
+	public static final int XtInputReadMask = 1;
+//	public static final int XtInputWriteMask = 2;
 //	public static final int XtInputExceptMask = 4;

 

 public static final native int XLoadQueryFont (int display, byte[] name);

 public static final native int XmFontListEntryCreate (byte[] tag, int type, int font);

-

-public static final native int XmImGetXIC (int widget, int input_policy, int[] args, int num_args);

-public static final native int XmImGetXIM (int widget);

-public static final native void XmImRegister (int widget, int reserved);

-//public static final native int XmImSetFocusValues (int widget, int[] args, int num_args);

-public static final native int XmImVaSetFocusValues(int widget, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9);

-public static final native int XmImSetValues (int widget, int[] args, int num_args);

-public static final native void XmImUnregister (int widget);

-public static final native void XmImUnsetFocus (int widget);

-//public static final native void XSetICFocus (int ic);

-//public static final native void XUnsetICFocus (int ic);

-//public static final native int XCreateIC (int im, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7);

-//public static final native int XSetICValues (int ic, int arg1, int arg2, int arg3);

-//public static final native int XGetICValues (int ic, int arg1, int arg2, int arg3);

-//public static final native int XGetIMValues (int im, int arg1, int arg2, int arg3);

-public static final native void memmove (int dest, short [] src, int count);

-//public static final native void memmove (char[] dest, int src, int count);

-//public static final native void memmove ( int dest, char[] src,int count);

-

-public static final native int nl_langinfo (int item);

-public static final native int iconv_open (byte[] tocode, byte[] fromcode);

-public static final native int iconv_close (int cd);

-public static final native int iconv (int cd, int[] inBuf, int[] inBytesLeft, int[] outBuf, int[] outBytesLeft);

-public static final native int MB_CUR_MAX ();

-public static final native int setlocale (int category, byte[] locale);

-

-public static final native int XCreateFontSet (int display, byte [] base_font_name_list, int [] missing_charset_list_return, int [] missing_charset_count_return, int [] def_string_return);

-public static final native int XLocaleOfFontSet (int fontSet);

-

+
 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/AbstractTreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/AbstractTreeItem.java
new file mode 100755
index 0000000..41f7d95
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/AbstractTreeItem.java
@@ -0,0 +1,313 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+

+import org.eclipse.swt.*;

+import org.eclipse.swt.graphics.*;

+import java.util.*;

+

+/** 

+ * This class stores and manages child items of a tree item.

+ * It provides protocol to query the index of an item relative 

+ * to the root and to retrieve items by index.

+ * The TreeItem class implements this protocol for general

+ * tree items.

+ * TreeRoots provides a special implementation that allows the 

+ * Tree class to treat trees with one root and with multiple 

+ * roots equally.

+ */

+abstract class AbstractTreeItem extends SelectableItem {

+	private Vector children;

+	private boolean isExpanded = false;		

+	// number of children. 

+	// includes all expanded items down to the leafs.

+	private int visibleItemCount = 0;

+

+/**

+ * Create a new instance of the receiver.

+ * @param parent - widget the receiver belongs to

+ * @param swtStyle - widget style. see Widget class for details

+ */

+AbstractTreeItem(Tree parent, int swtStyle) {

+	super(parent, swtStyle);

+}

+/**

+ * Insert 'item' in the list of child items. Notify the 

+ * parent about the new item.

+ * @param 'item' - the item that should be added to the 

+ *	receiver's children.

+ * @param index - position that 'item' will be inserted at

+ *	in the receiver.

+ */

+void add(TreeItem item, int index) {

+	Vector items = getChildren();

+	int visibleIndex = getVisibleIndex();

+	

+	if (index < 0 || index > items.size()) {

+		error(SWT.ERROR_INVALID_RANGE);

+	}

+	if (item.isRoot()) {

+		visibleIndex = index;

+	}

+	else

+	if (isExpanded == false) {

+		visibleIndex = -1;

+	}

+	if (visibleIndex != -1) {

+		if (index > 0) {

+			TreeItem previousChild = (TreeItem) getChildren().elementAt(index - 1);

+			visibleIndex = previousChild.getVisibleIndex() + previousChild.getVisibleItemCount() + 1;

+		}

+		else {

+			 visibleIndex = getVisibleIndex() + 1;

+		}

+	}

+	getSelectableParent().addingItem(item, visibleIndex);

+	item.setIndex(index);

+	resetChildIndices(index, true);

+	items.insertElementAt(item, index);

+	if (isExpanded == true) {

+		visibleItemCount++;

+		calculateVisibleItemCountParent();

+	}

+	getSelectableParent().addedItem(item, visibleIndex);

+}

+/** 

+ * Set whether the receiver is expanded or not. 

+ * If the receiver is expanded its child items are visible.

+ * @param expanded - 

+ *	true=the receiver is expanded, making its child items visible.

+ * 	false=the receiver is collapsed, making its child items invisible 

+ */

+void internalSetExpanded(boolean expanded) {

+	isExpanded = expanded;

+	calculateVisibleItemCount();

+}

+/**

+ * Calculate the number of expanded children.

+ * Recurse up in the tree to the root item.

+ */

+abstract void calculateVisibleItemCount();

+/**

+ * Calculate the number of expanded children for the parent item

+ * of this item.

+ */

+abstract void calculateVisibleItemCountParent();

+/**

+ * Deselect the receiver and all children

+ */

+void deselectAll() {

+	Enumeration children = getChildren().elements();

+	AbstractTreeItem treeItem;

+

+	setSelected(false);

+	while (children.hasMoreElements() == true) {

+		treeItem = (AbstractTreeItem) children.nextElement();

+		treeItem.deselectAll();

+	}

+}

+public void dispose() {

+	if (!isValidWidget ()) return;

+	Vector children = getChildren();

+	AbstractTreeItem child;

+	while (children.size() > 0) {		// TreeItem objects are removed from vector during dispose

+		child = (AbstractTreeItem) children.firstElement();

+		child.dispose();

+	}

+	super.dispose();

+}

+void doDispose() {

+	setChildren(null);

+	visibleItemCount = 0;

+	super.doDispose();

+}

+/**

+ * Answer the Vector containing the child items of the receiver.

+ */

+Vector getChildren() {

+	if (children == null) {

+		children = new Vector(4);

+	}

+	return children;

+}

+/**

+ * Answer whether the receiver is expanded or not. 

+ * If the receiver is expanded its children are visible.

+ * @return 

+ *	true - the receiver is expanded, making its children visible

+ * 	false - the receiver is collapsed, making its children invisible 

+ */

+public boolean getExpanded() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return isExpanded;

+}

+/**

+ * Answer the number of children.

+ */

+public int getItemCount() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return getChildren().size();

+}

+/**

+ * Answer the index of the receiver relative to the first root 

+ * item.

+ * If 'anIndex' is the global index of the expanded item 'anItem' 

+ * then the following expressions are true:

+ * 'anItem  == theRoot.getVisibleItem(anIndex)' and

+ * 'anIndex == anItem.getVisibleIndex()'

+ * @return

+ *	The index of the receiver relative to the first root item.

+ *	Answer -1 if the receiver is not visible (because the parent 

+ *	is collapsed).

+ */

+abstract int getVisibleIndex();

+/**

+ * Answer the index of the child item identified by 'childIndex' 

+ * relative to the first root item.

+ */

+abstract int getVisibleIndex(int childIndex);

+/**

+ * Answer the item at 'searchIndex' relativ to the receiver.

+ * When this method is called for the root item, 'searchIndex' 

+ * represents the global index into all items of the tree.

+ * searchIndex=0 returns the receiver. 

+ * searchIndex=1 returns the first visible child.

+ * Note: searchIndex must be >= 0

+ *

+ * Note: 

+ * Visible in this context does not neccessarily mean that the 

+ * item is displayed on the screen. Visible here means that all 

+ * the parents of the item are expanded. An item is only 

+ * visible on screen if it is within the receiver's parent's 

+ * client area.

+ */

+abstract TreeItem getVisibleItem(int searchIndex);

+/**

+ * Answer the number of expanded children, direct and indirect.

+ */

+int getVisibleItemCount() {

+	return visibleItemCount;

+}

+/**

+ * Returns the expanded state. Circumvent widget/thread check 

+ * for performance. For non-API callers only.

+ */

+boolean internalGetExpanded() {

+	return isExpanded;

+}

+/**

+ * Answer whether the receiver is a leaf item.

+ * An item is a leaf when it has no child items.

+ * @return

+ *	true - receiver is a leaf item

+ *	false - receiver is not a leaf item.

+ */

+boolean isLeaf() {

+	return (getChildren().size() == 0);

+}

+/**

+ * Answer whether the receiver is a root item.

+ * The receiver is a root item when it doesn't have a parent item.

+ * @return 

+ *	true - the receiver is a root item.

+ * 	false - the receiver is not a root item.

+ */

+boolean isRoot() {

+	return false;

+}

+/** 

+ * Remove 'child' from the receiver. 

+ * Notify the parent widget only if it is not being disposed itself.

+ */

+void removeItem(SelectableItem child) {

+	Vector children = getChildren();

+	SelectableItemWidget parent = getSelectableParent();

+	int childIndex = children.indexOf(child);

+

+	if (childIndex != -1) {

+		if (((Tree) parent).isRemovingAll() == true) {

+			children.removeElementAt(childIndex);		// just remove the item from the list if the whole tree is being disposed

+			if (isExpanded == true) {

+				visibleItemCount--;

+				calculateVisibleItemCountParent();

+			}

+		}

+		else {

+			parent.removingItem(child);	

+			children.removeElementAt(childIndex);

+			if (isExpanded == true) {

+				visibleItemCount--;

+				calculateVisibleItemCountParent();

+			}

+			resetChildIndices(childIndex, false);						// mark child index dirty

+			parent.removedItem(child);

+		}

+	}

+}

+/**

+ * Allow subclasses to reset any cached data.

+ * Called for all children of the receiver.

+ */

+void reset() {

+	Enumeration children = getChildren().elements();

+	AbstractTreeItem treeItem;

+

+	while (children.hasMoreElements() == true) {

+		treeItem = (AbstractTreeItem) children.nextElement();

+		treeItem.reset();

+	}

+}

+/**

+ * Mark all child indices dirty starting with the child at 

+ * 'startIndex'. This causes getIndex to recalculate the index.

+ * @param startIndex - index in the list of children at which 

+ *	and after which the indices are reset.

+ */

+void resetChildIndices(int startIndex, boolean addItem) {

+	Vector children = getChildren();

+	TreeItem child;

+	int increment = addItem ? 1 : 0;

+

+	for (int i = startIndex; i < children.size(); i++) {

+		child = (TreeItem) children.elementAt(i);

+		child.setIndex(i + increment);								// mark child index dirty

+	}

+}

+/**

+ * Select the receiver and all children.

+ * Return a Vector containing all the items that have been selected 

+ * (and that have not been selected before).

+ */

+Vector selectAll(Vector selectedItems) {

+	Enumeration children = getChildren().elements();

+	AbstractTreeItem treeItem;

+

+	if (isSelected() == false) {

+		selectedItems.addElement(this);

+		setSelected(true);

+		getSelectableParent().redrawSelection(this);

+	}

+	while (children.hasMoreElements() == true) {

+		treeItem = (AbstractTreeItem) children.nextElement();

+		selectedItems = treeItem.selectAll(selectedItems);

+	}

+	return selectedItems;

+}

+/**

+ * Set the Array containing the receiver's child items to 'children'.

+ */

+void setChildren(Vector children) {

+	this.children = children;

+}

+

+void setVisibleItemCount(int count) {

+	visibleItemCount = count;

+}

+}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java
index bfcb36a..ebacd6a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java
@@ -11,20 +11,20 @@
 import org.eclipse.swt.graphics.*;

 import org.eclipse.swt.events.*;

 

-/**

- * Instances of this class represent a selectable user interface object that

- * issues notification when pressed and released. 

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>ARROW, CHECK, PUSH, RADIO, TOGGLE, FLAT</dd>

- * <dd>LEFT, RIGHT, CENTER</dd>

- * <dt><b>Events:</b></dt>

- * <dd>Selection</dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is intended to be subclassed <em>only</em>

- * within the SWT implementation.

- * </p>

+/**
+ * Instances of this class represent a selectable user interface object that
+ * issues notification when pressed and released. 
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>ARROW, CHECK, PUSH, RADIO, TOGGLE, FLAT</dd>
+ * <dd>LEFT, RIGHT, CENTER</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
  */

 

 public /*final*/ class Button extends Control {

@@ -41,33 +41,33 @@
 		}

 		ARM_AND_ACTIVATE = buffer;

 	}

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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

+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <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
+ *
+ * @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 Button (Composite parent, int style) {

 	super (parent, checkStyle (style));

@@ -97,7 +97,8 @@
  * @see SelectionEvent

  */

 public void addSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener(listener);

 	addListener(SWT.Selection,typedListener);

@@ -123,7 +124,8 @@
 * Computes the preferred size.

 */

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int border = getBorderWidth ();

 	int width = border * 2, height = border * 2;

 	if ((style & SWT.ARROW) != 0) {

@@ -281,24 +283,25 @@
 int defaultForeground () {

 	return getDisplay ().buttonForeground;

 }

-/**

- * Returns a value which describes the position of the

- * text or image in the receiver. The value will be one of

- * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>

- * unless the receiver is an <code>ARROW</code> button, in 

- * which case, the alignment will indicate the direction of

- * the arrow (one of <code>LEFT</code>, <code>RIGHT</code>, 

- * <code>UP</code> or <code>DOWN</code>.

- *

- * @return the alignment 

- *

- * @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 value which describes the position of the
+ * text or image in the receiver. The value will be one of
+ * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
+ * unless the receiver is an <code>ARROW</code> button, in 
+ * which case, the alignment will indicate the direction of
+ * the arrow (one of <code>LEFT</code>, <code>RIGHT</code>, 
+ * <code>UP</code> or <code>DOWN</code>.
+ *
+ * @return the alignment 
+ *
+ * @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 getAlignment () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.ARROW) != 0) {

 		int [] argList = {OS.XmNarrowDirection, 0};

 		OS.XtGetValues (handle, argList, argList.length / 2);

@@ -323,64 +326,67 @@
 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1] != 0;

 }

-/**

- * Returns the receiver's image if it has one, or null

- * if it does not.

- *

- * @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>

+/**
+ * Returns the receiver's image if it has one, or null
+ * if it does not.
+ *
+ * @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();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return image;

 }

 String getNameText () {

 	return getText ();

 }

-/**

- * Returns <code>true</code> if the receiver is selected,

- * and false otherwise.

- * <p>

- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,

- * it is selected when it is checked. When it is of type <code>TOGGLE</code>,

- * it is selected when it is pushed.

- *

- * @return the selection 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 selected,
+ * and false otherwise.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
+ * it is selected when it is pushed.
+ *
+ * @return the selection 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 getSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;

 	int [] argList = {OS.XmNset, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1] != 0;

 }

-/**

- * Returns the receiver's text, which will be an empty

- * string if it has never been set.

- *

- * @return the receiver's text

- *

- * @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 the receiver's text, which will be an empty
+ * string if it has never been set.
+ *
+ * @return the receiver's text
+ *
+ * @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 String getText () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.ARROW) != 0) return "";

 	int [] argList = {OS.XmNlabelString, 0, OS.XmNmnemonic, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

-	int xmString = argList [1];

-	int mnemonic = argList [3];

+	int xmString = argList [1];
+	int mnemonic = argList [3];
 	if (mnemonic == OS.XK_VoidSymbol) mnemonic = 0;

 	if (xmString == 0) error (SWT.ERROR_CANNOT_GET_TEXT);

 	char [] result = null;	

@@ -397,7 +403,7 @@
 		byte [] buffer = new byte [length];

 		OS.memmove (buffer, address, length);

 		OS.XtFree (address);

-		result = Converter.mbcsToWcs (getCodePage (), buffer);

+		result = Converter.mbcsToWcs (null, buffer);

 	}	

 	if (xmString != 0) OS.XmStringFree (xmString);

 	int count = 0;

@@ -471,25 +477,26 @@
 	if (disabled != null) disabled.dispose ();

 	image = bitmap = disabled = null; 

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the control is selected.

- *

- * @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 SelectionListener

- * @see #addSelectionListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected.
+ *
+ * @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 SelectionListener
+ * @see #addSelectionListener
  */

 public void removeSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook(SWT.Selection, listener);

@@ -511,24 +518,25 @@
 	}

 	setSelection (true);

 }

-/**

- * Controls how text, images and arrows will be displayed

- * in the receiver. The argument should be one of

- * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>

- * unless the receiver is an <code>ARROW</code> button, in 

- * which case, the argument indicates the direction of

- * the arrow (one of <code>LEFT</code>, <code>RIGHT</code>, 

- * <code>UP</code> or <code>DOWN</code>.

- *

- * @param alignment the new alignment 

- *

- * @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>

+/**
+ * Controls how text, images and arrows will be displayed
+ * in the receiver. The argument should be one of
+ * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
+ * unless the receiver is an <code>ARROW</code> button, in 
+ * which case, the argument indicates the direction of
+ * the arrow (one of <code>LEFT</code>, <code>RIGHT</code>, 
+ * <code>UP</code> or <code>DOWN</code>.
+ *
+ * @param alignment the new alignment 
+ *
+ * @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 setAlignment (int alignment) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.ARROW) != 0) {

 		int [] argList = {OS.XmNarrowDirection, OS.XmARROW_UP};

 		if ((alignment & SWT.UP) != 0) argList [1] = OS.XmARROW_UP;

@@ -557,7 +565,6 @@
 	if (disabled != null) disabled.dispose ();

 	bitmap = disabled = null;

 	if (image != null) {

-		if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 		Display display = getDisplay ();

 		switch (image.type) {

 			case SWT.BITMAP:

@@ -594,63 +601,63 @@
 	int [] argList = {OS.XmNshowAsDefault, (value ? 1 : 0)};

 	OS.XtSetValues (handle, argList, argList.length / 2);

 }

-/**

- * Sets the receiver's image to the argument, which may be

- * null indicating that no image should be displayed.

- *

- * @param image the image to display on the receiver (may be null)

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the image 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>

+/**
+ * Sets the receiver's image to the argument, which may be
+ * null indicating that no image should be displayed.
+ *
+ * @param image the image to display on the receiver (may be null)
+ *
+ * @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 setImage (Image image) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	setBitmap (this.image = image);

 }

-/**

- * Sets the selection state of the receiver.

- * <p>

- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,

- * it is selected when it is checked. When it is of type <code>TOGGLE</code>,

- * it is selected when it is pushed.

- *

- * @param selected the new selection 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>

+/**
+ * Sets the selection state of the receiver.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
+ * it is selected when it is pushed.
+ *
+ * @param selected the new selection 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 void setSelection (boolean selected) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;

 	int [] argList = {OS.XmNset, selected ? 1 : 0};

 	OS.XtSetValues (handle, argList, argList.length / 2);

 }

-/**

- * Sets the receiver's text.

- * <p>

- * This method sets the button label.  The label may include

- * the mnemonic character but must not contain line delimiters.

- * </p>

- * 

- * @param string the new text

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the text 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>

+/**
+ * Sets the receiver's text.
+ * <p>
+ * This method sets the button label.  The label may include
+ * the mnemonic character but must not contain line delimiters.
+ * </p>
+ * 
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text 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>
  */

 public void setText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if ((style & SWT.ARROW) != 0) return;

 	char [] text = new char [string.length ()];

@@ -665,7 +672,7 @@
 		}

 	}

 	while (j < text.length) text [j++] = 0;

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), text, true);

+	byte [] buffer = Converter.wcsToMbcs (null, text, true);

 	int xmString = OS.XmStringParseText (

 		buffer,

 		0,

@@ -674,7 +681,7 @@
 		null,

 		0,

 		0);	

-	if (xmString == 0) error (SWT.ERROR_CANNOT_SET_TEXT);

+	if (xmString == 0) error (SWT.ERROR_CANNOT_SET_TEXT);
 	if (mnemonic == 0) mnemonic = OS.XK_VoidSymbol;

 	int [] argList = {

 		OS.XmNlabelType, OS.XmSTRING,

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java
index 79336fa..f8e2d31 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java
@@ -9,58 +9,58 @@
 import org.eclipse.swt.*;

 import org.eclipse.swt.graphics.*;

 

-/**

- * Instances of this class provide a surface for drawing

- * arbitrary graphics.

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>(none)</dd>

- * <dt><b>Events:</b></dt>

- * <dd>(none)</dd>

- * </dl>

- * <p>

- * This class may be subclassed by custom control implementors

- * who are building controls that are <em>not</em> constructed

- * from aggregates of other controls. That is, they are either

- * painted using SWT graphics calls or are handled by native

- * methods.

- * </p>

- *

- * @see Composite

- */

+/**
+ * Instances of this class provide a surface for drawing
+ * arbitrary graphics.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * This class may be subclassed by custom control implementors
+ * who are building controls that are <em>not</em> constructed
+ * from aggregates of other controls. That is, they are either
+ * painted using SWT graphics calls or are handled by native
+ * methods.
+ * </p>
+ *
+ * @see Composite
+ */
 public class Canvas extends Composite {

 	Caret caret;

 	

 Canvas () {

 	/* Do nothing */

 }

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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

+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <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
+ *
+ * @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 Canvas (Composite parent, int style) {

 	super (parent, style);

@@ -69,35 +69,30 @@
 	super.createWidget (index);

 	fontList = defaultFont ();

 }

-/**

- * Returns the caret.

- * <p>

- * The caret for the control is automatically hidden

- * and shown when the control is painted or resized,

- * when focus is gained or lost and when an the control

- * is scrolled.  To avoid drawing on top of the caret,

- * the programmer must hide and show the caret when

- * drawing in the window any other time.

- * </p>

- *

- * @return the caret

- *

- * @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 the caret.
+ * <p>
+ * The caret for the control is automatically hidden
+ * and shown when the control is painted or resized,
+ * when focus is gained or lost and when an the control
+ * is scrolled.  To avoid drawing on top of the caret,
+ * the programmer must hide and show the caret when
+ * drawing in the window any other time.
+ * </p>
+ *
+ * @return the caret
+ *
+ * @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 Caret getCaret () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return caret;

 }

 

-short [] getIMECaretPos () {

-	if (caret == null) return super.getIMECaretPos ();

-	int width = caret.width;

-	if (width <= 0) width = 2;

-	return new short[]{(short) (caret.x + width), (short) (caret.y + caret.height)};

-}

 int processFocusIn () {

 	int result = super.processFocusIn ();

 	if (caret != null) caret.setFocus ();

@@ -133,30 +128,31 @@
 	super.releaseWidget();

 }

 

-/**

- * Scrolls a rectangular area of the receiver by first copying 

- * the source area to the destination and then causing the area

- * of the source which is not covered by the destination to

- * be repainted. Children that intersect the rectangle are

- * optionally moved during the operation. In addition, outstanding

- * paint events are flushed before the source area is copied to

- * ensure that the contents of the canvas are drawn correctly.

- *

- * @param destX the x coordinate of the destination

- * @param destY the y coordinate of the destination

- * @param x the x coordinate of the source

- * @param y the y coordinate of the source

- * @param width the width of the area

- * @param height the height of the area

- * @param all <code>true</code>if children should be scrolled, and <code>false</code> 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>

- */

+/**
+ * Scrolls a rectangular area of the receiver by first copying 
+ * the source area to the destination and then causing the area
+ * of the source which is not covered by the destination to
+ * be repainted. Children that intersect the rectangle are
+ * optionally moved during the operation. In addition, outstanding
+ * paint events are flushed before the source area is copied to
+ * ensure that the contents of the canvas are drawn correctly.
+ *
+ * @param destX the x coordinate of the destination
+ * @param destY the y coordinate of the destination
+ * @param x the x coordinate of the source
+ * @param y the y coordinate of the source
+ * @param width the width of the area
+ * @param height the height of the area
+ * @param all <code>true</code>if children should be scrolled, and <code>false</code> 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 void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (width <= 0 || height <= 0) return;

 	int deltaX = destX - x, deltaY = destY - y;

 	if (deltaX == 0 && deltaY == 0) return;

@@ -201,68 +197,56 @@
 	if (isFocus) caret.setFocus ();

 }

 public void setBounds (int x, int y, int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	boolean isFocus = caret != null && caret.isFocusCaret ();

 	if (isFocus) caret.killFocus ();

 	super.setBounds (x, y, width, height);

 	if (isFocus) caret.setFocus ();

 }

-/**

- * Sets the receiver's caret.

- * <p>

- * The caret for the control is automatically hidden

- * and shown when the control is painted or resized,

- * when focus is gained or lost and when an the control

- * is scrolled.  To avoid drawing on top of the caret,

- * the programmer must hide and show the caret when

- * drawing in the window any other time.

- * </p>

- * @param caret the new caret for the receiver, may be null

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the caret 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>

+/**
+ * Sets the receiver's caret.
+ * <p>
+ * The caret for the control is automatically hidden
+ * and shown when the control is painted or resized,
+ * when focus is gained or lost and when an the control
+ * is scrolled.  To avoid drawing on top of the caret,
+ * the programmer must hide and show the caret when
+ * drawing in the window any other time.
+ * </p>
+ * @param caret the new caret for the receiver
+ *
+ * @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 setCaret (Caret caret) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	Caret newCaret = caret;

 	Caret oldCaret = this.caret;

 	this.caret = newCaret;

 	if (hasFocus ()) {

 		if (oldCaret != null) oldCaret.killFocus ();

-		if (newCaret != null) {

-			if (newCaret.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

-			newCaret.setFocus ();

-		}

+		if (newCaret != null) newCaret.setFocus ();

 	}

 }

 

 public void setLocation (int x, int y) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	boolean isFocus = caret != null && caret.isFocusCaret ();

 	if (isFocus) caret.killFocus ();

 	super.setLocation (x, y);

 	if (isFocus) caret.setFocus ();

 }

 public void setSize (int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	boolean isFocus = caret != null && caret.isFocusCaret ();

 	if (isFocus) caret.killFocus ();

 	super.setSize (width, height);

 	if (isFocus) caret.setFocus ();

 }

-void updateCaret () {

-	if (caret == null) return;

-	if (!IsDBLocale) return;

-	short [] point = getIMECaretPos ();

-	int ptr = OS.XtMalloc (4);

-	OS.memmove (ptr, point, 4);

-	int[] argList = {OS.XmNspotLocation, ptr};

-	OS.XmImSetValues (handle, argList, argList.length / 2);

-	if (ptr != 0) OS.XtFree (ptr);

-}

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Caret.java
index 3ea6d6e..5274b44 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Caret.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Caret.java
@@ -9,19 +9,19 @@
 import org.eclipse.swt.*;

 import org.eclipse.swt.graphics.*;

 

-/**

- * Instances of this class provide an i-beam that is typically used

- * as the insertion point for text.

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>(none)</dd>

- * <dt><b>Events:</b></dt>

- * <dd>(none)</dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is intended to be subclassed <em>only</em>

- * within the SWT implementation.

- * </p>

+/**
+ * Instances of this class provide an i-beam that is typically used
+ * as the insertion point for text.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
  */

 

 public /*final*/ class Caret extends Widget {

@@ -30,33 +30,33 @@
 	boolean moved, resized;

 	boolean isVisible, isShowing;

 	int blinkRate = 500;

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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

+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <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
+ *
+ * @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 Caret (Canvas parent, int style) {

 	super (parent, style);

@@ -97,19 +97,20 @@
 	OS.XFreeGC (xDisplay, 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).

- *

- * @return the receiver's bounding 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 (or its display if its parent is null).
+ *
+ * @return the receiver's bounding 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 () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return new Rectangle (x, y, width, height);

 }

 /**

@@ -120,82 +121,87 @@
 	if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent.getDisplay ();

 }

-/**

- * Returns the font that the receiver will use to paint textual information.

- *

- * @return the receiver's font

- *

- * @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 the font that the receiver will use to paint textual information.
+ *
+ * @return the receiver's font
+ *
+ * @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 Font getFont () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent.getFont ();

 }

-/**

- * Returns a point describing the receiver's location relative

- * to its parent (or its display if its parent is null).

- *

- * @return the receiver's location

- *

- * @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 point describing the receiver's location relative
+ * to its parent (or its display if its parent is null).
+ *
+ * @return the receiver's location
+ *
+ * @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 Point getLocation () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return new Point (x, y);

 }

-/**

- * Returns the receiver's parent, which must be a <code>Canvas</code>.

- *

- * @return the receiver's parent

- *

- * @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 the receiver's parent, which must be a <code>Canvas</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @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 Canvas getParent () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent;

 }

-/**

- * Returns a point describing the receiver's size.

- *

- * @return the receiver's size

- *

- * @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 point describing the receiver's size.
+ *
+ * @return the receiver's size
+ *
+ * @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 Point getSize () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return new Point (width, height);

 }

-/**

- * Returns <code>true</code> if the receiver is visible, and

- * <code>false</code> otherwise.

- * <p>

- * If one of the receiver's ancestors is not visible or some

- * other condition makes the receiver not visible, this method

- * may still indicate that it is considered visible even though

- * it may not actually be showing.

- * </p>

- *

- * @return the receiver's visibility 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 visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility 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 getVisible () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return isVisible;

 }

 boolean hideCaret () {

@@ -205,25 +211,26 @@
 	isShowing = false;

 	return drawCaret ();

 }

-/**

- * Returns <code>true</code> if the receiver is visible, and

- * <code>false</code> otherwise.

- * <p>

- * If one of the receiver's ancestors is not visible or some

- * other condition makes the receiver not visible, this method

- * may still indicate that it is considered visible even though

- * it may not actually be showing.

- * </p>

- *

- * @return the receiver's visibility 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 visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility 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 isVisible () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return isVisible && parent.isVisible () && parent.hasFocus ();

 }

 boolean isFocusCaret () {

@@ -249,24 +256,25 @@
 	}

 	parent = null;

 }

-/**

- * Sets the receiver's size and location to the rectangular

- * area specified by the arguments. The <code>x</code> and 

- * <code>y</code> arguments are relative to the receiver's

- * parent (or its display if its parent is null).

- *

- * @param x the new x coordinate for the receiver

- * @param y the new y coordinate for the receiver

- * @param width the new width for the receiver

- * @param height the new height for the receiver

- *

- * @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>

+/**
+ * Sets the receiver's size and location to the rectangular
+ * area specified by the arguments. The <code>x</code> and 
+ * <code>y</code> arguments are relative to the receiver's
+ * parent (or its display if its parent is null).
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ * @param width the new width for the receiver
+ * @param height the new height for the receiver
+ *
+ * @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 setBounds (int x, int y, int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	boolean samePosition, sameExtent, showing;

 	samePosition = (this.x == x) && (this.y == y);

 	sameExtent = (this.width == width) && (this.height == height);

@@ -278,33 +286,36 @@
 			moved = true;

 			if (isVisible ()) {

 				moved = false;

-				parent.updateCaret ();

+				//IsDBLocale ifTrue: [

+				//widget == nil ifFalse: [widget updateCaret]].

 			}

 	} else {

 			resized = true;

 			if (isVisible ()) {

 				moved = false;

-				parent.updateCaret ();

+				//IsDBLocale ifTrue: [

+				//widget == nil ifFalse: [widget updateCaret]].

 				resized = false;

 			}

 	}

 	if (isShowing) showCaret ();

 }

-/**

- * Sets the receiver's size and location to the rectangular

- * area specified by the argument. The <code>x</code> and 

- * <code>y</code> fields of the rectangle are relative to

- * the receiver's parent (or its display if its parent is null).

- *

- * @param rect the new bounds for the receiver

- *

- * @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>

+/**
+ * Sets the receiver's size and location to the rectangular
+ * area specified by the argument. The <code>x</code> and 
+ * <code>y</code> fields of the rectangle are relative to
+ * the receiver's parent (or its display if its parent is null).
+ *
+ * @param rect the new bounds for the receiver
+ *
+ * @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 setBounds (Rectangle rect) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);

 	setBounds (rect.x, rect.y, rect.width, rect.height);

 }

@@ -314,107 +325,113 @@
 	display.setCurrentCaret (this);

 	if (isVisible) showCaret ();

 }

-/**

- * Sets the font that the receiver will use to paint textual information

- * to the font specified by the argument, or to the default font for that

- * kind of control if the argument is null.

- *

- * @param font the new font (or null)

- *

- * @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>

+/**
+ * Sets the font that the receiver will use to paint textual information
+ * to the font specified by the argument, or to the default font for that
+ * kind of control if the argument is null.
+ *
+ * @param font the new font (or null)
+ *
+ * @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 setFont (Font font) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 }

-/**

- * Sets the receiver's location to the point specified by

- * the arguments which are relative to the receiver's

- * parent (or its display if its parent is null).

- *

- * @param x the new x coordinate for the receiver

- * @param y the new y coordinate for the receiver

- *

- * @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>

+/**
+ * Sets the receiver's location to the point specified by
+ * the arguments which are relative to the receiver's
+ * parent (or its display if its parent is null).
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ *
+ * @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 setLocation (int x, int y) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	setBounds (x, y, width, height);

 }

-/**

- * Sets the receiver's location to the point specified by

- * the argument which is relative to the receiver's

- * parent (or its display if its parent is null).

- *

- * @param location the new location for the receiver

- *

- * @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>

+/**
+ * Sets the receiver's location to the point specified by
+ * the argument which is relative to the receiver's
+ * parent (or its display if its parent is null).
+ *
+ * @param location the new location for the receiver
+ *
+ * @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 setLocation (Point location) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	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.

- *

- * @param width the new width for the receiver

- * @param height the new height for the receiver

- *

- * @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>

+/**
+ * Sets the receiver's size to the point specified by the arguments.
+ *
+ * @param width the new width for the receiver
+ * @param height the new height for the receiver
+ *
+ * @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 setSize (int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	setBounds (x, y, width, height);

 }

-/**

- * Sets the receiver's size to the point specified by the argument.

- *

- * @param size the new extent for the receiver

- * @param height the new height for the receiver

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the point 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>

+/**
+ * Sets the receiver's size to the point specified by the argument.
+ *
+ * @param size the new extent for the receiver
+ * @param height the new height for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point 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>
  */

 public void setSize (Point size) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	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. 

- * <p>

- * If one of the receiver's ancestors is not visible or some

- * other condition makes the receiver not visible, marking

- * it visible may not actually cause it to be displayed.

- * </p>

- *

- * @param visible the new visibility 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>

+/**
+ * Marks the receiver as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility 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 void setVisible (boolean visible) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);	

 	if (visible == isVisible) return;

 	if (isVisible = visible) {

 		showCaret ();

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ColorDialog.java
index 0226056..c598a52 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ColorDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ColorDialog.java
@@ -9,19 +9,19 @@
 import org.eclipse.swt.graphics.*;

 import org.eclipse.swt.layout.*;

 

-/**

- * Instances of this class allow the user to select a color

- * from a predefined set of available colors.

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>(none)</dd>

- * <dt><b>Events:</b></dt>

- * <dd>(none)</dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is intended to be subclassed <em>only</em>

- * within the SWT implementation.

- * </p>

+/**
+ * Instances of this class allow the user to select a color
+ * from a predefined set of available colors.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
  */

 public /*final*/ class ColorDialog extends Dialog {

 	private static final int DEPTH_4 = 0;				// index for COLOR_SWATCH_EXTENTS

@@ -41,60 +41,60 @@
 

 	private boolean okSelected;							// true if the dialog was hidden 

 														// because the ok button was selected

-	private RGB rgb;

+	private RGB dialogResult;													

 	private int colorDepth;								// color depth of the display

 	private int colorSwatchExtent;						// the size of on square used 

 														// to display one color

 	private Color colorGrid[][];						// the colors displayed in the dialog

 	

-/**

- * Constructs a new instance of this class given only its parent.

- *

- * @param parent a composite control which will be the parent of the new instance (cannot be null)

- *

- * @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

- */

+/**
+ * Constructs a new instance of this class given only its parent.
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ *
+ * @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 ColorDialog(Shell parent) {

 	this(parent, SWT.NULL);

 }

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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

- */

+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <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
+ *
+ * @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 ColorDialog(Shell parent, int style) {

 	super(parent, style | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);

 }

@@ -197,6 +197,10 @@
 		}

 	}

 }

+/**

+ * Insert the method's description here.

+ * Creation date: (7/6/99 5:07:09 PM)

+ */

 void drawColor(int xIndex, int yIndex, Color color, GC gc) {

 	int colorSwatchExtent = getColorSwatchExtent();

 	int colorExtent = colorSwatchExtent - COLOR_SWATCH_BORDER;

@@ -206,37 +210,69 @@
 		xIndex * colorSwatchExtent, yIndex * colorSwatchExtent, 

 		colorExtent, colorExtent);

 }

+/**

+ * Insert the method's description here.

+ * Creation date: (7/6/99 5:07:09 PM)

+ */

 Canvas getColorCanvas() {

 	return colorsCanvas;

 }

+/**

+ * Insert the method's description here.

+ * Creation date: (7/6/99 5:07:09 PM)

+ */

 int getColorDepth() {

 	return colorDepth;

 }

+/**

+ * Insert the method's description here.

+ * Creation date: (7/6/99 5:07:09 PM)

+ */

 Color [][] getColorGrid() {

 	return colorGrid;

 }

+/**

+ * Insert the method's description here.

+ * Creation date: (7/6/99 5:07:09 PM)

+ */

 int getColorSwatchExtent() {

 	return colorSwatchExtent;

 }

-/**

- * Returns the currently selected color in the receiver.

- *

- * @return the RGB value for the selected color, may be null

- *

- * @see PaletteData#getRGBs

- */

+/**
+ * Returns the currently selected color in the receiver.
+ *
+ * @return the RGB value for the selected color
+ *
+ * @see PaletteData#getRGBs
+ */
 public RGB getRGB() {

-	return rgb;

+	return dialogResult;

 }

+/**

+ * Insert the method's description here.

+ * Creation date: (7/6/99 5:07:09 PM)

+ */

 Canvas getSampleCanvas() {

 	return sampleCanvas;

 }

+/**

+ * Insert the method's description here.

+ * Creation date: (7/6/99 5:07:09 PM)

+ */

 Label getSampleText() {

 	return sampleLabel;

 }

+/**

+ * Insert the method's description here.

+ * Creation date: (7/6/99 5:07:09 PM)

+ */

 Canvas getSelectionCanvas() {

 	return selectionCanvas;

 }

+/**

+ * Insert the method's description here.

+ * Creation date: (7/6/99 5:07:09 PM)

+ */

 Label getSelectionText() {

 	return selectionLabel;

 }

@@ -267,6 +303,10 @@
 		}

 	}	

 }

+/**

+ * Insert the method's description here.

+ * Creation date: (7/6/99 5:07:09 PM)

+ */

 void initialize4BitColors() {

 	Display display = getDialogShell().getDisplay();

 	

@@ -290,6 +330,10 @@
 	colorGrid[7][0] = new Color(display, 128, 0, 128);

 	colorGrid[7][1] = new Color(display, 255, 0, 255);

 }

+/**

+ * Insert the method's description here.

+ * Creation date: (7/6/99 5:07:09 PM)

+ */

 void initialize8BitColors() {

 	Display display = getDialogShell().getDisplay();	

 	int numColumns = colorGrid.length;

@@ -322,6 +366,8 @@
 void initializeWidgets() {

 	Display display = getDialogShell().getDisplay();

 	Color selectionColor;

+	RGB rgb = getRGB();

+	

 	if (rgb != null) {

 		selectionColor = new Color(display, rgb);

 		getSelectionCanvas().setBackground(selectionColor);

@@ -342,6 +388,10 @@
 	colorCanvas.addListener(SWT.MouseDown, listener);

 	colorCanvas.addListener(SWT.MouseMove, listener);

 }

+/**

+ * Insert the method's description here.

+ * Creation date: (7/19/99 7:13:21 PM)

+ */

 void mouseDown(Event event) {

 	int swatchExtent = getColorSwatchExtent();

 	Color colorGrid[][] = getColorGrid();

@@ -350,6 +400,10 @@
 	getSelectionCanvas().setBackground(color);

 	getSelectionText().setBackground(color);	

 }

+/**

+ * Insert the method's description here.

+ * Creation date: (7/19/99 7:13:21 PM)

+ */

 void mouseMove(Event event) {

 	int swatchExtent = getColorSwatchExtent();

 	Color colorGrid[][] = getColorGrid();

@@ -358,41 +412,40 @@
 	getSampleCanvas().setBackground(color);

 	getSampleText().setBackground(color);

 }

-/**

- * Makes the receiver visible and brings it to the front

- * of the display.

- *

- * @return the selected color, or null if the dialog was

- *         cancelled, no color was selected, or an error

- *         occurred

- *

- * @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>

- */

+/**
+ * Makes the receiver visible and brings it to the front
+ * of the display.
+ *
+ * @return the selected 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>
+ */
 public RGB open() {

 	Color selectionColor;

+	RGB dialogResult = null;

 	Shell dialog = new Shell(getParent(), getStyle() | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);

 	

 	setDialogShell(dialog);

 	createChildren();

 	installListeners();

 	openModal();

-	rgb = null;

 	if (isOkSelected() == true) {

 		selectionColor = getSelectionCanvas().getBackground();

-		rgb = new RGB(

+		dialogResult = new RGB(

 			selectionColor.getRed(), 

 			selectionColor.getGreen(), 

 			selectionColor.getBlue());

+		setRGB(dialogResult);

 	}

 	disposeColors();	

 	// Fix for 1G5NLY7

 	if (dialog.isDisposed() == false) {

 		dialog.dispose();

 	}	

-	return rgb;

+	return dialogResult;

 }

 void paint(Event event) {

 	Color colorGrid[][] = getColorGrid();

@@ -416,17 +469,15 @@
 		initialize8BitColors();				

 	}

 }

-/**

- * Returns the receiver's selected color to be the argument.

- *

- * @param rgb the new RGB value for the selected color, may be

- *        null to let the platform to select a default when

- *        open() is called

- *

- * @see PaletteData#getRGBs

+/**
+ * Returns the receiver's selected color to be the argument.
+ *
+ * @param rgb the new RGB value for the selected color
+ *
+ * @see PaletteData#getRGBs
  */

 public void setRGB(RGB rgb) {

-	this.rgb = rgb;

+	dialogResult = rgb;

 }

 /**

  * Create the widgets of the dialog.

@@ -470,6 +521,12 @@
 	return ok;

 }

 

+

+/**

+ * Insert the method's description here.

+ * Creation date: (08/05/99 12:34:43)

+ * @return boolean

+ */

 boolean isOkSelected() {

 	return okSelected;

 }

@@ -506,6 +563,7 @@
 	Display display = dialog.getDisplay();

 

 	initializeWidgets();

+	setRGB(null);

 	openDialog();

 	while (dialog.isDisposed() == false && dialog.getVisible() == true) {

 		if (display.readAndDispatch() == false) {

@@ -514,6 +572,12 @@
 	}

 }

 

+

+/**

+ * Insert the method's description here.

+ * Creation date: (08/05/99 12:34:43)

+ * @param newOkSelected boolean

+ */

 void setOkSelected(boolean newOkSelected) {

 	okSelected = newOkSelected;

 }

@@ -524,4 +588,6 @@
 	this.shell = shell;

 }

 

+

+

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java
index 1c3e81e..e1b66be 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java
@@ -11,44 +11,44 @@
 import org.eclipse.swt.graphics.*;

 import org.eclipse.swt.events.*;

 

-/**

- * Instances of this class are controls that allow the user

- * to choose an item from a list of items, or optionally 

- * enter a new value by typing it into an editable text

- * field. Often, <code>Combo</code>s are used in the same place

- * where a single selection <code>List</code> widget could

- * be used but space is limited. A <code>Combo</code> takes

- * less space than a <code>List</code> widget and shows

- * similar information.

- * <p>

- * Note: Since <code>Combo</code>s can contain both a list

- * and an editable text field, it is possible to confuse methods

- * which access one versus the other (compare for example,

- * <code>clearSelection()</code> and <code>deselectAll()</code>).

- * The API documentation is careful to indicate either "the

- * receiver's list" or the "the receiver's text field" to 

- * distinguish between the two cases.

- * </p><p>

- * Note that although this class is a subclass of <code>Composite</code>,

- * it does not make sense to add children to it, or set a layout on it.

- * </p>

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>DROP_DOWN, READ_ONLY, SIMPLE</dd>

- * <dt><b>Events:</b></dt>

- * <dd>DefaultSelection, Modify, Selection</dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is <em>not</em> intended to be subclassed.

- * </p>

- *

- * @see List

- */

+/**
+ * Instances of this class are controls that allow the user
+ * to choose an item from a list of items, or optionally 
+ * enter a new value by typing it into an editable text
+ * field. Often, <code>Combo</code>s are used in the same place
+ * where a single selection <code>List</code> widget could
+ * be used but space is limited. A <code>Combo</code> takes
+ * less space than a <code>List</code> widget and shows
+ * similar information.
+ * <p>
+ * Note: Since <code>Combo</code>s can contain both a list
+ * and an editable text field, it is possible to confuse methods
+ * which access one versus the other (compare for example,
+ * <code>clearSelection()</code> and <code>deselectAll()</code>).
+ * The API documentation is careful to indicate either "the
+ * receiver's list" or the "the receiver's text field" to 
+ * distinguish between the two cases.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add children to it, or set a layout on it.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>DROP_DOWN, READ_ONLY, SIMPLE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>DefaultSelection, Modify, Selection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see List
+ */
 public /*final*/ class Combo extends Composite {

-	/**

-	 * the operating system limit for the number of characters

-	 * that the text field in an instance of this class can hold

-	 */

+	/**
+	 * the operating system limit for the number of characters
+	 * that the text field in an instance of this class can hold
+	 */
 	public static int LIMIT;

 	

 	/*

@@ -60,93 +60,95 @@
 		LIMIT = 0x7FFFFFFF;

 	}

 

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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

+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <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
+ *
+ * @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 Combo (Composite parent, int style) {

 	super (parent, checkStyle (style));

 }

-/**

- * Adds the argument to the end of the receiver's list.

- *

- * @param string the new item

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the string 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>

- * @exception SWTError <ul>

- *    <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>

- * </ul>

- *

- * @see #add(String,int)

+/**
+ * Adds the argument to the end of the receiver's list.
+ *
+ * @param string the new item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string 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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ *
+ * @see #add(String,int)
  */

 public void add (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), encodeString(string), true);

+	byte [] buffer = Converter.wcsToMbcs (null, encodeString(string), true);

 	int xmString = OS.XmStringCreateLocalized (buffer);

 	if (xmString == 0) error (SWT.ERROR_ITEM_NOT_ADDED);

 	OS.XmComboBoxAddItem(handle, xmString, -1, false);

 	OS.XmStringFree (xmString);

 }

-/**

- * Adds the argument to the receiver's list at the given

- * zero-relative index.

- * <p>

- * Note: To add an item at the end of the list, use the

- * result of calling <code>getItemCount()</code> as the

- * index or use <code>add(String)</code>.

- * </p>

- *

- * @param string the new item

- * @param index the index for the item

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>

- *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</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>

- * @exception SWTError <ul>

- *    <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>

- * </ul>

- *

- * @see #add(String)

+/**
+ * Adds the argument to the receiver's list at the given
+ * zero-relative index.
+ * <p>
+ * Note: To add an item at the end of the list, use the
+ * result of calling <code>getItemCount()</code> as the
+ * index or use <code>add(String)</code>.
+ * </p>
+ *
+ * @param string the new item
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ *
+ * @see #add(String)
  */

 public void add (String string, int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (index == -1) error (SWT.ERROR_INVALID_RANGE);

 	

@@ -161,33 +163,34 @@
 	if (!(0 <= index && index <= argList [1])) {

 		error (SWT.ERROR_INVALID_RANGE);

 	}

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), encodeString(string), true);

+	byte [] buffer = Converter.wcsToMbcs (null, encodeString(string), true);

 	int xmString = OS.XmStringCreateLocalized (buffer);

 	if (xmString == 0) error (SWT.ERROR_ITEM_NOT_ADDED);

 	OS.XmComboBoxAddItem(handle, xmString, index + 1, false);

 	OS.XmStringFree (xmString);

 }

-/**

- * Adds the listener to the collection of listeners who will

- * be notified when the receiver's text is modified, by sending

- * it one of the messages defined in the <code>ModifyListener</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 ModifyListener

- * @see #removeModifyListener

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is modified, by sending
+ * it one of the messages defined in the <code>ModifyListener</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 ModifyListener
+ * @see #removeModifyListener
  */

 public void addModifyListener (ModifyListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Modify, typedListener);

@@ -217,7 +220,8 @@
  * @see SelectionEvent

  */

 public void addSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Selection,typedListener);

@@ -253,25 +257,26 @@
 protected void checkSubclass () {

 	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);

 }

-/**

- * Sets the selection in the receiver's text field to an empty

- * selection starting just before the first character. If the

- * text field is editable, this has the effect of placing the

- * i-beam at the start of the text.

- * <p>

- * Note: To clear the selected items in the receiver's list, 

- * use <code>deselectAll()</code>.

- * </p>

- *

- * @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 #deselectAll

+/**
+ * Sets the selection in the receiver's text field to an empty
+ * selection starting just before the first character. If the
+ * text field is editable, this has the effect of placing the
+ * i-beam at the start of the text.
+ * <p>
+ * Note: To clear the selected items in the receiver's list, 
+ * use <code>deselectAll()</code>.
+ * </p>
+ *
+ * @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 #deselectAll
  */

 public void clearSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int xDisplay = OS.XtDisplay (handle);

 	if (xDisplay == 0) return;

 	int [] argList = {OS.XmNtextField, 0};

@@ -280,7 +285,8 @@
 }

 

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {

 		OS.XmNlist, 0, 

 		OS.XmNtextField, 0,

@@ -346,20 +352,21 @@
 	handle = OS.XmCreateComboBox (formHandle, null, argList2, argList2.length / 2);

 	if (handle == 0) error (SWT.ERROR_NO_HANDLES);

 }

-/**

- * Deselects the item at the given zero-relative index in the receiver's 

- * list.  If the item at the index was already deselected, it remains

- * deselected. Indices that are out of range are ignored.

- *

- * @param index the index of the item to deselect

- *

- * @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>

+/**
+ * Deselects the item at the given zero-relative index in the receiver's 
+ * list.  If the item at the index was already deselected, it remains
+ * deselected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to deselect
+ *
+ * @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 deselect (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (index == -1) return;

 	int [] argList = {OS.XmNtextField, 0, OS.XmNlist, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

@@ -374,22 +381,23 @@
 		OS.XmListDeselectAllItems (argList[3]);

 	}

 }

-/**

- * Deselects all selected items in the receiver's list.

- * <p>

- * Note: To clear the selection in the receiver's text field,

- * use <code>clearSelection()</code>.

- * </p>

- *

- * @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 #clearSelection

+/**
+ * Deselects all selected items in the receiver's list.
+ * <p>
+ * Note: To clear the selection in the receiver's text field,
+ * use <code>clearSelection()</code>.
+ * </p>
+ *
+ * @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 #clearSelection
  */

 public void deselectAll () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNtextField, 0, OS.XmNlist, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	Display display = getDisplay ();

@@ -402,27 +410,28 @@
 }

 

 

-/**

- * Returns the item at the given, zero-relative index in the

- * receiver's list. Throws an exception if the index is out

- * of range.

- *

- * @param index the index of the item to return

- * @return the item at the given index

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>

- * @exception SWTError <ul>

- *    <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver's list. Throws an exception if the index is out
+ * of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
  */

 public String getItem (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNitemCount, 0, OS.XmNitems, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	if (!(0 <= index && index < argList [1])) {

@@ -446,43 +455,45 @@
 	byte [] buffer = new byte [length];

 	OS.memmove (buffer, address, length);

 	OS.XtFree (address);

-	return decodeString(new String (Converter.mbcsToWcs (getCodePage (), buffer)));

+	return decodeString(new String (Converter.mbcsToWcs (null, buffer)));

 }

-/**

- * Returns the number of items contained in the receiver's list.

- *

- * @return the number of items

- *

- * @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>

- * @exception SWTError <ul>

- *    <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Returns the number of items contained in the receiver's list.
+ *
+ * @return the number of items
+ *
+ * @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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
+ * </ul>
  */

 public int getItemCount () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNitemCount, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * Returns the height of the area which would be used to

- * display <em>one</em> of the items in the receiver's list.

- *

- * @return the height of one item

- *

- * @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>

- * @exception SWTError <ul>

- *    <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Returns the height of the area which would be used to
+ * display <em>one</em> of the items in the receiver's list.
+ *
+ * @return the height of one item
+ *
+ * @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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li>
+ * </ul>
  */

 public int getItemHeight () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] listHandleArgs = {OS.XmNlist, 0};

 	OS.XtGetValues (handle, listHandleArgs, listHandleArgs.length / 2);

 	int [] argList = {OS.XmNlistSpacing, 0, OS.XmNhighlightThickness, 0};

@@ -491,33 +502,33 @@
 	/* Result is from empirical analysis on Linux and AIX */

 	return getFontHeight () + spacing + (2 * highlight);

 }

-/**

- * Returns an array of <code>String</code>s which are the items

- * in the receiver's list. 

- * <p>

- * Note: This is not the actual structure used by the receiver

- * to maintain its list of items, so modifying the array will

- * not affect the receiver. 

- * </p>

- *

- * @return the items in the receiver's list

- *

- * @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>

- * @exception SWTError <ul>

- *    <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Returns an array of <code>String</code>s which are the items
+ * in the receiver's list. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver's list
+ *
+ * @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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
  */

 public String [] getItems () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNitems, 0, OS.XmNitemCount, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	int items = argList [1], itemCount = argList [3];

 	int [] buffer1 = new int [1];

 	String [] result = new String [itemCount];

-	String codePage = getCodePage ();

 	for (int i = 0; i < itemCount; i++) {

 		OS.memmove (buffer1, items, 4);

 		int ptr = buffer1 [0];

@@ -534,27 +545,28 @@
 		byte [] buffer = new byte [length];

 		OS.memmove (buffer, address, length);

 		OS.XtFree (address);

-		result[i] = decodeString(new String (Converter.mbcsToWcs (codePage, buffer)));

+		result[i] = decodeString(new String (Converter.mbcsToWcs (null, buffer)));

 		items += 4;

 	}

 	return result;

 }

-/**

- * Returns a <code>Point</code> whose x coordinate is the start

- * of the selection in the receiver's text field, and whose y

- * coordinate is the end of the selection. The returned values

- * are zero-relative. An "empty" selection as indicated by

- * the the x and y coordinates having the same value.

- *

- * @return a point representing the selection start and end

- *

- * @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 <code>Point</code> whose x coordinate is the start
+ * of the selection in the receiver's text field, and whose y
+ * coordinate is the end of the selection. The returned values
+ * are zero-relative. An "empty" selection as indicated by
+ * the the x and y coordinates having the same value.
+ *
+ * @return a point representing the selection start and end
+ *
+ * @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 Point getSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] start = new int [1], end = new int [1];

 	int [] argList = {OS.XmNtextField, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

@@ -564,19 +576,21 @@
 	}

 	return new Point (start [0], end [0]);

 }

-/**

- * Returns the zero-relative index of the item which is currently

- * selected in the receiver's list, or -1 if no item is selected.

- *

- * @return the index of the selected item

- *

- * @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 the zero-relative index of the item which is currently
+ * selected in the receiver's list, or -1 if no item is selected.
+ *
+ * @return the index of the selected item
+ *
+ * @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 getSelectionIndex () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

 	int [] argList = {OS.XmNlist, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	

@@ -591,19 +605,21 @@
 	OS.XtFree (address);

 	return indices [0] - 1;

 }

-/**

- * Returns a string containing a copy of the contents of the

- * receiver's text field.

- *

- * @return the receiver's text

- *

- * @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 string containing a copy of the contents of the
+ * receiver's text field.
+ *
+ * @return the receiver's text
+ *
+ * @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 String getText () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

 	int [] argList = {OS.XmNtextField, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	

@@ -613,23 +629,25 @@
 	byte [] buffer = new byte [length];

 	OS.memmove (buffer, ptr, length);

 	OS.XtFree (ptr);

-	return decodeString(new String (Converter.mbcsToWcs (getCodePage (), buffer)));

+	return decodeString(new String (Converter.mbcsToWcs (null, buffer)));

 }

-/**

- * Returns the height of the receivers's text field.

- *

- * @return the text height

- *

- * @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>

- * @exception SWTError <ul>

- *    <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Returns the height of the receivers's text field.
+ *
+ * @return the text height
+ *
+ * @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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li>
+ * </ul>
  */

 public int getTextHeight () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

 	if ((style & SWT.DROP_DOWN) != 0) {

 		/*

 		* Bug in MOTIF.  For some reason, XtQueryGeometry ()

@@ -661,21 +679,23 @@
 		return height;

 	}

 }

-/**

- * Returns the maximum number of characters that the receiver's

- * text field is capable of holding. If this has not been changed

- * by <code>setTextLimit()</code>, it will be the constant

- * <code>Combo.LIMIT</code>.

- * 

- * @return the text limit

- * 

- * @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 the maximum number of characters that the receiver's
+ * text field is capable of holding. If this has not been changed
+ * by <code>setTextLimit()</code>, it will be the constant
+ * <code>Combo.LIMIT</code>.
+ * 
+ * @return the text limit
+ * 
+ * @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 getTextLimit () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

 	int [] argList = {OS.XmNtextField, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return OS.XmTextGetMaxLength (argList[1]);

@@ -689,28 +709,29 @@
 	OS.XtAddCallback (argList[1], OS.XmNactivateCallback, windowProc, SWT.DefaultSelection);

 	OS.XtAddCallback (argList[1], OS.XmNvalueChangedCallback, windowProc, SWT.Modify);

 }

-/**

- * Searches the receiver's list starting at the first item

- * (index 0) until an item is found that is equal to the 

- * argument, and returns the index of that item. If no item

- * is found, returns -1.

- *

- * @param string the search item

- * @return the index of the item

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the string 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>

+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param string the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string 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>
  */

 public int indexOf (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), encodeString(string), true);

+	byte [] buffer = Converter.wcsToMbcs (null, encodeString(string), true);

 	int xmString = OS.XmStringCreateLocalized (buffer);

 	if (xmString == 0) return -1;

 	

@@ -721,32 +742,33 @@
 	OS.XmStringFree (xmString);

 	return index - 1;

 }

-/**

- * Searches the receiver's list starting at the given, 

- * zero-relative index until an item is found that is equal

- * to the argument, and returns the index of that item. If

- * no item is found or the starting index is out of range,

- * returns -1.

- *

- * @param string the search item

- * @return the index of the item

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the string 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>

+/**
+ * Searches the receiver's list starting at the given, 
+ * zero-relative index until an item is found that is equal
+ * to the argument, and returns the index of that item. If
+ * no item is found or the starting index is out of range,
+ * returns -1.
+ *
+ * @param string the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string 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>
  */

 public int indexOf (String string, int start) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	int [] argList = {OS.XmNitems, 0, OS.XmNitemCount, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	int items = argList [1], itemCount = argList [3];

 	if (!((0 <= start) && (start < itemCount))) return -1;

-	byte [] buffer1 = Converter.wcsToMbcs (getCodePage (), encodeString(string), true);

+	byte [] buffer1 = Converter.wcsToMbcs (null, encodeString(string), true);

 	int xmString = OS.XmStringCreateLocalized (buffer1);

 	if (xmString == 0) return -1;

 	int index = start;

@@ -761,38 +783,26 @@
 	if (index == itemCount) return -1;

 	return index;

 }

-int processSelection (int callData) {

-	/*

-	* Bug in MOTIF.  If items have been added and removed from a

-	* combo then users are able to select an empty drop-down item

-	* in the combo once and force a resulting callback.  In such

-	* cases we want to eat this callback so that listeners are not

-	* notified.

-	*/

-	if (getSelectionIndex() == -1)

-		return 0;

-		

-	return super.processSelection(callData);

-}

-/**

- * Removes the item from the receiver's list at the given

- * zero-relative index.

- *

- * @param index the index for the item

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>

- * @exception SWTError <ul>

- *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Removes the item from the receiver's list at the given
+ * zero-relative index.
+ *
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
  */

 public void remove (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (index == -1) error (SWT.ERROR_INVALID_RANGE);

 	/*

 	* Feature in Motif.  An index out of range handled

@@ -807,27 +817,28 @@
 	}

 	OS.XmComboBoxDeletePos (handle, index + 1);

 }

-/**

- * Removes the items from the receiver's list which are

- * between the given zero-relative start and end 

- * indices (inclusive).

- *

- * @param start the start of the range

- * @param end the end of the range

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</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>

- * @exception SWTError <ul>

- *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Removes the items from the receiver's list which are
+ * between the given zero-relative start and end 
+ * indices (inclusive).
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
  */

 public void remove (int start, int end) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (start > end) return;

 	/*

 	* Feature in Motif.  An index out of range handled

@@ -852,30 +863,31 @@
 	OS.XtGetValues (handle, argList, argList.length / 2);

 	WidgetTable.put(argList[1], this);

 }

-/**

- * Searches the receiver's list starting at the first item

- * until an item is found that is equal to the argument, 

- * and removes that item from the list.

- *

- * @param string the item to remove

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>

- *    <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</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>

- * @exception SWTError <ul>

- *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Searches the receiver's list starting at the first item
+ * until an item is found that is equal to the argument, 
+ * and removes that item from the list.
+ *
+ * @param string the item to remove
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
  */

 public void remove (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), encodeString(string), true);

+	byte [] buffer = Converter.wcsToMbcs (null, encodeString(string), true);

 	int xmString = OS.XmStringCreateLocalized (buffer);

 	if (xmString == 0) error (SWT.ERROR_ITEM_NOT_REMOVED);

 	

@@ -887,16 +899,17 @@
 	if (index == 0) error (SWT.ERROR_INVALID_ARGUMENT);

 	OS.XmComboBoxDeletePos (handle, index);

 }

-/**

- * Removes all of the items from the receiver's list.

- * <p>

- * @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>

+/**
+ * Removes all of the items from the receiver's list.
+ * <p>
+ * @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 removeAll () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNtextField, 0, OS.XmNlist, 0, OS.XmNitemCount, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	

@@ -912,67 +925,70 @@
 		OS.XmComboBoxDeletePos(handle, 1);

 	}

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the receiver's text is modified.

- *

- * @param listener the listener which should no longer 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 ModifyListener

- * @see #addModifyListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's text is modified.
+ *
+ * @param listener the listener which should no longer 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 ModifyListener
+ * @see #addModifyListener
  */

 public void removeModifyListener (ModifyListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Modify, listener);	

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the receiver's selection changes.

- *

- * @param listener the listener which should no longer 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 SelectionListener

- * @see #addSelectionListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's selection changes.
+ *
+ * @param listener the listener which should no longer 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 SelectionListener
+ * @see #addSelectionListener
  */

 public void removeSelectionListener (SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Selection, listener);

 	eventTable.unhook (SWT.DefaultSelection,listener);	

 }

-/**

- * Selects the item at the given zero-relative index in the receiver's 

- * list.  If the item at the index was already selected, it remains

- * selected. Indices that are out of range are ignored.

- *

- * @param index the index of the item to select

- *

- * @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>

+/**
+ * Selects the item at the given zero-relative index in the receiver's 
+ * list.  If the item at the index was already selected, it remains
+ * selected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to select
+ *
+ * @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 select (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (index == -1) {

 		int [] argList = {OS.XmNtextField, 0, OS.XmNlist, 0};

 		OS.XtGetValues (handle, argList, argList.length / 2);

@@ -997,33 +1013,35 @@
 * Sets the widget bounds.

 */

 public void setBounds (int x, int y, int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int newHeight = ((style & SWT.DROP_DOWN) != 0) ? getTextHeight() : height;

 	super.setBounds (x, y, width, newHeight);

 }

-/**

- * Sets the text of the item in the receiver's list at the given

- * zero-relative index to the string argument. This is equivalent

- * to <code>remove</code>'ing the old item at the index, and then

- * <code>add</code>'ing the new item at that index.

- *

- * @param index the index for the item

- * @param string the new text for the item

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>

- * @exception SWTError <ul>

- *    <li>ERROR_ITEM_NOT_REMOVED - if the remove operation fails because of an operating system failure</li>

- *    <li>ERROR_ITEM_NOT_ADDED - if the add operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Sets the text of the item in the receiver's list at the given
+ * zero-relative index to the string argument. This is equivalent
+ * to <code>remove</code>'ing the old item at the index, and then
+ * <code>add</code>'ing the new item at that index.
+ *
+ * @param index the index for the item
+ * @param string the new text for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_ITEM_NOT_REMOVED - if the remove operation fails because of an operating system failure</li>
+ *    <li>ERROR_ITEM_NOT_ADDED - if the add operation fails because of an operating system failure</li>
+ * </ul>
  */

 public void setItem (int index, String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (index == -1) error (SWT.ERROR_INVALID_RANGE);

 	int [] argList = {OS.XmNlist, 0, OS.XmNitemCount, 0};

@@ -1031,7 +1049,7 @@
 	if (!(0 <= index && index < argList [3])) {

 		error (SWT.ERROR_INVALID_RANGE);

 	}

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), encodeString(string), true);

+	byte [] buffer = Converter.wcsToMbcs (null, encodeString(string), true);

 	int xmString = OS.XmStringCreateLocalized (buffer);

 	if (xmString == 0) error (SWT.ERROR_ITEM_NOT_ADDED);

 	boolean isSelected = OS.XmListPosSelected (argList[1], index + 1);

@@ -1039,21 +1057,22 @@
 	if (isSelected) OS.XmListSelectPos (argList[1], index + 1, false);

 	OS.XmStringFree (xmString);

 }

-/**

- * Sets the receiver's list to be the given array of items.

- *

- * @param items the array of items

- *

- * @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>

- * @exception SWTError <ul>

- *    <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Sets the receiver's list to be the given array of items.
+ *
+ * @param items the array of items
+ *
+ * @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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
+ * </ul>
  */

 public void setItems (String [] items) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (items == null) error (SWT.ERROR_NULL_ARGUMENT);

 

 	if (items.length == 0) {

@@ -1063,11 +1082,10 @@
 	

 	int index = 0;

 	int [] table = new int [items.length];

-	String codePage = getCodePage ();

 	while (index < items.length) {

 		String string = items [index];

 		if (string == null) break; 

-		byte [] buffer = Converter.wcsToMbcs (codePage, encodeString(string), true);

+		byte [] buffer = Converter.wcsToMbcs (null, encodeString(string), true);

 		int xmString = OS.XmStringCreateLocalized (buffer);

 		if (xmString == 0) break;

 		table [index++] = xmString;

@@ -1080,24 +1098,25 @@
 	OS.XtFree (ptr);

 	if (index < items.length) error (SWT.ERROR_ITEM_NOT_ADDED);

 }

-/**

- * Sets the selection in the receiver's text field to the

- * range specified by the argument whose x coordinate is the

- * start of the selection and whose y coordinate is the end

- * of the selection. 

- *

- * @param a point representing the new selection start and end

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the point 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>

+/**
+ * Sets the selection in the receiver's text field to the
+ * range specified by the argument whose x coordinate is the
+ * start of the selection and whose y coordinate is the end
+ * of the selection. 
+ *
+ * @param a point representing the new selection start and end
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point 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>
  */

 public void setSelection (Point selection) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	

 	int [] argList = {OS.XmNtextField, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

@@ -1133,37 +1152,39 @@
 * Sets the widget size.

 */

 public void setSize (int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int newHeight = ((style & SWT.DROP_DOWN) != 0) ? getTextHeight () : height;

 	super.setSize (width, newHeight);

 }

-/**

- * Sets the contents of the receiver's text field to the

- * given string.

- * <p>

- * Note: The text field in a <code>Combo</code> is typically

- * only capable of displaying a single line of text. Thus,

- * setting the text to a string containing line breaks or

- * other special characters will probably cause it to 

- * display incorrectly.

- * </p>

- *

- * @param text the new text

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the string 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>

+/**
+ * Sets the contents of the receiver's text field to the
+ * given string.
+ * <p>
+ * Note: The text field in a <code>Combo</code> is typically
+ * only capable of displaying a single line of text. Thus,
+ * setting the text to a string containing line breaks or
+ * other special characters will probably cause it to 
+ * display incorrectly.
+ * </p>
+ *
+ * @param text the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string 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>
  */

 public void setText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 

 	if ((style & SWT.READ_ONLY) == 0) {

-		byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+		byte [] buffer = Converter.wcsToMbcs (null, string, true);

 		int xmString = OS.XmStringCreateLocalized (buffer);

 		if (xmString == 0) return;

 		int [] argList = {OS.XmNtextField, 0, OS.XmNlist, 0};

@@ -1187,25 +1208,26 @@
 		* it does not send a Modify to notify the application

 		* that the text has changed.  The fix is to send the event.

 		*/

-		if (OS.IsLinux && (style & SWT.MULTI) != 0) sendEvent (SWT.Modify);

+		if (IsLinux && (style & SWT.MULTI) != 0) sendEvent (SWT.Modify);

 	}

 }

-/**

- * Sets the maximum number of characters that the receiver's

- * text field is capable of holding to be the argument.

- *

- * @param limit new text limit

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</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>

+/**
+ * Sets the maximum number of characters that the receiver's
+ * text field is capable of holding to be the argument.
+ *
+ * @param limit new text limit
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</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>
  */

 public void setTextLimit (int limit) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);

 	int [] argList = {OS.XmNtextField, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

@@ -1218,16 +1240,7 @@
 	OS.XtGetValues (handle, argList, argList.length / 2);

 	WidgetTable.remove (argList[1]);

 }

-void enableWidget (boolean enabled) {

-	super.enableWidget (enabled);

-	int [] argList = {

-		OS.XmNlist, 0, 

-		OS.XmNtextField, 0,

-	};

-	OS.XtGetValues (handle, argList, argList.length / 2);

-	enableHandle (enabled, argList [1]);

-	enableHandle (enabled, argList [3]);

-}

+

 /**

  * Bug in Motif.

  * Empty strings in the combo will cause GPFs if a) they

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java
index b92a91e..3b1441b 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java
@@ -9,23 +9,23 @@
 import org.eclipse.swt.*;

 import org.eclipse.swt.graphics.*;

 

-/**

- * Instances of this class are controls which are capable

- * of containing other controls.

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>NO_BACKGROUND, NO_FOCUS, NO_MERGE_PAINTS, NO_REDRAW_RESIZE</dd>

- * <dt><b>Events:</b></dt>

- * <dd>(none)</dd>

- * </dl>

- * <p>

- * This class may be subclassed by custom control implementors

- * who are building controls that are constructed from aggregates

- * of other controls.

- * </p>

- *

- * @see Canvas

- */

+/**
+ * Instances of this class are controls which are capable
+ * of containing other controls.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>NO_BACKGROUND, NO_FOCUS, NO_MERGE_PAINTS, NO_REDRAW_RESIZE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * This class may be subclassed by custom control implementors
+ * who are building controls that are constructed from aggregates
+ * of other controls.
+ * </p>
+ *
+ * @see Canvas
+ */
 public class Composite extends Scrollable {

 	Layout layout;

 	int damagedRegion;

@@ -33,34 +33,34 @@
 Composite () {

 	/* Do nothing */

 }

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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 widget which will be the parent of the new instance (cannot be null)

- * @param style the style of widget to construct

- *

- * @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

- */

+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <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 widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @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 Composite (Composite parent, int style) {

 	super (parent, style);

 }

@@ -94,7 +94,8 @@
 * Computes the preferred size.

 */

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	Point size;

 	if (layout != null) {

 		if ((wHint == SWT.DEFAULT) || (hHint == SWT.DEFAULT)) {

@@ -185,7 +186,8 @@
 	return getDisplay ().compositeForeground;

 }

 public boolean forceFocus () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	Control [] children = _getChildren ();

 	int [] traversals = new int [children.length];

 	int [] argList = new int [] {OS.XmNtraversalOn, 0};

@@ -202,23 +204,24 @@
 	}

 	return result;

 }

-/**

- * Returns an array containing the receiver's children.

- * <p>

- * Note: This is not the actual structure used by the receiver

- * to maintain its list of children, so modifying the array will

- * not affect the receiver. 

- * </p>

- *

- * @return an array of children

- *

- * @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 an array containing the receiver's children.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of children, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return an array of children
+ *
+ * @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 Control [] getChildren () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return _getChildren ();

 }

 int getChildrenCount () {

@@ -227,19 +230,20 @@
 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * Returns layout which is associated with the receiver, or

- * null if one has not been set.

- *

- * @return the receiver's layout or null

- *

- * @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 layout which is associated with the receiver, or
+ * null if one has not been set.
+ *
+ * @return the receiver's layout or null
+ *
+ * @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 Layout getLayout () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return layout;

 }

 

@@ -251,42 +255,44 @@
 	}

 }

 

-/**

- * 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. 

- * If the receiver does not have a layout, do nothing.

- * <p>

- * This is equivalent to calling <code>layout(true)</code>.

- * </p>

- *

- * @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>

+/**
+ * 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. 
+ * If the receiver does not have a layout, do nothing.
+ * <p>
+ * This is equivalent to calling <code>layout(true)</code>.
+ * </p>
+ *
+ * @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 layout () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	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. 

- * If the the argument is <code>true</code> the layout must not rely

- * on any cached information it is keeping about the children. If it

- * is <code>false</code> the layout may (potentially) simplify the

- * work it is doing by assuming that the state of the none of the

- * receiver's children has changed since the last layout.

- * If the receiver does not have a layout, do nothing.

- *

- * @param changed <code>true</code> if the layout must flush its caches, and <code>false</code> 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>

- */

+/**
+ * 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. 
+ * If the the argument is <code>true</code> the layout must not rely
+ * on any cached information it is keeping about the children. If it
+ * is <code>false</code> the layout may (potentially) simplify the
+ * work it is doing by assuming that the state of the none of the
+ * receiver's children has changed since the last layout.
+ * If the receiver does not have a layout, do nothing.
+ *
+ * @param changed <code>true</code> if the layout must flush its caches, and <code>false</code> 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 void layout (boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (layout == null) return;

 	int count = getChildrenCount ();

 	if (count == 0) return;

@@ -490,19 +496,20 @@
 	super.setBounds (x, y, width, height);

 	if (layout != null) layout (false);

 }

-/**

- * Sets the layout which is associated with the receiver to be

- * the argument which may be null.

- *

- * @param the receiver's new layout or null

- *

- * @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>

- */

+/**
+ * Sets the layout which is associated with the receiver to be
+ * the argument which may be null.
+ *
+ * @param the receiver's new layout or null
+ *
+ * @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 setLayout (Layout layout) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	this.layout = layout;

 }

 public void setSize (int width, int height) {

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java
index b13e897..af3b234 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java
@@ -1,9 +1,9 @@
 package org.eclipse.swt.widgets;

 

-/*

- * (c) Copyright IBM Corp. 2000, 2001.

- * All Rights Reserved

- */

+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
 

 import org.eclipse.swt.internal.*;

 import org.eclipse.swt.internal.motif.*;

@@ -11,21 +11,21 @@
 import org.eclipse.swt.*;

 import org.eclipse.swt.events.*;

 

-/**

- * Control is the abstract superclass of all windowed user interface classes.

- * <p>

- * <dl>

- * <dt><b>Styles:</b>

- * <dd>BORDER</dd>

- * <dt><b>Events:</b>

- * <dd>FocusIn, FocusOut, Help, KeyDown, KeyUp, MouseDoubleClick, MouseDown, MouseEnter,

- *     MouseExit, MouseHover, MouseUp, MouseMove, Move, Paint, Resize</dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is intended to be subclassed <em>only</em>

- * within the SWT implementation.

- * </p>

- */

+/**
+ * Control is the abstract superclass of all windowed user interface classes.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b>
+ * <dd>BORDER</dd>
+ * <dt><b>Events:</b>
+ * <dd>FocusIn, FocusOut, Help, KeyDown, KeyUp, MouseDoubleClick, MouseDown, MouseEnter,
+ *     MouseExit, MouseHover, MouseUp, MouseMove, Move, Paint, Resize</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ */
 public abstract class Control extends Widget implements Drawable {

 	Composite parent;

 	int fontList;

@@ -35,327 +35,337 @@
 Control () {

 	/* Do nothing */

 }

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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

- */

+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <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
+ *
+ * @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 Control (Composite parent, int style) {

 	super (parent, style);

 	this.parent = parent;

 	createWidget (0);

 }

-/**

- * Adds the listener to the collection of listeners who will

- * be notified when the control is moved or resized, by sending

- * it one of the messages defined in the <code>ControlListener</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 ControlListener

- * @see #removeControlListener

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is moved or resized, by sending
+ * it one of the messages defined in the <code>ControlListener</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 ControlListener
+ * @see #removeControlListener
  */

 public void addControlListener(ControlListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Resize,typedListener);

 	addListener (SWT.Move,typedListener);

 }

-/**

- * Adds the listener to the collection of listeners who will

- * be notified when the control gains or loses focus, by sending

- * it one of the messages defined in the <code>FocusListener</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 FocusListener

- * @see #removeFocusListener

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control gains or loses focus, by sending
+ * it one of the messages defined in the <code>FocusListener</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 FocusListener
+ * @see #removeFocusListener
  */

 public void addFocusListener(FocusListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener(SWT.FocusIn,typedListener);

 	addListener(SWT.FocusOut,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) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Help, typedListener);

 }

-/**

- * Adds the listener to the collection of listeners who will

- * be notified when keys are pressed and released on the system keyboard, by sending

- * it one of the messages defined in the <code>KeyListener</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 KeyListener

- * @see #removeKeyListener

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when keys are pressed and released on the system keyboard, by sending
+ * it one of the messages defined in the <code>KeyListener</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 KeyListener
+ * @see #removeKeyListener
  */

 public void addKeyListener(KeyListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener(SWT.KeyUp,typedListener);

 	addListener(SWT.KeyDown,typedListener);

 }

-/**

- * Adds the listener to the collection of listeners who will

- * be notified when mouse buttons are pressed and released, by sending

- * it one of the messages defined in the <code>MouseListener</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 MouseListener

- * @see #removeMouseListener

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when mouse buttons are pressed and released, by sending
+ * it one of the messages defined in the <code>MouseListener</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 MouseListener
+ * @see #removeMouseListener
  */

 public void addMouseListener(MouseListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener(SWT.MouseDown,typedListener);

 	addListener(SWT.MouseUp,typedListener);

 	addListener(SWT.MouseDoubleClick,typedListener);

 }

-/**

- * Adds the listener to the collection of listeners who will

- * be notified when the mouse passes or hovers over controls, by sending

- * it one of the messages defined in the <code>MouseTrackListener</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 MouseTrackListener

- * @see #removeMouseTrackListener

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the mouse passes or hovers over controls, by sending
+ * it one of the messages defined in the <code>MouseTrackListener</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 MouseTrackListener
+ * @see #removeMouseTrackListener
  */

 public void addMouseTrackListener (MouseTrackListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.MouseEnter,typedListener);

 	addListener (SWT.MouseExit,typedListener);

 	addListener (SWT.MouseHover,typedListener);

 }

-/**

- * Adds the listener to the collection of listeners who will

- * be notified when the mouse moves, by sending it one of the

- * messages defined in the <code>MouseMoveListener</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 MouseMoveListener

- * @see #removeMouseMoveListener

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the mouse moves, by sending it one of the
+ * messages defined in the <code>MouseMoveListener</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 MouseMoveListener
+ * @see #removeMouseMoveListener
  */

 public void addMouseMoveListener(MouseMoveListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener(SWT.MouseMove,typedListener);

 }

-/**

- * Adds the listener to the collection of listeners who will

- * be notified when the receiver needs to be painted, by sending it

- * one of the messages defined in the <code>PaintListener</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 PaintListener

- * @see #removePaintListener

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver needs to be painted, by sending it
+ * one of the messages defined in the <code>PaintListener</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 PaintListener
+ * @see #removePaintListener
  */

 public void addPaintListener(PaintListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener(SWT.Paint,typedListener);

 }

-/**

- * Adds the listener to the collection of listeners who will

- * be notified when traversal events occur, by sending it

- * one of the messages defined in the <code>TraverseListener</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 TraverseListener

- * @see #removeTraverseListener

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when traversal events occur, by sending it
+ * one of the messages defined in the <code>TraverseListener</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 TraverseListener
+ * @see #removeTraverseListener
  */

 public void addTraverseListener (TraverseListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Traverse,typedListener);

 }

-/**

- * Returns the preferred size of the receiver.

- * <p>

- * The <em>prefered size</em> of a control is the size that it would

- * best be displayed at. The width hint and height hint arguments

- * allow the caller to ask a control questions such as "Given a particular

- * width, how high does the control need to be to show all of the contents?"

- * To indicate that the caller does not wish to constrain a particular 

- * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint. 

- * </p>

- *

- * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)

- * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)

- * @return the preferred size of the control

- *

- * @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 Layout

- */

+/**
+ * Returns the preferred size of the receiver.
+ * <p>
+ * The <em>prefered size</em> of a control is the size that it would
+ * best be displayed at. The width hint and height hint arguments
+ * allow the caller to ask a control questions such as "Given a particular
+ * width, how high does the control need to be to show all of the contents?"
+ * To indicate that the caller does not wish to constrain a particular 
+ * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint. 
+ * </p>
+ *
+ * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
+ * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
+ * @return the preferred size of the control
+ *
+ * @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 Layout
+ */
 public Point computeSize (int wHint, int hHint) {

 	return computeSize (wHint, hHint, true);

 }

-/**

- * Returns the preferred size of the receiver.

- * <p>

- * The <em>prefered size</em> of a control is the size that it would

- * best be displayed at. The width hint and height hint arguments

- * allow the caller to ask a control questions such as "Given a particular

- * width, how high does the control need to be to show all of the contents?"

- * To indicate that the caller does not wish to constrain a particular 

- * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint. 

- * </p><p>

- * If the changed flag is <code>true</code>, it indicates that the receiver's

- * <em>contents</em> have changed, therefore any caches that a layout manager

- * containing the control may have been keeping need to be flushed. When the

- * control is resized, the changed flag will be <code>false</code>, so layout

- * manager caches can be retained. 

- * </p>

- *

- * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)

- * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)

- * @param changed <code>true</code> if the control's contents have changed, and <code>false</code> otherwise

- * @return the preferred size of the control.

- *

- * @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 Layout

+/**
+ * Returns the preferred size of the receiver.
+ * <p>
+ * The <em>prefered size</em> of a control is the size that it would
+ * best be displayed at. The width hint and height hint arguments
+ * allow the caller to ask a control questions such as "Given a particular
+ * width, how high does the control need to be to show all of the contents?"
+ * To indicate that the caller does not wish to constrain a particular 
+ * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint. 
+ * </p><p>
+ * If the changed flag is <code>true</code>, it indicates that the receiver's
+ * <em>contents</em> have changed, therefore any caches that a layout manager
+ * containing the control may have been keeping need to be flushed. When the
+ * control is resized, the changed flag will be <code>false</code>, so layout
+ * manager caches can be retained. 
+ * </p>
+ *
+ * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
+ * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
+ * @param changed <code>true</code> if the control's contents have changed, and <code>false</code> otherwise
+ * @return the preferred size of the control.
+ *
+ * @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 Layout
  */

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int width = DEFAULT_WIDTH;

 	int height = DEFAULT_HEIGHT;

 	if (wHint != SWT.DEFAULT) width = wHint;

@@ -369,37 +379,29 @@
 void createWidget (int index) {

 	super.createWidget (index);

 	

-	/*

-	* Register for the IME.  This is necessary on single byte

-	* platforms as well as double byte platforms in order to

-	* get composed characters. For example, accented characters

-	* on a German locale.

-	*/

-	OS.XmImRegister (handle, 0);

-	

-	/*

-	* Feature in MOTIF.  When a widget is created before the

-	* parent has been realized, the widget is created behind

-	* all siblings in the Z-order.  When a widget is created

-	* after the parent has been realized, it is created in

-	* front of all siblings.  This is not incorrect but is

-	* unexpected.  The fix is to force all widgets to always

-	* be created behind their siblings.

-	*/

-	int topHandle = topHandle ();

-	if (OS.XtIsRealized (topHandle)) {

-		int window = OS.XtWindow (topHandle);

-		if (window != 0) {

-			int display = OS.XtDisplay (topHandle);

-			if (display != 0) OS.XLowerWindow (display, window);

-		}

-		/*

-		* Make that the widget has been properly realized

-		* because the widget was created after the parent

-		* has been realized.  This is not part of the fix

-		* for Z-order in the code above. 

-		*/

-		realizeChildren ();

+	/*
+	* Feature in MOTIF.  When a widget is created before the
+	* parent has been realized, the widget is created behind
+	* all siblings in the Z-order.  When a widget is created
+	* after the parent has been realized, it is created in
+	* front of all siblings.  This is not incorrect but is
+	* unexpected.  The fix is to force all widgets to always
+	* be created behind their siblings.
+	*/
+	int topHandle = topHandle ();
+	if (OS.XtIsRealized (topHandle)) {
+		int window = OS.XtWindow (topHandle);
+		if (window != 0) {
+			int display = OS.XtDisplay (topHandle);
+			if (display != 0) OS.XLowerWindow (display, window);
+		}
+		/*
+		* Make that the widget has been properly realized
+		* because the widget was created after the parent
+		* has been realized.  This is not part of the fix
+		* for Z-order in the code above. 
+		*/
+		realizeChildren ();
 	}

 	

 	/*

@@ -422,6 +424,10 @@
 int defaultForeground () {

 	return getDisplay ().defaultForeground;

 }

+void enableHandle (boolean enabled, int widgetHandle) {

+	int [] argList = {OS.XmNsensitive, enabled ? 1 : 0};

+	OS.XtSetValues (widgetHandle, argList, argList.length / 2);

+}

 void enableWidget (boolean enabled) {

 	enableHandle (enabled, handle);

 }

@@ -439,38 +445,40 @@
 int fontHandle () {

 	return handle;

 }

-/**

- * Forces the receiver to have the <em>keyboard focus</em>, causing

- * all keyboard events to be delivered to it.

- *

- * @return <code>true</code> if the control got focus, and <code>false</code> if it was unable to.

- *

- * @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 #setFocus

- */

+/**
+ * Forces the receiver to have the <em>keyboard focus</em>, causing
+ * all keyboard events to be delivered to it.
+ *
+ * @return <code>true</code> if the control got focus, and <code>false</code> if it was unable to.
+ *
+ * @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 #setFocus
+ */
 public boolean forceFocus () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	Decorations shell = menuShell ();

 	shell.setSavedFocus (this);

 	shell.bringToTop ();

 	return OS.XmProcessTraversal (handle, OS.XmTRAVERSE_CURRENT);

 }

-/**

- * 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>

- */

+/**
+ * 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>
+ */
 public Color getBackground () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return Color.motif_new (getDisplay (), getXColor (getBackgroundPixel ()));

 }

 int getBackgroundPixel () {

@@ -478,36 +486,38 @@
 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * Returns the receiver's border width.

- *

- * @return the border width

- *

- * @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 the receiver's border width.
+ *
+ * @return the border width
+ *
+ * @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 getBorderWidth () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int topHandle = topHandle ();

 	int [] argList = {OS.XmNborderWidth, 0};

 	OS.XtGetValues (topHandle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * Returns a rectangle describing the receiver's size and location

- * relative to its parent (or its display if its parent is null).

- *

- * @return the receiver's bounding 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 (or its display if its parent is null).
+ *
+ * @return the receiver's bounding 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 () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int topHandle = topHandle ();

 	int [] argList = {OS.XmNx, 0, OS.XmNy, 0, OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};

 	OS.XtGetValues (topHandle, argList, argList.length / 2);

@@ -521,55 +531,54 @@
 	OS.XtTranslateCoords (parent.handle, (short) 0, (short) 0, topHandle_x, topHandle_y);

 	return new Point (handle_x [0] - topHandle_x [0], handle_y [0] - topHandle_y [0]);

 }

-String getCodePage () {

-	return Converter.getCodePage (OS.XtDisplay (handle), getFontList ());

-}

-/**

- * Returns the display that the receiver was created on.

- *

- * @return the receiver's display

- *

- * @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 the display that the receiver was created on.
+ *
+ * @return the receiver's display
+ *
+ * @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 Display getDisplay () {

 	Composite 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

- * not selectable from the user interface and draws with an

- * inactive or "grayed" look.

- *

- * @return the receiver's enabled 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 enabled, and
+ * <code>false</code> otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @return the receiver's enabled 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 getEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNsensitive, 0};

 	OS.XtGetValues (topHandle (), argList, argList.length / 2);

 	return argList [1] != 0;

 }

-/**

- * Returns the font that the receiver will use to paint textual information.

- *

- * @return the receiver's font

- *

- * @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 the font that the receiver will use to paint textual information.
+ *
+ * @return the receiver's font
+ *
+ * @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 Font getFont () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return Font.motif_new (getDisplay (), getFontList ());

 }

 

@@ -672,18 +681,19 @@
 	if (fontList == 0) fontList = defaultFont ();

 	return fontList;

 }

-/**

- * 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>

- */

+/**
+ * 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>
+ */
 public Color getForeground () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return Color.motif_new (getDisplay (), getXColor (getForegroundPixel ()));

 }

 int getForegroundPixel () {

@@ -691,74 +701,75 @@
 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-short [] getIMECaretPos () {

-	return new short[]{0, 0};

-}

-/**

- * Returns layout data which is associated with the receiver.

- *

- * @return the receiver's layout data

- *

- * @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 layout data which is associated with the receiver.
+ *
+ * @return the receiver's layout data
+ *
+ * @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 Object getLayoutData () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return layoutData;

 }

-/**

- * Returns a point describing the receiver's location relative

- * to its parent (or its display if its parent is null).

- *

- * @return the receiver's location

- *

- * @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 point describing the receiver's location relative
+ * to its parent (or its display if its parent is null).
+ *
+ * @return the receiver's location
+ *
+ * @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 Point getLocation () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int topHandle = topHandle ();

 	int [] argList = {OS.XmNx, 0, OS.XmNy, 0};

 	OS.XtGetValues (topHandle, argList, argList.length / 2);

 	return new Point ((short) argList [1], (short) argList [3]);

 }

-/**

- * Returns the receiver's pop up menu if it has one, or null

- * if it does not. All controls may optionally have a pop up

- * menu that is displayed when the user requests one for

- * the control. The sequence of key strokes, button presses

- * and/or button releases that are used to request a pop up

- * menu is platform specific.

- *

- * @return the receiver's menu

- *

- * @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 the receiver's pop up menu if it has one, or null
+ * if it does not. All controls may optionally have a pop up
+ * menu that is displayed when the user requests one for
+ * the control. The sequence of key strokes, button presses
+ * and/or button releases that are used to request a pop up
+ * menu is platform specific.
+ *
+ * @return the receiver's menu
+ *
+ * @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 Menu getMenu () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return menu;

 }

-/**

- * Returns the receiver's parent, which must be a <code>Composite</code>

- * or null when the receiver is a shell that was created with null or

- * a display for a parent.

- *

- * @return the receiver's parent

- *

- * @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 the receiver's parent, which must be a <code>Composite</code>
+ * or null when the receiver is a shell that was created with null or
+ * a display for a parent.
+ *
+ * @return the receiver's parent
+ *
+ * @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 Composite getParent () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent;

 }

 Control [] getPath () {

@@ -777,80 +788,84 @@
 	}

 	return result;

 }

-/**

- * Returns the receiver's shell. For all controls other than

- * shells, this simply returns the control's nearest ancestor

- * shell. Shells return themselves, even if they are children

- * of other shells.

- *

- * @return the receiver's shell

- *

- * @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 #getParent

- */

+/**
+ * Returns the receiver's shell. For all controls other than
+ * shells, this simply returns the control's nearest ancestor
+ * shell. Shells return themselves, even if they are children
+ * of other shells.
+ *
+ * @return the receiver's shell
+ *
+ * @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 #getParent
+ */
 public Shell getShell () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent.getShell ();

 }

-/**

- * Returns a point describing the receiver's size. The

- * x coordinate of the result is the width of the receiver.

- * The y coordinate of the result is the height of the

- * receiver.

- *

- * @return the receiver's size

- *

- * @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 point describing the receiver's size. The
+ * x coordinate of the result is the width of the receiver.
+ * The y coordinate of the result is the height of the
+ * receiver.
+ *
+ * @return the receiver's size
+ *
+ * @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 Point getSize () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int topHandle = topHandle ();

 	int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};

 	OS.XtGetValues (topHandle, argList, argList.length / 2);

 	int borders = argList [5] * 2;

 	return new Point (argList [1] + borders, argList [3] + borders);

 }

-/**

- * Returns the receiver's tool tip text, or null if it has

- * not been set.

- *

- * @return the receiver's tool tip text

- *

- * @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 the receiver's tool tip text, or null if it has
+ * not been set.
+ *
+ * @return the receiver's tool tip text
+ *
+ * @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 String getToolTipText () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return toolTipText;

 }

-/**

- * Returns <code>true</code> if the receiver is visible, and

- * <code>false</code> otherwise.

- * <p>

- * If one of the receiver's ancestors is not visible or some

- * other condition makes the receiver not visible, this method

- * may still indicate that it is considered visible even though

- * it may not actually be showing.

- * </p>

- *

- * @return the receiver's visibility 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 visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility 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 getVisible () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int topHandle = topHandle ();

 	int [] argList = {OS.XmNmappedWhenManaged, 0};

 	OS.XtGetValues (topHandle, argList, argList.length / 2);

@@ -884,26 +899,29 @@
 	OS.XtAddEventHandler (handle, OS.FocusChangeMask, false, windowProc, SWT.FocusIn);

 	OS.XtAddCallback (handle, OS.XmNhelpCallback, windowProc, SWT.Help);

 }

-/**	 

- * Invokes platform specific functionality to allocate a new GC handle.

- * <p>

- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public

- * API for <code>Control</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 data the platform specific GC data 

- * @return the platform specific GC handle

- *

- * @private

- */

-public int internal_new_GC (GCData data) {

-	checkWidget();

-	if (!OS.XtIsRealized (handle)) {

-		Shell shell = getShell ();

-		shell.realizeWidget ();

+int inputContext () {

+	return getShell ().inputContext ();

+}

+/**	 
+ * Invokes platform specific functionality to allocate a new GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Control</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 data the platform specific GC data 
+ * @return the platform specific GC handle
+ *
+ * @private
+ */
+public int internal_new_GC (GCData data) {
+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+	if (!OS.XtIsRealized (handle)) {
+		Shell shell = getShell ();
+		shell.realizeWidget ();
 	}

 	int xDisplay = OS.XtDisplay (handle);

 	if (xDisplay == 0) SWT.error(SWT.ERROR_NO_HANDLES);

@@ -925,94 +943,98 @@
 	}

 	return xGC;

 }

-/**	 

- * Invokes platform specific functionality to dispose a GC handle.

- * <p>

- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public

- * API for <code>Control</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 handle the platform specific GC handle

- * @param data the platform specific GC data 

- *

- * @private

- */

-public void internal_dispose_GC (int xGC, GCData data) {

-	int xDisplay = 0;

-	if (data != null) xDisplay = data.display;

+/**	 
+ * Invokes platform specific functionality to dispose a GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Control</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 handle the platform specific GC handle
+ * @param data the platform specific GC data 
+ *
+ * @private
+ */
+public void internal_dispose_GC (int xGC, GCData data) {
+	int xDisplay = 0;
+	if (data != null) xDisplay = data.display;
 	if (xDisplay == 0 && handle != 0) xDisplay = OS.XtDisplay (handle);

 	if (xDisplay == 0) SWT.error(SWT.ERROR_NO_HANDLES);

 	OS.XFreeGC (xDisplay, xGC);

 }

-/**

- * Returns <code>true</code> if the receiver is enabled, and

- * <code>false</code> otherwise. A disabled control is typically

- * not selectable from the user interface and draws with an

- * inactive or "grayed" look.

- *

- * @return the receiver's enabled 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 enabled, and
+ * <code>false</code> otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @return the receiver's enabled 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 isEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return getEnabled () && parent.isEnabled ();

 }

-/**

- * Returns <code>true</code> if the receiver has the user-interface

- * focus, and <code>false</code> otherwise.

- *

- * @return the receiver's focus 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 has the user-interface
+ * focus, and <code>false</code> otherwise.
+ *
+ * @return the receiver's focus 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 isFocusControl () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return hasFocus ();

 }

-/**

- * Returns <code>true</code> if the underlying operating

- * system supports this reparenting, otherwise <code>false</code>

- *

- * @return <code>true</code> if the widget can be reparented, otherwise <code>false</code>

- *

- * @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 underlying operating
+ * system supports this reparenting, otherwise <code>false</code>
+ *
+ * @return <code>true</code> if the widget can be reparented, otherwise <code>false</code>
+ *
+ * @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 isReparentable () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return false;

 }

-/**

- * Returns <code>true</code> if the receiver is visible, and

- * <code>false</code> otherwise.

- * <p>

- * If one of the receiver's ancestors is not visible or some

- * other condition makes the receiver not visible, this method

- * may still indicate that it is considered visible even though

- * it may not actually be showing.

- * </p>

- *

- * @return the receiver's visibility 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 visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility 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 isVisible () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return getVisible () && parent.isVisible ();

 }

 void manageChildren () {

@@ -1032,85 +1054,83 @@
 boolean mnemonicMatch (char key) {

 	return false;

 }

-/**

- * Moves the receiver above the specified control in the

- * drawing order. If the argument is null, then the receiver

- * is moved to the top of the drawing order. The control at

- * the top of the drawing order will not be covered by other

- * controls even if they occupy intersecting areas.

- *

- * @param the sibling control (or null)

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the control 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>

- */

+/**
+ * Moves the receiver above the specified control in the
+ * drawing order. If the argument is null, then the receiver
+ * is moved to the top of the drawing order. The control at
+ * the top of the drawing order will not be covered by other
+ * controls even if they occupy intersecting areas.
+ *
+ * @param the sibling control (or null)
+ *
+ * @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 moveAbove (Control control) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	setZOrder (control, true);

 }

-/**

- * Moves the receiver below the specified control in the

- * drawing order. If the argument is null, then the receiver

- * is moved to the bottom of the drawing order. The control at

- * the bottom of the drawing order will be covered by all other

- * controls which occupy intersecting areas.

- *

- * @param the sibling control (or null)

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the control 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>

- */

+/**
+ * Moves the receiver below the specified control in the
+ * drawing order. If the argument is null, then the receiver
+ * is moved to the bottom of the drawing order. The control at
+ * the bottom of the drawing order will be covered by all other
+ * controls which occupy intersecting areas.
+ *
+ * @param the sibling control (or null)
+ *
+ * @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 moveBelow (Control control) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	setZOrder (control, false);

 }

-/**

- * Causes the receiver to be resized to its preferred size.

- * For a composite, this involves computing the preferred size

- * from its layout, if there is one.

- *

- * @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 #computeSize

+/**
+ * Causes the receiver to be resized to its preferred size.
+ * For a composite, this involves computing the preferred size
+ * from its layout, if there is one.
+ *
+ * @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 #computeSize
  */

 public void pack () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	pack (true);

 }

-/**

- * Causes the receiver to be resized to its preferred size.

- * For a composite, this involves computing the preferred size

- * from its layout, if there is one.

- * <p>

- * If the changed flag is <code>true</code>, it indicates that the receiver's

- * <em>contents</em> have changed, therefore any caches that a layout manager

- * containing the control may have been keeping need to be flushed. When the

- * control is resized, the changed flag will be <code>false</code>, so layout

- * manager caches can be retained. 

- * </p>

- *

- * @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 #computeSize

+/**
+ * Causes the receiver to be resized to its preferred size.
+ * For a composite, this involves computing the preferred size
+ * from its layout, if there is one.
+ * <p>
+ * If the changed flag is <code>true</code>, it indicates that the receiver's
+ * <em>contents</em> have changed, therefore any caches that a layout manager
+ * containing the control may have been keeping need to be flushed. When the
+ * control is resized, the changed flag will be <code>false</code>, so layout
+ * manager caches can be retained. 
+ * </p>
+ *
+ * @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 #computeSize
  */

 public void pack (boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed));

 }

 int processDefaultSelection (int callData) {

@@ -1119,47 +1139,18 @@
 }

 int processFocusIn () {

 	sendEvent (SWT.FocusIn);

-	// widget could be disposed at this point

-	if (handle == 0) return 0;

-	processIMEFocusIn ();

+//	IsDBLocale ifTrue: [self killImeFocus].

 	return 0;

 }

 int processFocusOut () {

 	sendEvent (SWT.FocusOut);

-	// widget could be disposed at this point

-	if (handle == 0) return 0;

-	processIMEFocusOut ();

+//	IsDBLocale ifTrue: [self killImeFocus].

 	return 0;

 }

 int processHelp (int callData) {

 	sendHelpEvent (callData);

 	return 0;

 }

-int processIMEFocusIn () {

-	if (!(hooks (SWT.KeyDown) || hooks (SWT.KeyUp))) return 0;

-	short [] point = getIMECaretPos ();

-	int ptr = OS.XtMalloc (4);

-	OS.memmove (ptr, point, 4);

-	

-	/*

-	* Bug in Motif. On Linux Japanese only, XmImSetFocusValues will cause

-	* a GPF. The fix is to call XmImVaSetFocusValues instead.

-	*/

-	OS.XmImVaSetFocusValues (handle, 

-		OS.XmNforeground, getForegroundPixel(),

-		OS.XmNbackground, getBackgroundPixel(),

-		OS.XmNspotLocation, ptr,

-		OS.XmNfontList, getFontList(),

-		0);

-	

-	if (ptr != 0) OS.XtFree (ptr);

-	return 0;

-}

-int processIMEFocusOut () {

-	if (!(hooks (SWT.KeyDown) || hooks (SWT.KeyUp))) return 0;

-	OS.XmImUnsetFocus (handle);

-	return 0;

-}

 int processKeyDown (int callData) {

 	XKeyEvent xEvent = new XKeyEvent ();

 	OS.memmove (xEvent, callData, XKeyEvent.sizeof);

@@ -1356,56 +1347,89 @@
 void propagateChildren (boolean enabled) {

 	propagateWidget (enabled);

 }

+void propagateHandle (boolean enabled, int widgetHandle) {

+	int xDisplay = OS.XtDisplay (widgetHandle);

+	if (xDisplay == 0) return;

+	int xWindow = OS.XtWindow (widgetHandle);

+	if (xWindow == 0) return;

+	int event_mask = OS.XtBuildEventMask (widgetHandle);

+	int do_not_propagate_mask = OS.KeyPressMask | OS.KeyReleaseMask | OS.ButtonPressMask | OS.ButtonReleaseMask | OS.PointerMotionMask;

+	if (!enabled) {

+		event_mask &= ~do_not_propagate_mask;

+		do_not_propagate_mask = 0;

+	}

+	XSetWindowAttributes attributes = new XSetWindowAttributes ();

+	attributes.event_mask = event_mask;

+	attributes.do_not_propagate_mask = do_not_propagate_mask;

+	OS.XChangeWindowAttributes (xDisplay, xWindow, OS.CWDontPropagate | OS.CWEventMask, attributes);

+	int [] argList = {OS.XmNtraversalOn, enabled ? 1 : 0};

+	OS.XtSetValues (widgetHandle, argList, argList.length / 2);

+}

 void propagateWidget (boolean enabled) {

 	propagateHandle (enabled, handle);

 }

 void realizeChildren () {

 	if (!isEnabled ()) propagateWidget (false);

 }

-/**

- * Causes the entire bounds of the receiver to be marked

- * as needing to be redrawn. The next time a paint request

- * is processed, the control will be completely painted.

- *

- * @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 #update

- */

+/**
+ * Causes the entire bounds of the receiver to be marked
+ * as needing to be redrawn. The next time a paint request
+ * is processed, the control will be completely painted.
+ *
+ * @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 #update
+ */
 public void redraw () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	redrawWidget (0, 0, 0, 0, false);

 }

-/**

- * Causes the rectangular area of the receiver specified by

- * the arguments to be marked as needing to be redrawn. 

- * The next time a paint request is processed, that area of

- * the receiver will be painted. If the <code>all</code> flag

- * is <code>true</code>, any children of the receiver which

- * intersect with the specified area will also paint their

- * intersecting areas. If the <code>all</code> flag is 

- * <code>false</code>, the children will not be painted.

- *

- * @param x the x coordinate of the area to draw

- * @param y the y coordinate of the area to draw

- * @param width the width of the area to draw

- * @param height the height of the area to draw

- * @param all <code>true</code> if children should redraw, and <code>false</code> 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>

- *

- * @see #update

- */

+/**
+ * Causes the rectangular area of the receiver specified by
+ * the arguments to be marked as needing to be redrawn. 
+ * The next time a paint request is processed, that area of
+ * the receiver will be painted. If the <code>all</code> flag
+ * is <code>true</code>, any children of the receiver which
+ * intersect with the specified area will also paint their
+ * intersecting areas. If the <code>all</code> flag is 
+ * <code>false</code>, the children will not be painted.
+ *
+ * @param x the x coordinate of the area to draw
+ * @param y the y coordinate of the area to draw
+ * @param width the width of the area to draw
+ * @param height the height of the area to draw
+ * @param all <code>true</code> if children should redraw, and <code>false</code> 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>
+ *
+ * @see #update
+ */
 public void redraw (int x, int y, int width, int height, boolean all) {

-	checkWidget ();

-	if (width <= 0 || height <= 0) return;

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	if (x == 0 && y == 0 && width == 0 && height == 0) return;

 	redrawWidget (x, y, width, height, all);

 }

+void redrawHandle (int x, int y, int width, int height, int widgetHandle) {

+	int display = OS.XtDisplay (widgetHandle);

+	if (display == 0) return;

+	int window = OS.XtWindow (widgetHandle);

+	if (window == 0) return;

+	int [] argList = {OS.XmNborderWidth, 0, OS.XmNborderColor, 0};

+	OS.XtGetValues (widgetHandle, argList, argList.length / 2);

+	if (argList [1] != 0) {

+		/* Force the border to repaint by setting the color */

+		OS.XtSetValues (widgetHandle, argList, argList.length / 2);

+	}

+	OS.XClearArea (display, window, x, y, width, height, true);

+}

 void redrawWidget (int x, int y, int width, int height, boolean all) {

 	redrawHandle (x, y, width, height, handle);

 }

@@ -1418,219 +1442,247 @@
 		menu.dispose ();

 	}

 	menu = null;

-	OS.XmImUnregister (handle);

+/*

+	"Release the IME."

+	self isMenu ifFalse: [

+		handle xtIsWidget ifTrue: [

+			handle xmImUnregister.

+

+			"Bug in X.  On Solaris only, destroying the window that has IME focus causes

+			a segment fault.  The fix is to set focus to the IME client window (typically

+			the shell) when the receiver is being destroyed.  Destroying the shell window

+			does not have the problem.  Note that this fix is not necessary on AIX."

+			(xIC := self inputContext) == nil ifFalse: [

+				(window := handle xtWindow) isNull ifFalse: [

+					xIC xGetICValues: XNFocusWindow with: (buffer := ByteArray new: 4) with: 0.

+					(buffer uint32At: 0) = window asInteger ifTrue: [

+						xIC xGetICValues: XNClientWindow with: (buffer := ByteArray new: 4) with: 0.

+						xIC

+							xUnsetICFocus;

+							xSetICValues: XNFocusWindow with: (buffer uint32At: 0) with: 0;

+							xSetICFocus]]]]].

+*/

 	parent = null;

 	layoutData = null;

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the control is moved or resized.

- *

- * @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 ControlListener

- * @see #addControlListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is moved or resized.
+ *
+ * @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 ControlListener
+ * @see #addControlListener
  */

 public void removeControlListener (ControlListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Move, listener);

 	eventTable.unhook (SWT.Resize, listener);

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the control gains or loses focus.

- *

- * @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 FocusListener

- * @see #addFocusListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control gains or loses focus.
+ *
+ * @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 FocusListener
+ * @see #addFocusListener
  */

 public void removeFocusListener(FocusListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook(SWT.FocusIn, listener);

 	eventTable.unhook(SWT.FocusOut, listener);

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the help events are generated for the control.

- *

- * @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 #addHelpListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the help events are generated for the control.
+ *
+ * @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 #addHelpListener
  */

 public void removeHelpListener (HelpListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Help, listener);

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when keys are pressed and released on the system keyboard.

- *

- * @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 KeyListener

- * @see #addKeyListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when keys are pressed and released on the system keyboard.
+ *
+ * @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 KeyListener
+ * @see #addKeyListener
  */

 public void removeKeyListener(KeyListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook(SWT.KeyUp, listener);

 	eventTable.unhook(SWT.KeyDown, listener);

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when mouse buttons are pressed and released.

- *

- * @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 MouseListener

- * @see #addMouseListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when mouse buttons are pressed and released.
+ *
+ * @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 MouseListener
+ * @see #addMouseListener
  */

 public void removeMouseListener(MouseListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook(SWT.MouseDown, listener);

 	eventTable.unhook(SWT.MouseUp, listener);

 	eventTable.unhook(SWT.MouseDoubleClick, listener);

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the mouse moves.

- *

- * @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 MouseMoveListener

- * @see #addMouseMoveListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the mouse moves.
+ *
+ * @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 MouseMoveListener
+ * @see #addMouseMoveListener
  */

 public void removeMouseMoveListener(MouseMoveListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook(SWT.MouseMove, listener);

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the mouse passes or hovers over controls.

- *

- * @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 MouseTrackListener

- * @see #addMouseTrackListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the mouse passes or hovers over controls.
+ *
+ * @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 MouseTrackListener
+ * @see #addMouseTrackListener
  */

 public void removeMouseTrackListener(MouseTrackListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.MouseEnter, listener);

 	eventTable.unhook (SWT.MouseExit, listener);

 	eventTable.unhook (SWT.MouseHover, listener);

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the receiver needs to be painted.

- *

- * @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 PaintListener

- * @see #addPaintListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver needs to be painted.
+ *
+ * @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 PaintListener
+ * @see #addPaintListener
  */

 public void removePaintListener(PaintListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook(SWT.Paint, listener);

-}/**

- * Removes the listener from the collection of listeners who will

- * be notified when traversal events occur.

- *

- * @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 TraverseListener

- * @see #addTraverseListener

+}/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when traversal events occur.
+ *
+ * @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 TraverseListener
+ * @see #addTraverseListener
  */

 public void removeTraverseListener(TraverseListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Traverse, listener);

@@ -1645,29 +1697,33 @@
 		control = control.parent;

 	}

 }

-byte [] sendKeyEvent (int type, XKeyEvent xEvent) {

+void sendKeyEvent (int type, XKeyEvent xEvent) {

 	

 	/* Look up the keysym and character(s) */

 	byte [] buffer;

 	boolean isVirtual = false;

-	int [] keysym = new int [1];

+	int [] keysym = new int [1], status = new int [1];

 	if (xEvent.keycode != 0) {

 		buffer = new byte [1];

-		isVirtual = OS.XLookupString (xEvent, buffer, buffer.length, keysym, null) == 0;

+		isVirtual = OS.XLookupString (xEvent, buffer, buffer.length, keysym, status) == 0;

 	} else {

-		/*

-		* Bug in Motif. On Linux only, XmImMbLookupString() does not return 

-		* XBufferOverflow as the status if the buffer is too small. The fix is

-		* to pass a bigger buffer.

-		*/

-		buffer = new byte [512];

-		int [] status = new int [1];

-		int size = OS.XmImMbLookupString (handle, xEvent, buffer, buffer.length, keysym, status);

-		if (status [0] == OS.XBufferOverflow) {

-			buffer = new byte [size];

-			size = OS.XmImMbLookupString (handle, xEvent, buffer, size, keysym, status);

+		int size = 0;

+		buffer = new byte [2];

+		int xIC = inputContext ();

+		if (xIC == 0) {

+			size = OS.XmImMbLookupString (handle, xEvent, buffer, buffer.length, keysym, status);

+			if (status [0] == OS.XBufferOverflow) {

+				buffer = new byte [size];

+				size = OS.XmImMbLookupString (handle, xEvent, buffer, size, keysym, status);

+			}

+		} else {

+			size = OS.XmbLookupString (xIC, xEvent, buffer, buffer.length, keysym, status);

+			if (status [0] == OS.XBufferOverflow) {

+				buffer = new byte [size];

+				size = OS.XmbLookupString (xIC, xEvent, buffer, size, keysym, status);

+			}

 		}

-		if (size == 0) return null;

+		if (size == 0) return;

 	}

 

 	/*

@@ -1676,7 +1732,7 @@
 	* to 0x1005FF10 and 0x1005FF11 respectively.  The fix is to

 	* look for these values explicitly and correct them.

 	*/

-	if (OS.IsSunOS) {

+	if (IsSunOS) {

 		if ((keysym [0] == 0x1005FF10) || (keysym [0] == 0x1005FF11)) {

 			if (keysym [0] == 0x1005FF10) keysym [0] = OS.XK_F11;

 			if (keysym [0] == 0x1005FF11) keysym [0] = OS.XK_F12;

@@ -1692,14 +1748,11 @@
 	keysym [0] &= 0xFFFF;

 

 	/* Convert from MBCS to UNICODE and send the event */

-	/* Use the character encoding for the default locale */

 	char [] result = Converter.mbcsToWcs (null, buffer);

-	int index = 0;

-	while (index < result.length) {

-		if (result [index] == 0) break;

+	for (int i=0; i<result.length; i++) {

 		Event event = new Event ();

 		event.time = xEvent.time;

-		event.character = result [index];

+		event.character = result [i];

 		if (isVirtual) event.keyCode = Display.translateKey (keysym [0]);

 		if ((xEvent.state & OS.Mod1Mask) != 0) event.stateMask |= SWT.ALT;

 		if ((xEvent.state & OS.ShiftMask) != 0) event.stateMask |= SWT.SHIFT;

@@ -1708,10 +1761,7 @@
 		if ((xEvent.state & OS.Button2Mask) != 0) event.stateMask |= SWT.BUTTON2;

 		if ((xEvent.state & OS.Button3Mask) != 0) event.stateMask |= SWT.BUTTON3;

 		postEvent (type, event);

-		index++;

 	}

-	

-	return buffer;

 }

 void sendMouseEvent (int type, int button, int mask, XWindowEvent xEvent) {

 	Event event = new Event ();

@@ -1726,27 +1776,25 @@
 	if ((mask & OS.Button3Mask) != 0) event.stateMask |= SWT.BUTTON3;

 	postEvent (type, event);

 }

-/**

- * Sets the receiver's background color to the color specified

- * by the argument, or to the default system color for the control

- * 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>

- */

+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @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 setBackground (Color color) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (color == null) {

 		setBackgroundPixel (defaultBackground ());

 	} else {

-		if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

+		if (color.isDisposed ()) return;

 		setBackgroundPixel (color.handle.pixel);

 	}

 }

@@ -1756,29 +1804,30 @@
 	OS.XmChangeColor (handle, pixel);

 	OS.XtSetValues (handle, argList, argList.length / 2);

 }

-/**

- * Sets the receiver's size and location to the rectangular

- * area specified by the arguments. The <code>x</code> and 

- * <code>y</code> arguments are relative to the receiver's

- * parent (or its display if its parent is null).

- * <p>

- * Note: Attempting to set the width or height of the

- * receiver to a negative number will cause that

- * value to be set to zero instead.

- * </p>

- *

- * @param x the new x coordinate for the receiver

- * @param y the new y coordinate for the receiver

- * @param width the new width for the receiver

- * @param height the new height for the receiver

- *

- * @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>

- */

+/**
+ * Sets the receiver's size and location to the rectangular
+ * area specified by the arguments. The <code>x</code> and 
+ * <code>y</code> arguments are relative to the receiver's
+ * parent (or its display if its parent is null).
+ * <p>
+ * Note: Attempting to set the width or height of the
+ * receiver to a negative number will cause that
+ * value to be set to zero instead.
+ * </p>
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ * @param width the new width for the receiver
+ * @param height the new height for the receiver
+ *
+ * @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 setBounds (int x, int y, int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	/*

 	* Feature in Motif.  Motif will not allow a window

 	* to have a zero width or zero height.  The fix is

@@ -1802,42 +1851,43 @@
 	if (!sameOrigin) sendEvent (SWT.Move);

 	if (!sameExtent) sendEvent (SWT.Resize);

 }

-/**

- * Sets the receiver's size and location to the rectangular

- * area specified by the argument. The <code>x</code> and 

- * <code>y</code> fields of the rectangle are relative to

- * the receiver's parent (or its display if its parent is null).

- * <p>

- * Note: Attempting to set the width or height of the

- * receiver to a negative number will cause that

- * value to be set to zero instead.

- * </p>

- *

- * @param rect the new bounds for the receiver

- *

- * @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>

- */

+/**
+ * Sets the receiver's size and location to the rectangular
+ * area specified by the argument. The <code>x</code> and 
+ * <code>y</code> fields of the rectangle are relative to
+ * the receiver's parent (or its display if its parent is null).
+ * <p>
+ * Note: Attempting to set the width or height of the
+ * receiver to a negative number will cause that
+ * value to be set to zero instead.
+ * </p>
+ *
+ * @param rect the new bounds for the receiver
+ *
+ * @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 setBounds (Rectangle rect) {

 	if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);

 	setBounds (rect.x, rect.y, rect.width, rect.height);

 }

-/**

- * If the argument is <code>true</code>, causes the receiver to have

- * all mouse events delivered to it until the method is called with

- * <code>false</code> as the argument.

- *

- * @param capture <code>true</code> to capture the mouse, and <code>false</code> to release it

- *

- * @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>

- */

+/**
+ * If the argument is <code>true</code>, causes the receiver to have
+ * all mouse events delivered to it until the method is called with
+ * <code>false</code> as the argument.
+ *
+ * @param capture <code>true</code> to capture the mouse, and <code>false</code> to release it
+ *
+ * @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 setCapture (boolean capture) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int display = OS.XtDisplay (handle);

 	if (display == 0) return;

 	if (capture) {

@@ -1857,27 +1907,25 @@
 		OS.XUngrabPointer (display, OS.CurrentTime);

 	}

 }

-/**

- * Sets the receiver's cursor to the cursor specified by the

- * argument, or to the default cursor for that kind of control

- * if the argument is null.

- * <p>

- * When the mouse pointer passes over a control its appearance

- * is changed to match the control's cursor.

- * </p>

- *

- * @param cursor the new cursor (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>

- */

+/**
+ * Sets the receiver's cursor to the cursor specified by the
+ * argument, or to the default cursor for that kind of control
+ * if the argument is null.
+ * <p>
+ * When the mouse pointer passes over a control its appearance
+ * is changed to match the control's cursor.
+ * </p>
+ *
+ * @param cursor the new cursor (or null)
+ *
+ * @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 setCursor (Cursor cursor) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int display = OS.XtDisplay (handle);

 	if (display == 0) return;

 	int window = OS.XtWindow (handle);

@@ -1889,74 +1937,70 @@
 	if (cursor == null) {

 		OS.XUndefineCursor (display, window);

 	} else {

-		if (cursor.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 		int xCursor = cursor.handle;

 		OS.XDefineCursor (display, window, xCursor);

 		OS.XFlush (display);

 	}

 }

-/**

- * Enables the receiver if the argument is <code>true</code>,

- * and disables it otherwise. A disabled control is typically

- * not selectable from the user interface and draws with an

- * inactive or "grayed" look.

- *

- * @param enabled the new enabled 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>

- */

+/**
+ * Enables the receiver if the argument is <code>true</code>,
+ * and disables it otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @param enabled the new enabled 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 void setEnabled (boolean enabled) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	enableWidget (enabled);

 	if (!enabled || (isEnabled () && enabled)) {

 		propagateChildren (enabled);

 	}

 }

-/**

- * Causes the receiver to have the <em>keyboard focus</em>, 

- * such that all keyboard events will be delivered to it.

- *

- * @return <code>true</code> if the control got focus, and <code>false</code> if it was unable to.

- *

- * @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 #forceFocus

- */

+/**
+ * Causes the receiver to have the <em>keyboard focus</em>, 
+ * such that all keyboard events will be delivered to it.
+ *
+ * @return <code>true</code> if the control got focus, and <code>false</code> if it was unable to.
+ *
+ * @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 #forceFocus
+ */
 public boolean setFocus () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	Decorations shell = menuShell ();

 	shell.setSavedFocus (this);

 	shell.bringToTop ();

 	return OS.XmProcessTraversal (handle, OS.XmTRAVERSE_CURRENT);

 }

-/**

- * Sets the font that the receiver will use to paint textual information

- * to the font specified by the argument, or to the default font for that

- * kind of control if the argument is null.

- *

- * @param font the new font (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>

- */

+/**
+ * Sets the font that the receiver will use to paint textual information
+ * to the font specified by the argument, or to the default font for that
+ * kind of control if the argument is null.
+ *
+ * @param font the new font (or null)
+ *
+ * @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 setFont (Font font) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int fontList = 0;

-	if (font != null) {

-		if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

-		fontList = font.handle;

-	}

+	if (font != null) fontList = font.handle;

 	if (fontList == 0) fontList = defaultFont ();

 	setFontList (fontList);

 }

@@ -1981,27 +2025,25 @@
 	/* Restore the widget size */

 	OS.XtSetValues (handle, argList1, argList1.length / 2);

 }

-/**

- * Sets the receiver's foreground color to the color specified

- * by the argument, or to the default system color for the control

- * 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>

- */

+/**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @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 setForeground (Color color) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (color == null) {

 		setForegroundPixel (defaultForeground ());

 	} else {

-		if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

+		if (color.isDisposed ()) return;

 		setForegroundPixel (color.handle.pixel);

 	}

 }

@@ -2034,8 +2076,8 @@
 	if (xEvent.keycode != 0) {

 		event.time = xEvent.time;

 		byte [] buffer1 = new byte [1];

-		int [] keysym = new int [1];

-		if (OS.XLookupString (xEvent, buffer1, buffer1.length, keysym, null) == 0) {

+		int [] keysym = new int [1], status = new int [1];

+		if (OS.XLookupString (xEvent, buffer1, buffer1.length, keysym, status) == 0) {

 			event.keyCode = Display.translateKey (keysym [0] & 0xFFFF);

 		} else {

 			event.character = (char) buffer1 [0];

@@ -2048,35 +2090,37 @@
 		if ((xEvent.state & OS.Button3Mask) != 0) event.stateMask |= SWT.BUTTON3;

 	}	

 }

-/**

- * Sets the layout data associated with the receiver to the argument.

- * 

- * @param layoutData the new layout data for the receiver.

- * 

- * @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>

- */

+/**
+ * Sets the layout data associated with the receiver to the argument.
+ * 
+ * @param layoutData the new layout data for the receiver.
+ * 
+ * @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 setLayoutData (Object layoutData) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	this.layoutData = layoutData;

 }

-/**

- * Sets the receiver's location to the point specified by

- * the arguments which are relative to the receiver's

- * parent (or its display if its parent is null).

- *

- * @param x the new x coordinate for the receiver

- * @param y the new y coordinate for the receiver

- *

- * @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>

- */

+/**
+ * Sets the receiver's location to the point specified by
+ * the arguments which are relative to the receiver's
+ * parent (or its display if its parent is null).
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ *
+ * @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 setLocation (int x, int y) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int topHandle = topHandle ();

 	int [] argList = {OS.XmNx, 0, OS.XmNy, 0};

 	OS.XtGetValues (topHandle, argList, argList.length / 2);

@@ -2085,46 +2129,45 @@
 	OS.XtMoveWidget (topHandle, x, y);

 	if (!sameOrigin) sendEvent (SWT.Move);

 }

-/**

- * Sets the receiver's location to the point specified by

- * the argument which is relative to the receiver's

- * parent (or its display if its parent is null).

- *

- * @param location the new location for the receiver

- *

- * @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>

- */

+/**
+ * Sets the receiver's location to the point specified by
+ * the argument which is relative to the receiver's
+ * parent (or its display if its parent is null).
+ *
+ * @param location the new location for the receiver
+ *
+ * @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 setLocation (Point location) {

 	if (location == null) error (SWT.ERROR_NULL_ARGUMENT);

 	setLocation (location.x, location.y);

 }

-/**

- * Sets the receiver's pop up menu to the argument.

- * All controls may optionally have a pop up

- * menu that is displayed when the user requests one for

- * the control. The sequence of key strokes, button presses

- * and/or button releases that are used to request a pop up

- * menu is platform specific.

- *

- * @param menu the new pop up menu

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_MENU_NOT_POP_UP - the menu is not a pop up menu</li>

- *    <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>

- *    <li>ERROR_INVALID_ARGUMENT - if the menu 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>

+/**
+ * Sets the receiver's pop up menu to the argument.
+ * All controls may optionally have a pop up
+ * menu that is displayed when the user requests one for
+ * the control. The sequence of key strokes, button presses
+ * and/or button releases that are used to request a pop up
+ * menu is platform specific.
+ *
+ * @param menu the new pop up menu
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_MENU_NOT_POP_UP - the menu is not a pop up menu</li>
+ *    <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</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>
  */

 public void setMenu (Menu menu) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (menu != null) {

-		if (menu.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 		if ((menu.style & SWT.POP_UP) == 0) {

 			error (SWT.ERROR_MENU_NOT_POP_UP);

 		}

@@ -2135,71 +2178,70 @@
 	this.menu = menu;

 }

 

-/**

- * Changes the parent of the widget to be the one provided if

- * the underlying operating system supports this feature.

- * Answers <code>true</code> if the parent is successfully changed.

- *

- * @param parent the new parent for the control.

- * @return <code>true</code> if the parent is changed and <code>false</code> otherwise.

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 

- * </ul>

- * @exception SWTError <ul>

- *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>

- *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>

- *	</ul>

+/**
+ * Changes the parent of the widget to be the one provided if
+ * the underlying operating system supports this feature.
+ * Answers <code>true</code> if the parent is successfully changed.
+ *
+ * @param parent the new parent for the control.
+ * @return <code>true</code> if the parent is changed and <code>false</code> otherwise.
+ *
+ * @exception SWTError <ul>
+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *	</ul>
  */

 public boolean setParent (Composite parent) {

-	checkWidget();

-	if (parent.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return false;

 }

 

-/**

- * If the argument is <code>false</code>, causes subsequent drawing

- * operations in the receiver to be ignored. No drawing of any kind

- * can occur in the receiver until the flag is set to true.

- * Graphics operations that occurred while the flag was

- * <code>false</code> are lost. When the flag is set to <code>true</code>,

- * the entire widget is marked as needing to be redrawn.

- * <p>

- * Note: This operation is a hint and may not be supported on some

- * platforms or for some widgets.

- * </p>

- *

- * @param redraw the new redraw 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>

- * 

- * @see #redraw

- * @see #update

- */

+/**
+ * If the argument is <code>false</code>, causes subsequent drawing
+ * operations in the receiver to be ignored. No drawing of any kind
+ * can occur in the receiver until the flag is set to true.
+ * Graphics operations that occurred while the flag was
+ * <code>false</code> are lost. When the flag is set to <code>true</code>,
+ * the entire widget is marked as needing to be redrawn.
+ * <p>
+ * Note: This operation is a hint and may not be supported on some
+ * platforms or for some widgets.
+ * </p>
+ *
+ * @param redraw the new redraw 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>
+ * 
+ * @see #redraw
+ * @see #update
+ */
 public void setRedraw (boolean redraw) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 }

-/**

- * Sets the receiver's size to the point specified by the arguments.

- * <p>

- * Note: Attempting to set the width or height of the

- * receiver to a negative number will cause that

- * value to be set to zero instead.

- * </p>

- *

- * @param width the new width for the receiver

- * @param height the new height for the receiver

- *

- * @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>

- */

+/**
+ * Sets the receiver's size to the point specified by the arguments.
+ * <p>
+ * Note: Attempting to set the width or height of the
+ * receiver to a negative number will cause that
+ * value to be set to zero instead.
+ * </p>
+ *
+ * @param width the new width for the receiver
+ * @param height the new height for the receiver
+ *
+ * @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 setSize (int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	/*

 	* Feature in Motif.  Motif will not allow a window

 	* to have a zero width or zero height.  The fix is

@@ -2215,62 +2257,64 @@
 	OS.XtResizeWidget (topHandle, newWidth, newHeight, argList [5]);

 	if (!sameExtent) sendEvent (SWT.Resize);

 }

-/**

- * Sets the receiver's size to the point specified by the argument.

- * <p>

- * Note: Attempting to set the width or height of the

- * receiver to a negative number will cause them to be

- * set to zero instead.

- * </p>

- *

- * @param size the new size for the receiver

- * @param height the new height for the receiver

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the point 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>

- */

+/**
+ * Sets the receiver's size to the point specified by the argument.
+ * <p>
+ * Note: Attempting to set the width or height of the
+ * receiver to a negative number will cause them to be
+ * set to zero instead.
+ * </p>
+ *
+ * @param size the new size for the receiver
+ * @param height the new height for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point 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>
+ */
 public void setSize (Point size) {

 	if (size == null) error (SWT.ERROR_NULL_ARGUMENT);

 	setSize (size.x, size.y);

 }

-/**

- * Sets the receiver's tool tip text to the argument, which

- * may be null indicating that no tool tip text should be shown.

- *

- * @param string the new tool tip text (or null)

- *

- * @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>

+/**
+ * Sets the receiver's tool tip text to the argument, which
+ * may be null indicating that no tool tip text should be shown.
+ *
+ * @param string the new tool tip text (or null)
+ *
+ * @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 setToolTipText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	toolTipText = string;

 }

-/**

- * Marks the receiver as visible if the argument is <code>true</code>,

- * and marks it invisible otherwise. 

- * <p>

- * If one of the receiver's ancestors is not visible or some

- * other condition makes the receiver not visible, marking

- * it visible may not actually cause it to be displayed.

- * </p>

- *

- * @param visible the new visibility 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>

- */

+/**
+ * Marks the receiver as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility 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 void setVisible (boolean visible) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int topHandle = topHandle ();

 	int [] argList = {OS.XmNmappedWhenManaged, 0};

 	OS.XtGetValues (topHandle, argList, argList.length / 2);

@@ -2306,7 +2350,6 @@
 		}

 		return;

 	}

-	if (control.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 	int topHandle2 = control.topHandle ();

 	if (display != OS.XtDisplay (topHandle2)) return;

 	if (!OS.XtIsRealized (topHandle2)) {

@@ -2336,44 +2379,46 @@
 		if (parent != null) parent.moveBelow (topHandle1, topHandle2);

 	}

 }

-/**

- * Returns a point which is the result of converting the

- * argument, which is specified in display relative coordinates,

- * to coordinates relative to the receiver.

- * <p>

- * @param point the point to be translated (must not be null)

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the point 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>

- */

+/**
+ * Returns a point which is the result of converting the
+ * argument, which is specified in display relative coordinates,
+ * to coordinates relative to the receiver.
+ * <p>
+ * @param point the point to be translated (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point 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>
+ */
 public Point toControl (Point point) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	short [] root_x = new short [1], root_y = new short [1];

 	OS.XtTranslateCoords (handle, (short) 0, (short) 0, root_x, root_y);

 	return new Point (point.x - root_x [0], point.y - root_y [0]);

 }

-/**

- * Returns a point which is the result of converting the

- * argument, which is specified in coordinates relative to

- * the receiver, to display relative coordinates.

- * <p>

- * @param point the point to be translated (must not be null)

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the point 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>

- */

+/**
+ * Returns a point which is the result of converting the
+ * argument, which is specified in coordinates relative to
+ * the receiver, to display relative coordinates.
+ * <p>
+ * @param point the point to be translated (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point 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>
+ */
 public Point toDisplay (Point point) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	short [] root_x = new short [1], root_y = new short [1];

 	OS.XtTranslateCoords (handle, (short) point.x, (short) point.y, root_x, root_y);

 	return new Point (root_x [0], root_y [0]);

@@ -2461,23 +2506,24 @@
 	if (!isVisible () || !isEnabled ()) return false;

 	return mnemonicMatch (key) && mnemonicHit ();

 }

-/**

- * Based on the argument, perform one of the expected platform

- * traversal action. The argument should be one of the constants:

- * <code>SWT.TRAVERSE_ESCAPE</code>, <code>SWT.TRAVERSE_RETURN</code>, 

- * <code>SWT.TRAVERSE_TAB_NEXT</code>, <code>SWT.TRAVERSE_TAB_PREVIOUS</code>, 

- * <code>SWT.TRAVERSE_ARROW_NEXT</code> and <code>SWT.TRAVERSE_ARROW_PREVIOUS</code>.

- *

- * @param traversal the type of traversal

- * @return true if the traversal succeeded

- *

- * @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>

+/**
+ * Based on the argument, perform one of the expected platform
+ * traversal action. The argument should be one of the constants:
+ * <code>SWT.TRAVERSE_ESCAPE</code>, <code>SWT.TRAVERSE_RETURN</code>, 
+ * <code>SWT.TRAVERSE_TAB_NEXT</code>, <code>SWT.TRAVERSE_TAB_PREVIOUS</code>, 
+ * <code>SWT.TRAVERSE_ARROW_NEXT</code> and <code>SWT.TRAVERSE_ARROW_PREVIOUS</code>.
+ *
+ * @param traversal the type of traversal
+ * @return true if the traversal succeeded
+ *
+ * @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 traverse (int traversal) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (!isFocusControl () && !setFocus ()) return false;

 	switch (traversal) {

 		case SWT.TRAVERSE_ESCAPE:		return traverseEscape ();

@@ -2509,19 +2555,20 @@
 	button.click ();

 	return true;

 }

-/**

- * Forces all outstanding paint requests for the widget tree

- * to be processed before this method returns.

- *

- * @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 #redraw

- */

+/**
+ * Forces all outstanding paint requests for the widget tree
+ * to be processed before this method returns.
+ *
+ * @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 #redraw
+ */
 public void update () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int display = OS.XtDisplay (handle);

 	if (display == 0) return;

 	int window = OS.XtWindow (handle);

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/CoolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/CoolBar.java
index d8fa98f..8b6bef2 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/CoolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/CoolBar.java
@@ -11,61 +11,61 @@
 import org.eclipse.swt.graphics.*;

 import java.util.*;

 

-/**

- * Instances of this class provide an area for dynamically

- * positioning the items they contain.

- * <p>

- * The item children that may be added to instances of this class

- * must be of type <code>CoolItem</code>.

- * </p><p>

- * Note that although this class is a subclass of <code>Composite</code>,

- * it does not make sense to add <code>Control</code> children to it,

- * or set a layout on it.

- * </p><p>

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>(none)</dd>

- * <dt><b>Events:</b></dt>

- * <dd>(none)</dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is <em>not</em> intended to be subclassed.

- * </p>

- */

+/**
+ * Instances of this class provide an area for dynamically
+ * positioning the items they contain.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>CoolItem</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
 public /*final*/ class CoolBar extends Composite {

 	Vector rows;

 	Cursor hoverCursor;

 	Cursor dragCursor;

 	static final int ROW_SPACING = 2;

 		

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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

- */

+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <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
+ *
+ * @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 CoolBar (Composite parent, int style) {

 	super (parent, style);

 }

@@ -73,7 +73,8 @@
 	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);

 }

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int width = wHint, height = hHint;

 	if (wHint == SWT.DEFAULT) width = 0x7FFFFFFF;

 	if (hHint == SWT.DEFAULT) height = 0x7FFFFFFF;

@@ -82,26 +83,27 @@
 	if (hHint != SWT.DEFAULT) extent.y = hHint;

 	return extent;

 }

-/**

- * Returns the item at the given, zero-relative index in the

- * receiver. Throws an exception if the index is out of range.

- *

- * @param index the index of the item to return

- * @return the item at the given index

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>

- * @exception SWTError <ul>

- *    <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>

- * </ul>

- */

+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
 public CoolItem getItem (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (index < 0) error (SWT.ERROR_INVALID_RANGE);

 	for (int i = 0; i < rows.size(); i++) {

 		Vector row = (Vector) rows.elementAt(i);

@@ -114,21 +116,22 @@
 	error (SWT.ERROR_INVALID_RANGE);

 	return null;

 }

-/**

- * Returns the number of items contained in the receiver.

- *

- * @return the number of items

- *

- * @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>

- * @exception SWTError <ul>

- *    <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>

- * </ul>

- */

+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
 public int getItemCount () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int itemCount = 0;

 	for (int i = 0; i < rows.size(); i++) {

 		Vector row = (Vector) rows.elementAt(i);

@@ -136,27 +139,28 @@
 	}

 	return itemCount;

 }

-/**

- * Returns an array of <code>CoolItems</code>s which are the

- * items in the receiver in the order those items were added. 

- * <p>

- * Note: This is not the actual structure used by the receiver

- * to maintain its list of items, so modifying the array will

- * not affect the receiver. 

- * </p>

- *

- * @return the receiver's items

- *

- * @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>

- * @exception SWTError <ul>

- *    <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>

- * </ul>

- */

+/**
+ * Returns an array of <code>CoolItems</code>s which are the
+ * items in the receiver in the order those items were added. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the receiver's items
+ *
+ * @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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
 public CoolItem [] getItems () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	CoolItem [] result = new CoolItem [getItemCount()];

 	int index = 0;

 	for (int i = 0; i < rows.size(); i++) {

@@ -202,28 +206,27 @@
 	int windowProc = getDisplay ().windowProc;

 	OS.XtAddEventHandler (handle, OS.ExposureMask, false, windowProc, SWT.Paint);

 }

-/**

- * Searches the receiver's items, in the order they were

- * added, starting at the first item (index 0) until an item

- * is found that is equal to the argument, and returns the

- * index of that item. If no item is found, returns -1.

- *

- * @param item the search item

- * @return the index of the item

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>

- *    <li>ERROR_INVALID_ARGUMENT - if the item is 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>

- */

+/**
+ * Searches the receiver's items, in the order they were
+ * added, starting at the first item (index 0) until an item
+ * is found that is equal to the argument, and returns the
+ * index of that item. If no item is found, returns -1.
+ *
+ * @param item the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string 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>
+ */
 public int indexOf (CoolItem item) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);

-	if (item.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);

 	int answer = 0;

 	for (int i = 0; i < rows.size(); i++) {

 		Vector row = (Vector) rows.elementAt(i);

@@ -451,13 +454,6 @@
 	gc.dispose();

 	return 0;

 }

-void propagateWidget (boolean enabled) {

-	super.propagateWidget (enabled);

-	CoolItem [] items = getItems ();

-	for (int i=0; i<items.length; i++) {

-		items [i].propagateWidget (enabled);

-	}

-}

 /**

  * Remove the item from the row. Adjust the x and width values

  * appropriately.

@@ -573,29 +569,30 @@
 	}

 	return null;

 }

-/**

- * Returns an array of zero-relative indices which map the order

- * that the items in the receiver were added in (which is the

- * order that they are returned by <code>getItems()</code>) to

- * the order which they are currently being displayed.

- * <p>

- * Note: This is not the actual structure used by the receiver

- * to maintain its list of items, so modifying the array will

- * not affect the receiver. 

- * </p>

- *

- * @return the receiver's item order

- *

- * @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>

- * @exception SWTError <ul>

- *    <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>

- * </ul>

- */

+/**
+ * Returns an array of zero-relative indices which map the order
+ * that the items in the receiver were added in (which is the
+ * order that they are returned by <code>getItems()</code>) to
+ * the order which they are currently being displayed.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the receiver's item order
+ *
+ * @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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
 public int[] getItemOrder () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	CoolItem[] items = getItems();

 	int[] ids = new int[items.length];

 	for (int i = 0; i < items.length; i++) {

@@ -616,20 +613,21 @@
 	rows = new Vector(1);

 	rows.addElement(row);

 }

-/**

- * Returns an array of points whose x and y coordinates describe

- * the widths and heights (respectively) of the items in the receiver

- * in the order the items were added.

- *

- * @return the receiver's item sizes

- *

- * @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 an array of points whose x and y coordinates describe
+ * the widths and heights (respectively) of the items in the receiver
+ * in the order the items were added.
+ *
+ * @return the receiver's item sizes
+ *
+ * @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 Point[] getItemSizes () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	CoolItem[] items = getItems();

 	Point[] sizes = new Point[items.length];

 	for (int i = 0; i < items.length; i++) {

@@ -646,20 +644,21 @@
 		items[i].setBounds(bounds.x, bounds.y, sizes[i].x, sizes[i].y);

 	}

 }

-/**

- * 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, in the order the items were added.

- *

- * @return the receiver's wrap indices

- *

- * @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 an array of ints which describe the zero-relative
+ * row number of the row which each of the items in the 
+ * receiver occurs in, in the order the items were added.
+ *
+ * @return the receiver's wrap indices
+ *
+ * @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[] getWrapIndices () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int[] data = new int[rows.size() - 1];

 	int itemIndex = 0;

 	for (int i = 0; i < rows.size() - 1; i++) {

@@ -669,21 +668,22 @@
 	}

 	return data;

 }

-/**

- * 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 

- * in the order the items were added.

- *

- * @param indices the new wrap indices

- *

- * @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>

- */

+/**
+ * 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 
+ * in the order the items were added.
+ *
+ * @param indices the new wrap indices
+ *
+ * @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 setWrapIndices (int[] data) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (data == null) error(SWT.ERROR_NULL_ARGUMENT);

 	CoolItem[] items = getItems();

 	rows = new Vector(5);

@@ -705,22 +705,23 @@
 	rows.addElement(row);

 	relayout();

 }

-/**

- * Sets the receiver's item order, wrap indices, and item

- * sizes at once. This equivalent to calling the setter

- * methods for each of these values individually.

- *

- * @param itemOrder the new item order

- * @param wrapIndices the new wrap indices

- * @param size the new item sizes

- *

- * @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>

- */

+/**
+ * Sets the receiver's item order, wrap indices, and item
+ * sizes at once. This equivalent to calling the setter
+ * methods for each of these values individually.
+ *
+ * @param itemOrder the new item order
+ * @param wrapIndices the new wrap indices
+ * @param size the new item sizes
+ *
+ * @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 setItemLayout (int[] itemOrder, int[] wrapIndices, Point[] sizes) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	setItemOrder(itemOrder);

 	setWrapIndices(wrapIndices);

 	setItemSizes(sizes);	

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/CoolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/CoolItem.java
index 04909c7..cbd77e6 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/CoolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/CoolItem.java
@@ -10,20 +10,20 @@
 import org.eclipse.swt.*;

 import org.eclipse.swt.internal.motif.*;

  

-/**

- * Instances of this class are selectable user interface

- * objects that represent the dynamically positionable

- * areas of a <code>CoolBar</code>.

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>(none)</dd>

- * <dt><b>Events:</b></dt>

- * <dd>(none)</dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is <em>not</em> intended to be subclassed.

- * </p>

- */

+/**
+ * Instances of this class are selectable user interface
+ * objects that represent the dynamically positionable
+ * areas of a <code>CoolBar</code>.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
 public /*final*/ class CoolItem extends Item {

 	Control control;

 	CoolBar parent;

@@ -39,72 +39,72 @@
 	static final int GRABBER_WIDTH = 2;

 	static final int MINIMUM_WIDTH = (2 * MARGIN_WIDTH) + GRABBER_WIDTH;

 		

-/**

- * Constructs a new instance of this class given its parent

- * (which must be a <code>CoolBar</code>) and a style value

- * describing its behavior and appearance. The item is added

- * to the end of 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

- *

- * @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

- */

+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>CoolBar</code> and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of 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
+ *
+ * @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 CoolItem (CoolBar parent, int style) {

 	super(parent, style);

 	this.parent = parent;

 	parent.createItem (this, parent.getItemCount ());

 }

-/**

- * Constructs a new instance of this class given its parent

- * (which must be a <code>CoolBar</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

- */

+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>CoolBar</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 CoolItem (CoolBar parent, int style, int index) {

 	super(parent, style);

 	this.parent = parent;

@@ -113,30 +113,31 @@
 protected void checkSubclass () {

 	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);

 }

-/**

- * Returns the preferred size of the receiver.

- * <p>

- * The <em>prefered size</em> of a <code>CoolItem</code> is the size that

- * it would best be displayed at. The width hint and height hint arguments

- * allow the caller to ask the instance questions such as "Given a particular

- * width, how high does it need to be to show all of the contents?"

- * To indicate that the caller does not wish to constrain a particular 

- * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint. 

- * </p>

- *

- * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)

- * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)

- * @return the preferred size

- *

- * @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 Layout

- */

+/**
+ * Returns the preferred size of the receiver.
+ * <p>
+ * The <em>prefered size</em> of a <code>CoolItem</code> is the size that
+ * it would best be displayed at. The width hint and height hint arguments
+ * allow the caller to ask the instance questions such as "Given a particular
+ * width, how high does it need to be to show all of the contents?"
+ * To indicate that the caller does not wish to constrain a particular 
+ * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint. 
+ * </p>
+ *
+ * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
+ * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
+ * @return the preferred size
+ *
+ * @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 Layout
+ */
 public Point computeSize (int wHint, int hHint) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (preferredWidth > -1) return new Point(preferredWidth, preferredHeight);

 	int width = MINIMUM_WIDTH;

 	int height = DEFAULT_HEIGHT;

@@ -158,40 +159,42 @@
 	if (handle == 0) error (SWT.ERROR_NO_HANDLES);

 }

 public void dispose () {

-	if (isDisposed()) return;

+	if (!isValidWidget ()) return;

 	CoolBar parent = this.parent;

 	super.dispose ();

 	parent.relayout ();

 }

-/**

- * Returns a rectangle describing the receiver's size and location

- * relative to its parent.

- *

- * @return the receiver's bounding 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.
+ *
+ * @return the receiver's bounding 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 () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNx, 0, OS.XmNy, 0, OS.XmNwidth, 0, OS.XmNheight, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return new Rectangle ((short) argList [1], (short) argList [3], argList [5], argList [7]);

 }

-/**

- * Gets the control which is associated with the receiver.

- *

- * @return the control

- *

- * @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>

- */

+/**
+ * Gets the control which is associated with the receiver.
+ *
+ * @return the control
+ *
+ * @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 Control getControl () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return control;

 }

 public Display getDisplay () {

@@ -204,18 +207,19 @@
 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return new Rectangle(0, 0, MINIMUM_WIDTH, argList[1]);	

 }

-/**

- * Returns the receiver's parent, which must be a <code>CoolBar</code>.

- *

- * @return the receiver's parent

- *

- * @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 the receiver's parent, which must be a <code>CoolBar</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @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 CoolBar getParent () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent;

 }

 Point getSize () {

@@ -322,36 +326,22 @@
 	OS.XFreeGC(xDisplay, xGC);

 	return 0;

 }

-void propagateWidget (boolean enabled) {

-	propagateHandle (enabled, handle);

-	/*

-	* CoolItems never participate in focus traversal when

-	* either enabled or disabled.

-	*/

-	if (enabled) {

-		int [] argList = {OS.XmNtraversalOn, 0};

-		OS.XtSetValues (handle, argList, argList.length / 2);

-	}

-}

-/**

- * Sets the control which is associated with the receiver

- * to the argument.

- *

- * @param control the new control

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the control 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>

- */

+/**
+ * Sets the control which is associated with the receiver
+ * to the argument.
+ *
+ * @param control the new control
+ *
+ * @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 setControl (Control control) {

-	checkWidget();

-	if (control != null) {

-		if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);

-		if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	if (control != null && control.parent != parent) {

+		error (SWT.ERROR_INVALID_PARENT);

 	}

 	Control oldControl = this.control;

 	if (oldControl != null) oldControl.setVisible(false);

@@ -377,7 +367,8 @@
 	}

 }

 public void setSize (int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	width = Math.max (width, MINIMUM_WIDTH);

 	height = Math.max (height, DEFAULT_HEIGHT);

 	OS.XtResizeWidget (handle, width, height, 0);			

@@ -434,11 +425,13 @@
 	}

 }

 public Point getPreferredSize () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return new Point(preferredWidth, preferredHeight);

 }

 public void setPreferredSize (int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	preferredWidth = Math.max (width, MINIMUM_WIDTH);

 	preferredHeight = Math.max (height, DEFAULT_HEIGHT);

 	OS.XtResizeWidget (handle, preferredWidth, preferredHeight, 0);

@@ -449,7 +442,6 @@
 	}

 }

 public void setPreferredSize (Point size) {

-	if (size == null) error(SWT.ERROR_NULL_ARGUMENT);

 	setPreferredSize(size.x, size.y);

 }

 	

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Decorations.java
index da77360..d9af52c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Decorations.java
@@ -9,78 +9,78 @@
 import org.eclipse.swt.*;

 import org.eclipse.swt.graphics.*;

 

-/**

- * Instances of this class provide the appearance and

- * behavior of <code>Shells</code>, but are not top

- * level shells or dialogs. Class <code>Shell</code>

- * shares a significant amount of code with this class,

- * and is a subclass.

- * <p>

- * Instances are always displayed in one of the maximized, 

- * minimized or normal states:

- * <ul>

- * <li>

- * When an instance is marked as <em>maximized</em>, the

- * window manager will typically resize it to fill the

- * entire visible area of the display, and the instance

- * is usually put in a state where it can not be resized 

- * (even if it has style <code>RESIZE</code>) until it is

- * no longer maximized.

- * </li><li>

- * When an instance is in the <em>normal</em> state (neither

- * maximized or minimized), its appearance is controlled by

- * the style constants which were specified when it was created

- * and the restrictions of the window manager (see below).

- * </li><li>

- * When an instance has been marked as <em>minimized</em>,

- * its contents (client area) will usually not be visible,

- * and depending on the window manager, it may be

- * "iconified" (that is, replaced on the desktop by a small

- * simplified representation of itself), relocated to a

- * distinguished area of the screen, or hidden. Combinations

- * of these changes are also possible.

- * </li>

- * </ul>

- * </p>

- * Note: The styles supported by this class must be treated

- * as <em>HINT</em>s, since the window manager for the

- * desktop on which the instance is visible has ultimate

- * control over the appearance and behavior of decorations.

- * For example, some window managers only support resizable

- * windows and will always assume the RESIZE style, even if

- * it is not set.

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE</dd>

- * <dt><b>Events:</b></dt>

- * <dd>(none)</dd>

- * </dl>

- * Class <code>SWT</code> provides two "convenience constants"

- * for the most commonly required style combinations:

- * <dl>

- * <dt><code>SHELL_TRIM</code></dt>

- * <dd>

- * the result of combining the constants which are required

- * to produce a typical application top level shell: (that 

- * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)

- * </dd>

- * <dt><code>DIALOG_TRIM</code></dt>

- * <dd>

- * the result of combining the constants which are required

- * to produce a typical application dialog shell: (that 

- * is, <code>TITLE | CLOSE | BORDER</code>)

- * </dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is intended to be subclassed <em>only</em>

- * within the SWT implementation.

- * </p>

- *

- * @see #getMinimized

- * @see #getMaximized

- * @see Shell

- * @see SWT

- */

+/**
+ * Instances of this class provide the appearance and
+ * behavior of <code>Shells</code>, but are not top
+ * level shells or dialogs. Class <code>Shell</code>
+ * shares a significant amount of code with this class,
+ * and is a subclass.
+ * <p>
+ * Instances are always displayed in one of the maximized, 
+ * minimized or normal states:
+ * <ul>
+ * <li>
+ * When an instance is marked as <em>maximized</em>, the
+ * window manager will typically resize it to fill the
+ * entire visible area of the display, and the instance
+ * is usually put in a state where it can not be resized 
+ * (even if it has style <code>RESIZE</code>) until it is
+ * no longer maximized.
+ * </li><li>
+ * When an instance is in the <em>normal</em> state (neither
+ * maximized or minimized), its appearance is controlled by
+ * the style constants which were specified when it was created
+ * and the restrictions of the window manager (see below).
+ * </li><li>
+ * When an instance has been marked as <em>minimized</em>,
+ * its contents (client area) will usually not be visible,
+ * and depending on the window manager, it may be
+ * "iconified" (that is, replaced on the desktop by a small
+ * simplified representation of itself), relocated to a
+ * distinguished area of the screen, or hidden. Combinations
+ * of these changes are also possible.
+ * </li>
+ * </ul>
+ * </p>
+ * Note: The styles supported by this class must be treated
+ * as <em>HINT</em>s, since the window manager for the
+ * desktop on which the instance is visible has ultimate
+ * control over the appearance and behavior of decorations.
+ * For example, some window managers only support resizable
+ * windows and will always assume the RESIZE style, even if
+ * it is not set.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * Class <code>SWT</code> provides two "convenience constants"
+ * for the most commonly required style combinations:
+ * <dl>
+ * <dt><code>SHELL_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application top level shell: (that 
+ * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
+ * </dd>
+ * <dt><code>DIALOG_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application dialog shell: (that 
+ * is, <code>TITLE | CLOSE | BORDER</code>)
+ * </dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ *
+ * @see #getMinimized
+ * @see #getMaximized
+ * @see Shell
+ * @see SWT
+ */
 public class Decorations extends Canvas {

 	String label;

 	Image image;

@@ -93,33 +93,33 @@
 Decorations () {

 	/* Do nothing */

 }

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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

+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <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
+ *
+ * @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 Decorations (Composite parent, int style) {

 	super (parent, checkStyle (style));

@@ -162,7 +162,8 @@
 	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);

 }

 public Rectangle computeTrim (int x, int y, int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	Rectangle trim = super.computeTrim (x, y, width, height);

 	if (menuBar != null) {

 		XtWidgetGeometry request = new XtWidgetGeometry ();

@@ -186,117 +187,123 @@
 	if (dialogHandle != 0) return dialogHandle;

 	return dialogHandle = OS.XmCreateDialogShell (handle, null, null, 0);

 }

-/**

- * Returns the receiver's default button if one had

- * previously been set, otherwise returns null.

- *

- * @return the default button or null

- *

- * @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 #setDefaultButton

- */

+/**
+ * Returns the receiver's default button if one had
+ * previously been set, otherwise returns null.
+ *
+ * @return the default button or null
+ *
+ * @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 #setDefaultButton
+ */
 public Button getDefaultButton () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return defaultButton;

 }

-/**

- * Returns the receiver's image if it had previously been 

- * set using <code>setImage()</code>. The image is typically

- * displayed by the window manager when the instance is

- * marked as iconified, and may also be displayed somewhere

- * in the trim when the instance is in normal or maximized

- * states.

- * <p>

- * Note: This method will return null if called before

- * <code>setImage()</code> is called. It does not provide

- * access to a window manager provided, "default" image

- * even if one exists.

- * </p>

- * 

- * @return the 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>

+/**
+ * Returns the receiver's image if it had previously been 
+ * set using <code>setImage()</code>. The image is typically
+ * displayed by the window manager when the instance is
+ * marked as iconified, and may also be displayed somewhere
+ * in the trim when the instance is in normal or maximized
+ * states.
+ * <p>
+ * Note: This method will return null if called before
+ * <code>setImage()</code> is called. It does not provide
+ * access to a window manager provided, "default" image
+ * even if one exists.
+ * </p>
+ * 
+ * @return the 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();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return image;

 }

-/**

- * Returns <code>true</code> if the receiver is currently

- * maximized, and false otherwise. 

- * <p>

- *

- * @return the maximized 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>

- *

- * @see #setMaximized

- */

+/**
+ * Returns <code>true</code> if the receiver is currently
+ * maximized, and false otherwise. 
+ * <p>
+ *
+ * @return the maximized 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>
+ *
+ * @see #setMaximized
+ */
 public boolean getMaximized () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return maximized;

 }

-/**

- * Returns the receiver's menu bar if one had previously

- * been set, otherwise returns null.

- *

- * @return the menu bar or null

- *

- * @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 the receiver's menu bar if one had previously
+ * been set, otherwise returns null.
+ *
+ * @return the menu bar or null
+ *
+ * @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 Menu getMenuBar () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return menuBar;

 }

-/**

- * Returns <code>true</code> if the receiver is currently

- * minimized, and false otherwise. 

- * <p>

- *

- * @return the minimized 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>

- *

- * @see #setMinimized

- */

+/**
+ * Returns <code>true</code> if the receiver is currently
+ * minimized, and false otherwise. 
+ * <p>
+ *
+ * @return the minimized 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>
+ *
+ * @see #setMinimized
+ */
 public boolean getMinimized () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return minimized;

 }

 String getNameText () {

 	return getText ();

 }

-/**

- * Returns the receiver's text, which is the string that the

- * window manager will typically display as the receiver's

- * <em>title</em>. If the text has not previously been set, 

- * returns an empty string.

- *

- * @return the text

- *

- * @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 the receiver's text, which is the string that the
+ * window manager will typically display as the receiver's
+ * <em>title</em>. If the text has not previously been set, 
+ * returns an empty string.
+ *
+ * @return the text
+ *
+ * @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 String getText () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return label;

 }

 Decorations menuShell () {

@@ -337,35 +344,32 @@
 		}

 	}

 }

-/**

- * If the argument is not null, sets the receiver's default

- * button to the argument, and if the argument is null, sets

- * the receiver's default button to the first button which

- * was set as the receiver's default button (called the 

- * <em>saved default button</em>). If no default button had

- * previously been set, or the saved default button was

- * disposed, the receiver's default button will be set to

- * null. 

- *

- * @param the new default button

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the button 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>

- */

+/**
+ * If the argument is not null, sets the receiver's default
+ * button to the argument, and if the argument is null, sets
+ * the receiver's default button to the first button which
+ * was set as the receiver's default button (called the 
+ * <em>saved default button</em>). If no default button had
+ * previously been set, or the saved default button was
+ * disposed, the receiver's default button will be set to
+ * null. 
+ *
+ * @param the new default button
+ *
+ * @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 setDefaultButton (Button button) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	setDefaultButton (button, true);

 }

 void setDefaultButton (Button button, boolean save) {

 	if (button == null) {

 		if (defaultButton == saveDefault) return;

 	} else {

-		if (button.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 		if ((button.style & SWT.PUSH) == 0) return;

 		if (button == defaultButton) return;

 	}

@@ -379,28 +383,25 @@
 	if (save || saveDefault == null) saveDefault = defaultButton;

 	if (saveDefault != null && saveDefault.isDisposed ()) saveDefault = null;

 }

-/**

- * Sets the receiver's image to the argument, which may

- * be null. The image is typically displayed by the window

- * manager when the instance is marked as iconified, and

- * may also be displayed somewhere in the trim when the

- * instance is in normal or maximized states.

- * 

- * @param image the new image (or null)

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the image 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>

- */

+/**
+ * Sets the receiver's image to the argument, which may
+ * be null. The image is typically displayed by the window
+ * manager when the instance is marked as iconified, and
+ * may also be displayed somewhere in the trim when the
+ * instance is in normal or maximized states.
+ * 
+ * @param image the new image (or null)
+ *
+ * @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 setImage (Image image) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int pixmap = 0, mask = 0;

 	if (image != null) {

-		if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 		switch (image.type) {

 			case SWT.BITMAP:

 				pixmap = image.pixmap;

@@ -421,52 +422,50 @@
 	int topHandle = topHandle ();

 	OS.XtSetValues (topHandle, argList, argList.length / 2);

 }

-/**

- * Sets the maximized state of the receiver.

- * If the argument is <code>true</code> causes the receiver

- * to switch to the maximized state, and if the argument is

- * <code>false</code> and the receiver was previously maximized,

- * causes the receiver to switch back to either the minimized

- * or normal states.

- * <p>

- * Note: The result of intermixing calls to<code>setMaximized(true)</code>

- * and <code>setMinimized(true)</code> will vary by platform. Typically,

- * the behavior will match the platform user's expectations, but not

- * always. This should be avoided if possible.

- * </p>

- *

- * @param the new maximized 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>

- *

- * @see #setMinimized

- */

+/**
+ * Sets the maximized state of the receiver.
+ * If the argument is <code>true</code> causes the receiver
+ * to switch to the maximized state, and if the argument is
+ * <code>false</code> and the receiver was previously maximized,
+ * causes the receiver to switch back to either the minimized
+ * or normal states.
+ * <p>
+ * Note: The result of intermixing calls to<code>setMaximized(true)</code>
+ * and <code>setMinimized(true)</code> will vary by platform. Typically,
+ * the behavior will match the platform user's expectations, but not
+ * always. This should be avoided if possible.
+ * </p>
+ *
+ * @param the new maximized 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>
+ *
+ * @see #setMinimized
+ */
 public void setMaximized (boolean maximized) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	this.maximized = maximized;

 }

-/**

- * Sets the receiver's menu bar to the argument, which

- * may be null.

- *

- * @param menu the new menu bar

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the menu 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>

- */

+/**
+ * Sets the receiver's menu bar to the argument, which
+ * may be null.
+ *
+ * @param menu the new menu bar
+ *
+ * @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 setMenuBar (Menu menu) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (menuBar == menu) return;

 	if (menu != null) {

-		if (menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 		if ((menu.style & SWT.BAR) == 0) error (SWT.ERROR_MENU_NOT_BAR);

 		if (menu.parent != this) error (SWT.ERROR_INVALID_PARENT);

 	}

@@ -519,54 +518,56 @@
 		OS.XtResizeWidget (scrolledHandle, argList [1], argList [3], argList [5]);

 	}

 }

-/**

- * Sets the minimized stated of the receiver.

- * If the argument is <code>true</code> causes the receiver

- * to switch to the minimized state, and if the argument is

- * <code>false</code> and the receiver was previously minimized,

- * causes the receiver to switch back to either the maximized

- * or normal states.

- * <p>

- * Note: The result of intermixing calls to<code>setMaximized(true)</code>

- * and <code>setMinimized(true)</code> will vary by platform. Typically,

- * the behavior will match the platform user's expectations, but not

- * always. This should be avoided if possible.

- * </p>

- *

- * @param the new maximized 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>

- *

- * @see #setMaximized

- */

+/**
+ * Sets the minimized stated of the receiver.
+ * If the argument is <code>true</code> causes the receiver
+ * to switch to the minimized state, and if the argument is
+ * <code>false</code> and the receiver was previously minimized,
+ * causes the receiver to switch back to either the maximized
+ * or normal states.
+ * <p>
+ * Note: The result of intermixing calls to<code>setMaximized(true)</code>
+ * and <code>setMinimized(true)</code> will vary by platform. Typically,
+ * the behavior will match the platform user's expectations, but not
+ * always. This should be avoided if possible.
+ * </p>
+ *
+ * @param the new maximized 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>
+ *
+ * @see #setMaximized
+ */
 public void setMinimized (boolean minimized) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	this.minimized = minimized;

 }

 void setSavedFocus (Control control) {

 	if (this == control) return;

 	savedFocus = control;

 }

-/**

- * Sets the receiver's text, which is the string that the

- * window manager will typically display as the receiver's

- * <em>title</em>, to the argument, which may not be null. 

- *

- * @param text the new text

- *

- * @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>

- */

+/**
+ * Sets the receiver's text, which is the string that the
+ * window manager will typically display as the receiver's
+ * <em>title</em>, to the argument, which may not be null. 
+ *
+ * @param text the new text
+ *
+ * @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>
+ */
 public void setText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	label = string;

 }

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 7b1b05b..2543e84 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
@@ -9,74 +9,74 @@
 import org.eclipse.swt.internal.motif.*;

 import org.eclipse.swt.*;

 

-/**

- * Instances of this class allow the user to navigate

- * the file system and select a directory.

- * <p>

- * IMPORTANT: This class is intended to be subclassed <em>only</em>

- * within the SWT implementation.

- * </p>

+/**
+ * Instances of this class allow the user to navigate
+ * the file system and select a directory.
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
  */

 

 public /*final*/ class DirectoryDialog extends Dialog {

 	String filterPath = "";

 	boolean cancel = true;

 	String message = "";

-/**

- * Constructs a new instance of this class given only its

- * parent.

- * <p>

- * Note: Currently, null can be passed in for the parent.

- * This has the effect of creating the dialog on the currently active

- * display if there is one. If there is no current display, the 

- * dialog is created on a "default" display. <b>Passing in null as

- * the parent is not considered to be good coding style,

- * and may not be supported in a future release of SWT.</b>

- * </p>

- *

- * @param parent a shell which will be the parent of the new instance

- *

- * @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>

- */

+/**
+ * Constructs a new instance of this class given only its
+ * parent.
+ * <p>
+ * Note: Currently, null can be passed in for the parent.
+ * This has the effect of creating the dialog on the currently active
+ * display if there is one. If there is no current display, the 
+ * dialog is created on a "default" display. <b>Passing in null as
+ * the parent is not considered to be good coding style,
+ * and may not be supported in a future release of SWT.</b>
+ * </p>
+ *
+ * @param parent a shell which will be the parent of the new instance
+ *
+ * @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>
+ */
 public DirectoryDialog (Shell parent) {

 	this (parent, SWT.PRIMARY_MODAL);

 }

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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 dialog classes should include a comment which

- * describes the style constants which are applicable to the class.

- * </p>

- * Note: Currently, null can be passed in for the parent.

- * This has the effect of creating the dialog on the currently active

- * display if there is one. If there is no current display, the 

- * dialog is created on a "default" display. <b>Passing in null as

- * the parent is not considered to be good coding style,

- * and may not be supported in a future release of SWT.</b>

- * </p>

- *

- * @param parent a shell which will be the parent of the new instance

- *

- * @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>

- */

+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <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 dialog classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </p>
+ * Note: Currently, null can be passed in for the parent.
+ * This has the effect of creating the dialog on the currently active
+ * display if there is one. If there is no current display, the 
+ * dialog is created on a "default" display. <b>Passing in null as
+ * the parent is not considered to be good coding style,
+ * and may not be supported in a future release of SWT.</b>
+ * </p>
+ *
+ * @param parent a shell which will be the parent of the new instance
+ *
+ * @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>
+ */
 public DirectoryDialog (Shell parent, int style) {

 	super (parent, style);

 }

@@ -85,37 +85,36 @@
 	OS.XtUnmanageChild (widget);

 	return 0;

 }

-/**

- * Returns the path which the dialog will use to filter

- * the directories it shows.

- *

- * @return the filter path

- */

+/**
+ * Returns the path which the receiver will use to filter
+ * the directories it shows.
+ *
+ * @return the filter path
+ */
 public String getFilterPath () {

 	return filterPath;

 }

-/**

- * Returns the dialog's message, which is a description of

- * the purpose for which it was opened. This message will be

- * visible on the dialog while it is open.

- *

- * @return the message

- */

+/**
+ * Returns the receiver's message, which is a description of
+ * the purpose for which it was opened. This message will be
+ * visible on the receiver while it is open.
+ *
+ * @return the message
+ */
 public String getMessage () {

 	return message;

 }

-/**

- * Makes the dialog visible and brings it to the front

- * of the display.

- *

- * @return a string describing the absolute path of the selected directory,

- *         or null if the dialog was cancelled or an error occurred

- *

- * @exception SWTException <ul>

- *    <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>

- * </ul>

- */

+/**
+ * Makes the receiver visible and brings it to the front
+ * of the display.
+ *
+ * @return a string describing the absolute path of the selected directory
+ *
+ * @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 String open () {

 

 	/* Get the parent */

@@ -126,7 +125,6 @@
 	int parentHandle = appContext.shellHandle;

 	if ((parent != null) && (parent.getDisplay () == appContext))

 		parentHandle = parent.shellHandle;

-

 	/* Compute the dialog title */	

 	/*

 	* Feature in Motif.  It is not possible to set a shell

@@ -135,8 +133,6 @@
 	*/

 	String string = title;

 	if (string.length () == 0) string = " ";

-

-	/* Use the character encoding for the default locale */

 	byte [] buffer1 = Converter.wcsToMbcs (null, string, true);

 	int xmStringPtr1 = OS.XmStringParseText (

 		buffer1,

@@ -146,9 +142,7 @@
 		null,

 		0,

 		0);

-

 	/* Compute the filter */

-	/* Use the character encoding for the default locale */

 	byte [] buffer2 = Converter.wcsToMbcs (null, "*", true);

 	int xmStringPtr2 = OS.XmStringParseText (

 		buffer2,

@@ -161,7 +155,6 @@
 

 	/* Compute the filter path */

 	if (filterPath == null) filterPath = "";

-	/* Use the character encoding for the default locale */

 	byte [] buffer3 = Converter.wcsToMbcs (null, filterPath, true);

 	int xmStringPtr3 = OS.XmStringParseText (

 		buffer3,

@@ -172,7 +165,6 @@
 		0,

 		0);

 

-	/* Use the character encoding for the default locale */

 	byte [] buffer7 = Converter.wcsToMbcs (null, "Selection", true);

 	int xmStringPtr4 = OS.XmStringParseText (

 		buffer7,

@@ -182,7 +174,6 @@
 		null,

 		0,

 		0);

-

 	/* Create the dialog */

 	int [] argList1 = {

 		OS.XmNresizePolicy, OS.XmRESIZE_NONE,

@@ -193,7 +184,6 @@
 		OS.XmNdirectory, xmStringPtr3,

 		OS.XmNfilterLabelString, xmStringPtr4

 	};

-

 	/*

 	* Feature in Linux.  For some reason, the XmCreateFileSelectionDialog()

 	* will not accept NULL for the widget name.  This works fine on the other

@@ -221,7 +211,6 @@
 	OS.XmStringFree (xmStringPtr4);

 

 	// Add label widget for message text.

-	/* Use the character encoding for the default locale */

 	byte [] buffer4 = Converter.wcsToMbcs (null, message, true);

 	int [] parseTable = Display.getDefault ().parseTable;

 	int xmString1 = OS.XmStringParseText (

@@ -272,7 +261,6 @@
 			byte [] buffer = new byte [length];

 			OS.memmove (buffer, ptr, length);

 			OS.XtFree (ptr);

-			/* Use the character encoding for the default locale */

 			directoryPath = new String (Converter.mbcsToWcs (null, buffer));

 		}

 		OS.XmStringFree (xmString3);

@@ -300,23 +288,23 @@
 	if (cancel) return null;

 	return directoryPath;

 }

-/**

- * Sets the path which the dialog will use to filter

- * the directories it shows to the argument, which may be

- * null.

- *

- * @param string the filter path

- */

+/**
+ * Sets the path which the receiver will use to filter
+ * the directories it shows to the argument, which may be
+ * null.
+ *
+ * @param string the filter path
+ */
 public void setFilterPath (String string) {

 	filterPath = string;

 }

-/**

- * Sets the dialog's message, which is a description of

- * the purpose for which it was opened. This message will be

- * visible on the dialog while it is open.

- *

- * @param string the message

- */

+/**
+ * Sets the receiver's message, which is a description of
+ * the purpose for which it was opened. This message will be
+ * visible on the receiver while it is open.
+ *
+ * @param string the message
+ */
 public void setMessage (String string) {

 	message = string;

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java
index e4c765d..84a5113 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java
@@ -10,76 +10,76 @@
 import org.eclipse.swt.*;

 import org.eclipse.swt.graphics.*;

 

-/**

- * Instances of this class are responsible for managing the

- * connection between SWT and the underlying operating

- * system. Their most important function is to implement

- * the SWT event loop in terms of the platform event model.

- * They also provide various methods for accessing information

- * about the operating system, and have overall control over

- * the operating system resources which SWT allocates.

- * <p>

- * Applications which are built with SWT will <em>almost always</em>

- * require only a single display. In particular, some platforms

- * which SWT supports will not allow more than one <em>active</em>

- * display. In other words, some platforms do not support

- * creating a new display if one already exists that has not been

- * sent the <code>dispose()</code> message.

- * <p>

- * In SWT, the thread which creates a <code>Display</code>

- * instance is distinguished as the <em>user-interface thread</em>

- * for that display.

- * </p>

- * The user-interface thread for a particular display has the

- * following special attributes:

- * <ul>

- * <li>

- * The event loop for that display must be run from the thread.

- * </li>

- * <li>

- * Some SWT API methods (notably, most of the public methods in

- * <code>Widget</code> and its subclasses), may only be called

- * from the thread. (To support multi-threaded user-interface

- * applications, class <code>Display</code> provides inter-thread

- * communication methods which allow threads other than the 

- * user-interface thread to request that it perform operations

- * on their behalf.)

- * </li>

- * <li>

- * The thread is not allowed to construct other 

- * <code>Display</code>s until that display has been disposed.

- * (Note that, this is in addition to the restriction mentioned

- * above concerning platform support for multiple displays. Thus,

- * the only way to have multiple simultaneously active displays,

- * even on platforms which support it, is to have multiple threads.)

- * </li>

- * </ul>

- * Enforcing these attributes allows SWT to be implemented directly

- * on the underlying operating system's event model. This has 

- * numerous benefits including smaller footprint, better use of 

- * resources, safer memory management, clearer program logic,

- * better performance, and fewer overall operating system threads

- * required. The down side however, is that care must be taken

- * (only) when constructing multi-threaded applications to use the

- * inter-thread communication mechanisms which this class provides

- * when required.

- * </p><p>

- * All SWT API methods which may only be called from the user-interface

- * thread are distinguished in their documentation by indicating that

- * they throw the "<code>ERROR_THREAD_INVALID_ACCESS</code>"

- * SWT exception.

- * </p><p>

- * IMPORTANT: This class is <em>not</em> intended to be subclassed.

- * </p>

- * 

- * @see #syncExec

- * @see #asyncExec

- * @see #wake

- * @see #readAndDispatch

- * @see #sleep

- * @see #dispose

- */

-public class Display extends Device {

+/**
+ * Instances of this class are responsible for managing the
+ * connection between SWT and the underlying operating
+ * system. Their most important function is to implement
+ * the SWT event loop in terms of the platform event model.
+ * They also provide various methods for accessing information
+ * about the operating system, and have overall control over
+ * the operating system resources which SWT allocates.
+ * <p>
+ * Applications which are built with SWT will <em>almost always</em>
+ * require only a single display. In particular, some platforms
+ * which SWT supports will not allow more than one <em>active</em>
+ * display. In other words, some platforms do not support
+ * creating a new display if one already exists that has not been
+ * sent the <code>dispose()</code> message.
+ * <p>
+ * In SWT, the thread which creates a <code>Display</code>
+ * instance is distinguished as the <em>user-interface thread</em>
+ * for that display.
+ * </p>
+ * The user-interface thread for a particular display has the
+ * following special attributes:
+ * <ul>
+ * <li>
+ * The event loop for that display must be run from the thread.
+ * </li>
+ * <li>
+ * Some SWT API methods (notably, most of the public methods in
+ * <code>Widget</code> and its subclasses), may only be called
+ * from the thread. (To support multi-threaded user-interface
+ * applications, class <code>Display</code> provides inter-thread
+ * communication methods which allow threads other than the 
+ * user-interface thread to request that it perform operations
+ * on their behalf.)
+ * </li>
+ * <li>
+ * The thread is not allowed to construct other 
+ * <code>Display</code>s until that display has been disposed.
+ * (Note that, this is in addition to the restriction mentioned
+ * above concerning platform support for multiple displays. Thus,
+ * the only way to have multiple simultaneously active displays,
+ * even on platforms which support it, is to have multiple threads.)
+ * </li>
+ * </ul>
+ * Enforcing these attributes allows SWT to be implemented directly
+ * on the underlying operating system's event model. This has 
+ * numerous benefits including smaller footprint, better use of 
+ * resources, safer memory management, clearer program logic,
+ * better performance, and fewer overall operating system threads
+ * required. The down side however, is that care must be taken
+ * (only) when constructing multi-threaded applications to use the
+ * inter-thread communication mechanisms which this class provides
+ * when required.
+ * </p><p>
+ * All SWT API methods which may only be called from the user-interface
+ * thread are distinguished in their documentation by indicating that
+ * they throw the "<code>ERROR_THREAD_INVALID_ACCESS</code>"
+ * SWT exception.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * 
+ * @see #syncExec
+ * @see #asyncExec
+ * @see #wake
+ * @see #readAndDispatch
+ * @see #sleep
+ * @see #dispose
+ */
+public class Display extends Device {
 

 	/* Motif Only Public Fields */

 	public XAnyEvent xEvent = new XAnyEvent ();

@@ -234,15 +234,15 @@
 	int checkExposeProc;

 	int exposeCount;

 	

-	/* Wake */

-	Callback wakeCallback;

-	int wakeProc, read_fd, write_fd, inputID;

-	byte [] wake_buffer = new byte [1];

+	/* Wake */
+	Callback wakeCallback;
+	int wakeProc, read_fd, write_fd, inputID;
+	byte [] wake_buffer = new byte [1];
 	

 	/* Display Data */

 	Object data;

 	String [] keys;

-	Object [] values;

+	Object [] values;
 

 	static final byte[] _MOTIF_DEFAULT_LOCALE = Converter.wcsToMbcs(null, "_MOTIF_DEFAULT_LOCALE");

 

@@ -270,25 +270,25 @@
 	CurrentDevice = device;

 }

 

-/**

- * Constructs a new instance of this class.

- * <p>

- * Note: The resulting display is marked as the <em>current</em>

- * display. If this is the first display which has been 

- * constructed since the application started, it is also

- * marked as the <em>default</em> display.

- * </p>

- *

- * @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 #getCurrent

- * @see #getDefault

- * @see Widget#checkSubclass

- * @see Shell

- */

+/**
+ * Constructs a new instance of this class.
+ * <p>
+ * Note: The resulting display is marked as the <em>current</em>
+ * display. If this is the first display which has been 
+ * constructed since the application started, it is also
+ * marked as the <em>default</em> display.
+ * </p>
+ *
+ * @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 #getCurrent
+ * @see #getDefault
+ * @see Widget#checkSubclass
+ * @see Shell
+ */
 public Display () {

 	this (null);

 }

@@ -315,25 +315,25 @@
 	mouseHoverID = OS.XtAppAddTimeOut (xtContext, 400, mouseHoverProc, handle);

 	mouseHoverHandle = handle;

 }

-/**

- * Causes the <code>run()</code> method of the runnable to

- * be invoked by the user-interface thread at the next 

- * reasonable opportunity. The caller of this method continues 

- * to run in parallel, and is not notified when the

- * runnable has completed.

- *

- * @param runnable code to run on the user-interface thread.

- *

- * @see #syncExec

- */

+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread at the next 
+ * reasonable opportunity. The caller of this method continues 
+ * to run in parallel, and is not notified when the
+ * runnable has completed.
+ *
+ * @param runnable code to run on the user-interface thread.
+ *
+ * @see #syncExec
+ */
 public void asyncExec (Runnable runnable) {

 	if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);

 	synchronizer.asyncExec (runnable);

 }

-/**

- * Causes the system hardware to emit a short sound

- * (if it supports this capability).

- */

+/**
+ * Causes the system hardware to emit a short sound
+ * (if it supports this capability).
+ */
 public void beep () {

 	checkDevice ();

 	OS.XBell (xDisplay, 100);

@@ -375,7 +375,7 @@
 }

 protected void create (DeviceData data) {

 	checkSubclass ();

-	checkDisplay ();

+	checkDisplay ();
 	thread = Thread.currentThread ();

 	createDisplay (data);

 	register ();

@@ -419,7 +419,6 @@
 		if (data.application_name != null) application_name = data.application_name;

 		if (data.application_class != null) application_class = data.application_class;

 	}

-	/* Use the character encoding for the default locale */

 	if (display_name != null) displayName = Converter.wcsToMbcs (null, display_name, true);

 	if (application_name != null) appName = Converter.wcsToMbcs (null, application_name, true);

 	if (application_class != null) appClass = Converter.wcsToMbcs (null, application_class, true);

@@ -441,18 +440,18 @@
 void destroyDisplay () {

 	/*

 	* Destroy AppContext (this destroys the display)

-	*/

+	*/
 	int xtContext = OS.XtDisplayToApplicationContext (xDisplay);

-	OS.XtDestroyApplicationContext (xtContext);

+	OS.XtDestroyApplicationContext (xtContext);
 	DisplayDisposed = true;

 }

-/**

- * Causes the <code>run()</code> method of the runnable to

- * be invoked by the user-interface thread just before the

- * receiver is disposed.

- *

- * @param runnable code to run at dispose time.

- */

+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread just before the
+ * receiver is disposed.
+ *
+ * @param runnable code to run at dispose time.
+ */
 public void disposeExec (Runnable runnable) {

 	checkDevice ();

 	if (disposeList == null) disposeList = new Runnable [4];

@@ -474,7 +473,7 @@
 

 	/* Check the event and find the widget */

 	if (event.type != OS.KeyPress) return false;

-	if (!OS.IsLinux && OS.XFilterEvent(event, OS.None)) return true;

+	if (OS.XFilterEvent(event, OS.None)) return true;

 	XKeyEvent keyEvent = new XKeyEvent ();

 	

 	/* Move the any event into the key event */

@@ -520,58 +519,58 @@
 	/* Answer false because the event was not processed */

 	return false;

 }

-/**

- * Given the operating system handle for a widget, returns

- * the instance of the <code>Widget</code> subclass which

- * represents it in the currently running application, if

- * such exists, or null if no matching widget can be found.

- *

- * @param handle the handle for the widget

- * @return the SWT widget that the handle represents

- *

- * @exception SWTException <ul>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>

- * </ul>

- */

+/**
+ * Given the operating system handle for a widget, returns
+ * the instance of the <code>Widget</code> subclass which
+ * represents it in the currently running application, if
+ * such exists, or null if no matching widget can be found.
+ *
+ * @param handle the handle for the widget
+ * @return the SWT widget that the handle represents
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
 public Widget findWidget (int handle) {

 	checkDevice ();

 	return WidgetTable.get (handle);

 }

-/**

- * Returns the currently active <code>Shell</code>, or null

- * if no shell belonging to the currently running application

- * is active.

- *

- * @return the active shell or null

- *

- * @exception SWTException <ul>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>

- * </ul>

- */

+/**
+ * Returns the currently active <code>Shell</code>, or null
+ * if no shell belonging to the currently running application
+ * is active.
+ *
+ * @return the active shell or null
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
 public Shell getActiveShell () {

 	checkDevice ();

 	Control control = getFocusControl ();

 	if (control == null) return null;

 	return control.getShell ();

 }

-/**

- * Returns the display which the currently running thread is

- * the user-interface thread for, or null if the currently

- * running thread is not a user-interface thread for any display.

- *

- * @return the current display

- */

+/**
+ * Returns the display which the currently running thread is
+ * the user-interface thread for, or null if the currently
+ * running thread is not a user-interface thread for any display.
+ *
+ * @return the current display
+ */
 public static synchronized Display getCurrent () {

 	return findDisplay (Thread.currentThread ());

 }

-/**

- * Returns the display which the given thread is the

- * user-interface thread for, or null if the given thread

- * is not a user-interface thread for any display.

- *

- * @param thread the user-interface thread

- * @return the display for the given thread

- */

+/**
+ * Returns the display which the given thread is the
+ * user-interface thread for, or null if the given thread
+ * is not a user-interface thread for any display.
+ *
+ * @param thread the user-interface thread
+ * @return the display for the given thread
+ */
 public static synchronized Display findDisplay (Thread thread) {

 	for (int i=0; i<Displays.length; i++) {

 		Display display = Displays [i];

@@ -581,17 +580,17 @@
 	}

 	return null;

 }

-/**

- * Returns the control which the on-screen pointer is currently

- * over top of, or null if it is not currently over one of the

- * controls built by the currently running application.

- *

- * @return the control under the cursor

- *

- * @exception SWTException <ul>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>

- * </ul>

- */

+/**
+ * Returns the control which the on-screen pointer is currently
+ * over top of, or null if it is not currently over one of the
+ * controls built by the currently running application.
+ *
+ * @return the control under the cursor
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
 public Control getCursorControl () {

 	checkDevice ();

 	int [] unused = new int [1], buffer = new int [1];

@@ -613,16 +612,16 @@
 	} while ((handle = OS.XtParent (handle)) != 0);

 	return null;

 }

-/**

- * Returns the location of the on-screen pointer relative

- * to the top left corner of the screen.

- *

- * @return the cursor location

- *

- * @exception SWTException <ul>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>

- * </ul>

- */

+/**
+ * Returns the location of the on-screen pointer relative
+ * to the top left corner of the screen.
+ *
+ * @return the cursor location
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
 public Point getCursorLocation () {

 	checkDevice ();

 	int window = OS.XDefaultRootWindow (xDisplay);

@@ -632,41 +631,41 @@
 	OS.XQueryPointer(xDisplay, window, unused, unused, rootX, rootY, unused, unused, unused);

 	return new Point (rootX [0], rootY [0]);

 }

-/**

- * Returns the default display. One is created (making the

- * thread that invokes this method its user-interface thread)

- * if it did not already exist.

- *

- * @return the default display

- */

+/**
+ * Returns the default display. One is created (making the
+ * thread that invokes this method its user-interface thread)
+ * if it did not already exist.
+ *
+ * @return the default display
+ */
 public static synchronized Display getDefault () {

 	if (Default == null) Default = new Display ();

 	return Default;

 }

-/**

- * Returns the application defined property of the receiver

- * with the specified name, or null if it has not been set.

- * <p>

- * Applications may have associated arbitrary objects with the

- * receiver in this fashion. If the objects stored in the

- * properties need to be notified when the display is disposed

- * of, it is the application's responsibility provide a

- * <code>disposeExec()</code> handler which does so.

- * </p>

- *

- * @param key the name of the property

- * @return the value of the property or null if it has not been set

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the key is null</li>

- * </ul>

- * @exception SWTException <ul>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>

- * </ul>

- *

- * @see #setData

- * @see #disposeExec

- */

+/**
+ * Returns the application defined property of the receiver
+ * with the specified name, or null if it has not been set.
+ * <p>
+ * Applications may have associated arbitrary objects with the
+ * receiver in this fashion. If the objects stored in the
+ * properties need to be notified when the display is disposed
+ * of, it is the application's responsibility provide a
+ * <code>disposeExec()</code> handler which does so.
+ * </p>
+ *
+ * @param key the name of the property
+ * @return the value of the property or null if it has not been set
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the key is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setData
+ * @see #disposeExec
+ */
 public Object getData (String key) {

 	checkDevice ();

 	if (key == null) error (SWT.ERROR_NULL_ARGUMENT);

@@ -676,59 +675,59 @@
 	}

 	return null;

 }

-/**

- * Returns the application defined, display specific data

- * associated with the receiver, or null if it has not been

- * set. The <em>display specific data</em> is a single,

- * unnamed field that is stored with every display. 

- * <p>

- * Applications may put arbitrary objects in this field. If

- * the object stored in the display specific data needs to

- * be notified when the display is disposed of, it is the

- * application's responsibility provide a

- * <code>disposeExec()</code> handler which does so.

- * </p>

- *

- * @return the display specific data

- *

- * @exception SWTException <ul>

- *    <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>

- * </ul>

- *

- * @see #setData

- * @see #disposeExec

- */

+/**
+ * Returns the application defined, display specific data
+ * associated with the receiver, or null if it has not been
+ * set. The <em>display specific data</em> is a single,
+ * unnamed field that is stored with every display. 
+ * <p>
+ * Applications may put arbitrary objects in this field. If
+ * the object stored in the display specific data needs to
+ * be notified when the display is disposed of, it is the
+ * application's responsibility provide a
+ * <code>disposeExec()</code> handler which does so.
+ * </p>
+ *
+ * @return the display specific data
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>
+ * </ul>
+ *
+ * @see #setData
+ * @see #disposeExec
+ */
 public Object getData () {

 	checkDevice ();

 	return data;

 }

-/**

- * Returns the longest duration, in milliseconds, between

- * two mouse button clicks that will be considered a

- * <em>double click</em> by the underlying operating system.

- *

- * @return the double click time

- *

- * @exception SWTException <ul>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>

- * </ul>

- */

+/**
+ * Returns the longest duration, in milliseconds, between
+ * two mouse button clicks that will be considered a
+ * <em>double click</em> by the underlying operating system.
+ *
+ * @return the double click time
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
 public int getDoubleClickTime () {

 	checkDevice ();

 	return OS.XtGetMultiClickTime (xDisplay);

 }

-/**

- * Returns the control which currently has keyboard focus,

- * or null if keyboard events are not currently going to

- * any of the controls built by the currently running

- * application.

- *

- * @return the control under the cursor

- *

- * @exception SWTException <ul>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>

- * </ul>

- */

+/**
+ * Returns the control which currently has keyboard focus,
+ * or null if keyboard events are not currently going to
+ * any of the controls built by the currently running
+ * application.
+ *
+ * @return the control under the cursor
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
 public Control getFocusControl () {

 	checkDevice ();

 	int [] buffer1 = new int [1], buffer2 = new int [1];

@@ -748,30 +747,30 @@
 	} while ((handle = OS.XtParent (handle)) != 0);

 	return null;

 }

-/**

- * Returns the maximum allowed depth of icons on this display.

- * On some platforms, this may be different than the actual

- * depth of the display.

- *

- * @return the maximum icon depth

- *

- * @exception SWTException <ul>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>

- * </ul>

- */

+/**
+ * Returns the maximum allowed depth of icons on this display.
+ * On some platforms, this may be different than the actual
+ * depth of the display.
+ *
+ * @return the maximum icon depth
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
 public int getIconDepth () {

 	return getDepth ();

 }

-/**

- * Returns an array containing all shells which have not been

- * disposed and have the receiver as their display.

- *

- * @return the receiver's shells

- *

- * @exception SWTException <ul>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>

- * </ul>

- */

+/**
+ * Returns an array containing all shells which have not been
+ * disposed and have the receiver as their display.
+ *
+ * @return the receiver's shells
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
 public Shell [] getShells () {

 	checkDevice ();

 	/*

@@ -799,38 +798,38 @@
 	}

 	return result;

 }

-/**

- * Returns the thread that has invoked <code>syncExec</code>

- * or null if no such runnable is currently being invoked by

- * the user-interface thread.

- * <p>

- * Note: If a runnable invoked by asyncExec is currently

- * running, this method will return null.

- * </p>

- *

- * @return the receiver's sync-interface thread

+/**
+ * Returns the thread that has invoked <code>syncExec</code>
+ * or null if no such runnable is currently being invoked by
+ * the user-interface thread.
+ * <p>
+ * Note: If a runnable invoked by asyncExec is currently
+ * running, this method will return null.
+ * </p>
+ *
+ * @return the receiver's sync-interface thread
  */

 public Thread getSyncThread () {

 	if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);

 	return synchronizer.syncThread;

 }

-/**

- * Returns the matching standard color for the given

- * constant, which should be one of the color constants

- * specified in class <code>SWT</code>. Any value other

- * than one of the SWT color constants which is passed

- * in will result in the color black. This color should

- * not be free'd because it was allocated by the system,

- * not the application.

- *

- * @param id the color constant

- * @return the matching color

- *

- * @exception SWTException <ul>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>

- * </ul>

- *

- * @see SWT

+/**
+ * Returns the matching standard color for the given
+ * constant, which should be one of the color constants
+ * specified in class <code>SWT</code>. Any value other
+ * than one of the SWT color constants which is passed
+ * in will result in the color black. This color should
+ * not be free'd because it was allocated by the system,
+ * not the application.
+ *
+ * @param id the color constant
+ * @return the matching color
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SWT
  */

 public Color getSystemColor (int id) {

 	checkDevice ();

@@ -861,35 +860,35 @@
 	if (xColor == null) return super.getSystemColor (SWT.COLOR_BLACK);

 	return Color.motif_new (this, xColor);

 }

-/**

- * Returns a reasonable font for applications to use.

- * On some platforms, this will match the "default font"

- * or "system font" if such can be found.  This font

- * should not be free'd because it was allocated by the

- * system, not the application.

- * <p>

- * Typically, applications which want the default look

- * should simply not set the font on the widgets they

- * create. Widgets are always created with the correct

- * default font for the class of user-interface component

- * they represent.

- * </p>

- *

- * @return a font

- *

- * @exception SWTException <ul>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>

- * </ul>

- */

+/**
+ * Returns a reasonable font for applications to use.
+ * On some platforms, this will match the "default font"
+ * or "system font" if such can be found.  This font
+ * should not be free'd because it was allocated by the
+ * system, not the application.
+ * <p>
+ * Typically, applications which want the default look
+ * should simply not set the font on the widgets they
+ * create. Widgets are always created with the correct
+ * default font for the class of user-interface component
+ * they represent.
+ * </p>
+ *
+ * @return a font
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
 public Font getSystemFont () {

 	checkDevice ();

 	return Font.motif_new (this, defaultFontList);

 }

-/**

- * Returns the user-interface thread for the receiver.

- *

- * @return the receiver's user-interface thread

- */

+/**
+ * Returns the user-interface thread for the receiver.
+ *
+ * @return the receiver's user-interface thread
+ */
 public Thread getThread () {

 	if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);

 	return thread;

@@ -1071,16 +1070,16 @@
 	checkExposeCallback = new Callback (this, "checkExposeProc", 3);

 	checkExposeProc = checkExposeCallback.getAddress ();

 	if (checkExposeProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);

-	wakeCallback = new Callback (this, "wakeProc", 3);

-	wakeProc = wakeCallback.getAddress ();

-	if (wakeProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);

-	

-	/* Create and install the pipe used to wake up from sleep */

-	int [] filedes = new int [2];

-	if (OS.pipe (filedes) != 0) error (SWT.ERROR_NO_HANDLES);

-	read_fd = filedes [0];  write_fd = filedes [1];

-	int xtAppContext = OS.XtDisplayToApplicationContext (xDisplay);

-	inputID = OS.XtAppAddInput (xtAppContext, read_fd, OS.XtInputReadMask, wakeProc, 0);

+	wakeCallback = new Callback (this, "wakeProc", 3);
+	wakeProc = wakeCallback.getAddress ();
+	if (wakeProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+	
+	/* Create and install the pipe used to wake up from sleep */
+	int [] filedes = new int [2];
+	if (OS.pipe (filedes) != 0) error (SWT.ERROR_NO_HANDLES);
+	read_fd = filedes [0];  write_fd = filedes [1];
+	int xtAppContext = OS.XtDisplayToApplicationContext (xDisplay);
+	inputID = OS.XtAppAddInput (xtAppContext, read_fd, OS.XtInputReadMask, wakeProc, 0);
 	

 	/*

 	* Use dynamic Drag and Drop Protocol styles.

@@ -1269,23 +1268,22 @@
 	byte [] buffer3 = Converter.wcsToMbcs (null, "<Btn2Down>:\0");

 	dragTranslations = OS.XtParseTranslationTable (buffer3);

 }

-/**	 

- * Invokes platform specific functionality to allocate a new GC handle.

- * <p>

- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public

- * API for <code>Display</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 data the platform specific GC data 

- * @return the platform specific GC handle

- *

- * @private

- */

+/**	 
+ * Invokes platform specific functionality to allocate a new GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Display</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 data the platform specific GC data 
+ * @return the platform specific GC handle
+ *
+ * @private
+ */
 public int internal_new_GC (GCData data) {

-	if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);

 	int xDrawable = OS.XDefaultRootWindow (xDisplay);

 	int xGC = OS.XCreateGC (xDisplay, xDrawable, 0, null);

 	if (xGC == 0) SWT.error (SWT.ERROR_NO_HANDLES);

@@ -1299,21 +1297,21 @@
 	}

 	return xGC;

 }

-/**	 

- * Invokes platform specific functionality to dispose a GC handle.

- * <p>

- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public

- * API for <code>Display</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 handle the platform specific GC handle

- * @param data the platform specific GC data 

- *

- * @private

- */

+/**	 
+ * Invokes platform specific functionality to dispose a GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Display</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 handle the platform specific GC handle
+ * @param data the platform specific GC data 
+ *
+ * @private
+ */
 public void internal_dispose_GC (int gc, GCData data) {

 	OS.XFreeGC(xDisplay, gc);

 }

@@ -1352,44 +1350,44 @@
 	}

 	eventQueue [index] = event;

 }

-/**

- * Reads an event from the operating system's event queue,

- * dispatches it appropriately, and returns <code>true</code>

- * if there is potentially more work to do, or <code>false</code>

- * if the caller can sleep until another event is placed on

- * the event queue.

- * <p>

- * In addition to checking the system event queue, this method also

- * checks if any inter-thread messages (created by <code>syncExec()</code>

- * or <code>asyncExec()</code>) are waiting to be processed, and if

- * so handles them before returning.

- * </p>

- *

- * @return <code>false</code> if the caller can sleep upon return from this method

- *

- * @exception SWTException <ul>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>

- * </ul>

- *

- * @see #sleep

- * @see #wake

- */

+/**
+ * Reads an event from the operating system's event queue,
+ * dispatches it appropriately, and returns <code>true</code>
+ * if there is potentially more work to do, or <code>false</code>
+ * if the caller can sleep until another event is placed on
+ * the event queue.
+ * <p>
+ * In addition to checking the system event queue, this method also
+ * checks if any inter-thread messages (created by <code>syncExec()</code>
+ * or <code>asyncExec()</code>) are waiting to be processed, and if
+ * so handles them before returning.
+ * </p>
+ *
+ * @return <code>false</code> if the caller can sleep upon return from this method
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #sleep
+ * @see #wake
+ */
 public boolean readAndDispatch () {

 	checkDevice ();

 	int xtContext = OS.XtDisplayToApplicationContext (xDisplay);

 	int status = OS.XtAppPending (xtContext);

-	if (status != 0) {

+	if (status != 0) {
 		if ((status & OS.XtIMTimer) != 0) {

 			OS.XtAppProcessEvent (xtContext, OS.XtIMTimer);

-			status = OS.XtAppPending (xtContext);

+		}
+		if ((status & OS.XtIMAlternateInput) != 0) {
+			OS.XtAppProcessEvent (xtContext, OS.XtIMAlternateInput);
+//			runAsyncMessages ();
 		}

-		if ((status & OS.XtIMAlternateInput) != 0) {

-			OS.XtAppProcessEvent (xtContext, OS.XtIMAlternateInput);

-			status = OS.XtAppPending (xtContext);

-		}

-		if ((status & OS.XtIMXEvent) != 0) {

+		if ((status & OS.XtIMXEvent) != 0) {
 			OS.XtAppNextEvent (xtContext, xEvent);

-			if (!filterEvent (xEvent)) OS.XtDispatchEvent (xEvent);

+			if (filterEvent (xEvent)) return false;

+			OS.XtDispatchEvent (xEvent);

 		}

 		runDeferredEvents ();

 		return true;

@@ -1431,15 +1429,15 @@
 	/* Release synchronizer */

 	synchronizer.releaseSynchronizer ();

 	synchronizer = null;

-	releaseDisplay ();

-

+	releaseDisplay ();
+
 	super.release ();

 }

-void releaseDisplay () {

-

-	/* Destroy the hidden Override shell parent */

-	if (shellHandle != 0) OS.XtDestroyWidget (shellHandle);

-	shellHandle = 0;

+void releaseDisplay () {
+
+	/* Destroy the hidden Override shell parent */
+	if (shellHandle != 0) OS.XtDestroyWidget (shellHandle);
+	shellHandle = 0;
 	

 	/* Dispose the caret callback */

 	if (caretID != 0) OS.XtRemoveTimeOut (caretID);

@@ -1459,7 +1457,7 @@
 	timerCallback.dispose ();

 	timerCallback = null;

 	

-	/* Dispose the mouse hover callback */

+	/* Dispose the mouse hover callback */
 	if (mouseHoverID != 0) OS.XtRemoveTimeOut (mouseHoverID);

 	mouseHoverID = mouseHoverProc = mouseHoverHandle = toolTipHandle = 0;

 	mouseHoverCallback.dispose ();

@@ -1469,13 +1467,13 @@
 	windowCallback.dispose (); windowCallback = null;

 	checkExposeCallback.dispose (); checkExposeCallback = null;

 	checkExposeProc = 0;

-	

-	/* Dispose the wake callback, id and pipe */

-	if (inputID != 0) OS.XtRemoveInput (inputID);

-	wakeCallback.dispose (); wakeCallback = null;

-	wakeProc = 0;

-	OS.close (read_fd);

-	OS.close (write_fd);

+	
+	/* Dispose the wake callback, id and pipe */
+	if (inputID != 0) OS.XtRemoveInput (inputID);
+	wakeCallback.dispose (); wakeCallback = null;
+	wakeProc = 0;
+	OS.close (read_fd);
+	OS.close (write_fd);
 		

 	/* Free the font lists */

 	if (buttonFont != 0) OS.XmFontListFree (buttonFont);

@@ -1556,13 +1554,13 @@
 	eventQueue = null;

 	return true;

 }

-/**

- * On platforms which support it, sets the application name

- * to be the argument. On Motif, for example, this can be used

- * to set the name used for resource lookup.

- *

- * @param name the new app name

- */

+/**
+ * On platforms which support it, sets the application name
+ * to be the argument. On Motif, for example, this can be used
+ * to set the name used for resource lookup.
+ *
+ * @param name the new app name
+ */
 public static void setAppName (String name) {

 	APP_NAME = name;

 }

@@ -1576,30 +1574,30 @@
 		caretID = OS.XtAppAddTimeOut (xtContext, blinkRate, caretProc, 0);

 	}

 }

-/**

- * Sets the application defined property of the receiver

- * with the specified name to the given argument.

- * <p>

- * Applications may have associated arbitrary objects with the

- * receiver in this fashion. If the objects stored in the

- * properties need to be notified when the display is disposed

- * of, it is the application's responsibility provide a

- * <code>disposeExec()</code> handler which does so.

- * </p>

- *

- * @param key the name of the property

- * @param value the new value for the property

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the key is null</li>

- * </ul>

- * @exception SWTException <ul>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>

- * </ul>

- *

- * @see #setData

- * @see #disposeExec

- */

+/**
+ * Sets the application defined property of the receiver
+ * with the specified name to the given argument.
+ * <p>
+ * Applications may have associated arbitrary objects with the
+ * receiver in this fashion. If the objects stored in the
+ * properties need to be notified when the display is disposed
+ * of, it is the application's responsibility provide a
+ * <code>disposeExec()</code> handler which does so.
+ * </p>
+ *
+ * @param key the name of the property
+ * @param value the new value for the property
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the key is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setData
+ * @see #disposeExec
+ */
 public void setData (String key, Object value) {

 	checkDevice ();

 	if (key == null) error (SWT.ERROR_NULL_ARGUMENT);

@@ -1647,45 +1645,45 @@
 	keys = newKeys;

 	values = newValues;

 }

-/**

- * Sets the application defined, display specific data

- * associated with the receiver, to the argument.

- * The <em>display specific data</em> is a single,

- * unnamed field that is stored with every display. 

- * <p>

- * Applications may put arbitrary objects in this field. If

- * the object stored in the display specific data needs to

- * be notified when the display is disposed of, it is the

- * application's responsibility provide a

- * <code>disposeExec()</code> handler which does so.

- * </p>

- *

- * @param data the new display specific data

- *

- * @exception SWTException <ul>

- *    <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>

- * </ul>

- *

- * @see #getData

- * @see #disposeExec

- */

+/**
+ * Sets the application defined, display specific data
+ * associated with the receiver, to the argument.
+ * The <em>display specific data</em> is a single,
+ * unnamed field that is stored with every display. 
+ * <p>
+ * Applications may put arbitrary objects in this field. If
+ * the object stored in the display specific data needs to
+ * be notified when the display is disposed of, it is the
+ * application's responsibility provide a
+ * <code>disposeExec()</code> handler which does so.
+ * </p>
+ *
+ * @param data the new display specific data
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>
+ * </ul>
+ *
+ * @see #getData
+ * @see #disposeExec
+ */
 public void setData (Object data) {

 	checkDevice ();

 	this.data = data;

 }

-/**

- * Sets the synchronizer used by the display to be

- * the argument, which can not be null.

- *

- * @param synchronizer the new synchronizer for the display (must not be null)

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the synchronizer is null</li>

- * </ul>

- * @exception SWTException <ul>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>

- * </ul>

- */

+/**
+ * Sets the synchronizer used by the display to be
+ * the argument, which can not be null.
+ *
+ * @param synchronizer the new synchronizer for the display (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the synchronizer is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
 public void setSynchronizer (Synchronizer synchronizer) {

 	checkDevice ();

 	if (synchronizer == null) error (SWT.ERROR_NULL_ARGUMENT);

@@ -1695,105 +1693,115 @@
 	this.synchronizer = synchronizer;

 }

 void showToolTip (int handle, String toolTipText) {

-	if (toolTipText == null || toolTipText.length () == 0 || toolTipHandle != 0) {

+	if (toolTipText == null || toolTipText.length() == 0 || toolTipHandle != 0) {

 		 return;

 	}

 	

-	/* Create the shell and tool tip widget */

+	/* Create the tooltip widgets */	

 	int widgetClass = OS.OverrideShellWidgetClass ();

 	int [] argList1 = {OS.XmNmwmDecorations, 0, OS.XmNborderWidth, 1};

 	int shellHandle = OS.XtCreatePopupShell (null, widgetClass, handle, argList1, argList1.length / 2);

-	Color infoForeground = getSystemColor (SWT.COLOR_INFO_FOREGROUND);

-	Color infoBackground = getSystemColor (SWT.COLOR_INFO_BACKGROUND);

-	int foregroundPixel = infoForeground.handle.pixel;

-	int backgroundPixel = infoBackground.handle.pixel;

-	/* Use the character encoding for the default locale */

+	toolTipHandle = OS.XmCreateLabel(shellHandle, null, null, 0);

+	

+	/* Set the tooltip foreground and background */

+	Color infoForeground = getSystemColor(SWT.COLOR_INFO_FOREGROUND);

+	Color infoBackground = getSystemColor(SWT.COLOR_INFO_BACKGROUND);

+	int foregroundPixel = (infoForeground == null) ? defaultForeground : infoForeground.handle.pixel;

+	int backgroundPixel = (infoBackground == null) ? defaultBackground : infoBackground.handle.pixel;

+	int [] argList2 = {OS.XmNforeground, foregroundPixel, OS.XmNbackground, backgroundPixel};

+	OS.XtSetValues (toolTipHandle, argList2, argList2.length / 2);

+	OS.XtManageChild (toolTipHandle);		

+	

+	/* Set the tooltip label string */

 	byte [] buffer = Converter.wcsToMbcs (null, toolTipText, true);

-	int [] argList2 = {

-		OS.XmNforeground, foregroundPixel, 

-		OS.XmNbackground, backgroundPixel,

-		OS.XmNalignment, OS.XmALIGNMENT_BEGINNING,

-	};

-	toolTipHandle = OS.XmCreateLabel (shellHandle, buffer, argList2, argList2.length / 2);

-	OS.XtManageChild (toolTipHandle);	

+	int xmString = OS.XmStringParseText (

+		buffer,

+		0,

+		OS.XmFONTLIST_DEFAULT_TAG, 

+		OS.XmCHARSET_TEXT, 

+		null,

+		0,

+		0);

+	int [] argList3 = {OS.XmNlabelString, xmString};

+	OS.XtSetValues (toolTipHandle, argList3, argList3.length / 2);

+	if (xmString != 0) OS.XmStringFree (xmString);	

 		

 	/*

 	* Feature in X.  There is no way to query the size of a cursor.

 	* The fix is to use the default cursor size which is 16x16.

-	*/

-	int xWindow = OS.XDefaultRootWindow (xDisplay);

-	int [] rootX = new int [1], rootY = new int [1], unused = new int [1];

-	OS.XQueryPointer (xDisplay, xWindow, unused, unused, rootX, rootY, unused, unused, unused);

-	int x = rootX [0] + 16, y = rootY [0] + 16;

-	

-	/*

-	* Ensure that the tool tip is on the screen.

-	*/

-	int screen = OS.XDefaultScreen (xDisplay);

-	int width = OS.XDisplayWidth (xDisplay, screen);

-	int height = OS.XDisplayHeight (xDisplay, screen);

-	int [] argList4 = {OS.XmNwidth, 0, OS.XmNheight, 0};

-	OS.XtGetValues (toolTipHandle, argList4, argList4.length / 2);

-	x = Math.max (0, Math.min (x, width - argList4 [1]));

-	y = Math.max (0, Math.min (y, height - argList4 [3]));

-	OS.XtMoveWidget (shellHandle, x, y);

+	*/
+	int xWindow = OS.XDefaultRootWindow (xDisplay);
+	int [] rootX = new int [1], rootY = new int [1], unused = new int [1];
+	OS.XQueryPointer (xDisplay, xWindow, unused, unused, rootX, rootY, unused, unused, unused);
+	int x = rootX [0] + 16, y = rootY [0] + 16;
+	
+	/*
+	* Ensure that the tooltip is on the screen.
+	*/
+	int screen = OS.XDefaultScreen (xDisplay);
+	int width = OS.XDisplayWidth (xDisplay, screen);
+	int height = OS.XDisplayHeight (xDisplay, screen);
+	int [] argList4 = {OS.XmNwidth, 0, OS.XmNheight, 0};
+	OS.XtGetValues (toolTipHandle, argList4, argList4.length / 2);
+	x = Math.max (0, Math.min (x, width - argList4 [1]));
+	y = Math.max (0, Math.min (y, height - argList4 [3]));
+	OS.XtMoveWidget (shellHandle, x, y);
 	OS.XtPopup (shellHandle, OS.XtGrabNone);

 }

-/**

- * Causes the user-interface thread to <em>sleep</em> (that is,

- * to be put in a state where it does not consume CPU cycles)

- * until an event is received or it is otherwise awakened.

- *

- * @return <code>true</code> if an event requiring dispatching was placed on the queue.

- *

- * @exception SWTException <ul>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>

- * </ul>

- *

- * @see #wake

- */

+/**
+ * Causes the user-interface thread to <em>sleep</em> (that is,
+ * to be put in a state where it does not consume CPU cycles)
+ * until an event is received or it is otherwise awakened.
+ *
+ * @return <code>true</code> if an event requiring dispatching was placed on the queue.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #wake
+ */
 public boolean sleep () {

 	checkDevice ();

 	int xtContext = OS.XtDisplayToApplicationContext (xDisplay);

 	return OS.XtAppPeekEvent (xtContext, xEvent);

 }

-/**

- * Causes the <code>run()</code> method of the runnable to

- * be invoked by the user-interface thread at the next 

- * reasonable opportunity. The thread which calls this method

- * is suspended until the runnable completes.

- *

- * @param runnable code to run on the user-interface thread.

- *

- * @see #asyncExec

- */

+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread at the next 
+ * reasonable opportunity. The thread which calls this method
+ * is suspended until the runnable completes.
+ *
+ * @param runnable code to run on the user-interface thread.
+ *
+ * @see #asyncExec
+ */
 public void syncExec (Runnable runnable) {

 	if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);

 	synchronizer.syncExec (runnable);

 }

 int textWidth (String string, int fontList) {

 	if (string.length () == 0) return 0;

-	String codePage = Converter.getCodePage (xDisplay, fontList);

-	byte [] textBuffer = Converter.wcsToMbcs (codePage, string, true);

+	byte [] textBuffer = Converter.wcsToMbcs (null, string, true);

 	int xmString = OS.XmStringGenerate (textBuffer, null, OS.XmCHARSET_TEXT, _MOTIF_DEFAULT_LOCALE);

 	int width = OS.XmStringWidth (fontList, xmString);

 	OS.XmStringFree (xmString);

 	return width;

 }

-/**

- * Causes the <code>run()</code> method of the runnable to

- * be invoked by the user-interface thread after the specified

- * number of milliseconds have elapsed.

- *

- * @param milliseconds the delay before running the runnable

- * @param runnable code to run on the user-interface thread

- *

- * @exception SWTException <ul>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>

- * </ul>

- *

- * @see #asyncExec

- */

+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread after the specified
+ * number of milliseconds have elapsed.
+ *
+ * @param milliseconds the delay before running the runnable
+ * @param runnable code to run on the user-interface thread
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #asyncExec
+ */
 public void timerExec (int milliseconds, Runnable runnable) {

 	checkDevice ();

 	if (timerList == null) timerList = new Runnable [4];

@@ -1849,22 +1857,22 @@
 	OS.XSync (xDisplay, false); OS.XSync (xDisplay, false);

 	while (OS.XCheckMaskEvent (xDisplay, mask, event)) OS.XtDispatchEvent (event);

 }

-/**

- * If the receiver's user-interface thread was <code>sleep</code>'ing, 

- * causes it to be awakened and start running again. Note that this

- * method may be called from any thread.

- *

- * @see #sleep

- */

+/**
+ * If the receiver's user-interface thread was <code>sleep</code>'ing, 
+ * causes it to be awakened and start running again. Note that this
+ * method may be called from any thread.
+ *
+ * @see #sleep
+ */
 public void wake () {

-	if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);

-	/* Write a single byte to the wake up pipe */

+	if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+	/* Write a single byte to the wake up pipe */
 	while (OS.write (write_fd, wake_buffer, 1) != 1);

-}

-int wakeProc (int closure, int source, int id) {

-	/* Read a single byte from the wake up pipe */

-	while (OS.read (read_fd, wake_buffer, 1) != 1);

-	return 0;

+}
+int wakeProc (int closure, int source, int id) {
+	/* Read a single byte from the wake up pipe */
+	while (OS.read (read_fd, wake_buffer, 1) != 1);
+	return 0;
 }

 int windowProc (int handle, int clientData, int callData, int unused) {

 	Widget widget = WidgetTable.get (handle);

@@ -1902,10 +1910,9 @@
 			}

 			if (lineWidth > width) {

 				if (lastStart == wordStart) {

-					while (wordStart < wordEnd) {

-						line = text.substring (lineStart, wordStart + 1);

-						lineWidth = textWidth (line, fontList);

-						if (lineWidth >= width) break;

+					line = text.substring (lineStart, wordStart + 1);

+					lineWidth = textWidth (line, fontList);

+					while (wordStart < wordEnd && lineWidth < width) {

 						wordStart++;

 					}

 					if (wordStart == lastStart) wordStart++;

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FileDialog.java
index a55bc30..8603df1 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FileDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FileDialog.java
@@ -9,19 +9,19 @@
 import org.eclipse.swt.internal.motif.*;

 import org.eclipse.swt.*;

 

-/**

- * Instances of this class allow the user to navigate

- * the file system and select or enter a file name.

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>SAVE, OPEN, MULTI</dd>

- * <dt><b>Events:</b></dt>

- * <dd>(none)</dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is intended to be subclassed <em>only</em>

- * within the SWT implementation.

- * </p>

+/**
+ * Instances of this class allow the user to navigate
+ * the file system and select or enter a file name.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SAVE, OPEN, MULTI</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
  */

 public /*final*/ class FileDialog extends Dialog {

 	String [] filterNames = new String [0];

@@ -32,136 +32,32 @@
 	boolean cancel = true;

 	static final String FILTER = "*";

 

-/**

- * Constructs a new instance of this class given only its

- * parent.

- * <p>

- * Note: Currently, null can be passed in for the parent.

- * This has the effect of creating the dialog on the currently active

- * display if there is one. If there is no current display, the 

- * dialog is created on a "default" display. <b>Passing in null as

- * the parent is not considered to be good coding style,

- * and may not be supported in a future release of SWT.</b>

- * </p>

- *

- * @param parent a shell which will be the parent of the new instance

- *

- * @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>

- */

 public FileDialog (Shell parent) {

 	this (parent, SWT.PRIMARY_MODAL);

 }

-

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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 dialog classes should include a comment which

- * describes the style constants which are applicable to the class.

- * </p>

- * Note: Currently, null can be passed in for the parent.

- * This has the effect of creating the dialog on the currently active

- * display if there is one. If there is no current display, the 

- * dialog is created on a "default" display. <b>Passing in null as

- * the parent is not considered to be good coding style,

- * and may not be supported in a future release of SWT.</b>

- * </p>

- *

- * @param parent a shell which will be the parent of the new instance

- *

- * @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>

- */

 public FileDialog (Shell parent, int style) {

 	super (parent, style);

 }

-

 int activate (int widget, int client, int call) {

 	cancel = client == OS.XmDIALOG_CANCEL_BUTTON;

 	OS.XtUnmanageChild (widget);

 	return 0;

 }

-

-/**

- * Returns the path of the first file that was

- * selected in the dialog relative to the filter path,

- * or null if none is available.

- * 

- * @return the relative path of the file

- */

 public String getFileName () {

 	return fileName;

 }

-

-/**

- * Returns the paths of all files that were selected

- * in the dialog relative to the filter path, or null

- * if none are available.

- * 

- * @return the relative paths of the files

- */

 public String [] getFileNames () {

 	return new String [] {fileName};

 }

-

-/**

- * Returns the file extensions which the dialog will

- * use to filter the files it shows.

- *

- * @return the file extensions filter

- */

 public String [] getFilterExtensions () {

 	return filterExtensions;

 }

-

-/**

- * Returns the file names which the dialog will

- * use to filter the files it shows.

- *

- * @return the file name filter

- */

 public String [] getFilterNames () {

 	return filterNames;

 }

-

-/**

- * Returns the path which the dialog will use to filter

- * the files it shows.

- *

- * @return the filter path

- */

 public String getFilterPath () {

 	return filterPath;

 }

-

-/**

- * Makes the dialog visible and brings it to the front

- * of the display.

- *

- * @return a string describing the absolute path of the first selected file,

- *         or null if the dialog was cancelled or an error occurred

- *

- * @exception SWTException <ul>

- *    <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>

- * </ul>

- */

 public String open () {

 

 	/* Get the parent */

@@ -181,7 +77,6 @@
 	*/

 	String string = title;

 	if (string.length () == 0) string = " ";

-	/* Use the character encoding for the default locale */

 	byte [] buffer1 = Converter.wcsToMbcs (null, string, true);

 	int xmStringPtr1 = OS.XmStringParseText (

 		buffer1,

@@ -205,7 +100,6 @@
 			if (filter.indexOf (';', 0) == -1) mask = filter;

 		}

 	}

-	/* Use the character encoding for the default locale */

 	byte [] buffer2 = Converter.wcsToMbcs (null, mask, true);

 	int xmStringPtr2 = OS.XmStringParseText (

 		buffer2,

@@ -218,7 +112,6 @@
 

 	/* Compute the filter path */

 	if (filterPath == null) filterPath = "";

-	/* Use the character encoding for the default locale */

 	byte [] buffer3 = Converter.wcsToMbcs (null, filterPath, true);

 	int xmStringPtr3 = OS.XmStringParseText (

 		buffer3,

@@ -312,7 +205,6 @@
 			byte [] buffer = new byte [length];

 			OS.memmove (buffer, ptr, length);

 			OS.XtFree (ptr);

-			/* Use the character encoding for the default locale */

 			filterPath = new String (Converter.mbcsToWcs (null, buffer));

 		}

 		OS.XmStringFree (xmString3);

@@ -330,7 +222,6 @@
 			byte [] buffer = new byte [length];

 			OS.memmove (buffer, ptr, length);

 			OS.XtFree (ptr);

-			/* Use the character encoding for the default locale */

 			fullPath = new String (Converter.mbcsToWcs (null, buffer));

 		}

 		OS.XmStringFree (xmString4);

@@ -355,48 +246,15 @@
 	if (cancel) return null;

 	return fullPath;

 }

-

-/**

- * Set the initial filename which the dialog will

- * select by default when opened to the argument,

- * which may be null.  The name will be prefixed with

- * the filter path when one is supplied.

- * 

- * @param string the file name

- */

 public void setFileName (String string) {

 	fileName = string;

 }

-

-/**

- * Set the file extensions which the dialog will

- * use to filter the files it shows to the argument,

- * which may be null.

- *

- * @param extensions the file extension filter

- */

 public void setFilterExtensions (String [] extensions) {

 	filterExtensions = extensions;

 }

-

-/**

- * Sets the file names which the dialog will

- * use to filter the files it shows to the argument,

- * which may be null.

- *

- * @param names the file name filter

- */

 public void setFilterNames (String [] names) {

 	filterNames = names;

 }

-

-/**

- * Sets the path which the dialog will use to filter

- * the files it shows to the argument, which may be

- * null.

- *

- * @param string the filter path

- */

 public void setFilterPath (String string) {

 	filterPath = string;

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontDialog.java
index dbfb589..ea7088a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontDialog.java
@@ -11,20 +11,17 @@
 import java.text.*;

 import java.util.*;

 

-/**

- * Instances of this class allow the user to select a font

- * from all available fonts in the system.

- * <p>

- * IMPORTANT: This class is intended to be subclassed <em>only</em>

- * within the SWT implementation.

- * </p>

+/**
+ * Instances of this class allow the user to select a font
+ * from all available fonts in the system.
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
  */

 public /*final*/ class FontDialog extends Dialog {

 	private static final String TEXT_SAMPLE = "AaBbYyZz";

 	private static final String TEXT_FONT_NOT_LOADED = "Could not load selected font";	// text used in place of sample text when the selected font could not be loaded

-	private static final String SCALABLE_SIZES[] = new String[] {"8", "10", "11", "12", "14", "16", "18", "22", "24", "26"};

-	private static final int DEFAULT_SIZE = 14;

-	private static final String DEFAULT_STYLE = FontExtStyles.MEDIUM;

 	

 	private Shell shell;						// the dialog shell

 	private Combo characterSet;

@@ -47,67 +44,24 @@
 												// Used to correctly clean up allocated fonts

 												// will be used to initialize the font 

 												// combo boxes when the dialog is opened												

-

 /**

- * Constructs a new instance of this class given only its

- * parent.

- * <p>

- * Note: Currently, null can be passed in for the parent.

- * This has the effect of creating the dialog on the currently active

- * display if there is one. If there is no current display, the 

- * dialog is created on a "default" display. <b>Passing in null as

- * the parent is not considered to be good coding style,

- * and may not be supported in a future release of SWT.</b>

- * </p>

- *

- * @param parent a shell which will be the parent of the new instance

- *

- * @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>

+ * Create a new instance of the receiver with 'parent' as 

+ * its parent shell.

+ * @param parent - the parent shell. May be null

  */

 public FontDialog(Shell parent) {

 	this(parent, SWT.NULL);

 }

-

 /**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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 dialog classes should include a comment which

- * describes the style constants which are applicable to the class.

- * </p>

- * Note: Currently, null can be passed in for the parent.

- * This has the effect of creating the dialog on the currently active

- * display if there is one. If there is no current display, the 

- * dialog is created on a "default" display. <b>Passing in null as

- * the parent is not considered to be good coding style,

- * and may not be supported in a future release of SWT.</b>

- * </p>

- *

- * @param parent a shell which will be the parent of the new instance

- *

- * @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>

+ * Create a new instance of the receiver with 'parent' as 

+ * its parent shell using 'style' as the widget style.

+ * @param parent - the parent shell. May be null

+ * @param style - style bits used to create the receiver.

+ *	See class definition for details

  */

 public FontDialog(Shell parent, int style) {

 	super(parent, style | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);

 }

-

 /**

  * Add the fonts found in 'fonts' to the list of fonts.

  * Fonts are stored by character set and face name. For each character 

@@ -288,10 +242,8 @@
 	return faceName;

 }

 /**

- * Returns a FontData object describing the font that was

- * selected in the dialog, or null if none is available.

- * 

- * @return the FontData for the selected font, or null

+ * Returns the FontData for the selected font.

+ * Returns null if no font was selected and the dialog was cancelled.

  */

 public FontData getFontData() {

 	return dialogResult;

@@ -580,35 +532,32 @@
  * is used.

  */

 void initSizeCombo(FontExtStyles fontExtStyles) {

+	Vector sizes = null;

+	Integer size;

 	Combo sizeCombo = getSizeCombo();

-	String previousSize = sizeCombo.getText();

-	sizeCombo.removeAll();

-

+	String sizeStrings[] = {"8", "10", "11", "12", "14", "16", "18", "22", "24", "26"};

 	int selectionIndex = -1;

+	final int SelectionSize = 14;	

 

-	if (fontExtStyles.isScalable()) {

-		sizeCombo.setItems(SCALABLE_SIZES);

-		selectionIndex = sizeCombo.indexOf(String.valueOf(DEFAULT_SIZE));

+	sizeCombo.removeAll();

+	if (fontExtStyles.isScalable() == true) {

+		sizeCombo.setItems(sizeStrings);

+		selectionIndex = 4;

 	}

 	else {

-		Vector sizes = fontExtStyles.getSizes(getExtStyleCombo().getText());

+		sizes = fontExtStyles.getSizes(getExtStyleCombo().getText());

 		for (int i = 0; i < sizes.size(); i++) {

-			Integer size = (Integer) sizes.elementAt(i);

+			size = (Integer) sizes.elementAt(i);

 			sizeCombo.add(size.toString());

-			// select the largest height if there's no font

-			// size that is at least as high as SelectionSize

-			if (size.intValue() >= DEFAULT_SIZE && selectionIndex == -1)

+			if (size.intValue() >= SelectionSize && selectionIndex == -1) {

 				selectionIndex = i;

+			}

 		}

+	}	

+	if (selectionIndex == -1) {

+		selectionIndex = sizes.size() - 1;			// select largest height if there's no font 

+													// size that is at least as high as SelectionSize 

 	}

-

-	int indexOfPreviousSelection = sizeCombo.indexOf(previousSize);

-	if (indexOfPreviousSelection != -1)

-		selectionIndex = indexOfPreviousSelection;

-

-	if (selectionIndex == -1)	// last resort case, should not happen

-		selectionIndex = sizeCombo.getItemCount() - 1;			

-

 	sizeCombo.select(selectionIndex);	

 }

 /**

@@ -616,20 +565,20 @@
  * is available in.

  */

 void initStyleCombo(FontExtStyles fontExtStyles) {

+	Vector styleVector = fontExtStyles.getStyles(getExtStyleCombo().getText());

+	Enumeration styleEnum = styleVector.elements();

 	Combo styleCombo = getStyleCombo();

-	String previousStyle = styleCombo.getText();

+	int selectionIndex = styleVector.indexOf(FontExtStyles.MEDIUM);

+	String style;

+

 	styleCombo.removeAll();

-	

-	Enumeration styleEnum = fontExtStyles.getStyles(getExtStyleCombo().getText()).elements();

-	while (styleEnum.hasMoreElements())

-		styleCombo.add((String)styleEnum.nextElement());

-

-	int selectionIndex = styleCombo.indexOf(previousStyle);

-	if (selectionIndex == -1)

-		selectionIndex = styleCombo.indexOf(DEFAULT_STYLE);

-	if (selectionIndex == -1)	// last resort

+	while (styleEnum.hasMoreElements() == true) {

+		style = (String) styleEnum.nextElement();

+		styleCombo.add(style);

+	}		

+	if (selectionIndex == -1) {

 		selectionIndex = 0;

-

+	}

 	styleCombo.select(selectionIndex);

 }

 

@@ -673,16 +622,8 @@
 	getExtStyleCombo().addListener(SWT.Selection, listener);

 }

 /**

- * Makes the dialog visible and brings it to the front

- * of the display.

- *

- * @return a FontData object describing the font that was selected,

- *         or null if the dialog was cancelled or an error occurred

- *

- * @exception SWTException <ul>

- *    <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>

- * </ul>

+ * Initialize the widgets of the receiver, open the dialog

+ * and block the method until the dialog is closed by the user.

  */

 public FontData open() {

 	FontData dialogResult = null;

@@ -736,11 +677,7 @@
 	getStyleCombo().setText(value);

 }

 /**

- * Sets a FontData object describing the font to be

- * selected by default in the dialog, or null to let

- * the platform choose one.

- * 

- * @param fontData the FontData to use initially, or null

+ * Set the preselected font of the receiver to 'fontData'.

  */

 public void setFontData(FontData fontData) {

 	dialogResult = fontData;

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Group.java
index 202dd48..65b797c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Group.java
@@ -10,56 +10,30 @@
 import org.eclipse.swt.graphics.*;

 import org.eclipse.swt.*;

 

-/**

- * Instances of this class provide an etched border

- * with an optional title.

- * <p>

- * Shadow styles are hints and may not be honoured

- * by the platform.  To create a group with the

- * default shadow style for the platform, do not

- * specify a shadow style.

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>SHADOW_ETCHED_IN, SHADOW_ETCHED_OUT, SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>

- * <dt><b>Events:</b></dt>

- * <dd>(none)</dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is <em>not</em> intended to be subclassed.

- * </p>

+/**
+ * Instances of this class provide an etched border
+ * with an optional title.
+ * <p>
+ * Shadow styles are hints and may not be honoured
+ * by the platform.  To create a group with the
+ * default shadow style for the platform, do not
+ * specify a shadow style.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SHADOW_ETCHED_IN, SHADOW_ETCHED_OUT, SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
  */

 

 public /*final*/ class Group extends Composite {

 	int labelHandle;

-

 /**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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

- */

+* Creates a new instance of the widget.

+*/

 public Group (Composite parent, int style) {

 	super (parent, checkStyle (style));

 }

@@ -77,7 +51,8 @@
 	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);

 }

 public Rectangle computeTrim (int x, int y, int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int trimX, trimY, trimWidth, trimHeight;	

 	int [] argList = {

 		OS.XmNwidth, 0, 

@@ -152,7 +127,8 @@
 	return labelHandle;

 }

 public Rectangle getClientArea () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {

 		OS.XmNwidth, 0, 

 		OS.XmNheight, 0, 

@@ -176,20 +152,21 @@
 	}

 	return new Rectangle (x, y, width, height);

 }

-/**

- * Returns the receiver's text, which is the string that the

- * is used as the <em>title</em>. If the text has not previously

- * been set, returns an empty string.

- *

- * @return the text

- *

- * @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 the receiver's text, which is the string that the
+ * is used as the <em>title</em>. If the text has not previously
+ * been set, returns an empty string.
+ *
+ * @return the text
+ *
+ * @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 String getText () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNlabelString, 0};

 	OS.XtGetValues (labelHandle, argList, 1);

 	int xmString = argList [1];

@@ -207,7 +184,7 @@
 	OS.memmove (buffer, address, length);

 	OS.XtFree (address);

 	OS.XmStringFree (xmString);

-	return new String (Converter.mbcsToWcs (getCodePage (), buffer));

+	return new String (Converter.mbcsToWcs (null, buffer));

 }

 boolean mnemonicHit () {

 	return setFocus ();

@@ -233,25 +210,26 @@
 	super.releaseHandle ();

 	labelHandle = 0;

 }

-/**

- * Sets the receiver's text, which is the string that will

- * be displayed as the receiver's <em>title</em>, to the argument,

- * which may not be null. 

- *

- * @param text the new text

- *

- * @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>

+/**
+ * Sets the receiver's text, which is the string that will
+ * be displayed as the receiver's <em>title</em>, to the argument,
+ * which may not be null. 
+ *
+ * @param text the new text
+ *
+ * @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>
  */

 public void setText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (null, string, true);

 	int xmString = OS.XmStringParseText (

 		buffer,

 		0,

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Header.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Header.java
new file mode 100755
index 0000000..c77ad8a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Header.java
@@ -0,0 +1,336 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+

+import org.eclipse.swt.*;

+import org.eclipse.swt.events.*;

+import org.eclipse.swt.graphics.*;

+import java.util.*;

+ 

+/**

+ * A header draws one or more header items. Each item may have a text 

+ * label. Each item is identified by an index and can be resized.

+ */

+class Header extends Canvas {

+	private static final int DEFAULT_WIDTH = 64;		// used in computeSize if width could not be calculated

+	private static final int DEFAULT_HEIGHT = 64;		// used in computeSize if height could not be calculated	

+	private static final int VERTICAL_MARGIN = 4;		// space added to the height of the header label		

+	private static final int TEXT_Y_OFFSET = 2;			// space between the header label and the lower header boundary

+	private static final int DEFAULT_ITEM_WIDTH = 9;	// default width of a header item

+	private static final int TEXT_MARGIN = 6;			// space in front and behind header text

+	private static final int SHADOW_WIDTH = 2;			// width of the right side header shadow

+/**

+ * Create a Header widget as a child of 'parent'.

+ * @param parent - the parent of the new instance

+ */

+Header(Table parent) {

+	super(parent, SWT.NO_REDRAW_RESIZE | SWT.NO_FOCUS);

+	

+	addListener(SWT.Paint, new Listener() {

+		public void handleEvent(Event event) {paint(event);}

+	});

+	setHeaderHeight();

+}

+/**

+ * Answer the size of the receiver needed to display all items.

+ */

+public Point computeSize(int wHint, int hHint, boolean changed) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	int width = 0;

+	int height = 0;

+

+	for (int i = 0; i < getItemCount(); i++) {

+		width += getBounds(i).width;

+		if (height == 0) {

+			height = getBounds(i).height;

+		}

+	}

+	if (width == 0) {

+		width = DEFAULT_WIDTH;

+	}

+	if (height == 0) {

+		height = DEFAULT_HEIGHT;

+	}

+	if (wHint != SWT.DEFAULT) {

+		width = wHint;

+	}

+	if (hHint != SWT.DEFAULT) {

+		height = hHint;

+	}

+	return new Point(width, height);

+}

+/**

+ * Draw the bright shadow on the upper and left sides of a header item.

+ * @param gc - GC to draw on

+ * @param itemIndex - specifies the item to draw

+ */

+void drawHighlightShadow(GC gc, int itemIndex) {

+	Rectangle bounds = getBounds(itemIndex);

+	Color oldForeground = getForeground();

+

+	gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));	

+	// draw top horizontal line

+	gc.drawLine(bounds.x, bounds.y, bounds.x + bounds.width - 1, bounds.y);

+	// draw left vertical line

+	gc.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height - 1);

+	gc.setForeground(oldForeground);

+}

+/**

+ * Draw the dark shadow on the lower and right side of a header item.

+ * @param gc - GC to draw on

+ * @param itemIndex - specifies the item to draw

+ */

+void drawLowlightShadows(GC gc, int itemIndex) {

+	Rectangle bounds = getBounds(itemIndex);

+	Point bottomShadowStart = new Point(bounds.x + 1, bounds.height - 2);

+	Point bottomShadowStop = new Point(bottomShadowStart.x + bounds.width - 2, bottomShadowStart.y);	

+	Point rightShadowStart = null;

+	Point rightShadowStop = null;

+	Display display = getDisplay();

+	Color oldForeground = getForeground();	

+

+	// light inner shadow

+	gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));

+	gc.drawLine(

+		bottomShadowStart.x, bottomShadowStart.y,

+		bottomShadowStop.x, bottomShadowStop.y);

+	if(itemIndex != TableColumn.FILL) {

+		rightShadowStart = new Point(bounds.x + bounds.width - 2, bounds.y + 1);

+		rightShadowStop = new Point(rightShadowStart.x, bounds.height - 2);

+		gc.drawLine(

+			rightShadowStart.x, rightShadowStart.y,

+			rightShadowStop.x, rightShadowStop.y);

+	}	

+	// dark outer shadow 

+	bottomShadowStart.x--;

+	bottomShadowStart.y++;

+	bottomShadowStop.y++;

+	gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));

+	gc.drawLine(

+		bottomShadowStart.x, bottomShadowStart.y,

+		bottomShadowStop.x, bottomShadowStop.y);

+	if(itemIndex != TableColumn.FILL) {

+		rightShadowStart.x++;

+		rightShadowStart.y--;

+		rightShadowStop.y++;

+		rightShadowStop.x++;	

+		gc.drawLine(

+			rightShadowStart.x, rightShadowStart.y,

+			rightShadowStop.x, rightShadowStop.y);

+	}	

+	gc.setForeground(oldForeground);

+}

+/**

+ * Draw the item text of the item identified by 'itemIndex'.

+ * @param gc - GC to draw on

+ * @param itemIndex - specifies the item to draw

+ */

+void drawText(GC gc, int itemIndex) {

+	String label = getText(gc, itemIndex);

+	Point textExtent;

+	Rectangle bounds = getBounds(itemIndex);

+	int yPosition;

+	int xPosition = 0;

+	int alignment;

+

+	if (label != null) {

+		alignment = ((Table) getParent()).internalGetColumn(itemIndex).getAlignment();

+		textExtent = gc.stringExtent(label);

+		yPosition = bounds.height - textExtent.y - TEXT_Y_OFFSET;

+

+		if ((alignment & SWT.CENTER) != 0) {

+			xPosition = (bounds.width - textExtent.x) / 2;

+		}

+		else

+		if ((alignment & SWT.RIGHT) != 0) {

+			xPosition = bounds.width - textExtent.x - TEXT_MARGIN;

+		}

+		xPosition = Math.max(TEXT_MARGIN, xPosition);

+		xPosition += bounds.x;

+		gc.drawString(label, xPosition, yPosition);

+	}	

+}

+/**

+ * Answer the bounding rectangle of the item identified by 'itemIndex'.

+ * @param itemIndex - specifies the item whose bounding rectangle 

+ *	should be returned.

+ * @return the bouding rectangle of the item identified by 'itemIndex'.

+ */

+Rectangle getBounds(int itemIndex) {

+	Rectangle bounds = null;

+	int itemCount = getItemCount();

+	Table parent = (Table) getParent();

+

+	if (itemIndex >= 0 && itemIndex < itemCount) {

+		bounds = parent.internalGetColumn(itemIndex).getBounds();

+		bounds.y = 0;

+		bounds.height = getBounds().height;

+	}

+	else

+	if (itemIndex == TableColumn.FILL) {

+		if (itemCount > 0) {

+			bounds = parent.internalGetColumn(itemCount - 1).getBounds();

+			bounds.x += bounds.width;

+		}

+		else {

+			bounds = new Rectangle(0, 0, 0, 0);

+		}

+		bounds.width = Math.max(0, getBounds().width - bounds.x);

+		bounds.y = 0;

+		bounds.height = getBounds().height;		

+	}

+	return bounds;

+}

+/**

+ * Answer the number of items in the receiver.

+ */

+int getItemCount() {

+	return ((Table) getParent()).internalGetColumnCount();

+}

+/**

+ * Answer the maximum label width that fits into the item identified by

+ * 'itemIndex'.

+ */

+int getMaxLabelWidth(int itemIndex) {

+	return getBounds(itemIndex).width - 2 * TEXT_MARGIN;	

+}

+/**

+ * Answer the width required to display the complete label of the header 

+ * item at position 'index'.

+ * @param index - position of the header item whose preferred width should 

+ *	be returned.

+ */

+int getPreferredWidth(int index) {

+	Table parent = (Table) getParent();

+	String text = getText(index);

+	int headerWidth = 0;

+

+	if (text != null) {

+		headerWidth = parent.getTextWidth(text) + 2 * TEXT_MARGIN + 1;

+	}	

+	return headerWidth;

+}

+/**

+ * Answer the label of the item identified by 'itemIndex'.

+ */

+String getText(int itemIndex) {

+	String itemLabel = null;

+	

+	if (itemIndex >= 0 && itemIndex < getItemCount()) {

+		itemLabel = ((Table) getParent()).internalGetColumn(itemIndex).getText();

+	}

+	return itemLabel;

+}

+/**

+ * Answer the text that is going to be drawn in the header item 

+ * identified by 'itemIndex'. This may be truncated to fit the item

+ * width.

+ * @param gc - GC to use for measuring the label width.

+ * @param itemIndex - specifies the item whose label should be returned.

+ */

+String getText(GC gc, int itemIndex) {

+	String label = getText(itemIndex);

+	int maxWidth;

+

+	if (label != null) {

+		maxWidth = getMaxLabelWidth(itemIndex);

+		label = ((Table) getParent()).trimItemText(label, maxWidth, gc);

+	}

+	return label;

+}

+/**

+ * Draw the header item identified by 'itemIndex'.

+ * @param gc - GC to draw on

+ * @param itemIndex - item that should be drawn

+ */

+void paint(GC gc, int itemIndex) {

+	Rectangle bounds = getBounds(itemIndex);

+

+	// draw header background

+	gc.fillRectangle(bounds.x, bounds.y + 1, bounds.width, bounds.height - 3);

+	if (itemIndex != TableColumn.FILL) {

+		drawText(gc, itemIndex);

+	}

+	drawHighlightShadow(gc, itemIndex);

+	drawLowlightShadows(gc, itemIndex);	

+}

+/**

+ * Draw all header items.

+ * @param event - Paint event triggering the drawing operation.

+ */

+void paint(Event event) {

+	int labelCount = getItemCount();

+

+	for (int i = 0; i < labelCount; i++) {

+		paint(event.gc, i);

+	}

+	paint(event.gc, TableColumn.FILL);					// paint empty fill item behind last item

+}

+/**

+ * Redraw the item identified by 'itemIndex'.

+ * @param itemIndex - specifies the header item that should be redrawn

+ */

+void redraw(int itemIndex) {

+	Rectangle bounds = getBounds(itemIndex);

+

+	if (bounds != null) {

+		redraw(bounds.x, 0, bounds.width, bounds.height, false);

+	}

+}

+

+/**

+ * Set a new font. Recalculate the header height and redraw the header.

+ */

+public void setFont(Font font) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (font == null || font.equals(getFont()) == true) {

+		return;

+	}

+	super.setFont(font);

+	setHeaderHeight();

+	redraw();

+}

+/**

+ * Calculate and store the height of the receiver.

+ */

+void setHeaderHeight() {

+	GC gc = new GC(this);

+	Rectangle bounds = getBounds();

+

+	bounds.height = gc.stringExtent("aString").y + VERTICAL_MARGIN;

+	setBounds(bounds);

+	gc.dispose();

+}

+/**

+ * The width of the header item at position 'itemIndex' is about to change.

+ * Adjust the width of the header. Scroll and redraw all header items

+ * starting behind the item identified by 'itemIndex'.

+ * @param itemIndex - specifies the item after which the redraw

+ *	should begin.

+ * @param widthDiff - the width change of the item. 

+ *	> 0 = item width increased. < 0 = item width decreased

+ */

+void widthChange(int itemIndex, int widthDiff) {

+	Rectangle bounds = getBounds(itemIndex);

+	Rectangle headerBounds = getBounds();

+	

+	if (bounds != null) {

+		if (itemIndex != TableColumn.FILL) {						// ignore the fill column header item - there's nothing to redraw anyway

+			scroll(

+				bounds.x + bounds.width + widthDiff, 0,				// destination x, y

+				bounds.x + bounds.width, 0,							// source x, y

+				headerBounds.width + widthDiff, headerBounds.height, false);

+			redraw(bounds.x, 0, bounds.width, bounds.height, false);

+		}

+	}

+	headerBounds.width += widthDiff;

+	setBounds(headerBounds);

+}

+

+}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Label.java
index d19a39b..290359e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Label.java
@@ -11,54 +11,54 @@
 import org.eclipse.swt.*;

 import org.eclipse.swt.graphics.*;

 

-/**

- * Instances of this class represent a non-selectable

- * user interface object that displays a string or image.

- * When SEPARATOR is specified, displays a single

- * vertical or horizontal line.

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>SEPARATOR, HORIZONTAL, SHADOW_IN, SHADOW_OUT, VERTICAL</dd>

- * <dd>CENTER, LEFT, RIGHT, WRAP</dd>

- * <dt><b>Events:</b></dt>

- * <dd>(none)</dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is intended to be subclassed <em>only</em>

- * within the SWT implementation.

- * </p>

+/**
+ * Instances of this class represent a non-selectable
+ * user interface object that displays a string or image.
+ * When SEPARATOR is specified, displays a single
+ * vertical or horizontal line.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SEPARATOR, HORIZONTAL, SHADOW_IN, SHADOW_OUT, VERTICAL</dd>
+ * <dd>CENTER, LEFT, RIGHT, WRAP</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
  */

+

 public /*final*/ class Label extends Control {

 	String text = "";

 	Image image, bitmap, disabled;

-

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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

+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <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
+ *
+ * @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 Label (Composite parent, int style) {

 	super (parent, checkStyle (style));

@@ -68,7 +68,8 @@
 	return checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);

 }

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int border = getBorderWidth ();

 	int width = border * 2, height = border * 2;

 	if ((style & SWT.SEPARATOR) != 0) {

@@ -164,22 +165,23 @@
 int defaultForeground () {

 	return getDisplay ().labelForeground;

 }

-/**

- * Returns a value which describes the position of the

- * text or image in the receiver. The value will be one of

- * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>

- * unless the receiver is a <code>SEPARATOR</code> label, in 

- * which case, <code>NONE</code> is returned.

- *

- * @return the alignment 

- *

- * @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 value which describes the position of the
+ * text or image in the receiver. The value will be one of
+ * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
+ * unless the receiver is a <code>SEPARATOR</code> label, in 
+ * which case, <code>NONE</code> is returned.
+ *
+ * @return the alignment 
+ *
+ * @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 getAlignment () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SEPARATOR) != 0) return SWT.LEFT;

 	int [] argList = {OS.XmNalignment, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

@@ -189,38 +191,40 @@
 	if (alignment == OS.XmALIGNMENT_END)return SWT.RIGHT;

 	return SWT.LEFT;

 }

-/**

- * Returns the receiver's image if it has one, or null

- * if it does not.

- *

- * @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>

+/**
+ * Returns the receiver's image if it has one, or null
+ * if it does not.
+ *
+ * @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();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return image;

 }

 String getNameText () {

 	return getText ();

 }

-/**

- * Returns the receiver's text, which will be an empty

- * string if it has never been set or if the receiver is

- * a <code>SEPARATOR</code> label.

- *

- * @return the receiver's text

- *

- * @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 the receiver's text, which will be an empty
+ * string if it has never been set or if the receiver is
+ * a <code>SEPARATOR</code> label.
+ *
+ * @return the receiver's text
+ *
+ * @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 String getText () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SEPARATOR) != 0) return "";

 	return text;

 }

@@ -273,21 +277,22 @@
 	if ((style & (SWT.SHADOW_OUT)) != 0) return OS.XmSHADOW_ETCHED_OUT;

 	return OS.XmSHADOW_ETCHED_IN;

 }

-/**

- * Controls how text and images will be displayed in the receiver.

- * The argument should be one of <code>LEFT</code>, <code>RIGHT</code>

- * or <code>CENTER</code>.  If the receiver is a <code>SEPARATOR</code>

- * label, the argument is ignored and the alignment is not changed.

- *

- * @param alignment the new alignment 

- *

- * @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>

+/**
+ * Controls how text and images will be displayed in the receiver.
+ * The argument should be one of <code>LEFT</code>, <code>RIGHT</code>
+ * or <code>CENTER</code>.  If the receiver is a <code>SEPARATOR</code>
+ * label, the argument is ignored and the alignment is not changed.
+ *
+ * @param alignment the new alignment 
+ *
+ * @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 setAlignment (int alignment) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SEPARATOR) != 0) return;

 	int [] argList = {OS.XmNalignment, OS.XmALIGNMENT_BEGINNING};

 	if ((alignment & SWT.CENTER) != 0) argList [1] = OS.XmALIGNMENT_CENTER;

@@ -307,7 +312,6 @@
 	if (disabled != null) disabled.dispose ();

 	bitmap = disabled = null;

 	if (image != null) {

-		if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 		Display display = getDisplay ();

 		switch (image.type) {

 			case SWT.BITMAP:

@@ -346,47 +350,46 @@
 	super.setFont (font);

 	if ((style & SWT.WRAP) != 0) setText (text);

 }

-/**

- * Sets the receiver's image to the argument, which may be

- * null indicating that no image should be displayed.

- *

- * @param image the image to display on the receiver (may be null)

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the image 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>

+/**
+ * Sets the receiver's image to the argument, which may be
+ * null indicating that no image should be displayed.
+ *
+ * @param image the image to display on the receiver (may be null)
+ *
+ * @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 setImage (Image image) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	setBitmap (this.image = image);

 }

 public void setSize (int width, int height) {

 	super.setSize (width, height);

 	if ((style & SWT.WRAP) != 0) setText (text);

 }

-/**

- * Sets the receiver's text.

- * <p>

- * This method sets the widget label.  The label may include

- * the mnemonic characters and line delimiters.

- * </p>

- * 

- * @param string the new text

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the text 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>

+/**
+ * Sets the receiver's text.
+ * <p>
+ * This method sets the widget label.  The label may include
+ * the mnemonic characters and line delimiters.
+ * </p>
+ * 
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text 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>
  */

 public void setText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if ((style & SWT.SEPARATOR) != 0) return;

 	text = string;

@@ -419,11 +422,11 @@
 		OS.XtGetValues (handle, argList, argList.length / 2);

 		int width = argList [3] - argList [5] - argList [7] - argList [9] * 2 - argList [11] * 2;

 		Display display = getDisplay ();

-		if (mnemonic != 0) string = new String (unicode);

+		if (mnemonic != 0) string = new String(unicode);

 		string = display.wrapText (string, argList [1], width);

-		buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+		buffer = Converter.wcsToMbcs (null, string, true);

 	} else {

-		buffer = Converter.wcsToMbcs (getCodePage (), unicode, true);

+		buffer = Converter.wcsToMbcs (null, unicode, true);

 	}

 	

 	int [] parseTable = getDisplay ().parseTable;

@@ -435,21 +438,8 @@
 		parseTable,

 		parseTable.length,

 		0);

-	if (xmString == 0) error (SWT.ERROR_CANNOT_SET_TEXT);

-		

-	/*

-	* Bug in Solaris.  If a mnemonic is defined to be a character

-	* that appears in a string in a position that follows a '\n',

-	* Solaris segment faults.  For example, a label with text

-	* "Hello\nthe&re" would GP since "r" appears after '\n'.

-	*

-	* The fix is to remove mnemonics from labels that contain

-	* '\n', which is fine since such labels generally just act

-	* as descriptive texts anyways.

-	*/ 

-	if (mnemonic == 0 || string.indexOf ('\n') != -1) {

-		mnemonic = OS.XK_VoidSymbol;

-	}

+	if (xmString == 0) error (SWT.ERROR_CANNOT_SET_TEXT);
+	if (mnemonic == 0) mnemonic = OS.XK_VoidSymbol;

 	int [] argList = {

 		OS.XmNlabelType, OS.XmSTRING,

 		OS.XmNlabelString, xmString,

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/List.java
index ac0d9fe..148b752 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/List.java
@@ -12,51 +12,51 @@
 import org.eclipse.swt.events.*;

 

 

-/** 

- * Instances of this class represent a selectable user interface

- * object that displays a list of strings and issues notificiation

- * when a string selected.  A list may be single or multi select.

- * <p>

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>SINGLE, MULTI</dd>

- * <dt><b>Events:</b></dt>

- * <dd>Selection, DefaultSelection</dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is <em>not</em> intended to be subclassed.

- * </p>

+/** 
+ * Instances of this class represent a selectable user interface
+ * object that displays a list of strings and issues notificiation
+ * when a string selected.  A list may be single or multi select.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SINGLE, MULTI</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, DefaultSelection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
  */

 

 public /*final*/ class List extends Scrollable {

 	int rows, columns;

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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

+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <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
+ *
+ * @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 List (Composite parent, int style) {

 	/**

@@ -68,61 +68,63 @@
 	 */

 	super (parent, checkStyle (style | SWT.V_SCROLL));

 }

-/**

- * Adds the argument to the end of the receiver's list.

- *

- * @param string the new item

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the string 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>

- * @exception SWTError <ul>

- *    <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>

- * </ul>

- *

- * @see #add(String,int)

+/**
+ * Adds the argument to the end of the receiver's list.
+ *
+ * @param string the new item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string 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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ *
+ * @see #add(String,int)
  */

 public void add (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (null, string, true);

 	int xmString = OS.XmStringCreateLocalized (buffer);

 	if (xmString == 0) error (SWT.ERROR_ITEM_NOT_ADDED);

 	OS.XmListAddItemUnselected (handle, xmString, 0);

 	OS.XmStringFree (xmString);

 }

-/**

- * Adds the argument to the receiver's list at the given

- * zero-relative index.

- * <p>

- * Note: To add an item at the end of the list, use the

- * result of calling <code>getItemCount()</code> as the

- * index or use <code>add(String)</code>.

- * </p>

- *

- * @param string the new item

- * @param index the index for the item

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>

- *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</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>

- * @exception SWTError <ul>

- *    <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>

- * </ul>

- *

- * @see #add(String)

+/**
+ * Adds the argument to the receiver's list at the given
+ * zero-relative index.
+ * <p>
+ * Note: To add an item at the end of the list, use the
+ * result of calling <code>getItemCount()</code> as the
+ * index or use <code>add(String)</code>.
+ * </p>
+ *
+ * @param string the new item
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ *
+ * @see #add(String)
  */

 public void add (String string, int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (index == -1) error (SWT.ERROR_INVALID_RANGE);

 	/*

@@ -136,7 +138,7 @@
 	if (!(0 <= index && index <= argList [1])) {

 		error (SWT.ERROR_INVALID_RANGE);

 	}

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (null, string, true);

 	int xmString = OS.XmStringCreateLocalized (buffer);

 	if (xmString == 0) error (SWT.ERROR_ITEM_NOT_ADDED);

 	OS.XmListAddItemUnselected (handle, xmString, index + 1);

@@ -167,7 +169,8 @@
  * @see SelectionEvent

  */

 public void addSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener(listener);

 	addListener(SWT.Selection,typedListener);

@@ -177,7 +180,8 @@
 	return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);

 }

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	XtWidgetGeometry result = new XtWidgetGeometry ();

 	result.request_mode = OS.CWWidth;

 	OS.XtQueryGeometry (handle, null, result);

@@ -206,7 +210,8 @@
 	return new Point (rect.width, rect.height);

 }

 public Rectangle computeTrim (int x, int y, int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	Display display = getDisplay ();

 	int border = getBorderWidth ();

 	int trimX = x - border;

@@ -300,43 +305,45 @@
 int defaultForeground () {

 	return getDisplay ().listForeground;

 }

-/**

- * Deselects the item at the given zero-relative index in the receiver.

- * If the item at the index was already deselected, it remains

- * deselected. Indices that are out of range are ignored.

- *

- * @param index the index of the item to deselect

- *

- * @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>

+/**
+ * Deselects the item at the given zero-relative index in the receiver.
+ * If the item at the index was already deselected, it remains
+ * deselected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to deselect
+ *
+ * @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 deselect (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	/*

 	* Note:  We rely on the fact that XmListDeselectPos ()

 	* fails silently when the indices are out of range.

 	*/

 	if (index != -1) OS.XmListDeselectPos (handle, index + 1);

 }

-/**

- * Deselects the items at the given zero-relative indices in the receiver.

- * If the item at the given zero-relative index in the receiver 

- * is selected, it is deselected.  If the item at the index

- * was not selected, it remains deselected.  The range of the

- * indices is inclusive. Indices that are out of range are ignored.

- *

- * @param start the start index of the items to deselect

- * @param end the end index of the items to deselect

- *

- * @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>

+/**
+ * Deselects the items at the given zero-relative indices in the receiver.
+ * If the item at the given zero-relative index in the receiver 
+ * is selected, it is deselected.  If the item at the index
+ * was not selected, it remains deselected.  The range of the
+ * indices is inclusive. Indices that are out of range are ignored.
+ *
+ * @param start the start index of the items to deselect
+ * @param end the end index of the items to deselect
+ *
+ * @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 deselect (int start, int end) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (start > end) return;

 	/*

 	* Note:  We rely on the fact that XmListDeselectPos ()

@@ -347,25 +354,26 @@
 		if (index != 0) OS.XmListDeselectPos (handle, index);

 	}

 }

-/**

- * Deselects the items at the given zero-relative indices in the receiver.

- * If the item at the given zero-relative index in the receiver 

- * is selected, it is deselected.  If the item at the index

- * was not selected, it remains deselected. Indices that are out

- * of range and duplicate indices are ignored.

- *

- * @param indices the array of indices for the items to deselect

- *

- * @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>

+/**
+ * Deselects the items at the given zero-relative indices in the receiver.
+ * If the item at the given zero-relative index in the receiver 
+ * is selected, it is deselected.  If the item at the index
+ * was not selected, it remains deselected. Indices that are out
+ * of range and duplicate indices are ignored.
+ *
+ * @param indices the array of indices for the items to deselect
+ *
+ * @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>
  */

 public void deselect (int [] indices) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);

 	/*

 	* Note:  We rely on the fact that XmListDeselectPos ()

@@ -376,53 +384,56 @@
 		if (index != 0) OS.XmListDeselectPos (handle, index);

 	}

 }

-/**

- * Deselects all selected items in the receiver.

- *

- * @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>

+/**
+ * Deselects all selected items in the receiver.
+ *
+ * @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 deselectAll () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	OS.XmListDeselectAllItems (handle);

 }

-/**

- * Returns the zero-relative index of the item which is currently

- * has the focus in the receiver, or -1 if no item is has focus.

- *

- * @return the index of the selected item

- *

- * @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 the zero-relative index of the item which is currently
+ * has the focus in the receiver, or -1 if no item is has focus.
+ *
+ * @return the index of the selected item
+ *
+ * @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 getFocusIndex () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return OS.XmListGetKbdItemPos (handle) - 1;

 }

-/**

- * Returns the item at the given, zero-relative index in the

- * receiver. Throws an exception if the index is out of range.

- *

- * @param index the index of the item to return

- * @return the item at the given index

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>

- * @exception SWTError <ul>

- *    <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
  */

 public String getItem (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNitemCount, 0, OS.XmNitems, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	if (!(0 <= index && index < argList [1])) {

@@ -446,43 +457,45 @@
 	byte [] buffer = new byte [length];

 	OS.memmove (buffer, address, length);

 	OS.XtFree (address);

-	return new String (Converter.mbcsToWcs (getCodePage (), buffer));

+	return new String (Converter.mbcsToWcs (null, buffer));

 }

-/**

- * Returns the number of items contained in the receiver.

- *

- * @return the number of items

- *

- * @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>

- * @exception SWTError <ul>

- *    <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
+ * </ul>
  */

 public int getItemCount () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNitemCount, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * Returns the height of the area which would be used to

- * display <em>one</em> of the items in the tree.

- *

- * @return the height of one item

- *

- * @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>

- * @exception SWTError <ul>

- *    <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Returns the height of the area which would be used to
+ * display <em>one</em> of the items in the tree.
+ *
+ * @return the height of one item
+ *
+ * @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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li>
+ * </ul>
  */

 public int getItemHeight () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {

 		OS.XmNlistSpacing, 0,

 		OS.XmNhighlightThickness, 0,

@@ -493,34 +506,34 @@
 	/* Result is from empirical analysis on Linux and AIX */

 	return getFontHeight () + spacing + highlight + 1;

 }

-/**

- * Returns an array of <code>String</code>s which are the items

- * in the receiver. 

- * <p>

- * Note: This is not the actual structure used by the receiver

- * to maintain its list of items, so modifying the array will

- * not affect the receiver. 

- * </p>

- *

- * @return the items in the receiver's list

- *

- * @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>

- * @exception SWTError <ul>

- *    <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>

- *    <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure while getting the item count</li>

- * </ul>

+/**
+ * Returns an array of <code>String</code>s which are the items
+ * in the receiver. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver's list
+ *
+ * @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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
+ *    <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure while getting the item count</li>
+ * </ul>
  */

 public String [] getItems () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNitems, 0, OS.XmNitemCount, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	int items = argList [1], itemCount = argList [3];

 	int [] buffer1 = new int [1];

 	String [] result = new String [itemCount];

-	String codePage = getCodePage ();

 	for (int i=0; i<itemCount; i++) {

 		OS.memmove (buffer1, items, 4);

 		int ptr = buffer1 [0];

@@ -537,39 +550,39 @@
 		byte [] buffer = new byte [length];

 		OS.memmove (buffer, address, length);

 		OS.XtFree (address);

-		result[i] = new String (Converter.mbcsToWcs (codePage, buffer));

+		result[i] = new String (Converter.mbcsToWcs (null, buffer));

 		items += 4;

 	}

 	return result;

 }

-/**

- * Returns an array of <code>String</code>s that are currently

- * selected in the receiver. An empty array indicates that no

- * items are selected.

- * <p>

- * Note: This is not the actual structure used by the receiver

- * to maintain its selection, so modifying the array will

- * not affect the receiver. 

- * </p>

- * @return an array representing the selection

- *

- * @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>

- * @exception SWTError <ul>

- *    <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure while getting the selection</li>

- *    <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>

- * </ul>

+/**
+ * Returns an array of <code>String</code>s that are currently
+ * selected in the receiver. An empty array indicates that no
+ * items are selected.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ * @return an array representing the selection
+ *
+ * @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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure while getting the selection</li>
+ *    <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
+ * </ul>
  */

 public String [] getSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNselectedItems, 0, OS.XmNselectedItemCount, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	int items = argList [1], itemCount = argList [3];

 	int [] buffer1 = new int [1];

 	String [] result = new String [itemCount];

-	String codePage = getCodePage ();

 	for (int i=0; i<itemCount; i++) {

 		OS.memmove (buffer1, items, 4);

 		int ptr = buffer1 [0];

@@ -586,46 +599,48 @@
 		byte [] buffer = new byte [length];

 		OS.memmove (buffer, address, length);

 		OS.XtFree (address);

-		result[i] = new String (Converter.mbcsToWcs (codePage, buffer));

+		result[i] = new String (Converter.mbcsToWcs (null, buffer));

 		items += 4;

 	}

 	return result;

 }

-/**

- * Returns the number of selected items contained in the receiver.

- *

- * @return the number of selected items

- *

- * @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>

- * @exception SWTError <ul>

- *    <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Returns the number of selected items contained in the receiver.
+ *
+ * @return the number of selected items
+ *
+ * @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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
+ * </ul>
  */

 public int getSelectionCount () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNselectedItemCount, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * Returns the zero-relative index of the item which is currently

- * selected in the receiver, or -1 if no item is selected.

- *

- * @return the index of the selected item

- *

- * @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>

- * @exception SWTError <ul>

- *    <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Returns the zero-relative index of the item which is currently
+ * selected in the receiver, or -1 if no item is selected.
+ *
+ * @return the index of the selected item
+ *
+ * @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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</li>
+ * </ul>
  */

 public int getSelectionIndex () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int index = OS.XmListGetKbdItemPos (handle);

 	if (OS.XmListPosSelected (handle, index)) return index - 1;

 	int [] count = new int [1], positions = new int [1];

@@ -637,26 +652,27 @@
 	OS.XtFree (address);

 	return indices [0] - 1;

 }

-/**

- * Returns the zero-relative indices of the items which are currently

- * selected in the receiver.  The array is empty if no items are selected.

- * <p>

- * Note: This is not the actual structure used by the receiver

- * to maintain its selection, so modifying the array will

- * not affect the receiver. 

- * </p>

- * @return the array of indices of the selected items

- *

- * @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>

- * @exception SWTError <ul>

- *    <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Returns the zero-relative indices of the items which are currently
+ * selected in the receiver.  The array is empty if no items are selected.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ * @return the array of indices of the selected items
+ *
+ * @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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</li>
+ * </ul>
  */

 public int [] getSelectionIndices () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] count = new int [1], positions = new int [1];

 	OS.XmListGetSelectedPos (handle, positions, count);

 	int [] result = new int [count [0]];

@@ -665,20 +681,21 @@
 	for (int i=0; i<result.length; i++) --result [i];

 	return result;

 }

-/**

- * Returns the zero-relative index of the item which is currently

- * at the top of the receiver. This index can change when items are

- * scrolled or new items are added or removed.

- *

- * @return the index of the top item

- *

- * @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 the zero-relative index of the item which is currently
+ * at the top of the receiver. This index can change when items are
+ * scrolled or new items are added or removed.
+ *
+ * @return the index of the top item
+ *
+ * @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 getTopIndex () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNtopItemPosition, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1] - 1;

@@ -690,65 +707,67 @@
 	OS.XtAddCallback (handle, OS.XmNextendedSelectionCallback, windowProc, SWT.Selection);

 	OS.XtAddCallback (handle, OS.XmNdefaultActionCallback, windowProc, SWT.DefaultSelection);

 }

-/**

- * Gets the index of an item.

- * <p>

- * The list is searched starting at 0 until an

- * item is found that is equal to the search item.

- * If no item is found, -1 is returned.  Indexing

- * is zero based.

- *

- * @param string the search item

- * @return the index of the item

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the string 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>

+/**
+ * Gets the index of an item.
+ * <p>
+ * The list is searched starting at 0 until an
+ * item is found that is equal to the search item.
+ * If no item is found, -1 is returned.  Indexing
+ * is zero based.
+ *
+ * @param string the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string 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>
  */

 public int indexOf (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (null, string, true);

 	int xmString = OS.XmStringCreateLocalized (buffer);

 	if (xmString == 0) return -1;

 	int index = OS.XmListItemPos (handle, xmString);

 	OS.XmStringFree (xmString);

 	return index - 1;

 }

-/**

- * Searches the receiver's list starting at the given, 

- * zero-relative index until an item is found that is equal

- * to the argument, and returns the index of that item. If

- * no item is found or the starting index is out of range,

- * returns -1.

- *

- * @param string the search item

- * @return the index of the item

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the string 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>

- * @exception SWTError <ul>

- *    <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure while getting the item count</li>

- *    <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>

- * </ul>

+/**
+ * Searches the receiver's list starting at the given, 
+ * zero-relative index until an item is found that is equal
+ * to the argument, and returns the index of that item. If
+ * no item is found or the starting index is out of range,
+ * returns -1.
+ *
+ * @param string the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string 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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure while getting the item count</li>
+ *    <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
+ * </ul>
  */

 public int indexOf (String string, int start) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	int [] argList = {OS.XmNitems, 0, OS.XmNitemCount, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	int items = argList [1], itemCount = argList [3];

 	if (!((0 <= start) && (start < itemCount))) return -1;

-	byte [] buffer1 = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer1 = Converter.wcsToMbcs (null, string, true);

 	int xmString = OS.XmStringCreateLocalized (buffer1);

 	if (xmString == 0) return -1;

 	int index = start;

@@ -763,43 +782,45 @@
 	if (index == itemCount) return -1;

 	return index;

 }

-/**

- * Returns <code>true</code> if the item is selected,

- * and <code>false</code> otherwise.  Indices out of

- * range are ignored.

- *

- * @param index the index of the item

- * @return the visibility state of the item at the index

- *

- * @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 item is selected,
+ * and <code>false</code> otherwise.  Indices out of
+ * range are ignored.
+ *
+ * @param index the index of the item
+ * @return the visibility state of the item at the index
+ *
+ * @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 isSelected (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (index == -1) return false;

 	return OS.XmListPosSelected (handle, index + 1);

 }

-/**

- * Removes the item from the receiver at the given

- * zero-relative index.

- *

- * @param index the index for the item

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>

- * @exception SWTError <ul>

- *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Removes the item from the receiver at the given
+ * zero-relative index.
+ *
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
  */

 public void remove (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (index == -1) error (SWT.ERROR_INVALID_RANGE);

 	/*

 	* Feature in Motif.  An index out of range handled

@@ -814,27 +835,28 @@
 	}

 	OS.XmListDeletePos (handle, index + 1);

 }

-/**

- * Removes the items from the receiver which are

- * between the given zero-relative start and end 

- * indices (inclusive).

- *

- * @param start the start of the range

- * @param end the end of the range

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</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>

- * @exception SWTError <ul>

- *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Removes the items from the receiver which are
+ * between the given zero-relative start and end 
+ * indices (inclusive).
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
  */

 public void remove (int start, int end) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (start > end) return;

 	int count = end - start + 1;

 	/*

@@ -851,29 +873,30 @@
 	OS.XmListDeleteItemsPos (handle, count, start + 1);

 	if (end >= argList [1]) error (SWT.ERROR_INVALID_RANGE);

 }

-/**

- * Searches the receiver's list starting at the first item

- * until an item is found that is equal to the argument, 

- * and removes that item from the list.

- *

- * @param string the item to remove

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>

- *    <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</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>

- * @exception SWTError <ul>

- *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Searches the receiver's list starting at the first item
+ * until an item is found that is equal to the argument, 
+ * and removes that item from the list.
+ *
+ * @param string the item to remove
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
  */

 public void remove (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (null, string, true);

 	int xmString = OS.XmStringCreateLocalized (buffer);

 	if (xmString == 0) error (SWT.ERROR_ITEM_NOT_REMOVED);

 	int index = OS.XmListItemPos (handle, xmString);

@@ -881,25 +904,26 @@
 	if (index == 0) error (SWT.ERROR_INVALID_ARGUMENT);

 	OS.XmListDeletePos (handle, index);

 }

-/**

- * Removes the items from the receiver at the given

- * zero-relative indices.

- *

- * @param indices the array of indices of the items

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>

- * @exception SWTError <ul>

- *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Removes the items from the receiver at the given
+ * zero-relative indices.
+ *
+ * @param indices the array of indices of the items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
  */

 public void remove (int [] indices) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);

 	/*

 	* Feature in Motif.  An index out of range handled

@@ -919,16 +943,17 @@
 	OS.XmListDeletePositions (handle, newIndices, length);

 	if (length < indices.length) error (SWT.ERROR_INVALID_RANGE);

 }

-/**

- * Removes all of the items from the receiver.

- * <p>

- * @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>

+/**
+ * Removes all of the items from the receiver.
+ * <p>
+ * @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 removeAll () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	OS.XmListDeselectAllItems (handle);

 	OS.XmListDeleteAllItems (handle);

 	/*

@@ -941,44 +966,46 @@
 	*/

 	if ((style & SWT.H_SCROLL) != 0) OS.XtResizeWindow (handle);

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the receiver's selection changes.

- *

- * @param listener the listener which should no longer 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 SelectionListener

- * @see #addSelectionListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's selection changes.
+ *
+ * @param listener the listener which should no longer 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 SelectionListener
+ * @see #addSelectionListener
  */

 public void removeSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook(SWT.Selection, listener);

 	eventTable.unhook(SWT.DefaultSelection,listener);	

 }

-/**

- * Selects the item at the given zero-relative index in the receiver's 

- * list.  If the item at the index was already selected, it remains

- * selected. Indices that are out of range are ignored.

- *

- * @param index the index of the item to select

- *

- * @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>

+/**
+ * Selects the item at the given zero-relative index in the receiver's 
+ * list.  If the item at the index was already selected, it remains
+ * selected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to select
+ *
+ * @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 select (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (index == -1) return; 

 	if (OS.XmListPosSelected (handle, index + 1)) return;

 	/*

@@ -1006,22 +1033,23 @@
 		OS.XtSetValues (handle, argList, argList.length / 2);

 	}

 }

-/**

- * Selects the items at the given zero-relative indices in the receiver.

- * If the item at the index was already selected, it remains

- * selected. The range of the indices is inclusive. Indices that are

- * out of range are ignored.

- *

- * @param start the start of the range

- * @param end the end of the range

- *

- * @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>

+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * If the item at the index was already selected, it remains
+ * selected. The range of the indices is inclusive. Indices that are
+ * out of range are ignored.
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @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 select (int start, int end) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (start > end) return;

 	if ((style & SWT.SINGLE) != 0) {

 		int [] argList = {OS.XmNitemCount, 0};

@@ -1060,25 +1088,26 @@
 		OS.XtSetValues (handle, argList, argList.length / 2);

 	}

 }

-/**

- * Selects the items at the given zero-relative indices in the receiver.

- * If the item at the given zero-relative index in the receiver 

- * is not selected, it is selected.  If the item at the index

- * was selected, it remains selected. Indices that are out

- * of range and duplicate indices are ignored.

- *

- * @param indices the array of indices for the items to select

- *

- * @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>

+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * If the item at the given zero-relative index in the receiver 
+ * is not selected, it is selected.  If the item at the index
+ * was selected, it remains selected. Indices that are out
+ * of range and duplicate indices are ignored.
+ *
+ * @param indices the array of indices for the items to select
+ *
+ * @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>
  */

 public void select (int [] indices) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if ((style & SWT.SINGLE) != 0) {

 		int [] argList = {OS.XmNitemCount, 0};

@@ -1124,12 +1153,12 @@
 	}

 }

 void select (String [] items) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] table = new int [items.length];

-	String codePage = getCodePage ();

 	for (int i=0; i<items.length; i++) {

 		String string = items [i];

-		byte [] buffer = Converter.wcsToMbcs (codePage, string, true);

+		byte [] buffer = Converter.wcsToMbcs (null, string, true);

 		int xmString = OS.XmStringCreateLocalized (buffer);

 		table [i] = xmString;

 	}

@@ -1141,16 +1170,17 @@
 	OS.XtFree (ptr);

 	OS.XmListUpdateSelectedList (handle);

 }

-/**

- * Selects all the items in the receiver.

- *

- * @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>

+/**
+ * Selects all the items in the receiver.
+ *
+ * @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 selectAll () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SINGLE) != 0) return;

 	/*

 	* Feature in MOTIF.  The X/MOTIF 1.2 spec says that XmListSelectPos ()

@@ -1215,29 +1245,30 @@
 void setFocusIndex (int index) {

 	OS.XmListSetKbdItemPos (handle, index + 1);

 }

-/**

- * Sets the text of the item in the receiver's list at the given

- * zero-relative index to the string argument. This is equivalent

- * to <code>remove</code>'ing the old item at the index, and then

- * <code>add</code>'ing the new item at that index.

- *

- * @param index the index for the item

- * @param string the new text for the item

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>

- * @exception SWTError <ul>

- *    <li>ERROR_ITEM_NOT_REMOVED - if the remove operation fails because of an operating system failure</li>

- *    <li>ERROR_ITEM_NOT_ADDED - if the add operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Sets the text of the item in the receiver's list at the given
+ * zero-relative index to the string argument. This is equivalent
+ * to <code>remove</code>'ing the old item at the index, and then
+ * <code>add</code>'ing the new item at that index.
+ *
+ * @param index the index for the item
+ * @param string the new text for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_ITEM_NOT_REMOVED - if the remove operation fails because of an operating system failure</li>
+ *    <li>ERROR_ITEM_NOT_ADDED - if the add operation fails because of an operating system failure</li>
+ * </ul>
  */

 public void setItem (int index, String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (index == -1) error (SWT.ERROR_INVALID_RANGE);

 	int [] argList = {OS.XmNitemCount, 0};

@@ -1245,7 +1276,7 @@
 	if (!(0 <= index && index < argList [1])) {

 		error (SWT.ERROR_INVALID_RANGE);

 	}

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (null, string, true);

 	int xmString = OS.XmStringCreateLocalized (buffer);

 	if (xmString == 0) error (SWT.ERROR_ITEM_NOT_ADDED);

 	boolean isSelected = OS.XmListPosSelected (handle, index + 1);

@@ -1253,21 +1284,22 @@
 	if (isSelected) OS.XmListSelectPos (handle, index + 1, false);

 	OS.XmStringFree (xmString);

 }

-/**

- * Sets the receiver's items to be the given array of items.

- *

- * @param items the array of items

- *

- * @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>

- * @exception SWTError <ul>

- *    <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>

- * </ul>

+/**
+ * Sets the receiver's items to be the given array of items.
+ *
+ * @param items the array of items
+ *
+ * @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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
+ * </ul>
  */

 public void setItems (String [] items) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (items == null) error (SWT.ERROR_NULL_ARGUMENT);

 	/*

 	* Bug in AIX.  When all list items are replaced

@@ -1285,11 +1317,10 @@
 	}

 	int index = 0;

 	int [] table = new int [items.length];

-	String codePage = getCodePage ();

 	while (index < items.length) {

 		String string = items [index];

 		if (string == null) break; 

-		byte [] buffer = Converter.wcsToMbcs (codePage, string, true);

+		byte [] buffer = Converter.wcsToMbcs (null, string, true);

 		int xmString = OS.XmStringCreateLocalized (buffer);

 		if (xmString == 0) break;

 		table [index++] = xmString;

@@ -1310,92 +1341,92 @@
 	}

 	if (index < items.length) error (SWT.ERROR_ITEM_NOT_ADDED);

 }

-/**

- * Selects the item at the given zero-relative index in the receiver. 

- * If the item at the index was already selected, it remains selected.

- * The current selected is first cleared, then the new items are selected.

- * Indices that are out of range are ignored.

- *

- * @param index the index of the item to select

- *

- * @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 List#deselectAll()

- * @see List#select(int)

+/**
+ * Selects the item at the given zero-relative index in the receiver. 
+ * If the item at the index was already selected, it remains selected.
+ * The current selected is first cleared, then the new items are selected.
+ * Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to select
+ *
+ * @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 List#deselectAll()
+ * @see List#select(int)
  */

 public void setSelection (int index) {

 	if ((style & SWT.MULTI) != 0) deselectAll ();

 	select (index);

 }

-/**

- * Selects the items at the given zero-relative indices in the receiver. 

- * The current selected if first cleared, then the new items are selected.

- *

- * @param start the start index of the items to select

- * @param end the end index of the items to select

- *

- * @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 Table#deselectAll()

- * @see Table#select(int,int)

+/**
+ * Selects the items at the given zero-relative indices in the receiver. 
+ * The current selected if first cleared, then the new items are selected.
+ *
+ * @param start the start index of the items to select
+ * @param end the end index of the items to select
+ *
+ * @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 Table#deselectAll()
+ * @see Table#select(int,int)
  */

 public void setSelection (int start, int end) {

 	if ((style & SWT.MULTI) != 0) deselectAll ();

 	select (start, end);

 }

-/**

- * Selects the items at the given zero-relative indices in the receiver. 

- * The current selected of first cleared, then the new items are selected.

- *

- * @param indices the indices of the items to select

- *

- * @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 List#deselectAll()

- * @see List#select(int[])

+/**
+ * Selects the items at the given zero-relative indices in the receiver. 
+ * The current selected of first cleared, then the new items are selected.
+ *
+ * @param indices the indices of the items to select
+ *
+ * @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 List#deselectAll()
+ * @see List#select(int[])
  */

 public void setSelection(int[] indices) {

 	if ((style & SWT.MULTI) != 0) deselectAll ();

 	select (indices);

 }

-/**

- * Sets the receiver's selection to be the given array of items.

- * The current selected is first cleared, then the new items are

- * selected.

- *

- * @param items the array of items

- *

- * @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 List#deselectAll()

- * @see List#select(int)

+/**
+ * Sets the receiver's selection to be the given array of items.
+ * The current selected is first cleared, then the new items are
+ * selected.
+ *
+ * @param items the array of items
+ *
+ * @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 List#deselectAll()
+ * @see List#select(int)
  */

 public void setSelection (String [] items) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (items == null) error (SWT.ERROR_NULL_ARGUMENT);

-	String codePage = getCodePage ();

 	if ((style & SWT.SINGLE) != 0) {

 		for (int i=items.length-1; i>=0; --i) {

 			String string = items [i];

 			if (string != null) {

-				byte [] buffer = Converter.wcsToMbcs (codePage, string, true);

+				byte [] buffer = Converter.wcsToMbcs (null, string, true);

 				int xmString = OS.XmStringCreateLocalized (buffer);

 				if (xmString != 0) {

 					int index = OS.XmListItemPos (handle, xmString);

@@ -1414,7 +1445,7 @@
 	for (int i=0; i<items.length; i++) {

 		String string = items [i];

 		if (string != null) {

-			byte [] buffer = Converter.wcsToMbcs (codePage, string, true);

+			byte [] buffer = Converter.wcsToMbcs (null, string, true);

 			int xmString = OS.XmStringCreateLocalized (buffer);

 			if (xmString != 0) table [length++] = xmString;

 		}

@@ -1461,20 +1492,21 @@
 	OS.XtResizeWidget (scrolledHandle, argList [1] + 1, argList [3], argList [5]);

 	OS.XtResizeWidget (scrolledHandle, argList [1], argList [3], argList [5]);

 }

-/**

- * Sets the zero-relative index of the item which is currently

- * at the top of the receiver. This index can change when items

- * are scrolled or new items are added and removed.

- *

- * @param index the index of the top item

- *

- * @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>

+/**
+ * Sets the zero-relative index of the item which is currently
+ * at the top of the receiver. This index can change when items
+ * are scrolled or new items are added and removed.
+ *
+ * @param index the index of the top item
+ *
+ * @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 setTopIndex (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNitemCount, 0, OS.XmNvisibleItemCount, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	int newIndex = Math.max (1, Math.min (index + 1, argList [1]));

@@ -1482,21 +1514,22 @@
 	if (newIndex > lastIndex) newIndex = lastIndex;

 	OS.XmListSetPos (handle, newIndex);

 }

-/**

- * Shows the selection.  If the selection is already showing in the receiver,

- * this method simply returns.  Otherwise, the items are scrolled until

- * the selection is visible.

- *

- * @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>

+/**
+ * Shows the selection.  If the selection is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled until
+ * the selection is visible.
+ *
+ * @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>
  */

 public void showSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] buffer = new int [1], positions = new int [1];

 	if (!OS.XmListGetSelectedPos (handle, positions, buffer)) return;

 	if (buffer [0] == 0) return;

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Menu.java
index 04bc251..38ef27e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Menu.java
@@ -9,18 +9,18 @@
 import org.eclipse.swt.*;

 import org.eclipse.swt.events.*;

 

-/**

- * Instances of this class are user interface objects that contain

- * menu items.

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>BAR, DROP_DOWN, POP_UP</dd>

- * <dt><b>Events:</b></dt>

- * <dd>Help, Hide, Show </dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is <em>not</em> intended to be subclassed.

- * </p>

+/**
+ * Instances of this class are user interface objects that contain
+ * menu items.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BAR, DROP_DOWN, POP_UP</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Help, Hide, Show </dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
  */

 public /*final*/ class Menu extends Widget {

 	boolean hasLocation;

@@ -52,52 +52,54 @@
 public Menu (MenuItem parentItem) {

 	this (checkNull(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>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) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Help, 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>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

+/**
+ * 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) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener(SWT.Hide,typedListener);

@@ -188,20 +190,21 @@
 	super.createWidget (index);

 	parent.add (this);

 }

-/**

- * Returns the default menu item or null if none has

- * been previously set.

- *

- * @return the default menu item.

- *

- * </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>

+/**
+ * Returns the default menu item or null if none has
+ * been previously set.
+ *
+ * @return the default menu item.
+ *
+ * </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>
  */

 public MenuItem getDefaultItem () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return defaultItem;

 }

 public Display getDisplay () {

@@ -209,42 +212,44 @@
 	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

- * not selectable from the user interface and draws with an

- * inactive or "grayed" look.

- *

- * @return the receiver's enabled 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 enabled, and
+ * <code>false</code> otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @return the receiver's enabled 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 getEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNsensitive, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1] != 0;

 }

-/**

- * Returns the item at the given, zero-relative index in the

- * receiver. Throws an exception if the index is out of range.

- *

- * @param index the index of the item to return

- * @return the item at the given index

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>

+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>
  */

 public MenuItem getItem (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNchildren, 0, OS.XmNnumChildren, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	if (argList [1] == 0) error (SWT.ERROR_CANNOT_GET_ITEM);

@@ -263,18 +268,19 @@
 	if (!(widget instanceof MenuItem)) error (SWT.ERROR_CANNOT_GET_ITEM);

 	return (MenuItem) widget;

 }

-/**

- * Returns the number of items contained in the receiver.

- *

- * @return the number of items

- *

- * @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 the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @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 getItemCount () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNchildren, 0, OS.XmNnumChildren, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	if (argList [1] == 0 || argList [3] == 0) return 0;

@@ -286,24 +292,25 @@
 	}

 	return count;	

 }

-/**

- * Returns an array of <code>MenuItem</code>s which are the items

- * in the receiver. 

- * <p>

- * Note: This is not the actual structure used by the receiver

- * to maintain its list of items, so modifying the array will

- * not affect the receiver. 

- * </p>

- *

- * @return the items in the receiver

- *

- * @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 an array of <code>MenuItem</code>s which are the items
+ * in the receiver. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @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 MenuItem [] getItems () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNchildren, 0, OS.XmNnumChildren, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	int ptr = argList [1], count = argList [3];

@@ -334,91 +341,96 @@
 	}

 	return result;

 }

-/**

- * Returns the receiver's parent, which must be a <code>Decorations</code>.

- *

- * @return the receiver's parent

- *

- * @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 the receiver's parent, which must be a <code>Decorations</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @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 Decorations getParent () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent;

 }

-/**

- * Returns the receiver's parent item, which must be a

- * <code>MenuItem</code> or null when the receiver is a

- * root.

- *

- * @return the receiver's parent item

- *

- * @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 the receiver's parent item, which must be a
+ * <code>MenuItem</code> or null when the receiver is a
+ * root.
+ *
+ * @return the receiver's parent item
+ *
+ * @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 MenuItem getParentItem () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return cascade;

 }

-/**

- * Returns the receiver's parent item, which must be a

- * <code>Menu</code> or null when the receiver is a

- * root.

- *

- * @return the receiver's parent item

- *

- * @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 the receiver's parent item, which must be a
+ * <code>Menu</code> or null when the receiver is a
+ * root.
+ *
+ * @return the receiver's parent item
+ *
+ * @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 Menu getParentMenu () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (cascade != null) return cascade.parent;

 	return null;

 }

-/**

- * Returns the receiver's shell. For all controls other than

- * shells, this simply returns the control's nearest ancestor

- * shell. Shells return themselves, even if they are children

- * of other shells.

- *

- * @return the receiver's shell

- *

- * @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 #getParent

+/**
+ * Returns the receiver's shell. For all controls other than
+ * shells, this simply returns the control's nearest ancestor
+ * shell. Shells return themselves, even if they are children
+ * of other shells.
+ *
+ * @return the receiver's shell
+ *
+ * @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 #getParent
  */

 public Shell getShell () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent.getShell ();

 }

-/**

- * Returns <code>true</code> if the receiver is visible, and

- * <code>false</code> otherwise.

- * <p>

- * If one of the receiver's ancestors is not visible or some

- * other condition makes the receiver not visible, this method

- * may still indicate that it is considered visible even though

- * it may not actually be showing.

- * </p>

- *

- * @return the receiver's visibility 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 visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility 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 getVisible () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return OS.XtIsManaged (handle);

 }

 void hookEvents () {

@@ -427,25 +439,26 @@
 	OS.XtAddCallback (handle, OS.XmNmapCallback, windowProc, SWT.Show);

 	OS.XtAddCallback (handle, OS.XmNunmapCallback, windowProc, SWT.Hide);

 }

-/**

- * Searches the receiver's list starting at the first item

- * (index 0) until an item is found that is equal to the 

- * argument, and returns the index of that item. If no item

- * is found, returns -1.

- *

- * @param item the search item

- * @return the index of the item

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the string 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>

+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param item the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string 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>
  */

 public int indexOf (MenuItem item) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNchildren, 0, OS.XmNnumChildren, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	int [] handles = new int [argList [3]];

@@ -459,44 +472,46 @@
 	}

 	return -1;

 }

-/**

- * Returns <code>true</code> if the receiver is enabled, and

- * <code>false</code> otherwise. A disabled control is typically

- * not selectable from the user interface and draws with an

- * inactive or "grayed" look.

- *

- * @return the receiver's enabled 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 enabled, and
+ * <code>false</code> otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @return the receiver's enabled 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 isEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	Menu parentMenu = getParentMenu ();

 	if (parentMenu == null) return getEnabled ();

 	return getEnabled () && parentMenu.isEnabled ();

 }

-/**

- * Returns <code>true</code> if the receiver is visible, and

- * <code>false</code> otherwise.

- * <p>

- * If one of the receiver's ancestors is not visible or some

- * other condition makes the receiver not visible, this method

- * may still indicate that it is considered visible even though

- * it may not actually be showing.

- * </p>

- *

- * @return the receiver's visibility 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 visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility 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 isVisible () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return getVisible ();

 }

 int processHelp (int callData) {

@@ -549,48 +564,50 @@
 	parent = null;

 	cascade = defaultItem = null;

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the help events are generated for the control.

- *

- * @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 #addHelpListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the help events are generated for the control.
+ *
+ * @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 #addHelpListener
  */

 public void removeHelpListener (HelpListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Help, listener);

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the menu events are generated for the control.

- *

- * @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 #addMenuListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the menu events are generated for the control.
+ *
+ * @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 #addMenuListener
  */

 public void removeMenuListener(MenuListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook(SWT.Hide, listener);

@@ -603,84 +620,84 @@
 	}

 	parent.sendHelpEvent (callData);

 }

-/**

- * Sets the default menu item to the argument or removes

- * the default emphasis when the argument is <code>null</code>.

- * 

- * @param item the default menu item or null

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the menu item 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>

+/**
+ * Sets the default menu item to the argument or removes
+ * the default emphasis when the argument is <code>null</code>.
+ * 
+ * @param item the default menu item or null
+ *
+ * @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 setDefaultItem (MenuItem item) {

-	checkWidget();

-	if (item != null && item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	defaultItem = item;

 }

-/**

- * Enables the receiver if the argument is <code>true</code>,

- * and disables it otherwise. A disabled control is typically

- * not selectable from the user interface and draws with an

- * inactive or "grayed" look.

- *

- * @param enabled the new enabled 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>

+/**
+ * Enables the receiver if the argument is <code>true</code>,
+ * and disables it otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @param enabled the new enabled 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 void setEnabled (boolean enabled) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNsensitive, enabled ? 1 : 0};

 	OS.XtSetValues (handle, argList, argList.length / 2);

 }

-/**

- * Sets the receiver's location to the point specified by

- * the arguments which are relative to the display.

- * <p>

- * Note:  This is different from most widgets where the

- * location of the widget is relative to the parent.

- * </p>

- *

- * @param x the new x coordinate for the receiver

- * @param y the new y coordinate for the receiver

- *

- * @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>

- */

+/**
+ * Sets the receiver's location to the point specified by
+ * the arguments which are relative to the display.
+ * <p>
+ * Note:  This is different from most widgets where the
+ * location of the widget is relative to the parent.
+ * </p>
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ *
+ * @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 setLocation (int x, int y) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;

 	int [] argList = {OS.XmNx, x, OS.XmNy, y};

 	OS.XtSetValues (handle, argList, argList.length / 2);

 	hasLocation = true;

 }

-/**

- * Marks the receiver as visible if the argument is <code>true</code>,

- * and marks it invisible otherwise. 

- * <p>

- * If one of the receiver's ancestors is not visible or some

- * other condition makes the receiver not visible, marking

- * it visible may not actually cause it to be displayed.

- * </p>

- *

- * @param visible the new visibility 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>

+/**
+ * Marks the receiver as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility 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 void setVisible (boolean visible) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;

 	if (visible) {

 		if (!hasLocation) {

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MenuItem.java
index 94e897b..9240431 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MenuItem.java
@@ -11,143 +11,87 @@
 import org.eclipse.swt.graphics.*;

 import org.eclipse.swt.events.*;

 

-/**

- * Instances of this class represent a selectable user interface object

- * that issues notification when pressed and released. 

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>CHECK, CASCADE, PUSH, RADIO, SEPARATOR</dd>

- * <dt><b>Events:</b></dt>

- * <dd>Arm, Help, Selection</dd>

- * </dl>

- *<p>

- * IMPORTANT: This class is <em>not</em> intended to be subclassed.

- * </p>

+/**
+ * Instances of this class represent a selectable user interface object
+ * that issues notification when pressed and released. 
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>CHECK, CASCADE, PUSH, RADIO, SEPARATOR</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Arm, Help, Selection</dd>
+ * </dl>
+ *<p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
  */

 public /*final*/ class MenuItem extends Item {

 	int accelerator;

 	Menu parent, menu;

-

 /**

- * Constructs a new instance of this class given its parent

- * (which must be a <code>Menu</code>) and a style value

- * describing its behavior and appearance. The item is added

- * to the end of 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

- *

- * @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

- */

+* Creates a new instance of the widget.

+*/

 public MenuItem (Menu parent, int style) {

 	super (parent, checkStyle (style));

 	this.parent = parent;

 	createWidget (OS.XmLAST_POSITION);

 }

-

 /**

- * Constructs a new instance of this class given its parent

- * (which must be a <code>Menu</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

- */

+* Creates a new instance of the widget.

+*/

 public MenuItem (Menu parent, int style, int index) {

 	super (parent, checkStyle (style));

 	this.parent = parent;

 	if (index == OS.XmLAST_POSITION) error (SWT.ERROR_INVALID_RANGE);

 	createWidget (index);

 }

-

-/**

- * Adds the listener to the collection of listeners who will

- * be notified when the arm events are generated for the control, by sending

- * it one of the messages defined in the <code>ArmListener</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 ArmListener

- * @see #removeArmListener

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the arm events are generated for the control, by sending
+ * it one of the messages defined in the <code>ArmListener</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 ArmListener
+ * @see #removeArmListener
  */

 public void addArmListener (ArmListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Arm, 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) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Help, typedListener);

@@ -177,7 +121,8 @@
  * @see SelectionEvent

  */

 public void addSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener(listener);

 	addListener(SWT.Selection,typedListener);

@@ -249,21 +194,22 @@
 	OS.XtUnmanageChild (handle);

 	super.destroyWidget ();

 }

-/**

- * Return the widget accelerator.  An accelerator is the bit-wise

- * OR of zero or more modifier masks and a key. Examples:

- * <code>SWT.CONTROL | SWT.SHIFT | 'T', SWT.ALT | SWT.F2</code>.

- *

- * @return the accelerator

- *

- * </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>

+/**
+ * Return the widget accelerator.  An accelerator is the bit-wise
+ * OR of zero or more modifier masks and a key. Examples:
+ * <code>SWT.CONTROL | SWT.SHIFT | 'T', SWT.ALT | SWT.F2</code>.
+ *
+ * @return the accelerator
+ *
+ * </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>
  */

 public int getAccelerator () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return accelerator;

 }

 public Display getDisplay () {

@@ -271,77 +217,81 @@
 	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

- * not selectable from the user interface and draws with an

- * inactive or "grayed" look.

- *

- * @return the receiver's enabled 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 enabled, and
+ * <code>false</code> otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @return the receiver's enabled 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 getEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNsensitive, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1] != 0;

 }

-/**

- * Returns the receiver's cascade menu if it has one or null

- * if it does not. Only <code>CASCADE</code> menu items can have

- * a pull down menu. The sequence of key strokes, button presses 

- * and/or button releases that are used to request a pull down

- * menu is platform specific.

- *

- * @return the receiver's menu

- *

- * @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 the receiver's cascade menu if it has one or null
+ * if it does not. Only <code>CASCADE</code> menu items can have
+ * a pull down menu. The sequence of key strokes, button presses 
+ * and/or button releases that are used to request a pull down
+ * menu is platform specific.
+ *
+ * @return the receiver's menu
+ *
+ * @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 Menu getMenu () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return menu;

 }

 String getNameText () {

 	if ((style & SWT.SEPARATOR) != 0) return "|";

 	return super.getNameText ();

 }

-/**

- * Returns the receiver's parent, which must be a <code>Menu</code>.

- *

- * @return the receiver's parent

- *

- * @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 the receiver's parent, which must be a <code>Menu</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @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 Menu getParent () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent;

 }

-/**

- * Returns <code>true</code> if the receiver is selected,

- * and false otherwise.

- * <p>

- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,

- * it is selected when it is checked.

- *

- * @return the selection 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 selected,
+ * and false otherwise.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked.
+ *
+ * @return the selection 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 getSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return false;

 	int [] argList = {OS.XmNset, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

@@ -353,12 +303,13 @@
 * delimiters.

 */

 String getText2 () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.ARROW) != 0) return "";

 	int [] argList = {OS.XmNlabelString, 0, OS.XmNmnemonic, 0, OS.XmNacceleratorText, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

-	int xmString1 = argList [1], xmString2 = argList [5];

-	int mnemonic = argList [3];

+	int xmString1 = argList [1], xmString2 = argList [5];
+	int mnemonic = argList [3];
 	if (mnemonic == OS.XK_VoidSymbol) mnemonic = 0;

 	if (xmString1 == 0) error (SWT.ERROR_CANNOT_GET_TEXT);

 	char [] result = null;	

@@ -375,7 +326,6 @@
 		byte [] buffer = new byte [length];

 		OS.memmove (buffer, address, length);

 		OS.XtFree (address);

-		/* Use the character encoding for the default locale */

 		result = Converter.mbcsToWcs (null, buffer);

 	}

 	String accelText = "";

@@ -394,7 +344,6 @@
 			byte [] buffer = new byte [length];

 			OS.memmove (buffer, address, length);

 			OS.XtFree (address);

-			/* Use the character encoding for the default locale */

 			accelText = '\t' + new String (Converter.mbcsToWcs (null, buffer));

 		}

 	}

@@ -435,18 +384,18 @@
 		OS.XtAddCallback (handle, OS.XmNactivateCallback, windowProc, SWT.Selection);

 	}

 }

-/**

- * Returns <code>true</code> if the receiver is enabled, and

- * <code>false</code> otherwise. A disabled control is typically

- * not selectable from the user interface and draws with an

- * inactive or "grayed" look.

- *

- * @return the receiver's enabled 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 enabled, and
+ * <code>false</code> otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @return the receiver's enabled 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 isEnabled () {

 	return getEnabled ();

@@ -468,7 +417,6 @@
 	int length = OS.strlen (ptr);

 	byte [] buffer = new byte [length];

 	OS.memmove (buffer, ptr, buffer.length);

-	/* Use the character encoding for the default locale */

 	return new String (Converter.mbcsToWcs (null, buffer));

 }

 void manageChildren () {

@@ -486,28 +434,28 @@
 	parent.sendHelpEvent (callData);

 	return 0;

 }

-int processSelection (int callData) {

-	XmAnyCallbackStruct struct = new XmAnyCallbackStruct ();

-	OS.memmove (struct, callData, XmAnyCallbackStruct.sizeof);

-	Event event = new Event ();

-	if (struct.event != 0) {

-		XButtonEvent xEvent = new XButtonEvent ();

-		OS.memmove (xEvent, struct.event, XAnyEvent.sizeof);

-		event.time = xEvent.time;

-		switch (xEvent.type) {

-			case OS.ButtonPress:

-			case OS.ButtonRelease:

-			case OS.KeyPress:

-			case OS.KeyRelease:

-				if ((xEvent.state & OS.Mod1Mask) != 0) event.stateMask |= SWT.ALT;

-				if ((xEvent.state & OS.ShiftMask) != 0) event.stateMask |= SWT.SHIFT;

-				if ((xEvent.state & OS.ControlMask) != 0) event.stateMask |= SWT.CONTROL;

-				if ((xEvent.state & OS.Button1Mask) != 0) event.stateMask |= SWT.BUTTON1;

-				if ((xEvent.state & OS.Button2Mask) != 0) event.stateMask |= SWT.BUTTON2;

-				if ((xEvent.state & OS.Button3Mask) != 0) event.stateMask |= SWT.BUTTON3;

-		}

-	}

-	postEvent (SWT.Selection, event);

+int processSelection (int callData) {
+	XmAnyCallbackStruct struct = new XmAnyCallbackStruct ();
+	OS.memmove (struct, callData, XmAnyCallbackStruct.sizeof);
+	Event event = new Event ();
+	if (struct.event != 0) {
+		XButtonEvent xEvent = new XButtonEvent ();
+		OS.memmove (xEvent, struct.event, XAnyEvent.sizeof);
+		event.time = xEvent.time;
+		switch (xEvent.type) {
+			case OS.ButtonPress:
+			case OS.ButtonRelease:
+			case OS.KeyPress:
+			case OS.KeyRelease:
+				if ((xEvent.state & OS.Mod1Mask) != 0) event.stateMask |= SWT.ALT;
+				if ((xEvent.state & OS.ShiftMask) != 0) event.stateMask |= SWT.SHIFT;
+				if ((xEvent.state & OS.ControlMask) != 0) event.stateMask |= SWT.CONTROL;
+				if ((xEvent.state & OS.Button1Mask) != 0) event.stateMask |= SWT.BUTTON1;
+				if ((xEvent.state & OS.Button2Mask) != 0) event.stateMask |= SWT.BUTTON2;
+				if ((xEvent.state & OS.Button3Mask) != 0) event.stateMask |= SWT.BUTTON3;
+		}
+	}
+	postEvent (SWT.Selection, event);
 	return 0;

 }

 void releaseChild () {

@@ -528,91 +476,95 @@
 	}

 	parent = null;

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the arm events are generated for the control.

- *

- * @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 ArmListener

- * @see #addArmListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the arm events are generated for the control.
+ *
+ * @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 ArmListener
+ * @see #addArmListener
  */

 public void removeArmListener (ArmListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Arm, listener);

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the help events are generated for the control.

- *

- * @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 #addHelpListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the help events are generated for the control.
+ *
+ * @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 #addHelpListener
  */

 public void removeHelpListener (HelpListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Help, listener);

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the control is selected.

- *

- * @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 SelectionListener

- * @see #addSelectionListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected.
+ *
+ * @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 SelectionListener
+ * @see #addSelectionListener
  */

 public void removeSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook(SWT.Selection, listener);

 	eventTable.unhook(SWT.DefaultSelection,listener);	

 }

-/**

- * Sets the widget accelerator.  An accelerator is the bit-wise

- * OR of zero or more modifier masks and a key. Examples:

- * <code>SWT.CONTROL | SWT.SHIFT | 'T', SWT.ALT | SWT.F2</code>.

- *

- * @param accelerator an integer that is the bit-wise OR of masks and a key

- *

- * </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>

+/**
+ * Sets the widget accelerator.  An accelerator is the bit-wise
+ * OR of zero or more modifier masks and a key. Examples:
+ * <code>SWT.CONTROL | SWT.SHIFT | 'T', SWT.ALT | SWT.F2</code>.
+ *
+ * @param accelerator an integer that is the bit-wise OR of masks and a key
+ *
+ * </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>
  */

 public void setAccelerator (int accelerator) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	this.accelerator = accelerator;

 	int ptr = 0;

 	if (accelerator != 0) {

@@ -629,8 +581,7 @@
 			keysym = wcsToMbcs ((char) keysym);

 		}

 		String key = "<Key>" + keysymName (keysym);

-		/* Use the character encoding for the default locale */

-		byte [] buffer = Converter.wcsToMbcs (null, ctrl + alt + shift + key, true);		

+		byte [] buffer = Converter.wcsToMbcs (null, ctrl + alt + shift + key, true);

 		ptr = OS.XtMalloc (buffer.length);

 		if (ptr != 0) OS.memmove (ptr, buffer, buffer.length);

 	}

@@ -638,52 +589,53 @@
 	OS.XtSetValues (handle, argList, argList.length / 2);

 	if (ptr != 0) OS.XtFree (ptr);

 }

-/**

- * Enables the receiver if the argument is <code>true</code>,

- * and disables it otherwise. A disabled control is typically

- * not selectable from the user interface and draws with an

- * inactive or "grayed" look.

- *

- * @param enabled the new enabled 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>

+/**
+ * Enables the receiver if the argument is <code>true</code>,
+ * and disables it otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @param enabled the new enabled 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 void setEnabled (boolean enabled) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNsensitive, enabled ? 1 : 0};

 	OS.XtSetValues (handle, argList, argList.length / 2);

 }

-/**

- * Sets the receiver's cascade menu to the argument.

- * Only <code>CASCADE</code> menu items can have a

- * pull down menu. The sequence of key strokes, button presses

- * and/or button releases that are used to request a pull down

- * menu is platform specific.

- *

- * @param menu the new pop up menu

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_MENU_NOT_DROP_DOWN - the menu is not a drop down menu</li>

- *    <li>ERROR_MENUITEM_NOT_CASCADE - the menu item is not a <code>CASCADE</code></li>

- *    <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>

- *    <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</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>

+/**
+ * Sets the receiver's cascade menu to the argument.
+ * Only <code>CASCADE</code> menu items can have a
+ * pull down menu. The sequence of key strokes, button presses
+ * and/or button releases that are used to request a pull down
+ * menu is platform specific.
+ *
+ * @param menu the new pop up menu
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_MENU_NOT_DROP_DOWN - the menu is not a drop down menu</li>
+ *	<li>ERROR_MENUITEM_NOT_CASCADE - the menu item is not a <code>CASCADE</code></li>
+ *    <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</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>
  */

 public void setMenu (Menu menu) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

 	/* Check to make sure the new menu is valid */

 	if ((style & SWT.CASCADE) == 0) {

 		error (SWT.ERROR_MENUITEM_NOT_CASCADE);

 	}

 	if (menu != null) {

-		if (menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 		if ((menu.style & SWT.DROP_DOWN) == 0) {

 			error (SWT.ERROR_MENU_NOT_DROP_DOWN);

 		}

@@ -707,21 +659,22 @@
 	int [] argList = {OS.XmNsubMenuId, menuHandle};

 	OS.XtSetValues (handle, argList, argList.length / 2);

 }

-/**

- * Sets the selection state of the receiver.

- * <p>

- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,

- * it is selected when it is checked.

- *

- * @param selected the new selection 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>

+/**
+ * Sets the selection state of the receiver.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked.
+ *
+ * @param selected the new selection 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 void setSelection (boolean selected) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return;

 	int [] argList = {OS.XmNset, selected ? 1 : 0};

 	OS.XtSetValues (handle, argList, argList.length / 2);

@@ -739,7 +692,8 @@
 *	when string is null

 */

 public void setText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	super.setText (string);

 	if ((style & (SWT.ARROW | SWT.SEPARATOR)) != 0) return;

@@ -760,7 +714,6 @@
 	if (accel && ++i < text.length) {

 		char [] accelText = new char [text.length - i];

 		System.arraycopy (text, i, accelText, 0, accelText.length);

-		/* Use the character encoding for the default locale */

 		buffer2 = Converter.wcsToMbcs (null, accelText, true);

 	} else {

 		buffer2 = new byte [1];

@@ -775,7 +728,6 @@
 		0);

 	if (xmString2 == 0) error (SWT.ERROR_CANNOT_SET_TEXT);

 	while (j < text.length) text [j++] = 0;

-	/* Use the character encoding for the default locale */

 	byte [] buffer1 = Converter.wcsToMbcs (null, text, true);

 	int xmString1 = OS.XmStringParseText (

 		buffer1,

@@ -785,7 +737,7 @@
 		null,

 		0,

 		0);

-	if (xmString1 == 0) error (SWT.ERROR_CANNOT_SET_TEXT);

+	if (xmString1 == 0) error (SWT.ERROR_CANNOT_SET_TEXT);
 	if (mnemonic == 0) mnemonic = OS.XK_VoidSymbol;

 	int [] argList = {

 		OS.XmNlabelType, OS.XmSTRING,

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MessageBox.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MessageBox.java
index 341e830..f1980da 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MessageBox.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MessageBox.java
@@ -10,83 +10,29 @@
 import org.eclipse.swt.*;

 import org.eclipse.swt.widgets.*;

 

-/**

- * Instances of this class are used used to inform or warn the user.

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>ICON_ERROR, ICON_INFORMATION, ICON_QUESTION, ICON_WARNING, ICON_WORKING</dd>

- * <dd>OK, OK | CANCEL</dd>

- * <dd>YES | NO, YES | NO | CANCEL</dd>

- * <dd>RETRY | CANCEL</dd>

- * <dd>ABORT | RETRY | IGNORE</dd>

- * <dt><b>Events:</b></dt>

- * <dd>(none)</dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is intended to be subclassed <em>only</em>

- * within the SWT implementation.

- * </p>

- */

+/**
+ * Instances of this class are used used to inform or warn the user.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>ICON_ERROR, ICON_INFORMATION, ICON_QUESTION, ICON_WARNING, ICON_WORKING</dd>
+ * <dd>OK, OK | CANCEL</dd>
+ * <dd>YES | NO, YES | NO | CANCEL</dd>
+ * <dd>RETRY | CANCEL</dd>
+ * <dd>ABORT | RETRY | IGNORE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ */
 public /*final*/ class MessageBox extends Dialog {

 	int button;

 	String message = "";

-

-/**

- * Constructs a new instance of this class given only its

- * parent.

- * <p>

- * Note: Currently, null can be passed in for the parent.

- * This has the effect of creating the dialog on the currently active

- * display if there is one. If there is no current display, the 

- * dialog is created on a "default" display. <b>Passing in null as

- * the parent is not considered to be good coding style,

- * and may not be supported in a future release of SWT.</b>

- * </p>

- *

- * @param parent a shell which will be the parent of the new instance

- *

- * @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>

- */

 public MessageBox (Shell parent) {

 	this (parent, SWT.OK | SWT.ICON_INFORMATION | SWT.APPLICATION_MODAL);

 }

-

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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 dialog classes should include a comment which

- * describes the style constants which are applicable to the class.

- * </p>

- * Note: Currently, null can be passed in for the parent.

- * This has the effect of creating the dialog on the currently active

- * display if there is one. If there is no current display, the 

- * dialog is created on a "default" display. <b>Passing in null as

- * the parent is not considered to be good coding style,

- * and may not be supported in a future release of SWT.</b>

- * </p>

- *

- * @param parent a shell which will be the parent of the new instance

- *

- * @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>

- */

 public MessageBox (Shell parent, int style) {

 	super (parent, checkStyle (style));

 }

@@ -112,30 +58,9 @@
 	if ((style & SWT.ICON_WARNING) != 0) return OS.XmCreateWarningDialog (parentHandle, null, argList, argList.length / 2);

 	return OS.XmCreateMessageDialog (parentHandle, null, argList, argList.length / 2);

 }

-

-/**

- * Returns the dialog's message, which is a description of

- * the purpose for which it was opened. This message will be

- * visible on the dialog while it is open.

- *

- * @return the message

- */

 public String getMessage () {

 	return message;

 }

-

-/**

- * Makes the dialog visible and brings it to the front

- * of the display.

- *

- * @return the ID of the button that was selected to dismiss the

- *         message box (e.g. SWT.OK, SWT.CANCEL, etc...)

- *

- * @exception SWTException <ul>

- *    <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>

- * </ul>

- */

 public int open () {

 	

 	/* Create the dialog.*/

@@ -155,7 +80,6 @@
 	*/

 	String string = title;

 	if (string.length () == 0) string = " ";

-	/* Use the character encoding for the default locale */

 	byte [] buffer = Converter.wcsToMbcs (null, string, true);

 	int xmStringPtr = OS.XmStringParseText (

 		buffer,

@@ -254,7 +178,6 @@
 	}

 	if ((style & (SWT.YES | SWT.NO | SWT.CANCEL)) == (SWT.YES | SWT.NO | SWT.CANCEL)) {

 		OS.XtManageChild (help);

-		/* Use the character encoding for the default locale */

 		byte [] buffer1 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_Yes"), true);

 		int xmString1 = OS.XmStringParseText (

 			buffer1,

@@ -264,7 +187,6 @@
 			null,

 			0,

 			0);

-		/* Use the character encoding for the default locale */

 		byte [] buffer2 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_No"), true);

 		int xmString2 = OS.XmStringParseText (

 			buffer2,

@@ -274,7 +196,6 @@
 			null,

 			0,

 			0);

-		/* Use the character encoding for the default locale */

 		byte [] buffer3 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_Cancel"), true);

 		int xmString3 = OS.XmStringParseText (

 			buffer3,

@@ -290,7 +211,6 @@
 		return;

 	}

 	if ((style & (SWT.YES | SWT.NO)) == (SWT.YES | SWT.NO)) {

-		/* Use the character encoding for the default locale */

 		byte [] buffer1 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_Yes"), true);

 		int xmString1 = OS.XmStringParseText (

 			buffer1,

@@ -300,7 +220,6 @@
 			null,

 			0,

 			0);

-		/* Use the character encoding for the default locale */

 		byte [] buffer2 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_No"), true);

 		int xmString2 = OS.XmStringParseText (

 			buffer2,

@@ -316,7 +235,6 @@
 		return;

 	}

 	if ((style & (SWT.RETRY | SWT.CANCEL)) == (SWT.RETRY | SWT.CANCEL)) {

-		/* Use the character encoding for the default locale */

 		byte [] buffer1 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_Retry"), true);

 		int xmString1 = OS.XmStringParseText (

 			buffer1,

@@ -326,7 +244,6 @@
 			null,

 			0,

 			0);

-		/* Use the character encoding for the default locale */

 		byte [] buffer2 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_Cancel"), true);

 		int xmString2 = OS.XmStringParseText (

 			buffer2,

@@ -343,7 +260,6 @@
 	}

 	if ((style & (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) == (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) {

 		OS.XtManageChild (help);

-		/* Use the character encoding for the default locale */

 		byte [] buffer1 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_Abort"), true);

 		int xmString1 = OS.XmStringParseText (

 			buffer1,

@@ -353,7 +269,6 @@
 			null,

 			0,

 			0);

-		/* Use the character encoding for the default locale */

 		byte [] buffer2 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_Retry"), true);

 		int xmString2 = OS.XmStringParseText (

 			buffer2,

@@ -363,7 +278,6 @@
 			null,

 			0,

 			0);

-		/* Use the character encoding for the default locale */

 		byte [] buffer3 = Converter.wcsToMbcs (null, SWT.getMessage("SWT_Ignore"), true);

 		int xmString3 = OS.XmStringParseText (

 			buffer3,

@@ -394,7 +308,6 @@
 			text = display.wrapText (message, fontList, width * 3 / 5);

 		}

 	}

-	/* Use the character encoding for the default locale */

 	byte [] buffer = Converter.wcsToMbcs (null, text, true);

 	int [] parseTable = Display.getDefault ().parseTable;

 	int xmStringPtr = OS.XmStringParseText (

@@ -409,14 +322,6 @@
 	OS.XtSetValues (dialogHandle, argList, argList.length / 2);

 	OS.XmStringFree (xmStringPtr);

 }

-

-/**

- * Sets the dialog's message, which is a description of

- * the purpose for which it was opened. This message will be

- * visible on the dialog while it is open.

- *

- * @param string the message

- */

 public void setMessage (String string) {

 	message = string;

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ProgressBar.java
index 630fbbc..c2d580a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ProgressBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ProgressBar.java
@@ -9,54 +9,28 @@
 import org.eclipse.swt.*;

 import org.eclipse.swt.graphics.*;

 

-/**

- * Instances of the receiver represent is an unselectable

- * user interface object that is used to display progress,

- * typically in the form of a bar.

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>SMOOTH, HORIZONTAL, VERTICAL</dd>

- * <dt><b>Events:</b></dt>

- * <dd>(none)</dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is intended to be subclassed <em>only</em>

- * within the SWT implementation.

- * </p>

+/**
+ * Instances of the receiver represent is an unselectable
+ * user interface object that is used to display progress,
+ * typically in the form of a bar.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SMOOTH, HORIZONTAL, VERTICAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
  */

 

 public /*final*/ class ProgressBar extends Control {

-

 /**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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

- */

+* Creates a new instance of the widget.

+*/

 public ProgressBar (Composite parent, int style) {

-	/*

+	/**

 	 * Feature in Motif. If you set the progress bar's value to 0,

 	 * the thumb does not disappear. In order to make this happen,

 	 * we hide the widget when the value is set to zero by changing

@@ -71,7 +45,8 @@
 	return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);

 }

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int border = getBorderWidth ();

 	int width = border * 2, height = border * 2;

 	Display display = getDisplay ();

@@ -107,65 +82,68 @@
 	};

 	handle = OS.XmCreateScrollBar (parentHandle, null, argList, argList.length / 2);

 	if (handle == 0) error (SWT.ERROR_NO_HANDLES);

+}
+void disableButtonPress () {
+	int xWindow = OS.XtWindow (handle);
+	if (xWindow == 0) return;
+	int xDisplay = OS.XtDisplay (handle);
+	if (xDisplay == 0) return;
+	int event_mask = OS.XtBuildEventMask (handle);
+	XSetWindowAttributes attributes = new XSetWindowAttributes ();
+	attributes.event_mask = event_mask & ~OS.ButtonPressMask;
+	OS.XChangeWindowAttributes (xDisplay, xWindow, OS.CWEventMask, attributes);
+}
+void disableTraversal () {
+	int [] argList = {OS.XmNtraversalOn, 0};
+	OS.XtSetValues (handle, argList, argList.length / 2);
 }

-void disableButtonPress () {

-	int xWindow = OS.XtWindow (handle);

-	if (xWindow == 0) return;

-	int xDisplay = OS.XtDisplay (handle);

-	if (xDisplay == 0) return;

-	int event_mask = OS.XtBuildEventMask (handle);

-	XSetWindowAttributes attributes = new XSetWindowAttributes ();

-	attributes.event_mask = event_mask & ~OS.ButtonPressMask;

-	OS.XChangeWindowAttributes (xDisplay, xWindow, OS.CWEventMask, attributes);

-}

-void disableTraversal () {

-	int [] argList = {OS.XmNtraversalOn, 0};

-	OS.XtSetValues (handle, argList, argList.length / 2);

-}

-/**

- * Returns the maximum value which the receiver will allow.

- *

- * @return the maximum

- *

- * @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 the maximum value which the receiver will allow.
+ *
+ * @return the maximum
+ *
+ * @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 getMaximum () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNmaximum, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * Returns the minimum value which the receiver will allow.

- *

- * @return the minimum

- *

- * @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 the minimum value which the receiver will allow.
+ *
+ * @return the minimum
+ *
+ * @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 getMinimum () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNminimum, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * Returns the single <em>selection</em> that is the receiver's position.

- *

- * @return the selection

- *

- * @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 the single <em>selection</em> that is the receiver's position.
+ *
+ * @return the selection
+ *
+ * @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 getSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {

 		OS.XmNminimum, 0,

 		OS.XmNsliderSize, 0,

@@ -175,36 +153,37 @@
 	int minimum = argList [1], sliderSize = argList [3], background = argList [5];

 	if (sliderSize == 1 && background == defaultBackground()) sliderSize = 0;

 	return minimum + sliderSize;

-}

-void propagateWidget (boolean enabled) {

-	super.propagateWidget (enabled);

-	/*

-	* ProgressBars never participate in focus traversal when

-	* either enabled or disabled.

-	*/

-	if (enabled) {

-		disableTraversal ();

-		disableButtonPress ();

-	}

+}
+void propagateWidget (boolean enabled) {
+	super.propagateWidget (enabled);
+	/*
+	* ProgressBars never participate in focus traversal when
+	* either enabled or disabled.  Also, when enabled
+	*/
+	if (enabled) {
+		disableTraversal ();
+		disableButtonPress ();
+	}
 }

 void realizeChildren () {

-	super.realizeChildren ();

+	super.realizeChildren ();
 	disableButtonPress ();

 }

-/**

- * Sets the maximum value which the receiver will allow

- * to be the argument which must be greater than or

- * equal to zero.

- *

- * @param value the new maximum (must be zero or greater)

- *

- * @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>

+/**
+ * Sets the maximum value which the receiver will allow
+ * to be the argument which must be greater than or
+ * equal to zero.
+ *
+ * @param value the new maximum (must be zero or greater)
+ *
+ * @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 setMaximum (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (value < 0) return;

 	int [] argList = {OS.XmNmaximum, value, OS.XmNvalue, 0};

 	Display display = getDisplay ();

@@ -213,20 +192,21 @@
 	OS.XtSetValues (handle, argList, argList.length / 2);

 	display.setWarnings (warnings);

 }

-/**

- * Sets the minimum value which the receiver will allow

- * to be the argument which must be greater than or

- * equal to zero.

- *

- * @param value the new minimum (must be zero or greater)

- *

- * @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>

+/**
+ * Sets the minimum value which the receiver will allow
+ * to be the argument which must be greater than or
+ * equal to zero.
+ *
+ * @param value the new minimum (must be zero or greater)
+ *
+ * @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 setMinimum (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (value < 0) return;

 	int [] argList = {

 		OS.XmNminimum, 0,

@@ -251,20 +231,21 @@
 	display.setWarnings (warnings);

 	setThumb(selection - value);

 }

-/**

- * Sets the single <em>selection</em> that is the receiver's

- * position to the argument which must be greater than or equal

- * to zero.

- *

- * @param value the new selection (must be zero or greater)

- *

- * @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>

+/**
+ * Sets the single <em>selection</em> that is the receiver's
+ * position to the argument which must be greater than or equal
+ * to zero.
+ *
+ * @param value the new selection (must be zero or greater)
+ *
+ * @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 setSelection (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (value < 0) return;

 	int [] argList = {

 		OS.XmNminimum, 0,

@@ -282,9 +263,7 @@
 void setThumb (int sliderSize) {

 	Display display = getDisplay ();

 	int backgroundPixel = defaultBackground ();

-	int [] argList1 = new int [] {

-		OS.XmNbackground, 0,

-		OS.XmNminimum, 0};

+	int [] argList1 = new int [] {OS.XmNbackground, 0};

 	OS.XtGetValues (handle, argList1, argList1.length / 2);

 	if (sliderSize == 0) {

 		if (argList1 [1] != backgroundPixel) {

@@ -300,7 +279,6 @@
 		OS.XmNtroughColor, backgroundPixel,

 		OS.XmNtopShadowColor, backgroundPixel,

 		OS.XmNbottomShadowColor, backgroundPixel,

-		OS.XmNvalue, argList1[3]

 	};

 	boolean warnings = display.getWarnings ();

 	display.setWarnings (false);

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java
index d26fa47..7ca606c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java
@@ -10,27 +10,26 @@
 import org.eclipse.swt.graphics.*;

 import org.eclipse.swt.events.*;

 

-/**

- * Instances of the receiver represent a selectable user interface object

- * that allows the user to drag a rubber banded outline of the sash within

- * the parent control.

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd> HORIZONTAL, VERTICAL</dd>

- * <dt><b>Events:</b></dt>

- * <dd>Selection</dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is intended to be subclassed <em>only</em>

- * within the SWT implementation.

- * </p>

+/**
+ * Instances of the receiver represent a selectable user interface object
+ * that allows the user to drag a rubber banded outline of the sash within
+ * the parent control.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd> HORIZONTAL, VERTICAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
  */

 

 public /*final*/ class Sash extends Control {

 	boolean dragging;

 	int startX, startY, lastX, lastY;

 	int cursor;

-

 /**

  * Constructs a new instance of this class given its parent

  * and a style value describing its behavior and appearance.

@@ -62,7 +61,6 @@
 public Sash (Composite parent, int style) {

 	super (parent, checkStyle (style));

 }

-

 /**

  * Adds the listener to the collection of listeners who will

  * be notified when the control is selected, by sending

@@ -89,7 +87,8 @@
  * @see SelectionEvent

  */

 public void addSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener(listener);

 	addListener(SWT.Selection,typedListener);

@@ -99,7 +98,8 @@
 	return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);

 }

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int border = getBorderWidth ();

 	int width = border * 2, height = border * 2;

 	if ((style & SWT.HORIZONTAL) != 0) {

@@ -242,25 +242,26 @@
 	}

 	cursor = 0;

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the control is selected.

- *

- * @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 SelectionListener

- * @see #addSelectionListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected.
+ *
+ * @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 SelectionListener
+ * @see #addSelectionListener
  */

 public void removeSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook(SWT.Selection, listener);

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scale.java
index 4e935cb..8fae896 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scale.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scale.java
@@ -10,20 +10,20 @@
 import org.eclipse.swt.events.*;

 import org.eclipse.swt.graphics.*;

 

-/**

- * Instances of the receiver represent a selectable user

- * interface object that present a range of continuous

- * numeric values.

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd> HORIZONTAL, VERTICAL</dd>

- * <dt><b>Events:</b></dt>

- * <dd>Selection</dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is intended to be subclassed <em>only</em>

- * within the SWT implementation.

- * </p>

+/**
+ * Instances of the receiver represent a selectable user
+ * interface object that present a range of continuous
+ * numeric values.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd> HORIZONTAL, VERTICAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
  */

 

 public /*final*/ class Scale extends Control {

@@ -58,28 +58,28 @@
 public Scale (Composite parent, int style) {

 	super (parent, checkStyle (style));

 }

-

-/**

- * Adds the listener to the collection of listeners who will

- * be notified when the receiver's value changes, by sending

- * it one of the messages defined in the <code>SelectionListener</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 SelectionListener

- * @see #removeSelectionListener

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's value changes, by sending
+ * it one of the messages defined in the <code>SelectionListener</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 SelectionListener
+ * @see #removeSelectionListener
  */

 public void addSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener(listener);

 	addListener(SWT.Selection,typedListener);

@@ -89,7 +89,8 @@
 	return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);

 }

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int border = getBorderWidth ();

 	int width = border * 2, height = border * 2;

 	Display display = getDisplay ();

@@ -119,84 +120,89 @@
 	handle = OS.XmCreateScale (parentHandle, null, argList, argList.length / 2);

 	if (handle == 0) error (SWT.ERROR_NO_HANDLES);

 }

-/**

- * Returns the amount that the receiver's value will be

- * modified by when the up/down (or right/left) arrows

- * are pressed.

- *

- * @return the increment

- *

- * @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 the amount that the receiver's value will be
+ * modified by when the up/down (or right/left) arrows
+ * are pressed.
+ *
+ * @return the increment
+ *
+ * @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 getIncrement () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return 1;

 }

-/**

- * Returns the maximum value which the receiver will allow.

- *

- * @return the maximum

- *

- * @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 the maximum value which the receiver will allow.
+ *
+ * @return the maximum
+ *
+ * @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 getMaximum () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNmaximum, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * Returns the minimum value which the receiver will allow.

- *

- * @return the minimum

- *

- * @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 the minimum value which the receiver will allow.
+ *
+ * @return the minimum
+ *
+ * @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 getMinimum () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNminimum, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * Returns the amount that the receiver's value will be

- * modified by when the page increment/decrement areas

- * are selected.

- *

- * @return the page increment

- *

- * @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 the amount that the receiver's value will be
+ * modified by when the page increment/decrement areas
+ * are selected.
+ *
+ * @return the page increment
+ *
+ * @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 getPageIncrement () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNscaleMultiple, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * Returns the single <em>selection</em> that is the receiver's position.

- *

- * @return the selection

- *

- * @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 the single <em>selection</em> that is the receiver's position.
+ *
+ * @return the selection
+ *
+ * @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 getSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNvalue, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

@@ -207,60 +213,63 @@
 	OS.XtAddCallback (handle, OS.XmNvalueChangedCallback, windowProc, SWT.Selection);

 	OS.XtAddCallback (handle, OS.XmNdragCallback, windowProc, SWT.Selection);

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the receiver's value changes.

- *

- * @param listener the listener which should no longer 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 SelectionListener

- * @see #addSelectionListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's value changes.
+ *
+ * @param listener the listener which should no longer 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 SelectionListener
+ * @see #addSelectionListener
  */

 public void removeSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook(SWT.Selection, listener);

 	eventTable.unhook(SWT.DefaultSelection,listener);	

 }

-/**

- * Sets the amount that the receiver's value will be

- * modified by when the up/down (or right/left) arrows

- * are pressed to the argument, which must be at least 

- * one.

- *

- * @param value the new increment (must be greater than zero)

- *

- * @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>

+/**
+ * Sets the amount that the receiver's value will be
+ * modified by when the up/down (or right/left) arrows
+ * are pressed to the argument, which must be at least 
+ * one.
+ *
+ * @param value the new increment (must be greater than zero)
+ *
+ * @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 setIncrement (int increment) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 }

-/**

- * Sets the maximum value which the receiver will allow

- * to be the argument which must be greater than or

- * equal to zero.

- *

- * @param value the new maximum (must be zero or greater)

- *

- * @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>

+/**
+ * Sets the maximum value which the receiver will allow
+ * to be the argument which must be greater than or
+ * equal to zero.
+ *
+ * @param value the new maximum (must be zero or greater)
+ *
+ * @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 setMaximum (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (value < 0) return;

 	int [] argList = {OS.XmNmaximum, value};

 	Display display = getDisplay ();

@@ -269,20 +278,21 @@
 	OS.XtSetValues (handle, argList, argList.length / 2);

 	display.setWarnings (warnings);

 }

-/**

- * Sets the minimum value which the receiver will allow

- * to be the argument which must be greater than or

- * equal to zero.

- *

- * @param value the new minimum (must be zero or greater)

- *

- * @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>

+/**
+ * Sets the minimum value which the receiver will allow
+ * to be the argument which must be greater than or
+ * equal to zero.
+ *
+ * @param value the new minimum (must be zero or greater)
+ *
+ * @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 setMinimum (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (value < 0) return;

 	int [] argList = {OS.XmNminimum, value};

 	Display display = getDisplay ();

@@ -291,21 +301,22 @@
 	OS.XtSetValues (handle, argList, argList.length / 2);

 	display.setWarnings (warnings);

 }

-/**

- * Sets the amount that the receiver's value will be

- * modified by when the page increment/decrement areas

- * are selected to the argument, which must be at least

- * one.

- *

- * @return the page increment (must be greater than zero)

- *

- * @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>

+/**
+ * Sets the amount that the receiver's value will be
+ * modified by when the page increment/decrement areas
+ * are selected to the argument, which must be at least
+ * one.
+ *
+ * @return the page increment (must be greater than zero)
+ *
+ * @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 setPageIncrement (int pageIncrement) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (pageIncrement < 1) return;

 	int [] argList = {OS.XmNscaleMultiple, pageIncrement};

 	Display display = getDisplay ();

@@ -314,20 +325,21 @@
 	OS.XtSetValues (handle, argList, argList.length / 2);

 	display.setWarnings (warnings);

 }

-/**

- * Sets the single <em>selection</em> that is the receiver's

- * value to the argument which must be greater than or equal

- * to zero.

- *

- * @param value the new selection (must be zero or greater)

- *

- * @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>

+/**
+ * Sets the single <em>selection</em> that is the receiver's
+ * value to the argument which must be greater than or equal
+ * to zero.
+ *
+ * @param value the new selection (must be zero or greater)
+ *
+ * @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 setSelection (int selection) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (selection < 0) return;

 	int [] argList = {OS.XmNvalue, selection};

 	Display display = getDisplay ();

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ScrollBar.java
index 95ffca3..0dfc32c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ScrollBar.java
@@ -10,65 +10,65 @@
 import org.eclipse.swt.graphics.*;

 import org.eclipse.swt.events.*;

 

-/**

- * Instances of this class are selectable user interface

- * objects that represent a range of positive, numeric values. 

- * <p>

- * At any given moment, a given scroll bar will have a 

- * single <em>selection</em> that is considered to be its

- * value, which is constrained to be within the range of

- * values the scroll bar represents (that is, between its

- * <em>minimum</em> and <em>maximum</em> values).

- * </p><p>

- * Typically, scroll bars will be made up of five areas:

- * <ol>

- * <li>an arrow button for decrementing the value</li>

- * <li>a page decrement area for decrementing the value by a larger amount</li>

- * <li>a <em>thumb</em> for modifying the value by mouse dragging</li>

- * <li>a page increment area for incrementing the value by a larger amount</li>

- * <li>an arrow button for incrementing the value</li>

- * </ol>

- * Based on their style, scroll bars are either <code>HORIZONTAL</code>

- * (which have left and right facing buttons for incrementing and

- * decrementing the value) or <code>VERTICAL</code> (which have

- * up and down facing buttons for incrementing and decrementing

- * the value).

- * </p><p>

- * On some platforms, the size of the scroll bar's thumb can be

- * varied relative to the magnitude of the range of values it

- * represents (that is, relative to the difference between its

- * maximum and minimum values). Typically, this is used to

- * indicate some proportional value such as the ratio of the

- * visible area of a document to the total amount of space that

- * it would take to display it. SWT supports setting the thumb

- * size even if the underlying platform does not, but in this

- * case the appearance of the scroll bar will not change.

- * </p><p>

- * Scroll bars are created by specifying either <code>H_SCROLL</code>,

- * <code>V_SCROLL</code> or both when creating a <code>Scrollable</code>.

- * They are accessed from the <code>Scrollable</code> using

- * <code>getHorizontalBar</code> and <code>getVerticalBar</code>.

- * </p><p>

- * Note: Scroll bars are not Controls.  On some platforms, scroll bars

- * that appear as part of some standard controls such as a text or list

- * have no operating system resources and are not children of the control.

- * For this reason, scroll bars are treated specially.  To create a control

- * that looks like a scroll bar but has operating system resources, use

- * <code>Slider</code>. 

- * </p>

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>HORIZONTAL, VERTICAL</dd>

- * <dt><b>Events:</b></dt>

- * <dd>Selection</dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is <em>not</em> intended to be subclassed.

- *

- * @see Slider

- * @see Scrollable

- * @see Scrollable#getHorizontalBar

- * @see Scrollable#getVerticalBar

+/**
+ * Instances of this class are selectable user interface
+ * objects that represent a range of positive, numeric values. 
+ * <p>
+ * At any given moment, a given scroll bar will have a 
+ * single <em>selection</em> that is considered to be its
+ * value, which is constrained to be within the range of
+ * values the scroll bar represents (that is, between its
+ * <em>minimum</em> and <em>maximum</em> values).
+ * </p><p>
+ * Typically, scroll bars will be made up of five areas:
+ * <ol>
+ * <li>an arrow button for decrementing the value</li>
+ * <li>a page decrement area for decrementing the value by a larger amount</li>
+ * <li>a <em>thumb</em> for modifying the value by mouse dragging</li>
+ * <li>a page increment area for incrementing the value by a larger amount</li>
+ * <li>an arrow button for incrementing the value</li>
+ * </ol>
+ * Based on their style, scroll bars are either <code>HORIZONTAL</code>
+ * (which have left and right facing buttons for incrementing and
+ * decrementing the value) or <code>VERTICAL</code> (which have
+ * up and down facing buttons for incrementing and decrementing
+ * the value).
+ * </p><p>
+ * On some platforms, the size of the scroll bar's thumb can be
+ * varied relative to the magnitude of the range of values it
+ * represents (that is, relative to the difference between its
+ * maximum and minimum values). Typically, this is used to
+ * indicate some proportional value such as the ratio of the
+ * visible area of a document to the total amount of space that
+ * it would take to display it. SWT supports setting the thumb
+ * size even if the underlying platform does not, but in this
+ * case the appearance of the scroll bar will not change.
+ * </p><p>
+ * Scroll bars are created by specifying either <code>H_SCROLL</code>,
+ * <code>V_SCROLL</code> or both when creating a <code>Scrollable</code>.
+ * They are accessed from the <code>Scrollable</code> using
+ * <code>getHorizontalBar</code> and <code>getVerticalBar</code>.
+ * </p><p>
+ * Note: Scroll bars are not Controls.  On some platforms, scroll bars
+ * that appear as part of some standard controls such as a text or list
+ * have no operating system resources and are not children of the control.
+ * For this reason, scroll bars are treated specially.  To create a control
+ * that looks like a scroll bar but has operating system resources, use
+ * <code>Slider</code>. 
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>HORIZONTAL, VERTICAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ *
+ * @see Slider
+ * @see Scrollable
+ * @see Scrollable#getHorizontalBar
+ * @see Scrollable#getVerticalBar
  */

 

 public /*final*/ class ScrollBar extends Widget {

@@ -114,7 +114,8 @@
  * @see SelectionEvent

  */

 public void addSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener(listener);

 	addListener(SWT.Selection,typedListener);

@@ -142,180 +143,190 @@
 	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

- * not selectable from the user interface and draws with an

- * inactive or "grayed" look.

- *

- * @return the enabled 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 enabled, and
+ * <code>false</code> otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @return the enabled 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 getEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNsensitive, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1] != 0;

 }

-/**

- * Returns the amount that the receiver's value will be

- * modified by when the up/down (or right/left) arrows

- * are pressed.

- *

- * @return the increment

- *

- * @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 the amount that the receiver's value will be
+ * modified by when the up/down (or right/left) arrows
+ * are pressed.
+ *
+ * @return the increment
+ *
+ * @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 getIncrement () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNincrement, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * Returns the maximum value which the receiver will allow.

- *

- * @return the maximum

- *

- * @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 the maximum value which the receiver will allow.
+ *
+ * @return the maximum
+ *
+ * @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 getMaximum () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNmaximum, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * Returns the minimum value which the receiver will allow.

- *

- * @return the minimum

- *

- * @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 the minimum value which the receiver will allow.
+ *
+ * @return the minimum
+ *
+ * @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 getMinimum () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNminimum, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * Returns the amount that the receiver's value will be

- * modified by when the page increment/decrement areas

- * are selected.

- *

- * @return the page increment

- *

- * @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 the amount that the receiver's value will be
+ * modified by when the page increment/decrement areas
+ * are selected.
+ *
+ * @return the page increment
+ *
+ * @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 getPageIncrement () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNpageIncrement, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * Returns the receiver's parent, which must be scrollable.

- *

- * @return the receiver's parent

- *

- * @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 the receiver's parent, which must be scrollable.
+ *
+ * @return the receiver's parent
+ *
+ * @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 Scrollable getParent () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent;

 }

-/**

- * Returns the single <em>selection</em> that is the receiver's value.

- *

- * @return the selection

- *

- * @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 the single <em>selection</em> that is the receiver's value.
+ *
+ * @return the selection
+ *
+ * @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 getSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNvalue, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * For horizontal scroll bars, returns the height of the 

- * instance, and for vertical scroll bars, returns the width

- * of the instance.

- *

- * @return the scroll bar size

- *

- * @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>

+/**
+ * For horizontal scroll bars, returns the height of the 
+ * instance, and for vertical scroll bars, returns the width
+ * of the instance.
+ *
+ * @return the scroll bar size
+ *
+ * @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 Point getSize () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	int borders = argList [5] * 2;

 	return new Point (argList [1] + borders, argList [3] + borders);

 }

-/**

- * Answers the size of the receiver's thumb relative to the

- * difference between its maximum and minimum values.

- *

- * @return the thumb value

- *

- * @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 ScrollBar

+/**
+ * Answers the size of the receiver's thumb relative to the
+ * difference between its maximum and minimum values.
+ *
+ * @return the thumb value
+ *
+ * @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 ScrollBar
  */

 public int getThumb () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNsliderSize, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * Returns <code>true</code> if the receiver is visible, and

- * <code>false</code> otherwise.

- * <p>

- * If one of the receiver's ancestors is not visible or some

- * other condition makes the receiver not visible, this method

- * may still indicate that it is considered visible even though

- * it may not actually be showing.

- * </p>

- *

- * @return the receiver's visibility 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 visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility 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 getVisible () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return OS.XtIsManaged (handle);

 }

 void hookEvents () {

@@ -329,47 +340,49 @@
 	OS.XtAddCallback (handle, OS.XmNpageDecrementCallback, windowProc, SWT.Selection);

 	OS.XtAddCallback (handle, OS.XmNtoTopCallback, windowProc, SWT.Selection);

 }

-/**

- * Returns <code>true</code> if the receiver is enabled, and

- * <code>false</code> otherwise. A disabled control is typically

- * not selectable from the user interface and draws with an

- * inactive or "grayed" look.

- * <p>

- * Note: Because of the strong connection between a scroll bar

- * and the widget which contains it (its parent), a scroll bar

- * will not indicate that it is enabled if its parent is not.

- * </p>

- *

- * @return the receiver's enabled 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 enabled, and
+ * <code>false</code> otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ * <p>
+ * Note: Because of the strong connection between a scroll bar
+ * and the widget which contains it (its parent), a scroll bar
+ * will not indicate that it is enabled if its parent is not.
+ * </p>
+ *
+ * @return the receiver's enabled 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 isEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return getEnabled () && parent.isEnabled ();

 }

-/**

- * Returns <code>true</code> if the receiver is visible, and

- * <code>false</code> otherwise.

- * <p>

- * If one of the receiver's ancestors is not visible or some

- * other condition makes the receiver not visible, this method

- * may still indicate that it is considered visible even though

- * it may not actually be showing.

- * </p>

- *

- * @return the receiver's visibility 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 visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility 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 isVisible () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return getVisible () && parent.isVisible ();

 }

 void manageChildren () {

@@ -414,81 +427,85 @@
 	super.releaseWidget ();

 	parent = null;

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the receiver's value changes.

- *

- * @param listener the listener which should no longer 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 SelectionListener

- * @see #addSelectionListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's value changes.
+ *
+ * @param listener the listener which should no longer 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 SelectionListener
+ * @see #addSelectionListener
  */

 public void removeSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook(SWT.Selection, listener);

 	eventTable.unhook(SWT.DefaultSelection,listener);	

 }

-/**

- * Enables the receiver if the argument is <code>true</code>,

- * and disables it otherwise. A disabled control is typically

- * not selectable from the user interface and draws with an

- * inactive or "grayed" look.

- *

- * @param enabled the new enabled 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>

+/**
+ * Enables the receiver if the argument is <code>true</code>,
+ * and disables it otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @param enabled the new enabled 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 void setEnabled (boolean enabled) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNsensitive, enabled ? 1 : 0};

 	OS.XtSetValues (handle, argList, argList.length / 2);

 }

-/**

- * Sets the amount that the receiver's value will be

- * modified by when the up/down (or right/left) arrows

- * are pressed to the argument, which must be at least 

- * one.

- *

- * @param value the new increment (must be greater than zero)

- *

- * @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>

+/**
+ * Sets the amount that the receiver's value will be
+ * modified by when the up/down (or right/left) arrows
+ * are pressed to the argument, which must be at least 
+ * one.
+ *
+ * @param value the new increment (must be greater than zero)
+ *
+ * @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 setIncrement (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (value < 1) return;

 	int [] argList = {OS.XmNincrement, value};

 	OS.XtSetValues (handle, argList, argList.length / 2);

 }

-/**

- * Sets the maximum value which the receiver will allow

- * to be the argument which must be greater than or

- * equal to zero.

- *

- * @param value the new maximum (must be zero or greater)

- *

- * @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>

+/**
+ * Sets the maximum value which the receiver will allow
+ * to be the argument which must be greater than or
+ * equal to zero.
+ *
+ * @param value the new maximum (must be zero or greater)
+ *
+ * @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 setMaximum (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (value < 0) return;

 	int [] argList = {OS.XmNmaximum, value};

 	Display display = getDisplay ();

@@ -497,20 +514,21 @@
 	OS.XtSetValues (handle, argList, argList.length / 2);

 	display.setWarnings (warnings);

 }

-/**

- * Sets the minimum value which the receiver will allow

- * to be the argument which must be greater than or

- * equal to zero.

- *

- * @param value the new minimum (must be zero or greater)

- *

- * @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>

+/**
+ * Sets the minimum value which the receiver will allow
+ * to be the argument which must be greater than or
+ * equal to zero.
+ *
+ * @param value the new minimum (must be zero or greater)
+ *
+ * @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 setMinimum (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (value < 0) return;

 	int [] argList = {

 		OS.XmNminimum, 0,

@@ -538,39 +556,41 @@
 	OS.XtSetValues (handle, argList, argList.length / 2);

 	display.setWarnings (warnings);

 }

-/**

- * Sets the amount that the receiver's value will be

- * modified by when the page increment/decrement areas

- * are selected to the argument, which must be at least

- * one.

- *

- * @return the page increment (must be greater than zero)

- *

- * @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>

+/**
+ * Sets the amount that the receiver's value will be
+ * modified by when the page increment/decrement areas
+ * are selected to the argument, which must be at least
+ * one.
+ *
+ * @return the page increment (must be greater than zero)
+ *
+ * @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 setPageIncrement (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (value < 1) return;

 	int [] argList = {OS.XmNpageIncrement, value};

 	OS.XtSetValues (handle, argList, argList.length / 2);

 }

-/**

- * Sets the single <em>selection</em> that is the receiver's

- * value to the argument which must be greater than or equal

- * to zero.

- *

- * @param value the new selection (must be zero or greater)

- *

- * @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>

+/**
+ * Sets the single <em>selection</em> that is the receiver's
+ * value to the argument which must be greater than or equal
+ * to zero.
+ *
+ * @param value the new selection (must be zero or greater)
+ *
+ * @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 setSelection (int selection) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (selection < 0) return;

 	int [] argList = {OS.XmNvalue, selection};

 	Display display = getDisplay ();

@@ -579,22 +599,23 @@
 	OS.XtSetValues (handle, argList, argList.length / 2);

 	display.setWarnings (warnings);

 }

-/**

- * Sets the size of the receiver's thumb relative to the

- * difference between its maximum and minimum values to the

- * argument which must be at least one.

- *

- * @param value the new thumb value (must be at least one)

- *

- * @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 ScrollBar

+/**
+ * Sets the size of the receiver's thumb relative to the
+ * difference between its maximum and minimum values to the
+ * argument which must be at least one.
+ *
+ * @param value the new thumb value (must be at least one)
+ *
+ * @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 ScrollBar
  */

 public void setThumb (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (value < 1) return;

 	int [] argList = {OS.XmNsliderSize, value};

 	Display display = getDisplay ();

@@ -603,29 +624,30 @@
 	OS.XtSetValues (handle, argList, argList.length / 2);

 	display.setWarnings (warnings);

 }

-/**

- * Sets the receiver's selection, minimum value, maximum

- * value, thumb, increment and page increment all at once.

- * <p>

- * Note: This is equivalent to setting the values individually

- * using the appropriate methods, but may be implemented in a 

- * more efficient fashion on some platforms.

- * </p>

- *

- * @param selection the new selection value

- * @param minimum the new minimum value

- * @param maximum the new maximum value

- * @param thumb the new thumb value

- * @param increment the new increment value

- * @param pageIncrement the new pageIncrement value

- *

- * @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>

- */

+/**
+ * Sets the receiver's selection, minimum value, maximum
+ * value, thumb, increment and page increment all at once.
+ * <p>
+ * Note: This is equivalent to setting the values individually
+ * using the appropriate methods, but may be implemented in a 
+ * more efficient fashion on some platforms.
+ * </p>
+ *
+ * @param selection the new selection value
+ * @param minimum the new minimum value
+ * @param maximum the new maximum value
+ * @param thumb the new thumb value
+ * @param increment the new increment value
+ * @param pageIncrement the new pageIncrement value
+ *
+ * @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 setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (selection < 0) return;

 	if (minimum < 0) return;

 	if (maximum < 0) return;

@@ -647,24 +669,25 @@
 	OS.XtSetValues (handle, argList, argList.length / 2);

 	display.setWarnings (warnings);

 }

-/**

- * Marks the receiver as visible if the argument is <code>true</code>,

- * and marks it invisible otherwise. 

- * <p>

- * If one of the receiver's ancestors is not visible or some

- * other condition makes the receiver not visible, marking

- * it visible may not actually cause it to be displayed.

- * </p>

- *

- * @param visible the new visibility 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>

+/**
+ * Marks the receiver as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility 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 void setVisible (boolean visible) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	/*

 	* Feature in Motif.  Hiding or showing a scroll bar

 	* can cause the widget to automatically resize in

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scrollable.java
index 2a433e7..e4cebf4 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scrollable.java
@@ -9,82 +9,83 @@
 import org.eclipse.swt.*;

 import org.eclipse.swt.graphics.*;

 

-/**

- * This class is the abstract superclass of all classes which

- * represent controls that have standard scroll bars.

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>H_SCROLL, V_SCROLL</dd>

- * <dt><b>Events:</b>

- * <dd>(none)</dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is intended to be subclassed <em>only</em>

- * within the SWT implementation.

- * </p>

- */

+/**
+ * This class is the abstract superclass of all classes which
+ * represent controls that have standard scroll bars.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>H_SCROLL, V_SCROLL</dd>
+ * <dt><b>Events:</b>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ */
 public abstract class Scrollable extends Control {

 	int scrolledHandle, formHandle;

 	ScrollBar horizontalBar, verticalBar;

 Scrollable () {

 	/* Do nothing */

 }

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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

- */

+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <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
+ *
+ * @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 Scrollable (Composite parent, int style) {

 	super (parent, style);

 }

-/**

- * Given a desired <em>client area</em> for the receiver

- * (as described by the arguments), returns the bounding

- * rectangle which would be required to produce that client

- * area.

- * <p>

- * In other words, it returns a rectangle such that, if the

- * receiver's bounds were set to that rectangle, the area

- * of the receiver which is capable of displaying data

- * (that is, not covered by the "trimmings") would be the

- * rectangle described by the arguments (relative to the

- * receiver's parent).

- * </p>

- * 

- * @return the required bounds to produce the given client area

- *

- * @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 #getClientArea

- */

+/**
+ * Given a desired <em>client area</em> for the receiver
+ * (as described by the arguments), returns the bounding
+ * rectangle which would be required to produce that client
+ * area.
+ * <p>
+ * In other words, it returns a rectangle such that, if the
+ * receiver's bounds were set to that rectangle, the area
+ * of the receiver which is capable of displaying data
+ * (that is, not covered by the "trimmings") would be the
+ * rectangle described by the arguments (relative to the
+ * receiver's parent).
+ * </p>
+ * 
+ * @return the required bounds to produce the given client area
+ *
+ * @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 #getClientArea
+ */
 public Rectangle computeTrim (int x, int y, int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int border = getBorderWidth ();

 	int trimX = x - border, trimY = y - border;

 	int trimWidth = width + (border * 2), trimHeight = height + (border * 2);

@@ -153,54 +154,57 @@
 		if (argList [3] != 0) enableHandle (enabled, argList [3]);

 	}

 }

-/**

- * Returns a rectangle which describes the area of the

- * receiver which is capable of displaying data (that is,

- * not covered by the "trimmings").

- * 

- * @return the client area

- *

- * @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 #computeTrim

- */

+/**
+ * Returns a rectangle which describes the area of the
+ * receiver which is capable of displaying data (that is,
+ * not covered by the "trimmings").
+ * 
+ * @return the client area
+ *
+ * @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 #computeTrim
+ */
 public Rectangle getClientArea () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return new Rectangle (0, 0, argList [1], argList [3]);

 }

-/**

- * Returns the receiver's horizontal scroll bar if it has

- * one, and null if it does not.

- *

- * @return the horizontal scroll bar (or null)

- *

- * @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 the receiver's horizontal scroll bar if it has
+ * one, and null if it does not.
+ *
+ * @return the horizontal scroll bar (or null)
+ *
+ * @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 ScrollBar getHorizontalBar () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return horizontalBar;

 }

-/**

- * Returns the receiver's vertical scroll bar if it has

- * one, and null if it does not.

- *

- * @return the vertical scroll bar (or null)

- *

- * @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 the receiver's vertical scroll bar if it has
+ * one, and null if it does not.
+ *
+ * @return the vertical scroll bar (or null)
+ *
+ * @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 ScrollBar getVerticalBar () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return verticalBar;

 }

 void manageChildren () {

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/SelectableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/SelectableItem.java
new file mode 100755
index 0000000..87acefd
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/SelectableItem.java
@@ -0,0 +1,320 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+

+import org.eclipse.swt.*;

+import org.eclipse.swt.graphics.*;

+

+/**

+ * This class implements common behavior of TreeItem and TableItem.

+ */

+abstract class SelectableItem extends Item {

+	protected static final int CHECKBOX_PADDING = 1;	// Space behind check box, before item image or text

+		

+	private SelectableItemWidget parent;				// parent widget of the receiver

+	private boolean isSelected = false;					// item selection state

+	private boolean isChecked = false;					// item checked state. Can be one of checked and unchecked

+	private boolean isGrayed = false;					// item grayed state. The gray state is combined with the 

+														// checked state to create gray checked and gray unchecked.

+/**

+ * Create a new instance of the receiver.

+ * @param parent - widget the receiver is created in 

+ * @param style - widget style. see Widget class for details

+ */

+SelectableItem(SelectableItemWidget parent, int style) {

+	super(parent, style);

+	setParent(parent);	

+}

+public void dispose() {

+	if (!isValidWidget ()) return;

+	super.dispose();

+	doDispose();

+}

+void doDispose() {

+	setParent(null);

+}

+/**

+ * Draw the check box of the receiver at 'position' using 'gc'.

+ * @param gc - GC to draw on. 

+ * @param destinationPosition - position on the GC to draw at.

+ * @return Answer the position where drawing stopped.

+ */

+Point drawCheckbox(GC gc, Point position) {

+	SelectableItemWidget parent = getSelectableParent();

+	Image image;

+	Point imageExtent;

+	Rectangle imageBounds;

+	int imageOffset;

+	int xInset;

+	int yInset;

+

+	if (getGrayed() == true) {

+		image = parent.getGrayUncheckedImage();

+	}

+	else {

+		image = parent.getUncheckedImage();

+	}

+	if (image != null) {

+		imageExtent = parent.getCheckBoxExtent();

+		imageOffset = (parent.getItemHeight() - imageExtent.y) / 2;

+		gc.drawImage(image, position.x, position.y + imageOffset);

+		if (getChecked() == true) {

+			image = parent.getCheckMarkImage();

+			imageBounds = image.getBounds();

+			xInset = (imageExtent.x - imageBounds.width) / 2;

+			yInset = (imageExtent.y - imageBounds.height) / 2;

+			gc.drawImage(image, position.x + xInset, position.y + imageOffset + yInset);

+		}

+		position.x += imageExtent.x;

+	}

+	position.x += CHECKBOX_PADDING;									// leave extra space behind check box	

+	return position;

+}

+void drawInsertMark(GC gc, Point position) {

+	SelectableItemWidget parent = getSelectableParent();

+	Point selectionExtent = getSelectionExtent();

+	final int markerWidth = getInsertMarkWidth();

+	int insertMarkYOffset = 0;

+

+	if (selectionExtent == null) {

+		return;

+	}

+	if (parent.isInsertAfter()) {

+		insertMarkYOffset = selectionExtent.y - markerWidth;

+	}

+	gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_BLACK));

+	gc.fillRectangle(position.x, position.y + insertMarkYOffset, selectionExtent.x, markerWidth);

+	gc.setBackground(parent.getBackground());

+}

+/**

+ * Answer the bounding rectangle of the item check box.

+ * All points within this rectangle hit the check box.

+ */

+Rectangle getCheckboxBounds() {

+	SelectableItemWidget parent = getSelectableParent();

+	Point checkBoxExtent;

+	int redrawPosition;

+	Rectangle checkboxBounds = new Rectangle(0, 0, 0, 0);

+

+	if (isCheckable() == true) {

+		checkboxBounds.x = getCheckboxXPosition();

+		redrawPosition = parent.getRedrawY(this);

+		if (redrawPosition != -1) {

+			checkboxBounds.y = redrawPosition;

+		}

+		checkBoxExtent = parent.getCheckBoxExtent();

+		checkboxBounds.width = checkBoxExtent.x;

+		checkboxBounds.height = checkBoxExtent.y;

+		checkboxBounds.y += (parent.getItemHeight() - checkBoxExtent.y) / 2;

+	}

+	return checkboxBounds;

+}

+/**

+ * Answer the x position of the item check box

+ */

+abstract int getCheckboxXPosition();

+/**

+ * Return whether or not the receiver is checked.

+ * Always return false if the parent of the receiver does not

+ * have the CHECK style.

+ */

+public boolean getChecked() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	boolean checked = false;

+	

+	if (isCheckable() == true) {

+		checked = isChecked;

+	}

+	return checked;

+}

+/**

+ * Answer the display of the receiver's parent widget.

+ */

+public Display getDisplay() {

+	SelectableItemWidget parent = getSelectableParent();

+

+	if (parent == null) {

+		error(SWT.ERROR_WIDGET_DISPOSED);

+	}

+	return parent.getDisplay();

+}

+

+/**

+ * Gets the grayed state.

+ * <p>

+ * @return the item grayed state.

+ *

+ * @exception SWTError <ul>

+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>

+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>

+ *	</ul>

+ */

+public boolean getGrayed () {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	boolean grayed = false;

+	

+	if (isCheckable() == true) {

+		grayed = isGrayed;

+	}

+	return grayed;

+}

+/**

+ * Return the width in pixels of the line drawn to indicate the 

+ * drop insert position during a drag and drop operation.

+ */

+int getInsertMarkWidth() {

+	return 2;

+}

+/**

+ * Answer the parent widget of the receiver.

+ */

+SelectableItemWidget getSelectableParent() {

+	return parent;

+}

+/**

+ * Answer the background color to use for drawing the 

+ * selection rectangle.

+ */

+Color getSelectionBackgroundColor() {

+	Display display = getSelectableParent().getDisplay();	

+

+	return display.getSystemColor(SWT.COLOR_LIST_SELECTION);

+}

+/**

+ * Return the size of the rectangle drawn to indicate the

+ * selected state of the receiver.

+ */

+abstract Point getSelectionExtent();

+/** 

+ * Answer the foreground color to use for drawing the 

+ * selection rectangle.

+ */

+Color getSelectionForegroundColor() {

+	Display display = getSelectableParent().getDisplay();	

+

+	return display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);

+}

+/**

+ * Return the x position of the selection rectangle

+ */

+abstract int getSelectionX();

+/**

+ * Answer whether 'posiiton' is inside the item check box.

+ * @return

+ *	true - item check box hit

+ *	false - item check box not hit

+ */

+boolean isCheckHit(Point position) {

+	boolean isCheckHit = false;

+	

+	if (isCheckable() == true) {

+		isCheckHit = getCheckboxBounds().contains(position);

+	}

+	return isCheckHit;

+}

+/**

+ * Return whether or not the receiver has a check box and can 

+ * be checked.

+ */

+boolean isCheckable() {

+	return (getSelectableParent().getStyle() & SWT.CHECK) != 0;

+}

+/**

+ * Answer whether the receiver is selected.

+ * @return 

+ *	true - the receiver is selected

+ * 	false - the receiver is not selected

+ */

+boolean isSelected() {

+	return isSelected;

+}

+/**

+ * Redraw the insert mark

+ * @param yPosition - y position in the receiver's client area 

+ *	where the item should be drawn.

+ */

+void redrawInsertMark(int yPosition) {

+	SelectableItemWidget parent = getSelectableParent();

+	Point selectionExtent = getSelectionExtent();

+	int redrawHeight = getInsertMarkWidth();

+

+	if (selectionExtent != null) {

+		parent.redraw(getSelectionX(), yPosition, selectionExtent.x, redrawHeight, false);

+		parent.redraw(getSelectionX(), yPosition + selectionExtent.y - redrawHeight, selectionExtent.x, redrawHeight, false);

+	}	

+}

+/**

+ * Redraw the selection

+ * @param yPosition - y position in the receiver's client area 

+ *	where the item should be drawn.

+ */

+void redrawSelection(int yPosition) {

+	SelectableItemWidget parent = getSelectableParent();

+	Point selectionExtent = getSelectionExtent();

+

+	if (selectionExtent != null) {

+		parent.redraw(getSelectionX(), yPosition, selectionExtent.x, selectionExtent.y, false);

+	}

+}

+/**

+ * Set the checked state to 'checked' if the parent of the 

+ * receiver has the CHECK style.

+ */

+public void setChecked(boolean checked) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItemWidget parent = getSelectableParent();

+	Rectangle redrawRectangle = getCheckboxBounds();

+

+	if (isCheckable() == true && isChecked != checked) {

+		isChecked = checked;

+		parent.redraw(

+			redrawRectangle.x, redrawRectangle.y, 

+			redrawRectangle.width, redrawRectangle.height, false);

+	}	

+}

+

+/**

+ * Sets the grayed state.

+ * <p>

+ * @param grayed the new grayed state.

+ *

+ * @exception SWTError <ul>

+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>

+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>

+ *	</ul>

+ */

+public void setGrayed (boolean grayed) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItemWidget parent = getSelectableParent();

+	Rectangle redrawRectangle = getCheckboxBounds();

+

+	if (isCheckable() == true && isGrayed != grayed) {

+		isGrayed = grayed;

+		parent.redraw(

+			redrawRectangle.x, redrawRectangle.y, 

+			redrawRectangle.width, redrawRectangle.height, false);

+	}	

+}

+

+/**

+ * Set the receiver's parent widget to 'parent'.

+ */

+void setParent(SelectableItemWidget parent) {

+	this.parent = parent;

+}

+/**

+ * Set whether the receiver is selected.

+ * @param selected - true=the receiver is selected

+ * 	false=the receiver is not selected

+ */

+void setSelected(boolean selected) {

+	isSelected = selected;

+}

+}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/SelectableItemWidget.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/SelectableItemWidget.java
new file mode 100755
index 0000000..384fe03
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/SelectableItemWidget.java
@@ -0,0 +1,2051 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+ 

+import org.eclipse.swt.*;

+import org.eclipse.swt.graphics.*;

+import java.io.*;

+import java.util.*;

+ 

+/**

+ * This class is intended for widgets that display data of 

+ * type Item. It provides a framework for scrolling and 

+ * handles the screen refresh required when adding and 

+ * removing items. 

+ */

+abstract class SelectableItemWidget extends Composite {

+	private static final int DEFAULT_WIDTH = 64;		// used in computeSize if width could not be calculated

+	private static final int DEFAULT_HEIGHT = 64;		// used in computeSize if height could not be calculated

+	private static final int HORIZONTAL_SCROLL_INCREMENT = 5;	// number of pixel the tree is moved

+														// during horizontal line scrolling

+	private static ImageData UncheckedImageData;		// deselected check box image data. used to create an image at run time

+	private static ImageData GrayUncheckedImageData;		// grayed deselected check box image data. used to create an image at run time

+	private static ImageData CheckMarkImageData;		// check mark image data for check box. used to create an image at run time

+	static {

+		initializeImageData();

+	}

+

+	private int topIndex = 0;							// index of the first visible item

+	private int itemHeight = 0;							// height of a table item

+	private Point itemImageExtent = null;				// size of the item images. Null unless an image is set for any item

+	private int textHeight = -1;

+	private int contentWidth = 0;						// width of the widget data (ie. table rows/tree items)

+	private int horizontalOffset = 0;

+	private Vector selectedItems;						// indices of the selected items																

+	private SelectableItem lastSelectedItem;			// item that was selected last

+	private SelectableItem lastFocusItem;				// item that had the focus last. Always equals lastSelectedItem 

+														// for mouse selection but may differ for keyboard selection

+	private SelectableItem insertItem;					// item that draws the insert marker to indicate the drop location in a drag and drop operation

+	private boolean isInsertAfter;						// indicates where the insert marker is rendered, at the top or bottom of 'insertItem'

+	private boolean isCtrlSelection = false;			// the most recently selected item was 

+														// selected using the Ctrl modifier key

+	private boolean isRemovingAll = false;				// true=all items are removed. Used to optimize screen updates and to control item selection on dispose.

+	private boolean hasFocus;					// workaround for 1FMITIE

+	private Image uncheckedImage;					// deselected check box

+	private Image grayUncheckedImage;						// grayed check box

+	private Image checkMarkImage;					// check mark for selected check box

+	private Point checkBoxExtent = null;				// width, height of the item check box

+	private Listener listener;					// event listener used for all events. Events are dispatched 

+														// to handler methods in handleEvents(Event)

+	private int drawCount = 0;					// used to reimplement setRedraw(boolean)

+/**

+ * Create a new instance of ScrollableItemWidget.

+ * @param parent - the parent window of the new instance

+ * @param style - window style for the new instance

+ */

+SelectableItemWidget(Composite parent, int style) {

+	super(parent, style | SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_REDRAW_RESIZE);

+	initialize();

+}

+/**

+ * The SelectableItem 'item' has been added to the tree.

+ * Calculate the vertical scroll bar.

+ * Update the screen to display the new item.

+ * @param item - item that has been added to the receiver.

+ */

+void addedItem(SelectableItem item, int index) {

+	calculateVerticalScrollbar();

+	if (getLastFocus() == null) {						// if no item has the focus

+		setLastFocus(item, true);								// set focus to new (must be first) item 

+	}	

+}

+/**

+ * The SelectableItem 'item' is about to be added to the tree.

+ * @param item - item that is about to be added to the receiver.

+ */

+void addingItem(SelectableItem item, int index) {

+	if (index >= 0 && index <= getBottomIndex()) {

+		scrollVerticalAddingItem(index);

+	}

+}

+/**

+ * Set the scroll range of the horizontal scroll bar.

+ * Resize the scroll bar if the scroll range maximum 

+ * has changed.

+ */

+void calculateHorizontalScrollbar() {

+	int newMaximum = getContentWidth();

+	ScrollBar horizontalBar = getHorizontalBar();

+

+	if (horizontalBar.getMaximum() != newMaximum) {

+		// The call to setMaximum is ignored if newMaximum is 0.

+		// Therefore we can not rely on getMaximum to subsequently return the number of 

+		// items in the receiver. We always have to use getVisibleItemCount().

+		// Never rely on getMaximum to return what you set. It may not accept the 

+		// value you set. Even if you use a valid value now the implementation may change 

+		// later. That's what caused 1FRLOSG.

+		horizontalBar.setMaximum(newMaximum);

+		if (getVerticalBar().getVisible() == false) {			// remove these lines 

+			horizontalBar.setMaximum(newMaximum);				// when PR 1FIG5CG 

+		}														// is fixed

+		resizeHorizontalScrollbar();

+	}	

+}

+/**

+ * Calculate the height of items in the receiver.

+ * Only the image height is calculated if an item height 

+ * has already been calculated. Do nothing if both the item 

+ * height and the image height have already been calculated

+ */

+void calculateItemHeight(SelectableItem item) {

+	GC gc;

+	String itemText;

+	int itemHeight = -1;

+

+	if (itemImageExtent != null && textHeight != -1) {

+		return;

+	}

+	itemText = item.getText();

+	if (itemText != null && textHeight == -1) {

+		gc = new GC(this);

+		itemHeight = gc.stringExtent(itemText).y;

+		textHeight = itemHeight;

+		gc.dispose();

+	}

+	if (itemImageExtent == null) {

+		itemImageExtent = getImageExtent(item);

+		if (itemImageExtent != null) {

+			if (itemImageExtent.y > textHeight) {

+				itemHeight = itemImageExtent.y;

+			}

+			else {

+				itemHeight = textHeight;

+			}

+		}

+	}

+	itemHeight += getItemPadding();									// make sure that there is empty space below the image/text

+	if (itemHeight > getItemHeight()) {								// only set new item height if it's higher because new, 

+		setItemHeight(itemHeight);									// smaller item height may not include an icon

+	}

+}

+/**

+ * Calculate the range of items that need to be selected given

+ * the clicked item identified by 'hitItemIndex'

+ * @param hitItemIndex - item that was clicked and that the new

+ *	selection range will be based on. This index is relative to 

+ *	the top index.

+ */

+int [] calculateShiftSelectionRange(int hitItemIndex) {

+	int selectionRange[] = new int[] {-1, -1};

+	SelectableItem closestItem = null;

+	SelectableItem selectedItem;

+	Enumeration selectedItems = getSelectionVector().elements();

+	

+	while (selectedItems.hasMoreElements() == true) {

+		selectedItem = (SelectableItem) selectedItems.nextElement();

+		if (closestItem == null) {

+			closestItem = selectedItem;

+		}

+		else

+		if (Math.abs(hitItemIndex - getVisibleIndex(selectedItem)) < 

+			Math.abs(hitItemIndex - getVisibleIndex(closestItem))) {

+			closestItem = selectedItem;

+		}

+	}

+	if (closestItem == null) {								// no item selected

+		closestItem = getLastSelection();					// item selected last may still have the focus

+	}

+	if (closestItem != null) {

+		selectionRange[0] = getVisibleIndex(closestItem);

+		selectionRange[1] = hitItemIndex;

+	}

+	return selectionRange;

+}

+/**

+ * Set the scroll range of the vertical scroll bar.

+ * Resize the scroll bar if the scroll range maximum 

+ * has changed.

+ */

+void calculateVerticalScrollbar() {

+	int newMaximum = getVisibleItemCount();

+	ScrollBar verticalBar = getVerticalBar();

+

+	// The call to setMaximum is ignored if newMaximum is 0.

+	// Therefore we can not rely on getMaximum to subsequently return the number of 

+	// items in the receiver. We always have to use getVisibleItemCount().

+	// Never rely on getMaximum to return what you set. It may not accept the 

+	// value you set. Even if you use a valid value now the implementation may change 

+	// later. That's what caused 1FRLOSG.

+	verticalBar.setMaximum(newMaximum);

+	if (getHorizontalBar().getVisible() == false) {			// remove these lines 

+		verticalBar.setMaximum(newMaximum);					// when PR 1FIG5CG 

+	}														// is fixed	

+	resizeVerticalScrollbar();

+}

+

+/**

+ * Answer the size of the receiver needed to display all items.

+ * The length of the longest item in the receiver is used for the 

+ * width.

+ */

+public Point computeSize(int wHint, int hHint, boolean changed) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);	

+	int width = getContentWidth();

+	int height = getItemCount() * getItemHeight();

+	int style = getStyle();

+	int scrollBarWidth = computeTrim(0, 0, 0, 0).width;

+				

+	if (width == 0) {

+		width = DEFAULT_WIDTH;

+	}

+	if (height == 0) {

+		height = DEFAULT_HEIGHT;

+	}

+	if (wHint != SWT.DEFAULT) {

+		width = wHint;

+	}

+	if (hHint != SWT.DEFAULT) {

+		height = hHint;

+	}

+	if ((getStyle() & SWT.V_SCROLL) != 0) {

+		width += scrollBarWidth; 

+	}

+	if ((getStyle() & SWT.H_SCROLL) != 0) {

+		height += scrollBarWidth;

+	}

+	return new Point(width, height);

+}

+/**

+ * Do a ctrl+shift selection meaning the ctrl and shift keys 

+ * were pressed when the mouse click on an item occurred. 

+ * If an already selected item was clicked the focus is moved to 

+ * that item.

+ * If the previous selection was a ctrl or ctrl+shift selection

+ * the range between the last selected item and the clicked item

+ * is selected.

+ * Otherwise a regular shift selection is performed.

+ * @param hitItem - specifies the clicked item

+ * @param hitItemIndex - specifies the index of the clicked item 

+ *	relative to the first item.

+ */

+void ctrlShiftSelect(SelectableItem hitItem, int hitItemIndex) {

+	int fromIndex = -1;

+	int toIndex = -1;

+	int lastSelectionIndex = -1;

+	int selectionRange[];

+	SelectableItem lastSelection = getLastSelection();

+

+	if (lastSelection != null) {

+		lastSelectionIndex = getVisibleIndex(lastSelection);

+	}

+	if ((getSelectionVector().contains(hitItem) == true) &&		// clicked an already selected item?

+		(hitItemIndex != lastSelectionIndex)) {				// and click was not on last selected item?

+		setLastSelection(hitItem, true);							// set last selection which also sets the focus

+	}

+	else

+	if (isCtrlSelection() == true) {						// was last selection ctrl/ctrl+shift selection? 

+		fromIndex = lastSelectionIndex;						// select from last selection

+		toIndex = hitItemIndex;

+	}

+	else {													// clicked outside existing selection range

+		selectionRange = calculateShiftSelectionRange(hitItemIndex);

+		fromIndex = selectionRange[0];

+		toIndex = selectionRange[1];

+	}

+	if (fromIndex != -1 && toIndex != -1) {

+		selectRange(fromIndex, toIndex);

+	}

+}

+/**

+ * Deselect 'item'.

+ * @param item - item that should be deselected

+ */

+void deselect(SelectableItem item) {

+	Vector selectedItems = getSelectionVector();

+	

+	if ((item != null) && (item.isSelected() == true)) {

+		item.setSelected(false);

+		redrawSelection(item);

+		selectedItems.removeElement(item);

+	}

+}

+/**

+ * Deselect all item except 'keepSelected'. 

+ * @param keepSelected - item that should remain selected

+ */

+void deselectAllExcept(SelectableItem keepSelected) {

+	Vector selectedItems = getSelectionVector();

+	Vector deselectedItems = new Vector(selectedItems.size());

+	Enumeration elements = selectedItems.elements();

+	SelectableItem item;

+

+	// deselect and repaint previously selected items

+	while (elements.hasMoreElements() == true) {

+		item = (SelectableItem) elements.nextElement();

+		if (item.isSelected() == true && item != keepSelected) {		

+			item.setSelected(false);

+			// always redraw the selection, even if item is redrawn again 

+			// in setLastSelection. Fixes 1G0GQ8W

+			redrawSelection(item);

+			deselectedItems.addElement(item);

+		}

+	}

+	elements = deselectedItems.elements();

+	while (elements.hasMoreElements() == true) {

+		item = (SelectableItem) elements.nextElement();

+		selectedItems.removeElement(item);

+	}

+	setLastSelection(keepSelected, false);

+}

+/**

+ * Deselect all items except those in 'keepSelected'. 

+ * @param keepSelected - items that should remain selected

+ */

+void deselectAllExcept(Vector keepSelected) {

+	Vector selectedItems = getSelectionVector();

+	Vector deselectedItems = new Vector(selectedItems.size());

+	Enumeration elements = selectedItems.elements();

+	SelectableItem item;

+

+	// deselect and repaint previously selected items

+	while (elements.hasMoreElements() == true) {

+		item = (SelectableItem) elements.nextElement();

+		if (item.isSelected() == true && keepSelected.contains(item) == false) {		

+			item.setSelected(false);

+			// always redraw the selection, even if item is redrawn again 

+			// in setLastSelection. Fixes 1G0GQ8W

+			redrawSelection(item);

+			deselectedItems.addElement(item);

+		}

+	}

+	elements = deselectedItems.elements();

+	while (elements.hasMoreElements() == true) {

+		item = (SelectableItem) elements.nextElement();

+		selectedItems.removeElement(item);

+	}

+	if (keepSelected.size() > 0) {

+		setLastSelection((SelectableItem) keepSelected.firstElement(), false);

+	}

+}

+/**

+ * Deselect 'item'. Notify listeners.

+ * @param item - item that should be deselected

+ */

+void deselectNotify(SelectableItem item) {

+	Event event = new Event();

+

+	if (item.isSelected() == true) {

+		deselect(item);

+		setLastSelection(item, true);		

+		update();												// looks better when event notification takes long to return

+	}

+	event.item = item;

+	notifyListeners(SWT.Selection, event);

+}

+/**

+ * Deselect all items starting at and including 'fromIndex'

+ * stopping at and including 'toIndex'.

+ * @param fromIndex - index relative to the first item where 

+ *	deselection should start. Deselecion includes 'fromIndex'.

+ * @param toIndex - index relative to the first item where

+ *	deselection should stop. Deselecion includes 'toIndex'.

+ */

+void deselectRange(int fromIndex, int toIndex) {

+	if (fromIndex > toIndex) {

+		for (int i = toIndex; i <= fromIndex; i++) {

+			deselect(getVisibleItem(i));

+		}

+	}

+	else

+	if (fromIndex < toIndex) {		

+		for (int i = toIndex; i >= fromIndex; i--) {

+			deselect(getVisibleItem(i));

+		}

+	}

+	setLastSelection(getVisibleItem(fromIndex), true);

+}

+/**

+ * Modifier Key		Action

+ * None				Remove old selection, move selection down one item

+ * Ctrl				Keep old selection, move input focus down one item

+ * Shift			Extend selection by one item.

+ * Modifier Key is ignored when receiver has single selection style.

+ * @param keyMask - the modifier key that was pressed

+ */

+void doArrowDown(int keyMask) {

+	SelectableItem lastFocus = getLastFocus();

+	SelectableItem newFocus;

+	int focusItemIndex = getVisibleIndex(lastFocus);

+	

+	if (focusItemIndex < (getVisibleItemCount() - 1)) { 			// - 1 because indices are 0 based

+		focusItemIndex++;

+		newFocus = getVisibleItem(focusItemIndex);

+		if (keyMask == SWT.CTRL && isMultiSelect() == true) {

+			setLastFocus(newFocus, true);

+		}

+		else

+		if (keyMask == SWT.SHIFT && isMultiSelect() == true) {

+			shiftSelect(newFocus, focusItemIndex);

+		}		

+		else {

+			deselectAllExcept(newFocus);

+			selectNotify(newFocus);

+		}

+	}

+}

+/**

+ * Modifier Key		Action

+ * None				Scroll receiver to the left

+ * Ctrl				See None above

+ * Shift			See None above

+ * @param keyMask - the modifier key that was pressed

+ */

+void doArrowLeft(int keyMask) {

+	ScrollBar horizontalBar = getHorizontalBar();

+	int scrollSelection = horizontalBar.getSelection();

+	int scrollAmount;

+

+	if (horizontalBar.getVisible() == false) {

+		return;

+	}	

+	scrollAmount = Math.min(HORIZONTAL_SCROLL_INCREMENT, scrollSelection);

+	horizontalBar.setSelection(scrollSelection - scrollAmount);

+	setHorizontalOffset(horizontalBar.getSelection() * -1);

+}

+/**

+ * Modifier Key		Action

+ * None				Scroll receiver to the right

+ * Ctrl				See None above

+ * Shift			See None above

+ * @param keyMask - the modifier key that was pressed

+ */

+void doArrowRight(int keyMask) {

+	ScrollBar horizontalBar = getHorizontalBar();

+	int scrollSelection = horizontalBar.getSelection();

+	int scrollAmount;

+

+	if (horizontalBar.getVisible() == false) {

+		return;

+	}

+	scrollAmount = Math.min(									// scroll by the smaller of 

+		HORIZONTAL_SCROLL_INCREMENT, 							// the scroll increment

+		horizontalBar.getMaximum() 								// and the remaining scroll range

+			- horizontalBar.getPageIncrement() 

+			- scrollSelection);	

+	horizontalBar.setSelection(scrollSelection + scrollAmount);

+	setHorizontalOffset(horizontalBar.getSelection() * -1);

+}

+/**

+ * Modifier Key		Action

+ * None				Remove old selection, move selection up one item

+ * Ctrl				Keep old selection, move input focus up one item

+ * Shift			Extend selection by one item.

+ * Modifier Key is ignored when receiver has single selection style. 

+ * @param keyMask - the modifier key that was pressed

+ */

+void doArrowUp(int keyMask) {

+	SelectableItem lastFocus = getLastFocus();

+	SelectableItem newFocus;

+	int focusItemIndex = getVisibleIndex(lastFocus);

+	

+	if (focusItemIndex > 0) {

+		focusItemIndex--;

+		newFocus = getVisibleItem(focusItemIndex);

+		if (keyMask == SWT.CTRL && isMultiSelect() == true) {

+			setLastFocus(newFocus, true);

+		}

+		else

+		if (keyMask == SWT.SHIFT && isMultiSelect() == true) {

+			shiftSelect(newFocus, focusItemIndex);

+		}		

+		else {

+			deselectAllExcept(newFocus);

+			selectNotify(newFocus);

+		}

+	}

+}

+/**

+ * Perform a selection operation on the item check box.

+ * @param item - the item that was clicked

+ */

+void doCheckItem(SelectableItem item) {

+	Event event = new Event();

+	

+	item.setChecked(!item.getChecked());

+	event.item = item;

+	event.detail = SWT.CHECK;

+	notifyListeners(SWT.Selection, event);

+}

+/**

+ * Free resources.

+ */

+void doDispose() {

+	setRemovingAll(true);

+	getSelectionVector().removeAllElements();

+	lastFocusItem = null;

+	lastSelectedItem = null;		

+	if (uncheckedImage != null) {

+		uncheckedImage.dispose();

+	}	

+	if (grayUncheckedImage != null) {

+		grayUncheckedImage.dispose();

+	}

+	if (checkMarkImage != null) {

+		checkMarkImage.dispose();

+	}

+}

+/**

+ * Modifier Key		Action

+ * None				Remove old selection, move selection to the 

+ *					last item

+ * Ctrl				Keep old selection, move input focus to the 

+ *					last item

+ * Shift			Extend selection to the last item.

+ * Modifier Key is ignored when receiver has single selection style.

+ * @param keyMask - the modifier key that was pressed

+ */

+void doEnd(int keyMask) {

+	SelectableItem lastFocus = getLastFocus();

+	SelectableItem newFocus;

+	int focusItemIndex = getVisibleIndex(lastFocus);

+	int lastItemIndex = getVisibleItemCount() - 1;				// - 1 because indices are 0 based

+		

+	if (focusItemIndex < lastItemIndex) {

+		newFocus = getVisibleItem(lastItemIndex);

+		if (keyMask == SWT.CTRL && isMultiSelect() == true) {

+			setLastFocus(newFocus, true);

+		}

+		else

+		if (keyMask == SWT.SHIFT && isMultiSelect() == true) {

+			shiftSelect(newFocus, lastItemIndex);

+		}

+		else {

+			deselectAllExcept(newFocus);

+			selectNotify(newFocus);

+		}

+	}

+}

+/**

+ * Modifier Key		Action

+ * None				Remove old selection, move selection to the 

+ *					first item

+ * Ctrl				Keep old selection, move input focus to the 

+ *					first item

+ * Shift			Extend selection to the first item.

+ * Modifier Key is ignored when receiver has single selection style. 

+ * @param keyMask - the modifier key that was pressed

+ */

+void doHome(int keyMask) {

+	SelectableItem lastFocus = getLastFocus();

+	SelectableItem newFocus;

+	int firstItemIndex = 0;

+

+	if (getVisibleIndex(lastFocus) > firstItemIndex) {

+		newFocus = getVisibleItem(firstItemIndex);

+		if (keyMask == SWT.CTRL && isMultiSelect() == true) {

+			setLastFocus(newFocus, true);

+		}

+		else

+		if (keyMask == SWT.SHIFT && isMultiSelect() == true) {

+			shiftSelect(newFocus, firstItemIndex);

+		}		

+		else {

+			deselectAllExcept(newFocus);

+			selectNotify(newFocus);

+		}

+	}

+}

+/**

+ * Perform a mouse select action according to the key state 

+ * mask in 'eventStateMask'.

+ * Key state mask is ignored when receiver has the single selection 

+ * style.

+ * @param item - the item that was clicked

+ * @param itemIndex - the index of the clicked item relative 

+ *	to the first item of the receiver

+ * @param eventStateMask - the key state mask of the mouse event

+ * @param button - the mouse button that was pressed

+ */

+void doMouseSelect(SelectableItem item, int itemIndex, int eventStateMask, int button) {

+	if (((eventStateMask & SWT.CTRL) != 0) &&

+		((eventStateMask & SWT.SHIFT) != 0) &&

+		(isMultiSelect() == true)) {

+		if (getSelectionVector().size() == 0) {			// no old selection?

+			selectNotify(item);							// do standard CTRL selection

+		}

+		else {

+			ctrlShiftSelect(item, itemIndex);

+		}

+		setCtrlSelection(true);

+	}

+	else 

+	if (((eventStateMask & SWT.SHIFT) != 0) && (isMultiSelect() == true)) {

+		shiftSelect(item, itemIndex);

+		setCtrlSelection(false);

+	}

+	else

+	if (((eventStateMask & SWT.CTRL) != 0) && (isMultiSelect() == true)) {

+		toggleSelectionNotify(item);

+		setCtrlSelection(true);

+	}

+	else

+	if (button != 3 || item.isSelected() == false) {

+		// only select the item (and deselect all others) if the mouse click is 

+		// not a button 3 click or if a previously unselected item was clicked.

+		// Fixes 1G97L65

+		deselectAllExcept(item);

+		selectNotify(item);

+		setCtrlSelection(false);

+	}

+}

+/**

+ * Modifier Key		Action

+ * None				Remove old selection, move selection one page down

+ * Ctrl				Keep old selection, move input focus one page down

+ * Shift			Extend selection one page down

+ * One page is the number of items that can be displayed in the 

+ * receiver's canvas without truncating the last item.

+ * The selection is set to the last item if there is no full page 

+ * of items left.

+ * Modifier Key is ignored when receiver has single selection style.  

+ * @param keyMask - the modifier key that was pressed

+ */

+void doPageDown(int keyMask) {

+	SelectableItem newFocus;

+	int focusItemIndex = getVisibleIndex(getLastFocus());

+	int lastItemIndex = getVisibleItemCount() - 1;				// - 1 because indices are 0 based

+	int visibleItemCount;

+		

+	if (focusItemIndex < lastItemIndex) {

+		visibleItemCount = getItemCountWhole();

+		focusItemIndex = Math.min(

+			lastItemIndex, 

+			focusItemIndex + (visibleItemCount - 1));

+		newFocus = getVisibleItem(focusItemIndex);

+		if (newFocus == null) {

+			return;

+		}

+		if (keyMask == SWT.CTRL && isMultiSelect() == true) {

+			setLastFocus(newFocus, true);

+		}

+		else

+		if (keyMask == SWT.SHIFT && isMultiSelect() == true) {

+			shiftSelect(newFocus, focusItemIndex);

+		}		

+		else {

+			deselectAllExcept(newFocus);		

+			selectNotify(newFocus);

+		}

+	}

+}

+/**

+ * Modifier Key		Action

+ * None				Remove old selection, move selection one page up

+ * Ctrl				Keep old selection, move input focus one page up

+ * Shift			Extend selection one page up

+ * One page is the number of items that can be displayed in the 

+ * receiver's canvas without truncating the last item.

+ * The selection is set to the first item if there is no full page 

+ * of items left.

+ * Modifier Key is ignored when receiver has single selection style.  

+ * @param keyMask - the modifier key that was pressed

+ */

+void doPageUp(int keyMask) {

+	SelectableItem newFocus;	

+	int focusItemIndex = getVisibleIndex(getLastFocus());

+	int visibleItemCount;

+

+	if (focusItemIndex > 0) {

+		visibleItemCount = getItemCountWhole();

+		focusItemIndex = Math.max(

+			0, 

+			focusItemIndex - (visibleItemCount - 1));

+		newFocus = getVisibleItem(focusItemIndex);

+		if (keyMask == SWT.CTRL && isMultiSelect() == true) {

+			setLastFocus(newFocus, true);

+		}

+		else

+		if (keyMask == SWT.SHIFT && isMultiSelect() == true) {

+			shiftSelect(newFocus, focusItemIndex);

+		}		

+		else {

+			deselectAllExcept(newFocus);		

+			selectNotify(newFocus);

+		}

+	}

+}

+/**

+ * Modifier Key		Action

+ * Ctrl				Keep old selection, toggle selection of the item 

+ *					that has the input focus

+ * Shift			Extend selection to the item that has the input 

+ *					focus

+ * Ctrl & Shift		Set selection to the item that has input focus

+ * Do nothing if receiver has single selection style.

+ * @param keyMask - the modifier key that was pressed

+ */

+

+void doSpace(int keyMask) {

+	SelectableItem item = getLastFocus();

+	int itemIndex = getVisibleIndex(item);

+

+	if (keyMask == SWT.NULL && item.isSelected() == false) {	// do simple space select in SINGLE and MULTI mode

+		deselectAllExcept(item);

+		selectNotify(item);

+		return;

+	}

+	if (isMultiSelect() == false || item == null) {

+		return;

+	}

+	if (keyMask == SWT.CTRL) {

+		toggleSelectionNotify(item);

+	}

+	else

+	if (((keyMask & SWT.CTRL) != 0) && ((keyMask & SWT.SHIFT) != 0)) {

+		deselectAllExcept(item);

+		selectNotify(item);

+	}

+	else

+	if (keyMask == SWT.SHIFT) {

+		shiftSelect(item, itemIndex);

+	}

+}

+/**

+ * Make sure that free space at the bottom of the receiver is 

+ * occupied.

+ * There will be new space available below the last item when the 

+ * receiver's height is increased. In this case the receiver

+ * is scrolled down to occupy the new space.if the top item is 

+ * not the first item of the receiver.

+ */

+void claimBottomFreeSpace() {

+	int clientAreaItemCount = getItemCountWhole();

+	int topIndex = getTopIndex();

+	int newTopIndex;

+	int lastItemIndex = getVisibleItemCount() - topIndex;

+

+	if ((topIndex > 0) && 

+		(lastItemIndex > 0) &&

+		(lastItemIndex < clientAreaItemCount)) {

+		newTopIndex = Math.max(0, topIndex-(clientAreaItemCount-lastItemIndex));

+		setTopIndex(newTopIndex, true);

+	}

+}

+/**

+ * Make sure that free space at the right side of the receiver is 

+ * occupied. 

+ * There will be new space available at the right side of the receiver 

+ * when the receiver's width is increased. In this case the receiver 

+ * is scrolled to the right to occupy the new space.if possible.

+ */

+void claimRightFreeSpace() {

+	int clientAreaWidth = getClientArea().width;

+	int newHorizontalOffset = clientAreaWidth - getContentWidth();

+	

+	if (newHorizontalOffset - getHorizontalOffset() > 0) {			// item is no longer drawn past the right border of the client area

+		newHorizontalOffset = Math.min(0, newHorizontalOffset);		// align the right end of the item with the right border of the 

+		setHorizontalOffset(newHorizontalOffset);					// client area (window is scrolled right)	

+	}

+}

+/**	Not used right now. Replace focusIn/focusOut with this method once 

+ *	Display.getFocusWindow returns the new focus window on FocusOut event 

+ *	(see 1FMITIE)

+ * The focus has moved in to or out of the receiver.

+ * Redraw the item selection to reflect the focus change.

+ * @param event - the focus change event

+ */

+void focusChange(Event event) {

+	Enumeration items = getSelectionVector().elements();

+	SelectableItem lastFocusItem = getLastFocus();

+	SelectableItem item;

+

+	while (items.hasMoreElements() == true) {

+		item = (SelectableItem) items.nextElement();

+		redrawSelection(item);

+	}

+	if (lastFocusItem != null) {

+		redrawSelection(lastFocusItem);

+	}

+}

+/**

+ * The focus has moved in to or out of the receiver.

+ * Redraw the item selection to reflect the focus change.

+ * @param event - the focus change event

+ */

+void focusIn(Event event) {

+	Enumeration items = getSelectionVector().elements();

+	SelectableItem lastFocusItem = getLastFocus();

+	SelectableItem item;

+

+	// Workaround for 1FMITIE

+	hasFocus = true;

+	while (items.hasMoreElements() == true) {

+		item = (SelectableItem) items.nextElement();

+		redrawSelection(item);

+	}

+	if (lastFocusItem != null) {

+		redrawSelection(lastFocusItem);

+	}

+	// Fix blank item on slow machines/VMs. Also fixes 1G0IFMZ. 

+	update();

+}

+/**

+ * The focus has moved in to or out of the receiver.

+ * Redraw the item selection to reflect the focus change.

+ * @param event - the focus change event

+ */

+void focusOut(Event event) {

+	Enumeration items = getSelectionVector().elements();

+	SelectableItem lastFocusItem = getLastFocus();

+	SelectableItem item;

+

+	// Workaround for 1FMITIE

+	hasFocus = false;

+	while (items.hasMoreElements() == true) {

+		item = (SelectableItem) items.nextElement();

+		redrawSelection(item);

+	}

+	if (lastFocusItem != null) {

+		redrawSelection(lastFocusItem);

+	}

+	// Fix blank item on slow machines/VMs. Also fixes 1G0IFMZ. 

+	update();								

+}

+/**

+ * Answer the index of the last item position in the receiver's 

+ * client area.

+ * @return 0-based index of the last item position in the tree's 

+ * 	client area.

+ */

+int getBottomIndex() {

+	return getTopIndex() + getItemCountTruncated(getClientArea());

+}

+/**

+ * Answer the size of the check box image.

+ * The calculation is cached and assumes that the images for 

+ * the checked and unchecked state are the same size.

+ */

+Point getCheckBoxExtent() {

+	Image checkedImage;

+	Rectangle imageBounds;

+	

+	if (checkBoxExtent == null) {

+		checkedImage = getUncheckedImage();

+		if (checkedImage != null) {

+			imageBounds = checkedImage.getBounds();

+			checkBoxExtent = new Point(imageBounds.width, imageBounds.height);

+		}

+		else {

+			checkBoxExtent = new Point(0, 0);

+		}

+	}

+	return checkBoxExtent;

+}

+/**

+ * Answer the image for the selected check box

+ * Answer null if the image couldn't be loaded.

+ */

+Image getCheckMarkImage() {

+	InputStream resourceStream;

+	

+	if (checkMarkImage == null) {

+		checkMarkImage = new Image(getDisplay(), CheckMarkImageData);

+	}

+	return checkMarkImage;

+}

+/**

+ * Answer the width of the receiver's content. 

+ * Needs to be set by subclasses.

+ */

+int getContentWidth() {

+	return contentWidth;

+}

+/**

+ * Answer the horizontal drawing offset used for scrolling.

+ * This is < 0 if the receiver has been scrolled to the left,

+ * > 0 if the receiver has been scrolled to the right and 0

+ * if the receiver has not been scrolled.

+ */

+int getHorizontalOffset() {

+	return horizontalOffset;

+}

+

+/**

+ * Answer the size of item images. Calculated during the item 

+ * height calculation.

+ */

+Point getImageExtent() {

+	return itemImageExtent;

+}

+/**

+ * Answer the image extent of 'item'. Overridden by subclasses.

+ */

+Point getImageExtent(SelectableItem item) {

+	Image image = item.getImage();

+	Rectangle imageBounds;

+	Point imageExtent = null;

+

+	if (image != null) {

+		imageBounds = image.getBounds();

+		imageExtent = new Point(imageBounds.width, imageBounds.height);

+	}

+	return imageExtent;

+}

+/**

+ * Answer the index of 'item' in the receiver.

+ */

+abstract int getIndex(SelectableItem item);

+/** 

+ * Answer the first and last index of items that can be displayed in 

+ * the area defined by 'clipRectangle'. This includes partial items.

+ * @return

+ *	Array - 

+ *		First element is the index of the first item in 'clipRectangle'.

+ *		Second element is the index of the last item in 'clipRectangle'.

+ */

+int[] getIndexRange(Rectangle clipRectangle) {

+	int visibleRange[] = new int[] {0, 0};

+

+	visibleRange[0] = clipRectangle.y / getItemHeight();

+	visibleRange[1] = 

+		visibleRange[0] + 

+		getItemCountTruncated(clipRectangle) - 1;			// - 1 because item index is 0 based

+	return visibleRange;

+}

+/**

+ * Return the item that draws the marker indicating the insert location 

+ * in a drag and drop operation

+ */

+SelectableItem getInsertItem() {

+	return insertItem;

+}

+/**

+ * Answer the number of items in the receiver.

+ */

+public abstract int getItemCount();

+/**

+ * Answer the number of items that can be displayed in 'rectangle'.

+ * The result includes partially visible items.

+ */

+int getItemCountTruncated(Rectangle rectangle) {

+	int itemHeight = getItemHeight();

+	int itemCount = 0;

+	int startIndex;

+

+	startIndex = rectangle.y / itemHeight;

+	itemCount = (int) Math.ceil(((float) rectangle.y + rectangle.height) / itemHeight)-startIndex;

+	return itemCount;

+}

+/**

+ * Answer the number of items that can be displayed in the client 

+ * area of the receiver.

+ * The result only includes items that completely fit into the 

+ * client area.

+ */

+int getItemCountWhole() {

+	return getClientArea().height / getItemHeight();

+}

+/**

+ * Answer the height of an item in the receiver.

+ * The item height is the greater of the item icon height and 

+ * text height of the first item that has text or an image 

+ * respectively.

+ * Calculate a default item height based on the font height if

+ * no item height has been calculated yet.

+ */

+public int getItemHeight() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	GC gc;

+	if (itemHeight == 0) {

+		gc = new GC(this);

+		itemHeight = gc.stringExtent("String").y + getItemPadding();		// initial item height=font height + item spacing

+											// use real font height here when available in SWT, instead of GC.textExtent

+		gc.dispose();

+	}		

+	return itemHeight;

+}

+/**

+ * Answer the number of pixels that should be added to the item height.

+ */

+int getItemPadding() {

+	return 2 + getDisplay().textHighlightThickness;

+}

+/**

+ * Answer the item that most recently received the input focus.

+ */

+SelectableItem getLastFocus() {

+	return lastFocusItem;

+}

+/**

+ * Answer the item that was selected most recently.

+ */ 

+SelectableItem getLastSelection() {

+	return lastSelectedItem;

+}

+/**

+ * Answer the event listener used for all events. Events are 

+ * dispatched to handler methods in handleEvents(Event).

+ * This scheme saves a lot of inner classes.

+ */

+Listener getListener() {

+	return listener;

+}

+/**

+ * Answer the y coordinate at which 'item' is drawn. 

+ * @param item - SelectableItem for which the paint position 

+ *	should be returned

+ * @return the y coordinate at which 'item' is drawn.

+ *	Return -1 if 'item' is not an item of the receiver

+ */

+int getRedrawY(SelectableItem item) {

+	int redrawIndex = getVisibleIndex(item);

+	int redrawY = -1;

+

+	if (redrawIndex != -1) {

+		redrawY = (redrawIndex - getTopIndex()) * getItemHeight();

+	}

+	return redrawY;

+}

+/**

+ * Answer the number of selected items in the receiver.

+ */

+public int getSelectionCount() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return getSelectionVector().size();

+}

+/**

+ * Answer the selected items of the receiver. 

+ * @return The selected items of the receiver stored in a Vector.

+ *	Returned Vector is empty if no items are selected.

+ */

+Vector getSelectionVector() {

+	return selectedItems;

+}

+/**

+ * Answer the width of 'text' in pixel.

+ * Answer 0 if 'text' is null.

+ */

+int getTextWidth(String text) {

+	int textWidth = 0;

+	GC gc;

+

+	if (text != null) {

+		gc = new GC(this);

+		textWidth = gc.stringExtent(text).x;

+		gc.dispose();

+	}

+	return textWidth;

+}

+/**

+ * Answer the index of the first visible item in the receiver's 

+ * client area.

+ * @return 0-based index of the first visible item in the 

+ * 	receiver's client area.

+ */

+int getTopIndex() {

+	return topIndex;

+}

+/**

+ * Answer the image for the deselected check box.

+ */

+Image getUncheckedImage() {

+	InputStream resourceStream;

+	

+	if (uncheckedImage == null) {

+		uncheckedImage = new Image(getDisplay(), UncheckedImageData);

+	}

+	return uncheckedImage;

+}

+

+/**

+ * Answer the image for the grayed eck box.

+ */

+Image getGrayUncheckedImage() {

+	InputStream resourceStream;

+	

+	if (grayUncheckedImage == null) {

+		grayUncheckedImage = new Image(getDisplay(), GrayUncheckedImageData);

+	}

+	return grayUncheckedImage;

+}

+

+/**

+ * Answer the index of 'item' in the receiver.

+ * Answer -1 if the item is not visible.

+ * The returned index must refer to a visible item.

+ * Note: 

+ * 	Visible in this context does not neccessarily mean that the 

+ * 	item is displayed on the screen. It only means that the item 

+ * 	would be displayed if it is located inside the receiver's 

+ * 	client area.

+ *	Normally, every item of the receiver is visible.

+ */

+abstract int getVisibleIndex(SelectableItem item);

+/**

+ * Answer the SelectableItem located at 'itemIndex' in the 

+ * receiver.

+ * @param itemIndex - location of the SelectableItem object 

+ *	to return

+ */

+abstract SelectableItem getVisibleItem(int itemIndex);

+/**

+ * Answer the number of visible items of the receiver.

+ * Note: 

+ * 	Visible in this context does not neccessarily mean that the 

+ * 	item is displayed on the screen. It only means that the item 

+ * 	would be displayed if it is located inside the receiver's 

+ * 	client area.

+ *	Normally every item of the receiver is visible.

+ */

+int getVisibleItemCount() {

+	return getItemCount();

+}

+/**

+ * Answer the y coordinate at which 'item' is drawn. 

+ * @param item - SelectableItem for which the paint position 

+ *	should be returned

+ * @return the y coordinate at which 'item' is drawn.

+ *	Return -1 if 'item' is null or outside the client area

+ */

+abstract int getVisibleRedrawY(SelectableItem item);

+/**

+ * Handle the events the receiver is listening to.

+ */

+void handleEvents(Event event) {

+	switch (event.type) {

+		case SWT.Dispose:

+			doDispose();

+			break;		

+		case SWT.KeyDown:

+			keyDown(event);

+			break;

+		case SWT.Resize:

+			resize(event);

+			break;

+		case SWT.Selection:

+			if (event.widget == getVerticalBar()) {

+				scrollVertical(event);

+			}

+			else

+			if (event.widget == getHorizontalBar()) {

+				scrollHorizontal(event);

+			}

+			break;

+		case SWT.FocusOut:

+			focusOut(event);

+			break;

+		case SWT.FocusIn:

+			focusIn(event);

+			break;			

+	}	

+}

+

+

+

+/**

+ * Answer whether 'item' has the input focus.

+ */

+boolean hasFocus(SelectableItem item) {

+	return (isFocusControl() && item == getLastFocus());

+}

+/**

+ * Initialize the receiver. Add event listeners and set widget 

+ * colors.

+ */

+void initialize() {

+	Display display = getDisplay();	

+	ScrollBar horizontalBar = getHorizontalBar();

+	ScrollBar verticalBar = getVerticalBar();

+

+	// listener may be needed by overridden installListeners()

+	listener = new Listener() {

+		public void handleEvent(Event event) {handleEvents(event);}

+	};	

+	setSelectionVector(new Vector());

+	installListeners();

+	calculateVerticalScrollbar();

+	calculateHorizontalScrollbar();

+	horizontalBar.setMinimum(0);

+	verticalBar.setMinimum(0);

+	horizontalBar.setIncrement(HORIZONTAL_SCROLL_INCREMENT);

+	setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));

+	setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));

+}

+/**

+ * Initialize the ImageData used for the checked/unchecked images.

+ */ 

+static void initializeImageData() {

+	PaletteData uncheckedPalette = new PaletteData(	

+		new RGB[] {new RGB(128, 128, 128), new RGB(255, 255, 255)});

+	PaletteData grayUncheckedPalette = new PaletteData(	

+		new RGB[] {new RGB(128, 128, 128), new RGB(192, 192, 192)});

+	PaletteData checkMarkPalette = new PaletteData(	

+		new RGB[] {new RGB(0, 0, 0), new RGB(252, 3, 251)});

+	byte[] checkbox = new byte[] {0, 0, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 0, 0};

+

+	// Each pixel is represented by one bit in the byte data. 

+	// The bit references the palette position (0 or 1). Each pixel row of an image is padded to one byte.

+	// Arguments: width, height, depth, palette, scanline padding, data

+	UncheckedImageData =		new ImageData(11, 11, 1, uncheckedPalette, 2, checkbox);

+	GrayUncheckedImageData = 	new ImageData(11, 11, 1, grayUncheckedPalette, 2, checkbox);

+	CheckMarkImageData =		new ImageData(7, 7, 1, checkMarkPalette, 1, new byte[] {-4, -8, 112, 34, 6, -114, -34});

+	CheckMarkImageData.transparentPixel = 1;

+}

+/**

+ * Add event listeners to the tree widget and its scroll bars.

+ */

+void installListeners() {

+	Listener listener = getListener();

+	

+	addListener(SWT.Dispose, listener);	

+	addListener(SWT.Resize, listener);

+	addListener(SWT.KeyDown, listener);

+	addListener(SWT.FocusOut, listener);

+	addListener(SWT.FocusIn, listener);

+	

+	getVerticalBar().addListener(SWT.Selection, listener);

+	getHorizontalBar().addListener(SWT.Selection, listener);

+}

+/**

+ * Answer whether the currently selected items were selected 

+ * using the ctrl key.

+ */

+boolean isCtrlSelection() {

+	return isCtrlSelection;

+}

+/**

+ * Answer true if all items in the widget are disposed.

+ * Used to optimize item disposal. Prevents unnecessary screen 

+ * updates.

+ */

+boolean isRemovingAll() {

+	return isRemovingAll;

+}

+/**

+ * Answer whether the receiver has the input focus.

+ * Workaround for 1FMITIE

+ */

+public boolean isFocusControl() {

+	return hasFocus;

+}

+/**

+ * Return whether the drop insert position is before or after the 

+ * item set using motif_setInsertMark.

+ * @return 

+ *	true=insert position is after the insert item

+ *	false=insert position is before the insert item

+ */

+boolean isInsertAfter() {

+	return isInsertAfter;

+}

+/**

+ * Answer whether the receiver has the MULTI selection style set.

+ * @return

+ *	true = receiver is in multiple selection mode.

+ *	false = receiver is in single selection mode.

+ */

+boolean isMultiSelect() {

+	return ((getStyle() & SWT.MULTI) != 0);

+}

+/**

+ * The item identified by 'changedItem' has changed. 

+ * Calculate the item height based on the new item data (it might 

+ * now have an image which could also be the first image in the 

+ * receiver)

+ * Redraw the whole window if the item height has changed. Otherwise 

+ * redraw only the changed item or part of it depending on the 

+ * 'repaintStartX' and 'repaintWidth' parameters.

+ * @param changedItem - the item that has changed

+ * @param repaintStartX - x position of the item redraw. 

+ * @param repaintWidth - width of the item redraw.

+ */

+void itemChanged(SelectableItem changedItem, int repaintStartX, int repaintWidth) {

+	int yPosition;

+	int itemHeight;

+	int oldItemHeight = getItemHeight();

+	Point oldImageExtent = getImageExtent();

+	

+	calculateItemHeight(changedItem);					// make sure that the item height is recalculated

+	// no redraw necessary if redraw width is 0 or item is not visible

+	if (repaintWidth == 0 || (yPosition = getVisibleRedrawY(changedItem)) == -1) {

+		return;

+	}														// if changedItem is the first item with image.

+	itemHeight = getItemHeight();

+	if ((oldItemHeight == itemHeight) &&				// only redraw changed item if the item height and 

+	    (oldImageExtent == getImageExtent())) {			// image size has not changed. The latter will only change once,

+														// from null to a value-so it's safe to test using !=

+		// redrawing outside the client area redraws the widget border on Motif.

+		// adjust the redraw width if necessary. Workaround for 1G4TQRW

+		repaintWidth = Math.min(repaintWidth, getClientArea().width - repaintStartX);

+		if (repaintWidth > 0) {

+			redraw(repaintStartX, yPosition, repaintWidth, itemHeight, true);

+		}

+	}

+	else {

+		redraw();										// redraw all items if the item height has changed

+	}

+}

+/**

+ * A key was pressed. Call the appropriate handler method.

+ * @param event - the key event

+ */

+void keyDown(Event event) {

+	boolean isCtrlSelection = isCtrlSelection();

+	

+	if (event.stateMask != SWT.CTRL) {

+		isCtrlSelection = false;

+	}

+	switch (event.keyCode) {

+		case SWT.ARROW_UP:

+			doArrowUp(event.stateMask);

+			break;

+		case SWT.ARROW_DOWN:

+			doArrowDown(event.stateMask);

+			break;

+		case SWT.ARROW_LEFT:

+			doArrowLeft(event.stateMask);

+			break;

+		case SWT.ARROW_RIGHT:

+			doArrowRight(event.stateMask);

+			break;			

+		case SWT.PAGE_UP:

+			doPageUp(event.stateMask);

+			break;		

+		case SWT.PAGE_DOWN:

+			doPageDown(event.stateMask);

+			break;

+		case SWT.HOME:

+			doHome(event.stateMask);

+			break;

+		case SWT.END:

+			doEnd(event.stateMask);

+			break;

+		default:										// no selection occurred, keep previous 

+			isCtrlSelection = isCtrlSelection();		// selection type information

+	}

+	if (event.character == ' ') {

+		doSpace(event.stateMask);

+		isCtrlSelection = (event.stateMask == SWT.CTRL);

+	}

+	setCtrlSelection(isCtrlSelection);

+}

+/**

+ * Sets the drop insert item.

+ * The drop insert item has a visual hint to show where a dragged item 

+ * will be inserted when dropped on the tree.

+ * <p>

+ * @param item the insert item 

+ * @param after true places the insert mark below 'item'. false places 

+ *	the insert mark above 'item'.

+ */

+void motif_setInsertMark(SelectableItem item, boolean after) {

+	SelectableItem currentItem = getInsertItem();

+	int redrawY;

+	

+	setInsertItem(item);

+	setInsertAfter(after);

+	if (currentItem != null) {

+		redrawY = getVisibleRedrawY(currentItem);

+		if (redrawY != -1) {

+			currentItem.redrawInsertMark(redrawY);

+		}		

+	}

+	if (item != null) {

+		redrawY = getVisibleRedrawY(item);

+		if (redrawY != -1) {

+			item.redrawInsertMark(redrawY);

+		}		

+	}

+}

+

+

+/**

+ * Overridden to implement setRedraw(). Redraw is ignored if setRedraw was 

+ * set to false.

+ */

+public void redraw () {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (drawCount == 0) {

+		super.redraw();

+	}

+}

+/**

+ * Overridden to implement setRedraw(). Redraw is ignored if setRedraw was 

+ * set to false.

+ */

+public void redraw (int x, int y, int width, int height, boolean all) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (drawCount == 0) {

+		super.redraw(x, y, width, height, all);

+	}

+}

+

+/**

+ * Redraw the selection of 'item'

+ * @param item - SelectableItem that should have the selection redrawn.

+ */

+void redrawSelection(SelectableItem item) {

+	int redrawPosition = getVisibleRedrawY(item);

+

+	if (redrawPosition != -1) {

+		item.redrawSelection(redrawPosition);

+	}	

+}

+/**

+ * 'item' has been removed from the receiver. 

+ * Update the display and the scroll bars.

+ */

+void removedItem(SelectableItem item) {

+	claimBottomFreeSpace();

+	calculateVerticalScrollbar();

+	if (getItemCount() == 0) {

+		reset();

+	}

+}

+/**

+ * 'item' is about to be removed from the tree.

+ * Move the selection/input focus if 'item' is selected or has the 

+ * input focus, 

+ * @param item - item that is about to be removed from the tree.

+ */

+void removingItem(SelectableItem item) {

+	SelectableItem nextFocusItem = null;

+	int itemIndex = getVisibleIndex(item);

+	int itemCount = getVisibleItemCount();

+	

+	// deselect item and remove from selection

+	if (item.isSelected() == true) {

+		getSelectionVector().removeElement(item);

+	}

+	if (item == getLastFocus() && itemCount > 1) {

+		// select previous item if removed item is bottom item

+		// otherwise select next item. Fixes 1GA6L85

+		if (itemIndex == itemCount - 1) {

+			nextFocusItem = getVisibleItem(itemIndex - 1);

+		}

+		else {

+			nextFocusItem = getVisibleItem(itemIndex + 1);

+		}

+		setLastFocus(nextFocusItem, true);

+	}

+	// ignore items below widget client area

+	if (itemIndex != -1 && itemIndex <= getBottomIndex()) {			

+		scrollVerticalRemovedItem(itemIndex);

+	}

+}

+/**

+ * Reset state that is dependent on or calculated from the state 

+ * of the receiver.

+ */

+void reset() {

+	setSelectionVector(new Vector());

+	setTopIndexNoScroll(0, true);

+	lastSelectedItem = null;

+	lastFocusItem = null;

+	resetItemData();

+}

+/**

+ * Reset state that is dependent on or calculated from the items

+ * of the receiver.

+ */

+void resetItemData() {

+	setHorizontalOffset(0);

+	setItemHeight(0);

+	itemImageExtent = null;

+	textHeight = -1;	

+	claimRightFreeSpace();

+}

+/**

+ * The receiver has been resized. Update the scroll bars and

+ * make sure that new space is being occupied by items.

+ */

+void resize(Event event) {

+	int horizontalPageSize = getHorizontalBar().getPageIncrement();

+

+	resizeHorizontalScrollbar();

+	resizeVerticalScrollbar();

+	if (getClientArea().width > horizontalPageSize) {		// window resized wider? - Do this check here 

+		claimRightFreeSpace();							// because claimRightFreeSpace is called elsewhere.

+	}

+	claimBottomFreeSpace();

+}

+/**

+ * Display the horizontal scroll bar if items are drawn off 

+ * screen. Update the page size.

+ */

+void resizeHorizontalScrollbar() {

+	ScrollBar horizontalBar = getHorizontalBar();

+	int clientAreaWidth = getClientArea().width;

+

+	if (clientAreaWidth < getContentWidth()) {

+		if (horizontalBar.getVisible() == false) {

+			horizontalBar.setVisible(true);

+			horizontalBar.setSelection(0);

+		}

+	}

+	else 

+	if (horizontalBar.getVisible() == true) {

+		horizontalBar.setVisible(false);

+	}

+	horizontalBar.setThumb(clientAreaWidth);

+	horizontalBar.setPageIncrement(clientAreaWidth);

+}

+/**

+ * Display the vertical scroll bar if items are drawn off screen.

+ * Update the page size.

+ */

+void resizeVerticalScrollbar() {

+	int clientAreaItemCount = getItemCountWhole();

+	ScrollBar verticalBar = getVerticalBar();

+

+	if (clientAreaItemCount == 0) {

+		return;

+	}

+	if (clientAreaItemCount < getVisibleItemCount()) {

+		if (verticalBar.getVisible() == false) {

+			verticalBar.setVisible(true);

+		}

+		// Only set the page size to something smaller than the scroll 

+		// range maximum. Otherwise the scroll selection will be reset.

+		verticalBar.setPageIncrement(clientAreaItemCount);

+		verticalBar.setThumb(clientAreaItemCount);

+	}

+	else

+	if (verticalBar.getVisible() == true) {

+		verticalBar.setVisible(false);

+	}

+}

+/**

+ * Scroll the rectangle specified by x, y, width, height to the destination 

+ * position. Do nothing if redraw is set to false using setRedraw().

+ *

+ * @param destX - destination x position of the scrolled rectangle

+ * @param destY - destination y position of the scrolled rectangle

+ * @param x - x location of the upper left corner of the scroll rectangle

+ * @param y - y location of the upper left corner of the scroll rectangle

+ * @param width - width of the scroll rectangle

+ * @param height - height of the scroll rectangle

+ * @param all - not used. Used to be true=scroll children intersecting the 

+ *	scroll rectangle.

+ */

+void scroll(int destX, int destY, int x, int y, int width, int height, boolean all) {

+	if (drawCount == 0) {

+		update();

+		GC gc = new GC(this);

+		gc.copyArea(x, y, width, height, destX, destY);

+		gc.dispose();

+	}

+}

+/**

+ * Scroll horizontally by 'numPixel' pixel.

+ * @param numPixel - the number of pixel to scroll

+ * 	numPixel > 0 = scroll to left. numPixel < 0 = scroll to right

+ */

+abstract void scrollHorizontal(int numPixel);

+/**

+ * The position of the horizontal scroll bar has been modified 

+ * by the user. 

+ * Adjust the horizontal offset to trigger a horizontal scroll.

+ * @param event-the scroll event

+ */

+void scrollHorizontal(Event event) {

+	setHorizontalOffset(getHorizontalBar().getSelection() * -1);

+}

+/**

+ * Scroll 'item' into the receiver's client area if necessary.

+ * @param item - the item that should be scrolled.

+ */

+void scrollShowItem(SelectableItem item) {

+	int itemIndexFromTop = getIndex(item) - getTopIndex();

+	int clientAreaWholeItemCount = getItemCountWhole();

+	int scrollAmount = 0;

+

+	if (itemIndexFromTop >= clientAreaWholeItemCount) {		// show item below visible items?

+		scrollAmount = itemIndexFromTop;

+		if (clientAreaWholeItemCount > 0) {					// will be 0 if showItem is called and receiver hasn't been displayed yet

+			scrollAmount -= clientAreaWholeItemCount - 1;

+		}

+	}

+	else

+	if (itemIndexFromTop < 0) {								// show item above visible items?

+		scrollAmount = itemIndexFromTop;

+	}

+	setTopIndex(getTopIndex() + scrollAmount, true);

+}

+/**

+ * Scroll vertically by 'scrollIndexCount' items.

+ * @param scrollIndexCount - the number of items to scroll.

+ *	scrollIndexCount > 0 = scroll up. scrollIndexCount < 0 = scroll down

+ */

+abstract void scrollVertical(int scrollIndexCount);

+/**

+ * The position of the horizontal scroll bar has been modified 

+ * by the user.

+ * Adjust the index of the top item to trigger a vertical scroll.

+ * @param event-the scroll event

+ */

+void scrollVertical(Event event) {

+	setTopIndex(getVerticalBar().getSelection(), false);

+}

+/**

+ * Scroll items down to make space for a new item added to 

+ * the receiver at position 'index'.

+ * @param index - position at which space for one new item

+ *	should be made. This index is relative to the first item 

+ *	of the receiver.

+ */

+void scrollVerticalAddingItem(int index) {

+	Rectangle clientArea = getClientArea();

+	int itemHeight = getItemHeight();

+	int sourceY = Math.max(0, (index - getTopIndex()) * itemHeight);	// need to scroll in visible area

+

+	scroll(

+		0, sourceY + itemHeight, 						// destination x, y

+		0, sourceY, 									// source x, y

+		clientArea.width, clientArea.height, true);

+}

+/**

+ * Scroll the items below the item at position 'index' up 

+ * so that they cover the removed item.

+ * @param index - index of the removed item

+ */

+void scrollVerticalRemovedItem(int index) {

+	Rectangle clientArea = getClientArea();

+	int itemHeight = getItemHeight();

+	int destinationY = Math.max(0, (index - getTopIndex()) * itemHeight);

+

+	scroll(

+		0, destinationY, 						// destination x, y

+		0, destinationY + itemHeight, 			// source x, y

+		clientArea.width, clientArea.height, true);

+}

+/**

+ * Select 'item' if it is not selected.

+ * @param item - item that should be selected

+ */

+void select(SelectableItem item) {

+	Vector selectedItems = getSelectionVector();

+	

+	if (item != null && item.isSelected() == false && isRemovingAll() == false) {

+		item.setSelected(true);

+		redrawSelection(item);

+		selectedItems.addElement(item);

+	}

+}

+/**

+ * Select 'item' if it is not selected. Send a Selection event 

+ * if the selection was changed.

+ * @param item - item that should be selected

+ * @param asyncNotify 

+ *  true=send the selection event asynchronously

+ *  false=send the selection event immediately

+ */

+void selectNotify(final SelectableItem item, boolean asyncNotify) {

+	if (isRemovingAll() == false) {

+		if (item.isSelected() == false) {

+			select(item);

+			setLastSelection(item, true);

+			update();												// looks better when event notification takes long to return

+		}

+		if (asyncNotify == false) {

+			Event event = new Event();

+			event.item = item;

+			notifyListeners(SWT.Selection, event);

+		}

+		else {

+			getDisplay().asyncExec(new Runnable() {

+				public void run() {

+					// Only send a selection event when the item has not been disposed.

+					// Fixes 1GE6XQA

+					if (item.isDisposed() == false) {

+						Event event = new Event();

+						event.item = item;

+						notifyListeners(SWT.Selection, event);

+					}

+				}

+			});

+		}

+	}

+}

+/**

+ * Select 'item' if it is not selected. Send a Selection event 

+ * if the selection was changed.

+ * @param item - item that should be selected

+ */

+void selectNotify(SelectableItem item) {

+	selectNotify(item, false);

+}

+/**

+ * Select all items of the receiver starting at 'fromIndex' 

+ * and including 'toIndex'.

+ */

+void selectRange(int fromIndex, int toIndex) {

+	if (fromIndex > toIndex) {

+		for (int i = fromIndex; i > toIndex; i--) {

+			select(getVisibleItem(i));

+		}

+	}

+	else {

+		for (int i = fromIndex; i < toIndex; i++) {

+			select(getVisibleItem(i));			

+		}

+	}

+	selectNotify(getVisibleItem(toIndex));				// select last item, notifying listeners

+}

+/**

+ * Set the width of the receiver's contents to 'newWidth'.

+ * Content width is used to calculate the horizontal scrollbar.

+ */

+void setContentWidth(int newWidth) {

+	ScrollBar horizontalBar;

+	boolean scrollBarVisible;

+	

+	if (contentWidth != newWidth) {

+		horizontalBar = getHorizontalBar();

+		scrollBarVisible = horizontalBar.getVisible();

+		contentWidth = newWidth;

+		calculateHorizontalScrollbar();

+		if (scrollBarVisible != horizontalBar.getVisible()) {

+			resizeVerticalScrollbar();									// the vertical scroll bar needs to be resized if the horizontal 

+		}																// scroll bar was hidden or made visible during recalculation

+	}

+}

+/**

+ * Set whether the currently selected items were selected using the 

+ * ctrl key.

+ * @param isCtrlSelection - 

+ *	true = currently selected items were selected using the ctrl key.

+ *	false = currently selected items were not selected using the 

+ *	ctrl key.

+ */

+void setCtrlSelection(boolean isCtrlSelection) {

+	this.isCtrlSelection = isCtrlSelection;

+}

+/**

+ * The font is changing. Reset the text height to force a 

+ * recalculation during itemChanged().

+ */

+public void setFont(Font font) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	super.setFont(font);

+	textHeight = -1;

+}

+/**

+ * Set the horizontal drawing offset to 'offset'.

+ * Scroll the receiver's contents according to the offset change.

+ * @param offset - value < 0 = widget contents is drawn left of the client area.

+ */

+void setHorizontalOffset(int offset) {

+	int offsetChange = offset - horizontalOffset;

+	

+	if (offsetChange != 0) {

+		scrollHorizontal(offsetChange);

+		horizontalOffset = offset;

+	}

+}

+

+/**

+ * Set whether the drop insert position is before or after the 

+ * item set using motif_setInsertMark.

+ * @param after true=insert position is after the insert item

+ *	false=insert position is before the insert item

+ */

+void setInsertAfter(boolean after) {

+	isInsertAfter = after;

+}

+

+/**

+ * Set the item that draws the marker indicating the insert location 

+ * in a drag and drop operation.

+ * @param item the item that draws the insert marker

+ */

+void setInsertItem(SelectableItem item) {

+	insertItem = item;

+}

+/** 

+ * Set the height of the receiver's items to 'height'.

+ */

+void setItemHeight(int height) {

+	itemHeight = height;

+}

+/**

+ * Set the item that most recently received the input focus

+ * to 'focusItem'. Redraw both, the item that lost focus 

+ * and the one that received focus.

+ * @param focusItem - the item that most recently received 

+ *	the input focus

+ * @param showItem true=new focus item, if any, should be scrolled 

+ *	into view. false=don't scroll

+ */

+void setLastFocus(SelectableItem focusItem, boolean showItem) {

+	SelectableItem oldFocusItem = lastFocusItem;

+	

+	if (focusItem != lastFocusItem) {

+		lastFocusItem = focusItem;	

+		if (oldFocusItem != null) {

+			redrawSelection(oldFocusItem);

+		}

+		if (lastFocusItem != null && isFocusControl() == true) {

+			redrawSelection(lastFocusItem);

+		}

+	}

+	if (focusItem != null && showItem == true) {

+		showSelectableItem(focusItem);

+	}

+}

+/**

+ * Set the item that was selected most recently to 'selectedItem'.

+ * Set the input focus to that item.

+ * @param selectedItem - the item that was selected most recently

+ * @param showItem true=new focus item, if any, should be scrolled 

+ *	into view. false=don't scroll

+ */ 

+void setLastSelection(SelectableItem selectedItem, boolean showItem) {

+	if (selectedItem == null) {							// always store the item selected last

+		return;

+	}

+	setLastFocus(selectedItem, showItem);

+	lastSelectedItem = selectedItem;

+}

+/**

+ * Sets the redraw flag.

+ * @param redraw - 

+ *	true = redraw and scroll operations are performed normally

+ * 	false = redraw and scroll operations are ignored

+ */

+public void setRedraw (boolean redraw) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	if (redraw) {

+		if (--drawCount == 0) redraw();

+	} else {

+		drawCount++;

+	}

+}

+/**

+ * Set whether all items in the widget are disposed.

+ * Used to optimize item disposal. Prevents unnecessary screen 

+ * updates.

+ * @param removingAll 

+ *	true=all items are removed. 

+ *	false=normal state, no items or not all items are removed.

+ */

+void setRemovingAll(boolean removingAll) {

+	isRemovingAll = removingAll;

+}

+/**

+ * Select the items stored in 'selectionItems'. 

+ * A SWT.Selection event is not going to be sent.

+ * @param selectionItems - Array containing the items that should 

+ *	be selected

+ */

+void setSelectableSelection(SelectableItem selectionItems[]) {

+	SelectableItem item = null;

+	int selectionCount = selectionItems.length;

+	Vector keepSelected;

+	

+	if (isMultiSelect() == false && selectionCount > 1) {

+		selectionCount = 1;

+	}

+	keepSelected = new Vector(selectionItems.length);

+	for (int i = 0; i < selectionCount; i++) {

+		if (selectionItems[i] != null) {

+			keepSelected.addElement(selectionItems[i]);

+		}

+	}

+	deselectAllExcept(keepSelected);

+	// select in the same order as all the other selection and deslection methods.

+	// Otherwise setLastSelection repeatedly changes the lastSelectedItem for repeated 

+	// selections of the items, causing flash.	

+	for (int i = selectionCount - 1; i >= 0; i--) {

+		item = selectionItems[i];

+		if (item != null) {

+			select(item);

+		}

+	}

+	if (item != null) {

+		setLastSelection(item, true);

+	}	

+}

+/**

+ * Set the vector used to store the selected items of the receiver 

+ * to 'newVector'.

+ * @param newVector - the vector used to store the selected items 

+ *	of the receiver

+ */

+void setSelectionVector(Vector newVector) {

+	selectedItems = newVector;

+}

+/**

+ * Scroll the item at 'index' to the top.

+ * @param index - 0-based index of the first visible item in the 

+ *	receiver's client area.

+ * @param adjustScrollbar - true=set the position of the vertical 

+ *	scroll bar to the new top index. 

+ *	false=don't adjust the vertical scroll bar

+ */

+void setTopIndex(int index, boolean adjustScrollbar) {

+	int indexDiff = index-topIndex;

+

+	if (indexDiff != 0) {

+		scrollVertical(indexDiff);

+		setTopIndexNoScroll(index, adjustScrollbar);

+	}

+}

+/**

+ * Set the index of the first visible item in the receiver's client 

+ * area to 'index'.

+ * @param index - 0-based index of the first visible item in the 

+ *	receiver's client area.

+ * @param adjustScrollbar - true=set the position of the vertical 

+ *	scroll bar to the new top index. 

+ *	false=don't adjust the vertical scroll bar

+ */

+void setTopIndexNoScroll(int index, boolean adjustScrollbar) {

+	topIndex = index;

+	if (adjustScrollbar == true) {

+		getVerticalBar().setSelection(index);

+	}

+}

+/**

+ * The shift key was pressed when the mouse click on an item 

+ * occurred. Do a shift selection. If an already selected item was 

+ * clicked the selection is expanded/reduced to that item

+ * @param hitItem - specifies the clicked item

+ * @param hitItemIndex - specifies the index of the clicked item 

+ *	relative to the first item.

+ */

+void shiftSelect(SelectableItem hitItem, int hitItemIndex) {

+	int fromIndex = -1;

+	int toIndex = -1;

+	int lastSelectionIndex = -1;

+	int selectionRange[];

+	SelectableItem lastSelection = getLastSelection();

+

+	if (lastSelection != null) {

+		lastSelectionIndex = getVisibleIndex(lastSelection);

+	}

+	if (isCtrlSelection() == true) {						// was last selection ctrl selection? 

+		deselectAllExcept(lastSelection);					

+		fromIndex = lastSelectionIndex;						// select from last selection

+		toIndex = hitItemIndex;

+	}

+	else

+	if (getSelectionVector().contains(hitItem) == true) {	// clicked an item already selected?

+		deselectRange(hitItemIndex, lastSelectionIndex);	// reduce selection

+	}

+	else {													// clicked outside existing selection range

+		selectionRange = calculateShiftSelectionRange(hitItemIndex);

+		fromIndex = selectionRange[0];

+		toIndex = selectionRange[1];

+	}

+	if (hitItemIndex == lastSelectionIndex) {				// was click on last selected item?

+		return;

+	}

+	if (fromIndex == -1 || toIndex == -1) { 				// are there previously selected items?

+		toggleSelectionNotify(hitItem);						// do a single select.

+	}

+	else {

+		if (((lastSelectionIndex < fromIndex) && (hitItemIndex > fromIndex)) ||	// does selection reverse direction?

+			((lastSelectionIndex > fromIndex) && (hitItemIndex < fromIndex))) {

+			deselectAllExcept((SelectableItem) null);											// remove old selection 

+		}

+		selectRange(fromIndex, toIndex);

+	}					

+}

+/**

+ * Make 'item' visible by scrolling it into the receiver's client

+ * area if necessary.

+ * @param item - the item that should be made visible to the user.

+ */

+void showSelectableItem(SelectableItem item) {

+	if (item.getSelectableParent() != this) {

+		return;

+	}

+	scrollShowItem(item);

+	scrollShowItem(item);						// second call makes sure that the item is still visible

+												// even if the first scroll caused the horizontal scroll

+												// to be displayed and the item to be hidden again.

+}

+/**

+ * Show the selection. If there is no selection or the 

+ * selection is already visible, this method does nothing. 

+ * If the selection is not visible, the top index of the 

+ * widget is changed such that the selection becomes visible.

+ */

+public void showSelection() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector selection = getSelectionVector();

+	SelectableItem selectionItem;

+

+	if (selection.size() > 0) {

+		selectionItem = (SelectableItem) selection.firstElement();

+		showSelectableItem(selectionItem);

+	}

+}

+/**

+ * Sorts the specified range in the array.

+ *

+ * @param array the SelectableItem array to be sorted

+ * @param start the start index to sort

+ * @param end the last + 1 index to sort

+ */

+void sort(SelectableItem[] array, int start, int end) {

+	int middle = (start + end) / 2;

+	if (start + 1 < middle) sort(array, start, middle);

+	if (middle + 1 < end) sort(array, middle, end);

+	if (start + 1 >= end) return;	// this case can only happen when this method is called by the user

+	if (getVisibleIndex(array[middle-1]) <= getVisibleIndex(array[middle])) return;

+	if (start + 2 == end) {

+		SelectableItem temp = array[start];

+		array[start] = array[middle];

+		array[middle] = temp;

+		return;

+	}

+	int i1 = start, i2 = middle, i3 = 0;

+	SelectableItem[] merge = new SelectableItem[end - start];

+	while (i1 < middle && i2 < end) {

+		merge[i3++] = getVisibleIndex(array[i1]) <= getVisibleIndex(array[i2]) ?

+			array[i1++] : array[i2++];

+	}

+	if (i1 < middle) System.arraycopy(array, i1, merge, i3, middle - i1);

+	System.arraycopy(merge, 0, array, start, i2 - start);

+}

+/**

+ * Toggle the selection of 'item'.

+ * @param item - item that should be selected/deselected

+ */

+void toggleSelectionNotify(SelectableItem item) {

+	if (item.isSelected() == true) {

+		deselectNotify(item);

+	}

+	else {

+		selectNotify(item);

+	}

+}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Shell.java
index 9ce9b90..e5a3334 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Shell.java
@@ -11,172 +11,170 @@
 import org.eclipse.swt.graphics.*;

 import org.eclipse.swt.events.*;

 

-/**

- * Instances of this class represent the "windows"

- * which the desktop or "window manager" is managing.

- * Instances which do not have a parent (that is, they

- * are built using the constructor which takes a 

- * <code>Display</code> as the argument) are described

- * as <em>top level</em> shells. Instances which do have

- * a parent, are described as <em>secondary</em> or

- * <em>dialog</em> shells.

- * <p>

- * Instances are always displayed in one of the maximized, 

- * minimized or normal states:

- * <ul>

- * <li>

- * When an instance is marked as <em>maximized</em>, the

- * window manager will typically resize it to fill the

- * entire visible area of the display, and the instance

- * is usually put in a state where it can not be resized 

- * (even if it has style <code>RESIZE</code>) until it is

- * no longer maximized.

- * </li><li>

- * When an instance is in the <em>normal</em> state (neither

- * maximized or minimized), its appearance is controlled by

- * the style constants which were specified when it was created

- * and the restrictions of the window manager (see below).

- * </li><li>

- * When an instance has been marked as <em>minimized</em>,

- * its contents (client area) will usually not be visible,

- * and depending on the window manager, it may be

- * "iconified" (that is, replaced on the desktop by a small

- * simplified representation of itself), relocated to a

- * distinguished area of the screen, or hidden. Combinations

- * of these changes are also possible.

- * </li>

- * </ul>

- * </p>

- * Note: The styles supported by this class must be treated

- * as <em>HINT</em>s, since the window manager for the

- * desktop on which the instance is visible has ultimate

- * control over the appearance and behavior of decorations.

- * For example, some window managers only support resizable

- * windows and will always assume the RESIZE style, even if

- * it is not set.

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE</dd>

- * <dt><b>Events:</b></dt>

- * <dd>Activate, Close, Deactivate, Deiconify, Iconify</dd>

- * </dl>

- * Class <code>SWT</code> provides two "convenience constants"

- * for the most commonly required style combinations:

- * <dl>

- * <dt><code>SHELL_TRIM</code></dt>

- * <dd>

- * the result of combining the constants which are required

- * to produce a typical application top level shell: (that 

- * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)

- * </dd>

- * <dt><code>DIALOG_TRIM</code></dt>

- * <dd>

- * the result of combining the constants which are required

- * to produce a typical application dialog shell: (that 

- * is, <code>TITLE | CLOSE | BORDER</code>)

- * </dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is not intended to be subclassed.

- * </p>

- *

- * @see Decorations

- * @see SWT

- */

+/**
+ * Instances of this class represent the "windows"
+ * which the desktop or "window manager" is managing.
+ * Instances which do not have a parent (that is, they
+ * are built using the constructor which takes a 
+ * <code>Display</code> as the argument) are described
+ * as <em>top level</em> shells. Instances which do have
+ * a parent, are described as <em>secondary</em> or
+ * <em>dialog</em> shells.
+ * <p>
+ * Instances are always displayed in one of the maximized, 
+ * minimized or normal states:
+ * <ul>
+ * <li>
+ * When an instance is marked as <em>maximized</em>, the
+ * window manager will typically resize it to fill the
+ * entire visible area of the display, and the instance
+ * is usually put in a state where it can not be resized 
+ * (even if it has style <code>RESIZE</code>) until it is
+ * no longer maximized.
+ * </li><li>
+ * When an instance is in the <em>normal</em> state (neither
+ * maximized or minimized), its appearance is controlled by
+ * the style constants which were specified when it was created
+ * and the restrictions of the window manager (see below).
+ * </li><li>
+ * When an instance has been marked as <em>minimized</em>,
+ * its contents (client area) will usually not be visible,
+ * and depending on the window manager, it may be
+ * "iconified" (that is, replaced on the desktop by a small
+ * simplified representation of itself), relocated to a
+ * distinguished area of the screen, or hidden. Combinations
+ * of these changes are also possible.
+ * </li>
+ * </ul>
+ * </p>
+ * Note: The styles supported by this class must be treated
+ * as <em>HINT</em>s, since the window manager for the
+ * desktop on which the instance is visible has ultimate
+ * control over the appearance and behavior of decorations.
+ * For example, some window managers only support resizable
+ * windows and will always assume the RESIZE style, even if
+ * it is not set.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Activate, Close, Deactivate, Deiconify, Iconify</dd>
+ * </dl>
+ * Class <code>SWT</code> provides two "convenience constants"
+ * for the most commonly required style combinations:
+ * <dl>
+ * <dt><code>SHELL_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application top level shell: (that 
+ * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
+ * </dd>
+ * <dt><code>DIALOG_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application dialog shell: (that 
+ * is, <code>TITLE | CLOSE | BORDER</code>)
+ * </dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is not intended to be subclassed.
+ * </p>
+ *
+ * @see Decorations
+ * @see SWT
+ */
 public /*final*/ class Shell extends Decorations {

 	Display display;

 	int shellHandle;

 	boolean reparented, realized;

 	int oldX, oldY, oldWidth, oldHeight;

 	Control lastFocus;

-

-	static final  byte [] WM_DETELE_WINDOW = Converter.wcsToMbcs(null, "WM_DELETE_WINDOW\0");

-/**

- * Constructs a new instance of this class. This is equivalent

- * to calling <code>Shell((Display) null)</code>.

- *

- * @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>

+/**
+ * Constructs a new instance of this class. This is equivalent
+ * to calling <code>Shell((Display) null)</code>.
+ *
+ * @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>
  */

 public Shell () {

 	this ((Display) null);

 }

-/**

- * Constructs a new instance of this class given only the style

- * value describing its behavior and appearance. This is equivalent

- * to calling <code>Shell((Display) null, style)</code>.

- * <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 style the style of control to construct

- *

- * @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>

+/**
+ * Constructs a new instance of this class given only the style
+ * value describing its behavior and appearance. This is equivalent
+ * to calling <code>Shell((Display) null, style)</code>.
+ * <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 style the style of control to construct
+ *
+ * @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>
  */

 public Shell (int style) {

 	this ((Display) null, style);

 }

-/**

- * Constructs a new instance of this class given only the display

- * to create it on. It is created with style <code>SWT.SHELL_TRIM</code>.

- * <p>

- * Note: Currently, null can be passed in for the display argument.

- * This has the effect of creating the shell on the currently active

- * display if there is one. If there is no current display, the 

- * shell is created on a "default" display. <b>Passing in null as

- * the display argument is not considered to be good coding style,

- * and may not be supported in a future release of SWT.</b>

- * </p>

- *

- * @param display the display to create the shell on

- *

- * @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>

+/**
+ * Constructs a new instance of this class given only the display
+ * to create it on. It is created with style <code>SWT.SHELL_TRIM</code>.
+ * <p>
+ * Note: Currently, null can be passed in for the display argument.
+ * This has the effect of creating the shell on the currently active
+ * display if there is one. If there is no current display, the 
+ * shell is created on a "default" display. <b>Passing in null as
+ * the display argument is not considered to be good coding style,
+ * and may not be supported in a future release of SWT.</b>
+ * </p>
+ *
+ * @param display the display to create the shell on
+ *
+ * @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>
  */

 public Shell (Display display) {

 	this (display, SWT.SHELL_TRIM);

 }

-/**

- * Constructs a new instance of this class given the display

- * to create it on and a style value describing its behavior

- * and appearance.

- * <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><p>

- * Note: Currently, null can be passed in for the display argument.

- * This has the effect of creating the shell on the currently active

- * display if there is one. If there is no current display, the 

- * shell is created on a "default" display. <b>Passing in null as

- * the display argument is not considered to be good coding style,

- * and may not be supported in a future release of SWT.</b>

- * </p>

- *

- * @param display the display to create the shell on

- * @param style the style of control to construct

- *

- * @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>

+/**
+ * Constructs a new instance of this class given the display
+ * to create it on and a style value describing its behavior
+ * and appearance.
+ * <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><p>
+ * Note: Currently, null can be passed in for the display argument.
+ * This has the effect of creating the shell on the currently active
+ * display if there is one. If there is no current display, the 
+ * shell is created on a "default" display. <b>Passing in null as
+ * the display argument is not considered to be good coding style,
+ * and may not be supported in a future release of SWT.</b>
+ * </p>
+ *
+ * @param display the display to create the shell on
+ * @param style the style of control to construct
+ *
+ * @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>
  */

 public Shell (Display display, int style) {

 	this (display, null, style, 0);

@@ -194,58 +192,58 @@
 	this.handle = handle;

 	createWidget (0);

 }

-/**

- * Constructs a new instance of this class given only its

- * parent. It is created with style <code>SWT.DIALOG_TRIM</code>.

- * <p>

- * Note: Currently, null can be passed in for the parent.

- * This has the effect of creating the shell on the currently active

- * display if there is one. If there is no current display, the 

- * shell is created on a "default" display. <b>Passing in null as

- * the parent is not considered to be good coding style,

- * and may not be supported in a future release of SWT.</b>

- * </p>

- *

- * @param parent a shell which will be the parent of the new instance

- *

- * @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>

+/**
+ * Constructs a new instance of this class given only its
+ * parent. It is created with style <code>SWT.DIALOG_TRIM</code>.
+ * <p>
+ * Note: Currently, null can be passed in for the parent.
+ * This has the effect of creating the shell on the currently active
+ * display if there is one. If there is no current display, the 
+ * shell is created on a "default" display. <b>Passing in null as
+ * the parent is not considered to be good coding style,
+ * and may not be supported in a future release of SWT.</b>
+ * </p>
+ *
+ * @param parent a shell which will be the parent of the new instance
+ *
+ * @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>
  */

 public Shell (Shell parent) {

 	this (parent, SWT.DIALOG_TRIM);

 }

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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><p>

- * Note: Currently, null can be passed in for the parent.

- * This has the effect of creating the shell on the currently active

- * display if there is one. If there is no current display, the 

- * shell is created on a "default" display. <b>Passing in null as

- * the parent is not considered to be good coding style,

- * and may not be supported in a future release of SWT.</b>

- * </p>

- *

- * @param parent a shell which will be the parent of the new instance

- * @param style the style of control to construct

- *

- * @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>

+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <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><p>
+ * Note: Currently, null can be passed in for the parent.
+ * This has the effect of creating the shell on the currently active
+ * display if there is one. If there is no current display, the 
+ * shell is created on a "default" display. <b>Passing in null as
+ * the parent is not considered to be good coding style,
+ * and may not be supported in a future release of SWT.</b>
+ * </p>
+ *
+ * @param parent a shell which will be the parent of the new instance
+ * @param style the style of control to construct
+ *
+ * @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>
  */

 public Shell (Shell parent, int style) {

 	this (parent != null ? parent.getDisplay () : null, parent, style, 0);

@@ -265,27 +263,28 @@
 	return new Shell (display, null, SWT.NO_TRIM, handle);

 }

 

-/**

- * Adds the listener to the collection of listeners who will

- * be notified when operations are performed on the receiver,

- * by sending the listener one of the messages defined in the

- * <code>ShellListener</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 ShellListener

- * @see #removeShellListener

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when operations are performed on the receiver,
+ * by sending the listener one of the messages defined in the
+ * <code>ShellListener</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 ShellListener
+ * @see #removeShellListener
  */

 public void addShellListener(ShellListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener(SWT.Activate,typedListener);

@@ -376,20 +375,21 @@
 		return;

 	}

 }

-/**

- * Requests that the window manager close the receiver in

- * the same way it would be closed when the user clicks on

- * the "close box" or performs some other platform specific

- * key or mouse combination that indicates the window

- * should be removed.

- *

- * @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>

- */

+/**
+ * Requests that the window manager close the receiver in
+ * the same way it would be closed when the user clicks on
+ * the "close box" or performs some other platform specific
+ * key or mouse combination that indicates the window
+ * should be removed.
+ *
+ * @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 close () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	closeWidget ();

 }

 void closeWidget () {

@@ -413,11 +413,12 @@
 	if (event.doit && !isDisposed ()) dispose ();

 }

 public Rectangle computeTrim (int x, int y, int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	Rectangle trim = super.computeTrim (x, y, width, height);

 	int trimWidth = trimWidth (), trimHeight = trimHeight ();

 	trim.x -= trimWidth / 2; trim.y -= trimHeight - (trimWidth / 2);

-	trim.width += trimWidth; trim.height += trimHeight + imeHeight ();

+	trim.width += trimWidth; trim.height += trimHeight;

 	return trim;

 }

 void createHandle (int index) {

@@ -495,15 +496,6 @@
 		int [] argList1 = {OS.XmNborderWidth, 1};

 		OS.XtSetValues (handle, argList1, argList1.length / 2);

 	}

-	

-	/*

-	* Feature in Motif. There is no Motif API to negociate for the

-	* status line. The fix is to force the status line to appear

-	* by creating a hidden text widget.  This is much safer than

-	* using X API because this may conflict with Motif.

-	*/

-	int textHandle = OS.XmCreateTextField (handle, null, null, 0);

-	if (textHandle == 0) error (SWT.ERROR_NO_HANDLES);

 }

 void deregister () {

 	super.deregister ();

@@ -533,7 +525,7 @@
 	* Note:  It is valid to attempt to dispose a widget

 	* more than once.  If this happens, fail silently.

 	*/

-	if (isDisposed()) return;

+	if (!isValidWidget ()) return;

 

 	/*

 	* This code is intentionally commented.  On some

@@ -571,13 +563,15 @@
 	enableHandle (enabled, shellHandle);

 }

 public int getBorderWidth () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNborderWidth, 0};

 	OS.XtGetValues (scrolledHandle, argList, argList.length / 2);

 	return argList [1];

 }

 public Rectangle getBounds () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	short [] root_x = new short [1], root_y = new short [1];

 	OS.XtTranslateCoords (scrolledHandle, (short) 0, (short) 0, root_x, root_y);

 	int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};

@@ -592,50 +586,54 @@
 	if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);

 	return display;

 }

-/**

- * Returns the receiver's input method editor mode. This

- * will be the result of bitwise OR'ing together one or

- * more of the following constants defined in class

- * <code>SWT</code>:

- * <code>NONE</code>, <code>ROMAN</code>, <code>DBCS</code>, 

- * <code>PHONETIC</code>, <code>NATIVE</code>, <code>ALPHA</code>.

- *

- * @return the IME mode

- *

- * @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 SWT

- */

+/**
+ * Returns the receiver's input method editor mode. This
+ * will be the result of bitwise OR'ing together one or
+ * more of the following constants defined in class
+ * <code>SWT</code>:
+ * <code>NONE</code>, <code>ROMAN</code>, <code>DBCS</code>, 
+ * <code>PHONETIC</code>, <code>NATIVE</code>, <code>ALPHA</code>.
+ *
+ * @return the IME mode
+ *
+ * @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 SWT
+ */
 public int getImeInputMode () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return SWT.NONE;

 }

 public Point getLocation () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	short [] root_x = new short [1], root_y = new short [1];

 	OS.XtTranslateCoords (scrolledHandle, (short) 0, (short) 0, root_x, root_y);

 	return new Point (root_x [0], root_y [0]);

 }

 public Shell getShell () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return this;

 }

-/**

- * Returns an array containing all shells which are 

- * descendents of the receiver.

- * <p>

- * @return the dialog shells

- *

- * @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 an array containing all shells which are 
+ * descendents of the receiver.
+ * <p>
+ * @return the dialog shells
+ *
+ * @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 Shell [] getShells () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int count = 0;

 	Shell [] shells = display.getShells ();

 	for (int i=0; i<shells.length; i++) {

@@ -659,7 +657,8 @@
 	return result;

 }

 public Point getSize () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};

 	OS.XtGetValues (scrolledHandle, argList, argList.length / 2);

 	int border = argList [5];

@@ -669,7 +668,8 @@
 	return new Point (width, height);

 }

 public boolean getVisible () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (!OS.XtIsRealized (handle)) return false;

 	int xDisplay = OS.XtDisplay (handle);

 	if (xDisplay == 0) return false;

@@ -692,31 +692,30 @@
 	OS.XtSetValues (shellHandle, argList, argList.length / 2);

 	int xDisplay = OS.XtDisplay (shellHandle);

 	if (xDisplay != 0) {

+		byte [] WM_DETELE_WINDOW = Converter.wcsToMbcs (null, "WM_DELETE_WINDOW\0", false);

 		int atom = OS.XmInternAtom (xDisplay, WM_DETELE_WINDOW, false);	

 		OS.XmAddWMProtocolCallback (shellHandle, atom, windowProc, SWT.Dispose);

 	}

 }

-int imeHeight () {

-	if (!IsDBLocale) return 0;

-//	realizeWidget ();

-	int [] argList1 = {OS.XmNheight, 0};

-	OS.XtGetValues (shellHandle, argList1, argList1.length / 2);

-	int [] argList2 = {OS.XmNheight, 0};

-	OS.XtGetValues (scrolledHandle, argList2, argList2.length / 2);

-	return argList1 [1] - argList2 [1];

+int inputContext () {

+	//NOT DONE

+	return 0;

 }

 public boolean isEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return getEnabled ();

 }

 boolean isModal () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNmwmInputMode, 0};

 	OS.XtGetValues (shellHandle, argList, argList.length / 2);

 	return (argList [1] != -1 && argList [1] != OS.MWM_INPUT_MODELESS);

 }

 public boolean isVisible () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return getVisible ();

 }

 void manageChildren () {

@@ -728,23 +727,24 @@
 	int height = OS.XDisplayHeight (xDisplay, OS.XDefaultScreen (xDisplay)) * 5 / 8;

 	OS.XtResizeWidget (shellHandle, width, height, 0);

 }

-/**

- * Moves the receiver to the top of the drawing order for

- * the display on which it was created (so that all other

- * shells on that display, which are not the receiver's

- * children will be drawn behind it), marks it visible,

- * and sets focus to its default button (if it has one).

- *

- * @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 Control#setVisible

- * @see Decorations#setDefaultButton

-*/

+/**
+ * Moves the receiver to the top of the drawing order for
+ * the display on which it was created (so that all other
+ * shells on that display, which are not the receiver's
+ * children will be drawn behind it), marks it visible,
+ * and sets focus to its default button (if it has one).
+ *
+ * @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 Control#setVisible
+ * @see Decorations#setDefaultButton
+*/
 public void open () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	setVisible (true);

 }

 int processDispose (int callData) {

@@ -848,25 +848,26 @@
 	display = null;

 	lastFocus = null;

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when operations are performed on the receiver.

- *

- * @param listener the listener which should no longer 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 ShellListener

- * @see #addShellListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when operations are performed on the receiver.
+ *
+ * @param listener the listener which should no longer 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 ShellListener
+ * @see #addShellListener
  */

 public void removeShellListener(ShellListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook(SWT.Activate, listener);

@@ -886,7 +887,8 @@
 	oldWidth = argList [1];  oldHeight = argList [3];

 }

 public void setBounds (int x, int y, int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	/*

 	* Feature in Motif.  Motif will not allow a window

 	* to have a zero width or zero height.  The fix is

@@ -904,27 +906,29 @@
 	OS.XtConfigureWidget (shellHandle, x, y, newWidth, newHeight, 0);

 	if (isFocus) caret.setFocus ();

 }

-/**

- * Sets the input method editor mode to the argument which 

- * should be the result of bitwise OR'ing together one or more

- * of the following constants defined in class <code>SWT</code>:

- * <code>NONE</code>, <code>ROMAN</code>, <code>DBCS</code>, 

- * <code>PHONETIC</code>, <code>NATIVE</code>, <code>ALPHA</code>.

- *

- * @param mode the new IME mode

- *

- * @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 SWT

- */

+/**
+ * Sets the input method editor mode to the argument which 
+ * should be the result of bitwise OR'ing together one or more
+ * of the following constants defined in class <code>SWT</code>:
+ * <code>NONE</code>, <code>ROMAN</code>, <code>DBCS</code>, 
+ * <code>PHONETIC</code>, <code>NATIVE</code>, <code>ALPHA</code>.
+ *
+ * @param mode the new IME mode
+ *
+ * @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 SWT
+ */
 public void setImeInputMode (int mode) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 }

 public void setLocation (int x, int y) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	saveBounds ();

 	if (!reparented) {

 		super.setLocation(x, y);

@@ -936,7 +940,8 @@
 	if (isFocus) caret.setFocus ();

 }

 public void setMinimized (boolean minimized) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	

 	/* 

 	* Bug in MOTIF.  For some reason, the receiver does not keep the

@@ -966,7 +971,8 @@
 }

 

 public void setSize (int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	/*

 	* Feature in Motif.  Motif will not allow a window

 	* to have a zero width or zero height.  The fix is

@@ -985,7 +991,8 @@
 	if (isFocus) caret.setFocus ();

 }

 public void setText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	super.setText (string);

 	

@@ -994,7 +1001,6 @@
 	* title to an empty string.  The fix is to set the title

 	* to be a single space.

 	*/

-	/* Use the character encoding for the default locale */

 	if (string.length () == 0) string = " ";

 	byte [] buffer1 = Converter.wcsToMbcs (null, string, true);

 	int length = buffer1.length - 1;

@@ -1019,7 +1025,8 @@
 	OS.XtFree (ptr);

 }

 public void setVisible (boolean visible) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	realizeWidget ();

 

 	/* Show the shell */

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Slider.java
index 1c91455..2c78f90 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Slider.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Slider.java
@@ -10,50 +10,50 @@
 import org.eclipse.swt.events.*;

 import org.eclipse.swt.graphics.*;

 

-/**

- * Instances of this class are selectable user interface

- * objects that represent a range of positive, numeric values. 

- * <p>

- * At any given moment, a given slider will have a 

- * single <em>selection</em> that is considered to be its

- * value, which is constrained to be within the range of

- * values the slider represents (that is, between its

- * <em>minimum</em> and <em>maximum</em> values).

- * </p><p>

- * Typically, sliders will be made up of five areas:

- * <ol>

- * <li>an arrow button for decrementing the value</li>

- * <li>a page decrement area for decrementing the value by a larger amount</li>

- * <li>a <em>thumb</em> for modifying the value by mouse dragging</li>

- * <li>a page increment area for incrementing the value by a larger amount</li>

- * <li>an arrow button for incrementing the value</li>

- * </ol>

- * Based on their style, sliders are either <code>HORIZONTAL</code>

- * (which have left and right facing buttons for incrementing and

- * decrementing the value) or <code>VERTICAL</code> (which have

- * up and down facing buttons for incrementing and decrementing

- * the value).

- * </p><p>

- * On some platforms, the size of the slider's thumb can be

- * varied relative to the magnitude of the range of values it

- * represents (that is, relative to the difference between its

- * maximum and minimum values). Typically, this is used to

- * indicate some proportional value such as the ratio of the

- * visible area of a document to the total amount of space that

- * it would take to display it. SWT supports setting the thumb

- * size even if the underlying platform does not, but in this

- * case the appearance of the slider will not change.

- * </p>

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>HORIZONTAL, VERTICAL</dd>

- * <dt><b>Events:</b></dt>

- * <dd>Selection</dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is <em>not</em> intended to be subclassed.

- *

- * @see ScrollBar

+/**
+ * Instances of this class are selectable user interface
+ * objects that represent a range of positive, numeric values. 
+ * <p>
+ * At any given moment, a given slider will have a 
+ * single <em>selection</em> that is considered to be its
+ * value, which is constrained to be within the range of
+ * values the slider represents (that is, between its
+ * <em>minimum</em> and <em>maximum</em> values).
+ * </p><p>
+ * Typically, sliders will be made up of five areas:
+ * <ol>
+ * <li>an arrow button for decrementing the value</li>
+ * <li>a page decrement area for decrementing the value by a larger amount</li>
+ * <li>a <em>thumb</em> for modifying the value by mouse dragging</li>
+ * <li>a page increment area for incrementing the value by a larger amount</li>
+ * <li>an arrow button for incrementing the value</li>
+ * </ol>
+ * Based on their style, sliders are either <code>HORIZONTAL</code>
+ * (which have left and right facing buttons for incrementing and
+ * decrementing the value) or <code>VERTICAL</code> (which have
+ * up and down facing buttons for incrementing and decrementing
+ * the value).
+ * </p><p>
+ * On some platforms, the size of the slider's thumb can be
+ * varied relative to the magnitude of the range of values it
+ * represents (that is, relative to the difference between its
+ * maximum and minimum values). Typically, this is used to
+ * indicate some proportional value such as the ratio of the
+ * visible area of a document to the total amount of space that
+ * it would take to display it. SWT supports setting the thumb
+ * size even if the underlying platform does not, but in this
+ * case the appearance of the slider will not change.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>HORIZONTAL, VERTICAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ *
+ * @see ScrollBar
  */

 public /*final*/ class Slider extends Control {

 /**

@@ -120,7 +120,8 @@
  * @see SelectionEvent

  */

 public void addSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener(listener);

 	addListener(SWT.Selection,typedListener);

@@ -130,7 +131,8 @@
 	return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);

 }

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int border = getBorderWidth ();

 	int width = border * 2, height = border * 2;

 	Display display = getDisplay ();

@@ -158,103 +160,109 @@
 	handle = OS.XmCreateScrollBar (parentHandle, null, argList, argList.length / 2);

 	if (handle == 0) error (SWT.ERROR_NO_HANDLES);

 }

-/**

- * Returns the amount that the receiver's value will be

- * modified by when the up/down (or right/left) arrows

- * are pressed.

- *

- * @return the increment

- *

- * @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 the amount that the receiver's value will be
+ * modified by when the up/down (or right/left) arrows
+ * are pressed.
+ *
+ * @return the increment
+ *
+ * @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 getIncrement () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNincrement, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * Returns the maximum value which the receiver will allow.

- *

- * @return the maximum

- *

- * @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 the maximum value which the receiver will allow.
+ *
+ * @return the maximum
+ *
+ * @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 getMaximum () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNmaximum, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * Returns the minimum value which the receiver will allow.

- *

- * @return the minimum

- *

- * @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 the minimum value which the receiver will allow.
+ *
+ * @return the minimum
+ *
+ * @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 getMinimum () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNminimum, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * Returns the amount that the receiver's value will be

- * modified by when the page increment/decrement areas

- * are selected.

- *

- * @return the page increment

- *

- * @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 the amount that the receiver's value will be
+ * modified by when the page increment/decrement areas
+ * are selected.
+ *
+ * @return the page increment
+ *
+ * @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 getPageIncrement () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNpageIncrement, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * Returns the single <em>selection</em> that is the receiver's value.

- *

- * @return the selection

- *

- * @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 the single <em>selection</em> that is the receiver's value.
+ *
+ * @return the selection
+ *
+ * @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 getSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNvalue, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

 }

-/**

- * Returns the size of the receiver's thumb relative to the

- * difference between its maximum and minimum values.

- *

- * @return the thumb value

- *

- * @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 the size of the receiver's thumb relative to the
+ * difference between its maximum and minimum values.
+ *
+ * @return the thumb value
+ *
+ * @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 getThumb () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNsliderSize, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

@@ -292,63 +300,66 @@
 	sendEvent (SWT.Selection, event);

 	return 0;

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the receiver's value changes.

- *

- * @param listener the listener which should no longer 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 SelectionListener

- * @see #addSelectionListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's value changes.
+ *
+ * @param listener the listener which should no longer 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 SelectionListener
+ * @see #addSelectionListener
  */

 public void removeSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook(SWT.Selection, listener);

 	eventTable.unhook(SWT.DefaultSelection,listener);	

 }

-/**

- * Sets the amount that the receiver's value will be

- * modified by when the up/down (or right/left) arrows

- * are pressed to the argument, which must be at least 

- * one.

- *

- * @param value the new increment (must be greater than zero)

- *

- * @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>

+/**
+ * Sets the amount that the receiver's value will be
+ * modified by when the up/down (or right/left) arrows
+ * are pressed to the argument, which must be at least 
+ * one.
+ *
+ * @param value the new increment (must be greater than zero)
+ *
+ * @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 setIncrement (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (value < 1) return;

 	int [] argList = {OS.XmNincrement, value};

 	OS.XtSetValues (handle, argList, argList.length / 2);

 }

-/**

- * Sets the maximum value which the receiver will allow

- * to be the argument which must be greater than or

- * equal to zero.

- *

- * @param value the new maximum (must be zero or greater)

- *

- * @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>

+/**
+ * Sets the maximum value which the receiver will allow
+ * to be the argument which must be greater than or
+ * equal to zero.
+ *
+ * @param value the new maximum (must be zero or greater)
+ *
+ * @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 setMaximum (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (value < 0) return;

 	int [] argList = {OS.XmNmaximum, value};

 	Display display = getDisplay ();

@@ -357,20 +368,21 @@
 	OS.XtSetValues (handle, argList, argList.length / 2);

 	display.setWarnings (warnings);

 }

-/**

- * Sets the minimum value which the receiver will allow

- * to be the argument which must be greater than or

- * equal to zero.

- *

- * @param value the new minimum (must be zero or greater)

- *

- * @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>

+/**
+ * Sets the minimum value which the receiver will allow
+ * to be the argument which must be greater than or
+ * equal to zero.
+ *
+ * @param value the new minimum (must be zero or greater)
+ *
+ * @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 setMinimum (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (value < 0) return;

 	int [] argList = {

 		OS.XmNminimum, 0,

@@ -398,39 +410,41 @@
 	OS.XtSetValues (handle, argList, argList.length / 2);

 	display.setWarnings (warnings);

 }

-/**

- * Sets the amount that the receiver's value will be

- * modified by when the page increment/decrement areas

- * are selected to the argument, which must be at least

- * one.

- *

- * @return the page increment (must be greater than zero)

- *

- * @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>

+/**
+ * Sets the amount that the receiver's value will be
+ * modified by when the page increment/decrement areas
+ * are selected to the argument, which must be at least
+ * one.
+ *
+ * @return the page increment (must be greater than zero)
+ *
+ * @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 setPageIncrement (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (value < 1) return;

 	int [] argList = {OS.XmNpageIncrement, value};

 	OS.XtSetValues (handle, argList, argList.length / 2);

 }

-/**

- * Sets the single <em>selection</em> that is the receiver's

- * value to the argument which must be greater than or equal

- * to zero.

- *

- * @param value the new selection (must be zero or greater)

- *

- * @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>

+/**
+ * Sets the single <em>selection</em> that is the receiver's
+ * value to the argument which must be greater than or equal
+ * to zero.
+ *
+ * @param value the new selection (must be zero or greater)
+ *
+ * @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 setSelection (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (value < 0) return;

 	int [] argList = {OS.XmNvalue, value};

 	Display display = getDisplay ();

@@ -439,22 +453,23 @@
 	OS.XtSetValues (handle, argList, argList.length / 2);

 	display.setWarnings (warnings);

 }

-/**

- * Sets the size of the receiver's thumb relative to the

- * difference between its maximum and minimum values to the

- * argument which must be at least one.

- *

- * @param value the new thumb value (must be at least one)

- *

- * @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 ScrollBar

+/**
+ * Sets the size of the receiver's thumb relative to the
+ * difference between its maximum and minimum values to the
+ * argument which must be at least one.
+ *
+ * @param value the new thumb value (must be at least one)
+ *
+ * @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 ScrollBar
  */

 public void setThumb (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (value < 1) return;

 	int [] argList = {OS.XmNsliderSize, value};

 	Display display = getDisplay ();

@@ -463,29 +478,30 @@
 	OS.XtSetValues (handle, argList, argList.length / 2);

 	display.setWarnings (warnings);

 }

-/**

- * Sets the receiver's selection, minimum value, maximum

- * value, thumb, increment and page increment all at once.

- * <p>

- * Note: This is equivalent to setting the values individually

- * using the appropriate methods, but may be implemented in a 

- * more efficient fashion on some platforms.

- * </p>

- *

- * @param selection the new selection value

- * @param minimum the new minimum value

- * @param maximum the new maximum value

- * @param thumb the new thumb value

- * @param increment the new increment value

- * @param pageIncrement the new pageIncrement value

- *

- * @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>

- */

+/**
+ * Sets the receiver's selection, minimum value, maximum
+ * value, thumb, increment and page increment all at once.
+ * <p>
+ * Note: This is equivalent to setting the values individually
+ * using the appropriate methods, but may be implemented in a 
+ * more efficient fashion on some platforms.
+ * </p>
+ *
+ * @param selection the new selection value
+ * @param minimum the new minimum value
+ * @param maximum the new maximum value
+ * @param thumb the new thumb value
+ * @param increment the new increment value
+ * @param pageIncrement the new pageIncrement value
+ *
+ * @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 setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (selection < 0) return;

 	if (minimum < 0) return;

 	if (maximum < 0) return;

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TabFolder.java
new file mode 100755
index 0000000..3b7a4e7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TabFolder.java
@@ -0,0 +1,1025 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+ 

+import org.eclipse.swt.*;

+import org.eclipse.swt.events.*;

+import org.eclipse.swt.graphics.*;

+ 

+/**
+ * Instances of this class implement the notebook user interface
+ * metaphor.  It allows the user to select a notebook page from
+ * set of pages.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TabItem</code>.
+ * <code>Control</code> children are created and then set into a
+ * tab item using <code>TabItem#setControl</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */

+public /*final*/ class TabFolder extends Composite {

+	TabItem items[];

+	int selectedIndex = -1;

+	int xClient, yClient;

+	int imageHeight = -1;									// all images have the height of the first image ever set

+	int topTabIndex = 0;									// index of the first visible tab. Used for tab scrolling

+	boolean scrollButtonDown = false;						// true=one of the scroll buttons is being pushed

+	boolean inDispose = false;

+

+	// internal constants

+	static final int SCROLL_BUTTON_SIZE = 20;				// width/height of the scroll button used for scrolling tab items

+	static final int CLIENT_MARGIN_WIDTH = 2; 				// distance between widget border and client rect

+	static final int SELECTED_TAB_TOP_EXPANSION = 2; 		// amount we expand the selected tab on top

+	static final int SELECTED_TAB_HORIZONTAL_EXPANSION = 2; // amount we expand so it overlays to left and right

+/**

+ * Constructs a new instance of this class given its parent

+ * and a style value describing its behavior and appearance.

+ * <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

+ *

+ * @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 TabFolder(Composite parent, int style) {

+	super(parent, checkStyle (style));

+	Listener listener = new Listener() {

+		public void handleEvent(Event event) {handleEvents(event);}

+	};

+	addListener (SWT.Dispose, listener);

+	addListener (SWT.MouseDown, listener);

+	addListener (SWT.MouseUp, listener);	

+	addListener (SWT.Paint, listener);

+	addListener (SWT.Resize, listener);

+}

+/**

+ * Adds the listener to the collection of listeners who will

+ * be notified when the receiver's selection changes, by sending

+ * it one of the messages defined in the <code>SelectionListener</code>

+ * interface.

+ * <p>

+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.

+ * <code>widgetDefaultSelected</code> is not called.

+ * </p>

+ *

+ * @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 SelectionListener

+ * @see #removeSelectionListener

+ * @see SelectionEvent

+ */

+public void addSelectionListener(SelectionListener listener) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);	

+	TypedListener typedListener;

+

+	if (listener == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	typedListener = new TypedListener(listener);

+	addListener(SWT.Selection, typedListener);

+	addListener(SWT.DefaultSelection, typedListener);

+}

+static int checkStyle (int style) {

+	/*

+	* Even though it is legal to create this widget

+	* with scroll bars, they serve no useful purpose

+	* because they do not automatically scroll the

+	* widget's client area.  The fix is to clear

+	* the SWT style.

+	*/

+	return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);

+}

+protected void checkSubclass () {

+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);

+}

+public Point computeSize (int wHint, int hHint, boolean changed) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	int width = CLIENT_MARGIN_WIDTH * 2 + TabItem.SHADOW_WIDTH * 2;

+	int height = 0;

+

+	if (items != null && items.length > 0) {

+		TabItem lastItem = items[items.length-1];

+		width = Math.max (width, lastItem.x + lastItem.width);

+	}

+	Point size;

+	Layout layout = getLayout();

+	if (layout != null) {

+		size = layout.computeSize (this, wHint, hHint, changed);

+	} else {

+		size = minimumSize ();

+	}

+	if (size.x == 0) size.x = DEFAULT_WIDTH;

+	if (size.y == 0) size.y = DEFAULT_HEIGHT;

+	if (wHint != SWT.DEFAULT) size.x = wHint;

+	if (hHint != SWT.DEFAULT) size.y = hHint;

+	width = Math.max (width, size.x);

+	height = Math.max (height, size.y);

+	Rectangle trim = computeTrim (0, 0, width, height);

+	return new Point (trim.width, trim.height);

+}

+public Rectangle computeTrim (int x, int y, int width, int height) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	int border = getBorderWidth ();

+	int trimX = x - border - CLIENT_MARGIN_WIDTH - TabItem.SHADOW_WIDTH;

+	int trimY = y - border - CLIENT_MARGIN_WIDTH - TabItem.SHADOW_WIDTH;

+	int tabHeight = 0;

+	if (items != null && items.length > 0) {

+		TabItem item = items [0];

+		tabHeight = item.y + item.height;	// only use height of the first item because all items should be the same height

+	}

+	int trimWidth = width + border * 2 + CLIENT_MARGIN_WIDTH * 2 + TabItem.SHADOW_WIDTH * 2;

+	int trimHeight = height + tabHeight + border * 2 + CLIENT_MARGIN_WIDTH * 2 + TabItem.SHADOW_WIDTH * 2;

+	return new Rectangle (trimX, trimY - tabHeight, trimWidth, trimHeight);

+}

+/**

+ * Create the specified item at 'index'.

+ */

+void createChild (TabItem item, int index) {

+	boolean isTabScrolling = isTabScrolling();

+	

+	if (!(0 <= index && index <= getItemCount ())) error (SWT.ERROR_INVALID_RANGE);

+	item.parent = this;

+	if (items == null) {

+		items = new TabItem[1];

+		items[0] = item;

+	} else {

+		// grow by one and rearrange the array.

+		TabItem[] newItems = new TabItem [items.length + 1];

+		System.arraycopy(items, 0, newItems, 0, index);

+		newItems[index] = item;

+		System.arraycopy(items, index, newItems, index + 1, items.length - index);

+		items = newItems;

+		if (selectedIndex >= index) selectedIndex ++;

+	}

+	layoutItems();

+	redrawTabs();

+	// redraw scroll buttons if they just became visible

+	// fixes 1G5X1QL

+	if (isTabScrolling() != isTabScrolling && isTabScrolling == false) {

+		redrawScrollButtons();

+	}

+	if (getItemCount() == 1) {

+		// select the first added item and send a selection event.

+		// fixes 1GAP79N

+		setSelectionNotify(0);

+	}

+}

+/**

+ * Destroy the specified item.

+ */

+void destroyChild (TabItem item) {

+	int index = indexOf(item);

+	if (index == -1) return; 	// should trigger an error?

+	if (items.length == 1) {

+		items = null;

+		selectedIndex = -1;

+		topTabIndex = 0;

+		if (!inDispose){

+			Control control = item.control;

+			if (control != null && !control.isDisposed()) {

+				control.setVisible(false);

+			}

+			redraw();

+		}		

+	} else {

+		// shrink by one and rearrange the array.

+		TabItem[] newItems = new TabItem [items.length - 1];

+		System.arraycopy(items, 0, newItems, 0, index);

+		System.arraycopy(items, index + 1, newItems, index, items.length - index - 1);

+		items = newItems;

+

+		// move the selection if this item is selected

+		if (selectedIndex == index) {

+			if (!inDispose) {

+				Control control = item.getControl();

+				if (control != null && !control.isDisposed()) {

+					control.setVisible(false);

+				}

+				selectedIndex = -1;

+				setSelectionNotify(Math.max(0, index - 1));

+			}

+		} else if (selectedIndex > index) {

+			selectedIndex--;

+		}		

+		if (topTabIndex == items.length) {

+			--topTabIndex;

+		}

+	}

+	// Make sure that the first tab is visible if scroll buttons are no longer drawn.

+	// Fixes 1FXW5DV

+	if (topTabIndex > 0 && !isTabScrolling()) {

+		topTabIndex = 0;

+	}	

+	if (!inDispose) {

+		layoutItems();

+		redrawTabs();

+	}

+}

+/**

+ * Dispose the items of the receiver

+ */

+void doDispose() {

+	inDispose = true;

+	// items array is resized during TabItem.dispose

+	// it is set to null if the last item is removed

+	while (items != null) {						

+		if (items[items.length-1] != null) {

+			items[items.length-1].dispose();

+		}

+	}

+}

+/**

+ * Draw an arrow like that used in Button with SWT.ARROW style.

+ * @param gc - GC to draw on

+ * @param xPos - x position the underlying button is drawn at

+ * @param yPos - y position the underlying button is drawn at

+ * @param size - size of the underlying button

+ * @param left - true=arrow is facing left. false=arrow is facing right

+ */

+void drawArrow(GC gc, int xPos, int yPos, int size, boolean left) {

+	int arrowWidth = size / 4;

+	int arrow[] = new int[6];

+

+	if (!left) arrowWidth *= -1;

+	// start polygon lines with vertical line which is always the same

+	arrow[0] = xPos + (size + arrowWidth) / 2;	

+	arrow[1] = yPos + size / 4;

+	arrow[2] = arrow[0];

+	arrow[3] = arrow[1] + size / 2;

+

+	arrow[4] = arrow[0] - arrowWidth;

+	arrow[5] = yPos + size / 2;			

+

+	gc.setBackground(getForeground());

+	gc.fillPolygon(arrow);

+	gc.setBackground(getBackground());

+}

+/** 

+ * Draw a border around the receiver.

+ */

+void drawBorder(Event event) {

+	GC gc = event.gc;

+	Rectangle clientArea = getClientArea();

+	int wClient = clientArea.width;

+	int hClient = clientArea.height;

+	int x, y, x1, y1;

+	final Color HighlightShadow = getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);

+	final Color LightShadow = getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);

+

+	// Draw the left line

+	gc.setForeground(HighlightShadow);

+	gc.drawLine((x = xClient - CLIENT_MARGIN_WIDTH), 

+		yClient + hClient + CLIENT_MARGIN_WIDTH,

+		x, 

+		(y = yClient - CLIENT_MARGIN_WIDTH) + 1);

+	// Second, darker, line right of the previous line. 

+	// Necessary to workaround color constant differences on Windows/Motif

+	gc.setForeground(LightShadow);

+	gc.drawLine(x + 1, yClient + hClient + CLIENT_MARGIN_WIDTH, x + 1, y + 1);

+	gc.setForeground(HighlightShadow);

+		

+	// Draw the upper line in two chunks so we don't overwrite the selected tab

+	if (selectedIndex == -1) {

+		gc.setForeground(LightShadow);

+		gc.drawLine(x + 1, y + 1, xClient + wClient + CLIENT_MARGIN_WIDTH, y + 1);		

+	} else {

+		TabItem item = items[selectedIndex];

+		gc.setForeground(LightShadow);

+		if (selectedIndex > 0) {

+			gc.drawLine(x + 1, y + 1, item.x - 1 + CLIENT_MARGIN_WIDTH, y + 1);

+		}

+		gc.drawLine(item.x + item.width, y + 1, xClient + wClient + CLIENT_MARGIN_WIDTH, y + 1);

+	}

+

+	// Draw the right and bottom black lines

+	gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));

+	gc.drawLine((x = xClient - CLIENT_MARGIN_WIDTH),

+		(y = yClient + hClient + CLIENT_MARGIN_WIDTH),

+		(x1 = xClient + wClient + CLIENT_MARGIN_WIDTH),

+		y);

+	gc.drawLine(x1, y, x1, (y1 = yClient - CLIENT_MARGIN_WIDTH + 1));

+	x1--;

+	x++;

+	y--;

+	y1++;

+

+

+	// There is a dark gray line above the bottom back line

+	gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));

+	gc.drawLine(x, y, x1, y);

+	// On the right there is a dark gray line, left of the black one

+	gc.drawLine(x1, y-1, x1, y1);

+

+	// restore the foreground color.

+	gc.setForeground(getForeground());

+}

+/**

+ * Draw a plain push button

+ * @param gc - GC to draw on

+ * @param xPos - x position the button is drawn at

+ * @param yPos - y position the button is drawn at

+ * @param size - size of the button

+ */

+void drawPlainButton(GC gc, int xPos, int yPos, int size) {

+	Color rightBottomColor = getForeground();

+	Color leftTopColor = getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);

+	Color rightBottomInnerColor = getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW);

+	Color leftTopInnerColor = getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);	

+	int upper = yPos;

+	int left = xPos;

+	int lower = yPos + size - 1;

+	int right = xPos + size - 1;

+

+	if (scrollButtonDown) {						// draw the button in the pressed down state?

+		rightBottomColor = getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);	

+		leftTopColor = getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW);

+		rightBottomInnerColor = getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);

+		leftTopInnerColor = getForeground();

+	}		

+	gc.fillRectangle(left, upper, right - left, lower - upper);

+	// draw right, bottom line in foreground color

+	gc.setForeground(rightBottomColor);	

+	gc.drawLine(right, upper, right, lower);

+	gc.drawLine(left, lower, right, lower);	

+

+	// draw left, top line in normal shadow (default light gray)

+	gc.setForeground(leftTopColor);

+	gc.drawLine(left, upper, left, lower - 1);

+	gc.drawLine(left, upper, right - 1, upper);	

+

+	upper++;

+	left++;

+	lower--;

+	right--;

+	// draw right, bottom line in dark shadow (default dark gray)

+	gc.setForeground(rightBottomInnerColor);

+	gc.drawLine(right, upper, right, lower);

+	gc.drawLine(left, lower, right, lower);	

+

+	// draw left, top line in high light shadow (default off white)

+	gc.setForeground(leftTopInnerColor);

+	gc.drawLine(left, upper, left, lower - 1);

+	gc.drawLine(left, upper, right - 1, upper);	

+	gc.setForeground(getForeground());

+}

+/** 

+ * Draw the buttons used to scroll tab items

+ */

+void drawScrollButtons(Event event) {

+	Rectangle buttonArea = getScrollButtonArea();

+	int buttonSize = buttonArea.width / 2;

+

+	drawPlainButton(event.gc, buttonArea.x, buttonArea.y, buttonSize);

+	drawPlainButton(event.gc, buttonArea.x + buttonSize, buttonArea.y, buttonSize);

+	if (scrollButtonDown) {

+		drawArrow(event.gc, buttonArea.x, buttonArea.y, buttonSize, true);	

+		drawArrow(event.gc, buttonArea.x + buttonSize + 1, buttonArea.y, buttonSize + 1, false);

+	}

+	else {

+		drawArrow(event.gc, buttonArea.x - 1, buttonArea.y - 1, buttonSize, true);	

+		drawArrow(event.gc, buttonArea.x + buttonSize, buttonArea.y - 1, buttonSize, false);

+	}

+}

+

+/**

+ * Make sure that the first tab is visible if scroll buttons are no 

+ * longer drawn.

+ */

+void ensureRightFreeSpaceUsed() {

+	if (topTabIndex > 0 && !isTabScrolling()) {

+		topTabIndex = 0;

+		layoutItems();

+		redrawTabs();

+	}	

+}

+

+/**

+ * If the tab at 'tabIndex' is not visible or partially covered by the tab 

+ * scroll buttons and there is enough space to completely show the tab, 

+ * the tab is scrolled to the left to make it fully visible.

+ */ 

+void ensureVisible(int tabIndex) {

+	if (items == null || tabIndex < 0 || tabIndex >= items.length) return;

+

+	TabItem tabItem = items[tabIndex];

+	int tabStopX = tabItem.x + tabItem.width;

+	if (isTabScrolling() && tabStopX >= getScrollButtonArea().x && tabIndex != topTabIndex) {

+		scrollRight();

+	}

+}

+public Rectangle getClientArea() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Rectangle clientArea = super.getClientArea();

+	

+	if (yClient == 0) {					// position not calculated yet

+		layoutItems();					// calculate tab folder bounds as soon as there is tab data to use.		

+	}

+	clientArea.x = xClient;

+	clientArea.y = yClient;

+	clientArea.width -= xClient + CLIENT_MARGIN_WIDTH + 1;

+	clientArea.height -= yClient + CLIENT_MARGIN_WIDTH + 1;

+	return clientArea;

+}

+/**

+ * Return the height of item images. All images are scaled to 

+ * the height of the first image.

+ */

+int getImageHeight() {

+	return imageHeight;

+}

+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ */

+public TabItem getItem (int index) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (!(0 <= index && index < getItemCount())) error(SWT.ERROR_INVALID_RANGE);

+	return items [index];

+}

+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @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 getItemCount(){

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (items == null) 

+		return 0;

+	else return items.length;

+}

+/**
+ * Returns an array of <code>TabItem</code>s which are the items
+ * in the receiver. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @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 TabItem [] getItems() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (items == null) return new TabItem[0];

+	TabItem[] tabItems = new TabItem [items.length];

+	System.arraycopy(items, 0, tabItems, 0, items.length);

+	return tabItems;

+}

+/** 

+ * Returns the area where the two scroll buttons are drawn.

+ */

+Rectangle getScrollButtonArea() {

+	return new Rectangle(

+		super.getClientArea().width - SCROLL_BUTTON_SIZE * 2, SELECTED_TAB_TOP_EXPANSION, 

+		SCROLL_BUTTON_SIZE * 2, SCROLL_BUTTON_SIZE);

+}

+/**
+ * Returns an array of <code>TabItem</code>s that are currently
+ * selected in the receiver. An empty array indicates that no
+ * items are selected.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ * @return an array representing the selection
+ *
+ * @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 TabItem [] getSelection() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (selectedIndex == -1) return new TabItem [0];

+	return new TabItem [] {items[selectedIndex]};

+}

+/**
+ * Returns the zero-relative index of the item which is currently
+ * selected in the receiver, or -1 if no item is selected.
+ *
+ * @return the index of the selected item
+ *
+ * @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 getSelectionIndex() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return selectedIndex;

+}

+/**

+ * Handle the events that I have hooked on the canvas.

+ */

+void handleEvents (Event event){

+	switch (event.type) {

+		case SWT.Dispose:

+			doDispose();

+			break;

+		case SWT.Paint:

+			paint(event);

+			break;

+		case SWT.Resize:

+			resize();

+			break;

+		case SWT.MouseDown:

+			mouseDown(event);

+			break;

+		case SWT.MouseUp:

+			mouseUp(event);

+			break;

+		default:

+			break;

+	}

+}

+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param item the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string 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>
+ */

+public int indexOf(TabItem item) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (item == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	if (items != null) {

+		for (int i = 0; i < items.length; i++) {

+			if (items[i] == item) return i;

+		}

+	}

+	return -1;

+}

+/** 

+ * Answer true when the left scroll button was clicked with mouse button 1.

+ */

+boolean isLeftButtonHit(Event event) {

+	Rectangle buttonArea = getScrollButtonArea();

+

+	buttonArea.width /= 2;

+	return isTabScrolling() && event.button == 1 && buttonArea.contains(event.x, event.y);

+}

+/** 

+ * Answer true when the right scroll button was clicked with mouse button 1.

+ */

+boolean isRightButtonHit(Event event) {

+	Rectangle buttonArea = getScrollButtonArea();

+	int buttonSize = buttonArea.width / 2;

+	

+	buttonArea.x += buttonSize;

+	buttonArea.width = buttonSize;

+	return isTabScrolling() && event.button == 1 && buttonArea.contains(event.x, event.y);

+}

+/**

+ * Answer true if not all tabs can be visible in the receive

+ * thus requiring the scroll buttons to be visible.

+ */ 

+boolean isTabScrolling() {

+	boolean isVisible = false;

+	

+	if (items != null && items.length > 0) {

+		TabItem tabItem = items[items.length-1];

+		int tabStopX = tabItem.x + tabItem.width;

+		tabItem = items[0];

+		if (tabStopX - tabItem.x > super.getClientArea().width) {

+			isVisible = true;									// not all tabs fit in the client area

+		}

+	}

+	return isVisible;

+}

+/**

+ * 'item' has changed. Store the image size if this is the 

+ * first item with an image.

+ */

+void itemChanged(TabItem item) {

+	Image itemImage = item.getImage();

+	boolean isTabScrolling = isTabScrolling();

+	

+	if (imageHeight == -1 && itemImage != null) {

+		imageHeight = itemImage.getBounds().height;

+	}

+	layoutItems();

+	redrawTabs();

+	// redraw scroll buttons if they just became visible

+	// fixes 1G5X1QL

+	if (isTabScrolling() != isTabScrolling && isTabScrolling == false) {

+		redrawScrollButtons();

+	}	

+}

+/**

+ * Layout the items and store the client area size.

+ */

+void layoutItems() {

+	int x = SELECTED_TAB_HORIZONTAL_EXPANSION;

+	int y = SELECTED_TAB_TOP_EXPANSION;

+	int tabHeight = 0;

+	

+	if (items != null) {

+		GC gc = new GC(this);

+		for (int i=topTabIndex - 1; i>=0; i--) {			// if the first visible tab is not the first tab

+			TabItem tab = items[i];

+			tab.width = tab.preferredWidth(gc);

+			tab.height = tab.preferredHeight(gc);

+			x -= tab.width;									// layout tab items from right to left thus making them invisible

+			tab.x = x;

+			tab.y = y;

+			if (tab.height > tabHeight) tabHeight = tab.height;

+		}

+		x = SELECTED_TAB_HORIZONTAL_EXPANSION;

+		for (int i=topTabIndex; i<items.length; i++) {		// continue laying out remaining, visible items left to right 

+			TabItem tab = items[i];

+			tab.x = x;

+			tab.y = y;

+			tab.width = tab.preferredWidth(gc);

+			tab.height = tab.preferredHeight(gc);

+			x = x + tab.width;

+			if (tab.height > tabHeight) tabHeight = tab.height;

+		}

+		gc.dispose();

+	}

+	xClient = CLIENT_MARGIN_WIDTH;

+	yClient = CLIENT_MARGIN_WIDTH + tabHeight;

+	TabItem selection[] = getSelection();

+	if (selection.length > 0) 

+		selection[0].expand(SELECTED_TAB_HORIZONTAL_EXPANSION, SELECTED_TAB_TOP_EXPANSION, SELECTED_TAB_HORIZONTAL_EXPANSION, 0);

+}

+/** 

+ * A mouse button was pressed down. 

+ * If one of the tab scroll buttons was hit, scroll in the appropriate 

+ * direction.

+ * If a tab was hit select the tab.

+ */

+void mouseDown(Event event) {

+	if (items == null) return;

+	if (isLeftButtonHit(event)) {

+		scrollButtonDown = true;

+		redrawHitButton(event);

+		scrollLeft();

+	}

+	else

+	if (isRightButtonHit(event)) {

+		scrollButtonDown = true;

+		redrawHitButton(event);

+		scrollRight();

+	}

+	else {

+		for (int i=0; i<items.length; i++) {

+			if (items[i].getBounds().contains(new Point(event.x, event.y))) {

+				setSelectionNotify(i);

+				return;

+			}

+		}

+	}

+}

+/** 

+ * A mouse button was released.

+ */

+void mouseUp(Event event) {

+	if (scrollButtonDown && event.button == 1) {

+		scrollButtonDown = false;

+		redrawHitButton(event);

+	}

+}

+/** 

+ * Paint the receiver.

+ */

+void paint(Event event) {

+	// Draw the unselected tabs first.

+	for (int i=0; i<getItemCount(); i++) {

+		if (i != selectedIndex && event.getBounds().intersects(items[i].getBounds())) {

+			items[i].paint(event.gc, false);

+		}

+	}

+	drawBorder(event);

+	// Selected tab comes last since selected tabs overlay adjacent tabs 

+	// and the border

+	if (selectedIndex != -1) {

+		items[selectedIndex].paint(event.gc, true);

+	}

+	if (isTabScrolling()) drawScrollButtons(event);

+}

+/**

+ * Redraw the area of the receiver specified by x, y, width, height.

+ * Don't redraw the scroll buttons to avoid flashing.

+ */

+void redraw (int x, int y, int width, int height) {

+	Rectangle buttonArea = getScrollButtonArea();	

+	boolean fixScrollButtons = false;

+

+	if (isTabScrolling()) {		

+		if (x >	buttonArea.x) {

+			x = buttonArea.x;

+			fixScrollButtons = true;

+		}

+		if (x + width >	buttonArea.x) {

+			width = buttonArea.x - x;

+			fixScrollButtons = true;

+		}

+	}

+	redraw(x, y, width, height, false);

+	if (fixScrollButtons) {

+		redraw(buttonArea.x, 0, buttonArea.width, buttonArea.y, false);		// redraw space above scroll buttons

+		if (buttonArea.height < getClientArea().y) {

+			int redrawY = buttonArea.y + buttonArea.height;

+			redraw(

+				buttonArea.x, redrawY, 

+				buttonArea.width, getClientArea().y - redrawY, false);		// redraw space below scroll buttons

+		}

+	}

+}

+/** 

+ * Redraw the scroll button that was pressed down

+ */

+void redrawHitButton(Event event) {

+	Rectangle scrollButtonArea = getScrollButtonArea();

+	int scrollButtonWidth = scrollButtonArea.width / 2;

+	

+	if (isLeftButtonHit(event)) {

+		redraw(

+			scrollButtonArea.x, scrollButtonArea.y, 

+			scrollButtonWidth, scrollButtonArea.height, false);

+	}

+	else

+	if (isRightButtonHit(event)) {

+		redraw(

+			scrollButtonArea.x + scrollButtonWidth, scrollButtonArea.y, 

+			scrollButtonWidth, scrollButtonArea.height, false);		

+	}

+}

+/** 

+ * Redraw both scroll buttons

+ */

+void redrawScrollButtons() {

+	Rectangle scrollButtonArea = getScrollButtonArea();

+	

+	redraw(

+		scrollButtonArea.x, scrollButtonArea.y, 

+		scrollButtonArea.width, scrollButtonArea.height, false);

+}

+/** 

+ * Redraw the tabs at the specified indexes.

+ */

+void redrawSelectionChange(int oldSelection, int newSelection) {

+	if (oldSelection != -1) {

+		TabItem tab = items[oldSelection];

+		// since the tab used to be selected, we need to clear its old expanded size

+		redraw(tab.x - SELECTED_TAB_HORIZONTAL_EXPANSION, 

+				tab.y - SELECTED_TAB_TOP_EXPANSION, 

+				tab.width + 2 * SELECTED_TAB_HORIZONTAL_EXPANSION, 

+				tab.height + SELECTED_TAB_TOP_EXPANSION);

+	}

+	if (newSelection != -1) {

+		TabItem tab = items[newSelection];

+		// this tab is already at the expanded size

+		redraw(tab.x, tab.y, tab.width, tab.height);

+	}

+	// make sure the tab is repainted before the new page is made visible.

+	// The latter could take a long time and delay the screen update.

+	update();														

+}

+/**

+ * Redraw the whole tab area

+ */

+void redrawTabs() {

+	redraw(0, 0, super.getClientArea().width, getClientArea().y);

+}

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's selection changes.
+ *
+ * @param listener the listener which should no longer 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 SelectionListener
+ * @see #addSelectionListener
+ */

+public void removeSelectionListener(SelectionListener listener) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (listener == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	removeListener(SWT.Selection, listener);

+	removeListener(SWT.DefaultSelection, listener);	

+}

+/**

+ * The widget was resized. Adjust the size of the currently selected page.

+ */ 

+void resize() {

+	if (selectedIndex != -1) {

+		Control control = items[selectedIndex].getControl();

+		if (control != null && !control.isDisposed()) {

+			control.setBounds(getClientArea());

+		}

+	}

+	ensureRightFreeSpaceUsed();

+}

+

+/**

+ * Scroll the tab items to the left.

+ */

+void scrollLeft() {

+	if (topTabIndex > 0) {

+		--topTabIndex;

+		layoutItems();

+		redrawTabs();

+	}

+}

+/**

+ * Scroll the tab items to the right.

+ */

+void scrollRight() {

+	if (items != null && items.length > 0 && topTabIndex < items.length - 1) {

+		TabItem lastTabItem = items[items.length-1];

+		int tabStopX = lastTabItem.x + lastTabItem.width;

+		if (tabStopX > super.getClientArea().width - SCROLL_BUTTON_SIZE * 2) {

+			topTabIndex++;

+			layoutItems();

+			redrawTabs();

+		}

+	}	

+}

+public void setFont(Font font) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (font != null && font.equals(getFont())) return;

+	super.setFont(font);	

+	layoutItems();

+	redrawTabs();

+}

+/**
+ * Selects the item at the given zero-relative index in the receiver. 
+ * If the item at the index was already selected, it remains selected.
+ * The current selected is first cleared, then the new items are
+ * selected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to select
+ *
+ * @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 setSelection(int index) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	int oldIndex = selectedIndex;

+	

+	if (selectedIndex == index || index >= getItemCount()) return;

+	if (selectedIndex != -1) {

+		Control control = items[selectedIndex].control;

+		if (control != null && !control.isDisposed()) {

+			control.setVisible(false);

+		}		

+	}

+	if (index < 0) {

+		index = -1;										// make sure the index is always -1 if it's negative

+	}

+	selectedIndex = index;

+	layoutItems();

+	ensureVisible(index);	

+	redrawSelectionChange(oldIndex, index);

+	if (index >= 0) {

+		Control control = items[index].control;

+		if (control != null && !control.isDisposed()) {

+			control.setBounds(getClientArea());

+			control.setVisible(true);

+		}

+	}

+}

+/**
+ * Sets the receiver's selection to be the given array of items.
+ * The current selected is first cleared, then the new items are
+ * selected.
+ *
+ * @param items the array of items
+ *
+ * @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 setSelection(TabItem selectedItems[]) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (selectedItems == null) error(SWT.ERROR_NULL_ARGUMENT);

+	int index = -1;

+	if (selectedItems.length > 0) {

+		index = indexOf(selectedItems[0]);

+	}

+	setSelection(index);

+}

+/**

+ * Set the selection to the tab at the specified index.

+ */

+void setSelectionNotify(int index) {

+	int oldSelectedIndex = selectedIndex;

+	

+	setSelection(index);

+	if (selectedIndex != oldSelectedIndex && selectedIndex != -1) {

+		Event event = new Event();

+		event.item = getSelection()[0];

+		notifyListeners(SWT.Selection, event);

+	}

+}

+}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TabItem.java
new file mode 100755
index 0000000..3fe72ef
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TabItem.java
@@ -0,0 +1,353 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+

+import org.eclipse.swt.*;

+import org.eclipse.swt.graphics.*;

+ 

+/**
+ * Instances of this class represent a selectable user interface object
+ * corresponding to a tab for a page in a tab folder.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */

+

+public /*final*/ class TabItem extends Item {

+	TabFolder parent;

+	int x,y,width,height = 0;

+	String toolTipText;

+	Control control;									// the tab page

+	

+	// internal constants

+	static final int LEFT_HORIZONTAL_MARGIN = 8;

+	static final int RIGHT_HORIZONTAL_MARGIN = 2;	

+	static final int VERTICAL_MARGIN = 1;			// space between tab shadow and tab content

+	static final int ICON_MARGIN = 6;

+	static final int SHADOW_WIDTH = 2;				// width of the tab shadow

+	static final int DEFAULT_TEXT_WIDTH = 36;		// preferred text width if there is no text. 

+													// Used for preferred item width calculation

+/**

+ * Construct a TabItem with the specified parent and style.

+ */

+public TabItem (TabFolder parent, int style) {

+	this(parent, style, parent.getItemCount());

+}

+/**

+ * Construct a TabItem with the specified parent and style, inserted at

+ * the specified index.

+ */

+public TabItem (TabFolder parent, int style, int index) {

+	super (parent, style);

+	parent.createChild (this, index);

+}

+protected void checkSubclass () {

+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);

+}

+

+public void dispose() {

+	if (!isValidWidget ()) return;

+	super.dispose();

+	parent.destroyChild(this);

+	parent = null;

+	control = null;

+	toolTipText = null;

+}

+/**

+ * Expand the receiver's bounds by the specified number of pixels on 

+ * the left,top,right,and bottom.

+ */

+void expand(int left, int top, int right, int bottom) {

+	if (hasLocation()) {

+		x = x - left;

+		y = y - top;

+		width = width + left + right;

+		height = height + top + bottom;

+	}

+}

+/**

+ * Return the bounds of the TabItem.

+ */

+Rectangle getBounds () {

+	return new Rectangle(x, y, width, height);

+}

+/**
+ * Returns the control that is used to fill the client area of
+ * the tab folder when the user selects the tab item.  If no
+ * control has been set, return <code>null</code>.
+ * <p>
+ * @return the control
+ *
+ * @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 Control getControl () {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	return control;

+}

+public Display getDisplay() {

+	if (parent == null) error(SWT.ERROR_WIDGET_DISPOSED);

+	return parent.getDisplay();

+}

+/**
+ * Returns the receiver's parent, which must be a <code>TabFolder</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @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 TabFolder getParent () {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return parent;

+}

+/**
+ * Returns the receiver's tool tip text, or null if it has
+ * not been set.
+ *
+ * @return the receiver's tool tip text
+ *
+ * @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 String getToolTipText () {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	return toolTipText;

+}

+/**

+ * Answer true if the receiver has been layed out.

+ */

+boolean hasLocation() {

+	return !(width == 0 && height == 0 && x == 0 && y == 0);

+}

+/**

+ * Answer the image height.

+ */

+private int imageHeight() {

+	Image image = getImage();

+	

+	if (parent.getImageHeight() != -1) {

+		return parent.getImageHeight();

+	} else if (image != null) {

+		return image.getBounds().height;

+	}

+	else {

+		return 0;

+	}

+}

+/**

+ * Answer the icon width.

+ */

+private int imageWidth() {

+	Image image = getImage();

+	

+	if (image != null) {

+		return image.getBounds().width;

+	} else {

+		return 0;

+	}

+}

+/**

+ * Paint the receiver.

+ */

+void paint(GC gc, boolean isSelected) {

+	// high light colored line across left and top 

+	gc.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));

+	gc.drawLine(x, y + height - 2, x, y + 2);

+	gc.drawLine(x, y + 2, x + 2, y);

+	gc.drawLine(x + 2, y, x + width - 3, y);

+

+	// light color next to the left and below the top line.  

+	// Since tabs expand horizontally when selected, we actually draw 

+	// the background color to erase any debris from a selected tab.

+	gc.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));

+	gc.drawLine(x + 1, y + height - 2, x + 1, y + 2);

+	gc.drawLine(x + 2, y + 1, x + width - 3, y + 1);

+

+	// dark colored line at right

+	gc.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));

+	gc.drawLine(x + width - 1, y + 2, x + width - 1, y + height - 1);

+	// dark pixel on top of shadowed line, inside dark line

+	gc.drawLine(x + width - 2, y + 1, x + width - 2, y + 1);

+

+	// shadowed line on right inside the dark line

+	gc.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));

+	gc.drawLine(x + width - 2, y + 2, x + width - 2, y + height - 1);

+

+	// icon and bitmap.  Should probably be checking style bits to determine

+	// exactly what to paint.  Do we just draw the icon when the icon/text combination

+	// is too wide to fit all tabs?

+	gc.setForeground(parent.getForeground());

+	int xDraw = x + LEFT_HORIZONTAL_MARGIN;

+	int yCenter;

+	int decorationHeight = SHADOW_WIDTH * 2 + VERTICAL_MARGIN * 2;

+	Image image = getImage();

+	Rectangle sourceBounds = null;

+	if (image != null) {

+		sourceBounds = image.getBounds();

+		yCenter = y + SHADOW_WIDTH + VERTICAL_MARGIN + (height - decorationHeight - imageHeight()) / 2;

+		gc.drawImage(

+			image, 

+			sourceBounds.x, sourceBounds.y, sourceBounds.width, sourceBounds.height,

+			xDraw, yCenter, sourceBounds.width, parent.getImageHeight());

+	}

+	xDraw = xDraw + ICON_MARGIN;

+	if (sourceBounds != null) {

+		xDraw += sourceBounds.width;

+	}

+	yCenter = y + SHADOW_WIDTH + VERTICAL_MARGIN + (height - decorationHeight - textHeight(gc)) / 2; 	

+	gc.drawString(getText(), xDraw, yCenter);

+}

+/**

+ * Answer the preferred height of the receiver for the GC.

+ */

+int preferredHeight(GC gc) {

+	int height = textHeight(gc);

+	if (imageHeight() > height) height = imageHeight();

+	height += VERTICAL_MARGIN * 2 + SHADOW_WIDTH * 2;

+	return height;

+}

+/**

+ * Answer the preferred width of the receiver for the GC.

+ */

+int preferredWidth(GC gc) {

+	return imageWidth() + textWidth(gc) + LEFT_HORIZONTAL_MARGIN + 

+		RIGHT_HORIZONTAL_MARGIN + ICON_MARGIN + SHADOW_WIDTH * 2;

+}

+/**
+ * Sets the control that is used to fill the client area of
+ * the tab folder when the user selects the tab item.
+ * <p>
+ * @param control the new control (or null)
+ *
+ * @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 setControl (Control control) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	if (control != null && control.parent != parent) {

+		error (SWT.ERROR_INVALID_PARENT);

+	}

+	Control oldControl = this.control, newControl = control;

+	this.control = control;

+	int index = parent.indexOf (this);

+	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);

+}

+/**

+* Sets the image.

+* <p>

+* @param image the new image (or null)

+*

+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)

+*	when called from the wrong thread

+* @exception SWTError(ERROR_WIDGET_DISPOSED)

+*	when the widget has been disposed

+*/

+public void setImage (Image image) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Image oldImage = this.image;

+	

+	super.setImage(image);

+	if (image == null || !image.equals(oldImage)) {

+		parent.itemChanged(this);

+	}

+}

+/**

+ * Sets the receiver's text.

+ *

+ * @param string the new text

+ *

+ * @exception IllegalArgumentException <ul>

+ *    <li>ERROR_NULL_ARGUMENT - if the text 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>

+ */

+public void setText (String string) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	String oldText = text;

+	

+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

+	super.setText(string);

+	if (!string.equals(oldText)) {

+		parent.itemChanged(this);

+	}	

+}

+/**
+ * Sets the receiver's tool tip text to the argument, which
+ * may be null indicating that no tool tip text should be shown.
+ *
+ * @param string the new tool tip text (or null)
+ *
+ * @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 setToolTipText (String string) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	toolTipText = string;

+}

+/**

+ * Answer the text height.

+ */

+private int textHeight(GC gc) {

+	String text = getText();

+	

+	if (text == null) {

+		return 0;

+	} else {

+		return gc.stringExtent(text).y;

+	}

+}

+/**

+ * Answer the text width.

+ */

+private int textWidth(GC gc) {

+	String text = getText();	

+	int textWidth = 0;

+	

+	if (text != null) {

+		textWidth = gc.stringExtent(text).x;

+	}

+	if (textWidth == 0) {

+		textWidth = DEFAULT_TEXT_WIDTH;

+	}

+	return textWidth;

+}

+}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Table.java
new file mode 100755
index 0000000..75dc54f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Table.java
@@ -0,0 +1,2778 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+ 

+import org.eclipse.swt.events.*;

+import org.eclipse.swt.graphics.*;

+import org.eclipse.swt.*;

+import java.util.*;

+ 

+/** 
+ * Instances of this class implement a selectable user interface
+ * object that displays a list of images and strings and issue
+ * notificiation when selected.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TableItem</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SINGLE, MULTI, CHECK, FULL_SELECTION, HIDE_SELECTION</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, DefaultSelection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */

+public /*final*/ class Table extends SelectableItemWidget {

+	private static final int COLUMN_RESIZE_OFFSET = 7;	// offset from the start and end of each 

+														// column at which the resize cursor is displayed 

+														// if the mouse is in the column header

+	static final String DOT_STRING = "...";				// used to indicate truncated item labels

+

+	private Header tableHeader;

+	private Control focusProxy;							// used as a proxy to take focus in place of the table. 

+														// The latter can't get focus because it has a child 

+														// (the header widget). The header widget can't be used 

+														// as a focus widget because it may be hidden.

+	private Vector items;

+	private Vector columns;

+	private boolean drawGridLines = false;

+	private boolean hasColumnFocus = false;				// true if a column currently has focus

+	private boolean firstColumnImage = false;			// true if any item in the first column has an image

+	private int columnResizeX;							// last position of the cursor in a column resize operation

+	private Cursor columnResizeCursor;					// cursor displayed when a column resize is in progress. 

+														// Need to keep reference to the cursor in order to dispose it.

+	private boolean isColumnResizeCursor = false;		// set to true if the column resize cursor is active														

+	private TableColumn resizeColumn;					// column that is currently being resized

+	private TableColumn fillColumn;						// column used to fill up space that is not used 

+														// by user defined columns

+	private TableColumn defaultColumn;					// Default column that is created as soon as the table is created.

+														// Fix for 1FUSJY5

+	private int dotsWidth = -1;							// width of the static String dots (see above)

+/**

+ * Constructs a new instance of this class given its parent

+ * and a style value describing its behavior and appearance.

+ * <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

+ *

+ * @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 Table(Composite parent, int style) {

+	// use NO_MERGE_PAINTS to avoid flashing during column and widget resize redraw

+	super(parent, checkStyle(style| SWT.NO_MERGE_PAINTS));

+}

+/**

+ * Add 'column' to the receiver.

+ * @param column - new table column that should be added to 

+ *	the receiver

+ */

+void addColumn(TableColumn column) {

+	int index = column.getIndex();

+	

+	getColumnVector().insertElementAt(column, index);

+	// has the column been inserted (vs. appended)?

+	if (index < getColumnCount() - 1) {				

+		reindexColumns(index + 1);

+	}

+	// is there more than one user created column?

+	// There always is the data and visual of the default column

+	// so we don't need to create those for the first user column

+	if (getColumnCount() > 1) {

+		insertColumnData(column);

+	}

+	else {								// first user created column

+		setContentWidth(0);				// pretend it's ground zero for column resizings

+		redraw();						// redraw the table and header. The default column 

+		getHeader().redraw();			// won't be drawn anymore, because there now is a user created table.

+	}

+	insertColumnVisual(column);

+}

+/**

+ * Add 'item' to the receiver.

+ * @param item - new table item that should be added to 

+ *	the receiver

+ * @param index - position the new item should be inserted at

+ */

+void addItem(TableItem item, int index) {

+	Vector items = getItemVector();

+

+	if (index < 0 || index > getItemCount()) {

+		error(SWT.ERROR_INVALID_RANGE);

+	}	

+	addingItem(item, index);

+	item.setIndex(index);

+	if (index < items.size()) {

+		for (int i = index; i < items.size(); i++) {

+			TableItem anItem = (TableItem) items.elementAt(i);

+			anItem.setIndex(anItem.getIndex() + 1);

+		}

+		items.insertElementAt(item, index);

+	}

+	else {

+		items.addElement(item);

+	}

+	addedItem(item, index);

+}

+/**

+ * Adds the listener to the collection of listeners who will

+ * be notified when the receiver's selection changes, by sending

+ * it one of the messages defined in the <code>SelectionListener</code>

+ * interface.

+ * <p>

+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.

+ * If the reciever has <code>SWT.CHECK</code> style set and the check selection changes,

+ * the event object detail field contains the value <code>SWT.CHECK</code>.

+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.

+ * The item field of the event object is valid for default selection, but the detail field is not used.

+ * </p>

+ *

+ * @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 SelectionListener

+ * @see #removeSelectionListener

+ * @see SelectionEvent

+ */

+public void addSelectionListener (SelectionListener listener) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	TypedListener typedListener;

+

+	if (listener == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	typedListener = new TypedListener(listener);	

+	addListener(SWT.Selection, typedListener);

+	addListener(SWT.DefaultSelection, typedListener);

+}

+static int checkStyle (int style) {

+	return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);

+}

+protected void checkSubclass () {

+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);

+}

+/**

+ * The width of 'column' is about to change.

+ * Adjust the position of all columns behind it.

+ */

+void columnChange(TableColumn column, Rectangle newBounds) {

+	Rectangle columnBounds = column.getBounds();

+	Rectangle clientArea = getClientArea();

+	int oldXPosition = columnBounds.x + columnBounds.width; 

+	int newXPosition = newBounds.x + newBounds.width;

+	int widthChange = newBounds.width - columnBounds.width;

+	int headerHeight = getHeaderHeight();

+	int columnIndex = column.getIndex();

+

+	if (widthChange != 0) {

+		if (columnIndex != TableColumn.FILL) {

+			if (getLinesVisible() == true) {

+				oldXPosition -= getGridLineWidth();						// include vertical grid line when scrolling resized column.

+				newXPosition -= getGridLineWidth();

+			}

+			scroll(														// physically move all following columns

+				newXPosition, headerHeight, 							// destination x, y

+				oldXPosition, headerHeight, 							// source x, y

+				clientArea.width, clientArea.height, true);

+		}

+		column.internalSetBounds(newBounds);

+		if (columnIndex != TableColumn.FILL) {

+			resetTableItems(columnIndex);

+			moveColumns(columnIndex + 1, widthChange);					// logically move all following columns	(set their bounds)

+			setContentWidth(getContentWidth() + widthChange);			// set the width of the receiver's content

+			claimRightFreeSpace();

+			resizeRedraw(column, columnBounds.width, newBounds.width);

+		}

+	}

+	getHeader().widthChange(columnIndex, widthChange);

+}

+/**

+ * The mouse pointer was double clicked on the receiver.

+ * Handle the event according to the position of the mouse click

+ * and the modifier key that was pressed, if any.

+ * @param event - the mouse event

+ */

+void columnMouseDoubleClick(Event event) {

+	int itemHeight = getItemHeight();

+	int itemIndex;

+	TableItem hitItem;

+	TableColumn hitColumn = getColumnAtX(event.x);

+	Event columnDblClickEvent;

+	boolean isFullSelection = (getStyle() & SWT.FULL_SELECTION) != 0;
+

+	if (isFocusControl() == false) {

+		setFocus();									// focus proxy gets focus here because it's the first child of the receiver

+	}

+	if (hitColumn != null) {

+		itemIndex = (event.y - getHeaderHeight()) / itemHeight + getTopIndex();

+		hitItem = (TableItem) getVisibleItem(itemIndex);

+		if (hitItem != null && 

+			(hitColumn.getIndex() == TableColumn.FIRST || isFullSelection)) {
+			if (hitItem.isSelectionHit(event.x) == true) {

+				columnDblClickEvent = new Event();

+				columnDblClickEvent.item = hitItem;

+				notifyListeners(SWT.DefaultSelection, columnDblClickEvent);

+			}

+		}

+		else {

+			deselectAll();

+		}

+	}

+}

+/**

+ * The mouse pointer was pressed down on the receiver.

+ * Handle the event according to the position of the mouse click

+ * and the modifier key that was pressed, if any.

+ * @param event - the mouse event

+ */

+void columnMouseDown(Event event) {

+	int itemHeight = getItemHeight();

+	int itemIndex;

+	TableItem hitItem;

+	TableColumn hitColumn = getColumnAtX(event.x);

+

+	if (isFocusControl() == false) {

+		setFocus();									// focus proxy gets focus here because it's the first child of the receiver

+	}

+	if (hitColumn != null) {

+		itemIndex = (event.y - getHeaderHeight()) / itemHeight + getTopIndex();

+		hitItem = (TableItem) getVisibleItem(itemIndex);

+		if (hitItem != null) {

+			if (hitItem.isSelectionHit(event.x) == true) {

+				doMouseSelect(hitItem, itemIndex, event.stateMask, event.button);

+			}

+			else 

+			if (hitItem.isCheckHit(new Point(event.x, event.y)) == true) {

+				doCheckItem(hitItem);

+			}

+		}

+		else {

+			deselectAll();

+		}

+	}

+}

+/**

+ * The mouse pointer was moved over the receiver.

+ * Reset the column resize cursor if it was active.

+ * @param event - the mouse event

+ */

+void columnMouseMove(Event event) {

+	if (isColumnResizeStarted() == false) {

+		setColumnResizeCursor(false);

+	}

+}

+public Point computeSize(int wHint, int hHint, boolean changed) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Point size = super.computeSize(wHint, hHint, changed);

+	Point headerSize;

+	GC gc;

+	final int WidthCalculationCount = Math.min(getItemCount(), 50);		// calculate item width for the first couple of items only

+	TableItem item;

+	Image itemImage;

+	String itemText;

+	int width;

+	int newItemWidth = 0;

+		

+	if (getHeaderVisible() == true) {

+		headerSize = getHeader().computeSize(SWT.DEFAULT, SWT.DEFAULT, false);

+		size.y += headerSize.y;		

+	}

+	if (getContentWidth() == 0 && WidthCalculationCount > 0) {

+		gc = new GC(this);

+		for (int i = 0; i < WidthCalculationCount; i++) {

+			item = getItem(i);

+			if (item == null) {

+				break;											// no more items

+			}

+			itemImage = item.getImage();

+			itemText = item.getText();

+			width = 0;

+			if (itemImage != null) {

+				width += itemImage.getBounds().width;

+			}

+			if (itemText != null) {

+				width += gc.stringExtent(itemText).x;

+			}

+			newItemWidth = Math.max(newItemWidth, width);

+		}

+		if (newItemWidth > 0) {

+			size.x = newItemWidth;

+		}

+		gc.dispose();

+	}

+	return size;

+}

+/**
+ * Deselects the items at the given zero-relative indices in the receiver.
+ * If the item at the given zero-relative index in the receiver 
+ * is selected, it is deselected.  If the item at the index
+ * was not selected, it remains deselected. Indices that are out
+ * of range and duplicate indices are ignored.
+ *
+ * @param indices the array of indices for the items to deselect
+ *
+ * @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>
+ */

+public void deselect(int indices[]) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);	

+	SelectableItem item = null;

+	

+	if (indices == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	for (int i = 0; i < indices.length; i++) {

+		item = getVisibleItem(indices[i]);

+		if (item != null) {

+			deselect(item);

+		}

+	}

+	if (item != null) {

+		setLastSelection(item, false);

+	}

+}

+/**
+ * Deselects the item at the given zero-relative index in the receiver.
+ * If the item at the index was already deselected, it remains
+ * deselected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to deselect
+ *
+ * @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 deselect(int index) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItem item = getVisibleItem(index);

+

+	if (item != null) {

+		deselect(item);

+		setLastSelection(item, false);		

+	}

+}

+/**
+ * Deselects the items at the given zero-relative indices in the receiver.
+ * If the item at the given zero-relative index in the receiver 
+ * is selected, it is deselected.  If the item at the index
+ * was not selected, it remains deselected.  The range of the
+ * indices is inclusive. Indices that are out of range are ignored.
+ *
+ * @param start the start index of the items to deselect
+ * @param end the end index of the items to deselect
+ *
+ * @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 deselect(int start, int end) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItem item = null;

+

+	for (int i=start; i<=end; i++) {

+		item = getVisibleItem(i);

+		if (item != null) {

+			deselect(item);

+		}

+	}

+	if (item != null) {

+		setLastSelection(item, false);

+	}	

+}

+/**
+ * Deselects all selected items in the receiver.
+ *
+ * @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 deselectAll() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	deselectAllExcept((SelectableItem) null);

+}

+/**

+ * Free resources.

+ */

+void doDispose() {

+	Vector items = getItemVector();

+	

+	super.doDispose();

+	while (items.size() > 0) {								// TableItem objects are removed from vector during dispose()

+		((TableItem) items.lastElement()).dispose();

+	}

+	items = getColumnVector();

+	while (items.size() > 0) {								// TableColumn objects are removed from vector during dispose()

+		((TableColumn) items.lastElement()).dispose();

+	}

+	resizeColumn = null;

+	fillColumn = null;

+	defaultColumn = null;

+	if (columnResizeCursor != null) {

+		columnResizeCursor.dispose();

+	}

+}

+/**

+ * Draw a line tracking the current position of a column 

+ * resize operation.

+ * @param xPosition - x coordinate to draw the line at

+ */

+void drawColumnResizeLine(int xPosition) {

+	GC gc = new GC(this);

+	int lineHeight = getClientArea().height;

+

+	redraw(getColumnResizeX(), 0, 1, lineHeight, false);

+	setColumnResizeX(xPosition);

+	gc.drawLine(xPosition, 0, xPosition, lineHeight);

+	gc.dispose();

+}

+/**

+ * Draw the grid lines for the receiver.

+ * @param event - Paint event triggering the drawing operation.

+ * @param drawColumns - The table columns for which the grid 

+ *	lines should be drawn.

+ */

+void drawGridLines(Event event, Enumeration drawColumns) {

+	GC gc = event.gc;

+	Color oldForeground = getForeground();

+	Rectangle columnBounds;

+	TableColumn column;

+	int lineWidth = getGridLineWidth();

+	int itemHeight = getItemHeight();

+	int headerHeight = getHeaderHeight();

+	int lineXPosition;

+	int lineYPosition = headerHeight + ((event.y-headerHeight) / itemHeight) * itemHeight;

+	int lineYStopPosition = event.y + event.height;

+

+	gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));

+	// Draw the horizontal lines	

+	if (itemHeight > 0) {

+		while (lineYPosition < lineYStopPosition) {

+			gc.drawLine(

+				event.x, lineYPosition + itemHeight - lineWidth, 

+				event.x + event.width, lineYPosition + itemHeight - lineWidth);

+			lineYPosition += itemHeight; 		

+		}

+	}

+	// Draw the vertical lines at the right border of each column except the fill column

+	while (drawColumns.hasMoreElements() == true) {

+		column = (TableColumn) drawColumns.nextElement();

+		if (column.getIndex() != TableColumn.FILL) {

+			columnBounds = column.getBounds();

+			lineXPosition = columnBounds.x + columnBounds.width - lineWidth;

+			gc.drawLine(

+				lineXPosition, event.y, 

+				lineXPosition, event.y + event.height);

+		}

+	}

+	gc.setForeground(oldForeground);

+}

+/**

+ * Draw a filled rectangle indicating the selection state of 'item'

+ * If 'item' is selected the rectangle will be filled with the 

+ * selection background color. Otherwise the rectangle will be filled 

+ * with the background color to remove selection.

+ * The selection color depends on whether the table widget has 

+ * focus or not. See getSelectionBackgroundColor() for details.

+ * The rectangle is drawn in either the first column or in all columns 

+ * for full row select.

+ * @param item - item for which the selection state should be drawn

+ * @param gc - GC to draw on. 

+ * @param position - position on the GC to draw at.

+ * @param extent - extent of the selection rectangle.

+ */

+void drawSelection(TableItem item, GC gc, Point position, Point extent) {

+	if (item.isSelected() == true) {

+		gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));

+	}

+	gc.fillRectangle(position.x, position.y, extent.x, extent.y);

+	if (item.isSelected() == true) {

+		gc.setBackground(getBackground());

+	}

+}

+/**

+ * If the receiver has input focus draw a rectangle enclosing 

+ * the label of 'item' to indicate the input focus.

+ * The rectangle is drawn in either the first column or in all columns 

+ * for full row select. 

+ * @param item - item for which the selection state should be drawn

+ * @param gc - GC to draw on. 

+ */

+void drawSelectionFocus(TableItem item, GC gc) {

+	Point extent = item.getSelectionExtent();

+	Point position = new Point(

+		item.getImageStopX(TableColumn.FIRST) + getHorizontalOffset(),

+		getRedrawY(item));

+

+	gc.drawFocus(position.x, position.y, extent.x, extent.y);

+}

+

+/**	Not used right now. Replace focusIn/focusOut with this method once 

+ *	Display.getFocusWindow returns the new focus window on FocusOut event

+ * The focus has moved in to or out of the receiver.

+ * Redraw the item selection to reflect the focus change.

+ * @param event - the focus change event

+ */

+void focusChange(Event event) {

+	TableColumn focusColumn = getColumnAtX(event.x);

+	Control focusWindow = getDisplay().getFocusControl();

+

+	if (focusWindow == getFocusWindow() && 

+		focusColumn != null && 

+		focusColumn.getIndex() == TableColumn.FIRST) {

+		hasColumnFocus = true;

+	}

+	else {

+		hasColumnFocus = false;

+	}

+	super.focusChange(event);

+	event.widget = this;									// the ficus event is never sent to the table itself but only to the focus widget

+	notifyListeners(event.type, event);						// make sure that listeners of the table get the focus event, too

+}

+/**

+ * The focus has moved in to or out of the receiver.

+ * @param event - the focus change event

+ */

+void focusIn(Event event) {

+	TableColumn focusColumn = getColumnAtX(event.x);

+

+	if (focusColumn != null && 

+		focusColumn.getIndex() == TableColumn.FIRST) {

+		hasColumnFocus = true;

+	}

+	super.focusIn(event);

+	event.widget = this;									// the focus event is never sent to the table itself but only to the focus widget

+	notifyListeners(event.type, event);						// make sure that listeners of the table get the focus event, too

+}

+/**

+ * The focus has moved in to or out of the receiver.

+ * @param event - the focus change event

+ */

+void focusOut(Event event) {

+	TableColumn focusColumn = getColumnAtX(event.x);

+

+	if (focusColumn != null && 

+		focusColumn.getIndex() == TableColumn.FIRST) {

+		hasColumnFocus = false;

+	}

+	super.focusOut(event);

+	event.widget = this;									// the focus event is never sent to the table itself but only to the focus widget

+	notifyListeners(event.type, event);						// make sure that listeners of the table get the focus event, too

+}

+/**
+ * Returns the column at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ * If no <code>TableColumn</code>s were created by the programmer,
+ * this method will throw <code>ERROR_INVALID_RANGE</code> despite
+ * the fact that a single column of data may be visible in the table.
+ * This occurs when the programmer uses the table like a list, adding
+ * items but never creating a column.
+ *
+ * @param index the index of the column to return
+ * @return the column at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ */

+public TableColumn getColumn(int index) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector columns = getColumnVector();

+	

+	if (columns == null) error(SWT.ERROR_CANNOT_GET_ITEM);

+	if (index < 0 || index >= columns.size()) {

+		error(SWT.ERROR_INVALID_RANGE);

+	}

+	

+	return (TableColumn) columns.elementAt(index);

+}

+/**

+ * Return the column located at 'xPosition' in the widget.

+ * Return null if xPosition is outside the widget.

+ * @param xPosition - position of the desired column

+ */

+TableColumn getColumnAtX(int xPosition) {

+	Enumeration columns = internalGetColumnVector().elements();

+	TableColumn column;

+	TableColumn hitColumn = null;

+	Rectangle bounds;

+

+	while (columns.hasMoreElements() == true && hitColumn == null) {

+		column = (TableColumn) columns.nextElement();

+		bounds = column.getBounds();

+		if ((xPosition >= bounds.x) && 

+			(xPosition <= bounds.x + bounds.width)) {

+			hitColumn = column;

+		}

+	}

+	if (hitColumn == null) {

+		column = getFillColumn();

+		bounds = column.getBounds();

+		if ((xPosition >= bounds.x) && 

+			(xPosition <= bounds.x + bounds.width)) {

+			hitColumn = column;

+		}

+	}

+	return hitColumn;

+}

+/**
+ * Returns the number of columns contained in the receiver.
+ * If no <code>TableColumn</code>s were created by the programmer,
+ * this value is zero, despite the fact that visually, one column
+ * of items is may be visible. This occurs when the programmer uses
+ * the table like a list, adding items but never creating a column.
+ *
+ * @return the number of columns
+ *
+ * @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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */

+public int getColumnCount() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector columns = getColumnVector();

+	int count = 0;

+	

+	if (columns != null) {

+		count = columns.size();

+	}

+	return count;

+}

+/** Replace CURSOR_SIZEWE with real column resize cursor 

+ *	(no standard cursor-have to load from file)

+ * Answer the cursor displayed during a column resize 

+ * operation.

+ * Lazy initialize the cursor since it may never be needed.

+ */

+Cursor getColumnResizeCursor() {

+	if (columnResizeCursor == null) {

+		columnResizeCursor = new Cursor(getDisplay(), SWT.CURSOR_SIZEWE);

+	}

+	return columnResizeCursor;

+}

+/**

+ * Answer the current position of the mouse cursor during

+ * a column resize operation.

+ */

+int getColumnResizeX() {

+	return columnResizeX;

+}

+/**
+ * Returns an array of <code>TableColumn</code>s which are the
+ * columns in the receiver. If no <code>TableColumn</code>s were
+ * created by the programmer, the array is empty, despite the fact
+ * that visually, one column of items may be visible. This occurs
+ * when the programmer uses the table like a list, adding items but
+ * never creating a column.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @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 TableColumn [] getColumns() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector columns = getColumnVector();

+	TableColumn columnArray[] = new TableColumn[columns.size()];

+

+	columns.copyInto(columnArray);

+	return columnArray;

+}

+/**

+ * Answer a Vector containing all columns of receiver except 

+ * the fill column to the right of all content columns.

+ */

+Vector getColumnVector() {

+	return columns;

+}

+/**

+ * Return the default column that is created as soon as the table 

+ * is created.

+ * Fix for 1FUSJY5

+ */

+TableColumn getDefaultColumn() {

+	return defaultColumn;

+}

+/**

+ * Answer the width of the replacement String used to indicate 

+ * truncated items.

+ * Cached to speed up calculation of truncated items.

+ * @param gc - GC used to measure the width of the replacement 

+ *	String

+ */

+int getDotsWidth(GC gc) {

+	if (dotsWidth == -1) {

+		dotsWidth = gc.stringExtent(DOT_STRING).x;

+	}

+	return dotsWidth;

+}

+/**

+ * Answer the column used to occupy any space left to the 

+ * right of all the user created columns.

+ */

+TableColumn getFillColumn() {

+	return fillColumn;

+}

+/**

+ * Answer the widget that is used to hold focus for the receiver.

+ * The receiver can not get focus itself because it has children.

+ */

+Control getFocusWindow() {

+	return focusProxy;

+}

+/**
+ * Returns the width in pixels of a grid line.
+ *
+ * @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 getGridLineWidth () {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return 1;

+}

+/**

+ * Answer the table header widget.

+ */

+Header getHeader() {

+	return tableHeader;

+}

+/**

+ * Answer the header height or 0 if the header is not visible.

+ */

+int getHeaderHeight() {

+	Header header = getHeader();

+	int height = 0;

+	

+	if (header.getVisible() == true) {

+		height = header.getBounds().height;

+	}

+	return height;

+}

+/**
+ * Returns <code>true</code> if the receiver's header is visible,
+ * and <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's header's visibility 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 getHeaderVisible() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return getHeader().getVisible();

+}

+/**

+ * Answer the image extent of 'item'. Use the image of any column.

+ */

+Point getImageExtent(SelectableItem item) {

+	Image image = null;

+	Rectangle imageBounds;

+	Point imageExtent = null;

+	int columnCount = internalGetColumnCount();

+

+	for (int i = 0; i < columnCount && image == null; i++) {

+		image = ((TableItem) item).getImage(i);

+	}		

+	if (image != null) {

+		imageBounds = image.getBounds();

+		imageExtent = new Point(imageBounds.width, imageBounds.height);

+	}

+	return imageExtent;

+}

+/**

+ * Answer the index of 'item' in the receiver.

+ */

+int getIndex(SelectableItem item) {

+	int index = -1;

+	

+	if (item != null && item.getSelectableParent() == this) {

+		index = ((TableItem) item).getIndex();

+	}

+	return index;

+}

+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ */

+public TableItem getItem(int index) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	if (!(0 <= index && index < getItemCount())) {

+		error(SWT.ERROR_INVALID_RANGE);

+	}		

+	return (TableItem) getVisibleItem(index);	

+}

+

+/**
+ * Returns the item at the given point in the receiver
+ * or null if no such item exists. The point is in the
+ * coordinate system of the receiver.
+ *
+ * @param point the point used to locate the item
+ * @return the item at the given point
+ *
+ * @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>
+ */

+public TableItem getItem(Point point) {

+	int headerHeight = getHeaderHeight();

+	TableColumn column = getColumnAtX(point.x);

+	TableItem item = null;

+

+	if (column != null && column.getIndex() != TableColumn.FILL && point.y - headerHeight > 0) {

+		int itemIndex = (point.y - headerHeight) / getItemHeight() + getTopIndex();

+		item = (TableItem) getVisibleItem(itemIndex);

+		if (item != null) {

+			Point itemSize = item.getItemExtent(column);

+			if (point.x - column.getBounds().x > itemSize.x) {

+				item = null;

+			}

+		}

+	}

+	return item;

+}

+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @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 getItemCount() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return getItemVector().size();

+}

+/**

+ * Answer the number of items that can be displayed in the

+ * client area of the receiver without truncating any items.

+ */

+int getItemCountWhole() {

+	int clientAreaHeight = Math.max(0, getClientArea().height - getHeaderHeight());

+	

+	return clientAreaHeight / getItemHeight();

+}

+/**
+ * Returns the height of the area which would be used to
+ * display <em>one</em> of the items in the receiver's.
+ *
+ * @return the height of one item
+ *
+ * @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 getItemHeight() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return super.getItemHeight();

+}

+/**

+ * Answer the number of pixels that should be added to the item height.

+ */

+int getItemPadding() {

+	return getGridLineWidth() + getDisplay().textHighlightThickness + 1;

+}

+/**
+ * Returns an array of <code>TableItem</code>s which are the items
+ * in the receiver. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @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 TableItem [] getItems() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector items = getItemVector();

+	TableItem itemArray[] = new TableItem[items.size()];

+

+	items.copyInto(itemArray);

+	return itemArray;

+}

+/**

+ * Answer all items of the receiver.

+ */

+Vector getItemVector() {

+	return items;

+}

+/**
+ * Returns <code>true</code> if the receiver's lines are visible,
+ * and <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the visibility state of the lines
+ *
+ * @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 getLinesVisible() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return drawGridLines;

+}

+/** 

+ * Answer a Vector containing the columns that need repainting 

+ * based on the 'paintArea'.

+ * @param paintArea - invalidated rectangle that needs repainting

+ */

+Vector getPaintColumns(Rectangle paintArea) {

+	Enumeration columns = internalGetColumnVector().elements();

+	Vector paintColumns = new Vector();

+	TableColumn column;

+	Rectangle columnBounds;

+	int paintAreaRightBorder = paintArea.x + paintArea.width;

+

+	while (columns.hasMoreElements() == true) {

+		column = (TableColumn) columns.nextElement();

+		columnBounds = column.getBounds();

+		if ((columnBounds.x + columnBounds.width >= paintArea.x) &&	// does the paintArea overlap the current column?

+			(columnBounds.x <= paintAreaRightBorder)) {

+			paintColumns.addElement(column);

+		}

+	}

+	return paintColumns;

+}

+/** 

+ * Return the width of the widest item in the column identified by 'columnIndex'

+ * @param columnIndex - index of the column whose preferred width should be

+ *	calculated

+ */

+int getPreferredColumnWidth(int columnIndex) {

+	Enumeration tableItems = getItemVector().elements();

+	TableItem tableItem;

+	int width = 0;

+	int headerWidth;

+	

+	if (columnIndex != TableColumn.FILL) {

+		while (tableItems.hasMoreElements() == true) {

+			tableItem = (TableItem) tableItems.nextElement();

+			width = Math.max(width, tableItem.getPreferredWidth(columnIndex));

+		}

+		headerWidth = getHeader().getPreferredWidth(columnIndex);

+		if (width < headerWidth) {

+			width = headerWidth;

+		}

+	}

+	return width;

+}

+/**

+ * Answer the position in the receiver where 'item' is drawn

+ * @return the y coordinate at which 'item' is drawn.

+ *	Return -1 if 'item' is not an item of the receiver 

+ */

+int getRedrawY(SelectableItem item) {

+	int redrawY = super.getRedrawY(item);

+

+	if (redrawY != -1) {

+		redrawY += getHeaderHeight();

+	}

+	return redrawY;

+}

+/**

+ * Answer the column that is being resized or null if no 

+ * resize operation is in progress.

+ */

+TableColumn getResizeColumn() {

+	return resizeColumn;

+}

+/**

+ * Return the positions at which the column identified by 'columnIndex' 

+ * must be redrawn.

+ * These positions may be different for each item since each item may 

+ * have a different label

+ * @param columnIndex - the column index

+ * @param columnWidth - width of the column

+ * @return the positions at which the column must be redrawn.

+ *	Each item in the widget client area is represented by a slot in 

+ * 	the array. The item at position 'topIndex' is the first item in 

+ *	the array.

+ */

+int [] getResizeRedrawX(int columnIndex, int columnWidth) {

+	int topIndex = getTopIndex();

+	int bottomIndex = getBottomIndex();

+	int resizeRedrawX[];

+	TableItem item;

+

+	bottomIndex = Math.min(bottomIndex, getItemCount());

+	resizeRedrawX = new int[bottomIndex-topIndex+1];

+	for (int i = topIndex; i < bottomIndex; i++) {

+		item = (TableItem) getVisibleItem(i);

+		resizeRedrawX[i-topIndex] = item.getDotStartX(columnIndex, columnWidth);

+	}

+	return resizeRedrawX;

+}

+/**
+ * Returns an array of <code>TableItem</code>s that are currently
+ * selected in the receiver. An empty array indicates that no
+ * items are selected.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ * @return an array representing the selection
+ *
+ * @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 TableItem [] getSelection() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector selectionVector = getSelectionVector();

+	TableItem[] selectionArray = new TableItem[selectionVector.size()];

+

+	selectionVector.copyInto(selectionArray);

+	sort(selectionArray, 0, selectionArray.length);

+	return selectionArray;

+}

+

+/**
+ * Returns the number of selected items contained in the receiver.
+ *
+ * @return the number of selected items
+ *
+ * @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 getSelectionCount() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return super.getSelectionCount();

+}

+/**

+ * Answer the size of the full row selection rectangle for 'item'.

+ */

+Point getFullSelectionExtent(TableItem item) {

+	TableColumn lastColumn = (TableColumn) internalGetColumnVector().lastElement();

+	Point selectionExtent = null;

+	Rectangle columnBounds;

+	int xPosition = item.getImageStopX(TableColumn.FIRST);

+	int gridLineWidth = getGridLineWidth();

+

+	if (lastColumn != null) {

+		columnBounds = lastColumn.getBounds();

+		selectionExtent = new Point(

+			columnBounds.x - getHorizontalOffset() + columnBounds.width - xPosition - gridLineWidth, 

+			getItemHeight());

+		if (getLinesVisible() == true) {

+			selectionExtent.y -= gridLineWidth;

+		}	

+	}

+	return selectionExtent;

+}

+/**
+ * Returns the zero-relative index of the item which is currently
+ * selected in the receiver, or -1 if no item is selected.
+ *
+ * @return the index of the selected item
+ *
+ * @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 getSelectionIndex() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	int index = -1;

+	

+	if (getSelectionCount() > 0) {

+		index = getIndex(getSelection()[0]);

+	}

+	return index;

+}

+/**
+ * Returns the zero-relative indices of the items which are currently
+ * selected in the receiver.  The array is empty if no items are selected.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ * @return the array of indices of the selected items
+ *
+ * @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 [] getSelectionIndices() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	TableItem[] items = getSelection();

+	int indices[] = new int[items.length];

+

+	for (int i = 0; i < items.length; i++) {

+		indices[i] = getIndex(items[i]);

+	}	

+	return indices;

+}

+/**
+ * Returns the zero-relative index of the item which is currently
+ * at the top of the receiver. This index can change when items are
+ * scrolled or new items are added or removed.
+ *
+ * @return the index of the top item
+ *
+ * @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 getTopIndex() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return super.getTopIndex();

+}

+/**

+ * Answer the index of 'item' in the receiver.

+ * Answer -1 if the item is not visible.

+ * The returned index must refer to a visible item.

+ * Note: 

+ * 	Visible in this context does not neccessarily mean that the 

+ * 	item is displayed on the screen. It only means that the item 

+ * 	would be displayed if it is located inside the receiver's 

+ * 	client area.

+ *	Every item in a table widget should be visible.

+ */

+int getVisibleIndex(SelectableItem item) {

+	return getIndex(item);

+}

+/**

+ * Answer the SelectableItem located at 'itemIndex' in the receiver.

+ * @param itemIndex - location of the SelectableItem object to return

+ */

+SelectableItem getVisibleItem(int itemIndex) {

+	Vector items = getItemVector();

+	TableItem item = null;

+	

+	if ((items != null) && (itemIndex >= 0) && (itemIndex < items.size())) {

+		item = (TableItem) items.elementAt(itemIndex);

+	}

+	return item;

+}

+/**

+ * Answer the y coordinate at which 'item' is drawn. 

+ * @param item - SelectableItem for which the paint position 

+ *	should be returned

+ * @return the y coordinate at which 'item' is drawn.

+ *	Return -1 if 'item' is null or outside the client area

+ */

+int getVisibleRedrawY(SelectableItem item) {

+	int redrawY = -1;

+	int index = getTopIndex();

+	int bottomIndex = getBottomIndex();

+	

+	if (item == null) {

+		return redrawY;

+	}

+	while (index < bottomIndex && item.equals(getVisibleItem(index)) == false) {

+		index++;

+	}

+	if (index < bottomIndex) {

+		redrawY = getRedrawY(item);

+	}

+	return redrawY;

+}

+/**

+ * Handle the events the receiver is listening to.

+ */

+void handleEvents(Event event) {

+	switch (event.type) {

+		case SWT.MouseMove:

+			if (event.widget == tableHeader) {

+				headerMouseMove(event);

+			}

+			else {

+				columnMouseMove(event);

+			}

+			break;

+		case SWT.MouseDown:

+			if (event.widget == tableHeader) {

+				headerMouseDown(event);

+			}

+			else {

+				columnMouseDown(event);

+			}

+			break;

+		case SWT.MouseDoubleClick:

+			columnMouseDoubleClick(event);

+			break;

+		case SWT.MouseUp:

+			mouseUp(event);

+			break;

+		case SWT.Paint:

+			paint(event);

+			break;

+		default:

+			super.handleEvents(event);

+	}		

+}

+/**

+ * Answer true if any item in the first column has an image.

+ * Answer false otherwise.

+ */

+boolean hasFirstColumnImage() {

+	return firstColumnImage;

+}

+public boolean isFocusControl() {

+	return hasColumnFocus;

+}

+/**

+ * The mouse pointer was pressed down on the receiver's header

+ * widget. Start a column resize operation if apropriate.

+ * @param event - the mouse event that occured over the header 

+ *	widget

+ */

+void headerMouseDown(Event event) {

+	TableColumn column = getColumnAtX(event.x);

+

+	if (isColumnResize(event) == true) {

+		startColumnResize(event);

+	}

+	else

+	if (column != null) {

+		column.notifyListeners(SWT.Selection, new Event());

+	}

+}

+/**

+ * The mouse pointer was moved over the receiver's header widget.

+ * If a column is currently being resized a vertical line indicating 

+ * the new position of the resized column is drawn.

+ * Otherwise, if no column resize operation is in progress, the 

+ * column resize cursor is displayed when the mouse is near the border 

+ * of a column.

+ */

+void headerMouseMove(Event event) {

+	if (isColumnResizeStarted() == false) {				// only check whether cursor is in resize

+		setColumnResizeCursor(isColumnResize(event));	// area if no resize operation is in progress

+	}

+	else 

+	if (event.x >= getResizeColumn().getBounds().x) {

+		drawColumnResizeLine(event.x);

+		update();										// looks better if resize line is drawn immediately

+	}

+}

+/**
+ * Searches the receiver's list starting at the first column
+ * (index 0) until a column is found that is equal to the 
+ * argument, and returns the index of that column. If no column
+ * is found, returns -1.
+ *
+ * @param column the search column
+ * @return the index of the column
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string 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>
+ */

+public int indexOf(TableColumn column) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (column == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	return internalGetColumnVector().indexOf(column);

+}

+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param item the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string 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>
+ */

+public int indexOf(TableItem item) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (item == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}	

+	return getIndex(item);

+}

+/**

+ * Initialize the receiver. Create a header widget and an empty column.

+ */

+void initialize() {

+	columns = new Vector();

+	setItemVector(new Vector());

+	focusProxy = new Button(this, SWT.NULL);

+	focusProxy.setBounds(0, 0, 0, 0);				// make the focus proxy invisible

+	tableHeader = new Header(this);

+	tableHeader.setVisible(false);					// SWT table header is invisible by default, too

+	fillColumn = TableColumn.createFillColumn(this);

+	setColumnPosition(fillColumn);

+	defaultColumn = TableColumn.createDefaultColumn(this);	// Create the default column. Fix for 1FUSJY5	

+	super.initialize();

+}

+/**

+ * Insert the new column 'column' into the table data at position 

+ * 'index'.

+ */

+void insertColumnData(TableColumn column) {

+	Enumeration tableItems = getItemVector().elements();

+	TableItem tableItem;

+	

+	while (tableItems.hasMoreElements() == true ) {

+		tableItem = (TableItem) tableItems.nextElement();

+		tableItem.insertColumn(column);

+	}

+}

+/**

+ * Insert the new column 'column'.

+ * Set the position and move the following columns to the right.

+ */

+void insertColumnVisual(TableColumn column) {

+	Rectangle columnBounds = column.getBounds();

+	Rectangle previousColumnBounds;

+	int index = column.getIndex();

+		

+	if (index > 0) {

+		previousColumnBounds = getColumn(index - 1).getBounds();

+		columnBounds.x = previousColumnBounds.x + previousColumnBounds.width;

+	}

+	else {

+		columnBounds.x = 0;

+	}

+	column.setBounds(columnBounds);

+	setColumnPosition(column);

+}

+/**

+ * Set event listeners for the receiver.

+ */

+void installListeners() {

+	Header tableHeader = getHeader();

+	Control focusWindow = getFocusWindow();

+	Listener listener = getListener();

+

+	super.installListeners();	

+	tableHeader.addListener(SWT.MouseMove, listener);

+	tableHeader.addListener(SWT.MouseDown, listener);

+	tableHeader.addListener(SWT.MouseUp, listener);

+	

+	// HACK: All we're really interested in is focus change and key down

+	// for the table itself. Doesn't work that way because setFocus sets 

+	// focus to the first child of the receiver (which is our focus window)

+	removeListener(SWT.FocusOut, listener);

+	removeListener(SWT.FocusIn, listener);	

+	focusWindow.addListener(SWT.FocusOut, listener);

+	focusWindow.addListener(SWT.FocusIn, listener);

+	focusWindow.addListener(SWT.KeyDown, listener);			

+	

+	addListener(SWT.MouseMove, listener);

+	addListener(SWT.MouseDown, listener);

+	addListener(SWT.MouseDoubleClick, listener);

+	addListener(SWT.MouseUp, listener);

+	addListener(SWT.Paint, listener);

+}

+/**

+ * Answer the TableColumn at 'index'.

+ * If the user has not created any columns the default column is 

+ * returned if index is 0.

+ * Fix for 1FUSJY5 

+ */

+TableColumn internalGetColumn(int index) {

+	Vector columns = internalGetColumnVector();

+	

+	if (columns == null) error(SWT.ERROR_CANNOT_GET_ITEM);

+	if (index < 0 || index >= columns.size()) {

+		error(SWT.ERROR_INVALID_RANGE);

+	}

+	

+	return (TableColumn) columns.elementAt(index);

+

+}

+/**

+ * Answer the number of columns in the receiver.

+ * If the user has not created any columns, 1 is returned since there 

+ * always is a default column.

+ * Fix for 1FUSJY5

+ */

+int internalGetColumnCount() {

+	Vector columns = internalGetColumnVector();

+	int count = 0;

+	

+	if (columns != null) {

+		count = columns.size();

+	}

+	return count;

+}

+/**

+ * Return a Vector containing all columns of the receiver except 

+ * the fill column to the right of all content columns.

+ * Return a Vector containing the default column if the user has

+ * not created any columns.

+ * Fix for 1FUSJY5 

+ */

+Vector internalGetColumnVector() {

+	Vector internalColumnVector;

+	TableColumn defaultColumn;

+	

+	if (columns.isEmpty() == false) {

+		internalColumnVector = columns;

+	}

+	else {

+		internalColumnVector = new Vector(1);

+		defaultColumn = getDefaultColumn();		

+		if (defaultColumn != null) {

+			internalColumnVector.addElement(defaultColumn);

+		}

+	}

+	return internalColumnVector;

+}

+/**

+ * Answer whether the mouse pointer is at a position that can

+ * start a column resize operation. A column resize can be 

+ * started if the mouse pointer is at either the left or right 

+ * border of a column.

+ * @param event - mouse event specifying the location of the 

+ *	mouse pointer.

+ */

+boolean isColumnResize(Event event) {

+	TableColumn hotColumn = getColumnAtX(event.x);

+	if (hotColumn == null) return false;

+	Rectangle bounds = hotColumn.getBounds();

+	int hotColumnIndex = hotColumn.getIndex();

+	int columnX = event.x - bounds.x;

+	boolean isColumnResize = false;

+

+	if (columnX <= COLUMN_RESIZE_OFFSET && 									// mouse over left side of column? and

+		hotColumnIndex != TableColumn.FIRST) {								// it's not the first column)

+		if (hotColumnIndex == TableColumn.FILL) {

+			hotColumn = (TableColumn) internalGetColumnVector().lastElement();

+		}

+		else {

+			hotColumn = internalGetColumn(hotColumnIndex - 1);

+		}

+		isColumnResize = hotColumn.getResizable();							// check whether left column can be resized

+	}

+	else

+	if (columnX >= bounds.width - COLUMN_RESIZE_OFFSET && 					// mouse over right side of column and

+		hotColumn != getFillColumn()) {										// column is a real one (not the right hand fill column)?

+		isColumnResize = hotColumn.getResizable();							// check whether column under cursor can be resized

+	}

+	return isColumnResize;

+}

+/**

+ * Answer whether a column of the receiver is being resized.

+ */

+boolean isColumnResizeStarted() {

+	return (getResizeColumn() != null);

+}

+/**
+ * Returns <code>true</code> if the item is selected,
+ * and <code>false</code> otherwise.  Indices out of
+ * range are ignored.
+ *
+ * @param index the index of the item
+ * @return the visibility state of the item at the index
+ *
+ * @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 isSelected(int index) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	TableItem item = getItem(index);

+

+	return (item != null && item.isSelected() == true);

+}

+/**

+ * 'changedItem' has changed. Update the default column width.

+ * @param changedItem - the item that has changed

+ */

+void itemChanged(SelectableItem changedItem, int repaintStartX, int repaintWidth) {

+	// call super.itemChanged first to make sure that table image size is 

+	// calculated if necessary. Fixes 1FYPBBG.

+	super.itemChanged(changedItem, repaintStartX, repaintWidth);

+	// remember if any item ever had an image in the first column.

+	if (firstColumnImage == false && changedItem.getImage() != null) {

+		firstColumnImage = true;

+	}

+	setFirstColumnWidth((TableItem) changedItem);	

+}

+/**

+ * A mouse button was released. 

+ * Update the display if a column has been resized.

+ * @param event - the mouse event for the button up action

+ */

+void mouseUp(Event event) {

+	TableColumn resizeColumn = getResizeColumn();

+	Rectangle oldColumnBounds;

+	int resizeXPosition;

+	int widthChange;

+	

+	if (isColumnResizeStarted() == true) {

+		oldColumnBounds = resizeColumn.getBounds();

+		resizeXPosition = getColumnResizeX();	

+		widthChange = resizeXPosition - (oldColumnBounds.x + oldColumnBounds.width);

+		if (widthChange != 0) {

+			if (widthChange > 0) {

+				redraw(resizeXPosition, 0, 1, getClientArea().height, false);		// remove resize line

+				update();															// to avoid cheese caused by scrolling the resize line

+			}

+			resizeColumn.setWidth(oldColumnBounds.width + widthChange);

+		}

+		setResizeColumn(null);

+	}

+}

+/**

+ * Adjust the position of all columns starting at 'startIndex'.

+ * @param startIndex - index at which the column move should begin

+ *	If this is the index of the fill column all columns are moved,

+ * 	including the fill column

+ * @param moveDistance - distance that the columns should be moved.

+ *	< 0 = columns are going to be moved left.

+ *	> 0 = columns are going to be moved right.

+ */

+void moveColumns(int startIndex, int moveDistance) {

+	Vector columns = internalGetColumnVector();

+	TableColumn moveColumn;

+	Rectangle columnBounds;

+

+	if (startIndex == TableColumn.FILL) {

+		moveColumn = getFillColumn();

+		columnBounds = moveColumn.getBounds();

+		columnBounds.x += moveDistance;

+		moveColumn.setBounds(columnBounds);

+		startIndex = 0;					// continue with first data column

+	}

+	for (int i = startIndex; i < columns.size(); i++) {

+		moveColumn = (TableColumn) columns.elementAt(i);

+		columnBounds = moveColumn.getBounds();

+		columnBounds.x += moveDistance;

+		moveColumn.setBounds(columnBounds);

+	}

+}

+/**

+ * Adjust the y position of all columns including the fill column.

+ */

+void moveColumnsVertical() {

+	Enumeration columns = internalGetColumnVector().elements();

+	TableColumn column;

+

+	setColumnPosition(getFillColumn());

+	while (columns.hasMoreElements() == true) {

+		column = (TableColumn) columns.nextElement();

+		setColumnPosition(column);

+	}

+}

+/** 

+ * A paint event has occurred. Paint the invalidated items.

+ * @param event - paint event specifying the invalidated area.

+ */

+void paint(Event event) {

+	int visibleRange[];

+	int headerHeight = getHeaderHeight();

+	Vector paintColumns = getPaintColumns(event.getBounds());

+	TableItem focusItem = null;

+	

+	if (paintColumns.size() > 0) {

+		event.y -= headerHeight;

+		visibleRange = getIndexRange(event.getBounds());

+		event.y += headerHeight;

+		// When the top index is > 0 and the receiver is resized 

+		// higher so that the top index becomes 0 the invalidated 

+		// rectangle doesn't start below the header widget but at 

+		// y position 0. Subtraction of the header height (it is 

+		// not above the receiver but on top) causes event.y and 

+		// subsequently visibleRange[0] to be negative.

+		// Hack to prevent visibleRange[0] from becoming negative.

+		// Need to find out why the invalidated area starts at 0

+		// in the first place.

+		if (visibleRange[0] < 0) {

+			visibleRange[0] = 0;

+		}

+		// 

+		visibleRange[1] = Math.min(visibleRange[1], getItemCount()-1-getTopIndex());

+		focusItem = paintItems(event, visibleRange[0], visibleRange[1], paintColumns);

+	}

+	if (getLinesVisible() == true) {

+		drawGridLines(event, paintColumns.elements());

+	}

+	if (focusItem != null) {

+		// draw focus on top of drawing grid lines so that focus rectangle 

+		// is not obscured by grid. Fixes 1G5X20B

+		drawSelectionFocus(focusItem, event.gc);	

+	}

+}

+

+/**

+ * Paint items of the receiver starting at index 'topPaintIndex' and 

+ * ending at 'bottomPaintIndex'.

+ * @param event - holds the GC to draw on and the clipping rectangle

+ * @param topPaintIndex - index of the first item to draw

+ * @param bottomPaintIndex - index of the last item to draw

+ * @param paintColumns - the table columns that should be painted

+ * @return the item that has focus if it was among the rendered items.

+ *	null if the focus item was not rendered or if no item has focus (ie. 

+ *	because the widget does not have focus)

+ */

+TableItem paintItems(Event event, int topPaintIndex, int bottomPaintIndex, Vector paintColumns) {

+	Enumeration columns;

+	TableColumn column;

+	TableItem paintItem;

+	TableItem focusItem = null;

+	Point selectionExtent;

+	Point selectionPosition;

+	int itemHeight = getItemHeight();

+

+	topPaintIndex += getTopIndex();

+	bottomPaintIndex += getTopIndex();

+	for (int i = topPaintIndex; i <= bottomPaintIndex; i++) {

+		paintItem = (TableItem) getVisibleItem(i);

+		selectionExtent = paintItem.getSelectionExtent();

+		if (selectionExtent != null) {

+			selectionPosition = new Point(paintItem.getSelectionX(), getRedrawY(paintItem));

+			drawSelection(paintItem, event.gc, selectionPosition, selectionExtent);

+		}

+		columns = paintColumns.elements();

+		while (columns.hasMoreElements() == true) {

+			column = (TableColumn) columns.nextElement();

+			paintSubItem(event, paintItem, column, i * itemHeight);

+		}

+		if (hasFocus(paintItem)) {

+			focusItem = paintItem;

+		}

+	}

+	return focusItem;

+}

+

+/**

+ * Paint the table item 'paintItem' in 'column' at y position 

+ * 'paintYPosition' of the receiver.

+ * @param event - holds the GC to draw on and the clipping 

+ *	rectangle.

+ * @param paintItem - the item to draw

+ * @param column - column to draw 'paintItem' in

+ * @param paintYPosition - y position in the receiver to draw 

+ *	'paintItem' at.

+ */

+void paintSubItem(Event event, TableItem paintItem, TableColumn column, int paintYPosition) {

+	Rectangle columnBounds = column.getBounds();

+	int gridLineWidth = getGridLineWidth();

+	int itemDrawStopX = columnBounds.x + columnBounds.width - gridLineWidth;

+	int clipX;

+	

+	if (event.x + event.width > itemDrawStopX) {	// does the invalidated area stretch past the current column's right border?

+		clipX = Math.max(columnBounds.x, event.x);

+		event.gc.setClipping(											// clip the drawing area

+			clipX, event.y, 

+			itemDrawStopX - clipX, event.height);		

+	}

+	column.paint(paintItem, event.gc, paintYPosition);

+	if (event.x + event.width > itemDrawStopX) {

+		event.gc.setClipping(event.x, event.y, event.width, event.height); // restore original clip rectangle

+	}

+}

+/**

+ * Reindex all columns starting at 'startIndex'.

+ * Reindexing is necessary when a new column has been inserted.

+ */

+void reindexColumns(int startIndex) {

+	Vector columns = getColumnVector();

+	TableColumn column;

+	

+	for (int i = startIndex; i < getColumnCount(); i++) {

+		column = (TableColumn) columns.elementAt(i);

+		column.setIndex(i);

+	}

+}

+/**
+ * Removes the items from the receiver's list at the given
+ * zero-relative indices.
+ *
+ * @param indices the array of indices of the items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */

+public void remove(int indices[]) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItem item;

+	int [] sortedIndices;

+	int last = -1;

+	

+	if (indices == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	sortedIndices = new int[indices.length];	

+	System.arraycopy (indices, 0, sortedIndices, 0, indices.length);

+	sort(sortedIndices);								// sort indices in descending order

+	for (int i = 0; i < sortedIndices.length; i++) {

+		if (sortedIndices[i] != last) {

+			item = getVisibleItem(sortedIndices[i]);

+			if (item != null) {

+				item.dispose();

+			}

+			else {

+				error(SWT.ERROR_ITEM_NOT_REMOVED);

+			}

+			last = sortedIndices[i];			

+		}

+	}

+}

+/**
+ * Removes the item from the receiver at the given
+ * zero-relative index.
+ *
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */

+public void remove(int index) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItem item = getVisibleItem(index);

+

+	if (item != null) {

+		item.dispose();

+	}

+	else {

+		error(SWT.ERROR_ITEM_NOT_REMOVED);

+	}

+}

+/**
+ * Removes the items from the receiver which are
+ * between the given zero-relative start and end 
+ * indices (inclusive).
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */

+public void remove(int start, int end) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItem item;

+	

+	for (int i = end; i >= start; i--) {

+		item = getVisibleItem(i);

+		if (item != null) {

+			item.dispose();

+		}

+		else {

+			error(SWT.ERROR_ITEM_NOT_REMOVED);

+		}

+	}

+}

+/**
+ * Removes all of the items from the receiver.
+ * <p>
+ * @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 removeAll() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector items = getItemVector();

+

+	setRedraw(false);

+	setRemovingAll(true);

+	for (int i = 0; i < items.size(); i++) {

+		((TableItem) items.elementAt(i)).dispose();

+	}

+	setItemVector(new Vector());

+	reset();

+	calculateVerticalScrollbar();

+	setRemovingAll(false);

+	setRedraw(true);	

+}

+/**

+ * Remove 'column' from the receiver.

+ */

+void removeColumn(TableColumn column) {

+	TableColumn lastColumn;

+	int index = column.getIndex();

+	int columnWidth = column.getWidth();

+	int columnCount;

+

+	if (isRemovingAll() == true) {

+		getColumnVector().removeElementAt(index);

+	}

+	else {		

+		getColumnVector().removeElementAt(index);

+		columnCount = getColumnCount();

+		// Never remove the data of the last user created column. 

+		// SWT for Windows does the same.

+		if (columnCount > 0) {

+			removeColumnData(column);

+		}

+		removeColumnVisual(column);		

+		if (index < columnCount) {					// is there a column after the removed one?

+			reindexColumns(index);

+		}

+		// last user created column is about to be removed.

+		if (columnCount == 0) {		

+			TableColumn defaultColumn = getDefaultColumn();

+			defaultColumn.pack();						// make sure the default column has the right size...

+			setColumnPosition(defaultColumn);			// ...and is at the right position

+		}

+		// Fixes for 1G1L0UT

+		// Reduce the content width by the width of the removed column

+		setContentWidth(getContentWidth() - columnWidth);

+		// claim free space

+		claimRightFreeSpace();		

+		//

+	}

+}

+/**

+ * Remove the column 'column' from the table data.

+ */

+void removeColumnData(TableColumn column) {

+	Enumeration tableItems = getItemVector().elements();

+	TableItem tableItem;

+

+	while (tableItems.hasMoreElements() == true ) {

+		tableItem = (TableItem) tableItems.nextElement();

+		tableItem.removeColumn(column);

+	}

+}

+/**

+ * Remove the column 'column'.

+ * Set the position of the following columns.

+ */

+void removeColumnVisual(TableColumn column) {

+	int columnWidth = column.getWidth();

+		

+	// move following columns to the left

+	moveColumns(column.getIndex() + 1, columnWidth * -1);

+	redraw();

+	getHeader().redraw();

+}

+/** 

+ * Remove 'item' from the receiver. 

+ * @param item - item that should be removed from the receiver

+ */

+void removeItem(TableItem item) {

+	Vector items = getItemVector();

+	int index = items.indexOf(item);

+

+	if (index != -1) {

+		if (isRemovingAll() == false) {

+			removingItem(item);	

+		}			

+		items.removeElementAt(index);

+		for (int i = index; i < items.size(); i++) {

+			TableItem anItem = (TableItem) items.elementAt(i);

+			anItem.setIndex(anItem.getIndex() - 1);

+		}		

+		if (isRemovingAll() == false) {

+			removedItem(item);

+		}			

+	}

+}

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's selection changes.
+ *
+ * @param listener the listener which should no longer 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 SelectionListener
+ * @see #addSelectionListener
+ */

+public void removeSelectionListener(SelectionListener listener) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	if (listener == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	removeListener(SWT.Selection, listener);

+	removeListener(SWT.DefaultSelection, listener);

+}

+/** 

+ * Reset cached data of column at 'columnIndex' for the items of the receiver. 

+ * @param columnIndex - index of the column for which the item data should be 

+ *	reset.

+ */

+void resetTableItems(int columnIndex) {

+	Enumeration tableItems = getItemVector().elements();

+	TableItem tableItem;

+

+	while (tableItems.hasMoreElements() == true ) {

+		tableItem = (TableItem) tableItems.nextElement();

+		tableItem.reset(columnIndex);

+	}

+}

+/**

+ * The receiver has been resized. Resize the fill column 

+ * and the header widget.

+ */

+void resize(Event event) {

+	TableColumn fillColumn = getFillColumn();

+	Rectangle fillColumnBounds;

+

+	super.resize(event);

+	// the x position may change in super.resize.

+	// get the column bounds after calling super.resize. Fixes 1G7ALGG

+	fillColumnBounds = fillColumn.getBounds();

+	fillColumnBounds.width = Math.max(0, getClientArea().width - getContentWidth());

+	fillColumn.setBounds(fillColumnBounds);

+	resizeHeader();

+}

+/**

+ * Resize the header widget to occupy the whole width of the

+ * receiver.

+ */

+void resizeHeader() {

+	Header tableHeader = getHeader();

+	Point size = tableHeader.getSize();

+

+	size.x = Math.max(getContentWidth(), getClientArea().width);

+	tableHeader.setSize(size);

+}

+/**

+ * Redraw 'column' after its width has been changed.

+ * @param column - column whose width has changed.

+ * @param oldColumnWidth - column width before resize

+ * @param oldColumnWidth - column width after resize 

+ */

+void resizeRedraw(TableColumn column, int oldColumnWidth, int newColumnWidth) {

+	Rectangle columnBounds = column.getBounds();

+	int columnIndex = column.getIndex();

+	int oldRedrawStartX[] = getResizeRedrawX(columnIndex, oldColumnWidth);

+	int newRedrawStartX[] = getResizeRedrawX(columnIndex, newColumnWidth);

+	int itemHeight = getItemHeight();

+	int widthChange = newColumnWidth - oldColumnWidth;

+	int topIndex = getTopIndex();

+

+	for (int i = 0; i < newRedrawStartX.length; i++) {

+		if (newRedrawStartX[i] != oldRedrawStartX[i]) {

+			if (widthChange > 0) {

+				newRedrawStartX[i] = oldRedrawStartX[i];

+			}

+			redraw(

+				columnBounds.x + newRedrawStartX[i], columnBounds.y + itemHeight * (i + topIndex), 

+				columnBounds.width - newRedrawStartX[i], itemHeight, false);

+		}

+	}

+}

+/**

+ * Scroll horizontally by 'numPixel' pixel.

+ * @param numPixel - the number of pixel to scroll

+ *	< 0 = columns are going to be moved left.

+ *	> 0 = columns are going to be moved right.

+ */

+void scrollHorizontal(int numPixel) {

+	Rectangle clientArea = getClientArea();	

+

+	scroll(

+		numPixel, 0, 								// destination x, y

+		0, 0, 										// source x, y

+		clientArea.width, clientArea.height, true);

+	getHeader().scroll(

+		numPixel, 0, 								// destination x, y

+		0, 0, 										// source x, y

+		clientArea.width, clientArea.height, true);

+	moveColumns(TableColumn.FILL, numPixel);

+}

+/**

+ * Scroll vertically by 'scrollIndexCount' items.

+ * @param scrollIndexCount - the number of items to scroll.

+ *	scrollIndexCount > 0 = scroll up. scrollIndexCount < 0 = scroll down

+ */

+void scrollVertical(int scrollIndexCount) {

+	int scrollAmount = scrollIndexCount * getItemHeight();

+	int headerHeight = getHeaderHeight();

+	int destY;

+	int sourceY;

+	boolean scrollUp = scrollIndexCount < 0;

+	Rectangle clientArea = getClientArea();

+

+	if (scrollIndexCount == 0) {

+		return;

+	}

+	if (scrollUp == true) {

+		destY = headerHeight - scrollAmount;

+		sourceY = headerHeight;

+	}

+	else {

+		destY = headerHeight;

+		sourceY = destY + scrollAmount;

+	}

+	scroll(

+		0, destY, 									// destination x, y

+		0, sourceY,									// source x, y

+		clientArea.width, clientArea.height, true);

+}

+/**

+ * Scroll items down to make space for a new item added to 

+ * the receiver at position 'index'.

+ * @param index - position at which space for one new item

+ *	should be made. This index is relative to the first item 

+ *	of the receiver.

+ */

+void scrollVerticalAddingItem(int index) {

+	int itemHeight = getItemHeight();

+	int sourceY = getHeaderHeight();

+	Rectangle clientArea = getClientArea();	

+

+	if (index >= getTopIndex()) {

+		sourceY += (index-getTopIndex()) * itemHeight;

+	}

+	scroll(

+		0, sourceY + itemHeight, 				// destination x, y

+		0, sourceY,								// source x, y

+		clientArea.width, clientArea.height, true);

+}

+/**

+ * Scroll the items below the item at position 'index' up 

+ * so that they cover the removed item.

+ * @param index - index of the removed item

+ */

+void scrollVerticalRemovedItem(int index) {

+	int itemHeight = getItemHeight();

+	int headerHeight = getHeaderHeight();

+	int destY;

+	Rectangle clientArea = getClientArea();		

+

+	destY = Math.max(headerHeight, headerHeight + (index - getTopIndex()) * itemHeight);

+	scroll(

+		0, destY, 								// destination x, y

+		0, destY + itemHeight,					// source x, y

+		clientArea.width, clientArea.height, true);

+}

+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * If the item at the given zero-relative index in the receiver 
+ * is not selected, it is selected.  If the item at the index
+ * was selected, it remains selected. Indices that are out
+ * of range and duplicate indices are ignored.
+ *
+ * @param indices the array of indices for the items to select
+ *
+ * @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>
+ */

+public void select(int indices[]) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItem item = null;

+	int selectionCount;

+

+	if (indices == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	selectionCount = indices.length;

+	if (isMultiSelect() == false && selectionCount > 1) {

+		selectionCount = 1;

+		deselectAllExcept(getVisibleItem(indices[0]));

+	}

+	for (int i = selectionCount - 1; i >= 0; --i) {

+		item = getVisibleItem(indices[i]);

+		if (item != null) {

+			select(item);

+		}

+	}

+	if (item != null) {

+		setLastSelection(item, false);

+	}

+}

+/**
+ * Selects the item at the given zero-relative index in the receiver. 
+ * If the item at the index was already selected, it remains
+ * selected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to select
+ *
+ * @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 select(int index) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItem item = getVisibleItem(index);

+	

+	if (isMultiSelect() == false) {

+		deselectAllExcept(getVisibleItem(index));

+	}

+	if (item != null) {

+		select(item);

+		setLastSelection(item, false);

+	}

+}

+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * If the item at the index was already selected, it remains
+ * selected. The range of the indices is inclusive. Indices that are
+ * out of range are ignored.
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @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 select(int start, int end) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItem item = null;

+	int selectionCount = 1;

+	

+	if (isMultiSelect() == false) {

+		if (start < 0 && end >= 0) {

+			start = 0;

+		}

+		end = start;

+		deselectAllExcept(getVisibleItem(end));

+	}

+	// select in the same order as all the other selection and deslection methods.

+	// Otherwise setLastSelection repeatedly changes the lastSelectedItem for repeated 

+	// selections of the items, causing flash.

+	for (int i = end; i >= start; i--) {

+		item = getVisibleItem(i);

+		if (item != null) {

+			select(item);

+		}

+	}

+	if (item != null) {

+		setLastSelection(item, false);

+	}

+}

+/**
+ * Selects all the items in the receiver.
+ *
+ * @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 selectAll() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Enumeration items = getItemVector().elements();

+	TableItem item = null;

+

+	if (isMultiSelect() == false) {

+		return;

+	}

+	while (items.hasMoreElements() == true) {

+		item = (TableItem) items.nextElement();

+		select(item);

+	}

+	if (item != null) {

+		setLastSelection(item, false);

+	}

+}

+/**

+ * Set the y position of 'column'.

+ * @param column - the TableColumn that should be set to 

+ *	a new y position.

+ */

+void setColumnPosition(TableColumn column) {

+	Rectangle bounds = column.getBounds();

+

+	bounds.y = getHeaderHeight() - getTopIndex() * getItemHeight();

+	column.setBounds(bounds);	

+}

+/**

+ * Change the cursor of the receiver.

+ * @param isColumnResizeCursor - indicates whether the column 

+ *	resize cursor or the regular cursor should be set.

+ */

+void setColumnResizeCursor(boolean isColumnResizeCursor) {

+	if (isColumnResizeCursor != this.isColumnResizeCursor) {

+		this.isColumnResizeCursor = isColumnResizeCursor;

+		if (isColumnResizeCursor == true) {

+			setCursor(getColumnResizeCursor());

+		}

+		else {

+			setCursor(null);

+		}

+	}

+}

+/**

+ * Set the current position of the resized column to 'xPosition'.

+ * @param xPosition - the current position of the resized column

+ */

+void setColumnResizeX(int xPosition) {

+	columnResizeX = xPosition;

+}

+/**

+ * Set the width of the receiver's contents to 'newWidth'.

+ * Content width is used to calculate the horizontal scrollbar.

+ */

+void setContentWidth(int newWidth) {

+	TableColumn fillColumn = getFillColumn();

+	Rectangle fillColumnBounds;

+	int widthDiff = newWidth - getContentWidth();

+

+	super.setContentWidth(newWidth);

+	if (fillColumn != null) {

+		fillColumnBounds = fillColumn.getBounds();

+		fillColumnBounds.x += widthDiff;

+		fillColumnBounds.width = Math.max(0, getClientArea().width - newWidth);

+		fillColumn.setBounds(fillColumnBounds);

+	}

+}

+/**

+ * Set the width of the first column to fit 'item' if it is longer than 

+ * the current column width.

+ * Do nothing if the user has already set a width.

+ */

+void setFirstColumnWidth(TableItem item) {

+	int newWidth;

+	TableColumn column;

+

+	if (internalGetColumnCount() > 0) {

+		column = internalGetColumn(TableColumn.FIRST);		

+		if (column.isDefaultWidth() == true) {

+			newWidth = Math.max(column.getWidth(), item.getPreferredWidth(TableColumn.FIRST));

+			column.setWidth(newWidth);

+			column.setDefaultWidth(true);					// reset to true so that we know when the user has set 

+															// the width instead of us setting a default width.

+		}

+	}

+}

+public void setFont(Font font) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItem item;

+	int itemCount = getItemCount();

+

+	if (font == null || font.equals(getFont()) == true) {

+		return;

+	}

+	setRedraw(false);						// disable redraw because itemChanged() triggers undesired redraw	

+	resetItemData();	

+	super.setFont(font);

+	for (int i = 0; i < itemCount; i++) {

+		itemChanged(getItem(i), 0, getClientArea().width);

+	}

+	setRedraw(true);						// re-enable redraw

+	getHeader().setFont(font);

+}

+/**
+ * Marks the receiver's header as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility 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 void setHeaderVisible(boolean headerVisible) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (headerVisible != getHeaderVisible()) {

+		getHeader().setLocation(0, 0);

+		getHeader().setVisible(headerVisible);

+		// Windows resets scrolling so do we

+		setTopIndex(0, true);

+		moveColumnsVertical();

+		resizeVerticalScrollbar();

+		redraw();

+	}

+}

+/**

+ * Set the vector that stores the items of the receiver 

+ * to 'newVector'.

+ * @param newVector - Vector to use for storing the items of 

+ *	the receiver.

+ */

+void setItemVector(Vector newVector) {

+	items = newVector;

+}

+/**
+ * Marks the receiver's lines as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility 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 void setLinesVisible(boolean drawGridLines) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (this.drawGridLines != drawGridLines) {

+		this.drawGridLines = drawGridLines;

+		redraw();

+	}

+}

+public void setRedraw(boolean redraw) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	super.setRedraw(redraw);

+	getHeader().setRedraw(redraw);

+}

+/**

+ * Set the column that is being resized to 'column'. 

+ * @param column - the TableColumn that is being resized. 

+ * 	A null value indicates that no column resize operation is 

+ *	in progress.

+ */

+void setResizeColumn(TableColumn column) {

+	resizeColumn = column;

+}

+/**
+ * Selects the items at the given zero-relative indices in the receiver. 
+ * The current selected is first cleared, then the new items are selected.
+ *
+ * @param indices the indices of the items to select
+ *
+ * @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 Table#deselectAll()
+ * @see Table#select(int[])
+ */

+public void setSelection(int [] indices) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector keepSelected;

+	

+	if (indices == null)  {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}	

+	keepSelected = new Vector(indices.length);

+	for (int i = 0; i < indices.length; i++) {

+		SelectableItem item = getVisibleItem(indices[i]);

+		if (item != null) {

+			keepSelected.addElement(item);

+		}

+	}

+	deselectAllExcept(keepSelected);

+	select(indices);

+}

+/**
+ * Sets the receiver's selection to be the given array of items.
+ * The current selected is first cleared, then the new items are
+ * selected.
+ *
+ * @param items the array of items
+ *
+ * @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 Table#deselectAll()
+ * @see Table#select(int)
+ */

+public void setSelection(TableItem selectionItems[]) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (selectionItems == null)  {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}	

+	setSelectableSelection(selectionItems);

+}

+/**
+ * Selects the item at the given zero-relative index in the receiver. 
+ * The current selected is first cleared, then the new item is selected.
+ *
+ * @param index the index of the item to select
+ *
+ * @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 Table#deselectAll()
+ * @see Table#select(int)
+ */

+public void setSelection(int index) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	deselectAllExcept(getVisibleItem(index));

+	select(index);

+}

+/**
+ * Selects the items at the given zero-relative indices in the receiver. 
+ * The current selected if first cleared, then the new items are selected.
+ *
+ * @param start the start index of the items to select
+ * @param end the end index of the items to select
+ *
+ * @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 Table#deselectAll()
+ * @see Table#select(int,int)
+ */

+public void setSelection(int start, int end) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector keepSelected = new Vector(end - start + 1);

+	

+	for (int i = start; i <= end; i++) {

+		SelectableItem item = getVisibleItem(i);

+		if (item != null) {

+			keepSelected.addElement(item);

+		}

+	}	

+	deselectAllExcept(keepSelected);

+	select(start, end);

+}

+/**
+ * Sets the zero-relative index of the item which is currently
+ * at the top of the receiver. This index can change when items
+ * are scrolled or new items are added and removed.
+ *
+ * @param index the index of the top item
+ *
+ * @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 setTopIndex(int index) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	int itemCount = getItemCount();

+	int itemCountWhole = getItemCountWhole();

+	

+	if (index < 0 || itemCount == 0) {

+		return;

+	}

+	if (index >= itemCount) {

+		index = itemCount - itemCountWhole;

+	}

+	super.setTopIndex(index, true);

+}

+/**

+ * Set the index of the first visible item in the receiver's client 

+ * area to 'index'.

+ * @param index - 0-based index of the first visible item in the 

+ *	receiver's client area.

+ * @param adjustScrollbar - true=set the position of the vertical 

+ *	scroll bar to the new top index. 

+ *	false=don't adjust the vertical scroll bar

+ */

+void setTopIndexNoScroll(int index, boolean adjustScrollbar) {

+	super.setTopIndexNoScroll(index, adjustScrollbar);

+	moveColumnsVertical();

+}

+/**
+ * Shows the item.  If the item is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled until
+ * the item is visible.
+ *
+ * @param item the item to be shown
+ *
+ * @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 Table#showSelection()
+ */

+public void showItem(TableItem item) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (item == null)  {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}	

+	showSelectableItem(item);

+}

+/**
+ * Shows the selection.  If the selection is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled until
+ * the selection is visible.
+ *
+ * @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 Table#showItem(TableItem)
+ */

+public void showSelection() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	super.showSelection();

+}

+void sort (int [] items) {

+	/* Shell Sort from K&R, pg 108 */

+	int length = items.length;

+	for (int gap=length/2; gap>0; gap/=2) {

+		for (int i=gap; i<length; i++) {

+			for (int j=i-gap; j>=0; j-=gap) {

+		   		if (items [j] <= items [j + gap]) {

+					int swap = items [j];

+					items [j] = items [j + gap];

+					items [j + gap] = swap;

+		   		}

+	    	}

+	    }

+	}

+}

+/**

+ * Start a column resize operation.

+ * @param event - the mouse event that occured over the header 

+ * 	widget

+ */

+void startColumnResize(Event event) {

+	Vector columns = internalGetColumnVector();

+	TableColumn hitColumn = getColumnAtX(event.x);

+	Rectangle hitColumnBounds;

+	int hitIndex = hitColumn.getIndex();

+

+	if (hitColumn == getFillColumn()) {										// clicked on the fill column?

+		hitColumn = (TableColumn) columns.lastElement();					// resize the last real column

+	}

+	else 

+	if ((event.x - hitColumn.getBounds().x <= COLUMN_RESIZE_OFFSET) && 		// check if left side of a column was clicked

+		(hitIndex > 0)) {													

+		hitColumn = (TableColumn) columns.elementAt(hitIndex - 1);			// resize the preceding column

+	}

+	hitColumnBounds = hitColumn.getBounds();

+	setColumnResizeX(hitColumnBounds.x + hitColumnBounds.width);

+	setResizeColumn(hitColumn);

+}

+/**

+ * Return 'text' after it has been checked to be no longer than 'maxWidth' 

+ * when drawn on 'gc'.

+ * If it is too long it will be truncated up to the last character.

+ * @param text - the String that should be checked for length

+ * @param maxWidth - maximum width of 'text'

+ * @param gc - GC to use for String measurement

+ */

+String trimItemText(String text, int maxWidth, GC gc) {

+	int textWidth;

+	int dotsWidth;

+

+	if (text != null && text.length() > 1) {

+		textWidth = gc.stringExtent(text).x;

+		if (textWidth >= maxWidth) {

+			dotsWidth = getDotsWidth(gc);

+			while (textWidth + dotsWidth >= maxWidth && text.length() > 1) {

+				text = text.substring(0, text.length() - 1);		// chop off one character at the end

+				textWidth = gc.stringExtent(text).x;

+			}

+			text = text.concat(Table.DOT_STRING);

+		}

+	}

+	return text;

+}

+

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TableColumn.java
new file mode 100755
index 0000000..dc981d2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TableColumn.java
@@ -0,0 +1,495 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+ 

+import org.eclipse.swt.*;

+import org.eclipse.swt.events.*;

+import org.eclipse.swt.graphics.*;

+ 

+/**
+ * Instances of this class represent a column in a table widget.
+ *  <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>LEFT, RIGHT, CENTER</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd> Move, Resize, Selection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */

+public /*final*/ class TableColumn extends Item {

+	static final int FIRST = 0;							// index of the first column

+	static final int FILL = -1;							// index that identifies the column used to 

+														// fill space not used by other columns.

+	private static final int DEFAULT_WIDTH = 10;

+

+	private Table parent;

+	private int index;									// 0-based column index

+	private Rectangle bounds = new Rectangle(0, 0, 0, 0);

+	private boolean isDefaultWidth = true;

+	private boolean resize = true;

+/**

+ * Create a new TableColumn without adding it to the parent.

+ * Currently used to create fill columns and default columns.

+ * @see createFillColumn

+ * @see createDefaultColumn

+ * @param parent - Table widget the new instance will be a child of.

+ */

+TableColumn(Table parent) {

+	super(parent, SWT.NULL);

+	this.parent = parent;		

+}

+/**

+ * Create a new instance of TableColumn and append it to the existing 

+ * columns in 'parent'.

+ * @param parent - Table widget the new instance will be a child of.

+ * @param syle - style of the new TableColumn

+ */

+public TableColumn(Table parent, int style) {

+	this(parent, style, checkNull(parent).getColumnCount());

+}

+/**

+ * Create a new instance of TableColumn at position 'index' in the Table

+ * identified by 'parent'.

+ * @param parent - Table widget the new instance will be a child of.

+ * @param index - position in the 'parent' at which the new instance will

+ *	be located relative to the other columns.

+ * @param syle - style of the new TableColumn

+ */

+public TableColumn(Table parent, int style, int index) {

+	super(parent, checkStyle (style), index);

+	

+	this.parent = parent;

+	if (index < 0 || index > parent.getColumnCount()) {

+		error(SWT.ERROR_INVALID_RANGE);

+	}

+	setIndex(index);	

+	parent.addColumn(this);

+	setWidth(DEFAULT_WIDTH);

+	setDefaultWidth(true);

+	addListener(SWT.Dispose, new Listener() {

+		public void handleEvent(Event event) {disposeColumn();}

+	});

+}

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is moved or resized, by sending
+ * it one of the messages defined in the <code>ControlListener</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 ControlListener
+ * @see #removeControlListener
+ */

+public void addControlListener(ControlListener listener) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

+	TypedListener typedListener = new TypedListener (listener);

+	addListener (SWT.Resize,typedListener);

+	addListener (SWT.Move,typedListener);

+}

+/**

+ * Adds the listener to the collection of listeners who will

+ * be notified when the control is selected, by sending

+ * it one of the messages defined in the <code>SelectionListener</code>

+ * interface.

+ * <p>

+ * <code>widgetSelected</code> is called when the column header is selected.

+ * <code>widgetDefaultSelected</code> is not called.

+ * </p>

+ *

+ * @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 SelectionListener

+ * @see #removeSelectionListener

+ * @see SelectionEvent

+ */

+public void addSelectionListener (SelectionListener listener) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

+	TypedListener typedListener = new TypedListener (listener);

+	addListener (SWT.Selection,typedListener);

+	addListener (SWT.DefaultSelection,typedListener);

+}

+/**

+ * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'table' is null.

+ * Otherwise return 'table'

+ */

+static Table checkNull(Table table) {

+	if (table == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

+	return table;

+}

+static int checkStyle (int style) {

+	return checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);

+}

+protected void checkSubclass () {

+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);

+}

+/**

+ * Create a new instance of TableColumn that acts as a default column

+ * if the user does not create a TableColumn.

+ * @param parent - Table widget the new instance will be a child of.

+ */

+static TableColumn createDefaultColumn(Table parent) {

+	TableColumn defaultColumn = new TableColumn(parent);

+	

+	defaultColumn.setIndex(FIRST);

+	defaultColumn.setWidth(DEFAULT_WIDTH);

+	defaultColumn.setDefaultWidth(true);

+	return defaultColumn;

+}

+/**

+ * Create a new instance of TableColumn that acts as the rightmost 

+ * fill column in a Table. The new object is not added to the parent

+ * like a regular column is.

+ * @param parent - Table widget the new instance will be a child of.

+ */

+static TableColumn createFillColumn(Table parent) {

+	TableColumn fillColumn = new TableColumn(parent);

+	

+	fillColumn.setIndex(FILL);

+	return fillColumn;

+}

+/**

+ * Remove the receiver from its parent

+ */

+void disposeColumn() {

+	getParent().removeColumn(this);

+}

+/**
+ * Returns a value which describes the position of the
+ * text or image in the receiver. The value will be one of
+ * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>.
+ *
+ * @return the alignment 
+ *
+ * @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 getAlignment () {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	if ((style & SWT.LEFT) != 0) return SWT.LEFT;

+	if ((style & SWT.CENTER) != 0) return SWT.CENTER;

+	if ((style & SWT.RIGHT) != 0) return SWT.RIGHT;

+	return SWT.LEFT;

+}

+

+/**

+ * Answer the bounding rectangle of the receiver.

+ */

+Rectangle getBounds() {

+	return new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height);	// copy the object to prevent changes

+}

+public Display getDisplay() {

+	if (parent == null) {		// access parent field directly to prevent endless recursion

+		error(SWT.ERROR_WIDGET_DISPOSED);

+	}

+	return parent.getDisplay();

+}

+/**

+ * Answer the index of the receiver. Specifies the position of the

+ * receiver relative to other columns in the parent.

+ */

+int getIndex() {

+	return index;

+}

+/**
+ * Returns the receiver's parent, which must be a <code>Table</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @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 Table getParent() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return parent;

+}

+/**
+ * Gets the resizable attribute. A column that is
+ * not resizable cannot be dragged by the user but
+ * may be resized by the programmer.
+ *
+ * @return the resizable attribute
+ *
+ * @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 getResizable() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return resize;

+}

+/**
+ * Gets the width of the receiver.
+ *
+ * @return the width
+ *
+ * @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 getWidth () {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return getBounds().width;

+}

+/**

+ * Set the colun bounds.

+ */

+void internalSetBounds(Rectangle newBounds) {

+	bounds = newBounds;

+}

+/**

+ * Answer whether the column has a default width or if a width has been 

+ * set by the user.

+ * @return 

+ *  true=column width is a default width set internally

+ *	false=column width has been set by the user.

+ */

+boolean isDefaultWidth() {

+	return isDefaultWidth;

+}

+/**
+ * Causes the receiver to be resized to its preferred size.
+ * For a composite, this involves computing the preferred size
+ * from its layout, if there is one.
+ *
+ * @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 pack() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Table parent = getParent();

+	int index = parent.indexOf(this);

+

+	if (getIndex() != TableColumn.FILL && index != -1) {

+		setWidth(parent.getPreferredColumnWidth(index));

+	}

+}

+/**

+ * Draw the 'item' at 'yPosition' in the receiver column.

+ * @param item - TableItem that should be drawn.

+ * @param gc - GC to draw on

+ * @param yPosition - y position to draw at in the column.

+ */

+void paint(TableItem item, GC gc, int yPosition) {

+	Rectangle bounds = getBounds();

+	Point paintPosition = new Point(bounds.x, bounds.y + yPosition);

+

+	item.paint(gc, paintPosition, this);

+}

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is moved or resized.
+ *
+ * @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 ControlListener
+ * @see #addControlListener
+ */

+public void removeControlListener (ControlListener listener) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

+	if (eventTable == null) return;

+	eventTable.unhook (SWT.Move, listener);

+	eventTable.unhook (SWT.Resize, listener);

+}

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected.
+ *
+ * @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 SelectionListener
+ * @see #addSelectionListener
+ */

+public void removeSelectionListener(SelectionListener listener) {

+	if (!isValidThread ()) error(SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error(SWT.ERROR_WIDGET_DISPOSED);

+	

+	if (listener == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	removeListener(SWT.Selection, listener);

+	removeListener(SWT.DefaultSelection, listener);

+}

+/**
+ * Controls how text and images will be displayed in the receiver.
+ * The argument should be one of <code>LEFT</code>, <code>RIGHT</code>
+ * or <code>CENTER</code>.
+ *
+ * @param alignment the new alignment 
+ *
+ * @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 setAlignment(int alignment) {

+	if (!isValidThread ()) error(SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error(SWT.ERROR_WIDGET_DISPOSED);

+	int index = getIndex();

+	

+	if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) != 0 && index != 0) { // ignore calls for the first column to match Windows behavior

+		style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);

+		style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);

+		getParent().getHeader().redraw(index);	

+	}

+}

+/**

+ * Set the bounding rectangle of the receiver to 'newBounds'.

+ * Notify the table widget if the column width changes.

+ * @param newBounds - the new bounding rectangle of the receiver,

+ *	consisting of x, y, width, height

+ */

+void setBounds(Rectangle newBounds) {

+	if (newBounds.width != bounds.width) {

+		if (isDefaultWidth() == true) {

+			setDefaultWidth(false);

+		}

+		getParent().columnChange(this, newBounds);

+	}

+	else {

+		// columnChange causes update (via scroll) which may flush redraw 

+		// based on old bounds. Setting bounds after notifying table fixes 1GABZR5

+		// Table sets column bounds at appropriate time when called above with 

+		// width change. Only set bounds when table was not called. Fixes 1GCGDPB

+		bounds = newBounds;

+	}

+}

+/**

+ * Set whether the column has a default width or if a width has been 

+ * set by the user.

+ * @param isDefaultWidth

+ *	true=column width is a default width set internally

+ *	false=column width has been set by the user

+ */

+void setDefaultWidth(boolean isDefaultWidth) {

+	this.isDefaultWidth = isDefaultWidth;

+}

+/**

+ * Set the index of the receiver to 'newIndex'. The index specifies the

+ * position of the receiver relative to other columns in the parent.

+ */

+void setIndex(int newIndex) {

+	this.index = newIndex;

+}

+/**
+ * Sets the resizable attribute.  A column that is
+ * not resizable cannot be dragged by the user but
+ * may be resized by the programmer.
+ *
+ * @param resizable the resize attribute
+ *
+ * @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 setResizable(boolean resize) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	this.resize = resize;

+}

+public void setText(String newText) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	int index = getIndex();

+	

+	if (newText == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	if (index != FILL && (text == null || text.equals(newText) == false)) {

+		super.setText(newText);

+		getParent().getHeader().redraw(index);

+	}	

+}

+/**
+ * Sets the width of the receiver.
+ *
+ * @param width the new width
+ *
+ * @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 setWidth(int width) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Table parent = getParent();

+	Rectangle bounds = getBounds();

+	int oldWidth = bounds.width;

+	int redrawX;

+

+	if (width != oldWidth) {

+		redrawX = bounds.x;

+		bounds.width = width;

+		setBounds(bounds);

+		// redraw at old column position if column was resized wider.

+		// fixes focus rectangle. 

+		redrawX += Math.min(width, oldWidth);

+		parent.redraw(																

+			redrawX - 2, 0, 

+			2, parent.getClientArea().height, false);	// redraw 2 pixels wide to redraw item focus rectangle and grid line

+	}

+}

+}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TableItem.java
new file mode 100755
index 0000000..6da0ba3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TableItem.java
@@ -0,0 +1,1074 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+ 

+import org.eclipse.swt.*;

+import org.eclipse.swt.graphics.*;

+import java.util.*;

+

+/**

+ * Instances of this class represent a selectable user interface object

+ * that represents an item in a table.

+ * <dl>

+ * <dt><b>Styles:</b></dt>

+ * <dd>(none)</dd>

+ * <dt><b>Events:</b></dt>

+ * <dd>(none)</dd>

+ * </dl>

+ * <p>

+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.

+ * </p>

+ */

+public /*final*/ class TableItem extends SelectableItem {

+	private static final int FIRST_COLUMN_IMAGE_INDENT = 2;	// Space in front of image - first column only

+	private static final int FIRST_COLUMN_TEXT_INDENT = 4;	// Space in front of text - first column only	

+	private static final int TEXT_INDENT_NO_IMAGE = 2;		// Space in front of item text when no item in the column has an image - first column only

+	private static final int TEXT_INDENT = 6;				// Space in front of item text - all other columns

+	private static final int SELECTION_PADDING = 6;			// Space behind text in a selected item

+

+	private Vector dataLabels = new Vector();				// Original text set by the user. Items that don't 

+															// have a label are represented by a null slot

+	private String[] trimmedLabels = new String[0];			// Text that is actually displayed, may be trimmed 

+															// to fit the column

+	private Vector images = new Vector();					// Item images. Items that don't have an image 

+															// are represented by a null slot

+	private Point selectionExtent;							// Size of the rectangle drawn to indicate a 

+															// selected item.

+	private int imageIndent = 0;							// the factor by which the item image and check box, if any, 

+															// are indented. The multiplier is the image width.

+	private int index;										// index of the item in the parent widget

+/**

+ * Create a table item in the table widget 'parent'. Append the new 

+ * item to the existing items in 'parent'.

+ * @param parent - table widget the new item is added to.

+ * @param style - widget style. See Widget class for details

+ */

+public TableItem(Table parent, int style) {

+	this(parent, style, checkNull(parent).getItemCount());

+}

+/**

+ * Create a table item in the table widget 'parent'. Add the new 

+ * item at position 'index' to the existing items in 'parent'.

+ * @param parent - table widget the new item is added to.

+ * @param style - widget style. See Widget class for details

+ * @param index - position the new item is inserted at in 'parent'

+ */

+public TableItem(Table parent, int style, int index) {

+	super(parent, style);

+	parent.addItem(this, index);

+}

+/**

+ * Calculate the size of the rectangle drawn to indicate a selected 

+ * item. This is also used to draw the selection focus rectangle. 

+ * The selection extent is calculated for the first column only (the 

+ * only column the selection is drawn in).

+ */

+void calculateSelectionExtent() {

+	Table parent = getParent();

+	TableColumn column = parent.internalGetColumn(TableColumn.FIRST);

+	GC gc = new GC(parent);	

+	String trimmedText = getText(gc, column);

+	int gridLineWidth = parent.getGridLineWidth();

+	

+	if (trimmedText != null) {

+		selectionExtent = new Point(gc.stringExtent(trimmedText).x, parent.getItemHeight());

+		selectionExtent.x += getTextIndent(TableColumn.FIRST) + SELECTION_PADDING;

+		selectionExtent.x = Math.min(

+			selectionExtent.x, column.getWidth() - getImageStopX(column.getIndex()) - gridLineWidth);

+		if (parent.getLinesVisible() == true) {

+			selectionExtent.y -= gridLineWidth;

+		}

+	}

+	gc.dispose();

+}

+/**

+ * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'table' is null.

+ * Otherwise return 'table'

+ */

+static Table checkNull(Table table) {

+	if (table == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

+	return table;

+}

+protected void checkSubclass () {

+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);

+}

+public void dispose() {

+	if (!isValidWidget ()) return;

+	Table parent = getParent();

+	parent.removeItem(this);

+	super.dispose();

+}

+void doDispose() {

+	dataLabels = null;

+	trimmedLabels = null;

+	images = null;

+	selectionExtent = null;

+	super.doDispose();

+}

+

+/**

+ * Draw the image of the receiver for column 'index' at

+ * 'destinationPosition' using 'gc'.

+ * Stretch/shrink the image to the fixed image size of the receiver's 

+ * parent.

+ * @param gc - GC to draw on. 

+ * @param destinationPosition - position on the GC to draw at.

+ * @param index - index of the image to draw

+ * @return Answer the position where drawing stopped.

+ */

+Point drawImage(GC gc, Point destinationPosition, int index) {

+	Table parent = getParent();

+	Image image = getImage(index);

+	Rectangle sourceImageBounds;

+	Point destinationImageExtent = parent.getImageExtent();

+	

+	if (image != null) {

+		sourceImageBounds = image.getBounds();

+		// full row select would obscure transparent images in all but the first column

+		// so always clear the image area in this case. Fixes 1FYNITC

+		if ((parent.getStyle() & SWT.FULL_SELECTION) != 0 && index != TableColumn.FIRST) {

+			gc.fillRectangle(

+				destinationPosition.x, destinationPosition.y,			

+				destinationImageExtent.x, destinationImageExtent.y);

+		}

+		gc.drawImage(

+			image, 0, 0, 													// source x, y

+			sourceImageBounds.width, sourceImageBounds.height, 				// source width, height

+			destinationPosition.x, destinationPosition.y,					// destination x, y

+			destinationImageExtent.x, destinationImageExtent.y);			// destination width, height

+	}

+	if (((index == TableColumn.FIRST &&										// always add the image width for the first column 

+ 	 	  parent.hasFirstColumnImage() == true) ||							// if any item in the first column has an image

+		 (index != TableColumn.FIRST && 									// add the image width if it's not the first column

+		  image != null)) &&										 		// only when the item actually has an image

+		destinationImageExtent != null) {									

+		destinationPosition.x += destinationImageExtent.x;

+	}

+	return destinationPosition;

+}

+/**

+ * Draw the label of the receiver for column 'index' at 'position'

+ * using 'gc'. 

+ * The background color is set to the selection background color if 

+ * the item is selected and the text is drawn for the first column.

+ * @param gc - GC to draw on. 

+ * @param position - position on the GC to draw at.

+ * @param index - specifies which subitem text to draw

+ */

+void drawText(String label, GC gc, Point position, int index) {

+	Table parent = getParent();

+	boolean drawSelection;

+	int textOffset;

+	int textHeight;

+		

+	if (label != null) {

+		drawSelection = (index == TableColumn.FIRST || (parent.getStyle() & SWT.FULL_SELECTION) != 0);

+		if (isSelected() == true && drawSelection == true) {

+			gc.setBackground(getSelectionBackgroundColor());

+			gc.setForeground(getSelectionForegroundColor());

+		}

+		textHeight = gc.stringExtent(label).y;

+		textOffset = (parent.getItemHeight() - textHeight) / 2;			// vertically center the text

+		gc.drawString(label, position.x, position.y + textOffset);

+		if (isSelected() == true && drawSelection == true) {

+			gc.setBackground(parent.getBackground());

+			gc.setForeground(parent.getForeground());

+		}

+	}

+}

+

+/**

+ * 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) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Rectangle itemBounds;

+	Rectangle columnBounds;

+	Rectangle checkboxBounds;

+	Table parent = getParent();

+	TableColumn column;

+	int itemIndex = parent.indexOf(this);

+	int itemHeight = parent.getItemHeight();

+	int gridLineWidth = parent.getGridLineWidth();

+	int itemYPos;

+	

+	if (itemIndex == -1 || index < 0 || index >= parent.internalGetColumnCount()) {

+		itemBounds = new Rectangle(0, 0, 0, 0);

+	}

+	else {

+		column = parent.internalGetColumn(index);

+		columnBounds = column.getBounds();

+		itemYPos = columnBounds.y + itemHeight * itemIndex;

+		itemBounds = new Rectangle(

+			columnBounds.x, itemYPos, 

+			columnBounds.width - gridLineWidth, itemHeight - gridLineWidth);

+		if (index == TableColumn.FIRST) {

+			if (isCheckable() == true) {

+				checkboxBounds = getCheckboxBounds();

+				itemBounds.x += checkboxBounds.x + checkboxBounds.width + CHECKBOX_PADDING;	// add checkbox start, width and space behind checkbox

+				itemBounds.width -= itemBounds.x;

+			}

+			else {

+				itemBounds.x += getImageIndentPixel();

+			}

+		}

+	}

+	return itemBounds;

+}

+/**

+ * 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() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return super.getChecked();

+}

+/**

+ * Answer the x position of the item check box

+ */

+int getCheckboxXPosition() {

+	return getImageIndentPixel();

+}

+/**

+ * Answer the item labels set by the user.

+ * These may not be the same as those drawn on the screen. The latter 

+ * may be trimmed to fit the column. Items that don't have a label are 

+ * represented by a null slot in the vector.

+ * @return Vector - the item labels set by the user.

+ */

+Vector getDataLabels() {

+	return dataLabels;

+}

+public Display getDisplay() {

+	return super.getDisplay();

+}

+/**

+ * Return the position at which the string starts that is used 

+ * to indicate a truncated item text.

+ * @param columnIndex - index of the column for which the position of 

+ *	the truncation replacement should be calculated

+ * @param columnWidth - width of the column for which the position of 

+ *	the truncation replacement should be calculated

+ * @return -1 when the item text is not truncated

+ */

+int getDotStartX(int columnIndex, int columnWidth) {

+	GC gc;

+	Table parent = getParent();

+	String label = getText(columnIndex);

+	int dotStartX = -1;

+	int maxWidth;

+

+	if (label != null) {

+		gc = new GC(parent);

+		maxWidth = getMaxTextWidth(columnIndex, columnWidth);

+		label = parent.trimItemText(label, maxWidth, gc);

+		if (label.endsWith(Table.DOT_STRING) == true) {

+			dotStartX = gc.stringExtent(label).x - parent.getDotsWidth(gc);

+			// add indents, margins and image width

+			dotStartX += getImageStopX(columnIndex);

+			dotStartX += getTextIndent(columnIndex);

+		}

+		gc.dispose();		

+	}

+	return dotStartX;

+}

+/**

+ * Returns <code>true</code> if the receiver is grayed,

+ * and false otherwise. When the parent does not have

+ * the <code>CHECK style, return false.

+ *

+ * @return the grayed 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 getGrayed() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return super.getGrayed();

+}

+public Image getImage() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return getImage(0);

+}

+/**

+ * Returns the item image of the column identified by 'columnIndex' or 

+ * null if no image has been set for that column.

+ * 

+ * @param columnIndex - the column whose image should be returned

+ * @return the item image

+ */

+public Image getImage(int columnIndex) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Image image = null;

+	Vector images = getImages();

+	int itemIndex = getParent().indexOf(this);

+	

+	if (itemIndex != -1 && columnIndex >= 0 && columnIndex < images.size()) {

+		image = (Image) images.elementAt(columnIndex);

+	}

+	return image;

+}

+/**

+ * Returns a rectangle describing the size and location

+ * relative to its parent of an image at a column in the

+ * table.

+ *

+ * @param index the index that specifies the column

+ * @return the receiver's bounding image 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 getImageBounds(int index) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Table parent = getParent();

+	int itemIndex = parent.indexOf (this);

+	int imageWidth = 0;

+	Point imageExtent = parent.getImageExtent();

+	Rectangle checkboxBounds;

+	Rectangle imageBounds = getBounds(index);

+	

+	if (itemIndex == -1) {

+		imageBounds = new Rectangle(0, 0, 0, 0);

+	}

+	else

+	if (imageExtent != null) {

+		if (index == TableColumn.FIRST || getImage(index) != null) {

+			imageWidth = imageExtent.x;

+		}

+	}

+	imageBounds.width = imageWidth;

+	return imageBounds;

+}

+/**

+ * Gets the image indent.

+ *

+ * @return the indent

+ *

+ * @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 getImageIndent() {

+	if (isValidThread() == false) error(SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (isValidWidget() == false) error(SWT.ERROR_WIDGET_DISPOSED);

+	int index = getParent().indexOf(this);

+	

+	if (index == -1) {

+		return 0;

+	}

+	return imageIndent;

+}

+/**

+ * Answer the number of pixels the image in the first column is 

+ * indented. Calculation starts at the column start and counts 

+ * all pixels except the check box.

+ */

+int getImageIndentPixel() {

+	int indentPixel = FIRST_COLUMN_IMAGE_INDENT;

+	Point imageExtent = getParent().getImageExtent();

+	

+	if (imageExtent != null) {

+		indentPixel += imageExtent.x * getImageIndent();

+	}

+	return indentPixel;

+}

+/**

+ * Answer the item images set by the user. Items that don't have an 

+ * image are represented by a null slot in the vector.

+ */

+Vector getImages() {

+	return images;

+}

+/**

+ * Calculate the x coordinate where the item image of column 

+ * 'columnIndex' stops.

+ * @param columnIndex - the column for which the stop position of the 

+ *	image should be calculated.

+ */

+int getImageStopX(int columnIndex) {

+	int imageStopX = 0;

+	Table parent = getParent();

+	Rectangle checkboxBounds;

+

+	if (columnIndex == TableColumn.FIRST) {

+		if (isCheckable() == true) {

+			checkboxBounds = getCheckboxBounds();

+			imageStopX += checkboxBounds.x + checkboxBounds.width + CHECKBOX_PADDING;

+		}

+		else {

+			imageStopX = getImageIndentPixel();

+		}

+	}

+	if (((columnIndex == TableColumn.FIRST &&				// always add the image width for the first column 

+ 	 	  parent.hasFirstColumnImage() == true) ||			// if any item in the first column has an image

+		 (columnIndex != TableColumn.FIRST && 				// add the image width if it's not the first column

+		  getImage(columnIndex) != null)) &&		 		// only when the item actually has an image

+		parent.getImageExtent() != null) {									

+		imageStopX += parent.getImageExtent().x;

+	}

+	return imageStopX;

+}

+/**

+ * Return the index of the item in its parent widget.

+ */

+int getIndex() {

+	return index;

+}

+/**

+ * Return the item extent in the specified column

+ * The extent includes the actual width of the item including checkbox, 

+ * image and text.

+ */

+Point getItemExtent(TableColumn column) {

+	Table parent = getParent();

+	int columnIndex = column.getIndex();

+	Point extent = new Point(getImageStopX(columnIndex), parent.getItemHeight() - parent.getGridLineWidth());

+	GC gc = new GC(parent);	

+	String trimmedText = getText(gc, column);

+

+	if (trimmedText != null && trimmedText.length() > 0) {

+		extent.x += gc.stringExtent(trimmedText).x + getTextIndent(columnIndex);

+	}

+	if (columnIndex == TableColumn.FIRST) {

+		extent.x += SELECTION_PADDING;

+	}

+	gc.dispose();		

+	return extent;

+}

+/**

+ * Answer the maximum width in pixel of the text that fits in the 

+ * column identified by 'columnIndex' without trimming the text.

+ * @param columnIndex - the column for which the maximum text width

+ *	should be calculated.

+ * @param columnWidth - width of the column 'columnIndex'

+ */

+int getMaxTextWidth(int columnIndex, int columnWidth) {

+	int itemWidth = getImageStopX(columnIndex) + getTextIndent(columnIndex) * 2;

+

+	return columnWidth - itemWidth;

+}

+/**

+ * Returns the receiver's parent, which must be a <code>Table</code>.

+ *

+ * @return the receiver's parent

+ *

+ * @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 Table getParent() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return (Table) super.getSelectableParent();

+}

+/**

+ * Answer the width of the item required to display the complete contents.

+ */

+int getPreferredWidth(int index) {

+	int size = getImageStopX(index);

+	String text = getText(index);

+

+	if (text != null) {

+		size += getParent().getTextWidth(text) + getTextIndent(index) * 2 + 1;

+	}

+	return size;

+}

+/**

+ * Return the size of the rectangle drawn to indicate a selected item.

+ * This is also used to draw the selection focus rectangle and drop 

+ * insert marker. 

+ * Implements SelectableItem#getSelectionExtent

+ */

+Point getSelectionExtent() {

+	Table parent = getParent();

+	Point extent;

+	

+	if ((parent.getStyle() & SWT.FULL_SELECTION) == 0) {			// regular, first column, selection?

+		if (selectionExtent == null) {

+			calculateSelectionExtent();

+		}

+		extent = selectionExtent;

+	}

+	else {

+		extent = parent.getFullSelectionExtent(this);

+	}

+	return extent;

+}

+/**

+ * Return the x position of the selection rectangle

+ * Implements SelectableItem#getSelectionX

+ */

+int getSelectionX() {

+	return getImageStopX(TableColumn.FIRST) + getParent().getHorizontalOffset();

+}

+public String getText() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return getText(0);

+}

+/**

+ * Returns the item tezt of the column identified by 'columnIndex',

+ * or null if no text has been set for that column.

+ * 

+ * @param columnIndex - the column whose text should be returned

+ *	@return the item text or null if no text has been set for that column.

+ */

+public String getText(int columnIndex) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	int itemIndex = getParent().indexOf(this);

+	Vector labels = getDataLabels();

+	String label = null;

+	

+	if (itemIndex == -1) {

+		error(SWT.ERROR_CANNOT_GET_TEXT);

+	}	

+	if (columnIndex >= 0 && columnIndex < labels.size()) {

+		label = (String) labels.elementAt(columnIndex);

+	}

+	if (label == null) {

+		label = "";			// label vector is initialized with null instead of empty Strings

+	}

+	return label;

+}

+/**

+ * Answer the text that is going to be drawn in 'column'. This 

+ * text may be a trimmed copy of the original text set by the 

+ * user if it doesn't fit into the column. In that case the last 

+ * characters are replaced with Table.DOT_STRING.

+ * A cached copy of the trimmed text is returned if available.

+ * @param gc - GC to use for measuring the text extent

+ * @param column - TableColumn for which the text should be returned

+ */

+String getText(GC gc, TableColumn column) {

+	int columnIndex = column.getIndex();

+	String label = getTrimmedText(columnIndex);

+	int maxWidth;

+

+	if (label == null) {

+		maxWidth = getMaxTextWidth(columnIndex, column.getWidth());

+		label = getParent().trimItemText(getText(columnIndex), maxWidth, gc);

+	}

+	return label;

+}

+/**

+ * Answer the indent of the text in column 'columnIndex' in pixel.

+ * This indent is used in front of and behind the item text.

+ * @param columnIndex - specifies the column for which the indent 

+ *	should be calculated.

+ */

+int getTextIndent(int columnIndex) {

+	int textIndent;

+

+	if (columnIndex == TableColumn.FIRST) {

+		if (getParent().hasFirstColumnImage() == false) {

+			textIndent = TEXT_INDENT_NO_IMAGE;

+		}

+		else {

+			textIndent = FIRST_COLUMN_TEXT_INDENT;

+		}

+	}

+	else {

+		textIndent = TEXT_INDENT;

+	}

+	return textIndent;

+}

+/**

+ * Answer the cached trimmed text for column 'columnIndex'. 

+ * Answer null if it hasn't been calculated yet.

+ * @param columnIndex - specifies the column for which the 

+ *	trimmed text should be answered.

+ */

+String getTrimmedText(int columnIndex) {

+	String label = null;

+	String labels[] = getTrimmedTexts();

+

+	if (columnIndex < labels.length) {

+		label = labels[columnIndex];

+	}

+	return label;

+}

+/**

+ * Answer an array of cached trimmed labels.

+ */

+String [] getTrimmedTexts() {

+	return trimmedLabels;

+}

+/**

+ * Ensure that the image and label vectors have at least 

+ * 'newSize' number of elements.

+ */

+void growVectors(int newSize) {

+	Vector images = getImages();

+	Vector labels = getDataLabels();

+

+	if (newSize > images.size()){

+		images.setSize(newSize);

+	}

+	if (newSize > labels.size()){

+		labels.setSize(newSize);

+	}

+}

+/**

+ * Insert 'column' into the receiver.

+ */

+void insertColumn(TableColumn column) {	

+	Vector data = getDataLabels();

+	Vector images = getImages();

+	String stringData[];

+	Image imageData[];

+	int index = column.getIndex();

+

+	if (index < data.size()) {

+		data.insertElementAt(null, index);

+	}

+	else {

+		data.addElement(null);

+	}

+	stringData = new String[data.size()];

+	data.copyInto(stringData);

+	setText(stringData);

+

+	if (index < images.size()) {	

+		images.insertElementAt(null, index);

+	}

+	else {

+		images.addElement(null);

+	}

+	imageData = new Image[images.size()];

+	images.copyInto(imageData);

+	setImage(imageData);

+}

+/**

+ * Sets the image at an index.

+ *

+ * @param image the new image (or null)

+ *

+ * @exception SWTError(ERROR_THREAD_INVALID_ACCESS)

+ *	when called from the wrong thread

+ * @exception SWTError(ERROR_WIDGET_DISPOSED)

+ *	when the widget has been disposed

+ */

+void internalSetImage(int columnIndex, Image image) {

+	Vector images = getImages();

+	boolean imageWasNull = false;

+	Table parent = getParent();		

+	

+	if (columnIndex >= 0 && 

+		columnIndex < parent.internalGetColumnCount()) {

+		if (columnIndex >= images.size()) {

+			growVectors(columnIndex + 1);

+		}

+		if (((Image) images.elementAt(columnIndex)) == null && image != null) {

+			imageWasNull = true;

+		}

+		images.setElementAt(image, columnIndex);

+		reset(columnIndex);						// new image may cause text to no longer fit in the column

+		notifyImageChanged(columnIndex, imageWasNull);

+	}

+}

+/**

+* Sets the widget text.

+*

+* The widget text for an item is the label of the

+* item or the label of the text specified by a column

+* number.

+*

+* @param index the column number

+* @param text the new text

+*

+*/

+void internalSetText(int columnIndex, String string) {

+	Vector labels = getDataLabels();

+	Table parent = getParent();

+	String oldText;

+	

+	if (columnIndex >= 0 &&

+		columnIndex < parent.internalGetColumnCount()) {

+		if (columnIndex >= labels.size()) {

+			growVectors(columnIndex + 1);

+		}

+		oldText = (String) labels.elementAt(columnIndex);

+		if (string.equals(oldText) == false) {

+			labels.setElementAt(string, columnIndex);

+			reset(columnIndex);

+			notifyTextChanged(columnIndex, oldText == null);

+		}

+	}

+}

+/**

+ * Answer whether the click at 'xPosition' on the receiver is a 

+ * selection click.

+ * A selection click occurred when the click was behind the image

+ * and before the end of the item text.

+ * @return 

+ *	true - 'xPosition' is a selection click.

+ *	false - otherwise

+ */

+boolean isSelectionHit(int xPosition) {

+	int itemStopX = getImageStopX(TableColumn.FIRST);

+	Point selectionExtent = getSelectionExtent();

+

+	if (selectionExtent != null) {

+		itemStopX += selectionExtent.x;

+	}

+	return (xPosition > getCheckboxBounds().x + getCheckboxBounds().width) && (xPosition <= itemStopX);

+}

+/** 

+ * The image for the column identified by 'columnIndex' has changed.

+ * Notify the parent widget and supply redraw coordinates, if possible.

+ * @param columnIndex - index of the column that has a new image.

+ */

+void notifyImageChanged(int columnIndex, boolean imageWasNull) {	

+	Table parent = getParent();

+	Rectangle changedColumnBounds;

+	int redrawStartX = 0;

+	int redrawWidth = 0;

+	int columnCount = parent.internalGetColumnCount();	

+

+	if (columnIndex >= 0 && columnIndex < columnCount && parent.getVisibleRedrawY(this) != -1) {

+		changedColumnBounds = parent.internalGetColumn(columnIndex).getBounds();

+		redrawStartX = Math.max(0, getImageBounds(columnIndex).x);

+		if (parent.getImageExtent() != null && imageWasNull == false) {

+			redrawWidth = getImageStopX(columnIndex);

+		}

+		else {

+			redrawWidth = changedColumnBounds.width;

+		}

+		redrawWidth += changedColumnBounds.x - redrawStartX;

+	}

+	parent.itemChanged(this, redrawStartX, redrawWidth);

+}

+

+/**

+ * The label for the column identified by 'columnIndex' has changed.

+ * Notify the parent widget and supply redraw coordinates, if possible.

+ * @param columnIndex - index of the column that has a new label.

+ */

+void notifyTextChanged(int columnIndex, boolean textWasNull) {	

+	Table parent = getParent();

+	String text;

+	Rectangle columnBounds;

+	int redrawStartX = 0;

+	int redrawWidth = 0;

+	int columnCount = parent.internalGetColumnCount();

+

+	if (columnIndex >= 0 && columnIndex < columnCount && parent.getVisibleRedrawY(this) != -1) {

+		text = (String) getDataLabels().elementAt(columnIndex);

+		columnBounds = parent.internalGetColumn(columnIndex).getBounds();

+		redrawStartX = columnBounds.x;

+		if (getImage(columnIndex) != null) {

+			redrawStartX += getImageStopX(columnIndex);

+		}

+		redrawStartX = Math.max(0, redrawStartX);

+		// don't redraw if text changed from null to empty string

+		if (textWasNull == false || text.length() > 0) {

+			redrawWidth = columnBounds.x + columnBounds.width - redrawStartX;

+		}

+	}

+	parent.itemChanged(this, redrawStartX, redrawWidth);

+}

+/**

+ * Draw the receiver at 'paintPosition' in the column identified by 

+ * 'columnIndex' using 'gc'.

+ * @param gc - GC to use for drawing

+ * @param paintPosition - position where the receiver should be drawing.

+ * @param column - the column to draw in

+ */

+void paint(GC gc, Point paintPosition, TableColumn column) {

+	int columnIndex = column.getIndex();

+	String label = getText(gc, column);

+	String oldLabel = getTrimmedText(columnIndex);

+

+	if (label != null && label.equals(oldLabel) == false) {

+		setTrimmedText(label, columnIndex);

+		selectionExtent = null;		// force a recalculation next time the selection extent is needed

+	}

+	if (columnIndex == TableColumn.FIRST) {

+		paintPosition.x += getImageIndentPixel();

+		if (isCheckable() == true) {

+			paintPosition = drawCheckbox(gc, paintPosition);

+		}		

+	}

+	paintPosition = drawImage(gc, paintPosition, columnIndex);

+	paintPosition.x += getTextIndent(columnIndex);

+	drawText(label, gc, paintPosition, columnIndex);

+}

+/**

+ * Remove 'column' from the receiver.

+ */

+void removeColumn(TableColumn column) {

+	Vector data = getDataLabels();

+	Vector images = getImages();

+	String stringData[];

+	Image imageData[];

+	int index = column.getIndex();

+

+	if (index < data.size()) {

+		data.removeElementAt(index);

+		stringData = new String[data.size()];

+		data.copyInto(stringData);

+		setText(stringData);

+	}

+	if (index < images.size()) {

+		images.removeElementAt(index);

+		imageData = new Image[images.size()];

+		images.copyInto(imageData);

+		setImage(imageData);

+	}

+}

+/**

+ * Reset the cached trimmed label for the sub item identified by 

+ * 'index'.

+ * @param index - index of the label that should be reset.

+ */

+void reset(int index) {

+	String trimmedLabels[] = getTrimmedTexts();

+

+	if (index >= 0 && index < trimmedLabels.length) {

+		trimmedLabels[index] = null;

+	}

+	if (index == TableColumn.FIRST) {

+		selectionExtent = null;

+	}

+}

+/**

+ * Sets the image for multiple columns in the Table. 

+ * 

+ * @param strings the array of new images

+ *

+ * @exception IllegalArgumentException <ul>

+ *    <li>ERROR_NULL_ARGUMENT - if the text 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>

+ */

+public void setImage(Image [] images) {

+	if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);

+	

+	if (images == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	if (getParent().indexOf(this) == -1) {	

+		return;

+	}	

+	for (int i = 0; i < images.length; i++) {

+		internalSetImage(i, images[i]);

+	}

+}

+/**

+ * Sets the receiver's image at a column.

+ *

+ * @param index the column index

+ * @param string the new image

+ *

+ * @exception IllegalArgumentException <ul>

+ *    <li>ERROR_NULL_ARGUMENT - if the text 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>

+ */

+public void setImage(int columnIndex, Image image) {

+	if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);

+	

+	if (getParent().indexOf(this) != -1) {

+		internalSetImage(columnIndex, image);

+	}

+}

+public void setImage(Image image) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	setImage(0, image);

+}

+/**

+ * Sets the image indent.

+ *

+ * @param indent the new indent

+ *

+ * </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>

+ */

+public void setImageIndent(int indent) {

+	if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);

+	Table parent = getParent();

+	TableColumn column;

+	int index = parent.indexOf(this);

+

+	if (index != -1 && indent >= 0 && indent != imageIndent) {

+		imageIndent = indent;

+		column = parent.internalGetColumn(TableColumn.FIRST);

+		parent.redraw(

+			0, parent.getRedrawY(this), 

+			column.getWidth(), parent.getItemHeight(), false);

+	}

+}

+/**

+ * Sets the text for multiple columns in the table. 

+ * 

+ * @param strings the array of new strings

+ *

+ * @exception IllegalArgumentException <ul>

+ *    <li>ERROR_NULL_ARGUMENT - if the text 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>

+ */

+public void setText(String [] strings) {

+	if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);

+	

+	if (strings == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	if (getParent().indexOf(this) == -1) {	

+		return;

+	}

+	for (int i = 0; i < strings.length; i++) {

+		String string = strings[i];

+		if (string != null) {

+			internalSetText(i, string);

+		}

+	}

+}

+/**

+ * Sets the receiver's text at a column

+ *

+ * @param index the column index

+ * @param string the new text

+ *

+ * @exception IllegalArgumentException <ul>

+ *    <li>ERROR_NULL_ARGUMENT - if the text 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>

+ */

+public void setText (int columnIndex, String string) {

+	if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);

+	

+	if (string == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	if (getParent().indexOf(this) != -1) {

+		internalSetText(columnIndex, string);

+	}

+}

+public void setText(String text) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (text == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	setText(0, text);

+}

+/**

+ * Set the trimmed text of column 'columnIndex' to label. The trimmed 

+ * text is the one that is displayed in a column. It may be shorter than

+ * the text originally set by the user via setText(...) to fit the 

+ * column.

+ * @param label - the text label of column 'columnIndex'. May be trimmed

+ *	to fit the column.

+ * @param columnIndex - specifies the column whose text label should be 

+ *	set.

+ */

+void setTrimmedText(String label, int columnIndex) {

+	String labels[] = getTrimmedTexts();

+

+	if (columnIndex < labels.length) {

+		labels[columnIndex] = label;

+	}

+}

+/**

+ * Sets the checked state of the receiver.

+ *

+ * @param checked the new 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 void setChecked(boolean checked) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	super.setChecked(checked);

+}

+/**

+ * Sets the grayed state of the receiver.

+ *

+ * @param checked the new grayed 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 void setGrayed (boolean grayed) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	super.setGrayed(grayed);

+}

+/**

+ * Set the index of this item in its parent widget to 'newIndex'.

+ */

+void setIndex(int newIndex) {

+	index = newIndex;

+}

+

+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java
index 4e51779..e75c330 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java
@@ -11,19 +11,20 @@
 import org.eclipse.swt.graphics.*;

 import org.eclipse.swt.events.*;

 

-/**

- * Instances of this class are selectable user interface

- * objects that allow the user to enter and modify text.

- * <p>

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>MULTI, SINGLE, READ_ONLY, WRAP</dd>

- * <dt><b>Events:</b></dt>

- * <dd>DefaultSelection, Modify, Verify</dd>

- * </dl>

- * </p>

- * IMPORTANT: This class is <em>not</em> intended to be subclassed.

+/**
+ * Instances of this class are selectable user interface
+ * objects that allow the user to enter and modify text.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>MULTI, SINGLE, READ_ONLY, WRAP</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>DefaultSelection, Modify, Verify</dd>
+ * </dl>
+ * </p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
  */

+

 public class Text extends Scrollable {

 	char echoCharacter;

 	boolean ignoreChange;

@@ -43,7 +44,6 @@
 		LIMIT = 0x7FFFFFFF;

 		DELIMITER = "\n";

 	}

-

 /**

  * Constructs a new instance of this class given its parent

  * and a style value describing its behavior and appearance.

@@ -75,28 +75,28 @@
 public Text (Composite parent, int style) {

 	super (parent, checkStyle (style));

 }

-

-/**

- * Adds the listener to the collection of listeners who will

- * be notified when the receiver's text is modified, by sending

- * it one of the messages defined in the <code>ModifyListener</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 ModifyListener

- * @see #removeModifyListener

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is modified, by sending
+ * it one of the messages defined in the <code>ModifyListener</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 ModifyListener
+ * @see #removeModifyListener
  */

 public void addModifyListener (ModifyListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Modify, typedListener);

@@ -126,59 +126,62 @@
  * @see SelectionEvent

  */

 public void addSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener(listener);

 	addListener(SWT.Selection,typedListener);

 	addListener(SWT.DefaultSelection,typedListener);

 }

-/**

- * Adds the listener to the collection of listeners who will

- * be notified when the receiver's text is verified, by sending

- * it one of the messages defined in the <code>VerifyListener</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 VerifyListener

- * @see #removeVerifyListener

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is verified, by sending
+ * it one of the messages defined in the <code>VerifyListener</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 VerifyListener
+ * @see #removeVerifyListener
  */

 public void addVerifyListener (VerifyListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Verify, typedListener);

 }

-/**

- * Appends a string.

- * <p>

- * The new text is appended to the text at

- * the end of the widget.

- * </p>

- *

- * @param string the string to be appended

- *

- * @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>

+/**
+ * Appends a string.
+ * <p>
+ * The new text is appended to the text at
+ * the end of the widget.
+ * </p>
+ *
+ * @param string the string to be appended
+ *
+ * @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>
  */

 public void append (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	int position = OS.XmTextGetLastPosition (handle);

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (null, string, true);

 	Display display = getDisplay ();

 	boolean warnings = display.getWarnings ();

 	display.setWarnings (false);

@@ -196,22 +199,24 @@
 	}

 	return style | SWT.SINGLE;

 }

-/**

- * Clears the selection.

- *

- * @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>

+/**
+ * Clears the selection.
+ *
+ * @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 clearSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int xDisplay = OS.XtDisplay (handle);

 	if (xDisplay == 0) return;

 	OS.XmTextClearSelection (handle, OS.XtLastTimestampProcessed (xDisplay));

 }

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int width = wHint;

 	int height = hHint;

 	if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {

@@ -271,7 +276,8 @@
 	return new Point (width, height);

 }

 public Rectangle computeTrim (int x, int y, int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	Rectangle trim = super.computeTrim(x, y, width, height);

 	XRectangle rect = new XRectangle ();

 	OS.XmWidgetGetDisplayRect (handle, rect);

@@ -282,19 +288,20 @@
 	if ((style & (SWT.MULTI | SWT.BORDER)) != 0) trim.height += 3;

 	return trim;

 }

-/**

- * Copies the selected text.

- * <p>

- * The current selection is copied to the clipboard.

- * </p>

- *

- * @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>

+/**
+ * Copies the selected text.
+ * <p>
+ * The current selection is copied to the clipboard.
+ * </p>
+ *
+ * @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 copy () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int xDisplay = OS.XtDisplay (handle);

 	if (xDisplay == 0) return;

 	OS.XmTextCopy (handle, OS.XtLastTimestampProcessed (xDisplay));

@@ -335,23 +342,24 @@
 ScrollBar createScrollBar (int type) {

 	return createStandardBar (type);

 }

-/**

- * Cuts the selected text.

- * <p>

- * The current selection is first copied to the

- * clipboard and then deleted from the widget.

- * </p>

- *

- * @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>

- */

+/**
+ * Cuts the selected text.
+ * <p>
+ * The current selection is first copied to the
+ * clipboard and then deleted from the widget.
+ * </p>
+ *
+ * @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>
+ */
 public void cut () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int xDisplay = OS.XtDisplay (handle);

 	if (xDisplay == 0) return;

 	OS.XmTextCut (handle, OS.XtLastTimestampProcessed (xDisplay));

@@ -365,41 +373,43 @@
 int defaultForeground () {

 	return getDisplay ().textForeground;

 }

-/**

- * Gets the line number of the caret.

- * <p>

- * The line number of the caret is returned.

- * </p>

- *

- * @return the line number

- *

- * @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>

+/**
+ * Gets the line number of the caret.
+ * <p>
+ * The line number of the caret is returned.
+ * </p>
+ *
+ * @return the line number
+ *
+ * @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>
  */

 public int getCaretLineNumber () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return getLineNumber (OS.XmTextGetInsertionPosition (handle));

 }

-/**

- * Gets the location the caret.

- * <p>

- * The location of the caret is returned.

- * </p>

- *

- * @return a point, the location of the caret

- *

- * @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>

- */

+/**
+ * Gets the location the caret.
+ * <p>
+ * The location of the caret is returned.
+ * </p>
+ *
+ * @return a point, the location of the caret
+ *
+ * @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 Point getCaretLocation () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int position;

 	if (textVerify != null) {

 		position = textVerify.currInsert;

@@ -410,83 +420,88 @@
 	OS.XmTextPosToXY (handle, position, x, y);

 	return new Point (x [0], y [0] - getFontAscent ());

 }

-/**

- * Gets the position of the caret.

- * <p>

- * The character position of the caret is returned.

- * </p>

- *

- * @return the position of the caret

- *

- * @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>

+/**
+ * Gets the position of the caret.
+ * <p>
+ * The character position of the caret is returned.
+ * </p>
+ *
+ * @return the position of the caret
+ *
+ * @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 getCaretPosition () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return OS.XmTextGetInsertionPosition (handle);

 }

-/**

- * Gets the number of characters.

- *

- * @return number of characters in the widget

- *

- * @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>

+/**
+ * Gets the number of characters.
+ *
+ * @return number of characters in the widget
+ *
+ * @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 getCharCount () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return OS.XmTextGetLastPosition (handle);

 }

-/**

- * Gets the double click enabled flag.

- * <p>

- * The double click flag enables or disables the

- * default action of the text widget when the user

- * double clicks.

- * </p>

- *

- * @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>

+/**
+ * Gets the double click enabled flag.
+ * <p>
+ * The double click flag enables or disables the
+ * default action of the text widget when the user
+ * double clicks.
+ * </p>
+ *
+ * @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 getDoubleClickEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNselectionArrayCount, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1] != 1;

 }

-/**

- * Gets the echo character.

- * <p>

- * The echo character is the character that is

- * displayed when the user enters text or the

- * text is changed by the programmer.

- * </p>

- *

- * @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>

+/**
+ * Gets the echo character.
+ * <p>
+ * The echo character is the character that is
+ * displayed when the user enters text or the
+ * text is changed by the programmer.
+ * </p>
+ *
+ * @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 char getEchoChar () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return echoCharacter;

 }

-/**

- * Gets the editable 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>

- */

+/**
+ * Gets the editable 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 getEditable () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	/*

 	* Bug in MOTIF.  For some reason, when XmTextGetEditable () is called

 	* from inside an XmNvalueChangedCallback or XmNModifyVerifyCallback,

@@ -498,46 +513,49 @@
 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1] != 0;

 }

-/**

- * Gets the number of lines.

- *

- * @return the number of lines in the widget

- *

- * @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>

+/**
+ * Gets the number of lines.
+ *
+ * @return the number of lines in the widget
+ *
+ * @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 getLineCount () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return getLineNumber (echoCharacter != '\0' ? hiddenText.length () : OS.XmTextGetLastPosition (handle));

 }

-/**

- * Gets the line delimiter.

- *

- * @return a string that is the line delimiter

- *

- * @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>

+/**
+ * Gets the line delimiter.
+ *
+ * @return a string that is the line delimiter
+ *
+ * @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 String getLineDelimiter () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return "\n";

 }

-/**

- * Gets the height of a line.

- *

- * @return the height of a row of text

- *

- * @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>

+/**
+ * Gets the height of a line.
+ *
+ * @return the height of a row of text
+ *
+ * @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();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return getFontHeight ();

 }

 int getLineNumber (int position) {

@@ -553,7 +571,7 @@
 	* does not support multibyte locales.

 	*/

 	byte [] buffer1 = null;

-	if (OS.IsLinux) buffer1 = new byte [page + 1];

+	if (IsLinux) buffer1 = new byte [page + 1];

 	int end = ((position + page - 1) / page) * page;

 	while (start < end) {

 		int length = page;

@@ -561,7 +579,7 @@
 		if (echoCharacter != '\0') {

 			hiddenText.getChars (start, start + length, buffer, 0);

 		} else {

-			if (OS.IsLinux) {

+			if (IsLinux) {

 				OS.XmTextGetSubstring (handle, start, length, buffer1.length, buffer1);

 				for (int i=0; i<length; i++) buffer [i] = (char) buffer1 [i];

 			} else {

@@ -575,23 +593,24 @@
 	}

 	return count;

 }

-/**

- * Gets the position of the selected text.

- * <p>

- * Indexing is zero based.  The range of

- * a selection is from 0..N where N is

- * the number of characters in the widget.

- * </p>

- * 

- * @return the start and end of the selection

- *

- * @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>

+/**
+ * Gets the position of the selected text.
+ * <p>
+ * Indexing is zero based.  The range of
+ * a selection is from 0..N where N is
+ * the number of characters in the widget.
+ * </p>
+ * 
+ * @return the start and end of the selection
+ *
+ * @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 Point getSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (textVerify != null) {

 		return new Point (textVerify.startPos, textVerify.endPos);

 	}

@@ -602,18 +621,19 @@
 	}

 	return new Point (start [0], end [0]);

 }

-/**

- * Gets the number of selected characters.

- *

- * @return the number of selected characters.

- *

- * @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>

+/**
+ * Gets the number of selected characters.
+ *
+ * @return the number of selected characters.
+ *
+ * @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 getSelectionCount () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (textVerify != null) {

 		return textVerify.endPos - textVerify.startPos;

 	}

@@ -621,18 +641,19 @@
 	OS.XmTextGetSelectionPosition (handle, start, end);

 	return end [0] - start [0];

 }

-/**

- * Gets the selected text.

- *

- * @return the selected text

- * 

- * @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>

+/**
+ * Gets the selected text.
+ *
+ * @return the selected text
+ * 
+ * @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 String getSelectionText () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (echoCharacter != '\0' || textVerify != null) {

 		Point selection = getSelection ();

 		return getText (selection.x, selection.y);

@@ -643,43 +664,45 @@
 	byte [] buffer = new byte [length];

 	OS.memmove (buffer, ptr, length);

 	OS.XtFree (ptr);

-	return new String (Converter.mbcsToWcs (getCodePage (), buffer));

+	return new String (Converter.mbcsToWcs (null, buffer));

 }

-/**

- * Gets the number of tabs.

- * <p>

- * Tab stop spacing is specified in terms of the

- * space (' ') character.  The width of a single

- * tab stop is the pixel width of the spaces.

- * </p>

- *

- * @return the number of tab characters

- *

- * @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>

+/**
+ * Gets the number of tabs.
+ * <p>
+ * Tab stop spacing is specified in terms of the
+ * space (' ') character.  The width of a single
+ * tab stop is the pixel width of the spaces.
+ * </p>
+ *
+ * @return the number of tab characters
+ *
+ * @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 getTabs () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	/* Tabs are not supported in MOTIF. */

 	return 8;

 }

-/**

- * Gets the widget text.

- * <p>

- * The text for a text widget is the characters in the widget.

- * </p>

- *

- * @return the widget text

- *

- * @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>

+/**
+ * Gets the widget text.
+ * <p>
+ * The text for a text widget is the characters in the widget.
+ * </p>
+ *
+ * @return the widget text
+ *
+ * @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 String getText () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (echoCharacter != '\0') return hiddenText;

 	int ptr = OS.XmTextGetString (handle);

 	if (ptr == 0) return "";

@@ -687,27 +710,28 @@
 	byte [] buffer = new byte [length];

 	OS.memmove (buffer, ptr, length);

 	OS.XtFree (ptr);

-	return new String (Converter.mbcsToWcs (getCodePage (), buffer));

+	return new String (Converter.mbcsToWcs (null, buffer));

 }

-/**

- * Gets a range of text.

- * <p>

- * Indexing is zero based.  The range of

- * a selection is from 0..N-1 where N is

- * the number of characters in the widget.

- * </p>

- *

- * @param start the start of the range

- * @param end the end of the range

- * @return the range of text

- *

- * @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>

+/**
+ * Gets a range of text.
+ * <p>
+ * Indexing is zero based.  The range of
+ * a selection is from 0..N-1 where N is
+ * the number of characters in the widget.
+ * </p>
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ * @return the range of text
+ *
+ * @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 String getText (int start, int end) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int numChars = end - start + 1;

 	if (numChars < 0 || start < 0) return "";

 	if (echoCharacter != '\0') {

@@ -717,46 +741,48 @@
 	byte [] buffer = new byte [length];

 	int code = OS.XmTextGetSubstring (handle, start, numChars, length, buffer);

 	if (code == OS.XmCOPY_FAILED) return "";

-	char [] unicode = Converter.mbcsToWcs (getCodePage (), buffer);

+	char [] unicode = Converter.mbcsToWcs (null, buffer);

 	if (code == OS.XmCOPY_TRUNCATED) {

 		numChars = OS.XmTextGetLastPosition (handle) - start;

 	}

 	return new String (unicode, 0, numChars);

 }

-/**

- * Returns the maximum number of characters that the receiver is capable of holding. 

- * <p>

- * If this has not been changed by <code>setTextLimit()</code>,

- * it will be the constant <code>Text.LIMIT</code>.

- * </p>

- * 

- * @return the text limit

- * 

- * @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 the maximum number of characters that the receiver is capable of holding. 
+ * <p>
+ * If this has not been changed by <code>setTextLimit()</code>,
+ * it will be the constant <code>Text.LIMIT</code>.
+ * </p>
+ * 
+ * @return the text limit
+ * 
+ * @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 getTextLimit () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return OS.XmTextGetMaxLength (handle);

 }

-/**

- * Returns the zero-relative index of the line which is currently

- * at the top of the receiver.

- * <p>

- * This index can change when lines are scrolled or new lines are added or removed.

- * </p>

- *

- * @return the index of the top line

- *

- * @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 the zero-relative index of the line which is currently
+ * at the top of the receiver.
+ * <p>
+ * This index can change when lines are scrolled or new lines are added or removed.
+ * </p>
+ *
+ * @return the index of the top line
+ *
+ * @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 getTopIndex () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SINGLE) != 0) return 0;

 	if (scrolledHandle == 0) return 0;

 	int [] argList1 = {OS.XmNverticalScrollBar, 0};

@@ -766,32 +792,34 @@
 	OS.XtGetValues (argList1 [1], argList2, argList2.length / 2);

 	return argList2 [1];

 }

-/**

- * Gets the top pixel.

- * <p>

- * The top pixel is the pixel position of the line

- * that is currently at the top of the widget.  On

- * some platforms, a text widget can be scrolled by

- * pixels instead of lines so that a partial line

- * is displayed at the top of the widget.

- * </p><p>

- * The top pixel changes when the widget is scrolled.

- * The top pixel does not include the widget trimming.

- * </p>

- *

- * @return the pixel position of the top line

- *

- * @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>

+/**
+ * Gets the top pixel.
+ * <p>
+ * The top pixel is the pixel position of the line
+ * that is currently at the top of the widget.  On
+ * some platforms, a text widget can be scrolled by
+ * pixels instead of lines so that a partial line
+ * is displayed at the top of the widget.
+ * </p><p>
+ * The top pixel changes when the widget is scrolled.
+ * The top pixel does not include the widget trimming.
+ * </p>
+ *
+ * @return the pixel position of the top line
+ *
+ * @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 getTopPixel () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return getTopIndex () * getLineHeight ();

 }

 boolean getWrap () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNwordWrap, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1] != 0;

@@ -807,28 +835,29 @@
 	/* Answer zero.  The text widget uses the default MOTIF input context.  */

 	return 0;

 }

-/**

- * Inserts a string.

- * <p>

- * The old selection is replaced with the new text.

- * </p>

- *

- * @param string the string

- *

- * @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>

+/**
+ * Inserts a string.
+ * <p>
+ * The old selection is replaced with the new text.
+ * </p>
+ *
+ * @param string the string
+ *
+ * @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 insert (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	int [] start = new int [1], end = new int [1];

 	OS.XmTextGetSelectionPosition (handle, start, end);

 	if (start [0] == end [0]) {

 		start [0] = end [0] = OS.XmTextGetInsertionPosition (handle);

 	}

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (null, string, true);

 	Display display = getDisplay ();

 	boolean warnings = display.getWarnings ();

 	display.setWarnings (false);

@@ -837,20 +866,21 @@
 	OS.XmTextSetInsertionPosition (handle, position);

 	display.setWarnings (warnings);

 }

-/**

- * Pastes text from clipboard.

- * <p>

- * The selected text is deleted from the widget

- * and new text inserted from the clipboard.

- * </p>

- *

- * @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>

- */

+/**
+ * Pastes text from clipboard.
+ * <p>
+ * The selected text is deleted from the widget
+ * and new text inserted from the clipboard.
+ * </p>
+ *
+ * @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 paste () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	Display display = getDisplay ();

 	boolean warnings = display.getWarnings ();

 	display.setWarnings (false);

@@ -887,12 +917,6 @@
 	OS.XtSetValues (handle, argList, argList.length / 2);

 	return 0;

 }

-int processIMEFocusIn () {

-	return 0;

-}

-int processIMEFocusOut () {

-	return 0;

-}

 int processModify (int callData) {

 	if (!ignoreChange) super.processModify (callData);

 	return 0;

@@ -906,8 +930,7 @@
 	OS.memmove (textBlock, textVerify.text, XmTextBlockRec.sizeof);

 	byte [] buffer = new byte [textBlock.length];

 	OS.memmove (buffer, textBlock.ptr, textBlock.length);

-	String codePage = getCodePage ();

-	String text = new String (Converter.mbcsToWcs (codePage, buffer));

+	String text = new String (Converter.mbcsToWcs (null, buffer));

 	String newText = text;

 	if (!ignoreChange) {

 		Event event = new Event ();

@@ -936,7 +959,7 @@
 			newText = new String (charBuffer);

 		}

 		if (newText != text) {

-			byte [] buffer2 = Converter.wcsToMbcs (codePage, newText, true);

+			byte [] buffer2 = Converter.wcsToMbcs (null, newText, true);

 			int length = buffer2.length;

 			int ptr = OS.XtMalloc (length);

 			OS.memmove (ptr, buffer2, length);

@@ -949,117 +972,91 @@
 	textVerify = null;

 	return 0;

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the receiver's text is modified.

- *

- * @param listener the listener which should no longer 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 ModifyListener

- * @see #addModifyListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's text is modified.
+ *
+ * @param listener the listener which should no longer 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 ModifyListener
+ * @see #addModifyListener
  */

 public void removeModifyListener (ModifyListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Modify, listener);	

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the control is selected.

- *

- * @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 SelectionListener

- * @see #addSelectionListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected.
+ *
+ * @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 SelectionListener
+ * @see #addSelectionListener
  */

 public void removeSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook(SWT.Selection, listener);

 	eventTable.unhook(SWT.DefaultSelection,listener);	

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the control is verified.

- *

- * @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 VerifyListener

- * @see #addVerifyListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is verified.
+ *
+ * @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 VerifyListener
+ * @see #addVerifyListener
  */

 public void removeVerifyListener (VerifyListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Verify, listener);	

 }

-byte [] sendKeyEvent (int type, XKeyEvent xEvent) {

-	byte [] mbcs = super.sendKeyEvent (type, xEvent);

-	

-	/*

-	* Bug in Motif. On Solaris and Linux, XmImMbLookupString() clears

-	* the characters from the IME. This causes tht characters to be

-	* stolen from the text widget. The fix is to detect that the IME

-	* has been cleared and use XmTextInsert() to insert the stolen

-	* characters. This problem does not happen on AIX.

-	*/

-	if (mbcs == null || xEvent.keycode != 0) return null;

-	byte [] buffer = new byte [2];

-	int [] keysym = new int [1];

-	int [] status = new int [1];

-	int size = OS.XmImMbLookupString (handle, xEvent, buffer, buffer.length, keysym, status);

-	if (size != 0) return null;

-	int [] start = new int [1], end = new int [1];

-	OS.XmTextGetSelectionPosition (handle, start, end);

-	if (start [0] == end [0]) {

-		start [0] = end [0] = OS.XmTextGetInsertionPosition (handle);

-	}

-	Display display = getDisplay ();

-	boolean warnings = display.getWarnings ();

-	display.setWarnings (false);

-	OS.XmTextReplace (handle, start [0], end [0], mbcs);

-	int position = start [0] + mbcs.length - 1;

-	OS.XmTextSetInsertionPosition (handle, position);

-	display.setWarnings (warnings);

-	

-	return mbcs;

-}

-/**

- * Selects all the text in the receiver.

- *

- * @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>

+/**
+ * Selects all the text in the receiver.
+ *
+ * @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 selectAll () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

 	/* Clear the highlight before setting the selection. */

 	int position = OS.XmTextGetLastPosition (handle);

 //	OS.XmTextSetHighlight (handle, 0, position, OS.XmHIGHLIGHT_NORMAL);

@@ -1106,43 +1103,45 @@
 //	nWidth > inset x ifTrue: [^self].

 //	self showPosition: self topCharacter

 }

-/**

- * Sets the double click enabled flag.

- * <p>

- * The double click flag enables or disables the

- * default action of the text widget when the user

- * double clicks.

- * </p>

- * 

- * @param doubleClick the new double click flag

- *

- * @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>

+/**
+ * Sets the double click enabled flag.
+ * <p>
+ * The double click flag enables or disables the
+ * default action of the text widget when the user
+ * double clicks.
+ * </p>
+ * 
+ * @param doubleClick the new double click flag
+ *
+ * @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 setDoubleClickEnabled (boolean doubleClick) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNselectionArrayCount, doubleClick ? 4 : 1};

 	OS.XtSetValues (handle, argList, argList.length / 2);

 }

-/**

- * Sets the echo character.

- * <p>

- * The echo character is the character that is

- * displayed when the user enters text or the

- * text is changed by the programmer.

- * </p>

- *

- * @param echo the new echo character

- *

- * @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>

+/**
+ * Sets the echo character.
+ * <p>
+ * The echo character is the character that is
+ * displayed when the user enters text or the
+ * text is changed by the programmer.
+ * </p>
+ *
+ * @param echo the new echo character
+ *
+ * @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 setEchoChar (char echo) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (echoCharacter == echo) return;

 	String newText;

 	if (echo == 0) {

@@ -1159,18 +1158,19 @@
 	setSelection(selection);

 	ignoreChange = oldValue;

 }

-/**

- * Sets the editable state.

- *

- * @param editable the new editable 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>

- */

+/**
+ * Sets the editable state.
+ *
+ * @param editable the new editable 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 void setEditable (boolean editable) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	OS.XmTextSetEditable (handle, editable);

 	style &= ~SWT.READ_ONLY;

 	if (!editable) style |= SWT.READ_ONLY;

@@ -1182,7 +1182,8 @@
 * Sets the redraw flag.

 */

 public void setRedraw (boolean redraw) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SINGLE) != 0) return;

 	if (redraw) {

 		if (--drawCount == 0) OS.XmTextEnableRedisplay(handle);

@@ -1190,34 +1191,36 @@
 		if (drawCount++ == 0) OS.XmTextDisableRedisplay(handle);

 	}

 }

-/**

- * Sets the selection.

- * <p>

- * Indexing is zero based.  The range of

- * a selection is from 0..N where N is

- * the number of characters in the widget.

- * </p><p>

- * Text selections are specified in terms of

- * caret positions.  In a text widget that

- * contains N characters, there are N+1 caret

- * positions, ranging from 0..N.  This differs

- * from other functions that address character

- * position such as getText () that use the

- * regular array indexing rules.

- * </p>

- *

- * @param start new caret position

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the string 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>

+/**
+ * Sets the selection.
+ * <p>
+ * Indexing is zero based.  The range of
+ * a selection is from 0..N where N is
+ * the number of characters in the widget.
+ * </p><p>
+ * Text selections are specified in terms of
+ * caret positions.  In a text widget that
+ * contains N characters, there are N+1 caret
+ * positions, ranging from 0..N.  This differs
+ * from other functions that address character
+ * position such as getText () that use the
+ * regular array indexing rules.
+ * </p>
+ *
+ * @param start new caret position
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string 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>
  */

 public void setSelection (int start) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

 	/* Clear the selection and highlight before moving the i-beam. */

 	int xDisplay = OS.XtDisplay (handle);

 	if (xDisplay == 0) return;

@@ -1233,35 +1236,37 @@
 	OS.XmTextSetInsertionPosition (handle, nStart);

 	display.setWarnings (warnings);

 }

-/**

- * Sets the selection.

- * <p>

- * Indexing is zero based.  The range of

- * a selection is from 0..N where N is

- * the number of characters in the widget.

- * </p><p>

- * Text selections are specified in terms of

- * caret positions.  In a text widget that

- * contains N characters, there are N+1 caret

- * positions, ranging from 0..N.  This differs

- * from other functions that address character

- * position such as getText () that use the

- * usual array indexing rules.

- * </p>

- *

- * @param start the start of the range

- * @param end the end of the range

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the string 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>

+/**
+ * Sets the selection.
+ * <p>
+ * Indexing is zero based.  The range of
+ * a selection is from 0..N where N is
+ * the number of characters in the widget.
+ * </p><p>
+ * Text selections are specified in terms of
+ * caret positions.  In a text widget that
+ * contains N characters, there are N+1 caret
+ * positions, ranging from 0..N.  This differs
+ * from other functions that address character
+ * position such as getText () that use the
+ * usual array indexing rules.
+ * </p>
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string 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>
  */

 public void setSelection (int start, int end) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

 	/* Clear the highlight before setting the selection. */

 	int position = OS.XmTextGetLastPosition (handle);

 //	OS.XmTextSetHighlight (handle, 0, position, OS.XmHIGHLIGHT_NORMAL);

@@ -1290,34 +1295,35 @@
 	OS.XmTextSetInsertionPosition (handle, nEnd);

 	display.setWarnings (warnings);

 }

-/**

- * Sets the selection.

- * <p>

- * Indexing is zero based.  The range of

- * a selection is from 0..N where N is

- * the number of characters in the widget.

- * </p><p>

- * Text selections are specified in terms of

- * caret positions.  In a text widget that

- * contains N characters, there are N+1 caret

- * positions, ranging from 0..N.  This differs

- * from other functions that address character

- * position such as getText () that use the

- * usual array indexing rules.

- * </p>

- *

- * @param selection the point

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the string 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>

+/**
+ * Sets the selection.
+ * <p>
+ * Indexing is zero based.  The range of
+ * a selection is from 0..N where N is
+ * the number of characters in the widget.
+ * </p><p>
+ * Text selections are specified in terms of
+ * caret positions.  In a text widget that
+ * contains N characters, there are N+1 caret
+ * positions, ranging from 0..N.  This differs
+ * from other functions that address character
+ * position such as getText () that use the
+ * usual array indexing rules.
+ * </p>
+ *
+ * @param selection the point
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string 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>
  */

 public void setSelection (Point selection) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);

 	setSelection (selection.x, selection.y);

 }

@@ -1338,43 +1344,45 @@
 //	nWidth > inset x ifTrue: [^self].

 //	self showPosition: self topCharacter

 }

- /**

- * Sets the number of tabs.

- * <p>

- * Tab stop spacing is specified in terms of the

- * space (' ') character.  The width of a single

- * tab stop is the pixel width of the spaces.

- * </p>

- *

- * @param tabs the number of tabs

- *

- * </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>

+ /**
+ * Sets the number of tabs.
+ * <p>
+ * Tab stop spacing is specified in terms of the
+ * space (' ') character.  The width of a single
+ * tab stop is the pixel width of the spaces.
+ * </p>
+ *
+ * @param tabs the number of tabs
+ *
+ * </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>
 */

 public void setTabs (int tabs) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	/* Do nothing.  Tabs are not supported in MOTIF. */

 }

-/**

- * Sets the contents of the receiver to the given string.

- *

- * @param text the new text

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the string 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>

+/**
+ * Sets the contents of the receiver to the given string.
+ *
+ * @param text the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string 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>
  */

 public void setText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (null, string, true);

 	Display display = getDisplay ();

 	boolean warnings = display.getWarnings ();

 	display.setWarnings (false);

@@ -1386,41 +1394,43 @@
 	* it does not send a Modify to notify the application

 	* that the text has changed.  The fix is to send the event.

 	*/

-	if (OS.IsLinux && (style & SWT.MULTI) != 0) sendEvent (SWT.Modify);

+	if (IsLinux && (style & SWT.MULTI) != 0) sendEvent (SWT.Modify);

 }

-/**

- * Sets the maximum number of characters that the receiver

- * is capable of holding to be the argument.

- *

- * @param limit new text limit

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</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>

+/**
+ * Sets the maximum number of characters that the receiver
+ * is capable of holding to be the argument.
+ *
+ * @param limit new text limit
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</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>
  */

 public void setTextLimit (int limit) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);

 	OS.XmTextSetMaxLength (handle, limit);

 }

-/**

- * Sets the zero-relative index of the line which is currently

- * at the top of the receiver. This index can change when lines

- * are scrolled or new lines are added and removed.

- *

- * @param index the index of the top item

- *

- * @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>

+/**
+ * Sets the zero-relative index of the line which is currently
+ * at the top of the receiver. This index can change when lines
+ * are scrolled or new lines are added and removed.
+ *
+ * @param index the index of the top item
+ *
+ * @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 setTopIndex (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SINGLE) != 0) return;

 	if (scrolledHandle == 0) return;

 	int [] argList1 = {OS.XmNverticalScrollBar, 0};

@@ -1431,28 +1441,30 @@
 	OS.XmTextScroll (handle, index - argList2 [1]);

 }

 void setWrap (boolean wrap) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNwordWrap, wrap ? 1 : 0};

 	OS.XtSetValues (handle, argList, argList.length / 2);

 }

-/**

- * Shows the selection.

- * <p>

- * If the selection is already showing

- * in the receiver, this method simply returns.  Otherwise,

- * lines are scrolled until the selection is visible.

- * </p>

- * 

- * @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>

+/**
+ * Shows the selection.
+ * <p>
+ * If the selection is already showing
+ * in the receiver, this method simply returns.  Otherwise,
+ * lines are scrolled until the selection is visible.
+ * </p>
+ * 
+ * @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>
  */

 public void showSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	Display display = getDisplay ();

 	boolean warnings = display.getWarnings ();

 	display.setWarnings (false);

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolBar.java
index 34522de..2bcd850 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolBar.java
@@ -9,57 +9,57 @@
 import org.eclipse.swt.*;

 import org.eclipse.swt.graphics.*;

 

-/**

- * Instances of this class support the layout of selectable

- * tool bar items.

- * <p>

- * The item children that may be added to instances of this class

- * must be of type <code>ToolItem</code>.

- * </p><p>

- * Note that although this class is a subclass of <code>Composite</code>,

- * it does not make sense to add <code>Control</code> children to it,

- * or set a layout on it.

- * </p><p>

- * <dl>

- * <dt><b>Styles:</b></dt>

+/**
+ * Instances of this class support the layout of selectable
+ * tool bar items.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>ToolItem</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
  * <dd>FLAT, WRAP, RIGHT, HORIZONTAL, VERTICAL</dd>

- * <dt><b>Events:</b></dt>

- * <dd>(none)</dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is <em>not</em> intended to be subclassed.

- * </p>

- */

+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
 public /*final*/ class ToolBar extends Composite {

 	int drawCount, itemCount;

 	ToolItem [] items;

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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

+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <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
+ *
+ * @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 ToolBar (Composite parent, int style) {

 	super (parent, checkStyle (style));

@@ -88,7 +88,8 @@
 	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);

 }

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int width = wHint, height = hHint;

 	if (wHint == SWT.DEFAULT) width = 0x7FFFFFFF;

 	if (hHint == SWT.DEFAULT) height = 0x7FFFFFFF;

@@ -133,47 +134,49 @@
 	System.arraycopy (items, index + 1, items, index, --itemCount - index);

 	items [itemCount] = null;

 }

-/**

- * Returns the item at the given, zero-relative index in the

- * receiver. Throws an exception if the index is out of range.

- *

- * @param index the index of the item to return

- * @return the item at the given index

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>

- */

+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ */
 public ToolItem getItem (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	ToolItem [] items = getItems ();

 	if (0 <= index && index < items.length) return items [index];

 	error (SWT.ERROR_INVALID_RANGE);

 	return null;

 }

 

-/**

- * Returns the item at the given point in the receiver

- * or null if no such item exists. The point is in the

- * coordinate system of the receiver.

- *

- * @param point the point used to locate the item

- * @return the item at the given point

- *

- * @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>

- */

+/**
+ * Returns the item at the given point in the receiver
+ * or null if no such item exists. The point is in the
+ * coordinate system of the receiver.
+ *
+ * @param point the point used to locate the item
+ * @return the item at the given point
+ *
+ * @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>
+ */
 public ToolItem getItem (Point pt) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	ToolItem [] items = getItems ();

 	for (int i=0; i<items.length; i++) {

 		Rectangle rect = items [i].getBounds ();

@@ -182,82 +185,84 @@
 	return null;

 }

 

-/**

- * Returns the number of items contained in the receiver.

- *

- * @return the number of items

- *

- * @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 the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @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 getItemCount () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return itemCount;

 }

-/**

- * Returns an array of <code>TabItem</code>s which are the items

- * in the receiver. 

- * <p>

- * Note: This is not the actual structure used by the receiver

- * to maintain its list of items, so modifying the array will

- * not affect the receiver. 

- * </p>

- *

- * @return the items in the receiver

- *

- * @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 an array of <code>TabItem</code>s which are the items
+ * in the receiver. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @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 ToolItem [] getItems () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	ToolItem [] result = new ToolItem [itemCount];

 	System.arraycopy (items, 0, result, 0, itemCount);

 	return result;

 }

-/**

- * Returns the number of rows in the receiver. When

- * the receiver has the <code>WRAP</code> style, the

- * number of rows can be greater than one.  Otherwise,

- * the number of rows is always one.

- *

- * @return the number of items

- *

- * @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 the number of rows in the receiver. When
+ * the receiver has the <code>WRAP</code> style, the
+ * number of rows can be greater than one.  Otherwise,
+ * the number of rows is always one.
+ *
+ * @return the number of items
+ *
+ * @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 getRowCount () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	Rectangle rect = getClientArea ();

 	return layout (rect.width, rect.height, false) [0];

 }

-/**

- * Searches the receiver's list starting at the first item

- * (index 0) until an item is found that is equal to the 

- * argument, and returns the index of that item. If no item

- * is found, returns -1.

- *

- * @param item the search item

- * @return the index of the item

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the tool item is null</li>

- *    <li>ERROR_INVALID_ARGUMENT - if the tool item 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>

- */

+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param item the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string 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>
+ */
 public int indexOf (ToolItem item) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);

-	if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 	ToolItem [] items = getItems ();

 	for (int i=0; i<items.length; i++) {

 		if (items [i] == item) return i;

@@ -321,12 +326,6 @@
 		return layoutHorizontal (nWidth, nHeight, resize);

 	}

 }

-void propagateWidget (boolean enabled) {

-	super.propagateWidget (enabled);

-	for (int i=0; i<itemCount; i++) {

-		items [i].propagateWidget (enabled);

-	}

-}

 void relayout () {

 	if (drawCount > 0) return;

 	Rectangle rect = getClientArea ();

@@ -353,7 +352,8 @@
 	relayout (rect.width, rect.height);

 }

 public void setRedraw (boolean redraw) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (redraw) {

 		if (--drawCount == 0) relayout();

 	} else {

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolDrawable.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolDrawable.java
index df81e73..b070067 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolDrawable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolDrawable.java
@@ -33,4 +33,4 @@
 public void internal_dispose_GC (int xGC, GCData data) {

 	OS.XFreeGC (display, xGC);

 }

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolItem.java
index d3ea545..e3a291c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolItem.java
@@ -11,18 +11,18 @@
 import org.eclipse.swt.graphics.*;

 import org.eclipse.swt.events.*;

 

-/**

- * Instances of this class represent a selectable user interface object

- * that represents a button in a tool bar.

- * <p>

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>PUSH, CHECK, RADIO, SEPARATOR, DROP_DOWN</dd>

- * <dt><b>Events:</b></dt>

- * <dd>Selection</dd>

- * </dl>

- * </p>

- * IMPORTANT: This class is <em>not</em> intended to be subclassed.

+/**
+ * Instances of this class represent a selectable user interface object
+ * that represents a button in a tool bar.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>PUSH, CHECK, RADIO, SEPARATOR, DROP_DOWN</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * </p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
  */

 public /*final*/ class ToolItem extends Item {

 	ToolBar parent;

@@ -32,80 +32,23 @@
 	boolean set;

 

 /**

- * Constructs a new instance of this class given its parent

- * (which must be a <code>ToolBar</code>) and a style value

- * describing its behavior and appearance. The item is added

- * to the end of 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

- *

- * @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

- */

+* Creates a new instance of the widget.

+*/

 public ToolItem (ToolBar parent, int style) {

 	super (parent, checkStyle (style));

 	this.parent = parent;

 	parent.createItem (this, parent.getItemCount ());

 	parent.relayout ();

 }

-

 /**

- * Constructs a new instance of this class given its parent

- * (which must be a <code>ToolBar</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

- */

+* Creates a new instance of the widget.

+*/

 public ToolItem (ToolBar parent, int style, int index) {

 	super (parent, checkStyle (style));

 	this.parent = parent;

 	parent.createItem (this, index);

 	parent.relayout ();

 }

-

 /**

  * Adds the listener to the collection of listeners who will

  * be notified when the control is selected, by sending

@@ -132,7 +75,8 @@
  * @see SelectionEvent

  */

 public void addSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener(listener);

 	addListener(SWT.Selection,typedListener);

@@ -198,11 +142,10 @@
 		Display display = getDisplay ();

 		shadowThickness = Math.min (2, display.buttonShadowThickness);

 	}

-	final String plainText = stripMnemonicCodes(this.text);

 	int textWidth = 0, textHeight = 0;

-	if (plainText.length () != 0) {

+	if (text.length () != 0) {

 		GC gc = new GC (parent);

-		Point textExtent = gc.textExtent (plainText);

+		Point textExtent = gc.textExtent (text);

 		textWidth = textExtent.x;

 		textHeight = textExtent.y;

 		gc.dispose ();

@@ -244,41 +187,43 @@
 	parent.relayout ();

 }

 public void dispose () {

-	if (isDisposed()) return;

+	if (!isValidWidget ()) return;

 	ToolBar parent = this.parent;

 	super.dispose ();

 	parent.relayout ();

 }

-/**

- * Returns a rectangle describing the receiver's size and location

- * relative to its parent.

- *

- * @return the receiver's bounding 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.
+ *
+ * @return the receiver's bounding 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 () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNx, 0, OS.XmNy, 0, OS.XmNwidth, 0, OS.XmNheight, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return new Rectangle ((short) argList [1], (short) argList [3], argList [5], argList [7]);

 }

-/**

- * Returns the control that is used to fill the bounds of

- * the item when the items is a <code>SEPARATOR</code>.

- *

- * @return the control

- *

- * @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 the control that is used to fill the bounds of
+ * the item when the items is a <code>SEPARATOR</code>.
+ *
+ * @return the control
+ *
+ * @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 Control getControl () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return control;

 }

 /**

@@ -292,26 +237,28 @@
 *	when the widget has been disposed

 */

 public Image getDisabledmage () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return disabledImage;

 }

-/**

- * Returns <code>true</code> if the receiver is enabled, and

- * <code>false</code> otherwise.

- * <p>

- * A disabled control is typically not selectable from the

- * user interface and draws with an inactive or "grayed" look.

- * </p>

- *

- * @return the receiver's enabled 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 enabled, and
+ * <code>false</code> otherwise.
+ * <p>
+ * A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ * </p>
+ *
+ * @return the receiver's enabled 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 getEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNsensitive, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1] != 0;

@@ -321,85 +268,90 @@
 	if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent.getDisplay ();

 }

-/**

- * Returns the receiver's hot image if it has one, or null

- * if it does not.

- * <p>

- * The hot image is displayed when the mouse enters the receiver.

- * </p>

- *

- * @return the receiver's hot 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>

+/**
+ * Returns the receiver's hot image if it has one, or null
+ * if it does not.
+ * <p>
+ * The hot image is displayed when the mouse enters the receiver.
+ * </p>
+ *
+ * @return the receiver's hot 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 getHotImage () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return hotImage;

 }

-/**

- * Returns the receiver's parent, which must be a <code>ToolBar</code>.

- *

- * @return the receiver's parent

- *

- * @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 the receiver's parent, which must be a <code>ToolBar</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @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 ToolBar getParent () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent;

 }

-/**

- * Returns <code>true</code> if the receiver is selected,

- * and false otherwise.

- * <p>

- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,

- * it is selected when it is checked. When it is of type <code>TOGGLE</code>,

- * it is selected when it is pushed.

- * </p>

- *

- * @return the selection 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 selected,
+ * and false otherwise.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
+ * it is selected when it is pushed.
+ * </p>
+ *
+ * @return the selection 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 getSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return false;

 	return set;

 }

-/**

- * Returns the receiver's tool tip text, or null if it has not been set.

- *

- * @return the receiver's tool tip text

- *

- * @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 the receiver's tool tip text, or null if it has not been set.
+ *
+ * @return the receiver's tool tip text
+ *
+ * @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 String getToolTipText () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return toolTipText;

 }

-/**

- * Gets the width of the receiver.

- *

- * @return the width

- *

- * @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>

- */

+/**
+ * Gets the width of the receiver.
+ *
+ * @return the width
+ *
+ * @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 getWidth () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNwidth, 0};

 	OS.XtGetValues (handle, argList, argList.length / 2);

 	return argList [1];

@@ -427,23 +379,24 @@
 	OS.XtAddEventHandler (handle, OS.EnterWindowMask, false, windowProc, SWT.MouseEnter);

 	OS.XtAddEventHandler (handle, OS.LeaveWindowMask, false, windowProc, SWT.MouseExit);

 }

-/**

- * Returns <code>true</code> if the receiver is enabled, and

- * <code>false</code> otherwise.

- * <p>

- * A disabled control is typically not selectable from the

- * user interface and draws with an inactive or "grayed" look.

- * </p>

- *

- * @return the receiver's enabled 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 enabled, and
+ * <code>false</code> otherwise.
+ * <p>
+ * A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ * </p>
+ *
+ * @return the receiver's enabled 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 isEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return getEnabled () && parent.isEnabled ();

 }

 void manageChildren () {

@@ -469,25 +422,26 @@
 	toolTipText = null;

 	image = disabledImage = hotImage = null; 

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the control is selected.

- *

- * @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 SelectionListener

- * @see #addSelectionListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected.
+ *
+ * @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 SelectionListener
+ * @see #addSelectionListener
  */

 public void removeSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook(SWT.Selection, listener);

@@ -518,25 +472,22 @@
 	int newWidth = Math.max (width, 1), newHeight = Math.max (height, 1);

 	OS.XtConfigureWidget (handle, x, y, newWidth, newHeight, 0);

 }

-/**

- * Sets the control that is used to fill the bounds of

- * the item when the items is a <code>SEPARATOR</code>.

- *

- * @param control the new control

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the control 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>

+/**
+ * Sets the control that is used to fill the bounds of
+ * the item when the items is a <code>SEPARATOR</code>.
+ *
+ * @param control the new control
+ *
+ * @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 setControl (Control control) {

-	checkWidget();

-	if (control != null) {

-		if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);

-		if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	if (control != null && control.parent != parent) {

+		error (SWT.ERROR_INVALID_PARENT);

 	}

 	if ((style & SWT.SEPARATOR) == 0) return;

 	this.control = control;

@@ -544,78 +495,73 @@
 		control.setBounds (getBounds ());

 	}

 }

-/**

- * Enables the receiver if the argument is <code>true</code>,

- * and disables it otherwise.

- * <p>

- * A disabled control is typically

- * not selectable from the user interface and draws with an

- * inactive or "grayed" look.

- * </p>

- *

- * @param enabled the new enabled 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>

+/**
+ * Enables the receiver if the argument is <code>true</code>,
+ * and disables it otherwise.
+ * <p>
+ * A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ * </p>
+ *
+ * @param enabled the new enabled 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 void setEnabled (boolean enabled) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] argList = {OS.XmNsensitive, enabled ? 1 : 0};

 	OS.XtSetValues (handle, argList, argList.length / 2);

 }

-/**

- * Sets the receiver's disabled image to the argument, which may be

- * null indicating that no disabled image should be displayed.

- * <p>

- * The disbled image is displayed when the receiver is disabled.

- * </p>

- *

- * @param image the disabled image to display on the receiver (may be null)

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the image 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>

+/**
+ * Sets the receiver's disabled image to the argument, which may be
+ * null indicating that no disabled image should be displayed.
+ * <p>
+ * The disbled image is displayed when the receiver is disabled.
+ * </p>
+ *
+ * @param image the hot image to display on the receiver (may be null)
+ *
+ * @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 setDisabledImage (Image image) {

-	checkWidget();

-	if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SEPARATOR) != 0) return;

 	disabledImage = image;

 	if (!getEnabled ()) redraw ();

 }

-/**

- * Sets the receiver's hot image to the argument, which may be

- * null indicating that no hot image should be displayed.

- * <p>

- * The hot image is displayed when the mouse enters the receiver.

- * </p>

- *

- * @param image the hot image to display on the receiver (may be null)

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the image 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>

+/**
+ * Sets the receiver's hot image to the argument, which may be
+ * null indicating that no hot image should be displayed.
+ * <p>
+ * The hot image is displayed when the mouse enters the receiver.
+ * </p>
+ *
+ * @param image the hot image to display on the receiver (may be null)
+ *
+ * @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 setHotImage (Image image) {

-	checkWidget();

-	if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SEPARATOR) != 0) return;

 	hotImage = image;

 	if ((parent.style & SWT.FLAT) != 0) redraw ();

 }

 public void setImage (Image image) {

-	checkWidget();

-	if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SEPARATOR) != 0) return;

 	super.setImage (image);

 	Point size = computeSize ();

@@ -623,23 +569,24 @@
 	redraw ();

 }

 

-/**

- * Sets the selection state of the receiver.

- * <p>

- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,

- * it is selected when it is checked. When it is of type <code>TOGGLE</code>,

- * it is selected when it is pushed.

- * </p>

- *

- * @param selected the new selection 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>

+/**
+ * Sets the selection state of the receiver.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
+ * it is selected when it is pushed.
+ * </p>
+ *
+ * @param selected the new selection 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 void setSelection (boolean selected) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return;

 	if (selected == set) return;

 	set = selected;

@@ -654,7 +601,8 @@
 	}

 }

 public void setText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if ((style & SWT.SEPARATOR) != 0) return;

 	super.setText (string);

@@ -663,33 +611,35 @@
 	redraw ();

 }

 

-/**

- * Sets the receiver's tool tip text to the argument, which

- * may be null indicating that no tool tip text should be shown.

- *

- * @param string the new tool tip text (or null)

- *

- * @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>

+/**
+ * Sets the receiver's tool tip text to the argument, which
+ * may be null indicating that no tool tip text should be shown.
+ *
+ * @param string the new tool tip text (or null)
+ *
+ * @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 setToolTipText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	toolTipText = string;

 }

-/**

- * Sets the width of the receiver.

- *

- * @param width the new width

- *

- * @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>

- */

+/**
+ * Sets the width of the receiver.
+ *
+ * @param width the new width
+ *
+ * @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 setWidth (int width) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SEPARATOR) == 0) return;

 	if (width < 0) return;

 	int [] argList = {OS.XmNheight, 0};

@@ -896,10 +846,9 @@
 	}

 	gc.setBackground (parent.getBackground ());

 		

-	final String plainText = stripMnemonicCodes(this.text);

 	int textX = 0, textY = 0, textWidth = 0, textHeight = 0;

-	if (plainText.length () != 0) {

-		Point textExtent = gc.textExtent (plainText);

+	if (text.length () != 0) {

+		Point textExtent = gc.textExtent (text);

 		textWidth = textExtent.x;

 		textHeight = textExtent.y;

 	}	

@@ -927,10 +876,7 @@
 	if ((style & SWT.DROP_DOWN) != 0) {

 		textX -= 6;  imageX -=6;

 	}

-	if (textWidth > 0) {

-		/* To display the mnemonic underscore we'll want to use XmStringDrawUnderline here */

-		gc.drawText(plainText, textX, textY, false);

-	}

+	if (textWidth > 0) gc.drawText(text, textX, textY, false);

 	if (imageWidth > 0) gc.drawImage(currentImage, imageX, imageY);

 	if ((style & SWT.DROP_DOWN) != 0) {

 		int startX = width - 12, startY = (height - 2) / 2;

@@ -946,33 +892,4 @@
 	}

 	return 0;

 }

-void propagateWidget (boolean enabled) {

-	propagateHandle (enabled, handle);

-	/*

-	* ToolItems never participate in focus traversal when

-	* either enabled or disabled.

-	*/

-	if (enabled) {

-		int [] argList = {OS.XmNtraversalOn, 0};

-		OS.XtSetValues (handle, argList, argList.length / 2);

-	}

-}

-/**

- * Returns the provided string without mnemonic indicators.

- * 

- * @param string the string to demangle

- */

-static String stripMnemonicCodes(String string) {

-	char [] text = new char[string.length ()];

-	string.getChars(0, text.length, text, 0);

-	int j = 0;

-	for (int i = 0; i < text.length;) {

-		if ((text[j++] = text[i++]) == Mnemonic) {

-			if (i != text.length) {

-				if (text[i] == Mnemonic) i++; else j--;

-			}

-		}

-	}

-	return new String(text, 0, j);

-}

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tracker.java
index 59394ba..a185c1c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tracker.java
@@ -10,88 +10,35 @@
 import org.eclipse.swt.*;

 import org.eclipse.swt.events.*;

 

-/**

- *  Instances of this class implement rubber banding rectangles.

- *  

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>(none)</dd>

- * <dt><b>Events:</b></dt>

- * <dd>Move</dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is <em>not</em> intended to be subclassed.

- * </p>

+/**
+ *  Instances of this class implement rubber banding rectangles.
+ *  
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Move</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
  */

 public /*final*/ class Tracker extends Widget {

 	Composite parent;

 	Display display;

 	boolean tracking, stippled;

 	Rectangle [] rectangles = new Rectangle [0];

-

 /**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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 widget which will be the parent of the new instance (cannot be null)

- * @param style the style of widget to construct

- *

- * @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

- */

+* Creates a new instance of the widget.

+*/

 public Tracker (Composite parent, int style) {

 	super (parent, style);

 	this.parent = parent;

 	display = parent.getDisplay ();

 }

-

 /**

- * Constructs a new instance of this class given the display

- * to create it on and a style value describing its behavior

- * and appearance.

- * <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><p>

- * Note: Currently, null can be passed in for the display argument.

- * This has the effect of creating the tracker on the currently active

- * display if there is one. If there is no current display, the 

- * tracker is created on a "default" display. <b>Passing in null as

- * the display argument is not considered to be good coding style,

- * and may not be supported in a future release of SWT.</b>

- * </p>

- *

- * @param display the display to create the tracker on

- * @param style the style of control to construct

- *

- * @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>

- */

+* Creates a new instance of the widget.

+*/

 public Tracker (Display display, int style) {

 	if (display == null) display = Display.getCurrent ();

 	if (display == null) display = Display.getDefault ();

@@ -101,42 +48,41 @@
 	this.style = style;

 	this.display = display;

 }

-

-/**

- * Adds the listener to the collection of listeners who will

- * be notified when the control is moved or resized, by sending

- * it one of the messages defined in the <code>ControlListener</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 ControlListener

- * @see #removeControlListener

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is moved or resized, by sending
+ * it one of the messages defined in the <code>ControlListener</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 ControlListener
+ * @see #removeControlListener
  */

 public void addControlListener(ControlListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Move,typedListener);

 }

-/**

- * Stop displaying the tracker rectangles.

- *

- * @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>

- */

+/**
+ * Stop displaying the tracker rectangles.
+ *
+ * @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 close () {

-	checkWidget();

 	tracking = false;

 }

 void drawRectangles () {

@@ -180,44 +126,41 @@
 public Display getDisplay () {

 	return display;

 }

-/**

- * Returns the bounds of the Rectangles being drawn.

- *

- * @return the bounds of the Rectangles being drawn

- * 

- * @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 the bounds of the Rectangles being drawn.
+ *
+ * @return the bounds of the Rectangles being drawn
+ * 
+ * @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 [] getRectangles () {

-	checkWidget();

 	return rectangles;

 }

-/**

- * Returns <code>true</code> if the rectangles are drawn with a stippled line, <code>false</code> otherwise.

- *

- * @return the stippled effect of the rectangles

- *

- * @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 rectangles are drawn with a stippled line, <code>false</code> otherwise.
+ *
+ * @return the stippled effect of the rectangles
+ *
+ * @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 getStippled () {

-	checkWidget();

 	return stippled;

 }

-/**

- * Start displaying the Tracker rectangles.

- * 

- * @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>

- */

+/**
+ * Start displaying the Tracker rectangles.
+ * 
+ * @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 open () {

-	checkWidget();

 	int xDisplay = display.xDisplay;

 	int color = OS.XWhitePixel (xDisplay, 0);

 	int xWindow = OS.XDefaultRootWindow (xDisplay);

@@ -228,6 +171,7 @@
 	boolean cancelled = false;

 	tracking = true;

 	drawRectangles ();

+	Event event = new Event ();

 	XAnyEvent xEvent = new XAnyEvent ();

 	int [] unused = new int [1];

 	int [] newX = new int [1], newY = new int [1], oldX = new int [1], oldY = new int [1];

@@ -246,10 +190,7 @@
 						rectangles [i].x += newX [0] - oldX [0];

 						rectangles [i].y += newY [0] - oldY [0];

 					}

-					Event event = new Event();

-					event.x = newX[0];

-					event.y = newY[0];

-					sendEvent (SWT.Move,event);

+					sendEvent (SWT.Move);

 					drawRectangles ();

 					oldX [0] = newX [0];  oldY [0] = newY [0];

 				}

@@ -260,7 +201,7 @@
 				OS.memmove (keyEvent, xEvent, XKeyEvent.sizeof);

 				if (keyEvent.keycode != 0) {

 					int [] keysym = new int [1];

-					OS.XLookupString (keyEvent, null, 0, keysym, null);

+					OS.XLookupString (keyEvent, null, 0, keysym, unused);

 					keysym [0] &= 0xFFFF;

 					tracking = keysym [0] != OS.XK_Escape && keysym [0] != OS.XK_Cancel;

 					cancelled = !tracking;

@@ -272,55 +213,54 @@
 	tracking = false;

 	return !cancelled;

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notified when the control is moved or resized.

- *

- * @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 ControlListener

- * @see #addControlListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is moved or resized.
+ *
+ * @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 ControlListener
+ * @see #addControlListener
  */

 public void removeControlListener (ControlListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Move, listener);

 }

-/**

- * Specify the rectangles that should be drawn.

- *

- * @param rectangles the bounds of the rectangles to be drawn

- *

- * @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>

- */

+/**
+ * Specify the rectangles that should be drawn.
+ *
+ * @param rectangles the bounds of the rectangles to be drawn
+ *
+ * @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 setRectangles (Rectangle [] rectangles) {

-	checkWidget();

 	this.rectangles = rectangles;

 }

-/**

- * Change the appearance of the line used to draw the rectangles.

- *

- * @param stippled <code>true</code> if rectangle should appear stippled

- *

- * @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>

- */

+/**
+ * Change the appearance of the line used to draw the rectangles.
+ *
+ * @param stippled <code>true</code> if rectangle should appear stippled
+ *
+ * @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 setStippled (boolean stippled) {

-	checkWidget();

 	this.stippled = stippled;

 }

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tree.java
new file mode 100755
index 0000000..44b79a3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tree.java
@@ -0,0 +1,1661 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+

+import org.eclipse.swt.*;

+import org.eclipse.swt.events.*;

+import org.eclipse.swt.graphics.*;

+import java.io.*;

+import java.util.*;

+ 

+/**
+ * Instances of this class provide a selectable user interface object
+ * that displays a hierarchy of items and issue notificiation when an
+ * item in the hierarchy is selected.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TreeItem</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SINGLE, MULTI, CHECK</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, DefaultSelection, Collapse, Expand</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */

+public /*final*/ class Tree extends SelectableItemWidget {

+	// These constants are used internally for item hit test on mouse click

+	private static final int ActionNone = 0;			// The mouse event was not handled

+	private static final int ActionExpandCollapse = 1;	// Do an expand/collapse

+	private static final int ActionSelect = 2;			// Select the item

+	private static final int ActionCheck = 3;			// Toggle checked state of the item

+	private static ImageData CollapsedImageData;		// collapsed sub tree image data. used to create an image at run time

+	private static ImageData ExpandedImageData;			// expanded sub tree image data. used to create an image at run time

+	static {

+		initializeImageData();

+	}

+	

+	private TreeRoots root;

+	private TreeItem expandingItem;

+	

+	private Image collapsedImage;

+	private Image expandedImage;

+

+	// The following fields are needed for painting tree items

+	final Color CONNECTOR_LINE_COLOR;					// Color constant used during painting. Can't keep this in TreeItem 

+														// because we only need one instance per tree widget/display and can't 

+														// have it static. Initialized in c'tor and freed in dispose();

+	Rectangle hierarchyIndicatorRect = null;			// bounding rectangle of the hierarchy indication image (plus/minus)

+

+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <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
+ *
+ * @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 Tree(Composite parent, int style) {

+	super(parent, checkStyle (style));

+	CONNECTOR_LINE_COLOR = new Color(getDisplay(), 170, 170, 170);	// Light gray;

+}

+/**

+ * Add 'item' to the list of root items.

+ * @param 'item' - the tree item that should be added as a root.

+ * @param index - position that 'item' will be inserted at

+ *	in the receiver.

+ */

+void addItem(TreeItem item, int index) {

+	if (index < 0 || index > getItemCount()) {

+		error(SWT.ERROR_INVALID_RANGE);

+	}

+	getRoot().add(item, index);

+}

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's selection changes, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>

+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.

+ * If the reciever has <code>SWT.CHECK</code> style set and the check selection changes,

+ * the event object detail field contains the value <code>SWT.CHECK</code>.

+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.

+ * </p>

+ *
+ * @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 SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent

+ */

+public void addSelectionListener(SelectionListener listener) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	TypedListener typedListener;

+

+	if (listener == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	typedListener = new TypedListener(listener);	

+	addListener(SWT.Selection, typedListener);

+	addListener(SWT.DefaultSelection, typedListener);

+}

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when an item in the receiver is expanded or collapsed
+ * by sending it one of the messages defined in the <code>TreeListener</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 TreeListener
+ * @see #removeTreeListener
+ */

+public void addTreeListener(TreeListener listener) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	TypedListener typedListener;

+

+	if (listener == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	typedListener = new TypedListener(listener);	

+	addListener(SWT.Expand, typedListener);

+	addListener(SWT.Collapse, typedListener);

+}

+/**

+ * The SelectableItem 'item' has been added to the tree.

+ * Prevent screen updates when 'item' is inserted due to an 

+ * expand operation.

+ * @param item - item that has been added to the receiver.

+ */

+void addedItem(SelectableItem item, int index) {

+	super.addedItem(item, index);				

+	redrawAfterModify(item, index);		// redraw plus/minus image, hierarchy lines

+}

+/**

+ * Answer the y position of both the first child of 'item' and 

+ * the item following the last child of 'item'.

+ * Used to scroll items on expand/collapse.

+ * @param item - TreeItem to use for calculating the y boundary 

+ *	of child items.

+ * @return Array - first element is the position of the first 

+ *	child of 'item'. Second element is the position of the item 

+ *	following the last child of 'item'.

+ *	Both elements are -1 if 'item' is not a child of the receiver.

+ */

+int[] calculateChildrenYPos(TreeItem item) {

+	int itemIndex = item.getVisibleIndex();

+	int itemCount = item.getVisibleItemCount();

+	int itemHeight = getItemHeight();

+	int yPos;

+	int[] yPosition = new int[] {-1, -1};

+

+	if (itemIndex != -1) {

+		itemIndex -= getTopIndex();															

+		yPos = (itemIndex + itemCount + 1) * itemHeight;	// y position of the item following 

+															// the last child of 'item'

+		yPosition = new int[] {yPos - (itemCount * itemHeight), yPos};

+	}

+	return yPosition;

+}

+/**

+ * Calculate the widest of the children of 'item'.

+ * Items that are off screen and that may be scrolled into view are 

+ * included in the calculation.

+ * @param item - the tree item that was expanded

+ */

+void calculateWidestExpandingItem(TreeItem item) {

+	int itemIndex = item.getVisibleIndex();

+	int newMaximumItemWidth = getContentWidth();

+	int stopIndex = itemIndex + item.getVisibleItemCount();

+

+	for (int i = itemIndex + 1; i <= stopIndex; i++) {

+		newMaximumItemWidth = Math.max(newMaximumItemWidth, getContentWidth(i));

+	}

+	setContentWidth(newMaximumItemWidth);

+}

+/**

+ * Calculate the width of new items as they are scrolled into view.

+ * Precondition: 

+ * topIndex has already been set to the new index.

+ * @param topIndexDifference - difference between old and new top 

+ *	index.

+ */

+void calculateWidestScrolledItem(int topIndexDifference) {

+	int visibleItemCount = getItemCountTruncated(getClientArea());	

+	int newMaximumItemWidth = getContentWidth();

+	int topIndex = getTopIndex();

+	int stopIndex = topIndex;

+

+	if (topIndexDifference < 0) {								// scrolled up?

+		if (Math.abs(topIndexDifference) > visibleItemCount) {	// scrolled down more than one page (via quick thumb dragging)?

+			topIndexDifference = visibleItemCount * -1;

+		}

+		for (int i = stopIndex - topIndexDifference; i >= stopIndex; i--) {	// check item width from old top index up to new one

+			newMaximumItemWidth = Math.max(newMaximumItemWidth, getContentWidth(i));

+		}

+	}

+	else

+	if (topIndexDifference > 0) {								// scrolled down?

+		if (topIndexDifference > visibleItemCount) {			// scrolled down more than one page (via quick thumb dragging)?

+			topIndexDifference = visibleItemCount;

+		}

+		stopIndex += visibleItemCount;		

+		for (int i = stopIndex - topIndexDifference; i < stopIndex; i++) {

+			newMaximumItemWidth = Math.max(newMaximumItemWidth, getContentWidth(i));

+		}

+	}

+	setContentWidth(newMaximumItemWidth);

+}

+/**

+ * Calculate the maximum item width of all displayed items.

+ */

+void calculateWidestShowingItem() {

+	TreeItem visibleItem;

+	int newMaximumItemWidth = 0;

+	int bottomIndex = getBottomIndex();

+	int paintStopX;

+

+	// add one to the loop end index because otherwise an item covered 

+	// by the horizontal scroll bar would not be taken into acount and 

+	// may become visible after this calculation. We're in trouble if

+	// that item is wider than the client area.

+	if (getHorizontalBar().getVisible() == true) {

+		bottomIndex++;

+	}

+	for (int i = getTopIndex(); i < bottomIndex; i++) {

+		visibleItem = getRoot().getVisibleItem(i);

+		if (visibleItem != null) {

+			paintStopX = visibleItem.getPaintStopX();

+			newMaximumItemWidth = Math.max(newMaximumItemWidth, paintStopX);

+		}

+	}

+	setContentWidth(newMaximumItemWidth);

+}

+static int checkStyle (int style) {

+	return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);

+}

+protected void checkSubclass () {

+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);

+}

+/**

+ * Collapse the tree item identified by 'item' if it is not 

+ * already collapsed. Move the selection to the parent item 

+ * if one of the collapsed items is currently selected.

+ * @param item - item that should be collapsed.

+ * @param notifyListeners - 

+ *	true=a Collapse event is sent 

+ *	false=no event is sent

+ */

+void collapse(TreeItem item, boolean notifyListeners) {

+	Event event;

+	int itemIndex;

+	

+	if (item.getExpanded() == false) {

+		return;

+	}

+	collapseNoRedraw(item);

+	itemIndex = item.getVisibleIndex();

+	if (itemIndex != -1) {						// if the item's parent is not collapsed (and the item is thus visible) do the screen updates

+		item.redrawExpanded(itemIndex - getTopIndex());

+		showSelectableItem(item);

+		calculateVerticalScrollbar();

+		calculateWidestShowingItem();

+		claimRightFreeSpace();

+		claimBottomFreeSpace();		

+	}

+	if (notifyListeners == true) {

+		event = new Event();

+		event.item = item;

+		notifyListeners(SWT.Collapse, event);

+	}

+}

+

+/**

+ * Collapse the tree item identified by 'item' if it is not 

+ * already collapsed. Move the selection to the parent item 

+ * if one of the collapsed items is currently selected.

+ * This method is used to hide the children if an item is deleted.

+ * certain redraw and scroll operations are not needed for this 

+ * case.

+ * @param item - item that should be collapsed.

+ */

+void collapseNoRedraw(TreeItem item) {

+	int itemIndex;

+	

+	if (item.getExpanded() == false) {

+		return;

+	}

+	if (isSelectedItemCollapsing(item) == true) {

+		deselectAllExcept(item);

+		selectNotify(item);

+		update();								// call update to make sure that new selection is 

+												// drawn before items are collapsed (looks better)

+	}

+	scrollForCollapse(item);

+	item.internalSetExpanded(false);

+}

+

+public Point computeSize(int wHint, int hHint, boolean changed) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Point size = super.computeSize(wHint, hHint, changed);

+	GC gc;

+	final int WidthCalculationCount = 50;		// calculate item width for the first couple of items only

+	TreeRoots root = getRoot();

+	TreeItem item;

+	Image itemImage;

+	String itemText;

+	int width;

+	int newItemWidth = 0;

+		

+	if (getContentWidth() == 0 && getItemCount() > 0) {

+		gc = new GC(this);

+		for (int i = 0; i < WidthCalculationCount; i++) {

+			item = root.getVisibleItem(i);

+			if (item == null) {

+				break;											// no more items

+			}

+			itemImage = item.getImage();

+			itemText = item.getText();

+			width = 0;

+			if (itemImage != null) {

+				width += itemImage.getBounds().width;

+			}

+			if (itemText != null) {

+				width += gc.stringExtent(itemText).x;

+			}

+			newItemWidth = Math.max(newItemWidth, width);

+		}

+		if (newItemWidth > 0) {

+			size.x = newItemWidth;

+		}		

+		gc.dispose();

+	}

+	return size;

+}

+/**
+ * Deselects all selected items in the receiver.
+ *
+ * @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 deselectAll() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	getRoot().deselectAll();

+	getSelectionVector().removeAllElements();

+	redraw();

+}

+/**

+ * Modifier Key		Action

+ * None				Collapse the selected item if expanded. Select 

+ * 					parent item if selected item is already 

+ * 					collapsed and if it's not the root item.

+ * Ctrl				super.doArrowLeft(int);

+ * Shift			see None above

+ * @param keyMask - the modifier key that was pressed

+ */

+void doArrowLeft(int keyMask) {

+	TreeItem focusItem = (TreeItem) getLastFocus();

+	TreeItem parentItem;

+

+	if (focusItem == null) {

+		return;

+	}

+	if (keyMask == SWT.CTRL) {

+		super.doArrowLeft(keyMask);

+	}

+	else

+	if (focusItem.getExpanded() == true) {			// collapse if expanded

+		collapse(focusItem, true);

+	}

+	else

+	if (focusItem.isRoot() == false) {				// go to the parent if there is one

+		parentItem = focusItem.getParentItem();

+		deselectAllExcept(parentItem);

+		selectNotify(parentItem);

+	}

+}

+/**

+ * Modifier Key		Action

+ * None				Expand selected item if collapsed. Select 

+ * 					first child item if selected item is 

+ *					already expanded and there is a child item.

+ * Ctrl				super.doArrowRight(keyMask);

+ * Shift			see None above

+ * @param keyMask - the modifier key that was pressed

+ */

+void doArrowRight(int keyMask) {

+	TreeItem focusItem = (TreeItem) getLastFocus();

+	TreeItem childItem;

+

+	if (focusItem == null) {

+		return;

+	}	

+	if (keyMask == SWT.CTRL) {

+		super.doArrowRight(keyMask);

+	}

+	else

+	if (focusItem.isLeaf() == false) {

+		if (focusItem.getExpanded() == false) {			// expand if collapsed

+			expand(focusItem, true);

+		} 

+		else {											// go to the first child if there is one

+			childItem = focusItem.getItems()[0];

+			deselectAllExcept(childItem);

+			selectNotify(childItem);

+		}

+	}

+}

+/**

+ * Expand the selected item and all of its children.

+ */

+void doAsterix() {

+	expandAll((TreeItem) getLastFocus());

+}

+/**

+ * Free resources.

+ */

+void doDispose() {

+	super.doDispose();	

+	if (collapsedImage != null) {

+		collapsedImage.dispose();

+	}

+	if (expandedImage != null) {

+		expandedImage.dispose();

+	}

+	getRoot().dispose();

+	CONNECTOR_LINE_COLOR.dispose();

+	resetHierarchyIndicatorRect();

+}

+/**

+ * Collapse the selected item if it is expanded.

+ */

+void doMinus() {

+	TreeItem selectedItem = (TreeItem) getLastFocus();

+

+	if (selectedItem != null) {

+		collapse(selectedItem, true);

+	}

+}

+/**

+ * Expand the selected item if it is collapsed and if it 

+ * has children.

+ */

+void doPlus() {

+	TreeItem selectedItem = (TreeItem) getLastFocus();

+

+	if (selectedItem != null && selectedItem.isLeaf() == false) {

+		expand(selectedItem, true);

+	}

+}

+/**

+ * Expand the tree item identified by 'item' if it is not already 

+ * expanded. Scroll the expanded items into view.

+ * @param item - item that should be expanded

+ * @param notifyListeners - 

+ *	true=an Expand event is sent 

+ *	false=no event is sent

+ */

+void expand(TreeItem item, boolean notifyListeners) {

+	Event event = new Event();

+	int indexFromTop;

+	boolean nestedExpand = expandingItem != null;

+

+	if (item.getExpanded() == true) {

+		return;

+	}

+	if (nestedExpand == false) {

+		setExpandingItem(item);

+	}

+	scrollForExpand(item);

+	item.internalSetExpanded(true);

+	if (notifyListeners == true) {

+		event.item = item;

+		notifyListeners(SWT.Expand, event);

+	}

+	// redraw hierarchy image

+	item.redrawExpanded(item.getVisibleIndex() - getTopIndex());

+	calculateVerticalScrollbar();

+	if (nestedExpand == false && isVisible() == true) {

+		// Save the index here because showSelectableItem may change it

+		indexFromTop = item.getVisibleIndex() - getTopIndex();		

+		showSelectableItem(item);				// make expanded item visible. Could be invisible if the expand was caused by a key press.		

+		calculateWidestExpandingItem(item);

+		scrollExpandedItemsIntoView(item);		

+	}

+	if (nestedExpand == false) {

+		setExpandingItem(null);

+	}

+}

+/**

+ * Expand 'item' and all its children.

+ */

+void expandAll(TreeItem item) {

+	TreeItem items[];

+

+	if (item != null && item.isLeaf() == false) {

+		expand(item, true);

+		update();

+		items = item.getItems(); 

+		for (int i = 0; i < items.length; i++) {

+			expandAll(items[i]);

+		}

+	}

+}

+/**

+ * Answer the image that is used as a hierarchy indicator 

+ * for a collapsed hierarchy.

+ */

+Image getCollapsedImage() {

+	if (collapsedImage == null) {

+		collapsedImage = new Image(getDisplay(), CollapsedImageData);

+	}

+	return collapsedImage;

+}

+/**

+ * Answer the width of the item identified by 'itemIndex'.

+ */

+int getContentWidth(int itemIndex) {

+	TreeItem item = getRoot().getVisibleItem(itemIndex);

+	int paintStopX = 0;

+

+	if (item != null) {

+		paintStopX = item.getPaintStopX();

+	}

+	return paintStopX;

+}

+/**

+ * Answer the image that is used as a hierarchy indicator 

+ * for an expanded hierarchy.

+ */

+Image getExpandedImage() {

+	if (expandedImage == null) {

+		expandedImage = new Image(getDisplay(), ExpandedImageData);

+	}

+	return expandedImage;

+}

+/**

+ * Answer the rectangle enclosing the hierarchy indicator of a tree item.

+ * 

+ * Note:

+ * Assumes that the hierarchy indicators for expanded and 

+ * collapsed state are the same size.

+ * @return

+ *	The rectangle enclosing the hierarchy indicator.

+ */

+Rectangle getHierarchyIndicatorRect() {

+	int itemHeight = getItemHeight();

+	Image hierarchyImage;

+	Rectangle imageBounds;

+	

+	if (hierarchyIndicatorRect == null && itemHeight != -1) {

+		hierarchyImage = getCollapsedImage();

+		if (hierarchyImage != null) {

+		 	imageBounds = hierarchyImage.getBounds();

+		}

+		else {

+			imageBounds = new Rectangle(0, 0, 0, 0);

+		}

+		hierarchyIndicatorRect = new Rectangle(

+			0,

+			(itemHeight - imageBounds.height) / 2 + (itemHeight - imageBounds.height) % 2,

+			imageBounds.width,

+			imageBounds.height);

+	}

+	return hierarchyIndicatorRect;

+}

+/**

+ * Answer the index of 'item' in the receiver.

+ */

+int getIndex(SelectableItem item) {

+	int index = -1;

+

+	if (item != null) {

+		index = ((TreeItem) item).getGlobalIndex();

+	}

+	return index;

+}

+/**
+ * Returns the number of items contained in the receiver
+ * that are direct item children of the receiver.  The
+ * number that is returned is the number of roots in the
+ * tree.
+ *
+ * @return the number of items
+ *
+ * @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 getItemCount() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return getRoot().getItemCount();

+}

+/**
+ * Returns the height of the area which would be used to
+ * display <em>one</em> of the items in the tree.
+ *
+ * @return the height of one item
+ *
+ * @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 getItemHeight() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return super.getItemHeight();

+}

+/**
+ * Returns the number of items contained in the receiver
+ * that are direct item children of the receiver.  These
+ * are the roots of the tree.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the number of items
+ *
+ * @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 TreeItem [] getItems() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	TreeItem childrenArray[] = new TreeItem[getItemCount()];

+

+	getRoot().getChildren().copyInto(childrenArray);

+	return childrenArray;	

+}

+/**

+ * Answer the number of sub items of 'item' that do not fit in the 

+ * tree client area.

+ */

+int getOffScreenItemCount(TreeItem item) {

+	int itemIndexFromTop = item.getVisibleIndex() - getTopIndex();

+	int spaceRemaining = getItemCountWhole()-(itemIndexFromTop+1);

+	int expandedItemCount = item.getVisibleItemCount();

+

+	return expandedItemCount - spaceRemaining;	

+}

+/**
+ * Returns the receiver's parent item, which must be a
+ * <code>TreeItem</code> or null when the receiver is a
+ * root.
+ *
+ * @return the receiver's parent item
+ *
+ * @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 TreeItem getParentItem() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return null;

+}

+/**

+ * Answer the object that holds the root items of the receiver.

+ */

+TreeRoots getRoot() {

+	return root;

+}

+/**
+ * Returns an array of <code>TreeItem</code>s that are currently
+ * selected in the receiver. An empty array indicates that no
+ * items are selected.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ * @return an array representing the selection
+ *
+ * @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 TreeItem [] getSelection() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector selectionVector = getSelectionVector();

+	TreeItem[] selectionArray = new TreeItem[selectionVector.size()];

+

+	selectionVector.copyInto(selectionArray);

+	sort(selectionArray, 0, selectionArray.length);

+	return selectionArray;

+}

+/**

+ * Answer the index of 'item' in the receiver.

+ * Answer -1 if the item is not visible.

+ * The returned index must refer to a visible item.

+ * Note: 

+ * 	Visible in this context does not neccessarily mean that the 

+ * 	item is displayed on the screen. It only means that the item 

+ * 	would be displayed if it is located inside the receiver's 

+ * 	client area.

+ *	Collapsed items are not visible.

+ */

+int getVisibleIndex(SelectableItem item) {

+	int index = -1;

+

+	if (item != null) {

+		index = ((AbstractTreeItem) item).getVisibleIndex();

+	}

+	return index;

+}

+/**

+ * Answer the SelectableItem located at 'itemIndex' 

+ * in the receiver.

+ * @param itemIndex - location of the SelectableItem 

+ *	object to return

+ */

+SelectableItem getVisibleItem(int itemIndex) {

+	return getRoot().getVisibleItem(itemIndex);

+}

+/**

+ * Answer the number of visible items of the receiver.

+ * Note: 

+ * 	Visible in this context does not neccessarily mean that the 

+ * 	item is displayed on the screen. It only means that the item 

+ * 	would be displayed if it is located inside the receiver's 

+ * 	client area.

+ *	Collapsed items are not visible.

+ */

+int getVisibleItemCount() {

+	return getRoot().getVisibleItemCount();

+}

+/**

+ * Answer the y coordinate at which 'item' is drawn. 

+ * @param item - SelectableItem for which the paint position 

+ *	should be returned

+ * @return the y coordinate at which 'item' is drawn.

+ *	Return -1 if 'item' is null or outside the client area

+ */

+int getVisibleRedrawY(SelectableItem item) {

+	int redrawY = getRedrawY(item);

+	

+	if (redrawY < 0 || redrawY > getClientArea().height) {

+		redrawY = -1;

+	}

+	return redrawY;

+}

+/**

+ * Handle the events the receiver is listening to.

+ */

+void handleEvents(Event event) {

+	switch (event.type) {

+		case SWT.Paint:

+			paint(event);

+			break;

+		case SWT.MouseDown:

+			mouseDown(event);

+			break;

+		case SWT.MouseDoubleClick:

+			mouseDoubleClick(event);

+			break;

+		default:

+			super.handleEvents(event);

+	}	

+}

+/**

+ * Initialize the receiver.

+ */

+void initialize() {

+	resetRoot();					// has to be at very top because super class uses 

+									// functionality that relies on the TreeRoots object

+	super.initialize();

+}

+/**

+ * Initialize the ImageData used for the expanded/collapsed images.

+ */

+static void initializeImageData() {

+	PaletteData fourBit = new PaletteData(

+		new RGB[] {new RGB(0, 0, 0), new RGB (128, 0, 0), new RGB (0, 128, 0), new RGB (128, 128, 0), new RGB (0, 0, 128), new RGB (128, 0, 128), new RGB (0, 128, 128), new RGB (128, 128, 128), new RGB (192, 192, 192), new RGB (255, 0, 0), new RGB (0, 255, 0), new RGB (255, 255, 0), new RGB (0, 0, 255), new RGB (255, 0, 255), new RGB (0, 255, 255), new RGB (255, 255, 255)});

+	

+	CollapsedImageData = new ImageData(

+		9, 9, 4, 										// width, height, depth

+		fourBit, 4,

+		new byte[] {119, 119, 119, 119, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, 15, -1, 112, 0, 0, 0, 127, -1, 15, -1, 112, 0, 0, 0, 127, 0, 0, 15, 112, 0, 0, 0, 127, -1, 15, -1, 112, 0, 0, 0, 127, -1, 15, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 119, 119, 119, 119, 112, 0, 0, 0});

+	CollapsedImageData.transparentPixel = 15;			// use white for transparency

+	ExpandedImageData = new ImageData(

+		9, 9, 4, 										// width, height, depth

+		fourBit, 4,

+		new byte[] {119, 119, 119, 119, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, 0, 0, 15, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 119, 119, 119, 119, 112, 0, 0, 0});

+	ExpandedImageData.transparentPixel = 15;			// use white for transparency

+}

+/**

+ * Set event listeners for the receiver.

+ */

+void installListeners() {

+	Listener listener = getListener();

+

+	super.installListeners();

+	addListener(SWT.Paint, listener);

+	addListener(SWT.MouseDown, listener);

+	addListener(SWT.MouseDoubleClick, listener);

+}

+/**

+ * Answer whether the receiver is currently expanding a sub tree 

+ * with 'item' in it.

+ * Used for performance optimizations.

+ */

+boolean isExpandingItem(SelectableItem item) {

+	TreeItem parentItem;

+	

+	if (expandingItem == null || item == null || (item instanceof TreeItem) == false) {

+		return false;

+	}

+	parentItem = ((TreeItem) item).getParentItem();

+	return (parentItem == expandingItem || isExpandingItem(parentItem));

+}

+/**

+ * Answer whether the children of 'collapsingItem' contain 

+ * at least one selected item.

+ */

+boolean isSelectedItemCollapsing(TreeItem collapsingItem) {

+	Enumeration selection = getSelectionVector().elements();

+	TreeItem item;

+	int selectedItemIndex;

+	int collapsingItemIndex = collapsingItem.getVisibleIndex();

+	int lastCollapsedItemIndex = collapsingItemIndex + collapsingItem.getVisibleItemCount();

+

+	if (collapsingItemIndex == -1) {					// is the collapsing item in a collapsed subtree?

+		return false;									// then neither it nor its children are selected

+	}

+	while (selection.hasMoreElements() == true) {

+		item = (TreeItem) selection.nextElement();

+		selectedItemIndex = item.getVisibleIndex();

+		if ((selectedItemIndex > collapsingItemIndex) &&

+			(selectedItemIndex <= lastCollapsedItemIndex)) {

+			return true;

+		}

+	}

+	return false;

+}

+/**

+ * Test whether the mouse click specified by 'event' was a 

+ * valid selection or expand/collapse click.

+ * @return 

+ *  One of ActionExpandCollapse, ActionSelect, ActionNone, ActionCheck

+ *	specifying the action to be taken on the click.

+ */

+int itemAction(TreeItem item, int x, int y) {

+	int action = ActionNone;

+	int itemHeight = getItemHeight();

+	int offsetX;

+	int offsetY;

+	Point offsetPoint;

+

+	if (item != null) {

+		offsetX = x - item.getPaintStartX();

+		offsetY = y - itemHeight * (y / itemHeight);	

+		offsetPoint = new Point(offsetX, offsetY);	

+		if ((item.isLeaf() == false) &&

+			(getHierarchyIndicatorRect().contains(offsetPoint) == true)) {

+			action |= ActionExpandCollapse;

+		}

+		else

+		if (item.isSelectionHit(offsetPoint) == true) {

+			action |= ActionSelect;

+		}

+		else

+		if (item.isCheckHit(new Point(x, y)) == true) {

+			action |= ActionCheck;

+		}

+	}

+	return action;

+}

+/**

+ * The table item 'changedItem' has changed. Redraw the whole 

+ * item in that column. Include the text in the redraw because 

+ * an image set to null requires a redraw of the whole item anyway. 

+ */

+void itemChanged(SelectableItem changedItem, int repaintStartX, int repaintWidth) {

+	int oldItemHeight = getItemHeight();	

+	Point oldImageExtent = getImageExtent();

+	

+	if (isExpandingItem(changedItem) == false) {

+		super.itemChanged(changedItem, repaintStartX, repaintWidth);

+	}

+	else {

+		calculateItemHeight(changedItem);

+	}

+	if ((oldItemHeight != getItemHeight()) ||			// only reset items if the item height or

+		(oldImageExtent != getImageExtent())) {			// image size has changed. The latter will only change once, 

+														// from null to a value-so it's safe to test using !=

+		getRoot().reset();								// reset cached data of all items in the receiver

+		resetHierarchyIndicatorRect();

+		redraw();										// redraw all items if the image extent has changed. Fixes 1FRIHPZ		

+	}

+	else {

+		((AbstractTreeItem) changedItem).reset();		// reset the item that has changed when the tree item 

+														// height has not changed (otherwise the item caches old data)

+														// Fixes 1FF6B42

+	}

+	if (repaintWidth != 0) {

+		calculateWidestShowingItem();

+		claimRightFreeSpace();								// otherwise scroll bar may be reset, but not horizontal offset

+															// Fixes 1G4SBJ3

+	}

+}

+/**

+ * A key was pressed.

+ * Call the appropriate key handler method.

+ * @param event - the key event

+ */

+void keyDown(Event event) {

+	super.keyDown(event);

+	switch (event.character) {

+		case '+':

+			doPlus();

+			break;

+		case '-':

+			doMinus();

+			break;

+		case '*':

+			doAsterix();

+			break;

+	}

+}

+

+/**

+ * A mouse double clicked occurred over the receiver.

+ * Expand/collapse the clicked item. Do nothing if no item was clicked.

+ */

+void mouseDoubleClick(Event event) {

+	int hitItemIndex = event.y / getItemHeight();

+	TreeItem hitItem = getRoot().getVisibleItem(hitItemIndex + getTopIndex());

+	Event newEvent;

+	

+	if (hitItem == null || itemAction(hitItem, event.x, event.y) != ActionSelect) {

+		return;

+	}

+	if (hooks(SWT.DefaultSelection) == true) {

+		newEvent = new Event();

+		newEvent.item = hitItem;

+		notifyListeners(SWT.DefaultSelection, newEvent);

+	}

+	else

+	if (hitItem.isLeaf() == false) {		// item with children was hit. Default behavior is expand/collapse item

+		if (hitItem.getExpanded() == true) {

+			collapse(hitItem, true);

+		}

+		else {

+			expand(hitItem, true);

+		}

+	}

+}

+/**

+ * The mouse pointer was pressed down on the receiver.

+ * Handle the event according to the position of the mouse click.

+ */

+void mouseDown(Event event) {

+	int hitItemIndex;

+	TreeItem hitItem;

+	SelectableItem selectionItem = getLastSelection();

+	int itemAction;

+

+	if (event.button != 1) {		// only react to button one clicks.

+		return;

+	}

+	hitItemIndex = event.y / getItemHeight();

+	hitItem = getRoot().getVisibleItem(hitItemIndex + getTopIndex());

+	if (hitItem == null) {

+		return;

+	}

+	switch (itemAction = itemAction(hitItem, event.x, event.y)) {

+		case ActionExpandCollapse:

+			if (hitItem.getExpanded() == true) {

+				collapse(hitItem, true);

+			}

+			else {

+				expand(hitItem, true);

+			}

+			break;

+		case ActionSelect:

+			doMouseSelect(hitItem, hitItemIndex + getTopIndex(), event.stateMask, event.button);

+			break;

+		case ActionCheck:

+			doCheckItem(hitItem);

+			break;

+	}

+	if (itemAction != ActionSelect && selectionItem == null) {

+		selectionItem = getRoot().getVisibleItem(getTopIndex());	// select the top item if no item was selected before

+		selectNotify(selectionItem);								

+	}

+}

+/**

+ * A paint event has occurred. Display the invalidated items.

+ * @param event - expose event specifying the invalidated area.

+ */

+void paint(Event event) {

+	int visibleRange[] = getIndexRange(event.getBounds());

+	

+	paintItems(event.gc, visibleRange[0], visibleRange[1] + 1); // + 1 to paint the vertical line 

+																// connection the last item we really 

+																// want to paint with the item after that.

+}

+/**

+ * Paint tree items on 'gc' starting at index 'topPaintIndex' and 

+ * stopping at 'bottomPaintIndex'.

+ * @param gc - GC to draw tree items on.

+ * @param topPaintIndex - index of the first item to draw

+ * @param bottomPaintIndex - index of the last item to draw 

+ */

+void paintItems(GC gc, int topPaintIndex, int bottomPaintIndex) {

+	TreeItem visibleItem;

+	int itemHeight = getItemHeight();

+

+	for (int i = topPaintIndex; i <= bottomPaintIndex; i++) {

+		visibleItem = getRoot().getVisibleItem(i + getTopIndex());

+		if (visibleItem != null) {

+			visibleItem.paint(gc, i * itemHeight);

+		}

+	}

+}

+/**

+ * 'item' has been added to or removed from the receiver. 

+ * Repaint part of the tree to update the vertical hierarchy 

+ * connectors and hierarchy image.

+ * @param modifiedItem - the added/removed item 

+ * @param modifiedIndex - index of the added/removed item

+ */

+void redrawAfterModify(SelectableItem modifiedItem, int modifiedIndex) {

+	int redrawStartY;

+	int redrawStopY;

+	int itemChildIndex = ((TreeItem) modifiedItem).getIndex();

+	int topIndex = getTopIndex();

+	int itemHeight = getItemHeight();

+	int redrawItemIndex;

+	int itemCount;

+	AbstractTreeItem parentItem = ((TreeItem) modifiedItem).getParentItem();

+	AbstractTreeItem redrawItem = null;

+

+	if (redrawParentItem(modifiedItem) == false) {

+		return;

+	}

+	if (parentItem == null) {							// a root item is added/removed

+		parentItem = getRoot();

+	}

+	itemCount = parentItem.getItemCount();

+	// redraw hierarchy decorations of preceeding item if the last item at a tree 

+	// level was added/removed

+	// otherwise, if the first item was removed, redraw the parent to update hierarchy icon

+	if (itemChildIndex > 0) {							// more than one item left at this tree level

+		// added/removed last item at this tree level? have to test >=.

+		// when removing last item, item index is outside itemCount 

+		if (itemChildIndex >= itemCount - 1) { 

+			redrawItem = (AbstractTreeItem) parentItem.getChildren().elementAt(itemChildIndex - 1);

+		}

+	}

+	else 

+	if (getVisibleItemCount() > 0 && itemCount < 2) {	// last item at this level removed/first item added?

+		redrawItem = parentItem;						// redraw parent item to update hierarchy icon

+	}

+	if (redrawItem != null) {

+		redrawItemIndex = redrawItem.getVisibleIndex();

+		if (modifiedIndex == -1) {

+			modifiedIndex = redrawItemIndex + 1;

+		}

+		redrawStartY = (redrawItemIndex - topIndex) * itemHeight;

+		redrawStopY = (modifiedIndex - topIndex) * itemHeight;

+		redraw(

+			0, 

+			redrawStartY, 

+			redrawItem.getCheckboxXPosition(), 			// only redraw up to and including hierarchy icon to avoid flashing

+			redrawStopY - redrawStartY, false);

+	}	

+	if (modifiedIndex == 0) {											// added/removed first item ?

+		redraw(0, 0, getClientArea().width, getItemHeight() * 2, false);// redraw new first two items to 

+																		// fix vertical hierarchy line

+	}

+}

+

+/**

+ * Determine if part of the tree hierarchy needs to be redrawn.

+ * The hierarchy icon of the parent item of 'item' needs to be redrawn if 

+ * 'item' is added as the first child or removed as the last child.

+ * Hierarchy lines need to be redrawn if 'item' is the last in a series of 

+ * children.

+ * @param item - tree item that is added or removed.

+ * @return true=tree hierarchy needs to be redrawn. false=no redraw necessary

+ */

+boolean redrawParentItem(SelectableItem item) {

+	TreeItem parentItem = ((TreeItem) item).getParentItem();

+	TreeItem parentItem2; 

+	boolean redraw = false;

+

+	// determine if only the hierarchy icon needs to be redrawn

+	if (parentItem != null) {

+		parentItem2 = parentItem.getParentItem();

+		if ((parentItem2 == null || parentItem2.getExpanded() == true) && parentItem.getChildren().size() < 2) {

+			redraw = true;

+		}

+	}

+	// redraw is only neccessary when the receiver is not currently	

+	// expanding 'item' or a parent item or if the parent item is expanded 

+	// or if the hierarchy icon of the parent item needs to be redrawn

+	if (isExpandingItem(item) == false && parentItem == null || parentItem.getExpanded() == true || redraw == true) {

+		redraw = true;

+	}

+	else {

+		redraw = false;

+	}

+	return redraw;

+}

+

+/**
+ * Removes all of the items from the receiver.
+ * <p>
+ * @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 removeAll() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	setRedraw(false);

+	getRoot().dispose();

+	resetRoot();

+	reset();

+	calculateWidestShowingItem();

+	calculateVerticalScrollbar();

+	setRedraw(true);	

+}

+/** 

+ * Remove 'item' from the receiver. 

+ * @param item - tree item that should be removed from the 

+ *	receiver-must be a root item.

+ */

+void removeItem(TreeItem item) {

+	getRoot().removeItem(item);

+}

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's selection changes.
+ *
+ * @param listener the listener which should no longer 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 SelectionListener
+ * @see #addSelectionListener
+ */

+public void removeSelectionListener(SelectionListener listener) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (listener == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}	

+	removeListener (SWT.Selection, listener);

+	removeListener (SWT.DefaultSelection, listener);	

+}

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when items in the receiver are expanded or collapsed..
+ *
+ * @param listener the listener which should no longer 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 TreeListener
+ * @see #addTreeListener
+ */

+public void removeTreeListener(TreeListener listener) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (listener == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	removeListener (SWT.Expand, listener);

+	removeListener (SWT.Collapse, listener);

+}

+/**

+ * 'item' has been removed from the receiver. 

+ * Recalculate the content width.

+ */

+void removedItem(SelectableItem item) {

+	if (isExpandingItem(item) == false) {

+		super.removedItem(item);				

+	}	

+	calculateWidestShowingItem();

+	claimRightFreeSpace();

+}

+/**

+ * Notification that 'item' is about to be removed from the tree.

+ * Update the item selection if neccessary.

+ * @param item - item that is about to be removed from the tree.

+ */

+void removingItem(SelectableItem item) {

+	Vector selection = getSelectionVector();

+	TreeItem parentItem = ((TreeItem) item).getParentItem();

+	TreeItem newSelectionItem = null;

+	boolean isLastSelected = (selection.size() == 1) && (selection.elementAt(0) == item);

+	int itemIndex = getVisibleIndex(item);

+	

+	if (isLastSelected == true) {

+		// try selecting the following item

+		newSelectionItem = (TreeItem) getVisibleItem(itemIndex + 1);

+		if (newSelectionItem == null || newSelectionItem.getParentItem() != parentItem) {

+			// select parent item if there is no item following the removed  

+			// one on the same tree level

+			newSelectionItem = parentItem;

+		}

+		if (newSelectionItem != null) {

+			selectNotify(newSelectionItem, true);

+		}

+	}

+	super.removingItem(item);

+	if (isExpandingItem(item) == false) {

+		// redraw plus/minus image, hierarchy lines,

+		// redrawing here assumes that no update happens between now and 

+		// after the item has actually been removed. Otherwise this call 

+		// would need to be in removedItem and we would need to store the

+		// "itemIndex" here to redraw correctly.

+		redrawAfterModify(item, itemIndex);

+	}	

+}

+/**

+ * Reset the rectangle enclosing the hierarchy indicator to null.

+ * Forces a recalculation next time getHierarchyIndicatorRect is called.

+ */

+void resetHierarchyIndicatorRect() {

+	hierarchyIndicatorRect = null;

+}

+/**

+ * Reset state that is dependent on or calculated from the items

+ * of the receiver.

+ */

+void resetItemData() {

+	setContentWidth(0);

+	resetHierarchyIndicatorRect();	

+	super.resetItemData();	

+}

+/**

+ * Reset the object holding the root items of the receiver.

+ */

+void resetRoot() {

+	root = new TreeRoots(this);

+}

+/**

+ * The receiver has been resized. Recalculate the content width.

+ */

+void resize(Event event) {

+	int oldItemCount = getVerticalBar().getPageIncrement();

+

+	super.resize(event);

+	if (getItemCountWhole() > oldItemCount) {		// window resized higher?

+		calculateWidestShowingItem();				// recalculate widest item since a longer item may be visible now

+	}

+}

+/**

+ * Display as many expanded tree items as possible.

+ * Scroll the last expanded child to the bottom if all expanded 

+ * children can be displayed.

+ * Otherwise scroll the expanded item to the top.

+ * @param item - the tree item that was expanded

+ */

+void scrollExpandedItemsIntoView(TreeItem item) {

+	int itemCountOffScreen = getOffScreenItemCount(item);

+	int newTopIndex = getTopIndex() + itemCountOffScreen;

+

+	if (itemCountOffScreen > 0) {

+		newTopIndex = Math.min(item.getVisibleIndex(), newTopIndex);	// make sure the expanded item is never scrolled out of view

+		setTopIndex(newTopIndex, true);								

+	}

+}

+/**

+ * Scroll the items following the children of 'collapsedItem'

+ * below 'collapsedItem' to cover the collapsed children.

+ * @param collapsedItem - item that has been collapsed

+ */

+void scrollForCollapse(TreeItem collapsedItem) {

+	Rectangle clientArea = getClientArea();	

+	int topIndex = getTopIndex();

+	int itemCount = collapsedItem.getVisibleItemCount();

+	int scrollYPositions[] = calculateChildrenYPos(collapsedItem);

+

+	if (scrollYPositions[0] == -1 && scrollYPositions[1] == -1) {

+		return;

+	}

+	if (topIndex + getItemCountWhole() == getVisibleItemCount() && itemCount < topIndex) {

+		// scroll from top if last item is at bottom and will stay at 

+		// bottom after collapse. Avoids flash caused by too much bit 

+		// blitting (which force update and thus premature redraw)

+		int height = scrollYPositions[1] - scrollYPositions[0];

+		scroll(

+			0, 0,					// destination x, y

+			0, -height,				// source x, y		

+			clientArea.width, scrollYPositions[0]+height, true);

+		setTopIndexNoScroll(topIndex - itemCount, true);

+	}	

+	else {

+		scroll(

+			0, scrollYPositions[0],				// destination x, y

+			0, scrollYPositions[1],				// source x, y		

+			clientArea.width, clientArea.height - scrollYPositions[0], true);

+	}

+}

+/**

+ * Scroll the items following 'expandedItem' down to make 

+ * space for the children of 'expandedItem'.

+ * @param expandedItem - item that has been expanded.

+ */

+void scrollForExpand(TreeItem expandedItem) {

+	int scrollYPositions[];

+	Rectangle clientArea = getClientArea();

+

+	expandedItem.internalSetExpanded(true);		

+	scrollYPositions = calculateChildrenYPos(expandedItem);	

+	expandedItem.internalSetExpanded(false);	

+	if (scrollYPositions[0] == -1 && scrollYPositions[1] == -1) {

+		return;

+	}	

+	scroll(

+		0, scrollYPositions[1],				// destination x, y

+		0, scrollYPositions[0],				// source x, y

+		clientArea.width, clientArea.height, true);

+}

+/**

+ * Scroll horizontally by 'numPixel' pixel.

+ * @param numPixel - the number of pixel to scroll

+ *	< 0 = columns are going to be moved left.

+ *	> 0 = columns are going to be moved right.

+ */

+void scrollHorizontal(int numPixel) {

+	Rectangle clientArea = getClientArea();

+

+	scroll(

+		numPixel, 0, 								// destination x, y

+		0, 0, 										// source x, y

+		clientArea.width, clientArea.height, true);

+}

+/**

+ * Scroll vertically by 'scrollIndexCount' items.

+ * @param scrollIndexCount - the number of items to scroll.

+ *	scrollIndexCount > 0 = scroll up. scrollIndexCount < 0 = scroll down

+ */

+void scrollVertical(int scrollIndexCount) {

+	Rectangle clientArea = getClientArea();

+

+	scroll(

+		0, 0, 										// destination x, y

+		0, scrollIndexCount * getItemHeight(),		// source x, y

+		clientArea.width, clientArea.height, true);

+}

+/**
+ * Selects all the items in the receiver.
+ *
+ * @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 selectAll() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector selection = getSelectionVector();

+

+	if (isMultiSelect() == true) {

+		selection = getRoot().selectAll(selection);

+		setSelectionVector(selection);

+	}

+}

+/**

+ * Set the item that is currently being expanded to 'item'.

+ * Used for performance optimizations.

+ */

+void setExpandingItem(TreeItem item) {

+	expandingItem = item;

+}

+public void setFont(Font font) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Stack children = new Stack();						// traverse the tree depth first

+	Enumeration elements;

+	AbstractTreeItem item;

+

+	if (font != null && font.equals(getFont()) == true) {

+		return;

+	}

+	setRedraw(false);									// disable redraw because itemChanged() triggers undesired redraw

+	resetItemData();	

+	super.setFont(font);

+

+	// Call itemChanged for all tree items

+	elements = getRoot().getChildren().elements();

+	while (elements.hasMoreElements() == true) {

+		children.push(elements.nextElement());

+	}			

+	while (children.empty() == false) {

+		item = (AbstractTreeItem) children.pop();

+		itemChanged(item, 0, getClientArea().width);

+		elements = item.getChildren().elements();

+		while (elements.hasMoreElements() == true) {

+			children.push(elements.nextElement());

+		}			

+	}

+	setRedraw(true);									// re-enable redraw

+}

+/**
+ * Display a mark indicating the point at which an item will be inserted.
+ * The drop insert item has a visual hint to show where a dragged item 
+ * will be inserted when dropped on the tree.
+ * 
+ * @param item the insert item.  Null will clear the insertion mark.
+ * @param after true places the insert mark above 'item'. false places 
+ *	the insert mark below 'item'.
+ *
+ * @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 setInsertMark(TreeItem item, boolean before){

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	motif_setInsertMark(item, !before);

+}

+/**
+ * Sets the receiver's selection to be the given array of items.
+ * The current selected is first cleared, then the new items are
+ * selected.
+ *
+ * @param items the array of items
+ *
+ * @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 Tree#deselectAll()
+ */

+public void setSelection(TreeItem selectionItems[]) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	if (selectionItems == null)  {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}	

+	setSelectableSelection(selectionItems);

+}

+/**

+ * Set the index of the first visible item in the tree client area 

+ * to 'index'.

+ * Scroll the new top item to the top of the tree.

+ * @param index - 0-based index of the first visible item in the 

+ *	tree's client area.

+ * @param adjustScrollbar - 

+ *	true = the vertical scroll bar is set to reflect the new top index.

+ *	false = the vertical scroll bar position is not modified.

+ */

+void setTopIndex(int index, boolean adjustScrollbar) {

+	int indexDiff = index-getTopIndex();

+

+	super.setTopIndex(index, adjustScrollbar);

+	calculateWidestScrolledItem(indexDiff);

+}

+/**
+ * Shows the item.  If the item is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled
+ * and expanded until the item is visible.
+ *
+ * @param item the item to be shown
+ *
+ * @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 Tree#showSelection()
+ */

+public void showItem(TreeItem item) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (item == null)  {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}	

+	showSelectableItem(item);

+}

+/**

+ * Make 'item' visible by expanding its parent items and scrolling 

+ * it into the receiver's client area if necessary.

+ * An SWT.Expand event is going to be sent for every parent item 

+ * that is expanded to make 'item' visible.

+ * @param item - the item that should be made visible to the

+ *	user.

+ */

+void showSelectableItem(SelectableItem item) {

+	if (item.getSelectableParent() != this) {

+		return;

+	}

+	if (((TreeItem) item).isVisible() == false) {

+		((TreeItem) item).makeVisible();

+	}

+	super.showSelectableItem(item);

+}

+/**
+ * Returns the item at the given point in the receiver
+ * or null if no such item exists. The point is in the
+ * coordinate system of the receiver.
+ *
+ * @param point the point used to locate the item
+ * @return the item at the given point
+ *
+ * @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>
+ */

+public TreeItem getItem(Point point) {

+	int itemHeight;

+	int hitItemIndex;

+	TreeItem hitItem;

+

+	if (getClientArea().contains(point) == false) {

+		return null;

+	}	

+	itemHeight = getItemHeight();

+	hitItemIndex = point.y / itemHeight;

+	hitItem = getRoot().getVisibleItem(hitItemIndex + getTopIndex());

+	if (hitItem != null) {

+		point.x -= hitItem.getPaintStartX();

+		point.y -= itemHeight * hitItemIndex;			

+		if (hitItem.isSelectionHit(point) == false) {

+			hitItem = null;

+		}

+	}

+	return hitItem;

+}

+/**
+ * Returns the number of selected items contained in the receiver.
+ *
+ * @return the number of selected items
+ *
+ * @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 getSelectionCount() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return super.getSelectionCount();

+}

+/**
+ * Shows the selection.  If the selection is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled until
+ * the selection is visible.
+ *
+ * @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 Tree#showItem(TreeItem)
+ */

+public void showSelection() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	super.showSelection();

+}

+

+}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TreeItem.java
new file mode 100755
index 0000000..e19494c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TreeItem.java
@@ -0,0 +1,1198 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+ 

+import org.eclipse.swt.*;

+import org.eclipse.swt.graphics.*;

+import java.util.*;

+ 

+/**
+ * Instances of this class represent a selectable user interface object
+ * that represents a hierarchy of tree items in a tree widget.
+ * 
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */

+public /*final*/ class TreeItem extends AbstractTreeItem {

+/*

+ * This class caches geometric data for drawing.

+ * A description of the cached data follows:

+ *

+ *  |      1    ||      5        |  

+ *  |  2  |               |   6  |   

+ *  |3                          7|  

+ *   _____  | 4 |f|          |8      

+ *  |     |                            ____

+ *  |  -  | ===== {image}    root      9

+ *  |_____|          |

+ *                       |b|c|  |d|

+ *               | e |

+ * 

+ * Widths are measured between vertical lines.

+ *

+ * Cached item rendering data:

+ * 1 = getDecorationsWidth

+ * 2 = getHierarchyIndicatorRect

+ * 3 = getPaintStartX

+ * 4 = getItemConnectorWidth

+ * 5 = getItemWidth

+ * 6 = getSelectionWidth

+ * 7 = getPaintStopX

+ * 8 - getTextXPos

+ * 9 = getTextYPosition

+ *

+ * Rendering constants:

+ * 4 = DEFAULT_ITEM_CONNECTOR_WIDTH, used when no image is set in the tree.

+ *	Otherwise it is the image width.

+ * b = IMAGE_PADDING

+ * c = TEXT_INDENT

+ * d = SELECTION_PADDING

+ * e = ITEM_NOIMAGE_OFFSET

+ * f = ITEM_CONNECTOR_PADDING;

+ */

+	private static final int DEFAULT_ITEM_CONNECTOR_WIDTH = 8;	// Default width of the horizontal line connecting 

+															// items with the vertical lines. Only used when

+															// no image is set in the tree. Normally connector 

+															// line width is half the image width.

+	private static final int ITEM_CONNECTOR_PADDING = 2;	// Added to the calculated item connector width

+	private static final int IMAGE_PADDING = 3;				// Space behind bitmap

+	private static final int ITEM_NOIMAGE_OFFSET = 8;		// Offset added to the calculated paint position where 

+															// an item starts drawing. To be used when no item 

+															// image has been set. Otherwise children would start 

+															// drawing at the end of the horizontal item connector 

+															// of their parent.

+	private static final int ROOT_INDENT = 5;				// Indent of root items

+	private static final int SELECTION_PADDING = 2;			// Space behind text

+	private static final int TEXT_INDENT = 2;				// Identation of the item label

+	

+	// basic item info

+	private TreeItem parentItem;

+	private int index;										// index in the parent item

+	

+	// geometrical item info

+	private int paintStartX = -1;							// X coordinate of the upper-left corner of the 

+															// receivers bounding rectangle

+	private Point itemExtent;								// Size of the item (image + label)

+	private Point imageExtent;								// original size of the item image	

+	private int textYPosition = -1;							// Centered y position of the item text	

+/**

+ * Create a root item and add it to the tree widget identified

+ * by 'parent'.

+ * @param parent - Tree widget the receiver is added to

+ * @param swtStyle - widget style. see Widget class for details

+ */

+public TreeItem(Tree parent, int swtStyle) {

+	this(parent, swtStyle, checkNull(parent).getItemCount());

+}

+/**

+ * Create a root item and add it to the tree widget identified

+ * by 'parent'.

+ * @param parent - Tree widget the receiver is added to.

+ * @param swtStyle - widget style. see Widget class for details

+ * @param position - position in 'parentItem' the receiver will 

+ *	be inserted at 

+ */

+public TreeItem(Tree parent, int swtStyle, int position) {

+	super(parent, swtStyle);

+	parent.addItem(this, position);

+}

+/**

+ * Create a root item with 'parentItem' as the parent item.

+ * @param parentItem - the parent item of the receiver

+ * @param swtStyle - widget style. see Widget class for details

+ */

+public TreeItem(TreeItem parentItem, int swtStyle) {

+	this(parentItem, swtStyle, checkNull(parentItem).getItemCount());

+}

+/**

+ * Create a root item with 'parentItem' as the parent item.

+ * @param parentItem - the parent item of the receiver

+ * @param swtStyle - widget style. see Widget class for details

+ * @param position - position in 'parentItem' the receiver will 

+ *	be inserted at 

+ */

+public TreeItem(TreeItem parentItem, int swtStyle, int position) {

+	super(checkNull(parentItem).getParent(), swtStyle);

+	setParentItem(parentItem);	

+	parentItem.add(this, position);

+}

+/**

+ * Calculate the number of expanded children.

+ * Recurse up in the tree to the root item.

+ */

+void calculateVisibleItemCount() {

+	Vector children;

+	TreeItem child;

+	int visibleItemCount = 0;

+	

+	// check isExpanded field directly for performance

+	if (internalGetExpanded() == true) {

+		children = getChildren();

+		visibleItemCount = children.size();

+		for (int i = 0; i < children.size(); i++) {

+			child = (TreeItem) children.elementAt(i);

+			visibleItemCount += child.getVisibleItemCount();

+		}

+	}

+	setVisibleItemCount(visibleItemCount);

+	calculateVisibleItemCountParent();

+}

+/**

+ * Calculate the number of expanded children for the parent item

+ * of this item.

+ */

+void calculateVisibleItemCountParent() {

+	TreeItem parentItem = getParentItem();

+

+	if (parentItem != null) {

+		parentItem.calculateVisibleItemCount();

+	}

+	else {

+		getParent().getRoot().calculateVisibleItemCount();

+	}

+}

+/**

+ * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'tree' is null.

+ * Otherwise return 'tree'

+ */

+static Tree checkNull(Tree tree) {

+	if (tree == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

+	return tree;

+}

+/**

+ * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'item' is null.

+ * Otherwise return 'item'

+ */

+static TreeItem checkNull(TreeItem item) {

+	if (item == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

+	return item;

+}

+protected void checkSubclass () {

+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);

+}

+

+/**

+ * Draw the hierarchy indicator at 'position'.

+ *

+ * Note:

+ * Assumes that the hierarchy indicators for the expanded and 

+ * collapsed state are the same size.

+ * @param gc - GC to draw on. 

+ * @param position - position on the GC to draw at.

+ * @return position to continue drawing 

+ */

+Point drawHierarchyIndicator(GC gc, Point position) {

+	Tree parent = getParent();

+	Image hierarchyImage;

+	Rectangle indicatorRectangle = parent.getHierarchyIndicatorRect();

+	int x = position.x;

+	int y = position.y;

+	int yCenter = y + parent.getItemHeight() / 2;

+	Point connectorLinePosition;	

+

+	if (isLeaf() == false) {

+		if (getExpanded() == true) {

+			hierarchyImage = parent.getExpandedImage();

+		}

+		else {

+			hierarchyImage = parent.getCollapsedImage();

+		}

+		if (hierarchyImage != null) {

+			gc.drawImage(hierarchyImage, x + indicatorRectangle.x, y + indicatorRectangle.y);

+		}

+		connectorLinePosition = new Point(x + indicatorRectangle.width, yCenter);		

+	}	

+	else {

+		connectorLinePosition = new Point(

+			x + indicatorRectangle.width / 2 				

+			+ indicatorRectangle.width % 2, yCenter);		// % 2 in order to not start the next hierarchy 

+															// component at the middle of the icon but after.	

+	}

+	return connectorLinePosition;

+}

+/**

+ * Draw a horizontal line connecting the item image (or label 

+ * if there is no image) to the vertical line connecting to 

+ * the parent.

+ * @param gc - GC to draw on. 

+ * @param position - position on the GC to draw at.

+ * @return position to continue drawing 

+ */

+Point drawHorizontalItemConnector(GC gc, Point position) {

+	int itemConnectorEndPos = position.x + getItemConnectorWidth() - 1;	// -1 because the position of the last pixel needs to be calculated

+

+	gc.drawLine(position.x, position.y, itemConnectorEndPos, position.y);

+	return new Point(itemConnectorEndPos + 1, position.y);		// + 1 in order to resume drawing after line not on end of line

+}

+/** 

+ * Display the item image at 'position' using 'gc'.

+ * @param gc - GC to draw on

+ * @param position - position on the GC to draw at

+ * @return position to continue drawing 

+ */

+Point drawImage(GC gc, Point destinationPosition) {

+	Tree parent = getParent();

+	Image image = getImage();

+	Point sourceImageExtent;

+	Point destinationImageExtent = parent.getImageExtent();

+	int yCenter;

+	

+	if (image != null) {

+		sourceImageExtent = getImageExtent();

+		yCenter = (parent.getItemHeight() - destinationImageExtent.y) / 2;

+		gc.drawImage(

+			image, 

+			0, 0, 														// source x, y

+			sourceImageExtent.x, sourceImageExtent.y,					// source width, height

+			destinationPosition.x, destinationPosition.y + yCenter,		// destination x, y

+			destinationImageExtent.x, destinationImageExtent.y);		// destination width, height

+	}

+	if (destinationImageExtent != null) {

+		destinationPosition.x += destinationImageExtent.x + IMAGE_PADDING;

+	}

+	return destinationPosition;

+}

+/**

+ * Draw a filled rectangle indicating the item selection state

+ * The rectangle will be filled with the selection color if the 

+ * receiver is selected. Otherwise the rectangle will be filled

+ * in the background color to remove the selection.

+ * @param gc - GC to draw on. 

+ * @param position - position on the GC to draw at.

+ */

+void drawSelection(GC gc, Point position) {

+	Tree parent = getParent();

+	Point selectionExtent = getSelectionExtent();

+

+	if (selectionExtent == null) {

+		return;

+	}

+	if (isSelected() == true) {

+		gc.setBackground(getSelectionBackgroundColor());

+	}

+	gc.fillRectangle(position.x, position.y, selectionExtent.x, selectionExtent.y);

+	if (isSelected() == true) {

+		gc.setBackground(parent.getBackground());

+	}

+}

+/**

+ * Draw a rectangle enclosing the item label. The rectangle

+ * indicates that the receiver was selected last and that it has

+ * the input focus.

+ * The rectangle will only be drawn if the receiver is selected.

+ * @param gc - GC to draw on. 

+ * @param position - position on the GC to draw at.

+ */

+void drawSelectionFocus(GC gc, Point position) {

+	Point selectionExtent = getSelectionExtent();

+

+	if (selectionExtent == null) {

+		return;

+	}

+	if (getParent().hasFocus(this) == true) {

+		gc.drawFocus(

+			position.x, position.y, 

+			selectionExtent.x, selectionExtent.y);

+	}

+}

+/** 

+ * Draw the item label at 'position' using 'gc'.

+ * @param gc - GC to draw on. 

+ * @param position - position on the GC to draw at.

+ */

+void drawText(GC gc, Point position) {

+	Tree parent = getParent();

+	String text = getText();

+	

+	if (text != null) {

+		if (isSelected() == true) {

+			gc.setBackground(getSelectionBackgroundColor());

+			gc.setForeground(getSelectionForegroundColor());

+		}

+		gc.drawString(text, position.x, position.y);

+		if (isSelected() == true) {

+			gc.setBackground(parent.getBackground());

+			gc.setForeground(parent.getForeground());

+		}

+	}

+}

+/**

+ * Draw a vertical line connecting the horizontal connector line 

+ * with that of the previous item.

+ * Called recursively to draw the lines on all tree levels.

+ * @param gc - GC to draw on. 

+ * @param yPosition - y position of the upper side of the 

+ *	receiver's bounding box.

+ * @param isFirstChild - method is called to draw a vertical 

+ *	line for the first child. Leave room for the hierarchy icon.

+ */

+void drawVerticalItemConnector(GC gc, int yPosition, boolean isFirstChild) {

+	Tree parent = getParent();

+	TreeItem nextDrawItem = getParentItem();

+	AbstractTreeItem parentItem = nextDrawItem;

+	Rectangle indicatorRectangle = parent.getHierarchyIndicatorRect();

+	int itemHeight = parent.getItemHeight();	

+	int itemHeightDiv2 = itemHeight / 2 + itemHeight % 2;

+	int indicatorHeightDiv2 = indicatorRectangle.height / 2 + indicatorRectangle.height % 2;

+	int lineX = getPaintStartX() + indicatorRectangle.width / 2;

+	int lineStartY = yPosition - itemHeightDiv2;	

+	int lineEndY = yPosition + itemHeightDiv2;

+

+	if (parentItem == null) {

+		parentItem = parent.getRoot();

+	}

+	if (getIndex() != parentItem.getItemCount()-1) {		// if item is not the last child

+		if (isFirstChild == true) {

+			lineStartY += indicatorHeightDiv2;				// leave space for the hierarchy image

+		}	

+		gc.drawLine(lineX, lineStartY, lineX, lineEndY);

+	}

+	

+	if (nextDrawItem != null) {

+		nextDrawItem.drawVerticalItemConnector(gc, yPosition, false);

+	}	

+}

+/**

+ * Draw a vertical line connecting the horizontal connector line

+ * with that of the previous item.

+ * Do this on all tree levels up to the root level.

+ * @param gc - GC to draw on. 

+ * @param position - position on the GC to draw at.

+ * @return position to continue drawing 

+ */

+Point drawVerticalItemConnector(GC gc, Point position) {

+	Tree parent = getParent();

+	TreeItem parentItem = getParentItem();	

+	Rectangle indicatorRectangle = parent.getHierarchyIndicatorRect();

+	int itemHeight = parent.getItemHeight();

+	int itemHeightDiv2 = itemHeight / 2 + itemHeight % 2;

+	int indicatorHeightDiv2 = indicatorRectangle.height / 2 + indicatorRectangle.height % 2;

+	int lineX = position.x + indicatorRectangle.width / 2;

+	int lineStartY = position.y - itemHeightDiv2;	

+	int lineEndY = position.y + itemHeightDiv2 - itemHeight % 2;

+	TreeItem predecessor;

+	boolean isFirstChild = false;

+

+	if (isRoot() == true) {

+		if (getIndex() == 0) {

+			return position;									// first root, don't draw vertical line

+		}

+	}

+	else	

+	if (getIndex() == 0) {										// if item is first child

+		lineStartY += itemHeightDiv2;

+		isFirstChild = true;

+	}

+	predecessor = getPredecessor();

+	if (predecessor != null && predecessor.isLeaf() == false) {

+		lineStartY += indicatorHeightDiv2;						// leave space for the hierarchy image

+	}

+	if (isLeaf() == false) {

+		lineEndY -= indicatorHeightDiv2;

+	}

+	gc.drawLine(lineX, lineStartY, lineX, lineEndY);

+	if (parentItem != null) {

+		parentItem.drawVerticalItemConnector(gc, position.y, isFirstChild);

+	}

+	return position;

+}

+

+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent.
+ *
+ * @return the receiver's bounding 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() {

+	if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);

+	Tree parent = getParent();

+	Point extent = getItemExtent();

+	int x = getTextXPos() - TEXT_INDENT;

+	

+	return new Rectangle(x, parent.getRedrawY(this), extent.x - (x - getItemStartX()), extent.y);	

+}

+

+/**

+ * Answer the x position of the item check box

+ */

+int getCheckboxXPosition() {

+	return getPaintStartX() + getDecorationsWidth();

+}

+/**

+ * Answer the combined width of the hierarchy indicator and 

+ * the horizontal item connector line.

+ */

+int getDecorationsWidth() {

+	int indicatorWidth = getParent().getHierarchyIndicatorRect().width;

+	int width = indicatorWidth + getItemConnectorWidth();

+

+	if (isLeaf() == true) {

+		width -= indicatorWidth / 2;

+	}

+	return width;

+}

+/**

+ * Answer the index of the receiver relative to the first root 

+ * item.

+ * @return

+ *	The index of the receiver relative to the first root item.

+ */

+int getGlobalIndex() {

+	int globalItemIndex = getIndex();

+	AbstractTreeItem item = null;

+

+	if (isRoot() == false) {

+		item = getParentItem();

+		globalItemIndex++;						// adjust for 0-based non-root items

+	}

+	else {	

+		item = getParent().getRoot();

+	}

+

+	globalItemIndex += item.getVisibleIndex(getIndex());

+	return globalItemIndex;

+}

+/**

+ * Answer the original size of the image of the receiver.

+ */

+Point getImageExtent() {

+	Image image = getImage();

+	Rectangle imageBounds;

+	

+	if (imageExtent == null && image != null) {

+		imageBounds = image.getBounds();

+		imageExtent = new Point(imageBounds.width, imageBounds.height);

+	}

+	return imageExtent;

+}

+/**

+ * Answer the receiver's index into its parent's list of children

+ */

+int getIndex() {

+	return index;

+}

+/**

+ * Answer the width of the horizontal item connector line.

+ */

+int getItemConnectorWidth() {

+	Tree parent = getParent();

+	Point imageExtent = parent.getImageExtent();

+	int itemConnectorWidth;

+	int indicatorWidth = parent.getHierarchyIndicatorRect().width;

+

+	if (imageExtent != null) {

+		itemConnectorWidth = imageExtent.x / 2 + ITEM_CONNECTOR_PADDING;

+	}

+	else {

+		itemConnectorWidth = DEFAULT_ITEM_CONNECTOR_WIDTH;

+	}

+	if (isLeaf() == false) {	// has children = has hierarchy indicator = shorter connector

+		itemConnectorWidth -= indicatorWidth / 2;

+	}

+	return itemConnectorWidth;

+}

+/**
+ * Returns the number of items contained in the receiver
+ * that are direct item children of the receiver.
+ *
+ * @return the number of items
+ *
+ * @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 getItemCount() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return super.getItemCount();

+}

+/**

+ * Answer the size of the receiver as displayed on the screen.

+ */

+Point getItemExtent() {

+	Tree parent;

+	Point imageExtent;

+	String text;

+	int itemWidth;

+	

+	if (itemExtent == null) {

+		parent = getParent();

+		imageExtent = parent.getImageExtent();

+		text = getText();

+		itemWidth = SELECTION_PADDING;

+		if (text != null) {

+			itemWidth += parent.getTextWidth(text) + TEXT_INDENT;

+		}

+		if (imageExtent != null) {

+			itemWidth += imageExtent.x + IMAGE_PADDING;

+		}

+		itemExtent = new Point(itemWidth, parent.getItemHeight());

+	}

+	return itemExtent;

+}

+/**

+ * Answer the x position at which painting of the receiver's 

+ * contents (ie. image, text) can begin.

+ */

+int getItemStartX() {

+	int itemStartX = getPaintStartX() + getDecorationsWidth();

+	

+	if (isCheckable() == true) {

+		itemStartX += getCheckboxBounds().width + CHECKBOX_PADDING;

+	}

+	return itemStartX;

+}

+/**
+ * Returns an array of <code>TreeItem</code>s which are the
+ * direct item children of the receiver.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the receiver's items
+ *
+ * @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 TreeItem [] getItems() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	TreeItem childrenArray[] = new TreeItem[getItemCount()];

+

+	getChildren().copyInto(childrenArray);

+	return childrenArray;	

+}

+/**

+ * Answer the x position where the receiver is drawn.

+ */

+int getPaintStartX() {

+	Tree parent = getParent();

+	Point imageExtent;

+	TreeItem parentItem;

+

+	if (paintStartX == -1) {

+		if (isRoot() == true) {

+			paintStartX = ROOT_INDENT;

+		}

+		else {

+			parentItem = getParentItem();

+			// subtract parent.getHorizontalOffset() to calculate the cached start 

+			// position independent of the horizontal scroll offset. Fixes 1G1L7EU.

+			paintStartX = parentItem.getPaintStartX() 

+				- parent.getHorizontalOffset()	

+				+ parentItem.getDecorationsWidth()

+				- parent.getHierarchyIndicatorRect().width / 2;

+			imageExtent = parent.getImageExtent();

+			if (imageExtent != null) {

+				paintStartX += imageExtent.x / 2;

+			}

+			else {

+				paintStartX += ITEM_NOIMAGE_OFFSET;

+			}

+		}

+	}

+	return paintStartX + parent.getHorizontalOffset();

+}

+/**

+ * Answer the pixel at which the receiver stops drawing.

+ */

+int getPaintStopX() {

+	return (getItemStartX() + getItemExtent().x - getParent().getHorizontalOffset());

+}

+/**
+ * Returns the receiver's parent, which must be a <code>Tree</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @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 Tree getParent() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return (Tree) super.getSelectableParent();

+}

+/**
+ * Returns the receiver's parent item, which must be a
+ * <code>TreeItem</code> or null when the receiver is a
+ * root.
+ *
+ * @return the receiver's parent item
+ *
+ * @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 TreeItem getParentItem() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return parentItem;

+}

+/**

+ * Answer the item that directly precedes the receiver.

+ * Answer null if this is the first item in a hierarchy level

+ * or if there are expanded children in the previous item.

+ */

+TreeItem getPredecessor() {

+	AbstractTreeItem parentItem = getParentItem();

+	Vector children;

+	int previousIndex = getIndex() - 1;

+	TreeItem previousItem = null;

+

+	if (parentItem == null) {

+		parentItem = getParent().getRoot();

+	}

+	if (previousIndex >= 0) {

+		children = parentItem.getChildren();

+		previousItem = (TreeItem) children.elementAt(previousIndex);

+		if (previousItem.isLeaf() == false && previousItem.getExpanded() == true) {

+			previousItem = null;	// no immediate predecessor because there are expanded children

+		}

+	}

+	return previousItem;	

+}

+/**

+ * Answer the size of the rectangle drawn to indicate the

+ * selected state of the receiver.

+ * This is also used to draw the selection focus rectangle.

+ */

+Point getSelectionExtent() {

+	Point selectionExtent = getItemExtent();

+	Point imageExtent = getParent().getImageExtent();

+	int x = selectionExtent.x;

+

+	if (imageExtent != null) {

+		x -= imageExtent.x + IMAGE_PADDING;

+	}

+	return new Point(x, selectionExtent.y);

+}

+/**

+ * Return the x position of the selection rectangle

+ */

+int getSelectionX() {

+	return getTextXPos() - TEXT_INDENT;

+}

+/**

+ * Answer the x position where the receiver draws the item text.

+ * This position is relative to the item start position.

+ */

+int getTextXPos() {

+	Point imageExtent = getParent().getImageExtent();

+	int textXPos = getItemStartX() + TEXT_INDENT;

+

+	if (imageExtent != null) {

+		textXPos += imageExtent.x + IMAGE_PADDING;

+	}

+	return textXPos;

+}

+/**

+ * Answer the y position of the receiver's text.

+ * @param 

+ *	gc - GC to use for calculating the text y position 

+ */

+int getTextYPosition(GC gc) {

+	String text;

+

+	if (textYPosition == -1) {

+		text = getText();

+		if (text != null) {

+			textYPosition = (getParent().getItemHeight() - gc.stringExtent(text).y) / 2;

+		}

+		else {

+			textYPosition = 0;

+		}

+	}

+	return textYPosition;

+}

+/**

+ * Answer the index of the receiver relative to the first root 

+ * item.

+ * If 'anIndex' is the index of the expanded item 'anItem' 

+ * then the following expressions are true:

+ * 'anItem  == theRoot.getVisibleItem(anIndex)' and

+ * 'anIndex == anItem.getVisibleIndex()'

+ * @return

+ *	The index of the receiver relative to the first root item.

+ *	Answer -1 if the receiver is not visible (because the parent 

+ *	is collapsed).

+ */

+int getVisibleIndex() {

+	int visibleItemIndex = getIndex();

+	AbstractTreeItem item = null;

+

+	if (isRoot() == false) {

+		if (isVisible() == false) {

+			return -1;		

+		}

+		item = getParentItem();

+		visibleItemIndex++;						// adjust for 0-based non-root items

+	}

+	else {	

+		item = getParent().getRoot();

+	}

+

+	visibleItemIndex += item.getVisibleIndex(getIndex());

+	return visibleItemIndex;

+}

+/**

+ * Answer the index of the child item identified by 'childIndex' 

+ * relative to the first root item.

+ */

+int getVisibleIndex(int childIndex) {

+	Enumeration children = getChildren().elements();

+	TreeItem child;

+	int visibleItemIndex = getIndex();

+

+	if (isRoot() == false) {

+		visibleItemIndex++;									// adjust for 0-based non-root items

+	}

+

+	while (children.hasMoreElements() == true) {

+		child = (TreeItem) children.nextElement();

+		if (child.getIndex() == childIndex) {

+			if (isRoot() == false) {

+				visibleItemIndex += getParentItem().getVisibleIndex(getIndex());

+			}

+			else {

+				visibleItemIndex += getParent().getRoot().getVisibleIndex(getIndex());

+			}

+			break;

+		}

+		visibleItemIndex += child.getVisibleItemCount();		

+	}	

+	return visibleItemIndex;

+}

+/**

+ * Answer the item at 'searchIndex' relativ to the receiver.

+ * When this method is called for the root item, 'searchIndex' 

+ * represents the global index into all items of the tree.

+ * searchIndex=0 returns the receiver. 

+ * searchIndex=1 returns the first visible child.

+ * Note: searchIndex must be >= 0

+ *

+ * Note: 

+ * Visible in this context does not neccessarily mean that the 

+ * item is displayed on the screen. Visible here means that all 

+ * the parents of the item are expanded. An item is only 

+ * visible on screen if it is within the widget client area.

+ */

+TreeItem getVisibleItem(int searchIndex) {

+	TreeItem child;

+	TreeItem foundItem = null;

+	Enumeration children = getChildren().elements();

+

+	if (searchIndex == 0) {

+		return this;

+	}

+	else					

+	if (getExpanded() == false) { 		// trying to find a child when this item isn't expanded ? 

+		return null;

+	}

+

+	// Search for expanded items first. Count all subitems in the process.

+	while (children.hasMoreElements() == true && foundItem == null) {

+		child = (TreeItem) children.nextElement();

+		searchIndex--;

+		if (child.getExpanded() == true) {

+			searchIndex -= child.getVisibleItemCount();	// count children of all expanded items

+		}

+		if (searchIndex <= 0) {								// is searched item past child ?

+			// add back children of current item (that's what we want to search)			

+			foundItem = child.getVisibleItem(searchIndex + child.getVisibleItemCount());

+		}

+	}

+

+	return foundItem;

+}

+/**

+ * Answer whether 'item' is a child, direct or indirect, of the receiver.

+ * It is an indirect child if it is a child of one of the receiver's children.

+ */

+boolean isChild(TreeItem item) {

+	Vector children = getChildren();

+	TreeItem child;

+	

+	if (children.contains(item) == true) {

+		return true;

+	}

+	for (int i = 0; i < children.size(); i++) {

+		child = (TreeItem) children.elementAt(i);

+		if (child.isChild(item) == true) {

+			return true;

+		}

+	}

+	return false;

+}

+/**

+ * Answer whether the receiver is a root item.

+ * The receiver is a root item when it does not have a parent item.

+ * @return 

+ *	true - the receiver is a root item.

+ * 	false - the receiver is not a root item.

+ */

+boolean isRoot() {

+	return (getParentItem() == null);

+}

+/**

+ * Answer whether the click at 'position' on the receiver is a selection 

+ * click.

+ * @param position - location of the mouse click relative to the 

+ *	upper left corner of the receiver.

+ * @return true - receiver was clicked.

+ *	false - receiver was not clicked.

+ */

+boolean isSelectionHit(Point position) {

+	Point itemExtent = getItemExtent();

+

+	if (itemExtent == null) {		// neither image nor text have been set

+		return false;

+	}

+	return (new Rectangle(

+		getItemStartX() - getPaintStartX(), 0, 

+		itemExtent.x, itemExtent.y)).contains(position);

+}

+/**

+ * Answer whether the receiver is visible

+ * An item is visible when its parent item is visible and 

+ * expanded. Root items are always visible.

+ *

+ * Note: 

+ * Visible in this context does not neccessarily mean that the 

+ * item is displayed on the screen. Visible here means that all 

+ * the parents of the item are expanded. An item is only 

+ * visible on screen if it is within the receiver's parent's 

+ * client area.

+ * @return 

+ *	true - the receiver is visible

+ * 	false - the receiver is not visible

+ */

+boolean isVisible() {

+	boolean isVisible = true;

+	TreeItem parentItem = getParentItem();

+

+	if (isRoot() == false) {

+		isVisible = parentItem.getExpanded();

+		if (isVisible == true) {

+			isVisible = parentItem.isVisible();

+		}

+	}

+	return isVisible;		

+}

+/**

+ * Make this item visible by expanding its parent item.

+ */

+void makeVisible() {

+	TreeItem parentItem = getParentItem();

+	

+	if (isVisible() == false && parentItem != null) {

+		getParent().expand(parentItem, true);			// have to call Tree.expand directly in order to trigger Expand event

+		parentItem.makeVisible();

+	}

+}

+/** 

+ * Draw the receiver at 'yPosition' in the client area of the parent.

+ * @param gc - GC to draw on.

+ * @param yPosition - y coordinate where the receiver should draw at.

+ */

+void paint(GC gc, int yPosition) {

+	Tree parent = getParent();

+	Point paintPosition = new Point(getPaintStartX(), yPosition);

+	

+	if (isVisible() == false) {

+		return;

+	}

+	gc.setForeground(parent.CONNECTOR_LINE_COLOR);

+	paintPosition = drawVerticalItemConnector(gc, paintPosition);

+	paintPosition = drawHierarchyIndicator(gc, paintPosition);

+	paintPosition = drawHorizontalItemConnector(gc, paintPosition);

+	gc.setForeground(parent.getForeground());

+	// paint the rest

+	if (isCheckable() == true) {

+		paintPosition = drawCheckbox(gc, new Point(paintPosition.x, yPosition));

+	}

+	paintPosition = drawImage(gc, new Point(paintPosition.x, yPosition));

+	drawSelection(gc, paintPosition);

+	if (this == parent.getInsertItem()) {

+		drawInsertMark(gc, paintPosition);

+	}

+	drawText(gc, new Point(getTextXPos(), paintPosition.y + getTextYPosition(gc)));

+	drawSelectionFocus(gc, paintPosition);

+}

+/**

+ * Update the display to reflect the expanded state of the

+ * receiver.

+ * @param itemIndex - index position in the receiver's client 

+ *	area where should be drawn.

+ */

+void redrawExpanded(int itemIndex) {

+	Tree parent = getParent();

+	int indicatorWidth = parent.getHierarchyIndicatorRect().width;

+	int itemHeight = parent.getItemHeight();

+

+	parent.redraw(

+		getPaintStartX(), itemIndex * itemHeight,

+		indicatorWidth, itemHeight, false);

+}

+/**

+ * Reset cached size and position data.

+ */

+void reset() {

+	super.reset();

+	setImageExtent(null);

+	setItemExtent(null);	

+	setPaintStartX(-1);

+	setTextYPosition(-1);	

+}

+/**
+ * Sets the expanded state of the receiver.
+ * <p>
+ *
+ * @param expanded the new expanded 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 void setExpanded(boolean expand) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (isLeaf() == false && expand == true) {

+		getParent().expand(this, false);

+	}

+	else {

+		getParent().collapse(this, false);

+	}

+}

+public void setImage(Image newImage) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Tree parent = getParent();

+	Image oldImage = getImage();

+	boolean isSameImage;

+	int imageWidth = 0;

+	int redrawX = 0;

+

+	super.setImage(newImage);	

+	if (newImage != null && oldImage != null) {

+		isSameImage = newImage.equals(oldImage);

+	}

+	else {

+		isSameImage = newImage == oldImage;

+	}

+	if (isSameImage == false) {

+		if (parent.getVisibleRedrawY(this) != -1) {

+			if (parent.getImageExtent() != null) {

+				imageWidth = parent.getImageExtent().x;

+			}

+			else

+			if (newImage != null) {

+				imageWidth = newImage.getBounds().x;

+			}

+			redrawX = getItemStartX();

+		}

+		parent.itemChanged(this, redrawX, imageWidth);

+	}

+}

+/**

+ * Set the size of the original image of the receiver to 'imageExtent'. 

+ */

+void setImageExtent(Point imageExtent) {

+	this.imageExtent = imageExtent;

+}

+/**

+ * Set the index of the receiver to 'index'.

+ * This index is used to reference children in their parent.

+ */

+void setIndex(int index) {

+	this.index = index;

+}

+/**

+ * Set the size of the receiver to 'extent'.

+ */

+void setItemExtent(Point extent) {

+	itemExtent = extent;

+}

+/**

+ * Set the x position where the receiver is drawn to 'startX'.

+ * @param startX - the x position where the receiver is drawn

+ */

+void setPaintStartX(int startX) {

+	paintStartX = startX;

+}

+/**

+ * Set the parent item of the receiver to 'parentItem'.

+ * @param parentItem - the receiver's parent item. 

+ *	Receiver is a root if this is null.

+ */

+void setParentItem(TreeItem parentItem) {

+	this.parentItem = parentItem;

+}

+/**
+ * This label will be displayed to the right of the bitmap, 
+ * or, if the receiver doesn't have a bitmap to the right of 
+ * the horizontal hierarchy connector line.
+ */

+public void setText(String newText) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Tree parent = getParent();	

+	String oldText = getText();

+	int redrawX = 0;

+	int redrawWidth = 0;

+

+	if (newText == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	super.setText(newText);	

+	if (newText.equals(oldText) == false) {

+		if (parent.getVisibleRedrawY(this) != -1) {

+			redrawX = getTextXPos();

+			redrawWidth = parent.getClientArea().width - redrawX;

+		}

+		parent.itemChanged(this, redrawX, redrawWidth);

+	}

+}

+/**

+ * Set the y position of the receiver's text to 'yPosition'.

+ */

+void setTextYPosition(int yPosition) {

+	textYPosition = yPosition;

+}

+

+public void dispose() {

+	if (!isValidWidget ()) return;

+	// if the tree is being disposed don't bother collapsing the item since all 

+	// items in the tree will be deleted and redraws will not be processed anyway

+	Tree parent = getParent();

+	if (parent.isRemovingAll() == false) {

+		parent.collapseNoRedraw(this);

+	}	

+	

+	if (parentItem != null) {

+		parentItem.removeItem(this);

+	}

+	else {

+		parent.removeItem(this);

+	}

+	

+	super.dispose();

+}

+

+void doDispose() {	

+	// Notify the parent that the receiver is being removed.

+	// Reset cached data.

+	setParentItem(null);

+	setImageExtent(null);

+	setItemExtent(null);	

+	setIndex(-1);

+	setPaintStartX(-1);

+	setTextYPosition(-1);

+	

+	super.doDispose();

+}

+/**
+ * Returns <code>true</code> if the receiver is checked,
+ * and false otherwise.  When the parent does not have
+ * the <code>CHECK style, return false.
+ * <p>
+ *
+ * @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() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return super.getChecked();

+}

+public Display getDisplay() {

+	return super.getDisplay();

+}

+/**
+ * Returns <code>true</code> if the receiver is grayed,
+ * and false otherwise. When the parent does not have
+ * the <code>CHECK style, return false.
+ * <p>
+ *
+ * @return the grayed 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 getGrayed() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return super.getGrayed();

+}

+/**
+ * Sets the checked state of the receiver.
+ * <p>
+ *
+ * @param checked the new 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 void setChecked(boolean checked) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	super.setChecked(checked);

+}

+/**
+ * Sets the grayed state of the receiver.
+ * <p>
+ *
+ * @param checked the new grayed 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 void setGrayed (boolean grayed) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	super.setGrayed(grayed);

+}

+

+}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TreeRoots.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TreeRoots.java
new file mode 100755
index 0000000..dec4c31
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TreeRoots.java
@@ -0,0 +1,156 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+ 

+import org.eclipse.swt.graphics.*;

+import java.util.*;

+ 

+/** 

+ * This class is used to store tree root items.

+ * Instances of this class are never displayed.

+ */

+class TreeRoots extends AbstractTreeItem {

+/**

+ * Create a tree item that holds one or more root items 

+ * @param parent - Tree widget the receiver belongs to

+ */

+TreeRoots(Tree parent) {

+	super(parent, 0);

+	initialize();

+}

+/**

+ * Calculate the number of expanded children.

+ * Recurse up in the tree to the root item.

+ */

+void calculateVisibleItemCount() {

+	Vector children = getChildren();

+	TreeItem child;

+	int visibleItemCount = children.size();

+	

+	for (int i = 0; i < children.size(); i++) {

+		child = (TreeItem) children.elementAt(i);

+		visibleItemCount += child.getVisibleItemCount();

+	}

+	setVisibleItemCount(visibleItemCount);

+}

+/**

+ * Calculate the number of expanded children for the parent item

+ * of this item.

+ */

+void calculateVisibleItemCountParent() {}

+

+public void dispose() {

+	if (!isValidWidget ()) return;

+	Tree parent = (Tree) getSelectableParent();

+	

+	// all tree items are removed so we don't need to do

+	// time consuming screen updates for each removed item

+	parent.setRemovingAll(true);

+	super.dispose();

+	parent.setRemovingAll(false);

+}

+/**

+ * Answer the x position of the item check box

+ */

+int getCheckboxXPosition() {

+	return 0;

+}

+/**

+ * Implements SelectableItem#getSelectionExtent

+ * Should never be called since objects of this type are never 

+ * rendered

+ */

+Point getSelectionExtent() {

+	return new Point(0, 0);

+}

+/**

+ * Implements SelectableItem#getSelectionX

+ * Should never be called since objects of this type are never 

+ * rendered

+ */

+int getSelectionX() {

+	return 0;

+}

+/**

+ * Always answer -1 to indicate that the receiver is not visible.

+ */

+int getVisibleIndex() {

+	return -1;		

+}

+/**

+ * Answer the index of the child item identified by 'childIndex' 

+ * relative to the first root item.

+ */

+int getVisibleIndex(int childIndex) {

+	Enumeration children = getChildren().elements();

+	TreeItem child;

+	int globalItemIndex = 0;

+

+	while (children.hasMoreElements() == true) {

+		child = (TreeItem) children.nextElement();

+		if (child.getIndex() == childIndex) {

+			break;

+		}

+		globalItemIndex += child.getVisibleItemCount();		

+	}	

+	return globalItemIndex;

+}

+/**

+ * Answer the item at 'searchIndex' relativ to the receiver.

+ * When this method is called for the root item, 'searchIndex' 

+ * represents the global index into all items of the tree.

+ * searchIndex=0 returns the receiver. 

+ * searchIndex=1 returns the first visible child.

+ * Note: searchIndex must be >= 0

+ *

+ * Note: 

+ * Visible in this context does not neccessarily mean that the 

+ * item is displayed on the screen. Visible here means that all 

+ * the parents of the item are expanded. An item is only 

+ * visible on screen if it is within the widget client area.

+ */

+TreeItem getVisibleItem(int searchIndex) {

+	TreeItem child;

+	TreeItem foundItem = null;

+	Enumeration children = getChildren().elements();

+

+	searchIndex++;						// skip this fake root item

+

+	// Search for expanded items first. Count all subitems in the process.

+	while (children.hasMoreElements() == true && foundItem == null) {

+		child = (TreeItem) children.nextElement();

+		searchIndex--;

+		if (child.internalGetExpanded() == true) {

+			searchIndex -= child.getVisibleItemCount();	// count children of all expanded items

+		}

+		if (searchIndex <= 0) {								// is searched item past child ?

+			// add back children of current item (that's what we want to search)			

+			foundItem = child.getVisibleItem(searchIndex + child.getVisibleItemCount());

+		}

+	}

+	return foundItem;

+}

+/**

+ * Initialize the receiver

+ */

+void initialize() {

+	internalSetExpanded(true);

+}

+

+/**

+ * Select the receiver and all children

+ */

+Vector selectAll(Vector selectedItems) {

+	Enumeration children = getChildren().elements();

+	AbstractTreeItem treeItem;

+

+	while (children.hasMoreElements() == true) {

+		treeItem = (AbstractTreeItem) children.nextElement();

+		selectedItems = treeItem.selectAll(selectedItems);

+	}

+	return selectedItems;

+}

+}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java
index 9f73c72..d3c445d 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java
@@ -12,32 +12,32 @@
 import org.eclipse.swt.events.*;

 import java.util.EventListener;

 

-/**

- * This class is the abstract superclass of all user interface objects.  

- * Widgets are created, disposed and issue notification to listeners

- * when events occur which affect them.

- * <dl>

- * <dt><b>Styles:</b></dt>

- * <dd>(none)</dd>

- * <dt><b>Events:</b></dt>

- * <dd>Dispose</dd>

- * </dl>

- * <p>

- * IMPORTANT: This class is intended to be subclassed <em>only</em>

- * within the SWT implementation. However, it has not been marked

- * final to allow those outside of the SWT development team to implement

- * patched versions of the class in order to get around specific

- * limitations in advance of when those limitations can be addressed

- * by the team.  Any class built using subclassing to access the internals

- * of this class will likely fail to compile or run between releases and

- * may be strongly platform specific. Subclassing should not be attempted

- * without an intimate and detailed understanding of the workings of the

- * hierarchy. No support is provided for user-written classes which are

- * implemented as subclasses of this class.

- * </p>

- *

- * @see #checkSubclass

- */

+/**
+ * This class is the abstract superclass of all user interface objects.  
+ * Widgets are created, disposed and issue notification to listeners
+ * when events occur which affect them.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Dispose</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation. However, it has not been marked
+ * final to allow those outside of the SWT development team to implement
+ * patched versions of the class in order to get around specific
+ * limitations in advance of when those limitations can be addressed
+ * by the team.  Any class built using subclassing to access the internals
+ * of this class will likely fail to compile or run between releases and
+ * may be strongly platform specific. Subclassing should not be attempted
+ * without an intimate and detailed understanding of the workings of the
+ * hierarchy. No support is provided for user-written classes which are
+ * implemented as subclasses of this class.
+ * </p>
+ *
+ * @see #checkSubclass
+ */
 public abstract class Widget {

 

 	public int handle;

@@ -67,95 +67,113 @@
 	

 	/* Global widget variables */

 	static final char Mnemonic = '&';

-

-	/* DBCS flags */

-	static final boolean IsDBLocale;

+	static final boolean IsAIX, IsSunOS, IsLinux;

 	static {

-		IsDBLocale = OS.MB_CUR_MAX () != 1;

+		

+		/* Initialize the X/MOTIF flags */

+		String osName = System.getProperty ("os.name");

+		if (osName.equals("Linux")) {

+			IsLinux = true;

+			IsAIX = IsSunOS = false;

+		} else {

+			if (osName.equals("AIX")) {

+				IsAIX = true;

+				IsLinux = IsSunOS = false;

+			} else {

+				if (osName.equals("Solaris")) {

+					IsSunOS = true;

+					IsLinux = IsAIX = false;

+				} else {

+					IsLinux = IsSunOS = IsAIX = false;

+				}

+			}

+		}

 	}

 Widget () {

 	/* Do nothing */

 }

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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 widget which will be the parent of the new instance (cannot be null)

- * @param style the style of widget to construct

- *

- * @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 #checkSubclass

- * @see #getStyle

+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <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 widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @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 #checkSubclass
+ * @see #getStyle
  */

 public Widget (Widget parent, int style) {

 	if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

 	this.style = style;

 }

-/**

- * Adds the listener to the collection of listeners who will

- * be notifed when an event of the given type occurs. When the

- * event does occur in the widget, the listener is notified by

- * sending it the <code>handleEvent()</code> message.

- *

- * @param eventType the type of event to listen for

- * @param listener the listener which should be notified when the event occurs

- *

- * @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 Listener

- * @see #removeListener

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notifed when an event of the given type occurs. When the
+ * event does occur in the widget, the listener is notified by
+ * sending it the <code>handleEvent()</code> message.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should be notified when the event occurs
+ *
+ * @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 Listener
+ * @see #removeListener
  */

 public void addListener (int eventType, Listener handler) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) eventTable = new EventTable ();

 	eventTable.hook (eventType, handler);

 }

-/**

- * Adds the listener to the collection of listeners who will

- * be notifed when the widget is disposed. When the widget is

- * disposed, the listener is notified by sending it the

- * <code>widgetDisposed()</code> message.

- *

- * @param listener the listener which should be notified when the receiver is disposed

- *

- * @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 DisposeListener

- * @see #removeDisposeListener

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notifed when the widget is disposed. When the widget is
+ * disposed, the listener is notified by sending it the
+ * <code>widgetDisposed()</code> message.
+ *
+ * @param listener the listener which should be notified when the receiver is disposed
+ *
+ * @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 DisposeListener
+ * @see #removeDisposeListener
  */

 public void addDisposeListener (DisposeListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Dispose, typedListener);

@@ -174,7 +192,6 @@
 void checkParent (Widget parent) {

 	if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

-	if (parent.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);

 }

 /**

  * Checks that this class can be subclassed.

@@ -221,7 +238,7 @@
 */

 protected void checkWidget () {

 	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

-	if (isDisposed ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 }

 void createHandle (int index) {

 	/* Do nothing */

@@ -243,100 +260,98 @@
 		OS.XtDestroyWidget (topHandle);

 	}

 }

-/**

- * Disposes of the operating system resources associated with

- * the receiver and all its descendents. After this method has

- * been invoked, the receiver and all descendents will answer

- * <code>true</code> when sent the message <code>isDisposed()</code>.

- * Any internal connections between the widgets in the tree will

- * have been removed to facilitate garbage collection.

- * <p>

- * NOTE: This method is not called recursively on the descendents

- * of the receiver. This means that, widget implementers can not

- * detect when a widget is being disposed of by re-implementing

- * this method, but should instead listen for the <code>Dispose</code>

- * event.

- * </p>

- *

- * @exception SWTException <ul>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>

- * </ul>

- *

- * @see #addDisposeListener

- * @see #removeDisposeListener

- * @see #checkWidget

+/**
+ * Disposes of the operating system resources associated with
+ * the receiver and all its descendents. After this method has
+ * been invoked, the receiver and all descendents will answer
+ * <code>true</code> when sent the message <code>isDisposed()</code>.
+ * Any internal connections between the widgets in the tree will
+ * have been removed to facilitate garbage collection.
+ * <p>
+ * NOTE: This method is not called recursively on the descendents
+ * of the receiver. This means that, widget implementers can not
+ * detect when a widget is being disposed of by re-implementing
+ * this method, but should instead listen for the <code>Dispose</code>
+ * event.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #addDisposeListener
+ * @see #removeDisposeListener
+ * @see #checkWidget
  */

 public void dispose () {

 	/*

 	* Note:  It is valid to attempt to dispose a widget

 	* more than once.  If this happens, fail silently.

 	*/

-	if (isDisposed()) return;

+	if (!isValidWidget ()) return;

 	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

 	releaseChild ();

 	releaseWidget ();

 	destroyWidget ();

 }

-void enableHandle (boolean enabled, int widgetHandle) {

-	int [] argList = {OS.XmNsensitive, enabled ? 1 : 0};

-	OS.XtSetValues (widgetHandle, argList, argList.length / 2);

-}

 void error (int code) {

 	SWT.error(code);

 }

-/**

- * Returns the application defined widget data associated

- * with the receiver, or null if it has not been set. The

- * <em>widget data</em> is a single, unnamed field that is

- * stored with every widget. 

- * <p>

- * Applications may put arbitrary objects in this field. If

- * the object stored in the widget data needs to be notified

- * when the widget is disposed of, it is the application's

- * responsibility to hook the Dispose event on the widget and

- * do so.

- * </p>

- *

- * @return the widget data

- *

- * @exception SWTException <ul>

- *    <li>ERROR_WIDGET_DISPOSED - when the receiver has been disposed</li>

- *    <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>

- * </ul>

- *

- * @see #setData

+/**
+ * Returns the application defined widget data associated
+ * with the receiver, or null if it has not been set. The
+ * <em>widget data</em> is a single, unnamed field that is
+ * stored with every widget. 
+ * <p>
+ * Applications may put arbitrary objects in this field. If
+ * the object stored in the widget data needs to be notified
+ * when the widget is disposed of, it is the application's
+ * responsibility to hook the Dispose event on the widget and
+ * do so.
+ * </p>
+ *
+ * @return the widget data
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - when the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>
+ * </ul>
+ *
+ * @see #setData
  */

 public Object getData () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return data;

 }

 

-/**

- * Returns the application defined property of the receiver

- * with the specified name, or null if it has not been set.

- * <p>

- * Applications may have associated arbitrary objects with the

- * receiver in this fashion. If the objects stored in the

- * properties need to be notified when the widget is disposed

- * of, it is the application's responsibility to hook the

- * Dispose event on the widget and do so.

- * </p>

- *

- * @param	key the name of the property

- * @return the value of the property or null if it has not been set

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the key 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 #setData

+/**
+ * Returns the application defined property of the receiver
+ * with the specified name, or null if it has not been set.
+ * <p>
+ * Applications may have associated arbitrary objects with the
+ * receiver in this fashion. If the objects stored in the
+ * properties need to be notified when the widget is disposed
+ * of, it is the application's responsibility to hook the
+ * Dispose event on the widget and do so.
+ * </p>
+ *
+ * @param	key the name of the property
+ * @return the value of the property or null if it has not been set
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the key 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 #setData
  */

 public Object getData (String key) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (key == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (keys == null) return null;

 	for (int i=0; i<keys.length; i++) {

@@ -345,21 +360,21 @@
 	return null;

 }

 

-/**

- * Returns the <code>Display</code> that is associated with

- * the receiver.

- * <p>

- * A widget's display is either provided when it is created

- * (for example, top level <code>Shell</code>s) or is the

- * same as its parent's display.

- * </p>

- *

- * @return the receiver's display

- *

- * @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 the <code>Display</code> that is associated with
+ * the receiver.
+ * <p>
+ * A widget's display is either provided when it is created
+ * (for example, top level <code>Shell</code>s) or is the
+ * same as its parent's display.
+ * </p>
+ *
+ * @return the receiver's display
+ *
+ * @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 abstract Display getDisplay ();

 String getName () {

@@ -371,28 +386,29 @@
 String getNameText () {

 	return "";

 }

-/**

- * Returns the receiver's style information.

- * <p>

- * Note that the value which is returned by this method <em>may

- * not match</em> the value which was provided to the constructor

- * when the receiver was created. This can occur when the underlying

- * operating system does not support a particular combination of

- * requested styles. For example, if the platform widget used to

- * implement a particular SWT widget always has scroll bars, the

- * result of calling this method would always have the

- * <code>SWT.H_SCROLL</code> and <code>SWT.V_SCROLL</code> bits set.

- * </p>

- *

- * @return the style bits

- *

- * @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 the receiver's style information.
+ * <p>
+ * Note that the value which is returned by this method <em>may
+ * not match</em> the value which was provided to the constructor
+ * when the receiver was created. This can occur when the underlying
+ * operating system does not support a particular combination of
+ * requested styles. For example, if the platform widget used to
+ * implement a particular SWT widget always has scroll bars, the
+ * result of calling this method would always have the
+ * <code>SWT.H_SCROLL</code> and <code>SWT.V_SCROLL</code> bits set.
+ * </p>
+ *
+ * @return the style bits
+ *
+ * @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 getStyle () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return style;

 }

 void hookEvents () {

@@ -402,16 +418,16 @@
 	if (eventTable == null) return false;

 	return eventTable.hooks (eventType);

 }

-/**

- * Returns <code>true</code> if the widget has been disposed,

- * and <code>false</code> otherwise.

- * <p>

- * This method gets the dispose state for the widget.

- * When a widget has been disposed, it is an error to

- * invoke any other method using the widget.

- * </p>

- *

- * @return <code>true</code> when the widget is disposed and <code>false</code> otherwise

+/**
+ * Returns <code>true</code> if the widget has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the widget.
+ * When a widget has been disposed, it is an error to
+ * invoke any other method using the widget.
+ * </p>
+ *
+ * @return <code>true</code> when the widget is disposed and <code>false</code> otherwise
  */

 public boolean isDisposed () {

 	if (handle != 0) return false;

@@ -434,7 +450,8 @@
  *	</ul>

  */

 protected boolean isListening (int eventType) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return hooks (eventType);

 }

 boolean isValidSubclass () {

@@ -443,13 +460,15 @@
 boolean isValidThread () {

 	return getDisplay ().isValidThread ();

 }

+boolean isValidWidget () {

+	if (handle != 0) return true;

+	if ((state & HANDLE) != 0) return false;

+	return (state & DISPOSED) == 0;

+}

 void manageChildren () {

 	/* Do nothing */

 }

 char mbcsToWcs (char ch) {

-	return mbcsToWcs (ch, null);

-}

-char mbcsToWcs (char ch, String codePage) {

 	int key = ch & 0xFFFF;

 	if (key <= 0x7F) return ch;

 	byte [] buffer;

@@ -461,28 +480,29 @@
 		buffer [0] = (byte) ((key >> 8) & 0xFF);

 		buffer [1] = (byte) (key & 0xFF);

 	}

-	char [] result = Converter.mbcsToWcs (codePage, buffer);

+	char [] result = Converter.mbcsToWcs (null, buffer);

 	if (result.length == 0) return 0;

 	return result [0];

 }

-/**

- * Notifies all of the receiver's listeners for events

- * of the given type that one such event has occurred by

- * invoking their <code>handleEvent()</code> method.

- *

- * @param eventType the type of event which has occurred

- * @param event the event data

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the event 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>

+/**
+ * Notifies all of the receiver's listeners for events
+ * of the given type that one such event has occurred by
+ * invoking their <code>handleEvent()</code> method.
+ *
+ * @param eventType the type of event which has occurred
+ * @param event the event data
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the event 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>
  */

 public void notifyListeners (int eventType, Event event) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (event == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	event.type = eventType;

@@ -592,50 +612,6 @@
 int processVerify (int callData) {

 	return 0;

 }

-void propagateHandle (boolean enabled, int widgetHandle) {

-	int xDisplay = OS.XtDisplay (widgetHandle);

-	if (xDisplay == 0) return;

-	int xWindow = OS.XtWindow (widgetHandle);

-	if (xWindow == 0) return;

-	/*

-	* Get the event mask from the widget.  The event mask

-	* returned by XtBuildEventMask () includes the masks

-	* associated with all callbacks and event handlers

-	* that have been hooked on the widget.

-	*/

-	int event_mask = OS.XtBuildEventMask (widgetHandle);

-	int do_not_propagate_mask = 

-		OS.KeyPressMask | OS.KeyReleaseMask | OS.ButtonPressMask | 

-		OS.ButtonReleaseMask | OS.PointerMotionMask;

-	if (!enabled) {

-		/*

-		* Attempting to propogate EnterWindowMask and LeaveWindowMask

-		* causes an X error so these must be specially cleared out from

-		* the event mask, not included in the propogate mask.

-		*/

-		event_mask &= ~(do_not_propagate_mask | OS.EnterWindowMask | OS.LeaveWindowMask);

-		do_not_propagate_mask = 0;

-	}

-	XSetWindowAttributes attributes = new XSetWindowAttributes ();

-	attributes.event_mask = event_mask;

-	attributes.do_not_propagate_mask = do_not_propagate_mask;

-	OS.XChangeWindowAttributes (xDisplay, xWindow, OS.CWDontPropagate | OS.CWEventMask, attributes);

-	int [] argList = {OS.XmNtraversalOn, enabled ? 1 : 0};

-	OS.XtSetValues (widgetHandle, argList, argList.length / 2);

-}

-void redrawHandle (int x, int y, int width, int height, int widgetHandle) {

-	int display = OS.XtDisplay (widgetHandle);

-	if (display == 0) return;

-	int window = OS.XtWindow (widgetHandle);

-	if (window == 0) return;

-	int [] argList = {OS.XmNborderWidth, 0, OS.XmNborderColor, 0};

-	OS.XtGetValues (widgetHandle, argList, argList.length / 2);

-	if (argList [1] != 0) {

-		/* Force the border to repaint by setting the color */

-		OS.XtSetValues (widgetHandle, argList, argList.length / 2);

-	}

-	OS.XClearArea (display, window, x, y, width, height, true);

-}

 void register () {

 	if (handle == 0) return;

 	WidgetTable.put (handle, this);

@@ -655,26 +631,27 @@
 	keys = null;

 	values = null;

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notifed when an event of the given type occurs.

- *

- * @param eventType the type of event to listen for

- * @param listener the listener which should no longer be notified when the event occurs

- *

- * @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 Listener

- * @see #addListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notifed when an event of the given type occurs.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should no longer be notified when the event occurs
+ *
+ * @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 Listener
+ * @see #addListener
  */

 public void removeListener (int eventType, Listener handler) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (eventType, handler);

@@ -683,30 +660,32 @@
 * Warning: API under construction.

 */

 protected void removeListener (int eventType, EventListener handler) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (eventType, handler);

 }

-/**

- * Removes the listener from the collection of listeners who will

- * be notifed when the widget is disposed.

- *

- * @param listener the listener which should no longer be notified when the receiver is disposed

- *

- * @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 DisposeListener

- * @see #removeDisposeListener

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notifed when the widget is disposed.
+ *
+ * @param listener the listener which should no longer be notified when the receiver is disposed
+ *
+ * @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 DisposeListener
+ * @see #removeDisposeListener
  */

 public void removeDisposeListener (DisposeListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Dispose, listener);

@@ -725,57 +704,59 @@
 	}

 	eventTable.sendEvent (event);

 }

-/**

- * Sets the application defined widget data associated

- * with the receiver to be the argument. The <em>widget

- * data</em> is a single, unnamed field that is stored

- * with every widget. 

- * <p>

- * Applications may put arbitrary objects in this field. If

- * the object stored in the widget data needs to be notified

- * when the widget is disposed of, it is the application's

- * responsibility to hook the Dispose event on the widget and

- * do so.

- * </p>

- *

- * @param data the widget data

- *

- * @exception SWTException <ul>

- *    <li>ERROR_WIDGET_DISPOSED - when the receiver has been disposed</li>

- *    <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>

- * </ul>

+/**
+ * Sets the application defined widget data associated
+ * with the receiver to be the argument. The <em>widget
+ * data</em> is a single, unnamed field that is stored
+ * with every widget. 
+ * <p>
+ * Applications may put arbitrary objects in this field. If
+ * the object stored in the widget data needs to be notified
+ * when the widget is disposed of, it is the application's
+ * responsibility to hook the Dispose event on the widget and
+ * do so.
+ * </p>
+ *
+ * @param data the widget data
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - when the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>
+ * </ul>
  */

 public void setData (Object data) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	this.data = data;

 }

 

-/**

- * Sets the application defined property of the receiver

- * with the specified name to the given value.

- * <p>

- * Applications may associate arbitrary objects with the

- * receiver in this fashion. If the objects stored in the

- * properties need to be notified when the widget is disposed

- * of, it is the application's responsibility to hook the

- * Dispose event on the widget and do so.

- * </p>

- *

- * @param key the name of the property

- * @param value the new value for the property

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the key 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 #getData

+/**
+ * Sets the application defined property of the receiver
+ * with the specified name to the given value.
+ * <p>
+ * Applications may associate arbitrary objects with the
+ * receiver in this fashion. If the objects stored in the
+ * properties need to be notified when the widget is disposed
+ * of, it is the application's responsibility to hook the
+ * Dispose event on the widget and do so.
+ * </p>
+ *
+ * @param key the name of the property
+ * @param value the new value for the property
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the key 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 #getData
  */

 public void setData (String key, Object value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (key == null) error (SWT.ERROR_NULL_ARGUMENT);

 	

 	/* Remove the key/value pair */

@@ -822,11 +803,11 @@
 	values = newValues;

 }

 

-/**

- * Returns a string containing a concise, human-readable

- * description of the receiver.

- *

- * @return a string representation of the receiver

+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
  */

 public String toString () {

 	String string = "*Disposed*";

@@ -840,12 +821,9 @@
 	return handle;

 }

 char wcsToMbcs (char ch) {

-	return wcsToMbcs (ch, null);

-}

-char wcsToMbcs (char ch, String codePage) {

 	int key = ch & 0xFFFF;

 	if (key <= 0x7F) return ch;

-	byte [] buffer = Converter.wcsToMbcs (codePage, new char [] {ch}, false);

+	byte [] buffer = Converter.wcsToMbcs (null, new char [] {ch}, false);

 	if (buffer.length == 1) return (char) buffer [0];

 	if (buffer.length == 2) {

 		return (char) (((buffer [0] & 0xFF) << 8) | (buffer [1] & 0xFF));

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/library/makefile.mak b/bundles/org.eclipse.swt/Eclipse SWT/photon/library/makefile.mak
index 360f6f3..f688b0b 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/library/makefile.mak
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/library/makefile.mak
@@ -3,15 +3,14 @@
 # (c) Copyright IBM Corp., 2000, 2001
 # All Rights Reserved.
 
-maj_ver=2
-min_ver=002
+maj_ver=0
+min_ver=125
 revision=0
 
 #assumes IVE_HOME is set in the environment
 
 DLLPREFIX=swt
-OS_PREFIX=qnx
-DLLNAME=lib$(DLLPREFIX)-$(OS_PREFIX)-$(maj_ver)$(min_ver).so
+DLLNAME=lib$(DLLPREFIX)$(maj_ver)$(min_ver).so
 #DLLNAME=lib$(DLLPREFIX)$(maj_ver)$(min_ver)r$(revision).so
 
 DEBUG =  
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/library/structs.c b/bundles/org.eclipse.swt/Eclipse SWT/photon/library/structs.c
index f3cc1ea..51f3781 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/library/structs.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/library/structs.c
@@ -431,8 +431,9 @@
 	lpCache->key_mods = (*env)->GetFieldID(env, lpCache->clazz, "key_mods", "I");
 	lpCache->key_sym = (*env)->GetFieldID(env, lpCache->clazz, "key_sym", "I");
 	lpCache->key_cap = (*env)->GetFieldID(env, lpCache->clazz, "key_cap", "I");
-	lpCache->key_scan = (*env)->GetFieldID(env, lpCache->clazz, "key_scan", "S");
-	lpCache->key_zero = (*env)->GetFieldID(env, lpCache->clazz, "key_zero", "S");
+	lpCache->key_scan = (*env)->GetFieldID(env, lpCache->clazz, "key_scan", "B");
+	lpCache->key_zero1 = (*env)->GetFieldID(env, lpCache->clazz, "key_zero1", "B");
+	lpCache->key_zero2 = (*env)->GetFieldID(env, lpCache->clazz, "key_zero2", "S");
 	lpCache->pos_x = (*env)->GetFieldID(env, lpCache->clazz, "pos_x", "S");
 	lpCache->pos_y = (*env)->GetFieldID(env, lpCache->clazz, "pos_y", "S");
 	lpCache->button_state = (*env)->GetFieldID(env, lpCache->clazz, "button_state", "S");
@@ -445,10 +446,9 @@
 	lpStruct->key_mods = (*env)->GetIntField(env, lpObject, lpCache->key_mods);
 	lpStruct->key_sym = (*env)->GetIntField(env, lpObject, lpCache->key_sym);
 	lpStruct->key_cap = (*env)->GetIntField(env, lpObject, lpCache->key_cap);
-	lpStruct->key_scan = (*env)->GetShortField(env, lpObject, lpCache->key_scan);
-#if _NTO_VERSION+0 >= 610
-	lpStruct->key_zero = (*env)->GetShortField(env, lpObject, lpCache->key_zero);
-#endif
+	lpStruct->key_scan = (*env)->GetByteField(env, lpObject, lpCache->key_scan);
+	lpStruct->key_zero1 = (*env)->GetByteField(env, lpObject, lpCache->key_zero1);
+	lpStruct->key_zero2 = (*env)->GetShortField(env, lpObject, lpCache->key_zero2);
 	lpStruct->pos.x = (*env)->GetShortField(env, lpObject, lpCache->pos_x);
 	lpStruct->pos.y = (*env)->GetShortField(env, lpObject, lpCache->pos_y);
 	lpStruct->button_state = (*env)->GetShortField(env, lpObject, lpCache->button_state);
@@ -460,10 +460,9 @@
 	(*env)->SetIntField(env, lpObject, lpCache->key_mods, lpStruct->key_mods);
 	(*env)->SetIntField(env, lpObject, lpCache->key_sym, lpStruct->key_sym);
 	(*env)->SetIntField(env, lpObject, lpCache->key_cap, lpStruct->key_cap);
-	(*env)->SetShortField(env, lpObject, lpCache->key_scan, lpStruct->key_scan);
-#if _NTO_VERSION+0 >= 610
-	(*env)->SetShortField(env, lpObject, lpCache->key_zero, lpStruct->key_zero);
-#endif
+	(*env)->SetByteField(env, lpObject, lpCache->key_scan, lpStruct->key_scan);
+	(*env)->SetByteField(env, lpObject, lpCache->key_zero1, lpStruct->key_zero1);
+	(*env)->SetShortField(env, lpObject, lpCache->key_zero2, lpStruct->key_zero2);
 	(*env)->SetShortField(env, lpObject, lpCache->pos_x, lpStruct->pos.x);
 	(*env)->SetShortField(env, lpObject, lpCache->pos_y, lpStruct->pos.y);
 	(*env)->SetShortField(env, lpObject, lpCache->button_state, lpStruct->button_state);
@@ -1202,151 +1201,4 @@
 	(*env)->SetShortField(env, lpObject, lpCache->hdr_len, lpStruct->hdr.len);
 }
 
-void cachePgDisplaySettings_tFids(JNIEnv *env, jobject lpObject, PPgDisplaySettings_t_FID_CACHE lpCache)
-{
-	if (lpCache->cached) return;
-	lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
-	lpCache->reserved = (*env)->GetFieldID(env, lpCache->clazz, "reserved", "[I");
-	lpCache->flags = (*env)->GetFieldID(env, lpCache->clazz, "flags", "I");
-	lpCache->refresh = (*env)->GetFieldID(env, lpCache->clazz, "refresh", "I");
-	lpCache->yres = (*env)->GetFieldID(env, lpCache->clazz, "yres", "I");
-	lpCache->xres = (*env)->GetFieldID(env, lpCache->clazz, "xres", "I");
-	lpCache->mode = (*env)->GetFieldID(env, lpCache->clazz, "mode", "I");
-	lpCache->cached = 1;
-}
 
-void getPgDisplaySettings_tFields(JNIEnv *env, jobject lpObject, PgDisplaySettings_t *lpStruct, PPgDisplaySettings_t_FID_CACHE lpCache)
-{
-	jintArray reserved = (*env)->GetObjectField(env, lpObject, lpCache->reserved);
-    if (reserved) {
-        jint *reserved1 = (*env)->GetIntArrayElements(env, reserved, NULL);
-        memcpy(reserved1, lpStruct->reserved, sizeof (lpStruct->reserved));
-        (*env)->ReleaseIntArrayElements(env, reserved, reserved1, JNI_ABORT);
-	}
-	lpStruct->flags = (*env)->GetIntField(env, lpObject, lpCache->flags);
-	lpStruct->refresh = (*env)->GetIntField(env, lpObject, lpCache->refresh);
-	lpStruct->yres = (*env)->GetIntField(env, lpObject, lpCache->yres);
-	lpStruct->xres = (*env)->GetIntField(env, lpObject, lpCache->xres);
-	lpStruct->mode = (*env)->GetIntField(env, lpObject, lpCache->mode);
-}
-
-void setPgDisplaySettings_tFields(JNIEnv *env, jobject lpObject, PgDisplaySettings_t *lpStruct, PPgDisplaySettings_t_FID_CACHE lpCache)
-{
-	jintArray reserved = (*env)->GetObjectField(env, lpObject, lpCache->reserved);
-    if (reserved) {
-        jint *reserved1 = (*env)->GetIntArrayElements(env, reserved, NULL);
-        memcpy(reserved1, lpStruct->reserved, sizeof (lpStruct->reserved));
-        (*env)->ReleaseIntArrayElements(env, reserved, reserved1, 0);
-	}
-	(*env)->SetIntField(env, lpObject, lpCache->flags, lpStruct->flags);
-	(*env)->SetIntField(env, lpObject, lpCache->refresh, lpStruct->refresh);
-	(*env)->SetIntField(env, lpObject, lpCache->yres, lpStruct->yres);
-	(*env)->SetIntField(env, lpObject, lpCache->xres, lpStruct->xres);
-	(*env)->SetIntField(env, lpObject, lpCache->mode, lpStruct->mode);
-}
-
-void cachePgVideoModeInfo_tFids(JNIEnv *env, jobject lpObject, PPgVideoModeInfo_t_FID_CACHE lpCache)
-{
-	if (lpCache->cached) return;
-	lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
-	lpCache->refresh_rates = (*env)->GetFieldID(env, lpCache->clazz, "refresh_rates", "[B");
-	lpCache->mode_capabilities6 = (*env)->GetFieldID(env, lpCache->clazz, "mode_capabilities6", "I");
-	lpCache->mode_capabilities5 = (*env)->GetFieldID(env, lpCache->clazz, "mode_capabilities5", "I");
-	lpCache->mode_capabilities4 = (*env)->GetFieldID(env, lpCache->clazz, "mode_capabilities4", "I");
-	lpCache->mode_capabilities3 = (*env)->GetFieldID(env, lpCache->clazz, "mode_capabilities3", "I");
-	lpCache->mode_capabilities2 = (*env)->GetFieldID(env, lpCache->clazz, "mode_capabilities2", "I");
-	lpCache->mode_capabilities1 = (*env)->GetFieldID(env, lpCache->clazz, "mode_capabilities1", "I");
-	lpCache->type = (*env)->GetFieldID(env, lpCache->clazz, "type", "I");
-	lpCache->bytes_per_scanline = (*env)->GetFieldID(env, lpCache->clazz, "bytes_per_scanline", "S");
-	lpCache->bits_per_pixel = (*env)->GetFieldID(env, lpCache->clazz, "bits_per_pixel", "S");
-	lpCache->height = (*env)->GetFieldID(env, lpCache->clazz, "height", "S");
-	lpCache->width = (*env)->GetFieldID(env, lpCache->clazz, "width", "S");
-	lpCache->cached = 1;
-}
-
-void getPgVideoModeInfo_tFields(JNIEnv *env, jobject lpObject, PgVideoModeInfo_t *lpStruct, PPgVideoModeInfo_t_FID_CACHE lpCache)
-{
-	jbyteArray refresh_rates = (*env)->GetObjectField(env, lpObject, lpCache->refresh_rates);
-    if (refresh_rates) {
-        jbyte *refresh_rates1 = (*env)->GetByteArrayElements(env, refresh_rates, NULL);
-        memcpy(lpStruct->refresh_rates, refresh_rates1, sizeof(lpStruct->refresh_rates));
-        (*env)->ReleaseByteArrayElements(env, refresh_rates, refresh_rates1, JNI_ABORT);
-	}
-	lpStruct->mode_capabilities6 = (*env)->GetIntField(env, lpObject, lpCache->mode_capabilities6);
-	lpStruct->mode_capabilities5 = (*env)->GetIntField(env, lpObject, lpCache->mode_capabilities5);
-	lpStruct->mode_capabilities4 = (*env)->GetIntField(env, lpObject, lpCache->mode_capabilities4);
-	lpStruct->mode_capabilities3 = (*env)->GetIntField(env, lpObject, lpCache->mode_capabilities3);
-	lpStruct->mode_capabilities2 = (*env)->GetIntField(env, lpObject, lpCache->mode_capabilities2);
-	lpStruct->mode_capabilities1 = (*env)->GetIntField(env, lpObject, lpCache->mode_capabilities1);
-	lpStruct->type = (*env)->GetIntField(env, lpObject, lpCache->type);
-	lpStruct->bytes_per_scanline = (*env)->GetShortField(env, lpObject, lpCache->bytes_per_scanline);
-	lpStruct->bits_per_pixel = (*env)->GetShortField(env, lpObject, lpCache->bits_per_pixel);
-	lpStruct->height = (*env)->GetShortField(env, lpObject, lpCache->height);
-	lpStruct->width = (*env)->GetShortField(env, lpObject, lpCache->width);
-}
-
-void setPgVideoModeInfo_tFields(JNIEnv *env, jobject lpObject, PgVideoModeInfo_t *lpStruct, PPgVideoModeInfo_t_FID_CACHE lpCache)
-{
-	jbyteArray refresh_rates = (*env)->GetObjectField(env, lpObject, lpCache->refresh_rates);
-    if (refresh_rates) {
-        jbyte *refresh_rates1 = (*env)->GetByteArrayElements(env, refresh_rates, NULL);
-        memcpy(refresh_rates1, lpStruct->refresh_rates, sizeof(lpStruct->refresh_rates));
-        (*env)->ReleaseByteArrayElements(env, refresh_rates, refresh_rates1, 0);
-	}
-	(*env)->SetIntField(env, lpObject, lpCache->mode_capabilities6, lpStruct->mode_capabilities6);
-	(*env)->SetIntField(env, lpObject, lpCache->mode_capabilities5, lpStruct->mode_capabilities5);
-	(*env)->SetIntField(env, lpObject, lpCache->mode_capabilities4, lpStruct->mode_capabilities4);
-	(*env)->SetIntField(env, lpObject, lpCache->mode_capabilities3, lpStruct->mode_capabilities3);
-	(*env)->SetIntField(env, lpObject, lpCache->mode_capabilities2, lpStruct->mode_capabilities2);
-	(*env)->SetIntField(env, lpObject, lpCache->mode_capabilities1, lpStruct->mode_capabilities1);
-	(*env)->SetIntField(env, lpObject, lpCache->type, lpStruct->type);
-	(*env)->SetShortField(env, lpObject, lpCache->bytes_per_scanline, lpStruct->bytes_per_scanline);
-	(*env)->SetShortField(env, lpObject, lpCache->bits_per_pixel, lpStruct->bits_per_pixel);
-	(*env)->SetShortField(env, lpObject, lpCache->height, lpStruct->height);
-	(*env)->SetShortField(env, lpObject, lpCache->width, lpStruct->width);
-}
-
-void cachePhClipHeaderFids(JNIEnv *env, jobject lpObject, PPhClipHeader_FID_CACHE lpCache)
-{
-	if (lpCache->cached) return;
-	lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
-	lpCache->data = (*env)->GetFieldID(env, lpCache->clazz, "data", "I");
-	lpCache->length = (*env)->GetFieldID(env, lpCache->clazz, "length", "S");
-	lpCache->type_7 = (*env)->GetFieldID(env, lpCache->clazz, "type_7", "B");
-	lpCache->type_6 = (*env)->GetFieldID(env, lpCache->clazz, "type_6", "B");
-	lpCache->type_5 = (*env)->GetFieldID(env, lpCache->clazz, "type_5", "B");
-	lpCache->type_4 = (*env)->GetFieldID(env, lpCache->clazz, "type_4", "B");
-	lpCache->type_3 = (*env)->GetFieldID(env, lpCache->clazz, "type_3", "B");
-	lpCache->type_2 = (*env)->GetFieldID(env, lpCache->clazz, "type_2", "B");
-	lpCache->type_1 = (*env)->GetFieldID(env, lpCache->clazz, "type_1", "B");
-	lpCache->type_0 = (*env)->GetFieldID(env, lpCache->clazz, "type_0", "B");
-	lpCache->cached = 1;
-}
-
-void getPhClipHeaderFields(JNIEnv *env, jobject lpObject, PhClipHeader *lpStruct, PPhClipHeader_FID_CACHE lpCache)
-{
-	lpStruct->data = (void *)(*env)->GetIntField(env, lpObject, lpCache->data);
-	lpStruct->length = (*env)->GetShortField(env, lpObject, lpCache->length);
-	lpStruct->type[7] = (*env)->GetByteField(env, lpObject, lpCache->type_7);
-	lpStruct->type[6] = (*env)->GetByteField(env, lpObject, lpCache->type_6);
-	lpStruct->type[5] = (*env)->GetByteField(env, lpObject, lpCache->type_5);
-	lpStruct->type[4] = (*env)->GetByteField(env, lpObject, lpCache->type_4);
-	lpStruct->type[3] = (*env)->GetByteField(env, lpObject, lpCache->type_3);
-	lpStruct->type[2] = (*env)->GetByteField(env, lpObject, lpCache->type_2);
-	lpStruct->type[1] = (*env)->GetByteField(env, lpObject, lpCache->type_1);
-	lpStruct->type[0] = (*env)->GetByteField(env, lpObject, lpCache->type_0);
-}
-
-void setPhClipHeaderFields(JNIEnv *env, jobject lpObject, PhClipHeader *lpStruct, PPhClipHeader_FID_CACHE lpCache)
-{
-	(*env)->SetIntField(env, lpObject, lpCache->data, (jint)lpStruct->data);
-	(*env)->SetShortField(env, lpObject, lpCache->length, lpStruct->length);
-	(*env)->SetByteField(env, lpObject, lpCache->type_7, lpStruct->type[7]);
-	(*env)->SetByteField(env, lpObject, lpCache->type_6, lpStruct->type[6]);
-	(*env)->SetByteField(env, lpObject, lpCache->type_5, lpStruct->type[5]);
-	(*env)->SetByteField(env, lpObject, lpCache->type_4, lpStruct->type[4]);
-	(*env)->SetByteField(env, lpObject, lpCache->type_3, lpStruct->type[3]);
-	(*env)->SetByteField(env, lpObject, lpCache->type_2, lpStruct->type[2]);
-	(*env)->SetByteField(env, lpObject, lpCache->type_1, lpStruct->type[1]);
-	(*env)->SetByteField(env, lpObject, lpCache->type_0, lpStruct->type[0]);
-}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/library/structs.h b/bundles/org.eclipse.swt/Eclipse SWT/photon/library/structs.h
index 0ed83a4..38be26e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/library/structs.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/library/structs.h
@@ -39,10 +39,7 @@
 	PtColorSelectInfo_t_FID_CACHE PtColorSelectInfo_tFc; \
 	PhRegion_t_FID_CACHE PhRegion_tFc; \
 	PtContainerCallback_t_FID_CACHE PtContainerCallback_tFc; \
-	PhCursorDef_t_FID_CACHE PhCursorDef_tFc; \
-	PgDisplaySettings_t_FID_CACHE PgDisplaySettings_tFc; \
-	PgVideoModeInfo_t_FID_CACHE PgVideoModeInfo_tFc; \
-	PhClipHeader_FID_CACHE PhClipHeaderFc;
+	PhCursorDef_t_FID_CACHE PhCursorDef_tFc;
 
 /* PhPoint_t struct */
 typedef struct PhPoint_t_FID_CACHE {
@@ -165,7 +162,7 @@
 typedef struct PhKeyEvent_t_FID_CACHE {
 	int cached;
 	jclass clazz;
-	jfieldID key_flags, key_mods, key_sym, key_cap, key_scan, key_zero, pos_x, pos_y, button_state;
+	jfieldID key_flags, key_mods, key_sym, key_cap, key_scan, key_zero1, key_zero2, pos_x, pos_y, button_state;
 } PhKeyEvent_t_FID_CACHE;
 typedef PhKeyEvent_t_FID_CACHE *PPhKeyEvent_t_FID_CACHE;
 
@@ -329,40 +326,4 @@
 void getPhCursorDef_tFields(JNIEnv *env, jobject lpObject, PhCursorDef_t *lpStruct, PPhCursorDef_t_FID_CACHE lpCache);
 void setPhCursorDef_tFields(JNIEnv *env, jobject lpObject, PhCursorDef_t *lpStruct, PPhCursorDef_t_FID_CACHE lpCache);
 
-/* PgDisplaySettings_t struct */
-typedef struct PgDisplaySettings_t_FID_CACHE {
-	int cached;
-	jclass clazz;
-	jfieldID reserved, flags, refresh, yres, xres, mode;
-} PgDisplaySettings_t_FID_CACHE;
-typedef PgDisplaySettings_t_FID_CACHE *PPgDisplaySettings_t_FID_CACHE;
-
-void cachePgDisplaySettings_tFids(JNIEnv *env, jobject lpObject, PPgDisplaySettings_t_FID_CACHE lpCache);
-void getPgDisplaySettings_tFields(JNIEnv *env, jobject lpObject, PgDisplaySettings_t *lpStruct, PPgDisplaySettings_t_FID_CACHE lpCache);
-void setPgDisplaySettings_tFields(JNIEnv *env, jobject lpObject, PgDisplaySettings_t *lpStruct, PPgDisplaySettings_t_FID_CACHE lpCache);
-
-typedef struct PgVideoModeInfo_t_FID_CACHE {
-	int cached;
-	jclass clazz;
-	jfieldID refresh_rates, mode_capabilities6, mode_capabilities5, mode_capabilities4, mode_capabilities3, mode_capabilities2, mode_capabilities1, type, bytes_per_scanline, bits_per_pixel, height, width;
-} PgVideoModeInfo_t_FID_CACHE;
-typedef PgVideoModeInfo_t_FID_CACHE *PPgVideoModeInfo_t_FID_CACHE;
-
-void cachePgVideoModeInfo_tFids(JNIEnv *env, jobject lpObject, PPgVideoModeInfo_t_FID_CACHE lpCache);
-void getPgVideoModeInfo_tFields(JNIEnv *env, jobject lpObject, PgVideoModeInfo_t *lpStruct, PPgVideoModeInfo_t_FID_CACHE lpCache);
-void setPgVideoModeInfo_tFields(JNIEnv *env, jobject lpObject, PgVideoModeInfo_t *lpStruct, PPgVideoModeInfo_t_FID_CACHE lpCache);
-
-/* PhClipHeader struct */
-typedef struct PhClipHeader_FID_CACHE {
-	int cached;
-	jclass clazz;
-	jfieldID data, length, type_7, type_6, type_5, type_4, type_3, type_2, type_1, type_0;
-} PhClipHeader_FID_CACHE;
-typedef PhClipHeader_FID_CACHE *PPhClipHeader_FID_CACHE;
-
-void cachePhClipHeaderFids(JNIEnv *env, jobject lpObject, PPhClipHeader_FID_CACHE lpCache);
-void getPhClipHeaderFields(JNIEnv *env, jobject lpObject, PhClipHeader *lpStruct, PPhClipHeader_FID_CACHE lpCache);
-void setPhClipHeaderFields(JNIEnv *env, jobject lpObject, PhClipHeader *lpStruct, PPhClipHeader_FID_CACHE lpCache);
-
-
 #endif // INC_structs_H
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/library/swt.c b/bundles/org.eclipse.swt/Eclipse SWT/photon/library/swt.c
index 72d91f6..8dbd9a0 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/library/swt.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/library/swt.c
@@ -453,7 +453,6 @@
     }
     if (radii) {
         lpRadii1 = &radii1;
-        cachePhPoint_tFids(env, radii, &PGLOB(PhPoint_tFc));
         getPhPoint_tFields(env, radii, lpRadii1, &PGLOB(PhPoint_tFc));
     }
     return (jint) PgDrawArc(lpCenter1, lpRadii1, start, end, flags);
@@ -481,7 +480,6 @@
     }
     if (radii) {
         lpRadii1 = &radii1;
-        cachePhPoint_tFids(env, radii, &PGLOB(PhPoint_tFc));
         getPhPoint_tFields(env, radii, lpRadii1, &PGLOB(PhPoint_tFc));
     }
     return (jint) PgDrawEllipse(lpCenter1, lpRadii1, flags);
@@ -489,47 +487,6 @@
 
 /*
  * Class:     org_eclipse_swt_internal_photon_OS
- * Method:    PgDrawGradient
- * Signature: (Lorg/eclipse/swt/photon/PhPoint_t;Lorg/eclipse/swt/photon/PhPoint_t;IIIIIIII[B)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgDrawGradient
-  (JNIEnv *env, jobject that, jobject ul, jobject lr, jint gradient_type, jint transition_type, jint num_color_pts, jint color1, jint color2, jint color3, jint color4, jint table_size, jbyteArray transition_table)
-{
-	DECL_GLOB(pGlob)
-    jbyte *transition_table1=NULL;
-    PhPoint_t ul1, *lpUl1 = NULL, lr1, *lpLr1 = NULL;
-    jint result;
-
-#ifdef DEBUG_CALL_PRINTS
-    fprintf(stderr, "PgDrawGradient\n");
-#endif
-
-    if (ul) {
-        lpUl1 = &ul1;
-        cachePhPoint_tFids(env, ul, &PGLOB(PhPoint_tFc));
-        getPhPoint_tFields(env, ul, lpUl1, &PGLOB(PhPoint_tFc));
-    }
-    if (lr) {
-        lpLr1 = &lr1;
-        cachePhPoint_tFids(env, ul, &PGLOB(PhPoint_tFc));
-        getPhPoint_tFields(env, lr, lpLr1, &PGLOB(PhPoint_tFc));
-    }
-    if (transition_table)
-    	transition_table1 = (*env)->GetByteArrayElements(env, transition_table, NULL);
-
-    result = (jint) PgDrawGradient(lpUl1, lpLr1,
-    	(unsigned long) gradient_type, (unsigned long) transition_type, (unsigned long) num_color_pts,
-    	(PgColor_t) color1, (PgColor_t) color2, (PgColor_t) color3, (PgColor_t) color4,
-    	(unsigned long) table_size, (unsigned char*) transition_table1);
-
-    if (transition_table)
-    	(*env)->ReleaseByteArrayElements(env, transition_table, transition_table1, 0);
-
-    return result;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_photon_OS
  * Method:    PgDrawRoundRect
  * Signature: (Lorg/eclipse/swt/photon/PhRect_t;Lorg/eclipse/swt/photon/PhPoint_t;I)I
  */
@@ -4594,21 +4551,6 @@
 
 /*
  * Class:     org_eclipse_swt_internal_photon_OS
- * Method:    PtBlockWindow
- * Signature: (ISI)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtBlockWindow
-  (JNIEnv *env, jobject that, jint window, jshort cursor, jint cursor_color)
-{
-#ifdef DEBUG_CALL_PRINTS
-    fprintf(stderr, "PtBlockWindow\n");
-#endif
-	
-	return (jint) PtBlockWindow((PtWidget_t *)window, cursor, (PgColor_t)cursor_color);
-}
-
-/*
- * Class:     org_eclipse_swt_internal_photon_OS
  * Method:    PtUnblockWindows
  * Signature: (I)V
  */
@@ -6403,335 +6345,3 @@
 	return result;
 }
 
-/*
- * Class:     org_eclipse_swt_internal_photon_OS
- * Method:    memmove
- * Signature: (ILorg/eclipse/swt/internal/photon/PgDisplaySettings_t;I)V
- */
-/*
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__ILorg_eclipse_swt_internal_photon_PgDisplaySettings_1t_2I
-  (JNIEnv *env, jobject that, jint dest, jobject src, jint count)
-{
-	DECL_GLOB(pGlob)
-	
-    PgDisplaySettings_t object, *src1=NULL;
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_photon_PgDisplaySettings_1t_2I\n");
-#endif
-
-    if (src) {
-        src1=&object;
-        cachePgDisplaySettings_tFids(env, src, &PGLOB(PgDisplaySettings_tFc));
-        getPgDisplaySettings_tFields(env, src, src1, &PGLOB(PgDisplaySettings_tFc));
-    }
-    memmove((void *)dest, (void *)src1, count);
-}
-*/
-
-/*
- * Class:     org_eclipse_swt_internal_photon_OS
- * Method:    memmove
- * Signature: (Lorg/eclipse/swt/internal/photon/PgDisplaySettings_t;II)V
- */
-/*
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_PgDisplaySettings_1t_2II
-  (JNIEnv *env, jobject that, jobject dest, jint src, jint count)
-{
-	DECL_GLOB(pGlob)
-	PgDisplaySettings_t object, *dest1=NULL;
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_PgDisplaySettings_1t_2II\n");
-#endif
-
-    memmove((void *)&object, (void *)src, count);
-    if (dest) {
-        dest1=&object;
-        cachePgDisplaySettings_tFids(env, dest, &PGLOB(PgDisplaySettings_tFc));
-        setPgDisplaySettings_tFields(env, dest, dest1, &PGLOB(PgDisplaySettings_tFc));
-    }
-}
-*/
-
-/*
- * Class:     org_eclipse_swt_internal_photon_OS
- * Method:    memmove
- * Signature: (ILorg/eclipse/swt/internal/photon/PgVideoModeInfo_t;I)V
- */
-/*
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__ILorg_eclipse_swt_internal_photon_PgVideoModeInfo_1t_2I
-  (JNIEnv *env, jobject that, jint dest, jobject src, jint count)
-{
-	DECL_GLOB(pGlob)
-	
-    PgVideoModeInfo_t object, *src1=NULL;
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_photon_PgVideoModeInfo_1t_2I\n");
-#endif
-
-    if (src) {
-        src1=&object;
-        cachePgVideoModeInfo_tFids(env, src, &PGLOB(PgVideoModeInfo_tFc));
-        getPgVideoModeInfo_tFields(env, src, src1, &PGLOB(PgVideoModeInfo_tFc));
-    }
-    memmove((void *)dest, (void *)src1, count);
-}
-*/
-
-/*
- * Class:     org_eclipse_swt_internal_photon_OS
- * Method:    memmove
- * Signature: (Lorg/eclipse/swt/internal/photon/PgVideoModeInfo_t;II)V
- */
-/*
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_PgVideoModeInfo_1t_2II
-  (JNIEnv *env, jobject that, jobject dest, jint src, jint count)
-{
-	DECL_GLOB(pGlob)
-	PgVideoModeInfo_t object, *dest1=NULL;
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_PgVideoModeInfo_1t_2II\n");
-#endif
-
-    memmove((void *)&object, (void *)src, count);
-    if (dest) {
-        dest1=&object;
-        cachePgVideoModeInfo_tFids(env, dest, &PGLOB(PgVideoModeInfo_tFc));
-        setPgVideoModeInfo_tFields(env, dest, dest1, &PGLOB(PgVideoModeInfo_tFc));
-    }
-}
-*/
-
-/*
- * Class:     org_eclipse_swt_internal_photon_OS
- * Method:    PgGetVideoMode
- * Signature: (Lorg/eclipse/swt/internal/photon/PgDisplaySettings_t;)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgGetVideoMode
-  (JNIEnv *env, jobject that, jobject settings)
-{
-	DECL_GLOB(pGlob)
-	PgDisplaySettings_t settings1 = {0}, *lpSettings1=&settings1;
-	jint result;
-	
-#ifdef DEBUG_CALL_PRINTS
-    fprintf(stderr, "PgGetVideoMode\n");
-#endif
-
-    result = (jint)PgGetVideoMode(lpSettings1);
-
-    if (settings) {
-        cachePgDisplaySettings_tFids(env, settings, &PGLOB(PgDisplaySettings_tFc));
-        setPgDisplaySettings_tFields(env, settings, lpSettings1, &PGLOB(PgDisplaySettings_tFc));
-    }
-	return result;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_photon_OS
- * Method:    PgGetVideoModeInfo
- * Signature: (ILorg/eclipse/swt/internal/photon/PgVideoModeInfo_t;)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgGetVideoModeInfo
-  (JNIEnv *env, jobject that, jint mode_number, jobject mode_info)
-{
-	DECL_GLOB(pGlob)	
-    PgVideoModeInfo_t mode_info1, *lpmode_info1=NULL;
-	jint result;
-	
-#ifdef DEBUG_CALL_PRINTS
-    fprintf(stderr, "PgGetVideoModeInfo\n");
-#endif
-
-	if (mode_info) {
-        lpmode_info1 = &mode_info1;
-        cachePgVideoModeInfo_tFids(env, mode_info, &PGLOB(PgVideoModeInfo_tFc));
-        getPgVideoModeInfo_tFields(env, mode_info, lpmode_info1, &PGLOB(PgVideoModeInfo_tFc));
-    }
-    result = (jint)PgGetVideoModeInfo(mode_number, lpmode_info1);
-
-    if (mode_info) {
-        setPgVideoModeInfo_tFields(env, mode_info, lpmode_info1, &PGLOB(PgVideoModeInfo_tFc));
-    }
-	return result;
-}
-
-/*

- * Class:     org_eclipse_swt_internal_photon_OS

- * Method:    PhClipboardCopy

- * Signature: (SI[B)I

- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhClipboardCopy

-  (JNIEnv *env, jclass that, jshort ig, jint n, jbyteArray clip)

-{	
-   jbyte *clip1;
-   jint result;
-   
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "PhClipboardCopy\n");
-#endif
-
-    if (clip) {
-        clip1 = (*env)->GetByteArrayElements(env, clip, NULL);
-    }
-    
-    result = (jint)PhClipboardCopy(ig, n, (PhClipHeader const *)clip1);
-    
-    if (clip) {
-        (*env)->ReleaseByteArrayElements(env, clip, clip1, 0);
-    }
-    
-    return result;
-}
-

-/*

- * Class:     org_eclipse_swt_internal_photon_OS

- * Method:    PhClipboardPasteStart

- * Signature: (S)I

- */

-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhClipboardPasteStart

-  (JNIEnv *env, jobject that, jshort ig)

-{

-#ifdef DEBUG_CALL_PRINTS

-    fprintf(stderr, "PhClipboardPasteStart\n");

-#endif

-	

-	return (jint) PhClipboardPasteStart(ig);

-}

-

-/*

- * Class:     org_eclipse_swt_internal_photon_OS

- * Method:    PhClipboardPasteType

- * Signature: (I[B)I

- */

-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhClipboardPasteType

-  (JNIEnv *env, jobject that, jint cbdata, jbyteArray type)

-{

-	 char *type1=NULL;

-	 jint result;

-

-#ifdef DEBUG_CALL_PRINTS

-    fprintf(stderr, "PhClipboardPasteType\n");

-#endif

-

- 	if (type)

-        type1 = (char *)(*env)->GetByteArrayElements(env, type, NULL);

-    	

-	result = (jint) PhClipboardPasteType((void *)cbdata, type1);

-	

-	if (type)

-        (*env)->ReleaseByteArrayElements(env, type, (jbyte *)type1, 0);

-        

-	return result;

-}

-

-/*

- * Class:     org_eclipse_swt_internal_photon_OS

- * Method:    PhClipboardPasteTypeN

- * Signature: (II)I

- */

-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhClipboardPasteTypeN

-  (JNIEnv *env, jobject that, jint cbdata, jint n)

-{

-

-#ifdef DEBUG_CALL_PRINTS

-	fprintf(stderr, "PhClipboardPasteTypeN\n");

-#endif

-	return (jint) PhClipboardPasteTypeN((void *)cbdata, n);

-}

-

-/*

- * Class:     org_eclipse_swt_internal_photon_OS

- * Method:    PhClipboardPasteFinish

- * Signature: (I)V

- */

-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PhClipboardPasteFinish

-  (JNIEnv *env, jobject that, jint cbdata)

-{

-#ifdef DEBUG_CALL_PRINTS

-    fprintf(stderr, "PhClipboardPasteFinish\n");

-#endif

-	

-	PhClipboardPasteFinish((void *)cbdata);

-	

-	return;

-}

-

-/*

- * Class:     org_eclipse_swt_internal_photon_OS

- * Method:    memmove

- * Signature: (Lorg/eclipse/swt/internal/photon/PhClipHeader;II)V

- */

-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_PhClipHeader_2II

-  (JNIEnv *env, jobject that, jobject dest, jint src, jint count)

-{

-	DECL_GLOB(pGlob)

-	PhClipHeader object, *dest1=NULL;

-#ifdef DEBUG_CALL_PRINTS

-	fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_PhClipHeader_2II\n");

-#endif

-

-    memmove((void *)&object, (void *)src, count);

-    if (dest) {

-        dest1=&object;

-        cachePhClipHeaderFids(env, dest, &PGLOB(PhClipHeaderFc));

-        setPhClipHeaderFields(env, dest, dest1, &PGLOB(PhClipHeaderFc));

-    }

-

-}

-

-/*

- * Class:     org_eclipse_swt_internal_photon_OS

- * Method:    memmove

- * Signature: ([BLorg/eclipse/swt/internal/photon/PhClipHeader;I)V

- */

-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove___3BLorg_eclipse_swt_internal_photon_PhClipHeader_2I

-  (JNIEnv *env, jobject that, jbyteArray dest, jobject src, jint count)

-{

-	DECL_GLOB(pGlob)

-	jbyte *dest1=NULL;

-    PhClipHeader object, *src1= NULL;

-    

-#ifdef DEBUG_CALL_PRINTS

-	fprintf(stderr, "memmove___3BLorg_eclipse_swt_internal_photon_PhClipHeader_2I\n");

-#endif

-

-    if (src) {

-        src1=&object;

-        cachePhClipHeaderFids(env, src, &PGLOB(PhClipHeaderFc));

-        getPhClipHeaderFields(env, src, src1, &PGLOB(PhClipHeaderFc));

-    }

-    

-    if (dest) {

-    	dest1 = (*env)->GetByteArrayElements(env, dest, NULL);

-    }

-    

-    memmove((void *)dest1, (void *)src1, count);

-    

-    if (dest) {

-    	 (*env)->ReleaseByteArrayElements(env, dest, (jbyte *)dest1, 0);

-    }

-}
-
-/*
- * Class:     org_eclipse_swt_internal_photon_OS
- * Method:    memmove
- * Signature: (ILorg/eclipse/swt/internal/photon/PhClipHeader;I)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove___ILorg_eclipse_swt_internal_photon_PhClipHeader_2I
-  (JNIEnv *env, jobject that, jint dest, jobject src, jint count)
-{
-	DECL_GLOB(pGlob)
-    PhClipHeader object, *src1= NULL;
-    
-#ifdef DEBUG_CALL_PRINTS
-	fprintf(stderr, "memmove___3BLorg_eclipse_swt_internal_photon_PhClipHeader_2I\n");
-#endif
-
-    if (src) {
-        src1=&object;
-        cachePhClipHeaderFids(env, src, &PGLOB(PhClipHeaderFc));
-        getPhClipHeaderFields(env, src, src1, &PGLOB(PhClipHeaderFc));
-    }
-    
-    memmove((void *)dest, (void *)src1, count);
-}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java
index 78f73d6..ff740b3 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java
@@ -94,13 +94,6 @@
 

 public Rectangle getBounds () {

 	checkDevice ();

-	PgDisplaySettings_t settings = new PgDisplaySettings_t ();

-	OS.PgGetVideoMode (settings);

-	return new Rectangle (0, 0, settings.xres, settings.yres);

-}

-

-public Rectangle getClientArea () {

-	checkDevice ();

 	PhRect_t rect = new PhRect_t ();

 	OS.PhWindowQueryVisible (OS.Ph_QUERY_GRAPHICS, 0, 1, rect);

 	int width = rect.lr_x - rect.ul_x + 1;

@@ -108,13 +101,14 @@
 	return new Rectangle (rect.ul_x, rect.ul_y, width, height);

 }

 

+public Rectangle getClientArea () {

+	return getBounds ();

+}

+

 public int getDepth () {

 	checkDevice ();

-	PgDisplaySettings_t settings = new PgDisplaySettings_t ();

-	OS.PgGetVideoMode (settings);

-	PgVideoModeInfo_t mode_info = new PgVideoModeInfo_t ();

-	OS.PgGetVideoModeInfo ((short) settings.mode, mode_info);

-	return mode_info.bits_per_pixel;

+	//NOT DONE

+	return 32;

 }

 

 public DeviceData getDeviceData () {

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java
index d7c2faf..fd9902b 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java
@@ -8,7 +8,6 @@
 import org.eclipse.swt.internal.*;

 import org.eclipse.swt.internal.photon.*;

 import org.eclipse.swt.*;

-import java.util.Locale;

 

 public final class FontData {

 

@@ -35,12 +34,6 @@
 	 * (Warning: This field is platform dependent)

 	 */

 	public byte[] stem;

-	

-	/**

-	 * The locale of the font

-	 * (Warning: This field is platform dependent)

-	 */

-	public Locale locale;

 

 FontData(byte[] stem) {

 	FontQueryInfo info = new FontQueryInfo();

@@ -164,7 +157,6 @@
 }

 

 public void setHeight(int height) {

-	if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 	this.height = height;

 }

 

@@ -172,10 +164,6 @@
 	this.name = name;

 }

 

-public void setLocale(Locale locale) {

-	this.locale = locale;

-}

-

 public void setStyle(int style) {

 	this.style = style;

 }

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 dea53ac..27bfe18 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
@@ -288,17 +288,6 @@
 

 public void drawArc (int x, int y, int width, int height, int startAngle, int endAngle) {

 	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

-	if (width < 0) {

-		x = x + width;

-		width = -width;

-	}

-	if (height < 0) {

-		y = y + height;

-		height = -height;

-	}

-	if (width == 0 || height == 0 || endAngle == 0) {

-		SWT.error(SWT.ERROR_INVALID_ARGUMENT);

-	}

 	if (startAngle > 0) {

 		if (endAngle > 0) {

 			//No need to modify start angle.

@@ -324,8 +313,21 @@
 			endAngle = newStopAngle;			

 		}

 	}

+			

 	startAngle = (int) (startAngle * 65536 / 360);

 	endAngle   = (int) (endAngle * 65536 / 360);

+	

+	if (width < 0) {

+		x = x + width;

+		width = -width;

+	}

+	if (height < 0) {

+		y = y + height;

+		height = -height;

+	}

+	if (width == 0 || height == 0 || endAngle == 0) {

+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);

+	}

 

 	PhPoint_t center = new PhPoint_t();

 	center.x = (short)(x + (width / 2));

@@ -630,55 +632,64 @@
 		

 		/* Scale alpha data */

 		if (alpha.src_alpha_map_map != 0) {

-			int[] palette = new int[256];

-			for (int i = 0; i < palette.length; i++) {

-				palette[i] = i;

-			}

-			int palettePtr = OS.malloc(palette.length * 4);

-			OS.memmove(palettePtr, palette, palette.length * 4);

-			/*

-			* Feature on Photon - It is only possible to draw on images of

-			* type Pg_IMAGE_PALETTE_BYTE and Pg_IMAGE_DIRECT_888.

-			*/

-			int alphaImage = OS.PhCreateImage(null, (short)destWidth, (short)destHeight, OS.Pg_IMAGE_PALETTE_BYTE, palettePtr, palette.length, 0);

-			if (alphaImage == 0) {

-				OS.free(palettePtr);

-				OS.free(alphaPtr);

-				Image.destroyImage(memImage);

-				SWT.error(SWT.ERROR_NO_HANDLES);

-			}

-			mc = OS.PmMemCreateMC(alphaImage, scale, trans);

-			if (mc == 0) {

-				OS.free(palettePtr);

-				OS.free(alphaPtr);

-				Image.destroyImage(alphaImage);

-				Image.destroyImage(memImage);

-				SWT.error(SWT.ERROR_NO_HANDLES);

-			}

-			OS.PmMemStart(mc);

-			OS.PgSetPalette(palettePtr, 0, (short)0, (short)palette.length, OS.Pg_PALSET_SOFT, 0);

-			OS.PgDrawImage(alpha.src_alpha_map_map, OS.Pg_IMAGE_PALETTE_BYTE, pos, dim, alpha.src_alpha_map_bpl, 0);

-			OS.PgSetPalette(0, 0, (short)0, (short)-1, 0, 0);

-			OS.PmMemFlush(mc, alphaImage);

-			OS.PmMemStop(mc);

-			OS.PmMemReleaseMC(mc);

-			OS.free(palettePtr);

-				

-			/* Transfer the image to the scaled image alpha data*/

-			PhImage_t phAlphaImage = new PhImage_t();

-			OS.memmove(phAlphaImage, alphaImage, PhImage_t.sizeof);

-			alpha.src_alpha_map_bpl = (short)phAlphaImage.bpl;

-			alpha.src_alpha_map_dim_w = (short)phAlphaImage.bpl;

-			alpha.src_alpha_map_dim_h = (short)phAlphaImage.size_h;

-			alpha.src_alpha_map_map = phAlphaImage.image;

-

-			/* Release the temporary image but not the image data */

-			phAlphaImage.image = 0;

-			phAlphaImage.bpl = 0;

-			phAlphaImage.flags = OS.Ph_RELEASE_IMAGE_ALL;

-			OS.memmove(alphaImage, phAlphaImage, PhImage_t.sizeof);

-			OS.PhReleaseImage(alphaImage);

-			OS.free(alphaImage);

+//			int[] palette = new int[256];

+//			for (int i = 0; i < palette.length; i++) {

+//				palette[i] = i;

+//			}

+//			int palettePtr = OS.malloc(palette.length * 4);

+//			OS.memmove(palettePtr, palette, palette.length * 4);

+//			/*

+//			* Feature on Photon - It is only possible to draw on images of

+//			* type Pg_IMAGE_PALETTE_BYTE and Pg_IMAGE_DIRECT_888.

+//			*/

+//			int alphaImage = OS.PhCreateImage(null, (short)destWidth, (short)destHeight, OS.Pg_IMAGE_PALETTE_BYTE, palettePtr, palette.length, 0);

+//			if (alphaImage == 0) {

+//				Image.destroyImage(memImage);

+//				SWT.error(SWT.ERROR_NO_HANDLES);

+//			}

+//			mc = OS.PmMemCreateMC(alphaImage, scale, trans);

+//			if (mc == 0) {

+//				Image.destroyImage(alphaImage);

+//				Image.destroyImage(memImage);

+//				SWT.error(SWT.ERROR_NO_HANDLES);

+//			}

+//			OS.PmMemStart(mc);

+//			OS.PgSetPalette(palettePtr, 0, (short)0, (short)palette.length, OS.Pg_PALSET_SOFT, 0);

+//			OS.PgDrawImage(alpha.src_alpha_map_map, OS.Pg_IMAGE_PALETTE_BYTE, pos, dim, alpha.src_alpha_map_bpl, 0);

+//			OS.PgSetPalette(0, 0, (short)0, (short)-1, 0, 0);

+//			OS.PmMemFlush(mc, alphaImage);

+//			OS.PmMemStop(mc);

+//			OS.PmMemReleaseMC(mc);

+//			OS.free(palettePtr);

+//				

+//			/* Transfer the image to the scaled image alpha data*/

+//			PhImage_t phAlphaImage = new PhImage_t();

+//			OS.memmove(phAlphaImage, alphaImage, PhImage_t.sizeof);

+//			alpha.src_alpha_map_dim_w = (short)phAlphaImage.bpl;

+//			alpha.src_alpha_map_dim_h = (short)phAlphaImage.size_h;

+//			alpha.src_alpha_map_map = phAlphaImage.image;

+//

+//			/* Release the temporary image but not the image data */

+//			phAlphaImage.image = 0;

+//			phAlphaImage.bpl = 0;

+//			phAlphaImage.flags = OS.Ph_RELEASE_IMAGE_ALL;

+//			OS.memmove(alphaImage, phAlphaImage, PhImage_t.sizeof);

+//			OS.PhReleaseImage(alphaImage);

+//			OS.free(alphaImage);

+			

+			// The code above can not be used because it generates an image with

+			// scanline padding.  It seems that Photon does not accept

+			// padding in src_alpha_map, even though there is a field to specify

+			// the number of bytes per line - src_alpha_map_map_bpl.

+			byte[] srcAlphaData = new byte[alpha.src_alpha_map_dim_w * alpha.src_alpha_map_dim_h];

+			OS.memmove(srcAlphaData, alpha.src_alpha_map_map, srcAlphaData.length);

+			byte[] destAlphaData = new byte[destWidth * destHeight];

+			ImageData.stretch8(srcAlphaData, alpha.src_alpha_map_dim_w, 0, 0, srcWidth, srcHeight, destAlphaData, destWidth, 0, 0, destWidth, destHeight, null, false, false);

+			int ptr = OS.malloc(destAlphaData.length);

+			OS.memmove(ptr, destAlphaData, destAlphaData.length);

+			alpha.src_alpha_map_dim_w = (short)destWidth;

+			alpha.src_alpha_map_dim_h = (short)destHeight;

+			alpha.src_alpha_map_map = ptr;

 		}

 

 		OS.memmove(alphaPtr, alpha, PgAlpha_t.sizeof);

@@ -835,16 +846,15 @@
 	string = replaceTabs(string, 8);

 	byte[] buffer = Converter.wcsToMbcs(null, string, false);

 	PhRect_t rect = new PhRect_t();

+	rect.ul_x = (short)x;

+	rect.ul_y = (short)y;

+	rect.lr_x = (short)0xFFFF;

+	rect.lr_y = (short)0xFFFF;

 

 	int flags = OS.PtEnter(0);

 	try {

 		int prevContext = setGC();	

 		setGCClipping();

-		OS.PgExtentMultiText(rect, null, data.font, buffer, buffer.length, 0);

-		rect.lr_x += (short)(x - rect.ul_x);

-		rect.lr_y += (short)(y - rect.ul_y);

-		rect.ul_x = (short)x;

-		rect.ul_y = (short)y;

 		OS.PgDrawMultiTextArea(buffer, buffer.length, rect, drawFlags, OS.Pg_TEXT_LEFT | OS.Pg_TEXT_TOP, 0);

 		unsetGC(prevContext);

 	} finally {

@@ -858,17 +868,6 @@
 

 public void fillArc (int x, int y, int width, int height, int startAngle, int endAngle) {

 	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

-	if (width < 0) {

-		x = x + width;

-		width = -width;

-	}

-	if (height < 0) {

-		y = y + height;

-		height = -height;

-	}

-	if (width == 0 || height == 0 || endAngle == 0) {

-		SWT.error(SWT.ERROR_INVALID_ARGUMENT);

-	}

 	if (startAngle > 0) {

 		if (endAngle > 0) {

 			//No need to modify start angle.

@@ -893,10 +892,23 @@
 			startAngle = newStopAngle - Math.abs(endAngle);

 			endAngle = newStopAngle;			

 		}

-	}			

+	}

+			

 	startAngle = (int) (startAngle * 65536 / 360);

 	endAngle   = (int) (endAngle * 65536 / 360);

 	

+	if (width < 0) {

+		x = x + width;

+		width = -width;

+	}

+	if (height < 0) {

+		y = y + height;

+		height = -height;

+	}

+	if (width == 0 || height == 0 || endAngle == 0) {

+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);

+	}

+	

 	PhPoint_t center = new PhPoint_t();

 	center.x = (short)(x + (width / 2));

 	center.y = (short)(y + (height / 2));

@@ -915,71 +927,15 @@
 	}

 }

 

-/**

- * Fills the interior of the specified rectangle with a gradient

- * sweeping from left to right or top to bottom progressing

- * from the receiver's foreground color to its background color.

- *

- * @param x the x coordinate of the rectangle to be filled

- * @param y the y coordinate of the rectangle to be filled

- * @param width the width of the rectangle to be filled, may be negative

- *        (inverts direction of gradient if horizontal)

- * @param height the height of the rectangle to be filled, may be negative

- *        (inverts direction of gradient if vertical)

- * @param vertical if true sweeps from top to bottom, else 

- *        sweeps from left to right

- *

- * @exception SWTException <ul>

- *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>

- * </ul>

- *

- * @see #drawRectangle

- */

-public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {

-	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

-	if ((width == 0) || (height == 0)) return;

-	int fromColor = data.foreground;

-	int toColor = data.background;

-	boolean swapColors = false;

-	if (width < 0) {

-		x += width; width = -width;

-		if (! vertical) swapColors = true;

-	}

-	if (height < 0) {

-		y += height; height = -height;

-		if (vertical) swapColors = true;

-	}

-	if (swapColors) {

-		final int t = toColor;

-		toColor = fromColor;

-		fromColor = t;

-	}

-	PhPoint_t upperLeft = new PhPoint_t();

-	upperLeft.x = (short)x;

-	upperLeft.y = (short)y;

-	PhPoint_t lowerRight = new PhPoint_t();

-	lowerRight.x = (short)(x + width - 1);

-	lowerRight.y = (short)(y + height - 1);

-	int flags = OS.PtEnter(0);

-	try {

-		int prevContext = setGC();	

-		setGCClipping();

-		OS.PgDrawGradient(upperLeft, lowerRight,

-			vertical ? OS.Pg_GRAD_VERTICAL : OS.Pg_GRAD_HORIZONTAL, OS.Pg_GRAD_LINEAR,

-			vertical ? height : width, fromColor, toColor, 0, 0, 0, null);

-		unsetGC(prevContext);

-	} finally {

-		if (flags >= 0) OS.PtLeave(flags);

-	}

-}

-

 public void fillOval (int x, int y, int width, int height) {

 	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

 	PhPoint_t center = new PhPoint_t();

 	center.x = (short)x; center.y = (short)y;

 	PhPoint_t radii = new PhPoint_t();

 	radii.x = (short)(x + width);

+	if (width != 2) radii.x--;

 	radii.y = (short)(y + height);

+	if (height != 2) radii.y--;

 

 	int flags = OS.PtEnter(0);

 	try {

@@ -1415,19 +1371,23 @@
 void setGCClipping() {

 	int rid = data.rid;

 	int widget = data.widget;

+	int topWidget = data.topWidget;

 	if (rid == OS.Ph_DEV_RID) OS.PgSetRegion(rid);

 	else if (widget != 0) OS.PgSetRegion(OS.PtWidgetRid(widget));

 	else if (data.image != null) return;

 	

-	/* NOTE: PgSetRegion resets the clipping rectangle */

+	// NOTE: PgSetRegion resets the clipping rectangle to the full size of

+	// the region.

 	OS.PgSetMultiClip(data.clipRectsCount, data.clipRects);	

 

 	if (widget == 0) return;

 	

-	int clip_tile = getClipping(widget, data.topWidget, true, true);

+	int clip_tile = getClipping(widget, topWidget, true, true);

 	int[] clip_rects_count = new int[1];

 	int clip_rects = OS.PhTilesToRects(clip_tile, clip_rects_count);

-	OS.PhFreeTiles(clip_tile);	

+	OS.PhFreeTiles(clip_tile);

+	

+	/* PgSetClipping sets the clipping to the full region when the count is zero */

 	if (clip_rects_count[0] == 0) {

 		clip_rects_count[0] = 1;

 		OS.free(clip_rects);

@@ -1440,12 +1400,9 @@
 int getClipping(int widget, int topWidget, boolean clipChildren, boolean clipSiblings) {

 	int child_tile = 0;

 	int widget_tile = OS.PhGetTile(); // NOTE: PhGetTile native initializes the tile

-

-	PhRect_t rect = new PhRect_t ();

-	int args [] = {OS.Pt_ARG_FLAGS, 0, 0, OS.Pt_ARG_BASIC_FLAGS, 0, 0};

-	

+			

 	/* Get the rectangle of all siblings in front of the widget */

-	if (clipSiblings && OS.PtWidgetClass(topWidget) != OS.PtWindow()) {

+	if (clipSiblings) {

 		int temp_widget = topWidget;

 		while ((temp_widget = OS.PtWidgetBrotherInFront(temp_widget)) != 0) {

 			if (OS.PtWidgetIsRealized(temp_widget)) {

@@ -1453,17 +1410,6 @@
 				if (child_tile == 0) child_tile = tile;			

 				else child_tile = OS.PhAddMergeTiles(tile, child_tile, null);

 				OS.PtWidgetExtent(temp_widget, tile); // NOTE: tile->rect

-				args [1] = args [4] = 0;

-				OS.PtGetResources(temp_widget, args.length / 3, args);

-				if ((args [1] & OS.Pt_HIGHLIGHTED) != 0) {

-					int basic_flags = args [4];

-					OS.memmove(rect, tile, PhRect_t.sizeof);

-					if ((basic_flags & OS.Pt_TOP_ETCH) != 0) rect.ul_y++;

-					if ((basic_flags & OS.Pt_BOTTOM_ETCH) != 0) rect.lr_y--;

-					if ((basic_flags & OS.Pt_RIGHT_ETCH) != 0) rect.ul_x++;

-					if ((basic_flags & OS.Pt_LEFT_ETCH) != 0) rect.lr_x--;

-					OS.memmove(tile, rect, PhRect_t.sizeof);

-				}

 			}

 		}

 		/* Translate the siblings rectangles to the widget's coordinates */

@@ -1480,17 +1426,6 @@
 				if (child_tile == 0) child_tile = tile;			

 				else child_tile = OS.PhAddMergeTiles(tile, child_tile, null);

 				OS.PtWidgetExtent(temp_widget, tile); // NOTE: tile->rect

-				args [1] = args [4] = 0;

-				OS.PtGetResources(temp_widget, args.length / 3, args);

-				if ((args [1] & OS.Pt_HIGHLIGHTED) != 0) {

-					int basic_flags = args [4];

-					OS.memmove(rect, tile, PhRect_t.sizeof);

-					if ((basic_flags & OS.Pt_TOP_ETCH) != 0) rect.ul_y++;

-					if ((basic_flags & OS.Pt_BOTTOM_ETCH) != 0) rect.lr_y--;

-					if ((basic_flags & OS.Pt_RIGHT_ETCH) != 0) rect.ul_x++;

-					if ((basic_flags & OS.Pt_LEFT_ETCH) != 0) rect.lr_x--;

-					OS.memmove(tile, rect, PhRect_t.sizeof);

-				}

 			}

 			temp_widget = OS.PtWidgetBrotherInFront(temp_widget);

 		}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java
index f725ef4..2dc3f90 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java
@@ -384,9 +384,8 @@
 	if (i.depth == 1 || i.depth == 2) {

 		ImageData img = new ImageData(i.width, i.height, 4, i.palette);

 		ImageData.blit(ImageData.BLIT_SRC, 

-			i.data, i.depth, i.bytesPerLine, img.getByteOrder(), 0, 0, i.width, i.height, null, null, null,

-			ImageData.ALPHA_OPAQUE, null, 0,

-			img.data, img.depth, img.bytesPerLine, img.getByteOrder(), 0, 0, img.width, img.height, null, null, null, 

+			i.data, i.depth, i.bytesPerLine, ImageData.MSB_FIRST, 0, 0, i.width, i.height, null, null, null, -1, null, 0,

+			img.data, img.depth, img.bytesPerLine, ImageData.MSB_FIRST, 0, 0, img.width, img.height, null, null, null, 

 			false, false);

 		img.transparentPixel = i.transparentPixel;

 		img.maskPad = i.maskPad;

@@ -411,23 +410,15 @@
 			phPalette[j] = ((rgb.red & 0xFF) << 16) | ((rgb.green & 0xFF) << 8) | (rgb.blue & 0xFF);

 		}

 	} else {

-		final PaletteData palette = i.palette;

-		final int redMask = palette.redMask;

-		final int greenMask = palette.greenMask;

-		final int blueMask = palette.blueMask;

-		int newDepth = i.depth;

-		int newOrder = ImageData.MSB_FIRST;

 		PaletteData newPalette = null;

-

+		PaletteData palette = i.palette;

+		int redMask = palette.redMask;

+		int greenMask = palette.greenMask;

+		int blueMask = palette.blueMask;

+		int order = ImageData.MSB_FIRST;

 		switch (i.depth) {

-			case 8:

-				newDepth = 16;

-				newOrder = ImageData.LSB_FIRST;

-				newPalette = new PaletteData(0xF800, 0x7E0, 0x1F);

-				type = OS.Pg_IMAGE_DIRECT_565;

-				break;

 			case 16:

-				newOrder = ImageData.LSB_FIRST;

+				order = ImageData.LSB_FIRST;

 				if (redMask == 0x7C00 && greenMask == 0x3E0 && blueMask == 0x1F) {

 					type = OS.Pg_IMAGE_DIRECT_555;

 				} else if (redMask == 0xF800 && greenMask == 0x7E0 && blueMask == 0x1F) {

@@ -459,11 +450,10 @@
 				SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);

 		}

 		if (newPalette != null) {

-			ImageData img = new ImageData(i.width, i.height, newDepth, newPalette);

+			ImageData img = new ImageData(i.width, i.height, i.depth, newPalette);

 			ImageData.blit(ImageData.BLIT_SRC, 

-					i.data, i.depth, i.bytesPerLine, i.getByteOrder(), 0, 0, i.width, i.height, redMask, greenMask, blueMask,

-					ImageData.ALPHA_OPAQUE, null, 0,

-					img.data, img.depth, img.bytesPerLine, newOrder, 0, 0, img.width, img.height, newPalette.redMask, newPalette.greenMask, newPalette.blueMask,

+					i.data, i.depth, i.bytesPerLine, order, 0, 0, i.width, i.height, redMask, greenMask, blueMask, -1, null, 0,

+					img.data, img.depth, img.bytesPerLine, order, 0, 0, img.width, img.height, newPalette.redMask, newPalette.greenMask, newPalette.blueMask,

 					false, false);

 			if (i.transparentPixel != -1) {

 				img.transparentPixel = newPalette.getPixel(palette.getRGB(i.transparentPixel));

@@ -541,7 +531,6 @@
 					SWT.error(SWT.ERROR_NO_HANDLES);

 				}

 				OS.memmove(ptr, i.alphaData, i.alphaData.length);

-				alpha.src_alpha_map_bpl = (short)i.width;

 				alpha.src_alpha_map_dim_w = (short)i.width;

 				alpha.src_alpha_map_dim_h = (short)i.height;

 				alpha.src_alpha_map_map = ptr;

@@ -563,7 +552,6 @@
 }

 

 public int internal_new_GC (GCData data) {

-	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

 	/*

 	* Create a new GC that can draw into the image.

 	* Only supported for bitmaps.

@@ -594,40 +582,6 @@
 	return handle == 0;

 }

 

-/**

- * Sets the color to which to map the transparent pixel.

- * <p>

- * There are certain uses of <code>Images</code> that do not support

- * transparency (for example, setting an image into a button or label).

- * In these cases, it may be desired to simulate transparency by using

- * the background color of the widget to paint the transparent pixels

- * of the image. This method specifies the color that will be used in

- * these cases. For example:

- * <pre>

- *    Button b = new Button();

- *    image.setBackground(b.getBackground());>

- *    b.setImage(image);

- * </pre>

- * </p><p>

- * The image may be modified by this operation (in effect, the

- * transparent regions may be filled with the supplied color).  Hence

- * this operation is not reversible and it is not legal to call

- * this function twice or with a null argument.

- * </p><p>

- * This method has no effect if the receiver does not have a transparent

- * pixel value.

- * </p>

- *

- * @param color the color to use when a transparent pixel is specified

- *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the color is null</li>

- *    <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>

- * </ul>

- * @exception SWTException <ul>

- *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>

- * </ul>

- */

 public void setBackground(Color color) {

 	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

 	if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Region.java
index 049a782..dda73e3 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Region.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Region.java
@@ -29,7 +29,6 @@
 public void add (Rectangle rect) {

 	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

 	if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

-	if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 	if (handle == 0) return;

 	int tile_ptr = OS.PhGetTile();

 	PhTile_t tile = new PhTile_t();

@@ -45,9 +44,8 @@
 public void add (Region region) {

 	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

 	if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

-	if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 	if (handle == 0) return;

-	if (region.handle == EMPTY_REGION) return;

+	if (region.handle == 0 || region.handle == EMPTY_REGION) return;

 	int copy = OS.PhCopyTiles(region.handle);

 	if (handle == EMPTY_REGION) handle = copy;

 	else handle = OS.PhAddMergeTiles (handle, copy, null);

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/OS.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/OS.java
index 7e4550d..2c83686 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/OS.java
@@ -124,27 +124,6 @@
 //	public static final int Pg_BLEND_DST_DST_ALPHA                          = 0x06;		// (Ad,Ad,Ad,Ad)

 //	public static final int Pg_BLEND_DST_ONE_MINUS_DST_ALPHA                = 0x07;		// (1,1,1,1)-(Ad,Ad,Ad,Ad)

 

-//	public static final int Pg_GRAD_BYTES_PER_PIXEL = 3;

-//	public static final int Pg_GRAD_IMAGE_TYPE  = Pg_IMAGE_DIRECT_888;

-//	public static final int Pg_GRAD_BOXY        = 0x80000000;

-//	public static final int Pg_GRAD_NOGRADIENT  = 0;

-//	public static final int Pg_GRAD_VECTOR      = 1;

-//	public static final int Pg_GRAD_RADIAL      = 2;

-	public static final int Pg_GRAD_HORIZONTAL  = 3;

-	public static final int Pg_GRAD_VERTICAL    = 4;

-//	public static final int Pg_GRAD_FAST_VECTOR = 5;

-//	public static final int Pg_GRAD_DIAGF       = 6;

-//	public static final int Pg_GRAD_DIAGB       = 7;

-//	public static final int Pg_GRAD_4POINT      = 8;

-//	public static final int Pg_GRAD_BOX_DIAGF   = Pg_GRAD_DIAGF | Pg_GRAD_BOXY;

-//	public static final int Pg_GRAD_BOX_DIAGB   = Pg_GRAD_DIAGB | Pg_GRAD_BOXY;

-//	public static final int Pg_GRAD_BOX_4POINT  = Pg_GRAD_4POINT | Pg_GRAD_BOXY;

-//	public static final int Pg_GRAD_TABLE       = 100;

-	public static final int Pg_GRAD_LINEAR      = 0;

-//	public static final int Pg_GRAD_HILL        = 1;

-//	public static final int Pg_GRAD_HILL2       = 2;

-//	public static final int Pg_GRAD_EXP         = 3;

-

 //	public static final int Pt_ARG_PG_FLAGS		 			= 64 * 1000 + 0;

 //	public static final int Pt_ARG_PG_CURRENT					= 64 * 1000 + 1;

 	public static final int Pt_ARG_PG_PANEL_TITLES				= 64 * 1000 + 2;

@@ -197,11 +176,6 @@
 	public static final int Pt_ARG_MODIFIER_KEYS                                    = ( 7 * 1000 + 4 );

 

 	public static final byte [] Pg_PAT_HALF = {(byte)0xAA, (byte)0x55, (byte)0xAA, (byte)0x55, (byte)0xAA, (byte)0x55, (byte)0xAA, (byte)0x55};

-

-	public static final int Pt_ARG_BEVEL_CONTRAST                                    = ( 2 * 1000 + 20 );

-

-	public static final int Pt_NO_PARENT	                                    = 1;

-

 /*** END MANUALLY ADDED/FIXED ***/

 

 //public static final int Aw_ARG_ONOFF_STATE                                    = ( 5 * 1000 + 1 );

@@ -1091,7 +1065,7 @@
 	public static final int Ph_WM_STATE_ISICONIFIED                               = 0x00000040;

 //public static final int Ph_WM_STATE_ISMASK                                    = 0x0000FFFF;

 	public static final int Ph_WM_STATE_ISMAX                                     = 0x00000002;

-	public static final int Ph_WM_STATE_ISMAXING                                  = 0x00004000;

+//public static final int Ph_WM_STATE_ISMAXING                                  = 0x00004000;

 //public static final int Ph_WM_STATE_ISNORMAL                                  = 0x00000000;

 //public static final int Ph_WM_STATE_ISPDM                                     = 0x00000020;

 //public static final int Ph_WM_STATE_ISREMOTE                                  = 0x00000400;

@@ -2576,7 +2550,6 @@
 public static final native void PgDestroyGC (int GC);

 public static final native int PgDrawArc (PhPoint_t center, PhPoint_t radii, int start, int end, int flags);

 public static final native int PgDrawEllipse (PhPoint_t center, PhPoint_t radii, int flags);

-public static final native int PgDrawGradient (PhPoint_t ul, PhPoint_t lr, int gradient_type, int transition_type, int num_color_pts, int color1, int color2, int color3, int color4, int table_size, byte[] transition_table);

 public static final native int PgDrawPolygon (short[] ptr, int num, PhPoint_t pos, int flags);

 public static final native int PgDrawRoundRect (PhRect_t rect, PhPoint_t radii, int flags);

 public static final native int PgDrawILine (int x1, int y1, int x2, int y2);

@@ -2737,6 +2710,7 @@
 

 public static final native int PtTextModifyText (int widget, int start, int end, int insert_pos, byte [] text, int length);

 public static final native int PtTextModifyText (int widget, int start, int end, int insert_pos, int text, int length);

+public static final native int PhClipboardCopyString (short ig, byte [] string);

 public static final native int PtTextGetSelection (int widget, int [] start, int [] end);

 public static final native int PtTextSetSelection (int widget, int [] start, int [] end);

 

@@ -2832,8 +2806,10 @@
 public static final native void PtWindowToFront (int widget);

 public static final native int PtFindDisjoint (int widget);

 

+//public static final native int PhClipboardCopyString (short ig, int string);

+public static final native int PhClipboardPasteString (short ig);

+

 public static final native int PtBlockAllWindows(int skip, short cursor, int cursor_color);

-public static final native int PtBlockWindow(int window, short cursor, int cursor_color);

 public static final native void PtUnblockWindows(int bl);

 public static final native int PtNextTopLevelWidget(int widget);

 public static final native int PtWindowGetState(int widget);

@@ -2948,24 +2924,4 @@
 

 public static final native int PtInflateBalloon (int win, int me, int position, byte [] string, byte [] font, int fill, int text_color);

 

-//public static final native void memmove (PgDisplaySettings_t dest, int src, int size);

-//public static final native void memmove (int dest, PgDisplaySettings_t src, int size);

-

-//public static final native void memmove (PgVideoModeInfo_t dest, int src, int size);

-//public static final native void memmove (int dest, PgVideoModeInfo_t src, int size);

-

-public static final native int PgGetVideoMode (PgDisplaySettings_t settings);

-public static final native int PgGetVideoModeInfo (short mode_number, PgVideoModeInfo_t mode_info);

-

-public static final native void memmove (PhClipHeader dest, int src, int size);

-public static final native void memmove (int dest, PhClipHeader src, int size);

-public static final native void memmove (byte[] dest, PhClipHeader src, int size);

-

-public static final native int PhClipboardCopyString (short ig, byte [] string);

-public static final native int PhClipboardPasteString (short ig);

-public static final native int PhClipboardCopy (short ig, int n, byte[] clip);

-public static final native int PhClipboardPasteStart (short ig);

-public static final native int PhClipboardPasteType (int cbdata, byte[] type);

-public static final native int PhClipboardPasteTypeN (int cbdata, int n);

-public static final native void PhClipboardPasteFinish (int cbdata);

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java
index 4aa5622..1f0d221 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java
@@ -10,8 +10,9 @@
 	public int key_flags;

 	public int key_cap;

 	public int key_sym;

-	public short key_scan;

-	public short key_zero;

+	public byte key_scan;

+	public byte key_zero1;

+	public short key_zero2;

 //	PhPoint_t pos;

 	public short pos_x;

 	public short pos_y;

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/AbstractTreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/AbstractTreeItem.java
new file mode 100755
index 0000000..41f7d95
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/AbstractTreeItem.java
@@ -0,0 +1,313 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+

+import org.eclipse.swt.*;

+import org.eclipse.swt.graphics.*;

+import java.util.*;

+

+/** 

+ * This class stores and manages child items of a tree item.

+ * It provides protocol to query the index of an item relative 

+ * to the root and to retrieve items by index.

+ * The TreeItem class implements this protocol for general

+ * tree items.

+ * TreeRoots provides a special implementation that allows the 

+ * Tree class to treat trees with one root and with multiple 

+ * roots equally.

+ */

+abstract class AbstractTreeItem extends SelectableItem {

+	private Vector children;

+	private boolean isExpanded = false;		

+	// number of children. 

+	// includes all expanded items down to the leafs.

+	private int visibleItemCount = 0;

+

+/**

+ * Create a new instance of the receiver.

+ * @param parent - widget the receiver belongs to

+ * @param swtStyle - widget style. see Widget class for details

+ */

+AbstractTreeItem(Tree parent, int swtStyle) {

+	super(parent, swtStyle);

+}

+/**

+ * Insert 'item' in the list of child items. Notify the 

+ * parent about the new item.

+ * @param 'item' - the item that should be added to the 

+ *	receiver's children.

+ * @param index - position that 'item' will be inserted at

+ *	in the receiver.

+ */

+void add(TreeItem item, int index) {

+	Vector items = getChildren();

+	int visibleIndex = getVisibleIndex();

+	

+	if (index < 0 || index > items.size()) {

+		error(SWT.ERROR_INVALID_RANGE);

+	}

+	if (item.isRoot()) {

+		visibleIndex = index;

+	}

+	else

+	if (isExpanded == false) {

+		visibleIndex = -1;

+	}

+	if (visibleIndex != -1) {

+		if (index > 0) {

+			TreeItem previousChild = (TreeItem) getChildren().elementAt(index - 1);

+			visibleIndex = previousChild.getVisibleIndex() + previousChild.getVisibleItemCount() + 1;

+		}

+		else {

+			 visibleIndex = getVisibleIndex() + 1;

+		}

+	}

+	getSelectableParent().addingItem(item, visibleIndex);

+	item.setIndex(index);

+	resetChildIndices(index, true);

+	items.insertElementAt(item, index);

+	if (isExpanded == true) {

+		visibleItemCount++;

+		calculateVisibleItemCountParent();

+	}

+	getSelectableParent().addedItem(item, visibleIndex);

+}

+/** 

+ * Set whether the receiver is expanded or not. 

+ * If the receiver is expanded its child items are visible.

+ * @param expanded - 

+ *	true=the receiver is expanded, making its child items visible.

+ * 	false=the receiver is collapsed, making its child items invisible 

+ */

+void internalSetExpanded(boolean expanded) {

+	isExpanded = expanded;

+	calculateVisibleItemCount();

+}

+/**

+ * Calculate the number of expanded children.

+ * Recurse up in the tree to the root item.

+ */

+abstract void calculateVisibleItemCount();

+/**

+ * Calculate the number of expanded children for the parent item

+ * of this item.

+ */

+abstract void calculateVisibleItemCountParent();

+/**

+ * Deselect the receiver and all children

+ */

+void deselectAll() {

+	Enumeration children = getChildren().elements();

+	AbstractTreeItem treeItem;

+

+	setSelected(false);

+	while (children.hasMoreElements() == true) {

+		treeItem = (AbstractTreeItem) children.nextElement();

+		treeItem.deselectAll();

+	}

+}

+public void dispose() {

+	if (!isValidWidget ()) return;

+	Vector children = getChildren();

+	AbstractTreeItem child;

+	while (children.size() > 0) {		// TreeItem objects are removed from vector during dispose

+		child = (AbstractTreeItem) children.firstElement();

+		child.dispose();

+	}

+	super.dispose();

+}

+void doDispose() {

+	setChildren(null);

+	visibleItemCount = 0;

+	super.doDispose();

+}

+/**

+ * Answer the Vector containing the child items of the receiver.

+ */

+Vector getChildren() {

+	if (children == null) {

+		children = new Vector(4);

+	}

+	return children;

+}

+/**

+ * Answer whether the receiver is expanded or not. 

+ * If the receiver is expanded its children are visible.

+ * @return 

+ *	true - the receiver is expanded, making its children visible

+ * 	false - the receiver is collapsed, making its children invisible 

+ */

+public boolean getExpanded() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return isExpanded;

+}

+/**

+ * Answer the number of children.

+ */

+public int getItemCount() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return getChildren().size();

+}

+/**

+ * Answer the index of the receiver relative to the first root 

+ * item.

+ * If 'anIndex' is the global index of the expanded item 'anItem' 

+ * then the following expressions are true:

+ * 'anItem  == theRoot.getVisibleItem(anIndex)' and

+ * 'anIndex == anItem.getVisibleIndex()'

+ * @return

+ *	The index of the receiver relative to the first root item.

+ *	Answer -1 if the receiver is not visible (because the parent 

+ *	is collapsed).

+ */

+abstract int getVisibleIndex();

+/**

+ * Answer the index of the child item identified by 'childIndex' 

+ * relative to the first root item.

+ */

+abstract int getVisibleIndex(int childIndex);

+/**

+ * Answer the item at 'searchIndex' relativ to the receiver.

+ * When this method is called for the root item, 'searchIndex' 

+ * represents the global index into all items of the tree.

+ * searchIndex=0 returns the receiver. 

+ * searchIndex=1 returns the first visible child.

+ * Note: searchIndex must be >= 0

+ *

+ * Note: 

+ * Visible in this context does not neccessarily mean that the 

+ * item is displayed on the screen. Visible here means that all 

+ * the parents of the item are expanded. An item is only 

+ * visible on screen if it is within the receiver's parent's 

+ * client area.

+ */

+abstract TreeItem getVisibleItem(int searchIndex);

+/**

+ * Answer the number of expanded children, direct and indirect.

+ */

+int getVisibleItemCount() {

+	return visibleItemCount;

+}

+/**

+ * Returns the expanded state. Circumvent widget/thread check 

+ * for performance. For non-API callers only.

+ */

+boolean internalGetExpanded() {

+	return isExpanded;

+}

+/**

+ * Answer whether the receiver is a leaf item.

+ * An item is a leaf when it has no child items.

+ * @return

+ *	true - receiver is a leaf item

+ *	false - receiver is not a leaf item.

+ */

+boolean isLeaf() {

+	return (getChildren().size() == 0);

+}

+/**

+ * Answer whether the receiver is a root item.

+ * The receiver is a root item when it doesn't have a parent item.

+ * @return 

+ *	true - the receiver is a root item.

+ * 	false - the receiver is not a root item.

+ */

+boolean isRoot() {

+	return false;

+}

+/** 

+ * Remove 'child' from the receiver. 

+ * Notify the parent widget only if it is not being disposed itself.

+ */

+void removeItem(SelectableItem child) {

+	Vector children = getChildren();

+	SelectableItemWidget parent = getSelectableParent();

+	int childIndex = children.indexOf(child);

+

+	if (childIndex != -1) {

+		if (((Tree) parent).isRemovingAll() == true) {

+			children.removeElementAt(childIndex);		// just remove the item from the list if the whole tree is being disposed

+			if (isExpanded == true) {

+				visibleItemCount--;

+				calculateVisibleItemCountParent();

+			}

+		}

+		else {

+			parent.removingItem(child);	

+			children.removeElementAt(childIndex);

+			if (isExpanded == true) {

+				visibleItemCount--;

+				calculateVisibleItemCountParent();

+			}

+			resetChildIndices(childIndex, false);						// mark child index dirty

+			parent.removedItem(child);

+		}

+	}

+}

+/**

+ * Allow subclasses to reset any cached data.

+ * Called for all children of the receiver.

+ */

+void reset() {

+	Enumeration children = getChildren().elements();

+	AbstractTreeItem treeItem;

+

+	while (children.hasMoreElements() == true) {

+		treeItem = (AbstractTreeItem) children.nextElement();

+		treeItem.reset();

+	}

+}

+/**

+ * Mark all child indices dirty starting with the child at 

+ * 'startIndex'. This causes getIndex to recalculate the index.

+ * @param startIndex - index in the list of children at which 

+ *	and after which the indices are reset.

+ */

+void resetChildIndices(int startIndex, boolean addItem) {

+	Vector children = getChildren();

+	TreeItem child;

+	int increment = addItem ? 1 : 0;

+

+	for (int i = startIndex; i < children.size(); i++) {

+		child = (TreeItem) children.elementAt(i);

+		child.setIndex(i + increment);								// mark child index dirty

+	}

+}

+/**

+ * Select the receiver and all children.

+ * Return a Vector containing all the items that have been selected 

+ * (and that have not been selected before).

+ */

+Vector selectAll(Vector selectedItems) {

+	Enumeration children = getChildren().elements();

+	AbstractTreeItem treeItem;

+

+	if (isSelected() == false) {

+		selectedItems.addElement(this);

+		setSelected(true);

+		getSelectableParent().redrawSelection(this);

+	}

+	while (children.hasMoreElements() == true) {

+		treeItem = (AbstractTreeItem) children.nextElement();

+		selectedItems = treeItem.selectAll(selectedItems);

+	}

+	return selectedItems;

+}

+/**

+ * Set the Array containing the receiver's child items to 'children'.

+ */

+void setChildren(Vector children) {

+	this.children = children;

+}

+

+void setVisibleItemCount(int count) {

+	visibleItemCount = count;

+}

+}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java
index 6cf0259..43c4aed 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java
@@ -33,7 +33,8 @@
 }

 

 public void addSelectionListener (SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Selection,typedListener);

@@ -72,7 +73,8 @@
 }

 

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int border = getBorderWidth ();

 	int width = border * 2, height = border * 2;

 	if ((style & SWT.ARROW) != 0) {

@@ -137,7 +139,6 @@
 		int [] args = {

 			OS.Pt_ARG_HORIZONTAL_ALIGNMENT, alignment, 0,

 			OS.Pt_ARG_INDICATOR_TYPE, (style & SWT.CHECK) != 0 ? OS.Pt_N_OF_MANY : OS.Pt_ONE_OF_MANY, 0,

-			OS.Pt_ARG_FILL_COLOR, display.WIDGET_BACKGROUND, 0,

 			OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,

 		};	

 

@@ -157,7 +158,8 @@
 }

 

 public int getAlignment () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.ARROW) != 0) {

 		if ((style & SWT.UP) != 0) return SWT.UP;

 		if ((style & SWT.DOWN) != 0) return SWT.DOWN;

@@ -171,20 +173,15 @@
 	return SWT.LEFT;

 }

 

-boolean getDefault () {

-	if ((style & SWT.PUSH) == 0) return false;

-	int [] args = {OS.Pt_ARG_BEVEL_CONTRAST, 0, 0};

-	OS.PtGetResources (handle, args.length / 3, args);

-	return args [1] == 100;

-}

-

 public Image getImage () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return image;

 }

 

 public boolean getSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;

 	int [] args = {OS.Pt_ARG_FLAGS, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

@@ -196,7 +193,8 @@
 }

 

 public String getText () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.ARROW) != 0) return "";

 	int [] args = {

 		OS.Pt_ARG_TEXT_STRING, 0, 0,

@@ -249,26 +247,6 @@
 	return OS.Pt_CONTINUE;

 }

 

-int processFocusIn (int info) {

-	int result = super.processFocusIn (info);

-	// widget could be disposed at this point

-	if (handle == 0) return result;

-	if ((style & SWT.PUSH) == 0) return result;

-	getShell ().setDefaultButton (this, false);

-	return result;

-}

-

-int processFocusOut (int info) {

-	int result = super.processFocusOut (info);

-	// widget could be disposed at this point

-	if (handle == 0) return result;

-	if ((style & SWT.PUSH) == 0) return result;

-	if (getDefault ()) {

-		getShell ().setDefaultButton (null, false);

-	}

-	return result;

-}

-

 int processPaint (int damage) {

 	if ((style & SWT.ARROW) != 0) {

 		OS.PtSuperClassDraw (OS.PtButton (), handle, damage);

@@ -302,7 +280,8 @@
 }

 

 public void removeSelectionListener (SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Selection, listener);

@@ -327,7 +306,8 @@
 }

 

 public void setAlignment (int alignment) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.ARROW) != 0) {

 		if ((style & (SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT)) == 0) return; 

 		style &= ~(SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT);

@@ -344,29 +324,21 @@
 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

-void setDefault (boolean value) {

-	if ((style & SWT.PUSH) == 0) return;

-	if (getShell ().parent == null) return;

-	int [] args = {OS.Pt_ARG_BEVEL_CONTRAST, value ? 100 : 20, 0};

-	OS.PtSetResources (handle, args.length / 3, args);

-}

-

 public void setSelection (boolean selected) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;

 	int [] args = {OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void setImage (Image image) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.ARROW) != 0) return;

 	this.image = image;

 	int imageHandle = 0;

-	if (image != null) {

-		if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

-		imageHandle = copyPhImage (image.handle);

-	}

+	if (image != null) imageHandle = copyPhImage (image.handle);

 	int [] args = {

 		OS.Pt_ARG_LABEL_IMAGE, imageHandle, 0,

 		OS.Pt_ARG_LABEL_TYPE, OS.Pt_IMAGE, 0

@@ -376,7 +348,8 @@
 }

 

 public void setText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if ((style & SWT.ARROW) != 0) return;

 	char [] text = new char [string.length ()];

@@ -401,7 +374,7 @@
 		ptr2 = OS.malloc (buffer2.length);

 		OS.memmove (ptr2, buffer2, buffer2.length);

 	}

-	replaceMnemonic (mnemonic, true, true);

+	replaceMnemonic (mnemonic, 0);

 	int [] args = {

 		OS.Pt_ARG_TEXT_STRING, ptr, 0,

 		OS.Pt_ARG_LABEL_TYPE, OS.Pt_Z_STRING, 0,

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java
index 4c53438..24007b3 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java
@@ -21,7 +21,8 @@
 }

 

 public Caret getCaret () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return caret;

 }

 

@@ -91,7 +92,6 @@
 }

 

 public void redraw () {

-	checkWidget();

 	boolean isVisible = caret != null && caret.isVisible ();

 	if (isVisible) caret.hideCaret ();

 	super.redraw ();

@@ -99,7 +99,6 @@
 }

 

 public void redraw (int x, int y, int width, int height, boolean all) {

-	checkWidget();

 	boolean isVisible = caret != null && caret.isVisible ();

 	if (isVisible) caret.hideCaret ();

 	super.redraw (x, y, width, height, all);

@@ -116,7 +115,8 @@
 }

 

 public void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (width <= 0 || height <= 0) return;

 	int deltaX = destX - x, deltaY = destY - y;

 	if (deltaX == 0 && deltaY == 0) return;

@@ -130,7 +130,8 @@
 }

 

 void setBounds (int x, int y, int width, int height, boolean move, boolean resize) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	boolean isVisible = (caret != null) && (caret.isVisible ());

 	if (isVisible) caret.hideCaret ();

 	super.setBounds (x, y, width, height, move, resize);

@@ -138,17 +139,15 @@
 }

 

 public void setCaret (Caret caret) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	Caret newCaret = caret;

 	Caret oldCaret = this.caret;

 	this.caret = newCaret;

 	if (isFocusControl ()) {

 		if (oldCaret != null) oldCaret.killFocus ();

-		if (newCaret != null) {

-			if (newCaret.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

-			newCaret.setFocus ();

-		}

+		if (newCaret != null) newCaret.setFocus ();

 	}

 }

 

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java
index a8271df..5d6a427 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java
@@ -62,7 +62,8 @@
 }	

 

 public Rectangle getBounds () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return new Rectangle (x, y, width, height);

 }

 

@@ -73,27 +74,32 @@
 }

 

 public Font getFont () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent.getFont ();

 }

 

 public Point getLocation () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return new Point (x, y);

 }

 

 public Canvas getParent () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent;

 }

 

 public Point getSize () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return new Point (width, height);

 }

 

 public boolean getVisible () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return isVisible;

 }

 

@@ -106,7 +112,8 @@
 }

 

 public boolean isVisible () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return isVisible && parent.isVisible () && parent.hasFocus ();

 }

 

@@ -133,7 +140,8 @@
 }

 

 public void setBounds (int x, int y, int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	boolean samePosition, sameExtent, showing;

 	samePosition = (this.x == x) && (this.y == y);

 	sameExtent = (this.width == width) && (this.height == height);

@@ -164,33 +172,39 @@
 }

 

 public void setFont (Font font) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 }

 

 public void setLocation (int x, int y) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	setBounds (x, y, width, height);

 }

 

 public void setLocation (Point location) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (location == null) error (SWT.ERROR_NULL_ARGUMENT);

 	setLocation (location.x, location.y);

 }

 

 public void setSize (int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	setBounds (x, y, width, height);

 }

 

 public void setSize (Point size) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (size == null) error (SWT.ERROR_NULL_ARGUMENT);

 	setSize (size.x, size.y);

 }

 

 public void setVisible (boolean visible) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);	

 	if (visible == isVisible) return;

 	if (isVisible = visible) {

 		showCaret ();

@@ -205,4 +219,4 @@
 	isShowing = true;

 	return drawCaret ();

 }

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java
index 084d914..dd2d8b6 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java
@@ -48,4 +48,4 @@
 	this.rgb = rgb;

 }

 

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java
index 39e712b..7fe9e57 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java
@@ -46,7 +46,8 @@
 }

 

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	//NOT DONE: this only works with a DROP_DOWN combo 

 	if ((style & SWT.SIMPLE) != 0) return new Point(100, 100);

 	PhDim_t dim = new PhDim_t();

@@ -106,7 +107,8 @@
 }

 

 public void deselect (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {OS.Pt_ARG_CBOX_SELECTION_ITEM, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	if (args [1] == index) {

@@ -119,7 +121,8 @@
 }

 

 public void deselectAll () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {

 		OS.Pt_ARG_TEXT_STRING, 0, 0,

 		OS.Pt_ARG_CBOX_SELECTION_ITEM, 0, 0

@@ -128,7 +131,8 @@
 }

 

 public void add (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	byte [] buffer = Converter.wcsToMbcs (null, string, true);

 	int ptr = OS.malloc (buffer.length);

@@ -138,7 +142,8 @@
 }

 

 public void add (String string, int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (index == -1) error (SWT.ERROR_INVALID_RANGE);

 	byte [] buffer = Converter.wcsToMbcs (null, string, true);

@@ -155,14 +160,16 @@
 }

 

 public void addModifyListener (ModifyListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Modify, typedListener);

 }

 

 public void addSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Selection,typedListener);

@@ -174,7 +181,8 @@
 }

 

 public void clearSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	OS.PtTextSetSelection (handle, new int [] {0}, new int [] {0});

 }

 

@@ -196,7 +204,8 @@
 }

 

 public String getItem (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {

 		OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,

 		OS.Pt_ARG_ITEMS, 0, 0,

@@ -215,20 +224,23 @@
 }

 

 public int getItemCount () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public int getItemHeight () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	//NOT DONE - NOT NEEDED

 	return 0;

 }

 

 public String [] getItems () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {

 		OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,

 		OS.Pt_ARG_ITEMS, 0, 0,

@@ -245,14 +257,12 @@
 		result [i] = new String (unicode);

 	}

 	return result;

-}

 

-String getNameText () {

-	return getText ();

 }

 

 public Point getSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (((style & SWT.DROP_DOWN) != 0) && ((style & SWT.READ_ONLY) != 0)) {

 		int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};

 		OS.PtGetResources (handle, args.length / 3, args);

@@ -274,7 +284,8 @@
 }

 

 public int getSelectionIndex () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {OS.Pt_ARG_CBOX_SELECTION_ITEM, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	if (args [1] == 0) return -1;

@@ -282,7 +293,8 @@
 }

 

 public String getText () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	if (args [1] == 0) return "";

@@ -294,7 +306,8 @@
 }

 

 public int getTextHeight () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	//NOT DONE - Only works for DROP_DOWN

 	PhDim_t dim = new PhDim_t();

 	if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);

@@ -307,7 +320,8 @@
 }

 

 public int getTextLimit () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

@@ -325,13 +339,15 @@
 }

 

 public int indexOf (String string) {

-	checkWidget();

+	if (!isValidThread ()) error(SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error(SWT.ERROR_WIDGET_DISPOSED);

 	byte [] buffer = Converter.wcsToMbcs (null, string, true);

 	return OS.PtListItemPos(handle, buffer) - 1;

 }

 

 public int indexOf (String string, int start) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	

 	// NOT DONE - start is ignored

@@ -366,7 +382,8 @@
 }

 

 public void remove (int start, int end) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	if (!(0 < start && start <= end && end < args [1])) {

@@ -378,7 +395,8 @@
 }

 

 public void remove (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	if (!(0 <= index && index < args [1])) error (SWT.ERROR_INVALID_RANGE);

@@ -387,26 +405,30 @@
 }

 

 public void remove (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int index = indexOf (string, 0);

 	if (index == -1) error (SWT.ERROR_ITEM_NOT_REMOVED);

 	remove (index);

 }

 

 public void removeAll () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	OS.PtListDeleteAllItems (handle);

 }

 

 public void removeModifyListener (ModifyListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Modify, listener);	

 }

 

 public void removeSelectionListener (SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Selection, listener);

@@ -414,20 +436,23 @@
 }

 

 public void select (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (index < 0) return;

 	int [] args = new int [] {OS.Pt_ARG_CBOX_SELECTION_ITEM, index + 1, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 void setBounds (int x, int y, int width, int height, boolean move, boolean resize) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int newHeight = ((style & SWT.DROP_DOWN) != 0) ? getTextHeight() : height;

 	super.setBounds (x, y, width, newHeight, move, resize);

 }

 

 public void setItem (int index, String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

@@ -442,7 +467,8 @@
 }

 

 public void setItems (String [] items) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (items == null) error (SWT.ERROR_NULL_ARGUMENT);

 	OS.PtListDeleteAllItems (handle);

 	int[] itemsPtr = new int [items.length];

@@ -461,13 +487,15 @@
 }

 

 public void setSelection (Point selection) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);

 	OS.PtTextSetSelection (handle, new int [] {selection.x}, new int [] {selection.y});

 }

 

 public void setText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	byte [] buffer = Converter.wcsToMbcs (null, string, true);

 	if ((style & SWT.READ_ONLY) != 0) {

@@ -487,7 +515,8 @@
 }

 

 public void setTextLimit (int limit) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);

 	int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, limit, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

@@ -506,13 +535,4 @@
 	return code;

 }

 

-boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {

-	boolean translated = super.translateTraversal (key_sym, phEvent);

-	if (!translated && key_sym == OS.Pk_Return) {

-		postEvent (SWT.DefaultSelection);

-		return true;

-	}

-	return translated;

-}

-

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java
index d55fee2..b120e52 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java
@@ -51,7 +51,8 @@
 }

 

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	Point size;

 	if (layout != null) {

 		if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {

@@ -86,43 +87,21 @@
 	}

 }

 

-public boolean forceFocus () {

-	checkWidget();

-	/*

-	* Bug in Photon. PtContainerGiveFocus() is supposed to give

-	* focus to the widget even if the widget's Pt_GET_FOCUS flag

-	* is not set. This does not happen when the widget is a

-	* PtContainer. The fix is to set the flag before calling it.

-	*/

-	int [] args = {OS.Pt_ARG_FLAGS, OS.Pt_GETS_FOCUS, OS.Pt_GETS_FOCUS};

-	OS.PtSetResources (handle, args.length / 3, args);

-	boolean result = super.forceFocus ();

-	args [1] = 0;

-	OS.PtSetResources (handle, args.length / 3, args);

-	return result;

-}

-

 void createScrolledHandle (int parentHandle) {

 	int etches = OS.Pt_ALL_ETCHES | OS.Pt_ALL_OUTLINES;

 	int [] args = new int [] {

 		OS.Pt_ARG_FLAGS, hasBorder () ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,

 		OS.Pt_ARG_BASIC_FLAGS, hasBorder () ? etches : 0, etches,

 		OS.Pt_ARG_CONTAINER_FLAGS, 0, OS.Pt_ENABLE_CUA | OS.Pt_ENABLE_CUA_ARROWS,

-		OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,

 		OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,

 	};

 	scrolledHandle = OS.PtCreateWidget (OS.PtContainer (), parentHandle, args.length / 3, args);

+	if ((style & SWT.NO_BACKGROUND) != 0) {

+		args = new int [] {OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0};

+		OS.PtSetResources(scrolledHandle, args.length / 3, args);

+	}

 	if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);

 	Display display = getDisplay ();

-	etches = OS.Pt_TOP_OUTLINE | OS.Pt_LEFT_OUTLINE;

-	args = new int [] {

-		OS.Pt_ARG_FLAGS, OS.Pt_HIGHLIGHTED, OS.Pt_HIGHLIGHTED,

-		OS.Pt_ARG_BASIC_FLAGS, etches, etches,

-		OS.Pt_ARG_WIDTH, display.SCROLLBAR_WIDTH, 0,

-		OS.Pt_ARG_HEIGHT, display.SCROLLBAR_HEIGHT, 0,

-		OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,

-	};

-	OS.PtCreateWidget (OS.PtContainer (), scrolledHandle, args.length / 3, args);

 	int clazz = display.PtContainer;

 	args = new int [] {

 		OS.Pt_ARG_CONTAINER_FLAGS, 0, OS.Pt_ENABLE_CUA | OS.Pt_ENABLE_CUA_ARROWS,

@@ -134,87 +113,17 @@
 }

 

 public Rectangle getClientArea () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (scrolledHandle == 0) return super.getClientArea ();

 	PhArea_t area = new PhArea_t ();

 	OS.PtWidgetArea (handle, area);

 	return new Rectangle (area.pos_x, area.pos_y, area.size_w, area.size_h);

 }

-

-int getClipping(int widget, int topWidget, boolean clipChildren, boolean clipSiblings) {

-	int child_tile = 0;

-	int widget_tile = OS.PhGetTile(); // NOTE: PhGetTile native initializes the tile

-

-	PhRect_t rect = new PhRect_t ();

-	int args [] = {OS.Pt_ARG_FLAGS, 0, 0, OS.Pt_ARG_BASIC_FLAGS, 0, 0};

 	

-	/* Get the rectangle of all siblings in front of the widget */

-	if (clipSiblings && OS.PtWidgetClass(topWidget) != OS.PtWindow()) {

-		int temp_widget = topWidget;

-		while ((temp_widget = OS.PtWidgetBrotherInFront(temp_widget)) != 0) {

-			if (OS.PtWidgetIsRealized(temp_widget)) {

-				int tile = OS.PhGetTile();

-				if (child_tile == 0) child_tile = tile;			

-				else child_tile = OS.PhAddMergeTiles(tile, child_tile, null);

-				OS.PtWidgetExtent(temp_widget, tile); // NOTE: tile->rect

-				args [1] = args [4] = 0;

-				OS.PtGetResources(temp_widget, args.length / 3, args);

-				if ((args [1] & OS.Pt_HIGHLIGHTED) != 0) {

-					int basic_flags = args [4];

-					OS.memmove(rect, tile, PhRect_t.sizeof);

-					if ((basic_flags & OS.Pt_TOP_ETCH) != 0) rect.ul_y++;

-					if ((basic_flags & OS.Pt_BOTTOM_ETCH) != 0) rect.lr_y--;

-					if ((basic_flags & OS.Pt_RIGHT_ETCH) != 0) rect.ul_x++;

-					if ((basic_flags & OS.Pt_LEFT_ETCH) != 0) rect.lr_x--;

-					OS.memmove(tile, rect, PhRect_t.sizeof);

-				}

-			}

-		}

-		/* Translate the siblings rectangles to the widget's coordinates */

-		OS.PtWidgetCanvas(topWidget, widget_tile); // NOTE: widget_tile->rect

-		OS.PhDeTranslateTiles(child_tile, widget_tile); // NOTE: widget_tile->rect.ul

-	}

-			

-	/* Get the rectangle of the widget's children */

-	if (clipChildren) {

-		int temp_widget = OS.PtWidgetChildBack(widget);

-		while (temp_widget != 0) {

-			if (OS.PtWidgetIsRealized(temp_widget)) {

-				int tile = OS.PhGetTile();

-				if (child_tile == 0) child_tile = tile;			

-				else child_tile = OS.PhAddMergeTiles(tile, child_tile, null);

-				OS.PtWidgetExtent(temp_widget, tile); // NOTE: tile->rect

-				args [1] = args [4] = 0;

-				OS.PtGetResources(temp_widget, args.length / 3, args);

-				if ((args [1] & OS.Pt_HIGHLIGHTED) != 0) {

-					int basic_flags = args [4];

-					OS.memmove(rect, tile, PhRect_t.sizeof);

-					if ((basic_flags & OS.Pt_TOP_ETCH) != 0) rect.ul_y++;

-					if ((basic_flags & OS.Pt_BOTTOM_ETCH) != 0) rect.lr_y--;

-					if ((basic_flags & OS.Pt_RIGHT_ETCH) != 0) rect.ul_x++;

-					if ((basic_flags & OS.Pt_LEFT_ETCH) != 0) rect.lr_x--;

-					OS.memmove(tile, rect, PhRect_t.sizeof);

-				}

-			}

-			temp_widget = OS.PtWidgetBrotherInFront(temp_widget);

-		}

-	}

-

-	/* Get the widget's rectangle */

-	OS.PtWidgetCanvas(widget, widget_tile); // NOTE: widget_tile->rect

-	OS.PhDeTranslateTiles(widget_tile, widget_tile); // NOTE: widget_tile->rect.ul

-

-	/* Clip the widget's rectangle from the child/siblings rectangle's */

-	if (child_tile != 0) {

-		int clip_tile = OS.PhClipTilings(widget_tile, child_tile, null);

-		OS.PhFreeTiles(child_tile);

-		return clip_tile;

-	}

-	return widget_tile;

-}

-

 public Control [] getChildren () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return _getChildren ();

 }

 

@@ -229,7 +138,8 @@
 }

 

 public Layout getLayout () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return layout;

 }

 

@@ -248,7 +158,8 @@
 }

 

 public void layout () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	layout (true);

 }

 

@@ -264,7 +175,8 @@
 }

 

 public void layout (boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (layout == null) return;

 	int count = getChildrenCount ();

 	if (count == 0) return;

@@ -301,37 +213,7 @@
 int processPaint (int damage) {

 	if ((state & CANVAS) != 0) {

 		if ((style & SWT.NO_BACKGROUND) == 0) {

-			

-			/* Get the clipping tiles for children and siblings */

-			int clip_tile = getClipping (handle, topHandle (), true, true);

-

-			/* Translate the clipping to the current GC coordinates */

-			short [] abs_x = new short [1], abs_y = new short [1];

-			OS.PtGetAbsPosition (handle, abs_x, abs_y);

-			short [] dis_abs_x = new short [1], dis_abs_y = new short [1];

-			OS.PtGetAbsPosition (OS.PtFindDisjoint (handle), dis_abs_x, dis_abs_y);

-			PhPoint_t delta = new PhPoint_t ();

-			delta.x = (short) (abs_x [0] - dis_abs_x [0]);

-			delta.y = (short) (abs_y [0] - dis_abs_y [0]);

-			OS.PhTranslateTiles(clip_tile, delta);

-

-			/* Set the clipping */

-			int[] clip_rects_count = new int [1];

-			int clip_rects = OS.PhTilesToRects (clip_tile, clip_rects_count);

-			OS.PhFreeTiles (clip_tile);	

-			if (clip_rects_count [0] == 0) {

-				clip_rects_count [0] = 1;

-				OS.free (clip_rects);

-				clip_rects = OS.malloc (PhRect_t.sizeof);

-			}

-			OS.PgSetMultiClip (clip_rects_count[0], clip_rects);

-			OS.free (clip_rects);

-			

-			/* Draw the widget */

 			OS.PtSuperClassDraw (OS.PtContainer (), handle, damage);

-			

-			/* Reset the clipping */

-			OS.PgSetMultiClip (0, 0);

 		}

 	}

 	return super.processPaint (damage);

@@ -434,14 +316,6 @@
 		OS.Pt_ARG_HEIGHT, Math.max (clientHeight, 0), 0,

 	};

 	OS.PtSetResources (handle, args.length / 3, args);

-	PhPoint_t pt = new PhPoint_t ();

-	pt.x = (short) clientWidth;

-	pt.y = (short) clientHeight;

-	int ptr = OS.malloc (PhPoint_t.sizeof);

-	OS.memmove (ptr, pt, PhPoint_t.sizeof);

-	args = new int [] {OS.Pt_ARG_POS, ptr, 0};

-	OS.PtSetResources (OS.PtWidgetChildBack (scrolledHandle), args.length / 3, args);

-	OS.free (ptr);

 }

 

 void setBounds (int x, int y, int width, int height, boolean move, boolean resize) {

@@ -450,7 +324,8 @@
 }

 

 public void setLayout (Layout layout) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	this.layout = layout;

 }

 

@@ -459,4 +334,4 @@
 	return super.traversalCode (key_sym, ke);

 }

 

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java
index ce5bac1..e9dd1b7 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java
@@ -28,7 +28,8 @@
 }

 

 public void addControlListener(ControlListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Resize,typedListener);

@@ -36,7 +37,8 @@
 }

 

 public void addFocusListener (FocusListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.FocusIn,typedListener);

@@ -44,14 +46,16 @@
 }

 

 public void addHelpListener (HelpListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Help, typedListener);

 }

 

 public void addKeyListener (KeyListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.KeyUp,typedListener);

@@ -59,7 +63,8 @@
 }

 

 public void addMouseListener (MouseListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.MouseDown,typedListener);

@@ -68,7 +73,8 @@
 }

 

 public void addMouseTrackListener (MouseTrackListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.MouseEnter,typedListener);

@@ -77,28 +83,32 @@
 }

 

 public void addMouseMoveListener (MouseMoveListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.MouseMove,typedListener);

 }

 

 public void addPaintListener (PaintListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Paint,typedListener);

 }

 

 public void addTraverseListener (TraverseListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Traverse,typedListener);

 }

 

 public boolean forceFocus () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int shellHandle = OS.PtFindDisjoint (handle);

 	OS.PtWindowToFront (shellHandle);

 	OS.PtContainerGiveFocus (handle, null);

@@ -110,7 +120,8 @@
 }

 

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int width = DEFAULT_WIDTH;

 	int height = DEFAULT_HEIGHT;

 	if (wHint != SWT.DEFAULT) width = wHint;

@@ -133,14 +144,16 @@
 }

 

 public Color getBackground () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_FILL_COLOR, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return Color.photon_new (getDisplay (), args [1]);

 }

 

 public Font getFont () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {

 		OS.Pt_ARG_TEXT_FONT, 0, 0,

 		OS.Pt_ARG_LIST_FONT, 0, 0,

@@ -162,14 +175,16 @@
 }

 

 public Color getForeground () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_COLOR, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return Color.photon_new (getDisplay (), args [1]);

 }

 

 public int getBorderWidth () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int topHandle = topHandle ();

 	int [] args = {

 		OS.Pt_ARG_BASIC_FLAGS, 0, 0,

@@ -188,7 +203,8 @@
 }

 

 public Rectangle getBounds () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int topHandle = topHandle ();

 	PhArea_t area = new PhArea_t ();

 	OS.PtWidgetArea (topHandle, area);

@@ -202,19 +218,22 @@
 }

 

 public boolean getEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_FLAGS, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return (args [1] & OS.Pt_BLOCKED) == 0;

 }

 

 public Object getLayoutData () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return layoutData;

 }

 

 public Point getLocation () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int topHandle = topHandle ();

 	PhArea_t area = new PhArea_t ();

 	OS.PtWidgetArea (topHandle, area);

@@ -222,12 +241,14 @@
 }

 

 public Menu getMenu () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return null;

 }

 

 public Composite getParent () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent;

 }

 

@@ -249,7 +270,8 @@
 }

 

 public Point getSize () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int topHandle = topHandle ();

 	PhArea_t area = new PhArea_t ();

 	OS.PtWidgetArea (topHandle, area);

@@ -257,17 +279,20 @@
 }

 

 public String getToolTipText () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return toolTipText;

 }

 

 public Shell getShell () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent.getShell ();

 }

 

 public boolean getVisible () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int topHandle = topHandle ();

 	int [] args = {OS.Pt_ARG_FLAGS, 0, 0};

 	OS.PtGetResources (topHandle, args.length / 3, args);

@@ -296,7 +321,7 @@
 }

 

 public int internal_new_GC (GCData data) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

 	int phGC = OS.PgCreateGC(0); // NOTE: PgCreateGC ignores the parameter

 	if (phGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);

 

@@ -317,22 +342,26 @@
 }

 

 public boolean isEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return getEnabled () && parent.isEnabled ();

 }

 

 public boolean isFocusControl () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return hasFocus ();

 }

 

 public boolean isReparentable () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return false;

 }

 

 public boolean isVisible () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return OS.PtWidgetIsRealized (handle);

 }

 

@@ -341,38 +370,40 @@
 }

 

 public void moveAbove (Control control) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int topHandle1 = topHandle ();

 	if (control == null) {

 		OS.PtWidgetToFront (topHandle1);

 		OS.PtWindowToFront (topHandle1);

 		return;

 	}

-	if (control.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 	int topHandle2 = control.topHandle ();

 	OS.PtWidgetInsert (topHandle1, topHandle2, 0);

 }

 

 public void moveBelow (Control control) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int topHandle1 = topHandle ();

 	if (control == null) {

 		OS.PtWidgetToBack (topHandle1);

 		OS.PtWindowToBack (topHandle1);

 		return;

 	}

-	if (control.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 	int topHandle2 = control.topHandle ();

 	OS.PtWidgetInsert (topHandle1, topHandle2, 1);

 }

 

 public void pack () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	pack (true);

 }

 

 public void pack (boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed));

 }

 

@@ -591,14 +622,12 @@
 	OS.memmove (pe, data, PhPointerEvent_t.sizeof);

 	event.x = pe.pos_x + ev.translation_x;

 	event.y = pe.pos_y + ev.translation_y;

-	if (ev.type == OS.Ph_EV_BUT_PRESS || ev.type == OS.Ph_EV_BUT_RELEASE) {

-		switch (pe.buttons) {

-			case OS.Ph_BUTTON_SELECT:	event.button = 1; break;

-			case OS.Ph_BUTTON_ADJUST:	event.button = 2; break;

-			case OS.Ph_BUTTON_MENU:		event.button = 3; break;

-		}

+	switch (pe.buttons) {

+		case OS.Ph_BUTTON_SELECT:	event.button = 1; break;

+		case OS.Ph_BUTTON_ADJUST:	event.button = 2; break;

+		case OS.Ph_BUTTON_MENU:		event.button = 3; break;

 	}

-	setMouseState (ev.type, event, pe);

+	setMouseState (event, pe);

 	postEvent (event.type, event);

 	if (ev.type == OS.Ph_EV_BUT_PRESS && pe.click_count == 2) {

 		Event clickEvent = new Event ();

@@ -680,13 +709,14 @@
 }

 

 public void redraw () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	OS.PtDamageWidget (handle);

 }

 

 public void redraw (int x, int y, int width, int height, boolean allChildren) {

-	checkWidget ();

-	if (width <= 0 || height <= 0) return;

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	PhRect_t rect = new PhRect_t ();

 	rect.ul_x = (short) x;

 	rect.ul_y = (short) y;

@@ -696,7 +726,8 @@
 }

 

 public void removeControlListener (ControlListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Move, listener);

@@ -704,7 +735,8 @@
 }

 

 public void removeFocusListener(FocusListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.FocusIn, listener);

@@ -712,14 +744,16 @@
 }

 

 public void removeHelpListener (HelpListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Help, listener);

 }

 

 public void removeKeyListener(KeyListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.KeyUp, listener);

@@ -727,7 +761,8 @@
 }

 

 public void removeMouseTrackListener(MouseTrackListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.MouseEnter, listener);

@@ -736,7 +771,8 @@
 }

 

 public void removeMouseListener (MouseListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.MouseDown, listener);

@@ -745,21 +781,24 @@
 }

 

 public void removeMouseMoveListener(MouseMoveListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.MouseMove, listener);

 }

 

 public void removePaintListener(PaintListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook(SWT.Paint, listener);

 }

 

 public void removeTraverseListener(TraverseListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Traverse, listener);

@@ -808,25 +847,29 @@
 }

 

 public void setBounds (int x, int y, int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	setBounds (x, y, width, height, true, true);

 }

 

 public void setBounds (Rectangle rect) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);

 	setBounds (rect.x, rect.y, rect.width, rect.height);

 }

 

 public void setCapture (boolean capture) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 }

 

 public void setCursor (Cursor cursor) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int type = OS.Ph_CURSOR_INHERIT;

 	int bitmap = 0;

 	if (cursor != null) {

-		if (cursor.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 		type = cursor.type;

 		bitmap = cursor.bitmap;

 	}

@@ -850,7 +893,8 @@
 }

 

 public void setEnabled (boolean enabled) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {

 		OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_BLOCKED, OS.Pt_BLOCKED,

 		OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_GHOST, OS.Pt_GHOST,

@@ -859,11 +903,13 @@
 }

 

 public boolean setFocus () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return forceFocus ();

 }

 

 void sendPaintEvent (int damage) {

+	

 	if (!hooks(SWT.Paint)) return;

 	

 	/* Translate the damage to widget coordinates */

@@ -904,25 +950,18 @@
 }

 

 public void setBackground (Color color) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int pixel = OS.Pt_DEFAULT_COLOR;

-	if (color != null) {

-		if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

-		pixel = color.handle;

-	}

+	if (color != null) pixel = color.handle;

 	int [] args = {OS.Pt_ARG_FILL_COLOR, pixel, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void setFont (Font font) {

-	checkWidget();

-	byte[] buffer;

-	if (font != null) {

-		if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

-		buffer = font.handle;

-	} else {

-		buffer = defaultFont();

-	}

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	byte [] buffer = (font != null) ? font.handle : defaultFont (); 

 	int ptr = OS.malloc (buffer.length);

 	OS.memmove (ptr, buffer, buffer.length);

 	int [] args = {

@@ -935,12 +974,10 @@
 }

 

 public void setForeground (Color color) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int pixel = OS.Pt_DEFAULT_COLOR;

-	if (color != null) {

-		if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

-		pixel = color.handle;

-	}

+	if (color != null) pixel = color.handle;

 	int [] args = {OS.Pt_ARG_COLOR, pixel, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

@@ -974,28 +1011,28 @@
 }

 

 public void setLayoutData (Object layoutData) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	this.layoutData = layoutData;

 }

 

 public void setLocation (int x, int y) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	setBounds (x, y, 0, 0, true, false);

 }

 

 public void setLocation (Point location) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (location == null) error (SWT.ERROR_NULL_ARGUMENT);

 	setLocation (location.x, location.y);

 }

 

 public void setMenu (Menu menu) {

-	checkWidget();

-	int flags = 0;

-	if (menu != null) {

-		if (menu.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

-		flags = OS.Pt_MENUABLE;

-	}

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	int flags = menu != null ? OS.Pt_MENUABLE : 0;

 	int [] args = {

 		OS.Pt_ARG_FLAGS, flags, OS.Pt_ALL_BUTTONS | OS.Pt_MENUABLE,

 	};

@@ -1003,7 +1040,7 @@
 	this.menu = menu;

 }

 

-void setMouseState(int type, Event event, PhPointerEvent_t pe) {

+void setMouseState(Event event, PhPointerEvent_t pe) {

 	int key_mods = pe.key_mods;

 	int buttons = pe.buttons;

 	int button_state = pe.button_state;

@@ -1013,11 +1050,18 @@
 	if ((button_state & OS.Ph_BUTTON_SELECT) != 0) event.stateMask |= SWT.BUTTON1;

 	if ((button_state & OS.Ph_BUTTON_ADJUST) != 0) event.stateMask |= SWT.BUTTON2;

 	if ((button_state & OS.Ph_BUTTON_MENU) != 0) event.stateMask |= SWT.BUTTON3;

-	if (type == OS.Ph_EV_BUT_PRESS) {

-		if (buttons == OS.Ph_BUTTON_SELECT) event.stateMask &= ~SWT.BUTTON1;

-		if (buttons == OS.Ph_BUTTON_ADJUST) event.stateMask &= ~SWT.BUTTON2;

-		if (buttons == OS.Ph_BUTTON_MENU) event.stateMask &= ~SWT.BUTTON3;

-	} else if (type == OS.Ph_EV_BUT_RELEASE || type == OS.Ph_EV_DRAG) {

+	if (event.type == SWT.MouseDown) {

+		if (buttons == OS.Ph_BUTTON_SELECT && (button_state & OS.Ph_BUTTON_SELECT) != 0) {

+			event.stateMask &= ~SWT.BUTTON1;

+		}

+		if (buttons == OS.Ph_BUTTON_ADJUST && (button_state & OS.Ph_BUTTON_ADJUST) != 0) {

+			event.stateMask &= ~SWT.BUTTON2;

+		}

+		if (buttons == OS.Ph_BUTTON_MENU && (button_state & OS.Ph_BUTTON_MENU) != 0) {

+			event.stateMask &= ~SWT.BUTTON3;

+		}

+	}

+	if (event.type == SWT.MouseUp) {

 		if (buttons == OS.Ph_BUTTON_SELECT) event.stateMask |= SWT.BUTTON1;

 		if (buttons == OS.Ph_BUTTON_ADJUST) event.stateMask |= SWT.BUTTON2;

 		if (buttons == OS.Ph_BUTTON_MENU) event.stateMask |= SWT.BUTTON3;

@@ -1025,18 +1069,20 @@
 }

 

 public boolean setParent (Composite parent) {

-	checkWidget();

-	if (parent.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return false;

 }

 

 public void setSize (Point size) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (size == null) error (SWT.ERROR_NULL_ARGUMENT);

 	setSize (size.x, size.y);

 }

 public void setRedraw (boolean redraw) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (redraw) {

 		OS.PtContainerRelease (handle);

 	} else {

@@ -1044,12 +1090,14 @@
 	}

 }

 public void setSize (int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	setBounds (0, 0, width, height, false, true);

 }

 

 public void setVisible (boolean visible) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int topHandle = topHandle ();

 	int [] args = {

 		OS.Pt_ARG_FLAGS, visible ? 0 : OS.Pt_DELAY_REALIZE, OS.Pt_DELAY_REALIZE,

@@ -1065,7 +1113,8 @@
 }

 

 public void setToolTipText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	toolTipText = string;

 }

 

@@ -1090,14 +1139,16 @@
 }

 

 public Point toControl (Point point) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	short [] x = new short [1], y = new short [1];

 	OS.PtGetAbsPosition (handle, x, y);

 	return new Point (point.x - x [0], point.y - y [0]);

 }

 

 public Point toDisplay (Point point) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	short [] x = new short [1], y = new short [1];

 	OS.PtGetAbsPosition (handle, x, y);

 	return new Point (point.x + x [0], point.y + y [0]);

@@ -1172,7 +1223,8 @@
 }

 

 public boolean traverse (int traversal) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (!isFocusControl () && !setFocus ()) return false;

 	switch (traversal) {

 		case SWT.TRAVERSE_ESCAPE:		return traverseEscape ();

@@ -1216,7 +1268,8 @@
 }

 

 public void update () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	OS.PtFlush ();

 }

 

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java
index 9eb0d47..014dca0 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java
@@ -14,7 +14,6 @@
 	Menu [] menus;

 	String text = "";

 	Image image;

-	Button defaultButton, saveDefault;

 

 Decorations () {

 	/* Do nothing */

@@ -53,27 +52,32 @@
 }

 

 public Button getDefaultButton () {

-	checkWidget();

-	return defaultButton;

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	return null;

 }

 

 public Image getImage () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return image;

 }

 

 public boolean getMaximized () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return false;

 }

 

 public boolean getMinimized () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return false;

 }

 

 public Menu getMenuBar () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return menuBar;

 }

 

@@ -82,7 +86,8 @@
 }

 

 public String getText () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return text;

 }

 

@@ -107,9 +112,8 @@
 	menuBar = null;

 	menus = null;

 	image = null;

-	super.releaseWidget ();

-	defaultButton = saveDefault = null;

 	text = null;

+	super.releaseWidget ();

 }

 

 void remove (Menu menu) {

@@ -149,52 +153,38 @@
 }

 

 public void setDefaultButton (Button button) {

-	checkWidget();

-	setDefaultButton (button, true);

-}

-void setDefaultButton (Button button, boolean save) {

-	if (button == null) {

-		if (defaultButton == saveDefault) return;

-	} else {

-		if (button.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

-		if ((button.style & SWT.PUSH) == 0) return;

-		if (button == defaultButton) return;

-	}

-	if (defaultButton != null) {

-		if (!defaultButton.isDisposed ()) defaultButton.setDefault (false);

-	}

-	if ((defaultButton = button) == null) defaultButton = saveDefault;

-	if (defaultButton != null) {

-		if (!defaultButton.isDisposed ()) defaultButton.setDefault (true);

-	}

-	if (save || saveDefault == null) saveDefault = defaultButton;

-	if (saveDefault != null && saveDefault.isDisposed ()) saveDefault = null;

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	//NOT DONE

 }

 

 public void setImage (Image image) {

-	checkWidget();

-	if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	this.image = image;

 }

 

 public void setMaximized (boolean maximized) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 }

  

 public void setMenuBar (Menu menu) {

-	checkWidget();

-	if (menu != null && menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	//NOT DONE

 }

 

 public void setMinimized (boolean minimized) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 }

 

 public void setText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	text = string;

 }

 

-}

+}
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 e9c3c63..4bd4810 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
@@ -175,21 +175,13 @@
 	static {

 		DeviceFinder = new Runnable () {

 			public void run () {

-				Device device = getCurrent ();

-				if (device == null) {

-					device = getDefault ();

+				CurrentDevice = getCurrent ();

+				if (CurrentDevice == null) {

+					CurrentDevice = getDefault ();

 				}

-				setDevice (device);

 			}

 		};

 	}

-

-/*

-* TEMPORARY CODE.

-*/

-static void setDevice (Device device) {

-	CurrentDevice = device;

-}

 			

 public Display () {

 	this (null);

@@ -335,6 +327,15 @@
 	return null;

 }

 

+public Rectangle getBounds () {

+	checkDevice ();

+	PhRect_t rect = new PhRect_t ();

+	OS.PhWindowQueryVisible (OS.Ph_QUERY_GRAPHICS, 0, 1, rect);

+	int width = rect.lr_x - rect.ul_x + 1;

+	int height = rect.lr_y - rect.ul_y + 1;

+	return new Rectangle (rect.ul_x, rect.ul_y, width, height);

+}

+

 public Control getCursorControl () {

 	checkDevice ();

 	int ig = OS.PhInputGroup (0);

@@ -700,7 +701,6 @@
 }

 

 public int internal_new_GC (GCData data) {

-	if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);

 	int phGC = OS.PgCreateGC(0); // NOTE: PgCreateGC ignores the parameter

 	if (phGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);

 

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java
index 91ec43e..d030f43 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java
@@ -122,4 +122,4 @@
 	filterPath = string;

 }

 

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java
index 860493f..3737d6d 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java
@@ -56,4 +56,4 @@
 public void setFontData (FontData fontData) {

 	this.fontData = fontData;

 }

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java
index 13abc84..cd6c353 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java
@@ -28,7 +28,8 @@
 }

 

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	Point titleSize = getTitleSize();

 	Point size;

 	if (layout != null) {

@@ -64,7 +65,8 @@
 }

 

 public String getText () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_TITLE, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	if (args [1] == 0) return "";

@@ -103,7 +105,8 @@
 }

 

 public void setText (String string) {	

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	int flags = OS.Pt_SHOW_TITLE | OS.Pt_ETCH_TITLE_AREA | OS.Pt_GRADIENT_TITLE_AREA;

 	byte [] buffer = Converter.wcsToMbcs (null, string, true);

@@ -117,4 +120,4 @@
 	OS.free (ptr);

 }

 

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Header.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Header.java
new file mode 100755
index 0000000..c77ad8a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Header.java
@@ -0,0 +1,336 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+

+import org.eclipse.swt.*;

+import org.eclipse.swt.events.*;

+import org.eclipse.swt.graphics.*;

+import java.util.*;

+ 

+/**

+ * A header draws one or more header items. Each item may have a text 

+ * label. Each item is identified by an index and can be resized.

+ */

+class Header extends Canvas {

+	private static final int DEFAULT_WIDTH = 64;		// used in computeSize if width could not be calculated

+	private static final int DEFAULT_HEIGHT = 64;		// used in computeSize if height could not be calculated	

+	private static final int VERTICAL_MARGIN = 4;		// space added to the height of the header label		

+	private static final int TEXT_Y_OFFSET = 2;			// space between the header label and the lower header boundary

+	private static final int DEFAULT_ITEM_WIDTH = 9;	// default width of a header item

+	private static final int TEXT_MARGIN = 6;			// space in front and behind header text

+	private static final int SHADOW_WIDTH = 2;			// width of the right side header shadow

+/**

+ * Create a Header widget as a child of 'parent'.

+ * @param parent - the parent of the new instance

+ */

+Header(Table parent) {

+	super(parent, SWT.NO_REDRAW_RESIZE | SWT.NO_FOCUS);

+	

+	addListener(SWT.Paint, new Listener() {

+		public void handleEvent(Event event) {paint(event);}

+	});

+	setHeaderHeight();

+}

+/**

+ * Answer the size of the receiver needed to display all items.

+ */

+public Point computeSize(int wHint, int hHint, boolean changed) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	int width = 0;

+	int height = 0;

+

+	for (int i = 0; i < getItemCount(); i++) {

+		width += getBounds(i).width;

+		if (height == 0) {

+			height = getBounds(i).height;

+		}

+	}

+	if (width == 0) {

+		width = DEFAULT_WIDTH;

+	}

+	if (height == 0) {

+		height = DEFAULT_HEIGHT;

+	}

+	if (wHint != SWT.DEFAULT) {

+		width = wHint;

+	}

+	if (hHint != SWT.DEFAULT) {

+		height = hHint;

+	}

+	return new Point(width, height);

+}

+/**

+ * Draw the bright shadow on the upper and left sides of a header item.

+ * @param gc - GC to draw on

+ * @param itemIndex - specifies the item to draw

+ */

+void drawHighlightShadow(GC gc, int itemIndex) {

+	Rectangle bounds = getBounds(itemIndex);

+	Color oldForeground = getForeground();

+

+	gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));	

+	// draw top horizontal line

+	gc.drawLine(bounds.x, bounds.y, bounds.x + bounds.width - 1, bounds.y);

+	// draw left vertical line

+	gc.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height - 1);

+	gc.setForeground(oldForeground);

+}

+/**

+ * Draw the dark shadow on the lower and right side of a header item.

+ * @param gc - GC to draw on

+ * @param itemIndex - specifies the item to draw

+ */

+void drawLowlightShadows(GC gc, int itemIndex) {

+	Rectangle bounds = getBounds(itemIndex);

+	Point bottomShadowStart = new Point(bounds.x + 1, bounds.height - 2);

+	Point bottomShadowStop = new Point(bottomShadowStart.x + bounds.width - 2, bottomShadowStart.y);	

+	Point rightShadowStart = null;

+	Point rightShadowStop = null;

+	Display display = getDisplay();

+	Color oldForeground = getForeground();	

+

+	// light inner shadow

+	gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));

+	gc.drawLine(

+		bottomShadowStart.x, bottomShadowStart.y,

+		bottomShadowStop.x, bottomShadowStop.y);

+	if(itemIndex != TableColumn.FILL) {

+		rightShadowStart = new Point(bounds.x + bounds.width - 2, bounds.y + 1);

+		rightShadowStop = new Point(rightShadowStart.x, bounds.height - 2);

+		gc.drawLine(

+			rightShadowStart.x, rightShadowStart.y,

+			rightShadowStop.x, rightShadowStop.y);

+	}	

+	// dark outer shadow 

+	bottomShadowStart.x--;

+	bottomShadowStart.y++;

+	bottomShadowStop.y++;

+	gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));

+	gc.drawLine(

+		bottomShadowStart.x, bottomShadowStart.y,

+		bottomShadowStop.x, bottomShadowStop.y);

+	if(itemIndex != TableColumn.FILL) {

+		rightShadowStart.x++;

+		rightShadowStart.y--;

+		rightShadowStop.y++;

+		rightShadowStop.x++;	

+		gc.drawLine(

+			rightShadowStart.x, rightShadowStart.y,

+			rightShadowStop.x, rightShadowStop.y);

+	}	

+	gc.setForeground(oldForeground);

+}

+/**

+ * Draw the item text of the item identified by 'itemIndex'.

+ * @param gc - GC to draw on

+ * @param itemIndex - specifies the item to draw

+ */

+void drawText(GC gc, int itemIndex) {

+	String label = getText(gc, itemIndex);

+	Point textExtent;

+	Rectangle bounds = getBounds(itemIndex);

+	int yPosition;

+	int xPosition = 0;

+	int alignment;

+

+	if (label != null) {

+		alignment = ((Table) getParent()).internalGetColumn(itemIndex).getAlignment();

+		textExtent = gc.stringExtent(label);

+		yPosition = bounds.height - textExtent.y - TEXT_Y_OFFSET;

+

+		if ((alignment & SWT.CENTER) != 0) {

+			xPosition = (bounds.width - textExtent.x) / 2;

+		}

+		else

+		if ((alignment & SWT.RIGHT) != 0) {

+			xPosition = bounds.width - textExtent.x - TEXT_MARGIN;

+		}

+		xPosition = Math.max(TEXT_MARGIN, xPosition);

+		xPosition += bounds.x;

+		gc.drawString(label, xPosition, yPosition);

+	}	

+}

+/**

+ * Answer the bounding rectangle of the item identified by 'itemIndex'.

+ * @param itemIndex - specifies the item whose bounding rectangle 

+ *	should be returned.

+ * @return the bouding rectangle of the item identified by 'itemIndex'.

+ */

+Rectangle getBounds(int itemIndex) {

+	Rectangle bounds = null;

+	int itemCount = getItemCount();

+	Table parent = (Table) getParent();

+

+	if (itemIndex >= 0 && itemIndex < itemCount) {

+		bounds = parent.internalGetColumn(itemIndex).getBounds();

+		bounds.y = 0;

+		bounds.height = getBounds().height;

+	}

+	else

+	if (itemIndex == TableColumn.FILL) {

+		if (itemCount > 0) {

+			bounds = parent.internalGetColumn(itemCount - 1).getBounds();

+			bounds.x += bounds.width;

+		}

+		else {

+			bounds = new Rectangle(0, 0, 0, 0);

+		}

+		bounds.width = Math.max(0, getBounds().width - bounds.x);

+		bounds.y = 0;

+		bounds.height = getBounds().height;		

+	}

+	return bounds;

+}

+/**

+ * Answer the number of items in the receiver.

+ */

+int getItemCount() {

+	return ((Table) getParent()).internalGetColumnCount();

+}

+/**

+ * Answer the maximum label width that fits into the item identified by

+ * 'itemIndex'.

+ */

+int getMaxLabelWidth(int itemIndex) {

+	return getBounds(itemIndex).width - 2 * TEXT_MARGIN;	

+}

+/**

+ * Answer the width required to display the complete label of the header 

+ * item at position 'index'.

+ * @param index - position of the header item whose preferred width should 

+ *	be returned.

+ */

+int getPreferredWidth(int index) {

+	Table parent = (Table) getParent();

+	String text = getText(index);

+	int headerWidth = 0;

+

+	if (text != null) {

+		headerWidth = parent.getTextWidth(text) + 2 * TEXT_MARGIN + 1;

+	}	

+	return headerWidth;

+}

+/**

+ * Answer the label of the item identified by 'itemIndex'.

+ */

+String getText(int itemIndex) {

+	String itemLabel = null;

+	

+	if (itemIndex >= 0 && itemIndex < getItemCount()) {

+		itemLabel = ((Table) getParent()).internalGetColumn(itemIndex).getText();

+	}

+	return itemLabel;

+}

+/**

+ * Answer the text that is going to be drawn in the header item 

+ * identified by 'itemIndex'. This may be truncated to fit the item

+ * width.

+ * @param gc - GC to use for measuring the label width.

+ * @param itemIndex - specifies the item whose label should be returned.

+ */

+String getText(GC gc, int itemIndex) {

+	String label = getText(itemIndex);

+	int maxWidth;

+

+	if (label != null) {

+		maxWidth = getMaxLabelWidth(itemIndex);

+		label = ((Table) getParent()).trimItemText(label, maxWidth, gc);

+	}

+	return label;

+}

+/**

+ * Draw the header item identified by 'itemIndex'.

+ * @param gc - GC to draw on

+ * @param itemIndex - item that should be drawn

+ */

+void paint(GC gc, int itemIndex) {

+	Rectangle bounds = getBounds(itemIndex);

+

+	// draw header background

+	gc.fillRectangle(bounds.x, bounds.y + 1, bounds.width, bounds.height - 3);

+	if (itemIndex != TableColumn.FILL) {

+		drawText(gc, itemIndex);

+	}

+	drawHighlightShadow(gc, itemIndex);

+	drawLowlightShadows(gc, itemIndex);	

+}

+/**

+ * Draw all header items.

+ * @param event - Paint event triggering the drawing operation.

+ */

+void paint(Event event) {

+	int labelCount = getItemCount();

+

+	for (int i = 0; i < labelCount; i++) {

+		paint(event.gc, i);

+	}

+	paint(event.gc, TableColumn.FILL);					// paint empty fill item behind last item

+}

+/**

+ * Redraw the item identified by 'itemIndex'.

+ * @param itemIndex - specifies the header item that should be redrawn

+ */

+void redraw(int itemIndex) {

+	Rectangle bounds = getBounds(itemIndex);

+

+	if (bounds != null) {

+		redraw(bounds.x, 0, bounds.width, bounds.height, false);

+	}

+}

+

+/**

+ * Set a new font. Recalculate the header height and redraw the header.

+ */

+public void setFont(Font font) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (font == null || font.equals(getFont()) == true) {

+		return;

+	}

+	super.setFont(font);

+	setHeaderHeight();

+	redraw();

+}

+/**

+ * Calculate and store the height of the receiver.

+ */

+void setHeaderHeight() {

+	GC gc = new GC(this);

+	Rectangle bounds = getBounds();

+

+	bounds.height = gc.stringExtent("aString").y + VERTICAL_MARGIN;

+	setBounds(bounds);

+	gc.dispose();

+}

+/**

+ * The width of the header item at position 'itemIndex' is about to change.

+ * Adjust the width of the header. Scroll and redraw all header items

+ * starting behind the item identified by 'itemIndex'.

+ * @param itemIndex - specifies the item after which the redraw

+ *	should begin.

+ * @param widthDiff - the width change of the item. 

+ *	> 0 = item width increased. < 0 = item width decreased

+ */

+void widthChange(int itemIndex, int widthDiff) {

+	Rectangle bounds = getBounds(itemIndex);

+	Rectangle headerBounds = getBounds();

+	

+	if (bounds != null) {

+		if (itemIndex != TableColumn.FILL) {						// ignore the fill column header item - there's nothing to redraw anyway

+			scroll(

+				bounds.x + bounds.width + widthDiff, 0,				// destination x, y

+				bounds.x + bounds.width, 0,							// source x, y

+				headerBounds.width + widthDiff, headerBounds.height, false);

+			redraw(bounds.x, 0, bounds.width, bounds.height, false);

+		}

+	}

+	headerBounds.width += widthDiff;

+	setBounds(headerBounds);

+}

+

+}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java
index 7141de7..0bd2a8b 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java
@@ -23,7 +23,8 @@
 }

 

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SEPARATOR) != 0) {

 		int border = getBorderWidth ();

 		int width = border * 2, height = border * 2;

@@ -120,7 +121,6 @@
 		int [] args = {

 			OS.Pt_ARG_SEP_FLAGS, orientation, OS.Pt_SEP_VERTICAL | OS.Pt_SEP_HORIZONTAL,

 			OS.Pt_ARG_SEP_TYPE, type, 0,

-			OS.Pt_ARG_FILL_COLOR, display.WIDGET_BACKGROUND, 0,

 			OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,

 		};		

 		handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);

@@ -138,7 +138,6 @@
 		OS.Pt_ARG_FLAGS, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,

 		OS.Pt_ARG_HORIZONTAL_ALIGNMENT, alignment, 0,

 		OS.Pt_ARG_VERTICAL_ALIGNMENT, verticalAlign, 0,

-		OS.Pt_ARG_FILL_COLOR, display.WIDGET_BACKGROUND, 0,

 		OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,

 	};

 	handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);

@@ -146,7 +145,8 @@
 }

 

 public int getAlignment () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SEPARATOR) != 0) return 0;

 	if ((style & SWT.LEFT) != 0) return SWT.LEFT;

 	if ((style & SWT.CENTER) != 0) return SWT.CENTER;

@@ -155,7 +155,8 @@
 }

 

 public Image getImage () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return image;

 }

 

@@ -164,7 +165,8 @@
 }

 

 public String getText () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SEPARATOR) != 0) return "";

 	return text;

 }

@@ -201,7 +203,8 @@
 }

 

 public void setAlignment (int alignment) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SEPARATOR) != 0) return;

 	if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return;

 	style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);

@@ -218,7 +221,6 @@
 }

 

 public boolean setFocus () {

-	checkWidget();

 	return false;

 }

 

@@ -228,14 +230,12 @@
 }

 

 public void setImage (Image image) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SEPARATOR) != 0) return;

 	this.image = image;

 	int imageHandle = 0;

-	if (image != null) {

-		if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

-		imageHandle = copyPhImage (image.handle);

-	}

+	if (image != null) imageHandle = copyPhImage (image.handle);

 	int [] args = {

 		OS.Pt_ARG_LABEL_IMAGE, imageHandle, 0,

 		OS.Pt_ARG_LABEL_TYPE, OS.Pt_IMAGE, 0

@@ -245,7 +245,8 @@
 }

 

 public void setText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if ((style & SWT.SEPARATOR) != 0) return;

 	text = string;

@@ -295,7 +296,7 @@
 		ptr2 = OS.malloc (buffer2.length);

 		OS.memmove (ptr2, buffer2, buffer2.length);

 	}

-	replaceMnemonic (mnemonic, true, true);

+	replaceMnemonic (mnemonic, 0);

 	int [] args = {

 		OS.Pt_ARG_TEXT_STRING, ptr, 0,

 		OS.Pt_ARG_LABEL_TYPE, OS.Pt_Z_STRING, 0,

@@ -306,4 +307,4 @@
 	OS.free (ptr2);

 }

 

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
index bf24970..042df8e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
@@ -22,7 +22,8 @@
 }

 

 public void add (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	byte [] buffer = Converter.wcsToMbcs (null, string, true);

 	int ptr = OS.malloc (buffer.length);

@@ -32,7 +33,8 @@
 }

 

 public void addSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Selection,typedListener);

@@ -40,7 +42,8 @@
 }

 

 public void add (String string, int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (index == -1) error (SWT.ERROR_INVALID_RANGE);

 	byte [] buffer = Converter.wcsToMbcs (null, string, true);

@@ -57,7 +60,8 @@
 }

 

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 

 	/**

 	 * Feature in Photon - The preferred width calculated by

@@ -140,13 +144,15 @@
 }

 

 public void deselect (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (index < 0) return;

 	OS.PtListUnselectPos (handle, index + 1);

 }

 

 public void deselect (int start, int end) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (start > end) return;

 	if ((style & SWT.SINGLE) != 0) {

 		int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};

@@ -162,7 +168,8 @@
 }

 

 public void deselect (int [] indices) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (indices.length == 0) return;

 	for (int i=0; i<indices.length; i++) {

@@ -174,7 +181,8 @@
 }

 

 public void deselectAll () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	int count = args [1];

@@ -188,7 +196,8 @@
 }

 

 public String getItem (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {

 		OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,

 		OS.Pt_ARG_ITEMS, 0, 0,

@@ -207,14 +216,16 @@
 }

 

 public int getItemCount () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }	

 

 public int getItemHeight () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {

 		OS.Pt_ARG_LIST_TOTAL_HEIGHT, 0, 0,

 		OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,

@@ -233,7 +244,8 @@
 }

 

 public String [] getItems () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {

 		OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,

 		OS.Pt_ARG_ITEMS, 0, 0,

@@ -254,7 +266,8 @@
 }

 

 public String [] getSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] indices = getSelectionIndices ();

 	String [] result = new String [indices.length];

 	for (int i=0; i<indices.length; i++) {

@@ -264,14 +277,16 @@
 }

 

 public int getSelectionCount () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {OS.Pt_ARG_LIST_SEL_COUNT, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public int getSelectionIndex () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {

 		OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,

 		OS.Pt_ARG_SELECTION_INDEXES, 0, 0,

@@ -284,7 +299,8 @@
 }

 

 public int [] getSelectionIndices () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {

 		OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,

 		OS.Pt_ARG_SELECTION_INDEXES, 0, 0,

@@ -300,7 +316,8 @@
 }

 

 public int getTopIndex () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {OS.Pt_ARG_TOP_ITEM_POS, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1] - 1;

@@ -314,13 +331,15 @@
 }

 

 public int indexOf (String string) {

-	checkWidget();

+	if (!isValidThread ()) error(SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error(SWT.ERROR_WIDGET_DISPOSED);

 	byte [] buffer = Converter.wcsToMbcs (null, string, true);

 	return OS.PtListItemPos(handle, buffer) - 1;

 }

 

 public int indexOf (String string, int start) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	

 	// NOT DONE - start is ignored

@@ -328,7 +347,8 @@
 }

 

 public boolean isSelected (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {

 		OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,

 		OS.Pt_ARG_SELECTION_INDEXES, 0, 0,

@@ -364,7 +384,8 @@
 }

 

 public void remove (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	if (!(0 <= index && index < args [1])) error (SWT.ERROR_INVALID_RANGE);

@@ -373,14 +394,16 @@
 }

 

 public void remove (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int index = indexOf (string, 0);

 	if (index == -1) error (SWT.ERROR_ITEM_NOT_REMOVED);

 	remove (index);

 }

 

 public void remove (int [] indices) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);

 	int [] newIndices = new int [indices.length];

 	System.arraycopy (indices, 0, newIndices, 0, indices.length);

@@ -397,7 +420,8 @@
 }

 

 public void remove (int start, int end) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	if (!(0 < start && start <= end && end < args [1])) {

@@ -409,12 +433,14 @@
 }

 

 public void removeAll () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	OS.PtListDeleteAllItems (handle);

 }

 

 public void removeSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Selection, listener);

@@ -422,7 +448,8 @@
 }

 

 public void select (int start, int end) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (start > end) return;

 	int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

@@ -443,7 +470,8 @@
 }

 

 public void select (int [] indices) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (indices.length == 0) return;

 	int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};

@@ -461,7 +489,8 @@
 }

 

 public void select (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (index < 0) return;

 	int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

@@ -472,7 +501,8 @@
 }

 

 public void selectAll () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SINGLE) != 0) return;

 	int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

@@ -483,7 +513,8 @@
 }

 

 public void setItem (int index, String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

@@ -498,7 +529,8 @@
 }

 

 public void setItems (String [] items) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (items == null) error (SWT.ERROR_NULL_ARGUMENT);

 	OS.PtListDeleteAllItems (handle);

 	int[] itemsPtr = new int [items.length];

@@ -530,7 +562,8 @@
 }

 

 public void setSelection (String [] items) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (items == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if ((style & SWT.MULTI) != 0) deselectAll ();

 	for (int i=items.length-1; i>=0; --i) {

@@ -548,13 +581,15 @@
 }

 

 public void setTopIndex (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {OS.Pt_ARG_TOP_ITEM_POS, index + 1, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void showSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {

 		OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,

 		OS.Pt_ARG_SELECTION_INDEXES, 0, 0,

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java
index 07e7bd9..535e473 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java
@@ -54,14 +54,16 @@
 }

 

 public void addHelpListener (HelpListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Help, typedListener);

 }

 

 public void addMenuListener (MenuListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Hide,typedListener);

@@ -89,7 +91,8 @@
 }

 

 public MenuItem getDefaultItem () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return defaultItem;

 }

 

@@ -100,14 +103,16 @@
 }

 

 public boolean getEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_FLAGS, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return (args [1] & OS.Pt_BLOCKED) == 0;

 }

 

 public int getItemCount () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int count = 0;

 	int child = OS.PtWidgetChildBack (handle);

 	if (child != 0 && (style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);

@@ -119,7 +124,8 @@
 }

 

 public MenuItem getItem (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (index < 0) error (SWT.ERROR_INVALID_RANGE);	

 	int i = 0;

 	int child = OS.PtWidgetChildBack (handle);

@@ -136,7 +142,8 @@
 }

 

 public MenuItem [] getItems () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int count = 0;

 	int child = OS.PtWidgetChildBack (handle);

 	if (child != 0  && (style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);

@@ -176,28 +183,31 @@
 }

 

 public Decorations getParent () {

-	checkWidget();

 	return parent;

 }

 

 public MenuItem getParentItem () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return cascade;

 }

 

 public Menu getParentMenu () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (cascade != null) return cascade.parent;

 	return null;

 }

 

 public Shell getShell () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent.getShell ();

 }

 

 public boolean getVisible () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return true;

 }

 

@@ -207,7 +217,8 @@
 }

 

 public int indexOf (MenuItem item) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);

 	int i = 0;

 	int child = OS.PtWidgetChildBack (handle);

@@ -222,14 +233,16 @@
 }

 

 public boolean isEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	Menu parentMenu = getParentMenu ();

 	if (parentMenu == null) return getEnabled ();

 	return getEnabled () && parentMenu.isEnabled ();

 }

 

 public boolean isVisible () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return getVisible ();

 }

 

@@ -268,14 +281,16 @@
 }

 

 public void removeHelpListener (HelpListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Help, listener);

 }

 

 public void removeMenuListener (MenuListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Hide, listener);

@@ -283,13 +298,14 @@
 }

 

 public void setDefaultItem (MenuItem item) {

-	checkWidget();

-	if (item != null && item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	defaultItem = item;

 }

 

 public void setEnabled (boolean enabled) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {

 		OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_BLOCKED, OS.Pt_BLOCKED,

 		OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_GHOST, OS.Pt_GHOST,

@@ -298,15 +314,16 @@
 }

 

 public void setLocation (int x, int y) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	this.x = x;  this.y = y;

 	hasLocation = true;

 }

 

 public void setVisible (boolean visible) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.POP_UP) == 0) return;

-	if (visible == OS.PtWidgetIsRealized (handle)) return;

 	if (visible) {

 		PhPoint_t pt = new PhPoint_t ();

 		pt.x = (short) x;

@@ -330,4 +347,4 @@
 	}

 }

 

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java
index 3c41a80..69268fe 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java
@@ -27,21 +27,24 @@
 }

 

 public void addArmListener (ArmListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Arm, typedListener);

 }

 

 public void addHelpListener (HelpListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Help, typedListener);

 }

 

 public void addSelectionListener (SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener(listener);

 	addListener (SWT.Selection,typedListener);

@@ -93,7 +96,8 @@
 }

 

 public int getAccelerator () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return accelerator;

 }

 

@@ -104,7 +108,8 @@
 }

 

 public boolean getEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	/*

 	* Bug in Photon. The Pt_BLOCKED flag of a menu item is cleared

 	* when its parent menu is realized. The fix is to remember

@@ -118,7 +123,8 @@
 }

 

 public Menu getMenu () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return menu;

 }

 

@@ -128,12 +134,14 @@
 }

 

 public Menu getParent () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent;

 }

 

 public boolean getSelection () {	

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;

 	int [] args = {OS.Pt_ARG_FLAGS, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

@@ -157,8 +165,7 @@
 }

 

 int processActivate (int info) {

-	showMenu ();

-	return OS.Pt_CONTINUE;

+	return processArm (info);

 }

 

 int processSelection (int info) {

@@ -189,8 +196,42 @@
 }

 

 int processArm(int info) {

-	postEvent (SWT.Arm);

-	showMenu ();

+	if (menu != null) {

+		int menuHandle = menu.handle;

+		if (!OS.PtWidgetIsRealized (menuHandle)) {

+			if ((parent.style & SWT.BAR) == 0) {

+				int [] args = {OS.Pt_ARG_MENU_FLAGS, OS.Pt_MENU_CHILD, OS.Pt_MENU_CHILD};

+				OS.PtSetResources (menuHandle, args.length / 3, args);

+			}

+			OS.PtReParentWidget (menuHandle, handle);

+			

+			/*

+			* Bug in Photon. PtPositionMenu does not position the menu

+			* properly when the menu is a direct child a menu bar item.

+			* The fix is to position the menu ourselfs.

+			*/

+			if ((parent.style & SWT.BAR) != 0) {

+				PhPoint_t pt = new PhPoint_t ();

+				short [] x = new short [1], y = new short [1];

+				OS.PtGetAbsPosition (handle, x, y);

+				pt.x = x [0];

+				pt.y = y [0];

+				int [] args = {OS.Pt_ARG_HEIGHT, 0, 0};

+				OS.PtGetResources (handle, args.length / 3, args);

+				pt.y += args [1];

+				int ptr = OS.malloc (PhPoint_t.sizeof);

+				OS.memmove (ptr, pt, PhPoint_t.sizeof);

+				args = new int [] {OS.Pt_ARG_POS, ptr, 0};

+				OS.PtSetResources (menuHandle, args.length / 3, args);

+				OS.free (ptr);

+			} else {

+				OS.PtPositionMenu (menuHandle, null);

+			}

+			

+			menu.sendEvent (SWT.Show);

+			OS.PtRealizeWidget (menuHandle);

+		}

+	}

 	return OS.Pt_CONTINUE;

 }

 

@@ -213,14 +254,16 @@
 }

 

 public void removeArmListener (ArmListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Arm, listener);

 }

 

 public void removeHelpListener (HelpListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Help, listener);

@@ -243,7 +286,8 @@
 }

 

 public void removeSelectionListener (SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Selection, listener);

@@ -251,7 +295,9 @@
 }

 

 public void setAccelerator (int accelerator) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

 	removeAccelerator ();

 

 	this.accelerator = accelerator;		

@@ -271,7 +317,8 @@
 }

 

 public void setEnabled (boolean enabled) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	this.enabled = enabled;

 	int [] args = {

 		OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_BLOCKED, OS.Pt_BLOCKED,

@@ -281,7 +328,8 @@
 }

 

 public void setImage (Image image) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SEPARATOR) != 0) return;

 	super.setImage (image);

 	

@@ -289,12 +337,12 @@
 }

 

 public void setMenu (Menu menu) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.CASCADE) == 0) {

 		error (SWT.ERROR_MENUITEM_NOT_CASCADE);

 	}

 	if (menu != null) {

-		if (menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 		if ((menu.style & SWT.DROP_DOWN) == 0) {

 			error (SWT.ERROR_MENU_NOT_DROP_DOWN);

 		}

@@ -322,14 +370,16 @@
 }

 

 public void setSelection (boolean selected) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;

 	int [] args = {OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void setText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	super.setText (string);

 	char [] text = new char [string.length ()];

@@ -379,7 +429,7 @@
 		OS.memmove (ptr3, buffer3, buffer3.length);

 	}

 	if ((parent.style & SWT.BAR) != 0) {

-		replaceMnemonic (mnemonic, false, true);

+		replaceMnemonic (mnemonic, OS.Pk_KM_Alt);

 	}

 	int [] args = {

 		OS.Pt_ARG_TEXT_STRING, ptr1, 0,

@@ -400,42 +450,4 @@
 	if (OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);

 }

 

-void showMenu() {

-	if (menu == null)  return;

-	int menuHandle = menu.handle;

-	if (!OS.PtWidgetIsRealized (menuHandle)) {

-		if ((parent.style & SWT.BAR) == 0) {

-			int [] args = {OS.Pt_ARG_MENU_FLAGS, OS.Pt_MENU_CHILD, OS.Pt_MENU_CHILD};

-			OS.PtSetResources (menuHandle, args.length / 3, args);

-		}

-		OS.PtReParentWidget (menuHandle, handle);

-		

-		/*

-		* Bug in Photon. PtPositionMenu does not position the menu

-		* properly when the menu is a direct child a menu bar item.

-		* The fix is to position the menu ourselfs.

-		*/

-		if ((parent.style & SWT.BAR) != 0) {

-			PhPoint_t pt = new PhPoint_t ();

-			short [] x = new short [1], y = new short [1];

-			OS.PtGetAbsPosition (handle, x, y);

-			pt.x = x [0];

-			pt.y = y [0];

-			int [] args = {OS.Pt_ARG_HEIGHT, 0, 0};

-			OS.PtGetResources (handle, args.length / 3, args);

-			pt.y += args [1];

-			int ptr = OS.malloc (PhPoint_t.sizeof);

-			OS.memmove (ptr, pt, PhPoint_t.sizeof);

-			args = new int [] {OS.Pt_ARG_POS, ptr, 0};

-			OS.PtSetResources (menuHandle, args.length / 3, args);

-			OS.free (ptr);

-		} else {

-			OS.PtPositionMenu (menuHandle, null);

-		}

-		

-		menu.sendEvent (SWT.Show);

-		OS.PtRealizeWidget (menuHandle);

-	}

-}

-

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java
index 8323fcb..461ea7a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java
@@ -23,7 +23,8 @@
 * Not done - check Windows

 */

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int width = wHint, height = hHint;

 	if ((style & SWT.HORIZONTAL) != 0) {

 		if (width == SWT.DEFAULT) {

@@ -68,28 +69,32 @@
 }

 

 public int getMaximum () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public int getMinimum () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public int getSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_GAUGE_VALUE, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public void setMaximum (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int minimum = getMinimum();

 	if (0 <= minimum && minimum < value) {

 		int [] args = {OS.Pt_ARG_MAXIMUM, value, 0};

@@ -98,7 +103,8 @@
 }

 

 public void setMinimum (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int maximum = getMaximum();

 	if (0 <= value && value < maximum) {

 		int [] args = {OS.Pt_ARG_MINIMUM, value, 0};

@@ -107,9 +113,10 @@
 }

 

 public void setSelection (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (value < 0) return;

 	int [] args = {OS.Pt_ARG_GAUGE_VALUE, value, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java
index ee396dd..323de08 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java
@@ -23,7 +23,8 @@
 }

 

 public void addSelectionListener (SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Selection,typedListener);

@@ -31,7 +32,8 @@
 }

 

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int border = getBorderWidth ();

 	int width = border * 2, height = border * 2;

 	if ((style & SWT.HORIZONTAL) != 0) {

@@ -216,11 +218,12 @@
 	return OS.Pt_CONTINUE;

 }

 public void removeSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Selection, listener);

 	eventTable.unhook (SWT.DefaultSelection,listener);	

 }

 

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java
index 9ce22bc..400c247 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java
@@ -18,7 +18,8 @@
 }

 

 public void addSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Selection,typedListener);

@@ -30,7 +31,8 @@
 }

 

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	PhDim_t dim = new PhDim_t();

 	if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);

 	OS.PtWidgetPreferredSize(handle, dim);

@@ -57,7 +59,6 @@
 		OS.Pt_ARG_PAGE_INCREMENT, 10, 0,

 		OS.Pt_ARG_SLIDER_SIZE, 10, 0,

 		OS.Pt_ARG_ORIENTATION, (style & SWT.HORIZONTAL) != 0 ? OS.Pt_HORIZONTAL : OS.Pt_VERTICAL, 0,

-		OS.Pt_ARG_FILL_COLOR, display.WIDGET_BACKGROUND, 0,

 		OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,

 	};

 	handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);

@@ -65,35 +66,40 @@
 }

 

 public int getIncrement () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_INCREMENT, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public int getMaximum () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public int getMinimum () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public int getPageIncrement () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public int getSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_SCROLL_POSITION, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

@@ -116,7 +122,8 @@
 }

 

 public void removeSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Selection, listener);

@@ -124,31 +131,36 @@
 }

 

 public void setIncrement (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_INCREMENT, value, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void setMaximum (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_MAXIMUM, value - 1, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void setMinimum (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_MINIMUM, value, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void setPageIncrement (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_PAGE_INCREMENT, value, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void setSelection (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_SCROLL_POSITION, value, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java
index 7c741a4..586641b 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java
@@ -32,7 +32,8 @@
 }

 

 public void addSelectionListener (SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener(listener);

 	addListener (SWT.Selection,typedListener);

@@ -77,68 +78,78 @@
 }

 

 public boolean getEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_FLAGS, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return (args [1] & OS.Pt_BLOCKED) == 0;

 }

 

 public int getIncrement () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_INCREMENT, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public int getMinimum () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public int getMaximum () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public int getPageIncrement () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public Scrollable getParent () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent;

 }

 

 public int getSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_SCROLL_POSITION, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public Point getSize () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return new Point (args [1], args [4]);

 }

 

 public int getThumb () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_SLIDER_SIZE, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public boolean getVisible () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int topHandle = topHandle ();

 	int [] args = {OS.Pt_ARG_FLAGS, 0, 0};

 	OS.PtGetResources (topHandle, args.length / 3, args);

@@ -151,12 +162,14 @@
 }

 

 public boolean isEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return getEnabled () && parent.isEnabled ();

 }

 

 public boolean isVisible () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return OS.PtWidgetIsRealized (handle);

 }

 

@@ -196,7 +209,8 @@
 }

 

 public void removeSelectionListener (SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Selection, listener);

@@ -217,7 +231,8 @@
 }

 

 public void setEnabled (boolean enabled) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {

 		OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_BLOCKED, OS.Pt_BLOCKED,

 		OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_GHOST, OS.Pt_GHOST,

@@ -225,43 +240,50 @@
 	OS.PtSetResources (handle, args.length / 3, args);

 }

 public void setIncrement (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_INCREMENT, value, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void setMaximum (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_MAXIMUM, value - 1, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void setMinimum (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_MINIMUM, value, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void setPageIncrement (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_PAGE_INCREMENT, value, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void setSelection (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_SCROLL_POSITION, value, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void setThumb (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_SLIDER_SIZE, value, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (selection < 0) return;

 	if (minimum < 0) return;

 	if (maximum < 0) return;

@@ -281,7 +303,8 @@
 }

 

 public void setVisible (boolean visible) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (visible == OS.PtWidgetIsRealized (handle)) return;

 	int [] args = {

 		OS.Pt_ARG_FLAGS, visible ? 0 : OS.Pt_DELAY_REALIZE, OS.Pt_DELAY_REALIZE,

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java
index da16147..6781db2 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java
@@ -47,7 +47,8 @@
 }

 

 public Rectangle computeTrim (int x, int y, int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	PhRect_t rect = new PhRect_t ();

 	PhArea_t area = new PhArea_t ();

 	rect.ul_x = (short) x;

@@ -67,7 +68,8 @@
 }

 

 public Rectangle getClientArea () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	PhRect_t rect = new PhRect_t ();

 	int vParent = OS.PtValidParent (handle, OS.PtContainer ());

 	if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);

@@ -78,12 +80,14 @@
 }

 

 public ScrollBar getHorizontalBar () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return horizontalBar;

 }

 

 public ScrollBar getVerticalBar () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return verticalBar;

 }

 

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItem.java
new file mode 100755
index 0000000..87acefd
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItem.java
@@ -0,0 +1,320 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+

+import org.eclipse.swt.*;

+import org.eclipse.swt.graphics.*;

+

+/**

+ * This class implements common behavior of TreeItem and TableItem.

+ */

+abstract class SelectableItem extends Item {

+	protected static final int CHECKBOX_PADDING = 1;	// Space behind check box, before item image or text

+		

+	private SelectableItemWidget parent;				// parent widget of the receiver

+	private boolean isSelected = false;					// item selection state

+	private boolean isChecked = false;					// item checked state. Can be one of checked and unchecked

+	private boolean isGrayed = false;					// item grayed state. The gray state is combined with the 

+														// checked state to create gray checked and gray unchecked.

+/**

+ * Create a new instance of the receiver.

+ * @param parent - widget the receiver is created in 

+ * @param style - widget style. see Widget class for details

+ */

+SelectableItem(SelectableItemWidget parent, int style) {

+	super(parent, style);

+	setParent(parent);	

+}

+public void dispose() {

+	if (!isValidWidget ()) return;

+	super.dispose();

+	doDispose();

+}

+void doDispose() {

+	setParent(null);

+}

+/**

+ * Draw the check box of the receiver at 'position' using 'gc'.

+ * @param gc - GC to draw on. 

+ * @param destinationPosition - position on the GC to draw at.

+ * @return Answer the position where drawing stopped.

+ */

+Point drawCheckbox(GC gc, Point position) {

+	SelectableItemWidget parent = getSelectableParent();

+	Image image;

+	Point imageExtent;

+	Rectangle imageBounds;

+	int imageOffset;

+	int xInset;

+	int yInset;

+

+	if (getGrayed() == true) {

+		image = parent.getGrayUncheckedImage();

+	}

+	else {

+		image = parent.getUncheckedImage();

+	}

+	if (image != null) {

+		imageExtent = parent.getCheckBoxExtent();

+		imageOffset = (parent.getItemHeight() - imageExtent.y) / 2;

+		gc.drawImage(image, position.x, position.y + imageOffset);

+		if (getChecked() == true) {

+			image = parent.getCheckMarkImage();

+			imageBounds = image.getBounds();

+			xInset = (imageExtent.x - imageBounds.width) / 2;

+			yInset = (imageExtent.y - imageBounds.height) / 2;

+			gc.drawImage(image, position.x + xInset, position.y + imageOffset + yInset);

+		}

+		position.x += imageExtent.x;

+	}

+	position.x += CHECKBOX_PADDING;									// leave extra space behind check box	

+	return position;

+}

+void drawInsertMark(GC gc, Point position) {

+	SelectableItemWidget parent = getSelectableParent();

+	Point selectionExtent = getSelectionExtent();

+	final int markerWidth = getInsertMarkWidth();

+	int insertMarkYOffset = 0;

+

+	if (selectionExtent == null) {

+		return;

+	}

+	if (parent.isInsertAfter()) {

+		insertMarkYOffset = selectionExtent.y - markerWidth;

+	}

+	gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_BLACK));

+	gc.fillRectangle(position.x, position.y + insertMarkYOffset, selectionExtent.x, markerWidth);

+	gc.setBackground(parent.getBackground());

+}

+/**

+ * Answer the bounding rectangle of the item check box.

+ * All points within this rectangle hit the check box.

+ */

+Rectangle getCheckboxBounds() {

+	SelectableItemWidget parent = getSelectableParent();

+	Point checkBoxExtent;

+	int redrawPosition;

+	Rectangle checkboxBounds = new Rectangle(0, 0, 0, 0);

+

+	if (isCheckable() == true) {

+		checkboxBounds.x = getCheckboxXPosition();

+		redrawPosition = parent.getRedrawY(this);

+		if (redrawPosition != -1) {

+			checkboxBounds.y = redrawPosition;

+		}

+		checkBoxExtent = parent.getCheckBoxExtent();

+		checkboxBounds.width = checkBoxExtent.x;

+		checkboxBounds.height = checkBoxExtent.y;

+		checkboxBounds.y += (parent.getItemHeight() - checkBoxExtent.y) / 2;

+	}

+	return checkboxBounds;

+}

+/**

+ * Answer the x position of the item check box

+ */

+abstract int getCheckboxXPosition();

+/**

+ * Return whether or not the receiver is checked.

+ * Always return false if the parent of the receiver does not

+ * have the CHECK style.

+ */

+public boolean getChecked() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	boolean checked = false;

+	

+	if (isCheckable() == true) {

+		checked = isChecked;

+	}

+	return checked;

+}

+/**

+ * Answer the display of the receiver's parent widget.

+ */

+public Display getDisplay() {

+	SelectableItemWidget parent = getSelectableParent();

+

+	if (parent == null) {

+		error(SWT.ERROR_WIDGET_DISPOSED);

+	}

+	return parent.getDisplay();

+}

+

+/**

+ * Gets the grayed state.

+ * <p>

+ * @return the item grayed state.

+ *

+ * @exception SWTError <ul>

+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>

+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>

+ *	</ul>

+ */

+public boolean getGrayed () {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	boolean grayed = false;

+	

+	if (isCheckable() == true) {

+		grayed = isGrayed;

+	}

+	return grayed;

+}

+/**

+ * Return the width in pixels of the line drawn to indicate the 

+ * drop insert position during a drag and drop operation.

+ */

+int getInsertMarkWidth() {

+	return 2;

+}

+/**

+ * Answer the parent widget of the receiver.

+ */

+SelectableItemWidget getSelectableParent() {

+	return parent;

+}

+/**

+ * Answer the background color to use for drawing the 

+ * selection rectangle.

+ */

+Color getSelectionBackgroundColor() {

+	Display display = getSelectableParent().getDisplay();	

+

+	return display.getSystemColor(SWT.COLOR_LIST_SELECTION);

+}

+/**

+ * Return the size of the rectangle drawn to indicate the

+ * selected state of the receiver.

+ */

+abstract Point getSelectionExtent();

+/** 

+ * Answer the foreground color to use for drawing the 

+ * selection rectangle.

+ */

+Color getSelectionForegroundColor() {

+	Display display = getSelectableParent().getDisplay();	

+

+	return display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);

+}

+/**

+ * Return the x position of the selection rectangle

+ */

+abstract int getSelectionX();

+/**

+ * Answer whether 'posiiton' is inside the item check box.

+ * @return

+ *	true - item check box hit

+ *	false - item check box not hit

+ */

+boolean isCheckHit(Point position) {

+	boolean isCheckHit = false;

+	

+	if (isCheckable() == true) {

+		isCheckHit = getCheckboxBounds().contains(position);

+	}

+	return isCheckHit;

+}

+/**

+ * Return whether or not the receiver has a check box and can 

+ * be checked.

+ */

+boolean isCheckable() {

+	return (getSelectableParent().getStyle() & SWT.CHECK) != 0;

+}

+/**

+ * Answer whether the receiver is selected.

+ * @return 

+ *	true - the receiver is selected

+ * 	false - the receiver is not selected

+ */

+boolean isSelected() {

+	return isSelected;

+}

+/**

+ * Redraw the insert mark

+ * @param yPosition - y position in the receiver's client area 

+ *	where the item should be drawn.

+ */

+void redrawInsertMark(int yPosition) {

+	SelectableItemWidget parent = getSelectableParent();

+	Point selectionExtent = getSelectionExtent();

+	int redrawHeight = getInsertMarkWidth();

+

+	if (selectionExtent != null) {

+		parent.redraw(getSelectionX(), yPosition, selectionExtent.x, redrawHeight, false);

+		parent.redraw(getSelectionX(), yPosition + selectionExtent.y - redrawHeight, selectionExtent.x, redrawHeight, false);

+	}	

+}

+/**

+ * Redraw the selection

+ * @param yPosition - y position in the receiver's client area 

+ *	where the item should be drawn.

+ */

+void redrawSelection(int yPosition) {

+	SelectableItemWidget parent = getSelectableParent();

+	Point selectionExtent = getSelectionExtent();

+

+	if (selectionExtent != null) {

+		parent.redraw(getSelectionX(), yPosition, selectionExtent.x, selectionExtent.y, false);

+	}

+}

+/**

+ * Set the checked state to 'checked' if the parent of the 

+ * receiver has the CHECK style.

+ */

+public void setChecked(boolean checked) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItemWidget parent = getSelectableParent();

+	Rectangle redrawRectangle = getCheckboxBounds();

+

+	if (isCheckable() == true && isChecked != checked) {

+		isChecked = checked;

+		parent.redraw(

+			redrawRectangle.x, redrawRectangle.y, 

+			redrawRectangle.width, redrawRectangle.height, false);

+	}	

+}

+

+/**

+ * Sets the grayed state.

+ * <p>

+ * @param grayed the new grayed state.

+ *

+ * @exception SWTError <ul>

+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>

+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>

+ *	</ul>

+ */

+public void setGrayed (boolean grayed) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItemWidget parent = getSelectableParent();

+	Rectangle redrawRectangle = getCheckboxBounds();

+

+	if (isCheckable() == true && isGrayed != grayed) {

+		isGrayed = grayed;

+		parent.redraw(

+			redrawRectangle.x, redrawRectangle.y, 

+			redrawRectangle.width, redrawRectangle.height, false);

+	}	

+}

+

+/**

+ * Set the receiver's parent widget to 'parent'.

+ */

+void setParent(SelectableItemWidget parent) {

+	this.parent = parent;

+}

+/**

+ * Set whether the receiver is selected.

+ * @param selected - true=the receiver is selected

+ * 	false=the receiver is not selected

+ */

+void setSelected(boolean selected) {

+	isSelected = selected;

+}

+}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItemWidget.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItemWidget.java
new file mode 100755
index 0000000..384fe03
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItemWidget.java
@@ -0,0 +1,2051 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+ 

+import org.eclipse.swt.*;

+import org.eclipse.swt.graphics.*;

+import java.io.*;

+import java.util.*;

+ 

+/**

+ * This class is intended for widgets that display data of 

+ * type Item. It provides a framework for scrolling and 

+ * handles the screen refresh required when adding and 

+ * removing items. 

+ */

+abstract class SelectableItemWidget extends Composite {

+	private static final int DEFAULT_WIDTH = 64;		// used in computeSize if width could not be calculated

+	private static final int DEFAULT_HEIGHT = 64;		// used in computeSize if height could not be calculated

+	private static final int HORIZONTAL_SCROLL_INCREMENT = 5;	// number of pixel the tree is moved

+														// during horizontal line scrolling

+	private static ImageData UncheckedImageData;		// deselected check box image data. used to create an image at run time

+	private static ImageData GrayUncheckedImageData;		// grayed deselected check box image data. used to create an image at run time

+	private static ImageData CheckMarkImageData;		// check mark image data for check box. used to create an image at run time

+	static {

+		initializeImageData();

+	}

+

+	private int topIndex = 0;							// index of the first visible item

+	private int itemHeight = 0;							// height of a table item

+	private Point itemImageExtent = null;				// size of the item images. Null unless an image is set for any item

+	private int textHeight = -1;

+	private int contentWidth = 0;						// width of the widget data (ie. table rows/tree items)

+	private int horizontalOffset = 0;

+	private Vector selectedItems;						// indices of the selected items																

+	private SelectableItem lastSelectedItem;			// item that was selected last

+	private SelectableItem lastFocusItem;				// item that had the focus last. Always equals lastSelectedItem 

+														// for mouse selection but may differ for keyboard selection

+	private SelectableItem insertItem;					// item that draws the insert marker to indicate the drop location in a drag and drop operation

+	private boolean isInsertAfter;						// indicates where the insert marker is rendered, at the top or bottom of 'insertItem'

+	private boolean isCtrlSelection = false;			// the most recently selected item was 

+														// selected using the Ctrl modifier key

+	private boolean isRemovingAll = false;				// true=all items are removed. Used to optimize screen updates and to control item selection on dispose.

+	private boolean hasFocus;					// workaround for 1FMITIE

+	private Image uncheckedImage;					// deselected check box

+	private Image grayUncheckedImage;						// grayed check box

+	private Image checkMarkImage;					// check mark for selected check box

+	private Point checkBoxExtent = null;				// width, height of the item check box

+	private Listener listener;					// event listener used for all events. Events are dispatched 

+														// to handler methods in handleEvents(Event)

+	private int drawCount = 0;					// used to reimplement setRedraw(boolean)

+/**

+ * Create a new instance of ScrollableItemWidget.

+ * @param parent - the parent window of the new instance

+ * @param style - window style for the new instance

+ */

+SelectableItemWidget(Composite parent, int style) {

+	super(parent, style | SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_REDRAW_RESIZE);

+	initialize();

+}

+/**

+ * The SelectableItem 'item' has been added to the tree.

+ * Calculate the vertical scroll bar.

+ * Update the screen to display the new item.

+ * @param item - item that has been added to the receiver.

+ */

+void addedItem(SelectableItem item, int index) {

+	calculateVerticalScrollbar();

+	if (getLastFocus() == null) {						// if no item has the focus

+		setLastFocus(item, true);								// set focus to new (must be first) item 

+	}	

+}

+/**

+ * The SelectableItem 'item' is about to be added to the tree.

+ * @param item - item that is about to be added to the receiver.

+ */

+void addingItem(SelectableItem item, int index) {

+	if (index >= 0 && index <= getBottomIndex()) {

+		scrollVerticalAddingItem(index);

+	}

+}

+/**

+ * Set the scroll range of the horizontal scroll bar.

+ * Resize the scroll bar if the scroll range maximum 

+ * has changed.

+ */

+void calculateHorizontalScrollbar() {

+	int newMaximum = getContentWidth();

+	ScrollBar horizontalBar = getHorizontalBar();

+

+	if (horizontalBar.getMaximum() != newMaximum) {

+		// The call to setMaximum is ignored if newMaximum is 0.

+		// Therefore we can not rely on getMaximum to subsequently return the number of 

+		// items in the receiver. We always have to use getVisibleItemCount().

+		// Never rely on getMaximum to return what you set. It may not accept the 

+		// value you set. Even if you use a valid value now the implementation may change 

+		// later. That's what caused 1FRLOSG.

+		horizontalBar.setMaximum(newMaximum);

+		if (getVerticalBar().getVisible() == false) {			// remove these lines 

+			horizontalBar.setMaximum(newMaximum);				// when PR 1FIG5CG 

+		}														// is fixed

+		resizeHorizontalScrollbar();

+	}	

+}

+/**

+ * Calculate the height of items in the receiver.

+ * Only the image height is calculated if an item height 

+ * has already been calculated. Do nothing if both the item 

+ * height and the image height have already been calculated

+ */

+void calculateItemHeight(SelectableItem item) {

+	GC gc;

+	String itemText;

+	int itemHeight = -1;

+

+	if (itemImageExtent != null && textHeight != -1) {

+		return;

+	}

+	itemText = item.getText();

+	if (itemText != null && textHeight == -1) {

+		gc = new GC(this);

+		itemHeight = gc.stringExtent(itemText).y;

+		textHeight = itemHeight;

+		gc.dispose();

+	}

+	if (itemImageExtent == null) {

+		itemImageExtent = getImageExtent(item);

+		if (itemImageExtent != null) {

+			if (itemImageExtent.y > textHeight) {

+				itemHeight = itemImageExtent.y;

+			}

+			else {

+				itemHeight = textHeight;

+			}

+		}

+	}

+	itemHeight += getItemPadding();									// make sure that there is empty space below the image/text

+	if (itemHeight > getItemHeight()) {								// only set new item height if it's higher because new, 

+		setItemHeight(itemHeight);									// smaller item height may not include an icon

+	}

+}

+/**

+ * Calculate the range of items that need to be selected given

+ * the clicked item identified by 'hitItemIndex'

+ * @param hitItemIndex - item that was clicked and that the new

+ *	selection range will be based on. This index is relative to 

+ *	the top index.

+ */

+int [] calculateShiftSelectionRange(int hitItemIndex) {

+	int selectionRange[] = new int[] {-1, -1};

+	SelectableItem closestItem = null;

+	SelectableItem selectedItem;

+	Enumeration selectedItems = getSelectionVector().elements();

+	

+	while (selectedItems.hasMoreElements() == true) {

+		selectedItem = (SelectableItem) selectedItems.nextElement();

+		if (closestItem == null) {

+			closestItem = selectedItem;

+		}

+		else

+		if (Math.abs(hitItemIndex - getVisibleIndex(selectedItem)) < 

+			Math.abs(hitItemIndex - getVisibleIndex(closestItem))) {

+			closestItem = selectedItem;

+		}

+	}

+	if (closestItem == null) {								// no item selected

+		closestItem = getLastSelection();					// item selected last may still have the focus

+	}

+	if (closestItem != null) {

+		selectionRange[0] = getVisibleIndex(closestItem);

+		selectionRange[1] = hitItemIndex;

+	}

+	return selectionRange;

+}

+/**

+ * Set the scroll range of the vertical scroll bar.

+ * Resize the scroll bar if the scroll range maximum 

+ * has changed.

+ */

+void calculateVerticalScrollbar() {

+	int newMaximum = getVisibleItemCount();

+	ScrollBar verticalBar = getVerticalBar();

+

+	// The call to setMaximum is ignored if newMaximum is 0.

+	// Therefore we can not rely on getMaximum to subsequently return the number of 

+	// items in the receiver. We always have to use getVisibleItemCount().

+	// Never rely on getMaximum to return what you set. It may not accept the 

+	// value you set. Even if you use a valid value now the implementation may change 

+	// later. That's what caused 1FRLOSG.

+	verticalBar.setMaximum(newMaximum);

+	if (getHorizontalBar().getVisible() == false) {			// remove these lines 

+		verticalBar.setMaximum(newMaximum);					// when PR 1FIG5CG 

+	}														// is fixed	

+	resizeVerticalScrollbar();

+}

+

+/**

+ * Answer the size of the receiver needed to display all items.

+ * The length of the longest item in the receiver is used for the 

+ * width.

+ */

+public Point computeSize(int wHint, int hHint, boolean changed) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);	

+	int width = getContentWidth();

+	int height = getItemCount() * getItemHeight();

+	int style = getStyle();

+	int scrollBarWidth = computeTrim(0, 0, 0, 0).width;

+				

+	if (width == 0) {

+		width = DEFAULT_WIDTH;

+	}

+	if (height == 0) {

+		height = DEFAULT_HEIGHT;

+	}

+	if (wHint != SWT.DEFAULT) {

+		width = wHint;

+	}

+	if (hHint != SWT.DEFAULT) {

+		height = hHint;

+	}

+	if ((getStyle() & SWT.V_SCROLL) != 0) {

+		width += scrollBarWidth; 

+	}

+	if ((getStyle() & SWT.H_SCROLL) != 0) {

+		height += scrollBarWidth;

+	}

+	return new Point(width, height);

+}

+/**

+ * Do a ctrl+shift selection meaning the ctrl and shift keys 

+ * were pressed when the mouse click on an item occurred. 

+ * If an already selected item was clicked the focus is moved to 

+ * that item.

+ * If the previous selection was a ctrl or ctrl+shift selection

+ * the range between the last selected item and the clicked item

+ * is selected.

+ * Otherwise a regular shift selection is performed.

+ * @param hitItem - specifies the clicked item

+ * @param hitItemIndex - specifies the index of the clicked item 

+ *	relative to the first item.

+ */

+void ctrlShiftSelect(SelectableItem hitItem, int hitItemIndex) {

+	int fromIndex = -1;

+	int toIndex = -1;

+	int lastSelectionIndex = -1;

+	int selectionRange[];

+	SelectableItem lastSelection = getLastSelection();

+

+	if (lastSelection != null) {

+		lastSelectionIndex = getVisibleIndex(lastSelection);

+	}

+	if ((getSelectionVector().contains(hitItem) == true) &&		// clicked an already selected item?

+		(hitItemIndex != lastSelectionIndex)) {				// and click was not on last selected item?

+		setLastSelection(hitItem, true);							// set last selection which also sets the focus

+	}

+	else

+	if (isCtrlSelection() == true) {						// was last selection ctrl/ctrl+shift selection? 

+		fromIndex = lastSelectionIndex;						// select from last selection

+		toIndex = hitItemIndex;

+	}

+	else {													// clicked outside existing selection range

+		selectionRange = calculateShiftSelectionRange(hitItemIndex);

+		fromIndex = selectionRange[0];

+		toIndex = selectionRange[1];

+	}

+	if (fromIndex != -1 && toIndex != -1) {

+		selectRange(fromIndex, toIndex);

+	}

+}

+/**

+ * Deselect 'item'.

+ * @param item - item that should be deselected

+ */

+void deselect(SelectableItem item) {

+	Vector selectedItems = getSelectionVector();

+	

+	if ((item != null) && (item.isSelected() == true)) {

+		item.setSelected(false);

+		redrawSelection(item);

+		selectedItems.removeElement(item);

+	}

+}

+/**

+ * Deselect all item except 'keepSelected'. 

+ * @param keepSelected - item that should remain selected

+ */

+void deselectAllExcept(SelectableItem keepSelected) {

+	Vector selectedItems = getSelectionVector();

+	Vector deselectedItems = new Vector(selectedItems.size());

+	Enumeration elements = selectedItems.elements();

+	SelectableItem item;

+

+	// deselect and repaint previously selected items

+	while (elements.hasMoreElements() == true) {

+		item = (SelectableItem) elements.nextElement();

+		if (item.isSelected() == true && item != keepSelected) {		

+			item.setSelected(false);

+			// always redraw the selection, even if item is redrawn again 

+			// in setLastSelection. Fixes 1G0GQ8W

+			redrawSelection(item);

+			deselectedItems.addElement(item);

+		}

+	}

+	elements = deselectedItems.elements();

+	while (elements.hasMoreElements() == true) {

+		item = (SelectableItem) elements.nextElement();

+		selectedItems.removeElement(item);

+	}

+	setLastSelection(keepSelected, false);

+}

+/**

+ * Deselect all items except those in 'keepSelected'. 

+ * @param keepSelected - items that should remain selected

+ */

+void deselectAllExcept(Vector keepSelected) {

+	Vector selectedItems = getSelectionVector();

+	Vector deselectedItems = new Vector(selectedItems.size());

+	Enumeration elements = selectedItems.elements();

+	SelectableItem item;

+

+	// deselect and repaint previously selected items

+	while (elements.hasMoreElements() == true) {

+		item = (SelectableItem) elements.nextElement();

+		if (item.isSelected() == true && keepSelected.contains(item) == false) {		

+			item.setSelected(false);

+			// always redraw the selection, even if item is redrawn again 

+			// in setLastSelection. Fixes 1G0GQ8W

+			redrawSelection(item);

+			deselectedItems.addElement(item);

+		}

+	}

+	elements = deselectedItems.elements();

+	while (elements.hasMoreElements() == true) {

+		item = (SelectableItem) elements.nextElement();

+		selectedItems.removeElement(item);

+	}

+	if (keepSelected.size() > 0) {

+		setLastSelection((SelectableItem) keepSelected.firstElement(), false);

+	}

+}

+/**

+ * Deselect 'item'. Notify listeners.

+ * @param item - item that should be deselected

+ */

+void deselectNotify(SelectableItem item) {

+	Event event = new Event();

+

+	if (item.isSelected() == true) {

+		deselect(item);

+		setLastSelection(item, true);		

+		update();												// looks better when event notification takes long to return

+	}

+	event.item = item;

+	notifyListeners(SWT.Selection, event);

+}

+/**

+ * Deselect all items starting at and including 'fromIndex'

+ * stopping at and including 'toIndex'.

+ * @param fromIndex - index relative to the first item where 

+ *	deselection should start. Deselecion includes 'fromIndex'.

+ * @param toIndex - index relative to the first item where

+ *	deselection should stop. Deselecion includes 'toIndex'.

+ */

+void deselectRange(int fromIndex, int toIndex) {

+	if (fromIndex > toIndex) {

+		for (int i = toIndex; i <= fromIndex; i++) {

+			deselect(getVisibleItem(i));

+		}

+	}

+	else

+	if (fromIndex < toIndex) {		

+		for (int i = toIndex; i >= fromIndex; i--) {

+			deselect(getVisibleItem(i));

+		}

+	}

+	setLastSelection(getVisibleItem(fromIndex), true);

+}

+/**

+ * Modifier Key		Action

+ * None				Remove old selection, move selection down one item

+ * Ctrl				Keep old selection, move input focus down one item

+ * Shift			Extend selection by one item.

+ * Modifier Key is ignored when receiver has single selection style.

+ * @param keyMask - the modifier key that was pressed

+ */

+void doArrowDown(int keyMask) {

+	SelectableItem lastFocus = getLastFocus();

+	SelectableItem newFocus;

+	int focusItemIndex = getVisibleIndex(lastFocus);

+	

+	if (focusItemIndex < (getVisibleItemCount() - 1)) { 			// - 1 because indices are 0 based

+		focusItemIndex++;

+		newFocus = getVisibleItem(focusItemIndex);

+		if (keyMask == SWT.CTRL && isMultiSelect() == true) {

+			setLastFocus(newFocus, true);

+		}

+		else

+		if (keyMask == SWT.SHIFT && isMultiSelect() == true) {

+			shiftSelect(newFocus, focusItemIndex);

+		}		

+		else {

+			deselectAllExcept(newFocus);

+			selectNotify(newFocus);

+		}

+	}

+}

+/**

+ * Modifier Key		Action

+ * None				Scroll receiver to the left

+ * Ctrl				See None above

+ * Shift			See None above

+ * @param keyMask - the modifier key that was pressed

+ */

+void doArrowLeft(int keyMask) {

+	ScrollBar horizontalBar = getHorizontalBar();

+	int scrollSelection = horizontalBar.getSelection();

+	int scrollAmount;

+

+	if (horizontalBar.getVisible() == false) {

+		return;

+	}	

+	scrollAmount = Math.min(HORIZONTAL_SCROLL_INCREMENT, scrollSelection);

+	horizontalBar.setSelection(scrollSelection - scrollAmount);

+	setHorizontalOffset(horizontalBar.getSelection() * -1);

+}

+/**

+ * Modifier Key		Action

+ * None				Scroll receiver to the right

+ * Ctrl				See None above

+ * Shift			See None above

+ * @param keyMask - the modifier key that was pressed

+ */

+void doArrowRight(int keyMask) {

+	ScrollBar horizontalBar = getHorizontalBar();

+	int scrollSelection = horizontalBar.getSelection();

+	int scrollAmount;

+

+	if (horizontalBar.getVisible() == false) {

+		return;

+	}

+	scrollAmount = Math.min(									// scroll by the smaller of 

+		HORIZONTAL_SCROLL_INCREMENT, 							// the scroll increment

+		horizontalBar.getMaximum() 								// and the remaining scroll range

+			- horizontalBar.getPageIncrement() 

+			- scrollSelection);	

+	horizontalBar.setSelection(scrollSelection + scrollAmount);

+	setHorizontalOffset(horizontalBar.getSelection() * -1);

+}

+/**

+ * Modifier Key		Action

+ * None				Remove old selection, move selection up one item

+ * Ctrl				Keep old selection, move input focus up one item

+ * Shift			Extend selection by one item.

+ * Modifier Key is ignored when receiver has single selection style. 

+ * @param keyMask - the modifier key that was pressed

+ */

+void doArrowUp(int keyMask) {

+	SelectableItem lastFocus = getLastFocus();

+	SelectableItem newFocus;

+	int focusItemIndex = getVisibleIndex(lastFocus);

+	

+	if (focusItemIndex > 0) {

+		focusItemIndex--;

+		newFocus = getVisibleItem(focusItemIndex);

+		if (keyMask == SWT.CTRL && isMultiSelect() == true) {

+			setLastFocus(newFocus, true);

+		}

+		else

+		if (keyMask == SWT.SHIFT && isMultiSelect() == true) {

+			shiftSelect(newFocus, focusItemIndex);

+		}		

+		else {

+			deselectAllExcept(newFocus);

+			selectNotify(newFocus);

+		}

+	}

+}

+/**

+ * Perform a selection operation on the item check box.

+ * @param item - the item that was clicked

+ */

+void doCheckItem(SelectableItem item) {

+	Event event = new Event();

+	

+	item.setChecked(!item.getChecked());

+	event.item = item;

+	event.detail = SWT.CHECK;

+	notifyListeners(SWT.Selection, event);

+}

+/**

+ * Free resources.

+ */

+void doDispose() {

+	setRemovingAll(true);

+	getSelectionVector().removeAllElements();

+	lastFocusItem = null;

+	lastSelectedItem = null;		

+	if (uncheckedImage != null) {

+		uncheckedImage.dispose();

+	}	

+	if (grayUncheckedImage != null) {

+		grayUncheckedImage.dispose();

+	}

+	if (checkMarkImage != null) {

+		checkMarkImage.dispose();

+	}

+}

+/**

+ * Modifier Key		Action

+ * None				Remove old selection, move selection to the 

+ *					last item

+ * Ctrl				Keep old selection, move input focus to the 

+ *					last item

+ * Shift			Extend selection to the last item.

+ * Modifier Key is ignored when receiver has single selection style.

+ * @param keyMask - the modifier key that was pressed

+ */

+void doEnd(int keyMask) {

+	SelectableItem lastFocus = getLastFocus();

+	SelectableItem newFocus;

+	int focusItemIndex = getVisibleIndex(lastFocus);

+	int lastItemIndex = getVisibleItemCount() - 1;				// - 1 because indices are 0 based

+		

+	if (focusItemIndex < lastItemIndex) {

+		newFocus = getVisibleItem(lastItemIndex);

+		if (keyMask == SWT.CTRL && isMultiSelect() == true) {

+			setLastFocus(newFocus, true);

+		}

+		else

+		if (keyMask == SWT.SHIFT && isMultiSelect() == true) {

+			shiftSelect(newFocus, lastItemIndex);

+		}

+		else {

+			deselectAllExcept(newFocus);

+			selectNotify(newFocus);

+		}

+	}

+}

+/**

+ * Modifier Key		Action

+ * None				Remove old selection, move selection to the 

+ *					first item

+ * Ctrl				Keep old selection, move input focus to the 

+ *					first item

+ * Shift			Extend selection to the first item.

+ * Modifier Key is ignored when receiver has single selection style. 

+ * @param keyMask - the modifier key that was pressed

+ */

+void doHome(int keyMask) {

+	SelectableItem lastFocus = getLastFocus();

+	SelectableItem newFocus;

+	int firstItemIndex = 0;

+

+	if (getVisibleIndex(lastFocus) > firstItemIndex) {

+		newFocus = getVisibleItem(firstItemIndex);

+		if (keyMask == SWT.CTRL && isMultiSelect() == true) {

+			setLastFocus(newFocus, true);

+		}

+		else

+		if (keyMask == SWT.SHIFT && isMultiSelect() == true) {

+			shiftSelect(newFocus, firstItemIndex);

+		}		

+		else {

+			deselectAllExcept(newFocus);

+			selectNotify(newFocus);

+		}

+	}

+}

+/**

+ * Perform a mouse select action according to the key state 

+ * mask in 'eventStateMask'.

+ * Key state mask is ignored when receiver has the single selection 

+ * style.

+ * @param item - the item that was clicked

+ * @param itemIndex - the index of the clicked item relative 

+ *	to the first item of the receiver

+ * @param eventStateMask - the key state mask of the mouse event

+ * @param button - the mouse button that was pressed

+ */

+void doMouseSelect(SelectableItem item, int itemIndex, int eventStateMask, int button) {

+	if (((eventStateMask & SWT.CTRL) != 0) &&

+		((eventStateMask & SWT.SHIFT) != 0) &&

+		(isMultiSelect() == true)) {

+		if (getSelectionVector().size() == 0) {			// no old selection?

+			selectNotify(item);							// do standard CTRL selection

+		}

+		else {

+			ctrlShiftSelect(item, itemIndex);

+		}

+		setCtrlSelection(true);

+	}

+	else 

+	if (((eventStateMask & SWT.SHIFT) != 0) && (isMultiSelect() == true)) {

+		shiftSelect(item, itemIndex);

+		setCtrlSelection(false);

+	}

+	else

+	if (((eventStateMask & SWT.CTRL) != 0) && (isMultiSelect() == true)) {

+		toggleSelectionNotify(item);

+		setCtrlSelection(true);

+	}

+	else

+	if (button != 3 || item.isSelected() == false) {

+		// only select the item (and deselect all others) if the mouse click is 

+		// not a button 3 click or if a previously unselected item was clicked.

+		// Fixes 1G97L65

+		deselectAllExcept(item);

+		selectNotify(item);

+		setCtrlSelection(false);

+	}

+}

+/**

+ * Modifier Key		Action

+ * None				Remove old selection, move selection one page down

+ * Ctrl				Keep old selection, move input focus one page down

+ * Shift			Extend selection one page down

+ * One page is the number of items that can be displayed in the 

+ * receiver's canvas without truncating the last item.

+ * The selection is set to the last item if there is no full page 

+ * of items left.

+ * Modifier Key is ignored when receiver has single selection style.  

+ * @param keyMask - the modifier key that was pressed

+ */

+void doPageDown(int keyMask) {

+	SelectableItem newFocus;

+	int focusItemIndex = getVisibleIndex(getLastFocus());

+	int lastItemIndex = getVisibleItemCount() - 1;				// - 1 because indices are 0 based

+	int visibleItemCount;

+		

+	if (focusItemIndex < lastItemIndex) {

+		visibleItemCount = getItemCountWhole();

+		focusItemIndex = Math.min(

+			lastItemIndex, 

+			focusItemIndex + (visibleItemCount - 1));

+		newFocus = getVisibleItem(focusItemIndex);

+		if (newFocus == null) {

+			return;

+		}

+		if (keyMask == SWT.CTRL && isMultiSelect() == true) {

+			setLastFocus(newFocus, true);

+		}

+		else

+		if (keyMask == SWT.SHIFT && isMultiSelect() == true) {

+			shiftSelect(newFocus, focusItemIndex);

+		}		

+		else {

+			deselectAllExcept(newFocus);		

+			selectNotify(newFocus);

+		}

+	}

+}

+/**

+ * Modifier Key		Action

+ * None				Remove old selection, move selection one page up

+ * Ctrl				Keep old selection, move input focus one page up

+ * Shift			Extend selection one page up

+ * One page is the number of items that can be displayed in the 

+ * receiver's canvas without truncating the last item.

+ * The selection is set to the first item if there is no full page 

+ * of items left.

+ * Modifier Key is ignored when receiver has single selection style.  

+ * @param keyMask - the modifier key that was pressed

+ */

+void doPageUp(int keyMask) {

+	SelectableItem newFocus;	

+	int focusItemIndex = getVisibleIndex(getLastFocus());

+	int visibleItemCount;

+

+	if (focusItemIndex > 0) {

+		visibleItemCount = getItemCountWhole();

+		focusItemIndex = Math.max(

+			0, 

+			focusItemIndex - (visibleItemCount - 1));

+		newFocus = getVisibleItem(focusItemIndex);

+		if (keyMask == SWT.CTRL && isMultiSelect() == true) {

+			setLastFocus(newFocus, true);

+		}

+		else

+		if (keyMask == SWT.SHIFT && isMultiSelect() == true) {

+			shiftSelect(newFocus, focusItemIndex);

+		}		

+		else {

+			deselectAllExcept(newFocus);		

+			selectNotify(newFocus);

+		}

+	}

+}

+/**

+ * Modifier Key		Action

+ * Ctrl				Keep old selection, toggle selection of the item 

+ *					that has the input focus

+ * Shift			Extend selection to the item that has the input 

+ *					focus

+ * Ctrl & Shift		Set selection to the item that has input focus

+ * Do nothing if receiver has single selection style.

+ * @param keyMask - the modifier key that was pressed

+ */

+

+void doSpace(int keyMask) {

+	SelectableItem item = getLastFocus();

+	int itemIndex = getVisibleIndex(item);

+

+	if (keyMask == SWT.NULL && item.isSelected() == false) {	// do simple space select in SINGLE and MULTI mode

+		deselectAllExcept(item);

+		selectNotify(item);

+		return;

+	}

+	if (isMultiSelect() == false || item == null) {

+		return;

+	}

+	if (keyMask == SWT.CTRL) {

+		toggleSelectionNotify(item);

+	}

+	else

+	if (((keyMask & SWT.CTRL) != 0) && ((keyMask & SWT.SHIFT) != 0)) {

+		deselectAllExcept(item);

+		selectNotify(item);

+	}

+	else

+	if (keyMask == SWT.SHIFT) {

+		shiftSelect(item, itemIndex);

+	}

+}

+/**

+ * Make sure that free space at the bottom of the receiver is 

+ * occupied.

+ * There will be new space available below the last item when the 

+ * receiver's height is increased. In this case the receiver

+ * is scrolled down to occupy the new space.if the top item is 

+ * not the first item of the receiver.

+ */

+void claimBottomFreeSpace() {

+	int clientAreaItemCount = getItemCountWhole();

+	int topIndex = getTopIndex();

+	int newTopIndex;

+	int lastItemIndex = getVisibleItemCount() - topIndex;

+

+	if ((topIndex > 0) && 

+		(lastItemIndex > 0) &&

+		(lastItemIndex < clientAreaItemCount)) {

+		newTopIndex = Math.max(0, topIndex-(clientAreaItemCount-lastItemIndex));

+		setTopIndex(newTopIndex, true);

+	}

+}

+/**

+ * Make sure that free space at the right side of the receiver is 

+ * occupied. 

+ * There will be new space available at the right side of the receiver 

+ * when the receiver's width is increased. In this case the receiver 

+ * is scrolled to the right to occupy the new space.if possible.

+ */

+void claimRightFreeSpace() {

+	int clientAreaWidth = getClientArea().width;

+	int newHorizontalOffset = clientAreaWidth - getContentWidth();

+	

+	if (newHorizontalOffset - getHorizontalOffset() > 0) {			// item is no longer drawn past the right border of the client area

+		newHorizontalOffset = Math.min(0, newHorizontalOffset);		// align the right end of the item with the right border of the 

+		setHorizontalOffset(newHorizontalOffset);					// client area (window is scrolled right)	

+	}

+}

+/**	Not used right now. Replace focusIn/focusOut with this method once 

+ *	Display.getFocusWindow returns the new focus window on FocusOut event 

+ *	(see 1FMITIE)

+ * The focus has moved in to or out of the receiver.

+ * Redraw the item selection to reflect the focus change.

+ * @param event - the focus change event

+ */

+void focusChange(Event event) {

+	Enumeration items = getSelectionVector().elements();

+	SelectableItem lastFocusItem = getLastFocus();

+	SelectableItem item;

+

+	while (items.hasMoreElements() == true) {

+		item = (SelectableItem) items.nextElement();

+		redrawSelection(item);

+	}

+	if (lastFocusItem != null) {

+		redrawSelection(lastFocusItem);

+	}

+}

+/**

+ * The focus has moved in to or out of the receiver.

+ * Redraw the item selection to reflect the focus change.

+ * @param event - the focus change event

+ */

+void focusIn(Event event) {

+	Enumeration items = getSelectionVector().elements();

+	SelectableItem lastFocusItem = getLastFocus();

+	SelectableItem item;

+

+	// Workaround for 1FMITIE

+	hasFocus = true;

+	while (items.hasMoreElements() == true) {

+		item = (SelectableItem) items.nextElement();

+		redrawSelection(item);

+	}

+	if (lastFocusItem != null) {

+		redrawSelection(lastFocusItem);

+	}

+	// Fix blank item on slow machines/VMs. Also fixes 1G0IFMZ. 

+	update();

+}

+/**

+ * The focus has moved in to or out of the receiver.

+ * Redraw the item selection to reflect the focus change.

+ * @param event - the focus change event

+ */

+void focusOut(Event event) {

+	Enumeration items = getSelectionVector().elements();

+	SelectableItem lastFocusItem = getLastFocus();

+	SelectableItem item;

+

+	// Workaround for 1FMITIE

+	hasFocus = false;

+	while (items.hasMoreElements() == true) {

+		item = (SelectableItem) items.nextElement();

+		redrawSelection(item);

+	}

+	if (lastFocusItem != null) {

+		redrawSelection(lastFocusItem);

+	}

+	// Fix blank item on slow machines/VMs. Also fixes 1G0IFMZ. 

+	update();								

+}

+/**

+ * Answer the index of the last item position in the receiver's 

+ * client area.

+ * @return 0-based index of the last item position in the tree's 

+ * 	client area.

+ */

+int getBottomIndex() {

+	return getTopIndex() + getItemCountTruncated(getClientArea());

+}

+/**

+ * Answer the size of the check box image.

+ * The calculation is cached and assumes that the images for 

+ * the checked and unchecked state are the same size.

+ */

+Point getCheckBoxExtent() {

+	Image checkedImage;

+	Rectangle imageBounds;

+	

+	if (checkBoxExtent == null) {

+		checkedImage = getUncheckedImage();

+		if (checkedImage != null) {

+			imageBounds = checkedImage.getBounds();

+			checkBoxExtent = new Point(imageBounds.width, imageBounds.height);

+		}

+		else {

+			checkBoxExtent = new Point(0, 0);

+		}

+	}

+	return checkBoxExtent;

+}

+/**

+ * Answer the image for the selected check box

+ * Answer null if the image couldn't be loaded.

+ */

+Image getCheckMarkImage() {

+	InputStream resourceStream;

+	

+	if (checkMarkImage == null) {

+		checkMarkImage = new Image(getDisplay(), CheckMarkImageData);

+	}

+	return checkMarkImage;

+}

+/**

+ * Answer the width of the receiver's content. 

+ * Needs to be set by subclasses.

+ */

+int getContentWidth() {

+	return contentWidth;

+}

+/**

+ * Answer the horizontal drawing offset used for scrolling.

+ * This is < 0 if the receiver has been scrolled to the left,

+ * > 0 if the receiver has been scrolled to the right and 0

+ * if the receiver has not been scrolled.

+ */

+int getHorizontalOffset() {

+	return horizontalOffset;

+}

+

+/**

+ * Answer the size of item images. Calculated during the item 

+ * height calculation.

+ */

+Point getImageExtent() {

+	return itemImageExtent;

+}

+/**

+ * Answer the image extent of 'item'. Overridden by subclasses.

+ */

+Point getImageExtent(SelectableItem item) {

+	Image image = item.getImage();

+	Rectangle imageBounds;

+	Point imageExtent = null;

+

+	if (image != null) {

+		imageBounds = image.getBounds();

+		imageExtent = new Point(imageBounds.width, imageBounds.height);

+	}

+	return imageExtent;

+}

+/**

+ * Answer the index of 'item' in the receiver.

+ */

+abstract int getIndex(SelectableItem item);

+/** 

+ * Answer the first and last index of items that can be displayed in 

+ * the area defined by 'clipRectangle'. This includes partial items.

+ * @return

+ *	Array - 

+ *		First element is the index of the first item in 'clipRectangle'.

+ *		Second element is the index of the last item in 'clipRectangle'.

+ */

+int[] getIndexRange(Rectangle clipRectangle) {

+	int visibleRange[] = new int[] {0, 0};

+

+	visibleRange[0] = clipRectangle.y / getItemHeight();

+	visibleRange[1] = 

+		visibleRange[0] + 

+		getItemCountTruncated(clipRectangle) - 1;			// - 1 because item index is 0 based

+	return visibleRange;

+}

+/**

+ * Return the item that draws the marker indicating the insert location 

+ * in a drag and drop operation

+ */

+SelectableItem getInsertItem() {

+	return insertItem;

+}

+/**

+ * Answer the number of items in the receiver.

+ */

+public abstract int getItemCount();

+/**

+ * Answer the number of items that can be displayed in 'rectangle'.

+ * The result includes partially visible items.

+ */

+int getItemCountTruncated(Rectangle rectangle) {

+	int itemHeight = getItemHeight();

+	int itemCount = 0;

+	int startIndex;

+

+	startIndex = rectangle.y / itemHeight;

+	itemCount = (int) Math.ceil(((float) rectangle.y + rectangle.height) / itemHeight)-startIndex;

+	return itemCount;

+}

+/**

+ * Answer the number of items that can be displayed in the client 

+ * area of the receiver.

+ * The result only includes items that completely fit into the 

+ * client area.

+ */

+int getItemCountWhole() {

+	return getClientArea().height / getItemHeight();

+}

+/**

+ * Answer the height of an item in the receiver.

+ * The item height is the greater of the item icon height and 

+ * text height of the first item that has text or an image 

+ * respectively.

+ * Calculate a default item height based on the font height if

+ * no item height has been calculated yet.

+ */

+public int getItemHeight() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	GC gc;

+	if (itemHeight == 0) {

+		gc = new GC(this);

+		itemHeight = gc.stringExtent("String").y + getItemPadding();		// initial item height=font height + item spacing

+											// use real font height here when available in SWT, instead of GC.textExtent

+		gc.dispose();

+	}		

+	return itemHeight;

+}

+/**

+ * Answer the number of pixels that should be added to the item height.

+ */

+int getItemPadding() {

+	return 2 + getDisplay().textHighlightThickness;

+}

+/**

+ * Answer the item that most recently received the input focus.

+ */

+SelectableItem getLastFocus() {

+	return lastFocusItem;

+}

+/**

+ * Answer the item that was selected most recently.

+ */ 

+SelectableItem getLastSelection() {

+	return lastSelectedItem;

+}

+/**

+ * Answer the event listener used for all events. Events are 

+ * dispatched to handler methods in handleEvents(Event).

+ * This scheme saves a lot of inner classes.

+ */

+Listener getListener() {

+	return listener;

+}

+/**

+ * Answer the y coordinate at which 'item' is drawn. 

+ * @param item - SelectableItem for which the paint position 

+ *	should be returned

+ * @return the y coordinate at which 'item' is drawn.

+ *	Return -1 if 'item' is not an item of the receiver

+ */

+int getRedrawY(SelectableItem item) {

+	int redrawIndex = getVisibleIndex(item);

+	int redrawY = -1;

+

+	if (redrawIndex != -1) {

+		redrawY = (redrawIndex - getTopIndex()) * getItemHeight();

+	}

+	return redrawY;

+}

+/**

+ * Answer the number of selected items in the receiver.

+ */

+public int getSelectionCount() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return getSelectionVector().size();

+}

+/**

+ * Answer the selected items of the receiver. 

+ * @return The selected items of the receiver stored in a Vector.

+ *	Returned Vector is empty if no items are selected.

+ */

+Vector getSelectionVector() {

+	return selectedItems;

+}

+/**

+ * Answer the width of 'text' in pixel.

+ * Answer 0 if 'text' is null.

+ */

+int getTextWidth(String text) {

+	int textWidth = 0;

+	GC gc;

+

+	if (text != null) {

+		gc = new GC(this);

+		textWidth = gc.stringExtent(text).x;

+		gc.dispose();

+	}

+	return textWidth;

+}

+/**

+ * Answer the index of the first visible item in the receiver's 

+ * client area.

+ * @return 0-based index of the first visible item in the 

+ * 	receiver's client area.

+ */

+int getTopIndex() {

+	return topIndex;

+}

+/**

+ * Answer the image for the deselected check box.

+ */

+Image getUncheckedImage() {

+	InputStream resourceStream;

+	

+	if (uncheckedImage == null) {

+		uncheckedImage = new Image(getDisplay(), UncheckedImageData);

+	}

+	return uncheckedImage;

+}

+

+/**

+ * Answer the image for the grayed eck box.

+ */

+Image getGrayUncheckedImage() {

+	InputStream resourceStream;

+	

+	if (grayUncheckedImage == null) {

+		grayUncheckedImage = new Image(getDisplay(), GrayUncheckedImageData);

+	}

+	return grayUncheckedImage;

+}

+

+/**

+ * Answer the index of 'item' in the receiver.

+ * Answer -1 if the item is not visible.

+ * The returned index must refer to a visible item.

+ * Note: 

+ * 	Visible in this context does not neccessarily mean that the 

+ * 	item is displayed on the screen. It only means that the item 

+ * 	would be displayed if it is located inside the receiver's 

+ * 	client area.

+ *	Normally, every item of the receiver is visible.

+ */

+abstract int getVisibleIndex(SelectableItem item);

+/**

+ * Answer the SelectableItem located at 'itemIndex' in the 

+ * receiver.

+ * @param itemIndex - location of the SelectableItem object 

+ *	to return

+ */

+abstract SelectableItem getVisibleItem(int itemIndex);

+/**

+ * Answer the number of visible items of the receiver.

+ * Note: 

+ * 	Visible in this context does not neccessarily mean that the 

+ * 	item is displayed on the screen. It only means that the item 

+ * 	would be displayed if it is located inside the receiver's 

+ * 	client area.

+ *	Normally every item of the receiver is visible.

+ */

+int getVisibleItemCount() {

+	return getItemCount();

+}

+/**

+ * Answer the y coordinate at which 'item' is drawn. 

+ * @param item - SelectableItem for which the paint position 

+ *	should be returned

+ * @return the y coordinate at which 'item' is drawn.

+ *	Return -1 if 'item' is null or outside the client area

+ */

+abstract int getVisibleRedrawY(SelectableItem item);

+/**

+ * Handle the events the receiver is listening to.

+ */

+void handleEvents(Event event) {

+	switch (event.type) {

+		case SWT.Dispose:

+			doDispose();

+			break;		

+		case SWT.KeyDown:

+			keyDown(event);

+			break;

+		case SWT.Resize:

+			resize(event);

+			break;

+		case SWT.Selection:

+			if (event.widget == getVerticalBar()) {

+				scrollVertical(event);

+			}

+			else

+			if (event.widget == getHorizontalBar()) {

+				scrollHorizontal(event);

+			}

+			break;

+		case SWT.FocusOut:

+			focusOut(event);

+			break;

+		case SWT.FocusIn:

+			focusIn(event);

+			break;			

+	}	

+}

+

+

+

+/**

+ * Answer whether 'item' has the input focus.

+ */

+boolean hasFocus(SelectableItem item) {

+	return (isFocusControl() && item == getLastFocus());

+}

+/**

+ * Initialize the receiver. Add event listeners and set widget 

+ * colors.

+ */

+void initialize() {

+	Display display = getDisplay();	

+	ScrollBar horizontalBar = getHorizontalBar();

+	ScrollBar verticalBar = getVerticalBar();

+

+	// listener may be needed by overridden installListeners()

+	listener = new Listener() {

+		public void handleEvent(Event event) {handleEvents(event);}

+	};	

+	setSelectionVector(new Vector());

+	installListeners();

+	calculateVerticalScrollbar();

+	calculateHorizontalScrollbar();

+	horizontalBar.setMinimum(0);

+	verticalBar.setMinimum(0);

+	horizontalBar.setIncrement(HORIZONTAL_SCROLL_INCREMENT);

+	setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));

+	setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));

+}

+/**

+ * Initialize the ImageData used for the checked/unchecked images.

+ */ 

+static void initializeImageData() {

+	PaletteData uncheckedPalette = new PaletteData(	

+		new RGB[] {new RGB(128, 128, 128), new RGB(255, 255, 255)});

+	PaletteData grayUncheckedPalette = new PaletteData(	

+		new RGB[] {new RGB(128, 128, 128), new RGB(192, 192, 192)});

+	PaletteData checkMarkPalette = new PaletteData(	

+		new RGB[] {new RGB(0, 0, 0), new RGB(252, 3, 251)});

+	byte[] checkbox = new byte[] {0, 0, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 0, 0};

+

+	// Each pixel is represented by one bit in the byte data. 

+	// The bit references the palette position (0 or 1). Each pixel row of an image is padded to one byte.

+	// Arguments: width, height, depth, palette, scanline padding, data

+	UncheckedImageData =		new ImageData(11, 11, 1, uncheckedPalette, 2, checkbox);

+	GrayUncheckedImageData = 	new ImageData(11, 11, 1, grayUncheckedPalette, 2, checkbox);

+	CheckMarkImageData =		new ImageData(7, 7, 1, checkMarkPalette, 1, new byte[] {-4, -8, 112, 34, 6, -114, -34});

+	CheckMarkImageData.transparentPixel = 1;

+}

+/**

+ * Add event listeners to the tree widget and its scroll bars.

+ */

+void installListeners() {

+	Listener listener = getListener();

+	

+	addListener(SWT.Dispose, listener);	

+	addListener(SWT.Resize, listener);

+	addListener(SWT.KeyDown, listener);

+	addListener(SWT.FocusOut, listener);

+	addListener(SWT.FocusIn, listener);

+	

+	getVerticalBar().addListener(SWT.Selection, listener);

+	getHorizontalBar().addListener(SWT.Selection, listener);

+}

+/**

+ * Answer whether the currently selected items were selected 

+ * using the ctrl key.

+ */

+boolean isCtrlSelection() {

+	return isCtrlSelection;

+}

+/**

+ * Answer true if all items in the widget are disposed.

+ * Used to optimize item disposal. Prevents unnecessary screen 

+ * updates.

+ */

+boolean isRemovingAll() {

+	return isRemovingAll;

+}

+/**

+ * Answer whether the receiver has the input focus.

+ * Workaround for 1FMITIE

+ */

+public boolean isFocusControl() {

+	return hasFocus;

+}

+/**

+ * Return whether the drop insert position is before or after the 

+ * item set using motif_setInsertMark.

+ * @return 

+ *	true=insert position is after the insert item

+ *	false=insert position is before the insert item

+ */

+boolean isInsertAfter() {

+	return isInsertAfter;

+}

+/**

+ * Answer whether the receiver has the MULTI selection style set.

+ * @return

+ *	true = receiver is in multiple selection mode.

+ *	false = receiver is in single selection mode.

+ */

+boolean isMultiSelect() {

+	return ((getStyle() & SWT.MULTI) != 0);

+}

+/**

+ * The item identified by 'changedItem' has changed. 

+ * Calculate the item height based on the new item data (it might 

+ * now have an image which could also be the first image in the 

+ * receiver)

+ * Redraw the whole window if the item height has changed. Otherwise 

+ * redraw only the changed item or part of it depending on the 

+ * 'repaintStartX' and 'repaintWidth' parameters.

+ * @param changedItem - the item that has changed

+ * @param repaintStartX - x position of the item redraw. 

+ * @param repaintWidth - width of the item redraw.

+ */

+void itemChanged(SelectableItem changedItem, int repaintStartX, int repaintWidth) {

+	int yPosition;

+	int itemHeight;

+	int oldItemHeight = getItemHeight();

+	Point oldImageExtent = getImageExtent();

+	

+	calculateItemHeight(changedItem);					// make sure that the item height is recalculated

+	// no redraw necessary if redraw width is 0 or item is not visible

+	if (repaintWidth == 0 || (yPosition = getVisibleRedrawY(changedItem)) == -1) {

+		return;

+	}														// if changedItem is the first item with image.

+	itemHeight = getItemHeight();

+	if ((oldItemHeight == itemHeight) &&				// only redraw changed item if the item height and 

+	    (oldImageExtent == getImageExtent())) {			// image size has not changed. The latter will only change once,

+														// from null to a value-so it's safe to test using !=

+		// redrawing outside the client area redraws the widget border on Motif.

+		// adjust the redraw width if necessary. Workaround for 1G4TQRW

+		repaintWidth = Math.min(repaintWidth, getClientArea().width - repaintStartX);

+		if (repaintWidth > 0) {

+			redraw(repaintStartX, yPosition, repaintWidth, itemHeight, true);

+		}

+	}

+	else {

+		redraw();										// redraw all items if the item height has changed

+	}

+}

+/**

+ * A key was pressed. Call the appropriate handler method.

+ * @param event - the key event

+ */

+void keyDown(Event event) {

+	boolean isCtrlSelection = isCtrlSelection();

+	

+	if (event.stateMask != SWT.CTRL) {

+		isCtrlSelection = false;

+	}

+	switch (event.keyCode) {

+		case SWT.ARROW_UP:

+			doArrowUp(event.stateMask);

+			break;

+		case SWT.ARROW_DOWN:

+			doArrowDown(event.stateMask);

+			break;

+		case SWT.ARROW_LEFT:

+			doArrowLeft(event.stateMask);

+			break;

+		case SWT.ARROW_RIGHT:

+			doArrowRight(event.stateMask);

+			break;			

+		case SWT.PAGE_UP:

+			doPageUp(event.stateMask);

+			break;		

+		case SWT.PAGE_DOWN:

+			doPageDown(event.stateMask);

+			break;

+		case SWT.HOME:

+			doHome(event.stateMask);

+			break;

+		case SWT.END:

+			doEnd(event.stateMask);

+			break;

+		default:										// no selection occurred, keep previous 

+			isCtrlSelection = isCtrlSelection();		// selection type information

+	}

+	if (event.character == ' ') {

+		doSpace(event.stateMask);

+		isCtrlSelection = (event.stateMask == SWT.CTRL);

+	}

+	setCtrlSelection(isCtrlSelection);

+}

+/**

+ * Sets the drop insert item.

+ * The drop insert item has a visual hint to show where a dragged item 

+ * will be inserted when dropped on the tree.

+ * <p>

+ * @param item the insert item 

+ * @param after true places the insert mark below 'item'. false places 

+ *	the insert mark above 'item'.

+ */

+void motif_setInsertMark(SelectableItem item, boolean after) {

+	SelectableItem currentItem = getInsertItem();

+	int redrawY;

+	

+	setInsertItem(item);

+	setInsertAfter(after);

+	if (currentItem != null) {

+		redrawY = getVisibleRedrawY(currentItem);

+		if (redrawY != -1) {

+			currentItem.redrawInsertMark(redrawY);

+		}		

+	}

+	if (item != null) {

+		redrawY = getVisibleRedrawY(item);

+		if (redrawY != -1) {

+			item.redrawInsertMark(redrawY);

+		}		

+	}

+}

+

+

+/**

+ * Overridden to implement setRedraw(). Redraw is ignored if setRedraw was 

+ * set to false.

+ */

+public void redraw () {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (drawCount == 0) {

+		super.redraw();

+	}

+}

+/**

+ * Overridden to implement setRedraw(). Redraw is ignored if setRedraw was 

+ * set to false.

+ */

+public void redraw (int x, int y, int width, int height, boolean all) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (drawCount == 0) {

+		super.redraw(x, y, width, height, all);

+	}

+}

+

+/**

+ * Redraw the selection of 'item'

+ * @param item - SelectableItem that should have the selection redrawn.

+ */

+void redrawSelection(SelectableItem item) {

+	int redrawPosition = getVisibleRedrawY(item);

+

+	if (redrawPosition != -1) {

+		item.redrawSelection(redrawPosition);

+	}	

+}

+/**

+ * 'item' has been removed from the receiver. 

+ * Update the display and the scroll bars.

+ */

+void removedItem(SelectableItem item) {

+	claimBottomFreeSpace();

+	calculateVerticalScrollbar();

+	if (getItemCount() == 0) {

+		reset();

+	}

+}

+/**

+ * 'item' is about to be removed from the tree.

+ * Move the selection/input focus if 'item' is selected or has the 

+ * input focus, 

+ * @param item - item that is about to be removed from the tree.

+ */

+void removingItem(SelectableItem item) {

+	SelectableItem nextFocusItem = null;

+	int itemIndex = getVisibleIndex(item);

+	int itemCount = getVisibleItemCount();

+	

+	// deselect item and remove from selection

+	if (item.isSelected() == true) {

+		getSelectionVector().removeElement(item);

+	}

+	if (item == getLastFocus() && itemCount > 1) {

+		// select previous item if removed item is bottom item

+		// otherwise select next item. Fixes 1GA6L85

+		if (itemIndex == itemCount - 1) {

+			nextFocusItem = getVisibleItem(itemIndex - 1);

+		}

+		else {

+			nextFocusItem = getVisibleItem(itemIndex + 1);

+		}

+		setLastFocus(nextFocusItem, true);

+	}

+	// ignore items below widget client area

+	if (itemIndex != -1 && itemIndex <= getBottomIndex()) {			

+		scrollVerticalRemovedItem(itemIndex);

+	}

+}

+/**

+ * Reset state that is dependent on or calculated from the state 

+ * of the receiver.

+ */

+void reset() {

+	setSelectionVector(new Vector());

+	setTopIndexNoScroll(0, true);

+	lastSelectedItem = null;

+	lastFocusItem = null;

+	resetItemData();

+}

+/**

+ * Reset state that is dependent on or calculated from the items

+ * of the receiver.

+ */

+void resetItemData() {

+	setHorizontalOffset(0);

+	setItemHeight(0);

+	itemImageExtent = null;

+	textHeight = -1;	

+	claimRightFreeSpace();

+}

+/**

+ * The receiver has been resized. Update the scroll bars and

+ * make sure that new space is being occupied by items.

+ */

+void resize(Event event) {

+	int horizontalPageSize = getHorizontalBar().getPageIncrement();

+

+	resizeHorizontalScrollbar();

+	resizeVerticalScrollbar();

+	if (getClientArea().width > horizontalPageSize) {		// window resized wider? - Do this check here 

+		claimRightFreeSpace();							// because claimRightFreeSpace is called elsewhere.

+	}

+	claimBottomFreeSpace();

+}

+/**

+ * Display the horizontal scroll bar if items are drawn off 

+ * screen. Update the page size.

+ */

+void resizeHorizontalScrollbar() {

+	ScrollBar horizontalBar = getHorizontalBar();

+	int clientAreaWidth = getClientArea().width;

+

+	if (clientAreaWidth < getContentWidth()) {

+		if (horizontalBar.getVisible() == false) {

+			horizontalBar.setVisible(true);

+			horizontalBar.setSelection(0);

+		}

+	}

+	else 

+	if (horizontalBar.getVisible() == true) {

+		horizontalBar.setVisible(false);

+	}

+	horizontalBar.setThumb(clientAreaWidth);

+	horizontalBar.setPageIncrement(clientAreaWidth);

+}

+/**

+ * Display the vertical scroll bar if items are drawn off screen.

+ * Update the page size.

+ */

+void resizeVerticalScrollbar() {

+	int clientAreaItemCount = getItemCountWhole();

+	ScrollBar verticalBar = getVerticalBar();

+

+	if (clientAreaItemCount == 0) {

+		return;

+	}

+	if (clientAreaItemCount < getVisibleItemCount()) {

+		if (verticalBar.getVisible() == false) {

+			verticalBar.setVisible(true);

+		}

+		// Only set the page size to something smaller than the scroll 

+		// range maximum. Otherwise the scroll selection will be reset.

+		verticalBar.setPageIncrement(clientAreaItemCount);

+		verticalBar.setThumb(clientAreaItemCount);

+	}

+	else

+	if (verticalBar.getVisible() == true) {

+		verticalBar.setVisible(false);

+	}

+}

+/**

+ * Scroll the rectangle specified by x, y, width, height to the destination 

+ * position. Do nothing if redraw is set to false using setRedraw().

+ *

+ * @param destX - destination x position of the scrolled rectangle

+ * @param destY - destination y position of the scrolled rectangle

+ * @param x - x location of the upper left corner of the scroll rectangle

+ * @param y - y location of the upper left corner of the scroll rectangle

+ * @param width - width of the scroll rectangle

+ * @param height - height of the scroll rectangle

+ * @param all - not used. Used to be true=scroll children intersecting the 

+ *	scroll rectangle.

+ */

+void scroll(int destX, int destY, int x, int y, int width, int height, boolean all) {

+	if (drawCount == 0) {

+		update();

+		GC gc = new GC(this);

+		gc.copyArea(x, y, width, height, destX, destY);

+		gc.dispose();

+	}

+}

+/**

+ * Scroll horizontally by 'numPixel' pixel.

+ * @param numPixel - the number of pixel to scroll

+ * 	numPixel > 0 = scroll to left. numPixel < 0 = scroll to right

+ */

+abstract void scrollHorizontal(int numPixel);

+/**

+ * The position of the horizontal scroll bar has been modified 

+ * by the user. 

+ * Adjust the horizontal offset to trigger a horizontal scroll.

+ * @param event-the scroll event

+ */

+void scrollHorizontal(Event event) {

+	setHorizontalOffset(getHorizontalBar().getSelection() * -1);

+}

+/**

+ * Scroll 'item' into the receiver's client area if necessary.

+ * @param item - the item that should be scrolled.

+ */

+void scrollShowItem(SelectableItem item) {

+	int itemIndexFromTop = getIndex(item) - getTopIndex();

+	int clientAreaWholeItemCount = getItemCountWhole();

+	int scrollAmount = 0;

+

+	if (itemIndexFromTop >= clientAreaWholeItemCount) {		// show item below visible items?

+		scrollAmount = itemIndexFromTop;

+		if (clientAreaWholeItemCount > 0) {					// will be 0 if showItem is called and receiver hasn't been displayed yet

+			scrollAmount -= clientAreaWholeItemCount - 1;

+		}

+	}

+	else

+	if (itemIndexFromTop < 0) {								// show item above visible items?

+		scrollAmount = itemIndexFromTop;

+	}

+	setTopIndex(getTopIndex() + scrollAmount, true);

+}

+/**

+ * Scroll vertically by 'scrollIndexCount' items.

+ * @param scrollIndexCount - the number of items to scroll.

+ *	scrollIndexCount > 0 = scroll up. scrollIndexCount < 0 = scroll down

+ */

+abstract void scrollVertical(int scrollIndexCount);

+/**

+ * The position of the horizontal scroll bar has been modified 

+ * by the user.

+ * Adjust the index of the top item to trigger a vertical scroll.

+ * @param event-the scroll event

+ */

+void scrollVertical(Event event) {

+	setTopIndex(getVerticalBar().getSelection(), false);

+}

+/**

+ * Scroll items down to make space for a new item added to 

+ * the receiver at position 'index'.

+ * @param index - position at which space for one new item

+ *	should be made. This index is relative to the first item 

+ *	of the receiver.

+ */

+void scrollVerticalAddingItem(int index) {

+	Rectangle clientArea = getClientArea();

+	int itemHeight = getItemHeight();

+	int sourceY = Math.max(0, (index - getTopIndex()) * itemHeight);	// need to scroll in visible area

+

+	scroll(

+		0, sourceY + itemHeight, 						// destination x, y

+		0, sourceY, 									// source x, y

+		clientArea.width, clientArea.height, true);

+}

+/**

+ * Scroll the items below the item at position 'index' up 

+ * so that they cover the removed item.

+ * @param index - index of the removed item

+ */

+void scrollVerticalRemovedItem(int index) {

+	Rectangle clientArea = getClientArea();

+	int itemHeight = getItemHeight();

+	int destinationY = Math.max(0, (index - getTopIndex()) * itemHeight);

+

+	scroll(

+		0, destinationY, 						// destination x, y

+		0, destinationY + itemHeight, 			// source x, y

+		clientArea.width, clientArea.height, true);

+}

+/**

+ * Select 'item' if it is not selected.

+ * @param item - item that should be selected

+ */

+void select(SelectableItem item) {

+	Vector selectedItems = getSelectionVector();

+	

+	if (item != null && item.isSelected() == false && isRemovingAll() == false) {

+		item.setSelected(true);

+		redrawSelection(item);

+		selectedItems.addElement(item);

+	}

+}

+/**

+ * Select 'item' if it is not selected. Send a Selection event 

+ * if the selection was changed.

+ * @param item - item that should be selected

+ * @param asyncNotify 

+ *  true=send the selection event asynchronously

+ *  false=send the selection event immediately

+ */

+void selectNotify(final SelectableItem item, boolean asyncNotify) {

+	if (isRemovingAll() == false) {

+		if (item.isSelected() == false) {

+			select(item);

+			setLastSelection(item, true);

+			update();												// looks better when event notification takes long to return

+		}

+		if (asyncNotify == false) {

+			Event event = new Event();

+			event.item = item;

+			notifyListeners(SWT.Selection, event);

+		}

+		else {

+			getDisplay().asyncExec(new Runnable() {

+				public void run() {

+					// Only send a selection event when the item has not been disposed.

+					// Fixes 1GE6XQA

+					if (item.isDisposed() == false) {

+						Event event = new Event();

+						event.item = item;

+						notifyListeners(SWT.Selection, event);

+					}

+				}

+			});

+		}

+	}

+}

+/**

+ * Select 'item' if it is not selected. Send a Selection event 

+ * if the selection was changed.

+ * @param item - item that should be selected

+ */

+void selectNotify(SelectableItem item) {

+	selectNotify(item, false);

+}

+/**

+ * Select all items of the receiver starting at 'fromIndex' 

+ * and including 'toIndex'.

+ */

+void selectRange(int fromIndex, int toIndex) {

+	if (fromIndex > toIndex) {

+		for (int i = fromIndex; i > toIndex; i--) {

+			select(getVisibleItem(i));

+		}

+	}

+	else {

+		for (int i = fromIndex; i < toIndex; i++) {

+			select(getVisibleItem(i));			

+		}

+	}

+	selectNotify(getVisibleItem(toIndex));				// select last item, notifying listeners

+}

+/**

+ * Set the width of the receiver's contents to 'newWidth'.

+ * Content width is used to calculate the horizontal scrollbar.

+ */

+void setContentWidth(int newWidth) {

+	ScrollBar horizontalBar;

+	boolean scrollBarVisible;

+	

+	if (contentWidth != newWidth) {

+		horizontalBar = getHorizontalBar();

+		scrollBarVisible = horizontalBar.getVisible();

+		contentWidth = newWidth;

+		calculateHorizontalScrollbar();

+		if (scrollBarVisible != horizontalBar.getVisible()) {

+			resizeVerticalScrollbar();									// the vertical scroll bar needs to be resized if the horizontal 

+		}																// scroll bar was hidden or made visible during recalculation

+	}

+}

+/**

+ * Set whether the currently selected items were selected using the 

+ * ctrl key.

+ * @param isCtrlSelection - 

+ *	true = currently selected items were selected using the ctrl key.

+ *	false = currently selected items were not selected using the 

+ *	ctrl key.

+ */

+void setCtrlSelection(boolean isCtrlSelection) {

+	this.isCtrlSelection = isCtrlSelection;

+}

+/**

+ * The font is changing. Reset the text height to force a 

+ * recalculation during itemChanged().

+ */

+public void setFont(Font font) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	super.setFont(font);

+	textHeight = -1;

+}

+/**

+ * Set the horizontal drawing offset to 'offset'.

+ * Scroll the receiver's contents according to the offset change.

+ * @param offset - value < 0 = widget contents is drawn left of the client area.

+ */

+void setHorizontalOffset(int offset) {

+	int offsetChange = offset - horizontalOffset;

+	

+	if (offsetChange != 0) {

+		scrollHorizontal(offsetChange);

+		horizontalOffset = offset;

+	}

+}

+

+/**

+ * Set whether the drop insert position is before or after the 

+ * item set using motif_setInsertMark.

+ * @param after true=insert position is after the insert item

+ *	false=insert position is before the insert item

+ */

+void setInsertAfter(boolean after) {

+	isInsertAfter = after;

+}

+

+/**

+ * Set the item that draws the marker indicating the insert location 

+ * in a drag and drop operation.

+ * @param item the item that draws the insert marker

+ */

+void setInsertItem(SelectableItem item) {

+	insertItem = item;

+}

+/** 

+ * Set the height of the receiver's items to 'height'.

+ */

+void setItemHeight(int height) {

+	itemHeight = height;

+}

+/**

+ * Set the item that most recently received the input focus

+ * to 'focusItem'. Redraw both, the item that lost focus 

+ * and the one that received focus.

+ * @param focusItem - the item that most recently received 

+ *	the input focus

+ * @param showItem true=new focus item, if any, should be scrolled 

+ *	into view. false=don't scroll

+ */

+void setLastFocus(SelectableItem focusItem, boolean showItem) {

+	SelectableItem oldFocusItem = lastFocusItem;

+	

+	if (focusItem != lastFocusItem) {

+		lastFocusItem = focusItem;	

+		if (oldFocusItem != null) {

+			redrawSelection(oldFocusItem);

+		}

+		if (lastFocusItem != null && isFocusControl() == true) {

+			redrawSelection(lastFocusItem);

+		}

+	}

+	if (focusItem != null && showItem == true) {

+		showSelectableItem(focusItem);

+	}

+}

+/**

+ * Set the item that was selected most recently to 'selectedItem'.

+ * Set the input focus to that item.

+ * @param selectedItem - the item that was selected most recently

+ * @param showItem true=new focus item, if any, should be scrolled 

+ *	into view. false=don't scroll

+ */ 

+void setLastSelection(SelectableItem selectedItem, boolean showItem) {

+	if (selectedItem == null) {							// always store the item selected last

+		return;

+	}

+	setLastFocus(selectedItem, showItem);

+	lastSelectedItem = selectedItem;

+}

+/**

+ * Sets the redraw flag.

+ * @param redraw - 

+ *	true = redraw and scroll operations are performed normally

+ * 	false = redraw and scroll operations are ignored

+ */

+public void setRedraw (boolean redraw) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	if (redraw) {

+		if (--drawCount == 0) redraw();

+	} else {

+		drawCount++;

+	}

+}

+/**

+ * Set whether all items in the widget are disposed.

+ * Used to optimize item disposal. Prevents unnecessary screen 

+ * updates.

+ * @param removingAll 

+ *	true=all items are removed. 

+ *	false=normal state, no items or not all items are removed.

+ */

+void setRemovingAll(boolean removingAll) {

+	isRemovingAll = removingAll;

+}

+/**

+ * Select the items stored in 'selectionItems'. 

+ * A SWT.Selection event is not going to be sent.

+ * @param selectionItems - Array containing the items that should 

+ *	be selected

+ */

+void setSelectableSelection(SelectableItem selectionItems[]) {

+	SelectableItem item = null;

+	int selectionCount = selectionItems.length;

+	Vector keepSelected;

+	

+	if (isMultiSelect() == false && selectionCount > 1) {

+		selectionCount = 1;

+	}

+	keepSelected = new Vector(selectionItems.length);

+	for (int i = 0; i < selectionCount; i++) {

+		if (selectionItems[i] != null) {

+			keepSelected.addElement(selectionItems[i]);

+		}

+	}

+	deselectAllExcept(keepSelected);

+	// select in the same order as all the other selection and deslection methods.

+	// Otherwise setLastSelection repeatedly changes the lastSelectedItem for repeated 

+	// selections of the items, causing flash.	

+	for (int i = selectionCount - 1; i >= 0; i--) {

+		item = selectionItems[i];

+		if (item != null) {

+			select(item);

+		}

+	}

+	if (item != null) {

+		setLastSelection(item, true);

+	}	

+}

+/**

+ * Set the vector used to store the selected items of the receiver 

+ * to 'newVector'.

+ * @param newVector - the vector used to store the selected items 

+ *	of the receiver

+ */

+void setSelectionVector(Vector newVector) {

+	selectedItems = newVector;

+}

+/**

+ * Scroll the item at 'index' to the top.

+ * @param index - 0-based index of the first visible item in the 

+ *	receiver's client area.

+ * @param adjustScrollbar - true=set the position of the vertical 

+ *	scroll bar to the new top index. 

+ *	false=don't adjust the vertical scroll bar

+ */

+void setTopIndex(int index, boolean adjustScrollbar) {

+	int indexDiff = index-topIndex;

+

+	if (indexDiff != 0) {

+		scrollVertical(indexDiff);

+		setTopIndexNoScroll(index, adjustScrollbar);

+	}

+}

+/**

+ * Set the index of the first visible item in the receiver's client 

+ * area to 'index'.

+ * @param index - 0-based index of the first visible item in the 

+ *	receiver's client area.

+ * @param adjustScrollbar - true=set the position of the vertical 

+ *	scroll bar to the new top index. 

+ *	false=don't adjust the vertical scroll bar

+ */

+void setTopIndexNoScroll(int index, boolean adjustScrollbar) {

+	topIndex = index;

+	if (adjustScrollbar == true) {

+		getVerticalBar().setSelection(index);

+	}

+}

+/**

+ * The shift key was pressed when the mouse click on an item 

+ * occurred. Do a shift selection. If an already selected item was 

+ * clicked the selection is expanded/reduced to that item

+ * @param hitItem - specifies the clicked item

+ * @param hitItemIndex - specifies the index of the clicked item 

+ *	relative to the first item.

+ */

+void shiftSelect(SelectableItem hitItem, int hitItemIndex) {

+	int fromIndex = -1;

+	int toIndex = -1;

+	int lastSelectionIndex = -1;

+	int selectionRange[];

+	SelectableItem lastSelection = getLastSelection();

+

+	if (lastSelection != null) {

+		lastSelectionIndex = getVisibleIndex(lastSelection);

+	}

+	if (isCtrlSelection() == true) {						// was last selection ctrl selection? 

+		deselectAllExcept(lastSelection);					

+		fromIndex = lastSelectionIndex;						// select from last selection

+		toIndex = hitItemIndex;

+	}

+	else

+	if (getSelectionVector().contains(hitItem) == true) {	// clicked an item already selected?

+		deselectRange(hitItemIndex, lastSelectionIndex);	// reduce selection

+	}

+	else {													// clicked outside existing selection range

+		selectionRange = calculateShiftSelectionRange(hitItemIndex);

+		fromIndex = selectionRange[0];

+		toIndex = selectionRange[1];

+	}

+	if (hitItemIndex == lastSelectionIndex) {				// was click on last selected item?

+		return;

+	}

+	if (fromIndex == -1 || toIndex == -1) { 				// are there previously selected items?

+		toggleSelectionNotify(hitItem);						// do a single select.

+	}

+	else {

+		if (((lastSelectionIndex < fromIndex) && (hitItemIndex > fromIndex)) ||	// does selection reverse direction?

+			((lastSelectionIndex > fromIndex) && (hitItemIndex < fromIndex))) {

+			deselectAllExcept((SelectableItem) null);											// remove old selection 

+		}

+		selectRange(fromIndex, toIndex);

+	}					

+}

+/**

+ * Make 'item' visible by scrolling it into the receiver's client

+ * area if necessary.

+ * @param item - the item that should be made visible to the user.

+ */

+void showSelectableItem(SelectableItem item) {

+	if (item.getSelectableParent() != this) {

+		return;

+	}

+	scrollShowItem(item);

+	scrollShowItem(item);						// second call makes sure that the item is still visible

+												// even if the first scroll caused the horizontal scroll

+												// to be displayed and the item to be hidden again.

+}

+/**

+ * Show the selection. If there is no selection or the 

+ * selection is already visible, this method does nothing. 

+ * If the selection is not visible, the top index of the 

+ * widget is changed such that the selection becomes visible.

+ */

+public void showSelection() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector selection = getSelectionVector();

+	SelectableItem selectionItem;

+

+	if (selection.size() > 0) {

+		selectionItem = (SelectableItem) selection.firstElement();

+		showSelectableItem(selectionItem);

+	}

+}

+/**

+ * Sorts the specified range in the array.

+ *

+ * @param array the SelectableItem array to be sorted

+ * @param start the start index to sort

+ * @param end the last + 1 index to sort

+ */

+void sort(SelectableItem[] array, int start, int end) {

+	int middle = (start + end) / 2;

+	if (start + 1 < middle) sort(array, start, middle);

+	if (middle + 1 < end) sort(array, middle, end);

+	if (start + 1 >= end) return;	// this case can only happen when this method is called by the user

+	if (getVisibleIndex(array[middle-1]) <= getVisibleIndex(array[middle])) return;

+	if (start + 2 == end) {

+		SelectableItem temp = array[start];

+		array[start] = array[middle];

+		array[middle] = temp;

+		return;

+	}

+	int i1 = start, i2 = middle, i3 = 0;

+	SelectableItem[] merge = new SelectableItem[end - start];

+	while (i1 < middle && i2 < end) {

+		merge[i3++] = getVisibleIndex(array[i1]) <= getVisibleIndex(array[i2]) ?

+			array[i1++] : array[i2++];

+	}

+	if (i1 < middle) System.arraycopy(array, i1, merge, i3, middle - i1);

+	System.arraycopy(merge, 0, array, start, i2 - start);

+}

+/**

+ * Toggle the selection of 'item'.

+ * @param item - item that should be selected/deselected

+ */

+void toggleSelectionNotify(SelectableItem item) {

+	if (item.isSelected() == true) {

+		deselectNotify(item);

+	}

+	else {

+		selectNotify(item);

+	}

+}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java
index d6d1386..6e66d3a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java
@@ -14,7 +14,7 @@
 public class Shell extends Decorations {

 	int shellHandle;

 	Display display;

-	int blockedList;

+	int modal, blockedList;

 	Control lastFocus;

 

 public Shell () {

@@ -60,7 +60,8 @@
 }

 

 public void addShellListener (ShellListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Close,typedListener);

@@ -74,16 +75,6 @@
 	OS.PtWidgetToFront (shellHandle);

 }

 

-static int checkStyle (int style) {

-	style = Decorations.checkStyle (style);

-	int mask = SWT.SYSTEM_MODAL | SWT.APPLICATION_MODAL | SWT.PRIMARY_MODAL;

-	int bits = style & ~mask;

-	if ((style & SWT.SYSTEM_MODAL) != 0) return bits | SWT.SYSTEM_MODAL;

-	if ((style & SWT.APPLICATION_MODAL) != 0) return bits | SWT.APPLICATION_MODAL;

-	if ((style & SWT.PRIMARY_MODAL) != 0) return bits | SWT.PRIMARY_MODAL;

-	return bits;

-}

-

 void closeWidget () {

 	Event event = new Event ();

 	event.time = (int) System.currentTimeMillis ();

@@ -92,12 +83,14 @@
 }

 

 public void close () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	closeWidget ();

 }

 

 public Rectangle computeTrim (int x, int y, int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_WINDOW_RENDER_FLAGS, 0, 0};

 	OS.PtGetResources (shellHandle, args.length / 3, args);

 	int flags = args [1];

@@ -126,7 +119,6 @@
 	if (handle != 0) {

 		int clazz = display.PtContainer;

 		int [] args = {

-			OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,

 			OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,

 		};

 		shellHandle = OS.PtCreateWidget (clazz, handle, args.length / 3, args);

@@ -154,7 +146,7 @@
 			if ((style & SWT.TITLE) != 0) decorations |= OS.Ph_WM_RENDER_TITLE;

 		}

 		int notifyFlags =

-			OS.Ph_WM_ICON | OS.Ph_WM_FOCUS |

+			OS.Ph_WM_ICON | OS.Ph_WM_FOCUS | 

 			OS.Ph_WM_MOVE | OS.Ph_WM_RESIZE;

 		int windowState = OS.Ph_WM_STATE_ISFOCUS;

 		if ((style & SWT.ON_TOP) != 0) windowState = OS.Ph_WM_STATE_ISFRONT;

@@ -168,7 +160,6 @@
 			OS.Pt_ARG_WINDOW_NOTIFY_FLAGS, notifyFlags, notifyFlags,

 			OS.Pt_ARG_WINDOW_STATE, windowState, ~0,

 			OS.Pt_ARG_FLAGS, OS.Pt_DELAY_REALIZE, OS.Pt_DELAY_REALIZE,

-			OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,

 			OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,

 		};

 		OS.PtSetParentWidget (parentHandle);

@@ -176,11 +167,15 @@
 		OS.free (titlePtr);

 		if (shellHandle == 0) error (SWT.ERROR_NO_HANDLES);

 	}

+	if ((style & SWT.NO_BACKGROUND) != 0) {

+		int [] args = new int [] {OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0};

+		OS.PtSetResources(shellHandle, args.length / 3, args);

+	}

 	createScrolledHandle (shellHandle);

 	if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.RESIZE)) == 0) {

 		int [] args = {

 			OS.Pt_ARG_FLAGS, OS.Pt_HIGHLIGHTED, OS.Pt_HIGHLIGHTED,

-			OS.Pt_ARG_BASIC_FLAGS, OS.Pt_ALL_OUTLINES, ~0,

+			OS.Pt_ARG_BASIC_FLAGS, OS.Pt_ALL_OUTLINES, OS.Pt_ALL_OUTLINES,

 		};

 		OS.PtSetResources (scrolledHandle, args.length / 3, args);

 	}

@@ -201,46 +196,51 @@
 }

 

 public int getImeInputMode () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return 0;

 }

 

 public boolean isEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return getEnabled ();

 }

 

 public Point getLocation () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	//NOT DONE - shell location is 0,0 when queried before event loop

 	return super.getLocation ();

 }

 

 public boolean getMaximized () {

-	checkWidget();

-	int state = OS.PtWindowGetState (shellHandle);

-	if (state != -1) return (state & (OS.Ph_WM_STATE_ISMAX | OS.Ph_WM_STATE_ISMAXING)) != 0;

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	//ONLY WORKS WHEN SET in setMaximized

 	int [] args = {OS.Pt_ARG_WINDOW_STATE, 0, OS.Ph_WM_STATE_ISMAX};

 	OS.PtGetResources (shellHandle, args.length / 3, args);

 	return (args [1] & OS.Ph_WM_STATE_ISMAX) != 0;

 }

 

 public boolean getMinimized () {

-	checkWidget();

-	int state = OS.PtWindowGetState (shellHandle);

-	if (state != -1) return (state & OS.Ph_WM_STATE_ISICONIFIED) != 0;

-	int [] args = {OS.Pt_ARG_WINDOW_STATE, 0, OS.Ph_WM_STATE_ISICONIFIED};

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	//ONLY WORKS WHEN SET in setMinimized

+	int [] args = {OS.Pt_ARG_WINDOW_STATE, 0, OS.Ph_WM_STATE_ISHIDDEN};

 	OS.PtGetResources (shellHandle, args.length / 3, args);

-	return (args [1] & OS.Ph_WM_STATE_ISICONIFIED) != 0;

+	return (args [1] & OS.Ph_WM_STATE_ISHIDDEN) != 0;

 }

 

 public Shell getShell () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return this;

 }

 

 public Shell [] getShells () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int count = 0;

 	Shell [] shells = display.getShells ();

 	for (int i=0; i<shells.length; i++) {

@@ -265,7 +265,8 @@
 }

 

 public Point getSize () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {

 		OS.Pt_ARG_WINDOW_RENDER_FLAGS, 0, 0,

 		OS.Pt_ARG_WIDTH, 0, 0,

@@ -289,7 +290,8 @@
 }

 

 public void open () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	bringToTop ();

 	setVisible (true);

 }

@@ -338,7 +340,7 @@
 			break;

 		case OS.Ph_WM_MOVE:

 			sendEvent (SWT.Move);

-			break;

+			break;	

 	}

 	return OS.Pt_CONTINUE;

 }

@@ -400,7 +402,8 @@
 }

 

 public void removeShellListener (ShellListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Close, listener);

@@ -411,7 +414,8 @@
 }

 

 void setBounds (int x, int y, int width, int height, boolean move, boolean resize) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (OS.PtWidgetClass (shellHandle) != OS.PtWindow ()) {

 		super.setBounds (x, y, width, height, move, resize);

 		if (resize) resizeBounds (width, height);

@@ -465,25 +469,31 @@
 }

 

 public void setImeInputMode (int mode) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 }

 

 public void setMaximized (boolean maximized) {

-	checkWidget();

-	int bits = 0;

-	if (maximized) bits = OS.Ph_WM_STATE_ISMAX;

-	int [] args = {OS.Pt_ARG_WINDOW_STATE, bits, OS.Ph_WM_STATE_ISMAX};

-	OS.PtSetResources (shellHandle, args.length / 3, args);

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (OS.PtWidgetIsRealized (shellHandle)) {

+		// RESTORE DOESN'T WORK

 		PhWindowEvent_t event = new PhWindowEvent_t ();

-		event.rid = OS.PtWidgetRid (shellHandle);

 		event.event_f = maximized ? OS.Ph_WM_MAX : OS.Ph_WM_RESTORE;

+		event.event_state = (short) (maximized ? OS.Ph_WM_EVSTATE_HIDE : OS.Ph_WM_EVSTATE_UNHIDE);

+		event.rid = OS.PtWidgetRid (shellHandle);

 		OS.PtForwardWindowEvent (event);

+	} else {

+		int bits = 0;

+		if (maximized) bits = OS.Ph_WM_STATE_ISMAX;

+		int [] args = {OS.Pt_ARG_WINDOW_STATE, bits, OS.Ph_WM_STATE_ISMAX};

+		OS.PtSetResources (shellHandle, args.length / 3, args);

 	}

 }

 

 public void setMenuBar (Menu menu) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (menuBar == menu) return;

 	if (menu != null) {

 		if ((menu.style & SWT.BAR) == 0) error (SWT.ERROR_MENU_NOT_BAR);

@@ -514,22 +524,39 @@
 }

 

 public void setMinimized (boolean minimized) {

-	checkWidget();

-	int bits = 0;

-	if (minimized) bits = OS.Ph_WM_STATE_ISICONIFIED;

-	int [] args = {OS.Pt_ARG_WINDOW_STATE, bits, OS.Ph_WM_STATE_ISICONIFIED};

-	OS.PtSetResources (shellHandle, args.length / 3, args);

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (OS.PtWidgetIsRealized (shellHandle)) {

+		// RESTORE DOESN'T WORK

 		PhWindowEvent_t event = new PhWindowEvent_t ();

-		event.rid = OS.PtWidgetRid (shellHandle);

-		event.event_f = OS.Ph_WM_HIDE;

+		event.event_f = minimized ? OS.Ph_WM_HIDE : OS.Ph_WM_RESTORE;

 		event.event_state = (short) (minimized ? OS.Ph_WM_EVSTATE_HIDE : OS.Ph_WM_EVSTATE_UNHIDE);

+		event.rid = OS.PtWidgetRid (shellHandle);

 		OS.PtForwardWindowEvent (event);

+	} else {

+		int bits = 0;

+		if (minimized) bits = OS.Ph_WM_STATE_ISHIDDEN;

+		int [] args = {OS.Pt_ARG_WINDOW_STATE, bits, OS.Ph_WM_STATE_ISHIDDEN};

+		OS.PtSetResources (shellHandle, args.length / 3, args);

+	}

+}

+

+public void setModal (int modal) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	switch (modal) {

+		case SWT.MODELESS:

+		case SWT.PRIMARY_MODAL:

+		case SWT.APPLICATION_MODAL:

+		case SWT.SYSTEM_MODAL:

+			this.modal = modal;

+			break;

 	}

 }

 

 public void setText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	text = string;

 	byte [] buffer = Converter.wcsToMbcs (null, string, true);

@@ -541,9 +568,9 @@
 }

 

 public void setVisible (boolean visible) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (visible == OS.PtWidgetIsRealized (shellHandle)) return;

-

 	/*

 	* Feature in Photon.  It is not possible to show a PtWindow

 	* whose parent is not realized.  The fix is to temporarily

@@ -554,30 +581,22 @@
 		Shell shell = parent.getShell ();

 		int parentHandle = shell.shellHandle;

 		if (!OS.PtWidgetIsRealized (parentHandle)) {

-			OS.PtReParentWidget (shellHandle, visible ? OS.Pt_NO_PARENT : parentHandle);

+			OS.PtReParentWidget (shellHandle, visible ? 0 : parentHandle);

 		}

 	}

-	

-	if (visible) {

-		int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;

-		switch (style & mask) {

-			case SWT.PRIMARY_MODAL:

-				if (parent != null) {

-					int parentHandle = parent.getShell ().shellHandle;

-					blockedList = OS.PtBlockWindow (parentHandle, (short) 0, 0);

-				}

-				break;

-			case SWT.APPLICATION_MODAL:

-			case SWT.SYSTEM_MODAL:

+	switch (modal) {

+		case SWT.PRIMARY_MODAL:

+			//NOT DONE: should not disable all windows

+		case SWT.APPLICATION_MODAL:

+		case SWT.SYSTEM_MODAL:

+			if (visible) {

 				blockedList = OS.PtBlockAllWindows (shellHandle, (short) 0, 0);

-				break;

-		}

-	} else {

-		if (blockedList != 0) OS.PtUnblockWindows (blockedList);

-		blockedList = 0;

+			} else {

+				if (blockedList != 0) OS.PtUnblockWindows (blockedList);

+				blockedList = 0;

+			}

 	}

 	super.setVisible (visible);

-

 	/*

 	* Feature in Photon.  When a shell is shown, it may have child

 	* shells that have been temporarily reparented to NULL because

@@ -593,7 +612,6 @@
 			}

 		}

 	}

-

 	OS.PtSyncWidget (shellHandle);

 	OS.PtFlush ();

 }

@@ -602,4 +620,4 @@
 	return shellHandle;

 }

 

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java
index 39c28bc..b371b20 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java
@@ -21,7 +21,8 @@
 }

 

 public void addSelectionListener (SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener(listener);

 	addListener (SWT.Selection,typedListener);

@@ -29,7 +30,6 @@
 }

 

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

 	//NOT DONE - hard coding value to be the same as list's scrollbars

 	int width = 17, height = 100;

 	if ((style & SWT.HORIZONTAL) != 0) {

@@ -64,49 +64,56 @@
 }

 

 public int getIncrement () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_INCREMENT, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public int getMinimum () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public int getMaximum () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public int getPageIncrement () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public int getSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_SCROLL_POSITION, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public Point getSize () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return new Point (args [1], args [4]);

 }

 

 public int getThumb () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_SLIDER_SIZE, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

@@ -156,7 +163,8 @@
 }

 

 public void removeSelectionListener (SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Selection, listener);

@@ -164,43 +172,50 @@
 }

 

 public void setIncrement (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_INCREMENT, value, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void setMaximum (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_MAXIMUM, value - 1, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void setMinimum (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_MINIMUM, value, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void setPageIncrement (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_PAGE_INCREMENT, value, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void setSelection (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_SCROLL_POSITION, value, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void setThumb (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_SLIDER_SIZE, value, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (selection < 0) return;

 	if (minimum < 0) return;

 	if (maximum < 0) return;

@@ -219,4 +234,4 @@
 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java
index d013438..dd6ef94 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java
@@ -31,7 +31,8 @@
 }

 

 public void addSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener(listener);

 	addListener(SWT.Selection,typedListener);

@@ -43,7 +44,8 @@
 }

 

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	PhDim_t dim = new PhDim_t();

 	if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);

 	OS.PtWidgetPreferredSize(handle, dim);

@@ -66,7 +68,8 @@
 }

 

 public Rectangle computeTrim (int x, int y, int width, int height) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	PhDim_t dim = new PhDim_t();

 	if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);

 	OS.PtWidgetPreferredSize(handle, dim);

@@ -182,7 +185,8 @@
 }

 

 public TabItem getItem (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	if (!(0 <= index && index < args [2])) error (SWT.ERROR_INVALID_RANGE);

@@ -190,7 +194,8 @@
 }

 

 public TabItem [] getItems () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	TabItem [] result = new TabItem [args [2]];

@@ -199,21 +204,24 @@
 }

 

 public int getItemCount () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [2];

 }

 

 public TabItem [] getSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int index = getSelectionIndex ();

 	if (index == -1) return new TabItem [0];

 	return new TabItem [] {items [index]};

 }

 

 public int getSelectionIndex () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_PG_CURRENT_INDEX, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1] == OS.Pt_PG_INVALID ? -1 : args [1];

@@ -226,7 +234,8 @@
 }

 

 public int indexOf (TabItem item) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);

 	int count = getItemCount ();

 	for (int i=0; i<count; i++) {

@@ -302,7 +311,8 @@
 }

 

 public void removeSelectionListener (SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Selection, listener);

@@ -310,7 +320,8 @@
 }

 

 public void setSelection (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_PG_CURRENT_INDEX, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	int oldIndex = args [1];

@@ -337,7 +348,8 @@
 }

 

 public void setSelection (TabItem [] items) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (items == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (items.length == 0) {

 		setSelection (-1);

@@ -349,4 +361,4 @@
 	}

 }

 

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabItem.java
index a2fa31a..9c733f9 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabItem.java
@@ -30,7 +30,8 @@
 }

 

 public Control getControl () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return control;

 }

 

@@ -41,12 +42,14 @@
 }

 

 public TabFolder getParent () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent;

 }

 

 public String getToolTipText () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return toolTipText;

 }

 

@@ -63,10 +66,10 @@
 }

 

 public void setControl (Control control) {

-	checkWidget();

-	if (control != null) {

-		if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);

-		if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	if (control != null && control.parent != parent) {

+		error (SWT.ERROR_INVALID_PARENT);

 	}

 	Control oldControl = this.control, newControl = control;

 	this.control = control;

@@ -80,12 +83,14 @@
 }

 

 public void setImage (Image image) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	//NOT SUPPORTED

 }

 

 public void setText (String text) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	super.setText (text);

 	int index = parent.indexOf (this);

 	int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};

@@ -119,7 +124,8 @@
 }

 

 public void setToolTipText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	toolTipText = string;

 }

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Table.java
new file mode 100755
index 0000000..5cd4dda
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Table.java
@@ -0,0 +1,2777 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+ 

+import org.eclipse.swt.events.*;

+import org.eclipse.swt.graphics.*;

+import org.eclipse.swt.*;

+import java.util.*;

+ 

+/** 
+ * Instances of this class implement a selectable user interface
+ * object that displays a list of images and strings and issue
+ * notificiation when selected.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TableItem</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SINGLE, MULTI, CHECK, FULL_SELECTION, HIDE_SELECTION</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, DefaultSelection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */

+public /*final*/ class Table extends SelectableItemWidget {

+	private static final int COLUMN_RESIZE_OFFSET = 7;	// offset from the start and end of each 

+														// column at which the resize cursor is displayed 

+														// if the mouse is in the column header

+	static final String DOT_STRING = "...";				// used to indicate truncated item labels

+

+	private Header tableHeader;

+	private Control focusProxy;							// used as a proxy to take focus in place of the table. 

+														// The latter can't get focus because it has a child 

+														// (the header widget). The header widget can't be used 

+														// as a focus widget because it may be hidden.

+	private Vector items;

+	private Vector columns;

+	private boolean drawGridLines = false;

+	private boolean hasColumnFocus = false;				// true if a column currently has focus

+	private boolean firstColumnImage = false;			// true if any item in the first column has an image

+	private int columnResizeX;							// last position of the cursor in a column resize operation

+	private Cursor columnResizeCursor;					// cursor displayed when a column resize is in progress. 

+														// Need to keep reference to the cursor in order to dispose it.

+	private boolean isColumnResizeCursor = false;		// set to true if the column resize cursor is active														

+	private TableColumn resizeColumn;					// column that is currently being resized

+	private TableColumn fillColumn;						// column used to fill up space that is not used 

+														// by user defined columns

+	private TableColumn defaultColumn;					// Default column that is created as soon as the table is created.

+														// Fix for 1FUSJY5

+	private int dotsWidth = -1;							// width of the static String dots (see above)

+/**

+ * Constructs a new instance of this class given its parent

+ * and a style value describing its behavior and appearance.

+ * <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

+ *

+ * @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 Table(Composite parent, int style) {

+	// use NO_MERGE_PAINTS to avoid flashing during column and widget resize redraw

+	super(parent, checkStyle(style| SWT.NO_MERGE_PAINTS));

+}

+/**

+ * Add 'column' to the receiver.

+ * @param column - new table column that should be added to 

+ *	the receiver

+ */

+void addColumn(TableColumn column) {

+	int index = column.getIndex();

+	

+	getColumnVector().insertElementAt(column, index);

+	// has the column been inserted (vs. appended)?

+	if (index < getColumnCount() - 1) {				

+		reindexColumns(index + 1);

+	}

+	// is there more than one user created column?

+	// There always is the data and visual of the default column

+	// so we don't need to create those for the first user column

+	if (getColumnCount() > 1) {

+		insertColumnData(column);

+	}

+	else {								// first user created column

+		setContentWidth(0);				// pretend it's ground zero for column resizings

+		redraw();						// redraw the table and header. The default column 

+		getHeader().redraw();			// won't be drawn anymore, because there now is a user created table.

+	}

+	insertColumnVisual(column);

+}

+/**

+ * Add 'item' to the receiver.

+ * @param item - new table item that should be added to 

+ *	the receiver

+ * @param index - position the new item should be inserted at

+ */

+void addItem(TableItem item, int index) {

+	Vector items = getItemVector();

+

+	if (index < 0 || index > getItemCount()) {

+		error(SWT.ERROR_INVALID_RANGE);

+	}	

+	addingItem(item, index);

+	item.setIndex(index);

+	if (index < items.size()) {

+		for (int i = index; i < items.size(); i++) {

+			TableItem anItem = (TableItem) items.elementAt(i);

+			anItem.setIndex(anItem.getIndex() + 1);

+		}

+		items.insertElementAt(item, index);

+	}

+	else {

+		items.addElement(item);

+	}

+	addedItem(item, index);

+}

+/**

+ * Adds the listener to the collection of listeners who will

+ * be notified when the receiver's selection changes, by sending

+ * it one of the messages defined in the <code>SelectionListener</code>

+ * interface.

+ * <p>

+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.

+ * If the reciever has <code>SWT.CHECK</code> style set and the check selection changes,

+ * the event object detail field contains the value <code>SWT.CHECK</code>.

+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.

+ * The item field of the event object is valid for default selection, but the detail field is not used.

+ * </p>

+ *

+ * @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 SelectionListener

+ * @see #removeSelectionListener

+ * @see SelectionEvent

+ */

+public void addSelectionListener (SelectionListener listener) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	TypedListener typedListener;

+

+	if (listener == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	typedListener = new TypedListener(listener);	

+	addListener(SWT.Selection, typedListener);

+	addListener(SWT.DefaultSelection, typedListener);

+}

+static int checkStyle (int style) {

+	return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);

+}

+protected void checkSubclass () {

+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);

+}

+/**

+ * The width of 'column' is about to change.

+ * Adjust the position of all columns behind it.

+ */

+void columnChange(TableColumn column, Rectangle newBounds) {

+	Rectangle columnBounds = column.getBounds();

+	Rectangle clientArea = getClientArea();

+	int oldXPosition = columnBounds.x + columnBounds.width; 

+	int newXPosition = newBounds.x + newBounds.width;

+	int widthChange = newBounds.width - columnBounds.width;

+	int headerHeight = getHeaderHeight();

+	int columnIndex = column.getIndex();

+

+	if (widthChange != 0) {

+		if (columnIndex != TableColumn.FILL) {

+			if (getLinesVisible() == true) {

+				oldXPosition -= getGridLineWidth();						// include vertical grid line when scrolling resized column.

+				newXPosition -= getGridLineWidth();

+			}

+			scroll(														// physically move all following columns

+				newXPosition, headerHeight, 							// destination x, y

+				oldXPosition, headerHeight, 							// source x, y

+				clientArea.width, clientArea.height, true);

+		}

+		column.internalSetBounds(newBounds);

+		if (columnIndex != TableColumn.FILL) {

+			resetTableItems(columnIndex);

+			moveColumns(columnIndex + 1, widthChange);					// logically move all following columns	(set their bounds)

+			setContentWidth(getContentWidth() + widthChange);			// set the width of the receiver's content

+			claimRightFreeSpace();

+			resizeRedraw(column, columnBounds.width, newBounds.width);

+		}

+	}

+	getHeader().widthChange(columnIndex, widthChange);

+}

+/**

+ * The mouse pointer was double clicked on the receiver.

+ * Handle the event according to the position of the mouse click

+ * and the modifier key that was pressed, if any.

+ * @param event - the mouse event

+ */

+void columnMouseDoubleClick(Event event) {

+	int itemHeight = getItemHeight();

+	int itemIndex;

+	TableItem hitItem;

+	TableColumn hitColumn = getColumnAtX(event.x);

+	Event columnDblClickEvent;

+	boolean isFullSelection = (getStyle() & SWT.FULL_SELECTION) != 0;
+

+	if (isFocusControl() == false) {

+		setFocus();									// focus proxy gets focus here because it's the first child of the receiver

+	}

+	if (hitColumn != null) {

+		itemIndex = (event.y - getHeaderHeight()) / itemHeight + getTopIndex();

+		hitItem = (TableItem) getVisibleItem(itemIndex);

+		if (hitItem != null && 

+			(hitColumn.getIndex() == TableColumn.FIRST || isFullSelection)) {
+			if (hitItem.isSelectionHit(event.x) == true) {

+				columnDblClickEvent = new Event();

+				columnDblClickEvent.item = hitItem;

+				notifyListeners(SWT.DefaultSelection, columnDblClickEvent);

+			}

+		}

+		else {

+			deselectAll();

+		}

+	}

+}

+/**

+ * The mouse pointer was pressed down on the receiver.

+ * Handle the event according to the position of the mouse click

+ * and the modifier key that was pressed, if any.

+ * @param event - the mouse event

+ */

+void columnMouseDown(Event event) {

+	int itemHeight = getItemHeight();

+	int itemIndex;

+	TableItem hitItem;

+	TableColumn hitColumn = getColumnAtX(event.x);

+

+	if (isFocusControl() == false) {

+		setFocus();									// focus proxy gets focus here because it's the first child of the receiver

+	}

+	if (hitColumn != null) {

+		itemIndex = (event.y - getHeaderHeight()) / itemHeight + getTopIndex();

+		hitItem = (TableItem) getVisibleItem(itemIndex);

+		if (hitItem != null) {

+			if (hitItem.isSelectionHit(event.x) == true) {

+				doMouseSelect(hitItem, itemIndex, event.stateMask, event.button);

+			}

+			else 

+			if (hitItem.isCheckHit(new Point(event.x, event.y)) == true) {

+				doCheckItem(hitItem);

+			}

+		}

+		else {

+			deselectAll();

+		}

+	}

+}

+/**

+ * The mouse pointer was moved over the receiver.

+ * Reset the column resize cursor if it was active.

+ * @param event - the mouse event

+ */

+void columnMouseMove(Event event) {

+	if (isColumnResizeStarted() == false) {

+		setColumnResizeCursor(false);

+	}

+}

+public Point computeSize(int wHint, int hHint, boolean changed) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Point size = super.computeSize(wHint, hHint, changed);

+	Point headerSize;

+	GC gc;

+	final int WidthCalculationCount = Math.min(getItemCount(), 50);		// calculate item width for the first couple of items only

+	TableItem item;

+	Image itemImage;

+	String itemText;

+	int width;

+	int newItemWidth = 0;

+		

+	if (getHeaderVisible() == true) {

+		headerSize = getHeader().computeSize(SWT.DEFAULT, SWT.DEFAULT, false);

+		size.y += headerSize.y;		

+	}

+	if (getContentWidth() == 0 && WidthCalculationCount > 0) {

+		gc = new GC(this);

+		for (int i = 0; i < WidthCalculationCount; i++) {

+			item = getItem(i);

+			if (item == null) {

+				break;											// no more items

+			}

+			itemImage = item.getImage();

+			itemText = item.getText();

+			width = 0;

+			if (itemImage != null) {

+				width += itemImage.getBounds().width;

+			}

+			if (itemText != null) {

+				width += gc.stringExtent(itemText).x;

+			}

+			newItemWidth = Math.max(newItemWidth, width);

+		}

+		if (newItemWidth > 0) {

+			size.x = newItemWidth;

+		}

+		gc.dispose();

+	}

+	return size;

+}

+/**
+ * Deselects the items at the given zero-relative indices in the receiver.
+ * If the item at the given zero-relative index in the receiver 
+ * is selected, it is deselected.  If the item at the index
+ * was not selected, it remains deselected. Indices that are out
+ * of range and duplicate indices are ignored.
+ *
+ * @param indices the array of indices for the items to deselect
+ *
+ * @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>
+ */

+public void deselect(int indices[]) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);	

+	SelectableItem item = null;

+	

+	if (indices == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	for (int i = 0; i < indices.length; i++) {

+		item = getVisibleItem(indices[i]);

+		if (item != null) {

+			deselect(item);

+		}

+	}

+	if (item != null) {

+		setLastSelection(item, false);

+	}

+}

+/**
+ * Deselects the item at the given zero-relative index in the receiver.
+ * If the item at the index was already deselected, it remains
+ * deselected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to deselect
+ *
+ * @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 deselect(int index) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItem item = getVisibleItem(index);

+

+	if (item != null) {

+		deselect(item);

+		setLastSelection(item, false);		

+	}

+}

+/**
+ * Deselects the items at the given zero-relative indices in the receiver.
+ * If the item at the given zero-relative index in the receiver 
+ * is selected, it is deselected.  If the item at the index
+ * was not selected, it remains deselected.  The range of the
+ * indices is inclusive. Indices that are out of range are ignored.
+ *
+ * @param start the start index of the items to deselect
+ * @param end the end index of the items to deselect
+ *
+ * @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 deselect(int start, int end) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItem item = null;

+

+	for (int i=start; i<=end; i++) {

+		item = getVisibleItem(i);

+		if (item != null) {

+			deselect(item);

+		}

+	}

+	if (item != null) {

+		setLastSelection(item, false);

+	}	

+}

+/**
+ * Deselects all selected items in the receiver.
+ *
+ * @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 deselectAll() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	deselectAllExcept((SelectableItem) null);

+}

+/**

+ * Free resources.

+ */

+void doDispose() {

+	Vector items = getItemVector();

+	

+	super.doDispose();

+	while (items.size() > 0) {								// TableItem objects are removed from vector during dispose()

+		((TableItem) items.lastElement()).dispose();

+	}

+	items = getColumnVector();

+	while (items.size() > 0) {								// TableColumn objects are removed from vector during dispose()

+		((TableColumn) items.lastElement()).dispose();

+	}

+	resizeColumn = null;

+	fillColumn = null;

+	defaultColumn = null;

+	if (columnResizeCursor != null) {

+		columnResizeCursor.dispose();

+	}

+}

+/**

+ * Draw a line tracking the current position of a column 

+ * resize operation.

+ * @param xPosition - x coordinate to draw the line at

+ */

+void drawColumnResizeLine(int xPosition) {

+	GC gc = new GC(this);

+	int lineHeight = getClientArea().height;

+

+	redraw(getColumnResizeX(), 0, 1, lineHeight, false);

+	setColumnResizeX(xPosition);

+	gc.drawLine(xPosition, 0, xPosition, lineHeight);

+	gc.dispose();

+}

+/**

+ * Draw the grid lines for the receiver.

+ * @param event - Paint event triggering the drawing operation.

+ * @param drawColumns - The table columns for which the grid 

+ *	lines should be drawn.

+ */

+void drawGridLines(Event event, Enumeration drawColumns) {

+	GC gc = event.gc;

+	Color oldForeground = getForeground();

+	Rectangle columnBounds;

+	TableColumn column;

+	int lineWidth = getGridLineWidth();

+	int itemHeight = getItemHeight();

+	int headerHeight = getHeaderHeight();

+	int lineXPosition;

+	int lineYPosition = headerHeight + ((event.y-headerHeight) / itemHeight) * itemHeight;

+	int lineYStopPosition = event.y + event.height;

+

+	gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));

+	// Draw the horizontal lines	

+	if (itemHeight > 0) {

+		while (lineYPosition < lineYStopPosition) {

+			gc.drawLine(

+				event.x, lineYPosition + itemHeight - lineWidth, 

+				event.x + event.width, lineYPosition + itemHeight - lineWidth);

+			lineYPosition += itemHeight; 		

+		}

+	}

+	// Draw the vertical lines at the right border of each column except the fill column

+	while (drawColumns.hasMoreElements() == true) {

+		column = (TableColumn) drawColumns.nextElement();

+		if (column.getIndex() != TableColumn.FILL) {

+			columnBounds = column.getBounds();

+			lineXPosition = columnBounds.x + columnBounds.width - lineWidth;

+			gc.drawLine(

+				lineXPosition, event.y, 

+				lineXPosition, event.y + event.height);

+		}

+	}

+	gc.setForeground(oldForeground);

+}

+/**

+ * Draw a filled rectangle indicating the selection state of 'item'

+ * If 'item' is selected the rectangle will be filled with the 

+ * selection background color. Otherwise the rectangle will be filled 

+ * with the background color to remove selection.

+ * The selection color depends on whether the table widget has 

+ * focus or not. See getSelectionBackgroundColor() for details.

+ * The rectangle is drawn in either the first column or in all columns 

+ * for full row select.

+ * @param item - item for which the selection state should be drawn

+ * @param gc - GC to draw on. 

+ * @param position - position on the GC to draw at.

+ * @param extent - extent of the selection rectangle.

+ */

+void drawSelection(TableItem item, GC gc, Point position, Point extent) {

+	if (item.isSelected() == true) {

+		gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));

+	}

+	gc.fillRectangle(position.x, position.y, extent.x, extent.y);

+	if (item.isSelected() == true) {

+		gc.setBackground(getBackground());

+	}

+}

+/**

+ * If the receiver has input focus draw a rectangle enclosing 

+ * the label of 'item' to indicate the input focus.

+ * The rectangle is drawn in either the first column or in all columns 

+ * for full row select. 

+ * @param item - item for which the selection state should be drawn

+ * @param gc - GC to draw on. 

+ */

+void drawSelectionFocus(TableItem item, GC gc) {

+	Point extent = item.getSelectionExtent();

+	Point position = new Point(

+		item.getImageStopX(TableColumn.FIRST) + getHorizontalOffset(),

+		getRedrawY(item));

+

+	gc.drawFocus(position.x, position.y, extent.x, extent.y);

+}

+

+/**	Not used right now. Replace focusIn/focusOut with this method once 

+ *	Display.getFocusWindow returns the new focus window on FocusOut event

+ * The focus has moved in to or out of the receiver.

+ * Redraw the item selection to reflect the focus change.

+ * @param event - the focus change event

+ */

+void focusChange(Event event) {

+	TableColumn focusColumn = getColumnAtX(event.x);

+	Control focusWindow = getDisplay().getFocusControl();

+

+	if (focusWindow == getFocusWindow() && 

+		focusColumn != null && 

+		focusColumn.getIndex() == TableColumn.FIRST) {

+		hasColumnFocus = true;

+	}

+	else {

+		hasColumnFocus = false;

+	}

+	super.focusChange(event);

+	event.widget = this;									// the ficus event is never sent to the table itself but only to the focus widget

+	notifyListeners(event.type, event);						// make sure that listeners of the table get the focus event, too

+}

+/**

+ * The focus has moved in to or out of the receiver.

+ * @param event - the focus change event

+ */

+void focusIn(Event event) {

+	TableColumn focusColumn = getColumnAtX(event.x);

+

+	if (focusColumn != null && 

+		focusColumn.getIndex() == TableColumn.FIRST) {

+		hasColumnFocus = true;

+	}

+	super.focusIn(event);

+	event.widget = this;									// the focus event is never sent to the table itself but only to the focus widget

+	notifyListeners(event.type, event);						// make sure that listeners of the table get the focus event, too

+}

+/**

+ * The focus has moved in to or out of the receiver.

+ * @param event - the focus change event

+ */

+void focusOut(Event event) {

+	TableColumn focusColumn = getColumnAtX(event.x);

+

+	if (focusColumn != null && 

+		focusColumn.getIndex() == TableColumn.FIRST) {

+		hasColumnFocus = false;

+	}

+	super.focusOut(event);

+	event.widget = this;									// the focus event is never sent to the table itself but only to the focus widget

+	notifyListeners(event.type, event);						// make sure that listeners of the table get the focus event, too

+}

+/**
+ * Returns the column at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ * If no <code>TableColumn</code>s were created by the programmer,
+ * this method will throw <code>ERROR_INVALID_RANGE</code> despite
+ * the fact that a single column of data may be visible in the table.
+ * This occurs when the programmer uses the table like a list, adding
+ * items but never creating a column.
+ *
+ * @param index the index of the column to return
+ * @return the column at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ */

+public TableColumn getColumn(int index) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector columns = getColumnVector();

+	

+	if (columns == null) error(SWT.ERROR_CANNOT_GET_ITEM);

+	if (index < 0 || index >= columns.size()) {

+		error(SWT.ERROR_INVALID_RANGE);

+	}

+	

+	return (TableColumn) columns.elementAt(index);

+}

+/**

+ * Return the column located at 'xPosition' in the widget.

+ * Return null if xPosition is outside the widget.

+ * @param xPosition - position of the desired column

+ */

+TableColumn getColumnAtX(int xPosition) {

+	Enumeration columns = internalGetColumnVector().elements();

+	TableColumn column;

+	TableColumn hitColumn = null;

+	Rectangle bounds;

+

+	while (columns.hasMoreElements() == true && hitColumn == null) {

+		column = (TableColumn) columns.nextElement();

+		bounds = column.getBounds();

+		if ((xPosition >= bounds.x) && 

+			(xPosition <= bounds.x + bounds.width)) {

+			hitColumn = column;

+		}

+	}

+	if (hitColumn == null) {

+		column = getFillColumn();

+		bounds = column.getBounds();

+		if ((xPosition >= bounds.x) && 

+			(xPosition <= bounds.x + bounds.width)) {

+			hitColumn = column;

+		}

+	}

+	return hitColumn;

+}

+/**
+ * Returns the number of columns contained in the receiver.
+ * If no <code>TableColumn</code>s were created by the programmer,
+ * this value is zero, despite the fact that visually, one column
+ * of items is may be visible. This occurs when the programmer uses
+ * the table like a list, adding items but never creating a column.
+ *
+ * @return the number of columns
+ *
+ * @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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */

+public int getColumnCount() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector columns = getColumnVector();

+	int count = 0;

+	

+	if (columns != null) {

+		count = columns.size();

+	}

+	return count;

+}

+/** Replace CURSOR_SIZEWE with real column resize cursor 

+ *	(no standard cursor-have to load from file)

+ * Answer the cursor displayed during a column resize 

+ * operation.

+ * Lazy initialize the cursor since it may never be needed.

+ */

+Cursor getColumnResizeCursor() {

+	if (columnResizeCursor == null) {

+		columnResizeCursor = new Cursor(getDisplay(), SWT.CURSOR_SIZEWE);

+	}

+	return columnResizeCursor;

+}

+/**

+ * Answer the current position of the mouse cursor during

+ * a column resize operation.

+ */

+int getColumnResizeX() {

+	return columnResizeX;

+}

+/**
+ * Returns an array of <code>TableColumn</code>s which are the
+ * columns in the receiver. If no <code>TableColumn</code>s were
+ * created by the programmer, the array is empty, despite the fact
+ * that visually, one column of items may be visible. This occurs
+ * when the programmer uses the table like a list, adding items but
+ * never creating a column.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @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 TableColumn [] getColumns() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector columns = getColumnVector();

+	TableColumn columnArray[] = new TableColumn[columns.size()];

+

+	columns.copyInto(columnArray);

+	return columnArray;

+}

+/**

+ * Answer a Vector containing all columns of receiver except 

+ * the fill column to the right of all content columns.

+ */

+Vector getColumnVector() {

+	return columns;

+}

+/**

+ * Return the default column that is created as soon as the table 

+ * is created.

+ * Fix for 1FUSJY5

+ */

+TableColumn getDefaultColumn() {

+	return defaultColumn;

+}

+/**

+ * Answer the width of the replacement String used to indicate 

+ * truncated items.

+ * Cached to speed up calculation of truncated items.

+ * @param gc - GC used to measure the width of the replacement 

+ *	String

+ */

+int getDotsWidth(GC gc) {

+	if (dotsWidth == -1) {

+		dotsWidth = gc.stringExtent(DOT_STRING).x;

+	}

+	return dotsWidth;

+}

+/**

+ * Answer the column used to occupy any space left to the 

+ * right of all the user created columns.

+ */

+TableColumn getFillColumn() {

+	return fillColumn;

+}

+/**

+ * Answer the widget that is used to hold focus for the receiver.

+ * The receiver can not get focus itself because it has children.

+ */

+Control getFocusWindow() {

+	return focusProxy;

+}

+/**
+ * Returns the width in pixels of a grid line.
+ *
+ * @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 getGridLineWidth () {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return 1;

+}

+/**

+ * Answer the table header widget.

+ */

+Header getHeader() {

+	return tableHeader;

+}

+/**

+ * Answer the header height or 0 if the header is not visible.

+ */

+int getHeaderHeight() {

+	Header header = getHeader();

+	int height = 0;

+	

+	if (header.getVisible() == true) {

+		height = header.getBounds().height;

+	}

+	return height;

+}

+/**
+ * Returns <code>true</code> if the receiver's header is visible,
+ * and <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's header's visibility 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 getHeaderVisible() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return getHeader().getVisible();

+}

+/**

+ * Answer the image extent of 'item'. Use the image of any column.

+ */

+Point getImageExtent(SelectableItem item) {

+	Image image = null;

+	Rectangle imageBounds;

+	Point imageExtent = null;

+	int columnCount = internalGetColumnCount();

+

+	for (int i = 0; i < columnCount && image == null; i++) {

+		image = ((TableItem) item).getImage(i);

+	}		

+	if (image != null) {

+		imageBounds = image.getBounds();

+		imageExtent = new Point(imageBounds.width, imageBounds.height);

+	}

+	return imageExtent;

+}

+/**

+ * Answer the index of 'item' in the receiver.

+ */

+int getIndex(SelectableItem item) {

+	int index = -1;

+	

+	if (item != null && item.getSelectableParent() == this) {

+		index = ((TableItem) item).getIndex();

+	}

+	return index;

+}

+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ */

+public TableItem getItem(int index) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	if (!(0 <= index && index < getItemCount())) {

+		error(SWT.ERROR_INVALID_RANGE);

+	}		

+	return (TableItem) getVisibleItem(index);	

+}

+

+/**
+ * Returns the item at the given point in the receiver
+ * or null if no such item exists. The point is in the
+ * coordinate system of the receiver.
+ *
+ * @param point the point used to locate the item
+ * @return the item at the given point
+ *
+ * @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>
+ */

+public TableItem getItem(Point point) {

+	int headerHeight = getHeaderHeight();

+	TableColumn column = getColumnAtX(point.x);

+	TableItem item = null;

+

+	if (column != null && column.getIndex() != TableColumn.FILL && point.y - headerHeight > 0) {

+		int itemIndex = (point.y - headerHeight) / getItemHeight() + getTopIndex();

+		item = (TableItem) getVisibleItem(itemIndex);

+		if (item != null) {

+			Point itemSize = item.getItemExtent(column);

+			if (point.x - column.getBounds().x > itemSize.x) {

+				item = null;

+			}

+		}

+	}

+	return item;

+}

+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @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 getItemCount() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return getItemVector().size();

+}

+/**

+ * Answer the number of items that can be displayed in the

+ * client area of the receiver without truncating any items.

+ */

+int getItemCountWhole() {

+	int clientAreaHeight = Math.max(0, getClientArea().height - getHeaderHeight());

+	

+	return clientAreaHeight / getItemHeight();

+}

+/**
+ * Returns the height of the area which would be used to
+ * display <em>one</em> of the items in the receiver's.
+ *
+ * @return the height of one item
+ *
+ * @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 getItemHeight() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return super.getItemHeight();

+}

+/**

+ * Answer the number of pixels that should be added to the item height.

+ */

+int getItemPadding() {

+	return getGridLineWidth() + getDisplay().textHighlightThickness + 1;

+}

+/**
+ * Returns an array of <code>TableItem</code>s which are the items
+ * in the receiver. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @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 TableItem [] getItems() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector items = getItemVector();

+	TableItem itemArray[] = new TableItem[items.size()];

+

+	items.copyInto(itemArray);

+	return itemArray;

+}

+/**

+ * Answer all items of the receiver.

+ */

+Vector getItemVector() {

+	return items;

+}

+/**
+ * Returns <code>true</code> if the receiver's lines are visible,
+ * and <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the visibility state of the lines
+ *
+ * @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 getLinesVisible() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return drawGridLines;

+}

+/** 

+ * Answer a Vector containing the columns that need repainting 

+ * based on the 'paintArea'.

+ * @param paintArea - invalidated rectangle that needs repainting

+ */

+Vector getPaintColumns(Rectangle paintArea) {

+	Enumeration columns = internalGetColumnVector().elements();

+	Vector paintColumns = new Vector();

+	TableColumn column;

+	Rectangle columnBounds;

+	int paintAreaRightBorder = paintArea.x + paintArea.width;

+

+	while (columns.hasMoreElements() == true) {

+		column = (TableColumn) columns.nextElement();

+		columnBounds = column.getBounds();

+		if ((columnBounds.x + columnBounds.width >= paintArea.x) &&	// does the paintArea overlap the current column?

+			(columnBounds.x <= paintAreaRightBorder)) {

+			paintColumns.addElement(column);

+		}

+	}

+	return paintColumns;

+}

+/** 

+ * Return the width of the widest item in the column identified by 'columnIndex'

+ * @param columnIndex - index of the column whose preferred width should be

+ *	calculated

+ */

+int getPreferredColumnWidth(int columnIndex) {

+	Enumeration tableItems = getItemVector().elements();

+	TableItem tableItem;

+	int width = 0;

+	int headerWidth;

+	

+	if (columnIndex != TableColumn.FILL) {

+		while (tableItems.hasMoreElements() == true) {

+			tableItem = (TableItem) tableItems.nextElement();

+			width = Math.max(width, tableItem.getPreferredWidth(columnIndex));

+		}

+		headerWidth = getHeader().getPreferredWidth(columnIndex);

+		if (width < headerWidth) {

+			width = headerWidth;

+		}

+	}

+	return width;

+}

+/**

+ * Answer the position in the receiver where 'item' is drawn

+ * @return the y coordinate at which 'item' is drawn.

+ *	Return -1 if 'item' is not an item of the receiver 

+ */

+int getRedrawY(SelectableItem item) {

+	int redrawY = super.getRedrawY(item);

+

+	if (redrawY != -1) {

+		redrawY += getHeaderHeight();

+	}

+	return redrawY;

+}

+/**

+ * Answer the column that is being resized or null if no 

+ * resize operation is in progress.

+ */

+TableColumn getResizeColumn() {

+	return resizeColumn;

+}

+/**

+ * Return the positions at which the column identified by 'columnIndex' 

+ * must be redrawn.

+ * These positions may be different for each item since each item may 

+ * have a different label

+ * @param columnIndex - the column index

+ * @param columnWidth - width of the column

+ * @return the positions at which the column must be redrawn.

+ *	Each item in the widget client area is represented by a slot in 

+ * 	the array. The item at position 'topIndex' is the first item in 

+ *	the array.

+ */

+int [] getResizeRedrawX(int columnIndex, int columnWidth) {

+	int topIndex = getTopIndex();

+	int bottomIndex = getBottomIndex();

+	int resizeRedrawX[];

+	TableItem item;

+

+	bottomIndex = Math.min(bottomIndex, getItemCount());

+	resizeRedrawX = new int[bottomIndex-topIndex+1];

+	for (int i = topIndex; i < bottomIndex; i++) {

+		item = (TableItem) getVisibleItem(i);

+		resizeRedrawX[i-topIndex] = item.getDotStartX(columnIndex, columnWidth);

+	}

+	return resizeRedrawX;

+}

+/**
+ * Returns an array of <code>TableItem</code>s that are currently
+ * selected in the receiver. An empty array indicates that no
+ * items are selected.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ * @return an array representing the selection
+ *
+ * @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 TableItem [] getSelection() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector selectionVector = getSelectionVector();

+	TableItem[] selectionArray = new TableItem[selectionVector.size()];

+

+	selectionVector.copyInto(selectionArray);

+	sort(selectionArray, 0, selectionArray.length);

+	return selectionArray;

+}

+

+/**
+ * Returns the number of selected items contained in the receiver.
+ *
+ * @return the number of selected items
+ *
+ * @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 getSelectionCount() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return super.getSelectionCount();

+}

+/**

+ * Answer the size of the full row selection rectangle for 'item'.

+ */

+Point getFullSelectionExtent(TableItem item) {

+	TableColumn lastColumn = (TableColumn) internalGetColumnVector().lastElement();

+	Point selectionExtent = null;

+	Rectangle columnBounds;

+	int xPosition = item.getImageStopX(TableColumn.FIRST);

+	int gridLineWidth = getGridLineWidth();

+

+	if (lastColumn != null) {

+		columnBounds = lastColumn.getBounds();

+		selectionExtent = new Point(

+			columnBounds.x - getHorizontalOffset() + columnBounds.width - xPosition - gridLineWidth, 

+			getItemHeight());

+		if (getLinesVisible() == true) {

+			selectionExtent.y -= gridLineWidth;

+		}	

+	}

+	return selectionExtent;

+}

+/**
+ * Returns the zero-relative index of the item which is currently
+ * selected in the receiver, or -1 if no item is selected.
+ *
+ * @return the index of the selected item
+ *
+ * @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 getSelectionIndex() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	int index = -1;

+	

+	if (getSelectionCount() > 0) {

+		index = getIndex(getSelection()[0]);

+	}

+	return index;

+}

+/**
+ * Returns the zero-relative indices of the items which are currently
+ * selected in the receiver.  The array is empty if no items are selected.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ * @return the array of indices of the selected items
+ *
+ * @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 [] getSelectionIndices() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	TableItem[] items = getSelection();

+	int indices[] = new int[items.length];

+

+	for (int i = 0; i < items.length; i++) {

+		indices[i] = getIndex(items[i]);

+	}	

+	return indices;

+}

+/**
+ * Returns the zero-relative index of the item which is currently
+ * at the top of the receiver. This index can change when items are
+ * scrolled or new items are added or removed.
+ *
+ * @return the index of the top item
+ *
+ * @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 getTopIndex() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return super.getTopIndex();

+}

+/**

+ * Answer the index of 'item' in the receiver.

+ * Answer -1 if the item is not visible.

+ * The returned index must refer to a visible item.

+ * Note: 

+ * 	Visible in this context does not neccessarily mean that the 

+ * 	item is displayed on the screen. It only means that the item 

+ * 	would be displayed if it is located inside the receiver's 

+ * 	client area.

+ *	Every item in a table widget should be visible.

+ */

+int getVisibleIndex(SelectableItem item) {

+	return getIndex(item);

+}

+/**

+ * Answer the SelectableItem located at 'itemIndex' in the receiver.

+ * @param itemIndex - location of the SelectableItem object to return

+ */

+SelectableItem getVisibleItem(int itemIndex) {

+	Vector items = getItemVector();

+	TableItem item = null;

+	

+	if ((items != null) && (itemIndex >= 0) && (itemIndex < items.size())) {

+		item = (TableItem) items.elementAt(itemIndex);

+	}

+	return item;

+}

+/**

+ * Answer the y coordinate at which 'item' is drawn. 

+ * @param item - SelectableItem for which the paint position 

+ *	should be returned

+ * @return the y coordinate at which 'item' is drawn.

+ *	Return -1 if 'item' is null or outside the client area

+ */

+int getVisibleRedrawY(SelectableItem item) {

+	int redrawY = -1;

+	int index = getTopIndex();

+	int bottomIndex = getBottomIndex();

+	

+	if (item == null) {

+		return redrawY;

+	}

+	while (index < bottomIndex && item.equals(getVisibleItem(index)) == false) {

+		index++;

+	}

+	if (index < bottomIndex) {

+		redrawY = getRedrawY(item);

+	}

+	return redrawY;

+}

+/**

+ * Handle the events the receiver is listening to.

+ */

+void handleEvents(Event event) {

+	switch (event.type) {

+		case SWT.MouseMove:

+			if (event.widget == tableHeader) {

+				headerMouseMove(event);

+			}

+			else {

+				columnMouseMove(event);

+			}

+			break;

+		case SWT.MouseDown:

+			if (event.widget == tableHeader) {

+				headerMouseDown(event);

+			}

+			else {

+				columnMouseDown(event);

+			}

+			break;

+		case SWT.MouseDoubleClick:

+			columnMouseDoubleClick(event);

+			break;

+		case SWT.MouseUp:

+			mouseUp(event);

+			break;

+		case SWT.Paint:

+			paint(event);

+			break;

+		default:

+			super.handleEvents(event);

+	}		

+}

+/**

+ * Answer true if any item in the first column has an image.

+ * Answer false otherwise.

+ */

+boolean hasFirstColumnImage() {

+	return firstColumnImage;

+}

+public boolean isFocusControl() {

+	return hasColumnFocus;

+}

+/**

+ * The mouse pointer was pressed down on the receiver's header

+ * widget. Start a column resize operation if apropriate.

+ * @param event - the mouse event that occured over the header 

+ *	widget

+ */

+void headerMouseDown(Event event) {

+	TableColumn column = getColumnAtX(event.x);

+

+	if (isColumnResize(event) == true) {

+		startColumnResize(event);

+	}

+	else

+	if (column != null) {

+		column.notifyListeners(SWT.Selection, new Event());

+	}

+}

+/**

+ * The mouse pointer was moved over the receiver's header widget.

+ * If a column is currently being resized a vertical line indicating 

+ * the new position of the resized column is drawn.

+ * Otherwise, if no column resize operation is in progress, the 

+ * column resize cursor is displayed when the mouse is near the border 

+ * of a column.

+ */

+void headerMouseMove(Event event) {

+	if (isColumnResizeStarted() == false) {				// only check whether cursor is in resize

+		setColumnResizeCursor(isColumnResize(event));	// area if no resize operation is in progress

+	}

+	else 

+	if (event.x >= getResizeColumn().getBounds().x) {

+		drawColumnResizeLine(event.x);

+		update();										// looks better if resize line is drawn immediately

+	}

+}

+/**
+ * Searches the receiver's list starting at the first column
+ * (index 0) until a column is found that is equal to the 
+ * argument, and returns the index of that column. If no column
+ * is found, returns -1.
+ *
+ * @param column the search column
+ * @return the index of the column
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string 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>
+ */

+public int indexOf(TableColumn column) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (column == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	return internalGetColumnVector().indexOf(column);

+}

+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param item the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string 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>
+ */

+public int indexOf(TableItem item) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (item == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}	

+	return getIndex(item);

+}

+/**

+ * Initialize the receiver. Create a header widget and an empty column.

+ */

+void initialize() {

+	columns = new Vector();

+	setItemVector(new Vector());

+	focusProxy = new Button(this, SWT.NULL);

+	focusProxy.setBounds(-100, -100, 0, 0);				// make the focus proxy invisible

+	tableHeader = new Header(this);

+	tableHeader.setVisible(false);					// SWT table header is invisible by default, too

+	fillColumn = TableColumn.createFillColumn(this);

+	setColumnPosition(fillColumn);

+	defaultColumn = TableColumn.createDefaultColumn(this);	// Create the default column. Fix for 1FUSJY5	

+	super.initialize();

+}

+/**

+ * Insert the new column 'column' into the table data at position 

+ * 'index'.

+ */

+void insertColumnData(TableColumn column) {

+	Enumeration tableItems = getItemVector().elements();

+	TableItem tableItem;

+	

+	while (tableItems.hasMoreElements() == true ) {

+		tableItem = (TableItem) tableItems.nextElement();

+		tableItem.insertColumn(column);

+	}

+}

+/**

+ * Insert the new column 'column'.

+ * Set the position and move the following columns to the right.

+ */

+void insertColumnVisual(TableColumn column) {

+	Rectangle columnBounds = column.getBounds();

+	Rectangle previousColumnBounds;

+	int index = column.getIndex();

+		

+	if (index > 0) {

+		previousColumnBounds = getColumn(index - 1).getBounds();

+		columnBounds.x = previousColumnBounds.x + previousColumnBounds.width;

+	}

+	else {

+		columnBounds.x = 0;

+	}

+	column.setBounds(columnBounds);

+	setColumnPosition(column);

+}

+/**

+ * Set event listeners for the receiver.

+ */

+void installListeners() {

+	Header tableHeader = getHeader();

+	Control focusWindow = getFocusWindow();

+	Listener listener = getListener();

+

+	super.installListeners();	

+	tableHeader.addListener(SWT.MouseMove, listener);

+	tableHeader.addListener(SWT.MouseDown, listener);

+	tableHeader.addListener(SWT.MouseUp, listener);

+	

+	// HACK: All we're really interested in is focus change and key down

+	// for the table itself. Doesn't work that way because setFocus sets 

+	// focus to the first child of the receiver (which is our focus window)

+	removeListener(SWT.FocusOut, listener);

+	removeListener(SWT.FocusIn, listener);	

+	focusWindow.addListener(SWT.FocusOut, listener);

+	focusWindow.addListener(SWT.FocusIn, listener);

+	focusWindow.addListener(SWT.KeyDown, listener);			

+	

+	addListener(SWT.MouseMove, listener);

+	addListener(SWT.MouseDown, listener);

+	addListener(SWT.MouseDoubleClick, listener);

+	addListener(SWT.MouseUp, listener);

+	addListener(SWT.Paint, listener);

+}

+/**

+ * Answer the TableColumn at 'index'.

+ * If the user has not created any columns the default column is 

+ * returned if index is 0.

+ * Fix for 1FUSJY5 

+ */

+TableColumn internalGetColumn(int index) {

+	Vector columns = internalGetColumnVector();

+	

+	if (columns == null) error(SWT.ERROR_CANNOT_GET_ITEM);

+	if (index < 0 || index >= columns.size()) {

+		error(SWT.ERROR_INVALID_RANGE);

+	}

+	

+	return (TableColumn) columns.elementAt(index);

+

+}

+/**

+ * Answer the number of columns in the receiver.

+ * If the user has not created any columns, 1 is returned since there 

+ * always is a default column.

+ * Fix for 1FUSJY5

+ */

+int internalGetColumnCount() {

+	Vector columns = internalGetColumnVector();

+	int count = 0;

+	

+	if (columns != null) {

+		count = columns.size();

+	}

+	return count;

+}

+/**

+ * Return a Vector containing all columns of the receiver except 

+ * the fill column to the right of all content columns.

+ * Return a Vector containing the default column if the user has

+ * not created any columns.

+ * Fix for 1FUSJY5 

+ */

+Vector internalGetColumnVector() {

+	Vector internalColumnVector;

+	TableColumn defaultColumn;

+	

+	if (columns.isEmpty() == false) {

+		internalColumnVector = columns;

+	}

+	else {

+		internalColumnVector = new Vector(1);

+		defaultColumn = getDefaultColumn();		

+		if (defaultColumn != null) {

+			internalColumnVector.addElement(defaultColumn);

+		}

+	}

+	return internalColumnVector;

+}

+/**

+ * Answer whether the mouse pointer is at a position that can

+ * start a column resize operation. A column resize can be 

+ * started if the mouse pointer is at either the left or right 

+ * border of a column.

+ * @param event - mouse event specifying the location of the 

+ *	mouse pointer.

+ */

+boolean isColumnResize(Event event) {

+	TableColumn hotColumn = getColumnAtX(event.x);

+	Rectangle bounds = hotColumn.getBounds();

+	int hotColumnIndex = hotColumn.getIndex();

+	int columnX = event.x - bounds.x;

+	boolean isColumnResize = false;

+

+	if (columnX <= COLUMN_RESIZE_OFFSET && 									// mouse over left side of column? and

+		hotColumnIndex != TableColumn.FIRST) {								// it's not the first column)

+		if (hotColumnIndex == TableColumn.FILL) {

+			hotColumn = (TableColumn) internalGetColumnVector().lastElement();

+		}

+		else {

+			hotColumn = internalGetColumn(hotColumnIndex - 1);

+		}

+		isColumnResize = hotColumn.getResizable();							// check whether left column can be resized

+	}

+	else

+	if (columnX >= bounds.width - COLUMN_RESIZE_OFFSET && 					// mouse over right side of column and

+		hotColumn != getFillColumn()) {										// column is a real one (not the right hand fill column)?

+		isColumnResize = hotColumn.getResizable();							// check whether column under cursor can be resized

+	}

+	return isColumnResize;

+}

+/**

+ * Answer whether a column of the receiver is being resized.

+ */

+boolean isColumnResizeStarted() {

+	return (getResizeColumn() != null);

+}

+/**
+ * Returns <code>true</code> if the item is selected,
+ * and <code>false</code> otherwise.  Indices out of
+ * range are ignored.
+ *
+ * @param index the index of the item
+ * @return the visibility state of the item at the index
+ *
+ * @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 isSelected(int index) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	TableItem item = getItem(index);

+

+	return (item != null && item.isSelected() == true);

+}

+/**

+ * 'changedItem' has changed. Update the default column width.

+ * @param changedItem - the item that has changed

+ */

+void itemChanged(SelectableItem changedItem, int repaintStartX, int repaintWidth) {

+	// call super.itemChanged first to make sure that table image size is 

+	// calculated if necessary. Fixes 1FYPBBG.

+	super.itemChanged(changedItem, repaintStartX, repaintWidth);

+	// remember if any item ever had an image in the first column.

+	if (firstColumnImage == false && changedItem.getImage() != null) {

+		firstColumnImage = true;

+	}

+	setFirstColumnWidth((TableItem) changedItem);	

+}

+/**

+ * A mouse button was released. 

+ * Update the display if a column has been resized.

+ * @param event - the mouse event for the button up action

+ */

+void mouseUp(Event event) {

+	TableColumn resizeColumn = getResizeColumn();

+	Rectangle oldColumnBounds;

+	int resizeXPosition;

+	int widthChange;

+	

+	if (isColumnResizeStarted() == true) {

+		oldColumnBounds = resizeColumn.getBounds();

+		resizeXPosition = getColumnResizeX();	

+		widthChange = resizeXPosition - (oldColumnBounds.x + oldColumnBounds.width);

+		if (widthChange != 0) {

+			if (widthChange > 0) {

+				redraw(resizeXPosition, 0, 1, getClientArea().height, false);		// remove resize line

+				update();															// to avoid cheese caused by scrolling the resize line

+			}

+			resizeColumn.setWidth(oldColumnBounds.width + widthChange);

+		}

+		setResizeColumn(null);

+	}

+}

+/**

+ * Adjust the position of all columns starting at 'startIndex'.

+ * @param startIndex - index at which the column move should begin

+ *	If this is the index of the fill column all columns are moved,

+ * 	including the fill column

+ * @param moveDistance - distance that the columns should be moved.

+ *	< 0 = columns are going to be moved left.

+ *	> 0 = columns are going to be moved right.

+ */

+void moveColumns(int startIndex, int moveDistance) {

+	Vector columns = internalGetColumnVector();

+	TableColumn moveColumn;

+	Rectangle columnBounds;

+

+	if (startIndex == TableColumn.FILL) {

+		moveColumn = getFillColumn();

+		columnBounds = moveColumn.getBounds();

+		columnBounds.x += moveDistance;

+		moveColumn.setBounds(columnBounds);

+		startIndex = 0;					// continue with first data column

+	}

+	for (int i = startIndex; i < columns.size(); i++) {

+		moveColumn = (TableColumn) columns.elementAt(i);

+		columnBounds = moveColumn.getBounds();

+		columnBounds.x += moveDistance;

+		moveColumn.setBounds(columnBounds);

+	}

+}

+/**

+ * Adjust the y position of all columns including the fill column.

+ */

+void moveColumnsVertical() {

+	Enumeration columns = internalGetColumnVector().elements();

+	TableColumn column;

+

+	setColumnPosition(getFillColumn());

+	while (columns.hasMoreElements() == true) {

+		column = (TableColumn) columns.nextElement();

+		setColumnPosition(column);

+	}

+}

+/** 

+ * A paint event has occurred. Paint the invalidated items.

+ * @param event - paint event specifying the invalidated area.

+ */

+void paint(Event event) {

+	int visibleRange[];

+	int headerHeight = getHeaderHeight();

+	Vector paintColumns = getPaintColumns(event.getBounds());

+	TableItem focusItem = null;

+	

+	if (paintColumns.size() > 0) {

+		event.y -= headerHeight;

+		visibleRange = getIndexRange(event.getBounds());

+		event.y += headerHeight;

+		// When the top index is > 0 and the receiver is resized 

+		// higher so that the top index becomes 0 the invalidated 

+		// rectangle doesn't start below the header widget but at 

+		// y position 0. Subtraction of the header height (it is 

+		// not above the receiver but on top) causes event.y and 

+		// subsequently visibleRange[0] to be negative.

+		// Hack to prevent visibleRange[0] from becoming negative.

+		// Need to find out why the invalidated area starts at 0

+		// in the first place.

+		if (visibleRange[0] < 0) {

+			visibleRange[0] = 0;

+		}

+		// 

+		visibleRange[1] = Math.min(visibleRange[1], getItemCount()-1-getTopIndex());

+		focusItem = paintItems(event, visibleRange[0], visibleRange[1], paintColumns);

+	}

+	if (getLinesVisible() == true) {

+		drawGridLines(event, paintColumns.elements());

+	}

+	if (focusItem != null) {

+		// draw focus on top of drawing grid lines so that focus rectangle 

+		// is not obscured by grid. Fixes 1G5X20B

+		drawSelectionFocus(focusItem, event.gc);	

+	}

+}

+

+/**

+ * Paint items of the receiver starting at index 'topPaintIndex' and 

+ * ending at 'bottomPaintIndex'.

+ * @param event - holds the GC to draw on and the clipping rectangle

+ * @param topPaintIndex - index of the first item to draw

+ * @param bottomPaintIndex - index of the last item to draw

+ * @param paintColumns - the table columns that should be painted

+ * @return the item that has focus if it was among the rendered items.

+ *	null if the focus item was not rendered or if no item has focus (ie. 

+ *	because the widget does not have focus)

+ */

+TableItem paintItems(Event event, int topPaintIndex, int bottomPaintIndex, Vector paintColumns) {

+	Enumeration columns;

+	TableColumn column;

+	TableItem paintItem;

+	TableItem focusItem = null;

+	Point selectionExtent;

+	Point selectionPosition;

+	int itemHeight = getItemHeight();

+

+	topPaintIndex += getTopIndex();

+	bottomPaintIndex += getTopIndex();

+	for (int i = topPaintIndex; i <= bottomPaintIndex; i++) {

+		paintItem = (TableItem) getVisibleItem(i);

+		selectionExtent = paintItem.getSelectionExtent();

+		if (selectionExtent != null) {

+			selectionPosition = new Point(paintItem.getSelectionX(), getRedrawY(paintItem));

+			drawSelection(paintItem, event.gc, selectionPosition, selectionExtent);

+		}

+		columns = paintColumns.elements();

+		while (columns.hasMoreElements() == true) {

+			column = (TableColumn) columns.nextElement();

+			paintSubItem(event, paintItem, column, i * itemHeight);

+		}

+		if (hasFocus(paintItem)) {

+			focusItem = paintItem;

+		}

+	}

+	return focusItem;

+}

+

+/**

+ * Paint the table item 'paintItem' in 'column' at y position 

+ * 'paintYPosition' of the receiver.

+ * @param event - holds the GC to draw on and the clipping 

+ *	rectangle.

+ * @param paintItem - the item to draw

+ * @param column - column to draw 'paintItem' in

+ * @param paintYPosition - y position in the receiver to draw 

+ *	'paintItem' at.

+ */

+void paintSubItem(Event event, TableItem paintItem, TableColumn column, int paintYPosition) {

+	Rectangle columnBounds = column.getBounds();

+	int gridLineWidth = getGridLineWidth();

+	int itemDrawStopX = columnBounds.x + columnBounds.width - gridLineWidth;

+	int clipX;

+	

+	if (event.x + event.width > itemDrawStopX) {	// does the invalidated area stretch past the current column's right border?

+		clipX = Math.max(columnBounds.x, event.x);

+		event.gc.setClipping(											// clip the drawing area

+			clipX, event.y, 

+			itemDrawStopX - clipX, event.height);		

+	}

+	column.paint(paintItem, event.gc, paintYPosition);

+	if (event.x + event.width > itemDrawStopX) {

+		event.gc.setClipping(event.x, event.y, event.width, event.height); // restore original clip rectangle

+	}

+}

+/**

+ * Reindex all columns starting at 'startIndex'.

+ * Reindexing is necessary when a new column has been inserted.

+ */

+void reindexColumns(int startIndex) {

+	Vector columns = getColumnVector();

+	TableColumn column;

+	

+	for (int i = startIndex; i < getColumnCount(); i++) {

+		column = (TableColumn) columns.elementAt(i);

+		column.setIndex(i);

+	}

+}

+/**
+ * Removes the items from the receiver's list at the given
+ * zero-relative indices.
+ *
+ * @param indices the array of indices of the items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */

+public void remove(int indices[]) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItem item;

+	int [] sortedIndices;

+	int last = -1;

+	

+	if (indices == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	sortedIndices = new int[indices.length];	

+	System.arraycopy (indices, 0, sortedIndices, 0, indices.length);

+	sort(sortedIndices);								// sort indices in descending order

+	for (int i = 0; i < sortedIndices.length; i++) {

+		if (sortedIndices[i] != last) {

+			item = getVisibleItem(sortedIndices[i]);

+			if (item != null) {

+				item.dispose();

+			}

+			else {

+				error(SWT.ERROR_ITEM_NOT_REMOVED);

+			}

+			last = sortedIndices[i];			

+		}

+	}

+}

+/**
+ * Removes the item from the receiver at the given
+ * zero-relative index.
+ *
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */

+public void remove(int index) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItem item = getVisibleItem(index);

+

+	if (item != null) {

+		item.dispose();

+	}

+	else {

+		error(SWT.ERROR_ITEM_NOT_REMOVED);

+	}

+}

+/**
+ * Removes the items from the receiver which are
+ * between the given zero-relative start and end 
+ * indices (inclusive).
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</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>
+ * @exception SWTError <ul>
+ *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */

+public void remove(int start, int end) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItem item;

+	

+	for (int i = end; i >= start; i--) {

+		item = getVisibleItem(i);

+		if (item != null) {

+			item.dispose();

+		}

+		else {

+			error(SWT.ERROR_ITEM_NOT_REMOVED);

+		}

+	}

+}

+/**
+ * Removes all of the items from the receiver.
+ * <p>
+ * @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 removeAll() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector items = getItemVector();

+

+	setRedraw(false);

+	setRemovingAll(true);

+	for (int i = 0; i < items.size(); i++) {

+		((TableItem) items.elementAt(i)).dispose();

+	}

+	setItemVector(new Vector());

+	reset();

+	calculateVerticalScrollbar();

+	setRemovingAll(false);

+	setRedraw(true);	

+}

+/**

+ * Remove 'column' from the receiver.

+ */

+void removeColumn(TableColumn column) {

+	TableColumn lastColumn;

+	int index = column.getIndex();

+	int columnWidth = column.getWidth();

+	int columnCount;

+

+	if (isRemovingAll() == true) {

+		getColumnVector().removeElementAt(index);

+	}

+	else {		

+		getColumnVector().removeElementAt(index);

+		columnCount = getColumnCount();

+		// Never remove the data of the last user created column. 

+		// SWT for Windows does the same.

+		if (columnCount > 0) {

+			removeColumnData(column);

+		}

+		removeColumnVisual(column);		

+		if (index < columnCount) {					// is there a column after the removed one?

+			reindexColumns(index);

+		}

+		// last user created column is about to be removed.

+		if (columnCount == 0) {		

+			TableColumn defaultColumn = getDefaultColumn();

+			defaultColumn.pack();						// make sure the default column has the right size...

+			setColumnPosition(defaultColumn);			// ...and is at the right position

+		}

+		// Fixes for 1G1L0UT

+		// Reduce the content width by the width of the removed column

+		setContentWidth(getContentWidth() - columnWidth);

+		// claim free space

+		claimRightFreeSpace();		

+		//

+	}

+}

+/**

+ * Remove the column 'column' from the table data.

+ */

+void removeColumnData(TableColumn column) {

+	Enumeration tableItems = getItemVector().elements();

+	TableItem tableItem;

+

+	while (tableItems.hasMoreElements() == true ) {

+		tableItem = (TableItem) tableItems.nextElement();

+		tableItem.removeColumn(column);

+	}

+}

+/**

+ * Remove the column 'column'.

+ * Set the position of the following columns.

+ */

+void removeColumnVisual(TableColumn column) {

+	int columnWidth = column.getWidth();

+		

+	// move following columns to the left

+	moveColumns(column.getIndex() + 1, columnWidth * -1);

+	redraw();

+	getHeader().redraw();

+}

+/** 

+ * Remove 'item' from the receiver. 

+ * @param item - item that should be removed from the receiver

+ */

+void removeItem(TableItem item) {

+	Vector items = getItemVector();

+	int index = items.indexOf(item);

+

+	if (index != -1) {

+		if (isRemovingAll() == false) {

+			removingItem(item);	

+		}			

+		items.removeElementAt(index);

+		for (int i = index; i < items.size(); i++) {

+			TableItem anItem = (TableItem) items.elementAt(i);

+			anItem.setIndex(anItem.getIndex() - 1);

+		}		

+		if (isRemovingAll() == false) {

+			removedItem(item);

+		}			

+	}

+}

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's selection changes.
+ *
+ * @param listener the listener which should no longer 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 SelectionListener
+ * @see #addSelectionListener
+ */

+public void removeSelectionListener(SelectionListener listener) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	if (listener == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	removeListener(SWT.Selection, listener);

+	removeListener(SWT.DefaultSelection, listener);

+}

+/** 

+ * Reset cached data of column at 'columnIndex' for the items of the receiver. 

+ * @param columnIndex - index of the column for which the item data should be 

+ *	reset.

+ */

+void resetTableItems(int columnIndex) {

+	Enumeration tableItems = getItemVector().elements();

+	TableItem tableItem;

+

+	while (tableItems.hasMoreElements() == true ) {

+		tableItem = (TableItem) tableItems.nextElement();

+		tableItem.reset(columnIndex);

+	}

+}

+/**

+ * The receiver has been resized. Resize the fill column 

+ * and the header widget.

+ */

+void resize(Event event) {

+	TableColumn fillColumn = getFillColumn();

+	Rectangle fillColumnBounds;

+

+	super.resize(event);

+	// the x position may change in super.resize.

+	// get the column bounds after calling super.resize. Fixes 1G7ALGG

+	fillColumnBounds = fillColumn.getBounds();

+	fillColumnBounds.width = Math.max(0, getClientArea().width - getContentWidth());

+	fillColumn.setBounds(fillColumnBounds);

+	resizeHeader();

+}

+/**

+ * Resize the header widget to occupy the whole width of the

+ * receiver.

+ */

+void resizeHeader() {

+	Header tableHeader = getHeader();

+	Point size = tableHeader.getSize();

+

+	size.x = Math.max(getContentWidth(), getClientArea().width);

+	tableHeader.setSize(size);

+}

+/**

+ * Redraw 'column' after its width has been changed.

+ * @param column - column whose width has changed.

+ * @param oldColumnWidth - column width before resize

+ * @param oldColumnWidth - column width after resize 

+ */

+void resizeRedraw(TableColumn column, int oldColumnWidth, int newColumnWidth) {

+	Rectangle columnBounds = column.getBounds();

+	int columnIndex = column.getIndex();

+	int oldRedrawStartX[] = getResizeRedrawX(columnIndex, oldColumnWidth);

+	int newRedrawStartX[] = getResizeRedrawX(columnIndex, newColumnWidth);

+	int itemHeight = getItemHeight();

+	int widthChange = newColumnWidth - oldColumnWidth;

+	int topIndex = getTopIndex();

+

+	for (int i = 0; i < newRedrawStartX.length; i++) {

+		if (newRedrawStartX[i] != oldRedrawStartX[i]) {

+			if (widthChange > 0) {

+				newRedrawStartX[i] = oldRedrawStartX[i];

+			}

+			redraw(

+				columnBounds.x + newRedrawStartX[i], columnBounds.y + itemHeight * (i + topIndex), 

+				columnBounds.width - newRedrawStartX[i], itemHeight, false);

+		}

+	}

+}

+/**

+ * Scroll horizontally by 'numPixel' pixel.

+ * @param numPixel - the number of pixel to scroll

+ *	< 0 = columns are going to be moved left.

+ *	> 0 = columns are going to be moved right.

+ */

+void scrollHorizontal(int numPixel) {

+	Rectangle clientArea = getClientArea();	

+

+	scroll(

+		numPixel, 0, 								// destination x, y

+		0, 0, 										// source x, y

+		clientArea.width, clientArea.height, true);

+	getHeader().scroll(

+		numPixel, 0, 								// destination x, y

+		0, 0, 										// source x, y

+		clientArea.width, clientArea.height, true);

+	moveColumns(TableColumn.FILL, numPixel);

+}

+/**

+ * Scroll vertically by 'scrollIndexCount' items.

+ * @param scrollIndexCount - the number of items to scroll.

+ *	scrollIndexCount > 0 = scroll up. scrollIndexCount < 0 = scroll down

+ */

+void scrollVertical(int scrollIndexCount) {

+	int scrollAmount = scrollIndexCount * getItemHeight();

+	int headerHeight = getHeaderHeight();

+	int destY;

+	int sourceY;

+	boolean scrollUp = scrollIndexCount < 0;

+	Rectangle clientArea = getClientArea();

+

+	if (scrollIndexCount == 0) {

+		return;

+	}

+	if (scrollUp == true) {

+		destY = headerHeight - scrollAmount;

+		sourceY = headerHeight;

+	}

+	else {

+		destY = headerHeight;

+		sourceY = destY + scrollAmount;

+	}

+	scroll(

+		0, destY, 									// destination x, y

+		0, sourceY,									// source x, y

+		clientArea.width, clientArea.height, true);

+}

+/**

+ * Scroll items down to make space for a new item added to 

+ * the receiver at position 'index'.

+ * @param index - position at which space for one new item

+ *	should be made. This index is relative to the first item 

+ *	of the receiver.

+ */

+void scrollVerticalAddingItem(int index) {

+	int itemHeight = getItemHeight();

+	int sourceY = getHeaderHeight();

+	Rectangle clientArea = getClientArea();	

+

+	if (index >= getTopIndex()) {

+		sourceY += (index-getTopIndex()) * itemHeight;

+	}

+	scroll(

+		0, sourceY + itemHeight, 				// destination x, y

+		0, sourceY,								// source x, y

+		clientArea.width, clientArea.height, true);

+}

+/**

+ * Scroll the items below the item at position 'index' up 

+ * so that they cover the removed item.

+ * @param index - index of the removed item

+ */

+void scrollVerticalRemovedItem(int index) {

+	int itemHeight = getItemHeight();

+	int headerHeight = getHeaderHeight();

+	int destY;

+	Rectangle clientArea = getClientArea();		

+

+	destY = Math.max(headerHeight, headerHeight + (index - getTopIndex()) * itemHeight);

+	scroll(

+		0, destY, 								// destination x, y

+		0, destY + itemHeight,					// source x, y

+		clientArea.width, clientArea.height, true);

+}

+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * If the item at the given zero-relative index in the receiver 
+ * is not selected, it is selected.  If the item at the index
+ * was selected, it remains selected. Indices that are out
+ * of range and duplicate indices are ignored.
+ *
+ * @param indices the array of indices for the items to select
+ *
+ * @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>
+ */

+public void select(int indices[]) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItem item = null;

+	int selectionCount;

+

+	if (indices == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	selectionCount = indices.length;

+	if (isMultiSelect() == false && selectionCount > 1) {

+		selectionCount = 1;

+		deselectAllExcept(getVisibleItem(indices[0]));

+	}

+	for (int i = selectionCount - 1; i >= 0; --i) {

+		item = getVisibleItem(indices[i]);

+		if (item != null) {

+			select(item);

+		}

+	}

+	if (item != null) {

+		setLastSelection(item, false);

+	}

+}

+/**
+ * Selects the item at the given zero-relative index in the receiver. 
+ * If the item at the index was already selected, it remains
+ * selected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to select
+ *
+ * @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 select(int index) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItem item = getVisibleItem(index);

+	

+	if (isMultiSelect() == false) {

+		deselectAllExcept(getVisibleItem(index));

+	}

+	if (item != null) {

+		select(item);

+		setLastSelection(item, false);

+	}

+}

+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * If the item at the index was already selected, it remains
+ * selected. The range of the indices is inclusive. Indices that are
+ * out of range are ignored.
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @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 select(int start, int end) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItem item = null;

+	int selectionCount = 1;

+	

+	if (isMultiSelect() == false) {

+		if (start < 0 && end >= 0) {

+			start = 0;

+		}

+		end = start;

+		deselectAllExcept(getVisibleItem(end));

+	}

+	// select in the same order as all the other selection and deslection methods.

+	// Otherwise setLastSelection repeatedly changes the lastSelectedItem for repeated 

+	// selections of the items, causing flash.

+	for (int i = end; i >= start; i--) {

+		item = getVisibleItem(i);

+		if (item != null) {

+			select(item);

+		}

+	}

+	if (item != null) {

+		setLastSelection(item, false);

+	}

+}

+/**
+ * Selects all the items in the receiver.
+ *
+ * @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 selectAll() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Enumeration items = getItemVector().elements();

+	TableItem item = null;

+

+	if (isMultiSelect() == false) {

+		return;

+	}

+	while (items.hasMoreElements() == true) {

+		item = (TableItem) items.nextElement();

+		select(item);

+	}

+	if (item != null) {

+		setLastSelection(item, false);

+	}

+}

+/**

+ * Set the y position of 'column'.

+ * @param column - the TableColumn that should be set to 

+ *	a new y position.

+ */

+void setColumnPosition(TableColumn column) {

+	Rectangle bounds = column.getBounds();

+

+	bounds.y = getHeaderHeight() - getTopIndex() * getItemHeight();

+	column.setBounds(bounds);	

+}

+/**

+ * Change the cursor of the receiver.

+ * @param isColumnResizeCursor - indicates whether the column 

+ *	resize cursor or the regular cursor should be set.

+ */

+void setColumnResizeCursor(boolean isColumnResizeCursor) {

+	if (isColumnResizeCursor != this.isColumnResizeCursor) {

+		this.isColumnResizeCursor = isColumnResizeCursor;

+		if (isColumnResizeCursor == true) {

+			setCursor(getColumnResizeCursor());

+		}

+		else {

+			setCursor(null);

+		}

+	}

+}

+/**

+ * Set the current position of the resized column to 'xPosition'.

+ * @param xPosition - the current position of the resized column

+ */

+void setColumnResizeX(int xPosition) {

+	columnResizeX = xPosition;

+}

+/**

+ * Set the width of the receiver's contents to 'newWidth'.

+ * Content width is used to calculate the horizontal scrollbar.

+ */

+void setContentWidth(int newWidth) {

+	TableColumn fillColumn = getFillColumn();

+	Rectangle fillColumnBounds;

+	int widthDiff = newWidth - getContentWidth();

+

+	super.setContentWidth(newWidth);

+	if (fillColumn != null) {

+		fillColumnBounds = fillColumn.getBounds();

+		fillColumnBounds.x += widthDiff;

+		fillColumnBounds.width = Math.max(0, getClientArea().width - newWidth);

+		fillColumn.setBounds(fillColumnBounds);

+	}

+}

+/**

+ * Set the width of the first column to fit 'item' if it is longer than 

+ * the current column width.

+ * Do nothing if the user has already set a width.

+ */

+void setFirstColumnWidth(TableItem item) {

+	int newWidth;

+	TableColumn column;

+

+	if (internalGetColumnCount() > 0) {

+		column = internalGetColumn(TableColumn.FIRST);		

+		if (column.isDefaultWidth() == true) {

+			newWidth = Math.max(column.getWidth(), item.getPreferredWidth(TableColumn.FIRST));

+			column.setWidth(newWidth);

+			column.setDefaultWidth(true);					// reset to true so that we know when the user has set 

+															// the width instead of us setting a default width.

+		}

+	}

+}

+public void setFont(Font font) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	SelectableItem item;

+	int itemCount = getItemCount();

+

+	if (font == null || font.equals(getFont()) == true) {

+		return;

+	}

+	setRedraw(false);						// disable redraw because itemChanged() triggers undesired redraw	

+	resetItemData();	

+	super.setFont(font);

+	for (int i = 0; i < itemCount; i++) {

+		itemChanged(getItem(i), 0, getClientArea().width);

+	}

+	setRedraw(true);						// re-enable redraw

+	getHeader().setFont(font);

+}

+/**
+ * Marks the receiver's header as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility 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 void setHeaderVisible(boolean headerVisible) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (headerVisible != getHeaderVisible()) {

+		getHeader().setLocation(0, 0);

+		getHeader().setVisible(headerVisible);

+		// Windows resets scrolling so do we

+		setTopIndex(0, true);

+		moveColumnsVertical();

+		resizeVerticalScrollbar();

+		redraw();

+	}

+}

+/**

+ * Set the vector that stores the items of the receiver 

+ * to 'newVector'.

+ * @param newVector - Vector to use for storing the items of 

+ *	the receiver.

+ */

+void setItemVector(Vector newVector) {

+	items = newVector;

+}

+/**
+ * Marks the receiver's lines as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility 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 void setLinesVisible(boolean drawGridLines) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (this.drawGridLines != drawGridLines) {

+		this.drawGridLines = drawGridLines;

+		redraw();

+	}

+}

+public void setRedraw(boolean redraw) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	super.setRedraw(redraw);

+	getHeader().setRedraw(redraw);

+}

+/**

+ * Set the column that is being resized to 'column'. 

+ * @param column - the TableColumn that is being resized. 

+ * 	A null value indicates that no column resize operation is 

+ *	in progress.

+ */

+void setResizeColumn(TableColumn column) {

+	resizeColumn = column;

+}

+/**
+ * Selects the items at the given zero-relative indices in the receiver. 
+ * The current selected is first cleared, then the new items are selected.
+ *
+ * @param indices the indices of the items to select
+ *
+ * @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 Table#deselectAll()
+ * @see Table#select(int[])
+ */

+public void setSelection(int [] indices) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector keepSelected;

+	

+	if (indices == null)  {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}	

+	keepSelected = new Vector(indices.length);

+	for (int i = 0; i < indices.length; i++) {

+		SelectableItem item = getVisibleItem(indices[i]);

+		if (item != null) {

+			keepSelected.addElement(item);

+		}

+	}

+	deselectAllExcept(keepSelected);

+	select(indices);

+}

+/**
+ * Sets the receiver's selection to be the given array of items.
+ * The current selected is first cleared, then the new items are
+ * selected.
+ *
+ * @param items the array of items
+ *
+ * @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 Table#deselectAll()
+ * @see Table#select(int)
+ */

+public void setSelection(TableItem selectionItems[]) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (selectionItems == null)  {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}	

+	setSelectableSelection(selectionItems);

+}

+/**
+ * Selects the item at the given zero-relative index in the receiver. 
+ * The current selected is first cleared, then the new item is selected.
+ *
+ * @param index the index of the item to select
+ *
+ * @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 Table#deselectAll()
+ * @see Table#select(int)
+ */

+public void setSelection(int index) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	deselectAllExcept(getVisibleItem(index));

+	select(index);

+}

+/**
+ * Selects the items at the given zero-relative indices in the receiver. 
+ * The current selected if first cleared, then the new items are selected.
+ *
+ * @param start the start index of the items to select
+ * @param end the end index of the items to select
+ *
+ * @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 Table#deselectAll()
+ * @see Table#select(int,int)
+ */

+public void setSelection(int start, int end) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector keepSelected = new Vector(end - start + 1);

+	

+	for (int i = start; i <= end; i++) {

+		SelectableItem item = getVisibleItem(i);

+		if (item != null) {

+			keepSelected.addElement(item);

+		}

+	}	

+	deselectAllExcept(keepSelected);

+	select(start, end);

+}

+/**
+ * Sets the zero-relative index of the item which is currently
+ * at the top of the receiver. This index can change when items
+ * are scrolled or new items are added and removed.
+ *
+ * @param index the index of the top item
+ *
+ * @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 setTopIndex(int index) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	int itemCount = getItemCount();

+	int itemCountWhole = getItemCountWhole();

+	

+	if (index < 0 || itemCount == 0) {

+		return;

+	}

+	if (index >= itemCount) {

+		index = itemCount - itemCountWhole;

+	}

+	super.setTopIndex(index, true);

+}

+/**

+ * Set the index of the first visible item in the receiver's client 

+ * area to 'index'.

+ * @param index - 0-based index of the first visible item in the 

+ *	receiver's client area.

+ * @param adjustScrollbar - true=set the position of the vertical 

+ *	scroll bar to the new top index. 

+ *	false=don't adjust the vertical scroll bar

+ */

+void setTopIndexNoScroll(int index, boolean adjustScrollbar) {

+	super.setTopIndexNoScroll(index, adjustScrollbar);

+	moveColumnsVertical();

+}

+/**
+ * Shows the item.  If the item is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled until
+ * the item is visible.
+ *
+ * @param item the item to be shown
+ *
+ * @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 Table#showSelection()
+ */

+public void showItem(TableItem item) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (item == null)  {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}	

+	showSelectableItem(item);

+}

+/**
+ * Shows the selection.  If the selection is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled until
+ * the selection is visible.
+ *
+ * @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 Table#showItem(TableItem)
+ */

+public void showSelection() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	super.showSelection();

+}

+void sort (int [] items) {

+	/* Shell Sort from K&R, pg 108 */

+	int length = items.length;

+	for (int gap=length/2; gap>0; gap/=2) {

+		for (int i=gap; i<length; i++) {

+			for (int j=i-gap; j>=0; j-=gap) {

+		   		if (items [j] <= items [j + gap]) {

+					int swap = items [j];

+					items [j] = items [j + gap];

+					items [j + gap] = swap;

+		   		}

+	    	}

+	    }

+	}

+}

+/**

+ * Start a column resize operation.

+ * @param event - the mouse event that occured over the header 

+ * 	widget

+ */

+void startColumnResize(Event event) {

+	Vector columns = internalGetColumnVector();

+	TableColumn hitColumn = getColumnAtX(event.x);

+	Rectangle hitColumnBounds;

+	int hitIndex = hitColumn.getIndex();

+

+	if (hitColumn == getFillColumn()) {										// clicked on the fill column?

+		hitColumn = (TableColumn) columns.lastElement();					// resize the last real column

+	}

+	else 

+	if ((event.x - hitColumn.getBounds().x <= COLUMN_RESIZE_OFFSET) && 		// check if left side of a column was clicked

+		(hitIndex > 0)) {													

+		hitColumn = (TableColumn) columns.elementAt(hitIndex - 1);			// resize the preceding column

+	}

+	hitColumnBounds = hitColumn.getBounds();

+	setColumnResizeX(hitColumnBounds.x + hitColumnBounds.width);

+	setResizeColumn(hitColumn);

+}

+/**

+ * Return 'text' after it has been checked to be no longer than 'maxWidth' 

+ * when drawn on 'gc'.

+ * If it is too long it will be truncated up to the last character.

+ * @param text - the String that should be checked for length

+ * @param maxWidth - maximum width of 'text'

+ * @param gc - GC to use for String measurement

+ */

+String trimItemText(String text, int maxWidth, GC gc) {

+	int textWidth;

+	int dotsWidth;

+

+	if (text != null && text.length() > 1) {

+		textWidth = gc.stringExtent(text).x;

+		if (textWidth >= maxWidth) {

+			dotsWidth = getDotsWidth(gc);

+			while (textWidth + dotsWidth >= maxWidth && text.length() > 1) {

+				text = text.substring(0, text.length() - 1);		// chop off one character at the end

+				textWidth = gc.stringExtent(text).x;

+			}

+			text = text.concat(Table.DOT_STRING);

+		}

+	}

+	return text;

+}

+

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableColumn.java
new file mode 100755
index 0000000..dc981d2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableColumn.java
@@ -0,0 +1,495 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+ 

+import org.eclipse.swt.*;

+import org.eclipse.swt.events.*;

+import org.eclipse.swt.graphics.*;

+ 

+/**
+ * Instances of this class represent a column in a table widget.
+ *  <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>LEFT, RIGHT, CENTER</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd> Move, Resize, Selection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */

+public /*final*/ class TableColumn extends Item {

+	static final int FIRST = 0;							// index of the first column

+	static final int FILL = -1;							// index that identifies the column used to 

+														// fill space not used by other columns.

+	private static final int DEFAULT_WIDTH = 10;

+

+	private Table parent;

+	private int index;									// 0-based column index

+	private Rectangle bounds = new Rectangle(0, 0, 0, 0);

+	private boolean isDefaultWidth = true;

+	private boolean resize = true;

+/**

+ * Create a new TableColumn without adding it to the parent.

+ * Currently used to create fill columns and default columns.

+ * @see createFillColumn

+ * @see createDefaultColumn

+ * @param parent - Table widget the new instance will be a child of.

+ */

+TableColumn(Table parent) {

+	super(parent, SWT.NULL);

+	this.parent = parent;		

+}

+/**

+ * Create a new instance of TableColumn and append it to the existing 

+ * columns in 'parent'.

+ * @param parent - Table widget the new instance will be a child of.

+ * @param syle - style of the new TableColumn

+ */

+public TableColumn(Table parent, int style) {

+	this(parent, style, checkNull(parent).getColumnCount());

+}

+/**

+ * Create a new instance of TableColumn at position 'index' in the Table

+ * identified by 'parent'.

+ * @param parent - Table widget the new instance will be a child of.

+ * @param index - position in the 'parent' at which the new instance will

+ *	be located relative to the other columns.

+ * @param syle - style of the new TableColumn

+ */

+public TableColumn(Table parent, int style, int index) {

+	super(parent, checkStyle (style), index);

+	

+	this.parent = parent;

+	if (index < 0 || index > parent.getColumnCount()) {

+		error(SWT.ERROR_INVALID_RANGE);

+	}

+	setIndex(index);	

+	parent.addColumn(this);

+	setWidth(DEFAULT_WIDTH);

+	setDefaultWidth(true);

+	addListener(SWT.Dispose, new Listener() {

+		public void handleEvent(Event event) {disposeColumn();}

+	});

+}

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is moved or resized, by sending
+ * it one of the messages defined in the <code>ControlListener</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 ControlListener
+ * @see #removeControlListener
+ */

+public void addControlListener(ControlListener listener) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

+	TypedListener typedListener = new TypedListener (listener);

+	addListener (SWT.Resize,typedListener);

+	addListener (SWT.Move,typedListener);

+}

+/**

+ * Adds the listener to the collection of listeners who will

+ * be notified when the control is selected, by sending

+ * it one of the messages defined in the <code>SelectionListener</code>

+ * interface.

+ * <p>

+ * <code>widgetSelected</code> is called when the column header is selected.

+ * <code>widgetDefaultSelected</code> is not called.

+ * </p>

+ *

+ * @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 SelectionListener

+ * @see #removeSelectionListener

+ * @see SelectionEvent

+ */

+public void addSelectionListener (SelectionListener listener) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

+	TypedListener typedListener = new TypedListener (listener);

+	addListener (SWT.Selection,typedListener);

+	addListener (SWT.DefaultSelection,typedListener);

+}

+/**

+ * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'table' is null.

+ * Otherwise return 'table'

+ */

+static Table checkNull(Table table) {

+	if (table == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

+	return table;

+}

+static int checkStyle (int style) {

+	return checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);

+}

+protected void checkSubclass () {

+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);

+}

+/**

+ * Create a new instance of TableColumn that acts as a default column

+ * if the user does not create a TableColumn.

+ * @param parent - Table widget the new instance will be a child of.

+ */

+static TableColumn createDefaultColumn(Table parent) {

+	TableColumn defaultColumn = new TableColumn(parent);

+	

+	defaultColumn.setIndex(FIRST);

+	defaultColumn.setWidth(DEFAULT_WIDTH);

+	defaultColumn.setDefaultWidth(true);

+	return defaultColumn;

+}

+/**

+ * Create a new instance of TableColumn that acts as the rightmost 

+ * fill column in a Table. The new object is not added to the parent

+ * like a regular column is.

+ * @param parent - Table widget the new instance will be a child of.

+ */

+static TableColumn createFillColumn(Table parent) {

+	TableColumn fillColumn = new TableColumn(parent);

+	

+	fillColumn.setIndex(FILL);

+	return fillColumn;

+}

+/**

+ * Remove the receiver from its parent

+ */

+void disposeColumn() {

+	getParent().removeColumn(this);

+}

+/**
+ * Returns a value which describes the position of the
+ * text or image in the receiver. The value will be one of
+ * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>.
+ *
+ * @return the alignment 
+ *
+ * @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 getAlignment () {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	if ((style & SWT.LEFT) != 0) return SWT.LEFT;

+	if ((style & SWT.CENTER) != 0) return SWT.CENTER;

+	if ((style & SWT.RIGHT) != 0) return SWT.RIGHT;

+	return SWT.LEFT;

+}

+

+/**

+ * Answer the bounding rectangle of the receiver.

+ */

+Rectangle getBounds() {

+	return new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height);	// copy the object to prevent changes

+}

+public Display getDisplay() {

+	if (parent == null) {		// access parent field directly to prevent endless recursion

+		error(SWT.ERROR_WIDGET_DISPOSED);

+	}

+	return parent.getDisplay();

+}

+/**

+ * Answer the index of the receiver. Specifies the position of the

+ * receiver relative to other columns in the parent.

+ */

+int getIndex() {

+	return index;

+}

+/**
+ * Returns the receiver's parent, which must be a <code>Table</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @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 Table getParent() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return parent;

+}

+/**
+ * Gets the resizable attribute. A column that is
+ * not resizable cannot be dragged by the user but
+ * may be resized by the programmer.
+ *
+ * @return the resizable attribute
+ *
+ * @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 getResizable() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return resize;

+}

+/**
+ * Gets the width of the receiver.
+ *
+ * @return the width
+ *
+ * @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 getWidth () {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return getBounds().width;

+}

+/**

+ * Set the colun bounds.

+ */

+void internalSetBounds(Rectangle newBounds) {

+	bounds = newBounds;

+}

+/**

+ * Answer whether the column has a default width or if a width has been 

+ * set by the user.

+ * @return 

+ *  true=column width is a default width set internally

+ *	false=column width has been set by the user.

+ */

+boolean isDefaultWidth() {

+	return isDefaultWidth;

+}

+/**
+ * Causes the receiver to be resized to its preferred size.
+ * For a composite, this involves computing the preferred size
+ * from its layout, if there is one.
+ *
+ * @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 pack() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Table parent = getParent();

+	int index = parent.indexOf(this);

+

+	if (getIndex() != TableColumn.FILL && index != -1) {

+		setWidth(parent.getPreferredColumnWidth(index));

+	}

+}

+/**

+ * Draw the 'item' at 'yPosition' in the receiver column.

+ * @param item - TableItem that should be drawn.

+ * @param gc - GC to draw on

+ * @param yPosition - y position to draw at in the column.

+ */

+void paint(TableItem item, GC gc, int yPosition) {

+	Rectangle bounds = getBounds();

+	Point paintPosition = new Point(bounds.x, bounds.y + yPosition);

+

+	item.paint(gc, paintPosition, this);

+}

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is moved or resized.
+ *
+ * @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 ControlListener
+ * @see #addControlListener
+ */

+public void removeControlListener (ControlListener listener) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

+	if (eventTable == null) return;

+	eventTable.unhook (SWT.Move, listener);

+	eventTable.unhook (SWT.Resize, listener);

+}

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected.
+ *
+ * @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 SelectionListener
+ * @see #addSelectionListener
+ */

+public void removeSelectionListener(SelectionListener listener) {

+	if (!isValidThread ()) error(SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error(SWT.ERROR_WIDGET_DISPOSED);

+	

+	if (listener == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	removeListener(SWT.Selection, listener);

+	removeListener(SWT.DefaultSelection, listener);

+}

+/**
+ * Controls how text and images will be displayed in the receiver.
+ * The argument should be one of <code>LEFT</code>, <code>RIGHT</code>
+ * or <code>CENTER</code>.
+ *
+ * @param alignment the new alignment 
+ *
+ * @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 setAlignment(int alignment) {

+	if (!isValidThread ()) error(SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error(SWT.ERROR_WIDGET_DISPOSED);

+	int index = getIndex();

+	

+	if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) != 0 && index != 0) { // ignore calls for the first column to match Windows behavior

+		style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);

+		style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);

+		getParent().getHeader().redraw(index);	

+	}

+}

+/**

+ * Set the bounding rectangle of the receiver to 'newBounds'.

+ * Notify the table widget if the column width changes.

+ * @param newBounds - the new bounding rectangle of the receiver,

+ *	consisting of x, y, width, height

+ */

+void setBounds(Rectangle newBounds) {

+	if (newBounds.width != bounds.width) {

+		if (isDefaultWidth() == true) {

+			setDefaultWidth(false);

+		}

+		getParent().columnChange(this, newBounds);

+	}

+	else {

+		// columnChange causes update (via scroll) which may flush redraw 

+		// based on old bounds. Setting bounds after notifying table fixes 1GABZR5

+		// Table sets column bounds at appropriate time when called above with 

+		// width change. Only set bounds when table was not called. Fixes 1GCGDPB

+		bounds = newBounds;

+	}

+}

+/**

+ * Set whether the column has a default width or if a width has been 

+ * set by the user.

+ * @param isDefaultWidth

+ *	true=column width is a default width set internally

+ *	false=column width has been set by the user

+ */

+void setDefaultWidth(boolean isDefaultWidth) {

+	this.isDefaultWidth = isDefaultWidth;

+}

+/**

+ * Set the index of the receiver to 'newIndex'. The index specifies the

+ * position of the receiver relative to other columns in the parent.

+ */

+void setIndex(int newIndex) {

+	this.index = newIndex;

+}

+/**
+ * Sets the resizable attribute.  A column that is
+ * not resizable cannot be dragged by the user but
+ * may be resized by the programmer.
+ *
+ * @param resizable the resize attribute
+ *
+ * @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 setResizable(boolean resize) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	this.resize = resize;

+}

+public void setText(String newText) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	int index = getIndex();

+	

+	if (newText == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	if (index != FILL && (text == null || text.equals(newText) == false)) {

+		super.setText(newText);

+		getParent().getHeader().redraw(index);

+	}	

+}

+/**
+ * Sets the width of the receiver.
+ *
+ * @param width the new width
+ *
+ * @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 setWidth(int width) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Table parent = getParent();

+	Rectangle bounds = getBounds();

+	int oldWidth = bounds.width;

+	int redrawX;

+

+	if (width != oldWidth) {

+		redrawX = bounds.x;

+		bounds.width = width;

+		setBounds(bounds);

+		// redraw at old column position if column was resized wider.

+		// fixes focus rectangle. 

+		redrawX += Math.min(width, oldWidth);

+		parent.redraw(																

+			redrawX - 2, 0, 

+			2, parent.getClientArea().height, false);	// redraw 2 pixels wide to redraw item focus rectangle and grid line

+	}

+}

+}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableItem.java
new file mode 100755
index 0000000..6da0ba3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableItem.java
@@ -0,0 +1,1074 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+ 

+import org.eclipse.swt.*;

+import org.eclipse.swt.graphics.*;

+import java.util.*;

+

+/**

+ * Instances of this class represent a selectable user interface object

+ * that represents an item in a table.

+ * <dl>

+ * <dt><b>Styles:</b></dt>

+ * <dd>(none)</dd>

+ * <dt><b>Events:</b></dt>

+ * <dd>(none)</dd>

+ * </dl>

+ * <p>

+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.

+ * </p>

+ */

+public /*final*/ class TableItem extends SelectableItem {

+	private static final int FIRST_COLUMN_IMAGE_INDENT = 2;	// Space in front of image - first column only

+	private static final int FIRST_COLUMN_TEXT_INDENT = 4;	// Space in front of text - first column only	

+	private static final int TEXT_INDENT_NO_IMAGE = 2;		// Space in front of item text when no item in the column has an image - first column only

+	private static final int TEXT_INDENT = 6;				// Space in front of item text - all other columns

+	private static final int SELECTION_PADDING = 6;			// Space behind text in a selected item

+

+	private Vector dataLabels = new Vector();				// Original text set by the user. Items that don't 

+															// have a label are represented by a null slot

+	private String[] trimmedLabels = new String[0];			// Text that is actually displayed, may be trimmed 

+															// to fit the column

+	private Vector images = new Vector();					// Item images. Items that don't have an image 

+															// are represented by a null slot

+	private Point selectionExtent;							// Size of the rectangle drawn to indicate a 

+															// selected item.

+	private int imageIndent = 0;							// the factor by which the item image and check box, if any, 

+															// are indented. The multiplier is the image width.

+	private int index;										// index of the item in the parent widget

+/**

+ * Create a table item in the table widget 'parent'. Append the new 

+ * item to the existing items in 'parent'.

+ * @param parent - table widget the new item is added to.

+ * @param style - widget style. See Widget class for details

+ */

+public TableItem(Table parent, int style) {

+	this(parent, style, checkNull(parent).getItemCount());

+}

+/**

+ * Create a table item in the table widget 'parent'. Add the new 

+ * item at position 'index' to the existing items in 'parent'.

+ * @param parent - table widget the new item is added to.

+ * @param style - widget style. See Widget class for details

+ * @param index - position the new item is inserted at in 'parent'

+ */

+public TableItem(Table parent, int style, int index) {

+	super(parent, style);

+	parent.addItem(this, index);

+}

+/**

+ * Calculate the size of the rectangle drawn to indicate a selected 

+ * item. This is also used to draw the selection focus rectangle. 

+ * The selection extent is calculated for the first column only (the 

+ * only column the selection is drawn in).

+ */

+void calculateSelectionExtent() {

+	Table parent = getParent();

+	TableColumn column = parent.internalGetColumn(TableColumn.FIRST);

+	GC gc = new GC(parent);	

+	String trimmedText = getText(gc, column);

+	int gridLineWidth = parent.getGridLineWidth();

+	

+	if (trimmedText != null) {

+		selectionExtent = new Point(gc.stringExtent(trimmedText).x, parent.getItemHeight());

+		selectionExtent.x += getTextIndent(TableColumn.FIRST) + SELECTION_PADDING;

+		selectionExtent.x = Math.min(

+			selectionExtent.x, column.getWidth() - getImageStopX(column.getIndex()) - gridLineWidth);

+		if (parent.getLinesVisible() == true) {

+			selectionExtent.y -= gridLineWidth;

+		}

+	}

+	gc.dispose();

+}

+/**

+ * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'table' is null.

+ * Otherwise return 'table'

+ */

+static Table checkNull(Table table) {

+	if (table == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

+	return table;

+}

+protected void checkSubclass () {

+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);

+}

+public void dispose() {

+	if (!isValidWidget ()) return;

+	Table parent = getParent();

+	parent.removeItem(this);

+	super.dispose();

+}

+void doDispose() {

+	dataLabels = null;

+	trimmedLabels = null;

+	images = null;

+	selectionExtent = null;

+	super.doDispose();

+}

+

+/**

+ * Draw the image of the receiver for column 'index' at

+ * 'destinationPosition' using 'gc'.

+ * Stretch/shrink the image to the fixed image size of the receiver's 

+ * parent.

+ * @param gc - GC to draw on. 

+ * @param destinationPosition - position on the GC to draw at.

+ * @param index - index of the image to draw

+ * @return Answer the position where drawing stopped.

+ */

+Point drawImage(GC gc, Point destinationPosition, int index) {

+	Table parent = getParent();

+	Image image = getImage(index);

+	Rectangle sourceImageBounds;

+	Point destinationImageExtent = parent.getImageExtent();

+	

+	if (image != null) {

+		sourceImageBounds = image.getBounds();

+		// full row select would obscure transparent images in all but the first column

+		// so always clear the image area in this case. Fixes 1FYNITC

+		if ((parent.getStyle() & SWT.FULL_SELECTION) != 0 && index != TableColumn.FIRST) {

+			gc.fillRectangle(

+				destinationPosition.x, destinationPosition.y,			

+				destinationImageExtent.x, destinationImageExtent.y);

+		}

+		gc.drawImage(

+			image, 0, 0, 													// source x, y

+			sourceImageBounds.width, sourceImageBounds.height, 				// source width, height

+			destinationPosition.x, destinationPosition.y,					// destination x, y

+			destinationImageExtent.x, destinationImageExtent.y);			// destination width, height

+	}

+	if (((index == TableColumn.FIRST &&										// always add the image width for the first column 

+ 	 	  parent.hasFirstColumnImage() == true) ||							// if any item in the first column has an image

+		 (index != TableColumn.FIRST && 									// add the image width if it's not the first column

+		  image != null)) &&										 		// only when the item actually has an image

+		destinationImageExtent != null) {									

+		destinationPosition.x += destinationImageExtent.x;

+	}

+	return destinationPosition;

+}

+/**

+ * Draw the label of the receiver for column 'index' at 'position'

+ * using 'gc'. 

+ * The background color is set to the selection background color if 

+ * the item is selected and the text is drawn for the first column.

+ * @param gc - GC to draw on. 

+ * @param position - position on the GC to draw at.

+ * @param index - specifies which subitem text to draw

+ */

+void drawText(String label, GC gc, Point position, int index) {

+	Table parent = getParent();

+	boolean drawSelection;

+	int textOffset;

+	int textHeight;

+		

+	if (label != null) {

+		drawSelection = (index == TableColumn.FIRST || (parent.getStyle() & SWT.FULL_SELECTION) != 0);

+		if (isSelected() == true && drawSelection == true) {

+			gc.setBackground(getSelectionBackgroundColor());

+			gc.setForeground(getSelectionForegroundColor());

+		}

+		textHeight = gc.stringExtent(label).y;

+		textOffset = (parent.getItemHeight() - textHeight) / 2;			// vertically center the text

+		gc.drawString(label, position.x, position.y + textOffset);

+		if (isSelected() == true && drawSelection == true) {

+			gc.setBackground(parent.getBackground());

+			gc.setForeground(parent.getForeground());

+		}

+	}

+}

+

+/**

+ * 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) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Rectangle itemBounds;

+	Rectangle columnBounds;

+	Rectangle checkboxBounds;

+	Table parent = getParent();

+	TableColumn column;

+	int itemIndex = parent.indexOf(this);

+	int itemHeight = parent.getItemHeight();

+	int gridLineWidth = parent.getGridLineWidth();

+	int itemYPos;

+	

+	if (itemIndex == -1 || index < 0 || index >= parent.internalGetColumnCount()) {

+		itemBounds = new Rectangle(0, 0, 0, 0);

+	}

+	else {

+		column = parent.internalGetColumn(index);

+		columnBounds = column.getBounds();

+		itemYPos = columnBounds.y + itemHeight * itemIndex;

+		itemBounds = new Rectangle(

+			columnBounds.x, itemYPos, 

+			columnBounds.width - gridLineWidth, itemHeight - gridLineWidth);

+		if (index == TableColumn.FIRST) {

+			if (isCheckable() == true) {

+				checkboxBounds = getCheckboxBounds();

+				itemBounds.x += checkboxBounds.x + checkboxBounds.width + CHECKBOX_PADDING;	// add checkbox start, width and space behind checkbox

+				itemBounds.width -= itemBounds.x;

+			}

+			else {

+				itemBounds.x += getImageIndentPixel();

+			}

+		}

+	}

+	return itemBounds;

+}

+/**

+ * 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() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return super.getChecked();

+}

+/**

+ * Answer the x position of the item check box

+ */

+int getCheckboxXPosition() {

+	return getImageIndentPixel();

+}

+/**

+ * Answer the item labels set by the user.

+ * These may not be the same as those drawn on the screen. The latter 

+ * may be trimmed to fit the column. Items that don't have a label are 

+ * represented by a null slot in the vector.

+ * @return Vector - the item labels set by the user.

+ */

+Vector getDataLabels() {

+	return dataLabels;

+}

+public Display getDisplay() {

+	return super.getDisplay();

+}

+/**

+ * Return the position at which the string starts that is used 

+ * to indicate a truncated item text.

+ * @param columnIndex - index of the column for which the position of 

+ *	the truncation replacement should be calculated

+ * @param columnWidth - width of the column for which the position of 

+ *	the truncation replacement should be calculated

+ * @return -1 when the item text is not truncated

+ */

+int getDotStartX(int columnIndex, int columnWidth) {

+	GC gc;

+	Table parent = getParent();

+	String label = getText(columnIndex);

+	int dotStartX = -1;

+	int maxWidth;

+

+	if (label != null) {

+		gc = new GC(parent);

+		maxWidth = getMaxTextWidth(columnIndex, columnWidth);

+		label = parent.trimItemText(label, maxWidth, gc);

+		if (label.endsWith(Table.DOT_STRING) == true) {

+			dotStartX = gc.stringExtent(label).x - parent.getDotsWidth(gc);

+			// add indents, margins and image width

+			dotStartX += getImageStopX(columnIndex);

+			dotStartX += getTextIndent(columnIndex);

+		}

+		gc.dispose();		

+	}

+	return dotStartX;

+}

+/**

+ * Returns <code>true</code> if the receiver is grayed,

+ * and false otherwise. When the parent does not have

+ * the <code>CHECK style, return false.

+ *

+ * @return the grayed 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 getGrayed() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return super.getGrayed();

+}

+public Image getImage() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return getImage(0);

+}

+/**

+ * Returns the item image of the column identified by 'columnIndex' or 

+ * null if no image has been set for that column.

+ * 

+ * @param columnIndex - the column whose image should be returned

+ * @return the item image

+ */

+public Image getImage(int columnIndex) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Image image = null;

+	Vector images = getImages();

+	int itemIndex = getParent().indexOf(this);

+	

+	if (itemIndex != -1 && columnIndex >= 0 && columnIndex < images.size()) {

+		image = (Image) images.elementAt(columnIndex);

+	}

+	return image;

+}

+/**

+ * Returns a rectangle describing the size and location

+ * relative to its parent of an image at a column in the

+ * table.

+ *

+ * @param index the index that specifies the column

+ * @return the receiver's bounding image 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 getImageBounds(int index) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Table parent = getParent();

+	int itemIndex = parent.indexOf (this);

+	int imageWidth = 0;

+	Point imageExtent = parent.getImageExtent();

+	Rectangle checkboxBounds;

+	Rectangle imageBounds = getBounds(index);

+	

+	if (itemIndex == -1) {

+		imageBounds = new Rectangle(0, 0, 0, 0);

+	}

+	else

+	if (imageExtent != null) {

+		if (index == TableColumn.FIRST || getImage(index) != null) {

+			imageWidth = imageExtent.x;

+		}

+	}

+	imageBounds.width = imageWidth;

+	return imageBounds;

+}

+/**

+ * Gets the image indent.

+ *

+ * @return the indent

+ *

+ * @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 getImageIndent() {

+	if (isValidThread() == false) error(SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (isValidWidget() == false) error(SWT.ERROR_WIDGET_DISPOSED);

+	int index = getParent().indexOf(this);

+	

+	if (index == -1) {

+		return 0;

+	}

+	return imageIndent;

+}

+/**

+ * Answer the number of pixels the image in the first column is 

+ * indented. Calculation starts at the column start and counts 

+ * all pixels except the check box.

+ */

+int getImageIndentPixel() {

+	int indentPixel = FIRST_COLUMN_IMAGE_INDENT;

+	Point imageExtent = getParent().getImageExtent();

+	

+	if (imageExtent != null) {

+		indentPixel += imageExtent.x * getImageIndent();

+	}

+	return indentPixel;

+}

+/**

+ * Answer the item images set by the user. Items that don't have an 

+ * image are represented by a null slot in the vector.

+ */

+Vector getImages() {

+	return images;

+}

+/**

+ * Calculate the x coordinate where the item image of column 

+ * 'columnIndex' stops.

+ * @param columnIndex - the column for which the stop position of the 

+ *	image should be calculated.

+ */

+int getImageStopX(int columnIndex) {

+	int imageStopX = 0;

+	Table parent = getParent();

+	Rectangle checkboxBounds;

+

+	if (columnIndex == TableColumn.FIRST) {

+		if (isCheckable() == true) {

+			checkboxBounds = getCheckboxBounds();

+			imageStopX += checkboxBounds.x + checkboxBounds.width + CHECKBOX_PADDING;

+		}

+		else {

+			imageStopX = getImageIndentPixel();

+		}

+	}

+	if (((columnIndex == TableColumn.FIRST &&				// always add the image width for the first column 

+ 	 	  parent.hasFirstColumnImage() == true) ||			// if any item in the first column has an image

+		 (columnIndex != TableColumn.FIRST && 				// add the image width if it's not the first column

+		  getImage(columnIndex) != null)) &&		 		// only when the item actually has an image

+		parent.getImageExtent() != null) {									

+		imageStopX += parent.getImageExtent().x;

+	}

+	return imageStopX;

+}

+/**

+ * Return the index of the item in its parent widget.

+ */

+int getIndex() {

+	return index;

+}

+/**

+ * Return the item extent in the specified column

+ * The extent includes the actual width of the item including checkbox, 

+ * image and text.

+ */

+Point getItemExtent(TableColumn column) {

+	Table parent = getParent();

+	int columnIndex = column.getIndex();

+	Point extent = new Point(getImageStopX(columnIndex), parent.getItemHeight() - parent.getGridLineWidth());

+	GC gc = new GC(parent);	

+	String trimmedText = getText(gc, column);

+

+	if (trimmedText != null && trimmedText.length() > 0) {

+		extent.x += gc.stringExtent(trimmedText).x + getTextIndent(columnIndex);

+	}

+	if (columnIndex == TableColumn.FIRST) {

+		extent.x += SELECTION_PADDING;

+	}

+	gc.dispose();		

+	return extent;

+}

+/**

+ * Answer the maximum width in pixel of the text that fits in the 

+ * column identified by 'columnIndex' without trimming the text.

+ * @param columnIndex - the column for which the maximum text width

+ *	should be calculated.

+ * @param columnWidth - width of the column 'columnIndex'

+ */

+int getMaxTextWidth(int columnIndex, int columnWidth) {

+	int itemWidth = getImageStopX(columnIndex) + getTextIndent(columnIndex) * 2;

+

+	return columnWidth - itemWidth;

+}

+/**

+ * Returns the receiver's parent, which must be a <code>Table</code>.

+ *

+ * @return the receiver's parent

+ *

+ * @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 Table getParent() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return (Table) super.getSelectableParent();

+}

+/**

+ * Answer the width of the item required to display the complete contents.

+ */

+int getPreferredWidth(int index) {

+	int size = getImageStopX(index);

+	String text = getText(index);

+

+	if (text != null) {

+		size += getParent().getTextWidth(text) + getTextIndent(index) * 2 + 1;

+	}

+	return size;

+}

+/**

+ * Return the size of the rectangle drawn to indicate a selected item.

+ * This is also used to draw the selection focus rectangle and drop 

+ * insert marker. 

+ * Implements SelectableItem#getSelectionExtent

+ */

+Point getSelectionExtent() {

+	Table parent = getParent();

+	Point extent;

+	

+	if ((parent.getStyle() & SWT.FULL_SELECTION) == 0) {			// regular, first column, selection?

+		if (selectionExtent == null) {

+			calculateSelectionExtent();

+		}

+		extent = selectionExtent;

+	}

+	else {

+		extent = parent.getFullSelectionExtent(this);

+	}

+	return extent;

+}

+/**

+ * Return the x position of the selection rectangle

+ * Implements SelectableItem#getSelectionX

+ */

+int getSelectionX() {

+	return getImageStopX(TableColumn.FIRST) + getParent().getHorizontalOffset();

+}

+public String getText() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return getText(0);

+}

+/**

+ * Returns the item tezt of the column identified by 'columnIndex',

+ * or null if no text has been set for that column.

+ * 

+ * @param columnIndex - the column whose text should be returned

+ *	@return the item text or null if no text has been set for that column.

+ */

+public String getText(int columnIndex) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	int itemIndex = getParent().indexOf(this);

+	Vector labels = getDataLabels();

+	String label = null;

+	

+	if (itemIndex == -1) {

+		error(SWT.ERROR_CANNOT_GET_TEXT);

+	}	

+	if (columnIndex >= 0 && columnIndex < labels.size()) {

+		label = (String) labels.elementAt(columnIndex);

+	}

+	if (label == null) {

+		label = "";			// label vector is initialized with null instead of empty Strings

+	}

+	return label;

+}

+/**

+ * Answer the text that is going to be drawn in 'column'. This 

+ * text may be a trimmed copy of the original text set by the 

+ * user if it doesn't fit into the column. In that case the last 

+ * characters are replaced with Table.DOT_STRING.

+ * A cached copy of the trimmed text is returned if available.

+ * @param gc - GC to use for measuring the text extent

+ * @param column - TableColumn for which the text should be returned

+ */

+String getText(GC gc, TableColumn column) {

+	int columnIndex = column.getIndex();

+	String label = getTrimmedText(columnIndex);

+	int maxWidth;

+

+	if (label == null) {

+		maxWidth = getMaxTextWidth(columnIndex, column.getWidth());

+		label = getParent().trimItemText(getText(columnIndex), maxWidth, gc);

+	}

+	return label;

+}

+/**

+ * Answer the indent of the text in column 'columnIndex' in pixel.

+ * This indent is used in front of and behind the item text.

+ * @param columnIndex - specifies the column for which the indent 

+ *	should be calculated.

+ */

+int getTextIndent(int columnIndex) {

+	int textIndent;

+

+	if (columnIndex == TableColumn.FIRST) {

+		if (getParent().hasFirstColumnImage() == false) {

+			textIndent = TEXT_INDENT_NO_IMAGE;

+		}

+		else {

+			textIndent = FIRST_COLUMN_TEXT_INDENT;

+		}

+	}

+	else {

+		textIndent = TEXT_INDENT;

+	}

+	return textIndent;

+}

+/**

+ * Answer the cached trimmed text for column 'columnIndex'. 

+ * Answer null if it hasn't been calculated yet.

+ * @param columnIndex - specifies the column for which the 

+ *	trimmed text should be answered.

+ */

+String getTrimmedText(int columnIndex) {

+	String label = null;

+	String labels[] = getTrimmedTexts();

+

+	if (columnIndex < labels.length) {

+		label = labels[columnIndex];

+	}

+	return label;

+}

+/**

+ * Answer an array of cached trimmed labels.

+ */

+String [] getTrimmedTexts() {

+	return trimmedLabels;

+}

+/**

+ * Ensure that the image and label vectors have at least 

+ * 'newSize' number of elements.

+ */

+void growVectors(int newSize) {

+	Vector images = getImages();

+	Vector labels = getDataLabels();

+

+	if (newSize > images.size()){

+		images.setSize(newSize);

+	}

+	if (newSize > labels.size()){

+		labels.setSize(newSize);

+	}

+}

+/**

+ * Insert 'column' into the receiver.

+ */

+void insertColumn(TableColumn column) {	

+	Vector data = getDataLabels();

+	Vector images = getImages();

+	String stringData[];

+	Image imageData[];

+	int index = column.getIndex();

+

+	if (index < data.size()) {

+		data.insertElementAt(null, index);

+	}

+	else {

+		data.addElement(null);

+	}

+	stringData = new String[data.size()];

+	data.copyInto(stringData);

+	setText(stringData);

+

+	if (index < images.size()) {	

+		images.insertElementAt(null, index);

+	}

+	else {

+		images.addElement(null);

+	}

+	imageData = new Image[images.size()];

+	images.copyInto(imageData);

+	setImage(imageData);

+}

+/**

+ * Sets the image at an index.

+ *

+ * @param image the new image (or null)

+ *

+ * @exception SWTError(ERROR_THREAD_INVALID_ACCESS)

+ *	when called from the wrong thread

+ * @exception SWTError(ERROR_WIDGET_DISPOSED)

+ *	when the widget has been disposed

+ */

+void internalSetImage(int columnIndex, Image image) {

+	Vector images = getImages();

+	boolean imageWasNull = false;

+	Table parent = getParent();		

+	

+	if (columnIndex >= 0 && 

+		columnIndex < parent.internalGetColumnCount()) {

+		if (columnIndex >= images.size()) {

+			growVectors(columnIndex + 1);

+		}

+		if (((Image) images.elementAt(columnIndex)) == null && image != null) {

+			imageWasNull = true;

+		}

+		images.setElementAt(image, columnIndex);

+		reset(columnIndex);						// new image may cause text to no longer fit in the column

+		notifyImageChanged(columnIndex, imageWasNull);

+	}

+}

+/**

+* Sets the widget text.

+*

+* The widget text for an item is the label of the

+* item or the label of the text specified by a column

+* number.

+*

+* @param index the column number

+* @param text the new text

+*

+*/

+void internalSetText(int columnIndex, String string) {

+	Vector labels = getDataLabels();

+	Table parent = getParent();

+	String oldText;

+	

+	if (columnIndex >= 0 &&

+		columnIndex < parent.internalGetColumnCount()) {

+		if (columnIndex >= labels.size()) {

+			growVectors(columnIndex + 1);

+		}

+		oldText = (String) labels.elementAt(columnIndex);

+		if (string.equals(oldText) == false) {

+			labels.setElementAt(string, columnIndex);

+			reset(columnIndex);

+			notifyTextChanged(columnIndex, oldText == null);

+		}

+	}

+}

+/**

+ * Answer whether the click at 'xPosition' on the receiver is a 

+ * selection click.

+ * A selection click occurred when the click was behind the image

+ * and before the end of the item text.

+ * @return 

+ *	true - 'xPosition' is a selection click.

+ *	false - otherwise

+ */

+boolean isSelectionHit(int xPosition) {

+	int itemStopX = getImageStopX(TableColumn.FIRST);

+	Point selectionExtent = getSelectionExtent();

+

+	if (selectionExtent != null) {

+		itemStopX += selectionExtent.x;

+	}

+	return (xPosition > getCheckboxBounds().x + getCheckboxBounds().width) && (xPosition <= itemStopX);

+}

+/** 

+ * The image for the column identified by 'columnIndex' has changed.

+ * Notify the parent widget and supply redraw coordinates, if possible.

+ * @param columnIndex - index of the column that has a new image.

+ */

+void notifyImageChanged(int columnIndex, boolean imageWasNull) {	

+	Table parent = getParent();

+	Rectangle changedColumnBounds;

+	int redrawStartX = 0;

+	int redrawWidth = 0;

+	int columnCount = parent.internalGetColumnCount();	

+

+	if (columnIndex >= 0 && columnIndex < columnCount && parent.getVisibleRedrawY(this) != -1) {

+		changedColumnBounds = parent.internalGetColumn(columnIndex).getBounds();

+		redrawStartX = Math.max(0, getImageBounds(columnIndex).x);

+		if (parent.getImageExtent() != null && imageWasNull == false) {

+			redrawWidth = getImageStopX(columnIndex);

+		}

+		else {

+			redrawWidth = changedColumnBounds.width;

+		}

+		redrawWidth += changedColumnBounds.x - redrawStartX;

+	}

+	parent.itemChanged(this, redrawStartX, redrawWidth);

+}

+

+/**

+ * The label for the column identified by 'columnIndex' has changed.

+ * Notify the parent widget and supply redraw coordinates, if possible.

+ * @param columnIndex - index of the column that has a new label.

+ */

+void notifyTextChanged(int columnIndex, boolean textWasNull) {	

+	Table parent = getParent();

+	String text;

+	Rectangle columnBounds;

+	int redrawStartX = 0;

+	int redrawWidth = 0;

+	int columnCount = parent.internalGetColumnCount();

+

+	if (columnIndex >= 0 && columnIndex < columnCount && parent.getVisibleRedrawY(this) != -1) {

+		text = (String) getDataLabels().elementAt(columnIndex);

+		columnBounds = parent.internalGetColumn(columnIndex).getBounds();

+		redrawStartX = columnBounds.x;

+		if (getImage(columnIndex) != null) {

+			redrawStartX += getImageStopX(columnIndex);

+		}

+		redrawStartX = Math.max(0, redrawStartX);

+		// don't redraw if text changed from null to empty string

+		if (textWasNull == false || text.length() > 0) {

+			redrawWidth = columnBounds.x + columnBounds.width - redrawStartX;

+		}

+	}

+	parent.itemChanged(this, redrawStartX, redrawWidth);

+}

+/**

+ * Draw the receiver at 'paintPosition' in the column identified by 

+ * 'columnIndex' using 'gc'.

+ * @param gc - GC to use for drawing

+ * @param paintPosition - position where the receiver should be drawing.

+ * @param column - the column to draw in

+ */

+void paint(GC gc, Point paintPosition, TableColumn column) {

+	int columnIndex = column.getIndex();

+	String label = getText(gc, column);

+	String oldLabel = getTrimmedText(columnIndex);

+

+	if (label != null && label.equals(oldLabel) == false) {

+		setTrimmedText(label, columnIndex);

+		selectionExtent = null;		// force a recalculation next time the selection extent is needed

+	}

+	if (columnIndex == TableColumn.FIRST) {

+		paintPosition.x += getImageIndentPixel();

+		if (isCheckable() == true) {

+			paintPosition = drawCheckbox(gc, paintPosition);

+		}		

+	}

+	paintPosition = drawImage(gc, paintPosition, columnIndex);

+	paintPosition.x += getTextIndent(columnIndex);

+	drawText(label, gc, paintPosition, columnIndex);

+}

+/**

+ * Remove 'column' from the receiver.

+ */

+void removeColumn(TableColumn column) {

+	Vector data = getDataLabels();

+	Vector images = getImages();

+	String stringData[];

+	Image imageData[];

+	int index = column.getIndex();

+

+	if (index < data.size()) {

+		data.removeElementAt(index);

+		stringData = new String[data.size()];

+		data.copyInto(stringData);

+		setText(stringData);

+	}

+	if (index < images.size()) {

+		images.removeElementAt(index);

+		imageData = new Image[images.size()];

+		images.copyInto(imageData);

+		setImage(imageData);

+	}

+}

+/**

+ * Reset the cached trimmed label for the sub item identified by 

+ * 'index'.

+ * @param index - index of the label that should be reset.

+ */

+void reset(int index) {

+	String trimmedLabels[] = getTrimmedTexts();

+

+	if (index >= 0 && index < trimmedLabels.length) {

+		trimmedLabels[index] = null;

+	}

+	if (index == TableColumn.FIRST) {

+		selectionExtent = null;

+	}

+}

+/**

+ * Sets the image for multiple columns in the Table. 

+ * 

+ * @param strings the array of new images

+ *

+ * @exception IllegalArgumentException <ul>

+ *    <li>ERROR_NULL_ARGUMENT - if the text 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>

+ */

+public void setImage(Image [] images) {

+	if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);

+	

+	if (images == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	if (getParent().indexOf(this) == -1) {	

+		return;

+	}	

+	for (int i = 0; i < images.length; i++) {

+		internalSetImage(i, images[i]);

+	}

+}

+/**

+ * Sets the receiver's image at a column.

+ *

+ * @param index the column index

+ * @param string the new image

+ *

+ * @exception IllegalArgumentException <ul>

+ *    <li>ERROR_NULL_ARGUMENT - if the text 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>

+ */

+public void setImage(int columnIndex, Image image) {

+	if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);

+	

+	if (getParent().indexOf(this) != -1) {

+		internalSetImage(columnIndex, image);

+	}

+}

+public void setImage(Image image) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	setImage(0, image);

+}

+/**

+ * Sets the image indent.

+ *

+ * @param indent the new indent

+ *

+ * </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>

+ */

+public void setImageIndent(int indent) {

+	if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);

+	Table parent = getParent();

+	TableColumn column;

+	int index = parent.indexOf(this);

+

+	if (index != -1 && indent >= 0 && indent != imageIndent) {

+		imageIndent = indent;

+		column = parent.internalGetColumn(TableColumn.FIRST);

+		parent.redraw(

+			0, parent.getRedrawY(this), 

+			column.getWidth(), parent.getItemHeight(), false);

+	}

+}

+/**

+ * Sets the text for multiple columns in the table. 

+ * 

+ * @param strings the array of new strings

+ *

+ * @exception IllegalArgumentException <ul>

+ *    <li>ERROR_NULL_ARGUMENT - if the text 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>

+ */

+public void setText(String [] strings) {

+	if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);

+	

+	if (strings == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	if (getParent().indexOf(this) == -1) {	

+		return;

+	}

+	for (int i = 0; i < strings.length; i++) {

+		String string = strings[i];

+		if (string != null) {

+			internalSetText(i, string);

+		}

+	}

+}

+/**

+ * Sets the receiver's text at a column

+ *

+ * @param index the column index

+ * @param string the new text

+ *

+ * @exception IllegalArgumentException <ul>

+ *    <li>ERROR_NULL_ARGUMENT - if the text 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>

+ */

+public void setText (int columnIndex, String string) {

+	if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);

+	

+	if (string == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	if (getParent().indexOf(this) != -1) {

+		internalSetText(columnIndex, string);

+	}

+}

+public void setText(String text) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (text == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	setText(0, text);

+}

+/**

+ * Set the trimmed text of column 'columnIndex' to label. The trimmed 

+ * text is the one that is displayed in a column. It may be shorter than

+ * the text originally set by the user via setText(...) to fit the 

+ * column.

+ * @param label - the text label of column 'columnIndex'. May be trimmed

+ *	to fit the column.

+ * @param columnIndex - specifies the column whose text label should be 

+ *	set.

+ */

+void setTrimmedText(String label, int columnIndex) {

+	String labels[] = getTrimmedTexts();

+

+	if (columnIndex < labels.length) {

+		labels[columnIndex] = label;

+	}

+}

+/**

+ * Sets the checked state of the receiver.

+ *

+ * @param checked the new 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 void setChecked(boolean checked) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	super.setChecked(checked);

+}

+/**

+ * Sets the grayed state of the receiver.

+ *

+ * @param checked the new grayed 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 void setGrayed (boolean grayed) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	super.setGrayed(grayed);

+}

+/**

+ * Set the index of this item in its parent widget to 'newIndex'.

+ */

+void setIndex(int newIndex) {

+	index = newIndex;

+}

+

+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java
index 3e4899e..d14ced4 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java
@@ -43,7 +43,8 @@
 	return style | SWT.SINGLE;

 }

 public Point computeSize (int wHint, int hHint, boolean changed) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	PhDim_t dim = new PhDim_t ();

 	if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);

 	OS.PtWidgetPreferredSize (handle, dim);

@@ -73,14 +74,9 @@
 	return new Point(width, height);

 }

 public void clearSelection () {

-	checkWidget();

-	int [] position = {0};

-	if ((style & SWT.SINGLE) != 0) {

-		int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};

-		OS.PtGetResources (handle, args.length / 3, args);

-		position [0] = args [1];

-	}

-	OS.PtTextSetSelection (handle, position, position);

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	OS.PtTextSetSelection (handle, new int [] {0}, new int [] {0});

 }

 void createHandle (int index) {

 	state |= HANDLE;

@@ -123,14 +119,16 @@
 }

 

 public void addModifyListener (ModifyListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Modify, typedListener);

 }

 

 public void addSelectionListener (SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Selection,typedListener);

@@ -138,21 +136,25 @@
 }

 

 public void addVerifyListener (VerifyListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Verify, typedListener);

 }

 

 public void append (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	byte [] buffer = Converter.wcsToMbcs (null, string, false);

 	OS.PtTextModifyText (handle, 0, 0, -1, buffer, buffer.length);

 }

 

 public void copy () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

 	int [] start = new int [1], end = new int [1];

 	int length = OS.PtTextGetSelection (handle, start, end);

 	if (length <= 0) return;

@@ -165,7 +167,9 @@
 }

 

 public void cut () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

 	int [] start = new int [1], end = new int [1];

 	int length = OS.PtTextGetSelection (handle, start, end);

 	if (length <= 0) return;

@@ -195,26 +199,30 @@
 }

 

 public int getCaretLineNumber () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	//NOT DONE - NOT NEEDED

 	return 0;

 }

 

 public Point getCaretLocation () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	//NOT DONE - NOT NEEDED

 	return null;

 }

 

 public int getCaretPosition () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public int getCharCount () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	if (args [1] == 0) return 0;

@@ -222,25 +230,29 @@
 }

 

 public boolean getDoubleClickEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);	

 	//NOT DONE - NOT NEEDED

 	return false;

 }

 

 public char getEchoChar () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return echoCharacter;

 }

 

 public boolean getEditable () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_TEXT_FLAGS, 0, 0};

 	OS.PtGetResources(handle, args.length / 3, args);

 	return (args [1] & OS.Pt_EDITABLE) != 0;

 }

 

 public int getLineCount () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SINGLE) != 0) return 1;

 	int [] args = {OS.Pt_ARG_MULTITEXT_NUM_LINES, 0, 0};

 	OS.PtGetResources(handle, args.length / 3, args);

@@ -248,12 +260,12 @@
 }

 

 public String getLineDelimiter () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return "\n";

 }

 

 public int getLineHeight () {

-	checkWidget();

 	if ((style & SWT.SINGLE) != 0) {

 		PhDim_t dim = new PhDim_t ();

 		if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);

@@ -286,7 +298,8 @@
 }

 

 public Point getSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (textVerify != null) {

 		return new Point (textVerify.start_pos, textVerify.end_pos);

 	}

@@ -301,13 +314,15 @@
 }

 

 public int getSelectionCount () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	Point selection = getSelection ();

 	return selection.y - selection.x;

 }

 

 public String getSelectionText () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	/*

 	* NOTE: The current implementation uses substring ()

 	* which can reference a potentially large character

@@ -318,7 +333,8 @@
 }

 

 public int getTabs () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return tabs;

 }

 

@@ -335,7 +351,8 @@
 }

 

 public String getText (int start, int end) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	/*

 	* NOTE: The current implementation uses substring ()

 	* which can reference a potentially large character

@@ -346,7 +363,8 @@
 }

 

 public String getText () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (echoCharacter != '\0') return hiddenText;

 	int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

@@ -359,22 +377,26 @@
 }

 

 public int getTextLimit () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

 }

 

 public int getTopIndex () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SINGLE) != 0) return 0;

 	int [] args = {OS.Pt_ARG_MULTITEXT_TOP_LINE, 0, 0};

 	OS.PtGetResources(handle, args.length / 3, args);

-	return args [1] - 1;

+	return args [1];

 }

 

 public int getTopPixel () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

 	//NOT DONE - NOT NEEDED

 	return 0;

 }

@@ -387,7 +409,8 @@
 }

 

 public void insert (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	byte [] buffer = Converter.wcsToMbcs (null, string, false);

 	int [] start = new int [1], end = new int [1];

@@ -401,7 +424,9 @@
 }

 

 public void paste () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

 	int ig = OS.PhInputGroup (0);

 	int ptr = OS.PhClipboardPasteString((short)ig);

 	if (ptr == 0) return;

@@ -533,14 +558,16 @@
 }

 

 public void removeModifyListener (ModifyListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Modify, listener);	

 }

 

 public void removeSelectionListener (SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Selection, listener);

@@ -548,19 +575,22 @@
 }

 

 public void removeVerifyListener (VerifyListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Verify, listener);	

 }

 

 public void selectAll () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	OS.PtTextSetSelection (handle, new int [0], new int [] {-1});

 }

 

 public void setEchoChar (char echo) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (echoCharacter == echo) return;

 	String newText;

 	if (echo == 0) {

@@ -579,12 +609,15 @@
 }

 

 public void setDoubleClickEnabled (boolean doubleClick) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

 	//NOT DONE - NOT NEEDED

 }

 

 public void setEditable (boolean editable) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	style &= ~SWT.READ_ONLY;

 	if (!editable) style |= SWT.READ_ONLY; 

 	int [] args = {OS.Pt_ARG_TEXT_FLAGS, editable ? OS.Pt_EDITABLE : 0, OS.Pt_EDITABLE};

@@ -597,46 +630,28 @@
 }

 

 public void setSelection (int position) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_CURSOR_POSITION, position, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

-

-	/*

-	* Feature in Photon. On a single-line text, the selection is

-	* not cleared when setting the cursor position. The fix is to

-	* set the selection start and end values to the specified

-	* position.

-	*/

-	if ((style & SWT.SINGLE) != 0) {

-		int [] selection = {position};

-		OS.PtTextSetSelection (handle, selection, selection);

-	}

 }

 

 public void setSelection (Point selection) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);

 	setSelection (selection.x, selection.y);

 }

 

 public void setSelection (int start, int end) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	OS.PtTextSetSelection (handle, new int [] {start}, new int [] {end});

-	

-	/*

-	* Feature in Photon. On a multi-line text, the caret position

-	* is not changed with the selection start and end values are

-	* the same. The fix is to detect this case and change the

-	* cursor position.

-	*/

-	if ((style & SWT.MULTI) != 0 && start == end) {

-		int [] args = {OS.Pt_ARG_CURSOR_POSITION, start, 0};

-		OS.PtSetResources (handle, args.length / 3, args);

-	}

 }

 

 public void setTabs (int tabs) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (tabs < 0) return;

 	setTabStops (this.tabs = tabs);

 }

@@ -652,7 +667,8 @@
 }

 

 public void setText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	byte [] buffer = Converter.wcsToMbcs (null, string, true);

 	int ptr = OS.malloc (buffer.length);

@@ -663,21 +679,25 @@
 }

 

 public void setTextLimit (int limit) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);

 	int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, limit, 0};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void setTopIndex (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SINGLE) != 0) return;

 	int [] args = {OS.Pt_ARG_MULTITEXT_TOP_LINE, index + 1, 0};

 	OS.PtSetResources(handle, args.length / 3, args);

 }

 

 public void showSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

 	//NOT DONE - NOT NEEDED

 }

 

@@ -692,13 +712,4 @@
 	return SWT.TRAVERSE_ESCAPE;

 }

 

-boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {

-	boolean translated = super.translateTraversal (key_sym, phEvent);

-	if ((style & SWT.SINGLE) != 0 && !translated && key_sym == OS.Pk_Return) {

-		postEvent (SWT.DefaultSelection);

-		return true;

-	}

-	return translated;

-}

-

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java
index bbe5c45..707d5df 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java
@@ -47,7 +47,8 @@
 

 public Point computeSize (int wHint, int hHint, boolean changed) {

 //	if (layout != null) return super.computeSize (wHint, hHint, changed);

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	PhDim_t dim = new PhDim_t();

 	if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);

 	OS.PtWidgetPreferredSize(handle, dim);

@@ -108,26 +109,30 @@
 }

 

 public int getItemCount () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return itemCount;

 }

 

 public ToolItem [] getItems () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	ToolItem [] result = new ToolItem [itemCount];

 	System.arraycopy (items, 0, result, 0, itemCount);

 	return result;

 }

 

 public ToolItem getItem (int index) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int count = itemCount;

 	if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);	

 	return items [index];

 }

 

 public ToolItem getItem (Point pt) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	ToolItem [] items = getItems ();

 	for (int i=0; i<items.length; i++) {

 		Rectangle rect = items [i].getBounds ();

@@ -137,14 +142,15 @@
 }

 

 public int getRowCount () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return 1;

 }

 

 public int indexOf (ToolItem item) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);

-	if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 	int count = itemCount;

 	for (int i=0; i<count; i++) {

 		if (items [i] == item) return i;

@@ -163,16 +169,5 @@
 	items = null;

 	super.releaseWidget ();

 }

-
-/* TEMPORARY CODE.  Hack for eclipse. */
-public void setData(Object data) {

-	super.setData(data);

-	if (data != null && data.getClass().getName().indexOf("org.eclipse.ui.internal.ShortcutBarPart") != -1) {

-		int [] args = {

-			OS.Pt_ARG_ORIENTATION, OS.Pt_VERTICAL, 0,

-		};

-		OS.PtSetResources(handle, args.length / 3, args);

-	}

-}
 

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java
index d9b2704..305bfc6 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java
@@ -30,7 +30,8 @@
 }

 

 public void addSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Selection,typedListener);

@@ -146,19 +147,22 @@
 }

 

 public Rectangle getBounds () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	PhArea_t area = new PhArea_t ();

 	OS.PtWidgetArea (handle, area);

 	return new Rectangle (area.pos_x, area.pos_y, area.size_w, area.size_h);

 }

 

 public Control getControl () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return control;

 }

 

 public Image getDisabledImage () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return disabledImage;

 }

 

@@ -169,24 +173,28 @@
 }

 

 public boolean getEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_FLAGS, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return (args [1] & OS.Pt_BLOCKED) == 0;

 }

 

 public Image getHotImage () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return hotImage;

 }

 

 public ToolBar getParent () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent;

 }

 

 public boolean getSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;

 	int [] args = {OS.Pt_ARG_FLAGS, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

@@ -194,12 +202,14 @@
 }

 

 public String getToolTipText () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return toolTipText;

 }

 

 public int getWidth () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {OS.Pt_ARG_WIDTH, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

 	return args [1];

@@ -217,7 +227,8 @@
 }

 

 public boolean isEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return getEnabled () && parent.isEnabled ();

 }

 

@@ -304,7 +315,8 @@
 }

 

 public void removeSelectionListener(SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Selection, listener);

@@ -312,10 +324,10 @@
 }

 

 public void setControl (Control control) {

-	checkWidget();

-	if (control != null) {

-		if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);

-		if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	if (control != null && control.parent != parent) {

+		error (SWT.ERROR_INVALID_PARENT);

 	}

 	if ((style & SWT.SEPARATOR) == 0) return;

 	Control oldControl = this.control;

@@ -330,14 +342,15 @@
 }

 

 public void setDisabledImage (Image image) {

-	checkWidget();

-	if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SEPARATOR) != 0) return;

 	disabledImage = image;

 }

 

 public void setEnabled (boolean enabled) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int [] args = {

 		OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_BLOCKED, OS.Pt_BLOCKED,

 		OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_GHOST, OS.Pt_GHOST,

@@ -346,25 +359,16 @@
 }

 

 public void setHotImage (Image image) {

-	checkWidget();

-	if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SEPARATOR) != 0) return;

-

-	/* TEMPORARY CODE: remove when when FLAT tool bars are implemented */

-	if ((parent.style & SWT.FLAT) != 0) setImage (image);

-

 	hotImage = image;

 }

 

 public void setImage (Image image) {

-	checkWidget();

-	if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

-	if ((style & SWT.SEPARATOR) != 0) return;	

-	super.setImage (image);

-

-	/* TEMPORARY CODE: remove when when FLAT tool bars are implemented */

-	if ((parent.style & SWT.FLAT) != 0 && hotImage != null) return;

-

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	if ((style & SWT.SEPARATOR) != 0) return;

 	int imageHandle = 0;

 	int type = OS.Pt_Z_STRING;

 	if (image != null) {

@@ -395,14 +399,16 @@
 }

 

 public void setSelection (boolean selected) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;

 	int [] args = {OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET};

 	OS.PtSetResources (handle, args.length / 3, args);

 }

 

 public void setText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SEPARATOR) != 0) return;

 	super.setText (string);

 	int ptr = 0;

@@ -437,12 +443,14 @@
 }

 

 public void setToolTipText (String string) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	toolTipText = string;

 }

 

 public void setWidth (int width) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if ((style & SWT.SEPARATOR) == 0) return;

 	if (width < 0) return;

 	int [] args = {OS.Pt_ARG_WIDTH, width, 0};

@@ -451,4 +459,4 @@
 		control.setBounds (getBounds ());

 	}

 }

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java
index e35cab7..9870e16 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java
@@ -32,13 +32,15 @@
 	this.display = parent.getDisplay ();

 }

 public void addControlListener(ControlListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Move,typedListener);

 }

 public void close () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	tracking = false;

 }

 

@@ -84,15 +86,18 @@
 }

 

 public Rectangle [] getRectangles () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return rectangles;

 }

 public boolean getStippled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return stippled;

 }

 public boolean open () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int sense = OS.Ph_EV_DRAG | OS.Ph_EV_KEY | OS.Ph_EV_BUT_PRESS |

 		OS.Ph_EV_BUT_RELEASE | OS.Ph_EV_PTR_MOTION;

 	int [] args = {

@@ -154,8 +159,6 @@
 						* event.  If this happens, return false to indicate

 						* that the tracking has failed.

 						*/

-						ev.x = newX;

-						ev.y = newY;

 						sendEvent (SWT.Move, ev);

 						if (isDisposed ()) return false;

 						drawRectangles ();

@@ -194,19 +197,22 @@
 	rectangles = null;

 }

 public void removeControlListener (ControlListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Move, listener);

 }

 public void setRectangles (Rectangle [] rectangles) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (rectangles == null) error (SWT.ERROR_NULL_ARGUMENT);

 	this.rectangles = rectangles;

 }

 public void setStippled (boolean stippled) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	this.stippled = stippled;

 }

 

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tree.java
new file mode 100755
index 0000000..8447820
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tree.java
@@ -0,0 +1,1661 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+

+import org.eclipse.swt.*;

+import org.eclipse.swt.events.*;

+import org.eclipse.swt.graphics.*;

+import java.io.*;

+import java.util.*;

+ 

+/**
+ * Instances of this class provide a selectable user interface object
+ * that displays a hierarchy of items and issue notificiation when an
+ * item in the hierarchy is selected.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TreeItem</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SINGLE, MULTI, CHECK</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, DefaultSelection, Collapse, Expand</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */

+public /*final*/ class Tree extends SelectableItemWidget {

+	// These constants are used internally for item hit test on mouse click

+	private static final int ActionNone = 0;			// The mouse event was not handled

+	private static final int ActionExpandCollapse = 1;	// Do an expand/collapse

+	private static final int ActionSelect = 2;			// Select the item

+	private static final int ActionCheck = 3;			// Toggle checked state of the item

+	private static ImageData CollapsedImageData;		// collapsed sub tree image data. used to create an image at run time

+	private static ImageData ExpandedImageData;			// expanded sub tree image data. used to create an image at run time

+	static {

+		initializeImageData();

+	}

+	

+	private TreeRoots root;

+	private TreeItem expandingItem;

+	

+	private Image collapsedImage;

+	private Image expandedImage;

+

+	// The following fields are needed for painting tree items

+	final Color CONNECTOR_LINE_COLOR;					// Color constant used during painting. Can't keep this in TreeItem 

+														// because we only need one instance per tree widget/display and can't 

+														// have it static. Initialized in c'tor and freed in dispose();

+	Rectangle hierarchyIndicatorRect = null;			// bounding rectangle of the hierarchy indication image (plus/minus)

+

+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <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
+ *
+ * @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 Tree(Composite parent, int style) {

+	super(parent, checkStyle (style));

+	CONNECTOR_LINE_COLOR = new Color(getDisplay(), 170, 170, 170);	// Light gray;

+}

+/**

+ * Add 'item' to the list of root items.

+ * @param 'item' - the tree item that should be added as a root.

+ * @param index - position that 'item' will be inserted at

+ *	in the receiver.

+ */

+void addItem(TreeItem item, int index) {

+	if (index < 0 || index > getItemCount()) {

+		error(SWT.ERROR_INVALID_RANGE);

+	}

+	getRoot().add(item, index);

+}

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's selection changes, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>

+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.

+ * If the reciever has <code>SWT.CHECK</code> style set and the check selection changes,

+ * the event object detail field contains the value <code>SWT.CHECK</code>.

+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.

+ * </p>

+ *
+ * @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 SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent

+ */

+public void addSelectionListener(SelectionListener listener) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	TypedListener typedListener;

+

+	if (listener == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	typedListener = new TypedListener(listener);	

+	addListener(SWT.Selection, typedListener);

+	addListener(SWT.DefaultSelection, typedListener);

+}

+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when an item in the receiver is expanded or collapsed
+ * by sending it one of the messages defined in the <code>TreeListener</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 TreeListener
+ * @see #removeTreeListener
+ */

+public void addTreeListener(TreeListener listener) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	TypedListener typedListener;

+

+	if (listener == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	typedListener = new TypedListener(listener);	

+	addListener(SWT.Expand, typedListener);

+	addListener(SWT.Collapse, typedListener);

+}

+/**

+ * The SelectableItem 'item' has been added to the tree.

+ * Prevent screen updates when 'item' is inserted due to an 

+ * expand operation.

+ * @param item - item that has been added to the receiver.

+ */

+void addedItem(SelectableItem item, int index) {

+	super.addedItem(item, index);				

+	redrawAfterModify(item, index);		// redraw plus/minus image, hierarchy lines

+}

+/**

+ * Answer the y position of both the first child of 'item' and 

+ * the item following the last child of 'item'.

+ * Used to scroll items on expand/collapse.

+ * @param item - TreeItem to use for calculating the y boundary 

+ *	of child items.

+ * @return Array - first element is the position of the first 

+ *	child of 'item'. Second element is the position of the item 

+ *	following the last child of 'item'.

+ *	Both elements are -1 if 'item' is not a child of the receiver.

+ */

+int[] calculateChildrenYPos(TreeItem item) {

+	int itemIndex = item.getVisibleIndex();

+	int itemCount = item.getVisibleItemCount();

+	int itemHeight = getItemHeight();

+	int yPos;

+	int[] yPosition = new int[] {-1, -1};

+

+	if (itemIndex != -1) {

+		itemIndex -= getTopIndex();															

+		yPos = (itemIndex + itemCount + 1) * itemHeight;	// y position of the item following 

+															// the last child of 'item'

+		yPosition = new int[] {yPos - (itemCount * itemHeight), yPos};

+	}

+	return yPosition;

+}

+/**

+ * Calculate the widest of the children of 'item'.

+ * Items that are off screen and that may be scrolled into view are 

+ * included in the calculation.

+ * @param item - the tree item that was expanded

+ */

+void calculateWidestExpandingItem(TreeItem item) {

+	int itemIndex = item.getVisibleIndex();

+	int newMaximumItemWidth = getContentWidth();

+	int stopIndex = itemIndex + item.getVisibleItemCount();

+

+	for (int i = itemIndex + 1; i <= stopIndex; i++) {

+		newMaximumItemWidth = Math.max(newMaximumItemWidth, getContentWidth(i));

+	}

+	setContentWidth(newMaximumItemWidth);

+}

+/**

+ * Calculate the width of new items as they are scrolled into view.

+ * Precondition: 

+ * topIndex has already been set to the new index.

+ * @param topIndexDifference - difference between old and new top 

+ *	index.

+ */

+void calculateWidestScrolledItem(int topIndexDifference) {

+	int visibleItemCount = getItemCountTruncated(getClientArea());	

+	int newMaximumItemWidth = getContentWidth();

+	int topIndex = getTopIndex();

+	int stopIndex = topIndex;

+

+	if (topIndexDifference < 0) {								// scrolled up?

+		if (Math.abs(topIndexDifference) > visibleItemCount) {	// scrolled down more than one page (via quick thumb dragging)?

+			topIndexDifference = visibleItemCount * -1;

+		}

+		for (int i = stopIndex - topIndexDifference; i >= stopIndex; i--) {	// check item width from old top index up to new one

+			newMaximumItemWidth = Math.max(newMaximumItemWidth, getContentWidth(i));

+		}

+	}

+	else

+	if (topIndexDifference > 0) {								// scrolled down?

+		if (topIndexDifference > visibleItemCount) {			// scrolled down more than one page (via quick thumb dragging)?

+			topIndexDifference = visibleItemCount;

+		}

+		stopIndex += visibleItemCount;		

+		for (int i = stopIndex - topIndexDifference; i < stopIndex; i++) {

+			newMaximumItemWidth = Math.max(newMaximumItemWidth, getContentWidth(i));

+		}

+	}

+	setContentWidth(newMaximumItemWidth);

+}

+/**

+ * Calculate the maximum item width of all displayed items.

+ */

+void calculateWidestShowingItem() {

+	TreeItem visibleItem;

+	int newMaximumItemWidth = 0;

+	int bottomIndex = getBottomIndex();

+	int paintStopX;

+

+	// add one to the loop end index because otherwise an item covered 

+	// by the horizontal scroll bar would not be taken into acount and 

+	// may become visible after this calculation. We're in trouble if

+	// that item is wider than the client area.

+	if (getHorizontalBar().getVisible() == true) {

+		bottomIndex++;

+	}

+	for (int i = getTopIndex(); i < bottomIndex; i++) {

+		visibleItem = getRoot().getVisibleItem(i);

+		if (visibleItem != null) {

+			paintStopX = visibleItem.getPaintStopX();

+			newMaximumItemWidth = Math.max(newMaximumItemWidth, paintStopX);

+		}

+	}

+	setContentWidth(newMaximumItemWidth);

+}

+static int checkStyle (int style) {

+	return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);

+}

+protected void checkSubclass () {

+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);

+}

+/**

+ * Collapse the tree item identified by 'item' if it is not 

+ * already collapsed. Move the selection to the parent item 

+ * if one of the collapsed items is currently selected.

+ * @param item - item that should be collapsed.

+ * @param notifyListeners - 

+ *	true=a Collapse event is sent 

+ *	false=no event is sent

+ */

+void collapse(TreeItem item, boolean notifyListeners) {

+	Event event;

+	int itemIndex;

+	

+	if (item.getExpanded() == false) {

+		return;

+	}

+	collapseNoRedraw(item);

+	itemIndex = item.getVisibleIndex();

+	if (itemIndex != -1) {						// if the item's parent is not collapsed (and the item is thus visible) do the screen updates

+		item.redrawExpanded(itemIndex - getTopIndex());

+		showSelectableItem(item);

+		calculateVerticalScrollbar();

+		calculateWidestShowingItem();

+		claimRightFreeSpace();

+		claimBottomFreeSpace();		

+	}

+	if (notifyListeners == true) {

+		event = new Event();

+		event.item = item;

+		notifyListeners(SWT.Collapse, event);

+	}

+}

+

+/**

+ * Collapse the tree item identified by 'item' if it is not 

+ * already collapsed. Move the selection to the parent item 

+ * if one of the collapsed items is currently selected.

+ * This method is used to hide the children if an item is deleted.

+ * certain redraw and scroll operations are not needed for this 

+ * case.

+ * @param item - item that should be collapsed.

+ */

+void collapseNoRedraw(TreeItem item) {

+	int itemIndex;

+	

+	if (item.getExpanded() == false) {

+		return;

+	}

+	if (isSelectedItemCollapsing(item) == true) {

+		deselectAllExcept(item);

+		selectNotify(item);

+		update();								// call update to make sure that new selection is 

+												// drawn before items are collapsed (looks better)

+	}

+	scrollForCollapse(item);

+	item.internalSetExpanded(false);

+}

+

+public Point computeSize(int wHint, int hHint, boolean changed) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Point size = super.computeSize(wHint, hHint, changed);

+	GC gc;

+	final int WidthCalculationCount = 50;		// calculate item width for the first couple of items only

+	TreeRoots root = getRoot();

+	TreeItem item;

+	Image itemImage;

+	String itemText;

+	int width;

+	int newItemWidth = 0;

+		

+	if (getContentWidth() == 0 && getItemCount() > 0) {

+		gc = new GC(this);

+		for (int i = 0; i < WidthCalculationCount; i++) {

+			item = root.getVisibleItem(i);

+			if (item == null) {

+				break;											// no more items

+			}

+			itemImage = item.getImage();

+			itemText = item.getText();

+			width = 0;

+			if (itemImage != null) {

+				width += itemImage.getBounds().width;

+			}

+			if (itemText != null) {

+				width += gc.stringExtent(itemText).x;

+			}

+			newItemWidth = Math.max(newItemWidth, width);

+		}

+		if (newItemWidth > 0) {

+			size.x = newItemWidth;

+		}		

+		gc.dispose();

+	}

+	return size;

+}

+/**
+ * Deselects all selected items in the receiver.
+ *
+ * @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 deselectAll() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	getRoot().deselectAll();

+	getSelectionVector().removeAllElements();

+	redraw();

+}

+/**

+ * Modifier Key		Action

+ * None				Collapse the selected item if expanded. Select 

+ * 					parent item if selected item is already 

+ * 					collapsed and if it's not the root item.

+ * Ctrl				super.doArrowLeft(int);

+ * Shift			see None above

+ * @param keyMask - the modifier key that was pressed

+ */

+void doArrowLeft(int keyMask) {

+	TreeItem focusItem = (TreeItem) getLastFocus();

+	TreeItem parentItem;

+

+	if (focusItem == null) {

+		return;

+	}

+	if (keyMask == SWT.CTRL) {

+		super.doArrowLeft(keyMask);

+	}

+	else

+	if (focusItem.getExpanded() == true) {			// collapse if expanded

+		collapse(focusItem, true);

+	}

+	else

+	if (focusItem.isRoot() == false) {				// go to the parent if there is one

+		parentItem = focusItem.getParentItem();

+		deselectAllExcept(parentItem);

+		selectNotify(parentItem);

+	}

+}

+/**

+ * Modifier Key		Action

+ * None				Expand selected item if collapsed. Select 

+ * 					first child item if selected item is 

+ *					already expanded and there is a child item.

+ * Ctrl				super.doArrowRight(keyMask);

+ * Shift			see None above

+ * @param keyMask - the modifier key that was pressed

+ */

+void doArrowRight(int keyMask) {

+	TreeItem focusItem = (TreeItem) getLastFocus();

+	TreeItem childItem;

+

+	if (focusItem == null) {

+		return;

+	}	

+	if (keyMask == SWT.CTRL) {

+		super.doArrowRight(keyMask);

+	}

+	else

+	if (focusItem.isLeaf() == false) {

+		if (focusItem.getExpanded() == false) {			// expand if collapsed

+			expand(focusItem, true);

+		} 

+		else {											// go to the first child if there is one

+			childItem = focusItem.getItems()[0];

+			deselectAllExcept(childItem);

+			selectNotify(childItem);

+		}

+	}

+}

+/**

+ * Expand the selected item and all of its children.

+ */

+void doAsterix() {

+	expandAll((TreeItem) getLastFocus());

+}

+/**

+ * Free resources.

+ */

+void doDispose() {

+	super.doDispose();	

+	if (collapsedImage != null) {

+		collapsedImage.dispose();

+	}

+	if (expandedImage != null) {

+		expandedImage.dispose();

+	}

+	getRoot().dispose();

+	CONNECTOR_LINE_COLOR.dispose();

+	resetHierarchyIndicatorRect();

+}

+/**

+ * Collapse the selected item if it is expanded.

+ */

+void doMinus() {

+	TreeItem selectedItem = (TreeItem) getLastFocus();

+

+	if (selectedItem != null) {

+		collapse(selectedItem, true);

+	}

+}

+/**

+ * Expand the selected item if it is collapsed and if it 

+ * has children.

+ */

+void doPlus() {

+	TreeItem selectedItem = (TreeItem) getLastFocus();

+

+	if (selectedItem != null && selectedItem.isLeaf() == false) {

+		expand(selectedItem, true);

+	}

+}

+/**

+ * Expand the tree item identified by 'item' if it is not already 

+ * expanded. Scroll the expanded items into view.

+ * @param item - item that should be expanded

+ * @param notifyListeners - 

+ *	true=an Expand event is sent 

+ *	false=no event is sent

+ */

+void expand(TreeItem item, boolean notifyListeners) {

+	Event event = new Event();

+	int indexFromTop;

+	boolean nestedExpand = expandingItem != null;

+

+	if (item.getExpanded() == true) {

+		return;

+	}

+	if (nestedExpand == false) {

+		setExpandingItem(item);

+	}

+	if (notifyListeners == true) {

+		event.item = item;

+		notifyListeners(SWT.Expand, event);

+	}

+	scrollForExpand(item);

+	item.internalSetExpanded(true);

+	// redraw hierarchy image

+	item.redrawExpanded(item.getVisibleIndex() - getTopIndex());

+	calculateVerticalScrollbar();

+	if (nestedExpand == false && isVisible() == true) {

+		// Save the index here because showSelectableItem may change it

+		indexFromTop = item.getVisibleIndex() - getTopIndex();		

+		showSelectableItem(item);				// make expanded item visible. Could be invisible if the expand was caused by a key press.		

+		calculateWidestExpandingItem(item);

+		scrollExpandedItemsIntoView(item);		

+	}

+	if (nestedExpand == false) {

+		setExpandingItem(null);

+	}

+}

+/**

+ * Expand 'item' and all its children.

+ */

+void expandAll(TreeItem item) {

+	TreeItem items[];

+

+	if (item != null && item.isLeaf() == false) {

+		expand(item, true);

+		update();

+		items = item.getItems(); 

+		for (int i = 0; i < items.length; i++) {

+			expandAll(items[i]);

+		}

+	}

+}

+/**

+ * Answer the image that is used as a hierarchy indicator 

+ * for a collapsed hierarchy.

+ */

+Image getCollapsedImage() {

+	if (collapsedImage == null) {

+		collapsedImage = new Image(getDisplay(), CollapsedImageData);

+	}

+	return collapsedImage;

+}

+/**

+ * Answer the width of the item identified by 'itemIndex'.

+ */

+int getContentWidth(int itemIndex) {

+	TreeItem item = getRoot().getVisibleItem(itemIndex);

+	int paintStopX = 0;

+

+	if (item != null) {

+		paintStopX = item.getPaintStopX();

+	}

+	return paintStopX;

+}

+/**

+ * Answer the image that is used as a hierarchy indicator 

+ * for an expanded hierarchy.

+ */

+Image getExpandedImage() {

+	if (expandedImage == null) {

+		expandedImage = new Image(getDisplay(), ExpandedImageData);

+	}

+	return expandedImage;

+}

+/**

+ * Answer the rectangle enclosing the hierarchy indicator of a tree item.

+ * 

+ * Note:

+ * Assumes that the hierarchy indicators for expanded and 

+ * collapsed state are the same size.

+ * @return

+ *	The rectangle enclosing the hierarchy indicator.

+ */

+Rectangle getHierarchyIndicatorRect() {

+	int itemHeight = getItemHeight();

+	Image hierarchyImage;

+	Rectangle imageBounds;

+	

+	if (hierarchyIndicatorRect == null && itemHeight != -1) {

+		hierarchyImage = getCollapsedImage();

+		if (hierarchyImage != null) {

+		 	imageBounds = hierarchyImage.getBounds();

+		}

+		else {

+			imageBounds = new Rectangle(0, 0, 0, 0);

+		}

+		hierarchyIndicatorRect = new Rectangle(

+			0,

+			(itemHeight - imageBounds.height) / 2 + (itemHeight - imageBounds.height) % 2,

+			imageBounds.width,

+			imageBounds.height);

+	}

+	return hierarchyIndicatorRect;

+}

+/**

+ * Answer the index of 'item' in the receiver.

+ */

+int getIndex(SelectableItem item) {

+	int index = -1;

+

+	if (item != null) {

+		index = ((TreeItem) item).getGlobalIndex();

+	}

+	return index;

+}

+/**
+ * Returns the number of items contained in the receiver
+ * that are direct item children of the receiver.  The
+ * number that is returned is the number of roots in the
+ * tree.
+ *
+ * @return the number of items
+ *
+ * @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 getItemCount() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return getRoot().getItemCount();

+}

+/**
+ * Returns the height of the area which would be used to
+ * display <em>one</em> of the items in the tree.
+ *
+ * @return the height of one item
+ *
+ * @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 getItemHeight() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return super.getItemHeight();

+}

+/**
+ * Returns the number of items contained in the receiver
+ * that are direct item children of the receiver.  These
+ * are the roots of the tree.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the number of items
+ *
+ * @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 TreeItem [] getItems() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	TreeItem childrenArray[] = new TreeItem[getItemCount()];

+

+	getRoot().getChildren().copyInto(childrenArray);

+	return childrenArray;	

+}

+/**

+ * Answer the number of sub items of 'item' that do not fit in the 

+ * tree client area.

+ */

+int getOffScreenItemCount(TreeItem item) {

+	int itemIndexFromTop = item.getVisibleIndex() - getTopIndex();

+	int spaceRemaining = getItemCountWhole()-(itemIndexFromTop+1);

+	int expandedItemCount = item.getVisibleItemCount();

+

+	return expandedItemCount - spaceRemaining;	

+}

+/**
+ * Returns the receiver's parent item, which must be a
+ * <code>TreeItem</code> or null when the receiver is a
+ * root.
+ *
+ * @return the receiver's parent item
+ *
+ * @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 TreeItem getParentItem() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return null;

+}

+/**

+ * Answer the object that holds the root items of the receiver.

+ */

+TreeRoots getRoot() {

+	return root;

+}

+/**
+ * Returns an array of <code>TreeItem</code>s that are currently
+ * selected in the receiver. An empty array indicates that no
+ * items are selected.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ * @return an array representing the selection
+ *
+ * @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 TreeItem [] getSelection() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector selectionVector = getSelectionVector();

+	TreeItem[] selectionArray = new TreeItem[selectionVector.size()];

+

+	selectionVector.copyInto(selectionArray);

+	sort(selectionArray, 0, selectionArray.length);

+	return selectionArray;

+}

+/**

+ * Answer the index of 'item' in the receiver.

+ * Answer -1 if the item is not visible.

+ * The returned index must refer to a visible item.

+ * Note: 

+ * 	Visible in this context does not neccessarily mean that the 

+ * 	item is displayed on the screen. It only means that the item 

+ * 	would be displayed if it is located inside the receiver's 

+ * 	client area.

+ *	Collapsed items are not visible.

+ */

+int getVisibleIndex(SelectableItem item) {

+	int index = -1;

+

+	if (item != null) {

+		index = ((AbstractTreeItem) item).getVisibleIndex();

+	}

+	return index;

+}

+/**

+ * Answer the SelectableItem located at 'itemIndex' 

+ * in the receiver.

+ * @param itemIndex - location of the SelectableItem 

+ *	object to return

+ */

+SelectableItem getVisibleItem(int itemIndex) {

+	return getRoot().getVisibleItem(itemIndex);

+}

+/**

+ * Answer the number of visible items of the receiver.

+ * Note: 

+ * 	Visible in this context does not neccessarily mean that the 

+ * 	item is displayed on the screen. It only means that the item 

+ * 	would be displayed if it is located inside the receiver's 

+ * 	client area.

+ *	Collapsed items are not visible.

+ */

+int getVisibleItemCount() {

+	return getRoot().getVisibleItemCount();

+}

+/**

+ * Answer the y coordinate at which 'item' is drawn. 

+ * @param item - SelectableItem for which the paint position 

+ *	should be returned

+ * @return the y coordinate at which 'item' is drawn.

+ *	Return -1 if 'item' is null or outside the client area

+ */

+int getVisibleRedrawY(SelectableItem item) {

+	int redrawY = getRedrawY(item);

+	

+	if (redrawY < 0 || redrawY > getClientArea().height) {

+		redrawY = -1;

+	}

+	return redrawY;

+}

+/**

+ * Handle the events the receiver is listening to.

+ */

+void handleEvents(Event event) {

+	switch (event.type) {

+		case SWT.Paint:

+			paint(event);

+			break;

+		case SWT.MouseDown:

+			mouseDown(event);

+			break;

+		case SWT.MouseDoubleClick:

+			mouseDoubleClick(event);

+			break;

+		default:

+			super.handleEvents(event);

+	}	

+}

+/**

+ * Initialize the receiver.

+ */

+void initialize() {

+	resetRoot();					// has to be at very top because super class uses 

+									// functionality that relies on the TreeRoots object

+	super.initialize();

+}

+/**

+ * Initialize the ImageData used for the expanded/collapsed images.

+ */

+static void initializeImageData() {

+	PaletteData fourBit = new PaletteData(

+		new RGB[] {new RGB(0, 0, 0), new RGB (128, 0, 0), new RGB (0, 128, 0), new RGB (128, 128, 0), new RGB (0, 0, 128), new RGB (128, 0, 128), new RGB (0, 128, 128), new RGB (128, 128, 128), new RGB (192, 192, 192), new RGB (255, 0, 0), new RGB (0, 255, 0), new RGB (255, 255, 0), new RGB (0, 0, 255), new RGB (255, 0, 255), new RGB (0, 255, 255), new RGB (255, 255, 255)});

+	

+	CollapsedImageData = new ImageData(

+		9, 9, 4, 										// width, height, depth

+		fourBit, 4,

+		new byte[] {119, 119, 119, 119, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, 15, -1, 112, 0, 0, 0, 127, -1, 15, -1, 112, 0, 0, 0, 127, 0, 0, 15, 112, 0, 0, 0, 127, -1, 15, -1, 112, 0, 0, 0, 127, -1, 15, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 119, 119, 119, 119, 112, 0, 0, 0});

+	CollapsedImageData.transparentPixel = 15;			// use white for transparency

+	ExpandedImageData = new ImageData(

+		9, 9, 4, 										// width, height, depth

+		fourBit, 4,

+		new byte[] {119, 119, 119, 119, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, 0, 0, 15, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 119, 119, 119, 119, 112, 0, 0, 0});

+	ExpandedImageData.transparentPixel = 15;			// use white for transparency

+}

+/**

+ * Set event listeners for the receiver.

+ */

+void installListeners() {

+	Listener listener = getListener();

+

+	super.installListeners();

+	addListener(SWT.Paint, listener);

+	addListener(SWT.MouseDown, listener);

+	addListener(SWT.MouseDoubleClick, listener);

+}

+/**

+ * Answer whether the receiver is currently expanding a sub tree 

+ * with 'item' in it.

+ * Used for performance optimizations.

+ */

+boolean isExpandingItem(SelectableItem item) {

+	TreeItem parentItem;

+	

+	if (expandingItem == null || item == null || (item instanceof TreeItem) == false) {

+		return false;

+	}

+	parentItem = ((TreeItem) item).getParentItem();

+	return (parentItem == expandingItem || isExpandingItem(parentItem));

+}

+/**

+ * Answer whether the children of 'collapsingItem' contain 

+ * at least one selected item.

+ */

+boolean isSelectedItemCollapsing(TreeItem collapsingItem) {

+	Enumeration selection = getSelectionVector().elements();

+	TreeItem item;

+	int selectedItemIndex;

+	int collapsingItemIndex = collapsingItem.getVisibleIndex();

+	int lastCollapsedItemIndex = collapsingItemIndex + collapsingItem.getVisibleItemCount();

+

+	if (collapsingItemIndex == -1) {					// is the collapsing item in a collapsed subtree?

+		return false;									// then neither it nor its children are selected

+	}

+	while (selection.hasMoreElements() == true) {

+		item = (TreeItem) selection.nextElement();

+		selectedItemIndex = item.getVisibleIndex();

+		if ((selectedItemIndex > collapsingItemIndex) &&

+			(selectedItemIndex <= lastCollapsedItemIndex)) {

+			return true;

+		}

+	}

+	return false;

+}

+/**

+ * Test whether the mouse click specified by 'event' was a 

+ * valid selection or expand/collapse click.

+ * @return 

+ *  One of ActionExpandCollapse, ActionSelect, ActionNone, ActionCheck

+ *	specifying the action to be taken on the click.

+ */

+int itemAction(TreeItem item, int x, int y) {

+	int action = ActionNone;

+	int itemHeight = getItemHeight();

+	int offsetX;

+	int offsetY;

+	Point offsetPoint;

+

+	if (item != null) {

+		offsetX = x - item.getPaintStartX();

+		offsetY = y - itemHeight * (y / itemHeight);	

+		offsetPoint = new Point(offsetX, offsetY);	

+		if ((item.isLeaf() == false) &&

+			(getHierarchyIndicatorRect().contains(offsetPoint) == true)) {

+			action |= ActionExpandCollapse;

+		}

+		else

+		if (item.isSelectionHit(offsetPoint) == true) {

+			action |= ActionSelect;

+		}

+		else

+		if (item.isCheckHit(new Point(x, y)) == true) {

+			action |= ActionCheck;

+		}

+	}

+	return action;

+}

+/**

+ * The table item 'changedItem' has changed. Redraw the whole 

+ * item in that column. Include the text in the redraw because 

+ * an image set to null requires a redraw of the whole item anyway. 

+ */

+void itemChanged(SelectableItem changedItem, int repaintStartX, int repaintWidth) {

+	int oldItemHeight = getItemHeight();	

+	Point oldImageExtent = getImageExtent();

+	

+	if (isExpandingItem(changedItem) == false) {

+		super.itemChanged(changedItem, repaintStartX, repaintWidth);

+	}

+	else {

+		calculateItemHeight(changedItem);

+	}

+	if ((oldItemHeight != getItemHeight()) ||			// only reset items if the item height or

+		(oldImageExtent != getImageExtent())) {			// image size has changed. The latter will only change once, 

+														// from null to a value-so it's safe to test using !=

+		getRoot().reset();								// reset cached data of all items in the receiver

+		resetHierarchyIndicatorRect();

+		redraw();										// redraw all items if the image extent has changed. Fixes 1FRIHPZ		

+	}

+	else {

+		((AbstractTreeItem) changedItem).reset();		// reset the item that has changed when the tree item 

+														// height has not changed (otherwise the item caches old data)

+														// Fixes 1FF6B42

+	}

+	if (repaintWidth != 0) {

+		calculateWidestShowingItem();

+		claimRightFreeSpace();								// otherwise scroll bar may be reset, but not horizontal offset

+															// Fixes 1G4SBJ3

+	}

+}

+/**

+ * A key was pressed.

+ * Call the appropriate key handler method.

+ * @param event - the key event

+ */

+void keyDown(Event event) {

+	super.keyDown(event);

+	switch (event.character) {

+		case '+':

+			doPlus();

+			break;

+		case '-':

+			doMinus();

+			break;

+		case '*':

+			doAsterix();

+			break;

+	}

+}

+

+/**

+ * A mouse double clicked occurred over the receiver.

+ * Expand/collapse the clicked item. Do nothing if no item was clicked.

+ */

+void mouseDoubleClick(Event event) {

+	int hitItemIndex = event.y / getItemHeight();

+	TreeItem hitItem = getRoot().getVisibleItem(hitItemIndex + getTopIndex());

+	Event newEvent;

+	

+	if (hitItem == null || itemAction(hitItem, event.x, event.y) != ActionSelect) {

+		return;

+	}

+	if (hooks(SWT.DefaultSelection) == true) {

+		newEvent = new Event();

+		newEvent.item = hitItem;

+		notifyListeners(SWT.DefaultSelection, newEvent);

+	}

+	else

+	if (hitItem.isLeaf() == false) {		// item with children was hit. Default behavior is expand/collapse item

+		if (hitItem.getExpanded() == true) {

+			collapse(hitItem, true);

+		}

+		else {

+			expand(hitItem, true);

+		}

+	}

+}

+/**

+ * The mouse pointer was pressed down on the receiver.

+ * Handle the event according to the position of the mouse click.

+ */

+void mouseDown(Event event) {

+	int hitItemIndex;

+	TreeItem hitItem;

+	SelectableItem selectionItem = getLastSelection();

+	int itemAction;

+

+	if (event.button != 1) {		// only react to button one clicks.

+		return;

+	}

+	hitItemIndex = event.y / getItemHeight();

+	hitItem = getRoot().getVisibleItem(hitItemIndex + getTopIndex());

+	if (hitItem == null) {

+		return;

+	}

+	switch (itemAction = itemAction(hitItem, event.x, event.y)) {

+		case ActionExpandCollapse:

+			if (hitItem.getExpanded() == true) {

+				collapse(hitItem, true);

+			}

+			else {

+				expand(hitItem, true);

+			}

+			break;

+		case ActionSelect:

+			doMouseSelect(hitItem, hitItemIndex + getTopIndex(), event.stateMask, event.button);

+			break;

+		case ActionCheck:

+			doCheckItem(hitItem);

+			break;

+	}

+	if (itemAction != ActionSelect && selectionItem == null) {

+		selectionItem = getRoot().getVisibleItem(getTopIndex());	// select the top item if no item was selected before

+		selectNotify(selectionItem);								

+	}

+}

+/**

+ * A paint event has occurred. Display the invalidated items.

+ * @param event - expose event specifying the invalidated area.

+ */

+void paint(Event event) {

+	int visibleRange[] = getIndexRange(event.getBounds());

+	

+	paintItems(event.gc, visibleRange[0], visibleRange[1] + 1); // + 1 to paint the vertical line 

+																// connection the last item we really 

+																// want to paint with the item after that.

+}

+/**

+ * Paint tree items on 'gc' starting at index 'topPaintIndex' and 

+ * stopping at 'bottomPaintIndex'.

+ * @param gc - GC to draw tree items on.

+ * @param topPaintIndex - index of the first item to draw

+ * @param bottomPaintIndex - index of the last item to draw 

+ */

+void paintItems(GC gc, int topPaintIndex, int bottomPaintIndex) {

+	TreeItem visibleItem;

+	int itemHeight = getItemHeight();

+

+	for (int i = topPaintIndex; i <= bottomPaintIndex; i++) {

+		visibleItem = getRoot().getVisibleItem(i + getTopIndex());

+		if (visibleItem != null) {

+			visibleItem.paint(gc, i * itemHeight);

+		}

+	}

+}

+/**

+ * 'item' has been added to or removed from the receiver. 

+ * Repaint part of the tree to update the vertical hierarchy 

+ * connectors and hierarchy image.

+ * @param modifiedItem - the added/removed item 

+ * @param modifiedIndex - index of the added/removed item

+ */

+void redrawAfterModify(SelectableItem modifiedItem, int modifiedIndex) {

+	int redrawStartY;

+	int redrawStopY;

+	int itemChildIndex = ((TreeItem) modifiedItem).getIndex();

+	int topIndex = getTopIndex();

+	int itemHeight = getItemHeight();

+	int redrawItemIndex;

+	int itemCount;

+	AbstractTreeItem parentItem = ((TreeItem) modifiedItem).getParentItem();

+	AbstractTreeItem redrawItem = null;

+

+	if (redrawParentItem(modifiedItem) == false) {

+		return;

+	}

+	if (parentItem == null) {							// a root item is added/removed

+		parentItem = getRoot();

+	}

+	itemCount = parentItem.getItemCount();

+	// redraw hierarchy decorations of preceeding item if the last item at a tree 

+	// level was added/removed

+	// otherwise, if the first item was removed, redraw the parent to update hierarchy icon

+	if (itemChildIndex > 0) {							// more than one item left at this tree level

+		// added/removed last item at this tree level? have to test >=.

+		// when removing last item, item index is outside itemCount 

+		if (itemChildIndex >= itemCount - 1) { 

+			redrawItem = (AbstractTreeItem) parentItem.getChildren().elementAt(itemChildIndex - 1);

+		}

+	}

+	else 

+	if (getVisibleItemCount() > 0 && itemCount < 2) {	// last item at this level removed/first item added?

+		redrawItem = parentItem;						// redraw parent item to update hierarchy icon

+	}

+	if (redrawItem != null) {

+		redrawItemIndex = redrawItem.getVisibleIndex();

+		if (modifiedIndex == -1) {

+			modifiedIndex = redrawItemIndex + 1;

+		}

+		redrawStartY = (redrawItemIndex - topIndex) * itemHeight;

+		redrawStopY = (modifiedIndex - topIndex) * itemHeight;

+		redraw(

+			0, 

+			redrawStartY, 

+			redrawItem.getCheckboxXPosition(), 			// only redraw up to and including hierarchy icon to avoid flashing

+			redrawStopY - redrawStartY, false);

+	}	

+	if (modifiedIndex == 0) {											// added/removed first item ?

+		redraw(0, 0, getClientArea().width, getItemHeight() * 2, false);// redraw new first two items to 

+																		// fix vertical hierarchy line

+	}

+}

+

+/**

+ * Determine if part of the tree hierarchy needs to be redrawn.

+ * The hierarchy icon of the parent item of 'item' needs to be redrawn if 

+ * 'item' is added as the first child or removed as the last child.

+ * Hierarchy lines need to be redrawn if 'item' is the last in a series of 

+ * children.

+ * @param item - tree item that is added or removed.

+ * @return true=tree hierarchy needs to be redrawn. false=no redraw necessary

+ */

+boolean redrawParentItem(SelectableItem item) {

+	TreeItem parentItem = ((TreeItem) item).getParentItem();

+	TreeItem parentItem2; 

+	boolean redraw = false;

+

+	// determine if only the hierarchy icon needs to be redrawn

+	if (parentItem != null) {

+		parentItem2 = parentItem.getParentItem();

+		if ((parentItem2 == null || parentItem2.getExpanded() == true) && parentItem.getChildren().size() < 2) {

+			redraw = true;

+		}

+	}

+	// redraw is only neccessary when the receiver is not currently	

+	// expanding 'item' or a parent item or if the parent item is expanded 

+	// or if the hierarchy icon of the parent item needs to be redrawn

+	if (isExpandingItem(item) == false && parentItem == null || parentItem.getExpanded() == true || redraw == true) {

+		redraw = true;

+	}

+	else {

+		redraw = false;

+	}

+	return redraw;

+}

+

+/**
+ * Removes all of the items from the receiver.
+ * <p>
+ * @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 removeAll() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	setRedraw(false);

+	getRoot().dispose();

+	resetRoot();

+	reset();

+	calculateWidestShowingItem();

+	calculateVerticalScrollbar();

+	setRedraw(true);	

+}

+/** 

+ * Remove 'item' from the receiver. 

+ * @param item - tree item that should be removed from the 

+ *	receiver-must be a root item.

+ */

+void removeItem(TreeItem item) {

+	getRoot().removeItem(item);

+}

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's selection changes.
+ *
+ * @param listener the listener which should no longer 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 SelectionListener
+ * @see #addSelectionListener
+ */

+public void removeSelectionListener(SelectionListener listener) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (listener == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}	

+	removeListener (SWT.Selection, listener);

+	removeListener (SWT.DefaultSelection, listener);	

+}

+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when items in the receiver are expanded or collapsed..
+ *
+ * @param listener the listener which should no longer 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 TreeListener
+ * @see #addTreeListener
+ */

+public void removeTreeListener(TreeListener listener) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (listener == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	removeListener (SWT.Expand, listener);

+	removeListener (SWT.Collapse, listener);

+}

+/**

+ * 'item' has been removed from the receiver. 

+ * Recalculate the content width.

+ */

+void removedItem(SelectableItem item) {

+	if (isExpandingItem(item) == false) {

+		super.removedItem(item);				

+	}	

+	calculateWidestShowingItem();

+	claimRightFreeSpace();

+}

+/**

+ * Notification that 'item' is about to be removed from the tree.

+ * Update the item selection if neccessary.

+ * @param item - item that is about to be removed from the tree.

+ */

+void removingItem(SelectableItem item) {

+	Vector selection = getSelectionVector();

+	TreeItem parentItem = ((TreeItem) item).getParentItem();

+	TreeItem newSelectionItem = null;

+	boolean isLastSelected = (selection.size() == 1) && (selection.elementAt(0) == item);

+	int itemIndex = getVisibleIndex(item);

+	

+	if (isLastSelected == true) {

+		// try selecting the following item

+		newSelectionItem = (TreeItem) getVisibleItem(itemIndex + 1);

+		if (newSelectionItem == null || newSelectionItem.getParentItem() != parentItem) {

+			// select parent item if there is no item following the removed  

+			// one on the same tree level

+			newSelectionItem = parentItem;

+		}

+		if (newSelectionItem != null) {

+			selectNotify(newSelectionItem, true);

+		}

+	}

+	super.removingItem(item);

+	if (isExpandingItem(item) == false) {

+		// redraw plus/minus image, hierarchy lines,

+		// redrawing here assumes that no update happens between now and 

+		// after the item has actually been removed. Otherwise this call 

+		// would need to be in removedItem and we would need to store the

+		// "itemIndex" here to redraw correctly.

+		redrawAfterModify(item, itemIndex);

+	}	

+}

+/**

+ * Reset the rectangle enclosing the hierarchy indicator to null.

+ * Forces a recalculation next time getHierarchyIndicatorRect is called.

+ */

+void resetHierarchyIndicatorRect() {

+	hierarchyIndicatorRect = null;

+}

+/**

+ * Reset state that is dependent on or calculated from the items

+ * of the receiver.

+ */

+void resetItemData() {

+	setContentWidth(0);

+	resetHierarchyIndicatorRect();	

+	super.resetItemData();	

+}

+/**

+ * Reset the object holding the root items of the receiver.

+ */

+void resetRoot() {

+	root = new TreeRoots(this);

+}

+/**

+ * The receiver has been resized. Recalculate the content width.

+ */

+void resize(Event event) {

+	int oldItemCount = getVerticalBar().getPageIncrement();

+

+	super.resize(event);

+	if (getItemCountWhole() > oldItemCount) {		// window resized higher?

+		calculateWidestShowingItem();				// recalculate widest item since a longer item may be visible now

+	}

+}

+/**

+ * Display as many expanded tree items as possible.

+ * Scroll the last expanded child to the bottom if all expanded 

+ * children can be displayed.

+ * Otherwise scroll the expanded item to the top.

+ * @param item - the tree item that was expanded

+ */

+void scrollExpandedItemsIntoView(TreeItem item) {

+	int itemCountOffScreen = getOffScreenItemCount(item);

+	int newTopIndex = getTopIndex() + itemCountOffScreen;

+

+	if (itemCountOffScreen > 0) {

+		newTopIndex = Math.min(item.getVisibleIndex(), newTopIndex);	// make sure the expanded item is never scrolled out of view

+		setTopIndex(newTopIndex, true);								

+	}

+}

+/**

+ * Scroll the items following the children of 'collapsedItem'

+ * below 'collapsedItem' to cover the collapsed children.

+ * @param collapsedItem - item that has been collapsed

+ */

+void scrollForCollapse(TreeItem collapsedItem) {

+	Rectangle clientArea = getClientArea();	

+	int topIndex = getTopIndex();

+	int itemCount = collapsedItem.getVisibleItemCount();

+	int scrollYPositions[] = calculateChildrenYPos(collapsedItem);

+

+	if (scrollYPositions[0] == -1 && scrollYPositions[1] == -1) {

+		return;

+	}

+	if (topIndex + getItemCountWhole() == getVisibleItemCount() && itemCount < topIndex) {

+		// scroll from top if last item is at bottom and will stay at 

+		// bottom after collapse. Avoids flash caused by too much bit 

+		// blitting (which force update and thus premature redraw)

+		int height = scrollYPositions[1] - scrollYPositions[0];

+		scroll(

+			0, 0,					// destination x, y

+			0, -height,				// source x, y		

+			clientArea.width, scrollYPositions[0]+height, true);

+		setTopIndexNoScroll(topIndex - itemCount, true);

+	}	

+	else {

+		scroll(

+			0, scrollYPositions[0],				// destination x, y

+			0, scrollYPositions[1],				// source x, y		

+			clientArea.width, clientArea.height - scrollYPositions[0], true);

+	}

+}

+/**

+ * Scroll the items following 'expandedItem' down to make 

+ * space for the children of 'expandedItem'.

+ * @param expandedItem - item that has been expanded.

+ */

+void scrollForExpand(TreeItem expandedItem) {

+	int scrollYPositions[];

+	Rectangle clientArea = getClientArea();

+

+	expandedItem.internalSetExpanded(true);		

+	scrollYPositions = calculateChildrenYPos(expandedItem);	

+	expandedItem.internalSetExpanded(false);	

+	if (scrollYPositions[0] == -1 && scrollYPositions[1] == -1) {

+		return;

+	}	

+	scroll(

+		0, scrollYPositions[1],				// destination x, y

+		0, scrollYPositions[0],				// source x, y

+		clientArea.width, clientArea.height, true);

+}

+/**

+ * Scroll horizontally by 'numPixel' pixel.

+ * @param numPixel - the number of pixel to scroll

+ *	< 0 = columns are going to be moved left.

+ *	> 0 = columns are going to be moved right.

+ */

+void scrollHorizontal(int numPixel) {

+	Rectangle clientArea = getClientArea();

+

+	scroll(

+		numPixel, 0, 								// destination x, y

+		0, 0, 										// source x, y

+		clientArea.width, clientArea.height, true);

+}

+/**

+ * Scroll vertically by 'scrollIndexCount' items.

+ * @param scrollIndexCount - the number of items to scroll.

+ *	scrollIndexCount > 0 = scroll up. scrollIndexCount < 0 = scroll down

+ */

+void scrollVertical(int scrollIndexCount) {

+	Rectangle clientArea = getClientArea();

+

+	scroll(

+		0, 0, 										// destination x, y

+		0, scrollIndexCount * getItemHeight(),		// source x, y

+		clientArea.width, clientArea.height, true);

+}

+/**
+ * Selects all the items in the receiver.
+ *
+ * @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 selectAll() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Vector selection = getSelectionVector();

+

+	if (isMultiSelect() == true) {

+		selection = getRoot().selectAll(selection);

+		setSelectionVector(selection);

+	}

+}

+/**

+ * Set the item that is currently being expanded to 'item'.

+ * Used for performance optimizations.

+ */

+void setExpandingItem(TreeItem item) {

+	expandingItem = item;

+}

+public void setFont(Font font) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Stack children = new Stack();						// traverse the tree depth first

+	Enumeration elements;

+	AbstractTreeItem item;

+

+	if (font != null && font.equals(getFont()) == true) {

+		return;

+	}

+	setRedraw(false);									// disable redraw because itemChanged() triggers undesired redraw

+	resetItemData();	

+	super.setFont(font);

+

+	// Call itemChanged for all tree items

+	elements = getRoot().getChildren().elements();

+	while (elements.hasMoreElements() == true) {

+		children.push(elements.nextElement());

+	}			

+	while (children.empty() == false) {

+		item = (AbstractTreeItem) children.pop();

+		itemChanged(item, 0, getClientArea().width);

+		elements = item.getChildren().elements();

+		while (elements.hasMoreElements() == true) {

+			children.push(elements.nextElement());

+		}			

+	}

+	setRedraw(true);									// re-enable redraw

+}

+/**
+ * Display a mark indicating the point at which an item will be inserted.
+ * The drop insert item has a visual hint to show where a dragged item 
+ * will be inserted when dropped on the tree.
+ * 
+ * @param item the insert item.  Null will clear the insertion mark.
+ * @param after true places the insert mark above 'item'. false places 
+ *	the insert mark below 'item'.
+ *
+ * @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 setInsertMark(TreeItem item, boolean before){

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	motif_setInsertMark(item, !before);

+}

+/**
+ * Sets the receiver's selection to be the given array of items.
+ * The current selected is first cleared, then the new items are
+ * selected.
+ *
+ * @param items the array of items
+ *
+ * @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 Tree#deselectAll()
+ */

+public void setSelection(TreeItem selectionItems[]) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	if (selectionItems == null)  {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}	

+	setSelectableSelection(selectionItems);

+}

+/**

+ * Set the index of the first visible item in the tree client area 

+ * to 'index'.

+ * Scroll the new top item to the top of the tree.

+ * @param index - 0-based index of the first visible item in the 

+ *	tree's client area.

+ * @param adjustScrollbar - 

+ *	true = the vertical scroll bar is set to reflect the new top index.

+ *	false = the vertical scroll bar position is not modified.

+ */

+void setTopIndex(int index, boolean adjustScrollbar) {

+	int indexDiff = index-getTopIndex();

+

+	super.setTopIndex(index, adjustScrollbar);

+	calculateWidestScrolledItem(indexDiff);

+}

+/**
+ * Shows the item.  If the item is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled
+ * and expanded until the item is visible.
+ *
+ * @param item the item to be shown
+ *
+ * @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 Tree#showSelection()
+ */

+public void showItem(TreeItem item) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (item == null)  {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}	

+	showSelectableItem(item);

+}

+/**

+ * Make 'item' visible by expanding its parent items and scrolling 

+ * it into the receiver's client area if necessary.

+ * An SWT.Expand event is going to be sent for every parent item 

+ * that is expanded to make 'item' visible.

+ * @param item - the item that should be made visible to the

+ *	user.

+ */

+void showSelectableItem(SelectableItem item) {

+	if (item.getSelectableParent() != this) {

+		return;

+	}

+	if (((TreeItem) item).isVisible() == false) {

+		((TreeItem) item).makeVisible();

+	}

+	super.showSelectableItem(item);

+}

+/**
+ * Returns the item at the given point in the receiver
+ * or null if no such item exists. The point is in the
+ * coordinate system of the receiver.
+ *
+ * @param point the point used to locate the item
+ * @return the item at the given point
+ *
+ * @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>
+ */

+public TreeItem getItem(Point point) {

+	int itemHeight;

+	int hitItemIndex;

+	TreeItem hitItem;

+

+	if (getClientArea().contains(point) == false) {

+		return null;

+	}	

+	itemHeight = getItemHeight();

+	hitItemIndex = point.y / itemHeight;

+	hitItem = getRoot().getVisibleItem(hitItemIndex + getTopIndex());

+	if (hitItem != null) {

+		point.x -= hitItem.getPaintStartX();

+		point.y -= itemHeight * hitItemIndex;			

+		if (hitItem.isSelectionHit(point) == false) {

+			hitItem = null;

+		}

+	}

+	return hitItem;

+}

+/**
+ * Returns the number of selected items contained in the receiver.
+ *
+ * @return the number of selected items
+ *
+ * @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 getSelectionCount() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return super.getSelectionCount();

+}

+/**
+ * Shows the selection.  If the selection is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled until
+ * the selection is visible.
+ *
+ * @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 Tree#showItem(TreeItem)
+ */

+public void showSelection() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	super.showSelection();

+}

+

+}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeItem.java
new file mode 100755
index 0000000..e19494c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeItem.java
@@ -0,0 +1,1198 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+ 

+import org.eclipse.swt.*;

+import org.eclipse.swt.graphics.*;

+import java.util.*;

+ 

+/**
+ * Instances of this class represent a selectable user interface object
+ * that represents a hierarchy of tree items in a tree widget.
+ * 
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */

+public /*final*/ class TreeItem extends AbstractTreeItem {

+/*

+ * This class caches geometric data for drawing.

+ * A description of the cached data follows:

+ *

+ *  |      1    ||      5        |  

+ *  |  2  |               |   6  |   

+ *  |3                          7|  

+ *   _____  | 4 |f|          |8      

+ *  |     |                            ____

+ *  |  -  | ===== {image}    root      9

+ *  |_____|          |

+ *                       |b|c|  |d|

+ *               | e |

+ * 

+ * Widths are measured between vertical lines.

+ *

+ * Cached item rendering data:

+ * 1 = getDecorationsWidth

+ * 2 = getHierarchyIndicatorRect

+ * 3 = getPaintStartX

+ * 4 = getItemConnectorWidth

+ * 5 = getItemWidth

+ * 6 = getSelectionWidth

+ * 7 = getPaintStopX

+ * 8 - getTextXPos

+ * 9 = getTextYPosition

+ *

+ * Rendering constants:

+ * 4 = DEFAULT_ITEM_CONNECTOR_WIDTH, used when no image is set in the tree.

+ *	Otherwise it is the image width.

+ * b = IMAGE_PADDING

+ * c = TEXT_INDENT

+ * d = SELECTION_PADDING

+ * e = ITEM_NOIMAGE_OFFSET

+ * f = ITEM_CONNECTOR_PADDING;

+ */

+	private static final int DEFAULT_ITEM_CONNECTOR_WIDTH = 8;	// Default width of the horizontal line connecting 

+															// items with the vertical lines. Only used when

+															// no image is set in the tree. Normally connector 

+															// line width is half the image width.

+	private static final int ITEM_CONNECTOR_PADDING = 2;	// Added to the calculated item connector width

+	private static final int IMAGE_PADDING = 3;				// Space behind bitmap

+	private static final int ITEM_NOIMAGE_OFFSET = 8;		// Offset added to the calculated paint position where 

+															// an item starts drawing. To be used when no item 

+															// image has been set. Otherwise children would start 

+															// drawing at the end of the horizontal item connector 

+															// of their parent.

+	private static final int ROOT_INDENT = 5;				// Indent of root items

+	private static final int SELECTION_PADDING = 2;			// Space behind text

+	private static final int TEXT_INDENT = 2;				// Identation of the item label

+	

+	// basic item info

+	private TreeItem parentItem;

+	private int index;										// index in the parent item

+	

+	// geometrical item info

+	private int paintStartX = -1;							// X coordinate of the upper-left corner of the 

+															// receivers bounding rectangle

+	private Point itemExtent;								// Size of the item (image + label)

+	private Point imageExtent;								// original size of the item image	

+	private int textYPosition = -1;							// Centered y position of the item text	

+/**

+ * Create a root item and add it to the tree widget identified

+ * by 'parent'.

+ * @param parent - Tree widget the receiver is added to

+ * @param swtStyle - widget style. see Widget class for details

+ */

+public TreeItem(Tree parent, int swtStyle) {

+	this(parent, swtStyle, checkNull(parent).getItemCount());

+}

+/**

+ * Create a root item and add it to the tree widget identified

+ * by 'parent'.

+ * @param parent - Tree widget the receiver is added to.

+ * @param swtStyle - widget style. see Widget class for details

+ * @param position - position in 'parentItem' the receiver will 

+ *	be inserted at 

+ */

+public TreeItem(Tree parent, int swtStyle, int position) {

+	super(parent, swtStyle);

+	parent.addItem(this, position);

+}

+/**

+ * Create a root item with 'parentItem' as the parent item.

+ * @param parentItem - the parent item of the receiver

+ * @param swtStyle - widget style. see Widget class for details

+ */

+public TreeItem(TreeItem parentItem, int swtStyle) {

+	this(parentItem, swtStyle, checkNull(parentItem).getItemCount());

+}

+/**

+ * Create a root item with 'parentItem' as the parent item.

+ * @param parentItem - the parent item of the receiver

+ * @param swtStyle - widget style. see Widget class for details

+ * @param position - position in 'parentItem' the receiver will 

+ *	be inserted at 

+ */

+public TreeItem(TreeItem parentItem, int swtStyle, int position) {

+	super(checkNull(parentItem).getParent(), swtStyle);

+	setParentItem(parentItem);	

+	parentItem.add(this, position);

+}

+/**

+ * Calculate the number of expanded children.

+ * Recurse up in the tree to the root item.

+ */

+void calculateVisibleItemCount() {

+	Vector children;

+	TreeItem child;

+	int visibleItemCount = 0;

+	

+	// check isExpanded field directly for performance

+	if (internalGetExpanded() == true) {

+		children = getChildren();

+		visibleItemCount = children.size();

+		for (int i = 0; i < children.size(); i++) {

+			child = (TreeItem) children.elementAt(i);

+			visibleItemCount += child.getVisibleItemCount();

+		}

+	}

+	setVisibleItemCount(visibleItemCount);

+	calculateVisibleItemCountParent();

+}

+/**

+ * Calculate the number of expanded children for the parent item

+ * of this item.

+ */

+void calculateVisibleItemCountParent() {

+	TreeItem parentItem = getParentItem();

+

+	if (parentItem != null) {

+		parentItem.calculateVisibleItemCount();

+	}

+	else {

+		getParent().getRoot().calculateVisibleItemCount();

+	}

+}

+/**

+ * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'tree' is null.

+ * Otherwise return 'tree'

+ */

+static Tree checkNull(Tree tree) {

+	if (tree == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

+	return tree;

+}

+/**

+ * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'item' is null.

+ * Otherwise return 'item'

+ */

+static TreeItem checkNull(TreeItem item) {

+	if (item == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

+	return item;

+}

+protected void checkSubclass () {

+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);

+}

+

+/**

+ * Draw the hierarchy indicator at 'position'.

+ *

+ * Note:

+ * Assumes that the hierarchy indicators for the expanded and 

+ * collapsed state are the same size.

+ * @param gc - GC to draw on. 

+ * @param position - position on the GC to draw at.

+ * @return position to continue drawing 

+ */

+Point drawHierarchyIndicator(GC gc, Point position) {

+	Tree parent = getParent();

+	Image hierarchyImage;

+	Rectangle indicatorRectangle = parent.getHierarchyIndicatorRect();

+	int x = position.x;

+	int y = position.y;

+	int yCenter = y + parent.getItemHeight() / 2;

+	Point connectorLinePosition;	

+

+	if (isLeaf() == false) {

+		if (getExpanded() == true) {

+			hierarchyImage = parent.getExpandedImage();

+		}

+		else {

+			hierarchyImage = parent.getCollapsedImage();

+		}

+		if (hierarchyImage != null) {

+			gc.drawImage(hierarchyImage, x + indicatorRectangle.x, y + indicatorRectangle.y);

+		}

+		connectorLinePosition = new Point(x + indicatorRectangle.width, yCenter);		

+	}	

+	else {

+		connectorLinePosition = new Point(

+			x + indicatorRectangle.width / 2 				

+			+ indicatorRectangle.width % 2, yCenter);		// % 2 in order to not start the next hierarchy 

+															// component at the middle of the icon but after.	

+	}

+	return connectorLinePosition;

+}

+/**

+ * Draw a horizontal line connecting the item image (or label 

+ * if there is no image) to the vertical line connecting to 

+ * the parent.

+ * @param gc - GC to draw on. 

+ * @param position - position on the GC to draw at.

+ * @return position to continue drawing 

+ */

+Point drawHorizontalItemConnector(GC gc, Point position) {

+	int itemConnectorEndPos = position.x + getItemConnectorWidth() - 1;	// -1 because the position of the last pixel needs to be calculated

+

+	gc.drawLine(position.x, position.y, itemConnectorEndPos, position.y);

+	return new Point(itemConnectorEndPos + 1, position.y);		// + 1 in order to resume drawing after line not on end of line

+}

+/** 

+ * Display the item image at 'position' using 'gc'.

+ * @param gc - GC to draw on

+ * @param position - position on the GC to draw at

+ * @return position to continue drawing 

+ */

+Point drawImage(GC gc, Point destinationPosition) {

+	Tree parent = getParent();

+	Image image = getImage();

+	Point sourceImageExtent;

+	Point destinationImageExtent = parent.getImageExtent();

+	int yCenter;

+	

+	if (image != null) {

+		sourceImageExtent = getImageExtent();

+		yCenter = (parent.getItemHeight() - destinationImageExtent.y) / 2;

+		gc.drawImage(

+			image, 

+			0, 0, 														// source x, y

+			sourceImageExtent.x, sourceImageExtent.y,					// source width, height

+			destinationPosition.x, destinationPosition.y + yCenter,		// destination x, y

+			destinationImageExtent.x, destinationImageExtent.y);		// destination width, height

+	}

+	if (destinationImageExtent != null) {

+		destinationPosition.x += destinationImageExtent.x + IMAGE_PADDING;

+	}

+	return destinationPosition;

+}

+/**

+ * Draw a filled rectangle indicating the item selection state

+ * The rectangle will be filled with the selection color if the 

+ * receiver is selected. Otherwise the rectangle will be filled

+ * in the background color to remove the selection.

+ * @param gc - GC to draw on. 

+ * @param position - position on the GC to draw at.

+ */

+void drawSelection(GC gc, Point position) {

+	Tree parent = getParent();

+	Point selectionExtent = getSelectionExtent();

+

+	if (selectionExtent == null) {

+		return;

+	}

+	if (isSelected() == true) {

+		gc.setBackground(getSelectionBackgroundColor());

+	}

+	gc.fillRectangle(position.x, position.y, selectionExtent.x, selectionExtent.y);

+	if (isSelected() == true) {

+		gc.setBackground(parent.getBackground());

+	}

+}

+/**

+ * Draw a rectangle enclosing the item label. The rectangle

+ * indicates that the receiver was selected last and that it has

+ * the input focus.

+ * The rectangle will only be drawn if the receiver is selected.

+ * @param gc - GC to draw on. 

+ * @param position - position on the GC to draw at.

+ */

+void drawSelectionFocus(GC gc, Point position) {

+	Point selectionExtent = getSelectionExtent();

+

+	if (selectionExtent == null) {

+		return;

+	}

+	if (getParent().hasFocus(this) == true) {

+		gc.drawFocus(

+			position.x, position.y, 

+			selectionExtent.x, selectionExtent.y);

+	}

+}

+/** 

+ * Draw the item label at 'position' using 'gc'.

+ * @param gc - GC to draw on. 

+ * @param position - position on the GC to draw at.

+ */

+void drawText(GC gc, Point position) {

+	Tree parent = getParent();

+	String text = getText();

+	

+	if (text != null) {

+		if (isSelected() == true) {

+			gc.setBackground(getSelectionBackgroundColor());

+			gc.setForeground(getSelectionForegroundColor());

+		}

+		gc.drawString(text, position.x, position.y);

+		if (isSelected() == true) {

+			gc.setBackground(parent.getBackground());

+			gc.setForeground(parent.getForeground());

+		}

+	}

+}

+/**

+ * Draw a vertical line connecting the horizontal connector line 

+ * with that of the previous item.

+ * Called recursively to draw the lines on all tree levels.

+ * @param gc - GC to draw on. 

+ * @param yPosition - y position of the upper side of the 

+ *	receiver's bounding box.

+ * @param isFirstChild - method is called to draw a vertical 

+ *	line for the first child. Leave room for the hierarchy icon.

+ */

+void drawVerticalItemConnector(GC gc, int yPosition, boolean isFirstChild) {

+	Tree parent = getParent();

+	TreeItem nextDrawItem = getParentItem();

+	AbstractTreeItem parentItem = nextDrawItem;

+	Rectangle indicatorRectangle = parent.getHierarchyIndicatorRect();

+	int itemHeight = parent.getItemHeight();	

+	int itemHeightDiv2 = itemHeight / 2 + itemHeight % 2;

+	int indicatorHeightDiv2 = indicatorRectangle.height / 2 + indicatorRectangle.height % 2;

+	int lineX = getPaintStartX() + indicatorRectangle.width / 2;

+	int lineStartY = yPosition - itemHeightDiv2;	

+	int lineEndY = yPosition + itemHeightDiv2;

+

+	if (parentItem == null) {

+		parentItem = parent.getRoot();

+	}

+	if (getIndex() != parentItem.getItemCount()-1) {		// if item is not the last child

+		if (isFirstChild == true) {

+			lineStartY += indicatorHeightDiv2;				// leave space for the hierarchy image

+		}	

+		gc.drawLine(lineX, lineStartY, lineX, lineEndY);

+	}

+	

+	if (nextDrawItem != null) {

+		nextDrawItem.drawVerticalItemConnector(gc, yPosition, false);

+	}	

+}

+/**

+ * Draw a vertical line connecting the horizontal connector line

+ * with that of the previous item.

+ * Do this on all tree levels up to the root level.

+ * @param gc - GC to draw on. 

+ * @param position - position on the GC to draw at.

+ * @return position to continue drawing 

+ */

+Point drawVerticalItemConnector(GC gc, Point position) {

+	Tree parent = getParent();

+	TreeItem parentItem = getParentItem();	

+	Rectangle indicatorRectangle = parent.getHierarchyIndicatorRect();

+	int itemHeight = parent.getItemHeight();

+	int itemHeightDiv2 = itemHeight / 2 + itemHeight % 2;

+	int indicatorHeightDiv2 = indicatorRectangle.height / 2 + indicatorRectangle.height % 2;

+	int lineX = position.x + indicatorRectangle.width / 2;

+	int lineStartY = position.y - itemHeightDiv2;	

+	int lineEndY = position.y + itemHeightDiv2 - itemHeight % 2;

+	TreeItem predecessor;

+	boolean isFirstChild = false;

+

+	if (isRoot() == true) {

+		if (getIndex() == 0) {

+			return position;									// first root, don't draw vertical line

+		}

+	}

+	else	

+	if (getIndex() == 0) {										// if item is first child

+		lineStartY += itemHeightDiv2;

+		isFirstChild = true;

+	}

+	predecessor = getPredecessor();

+	if (predecessor != null && predecessor.isLeaf() == false) {

+		lineStartY += indicatorHeightDiv2;						// leave space for the hierarchy image

+	}

+	if (isLeaf() == false) {

+		lineEndY -= indicatorHeightDiv2;

+	}

+	gc.drawLine(lineX, lineStartY, lineX, lineEndY);

+	if (parentItem != null) {

+		parentItem.drawVerticalItemConnector(gc, position.y, isFirstChild);

+	}

+	return position;

+}

+

+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent.
+ *
+ * @return the receiver's bounding 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() {

+	if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);

+	Tree parent = getParent();

+	Point extent = getItemExtent();

+	int x = getTextXPos() - TEXT_INDENT;

+	

+	return new Rectangle(x, parent.getRedrawY(this), extent.x - (x - getItemStartX()), extent.y);	

+}

+

+/**

+ * Answer the x position of the item check box

+ */

+int getCheckboxXPosition() {

+	return getPaintStartX() + getDecorationsWidth();

+}

+/**

+ * Answer the combined width of the hierarchy indicator and 

+ * the horizontal item connector line.

+ */

+int getDecorationsWidth() {

+	int indicatorWidth = getParent().getHierarchyIndicatorRect().width;

+	int width = indicatorWidth + getItemConnectorWidth();

+

+	if (isLeaf() == true) {

+		width -= indicatorWidth / 2;

+	}

+	return width;

+}

+/**

+ * Answer the index of the receiver relative to the first root 

+ * item.

+ * @return

+ *	The index of the receiver relative to the first root item.

+ */

+int getGlobalIndex() {

+	int globalItemIndex = getIndex();

+	AbstractTreeItem item = null;

+

+	if (isRoot() == false) {

+		item = getParentItem();

+		globalItemIndex++;						// adjust for 0-based non-root items

+	}

+	else {	

+		item = getParent().getRoot();

+	}

+

+	globalItemIndex += item.getVisibleIndex(getIndex());

+	return globalItemIndex;

+}

+/**

+ * Answer the original size of the image of the receiver.

+ */

+Point getImageExtent() {

+	Image image = getImage();

+	Rectangle imageBounds;

+	

+	if (imageExtent == null && image != null) {

+		imageBounds = image.getBounds();

+		imageExtent = new Point(imageBounds.width, imageBounds.height);

+	}

+	return imageExtent;

+}

+/**

+ * Answer the receiver's index into its parent's list of children

+ */

+int getIndex() {

+	return index;

+}

+/**

+ * Answer the width of the horizontal item connector line.

+ */

+int getItemConnectorWidth() {

+	Tree parent = getParent();

+	Point imageExtent = parent.getImageExtent();

+	int itemConnectorWidth;

+	int indicatorWidth = parent.getHierarchyIndicatorRect().width;

+

+	if (imageExtent != null) {

+		itemConnectorWidth = imageExtent.x / 2 + ITEM_CONNECTOR_PADDING;

+	}

+	else {

+		itemConnectorWidth = DEFAULT_ITEM_CONNECTOR_WIDTH;

+	}

+	if (isLeaf() == false) {	// has children = has hierarchy indicator = shorter connector

+		itemConnectorWidth -= indicatorWidth / 2;

+	}

+	return itemConnectorWidth;

+}

+/**
+ * Returns the number of items contained in the receiver
+ * that are direct item children of the receiver.
+ *
+ * @return the number of items
+ *
+ * @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 getItemCount() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return super.getItemCount();

+}

+/**

+ * Answer the size of the receiver as displayed on the screen.

+ */

+Point getItemExtent() {

+	Tree parent;

+	Point imageExtent;

+	String text;

+	int itemWidth;

+	

+	if (itemExtent == null) {

+		parent = getParent();

+		imageExtent = parent.getImageExtent();

+		text = getText();

+		itemWidth = SELECTION_PADDING;

+		if (text != null) {

+			itemWidth += parent.getTextWidth(text) + TEXT_INDENT;

+		}

+		if (imageExtent != null) {

+			itemWidth += imageExtent.x + IMAGE_PADDING;

+		}

+		itemExtent = new Point(itemWidth, parent.getItemHeight());

+	}

+	return itemExtent;

+}

+/**

+ * Answer the x position at which painting of the receiver's 

+ * contents (ie. image, text) can begin.

+ */

+int getItemStartX() {

+	int itemStartX = getPaintStartX() + getDecorationsWidth();

+	

+	if (isCheckable() == true) {

+		itemStartX += getCheckboxBounds().width + CHECKBOX_PADDING;

+	}

+	return itemStartX;

+}

+/**
+ * Returns an array of <code>TreeItem</code>s which are the
+ * direct item children of the receiver.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the receiver's items
+ *
+ * @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 TreeItem [] getItems() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	TreeItem childrenArray[] = new TreeItem[getItemCount()];

+

+	getChildren().copyInto(childrenArray);

+	return childrenArray;	

+}

+/**

+ * Answer the x position where the receiver is drawn.

+ */

+int getPaintStartX() {

+	Tree parent = getParent();

+	Point imageExtent;

+	TreeItem parentItem;

+

+	if (paintStartX == -1) {

+		if (isRoot() == true) {

+			paintStartX = ROOT_INDENT;

+		}

+		else {

+			parentItem = getParentItem();

+			// subtract parent.getHorizontalOffset() to calculate the cached start 

+			// position independent of the horizontal scroll offset. Fixes 1G1L7EU.

+			paintStartX = parentItem.getPaintStartX() 

+				- parent.getHorizontalOffset()	

+				+ parentItem.getDecorationsWidth()

+				- parent.getHierarchyIndicatorRect().width / 2;

+			imageExtent = parent.getImageExtent();

+			if (imageExtent != null) {

+				paintStartX += imageExtent.x / 2;

+			}

+			else {

+				paintStartX += ITEM_NOIMAGE_OFFSET;

+			}

+		}

+	}

+	return paintStartX + parent.getHorizontalOffset();

+}

+/**

+ * Answer the pixel at which the receiver stops drawing.

+ */

+int getPaintStopX() {

+	return (getItemStartX() + getItemExtent().x - getParent().getHorizontalOffset());

+}

+/**
+ * Returns the receiver's parent, which must be a <code>Tree</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @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 Tree getParent() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return (Tree) super.getSelectableParent();

+}

+/**
+ * Returns the receiver's parent item, which must be a
+ * <code>TreeItem</code> or null when the receiver is a
+ * root.
+ *
+ * @return the receiver's parent item
+ *
+ * @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 TreeItem getParentItem() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	return parentItem;

+}

+/**

+ * Answer the item that directly precedes the receiver.

+ * Answer null if this is the first item in a hierarchy level

+ * or if there are expanded children in the previous item.

+ */

+TreeItem getPredecessor() {

+	AbstractTreeItem parentItem = getParentItem();

+	Vector children;

+	int previousIndex = getIndex() - 1;

+	TreeItem previousItem = null;

+

+	if (parentItem == null) {

+		parentItem = getParent().getRoot();

+	}

+	if (previousIndex >= 0) {

+		children = parentItem.getChildren();

+		previousItem = (TreeItem) children.elementAt(previousIndex);

+		if (previousItem.isLeaf() == false && previousItem.getExpanded() == true) {

+			previousItem = null;	// no immediate predecessor because there are expanded children

+		}

+	}

+	return previousItem;	

+}

+/**

+ * Answer the size of the rectangle drawn to indicate the

+ * selected state of the receiver.

+ * This is also used to draw the selection focus rectangle.

+ */

+Point getSelectionExtent() {

+	Point selectionExtent = getItemExtent();

+	Point imageExtent = getParent().getImageExtent();

+	int x = selectionExtent.x;

+

+	if (imageExtent != null) {

+		x -= imageExtent.x + IMAGE_PADDING;

+	}

+	return new Point(x, selectionExtent.y);

+}

+/**

+ * Return the x position of the selection rectangle

+ */

+int getSelectionX() {

+	return getTextXPos() - TEXT_INDENT;

+}

+/**

+ * Answer the x position where the receiver draws the item text.

+ * This position is relative to the item start position.

+ */

+int getTextXPos() {

+	Point imageExtent = getParent().getImageExtent();

+	int textXPos = getItemStartX() + TEXT_INDENT;

+

+	if (imageExtent != null) {

+		textXPos += imageExtent.x + IMAGE_PADDING;

+	}

+	return textXPos;

+}

+/**

+ * Answer the y position of the receiver's text.

+ * @param 

+ *	gc - GC to use for calculating the text y position 

+ */

+int getTextYPosition(GC gc) {

+	String text;

+

+	if (textYPosition == -1) {

+		text = getText();

+		if (text != null) {

+			textYPosition = (getParent().getItemHeight() - gc.stringExtent(text).y) / 2;

+		}

+		else {

+			textYPosition = 0;

+		}

+	}

+	return textYPosition;

+}

+/**

+ * Answer the index of the receiver relative to the first root 

+ * item.

+ * If 'anIndex' is the index of the expanded item 'anItem' 

+ * then the following expressions are true:

+ * 'anItem  == theRoot.getVisibleItem(anIndex)' and

+ * 'anIndex == anItem.getVisibleIndex()'

+ * @return

+ *	The index of the receiver relative to the first root item.

+ *	Answer -1 if the receiver is not visible (because the parent 

+ *	is collapsed).

+ */

+int getVisibleIndex() {

+	int visibleItemIndex = getIndex();

+	AbstractTreeItem item = null;

+

+	if (isRoot() == false) {

+		if (isVisible() == false) {

+			return -1;		

+		}

+		item = getParentItem();

+		visibleItemIndex++;						// adjust for 0-based non-root items

+	}

+	else {	

+		item = getParent().getRoot();

+	}

+

+	visibleItemIndex += item.getVisibleIndex(getIndex());

+	return visibleItemIndex;

+}

+/**

+ * Answer the index of the child item identified by 'childIndex' 

+ * relative to the first root item.

+ */

+int getVisibleIndex(int childIndex) {

+	Enumeration children = getChildren().elements();

+	TreeItem child;

+	int visibleItemIndex = getIndex();

+

+	if (isRoot() == false) {

+		visibleItemIndex++;									// adjust for 0-based non-root items

+	}

+

+	while (children.hasMoreElements() == true) {

+		child = (TreeItem) children.nextElement();

+		if (child.getIndex() == childIndex) {

+			if (isRoot() == false) {

+				visibleItemIndex += getParentItem().getVisibleIndex(getIndex());

+			}

+			else {

+				visibleItemIndex += getParent().getRoot().getVisibleIndex(getIndex());

+			}

+			break;

+		}

+		visibleItemIndex += child.getVisibleItemCount();		

+	}	

+	return visibleItemIndex;

+}

+/**

+ * Answer the item at 'searchIndex' relativ to the receiver.

+ * When this method is called for the root item, 'searchIndex' 

+ * represents the global index into all items of the tree.

+ * searchIndex=0 returns the receiver. 

+ * searchIndex=1 returns the first visible child.

+ * Note: searchIndex must be >= 0

+ *

+ * Note: 

+ * Visible in this context does not neccessarily mean that the 

+ * item is displayed on the screen. Visible here means that all 

+ * the parents of the item are expanded. An item is only 

+ * visible on screen if it is within the widget client area.

+ */

+TreeItem getVisibleItem(int searchIndex) {

+	TreeItem child;

+	TreeItem foundItem = null;

+	Enumeration children = getChildren().elements();

+

+	if (searchIndex == 0) {

+		return this;

+	}

+	else					

+	if (getExpanded() == false) { 		// trying to find a child when this item isn't expanded ? 

+		return null;

+	}

+

+	// Search for expanded items first. Count all subitems in the process.

+	while (children.hasMoreElements() == true && foundItem == null) {

+		child = (TreeItem) children.nextElement();

+		searchIndex--;

+		if (child.getExpanded() == true) {

+			searchIndex -= child.getVisibleItemCount();	// count children of all expanded items

+		}

+		if (searchIndex <= 0) {								// is searched item past child ?

+			// add back children of current item (that's what we want to search)			

+			foundItem = child.getVisibleItem(searchIndex + child.getVisibleItemCount());

+		}

+	}

+

+	return foundItem;

+}

+/**

+ * Answer whether 'item' is a child, direct or indirect, of the receiver.

+ * It is an indirect child if it is a child of one of the receiver's children.

+ */

+boolean isChild(TreeItem item) {

+	Vector children = getChildren();

+	TreeItem child;

+	

+	if (children.contains(item) == true) {

+		return true;

+	}

+	for (int i = 0; i < children.size(); i++) {

+		child = (TreeItem) children.elementAt(i);

+		if (child.isChild(item) == true) {

+			return true;

+		}

+	}

+	return false;

+}

+/**

+ * Answer whether the receiver is a root item.

+ * The receiver is a root item when it does not have a parent item.

+ * @return 

+ *	true - the receiver is a root item.

+ * 	false - the receiver is not a root item.

+ */

+boolean isRoot() {

+	return (getParentItem() == null);

+}

+/**

+ * Answer whether the click at 'position' on the receiver is a selection 

+ * click.

+ * @param position - location of the mouse click relative to the 

+ *	upper left corner of the receiver.

+ * @return true - receiver was clicked.

+ *	false - receiver was not clicked.

+ */

+boolean isSelectionHit(Point position) {

+	Point itemExtent = getItemExtent();

+

+	if (itemExtent == null) {		// neither image nor text have been set

+		return false;

+	}

+	return (new Rectangle(

+		getItemStartX() - getPaintStartX(), 0, 

+		itemExtent.x, itemExtent.y)).contains(position);

+}

+/**

+ * Answer whether the receiver is visible

+ * An item is visible when its parent item is visible and 

+ * expanded. Root items are always visible.

+ *

+ * Note: 

+ * Visible in this context does not neccessarily mean that the 

+ * item is displayed on the screen. Visible here means that all 

+ * the parents of the item are expanded. An item is only 

+ * visible on screen if it is within the receiver's parent's 

+ * client area.

+ * @return 

+ *	true - the receiver is visible

+ * 	false - the receiver is not visible

+ */

+boolean isVisible() {

+	boolean isVisible = true;

+	TreeItem parentItem = getParentItem();

+

+	if (isRoot() == false) {

+		isVisible = parentItem.getExpanded();

+		if (isVisible == true) {

+			isVisible = parentItem.isVisible();

+		}

+	}

+	return isVisible;		

+}

+/**

+ * Make this item visible by expanding its parent item.

+ */

+void makeVisible() {

+	TreeItem parentItem = getParentItem();

+	

+	if (isVisible() == false && parentItem != null) {

+		getParent().expand(parentItem, true);			// have to call Tree.expand directly in order to trigger Expand event

+		parentItem.makeVisible();

+	}

+}

+/** 

+ * Draw the receiver at 'yPosition' in the client area of the parent.

+ * @param gc - GC to draw on.

+ * @param yPosition - y coordinate where the receiver should draw at.

+ */

+void paint(GC gc, int yPosition) {

+	Tree parent = getParent();

+	Point paintPosition = new Point(getPaintStartX(), yPosition);

+	

+	if (isVisible() == false) {

+		return;

+	}

+	gc.setForeground(parent.CONNECTOR_LINE_COLOR);

+	paintPosition = drawVerticalItemConnector(gc, paintPosition);

+	paintPosition = drawHierarchyIndicator(gc, paintPosition);

+	paintPosition = drawHorizontalItemConnector(gc, paintPosition);

+	gc.setForeground(parent.getForeground());

+	// paint the rest

+	if (isCheckable() == true) {

+		paintPosition = drawCheckbox(gc, new Point(paintPosition.x, yPosition));

+	}

+	paintPosition = drawImage(gc, new Point(paintPosition.x, yPosition));

+	drawSelection(gc, paintPosition);

+	if (this == parent.getInsertItem()) {

+		drawInsertMark(gc, paintPosition);

+	}

+	drawText(gc, new Point(getTextXPos(), paintPosition.y + getTextYPosition(gc)));

+	drawSelectionFocus(gc, paintPosition);

+}

+/**

+ * Update the display to reflect the expanded state of the

+ * receiver.

+ * @param itemIndex - index position in the receiver's client 

+ *	area where should be drawn.

+ */

+void redrawExpanded(int itemIndex) {

+	Tree parent = getParent();

+	int indicatorWidth = parent.getHierarchyIndicatorRect().width;

+	int itemHeight = parent.getItemHeight();

+

+	parent.redraw(

+		getPaintStartX(), itemIndex * itemHeight,

+		indicatorWidth, itemHeight, false);

+}

+/**

+ * Reset cached size and position data.

+ */

+void reset() {

+	super.reset();

+	setImageExtent(null);

+	setItemExtent(null);	

+	setPaintStartX(-1);

+	setTextYPosition(-1);	

+}

+/**
+ * Sets the expanded state of the receiver.
+ * <p>
+ *
+ * @param expanded the new expanded 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 void setExpanded(boolean expand) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+

+	if (isLeaf() == false && expand == true) {

+		getParent().expand(this, false);

+	}

+	else {

+		getParent().collapse(this, false);

+	}

+}

+public void setImage(Image newImage) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Tree parent = getParent();

+	Image oldImage = getImage();

+	boolean isSameImage;

+	int imageWidth = 0;

+	int redrawX = 0;

+

+	super.setImage(newImage);	

+	if (newImage != null && oldImage != null) {

+		isSameImage = newImage.equals(oldImage);

+	}

+	else {

+		isSameImage = newImage == oldImage;

+	}

+	if (isSameImage == false) {

+		if (parent.getVisibleRedrawY(this) != -1) {

+			if (parent.getImageExtent() != null) {

+				imageWidth = parent.getImageExtent().x;

+			}

+			else

+			if (newImage != null) {

+				imageWidth = newImage.getBounds().x;

+			}

+			redrawX = getItemStartX();

+		}

+		parent.itemChanged(this, redrawX, imageWidth);

+	}

+}

+/**

+ * Set the size of the original image of the receiver to 'imageExtent'. 

+ */

+void setImageExtent(Point imageExtent) {

+	this.imageExtent = imageExtent;

+}

+/**

+ * Set the index of the receiver to 'index'.

+ * This index is used to reference children in their parent.

+ */

+void setIndex(int index) {

+	this.index = index;

+}

+/**

+ * Set the size of the receiver to 'extent'.

+ */

+void setItemExtent(Point extent) {

+	itemExtent = extent;

+}

+/**

+ * Set the x position where the receiver is drawn to 'startX'.

+ * @param startX - the x position where the receiver is drawn

+ */

+void setPaintStartX(int startX) {

+	paintStartX = startX;

+}

+/**

+ * Set the parent item of the receiver to 'parentItem'.

+ * @param parentItem - the receiver's parent item. 

+ *	Receiver is a root if this is null.

+ */

+void setParentItem(TreeItem parentItem) {

+	this.parentItem = parentItem;

+}

+/**
+ * This label will be displayed to the right of the bitmap, 
+ * or, if the receiver doesn't have a bitmap to the right of 
+ * the horizontal hierarchy connector line.
+ */

+public void setText(String newText) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	Tree parent = getParent();	

+	String oldText = getText();

+	int redrawX = 0;

+	int redrawWidth = 0;

+

+	if (newText == null) {

+		error(SWT.ERROR_NULL_ARGUMENT);

+	}

+	super.setText(newText);	

+	if (newText.equals(oldText) == false) {

+		if (parent.getVisibleRedrawY(this) != -1) {

+			redrawX = getTextXPos();

+			redrawWidth = parent.getClientArea().width - redrawX;

+		}

+		parent.itemChanged(this, redrawX, redrawWidth);

+	}

+}

+/**

+ * Set the y position of the receiver's text to 'yPosition'.

+ */

+void setTextYPosition(int yPosition) {

+	textYPosition = yPosition;

+}

+

+public void dispose() {

+	if (!isValidWidget ()) return;

+	// if the tree is being disposed don't bother collapsing the item since all 

+	// items in the tree will be deleted and redraws will not be processed anyway

+	Tree parent = getParent();

+	if (parent.isRemovingAll() == false) {

+		parent.collapseNoRedraw(this);

+	}	

+	

+	if (parentItem != null) {

+		parentItem.removeItem(this);

+	}

+	else {

+		parent.removeItem(this);

+	}

+	

+	super.dispose();

+}

+

+void doDispose() {	

+	// Notify the parent that the receiver is being removed.

+	// Reset cached data.

+	setParentItem(null);

+	setImageExtent(null);

+	setItemExtent(null);	

+	setIndex(-1);

+	setPaintStartX(-1);

+	setTextYPosition(-1);

+	

+	super.doDispose();

+}

+/**
+ * Returns <code>true</code> if the receiver is checked,
+ * and false otherwise.  When the parent does not have
+ * the <code>CHECK style, return false.
+ * <p>
+ *
+ * @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() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return super.getChecked();

+}

+public Display getDisplay() {

+	return super.getDisplay();

+}

+/**
+ * Returns <code>true</code> if the receiver is grayed,
+ * and false otherwise. When the parent does not have
+ * the <code>CHECK style, return false.
+ * <p>
+ *
+ * @return the grayed 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 getGrayed() {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	return super.getGrayed();

+}

+/**
+ * Sets the checked state of the receiver.
+ * <p>
+ *
+ * @param checked the new 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 void setChecked(boolean checked) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	super.setChecked(checked);

+}

+/**
+ * Sets the grayed state of the receiver.
+ * <p>
+ *
+ * @param checked the new grayed 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 void setGrayed (boolean grayed) {

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	

+	super.setGrayed(grayed);

+}

+

+}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeRoots.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeRoots.java
new file mode 100755
index 0000000..dec4c31
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeRoots.java
@@ -0,0 +1,156 @@
+package org.eclipse.swt.widgets;

+

+/*

+ * (c) Copyright IBM Corp. 2000, 2001.

+ * All Rights Reserved

+ */

+ 

+import org.eclipse.swt.graphics.*;

+import java.util.*;

+ 

+/** 

+ * This class is used to store tree root items.

+ * Instances of this class are never displayed.

+ */

+class TreeRoots extends AbstractTreeItem {

+/**

+ * Create a tree item that holds one or more root items 

+ * @param parent - Tree widget the receiver belongs to

+ */

+TreeRoots(Tree parent) {

+	super(parent, 0);

+	initialize();

+}

+/**

+ * Calculate the number of expanded children.

+ * Recurse up in the tree to the root item.

+ */

+void calculateVisibleItemCount() {

+	Vector children = getChildren();

+	TreeItem child;

+	int visibleItemCount = children.size();

+	

+	for (int i = 0; i < children.size(); i++) {

+		child = (TreeItem) children.elementAt(i);

+		visibleItemCount += child.getVisibleItemCount();

+	}

+	setVisibleItemCount(visibleItemCount);

+}

+/**

+ * Calculate the number of expanded children for the parent item

+ * of this item.

+ */

+void calculateVisibleItemCountParent() {}

+

+public void dispose() {

+	if (!isValidWidget ()) return;

+	Tree parent = (Tree) getSelectableParent();

+	

+	// all tree items are removed so we don't need to do

+	// time consuming screen updates for each removed item

+	parent.setRemovingAll(true);

+	super.dispose();

+	parent.setRemovingAll(false);

+}

+/**

+ * Answer the x position of the item check box

+ */

+int getCheckboxXPosition() {

+	return 0;

+}

+/**

+ * Implements SelectableItem#getSelectionExtent

+ * Should never be called since objects of this type are never 

+ * rendered

+ */

+Point getSelectionExtent() {

+	return new Point(0, 0);

+}

+/**

+ * Implements SelectableItem#getSelectionX

+ * Should never be called since objects of this type are never 

+ * rendered

+ */

+int getSelectionX() {

+	return 0;

+}

+/**

+ * Always answer -1 to indicate that the receiver is not visible.

+ */

+int getVisibleIndex() {

+	return -1;		

+}

+/**

+ * Answer the index of the child item identified by 'childIndex' 

+ * relative to the first root item.

+ */

+int getVisibleIndex(int childIndex) {

+	Enumeration children = getChildren().elements();

+	TreeItem child;

+	int globalItemIndex = 0;

+

+	while (children.hasMoreElements() == true) {

+		child = (TreeItem) children.nextElement();

+		if (child.getIndex() == childIndex) {

+			break;

+		}

+		globalItemIndex += child.getVisibleItemCount();		

+	}	

+	return globalItemIndex;

+}

+/**

+ * Answer the item at 'searchIndex' relativ to the receiver.

+ * When this method is called for the root item, 'searchIndex' 

+ * represents the global index into all items of the tree.

+ * searchIndex=0 returns the receiver. 

+ * searchIndex=1 returns the first visible child.

+ * Note: searchIndex must be >= 0

+ *

+ * Note: 

+ * Visible in this context does not neccessarily mean that the 

+ * item is displayed on the screen. Visible here means that all 

+ * the parents of the item are expanded. An item is only 

+ * visible on screen if it is within the widget client area.

+ */

+TreeItem getVisibleItem(int searchIndex) {

+	TreeItem child;

+	TreeItem foundItem = null;

+	Enumeration children = getChildren().elements();

+

+	searchIndex++;						// skip this fake root item

+

+	// Search for expanded items first. Count all subitems in the process.

+	while (children.hasMoreElements() == true && foundItem == null) {

+		child = (TreeItem) children.nextElement();

+		searchIndex--;

+		if (child.internalGetExpanded() == true) {

+			searchIndex -= child.getVisibleItemCount();	// count children of all expanded items

+		}

+		if (searchIndex <= 0) {								// is searched item past child ?

+			// add back children of current item (that's what we want to search)			

+			foundItem = child.getVisibleItem(searchIndex + child.getVisibleItemCount());

+		}

+	}

+	return foundItem;

+}

+/**

+ * Initialize the receiver

+ */

+void initialize() {

+	internalSetExpanded(true);

+}

+

+/**

+ * Select the receiver and all children

+ */

+Vector selectAll(Vector selectedItems) {

+	Enumeration children = getChildren().elements();

+	AbstractTreeItem treeItem;

+

+	while (children.hasMoreElements() == true) {

+		treeItem = (AbstractTreeItem) children.nextElement();

+		selectedItems = treeItem.selectAll(selectedItems);

+	}

+	return selectedItems;

+}

+}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java
index 307bcf9..1ca65f7 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java
@@ -55,7 +55,6 @@
 void checkParent (Widget parent) {

 	if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

-	if (parent.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);

 }

 

 protected void checkSubclass () {

@@ -64,7 +63,7 @@
 

 protected void checkWidget () {

 	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

-	if (isDisposed ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 }

 

 int copyPhImage(int image) {

@@ -86,14 +85,16 @@
 }

 

 public void addListener (int eventType, Listener handler) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) eventTable = new EventTable ();

 	eventTable.hook (eventType, handler);

 }

 

 public void addDisposeListener (DisposeListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener (listener);

 	addListener (SWT.Dispose, typedListener);

@@ -173,7 +174,7 @@
 	* Note:  It is valid to attempt to dispose a widget

 	* more than once.  If this happens, fail silently.

 	*/

-	if (isDisposed()) return;

+	if (!isValidWidget ()) return;

 	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

 	releaseChild ();

 	releaseWidget ();

@@ -185,12 +186,14 @@
 }

 

 public Object getData () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return data;

 }

 

 public Object getData (String key) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (key == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (keys == null) return null;

 	for (int i=0; i<keys.length; i++) {

@@ -213,7 +216,8 @@
 }

 

 public int getStyle () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return style;

 }

 

@@ -237,7 +241,8 @@
 }

 

 protected boolean isListening (int eventType) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return hooks (eventType);

 }

 

@@ -245,8 +250,15 @@
 	return getDisplay ().isValidThread ();

 }

 

+boolean isValidWidget () {

+	if (handle != 0) return true;

+	if ((state & HANDLE) != 0) return false;

+	return (state & DISPOSED) == 0;

+}

+

 public void notifyListeners (int eventType, Event event) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (event == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	event.type = eventType;

@@ -389,27 +401,30 @@
 }

 

 public void removeListener (int eventType, Listener handler) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (eventType, handler);

 }

 

 protected void removeListener (int eventType, EventListener handler) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (eventType, handler);

 }

 

 public void removeDisposeListener (DisposeListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Dispose, listener);

 }

 

-void replaceMnemonic (int mnemonic, boolean normal, boolean alt) {

+void replaceMnemonic (int mnemonic, int mods) {

 	Display display = getDisplay ();

 	int [] args = {OS.Pt_ARG_ACCEL_KEY, 0, 0};

 	OS.PtGetResources (handle, args.length / 3, args);

@@ -421,23 +436,13 @@
 			char [] accelText = Converter.mbcsToWcs (null, buffer);

 			if (accelText.length > 0) {

 				char key = Character.toLowerCase (accelText [0]);

-				if (normal) {

-					OS.PtRemoveHotkeyHandler (handle, key, 0, (short)0, SWT.Activate, display.windowProc);

-				}

-				if (alt) {

-					OS.PtRemoveHotkeyHandler (handle, key, OS.Pk_KM_Alt, (short)0, SWT.Activate, display.windowProc);

-				}

+				OS.PtRemoveHotkeyHandler (handle, key, 0, (short)0, SWT.Activate, display.windowProc);

 			}

 		}

 	}

 	if (mnemonic == 0) return;

 	char key = Character.toLowerCase ((char)mnemonic);

-	if (normal) {

-		OS.PtAddHotkeyHandler (handle, key, 0, (short)0, SWT.Activate, display.windowProc);

-	}

-	if (alt) {

-		OS.PtAddHotkeyHandler (handle, key, OS.Pk_KM_Alt, (short)0, SWT.Activate, display.windowProc);

-	}

+	OS.PtAddHotkeyHandler (handle, key, mods, (short)0, SWT.Activate, display.windowProc);

 }

 

 void sendEvent (int eventType) {

@@ -456,12 +461,14 @@
 }

 

 public void setData (Object data) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	this.data = data;

 }

 

 public void setData (String key, Object value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (key == null) error (SWT.ERROR_NULL_ARGUMENT);

 	

 	/* Remove the key/value pair */

@@ -521,4 +528,4 @@
 	return handle;

 }

 

-}

+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/library/makefile.mak b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/makefile.mak
index c6ea1ae..e6d66f6 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/library/makefile.mak
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/makefile.mak
@@ -12,8 +12,8 @@
 APPVER=5.0

 !include <win32.mak>

 

-maj_ver=2

-min_ver=002

+maj_ver=0

+min_ver=125

 bld_num=0

 

 pgm_ver_str="SWT $(maj_ver).0$(min_ver) for Windows"

@@ -23,8 +23,7 @@
 # assumes JAVA_HOME is set in the environment from which nmake is run

 

 DLLPREFIX=swt

-OSPREFIX=win32

-DLLNAME=$(DLLPREFIX)-$(OSPREFIX)-$(maj_ver)$(min_ver).dll

+DLLNAME=$(DLLPREFIX)$(maj_ver)$(min_ver).dll

 

 LIBNAME=swt# declaration

 

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/library/structs.c b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/structs.c
index 2a46509..63ec0a1 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/library/structs.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/structs.c
@@ -311,15 +311,6 @@
     lpCache->itemData = (*env)->GetFieldID(env,lpCache->drawitemstructClass,"itemData","I");

     lpCache->cached = 1;

 }

-
-void cacheGradientrectFids(JNIEnv *env, jobject lpGradientrect, PGRADIENT_RECT_FID_CACHE lpCache)
-{
-    if (lpCache->cached) return;
-    lpCache->gradientrectClass = (*env)->GetObjectClass(env,lpGradientrect);
-    lpCache->UpperLeft = (*env)->GetFieldID(env,lpCache->gradientrectClass,"UpperLeft","I");
-    lpCache->LowerRight = (*env)->GetFieldID(env,lpCache->gradientrectClass,"LowerRight","I");
-    lpCache->cached = 1;
-}
 

 void cacheHditemFids(JNIEnv *env, jobject lpHditem, PHDITEM_FID_CACHE lpCache)

 {

@@ -1021,20 +1012,7 @@
     lpCache->dwHoverTime = (*env)->GetFieldID(env,lpCache->trackmouseeventClass,"dwHoverTime","I");

     lpCache->cached = 1;

 }

-
-void cacheTrivertexFids(JNIEnv *env, jobject lpTrivertex, PTRIVERTEX_FID_CACHE lpCache)
-{
-    if (lpCache->cached) return;
-    lpCache->trivertexClass = (*env)->GetObjectClass(env,lpTrivertex);
-    lpCache->x = (*env)->GetFieldID(env,lpCache->trivertexClass,"x","I");
-    lpCache->y = (*env)->GetFieldID(env,lpCache->trivertexClass,"y","I");
-    lpCache->Red = (*env)->GetFieldID(env,lpCache->trivertexClass,"Red","S");
-    lpCache->Green = (*env)->GetFieldID(env,lpCache->trivertexClass,"Green","S");
-    lpCache->Blue = (*env)->GetFieldID(env,lpCache->trivertexClass,"Blue","S");
-    lpCache->Alpha = (*env)->GetFieldID(env,lpCache->trivertexClass,"Alpha","S");
-    lpCache->cached = 1;
-}
-
+

 void cacheTvhittestinfoFids(JNIEnv *env, jobject lpTvhittestinfo, PTVHITTESTINFO_FID_CACHE lpCache)

 {

     if (lpCache->cached) return;

@@ -1526,23 +1504,7 @@
     lpCache->filler = (*env)->GetFieldID(env,lpCache->vardescClass,"filler","S");

     lpCache->varkind = (*env)->GetFieldID(env,lpCache->vardescClass,"varkind","I");

     lpCache->cached = 1;

-}
-
-void cacheGCP_RESULTSFids(JNIEnv *env, jobject lpObject, PGCP_RESULTS_FID_CACHE lpCache)
-{
-	if (lpCache->cached) return;
-	lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
-	lpCache->nMaxFit = (*env)->GetFieldID(env, lpCache->clazz, "nMaxFit", "I");
-	lpCache->nGlyphs = (*env)->GetFieldID(env, lpCache->clazz, "nGlyphs", "I");
-	lpCache->lpGlyphs = (*env)->GetFieldID(env, lpCache->clazz, "lpGlyphs", "I");
-	lpCache->lpClass = (*env)->GetFieldID(env, lpCache->clazz, "lpClass", "I");
-	lpCache->lpCaretPos = (*env)->GetFieldID(env, lpCache->clazz, "lpCaretPos", "I");
-	lpCache->lpDx = (*env)->GetFieldID(env, lpCache->clazz, "lpDx", "I");
-	lpCache->lpOrder = (*env)->GetFieldID(env, lpCache->clazz, "lpOrder", "I");
-	lpCache->lpOutString = (*env)->GetFieldID(env, lpCache->clazz, "lpOutString", "I");
-	lpCache->lStructSize = (*env)->GetFieldID(env, lpCache->clazz, "lStructSize", "I");
-	lpCache->cached = 1;
-}
+}

     

 /* ----------- swt getters and setters  ----------- */

 /**

@@ -2053,19 +2015,7 @@
     (*env)->SetIntField(env,lpObject,lpDrawitemstructFc->bottom, lpDrawitemstruct->rcItem.bottom);

     (*env)->SetIntField(env,lpObject,lpDrawitemstructFc->itemData, lpDrawitemstruct->itemData);

 }

-
-void getGradientrectFields(JNIEnv *env, jobject lpObject, GRADIENT_RECT *lpGradientrect, GRADIENT_RECT_FID_CACHE *lpGradientrectFc)
-{
-	lpGradientrect->UpperLeft = (*env)->GetIntField(env,lpObject,lpGradientrectFc->UpperLeft);
-	lpGradientrect->LowerRight = (*env)->GetIntField(env,lpObject,lpGradientrectFc->LowerRight);
-}
-
-void setGradientrectFields(JNIEnv *env, jobject lpObject, GRADIENT_RECT *lpGradientrect, GRADIENT_RECT_FID_CACHE *lpGradientrectFc)
-{
-    (*env)->SetIntField(env,lpObject,lpGradientrectFc->UpperLeft, (jint)lpGradientrect->UpperLeft);
-    (*env)->SetIntField(env,lpObject,lpGradientrectFc->LowerRight, (jint)lpGradientrect->LowerRight);
-}
-
+

 void getHditemFields(JNIEnv *env, jobject lpObject, HDITEM *lpHditem, HDITEM_FID_CACHE *lpHditemFc)

 {

     lpHditem->mask = (*env)->GetIntField(env,lpObject,lpHditemFc->mask);

@@ -3239,26 +3189,6 @@
     (*env)->SetIntField(env,lpObject,lpTrackmouseeventFc->dwHoverTime, lpTrackmouseevent->dwHoverTime);

 }

 

-void getTrivertexFields(JNIEnv *env, jobject lpObject, TRIVERTEX *lpTrivertex, TRIVERTEX_FID_CACHE *lpTrivertexFc)
-{
-	lpTrivertex->x = (*env)->GetIntField(env,lpObject,lpTrivertexFc->x);
-	lpTrivertex->y = (*env)->GetIntField(env,lpObject,lpTrivertexFc->y);
-	lpTrivertex->Red = (*env)->GetShortField(env,lpObject,lpTrivertexFc->Red);
-	lpTrivertex->Green = (*env)->GetShortField(env,lpObject,lpTrivertexFc->Green);
-	lpTrivertex->Blue = (*env)->GetShortField(env,lpObject,lpTrivertexFc->Blue);
-	lpTrivertex->Alpha = (*env)->GetShortField(env,lpObject,lpTrivertexFc->Alpha);
-}
-
-void setTrivertexFields(JNIEnv *env, jobject lpObject, TRIVERTEX *lpTrivertex, TRIVERTEX_FID_CACHE *lpTrivertexFc)
-{
-    (*env)->SetIntField(env,lpObject,lpTrivertexFc->x, (jint)lpTrivertex->x);
-    (*env)->SetIntField(env,lpObject,lpTrivertexFc->y, (jint)lpTrivertex->y);
-    (*env)->SetShortField(env,lpObject,lpTrivertexFc->Red, (jshort)lpTrivertex->Red);
-    (*env)->SetShortField(env,lpObject,lpTrivertexFc->Green, (jshort)lpTrivertex->Green);
-    (*env)->SetShortField(env,lpObject,lpTrivertexFc->Blue, (jshort)lpTrivertex->Blue);
-    (*env)->SetShortField(env,lpObject,lpTrivertexFc->Alpha, (jshort)lpTrivertex->Alpha);
-}
-
 void getTvhittestinfoFields(JNIEnv *env, jobject lpObject, TVHITTESTINFO *lpTvhittestinfo, TVHITTESTINFO_FID_CACHE *lpTvhittestinfoFc)

 {

     lpTvhittestinfo->pt.x = (*env)->GetIntField(env,lpObject,lpTvhittestinfoFc->x);

@@ -4048,30 +3978,4 @@
     (*env)->SetShortField(env,lpObject,lpVardescFc->elemdescVar_idldesc_wIDLFlags, (jshort)lpVardesc->elemdescVar.idldesc.wIDLFlags);

     (*env)->SetShortField(env,lpObject,lpVardescFc->wVarFlags, (jshort)lpVardesc->wVarFlags);

     (*env)->SetIntField(env,lpObject,lpVardescFc->varkind, (jint)lpVardesc->varkind);    

-}
-
-void getGCP_RESULTSFields(JNIEnv *env, jobject lpObject, GCP_RESULTS *lpStruct, PGCP_RESULTS_FID_CACHE lpCache)
-{
-	lpStruct->nMaxFit = (*env)->GetIntField(env, lpObject, lpCache->nMaxFit);
-	lpStruct->nGlyphs = (*env)->GetIntField(env, lpObject, lpCache->nGlyphs);
-	lpStruct->lpGlyphs = (LPWSTR)(*env)->GetIntField(env, lpObject, lpCache->lpGlyphs);
-	lpStruct->lpClass = (LPSTR)(*env)->GetIntField(env, lpObject, lpCache->lpClass);
-	lpStruct->lpCaretPos = (int  *)(*env)->GetIntField(env, lpObject, lpCache->lpCaretPos);
-	lpStruct->lpDx = (int  *)(*env)->GetIntField(env, lpObject, lpCache->lpDx);
-	lpStruct->lpOrder = (UINT  *)(*env)->GetIntField(env, lpObject, lpCache->lpOrder);
-	lpStruct->lpOutString = (LPTSTR)(*env)->GetIntField(env, lpObject, lpCache->lpOutString);
-	lpStruct->lStructSize = (*env)->GetIntField(env, lpObject, lpCache->lStructSize);
-}
-
-void setGCP_RESULTSFields(JNIEnv *env, jobject lpObject, GCP_RESULTS *lpStruct, PGCP_RESULTS_FID_CACHE lpCache)
-{
-	(*env)->SetIntField(env, lpObject, lpCache->nMaxFit, lpStruct->nMaxFit);
-	(*env)->SetIntField(env, lpObject, lpCache->nGlyphs, lpStruct->nGlyphs);
-	(*env)->SetIntField(env, lpObject, lpCache->lpGlyphs, (int)lpStruct->lpGlyphs);
-	(*env)->SetIntField(env, lpObject, lpCache->lpClass, (int)lpStruct->lpClass);
-	(*env)->SetIntField(env, lpObject, lpCache->lpCaretPos, (int)lpStruct->lpCaretPos);
-	(*env)->SetIntField(env, lpObject, lpCache->lpDx, (int)lpStruct->lpDx);
-	(*env)->SetIntField(env, lpObject, lpCache->lpOrder, (int)lpStruct->lpOrder);
-	(*env)->SetIntField(env, lpObject, lpCache->lpOutString, (int)lpStruct->lpOutString);
-	(*env)->SetIntField(env, lpObject, lpCache->lStructSize, lpStruct->lStructSize);
-}
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/library/structs.h b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/structs.h
index 8b3539f..6ae3474 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/library/structs.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/structs.h
@@ -111,10 +111,7 @@
 	FUNCDESC1_FID_CACHE Funcdesc1Fc; \

 	FUNCDESC2_FID_CACHE Funcdesc2Fc; \

 	VARDESC1_FID_CACHE Vardesc1Fc; \

-	VARDESC2_FID_CACHE Vardesc2Fc; \

-	GCP_RESULTS_FID_CACHE GCP_RESULTSFc; \
-	TRIVERTEX_FID_CACHE TrivertexFc; \
-	GRADIENT_RECT_FID_CACHE GradientrectFc;
+	VARDESC2_FID_CACHE Vardesc2Fc;

 

 /*	PARAFORMAT_FID_CACHE ParaformatFc; \*/

 /*	CHARFORMAT_FID_CACHE CharformatFc; \*/

@@ -326,17 +323,6 @@
 

 typedef DRAWITEMSTRUCT_FID_CACHE *PDRAWITEMSTRUCT_FID_CACHE;

 

-/* GRADIENT_RECT struct */
-typedef struct GRADIENT_RECT_FID_CACHE {
-    
-    int cached;
-    jclass gradientrectClass;
-    jfieldID UpperLeft, LowerRight;
-
-} GRADIENT_RECT_FID_CACHE;
-
-typedef GRADIENT_RECT_FID_CACHE *PGRADIENT_RECT_FID_CACHE;
-
 /* HDITEM struct */

 typedef struct HDITEM_FID_CACHE {

     

@@ -824,17 +810,6 @@
 

 typedef TRACKMOUSEEVENT_FID_CACHE *PTRACKMOUSEEVENT_FID_CACHE;

 

-/* TRIVERTEX struct */
-typedef struct TRIVERTEX_FID_CACHE {
-    
-    int cached;
-    jclass trivertexClass;
-    jfieldID x, y, Red, Green, Blue, Alpha;
-
-} TRIVERTEX_FID_CACHE;
-
-typedef TRIVERTEX_FID_CACHE *PTRIVERTEX_FID_CACHE;
-
 /* TVHITTESTINFO struct */

 typedef struct TVHITTESTINFO_FID_CACHE {

     

@@ -1233,17 +1208,7 @@
 

 } VARDESC2_FID_CACHE;

 

-typedef VARDESC2_FID_CACHE *PVARDESC2_FID_CACHE;
-
-/* GCP_RESULTS struct */
-typedef struct GCP_RESULTS_FID_CACHE {
-	int cached;
-	jclass clazz;
-	jfieldID nMaxFit, nGlyphs, lpGlyphs, lpClass, lpCaretPos, lpDx, lpOrder, lpOutString, lStructSize;
-} GCP_RESULTS_FID_CACHE;
-
-typedef GCP_RESULTS_FID_CACHE *PGCP_RESULTS_FID_CACHE;
-
+typedef VARDESC2_FID_CACHE *PVARDESC2_FID_CACHE;

 

 /* ----------- ole cache function prototypes  ----------- */

 

@@ -1268,7 +1233,6 @@
 void cacheFuncdesc2Fids(JNIEnv *env, jobject lpFuncdesc, PFUNCDESC2_FID_CACHE lpCache);

 void cacheVardesc1Fids(JNIEnv *env, jobject lpVardesc, PVARDESC1_FID_CACHE lpCache);

 void cacheVardesc2Fids(JNIEnv *env, jobject lpVardesc, PVARDESC2_FID_CACHE lpCache);

-void cacheGCP_RESULTSFids(JNIEnv *env, jobject lpObject, PGCP_RESULTS_FID_CACHE lpCache);
 

 /* ----------- cache function prototypes  ----------- */

 

@@ -1290,7 +1254,6 @@
 void cacheDocinfoFids(JNIEnv *env, jobject lpDocinfo, PDOCINFO_FID_CACHE lpCache);

 void cacheDrawitemstructFids(JNIEnv *env, jobject lpDrawitemstruct, PDRAWITEMSTRUCT_FID_CACHE lpCache);

 void cacheDropfilesFids(JNIEnv *env, jobject lpDropfiles, PDROPFILES_FID_CACHE lpCache);

-void cacheGradientrectFids(JNIEnv *env, jobject lpGradientrect, PGRADIENT_RECT_FID_CACHE lpCache);
 void cacheHditemFids(JNIEnv *env, jobject lpHditem, PHDITEM_FID_CACHE lpCache);

 void cacheHdlayoutFids(JNIEnv *env, jobject lpHdlayout, PHDLAYOUT_FID_CACHE lpCache);

 void cacheHelpinfoFids(JNIEnv *env, jobject lpHelpinfo, PHELPINFO_FID_CACHE lpCache);

@@ -1336,7 +1299,6 @@
 void cacheTextmetricFids(JNIEnv *env, jobject lpTextmetric, PTEXTMETRIC_FID_CACHE lpCache);

 void cacheToolinfoFids(JNIEnv *env, jobject lpToolinfo, PTOOLINFO_FID_CACHE lpCache);

 void cacheTrackmouseeventFids(JNIEnv *env, jobject lpTrackmouseevent, PTRACKMOUSEEVENT_FID_CACHE lpCache);

-void cacheTrivertexFids(JNIEnv *env, jobject lpTrivertex, PTRIVERTEX_FID_CACHE lpCache);
 void cacheTvhittestinfoFids(JNIEnv *env, jobject lpTvhittestinfo, PTVHITTESTINFO_FID_CACHE lpCache);

 void cacheTvinsertstructFids(JNIEnv *env, jobject lpTvinsertstruct, PTVINSERTSTRUCT_FID_CACHE lpCache);

 void cacheTvitemFids(JNIEnv *env, jobject lpTvitem, PTVITEM_FID_CACHE lpCache);

@@ -1398,8 +1360,6 @@
 void setDocinfoFields(JNIEnv *env, jobject lpObject, DOCINFO *lpDocinfo, PDOCINFO_FID_CACHE lpDocinfoFc);

 void getDrawitemstructFields(JNIEnv *env, jobject lpObject, DRAWITEMSTRUCT *lpDrawitemstruct, PDRAWITEMSTRUCT_FID_CACHE lpDrawitemstructFc);

 void setDrawitemstructFields(JNIEnv *env, jobject lpObject, DRAWITEMSTRUCT *lpDrawitemstruct, PDRAWITEMSTRUCT_FID_CACHE lpDrawitemstructFc);

-void getGradientrectFields(JNIEnv *env, jobject lpObject, GRADIENT_RECT *lpGradientrect, GRADIENT_RECT_FID_CACHE *lpGradientrectFc);
-void setGradientrectFields(JNIEnv *env, jobject lpObject, GRADIENT_RECT *lpGradientrect, GRADIENT_RECT_FID_CACHE *lpGradientrectFc);
 void getHditemFields(JNIEnv *env, jobject lpObject, HDITEM *lpHditem, HDITEM_FID_CACHE *lpHditemFc);

 void setHditemFields(JNIEnv *env, jobject lpObject, HDITEM *lpHditem, HDITEM_FID_CACHE *lpHditemFc);

 void getHdlayoutFields(JNIEnv *env, jobject lpObject, HDLAYOUT *lpHdlayout, HDLAYOUT_FID_CACHE *lpHdlayoutFc);

@@ -1484,8 +1444,6 @@
 void setToolinfoFields(JNIEnv *env, jobject lpObject, TOOLINFO *lpToolinfo, TOOLINFO_FID_CACHE *lpToolinfoFc);

 void getTrackmouseeventFields(JNIEnv *env, jobject lpObject, TRACKMOUSEEVENT *lpTrackmouseevent, TRACKMOUSEEVENT_FID_CACHE *lpTrackmouseeventFc);

 void setTrackmouseeventFields(JNIEnv *env, jobject lpObject, TRACKMOUSEEVENT *lpTrackmouseevent, TRACKMOUSEEVENT_FID_CACHE *lpTrackmouseeventFc);

-void getTrivertexFields(JNIEnv *env, jobject lpObject, TRIVERTEX *lpTrivertex, TRIVERTEX_FID_CACHE *lpTrivertexFc);
-void setTrivertexFields(JNIEnv *env, jobject lpObject, TRIVERTEX *lpTrivertex, TRIVERTEX_FID_CACHE *lpTrivertexFc);
 void getTvhittestinfoFields(JNIEnv *env, jobject lpObject, TVHITTESTINFO *lpTvhittestinfo, TVHITTESTINFO_FID_CACHE *lpTvhittestinfoFc);

 void setTvhittestinfoFields(JNIEnv *env, jobject lpObject, TVHITTESTINFO *lpTvhittestinfo, TVHITTESTINFO_FID_CACHE *lpTvhittestinfoFc);

 void getTvinsertstructFields(JNIEnv *env, jobject lpObject, TVINSERTSTRUCT *lpTvinsertstruct, TVINSERTSTRUCT_FID_CACHE *lpTvinsertstructFc);

@@ -1556,8 +1514,6 @@
 void setVardesc1Fields(JNIEnv *env, jobject lpObject, VARDESC *lpVardesc, VARDESC1_FID_CACHE *lpVardescFc);

 void getVardesc2Fields(JNIEnv *env, jobject lpObject, VARDESC *lpVardesc, VARDESC2_FID_CACHE *lpVardescFc);

 void setVardesc2Fields(JNIEnv *env, jobject lpObject, VARDESC *lpVardesc, VARDESC2_FID_CACHE *lpVardescFc);

-void getGCP_RESULTSFields(JNIEnv *env, jobject lpObject, GCP_RESULTS *lpStruct, PGCP_RESULTS_FID_CACHE lpCache);
-void setGCP_RESULTSFields(JNIEnv *env, jobject lpObject, GCP_RESULTS *lpStruct, PGCP_RESULTS_FID_CACHE lpCache);
 

 

 #endif // INC_structs_H
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/library/swt.c b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/swt.c
index f16ddc5..eb9bc7e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/library/swt.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/swt.c
@@ -3220,38 +3220,6 @@
     return (jboolean) GlobalUnlock((HANDLE)hMem);
 }
 
-#ifdef USE_2000_CALLS
-/*
- * Class:     org_eclipse_swt_internal_win32_OS
- * Method:    GradientFill
- * Signature: (IIIIII)Z
- */
-JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_GradientFill
-  (JNIEnv *env, jclass that, jint hdc, int pVertex, jint dwNumVertex, int pMesh, jint dwNumMesh, jint dwMode)
-{
-	DECL_GLOB(pGlob)
-	BOOL rc = FALSE;
-    HMODULE hm;
-    FARPROC fp;
-	
-#ifdef DEBUG_CALL_PRINTS
-    fprintf(stderr, "GradientFill\n");
-#endif
-    /*
-    **  GradientFill is a Win2000 and Win98 specific call
-    **  If you link it into swt.dll, a system modal entry point not found dialog will
-    **  appear as soon as swt.dll is loaded. Here we check for the entry point and
-    **  only do the call if it exists.
-    */
-    if (! (hm = GetModuleHandle("msimg32.dll"))) hm = LoadLibrary("msimg32.dll");
-    if (hm && (fp = GetProcAddress(hm, "GradientFill"))) {
-		rc = fp((HDC)hdc, (PTRIVERTEX)pVertex, (ULONG)dwNumVertex, (PVOID)pMesh, (ULONG)dwNumMesh, (ULONG)dwMode);
-//		rc = GradientFill((HDC)hdc, (PTRIVERTEX)pVertex, (ULONG)dwNumVertex, (PVOID)pMesh, (ULONG)dwNumMesh, (ULONG)dwMode);
-    }
-    return (jboolean) rc;
-}
-#endif
-
 /*
  * Class:     org_eclipse_swt_internal_win32_OS
  * Method:    HeapAlloc
@@ -4389,29 +4357,6 @@
 /*
  * Class:     org_eclipse_swt_internal_win32_OS
  * Method:    MoveMemory
- * Signature: (ILorg/eclipse/swt/internal/win32/GRADIENT_RECT;I)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__ILorg_eclipse_swt_internal_win32_GRADIENT_1RECT_2I
-  (JNIEnv *env, jclass that, jint Destination, jobject Source, jint Length)
-{
-	DECL_GLOB(pGlob)
-    GRADIENT_RECT gradientrect, *lpSource1=NULL;
-
-#ifdef DEBUG_CALL_PRINTS
-    fprintf(stderr, "MoveMemory__ILorg_eclipse_swt_internal_win32_GRADIENT_1RECT_2I\n");
-#endif
-
-    if (Source) {
-        lpSource1 = &gradientrect;
-        cacheGradientrectFids(env, Source, &PGLOB(GradientrectFc));
-        getGradientrectFields(env, Source, lpSource1, &PGLOB(GradientrectFc));
-    }
-    MoveMemory((PVOID)Destination, lpSource1, Length);
-}
-
-/*
- * Class:     org_eclipse_swt_internal_win32_OS
- * Method:    MoveMemory
  * Signature: (ILorg/eclipse/swt/internal/win32/LOGFONT;I)V
  */
 JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__ILorg_eclipse_swt_internal_win32_LOGFONT_2I
@@ -4527,29 +4472,6 @@
 /*
  * Class:     org_eclipse_swt_internal_win32_OS
  * Method:    MoveMemory
- * Signature: (ILorg/eclipse/swt/internal/win32/TRIVERTEX;I)V
- */
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__ILorg_eclipse_swt_internal_win32_TRIVERTEX_2I
-  (JNIEnv *env, jclass that, jint Destination, jobject Source, jint Length)
-{
-	DECL_GLOB(pGlob)
-    TRIVERTEX trivertex, *lpSource1=NULL;
-
-#ifdef DEBUG_CALL_PRINTS
-    fprintf(stderr, "MoveMemory__ILorg_eclipse_swt_internal_win32_TRIVERTEX_2I\n");
-#endif
-
-    if (Source) {
-        lpSource1 = &trivertex;
-        cacheTrivertexFids(env, Source, &PGLOB(TrivertexFc));
-        getTrivertexFields(env, Source, lpSource1, &PGLOB(TrivertexFc));
-    }
-    MoveMemory((PVOID)Destination, lpSource1, Length);
-}
-
-/*
- * Class:     org_eclipse_swt_internal_win32_OS
- * Method:    MoveMemory
  * Signature: (Lorg/eclipse/swt/internal/win32/DRAWITEMSTRUCT;II)V
  */
 JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__Lorg_eclipse_swt_internal_win32_DRAWITEMSTRUCT_2II
@@ -8041,277 +7963,4 @@
         cacheMsgFids(env, Destination, &PGLOB(MsgFc));
         setMsgFields(env, Destination, lpDestination1, &PGLOB(MsgFc));
     }
-}
-
-/*
- * Class:     org_eclipse_swt_internal_win32_OS
- * Method:    GetCharacterPlacement
- * Signature: 
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetCharacterPlacement
-  (JNIEnv *env, jclass that, jint hdc, jbyteArray lpString, jint nCount, jint nMaxExtent, jobject lpResults, jint dwFlags)
-{
-	DECL_GLOB(pGlob)
-    GCP_RESULTS results, *lpResults1=NULL;
-    LPCTSTR lpString1=NULL;
-    jint rc;
-    
-#ifdef DEBUG_CALL_PRINTS
-    fprintf(stderr, "GetCharacterPlacement\n");
-#endif
-
-    if (lpString)
-        lpString1 = (LPCTSTR)(*env)->GetByteArrayElements(env, lpString, NULL);
-    if (lpResults) {
-        lpResults1 = &results;
-        cacheGCP_RESULTSFids(env, lpResults, &PGLOB(GCP_RESULTSFc));
-        getGCP_RESULTSFields(env, lpResults, lpResults1, &PGLOB(GCP_RESULTSFc));
-    }
-    
-    rc = (jint) GetCharacterPlacement((HDC)hdc, lpString1, nCount, nMaxExtent, lpResults1, dwFlags);
-    
-    if (lpString)
-        (*env)->ReleaseByteArrayElements(env, lpString, (jbyte *)lpString1, 0);
-    if (lpResults) {
-        setGCP_RESULTSFields(env, lpResults, lpResults1, &PGLOB(GCP_RESULTSFc));
-    }
-    return rc;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_win32_OS
- * Method:    ExtTextOut
- * Signature: 
- */
-JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ExtTextOut
-  (JNIEnv *env, jclass that, jint hdc, jint X, jint Y, jint fuOptions, jobject lprc, jbyteArray lpString, jint cbCount, jintArray lpDx)
-{
-	DECL_GLOB(pGlob)
-    RECT rect, *lpRect1=NULL;
-    LPCTSTR lpString1=NULL;
-	CONST INT* lpDx1 = NULL;
-    jboolean rc;
-    
-#ifdef DEBUG_CALL_PRINTS
-    fprintf(stderr, "ExtTextOut\n");
-#endif
-
-    if (lpString)
-        lpString1 = (LPCTSTR)(*env)->GetByteArrayElements(env, lpString, NULL);
-    if (lprc) {
-        lpRect1 = &rect;
-        cacheRectFids(env, lprc, &PGLOB(RectFc));
-        getRectFields(env, lprc, lpRect1, &PGLOB(RectFc));
-    }
-    if (lpDx)
-        lpDx1 = (CONST INT*)(*env)->GetIntArrayElements(env, lpDx, NULL);
-    
-    rc = (jboolean) ExtTextOut((HDC)hdc, X, Y, fuOptions, lpRect1, lpString1, cbCount, lpDx1);
-    
-    if (lpString)
-        (*env)->ReleaseByteArrayElements(env, lpString, (jbyte *)lpString1, 0);
-    if (lprc) {
-        setRectFields(env, lprc, lpRect1, &PGLOB(RectFc));
-    }
-    if (lpDx)
-        (*env)->ReleaseIntArrayElements(env, lpDx, (jint *)lpDx1, 0);
-    return rc;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_win32_OS
- * Method:    GetFontLanguageInfo
- * Signature: 
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetFontLanguageInfo
-  (JNIEnv *env, jclass that, jint hdc)
-{
-#ifdef DEBUG_CALL_PRINTS
-    fprintf(stderr, "GetFontLanguageInfo\n");
-#endif
-
-    return (jint) GetFontLanguageInfo((HDC)hdc);
-}
-
-/*
- * Class:     org_eclipse_swt_internal_win32_OS
- * Method:    GetKeyboardLayoutList
- * Signature: 
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetKeyboardLayoutList
-  (JNIEnv *env, jclass that, jint nBuff, jintArray lpList)
-{
-	HKL FAR *lpList1;
-    jint rc;
-    
-#ifdef DEBUG_CALL_PRINTS
-    fprintf(stderr, "GetKeyboardLayoutList\n");
-#endif
-
-    if (lpList)
-        lpList1 = (HKL FAR *)(*env)->GetIntArrayElements(env, lpList, NULL);
-
-    rc = (jint) GetKeyboardLayoutList(nBuff, lpList1);
-    
-    if (lpList)
-        (*env)->ReleaseIntArrayElements(env, lpList, (jint *)lpList1, 0);
-    return rc;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_win32_OS
- * Method:    GetKeyboardLayout
- * Signature: 
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetKeyboardLayout
-  (JNIEnv *env, jclass that, jint idThread)
-{
-#ifdef DEBUG_CALL_PRINTS
-    fprintf(stderr, "GetKeyboardLayout\n");
-#endif
-
-    return (jint) GetKeyboardLayout(idThread);
-}
-
-/*
- * Class:     org_eclipse_swt_internal_win32_OS
- * Method:    ActivateKeyboardLayout
- * Signature: 
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_ActivateKeyboardLayout
-  (JNIEnv *env, jclass that, jint hkl, jint Flags)
-{
-#ifdef DEBUG_CALL_PRINTS
-    fprintf(stderr, "ActivateKeyboardLayout\n");
-#endif
-
-    return (jint) ActivateKeyboardLayout((HKL)hkl, Flags);
-}
-
-/*
- * Class:     org_eclipse_swt_internal_win32_OS
- * Method:    SetTextAlign
- * Signature: 
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SetTextAlign
-  (JNIEnv *env, jclass that, jint hdc, jint fMode)
-{
-#ifdef DEBUG_CALL_PRINTS
-    fprintf(stderr, "SetTextAlign\n");
-#endif
-
-    return (jint) SetTextAlign((HDC)hdc, fMode);
-}
-
-/*
- * Class:     org_eclipse_swt_internal_win32_OS
- * Method:    TranslateCharsetInfo
- * Signature: 
- */
-JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_TranslateCharsetInfo
-  (JNIEnv *env, jclass that, jint lpSrc, jintArray lpCs, jint dwFlags)
-{
-	LPCHARSETINFO lpCs1 =NULL;
-    jboolean rc;
-    
-#ifdef DEBUG_CALL_PRINTS
-    fprintf(stderr, "TranslateCharsetInfo\n");
-#endif
-
-    if (lpCs)
-        lpCs1 = (LPCHARSETINFO)(*env)->GetIntArrayElements(env, lpCs, NULL);
-
-    rc = (jboolean)TranslateCharsetInfo((DWORD *)lpSrc, lpCs1, dwFlags);
-    
-    if (lpCs)
-        (*env)->ReleaseIntArrayElements(env, lpCs, (jint *)lpCs1, 0);
-        
-    return rc;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_win32_OS
- * Method:    GetTextCharset
- * Signature: 
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetTextCharset
-  (JNIEnv *env, jclass that, jint hdc)
-{
-#ifdef DEBUG_CALL_PRINTS
-    fprintf(stderr, "GetTextCharset\n");
-#endif
-
-    return (jint) GetTextCharset((HDC)hdc);
-}
-
-/*
- * Class:     org_eclipse_swt_internal_win32_OS
- * Method:    GetLocaleInfo
- * Signature: (II[BI)I
- */
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetLocaleInfo
-  (JNIEnv *env, jclass that, jint Locale, jint LCType, jbyteArray lpLCData, jint cchData)
-{
-    LPTSTR lpLCData1=NULL;
-    jint rc;
-
-#ifdef DEBUG_CALL_PRINTS
-    fprintf(stderr, "GetLocaleInfo\n");
-#endif
-
-    if (lpLCData)
-        lpLCData1 = (*env)->GetByteArrayElements(env, lpLCData, NULL);
-
-    rc = (jint) GetLocaleInfo(Locale, LCType, lpLCData1, cchData);
-
-    if (lpLCData)
-        (*env)->ReleaseByteArrayElements(env, lpLCData, (jbyte *)lpLCData1, 0);
-    return rc;
-}
-
-/*
- * Class:     org_eclipse_swt_internal_win32_OS
- * Method:    EnumSystemLocales
- * Signature: (II)Z
- */
-JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_EnumSystemLocales
-  (JNIEnv *env, jclass that, jint lpLocaleEnumProc, jint dwFlags)
-{
-#ifdef DEBUG_CALL_PRINTS
-    fprintf(stderr, "EnumSystemLocales\n");
-#endif
-
-    return (jboolean) EnumSystemLocales((LOCALE_ENUMPROC)lpLocaleEnumProc, (DWORD)dwFlags);
-}
-
-/*
- * Class:     org_eclipse_swt_internal_win32_OS
- * Method:    SystemParametersInfo
- * Signature: 
- */
-JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_SystemParametersInfo
-  (JNIEnv *env, jclass that, jint uiAction, jint uiName, jobject pvParam, jint fWinIni)
-{
-	DECL_GLOB(pGlob)
-    RECT rect, *pvParam1=NULL;
-    jboolean rc;
-    
-#ifdef DEBUG_CALL_PRINTS
-    fprintf(stderr, "SystemParametersInfo\n");
-#endif
-
-     if (pvParam) {
-        pvParam1 = &rect;
-        cacheRectFids(env, pvParam, &PGLOB(RectFc));
-        getRectFields(env, pvParam, pvParam1, &PGLOB(RectFc));
-    }
-    
-    rc = (jboolean) SystemParametersInfo(uiAction, uiName, pvParam1, fWinIni);
-    
-    if (pvParam) {
-        setRectFields(env, pvParam, pvParam1, &PGLOB(RectFc));
-    }
-
-    return rc;
-}
-
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/library/swt.rc b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/swt.rc
index c02562e..b875e93 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/library/swt.rc
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/swt.rc
@@ -34,7 +34,7 @@
 //

 

 VS_VERSION_INFO VERSIONINFO

- FILEVERSION 2,0,0,2

+ FILEVERSION 0,1,2,5

  PRODUCTVERSION 0,0,0,0

  FILEFLAGSMASK 0x3fL

 #ifdef _DEBUG

@@ -52,10 +52,10 @@
         BEGIN

             VALUE "CompanyName", "IBM Corporation\0"

             VALUE "FileDescription", "Standard Widget Toolkit\0"

-            VALUE "FileVersion", "win32 2.002\0"

+            VALUE "FileVersion", "win32 0.125\0"

             VALUE "InternalName", "SWT\0"

             VALUE "LegalCopyright", "© Copyright IBM Corp. 2000, 2001. All Rights Reserved.\0"

-            VALUE "OriginalFilename", "swt-win32-2002.dll\0"

+            VALUE "OriginalFilename", "swt0125.dll\0"

             VALUE "ProductName", "\0"

             VALUE "ProductVersion", "0, 0, 0, 0\0"

         END

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java
index 61cefdd..a6c06ba 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java
@@ -404,7 +404,6 @@
 			OS.EnumFontFamilies (hDC, lpFaceName, lpEnumFontFamProc, scalable ? 1 : 0);

 		}

 	} else {

-		/* Use the character encoding for the default locale */

 		byte [] lpFaceName = Converter.wcsToMbcs (0, faceName, true);

 		/**

 		 * Bug in Windows 98. When EnumFontFamiliesEx is called with a specified face name, it

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontData.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontData.java
index c388614..9b05c77 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontData.java
@@ -8,7 +8,6 @@
 import org.eclipse.swt.internal.*;

 import org.eclipse.swt.internal.win32.*;

 import org.eclipse.swt.*;

-import java.util.Locale;

 

 /**

  * Instances of this class describe operating system fonts.

@@ -50,12 +49,6 @@
 	 */

 	public int height;

 	

-	/**

-	 * The locale of the font

-	 * (Warning: This field is platform dependent)

-	 */

-	Locale locale;

-	

 /**	 

  * Constructs a new un-initialized font data.

  */

@@ -331,37 +324,6 @@
 		data.lfFaceName31 == lf.lfFaceName31;

 }

 

-int EnumLocalesProc(int lpLocaleString) {

-	

-	/* Get the locale ID */

-	int length = 8;

-	byte[] buffer = new byte[length];

-	OS.MoveMemory(buffer, lpLocaleString, length);

-	int lcid = Integer.parseInt(new String(buffer, 0, length), 16);

-

-	/* Check the language */

-	int size = OS.GetLocaleInfo(lcid, OS.LOCALE_SISO639LANGNAME, buffer, length);

-	String lang = new String(buffer, 0, size - 1);

-	if (!locale.getLanguage().equals(lang)) return 1;

-

-	/* Check the country */

-	String javaCountry = locale.getCountry();

-	if (javaCountry.length() != 0) {

-		size = OS.GetLocaleInfo(lcid, OS.LOCALE_SISO3166CTRYNAME, buffer, length);

-		String country = new String(buffer, 0, size - 1);

-		if (!javaCountry.equals(country)) return 1;

-	}

-

-	/* Get the charset */

-	size = OS.GetLocaleInfo(lcid, OS.LOCALE_IDEFAULTANSICODEPAGE, buffer, length);

-	int cp = Integer.parseInt(new String(buffer, 0, size - 1));

-	int [] lpCs = new int[8];

-	OS.TranslateCharsetInfo(cp, lpCs, OS.TCI_SRCCODEPAGE);

-	data.lfCharSet = (byte)lpCs[0];

-

-	return 0;

-}

-

 /**

  * Returns the height of the receiver in points.

  *

@@ -404,7 +366,6 @@
 		System.arraycopy(bytes, 0, newBytes, 0, index);

 		bytes = newBytes;

 	}

-	/* Use the character encoding for the default locale */

 	char[] name = Converter.mbcsToWcs(0, bytes);

 	return new String(name);

 }

@@ -472,24 +433,6 @@
 }

 

 /**

- * Sets the locale of the receiver.

- *

- * @param locale the Locale of the <code>FontData</code>

- *

- */

-public void setLocale(Locale locale) {

-	this.locale = locale;

-	if (locale == null) {

-		data.lfCharSet = OS.DEFAULT_CHARSET;

-	} else {

-		Callback callback = new Callback (this, "EnumLocalesProc", 1);

-		int lpEnumLocalesProc = callback.getAddress ();	

-		OS.EnumSystemLocales(lpEnumLocalesProc, OS.LCID_SUPPORTED);

-		callback.dispose ();

-	}

-}

-

-/**

  * Sets the name of the receiver.

  * <p>

  * Some platforms support font foundries. On these platforms, the name

@@ -507,12 +450,11 @@
  * <code>getName()</code>.

  * </p>

  *

- * @param name the name of the font data (must not be null)

+ * @param name the name of the font data

  *

  * @see #getName

  */

 public void setName(String name) {

-	/* Use the character encoding for the default locale */

 	byte[] nameBytes = Converter.wcsToMbcs(0, name, true);

 	/* Pad nameBytes to 32 */

 	byte[] paddedNameBytes = new byte[32];

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
index bbc7330..21b370b 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
@@ -587,8 +587,8 @@
 	/* Create resources */

 	int srcHdc = OS.CreateCompatibleDC(handle);

 	int oldSrcBitmap = OS.SelectObject(srcHdc, srcImage.handle);

+	int memDib = createDIB(destWidth, destHeight, 32);

 	int memHdc = OS.CreateCompatibleDC(handle);

-	int memDib = createDIB(Math.max(srcWidth, destWidth), Math.max(srcWidth, destHeight), 32);

 	int oldMemBitmap = OS.SelectObject(memHdc, memDib);

 

 	BITMAP dibBM = new BITMAP();

@@ -601,46 +601,23 @@
 	OS.MoveMemory(destData, dibBM.bmBits, sizeInBytes);

 

  	/* Get the foreground pixels */

- 	OS.BitBlt(memHdc, 0, 0, srcWidth, srcHeight, srcHdc, srcX, srcY, OS.SRCCOPY);

- 	byte[] srcData = new byte[sizeInBytes];

-	OS.MoveMemory(srcData, dibBM.bmBits, sizeInBytes);

-	

-	/* Merge the alpha channel in place */

-	int alpha = srcImage.alpha;

-	final boolean hasAlphaChannel = (srcImage.alpha == -1);

-	if (hasAlphaChannel) {

-		final int apinc = imgWidth - srcWidth;

-		final int spinc = dibBM.bmWidthBytes - srcWidth * 4;

-		int ap = 0, sp = 3;

-		byte[] alphaData = srcImage.alphaData;

-		for (int y = 0; y < srcHeight; ++y) {

-			for (int x = 0; x < srcWidth; ++x) {

-				srcData[sp] = alphaData[ap++];

-				sp += 4;

-			}

-			ap += apinc;

-			sp += spinc;

-		}

-	}

-	

-	/* Scale the foreground pixels with alpha */

 	OS.SetStretchBltMode(memHdc, OS.COLORONCOLOR);

-	OS.MoveMemory(dibBM.bmBits, srcData, sizeInBytes);

-	OS.StretchBlt(memHdc, 0, 0, destWidth, destHeight, memHdc, 0, 0, srcWidth, srcHeight, OS.SRCCOPY);

+	OS.StretchBlt(memHdc, 0, 0, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, OS.SRCCOPY);

+	byte[] srcData = new byte[sizeInBytes];

 	OS.MoveMemory(srcData, dibBM.bmBits, sizeInBytes);

-	

+

 	/* Compose the pixels */

-	final int dpinc = dibBM.bmWidthBytes - destWidth * 4;

-	int dp = 0;

-	for (int y = 0; y < destHeight; ++y) {

-		for (int x = 0; x < destWidth; ++x) {

-			if (hasAlphaChannel) alpha = srcData[dp + 3] & 0xff;

-			destData[dp] += ((srcData[dp] & 0xff) - (destData[dp] & 0xff)) * alpha / 255;

-			destData[dp + 1] += ((srcData[dp + 1] & 0xff) - (destData[dp + 1] & 0xff)) * alpha / 255;

-			destData[dp + 2] += ((srcData[dp + 2] & 0xff) - (destData[dp + 2] & 0xff)) * alpha / 255;

-			dp += 4;

-		}

-		dp += dpinc;

+	int alpha = srcImage.alpha;

+	byte[] alphaData = null;

+	if (alpha == -1) {

+		alphaData = new byte[destWidth * destHeight];

+		ImageData.stretch8(srcImage.alphaData, imgWidth, srcX, srcY, srcWidth, srcHeight, alphaData, destWidth, 0, 0, destWidth, destHeight, null, false, false);

+	}

+	for (int i = 0; i < sizeInBytes; i += 4) {

+		if (alphaData != null) alpha = alphaData[i / 4] & 0xff;

+		destData[i] += ((srcData[i] & 0xFF) - (destData[i] & 0xFF)) * alpha / 255;

+		destData[i+1] += ((srcData[i+1] & 0xFF) - (destData[i+1] & 0xFF)) * alpha / 255;

+		destData[i+2] += ((srcData[i+2] & 0xFF) - (destData[i+2] & 0xFF)) * alpha / 255;

 	}

 

 	/* Draw the composed pixels */

@@ -722,10 +699,10 @@
 

 	/* Create the mask for the source image */

 	int maskHdc = OS.CreateCompatibleDC(hDC);

-	int maskBitmap = OS.CreateBitmap(imgWidth, imgHeight, 1, 1, null);

+	int maskBitmap = OS.CreateBitmap(srcWidth, srcHeight, 1, 1, null);

 	int oldMaskBitmap = OS.SelectObject(maskHdc, maskBitmap);

 	OS.SetBkColor(srcHdc, (transBlue << 16) | (transGreen << 8) | transRed);

-	OS.BitBlt(maskHdc, 0, 0, imgWidth, imgHeight, srcHdc, 0, 0, OS.SRCCOPY);

+	OS.BitBlt(maskHdc, 0, 0, srcWidth, srcHeight, srcHdc, 0, 0, OS.SRCCOPY);

 	if (originalColors != null) OS.SetDIBColorTable(srcHdc, 0, 1 << bm.bmBitsPixel, originalColors);

 

 	/* Draw the source bitmap transparently using invert/and mask/invert */

@@ -813,7 +790,7 @@
 	// set the background color, we may not have to do this work?

 	int nullBrush = OS.GetStockObject(OS.NULL_BRUSH);

 	int oldBrush = OS.SelectObject(handle, nullBrush);

-	OS.Ellipse(handle, x,y,x+width+1,y+height+1);

+	OS.Ellipse(handle, x,y,x+width,y+height);

 	OS.SelectObject(handle,oldBrush);

 }

 

@@ -956,7 +933,7 @@
  */

 public void drawString (String string, int x, int y) {

 	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

-	byte [] buffer = Converter.wcsToMbcs (getCodePage(), string, false);

+	byte [] buffer = Converter.wcsToMbcs (0, string, false);

 	OS.TextOut (handle, x, y, buffer, buffer.length);

 }

 

@@ -982,7 +959,7 @@
  */

 public void drawString (String string, int x, int y, boolean isTransparent) {

 	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

-	byte [] buffer = Converter.wcsToMbcs (getCodePage(), string, false);

+	byte [] buffer = Converter.wcsToMbcs (0, string, false);

 	if (isTransparent) {

 		int oldBkMode = OS.SetBkMode(handle, OS.TRANSPARENT);

 		OS.TextOut (handle, x, y, buffer, buffer.length);

@@ -1014,7 +991,7 @@
 	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

 	RECT rect = new RECT();

 	OS.SetRect(rect, x, y, 0x7FFF, 0x7FFF);

-	byte [] buffer = Converter.wcsToMbcs(getCodePage(), string, false);

+	byte [] buffer = Converter.wcsToMbcs(0, string, false);

 	OS.DrawText(handle, buffer, buffer.length, rect, OS.DT_EXPANDTABS | OS.DT_LEFT | OS.DT_NOPREFIX);

 }

 

@@ -1042,7 +1019,7 @@
 	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

 	RECT rect = new RECT();

 	OS.SetRect(rect, x, y, 0x7FFF, 0x7FFF);

-	byte [] buffer = Converter.wcsToMbcs(getCodePage(), string, false);

+	byte [] buffer = Converter.wcsToMbcs(0, string, false);

 	if (isTransparent) {

 		int oldBkMode = OS.SetBkMode(handle, OS.TRANSPARENT);

 		OS.DrawText(handle, buffer, buffer.length, rect, OS.DT_EXPANDTABS | OS.DT_LEFT | OS.DT_NOPREFIX);

@@ -1149,98 +1126,6 @@
 	

 }

 

-/**

- * Fills the interior of the specified rectangle with a gradient

- * sweeping from left to right or top to bottom progressing

- * from the receiver's foreground color to its background color.

- *

- * @param x the x coordinate of the rectangle to be filled

- * @param y the y coordinate of the rectangle to be filled

- * @param width the width of the rectangle to be filled, may be negative

- *        (inverts direction of gradient if horizontal)

- * @param height the height of the rectangle to be filled, may be negative

- *        (inverts direction of gradient if vertical)

- * @param vertical if true sweeps from top to bottom, else 

- *        sweeps from left to right

- *

- * @exception SWTException <ul>

- *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>

- * </ul>

- *

- * @see #drawRectangle

- */

-public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {

-	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

-	if (width == 0 || height == 0) return;

-	int fromColor = OS.GetTextColor(handle);

-	if (fromColor == OS.CLR_INVALID) {

-		fromColor = OS.GetSysColor(OS.COLOR_WINDOWTEXT);

-	}

-	int toColor = OS.GetBkColor(handle);

-	if (toColor == OS.CLR_INVALID) {

-		toColor = OS.GetSysColor(OS.COLOR_WINDOW);

-	}

-	boolean swapColors = false;

-	if (width < 0) {

-		x += width; width = -width;

-		if (! vertical) swapColors = true;

-	}

-	if (height < 0) {

-		y += height; height = -height;

-		if (vertical) swapColors = true;

-	}

-	if (swapColors) {

-		final int t = fromColor;

-		fromColor = toColor;

-		toColor = t;

-	}

-	final RGB fromRGB = new RGB(fromColor & 0xff, (fromColor >>> 8) & 0xff, (fromColor >>> 16) & 0xff);

-	final RGB toRGB = new RGB(toColor & 0xff, (toColor >>> 8) & 0xff, (toColor >>> 16) & 0xff);	

-	if ((fromRGB.red == toRGB.red) && (fromRGB.green == toRGB.green) && (fromRGB.blue == toRGB.blue)) {

-		OS.PatBlt(handle, x, y, width, height, OS.PATCOPY);

-		return;

-	}

-

-	/* Use GradientFill if supported, only on Windows 98, 2000 and newer */

-	final int hHeap = OS.GetProcessHeap();

-	final int pMesh = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY,

-		GRADIENT_RECT.sizeof + TRIVERTEX.sizeof * 2);

-	final int pVertex = pMesh + GRADIENT_RECT.sizeof;

-

-	GRADIENT_RECT gradientRect = new GRADIENT_RECT();

-	gradientRect.UpperLeft = 0;

-	gradientRect.LowerRight = 1;

-	OS.MoveMemory(pMesh, gradientRect, gradientRect.sizeof);

-

-	TRIVERTEX trivertex = new TRIVERTEX();

-	trivertex.x = x;

-	trivertex.y = y;

-	trivertex.Red = (short)((fromRGB.red << 8) | fromRGB.red);

-	trivertex.Green = (short)((fromRGB.green << 8) | fromRGB.green);

-	trivertex.Blue = (short)((fromRGB.blue << 8) | fromRGB.blue);

-	trivertex.Alpha = -1;

-	OS.MoveMemory(pVertex, trivertex, TRIVERTEX.sizeof);

-	

-	trivertex.x = x + width;

-	trivertex.y = y + height;

-	trivertex.Red = (short)((toRGB.red << 8) | toRGB.red);

-	trivertex.Green = (short)((toRGB.green << 8) | toRGB.green);

-	trivertex.Blue = (short)((toRGB.blue << 8) | toRGB.blue);

-	trivertex.Alpha = -1;

-	OS.MoveMemory(pVertex + TRIVERTEX.sizeof, trivertex, TRIVERTEX.sizeof);

-

-	boolean success = OS.GradientFill(handle, pVertex, 2, pMesh, 1,

-		vertical ? OS.GRADIENT_FILL_RECT_V : OS.GRADIENT_FILL_RECT_H);

-	OS.HeapFree(hHeap, 0, pMesh);

-	if (success) return;

-	

-	final int depth = OS.GetDeviceCaps(handle, OS.BITSPIXEL);

-	final int bitResolution = (depth >= 24) ? 8 : (depth >= 15) ? 5 : 0;

-	ImageData.fillGradientRectangle(this, data.device,

-		x, y, width, height, vertical, fromRGB, toRGB,

-		bitResolution, bitResolution, bitResolution);

-}

-

 /** 

  * Fills the interior of an oval, within the specified

  * rectangular area, with the receiver's background

@@ -1263,7 +1148,7 @@
 	/* Assumes that user sets the background color. */

 	int nullPen = OS.GetStockObject(OS.NULL_PEN);

 	int oldPen = OS.SelectObject(handle, nullPen);

-	OS.Ellipse(handle, x,y,x+width+1,y+height+1);

+	OS.Ellipse(handle, x,y,x+width,y+height);

 	OS.SelectObject(handle,oldPen);

 }

 

@@ -1379,7 +1264,7 @@
  */

 public int getAdvanceWidth(char ch) {

 	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

-	byte[] buffer = Converter.wcsToMbcs(getCodePage(), new char[] { ch });

+	byte[] buffer = Converter.wcsToMbcs(0, new char[] { ch });

 	int val = 0;

 	for (int i = 0; i < buffer.length; i++) {

 		val |= (buffer[i] & 0xFF) << (i * 8);

@@ -1425,7 +1310,7 @@
  */

 public int getCharWidth(char ch) {

 	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

-	byte[] buffer = Converter.wcsToMbcs(getCodePage(), new char[] { ch });

+	byte[] buffer = Converter.wcsToMbcs(0, new char[] { ch });

 	int val = 0;

 	for (int i = 0; i < buffer.length; i++) {

 		val |= (buffer[i] & 0xFF) << (i * 8);

@@ -1485,13 +1370,6 @@
 	OS.SetRectRgn(region.handle, rect.left, rect.top, rect.right, rect.bottom);

 }

 

-int getCodePage () {

-	int[] lpCs = new int[8];

-	int cs = OS.GetTextCharset(handle);

-	OS.TranslateCharsetInfo(cs, lpCs, OS.TCI_SRCCHARSET);

-	return lpCs[1];

-}

-

 /** 

  * Returns the font currently being used by the receiver

  * to draw and measure text.

@@ -1939,7 +1817,7 @@
 		OS.GetTextExtentPoint32(handle, SPACE, 1, size);

 		return new Point(0, size.cy);

 	} else {

-		byte [] buffer = Converter.wcsToMbcs(getCodePage(), string, false);

+		byte [] buffer = Converter.wcsToMbcs(0, string, false);

 		OS.GetTextExtentPoint32(handle, buffer, buffer.length, size);

 		return new Point(size.cx, size.cy);

 	}

@@ -1973,7 +1851,7 @@
 		return new Point(0, size.cy);

 	} else {

 		RECT rect = new RECT();

-		byte [] buffer = Converter.wcsToMbcs(getCodePage(), string, false);

+		byte [] buffer = Converter.wcsToMbcs(0, string, false);

 		OS.DrawText(handle, buffer, buffer.length, rect, OS.DT_EXPANDTABS | OS.DT_LEFT | OS.DT_NOPREFIX | OS.DT_CALCRECT);

 		return new Point(rect.right, rect.bottom);

 	}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
index aaec287..a321b0c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
@@ -477,7 +477,6 @@
  *

  * @exception IllegalArgumentException <ul>

  *    <li>ERROR_NULL_ARGUMENT - if the bounds rectangle is null</li>

- *    <li>ERROR_INVALID_ARGUMENT - if either the rectangle's width or height is negative</li>

  * </ul>

  */

 public Image(Device device, Rectangle bounds) {

@@ -1269,9 +1268,8 @@
 	if ((i.depth == 1 && i.getTransparencyType() != SWT.TRANSPARENCY_MASK) || i.depth == 2) {

 		ImageData img = new ImageData(i.width, i.height, 4, i.palette);

 		ImageData.blit(ImageData.BLIT_SRC, 

-			i.data, i.depth, i.bytesPerLine, i.getByteOrder(), 0, 0, i.width, i.height, null, null, null,

-			ImageData.ALPHA_OPAQUE, null, 0,

-			img.data, img.depth, img.bytesPerLine, i.getByteOrder(), 0, 0, img.width, img.height, null, null, null, 

+			i.data, i.depth, i.bytesPerLine, ImageData.MSB_FIRST, 0, 0, i.width, i.height, null, null, null, -1, null, 0,

+			img.data, img.depth, img.bytesPerLine, ImageData.MSB_FIRST, 0, 0, img.width, img.height, null, null, null, 

 			false, false);

 		img.transparentPixel = i.transparentPixel;

 		img.maskPad = i.maskPad;

@@ -1287,22 +1285,15 @@
 	 * Windows-supported.

 	 */

 	if (i.palette.isDirect) {

-		final PaletteData palette = i.palette;

-		final int redMask = palette.redMask;

-		final int greenMask = palette.greenMask;

-		final int blueMask = palette.blueMask;

-		int newDepth = i.depth;

-		int newOrder = ImageData.MSB_FIRST;

 		PaletteData newPalette = null;

-

+		PaletteData palette = i.palette;

+		int redMask = palette.redMask;

+		int greenMask = palette.greenMask;

+		int blueMask = palette.blueMask;

+		int order = ImageData.MSB_FIRST;

 		switch (i.depth) {

-			case 8:

-				newDepth = 16;

-				newOrder = ImageData.LSB_FIRST;

-				newPalette = new PaletteData(0x7C00, 0x3E0, 0x1F);

-				break;

 			case 16:

-				newOrder = ImageData.LSB_FIRST;

+				order = ImageData.LSB_FIRST;

 				if (!(redMask == 0x7C00 && greenMask == 0x3E0 && blueMask == 0x1F)) {

 					newPalette = new PaletteData(0x7C00, 0x3E0, 0x1F);

 				}

@@ -1321,11 +1312,10 @@
 				SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);

 		}

 		if (newPalette != null) {

-			ImageData img = new ImageData(i.width, i.height, newDepth, newPalette);

+			ImageData img = new ImageData(i.width, i.height, i.depth, newPalette);

 			ImageData.blit(ImageData.BLIT_SRC, 

-					i.data, i.depth, i.bytesPerLine, i.getByteOrder(), 0, 0, i.width, i.height, redMask, greenMask, blueMask,

-					ImageData.ALPHA_OPAQUE, null, 0,

-					img.data, img.depth, img.bytesPerLine, newOrder, 0, 0, img.width, img.height, newPalette.redMask, newPalette.greenMask, newPalette.blueMask,

+					i.data, i.depth, i.bytesPerLine, order, 0, 0, i.width, i.height, redMask, greenMask, blueMask, -1, null, 0,

+					img.data, img.depth, img.bytesPerLine, order, 0, 0, img.width, img.height, newPalette.redMask, newPalette.greenMask, newPalette.blueMask,

 					false, false);

 			if (i.transparentPixel != -1) {

 				img.transparentPixel = newPalette.getPixel(palette.getRGB(i.transparentPixel));

@@ -1489,7 +1479,6 @@
  * @private

  */

 public int internal_new_GC (GCData data) {

-	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

 	/*

 	* Create a new GC that can draw into the image.

 	* Only supported for bitmaps.

@@ -1560,15 +1549,8 @@
  *    image.setBackground(b.getBackground());>

  *    b.setImage(image);

  * </pre>

- * </p><p>

- * The image may be modified by this operation (in effect, the

- * transparent regions may be filled with the supplied color).  Hence

- * this operation is not reversible and it is not legal to call

- * this function twice or with a null argument.

- * </p><p>

  * This method has no effect if the receiver does not have a transparent

  * pixel value.

- * </p>

  *

  * @param color the color to use when a transparent pixel is specified

  *

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java
index 8a82e6c..383a97d 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java
@@ -52,7 +52,6 @@
  *

  * @exception IllegalArgumentException <ul>

  *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>

- *    <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>

  * </ul>

  * @exception SWTException <ul>

  *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>

@@ -61,8 +60,6 @@
 public void add (Rectangle rect) {

 	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

 	if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

-	if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

-	

 	int rectRgn = OS.CreateRectRgn (rect.x, rect.y, rect.x + rect.width, rect.y + rect.height);

 	OS.CombineRgn (handle, handle, rectRgn, OS.RGN_OR);

 	OS.DeleteObject (rectRgn);

@@ -77,7 +74,6 @@
  *

  * @exception IllegalArgumentException <ul>

  *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>

- *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>

  * </ul>

  * @exception SWTException <ul>

  *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>

@@ -86,7 +82,6 @@
 public void add (Region region) {

 	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);

 	if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);

-	if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 	OS.CombineRgn (handle, handle, region.handle, OS.RGN_OR);

 }

 

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/OS.java
index 92f6e52..a48ecac 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/OS.java
@@ -29,33 +29,6 @@
 	/* OLE Constants */

 	public static final int S_OK = 0;

 	

-	/* Charset Constants */

-//	public static final int ANSI_CHARSET           = 0;

-	public static final int DEFAULT_CHARSET        = 1;

-//	public static final int SYMBOL_CHARSET         = 2;

-//	public static final int SHIFTJIS_CHARSET       = 128;

-//	public static final int HANGEUL_CHARSET        = 129;

-//	public static final int GB2312_CHARSET         = 134;

-//	public static final int CHINESEBIG5_CHARSET    = 136;

-//	public static final int OEM_CHARSET            = 255;

-//	public static final int JOHAB_CHARSET          = 130;

-//	public static final int HEBREW_CHARSET         = 177;

-//	public static final int ARABIC_CHARSET         = 178;

-//	public static final int GREEK_CHARSET          = 161;

-//	public static final int TURKISH_CHARSET        = 162;

-//	public static final int VIETNAMESE_CHARSET     = 163;

-//	public static final int THAI_CHARSET           = 222;

-//	public static final int EASTEUROPE_CHARSET     = 238;

-//	public static final int RUSSIAN_CHARSET        = 204;

-//	public static final int MAC_CHARSET            = 77;

-//	public static final int BALTIC_CHARSET         = 186;

-	

-	/* Locale Constants */

-	public static final int LCID_SUPPORTED = 0x00000002;

-	public static final int LOCALE_SISO3166CTRYNAME = 0x0000005A;

-	public static final int LOCALE_SISO639LANGNAME = 0x00000059;

-	public static final int LOCALE_IDEFAULTANSICODEPAGE = 0x00001004;

-	

 	/* Window Constants */

 	public static final int COLOR_BTNFACE = 15;

 	public static final int COLOR_BTNHIGHLIGHT = 20;

@@ -95,159 +68,6 @@
 //	public static final byte WBF_CLASS = 0x0F;

 //	public static final byte WBF_ISWHITE = 0x10;

 

-/*** BEGIN SystemParametersInfo ***/

-//	public static final int SPI_GETBEEP = 1;

-//	public static final int SPI_SETBEEP = 2;

-//	public static final int SPI_GETMOUSE = 3;

-//	public static final int SPI_SETMOUSE = 4;

-//	public static final int SPI_GETBORDER = 5;

-//	public static final int SPI_SETBORDER = 6;

-//	public static final int SPI_GETKEYBOARDSPEED = 10;

-//	public static final int SPI_SETKEYBOARDSPEED = 11;

-//	public static final int SPI_LANGDRIVER = 12;

-//	public static final int SPI_ICONHORIZONTALSPACING = 13;

-//	public static final int SPI_GETSCREENSAVETIMEOUT   = 14;

-//	public static final int SPI_SETSCREENSAVETIMEOUT   = 15;

-//	public static final int SPI_GETSCREENSAVEACTIVE    = 16;

-//	public static final int SPI_SETSCREENSAVEACTIVE    = 17;

-//	public static final int SPI_GETGRIDGRANULARITY     = 18;

-//	public static final int  SPI_SETGRIDGRANULARITY     = 19;

-//	public static final int  SPI_SETDESKWALLPAPER       = 20;

-//	public static final int  SPI_SETDESKPATTERN         = 21;

-//	public static final int  SPI_GETKEYBOARDDELAY       = 22;

-//	public static final int  SPI_SETKEYBOARDDELAY       = 23;

-//	public static final int  SPI_ICONVERTICALSPACING    = 24;

-//	public static final int  SPI_GETICONTITLEWRAP       = 25;

-//	public static final int  SPI_SETICONTITLEWRAP       = 26;

-//	public static final int  SPI_GETMENUDROPALIGNMENT   = 27;

-//	public static final int  SPI_SETMENUDROPALIGNMENT   = 28;

-//	public static final int  SPI_SETDOUBLECLKWIDTH      = 29;

-//	public static final int  SPI_SETDOUBLECLKHEIGHT     = 30;

-//	public static final int  SPI_GETICONTITLELOGFONT    = 31;

-//	public static final int  SPI_SETDOUBLECLICKTIME     = 32;

-//	public static final int  SPI_SETMOUSEBUTTONSWAP     = 33;

-//	public static final int  SPI_SETICONTITLELOGFONT    = 34;

-//	public static final int  SPI_GETFASTTASKSWITCH      = 35;

-//	public static final int  SPI_SETFASTTASKSWITCH      = 36;

-//	public static final int  SPI_SETDRAGFULLWINDOWS     = 37;

-//	public static final int  SPI_GETDRAGFULLWINDOWS     = 38;

-//	public static final int  SPI_GETNONCLIENTMETRICS    = 41;

-//	public static final int  SPI_SETNONCLIENTMETRICS    = 42;

-//	public static final int  SPI_GETMINIMIZEDMETRICS    = 43;

-//	public static final int  SPI_SETMINIMIZEDMETRICS    = 44;

-//	public static final int  SPI_GETICONMETRICS         = 45;

-//	public static final int  SPI_SETICONMETRICS         = 46;

-//	public static final int  SPI_SETWORKAREA            = 47;

-	public static final int  SPI_GETWORKAREA            = 48;

-//	public static final int  SPI_SETPENWINDOWS          = 49;

-//	public static final int  SPI_GETHIGHCONTRAST        = 66;

-//	public static final int  SPI_SETHIGHCONTRAST        = 67;

-//	public static final int  SPI_GETKEYBOARDPREF        = 68;

-//	public static final int  SPI_SETKEYBOARDPREF        = 69;

-//	public static final int  SPI_GETSCREENREADER        = 70;

-//	public static final int  SPI_SETSCREENREADER        = 71;

-//	public static final int  SPI_GETANIMATION           = 72;

-//	public static final int  SPI_SETANIMATION           = 73;

-//	public static final int  SPI_GETFONTSMOOTHING       = 74;

-//	public static final int  SPI_SETFONTSMOOTHING       = 75;

-//	public static final int  SPI_SETDRAGWIDTH           = 76;

-//	public static final int  SPI_SETDRAGHEIGHT          = 77;

-//	public static final int  SPI_SETHANDHELD            = 78;

-//	public static final int  SPI_GETLOWPOWERTIMEOUT     = 79;

-//	public static final int  SPI_GETPOWEROFFTIMEOUT     = 80;

-//	public static final int  SPI_SETLOWPOWERTIMEOUT     = 81;

-//	public static final int  SPI_SETPOWEROFFTIMEOUT     = 82;

-//	public static final int  SPI_GETLOWPOWERACTIVE      = 83;

-//	public static final int  SPI_GETPOWEROFFACTIVE      = 84;

-//	public static final int  SPI_SETLOWPOWERACTIVE      = 85;

-//	public static final int  SPI_SETPOWEROFFACTIVE      = 86;

-//	public static final int  SPI_SETCURSORS             = 87;

-//	public static final int  SPI_SETICONS               = 88;

-//	public static final int  SPI_GETDEFAULTINPUTLANG    = 89;

-//	public static final int  SPI_SETDEFAULTINPUTLANG    = 90;

-//	public static final int  SPI_SETLANGTOGGLE          = 91;

-//	public static final int  SPI_GETWINDOWSEXTENSION    = 92;

-//	public static final int  SPI_SETMOUSETRAILS         = 93;

-//	public static final int  SPI_GETMOUSETRAILS         = 94;

-//	public static final int  SPI_SETSCREENSAVERRUNNING  = 97;

-//	public static final int  SPI_SCREENSAVERRUNNING     = SPI_SETSCREENSAVERRUNNING;

-//	public static final int  SPI_GETFILTERKEYS          = 50;

-//	public static final int  SPI_SETFILTERKEYS          = 51;

-//	public static final int  SPI_GETTOGGLEKEYS          = 52;

-//	public static final int  SPI_SETTOGGLEKEYS          = 53;

-//	public static final int  SPI_GETMOUSEKEYS           = 54;

-//	public static final int  SPI_SETMOUSEKEYS           = 55;

-//	public static final int  SPI_GETSHOWSOUNDS          = 56;

-//	public static final int  SPI_SETSHOWSOUNDS          = 57;

-//	public static final int  SPI_GETSTICKYKEYS          = 58;

-//	public static final int  SPI_SETSTICKYKEYS          = 59;

-//	public static final int  SPI_GETACCESSTIMEOUT       = 60;

-//	public static final int  SPI_SETACCESSTIMEOUT       = 61;

-//	public static final int  SPI_GETSERIALKEYS          = 62;

-//	public static final int  SPI_SETSERIALKEYS          = 63;

-//	public static final int  SPI_GETSOUNDSENTRY         = 64;

-//	public static final int  SPI_SETSOUNDSENTRY         = 65;

-//	public static final int  SPI_GETSNAPTODEFBUTTON     = 95;

-//	public static final int  SPI_SETSNAPTODEFBUTTON     = 96;

-//	public static final int  SPI_GETMOUSEHOVERWIDTH     = 98;

-//	public static final int  SPI_SETMOUSEHOVERWIDTH     = 99;

-//	public static final int  SPI_GETMOUSEHOVERHEIGHT   = 100;

-//	public static final int  SPI_SETMOUSEHOVERHEIGHT   = 101;

-//	public static final int  SPI_GETMOUSEHOVERTIME     = 102;

-//	public static final int  SPI_SETMOUSEHOVERTIME     = 103;

-//	public static final int  SPI_GETWHEELSCROLLLINES   = 104;

-//	public static final int  SPI_SETWHEELSCROLLLINES   = 105;

-//	public static final int  SPI_GETMENUSHOWDELAY      = 106;

-//	public static final int  SPI_SETMENUSHOWDELAY      = 107;

-//	public static final int  SPI_GETSHOWIMEUI          = 110;

-//	public static final int  SPI_SETSHOWIMEUI          = 111;

-//	public static final int  SPI_GETMOUSESPEED         = 112;

-//	public static final int  SPI_SETMOUSESPEED         = 113;

-//	public static final int  SPI_GETSCREENSAVERRUNNING = 114;

-//	public static final int  SPI_GETDESKWALLPAPER      = 115;

-//	public static final int  SPI_GETACTIVEWINDOWTRACKING         = 0x1000;

-//	public static final int  SPI_SETACTIVEWINDOWTRACKING         = 0x1001;

-//	public static final int  SPI_GETMENUANIMATION                = 0x1002;

-//	public static final int  SPI_SETMENUANIMATION                = 0x1003;

-//	public static final int  SPI_GETCOMBOBOXANIMATION            = 0x1004;

-//	public static final int  SPI_SETCOMBOBOXANIMATION            = 0x1005;

-//	public static final int  SPI_GETLISTBOXSMOOTHSCROLLING       = 0x1006;

-//	public static final int  SPI_SETLISTBOXSMOOTHSCROLLING       = 0x1007;

-//	public static final int  SPI_GETGRADIENTCAPTIONS             = 0x1008;

-//	public static final int  SPI_SETGRADIENTCAPTIONS             = 0x1009;

-//	public static final int  SPI_GETKEYBOARDCUES                 = 0x100A;

-//	public static final int  SPI_SETKEYBOARDCUES                 = 0x100B;

-//	public static final int  SPI_GETMENUUNDERLINES               = SPI_GETKEYBOARDCUES;

-//	public static final int  SPI_SETMENUUNDERLINES               = SPI_SETKEYBOARDCUES;

-//	public static final int  SPI_GETACTIVEWNDTRKZORDER           = 0x100C;

-//	public static final int  SPI_SETACTIVEWNDTRKZORDER           = 0x100D;

-//	public static final int  SPI_GETHOTTRACKING                  = 0x100E;

-//	public static final int  SPI_SETHOTTRACKING                  = 0x100F;

-//	public static final int  SPI_GETMENUFADE                     = 0x1012;

-//	public static final int  SPI_SETMENUFADE                     = 0x1013;

-//	public static final int  SPI_GETSELECTIONFADE                = 0x1014;

-//	public static final int  SPI_SETSELECTIONFADE                = 0x1015;

-//	public static final int  SPI_GETTOOLTIPANIMATION             = 0x1016;

-//	public static final int  SPI_SETTOOLTIPANIMATION             = 0x1017;

-//	public static final int  SPI_GETTOOLTIPFADE                  = 0x1018;

-//	public static final int  SPI_SETTOOLTIPFADE                  = 0x1019;

-//	public static final int  SPI_GETCURSORSHADOW                 = 0x101A;

-//	public static final int  SPI_SETCURSORSHADOW                 = 0x101B;

-//	public static final int  SPI_GETUIEFFECTS                    = 0x103E;

-//	public static final int  SPI_SETUIEFFECTS                    = 0x103F;

-//	public static final int  SPI_GETFOREGROUNDLOCKTIMEOUT        = 0x2000;

-//	public static final int  SPI_SETFOREGROUNDLOCKTIMEOUT        = 0x2001;

-//	public static final int  SPI_GETACTIVEWNDTRKTIMEOUT          = 0x2002;

-//	public static final int  SPI_SETACTIVEWNDTRKTIMEOUT          = 0x2003;

-//	public static final int  SPI_GETFOREGROUNDFLASHCOUNT         = 0x2004;

-//	public static final int  SPI_SETFOREGROUNDFLASHCOUNT         = 0x2005;

-//	public static final int  SPI_GETCARETWIDTH                   = 0x2006;

-//	public static final int  SPI_SETCARETWIDTH                   = 0x2007;

-//	public static final int  SPIF_UPDATEINIFILE    = 0x0001;

-//	public static final int  SPIF_SENDWININICHANGE = 0x0002;

-//	public static final int  SPIF_SENDCHANGE       = SPIF_SENDWININICHANGE;

-/*** END SystemParamtersInfo ***/

-

 /*** BEGIN SetWindowsHook ***/

 //	public static final int WH_MSGFILTER        = -1;

 //	public static final int WH_JOURNALRECORD    = 0;

@@ -336,16 +156,8 @@
 	public static final int WM_MOUSELEAVE = 0x02A3;

 //	public static final int WM_NCMOUSEHOVER = 0x02A0;

 //	public static final int WM_NCMOUSELEAVE = 0x02A2;

-	public static final int WM_MOUSEWHEEL = 0x020A;

 /*** END TrackMouseEvent ***/

 

-/*** BEGIN GradientFill ***/

-	public static final int GRADIENT_FILL_RECT_H = 0;

-	public static final int GRADIENT_FILL_RECT_V = 1;

-//	public static final int GRADIENT_FILL_TRIANGLE = 2;

-//	public static final int GRADIENT_FILL_OP_FLAG = 0xff;

-/*** END GradientFill ***/

-

 /*** BEGIN ICC ***/

 //	public static final int ICC_LISTVIEW_CLASSES 	= 0x00000001;

 //	public static final int ICC_TREEVIEW_CLASSES 	= 0x00000002;

@@ -1007,6 +819,7 @@
 //	public static final int DCX_PARENTCLIP = 0x20;

 //	public static final int DCX_VALIDATE = 0x200000;

 //	public static final int DCX_WINDOW = 0x1;

+	public static final int DEFAULT_CHARSET = 1;

 	public static final int DEFAULT_GUI_FONT = 0x11;

 //	public static final int DEFAULT_PALETTE = 0xF;

 //	public static final int DEVICE_DEFAULT_FONT = 0xE;

@@ -1250,7 +1063,7 @@
 	public static final int EM_GETLIMITTEXT = 0xD5;

 	public static final int EM_GETLINE = 0xC4;

 	public static final int EM_GETLINECOUNT = 0xBA;

-	public static final int EM_GETMARGINS = 0xD4;

+//	public static final int EM_GETMARGINS = 0xD4;

 //	public static final int EM_GETMODIFY = 0xB8;

 //	public static final int EM_GETOLEINTERFACE = (WM_USER + 60);

 //	public static final int EM_GETOPTIONS = (WM_USER + 78);

@@ -1717,7 +1530,7 @@
 //	public static final int HWND_DESKTOP = 0x0;

 //	public static final int HWND_NOTOPMOST = 0xFFFFFFFE;

 	public static final int HWND_TOP = 0x0;

-	public static final int HWND_TOPMOST = 0xFFFFFFFF;

+//	public static final int HWND_TOPMOST = 0xFFFFFFFF;

 //	public static final int I_CHILDRENCALLBACK = -1;

 //	public static final int ICM_LEVEL2 = 0x0002;

 //	public static final int ICM_LEVEL2_5 = 0x0003;

@@ -3318,8 +3131,6 @@
 //	public static final int TC_SO_ABLE = 0x1000;

 //	public static final int TC_UA_ABLE = 0x800;

 //	public static final int TC_VA_ABLE = 0x4000;

-	public static final int TCI_SRCCHARSET = 1;

-	public static final int TCI_SRCCODEPAGE = 2;

 	public static final int TCIF_IMAGE = 0x0002;

 //	public static final int TCIF_PARAM = 0x0008;

 //	public static final int TCIF_RTLREADING = 0x0004;

@@ -3439,7 +3250,7 @@
 //	public static final int TTM_RELAYEVENT = (WM_USER + 7);

 //	public static final int TTM_SETDELAYTIME = (WM_USER + 3);

 //	public static final int TTM_SETMARGIN = (WM_USER + 26);

-	public static final int TTM_SETMAXTIPWIDTH = (WM_USER + 24);

+//	public static final int TTM_SETMAXTIPWIDTH = (WM_USER + 24);

 //	public static final int TTM_SETTIPBKCOLOR = (WM_USER + 19);

 //	public static final int TTM_SETTIPTEXTCOLOR = (WM_USER + 20);

 //	public static final int TTM_SETTOOLINFO = (WM_USER + 9);

@@ -3949,7 +3760,7 @@
 //	public static final int WS_EX_RTLREADING = 0x2000;

 	public static final int WS_EX_STATICEDGE = 0x20000;

 	public static final int WS_EX_TOOLWINDOW = 0x80;

-	public static final int WS_EX_TOPMOST = 0x8;

+//	public static final int WS_EX_TOPMOST = 0x8;

 //	public static final int WS_EX_TRANSPARENT = 0x20;

 //	public static final int WS_EX_WINDOWEDGE = 0x100;

 //	public static final int WS_GROUP = 0x20000;

@@ -4285,7 +4096,6 @@
 public static final native int GlobalLock (int hMem);

 public static final native int GlobalSize (int hMem);

 public static final native boolean GlobalUnlock (int hMem);

-public static final native boolean GradientFill(int hdc, int pVertex, int dwNumVertex, int pMesh, int dwNumMesh, int dwMode);

 public static final native int HeapAlloc (

   int hHeap,  // handle to the private heap block

   int dwFlags, // heap allocation control flags

@@ -4404,11 +4214,6 @@
   int Length        // size, in bytes, of block to move

 );

 public static final native void MoveMemory (

-  int Destination,  // address of move destination

-  GRADIENT_RECT Source, 	// address of block to move

-  int Length        // size, in bytes, of block to move

-);

-public static final native void MoveMemory (

   int Destination,				// address of move destination

   LOGFONT Source, 				// address of block to move

   int Length        			// size, in bytes, of block to move

@@ -4429,11 +4234,6 @@
   int Length        // size, in bytes, of block to move

 );

 public static final native void MoveMemory (

-  int Destination,  // address of move destination

-  TRIVERTEX Source, 	// address of block to move

-  int Length        // size, in bytes, of block to move

-);

-public static final native void MoveMemory (

   DRAWITEMSTRUCT Destination,	// address of move destination

   int Source, 					// address of block to move

   int Length        			// size, in bytes, of block to move

@@ -4668,24 +4468,4 @@
 

 public static final native int CreatePen (int fnPenStyle, int nWidth, int crColor);

 public static final native int SetStretchBltMode(int hdc, int iStretchMode);

-

-public static final native int GetCharacterPlacement(int hdc, byte[] lpString, int nCount, int nMaxExtent, GCP_RESULTS lpResults, int dwFlags);

-public static final native boolean ExtTextOut(int hdc, int X, int Y, int fuOptions, RECT lprc, byte[] lpString, int cbCount, int[] lpDx);

-public static final native int GetFontLanguageInfo(int hdc);

-public static final native int GetKeyboardLayoutList(int nBuff, int[] lpList);

-public static final native int GetKeyboardLayout(int idThread);

-public static final native int ActivateKeyboardLayout(int hkl, int Flags);

-public static final native int SetTextAlign(int hdc, int fMode);

-

-public static final native boolean TranslateCharsetInfo(int lpSrc, int [] lpCs, int dwFlags);

-public static final native int GetTextCharset(int hdc);

-public static final native int GetLocaleInfo(int Locale, int LCType, byte[] lpLCData, int cchData);

-public static final native boolean EnumSystemLocales(int lpLocaleEnumProc, int dwFlags);

-

-public static final native boolean SystemParametersInfo (

-	int uiAction,  // system parameter to retrieve or set

-	int uiParam,   // depends on action to be taken

-	RECT pvParam,  // depends on action to be taken

-	int fWinIni    // user profile update option

-);

 }

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 da0f6be..82d85ea 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
@@ -317,7 +317,7 @@
 	if (length == 0) return "";

 	byte [] buffer1 = new byte [length + 1];

 	OS.GetWindowText (handle, buffer1, buffer1.length);

-	char [] buffer2 = Converter.mbcsToWcs (getCodePage (), buffer1);

+	char [] buffer2 = Converter.mbcsToWcs (0, buffer1);

 	return new String (buffer2, 0, buffer2.length - 1);

 }

 

@@ -431,7 +431,6 @@
 }

 

 public boolean setFocus () {

-	checkWidget();

 	if ((style & SWT.ARROW) != 0) return false;

 	if (!super.setFocus ()) return false;

 	menuShell ().setDefaultButton (this, false);

@@ -444,9 +443,6 @@
  *

  * @param image the image to display on the receiver (may be null)

  *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the image 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>

@@ -456,7 +452,6 @@
 	checkWidget ();

 	int hImage = 0, imageBits = 0, fImageType = 0;

 	if (image != null) {

-		if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 		hImage = image.handle;

 		switch (image.type) {

 			case SWT.BITMAP:

@@ -546,7 +541,7 @@
 	if (newBits != oldBits) {

 		OS.SetWindowLong (handle, OS.GWL_STYLE, newBits);

 	}

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (0, string, true);

 	OS.SetWindowText (handle, buffer);

 }

 

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
index e884b32..d41b414 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
@@ -164,11 +164,8 @@
  * the programmer must hide and show the caret when

  * drawing in the window any other time.

  * </p>

- * @param caret the new caret for the receiver, may be null

+ * @param caret the new caret for the receiver

  *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the caret 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>

@@ -181,10 +178,7 @@
 	this.caret = newCaret;

 	if (isFocusControl ()) {

 		if (oldCaret != null) oldCaret.killFocus ();

-		if (newCaret != null) {

-			if (newCaret.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

-			newCaret.setFocus ();

-		}

+		if (newCaret != null) newCaret.setFocus ();

 	}

 }

 

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ColorDialog.java
index 6aa1958..03ae84c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ColorDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ColorDialog.java
@@ -86,7 +86,6 @@
 	switch (uiMsg) {

 		case OS.WM_INITDIALOG:

 			if (title != null && title.length () != 0) {

-				/* Use the character encoding for the default locale */

 				byte [] buffer = Converter.wcsToMbcs (0, title, true);

 				OS.SetWindowText (hdlg, buffer);

 			}

@@ -98,7 +97,7 @@
 /**

  * Returns the currently selected color in the receiver.

  *

- * @return the RGB value for the selected color, may be null

+ * @return the RGB value for the selected color

  *

  * @see PaletteData#getRGBs

  */

@@ -110,9 +109,7 @@
  * Makes the receiver visible and brings it to the front

  * of the display.

  *

- * @return the selected color, or null if the dialog was

- *         cancelled, no color was selected, or an error

- *         occurred

+ * @return the selected color

  *

  * @exception SWTException <ul>

  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>

@@ -173,9 +170,7 @@
 /**

  * Returns the receiver's selected color to be the argument.

  *

- * @param rgb the new RGB value for the selected color, may be

- *        null to let the platform to select a default when

- *        open() is called

+ * @param rgb the new RGB value for the selected color

  *

  * @see PaletteData#getRGBs

  */

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
index b6e750f..9a09f76 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
@@ -63,7 +63,7 @@
 	}

 	

 	static final int ComboProc;

-	static final byte [] ComboClass = Converter.wcsToMbcs (0,"COMBOBOX\0");

+	static final byte [] ComboClass = Converter.wcsToMbcs (0,"COMBOBOX\0", false);

 	/*

 	 * These are the undocumented control id's for the children of

 	 * a combo box.  Since there are no constants for these values,

@@ -132,7 +132,7 @@
 public void add (String string) {

 	checkWidget ();

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (0, string, true);

 	int result = OS.SendMessage (handle, OS.CB_ADDSTRING, 0, buffer);

 	if (result == OS.CB_ERR) error (SWT.ERROR_ITEM_NOT_ADDED);

 	if (result == OS.CB_ERRSPACE) error (SWT.ERROR_ITEM_NOT_ADDED);

@@ -167,7 +167,7 @@
 public void add (String string, int index) {

 	checkWidget ();

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (0, string, true);

 	int result = OS.SendMessage (handle, OS.CB_INSERTSTRING, index, buffer);

 	if (result == OS.CB_ERRSPACE) error (SWT.ERROR_ITEM_NOT_ADDED);

 	if (result == OS.CB_ERR) {

@@ -423,7 +423,7 @@
 		byte [] buffer1 = new byte [length + 1];

 		int result = OS.SendMessage (handle, OS.CB_GETLBTEXT, index, buffer1);

 		if (result != OS.CB_ERR) {

-			char [] buffer2 = Converter.mbcsToWcs (getCodePage (), buffer1);

+			char [] buffer2 = Converter.mbcsToWcs (0, buffer1);

 			return new String (buffer2, 0, buffer2.length - 1);

 		}

 	}

@@ -563,7 +563,7 @@
 	if (length == 0) return "";

 	byte [] buffer1 = new byte [length + 1];

 	OS.GetWindowText (handle, buffer1, buffer1.length);

-	char [] buffer2 = Converter.mbcsToWcs (getCodePage (), buffer1);

+	char [] buffer2 = Converter.mbcsToWcs (0, buffer1);

 	return new String (buffer2, 0, buffer2.length - 1);

 }

 

@@ -645,6 +645,7 @@
  * </ul>

  */

 public int indexOf (String string) {

+	checkWidget ();

 	return indexOf (string, 0);

 }

 

@@ -672,7 +673,7 @@
 	int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);

 	if (!((0 <= start) && (start < count))) return -1;

 	int index = start - 1, last;

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (0, string, true);

 	do {

 		index = OS.SendMessage (handle, OS.CB_FINDSTRINGEXACT, last = index, buffer);

 		if ((index == OS.CB_ERR) || (index <= last)) return -1;

@@ -801,6 +802,7 @@
  * </ul>

  */

 public void remove (String string) {

+	checkWidget ();

 	int index = indexOf (string, 0);

 	if (index == -1) error (SWT.ERROR_INVALID_ARGUMENT);

 	remove (index);

@@ -993,10 +995,9 @@
 	checkWidget ();

 	if (items == null) error (SWT.ERROR_NULL_ARGUMENT);

 	OS.SendMessage (handle, OS.CB_RESETCONTENT, 0, 0);

-	int codePage = getCodePage ();

 	for (int i=0; i<items.length; i++) {

 		String string = items [i];

-		byte [] buffer = Converter.wcsToMbcs (codePage, string, true);

+		byte [] buffer = Converter.wcsToMbcs (0, string, true);

 		int code = OS.SendMessage (handle, OS.CB_ADDSTRING, 0, buffer);

 		if (code == OS.CB_ERR) error (SWT.ERROR_ITEM_NOT_ADDED);

 		if (code == OS.CB_ERRSPACE) error (SWT.ERROR_ITEM_NOT_ADDED);

@@ -1053,7 +1054,7 @@
 public void setText (String string) {

 	checkWidget ();

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (0, string, true);

 	if ((style & SWT.READ_ONLY) != 0) {

 		int code = OS.SendMessage (handle, OS.CB_SELECTSTRING, -1, buffer);

 		if (code != OS.CB_ERR) {

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
index a896720..dfd4864 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
@@ -410,8 +410,6 @@
 			OS.MoveMemory (lpnmtdi, lParam, NMTTDISPINFO.sizeof);

 			String string = toolTipText (lpnmtdi);

 			if (string != null && string.length () != 0) {

-				string = Display.withCrLf (string);

-				/* Use the character encoding for the default locale */

 				byte [] buffer = Converter.wcsToMbcs (0, string, true);

 				getShell ().setToolTipText (lpnmtdi, buffer);

 				OS.MoveMemory (lParam, lpnmtdi, NMTTDISPINFO.sizeof);

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 c2c1ab9..abe7375 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
@@ -572,16 +572,6 @@
 	return new Rectangle (rect.left, rect.top, width, height);

 }

 

-int getCodePage () {

-	int hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);

-	LOGFONT logFont = new LOGFONT ();

-	OS.GetObject (hFont, LOGFONT.sizeof, logFont);

-	int cs = logFont.lfCharSet & 0xFF;

-	int [] lpCs = new int [8];

-	OS.TranslateCharsetInfo (cs, lpCs, OS.TCI_SRCCHARSET);

-	return lpCs [1];

-}

-

 /**

  * Returns the display that the receiver was created on.

  *

@@ -890,7 +880,7 @@
  * @private

  */

 public int internal_new_GC (GCData data) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

 	int hDC;

 	if (data == null || data.ps == null) {

 		hDC = OS.GetDC (handle);

@@ -923,7 +913,7 @@
  * @private

  */

 public void internal_dispose_GC (int hDC, GCData data) {

-	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	//if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

 	if (data == null || data.ps == null) {

 		OS.ReleaseDC (handle, hDC);

 	} else {

@@ -1024,6 +1014,10 @@
 	return true;

 }

 

+boolean isValidWidget () {

+	return handle != 0;

+}

+

 /**

  * Returns <code>true</code> if the receiver is visible, and

  * <code>false</code> otherwise.

@@ -1067,9 +1061,6 @@
  *

  * @param the sibling control (or null)

  *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the control 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>

@@ -1079,7 +1070,6 @@
 	checkWidget ();

 	int hwndAfter = OS.HWND_TOP;

 	if (control != null) {

-		if (control.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 		int hwnd = control.handle;

 		if ((hwnd == 0) || (hwnd == handle)) return;

 		hwndAfter = OS.GetWindow (hwnd, OS.GW_HWNDPREV);

@@ -1098,9 +1088,6 @@
  *

  * @param the sibling control (or null)

  *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the control 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>

@@ -1109,10 +1096,7 @@
 public void moveBelow (Control control) {

 	checkWidget ();

 	int hwndAfter = OS.HWND_BOTTOM;

-	if (control != null) {

-		if (control.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

-		hwndAfter = control.handle;

-	}

+	if (control != null) hwndAfter = control.handle;

 	if (hwndAfter == 0) return;

 	int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE; 

 	OS.SetWindowPos (handle, hwndAfter, 0, 0, 0, 0, flags);

@@ -1203,7 +1187,6 @@
  */

 public void redraw (int x, int y, int width, int height, boolean all) {

 	checkWidget ();

-	if (width <= 0 || height <= 0) return;

 	if (!OS.IsWindowVisible (handle)) return;

 	RECT rect = new RECT ();

 	int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE;

@@ -1482,21 +1465,20 @@
 	if (OS.GetKeyState (OS.VK_MENU) < 0) event.stateMask |= SWT.ALT;

 	if ((wParam & OS.MK_SHIFT) != 0) event.stateMask |= SWT.SHIFT;

 	if ((wParam & OS.MK_CONTROL) != 0) event.stateMask |= SWT.CONTROL;

-	if ((wParam & OS.MK_LBUTTON) != 0) event.stateMask |= SWT.BUTTON1;

-	if ((wParam & OS.MK_MBUTTON) != 0) event.stateMask |= SWT.BUTTON2;

-	if ((wParam & OS.MK_RBUTTON) != 0) event.stateMask |= SWT.BUTTON3;

-	switch (type) {

-		case SWT.MouseDown:

-		case SWT.MouseDoubleClick:

-			if (button == 1) event.stateMask &= ~SWT.BUTTON1;

-			if (button == 2) event.stateMask &= ~SWT.BUTTON2;

-			if (button == 3) event.stateMask &= ~SWT.BUTTON3;

-			break;

-		case SWT.MouseUp:

-			if (button == 1) event.stateMask |= SWT.BUTTON1;

-			if (button == 2) event.stateMask |= SWT.BUTTON2;

-			if (button == 3) event.stateMask |= SWT.BUTTON3;

-			break;

+	if (button != 1 || (type != SWT.MouseDown && type != SWT.MouseDoubleClick)) {

+		if (type == SWT.MouseUp || (wParam & OS.MK_LBUTTON) != 0) {

+			event.stateMask |= SWT.BUTTON1;

+		}

+	}

+	if (button != 2 || (type != SWT.MouseDown && type != SWT.MouseDoubleClick)) {

+		if (type == SWT.MouseUp || (wParam & OS.MK_MBUTTON) != 0) {

+			event.stateMask |= SWT.BUTTON2;

+		}

+	}

+	if (button != 3 || (type != SWT.MouseDown && type != SWT.MouseDoubleClick)) {

+		if (type == SWT.MouseUp || (wParam & OS.MK_RBUTTON) != 0) {

+			event.stateMask |= SWT.BUTTON3;

+		}

 	}

 	return sendMouseEvent (type, msg, wParam, lParam, event);

 }

@@ -1513,9 +1495,6 @@
  *

  * @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>

@@ -1525,7 +1504,6 @@
 	checkWidget ();

 	int pixel = -1;

 	if (color != null) {

-		if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 		pixel = color.handle;

 	}

 	setBackgroundPixel (pixel);

@@ -1646,9 +1624,6 @@
  *

  * @param cursor the new cursor (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>

@@ -1657,10 +1632,7 @@
 public void setCursor (Cursor cursor) {

 	checkWidget ();

 	hCursor = 0;

-	if (cursor != null) {

-		if (cursor.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

-		hCursor = cursor.handle;

-	}

+	if (cursor != null) hCursor = cursor.handle;

 	int hwndCursor = OS.GetCapture ();

 	if (hwndCursor == 0) {

 		POINT pt = new POINT ();

@@ -1749,9 +1721,6 @@
  *

  * @param font the new font (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>

@@ -1760,10 +1729,7 @@
 public void setFont (Font font) {

 	checkWidget ();

 	int hFont = 0;

-	if (font != null) { 

-		if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

-		hFont = font.handle;

-	}

+	if (font != null) hFont = font.handle;

 	if (hFont == 0) hFont = defaultFont ();

 	OS.SendMessage (handle, OS.WM_SETFONT, hFont, 1);

 }

@@ -1775,9 +1741,6 @@
  *

  * @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>

@@ -1787,7 +1750,6 @@
 	checkWidget ();

 	int pixel = -1;

 	if (color != null) {

-		if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 		pixel = color.handle;

 	}

 	setForegroundPixel (pixel);

@@ -1900,7 +1862,6 @@
  * @exception IllegalArgumentException <ul>

  *    <li>ERROR_MENU_NOT_POP_UP - the menu is not a pop up menu</li>

  *    <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>

- *    <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li> 

  * </ul>

  * @exception SWTException <ul>

  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>

@@ -1910,7 +1871,6 @@
 public void setMenu (Menu menu) {

 	checkWidget ();

 	if (menu != null) {

-		if (menu.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 		if ((menu.style & SWT.POP_UP) == 0) {

 			error (SWT.ERROR_MENU_NOT_POP_UP);

 		}

@@ -1949,6 +1909,7 @@
  */

 public void setRedraw (boolean redraw) {

 	checkWidget ();

+	

 	/*

 	 * This code is intentionally commented.

 	 *

@@ -2403,9 +2364,6 @@
  * @param parent the new parent for the control.

  * @return <code>true</code> if the parent is changed and <code>false</code> otherwise.

  *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 

- * </ul>

  * @exception SWTError <ul>

  *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>

  *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>

@@ -2414,7 +2372,6 @@
 public boolean setParent (Composite parent) {

 	checkWidget ();

 	if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);

-	if (parent.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);

 	if (OS.SetParent (handle, parent.handle) == 0) {

 		return false;

 	}

@@ -2433,7 +2390,7 @@
 		case OS.WM_CHAR:				result = WM_CHAR (wParam, lParam); break;

 		case OS.WM_CLEAR:				result = WM_CLEAR (wParam, lParam); break;

 		case OS.WM_CLOSE:				result = WM_CLOSE (wParam, lParam); break;

-		case OS.WM_COMMAND:				result = WM_COMMAND (wParam, lParam); break;

+		case OS.WM_COMMAND:			result = WM_COMMAND (wParam, lParam); break;

 		case OS.WM_CONTEXTMENU:			result = WM_CONTEXTMENU (wParam, lParam); break;

 		case OS.WM_CTLCOLORBTN:

 		case OS.WM_CTLCOLORDLG:

@@ -2442,18 +2399,18 @@
 		case OS.WM_CTLCOLORMSGBOX:

 		case OS.WM_CTLCOLORSCROLLBAR:

 		case OS.WM_CTLCOLORSTATIC:		result = WM_CTLCOLOR (wParam, lParam); break;

-		case OS.WM_CUT:					result = WM_CUT (wParam, lParam); break;

-		case OS.WM_DESTROY:				result = WM_DESTROY (wParam, lParam); break;

+		case OS.WM_CUT:				result = WM_CUT (wParam, lParam); break;

+		case OS.WM_DESTROY:			result = WM_DESTROY (wParam, lParam); break;

 		case OS.WM_DRAWITEM:			result = WM_DRAWITEM (wParam, lParam); break;

 		case OS.WM_ERASEBKGND:			result = WM_ERASEBKGND (wParam, lParam); break;

 		case OS.WM_GETDLGCODE:			result = WM_GETDLGCODE (wParam, lParam); break;

 		case OS.WM_HELP:				result = WM_HELP (wParam, lParam); break;

-		case OS.WM_HSCROLL:				result = WM_HSCROLL (wParam, lParam); break;

+		case OS.WM_HSCROLL:			result = WM_HSCROLL (wParam, lParam); break;

 		case OS.WM_IME_CHAR:			result = WM_IME_CHAR (wParam, lParam); break;

 		case OS.WM_IME_COMPOSITION:		result = WM_IME_COMPOSITION (wParam, lParam); break;

 		case OS.WM_INITMENUPOPUP:		result = WM_INITMENUPOPUP (wParam, lParam); break;

-		case OS.WM_GETFONT:				result = WM_GETFONT (wParam, lParam); break;

-		case OS.WM_KEYDOWN:				result = WM_KEYDOWN (wParam, lParam); break;

+		case OS.WM_GETFONT:			result = WM_GETFONT (wParam, lParam); break;

+		case OS.WM_KEYDOWN:			result = WM_KEYDOWN (wParam, lParam); break;

 		case OS.WM_KEYUP:				result = WM_KEYUP (wParam, lParam); break;

 		case OS.WM_KILLFOCUS:			result = WM_KILLFOCUS (wParam, lParam); break;

 		case OS.WM_LBUTTONDBLCLK:		result = WM_LBUTTONDBLCLK (wParam, lParam); break;

@@ -2473,7 +2430,7 @@
 		case OS.WM_NCACTIVATE:			result = WM_NCACTIVATE (wParam, lParam); break;

 		case OS.WM_NCCALCSIZE:			result = WM_NCCALCSIZE (wParam, lParam); break;

 		case OS.WM_NCHITTEST:			result = WM_NCHITTEST (wParam, lParam); break;

-		case OS.WM_NOTIFY:				result = WM_NOTIFY (wParam, lParam); break;

+		case OS.WM_NOTIFY:			result = WM_NOTIFY (wParam, lParam); break;

 		case OS.WM_PAINT:				result = WM_PAINT (wParam, lParam); break;

 		case OS.WM_PALETTECHANGED:		result = WM_PALETTECHANGED (wParam, lParam); break;

 		case OS.WM_PASTE:				result = WM_PASTE (wParam, lParam); break;

@@ -2484,19 +2441,18 @@
 		case OS.WM_RBUTTONUP:			result = WM_RBUTTONUP (wParam, lParam); break;

 		case OS.WM_SETCURSOR:			result = WM_SETCURSOR (wParam, lParam); break;

 		case OS.WM_SETFOCUS:			result = WM_SETFOCUS (wParam, lParam); break;

-		case OS.WM_SETFONT:				result = WM_SETFONT (wParam, lParam); break;

+		case OS.WM_SETFONT:			result = WM_SETFONT (wParam, lParam); break;

 		case OS.WM_SHOWWINDOW:			result = WM_SHOWWINDOW (wParam, lParam); break;

 		case OS.WM_SIZE:				result = WM_SIZE (wParam, lParam); break;

-		case OS.WM_SYSCHAR:				result = WM_SYSCHAR (wParam, lParam); break;

+		case OS.WM_SYSCHAR:			result = WM_SYSCHAR (wParam, lParam); break;

 		case OS.WM_SYSCOLORCHANGE:		result = WM_SYSCOLORCHANGE (wParam, lParam); break;

 		case OS.WM_SYSCOMMAND:			result = WM_SYSCOMMAND (wParam, lParam); break;

 		case OS.WM_SYSKEYDOWN:			result = WM_SYSKEYDOWN (wParam, lParam); break;

 		case OS.WM_SYSKEYUP:			result = WM_SYSKEYUP (wParam, lParam); break;

 		case OS.WM_TIMER:				result = WM_TIMER (wParam, lParam); break;

 		case OS.WM_UNDO:				result = WM_UNDO (wParam, lParam); break;

-		case OS.WM_VSCROLL:				result = WM_VSCROLL (wParam, lParam); break;

-		case OS.WM_WINDOWPOSCHANGING:	result = WM_WINDOWPOSCHANGING (wParam, lParam); break;

-		case OS.WM_MOUSEWHEEL:			return OS.DefWindowProc(handle, msg, wParam, lParam);

+		case OS.WM_VSCROLL:			result = WM_VSCROLL (wParam, lParam); break;

+		case OS.WM_WINDOWPOSCHANGING:		result = WM_WINDOWPOSCHANGING (wParam, lParam); break;

 	}

 	if (result != null) return result.value;

 	return callWindowProc (msg, wParam, lParam);

@@ -2957,8 +2913,20 @@
 }

 

 LRESULT WM_KILLFOCUS (int wParam, int lParam) {

+	

+	/* Build the focus out list */

+	int index = 0;

+	Control [] focusOut = getPath ();

 	Display display = getDisplay ();

-	Shell shell = getShell ();

+	Control control = display.findControl (wParam);

+	if (control != null) {

+		Control [] focusIn = control.getPath ();

+		int length = Math.min (focusIn.length, focusOut.length);

+		while (index < length) {

+			if (focusIn [index] != focusOut [index]) break;

+			index++;

+		}

+	}

 	

 	/*

 	* It is possible (but unlikely), that application

@@ -2970,15 +2938,15 @@
 	// widget could be disposed at this point

 	

 	/*

-	* It is possible that the shell may be

-	* disposed at this point.  If this happens

-	* don't send the activate and deactivate

-	* events.

-	*/	

-	if (!shell.isDisposed ()) {

-		Control control = display.findControl (wParam);

-		if (control == null || shell != control.getShell ()) {

-			shell.setActiveControl (null);

+	* It is possible (but unlikely), that application

+	* code could have destroyed some of the widgets in

+	* the focus out event or the deactivate event.  If

+	* this happens, keep processing those widgets that

+	* are not disposed.

+	*/

+	for (int i=focusOut.length-1; i>=index; --i) {

+		if (!focusOut [i].isDisposed ()) {

+			focusOut [i].sendEvent (SWT.Deactivate);

 		}

 	}

 	

@@ -3397,7 +3365,20 @@
 }

 

 LRESULT WM_SETFOCUS (int wParam, int lParam) {

-	Shell shell = getShell ();

+	

+	/* Build the focus in list */

+	int index = 0;

+	Control [] focusIn = getPath ();

+	Display display = getDisplay ();

+	Control control = display.findControl (wParam);

+	if (control != null) {

+		Control [] focusOut = control.getPath ();

+		int length = Math.min (focusIn.length, focusOut.length);

+		while (index < length) {

+			if (focusIn [index] != focusOut [index]) break;

+			index++;

+		}

+	}

 	

 	/*

 	* It is possible (but unlikely), that application

@@ -3409,13 +3390,16 @@
 	// widget could be disposed at this point

 	

 	/*

-	* It is possible that the shell may be

-	* disposed at this point.  If this happens

-	* don't send the activate and deactivate

-	* events.

-	*/	

-	if (!shell.isDisposed ()) {

-		shell.setActiveControl (this);

+	* It is possible (but unlikely), that application

+	* code could have destroyed some of the widgets in

+	* the focus in event or the activate event.  If

+	* this happens, keep processing those widgets that

+	* are not disposed.

+	*/

+	for (int i=focusIn.length-1; i>=index; --i) {

+		if (!focusIn [i].isDisposed ()) {

+			focusIn [i].sendEvent (SWT.Activate);

+		}

 	}

 

 	/*

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 3334b39..82d52d3 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
@@ -281,8 +281,7 @@
  * @return the index of the item

  *

  * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>

- *    <li>ERROR_INVALID_ARGUMENT - if the item is disposed</li>

+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>

  * </ul>

  * @exception SWTException <ul>

  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>

@@ -292,7 +291,6 @@
 public int indexOf (CoolItem item) {

 	checkWidget ();

 	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);

-	if (item.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);

 	return OS.SendMessage (handle, OS.RB_IDTOINDEX, item.id, 0);

 }

 

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java
index 2077fd3..2f273e8 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java
@@ -32,7 +32,7 @@
 

 /**

  * Constructs a new instance of this class given its parent

- * (which must be a <code>CoolBar</code>) and a style value

+ * (which must be a <code>CoolBar</code> and a style value

  * describing its behavior and appearance. The item is added

  * to the end of the items maintained by its parent.

  * <p>

@@ -68,7 +68,7 @@
 

 /**

  * Constructs a new instance of this class given its parent

- * (which must be a <code>CoolBar</code>), a style value

+ * (which must be a <code>CoolBar</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>

@@ -253,9 +253,6 @@
  *

  * @param control the new control

  *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the control 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>

@@ -263,9 +260,8 @@
  */

 public void setControl (Control control) {

 	checkWidget ();

-	if (control != null) {

-		if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);

-		if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);

+	if (control != null && control.parent != parent) {

+		error (SWT.ERROR_INVALID_PARENT);

 	}

 	int index = parent.indexOf (this);

 	if (index == -1) return;

@@ -319,7 +315,6 @@
 

 public void setPreferredSize (Point size) {

 	checkWidget ();

-	if (size == null) error(SWT.ERROR_NULL_ARGUMENT);

 	setPreferredSize (size.x, size.y);

 }

 

@@ -355,7 +350,7 @@
 }

 

 public void setSize (Point size) {

-	if (size == null) error(SWT.ERROR_NULL_ARGUMENT);

+	checkWidget ();

 	setSize (size.x, size.y);

 }

 

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
index 79852d5..2ec2522 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
@@ -435,7 +435,6 @@
 	if (length == 0) return "";

 	byte [] buffer1 = new byte [length + 1];

 	OS.GetWindowText (handle, buffer1, buffer1.length);

-	/* Use the character encoding for the default locale */

 	char [] buffer2 = Converter.mbcsToWcs (0, buffer1);

 	return new String (buffer2, 0, buffer2.length - 1);

 }

@@ -531,9 +530,6 @@
  *

  * @param the new default button

  *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the button 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>

@@ -548,7 +544,6 @@
 	if (button == null) {

 		if (defaultButton == saveDefault) return;

 	} else {

-		if (button.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 		if ((button.style & SWT.PUSH) == 0) return;

 		if (button == defaultButton) return;

 	}

@@ -584,9 +579,6 @@
  * 

  * @param image the new image (or null)

  *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the image 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>

@@ -596,7 +588,6 @@
 	checkWidget ();

 	int hIcon = 0;

 	if (image != null) {

-		if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 		switch (image.type) {

 			case SWT.BITMAP:

 				int hOld = OS.SendMessage (handle, OS.WM_GETICON, OS.ICON_BIG, 0);

@@ -689,9 +680,6 @@
  *

  * @param menu the new menu bar

  *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the menu 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>

@@ -701,7 +689,6 @@
 	checkWidget ();

 	if (menuBar == menu) return;

 	if (menu != null) {

-		if (menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 		if ((menu.style & SWT.BAR) == 0) error (SWT.ERROR_MENU_NOT_BAR);

 		if (menu.parent != this) error (SWT.ERROR_INVALID_PARENT);

 	}

@@ -828,7 +815,6 @@
 public void setText (String string) {

 	checkWidget ();

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

-	/* Use the character encoding for the default locale */

 	byte [] buffer = Converter.wcsToMbcs (0, string, true);

 	OS.SetWindowText (handle, buffer);

 }

@@ -943,9 +929,6 @@
 		* Windows message by returning zero as the result of

 		* the window proc.

 		*/

-		Shell shell = getShell ();

-		shell.setActiveControl (null);

-		if (isDisposed ()) return LRESULT.ZERO;

 		sendEvent (SWT.Deactivate);

 		if (isDisposed ()) return LRESULT.ZERO;

 		saveFocus ();

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 e1bbe43..1b7a473 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
@@ -87,12 +87,10 @@
 	switch (uMsg) {

 		case OS.BFFM_INITIALIZED:

 			if (filterPath != null && filterPath.length () != 0) {

-				/* Use the character encoding for the default locale */

 				byte [] buffer = Converter.wcsToMbcs (0, filterPath, true);

 				OS.SendMessage (hwnd, OS.BFFM_SETSELECTION, 1, buffer);

 			}

 			if (title != null && title.length () != 0) {

-				/* Use the character encoding for the default locale */

 				byte [] buffer = Converter.wcsToMbcs (0, title, true);

 				OS.SetWindowText (hwnd, buffer);

 			}

@@ -100,7 +98,6 @@
 		case OS.BFFM_VALIDATEFAILED:

 			byte [] buffer1 = new byte [256];

 			OS.MoveMemory (buffer1, lParam, 256);

-			/* Use the character encoding for the default locale */

 			char [] buffer2 = Converter.mbcsToWcs (0, buffer1);

 			int length = 0;

 			while (length < buffer2.length && buffer2 [length] != 0) length++;

@@ -111,7 +108,7 @@
 }

 

 /**

- * Returns the path which the dialog will use to filter

+ * Returns the path which the receiver will use to filter

  * the directories it shows.

  *

  * @return the filter path

@@ -121,9 +118,9 @@
 }

 

 /**

- * Returns the dialog's message, which is a description of

+ * Returns the receiver's message, which is a description of

  * the purpose for which it was opened. This message will be

- * visible on the dialog while it is open.

+ * visible on the receiver while it is open.

  *

  * @return the message

  */

@@ -132,15 +129,14 @@
 }

 

 /**

- * Makes the dialog visible and brings it to the front

+ * Makes the receiver visible and brings it to the front

  * of the display.

  *

- * @return a string describing the absolute path of the selected directory,

- *         or null if the dialog was cancelled or an error occurred

+ * @return a string describing the absolute path of the selected directory

  *

  * @exception SWTException <ul>

- *    <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>

+ *    <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 String open () {

@@ -157,7 +153,6 @@
 	/* Copy the message to OS memory */

 	int lpszTitle = 0;

 	if (message != null && message.length () != 0) {

-		/* Use the character encoding for the default locale */

 		byte [] buffer = Converter.wcsToMbcs (0, message, true);

 		lpszTitle = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer.length);

 		OS.MoveMemory (lpszTitle, buffer, buffer.length);

@@ -178,7 +173,6 @@
 	if (lpItemIdList != 0) {

 		byte [] buffer = new byte [256];

 		if (OS.SHGetPathFromIDList (lpItemIdList, buffer)) {

-			/* Use the character encoding for the default locale */

 			char [] path = Converter.mbcsToWcs (0, buffer);

 			int length = 0;

 			while ((length < path.length) && (path [length] != 0)) length++;

@@ -215,7 +209,7 @@
 }

 

 /**

- * Sets the path which the dialog will use to filter

+ * Sets the path which the receiver will use to filter

  * the directories it shows to the argument, which may be

  * null.

  *

@@ -226,9 +220,9 @@
 }

 

 /**

- * Sets the dialog's message, which is a description of

+ * Sets the receiver's message, which is a description of

  * the purpose for which it was opened. This message will be

- * visible on the dialog while it is open.

+ * visible on the receiver while it is open.

  *

  * @param string the message

  */

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
index 2c45297..d16ccef 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
@@ -113,9 +113,6 @@
 	int lastKey, lastAscii, lastMouse;

 	byte [] keyboard = new byte [256];

 	boolean accelKeyHit, mnemonicKeyHit;

-	

-	/* Image list cache */	

-	ImageList[] imageList, toolImageList, toolHotImageList, toolDisabledImageList;

 

 	/* Key Mappings */

 	static final int [] [] KeyTable = {

@@ -551,15 +548,6 @@
 	return findDisplay (Thread.currentThread ());

 }

 

-public Rectangle getClientArea () {

-	checkDevice ();

-	RECT rect = new RECT ();

-	OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, rect, 0);

-	int width = rect.right - rect.left;

-	int height = rect.bottom - rect.top;

-	return new Rectangle (rect.left, rect.top, width, height);

-}

-

 /**

  * Returns the control which the on-screen pointer is currently

  * over top of, or null if it is not currently over one of the

@@ -574,7 +562,7 @@
 public Control getCursorControl () {

 	checkDevice ();

 	POINT pt = new POINT ();

-	if (!OS.GetCursorPos (pt)) return null;

+	OS.GetCursorPos (pt);

 	return findControl (OS.WindowFromPoint (pt));

 }

 

@@ -721,18 +709,15 @@
 public int getIconDepth () {

 	checkDevice ();

 	int [] phkResult = new int [1];

-	/* Use the character encoding for the default locale */

 	byte [] buffer1 = Converter.wcsToMbcs (0, "Control Panel\\Desktop\\WindowMetrics", true);

 	int result = OS.RegOpenKeyEx (OS.HKEY_CURRENT_USER, buffer1, 0, OS.KEY_READ, phkResult);

 	if (result != 0) return 4;

 	int depth = 4;

 	int [] lpcbData = {128};

 	byte [] lpData = new byte [lpcbData [0]];

-	/* Use the character encoding for the default locale */

 	byte [] buffer2 = Converter.wcsToMbcs (0, "Shell Icon BPP", true);

 	result = OS.RegQueryValueEx (phkResult [0], buffer2, 0, null, lpData, lpcbData);

 	if (result == 0) {

-		/* Use the character encoding for the default locale */

 		char [] buffer3 = Converter.mbcsToWcs (0, lpData);

 		int length = 0;

 		while (length < buffer3.length && buffer3 [length] != 0) length++;

@@ -744,114 +729,6 @@
 	return depth;

 }

 

-ImageList getImageList (Point size) {

-	if (imageList == null) imageList = new ImageList [4];

-	

-	int i = 0;

-	int length = imageList.length; 

-	while (i < length) {

-		ImageList list = imageList [i];

-		if (list == null) break;

-		if (list.getImageSize().equals(size)) {

-			list.addRef();

-			return list;

-		}

-		i++;

-	}

-	

-	if (i == length) {

-		ImageList [] newList = new ImageList [length + 4];

-		System.arraycopy (imageList, 0, newList, 0, length);

-		imageList = newList;

-	}

-	

-	ImageList list = new ImageList();

-	imageList [i] = list;

-	list.addRef();

-	return list;

-}

-

-ImageList getToolImageList (Point size) {

-	if (toolImageList == null) toolImageList = new ImageList [4];

-	

-	int i = 0;

-	int length = toolImageList.length; 

-	while (i < length) {

-		ImageList list = toolImageList [i];

-		if (list == null) break;

-		if (list.getImageSize().equals(size)) {

-			list.addRef();

-			return list;

-		}

-		i++;

-	}

-	

-	if (i == length) {

-		ImageList [] newList = new ImageList [length + 4];

-		System.arraycopy (toolImageList, 0, newList, 0, length);

-		toolImageList = newList;

-	}

-	

-	ImageList list = new ImageList();

-	toolImageList [i] = list;

-	list.addRef();

-	return list;

-}

-

-ImageList getToolHotImageList (Point size) {

-	if (toolHotImageList == null) toolHotImageList = new ImageList [4];

-	

-	int i = 0;

-	int length = toolHotImageList.length; 

-	while (i < length) {

-		ImageList list = toolHotImageList [i];

-		if (list == null) break;

-		if (list.getImageSize().equals(size)) {

-			list.addRef();

-			return list;

-		}

-		i++;

-	}

-	

-	if (i == length) {

-		ImageList [] newList = new ImageList [length + 4];

-		System.arraycopy (toolHotImageList, 0, newList, 0, length);

-		toolHotImageList = newList;

-	}

-	

-	ImageList list = new ImageList();

-	toolHotImageList [i] = list;

-	list.addRef();

-	return list;

-}

-

-ImageList getToolDisabledImageList (Point size) {

-	if (toolDisabledImageList == null) toolDisabledImageList = new ImageList [4];

-	

-	int i = 0;

-	int length = toolDisabledImageList.length; 

-	while (i < length) {

-		ImageList list = toolDisabledImageList [i];

-		if (list == null) break;

-		if (list.getImageSize().equals(size)) {

-			list.addRef();

-			return list;

-		}

-		i++;

-	}

-	

-	if (i == length) {

-		ImageList [] newList = new ImageList [length + 4];

-		System.arraycopy (toolDisabledImageList, 0, newList, 0, length);

-		toolDisabledImageList = newList;

-	}

-	

-	ImageList list = new ImageList();

-	toolDisabledImageList [i] = list;

-	list.addRef();

-	return list;

-}

-

 Shell getModalShell () {

 	if (ModalWidgets == null) return null;

 	int index = ModalWidgets.length;

@@ -1022,7 +899,6 @@
  * @private

  */

 public int internal_new_GC (GCData data) {

-	if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);

 	int hDC = OS.GetDC (0);

 	if (hDC == 0) SWT.error (SWT.ERROR_NO_HANDLES);

 	if (data != null) {

@@ -1055,12 +931,10 @@
 	threadId = OS.GetCurrentThreadId ();

 	processId = OS.GetCurrentProcessId ();

 	

-	/* Use the character encoding for the default locale */

-	windowClass = Converter.wcsToMbcs (0, WindowName + windowClassCount++ + "\0");

-

 	/* Register the SWT window class */

 	int hHeap = OS.GetProcessHeap ();

 	int hInstance = OS.GetModuleHandle (null);

+	windowClass = Converter.wcsToMbcs (0, WindowName + windowClassCount++ + "\0");

 	WNDCLASSEX lpWndClass = new WNDCLASSEX ();

 	lpWndClass.cbSize = WNDCLASSEX.sizeof;

 	if (OS.GetClassInfoEx (hInstance, windowClass, lpWndClass)) {

@@ -1153,10 +1027,9 @@
 public boolean readAndDispatch () {

 	checkDevice ();

 	if (OS.PeekMessage (msg, 0, 0, 0, OS.PM_REMOVE)) {

-		if (!filterMessage (msg)) {

-			OS.TranslateMessage (msg);

-			OS.DispatchMessage (msg);

-		}

+		if (filterMessage (msg)) return false;

+		OS.TranslateMessage (msg);

+		OS.DispatchMessage (msg);

 		runDeferredEvents ();

 		return true;

 	}

@@ -1256,82 +1129,6 @@
 	values = null;

 }

 

-void releaseImageList (ImageList list) {

-	int i = 0;

-	int length = imageList.length; 

-	while (i < length) {

-		if (imageList [i] == list) {

-			if (list.removeRef () > 0) return;

-			list.dispose ();

-			System.arraycopy (imageList, i + 1, imageList, i, --length - i);

-			imageList [length] = null;

-			for (int j=0; j<length; j++) {

-				if (imageList [j] != null) return;

-			}

-			imageList = null;

-			return;

-		}

-		i++;

-	}

-}

-

-void releaseToolImageList (ImageList list) {

-	int i = 0;

-	int length = toolImageList.length; 

-	while (i < length) {

-		if (toolImageList [i] == list) {

-			if (list.removeRef () > 0) return;

-			list.dispose ();

-			System.arraycopy (toolImageList, i + 1, toolImageList, i, --length - i);

-			toolImageList [length] = null;

-			for (int j=0; j<length; j++) {

-				if (toolImageList [j] != null) return;

-			}

-			toolImageList = null;

-			return;

-		}

-		i++;

-	}

-}

-

-void releaseToolHotImageList (ImageList list) {

-	int i = 0;

-	int length = toolHotImageList.length; 

-	while (i < length) {

-		if (toolHotImageList [i] == list) {

-			if (list.removeRef () > 0) return;

-			list.dispose ();

-			System.arraycopy (toolHotImageList, i + 1, toolHotImageList, i, --length - i);

-			toolHotImageList [length] = null;

-			for (int j=0; j<length; j++) {

-				if (toolHotImageList [j] != null) return;

-			}

-			toolHotImageList = null;

-			return;

-		}

-		i++;

-	}

-}

-

-void releaseToolDisabledImageList (ImageList list) {

-	int i = 0;

-	int length = toolDisabledImageList.length; 

-	while (i < length) {

-		if (toolDisabledImageList [i] == list) {

-			if (list.removeRef () > 0) return;

-			list.dispose ();

-			System.arraycopy (toolDisabledImageList, i + 1, toolDisabledImageList, i, --length - i);

-			toolDisabledImageList [length] = null;

-			for (int j=0; j<length; j++) {

-				if (toolDisabledImageList [j] != null) return;

-			}

-			toolDisabledImageList = null;

-			return;

-		}

-		i++;

-	}

-}

-

 boolean runAsyncMessages () {

 	return synchronizer.runAsyncMessages ();

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FileDialog.java
index 7b09ecf..bab97bd 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FileDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FileDialog.java
@@ -33,130 +33,34 @@
 	static final String FILTER = "*.*";

 	static int BUFFER_SIZE = 1024 * 10;

 

-/**

- * Constructs a new instance of this class given only its

- * parent.

- * <p>

- * Note: Currently, null can be passed in for the parent.

- * This has the effect of creating the dialog on the currently active

- * display if there is one. If there is no current display, the 

- * dialog is created on a "default" display. <b>Passing in null as

- * the parent is not considered to be good coding style,

- * and may not be supported in a future release of SWT.</b>

- * </p>

- *

- * @param parent a shell which will be the parent of the new instance

- *

- * @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>

- */

 public FileDialog (Shell parent) {

 	this (parent, SWT.PRIMARY_MODAL);

 }

 

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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 dialog classes should include a comment which

- * describes the style constants which are applicable to the class.

- * </p>

- * Note: Currently, null can be passed in for the parent.

- * This has the effect of creating the dialog on the currently active

- * display if there is one. If there is no current display, the 

- * dialog is created on a "default" display. <b>Passing in null as

- * the parent is not considered to be good coding style,

- * and may not be supported in a future release of SWT.</b>

- * </p>

- *

- * @param parent a shell which will be the parent of the new instance

- *

- * @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>

- */

 public FileDialog (Shell parent, int style) {

 	super (parent, style);

 }

 

-/**

- * Returns the path of the first file that was

- * selected in the dialog relative to the filter path,

- * or null if none is available.

- * 

- * @return the relative path of the file

- */

 public String getFileName () {

 	return fileName;

 }

 

-/**

- * Returns the paths of all files that were selected

- * in the dialog relative to the filter path, or null

- * if none are available.

- * 

- * @return the relative paths of the files

- */

 public String [] getFileNames () {

 	return fileNames;

 }

 

-/**

- * Returns the file extensions which the dialog will

- * use to filter the files it shows.

- *

- * @return the file extensions filter

- */

-public String [] getFilterExtensions () {

-	return filterExtensions;

-}

-

-/**

- * Returns the file names which the dialog will

- * use to filter the files it shows.

- *

- * @return the file name filter

- */

 public String [] getFilterNames () {

 	return filterNames;

 }

 

-/**

- * Returns the path which the dialog will use to filter

- * the files it shows.

- *

- * @return the filter path

- */

+public String [] getFilterExtensions () {

+	return filterExtensions;

+}

+

 public String getFilterPath () {

 	return filterPath;

 }

 

-/**

- * Makes the dialog visible and brings it to the front

- * of the display.

- *

- * @return a string describing the absolute path of the first selected file,

- *         or null if the dialog was cancelled or an error occurred

- *

- * @exception SWTException <ul>

- *    <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>

- * </ul>

- */

 public String open () {

 	int hHeap = OS.GetProcessHeap ();

 	

@@ -166,7 +70,6 @@
 

 	/* Convert the title and copy it into lpstrTitle */

 	if (title == null) title = "";

-	/* Use the character encoding for the default locale */

 	byte [] buffer3 = Converter.wcsToMbcs (0, title, true);

 	int lpstrTitle = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer3.length);

 	OS.MoveMemory (lpstrTitle, buffer3, buffer3.length); 

@@ -183,17 +86,14 @@
 	if (filterExtensions.length == 0) {

 		strFilter = strFilter + FILTER + '\0' + FILTER + '\0';

 	}

-	/* Use the character encoding for the default locale */

 	byte [] buffer4 = Converter.wcsToMbcs (0, strFilter, true);

 	int lpstrFilter = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer4.length);

 	OS.MoveMemory (lpstrFilter, buffer4, buffer4.length);

 	

 	/* Convert the fileName and filterName to C strings */

 	if (fileName == null) fileName = "";

-	/* Use the character encoding for the default locale */

 	byte [] name = Converter.wcsToMbcs (0, fileName, false);

 	if (filterPath == null) filterPath = "";

-	/* Use the character encoding for the default locale */

 	byte [] path = Converter.wcsToMbcs (0, filterPath, false);

 

 	/*

@@ -277,7 +177,6 @@
 		OS.MoveMemory (buffer, lpstrFile, buffer.length);

 		byte [] prefix = new byte [struct.nFileOffset - 1];

 		System.arraycopy (buffer, 0, prefix, 0, prefix.length);

-		/* Use the character encoding for the default locale */

 		filterPath = new String (Converter.mbcsToWcs (0, prefix));

 		int start = struct.nFileOffset;

 		do {

@@ -286,7 +185,6 @@
 			byte [] buffer1 = new byte [end - start];

 			System.arraycopy (buffer, start, buffer1, 0, buffer1.length);

 			start = end;

-			/* Use the character encoding for the default locale */

 			String string = new String (Converter.mbcsToWcs (0, buffer1));

 			if (count == fileNames.length) {

 				String [] newFileNames = new String [fileNames.length + 4];

@@ -335,47 +233,18 @@
 	return fullPath;

 }

 

-/**

- * Set the initial filename which the dialog will

- * select by default when opened to the argument,

- * which may be null.  The name will be prefixed with

- * the filter path when one is supplied.

- * 

- * @param string the file name

- */

 public void setFileName (String string) {

 	fileName = string;

 }

 

-/**

- * Set the file extensions which the dialog will

- * use to filter the files it shows to the argument,

- * which may be null.

- *

- * @param extensions the file extension filter

- */

 public void setFilterExtensions (String [] extensions) {

 	filterExtensions = extensions;

 }

 

-/**

- * Sets the file names which the dialog will

- * use to filter the files it shows to the argument,

- * which may be null.

- *

- * @param names the file name filter

- */

 public void setFilterNames (String [] names) {

 	filterNames = names;

 }

 

-/**

- * Sets the path which the dialog will use to filter

- * the files it shows to the argument, which may be

- * null.

- *

- * @param string the filter path

- */

 public void setFilterPath (String string) {

 	filterPath = string;

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java
index ecf14cf..953ebac 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java
@@ -21,89 +21,20 @@
 public class FontDialog extends Dialog {

 	FontData fontData;

 	

-/**

- * Constructs a new instance of this class given only its

- * parent.

- * <p>

- * Note: Currently, null can be passed in for the parent.

- * This has the effect of creating the dialog on the currently active

- * display if there is one. If there is no current display, the 

- * dialog is created on a "default" display. <b>Passing in null as

- * the parent is not considered to be good coding style,

- * and may not be supported in a future release of SWT.</b>

- * </p>

- *

- * @param parent a shell which will be the parent of the new instance

- *

- * @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>

- */

 public FontDialog (Shell parent) {

 	this (parent, SWT.PRIMARY_MODAL);

 }

 

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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 dialog classes should include a comment which

- * describes the style constants which are applicable to the class.

- * </p>

- * Note: Currently, null can be passed in for the parent.

- * This has the effect of creating the dialog on the currently active

- * display if there is one. If there is no current display, the 

- * dialog is created on a "default" display. <b>Passing in null as

- * the parent is not considered to be good coding style,

- * and may not be supported in a future release of SWT.</b>

- * </p>

- *

- * @param parent a shell which will be the parent of the new instance

- *

- * @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>

- */

 public FontDialog (Shell parent, int style) {

 	super (parent, style);

 }

 

-/**

- * Returns a FontData object describing the font that was

- * selected in the dialog, or null if none is available.

- * 

- * @return the FontData for the selected font, or null

- */

 public FontData getFontData() {

 	return fontData;

 }

 

-/**

- * Makes the dialog visible and brings it to the front

- * of the display.

- *

- * @return a FontData object describing the font that was selected,

- *         or null if the dialog was cancelled or an error occurred

- *

- * @exception SWTException <ul>

- *    <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>

- * </ul>

- */

 public FontData open () {

+	

 	/* Get the owner HWND for the dialog */

 	int hwndOwner = 0;

 	if (parent != null) hwndOwner = parent.handle;

@@ -172,13 +103,6 @@
 	return fontData;

 }

 

-/**

- * Sets a FontData object describing the font to be

- * selected by default in the dialog, or null to let

- * the platform choose one.

- * 

- * @param fontData the FontData to use initially, or null

- */

 public void setFontData (FontData fontData) {

 	this.fontData = fontData;

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
index d738e99..7731638 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
@@ -31,7 +31,7 @@
 

 public class Group extends Composite {

 	static final int GroupProc;

-	static final byte [] GroupClass = Converter.wcsToMbcs (0, "BUTTON\0");

+	static final byte [] GroupClass = Converter.wcsToMbcs (0, "BUTTON\0", false);

 	static {

 		WNDCLASSEX lpWndClass = new WNDCLASSEX ();

 		lpWndClass.cbSize = WNDCLASSEX.sizeof;

@@ -39,34 +39,6 @@
 		GroupProc = lpWndClass.lpfnWndProc;

 	}

 

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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 Group (Composite parent, int style) {

 	super (parent, checkStyle (style));

 }

@@ -190,7 +162,7 @@
 	if (length == 0) return "";

 	byte [] buffer1 = new byte [length + 1];

 	OS.GetWindowText (handle, buffer1, buffer1.length);

-	char [] buffer2 = Converter.mbcsToWcs (getCodePage (), buffer1);

+	char [] buffer2 = Converter.mbcsToWcs (0, buffer1);

 	return new String (buffer2, 0, buffer2.length - 1);

 }

 

@@ -222,7 +194,7 @@
 public void setText (String string) {

 	checkWidget ();

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (0, string, true);

 	OS.SetWindowText (handle, buffer);

 }

 

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ImageList.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ImageList.java
index a2bf711..d44e28e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ImageList.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ImageList.java
@@ -10,7 +10,7 @@
 import org.eclipse.swt.graphics.*;

 

 class ImageList {

-	int handle, refCount;

+	int handle, background;

 	Image [] images;

 	static final int CREATE_FLAGS;

 	static {

@@ -45,6 +45,7 @@
 public ImageList () {

 	handle = OS.ImageList_Create (32, 32, CREATE_FLAGS, 16, 16);

 	images = new Image [4];

+	background = 0x00FFFFFF;

 }

 

 public int add (Image image) {

@@ -69,13 +70,10 @@
 				OS.ImageList_SetIconSize (handle, cx [0], cy [0]);

 			}

 			int hBitmap = copyBitmap (hImage, cx [0], cy [0]);

-			int background = -1;

-			Color color = image.getBackground ();

-			if (color != null) background = color.handle;

 			if (index == count) {

 				OS.ImageList_AddMasked (handle, hBitmap, background);

 			} else {

-				int hMask = createMask (hBitmap, cx [0], cy [0], background);

+				int hMask = createMask (hBitmap, cx [0], cy [0]);

 				OS.ImageList_Replace (handle, index, hBitmap, hMask);

 				OS.DeleteObject (hMask);

 			}

@@ -111,10 +109,6 @@
 	return index;

 }

 

-int addRef() {

-	return ++refCount;

-}

-

 int copyBitmap (int hImage, int width, int height) {

 	BITMAP bm = new BITMAP ();

 	OS.GetObject (hImage, BITMAP.sizeof, bm);

@@ -137,20 +131,18 @@
 	return hIcon;

 }

 

-int createMask (int hBitmap, int width, int height, int background) {

+int createMask (int hBitmap, int width, int height) {

+	int hDC = OS.GetDC (0);

+	int hdc1 = OS.CreateCompatibleDC (hDC);

+	OS.SelectObject (hdc1, hBitmap);

+	int hdc2 = OS.CreateCompatibleDC (hDC);

 	int hMask = OS.CreateBitmap (width, height, 1, 1, null);

-	if (background != -1) {

-		int hDC = OS.GetDC (0);

-		int hdc1 = OS.CreateCompatibleDC (hDC);

-		OS.SelectObject (hdc1, hBitmap);

-		int hdc2 = OS.CreateCompatibleDC (hDC);

-		OS.SelectObject (hdc2, hMask);

-		OS.SetBkColor (hdc1, background);

-		OS.BitBlt (hdc2, 0, 0, width, height, hdc1, 0, 0, OS.SRCCOPY);

-		OS.ReleaseDC (0, hDC);

-		OS.DeleteDC (hdc1);

-		OS.DeleteDC (hdc2);

-	}

+	OS.SelectObject (hdc2, hMask);

+	OS.SetBkColor (hdc1, background);

+	OS.BitBlt (hdc2, 0, 0, width, height, hdc1, 0, 0, OS.SRCCOPY);

+	OS.ReleaseDC (0, hDC);

+	OS.DeleteDC (hdc1);

+	OS.DeleteDC (hdc2);

 	return hMask;

 }

 

@@ -164,14 +156,12 @@
 	return images [index];

 }

 

-public int getHandle () {

-	return handle;

+public int getBackground () {

+	return background;

 }

 

-public Point getImageSize() {

-	int [] cx = new int [1], cy = new int [1];

-	OS.ImageList_GetIconSize (handle, cx, cy);

-	return new Point (cx [0], cy [0]);

+public int getHandle () {

+	return handle;

 }

 

 public int indexOf (Image image) {

@@ -194,11 +184,8 @@
 		int hImage = image.handle;

 		switch (image.type) {

 			case SWT.BITMAP:

-				int background = -1;

-				Color color = image.getBackground ();

-				if (color != null) background = color.handle;

 				int hBitmap = copyBitmap (hImage, cx [0], cy [0]);

-				int hMask = createMask (hBitmap, cx [0], cy [0], background);

+				int hMask = createMask (hBitmap, cx [0], cy [0]);

 				OS.ImageList_Replace (handle, index, hBitmap, hMask);

 				OS.DeleteObject (hBitmap);

 				OS.DeleteObject (hMask);

@@ -221,8 +208,51 @@
 	images [index] = null;

 }

 

-int removeRef() {

-	return --refCount;

+public void setBackground (int color) {

+	if (background == color) return;

+	background = color;

+	/*

+	* This code is intentionally commented.  When the background

+	* color of the control changes, it is necessary to recompute

+	* the masks for all bitmaps in the image list.  This can look

+	* really bad when the application program assumes the original

+	* color of the control and makes bitmaps accordingly.  Typically

+	* this happens when the colors are change using the control panel.

+	* Therefore, this code remains commented even though it is correct.

+	*/

+//	int length = OS.ImageList_GetImageCount (handle);

+//	if (length == 0) return;

+//	int [] cx = new int [1], cy = new int [1];

+//	OS.ImageList_GetIconSize (handle, cx, cy);

+//	int width = cx [0], height = cy [0];

+//	OS.ImageList_Destroy (handle);

+//	handle = OS.ImageList_Create (width, height, CREATE_FLAGS, length, 16);

+//	for (int i=0; i<length; i++) {

+//		Image image = images [i];

+//		if (image == null || image.isDisposed ()) {

+//			images [i] = null;

+//			int hBitmap = OS.CreateBitmap (width, height, 1, 1, null);

+//			OS.ImageList_AddMasked (handle, hBitmap, background);

+//			OS.DeleteObject (hBitmap);

+//		} else {

+//			int hImage = image.handle;

+//			switch (image.type) {

+//				case SWT.BITMAP:

+//					int hBitmap = copyBitmap (hImage, width, height);

+//					OS.ImageList_AddMasked (handle, hBitmap, background);

+//					OS.DeleteObject (hBitmap);

+//					break;

+//				case SWT.ICON:

+//					int hIcon = copyIcon (hImage, width, height);

+//					OS.ImageList_ReplaceIcon (handle, -1, hIcon);

+//					OS.DestroyIcon (hIcon);

+//					break;

+//				default:

+//					SWT.error (SWT.ERROR_NOT_IMPLEMENTED);

+//					break;

+//			}

+//		}

+//	}

 }

 

 public int size () {

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
index 072bf29..2f18c51 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
@@ -27,6 +27,7 @@
  * within the SWT implementation.

  * </p>

  */

+

 public class Label extends Control {

 	Image image;

 	int font;

@@ -220,7 +221,7 @@
 	if (length == 0) return "";

 	byte [] buffer1 = new byte [length + 1];

 	OS.GetWindowText (handle, buffer1, buffer1.length);

-	char [] buffer2 = Converter.mbcsToWcs (getCodePage (), buffer1);

+	char [] buffer2 = Converter.mbcsToWcs (0, buffer1);

 	return new String (buffer2, 0, buffer2.length - 1);

 }

 

@@ -306,7 +307,6 @@
 }

 

 public boolean setFocus () {

-	checkWidget();

 	return false;

 }

 

@@ -316,9 +316,6 @@
  *

  * @param image the image to display on the receiver (may be null)

  *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the image 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>

@@ -329,7 +326,6 @@
 	if ((style & SWT.SEPARATOR) != 0) return;

 	int hImage = 0, imageBits = 0, fImageType = 0;

 	if (image != null) {

-		if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 		hImage = image.handle;

 		switch (image.type) {

 			case SWT.BITMAP:

@@ -410,7 +406,7 @@
 		if (hFont != 0) OS.SendMessage (handle, OS.WM_SETFONT, hFont, 0);

 	}

 	string = Display.withCrLf (string);

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (0, string, true);

 	OS.SetWindowText (handle, buffer);

 }

 

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 9c36525..1390159 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
@@ -29,7 +29,7 @@
 

 public class List extends Scrollable {

 	static final int ListProc;

-	static final byte [] ListClass = Converter.wcsToMbcs (0, "LISTBOX\0");

+	static final byte [] ListClass = Converter.wcsToMbcs (0, "LISTBOX\0", false);

 	static {

 		WNDCLASSEX lpWndClass = new WNDCLASSEX ();

 		lpWndClass.cbSize = WNDCLASSEX.sizeof;

@@ -89,7 +89,7 @@
 public void add (String string) {

 	checkWidget ();

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (0, string, true);

 	int result = OS.SendMessage (handle, OS.LB_ADDSTRING, 0, buffer);

 	if (result == OS.LB_ERR) error (SWT.ERROR_ITEM_NOT_ADDED);

 	if (result == OS.LB_ERRSPACE) error (SWT.ERROR_ITEM_NOT_ADDED);

@@ -125,7 +125,7 @@
 	checkWidget ();

 	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (index == -1) error (SWT.ERROR_INVALID_RANGE);

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (0, string, true);

 	int result = OS.SendMessage (handle, OS.LB_INSERTSTRING, index, buffer);

 	if (result == OS.LB_ERRSPACE) error (SWT.ERROR_ITEM_NOT_ADDED);

 	if (result == OS.LB_ERR) {

@@ -395,7 +395,7 @@
 		byte [] buffer1 = new byte [length + 1];

 		int result = OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer1);

 		if (result != OS.LB_ERR) {

-			char [] buffer2 = Converter.mbcsToWcs (getCodePage (), buffer1);

+			char [] buffer2 = Converter.mbcsToWcs (0, buffer1);

 			return new String (buffer2, 0, buffer2.length - 1);

 		}

 	}

@@ -634,6 +634,7 @@
  * </ul>

  */

 public int indexOf (String string) {

+	checkWidget ();

 	return indexOf (string, 0);

 }

 

@@ -681,7 +682,7 @@
 	int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);

 	if (!((0 <= start) && (start < count))) return -1;

 	int index = start - 1, last;

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (0, string, true);

 	do {

 		index = OS.SendMessage (handle, OS.LB_FINDSTRINGEXACT, last = index, buffer);

 		if ((index == OS.LB_ERR) || (index <= last)) return -1;

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 0a8c280..7fb3d9a 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
@@ -473,6 +473,10 @@
 	return getEnabled () && parentMenu.isEnabled ();

 }

 

+boolean isValidWidget () {

+	return handle != 0;

+}

+

 /**

  * Returns <code>true</code> if the receiver is visible, and

  * <code>false</code> otherwise.

@@ -605,9 +609,6 @@
  * 

  * @param item the default menu item or null

  *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the menu item 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>

@@ -616,10 +617,7 @@
 public void setDefaultItem (MenuItem item) {

 	checkWidget ();

 	int command = -1;

-	if (item != null) {

-		if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

-		command = item.id;

-	}

+	if (item != null) command = item.id;

 	OS.SetMenuDefaultItem (handle, command, OS.MF_BYCOMMAND);

 	redraw ();

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
index 926908a..c5a20e5 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
@@ -29,73 +29,12 @@
 	Menu parent, menu;

 	int id, accelerator;

 

-/**

- * Constructs a new instance of this class given its parent

- * (which must be a <code>Menu</code>) and a style value

- * describing its behavior and appearance. The item is added

- * to the end of 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

- *

- * @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 MenuItem (Menu parent, int style) {

 	super (parent, checkStyle (style));

 	this.parent = parent;

 	parent.createItem (this, parent.getItemCount ());

 }

 

-/**

- * Constructs a new instance of this class given its parent

- * (which must be a <code>Menu</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 MenuItem (Menu parent, int style, int index) {

 	super (parent, checkStyle (style));

 	this.parent = parent;

@@ -508,18 +447,17 @@
 }

 

 /**

- * Sets the receiver's pull down menu to the argument.

+ * Sets the receiver's cascade menu to the argument.

  * Only <code>CASCADE</code> menu items can have a

  * pull down menu. The sequence of key strokes, button presses

  * and/or button releases that are used to request a pull down

  * menu is platform specific.

  *

- * @param menu the new pull down menu

+ * @param menu the new pop up menu

  *

  * @exception IllegalArgumentException <ul>

- *    <li>ERROR_MENU_NOT_DROP_DOWN - if the menu is not a drop down menu</li>

- *    <li>ERROR_MENUITEM_NOT_CASCADE - if the menu item is not a <code>CASCADE</code></li>

- *    <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>

+ *    <li>ERROR_MENU_NOT_DROP_DOWN - the menu is not a drop down menu</li>

+ *	<li>ERROR_MENUITEM_NOT_CASCADE - the menu item is not a <code>CASCADE</code></li>

  *    <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>

  * </ul>

  * @exception SWTException <ul>

@@ -535,7 +473,6 @@
 		error (SWT.ERROR_MENUITEM_NOT_CASCADE);

 	}

 	if (menu != null) {

-		if (menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 		if ((menu.style & SWT.DROP_DOWN) == 0) {

 			error (SWT.ERROR_MENU_NOT_DROP_DOWN);

 		}

@@ -626,7 +563,6 @@
 	super.setText (string);

 	int hMenu = parent.handle;

 	int hHeap = OS.GetProcessHeap ();

-	/* Use the character encoding for the default locale */

 	byte [] buffer = Converter.wcsToMbcs (0, string, false);

 	int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer.length + 1);

 	OS.MoveMemory (pszText, buffer, buffer.length);

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MessageBox.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MessageBox.java
index 462c109..26db85b 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MessageBox.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MessageBox.java
@@ -30,62 +30,10 @@
 public  class MessageBox extends Dialog {

 	String message = "";

 	

-/**

- * Constructs a new instance of this class given only its

- * parent.

- * <p>

- * Note: Currently, null can be passed in for the parent.

- * This has the effect of creating the dialog on the currently active

- * display if there is one. If there is no current display, the 

- * dialog is created on a "default" display. <b>Passing in null as

- * the parent is not considered to be good coding style,

- * and may not be supported in a future release of SWT.</b>

- * </p>

- *

- * @param parent a shell which will be the parent of the new instance

- *

- * @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>

- */

 public MessageBox (Shell parent) {

 	this (parent, SWT.OK | SWT.ICON_INFORMATION | SWT.APPLICATION_MODAL);

 }

 

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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 dialog classes should include a comment which

- * describes the style constants which are applicable to the class.

- * </p>

- * Note: Currently, null can be passed in for the parent.

- * This has the effect of creating the dialog on the currently active

- * display if there is one. If there is no current display, the 

- * dialog is created on a "default" display. <b>Passing in null as

- * the parent is not considered to be good coding style,

- * and may not be supported in a future release of SWT.</b>

- * </p>

- *

- * @param parent a shell which will be the parent of the new instance

- *

- * @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>

- */

 public MessageBox (Shell parent, int style) {

 	super (parent, checkStyle (style));

 }

@@ -101,29 +49,10 @@
 	return style;

 }

 

-/**

- * Returns the dialog's message, which is a description of

- * the purpose for which it was opened. This message will be

- * visible on the dialog while it is open.

- *

- * @return the message

- */

 public String getMessage () {

 	return message;

 }

 

-/**

- * Makes the dialog visible and brings it to the front

- * of the display.

- *

- * @return the ID of the button that was selected to dismiss the

- *         message box (e.g. SWT.OK, SWT.CANCEL, etc...)

- *

- * @exception SWTException <ul>

- *    <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>

- *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>

- * </ul>

- */

 public int open () {

 

 	/* Compute the MessageBox style */

@@ -179,7 +108,6 @@
 	int hwndFocus = OS.GetFocus ();

 

 	/* Open the message box */

-	/* Use the character encoding for the default locale */

 	byte [] buffer1 = Converter.wcsToMbcs (0, message, true);

 	byte [] buffer2 = Converter.wcsToMbcs (0, title, true);

 	int code = OS.MessageBox (hwndOwner, buffer1, buffer2, bits);

@@ -222,13 +150,6 @@
 	return SWT.CANCEL;

 }

 

-/**

- * Sets the dialog's message, which is a description of

- * the purpose for which it was opened. This message will be

- * visible on the dialog while it is open.

- *

- * @param string the message

- */

 public void setMessage (String string) {

 	message = string;

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java
index ad20481..50384c0 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java
@@ -34,34 +34,6 @@
 		ProgressBarProc = lpWndClass.lpfnWndProc;

 	}

 

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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 ProgressBar (Composite parent, int style) {

 	super (parent, checkStyle (style));

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java
index 4b51821..bee0bba 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java
@@ -29,34 +29,6 @@
 	boolean dragging;

 	int startX, startY, lastX, lastY;

 

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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 Sash (Composite parent, int style) {

 	super (parent, checkStyle (style));

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java
index 60a6e59..f9a7437 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java
@@ -36,34 +36,6 @@
 		TrackBarProc = lpWndClass.lpfnWndProc;

 	}

 

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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 Scale (Composite parent, int style) {

 	super (parent, checkStyle (style));

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java
index f54e74d..290f652 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java
@@ -143,7 +143,8 @@
  * @see SelectionEvent

  */

 public void addSelectionListener (SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	TypedListener typedListener = new TypedListener(listener);

 	addListener (SWT.Selection,typedListener);

@@ -203,7 +204,8 @@
  * </ul>

  */

 public boolean getEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return (state & DISABLED) == 0;

 }

 

@@ -220,7 +222,8 @@
  * </ul>

  */

 public int getIncrement () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return increment;

 }

 

@@ -235,7 +238,8 @@
  * </ul>

  */

 public int getMaximum () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	SCROLLINFO info = new SCROLLINFO ();

 	info.cbSize = SCROLLINFO.sizeof;

 	info.fMask = OS.SIF_RANGE;

@@ -256,7 +260,8 @@
  * </ul>

  */

 public int getMinimum () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	SCROLLINFO info = new SCROLLINFO ();

 	info.cbSize = SCROLLINFO.sizeof;

 	info.fMask = OS.SIF_RANGE;

@@ -279,7 +284,8 @@
  * </ul>

  */

 public int getPageIncrement () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return pageIncrement;

 }

 

@@ -294,7 +300,8 @@
  * </ul>

  */

 public Scrollable getParent () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return parent;

 }

 

@@ -309,7 +316,8 @@
  * </ul>

  */

 public int getSelection () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	SCROLLINFO info = new SCROLLINFO ();

 	info.cbSize = SCROLLINFO.sizeof;

 	info.fMask = OS.SIF_POS;

@@ -332,7 +340,8 @@
  * </ul>

  */

 public Point getSize () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	RECT rect = new RECT ();

 	OS.GetClientRect (parent.handle, rect);

 	int width, height;

@@ -360,7 +369,8 @@
  * @see ScrollBar

  */

 public int getThumb () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	SCROLLINFO info = new SCROLLINFO ();

 	info.cbSize = SCROLLINFO.sizeof;

 	info.fMask = OS.SIF_PAGE;

@@ -389,7 +399,8 @@
  * </ul>

  */

 public boolean getVisible () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return (state & HIDDEN) == 0;

 }

 

@@ -416,7 +427,8 @@
  * </ul>

  */

 public boolean isEnabled () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return getEnabled () && parent.isEnabled ();

 }

 

@@ -438,7 +450,8 @@
  * </ul>

  */

 public boolean isVisible () {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	return getVisible () && parent.isVisible ();

 }

 

@@ -471,7 +484,8 @@
  * @see #addSelectionListener

  */

 public void removeSelectionListener (SelectionListener listener) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (eventTable == null) return;

 	eventTable.unhook (SWT.Selection, listener);

@@ -504,7 +518,8 @@
  * </ul>

  */

 public void setEnabled (boolean enabled) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int hwnd = hwndScrollBar (), type = scrollBarType ();

 	int flags = OS.ESB_DISABLE_BOTH;

 	if (enabled) flags = OS.ESB_ENABLE_BOTH;

@@ -527,7 +542,8 @@
  * </ul>

  */

 public void setIncrement (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (value < 1) return;

 	increment = value;

 }

@@ -545,7 +561,8 @@
  * </ul>

  */

 public void setMaximum (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (value < 0) return;

 	SCROLLINFO info = new SCROLLINFO ();

 	info.cbSize = SCROLLINFO.sizeof;

@@ -595,7 +612,8 @@
  * </ul>

  */

 public void setMinimum (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (value < 0) return;

 	SCROLLINFO info = new SCROLLINFO ();

 	info.cbSize = SCROLLINFO.sizeof;

@@ -646,7 +664,8 @@
  * </ul>

  */

 public void setPageIncrement (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (value < 1) return;

 	pageIncrement = value;

 }

@@ -664,7 +683,8 @@
  * </ul>

  */

 public void setSelection (int selection) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (selection < 0) return;

 	SCROLLINFO info = new SCROLLINFO ();

 	info.cbSize = SCROLLINFO.sizeof;

@@ -689,7 +709,8 @@
  * @see ScrollBar

  */

 public void setThumb (int value) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 

 	/* Position the thumb */

 	if (value < 1) return;

@@ -751,7 +772,8 @@
  * </ul>

  */

 public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	if (selection < 0) return;

 	if (minimum < 0) return;

 	if (maximum < 0) return;

@@ -815,7 +837,8 @@
  * </ul>

  */

 public void setVisible (boolean visible) {

-	checkWidget();

+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 	int hwnd = hwndScrollBar (), type = scrollBarType ();

 	if (OS.ShowScrollBar (hwnd, type, visible)) {

 		/*

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
index a43f538..a4267d0 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
@@ -90,7 +90,6 @@
 	int [] brushes;

 	boolean showWithParent;

 	int toolTipHandle, lpstrTip;

-	Control lastActive;

 

 /**

  * Constructs a new instance of this class. This is equivalent

@@ -575,7 +574,6 @@
 	if (IsDBLocale) {

 		if (hIMC != 0) OS.ImmDestroyContext (hIMC);

 	}

-	lastActive = null;

 }

 

 void remove (Menu menu) {

@@ -625,43 +623,6 @@
 	return (result > 0) ? LRESULT.ONE : LRESULT.ZERO;

 }

 

-void setActiveControl (Control control) {

-	if (control != null && control.isDisposed ()) control = null;

-	if (lastActive != null && lastActive.isDisposed ()) lastActive = null;

-	if (lastActive == control) return;

-	

-	/*

-	* Compute the list of controls to be activated and

-	* deactivated by finding the first common parent

-	* control.

-	*/

-	Control [] activate = (control == null) ? new Control[0] : control.getPath ();

-	Control [] deactivate = (lastActive == null) ? new Control[0] : lastActive.getPath ();

-	lastActive = control;

-	int index = 0, length = Math.min (activate.length, deactivate.length);

-	while (index < length) {

-		if (activate [index] != deactivate [index]) break;

-		index++;

-	}

-	

-	/*

-	* It is possible (but unlikely), that application

-	* code could have destroyed some of the widgets. If

-	* this happens, keep processing those widgets that

-	* are not disposed.

-	*/

-	for (int i=deactivate.length-1; i>=index; --i) {

-		if (!deactivate [i].isDisposed ()) {

-			deactivate [i].sendEvent (SWT.Deactivate);

-		}

-	}

-	for (int i=activate.length-1; i>=index; --i) {

-		if (!activate [i].isDisposed ()) {

-			activate [i].sendEvent (SWT.Activate);

-		}

-	}

-}

-

 void setBounds (int x, int y, int width, int height, int flags) {

 	if (OS.IsIconic (handle)) {

 		super.setBounds (x, y, width, height, flags);

@@ -750,7 +711,7 @@
 void setToolTipText (int hwnd, String text) {

 	if (toolTipHandle == 0) {

 		toolTipHandle = OS.CreateWindowEx (

-			OS.WS_EX_TOPMOST,

+			0,

 			OS.TOOLTIPS_CLASS,

 			null,

 			OS.TTS_ALWAYSTIP,

@@ -760,14 +721,6 @@
 			OS.GetModuleHandle (null),

 			null);

 		if (toolTipHandle == 0) error (SWT.ERROR_NO_HANDLES);

-		/*

-		* Feature in Windows.  Despite the fact that the

-		* tool tip text contains \r\n, the tooltip will

-		* not honour the new line unless TTM_SETMAXTIPWIDTH

-		* is set.  The fix is to set TTM_SETMAXTIPWIDTH to

-		* a large value.

-		*/

-		OS.SendMessage (toolTipHandle, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF);

 	}

 	TOOLINFO lpti = new TOOLINFO ();

 	lpti.cbSize = TOOLINFO.sizeof;

@@ -834,12 +787,6 @@
 	setItemEnabled (OS.SC_CLOSE, isActive ());

 }

 

-int widgetExtStyle () {

-	int bits = super.widgetExtStyle ();

-	if ((style & SWT.ON_TOP) != 0) bits |= OS.WS_EX_TOPMOST;

-	return bits;

-}

-

 int widgetStyle () {

 	int bits = super.widgetStyle () & ~OS.WS_POPUP;

 	if (handle != 0) return bits | OS.WS_CHILD;

@@ -875,31 +822,14 @@
 	if (result != null) return result;

 	int hittest = lParam & 0xFFFF;

 	if (hittest == OS.HTMENU) return null;

-	/*

-	* Get the current location of the cursor,

-	* not the location of the cursor when the

-	* WM_MOUSEACTIVATE was generated.  This is

-	* strictly incorrect but is necessary in

-	* order to support Activate and Deactivate

-	* events for embedded widgets that have

-	* their own event loop.  In that case, the

-	* cursor location reported by GetMessagePos

-	* is the one for our event loop, not the

-	* embedded widget's event loop.

-	*/

 	POINT pt = new POINT ();

-	if (!OS.GetCursorPos (pt)) {

-		int pos = OS.GetMessagePos ();

-		pt.x = (short) (pos & 0xFFFF);

-		pt.y = (short) (pos >> 16);

-	}

+	int pos = OS.GetMessagePos ();

+	pt.x = (short) (pos & 0xFFFF);

+	pt.y = (short) (pos >> 16);

 	int hwnd = OS.WindowFromPoint (pt);

 	if (hwnd == 0) return null;

-	Control control = display.findControl (hwnd);

-	setActiveControl (control);

-	// widget could be disposed at this point

-	if (isDisposed ()) return null;

-	if (control == null || control.isDisposed ()) return null;	

+	Control control = WidgetTable.get (hwnd);

+	if (control == null) return null;

 	Button button = null;

 	boolean setDefault = false;

 	if (OS.GetActiveWindow () == handle && this == control.getShell ()) {

@@ -928,7 +858,7 @@
 //			return new LRESULT (OS.MA_NOACTIVATE);

 //		}

 //	}

-	return null;

+	return result;

 }

 

 LRESULT WM_NCHITTEST (int wParam, int lParam) {

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java
index 802e817..3bf730b 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java
@@ -56,10 +56,11 @@
  *

  * @see ScrollBar

  */

+

 public class Slider extends Control {

 	int increment, pageIncrement;

 	static final int ScrollBarProc;

-	static final byte [] ScrollBarClass = Converter.wcsToMbcs (0, "SCROLLBAR\0");

+	static final byte [] ScrollBarClass = Converter.wcsToMbcs (0, "SCROLLBAR\0", false);

 	static {

 		WNDCLASSEX lpWndClass = new WNDCLASSEX ();

 		lpWndClass.cbSize = WNDCLASSEX.sizeof;

@@ -67,34 +68,6 @@
 		ScrollBarProc = lpWndClass.lpfnWndProc;

 	}

 

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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 Slider (Composite parent, int style) {

 	super (parent, checkStyle (style));

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
index 9ac3e9d..a768df1 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
@@ -34,6 +34,7 @@
  * IMPORTANT: This class is <em>not</em> intended to be subclassed.

  * </p>

  */

+

 public class TabFolder extends Composite {

 	TabItem [] items;

 	ImageList imageList;

@@ -68,34 +69,7 @@
 		}

 	}

 

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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 TabFolder (Composite parent, int style) {

 	super (parent, checkStyle (style));

 }

@@ -223,27 +197,6 @@
 void createHandle () {

 	super.createHandle ();

 	state &= ~CANVAS;

-	

-	/*

-	* Feature in Windows.  Despite the fact that the

-	* tool tip text contains \r\n, the tooltip will

-	* not honour the new line unless TTM_SETMAXTIPWIDTH

-	* is set.  The fix is to set TTM_SETMAXTIPWIDTH to

-	* a large value.

-	*/

-	int hwndToolTip = OS.SendMessage (handle, OS.TCM_GETTOOLTIPS, 0, 0);

-	OS.SendMessage (hwndToolTip, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF);

-	

-	/*

-	* Feature in Windows.  When the tool tip control is

-	* created, the parent of the tool tip is the shell.

-	* If SetParent () is used to reparent the tab folder

-	* into a new shell, the tool tip is not reparented

-	* and pops up underneath the new shell.  The fix is

-	* to make sure the tool tip is a topmost window.

-	*/

-	int flags = OS.SWP_NOACTIVATE | OS.SWP_NOMOVE | OS.SWP_NOSIZE;

-	OS.SetWindowPos (hwndToolTip, OS.HWND_TOPMOST, 0, 0, 0, 0, flags);

 }

 

 void createWidget () {

@@ -268,8 +221,7 @@
 	if (count == 0) {

 		if (imageList != null) {

 			OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, 0);

-			Display display = getDisplay ();

-			display.releaseImageList (imageList);

+			imageList.dispose ();

 		}

 		imageList = null;

 		items = new TabItem [4];

@@ -406,13 +358,12 @@
 int imageIndex (Image image) {

 	if (image == null) return OS.I_IMAGENONE;

 	if (imageList == null) {

-		Rectangle bounds = image.getBounds ();

-		imageList = getDisplay ().getImageList (new Point (bounds.width, bounds.height));

-		int index = imageList.indexOf (image);

-		if (index == -1) index = imageList.add (image);

+		imageList = new ImageList ();

+		imageList.setBackground (getBackgroundPixel ());

+		imageList.add (image);

 		int hImageList = imageList.getHandle ();

 		OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, hImageList);

-		return index;

+		return 0;

 	}

 	int index = imageList.indexOf (image);

 	if (index != -1) return index;

@@ -453,13 +404,12 @@
 		if (!item.isDisposed ()) item.releaseWidget ();

 	}

 	items = null;

+	super.releaseWidget ();

 	if (imageList != null) {

 		OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, 0);

-		Display display = getDisplay ();

-		display.releaseImageList (imageList);

+		imageList.dispose ();

 	}

 	imageList = null;

-	super.releaseWidget ();

 }

 

 /**

@@ -628,7 +578,6 @@
 				if (item != null) string = item.toolTipText;

 			}

 			if (string != null && string.length () != 0) {

-				string = Display.withCrLf (string);

 				int length = string.length ();

 				char [] buffer = new char [length + 1];

 				string.getChars (0, length, buffer, 0);

@@ -662,6 +611,17 @@
 	return result;

 }

 

+LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) {

+	LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam);

+	if (result != null) return result;

+	if (imageList != null && background == -1) {

+		imageList.setBackground (defaultBackground ());

+		int hImageList = imageList.getHandle ();

+		OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, hImageList);

+	}

+	return result;

+}

+

 LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) {

 	LRESULT result = super.WM_WINDOWPOSCHANGING (wParam, lParam);

 	if (result != null) return result;

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java
index 25b75e5..4751b0f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java
@@ -29,73 +29,13 @@
 	Control control;

 	String toolTipText;

 

-/**

- * Constructs a new instance of this class given its parent

- * (which must be a <code>TabFolder</code>) and a style value

- * describing its behavior and appearance. The item is added

- * to the end of 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

- *

- * @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 TabItem (TabFolder parent, int style) {

 	super (parent, 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

- * 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 TabItem (TabFolder parent, int style, int index) {

 	super (parent, style);

 	this.parent = parent;

@@ -180,9 +120,6 @@
  * <p>

  * @param control the new control (or null)

  *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the control 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>

@@ -190,9 +127,8 @@
  */

 public void setControl (Control control) {

 	checkWidget();

-	if (control != null) {

-		if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);

-		if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);

+	if (control != null && control.parent != parent) {

+		error (SWT.ERROR_INVALID_PARENT);

 	}

 	Control oldControl = this.control, newControl = control;

 	this.control = control;

@@ -227,7 +163,7 @@
 	super.setText (string);

 	int hwnd = parent.handle;

 	int hHeap = OS.GetProcessHeap ();

-	byte [] buffer = Converter.wcsToMbcs (parent.getCodePage (), string, false);

+	byte [] buffer = Converter.wcsToMbcs (0, string, false);

 	int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer.length + 1);

 	OS.MoveMemory (pszText, buffer, buffer.length); 

 	TCITEM tcItem = new TCITEM ();

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 7a4c65c..26d1a8a 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
@@ -47,34 +47,6 @@
 		TableProc = lpWndClass.lpfnWndProc;

 	}

 

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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 Table (Composite parent, int style) {

 	super (parent, checkStyle (style));

 }

@@ -512,8 +484,7 @@
 	if (count == 0) {

 		if (imageList != null) {

 			OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0);

-			Display display = getDisplay ();

-			display.releaseImageList (imageList);

+			imageList.dispose ();

 		}

 		imageList = null;

 		items = new TableItem [4];

@@ -889,13 +860,12 @@
 int imageIndex (Image image) {

 	if (image == null) return OS.I_IMAGENONE;

 	if (imageList == null) {

-		Rectangle bounds = image.getBounds ();

-		imageList = getDisplay ().getImageList (new Point (bounds.width, bounds.height));

-		int index = imageList.indexOf (image);

-		if (index == -1) index = imageList.add (image);

+		imageList = new ImageList ();

+		imageList.setBackground (getBackgroundPixel ());

+		imageList.add (image);

 		int hImageList = imageList.getHandle ();

 		OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, hImageList);

-		return index;

+		return 0;

 	}

 	int index = imageList.indexOf (image);

 	if (index != -1) return index;

@@ -1022,16 +992,15 @@
 //	}

 

 	items = null;

+	super.releaseWidget ();

 	if (imageList != null) {

 		OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0);

-		Display display = getDisplay ();

-		display.releaseImageList (imageList);

+		imageList.dispose ();

 	}

 	imageList = null;

 	int hOldList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);

 	OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_STATE, 0);

 	if (hOldList != 0) OS.ImageList_Destroy (hOldList);

-	super.releaseWidget ();

 }

 

 /**

@@ -1226,8 +1195,7 @@
 

 	if (imageList != null) {

 		OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0);

-		Display display = getDisplay ();

-		display.releaseImageList (imageList);

+		imageList.dispose ();

 	}

 	imageList = null;

 	items = new TableItem [4];

@@ -1268,7 +1236,7 @@
  * @param indices the array of indices for the items to select

  *

  * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the array of indices is null</li>

+ *    <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>

@@ -1471,6 +1439,11 @@
 	if (pixel == -1) pixel = defaultBackground ();

 	OS.SendMessage (handle, OS.LVM_SETBKCOLOR, 0, pixel);

 	OS.SendMessage (handle, OS.LVM_SETTEXTBKCOLOR, 0, pixel);

+	if (imageList != null) {

+		imageList.setBackground (pixel);

+		int hImageList = imageList.getHandle ();

+		OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, hImageList);

+	}

 	if ((style & SWT.CHECK) != 0) setCheckboxImageList ();

 	

 	/*

@@ -1709,7 +1682,7 @@
  * @param indices the indices of the items to select

  *

  * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the array of indices is null</li>

+ *    <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>

@@ -1732,8 +1705,7 @@
  * @param items the array of items

  *

  * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the array of items is null</li>

- *    <li>ERROR_INVALID_ARGUMENT - if one of the item has been disposed</li>

+ *    <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>

@@ -1879,7 +1851,6 @@
 public void showItem (TableItem item) {

 	checkWidget ();

 	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);

-	if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 	int index = indexOf (item);

 	if (index != -1) {

 		OS.SendMessage (handle, OS.LVM_ENSUREVISIBLE, index, 0);

@@ -2166,6 +2137,11 @@
 LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) {

 	LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam);

 	if (result != null) return result;

+	if (imageList != null && background == -1) {

+		imageList.setBackground (defaultBackground ());

+		int hImageList = imageList.getHandle ();

+		OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, hImageList);

+	}

 	if ((style & SWT.CHECK) != 0) setCheckboxImageList ();

 	return result;

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java
index 83a7cba..cebb9ef 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java
@@ -23,40 +23,12 @@
  * IMPORTANT: This class is <em>not</em> intended to be subclassed.

  * </p>

  */

+

 public class TableColumn extends Item {

 	Table parent;

 	boolean resizable;

 

-/**

- * Constructs a new instance of this class given its parent

- * (which must be a <code>Table</code>) and a style value

- * describing its behavior and appearance. The item is added

- * to the end of 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

- *

- * @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 TableColumn (Table parent, int style) {

 	super (parent, checkStyle (style));

 	resizable = true;

@@ -64,37 +36,6 @@
 	parent.createItem (this, parent.getColumnCount ());

 }

 

-/**

- * 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 TableColumn (Table parent, int style, int index) {

 	super (parent, checkStyle (style));

 	resizable = true;

@@ -265,7 +206,7 @@
 	int index = parent.indexOf (this);

 	if (index == -1) return;

 	int hwnd = parent.handle;

-	byte [] buffer = Converter.wcsToMbcs (parent.getCodePage (), text, true);

+	byte [] buffer = Converter.wcsToMbcs (0, text, true);

 	int headerWidth = OS.SendMessage (hwnd, OS.LVM_GETSTRINGWIDTH, 0, buffer);

 	OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, OS.LVSCW_AUTOSIZE);

 	int columnWidth = OS.SendMessage (hwnd, OS.LVM_GETCOLUMNWIDTH, index, 0);

@@ -402,7 +343,7 @@
 

 	/* Set the column title */

 	int hHeap = OS.GetProcessHeap ();

-	byte [] buffer = Converter.wcsToMbcs (parent.getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (0, string, true);

 	int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer.length);

 	OS.MoveMemory (pszText, buffer, buffer.length);

 	lvColumn.mask |= OS.LVCF_TEXT;

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java
index ac9507c..05f41b0 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java
@@ -27,73 +27,12 @@
 public class TableItem extends Item {

 	Table parent;

 	

-/**

- * Constructs a new instance of this class given its parent

- * (which must be a <code>Table</code>) and a style value

- * describing its behavior and appearance. The item is added

- * to the end of 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

- *

- * @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) {

 	super (parent, style);

 	this.parent = parent;

 	parent.createItem (this, parent.getItemCount ());

 }

 

-/**

- * 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;

@@ -328,7 +267,7 @@
 	OS.MoveMemory (buffer1, pszText, cchTextMax);

 	OS.HeapFree (hHeap, 0, pszText);

 	if (result == 0) error (SWT.ERROR_CANNOT_GET_TEXT);

-	char [] buffer2 = Converter.mbcsToWcs (parent.getCodePage (), buffer1);

+	char [] buffer2 = Converter.mbcsToWcs (0, buffer1);

 	int length = 0;

 	while (length < buffer2.length && buffer2 [length] != 0) length++;

 	return new String (buffer2, 0, length);

@@ -413,11 +352,10 @@
 /**

  * Sets the image for multiple columns in the Table. 

  * 

- * @param images the array of new images

+ * @param strings the array of new images

  *

  * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the array of images is null</li>

- *    <li>ERROR_INVALID_ARGUMENT - if one of the images has been disposed</li>

+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>

  * </ul>

  * @exception SWTException <ul>

  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>

@@ -436,10 +374,10 @@
  * Sets the receiver's image at a column.

  *

  * @param index the column index

- * @param image the new image

+ * @param string the new image

  *

  * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>

+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>

  * </ul>

  * @exception SWTException <ul>

  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>

@@ -448,9 +386,6 @@
  */

 public void setImage (int index, Image image) {

 	checkWidget();

-	if (image != null && image.isDisposed ()) {

-		error(SWT.ERROR_INVALID_ARGUMENT);

-	}

 	if (index == 0) {

 		setImage (image);

 		return;

@@ -468,9 +403,6 @@
 

 public void setImage (Image image) {

 	checkWidget();

-	if (image != null && image.isDisposed ()) {

-		error(SWT.ERROR_INVALID_ARGUMENT);

-	}

 	int index = parent.indexOf (this);

 	if (index == -1) return;

 	super.setImage (image);

@@ -555,7 +487,7 @@
 	if (itemIndex == -1) return;

 	int hwnd = parent.handle;

 	int hHeap = OS.GetProcessHeap ();	

-	byte [] buffer = Converter.wcsToMbcs (parent.getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (0, string, true);

 	int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer.length);

 	LVITEM lvItem = new LVITEM ();

 	lvItem.mask = OS.LVIF_TEXT;

@@ -578,7 +510,7 @@
 	lvItem.mask = OS.LVIF_TEXT;

 	lvItem.iItem = index;

 	int hHeap = OS.GetProcessHeap ();

-	byte [] buffer = Converter.wcsToMbcs (parent.getCodePage (), string, false);

+	byte [] buffer = Converter.wcsToMbcs (0, string, false);

 	int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer.length + 1);

 	OS.MoveMemory (pszText, buffer, buffer.length); 

 	lvItem.pszText = pszText;

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 a5bd479..bb0b6d9 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
@@ -24,6 +24,7 @@
  * </p>

  * IMPORTANT: This class is <em>not</em> intended to be subclassed.

  */

+

 public class Text extends Scrollable {

 	int tabs, oldStart, oldEnd;

 	boolean doubleClick, ignoreVerify, ignoreCharacter;

@@ -41,7 +42,7 @@
 	}

 	

 	static final int EditProc;

-	static final byte [] EditClass = Converter.wcsToMbcs (0, "EDIT\0");

+	static final byte [] EditClass = Converter.wcsToMbcs (0, "EDIT\0", false);

 	static {

 		WNDCLASSEX lpWndClass = new WNDCLASSEX ();

 		lpWndClass.cbSize = WNDCLASSEX.sizeof;

@@ -49,34 +50,6 @@
 		EditProc = lpWndClass.lpfnWndProc;

 	}

 

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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

- *

- * @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 Text (Composite parent, int style) {

 	super (parent, checkStyle (style));

 }

@@ -202,7 +175,7 @@
 		if (string == null) return;

 	}

 	OS.SendMessage (handle, OS.EM_SETSEL, length, length);

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (0, string, true);

 	OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);

 	OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0);

 }

@@ -244,7 +217,7 @@
 		rect.right = wHint;

 	}

 	String text = getText ();

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), text, false);

+	byte [] buffer = Converter.wcsToMbcs (0, text, false);

 	OS.DrawText (hDC, buffer, buffer.length, rect, flags);

 	width = rect.right - rect.left;

 	if ((style & SWT.WRAP) != 0 && hHint == SWT.DEFAULT) {

@@ -257,11 +230,6 @@
 	if (height == 0) height = DEFAULT_HEIGHT;

 	if (wHint != SWT.DEFAULT) width = wHint;

 	if (hHint != SWT.DEFAULT) height = hHint;

-

-	/* Calculate the margin width */

-	int margins = OS.SendMessage(handle, OS.EM_GETMARGINS, 0, 0);

-	int marginWidth = (margins & 0xFFFF) + ((margins >> 16) & 0xFFFF);

-	width += marginWidth;

 	

 	/*

 	* Bug in Windows.  For some reason, despite the fact

@@ -277,7 +245,7 @@
 	}

 

 	/*

-	* The preferred height of a single-line text widget

+	* The preferred size of a single-line text widget

 	* has been hand-crafted to be the same height as

 	* the single-line text widget in an editable combo

 	* box.

@@ -385,6 +353,7 @@
  */

 public Point getCaretLocation () {

 	checkWidget ();

+

 	/*

 	* Bug in Windows.  For some reason, Windows is unable

 	* to return the pixel coordinates of the last character

@@ -511,7 +480,7 @@
 public char getEchoChar () {

 	checkWidget ();

 	char echo = (char) OS.SendMessage (handle, OS.EM_GETPASSWORDCHAR, 0, 0);

-	if (echo != 0 && (echo = mbcsToWcs (echo, getCodePage ())) == 0) echo = '*';

+	if (echo != 0 && (echo = mbcsToWcs (echo)) == 0) echo = '*';

 	return echo;

 }

 

@@ -697,7 +666,7 @@
 	if (length == 0) return "";

 	byte [] buffer1 = new byte [length + 1];

 	OS.GetWindowText (handle, buffer1, buffer1.length);

-	char [] buffer2 = Converter.mbcsToWcs (getCodePage (), buffer1);

+	char [] buffer2 = Converter.mbcsToWcs (0, buffer1);

 	return new String (buffer2, 0, buffer2.length - 1);

 }

 

@@ -720,6 +689,7 @@
  */

 public String getText (int start, int end) {

 	checkWidget ();

+	

 	/*

 	* NOTE: The current implementation uses substring ()

 	* which can reference a potentially large character

@@ -790,6 +760,7 @@
  */

 public int getTopPixel () {

 	checkWidget ();

+	

 	/*

 	* Note, EM_GETSCROLLPOS is implemented in Rich Edit 3.0

 	* and greater.  The plain text widget and previous versions

@@ -834,7 +805,7 @@
 		string = verifyText (string, start [0], end [0]);

 		if (string == null) return;

 	}

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (0, string, true);

 	OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);

 }

 

@@ -1066,7 +1037,7 @@
 	if (newText == null) return false;

 	if (newText == oldText) return true;

 	newText = Display.withCrLf (newText);

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), newText, true);

+	byte [] buffer = Converter.wcsToMbcs (0, newText, true);

 	OS.SendMessage (handle, OS.EM_SETSEL, start [0], end [0]);

 	OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);

 	return false;

@@ -1109,9 +1080,7 @@
  */

 public void setEchoChar (char echo) {

 	checkWidget ();

-	if (echo != 0) {

-		if ((echo = wcsToMbcs (echo, getCodePage ())) == 0) echo = '*';

-	}

+	if (echo != 0 && (echo = wcsToMbcs (echo)) == 0) echo = '*';

 	OS.SendMessage (handle, OS.EM_SETPASSWORDCHAR, echo, 0);

 	/*

 	* Bug in Windows.  When the password character is changed,

@@ -1320,7 +1289,7 @@
 		string = verifyText (string, 0, length);

 		if (string == null) return;

 	}

-	byte [] buffer = Converter.wcsToMbcs (getCodePage (), string, true);

+	byte [] buffer = Converter.wcsToMbcs (0, string, true);

 	OS.SetWindowText (handle, buffer);

 	/*

 	* Bug in Windows.  When the widget is multi line

@@ -1535,7 +1504,7 @@
 	if (newText.length () != 0) {

 		result = new LRESULT (callWindowProc (OS.WM_CLEAR, 0, 0));	

 		newText = Display.withCrLf (newText);

-		byte [] buffer = Converter.wcsToMbcs (getCodePage (), newText, true);

+		byte [] buffer = Converter.wcsToMbcs (0, newText, true);

 		OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);

 	}

 	return result;

@@ -1555,7 +1524,7 @@
 	if (newText.length () != 0) {

 		result = new LRESULT (callWindowProc (OS.WM_CUT, 0, 0));	

 		newText = Display.withCrLf (newText);

-		byte [] buffer = Converter.wcsToMbcs (getCodePage (), newText, true);

+		byte [] buffer = Converter.wcsToMbcs (0, newText, true);

 		OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);

 	}

 	return result;

@@ -1639,7 +1608,7 @@
 	if (newText == null) return LRESULT.ZERO;

 	if (newText != oldText) {

 		newText = Display.withCrLf (newText);

-		byte [] buffer = Converter.wcsToMbcs (getCodePage (), newText, true);

+		byte [] buffer = Converter.wcsToMbcs (0, newText, true);

 		OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);

 		return LRESULT.ZERO;

 	}

@@ -1705,7 +1674,7 @@
 	if (newText == null) return LRESULT.ZERO;

 	if (newText != oldText) {

 		newText = Display.withCrLf (newText);

-		byte [] buffer = Converter.wcsToMbcs (getCodePage (), newText, true);

+		byte [] buffer = Converter.wcsToMbcs (0, newText, true);

 		OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);

 		return LRESULT.ZERO;

 	}

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
index f3fd4f1..8b5644c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
@@ -180,32 +180,6 @@
 	state &= ~CANVAS;

 

 	/*

-	* Feature in Windows.  Despite the fact that the

-	* tool tip text contains \r\n, the tooltip will

-	* not honour the new line unless TTM_SETMAXTIPWIDTH

-	* is set.  The fix is to set TTM_SETMAXTIPWIDTH to

-	* a large value.

-	*/

-	int hwndToolTip = OS.SendMessage (handle, OS.TB_GETTOOLTIPS, 0, 0);	

-	/*

-	* This line is intentionally commented.  The tool

-	* bar currently sets this value to 300 so it is

-	* not necessary to set TTM_SETMAXTIPWIDTH.

-	*/

-//	OS.SendMessage (hwndToolTip, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF);

-

-	/*

-	* Feature in Windows.  When the tool tip control is

-	* created, the parent of the tool tip is the shell.

-	* If SetParent () is used to reparent the tool bar

-	* into a new shell, the tool tip is not reparented

-	* and pops up underneath the new shell.  The fix is

-	* to make sure the tool tip is a topmost window.

-	*/

-	int flags = OS.SWP_NOACTIVATE | OS.SWP_NOMOVE | OS.SWP_NOSIZE;

-	OS.SetWindowPos (hwndToolTip, OS.HWND_TOPMOST, 0, 0, 0, 0, flags);

-

-	/*

 	* Feature in Windows.  When the control is created,

 	* it does not use the default system font.  A new HFONT

 	* is created and destroyed when the control is destroyed.

@@ -266,7 +240,6 @@
 	if ((style & SWT.VERTICAL) != 0) {

 		OS.SendMessage (handle, OS.TB_SETROWS, count+1, 0);

 	}

-	layoutItems ();

 }

 

 void createWidget () {

@@ -299,18 +272,17 @@
 	item.id = -1;

 	int count = OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);

 	if (count == 0) {

-		Display display = getDisplay ();

 		if (imageList != null) {

 			OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, 0);

-			display.releaseToolImageList (imageList);

+			imageList.dispose ();

 		}

 		if (hotImageList != null) {

 			OS.SendMessage (handle, OS.TB_SETHOTIMAGELIST, 0, 0);

-			display.releaseToolHotImageList (hotImageList);

+			hotImageList.dispose ();

 		}

 		if (disabledImageList != null) {

 			OS.SendMessage (handle, OS.TB_SETDISABLEDIMAGELIST, 0, 0);

-			display.releaseToolDisabledImageList (disabledImageList);

+			disabledImageList.dispose ();

 		}

 		imageList = hotImageList = disabledImageList = null;

 		items = new ToolItem [4];

@@ -318,7 +290,6 @@
 	if ((style & SWT.VERTICAL) != 0) {

 		OS.SendMessage (handle, OS.TB_SETROWS, count-1, 0);

 	}

-	layoutItems ();

 }

 

 ImageList getDisabledImageList () {

@@ -456,8 +427,7 @@
  * @return the index of the item

  *

  * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the tool item is null</li>

- *    <li>ERROR_INVALID_ARGUMENT - if the tool item has been disposed</li>

+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>

  * </ul>

  * @exception SWTException <ul>

  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>

@@ -467,47 +437,31 @@
 public int indexOf (ToolItem item) {

 	checkWidget ();

 	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);

-	if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 	return OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, item.id, 0);

 }

 

-void layoutItems () {

-	for (int i=0; i<items.length; i++) {

-		ToolItem item = items [i];

-		if (item != null) {

-			Control control = item.control;

-			if (control != null && !control.isDisposed ()) {

-				Rectangle rect = item.getBounds ();

-				control.setLocation (rect.x, rect.y);

-			}

-		}

-	}

-}

-

 void releaseWidget () {

 	for (int i=0; i<items.length; i++) {

 		ToolItem item = items [i];

 		if (item != null && !item.isDisposed ()) {

-			item.releaseImages ();

 			item.releaseWidget ();

 		}

 	}

 	items = null;

-	Display display = getDisplay ();

+	super.releaseWidget ();

 	if (imageList != null) {

 		OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, 0);

-		display.releaseToolImageList (imageList);

+		imageList.dispose ();

 	}

 	if (hotImageList != null) {

 		OS.SendMessage (handle, OS.TB_SETHOTIMAGELIST, 0, 0);

-		display.releaseToolHotImageList (hotImageList);

+		hotImageList.dispose ();

 	}

 	if (disabledImageList != null) {

 		OS.SendMessage (handle, OS.TB_SETDISABLEDIMAGELIST, 0, 0);

-		display.releaseToolDisabledImageList (disabledImageList);

+		disabledImageList.dispose ();

 	}

 	imageList = hotImageList = disabledImageList = null;

-	super.releaseWidget ();

 }

 

 void setDefaultFont () {

@@ -521,6 +475,7 @@
 	int hImageList = 0;

 	if ((disabledImageList = imageList) != null) {

 		hImageList = disabledImageList.getHandle ();

+		disabledImageList.setBackground (getBackgroundPixel ());

 	}

 	OS.SendMessage (handle, OS.TB_SETDISABLEDIMAGELIST, 0, hImageList);

 }

@@ -535,6 +490,7 @@
 	int hImageList = 0;

 	if ((hotImageList = imageList) != null) {

 		hImageList = hotImageList.getHandle ();

+		hotImageList.setBackground (getBackgroundPixel ());

 	}

 	OS.SendMessage (handle, OS.TB_SETHOTIMAGELIST, 0, hImageList);

 }

@@ -544,6 +500,7 @@
 	int hImageList = 0;

 	if ((this.imageList = imageList) != null) {

 		hImageList = imageList.getHandle ();

+		imageList.setBackground (getBackgroundPixel ());

 	}

 	OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, hImageList);

 }

@@ -628,7 +585,6 @@
 				if (item != null) string = item.toolTipText;

 			}

 			if (string != null && string.length () != 0) {

-				string = Display.withCrLf (string);

 				int length = string.length ();

 				char [] buffer = new char [length + 1];

 				string.getChars (0, length, buffer, 0);

@@ -651,7 +607,37 @@
 	* WM_SIZE message.

 	*/

 	if (isDisposed ()) return result;

-	layoutItems ();

+	for (int i=0; i<items.length; i++) {

+		ToolItem item = items [i];

+		if (item != null) {

+			Control control = item.control;

+			if (control != null && !control.isDisposed ()) {

+				Rectangle rect = item.getBounds ();

+				control.setLocation (rect.x, rect.y);

+			}

+		}

+	}

+	return result;

+}

+

+LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) {

+	LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam);

+	if (result != null) return result;

+	if (imageList != null && background == -1) {

+		imageList.setBackground (defaultBackground ());

+		int hImageList = imageList.getHandle ();

+		OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, hImageList);

+	}

+	if (hotImageList != null && background == -1) {

+		hotImageList.setBackground (defaultBackground ());

+		int hImageList = hotImageList.getHandle ();

+		OS.SendMessage (handle, OS.TB_SETHOTIMAGELIST, 0, hImageList);

+	}

+	if (disabledImageList != null && background == -1) {

+		disabledImageList.setBackground (defaultBackground ());

+		int hImageList = disabledImageList.getHandle ();

+		OS.SendMessage (handle, OS.TB_SETDISABLEDIMAGELIST, 0, hImageList);

+	}

 	return result;

 }

 

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java
index 091705b..148304d 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java
@@ -32,73 +32,12 @@
 	Image disabledImage2;

 	int id;

 

-/**

- * Constructs a new instance of this class given its parent

- * (which must be a <code>ToolBar</code>) and a style value

- * describing its behavior and appearance. The item is added

- * to the end of 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

- *

- * @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 ToolItem (ToolBar parent, int style) {

 	super (parent, checkStyle (style));

 	this.parent = parent;

 	parent.createItem (this, parent.getItemCount ());

 }

 

-/**

- * Constructs a new instance of this class given its parent

- * (which must be a <code>ToolBar</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 ToolItem (ToolBar parent, int style, int index) {

 	super (parent, checkStyle (style));

 	this.parent = parent;

@@ -377,32 +316,6 @@
 	disabledImage2 = null;

 }

 

-void releaseImages () {

-	TBBUTTONINFO info = new TBBUTTONINFO ();

-	info.cbSize = TBBUTTONINFO.sizeof;

-	info.dwMask = OS.TBIF_IMAGE | OS.TBIF_STYLE;

-	int hwnd = parent.handle;

-	int index = OS.SendMessage (hwnd, OS.TB_GETBUTTONINFO, id, info);

-	/*

-	* Feature in Windows.  For some reason, a tool item that has

-	* the style BTNS_SEP does not return I_IMAGENONE when queried

-	* for an image index, despite the fact that no attempt has been

-	* made to assign an image to the item.  As a result, operations

-	* on an image list that use the wrong index cause random results.	

-	* The fix is to ensure that the tool item is not a separator

-	* before using the image index.  Since separators cannot have

-	* an image and one is never assigned, this is not a problem.

-	*/

-	if ((info.fsStyle & OS.BTNS_SEP) == 0 && info.iImage != OS.I_IMAGENONE) {

-		ImageList imageList = parent.getImageList ();

-		ImageList hotImageList = parent.getHotImageList ();

-		ImageList disabledImageList = parent.getDisabledImageList();

-		if (imageList != null) imageList.put (info.iImage, null);

-		if (hotImageList != null) hotImageList.put (info.iImage, null);

-		if (disabledImageList != null) disabledImageList.put (info.iImage, null);

-	}

-}

-

 /**

  * Removes the listener from the collection of listeners who will

  * be notified when the control is selected.

@@ -434,9 +347,6 @@
  *

  * @param control the new control

  *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the control 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>

@@ -444,9 +354,8 @@
  */

 public void setControl (Control control) {

 	checkWidget();

-	if (control != null) {

-		if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);

-		if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);

+	if (control != null && control.parent != parent) {

+		error (SWT.ERROR_INVALID_PARENT);

 	}

 	if ((style & SWT.SEPARATOR) == 0) return;

 	this.control = control;

@@ -488,11 +397,8 @@
  * The disbled image is displayed when the receiver is disabled.

  * </p>

  *

- * @param image the disabled image to display on the receiver (may be null)

+ * @param image the hot image to display on the receiver (may be null)

  *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the image 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>

@@ -501,7 +407,6 @@
 public void setDisabledImage (Image image) {

 	checkWidget();

 	if ((style & SWT.SEPARATOR) != 0) return;

-	if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 	disabledImage = image;

 	updateImages ();

 }

@@ -515,9 +420,6 @@
  *

  * @param image the hot image to display on the receiver (may be null)

  *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the image 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>

@@ -526,7 +428,6 @@
 public void setHotImage (Image image) {

 	checkWidget();

 	if ((style & SWT.SEPARATOR) != 0) return;

-	if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 	hotImage = image;

 	updateImages ();

 }

@@ -534,7 +435,6 @@
 public void setImage (Image image) {

 	checkWidget();

 	if ((style & SWT.SEPARATOR) != 0) return;

-	if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 	super.setImage (image);

 	updateImages ();

 }

@@ -571,7 +471,7 @@
 	super.setText (string);

 	int hwnd = parent.handle;

 	int hHeap = OS.GetProcessHeap ();

-	byte [] buffer = Converter.wcsToMbcs (parent.getCodePage (), string, false);

+	byte [] buffer = Converter.wcsToMbcs (0, string, false);

 	int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer.length + 1);

 	OS.MoveMemory (pszText, buffer, buffer.length); 

 	TBBUTTONINFO info = new TBBUTTONINFO ();

@@ -592,8 +492,6 @@
 	*/

 	int hFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);

 	OS.SendMessage (hwnd, OS.WM_SETFONT, hFont, 0);

-	

-	parent.layoutItems ();

 }

 

 /**

@@ -635,7 +533,6 @@
 	if (control != null && !control.isDisposed ()) {

 		control.setBounds (getBounds ());

 	}

-	parent.layoutItems ();

 }

 

 void updateImages () {

@@ -649,13 +546,10 @@
 	ImageList hotImageList = parent.getHotImageList ();

 	ImageList disabledImageList = parent.getDisabledImageList();

 	if (info.iImage == OS.I_IMAGENONE) {

-		Display display = getDisplay ();

-		Rectangle bounds = image.getBounds ();

-		Point size = new Point (bounds.width, bounds.height);

-		if (imageList == null) imageList = display.getToolImageList (size);

+		if (imageList == null) imageList = new ImageList ();

 		info.iImage = imageList.add (image);

 		parent.setImageList (imageList);

-		if (disabledImageList == null) disabledImageList = display.getToolDisabledImageList (size);

+		if (disabledImageList == null) disabledImageList = new ImageList ();

 		Image disabled = disabledImage;

 		if (disabledImage == null) {

 			disabled = image;

@@ -667,7 +561,7 @@
 		disabledImageList.add (disabled);

 		parent.setDisabledImageList (disabledImageList);

 		if ((parent.style & SWT.FLAT) != 0) {

-			if (hotImageList == null) hotImageList = display.getToolHotImageList (size);

+			if (hotImageList == null) hotImageList = new ImageList ();

 			hotImageList.add (hotImage != null ? hotImage : image);

 			parent.setHotImageList (hotImageList);

 		}

@@ -697,8 +591,6 @@
 		if (image == null) info.iImage = OS.I_IMAGENONE;

 	}

 	OS.SendMessage (hwnd, OS.TB_SETBUTTONINFO, id, info);

-	

-	parent.layoutItems ();

 }

 

 int widgetStyle () {

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java
index 7719da0..9f38cd1 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java
@@ -30,69 +30,12 @@
 	boolean tracking, stippled;

 	Rectangle [] rectangles = new Rectangle [0];

 

-/**

- * Constructs a new instance of this class given its parent

- * and a style value describing its behavior and appearance.

- * <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 widget which will be the parent of the new instance (cannot be null)

- * @param style the style of widget to construct

- *

- * @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 Tracker (Composite parent, int style) {

 	super (parent, style);

 	this.parent = parent;

 	display = parent.getDisplay ();

 }

 

-/**

- * Constructs a new instance of this class given the display

- * to create it on and a style value describing its behavior

- * and appearance.

- * <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><p>

- * Note: Currently, null can be passed in for the display argument.

- * This has the effect of creating the tracker on the currently active

- * display if there is one. If there is no current display, the 

- * tracker is created on a "default" display. <b>Passing in null as

- * the display argument is not considered to be good coding style,

- * and may not be supported in a future release of SWT.</b>

- * </p>

- *

- * @param display the display to create the tracker on

- * @param style the style of control to construct

- *

- * @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>

- */

 public Tracker (Display display, int style) {

 	if (display == null) display = Display.getCurrent ();

 	if (display == null) display = Display.getDefault ();

@@ -253,8 +196,6 @@
 					* event.  If this happens, return false to indicate

 					* that the tracking has failed.

 					*/

-					event.x = newX;

-					event.y = newY;

 					sendEvent (SWT.Move, event);

 					if (isDisposed ()) return false;

 					drawRectangles ();

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 f91dff2..bc471fc 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
@@ -240,7 +240,6 @@
 	if (hItem == 0) error (SWT.ERROR_ITEM_NOT_ADDED);

 	item.handle = hItem;

 	items [id] = item;

-	

 	/*

 	* This code is intentionally commented.

 	*/

@@ -251,7 +250,7 @@
 //	}

 

 	/*

-	* Bug in Windows.  When a child item is added to a parent item

+	* Bug in Windows.  When a child item ss added to a parent item

 	* that has no children outside of WM_NOTIFY with control code

 	* TVN_ITEMEXPANDED, the tree widget does not redraw the +/-

 	* indicator.  The fix is to detect this case and force a redraw.

@@ -338,8 +337,7 @@
 	if (count == 0) {

 		if (imageList != null) {

 			OS.SendMessage (handle, OS.TVM_SETIMAGELIST, 0, 0);

-			Display display = getDisplay ();

-			display.releaseImageList (imageList);

+			imageList.dispose ();

 		}

 		imageList = null;

 		items = new TreeItem [4];	

@@ -588,13 +586,12 @@
 	if (imageList == null) {

 		int hOldList = OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0);

 		if (hOldList != 0) OS.ImageList_Destroy (hOldList);

-		Rectangle bounds = image.getBounds ();

-		imageList = getDisplay ().getImageList (new Point (bounds.width, bounds.height));

-		int index = imageList.indexOf (image);

-		if (index == -1) index = imageList.add (image);

+		imageList = new ImageList ();

+		imageList.setBackground (getBackgroundPixel ());

+		imageList.add (image);

 		int hImageList = imageList.getHandle ();

 		OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, hImageList);

-		return index;

+		return 0;

 	}

 	int index = imageList.indexOf (image);

 	if (index != -1) return index;

@@ -629,10 +626,10 @@
 		}

 	}

 	items = null;

+	super.releaseWidget ();

 	if (imageList != null) {

 		OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, 0);

-		Display display = getDisplay ();

-		display.releaseImageList (imageList);

+		imageList.dispose ();

 	} else {

 		int hOldList = OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0);

 		OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, 0);

@@ -642,7 +639,6 @@
 	int hOldList = OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_STATE, 0);

 	OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_STATE, 0);

 	if (hOldList != 0) OS.ImageList_Destroy (hOldList);

-	super.releaseWidget ();

 }

 

 

@@ -669,8 +665,7 @@
 	}

 	if (imageList != null) {

 		OS.SendMessage (handle, OS.TVM_SETIMAGELIST, 0, 0);

-		Display display = getDisplay ();

-		display.releaseImageList (imageList);

+		imageList.dispose ();

 	}

 	imageList = null;

 	items = new TreeItem [4];

@@ -735,9 +730,6 @@
  * @param after true places the insert mark above 'item'. false places 

  *	the insert mark below 'item'.

  *

- * @exception IllegalArgumentException <ul>

- *    <li>ERROR_INVALID_ARGUMENT - if the item 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>

@@ -746,10 +738,7 @@
 public void setInsertMark (TreeItem item, boolean before) {

 	checkWidget ();

 	int hItem = 0;

-	if (item != null) {

-		if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

-		hItem = item.handle;

-	}

+	if (item != null) hItem = item.handle;

 	OS.SendMessage (handle, OS.TVM_SETINSERTMARK, (before) ? 0 : 1, hItem);

 }

 

@@ -804,6 +793,12 @@
 	int oldPixel = OS.SendMessage (handle, OS.TVM_GETBKCOLOR, 0, 0);

 	if (oldPixel != -1) OS.SendMessage (handle, OS.TVM_SETBKCOLOR, 0, -1);

 	OS.SendMessage (handle, OS.TVM_SETBKCOLOR, 0, pixel);

+	if (pixel == -1) pixel = getBackgroundPixel ();

+	if (imageList != null) {

+		imageList.setBackground (pixel);

+		int hImageList = imageList.getHandle ();

+		OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, hImageList);

+	}

 	if ((style & SWT.CHECK) != 0) setCheckboxImageList ();

 }

 

@@ -852,35 +847,6 @@
 	OS.SendMessage (handle, OS.TVM_SETTEXTCOLOR, 0, pixel);

 }

 

-public void setRedraw (boolean redraw) {

-	checkWidget ();

-	/*

-	* Bug in Windows.  For some reason, when WM_SETREDRAW

-	* is used to turn redraw on for a tree and the tree

-	* contains no items, the last item in the tree does

-	* not redraw properly.  If the tree has only one item,

-	* that item is not drawn.  If another window is dragged

-	* on top of the item, parts of the item are redrawn

-	* and erased at random.  The fix is to ensure that this

-	* case doesn't happen by inserting and deleting an item

-	* when redraw is turned on and there are no items in

-	* the tree.

-	*/

-	int hItem = 0;

-	if (redraw) {

-		int count = OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0);

-		if (count == 0) {

-			TVINSERTSTRUCT tvInsert = new TVINSERTSTRUCT ();

-			tvInsert.hInsertAfter = OS.TVI_FIRST;

-			hItem = OS.SendMessage (handle, OS.TVM_INSERTITEM, 0, tvInsert);

-		}

-	}

-	super.setRedraw (redraw);

-	if (hItem != 0) {

-		OS.SendMessage (handle, OS.TVM_DELETEITEM, 0, hItem);

-	}

-}

-

 /**

  * Sets the receiver's selection to be the given array of items.

  * The current selected is first cleared, then the new items are

@@ -889,8 +855,7 @@
  * @param items the array of items

  *

  * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the array of items is null</li>

- *    <li>ERROR_INVALID_ARGUMENT - if one of the item has been disposed</li>

+ *    <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>

@@ -916,10 +881,7 @@
 	} else {

 		int hNewItem = 0;

 		TreeItem item = items [0];

-		if (item != null) {

-			if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

-			hNewItem = item.handle;

-		}

+		if (item != null) hNewItem = item.handle;

 		ignoreSelect = true;

 		OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_CARET, hNewItem);

 		ignoreSelect = false;

@@ -950,7 +912,6 @@
 	for (int i=0; i<this.items.length; i++) {

 		TreeItem item = this.items [i];

 		if (item != null) {

-			if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 			int index = 0;

 			while (index < items.length) {

 				if (items [index] == item) break;

@@ -982,8 +943,7 @@
  * @param item the item to be shown

  *

  * @exception IllegalArgumentException <ul>

- *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>

- *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>

+ *    <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>

@@ -995,7 +955,6 @@
 public void showItem (TreeItem item) {

 	checkWidget ();

 	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);

-	if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);

 	OS.SendMessage (handle, OS.TVM_ENSUREVISIBLE, 0, item.handle);

 }

 

@@ -1371,6 +1330,11 @@
 LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) {

 	LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam);

 	if (result != null) return result;

+	if (imageList != null && background == -1) {

+		imageList.setBackground (defaultBackground ());

+		int hImageList = imageList.getHandle ();

+		OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, hImageList);

+	}

 	if ((style & SWT.CHECK) != 0) setCheckboxImageList ();

 	return result;

 }

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java
index 521a2a2..2933fe5 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java
@@ -29,82 +29,21 @@
 	public int handle;

 	Tree parent;

 	

-/**

- * Constructs a new instance of this class given its parent

- * (which must be a <code>Tree</code> or a <code>TreeItem</code>)

- * and a style value describing its behavior and appearance.

- * The item is added to the end of 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

- *

- * @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 TreeItem (Tree parent, int style) {

 	super (parent, style);

 	this.parent = parent;

 	parent.createItem (this, 0, OS.TVI_LAST);

 }

 

-/**

- * Constructs a new instance of this class given its parent

- * (which must be a <code>Tree</code> or a <code>TreeItem</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 TreeItem (Tree parent, int style, int index) {

+public TreeItem (Tree parent, int style, int position) {

 	super (parent, style);

-	if (index < 0) error (SWT.ERROR_INVALID_RANGE);

+	if (position < 0) error (SWT.ERROR_INVALID_RANGE);

 	this.parent = parent;

 	int hItem = OS.TVI_FIRST;

-	if (index != 0) {

+	if (position != 0) {

 		int count = 1, hwnd = parent.handle;

 		hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);

-		while (hItem != 0 && count < index) {

+		while (hItem != 0 && count < position) {

 			hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hItem);

 			count++;

 		}

@@ -113,36 +52,6 @@
 	parent.createItem (this, 0, hItem);

 }

 

-/**

- * Constructs a new instance of this class given its parent

- * (which must be a <code>Tree</code> or a <code>TreeItem</code>)

- * and a style value describing its behavior and appearance.

- * The item is added to the end of 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 parentItem a composite control which will be the parent of the new instance (cannot be null)

- * @param style the style of control to construct

- *

- * @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 TreeItem (TreeItem parentItem, int style) {

 	super (checkNull (parentItem).parent, style);

 	parent = parentItem.parent;

@@ -150,47 +59,16 @@
 	parent.createItem (this, hItem, OS.TVI_LAST);

 }

 

-/**

- * Constructs a new instance of this class given its parent

- * (which must be a <code>Tree</code> or a <code>TreeItem</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 parentItem 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 TreeItem (TreeItem parentItem, int style, int index) {

+public TreeItem (TreeItem parentItem, int style, int position) {

 	super (checkNull (parentItem).parent, style);

-	if (index < 0) error (SWT.ERROR_INVALID_RANGE);

+	if (position < 0) error (SWT.ERROR_INVALID_RANGE);

 	parent = parentItem.parent;

 	int hItem = OS.TVI_FIRST;

 	int hParent = parentItem.handle;

-	if (index != 0) {

+	if (position != 0) {

 		int count = 1, hwnd = parent.handle;

 		hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hParent);

-		while (hItem != 0 && count < index) {

+		while (hItem != 0 && count < position) {

 			hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hItem);

 			count++;

 		}

@@ -553,7 +431,7 @@
 	super.setText (string);

 	int hwnd = parent.handle;

 	int hHeap = OS.GetProcessHeap ();

-	byte [] buffer = Converter.wcsToMbcs (parent.getCodePage (), string, false);

+	byte [] buffer = Converter.wcsToMbcs (0, string, false);

 	int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer.length + 1);

 	OS.MoveMemory (pszText, buffer, buffer.length); 

 	TVITEM tvItem = new TVITEM ();

diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
index 8fbaf37..a6874b5 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
@@ -240,7 +240,6 @@
  *

  * @exception IllegalArgumentException <ul>

  *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>

- *    <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li>

  * </ul>

  * @exception SWTException <ul>

  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>

@@ -249,7 +248,6 @@
 void checkParent (Widget parent) {

 	if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);

 	if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

-	if (parent.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);

 }

 

 /**

@@ -309,7 +307,7 @@
  */

 protected void checkWidget () {

 	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

-	if (isDisposed ()) error (SWT.ERROR_WIDGET_DISPOSED);

+	if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);

 }

 

 /**

@@ -361,7 +359,7 @@
 	* Note:  It is valid to attempt to dispose a widget

 	* more than once.  If this happens, fail silently.

 	*/

-	if (isDisposed ()) return;

+	if (!isValidWidget ()) return;

 	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);

 	releaseChild ();

 	releaseWidget ();

@@ -583,28 +581,30 @@
 	return getDisplay ().isValidThread ();

 }

 

+/**

+ * Returns <code>true</code> if the widget is not disposed,

+ * and <code>false</code> otherwise.

+ * <p>

+ * Note: This method is no longer required and will be deprecated.

+ * </p>

+ *

+ * @return <code>true</code> when the widget is not disposed and <code>false</code> otherwise

+ *

+ * @see #isDisposed

+ */

+boolean isValidWidget () {

+	return (state & DISPOSED) == 0;

+}

+

 /*

- * Returns a single character, converted from the default

- * multi-byte character set (MBCS) used by the operating

- * system widgets to a wide character set (WCS) used by Java.

+ * Returns a single character, converted from the multi-byte

+ * character set (MBCS) used by the operating system widgets

+ * to a wide character set (WCS) used by Java.

  *

  * @param ch the MBCS character

  * @return the WCS character

  */

 char mbcsToWcs (char ch) {

-	return mbcsToWcs (ch, 0);

-}

-

-/*

- * Returns a single character, converted from the specified

- * multi-byte character set (MBCS) used by the operating

- * system widgets to a wide character set (WCS) used by Java.

- *

- * @param ch the MBCS character

- * @param codePage the code page used to convert the character

- * @return the WCS character

- */

-char mbcsToWcs (char ch, int codePage) {

 	int key = ch & 0xFFFF;

 	if (key <= 0x7F) return ch;

 	byte [] buffer;

@@ -616,7 +616,7 @@
 		buffer [0] = (byte) ((key >> 8) & 0xFF);

 		buffer [1] = (byte) (key & 0xFF);

 	}

-	char [] result = Converter.mbcsToWcs (codePage, buffer);

+	char [] result = Converter.mbcsToWcs (0, buffer);

 	if (result.length == 0) return 0;

 	return result [0];

 }

@@ -954,31 +954,16 @@
 }

 /*

  * Returns a single character, converted from the wide

- * character set (WCS) used by Java to the default

- * multi-byte character set used by the operating system

- * widgets.

+ * character set (WCS) used by Java to the multi-byte

+ * character set used by the operating system widgets.

  *

  * @param ch the WCS character

  * @return the MBCS character

  */

 char wcsToMbcs (char ch) {

-	return wcsToMbcs (ch, 0);

-}

-

-/*

- * Returns a single character, converted from the wide

- * character set (WCS) used by Java to the specified

- * multi-byte character set used by the operating system

- * widgets.

- *

- * @param ch the WCS character

- * @param codePage the code page used to convert the character

- * @return the MBCS character

- */

-char wcsToMbcs (char ch, int codePage) {

 	int key = ch & 0xFFFF;

 	if (key <= 0x7F) return ch;

-	byte [] buffer = Converter.wcsToMbcs (codePage, new char [] {ch}, false);

+	byte [] buffer = Converter.wcsToMbcs (0, new char [] {ch}, false);

 	if (buffer.length == 1) return (char) buffer [0];

 	if (buffer.length == 2) {

 		return (char) (((buffer [0] & 0xFF) << 8) | (buffer [1] & 0xFF));

diff --git a/bundles/org.eclipse.swt/build.properties.motif b/bundles/org.eclipse.swt/build.properties.motif
index b5db17f..9096484 100755
--- a/bundles/org.eclipse.swt/build.properties.motif
+++ b/bundles/org.eclipse.swt/build.properties.motif
@@ -1,4 +1,4 @@
-build.vaj.Eclipse\ SWT=Eclipse SWT/common,Eclipse SWT/emulated,Eclipse SWT/motif

+build.vaj.Eclipse\ SWT=Eclipse SWT/common,Eclipse SWT/motif

 build.vaj.Eclipse\ SWT\ Drag\ and\ Drop=Eclipse SWT Drag and Drop/common,Eclipse SWT Drag and Drop/motif

 build.vaj.Eclipse\ SWT\ Printing=Eclipse SWT Printing/common,Eclipse SWT Printing/motif

 build.vaj.Eclipse\ SWT\ Program=Eclipse SWT Program/common,Eclipse SWT Program/motif

diff --git a/bundles/org.eclipse.swt/build.properties.photon b/bundles/org.eclipse.swt/build.properties.photon
index 339b680..072feb6 100755
--- a/bundles/org.eclipse.swt/build.properties.photon
+++ b/bundles/org.eclipse.swt/build.properties.photon
@@ -1,4 +1,4 @@
-build.vaj.Eclipse\ SWT=Eclipse SWT/common,Eclipse SWT/emulated,Eclipse SWT/photon

+build.vaj.Eclipse\ SWT=Eclipse SWT/common,Eclipse SWT/photon

 build.vaj.Eclipse\ SWT\ Drag\ and\ Drop=Eclipse SWT Drag and Drop/common,Eclipse SWT Drag and Drop/photon

 build.vaj.Eclipse\ SWT\ Printing=Eclipse SWT Printing/common,Eclipse SWT Printing/photon

 build.vaj.Eclipse\ SWT\ Program=Eclipse SWT Program/common,Eclipse SWT Program/photon

diff --git a/bundles/org.eclipse.swt/buildnotes_swt.html b/bundles/org.eclipse.swt/buildnotes_swt.html
index 6ebe43b..7069179 100755
--- a/bundles/org.eclipse.swt/buildnotes_swt.html
+++ b/bundles/org.eclipse.swt/buildnotes_swt.html
@@ -11,65 +11,6 @@
 <h1>

 Eclipse Platform Build Notes<br>

 SWT</h1>

-SWT Build 2.0 002 - Wednesday July 18, 2001

-

-<h2>

-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>

-

-<blockquote>

-1GGZ13T: SWT:Neutrino - invalid mouse state occuring in Photon

-<br>1GGRCCS: SWT:Neutrino - Label does not wrap in SWT0125

-<br>1GGAON2: SWT:ALL - Scaling image with alphas does not work correctly

-<br>1GFZQVQ: SWT:Linux - Vertical ProgressBar grows incorrectly

-<br>1GFQA18: SWT:Linux - Cheese with GC drawRoundedRectangle() on Motif

-<br>1GFPK6G: SWT:Linux - Motif fillPolygon() specifies improper hint

-</blockquote>

-

-<h1>

-Eclipse Platform Build Notes<br>

-SWT</h1>

-SWT Build 2.0 001 - Thursday July 12, 2001

-

-<h2>

-<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>

-

-<blockquote>

-1GGET76: SWT:Neutrino - Canvas does not respond to setFocus()

-<br>1GGAS5P: SWT:Neutrino - Photon on QNX 6.1.x needs SWT native changes

-<br>1GG96RO: SWT:Neutrino - drawOval and fillOval not compatible

-<br>1GG8ZLV: SWT:WINNT - drawOval behaves differently on Windows vs. other platforms

-<br>1GFKYD9: SWT:Linux - -HANG- (Xserver) When perfoming display.wake() in a DND dragStart()

-<br>1GFKK37: SWT:Linux - FileViewer examples issues

-<br>1GFBHX6: SWT:ALL - CTabItem tool tip flashing

-<br>1GF9ZMT: SWT:SPARC - 8-bit Icons are losing colors

-<br>1GF9ZJG: SWT:SPARC - Icons are being masked incorrectly on Solaris

-<br>1GF9YHD: ITPUI:WIN2000 - SWTException: help view

-<br>1GF9Y32: SWT:SPARC - 24-bit MSB Icons are wrong color (greenish)

-<br>1GF0D05: SWT:Linux - GPFs when running JUnit TestRunner in J9 AWT

-<br>1GEUZZC: SWT:ALL - "Name" of plugin inconsistant with other plugins

-<br>1GETDP5: ITPUI:Linux - NPE while closing editor on linux

-<br>1GDVRT5: SWT:Neutrino - Alpha channel memory leak

-<br>1GDRXZR: ITPJUI:Linux - SWT: Context-Menus issue under Linux 

-<br>1GD0OSK: SWT:ALL - API - package javadoc for SWT packages missing

-<br>1GCHS75: SWT:WINNT - workbench exits during expand collapse

-<br>1GCFUS0: SWT:ALL - CTabFolder "floating" X sticks sometimes

-<br>1GAR95O: SWT:ALL - Remove Smalltalk comments from SWT code

-<br>1GAQRND: SWT:ALL - DOC: Write good Javadoc comments for all of SWT

-<br>1G97I28: SWT:Linux - Tool bar buttons do not always work

-<br>1G84AZB: ITPDUI:ALL - Rename truncates name

-<br>1G845EZ: SWT:WIN2000 - Spec for Layout.computeSize() is truncated

-<br>1G7YXLB: SWT:WIN - StyledText - NLS Support

-<br>1G7NSHR: SWT:ALL - Widget.addListener(int, Listener) vs. adding typed listeners

-<br>1G4XDJO: SWT:Linux - Tree needs to display an insert marker

-<br>1G0Y8NZ: SWT:ALL - Combo box doesn't send key and mouse events 

-<br>1FXAVLF: SWT:WINNT - Disabled toolbar icons don't adapt to appearance changes

-<br>1FV1S18: SWT:ALL - Need more WM_* messages passed to ActiveX Control

-<br>1FTWX55: SWT:ALL - Inconsistant commenting of which SWT objects need to be disposed.

-</blockquote>

-

-<h1>

-Eclipse Platform Build Notes<br>

-SWT</h1>

 SWT Build 125 - Friday June 15, 2001

 

 <h2>

diff --git a/bundles/org.eclipse.swt/ws/motif/libswt-gnome0125.so b/bundles/org.eclipse.swt/ws/motif/libswt-gnome0125.so
new file mode 100755
index 0000000..3c3ba7e
--- /dev/null
+++ b/bundles/org.eclipse.swt/ws/motif/libswt-gnome0125.so
Binary files differ
diff --git a/bundles/org.eclipse.swt/ws/motif/libswt0125.so b/bundles/org.eclipse.swt/ws/motif/libswt0125.so
new file mode 100755
index 0000000..c0972e7
--- /dev/null
+++ b/bundles/org.eclipse.swt/ws/motif/libswt0125.so
Binary files differ
diff --git a/bundles/org.eclipse.swt/ws/photon/libswt0125.so b/bundles/org.eclipse.swt/ws/photon/libswt0125.so
new file mode 100755
index 0000000..81ca20b
--- /dev/null
+++ b/bundles/org.eclipse.swt/ws/photon/libswt0125.so
Binary files differ
diff --git a/bundles/org.eclipse.swt/ws/win32/swt0125.dll b/bundles/org.eclipse.swt/ws/win32/swt0125.dll
new file mode 100755
index 0000000..90aab8f
--- /dev/null
+++ b/bundles/org.eclipse.swt/ws/win32/swt0125.dll
Binary files differ