summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse
diff options
context:
space:
mode:
authorVeronika Irvine <torres>2001-06-21 15:16:50 +0000
committerVeronika Irvine <torres>2001-06-21 15:16:50 +0000
commit6c0e3d76ce668620fd159ac504e2b5d9a48852be (patch)
tree28ec743469ad12010dec20832bd1d5c1a3d72d8a /bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse
parent3fb799dcaa7d449679ed92f9829fbed85aa6fd1d (diff)
downloadeclipse.platform.swt-6c0e3d76ce668620fd159ac504e2b5d9a48852be.tar.gz
eclipse.platform.swt-6c0e3d76ce668620fd159ac504e2b5d9a48852be.tar.xz
eclipse.platform.swt-6c0e3d76ce668620fd159ac504e2b5d9a48852be.zip
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Color.java11
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java110
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java55
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/DeviceData.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java7
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java239
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GCData.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java21
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Region.java27
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/Converter.java4
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontDetails.java4
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontQueryInfo.java4
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/OS.java108
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgAlpha_t.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgMap_t.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhArea_t.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhCursorDef_t.java36
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhCursorInfo_t.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhDim_t.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhEvent_t.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhImage_t.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPoint_t.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPointerEvent_t.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRect_t.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRegion_t.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhTile_t.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhWindowEvent_t.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtCallbackInfo_t.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtColorSelectInfo_t.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtContainerCallback_t.java22
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtFileSelectionInfo_t.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtScrollbarCallback_t.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTextCallback_t.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTreeItem_t.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/AbstractTreeItem.java23
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java59
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java41
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java53
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java145
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java533
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java30
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/DirectoryDialog.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java252
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java7
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Header.java10
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java189
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java81
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java58
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java216
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java4
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java7
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java26
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java5
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java26
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java14
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItem.java24
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItemWidget.java48
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java268
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java7
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabItem.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Table.java872
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableColumn.java328
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableItem.java288
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java124
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java24
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java155
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java155
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tree.java420
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeItem.java272
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeRoots.java19
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java122
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/WidgetTable.java6
80 files changed, 4116 insertions, 1647 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Color.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Color.java
index f737dbd2df..9d8ad52bda 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Color.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Color.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.graphics;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.*;
@@ -54,18 +54,22 @@ public boolean equals (Object object) {
}
public int getBlue () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return handle & 0xFF;
}
public int getGreen () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return (handle & 0xFF00) >> 8;
}
public int getRed () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return (handle & 0xFF0000) >> 16;
}
public RGB getRGB () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return new RGB((handle & 0xFF0000) >> 16, (handle & 0xFF00) >> 8, handle & 0xFF);
}
@@ -86,6 +90,7 @@ public boolean isDisposed() {
}
public String toString () {
+ if (isDisposed()) return "Color {*DISPOSED*}";
return "Color {" + getRed() + ", " + getGreen() + ", " + getBlue() + "}";
}
@@ -96,4 +101,4 @@ public static Color photon_new(Device device, int handle) {
color.device = device;
return color;
}
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java
index dae177eaca..4f5386b0e5 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.graphics;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.photon.*;
@@ -20,7 +20,7 @@ public final class Cursor {
* the handle to the OS cursor resource
* (Warning: This field is platform dependent)
*/
- public int handle;
+ public int bitmap;
/**
* the device where this cursor was created
@@ -60,8 +60,7 @@ public Cursor(Device device, int style) {
default:
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
- handle = type;
- if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ if (type == 0) SWT.error(SWT.ERROR_NO_HANDLES);
if (device.tracking) device.new_Object(this);
}
@@ -69,18 +68,91 @@ public Cursor(Device device, ImageData source, ImageData mask, int hotspotX, int
if (device == null) device = Device.getDevice();
if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
this.device = device;
+ if (source == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (mask == null) {
+ if (source.getTransparencyType() != SWT.TRANSPARENCY_MASK) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ mask = source.getTransparencyMask();
+ }
+ /* Check the bounds. Mask must be the same size as source */
+ if (mask.width != source.width || mask.height != source.height) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ /* Check color depths */
+ if (mask.depth != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (source.depth != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ /* Check the hotspots */
+ if (hotspotX >= source.width || hotspotX < 0 ||
+ hotspotY >= source.height || hotspotY < 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
type = OS.Ph_CURSOR_BITMAP;
- SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
- if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+
+ short w = (short)source.width;
+ short h = (short)source.height;
+ ImageData mask1 = new ImageData(w, h, 1, source.palette);
+ ImageData mask2 = new ImageData(w, h, 1, mask.palette);
+ for (int y=0; y<h; y++) {
+ for (int x=0; x<w; x++) {
+ int mask1_pixel, src_pixel = source.getPixel(x, y);
+ int mask2_pixel, mask_pixel = mask.getPixel(x, y);
+ if (src_pixel == 0 && mask_pixel == 0) {
+ // BLACK
+ mask1_pixel = 0;
+ mask2_pixel = 1;
+ } else if (src_pixel == 0 && mask_pixel == 1) {
+ // WHITE - cursor color
+ mask1_pixel = 1;
+ mask2_pixel = 0;
+ } else if (src_pixel == 1 && mask_pixel == 0) {
+ // SCREEN
+ mask1_pixel = 0;
+ mask2_pixel = 0;
+ } else {
+ /*
+ * Feature in Photon. It is not possible to have
+ * the reverse screen case using the Photon support.
+ * Reverse screen will be the same as screen.
+ */
+ // REVERSE SCREEN -> SCREEN
+ mask1_pixel = 0;
+ mask2_pixel = 0;
+ }
+ mask1.setPixel(x, y, mask1_pixel);
+ mask2.setPixel(x, y, mask2_pixel);
+ }
+ }
+
+ PhCursorDef_t cursor = new PhCursorDef_t();
+ cursor.size1_x = w;
+ cursor.size1_y = h;
+ cursor.offset1_x = (short)-hotspotX;
+ cursor.offset1_y = (short)-hotspotY;
+ cursor.bytesperline1 = (byte)mask1.bytesPerLine;
+ cursor.color1 = OS.Ph_CURSOR_DEFAULT_COLOR;
+ cursor.size2_x = w;
+ cursor.size2_y = h;
+ cursor.offset2_x = (short)-hotspotX;
+ cursor.offset2_y = (short)-hotspotY;
+ cursor.bytesperline2 = (byte)mask2.bytesPerLine;
+ cursor.color2 = 0x000000;
+ int mask1Size = cursor.bytesperline1 * cursor.size1_y;
+ int mask2Size = cursor.bytesperline2 * cursor.size2_y;
+ bitmap = OS.malloc(PhCursorDef_t.sizeof + mask1Size + mask2Size);
+ if (bitmap == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ OS.memmove(bitmap, cursor, PhCursorDef_t.sizeof);
+ OS.memmove(bitmap + PhCursorDef_t.sizeof, mask1.data, mask1Size);
+ OS.memmove(bitmap + PhCursorDef_t.sizeof + mask1Size, mask2.data, mask2Size);
if (device.tracking) device.new_Object(this);
}
public void dispose () {
- if (handle == 0) return;
- if (type == OS.Ph_CURSOR_BITMAP && handle != 0) {
- /* BITMAP cursors are not implemented yet */
+ if (type == 0) return;
+ if (type == OS.Ph_CURSOR_BITMAP && bitmap != 0) {
+ OS.free(bitmap);
}
- type = handle = 0;
+ type = bitmap = 0;
if (device.tracking) device.dispose_Object(this);
device = null;
}
@@ -89,24 +161,30 @@ public boolean equals (Object object) {
if (object == this) return true;
if (!(object instanceof Cursor)) return false;
Cursor cursor = (Cursor) object;
- return device == cursor.device && handle == cursor.handle;
+ return device == cursor.device && type == cursor.type &&
+ bitmap == cursor.bitmap;
}
public int hashCode () {
- return handle ^ type;
+ return bitmap ^ type;
}
public boolean isDisposed() {
return type == 0;
}
-public static Cursor photon_new(Device device, int type, int handle) {
+public static Cursor photon_new(Device device, int type, int bitmap) {
if (device == null) device = Device.getDevice();
Cursor cursor = new Cursor();
cursor.type = type;
- cursor.handle = handle;
+ cursor.bitmap = bitmap;
cursor.device = device;
return cursor;
}
-} \ No newline at end of file
+public String toString () {
+ if (isDisposed()) return "Cursor {*DISPOSED*}";
+ return "Cursor {" + type + "," + bitmap + "}";
+}
+
+}
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 3d48ea467a..ff740b3b53 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
@@ -1,5 +1,10 @@
package org.eclipse.swt.graphics;
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
import org.eclipse.swt.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.photon.*;
@@ -14,37 +19,47 @@ public abstract class Device implements Drawable {
Object [] objects;
boolean disposed;
+
+ /*
+ * TEMPORARY CODE. When a graphics object is
+ * created and the device parameter is null,
+ * the current Display is used. This presents
+ * a problem because SWT graphics does not
+ * reference classes in SWT widgets. The correct
+ * fix is to remove this feature. Unfortunately,
+ * too many application programs rely on this
+ * feature.
+ *
+ * This code will be removed in the future.
+ */
+ protected static Device CurrentDevice;
+ protected static Runnable DeviceFinder;
+ static {
+ try {
+ Class.forName ("org.eclipse.swt.widgets.Display");
+ } catch (Throwable e) {}
+ }
+
+static Device getDevice () {
+ if (DeviceFinder != null) DeviceFinder.run();
+ Device device = CurrentDevice;
+ CurrentDevice = null;
+ return device;
+}
public Device(DeviceData data) {
- create (data);
- init ();
if (data != null) {
debug = data.debug;
tracking = data.tracking;
}
+ create (data);
+ init ();
if (tracking) {
errors = new Error [128];
objects = new Object [128];
}
}
-/**
- * Temporary code.
- */
-static Device getDevice () {
- Device device = null;
- try {
- Class clazz = Class.forName ("org.eclipse.swt.widgets.Display");
- java.lang.reflect.Method method = clazz.getMethod("getCurrent", new Class[0]);
- device = (Device) method.invoke(clazz, new Object[0]);
- if (device == null) {
- method = clazz.getMethod("getDefault", new Class[0]);
- device = (Device)method.invoke(clazz, new Object[0]);
- }
- } catch (Throwable e) {};
- return device;
-}
-
protected void checkDevice () {
if (disposed) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
}
@@ -250,4 +265,4 @@ public void setWarnings (boolean warnings) {
checkDevice ();
}
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/DeviceData.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/DeviceData.java
index f971a60537..27fe10271d 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/DeviceData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/DeviceData.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.graphics;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class DeviceData {
@@ -14,4 +14,4 @@ public class DeviceData {
public boolean tracking;
public Error [] errors;
public Object [] objects;
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java
index de23742eed..433ccb07b1 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.graphics;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.*;
@@ -66,6 +66,7 @@ public boolean equals(Object object) {
}
public FontData[] getFontData() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return new FontData[]{new FontData(handle)};
}
@@ -104,4 +105,9 @@ public static Font photon_new(Device device, byte[] stem) {
return font;
}
-} \ No newline at end of file
+public String toString () {
+ if (isDisposed()) return "Font {*DISPOSED*}";
+ return "Font {" + new String(handle).trim() + "}";
+}
+
+}
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 b7e0fe27ce..fd9902bd2b 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.graphics;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.*;
@@ -185,4 +185,4 @@ public static FontData photon_new(byte[] stem) {
return new FontData(stem);
}
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java
index 6943cd42d9..fa6ba3fb21 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.graphics;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.photon.*;
@@ -47,6 +47,7 @@ public int getAscent() {
}
public int getAverageCharWidth() {
+ if ((handle.style & OS.PHFONT_INFO_FIXED) != 0) return handle.width;
return handle.width / 2;
}
@@ -75,4 +76,4 @@ public static FontMetrics photon_new(FontQueryInfo handle) {
fontMetrics.handle = handle;
return fontMetrics;
}
-} \ No newline at end of file
+}
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 9c79ad0715..27bfe18b80 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.graphics;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.*;
@@ -52,8 +52,9 @@ public GC(Drawable drawable) {
}
public void copyArea(Image image, int x, int y) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (image.type != SWT.BITMAP) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
int flags = OS.PtEnter(0);
try {
Rectangle bounds = image.getBounds();
@@ -111,6 +112,7 @@ public void copyArea(Image image, int x, int y) {
}
public void copyArea(int x, int y, int width, int height, int destX, int destY) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width == 0 || height == 0) return;
int deltaX = destX - x, deltaY = destY - y;
if (deltaX == 0 && deltaY == 0) return;
@@ -195,14 +197,23 @@ public void copyArea(int x, int y, int width, int height, int destX, int destY)
delta.x = (short)deltaX;
delta.y = (short)deltaY;
int clipRects = data.clipRects;
- if (clipRects == 0) {
+ int child_clip = getClipping(widget, data.topWidget, true, true);
+ if (clipRects == 0 && child_clip == 0) {
OS.PhBlit(rid, rect, delta);
} else {
int dest = OS.PhGetTile();
OS.memmove(dest, rect, PhRect_t.sizeof);
OS.PhTranslateTiles(dest, delta);
- int clip = OS.PhRectsToTiles(clipRects, data.clipRectsCount);
- int dest_tiles = OS.PhIntersectTilings(dest, clip, new short[1]);
+ short[] unused = new short[1];
+ int clip = child_clip;
+ if (clipRects != 0) {
+ clip = OS.PhRectsToTiles(clipRects, data.clipRectsCount);
+ if (child_clip != 0) {
+ clip = OS.PhIntersectTilings(clip, child_clip, unused);
+ OS.PhFreeTiles(child_clip);
+ }
+ }
+ int dest_tiles = OS.PhIntersectTilings(dest, clip, unused);
OS.PhFreeTiles(clip);
OS.PhFreeTiles(dest);
PhPoint_t inverseDelta = new PhPoint_t();
@@ -276,6 +287,7 @@ public void dispose() {
}
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 (startAngle > 0) {
if (endAngle > 0) {
//No need to modify start angle.
@@ -336,27 +348,32 @@ public void drawArc (int x, int y, int width, int height, int startAngle, int en
}
public void drawFocus (int x, int y, int width, int height) {
+ width = (width < 0 ? -width : width) - 1;
+ height = (height < 0 ? -height : height) - 1;
drawRectangle(x, y, width, height);
}
public void drawImage(Image image, int x, int y) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (image.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true);
}
public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (srcWidth == 0 || srcHeight == 0 || destWidth == 0 || destHeight == 0) return;
if (srcX < 0 || srcY < 0 || srcWidth < 0 || srcHeight < 0 || destWidth < 0 || destHeight < 0) {
SWT.error (SWT.ERROR_INVALID_ARGUMENT);
}
if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (image.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false);
}
void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) {
int flags = OS.PtEnter(0);
try {
int drawImage = image.handle;
- if (drawImage == 0) return;
PhImage_t phDrawImage = new PhImage_t();
OS.memmove(phDrawImage, drawImage, PhImage_t.sizeof);
int imgWidth = phDrawImage.size_w;
@@ -683,6 +700,7 @@ static int scaleImage(Image image, PhImage_t phImage, int srcX, int srcY, int sr
}
public void drawLine (int x1, int y1, int x2, int y2) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
int flags = OS.PtEnter(0);
try {
int prevContext = setGC();
@@ -695,6 +713,7 @@ public void drawLine (int x1, int y1, int x2, int y2) {
}
public void drawOval (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();
@@ -713,6 +732,7 @@ public void drawOval (int x, int y, int width, int height) {
}
public void drawPolygon(int[] pointArray) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
short[] points = new short[pointArray.length];
@@ -732,20 +752,19 @@ public void drawPolygon(int[] pointArray) {
}
public void drawPolyline(int[] pointArray) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
short[] points = new short[pointArray.length];
for (int i = pointArray.length - 1; i >= 0; i--) {
points[i] = (short)pointArray[i];
}
- PhPoint_t pos = new PhPoint_t();
- pos.x = 0; pos.y = 0;
int flags = OS.PtEnter(0);
try {
int prevContext = setGC();
setGCClipping();
- OS.PgDrawPolygon(points, pointArray.length / 2, pos, OS.Pg_DRAW_STROKE);
+ OS.PgDrawPolygon(points, pointArray.length / 2, new PhPoint_t(), OS.Pg_DRAW_STROKE);
unsetGC(prevContext);
} finally {
if (flags >= 0) OS.PtLeave(flags);
@@ -753,6 +772,7 @@ public void drawPolyline(int[] pointArray) {
}
public void drawRectangle (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
int flags = OS.PtEnter(0);
try {
int prevContext = setGC();
@@ -771,6 +791,7 @@ public void drawRectangle (Rectangle rect) {
}
public void drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
PhRect_t rect = new PhRect_t();
rect.ul_x = (short)x; rect.ul_y = (short)y;
// Don't subtract one, so that the bottom/right edges are drawn
@@ -794,6 +815,7 @@ public void drawString (String string, int x, int y) {
}
public void drawString (String string, int x, int y, boolean isTransparent) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
int drawFlags = OS.Pg_TEXT_LEFT | OS.Pg_TEXT_TOP;
@@ -816,7 +838,28 @@ public void drawText (String string, int x, int y) {
}
public void drawText (String string, int x, int y, boolean isTransparent) {
- drawString(string, x, y, isTransparent);;
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+
+ int drawFlags = OS.Pg_TEXT_LEFT | OS.Pg_TEXT_TOP;
+ if (!isTransparent) drawFlags |= OS.Pg_BACK_FILL;
+ 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.PgDrawMultiTextArea(buffer, buffer.length, rect, drawFlags, OS.Pg_TEXT_LEFT | OS.Pg_TEXT_TOP, 0);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
}
public boolean equals (Object object) {
@@ -824,6 +867,7 @@ public boolean equals (Object object) {
}
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 (startAngle > 0) {
if (endAngle > 0) {
//No need to modify start angle.
@@ -884,6 +928,7 @@ public void fillArc (int x, int y, int width, int height, int startAngle, int en
}
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();
@@ -904,6 +949,7 @@ public void fillOval (int x, int y, int width, int height) {
}
public void fillPolygon(int[] pointArray) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
short[] points = new short[pointArray.length];
@@ -923,6 +969,7 @@ public void fillPolygon(int[] pointArray) {
}
public void fillRectangle (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width == 0 || height == 0) return;
int flags = OS.PtEnter(0);
try {
@@ -941,6 +988,7 @@ public void fillRectangle (Rectangle rect) {
}
public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
PhRect_t rect = new PhRect_t();
rect.ul_x = (short)x; rect.ul_y = (short)y;
rect.lr_x = (short)(x + width - 1); rect.lr_y = (short)(y + height - 1);
@@ -963,16 +1011,19 @@ public int getAdvanceWidth(char ch) {
}
public Color getBackground() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return Color.photon_new(data.device, data.background);
}
public int getCharWidth(char ch) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
String string = new String(new char[] {ch});
Point point = stringExtent(string);
return point.x;
}
public Rectangle getClipping() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
int flags = OS.PtEnter(0);
try {
PhRect_t rect = new PhRect_t();
@@ -1014,6 +1065,7 @@ public Rectangle getClipping() {
}
public void getClipping (Region region) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (region == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
int flags = OS.PtEnter(0);
try {
@@ -1047,28 +1099,34 @@ public void getClipping (Region region) {
}
public Font getFont () {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return Font.photon_new(data.device, data.font);
}
public FontMetrics getFontMetrics() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
FontQueryInfo info = new FontQueryInfo();
OS.PfQueryFontInfo(data.font, info);
return FontMetrics.photon_new(info);
}
public Color getForeground() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return Color.photon_new(data.device, data.foreground);
}
public int getLineStyle() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return data.lineStyle;
}
public int getLineWidth() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return data.lineWidth;
}
public boolean getXORMode() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return data.xorMode;
}
@@ -1076,7 +1134,6 @@ public int hashCode () {
return handle;
}
-
void init(Drawable drawable, GCData data, int context) {
int prevContext;
Image image = data.image;
@@ -1123,6 +1180,7 @@ void init(Drawable drawable, GCData data, int context) {
}
public boolean isClipped() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
return data.clipRects != 0;
}
@@ -1130,13 +1188,34 @@ public boolean isDisposed() {
return handle == 0;
}
+static String replaceTabs(String text, int spaces) {
+ int length = text.length();
+ int index = text.indexOf('\t', 0);
+ if (index == -1) return text;
+
+ int start = 0;
+ StringBuffer result = new StringBuffer();
+ StringBuffer spaceString = new StringBuffer();
+ while (spaces-- > 0) {
+ spaceString.append(' ');
+ }
+ while (index != -1 && index < length) {
+ result.append(text.substring(start, index));
+ result.append(spaceString);
+ index = text.indexOf('\t', start = index + 1);
+ }
+ if (index == -1) result.append(text.substring(start, length));
+ return result.toString();
+}
+
public void setBackground (Color color) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
int flags = OS.PtEnter(0);
try {
int prevContext = setGC();
- int backColor = color == null ? DefaultBack : color.handle;
- OS.PgSetFillColor(backColor);
- data.background = backColor;
+ OS.PgSetFillColor(data.background = color.handle);
unsetGC(prevContext);
} finally {
if (flags >= 0) OS.PtLeave(flags);
@@ -1144,6 +1223,7 @@ public void setBackground (Color color) {
}
public void setClipping (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
int flags = OS.PtEnter(0);
try {
int clipRects = data.clipRects;
@@ -1168,6 +1248,7 @@ public void setClipping (int x, int y, int width, int height) {
}
public void setClipping (Rectangle rect) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (rect == null) {
int flags = OS.PtEnter(0);
try {
@@ -1186,6 +1267,7 @@ public void setClipping (Rectangle rect) {
}
public void setClipping (Region region) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
int flags = OS.PtEnter(0);
try {
int clipRects = data.clipRects;
@@ -1213,6 +1295,8 @@ public void setClipping (Region region) {
}
public void setFont (Font font) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (font != null && font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
int flags = OS.PtEnter(0);
try {
int prevContext = setGC();
@@ -1226,11 +1310,13 @@ public void setFont (Font font) {
}
public void setForeground (Color color) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
int flags = OS.PtEnter(0);
try {
int prevContext = setGC();
- int foreColor = color == null ? DefaultFore : color.handle;
- data.foreground = foreColor;
+ int foreColor = data.foreground = color.handle;
OS.PgSetStrokeColor(foreColor);
OS.PgSetTextColor(foreColor);
unsetGC(prevContext);
@@ -1240,6 +1326,7 @@ public void setForeground (Color color) {
}
public void setLineStyle(int lineStyle) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
byte[] dashList;
switch (lineStyle) {
case SWT.LINE_SOLID: dashList = DashList[0]; break;
@@ -1263,6 +1350,7 @@ public void setLineStyle(int lineStyle) {
}
public void setLineWidth(int lineWidth) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
int flags = OS.PtEnter(0);
try {
int prevContext = setGC();
@@ -1294,63 +1382,70 @@ void setGCClipping() {
if (widget == 0) return;
+ 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);
+
+ /* 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);
+ clip_rects = OS.malloc(PhRect_t.sizeof);
+ }
+ OS.PgSetClipping((short)clip_rects_count[0], clip_rects);
+ OS.free(clip_rects);
+}
+
+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
- // Get the rectangle of all siblings in front of the widget
- 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
+ /* Get the rectangle of all siblings in front of the widget */
+ if (clipSiblings) {
+ 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
+ }
}
+ /* 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
}
- // 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
- 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
+ /* 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
+ }
+ temp_widget = OS.PtWidgetBrotherInFront(temp_widget);
}
- temp_widget = OS.PtWidgetBrotherInFront(temp_widget);
}
- // Get the widget's rectangle
+ /* 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
- int clip_rects;
- int[] clip_rects_count = new int[1];
+ /* 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);
- clip_rects = OS.PhTilesToRects(clip_tile, clip_rects_count);
OS.PhFreeTiles(child_tile);
- OS.PhFreeTiles(clip_tile);
- } else {
- clip_rects = OS.PhTilesToRects(widget_tile, clip_rects_count);
- OS.PhFreeTiles(widget_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);
- clip_rects = OS.malloc(PhRect_t.sizeof);
+ return clip_tile;
}
- OS.PgSetClipping((short)clip_rects_count[0], clip_rects);
- OS.free(clip_rects);
+ return widget_tile;
}
public void setXORMode(boolean xor) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
int flags = OS.PtEnter(0);
try {
int prevContext = setGC();
@@ -1364,6 +1459,7 @@ public void setXORMode(boolean xor) {
}
public Point stringExtent(String string) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
PhRect_t rect = new PhRect_t();
int size = string.length();
@@ -1377,13 +1473,40 @@ public Point stringExtent(String string) {
if (flags >= 0) OS.PtLeave(flags);
}
- int width = rect.lr_x - rect.ul_x + 1;
+ int width;
+ if (size == 0) width = 0;
+ else width = rect.lr_x - (rect.ul_x < 0 ? rect.ul_x : 0) + 1;
int height = rect.lr_y - rect.ul_y + 1;
return new Point(width, height);
}
public Point textExtent(String string) {
- return stringExtent(string);
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ PhRect_t rect = new PhRect_t();
+ string = replaceTabs(string, 8);
+ int size = string.length();
+ byte [] buffer = Converter.wcsToMbcs (null, string, false);
+
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ OS.PgExtentMultiText(rect, null, data.font, buffer, buffer.length, 0);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+
+ int width;
+ if (size == 0) width = 0;
+ else width = rect.lr_x - (rect.ul_x < 0 ? rect.ul_x : 0) + 1;
+ int height = rect.lr_y - rect.ul_y + 1;
+ return new Point(width, height);
+}
+
+public String toString () {
+ if (isDisposed()) return "GC {*DISPOSED*}";
+ return "GC {" + handle + "}";
}
void unsetGC(int prevContext) {
@@ -1404,4 +1527,4 @@ public static GC photon_new(Drawable drawable, GCData data) {
return gc;
}
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GCData.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GCData.java
index f021841ba1..389600ec87 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GCData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GCData.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.graphics;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.*;
@@ -20,4 +20,4 @@ public final class GCData {
public int lineWidth = 1;
public int clipRectsCount;
public int clipRects;
-} \ No newline at end of file
+}
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 01f00d8053..2dc3f904a3 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.graphics;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.photon.*;
@@ -61,6 +61,7 @@ public Image(Device device, Image srcImage, int flag) {
if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
this.device = device;
if (srcImage == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (srcImage.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
switch (flag) {
case SWT.IMAGE_COPY:
case SWT.IMAGE_DISABLE:
@@ -238,6 +239,7 @@ public boolean equals (Object object) {
}
public Color getBackground() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (transparentPixel == -1) return null;
PhImage_t phImage = new PhImage_t();
@@ -274,13 +276,14 @@ public Color getBackground() {
}
public Rectangle getBounds() {
- if (handle == 0) return new Rectangle(0, 0, 0, 0);
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
PhImage_t image = new PhImage_t();
OS.memmove(image, handle, PhImage_t.sizeof);
return new Rectangle(0, 0, image.size_w, image.size_h);
}
public ImageData getImageData() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
PhImage_t phImage = new PhImage_t();
OS.memmove(phImage, handle, PhImage_t.sizeof);
int depth = 0;
@@ -580,8 +583,11 @@ public boolean isDisposed() {
}
public void setBackground(Color color) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (transparentPixel == -1) return;
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (transparentPixel == -1) return;
+
PhImage_t phImage = new PhImage_t();
OS.memmove(phImage, handle, PhImage_t.sizeof);
int phPalette = phImage.palette;
@@ -609,4 +615,9 @@ public static Image photon_new(Device device, int type, int handle) {
return image;
}
-} \ No newline at end of file
+public String toString () {
+ if (isDisposed()) return "Image {*DISPOSED*}";
+ return "Image {" + handle + "}";
+}
+
+}
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 2b058dfc7c..dda73e3f79 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.graphics;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.photon.*;
@@ -27,6 +27,7 @@ Region(int handle) {
public void add (Rectangle rect) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (handle == 0) return;
int tile_ptr = OS.PhGetTile();
@@ -41,6 +42,7 @@ public void add (Rectangle rect) {
}
public void add (Region region) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (handle == 0) return;
if (region.handle == 0 || region.handle == EMPTY_REGION) return;
@@ -50,6 +52,7 @@ public void add (Region region) {
}
public boolean contains (int x, int y) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (handle == 0 || handle == EMPTY_REGION) return false;
int tile_ptr = OS.PhGetTile();
PhTile_t tile = new PhTile_t();
@@ -82,6 +85,7 @@ public boolean equals (Object object) {
}
public Rectangle getBounds() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (handle == 0 || handle == EMPTY_REGION) return new Rectangle(0, 0, 0, 0);
PhTile_t tile = new PhTile_t();
int temp_tile;
@@ -105,6 +109,7 @@ public int hashCode () {
}
public boolean intersects (int x, int y, int width, int height) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (handle == 0 || handle == EMPTY_REGION) return false;
int tile_ptr = OS.PhGetTile();
PhTile_t tile = new PhTile_t();
@@ -137,17 +142,9 @@ public boolean isEmpty () {
public static Region photon_new(int handle) {
return new Region(handle);
}
-/*
-public static void printTile(int tile_ptr, String msg) {
- if (tile_ptr == 0) return;
- PhTile_t tile = new PhTile_t();
- int temp_tile = tile_ptr;
- int count = 0;
- do {
- OS.memmove(tile, temp_tile, PhTile_t.sizeof);
- System.out.println(msg + "-" + count++ + " address=" + temp_tile + " x1=" + tile.rect_ul_x + " y1=" + tile.rect_ul_y + " x2=" + tile.rect_lr_x + " y2=" + tile.rect_lr_y);
- temp_tile = tile.next;
- } while (temp_tile != 0);
+
+public String toString () {
+ if (isDisposed()) return "Region {*DISPOSED*}";
+ return "Region {" + handle + "}";
}
-*/
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/Converter.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/Converter.java
index 682f69081f..f9c66b8274 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/Converter.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/Converter.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.internal;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public final class Converter {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontDetails.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontDetails.java
index adcae07101..04879a4ab9 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontDetails.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontDetails.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class FontDetails {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontQueryInfo.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontQueryInfo.java
index af0556407a..90cf14d8d8 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontQueryInfo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontQueryInfo.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class FontQueryInfo {
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 0ecedcc7b1..2c83686a4f 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.*;
@@ -34,10 +34,10 @@ public class OS {
public static final int Pt_BOTTOM_OUTLINE = 0x00000020;
public static final int Pt_LEFT_OUTLINE = 0x00000040;
public static final int Pt_RIGHT_OUTLINE = 0x00000080;
-// public static final int Pt_TOP_BEVEL = 0x00000100;
-// public static final int Pt_BOTTOM_BEVEL = 0x00000200;
-// public static final int Pt_LEFT_BEVEL = 0x00000400;
-// public static final int Pt_RIGHT_BEVEL = 0x00000800;
+ public static final int Pt_TOP_BEVEL = 0x00000100;
+ public static final int Pt_BOTTOM_BEVEL = 0x00000200;
+ public static final int Pt_LEFT_BEVEL = 0x00000400;
+ public static final int Pt_RIGHT_BEVEL = 0x00000800;
public static final int Pt_TOP_INLINE = 0x00001000;
public static final int Pt_BOTTOM_INLINE = 0x00002000;
public static final int Pt_LEFT_INLINE = 0x00004000;
@@ -156,16 +156,26 @@ public class OS {
public static final int Pt_ARG_TOOLBAR_FLAGS = ( 61 * 1000 + 0 );
public static final int Pt_ARG_TOOLBAR_SPACING = ( 61 * 1000 + 1 );
+ public static final int Pt_TOOLBAR_DRAGGABLE = 0x0001;
public static final int Pt_TOOLBAR_ITEM_SEPARATORS = 0x0020;
+ public static final int Pt_TOOLBAR_END_SEPARATOR = 0x0040;
public static final int Pt_COLORSELECT_MODAL = 0x4;
public static final int Pt_COLORSELECT_ACCEPT = 0x8000;
public static final int Pt_PROCESS = 0;
// public static final int Pt_IGNORE = 1;
-// public static final int Pt_CONSUME = 2;
+ public static final int Pt_CONSUME = 2;
public static final int Pt_CB_FILTER = ( 1 * 1000 + 26 );
+ public static final int Pt_ALL_BUTTONS = 0x00800000;
+ public static final int Pt_MENUABLE = 0x08000000;
+
+ public static final int Ph_CONSUMED = 0x0004;
+
+ 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};
/*** END MANUALLY ADDED/FIXED ***/
//public static final int Aw_ARG_ONOFF_STATE = ( 5 * 1000 + 1 );
@@ -652,7 +662,7 @@ public static final int Pg_BITMAP_TRANSPARENT =
public static final int Ph_CURSOR_BITMAP = 0xFB;
public static final int Ph_CURSOR_CLOCK = 0xE908;
public static final int Ph_CURSOR_CROSSHAIR = 0xE906;
-//public static final int Ph_CURSOR_DEFAULT_COLOR = 0xFFFFE0;
+ public static final int Ph_CURSOR_DEFAULT_COLOR = 0xFFFFE0;
public static final int Ph_CURSOR_DONT = 0xE90A;
//public static final int Ph_CURSOR_DRAG_BACKDIAG = 0xE914;
public static final int Ph_CURSOR_DRAG_BL = 0xE916;
@@ -673,7 +683,7 @@ public static final int Pg_BITMAP_TRANSPARENT =
//public static final int Ph_CURSOR_LONG_WAIT = 0xE91A;
//public static final int Ph_CURSOR_MANUAL_CONTROL = 0xFF;
public static final int Ph_CURSOR_MOVE = 0xE904;
-//public static final int Ph_CURSOR_NO_INHERIT = 0x01;
+ public static final int Ph_CURSOR_NO_INHERIT = 0x01;
//public static final int Ph_CURSOR_NOINPUT = 0xE90A;
//public static final int Ph_CURSOR_NONE = 0xFD;
//public static final int Ph_CURSOR_PASTE = 0xE91E;
@@ -724,9 +734,9 @@ public static final int Pg_BITMAP_TRANSPARENT =
//public static final int Ph_EV_DNDROP = 0x00200000;
public static final int Ph_EV_DRAG = 0x00000200;
//public static final int Ph_EV_DRAG_BOUNDARY = 5;
-//public static final int Ph_EV_DRAG_COMPLETE = 2;
+ public static final int Ph_EV_DRAG_COMPLETE = 2;
//public static final int Ph_EV_DRAG_INIT = 0;
-//public static final int Ph_EV_DRAG_KEY_EVENT = 3;
+ public static final int Ph_EV_DRAG_KEY_EVENT = 3;
public static final int Ph_EV_DRAG_MOTION_EVENT = 4;
//public static final int Ph_EV_DRAG_MOVE = 1;
//public static final int Ph_EV_DRAG_START = 6;
@@ -755,10 +765,10 @@ public static final int Pg_BITMAP_TRANSPARENT =
public static final int Ph_EV_PTR_MOTION_NOBUTTON = 0x00000008;
//public static final int Ph_EV_PTR_RECT_ENTER = 0x10;
//public static final int Ph_EV_PTR_RECT_LEAVE = 0x11;
-//public static final int Ph_EV_PTR_STEADY = 2;
+ public static final int Ph_EV_PTR_STEADY = 2;
//public static final int Ph_EV_PTR_TRANSIENT_ENTER = 8;
//public static final int Ph_EV_PTR_TRANSIENT_LEAVE = 9;
-//public static final int Ph_EV_PTR_UNSTEADY = 3;
+ public static final int Ph_EV_PTR_UNSTEADY = 3;
public static final int Ph_EV_PTR_MOTION = ( Ph_EV_PTR_MOTION_NOBUTTON | Ph_EV_PTR_MOTION_BUTTON );
//public static final int Ph_EV_PTR_ALL = ( Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE | Ph_EV_PTR_MOTION | Ph_EV_BUT_REPEAT );
//public static final int Ph_EV_RAW = 0x00008000;
@@ -768,7 +778,7 @@ public static final int Pg_BITMAP_TRANSPARENT =
//public static final int Ph_EV_RELEASE_ENDCLICK = 2;
//public static final int Ph_EV_RELEASE_OUTBOUND = 3;
public static final int Ph_EV_RELEASE_PHANTOM = 1;
-//public static final int Ph_EV_RELEASE_REAL = 0;
+ public static final int Ph_EV_RELEASE_REAL = 0;
//public static final int Ph_EV_REMOTE_WM = 1;
//public static final int Ph_EV_SERVICE = 0x00040000;
//public static final int Ph_EV_SYSTEM = 0x00001000;
@@ -795,7 +805,7 @@ public static final int Pg_BITMAP_TRANSPARENT =
//public static final int Ph_EV_ICON_OPAQUE = ( Ph_EV_WM | Ph_EV_EXPOSE | Ph_EV_DRAW );
//public static final int Ph_EV_ICON_SENSE = ( Ph_EV_WM | Ph_EV_EXPOSE );
//public static final int Ph_EVENT_ABSOLUTE = 0x0004;
-//public static final int Ph_EVENT_DIRECT = 0x0010;
+ public static final int Ph_EVENT_DIRECT = 0x0010;
//public static final int Ph_EVENT_INCLUSIVE = 0x0008;
public static final int Ph_EVENT_MSG = 1;
//public static final int Ph_EVENT_NO_RECT = 0x0002;
@@ -803,7 +813,7 @@ public static final int Pg_BITMAP_TRANSPARENT =
//public static final int Ph_EVENT_RSRV1 = 0x8000;
//public static final int Ph_EXPOSE_FAMILY = 0x00002000;
//public static final int Ph_EXPOSE_REGION = 0x00004000;
-//public static final int Ph_FAKE_EVENT = 0x0001;
+ public static final int Ph_FAKE_EVENT = 0x0001;
//public static final int Ph_FEP_ACTIVATE = 0x00000003;
//public static final int Ph_FEP_BROADCAST = 0x00000000;
//public static final int Ph_FEP_CHINESE = 0x00000002;
@@ -900,7 +910,7 @@ public static final int Pg_BITMAP_TRANSPARENT =
//public static final int Ph_NO_PROXY = 0x00000004;
//public static final int Ph_NORMAL_DRAW = 0x0000;
//public static final int Ph_NORMAL_EXPOSE = 0;
-//public static final int Ph_NOT_CUAKEY = 0x10;
+ public static final int Ph_NOT_CUAKEY = 0x10;
//public static final int Ph_NOT_HOTKEY = 0x20;
//public static final int Ph_PRINT_REGION = 0x00000020;
//public static final int Ph_PRINTER_EXPOSE = 1;
@@ -1049,7 +1059,7 @@ public static final int Pg_BITMAP_TRANSPARENT =
//public static final int Ph_WM_STATE_ISBACKDROP = 0x00000004;
//public static final int Ph_WM_STATE_ISBLOCKED = 0x00000008;
public static final int Ph_WM_STATE_ISFOCUS = 0x00008000;
-//public static final int Ph_WM_STATE_ISFRONT = 0x00000100;
+ public static final int Ph_WM_STATE_ISFRONT = 0x00000100;
public static final int Ph_WM_STATE_ISHIDDEN = 0x00000001;
//public static final int Ph_WM_STATE_ISICON = 0x00000080;
public static final int Ph_WM_STATE_ISICONIFIED = 0x00000040;
@@ -1190,7 +1200,7 @@ public static final int Pg_BITMAP_TRANSPARENT =
//public static final int Pk_Num_Lock = 0xF07F;
//
//public static final int Pk_KP_Space = 0xF080; /* space */
-//public static final int Pk_KP_Tab = 0xF089;
+ public static final int Pk_KP_Tab = 0xF089;
//public static final int Pk_KP_Enter = 0xF08D; /* enter */
//public static final int Pk_KP_F1 = 0xF091; /* PF1, KP_A, ... */
//public static final int Pk_KP_F2 = 0xF092;
@@ -1290,8 +1300,8 @@ public static final int Pg_BITMAP_TRANSPARENT =
//public static final int Pt_ARG_ARM_COLOR = ( 6 * 1000 + 0 );
//public static final int Pt_ARG_ARM_DATA = ( 6 * 1000 + 1 );
//public static final int Pt_ARG_ARM_FILL = ( 6 * 1000 + 2 );
-//public static final int Pt_ARG_BALLOON_COLOR = ( 3 * 1000 + 20 );
-//public static final int Pt_ARG_BALLOON_FILL_COLOR = ( 3 * 1000 + 19 );
+ public static final int Pt_ARG_BALLOON_COLOR = ( 3 * 1000 + 20 );
+ public static final int Pt_ARG_BALLOON_FILL_COLOR = ( 3 * 1000 + 19 );
public static final int Pt_ARG_BALLOON_POSITION = ( 3 * 1000 + 16 );
//public static final int Pt_ARG_BANDWIDTH_THRESHOLD = ( 2 * 1000 + 17 );
public static final int Pt_ARG_BASIC_FLAGS = ( 2 * 1000 + 15 );
@@ -1301,7 +1311,7 @@ public static final int Pg_BITMAP_TRANSPARENT =
//public static final int Pt_ARG_BITMAP_BALLOON_FILL_COLOR = ( 20 * 1000 + 10 );
//public static final int Pt_ARG_BITMAP_BALLOON_POSITION = ( 20 * 1000 + 8 );
//public static final int Pt_ARG_BITMAP_COLORS = ( 20 * 1000 + 0 );
-//public static final int Pt_ARG_BITMAP_CURSOR = ( 1 * 1000 + 17 );
+ public static final int Pt_ARG_BITMAP_CURSOR = ( 1 * 1000 + 17 );
//public static final int Pt_ARG_BITMAP_DATA = ( 20 * 1000 + 1 );
//public static final int Pt_ARG_BITMAP_FLAGS = ( 20 * 1000 + 7 );
//public static final int Pt_ARG_BITMAP_TEXT = ( 20 * 1000 + 2 );
@@ -1382,7 +1392,7 @@ public static final int Pg_BITMAP_TRANSPARENT =
//public static final int Pt_ARG_COLUMNS = ( 4 * 1000 + 1 );
public static final int Pt_ARG_CONTAINER_FLAGS = ( 10 * 1000 + 5 );
//public static final int Pt_ARG_CURRENT_FRAME = ( 101 * 1000 + 3 );
-//public static final int Pt_ARG_CURSOR_COLOR = ( 1 * 1000 + 3 );
+ public static final int Pt_ARG_CURSOR_COLOR = ( 1 * 1000 + 3 );
//public static final int Pt_ARG_CURSOR_OFFSET = ( 4 * 1000 + 19);
public static final int Pt_ARG_CURSOR_POSITION = ( 4 * 1000 + 3 );
public static final int Pt_ARG_CURSOR_TYPE = ( 1 * 1000 + 2 );
@@ -1434,7 +1444,7 @@ public static final int Pg_BITMAP_TRANSPARENT =
//public static final int Pt_ARG_GRID_VERTICAL = ( 43 * 1000 + 1 );
public static final int Pt_ARG_GROUP_FLAGS = ( 11 * 1000 + 0 );
public static final int Pt_ARG_GROUP_HORZ_ALIGN = ( 11 * 1000 + 1 );
-//public static final int Pt_ARG_GROUP_ORIENTATION = ( 11 * 1000 + 2 );
+ public static final int Pt_ARG_GROUP_ORIENTATION = ( 11 * 1000 + 2 );
//public static final int Pt_ARG_GROUP_ROWS_COLS = ( 11 * 1000 + 5 );
public static final int Pt_ARG_GROUP_SPACING = ( 11 * 1000 + 3 );
//public static final int Pt_ARG_GROUP_SPACING_X = ( 11 * 1000 + 6 );
@@ -1503,7 +1513,7 @@ public static final int Pg_BITMAP_TRANSPARENT =
public static final int Pt_ARG_LABEL_TYPE = ( 3 * 1000 + 3 );
//public static final int Pt_ARG_LINE_CAP = ( 25 * 1000 + 4 );
//public static final int Pt_ARG_LINE_JOIN = ( 25 * 1000 + 3 );
-//public static final int Pt_ARG_LINE_SPACING = ( 3 * 1000 + 21 );
+ public static final int Pt_ARG_LINE_SPACING = ( 3 * 1000 + 21 );
//public static final int Pt_ARG_LINE_WIDTH = ( 25 * 1000 + 2 );
//public static final int Pt_ARG_LIST_BALLOON = ( 23 * 1000 + 31 );
//public static final int Pt_ARG_LIST_COLUMN_ATTR = ( 23 * 1000 + 28 );
@@ -1517,7 +1527,7 @@ public static final int Pg_BITMAP_TRANSPARENT =
//public static final int Pt_ARG_LIST_SPACING = ( 23 * 1000 + 4 );
public static final int Pt_ARG_LIST_TOTAL_HEIGHT = ( 23 * 1000 + 16 );
public static final int Pt_ARG_MARGIN_BOTTOM = ( 3 * 1000 + 4 );
-//public static final int Pt_ARG_MARGIN_HEIGHT = ( 2 * 1000 + 4 );
+ public static final int Pt_ARG_MARGIN_HEIGHT = ( 2 * 1000 + 4 );
public static final int Pt_ARG_MARGIN_LEFT = ( 3 * 1000 + 5 );
public static final int Pt_ARG_MARGIN_RIGHT = ( 3 * 1000 + 6 );
public static final int Pt_ARG_MARGIN_TOP = ( 3 * 1000 + 7 );
@@ -1572,7 +1582,7 @@ public static final int Pg_BITMAP_TRANSPARENT =
//public static final int Pt_ARG_MULTITEXT_RANGE_ATTRIBUTES = ( 5 * 1000 + 0 );
//public static final int Pt_ARG_MULTITEXT_ROWS = ( 5 * 1000 + 12 );
//public static final int Pt_ARG_MULTITEXT_SEGMENTS = ( 5 * 1000 + 4 );
-//public static final int Pt_ARG_MULTITEXT_TABS = ( 5 * 1000 + 13 );
+ public static final int Pt_ARG_MULTITEXT_TABS = ( 5 * 1000 + 13 );
public static final int Pt_ARG_MULTITEXT_TOP_LINE = ( 5 * 1000 + 7 );
public static final int Pt_ARG_MULTITEXT_WRAP_FLAGS = ( 5 * 1000 + 1 );
//public static final int Pt_ARG_MULTITEXT_X_SCROLL_POS = ( 5 * 1000 + 9 );
@@ -1745,7 +1755,7 @@ public static final int Pg_BITMAP_TRANSPARENT =
//public static final int Pt_ARG_UPDOWN_TOP_BDR_COLOR = ( 52 * 1000 + 13 );
//public static final int Pt_ARG_UPDOWN_TOP_BORDER_COLOR = ( 52 * 1000 + 13 );
public static final int Pt_ARG_USER_DATA = ( 1 * 1000 + 14 );
-//public static final int Pt_ARG_VERTICAL_ALIGNMENT = ( 3 * 1000 + 15 );
+ public static final int Pt_ARG_VERTICAL_ALIGNMENT = ( 3 * 1000 + 15 );
public static final int Pt_ARG_VISIBLE_COUNT = ( 23 * 1000 + 9 );
//public static final int Pt_ARG_WIN_PARENT = ( 18 * 1000 + 8 );
//public static final int Pt_ARG_WINDOW_ACTIVE_COLOR = ( 18 * 1000 + 18 );
@@ -1851,7 +1861,7 @@ public static final int Pg_BITMAP_TRANSPARENT =
//public static final int Pt_CB_IS_DESTROYED = ( 1 * 1000 + 19 );
//public static final int Pt_CB_LIST_INPUT = ( 23 * 1000 + 24 );
public static final int Pt_CB_LOST_FOCUS = ( 2 * 1000 + 11 );
-//public static final int Pt_CB_MENU = ( 2 * 1000 + 16 );
+ public static final int Pt_CB_MENU = ( 2 * 1000 + 16 );
//public static final int Pt_CB_MODIFY_NOTIFY = ( 4 * 1000 + 10);
public static final int Pt_CB_MODIFY_VERIFY = ( 4 * 1000 + 9 );
//public static final int Pt_CB_MOTION_NOTIFY = ( 4 * 1000 + 14);
@@ -1986,8 +1996,8 @@ public static final int Pg_BITMAP_TRANSPARENT =
//public static final int Pt_EMT_READ_ONLY_FLAGS = Pt_EMT_DISABLE_PURGE | Pt_EMT_FOCUSED;
//public static final int Pt_EMT_SCROLL_TO_CURSOR = 0x80000000;
public static final int Pt_EMT_WORD = 0x01;
-//public static final int Pt_ENABLE_CUA = 0x00000010;
-//public static final int Pt_ENABLE_CUA_ARROWS = 0x00000020;
+ public static final int Pt_ENABLE_CUA = 0x00000010;
+ public static final int Pt_ENABLE_CUA_ARROWS = 0x00000020;
public static final int Pt_END = 2;
//public static final int Pt_ESC_DISABLE = 0x8;
//public static final int Pt_ETCH_HIGHLIGHT = 0x00000200;
@@ -2064,9 +2074,9 @@ public static final int Pg_BITMAP_TRANSPARENT =
//public static final int Pt_GROUP_ASIS = 2;
public static final int Pt_GROUP_EQUAL_SIZE = 0x00000002;
//public static final int Pt_GROUP_EQUAL_SIZE_HORIZONTAL = 0x00000100;
-//public static final int Pt_GROUP_EQUAL_SIZE_VERTICAL = 0x00000200;
+ public static final int Pt_GROUP_EQUAL_SIZE_VERTICAL = 0x00000200;
//public static final int Pt_GROUP_EXCLUSIVE = 0x00000001;
-//public static final int Pt_GROUP_HORIZONTAL = 0;
+ public static final int Pt_GROUP_HORIZONTAL = 0;
//public static final int Pt_GROUP_HORZ_CENTER = 0;
//public static final int Pt_GROUP_HORZ_LEFT = 1;
//public static final int Pt_GROUP_HORZ_NONE = -1;
@@ -2202,7 +2212,7 @@ public static final int Pg_BITMAP_TRANSPARENT =
//public static final int Pt_MENU_PDR_ON = 0x80000000;
public static final int Pt_MENU_RIGHT = 2;
//public static final int Pt_MENU_TEAR_OFF = 0x00000004;
-//public static final int Pt_MENU_TEXT = 0;
+ public static final int Pt_MENU_TEXT = 0;
//public static final int Pt_MENU_TRANSIENT = 0x00000002;
//public static final int Pt_MENU_UP = 4;
//public static final int Pt_MENUABLE = 0x08000000;
@@ -2389,7 +2399,7 @@ public static final int Pg_BITMAP_TRANSPARENT =
//public static final int Pt_TIMER_INITIAL = 1;
//public static final int Pt_TIMER_REPEAT = 2;
public static final int Pt_TOGGLE = 0x00000008;
-//public static final int Pt_TOP = 0;
+ public static final int Pt_TOP = 0;
public static final int Pt_TOP_ANCHORED_BOTTOM = 0x00000040;
//public static final int Pt_TOP_ANCHORED_RELATIVE = 0x00000004;
public static final int Pt_TOP_ANCHORED_TOP = 0x00000400;
@@ -2524,6 +2534,7 @@ public static final int MAX_FONT_TAG
public static final native int PfQueryFontInfo (byte[] font, FontQueryInfo info);
public static final native PhRect_t PfExtentWideText(PhRect_t extent, PhPoint_t pos, byte[] font, char[] str, int len);
public static final native PhRect_t PfExtentText(PhRect_t extent, PhPoint_t pos, int font, int str, int len);
+public static final native PhRect_t PfExtentText(PhRect_t extent, PhPoint_t pos, byte[] font, byte[] str, int len);
public static final native int PfQueryFonts(int symbol, int flags, int list, int n);
public static final native byte[] PfGenerateFontName(byte[] pkucDescription, int kuiFlags, int kuiSize, byte[] pucBuff);
//public static final native int PfFindFont(byte[] pkucDescription, int kulFlags, int kulSize);
@@ -2533,6 +2544,8 @@ public static final native byte[] PfGenerateFontName(byte[] pkucDescription, int
//public static final native int PfFontFlags(int ptsID);
//public static final native int PfConvertFontID(int ptsID);
+public static final native PhRect_t PgExtentMultiText(PhRect_t extent, PhPoint_t pos, byte[] font, byte[] str, int n, int linespacing);
+
public static final native int PgCreateGC (int size);
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);
@@ -2543,6 +2556,7 @@ public static final native int PgDrawILine (int x1, int y1, int x2, int y2);
public static final native int PgDrawIRect (int ulx, int uly, int lrx, int lry, int flags);
//public static final native int PgDrawText (char[] ptr, int len, short x, short y, int flags);
public static final native int PgDrawText (byte[] ptr, int len, short x, short y, int flags);
+public static final native int PgDrawMultiTextArea (byte[] text, int len, PhRect_t canvas, int text_flags, int canvas_flags, int linespacing);
public static final native int PgFlush ();
public static final native int PgSetFillColor (int color);
public static final native int PgSetStrokeColor (int color);
@@ -2569,6 +2583,7 @@ public static final native int PtClippedBlit (int widget, int src, PhPoint_t del
public static final native int PgSetDrawBufferSize (int cmd_buf_len);
public static final native int PhEventPeek (int buffer, int size);
+public static final native int PhEventNext (int buffer, int size);
public static final native int PhGetMsgSize (int event_buf);
public static final native int PhGetTile ();
public static final native int PhAddMergeTiles (int tiles, int add_tiles, int[] added);
@@ -2654,6 +2669,12 @@ public static final native int PtSyncWidget (int widget);
public static final native int PtFlush ();
public static final native int PtContainerGiveFocus (int widget, PhEvent_t event);
+public static final native int PtContainerFocusNext (int widget, PhEvent_t event);
+public static final native int PtContainerFocusPrev (int widget, PhEvent_t event);
+public static final native int PtGlobalFocusNext (int widget, PhEvent_t event);
+public static final native int PtGlobalFocusPrev (int widget, PhEvent_t event);
+public static final native int PtGlobalFocusNextContainer (int widget, PhEvent_t event);
+public static final native int PtGlobalFocusPrevContainer (int widget, PhEvent_t event);
public static final native int PtWidgetToBack (int widget);
public static final native int PtWidgetToFront (int widget);
@@ -2717,7 +2738,7 @@ public static final native void memmove (PhImage_t image, int address, int size)
//public static final native void memmove (int address, FontDetails details, int size);
public static final native void memmove (FontDetails details, int address, int size);
-//public static final native void memmove (int address, PhImage_t image, int size);
+public static final native void memmove (int address, PhPointerEvent_t image, int size);
public static final native void memmove (PhPointerEvent_t dest, int src, int size);
public static final native int PhGetData (int event);
@@ -2725,6 +2746,7 @@ public static final native int PhGetRects (int event);
//public static final native void memmove (int address, PhWindowEvent_t event, int size);
public static final native void memmove (PhEvent_t event, int address, int size);
+public static final native void memmove (int address, PhEvent_t event, int size);
public static final native int PtExtentWidget (int widget);
public static final native int PtExtentWidgetFamily (int widget);
@@ -2852,7 +2874,7 @@ public static final native int PtToolbar ();
//public static final native int PtColorPatch ();
//public static final native int PtColorPalette ();
-//public static final native int PtGroup ();
+public static final native int PtGroup ();
//public static final native int Pg_CM_RGB ();
//public static final native int Pg_CM_HSB ();
@@ -2890,4 +2912,16 @@ public static final native int PgShmemDestroy (int addr);
public static final native int PhRegionQuery (int rid, PhRegion_t region, PhRect_t rect, int data, int data_len);
//public static final native int PiGetPixelRGB (int image, short x, short y, int[] value);
+public static final native void memmove (PtContainerCallback_t dest, int src, int size);
+//public static final native void memmove (int dest, PtContainerCallback_t src, int size);
+
+public static final native void PtSendEventToWidget (int widget, int event);
+
+//public static final native void memmove (PhCursorDef_t dest, int src, int size);
+public static final native void memmove (int dest, PhCursorDef_t src, int size);
+
+public static final native void PgSetFillTransPat (byte [] pat);
+
+public static final native int PtInflateBalloon (int win, int me, int position, byte [] string, byte [] font, int fill, int text_color);
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgAlpha_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgAlpha_t.java
index ebf21fad67..7485fdfd4c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgAlpha_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgAlpha_t.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class PgAlpha_t {
@@ -21,4 +21,4 @@ public class PgAlpha_t {
public byte dest_global_alpha;
// char spare[2]; *** unused
public static final int sizeof = 104;
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgMap_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgMap_t.java
index e41f9bfd48..d25f90f9bf 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgMap_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgMap_t.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class PgMap_t {
@@ -13,4 +13,4 @@ public class PgMap_t {
public short bpp;
public int map;
public static final int sizeof = 12;
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhArea_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhArea_t.java
index ab892950c6..0a09362a26 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhArea_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhArea_t.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class PhArea_t {
@@ -11,4 +11,4 @@ public class PhArea_t {
public short size_w;
public short size_h;
public static final int sizeof = 8;
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhCursorDef_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhCursorDef_t.java
new file mode 100755
index 0000000000..1bfe5c26cd
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhCursorDef_t.java
@@ -0,0 +1,36 @@
+package org.eclipse.swt.internal.photon;
+ /*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+ public class PhCursorDef_t {
+// PhRegionDataHdr_t hdr;
+ public short hdr_len;
+ public short hdr_type;
+
+// PhPoint_t size1;
+ public short size1_x;
+ public short size1_y;
+// PhPoint_t offset1;
+ public short offset1_x;
+ public short offset1_y;
+ public int color1;
+ public byte bytesperline1;
+
+// byte zero1; // 3 bytes
+
+// PhPoint_t size2;
+ public short size2_x;
+ public short size2_y;
+// PhPoint_t offset2;
+ public short offset2_x;
+ public short offset2_y;
+ public int color2;
+ public byte bytesperline2;
+
+// byte Spare; // 14 bytes
+
+// byte images; // variable number of bytes
+
+ public static final int sizeof = 47;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhCursorInfo_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhCursorInfo_t.java
index 8249867c82..ad22c1e0ee 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhCursorInfo_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhCursorInfo_t.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class PhCursorInfo_t {
@@ -35,4 +35,4 @@ public class PhCursorInfo_t {
public int zero2;
public static final int sizeof = 60;
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhDim_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhDim_t.java
index 95ccd121d6..66021b3848 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhDim_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhDim_t.java
@@ -1,12 +1,12 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class PhDim_t {
public short w;
public short h;
public static final int sizeof = 4;
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhEvent_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhEvent_t.java
index ee5a6ab230..4b0461f844 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhEvent_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhEvent_t.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class PhEvent_t {
@@ -24,4 +24,4 @@ public class PhEvent_t {
public short num_rects;
public short data_len;
public static final int sizeof = 40;
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhImage_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhImage_t.java
index eaad75d4a4..539c1dee07 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhImage_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhImage_t.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class PhImage_t {
@@ -25,4 +25,4 @@ public class PhImage_t {
public int palette;
public int image;
public static final int sizeof = 56;
-} \ No newline at end of file
+}
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 3c74f4df11..1f0d2211b7 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class PhKeyEvent_t {
@@ -18,4 +18,4 @@ public class PhKeyEvent_t {
public short pos_y;
public short button_state;
public static final int sizeof = 26;
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPoint_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPoint_t.java
index fabd9f25fe..5bcca4457f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPoint_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPoint_t.java
@@ -1,12 +1,12 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class PhPoint_t {
public short x;
public short y;
public static final int sizeof = 4;
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPointerEvent_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPointerEvent_t.java
index 9240762c20..07c8cd3491 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPointerEvent_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPointerEvent_t.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class PhPointerEvent_t {
@@ -17,4 +17,4 @@ public class PhPointerEvent_t {
public int key_mods;
public int zero;
public static final int sizeof = 20;
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRect_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRect_t.java
index db6377c99a..0fe5db44e7 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRect_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRect_t.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class PhRect_t {
@@ -11,4 +11,4 @@ public class PhRect_t {
public short lr_x;
public short lr_y;
public static final int sizeof = 8;
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRegion_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRegion_t.java
index b3d1b78c96..b7012858f1 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRegion_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRegion_t.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class PhRegion_t {
@@ -29,4 +29,4 @@ public class PhRegion_t {
// public short zero3;
public static final int sizeof = 68;
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhTile_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhTile_t.java
index d006c2ade4..92f270ca42 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhTile_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhTile_t.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class PhTile_t {
@@ -13,4 +13,4 @@ public class PhTile_t {
public short rect_lr_y;
public int next;
public static final int sizeof = 12;
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhWindowEvent_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhWindowEvent_t.java
index f490159630..4084fa5911 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhWindowEvent_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhWindowEvent_t.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class PhWindowEvent_t {
@@ -19,4 +19,4 @@ public class PhWindowEvent_t {
public short input_group;
public int rsvd0, rsvd1, rsvd2, rsvd3;
public static final int sizeof = 40;
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtCallbackInfo_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtCallbackInfo_t.java
index 2ecde6b294..04b970a3fd 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtCallbackInfo_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtCallbackInfo_t.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class PtCallbackInfo_t {
@@ -11,4 +11,4 @@ public class PtCallbackInfo_t {
public int event;
public int cbdata;
public static final int sizeof = 16;
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtColorSelectInfo_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtColorSelectInfo_t.java
index 54dec671d7..bab9c5b694 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtColorSelectInfo_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtColorSelectInfo_t.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class PtColorSelectInfo_t {
@@ -24,4 +24,4 @@ public class PtColorSelectInfo_t {
public int rgb;
public int dialog;
public static final int sizeof = 52;
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtContainerCallback_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtContainerCallback_t.java
new file mode 100755
index 0000000000..a6d14e8f5e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtContainerCallback_t.java
@@ -0,0 +1,22 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
+public class PtContainerCallback_t {
+ public short new_size_ul_x;
+ public short new_size_ul_y;
+ public short new_size_lr_x;
+ public short new_size_lr_y;
+ public short old_size_ul_x;
+ public short old_size_ul_y;
+ public short old_size_lr_x;
+ public short old_size_lr_y;
+ public short new_dim_w;
+ public short new_dim_h;
+ public short old_dim_w;
+ public short old_dim_h;
+ public static final int sizeof = 24;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtFileSelectionInfo_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtFileSelectionInfo_t.java
index 0cc12aef00..852218383d 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtFileSelectionInfo_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtFileSelectionInfo_t.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class PtFileSelectionInfo_t {
@@ -22,4 +22,4 @@ public class PtFileSelectionInfo_t {
public int args;
public int [] spare = new int [4];
public static final int sizeof = 1500;
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtScrollbarCallback_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtScrollbarCallback_t.java
index aac48e6020..3185fabfb1 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtScrollbarCallback_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtScrollbarCallback_t.java
@@ -1,12 +1,12 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class PtScrollbarCallback_t {
public int action;
public int position;
public static final int sizeof = 8;
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTextCallback_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTextCallback_t.java
index abac0c47d9..77def5959a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTextCallback_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTextCallback_t.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class PtTextCallback_t {
@@ -15,4 +15,4 @@ public class PtTextCallback_t {
public int text;
public int doit;
public static final int sizeof = 30;
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTreeItem_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTreeItem_t.java
index 27f857a96c..d411b93bd9 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTreeItem_t.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTreeItem_t.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.internal.photon;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
public class PtTreeItem_t {
@@ -22,4 +22,4 @@ public class PtTreeItem_t {
// char string [1];
// byte string;
public static final int sizeof = 40;
-} \ No newline at end of file
+}
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
index b23dff6c03..41f7d95a58 100755
--- 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
@@ -1,14 +1,14 @@
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.*;
-/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
- */
-
/**
* This class stores and manages child items of a tree item.
* It provides protocol to query the index of an item relative
@@ -109,25 +109,20 @@ void deselectAll() {
treeItem.deselectAll();
}
}
-/**
- * Destroy all children of the receiver
- */
-void disposeItem() {
+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();
}
- doDispose();
- super.disposeItem();
+ super.dispose();
}
-/**
- * Subclasses should free resources here
- */
void doDispose() {
setChildren(null);
visibleItemCount = 0;
+ super.doDispose();
}
/**
* Answer the Vector containing the child items of the receiver.
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 92992ee18a..43c4aeddc7 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.*;
@@ -41,6 +41,37 @@ public void addSelectionListener (SelectionListener listener) {
addListener (SWT.DefaultSelection,typedListener);
}
+void click () {
+ int rid = OS.PtWidgetRid (handle);
+ if (rid == 0) return;
+ PhEvent_t event = new PhEvent_t ();
+ event.emitter_rid = rid;
+ event.emitter_handle = handle;
+ event.collector_rid = rid;
+ event.collector_handle = handle;
+ event.flags = OS.Ph_EVENT_DIRECT;
+ event.processing_flags = OS.Ph_FAKE_EVENT;
+ event.type = OS.Ph_EV_BUT_PRESS;
+ event.num_rects = 1;
+ PhPointerEvent_t pe = new PhPointerEvent_t ();
+ pe.click_count = 1;
+ pe.buttons = OS.Ph_BUTTON_SELECT;
+ PhRect_t rect = new PhRect_t ();
+ int ptr = OS.malloc (PhEvent_t.sizeof + PhPointerEvent_t.sizeof + PhRect_t.sizeof);
+ OS.memmove (ptr, event, PhEvent_t.sizeof);
+ OS.memmove (ptr + PhEvent_t.sizeof, rect, PhRect_t.sizeof);
+ OS.memmove (ptr + PhEvent_t.sizeof + PhRect_t.sizeof, pe, PhPointerEvent_t.sizeof);
+ OS.PtSendEventToWidget (handle, ptr);
+ OS.PtFlush ();
+ event.type = OS.Ph_EV_BUT_RELEASE;
+ event.subtype = OS.Ph_EV_RELEASE_REAL;
+ OS.memmove (ptr, event, PhEvent_t.sizeof);
+ OS.memmove (ptr + PhEvent_t.sizeof, rect, PhRect_t.sizeof);
+ OS.memmove (ptr + PhEvent_t.sizeof + PhRect_t.sizeof, pe, PhPointerEvent_t.sizeof);
+ OS.PtSendEventToWidget (handle, ptr);
+ OS.free (ptr);
+}
+
public Point computeSize (int wHint, int hHint, boolean changed) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -58,18 +89,32 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
OS.PtWidgetPreferredSize(handle, dim);
width = dim.w; height = dim.h;
if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ int [] args = {
+ OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 1
+ OS.Pt_ARG_MARGIN_HEIGHT, 0, 0, // 4
+ OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 7
+ OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 10
+ OS.Pt_ARG_MARGIN_TOP, 0, 0, // 13
+ OS.Pt_ARG_MARGIN_BOTTOM, 0, 0, // 16
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
PhRect_t rect = new PhRect_t ();
PhArea_t area = new PhArea_t ();
rect.lr_x = (short) (wHint - 1);
rect.lr_y = (short) (hHint - 1);
OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
- if (wHint != SWT.DEFAULT) width = area.size_w;
- if (hHint != SWT.DEFAULT) height = area.size_h;
+ if (wHint != SWT.DEFAULT) {
+ width = area.size_w + (args [1] * 2) + args [7] + args [10];
+ }
+ if (hHint != SWT.DEFAULT) {
+ height = area.size_h + (args [4] * 2) + args [13] + args [16];
+ }
}
return new Point (width, height);
}
void createHandle (int index) {
+ state |= HANDLE;
Display display = getDisplay ();
int parentHandle = parent.handle;
@@ -197,6 +242,11 @@ void hookEvents () {
OS.PtAddCallback (handle, OS.Pt_CB_ACTIVATE, windowProc, SWT.Selection);
}
+int processActivate (int info) {
+ if (setFocus ()) click ();
+ return OS.Pt_CONTINUE;
+}
+
int processPaint (int damage) {
if ((style & SWT.ARROW) != 0) {
OS.PtSuperClassDraw (OS.PtButton (), handle, damage);
@@ -324,6 +374,7 @@ public void setText (String string) {
ptr2 = OS.malloc (buffer2.length);
OS.memmove (ptr2, buffer2, buffer2.length);
}
+ 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 1eff950532..24007b320d 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
@@ -1,12 +1,13 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.*;
import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.graphics.*;
public class Canvas extends Composite {
Caret caret;
@@ -122,37 +123,9 @@ public void scroll (int destX, int destY, int x, int y, int width, int height, b
if (!isVisible ()) return;
boolean isVisible = (caret != null) && (caret.isVisible ());
if (isVisible) caret.hideCaret ();
- PhRect_t rect = new PhRect_t();
- rect.ul_x = (short)x;
- rect.ul_y = (short)y;
- rect.lr_x = (short)(x + width - 1);
- rect.lr_y = (short)(y + height - 1);
- PhPoint_t delta = new PhPoint_t();
- delta.x = (short)deltaX;
- delta.y = (short)deltaY;
- OS.PtFlush ();
- OS.PhBlit(OS.PtWidgetRid(handle), rect, delta);
- boolean overlaps = (destX < x + width) && (destY < y + height) &&
- (destX + width > x) && (destY + height > y);
- if (!overlaps) {
- OS.PtDamageExtent (handle, rect);
- } else {
- int src = OS.PhGetTile();
- int dest = OS.PhGetTile();
- OS.memmove(src, rect, PhRect_t.sizeof);
- OS.memmove(dest, rect, PhRect_t.sizeof);
- OS.PhTranslateTiles(dest, delta);
- int damage_tile = OS.PhClipTilings(src, dest, null);
- int[] damage_rects_count = new int[1];
- int damage_rects = OS.PhTilesToRects(damage_tile, damage_rects_count);
- OS.PhFreeTiles(dest);
- OS.PhFreeTiles(damage_tile);
- for (int i=0; i<damage_rects_count[0]; i++) {
- OS.memmove(rect, damage_rects + (i * PhRect_t.sizeof), PhRect_t.sizeof);
- OS.PtDamageExtent (handle, rect);
- }
- OS.free(damage_rects);
- }
+ GC gc = new GC (this);
+ gc.copyArea (x, y, width, height, destX, destY);
+ gc.dispose ();
if (isVisible) caret.showCaret ();
}
@@ -177,4 +150,4 @@ public void setCaret (Caret caret) {
}
}
-} \ No newline at end of file
+}
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 858ff99e8c..5d6a427547 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.photon.*;
@@ -219,4 +219,4 @@ boolean showCaret () {
isShowing = true;
return drawCaret ();
}
-} \ No newline at end of file
+}
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 15d71cf99d..dd2d8b6b81 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.*;
@@ -48,4 +48,4 @@ public void setRGB (RGB rgb) {
this.rgb = rgb;
}
-} \ No newline at end of file
+}
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 9b3723f87f..7fe9e578b3 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.*;
@@ -91,6 +91,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
}
void createHandle (int index) {
+ state |= HANDLE;
Display display = getDisplay ();
int clazz = display.PtComboBox;
int parentHandle = parent.handle;
@@ -185,6 +186,23 @@ public void clearSelection () {
OS.PtTextSetSelection (handle, new int [] {0}, new int [] {0});
}
+void deregister () {
+ super.deregister ();
+ int child = OS.PtWidgetChildBack (handle);
+ WidgetTable.remove (child);
+}
+
+int focusHandle () {
+
+ /*
+ * Fetuare in Photon. The combo box does not receive
+ * Pt_CB_GOT_FOCUS and Pt_CB_LOST_FOCUS callbacks itself.
+ * Only the internal PtText receives them. The fix is to
+ * add these callbacks in the internal PtText.
+ */
+ return OS.PtWidgetChildBack (handle);
+}
+
public String getItem (int index) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -309,6 +327,10 @@ public int getTextLimit () {
return args [1];
}
+boolean hasFocus () {
+ return OS.PtIsFocused (handle) != 0;
+}
+
void hookEvents () {
super.hookEvents ();
int windowProc = getDisplay ().windowProc;
@@ -319,7 +341,8 @@ void hookEvents () {
public int indexOf (String string) {
if (!isValidThread ()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error(SWT.ERROR_WIDGET_DISPOSED);
- return indexOf (string, 0);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ return OS.PtListItemPos(handle, buffer) - 1;
}
public int indexOf (String string, int start) {
@@ -328,8 +351,7 @@ public int indexOf (String string, int start) {
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
// NOT DONE - start is ignored
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- return OS.PtListItemPos(handle, buffer) - 1;
+ return indexOf (string);
}
int processModify (int info) {
@@ -353,6 +375,12 @@ int processSelection (int info) {
return OS.Pt_CONTINUE;
}
+void register () {
+ super.register ();
+ int child = OS.PtWidgetChildBack (handle);
+ WidgetTable.put (child, this);
+}
+
public void remove (int start, int end) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -494,4 +522,17 @@ public void setTextLimit (int limit) {
OS.PtSetResources (handle, args.length / 3, args);
}
-} \ No newline at end of file
+int traversalCode (int key_sym, PhKeyEvent_t ke) {
+ int code = super.traversalCode (key_sym, ke);
+ if (key_sym == OS.Pk_Up || key_sym == OS.Pk_Down) {
+ code &= ~(SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS);
+ }
+ if ((style & SWT.READ_ONLY) == 0) {
+ if (key_sym == OS.Pk_Up || key_sym == OS.Pk_Down) {
+ code &= ~(SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS);
+ }
+ }
+ return code;
+}
+
+}
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 40fc195c5a..b120e52b4e 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.photon.*;
@@ -72,6 +72,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
}
void createHandle (int index) {
+ state |= HANDLE | CANVAS;
int parentHandle = parent.handle;
createScrolledHandle (parentHandle);
}
@@ -89,27 +90,36 @@ void createScrollBars () {
void createScrolledHandle (int parentHandle) {
int etches = OS.Pt_ALL_ETCHES | OS.Pt_ALL_OUTLINES;
int [] args = new int [] {
- /*
- * Bug in Photon. We must set Pt_GETS_FOCUS or Photon will
- * segment fault when no widget has focus and a key is pressed.
- */
- OS.Pt_ARG_FLAGS, OS.Pt_GETS_FOCUS, OS.Pt_GETS_FOCUS,
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_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 ();
int clazz = display.PtContainer;
args = new int [] {
- OS.Pt_ARG_FLAGS, OS.Pt_GETS_FOCUS, OS.Pt_GETS_FOCUS,
+ OS.Pt_ARG_CONTAINER_FLAGS, 0, OS.Pt_ENABLE_CUA | OS.Pt_ENABLE_CUA_ARROWS,
OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
};
handle = OS.PtCreateWidget (clazz, scrolledHandle, args.length / 3, args);
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
createScrollBars ();
}
+
+public Rectangle getClientArea () {
+ 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);
+}
public Control [] getChildren () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
@@ -137,6 +147,10 @@ boolean hasBorder () {
return (style & SWT.BORDER) != 0;
}
+boolean hasFocus () {
+ return OS.PtIsFocused (handle) == 2;
+}
+
void hookEvents () {
super.hookEvents ();
int windowProc = getDisplay ().windowProc;
@@ -169,8 +183,39 @@ public void layout (boolean changed) {
layout.layout (this, changed);
}
+int processMouse (int info) {
+
+ /* Set focus for a canvas with no children */
+ if (OS.PtWidgetChildFront (handle) == 0) {
+ if ((state & CANVAS) != 0 && (style & SWT.NO_FOCUS) == 0) {
+ if (info == 0) return OS.Pt_END;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.event == 0) return OS.Pt_END;
+ PhEvent_t ev = new PhEvent_t ();
+ OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
+ switch (ev.type) {
+ case OS.Ph_EV_BUT_PRESS: {
+ int data = OS.PhGetData (cbinfo.event);
+ if (data == 0) return OS.Pt_END;
+ PhPointerEvent_t pe = new PhPointerEvent_t ();
+ OS.memmove (pe, data, PhPointerEvent_t.sizeof);
+ if (pe.buttons == OS.Ph_BUTTON_SELECT) {
+ setFocus ();
+ }
+ }
+ }
+ }
+ }
+ return super.processMouse (info);
+}
+
int processPaint (int damage) {
- OS.PtSuperClassDraw (OS.PtContainer (), handle, damage);
+ if ((state & CANVAS) != 0) {
+ if ((style & SWT.NO_BACKGROUND) == 0) {
+ OS.PtSuperClassDraw (OS.PtContainer (), handle, damage);
+ }
+ }
return super.processPaint (damage);
}
@@ -179,12 +224,17 @@ int processResize (int info) {
PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
if (cbinfo.cbdata == 0) return OS.Pt_CONTINUE;
+ PtContainerCallback_t cbdata = new PtContainerCallback_t ();
+ OS.memmove(cbdata, cbinfo.cbdata, PtContainerCallback_t.sizeof);
+ if (cbdata.new_dim_w == cbdata.old_dim_w && cbdata.new_dim_h == cbdata.old_dim_h) {
+ return OS.Pt_CONTINUE;
+ }
sendEvent (SWT.Resize);
if (layout != null) layout (false);
return OS.Pt_CONTINUE;
}
-void releaseWidget () {
+void releaseChildren () {
Control [] children = _getChildren ();
for (int i=0; i<children.length; i++) {
Control child = children [i];
@@ -193,6 +243,10 @@ void releaseWidget () {
child.releaseHandle ();
}
}
+}
+
+void releaseWidget () {
+ releaseChildren ();
super.releaseWidget ();
}
@@ -207,46 +261,66 @@ boolean sendResize () {
}
void resizeClientArea (int width, int height) {
+ if (scrolledHandle == 0) return;
+
+ /* Calculate the insets */
+ int [] args = {
+ OS.Pt_ARG_BASIC_FLAGS, 0, 0,
+ OS.Pt_ARG_BEVEL_WIDTH, 0, 0,
+ };
+ OS.PtGetResources (scrolledHandle, args.length / 3, args);
+ int flags = args [1];
+ int bevel = args [4];
+ int top = 0, left = 0, right = 0, bottom = 0;
+ if ((flags & OS.Pt_TOP_ETCH) != 0) top++;
+ if ((flags & OS.Pt_TOP_OUTLINE) != 0) top++;
+ if ((flags & OS.Pt_TOP_INLINE) != 0) top++;
+ if ((flags & OS.Pt_TOP_BEVEL) != 0) top += bevel;
+ if ((flags & OS.Pt_BOTTOM_ETCH) != 0) bottom++;
+ if ((flags & OS.Pt_BOTTOM_OUTLINE) != 0) bottom++;
+ if ((flags & OS.Pt_BOTTOM_INLINE) != 0) bottom++;
+ if ((flags & OS.Pt_BOTTOM_BEVEL) != 0) bottom += bevel;
+ if ((flags & OS.Pt_RIGHT_ETCH) != 0) right++;
+ if ((flags & OS.Pt_RIGHT_OUTLINE) != 0) right++;
+ if ((flags & OS.Pt_RIGHT_INLINE) != 0) right++;
+ if ((flags & OS.Pt_RIGHT_BEVEL) != 0) right += bevel;
+ if ((flags & OS.Pt_LEFT_ETCH) != 0) left++;
+ if ((flags & OS.Pt_LEFT_OUTLINE) != 0) left++;
+ if ((flags & OS.Pt_LEFT_INLINE) != 0) left++;
+ if ((flags & OS.Pt_LEFT_BEVEL) != 0) left += bevel;
+
+ int clientWidth = width - (left + right);
+ int clientHeight = height - (top + bottom);
+
int vBarWidth = 0, hBarHeight = 0;
boolean isVisibleHBar = horizontalBar != null && horizontalBar.getVisible ();
boolean isVisibleVBar = verticalBar != null && verticalBar.getVisible ();
if (isVisibleHBar) {
- int [] args = {OS.Pt_ARG_HEIGHT, 0, 0};
+ args = new int [] {OS.Pt_ARG_HEIGHT, 0, 0};
OS.PtGetResources (horizontalBar.handle, args.length / 3, args);
- height = height - (hBarHeight = args [1]);
+ clientHeight -= (hBarHeight = args [1]);
}
if (isVisibleVBar) {
- int [] args = {OS.Pt_ARG_WIDTH, 0, 0};
+ args = new int [] {OS.Pt_ARG_WIDTH, 0, 0};
OS.PtGetResources (verticalBar.handle, args.length / 3, args);
- width = width - (vBarWidth = args [1]);
- }
-
- //NOT DONE - used widget canvas to compute insets
- int left = 0, right = 0;
- if (hasBorder ()) {
- left = 2;
- if (isVisibleHBar && isVisibleVBar) right = 3;
+ clientWidth -= (vBarWidth = args [1]);
}
if (isVisibleHBar) {
- horizontalBar.setBounds (-left, height - left, width + right, hBarHeight);
+ horizontalBar.setBounds (0, clientHeight, clientWidth, hBarHeight);
}
if (isVisibleVBar) {
- verticalBar.setBounds (width - left, -left, vBarWidth, height + right);
+ verticalBar.setBounds (clientWidth, 0, vBarWidth, clientHeight);
}
-
- PhArea_t area = new PhArea_t ();
- area.size_w = (short) (Math.max (width - (left * 2), 0));
- area.size_h = (short) (Math.max (height - (left * 2), 0));
- int ptr = OS.malloc (PhArea_t.sizeof);
- OS.memmove (ptr, area, PhArea_t.sizeof);
- int [] args = {OS.Pt_ARG_AREA, ptr, 0};
+ args = new int [] {
+ OS.Pt_ARG_WIDTH, Math.max (clientWidth, 0), 0,
+ OS.Pt_ARG_HEIGHT, Math.max (clientHeight, 0), 0,
+ };
OS.PtSetResources (handle, args.length / 3, args);
- OS.free (ptr);
}
void setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
- if (resize) resizeClientArea (width, height);
super.setBounds (x, y, width, height, move, resize);
+ if (resize) resizeClientArea (width, height);
}
public void setLayout (Layout layout) {
@@ -255,4 +329,9 @@ public void setLayout (Layout layout) {
this.layout = layout;
}
-} \ No newline at end of file
+int traversalCode (int key_sym, PhKeyEvent_t ke) {
+ if ((state & CANVAS) != 0 && hooks (SWT.KeyDown)) return 0;
+ 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 079c6efd82..e9dd1b72c3 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.photon.*;
@@ -14,6 +14,8 @@ public abstract class Control extends Widget implements Drawable {
Composite parent;
Menu menu;
Object layoutData;
+ String toolTipText;
+ int toolTipHandle;
Control () {
/* Do nothing */
@@ -109,7 +111,8 @@ public boolean forceFocus () {
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
int shellHandle = OS.PtFindDisjoint (handle);
OS.PtWindowToFront (shellHandle);
- return handle != OS.PtContainerGiveFocus (handle, null);
+ OS.PtContainerGiveFocus (handle, null);
+ return hasFocus ();
}
public Point computeSize (int wHint, int hHint) {
@@ -147,6 +150,7 @@ public Color getBackground () {
OS.PtGetResources (handle, args.length / 3, args);
return Color.photon_new (getDisplay (), args [1]);
}
+
public Font getFont () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -169,6 +173,7 @@ public Font getFont () {
}
return Font.photon_new (getDisplay (), font);
}
+
public Color getForeground () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -183,15 +188,17 @@ public int getBorderWidth () {
int topHandle = topHandle ();
int [] args = {
OS.Pt_ARG_BASIC_FLAGS, 0, 0,
+ OS.Pt_ARG_FLAGS, 0, 0,
// OS.Pt_ARG_BEVEL_WIDTH, 0, 0,
};
OS.PtGetResources (topHandle, args.length / 3, args);
+ if ((args [4] & OS.Pt_HIGHLIGHTED) == 0) return 0;
int border = 0;
int flags = args [1];
if ((flags & OS.Pt_ALL_ETCHES) != 0) border++;
if ((flags & OS.Pt_ALL_OUTLINES) != 0) border++;
if ((flags & OS.Pt_ALL_INLINES) != 0) border++;
-// if ((flags & OS.Pt_ALL_BEVELS) != 0) border += args [4];
+// if ((flags & OS.Pt_ALL_BEVELS) != 0) border += args [7];
return border;
}
@@ -245,6 +252,23 @@ public Composite getParent () {
return parent;
}
+Control [] getPath () {
+ int count = 0;
+ Shell shell = getShell ();
+ Control control = this;
+ while (control != shell) {
+ count++;
+ control = control.parent;
+ }
+ control = this;
+ Control [] result = new Control [count];
+ while (control != shell) {
+ result [--count] = control;
+ control = control.parent;
+ }
+ return result;
+}
+
public Point getSize () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -257,7 +281,7 @@ public Point getSize () {
public String getToolTipText () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return null;
+ return toolTipText;
}
public Shell getShell () {
@@ -276,18 +300,24 @@ public boolean getVisible () {
}
boolean hasFocus () {
- return OS.PtIsFocused (handle) == 2;
+ return OS.PtIsFocused (handle) != 0;
}
void hookEvents () {
int windowProc = getDisplay ().windowProc;
- OS.PtAddEventHandler (handle, OS.Ph_EV_KEY, windowProc, SWT.KeyDown);
+ int focusHandle = focusHandle ();
+ OS.PtAddFilterCallback (handle, OS.Ph_EV_KEY, windowProc, SWT.KeyDown);
OS.PtAddEventHandler (handle, OS.Ph_EV_BUT_PRESS, windowProc, SWT.MouseDown);
OS.PtAddEventHandler (handle, OS.Ph_EV_BUT_RELEASE, windowProc, SWT.MouseUp);
OS.PtAddEventHandler (handle, OS.Ph_EV_PTR_MOTION, windowProc, SWT.MouseMove);
OS.PtAddEventHandler (handle, OS.Ph_EV_BOUNDARY, windowProc, SWT.MouseEnter);
- OS.PtAddCallback (handle, OS.Pt_CB_GOT_FOCUS, windowProc, SWT.FocusIn);
- OS.PtAddCallback (handle, OS.Pt_CB_LOST_FOCUS, windowProc, SWT.FocusOut);
+ OS.PtAddCallback (focusHandle, OS.Pt_CB_GOT_FOCUS, windowProc, SWT.FocusIn);
+ OS.PtAddCallback (focusHandle, OS.Pt_CB_LOST_FOCUS, windowProc, SWT.FocusOut);
+ OS.PtAddCallback (handle, OS.Pt_CB_MENU, windowProc, SWT.Show);
+}
+
+int focusHandle () {
+ return handle;
}
public int internal_new_GC (GCData data) {
@@ -384,6 +414,30 @@ int processPaint (int damage) {
int processFocusIn (int info) {
sendEvent (SWT.FocusIn);
+ if (isDisposed ()) return OS.Pt_CONTINUE;
+
+ int index = 0;
+ Shell shell = getShell ();
+ Control [] focusIn = getPath ();
+ Control lastFocus = shell.lastFocus;
+ if (lastFocus != null) {
+ if (!lastFocus.isDisposed ()) {
+ Control [] focusOut = lastFocus.getPath ();
+ int length = Math.min (focusIn.length, focusOut.length);
+ while (index < length) {
+ if (focusIn [index] != focusOut [index]) break;
+ index++;
+ }
+ for (int i=focusOut.length-1; i>=index; --i) {
+ focusOut [i].sendEvent (SWT.Deactivate);
+ }
+ }
+ shell.lastFocus = null;
+ }
+ for (int i=focusIn.length-1; i>=index; --i) {
+ focusIn [i].sendEvent (SWT.Activate);
+ }
+
/*
* Feature in Photon. Cannot return Pt_END
* or the text widget will not take focus.
@@ -393,6 +447,20 @@ int processFocusIn (int info) {
int processFocusOut (int info) {
sendEvent (SWT.FocusOut);
+ if (isDisposed ()) return OS.Pt_CONTINUE;
+
+ Shell shell = getShell ();
+ shell.lastFocus = this;
+ Display display = getDisplay ();
+ Control focusControl = display.getFocusControl ();
+ if (focusControl == null || shell != focusControl.getShell ()) {
+ Control [] focusOut = getPath ();
+ for (int i=focusOut.length-1; i>=0; --i) {
+ focusOut [i].sendEvent (SWT.Deactivate);
+ }
+ shell.lastFocus = null;
+ }
+
/*
* Feature in Photon. Cannot return Pt_END
* or the text widget will not take focus.
@@ -401,27 +469,21 @@ int processFocusOut (int info) {
}
int processKey (int info) {
- if (info == 0) return OS.Pt_END;
+ if (!hasFocus ()) return OS.Pt_PROCESS;
+ if (info == 0) return OS.Pt_PROCESS;
PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
- if (cbinfo.event == 0) return OS.Pt_END;
+ if (cbinfo.event == 0) return OS.Pt_PROCESS;
PhEvent_t ev = new PhEvent_t ();
OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
+ if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
+ return OS.Pt_PROCESS;
+ }
int data = OS.PhGetData (cbinfo.event);
- if (data == 0) return OS.Pt_END;
+ if (data == 0) return OS.Pt_PROCESS;
PhKeyEvent_t ke = new PhKeyEvent_t ();
OS.memmove (ke, data, PhKeyEvent_t.sizeof);
- /*
- * Feature in Photon. The multi-line text widget consumes
- * key down events. The fix is to use a filter callback
- * for the text widget to see the key down. The following
- * code ignores key up when called from a filter callback.
- */
- if (cbinfo.reason == OS.Pt_CB_FILTER) {
- if ((ke.key_flags & (OS.Pk_KF_Key_Down | OS.Pk_KF_Key_Repeat)) == 0) {
- return OS.Pt_PROCESS;
- }
- }
+
/*
* Feature in Photon. When the user presses certain keys
* (such as the arrow keys), Photon sends 2 event for one
@@ -431,7 +493,7 @@ int processKey (int info) {
* first event.
*/
if (ke.key_flags == OS.Pk_KF_Scan_Valid) {
- return (cbinfo.reason == OS.Pt_CB_FILTER) ? OS.Pt_PROCESS : OS.Pt_END;
+ return OS.Pt_PROCESS;
}
if ((ke.key_flags & OS.Pk_KF_Key_Repeat) != 0) {
if ((ke.key_flags & OS.Pk_KF_Sym_Valid) != 0) {
@@ -442,16 +504,45 @@ int processKey (int info) {
case OS.Pk_Control_R:
case OS.Pk_Shift_L:
case OS.Pk_Shift_R:
- /*
- * Bug in Photon. Despite the fact that we return Pt_END,
- * for some reason, Photon continues to forward the event
- * to the parent. The fix is to change the event type to
- * zero. This doesn't stop the forwarding but makes the
- * event unknown.
- */
- if (cbinfo.reason == OS.Pt_CB_FILTER) return OS.Pt_PROCESS;
- OS.memmove (cbinfo.event, new int [1], 4);
- return OS.Pt_END;
+ return OS.Pt_PROCESS;
+ }
+ }
+ }
+
+ if ((ke.key_flags & (OS.Pk_KF_Key_Down | OS.Pk_KF_Key_Repeat)) != 0) {
+
+ /*
+ * Fetuare in Photon. The key_sym value is not valid when Ctrl
+ * or Alt is pressed. The fix is to detect this case and try to
+ * use the key_cap value.
+ */
+ int key = ke.key_sym;
+ if ((ke.key_flags & OS.Pk_KF_Sym_Valid) == 0) {
+ key = 0;
+ if ((ke.key_flags & OS.Pk_KF_Cap_Valid) != 0) {
+ if (ke.key_cap == OS.Pk_Tab && (ke.key_mods & OS.Pk_KM_Ctrl) != 0) {
+ key = OS.Pk_Tab;
+ }
+ }
+ }
+ switch (key) {
+ case OS.Pk_Escape:
+ case OS.Pk_Return:
+ case OS.Pk_KP_Tab:
+ case OS.Pk_Tab:
+ case OS.Pk_Up:
+ case OS.Pk_Down:
+ case OS.Pk_Left:
+ case OS.Pk_Right: {
+ if (key != OS.Pk_Return) {
+ ev.processing_flags |= OS.Ph_NOT_CUAKEY;
+ OS.memmove (cbinfo.event, ev, PhEvent_t.sizeof);
+ }
+ if (translateTraversal (key, ke)) {
+ ev.processing_flags |= OS.Ph_CONSUMED;
+ OS.memmove (cbinfo.event, ev, PhEvent_t.sizeof);
+ return OS.Pt_PROCESS;
+ }
}
}
}
@@ -469,12 +560,12 @@ int processKey (int info) {
case OS.Pk_BackSpace: event.character = '\b'; break;
case OS.Pk_Tab: event.character = '\t'; break;
case OS.Pk_Linefeed: event.character = '\n'; break;
- case OS.Pk_Clear: event.character = 0xB; break;
- case OS.Pk_Return: event.character = '\r'; break;
+ case OS.Pk_Clear: event.character = 0xB; break;
+ case OS.Pk_Return: event.character = '\r'; break;
case OS.Pk_Pause: event.character = 0x13; break;
case OS.Pk_Scroll_Lock: event.character = 0x14; break;
- case OS.Pk_Escape: event.character = 0x1B; break;
- case OS.Pk_Delete: event.character = 0x7F; break;
+ case OS.Pk_Escape: event.character = 0x1B; break;
+ case OS.Pk_Delete: event.character = 0x7F; break;
default:
event.character = (char) ke.key_sym;
}
@@ -482,42 +573,14 @@ int processKey (int info) {
display.lastKey = event.keyCode;
display.lastAscii = event.character;
}
- if ((ke.key_mods & OS.Pk_KM_Alt) != 0) {
- if (type != SWT.KeyDown || event.keyCode != SWT.ALT) {
- event.stateMask |= SWT.ALT;
- }
- }
- if ((ke.key_mods & OS.Pk_KM_Shift) != 0) {
- if (type != SWT.KeyDown || event.keyCode != SWT.SHIFT) {
- event.stateMask |= SWT.SHIFT;
- }
- }
- if ((ke.key_mods & OS.Pk_KM_Ctrl) != 0) {
- if (type != SWT.KeyDown || event.keyCode != SWT.CONTROL) {
- event.stateMask |= SWT.CONTROL;
- }
- }
- if ((ke.button_state & OS.Ph_BUTTON_SELECT) != 0) event.stateMask |= SWT.BUTTON1;
- if ((ke.button_state & OS.Ph_BUTTON_ADJUST) != 0) event.stateMask |= SWT.BUTTON2;
- if ((ke.button_state & OS.Ph_BUTTON_MENU) != 0) event.stateMask |= SWT.BUTTON3;
+ setKeyState(event, ke);
if (type == SWT.KeyUp) {
if (event.keyCode == 0) event.keyCode = display.lastKey;
if (event.character == 0) event.character = (char) display.lastAscii;
- if (event.keyCode == SWT.ALT) event.stateMask |= SWT.ALT;
- if (event.keyCode == SWT.SHIFT) event.stateMask |= SWT.SHIFT;
- if (event.keyCode == SWT.CONTROL) event.stateMask |= SWT.CONTROL;
}
postEvent (type, event);
- /*
- * Bug in Photon. Despite the fact that we return Pt_END,
- * for some reason, Photon continues to forward the event
- * to the parent. The fix is to change the event type to
- * zero. This doesn't stop the forwarding but makes the
- * event unknown.
- */
- if (cbinfo.reason == OS.Pt_CB_FILTER) return OS.Pt_PROCESS;
- OS.memmove (cbinfo.event, new int [1], 4);
- return OS.Pt_END;
+
+ return OS.Pt_PROCESS;
}
int processMouse (int info) {
@@ -527,6 +590,9 @@ int processMouse (int info) {
if (cbinfo.event == 0) return OS.Pt_END;
PhEvent_t ev = new PhEvent_t ();
OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
+ if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
+ return OS.Pt_CONTINUE;
+ }
Event event = new Event ();
switch (ev.type) {
case OS.Ph_EV_BUT_PRESS:
@@ -556,43 +622,25 @@ int processMouse (int info) {
OS.memmove (pe, data, PhPointerEvent_t.sizeof);
event.x = pe.pos_x + ev.translation_x;
event.y = pe.pos_y + ev.translation_y;
- int type = ev.type;
- int buttons = pe.buttons;
- int key_mods = pe.key_mods;
- int button_state = pe.button_state;
- int click_count = pe.click_count;
- switch (buttons) {
+ 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;
}
- if ((key_mods & OS.Pk_KM_Alt) != 0) event.stateMask |= SWT.ALT;
- if ((key_mods & OS.Pk_KM_Shift) != 0) event.stateMask |= SWT.SHIFT;
- if ((key_mods & OS.Pk_KM_Ctrl) != 0) event.stateMask |= SWT.CONTROL;
- 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 && (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 (type == OS.Ph_EV_BUT_RELEASE) {
- 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;
- }
+ setMouseState (event, pe);
postEvent (event.type, event);
- if (type == OS.Ph_EV_BUT_PRESS && click_count == 2) {
- postEvent (SWT.MouseDoubleClick, event);
+ if (ev.type == OS.Ph_EV_BUT_PRESS && pe.click_count == 2) {
+ Event clickEvent = new Event ();
+ clickEvent.time = event.time;
+ clickEvent.x = event.x;
+ clickEvent.y = event.y;
+ clickEvent.button = event.button;
+ clickEvent.stateMask = event.stateMask;
+ postEvent (SWT.MouseDoubleClick, clickEvent);
}
- return OS.Pt_END;
+ ev.processing_flags |= OS.Ph_CONSUMED;
+ OS.memmove (cbinfo.event, ev, PhEvent_t.sizeof);
+ return OS.Pt_CONTINUE;
}
int processMouseEnter (int info) {
@@ -617,11 +665,32 @@ int processMouseEnter (int info) {
case OS.Ph_EV_PTR_LEAVE:
case OS.Ph_EV_PTR_LEAVE_TO_CHILD:
sendEvent (SWT.MouseExit, event);
+ break;
+ case OS.Ph_EV_PTR_STEADY:
+ postEvent (SWT.MouseHover, event);
+ destroyToolTip (toolTipHandle);
+ toolTipHandle = createToolTip (toolTipText, handle, getFont ().handle);
+ break;
+ case OS.Ph_EV_PTR_UNSTEADY:
+ destroyToolTip (toolTipHandle);
+ toolTipHandle = 0;
break;
}
return OS.Pt_END;
}
+int processShow (int info) {
+ if (info == 0) return OS.Pt_END;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.reason == OS.Pt_CB_MENU) {
+ if (menu != null && !menu.isDisposed ()) {
+ menu.setVisible (true);
+ }
+ }
+ return OS.Pt_CONTINUE;
+}
+
void realizeWidget() {
int parentHandle = parent.handle;
if (OS.PtWidgetIsRealized (parentHandle)) {
@@ -629,6 +698,16 @@ void realizeWidget() {
}
}
+void releaseWidget () {
+ super.releaseWidget ();
+ if (menu != null && !menu.isDisposed ()) {
+ menu.dispose ();
+ }
+ menu = null;
+ parent = null;
+ layoutData = null;
+}
+
public void redraw () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -789,9 +868,28 @@ public void setCursor (Cursor cursor) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
int type = OS.Ph_CURSOR_INHERIT;
- if (cursor != null) type = cursor.handle;
- int [] args = {OS.Pt_ARG_CURSOR_TYPE, type, 0};
+ int bitmap = 0;
+ if (cursor != null) {
+ type = cursor.type;
+ bitmap = cursor.bitmap;
+ }
+ int [] args = new int []{
+ OS.Pt_ARG_CURSOR_TYPE, type, 0,
+ OS.Pt_ARG_BITMAP_CURSOR, bitmap, 0,
+ };
OS.PtSetResources (handle, args.length / 3, args);
+
+ /*
+ * Bug in Photon. For some reason, the widget cursor will
+ * not change, when the new cursor is a bitmap cursor, if
+ * the flag Ph_CURSOR_NO_INHERIT is reset. The fix is to reset
+ * this flag after changing the cursor type to Ph_CURSOR_BITMAP.
+ */
+ if (type == OS.Ph_CURSOR_BITMAP) {
+ type &= ~OS.Ph_CURSOR_NO_INHERIT;
+ args = new int []{OS.Pt_ARG_CURSOR_TYPE, type, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+ }
}
public void setEnabled (boolean enabled) {
@@ -831,18 +929,20 @@ void sendPaintEvent (int damage) {
/* Send the paint event */
PhTile_t tile = new PhTile_t ();
OS.memmove (tile, damage, PhTile_t.sizeof);
- Event event = new Event ();
- event.x = tile.rect_ul_x;
- event.y = tile.rect_ul_y;
- event.width = tile.rect_lr_x - tile.rect_ul_x + 1;
- event.height = tile.rect_lr_y - tile.rect_ul_y + 1;
- Region region = Region.photon_new (tile.next);
- GC gc = event.gc = new GC (this);
- gc.setClipping (region);
- sendEvent (SWT.Paint, event);
- gc.dispose ();
+ if (tile.rect_ul_x != tile.rect_lr_x || tile.rect_ul_y != tile.rect_lr_y) {
+ Event event = new Event ();
+ event.x = tile.rect_ul_x;
+ event.y = tile.rect_ul_y;
+ event.width = tile.rect_lr_x - tile.rect_ul_x + 1;
+ event.height = tile.rect_lr_y - tile.rect_ul_y + 1;
+ Region region = Region.photon_new (tile.next);
+ GC gc = event.gc = new GC (this);
+ gc.setClipping (region);
+ sendEvent (SWT.Paint, event);
+ gc.dispose ();
+ event.gc = null;
+ }
OS.PhFreeTiles (damage);
- event.gc = null;
}
boolean sendResize () {
@@ -882,16 +982,32 @@ public void setForeground (Color color) {
OS.PtSetResources (handle, args.length / 3, args);
}
-public void setMenu (Menu menu) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- this.menu = menu;
-}
-
-public boolean setParent (Composite parent) {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- return false;
+void setKeyState(Event event, PhKeyEvent_t ke) {
+ int key_mods = ke.key_mods;
+ int button_state = ke.button_state;
+ if ((key_mods & OS.Pk_KM_Alt) != 0) {
+ if (event.type != SWT.KeyDown || event.keyCode != SWT.ALT) {
+ event.stateMask |= SWT.ALT;
+ }
+ }
+ if ((key_mods & OS.Pk_KM_Shift) != 0) {
+ if (event.type != SWT.KeyDown || event.keyCode != SWT.SHIFT) {
+ event.stateMask |= SWT.SHIFT;
+ }
+ }
+ if ((key_mods & OS.Pk_KM_Ctrl) != 0) {
+ if (event.type != SWT.KeyDown || event.keyCode != SWT.CONTROL) {
+ event.stateMask |= SWT.CONTROL;
+ }
+ }
+ 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 (event.type == SWT.KeyUp) {
+ if (event.keyCode == SWT.ALT) event.stateMask |= SWT.ALT;
+ if (event.keyCode == SWT.SHIFT) event.stateMask |= SWT.SHIFT;
+ if (event.keyCode == SWT.CONTROL) event.stateMask |= SWT.CONTROL;
+ }
}
public void setLayoutData (Object layoutData) {
@@ -913,6 +1029,51 @@ public void setLocation (Point location) {
setLocation (location.x, location.y);
}
+public void setMenu (Menu menu) {
+ 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,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ this.menu = menu;
+}
+
+void setMouseState(Event event, PhPointerEvent_t pe) {
+ int key_mods = pe.key_mods;
+ int buttons = pe.buttons;
+ int button_state = pe.button_state;
+ if ((key_mods & OS.Pk_KM_Alt) != 0) event.stateMask |= SWT.ALT;
+ if ((key_mods & OS.Pk_KM_Shift) != 0) event.stateMask |= SWT.SHIFT;
+ if ((key_mods & OS.Pk_KM_Ctrl) != 0) event.stateMask |= SWT.CONTROL;
+ 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 (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;
+ }
+}
+
+public boolean setParent (Composite parent) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return false;
+}
+
public void setSize (Point size) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -954,18 +1115,35 @@ public void setVisible (boolean visible) {
public void setToolTipText (String string) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ toolTipText = string;
}
void setZOrder() {
OS.PtWidgetToBack (topHandle ());
}
+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;
+ }
+ }
+ }
+ }
+}
+
public Point toControl (Point point) {
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 (x [0] - point.x, y [0] - point.y);
+ return new Point (point.x - x [0], point.y - y [0]);
}
public Point toDisplay (Point point) {
@@ -976,12 +1154,119 @@ public Point toDisplay (Point point) {
return new Point (point.x + x [0], point.y + y [0]);
}
+boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
+ int detail = 0;
+ boolean shift = (phEvent.key_mods & OS.Pk_KM_Shift) != 0;
+ boolean control = (phEvent.key_mods & OS.Pk_KM_Ctrl) != 0;
+ switch (key_sym) {
+ case OS.Pk_Escape:
+ Shell shell = getShell ();
+ if (shell.parent == null) return false;
+ if (!shell.isVisible () || !shell.isEnabled ()) return false;
+ detail = SWT.TRAVERSE_ESCAPE;
+ break;
+ case OS.Pk_Return:
+ Button button = menuShell ().getDefaultButton ();
+ if (button == null || button.isDisposed ()) return false;
+ if (!button.isVisible () || !button.isEnabled ()) return false;
+ detail = SWT.TRAVERSE_RETURN;
+ break;
+ case OS.Pk_Tab:
+ case OS.Pk_KP_Tab:
+ detail = SWT.TRAVERSE_TAB_NEXT;
+ if (shift) detail = SWT.TRAVERSE_TAB_PREVIOUS;
+ break;
+ case OS.Pk_Up:
+ case OS.Pk_Left:
+ detail = SWT.TRAVERSE_ARROW_PREVIOUS;
+ break;
+ case OS.Pk_Down:
+ case OS.Pk_Right:
+ detail = SWT.TRAVERSE_ARROW_NEXT;
+ break;
+ default:
+ return false;
+ }
+ boolean doit = (detail & traversalCode (key_sym, phEvent)) != 0;
+ if (!doit && control && (key_sym == OS.Pk_Tab || key_sym == OS.Pk_Tab)) {
+ doit = true;
+ control = false;
+ }
+ if (hooks (SWT.Traverse)) {
+ Event event = new Event();
+ event.doit = doit;
+ event.detail = detail;
+ setKeyState (event, phEvent);
+ sendEvent (SWT.Traverse, event);
+ if (isDisposed ()) return true;
+ doit = event.doit;
+ detail = event.detail;
+ }
+ if (doit) {
+ switch (detail) {
+ case SWT.TRAVERSE_ESCAPE: return traverseEscape ();
+ case SWT.TRAVERSE_RETURN: return traverseReturn ();
+ case SWT.TRAVERSE_TAB_NEXT: return traverseGroup (true, control);
+ case SWT.TRAVERSE_TAB_PREVIOUS: return traverseGroup (false, control);
+ case SWT.TRAVERSE_ARROW_NEXT: return traverseItem (true);
+ case SWT.TRAVERSE_ARROW_PREVIOUS: return traverseItem (false);
+ }
+ }
+ return false;
+}
+
+int traversalCode (int key_sym, PhKeyEvent_t ke) {
+ return
+ SWT.TRAVERSE_ESCAPE | SWT.TRAVERSE_RETURN |
+ SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS |
+ SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS;
+}
+
public boolean traverse (int traversal) {
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 ();
+ case SWT.TRAVERSE_RETURN: return traverseReturn ();
+ case SWT.TRAVERSE_TAB_NEXT: return traverseGroup (true, false);
+ case SWT.TRAVERSE_TAB_PREVIOUS: return traverseGroup (false, false);
+ case SWT.TRAVERSE_ARROW_NEXT: return traverseItem (true);
+ case SWT.TRAVERSE_ARROW_PREVIOUS: return traverseItem (false);
+ }
return false;
}
+boolean traverseEscape () {
+ Shell shell = getShell ();
+ if (shell.parent == null) return false;
+ if (!shell.isVisible () || !shell.isEnabled ()) return false;
+ shell.close ();
+ return true;
+}
+
+boolean traverseGroup (boolean next, boolean control) {
+ if (control) {
+ if (next) return OS.PtGlobalFocusPrevContainer (handle, null) != 0;
+ return OS.PtGlobalFocusNextContainer (handle, null) != 0;
+ }
+ if (next) return OS.PtGlobalFocusPrev (handle, null) != 0;
+ return OS.PtGlobalFocusNext (handle, null) != 0;
+}
+
+boolean traverseItem (boolean next) {
+ if (next) return OS.PtContainerFocusPrev (handle, null) != 0;
+ return OS.PtContainerFocusNext (handle, null) != 0;
+}
+
+boolean traverseReturn () {
+ Button button = menuShell ().getDefaultButton ();
+ if (button == null || button.isDisposed ()) return false;
+ if (!button.isVisible () || !button.isEnabled ()) return false;
+ button.click ();
+ return true;
+}
+
public void update () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
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 80f4787cc6..014dca0453 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.photon.*;
@@ -112,6 +112,7 @@ void releaseWidget () {
menuBar = null;
menus = null;
image = null;
+ text = null;
super.releaseWidget ();
}
@@ -126,13 +127,28 @@ void remove (Menu menu) {
}
void resizeBounds (int width, int height) {
+ int menuHeight = 0;
if (menuBar != null) {
- int [] args = {OS.Pt_ARG_HEIGHT, 0, 0};
- OS.PtGetResources (menuBar.handle, args.length / 3, args);
- height = Math.max (height - args [1], 0);
+ PhDim_t dim = new PhDim_t ();
+ int menuHandle = menuBar.handle;
+ if (!OS.PtWidgetIsRealized (menuHandle)) {
+ OS.PtExtentWidgetFamily (menuHandle);
+ }
+ OS.PtWidgetPreferredSize (menuHandle, dim);
+ menuHeight = dim.h;
+ int [] args = {OS.Pt_ARG_HEIGHT, menuHeight, 0};
+ OS.PtSetResources (menuHandle, args.length / 3, args);
+ height = height - menuHeight;
}
- int [] args = {OS.Pt_ARG_WIDTH, width, 0, OS.Pt_ARG_HEIGHT, height, 0};
+ PhArea_t area = new PhArea_t ();
+ area.pos_y = (short) menuHeight;
+ area.size_w = (short) Math.max (width, 0);
+ area.size_h = (short) Math.max (height ,0);
+ int ptr = OS.malloc (PhArea_t.sizeof);
+ OS.memmove (ptr, area, PhArea_t.sizeof);
+ int [] args = new int [] {OS.Pt_ARG_AREA, ptr, 0};
OS.PtSetResources (scrolledHandle, args.length / 3, args);
+ OS.free (ptr);
resizeClientArea (width, height);
}
@@ -171,4 +187,4 @@ public void setText (String string) {
text = string;
}
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/DirectoryDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/DirectoryDialog.java
index dc7aad26e1..62c1e91099 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/DirectoryDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/DirectoryDialog.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.*;
@@ -58,4 +58,4 @@ public void setMessage (String string) {
message = string;
}
-} \ No newline at end of file
+}
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 f4412502fa..4bd481006c 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.*;
@@ -27,8 +27,8 @@ public /*final*/ class Display extends Device {
Event [] eventQueue;
/* Events Dispatching and Callback */
- Callback windowCallback, drawCallback, workCallback, inputCallback;
- int windowProc, drawProc, workProc, inputProc, input, pulse;
+ Callback windowCallback, drawCallback, workCallback, inputCallback, hotkeyCallback;
+ int windowProc, drawProc, workProc, inputProc, hotkeyProc, input, pulse;
boolean idle;
/* Sync/Async Widget Communication */
@@ -140,9 +140,16 @@ public /*final*/ class Display extends Device {
int WIDGET_DARK_SHADOW, WIDGET_NORMAL_SHADOW, WIDGET_LIGHT_SHADOW;
int WIDGET_HIGHLIGHT_SHADOW, WIDGET_BACKGROUND, WIDGET_FOREGROUND, WIDGET_BORDER;
int LIST_FOREGROUND, LIST_BACKGROUND, LIST_SELECTION, LIST_SELECTION_TEXT;
+ int INFO_FOREGROUND, INFO_BACKGROUND;
/* Fonts */
byte [] TEXT_FONT, LIST_FONT;
+
+ /* ScrollBars */
+ int SCROLLBAR_WIDTH;
+ int SCROLLBAR_HEIGHT;
+ int SCROLLBAR_VERTICAL_BASIC_FLAGS;
+ int SCROLLBAR_HORIZONTAL_BASIC_FLAGS;
/* Package name */
static final String PACKAGE_NAME;
@@ -159,6 +166,22 @@ public /*final*/ class Display extends Device {
Object data;
String [] keys;
Object [] values;
+
+ /*
+ * TEMPORARY CODE. Install the runnable that
+ * gets the current display. This code will
+ * be removed in the future.
+ */
+ static {
+ DeviceFinder = new Runnable () {
+ public void run () {
+ CurrentDevice = getCurrent ();
+ if (CurrentDevice == null) {
+ CurrentDevice = getDefault ();
+ }
+ }
+ };
+ }
public Display () {
this (null);
@@ -195,6 +218,32 @@ protected void checkSubclass () {
if (!isValidClass (getClass ())) error (SWT.ERROR_INVALID_SUBCLASS);
}
+String convertToLf (String text) {
+ int length = text.length ();
+ if (length == 0) return text;
+
+ /* Check for an LF or CR/LF. Assume the rest of the string
+ * is formated that way. This will not work if the string
+ * contains mixed delimiters. */
+ int i = text.indexOf ('\n', 0);
+ if (i == -1 || i == 0) return text;
+ if (text.charAt (i - 1) != '\r') return text;
+
+ /* The string is formatted with CR/LF.
+ * Create a new string with the LF line delimiter. */
+ i = 0;
+ StringBuffer result = new StringBuffer ();
+ while (i < length) {
+ int j = text.indexOf ('\r', i);
+ if (j == -1) j = length;
+ String s = text.substring (i, j);
+ result.append (s);
+ i = j + 2;
+ result.append ('\n');
+ }
+ return result.toString ();
+}
+
protected void create (DeviceData data) {
checkSubclass ();
checkDisplay ();
@@ -407,23 +456,25 @@ public Color getSystemColor (int id) {
checkDevice ();
int color = 0x000000;
switch (id) {
- case SWT.COLOR_TITLE_FOREGROUND: color = 0x000000; break;
- case SWT.COLOR_TITLE_BACKGROUND: color = 0x6493E7; break;
+ case SWT.COLOR_INFO_FOREGROUND: color = INFO_FOREGROUND; break;
+ case SWT.COLOR_INFO_BACKGROUND: color = INFO_BACKGROUND; break;
+ case SWT.COLOR_TITLE_FOREGROUND: color = 0x000000; break;
+ case SWT.COLOR_TITLE_BACKGROUND: color = 0x6493E7; break;
case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: color = 0x0000FF; break;
case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: color = 0x000000; break;
- case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: color = 0xABBBD3; break;
+ case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: color = 0xABBBD3; break;
case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: color = 0x0000FF; break;
- case SWT.COLOR_WIDGET_DARK_SHADOW: color = WIDGET_DARK_SHADOW; break;
- case SWT.COLOR_WIDGET_NORMAL_SHADOW: color = WIDGET_NORMAL_SHADOW; break;
- case SWT.COLOR_WIDGET_LIGHT_SHADOW: color = WIDGET_LIGHT_SHADOW; break;
- case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: color = WIDGET_HIGHLIGHT_SHADOW; break;
- case SWT.COLOR_WIDGET_BACKGROUND: color = WIDGET_BACKGROUND; break;
- case SWT.COLOR_WIDGET_FOREGROUND: color = WIDGET_FOREGROUND; break;
- case SWT.COLOR_WIDGET_BORDER: color = WIDGET_BORDER; break;
- case SWT.COLOR_LIST_FOREGROUND: color = LIST_FOREGROUND; break;
- case SWT.COLOR_LIST_BACKGROUND: color = LIST_BACKGROUND; break;
- case SWT.COLOR_LIST_SELECTION: color = LIST_SELECTION; break;
- case SWT.COLOR_LIST_SELECTION_TEXT: color = LIST_SELECTION_TEXT; break;
+ case SWT.COLOR_WIDGET_DARK_SHADOW: color = WIDGET_DARK_SHADOW; break;
+ case SWT.COLOR_WIDGET_NORMAL_SHADOW: color = WIDGET_NORMAL_SHADOW; break;
+ case SWT.COLOR_WIDGET_LIGHT_SHADOW: color = WIDGET_LIGHT_SHADOW; break;
+ case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: color = WIDGET_HIGHLIGHT_SHADOW; break;
+ case SWT.COLOR_WIDGET_BACKGROUND: color = WIDGET_BACKGROUND; break;
+ case SWT.COLOR_WIDGET_FOREGROUND: color = WIDGET_FOREGROUND; break;
+ case SWT.COLOR_WIDGET_BORDER: color = WIDGET_BORDER; break;
+ case SWT.COLOR_LIST_FOREGROUND: color = LIST_FOREGROUND; break;
+ case SWT.COLOR_LIST_BACKGROUND: color = LIST_BACKGROUND; break;
+ case SWT.COLOR_LIST_SELECTION: color = LIST_SELECTION; break;
+ case SWT.COLOR_LIST_SELECTION_TEXT: color = LIST_SELECTION_TEXT; break;
default:
return super.getSystemColor (id);
}
@@ -445,12 +496,19 @@ public Thread getThread () {
return thread;
}
+int hotkeyProc (int handle, int data, int info) {
+ Widget widget = WidgetTable.get (handle);
+ if (widget == null) return OS.Pt_CONTINUE;
+ return widget.processHotkey (data, info);
+}
+
protected void init () {
super.init ();
initializeDisplay ();
initializeWidgetClasses ();
initializeWidgetColors ();
initializeWidgetFonts ();
+ initializeScrollbars ();
}
void initializeDisplay () {
@@ -469,6 +527,9 @@ void initializeDisplay () {
timerCallback = new Callback (this, "timerProc", 3);
timerProc = timerCallback.getAddress ();
if (timerProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ hotkeyCallback = new Callback (this, "hotkeyProc", 3);
+ hotkeyProc = hotkeyCallback.getAddress ();
+ if (hotkeyProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
pulse = OS.PtAppCreatePulse (app_context, -1);
input = OS.PtAppAddInput (app_context, pulse, inputProc, 0);
@@ -483,6 +544,36 @@ void initializeDisplay () {
OS.PtRealizeWidget (timerHandle);
}
+void initializeScrollbars () {
+ OS.PtSetParentWidget (0);
+ int shellHandle = OS.PtCreateWidget (OS.PtWindow (), 0, 0, null);
+ int textHandle = OS.PtCreateWidget (OS.PtMultiText (), shellHandle, 0, null);
+ int child = OS.PtWidgetChildFront (textHandle);
+ while (child != 0) {
+ if (OS.PtWidgetClass (child) == OS.PtScrollbar ()) {
+ int [] args = new int [] {
+ OS.Pt_ARG_ORIENTATION, 0, 0,
+ OS.Pt_ARG_WIDTH, 0, 0,
+ OS.Pt_ARG_HEIGHT, 0, 0,
+ OS.Pt_ARG_BASIC_FLAGS, 0, 0,
+ };
+ OS.PtGetResources (child, args.length / 3, args);
+ switch (args [1]) {
+ case OS.Pt_HORIZONTAL:
+ SCROLLBAR_HEIGHT = args [7];
+ SCROLLBAR_HORIZONTAL_BASIC_FLAGS = args [10];
+ break;
+ case OS.Pt_VERTICAL:
+ SCROLLBAR_WIDTH = args [4];
+ SCROLLBAR_VERTICAL_BASIC_FLAGS = args [10];
+ break;
+ }
+ }
+ child = OS.PtWidgetBrotherBehind (child);
+ }
+ OS.PtDestroyWidget (shellHandle);
+}
+
void initializeWidgetClasses () {
int [] args = {OS.Pt_SET_DRAW_F, drawProc, 0};
int [] buffer = {
@@ -529,36 +620,57 @@ void initializeWidgetClasses () {
void initializeWidgetColors () {
OS.PtSetParentWidget (0);
- int shellHandle = OS.PtCreateWidget (OS.PtWindow (), 0, 0, null);
int [] args = {
+ OS.Pt_ARG_WINDOW_STATE, OS.Ph_WM_STATE_ISHIDDEN, ~0,
+ };
+ int shellHandle = OS.PtCreateWidget (OS.PtWindow (), 0, args.length / 3, args);
+ args = new int [] {
OS.Pt_ARG_COLOR, 0, 0,
OS.Pt_ARG_FILL_COLOR, 0, 0,
};
OS.PtGetResources (shellHandle, args.length / 3, args);
WIDGET_FOREGROUND = args [1];
WIDGET_BACKGROUND = args [4];
+
int handle = OS.PtCreateWidget (OS.PtList (), shellHandle, 0, null);
args = new int [] {
OS.Pt_ARG_COLOR, 0, 0,
OS.Pt_ARG_FILL_COLOR, 0, 0,
OS.Pt_ARG_SELECTION_FILL_COLOR, 0, 0,
OS.Pt_ARG_SELECTION_TEXT_COLOR, 0, 0,
- OS.Pt_ARG_OUTLINE_COLOR, 0, 0,
- OS.Pt_ARG_OUTLINE_COLOR, 0, 0,
- OS.Pt_ARG_OUTLINE_COLOR, 0, 0,
- OS.Pt_ARG_INLINE_COLOR, 0, 0,
- OS.Pt_ARG_INLINE_COLOR, 0, 0,
};
OS.PtGetResources (handle, args.length / 3, args);
LIST_FOREGROUND = args [1];
LIST_BACKGROUND = args [4];
LIST_SELECTION = args [7];
LIST_SELECTION_TEXT = args [10];
- WIDGET_BORDER = args [13];
- WIDGET_DARK_SHADOW = args [16];
- WIDGET_NORMAL_SHADOW = args [19];
- WIDGET_LIGHT_SHADOW = args [22];
- WIDGET_HIGHLIGHT_SHADOW = args [25];
+
+ /*
+ * Feature in Photon. The values of Pt_ARG_DARK_BEVEL_COLOR and
+ * Pt_ARG_LIGHT_BEVEL_COLOR are not initialized until the widget
+ * is realized. The fix is to realize the shell, but don't
+ * display it.
+ */
+ handle = OS.PtCreateWidget (OS.PtButton (), shellHandle, 0, null);
+ OS.PtRealizeWidget(shellHandle);
+ args = new int [] {
+ OS.Pt_ARG_OUTLINE_COLOR, 0, 0,
+ OS.Pt_ARG_OUTLINE_COLOR, 0, 0,
+ OS.Pt_ARG_DARK_BEVEL_COLOR, 0, 0,
+ OS.Pt_ARG_BEVEL_COLOR, 0, 0,
+ OS.Pt_ARG_LIGHT_BEVEL_COLOR, 0, 0,
+ OS.Pt_ARG_BALLOON_COLOR, 0, 0,
+ OS.Pt_ARG_BALLOON_FILL_COLOR, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ WIDGET_BORDER = args [1];
+ WIDGET_DARK_SHADOW = args [4];
+ WIDGET_NORMAL_SHADOW = args [7];
+ WIDGET_LIGHT_SHADOW = args [10];
+ WIDGET_HIGHLIGHT_SHADOW = args [13];
+ INFO_FOREGROUND = args [16];
+ INFO_BACKGROUND = args [19];
+
OS.PtDestroyWidget (shellHandle);
}
@@ -713,14 +825,10 @@ void releaseDisplay () {
OS.PtAppRemoveInput (app_context, input);
OS.PtAppDeletePulse (app_context, pulse);
- /* Free the window proc */
- windowCallback.dispose ();
- windowCallback = null;
-
/* Free the timers */
if (timers != null) {
- for (int i=0; i<=timers.length; i++) {
- OS.PtDestroyWidget (timers [i]);
+ for (int i=0; i<timers.length; i++) {
+ if (timers [i] != 0) OS.PtDestroyWidget (timers [i]);
}
}
timers = null;
@@ -728,7 +836,11 @@ void releaseDisplay () {
timerProc = 0;
timerCallback.dispose ();
timerCallback = null;
-
+
+ /* Free the window proc */
+ windowCallback.dispose ();
+ windowCallback = null;
+
/* Free callbacks */
drawCallback.dispose();
drawCallback = null;
@@ -736,6 +848,8 @@ void releaseDisplay () {
workCallback = null;
inputCallback.dispose();
inputCallback = null;
+ hotkeyCallback.dispose();
+ hotkeyCallback = null;
/* Release references */
thread = null;
@@ -858,6 +972,15 @@ public void syncExec (Runnable runnable) {
synchronizer.syncExec (runnable);
}
+int textWidth (String string, byte[] font) {
+ if (string.length () == 0) return 0;
+ byte [] textBuffer = Converter.wcsToMbcs (null, string, false);
+ PhRect_t rect = new PhRect_t ();
+ OS.PfExtentText(rect, null, font, textBuffer, textBuffer.length);
+ if (rect.lr_x == rect.ul_x) return 0;
+ return rect.lr_x - rect.ul_x + 1;
+}
+
public void timerExec (int milliseconds, Runnable runnable) {
checkDevice ();
if (timerList == null) timerList = new Runnable [4];
@@ -932,7 +1055,7 @@ public void wake () {
int windowProc (int handle, int data, int info) {
Widget widget = WidgetTable.get (handle);
if (widget == null) return OS.Pt_CONTINUE;
- return widget.processEvent (data, info);
+ return widget.processEvent (handle, data, info);
}
int workProc (int data) {
@@ -940,4 +1063,59 @@ int workProc (int data) {
return OS.Pt_CONTINUE;
}
+String wrapText (String text, byte[] font, int width) {
+ text = convertToLf (text);
+ int length = text.length ();
+ if (width <= 0 || length == 0 || length == 1) return text;
+ StringBuffer result = new StringBuffer ();
+ int lineStart = 0, lineEnd = 0;
+ while (lineStart < length) {
+ lineEnd = text.indexOf ('\n', lineStart);
+ boolean noLf = lineEnd == -1;
+ if (noLf) lineEnd = length;
+ int nextStart = lineEnd + 1;
+ while (lineEnd > lineStart + 1 && Character.isWhitespace (text.charAt (lineEnd - 1))) {
+ lineEnd--;
+ }
+ int wordStart = lineStart, wordEnd = lineStart;
+ int i = lineStart;
+ while (i < lineEnd) {
+ int lastStart = wordStart, lastEnd = wordEnd;
+ wordStart = i;
+ while (i < lineEnd && !Character.isWhitespace (text.charAt (i))) {
+ i++;
+ }
+ wordEnd = i - 1;
+ String line = text.substring (lineStart, wordEnd + 1);
+ int lineWidth = textWidth (line, font);
+ while (i < lineEnd && Character.isWhitespace (text.charAt (i))) {
+ i++;
+ }
+ if (lineWidth > width) {
+ if (lastStart == wordStart) {
+ while (wordStart < wordEnd) {
+ line = text.substring (lineStart, wordStart + 1);
+ lineWidth = textWidth (line, font);
+ if (lineWidth >= width) break;
+ wordStart++;
+ }
+ if (wordStart == lastStart) wordStart++;
+ lastEnd = wordStart - 1;
+ }
+ line = text.substring (lineStart, lastEnd + 1);
+ result.append (line); result.append ('\n');
+ i = wordStart; lineStart = wordStart; wordEnd = wordStart;
+ }
+ }
+ if (lineStart < lineEnd) {
+ result.append (text.substring (lineStart, lineEnd));
+ }
+ if (!noLf) {
+ result.append ('\n');
+ }
+ lineStart = nextStart;
+ }
+ return result.toString ();
+}
+
}
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 d456c137b4..d030f4382b 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.*;
@@ -122,4 +122,4 @@ public void setFilterPath (String string) {
filterPath = string;
}
-} \ No newline at end of file
+}
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 6402e9c2e4..3737d6d850 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.*;
@@ -56,4 +56,4 @@ public FontData open () {
public void setFontData (FontData fontData) {
this.fontData = fontData;
}
-} \ No newline at end of file
+}
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 7f5022c5cf..cd6c3535ff 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.*;
@@ -53,6 +53,7 @@ protected void checkSubclass () {
}
void createHandle (int index) {
+ state |= HANDLE;
Display display = getDisplay ();
int clazz = display.PtPane;
int parentHandle = parent.handle;
@@ -119,4 +120,4 @@ public void setText (String string) {
OS.free (ptr);
}
-} \ No newline at end of file
+}
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
index 0c2e37f0b6..c77ad8aa33 100755
--- 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
@@ -1,14 +1,14 @@
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.*;
-
-/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
- */
/**
* A header draws one or more header items. Each item may have a text
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 ac5f1acd86..0bd2a8b36b 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.*;
@@ -11,6 +11,7 @@ import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
public class Label extends Control {
+ String text = "";
Image image;
public Label (Composite parent, int style) {
@@ -24,9 +25,9 @@ static int checkStyle (int style) {
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 border = getBorderWidth ();
- int width = border * 2, height = border * 2;
if ((style & SWT.SEPARATOR) != 0) {
+ int border = getBorderWidth ();
+ int width = border * 2, height = border * 2;
if ((style & SWT.HORIZONTAL) != 0) {
width += DEFAULT_WIDTH; height += 3;
} else {
@@ -36,23 +37,79 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
if (hHint != SWT.DEFAULT) height = hHint + (border * 2);
return new Point (width, height);
}
+
+ if ((style & SWT.WRAP) != 0) {
+ int [] args = {
+ OS.Pt_ARG_LABEL_TYPE, 0, 0, // 1
+ OS.Pt_ARG_TEXT_FONT, 0, 0, // 4
+ OS.Pt_ARG_LINE_SPACING, 0, 0, // 7
+ OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 10
+ OS.Pt_ARG_MARGIN_HEIGHT, 0, 0, // 13
+ OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 16
+ OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 19
+ OS.Pt_ARG_MARGIN_TOP, 0, 0, // 22
+ OS.Pt_ARG_MARGIN_BOTTOM, 0, 0, // 25
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ /* If we are wrapping text, calculate the height based on wHint. */
+ if (args [1] == OS.Pt_Z_STRING) {
+ int length = OS.strlen (args [4]);
+ byte [] font = new byte [length + 1];
+ OS.memmove (font, args [4], length);
+ Display display = getDisplay ();
+ PhRect_t rect = new PhRect_t ();
+ String string = text;
+ if (wHint != SWT.DEFAULT) {
+ string = display.wrapText (text, font, wHint);
+ }
+ if (hHint != SWT.DEFAULT) {
+ rect.ul_y = 0;
+ rect.lr_y = (short)(hHint - 1);
+ } else {
+ byte [] buffer = Converter.wcsToMbcs (null, string, false);
+ OS.PgExtentMultiText (rect, null, font, buffer, buffer.length, args [7]);
+ }
+ PhArea_t area = new PhArea_t ();
+ OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
+ int width = area.size_w;
+ int height = area.size_h;
+ width += (args [10] * 2) + args [16] + args [19];
+ height += (args [13] * 2) + args [22] + args [25];
+ return new Point (width, height);
+ }
+ }
+
PhDim_t dim = new PhDim_t();
if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
OS.PtWidgetPreferredSize(handle, dim);
- width = dim.w; height = dim.h;
+ int width = dim.w, height = dim.h;
if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ int [] args = {
+ OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 1
+ OS.Pt_ARG_MARGIN_HEIGHT, 0, 0, // 4
+ OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 7
+ OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 10
+ OS.Pt_ARG_MARGIN_TOP, 0, 0, // 13
+ OS.Pt_ARG_MARGIN_BOTTOM, 0, 0, // 16
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
PhRect_t rect = new PhRect_t ();
PhArea_t area = new PhArea_t ();
rect.lr_x = (short) (wHint - 1);
rect.lr_y = (short) (hHint - 1);
OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
- if (wHint != SWT.DEFAULT) width = area.size_w;
- if (hHint != SWT.DEFAULT) height = area.size_h;
+ if (wHint != SWT.DEFAULT) {
+ width = area.size_w + (args [1] * 2) + args [7] + args [10];
+ }
+ if (hHint != SWT.DEFAULT) {
+ height = area.size_h + (args [4] * 2) + args [13] + args [16];
+ }
}
return new Point (width, height);
}
void createHandle (int index) {
+ state |= HANDLE;
Display display = getDisplay ();
int parentHandle = parent.handle;
@@ -75,8 +132,12 @@ void createHandle (int index) {
int alignment = OS.Pt_LEFT;
if ((style & SWT.CENTER) != 0) alignment = OS.Pt_CENTER;
if ((style & SWT.RIGHT) != 0) alignment = OS.Pt_RIGHT;
+ int verticalAlign = (style & SWT.WRAP) != 0 ? OS.Pt_TOP : OS.Pt_CENTER;
+ boolean hasBorder = (style & SWT.BORDER) != 0;
int [] args = {
+ 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_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
};
handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
@@ -107,44 +168,7 @@ public String getText () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if ((style & SWT.SEPARATOR) != 0) return "";
- int [] args = {
- OS.Pt_ARG_TEXT_STRING, 0, 0,
- OS.Pt_ARG_ACCEL_KEY, 0, 0,
- };
- OS.PtGetResources (handle, args.length / 3, args);
- if (args [1] == 0) return "";
- int length = OS.strlen (args [1]);
- byte [] buffer = new byte [length];
- OS.memmove (buffer, args [1], length);
- char [] result = Converter.mbcsToWcs (null, buffer);
- int count = 0;
- int mnemonic = 0;
- if (args [4] != 0) {
- int length2 = OS.strlen (args [4]);
- if (length2 > 0) {
- byte [] buffer2 = new byte [length2];
- OS.memmove (buffer2, args [4], length2);
- char [] result2 = Converter.mbcsToWcs (null, buffer2);
- if (result2.length > 0) mnemonic = result2 [0];
- }
- }
- if (mnemonic != 0) count++;
- for (int i=0; i<result.length-1; i++)
- if (result [i] == Mnemonic) count++;
- char [] newResult = result;
- if ((count != 0) || (mnemonic != 0)) {
- newResult = new char [result.length + count];
- int i = 0, j = 0;
- while (i < result.length) {
- if ((mnemonic != 0) && (result [i] == mnemonic)) {
- if (j < newResult.length) newResult [j++] = Mnemonic;
- mnemonic = 0;
- }
- if ((newResult [j++] = result [i++]) == Mnemonic)
- if (j < newResult.length) newResult [j++] = Mnemonic;
- }
- }
- return new String (newResult);
+ return text;
}
int processPaint (int damage) {
@@ -154,9 +178,28 @@ int processPaint (int damage) {
return super.processPaint (damage);
}
+int processActivate (int info) {
+ Composite control = this.parent;
+ while (control != null) {
+ Control [] children = control._getChildren ();
+ int index = 0;
+ while (index < children.length) {
+ if (children [index] == this) break;
+ index++;
+ }
+ index++;
+ if (index < children.length) {
+ if (children [index].setFocus ()) return OS.Pt_CONTINUE;
+ }
+ control = control.parent;
+ }
+ return OS.Pt_CONTINUE;
+}
+
void releaseWidget () {
super.releaseWidget ();
image = null;
+ text = null;
}
public void setAlignment (int alignment) {
@@ -172,10 +215,20 @@ public void setAlignment (int alignment) {
OS.PtSetResources (handle, args.length / 3, args);
}
+void setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ super.setBounds (x, y, width, height, move, resize);
+ if (resize && (style & SWT.WRAP) != 0) setText (text);
+}
+
public boolean setFocus () {
return false;
}
+public void setFont (Font font) {
+ super.setFont (font);
+ if ((style & SWT.WRAP) != 0) setText (text);
+}
+
public void setImage (Image image) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -196,20 +249,45 @@ public void setText (String string) {
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
if ((style & SWT.SEPARATOR) != 0) return;
- char [] text = new char [string.length ()];
- string.getChars (0, text.length, text, 0);
+ text = string;
+ char [] unicode = new char [string.length ()];
+ string.getChars (0, unicode.length, unicode, 0);
int i=0, j=0;
char mnemonic=0;
- while (i < text.length) {
- if ((text [j++] = text [i++]) == Mnemonic) {
- if (i == text.length) {continue;}
- if (text [i] == Mnemonic) {i++; continue;}
- if (mnemonic == 0) mnemonic = text [i];
+ while (i < unicode.length) {
+ if ((unicode [j++] = unicode [i++]) == Mnemonic) {
+ if (i == unicode.length) {continue;}
+ if (unicode [i] == Mnemonic) {i++; continue;}
+ if (mnemonic == 0) mnemonic = unicode [i];
j--;
}
}
- while (j < text.length) text [j++] = 0;
- byte [] buffer = Converter.wcsToMbcs (null, text, true);
+ while (j < unicode.length) unicode [j++] = 0;
+ /* Wrap the text if necessary, and convert to mbcs. */
+ byte [] buffer;
+ if ((style & SWT.WRAP) != 0) {
+ int [] args = {
+ OS.Pt_ARG_TEXT_FONT, 0, 0, // 1
+ OS.Pt_ARG_WIDTH, 0, 0, // 4
+ OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 7
+ OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 10
+ OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 13
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ int length = OS.strlen (args [1]);
+ byte [] font = new byte [length + 1];
+ OS.memmove (font, args [1], length);
+ int border = 0;
+ if ((style & SWT.BORDER) != 0) border = 2;
+ int width = args [4];
+ width -= (args [7] * 2) + args [10] + args [13] + border * 2;
+ Display display = getDisplay ();
+ if (mnemonic != '\0') string = new String (unicode);
+ string = display.wrapText (string, font, width);
+ buffer = Converter.wcsToMbcs (null, string, true);
+ } else {
+ buffer = Converter.wcsToMbcs (null, unicode, true);
+ }
int ptr = OS.malloc (buffer.length);
OS.memmove (ptr, buffer, buffer.length);
int ptr2 = 0;
@@ -218,6 +296,7 @@ public void setText (String string) {
ptr2 = OS.malloc (buffer2.length);
OS.memmove (ptr2, buffer2, buffer2.length);
}
+ replaceMnemonic (mnemonic, 0);
int [] args = {
OS.Pt_ARG_TEXT_STRING, ptr, 0,
OS.Pt_ARG_LABEL_TYPE, OS.Pt_Z_STRING, 0,
@@ -228,4 +307,4 @@ public void setText (String string) {
OS.free (ptr2);
}
-} \ No newline at end of file
+}
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 5fc15bfb72..042df8e3d3 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.*;
@@ -112,6 +112,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
}
void createHandle (int index) {
+ state |= HANDLE;
Display display = getDisplay ();
int clazz = display.PtList;
int parentHandle = parent.handle;
@@ -125,7 +126,9 @@ void createHandle (int index) {
}
}
mode |= OS.Pt_SELECTION_MODE_NOFOCUS;
+ boolean hasBorder = (style & SWT.BORDER) != 0;
int [] args = {
+ OS.Pt_ARG_FLAGS, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
OS.Pt_ARG_SELECTION_MODE, mode, 0,
OS.Pt_ARG_FLAGS, OS.Pt_SELECTABLE | OS.Pt_SELECT_NOREDRAW, OS.Pt_SELECTABLE | OS.Pt_SELECT_NOREDRAW,
OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
@@ -152,14 +155,14 @@ public void deselect (int start, int end) {
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if (start > end) return;
if ((style & SWT.SINGLE) != 0) {
- int [] args = new int [] {OS.Pt_ARG_LIST_SEL_COUNT, 0, 0};
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
int count = args [1];
int index = Math.min (count - 1, end);
if (index >= start) deselect (index);
return;
}
- for (int i=start; i<end; i++) {
+ for (int i=start; i<=end; i++) {
OS.PtListUnselectPos (handle, i + 1);
}
}
@@ -317,7 +320,7 @@ public int getTopIndex () {
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];
+ return args [1] - 1;
}
void hookEvents () {
@@ -330,7 +333,8 @@ void hookEvents () {
public int indexOf (String string) {
if (!isValidThread ()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error(SWT.ERROR_WIDGET_DISPOSED);
- return indexOf (string, 0);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ return OS.PtListItemPos(handle, buffer) - 1;
}
public int indexOf (String string, int start) {
@@ -339,8 +343,7 @@ public int indexOf (String string, int start) {
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
// NOT DONE - start is ignored
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- return OS.PtListItemPos(handle, buffer) - 1;
+ return indexOf (string);
}
public boolean isSelected (int index) {
@@ -402,11 +405,20 @@ public void remove (int [] indices) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
-
- //NOT DONE
+ int [] newIndices = new int [indices.length];
+ System.arraycopy (indices, 0, newIndices, 0, indices.length);
+ sort (newIndices);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ for (int i=0; i<newIndices.length; i++ ) {
+ int index = newIndices [i];
+ if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
+ int result = OS.PtListDeleteItemPos (handle, 1, index + 1);
+ if (result != 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ }
}
-
public void remove (int start, int end) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -426,7 +438,6 @@ public void removeAll () {
OS.PtListDeleteAllItems (handle);
}
-
public void removeSelectionListener(SelectionListener listener) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -440,18 +451,22 @@ public void select (int start, int end) {
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);
+ int count = args [1];
if ((style & SWT.SINGLE) != 0) {
- int [] args = new int [] {OS.Pt_ARG_LIST_SEL_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- int count = args [1];
int index = Math.min (count - 1, end);
if (index >= start) select (index);
return;
}
- for (int i=start; i<end; i++) {
- OS.PtListSelectPos (handle, start + 1);
+ int gotoIndex = -1;
+ for (int index=end; index>=start; index--) {
+ if (0 <= index && index < count) {
+ gotoIndex = index;
+ OS.PtListSelectPos (handle, index + 1);
+ }
}
- OS.PtListGotoPos (handle, start + 1);
+ if (gotoIndex != -1) OS.PtListGotoPos (handle, gotoIndex + 1);
}
public void select (int [] indices) {
@@ -459,27 +474,37 @@ public void select (int [] indices) {
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};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ int gotoIndex = -1;
for (int i=0; i<indices.length; i++) {
- if (indices [i] >= 0) {
- OS.PtListSelectPos (handle, indices [i] + 1);
+ int index = indices [i];
+ if (0 <= index && index < count) {
+ gotoIndex = index;
+ OS.PtListSelectPos (handle, index + 1);
}
}
- OS.PtListGotoPos (handle, indices [0] + 1);
+ if (gotoIndex != -1) OS.PtListGotoPos (handle, gotoIndex + 1);
}
public void select (int index) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if (index < 0) return;
- OS.PtListSelectPos (handle, index + 1);
- OS.PtListGotoPos (handle, index + 1);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (index < args [1]) {
+ OS.PtListSelectPos (handle, index + 1);
+ OS.PtListGotoPos (handle, index + 1);
+ }
}
public void selectAll () {
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_SEL_COUNT, 0, 0};
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
OS.PtGetResources (handle, args.length / 3, args);
int count = args [1];
for (int i=0; i<count; i++) {
@@ -586,4 +611,12 @@ public void showSelection () {
OS.PtSetResources (handle, args.length / 3, args);
}
+int traversalCode (int key_sym, PhKeyEvent_t ke) {
+ int code = super.traversalCode (key_sym, ke);
+ if (key_sym == OS.Pk_Up || key_sym == OS.Pk_Down) {
+ code &= ~(SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS);
+ }
+ return code;
+}
+
}
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 929031a615..535e47327f 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.photon.*;
@@ -14,7 +14,7 @@ public class Menu extends Widget {
int x, y;
boolean hasLocation;
Decorations parent;
- MenuItem cascade;
+ MenuItem cascade, defaultItem;
public Menu (Control parent) {
this (checkNull (parent).getShell (), SWT.POP_UP);
@@ -71,6 +71,7 @@ public void addMenuListener (MenuListener listener) {
}
void createHandle (int index) {
+ state |= HANDLE;
int parentHandle = parent.topHandle ();
if ((style & SWT.BAR) != 0) {
int [] args = {
@@ -92,8 +93,7 @@ void createWidget (int index) {
public MenuItem getDefaultItem () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- //NOT DONE - NOT NEEDED
- return null;
+ return defaultItem;
}
public Display getDisplay () {
@@ -126,12 +126,19 @@ public int getItemCount () {
public MenuItem getItem (int index) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- //NOT DONE - bogus
- MenuItem[] items = getItems();
- if (!(0 <= index && index < items.length)) {
- error (SWT.ERROR_INVALID_RANGE);
+ if (index < 0) error (SWT.ERROR_INVALID_RANGE);
+ int i = 0;
+ int child = OS.PtWidgetChildBack (handle);
+ if (child != 0 && (style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);
+ while (child != 0) {
+ Widget widget = WidgetTable.get (child);
+ if (widget != null && widget instanceof MenuItem) {
+ if (i++ == index) return (MenuItem) widget;
+ }
+ child = OS.PtWidgetBrotherInFront (child);
}
- return items [index];
+ error (SWT.ERROR_INVALID_RANGE);
+ return null;
}
public MenuItem [] getItems () {
@@ -206,7 +213,6 @@ public boolean getVisible () {
void hookEvents () {
int windowProc = getDisplay ().windowProc;
- OS.PtAddCallback (handle, OS.Pt_CB_REALIZED, windowProc, SWT.Show);
OS.PtAddCallback (handle, OS.Pt_CB_UNREALIZED, windowProc, SWT.Hide);
}
@@ -214,10 +220,14 @@ public int indexOf (MenuItem item) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- //NOT DONE - bogus
- MenuItem[] items = getItems();
- for (int i=0; i<items.length; i++) {
- if (item == items [i]) return i;
+ int i = 0;
+ int child = OS.PtWidgetChildBack (handle);
+ if (child != 0 && (style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);
+ while (child != 0) {
+ Widget widget = WidgetTable.get (child);
+ if (item == widget) return i;
+ if (widget != null && widget instanceof MenuItem) i++;
+ child = OS.PtWidgetBrotherInFront (child);
}
return -1;
}
@@ -237,15 +247,16 @@ public boolean isVisible () {
}
int processHide (int info) {
+ if (cascade != null) {
+ int [] args = {OS.Pt_ARG_MENU_FLAGS, 0, OS.Pt_MENU_CHILD};
+ OS.PtSetResources (handle, args.length / 3, args);
+ int shellHandle = parent.topHandle ();
+ OS.PtReParentWidget (handle, shellHandle);
+ }
sendEvent (SWT.Hide);
return OS.Pt_CONTINUE;
}
-int processShow (int info) {
- sendEvent (SWT.Show);
- return OS.Pt_CONTINUE;
-}
-
void releaseChild () {
super.releaseChild ();
if (cascade != null) cascade.setMenu (null);
@@ -266,7 +277,7 @@ void releaseWidget () {
super.releaseWidget ();
if (parent != null) parent.remove (this);
parent = null;
-
+ cascade = null;
}
public void removeHelpListener (HelpListener listener) {
@@ -289,7 +300,7 @@ public void removeMenuListener (MenuListener listener) {
public void setDefaultItem (MenuItem item) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- //NOT DONE - NOT NEEDED
+ defaultItem = item;
}
public void setEnabled (boolean enabled) {
@@ -329,10 +340,11 @@ public void setVisible (boolean visible) {
int [] args = {OS.Pt_ARG_POS, ptr, 0};
OS.PtSetResources (handle, args.length / 3, args);
OS.free (ptr);
+ sendEvent (SWT.Show);
OS.PtRealizeWidget (handle);
} else {
OS.PtUnrealizeWidget(handle);
}
}
-} \ No newline at end of file
+}
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 e014e1f8b0..69268fe0a7 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.*;
@@ -13,6 +13,8 @@ import org.eclipse.swt.events.*;
public class MenuItem extends Item {
Menu parent, menu;
+ int accelerator;
+ boolean enabled = true;
public MenuItem (Menu parent, int style) {
this (parent, style, parent.getItemCount());
@@ -58,6 +60,7 @@ static int checkStyle (int style) {
}
void createHandle (int index) {
+ state |= HANDLE;
int count = parent.getItemCount();
if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
int parentHandle = parent.handle;
@@ -65,8 +68,6 @@ void createHandle (int index) {
handle = OS.PtCreateWidget (OS.PtSeparator (), parentHandle, 0, null);
} else if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
int [] args = {
-// OS.Pt_ARG_FLAGS, OS.Pt_MENU_BUTTON | OS.Pt_SELECTABLE, OS.Pt_MENU_BUTTON | OS.Pt_SELECTABLE,
-// OS.Pt_ARG_FLAGS, OS.Pt_AUTOHIGHLIGHT, OS.Pt_AUTOHIGHLIGHT,
OS.Pt_ARG_INDICATOR_TYPE, (style & SWT.CHECK) != 0 ? OS.Pt_N_OF_MANY : OS.Pt_ONE_OF_MANY, 0
};
handle = OS.PtCreateWidget (OS.PtToggleButton (), parentHandle, args.length / 3, args);
@@ -91,18 +92,13 @@ void createHandle (int index) {
}
if (OS.PtWidgetIsRealized (parentHandle)) {
OS.PtRealizeWidget (topHandle ());
- if ((parent.style & SWT.BAR) == 0) {
- OS.PtExtentWidgetFamily (parentHandle);
- OS.PtPositionMenu (parentHandle, null);
- }
}
}
public int getAccelerator () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- //NOT DONE - NOT NEEDED
- return 0;
+ return accelerator;
}
public Display getDisplay () {
@@ -114,9 +110,16 @@ public Display getDisplay () {
public boolean getEnabled () {
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;
+ /*
+ * Bug in Photon. The Pt_BLOCKED flag of a menu item is cleared
+ * when its parent menu is realized. The fix is to remember
+ * the menu item state and reset it when the menu item is
+ * realized.
+ */
+// int [] args = {OS.Pt_ARG_FLAGS, 0, 0};
+// OS.PtGetResources (handle, args.length / 3, args);
+// return (args [1] & OS.Pt_BLOCKED) == 0;
+ return enabled;
}
public Menu getMenu () {
@@ -149,15 +152,22 @@ void hookEvents () {
if ((style & SWT.SEPARATOR) != 0) return;
int windowProc = getDisplay ().windowProc;
if ((style & SWT.CASCADE) != 0) {
- OS.PtAddCallback (handle, OS.Pt_CB_ARM, windowProc, SWT.Show);
+ OS.PtAddCallback (handle, OS.Pt_CB_ARM, windowProc, SWT.Arm);
}
OS.PtAddCallback (handle, OS.Pt_CB_ACTIVATE, windowProc, SWT.Selection);
+ if ((parent.style & SWT.BAR) == 0) {
+ OS.PtAddCallback (handle, OS.Pt_CB_REALIZED, windowProc, SWT.Show);
+ }
}
public boolean isEnabled () {
return getEnabled () && parent.isEnabled ();
}
+int processActivate (int info) {
+ return processArm (info);
+}
+
int processSelection (int info) {
if ((style & SWT.CASCADE) != 0) {
int [] args = {OS.Pt_ARG_BUTTON_TYPE, 0, 0};
@@ -170,38 +180,79 @@ int processSelection (int info) {
return OS.Pt_CONTINUE;
}
+int processShow (int info) {
+ /*
+ * Bug in Photon. The Pt_BLOCKED flag of a menu item is cleared
+ * when its parent menu is realized. The fix is to remember
+ * the menu item state and reset it when the menu item is
+ * realized.
+ */
+ 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,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ return OS.Pt_CONTINUE;
+}
+
+int processArm(int info) {
+ 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;
+}
+
void releaseChild () {
super.releaseChild ();
if (menu != null) menu.dispose ();
menu = null;
-// parent.destroyItem (this);
}
void releaseWidget () {
- if (menu != null) {
+ if (menu != null && !menu.isDisposed ()) {
menu.releaseWidget ();
menu.releaseHandle ();
}
menu = null;
super.releaseWidget ();
-// if (accelerator != 0) {
-// parent.destroyAcceleratorTable ();
-// }
-// accelerator = 0;
-// Decorations shell = parent.parent;
-// shell.remove (this);
+ if (accelerator != 0) removeAccelerator ();
+ accelerator = 0;
parent = null;
}
-int processShow (int damage) {
- if (menu != null) {
- int menuHandle = menu.handle;
- OS.PtPositionMenu (menuHandle, null);
- OS.PtRealizeWidget (menuHandle);
- }
- return OS.Pt_CONTINUE;
-}
-
public void removeArmListener (ArmListener listener) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -218,6 +269,22 @@ public void removeHelpListener (HelpListener listener) {
eventTable.unhook (SWT.Help, listener);
}
+void removeAccelerator () {
+ if (accelerator == 0) return;
+
+ int keyMods = 0;
+ if ((accelerator & SWT.ALT) != 0) keyMods |= OS.Pk_KM_Alt;
+ if ((accelerator & SWT.SHIFT) != 0) keyMods |= OS.Pk_KM_Shift;
+ if ((accelerator & SWT.CONTROL) != 0) keyMods |= OS.Pk_KM_Ctrl;
+ int key = (accelerator & ~(SWT.ALT | SWT.SHIFT | SWT.CONTROL));
+ Display display = getDisplay ();
+ int keyCode = display.untranslateKey (key);
+ if (keyCode != 0) key = keyCode;
+ else key = Character.toLowerCase ((char)key);
+ Shell shell = parent.getShell ();
+ OS.PtRemoveHotkeyHandler(shell.shellHandle, key, keyMods, (short)0, handle, display.hotkeyProc);
+}
+
public void removeSelectionListener (SelectionListener listener) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -231,24 +298,28 @@ public void setAccelerator (int accelerator) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- //NOT DONE: remove previous - NEEDED NEEDED
-//
-// if (accelerator != 0) {
-// int keyMods = 0;
-// if ((accelerator & SWT.ALT) != 0) keyMods |= OS.Pk_KM_Alt;
-// if ((accelerator & SWT.SHIFT) != 0) keyMods |= OS.Pk_KM_Shift;
-// if ((accelerator & SWT.CONTROL) != 0) keyMods |= OS.Pk_KM_Ctrl;
-// int key = accelerator & ~(SWT.ALT | SWT.SHIFT | SWT.CONTROL);
-// //key = Display.untranslateKey(key);
-// key = 0x61;
-// System.out.println("key=" + Integer.toHexString(key));
-// OS.PtAddHotkeyHandler(handle, key, keyMods, (short)0, SWT.Selection, 0);
-// }
+ removeAccelerator ();
+
+ this.accelerator = accelerator;
+ if (accelerator == 0) return;
+
+ int keyMods = 0;
+ if ((accelerator & SWT.ALT) != 0) keyMods |= OS.Pk_KM_Alt;
+ if ((accelerator & SWT.SHIFT) != 0) keyMods |= OS.Pk_KM_Shift;
+ if ((accelerator & SWT.CONTROL) != 0) keyMods |= OS.Pk_KM_Ctrl;
+ int key = (accelerator & ~(SWT.ALT | SWT.SHIFT | SWT.CONTROL));
+ Display display = getDisplay ();
+ int keyCode = display.untranslateKey (key);
+ if (keyCode != 0) key = keyCode;
+ else key = Character.toLowerCase ((char)key);
+ Shell shell = parent.getShell ();
+ OS.PtAddHotkeyHandler(shell.shellHandle, key, keyMods, (short)0, handle, display.hotkeyProc);
}
public void setEnabled (boolean enabled) {
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,
OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_GHOST, OS.Pt_GHOST,
@@ -284,26 +355,17 @@ public void setMenu (Menu menu) {
this.menu = menu;
if (oldMenu != null) {
oldMenu.cascade = null;
- int menuHandle = oldMenu.handle;
- int shellHandle = oldMenu.parent.topHandle ();
if ((parent.style & SWT.BAR) == 0) {
- int [] args = {OS.Pt_ARG_BUTTON_TYPE, 0, OS.Pt_MENU_RIGHT};
+ int [] args = {OS.Pt_ARG_BUTTON_TYPE, OS.Pt_MENU_TEXT, 0};
OS.PtSetResources (handle, args.length / 3, args);
- args = new int [] {OS.Pt_ARG_MENU_FLAGS, 0, OS.Pt_MENU_CHILD};
- OS.PtSetResources (menuHandle, args.length / 3, args);
}
- OS.PtReParentWidget (menuHandle, shellHandle);
}
if (menu != null) {
menu.cascade = this;
- int menuHandle = menu.handle;
if ((parent.style & SWT.BAR) == 0) {
- int [] args = {OS.Pt_ARG_BUTTON_TYPE, OS.Pt_MENU_RIGHT, OS.Pt_MENU_RIGHT};
+ int [] args = {OS.Pt_ARG_BUTTON_TYPE, OS.Pt_MENU_RIGHT, 0};
OS.PtSetResources (handle, args.length / 3, args);
- args = new int [] {OS.Pt_ARG_MENU_FLAGS, OS.Pt_MENU_CHILD, OS.Pt_MENU_CHILD};
- OS.PtSetResources (menuHandle, args.length / 3, args);
}
- OS.PtReParentWidget (menuHandle, handle);
}
}
@@ -333,31 +395,51 @@ public void setText (String string) {
if (mnemonic == 0) mnemonic = text [i];
j--;
}
- }
- byte [] buffer2;
+ }
+ int keyMods = 0;
+ byte [] buffer2 = new byte [1];
if (accel && ++i < text.length) {
- char [] accelText = new char [text.length - i];
- System.arraycopy (text, i, accelText, 0, accelText.length);
- buffer2 = Converter.wcsToMbcs (null, accelText, true);
- } else {
- buffer2 = new byte [1];
+ int start = i;
+// while (i < text.length) {
+// if (text [i] == '+') {
+// String str = new String (text, start, i - start);
+// if (str.equals ("Ctrl")) keyMods |= OS.Pk_KM_Ctrl;
+// if (str.equals ("Shift")) keyMods |= OS.Pk_KM_Shift;
+// if (str.equals ("Alt")) keyMods |= OS.Pk_KM_Alt;
+// start = i + 1;
+// }
+// i++;
+// }
+ if (start < text.length) {
+ char [] accelText = new char [text.length - start];
+ System.arraycopy (text, start, accelText, 0, accelText.length);
+ buffer2 = Converter.wcsToMbcs (null, accelText, true);
+ }
}
while (j < text.length) text [j++] = 0;
byte [] buffer1 = Converter.wcsToMbcs (null, text, true);
- int ptr = OS.malloc (buffer1.length);
- OS.memmove (ptr, buffer1, buffer1.length);
+ int ptr1 = OS.malloc (buffer1.length);
+ OS.memmove (ptr1, buffer1, buffer1.length);
+ int ptr2 = OS.malloc (buffer2.length);
+ OS.memmove (ptr2, buffer2, buffer2.length);
int ptr3 = 0;
if (mnemonic != 0) {
byte [] buffer3 = Converter.wcsToMbcs (null, new char []{mnemonic}, true);
ptr3 = OS.malloc (buffer3.length);
OS.memmove (ptr3, buffer3, buffer3.length);
}
+ if ((parent.style & SWT.BAR) != 0) {
+ replaceMnemonic (mnemonic, OS.Pk_KM_Alt);
+ }
int [] args = {
- OS.Pt_ARG_TEXT_STRING, ptr, 0,
+ OS.Pt_ARG_TEXT_STRING, ptr1, 0,
+ OS.Pt_ARG_ACCEL_TEXT, ptr2, 0,
+ OS.Pt_ARG_MODIFIER_KEYS, keyMods, keyMods,
OS.Pt_ARG_ACCEL_KEY, ptr3, 0,
};
OS.PtSetResources (handle, args.length / 3, args);
- OS.free (ptr);
+ OS.free (ptr1);
+ OS.free (ptr2);
OS.free (ptr3);
/*
* Bug on Photon. When a the text is set on a menu
@@ -368,4 +450,4 @@ public void setText (String string) {
if (OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
}
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java
index 97348244e3..c3a29ea2cc 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.*;
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 0e9b4579fc..461ea7a7bb 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.photon.*;
@@ -50,6 +50,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
}
void createHandle (int index) {
+ state |= HANDLE;
Display display = getDisplay ();
int clazz = display.PtProgress;
int parentHandle = parent.handle;
@@ -118,4 +119,4 @@ public void setSelection (int value) {
int [] args = {OS.Pt_ARG_GAUGE_VALUE, value, 0};
OS.PtSetResources (handle, args.length / 3, args);
}
-} \ No newline at end of file
+}
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 2f97a08506..323de08511 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.photon.*;
@@ -47,6 +47,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
}
void createHandle (int index) {
+ state |= HANDLE;
Display display = getDisplay ();
int clazz = display.PtContainer;
int parentHandle = parent.handle;
@@ -80,6 +81,12 @@ void drawBand (int x, int y, int width, int height) {
OS.PgDestroyGC (phGC);
}
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddEventHandler (handle, OS.Ph_EV_DRAG, windowProc, SWT.MouseMove);
+}
+
int processMouse (int info) {
int result = super.processMouse (info);
@@ -111,8 +118,8 @@ int processMouse (int info) {
rect.ul_x = rect.lr_x = (short) (pos.x + ev.translation_x);
rect.ul_y = rect.lr_y = (short) (pos.y + ev.translation_y);
int rid = OS.PtWidgetRid (handle);
- int input_group = OS.PhInputGroup (cbinfo.event);
-// int input_group = OS.PhInputGroup (0);
+// int input_group = OS.PhInputGroup (cbinfo.event);
+ int input_group = OS.PhInputGroup (0);
OS.PhInitDrag (rid, OS.Ph_DRAG_KEY_MOTION | OS.Ph_DRAG_TRACK | OS.Ph_TRACK_DRAG, rect, null, input_group, null, null, null, pos, null);
/* Compute the banding rectangle */
@@ -168,12 +175,9 @@ int processMouse (int info) {
/* Compute the banding rectangle */
x += area.pos_x;
y += area.pos_y;
- int parentHandle = parent.handle;
- rect = new PhRect_t ();
- int vParent = OS.PtValidParent (handle, OS.PtContainer ());
- OS.PtCalcCanvas (vParent, rect);
- int clientWidth = rect.lr_x - rect.ul_x + 1;
- int clientHeight = rect.lr_y - rect.ul_y + 1;
+ Rectangle r = parent.getClientArea ();
+ int clientWidth = r.width;
+ int clientHeight = r.height;
int newX = lastX, newY = lastY;
if ((style & SWT.VERTICAL) != 0) {
newX = Math.min (Math.max (0, x - startX), clientWidth - width);
@@ -222,4 +226,4 @@ public void removeSelectionListener(SelectionListener listener) {
eventTable.unhook (SWT.DefaultSelection,listener);
}
-} \ No newline at end of file
+}
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 96820ad7b6..400c24766f 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.photon.*;
@@ -50,6 +50,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
}
void createHandle (int index) {
+ state |= HANDLE;
Display display = getDisplay ();
int clazz = display.PtSlider;
int parentHandle = parent.handle;
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 3b810a2ab2..586641bb58 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.photon.*;
@@ -17,6 +17,7 @@ ScrollBar (Scrollable parent, int style, int handle) {
super (parent, checkStyle (style));
this.parent = parent;
this.handle = handle;
+ state |= HANDLE;
createWidget (0);
}
@@ -40,18 +41,34 @@ public void addSelectionListener (SelectionListener listener) {
}
void createHandle (int index) {
+ state |= HANDLE;
if (handle != 0) return;
+ Display display = getDisplay ();
int parentHandle = parent.scrolledHandle;
+ int orientation, sizeArg, size, basicFlags;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ orientation = OS.Pt_HORIZONTAL;
+ sizeArg = OS.Pt_ARG_HEIGHT;
+ size = display.SCROLLBAR_HEIGHT;
+ basicFlags = display.SCROLLBAR_HORIZONTAL_BASIC_FLAGS;
+ } else {
+ orientation = OS.Pt_VERTICAL;
+ sizeArg = OS.Pt_ARG_WIDTH;
+ size = display.SCROLLBAR_WIDTH;
+ basicFlags = display.SCROLLBAR_VERTICAL_BASIC_FLAGS;
+ }
int [] args = {
+ sizeArg, size, 0,
OS.Pt_ARG_MAXIMUM, 100, 0,
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_BASIC_FLAGS, basicFlags, ~0,
+ OS.Pt_ARG_ORIENTATION, orientation, 0,
+ OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
};
handle = OS.PtCreateWidget (OS.PtScrollbar (), parentHandle, args.length / 3, args);
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- OS.PtExtentWidget (handle);
}
public Display getDisplay () {
@@ -288,6 +305,7 @@ public void setValues (int selection, int minimum, int maximum, int thumb, int i
public void setVisible (boolean visible) {
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 ac2121a3de..6781db28da 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.photon.*;
@@ -101,8 +101,14 @@ void resizeClientArea () {
}
void releaseWidget () {
- if (horizontalBar != null) horizontalBar.releaseWidget ();
- if (verticalBar != null) verticalBar.releaseWidget ();
+ if (horizontalBar != null) {
+ horizontalBar.releaseWidget ();
+ horizontalBar.releaseHandle ();
+ }
+ if (verticalBar != null) {
+ verticalBar.releaseWidget ();
+ verticalBar.releaseHandle ();
+ }
horizontalBar = verticalBar = null;
super.releaseWidget ();
}
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
index 7b590263a7..87acefdaef 100755
--- 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
@@ -1,13 +1,13 @@
package org.eclipse.swt.widgets;
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
-/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
- */
-
/**
* This class implements common behavior of TreeItem and TableItem.
*/
@@ -26,14 +26,14 @@ abstract class SelectableItem extends Item {
*/
SelectableItem(SelectableItemWidget parent, int style) {
super(parent, style);
- setParent(parent);
- addListener(SWT.Dispose, new Listener() {
- public void handleEvent(Event event) {disposeItem();}});
+ setParent(parent);
}
-/**
- * Subclasses should free resources here
- */
-void disposeItem() {
+public void dispose() {
+ if (!isValidWidget ()) return;
+ super.dispose();
+ doDispose();
+}
+void doDispose() {
setParent(null);
}
/**
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
index 0eda6178f2..384fe03089 100755
--- 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
@@ -1,14 +1,14 @@
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.*;
-
-/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
- */
/**
* This class is intended for widgets that display data of
@@ -1657,22 +1657,46 @@ void select(SelectableItem 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(SelectableItem item) {
- Event event;
-
+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
}
- event = new Event();
- event.item = item;
- notifyListeners(SWT.Selection, event);
+ 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'.
*/
@@ -2024,4 +2048,4 @@ void toggleSelectionNotify(SelectableItem item) {
selectNotify(item);
}
}
-} \ No newline at end of file
+}
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 46decb71bd..6e66d3a8ca 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.*;
@@ -15,7 +15,8 @@ public class Shell extends Decorations {
int shellHandle;
Display display;
int modal, blockedList;
-
+ Control lastFocus;
+
public Shell () {
this ((Display) null);
}
@@ -101,19 +102,23 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
int trimWidth = width + left [0] + right [0];
int trimHeight = height + top [0] + bottom [0];
if (menuBar != null) {
- args = new int [] {OS.Pt_ARG_HEIGHT, 0, 0};
- OS.PtGetResources (menuBar.handle, args.length / 3, args);
- trimHeight += args [1];
- trimY -= args [1];
+ PhDim_t dim = new PhDim_t ();
+ int menuHandle = menuBar.handle;
+ if (!OS.PtWidgetIsRealized (menuHandle)) {
+ OS.PtExtentWidgetFamily (menuHandle);
+ }
+ OS.PtWidgetPreferredSize (menuHandle, dim);
+ trimHeight += dim.h;
+ trimY -= dim.h;
}
return new Rectangle (trimX, trimY, trimWidth, trimHeight);
}
void createHandle (int index) {
+ state |= HANDLE | CANVAS;
if (handle != 0) {
int clazz = display.PtContainer;
int [] args = {
- OS.Pt_ARG_FLAGS, OS.Pt_GETS_FOCUS, OS.Pt_GETS_FOCUS,
OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
};
shellHandle = OS.PtCreateWidget (clazz, handle, args.length / 3, args);
@@ -140,6 +145,11 @@ void createHandle (int index) {
if ((style & SWT.MENU) != 0) decorations |= OS.Ph_WM_RENDER_MENU;
if ((style & SWT.TITLE) != 0) decorations |= OS.Ph_WM_RENDER_TITLE;
}
+ int notifyFlags =
+ 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;
int titlePtr = OS.malloc (1);
int [] args = {
OS.Pt_ARG_WIDTH, width, 0,
@@ -147,10 +157,8 @@ void createHandle (int index) {
OS.Pt_ARG_WINDOW_TITLE, titlePtr, 0,
OS.Pt_ARG_WINDOW_RENDER_FLAGS, decorations, flags,
OS.Pt_ARG_WINDOW_MANAGED_FLAGS, 0, OS.Ph_WM_CLOSE,
- OS.Pt_ARG_WINDOW_NOTIFY_FLAGS, OS.Ph_WM_ICON, OS.Ph_WM_ICON,
- OS.Pt_ARG_WINDOW_NOTIFY_FLAGS, OS.Ph_WM_FOCUS, OS.Ph_WM_FOCUS,
- OS.Pt_ARG_WINDOW_NOTIFY_FLAGS, OS.Ph_WM_MOVE, OS.Ph_WM_MOVE,
- OS.Pt_ARG_WINDOW_NOTIFY_FLAGS, OS.Ph_WM_RESIZE, OS.Ph_WM_RESIZE,
+ 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_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
};
@@ -159,7 +167,18 @@ void createHandle (int index) {
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, OS.Pt_ALL_OUTLINES,
+ };
+ OS.PtSetResources (scrolledHandle, args.length / 3, args);
+ }
int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
OS.PtGetResources (shellHandle, args.length / 3, args);
resizeBounds (args [1], args [4]);
@@ -170,66 +189,6 @@ void deregister () {
WidgetTable.remove (shellHandle);
}
-void hookEvents () {
- super.hookEvents ();
- int windowProc = getDisplay ().windowProc;
- OS.PtAddCallback (shellHandle, OS.Pt_CB_WINDOW, windowProc, SWT.Move);
- OS.PtAddCallback (shellHandle, OS.Pt_CB_RESIZE, windowProc, -1);
-}
-
-public void open () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- bringToTop ();
- setVisible (true);
-}
-
-int processMove (int info) {
- if (info == 0) return OS.Pt_CONTINUE;
- PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
- OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
- if (cbinfo.cbdata == 0) return OS.Pt_CONTINUE;
- PhWindowEvent_t we = new PhWindowEvent_t ();
- OS.memmove (we, cbinfo.cbdata, PhWindowEvent_t.sizeof);
- switch (we.event_f) {
- case OS.Ph_WM_CLOSE:
- closeWidget ();
- break;
- case OS.Ph_WM_ICON:
- if ((we.state_f & OS.Ph_WM_STATE_ISICONIFIED) != 0) {
- sendEvent (SWT.Iconify);
- } else {
- sendEvent (SWT.Deiconify);
- }
- break;
- case OS.Ph_WM_FOCUS:
- switch (we.event_state) {
- case OS.Ph_WM_EVSTATE_FOCUS: sendEvent (SWT.Activate); break;
- case OS.Ph_WM_EVSTATE_FOCUSLOST: sendEvent (SWT.Deactivate); break;
- }
- break;
- case OS.Ph_WM_MOVE:
- sendEvent (SWT.Move);
- break;
- }
- return OS.Pt_CONTINUE;
-}
-
-int processShellResize (int info) {
- if (info == 0) return OS.Pt_CONTINUE;
- PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
- OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
- if (cbinfo.cbdata == 0) return OS.Pt_CONTINUE;
- int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
- OS.PtGetResources (shellHandle, args.length / 3, args);
- resizeBounds (args [1], args [4]);
- return OS.Pt_CONTINUE;
-}
-
-void register () {
- super.register ();
- WidgetTable.put (shellHandle, this);
-}
public Display getDisplay () {
if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -323,16 +282,125 @@ public Point getSize () {
return new Point (width, height);
}
-void releaseHandle () {
- super.releaseHandle ();
- if (blockedList != 0) OS.PtUnblockWindows (blockedList);
- blockedList = shellHandle = 0;
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (shellHandle, OS.Pt_CB_WINDOW, windowProc, SWT.Move);
+ OS.PtAddCallback (shellHandle, OS.Pt_CB_RESIZE, windowProc, SWT.Resize);
+}
+
+public void open () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ bringToTop ();
+ setVisible (true);
+}
+
+int processEvent (int widget, int data, int info) {
+ if (widget == shellHandle && data == SWT.Resize) {
+ return processShellResize (info);
+ }
+ return super.processEvent (widget, data, info);;
+}
+
+int processHotkey (int data, int info) {
+ if (data != 0) {
+ Widget widget = WidgetTable.get (data);
+ if (widget instanceof MenuItem) {
+ MenuItem item = (MenuItem) widget;
+ if (item.isEnabled ()) item.processSelection (info);
+ }
+ }
+ return OS.Pt_CONTINUE;
+}
+
+int processMove (int info) {
+ if (info == 0) return OS.Pt_CONTINUE;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.cbdata == 0) return OS.Pt_CONTINUE;
+ PhWindowEvent_t we = new PhWindowEvent_t ();
+ OS.memmove (we, cbinfo.cbdata, PhWindowEvent_t.sizeof);
+ switch (we.event_f) {
+ case OS.Ph_WM_CLOSE:
+ closeWidget ();
+ break;
+ case OS.Ph_WM_ICON:
+ if ((we.state_f & OS.Ph_WM_STATE_ISICONIFIED) != 0) {
+ sendEvent (SWT.Iconify);
+ } else {
+ sendEvent (SWT.Deiconify);
+ }
+ break;
+ case OS.Ph_WM_FOCUS:
+ switch (we.event_state) {
+ case OS.Ph_WM_EVSTATE_FOCUS: sendEvent (SWT.Activate); break;
+ case OS.Ph_WM_EVSTATE_FOCUSLOST: sendEvent (SWT.Deactivate); break;
+ }
+ break;
+ case OS.Ph_WM_MOVE:
+ sendEvent (SWT.Move);
+ break;
+ }
+ return OS.Pt_CONTINUE;
+}
+
+int processShellResize (int info) {
+ if (info == 0) return OS.Pt_CONTINUE;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.cbdata == 0) return OS.Pt_CONTINUE;
+ int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ resizeBounds (args [1], args [4]);
+ return OS.Pt_CONTINUE;
+}
+
+void register () {
+ super.register ();
+ WidgetTable.put (shellHandle, this);
}
void realizeWidget() {
/* Do nothing */
}
+void releaseHandle () {
+ super.releaseHandle ();
+ shellHandle = 0;
+}
+
+void releaseShells () {
+ Shell [] shells = getShells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (!shell.isDisposed ()) {
+ /*
+ * Feature in Photon. A shell may have child shells that have been
+ * temporarily reparented to NULL because they were shown without
+ * showing the parent. In this case, Photon will not destroy the
+ * child shells because they are not in the widget hierarchy.
+ * The fix is to detect this case and destroy the shells.
+ */
+ if (shell.parent != null && OS.PtWidgetParent (shell.shellHandle) == 0) {
+ shell.dispose ();
+ } else {
+ shell.releaseWidget ();
+ shell.releaseHandle ();
+ }
+ }
+ }
+}
+
+void releaseWidget () {
+ releaseShells ();
+ super.releaseWidget ();
+ if (blockedList != 0) OS.PtUnblockWindows (blockedList);
+ blockedList = 0;
+ lastFocus = null;
+ display = null;
+}
+
public void removeShellListener (ShellListener listener) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -443,7 +511,6 @@ public void setMenuBar (Menu menu) {
int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
OS.PtGetResources (shellHandle, args.length / 3, args);
int width = args [1], height = args [4];
- PhArea_t area = new PhArea_t ();
if (menuBar != null) {
int menuHandle = menu.handle;
args = new int [] {
@@ -451,22 +518,9 @@ public void setMenuBar (Menu menu) {
OS.Pt_ARG_FLAGS, 0, OS.Pt_DELAY_REALIZE,
};
OS.PtSetResources (menuHandle, args.length / 3, args);
- args = new int [] {OS.Pt_ARG_HEIGHT, 0, 0};
- OS.PtGetResources (menuHandle, args.length / 3, args);
- area.pos_y = (short) args [1];
- area.size_w = (short) width;
- area.size_h = (short) Math.max (0, (height - args [1]));
- OS.PtRealizeWidget (menuBar.handle);
- } else {
- area.size_w = (short) width;
- area.size_h = (short) height;
+ OS.PtRealizeWidget (menuHandle);
}
- int ptr = OS.malloc (PhArea_t.sizeof);
- OS.memmove (ptr, area, PhArea_t.sizeof);
- args = new int [] {OS.Pt_ARG_AREA, ptr, 0};
- OS.PtSetResources (scrolledHandle, args.length / 3, args);
- OS.free (ptr);
- resizeClientArea();
+ resizeBounds(width, height);
}
public void setMinimized (boolean minimized) {
@@ -517,6 +571,19 @@ public void setVisible (boolean visible) {
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
+ * reparent the child shell to NULL and then realize the child
+ * shell.
+ */
+ if (parent != null) {
+ Shell shell = parent.getShell ();
+ int parentHandle = shell.shellHandle;
+ if (!OS.PtWidgetIsRealized (parentHandle)) {
+ OS.PtReParentWidget (shellHandle, visible ? 0 : parentHandle);
+ }
+ }
switch (modal) {
case SWT.PRIMARY_MODAL:
//NOT DONE: should not disable all windows
@@ -530,6 +597,21 @@ public void setVisible (boolean visible) {
}
}
super.setVisible (visible);
+ /*
+ * Feature in Photon. When a shell is shown, it may have child
+ * shells that have been temporarily reparented to NULL because
+ * the child was shown before the parent. The fix is to reparent
+ * the child shells back to the correct parent.
+ */
+ if (visible) {
+ Shell [] shells = getShells ();
+ for (int i=0; i<shells.length; i++) {
+ int childHandle = shells [i].shellHandle;
+ if (OS.PtWidgetParent (childHandle) == 0) {
+ OS.PtReParentWidget (childHandle, shellHandle);
+ }
+ }
+ }
OS.PtSyncWidget (shellHandle);
OS.PtFlush ();
}
@@ -538,4 +620,4 @@ int topHandle () {
return shellHandle;
}
-} \ No newline at end of file
+}
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 b21f1b5831..b371b20828 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.photon.*;
@@ -48,6 +48,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
}
void createHandle (int index) {
+ state |= HANDLE;
Display display = getDisplay ();
int clazz = display.PtScrollbar;
int parentHandle = parent.handle;
@@ -233,4 +234,4 @@ public void setValues (int selection, int minimum, int maximum, int thumb, int i
OS.PtSetResources (handle, args.length / 3, args);
}
-} \ No newline at end of file
+}
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 d69f35ad78..dd6ef94491 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.*;
@@ -89,6 +89,7 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
}
void createHandle (int index) {
+ state |= HANDLE;
Display display = getDisplay ();
int clazz = display.PtPanelGroup;
int parentHandle = parent.handle;
@@ -300,7 +301,10 @@ void releaseWidget () {
int count = args [2];
for (int i=0; i<count; i++) {
TabItem item = items [i];
- if (!item.isDisposed ()) item.releaseWidget ();
+ if (!item.isDisposed ()) {
+ item.releaseWidget ();
+ item.releaseHandle ();
+ }
}
items = null;
super.releaseWidget ();
@@ -357,4 +361,4 @@ public void setSelection (TabItem [] items) {
}
}
-} \ No newline at end of file
+}
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 e41dde1451..9c733f9677 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.*;
@@ -53,11 +53,6 @@ public String getToolTipText () {
return toolTipText;
}
-public boolean isDisposed () {
- //NOT DONE - should have a handle or state flag
- return parent == null;
-}
-
void releaseChild () {
super.releaseChild ();
parent.destroyItem (this);
@@ -67,6 +62,7 @@ void releaseWidget () {
super.releaseWidget ();
control = null;
parent = null;
+ toolTipText = null;
}
public void setControl (Control control) {
@@ -132,4 +128,4 @@ public void setToolTipText (String string) {
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
toolTipText = string;
}
-} \ No newline at end of file
+}
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
index c0897e483c..5cd4dda148 100755
--- 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
@@ -1,18 +1,36 @@
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.*;
-
-/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
- */
-/**
- * This class display rows of items arranged in one or more
- * columns. Items can be selected, columns can be resized.
+/**
+ * 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
@@ -41,9 +59,32 @@ public /*final*/ class Table extends SelectableItemWidget {
// Fix for 1FUSJY5
private int dotsWidth = -1; // width of the static String dots (see above)
/**
- * Create a new instance of Table.
- * @param parent - the parent window of the new instance
- * @param style - window style for the new instance
+ * 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
@@ -101,12 +142,33 @@ void addItem(TableItem item, int index) {
}
addedItem(item, index);
}
-/**
-* Adds the listener to receive events.
-* <p>
-*
-* @param listener the 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.
+ * 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);
@@ -172,6 +234,7 @@ void columnMouseDoubleClick(Event event) {
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
@@ -180,7 +243,7 @@ void columnMouseDoubleClick(Event event) {
itemIndex = (event.y - getHeaderHeight()) / itemHeight + getTopIndex();
hitItem = (TableItem) getVisibleItem(itemIndex);
if (hitItem != null &&
- hitColumn.getIndex() == TableColumn.FIRST) {
+ (hitColumn.getIndex() == TableColumn.FIRST || isFullSelection)) {
if (hitItem.isSelectionHit(event.x) == true) {
columnDblClickEvent = new Event();
columnDblClickEvent.item = hitItem;
@@ -234,10 +297,6 @@ void columnMouseMove(Event event) {
setColumnResizeCursor(false);
}
}
-/**
- * Answer the size of the receiver needed to display all or
- * the first 50 items whichever is less.
- */
public Point computeSize(int wHint, int hHint, boolean changed) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -280,11 +339,22 @@ public Point computeSize(int wHint, int hHint, boolean changed) {
}
return size;
}
-/**
- * Deselect the items identified by the indices stored
- * in 'indices'.
- * A SWT.Selection event will not be sent.
- * @param indices - indices of the items to deselect
+/**
+ * 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);
@@ -304,10 +374,17 @@ public void deselect(int indices[]) {
setLastSelection(item, false);
}
}
-/**
- * Deselect the item identified by 'index'.
- * A SWT.Selection event will not be sent.
- * @param index - index of the item to deselect
+/**
+ * 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);
@@ -319,12 +396,20 @@ public void deselect(int index) {
setLastSelection(item, false);
}
}
-/**
- * Deselect a range of items starting at index 'start'
- * and stopping at index 'end'. Indices that are out of
- * range are ignored. Indexing is zero based.
- * @param start - the start of the range
- * @param end - the end of the range
+/**
+ * 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);
@@ -341,8 +426,13 @@ public void deselect(int start, int end) {
setLastSelection(item, false);
}
}
-/**
- * Deselect all items of the receiver.
+/**
+ * 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);
@@ -518,8 +608,25 @@ void focusOut(Event 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
}
-/**
- * Answer the TableColumn at 'index'.
+/**
+ * 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);
@@ -562,8 +669,22 @@ TableColumn getColumnAtX(int xPosition) {
}
return hitColumn;
}
-/**
- * Answer the number of columns in the receiver.
+/**
+ * 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);
@@ -595,9 +716,25 @@ Cursor getColumnResizeCursor() {
int getColumnResizeX() {
return columnResizeX;
}
-/**
- * Answer an Array containing all columns of receiver except
- * the fill column to the right of all content columns.
+/**
+ * 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);
@@ -650,16 +787,14 @@ TableColumn getFillColumn() {
Control getFocusWindow() {
return focusProxy;
}
-/**
-* Gets the width of a grid line.
-* <p>
-* @return the width of a grid line
-*
-* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
+/**
+ * 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);
@@ -684,10 +819,22 @@ int getHeaderHeight() {
}
return height;
}
-/**
- * Answer whether the header is visible.
- * @return
- * true = header is visible. false = header is not visible
+/**
+ * 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);
@@ -724,9 +871,20 @@ int getIndex(SelectableItem item) {
}
return index;
}
-/**
- * Answer the TableItem located at 'index' in the receiver.
- * @param index - location of the TableItem object to return
+/**
+ * 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);
@@ -738,9 +896,21 @@ public TableItem getItem(int index) {
return (TableItem) getVisibleItem(index);
}
-/**
- * Return the item at the specified position in the widget
- * Return null if the position is outside the widget or in the header widget.
+/**
+ * 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();
@@ -759,8 +929,15 @@ public TableItem getItem(Point point) {
}
return item;
}
-/**
- * Answer the number of items in the receiver.
+/**
+ * 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);
@@ -777,13 +954,16 @@ int getItemCountWhole() {
return clientAreaHeight / 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.
+/**
+ * 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);
@@ -797,8 +977,21 @@ public int getItemHeight() {
int getItemPadding() {
return getGridLineWidth() + getDisplay().textHighlightThickness + 1;
}
-/**
- * Answer all items of the receiver as an Array.
+/**
+ * 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);
@@ -815,11 +1008,22 @@ public TableItem [] getItems() {
Vector getItemVector() {
return items;
}
-/**
- * Answer whether the receiver is drawing grid lines.
- * @return
- * true = receiver draws grid lines
- * false = receiver does not draw grid lines
+/**
+ * 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);
@@ -918,10 +1122,21 @@ int [] getResizeRedrawX(int columnIndex, int columnWidth) {
}
return resizeRedrawX;
}
-/**
- * Answer the selected items of the receiver.
- * @return an Array of TableItems containing the selected items.
- * An empty Array if no items are selected.
+/**
+ * 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);
@@ -934,8 +1149,15 @@ public TableItem [] getSelection() {
return selectionArray;
}
-/**
- * Answer the number of selected items in the receiver.
+/**
+ * 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);
@@ -964,8 +1186,16 @@ Point getFullSelectionExtent(TableItem item) {
}
return selectionExtent;
}
-/**
- * Answer the index of the first selected item of the receiver.
+/**
+ * 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);
@@ -977,10 +1207,20 @@ public int getSelectionIndex() {
}
return index;
}
-/**
- * Answer the indices of the selected items of the receiver.
- * @return an Array containing the indices of the selected items.
- * An empty Array if no items are selected.
+/**
+ * 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);
@@ -993,11 +1233,17 @@ public int [] getSelectionIndices() {
}
return indices;
}
-/**
- * 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.
+/**
+ * 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);
@@ -1096,9 +1342,6 @@ void handleEvents(Event event) {
boolean hasFirstColumnImage() {
return firstColumnImage;
}
-/**
- * Answer whether the receiver has the input focus.
- */
public boolean isFocusControl() {
return hasColumnFocus;
}
@@ -1137,9 +1380,22 @@ void headerMouseMove(Event event) {
update(); // looks better if resize line is drawn immediately
}
}
-/**
- * Answer the index of 'column' in the receiver or -1 if 'column'
- * does not exist in the receiver.
+/**
+ * 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);
@@ -1150,9 +1406,22 @@ public int indexOf(TableColumn column) {
}
return internalGetColumnVector().indexOf(column);
}
-/**
- * Answer the index of 'item' in the receiver or -1 if 'item'
- * does not exist in the receiver.
+/**
+ * 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);
@@ -1170,7 +1439,7 @@ 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
+ 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);
@@ -1331,11 +1600,18 @@ boolean isColumnResize(Event event) {
boolean isColumnResizeStarted() {
return (getResizeColumn() != null);
}
-/**
- * Answer whether the item identified by 'index' is selected.
- * @return
- * true=item identified by 'index' is selected
- * false=item identified by 'index' is not selected.
+/**
+ * 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);
@@ -1545,10 +1821,22 @@ void reindexColumns(int startIndex) {
column.setIndex(i);
}
}
-/**
- * Remove the items identified by the indices stored in
- * 'indices' from the receiver.
- * @param indices - indices of the items to dispose
+/**
+ * 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);
@@ -1576,9 +1864,22 @@ public void remove(int indices[]) {
}
}
}
-/**
- * Remove the item identified by 'index'.
- * @param index - index of the item to dispose
+/**
+ * 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);
@@ -1592,13 +1893,24 @@ public void remove(int index) {
error(SWT.ERROR_ITEM_NOT_REMOVED);
}
}
-/**
- * Remove a range of items starting at index 'start' and
- * stopping at index 'end'.
- * This operation will fail when the index is out of range
- * Indexing is zero based.
- * @param start - the start of the range
- * @param end - the end of the range
+/**
+ * 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);
@@ -1615,8 +1927,13 @@ public void remove(int start, int end) {
}
}
}
-/**
- * Remove all items of the receiver.
+/**
+ * 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);
@@ -1718,13 +2035,23 @@ void removeItem(TableItem item) {
}
}
}
-/**
-* Removes the listener.
-* <p>
-*
-* @param listener the 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
+ */
public void removeSelectionListener(SelectionListener listener) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -1886,11 +2213,22 @@ void scrollVerticalRemovedItem(int index) {
0, destY + itemHeight, // source x, y
clientArea.width, clientArea.height, true);
}
-/**
- * Select the items identified by the indices stored in
- * 'indices'.
- * A SWT.Selection event will not be sent.
- * @param indices - indices of the items to select
+/**
+ * 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);
@@ -1916,10 +2254,17 @@ public void select(int indices[]) {
setLastSelection(item, false);
}
}
-/**
- * Select the item identified by 'index'.
- * A SWT.Selection event will not be sent.
- * @param index - index of the item to select
+/**
+ * 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);
@@ -1934,12 +2279,19 @@ public void select(int index) {
setLastSelection(item, false);
}
}
-/**
- * Select a range of items starting at index 'start' and
- * stopping at index 'end'. Indices that are out of range
- * are ignored. Indexing is zero based.
- * @param start - the start of the range
- * @param end - the end of the range
+/**
+ * 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);
@@ -1967,11 +2319,13 @@ public void select(int start, int end) {
setLastSelection(item, false);
}
}
-/**
- * Select all items of the receiver if it is in multiple
- * selection mode.
- * A SWT.Selection event will not be sent.
- * Do nothing if the receiver is in single selection mode.
+/**
+ * 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);
@@ -2060,10 +2414,6 @@ void setFirstColumnWidth(TableItem item) {
}
}
}
-/**
- * The font is changing. Trigger a recalculation of the item
- * height using all items of the receiver.
- */
public void setFont(Font font) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -2082,10 +2432,21 @@ public void setFont(Font font) {
setRedraw(true); // re-enable redraw
getHeader().setFont(font);
}
-/**
- * Set whether or not the header is visible.
- * @param headerVisible -
- * true = header is visible. false = header is not visible
+/**
+ * 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);
@@ -2110,12 +2471,21 @@ public void setHeaderVisible(boolean headerVisible) {
void setItemVector(Vector newVector) {
items = newVector;
}
-/**
- * Set whether the receiver is drawing grid lines to
- * 'drawGridLines'.
- * @param drawGridLines -
- * true = receiver draws grid lines
- * false = receiver does not draw grid lines
+/**
+ * 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);
@@ -2126,13 +2496,6 @@ public void setLinesVisible(boolean drawGridLines) {
redraw();
}
}
-/**
- * Set whether the receiver and it's children should be
- * drawn or not.
- * @param redraw -
- * true = redraw the receiver and its children
- * false = do not draw the receiver or its children
- */
public void setRedraw(boolean redraw) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -2149,22 +2512,23 @@ public void setRedraw(boolean redraw) {
void setResizeColumn(TableColumn column) {
resizeColumn = column;
}
-/**
-* Sets the selection.
-* <p>
-* The previous selection is cleared
-* before new items are selected.
-*
-* @see Table#deselectAll()
-* @see Table#select(int [])
-*
-* @param indices the indices of the items
-*
-* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
+/**
+ * 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);
@@ -2183,11 +2547,23 @@ public void setSelection(int [] indices) {
deselectAllExcept(keepSelected);
select(indices);
}
-/**
- * Select the items stored in 'items'.
- * A SWT.Selection event is not going to be sent.
- * @param selectionItems - Array containing the items that should
- * be selected
+/**
+ * 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);
@@ -2198,10 +2574,19 @@ public void setSelection(TableItem selectionItems[]) {
}
setSelectableSelection(selectionItems);
}
-/**
- * Set the selection to the item identified by 'index'.
- * SWT.Selection events are not going to be sent.
- * @param index - index of the item that should be selected
+/**
+ * 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);
@@ -2210,12 +2595,20 @@ public void setSelection(int index) {
deselectAllExcept(getVisibleItem(index));
select(index);
}
-/**
- * Set the selection to a range of items starting at index
- * 'start' and stopping at index 'end'. Indices that are out
- * of range are ignored. Indexing is zero based.
- * @param start - the start of the range
- * @param end - the end of the range
+/**
+ * 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);
@@ -2231,14 +2624,17 @@ public void setSelection(int start, int end) {
deselectAllExcept(keepSelected);
select(start, end);
}
-/**
- * Scroll the item at position 'index' to the top of the receiver.
- * If the scroll operation would result in empty space being
- * displayed below the last item of the receiver, the last item is
- * scrolled into view. This results in the specified item not being
- * displayed at the top of the receiver but after the top item.
- * @param index - 0-based index of the item that should be
- * displayed at the top of the receiver's client area.
+/**
+ * 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);
@@ -2267,11 +2663,22 @@ void setTopIndexNoScroll(int index, boolean adjustScrollbar) {
super.setTopIndexNoScroll(index, adjustScrollbar);
moveColumnsVertical();
}
-/**
- * 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.
+/**
+ * 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);
@@ -2282,11 +2689,20 @@ public void showItem(TableItem item) {
}
showSelectableItem(item);
}
-/**
- * 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.
+/**
+ * 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);
@@ -2358,4 +2774,4 @@ String trimItemText(String text, int maxWidth, GC gc) {
return text;
}
-} \ No newline at end of file
+}
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
index 55c9ba604c..dc981d2a72 100755
--- 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
@@ -1,17 +1,25 @@
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.*;
-
-/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
- */
-/**
- * A TableColumn stores such data as column label, label alignmentand size.
- * It routes paint requests to the corresponding table item.
+/**
+ * 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
@@ -67,19 +75,25 @@ public TableColumn(Table parent, int style, int index) {
public void handleEvent(Event event) {disposeColumn();}
});
}
-/**
-* Adds the listener to receive events.
-* <p>
-*
-* @param listener the listener
-*
-* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception SWTError(ERROR_NULL_ARGUMENT)
-* when listener is null
-*/
+/**
+ * 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);
@@ -88,19 +102,30 @@ public void addControlListener(ControlListener listener) {
addListener (SWT.Resize,typedListener);
addListener (SWT.Move,typedListener);
}
-/**
-* Adds the listener to receive events.
-* <p>
-*
-* @param listener the listener
-*
-* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception SWTError(ERROR_NULL_ARGUMENT)
-* when listener is null
-*/
+/**
+ * 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);
@@ -154,20 +179,18 @@ static TableColumn createFillColumn(Table parent) {
void disposeColumn() {
getParent().removeColumn(this);
}
-/**
-* Gets the alignment.
-* <p>
-* The alignment of a widget controls the position of the
-* text or image in the widget. The alignment may be one
-* of LEFT, RIGHT or CENTER.
-*
-* @return the alignment
-*
-* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
+/**
+ * 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);
@@ -183,9 +206,6 @@ public int getAlignment () {
Rectangle getBounds() {
return new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height); // copy the object to prevent changes
}
-/**
- * Gets the Display.
- */
public Display getDisplay() {
if (parent == null) { // access parent field directly to prevent endless recursion
error(SWT.ERROR_WIDGET_DISPOSED);
@@ -199,8 +219,15 @@ public Display getDisplay() {
int getIndex() {
return index;
}
-/**
- * Answer the parent widget of the receiver.
+/**
+ * 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);
@@ -208,32 +235,34 @@ public Table getParent() {
return parent;
}
-/**
-* Gets the resize attribute.
-* <p>
-* @return the resize attribute
-*
-* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
+/**
+ * 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.
-* <p>
-* @return the width
-*
-* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
+/**
+ * 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);
@@ -256,17 +285,17 @@ void internalSetBounds(Rectangle newBounds) {
boolean isDefaultWidth() {
return isDefaultWidth;
}
-/**
-* Packs the widget.
-* <p>
-* Packing a widget causes it to be resized to the
-* preferred size for the widget.
-*
-* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
+/**
+ * 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);
@@ -289,19 +318,23 @@ void paint(TableItem item, GC gc, int yPosition) {
item.paint(gc, paintPosition, this);
}
-/**
-* Removes the listener.
-* <p>
-*
-* @param listener the listener
-*
-* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception SWTError(ERROR_NULL_ARGUMENT)
-* when listener is 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
+ */
public void removeControlListener (ControlListener listener) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -310,19 +343,23 @@ public void removeControlListener (ControlListener listener) {
eventTable.unhook (SWT.Move, listener);
eventTable.unhook (SWT.Resize, listener);
}
-/**
-* Removes the listener.
-* <p>
-*
-* @param listener the listener
-*
-* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception SWTError(ERROR_NULL_ARGUMENT)
-* when listener is 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
+ */
public void removeSelectionListener(SelectionListener listener) {
if (!isValidThread ()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error(SWT.ERROR_WIDGET_DISPOSED);
@@ -333,20 +370,18 @@ public void removeSelectionListener(SelectionListener listener) {
removeListener(SWT.Selection, listener);
removeListener(SWT.DefaultSelection, listener);
}
-/**
-* Sets the alignment.
-* <p>
-* The alignment of a widget controls the position of the
-* text or image in the widget. The alignement may be one
-* of LEFT, RIGHT or CENTER.
-*
-* @param alignment the new alignment
-*
-* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
+/**
+ * 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);
@@ -396,25 +431,24 @@ void setDefaultWidth(boolean isDefaultWidth) {
void setIndex(int newIndex) {
this.index = newIndex;
}
-/**
-* Sets the resize attribute.
-* <p>
-* @param resizee the resize attribute
-*
-* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
+/**
+ * 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;
}
-/**
- * Set the text of the receiver to 'text'.
- */
public void setText(String newText) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -428,16 +462,16 @@ public void setText(String newText) {
getParent().getHeader().redraw(index);
}
}
-/**
-* Sets the width.
-* <p>
-* @param width the width
-*
-* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
+/**
+ * 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);
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
index 6919d84766..6da0ba377e 100755
--- 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
@@ -1,18 +1,26 @@
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.*;
-/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
- */
-
/**
- * A table item is a selectable user interface object
+ * Instances of this class represent a selectable user interface object
* that represents an item in a table.
- * Table items can consist of multiple columns called sub items.
+ * <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
@@ -87,17 +95,20 @@ static Table checkNull(Table table) {
protected void checkSubclass () {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
-/**
- * The receiver is destroyed. Remove it from its parent widget.
- */
-void disposeItem() {
- getParent().removeItem(this);
+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.disposeItem();
+ super.doDispose();
}
+
/**
* Draw the image of the receiver for column 'index' at
* 'destinationPosition' using 'gc'.
@@ -170,15 +181,17 @@ void drawText(String label, GC gc, Point position, int index) {
}
/**
-* Gets the item bounds at an index
-* <p>
-* @return the item bounds
-*
-* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
+ * 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);
@@ -216,9 +229,16 @@ public Rectangle getBounds(int index) {
return itemBounds;
}
/**
- * Return whether or not the receiver is checked.
- * Always return false if the parent of the receiver does not
- * have the CHECK style.
+ * 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);
@@ -242,9 +262,6 @@ int getCheckboxXPosition() {
Vector getDataLabels() {
return dataLabels;
}
-/**
- * Answer the display of the receiver's parent widget.
- */
public Display getDisplay() {
return super.getDisplay();
}
@@ -279,14 +296,16 @@ int getDotStartX(int columnIndex, int columnWidth) {
return dotStartX;
}
/**
- * Gets the grayed state.
- * <p>
- * @return the item grayed state.
+ * 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 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>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if 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);
@@ -294,9 +313,6 @@ public boolean getGrayed() {
return super.getGrayed();
}
-/**
- * Answer the item image of the first column.
- */
public Image getImage() {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -304,9 +320,11 @@ public Image getImage() {
return getImage(0);
}
/**
- * Answer the item image of the column identified by 'columnIndex' or
+ * 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 answered
+ *
+ * @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);
@@ -321,15 +339,18 @@ public Image getImage(int columnIndex) {
return image;
}
/**
-* Gets the image bounds at an index
-* <p>
-* @return the item icon's bounds
-*
-* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
+ * 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);
@@ -353,15 +374,15 @@ public Rectangle getImageBounds(int index) {
return imageBounds;
}
/**
-* Gets the image indent.
-* <p>
-* @return the indent
-*
-* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
+ * 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);
@@ -462,7 +483,14 @@ int getMaxTextWidth(int columnIndex, int columnWidth) {
return columnWidth - itemWidth;
}
/**
- * Answer the parent widget of the receiver.
+ * 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);
@@ -510,9 +538,6 @@ Point getSelectionExtent() {
int getSelectionX() {
return getImageStopX(TableColumn.FIRST) + getParent().getHorizontalOffset();
}
-/**
- * Answer the item text of the first column.
- */
public String getText() {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -520,10 +545,11 @@ public String getText() {
return getText(0);
}
/**
- * Answer the item tezt of the column identified by 'columnIndex'.
- * Answer null if no text has been set for that column.
- * @param columnIndex - the column whose text should be answered.
- * null if no text has been set for that column.
+ * 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);
@@ -653,7 +679,7 @@ void insertColumn(TableColumn column) {
}
/**
* Sets the image at an index.
- * <p>
+ *
* @param image the new image (or null)
*
* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
@@ -681,7 +707,6 @@ void internalSetImage(int columnIndex, Image image) {
}
/**
* Sets the widget text.
-* <p>
*
* The widget text for an item is the label of the
* item or the label of the text specified by a column
@@ -846,8 +871,18 @@ void reset(int index) {
}
}
/**
-* Warning: API under construction.
-*/
+ * 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);
@@ -863,14 +898,18 @@ public void setImage(Image [] images) {
}
}
/**
- * Sets the image at an index.
- * <p>
- * @param image the new image (or null)
+ * Sets the receiver's image at a column.
*
- * @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
- * when called from the wrong thread
- * @exception SWTError(ERROR_WIDGET_DISPOSED)
- * when the widget has been disposed
+ * @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);
@@ -880,11 +919,6 @@ public void setImage(int columnIndex, Image image) {
internalSetImage(columnIndex, image);
}
}
-/**
- * Set the item image of the first column to 'image'.
- * @param image - the item image of the first column. Image
- * will be removed if this is null.
- */
public void setImage(Image image) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -892,15 +926,16 @@ public void setImage(Image image) {
setImage(0, image);
}
/**
-* Sets the image indent.
-* <p>
-* @param indent the new indent
-*
-* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-*/
+ * 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);
@@ -917,7 +952,17 @@ public void setImageIndent(int indent) {
}
}
/**
- * Warning: API under construction.
+ * 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);
@@ -937,23 +982,19 @@ public void setText(String [] strings) {
}
}
/**
-* Sets the widget text.
-* <p>
-*
-* 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
-*
-* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
-* when called from the wrong thread
-* @exception SWTError(ERROR_WIDGET_DISPOSED)
-* when the widget has been disposed
-* @exception SWTError(ERROR_NULL_ARGUMENT)
-* when string is null
-*/
+ * 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);
@@ -965,11 +1006,6 @@ public void setText (int columnIndex, String string) {
internalSetText(columnIndex, string);
}
}
-/**
- * Set the item text of the first column to 'text'.
- * @param text - the item text of the first column. May be null if the
- * text label should be removed.
- */
public void setText(String text) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -997,8 +1033,14 @@ void setTrimmedText(String label, int columnIndex) {
}
}
/**
- * Set the checked state to 'checked' if the parent of the
- * receiver has the CHECK style.
+ * 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);
@@ -1007,14 +1049,14 @@ public void setChecked(boolean checked) {
super.setChecked(checked);
}
/**
- * Sets the grayed state.
- * <p>
- * @param grayed the new grayed state.
+ * Sets the grayed state of the receiver.
+ *
+ * @param checked 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>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if 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);
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 407924fdc7..d14ced445a 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.*;
@@ -15,7 +15,7 @@ public class Text extends Scrollable {
char echoCharacter;
boolean ignoreChange;
String hiddenText;
- int lastModifiedText;
+ int tabs, lastModifiedText;
PtTextCallback_t textVerify;
public static final int LIMIT;
@@ -79,12 +79,15 @@ public void clearSelection () {
OS.PtTextSetSelection (handle, new int [] {0}, new int [] {0});
}
void createHandle (int index) {
+ state |= HANDLE;
Display display = getDisplay ();
int parentHandle = parent.handle;
+ boolean hasBorder = (style & SWT.BORDER) != 0;
int textFlags = (style & SWT.READ_ONLY) != 0 ? 0 : OS.Pt_EDITABLE;
if ((style & SWT.SINGLE) != 0) {
int clazz = display.PtText;
int [] args = {
+ OS.Pt_ARG_FLAGS, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
OS.Pt_ARG_FLAGS, OS.Pt_CALLBACKS_ACTIVE, OS.Pt_CALLBACKS_ACTIVE,
OS.Pt_ARG_TEXT_FLAGS, textFlags, OS.Pt_EDITABLE,
OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
@@ -96,6 +99,7 @@ void createHandle (int index) {
int clazz = display.PtMultiText;
int wrapFlags = (style & SWT.WRAP) != 0 ? OS.Pt_EMT_WORD | OS.Pt_EMT_CHAR : 0;
int [] args = {
+ OS.Pt_ARG_FLAGS, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
OS.Pt_ARG_FLAGS, OS.Pt_CALLBACKS_ACTIVE, OS.Pt_CALLBACKS_ACTIVE,
OS.Pt_ARG_TEXT_FLAGS, textFlags, OS.Pt_EDITABLE,
OS.Pt_ARG_MULTITEXT_WRAP_FLAGS, wrapFlags, OS.Pt_EMT_WORD | OS.Pt_EMT_CHAR,
@@ -108,6 +112,12 @@ void createHandle (int index) {
createScrollBars();
}
+void createWidget (int index) {
+ super.createWidget (index);
+// doubleClick = true;
+ setTabStops (tabs = 8);
+}
+
public void addModifyListener (ModifyListener listener) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -173,6 +183,21 @@ public void cut () {
OS.PtTextModifyText (handle, start [0], end [0], start [0], buffer, buffer.length);
}
+void deregister () {
+ super.deregister ();
+
+ /*
+ * Bug in Photon. Even though the Pt_CB_GOT_FOCUS callback
+ * is added to the multi-line text, the widget parameter
+ * in the callback is a child of the multi-line text. The fix
+ * is to register that child so that the lookup in the widget
+ * table will find the muti-line text.
+ */
+ if ((style & SWT.MULTI) == 0) return;
+ int child = OS.PtWidgetChildBack (handle);
+ WidgetTable.remove (child);
+}
+
public int getCaretLineNumber () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -267,6 +292,11 @@ public int getLineHeight () {
return extent.lr_y - extent.ul_y + 1 + args [4];
}
+String getNameText () {
+ if ((style & SWT.SINGLE) != 0) return getText ();
+ return getText (0, Math.min(getCharCount () - 1, 10));
+}
+
public Point getSelection () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -305,8 +335,19 @@ public String getSelectionText () {
public int getTabs () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
- //NOT DONE - NOT NEEDED
- return 0;
+ return tabs;
+}
+
+int getTabWidth (int tabs) {
+ int [] args = new int [] {OS.Pt_ARG_TEXT_FONT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ PhRect_t rect = new PhRect_t ();
+ int ptr = OS.malloc (1);
+ OS.memmove (ptr, new byte [] {' '}, 1);
+ OS.PfExtentText(rect, null, args [1], ptr, 1);
+ OS.free (ptr);
+ int width = rect.lr_x - rect.ul_x + 1;
+ return width * tabs;
}
public String getText (int start, int end) {
@@ -363,9 +404,6 @@ public int getTopPixel () {
void hookEvents () {
super.hookEvents ();
int windowProc = getDisplay ().windowProc;
- if ((style & SWT.MULTI) != 0) {
- OS.PtAddFilterCallback (handle, OS.Ph_EV_KEY, windowProc, SWT.KeyDown);
- }
OS.PtAddCallback (handle, OS.Pt_CB_MODIFY_VERIFY, windowProc, SWT.Verify);
OS.PtAddCallback (handle, OS.Pt_CB_TEXT_CHANGED, windowProc, SWT.Modify);
}
@@ -404,6 +442,24 @@ public void paste () {
OS.free(ptr);
}
+int processEvent (int widget, int data, int info) {
+
+ /*
+ * Bug in Photon. Even though the Pt_CB_GOT_FOCUS callback
+ * is added to the multi-line text, the widget parameter
+ * in the callback is a child of the multi-line text. The fix
+ * is to register that child so that the lookup in the widget
+ * table will find the muti-line text and avoid multiple
+ * Pt_CB_LOST_FOCUS callbacks.
+ */
+ if ((style & SWT.MULTI) != 0) {
+ if (widget != handle && data == SWT.FocusOut) {
+ return OS.Pt_CONTINUE;
+ }
+ }
+ return super.processEvent (widget, data, info);
+}
+
int processModify (int info) {
if (lastModifiedText != 0) {
OS.free (lastModifiedText);
@@ -478,12 +534,27 @@ int processVerify (int info) {
return 0;
}
+void register () {
+ super.register ();
+
+ /*
+ * Bug in Photon. Even though the Pt_CB_GOT_FOCUS callback
+ * is added to the multi-line text, the widget parameter
+ * in the callback is a child of the multi-line text. The fix
+ * is to register that child so that the lookup in the widget
+ * table will find the muti-line text.
+ */
+ if ((style & SWT.MULTI) == 0) return;
+ int child = OS.PtWidgetChildBack (handle);
+ WidgetTable.put (child, this);
+}
+
void releaseWidget () {
super.releaseWidget ();
- if (lastModifiedText != 0) {
- OS.free (lastModifiedText);
- lastModifiedText = 0;
- }
+ if (lastModifiedText != 0) OS.free (lastModifiedText);
+ lastModifiedText = 0;
+ hiddenText = null;
+ textVerify = null;
}
public void removeModifyListener (ModifyListener listener) {
@@ -553,6 +624,11 @@ public void setEditable (boolean editable) {
OS.PtSetResources(handle, args.length / 3, args);
}
+public void setFont (Font font) {
+ super.setFont (font);
+ setTabStops (tabs);
+}
+
public void setSelection (int position) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -577,8 +653,17 @@ public void setTabs (int tabs) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
if (tabs < 0) return;
+ setTabStops (this.tabs = tabs);
+}
- //NOT DONE - NOT NEEDED
+void setTabStops (int tabs) {
+ if ((style & SWT.SINGLE) != 0) return;
+ int tabsWidth = getTabWidth (tabs);
+ int ptr = OS.malloc (4);
+ OS.memmove (ptr, new int [] {tabsWidth}, 4);
+ int [] args = {OS.Pt_ARG_MULTITEXT_TABS, ptr, 1};
+ OS.PtSetResources (handle, args.length / 3, args);
+ OS.free (ptr);
}
public void setText (String string) {
@@ -616,4 +701,15 @@ public void showSelection () {
//NOT DONE - NOT NEEDED
}
-} \ No newline at end of file
+int traversalCode (int key_sym, PhKeyEvent_t ke) {
+ if ((style & SWT.SINGLE) != 0) {
+ int code = super.traversalCode (key_sym, ke);
+ if (key_sym == OS.Pk_Right || key_sym == OS.Pk_Left) {
+ code &= ~(SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS);
+ }
+ return code;
+ }
+ return SWT.TRAVERSE_ESCAPE;
+}
+
+}
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 5b61c7394e..707d5df752 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.photon.*;
@@ -15,6 +15,20 @@ public /*final*/ class ToolBar extends Composite {
public ToolBar (Composite parent, int style) {
super (parent, checkStyle (style));
+
+ /*
+ * Ensure that either of HORIZONTAL or VERTICAL is set.
+ * NOTE: HORIZONTAL and VERTICAL have the same values
+ * as H_SCROLL and V_SCROLL so it is necessary to first
+ * clear these bits to avoid scroll bars and then reset
+ * the bits using the original style supplied by the
+ * programmer.
+ */
+ this.style = checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+ int [] args = {
+ OS.Pt_ARG_ORIENTATION, (style & SWT.VERTICAL) == 0 ? OS.Pt_HORIZONTAL : OS.Pt_VERTICAL, 0,
+ };
+ OS.PtSetResources(handle, args.length / 3, args);
}
static int checkStyle (int style) {
/*
@@ -52,10 +66,13 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
}
void createHandle (int index) {
+ state |= HANDLE;
Display display = getDisplay ();
int parentHandle = parent.handle;
int [] args = {
+ OS.Pt_ARG_FLAGS, hasBorder () ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
+ OS.Pt_ARG_TOOLBAR_FLAGS, 0, OS.Pt_TOOLBAR_DRAGGABLE | OS.Pt_TOOLBAR_END_SEPARATOR,
OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
};
handle = OS.PtCreateWidget (OS.PtToolbar (), parentHandle, args.length / 3, args);
@@ -146,10 +163,11 @@ void releaseWidget () {
ToolItem item = items [i];
if (item != null && !item.isDisposed ()) {
item.releaseWidget ();
+ item.releaseHandle ();
}
}
items = null;
super.releaseWidget ();
}
-} \ No newline at end of file
+}
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 d8e1d10127..305bfc6873 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.*;
@@ -15,7 +15,9 @@ public /*final*/ class ToolItem extends Item {
ToolBar parent;
Control control;
String toolTipText;
+ int toolTipHandle;
Image hotImage, disabledImage;
+ int button, arrow;
public ToolItem (ToolBar parent, int style) {
this(parent, style, parent.getItemCount ());
@@ -44,7 +46,32 @@ protected void checkSubclass () {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
+int createArrowImage () {
+ short width = 5;
+ short height = 4;
+ int image = OS.PhCreateImage(null, width, height, OS.Pg_IMAGE_DIRECT_888, 0, 0, 0);
+ if (image == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ PhDim_t dim = new PhDim_t();
+ dim.w = width;
+ dim.h = height;
+ int mc = OS.PmMemCreateMC(image, dim, new PhPoint_t());
+ if (mc == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ OS.PmMemStart(mc);
+ OS.PgSetFillColor(0xFFFFFF);
+ OS.PgDrawIRect(0, 0, width, height, OS.Pg_DRAW_FILL);
+ OS.PgSetStrokeColor(0x000000);
+ OS.PgSetFillColor(0x000000);
+ short [] points = {(short)0, (short)1, (short)2, (short)3, (short)4, (short)1};
+ OS.PgDrawPolygon(points, points.length / 2, new PhPoint_t(), OS.Pg_DRAW_FILL | OS.Pg_DRAW_STROKE | OS.Pg_CLOSED);
+ OS.PmMemFlush(mc, image);
+ OS.PmMemStop(mc);
+ OS.PmMemReleaseMC(mc);
+ OS.PhMakeTransBitmap(image, 0xFFFFFF);
+ return image;
+}
+
void createHandle (int index) {
+ state |= HANDLE;
int count = parent.getItemCount();
if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
int parentHandle = parent.handle;
@@ -57,6 +84,30 @@ void createHandle (int index) {
OS.Pt_ARG_RESIZE_FLAGS, OS.Pt_RESIZE_Y_ALWAYS, OS.Pt_RESIZE_XY_BITS,
};
handle = OS.PtCreateWidget (OS.PtContainer (), parentHandle, args.length / 3, args);
+ } else if ((style & SWT.DROP_DOWN) != 0) {
+ int [] args = {
+ OS.Pt_ARG_GROUP_ORIENTATION, OS.Pt_GROUP_HORIZONTAL, 0,
+ OS.Pt_ARG_GROUP_FLAGS, OS.Pt_GROUP_EQUAL_SIZE_VERTICAL, OS.Pt_GROUP_EQUAL_SIZE_VERTICAL,
+ };
+ handle = OS.PtCreateWidget (OS.PtGroup (), parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ boolean rightAligned = (parent.style & SWT.RIGHT) != 0;
+ args = new int [] {
+ OS.Pt_ARG_BALLOON_POSITION, rightAligned ? OS.Pt_BALLOON_RIGHT : OS.Pt_BALLOON_BOTTOM, 0,
+ OS.Pt_ARG_BASIC_FLAGS, 0, OS.Pt_RIGHT_ETCH | OS.Pt_RIGHT_OUTLINE,
+ };
+ button = OS.PtCreateWidget (OS.PtButton (), handle, args.length / 3, args);
+ if (button == 0) error (SWT.ERROR_NO_HANDLES);
+ int arrowImage = createArrowImage ();
+ args = new int [] {
+ OS.Pt_ARG_LABEL_IMAGE, arrowImage, 0,
+ OS.Pt_ARG_LABEL_TYPE, OS.Pt_IMAGE, 0,
+ OS.Pt_ARG_MARGIN_WIDTH, 1, 0,
+ OS.Pt_ARG_BASIC_FLAGS, 0, OS.Pt_LEFT_ETCH | OS.Pt_LEFT_OUTLINE,
+ };
+ arrow = OS.PtCreateWidget (OS.PtButton (), handle, args.length / 3, args);
+ OS.free (arrowImage);
+ if (arrow == 0) error (SWT.ERROR_NO_HANDLES);
} else {
boolean rightAligned = (parent.style & SWT.RIGHT) != 0;
boolean toggle = (style & (SWT.CHECK | SWT.RADIO)) != 0;
@@ -64,7 +115,7 @@ void createHandle (int index) {
OS.Pt_ARG_BALLOON_POSITION, rightAligned ? OS.Pt_BALLOON_RIGHT : OS.Pt_BALLOON_BOTTOM, 0,
OS.Pt_ARG_FLAGS, toggle ? OS.Pt_TOGGLE : 0, OS.Pt_TOGGLE,
};
- handle = OS.PtCreateWidget (OS.PtButton (), parentHandle, args.length / 3, args);
+ handle = button = OS.PtCreateWidget (OS.PtButton (), parentHandle, args.length / 3, args);
}
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
if (index != count) {
@@ -87,6 +138,14 @@ void createHandle (int index) {
}
}
+void deregister () {
+ super.deregister ();
+ if ((style & SWT.DROP_DOWN) != 0) {
+ WidgetTable.remove (button);
+ WidgetTable.remove (arrow);
+ }
+}
+
public Rectangle getBounds () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -158,8 +217,13 @@ public int getWidth () {
void hookEvents () {
super.hookEvents ();
+ if ((style & SWT.SEPARATOR) != 0) return;
int windowProc = getDisplay ().windowProc;
- OS.PtAddCallback (handle, OS.Pt_CB_ACTIVATE, windowProc, SWT.Selection);
+ OS.PtAddEventHandler (handle, OS.Ph_EV_BOUNDARY, windowProc, SWT.MouseEnter);
+ OS.PtAddCallback (button, OS.Pt_CB_ACTIVATE, windowProc, SWT.Selection);
+ if ((style & SWT.DROP_DOWN) != 0) {
+ OS.PtAddCallback (arrow, OS.Pt_CB_ACTIVATE, windowProc, SWT.Selection);
+ }
}
public boolean isEnabled () {
@@ -168,6 +232,41 @@ public boolean isEnabled () {
return getEnabled () && parent.isEnabled ();
}
+int processEvent (int widget, int data, int info) {
+ if (widget == arrow && data == SWT.Selection) {
+ Event event = new Event ();
+ event.detail = SWT.ARROW;
+ postEvent (SWT.Selection, event);
+ return OS.Pt_CONTINUE;
+ }
+ return super.processEvent (widget, data, info);;
+}
+
+int processMouseEnter (int info) {
+ if (info == 0) return OS.Pt_END;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.event == 0) return OS.Pt_END;
+ PhEvent_t ev = new PhEvent_t ();
+ OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
+ switch (ev.subtype) {
+ case OS.Ph_EV_PTR_STEADY:
+ int [] args = {OS.Pt_ARG_TEXT_FONT, 0, 0};
+ OS.PtGetResources (button, args.length / 3, args);
+ int length = OS.strlen (args [1]);
+ byte [] font = new byte [length + 1];
+ OS.memmove (font, args [1], length);
+ destroyToolTip (toolTipHandle);
+ toolTipHandle = createToolTip (toolTipText, button, font);
+ break;
+ case OS.Ph_EV_PTR_UNSTEADY:
+ destroyToolTip (toolTipHandle);
+ toolTipHandle = 0;
+ break;
+ }
+ return OS.Pt_END;
+}
+
int processSelection (int info) {
if ((style & SWT.RADIO) != 0) {
setSelection (true);
@@ -188,17 +287,31 @@ int processSelection (int info) {
return OS.Pt_CONTINUE;
}
+void register () {
+ super.register ();
+ if ((style & SWT.DROP_DOWN) != 0) {
+ WidgetTable.put (button, this);
+ WidgetTable.put (arrow, this);
+ }
+}
+
void releaseChild () {
super.releaseChild ();
parent.destroyItem (this);
}
+void releaseHandle () {
+ super.releaseHandle ();
+ arrow = button = 0;
+}
+
void releaseWidget () {
super.releaseWidget ();
parent = null;
control = null;
hotImage = null;
disabledImage = null;
+ toolTipText = null;
}
public void removeSelectionListener(SelectionListener listener) {
@@ -261,7 +374,7 @@ public void setImage (Image image) {
if (image != null) {
imageHandle = copyPhImage (image.handle);
int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
+ OS.PtGetResources (button, args.length / 3, args);
if (args [1] != 0 && OS.strlen (args [1]) > 0) type = OS.Pt_TEXT_IMAGE;
else type = OS.Pt_IMAGE;
}
@@ -269,8 +382,20 @@ public void setImage (Image image) {
OS.Pt_ARG_LABEL_IMAGE, imageHandle, 0,
OS.Pt_ARG_LABEL_TYPE, type, 0
};
- OS.PtSetResources (handle, args.length / 3, args);
+ OS.PtSetResources (button, args.length / 3, args);
if (imageHandle != 0) OS.free (imageHandle);
+
+ /*
+ * Bug on Photon. When a the text/image is set on a
+ * DROP_DOWN item that is realized, the item does not resize
+ * to show the new text/image. The fix is to force the item
+ * to recalculate the size.
+ */
+ if ((style & SWT.DROP_DOWN) != 0) {
+ if (OS.PtWidgetIsRealized (handle)) {
+ OS.PtExtentWidget (handle);
+ }
+ }
}
public void setSelection (boolean selected) {
@@ -293,7 +418,7 @@ public void setText (String string) {
ptr = OS.malloc (buffer.length);
OS.memmove (ptr, buffer, buffer.length);
int [] args = {OS.Pt_ARG_LABEL_IMAGE, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
+ OS.PtGetResources (button, args.length / 3, args);
if (args [1] != 0) type = OS.Pt_TEXT_IMAGE;
else type = OS.Pt_Z_STRING;
}
@@ -301,8 +426,20 @@ public void setText (String string) {
OS.Pt_ARG_TEXT_STRING, ptr, 0,
OS.Pt_ARG_LABEL_TYPE, type, 0,
};
- OS.PtSetResources (handle, args.length / 3, args);
+ OS.PtSetResources (button, args.length / 3, args);
if (ptr != 0) OS.free (ptr);
+
+ /*
+ * Bug on Photon. When a the text/image is set on a
+ * DROP_DOWN item that is realized, the item does not resize
+ * to show the new text/image. The fix is to force the item
+ * to recalculate the size.
+ */
+ if ((style & SWT.DROP_DOWN) != 0) {
+ if (OS.PtWidgetIsRealized (handle)) {
+ OS.PtExtentWidget (handle);
+ }
+ }
}
public void setToolTipText (String string) {
@@ -322,4 +459,4 @@ public void setWidth (int width) {
control.setBounds (getBounds ());
}
}
-} \ No newline at end of file
+}
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 13657ad4b0..9870e1603c 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
@@ -1,8 +1,8 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.photon.*;
@@ -43,6 +43,44 @@ public void close () {
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
tracking = false;
}
+
+void drawRectangles () {
+ if (parent != null) {
+ if (parent.isDisposed ()) return;
+ parent.getShell ().update ();
+ } else {
+ display.update ();
+ }
+ int rid = OS.Ph_DEV_RID;
+ if (parent != null) rid = OS.PtWidgetRid (parent.handle);
+
+ int phGC = OS.PgCreateGC (0);
+ if (phGC == 0) return;
+ int prevContext = OS.PgSetGC (phGC);
+ OS.PgSetRegion (rid);
+ OS.PgSetDrawMode (OS.Pg_DRAWMODE_XOR);
+ OS.PgSetFillColor (0xffffff);
+
+ int bandWidth = 0;
+ if (stippled) {
+ bandWidth = 2;
+ OS.PgSetFillTransPat (OS.Pg_PAT_HALF);
+ }
+ for (int i=0; i<rectangles.length; i++) {
+ Rectangle r = rectangles [i];
+ int x1 = r.x;
+ int y1 = r.y;
+ int x2 = r.x + r.width;
+ int y2 = r.y + r.height;
+ OS.PgDrawIRect(x1, y1, x2, y1 + bandWidth, OS.Pg_DRAW_FILL);
+ OS.PgDrawIRect(x1, y1 + bandWidth + 1, x1 + bandWidth, y2 - bandWidth - 1, OS.Pg_DRAW_FILL);
+ OS.PgDrawIRect(x2 - bandWidth, y1 + bandWidth + 1, x2, y2 - bandWidth - 1, OS.Pg_DRAW_FILL);
+ OS.PgDrawIRect(x1, y2 - bandWidth, x2, y2, OS.Pg_DRAW_FILL);
+ }
+ OS.PgSetGC (prevContext);
+ OS.PgDestroyGC (phGC);
+}
+
public Display getDisplay () {
return display;
}
@@ -60,38 +98,103 @@ public boolean getStippled () {
public boolean open () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
-// int handle = parent.handle;
- PhRect_t r = new PhRect_t ();
- OS.PhWindowQueryVisible (OS.Ph_QUERY_GRAPHICS, 0, 1, r);
- int width = (short) (r.lr_x - r.ul_x + 1);
- int height = (short) (r.lr_y - r.ul_y + 1);
+ 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 = {
- OS.Pt_ARG_WIDTH, 200 /*width*/, 0,
- OS.Pt_ARG_HEIGHT, 200 /*height*/, 0,
+ OS.Pt_ARG_WIDTH, 0, 0,
+ OS.Pt_ARG_HEIGHT, 0, 0,
OS.Pt_ARG_REGION_OPAQUE, 0, ~0,
-// OS.Pt_ARG_REGION_SENSE, OS.Ph_EV_BUT_PRESS | OS.Ph_EV_DRAG, ~0,
-// OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,
+ OS.Pt_ARG_REGION_SENSE, sense, ~0,
+ OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,
};
OS.PtSetParentWidget (0);
int handle = OS.PtCreateWidget (OS.PtRegion (), 0, args.length / 3, args);
OS.PtRealizeWidget (handle);
+ PhRect_t rect = new PhRect_t ();
int rid = OS.PtWidgetRid (handle);
int input_group = OS.PhInputGroup (0);
- PhRect_t rect1 = new PhRect_t ();
- for (int i=0; i<rectangles.length; i++) {
- Rectangle rect = rectangles [i];
- PhRect_t rect2 = new PhRect_t ();
- rect2.ul_x = (short) rect.x;
- rect2.ul_y = (short) rect.y;
- rect2.lr_x = (short) (rect.x + rect.width - 1);
- rect2.lr_y = (short) (rect.y + rect.height - 1);
- if (i == 0) rect1 = rect2;
- OS.PhRectUnion (rect1, rect2);
+ OS.PhInitDrag (rid, OS.Ph_DRAG_KEY_MOTION | OS.Ph_TRACK_DRAG, rect, null, input_group, null, null, null, null, null);
+ PhCursorInfo_t info = new PhCursorInfo_t ();
+ OS.PhQueryCursor ((short)input_group, info);
+ int oldX = info.pos_x;
+ int oldY = info.pos_y;
+ int size = PhEvent_t.sizeof + 1024;
+ int buffer = OS.malloc (size);
+ PhEvent_t event = new PhEvent_t ();
+ Event ev = new Event ();
+
+ drawRectangles ();
+ boolean tracking = true;
+ boolean cancelled = false;
+ while (tracking && !cancelled) {
+ if (parent != null && parent.isDisposed ()) break;
+ int result = OS.PhEventNext (buffer, size);
+ switch (result) {
+ case OS.Ph_EVENT_MSG: break;
+ case OS.Ph_RESIZE_MSG:
+ size = OS.PhGetMsgSize (buffer);
+ OS.free (buffer);
+ buffer = OS.malloc (size);
+ continue;
+ }
+ OS.memmove (event, buffer, PhEvent_t.sizeof);
+ if (event.type == OS.Ph_EV_DRAG) {
+ switch (event.subtype) {
+ case OS.Ph_EV_DRAG_MOTION_EVENT: {
+ int data = OS.PhGetData (buffer);
+ if (data == 0) break;
+ PhPointerEvent_t pe = new PhPointerEvent_t ();
+ OS.memmove (pe, data, PhPointerEvent_t.sizeof);
+ int newX = pe.pos_x;
+ int newY = pe.pos_y;
+ if (newX != oldX || newY != oldY) {
+ drawRectangles ();
+ for (int i=0; i<rectangles.length; i++) {
+ rectangles [i].x += newX - oldX;
+ rectangles [i].y += newY - oldY;
+ }
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the move
+ * event. If this happens, return false to indicate
+ * that the tracking has failed.
+ */
+ sendEvent (SWT.Move, ev);
+ if (isDisposed ()) return false;
+ drawRectangles ();
+ oldX = newX;
+ oldY = newY;
+ }
+ break;
+ }
+ case OS.Ph_EV_DRAG_KEY_EVENT: {
+ int data = OS.PhGetData (buffer);
+ if (data == 0) break;
+ PhKeyEvent_t ke = new PhKeyEvent_t ();
+ OS.memmove (ke, data, PhKeyEvent_t.sizeof);
+ if ((ke.key_flags & OS.Pk_KF_Sym_Valid) != 0) {
+ cancelled = ke.key_sym == OS.Pk_Escape;
+ }
+ break;
+ }
+ case OS.Ph_EV_DRAG_COMPLETE: {
+ tracking = false;
+ break;
+ }
+ }
+ }
+ OS.PtEventHandler (buffer);
}
- rect1.ul_x = rect1.ul_y = 10;
- rect1.lr_x = rect1.lr_y = 100;
- int result = OS.PhInitDrag (rid, OS.Ph_DRAG_KEY_MOTION | OS.Ph_TRACK_DRAG, rect1, null, input_group, null, null, null, null /*pos*/, null);
- return result == 0;
+ drawRectangles ();
+ tracking = false;
+ OS.PtDestroyWidget (handle);
+ return !cancelled;
+}
+void releaseWidget () {
+ super.releaseWidget ();
+ parent = null;
+ display = null;
+ rectangles = null;
}
public void removeControlListener (ControlListener listener) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
@@ -112,4 +215,4 @@ public void setStippled (boolean stippled) {
this.stippled = stippled;
}
-} \ No newline at end of file
+}
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
index 463f425b91..84478209ba 100755
--- 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
@@ -1,19 +1,37 @@
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.*;
-
-/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
- */
-/**
- * Displays a hierarchy of items that can be selected.
- * Sub hierarchies can be expanded and collapsed.
+/**
+ * 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
@@ -39,9 +57,33 @@ public /*final*/ class Tree extends SelectableItemWidget {
// have it static. Initialized in c'tor and freed in dispose();
Rectangle hierarchyIndicatorRect = null; // bounding rectangle of the hierarchy indication image (plus/minus)
-/**
- * Create a new instance of the receiver with 'parent'
- * as its parent widget.
+/**
+ * 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));
@@ -59,13 +101,32 @@ void addItem(TreeItem item, int index) {
}
getRoot().add(item, index);
}
-/**
-* Adds the listener to receive events.
-* <p>
-*
-* @param listener the 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.
+ * 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);
@@ -78,13 +139,25 @@ public void addSelectionListener(SelectionListener listener) {
addListener(SWT.Selection, typedListener);
addListener(SWT.DefaultSelection, typedListener);
}
-/**
-* Adds the listener to receive events.
-* <p>
-*
-* @param listener the listener
-*
-*/
+/**
+ * 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);
@@ -271,10 +344,6 @@ void collapseNoRedraw(TreeItem item) {
item.internalSetExpanded(false);
}
-/**
- * Answer the size of the receiver needed to display all or
- * the first 50 items whichever is less.
- */
public Point computeSize(int wHint, int hHint, boolean changed) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -313,8 +382,13 @@ public Point computeSize(int wHint, int hHint, boolean changed) {
}
return size;
}
-/**
- * Deselect all items of the receiver.
+/**
+ * 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);
@@ -446,12 +520,12 @@ void expand(TreeItem item, boolean notifyListeners) {
if (nestedExpand == false) {
setExpandingItem(item);
}
- scrollForExpand(item);
- item.internalSetExpanded(true);
if (notifyListeners == true) {
event.item = item;
notifyListeners(SWT.Expand, event);
}
+ scrollForExpand(item);
+ item.internalSetExpanded(true);
// redraw hierarchy image
item.redrawExpanded(item.getVisibleIndex() - getTopIndex());
calculateVerticalScrollbar();
@@ -554,8 +628,18 @@ int getIndex(SelectableItem item) {
}
return index;
}
-/**
- * Answer the number of root items.
+/**
+ * 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);
@@ -563,13 +647,16 @@ public int getItemCount() {
return getRoot().getItemCount();
}
-/**
- * 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.
+/**
+ * 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);
@@ -577,8 +664,22 @@ public int getItemHeight() {
return super.getItemHeight();
}
-/**
- * Answer the root items of the receiver as an Array.
+/**
+ * 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);
@@ -599,9 +700,17 @@ int getOffScreenItemCount(TreeItem item) {
return expandedItemCount - spaceRemaining;
}
-/**
- * Answer the parent item of the receiver.
- * This is null because the Tree widget does not have a parent item.
+/**
+ * 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);
@@ -615,10 +724,21 @@ public TreeItem getParentItem() {
TreeRoots getRoot() {
return root;
}
-/**
- * Answer the selected tree items.
- * @return an Array of DrawnTreeItems containing the selected items.
- * An empty Array if no items are selected.
+/**
+ * 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);
@@ -873,19 +993,16 @@ void mouseDoubleClick(Event event) {
TreeItem hitItem = getRoot().getVisibleItem(hitItemIndex + getTopIndex());
Event newEvent;
- if (hitItem == null) {
+ 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);
- return;
- }
- if (hitItem.getItemCount() == 0) {
- return; // an item was hit but it does not have children
}
- if (itemAction(hitItem, event.x, event.y) == ActionSelect) {
+ else
+ if (hitItem.isLeaf() == false) { // item with children was hit. Default behavior is expand/collapse item
if (hitItem.getExpanded() == true) {
collapse(hitItem, true);
}
@@ -1053,8 +1170,13 @@ boolean redrawParentItem(SelectableItem item) {
return redraw;
}
-/**
- * Remove all items of the receiver.
+/**
+ * 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);
@@ -1076,13 +1198,23 @@ public void removeAll() {
void removeItem(TreeItem item) {
getRoot().removeItem(item);
}
-/**
-* Removes the listener.
-* <p>
-*
-* @param listener the 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
+ */
public void removeSelectionListener(SelectionListener listener) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -1093,13 +1225,23 @@ public void removeSelectionListener(SelectionListener listener) {
removeListener (SWT.Selection, listener);
removeListener (SWT.DefaultSelection, listener);
}
-/**
-* Removes the listener.
-* <p>
-*
-* @param listener the 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);
@@ -1142,7 +1284,7 @@ void removingItem(SelectableItem item) {
newSelectionItem = parentItem;
}
if (newSelectionItem != null) {
- selectNotify(newSelectionItem);
+ selectNotify(newSelectionItem, true);
}
}
super.removingItem(item);
@@ -1283,11 +1425,13 @@ void scrollVertical(int scrollIndexCount) {
0, scrollIndexCount * getItemHeight(), // source x, y
clientArea.width, clientArea.height, true);
}
-/**
- * Select all items of the receiver if it is in multiple
- * selection mode.
- * A SWT.Selection event will not be sent.
- * Do nothing if the receiver is in single selection mode.
+/**
+ * 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);
@@ -1306,10 +1450,6 @@ public void selectAll() {
void setExpandingItem(TreeItem item) {
expandingItem = item;
}
-/**
- * The font is changing. Reset and recalculate the item
- * height using all items of the receiver.
- */
public void setFont(Font font) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -1339,14 +1479,19 @@ public void setFont(Font font) {
}
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.
- * <p>
- * @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'.
+/**
+ * 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);
@@ -1354,11 +1499,22 @@ public void setInsertMark(TreeItem item, boolean before){
motif_setInsertMark(item, !before);
}
-/**
- * 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
+/**
+ * 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);
@@ -1385,13 +1541,22 @@ void setTopIndex(int index, boolean adjustScrollbar) {
super.setTopIndex(index, adjustScrollbar);
calculateWidestScrolledItem(indexDiff);
}
-/**
- * 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.
+/**
+ * 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);
@@ -1419,10 +1584,21 @@ void showSelectableItem(SelectableItem item) {
}
super.showSelectableItem(item);
}
-/**
- * Return the item at the specified location in the widget.
- * Return null if there is no item at the specified location
- * or if the location is outside the widget client area.
+/**
+ * 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;
@@ -1444,8 +1620,15 @@ public TreeItem getItem(Point point) {
}
return hitItem;
}
-/**
- * Answer the number of selected items in the receiver.
+/**
+ * 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);
@@ -1453,11 +1636,20 @@ public int getSelectionCount() {
return super.getSelectionCount();
}
-/**
- * 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.
+/**
+ * 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);
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
index cb0aba6a89..e19494cdd0 100755
--- 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
@@ -1,22 +1,31 @@
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.*;
-
-/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
- */
-/**
- * This class represents leaf, non-leaf and root tree items.
- * leaf items don't have any children. non-leaf items have one
- * or more children.
- * Root items don't have a parent item. Root items are either
- * leaf or non-leaf items.
- *
- * This class caches geometrical data for drawing..
+/**
+ * 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 |
@@ -50,9 +59,7 @@ import java.util.*;
* d = SELECTION_PADDING
* e = ITEM_NOIMAGE_OFFSET
* f = ITEM_CONNECTOR_PADDING;
-
*/
-public /*final*/ class TreeItem extends AbstractTreeItem {
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
@@ -173,26 +180,7 @@ static TreeItem checkNull(TreeItem item) {
protected void checkSubclass () {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
-/**
- * Notify the parent that the receiver is being removed.
- * Reset cached data.
- */
-void doDispose() {
- TreeItem parentItem = getParentItem();
-
- if (parentItem != null) {
- parentItem.removeItem(this);
- }
- else {
- getParent().removeItem(this);
- }
- setParentItem(null);
- setImageExtent(null);
- setItemExtent(null);
- setIndex(-1);
- setPaintStartX(-1);
- setTextYPosition(-1);
-}
+
/**
* Draw the hierarchy indicator at 'position'.
*
@@ -419,17 +407,16 @@ Point drawVerticalItemConnector(GC gc, Point position) {
return position;
}
-/**
- * Gets the widget bounds.
- * The widget bounds is the rectangle around the item text. It is
- * the same as the selection rectangle.
- * <p>
- * @return a rectangle that is the widget bounds.
- *
- * @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>
+/**
+ * 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);
@@ -520,8 +507,16 @@ int getItemConnectorWidth() {
}
return itemConnectorWidth;
}
-/**
- * Return the number of children.
+/**
+ * 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);
@@ -565,8 +560,21 @@ int getItemStartX() {
}
return itemStartX;
}
-/**
- * Answer the child items of the receiver as an Array.
+/**
+ * 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);
@@ -613,8 +621,15 @@ int getPaintStartX() {
int getPaintStopX() {
return (getItemStartX() + getItemExtent().x - getParent().getHorizontalOffset());
}
-/**
- * Answer the parent widget of the receiver.
+/**
+ * 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);
@@ -622,9 +637,17 @@ public Tree getParent() {
return (Tree) super.getSelectableParent();
}
-/**
- * Answer the parent item of the receiver or null if the
- * receiver is a root.
+/**
+ * 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);
@@ -947,14 +970,16 @@ void reset() {
setPaintStartX(-1);
setTextYPosition(-1);
}
-/**
- * Set whether the receiver is expanded or not.
- * If the receiver is expanded its child items are visible.
- * @param expand -
- * true=the receiver will be expanded, making its child items
- * visible.
- * false=the receiver will be collapsed, making its child items
- * invisible
+/**
+ * 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);
@@ -967,10 +992,6 @@ public void setExpanded(boolean expand) {
getParent().collapse(this, false);
}
}
-/**
- * Set the image of the receiver to 'newImage'.
- * Reset cached data and notify the parent if the image has changed.
- */
public void setImage(Image newImage) {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
@@ -1035,13 +1056,10 @@ void setPaintStartX(int startX) {
void setParentItem(TreeItem parentItem) {
this.parentItem = parentItem;
}
-/**
- * Set the label text of the receiver to 'string'.
- * Reset cached data and notify the parent if the text has
- * changed.
- * 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.
+/**
+ * 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);
@@ -1069,24 +1087,50 @@ public void setText(String newText) {
void setTextYPosition(int yPosition) {
textYPosition = yPosition;
}
-/**
- * Destroy all children of the receiver
- * Collapsing the item speeds up deleting the children.
- */
-void disposeItem() {
- Tree parent = getParent();
-
+
+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.disposeItem();
+
+ super.dispose();
}
-/**
- * Return whether or not the receiver is checked.
- * Always return false if the parent of the receiver does not
- * have the CHECK style.
+
+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);
@@ -1094,21 +1138,21 @@ public boolean getChecked() {
return super.getChecked();
}
-/**
- * Answer the display of the receiver's parent widget.
- */
public Display getDisplay() {
return super.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>
+/**
+ * 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);
@@ -1116,9 +1160,16 @@ public boolean getGrayed() {
return super.getGrayed();
}
-/**
- * Set the checked state to 'checked' if the parent of the
- * receiver has the CHECK style.
+/**
+ * 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);
@@ -1126,15 +1177,16 @@ public void setChecked(boolean checked) {
super.setChecked(checked);
}
-/**
- * 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>
+/**
+ * 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);
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
index c9e4dea7ab..dec4c31435 100755
--- 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
@@ -1,13 +1,13 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.graphics.*;
-import java.util.*;
-
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ * (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.
@@ -41,16 +41,15 @@ void calculateVisibleItemCount() {
* of this item.
*/
void calculateVisibleItemCountParent() {}
-/**
- * Destroy all children of the receiver
- */
-void disposeItem() {
+
+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.disposeItem();
+ super.dispose();
parent.setRemovingAll(false);
}
/**
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 7f80b5e68d..1ca65f7b66 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
@@ -1,10 +1,11 @@
package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
+import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.photon.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
@@ -14,12 +15,16 @@ import java.util.EventListener;
public abstract class Widget {
public int handle;
- int style;
+ int style, state;
EventTable eventTable;
Object data;
String [] keys;
Object [] values;
+ static final int DISPOSED = 0x00000001;
+ static final int HANDLE = 0x00000002;
+ static final int CANVAS = 0x00000004;
+
static final int DEFAULT_WIDTH = 64;
static final int DEFAULT_HEIGHT = 64;
@@ -99,6 +104,48 @@ void createHandle (int index) {
/* Do nothing */
}
+int createToolTip (String string, int handle, byte [] font) {
+ if (string == null || string.length () == 0 || handle == 0) {
+ return 0;
+ }
+
+ int shellHandle = OS.PtFindDisjoint (handle);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ Display display = getDisplay ();
+ int fill = display.INFO_BACKGROUND;
+ int text_color = display.INFO_FOREGROUND;
+ int toolTipHandle = OS.PtInflateBalloon (shellHandle, handle, OS.Pt_BALLOON_RIGHT, buffer, font, fill, text_color);
+
+ /*
+ * Feature in Photon. The position of the inflated balloon
+ * is relative to the widget position and not to the cursor
+ * position. The fix is to re-position the balloon.
+ */
+ int ig = OS.PhInputGroup (0);
+ PhCursorInfo_t info = new PhCursorInfo_t ();
+ OS.PhQueryCursor ((short)ig, info);
+ short [] absX = new short [1], absY = new short [1];
+ OS.PtGetAbsPosition (shellHandle, absX, absY);
+ int x = info.pos_x - absX [0] + 16;
+ int y = info.pos_y - absY [0] + 16;
+ PhArea_t shellArea = new PhArea_t ();
+ OS.PtWidgetArea (shellHandle, shellArea);
+ PhArea_t toolTipArea = new PhArea_t ();
+ OS.PtWidgetArea (toolTipHandle, toolTipArea);
+ x = Math.max (0, Math.min (x, shellArea.size_w - toolTipArea.size_w));
+ y = Math.max (0, Math.min (y, shellArea.size_h - toolTipArea.size_h));
+ PhPoint_t pt = new PhPoint_t ();
+ pt.x = (short) x;
+ pt.y = (short) y;
+ int ptr = OS.malloc (PhPoint_t.sizeof);
+ OS.memmove (ptr, pt, PhPoint_t.sizeof);
+ int [] args = {OS.Pt_ARG_POS, ptr, 0};
+ OS.PtSetResources (toolTipHandle, args.length / 3, args);
+ OS.free (ptr);
+
+ return toolTipHandle;
+}
+
void createWidget (int index) {
createHandle (index);
hookEvents ();
@@ -110,6 +157,10 @@ void deregister () {
WidgetTable.remove (handle);
}
+void destroyToolTip (int toolTipHandle) {
+ if (toolTipHandle != 0) OS.PtDestroyWidget (toolTipHandle);
+}
+
void destroyWidget () {
int topHandle = topHandle ();
releaseHandle ();
@@ -119,8 +170,12 @@ void destroyWidget () {
}
public void dispose () {
+ /*
+ * Note: It is valid to attempt to dispose a widget
+ * more than once. If this happens, fail silently.
+ */
+ if (!isValidWidget ()) return;
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
releaseChild ();
releaseWidget ();
destroyWidget ();
@@ -176,7 +231,9 @@ void hookEvents () {
}
public boolean isDisposed () {
- return handle == 0;
+ if (handle != 0) return false;
+ if ((state & HANDLE) != 0) return true;
+ return (state & DISPOSED) != 0;
}
boolean isValidSubclass () {
@@ -194,7 +251,9 @@ boolean isValidThread () {
}
boolean isValidWidget () {
- return true /*handle != 0*/;
+ if (handle != 0) return true;
+ if ((state & HANDLE) != 0) return false;
+ return (state & DISPOSED) == 0;
}
public void notifyListeners (int eventType, Event event) {
@@ -222,6 +281,14 @@ void postEvent (int eventType, Event event) {
getDisplay ().postEvent (event);
}
+int processActivate (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processArm (int info) {
+ return OS.Pt_CONTINUE;
+}
+
int processDefaultSelection (int info) {
return OS.Pt_CONTINUE;
}
@@ -238,13 +305,18 @@ int processHide (int info) {
return OS.Pt_CONTINUE;
}
+int processHotkey (int data, int info) {
+ return OS.Pt_CONTINUE;
+}
+
int processKey (int info) {
return OS.Pt_CONTINUE;
}
-int processEvent (int data, int info) {
+int processEvent (int widget, int data, int info) {
switch (data) {
-// case SWT.Arm: return processArm (info);
+ case SWT.Activate: return processActivate (info);
+ case SWT.Arm: return processArm (info);
// case SWT.Dispose: return processDispose (info);
case SWT.DefaultSelection: return processDefaultSelection (info);
case SWT.FocusIn: return processFocusIn (info);
@@ -265,7 +337,6 @@ int processEvent (int data, int info) {
case SWT.Show: return processShow (info);
case SWT.Selection: return processSelection (info);
case SWT.Verify: return processVerify (info);
- case -1: return processShellResize (info);
}
return OS.Pt_CONTINUE;
}
@@ -298,10 +369,6 @@ int processShow (int info) {
return OS.Pt_CONTINUE;
}
-int processShellResize (int info) {
- return OS.Pt_CONTINUE;
-}
-
int processSelection (int info) {
return OS.Pt_CONTINUE;
}
@@ -321,14 +388,16 @@ void register () {
void releaseHandle () {
handle = 0;
-// state |= DISPOSED;
+ state |= DISPOSED;
}
void releaseWidget () {
sendEvent (SWT.Dispose);
-// state |= DISPOSED;
+ deregister ();
eventTable = null;
data = null;
+ keys = null;
+ values = null;
}
public void removeListener (int eventType, Listener handler) {
@@ -355,6 +424,27 @@ public void removeDisposeListener (DisposeListener listener) {
eventTable.unhook (SWT.Dispose, listener);
}
+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);
+ if (args [1] != 0) {
+ int length = OS.strlen (args [1]);
+ if (length > 0) {
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, args [1], length);
+ char [] accelText = Converter.mbcsToWcs (null, buffer);
+ if (accelText.length > 0) {
+ char key = Character.toLowerCase (accelText [0]);
+ OS.PtRemoveHotkeyHandler (handle, key, 0, (short)0, SWT.Activate, display.windowProc);
+ }
+ }
+ }
+ if (mnemonic == 0) return;
+ char key = Character.toLowerCase ((char)mnemonic);
+ OS.PtAddHotkeyHandler (handle, key, mods, (short)0, SWT.Activate, display.windowProc);
+}
+
void sendEvent (int eventType) {
if (eventTable == null) return;
sendEvent (eventType, new Event ());
@@ -438,4 +528,4 @@ int topHandle () {
return handle;
}
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/WidgetTable.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/WidgetTable.java
index 570e5b3c78..d657be6abf 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/WidgetTable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/WidgetTable.java
@@ -2,8 +2,8 @@ package org.eclipse.swt.widgets;
/*
- * Licensed Materials - Property of IBM,
- * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
*/
import org.eclipse.swt.internal.photon.*;
@@ -62,7 +62,7 @@ public static synchronized Widget remove (int handle) {
if (GetArgs [1] == 0) return null;
OS.memmove (ArgBuffer, GetArgs [1], 4);
if (ArgBuffer [0] == 0) return null;
- int index = ArgBuffer [1] - 1;
+ int index = ArgBuffer [0] - 1;
Widget widget = null;
if (0 <= index && index < WidgetTable.length) {
widget = WidgetTable [index];