summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/photon/org
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/photon/org')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Color.java99
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java112
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java253
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/DeviceData.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java107
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java188
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java78
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java1407
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GCData.java23
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java612
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Region.java153
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/Converter.java71
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontDetails.java15
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontQueryInfo.java19
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/OS.java2893
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgAlpha_t.java24
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgMap_t.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhArea_t.java14
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhCursorInfo_t.java38
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhDim_t.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhEvent_t.java27
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhImage_t.java28
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java21
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPoint_t.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPointerEvent_t.java20
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRect_t.java14
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRegion_t.java32
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhTile_t.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhWindowEvent_t.java22
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtCallbackInfo_t.java14
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtColorSelectInfo_t.java27
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtFileSelectionInfo_t.java25
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtScrollbarCallback_t.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTextCallback_t.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTreeItem_t.java25
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/AbstractTreeItem.java318
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java337
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java180
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java222
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java51
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java497
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java258
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java991
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java174
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/DirectoryDialog.java61
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java943
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java125
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java59
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java122
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Header.java336
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java231
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java589
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java338
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java371
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java99
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java121
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java225
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java167
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java306
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java120
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItem.java320
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItemWidget.java2027
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java541
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java236
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java360
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabItem.java135
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Table.java2361
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableColumn.java461
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableItem.java1032
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java619
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java155
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java325
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java115
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tree.java1469
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeItem.java1146
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeRoots.java157
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java441
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/WidgetTable.java101
78 files changed, 25706 insertions, 0 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
new file mode 100755
index 0000000000..f737dbd2df
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Color.java
@@ -0,0 +1,99 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+
+public final class Color {
+
+ /**
+ * the handle to the OS color resource
+ * (Warning: This field is platform dependent)
+ */
+ public int handle;
+
+ /**
+ * the device where this color was created
+ */
+ Device device;
+
+Color() {
+}
+
+public Color (Device device, int red, int green, int blue) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, red, green, blue);
+ if (device.tracking) device.new_Object(this);
+}
+
+public Color (Device device, RGB rgb) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (rgb == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, rgb.red, rgb.green, rgb.blue);
+ if (device.tracking) device.new_Object(this);
+}
+
+public void dispose() {
+ if (handle == -1) return;
+
+ handle = -1;
+ if (device.tracking) device.dispose_Object(this);
+ device = null;
+}
+
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof Color)) return false;
+ Color color = (Color) object;
+ return device == color.device && (handle & 0xFFFFFF) == (color.handle & 0xFFFFFF);
+}
+
+public int getBlue () {
+ return handle & 0xFF;
+}
+
+public int getGreen () {
+ return (handle & 0xFF00) >> 8;
+}
+
+public int getRed () {
+ return (handle & 0xFF0000) >> 16;
+}
+
+public RGB getRGB () {
+ return new RGB((handle & 0xFF0000) >> 16, (handle & 0xFF00) >> 8, handle & 0xFF);
+}
+
+public int hashCode () {
+ return handle;
+}
+
+void init(Device device, int red, int green, int blue) {
+ if (red > 255 || red < 0 || green > 255 || green < 0 || blue > 255 || blue < 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ this.device = device;
+ handle = (blue & 0xFF) | ((green & 0xFF) << 8) | ((red & 0xFF) << 16);
+}
+
+public boolean isDisposed() {
+ return handle == -1;
+}
+
+public String toString () {
+ return "Color {" + getRed() + ", " + getGreen() + ", " + getBlue() + "}";
+}
+
+public static Color photon_new(Device device, int handle) {
+ if (device == null) device = Device.getDevice();
+ Color color = new Color();
+ color.handle = 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
new file mode 100755
index 0000000000..dae177eaca
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java
@@ -0,0 +1,112 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
+public final class Cursor {
+
+ /**
+ * the type to the OS cursor resource
+ * (Warning: This field is platform dependent)
+ */
+ public int type;
+
+ /**
+ * the handle to the OS cursor resource
+ * (Warning: This field is platform dependent)
+ */
+ public int handle;
+
+ /**
+ * the device where this cursor was created
+ */
+ Device device;
+
+Cursor() {
+}
+
+public Cursor(Device device, int style) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+ switch (style) {
+ case SWT.CURSOR_ARROW: type = OS.Ph_CURSOR_POINTER; break;
+ case SWT.CURSOR_WAIT: type = OS.Ph_CURSOR_CLOCK; break;
+ case SWT.CURSOR_HAND: type = OS.Ph_CURSOR_FINGER; break;
+ case SWT.CURSOR_CROSS: type = OS.Ph_CURSOR_CROSSHAIR; break;
+ case SWT.CURSOR_APPSTARTING: type = OS.Ph_CURSOR_POINT_WAIT; break;
+ case SWT.CURSOR_HELP: type = OS.Ph_CURSOR_QUESTION_POINT; break;
+ case SWT.CURSOR_SIZEALL: type = OS.Ph_CURSOR_MOVE; break;
+ case SWT.CURSOR_SIZENESW: type = OS.Ph_CURSOR_MOVE; break;
+ case SWT.CURSOR_SIZENS: type = OS.Ph_CURSOR_DRAG_VERTICAL; break;
+ case SWT.CURSOR_SIZENWSE: type = OS.Ph_CURSOR_MOVE; break;
+ case SWT.CURSOR_SIZEWE: type = OS.Ph_CURSOR_DRAG_HORIZONTAL; break;
+ case SWT.CURSOR_SIZEN: type = OS.Ph_CURSOR_DRAG_TOP; break;
+ case SWT.CURSOR_SIZES: type = OS.Ph_CURSOR_DRAG_BOTTOM; break;
+ case SWT.CURSOR_SIZEE: type = OS.Ph_CURSOR_DRAG_RIGHT; break;
+ case SWT.CURSOR_SIZEW: type = OS.Ph_CURSOR_DRAG_LEFT; break;
+ case SWT.CURSOR_SIZENE: type = OS.Ph_CURSOR_DRAG_TR; break;
+ case SWT.CURSOR_SIZESE: type = OS.Ph_CURSOR_DRAG_BR; break;
+ case SWT.CURSOR_SIZESW: type = OS.Ph_CURSOR_DRAG_BL; break;
+ case SWT.CURSOR_SIZENW: type = OS.Ph_CURSOR_DRAG_TL; break;
+ case SWT.CURSOR_UPARROW: type = OS.Ph_CURSOR_FINGER; break;
+ case SWT.CURSOR_IBEAM: type = OS.Ph_CURSOR_INSERT; break;
+ case SWT.CURSOR_NO: type = OS.Ph_CURSOR_DONT; break;
+ default:
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ handle = type;
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ if (device.tracking) device.new_Object(this);
+}
+
+public Cursor(Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+ type = OS.Ph_CURSOR_BITMAP;
+ SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ 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 */
+ }
+ type = handle = 0;
+ if (device.tracking) device.dispose_Object(this);
+ device = null;
+}
+
+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;
+}
+
+public int hashCode () {
+ return handle ^ type;
+}
+
+public boolean isDisposed() {
+ return type == 0;
+}
+
+public static Cursor photon_new(Device device, int type, int handle) {
+ if (device == null) device = Device.getDevice();
+ Cursor cursor = new Cursor();
+ cursor.type = type;
+ cursor.handle = handle;
+ cursor.device = device;
+ return cursor;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java
new file mode 100755
index 0000000000..3d48ea467a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java
@@ -0,0 +1,253 @@
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+
+public abstract class Device implements Drawable {
+
+ /* Debugging */
+ public static boolean DEBUG;
+ boolean debug = DEBUG;
+ public boolean tracking = DEBUG;
+ Error [] errors;
+ Object [] objects;
+
+ boolean disposed;
+
+public Device(DeviceData data) {
+ create (data);
+ init ();
+ if (data != null) {
+ debug = data.debug;
+ tracking = data.tracking;
+ }
+ 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);
+}
+
+protected void create (DeviceData data) {
+}
+
+protected void destroy () {
+}
+
+public void dispose () {
+ if (isDisposed()) return;
+ checkDevice ();
+ release ();
+ destroy ();
+ disposed = true;
+ if (tracking) {
+ objects = null;
+ errors = null;
+ }
+}
+
+void dispose_Object (Object object) {
+ for (int i=0; i<objects.length; i++) {
+ if (objects [i] == object) {
+ objects [i] = null;
+ errors [i] = null;
+ return;
+ }
+ }
+}
+
+public Rectangle getBounds () {
+ checkDevice ();
+ PhRect_t rect = new PhRect_t ();
+ OS.PhWindowQueryVisible (OS.Ph_QUERY_GRAPHICS, 0, 1, rect);
+ int width = rect.lr_x - rect.ul_x + 1;
+ int height = rect.lr_y - rect.ul_y + 1;
+ return new Rectangle (rect.ul_x, rect.ul_y, width, height);
+}
+
+public Rectangle getClientArea () {
+ return getBounds ();
+}
+
+public int getDepth () {
+ checkDevice ();
+ //NOT DONE
+ return 32;
+}
+
+public DeviceData getDeviceData () {
+ checkDevice();
+ DeviceData data = new DeviceData ();
+ data.debug = debug;
+ data.tracking = tracking;
+ int count = 0, length = 0;
+ if (tracking) length = objects.length;
+ for (int i=0; i<length; i++) {
+ if (objects [i] != null) count++;
+ }
+ int index = 0;
+ data.objects = new Object [count];
+ data.errors = new Error [count];
+ for (int i=0; i<length; i++) {
+ if (objects [i] != null) {
+ data.objects [index] = objects [i];
+ data.errors [index] = errors [i];
+ index++;
+ }
+ }
+ return data;
+}
+
+public Point getDPI () {
+ checkDevice ();
+ //NOT DONE
+ return new Point (96, 96);
+}
+
+public FontData [] getFontList (String faceName, boolean scalable) {
+ checkDevice ();
+ int flags = OS.PHFONT_FIXED | OS.PHFONT_PROP | OS.PFFONT_DONT_SHOW_LEGACY;
+ flags |= scalable ? OS.PHFONT_SCALABLE : OS.PHFONT_BITMAP;
+ int nfonts = OS.PfQueryFonts(OS.PHFONT_ALL_FONTS, flags, 0, 0);
+ if (nfonts <= 0) return new FontData[0];
+
+ int list_ptr = OS.malloc(nfonts * FontDetails.sizeof);
+ nfonts = OS.PfQueryFonts(OS.PHFONT_ALL_FONTS, flags, list_ptr, nfonts);
+ int ptr = list_ptr;
+ int nFds = 0;
+ FontData[] fds = new FontData[faceName != null ? 4 : nfonts];
+ FontDetails details = new FontDetails();
+ for (int i = 0; i < nfonts; i++) {
+ OS.memmove(details, ptr, FontDetails.sizeof);
+ String name = new String(Converter.mbcsToWcs(null, details.desc)).trim();
+ if (faceName == null || faceName.equalsIgnoreCase(name)) {
+ int size;
+ if (details.losize == 0 && details.hisize == 0) size = 9; // This value was taken from the PhAB editor
+ else size = details.losize;
+ flags = details.flags & ~(OS.PHFONT_INFO_PROP | OS.PHFONT_INFO_FIXED);
+ while (flags != 0) {
+ int style;
+ if ((flags & OS.PHFONT_INFO_PLAIN) != 0) {
+ style = SWT.NORMAL;
+ flags &= ~OS.PHFONT_INFO_PLAIN;
+ } else if ((flags & OS.PHFONT_INFO_BOLD) != 0) {
+ style = SWT.BOLD;
+ flags &= ~OS.PHFONT_INFO_BOLD;
+ } else if ((flags & OS.PHFONT_INFO_ITALIC) != 0) {
+ style = SWT.ITALIC;
+ flags &= ~OS.PHFONT_INFO_ITALIC;
+ } else if ((flags & OS.PHFONT_INFO_BLDITC) != 0) {
+ style = SWT.BOLD | SWT.ITALIC;
+ flags &= ~OS.PHFONT_INFO_BLDITC;
+ } else break;
+ if (nFds == fds.length) {
+ FontData[] newFds = new FontData[fds.length + nfonts];
+ System.arraycopy(fds, 0, newFds, 0, nFds);
+ fds = newFds;
+ }
+ fds[nFds++] = new FontData(name, size, style);
+ }
+ }
+ ptr += FontDetails.sizeof;
+ }
+ OS.free(list_ptr);
+
+ if (nFds == fds.length) return fds;
+
+ FontData[] result = new FontData[nFds];
+ System.arraycopy(fds, 0, result, 0, nFds);
+ return result;
+}
+
+public Color getSystemColor (int id) {
+ checkDevice ();
+ int color = 0x000000;
+ switch (id) {
+ case SWT.COLOR_BLACK: color = 0x000000; break;
+ case SWT.COLOR_DARK_RED: color = 0x800000; break;
+ case SWT.COLOR_DARK_GREEN: color = 0x008000; break;
+ case SWT.COLOR_DARK_YELLOW: color = 0x808000; break;
+ case SWT.COLOR_DARK_BLUE: color = 0x000080; break;
+ case SWT.COLOR_DARK_MAGENTA: color = 0x800080; break;
+ case SWT.COLOR_DARK_CYAN: color = 0x008080; break;
+ case SWT.COLOR_GRAY: color = 0x808080; break;
+ case SWT.COLOR_DARK_GRAY: color = 0x404040; break;
+ case SWT.COLOR_RED: color = 0xFF0000; break;
+ case SWT.COLOR_GREEN: color = 0x00FF00; break;
+ case SWT.COLOR_YELLOW: color = 0xFFFF00; break;
+ case SWT.COLOR_BLUE: color = 0x0000FF; break;
+ case SWT.COLOR_MAGENTA: color = 0xFF00FF; break;
+ case SWT.COLOR_CYAN: color = 0x00FFFF; break;
+ case SWT.COLOR_WHITE: color = 0xFFFFFF; break;
+ }
+ return Color.photon_new (this, color);
+}
+
+public Font getSystemFont () {
+ checkDevice ();
+ return Font.photon_new (this, Font.DefaultFont);
+}
+
+public boolean getWarnings () {
+ checkDevice ();
+ return false;
+}
+
+protected void init () {
+}
+
+public abstract int internal_new_GC (GCData data);
+
+public abstract void internal_dispose_GC (int handle, GCData data);
+
+public boolean isDisposed () {
+ return disposed;
+}
+
+void new_Object (Object object) {
+ for (int i=0; i<objects.length; i++) {
+ if (objects [i] == null) {
+ objects [i] = object;
+ errors [i] = new Error ();
+ return;
+ }
+ }
+ Object [] newObjects = new Object [objects.length + 128];
+ System.arraycopy (objects, 0, newObjects, 0, objects.length);
+ newObjects [objects.length] = object;
+ objects = newObjects;
+ Error [] newErrors = new Error [errors.length + 128];
+ System.arraycopy (errors, 0, newErrors, 0, errors.length);
+ newErrors [errors.length] = new Error ();
+ errors = newErrors;
+}
+
+protected void release () {
+}
+
+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
new file mode 100755
index 0000000000..f971a60537
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/DeviceData.java
@@ -0,0 +1,17 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class DeviceData {
+ /*
+ * Debug fields - may not be honoured
+ * on some SWT platforms.
+ */
+ public boolean debug;
+ 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
new file mode 100755
index 0000000000..de23742eed
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java
@@ -0,0 +1,107 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
+public final class Font {
+
+ /**
+ * the handle to the OS font resource
+ * (Warning: This field is platform dependent)
+ */
+ public byte[] handle;
+
+ /**
+ * the device where this font was created
+ */
+ Device device;
+
+ static final byte[] DefaultFontName = {(byte)'h', (byte)'e', (byte)'l', (byte)'v'};
+ static final byte[] DefaultFont = {(byte)'h', (byte)'e', (byte)'l', (byte)'v', (byte)'1', (byte)'2'};
+
+Font() {
+}
+
+public Font(Device device, FontData fd) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (fd == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, fd.getName(), fd.getHeight(), fd.getStyle(), fd.stem);
+ if (device.tracking) device.new_Object(this);
+}
+
+public Font(Device device, String name, int height, int style) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, name, height, style, null);
+ if (device.tracking) device.new_Object(this);
+}
+
+public void dispose() {
+ if (handle == null) return;
+
+ handle = null;
+ if (device.tracking) device.dispose_Object(this);
+ device = null;
+}
+
+public boolean equals(Object object) {
+ if (object == this) return true;
+ if (!(object instanceof Font)) return false;
+ byte[] h = ((Font)object).handle;
+ if (h == handle) return true;
+ if (h == null || handle == null) return false;
+ if (h.length != handle.length) return false;
+ for (int i = 0; i < handle.length; i++) {
+ if (handle[i] != h[i]) return false;
+ }
+ return true;
+}
+
+public FontData[] getFontData() {
+ return new FontData[]{new FontData(handle)};
+}
+
+public int hashCode () {
+ if (handle == null) return 0;
+ return handle.hashCode();
+}
+
+public boolean isDisposed() {
+ return handle == null;
+}
+
+void init(Device device, String name, int height, int style, byte[] stem) {
+ if (height < 0) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+ if (stem != null) {
+ handle = stem;
+ } else {
+ byte[] description = (name == null) ? null : Converter.wcsToMbcs(null, name, true);
+ int osStyle = 0;
+ if ((style & SWT.BOLD) != 0) osStyle |= OS.PF_STYLE_BOLD;
+ if ((style & SWT.ITALIC) != 0) osStyle |= OS.PF_STYLE_ITALIC;
+ byte[] buffer = new byte[OS.MAX_FONT_TAG];
+ handle = OS.PfGenerateFontName(description, osStyle, height, buffer);
+ if (handle == null) handle = OS.PfGenerateFontName(DefaultFontName, osStyle, height, buffer);
+ }
+ if (handle == null) handle = DefaultFont;
+ FontQueryInfo info = new FontQueryInfo();
+ if (OS.PfQueryFontInfo(handle, info) == 0) handle = info.font;
+}
+
+public static Font photon_new(Device device, byte[] stem) {
+ if (device == null) device = Device.getDevice();
+ Font font = new Font();
+ font.init(device, null, 0, 0, stem);
+ return font;
+}
+
+} \ No newline at end of file
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
new file mode 100755
index 0000000000..b7e0fe27ce
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java
@@ -0,0 +1,188 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
+public final class FontData {
+
+ /**
+ * the font name
+ * (Warning: This field is platform dependent)
+ */
+ String name;
+
+ /**
+ * the font height
+ * (Warning: This field is platform dependent)
+ */
+ int height;
+
+ /**
+ * the font style
+ * (Warning: This field is platform dependent)
+ */
+ int style;
+
+ /**
+ * A Photon stem
+ * (Warning: This field is platform dependent)
+ */
+ public byte[] stem;
+
+FontData(byte[] stem) {
+ FontQueryInfo info = new FontQueryInfo();
+ if (OS.PfQueryFontInfo(stem, info) == 0) {
+ this.stem = info.font;
+ name = new String(Converter.mbcsToWcs(null, info.desc)).trim();
+ if ((info.style & OS.PHFONT_INFO_PLAIN) != 0) style = SWT.NORMAL;
+ else if ((info.style & OS.PHFONT_INFO_BOLD) != 0) style = SWT.BOLD;
+ else if ((info.style & OS.PHFONT_INFO_ITALIC) != 0) style = SWT.ITALIC;
+ else if ((info.style & OS.PHFONT_INFO_BLDITC) != 0) style = SWT.BOLD | SWT.ITALIC;
+ else style = SWT.NORMAL;
+ /*
+ * For some reason, sometimes PfQueryFontInfo does not
+ * set the size of the font. In that case, the size is
+ * parsed from the stem.
+ */
+ if (info.size != 0) {
+ height = info.size;
+ } else {
+ String fontName = new String(Converter.mbcsToWcs(null, this.stem)).trim();
+ int end = fontName.length();
+ for (int i = end - 1; i >= 0; i--) {
+ if (Character.isDigit(fontName.charAt(i))) break;
+ end--;
+ }
+ int start = end;
+ for (int i = end - 1; i >= 0; i--) {
+ if (!Character.isDigit(fontName.charAt(i))) break;
+ start--;
+ }
+ try {
+ height = Integer.parseInt(fontName.substring(start, end));
+ } catch (NumberFormatException e) {}
+ }
+ } else {
+ this.stem = stem;
+ }
+}
+
+public FontData() {
+ this("", 12, SWT.NORMAL);
+}
+
+public FontData(String string) {
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int start = 0;
+ int end = string.indexOf('|');
+ if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ String version1 = string.substring(start, end);
+
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ String name = string.substring(start, end);
+
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ int height = 0;
+ try {
+ height = Integer.parseInt(string.substring(start, end));
+ } catch (NumberFormatException e) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ int style = 0;
+ try {
+ style = Integer.parseInt(string.substring(start, end));
+ } catch (NumberFormatException e) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ start = end + 1;
+ end = string.indexOf('|', start);
+ setName(name);
+ setHeight(height);
+ setStyle(style);
+ if (end == -1) return;
+ String platform = string.substring(start, end);
+
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) return;
+ String version2 = string.substring(start, end);
+
+ if (platform.equals("PHOTON") && version2.equals("1")) {
+ return;
+ }
+}
+
+public FontData(String name, int height, int style) {
+ setName(name);
+ setHeight(height);
+ setStyle(style);
+}
+
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof FontData)) return false;
+ FontData data = (FontData)object;
+ return name == name && height == data.height && style == data.style;
+}
+
+public int getHeight() {
+ return height;
+}
+
+public String getName() {
+ return name;
+}
+
+public int getStyle() {
+ return style;
+}
+
+public int hashCode () {
+ return name.hashCode() ^ height ^ style;
+}
+
+public void setHeight(int height) {
+ this.height = height;
+}
+
+public void setName(String name) {
+ this.name = name;
+}
+
+public void setStyle(int style) {
+ this.style = style;
+}
+
+public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("1|");
+ buffer.append(getName());
+ buffer.append("|");
+ buffer.append(getHeight());
+ buffer.append("|");
+ buffer.append(getStyle());
+ buffer.append("|");
+ buffer.append("PHOTON|1|");
+ return buffer.toString();
+}
+
+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
new file mode 100755
index 0000000000..6943cd42d9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java
@@ -0,0 +1,78 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+
+public final class FontMetrics {
+
+ /**
+ * A Photon FontQueryInfo struct
+ * (Warning: This field is platform dependent)
+ */
+ FontQueryInfo handle;
+
+FontMetrics() {
+}
+
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof FontMetrics)) return false;
+ FontQueryInfo info = ((FontMetrics)object).handle;
+ if (info == handle) return true;
+ if (info == null || handle == null) return false;
+ if (handle.size == info.size &&
+ handle.style == info.style &&
+ handle.ascender == info.ascender &&
+ handle.descender == info.descender &&
+ handle.width == info.width &&
+ handle.lochar == info.lochar &&
+ handle.hichar == info.hichar &&
+ handle.desc.length == info.desc.length &&
+ handle.font.length == info.font.length)
+ {
+ for (int i = handle.font.length - 1; i >= 0; i--) {
+ if (handle.font[i] != info.font[i]) return false;
+ }
+ return true;
+ }
+ return false;
+}
+
+public int getAscent() {
+ return -handle.ascender;
+}
+
+public int getAverageCharWidth() {
+ return handle.width / 2;
+}
+
+public int getDescent() {
+ return handle.descender;
+}
+
+public int getHeight() {
+ return -handle.ascender + handle.descender;
+}
+
+public int getLeading() {
+ return 0;
+}
+
+public int hashCode() {
+ if (handle == null) return 0;
+ return handle.size ^ handle.style ^ handle.ascender ^
+ handle.descender ^ handle.width ^
+ handle.lochar ^ handle.hichar ^ handle.font.hashCode() ^
+ handle.desc.hashCode();
+}
+
+public static FontMetrics photon_new(FontQueryInfo handle) {
+ FontMetrics fontMetrics = new FontMetrics();
+ 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
new file mode 100755
index 0000000000..9c79ad0715
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java
@@ -0,0 +1,1407 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
+public final class GC {
+ /**
+ * The handle to the OS device context.
+ * Warning: This field is platform dependent.
+ */
+ public int handle;
+
+ Drawable drawable;
+ GCData data;
+
+ static final int DefaultBack = 0xffffff;
+ static final int DefaultFore = 0x000000;
+ static final byte[][] DashList = {
+ { }, // SWT.LINE_SOLID
+ { 10, 4 }, // SWT.LINE_DASH
+ { 2, 2 }, // SWT.LINE_DOT
+ { 10, 4, 2, 4 }, // SWT.LINE_DASHDOT
+ { 10, 4, 2, 4, 2, 4 } // SWT.LINE_DASHDOTDOT
+ };
+ // Photon Draw Buffer Size for off screen drawing.
+ static int DrawBufferSize = 48 * 1024;
+
+GC() {
+}
+
+public GC(Drawable drawable) {
+ int flags = OS.PtEnter(0);
+ try {
+ if (drawable == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ GCData data = new GCData ();
+ int hDC = drawable.internal_new_GC (data);
+ Device device = data.device;
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ data.device = device;
+ init (drawable, data, hDC);
+ if (device.tracking) device.new_Object(this);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void copyArea(Image image, int x, int y) {
+ if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (image.type != SWT.BITMAP) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ int flags = OS.PtEnter(0);
+ try {
+ Rectangle bounds = image.getBounds();
+ int memImage = 0;
+ PhRect_t rect = new PhRect_t();
+ rect.ul_x = (short)x; rect.ul_y = (short)y;
+ rect.lr_x = (short)(x + bounds.width - 1); rect.lr_y = (short)(y + bounds.height - 1);
+ boolean sharedMem = true;
+ int rid = data.rid;
+ int widget = data.widget;
+ if (rid == OS.Ph_DEV_RID) {
+ memImage = OS.PgShmemCreate(OS.PgReadScreenSize(rect), null);
+ if (memImage != 0) memImage = OS.PgReadScreen(rect, memImage);
+ } else if (widget != 0) {
+ short [] widget_x = new short [1], widget_y = new short [1];
+ OS.PtGetAbsPosition(widget, widget_x, widget_y);
+ rect.ul_x += widget_x[0];
+ rect.ul_y += widget_y[0];
+ rect.lr_x += widget_y[0];
+ rect.lr_y += widget_y[0];
+ memImage = OS.PgShmemCreate(OS.PgReadScreenSize(rect), null);
+ if (memImage != 0) memImage = OS.PgReadScreen(rect, memImage);
+ } else if (data.image != null) {
+ memImage = OS.PiCropImage(data.image.handle, rect, 0);
+ sharedMem = false;
+ }
+ if (memImage == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove(phImage, memImage, PhImage_t.sizeof);
+ PhPoint_t trans = new PhPoint_t();
+ PhPoint_t pos = new PhPoint_t();
+ PhDim_t scale = new PhDim_t();
+ scale.w = (short)bounds.width;
+ scale.h = (short)bounds.height;
+ int mc = OS.PmMemCreateMC(image.handle, scale, trans);
+ OS.PmMemStart(mc);
+ OS.PgSetDrawBufferSize(DrawBufferSize);
+ if (phImage.palette != 0) OS.PgSetPalette(phImage.palette, 0, (short)0, (short)phImage.colors, OS.Pg_PALSET_SOFT, 0);
+ OS.PgDrawImage(phImage.image, phImage.type, pos, scale, phImage.bpl, 0);
+ if (phImage.palette != 0) OS.PgSetPalette(0, 0, (short)0, (short)-1, 0, 0);
+ OS.PmMemFlush(mc, image.handle);
+ OS.PmMemStop(mc);
+ OS.PmMemReleaseMC(mc);
+ if (sharedMem) {
+ OS.PgShmemDestroy(memImage);
+ } else {
+ phImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
+ OS.memmove(memImage, phImage, PhImage_t.sizeof);
+ OS.PhReleaseImage(memImage);
+ OS.free(memImage);
+ }
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void copyArea(int x, int y, int width, int height, int destX, int destY) {
+ if (width == 0 || height == 0) return;
+ int deltaX = destX - x, deltaY = destY - y;
+ if (deltaX == 0 && deltaY == 0) return;
+
+ int flags = OS.PtEnter(0);
+ try {
+ boolean overlaps = (destX < x + width) && (destY < y + height) &&
+ (destX + width > x) && (destY + height > y);
+ int widget = data.widget;
+ Image image = data.image;
+ if (image != null) {
+ int drawImage = image.handle;
+ PhImage_t phDrawImage = new PhImage_t();
+ OS.memmove(phDrawImage, drawImage, PhImage_t.sizeof);
+ if (overlaps) {
+ PhPoint_t trans = new PhPoint_t();
+ PhDim_t scale = new PhDim_t();
+ scale.w = (short)width;
+ scale.h = (short)height;
+ PhPoint_t pos = new PhPoint_t();
+ pos.x = (short)-x;
+ pos.y = (short)-y;
+ PhDim_t dim = new PhDim_t();
+ dim.w = (short)Math.min(phDrawImage.size_w, x + width);
+ dim.h = (short)Math.min(phDrawImage.size_h, y + height);
+ /* Feature on Photon - It is only possible to draw on images of
+ type Pg_IMAGE_PALETTE_BYTE and Pg_IMAGE_DIRECT_888.
+ */
+ int type = OS.Pg_IMAGE_PALETTE_BYTE;
+ if ((phDrawImage.type & OS.Pg_IMAGE_CLASS_MASK) == OS.Pg_IMAGE_CLASS_DIRECT) {
+ type = OS.Pg_IMAGE_DIRECT_888;
+ }
+ int memImage = OS.PhCreateImage(null, (short)width, (short)height, type, phDrawImage.palette, phDrawImage.colors, 0);
+ int mc = OS.PmMemCreateMC(memImage, scale, trans);
+ OS.PmMemStart(mc);
+ OS.PgSetDrawBufferSize(DrawBufferSize);
+ if (phDrawImage.palette != 0) OS.PgSetPalette(phDrawImage.palette, 0, (short)0, (short)phDrawImage.colors, OS.Pg_PALSET_SOFT, 0);
+ OS.PgDrawImage(phDrawImage.image, phDrawImage.type, pos, dim, phDrawImage.bpl, 0);
+ if (phDrawImage.palette != 0) OS.PgSetPalette(0, 0, (short)0, (short)-1, 0, 0);
+ OS.PmMemFlush(mc, memImage);
+ OS.PmMemStop(mc);
+ OS.PmMemReleaseMC(mc);
+ x = (short)0;
+ y = (short)0;
+ drawImage = memImage;
+ OS.memmove(phDrawImage, drawImage, PhImage_t.sizeof);
+ phDrawImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
+ OS.memmove(drawImage, phDrawImage, PhImage_t.sizeof);
+ }
+ PhPoint_t pos = new PhPoint_t();
+ pos.x = (short)(destX - x);
+ pos.y = (short)(destY - y);
+ PhRect_t clip = new PhRect_t();
+ clip.ul_x = (short)destX;
+ clip.ul_y = (short)destY;
+ clip.lr_x = (short)(destX + width - 1);
+ clip.lr_y = (short)(destY + height - 1);
+ PhDim_t dim = new PhDim_t();
+ dim.w = (short)Math.min(phDrawImage.size_w, x + width);
+ dim.h = (short)Math.min(phDrawImage.size_h, y + height);
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgSetUserClip(clip);
+ if (phDrawImage.palette != 0) OS.PgSetPalette(phDrawImage.palette, 0, (short)0, (short)phDrawImage.colors, OS.Pg_PALSET_SOFT, 0);
+ OS.PgDrawImage(phDrawImage.image, phDrawImage.type, pos, dim, phDrawImage.bpl, 0);
+ if (phDrawImage.palette != 0) OS.PgSetPalette(0, 0, (short)0, (short)-1, 0, 0);
+ OS.PgSetUserClip(null);
+ unsetGC(prevContext);
+ if (drawImage != image.handle) {
+ OS.PhReleaseImage(drawImage);
+ OS.free(drawImage);
+ }
+ } else if (widget != 0) {
+ int rid = OS.PtWidgetRid(widget);
+ if (rid == 0) return;
+ 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;
+ int clipRects = data.clipRects;
+ if (clipRects == 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]);
+ OS.PhFreeTiles(clip);
+ OS.PhFreeTiles(dest);
+ PhPoint_t inverseDelta = new PhPoint_t();
+ inverseDelta.x = (short)(-delta.x);
+ inverseDelta.y = (short)(-delta.y);
+ OS.PhTranslateTiles(dest_tiles, inverseDelta);
+ int[] src_rects_count = new int[1];
+ int src_rects = OS.PhTilesToRects(dest_tiles, src_rects_count);
+ OS.PhFreeTiles(dest_tiles);
+ PhRect_t src_rect = new PhRect_t();
+ for (int i = 0; i<src_rects_count[0]; i++) {
+ OS.memmove(src_rect, src_rects + (i * PhRect_t.sizeof), PhRect_t.sizeof);
+ OS.PhBlit(rid, src_rect, delta);
+ }
+ OS.free(src_rects);
+ }
+ if (!overlaps) {
+ OS.PtDamageExtent (widget, 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 (widget, rect);
+ }
+ OS.free(damage_rects);
+ }
+ }
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void dispose() {
+ int flags = OS.PtEnter(0);
+ try {
+ if (handle == 0) return;
+
+ int clipRects = data.clipRects;
+ if (clipRects != 0) {
+ OS.free(clipRects);
+ data.clipRects = data.clipRectsCount = 0;
+ }
+ Image image = data.image;
+ if (image != null) image.memGC = null;
+
+ /*
+ * Dispose the HDC.
+ */
+ Device device = data.device;
+ drawable.internal_dispose_GC(handle, data);
+ drawable = null;
+ handle = 0;
+ data.image = null;
+ data.font = null;
+ data.rid = data.widget = data.topWidget = 0;
+ if (device.tracking) device.dispose_Object(this);
+ data.device = null;
+ data = null;
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void drawArc (int x, int y, int width, int height, int startAngle, int endAngle) {
+ if (startAngle > 0) {
+ if (endAngle > 0) {
+ //No need to modify start angle.
+ endAngle += startAngle;
+ } else {
+ int newStartAngle;
+ int newStopAngle = startAngle;
+ if (startAngle > Math.abs(endAngle)) {
+ newStartAngle = startAngle - Math.abs(endAngle);
+ } else {
+ newStartAngle = startAngle + 360 - Math.abs(endAngle);
+ }
+ startAngle = newStartAngle;
+ endAngle = newStopAngle;
+ }
+ } else {
+ if (endAngle > 0) {
+ endAngle = endAngle + startAngle;
+ startAngle = 360 - Math.abs(startAngle);
+ } else {
+ int newStopAngle = 360 + startAngle;
+ startAngle = newStopAngle - Math.abs(endAngle);
+ endAngle = newStopAngle;
+ }
+ }
+
+ startAngle = (int) (startAngle * 65536 / 360);
+ endAngle = (int) (endAngle * 65536 / 360);
+
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ if (width == 0 || height == 0 || endAngle == 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ PhPoint_t center = new PhPoint_t();
+ center.x = (short)(x + (width / 2));
+ center.y = (short)(y + (height / 2));
+ PhPoint_t radii = new PhPoint_t();
+ radii.x = (short)(width / 2);
+ radii.y = (short)(height / 2);
+
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawArc(center, radii, startAngle, endAngle, OS.Pg_ARC | OS.Pg_DRAW_STROKE);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void drawFocus (int x, int y, int width, int height) {
+ drawRectangle(x, y, width, height);
+}
+
+public void drawImage(Image image, int x, int y) {
+ if (image == null) SWT.error (SWT.ERROR_NULL_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 (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);
+ 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;
+ int imgHeight = phDrawImage.size_h;
+ if (simple) {
+ srcWidth = destWidth = imgWidth;
+ srcHeight = destHeight = imgHeight;
+ } else {
+ simple = srcX == 0 && srcY == 0 &&
+ srcWidth == destWidth && destWidth == imgWidth &&
+ srcHeight == destHeight && destHeight == imgHeight;
+ if (srcX + srcWidth > imgWidth || srcY + srcHeight > imgHeight) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ }
+ if (srcWidth != destWidth || srcHeight != destHeight) {
+ drawImage = scaleImage(image, phDrawImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight);
+ srcX = (short)0;
+ srcY = (short)0;
+ srcWidth = (short)destWidth;
+ srcHeight = (short)destHeight;
+ OS.memmove(phDrawImage, drawImage, PhImage_t.sizeof);
+ }
+ PhPoint_t pos = new PhPoint_t();
+ pos.x = (short)(destX - srcX);
+ pos.y = (short)(destY - srcY);
+ PhDim_t dim = new PhDim_t();
+ dim.w = (short)Math.min(phDrawImage.size_w, srcX + srcWidth);
+ dim.h = (short)Math.min(phDrawImage.size_h, srcY + srcHeight);
+ PhRect_t clip = new PhRect_t();
+ clip.ul_x = (short)destX;
+ clip.ul_y = (short)destY;
+ clip.lr_x = (short)(destX + destWidth - 1);
+ clip.lr_y = (short)(destY + destHeight - 1);
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgSetUserClip(clip);
+ if (phDrawImage.palette != 0) OS.PgSetPalette(phDrawImage.palette, 0, (short)0, (short)phDrawImage.colors, OS.Pg_PALSET_SOFT, 0);
+ if (phDrawImage.alpha != 0) {
+ drawImageAlpha(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, phDrawImage, drawImage, pos, dim);
+ } else if (image.transparentPixel != -1) {
+ drawImageTransparent(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, phDrawImage, drawImage, pos, dim);
+ } else if (phDrawImage.mask_bm != 0) {
+ drawImageMask(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, phDrawImage, drawImage, pos, dim);
+ } else {
+ drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, phDrawImage, drawImage, pos, dim);
+ }
+ if (phDrawImage.palette != 0) OS.PgSetPalette(0, 0, (short)0, (short)-1, 0, 0);
+ OS.PgSetUserClip(null);
+ unsetGC(prevContext);
+ if (drawImage != image.handle) {
+ phDrawImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
+ OS.memmove(drawImage, phDrawImage, PhImage_t.sizeof);
+ OS.PhReleaseImage(drawImage);
+ OS.free(drawImage);
+ }
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+void drawImageAlpha(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, PhImage_t phImage, int imgHandle, PhPoint_t pos, PhDim_t dim) {
+ PgAlpha_t phAlpha = new PgAlpha_t();
+ OS.memmove(phAlpha, phImage.alpha, PgAlpha_t.sizeof);
+ if ((phAlpha.alpha_op & OS.Pg_ALPHA_OP_SRC_GLOBAL) != 0) {
+ OS.PgSetAlpha(phAlpha.alpha_op, null, 0, phAlpha.src_global_alpha, phAlpha.dest_global_alpha);
+ OS.PgAlphaOn();
+ OS.PgDrawImage(phImage.image, phImage.type, pos, dim, phImage.bpl, 0);
+ OS.PgAlphaOff();
+ return;
+ }
+
+ /*
+ * Feature/Bug in Photon - When drawing images with alpha blending
+ * enabled, there is a limitation in the size of the alpha map.
+ * This limitation is probably related to the draw buffer size and
+ * it seems to be worse when drawing to a memory context. The
+ * fix/workaround is to draw the image line by line.
+ */
+ PgMap_t imageMap = new PgMap_t();
+ OS.memmove(imageMap, phImage.alpha + 4, PgMap_t.sizeof);
+ PgMap_t lineMap = new PgMap_t();
+ lineMap.dim_w = imageMap.dim_w;
+ lineMap.dim_h = 1;
+ /*
+ * Feature in Photon - The alpha map set in a graphics context by
+ * PgSetAlpha is freed when the graphics context is destroyed.
+ */
+ lineMap.map = OS.malloc(lineMap.dim_w);
+ OS.PgSetAlpha(phAlpha.alpha_op, lineMap, 0, phAlpha.src_global_alpha, phAlpha.dest_global_alpha);
+ OS.PgAlphaOn();
+ pos.y = (short)(destY);
+ int end = dim.h;
+ dim.h = (short)1;
+ for (int y=srcY; y<end; y+=lineMap.dim_h) {
+ OS.memmove(lineMap.map, imageMap.map + (imageMap.dim_w * y), lineMap.dim_w);
+ /*
+ * Bug in Photon - When drawing an image to a memory context created by
+ * PmMemCreateMC at a negative position, the alpha map is not offset.
+ */
+ if (data.image != null && pos.x < 0) {
+ OS.memmove(lineMap.map, lineMap.map - pos.x, lineMap.dim_w + pos.x);
+ }
+ OS.PgDrawImage(phImage.image + (phImage.bpl * y), phImage.type, pos, dim, phImage.bpl, 0);
+ /*
+ * Flushing is necessary in order to change the alpha map.
+ */
+ if (data.image != null) OS.PmMemFlush(handle, data.image.handle);
+ else OS.PgFlush();
+ pos.y += lineMap.dim_h;
+ }
+ OS.PgAlphaOff();
+}
+void drawImageTransparent(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, PhImage_t phImage, int imgHandle, PhPoint_t pos, PhDim_t dim) {
+ /* Generate the mask if necessary */
+ if (phImage.mask_bm == 0) {
+ createMask(imgHandle, phImage.type, image.transparentPixel);
+ OS.memmove(phImage, imgHandle, PhImage_t.sizeof);
+ }
+ OS.PgDrawTImage(phImage.image, phImage.type, pos, dim, phImage.bpl, 0, phImage.mask_bm, phImage.mask_bpl);
+ /* Destroy the mask if there is a GC created on the image */
+ if (image.memGC != null && image.handle == imgHandle) {
+ OS.free(phImage.mask_bm);
+ phImage.mask_bm = 0;
+ phImage.mask_bpl = 0;
+ OS.memmove(imgHandle, phImage, PhImage_t.sizeof);
+ }
+}
+void drawImageMask(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, PhImage_t phImage, int imgHandle, PhPoint_t pos, PhDim_t dim) {
+ OS.PgDrawTImage(phImage.image, phImage.type, pos, dim, phImage.bpl, 0, phImage.mask_bm, phImage.mask_bpl);
+}
+void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, PhImage_t phImage, int imgHandle, PhPoint_t pos, PhDim_t dim) {
+ OS.PgDrawImage(phImage.image, phImage.type, pos, dim, phImage.bpl, 0);
+}
+static void createMask(int image, int type, int transparent) {
+ if ((type & OS.Pg_IMAGE_CLASS_MASK) == OS.Pg_IMAGE_CLASS_PALETTE) {
+ transparent = (transparent & 0xFF) | OS.Pt_INDEX_COLOR;
+ } else {
+ switch (type) {
+ case OS.Pg_IMAGE_DIRECT_888:
+ transparent = ((transparent & 0xFF) << 16) | (transparent & 0xFF00) | ((transparent & 0xFF0000) >> 16);
+ break;
+ case OS.Pg_IMAGE_DIRECT_8888:
+ transparent = ((transparent & 0xFF00) << 8) | ((transparent & 0xFF0000) >> 8) | ((transparent & 0xFF000000) >> 24);
+ break;
+ case OS.Pg_IMAGE_DIRECT_565:
+ transparent = ((transparent & 0xF800) << 8) | ((transparent & 0x7E0) << 5) | ((transparent & 0x1F) << 3);
+ break;
+ case OS.Pg_IMAGE_DIRECT_555:
+ transparent = ((transparent & 0x7C00) << 9) | ((transparent & 0x3E0) << 6) | ((transparent & 0x1F) << 3);
+ break;
+ case OS.Pg_IMAGE_DIRECT_444:
+ transparent = ((transparent & 0xF00) << 12) | ((transparent & 0xF0) << 8) | ((transparent & 0xF) << 4);
+ break;
+ }
+ }
+ OS.PhMakeTransBitmap(image, transparent);
+}
+static int scaleImage(Image image, PhImage_t phImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
+ PhPoint_t trans = new PhPoint_t();
+ PhDim_t scale = new PhDim_t();
+ scale.w = (short)srcWidth;
+ scale.h = (short)srcHeight;
+ PhPoint_t pos = new PhPoint_t();
+ pos.x = (short)-srcX;
+ pos.y = (short)-srcY;
+ PhDim_t dim = new PhDim_t();
+ dim.w = (short)Math.min(phImage.size_w, srcX + srcWidth);
+ dim.h = (short)Math.min(phImage.size_h, srcY + srcHeight);
+ /*
+ * Feature on Photon - It is only possible to draw on images of
+ * type Pg_IMAGE_PALETTE_BYTE and Pg_IMAGE_DIRECT_888.
+ */
+ int type = OS.Pg_IMAGE_PALETTE_BYTE;
+ if ((phImage.type & OS.Pg_IMAGE_CLASS_MASK) == OS.Pg_IMAGE_CLASS_DIRECT) {
+ type = OS.Pg_IMAGE_DIRECT_888;
+ }
+ /* Scale the image */
+ int memImage = OS.PhCreateImage(null, (short)destWidth, (short)destHeight, type, phImage.palette, phImage.colors, 0);
+ if (memImage == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ int mc = OS.PmMemCreateMC(memImage, scale, trans);
+ if (mc == 0) {
+ Image.destroyImage(memImage);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ OS.PmMemStart(mc);
+ OS.PgSetDrawBufferSize(DrawBufferSize);
+ if (phImage.palette != 0) OS.PgSetPalette(phImage.palette, 0, (short)0, (short)phImage.colors, OS.Pg_PALSET_SOFT, 0);
+ OS.PgDrawImage(phImage.image, phImage.type, pos, dim, phImage.bpl, 0);
+ if (phImage.palette != 0) OS.PgSetPalette(0, 0, (short)0, (short)-1, 0, 0);
+ OS.PmMemFlush(mc, memImage);
+ OS.PmMemStop(mc);
+ OS.PmMemReleaseMC(mc);
+
+ PhImage_t phMemImage = new PhImage_t();
+ OS.memmove(phMemImage, memImage, PhImage_t.sizeof);
+ if (image.transparentPixel != -1) {
+ /* Generate the mask if it was created originally */
+ if (phImage.mask_bm != 0) {
+ createMask(memImage, phImage.type, image.transparentPixel);
+ }
+ } else if (phImage.mask_bm != 0) {
+ /* Scale the mask */
+ int[] palette = new int[2];
+ palette[0] = 0x000000;
+ palette[1] = 0xffffff;
+ int palettePtr = OS.malloc(palette.length * 4);
+ OS.memmove(palettePtr, palette, palette.length * 4);
+ /*
+ * Feature on Photon - It is only possible to draw on images of
+ * type Pg_IMAGE_PALETTE_BYTE and Pg_IMAGE_DIRECT_888.
+ */
+ int maskImage = OS.PhCreateImage(null, (short)destWidth, (short)destHeight, OS.Pg_IMAGE_PALETTE_BYTE, palettePtr, palette.length, 0);
+ if (maskImage == 0) {
+ Image.destroyImage(memImage);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ mc = OS.PmMemCreateMC(maskImage, scale, trans);
+ if (mc == 0) {
+ Image.destroyImage(maskImage);
+ Image.destroyImage(memImage);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ OS.PmMemStart(mc);
+ OS.PgSetDrawBufferSize(DrawBufferSize);
+ OS.PgSetFillColor(palette[0]);
+ OS.PgSetTextColor(palette[1]);
+ OS.PgDrawBitmap(phImage.mask_bm, OS.Pg_BACK_FILL, pos, dim, phImage.mask_bpl, 0);
+ OS.PmMemFlush(mc, maskImage);
+ OS.PmMemStop(mc);
+ OS.PmMemReleaseMC(mc);
+ OS.free(palettePtr);
+
+ /* Transfer the mask to the scaled image */
+ OS.PhMakeTransBitmap(maskImage, 0 | OS.Pt_INDEX_COLOR);
+ PhImage_t phMaskImage = new PhImage_t();
+ OS.memmove(phMaskImage, maskImage, PhImage_t.sizeof);
+ phMemImage.mask_bm = phMaskImage.mask_bm;
+ phMemImage.mask_bpl = phMaskImage.mask_bpl;
+ OS.memmove(memImage, phMemImage, PhImage_t.sizeof);
+
+ /* Release the temporary image but not the mask data */
+ phMaskImage.mask_bm = 0;
+ phMaskImage.mask_bpl = 0;
+ phMaskImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
+ OS.memmove(maskImage, phMaskImage, PhImage_t.sizeof);
+ OS.PhReleaseImage(maskImage);
+ OS.free(maskImage);
+ } else if (phImage.alpha != 0) {
+ PgAlpha_t alpha = new PgAlpha_t();
+ OS.memmove(alpha, phImage.alpha, PgAlpha_t.sizeof);
+ int alphaPtr = OS.malloc(PgAlpha_t.sizeof);
+ if (alphaPtr == 0) {
+ Image.destroyImage(memImage);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+
+ /* Scale alpha data */
+ if (alpha.src_alpha_map_map != 0) {
+// int[] palette = new int[256];
+// for (int i = 0; i < palette.length; i++) {
+// palette[i] = i;
+// }
+// int palettePtr = OS.malloc(palette.length * 4);
+// OS.memmove(palettePtr, palette, palette.length * 4);
+// /*
+// * Feature on Photon - It is only possible to draw on images of
+// * type Pg_IMAGE_PALETTE_BYTE and Pg_IMAGE_DIRECT_888.
+// */
+// int alphaImage = OS.PhCreateImage(null, (short)destWidth, (short)destHeight, OS.Pg_IMAGE_PALETTE_BYTE, palettePtr, palette.length, 0);
+// if (alphaImage == 0) {
+// Image.destroyImage(memImage);
+// SWT.error(SWT.ERROR_NO_HANDLES);
+// }
+// mc = OS.PmMemCreateMC(alphaImage, scale, trans);
+// if (mc == 0) {
+// Image.destroyImage(alphaImage);
+// Image.destroyImage(memImage);
+// SWT.error(SWT.ERROR_NO_HANDLES);
+// }
+// OS.PmMemStart(mc);
+// OS.PgSetPalette(palettePtr, 0, (short)0, (short)palette.length, OS.Pg_PALSET_SOFT, 0);
+// OS.PgDrawImage(alpha.src_alpha_map_map, OS.Pg_IMAGE_PALETTE_BYTE, pos, dim, alpha.src_alpha_map_bpl, 0);
+// OS.PgSetPalette(0, 0, (short)0, (short)-1, 0, 0);
+// OS.PmMemFlush(mc, alphaImage);
+// OS.PmMemStop(mc);
+// OS.PmMemReleaseMC(mc);
+// OS.free(palettePtr);
+//
+// /* Transfer the image to the scaled image alpha data*/
+// PhImage_t phAlphaImage = new PhImage_t();
+// OS.memmove(phAlphaImage, alphaImage, PhImage_t.sizeof);
+// alpha.src_alpha_map_dim_w = (short)phAlphaImage.bpl;
+// alpha.src_alpha_map_dim_h = (short)phAlphaImage.size_h;
+// alpha.src_alpha_map_map = phAlphaImage.image;
+//
+// /* Release the temporary image but not the image data */
+// phAlphaImage.image = 0;
+// phAlphaImage.bpl = 0;
+// phAlphaImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
+// OS.memmove(alphaImage, phAlphaImage, PhImage_t.sizeof);
+// OS.PhReleaseImage(alphaImage);
+// OS.free(alphaImage);
+
+ // The code above can not be used because it generates an image with
+ // scanline padding. It seems that Photon does not accept
+ // padding in src_alpha_map, even though there is a field to specify
+ // the number of bytes per line - src_alpha_map_map_bpl.
+ byte[] srcAlphaData = new byte[alpha.src_alpha_map_dim_w * alpha.src_alpha_map_dim_h];
+ OS.memmove(srcAlphaData, alpha.src_alpha_map_map, srcAlphaData.length);
+ byte[] destAlphaData = new byte[destWidth * destHeight];
+ ImageData.stretch8(srcAlphaData, alpha.src_alpha_map_dim_w, 0, 0, srcWidth, srcHeight, destAlphaData, destWidth, 0, 0, destWidth, destHeight, null, false, false);
+ int ptr = OS.malloc(destAlphaData.length);
+ OS.memmove(ptr, destAlphaData, destAlphaData.length);
+ alpha.src_alpha_map_dim_w = (short)destWidth;
+ alpha.src_alpha_map_dim_h = (short)destHeight;
+ alpha.src_alpha_map_map = ptr;
+ }
+
+ OS.memmove(alphaPtr, alpha, PgAlpha_t.sizeof);
+ phMemImage.alpha = alphaPtr;
+ OS.memmove(memImage, phMemImage, PhImage_t.sizeof);
+ }
+ return memImage;
+}
+
+public void drawLine (int x1, int y1, int x2, int y2) {
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawILine(x1, y1, x2, y2);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void drawOval (int x, int y, int width, int height) {
+ PhPoint_t center = new PhPoint_t();
+ center.x = (short)x; center.y = (short)y;
+ PhPoint_t radii = new PhPoint_t();
+ // Don't subtract one, so that the bottom/right edges are drawn
+ radii.x = (short)(x + width); radii.y = (short)(y + height);
+
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawEllipse(center, radii, OS.Pg_DRAW_STROKE | OS.Pg_EXTENT_BASED);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void drawPolygon(int[] pointArray) {
+ 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];
+ }
+
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawPolygon(points, pointArray.length / 2, new PhPoint_t(), OS.Pg_DRAW_STROKE | OS.Pg_CLOSED);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void drawPolyline(int[] pointArray) {
+ 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);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void drawRectangle (int x, int y, int width, int height) {
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ // Don't subtract one, so that the bottom/right edges are drawn
+ OS.PgDrawIRect(x, y, x + width, y + height, OS.Pg_DRAW_STROKE);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void drawRectangle (Rectangle rect) {
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ drawRectangle (rect.x, rect.y, rect.width, rect.height);
+}
+
+public void drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
+ 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
+ rect.lr_x = (short)(x + width); rect.lr_y = (short)(y + height);
+ PhPoint_t radii = new PhPoint_t();
+ radii.x = (short)(arcWidth / 2); radii.y = (short)(arcHeight / 2);
+
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawRoundRect(rect, radii, OS.Pg_DRAW_STROKE);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void drawString (String string, int x, int y) {
+ drawString(string, x, y, false);
+}
+
+public void drawString (String string, int x, int y, boolean isTransparent) {
+ 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;
+ byte[] buffer = Converter.wcsToMbcs(null, string, false);
+
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawText(buffer, buffer.length, (short)x, (short)y, drawFlags);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void drawText (String string, int x, int y) {
+ drawText(string, x, y, false);
+}
+
+public void drawText (String string, int x, int y, boolean isTransparent) {
+ drawString(string, x, y, isTransparent);;
+}
+
+public boolean equals (Object object) {
+ return (object == this) || ((object instanceof GC) && (handle == ((GC)object).handle));
+}
+
+public void fillArc (int x, int y, int width, int height, int startAngle, int endAngle) {
+ if (startAngle > 0) {
+ if (endAngle > 0) {
+ //No need to modify start angle.
+ endAngle += startAngle;
+ } else {
+ int newStartAngle;
+ int newStopAngle = startAngle;
+ if (startAngle > Math.abs(endAngle)) {
+ newStartAngle = startAngle - Math.abs(endAngle);
+ } else {
+ newStartAngle = startAngle + 360 - Math.abs(endAngle);
+ }
+ startAngle = newStartAngle;
+ endAngle = newStopAngle;
+ }
+ } else {
+ if (endAngle > 0) {
+ endAngle = endAngle + startAngle;
+ startAngle = 360 - Math.abs(startAngle);
+ } else {
+ int newStopAngle = 360 + startAngle;
+ startAngle = newStopAngle - Math.abs(endAngle);
+ endAngle = newStopAngle;
+ }
+ }
+
+ startAngle = (int) (startAngle * 65536 / 360);
+ endAngle = (int) (endAngle * 65536 / 360);
+
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ if (width == 0 || height == 0 || endAngle == 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ PhPoint_t center = new PhPoint_t();
+ center.x = (short)(x + (width / 2));
+ center.y = (short)(y + (height / 2));
+ PhPoint_t radii = new PhPoint_t();
+ radii.x = (short)(width / 2);
+ radii.y = (short)(height / 2);
+
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawArc(center, radii, startAngle, endAngle, OS.Pg_ARC_PIE | OS.Pg_DRAW_FILL);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void fillOval (int x, int y, int width, int height) {
+ PhPoint_t center = new PhPoint_t();
+ center.x = (short)x; center.y = (short)y;
+ PhPoint_t radii = new PhPoint_t();
+ radii.x = (short)(x + width);
+ if (width != 2) radii.x--;
+ radii.y = (short)(y + height);
+ if (height != 2) radii.y--;
+
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawEllipse(center, radii, OS.Pg_DRAW_FILL | OS.Pg_EXTENT_BASED);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void fillPolygon(int[] pointArray) {
+ 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];
+ }
+
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawPolygon(points, pointArray.length / 2, new PhPoint_t(), OS.Pg_DRAW_FILL | OS.Pg_CLOSED);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void fillRectangle (int x, int y, int width, int height) {
+ if (width == 0 || height == 0) return;
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawIRect(x, y, x + width - 1, y + height - 1, OS.Pg_DRAW_FILL);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void fillRectangle (Rectangle rect) {
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ fillRectangle (rect.x, rect.y, rect.width, rect.height);
+}
+
+public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
+ 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 radii = new PhPoint_t();
+ radii.x = (short)(arcWidth / 2); radii.y = (short)(arcHeight / 2);
+
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawRoundRect(rect, radii, OS.Pg_DRAW_FILL);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public int getAdvanceWidth(char ch) {
+ return getCharWidth(ch);
+}
+
+public Color getBackground() {
+ return Color.photon_new(data.device, data.background);
+}
+
+public int getCharWidth(char ch) {
+ String string = new String(new char[] {ch});
+ Point point = stringExtent(string);
+ return point.x;
+}
+
+public Rectangle getClipping() {
+ int flags = OS.PtEnter(0);
+ try {
+ PhRect_t rect = new PhRect_t();
+ int rid = data.rid;
+ int widget = data.widget;
+ Image image = data.image;
+ if (rid == OS.Ph_DEV_RID) {
+ OS.PhRegionQuery (rid, null, rect, 0, 0);
+ } else if (widget != 0) {
+ OS.PtWidgetCanvas(widget, rect);
+ } else if (image != null) {
+ PhImage_t img = new PhImage_t();
+ OS.memmove(img, image.handle, PhImage_t.sizeof);
+ rect.lr_x = (short)(img.size_w - 1);
+ rect.lr_y = (short)(img.size_h - 1);
+ }
+ int clipRects = data.clipRects;
+ if (clipRects != 0) {
+ int clipRectsCount = data.clipRectsCount;
+ int clip_ptr = OS.malloc(PhRect_t.sizeof);
+ OS.memmove(clip_ptr, clipRects, PhRect_t.sizeof);
+ for (int i = 1; i < clipRectsCount; i++) {
+ OS.PhRectUnion (clip_ptr, clipRects + (i * 4));
+ }
+ int rect_ptr = OS.malloc(PhRect_t.sizeof);
+ OS.memmove(rect_ptr, rect, PhRect_t.sizeof);
+ boolean intersect = OS.PhRectIntersect(rect_ptr, clip_ptr) != 0;
+ OS.memmove(rect, rect_ptr, PhRect_t.sizeof);
+ OS.free(rect_ptr);
+ OS.free(clip_ptr);
+ if (!intersect) return new Rectangle(0, 0, 0, 0);
+ }
+ int width = rect.lr_x - rect.ul_x + 1;
+ int height = rect.lr_y - rect.ul_y + 1;
+ return new Rectangle(rect.ul_x, rect.ul_y, width, height);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void getClipping (Region region) {
+ if (region == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ int flags = OS.PtEnter(0);
+ try {
+ if (region.handle != 0 && region.handle != Region.EMPTY_REGION) {
+ OS.PhFreeTiles(region.handle);
+ }
+ int clipRects = data.clipRects;
+ if (clipRects != 0) {
+ region.handle = OS.PhRectsToTiles(clipRects, data.clipRectsCount);
+ } else {
+ region.handle = OS.PhGetTile();
+ PhRect_t rect = new PhRect_t ();
+ int rid = data.rid;
+ int widget = data.widget;
+ Image image = data.image;
+ if (rid == OS.Ph_DEV_RID) {
+ OS.PhRegionQuery (rid, null, rect, 0, 0);
+ } else if (widget != 0) {
+ OS.PtWidgetCanvas(widget, rect);
+ } else if (image != null) {
+ PhImage_t img = new PhImage_t();
+ OS.memmove(img, image.handle, PhImage_t.sizeof);
+ rect.lr_x = (short)(img.size_w - 1);
+ rect.lr_y = (short)(img.size_h - 1);
+ }
+ OS.memmove(region.handle, rect, PhRect_t.sizeof);
+ }
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public Font getFont () {
+ return Font.photon_new(data.device, data.font);
+}
+
+public FontMetrics getFontMetrics() {
+ FontQueryInfo info = new FontQueryInfo();
+ OS.PfQueryFontInfo(data.font, info);
+ return FontMetrics.photon_new(info);
+}
+
+public Color getForeground() {
+ return Color.photon_new(data.device, data.foreground);
+}
+
+public int getLineStyle() {
+ return data.lineStyle;
+}
+
+public int getLineWidth() {
+ return data.lineWidth;
+}
+
+public boolean getXORMode() {
+ return data.xorMode;
+}
+
+public int hashCode () {
+ return handle;
+}
+
+
+void init(Drawable drawable, GCData data, int context) {
+ int prevContext;
+ Image image = data.image;
+ if (image == null) {
+ prevContext = OS.PgSetGC(context);
+ } else {
+ prevContext = OS.PmMemStart(context);
+ OS.PgSetDrawBufferSize(DrawBufferSize);
+ }
+
+ if (data.foreground == -1) data.foreground = DefaultFore;
+ OS.PgSetStrokeColor(data.foreground);
+ OS.PgSetTextColor(data.foreground);
+ if (data.background == -1) data.background = DefaultBack;
+ OS.PgSetFillColor(data.background);
+ if (data.font == null) data.font = Font.DefaultFont;
+ OS.PgSetFont(data.font);
+
+ if (image == null) {
+ OS.PgSetGC(prevContext);
+ } else {
+ image.memGC = this;
+ OS.PmMemStop(context);
+
+
+ /*
+ * Destroy the mask when it is generated from a transparent
+ * pixel since drawing on the image might change the mask.
+ */
+ if (image.transparentPixel != -1) {
+ PhImage_t phImage = new PhImage_t ();
+ OS.memmove(phImage, image.handle, PhImage_t.sizeof);
+ if (phImage.mask_bm != 0) {
+ OS.free(phImage.mask_bm);
+ phImage.mask_bm = 0;
+ phImage.mask_bpl = 0;
+ OS.memmove(image.handle, phImage, PhImage_t.sizeof);
+ }
+ }
+ }
+ this.drawable = drawable;
+ this.data = data;
+ handle = context;
+}
+
+public boolean isClipped() {
+ return data.clipRects != 0;
+}
+
+public boolean isDisposed() {
+ return handle == 0;
+}
+
+public void setBackground (Color color) {
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ int backColor = color == null ? DefaultBack : color.handle;
+ OS.PgSetFillColor(backColor);
+ data.background = backColor;
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void setClipping (int x, int y, int width, int height) {
+ int flags = OS.PtEnter(0);
+ try {
+ int clipRects = data.clipRects;
+ if (clipRects != 0)
+ OS.free(clipRects);
+ clipRects = OS.malloc(PhRect_t.sizeof);
+ int clipRectsCount = 1;
+ 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);
+ OS.memmove(clipRects, rect, PhRect_t.sizeof);
+ int prevContext = setGC();
+ OS.PgSetMultiClip(clipRectsCount, clipRects);
+ data.clipRects = clipRects;
+ data.clipRectsCount = clipRectsCount;
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void setClipping (Rectangle rect) {
+ if (rect == null) {
+ int flags = OS.PtEnter(0);
+ try {
+ int clipRects = data.clipRects;
+ if (clipRects != 0)
+ OS.free(clipRects);
+ data.clipRects = data.clipRectsCount = 0;
+ int prevContext = setGC();
+ OS.PgSetMultiClip(0, 0);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+ } else
+ setClipping (rect.x, rect.y, rect.width, rect.height);
+}
+
+public void setClipping (Region region) {
+ int flags = OS.PtEnter(0);
+ try {
+ int clipRects = data.clipRects;
+ int clipRectsCount = data.clipRectsCount;
+ if (clipRects != 0)
+ OS.free(clipRects);
+ if (region == null || region.handle == 0) {
+ clipRects = clipRectsCount = 0;
+ } else if (region.handle == Region.EMPTY_REGION) {
+ clipRects = OS.malloc(PhRect_t.sizeof);
+ clipRectsCount = 1;
+ } else {
+ int[] clip_rects_count = new int[1];
+ clipRects = OS.PhTilesToRects(region.handle, clip_rects_count);
+ clipRectsCount = clip_rects_count[0];
+ }
+ int prevContext = setGC();
+ OS.PgSetMultiClip(clipRectsCount, clipRects);
+ data.clipRects = clipRects;
+ data.clipRectsCount = clipRectsCount;
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void setFont (Font font) {
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ byte[] newFont = font == null ? Font.DefaultFont : font.handle;
+ OS.PgSetFont(newFont);
+ data.font = newFont;
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void setForeground (Color color) {
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ int foreColor = color == null ? DefaultFore : color.handle;
+ data.foreground = foreColor;
+ OS.PgSetStrokeColor(foreColor);
+ OS.PgSetTextColor(foreColor);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void setLineStyle(int lineStyle) {
+ byte[] dashList;
+ switch (lineStyle) {
+ case SWT.LINE_SOLID: dashList = DashList[0]; break;
+ case SWT.LINE_DASH: dashList = DashList[1]; break;
+ case SWT.LINE_DOT: dashList = DashList[2]; break;
+ case SWT.LINE_DASHDOT: dashList = DashList[3]; break;
+ case SWT.LINE_DASHDOTDOT: dashList = DashList[4]; break;
+ default:
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ return;
+ }
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ data.lineStyle = lineStyle;
+ OS.PgSetStrokeDash(dashList, dashList.length, 0x10000);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void setLineWidth(int lineWidth) {
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ data.lineWidth = lineWidth;
+ OS.PgSetStrokeWidth(lineWidth);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+int setGC() {
+ if (data.image != null) return OS.PmMemStart(handle);
+ else if (data.rid == OS.Ph_DEV_RID || data.widget != 0) return OS.PgSetGC(handle);
+ else return 0;
+}
+
+void setGCClipping() {
+ int rid = data.rid;
+ int widget = data.widget;
+ int topWidget = data.topWidget;
+ if (rid == OS.Ph_DEV_RID) OS.PgSetRegion(rid);
+ else if (widget != 0) OS.PgSetRegion(OS.PtWidgetRid(widget));
+ else if (data.image != null) return;
+
+ // NOTE: PgSetRegion resets the clipping rectangle to the full size of
+ // the region.
+ OS.PgSetMultiClip(data.clipRectsCount, data.clipRects);
+
+ if (widget == 0) return;
+
+ 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
+ }
+ }
+ // 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
+ }
+ temp_widget = OS.PtWidgetBrotherInFront(temp_widget);
+ }
+
+ // Get the widget's rectangle
+ OS.PtWidgetCanvas(widget, widget_tile); // NOTE: widget_tile->rect
+ OS.PhDeTranslateTiles(widget_tile, widget_tile); // NOTE: widget_tile->rect.ul
+
+ // Clip the widget's rectangle from the child/siblings rectangle's
+ int clip_rects;
+ int[] clip_rects_count = new int[1];
+ 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);
+ }
+ OS.PgSetClipping((short)clip_rects_count[0], clip_rects);
+ OS.free(clip_rects);
+}
+
+public void setXORMode(boolean xor) {
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ data.xorMode = xor;
+ if (xor) OS.PgSetDrawMode(OS.Pg_DRAWMODE_XOR);
+ else OS.PgSetDrawMode(OS.Pg_DRAWMODE_OPAQUE);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public Point stringExtent(String string) {
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ PhRect_t rect = new PhRect_t();
+ int size = string.length();
+ char[] buffer = new char[size];
+ string.getChars(0, size, buffer, 0);
+
+ int flags = OS.PtEnter(0);
+ try {
+ OS.PfExtentWideText(rect, null, data.font, buffer, size * 2);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+
+ int width = rect.lr_x - rect.ul_x + 1;
+ int height = rect.lr_y - rect.ul_y + 1;
+ return new Point(width, height);
+}
+
+public Point textExtent(String string) {
+ return stringExtent(string);
+}
+
+void unsetGC(int prevContext) {
+ Image image = data.image;
+ if (image != null) {
+ OS.PmMemFlush(handle, image.handle);
+ OS.PmMemStop(handle);
+ } else if (data.rid == OS.Ph_DEV_RID || data.widget != 0) {
+ OS.PgSetGC(prevContext);
+// OS.PgFlush();
+ }
+}
+
+public static GC photon_new(Drawable drawable, GCData data) {
+ GC gc = new GC();
+ int context = drawable.internal_new_GC(data);
+ gc.init(drawable, data, context);
+ 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
new file mode 100755
index 0000000000..f021841ba1
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GCData.java
@@ -0,0 +1,23 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+
+public final class GCData {
+ public Device device;
+ public Image image;
+ public int rid;
+ public int widget, topWidget;
+ public int foreground = -1;
+ public int background = -1;
+ public byte[] font;
+ public boolean xorMode;
+ public int lineStyle = SWT.LINE_SOLID;
+ 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
new file mode 100755
index 0000000000..01f00d8053
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java
@@ -0,0 +1,612 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import java.io.*;
+
+public final class Image implements Drawable {
+
+ /**
+ * specifies whether the receiver is a bitmap or an icon
+ * (one of <code>SWT.BITMAP</code>, <code>SWT.ICON</code>)
+ */
+ public int type;
+
+ /**
+ * the OS resource of the image
+ * (Warning: This field is platform dependent)
+ */
+ public int handle;
+
+ /**
+ * the device where this image was created
+ */
+ Device device;
+
+ /**
+ * specifies the transparent pixel
+ * (Warning: This field is platform dependent)
+ */
+ int transparentPixel = -1;
+
+ /**
+ * the GC which is drawing on the image
+ * (Warning: This field is platform dependent)
+ */
+ GC memGC;
+
+ /**
+ * specifies the default scanline padding
+ * (Warning: This field is platform dependent)
+ */
+ static final int DEFAULT_SCANLINE_PAD = 4;
+
+Image () {
+}
+
+public Image(Device device, int width, int height) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, width, height);
+ if (device.tracking) device.new_Object(this);
+}
+
+public Image(Device device, Image srcImage, int flag) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+ if (srcImage == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ switch (flag) {
+ case SWT.IMAGE_COPY:
+ case SWT.IMAGE_DISABLE:
+ this.type = srcImage.type;
+ int imageHandle = srcImage.handle;
+ if (imageHandle != 0) {
+ imageHandle = OS.PiDuplicateImage (imageHandle, 0);
+ if (imageHandle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ PhImage_t phImage = new PhImage_t();
+ if (flag == SWT.IMAGE_COPY) {
+ /*
+ * Bug in Photon - The image returned by PiDuplicateImage
+ * has the same mask_bm as the original image.
+ */
+ OS.memmove (phImage, imageHandle, PhImage_t.sizeof);
+ if (phImage.mask_bm != 0) {
+ int length = phImage.mask_bpl * phImage.size_h;
+ int ptr = OS.malloc (length);
+ OS.memmove(ptr, phImage.mask_bm, length);
+ phImage.mask_bm = ptr;
+ OS.memmove (imageHandle, phImage, PhImage_t.sizeof);
+ }
+ /*
+ * Bug in Photon - The image returned by PiDuplicateImage
+ * has the same alpha as the original image.
+ */
+ if (phImage.alpha != 0) {
+ PgAlpha_t alpha = new PgAlpha_t();
+ OS.memmove(alpha, phImage.alpha, PgAlpha_t.sizeof);
+ if (alpha.src_alpha_map_map != 0) {
+ int length = alpha.src_alpha_map_dim_w * alpha.src_alpha_map_dim_h;
+ int ptr = OS.malloc(length);
+ OS.memmove(ptr, alpha.src_alpha_map_map, length);
+ }
+ int ptr = OS.malloc(PgAlpha_t.sizeof);
+ OS.memmove(ptr, alpha, PgAlpha_t.sizeof);
+ phImage.alpha = ptr;
+ OS.memmove (imageHandle, phImage, PhImage_t.sizeof);
+ }
+ transparentPixel = srcImage.transparentPixel;
+ } else {
+ OS.PhMakeGhostBitmap(imageHandle);
+ OS.memmove (phImage, imageHandle, PhImage_t.sizeof);
+ phImage.mask_bm = phImage.ghost_bitmap;
+ phImage.mask_bpl = phImage.ghost_bpl;
+ phImage.ghost_bitmap = 0;
+ phImage.ghost_bpl = 0;
+ phImage.alpha = 0;
+ OS.memmove (imageHandle, phImage, PhImage_t.sizeof);
+ }
+ }
+ handle = imageHandle;
+ if (device.tracking) device.new_Object(this);
+ return;
+ case SWT.IMAGE_GRAY:
+ Rectangle r = srcImage.getBounds();
+ ImageData data = srcImage.getImageData();
+ PaletteData palette = data.palette;
+ ImageData newData = data;
+ if (!palette.isDirect) {
+ /* Convert the palette entries to gray. */
+ RGB [] rgbs = palette.getRGBs();
+ for (int i=0; i<rgbs.length; i++) {
+ if (data.transparentPixel != i) {
+ RGB color = rgbs [i];
+ int red = color.red;
+ int green = color.green;
+ int blue = color.blue;
+ int intensity = (red+red+green+green+green+green+green+blue) >> 3;
+ color.red = color.green = color.blue = intensity;
+ }
+ }
+ newData.palette = new PaletteData(rgbs);
+ } else {
+ /* Create a 8 bit depth image data with a gray palette. */
+ RGB[] rgbs = new RGB[256];
+ for (int i=0; i<rgbs.length; i++) {
+ rgbs[i] = new RGB(i, i, i);
+ }
+ newData = new ImageData(r.width, r.height, 8, new PaletteData(rgbs));
+ newData.maskData = data.maskData;
+ newData.maskPad = data.maskPad;
+
+ /* Convert the pixels. */
+ int[] scanline = new int[r.width];
+ int redMask = palette.redMask;
+ int greenMask = palette.greenMask;
+ int blueMask = palette.blueMask;
+ int redShift = palette.redShift;
+ int greenShift = palette.greenShift;
+ int blueShift = palette.blueShift;
+ for (int y=0; y<r.height; y++) {
+ int offset = y * newData.bytesPerLine;
+ data.getPixels(0, y, r.width, scanline, 0);
+ for (int x=0; x<r.width; x++) {
+ int pixel = scanline[x];
+ int red = pixel & redMask;
+ red = (redShift < 0) ? red >>> -redShift : red << redShift;
+ int green = pixel & greenMask;
+ green = (greenShift < 0) ? green >>> -greenShift : green << greenShift;
+ int blue = pixel & blueMask;
+ blue = (blueShift < 0) ? blue >>> -blueShift : blue << blueShift;
+ newData.data[offset++] =
+ (byte)((red+red+green+green+green+green+green+blue) >> 3);
+ }
+ }
+ }
+ init (device, newData);
+ if (device.tracking) device.new_Object(this);
+ return;
+ default:
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+}
+
+public Image(Device device, Rectangle bounds) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, bounds.width, bounds.height);
+ if (device.tracking) device.new_Object(this);
+}
+
+public Image(Device device, ImageData data) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, data);
+ if (device.tracking) device.new_Object(this);
+}
+
+public Image(Device device, ImageData source, ImageData mask) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (source == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (mask == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (source.width != mask.width || source.height != mask.height) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (mask.depth != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ ImageData image = new ImageData(source.width, source.height, source.depth, source.palette, source.scanlinePad, source.data);
+ image.maskPad = mask.scanlinePad;
+ image.maskData = mask.data;
+ init(device, image);
+ if (device.tracking) device.new_Object(this);
+}
+
+public Image (Device device, InputStream stream) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, new ImageData(stream));
+ if (device.tracking) device.new_Object(this);
+}
+
+public Image (Device device, String filename) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, new ImageData(filename));
+ if (device.tracking) device.new_Object(this);
+}
+
+public void dispose () {
+ if (handle == 0) return;
+ destroyImage(handle);
+ handle = 0;
+ memGC = null;
+ if (device.tracking) device.dispose_Object(this);
+ device = null;
+}
+
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof Image)) return false;
+ Image image = (Image) object;
+ return device == image.device && handle == image.handle;
+}
+
+public Color getBackground() {
+ if (transparentPixel == -1) return null;
+
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove(phImage, handle, PhImage_t.sizeof);
+ int color = 0;
+ if ((phImage.type & OS.Pg_IMAGE_CLASS_MASK) == OS.Pg_IMAGE_CLASS_PALETTE) {
+ int phPalette = phImage.palette;
+ if (phPalette == 0 || transparentPixel > phImage.colors) return null;
+ int[] pgColor = new int[1];
+ OS.memmove(pgColor, phPalette + (transparentPixel * 4), 4);
+ color = pgColor[0];
+ } else {
+ switch (phImage.type) {
+ case OS.Pg_IMAGE_DIRECT_888:
+ color = ((transparentPixel & 0xFF) << 16) | (transparentPixel & 0xFF00) | ((transparentPixel & 0xFF0000) >> 16);
+ break;
+ case OS.Pg_IMAGE_DIRECT_8888:
+ color = ((transparentPixel & 0xFF00) << 8) | ((transparentPixel & 0xFF0000) >> 8) | ((transparentPixel & 0xFF000000) >> 24);
+ break;
+ case OS.Pg_IMAGE_DIRECT_565:
+ color = ((transparentPixel & 0xF800) << 8) | ((transparentPixel & 0x7E0) << 5) | ((transparentPixel & 0x1F) << 3);
+ break;
+ case OS.Pg_IMAGE_DIRECT_555:
+ color = ((transparentPixel & 0x7C00) << 9) | ((transparentPixel & 0x3E0) << 6) | ((transparentPixel & 0x1F) << 3);
+ break;
+ case OS.Pg_IMAGE_DIRECT_444:
+ color = ((transparentPixel & 0xF00) << 12) | ((transparentPixel & 0xF0) << 8) | ((transparentPixel & 0xF) << 4);
+ break;
+ default:
+ return null;
+ }
+ }
+ return Color.photon_new(device, color);
+}
+
+public Rectangle getBounds() {
+ if (handle == 0) return new Rectangle(0, 0, 0, 0);
+ 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() {
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove(phImage, handle, PhImage_t.sizeof);
+ int depth = 0;
+ PaletteData palette = null;
+ switch (phImage.type) {
+ case OS.Pg_IMAGE_DIRECT_555:
+ depth = 16;
+ palette = new PaletteData(0x7C00,0x3E0,0x1F);
+ break;
+ case OS.Pg_IMAGE_DIRECT_565:
+ depth = 16;
+ palette = new PaletteData(0xF800,0x7E0,0x1F);
+ break;
+ case OS.Pg_IMAGE_DIRECT_444:
+ depth = 16;
+ palette = new PaletteData(0xF00,0xF0,0xF);
+ break;
+ case OS.Pg_IMAGE_DIRECT_888:
+ depth = 24;
+ palette = new PaletteData(0xFF,0xFF00,0xFF0000);
+ break;
+ case OS.Pg_IMAGE_DIRECT_8888:
+ depth = 32;
+ palette = new PaletteData(0xFF00,0xFF0000,0xFF000000);
+ break;
+ case -1:
+ depth = 1;
+ palette = new PaletteData(new RGB[] {new RGB(0,0,0), new RGB(255,255,255)});
+ break;
+ case OS.Pg_IMAGE_PALETTE_NIBBLE:
+ case OS.Pg_IMAGE_PALETTE_BYTE:
+ depth = phImage.type == OS.Pg_IMAGE_PALETTE_BYTE ? 8 : 4;
+ RGB[] rgbs = new RGB[phImage.colors];
+ int[] colors = new int[phImage.colors];
+ OS.memmove(colors, phImage.palette, colors.length * 4);
+ for (int i = 0; i < rgbs.length; i++) {
+ int rgb = colors[i];
+ rgbs[i] = new RGB((rgb & 0xFF0000) >> 16, (rgb & 0xFF00) >> 8, rgb & 0xFF);
+ }
+ palette = new PaletteData(rgbs);
+ break;
+ default:
+ SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+ }
+
+ int calcBpl, scanLinePad, bpl = phImage.bpl;
+ int width = phImage.size_w, height = phImage.size_h;
+ int dataBytesPerLine = (width * depth + 7) / 8;
+ for (scanLinePad = 1; scanLinePad < 128; scanLinePad++) {
+ calcBpl = (dataBytesPerLine + (scanLinePad - 1)) / scanLinePad * scanLinePad;
+ if (bpl == calcBpl) break;
+ }
+ byte[] data = new byte[height * bpl];
+ OS.memmove(data, phImage.image, data.length);
+
+ ImageData imageData = new ImageData(width, height, depth, palette, scanLinePad, data);
+
+ if (transparentPixel != -1) {
+ imageData.transparentPixel = transparentPixel;
+ } else if (phImage.mask_bm != 0) {
+ imageData.maskData = new byte[height * phImage.mask_bpl];
+ OS.memmove(imageData.maskData, phImage.mask_bm, imageData.maskData.length);
+ imageData.maskPad = 4;
+ } else if (phImage.alpha != 0) {
+ PgAlpha_t alpha = new PgAlpha_t();
+ OS.memmove(alpha, phImage.alpha, PgAlpha_t.sizeof);
+ imageData.alpha = alpha.src_global_alpha;
+ if ((alpha.alpha_op & OS.Pg_ALPHA_OP_SRC_MAP) != 0 && alpha.src_alpha_map_map != 0) {
+ int length = alpha.src_alpha_map_dim_w * alpha.src_alpha_map_dim_h;
+ imageData.alphaData = new byte[length];
+ OS.memmove(imageData.alphaData, alpha.src_alpha_map_map, length);
+ }
+ }
+
+ return imageData;
+}
+
+public int hashCode () {
+ return handle;
+}
+
+void init(Device device, int width, int height) {
+ if (width <= 0 | height <= 0) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ this.device = device;
+ this.type = SWT.BITMAP;
+
+ handle = OS.PhCreateImage(null, (short)width, (short)height, OS.Pg_IMAGE_DIRECT_888, 0, 0, 0);
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+}
+
+void init(Device device, ImageData i) {
+ if (i == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+
+ /* Photon does not support 1 & 2-bit images. Convert to 4-bit image. */
+ if (i.depth == 1 || i.depth == 2) {
+ ImageData img = new ImageData(i.width, i.height, 4, i.palette);
+ ImageData.blit(ImageData.BLIT_SRC,
+ i.data, i.depth, i.bytesPerLine, ImageData.MSB_FIRST, 0, 0, i.width, i.height, null, null, null, -1, null, 0,
+ img.data, img.depth, img.bytesPerLine, ImageData.MSB_FIRST, 0, 0, img.width, img.height, null, null, null,
+ false, false);
+ img.transparentPixel = i.transparentPixel;
+ img.maskPad = i.maskPad;
+ img.maskData = i.maskData;
+ img.alpha = i.alpha;
+ img.alphaData = i.alphaData;
+ i = img;
+ }
+
+ int type = 0;
+ int[] phPalette = null;
+ if (!i.palette.isDirect) {
+ switch (i.depth) {
+ case 4: type = OS.Pg_IMAGE_PALETTE_NIBBLE; break;
+ case 8: type = OS.Pg_IMAGE_PALETTE_BYTE; break;
+ default: SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+ }
+ RGB[] rgbs = i.palette.getRGBs();
+ phPalette = new int[rgbs.length];
+ for (int j=0; j<rgbs.length; j++) {
+ RGB rgb = rgbs[j];
+ phPalette[j] = ((rgb.red & 0xFF) << 16) | ((rgb.green & 0xFF) << 8) | (rgb.blue & 0xFF);
+ }
+ } else {
+ PaletteData newPalette = null;
+ PaletteData palette = i.palette;
+ int redMask = palette.redMask;
+ int greenMask = palette.greenMask;
+ int blueMask = palette.blueMask;
+ int order = ImageData.MSB_FIRST;
+ switch (i.depth) {
+ case 16:
+ order = ImageData.LSB_FIRST;
+ if (redMask == 0x7C00 && greenMask == 0x3E0 && blueMask == 0x1F) {
+ type = OS.Pg_IMAGE_DIRECT_555;
+ } else if (redMask == 0xF800 && greenMask == 0x7E0 && blueMask == 0x1F) {
+ type = OS.Pg_IMAGE_DIRECT_565;
+ } else if (redMask == 0xF00 && greenMask == 0xF0 && blueMask == 0xF) {
+ type = OS.Pg_IMAGE_DIRECT_444;
+ } else {
+ type = OS.Pg_IMAGE_DIRECT_565;
+ newPalette = new PaletteData(0xF800, 0x7E0, 0x1F);
+ }
+ break;
+ case 24:
+ if (redMask == 0xFF && greenMask == 0xFF00 && blueMask == 0xFF0000) {
+ type = OS.Pg_IMAGE_DIRECT_888;
+ } else {
+ type = OS.Pg_IMAGE_DIRECT_888;
+ newPalette = new PaletteData(0xFF, 0xFF00, 0xFF0000);
+ }
+ break;
+ case 32:
+ if (redMask == 0xFF00 && greenMask == 0xFF0000 && blueMask == 0xFF000000) {
+ type = OS.Pg_IMAGE_DIRECT_8888;
+ } else {
+ type = OS.Pg_IMAGE_DIRECT_8888;
+ newPalette = new PaletteData(0xFF00, 0xFF0000, 0xFF000000);
+ }
+ break;
+ default:
+ SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+ }
+ if (newPalette != null) {
+ ImageData img = new ImageData(i.width, i.height, i.depth, newPalette);
+ ImageData.blit(ImageData.BLIT_SRC,
+ i.data, i.depth, i.bytesPerLine, order, 0, 0, i.width, i.height, redMask, greenMask, blueMask, -1, null, 0,
+ img.data, img.depth, img.bytesPerLine, order, 0, 0, img.width, img.height, newPalette.redMask, newPalette.greenMask, newPalette.blueMask,
+ false, false);
+ if (i.transparentPixel != -1) {
+ img.transparentPixel = newPalette.getPixel(palette.getRGB(i.transparentPixel));
+ }
+ img.maskPad = i.maskPad;
+ img.maskData = i.maskData;
+ img.alpha = i.alpha;
+ img.alphaData = i.alphaData;
+ i = img;
+ }
+ }
+ int handle = OS.malloc(PhImage_t.sizeof);
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ PhImage_t phImage = new PhImage_t();
+ phImage.type = type;
+ phImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
+ int size = i.data.length;
+ int ptr = OS.malloc(size);
+ if (ptr == 0) {
+ OS.free(handle);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ OS.memmove(ptr, i.data, size);
+ phImage.image = ptr;
+ phImage.size_w = (short)i.width;
+ phImage.size_h = (short)i.height;
+ phImage.bpl = i.bytesPerLine;
+ if (phPalette != null) {
+ size = phPalette.length * 4;
+ ptr = OS.malloc(size);
+ if (ptr == 0) {
+ OS.free(phImage.image);
+ OS.free(handle);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ OS.memmove(ptr, phPalette, size);
+ phImage.palette = ptr;
+ phImage.colors = phPalette.length;
+ }
+ if (i.getTransparencyType() == SWT.TRANSPARENCY_MASK) {
+ this.type = SWT.ICON;
+ int maskBpl = (i.width * 1 + 7) / 8;
+ maskBpl = (maskBpl + (i.maskPad - 1)) / i.maskPad * i.maskPad;
+ size = maskBpl * i.height;
+ ptr = OS.malloc(size);
+ if (ptr == 0) {
+ if (phImage.palette != 0) OS.free(phImage.palette);
+ OS.free(phImage.image);
+ OS.free(handle);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ OS.memmove(ptr, i.maskData, size);
+ phImage.mask_bm = ptr;
+ phImage.mask_bpl = maskBpl;
+ } else {
+ this.type = SWT.BITMAP;
+ if (i.transparentPixel != -1) {
+ /*
+ * The PhImage_t field transparent can not used to store the
+ * transparent pixel because it is overwritten when a GC is
+ * created on the image.
+ */
+ transparentPixel = i.transparentPixel;
+ } else if (i.alpha != -1 || i.alphaData != null) {
+ PgAlpha_t alpha = new PgAlpha_t();
+ alpha.alpha_op = i.alpha != -1 ? OS.Pg_ALPHA_OP_SRC_GLOBAL : OS.Pg_ALPHA_OP_SRC_MAP;
+ alpha.alpha_op |= OS.Pg_BLEND_SRC_SRC_ALPHA | OS.Pg_BLEND_DST_ONE_MINUS_SRC_ALPHA;
+ alpha.src_global_alpha = (byte)i.alpha;
+ if (i.alpha == -1 && i.alphaData != null) {
+ ptr = OS.malloc(i.alphaData.length);
+ if (ptr == 0) {
+ if (phImage.palette != 0) OS.free(phImage.palette);
+ OS.free(phImage.image);
+ OS.free(handle);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ OS.memmove(ptr, i.alphaData, i.alphaData.length);
+ alpha.src_alpha_map_dim_w = (short)i.width;
+ alpha.src_alpha_map_dim_h = (short)i.height;
+ alpha.src_alpha_map_map = ptr;
+ }
+ ptr = OS.malloc(PgAlpha_t.sizeof);
+ if (ptr == 0) {
+ if (alpha.src_alpha_map_map != 0) OS.free(alpha.src_alpha_map_map);
+ if (phImage.palette != 0) OS.free(phImage.palette);
+ OS.free(phImage.image);
+ OS.free(handle);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ OS.memmove(ptr, alpha, PgAlpha_t.sizeof);
+ phImage.alpha = ptr;
+ }
+ }
+ OS.memmove(handle, phImage, PhImage_t.sizeof);
+ this.handle = handle;
+}
+
+public int internal_new_GC (GCData data) {
+ /*
+ * Create a new GC that can draw into the image.
+ * Only supported for bitmaps.
+ */
+ if (type != SWT.BITMAP || memGC != null) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove(phImage, handle, PhImage_t.sizeof);
+ PhDim_t dim = new PhDim_t();
+ dim.w = phImage.size_w;
+ dim.h = phImage.size_h;
+ PhPoint_t trans = new PhPoint_t();
+ int pmMC = OS.PmMemCreateMC(handle, dim, trans);
+ if (pmMC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+
+ data.device = device;
+ data.image = this;
+ return pmMC;
+}
+
+public void internal_dispose_GC (int pmMC, GCData data) {
+ OS.PmMemReleaseMC(pmMC);
+}
+
+public boolean isDisposed() {
+ return handle == 0;
+}
+
+public void setBackground(Color color) {
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (transparentPixel == -1) return;
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove(phImage, handle, PhImage_t.sizeof);
+ int phPalette = phImage.palette;
+ if (phPalette == 0 || transparentPixel > phImage.colors) return;
+ int[] pgColor = new int[]{ color.handle };
+ OS.memmove(phPalette + (transparentPixel * 4), pgColor, 4);
+}
+
+static void destroyImage(int image) {
+ if (image == 0) return;
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove(phImage, image, PhImage_t.sizeof);
+ phImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
+ OS.memmove(image, phImage, PhImage_t.sizeof);
+ OS.PhReleaseImage(image);
+ OS.free(image);
+}
+
+public static Image photon_new(Device device, int type, int handle) {
+ if (device == null) device = Device.getDevice();
+ Image image = new Image();
+ image.type = type;
+ image.handle = handle;
+ image.device = device;
+ return image;
+}
+
+} \ No newline at end of file
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
new file mode 100755
index 0000000000..2b058dfc7c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Region.java
@@ -0,0 +1,153 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
+public final class Region {
+
+ /**
+ * the OS resource for the region
+ * (Warning: This field is platform dependent)
+ */
+ public int handle;
+
+ static int EMPTY_REGION = -1;
+
+public Region () {
+ handle = EMPTY_REGION;
+}
+Region(int handle) {
+ this.handle = handle;
+}
+
+
+public void add (Rectangle rect) {
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (handle == 0) return;
+ int tile_ptr = OS.PhGetTile();
+ PhTile_t tile = new PhTile_t();
+ tile.rect_ul_x = (short)rect.x;
+ tile.rect_ul_y = (short)rect.y;
+ tile.rect_lr_x = (short)(rect.x + rect.width - 1);
+ tile.rect_lr_y = (short)(rect.y + rect.height - 1);
+ OS.memmove(tile_ptr, tile, PhTile_t.sizeof);
+ if (handle == EMPTY_REGION) handle = tile_ptr;
+ else handle = OS.PhAddMergeTiles (handle, tile_ptr, null);
+}
+
+public void add (Region region) {
+ if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (handle == 0) return;
+ if (region.handle == 0 || region.handle == EMPTY_REGION) return;
+ int copy = OS.PhCopyTiles(region.handle);
+ if (handle == EMPTY_REGION) handle = copy;
+ else handle = OS.PhAddMergeTiles (handle, copy, null);
+}
+
+public boolean contains (int x, int y) {
+ if (handle == 0 || handle == EMPTY_REGION) return false;
+ int tile_ptr = OS.PhGetTile();
+ PhTile_t tile = new PhTile_t();
+ tile.rect_ul_x = tile.rect_lr_x = (short)x;
+ tile.rect_ul_y = tile.rect_lr_y = (short)y;
+ OS.memmove(tile_ptr, tile, PhTile_t.sizeof);
+ int intersection = OS.PhIntersectTilings (tile_ptr, handle, null);
+ boolean result = intersection != 0;
+ OS.PhFreeTiles(tile_ptr);
+ OS.PhFreeTiles(intersection);
+ return result;
+}
+
+public boolean contains (Point pt) {
+ if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return contains(pt.x, pt.y);
+}
+
+public void dispose () {
+ if (handle == 0) return;
+ if (handle != EMPTY_REGION) OS.PhFreeTiles (handle);
+ handle = 0;
+}
+
+public boolean equals (Object object) {
+ if (this == object) return true;
+ if (!(object instanceof Region)) return false;
+ int rgn = ((Region)object).handle;
+ return handle == rgn;
+}
+
+public Rectangle getBounds() {
+ if (handle == 0 || handle == EMPTY_REGION) return new Rectangle(0, 0, 0, 0);
+ PhTile_t tile = new PhTile_t();
+ int temp_tile;
+ int rect_ptr = OS.malloc(PhRect_t.sizeof);
+ OS.memmove(rect_ptr, handle, PhRect_t.sizeof);
+ OS.memmove(tile, handle, PhTile_t.sizeof);
+ while ((temp_tile = tile.next) != 0) {
+ OS.PhRectUnion (rect_ptr, temp_tile);
+ OS.memmove(tile, temp_tile, PhTile_t.sizeof);
+ }
+ PhRect_t rect = new PhRect_t();
+ OS.memmove(rect, rect_ptr, PhRect_t.sizeof);
+ OS.free(rect_ptr);
+ int width = rect.lr_x - rect.ul_x + 1;
+ int height = rect.lr_y - rect.ul_y + 1;
+ return new Rectangle(rect.ul_x, rect.ul_y, width, height);
+}
+
+public int hashCode () {
+ return handle;
+}
+
+public boolean intersects (int x, int y, int width, int height) {
+ if (handle == 0 || handle == EMPTY_REGION) return false;
+ int tile_ptr = OS.PhGetTile();
+ PhTile_t tile = new PhTile_t();
+ tile.rect_ul_x = (short)x;
+ tile.rect_ul_y = (short)y;
+ tile.rect_lr_x = (short)(x + width - 1);
+ tile.rect_lr_y = (short)(y + height - 1);
+ OS.memmove(tile_ptr, tile, PhTile_t.sizeof);
+ int intersection = OS.PhIntersectTilings (tile_ptr, handle, null);
+ boolean result = intersection != 0;
+ OS.PhFreeTiles(tile_ptr);
+ OS.PhFreeTiles(intersection);
+ return result;
+}
+
+public boolean intersects (Rectangle rect) {
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return intersects(rect.x, rect.y, rect.width, rect.height);
+}
+
+public boolean isDisposed() {
+ return handle == 0;
+}
+
+public boolean isEmpty () {
+ return getBounds().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);
+}
+*/
+} \ 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
new file mode 100755
index 0000000000..682f69081f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/Converter.java
@@ -0,0 +1,71 @@
+package org.eclipse.swt.internal;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public final class Converter {
+ public static final byte [] NullByteArray = new byte [1];
+ public static final char [] NullCharArray = new char [1];
+ public static final byte [] EmptyByteArray = new byte [0];
+ public static final char [] EmptyCharArray = new char [0];
+public static String defaultCodePage () {
+ /*
+ | ptr cp |
+ DefaultCodePage == nil ifFalse: [^DefaultCodePage].
+ cp := ''. "$NON-NLS$"
+ (ptr := OSStringZ address: (NlLanginfo callWith: 49)) isNull
+ ifFalse: [cp := String copyFromOSMemory: ptr].
+ cp isEmpty ifFalse: [
+ IsSunOS ifTrue: [
+ (cp size > 3 and: [(cp copyFrom: 1 to: 3) = 'ISO'])
+ ifTrue: [cp := cp copyFrom: 4 to: cp size]].
+ ^DefaultCodePage := cp].
+ IsAIX ifTrue: [^DefaultCodePage := 'ISO8859-1'].
+ IsSunOS ifTrue: [^DefaultCodePage := '8859-1'].
+ ^DefaultCodePage := 'iso8859_1'
+ */
+ return null;
+}
+static boolean is7BitAscii (byte [] buffer) {
+ for (int i=0; i<buffer.length; i++) {
+ if ((buffer [i] & 0xFF) > 0x7F) return false;
+ }
+ return true;
+}
+static boolean is7BitAscii (char [] buffer) {
+ for (int i=0; i<buffer.length; i++) {
+ if (buffer [i] > 0x7F) return false;
+ }
+ return true;
+}
+public static char [] mbcsToWcs (String codePage, byte [] buffer) {
+ //SLOW AND BOGUS
+ return new String (buffer).toCharArray ();
+}
+/* TEMPORARY CODE */
+public static byte [] wcsToMbcs (String codePage, String string) {
+ return wcsToMbcs (codePage, string, false);
+}
+public static byte [] wcsToMbcs (String codePage, String string, boolean terminate) {
+ //SLOW AND BOGUS
+ int count = string.length ();
+ if (terminate) count++;
+ char [] buffer = new char [count];
+ string.getChars (0, string.length (), buffer, 0);
+ return wcsToMbcs (codePage, buffer, false);
+}
+/* TEMPORARY CODE */
+public static byte [] wcsToMbcs (String codePage, char [] buffer) {
+ return wcsToMbcs (codePage, buffer, false);
+}
+public static byte [] wcsToMbcs (String codePage, char [] buffer, boolean terminate) {
+ //SLOW AND BOGUS
+ if (!terminate) return new String (buffer).getBytes ();
+ byte [] buffer1 = new String (buffer).getBytes ();
+ byte [] buffer2 = new byte [buffer1.length + 1];
+ System.arraycopy (buffer1, 0, buffer2, 0, buffer1.length);
+ return buffer2;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontDetails.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontDetails.java
new file mode 100755
index 0000000000..adcae07101
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontDetails.java
@@ -0,0 +1,15 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class FontDetails {
+ public byte[] desc = new byte[OS.MAX_DESC_LENGTH];
+ public byte[] stem = new byte[OS.MAX_FONT_TAG];
+ public short losize;
+ public short hisize;
+ public short flags;
+ public static final int sizeof = 128;
+}
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
new file mode 100755
index 0000000000..af0556407a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontQueryInfo.java
@@ -0,0 +1,19 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class FontQueryInfo {
+ public byte[] font = new byte[OS.MAX_FONT_TAG];
+ public byte[] desc = new byte[OS.MAX_DESC_LENGTH];
+ public short size;
+ public short style;
+ public short ascender;
+ public short descender;
+ public short width;
+ public int lochar;
+ public int hichar;
+ public static final int sizeof = 140;
+}
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
new file mode 100755
index 0000000000..0ecedcc7b1
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/OS.java
@@ -0,0 +1,2893 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+
+public class OS {
+
+ /* Load the SWT library. */
+ static {
+ Callback.loadLibrary ();
+ }
+
+/**** BEGIN MANUALLY ADDED/FIXED ***/
+ public static final int Pt_SET_DRAW_F = 1507348;
+ public static final int Pt_ARG_ORIENTATION = ( 21 * 1000 + 5 );
+ public static final int Pt_ARG_SCROLL_POSITION = ( 21 * 1000 + 4 );
+ public static final int Pt_ARG_MAXIMUM = ( 21 * 1000 + 3 );
+ public static final int Pt_ARG_MINIMUM = ( 21 * 1000 + 2 );
+ public static final int Pt_ARG_WIDTH = ( 1 * 1000 + 23 );
+ public static final int Pt_ARG_HEIGHT = ( 1 * 1000 + 24 );
+// public static final int Pt_ARG_STYLE = ( 2 * 1000 + 18 );
+// public static final int Ph_USE_TRANSPARENCY = 0x80;
+ public static final int Ph_RELEASE_IMAGE_ALL = 0x1F;
+
+ public static final int Pt_TOP_ETCH = 0x00000001;
+ public static final int Pt_BOTTOM_ETCH = 0x00000002;
+ public static final int Pt_LEFT_ETCH = 0x00000004;
+ public static final int Pt_RIGHT_ETCH = 0x00000008;
+ public static final int Pt_TOP_OUTLINE = 0x00000010;
+ 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_INLINE = 0x00001000;
+ public static final int Pt_BOTTOM_INLINE = 0x00002000;
+ public static final int Pt_LEFT_INLINE = 0x00004000;
+ public static final int Pt_RIGHT_INLINE = 0x00008000;
+// public static final int Pt_FLAT_FILL = 0x00010000;
+// public static final int Pt_FULL_BORDERS = 0x00020000;
+// public static final int Pt_FULL_BEVELS = 0x00020000;
+ public static final int Pt_HORIZONTAL_GRADIENT = 0x00040000;
+// public static final int Pt_REVERSE_GRADIENT = 0x00080000;
+ public static final int Pt_STATIC_GRADIENT = 0x00100000;
+// public static final int Pt_STATIC_BORDERS = 0x00200000;
+// public static final int Pt_STATIC_BEVELS = 0x00200000;
+// public static final int Pt_STATIC_BORDER_COLORS = 0x00400000;
+// public static final int Pt_STATIC_BEVEL_COLORS = 0x00400000;
+// public static final int Pt_BASIC_ARMED = 0x80000000;
+// public static final int Pt_BASIC_RO_FLAGS = 0x80000000;
+// public static final int Pt_TOP_LEFT_ETCH = (Pt_TOP_ETCH | Pt_LEFT_ETCH);
+// public static final int Pt_BOTTOM_RIGHT_ETCH = (Pt_BOTTOM_ETCH | Pt_RIGHT_ETCH);
+// public static final int Pt_ALL_ETCHED = (Pt_TOP_LEFT_ETCH | Pt_BOTTOM_RIGHT_ETCH);
+ public static final int Pt_ALL_ETCHES = (Pt_TOP_ETCH | Pt_BOTTOM_ETCH | Pt_LEFT_ETCH | Pt_RIGHT_ETCH );
+// public static final int Pt_TOP_LEFT_OUTLINE = (Pt_TOP_OUTLINE | Pt_LEFT_OUTLINE);
+// public static final int Pt_BOTTOM_RIGHT_OUTLINE = (Pt_BOTTOM_OUTLINE | Pt_RIGHT_OUTLINE );
+ public static final int Pt_ALL_OUTLINES = (Pt_TOP_OUTLINE | Pt_BOTTOM_OUTLINE | Pt_LEFT_OUTLINE | Pt_RIGHT_OUTLINE);
+// public static final int Pt_TOP_LEFT_INLINE = (Pt_TOP_INLINE | Pt_LEFT_INLINE);
+// public static final int Pt_BOTTOM_RIGHT_INLINE = (Pt_BOTTOM_INLINE | Pt_RIGHT_INLINE );
+ public static final int Pt_ALL_INLINES = (Pt_TOP_INLINE | Pt_BOTTOM_INLINE | Pt_LEFT_INLINE | Pt_RIGHT_INLINE);
+// public static final int Pt_TOP_LEFT_BEVEL = (Pt_TOP_BEVEL | Pt_LEFT_BEVEL);
+// public static final int Pt_BOTTOM_RIGHT_BEVEL = (Pt_BOTTOM_BEVEL | Pt_RIGHT_BEVEL );
+// public static final int Pt_ALL_BEVELS = (Pt_TOP_BEVEL | Pt_BOTTOM_BEVEL | Pt_LEFT_BEVEL | Pt_RIGHT_BEVEL);
+// public static final int Pt_ALL_TOP = (Pt_TOP_ETCH | Pt_TOP_OUTLINE | Pt_TOP_BEVEL | Pt_TOP_INLINE);
+// public static final int Pt_ALL_BOTTOM = (Pt_BOTTOM_ETCH | Pt_BOTTOM_OUTLINE | Pt_BOTTOM_BEVEL | Pt_BOTTOM_INLINE);
+// public static final int Pt_ALL_LEFT = (Pt_LEFT_ETCH | Pt_LEFT_OUTLINE | Pt_LEFT_BEVEL | Pt_LEFT_INLINE);
+// public static final int Pt_ALL_RIGHT = (Pt_RIGHT_ETCH | Pt_RIGHT_OUTLINE | Pt_RIGHT_BEVEL | Pt_RIGHT_INLINE);
+// public static final int Pt_ALL = (Pt_ALL_TOP | Pt_ALL_BOTTOM | Pt_ALL_LEFT | Pt_ALL_RIGHT);
+
+ public static final int NAME_MAX = 255;
+ public static final int PATH_MAX = 1024;
+ public static final int Pt_FSR_NO_FCHECK = 0x000100;
+// public static final int Pt_FSR_NO_FSPEC = 0x000200;
+// public static final int Pt_FSR_NO_UP_BUTTON = 0x000400;
+// public static final int Pt_FSR_NO_NEW = 0x000800;
+// public static final int Pt_FSR_NO_NEW_BUTTON = 0x001000;
+ public static final int Pt_FSR_NO_SELECT_FILES = 0x002000;
+ public static final int Pt_FSR_SELECT_DIRS = 0x004000;
+// public static final int Pt_FSR_CREATE_PATH = 0x008000;
+// public static final int Pt_FSR_NO_CONFIRM_CREATE_PATH = 0x010000;
+// public static final int Pt_FSR_NO_DELETE = 0x020000;
+// public static final int Pt_FSR_NO_CONFIRM_DELETE = 0x040000;
+// public static final int Pt_FSR_RECURSIVE_DELETE = 0x080000;
+// public static final int Pt_FSR_CONFIRM_EXISTING = 0x100000;
+// public static final int Pt_FSR_CENTER = 0x200000;
+
+ public static final int Pt_ARG_BEVEL_WIDTH = ( 1 * 1000 + 1 );
+ public static final int Pt_ARG_INLINE_COLOR = ( 2 * 1000 + 23 );
+ public static final int Pt_ARG_OUTLINE_COLOR = ( 2 * 1000 + 22 );
+ public static final int Pt_ARG_LIGHT_FILL_COLOR = ( 2 * 1000 + 24 );
+ public static final int Pt_ARG_DARK_FILL_COLOR = ( 2 * 1000 + 25 );
+ public static final int Pt_ARG_DARK_BEVEL_COLOR = ( 2 * 1000 + 6 );
+ public static final int Pt_ARG_LIGHT_BEVEL_COLOR = ( 2 * 1000 + 0 );
+ public static final int Pt_ARG_BEVEL_COLOR = ( 2 * 1000 + 21 );
+
+ public static final int Pt_INDEX_COLOR = 0x2000000;
+
+// public static final int Pg_ALPHA_VALID = 0x80000000;
+// public static final int Pg_ALPHA_OP_TEST = 0x00010000;
+// public static final int Pg_ALPHA_OP_DEST_GLOBAL = 0x00020000;
+ public static final int Pg_ALPHA_OP_SRC_GLOBAL = 0x00040000;
+ public static final int Pg_ALPHA_OP_SRC_MAP = 0x00080000;
+// public static final int Pg_ALPHA_OP_SRC_GRADIENT = 0x00100000;
+// public static final int Pg_BLEND_SRC_ZERO = 0x0000; // (0,0,0,0)
+// public static final int Pg_BLEND_SRC_ONE = 0x0100; // (1,1,1,1)
+// public static final int Pg_BLEND_SRC_DST_COLOR = 0x0200; // (Ad,Rd,Gd,Bd)
+// public static final int Pg_BLEND_SRC_ONE_MINUS_DST_ALPHA = 0x0300; // (1,1,1,1)-(Ad,Rd,Gd,Bd)
+ public static final int Pg_BLEND_SRC_SRC_ALPHA = 0x0400; // (As,As,As,As)
+// public static final int Pg_BLEND_SRC_ONE_MINUS_SRC_ALPHA = 0x0500; // (1,1,1,1)-(As,As,As,As)
+// public static final int Pg_BLEND_SRC_DST_ALPHA = 0x0600; // (Ad,Ad,Ad,Ad)
+// public static final int Pg_BLEND_ONE_MINUS_DST_ALPHA = 0x0700; // (1,1,1,1)-(Ad,Ad,Ad,Ad)
+// public static final int Pg_BLEND_DST_ZERO = 0x00; // (0,0,0,0)
+// public static final int Pg_BLEND_DST_ONE = 0x01; // (1,1,1,1)
+// public static final int Pg_BLEND_DST_SRC_COLOR = 0x02; // (As,Rs,Gs,Bs)
+// public static final int Pg_BLEND_DST_ONE_MINUS_SRC = 0x03; // (1,1,1,1)-(As,Rs,Gs,Bs)
+// public static final int Pg_BLEND_DST_SRC_ALPHA = 0x04; // (As,As,As,As)
+ public static final int Pg_BLEND_DST_ONE_MINUS_SRC_ALPHA = 0x05; // (1,1,1,1)-(As,As,As,As)
+// public static final int Pg_BLEND_DST_DST_ALPHA = 0x06; // (Ad,Ad,Ad,Ad)
+// public static final int Pg_BLEND_DST_ONE_MINUS_DST_ALPHA = 0x07; // (1,1,1,1)-(Ad,Ad,Ad,Ad)
+
+// public static final int Pt_ARG_PG_FLAGS = 64 * 1000 + 0;
+// public static final int Pt_ARG_PG_CURRENT = 64 * 1000 + 1;
+ public static final int Pt_ARG_PG_PANEL_TITLES = 64 * 1000 + 2;
+// public static final int Pt_ARG_PG_CONTAINERS = 64 * 1000 + 3;
+// public static final int Pt_ARG_PG_SELECTION_MODE = 64 * 1000 + 4;
+ public static final int Pt_ARG_PG_CURRENT_INDEX = 64 * 1000 + 5;
+// public static final int Pt_ARG_PG_OVERLAP_THRESHOLD = 64 * 1000 + 6;
+// public static final int Pt_ARG_PG_DEFAULT_TAB_COLOR = 64 * 1000 + 7;
+ public static final int Pt_CB_PG_PANEL_SWITCHING = 64 * 1000 + 10;
+ public static final int Pt_PG_INVALID = 65535;
+
+ public static final int Pt_ARG_TITLE = 10 * 1000 + 7;
+ public static final int Pt_ARG_TITLE_FONT = 10 * 1000 + 8;
+ public static final int Pt_SHOW_TITLE = 0x00000100;
+ public static final int Pt_ETCH_TITLE_AREA = 0x00000200;
+ public static final int Pt_GRADIENT_TITLE_AREA = 0x00000400;
+
+ public static final int PF_STYLE_BOLD = 0x1;
+ public static final int PF_STYLE_ITALIC = 0x2;
+
+ public static final int PFFONT_DONT_SHOW_LEGACY = 0x40;
+
+// public static final int Pt_ARG_CS_COLOR = ( 150 * 1000 + 1 );
+// public static final int Pt_ARG_CS_COLOR_MODELS = ( 150 * 1000 + 2 );
+// public static final int Pt_ARG_CS_PALETTE = ( 150 * 1000 + 4 );
+
+ public static final int Ph_WM_RENDER_COLLAPSE = 0x00004000;
+
+ public static final int Pt_ARG_LABEL_IMAGE = ( 3 * 1000 + 1 );
+
+ 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_ITEM_SEPARATORS = 0x0020;
+
+ 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_CB_FILTER = ( 1 * 1000 + 26 );
+
+/*** END MANUALLY ADDED/FIXED ***/
+
+//public static final int Aw_ARG_ONOFF_STATE = ( 5 * 1000 + 1 );
+//public static final int Aw_CB_ONOFF_NEW_VALUE = ( 5 * 1000 + 0 );
+//public static final int DEV_CTRL_DEVICE_LAYER = 1;
+//public static final int DEV_CTRL_INPUT = 1;
+//public static final int DEV_CTRL_LAYER_MASK = 0xf0000000;
+//public static final int DEV_CTRL_OUTPUT = 2;
+//public static final int DEV_CTRL_PROTOCOL_LAYER = 2;
+//public static final int DEV_CTRL_SWITCH_MASK = 0x0f000000;
+//public static final int DEV_CTRL_TRANSLATE = 4;
+//public static final int DEV_CTRL_TYPE_MASK = 0x000000ff;
+//public static final int IsBorder = 0x00000200;
+//public static final int IsColorMode = 0x00010000;
+//public static final int IsColors = 0x04000000;
+//public static final int IsCopies = 0x00008000;
+//public static final int IsDither = 0x00400000;
+//public static final int IsDuplex = 0x00200000;
+//public static final int IsInkType = 0x01000000;
+//public static final int IsIntensity = 0x00800000;
+//public static final int IsMargins = 0x00000100;
+//public static final int IsOrientation = 0x00020000;
+//public static final int IsPageRange = 0x10000000;
+//public static final int IsPaperCollate = 0x00100000;
+//public static final int IsPaperSize = 0x00000040;
+//public static final int IsPaperSource = 0x00040000;
+//public static final int IsPaperType = 0x00080000;
+//public static final int IsPrinterDpi = 0x00000010;
+//public static final int IsScale = 0x00004000;
+//public static final int IsSrcColors = 0x02000000;
+//public static final int IsSrcDim = 0x00000001;
+//public static final int IsSrcDpi = 0x00001000;
+//public static final int IsSrcOff = 0x00000004;
+//public static final int KEY_CAP_VALID = 0x00000080;
+//public static final int KEY_DEAD = 0x40000000;
+//public static final int KEY_DEAD_FLAG = 0x80;
+//public static final int KEY_DOWN = 0x00000001;
+//public static final int KEY_MASK = 0x03ff;
+//public static final int KEY_NOSYM_FLAG = 0x40;
+//public static final int KEY_OEM_CAP = 0x80000000;
+//public static final int KEY_REPEAT = 0x00000002;
+//public static final int KEY_SCAN_VALID = 0x00000020;
+//public static final int KEY_SYM_VALID = 0x00000040;
+//public static final int KEYBOARD_CTRL_ATTR_MASK = 0x000f0000;
+//public static final int KEYBOARD_CTRL_DELAY = 0x00001000;
+//public static final int KEYBOARD_CTRL_DISPLAY = 0x00000400;
+//public static final int KEYBOARD_CTRL_DISPLAY_OFF = 0x00020000;
+//public static final int KEYBOARD_CTRL_DISPLAY_ON = 0x00010000;
+//public static final int KEYBOARD_CTRL_FILENAME = 0x00002000;
+//public static final int KEYBOARD_CTRL_LAYER = 0x00040000;
+//public static final int KEYBOARD_CTRL_LAYER_MASK = DEV_CTRL_LAYER_MASK;
+//public static final int KEYBOARD_CTRL_OFF = 0x00000200;
+//public static final int KEYBOARD_CTRL_ON = 0x00000100;
+//public static final int KEYBOARD_CTRL_RATE = 0x00000800;
+//public static final int KEYBOARD_CTRL_SWITCH_MASK = DEV_CTRL_SWITCH_MASK;
+//public static final int KEYBOARD_CTRL_TYPE_MASK = (DEV_CTRL_TYPE_MASK << 8);
+//public static final int KEYCAP = 0x0400;
+//public static final int KEYCODE_PC_KEYS = 0xF000;
+//public static final int KEYCODE_CAPS_LOCK = (KEYCODE_PC_KEYS + 0xe5);
+//public static final int KEYCODE_DELETE = (KEYCODE_PC_KEYS + 0xff);
+//public static final int KEYCODE_DOWN = (KEYCODE_PC_KEYS + 0x54);
+//public static final int KEYCODE_END = (KEYCODE_PC_KEYS + 0x57);
+//public static final int KEYCODE_ESCAPE = (KEYCODE_PC_KEYS + 0x1b);
+//public static final int KEYCODE_F1 = (KEYCODE_PC_KEYS + 0xbe);
+//public static final int KEYCODE_F10 = (KEYCODE_PC_KEYS + 0xc7);
+//public static final int KEYCODE_F11 = (KEYCODE_PC_KEYS + 0xc8);
+//public static final int KEYCODE_F12 = (KEYCODE_PC_KEYS + 0xc9);
+//public static final int KEYCODE_F2 = (KEYCODE_PC_KEYS + 0xbf);
+//public static final int KEYCODE_F3 = (KEYCODE_PC_KEYS + 0xc0);
+//public static final int KEYCODE_F4 = (KEYCODE_PC_KEYS + 0xc1);
+//public static final int KEYCODE_F5 = (KEYCODE_PC_KEYS + 0xc2);
+//public static final int KEYCODE_F6 = (KEYCODE_PC_KEYS + 0xc3);
+//public static final int KEYCODE_F7 = (KEYCODE_PC_KEYS + 0xc4);
+//public static final int KEYCODE_F8 = (KEYCODE_PC_KEYS + 0xc5);
+//public static final int KEYCODE_F9 = (KEYCODE_PC_KEYS + 0xc6);
+//public static final int KEYCODE_HOME = (KEYCODE_PC_KEYS + 0x50);
+//public static final int KEYCODE_INSERT = (KEYCODE_PC_KEYS + 0x63);
+//public static final int KEYCODE_KP_DELETE = (KEYCODE_PC_KEYS + 0xae);
+//public static final int KEYCODE_KP_DIVIDE = (KEYCODE_PC_KEYS + 0xaf);
+//public static final int KEYCODE_KP_DOWN = (KEYCODE_PC_KEYS + 0xb2);
+//public static final int KEYCODE_KP_END = (KEYCODE_PC_KEYS + 0xb1);
+//public static final int KEYCODE_KP_ENTER = (KEYCODE_PC_KEYS + 0x8d);
+//public static final int KEYCODE_KP_FIVE = (KEYCODE_PC_KEYS + 0xb5);
+//public static final int KEYCODE_KP_HOME = (KEYCODE_PC_KEYS + 0xb7);
+//public static final int KEYCODE_KP_INSERT = (KEYCODE_PC_KEYS + 0xb0);
+//public static final int KEYCODE_KP_LEFT = (KEYCODE_PC_KEYS + 0xb4);
+//public static final int KEYCODE_KP_MINUS = (KEYCODE_PC_KEYS + 0xad);
+//public static final int KEYCODE_KP_MULTIPLY = (KEYCODE_PC_KEYS + 0xaa);
+//public static final int KEYCODE_KP_PG_DOWN = (KEYCODE_PC_KEYS + 0xb3);
+//public static final int KEYCODE_KP_PG_UP = (KEYCODE_PC_KEYS + 0xb9);
+//public static final int KEYCODE_KP_PLUS = (KEYCODE_PC_KEYS + 0xab);
+//public static final int KEYCODE_KP_RIGHT = (KEYCODE_PC_KEYS + 0xb6);
+//public static final int KEYCODE_KP_UP = (KEYCODE_PC_KEYS + 0xb8);
+//public static final int KEYCODE_LEFT = (KEYCODE_PC_KEYS + 0x51);
+//public static final int KEYCODE_LEFT_ALT = (KEYCODE_PC_KEYS + 0xe9);
+//public static final int KEYCODE_LEFT_CTRL = (KEYCODE_PC_KEYS + 0xe3);
+//public static final int KEYCODE_LEFT_HYPER = (KEYCODE_PC_KEYS + 0xed);
+//public static final int KEYCODE_LEFT_SHIFT = (KEYCODE_PC_KEYS + 0xe1);
+//public static final int KEYCODE_MENU = (KEYCODE_PC_KEYS + 0x67);
+//public static final int KEYCODE_NUM_LOCK = (KEYCODE_PC_KEYS + 0x7f);
+//public static final int KEYCODE_PAUSE = (KEYCODE_PC_KEYS + 0x13);
+//public static final int KEYCODE_PG_DOWN = (KEYCODE_PC_KEYS + 0x56);
+//public static final int KEYCODE_PG_UP = (KEYCODE_PC_KEYS + 0x55);
+//public static final int KEYCODE_PRINT = (KEYCODE_PC_KEYS + 0x61);
+//public static final int KEYCODE_RETURN = (KEYCODE_PC_KEYS + 0x0d);
+//public static final int KEYCODE_RIGHT = (KEYCODE_PC_KEYS + 0x53);
+//public static final int KEYCODE_RIGHT_ALT = (KEYCODE_PC_KEYS + 0xea);
+//public static final int KEYCODE_RIGHT_CTRL = (KEYCODE_PC_KEYS + 0xe4);
+//public static final int KEYCODE_RIGHT_HYPER = (KEYCODE_PC_KEYS + 0xee);
+//public static final int KEYCODE_RIGHT_SHIFT = (KEYCODE_PC_KEYS + 0xe2);
+//public static final int KEYCODE_SCROLL_LOCK = (KEYCODE_PC_KEYS + 0x14);
+//public static final int KEYCODE_SYSREQ = (KEYCODE_PC_KEYS + 0x6a);
+//public static final int KEYCODE_TAB = (KEYCODE_PC_KEYS + 0x09);
+//public static final int KEYCODE_UP = (KEYCODE_PC_KEYS + 0x52);
+//public static final int KEYCOMPOSE_CODE = 0x0000;
+//public static final int KEYCOMPOSE_LAST = 0x8000;
+//public static final int KEYCOMPOSE_SIZE = 0x3fff;
+//public static final int KEYCOMPOSE_TABLE = 0x4000;
+//public static final int KEYGRP_MAX = 15;
+//public static final int KEYIND_CAPS_LOCK = 0x04;
+//public static final int KEYIND_NUM_LOCK = 0x02;
+//public static final int KEYIND_SCROLL_LOCK = 0x01;
+//public static final int KEYINDICATOR_MAX = 7;
+//public static final int KEYMAP_COMPOSE = 5;
+//public static final int KEYMAP_EXTENDED_MAP = 1;
+//public static final int KEYMAP_GEOMETRY = 7;
+//public static final int KEYMAP_GROUPS = 2;
+//public static final int KEYMAP_INDICATORS = 6;
+//public static final int KEYMAP_KEYS = 3;
+//public static final int KEYMAP_MAGIC = 0x2044424b;
+//public static final int KEYMAP_MODIFIERS = 4;
+//public static final int KEYMAP_NAME = 0;
+//public static final int KEYMODBIT_ALT = 2;
+//public static final int KEYMODBIT_ALT_LOCK = 10;
+//public static final int KEYMODBIT_ALTGR = 3;
+//public static final int KEYMODBIT_ALTGR_LOCK = 11;
+//public static final int KEYMODBIT_CAPS_LOCK = 16;
+//public static final int KEYMODBIT_CTRL = 1;
+//public static final int KEYMODBIT_CTRL_LOCK = 9;
+//public static final int KEYMODBIT_MASK = 0x3f;
+//public static final int KEYMODBIT_MOD6 = 5;
+//public static final int KEYMODBIT_MOD6_LOCK = 13;
+//public static final int KEYMODBIT_MOD7 = 6;
+//public static final int KEYMODBIT_MOD7_LOCK = 14;
+//public static final int KEYMODBIT_MOD8 = 7;
+//public static final int KEYMODBIT_MOD8_LOCK = 15;
+//public static final int KEYMODBIT_NUM_LOCK = 17;
+//public static final int KEYMODBIT_SCROLL_LOCK = 18;
+//public static final int KEYMODBIT_SHIFT = 0;
+//public static final int KEYMODBIT_SHIFT_LOCK = 8;
+//public static final int KEYMODBIT_SHL3 = 4;
+//public static final int KEYMODBIT_SHL3_LOCK = 12;
+//public static final int KEYMOD = 0x0800;
+//public static final int KEYMOD_ALT = (1 << KEYMODBIT_ALT);
+//public static final int KEYMOD_ALT_LOCK = (1 << KEYMODBIT_ALT_LOCK);
+//public static final int KEYMOD_ALTGR = (1 << KEYMODBIT_ALTGR);
+//public static final int KEYMOD_ALTGR_LOCK = (1 << KEYMODBIT_ALTGR_LOCK);
+//public static final int KEYMOD_AND = 0x80;
+//public static final int KEYMOD_CAPS_LOCK = (1 << KEYMODBIT_CAPS_LOCK);
+//public static final int KEYMOD_CTRL = (1 << KEYMODBIT_CTRL);
+//public static final int KEYMOD_CTRL_LOCK = (1 << KEYMODBIT_CTRL_LOCK);
+//public static final int KEYMOD_DOWN = 0x40;
+//public static final int KEYMOD_MOD6 = (1 << KEYMODBIT_MOD6);
+//public static final int KEYMOD_MOD6_LOCK = (1 << KEYMODBIT_MOD6_LOCK);
+//public static final int KEYMOD_MOD7 = (1 << KEYMODBIT_MOD7);
+//public static final int KEYMOD_MOD7_LOCK = (1 << KEYMODBIT_MOD7_LOCK);
+//public static final int KEYMOD_MOD8 = (1 << KEYMODBIT_MOD8);
+//public static final int KEYMOD_MOD8_LOCK = (1 << KEYMODBIT_MOD8_LOCK);
+//public static final int KEYMOD_NUM_LOCK = (1 << KEYMODBIT_NUM_LOCK);
+//public static final int KEYMOD_OR = 0x00;
+//public static final int KEYMOD_PRESS = 0xc0;
+//public static final int KEYMOD_RELEASE = 0x80;
+//public static final int KEYMOD_SCROLL_LOCK = (1 << KEYMODBIT_SCROLL_LOCK);
+//public static final int KEYMOD_SHIFT = (1 << KEYMODBIT_SHIFT);
+//public static final int KEYMOD_SHIFT_LOCK = (1 << KEYMODBIT_SHIFT_LOCK);
+//public static final int KEYMOD_SHL3 = (1 << KEYMODBIT_SHL3);
+//public static final int KEYMOD_SHL3_LOCK = (1 << KEYMODBIT_SHL3_LOCK);
+//public static final int KEYMOD_UP = 0x00;
+//public static final int MAX_FONT_TAG = 80;
+//public static final int NAME_MAX = 48;
+//public static final int NUMERIC_BUF = 40;
+//public static final int PaperCollateAAABBBCCC = 0x0002;
+//public static final int PaperCollateABCABCABC = 0x0001;
+//public static final int PaperCollateDefault = 0x0000;
+//public static final int PaperSourceAuto = 0x0001;
+//public static final int PaperSourceDefault = 0x0000;
+//public static final int PaperSourceEnvelope = 0x0005;
+//public static final int PaperSourceLower = 0x0003;
+//public static final int PaperSourceManual = 0x0004;
+//public static final int PaperSourceManualEnv = 0x0006;
+//public static final int PaperSourceUpper = 0x0002;
+//public static final int PaperTypeDefault = 0x0000;
+//public static final int PaperTypeDraftQuality = 0x0003;
+//public static final int PaperTypeEnvelope = 0x0005;
+//public static final int PaperTypeHighQuality = 0x0002;
+//public static final int PaperTypeNormal = 0x0001;
+//public static final int PaperTypeTransparency = 0x0004;
+//public static final int PaperTypeTShirt = 0x0006;
+//public static final int PFR_STATS = 0x02;
+//public static final int Pg_DRAW_ARC = 0x44;
+//public static final int Pg_DRAW_BEVELBOX = 0x45;
+//public static final int Pg_DRAW_BEZIER = 0x47;
+//public static final int Pg_DRAW_BITBLIT = 0x46;
+//public static final int Pg_DRAW_BITBLT = 0x46;
+//public static final int Pg_DRAW_BITBLT_CHROMA = 0x4A;
+//public static final int Pg_DRAW_BITMAP = 0x44;
+//public static final int Pg_DRAW_ELLIPSE = 0x43;
+ public static final int Pg_DRAW_FILL = 0x20;
+ public static final int Pg_DRAW_STROKE = 0x10;
+//public static final int Pg_DRAW_FILL_STROKE = (Pg_DRAW_FILL | Pg_DRAW_STROKE);
+//public static final int Pg_DRAW_GETIMAGE = 0x4F;
+//public static final int Pg_DRAW_GRADIENT = 0xD2;
+//public static final int Pg_DRAW_GRID = 0x47;
+//public static final int Pg_DRAW_IMAGE = 0x45;
+//public static final int Pg_DRAW_LINE = 0x42;
+//public static final int Pg_DRAW_POINT = 0x40;
+//public static final int Pg_DRAW_POINT_ARRAY = 0x41;
+//public static final int Pg_DRAW_POLYGON = 0x40;
+//public static final int Pg_DRAW_RECT = 0x41;
+//public static final int Pg_DRAW_RRECT = 0x42;
+//public static final int Pg_DRAW_SPAN = 0x46;
+//public static final int Pg_DRAW_STROKE_FILL = Pg_DRAW_FILL_STROKE;
+//public static final int Pg_DRAW_TEXT = 0x43;
+//public static final int Pg_DRAW_TREND = 0x48;
+//public static final int Pg_DRAW_VECTOR = 0x49;
+ public static final int Pg_ARC = (0x20 << 8);
+//public static final int Pg_ARC_CHORD = (0x00 << 8);
+ public static final int Pg_ARC_PIE = (0x10 << 8);
+//public static final int Pg_ARC_FILL = Pg_DRAW_FILL;
+//public static final int Pg_ARC_FILL_CHORD = Pg_DRAW_STROKE | Pg_ARC_CHORD;
+//public static final int Pg_ARC_FILL_PIE = Pg_DRAW_FILL | Pg_ARC_PIE;
+//public static final int Pg_ARC_STROKE = Pg_DRAW_STROKE;
+//public static final int Pg_ARC_STROKE_ARC = Pg_DRAW_STROKE | Pg_ARC;
+//public static final int Pg_ARC_STROKE_CHORD = Pg_DRAW_STROKE | Pg_ARC_CHORD;
+//public static final int Pg_ARC_STROKE_PIE = Pg_DRAW_STROKE | Pg_ARC_PIE;
+ public static final int Pg_BACK_FILL = (0x01 << 8);
+//public static final int Pg_BEVEL_ADOWN = 0xE000;
+//public static final int Pg_BEVEL_ALEFT = 0x2000;
+//public static final int Pg_BEVEL_ARIGHT = 0x6000;
+//public static final int Pg_BEVEL_ARROW = 0x2000;
+//public static final int Pg_BEVEL_AUP = 0xA000;
+//public static final int Pg_BEVEL_CLIP = 0x8000;
+//public static final int Pg_BEVEL_JOIN = 0x02;
+//public static final int Pg_BEVEL_MAX = 15;
+//public static final int Pg_BEVEL_ROUND = 0xC000;
+//public static final int Pg_BEVEL_SET = 0x1000;
+//public static final int Pg_BEVEL_SQUARE = 0x0000;
+//public static final int Pg_BEVEL_TYPE_MASK = 0xE000;
+public static final int Pg_BITMAP_BACKFILL = 0xFE;
+public static final int Pg_BITMAP_TRANSPARENT = 0xFF;
+//public static final int Pg_BUTT_CAP = 0x00;
+//public static final int Pg_BUTT_JOIN = 0x04;
+//public static final int Pg_CAH_INLINE_OFF_SIZE = 0x00000040;
+//public static final int Pg_CAH_RECORD_SIZE_MASK = 0x0000003F;
+//public static final int Pg_CAH_RELAY_TAGGED = 0x00002000;
+//public static final int Pg_CAH_SHMEM_LIMIT = 0x00000100;
+//public static final int Pg_CAH_SHMEM_NAME = 0x00000080;
+//public static final int Pg_CAH_SHMEM_OFFSET = 0x00000200;
+//public static final int Pg_CAH_SRCE_OFFSET = 0x00000800;
+//public static final int Pg_CAH_SRCE_SIZE = 0x00001000;
+//public static final int Pg_CAH_SRCE_TAG = 0x00000400;
+//public static final int Pg_CENTER_BASED = (0x00 << 8);
+//public static final int Pg_CHROMA_DEST_KEY = 0x00000001;
+//public static final int Pg_CHROMA_DEST_MATCH = 1;
+//public static final int Pg_CHROMA_DRAW = 0;
+//public static final int Pg_CHROMA_NODRAW = 2;
+//public static final int Pg_CHROMA_NOT_DST_KEY = 0x00000003;
+//public static final int Pg_CHROMA_NOT_SRC_KEY = 0x00000002;
+//public static final int Pg_CHROMA_SRC_KEY = 0x00000000;
+//public static final int Pg_CHROMA_SRC_MATCH = 0;
+//public static final int Pg_CLIPTEST_CURSOR_HIDE = 0x0020;
+ public static final int Pg_CLOSED = (0x10 << 8);
+//public static final int Pg_CMD_CAH_COUNT_1 = 0x00010000;
+//public static final int Pg_CMD_CAH_COUNT_2 = 0x00020000;
+//public static final int Pg_CMD_CAH_COUNT_3 = 0x00030000;
+//public static final int Pg_CMD_CAH_COUNT_MASK = 0x00030000;
+//public static final int Pg_CMD_CAH_COUNT_UNIT = 0x00010000;
+//public static final int Pg_CMD_CMD_SIZE_MASK = 0xFFFC0000;
+ public static final int Pg_TRANSPARENT = 0xFFFFFFFF;
+//public static final int Pg_INVERT_COLOR = 0xFFFFFFFE;
+//public static final int Pg_CURSOR_SHOW = 0x0080;
+//public static final int Pg_DASH_INVERT = 0x40;
+//public static final int Pg_DASH_SLOPE_ADJ = 0x80;
+//public static final int Pg_DELETE_CURSOR = 0x80;
+//public static final int Pg_DLL_CMDS = 0xD0;
+//public static final int Pg_DO_EXTENT = 0x0002;
+//public static final int Pg_DOUBLE_UNDERLINE = 0x10;
+//public static final int Pg_DRAWMODE_AND = 2;
+//public static final int Pg_DRAWMODE_ANDINV = 6;
+//public static final int Pg_DRAWMODE_ANDREV = 0xA;
+//public static final int Pg_DRAWMODE_CLEAR = 8;
+//public static final int Pg_DRAWMODE_COPYINV = 4;
+//public static final int Pg_DRAWMODE_INVERT = 0xD;
+//public static final int Pg_DRAWMODE_NAND = 0xF;
+//public static final int Pg_DRAWMODE_NOP = 9;
+//public static final int Pg_DRAWMODE_NOR = 0xE;
+ public static final int Pg_DRAWMODE_OPAQUE = 0;
+//public static final int Pg_DRAWMODE_OR = 3;
+//public static final int Pg_DRAWMODE_ORINV = 7;
+//public static final int Pg_DRAWMODE_ORREV = 0xB;
+//public static final int Pg_DRAWMODE_SET = 0xC;
+//public static final int Pg_DRAWMODE_XNOR = 5;
+ public static final int Pg_DRAWMODE_XOR = 1;
+//public static final int Pg_ENABLE_CHROMA = 0x00000004;
+//public static final int Pg_END_OF_DRAW = 0x00;
+//public static final int Pg_ENDIAN_TEST = 0xD5;
+//public static final int Pg_EXPOSE_SOURCE = (0x02 << 8);
+ public static final int Pg_EXTENT_BASED = (0x01 << 8);
+//public static final int Pg_GHOST = 0x01000000;
+ public static final int Pg_IMAGE_PALETTE_BYTE = 0x10;
+//public static final int Pg_IMAGE_BYTE_PALETTE = Pg_IMAGE_PALETTE_BYTE;
+//public static final int Pg_IMAGE_CLASS_BLEND = 0x08;
+ public static final int Pg_IMAGE_CLASS_DIRECT = 0x20;
+//public static final int Pg_IMAGE_CLASS_GRADIENT = 0x18;
+ public static final int Pg_IMAGE_CLASS_MASK = 0x38;
+ public static final int Pg_IMAGE_CLASS_PALETTE = 0x10;
+//public static final int Pg_IMAGE_DBLEND_LONG = 0x0B;
+//public static final int Pg_IMAGE_DBLEND_SHORT = 0x0A;
+ public static final int Pg_IMAGE_DIRECT_444 = 0x24;
+ public static final int Pg_IMAGE_DIRECT_555 = 0x23;
+ public static final int Pg_IMAGE_DIRECT_565 = 0x22;
+ public static final int Pg_IMAGE_DIRECT_888 = 0x21;
+ public static final int Pg_IMAGE_DIRECT_8888 = 0x20;
+//public static final int Pg_IMAGE_GBLEND_BYTE = 0x08;
+//public static final int Pg_IMAGE_GBLEND_NIBBLE = 0x09;
+//public static final int Pg_IMAGE_GRADIENT_BYTE = 0x18;
+//public static final int Pg_IMAGE_GRADIENT_NIBBLE = 0x19;
+ public static final int Pg_IMAGE_PALETTE_NIBBLE = 0x11;
+//public static final int Pg_IMAGE_NIBBLE_PALETTE = Pg_IMAGE_PALETTE_NIBBLE;
+//public static final int Pg_ITEST_CURSOR_HIDE = 0x0010;
+//public static final int Pg_MITER_JOIN = 0x00;
+//public static final int Pg_MOVE_DISPLAY = 0x4D;
+//public static final int Pg_OVRFN_EQ = 5;
+//public static final int Pg_OVRFN_FALSE = 0;
+//public static final int Pg_OVRFN_GE = 2;
+//public static final int Pg_OVRFN_GT = 7;
+//public static final int Pg_OVRFN_LE = 6;
+//public static final int Pg_OVRFN_LT = 3;
+//public static final int Pg_OVRFN_NE = 4;
+//public static final int Pg_OVRFN_TRUE = 1;
+//public static final int Pg_PALSET_FORCE_EXPOSE = 0x80;
+//public static final int Pg_PALSET_GLOBAL = 0x03;
+//public static final int Pg_PALSET_HARD = 0x01;
+//public static final int Pg_PALSET_HARDINACTIVE = 0x05;
+//public static final int Pg_PALSET_HARDLOCKED = 0x02;
+ public static final int Pg_PALSET_SOFT = 0x00;
+//public static final int Pg_PALSET_TYPEMASK = 0x0F;
+//public static final int Pg_POINT_CAP = 0x03;
+//public static final int Pg_RELATIVE = (0x01 << 8);
+//public static final int Pg_REPBM_ALTERNATE = (0x10 <<16);
+//public static final int Pg_POLY_FILL = Pg_DRAW_FILL;
+//public static final int Pg_POLY_RELATIVE = Pg_RELATIVE;
+//public static final int Pg_POLY_STROKE = Pg_DRAW_STROKE;
+//public static final int Pg_POLY_STROKE_CLOSED = Pg_DRAW_STROKE | Pg_CLOSED;
+//public static final int Pg_PRINTER_CMD = 0xF1;
+//public static final int Pg_QROUND_JOIN = 0x03;
+//public static final int Pg_REL_POLY_FILL = (Pg_POLY_FILL | Pg_POLY_RELATIVE);
+//public static final int Pg_REL_POLY_STROKE = (Pg_POLY_STROKE | Pg_POLY_RELATIVE);
+//public static final int Pg_REL_POLY_STROKE_CLOSED = (Pg_POLY_STROKE_CLOSED | Pg_POLY_RELATIVE);
+//public static final int Pg_ROUND_CAP = 0x01;
+//public static final int Pg_ROUND_JOIN = 0x01;
+//public static final int Pg_SET = 1;
+//public static final int Pg_SET_AUX_CLIP = 0x07;
+//public static final int Pg_SET_CURSOR_BITMAP = 0x83;
+//public static final int Pg_SET_CURSOR_CHAR = 0x82;
+//public static final int Pg_SET_CURSOR_POSITION = 0x81;
+//public static final int Pg_SET_DEFAULT_STATE = 0x01;
+//public static final int Pg_SET_DRAG_CURSOR = 0x84;
+//public static final int Pg_SET_DRAW_MODE = 0x02;
+//public static final int Pg_SET_FILL_COLOR = 0x20;
+//public static final int Pg_SET_FILL_DITHER = 0x22;
+//public static final int Pg_SET_FILL_TRANSP = 0x23;
+//public static final int Pg_SET_FILL_XOR_COLOR = 0x21;
+//public static final int Pg_SET_PALETTE = 0x08;
+//public static final int Pg_SET_PLANE_MASK = 0x03;
+//public static final int Pg_SET_ROTATION = 0x0B;
+//public static final int Pg_SET_SCALE = 0x0A;
+//public static final int Pg_SET_STROKE_CAP = 0x15;
+//public static final int Pg_SET_STROKE_COLOR = 0x10;
+//public static final int Pg_SET_STROKE_DASH = 0x17;
+//public static final int Pg_SET_STROKE_DITHER = 0x12;
+//public static final int Pg_SET_STROKE_JOIN = 0x16;
+//public static final int Pg_SET_STROKE_TRANSP = 0x13;
+//public static final int Pg_SET_STROKE_WIDTH = 0x14;
+//public static final int Pg_SET_STROKE_XOR_COLOR = 0x11;
+//public static final int Pg_SET_TEXT_COLOR = 0x30;
+//public static final int Pg_SET_TEXT_DITHER = 0x32;
+//public static final int Pg_SET_TEXT_FONT = 0x34;
+//public static final int Pg_SET_TEXT_TRANSP = 0x33;
+//public static final int Pg_SET_TEXT_UNDERLINE = 0x35;
+//public static final int Pg_SET_TEXT_XOR_COLOR = 0x31;
+//public static final int Pg_SET_TRANSLATION = 0x09;
+//public static final int Pg_SET_USER_CLIP = 0x06;
+//public static final int Pg_SETGAMMA_CBlack = 0x0004;
+//public static final int Pg_SETGAMMA_CFactor = 0x0002;
+//public static final int Pg_SETGAMMA_CWhite = 0x0008;
+//public static final int Pg_SETGAMMA_Factor = 0x0001;
+//public static final int Pg_SMART_BLIT = (0x01 << 8);
+//public static final int Pg_SQUARE_CAP = 0x02;
+//public static final int Pg_STRETCH_BLT = 0x00000008;
+//public static final int Pg_SWAP_DISPLAY = 0xD4;
+//public static final int Pg_SYNC = 0xD3;
+//public static final int Pg_TARGET_STREAM = 0xD1;
+//public static final int Pg_TEST_BITMAP = 2;
+//public static final int Pg_TEST_FILL = (Pg_DRAW_FILL);
+//public static final int Pg_TEST_FILL_STROKE = (Pg_DRAW_FILL | Pg_DRAW_STROKE);
+//public static final int Pg_TEST_STROKE = (Pg_DRAW_STROKE);
+//public static final int Pg_TEST_TEXT = 1;
+//public static final int Pg_TEXT_AREA = (0x08 << 8);
+//public static final int Pg_TEXT_BOTTOM = (0x80 << 8);
+ public static final int Pg_TEXT_LEFT = (0x10 << 8);
+//public static final int Pg_TEXT_RIGHT = (0x20 << 8);
+ public static final int Pg_TEXT_TOP = (0x40 << 8);
+//public static final int Pg_TEXT_CENTER = ( Pg_TEXT_LEFT | Pg_TEXT_RIGHT );
+//public static final int Pg_TEXT_MIDDLE = ( Pg_TEXT_TOP | Pg_TEXT_BOTTOM );
+//public static final int Pg_TEXT_SIZE_HINT = (0x02 << 8);
+ public static final int Pg_TEXT_UTF2CHAR = (0x04 << 8);
+ public static final int Pg_TEXT_WIDECHAR = (Pg_TEXT_UTF2CHAR);
+//public static final int Pg_TREND_HORIZ = 0x00;
+//public static final int Pg_TREND_VERT = 0x01;
+//public static final int Pg_UNSET = 0;
+//public static final int Pg_WAIT_VSYNC = 0x00000010;
+//public static final int Pg_XADDR_INLINE = 1;
+//public static final int Pg_XADDR_SHMEM = 0;
+//public static final int Pgrs_RelBehind = 0x0002;
+//public static final int Pgrs_RelInFront = 0x0001;
+//public static final int Pgrs_RelParent = 0x0000;
+//public static final int PgrsI_CreatedShmem = 0x0001;
+//public static final int Pgv_C_ByteFlag = 0x00000800;
+//public static final int Pgv_C_ByteIndex = 0x00000600;
+//public static final int Pgv_C_Direct = 0x00000400;
+//public static final int Pgv_C_DStrokePen = 0x00000200;
+//public static final int Pgv_C_MASK = 0x00000E00;
+//public static final int Pgv_C_StrokePen = 0x00000000;
+//public static final int Pgv_O_FixedLine = 0x00000000;
+//public static final int Pgv_O_MASK = 0x03000000;
+//public static final int Pgv_O_Variable = 0x01000000;
+//public static final int Pgv_OP_Glyph = 0x80;
+//public static final int Pgv_OP_Line = 0x01;
+//public static final int Pgv_OP_NOP = 0x00;
+//public static final int Pgv_OP_Point = 0x02;
+//public static final int Pgv_P_Color = 0x00200000;
+//public static final int Pgv_P_MASK = 0x00F00000;
+//public static final int Pgv_P_Simple = 0x00100000;
+//public static final int Pgv_T_MASK = 0x00003000;
+//public static final int Pgv_T_PostTrans = 0x00002000;
+//public static final int Pgv_T_PreTrans = 0x00001000;
+//public static final int Pgv_T_ZTrans = 0x00004000;
+//public static final int Pgv_X_Char = 0x00000002;
+//public static final int Pgv_X_LFixed = 0x00000004;
+//public static final int Pgv_X_MASK = 0x00000007;
+//public static final int Pgv_X_Short = 0x00000003;
+//public static final int Pgv_X_UseDelta = 0x00000001;
+//public static final int Pgv_Y_Char = (Pgv_X_Char << 3);
+//public static final int Pgv_Y_LFixed = (Pgv_X_LFixed << 3);
+//public static final int Pgv_Y_MASK = (Pgv_X_MASK << 3);
+//public static final int Pgv_Y_Short = (Pgv_X_Short << 3);
+//public static final int Pgv_Y_UseDelta = (Pgv_X_UseDelta << 3);
+//public static final int Pgv_Z_Char = (Pgv_X_Char << 6);
+//public static final int Pgv_Z_LFixed = (Pgv_X_LFixed << 6);
+//public static final int Pgv_Z_MASK = (Pgv_X_MASK << 6);
+//public static final int Pgv_Z_Short = (Pgv_X_Short << 6);
+//public static final int Pgv_Z_UseDelta = (Pgv_X_UseDelta << 6);
+//public static final int Ph_ACTIVATE_DC = 0;
+//public static final int Ph_AUDIO_REGION = 0x00000100;
+//public static final int Ph_AUXPTR_REGION = 0x00000080;
+//public static final int Ph_BACK_EVENT = 0x0002;
+//public static final int Ph_BAUD_CONSOLE = 100000000;
+//public static final int Ph_BAUD_NETWORK = 10000000;
+//public static final int Ph_BAUD_SLOW = 100000;
+//public static final int Ph_BLIT_REGION = 0x00008000;
+//public static final int Ph_BLOCK_OVERFLOW = 0x00000001;
+ public static final int Ph_BUTTON_ADJUST = 0x0002;
+ public static final int Ph_BUTTON_MENU = 0x0001;
+ public static final int Ph_BUTTON_SELECT = 0x0004;
+// public static final int Ph_BUTTON_1 = Ph_BUTTON_MENU;
+// public static final int Ph_BUTTON_2 = Ph_BUTTON_ADJUST;
+// public static final int Ph_BUTTON_3 = Ph_BUTTON_SELECT;
+//public static final int Ph_CAPTURE_EXPOSE = 4;
+//public static final int Ph_CLIPBOARD_MAX_TYPES = 5;
+//public static final int Ph_COMPOUND_REPLY = 0x00000020;
+//public static final int Ph_CURSOR_BACK = 2;
+//public static final int Ph_CURSOR_BIG_POINTER = 0xE902;
+ 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_DONT = 0xE90A;
+//public static final int Ph_CURSOR_DRAG_BACKDIAG = 0xE914;
+ public static final int Ph_CURSOR_DRAG_BL = 0xE916;
+ public static final int Ph_CURSOR_DRAG_BOTTOM = 0xE910;
+ public static final int Ph_CURSOR_DRAG_BR = 0xE914;
+//public static final int Ph_CURSOR_DRAG_FOREDIAG = 0xE916;
+ public static final int Ph_CURSOR_DRAG_HORIZONTAL = 0xE912;
+ public static final int Ph_CURSOR_DRAG_LEFT = 0xE912;
+ public static final int Ph_CURSOR_DRAG_RIGHT = 0xE912;
+ public static final int Ph_CURSOR_DRAG_TL = 0xE914;
+ public static final int Ph_CURSOR_DRAG_TOP = 0xE910;
+ public static final int Ph_CURSOR_DRAG_TR = 0xE916;
+ public static final int Ph_CURSOR_DRAG_VERTICAL = 0xE910;
+ public static final int Ph_CURSOR_FINGER = 0xE90C;
+//public static final int Ph_CURSOR_FRONT = 1;
+ public static final int Ph_CURSOR_INHERIT = 0x00;
+ public static final int Ph_CURSOR_INSERT = 0xE90E;
+//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_NOINPUT = 0xE90A;
+//public static final int Ph_CURSOR_NONE = 0xFD;
+//public static final int Ph_CURSOR_PASTE = 0xE91E;
+ public static final int Ph_CURSOR_POINT_WAIT = 0xE918;
+ public static final int Ph_CURSOR_POINTER = 0xE900;
+ public static final int Ph_CURSOR_QUESTION_POINT = 0xE91C;
+//public static final int Ph_CURSOR_SET = 0x01000000;
+//public static final int Ph_CURSOR_WAIT = 0xE908;
+//public static final int Ph_DEACTIVATE_DC = 1;
+//public static final int Ph_DESTROYING_DC = 2;
+ public static final int Ph_DEV_RID = 1;
+//public static final int Ph_DIRECTED_FOCUS = 0x0004;
+//public static final int Ph_DONE_DRAW = 0x8000;
+//public static final int Ph_DRAG_ABSOLUTE = 0x0080;
+//public static final int Ph_DRAG_CURSOR_EXACT = 0x0400;
+//public static final int Ph_DRAG_DRAW_RECT = 0x0100;
+//public static final int Ph_DRAG_DRAW_RECT_INITIAL = 0x0200;
+ public static final int Ph_DRAG_KEY_MOTION = 0x0020;
+ public static final int Ph_DRAG_NOBUTTON = 0x0040;
+ public static final int Ph_DRAG_TRACK = 0x0010;
+//public static final int Ph_DRAW_TO_MEMORY_CONTEXT = 2;
+//public static final int Ph_DRAW_TO_PHOTON = 0;
+//public static final int Ph_DRAW_TO_PRINT_CONTEXT = 1;
+//public static final int Ph_DRAW_TO_SERVICE = 3;
+//public static final int Ph_DYNAMIC_BUFFER = 0x00000010;
+//public static final int Ph_EMIT_TOWARD = 0x0001;
+//public static final int Ph_ESCAPE_COUNT_MASK = 0x000F;
+//public static final int Ph_EV_ADMIN_FILE_SENT = 1;
+//public static final int Ph_EV_ADMIN_SEND_FILE = 0;
+//public static final int Ph_EV_AMIN = 0x00000100;
+//public static final int Ph_EV_AUDIO = 0x00100000;
+//public static final int Ph_EV_BLIT = 0x00000800;
+ public static final int Ph_EV_BOUNDARY = 0x00000020;
+ public static final int Ph_EV_BUT_PRESS = 0x00000002;
+ public static final int Ph_EV_BUT_RELEASE = 0x00000004;
+//public static final int Ph_EV_BUT_REPEAT = 0x00004000;
+//public static final int Ph_EV_CONFIG = 3;
+//public static final int Ph_EV_COVERED = 0x00000400;
+//public static final int Ph_EV_DND_ACK = 4;
+//public static final int Ph_EV_DND_CANCEL = 1;
+//public static final int Ph_EV_DND_COMPLETE = 7;
+//public static final int Ph_EV_DND_DELIVERED = 8;
+//public static final int Ph_EV_DND_DROP = 6;
+//public static final int Ph_EV_DND_ENTER = 2;
+//public static final int Ph_EV_DND_INIT = 0;
+//public static final int Ph_EV_DND_LEAVE = 3;
+//public static final int Ph_EV_DND_MOTION = 5;
+//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_INIT = 0;
+//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;
+//public static final int Ph_EV_DRAW = 0x00000080;
+//public static final int Ph_EV_EXPOSE = 0x00000040;
+//public static final int Ph_EV_FEP = 4;
+//public static final int Ph_EV_INFO = 0x00080000;
+//public static final int Ph_EV_INVALIDATE_FONTINFO = 1;
+//public static final int Ph_EV_INVALIDATE_SYSINFO = 0;
+ public static final int Ph_EV_KEY = 0x00000001;
+//public static final int Ph_EV_KEY_NORMAL = 0;
+//public static final int Ph_EV_KEYBOARD_CTRL = 3;
+//public static final int Ph_EV_LB_SYSTEM = 0x00020000;
+//public static final int Ph_EV_MOTION_NORMAL = 0;
+//public static final int Ph_EV_MOTION_STEADY = 1;
+//public static final int Ph_EV_NEW_TIMEZONE = 2;
+//public static final int Ph_EV_POINTER_CTRL = 2;
+//public static final int Ph_EV_PRINTER = 5;
+ public static final int Ph_EV_PTR_ENTER = 0;
+ public static final int Ph_EV_PTR_ENTER_FROM_CHILD = 4;
+//public static final int Ph_EV_PTR_ENTER_FROM_PARENT = 0;
+ public static final int Ph_EV_PTR_LEAVE = 1;
+ public static final int Ph_EV_PTR_LEAVE_TO_CHILD = 5;
+//public static final int Ph_EV_PTR_LEAVE_TO_PARENT = 1;
+ public static final int Ph_EV_PTR_MOTION_BUTTON = 0x00000010;
+ 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_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_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;
+//public static final int Ph_EV_RAW_AUXPTR = 2;
+//public static final int Ph_EV_RAW_KEY = 0;
+//public static final int Ph_EV_RAW_PTR = 1;
+//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_REMOTE_WM = 1;
+//public static final int Ph_EV_SERVICE = 0x00040000;
+//public static final int Ph_EV_SYSTEM = 0x00001000;
+ public static final int Ph_EV_TIMER = 0x00010000;
+//public static final int Ph_EV_WIDGET_SENSE = ( Ph_EV_KEY | Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE | Ph_EV_DRAG | Ph_EV_BOUNDARY );
+//public static final int Ph_EV_WIDGET_OPAQUE = ( Ph_EV_WIDGET_SENSE | Ph_EV_PTR_ALL | Ph_EV_KEY );
+//public static final int Ph_EV_WIN_SENSE = ( Ph_EV_KEY | Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE | Ph_EV_EXPOSE | Ph_EV_DRAG | Ph_EV_TIMER );
+//public static final int Ph_EV_WIN_OPAQUE = ( Ph_EV_WIN_SENSE | Ph_EV_PTR_ALL | Ph_EV_BOUNDARY | Ph_EV_DRAW | Ph_EV_COVERED | Ph_EV_KEY | Ph_EV_BUT_REPEAT );
+//public static final int Ph_EV_WM = 0x00002000;
+//public static final int _Ph_REGION_OPEN = 0;
+//public static final int _Ph_REGION_SET = 1;
+//public static final int _Ph_REGION_CLOSE = 2;
+//public static final int _Ph_REGION_WM_BASE = 8;
+//public static final int Ph_EV_WM_CLOSE = _Ph_REGION_CLOSE;
+//public static final int Ph_EV_WM_CONFIG = (_Ph_REGION_WM_BASE+3);
+//public static final int Ph_EV_WM_CONSWITCH = (_Ph_REGION_WM_BASE+5);
+//public static final int Ph_EV_WM_EVENT = (_Ph_REGION_WM_BASE+0);
+//public static final int Ph_EV_WM_MENUREAD = (_Ph_REGION_WM_BASE+6);
+//public static final int Ph_EV_WM_OPEN = _Ph_REGION_OPEN;
+//public static final int Ph_EV_WM_SET = _Ph_REGION_SET;
+//public static final int Ph_EV_WM_TASKEVENT = (_Ph_REGION_WM_BASE+4);
+//public static final int Ph_EV_WM_TRANSPORT = (_Ph_REGION_WM_BASE+2);
+//public static final int Ph_EV_WM_VISIBLE = (_Ph_REGION_WM_BASE+1);
+//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_INCLUSIVE = 0x0008;
+ public static final int Ph_EVENT_MSG = 1;
+//public static final int Ph_EVENT_NO_RECT = 0x0002;
+//public static final int Ph_EVENT_REDIRECTED = 0x0020;
+//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_FEP_ACTIVATE = 0x00000003;
+//public static final int Ph_FEP_BROADCAST = 0x00000000;
+//public static final int Ph_FEP_CHINESE = 0x00000002;
+//public static final int Ph_FEP_DEACTIVATE = 0x00000004;
+//public static final int Ph_FEP_DEREGISTER = 1;
+//public static final int Ph_FEP_JAPANESE = 0x00000001;
+//public static final int Ph_FEP_KOREAN = 0x00000003;
+//public static final int Ph_FEP_NORECT = 0x00000002;
+//public static final int Ph_FEP_RECT = 0x00000001;
+//public static final int Ph_FEP_REGISTER = 0;
+//public static final int Ph_FOCUS_BRANCH = 0x0008;
+//public static final int Ph_FOLLOW_IG_SIZE = 0x00200000;
+//public static final int Ph_FORCE_BOUNDARY = 0x00400000;
+//public static final int Ph_FORCE_FRONT = 0x00100000;
+//public static final int Ph_GCAP_BLIT = 0x00000001;
+//public static final int Ph_GCAP_DIRECTCOLOR = 0x00000100;
+//public static final int Ph_GCAP_DRAW_OFFSCREEN = 0x00004000;
+//public static final int Ph_GCAP_FRAME_READ = 0x00001000;
+//public static final int Ph_GCAP_FutureSupported = 0xFF000000;
+//public static final int Ph_GCAP_LOCALHW = 0x00000040;
+//public static final int Ph_GCAP_MASKED_BLIT = 0x00000002;
+//public static final int Ph_GCAP_NONINTERLACED = 0x00000400;
+//public static final int Ph_GCAP_PALETTE = 0x00000008;
+//public static final int Ph_GCAP_PHINDOWS = 0x00000020;
+//public static final int Ph_GCAP_RELAY = 0x00000010;
+//public static final int Ph_GCAP_SHMEM = 0x00000004;
+//public static final int Ph_GCAP_SHMEM_FLUSH = 0x00002000;
+//public static final int Ph_GCAP_TEXT_AREA = 0x00000800;
+//public static final int Ph_GCAP_VIDEO_READABLE = 0x00000200;
+//public static final int Ph_GEN_INFO_BANDWIDTH = 0x000000001;
+//public static final int Ph_GEN_INFO_CAPABILITIES = 0x000000002;
+//public static final int Ph_GEN_INFO_NUM_GFX = 0x000000004;
+//public static final int Ph_GEN_INFO_NUM_IG = 0x000000020;
+//public static final int Ph_GEN_INFO_NUM_KBD = 0x000000008;
+//public static final int Ph_GEN_INFO_NUM_PTR = 0x000000010;
+//public static final int Ph_GFX_BANDWIDTH = 0x00000001;
+//public static final int Ph_GFX_CAPABILITIES = 0x00000002;
+//public static final int Ph_GFX_COLOR_BITS = 0x00000004;
+//public static final int Ph_GFX_POSSIBILITIES = 0x00000008;
+//public static final int Ph_GFXD_DITHERSTROKE = 0x00000008;
+//public static final int Ph_GFXD_HARDROT = 0x00000002;
+//public static final int Ph_GFXD_SCALEING = 0x00000004;
+//public static final int Ph_GFXD_VPANNING = 0x00000001;
+//public static final int Ph_GFXG_DMANDOR = 0x00000020;
+//public static final int Ph_GFXG_DMEXTENDED = 0x00000040;
+//public static final int Ph_GFXG_DMXOR = 0x00000010;
+//public static final int Ph_GFXG_HWBITBLT = 0x00000002;
+//public static final int Ph_GFXG_HWBITBLT_CHROMA = 0x00000080;
+//public static final int Ph_GFXG_HWBITBLT_STRETCH = 0x00000100;
+//public static final int Ph_GFXG_HWCURSOR = 0x00000001;
+//public static final int Ph_GFXG_MASKBLIT = 0x00000004;
+//public static final int Ph_GFXG_OFFSCREENMEM = 0x00000008;
+//public static final int Ph_GFXV_DIRECT = 0x00000010;
+//public static final int Ph_GFXV_MONOCHROME = 0x00000001;
+//public static final int Ph_GFXV_NONINTERLACED = 0x00002000;
+//public static final int Ph_GFXV_OVERLAY = 0x00000020;
+//public static final int Ph_GFXV_PALETTE16 = 0x00000002;
+//public static final int Ph_GFXV_PALETTE256 = 0x00000004;
+//public static final int Ph_GFXV_VIDEO_READABLE = 0x00001000;
+//public static final int Ph_GFXVAL_BITPOS = 0x00400000;
+//public static final int Ph_GFXVAL_BPL = 0x00100000;
+//public static final int Ph_GFXVAL_BPP = 0x00200000;
+//public static final int Ph_GFXVAL_CARDSUBTYPE = 0x00000020;
+//public static final int Ph_GFXVAL_CARDTYPE = 0x00000010;
+//public static final int Ph_GFXVAL_COPT = 0x00000008;
+//public static final int Ph_GFXVAL_DACSIZE = 0x00800000;
+//public static final int Ph_GFXVAL_DOPT = 0x00000002;
+//public static final int Ph_GFXVAL_GOPT = 0x00000004;
+//public static final int Ph_GFXVAL_NCURSOR = 0x00001000;
+//public static final int Ph_GFXVAL_NPALETTE = 0x00002000;
+//public static final int Ph_GFXVAL_POINTBS = 0x00004000;
+//public static final int Ph_GFXVAL_PRES = 0x00000100;
+//public static final int Ph_GFXVAL_VOPT = 0x00000001;
+//public static final int Ph_GFXVAL_VRAMSIZE = 0x00000800;
+//public static final int Ph_GFXVAL_VRES = 0x00000200;
+//public static final int Ph_GFXVAL_WORKSPACES = 0x00008000;
+//public static final int Ph_GRAFX_REGION = 0x00000004;
+//public static final int Ph_GRAPHIC_EXPOSE = 2;
+//public static final int Ph_INFO_CTRL_BUF_GC = 6;
+//public static final int Ph_INFO_CTRL_DFLT_GC = 5;
+//public static final int Ph_INFO_CTRL_FD = 0;
+//public static final int Ph_INFO_CTRL_GC = 4;
+//public static final int Ph_INFO_CTRL_GIN = 3;
+//public static final int Ph_INFO_CTRL_PROXY = 1;
+//public static final int Ph_INFO_CTRL_REM_PROXY = 2;
+//public static final int Ph_INLINE_SHMEM_OBJECTS = 0x00000001;
+//public static final int Ph_INPUTGROUP_REGION = 0x00000040;
+//public static final int Ph_KBD_CAPABILITIES = 0x00000001;
+//public static final int Ph_KBD_REGION = 0x00000010;
+//public static final int Ph_LIB_VERSION = 114;
+//public static final int Ph_MAX_FONT_LEN = 16;
+//public static final int Ph_NO_COMPRESSION = 0x00800000;
+//public static final int Ph_NO_HOLD = 0x00000008;
+//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_HOTKEY = 0x20;
+//public static final int Ph_PRINT_REGION = 0x00000020;
+//public static final int Ph_PRINTER_EXPOSE = 1;
+//public static final int Ph_PROC_ARMED = 0x0002;
+//public static final int Ph_PROC_BLOCKED = 0x0004;
+//public static final int Ph_PROC_CATCH_UP = 0x0010;
+//public static final int Ph_PROC_DYNAMIC_BUF = 0x0020;
+//public static final int Ph_PROC_HELD = 0x0008;
+//public static final int Ph_PROC_VIRTUAL = 0x0001;
+//public static final int Ph_PTR_CAPABILITIES = 0x00000001;
+//public static final int Ph_PTR_FLAG_PROG = 0x04;
+//public static final int Ph_PTR_FLAG_Z_ABS = 0x02;
+//public static final int Ph_PTR_FLAG_Z_MASK = 0x03;
+//public static final int Ph_PTR_FLAG_Z_NONE = 0x00;
+//public static final int Ph_PTR_FLAG_Z_PRESSURE = 0x03;
+//public static final int Ph_PTR_FLAG_Z_REL = 0x01;
+//public static final int Ph_PTR_RAW_FLAG_NO_BUTTONS = 0x01;
+//public static final int Ph_PTR_RAW_FLAG_XY_REL = 0x02;
+//public static final int Ph_PTR_REGION = 0x00000008;
+//public static final int Ph_QUERY_DC_GRAFX_INFO = 0x80000000;
+//public static final int Ph_QUERY_EXACT = 0x0100;
+ public static final int Ph_QUERY_GRAPHICS = 0x0004;
+//public static final int Ph_QUERY_IG_POINTER = 0x1000;
+//public static final int Ph_QUERY_IG_REGION = 0x2000;
+//public static final int Ph_QUERY_INPUT_GROUP = 0x0040;
+//public static final int Ph_QUERY_MEMORY_GRAFX_INFO = 0x80000000;
+//public static final int Ph_RDATA_CLIPBOARD = 0x000A;
+//public static final int Ph_RDATA_CURSOR = 0x0002;
+//public static final int Ph_RDATA_GFXDETAIL = 0x0008;
+//public static final int Ph_RDATA_GFXINFO = 0x0004;
+//public static final int Ph_RDATA_IG = 0x0003;
+//public static final int Ph_RDATA_INPMGRINFO = 0x0009;
+//public static final int Ph_RDATA_KBDINFO = 0x0005;
+//public static final int Ph_RDATA_PTRINFO = 0x0006;
+//public static final int Ph_RDATA_USER = 0xFFFF;
+//public static final int Ph_RDATA_WINDOW = 0x0001;
+//public static final int Ph_RDATA_WMCONFIG = 0x0007;
+//public static final int Ph_RECT_BOUNDARY = 0x02000000;
+//public static final int Ph_REGION_BEHIND = 0x00000200;
+//public static final int Ph_REGION_CURSOR = 0x00001000;
+//public static final int Ph_REGION_DATA = 0x00000800;
+//public static final int Ph_REGION_EV_OPAQUE = 0x00000008;
+//public static final int Ph_REGION_EV_OPAQUE_AND = 0x00010000;
+//public static final int Ph_REGION_EV_OPAQUE_OR = 0x00040000;
+//public static final int Ph_REGION_EV_OPAQUE_SET = 0x00000008;
+//public static final int Ph_REGION_EV_SENSE = 0x00000010;
+//public static final int Ph_REGION_EV_SENSE_AND = 0x00020000;
+//public static final int Ph_REGION_EV_SENSE_OR = 0x00080000;
+//public static final int Ph_REGION_EV_SENSE_SET = 0x00000010;
+//public static final int Ph_REGION_FLAGS = 0x00000004;
+//public static final int Ph_REGION_HANDLE = 0x00000002;
+//public static final int Ph_REGION_IN_FRONT = 0x00000100;
+//public static final int Ph_REGION_INPUT_GROUP = 0x00008000;
+//public static final int Ph_REGION_ORIGIN = 0x00000040;
+//public static final int Ph_REGION_OWNER = 0x00000001;
+//public static final int Ph_REGION_PARENT = 0x00000080;
+//public static final int Ph_REGION_RECT = 0x00000400;
+//public static final int Ph_REGION_STATE = 0x00000020;
+//public static final int Ph_REGION_TYPE_MASK = 0x000FFFFF;
+//public static final int Ph_RELEASE_GHOST_BITMAP = 0x08;
+//public static final int Ph_RELEASE_IMAGE = 0x01;
+//public static final int Ph_RELEASE_IMAGE_ALL = 0x0F;
+//public static final int Ph_RELEASE_PALETTE = 0x02;
+//public static final int Ph_RELEASE_TRANSPARENCY_MASK = 0x04;
+ public static final int Ph_RESIZE_MSG = 3;
+//public static final int Ph_RIDQUERY_IG_POINTER = 0x1000;
+//public static final int Ph_RIDQUERY_TOWARD = 0x2000;
+//public static final int Ph_ROOT_RID = 0;
+//public static final int Ph_START_DRAW = 0x4000;
+//public static final int Ph_SUPRESS_PARENT_CLIP = 0x00000004;
+//public static final int Ph_SYNC_GCS = 0x00000008;
+//public static final int Ph_SYSTEM_CON_SWITCHABS = 0x0101;
+//public static final int Ph_SYSTEM_CON_SWITCHREL = 0x0102;
+//public static final int Ph_SYSTEM_GRAPHIC_ROTATE = 0x0201;
+//public static final int Ph_SYSTEM_GRAPHIC_ZOOM = 0x0202;
+//public static final int Ph_SYSTEM_MOUSE_ACCEL = 0x0342;
+//public static final int Ph_SYSTEM_MOUSE_DCLICK = 0x0341;
+//public static final int Ph_SYSTEM_NEWMANAGER = 0x0002;
+//public static final int Ph_SYSTEM_PTR_REGION_CHANGE = 0x0301;
+//public static final int Ph_SYSTEM_REGION_CHANGE = 0x0004;
+//public static final int Ph_SYSTEM_ROTATE = 0x0003;
+//public static final int Ph_SYSTEM_SHUTDOWN = 0x0001;
+//public static final int Ph_TEXT_EXTENTS = 0x00000002;
+ public static final int Ph_TRACK_BOTTOM = 0x0008;
+ public static final int Ph_TRACK_LEFT = 0x0001;
+ public static final int Ph_TRACK_RIGHT = 0x0002;
+ public static final int Ph_TRACK_TOP = 0x0004;
+ public static final int Ph_TRACK_DRAG = (Ph_TRACK_LEFT|Ph_TRACK_RIGHT|Ph_TRACK_TOP|Ph_TRACK_BOTTOM);
+//public static final int Ph_TYPE_SPECIFIC = 0x0FF0;
+//public static final int Ph_USER_RSRVD_BITS = 0xF000;
+//public static final int Ph_WINDOW_REGION = 0x00000001;
+//public static final int Ph_WM_ALL_FLAGS = 0x00003F3D;
+//
+//public static final int Ph_WM_BACKDROP = 0x00001000;
+ public static final int Ph_WM_CLOSE = 0x00000001;
+//public static final int Ph_WM_CONSWITCH = 0x00000080;
+//public static final int Ph_WM_EVSTATE_DEICONIFY = 1;
+//public static final int Ph_WM_EVSTATE_FFRONT = 0;
+//public static final int Ph_WM_EVSTATE_FFRONT_DISABLE = 1;
+ public static final int Ph_WM_EVSTATE_FOCUS = 0;
+ public static final int Ph_WM_EVSTATE_FOCUSLOST = 1;
+ public static final int Ph_WM_EVSTATE_HIDE = 0;
+// public static final int Ph_WM_EVSTATE_ICONIFY = 0;
+//public static final int Ph_WM_EVSTATE_INVERSE = 1;
+//public static final int Ph_WM_EVSTATE_MENU = 0;
+//public static final int Ph_WM_EVSTATE_MENU_FINISH = 1;
+//public static final int Ph_WM_EVSTATE_PERFORM = 0;
+ public static final int Ph_WM_EVSTATE_UNHIDE = 1;
+//public static final int Ph_WM_FFRONT = 0x00010000;
+ public static final int Ph_WM_FOCUS = 0x00000004;
+ public static final int Ph_WM_HELP = 0x00002000;
+ public static final int Ph_WM_HIDE = 0x00000040;
+ public static final int Ph_WM_ICON = 0x00000400;
+ public static final int Ph_WM_MAX = 0x00000800;
+//public static final int Ph_WM_MENU = 0x00000008;
+ public static final int Ph_WM_MOVE = 0x00000200;
+//public static final int Ph_WM_RENDER_ASAPP = 0x00000000;
+//public static final int Ph_WM_RENDER_ASICON = 0x00000001;
+//public static final int Ph_WM_RENDER_ASMASK = 0x0000000F;
+ public static final int Ph_WM_RENDER_BORDER = 0x00000010;
+//public static final int Ph_WM_RENDER_CLOSE = 0x00000200;
+//public static final int Ph_WM_RENDER_HELP = 0x00000400;
+ public static final int Ph_WM_RENDER_MAX = 0x00002000;
+ public static final int Ph_WM_RENDER_MENU = 0x00000100;
+ public static final int Ph_WM_RENDER_MIN = 0x00001000;
+//public static final int Ph_WM_RENDER_MOVE = 0x00000040;
+ public static final int Ph_WM_RENDER_RESIZE = 0x00000020;
+//public static final int Ph_WM_RENDER_RETURN = 0x00008000;
+ public static final int Ph_WM_RENDER_TITLE = 0x00000080;
+ public static final int Ph_WM_RESIZE = 0x00000100;
+ public static final int Ph_WM_RESTORE = 0x00008000;
+//public static final int Ph_WM_SET_CHILD_COUNT = 0x0200;
+//public static final int Ph_WM_SET_CONVERSE_LINK = 0x8000;
+//public static final int Ph_WM_SET_FLAGS = 0x0001;
+//public static final int Ph_WM_SET_FRAME_ATTRIB = 0x0400;
+//public static final int Ph_WM_SET_FRONT_WINDOW = 0x0800;
+//public static final int Ph_WM_SET_ICON_POS = 0x0040;
+//public static final int Ph_WM_SET_ICON_SIZE = 0x0020;
+//public static final int Ph_WM_SET_ICON_TITLE = 0x0010;
+//public static final int Ph_WM_SET_LINK = 0x0080;
+//public static final int Ph_WM_SET_RELATION = 0x0100;
+//public static final int Ph_WM_SET_RENDER = 0x0004;
+//public static final int Ph_WM_SET_STATE = 0x0002;
+//public static final int Ph_WM_SET_TITLE = 0x0008;
+//public static final int Ph_WM_STATE_ISALTKEY = 0x00000200;
+//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_ISHIDDEN = 0x00000001;
+//public static final int Ph_WM_STATE_ISICON = 0x00000080;
+ public static final int Ph_WM_STATE_ISICONIFIED = 0x00000040;
+//public static final int Ph_WM_STATE_ISMASK = 0x0000FFFF;
+ public static final int Ph_WM_STATE_ISMAX = 0x00000002;
+//public static final int Ph_WM_STATE_ISMAXING = 0x00004000;
+//public static final int Ph_WM_STATE_ISNORMAL = 0x00000000;
+//public static final int Ph_WM_STATE_ISPDM = 0x00000020;
+//public static final int Ph_WM_STATE_ISREMOTE = 0x00000400;
+//public static final int Ph_WM_STATE_ISTASKBAR = 0x00000010;
+//public static final int Ph_WM_SUPERSELECT = ~0;
+//public static final int Ph_WM_TASKBAR = 0x00004000;
+//public static final int Ph_WM_TERMINATE = 0x00000002;
+//public static final int Ph_WM_TOBACK = 0x00000020;
+//public static final int Ph_WM_TOFRONT = 0x00000010;
+//public static final int Ph_WND_MGR_REGION = 0x00000002;
+//public static final int PHF_STATS = 0x01;
+ public static final int PHFONT_ALL_FONTS = 0x33;
+ public static final int PHFONT_ALL_SYMBOLS = (-1);
+ public static final int PHFONT_BITMAP = 0x02;
+ public static final int PHFONT_FIXED = 0x20;
+ public static final int PHFONT_INFO_BLDITC = 0x08;
+ public static final int PHFONT_INFO_BOLD = 0x02;
+ public static final int PHFONT_INFO_FIXED = 0x10;
+ public static final int PHFONT_INFO_ITALIC = 0x04;
+ public static final int PHFONT_INFO_PLAIN = 0x01;
+ public static final int PHFONT_INFO_PROP = 0x20;
+//public static final int PHFONT_LOAD_IMAGES = 0x02;
+//public static final int PHFONT_LOAD_METRICS = 0x01;
+//public static final int PHFONT_MSG_ANTIALIAS = 12;
+//public static final int PHFONT_MSG_CEXTENT1 = 6;
+//public static final int PHFONT_MSG_CEXTENT2 = 14;
+//public static final int PHFONT_MSG_DYNAMIC_LOAD = 0x1000;
+//public static final int PHFONT_MSG_DYNAMIC_UNLOAD = 0x1001;
+//public static final int PHFONT_MSG_EXTENT = 5;
+//public static final int PHFONT_MSG_FEXTENT = 18;
+//public static final int PHFONT_MSG_FEXTENT_WIDE = 26;
+//public static final int PHFONT_MSG_FRENDER = 19;
+//public static final int PHFONT_MSG_FRENDER2 = 20;
+//public static final int PHFONT_MSG_FRENDER_WIDE = 25;
+//public static final int PHFONT_MSG_FRENDER_WIDE2 = 27;
+//public static final int PHFONT_MSG_GLYPH = 9;
+//public static final int PHFONT_MSG_LIST = 3;
+//public static final int PHFONT_MSG_LOAD = 2;
+//public static final int PHFONT_MSG_LOCAL1 = 10;
+//public static final int PHFONT_MSG_LOCAL2 = 11;
+//public static final int PHFONT_MSG_LOCAL2_V20 = 31;
+//public static final int PHFONT_MSG_QUERY = 4;
+//public static final int PHFONT_MSG_RENDER = 7;
+//public static final int PHFONT_MSG_RENDER2 = 13;
+//public static final int PHFONT_MSG_SHMEM = 8;
+//public static final int PHFONT_MSG_STAT_PFR = 29;
+//public static final int PHFONT_MSG_STAT_PHF = 28;
+//public static final int PHFONT_MSG_STAT_TTF = 30;
+//public static final int PHFONT_MSG_WEXTENT = 15;
+//public static final int PHFONT_MSG_WRENDER = 16;
+//public static final int PHFONT_MSG_WRENDER2 = 17;
+ public static final int PHFONT_PROP = 0x10;
+ public static final int PHFONT_SCALABLE = 0x01;
+//
+ public static final int Pk_KF_Key_Down = 0x00000001;
+ public static final int Pk_KF_Key_Repeat = 0x00000002;
+ public static final int Pk_KF_Scan_Valid = 0x00000020;
+ public static final int Pk_KF_Sym_Valid = 0x00000040;
+ public static final int Pk_KF_Cap_Valid = 0x00000080;
+//public static final int Pk_KF_Compose = 0x40000000;
+ public static final int Pk_KM_Shift = 0x00000001;
+ public static final int Pk_KM_Ctrl = 0x00000002;
+ public static final int Pk_KM_Alt = 0x00000004;
+//public static final int Pk_KM_AltGr = 0x00000008;
+//public static final int Pk_KM_Shl3 = 0x00000010;
+//
+//public static final int Pk_KM_Shift_Lock = 0x00000100;
+//public static final int Pk_KM_Ctrl_Lock = 0x00000200;
+//public static final int Pk_KM_Alt_Lock = 0x00000400;
+//public static final int Pk_KM_AltGr_Lock = 0x00000800;
+//
+//public static final int Pk_KM_Caps_Lock = 0x00010000;
+//public static final int Pk_KM_Num_Lock = 0x00020000;
+//public static final int Pk_KM_Scroll_Lock = 0x00040000;
+//
+//
+ public static final int Pk_BackSpace = 0xF008; /* back space, back char */
+ public static final int Pk_Tab = 0xF009;
+ public static final int Pk_Linefeed = 0xF00A; /* Linefeed, LF */
+ public static final int Pk_Clear = 0xF00B;
+ public static final int Pk_Return = 0xF00D; /* Return, enter */
+ public static final int Pk_Pause = 0xF013; /* Pause, hold */
+ public static final int Pk_Scroll_Lock = 0xF014;
+ public static final int Pk_Escape = 0xF01B;
+ public static final int Pk_Delete = 0xF0FF; /* Delete, rubout */
+//
+//public static final int Pk_Multi_key = 0xF020; /* Multi-key character compose */
+//
+//public static final int Pk_Kanji = 0xF021; /* Kanji, Kanji convert */
+//public static final int Pk_Muhenkan = 0xF022; /* Cancel Conversion */
+//public static final int Pk_Henkan_Mode = 0xF023; /* Start/Stop Conversion */
+//public static final int Pk_Henkan = 0xF023; /* Alias for Henkan_Mode */
+//public static final int Pk_Romaji = 0xF024; /* to Romaji */
+//public static final int Pk_Hiragana = 0xF025; /* to Hiragana */
+//public static final int Pk_Katakana = 0xF026; /* to Katakana */
+//public static final int Pk_Hiragana_Katakana = 0xF027; /* Hiragana/Katakana toggle */
+//public static final int Pk_Zenkaku = 0xF028; /* to Zenkaku */
+//public static final int Pk_Hankaku = 0xF029; /* to Hankaku */
+//public static final int Pk_Zenkaku_Hankaku = 0xF02A; /* Zenkaku/Hankaku toggle */
+//public static final int Pk_Touroku = 0xF02B; /* Add to Dictionary */
+//public static final int Pk_Massyo = 0xF02C; /* Delete from Dictionary */
+//public static final int Pk_Kana_Lock = 0xF02D; /* Kana Lock */
+//public static final int Pk_Kana_Shift = 0xF02E; /* Kana Shift */
+//public static final int Pk_Eisu_Shift = 0xF02F; /* Alphanumeric Shift */
+//public static final int Pk_Eisu_toggle = 0xF030; /* Alphanumeric toggle */
+//
+ public static final int Pk_Home = 0xF050;
+ public static final int Pk_Left = 0xF051; /* Move left, left arrow */
+ public static final int Pk_Up = 0xF052; /* Move up, up arrow */
+ public static final int Pk_Right = 0xF053; /* Move right, right arrow */
+ public static final int Pk_Down = 0xF054; /* Move down, down arrow */
+ public static final int Pk_Prior = 0xF055; /* Prior, previous */
+ public static final int Pk_Pg_Up = 0xF055; /* Prior, previous */
+ public static final int Pk_Next = 0xF056; /* Next */
+ public static final int Pk_Pg_Down = 0xF056; /* Next */
+ public static final int Pk_End = 0xF057; /* EOL */
+//public static final int Pk_Begin = 0xF058; /* BOL */
+//
+//public static final int Pk_Select = 0xF060; /* Select, mark */
+//public static final int Pk_Print = 0xF061;
+//public static final int Pk_Execute = 0xF062; /* Execute, run, do */
+ public static final int Pk_Insert = 0xF063; /* Insert, insert here */
+//public static final int Pk_Undo = 0xF065; /* Undo, oops */
+//public static final int Pk_Redo = 0xF066; /* redo, again */
+//public static final int Pk_Menu = 0xF067;
+//public static final int Pk_Find = 0xF068; /* Find, search */
+//public static final int Pk_Cancel = 0xF069; /* Cancel, stop, abort, exit */
+//public static final int Pk_Help = 0xF06A; /* Help, ? */
+//public static final int Pk_Break = 0xF06B;
+//public static final int Pk_Mode_switch = 0xF07E; /* Character set switch */
+//public static final int Pk_script_switch = 0xF07E; /* Alias for mode_switch */
+//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_Enter = 0xF08D; /* enter */
+//public static final int Pk_KP_F1 = 0xF091; /* PF1, KP_A, ... */
+//public static final int Pk_KP_F2 = 0xF092;
+//public static final int Pk_KP_F3 = 0xF093;
+//public static final int Pk_KP_F4 = 0xF094;
+//public static final int Pk_KP_Equal = 0xF0BD; /* equals */
+//public static final int Pk_KP_Multiply = 0xF0AA;
+//public static final int Pk_KP_Add = 0xF0AB;
+//public static final int Pk_KP_Separator = 0xF0AC; /* separator, often comma */
+//public static final int Pk_KP_Subtract = 0xF0AD;
+//public static final int Pk_KP_Decimal = 0xF0AE;
+//public static final int Pk_KP_Divide = 0xF0AF;
+//
+//public static final int Pk_KP_0 = 0xF0B0;
+//public static final int Pk_KP_1 = 0xF0B1;
+//public static final int Pk_KP_2 = 0xF0B2;
+//public static final int Pk_KP_3 = 0xF0B3;
+//public static final int Pk_KP_4 = 0xF0B4;
+//public static final int Pk_KP_5 = 0xF0B5;
+//public static final int Pk_KP_6 = 0xF0B6;
+//public static final int Pk_KP_7 = 0xF0B7;
+//public static final int Pk_KP_8 = 0xF0B8;
+//public static final int Pk_KP_9 = 0xF0B9;
+//
+ public static final int Pk_F1 = 0xF0BE;
+ public static final int Pk_F2 = 0xF0BF;
+ public static final int Pk_F3 = 0xF0C0;
+ public static final int Pk_F4 = 0xF0C1;
+ public static final int Pk_F5 = 0xF0C2;
+ public static final int Pk_F6 = 0xF0C3;
+ public static final int Pk_F7 = 0xF0C4;
+ public static final int Pk_F8 = 0xF0C5;
+ public static final int Pk_F9 = 0xF0C6;
+ public static final int Pk_F10 = 0xF0C7;
+ public static final int Pk_F11 = 0xF0C8;
+ public static final int Pk_F12 = 0xF0C9;
+//
+ public static final int Pk_Shift_L = 0xF0E1; /* Left shift */
+ public static final int Pk_Shift_R = 0xF0E2; /* Right shift */
+ public static final int Pk_Control_L = 0xF0E3; /* Left control */
+ public static final int Pk_Control_R = 0xF0E4; /* Right control */
+//public static final int Pk_Caps_Lock = 0xF0E5; /* Caps lock */
+//public static final int Pk_Shift_Lock = 0xF0E6; /* Shift lock */
+//
+//public static final int Pk_Meta_L = 0xF0E7; /* Left meta */
+//public static final int Pk_Meta_R = 0xF0E8; /* Right meta */
+ public static final int Pk_Alt_L = 0xF0E9; /* Left alt */
+ public static final int Pk_Alt_R = 0xF0EA; /* Right alt */
+//
+//public static final int Pm_CONTEXT_FLUSHED = 0x00000001;
+//public static final int Pm_IMAGE_CONTEXT = 1;
+//public static final int Pm_PHS_CONTEXT = 0;
+//public static final int POINTER_CTRL_ATTR_MASK = 0x00000f00;
+//public static final int POINTER_CTRL_BUTTONS = 0x00000010;
+//public static final int POINTER_CTRL_DEVMATRIX = 0x00000200;
+//public static final int POINTER_CTRL_FILENAME = 0x00000080;
+//public static final int POINTER_CTRL_GAIN = 0x00000004;
+//public static final int POINTER_CTRL_GETCTRL = 0x00000000;
+//public static final int POINTER_CTRL_GETMATRIX = 0x00000040;
+//public static final int POINTER_CTRL_LAYER = 0x00000800;
+//public static final int POINTER_CTRL_LAYER_MASK = DEV_CTRL_LAYER_MASK;
+//public static final int POINTER_CTRL_OFF = 0x00000002;
+//public static final int POINTER_CTRL_ON = 0x00000001;
+//public static final int POINTER_CTRL_SCRNMATRIX = 0x00000400;
+//public static final int POINTER_CTRL_SETMATRIX = 0x00000020;
+//public static final int POINTER_CTRL_SWAP = 0x00000100;
+//public static final int POINTER_CTRL_SWITCH_MASK = DEV_CTRL_SWITCH_MASK;
+//public static final int POINTER_CTRL_THRESHOLD = 0x00000008;
+//public static final int POINTER_CTRL_TYPE_MASK = DEV_CTRL_TYPE_MASK;
+//public static final int Pp_DOCUMENT_COMPLETE = 0x00000001;
+//public static final int Pp_LANDSCAPE = 1;
+//public static final int Pp_LANDSCAPE_TSHIRT = 3;
+//public static final int Pp_PAGE_COMPLETE = 0x00000002;
+//public static final int Pp_PORTRAIT = 0;
+//public static final int Pp_TSHIRT = 2;
+//public static final int Pt_ALIGN_BOTTOM = 0x20;
+//public static final int Pt_ALIGN_CENTER = 0x2;
+//public static final int Pt_ALIGN_LEFT = 0x40;
+//public static final int Pt_ALIGN_RIGHT = 0x80;
+//public static final int Pt_ALIGN_TOP = 0x10;
+//public static final int Pt_ALL_BUTTONS = 0x00800000;
+ public static final int Pt_ALWAYS = 0x01;
+//public static final int Pt_ANCHORS_INVALID = 0x40000000;
+ public static final int Pt_ANCHORS_LOCKED = 0x04000000;
+//public static final int Pt_ARC_CHORD = Pg_ARC_CHORD;
+//public static final int Pt_ARC_CURVE = Pg_ARC;
+//public static final int Pt_ARC_PIE = Pg_ARC_PIE;
+//public static final int Pt_ARG_ACCEL_FONT = ( 7 * 1000 + 1 );
+ public static final int Pt_ARG_ACCEL_KEY = ( 3 * 1000 + 18 );
+ public static final int Pt_ARG_ACCEL_TEXT = ( 7 * 1000 + 0 );
+ public static final int Pt_ARG_ANCHOR_FLAGS = ( 10 * 1000 + 1 );
+//public static final int Pt_ARG_ANCHOR_OFFSETS = ( 10 * 1000 + 0 );
+//public static final int Pt_ARG_ARC_END = ( 26 * 1000 + 0 );
+//public static final int Pt_ARG_ARC_START = ( 26 * 1000 + 1 );
+//public static final int Pt_ARG_ARC_TYPE = ( 26 * 1000 + 2 );
+ public static final int Pt_ARG_AREA = ( 1 * 1000 + 0 );
+//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_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 );
+//public static final int Pt_ARG_BEZIER_FLAGS = ( 42 * 1000 + 1 );
+//public static final int Pt_ARG_BITMAP_BALLOON = ( 20 * 1000 + 9 );
+//public static final int Pt_ARG_BITMAP_BALLOON_COLOR = ( 20 * 1000 + 11 );
+//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_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 );
+//public static final int Pt_ARG_BKGD_BRT_FROM = ( 14 * 1000 + 0 );
+//public static final int Pt_ARG_BKGD_BRT_TO = ( 14 * 1000 + 1 );
+//public static final int Pt_ARG_BKGD_HUE_FROM = ( 14 * 1000 + 2 );
+//public static final int Pt_ARG_BKGD_HUE_TO = ( 14 * 1000 + 3 );
+//public static final int Pt_ARG_BKGD_IMAGE = ( 14 * 1000 + 15 );
+//public static final int Pt_ARG_BKGD_MIX = ( 14 * 1000 + 4 );
+//public static final int Pt_ARG_BKGD_ORIENTATION = ( 14 * 1000 + 5 );
+//public static final int Pt_ARG_BKGD_PIX_HEIGHT = ( 14 * 1000 + 8 );
+//public static final int Pt_ARG_BKGD_PIX_WIDTH = ( 14 * 1000 + 9 );
+//public static final int Pt_ARG_BKGD_PIXCOLORS = ( 14 * 1000 + 6 );
+//public static final int Pt_ARG_BKGD_PIXMAP = ( 14 * 1000 + 7 );
+//public static final int Pt_ARG_BKGD_SAT_FROM = ( 14 * 1000 + 10 );
+//public static final int Pt_ARG_BKGD_SAT_TO = ( 14 * 1000 + 11 );
+//public static final int Pt_ARG_BKGD_SPACING = ( 14 * 1000 + 16 );
+//public static final int Pt_ARG_BKGD_STEPS = ( 14 * 1000 + 12 );
+//public static final int Pt_ARG_BKGD_TILE = ( 14 * 1000 + 13 );
+//public static final int Pt_ARG_BKGD_TYPE = ( 14 * 1000 + 14 );
+//public static final int Pt_ARG_BMP_SET_BG_COLOR = ( 20 * 1000 + 3 );
+//public static final int Pt_ARG_BMP_SET_BG_FILL = ( 20 * 1000 + 4 );
+ public static final int Pt_ARG_BORDER_WIDTH = ( 1 * 1000 + 1 );
+//public static final int Pt_ARG_BOT_BORDER_COLOR = ( 2 * 1000 + 0 );
+ public static final int Pt_ARG_BUTTON_TYPE = ( 7 * 1000 + 2 );
+//public static final int Pt_ARG_CALENDAR_COLOR1 = ( 56 * 1000 + 2 );
+//public static final int Pt_ARG_CALENDAR_COLOR2 = ( 56 * 1000 + 4 );
+//public static final int Pt_ARG_CALENDAR_COLOR3 = ( 56 * 1000 + 6 );
+//public static final int Pt_ARG_CALENDAR_COLOR4 = ( 56 * 1000 + 8 );
+//public static final int Pt_ARG_CALENDAR_COLOR5 = ( 56 * 1000 + 10 );
+//public static final int Pt_ARG_CALENDAR_DATE = ( 56 * 1000 + 0 );
+//public static final int Pt_ARG_CALENDAR_FLAGS = ( 56 * 1000 + 14 );
+//public static final int Pt_ARG_CALENDAR_FONT1 = ( 56 * 1000 + 1 );
+//public static final int Pt_ARG_CALENDAR_FONT2 = ( 56 * 1000 + 3 );
+//public static final int Pt_ARG_CALENDAR_FONT3 = ( 56 * 1000 + 5 );
+//public static final int Pt_ARG_CALENDAR_FONT4 = ( 56 * 1000 + 7 );
+//public static final int Pt_ARG_CALENDAR_FONT5 = ( 56 * 1000 + 9 );
+//public static final int Pt_ARG_CALENDAR_HIGHLIGHT = ( 56 * 1000 + 15 );
+//public static final int Pt_ARG_CALENDAR_MONTH_BTN_COLOR = ( 56 * 1000 + 19 );
+//public static final int Pt_ARG_CALENDAR_MONTH_NAMES = ( 56 * 1000 + 13 );
+//public static final int Pt_ARG_CALENDAR_SEL_COLOR = ( 56 * 1000 + 11 );
+//public static final int Pt_ARG_CALENDAR_TIME_T = ( 56 * 1000 + 17 );
+//public static final int Pt_ARG_CALENDAR_WDAY_NAMES = ( 56 * 1000 + 12 );
+//public static final int Pt_ARG_CALENDAR_YEAR_BTN_COLOR = ( 56 * 1000 + 18 );
+//public static final int Pt_ARG_CBOX_BUTTON_BORDER_WIDTH = ( 31 * 1000 + 15 );
+//public static final int Pt_ARG_CBOX_BUTTON_BOT_BORDER_COLOR = ( 31 * 1000 + 17 );
+//public static final int Pt_ARG_CBOX_BUTTON_COLOR = ( 31 * 1000 + 18 );
+//public static final int Pt_ARG_CBOX_BUTTON_TOP_BORDER_COLOR = ( 31 * 1000 + 16 );
+//public static final int Pt_ARG_CBOX_BUTTON_WIDTH = ( 31 * 1000 + 6 );
+ public static final int Pt_ARG_CBOX_FLAGS = ( 31 * 1000 + 0 );
+ public static final int Pt_ARG_CBOX_MAX_VISIBLE_COUNT = ( 31 * 1000 + 19);
+//public static final int Pt_ARG_CBOX_SEL_ITEM = ( 31 * 1000 + 1 );
+ public static final int Pt_ARG_CBOX_SELECTION_ITEM = ( 31 * 1000 + 1 );
+//public static final int Pt_ARG_CLIENT_FLAGS = ( 99 * 1000 + 7 );
+//public static final int Pt_ARG_CLIENT_NAME = ( 99 * 1000 + 4 );
+//public static final int Pt_ARG_CLIENT_REPLY_LEN = ( 99 * 1000 + 2 );
+//public static final int Pt_ARG_CLIENT_SEND = ( 99 * 1000 + 1 );
+//public static final int Pt_ARG_CLIENT_SERVER = ( 99 * 1000 + 0 );
+//public static final int Pt_ARG_CLOCK_FACE_COLOR = (57 * 1000 +6);
+//public static final int Pt_ARG_CLOCK_FACE_OUTLINE_COLOR = (57 * 1000 +5);
+//public static final int Pt_ARG_CLOCK_FLAGS = (57 * 1000 +1);
+//public static final int Pt_ARG_CLOCK_FONT = (57 * 1000 +17);
+//public static final int Pt_ARG_CLOCK_HOUR = (57 * 1000 +2);
+//public static final int Pt_ARG_CLOCK_HOUR_COLOR = (57 * 1000 +7);
+//public static final int Pt_ARG_CLOCK_HOUR_OFFSET = (57 * 1000 +14);
+//public static final int Pt_ARG_CLOCK_MINUTE = (57 * 1000 +3);
+//public static final int Pt_ARG_CLOCK_MINUTE_COLOR = (57 * 1000 +8);
+//public static final int Pt_ARG_CLOCK_MINUTE_OFFSET = (57 * 1000 +15);
+//public static final int Pt_ARG_CLOCK_SECOND = (57 * 1000 +4);
+//public static final int Pt_ARG_CLOCK_SECOND_COLOR = (57 * 1000 +9);
+//public static final int Pt_ARG_CLOCK_SECOND_OFFSET = (57 * 1000 +16);
+//public static final int Pt_ARG_CLOCK_SEP1 = (57 * 1000 +10);
+//public static final int Pt_ARG_CLOCK_SEP1_COLOR = (57 * 1000 +12);
+//public static final int Pt_ARG_CLOCK_SEP2 = (57 * 1000 +11);
+//public static final int Pt_ARG_CLOCK_SEP2_COLOR = (57 * 1000 +13);
+//public static final int Pt_ARG_CLOCK_TYPE = (57 * 1000 +0);
+ public static final int Pt_ARG_COLOR = ( 2 * 1000 + 1 );
+//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_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 );
+//public static final int Pt_ARG_DASH_LIST = ( 25 * 1000 + 0 );
+//public static final int Pt_ARG_DASH_SCALE = ( 25 * 1000 + 8 );
+//public static final int Pt_ARG_DATA = ( 1 * 1000 + 4 );
+//public static final int Pt_ARG_DB_IMAGE_TYPE = ( 48 * 1000 + 0 );
+//public static final int Pt_ARG_DB_MEMORY_CONTEXT_TYPE = ( 48 * 1000 + 1 );
+//public static final int Pt_ARG_DEFAULT_ACTION = ( 18 * 1000 + 0 );
+ public static final int Pt_ARG_DIM = ( 1 * 1000 + 5 );
+//public static final int Pt_ARG_DIRECTION = ( 29 * 1000 + 0 );
+//public static final int Pt_ARG_DIVIDER_FLAGS = ( 44 * 1000 + 1 );
+//public static final int Pt_ARG_DIVIDER_OFFSET = ( 44 * 1000 + 4 );
+//public static final int Pt_ARG_DIVIDER_SIZES = ( 44 * 1000 + 2 );
+//public static final int Pt_ARG_EDIT_MASK = ( 4 * 1000 + 4 );
+//public static final int Pt_ARG_EFLAGS = ( 1 * 1000 + 18 );
+//public static final int Pt_ARG_EXTENDED_SHIFT = 20;
+//public static final int Pt_ARG_EXTENDED_TYPES_MASK = 0x00300000;
+ public static final int Pt_ARG_FILL_COLOR = ( 2 * 1000 + 2 );
+//public static final int Pt_ARG_FILL_PATTERN = ( 2 * 1000 + 3 );
+ public static final int Pt_ARG_FLAGS = ( 1 * 1000 + 6 );
+//public static final int Pt_ARG_FOCUS = ( 10 * 1000 + 2 );
+//public static final int Pt_ARG_FONT_DISPLAY = (38 * 1000 + 5);
+//public static final int Pt_ARG_FONT_FLAGS = (38 * 1000 + 3);
+//public static final int Pt_ARG_FONT_NAME = (38 * 1000 + 0);
+//public static final int Pt_ARG_FONT_SAMPLE = (38 * 1000 + 1);
+//public static final int Pt_ARG_FONT_SYMBOL = (38 * 1000 + 2);
+//public static final int Pt_ARG_FRAME_DATA = ( 101 * 1000 + 0 );
+//public static final int Pt_ARG_FRAME_INTERVAL = ( 101 * 1000 + 2 );
+//public static final int Pt_ARG_FS_FILE_SPEC = ( 47 * 1000 + 5 );
+//public static final int Pt_ARG_FS_FLAGS = ( 47 * 1000 + 2 );
+//public static final int Pt_ARG_FS_FORMAT = ( 47 * 1000 + 5 );
+//public static final int Pt_ARG_FS_IMAGES = ( 47 * 1000 + 1 );
+//public static final int Pt_ARG_FS_REFRESH = ( 47 * 1000 + 3 );
+//public static final int Pt_ARG_FS_ROOT_DIR = ( 47 * 1000 + 0 );
+//public static final int Pt_ARG_FS_TIMER_INITIAL = ( 47 * 1000 + 4 );
+//public static final int Pt_ARG_GAUGE_FLAGS = ( 21 * 1000 + 0 );
+//public static final int Pt_ARG_GAUGE_FONT = ( 21 * 1000 + 1 );
+//public static final int Pt_ARG_GAUGE_H_ALIGN = ( 21 * 1000 + 8 );
+ public static final int Pt_ARG_GAUGE_MAXIMUM = ( 21 * 1000 + 3 );
+ public static final int Pt_ARG_GAUGE_MINIMUM = ( 21 * 1000 + 2 );
+ public static final int Pt_ARG_GAUGE_ORIENTATION = ( 21 * 1000 + 5 );
+//public static final int Pt_ARG_GAUGE_V_ALIGN = ( 21 * 1000 + 9 );
+ public static final int Pt_ARG_GAUGE_VALUE = ( 21 * 1000 + 4 );
+//public static final int Pt_ARG_GAUGE_VALUE_PREFIX = ( 21 * 1000 + 6 );
+//public static final int Pt_ARG_GAUGE_VALUE_SUFFIX = ( 21 * 1000 + 7 );
+//public static final int Pt_ARG_GRAPHIC_FLAGS = ( 25 * 1000 + 1 );
+//public static final int Pt_ARG_GRID_HORIZONTAL = ( 43 * 1000 + 0 );
+//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_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 );
+//public static final int Pt_ARG_GROUP_SPACING_Y = ( 11 * 1000 + 7 );
+ public static final int Pt_ARG_GROUP_VERT_ALIGN = ( 11 * 1000 + 4 );
+//public static final int Pt_ARG_HELP_TOPIC = ( 1 * 1000 + 15 );
+//public static final int Pt_ARG_HIGHLIGHT_COLOR = ( 4 * 1000 + 15 );
+//public static final int Pt_ARG_HIGHLIGHT_ROUNDNESS = ( 2 * 1000 + 14 );
+ public static final int Pt_ARG_HORIZONTAL_ALIGNMENT = ( 3 * 1000 + 0 );
+//public static final int Pt_ARG_HTML_BORDER_WIDTH = ( 45 * 1000 + 26 );
+//public static final int Pt_ARG_HTML_CURSOR_BUSY = ( 45 * 1000 + 11 );
+//public static final int Pt_ARG_HTML_CURSOR_DEFAULT = ( 45 * 1000 + 9 );
+//public static final int Pt_ARG_HTML_CURSOR_LINK = ( 45 * 1000 + 10 );
+//public static final int Pt_ARG_HTML_FILL_COLOR = ( 45 * 1000 + 27 );
+//public static final int Pt_ARG_HTML_FLAGS = ( 45 * 1000 + 31 );
+//public static final int Pt_ARG_HTML_H1_FONT = ( 45 * 1000 + 2 );
+//public static final int Pt_ARG_HTML_H2_FONT = ( 45 * 1000 + 3 );
+//public static final int Pt_ARG_HTML_H3_FONT = ( 45 * 1000 + 4 );
+//public static final int Pt_ARG_HTML_H4_FONT = ( 45 * 1000 + 5 );
+//public static final int Pt_ARG_HTML_H5_FONT = ( 45 * 1000 + 6 );
+//public static final int Pt_ARG_HTML_H6_FONT = ( 45 * 1000 + 7 );
+//public static final int Pt_ARG_HTML_INCREMENT = ( 45 * 1000 + 32 );
+//public static final int Pt_ARG_HTML_LINK_COLOR = ( 45 * 1000 + 8 );
+//public static final int Pt_ARG_HTML_PAGE_BM = ( 45 * 1000 + 24 );
+//public static final int Pt_ARG_HTML_PAGE_H = ( 45 * 1000 + 20 );
+//public static final int Pt_ARG_HTML_PAGE_INCREMENT = ( 45 * 1000 + 33 );
+//public static final int Pt_ARG_HTML_PAGE_LM = ( 45 * 1000 + 25 );
+//public static final int Pt_ARG_HTML_PAGE_N = ( 45 * 1000 + 35 );
+//public static final int Pt_ARG_HTML_PAGE_RM = ( 45 * 1000 + 23 );
+//public static final int Pt_ARG_HTML_PAGE_TM = ( 45 * 1000 + 22 );
+//public static final int Pt_ARG_HTML_PAGE_W = ( 45 * 1000 + 21 );
+//public static final int Pt_ARG_HTML_PAGE_X = ( 45 * 1000 + 18 );
+//public static final int Pt_ARG_HTML_PAGE_Y = ( 45 * 1000 + 19 );
+//public static final int Pt_ARG_HTML_PAGES = ( 45 * 1000 + 34 );
+//public static final int Pt_ARG_HTML_SCROLL_COLOR = ( 45 * 1000 + 28 );
+//public static final int Pt_ARG_HTML_SCROLL_FILL_COLOR = ( 45 * 1000 + 29 );
+//public static final int Pt_ARG_HTML_SCROLL_HORIZONTAL = ( 45 * 1000 + 13 );
+//public static final int Pt_ARG_HTML_SCROLL_VERTICAL = ( 45 * 1000 + 12 );
+//public static final int Pt_ARG_HTML_SCROLL_WIDTH = ( 45 * 1000 + 14 );
+//public static final int Pt_ARG_HTML_TEXT_FONT = ( 45 * 1000 + 1 );
+//public static final int Pt_ARG_HTML_URL = ( 45 * 1000 + 0 );
+//public static final int Pt_ARG_ICON_FLAGS = ( 18 * 1000 + 1 );
+//public static final int Pt_ARG_ICON_POS = ( 18 * 1000 + 2 );
+//public static final int Pt_ARG_ICON_WINDOW = ( 18 * 1000 + 3 );
+//public static final int Pt_ARG_IMAGEAREA_FLAGS = ( 103 * 1000 + 8 );
+//public static final int Pt_ARG_IMAGEAREA_GRID_COLOR = ( 103 * 1000 + 14 );
+//public static final int Pt_ARG_IMAGEAREA_GRID_THRESHOLD = ( 103 * 1000 + 13 );
+//public static final int Pt_ARG_IMAGEAREA_IMAGE = ( 103 * 1000 + 0 );
+//public static final int Pt_ARG_IMAGEAREA_LEFT = ( 103 * 1000 + 6 );
+//public static final int Pt_ARG_IMAGEAREA_SELECTION = ( 103 * 1000 + 12 );
+//public static final int Pt_ARG_IMAGEAREA_TOP = ( 103 * 1000 + 5 );
+//public static final int Pt_ARG_IMAGEAREA_ZOOM = ( 103 * 1000 + 7 );
+//public static final int Pt_ARG_IMAGETREE_COLUMNS = ( 49 * 1000 + 2 );
+//public static final int Pt_ARG_IN_EXDATA = 0x00100000;
+//public static final int Pt_ARG_IN_WDATA = 0x00200000;
+ public static final int Pt_ARG_INCREMENT = ( 29 * 1000 + 1 );
+//public static final int Pt_ARG_INDICATOR_COLOR = ( 9 * 1000 + 0 );
+//public static final int Pt_ARG_INDICATOR_DEPTH = ( 9 * 1000 + 6 );
+//public static final int Pt_ARG_INDICATOR_HEIGHT = ( 9 * 1000 + 8 );
+ public static final int Pt_ARG_INDICATOR_TYPE = ( 9 * 1000 + 2 );
+//public static final int Pt_ARG_INDICATOR_WIDTH = ( 9 * 1000 + 7 );
+ public static final int Pt_ARG_ITEMS = ( 23 * 1000 + 1 );
+//public static final int Pt_ARG_LABEL_BALLOON = ( 3 * 1000 + 17 );
+//public static final int Pt_ARG_LABEL_DATA = ( 3 * 1000 + 1 );
+//public static final int Pt_ARG_LABEL_FLAGS = ( 3 * 1000 + 2 );
+ 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_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 );
+//public static final int Pt_ARG_LIST_COLUMN_POS = ( 23 * 1000 + 27 );
+//public static final int Pt_ARG_LIST_FLAGS = ( 23 * 1000 + 2 );
+ public static final int Pt_ARG_LIST_FONT = ( 23 * 1000 + 3 );
+ public static final int Pt_ARG_LIST_ITEM_COUNT = ( 23 * 1000 + 14 );
+//public static final int Pt_ARG_LIST_SB_RES = ( 23 * 1000 + 25 );
+//public static final int Pt_ARG_LIST_SCROLL_RATE = ( 23 * 1000 + 26 );
+ public static final int Pt_ARG_LIST_SEL_COUNT = ( 23 * 1000 + 15 );
+//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_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 );
+ public static final int Pt_ARG_MARGIN_WIDTH = ( 2 * 1000 + 5 );
+//public static final int Pt_ARG_MAX_HEIGHT = ( 18 * 1000 + 4 );
+ public static final int Pt_ARG_MAX_LENGTH = ( 4 * 1000 + 5 );
+//public static final int Pt_ARG_MAX_WIDTH = ( 18 * 1000 + 5 );
+ public static final int Pt_ARG_MENU_FLAGS = ( 19 * 1000 + 0 );
+//public static final int Pt_ARG_MENU_SPACING = ( 19 * 1000 + 1 );
+//public static final int Pt_ARG_MENU_TEXT_FONT = ( 19 * 1000 + 2 );
+//public static final int Pt_ARG_MENU_TITLE = ( 19 * 1000 + 3 );
+//public static final int Pt_ARG_MENU_TITLE_FONT = ( 19 * 1000 + 4 );
+//public static final int Pt_ARG_MENUBAR_FLAGS = ( 37 * 1000 + 0 );
+//public static final int Pt_ARG_MIN_HEIGHT = ( 18 * 1000 + 6 );
+//public static final int Pt_ARG_MIN_SLIDER_SIZE = ( 29 * 1000 + 11 );
+//public static final int Pt_ARG_MIN_WIDTH = ( 18 * 1000 + 7 );
+//public static final int Pt_ARG_MLTITXT_FLAGS = ( 5 * 1000 + 2 );
+//public static final int Pt_ARG_MODE_ALLOC = 0x000A0000;
+//public static final int Pt_ARG_MODE_ARRAY = 0x000C0000;
+//public static final int Pt_ARG_MODE_BOOLEAN = 0x00080000;
+//public static final int Pt_ARG_MODE_CHAR = 0x00010000;
+//public static final int Pt_ARG_MODE_CHAR_FLAGS = 0x00040000;
+//public static final int Pt_ARG_MODE_LONG = 0x00030000;
+//public static final int Pt_ARG_MODE_INT = Pt_ARG_MODE_LONG;
+//public static final int Pt_ARG_MODE_LINKED = 0x000D0000;
+//public static final int Pt_ARG_MODE_LONG_FLAGS = 0x00060000;
+//public static final int Pt_ARG_MODE_MASK = 0x000F0000;
+//public static final int Pt_ARG_MODE_PTR = 0x00070000;
+//public static final int Pt_ARG_MODE_SHORT = 0x00020000;
+//public static final int Pt_ARG_MODE_SHORT_FLAGS = 0x00050000;
+//public static final int Pt_ARG_MODE_STRALLOC = 0x000B0000;
+//public static final int Pt_ARG_MODE_STRING = 0x000B0000;
+//public static final int Pt_ARG_MODE_STRUCT = 0x00090000;
+//public static final int Pt_ARG_MODE_VARIABLE = 0x00090000;
+//public static final int Pt_ARG_MODIFY_ITEMS = ( 23 * 1000 + 29 );
+//public static final int Pt_ARG_MSG_BUTTON1 = ( 32 * 1000 + 4 );
+//public static final int Pt_ARG_MSG_BUTTON2 = ( 32 * 1000 + 5 );
+//public static final int Pt_ARG_MSG_BUTTON3 = ( 32 * 1000 + 6 );
+//public static final int Pt_ARG_MSG_DEFAULT = ( 32 * 1000 + 7 );
+//public static final int Pt_ARG_MSG_ESCAPE = ( 32 * 1000 + 2 );
+//public static final int Pt_ARG_MSG_FLAGS = ( 32 * 1000 + 11 );
+//public static final int Pt_ARG_MSG_FONT = ( 32 * 1000 + 3 );
+//public static final int Pt_ARG_MSG_TEXT = ( 32 * 1000 + 1 );
+//public static final int Pt_ARG_MSG_TITLE = ( 32 * 1000 + 0 );
+//public static final int Pt_ARG_MULTITEXT_BOTTOM_LINE = ( 5 * 1000 + 8 );
+//public static final int Pt_ARG_MULTITEXT_FLAGS = ( 5 * 1000 + 15 );
+ public static final int Pt_ARG_MULTITEXT_LINE_SPACING = ( 5 * 1000 + 3 );
+ public static final int Pt_ARG_MULTITEXT_NUM_LINES = ( 5 * 1000 + 6 );
+//public static final int Pt_ARG_MULTITEXT_NUM_LINES_VISIBLE = ( 5 * 1000 + 5 );
+//public static final int Pt_ARG_MULTITEXT_QUERY_CHARACTER = ( 5 * 1000 + 11 );
+ public static final int Pt_ARG_MULTITEXT_QUERY_LINE = ( 5 * 1000 + 10 );
+//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_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 );
+//public static final int Pt_ARG_MULTITEXT_Y_SCROLL_POS = ( 5 * 1000 + 7 );
+//public static final int Pt_ARG_NUM_FRAMES = ( 101 * 1000 + 1 );
+//public static final int Pt_ARG_NUMERIC_FLAGS = ( 53 * 1000 + 1 );
+//public static final int Pt_ARG_NUMERIC_INCREMENT = ( 53 * 1000 + 3 );
+//public static final int Pt_ARG_NUMERIC_MAX = ( 53 * 1000 + 6 );
+//public static final int Pt_ARG_NUMERIC_MIN = ( 53 * 1000 + 5 );
+//public static final int Pt_ARG_NUMERIC_PRECISION = ( 53 * 1000 + 16 );
+//public static final int Pt_ARG_NUMERIC_PREFIX = ( 53 * 1000 + 7 );
+//public static final int Pt_ARG_NUMERIC_SPACING = ( 53 * 1000 + 17 );
+//public static final int Pt_ARG_NUMERIC_SUFFIX = ( 53 * 1000 + 8 );
+//public static final int Pt_ARG_NUMERIC_TEXT_BORDER = ( 53 * 1000 + 9 );
+//public static final int Pt_ARG_NUMERIC_TEXT_BOT_BORDER_COLOR = ( 53 * 1000 + 14 );
+//public static final int Pt_ARG_NUMERIC_TEXT_COLOR = ( 53 * 1000 + 11 );
+//public static final int Pt_ARG_NUMERIC_TEXT_FILL_COLOR = ( 53 * 1000 + 12 );
+//public static final int Pt_ARG_NUMERIC_TEXT_FLAGS = ( 53 * 1000 + 19 );
+//public static final int Pt_ARG_NUMERIC_TEXT_FONT = ( 53 * 1000 + 10 );
+//public static final int Pt_ARG_NUMERIC_TEXT_TOP_BORDER_COLOR = ( 53 * 1000 + 13 );
+//public static final int Pt_ARG_NUMERIC_UPDOWN_BORDER_WIDTH = ( 53 * 1000 + 18 );
+//public static final int Pt_ARG_NUMERIC_UPDOWN_WIDTH = ( 53 * 1000 + 2 );
+//public static final int Pt_ARG_NUMERIC_VALUE = ( 53 * 1000 + 4 );
+//public static final int Pt_ARG_OFFSET = ( 7 * 1000 + 3 );
+//public static final int Pt_ARG_OFFSET_MASK = 0x0000FFFF;
+//public static final int Pt_ARG_ONOFF_STATE = ( 8 * 1000 + 0 );
+//public static final int Pt_ARG_ORIGIN = ( 25 * 1000 + 5 );
+ public static final int Pt_ARG_PAGE_INCREMENT = ( 29 * 1000 + 5 );
+//public static final int Pt_ARG_PANE_FLAGS = ( 12 * 1000 + 0 );
+//public static final int Pt_ARG_PANE_RECT = ( 12 * 1000 + 1 );
+//public static final int Pt_ARG_POINTS = ( 25 * 1000 + 6 );
+//public static final int Pt_ARG_POLYGON_FLAGS = ( 27 * 1000 + 1 );
+ public static final int Pt_ARG_POS = ( 1 * 1000 + 7 );
+//public static final int Pt_ARG_PRINT_CONTEXT = (46 * 1000 + 0);
+//public static final int Pt_ARG_PRINT_FLAGS = (46 * 1000 + 1);
+//public static final int Pt_ARG_PS_ALL_PAGES_LABEL = (46 * 1000 + 12);
+//public static final int Pt_ARG_PS_COLLATE_METHOD_LABEL = (46 * 1000 + 6);
+//public static final int Pt_ARG_PS_COPIES_LABEL = (46 * 1000 + 10);
+//public static final int Pt_ARG_PS_FILENAME_LABEL = (46 * 1000 + 16);
+//public static final int Pt_ARG_PS_LOCATION_LABEL = (46 * 1000 + 7);
+//public static final int Pt_ARG_PS_NUM_COPIES_LABEL = (46 * 1000 + 5);
+//public static final int Pt_ARG_PS_PAGES_LABEL = (46 * 1000 + 13);
+//public static final int Pt_ARG_PS_PRINT_RANGE_LABEL = (46 * 1000 + 9);
+//public static final int Pt_ARG_PS_PRINTER_LABEL = (46 * 1000 + 8);
+//public static final int Pt_ARG_PS_PROPERTIES_LABEL = (46 * 1000 + 11);
+//public static final int Pt_ARG_PS_SEL_TITLE = (46 * 1000 + 4);
+//public static final int Pt_ARG_PS_SELECTION_LABEL = (46 * 1000 + 15);
+//public static final int Pt_ARG_PS_TOFILE_LABEL = (46 * 1000 + 14);
+//public static final int Pt_ARG_RAW_CALLBACKS = ( 1 * 1000 + 11 );
+//public static final int Pt_ARG_RAW_CONNECT_F = ( 24 * 1000 + 1 );
+//public static final int Pt_ARG_RAW_DRAW_F = ( 24 * 1000 + 0 );
+//public static final int Pt_ARG_RAW_EXTENT_F = ( 24 * 1000 + 2 );
+//public static final int Pt_ARG_RAW_INIT_F = ( 24 * 1000 + 3 );
+//public static final int Pt_ARG_RECT_ROUNDNESS = ( 28 * 1000 + 0 );
+//public static final int Pt_ARG_REGION_CURSOR = ( 1 * 1000 + 2 );
+//public static final int Pt_ARG_REGION_CURSOR_COLOR = ( 1 * 1000 + 3 );
+//public static final int Pt_ARG_REGION_DATA = ( 15 * 1000 + 9 );
+//public static final int Pt_ARG_REGION_FIELDS = ( 15 * 1000 + 2 );
+//public static final int Pt_ARG_REGION_FLAGS = ( 15 * 1000 + 3 );
+//public static final int Pt_ARG_REGION_HANDLE = ( 15 * 1000 + 4 );
+//public static final int Pt_ARG_REGION_INFRONT = ( 15 * 1000 + 10 );
+//public static final int Pt_ARG_REGION_INPUT_GROUP = ( 15 * 1000 + 11 );
+ public static final int Pt_ARG_REGION_OPAQUE = ( 15 * 1000 + 5 );
+//public static final int Pt_ARG_REGION_OWNER = ( 15 * 1000 + 6 );
+//public static final int Pt_ARG_REGION_PARENT = ( 15 * 1000 + 7 );
+ public static final int Pt_ARG_REGION_SENSE = ( 15 * 1000 + 8 );
+ public static final int Pt_ARG_RESIZE_FLAGS = ( 1 * 1000 + 8 );
+//public static final int Pt_ARG_SCROLL_AREA_FLAGS = ( 13 * 1000 + 12 );
+//public static final int Pt_ARG_SCROLL_AREA_INCREMENT_X = ( 13 * 1000 + 0 );
+//public static final int Pt_ARG_SCROLL_AREA_INCREMENT_Y = ( 13 * 1000 + 1 );
+ public static final int Pt_ARG_SCROLL_AREA_MAX_X = ( 13 * 1000 + 2 );
+ public static final int Pt_ARG_SCROLL_AREA_MAX_Y = ( 13 * 1000 + 3 );
+//public static final int Pt_ARG_SCROLL_AREA_POS_X = ( 13 * 1000 + 5 );
+//public static final int Pt_ARG_SCROLL_AREA_POS_Y = ( 13 * 1000 + 4 );
+//public static final int Pt_ARG_SCROLLBAR = ( 23 * 1000 + 11 );
+//public static final int Pt_ARG_SCROLLBAR_FLAGS = ( 29 * 1000 + 9 );
+ public static final int Pt_ARG_SCROLLBAR_WIDTH = ( 23 * 1000 + 5 );
+ public static final int Pt_ARG_SCROLLBAR_X_DISPLAY = ( 13 * 1000 + 6 );
+//public static final int Pt_ARG_SCROLLBAR_X_HEIGHT = ( 13 * 1000 + 7 );
+ public static final int Pt_ARG_SCROLLBAR_Y_DISPLAY = ( 13 * 1000 + 8 );
+//public static final int Pt_ARG_SCROLLBAR_Y_WIDTH = ( 13 * 1000 + 9 );
+//public static final int Pt_ARG_SEL_INDEXES = ( 23 * 1000 + 6 );
+//public static final int Pt_ARG_SEL_MODE = ( 23 * 1000 + 7 );
+//public static final int Pt_ARG_SELECT_SHIFT = ( 3 * 1000 + 9 );
+ public static final int Pt_ARG_SELECTION_FILL_COLOR = ( 23 * 1000 + 12 );
+ public static final int Pt_ARG_SELECTION_INDEXES = ( 23 * 1000 + 6 );
+ public static final int Pt_ARG_SELECTION_MODE = ( 23 * 1000 + 7 );
+ public static final int Pt_ARG_SELECTION_RANGE = ( 4 * 1000 + 12 );
+ public static final int Pt_ARG_SELECTION_TEXT_COLOR = ( 23 * 1000 + 13 );
+ public static final int Pt_ARG_SEP_FLAGS = ( 30 * 1000 + 0 );
+//public static final int Pt_ARG_SEP_ORIENTATION = ( 30 * 1000 + 1 );
+ public static final int Pt_ARG_SEP_TYPE = ( 30 * 1000 + 2 );
+//public static final int Pt_ARG_SERVER_CONNECTION = ( 98 * 1000 + 6 );
+//public static final int Pt_ARG_SERVER_NAME = ( 98 * 1000 + 7 );
+//public static final int Pt_ARG_SERVER_SEND = ( 98 * 1000 + 2 );
+//public static final int Pt_ARG_SET_BITMAP_COLORS = ( 20 * 1000 + 5 );
+//public static final int Pt_ARG_SET_BITMAP_DATA = ( 20 * 1000 + 6 );
+//public static final int Pt_ARG_SET_COLOR = ( 9 * 1000 + 3 );
+//public static final int Pt_ARG_SET_FILL = ( 9 * 1000 + 4 );
+//public static final int Pt_ARG_SHOW_ARROWS = ( 29 * 1000 + 6 );
+//public static final int Pt_ARG_SIZE_MASK = 0xFFC00000;
+//public static final int Pt_ARG_SIZE_SHIFT = 22;
+//public static final int Pt_ARG_SLIDER_FLAGS = ( 22 * 1000 + 0 );
+//public static final int Pt_ARG_SLIDER_HANDLE_HEIGHT = ( 22 * 1000 + 8 );
+//public static final int Pt_ARG_SLIDER_HANDLE_WIDTH = ( 22 * 1000 + 7 );
+//public static final int Pt_ARG_SLIDER_IMAGE = ( 22 * 1000 + 9 );
+//public static final int Pt_ARG_SLIDER_INCREMENT = ( 22 * 1000 + 1 );
+//public static final int Pt_ARG_SLIDER_LABEL_BR = ( 22 * 1000 + 3 );
+//public static final int Pt_ARG_SLIDER_LABEL_BR_COL = ( 22 * 1000 + 5 );
+//public static final int Pt_ARG_SLIDER_LABEL_TL = ( 22 * 1000 + 2 );
+//public static final int Pt_ARG_SLIDER_LABEL_TL_COL = ( 22 * 1000 + 4 );
+//public static final int Pt_ARG_SLIDER_MULTIPLE = ( 22 * 1000 + 6 );
+//public static final int Pt_ARG_SLIDER_ORIENTATION = ( 22 * 1000 + 19 );
+ public static final int Pt_ARG_SLIDER_SIZE = ( 29 * 1000 + 7 );
+//public static final int Pt_ARG_SLIDER_TICK_MAJOR_COL = ( 22 * 1000 + 10 );
+//public static final int Pt_ARG_SLIDER_TICK_MAJOR_DIV = ( 22 * 1000 + 13 );
+//public static final int Pt_ARG_SLIDER_TICK_MAJOR_LEN = ( 22 * 1000 + 14 );
+//public static final int Pt_ARG_SLIDER_TICK_MINOR_COL = ( 22 * 1000 + 11 );
+//public static final int Pt_ARG_SLIDER_TICK_MINOR_DIV = ( 22 * 1000 + 12 );
+//public static final int Pt_ARG_SLIDER_TICK_MINOR_LEN = ( 22 * 1000 + 15 );
+//public static final int Pt_ARG_SLIDER_TROUGH_COL = ( 22 * 1000 + 18 );
+//public static final int Pt_ARG_SLIDER_TROUGH_SIZE = ( 22 * 1000 + 16 );
+//public static final int Pt_ARG_SPACING = ( 9 * 1000 + 5 );
+//public static final int Pt_ARG_TAB_FLAGS = ( 58 * 1000 + 0 );
+//public static final int Pt_ARG_TEMPLATE_1 = ( 5001 * 1000 + 0 );
+//public static final int Pt_ARG_TEMPLATE_2 = ( 5001 * 1000 + 1 );
+//public static final int Pt_ARG_TEXT_CURSOR_WIDTH = ( 4 * 1000 + 18 );
+ public static final int Pt_ARG_TEXT_FLAGS = ( 4 * 1000 + 8 );
+ public static final int Pt_ARG_TEXT_FONT = ( 3 * 1000 + 10 );
+//public static final int Pt_ARG_TEXT_HIGHLIGHT_BACKGROUND_COLOR = ( 4 * 1000 + 17 );
+//public static final int Pt_ARG_TEXT_HIGHLIGHT_TEXT_COLOR = ( 4 * 1000 + 16 );
+ public static final int Pt_ARG_TEXT_STRING = ( 3 * 1000 + 11 );
+//public static final int Pt_ARG_TEXT_SUBSTRING = ( 4 * 1000 + 13 );
+ public static final int Pt_ARG_TIMER_INITIAL = ( 41 * 1000 + 0 );
+//public static final int Pt_ARG_TIMER_REPEAT = ( 41 * 1000 + 1 );
+//public static final int Pt_ARG_TOP_BORDER_COLOR = ( 2 * 1000 + 6 );
+ public static final int Pt_ARG_TOP_ITEM_POS = ( 23 * 1000 + 8 );
+//public static final int Pt_ARG_TRANS_PATTERN = ( 2 * 1000 + 13 );
+//public static final int Pt_ARG_TREE_BALLOON = ( 23 * 1000 + 30 );
+//public static final int Pt_ARG_TREE_FLAGS = ( 23 * 1000 + 18 );
+ public static final int Pt_ARG_TREE_IMAGES = ( 23 * 1000 + 19 );
+//public static final int Pt_ARG_TREE_IMGMASK = ( 23 * 1000 + 20 );
+//public static final int Pt_ARG_UNDERLINE1 = ( 3 * 1000 + 12 );
+//public static final int Pt_ARG_UNDERLINE2 = ( 3 * 1000 + 13 );
+//public static final int Pt_ARG_UNDERLINE_TYPE = ( 3 * 1000 + 14 );
+//public static final int Pt_ARG_UPDOWN_ARM_DATA_BOT = ( 52 * 1000 + 8 );
+//public static final int Pt_ARG_UPDOWN_ARM_DATA_BOTTOM = ( 52 * 1000 + 8 );
+//public static final int Pt_ARG_UPDOWN_ARM_DATA_LEF = ( 52 * 1000 + 9 );
+//public static final int Pt_ARG_UPDOWN_ARM_DATA_LEFT = ( 52 * 1000 + 9 );
+//public static final int Pt_ARG_UPDOWN_ARM_DATA_RIGHT = ( 52 * 1000 + 10 );
+//public static final int Pt_ARG_UPDOWN_ARM_DATA_RIT = ( 52 * 1000 + 10 );
+//public static final int Pt_ARG_UPDOWN_ARM_DATA_TOP = ( 52 * 1000 + 7 );
+//public static final int Pt_ARG_UPDOWN_BOT_BDR_COLOR = ( 52 * 1000 + 12 );
+//public static final int Pt_ARG_UPDOWN_BOTTOM_BORDER_COLOR = ( 52 * 1000 + 12 );
+//public static final int Pt_ARG_UPDOWN_DATA_BOT = ( 52 * 1000 + 4 );
+//public static final int Pt_ARG_UPDOWN_DATA_BOTTOM = ( 52 * 1000 + 4 );
+//public static final int Pt_ARG_UPDOWN_DATA_LEF = ( 52 * 1000 + 5 );
+//public static final int Pt_ARG_UPDOWN_DATA_LEFT = ( 52 * 1000 + 5 );
+//public static final int Pt_ARG_UPDOWN_DATA_RIGHT = ( 52 * 1000 + 6 );
+//public static final int Pt_ARG_UPDOWN_DATA_RIT = ( 52 * 1000 + 6 );
+//public static final int Pt_ARG_UPDOWN_DATA_TOP = ( 52 * 1000 + 3 );
+//public static final int Pt_ARG_UPDOWN_FILL_COLOR = ( 52 * 1000 + 16 );
+//public static final int Pt_ARG_UPDOWN_FLAGS = ( 52 * 1000 + 15 );
+//public static final int Pt_ARG_UPDOWN_HIGHLGHT_ROUND = ( 52 * 1000 + 14 );
+//public static final int Pt_ARG_UPDOWN_HIGHLIGHT_ROUND = ( 52 * 1000 + 14 );
+//public static final int Pt_ARG_UPDOWN_MARGIN_HEIGHT = ( 52 * 1000 + 17 );
+//public static final int Pt_ARG_UPDOWN_MARGIN_WIDTH = ( 52 * 1000 + 18 );
+//public static final int Pt_ARG_UPDOWN_ORIENTATION = ( 52 * 1000 + 1 );
+//public static final int Pt_ARG_UPDOWN_SPACING = ( 52 * 1000 + 2 );
+//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_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 );
+//public static final int Pt_ARG_WINDOW_CURSOR_OVERRIDE = ( 18 * 1000 + 9 );
+//public static final int Pt_ARG_WINDOW_FORCE_FRONT = ( 18 * 1000 + 10 );
+//public static final int Pt_ARG_WINDOW_FRONT_WINDOW = ( 18 * 1000 + 22 );
+//public static final int Pt_ARG_WINDOW_HELP_ROOT = ( 18 * 1000 + 20 );
+//public static final int Pt_ARG_WINDOW_INACTIVE_COLOR = ( 18 * 1000 + 19 );
+ public static final int Pt_ARG_WINDOW_MANAGED_FLAGS = ( 18 * 1000 + 11 );
+ public static final int Pt_ARG_WINDOW_NOTIFY_FLAGS = ( 18 * 1000 + 12 );
+ public static final int Pt_ARG_WINDOW_RENDER_FLAGS = ( 18 * 1000 + 13 );
+ public static final int Pt_ARG_WINDOW_STATE = ( 18 * 1000 + 14 );
+ public static final int Pt_ARG_WINDOW_TITLE = ( 18 * 1000 + 15 );
+//public static final int Pt_ARG_WINDOW_TITLE_COLOR = ( 18 * 1000 + 16 );
+ public static final int Pt_AS_REQUIRED = 0x02;
+ public static final int Pt_AUTO_EXTENT = 0x00000002;
+ public static final int Pt_AUTOHIGHLIGHT = 0x00000004;
+//public static final int Pt_BACKFILL_TEXT = 0x10;
+//public static final int Pt_BALLOON_AS_REQUIRED = 0x08;
+ public static final int Pt_BALLOON_BOTTOM = 3;
+//public static final int Pt_BALLOON_INPLACE = 4;
+//public static final int Pt_BALLOON_LEFT = 1;
+//public static final int Pt_BALLOON_PROPAGATE = 0x00000040;
+//public static final int Pt_BALLOON_REGISTERED = 0x80;
+ public static final int Pt_BALLOON_RIGHT = 0;
+//public static final int Pt_BALLOON_TOP = 2;
+//public static final int Pt_BALLOONS_ACTIVE = 0x02000000;
+//public static final int Pt_BALLOONS_LOCKED = 0x80000000;
+//public static final int Pt_BALLOONS_ON = 0x00001000;
+//public static final int Pt_BASIC_RO_FLAGS = 0xffffffff;
+//public static final int Pt_BITMAP = 0x02;
+//public static final int Pt_BITMAP_BALLOON_BOTTOM = 3;
+//public static final int Pt_BITMAP_BALLOON_INPLACE = 4;
+//public static final int Pt_BITMAP_BALLOON_LEFT = 1;
+//public static final int Pt_BITMAP_BALLOON_RIGHT = 0;
+//public static final int Pt_BITMAP_BALLOON_TOP = 2;
+//public static final int Pt_BITMAP_SHOW_BALLOON = 0x04;
+//public static final int Pt_BKGD_ALT = 2;
+//public static final int Pt_BKGD_BRIGHTNESS = 3;
+//public static final int Pt_BKGD_CENTER = 3;
+//public static final int Pt_BKGD_CENTER_GRID = 4;
+//public static final int Pt_BKGD_GRID = 1;
+//public static final int Pt_BKGD_HORIZONTAL = 1;
+//public static final int Pt_BKGD_HUE = 1;
+//public static final int Pt_BKGD_IMAGE = 5;
+//public static final int Pt_BKGD_NONE = 0;
+//public static final int Pt_BKGD_PIXMAP = 4;
+//public static final int Pt_BKGD_SATURATION = 2;
+//public static final int Pt_BKGD_VERTICAL = 2;
+//public static final int Pt_BLIT = 0xFFFF;
+//public static final int Pt_BLIT_FORCE = 0xFFFE;
+//public static final int Pt_BLOCK_CUA_FOCUS = 0x00000001;
+ public static final int Pt_BLOCKED = 0x00020000;
+//public static final int Pt_BOTTOM = 1;
+ public static final int Pt_BOTTOM_ANCHORED_BOTTOM = 0x00000080;
+ public static final int Pt_BOTTOM_ANCHORED_RELATIVE = 0x00000008;
+ public static final int Pt_BOTTOM_ANCHORED_TOP = 0x00000800;
+ public static final int Pt_BOTTOM_IS_ANCHORED = Pt_BOTTOM_ANCHORED_BOTTOM | Pt_BOTTOM_ANCHORED_RELATIVE | Pt_BOTTOM_ANCHORED_TOP;
+//public static final int Pt_BROWSE_MODE = 3;
+//public static final int Pt_CALENDAR_DATE_SELECTED = 1;
+//public static final int Pt_CALENDAR_ID = 56;
+//public static final int Pt_CALENDAR_MONTH_BTNS = 2;
+//public static final int Pt_CALENDAR_MONTH_SELECTED = 3;
+//public static final int Pt_CALENDAR_SHOW_GRID = 16;
+//public static final int Pt_CALENDAR_SHOW_NEXT = 8;
+//public static final int Pt_CALENDAR_SHOW_PREV = 4;
+//public static final int Pt_CALENDAR_WDAY_SELECTED = 2;
+//public static final int Pt_CALENDAR_YEAR_BTNS = 1;
+//public static final int Pt_CALENDAR_YEAR_SELECTED = 4;
+ public static final int Pt_CALLBACKS_ACTIVE = 0x04000000;
+//public static final int Pt_CANVAS_INVALID = 0x00004000;
+ public static final int Pt_CB_ACTIVATE = ( 2 * 1000 + 9 );
+ public static final int Pt_CB_ARM = ( 2 * 1000 + 7 );
+//public static final int Pt_CB_BALLOONS = ( 10 * 1000 + 4 );
+//public static final int Pt_CB_BLOCKED = ( 1 * 1000 + 16 );
+//public static final int Pt_CB_CALENDAR_SELECT = ( 56 * 1000 + 16 );
+//public static final int Pt_CB_CBOX_ACTIVATE = ( 31 * 1000 + 14 );
+//public static final int Pt_CB_CBOX_CLOSE = ( 31 * 1000 + 20 );
+//public static final int Pt_CB_CLIENT_CONNECTED = ( 99 * 1000 + 6 );
+//public static final int Pt_CB_CLIENT_EVENT = ( 99 * 1000 + 3 );
+//public static final int Pt_CB_CLIENT_NOT_FOUND = ( 99 * 1000 + 8 );
+//public static final int Pt_CB_CLOCK_TIME_CHANGED = (57 * 1000 +18);
+//public static final int Pt_CB_DESTROYED = ( 1 * 1000 + 9 );
+//public static final int Pt_CB_DISARM = ( 2 * 1000 + 8 );
+//public static final int Pt_CB_DIVIDER_DRAG = ( 44 * 1000 + 3 );
+//public static final int Pt_CB_DIVIDER_SETRESOURCES = 9;
+//public static final int Pt_CB_FONT_MODIFY = (38 * 1000 + 4);
+//public static final int Pt_CB_FS_BKGD_HANDLER = ( 47 * 1000 + 8 );
+//public static final int Pt_CB_FS_SELECTION = ( 47 * 1000 + 7 );
+//public static final int Pt_CB_FS_STATE = ( 47 * 1000 + 6 );
+//public static final int Pt_CB_GEN_TREE_INPUT = ( 23 * 1000 + 23 );
+ public static final int Pt_CB_GOT_FOCUS = ( 2 * 1000 + 10 );
+//public static final int Pt_CB_HOTKEY = ( 1 * 1000 + 10);
+//public static final int Pt_CB_HTML_ERROR = ( 45 * 1000 + 30 );
+//public static final int Pt_CB_HTML_FILE_POST = ( 45 * 1000 + 16 );
+//public static final int Pt_CB_HTML_FILE_PRE = ( 45 * 1000 + 15 );
+//public static final int Pt_CB_HTML_IMAGE = ( 45 * 1000 + 17 );
+//public static final int Pt_CB_IMAGEAREA_DRAG = ( 103 * 1000 + 15 );
+//public static final int Pt_CB_IMAGEAREA_MOVEMENT = ( 103 * 1000 + 10 );
+//public static final int Pt_CB_IMAGEAREA_SCROLLED = ( 103 * 1000 + 9 );
+//public static final int Pt_CB_IMAGEAREA_SELECTION = ( 103 * 1000 + 11 );
+//public static final int Pt_CB_IMAGETREE_COLUMN_SEL = ( 49 * 1000 + 3 );
+//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_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);
+//public static final int Pt_CB_MOTION_VERIFY = ( 4 * 1000 + 11);
+//public static final int Pt_CB_MSG_BUTTON1 = ( 32 * 1000 + 8 );
+//public static final int Pt_CB_MSG_BUTTON2 = ( 32 * 1000 + 9 );
+//public static final int Pt_CB_MSG_BUTTON3 = ( 32 * 1000 +10 );
+//public static final int Pt_CB_MULTITEXT_SCROLLUPDATE = ( 5 * 1000 + 14 );
+//public static final int Pt_CB_NUMERIC_CHANGED = ( 53 * 1000 + 15 );
+//public static final int Pt_CB_ONOFF_NEW_VALUE = ( 8 * 1000 + 1 );
+//public static final int Pt_CB_PRINT_PROPS = (46 * 1000 + 2);
+//public static final int Pt_CB_PRINT_TOFILE = (46 * 1000 + 3);
+//public static final int Pt_CB_RAW = ( 1 * 1000 + 11 );
+//public static final int Pt_CB_RAW_EVENT = ( 1 * 1000 + 11 );
+ public static final int Pt_CB_REALIZED = ( 1 * 1000 + 12 );
+//public static final int Pt_CB_REPEAT = ( 2 * 1000 + 12 );
+//public static final int Pt_CB_RESCALE = ( 25 * 1000 + 7 );
+ public static final int Pt_CB_RESIZE = ( 10 * 1000 + 3 );
+ public static final int Pt_CB_SCROLL_MOVE = ( 29 * 1000 + 10 );
+//public static final int Pt_CB_SCROLLED_X = ( 13 * 1000 + 10 );
+//public static final int Pt_CB_SCROLLED_Y = ( 13 * 1000 + 11 );
+ public static final int Pt_CB_SELECTION = ( 23 * 1000 + 10 );
+//public static final int Pt_CB_SERVER_CONNECTED = ( 98 * 1000 + 8 );
+//public static final int Pt_CB_SERVER_RECEIVE = ( 98 * 1000 + 3 );
+//public static final int Pt_CB_SERVER_TRANSPORT = ( 98 * 1000 + 4 );
+ public static final int Pt_CB_SLIDER_MOVE = ( 22 * 1000 + 17 );
+//public static final int Pt_CB_STRING_CHANGED = ( 4 * 1000 + 10);
+ public static final int Pt_CB_TEXT_CHANGED = ( 4 * 1000 + 10);
+ public static final int Pt_CB_TIMER_ACTIVATE = ( 41 * 1000 + 2 );
+//public static final int Pt_CB_TREE_SELECTION = ( 23 * 1000 + 22 );
+//public static final int Pt_CB_TREE_STATE = ( 23 * 1000 + 21 );
+ public static final int Pt_CB_UNREALIZED = ( 1 * 1000 + 13 );
+ public static final int Pt_CB_WINDOW = ( 18 * 1000 + 17 );
+//public static final int Pt_CB_WINDOW_CLOSING = ( 18 * 1000 + 24 );
+//public static final int Pt_CB_WINDOW_OPENING = ( 18 * 1000 + 23 );
+//public static final int Pt_CB_WINDOW_TRANSPORT = ( 18 * 1000 + 21 );
+ public static final int Pt_CENTER = 2;
+//public static final int Pt_CHANGE_ACTIVATE = 0x00000020;
+//public static final int Pt_CHANGE_INVISIBLE = 0;
+//public static final int Pt_CHECK = 5;
+//public static final int Pt_CHILD_CREATED = 0x01000000;
+//public static final int Pt_CHILD_DESTROYED = 0x00800000;
+//public static final int Pt_CHILD_GETTING_FOCUS = 0x10000000;
+//public static final int Pt_CHILD_GETTING_RESOURCE = 0x80000000;
+//public static final int Pt_CHILD_LOSING_FOCUS = 0x20000000;
+//public static final int Pt_CHILD_LOST_FOCUS = 0x20000000;
+//public static final int Pt_CHILD_MOVED_RESIZED = 0x08000000;
+//public static final int Pt_CHILD_REALIZED = 0x02000000;
+//public static final int Pt_CHILD_REDIRECTOR = 0x00400000;
+//public static final int Pt_CHILD_SETTING_RESOURCE = 0x40000000;
+//public static final int Pt_CHILD_UNREALIZED = 0x04000000;
+//public static final int Pt_CLEAN_RESOURCES = 0x00000010;
+//public static final int Pt_CLEAR = 0x00010000;
+//public static final int Pt_CLIENT_GETEVENTS = 0x0001;
+//public static final int Pt_CLIENT_NEEDEVENTS = 0x0002;
+//public static final int Pt_CLIENT_NOEVENTS = 0x0002;
+//public static final int Pt_CLIENT_NONBLOCK = 0x0001;
+//public static final int Pt_CLIP_HIGHLIGHT = 0x00000010;
+//public static final int Pt_CLOCK_24_HOUR = 4;
+//public static final int Pt_CLOCK_ANALOG = 1;
+//public static final int Pt_CLOCK_CURRENT = -1;
+//public static final int Pt_CLOCK_DIGITAL = 0;
+//public static final int Pt_CLOCK_HOUR_CHANGED = 1;
+//public static final int Pt_CLOCK_LED = 2;
+//public static final int Pt_CLOCK_MINUTE_CHANGED = 2;
+//public static final int Pt_CLOCK_PAD_HOURS = 32;
+//public static final int Pt_CLOCK_SECOND_CHANGED = 4;
+//public static final int Pt_CLOCK_SHOW_AMPM = 16;
+//public static final int Pt_CLOCK_SHOW_NUMBERS = 8;
+//public static final int Pt_CLOCK_SHOW_SECONDS = 2;
+//public static final int Pt_CLOCK_TRACK_TIME = 1;
+//public static final int Pt_CMT_IN_UPDATE = 0x80000000;
+//public static final int Pt_CMT_SCROLL_CB_ACTIVE = 0x40000000;
+//public static final int Pt_COMBOBOX_ALT_DOWN = 0x00000100;
+//public static final int Pt_COMBOBOX_EXTENTING = 0x20000000;
+//public static final int Pt_COMBOBOX_MAX_WIDTH = 0x00000080;
+//public static final int Pt_COMBOBOX_ON_BOTTOM = 0x40000000;
+//public static final int Pt_COMBOBOX_OPEN = 0x80000000;
+ public static final int Pt_COMBOBOX_STATIC = 0x00000020;
+//public static final int Pt_COMBOBOX_TOP = 0x00000040;
+//public static final int Pt_COMPOUND = 0x00000100;
+//public static final int Pt_CONNECTION_NOTIFY_FLUSH = 4;
+//public static final int Pt_CONNECTION_NOTIFY_NOFLUSH = 2;
+//public static final int Pt_CONNECTION_NOTIFY_RESIZE = 1;
+//public static final int Pt_CONSUME_EVENTS = 0x0001;
+//public static final int Pt_CONTAINER = 0x00000001;
+//public static final int Pt_CONTAINER_ANCHORING = 0x20000000;
+//public static final int Pt_CONTAINER_CONSTRAINT_BITS = 0xFFFF0000;
+//public static final int Pt_CONTAINER_FLAGS_MASK = 0x00001fff;
+//public static final int Pt_CONTAINER_RESIZING = 0x01000000;
+ public static final int Pt_CONTINUE = 0;
+//public static final int Pt_CURSOR_IN_CONTAINER = 0x00001000;
+//public static final int Pt_CURSOR_VISIBLE = 0x00000001;
+//public static final int Pt_DAMAGE_FAMILY = 0x00040000;
+//public static final int Pt_DAMAGE_ON_FOCUS = 0x8000;
+//public static final int Pt_DAMAGE_PARENT = 0x4000;
+//public static final int Pt_DAMAGED = 0x00002000;
+//public static final int Pt_DB_INLINE_IMAGE = 0x00000001;
+ public static final int Pt_DEFAULT_COLOR = (-3);
+//public static final int Pt_DEFAULT_FONT = (0);
+ public static final int Pt_DELAY_ACTIVATION = 0x00000040;
+ public static final int Pt_DELAY_REALIZE = Pt_DELAY_ACTIVATION;
+//public static final int Pt_DESTROYED = 0x00001000;
+//public static final int Pt_DISABLE_BALLOONS = 0x00000008;
+//public static final int Pt_DISCONTINUOUS = 0x00000004;
+//public static final int Pt_DISJOINT = 0x00000080;
+//public static final int Pt_DIVIDER_CASCADE = 0x0008;
+//public static final int Pt_DIVIDER_INVISIBLE = 0x0004;
+//public static final int Pt_DIVIDER_NORESIZE = 0x0001;
+//public static final int Pt_DIVIDER_RESIZE_BOTH = 0x0002;
+//public static final int Pt_DOOMED = 0x0800;
+//public static final int Pt_DOUBLE_DASH_LINE = 3;
+//public static final int Pt_DOUBLE_LINE = 1;
+//public static final int Pt_DOUBLE_ULINE = 2;
+//public static final int Pt_DRAW_COPY_RECTS = 0x0010;
+//public static final int Pt_DRAW_DEFAULT = 0x0000;
+//public static final int Pt_DRAW_MODE_MASK = 0x000F;
+//public static final int Pt_DRAW_OVERWRITE = 0x0001;
+//public static final int Pt_DRAW_RAW = 0x0002;
+//public static final int Pt_DRAW_START = 0x0003;
+//public static final int Pt_DYNAMIC = 0;
+//public static final int Pt_EDIT_ACTIVATE = 1;
+ public static final int Pt_EDITABLE = 0x00000002;
+//public static final int Pt_EMT_AUTOINDENT = 0x00000010;
+ public static final int Pt_EMT_CHAR = 0x02;
+//public static final int Pt_EMT_DISABLE_PURGE = 0x40000000;
+//public static final int Pt_EMT_FOCUSED = 0x20000000;
+//public static final int Pt_EMT_FORCED_SCROLL = 0x00000040;
+//public static final int Pt_EMT_FULL_LINES = 0x00000020;
+ public static final int Pt_EMT_NEWLINE = 0x04;
+//public static final int Pt_EMT_NO_TABS = 0x00000080;
+//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_END = 2;
+//public static final int Pt_ESC_DISABLE = 0x8;
+//public static final int Pt_ETCH_HIGHLIGHT = 0x00000200;
+ public static final int Pt_ETCHED_IN = 4;
+ public static final int Pt_ETCHED_OUT = 5;
+//public static final int Pt_EV_REDIRECTED = (Ph_EV_BUT_PRESS|Ph_EV_BUT_RELEASE|Ph_EV_KEY|Ph_EV_BUT_REPEAT);
+ public static final int Pt_EXTENDED_MODE = 4;
+//public static final int Pt_FALSE = 0;
+//public static final int Pt_FD_DRAIN = 0x00000001;
+//public static final int Pt_FD_NOPOLL = 0x8;
+//public static final int Pt_FD_OBAND = 0x40000000;
+//public static final int Pt_FD_READ = 0x10000000;
+//public static final int Pt_FD_WRITE = 0x20000000;
+//public static final int Pt_FEP_PRESENT = 0x00000002;
+//public static final int Pt_FEP_QUERIED = 0x00000004;
+//public static final int Pt_FLOAT_ORIGIN = 0x02;
+//public static final int Pt_FLOAT_POS = 0x01;
+//public static final int Pt_FOCUS_RENDER = 0x02000000;
+//public static final int Pt_FONTSEL_AA_CHECK = 0x01;
+//public static final int Pt_FONTSEL_ALL_FONTS = PHFONT_ALL_FONTS;
+//public static final int Pt_FONTSEL_ALL_SYMBOLS = PHFONT_ALL_SYMBOLS;
+//public static final int Pt_FONTSEL_BITMAP = PHFONT_BITMAP;
+//public static final int Pt_FONTSEL_FIXED = PHFONT_FIXED;
+//public static final int Pt_FONTSEL_PROP = PHFONT_PROP;
+//public static final int Pt_FONTSEL_SAMPLE = 0x02;
+//public static final int Pt_FONTSEL_SCALABLE = PHFONT_SCALABLE;
+//public static final int Pt_FORCE_UNREALIZE = 0x00000040;
+//public static final int Pt_FREE_MEMORY = 0x20000000;
+//public static final int Pt_FS_DIR_CL = 1;
+//public static final int Pt_FS_DIR_OP = 0;
+//public static final int Pt_FS_DLINK_CL = 3;
+//public static final int Pt_FS_DLINK_OP = 2;
+//public static final int Pt_FS_ERROR = 6;
+//public static final int Pt_FS_FILE = 4;
+//public static final int Pt_FS_FLINK = 5;
+//public static final int Pt_FS_FREE_ON_COLLAPSE = 0x10;
+//public static final int Pt_FS_NEW_DIR = 0;
+//public static final int Pt_FS_NEW_ITEM = 1;
+//public static final int Pt_FS_NO_ROOT_DISPLAY = 0x80;
+//public static final int Pt_FS_OLD_DIR = 1;
+//public static final int Pt_FS_OLD_ITEM = -1;
+//public static final int Pt_FS_SEEK_KEY = 0x30;
+//public static final int Pt_FS_SHOW_DIRS = 0x1;
+//public static final int Pt_FS_SHOW_ERRORS = 0x8;
+//public static final int Pt_FS_SHOW_FILES = 0x2;
+//public static final int Pt_FS_SHOW_HIDDEN = 0x4;
+//public static final int Pt_FS_SINGLE_LEVEL = 0x20;
+//public static final int Pt_FS_ALL_FLAGS = Pt_FS_SHOW_DIRS|Pt_FS_SHOW_FILES|Pt_FS_SHOW_HIDDEN|Pt_FS_SHOW_ERRORS|Pt_FS_FREE_ON_COLLAPSE|Pt_FS_SINGLE_LEVEL|Pt_FS_SEEK_KEY;
+//public static final int Pt_FS_STATE_END = 2;
+//public static final int Pt_FS_STATE_START = 1;
+//public static final int Pt_FSDIALOG_BTN1 = 1;
+ public static final int Pt_FSDIALOG_BTN2 = 2;
+//public static final int Pt_FSDIALOG_CANCEL = 1;
+//public static final int Pt_FSDIALOG_NO_DIRS = 0x10;
+//public static final int Pt_FSDIALOG_NO_FCHECK = 0x1;
+//public static final int Pt_FSDIALOG_NO_FILES = 0x20;
+//public static final int Pt_FSDIALOG_NO_FSPEC = 0x4;
+//public static final int Pt_FSDIALOG_NO_UP_BUTTON = 0x4;
+//public static final int Pt_FSDIALOG_OPEN = 2;
+//public static final int Pt_FSDIALOG_SHOW_HIDDEN = 0x8;
+//public static final int Pt_GAUGE_MAX_ON_BOTTOM = 1;
+//public static final int Pt_GAUGE_MAX_ON_LEFT = 1;
+//public static final int Pt_GAUGE_MAX_ON_RIGHT = 0;
+//public static final int Pt_GAUGE_MAX_ON_TOP = 0;
+//public static final int Pt_GAUGE_LIVE = 0x40;
+//public static final int Pt_GEN_LIST_FULL_WIDTH = 0x08;
+//public static final int Pt_GEN_LIST_ITEM_BACKGROUND = 0x20;
+//public static final int Pt_GEN_LIST_NO_AUTOFOCUS = 0x10;
+//public static final int Pt_GEN_LIST_NO_BACKGROUND = 0x01;
+//public static final int Pt_GEN_LIST_NO_CLIPPING = 0x02;
+//public static final int Pt_GEN_LIST_SHOW_DAMAGED = 0x04;
+ public static final int Pt_GETS_FOCUS = 0x00000400;
+ public static final int Pt_GHOST = 0x01000000;
+//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_EXCLUSIVE = 0x00000001;
+//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;
+ public static final int Pt_GROUP_HORZ_RIGHT = 2;
+//public static final int Pt_GROUP_NO_KEY_WRAP_HORIZONTAL = 0x00000010;
+//public static final int Pt_GROUP_NO_KEY_WRAP_VERTICAL = 0x00000020;
+//public static final int Pt_GROUP_NO_KEY_WRAP = (Pt_GROUP_NO_KEY_WRAP_HORIZONTAL | Pt_GROUP_NO_KEY_WRAP_VERTICAL );
+//public static final int Pt_GROUP_NO_KEYS = 0x00000008;
+//public static final int Pt_GROUP_NO_SELECT_ALLOWED = 0x00000004;
+//public static final int Pt_GROUP_STRETCH_FILL = 0x00001000;
+//public static final int Pt_GROUP_STRETCH_HORIZONTAL = 0x00000400;
+//public static final int Pt_GROUP_STRETCH_VERTICAL = 0x00000800;
+//public static final int Pt_GROUP_STRETCH = (Pt_GROUP_STRETCH_VERTICAL|Pt_GROUP_STRETCH_HORIZONTAL);
+//public static final int Pt_GROUP_VERT_BOTTOM = 2;
+ public static final int Pt_GROUP_VERT_CENTER = 0;
+//public static final int Pt_GROUP_VERT_NONE = -1;
+//public static final int Pt_GROUP_VERT_TOP = 1;
+//public static final int Pt_GROUP_VERTICAL = 1;
+//public static final int Pt_HALT = 1;
+ public static final int Pt_HIGHLIGHTED = 0x00000100;
+ public static final int Pt_HORIZONTAL = 1;
+//public static final int Pt_HOTKEY_IGNORE_MODS = 0x0002;
+//public static final int Pt_HOTKEY_SYM = 0x0001;
+//public static final int Pt_HOTKEY_TERMINATOR = 0x00000004;
+//public static final int Pt_HOTKEYS_FIRST = 0x00000080;
+//public static final int Pt_HTML_DISPLAY = 0x01;
+//public static final int Pt_HTML_LOAD = 0x08;
+//public static final int Pt_HTML_PAGE = 0x10;
+//public static final int Pt_HTML_PAGE_MODE = 0x2;
+//public static final int Pt_HTML_REDIRECT = 0x04;
+//public static final int Pt_HTML_RELOAD = 0x1;
+//public static final int Pt_HTML_RESIZE = 0x02;
+//public static final int Pt_IGNORE_CONSTRAINTS = 0x00008000;
+ public static final int Pt_IMAGE = 0x04;
+//public static final int Pt_IMAGEAREA_AUTOSCALE = 0x2;
+//public static final int Pt_IMAGEAREA_COMPLETE = 3;
+//public static final int Pt_IMAGEAREA_DRAG = 2;
+//public static final int Pt_IMAGEAREA_EDITABLE_SELECTION = 0x8;
+//public static final int Pt_IMAGEAREA_ENABLE_SELECTION = 0x4;
+//public static final int Pt_IMAGEAREA_IMGCRC_VALID = 0x1;
+//public static final int Pt_IMAGEAREA_INIT = 1;
+//public static final int Pt_IMAGEAREA_NO_MEMORY = 0x10;
+//public static final int Pt_IMAGEAREA_PALCRC_VALID = 0x2;
+//public static final int Pt_IMAGEAREA_RENDERED = 0x1;
+//public static final int Pt_IMAGEAREA_SCROLLED_X = 1;
+//public static final int Pt_IMAGEAREA_SCROLLED_Y = 2;
+//public static final int Pt_IMMEDIATE_CHILD = 1;
+//public static final int Pt_IN_EXPOSE = 0x00000008;
+//public static final int Pt_IN_FLUX = 0x00008000;
+//public static final int Pt_INDEX_RESOURCES = 0x00000020;
+//public static final int Pt_INFLATE_BALLOON = 0;
+//public static final int Pt_INHERIT_COLOR = (-4);
+//public static final int Pt_INHERIT_FONT = (-1);
+ public static final int Pt_INITIAL = 0x04;
+//public static final int Pt_INITIALIZED = 0x04000000;
+//public static final int PT_INPUT_ID = 1;
+//public static final int Pt_INSERT_MODE = 0x00000008;
+//public static final int Pt_INTERNAL_HELP = 0x0002;
+//public static final int Pt_LABEL_SELECT_SHIFT = 0x01;
+ public static final int Pt_LEFT = 0;
+ public static final int Pt_LEFT_ANCHORED_LEFT = 0x00000100;
+ public static final int Pt_LEFT_ANCHORED_RELATIVE = 0x00000001;
+ public static final int Pt_LEFT_ANCHORED_RIGHT = 0x00000010;
+ public static final int Pt_LEFT_IS_ANCHORED = Pt_LEFT_ANCHORED_LEFT | Pt_LEFT_ANCHORED_RELATIVE | Pt_LEFT_ANCHORED_RIGHT;
+//public static final int Pt_LINK_DELETE = -2;
+//public static final int Pt_LINK_INSERT = -1;
+//public static final int Pt_LIST_BALLOON_AS_REQUIRED = 0x0040;
+//public static final int Pt_LIST_BALLOON_CENTER = (-3);
+//public static final int Pt_LIST_BALLOON_LEFT = (-1);
+//public static final int Pt_LIST_BALLOON_MASK = 0x0060;
+//public static final int Pt_LIST_BALLOON_NEVER = 0x0000;
+//public static final int Pt_LIST_BALLOON_REGISTERED = 0x0080;
+//public static final int Pt_LIST_BALLOON_RIGHT = (-2);
+//public static final int Pt_LIST_BALLOONS_IN_COLUMNS = 0x1000;
+//public static final int Pt_LIST_BOUNDARY_KEY_EVENTS = 0x2000;
+//public static final int Pt_LIST_COLUMN_ALIGNMENT = ( Pg_TEXT_LEFT | Pg_TEXT_RIGHT | Pg_TEXT_CENTER );
+//public static final int Pt_LIST_COLUMN_CENTER = Pg_TEXT_CENTER;
+//public static final int Pt_LIST_COLUMN_DAMAGE_ALWAYS = 0x0001;
+//public static final int Pt_LIST_COLUMN_LEFT = Pg_TEXT_LEFT;
+//public static final int Pt_LIST_COLUMN_RIGHT = Pg_TEXT_RIGHT;
+//public static final int Pt_LIST_FIND_STRING = 6;
+//public static final int Pt_LIST_GOTO_POS = 10;
+//public static final int Pt_LIST_HEADER_AUTORESIZE = 0x0400;
+//public static final int Pt_LIST_INACTIVE = 0x0004;
+//public static final int Pt_LIST_INSERT_ITEMS = 1;
+//public static final int Pt_LIST_ITEM_ABOVE = 0x010;
+//public static final int Pt_LIST_ITEM_BELOW = 0x020;
+//public static final int Pt_LIST_ITEM_CURRENT = 0x002;
+//public static final int Pt_LIST_ITEM_DAMAGED = 0x008;
+//public static final int Pt_LIST_ITEM_DISABLED = 0x004;
+//public static final int Pt_LIST_ITEM_NOCOLUMNS = 0x200;
+//public static final int Pt_LIST_ITEM_SAVED = 0x100;
+//public static final int Pt_LIST_ITEM_SELECTED = 0x001;
+//public static final int Pt_LIST_ITEM_USED_FLAGS = 0x33F;
+//public static final int Pt_LIST_MOD_LONG_POSITIONS = 5;
+//public static final int Pt_LIST_MOD_RANGE = 3;
+//public static final int Pt_LIST_MOD_SHORT_POSITIONS = 4;
+//public static final int Pt_LIST_MOD_STRINGS = 2;
+//public static final int Pt_LIST_NOBLIT = 0x0200;
+//public static final int Pt_LIST_NON_SELECT = 0x0008;
+//public static final int Pt_LIST_REMOVE_ALL_ITEMS = 0;
+//public static final int Pt_LIST_SCROLL_LIST = 0x00;
+//public static final int Pt_LIST_SCROLL_SCROLLBAR = 0x01;
+//public static final int Pt_LIST_SCROLLBAR_ALWAYS = 0x0001;
+//public static final int Pt_LIST_SCROLLBAR_AS_REQUIRED = 0x0002;
+//public static final int Pt_LIST_SCROLLBAR_AUTORESIZE = 0x0800;
+//public static final int Pt_LIST_SCROLLBAR_GETS_FOCUS = 0x0100;
+//public static final int Pt_LIST_SCROLLBAR_MASK = 0x0003;
+//public static final int Pt_LIST_SCROLLBAR_NEVER = 0x0000;
+//public static final int Pt_LIST_SELECT_POS = 7;
+//public static final int Pt_LIST_SELECTION_BROWSE = 0x01;
+//public static final int Pt_LIST_SELECTION_CANCEL = 0x02;
+ public static final int Pt_LIST_SELECTION_FINAL = 0x00;
+//public static final int Pt_LIST_SHOW_BALLOON = 0x0020;
+//public static final int Pt_LIST_SHOW_POS = 9;
+//public static final int Pt_LIST_SNAP = 0x0010;
+//public static final int Pt_LIST_UNSELECT_POS = 8;
+//public static final int Pt_MAX_ON_BOTTOM = 1;
+//public static final int Pt_MAX_ON_LEFT = 0;
+//public static final int Pt_MAX_ON_RIGHT = 1;
+//public static final int Pt_MAX_ON_TOP = 0;
+ public static final int Pt_MENU_AUTO = 0x00000001;
+//public static final int Pt_MENU_BAR = 1;
+ public static final int Pt_MENU_BUTTON = 0x00000800;
+ public static final int Pt_MENU_CHILD = 0x00000008;
+ public static final int Pt_MENU_DOWN = 3;
+//public static final int Pt_MENU_END_RELEASE = 0x40000000;
+//public static final int Pt_MENU_FOCUS = 0x20000000;
+//public static final int Pt_MENU_GOT_FOCUS = 0x10000000;
+//public static final int Pt_MENU_NAVIGATE = 1;
+//public static final int Pt_MENU_ON_LEFT = 0x08000000;
+//public static final int Pt_MENU_ON_TOP = 0x04000000;
+//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_TRANSIENT = 0x00000002;
+//public static final int Pt_MENU_UP = 4;
+//public static final int Pt_MENUABLE = 0x08000000;
+//public static final int Pt_MENUBAR_LAST_R_ALIGNED = 0x0001;
+//public static final int Pt_MENUBAR_MENU_OPEN = 0x8000;
+//public static final int Pt_MERGE_NEXT = 0x80000000;
+//public static final int Pt_MERGE_PREV = 0x40000000;
+ public static final int Pt_MODAL = 0x4;
+//public static final int Pt_MSG_CENTER_ON_PARENT = 0x1;
+//public static final int Pt_MSG_FONT_ON_BUTTONS = 0x2;
+//public static final int Pt_MT_ALIGN_BITS = 0x00000007;
+//public static final int Pt_MT_BACKGROUND = 0x0004;
+//public static final int Pt_MT_BACKGROUND_COLOR = 0x0004;
+//public static final int Pt_MT_CENTER = 0x00000002;
+//public static final int Pt_MT_FLAGS = 0x0010;
+//public static final int Pt_MT_FONT = 0x0001;
+//public static final int Pt_MT_FOREGROUND = 0x0002;
+//public static final int Pt_MT_LEFT = 0x00000004;
+//public static final int Pt_MT_QUERY_CHAR = 0;
+//public static final int Pt_MT_QUERY_LINE = 1;
+//public static final int Pt_MT_RIGHT = 0x00000001;
+//public static final int Pt_MT_TAG = 0x0008;
+//public static final int Pt_MT_TEXT_COLOR = 0x0002;
+//public static final int Pt_MT_UPDATE_POS_ONLY = 4;
+//public static final int Pt_MT_UPDATE_X_SCROLLBAR = 2;
+//public static final int Pt_MT_UPDATE_Y_SCROLLBAR = 1;
+ public static final int Pt_MULTIPLE_MODE = 2;
+//public static final int Pt_MULTITEXT = 0x20;
+ public static final int Pt_N_OF_MANY = 0;
+ public static final int Pt_NEVER = 0x00;
+//public static final int Pt_NO_INHERITED_RESOURCES = 0x00000400;
+//public static final int Pt_NO_RANGE_SELECTION = 0x00000040;
+//public static final int Pt_NO_ULINE = 0;
+ public static final int Pt_NOLINE = 6;
+//public static final int Pt_NOREDRAW_SET = 0x10000000;
+//public static final int Pt_NUMERIC_ACTIVATE = 0x2;
+//public static final int Pt_NUMERIC_AUTO_HIGHLIGHT = 0x08;
+//public static final int Pt_NUMERIC_CHANGED = 0x1;
+//public static final int Pt_NUMERIC_ENABLE_UPDOWN = 0x01;
+//public static final int Pt_NUMERIC_HEXADECIMAL = 0x10;
+//public static final int Pt_NUMERIC_UPDOWN_ACTIVATE = 0x8;
+//public static final int Pt_NUMERIC_UPDOWN_REPEAT = 0x4;
+//public static final int Pt_NUMERIC_USE_SEPARATORS = 0x02;
+//public static final int Pt_NUMERIC_VALUE_CHANGED = 0x80000000;
+//public static final int Pt_NUMERIC_WRAP = 0x04;
+//public static final int Pt_OBSCURED = 0x00004000;
+//public static final int Pt_OCCLUSIVE = 0x00000800;
+ public static final int Pt_ONE_OF_MANY = 1;
+//public static final int Pt_OPAQUE = 0x00000020;
+//public static final int Pt_PANE_XLR_ANCHOR_RIGHT = 0x0020;
+//public static final int Pt_PANE_XLR_REL = 0x0002;
+//public static final int Pt_PANE_XUL_ANCHOR_RIGHT = 0x0010;
+//public static final int Pt_PANE_XUL_REL = 0x0001;
+//public static final int Pt_PANE_YLR_ANCHOR_BOTTOM = 0x0080;
+//public static final int Pt_PANE_YLR_REL = 0x0008;
+//public static final int Pt_PANE_YUL_ANCHOR_BOTTOM = 0x0040;
+//public static final int Pt_PANE_YUL_REL = 0x0004;
+//public static final int Pt_PASS_END = 3;
+//public static final int Pt_PEN_PRESENT = 0x00000001;
+//public static final int Pt_POP_BALLOON = 1;
+//public static final int Pt_POSITIONING = 1;
+//public static final int Pt_PP_NO_RESIZE = 2;
+//public static final int Pt_PP_RESIZE_PC = 1;
+//public static final int Pt_PP_RESIZE_WIDGET = 0;
+//public static final int Pt_PROCREATED = 0x00400000;
+ public static final int Pt_RADIO = 2;
+ public static final int Pt_RANGE_MODE = 5;
+//public static final int Pt_REALIZED = 0x00000001;
+//public static final int Pt_REALIZING = 0x80000000;
+//public static final int Pt_RECTANGULAR = 0x00000002;
+//public static final int Pt_REGION = 0x40000000;
+//public static final int Pt_RELATIVE = 0x10;
+ public static final int Pt_RESIZE_BITS = 0x07;
+//public static final int Pt_RESIZE_WIDTH = 0x00000004;
+ public static final int Pt_RESIZE_Y_SHIFT = 20;
+ public static final int Pt_RESIZE_X_SHIFT = 23;
+ public static final int Pt_RESIZE_X_ALWAYS = (Pt_ALWAYS << Pt_RESIZE_X_SHIFT);
+ public static final int Pt_RESIZE_X_AS_REQUIRED = (Pt_AS_REQUIRED << Pt_RESIZE_X_SHIFT);
+ public static final int Pt_RESIZE_X_BITS = (Pt_RESIZE_BITS << Pt_RESIZE_X_SHIFT);
+ public static final int Pt_RESIZE_X_INITIAL = (Pt_INITIAL << Pt_RESIZE_X_SHIFT);
+ public static final int Pt_RESIZE_Y_ALWAYS = (Pt_ALWAYS << Pt_RESIZE_Y_SHIFT);
+ public static final int Pt_RESIZE_Y_AS_REQUIRED = (Pt_AS_REQUIRED << Pt_RESIZE_Y_SHIFT);
+ public static final int Pt_RESIZE_Y_BITS = (Pt_RESIZE_BITS << Pt_RESIZE_Y_SHIFT);
+ public static final int Pt_RESIZE_Y_INITIAL = (Pt_INITIAL << Pt_RESIZE_Y_SHIFT);
+//public static final int Pt_RESIZE_XY_ALWAYS = (Pt_RESIZE_X_ALWAYS |Pt_RESIZE_Y_ALWAYS);
+ public static final int Pt_RESIZE_XY_AS_REQUIRED = (Pt_RESIZE_X_AS_REQUIRED|Pt_RESIZE_Y_AS_REQUIRED);
+ public static final int Pt_RESIZE_XY_BITS = (Pt_RESIZE_X_BITS |Pt_RESIZE_Y_BITS);
+//public static final int Pt_RESIZE_XY_INITIAL = (Pt_RESIZE_X_INITIAL |Pt_RESIZE_Y_INITIAL);
+ public static final int Pt_RIGHT = 1;
+ public static final int Pt_RIGHT_ANCHORED_LEFT = 0x00000200;
+ public static final int Pt_RIGHT_ANCHORED_RELATIVE = 0x00000002;
+ public static final int Pt_RIGHT_ANCHORED_RIGHT = 0x00000020;
+ public static final int Pt_RIGHT_IS_ANCHORED = Pt_RIGHT_ANCHORED_LEFT | Pt_RIGHT_ANCHORED_RELATIVE | Pt_RIGHT_ANCHORED_RIGHT;
+//public static final int Pt_ROUND = 3;
+//public static final int Pt_SCROLL_AREA_IGNORE_KEYS = 0x0001;
+//public static final int Pt_SCROLL_AREA_RO_FLAGS = 0x0000;
+//public static final int Pt_SCROLL_AREA_TRACK_FOCUS = 0x0002;
+ public static final int Pt_SCROLL_DECREMENT = 1;
+//public static final int Pt_SCROLL_DECREMENT_PRESSED = 0x2000;
+ public static final int Pt_SCROLL_DRAGGED = 7;
+//public static final int Pt_SCROLL_HORIZONTAL = 0;
+ public static final int Pt_SCROLL_INCREMENT = 2;
+//public static final int Pt_SCROLL_INCREMENT_PRESSED = 0x4000;
+//public static final int Pt_SCROLL_INVERTED = 2;
+ public static final int Pt_SCROLL_PAGE_DECREMENT = 4;
+ public static final int Pt_SCROLL_PAGE_INCREMENT = 3;
+//public static final int Pt_SCROLL_PRESSED_MASK = 0xe000;
+//public static final int Pt_SCROLL_RELEASED = 8;
+//public static final int Pt_SCROLL_RESTART_DRAG = 0x1000;
+//public static final int Pt_SCROLL_SET = 9;
+//public static final int Pt_SCROLL_SHOW_ARROWS = 1;
+//public static final int Pt_SCROLL_SLIDER_PRESSED = 0x8000;
+ public static final int Pt_SCROLL_TO_MAX = 5;
+ public static final int Pt_SCROLL_TO_MIN = 6;
+//public static final int Pt_SCROLLAREA_EXTENTING = 0x8000;
+//public static final int Pt_SCROLLBAR_FOCUSED = 0x0080;
+//public static final int Pt_SCROLLBAR_HORIZONTAL = 0x0001;
+//public static final int Pt_SCROLLBAR_INVERTED = 0x0004;
+//public static final int Pt_SCROLLBAR_NOTIFY_ONLY = 0x0008;
+//public static final int Pt_SCROLLBAR_SHOW_ARROWS = 0x0002;
+ public static final int Pt_SELECT_NOREDRAW = 0x00080000;
+ public static final int Pt_SELECTABLE = 0x00000080;
+ public static final int Pt_SELECTION_MODE_AUTO = 0x8200;
+//public static final int Pt_SELECTION_MODE_COMPOSE_FLAG = 0x8000;
+//public static final int Pt_SELECTION_MODE_COMPOSE_MASK = 0x9FF0;
+ public static final int Pt_SELECTION_MODE_MULTIPLE = 0x8000;
+ public static final int Pt_SELECTION_MODE_NOCLEAR = 0x8400;
+ public static final int Pt_SELECTION_MODE_NOFOCUS = 0x9000;
+ public static final int Pt_SELECTION_MODE_NOMOVE = 0x8080;
+//public static final int Pt_SELECTION_MODE_NONE = 0x8030;
+//public static final int Pt_SELECTION_MODE_NOREST = 0x8100;
+ public static final int Pt_SELECTION_MODE_NOSCROLL = 0x8040;
+ public static final int Pt_SELECTION_MODE_RANGE = 0x8010;
+ public static final int Pt_SELECTION_MODE_SINGLE = 0x8020;
+ public static final int Pt_SELECTION_MODE_TOGGLE = 0x8800;
+ public static final int Pt_SEP_HORIZONTAL = 1;
+//public static final int Pt_SEP_HORIZONTAL_F = 1;
+//public static final int Pt_SEP_ORIENTATION = 0x01;
+ public static final int Pt_SEP_VERTICAL = 0;
+ public static final int Pt_SET = 0x00000002;
+//public static final int Pt_SHOW_BALLOON = 0x04;
+//public static final int Pt_SHOW_VALUE = 0x10;
+//public static final int Pt_SHOW_VALUE_BOTTOM = 0x20;
+//public static final int Pt_SHOW_VALUE_CENTER = 0xc0;
+//public static final int Pt_SHOW_VALUE_LEFT = 0x40;
+//public static final int Pt_SHOW_VALUE_MASK = 0xf0;
+//public static final int Pt_SHOW_VALUE_RIGHT = 0x80;
+//public static final int Pt_SHOW_VALUE_TOP = 0x10;
+//public static final int Pt_SINGLE_DASH_LINE = 2;
+//public static final int Pt_SINGLE_LINE = 0;
+//public static final int Pt_SINGLE_MODE = 1;
+//public static final int Pt_SINGLE_ULINE = 1;
+//public static final int Pt_SKIP_CHILDREN = 0x2000;
+//public static final int Pt_SLIDER_IMAGE = 0x80;
+//public static final int Pt_SLIDER_MASK = 0x70;
+//public static final int Pt_SLIDER_MIN_ON_BOTTOM = 1;
+//public static final int Pt_SLIDER_MIN_ON_LEFT = 0;
+//public static final int Pt_SLIDER_MIN_ON_RIGHT = 1;
+//public static final int Pt_SLIDER_MIN_ON_TOP = 0;
+//public static final int Pt_SLIDER_POINT_DOWN = 0x40;
+//public static final int Pt_SLIDER_POINT_LEFT = 0x20;
+//public static final int Pt_SLIDER_POINT_RIGHT = 0x40;
+//public static final int Pt_SLIDER_POINT_UP = 0x20;
+//public static final int Pt_SLIDER_X1_RESOURCES = 1;
+//public static final int Pt_SUBORDINATES_CHILD = 2;
+//public static final int Pt_SUPER_CONSTRAINTS = 0x00000800;
+//public static final int Pt_SYSINFO_VALID = 0x00002000;
+//public static final int Pt_TAB_UPSIDE_DOWN = 0x1;
+//public static final int Pt_TEXT_AUTO_HIGHLIGHT = 0x00000080;
+//public static final int Pt_TEXT_CHANGED = 0x80000000;
+//public static final int Pt_TEXT_FULL = 0x00000010;
+ public static final int Pt_TEXT_IMAGE = 0x08;
+//public static final int Pt_TEXT_RANGE_ACTIVE = 0x40000000;
+//public static final int Pt_TEXT_X1_RESOURCES = 1;
+ public static final int Pt_TICK = 4;
+//public static final int Pt_TICKS_ETCHED_IN = 0x10;
+//public static final int Pt_TICKS_ETCHED_OUT = 0x08;
+//public static final int Pt_TICKS_MASK = 0x03;
+//public static final int Pt_TICKS_ON_BOTTOM = 0x02;
+//public static final int Pt_TICKS_ON_LEFT = 0x01;
+//public static final int Pt_TICKS_ON_RIGHT = 0x02;
+//public static final int Pt_TICKS_ON_TOP = 0x01;
+//public static final int Pt_TICKS_TOUCH_TROUGH = 0x04;
+//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_ANCHORED_BOTTOM = 0x00000040;
+//public static final int Pt_TOP_ANCHORED_RELATIVE = 0x00000004;
+ public static final int Pt_TOP_ANCHORED_TOP = 0x00000400;
+//public static final int Pt_TOP_IS_ANCHORED = Pt_TOP_ANCHORED_BOTTOM | Pt_TOP_ANCHORED_RELATIVE | Pt_TOP_ANCHORED_TOP;
+//public static final int Pt_TRAVERSE_BACK = 0x00000004;
+//public static final int Pt_TRAVERSE_DONE = 0;
+//public static final int Pt_TRAVERSE_FORCE = 0x00000008;
+//public static final int Pt_TRAVERSE_LAST = 0x00000002;
+//public static final int Pt_TRAVERSE_ROOT = 0x00000001;
+//public static final int Pt_TRAVERSE_START = 0;
+//public static final int Pt_TREE_BALLOON_ON_IMAGE = 0x0100;
+//public static final int Pt_TREE_BALLOON_ON_TREE = 0x0200;
+//public static final int Pt_TREE_COLLAPSING = 0;
+//public static final int Pt_TREE_EXPANDING = 1;
+//public static final int Pt_TREE_HAS_BUTTONS = 0x0001;
+//public static final int Pt_TREE_HAS_LINES = 0x0002;
+//public static final int Pt_TREE_ITEM_EXPANDABLE = 0x0040;
+ public static final int Pt_TREE_ITEM_EXPANDED = 0x0080;
+//public static final int Pt_TREE_ROOT_LINES = 0x0004;
+//public static final int Pt_TREE_TO_LEFT = 0x0010;
+//public static final int Pt_TREE_TO_RIGHT = 0x0008;
+//public static final int Pt_TRUE = -1;
+//public static final int Pt_UCLIP = 0x08000000;
+//public static final int Pt_ULINE_ETCHED_IN = 3;
+//public static final int Pt_ULINE_ETCHED_OUT = 4;
+//public static final int Pt_UNCLEAN_RESOURCES = 0x00000200;
+//public static final int Pt_UNUSED = 0x00000008;
+//public static final int Pt_USE_ELLIPSIS = 0x20;
+//public static final int Pt_VALUE_XOR = 0x20;
+//public static final int Pt_VERSION = 1;
+public static final int Pt_VERTICAL = 0;
+//public static final int Pt_WIDGET_REBUILD = 0x00100000;
+//public static final int Pt_WIDGET_RESIZE = 0x00200000;
+//public static final int Pt_WIN_REQUEST = 0x1000;
+//public static final int Pt_WINDOW_CURSOR_OVERRIDE = 0x0002;
+//public static final int Pt_WINDOW_EXTENTING = 0x0008;
+//public static final int Pt_WINDOW_FORCE_FRONT = 0x0001;
+//public static final int Pt_WINDOW_MAXING = 0x8000;
+//public static final int Pt_WINDOW_SETTING = 0x0010;
+//public static final int Pt_WINDOW_TASKBAR = 0x0004;
+//
+//public static final int Ph_WM_APP_DEF_MANAGED = ( Ph_WM_CLOSE | Ph_WM_FOCUS | Ph_WM_MENU | Ph_WM_TOFRONT | Ph_WM_TOBACK |
+// Ph_WM_RESIZE | Ph_WM_MOVE | Ph_WM_HIDE | Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_TASKBAR );
+//
+//public static final int Ph_WM_APP_DEF_NOTIFY = ( 0 );
+//public static final int Ph_WM_APP_DEF_RENDER = ( Ph_WM_RENDER_ASAPP | Ph_WM_RENDER_BORDER |
+// Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MOVE |
+// Ph_WM_RENDER_TITLE | Ph_WM_RENDER_MENU |
+// Ph_WM_RENDER_MIN | Ph_WM_RENDER_MAX );
+//
+//public static final int Ph_WM_ICON_DEF_MANAGED = ( Ph_WM_CLOSE | Ph_WM_FOCUS | Ph_WM_MENU | Ph_WM_TOFRONT | Ph_WM_TOBACK | Ph_WM_MOVE | Ph_WM_ICON | Ph_WM_RESTORE );
+//public static final int Ph_WM_ICON_DEF_NOTIFY = ( 0 );
+//public static final int Ph_WM_ICON_DEF_RENDER = ( Ph_WM_RENDER_ASICON | Ph_WM_RENDER_BORDER );
+//
+//public static final int Pt_RO_EFLAGS = (Pt_DAMAGE_ON_FOCUS | Pt_SKIP_CHILDREN | Pt_WIN_REQUEST | Pt_DOOMED );
+//public static final int Pt_CONTAINER_RO_FLAGS = (Pt_IGNORE_CONSTRAINTS | Pt_CANVAS_INVALID | Pt_CONTAINER_CONSTRAINT_BITS);
+//
+//public static final int PT_WORKPROC_ID = 2;
+ public static final int Pt_Z_STRING = 0x01;
+//public static final int PX_DIRECT_COLOR = 0x04;
+//public static final int PX_DODITHER = 0x40;
+//public static final int PX_IMAGE = 0x01;
+//public static final int PX_IMAGE_BMP = 0x00;
+//public static final int PX_IMAGE_GIF = 0x01;
+//public static final int PX_IMAGE_JPG = 0x02;
+//public static final int PX_IMAGE_PCX = 0x03;
+//public static final int PX_IMAGE_PNG = 0x05;
+//public static final int PX_IMAGE_TGA = 0x04;
+//public static final int PX_IMAGE_TIFF = 0x06;
+//public static final int PX_IMAGE_XBM = 0x07;
+//public static final int PX_LOAD = 0x00;
+//public static final int PX_METHODS = 0x80000000;
+//public static final int PX_NORMAL = 0x00;
+//public static final int PX_PALETTE = 0x02;
+//public static final int PX_QUERY = 0x01;
+//public static final int PX_SUPPRESS_CRC = 0x02;
+//public static final int PX_SUPPRESS_TAG = 0x02;
+//public static final int PX_TRANSPARENT = 0x08;
+//public static final int PX_USECOLORS = 0x20;
+//public static final int PXCONFIG_CREATE = 0x4;
+//public static final int PXCONFIG_FMT_BOOL_ON = 1;
+//public static final int PXCONFIG_FMT_BOOL_TRUE = 3;
+//public static final int PXCONFIG_FMT_BOOL_YES = 2;
+//public static final int PXCONFIG_FMT_CHAR_CHAR = 11;
+//public static final int PXCONFIG_FMT_CHAR_HEX = 12;
+//public static final int PXCONFIG_FMT_INT_DECIMAL = 21;
+//public static final int PXCONFIG_FMT_INT_HEX = 22;
+//public static final int PXCONFIG_FMT_STRING = 31;
+//public static final int PXCONFIG_READ = 0x0;
+//public static final int PXCONFIG_WRITE = 0x1;
+//public static final int REMOTE_FLAG_FIXED = 0x0001;
+//public static final int REMOTE_FLAG_INITIAL = 0x0002;
+//public static final int REMOTE_FLAG_IS_ORIGIN = 0x0004;
+//public static final int REMOTE_FLAG_NO_DIM = 0x0008;
+//public static final int REMOTE_WM_TITLE = 2;
+//public static final int REMOTE_WM_WINDOW = 1;
+//public static final int RF_BUF_MALLOCED = 0x0020;
+//public static final int RF_CTRL_MALLOCED = 0x0080;
+//public static final int RF_DO_PALETTE = 0x0001;
+//public static final int RF_DO_RAM = 0x0002;
+//public static final int RF_DONT_COPY = 0x0010;
+//public static final int RF_DONT_FONTMAP = 0x0008;
+//public static final int RF_DRAWFUNCS_AVAILABLE = 0x0400;
+//public static final int RF_DRAWFUNCS_MALLOCED = 0x0800;
+//public static final int RF_FORCE_ANTIALIAS = 0x0004;
+//public static final int RF_FUNCS_LOADED = 0x0040;
+//public static final int RF_NEVER_ANTIALIAS = 0x0200;
+//public static final int RF_ONE2ONE = 0x0100;
+//public static final int TTF_STATS = 0x03;
+//public static final int UPDOWN_BOT = 2;
+//public static final int UPDOWN_BOTTOM = 2;
+//public static final int UPDOWN_LEF = 3;
+//public static final int UPDOWN_LEFT = 3;
+//public static final int UPDOWN_RIGHT = 4;
+//public static final int UPDOWN_RIT = 4;
+//public static final int UPDOWN_TOP = 1;
+//public static final int VKEYMODBIT = 32;
+//public static final int WM_CONSWITCH_BACK = 1;
+//public static final int WM_CONSWITCH_CONSOLE = 0;
+//public static final int WM_CONSWITCH_FWD = 2;
+//public static final int WM_CONSWITCH_RID = 3;
+//public static final int WM_VERSION = 8;
+//
+//public static final String Ph_CLIPBOARD_TYPE_TEXT = "TEXT";
+//public static final String Ph_CURSOR_DEFAULT_FONT = "phcursor";
+//public static final String PHFONT_ENVVAR = "PHFONT";
+//public static final String PHFONT_FDNAME = "/dev/phfont";
+
+public static final int MAX_DESC_LENGTH = 32;
+public static final int MAX_FONT_TAG = 80;
+
+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 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);
+//public static final native int PfFreeFont(int ptsID);
+//public static final native int PfFontDescription(int ptsID);
+//public static final native int PfFontSize(int ptsID);
+//public static final native int PfFontFlags(int ptsID);
+//public static final native int PfConvertFontID(int ptsID);
+
+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);
+public static final native int PgDrawEllipse (PhPoint_t center, PhPoint_t radii, int flags);
+public static final native int PgDrawPolygon (short[] ptr, int num, PhPoint_t pos, int flags);
+public static final native int PgDrawRoundRect (PhRect_t rect, PhPoint_t radii, int flags);
+public static final native int PgDrawILine (int x1, int y1, int x2, int y2);
+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 PgFlush ();
+public static final native int PgSetFillColor (int color);
+public static final native int PgSetStrokeColor (int color);
+public static final native int PgSetTextColor (int color);
+public static final native void PgSetFont (byte[] ff);
+public static final native int PgSetStrokeDash (byte[] DashList, int ListLen, int DashScale);
+public static final native int PgSetStrokeWidth (int width);
+public static final native int PgSetDrawMode (int mode);
+public static final native int PgSetClipping (short n, int rects);
+public static final native int PgSetPalette (int palette, int palette_id, short first_color, short num_colors, int flags, int tag);
+public static final native int PgSetGC (int GC);
+public static final native void PgSetRegion (int rid);
+public static final native int PgSetMultiClip (int num, int clip_list);
+//public static final native void PgSetUserClip (int ClipRect);
+public static final native void PgSetUserClip (PhRect_t ClipRect);
+public static final native int PgDrawImage (int ptr, int type, PhPoint_t pos, PhDim_t size, int bpl, int tag);
+public static final native int PgDrawBitmap (int ptr, int flags, PhPoint_t pos, PhDim_t size, int bpl, int tag);
+public static final native int PgDrawTImage (int ptr, int type, PhPoint_t pos, PhDim_t size, int bpl, int tag, int TransPtr, int TransBPl);
+public static final native int PgDrawPhImageRectmx (PhPoint_t pos, int image, PhRect_t rect, int flags);
+public static final native int PhMakeTransBitmap (int image, int trans_color);
+public static final native int PiCropImage (int image, PhRect_t bounds, int flags);
+public static final native void PhBlit (int rid, PhRect_t rect, PhPoint_t offset);
+public static final native int PtClippedBlit (int widget, int src, PhPoint_t delta, int clip);
+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 PhGetMsgSize (int event_buf);
+public static final native int PhGetTile ();
+public static final native int PhAddMergeTiles (int tiles, int add_tiles, int[] added);
+public static final native int PhIntersectTilings (int tile1, int tile2, short[] num_intersect_tiles);
+public static final native int PhCoalesceTiles (int tiles);
+public static final native int PhMergeTiles (int tiles);
+public static final native int PhRectUnion (int rect1, int rect2);
+public static final native int PhRectIntersect (int rect1, int rect2);
+public static final native int PhTranslateTiles (int tile, PhPoint_t point_add);
+public static final native int PhDeTranslateTiles (int tile, int point_subtract);
+public static final native int PhClipTilings (int tiles, int clip_tiles, int[] intersection);
+public static final native int PhTilesToRects (int tiles, int[] num_rects);
+public static final native int PhRectsToTiles (int rects, int num_rects);
+public static final native void PhFreeTiles (int tiles);
+public static final native int PhWindowQueryVisible (int flag, int rid, int input_group, PhRect_t rect);
+//public static final native int PhCreateImage(PhImage_t buffer, short width, short height, int type, int[] palette, int ncolors, int shmem);
+public static final native int PhCreateImage(PhImage_t buffer, short width, short height, int type, int palette, int ncolors, int shmem);
+public static final native void PhReleaseImage(int image);
+
+public static final native int PmMemCreateMC(int image, PhDim_t dim, PhPoint_t translation);
+public static final native void PmMemReleaseMC(int mc);
+public static final native int PmMemStart(int mc);
+public static final native int PmMemStop(int mc);
+public static final native int PmMemFlush(int mc, int image);
+
+public static final native int PtList ();
+public static final native int PtLabel ();
+public static final native int PtWindow ();
+public static final native int PtInit (byte [] name);
+public static final native int PtEnter (int flags);
+public static final native int PtLeave (int flags);
+public static final native int PtCreateWidget (int clazz, int parent, int n_args, int [] args);
+public static final native int PtGetResources (int widget, int n_args, int [] args);
+public static final native int PtSetResources (int widget, int n_args, int [] args);
+public static final native int PtRealizeWidget (int widget);
+public static final native void PtAddEventHandler (int widget, int event_mask, int callback, int data);
+public static final native int PtWidgetRid (int widget);
+public static final native void PtMainLoop ();
+public static final native int PtEventHandler (int event);
+public static final native int PtDestroyWidget (int widget);
+public static final native int PtWidgetCanvas (int widget, int canvas_rect);
+public static final native int PtLabelWidgetCanvas (int widget, PhRect_t canvas_rect);
+public static final native int PtWidgetExtent (int widget, int extent);
+public static final native int PtWidgetChildBack (int widget);
+public static final native boolean PtWidgetIsRealized (int widget);
+public static final native int PtWidgetBrotherInFront (int widget);
+public static final native int PtWidgetParent (int widget);
+
+public static final native int malloc (int size);
+public static final native void free (int ptr);
+
+public static final native void memmove (int address, PhPoint_t point, int size);
+public static final native void memmove (PhPoint_t point, int address, int size);
+
+public static final native void memmove (int [] buffer, int address, int size);
+public static final native void memmove (int address, int [] buffer, int size);
+
+public static final native void memmove (int address, PhTile_t tile, int size);
+public static final native void memmove (PhTile_t tile, int address, int size);
+
+//public static final native void memmove (int address, PtCallbackInfo_t callack, int size);
+public static final native void memmove (PtCallbackInfo_t callack, int address, int size);
+
+//public static final native void memmove (int address, PhWindowEvent_t event, int size);
+public static final native void memmove (PhWindowEvent_t event, int address, int size);
+
+public static final native void PtAddCallback (int widget, int callback_type, int callback, int data);
+
+public static final native int PtWidgetChildFront (int widget);
+public static final native int PtWidgetBrotherBehind (int widget);
+
+public static final native void memmove (byte [] buffer, int address, int size);
+public static final native void memmove (int address, byte [] buffer, int size);
+
+public static final native int PtButton ();
+
+public static final native void memmove (int address, PhRect_t rect, int size);
+public static final native void memmove (PhRect_t rect, int address, int size);
+
+public static final native int PtUnrealizeWidget (int widget);
+
+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 PtWidgetToBack (int widget);
+public static final native int PtWidgetToFront (int widget);
+public static final native int PtWidgetInsert (int widget, int new_sibling, int behind);
+
+public static final native int PtDamageExtent (int widget, PhRect_t extent);
+
+public static final native int PtCreateWidgetClass (int superclass_ref, int size, int num_args, int [] arg);
+public static final native void PtSuperClassDraw (int wc_ref, int widget, int damage);
+
+public static final native int PtToggleButton ();
+public static final native int PtComboBox ();
+public static final native int PtText ();
+public static final native int PtMultiText ();
+public static final native int PtMenu ();
+public static final native int PtMenuBar ();
+public static final native int PtMenuButton ();
+public static final native int PtScrollbar ();
+public static final native int PtSeparator ();
+
+public static final native int PtListAddItems (int widget, int [] items, int item_count, int position);
+public static final native void PtListUnselectPos (int widget, int pos);
+
+public static final native void memmove (short [] buffer, int address, int size);
+public static final native void memmove (int address, short [] buffer, int size);
+public static final native int strlen (int string);
+
+public static final native int PtListDeleteItemPos (int widget, int item_count, int position);
+public static final native int PtListDeleteAllItems (int widget);
+public static final native void PtListSelectPos (int widget, int pos);
+public static final native int PtListReplaceItemPos (int widget, int [] new_items, int item_count, int position);
+public static final native void PtListGotoPos (int widget, int pos);
+
+public static final native int PtTextModifyText (int widget, int start, int end, int insert_pos, byte [] text, int length);
+public static final native int PtTextModifyText (int widget, int start, int end, int insert_pos, int text, int length);
+public static final native int PhClipboardCopyString (short ig, byte [] string);
+public static final native int PtTextGetSelection (int widget, int [] start, int [] end);
+public static final native int PtTextSetSelection (int widget, int [] start, int [] end);
+
+public static final native int PtPositionMenu (int widget, PhEvent_t event);
+public static final native int PtReParentWidget (int widget, int parent);
+
+public static final native int PtForwardWindowEvent (PhWindowEvent_t event);
+
+public static final native int PtWidgetOffset (int widget, PhPoint_t offset);
+
+public static final native void PtRemoveCallback (int widget, int callback_type, int callback, int data);
+
+public static final native int PtScrollContainer ();
+
+public static final native int PtWidgetCanvas (int widget, PhRect_t canvas_rect);
+//public static final native int PtAddClassStyle (int wclass, int style);
+public static final native int PtWidgetClass (int widget);
+public static final native int PtWidgetIsClassMember (int widget, int clazz);
+
+public static final native void memmove (int dest, int src, int size);
+
+public static final native void memmove (int address, PhImage_t image, int size);
+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 (PhPointerEvent_t dest, int src, int size);
+
+public static final native int PhGetData (int event);
+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 int PtExtentWidget (int widget);
+public static final native int PtExtentWidgetFamily (int widget);
+
+public static final native void PtGetAbsPosition (int widget, short [] x, short [] y);
+
+//public static final native int PtSetAreaFromExtent (int widget, PhRect_t extent_rect, PhArea_t area);
+public static final native int PtSetAreaFromWidgetCanvas (int widget, PhRect_t canvas_rect, PhArea_t area);
+
+//NOT THE SAME
+//public static final native int PtSetAreaFromCanvas (int widget, PhRect_t canvas_rect, PhArea_t area);
+
+//public static final native void memmove (int address, PhImage_t image, int size);
+public static final native void memmove (PhKeyEvent_t dest, int src, int size);
+
+//public static final native int PhTo8859_1 (int event);
+//public static final native int PhKeyToMb (byte [] buffer, int event);
+
+//public static final native void memmove (int dest, PhImage_t src, int size);
+public static final native void memmove (PtScrollbarCallback_t dest, int src, int size);
+
+public static final native void memmove (int dest, PhArea_t src, int size);
+//public static final native void memmove (PhArea_t dest, int src, int size);
+
+public static final native int PtSetParentWidget (int widget);
+public static final native void PtFrameSize (int widget, int border_width, int [] left_border, int [] top_border, int [] right_border, int [] bottom_border);
+
+public static final native int PtCreateAppContext ();
+public static final native void PtAppProcessEvent (int app_context);
+public static final native int PtAppAddWorkProc (int app_context, int work_func, int data);
+public static final native void PtAppRemoveWorkProc (int app_context, int WorkProc_id);
+
+public static final native int PtWidgetExtent (int widget, PhRect_t extent);
+public static final native int PtWidgetArea (int widget, PhArea_t area);
+public static final native int PhQueryCursor (short ig, PhCursorInfo_t buf);
+public static final native int PhInputGroup (int event);
+
+public static final native int PtContainer ();
+public static final native int PtDisjoint ();
+public static final native int PtScrollArea ();
+public static final native int PhCopyTiles (int tile);
+
+public static final native int PtFileSelection (int parent, PhPoint_t pos, byte [] title, byte [] root_dir, byte [] file_spec, byte [] btn1, byte [] btn2, byte [] format, PtFileSelectionInfo_t info, int flags);
+
+public static final native int PtWidgetPreferredSize (int widget, PhDim_t dim);
+
+public static final native int PtAppCreatePulse (int app, int priority);
+public static final native int PtAppAddInput (int app_context, int pid, int input_func, int data);
+public static final native void PtAppRemoveInput (int app_context, int input_id);
+public static final native int PtAppDeletePulse (int app, int pulse_pid);
+public static final native int PtAppPulseTrigger (int app, int pulse);
+
+public static final native int PtContainerFindFocus (int family_member);
+public static final native int PtIsFocused (int widget);
+public static final native int PtWindowFocus (int widget);
+public static final native void PtWindowToBack (int widget);
+public static final native void PtWindowToFront (int widget);
+public static final native int PtFindDisjoint (int widget);
+
+//public static final native int PhClipboardCopyString (short ig, int string);
+public static final native int PhClipboardPasteString (short ig);
+
+public static final native int PtBlockAllWindows(int skip, short cursor, int cursor_color);
+public static final native void PtUnblockWindows(int bl);
+public static final native int PtNextTopLevelWidget(int widget);
+public static final native int PtWindowGetState(int widget);
+
+public static final native void PtAddHotkeyHandler(int widget, int key_sym_cap, int key_mods, short flags, int data, int callback);
+public static final native void PtRemoveHotkeyHandler(int widget, int key_sym_cap, int key_mods, short flags, int data, int callback);
+
+public static final native void memmove (PgAlpha_t dest, int src, int size);
+public static final native void memmove (int dest, PgAlpha_t src, int size);
+
+public static final native void PgAlphaOn();
+public static final native void PgAlphaOff();
+//public static final native void PgSetAlpha(int alpha_op, int src_alpha_map, int src_alpha_gradient, byte src_global_alpha, byte dst_global_alpha);
+public static final native void PgSetAlpha(int alpha_op, PgMap_t src_alpha_map, int src_alpha_gradient, byte src_global_alpha, byte dst_global_alpha);
+
+public static final native void memmove (PtTextCallback_t dest, int src, int size);
+public static final native void memmove (int dest, PtTextCallback_t src, int size);
+
+public static final native int PhInitDrag (int rid, int flags, PhRect_t rect, PhRect_t boundary, int input_group, PhDim_t min, PhDim_t max, PhDim_t step, PhPoint_t ptrpos, short [] cursor);
+
+public static final native int PtProgress ();
+public static final native int PtPanelGroup ();
+
+public static final native void PhAreaToRect (PhArea_t area, PhRect_t rect);
+public static final native int PtCalcCanvas (int widget, PhRect_t canvas_rect);
+public static final native int PtValidParent (int widget_parent, int class_ref);
+public static final native void PtCalcBorder (int widget, PhRect_t rect);
+
+public static final native int PtPane ();
+
+public static final native int PtTree ();
+public static final native int PtTreeAllocItem (int tree, byte[] str, short set_img, short unset_img);
+public static final native int PtTreeModifyItem (int tree, int item, byte[] str, short set_img, short unset_img);
+public static final native int PtTreeModifyItemString (int tree, int item, byte[] string);
+public static final native int PtTreeFreeItems (int items);
+public static final native int PtTreeAddFirst (int tree, int item, int parent);
+public static final native int PtTreeAddAfter (int tree, int item, int brother);
+public static final native int PtTreeExpand (int tree, int item, int event);
+public static final native int PtTreeCollapse (int tree, int item, int event);
+public static final native void PtTreeRemoveItem (int tree, int item);
+public static final native void PtTreeFreeAllItems (int tree);
+public static final native int PtTreeRootItem (int tree);
+public static final native void PtTreeClearSelection (int tree);
+public static final native void PtTreeSelect (int tree, int item);
+
+public static final native void memmove (PtTreeItem_t dest, int src, int size);
+public static final native void memmove (int dest, PtTreeItem_t src, int size);
+
+public static final native void memmove (PgMap_t dest, int src, int size);
+public static final native void memmove (int dest, PgMap_t src, int size);
+
+public static final native int PtDamageWidget (int widget);
+public static final native int PtBlit (int widget, PhRect_t source, PhPoint_t delta);
+public static final native int PtContainerHold (int container_widget);
+public static final native int PtContainerRelease (int container_widget);
+
+public static final native int PtFontSelection (int parent, PhPoint_t pos, byte[] title, byte[] font, int symbol, int flags, byte[] sample);
+
+public static final native int PtToolbar ();
+
+//public static final native int PtColorSelGroup ();
+//public static final native int PtColorPatch ();
+//public static final native int PtColorPalette ();
+
+//public static final native int PtGroup ();
+
+//public static final native int Pg_CM_RGB ();
+//public static final native int Pg_CM_HSB ();
+//public static final native int Pg_CM_HLS ();
+
+public static final native int PhRectUnion (PhRect_t rect1, PhRect_t rect2);
+public static final native int PtRegion ();
+public static final native void PtAddFilterCallback (int widget, int event_mask, int callback, int data);
+
+public static final native int PtListItemPos (int widget, byte[] item);
+
+public static final native int PtTimer ();
+public static final native int PtHit (int container, int n, PhRect_t rect);
+
+public static final native int PtColorSelect (int parent, byte[] title, PtColorSelectInfo_t info);
+
+public static final native void PgDrawArrow (PhRect_t rect, short unknown, int color, int flags);
+
+public static final native int PtBeep ();
+
+public static final native int PtAlert (int parent, PhPoint_t location, byte[] title, int image, byte[] message, byte[] msgFont, int btnCount, int[] buttons, int[] btnFonts, int defBtn, int escBtn, int flags);
+
+public static final native int PtSlider ();
+
+public static final native int PiDuplicateImage (int image, int flags);
+
+public static final native int PhMakeGhostBitmap (int image);
+
+public static final native int PgReadScreen (PhRect_t rect, int buffer);
+public static final native int PgReadScreenSize (PhRect_t rect);
+public static final native int PgShmemCreate (int size, byte[] name);
+//public static final native int PgShmemDetach (int addr);
+public static final native int PgShmemDestroy (int addr);
+//public static final native void PgShmemCleanup ();
+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);
+
+}
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
new file mode 100755
index 0000000000..ebf21fad67
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgAlpha_t.java
@@ -0,0 +1,24 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PgAlpha_t {
+
+ public int alpha_op;
+ // PgMap_t src_alpha_map;
+ public short src_alpha_map_dim_w;
+ public short src_alpha_map_dim_h;
+ public short src_alpha_map_bpl;
+ public short src_alpha_map_bpp;
+ public int src_alpha_map_map;
+ // PgGradient_t src_alpha_gradient; *** unused
+ // PgMap_t dest_alpha_map; *** unused
+ // PgGradient_t dest_alpha_gradient; *** unused
+ public byte src_global_alpha;
+ 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
new file mode 100755
index 0000000000..e41f9bfd48
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgMap_t.java
@@ -0,0 +1,16 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PgMap_t {
+
+ public short dim_w;
+ public short dim_h;
+ public short bpl;
+ 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
new file mode 100755
index 0000000000..ab892950c6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhArea_t.java
@@ -0,0 +1,14 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhArea_t {
+ public short pos_x;
+ public short pos_y;
+ 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/PhCursorInfo_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhCursorInfo_t.java
new file mode 100755
index 0000000000..8249867c82
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhCursorInfo_t.java
@@ -0,0 +1,38 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhCursorInfo_t {
+// PhPoint_t pos;
+ public short pos_x;
+ public short pos_y;
+ public int region;
+ public int ig_region;
+ public int color;
+// PhPoint_t last_press;
+ public short last_press_x;
+ public short last_press_y;
+ public int msec;
+// PhPoint_t steady;
+ public int steady_x;
+ public int steady_y;
+ public int dragger;
+// PhRect_t drag_boundary;
+ public short drag_boundary_xUL;
+ public short drag_boundary_yUL;
+ public short drag_boundary_xLR;
+ public short drag_boundary_yLR;
+ public int phantom_rid;
+ public short type;
+ public short ig;
+ public short button_state;
+ public byte click_count;
+ public byte zero10, zero11,zero12;
+ public int key_mods;
+ 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
new file mode 100755
index 0000000000..95ccd121d6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhDim_t.java
@@ -0,0 +1,12 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 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
new file mode 100755
index 0000000000..ee5a6ab230
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhEvent_t.java
@@ -0,0 +1,27 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhEvent_t {
+ public int type;
+ public short subtype;
+ public short processing_flags;
+// public PhEventRegion_t emitter;
+ public int emitter_rid;
+ public int emitter_handle;
+// public PhEventRegion_t collector;
+ public int collector_rid;
+ public int collector_handle;
+ public short input_group;
+ public short flags;
+ public int timestamp;
+// public PhPoint_t translation;
+ public short translation_x;
+ public short translation_y;
+ 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
new file mode 100755
index 0000000000..eaad75d4a4
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhImage_t.java
@@ -0,0 +1,28 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhImage_t {
+ public int type;
+ public int image_tag;
+ public int bpl;
+ public short size_w;
+ public short size_h;
+ public int palette_tag;
+ public int colors;
+ public int alpha;
+ public int transparent;
+ public byte format;
+ public byte flags;
+ public byte ghost_bpl;
+ public byte spare1;
+ public int ghost_bitmap;
+ public int mask_bpl;
+ public int mask_bm;
+ 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
new file mode 100755
index 0000000000..3c74f4df11
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java
@@ -0,0 +1,21 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhKeyEvent_t {
+ public int key_mods;
+ public int key_flags;
+ public int key_cap;
+ public int key_sym;
+ public byte key_scan;
+ public byte key_zero1;
+ public short key_zero2;
+// PhPoint_t pos;
+ public short pos_x;
+ 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
new file mode 100755
index 0000000000..fabd9f25fe
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPoint_t.java
@@ -0,0 +1,12 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 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
new file mode 100755
index 0000000000..9240762c20
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPointerEvent_t.java
@@ -0,0 +1,20 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhPointerEvent_t {
+// public PhPoint_t pos;
+ public short pos_x;
+ public short pos_y;
+ public short buttons;
+ public short button_state;
+ public byte click_count;
+ public byte flags;
+ public short z;
+ 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
new file mode 100755
index 0000000000..db6377c99a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRect_t.java
@@ -0,0 +1,14 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhRect_t {
+ public short ul_x;
+ public short ul_y;
+ 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
new file mode 100755
index 0000000000..b3d1b78c96
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRegion_t.java
@@ -0,0 +1,32 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhRegion_t {
+ public int rid;
+ public int handle;
+ public int owner;
+ public int flags;
+ public short state;
+// public short zero1;
+ public int events_sense;
+ public int events_opaque;
+ public short origin_x;
+ public short origin_y;
+ public int parent;
+ public int child;
+ public int bro_in_front;
+ public int bro_behind;
+ public int cursor_color;
+ public short input_group;
+ public short data_len;
+// public int zero21;
+// public int zero22;
+ public short cursor_type;
+// 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
new file mode 100755
index 0000000000..d006c2ade4
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhTile_t.java
@@ -0,0 +1,16 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhTile_t {
+ // PhRect_t rect;
+ public short rect_ul_x;
+ public short rect_ul_y;
+ public short rect_lr_x;
+ 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
new file mode 100755
index 0000000000..f490159630
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhWindowEvent_t.java
@@ -0,0 +1,22 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhWindowEvent_t {
+ public int event_f;
+ public int state_f;
+ public int rid;
+// PhPoint_t pos;
+ public short pos_x;
+ public short pos_y;
+// PhDim_t size;
+ public short size_w;
+ public short size_h;
+ public short event_state;
+ 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
new file mode 100755
index 0000000000..2ecde6b294
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtCallbackInfo_t.java
@@ -0,0 +1,14 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PtCallbackInfo_t {
+ public int reason;
+ public int reason_subtype;
+ 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
new file mode 100755
index 0000000000..54dec671d7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtColorSelectInfo_t.java
@@ -0,0 +1,27 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PtColorSelectInfo_t {
+ public short flags;
+ public byte nselectors;
+ public byte ncolor_models;
+ public int color_models;
+ public int selectors;
+ public short pos_x;
+ public short pos_y;
+ public short size_w;
+ public short size_h;
+ public int palette;
+ public int accept_text;
+ public int dismiss_text;
+ public int accept_dismiss_text;
+ public int apply_f;
+ public int data;
+ 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/PtFileSelectionInfo_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtFileSelectionInfo_t.java
new file mode 100755
index 0000000000..0cc12aef00
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtFileSelectionInfo_t.java
@@ -0,0 +1,25 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PtFileSelectionInfo_t {
+ public short ret;
+ public byte [] path = new byte [(OS.PATH_MAX + OS.NAME_MAX + 4) & (~3)];
+ public PhDim_t dim = new PhDim_t ();
+ public PhPoint_t pos = new PhPoint_t ();
+ public byte [] format = new byte [80];
+ public byte [] fspec = new byte [80];
+ public int user_data;
+ public int confirm_display;
+ public int confirm_selection;
+ public int new_directory;
+ public int btn1;
+ public int btn2;
+ public int num_args;
+ 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
new file mode 100755
index 0000000000..aac48e6020
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtScrollbarCallback_t.java
@@ -0,0 +1,12 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 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
new file mode 100755
index 0000000000..abac0c47d9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTextCallback_t.java
@@ -0,0 +1,18 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PtTextCallback_t {
+ public int start_pos;
+ public int end_pos;
+ public int cur_insert;
+ public int new_insert;
+ public int length;
+ public short reserved;
+ 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
new file mode 100755
index 0000000000..27f857a96c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTreeItem_t.java
@@ -0,0 +1,25 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PtTreeItem_t {
+ public int list_flags;
+ public short list_size_w;
+ public short list_size_h;
+ public int list_next;
+ public int list_prev;
+ public int father;
+ public int son;
+ public int brother;
+ public short dim_w;
+ public short dim_h;
+ public short img_set;
+ public short img_unset;
+ public int data;
+// 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
new file mode 100755
index 0000000000..b23dff6c03
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/AbstractTreeItem.java
@@ -0,0 +1,318 @@
+package org.eclipse.swt.widgets;
+
+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
+ * to the root and to retrieve items by index.
+ * The TreeItem class implements this protocol for general
+ * tree items.
+ * TreeRoots provides a special implementation that allows the
+ * Tree class to treat trees with one root and with multiple
+ * roots equally.
+ */
+abstract class AbstractTreeItem extends SelectableItem {
+ private Vector children;
+ private boolean isExpanded = false;
+ // number of children.
+ // includes all expanded items down to the leafs.
+ private int visibleItemCount = 0;
+
+/**
+ * Create a new instance of the receiver.
+ * @param parent - widget the receiver belongs to
+ * @param swtStyle - widget style. see Widget class for details
+ */
+AbstractTreeItem(Tree parent, int swtStyle) {
+ super(parent, swtStyle);
+}
+/**
+ * Insert 'item' in the list of child items. Notify the
+ * parent about the new item.
+ * @param 'item' - the item that should be added to the
+ * receiver's children.
+ * @param index - position that 'item' will be inserted at
+ * in the receiver.
+ */
+void add(TreeItem item, int index) {
+ Vector items = getChildren();
+ int visibleIndex = getVisibleIndex();
+
+ if (index < 0 || index > items.size()) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+ if (item.isRoot()) {
+ visibleIndex = index;
+ }
+ else
+ if (isExpanded == false) {
+ visibleIndex = -1;
+ }
+ if (visibleIndex != -1) {
+ if (index > 0) {
+ TreeItem previousChild = (TreeItem) getChildren().elementAt(index - 1);
+ visibleIndex = previousChild.getVisibleIndex() + previousChild.getVisibleItemCount() + 1;
+ }
+ else {
+ visibleIndex = getVisibleIndex() + 1;
+ }
+ }
+ getSelectableParent().addingItem(item, visibleIndex);
+ item.setIndex(index);
+ resetChildIndices(index, true);
+ items.insertElementAt(item, index);
+ if (isExpanded == true) {
+ visibleItemCount++;
+ calculateVisibleItemCountParent();
+ }
+ getSelectableParent().addedItem(item, visibleIndex);
+}
+/**
+ * Set whether the receiver is expanded or not.
+ * If the receiver is expanded its child items are visible.
+ * @param expanded -
+ * true=the receiver is expanded, making its child items visible.
+ * false=the receiver is collapsed, making its child items invisible
+ */
+void internalSetExpanded(boolean expanded) {
+ isExpanded = expanded;
+ calculateVisibleItemCount();
+}
+/**
+ * Calculate the number of expanded children.
+ * Recurse up in the tree to the root item.
+ */
+abstract void calculateVisibleItemCount();
+/**
+ * Calculate the number of expanded children for the parent item
+ * of this item.
+ */
+abstract void calculateVisibleItemCountParent();
+/**
+ * Deselect the receiver and all children
+ */
+void deselectAll() {
+ Enumeration children = getChildren().elements();
+ AbstractTreeItem treeItem;
+
+ setSelected(false);
+ while (children.hasMoreElements() == true) {
+ treeItem = (AbstractTreeItem) children.nextElement();
+ treeItem.deselectAll();
+ }
+}
+/**
+ * Destroy all children of the receiver
+ */
+void disposeItem() {
+ 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();
+}
+/**
+ * Subclasses should free resources here
+ */
+void doDispose() {
+ setChildren(null);
+ visibleItemCount = 0;
+}
+/**
+ * Answer the Vector containing the child items of the receiver.
+ */
+Vector getChildren() {
+ if (children == null) {
+ children = new Vector(4);
+ }
+ return children;
+}
+/**
+ * Answer whether the receiver is expanded or not.
+ * If the receiver is expanded its children are visible.
+ * @return
+ * true - the receiver is expanded, making its children visible
+ * false - the receiver is collapsed, making its children invisible
+ */
+public boolean getExpanded() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return isExpanded;
+}
+/**
+ * Answer the number of children.
+ */
+public int getItemCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getChildren().size();
+}
+/**
+ * Answer the index of the receiver relative to the first root
+ * item.
+ * If 'anIndex' is the global index of the expanded item 'anItem'
+ * then the following expressions are true:
+ * 'anItem == theRoot.getVisibleItem(anIndex)' and
+ * 'anIndex == anItem.getVisibleIndex()'
+ * @return
+ * The index of the receiver relative to the first root item.
+ * Answer -1 if the receiver is not visible (because the parent
+ * is collapsed).
+ */
+abstract int getVisibleIndex();
+/**
+ * Answer the index of the child item identified by 'childIndex'
+ * relative to the first root item.
+ */
+abstract int getVisibleIndex(int childIndex);
+/**
+ * Answer the item at 'searchIndex' relativ to the receiver.
+ * When this method is called for the root item, 'searchIndex'
+ * represents the global index into all items of the tree.
+ * searchIndex=0 returns the receiver.
+ * searchIndex=1 returns the first visible child.
+ * Note: searchIndex must be >= 0
+ *
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. Visible here means that all
+ * the parents of the item are expanded. An item is only
+ * visible on screen if it is within the receiver's parent's
+ * client area.
+ */
+abstract TreeItem getVisibleItem(int searchIndex);
+/**
+ * Answer the number of expanded children, direct and indirect.
+ */
+int getVisibleItemCount() {
+ return visibleItemCount;
+}
+/**
+ * Returns the expanded state. Circumvent widget/thread check
+ * for performance. For non-API callers only.
+ */
+boolean internalGetExpanded() {
+ return isExpanded;
+}
+/**
+ * Answer whether the receiver is a leaf item.
+ * An item is a leaf when it has no child items.
+ * @return
+ * true - receiver is a leaf item
+ * false - receiver is not a leaf item.
+ */
+boolean isLeaf() {
+ return (getChildren().size() == 0);
+}
+/**
+ * Answer whether the receiver is a root item.
+ * The receiver is a root item when it doesn't have a parent item.
+ * @return
+ * true - the receiver is a root item.
+ * false - the receiver is not a root item.
+ */
+boolean isRoot() {
+ return false;
+}
+/**
+ * Remove 'child' from the receiver.
+ * Notify the parent widget only if it is not being disposed itself.
+ */
+void removeItem(SelectableItem child) {
+ Vector children = getChildren();
+ SelectableItemWidget parent = getSelectableParent();
+ int childIndex = children.indexOf(child);
+
+ if (childIndex != -1) {
+ if (((Tree) parent).isRemovingAll() == true) {
+ children.removeElementAt(childIndex); // just remove the item from the list if the whole tree is being disposed
+ if (isExpanded == true) {
+ visibleItemCount--;
+ calculateVisibleItemCountParent();
+ }
+ }
+ else {
+ parent.removingItem(child);
+ children.removeElementAt(childIndex);
+ if (isExpanded == true) {
+ visibleItemCount--;
+ calculateVisibleItemCountParent();
+ }
+ resetChildIndices(childIndex, false); // mark child index dirty
+ parent.removedItem(child);
+ }
+ }
+}
+/**
+ * Allow subclasses to reset any cached data.
+ * Called for all children of the receiver.
+ */
+void reset() {
+ Enumeration children = getChildren().elements();
+ AbstractTreeItem treeItem;
+
+ while (children.hasMoreElements() == true) {
+ treeItem = (AbstractTreeItem) children.nextElement();
+ treeItem.reset();
+ }
+}
+/**
+ * Mark all child indices dirty starting with the child at
+ * 'startIndex'. This causes getIndex to recalculate the index.
+ * @param startIndex - index in the list of children at which
+ * and after which the indices are reset.
+ */
+void resetChildIndices(int startIndex, boolean addItem) {
+ Vector children = getChildren();
+ TreeItem child;
+ int increment = addItem ? 1 : 0;
+
+ for (int i = startIndex; i < children.size(); i++) {
+ child = (TreeItem) children.elementAt(i);
+ child.setIndex(i + increment); // mark child index dirty
+ }
+}
+/**
+ * Select the receiver and all children.
+ * Return a Vector containing all the items that have been selected
+ * (and that have not been selected before).
+ */
+Vector selectAll(Vector selectedItems) {
+ Enumeration children = getChildren().elements();
+ AbstractTreeItem treeItem;
+
+ if (isSelected() == false) {
+ selectedItems.addElement(this);
+ setSelected(true);
+ getSelectableParent().redrawSelection(this);
+ }
+ while (children.hasMoreElements() == true) {
+ treeItem = (AbstractTreeItem) children.nextElement();
+ selectedItems = treeItem.selectAll(selectedItems);
+ }
+ return selectedItems;
+}
+/**
+ * Set the Array containing the receiver's child items to 'children'.
+ */
+void setChildren(Vector children) {
+ this.children = children;
+}
+
+void setVisibleItemCount(int count) {
+ visibleItemCount = count;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java
new file mode 100755
index 0000000000..92992ee18a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java
@@ -0,0 +1,337 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public /*final*/ class Button extends Control {
+ Image image;
+
+public Button (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+ style = checkBits (style, SWT.PUSH, SWT.ARROW, SWT.CHECK, SWT.RADIO, SWT.TOGGLE, 0);
+ if ((style & SWT.PUSH) != 0) {
+ return checkBits (style, SWT.CENTER, SWT.LEFT, SWT.RIGHT, 0, 0, 0);
+ }
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) != 0) {
+ return checkBits (style, SWT.LEFT, SWT.RIGHT, SWT.CENTER, 0, 0, 0);
+ }
+ if ((style & SWT.ARROW) != 0) {
+ return checkBits (style, SWT.UP, SWT.DOWN, SWT.LEFT, SWT.RIGHT, 0, 0);
+ }
+ return style;
+}
+
+public void addSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+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.ARROW) != 0) {
+ if (wHint != SWT.DEFAULT) width += wHint;
+ else width = 17;
+ if (hHint != SWT.DEFAULT) height += hHint;
+ else height = 17;
+ 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;
+ if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ 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;
+ }
+ return new Point (width, height);
+}
+
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int parentHandle = parent.handle;
+
+ /* ARROW button */
+ if ((style & SWT.ARROW) != 0) {
+ int [] args = {
+ OS.Pt_ARG_BASIC_FLAGS, OS.Pt_HORIZONTAL_GRADIENT, OS.Pt_STATIC_GRADIENT | OS.Pt_HORIZONTAL_GRADIENT,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (display.PtButton, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ return;
+ }
+
+ /* Compute alignment */
+ int alignment = OS.Pt_LEFT;
+ if ((style & SWT.CENTER) != 0) alignment = OS.Pt_CENTER;
+ if ((style & SWT.RIGHT) != 0) alignment = OS.Pt_RIGHT;
+
+ /* CHECK or RADIO button */
+ if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
+ int [] args = {
+ OS.Pt_ARG_HORIZONTAL_ALIGNMENT, alignment, 0,
+ OS.Pt_ARG_INDICATOR_TYPE, (style & SWT.CHECK) != 0 ? OS.Pt_N_OF_MANY : OS.Pt_ONE_OF_MANY, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+
+ handle = OS.PtCreateWidget (display.PtToggleButton, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ return;
+ }
+
+ /* PUSH or TOGGLE button */
+ int [] args = {
+ OS.Pt_ARG_FLAGS, (style & SWT.TOGGLE) != 0 ? OS.Pt_TOGGLE : 0, OS.Pt_TOGGLE,
+ OS.Pt_ARG_HORIZONTAL_ALIGNMENT, alignment, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (display.PtButton, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+public int getAlignment () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.ARROW) != 0) {
+ if ((style & SWT.UP) != 0) return SWT.UP;
+ if ((style & SWT.DOWN) != 0) return SWT.DOWN;
+ if ((style & SWT.LEFT) != 0) return SWT.LEFT;
+ if ((style & SWT.RIGHT) != 0) return SWT.RIGHT;
+ return SWT.UP;
+ }
+ if ((style & SWT.LEFT) != 0) return SWT.LEFT;
+ if ((style & SWT.CENTER) != 0) return SWT.CENTER;
+ if ((style & SWT.RIGHT) != 0) return SWT.RIGHT;
+ return SWT.LEFT;
+}
+
+public Image getImage () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return image;
+}
+
+public boolean getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
+ int [] args = {OS.Pt_ARG_FLAGS, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return (args [1] & OS.Pt_SET) != 0;
+}
+
+String getNameText () {
+ return getText ();
+}
+
+public String getText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.ARROW) != 0) return "";
+ int [] args = {
+ OS.Pt_ARG_TEXT_STRING, 0, 0,
+ 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);
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_ACTIVATE, windowProc, SWT.Selection);
+}
+
+int processPaint (int damage) {
+ if ((style & SWT.ARROW) != 0) {
+ OS.PtSuperClassDraw (OS.PtButton (), handle, damage);
+ PhRect_t rect = new PhRect_t ();
+ OS.PtCalcCanvas (handle, rect);
+ int flags = 0;
+ if ((style & SWT.RIGHT) != 0) flags = 2;
+ if ((style & SWT.LEFT) != 0) flags = 1;
+ if ((style & SWT.DOWN) != 0) flags = 8;
+ if ((style & SWT.UP) != 0) flags = 4;
+ OS.PgDrawArrow (rect, (short)0, 0x000000, flags);
+ } else if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
+ OS.PtSuperClassDraw (OS.PtToggleButton (), handle, damage);
+ } else {
+ OS.PtSuperClassDraw (OS.PtButton (), handle, damage);
+ }
+ return super.processPaint (damage);
+}
+
+int processSelection (int info) {
+ if ((style & SWT.RADIO) != 0) {
+ if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) selectRadio ();
+ }
+ postEvent (SWT.Selection);
+ return OS.Pt_CONTINUE;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ image = null;
+}
+
+public void removeSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+void selectRadio () {
+ Control [] children = parent._getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (this != child && child instanceof Button) {
+ Button button = (Button) child;
+ if ((button.style & SWT.RADIO) != 0) {
+ if (button.getSelection ()) {
+ button.setSelection (false);
+ button.postEvent (SWT.Selection);
+ }
+ }
+ }
+ }
+ setSelection (true);
+}
+
+public void setAlignment (int alignment) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.ARROW) != 0) {
+ if ((style & (SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT)) == 0) return;
+ style &= ~(SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT);
+ style |= alignment & (SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT);
+ OS.PtDamageWidget (handle);
+ return;
+ }
+ if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return;
+ style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+ style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+ int [] args = {OS.Pt_ARG_HORIZONTAL_ALIGNMENT, OS.Pt_LEFT, 0};
+ if ((style & SWT.CENTER) != 0) args [1] = OS.Pt_CENTER;
+ if ((style & SWT.RIGHT) != 0) args [1] = OS.Pt_RIGHT;
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setSelection (boolean selected) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
+ int [] args = {OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.ARROW) != 0) return;
+ this.image = image;
+ int imageHandle = 0;
+ if (image != null) imageHandle = copyPhImage (image.handle);
+ int [] args = {
+ OS.Pt_ARG_LABEL_IMAGE, imageHandle, 0,
+ OS.Pt_ARG_LABEL_TYPE, OS.Pt_IMAGE, 0
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ if (imageHandle != 0) OS.free (imageHandle);
+}
+
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.ARROW) != 0) return;
+ char [] text = new char [string.length ()];
+ string.getChars (0, text.length, text, 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];
+ j--;
+ }
+ }
+ while (j < text.length) text [j++] = 0;
+ byte [] buffer = Converter.wcsToMbcs (null, text, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int ptr2 = 0;
+ if (mnemonic != 0) {
+ byte [] buffer2 = Converter.wcsToMbcs (null, new char []{mnemonic}, true);
+ ptr2 = OS.malloc (buffer2.length);
+ OS.memmove (ptr2, buffer2, buffer2.length);
+ }
+ int [] args = {
+ OS.Pt_ARG_TEXT_STRING, ptr, 0,
+ OS.Pt_ARG_LABEL_TYPE, OS.Pt_Z_STRING, 0,
+ OS.Pt_ARG_ACCEL_KEY, ptr2, 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ OS.free (ptr);
+ OS.free (ptr2);
+}
+
+}
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
new file mode 100755
index 0000000000..1eff950532
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java
@@ -0,0 +1,180 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.photon.*;
+
+public class Canvas extends Composite {
+ Caret caret;
+
+Canvas () {
+ /* Do nothing */
+}
+
+public Canvas (Composite parent, int style) {
+ super (parent, style);
+}
+
+public Caret getCaret () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return caret;
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddEventHandler (handle, OS.Ph_EV_DRAG, windowProc, SWT.MouseMove);
+}
+
+int processFocusIn (int info) {
+ int result = super.processFocusIn (info);
+ if (caret != null) caret.setFocus ();
+ return result;
+}
+int processFocusOut (int info) {
+ int result = super.processFocusOut (info);
+ if (caret != null) caret.killFocus ();
+ return result;
+}
+
+int processPaint (int callData) {
+ boolean isVisible = caret != null && caret.isVisible ();
+ if (isVisible) caret.hideCaret ();
+ int result = super.processPaint (callData);
+ if (isVisible) caret.showCaret ();
+ return result;
+}
+
+int processMouse (int info) {
+ /*
+ * Bug in Photon. Despite the fact that we are returning
+ * Pt_END when a button is pressed, for some reason, the
+ * single-line text widget does not end the processing and
+ * the callback is sent to the parent. This causes us to
+ * call PhInitDrag () which interferes with drag selection
+ * in the text widget. The fix is to only call PhInitDrag ()
+ * when there are no children.
+ */
+ if (OS.PtWidgetChildFront (handle) != 0) {
+ return super.processMouse (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.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);
+ PhRect_t rect = new PhRect_t ();
+ PhPoint_t pos = new PhPoint_t();
+ pos.x = pe.pos_x;
+ pos.y = pe.pos_y;
+ 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);
+ 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);
+ }
+ return super.processMouse (info);
+}
+
+public void redraw () {
+ boolean isVisible = caret != null && caret.isVisible ();
+ if (isVisible) caret.hideCaret ();
+ super.redraw ();
+ if (isVisible) caret.showCaret ();
+}
+
+public void redraw (int x, int y, int width, int height, boolean all) {
+ boolean isVisible = caret != null && caret.isVisible ();
+ if (isVisible) caret.hideCaret ();
+ super.redraw (x, y, width, height, all);
+ if (isVisible) caret.showCaret ();
+}
+
+void releaseWidget () {
+ if (caret != null) {
+ caret.releaseWidget ();
+ caret.releaseHandle ();
+ }
+ caret = null;
+ super.releaseWidget();
+}
+
+public void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (width <= 0 || height <= 0) return;
+ int deltaX = destX - x, deltaY = destY - y;
+ if (deltaX == 0 && deltaY == 0) return;
+ 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);
+ }
+ if (isVisible) caret.showCaret ();
+}
+
+void setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ boolean isVisible = (caret != null) && (caret.isVisible ());
+ if (isVisible) caret.hideCaret ();
+ super.setBounds (x, y, width, height, move, resize);
+ if (isVisible) caret.showCaret ();
+}
+
+public void setCaret (Caret caret) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Caret newCaret = caret;
+ Caret oldCaret = this.caret;
+ this.caret = newCaret;
+ if (isFocusControl ()) {
+ if (oldCaret != null) oldCaret.killFocus ();
+ if (newCaret != null) newCaret.setFocus ();
+ }
+}
+
+} \ 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
new file mode 100755
index 0000000000..858ff99e8c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java
@@ -0,0 +1,222 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public /*final*/ class Caret extends Widget {
+ Canvas parent;
+ int x, y, width, height;
+ boolean moved, resized;
+ boolean isVisible, isShowing;
+// int blinkRate = 500;
+
+public Caret (Canvas parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ createWidget (0);
+}
+
+//boolean blinkCaret () {
+// if (!isVisible) return true;
+// if (!isShowing) return showCaret ();
+// if (blinkRate == 0) return true;
+// return hideCaret ();
+//}
+
+void createWidget (int index) {
+ super.createWidget (index);
+ isVisible = true;
+ if (parent.getCaret () == null) {
+ parent.setCaret (this);
+ }
+}
+
+boolean drawCaret () {
+ if (parent == null) return false;
+ if (parent.isDisposed ()) return false;
+ int handle = parent.handle;
+ if (!OS.PtWidgetIsRealized (handle)) return false;
+ int phGC = OS.PgCreateGC (0); // NOTE: PgCreateGC ignores the parameter
+ if (phGC == 0) return false;
+ int [] args = {OS.Pt_ARG_COLOR, 0, 0, OS.Pt_ARG_FILL_COLOR, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int foreground = args [1];
+ int background = args [4];
+ int color = foreground ^ ~background;
+ int prevContext = OS.PgSetGC (phGC);
+ OS.PgSetRegion (OS.PtWidgetRid (handle));
+ OS.PgSetDrawMode (OS.Pg_DRAWMODE_XOR);
+ OS.PgSetFillColor (color);
+ int nWidth = width;
+ if (nWidth <= 0) nWidth = 2;
+ OS.PgDrawIRect (x, y, x + nWidth - 1, y + height - 1, OS.Pg_DRAW_FILL);
+ OS.PgSetGC (prevContext);
+ OS.PgDestroyGC (phGC);
+ return true;
+}
+
+public Rectangle getBounds () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return new Rectangle (x, y, width, height);
+}
+
+public Display getDisplay () {
+ Composite parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
+public Font getFont () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getFont ();
+}
+
+public Point getLocation () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return new Point (x, y);
+}
+
+public Canvas getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
+
+public Point getSize () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return new Point (width, height);
+}
+
+public boolean getVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return isVisible;
+}
+
+boolean hideCaret () {
+// Display display = getDisplay ();
+// if (display.currentCaret != this) return false;
+ if (!isShowing) return true;
+ isShowing = false;
+ return drawCaret ();
+}
+
+public boolean isVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return isVisible && parent.isVisible () && parent.hasFocus ();
+}
+
+void killFocus () {
+// Display display = getDisplay ();
+// if (display.currentCaret != this) return;
+ if (isVisible) hideCaret ();
+// display.setCurrentCaret (null);
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ if (this == parent.getCaret ()) parent.setCaret (null);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+// Display display = getDisplay ();
+// if (display.currentCaret == this) {
+// if (isVisible) hideCaret ();
+// display.setCurrentCaret (null);
+// }
+ parent = null;
+}
+
+public void setBounds (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ boolean samePosition, sameExtent, showing;
+ samePosition = (this.x == x) && (this.y == y);
+ sameExtent = (this.width == width) && (this.height == height);
+ if ((samePosition) && (sameExtent)) return;
+ if (showing = isShowing) hideCaret ();
+ this.x = x; this.y = y;
+ this.width = width; this.height = height;
+ if (sameExtent) {
+ moved = true;
+ if (isVisible ()) {
+ moved = false;
+ }
+ } else {
+ resized = true;
+ if (isVisible ()) {
+ moved = false;
+ resized = false;
+ }
+ }
+ if (showing) showCaret ();
+}
+
+void setFocus () {
+// Display display = getDisplay ();
+// if (display.currentCaret == this) return;
+// display.setCurrentCaret (this);
+ if (isVisible) showCaret ();
+}
+
+public void setFont (Font font) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+
+public void setLocation (int x, int y) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setBounds (x, y, width, height);
+}
+
+public void setLocation (Point location) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setLocation (location.x, location.y);
+}
+
+public void setSize (int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setBounds (x, y, width, height);
+}
+
+public void setSize (Point size) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setSize (size.x, size.y);
+}
+
+public void setVisible (boolean visible) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (visible == isVisible) return;
+ if (isVisible = visible) {
+ showCaret ();
+ } else {
+ hideCaret ();
+ }
+}
+
+boolean showCaret () {
+// if (getDisplay ().currentCaret != this) return false;
+ if (isShowing) return true;
+ 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
new file mode 100755
index 0000000000..15d71cf99d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java
@@ -0,0 +1,51 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public /*final*/ class ColorDialog extends Dialog {
+ RGB rgb;
+
+public ColorDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+
+public ColorDialog (Shell parent, int style) {
+ super (parent, style);
+}
+
+public RGB getRGB () {
+ return rgb;
+}
+
+public RGB open () {
+ int parentHandle = 0;
+ if (parent != null) parentHandle = parent.shellHandle;
+ byte[] title = null;
+ if (this.title != null) title = Converter.wcsToMbcs (null, this.title, true);
+ PtColorSelectInfo_t info = new PtColorSelectInfo_t();
+ info.flags = OS.Pt_COLORSELECT_MODAL;
+ if (rgb != null) info.rgb = (rgb. blue & 0xFF) | ((rgb.green & 0xFF) << 8) | ((rgb.red & 0xFF) << 16);
+ rgb = null;
+
+ OS.PtColorSelect(parentHandle, title, info);
+
+ if ((info.flags & OS.Pt_COLORSELECT_ACCEPT) != 0) {
+ int color = info.rgb;
+ rgb = new RGB ((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, color & 0xFF);
+ }
+ return rgb;
+}
+
+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
new file mode 100755
index 0000000000..9b3723f87f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java
@@ -0,0 +1,497 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public class Combo extends Composite {
+
+public Combo (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+ /*
+ * Feature in Windows. It is not possible to create
+ * a combo box that has a border using Windows style
+ * bits. All combo boxes draw their own border and
+ * do not use the standard Windows border styles.
+ * Therefore, no matter what style bits are specified,
+ * clear the BORDER bits so that the SWT style will
+ * match the Windows widget.
+ *
+ * The Windows behavior is currently implemented on
+ * all platforms.
+ */
+ style &= ~SWT.BORDER;
+
+ /*
+ * Even though it is legal to create this widget
+ * with scroll bars, they serve no useful purpose
+ * because they do not automatically scroll the
+ * widget's client area. The fix is to clear
+ * the SWT style.
+ */
+ style &= ~(SWT.H_SCROLL | SWT.V_SCROLL);
+ style = checkBits (style, SWT.DROP_DOWN, SWT.SIMPLE, 0, 0, 0, 0);
+ if ((style & SWT.SIMPLE) != 0) return style & ~SWT.READ_ONLY;
+ return 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);
+ //NOT DONE: this only works with a DROP_DOWN combo
+ if ((style & SWT.SIMPLE) != 0) return new Point(100, 100);
+ PhDim_t dim = new PhDim_t();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
+ OS.PtWidgetPreferredSize(handle, dim);
+ int width = dim.w;
+ int height = dim.h;
+ int text = OS.PtWidgetChildBack(handle);
+ OS.PtWidgetPreferredSize(text, dim);
+ height += dim.h;
+ PhRect_t rect = new PhRect_t ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtSetAreaFromWidgetCanvas (text, rect, area);
+ width += area.size_w;
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
+ OS.Pt_ARG_ITEMS, 0, 0,
+ OS.Pt_ARG_TEXT_FONT, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ int maxWidth = 0;
+ rect = new PhRect_t();
+ int [] items = new int [1];
+ for (int i = 0; i < args [1]; i++) {
+ OS.memmove (items, args [4] + (i * 4), 4);
+ int length = OS.strlen (items [0]);
+ OS.PfExtentText(rect, null, args [7], items [0], length);
+ maxWidth = Math.max(maxWidth, rect.lr_x - rect.ul_x + 1);
+ }
+ width += maxWidth;
+ if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ rect = new PhRect_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;
+ }
+ return new Point(width, height);
+}
+
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int clazz = display.PtComboBox;
+ int parentHandle = parent.handle;
+ int textFlags = (style & SWT.READ_ONLY) != 0 ? 0 : OS.Pt_EDITABLE;
+ int [] args = {
+ OS.Pt_ARG_TEXT_FLAGS, textFlags, OS.Pt_EDITABLE,
+ OS.Pt_ARG_CBOX_MAX_VISIBLE_COUNT, 5, 0,
+ OS.Pt_ARG_CBOX_FLAGS, (style & SWT.SIMPLE) != 0 ? OS.Pt_COMBOBOX_STATIC: 0, OS.Pt_COMBOBOX_STATIC,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+public void deselect (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_CBOX_SELECTION_ITEM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] == index) {
+ args = new int [] {
+ OS.Pt_ARG_TEXT_STRING, 0, 0,
+ OS.Pt_ARG_CBOX_SELECTION_ITEM, 0, 0
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ }
+}
+
+public void deselectAll () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {
+ OS.Pt_ARG_TEXT_STRING, 0, 0,
+ OS.Pt_ARG_CBOX_SELECTION_ITEM, 0, 0
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void add (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ OS.PtListAddItems (handle, new int [] {ptr}, 1, 0);
+ OS.free (ptr);
+}
+
+public void add (String string, int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (index == -1) error (SWT.ERROR_INVALID_RANGE);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int result = OS.PtListAddItems (handle, new int [] {ptr}, 1, index + 1);
+ OS.free (ptr);
+ if (result != 0) {
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (0 <= index && index <= args [1]) error (SWT.ERROR_ITEM_NOT_ADDED);
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+}
+
+public void addModifyListener (ModifyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Modify, typedListener);
+}
+
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+public void clearSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ OS.PtTextSetSelection (handle, new int [] {0}, new int [] {0});
+}
+
+public String getItem (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
+ OS.Pt_ARG_ITEMS, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 <= index && index < args [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ int [] items = new int [1];
+ OS.memmove (items, args [4] + (index * 4), 4);
+ int length = OS.strlen (items [0]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, items [0], length);
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ return new String (unicode);
+}
+
+public int getItemCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getItemHeight () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE - NOT NEEDED
+ return 0;
+}
+
+public String [] getItems () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
+ OS.Pt_ARG_ITEMS, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ int [] items = new int [args [1]];
+ OS.memmove (items, args [4], args [1] * 4);
+ String [] result = new String [args [1]];
+ for (int i=0; i<args [1]; i++) {
+ int length = OS.strlen (items [i]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, items [i], length);
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ result [i] = new String (unicode);
+ }
+ return result;
+
+}
+
+public Point getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (((style & SWT.DROP_DOWN) != 0) && ((style & SWT.READ_ONLY) != 0)) {
+ int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int length = 0;
+ if (args [1] != 0) length = OS.strlen (args [1]);
+ return new Point (0, length);
+ }
+// if (textVerify != null) {
+// return new Point (textVerify.start_pos, textVerify.end_pos);
+// }
+ int [] start = new int [1], end = new int [1];
+ OS.PtTextGetSelection (handle, start, end);
+ if (start [0] == -1) {
+ int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ start [0] = end [0] = args [1];
+ }
+ return new Point (start [0], end [0]);
+}
+
+public int getSelectionIndex () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_CBOX_SELECTION_ITEM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] == 0) return -1;
+ return args [1] - 1;
+}
+
+public String getText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] == 0) return "";
+ int length = OS.strlen (args [1]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, args [1], length);
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ return new String (unicode);
+}
+
+public int getTextHeight () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE - Only works for DROP_DOWN
+ PhDim_t dim = new PhDim_t();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
+ OS.PtWidgetPreferredSize(handle, dim);
+ int height = dim.h;
+ int text = OS.PtWidgetChildBack(handle);
+ OS.PtWidgetPreferredSize(text, dim);
+ height += dim.h;
+ return height;
+}
+
+public int getTextLimit () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_SELECTION, windowProc, SWT.Selection);
+ OS.PtAddCallback (handle, OS.Pt_CB_TEXT_CHANGED, windowProc, SWT.Modify);
+}
+
+public int indexOf (String string) {
+ if (!isValidThread ()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error(SWT.ERROR_WIDGET_DISPOSED);
+ return indexOf (string, 0);
+}
+
+public int indexOf (String string, int start) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ // NOT DONE - start is ignored
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ return OS.PtListItemPos(handle, buffer) - 1;
+}
+
+int processModify (int info) {
+ sendEvent (SWT.Modify);
+ return OS.Pt_CONTINUE;
+}
+
+int processPaint (int damage) {
+ OS.PtSuperClassDraw (OS.PtComboBox (), handle, damage);
+ sendPaintEvent (damage);
+ return OS.Pt_CONTINUE;
+}
+
+int processSelection (int info) {
+ if (info == 0) return OS.Pt_CONTINUE;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.reason_subtype == OS.Pt_LIST_SELECTION_FINAL) {
+ postEvent(SWT.Selection);
+ }
+ return OS.Pt_CONTINUE;
+}
+
+public void remove (int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 < start && start <= end && end < args [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ int count = end - start + 1;
+ int result = OS.PtListDeleteItemPos (handle, count, start + 1);
+ if (result != 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
+}
+
+public void remove (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 <= index && index < args [1])) error (SWT.ERROR_INVALID_RANGE);
+ int result = OS.PtListDeleteItemPos (handle, 1, index + 1);
+ if (result != 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
+}
+
+public void remove (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int index = indexOf (string, 0);
+ if (index == -1) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ remove (index);
+}
+
+public void removeAll () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ OS.PtListDeleteAllItems (handle);
+}
+
+public void removeModifyListener (ModifyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Modify, listener);
+}
+
+public void removeSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+public void select (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (index < 0) return;
+ int [] args = new int [] {OS.Pt_ARG_CBOX_SELECTION_ITEM, index + 1, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+void setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int newHeight = ((style & SWT.DROP_DOWN) != 0) ? getTextHeight() : height;
+ super.setBounds (x, y, width, newHeight, move, resize);
+}
+
+public void setItem (int index, String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 <= index && index < args [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ OS.PtListReplaceItemPos (handle, new int [] {ptr}, 1, index + 1);
+ OS.free (ptr);
+}
+
+public void setItems (String [] items) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+ OS.PtListDeleteAllItems (handle);
+ int[] itemsPtr = new int [items.length];
+ for (int i=0; i<itemsPtr.length; i++) {
+ byte [] buffer = Converter.wcsToMbcs (null, items [i], true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ itemsPtr [i] = ptr;
+ }
+ OS.PtListAddItems (handle, itemsPtr, itemsPtr.length, 0);
+ for (int i=0; i<itemsPtr.length; i++) {
+ OS.free (itemsPtr [i]);
+ }
+ int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setSelection (Point selection) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
+ OS.PtTextSetSelection (handle, new int [] {selection.x}, new int [] {selection.y});
+}
+
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ if ((style & SWT.READ_ONLY) != 0) {
+ int index = OS.PtListItemPos(handle, buffer);
+ if (index > 0) {
+ int [] args = new int [] {OS.Pt_ARG_CBOX_SELECTION_ITEM, index, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+// sendEvent (SWT.Modify);
+ }
+ return;
+ }
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int [] args = {OS.Pt_ARG_TEXT_STRING, ptr, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+ OS.free (ptr);
+}
+
+public void setTextLimit (int limit) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
+ int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, limit, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+} \ No newline at end of file
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
new file mode 100755
index 0000000000..40fc195c5a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java
@@ -0,0 +1,258 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public class Composite extends Scrollable {
+ Layout layout;
+
+Composite () {
+ /* Do nothing */
+}
+
+public Composite (Composite parent, int style) {
+ super (parent, style);
+}
+
+Control [] _getChildren () {
+ int count = 0;
+ int child = OS.PtWidgetChildFront (handle);
+ while (child != 0) {
+ child = OS.PtWidgetBrotherBehind (child);
+ count++;
+ }
+ Control [] children = new Control [count];
+ int i = 0, j = 0;
+ child = OS.PtWidgetChildFront (handle);
+ while (i < count) {
+ Widget widget = WidgetTable.get (child);
+ if (widget != null && widget != this) {
+ if (widget instanceof Control) {
+ children [j++] = (Control) widget;
+ }
+ }
+ i++;
+ child = OS.PtWidgetBrotherBehind (child);
+ }
+ if (i == j) return children;
+ Control [] newChildren = new Control [j];
+ System.arraycopy (children, 0, newChildren, 0, j);
+ return newChildren;
+}
+
+protected void checkSubclass () {
+ /* Do nothing - Subclassing is allowed */
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Point size;
+ if (layout != null) {
+ if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
+ size = layout.computeSize (this, wHint, hHint, changed);
+ } else {
+ size = new Point (wHint, hHint);
+ }
+ } else {
+ size = minimumSize ();
+ }
+ if (size.x == 0) size.x = DEFAULT_WIDTH;
+ if (size.y == 0) size.y = DEFAULT_HEIGHT;
+ if (wHint != SWT.DEFAULT) size.x = wHint;
+ if (hHint != SWT.DEFAULT) size.y = hHint;
+ Rectangle trim = computeTrim (0, 0, size.x, size.y);
+ return new Point (trim.width, trim.height);
+}
+
+void createHandle (int index) {
+ int parentHandle = parent.handle;
+ createScrolledHandle (parentHandle);
+}
+
+void createScrollBars () {
+ if (scrolledHandle == 0) return;
+ if ((style & SWT.H_SCROLL) != 0) {
+ horizontalBar = new ScrollBar (this, SWT.HORIZONTAL);
+ }
+ if ((style & SWT.V_SCROLL) != 0) {
+ verticalBar = new ScrollBar (this, SWT.VERTICAL);
+ }
+}
+
+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_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ scrolledHandle = OS.PtCreateWidget (OS.PtContainer (), parentHandle, 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_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 Control [] getChildren () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return _getChildren ();
+}
+
+int getChildrenCount () {
+ int count = 0;
+ int child = OS.PtWidgetChildFront (handle);
+ while (child != 0) {
+ child = OS.PtWidgetBrotherBehind (child);
+ count++;
+ }
+ return count;
+}
+
+public Layout getLayout () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return layout;
+}
+
+boolean hasBorder () {
+ return (style & SWT.BORDER) != 0;
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_RESIZE, windowProc, SWT.Resize);
+}
+
+public void layout () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ layout (true);
+}
+
+Point minimumSize () {
+ Control [] children = _getChildren ();
+ int width = 0, height = 0;
+ for (int i=0; i<children.length; i++) {
+ Rectangle rect = children [i].getBounds ();
+ width = Math.max (width, rect.x + rect.width);
+ height = Math.max (height, rect.y + rect.height);
+ }
+ return new Point (width, height);
+}
+
+public void layout (boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (layout == null) return;
+ int count = getChildrenCount ();
+ if (count == 0) return;
+ layout.layout (this, changed);
+}
+
+int processPaint (int damage) {
+ OS.PtSuperClassDraw (OS.PtContainer (), handle, damage);
+ return super.processPaint (damage);
+}
+
+int processResize (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;
+ sendEvent (SWT.Resize);
+ if (layout != null) layout (false);
+ return OS.Pt_CONTINUE;
+}
+
+void releaseWidget () {
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (!child.isDisposed ()) {
+ child.releaseWidget ();
+ child.releaseHandle ();
+ }
+ }
+ super.releaseWidget ();
+}
+
+void resizeClientArea () {
+ int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (scrolledHandle, args.length / 3, args);
+ resizeClientArea (args [1], args [4]);
+}
+
+boolean sendResize () {
+ return false;
+}
+
+void resizeClientArea (int width, int height) {
+ 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};
+ OS.PtGetResources (horizontalBar.handle, args.length / 3, args);
+ height = height - (hBarHeight = args [1]);
+ }
+ if (isVisibleVBar) {
+ int [] args = {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;
+ }
+ if (isVisibleHBar) {
+ horizontalBar.setBounds (-left, height - left, width + right, hBarHeight);
+ }
+ if (isVisibleVBar) {
+ verticalBar.setBounds (width - left, -left, vBarWidth, height + right);
+ }
+
+ 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};
+ 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);
+}
+
+public void setLayout (Layout layout) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ this.layout = layout;
+}
+
+} \ No newline at end of file
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
new file mode 100755
index 0000000000..079c6efd82
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java
@@ -0,0 +1,991 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.*;
+
+public abstract class Control extends Widget implements Drawable {
+ Composite parent;
+ Menu menu;
+ Object layoutData;
+
+Control () {
+ /* Do nothing */
+}
+
+public Control (Composite parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ createWidget (0);
+}
+
+public void addControlListener(ControlListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Resize,typedListener);
+ addListener (SWT.Move,typedListener);
+}
+
+public void addFocusListener (FocusListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.FocusIn,typedListener);
+ addListener (SWT.FocusOut,typedListener);
+}
+
+public void addHelpListener (HelpListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Help, typedListener);
+}
+
+public void addKeyListener (KeyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.KeyUp,typedListener);
+ addListener (SWT.KeyDown,typedListener);
+}
+
+public void addMouseListener (MouseListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.MouseDown,typedListener);
+ addListener (SWT.MouseUp,typedListener);
+ addListener (SWT.MouseDoubleClick,typedListener);
+}
+
+public void addMouseTrackListener (MouseTrackListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.MouseEnter,typedListener);
+ addListener (SWT.MouseExit,typedListener);
+ addListener (SWT.MouseHover,typedListener);
+}
+
+public void addMouseMoveListener (MouseMoveListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.MouseMove,typedListener);
+}
+
+public void addPaintListener (PaintListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Paint,typedListener);
+}
+
+public void addTraverseListener (TraverseListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Traverse,typedListener);
+}
+
+public boolean forceFocus () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int shellHandle = OS.PtFindDisjoint (handle);
+ OS.PtWindowToFront (shellHandle);
+ return handle != OS.PtContainerGiveFocus (handle, null);
+}
+
+public Point computeSize (int wHint, int hHint) {
+ return computeSize (wHint, hHint, true);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int width = DEFAULT_WIDTH;
+ int height = DEFAULT_HEIGHT;
+ if (wHint != SWT.DEFAULT) width = wHint;
+ if (hHint != SWT.DEFAULT) height = hHint;
+ int border = getBorderWidth ();
+ width += border * 2;
+ height += border * 2;
+ return new Point (width, height);
+}
+
+void createWidget (int index) {
+ super.createWidget (index);
+ setZOrder ();
+ realizeWidget ();
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.TEXT_FONT;
+}
+
+public Color getBackground () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_FILL_COLOR, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return Color.photon_new (getDisplay (), args [1]);
+}
+public Font getFont () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {
+ OS.Pt_ARG_TEXT_FONT, 0, 0,
+ OS.Pt_ARG_LIST_FONT, 0, 0,
+ OS.Pt_ARG_TITLE_FONT, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ byte [] font;
+ int ptr = args [1];
+ if (ptr == 0) ptr = args [4];
+ if (ptr == 0) ptr = args [7];
+ if (ptr == 0) {
+ font = defaultFont ();
+ } else {
+ int length = OS.strlen (ptr);
+ font = new byte [length + 1];
+ OS.memmove (font, ptr, length);
+ }
+ return Font.photon_new (getDisplay (), font);
+}
+public Color getForeground () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_COLOR, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return Color.photon_new (getDisplay (), args [1]);
+}
+
+public int getBorderWidth () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle = topHandle ();
+ int [] args = {
+ OS.Pt_ARG_BASIC_FLAGS, 0, 0,
+// OS.Pt_ARG_BEVEL_WIDTH, 0, 0,
+ };
+ OS.PtGetResources (topHandle, args.length / 3, args);
+ 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];
+ return border;
+}
+
+public Rectangle getBounds () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle = topHandle ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (topHandle, area);
+ return new Rectangle (area.pos_x, area.pos_y, area.size_w, area.size_h);
+}
+
+public Display getDisplay () {
+ Composite parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.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;
+}
+
+public Object getLayoutData () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return layoutData;
+}
+
+public Point getLocation () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle = topHandle ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (topHandle, area);
+ return new Point (area.pos_x, area.pos_y);
+}
+
+public Menu getMenu () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return null;
+}
+
+public Composite getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
+
+public Point getSize () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle = topHandle ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (topHandle, area);
+ return new Point (area.size_w, area.size_h);
+}
+
+public String getToolTipText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return null;
+}
+
+public Shell getShell () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getShell ();
+}
+
+public boolean getVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle = topHandle ();
+ int [] args = {OS.Pt_ARG_FLAGS, 0, 0};
+ OS.PtGetResources (topHandle, args.length / 3, args);
+ return (args [1] & OS.Pt_DELAY_REALIZE) == 0;
+}
+
+boolean hasFocus () {
+ return OS.PtIsFocused (handle) == 2;
+}
+
+void hookEvents () {
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddEventHandler (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);
+}
+
+public int internal_new_GC (GCData data) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ int phGC = OS.PgCreateGC(0); // NOTE: PgCreateGC ignores the parameter
+ if (phGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+
+ int [] args = {OS.Pt_ARG_COLOR, 0, 0, OS.Pt_ARG_FILL_COLOR, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ data.device = getDisplay ();
+ data.widget = handle;
+ data.topWidget = topHandle ();
+ data.foreground = args [1];
+ data.background = args [4];
+ data.font = getFont ().handle;
+ return phGC;
+}
+
+public void internal_dispose_GC (int phGC, GCData data) {
+ //if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ OS.PgDestroyGC(phGC);
+}
+
+public boolean isEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getEnabled () && parent.isEnabled ();
+}
+
+public boolean isFocusControl () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return hasFocus ();
+}
+
+public boolean isReparentable () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return false;
+}
+
+public boolean isVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return OS.PtWidgetIsRealized (handle);
+}
+
+Decorations menuShell () {
+ return parent.menuShell ();
+}
+
+public void moveAbove (Control control) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle1 = topHandle ();
+ if (control == null) {
+ OS.PtWidgetToFront (topHandle1);
+ OS.PtWindowToFront (topHandle1);
+ return;
+ }
+ int topHandle2 = control.topHandle ();
+ OS.PtWidgetInsert (topHandle1, topHandle2, 0);
+}
+
+public void moveBelow (Control control) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle1 = topHandle ();
+ if (control == null) {
+ OS.PtWidgetToBack (topHandle1);
+ OS.PtWindowToBack (topHandle1);
+ return;
+ }
+ int topHandle2 = control.topHandle ();
+ OS.PtWidgetInsert (topHandle1, topHandle2, 1);
+}
+
+public void pack () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ pack (true);
+}
+
+public void pack (boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed));
+}
+
+int processPaint (int damage) {
+ sendPaintEvent (damage);
+ return OS.Pt_CONTINUE;
+}
+
+int processFocusIn (int info) {
+ sendEvent (SWT.FocusIn);
+ /*
+ * Feature in Photon. Cannot return Pt_END
+ * or the text widget will not take focus.
+ */
+ return OS.Pt_CONTINUE;
+}
+
+int processFocusOut (int info) {
+ sendEvent (SWT.FocusOut);
+ /*
+ * Feature in Photon. Cannot return Pt_END
+ * or the text widget will not take focus.
+ */
+ return OS.Pt_CONTINUE;
+}
+
+int processKey (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);
+ int data = OS.PhGetData (cbinfo.event);
+ if (data == 0) return OS.Pt_END;
+ 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
+ * key press. The first event has only the scan code while
+ * the second has the keysym and other information. This
+ * also happens for key release. The fix is to ignore the
+ * first event.
+ */
+ if (ke.key_flags == OS.Pk_KF_Scan_Valid) {
+ return (cbinfo.reason == OS.Pt_CB_FILTER) ? OS.Pt_PROCESS : OS.Pt_END;
+ }
+ if ((ke.key_flags & OS.Pk_KF_Key_Repeat) != 0) {
+ if ((ke.key_flags & OS.Pk_KF_Sym_Valid) != 0) {
+ switch (ke.key_sym) {
+ case OS.Pk_Alt_L:
+ case OS.Pk_Alt_R:
+ case OS.Pk_Control_L:
+ 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;
+ }
+ }
+ }
+ Display display = getDisplay ();
+ Event event = new Event ();
+ event.time = ev.timestamp;
+ int type = SWT.KeyUp;
+ if ((ke.key_flags & (OS.Pk_KF_Key_Down | OS.Pk_KF_Key_Repeat)) != 0) {
+ type = SWT.KeyDown;
+ }
+ if ((ke.key_flags & OS.Pk_KF_Sym_Valid) != 0) {
+ event.keyCode = Display.translateKey (ke.key_sym);
+ if (event.keyCode == 0) {
+ switch (ke.key_sym) {
+ 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_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;
+ default:
+ event.character = (char) ke.key_sym;
+ }
+ }
+ 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;
+ 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;
+}
+
+int processMouse (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);
+ Event event = new Event ();
+ switch (ev.type) {
+ case OS.Ph_EV_BUT_PRESS:
+ event.type = SWT.MouseDown;
+ break;
+ case OS.Ph_EV_BUT_RELEASE:
+ if (ev.subtype != OS.Ph_EV_RELEASE_PHANTOM) {
+ return OS.Pt_END;
+ }
+ event.type = SWT.MouseUp;
+ break;
+ case OS.Ph_EV_PTR_MOTION_BUTTON:
+ case OS.Ph_EV_PTR_MOTION_NOBUTTON:
+ event.type = SWT.MouseMove;
+ break;
+ case OS.Ph_EV_DRAG:
+ if (ev.subtype != OS.Ph_EV_DRAG_MOTION_EVENT) {
+ return OS.Pt_END;
+ }
+ event.type = SWT.MouseMove;
+ break;
+ }
+ event.time = ev.timestamp;
+ 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);
+ 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) {
+ 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;
+ }
+ postEvent (event.type, event);
+ if (type == OS.Ph_EV_BUT_PRESS && click_count == 2) {
+ postEvent (SWT.MouseDoubleClick, event);
+ }
+ return OS.Pt_END;
+}
+
+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);
+ int rects = OS.PhGetRects (cbinfo.event);
+ PhRect_t rect = new PhRect_t ();
+ OS.memmove (rect, rects, PhRect_t.sizeof);
+ Event event = new Event ();
+ event.time = ev.timestamp;
+ event.x = rect.ul_x;
+ event.y = rect.ul_y;
+ switch (ev.subtype) {
+ case OS.Ph_EV_PTR_ENTER:
+ case OS.Ph_EV_PTR_ENTER_FROM_CHILD:
+ sendEvent (SWT.MouseEnter, event);
+ break;
+ case OS.Ph_EV_PTR_LEAVE:
+ case OS.Ph_EV_PTR_LEAVE_TO_CHILD:
+ sendEvent (SWT.MouseExit, event);
+ break;
+ }
+ return OS.Pt_END;
+}
+
+void realizeWidget() {
+ int parentHandle = parent.handle;
+ if (OS.PtWidgetIsRealized (parentHandle)) {
+ OS.PtRealizeWidget (topHandle ());
+ }
+}
+
+public void redraw () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ OS.PtDamageWidget (handle);
+}
+
+public void redraw (int x, int y, int width, int height, boolean allChildren) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ PhRect_t rect = new PhRect_t ();
+ rect.ul_x = (short) x;
+ rect.ul_y = (short) y;
+ rect.lr_x = (short) (x + width - 1);
+ rect.lr_y = (short) (y + height - 1);
+ OS.PtDamageExtent (handle, rect);
+}
+
+public void removeControlListener (ControlListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Move, listener);
+ eventTable.unhook (SWT.Resize, listener);
+}
+
+public void removeFocusListener(FocusListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.FocusIn, listener);
+ eventTable.unhook (SWT.FocusOut, listener);
+}
+
+public void removeHelpListener (HelpListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Help, listener);
+}
+
+public void removeKeyListener(KeyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.KeyUp, listener);
+ eventTable.unhook (SWT.KeyDown, listener);
+}
+
+public void removeMouseTrackListener(MouseTrackListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.MouseEnter, listener);
+ eventTable.unhook (SWT.MouseExit, listener);
+ eventTable.unhook (SWT.MouseHover, listener);
+}
+
+public void removeMouseListener (MouseListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.MouseDown, listener);
+ eventTable.unhook (SWT.MouseUp, listener);
+ eventTable.unhook (SWT.MouseDoubleClick, listener);
+}
+
+public void removeMouseMoveListener(MouseMoveListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.MouseMove, listener);
+}
+
+public void removePaintListener(PaintListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook(SWT.Paint, listener);
+}
+
+public void removeTraverseListener(TraverseListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Traverse, listener);
+}
+
+void setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ int topHandle = topHandle ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (topHandle, area);
+ boolean sameOrigin = x == area.pos_x && y == area.pos_y;
+ boolean sameExtent = width == area.size_w && height == area.size_h;
+ if (move && resize) {
+ area.pos_x = (short) x;
+ area.pos_y = (short) y;
+ 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 = {OS.Pt_ARG_AREA, ptr, 0};
+ OS.PtSetResources (topHandle, args.length / 3, args);
+ OS.free (ptr);
+ } else {
+ if (move) {
+ 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 (topHandle, args.length / 3, args);
+ OS.free (ptr);
+ }
+ if (resize) {
+ int [] args = {
+ OS.Pt_ARG_WIDTH, Math.max (width, 0), 0,
+ OS.Pt_ARG_HEIGHT, Math.max (height, 0), 0,
+ };
+ OS.PtSetResources (topHandle, args.length / 3, args);
+ }
+ }
+ if (!OS.PtWidgetIsRealized (topHandle)) {
+ OS.PtExtentWidgetFamily (topHandle);
+ }
+ if (!sameOrigin & move) sendEvent (SWT.Move);
+ if (!sameExtent & resize & sendResize()) sendEvent (SWT.Resize);
+}
+
+public void setBounds (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setBounds (x, y, width, height, true, true);
+}
+
+public void setBounds (Rectangle rect) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setBounds (rect.x, rect.y, rect.width, rect.height);
+}
+
+public void setCapture (boolean capture) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+
+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};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setEnabled (boolean enabled) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {
+ OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_BLOCKED, OS.Pt_BLOCKED,
+ OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_GHOST, OS.Pt_GHOST,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public boolean setFocus () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return forceFocus ();
+}
+
+void sendPaintEvent (int damage) {
+
+ if (!hooks(SWT.Paint)) return;
+
+ /* Translate the damage to widget coordinates */
+ short [] widgetX = new short [1];
+ short [] widgetY = new short [1];
+ OS.PtGetAbsPosition (handle, widgetX, widgetY);
+ short [] shellX = new short [1];
+ short [] shellY = new short [1];
+ int shellHandle = OS.PtFindDisjoint (handle);
+ OS.PtGetAbsPosition (shellHandle, shellX, shellY);
+ PhPoint_t pt = new PhPoint_t ();
+ pt.x = (short) (shellX [0] - widgetX [0]);
+ pt.y = (short) (shellY [0] - widgetY [0]);
+ damage = OS.PhCopyTiles (damage);
+ damage = OS.PhTranslateTiles (damage, pt);
+
+ /* 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 ();
+ OS.PhFreeTiles (damage);
+ event.gc = null;
+}
+
+boolean sendResize () {
+ return true;
+}
+
+public void setBackground (Color color) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int pixel = OS.Pt_DEFAULT_COLOR;
+ if (color != null) pixel = color.handle;
+ int [] args = {OS.Pt_ARG_FILL_COLOR, pixel, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setFont (Font font) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ byte [] buffer = (font != null) ? font.handle : defaultFont ();
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int [] args = {
+ OS.Pt_ARG_TEXT_FONT, ptr, 0,
+ OS.Pt_ARG_LIST_FONT, ptr, 0,
+ OS.Pt_ARG_TITLE_FONT, ptr, 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ OS.free (ptr);
+}
+
+public void setForeground (Color color) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int pixel = OS.Pt_DEFAULT_COLOR;
+ if (color != null) pixel = color.handle;
+ int [] args = {OS.Pt_ARG_COLOR, pixel, 0};
+ 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;
+}
+
+public void setLayoutData (Object layoutData) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ this.layoutData = layoutData;
+}
+
+public void setLocation (int x, int y) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setBounds (x, y, 0, 0, true, false);
+}
+
+public void setLocation (Point location) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setLocation (location.x, location.y);
+}
+
+public void setSize (Point size) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setSize (size.x, size.y);
+}
+public void setRedraw (boolean redraw) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (redraw) {
+ OS.PtContainerRelease (handle);
+ } else {
+ OS.PtContainerHold (handle);
+ }
+}
+public void setSize (int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setBounds (0, 0, width, height, false, true);
+}
+
+public void setVisible (boolean visible) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle = topHandle ();
+ int [] args = {
+ OS.Pt_ARG_FLAGS, visible ? 0 : OS.Pt_DELAY_REALIZE, OS.Pt_DELAY_REALIZE,
+ };
+ OS.PtSetResources (topHandle, args.length / 3, args);
+ if (visible) {
+ sendEvent (SWT.Show);
+ OS.PtRealizeWidget (topHandle);
+ } else {
+ OS.PtUnrealizeWidget (topHandle);
+ sendEvent(SWT.Hide);
+ }
+}
+
+public void setToolTipText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+
+void setZOrder() {
+ OS.PtWidgetToBack (topHandle ());
+}
+
+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);
+}
+
+public Point toDisplay (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 (point.x + x [0], point.y + y [0]);
+}
+
+public boolean traverse (int traversal) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return false;
+}
+
+public void update () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ OS.PtFlush ();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java
new file mode 100755
index 0000000000..80f4787cc6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java
@@ -0,0 +1,174 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public class Decorations extends Canvas {
+ Menu menuBar;
+ Menu [] menus;
+ String text = "";
+ Image image;
+
+Decorations () {
+ /* Do nothing */
+}
+
+public Decorations (Composite parent, int style) {
+ super (parent, style);
+}
+
+static int checkStyle (int style) {
+ if ((style & (SWT.MENU | SWT.MIN | SWT.MAX | SWT.CLOSE)) != 0) {
+ style |= SWT.TITLE;
+ }
+ return style;
+}
+
+void add (Menu menu) {
+ if (menus == null) menus = new Menu [4];
+ for (int i=0; i<menus.length; i++) {
+ if (menus [i] == null) {
+ menus [i] = menu;
+ return;
+ }
+ }
+ Menu [] newMenus = new Menu [menus.length + 4];
+ newMenus [menus.length] = menu;
+ System.arraycopy (menus, 0, newMenus, 0, menus.length);
+ menus = newMenus;
+}
+
+void bringToTop () {
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+public Button getDefaultButton () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return null;
+}
+
+public Image getImage () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return image;
+}
+
+public boolean getMaximized () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return false;
+}
+
+public boolean getMinimized () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return false;
+}
+
+public Menu getMenuBar () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return menuBar;
+}
+
+String getNameText () {
+ return getText ();
+}
+
+public String getText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return text;
+}
+
+boolean hasBorder () {
+ return false;
+}
+
+Decorations menuShell () {
+ return this;
+}
+
+void releaseWidget () {
+ if (menus != null) {
+ for (int i=0; i<menus.length; i++) {
+ Menu menu = menus [i];
+ if (menu != null && !menu.isDisposed ()) {
+ menu.releaseWidget ();
+ menu.releaseHandle ();
+ }
+ }
+ }
+ menuBar = null;
+ menus = null;
+ image = null;
+ super.releaseWidget ();
+}
+
+void remove (Menu menu) {
+ if (menus == null) return;
+ for (int i=0; i<menus.length; i++) {
+ if (menus [i] == menu) {
+ menus [i] = null;
+ return;
+ }
+ }
+}
+
+void resizeBounds (int width, int height) {
+ 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);
+ }
+ int [] args = {OS.Pt_ARG_WIDTH, width, 0, OS.Pt_ARG_HEIGHT, height, 0};
+ OS.PtSetResources (scrolledHandle, args.length / 3, args);
+ resizeClientArea (width, height);
+}
+
+public void setDefaultButton (Button button) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE
+}
+
+public void setImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ this.image = image;
+}
+
+public void setMaximized (boolean maximized) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+
+public void setMenuBar (Menu menu) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE
+}
+
+public void setMinimized (boolean minimized) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ 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
new file mode 100755
index 0000000000..dc7aad26e1
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/DirectoryDialog.java
@@ -0,0 +1,61 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+public /*final*/ class DirectoryDialog extends Dialog {
+ String message = "", filterPath = "";
+
+public DirectoryDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+
+public DirectoryDialog (Shell parent, int style) {
+ super (parent, style);
+}
+
+public String getFilterPath () {
+ return filterPath;
+}
+
+public String getMessage () {
+ return message;
+}
+
+public String open () {
+ int parentHandle = 0;
+ if (parent != null) parentHandle = parent.shellHandle;
+ byte [] title = null;
+ if (this.title != null) title = Converter.wcsToMbcs (null, this.title, true);
+ byte [] root_dir = null;
+ if (filterPath != null) {
+ root_dir = Converter.wcsToMbcs (null, filterPath, true);
+ }
+ byte [] file_spec = null;
+ int flags = OS.Pt_FSR_NO_FCHECK | OS.Pt_FSR_NO_SELECT_FILES | OS.Pt_FSR_SELECT_DIRS;
+ PtFileSelectionInfo_t info = new PtFileSelectionInfo_t ();
+ OS.PtFileSelection (parentHandle, null, title, root_dir, file_spec, null, null, null, info, flags);
+ if (info.ret == OS.Pt_FSDIALOG_BTN2) return null;
+ int length = 0;
+ while (length < info.path.length && info.path [length] != 0) length++;
+ byte [] path = new byte [length];
+ System.arraycopy (info.path, 0, path, 0, length);
+ return new String (Converter.mbcsToWcs (null, path));
+}
+
+public void setFilterPath (String string) {
+ filterPath = string;
+}
+
+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
new file mode 100755
index 0000000000..f4412502fa
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java
@@ -0,0 +1,943 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public /*final*/ class Display extends Device {
+
+ /**** TEMPORARY CODE FOR MOTIF TABLE ***/
+ static int textHighlightThickness = 0;
+
+ /* TEMPORARY HACK FOR PHOTON */
+ public boolean embedded;
+
+ /* Photon Only Public Fields */
+ public int app_context;
+// public int phEventSize = PhEvent_t.sizeof + 1024;
+// public int phEvent = OS.malloc (phEventSize);
+
+ /* Deferred Events */
+ Event [] eventQueue;
+
+ /* Events Dispatching and Callback */
+ Callback windowCallback, drawCallback, workCallback, inputCallback;
+ int windowProc, drawProc, workProc, inputProc, input, pulse;
+ boolean idle;
+
+ /* Sync/Async Widget Communication */
+ Synchronizer synchronizer = new Synchronizer (this);
+ Thread thread = Thread.currentThread ();
+
+ /* Display Shutdown */
+ Runnable [] disposeList;
+
+ /* Timers */
+ int [] timers;
+ Runnable [] timerList;
+ Callback timerCallback;
+ int timerProc, timerHandle;
+
+ /* Keyboard */
+ int lastKey, lastAscii;
+
+ /* Key Mappings. */
+ private static final int [] [] KeyTable = {
+
+ /* Keyboard and Mouse Masks */
+ {OS.Pk_Alt_L, SWT.ALT},
+ {OS.Pk_Alt_R, SWT.ALT},
+ {OS.Pk_Shift_L, SWT.SHIFT},
+ {OS.Pk_Shift_R, SWT.SHIFT},
+ {OS.Pk_Control_L, SWT.CONTROL},
+ {OS.Pk_Control_R, SWT.CONTROL},
+
+// {OS.VK_LBUTTON, SWT.BUTTON1},
+// {OS.VK_MBUTTON, SWT.BUTTON3},
+// {OS.VK_RBUTTON, SWT.BUTTON2},
+
+ /* Non-Numeric Keypad Constants */
+ {OS.Pk_Up, SWT.ARROW_UP},
+ {OS.Pk_Down, SWT.ARROW_DOWN},
+ {OS.Pk_Left, SWT.ARROW_LEFT},
+ {OS.Pk_Right, SWT.ARROW_RIGHT},
+ {OS.Pk_Prior, SWT.PAGE_UP},
+ {OS.Pk_Next, SWT.PAGE_DOWN},
+ {OS.Pk_Home, SWT.HOME},
+ {OS.Pk_End, SWT.END},
+ {OS.Pk_Insert, SWT.INSERT},
+// {OS.Pk_Delete, SWT.DELETE},
+// {OS.Pk_Escape, 0x001B},
+
+ /* Functions Keys */
+ {OS.Pk_F1, SWT.F1},
+ {OS.Pk_F2, SWT.F2},
+ {OS.Pk_F3, SWT.F3},
+ {OS.Pk_F4, SWT.F4},
+ {OS.Pk_F5, SWT.F5},
+ {OS.Pk_F6, SWT.F6},
+ {OS.Pk_F7, SWT.F7},
+ {OS.Pk_F8, SWT.F8},
+ {OS.Pk_F9, SWT.F9},
+ {OS.Pk_F10, SWT.F10},
+ {OS.Pk_F11, SWT.F11},
+ {OS.Pk_F12, SWT.F12},
+
+
+ /* Numeric Keypad Constants */
+ /*
+ {OS.XK_KP_Add, SWT.KP_PLUS},
+ {OS.XK_KP_Subtract, SWT.KP_MINUS},
+ {OS.XK_KP_Multiply, SWT.KP_TIMES},
+ {OS.XK_KP_Divide, SWT.KP_DIVIDE},
+ {OS.XK_KP_Decimal, SWT.KP_PERIOD},
+ {OS.XK_KP_Enter, SWT.KP_ENTER},
+ {OS.XK_KP_0, SWT.KP_0},
+ {OS.XK_KP_1, SWT.KP_1},
+ {OS.XK_KP_2, SWT.KP_2},
+ {OS.XK_KP_3, SWT.KP_3},
+ {OS.XK_KP_4, SWT.KP_4},
+ {OS.XK_KP_5, SWT.KP_5},
+ {OS.XK_KP_6, SWT.KP_6},
+ {OS.XK_KP_7, SWT.KP_7},
+ {OS.XK_KP_8, SWT.KP_8},
+ {OS.XK_KP_9, SWT.KP_9},
+ */
+ };
+
+ /* Multiple Displays. */
+ static Display Default;
+ static Display [] Displays = new Display [4];
+
+ /* Window Classes */
+ static int ClassesPtr;
+ static int PtButton;
+ static int PtList;
+ static int PtLabel;
+ static int PtWindow;
+ static int PtToggleButton;
+ static int PtComboBox;
+ static int PtText;
+ static int PtMultiText;
+ static int PtScrollbar;
+ static int PtScrollContainer;
+ static int PtScrollArea;
+ static int PtContainer;
+ static int PtProgress;
+ static int PtPanelGroup;
+ static int PtPane;
+ static int PtTree;
+ static int PtSlider;
+ static int PtSeparator;
+
+ /* Colors */
+ 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;
+
+ /* Fonts */
+ byte [] TEXT_FONT, LIST_FONT;
+
+ /* Package name */
+ static final String PACKAGE_NAME;
+ static {
+ String name = Display.class.getName ();
+ int index = name.lastIndexOf ('.');
+ PACKAGE_NAME = name.substring (0, index + 1);
+ }
+
+ /* Photon Draw Buffer - shared by all widgets */
+ static int DrawBufferSize = 1024 * 48;
+
+ /* Display Data */
+ Object data;
+ String [] keys;
+ Object [] values;
+
+public Display () {
+ this (null);
+}
+
+public Display (DeviceData data) {
+ super (data);
+}
+
+public void asyncExec (Runnable runnable) {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ synchronizer.asyncExec (runnable);
+}
+
+public void beep () {
+ checkDevice ();
+ OS.PtBeep ();
+}
+
+protected void checkDevice () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+}
+
+synchronized void checkDisplay () {
+ for (int i=0; i<Displays.length; i++) {
+ if (Displays [i] != null && Displays [i].thread == thread) {
+ error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ }
+ }
+}
+
+protected void checkSubclass () {
+ if (!isValidClass (getClass ())) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+protected void create (DeviceData data) {
+ checkSubclass ();
+ checkDisplay ();
+ createDisplay (data);
+ register ();
+ if (Default == null) Default = this;
+}
+
+void createDisplay (DeviceData data) {
+ OS.PtInit (null);
+ OS.PgSetDrawBufferSize (DrawBufferSize);
+ app_context = OS.PtCreateAppContext ();
+}
+
+synchronized void deregister () {
+ for (int i=0; i<Displays.length; i++) {
+ if (this == Displays [i]) Displays [i] = null;
+ }
+}
+
+protected void destroy () {
+ if (this == Default) Default = null;
+ deregister ();
+ destroyDisplay ();
+}
+
+void destroyDisplay () {
+ // NEED to destroy app_context ???
+}
+
+public void disposeExec (Runnable runnable) {
+ checkDevice ();
+ if (disposeList == null) disposeList = new Runnable [4];
+ for (int i=0; i<disposeList.length; i++) {
+ if (disposeList [i] == null) {
+ disposeList [i] = runnable;
+ return;
+ }
+ }
+ Runnable [] newDisposeList = new Runnable [disposeList.length + 4];
+ System.arraycopy (disposeList, 0, newDisposeList, 0, disposeList.length);
+ newDisposeList [disposeList.length] = runnable;
+ disposeList = newDisposeList;
+}
+
+int drawProc (int handle, int damage) {
+ Widget widget = WidgetTable.get (handle);
+ if (widget == null) return 0;
+ return widget.processPaint (damage);
+}
+
+void error (int code) {
+ SWT.error(code);
+}
+
+public static synchronized Display findDisplay (Thread thread) {
+ for (int i=0; i<Displays.length; i++) {
+ Display display = Displays [i];
+ if (display != null && display.thread == thread) {
+ return display;
+ }
+ }
+ return null;
+}
+
+public Widget findWidget (int handle) {
+ checkDevice ();
+ return WidgetTable.get (handle);
+}
+
+public Shell getActiveShell () {
+ checkDevice ();
+ int handle = 0;
+ while ((handle = OS.PtNextTopLevelWidget (handle)) != 0) {
+ int state = OS.PtWindowGetState (handle);
+ if (state != -1 && (state & OS.Ph_WM_STATE_ISFOCUS) != 0) {
+ Widget widget = WidgetTable.get (handle);
+ if (widget instanceof Shell) return (Shell) widget;
+ }
+ }
+ return null;
+}
+
+public Rectangle getBounds () {
+ checkDevice ();
+ PhRect_t rect = new PhRect_t ();
+ OS.PhWindowQueryVisible (OS.Ph_QUERY_GRAPHICS, 0, 1, rect);
+ int width = rect.lr_x - rect.ul_x + 1;
+ int height = rect.lr_y - rect.ul_y + 1;
+ return new Rectangle (rect.ul_x, rect.ul_y, width, height);
+}
+
+public Control getCursorControl () {
+ checkDevice ();
+ int ig = OS.PhInputGroup (0);
+ PhCursorInfo_t info = new PhCursorInfo_t ();
+ OS.PhQueryCursor ((short) ig, info);
+ PhRect_t rect = new PhRect_t ();
+ rect.ul_x = rect.lr_x = info.pos_x;
+ rect.ul_y = rect.lr_y = info.pos_y;
+ int handle = 0;
+ //DOESN'T WORK WHEN SHELLS OVERLAP (NEED Z ORDER)
+ while ((handle = OS.PtNextTopLevelWidget (handle)) != 0) {
+ int child = handle, parent = 0;
+ short [] x = new short [1], y = new short [1];
+ do {
+ OS.PtGetAbsPosition (child, x, y);
+ rect.ul_x = rect.lr_x = (short) (info.pos_x - x [0]);
+ rect.ul_y = rect.lr_y = (short) (info.pos_y - y [0]);
+ if ((child = OS.PtHit (child, 1, rect)) == 0) break;
+ parent = child;
+ if (OS.PtWidgetIsClassMember (child, OS.PtContainer ()) == 0) break;
+ } while (child != 0);
+ if (parent != 0) {
+ do {
+ Widget widget = WidgetTable.get (parent);
+ if (widget != null && widget instanceof Control) {
+ Control control = (Control) widget;
+ if (control.getEnabled ()) return control;
+ return control;
+ }
+ } while ((parent = OS.PtWidgetParent (parent)) != 0);
+ }
+ }
+ return null;
+}
+
+public Point getCursorLocation () {
+ checkDevice ();
+ int ig = OS.PhInputGroup (0);
+ PhCursorInfo_t info = new PhCursorInfo_t ();
+ OS.PhQueryCursor ((short)ig, info);
+ return new Point (info.pos_x, info.pos_y);
+}
+
+public static synchronized Display getCurrent () {
+ Thread current = Thread.currentThread ();
+ for (int i=0; i<Displays.length; i++) {
+ Display display = Displays [i];
+ if (display != null && display.thread == current) return display;
+ }
+ return null;
+}
+
+public static synchronized Display getDefault () {
+ if (Default == null) Default = new Display ();
+ return Default;
+}
+
+public static void setAppName (String name) {
+ /* Do nothing */
+}
+
+public int getDoubleClickTime () {
+ checkDevice ();
+ //NOT DONE
+ return 250;
+}
+
+public Control getFocusControl () {
+ checkDevice ();
+ int handle = 0;
+ while ((handle = OS.PtNextTopLevelWidget (handle)) != 0) {
+ int state = OS.PtWindowGetState (handle);
+ if (state != -1 && (state & OS.Ph_WM_STATE_ISFOCUS) != 0) {
+ int focusHandle = OS.PtContainerFindFocus (handle);
+ if (focusHandle != 0) {
+ Widget widget = WidgetTable.get (focusHandle);
+ if (widget instanceof Control) return (Control) widget;
+ }
+ return null;
+ }
+ }
+ return null;
+}
+
+public int getIconDepth () {
+ return getDepth ();
+}
+
+public Shell [] getShells () {
+ checkDevice ();
+ /*
+ * NOTE: Need to check that the shells that belong
+ * to another display have not been disposed by the
+ * other display's thread as the shells list is being
+ * processed.
+ */
+ int count = 0;
+ Shell [] shells = WidgetTable.shells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (!shell.isDisposed () && this == shell.getDisplay ()) {
+ count++;
+ }
+ }
+ if (count == shells.length) return shells;
+ int index = 0;
+ Shell [] result = new Shell [count];
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (!shell.isDisposed () && this == shell.getDisplay ()) {
+ result [index++] = shell;
+ }
+ }
+ return result;
+}
+
+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_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_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;
+ default:
+ return super.getSystemColor (id);
+ }
+ return Color.photon_new (this, color);
+}
+
+public Font getSystemFont () {
+ checkDevice ();
+ return Font.photon_new (this, TEXT_FONT);
+}
+
+public Thread getSyncThread () {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ return synchronizer.syncThread;
+}
+
+public Thread getThread () {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ return thread;
+}
+
+protected void init () {
+ super.init ();
+ initializeDisplay ();
+ initializeWidgetClasses ();
+ initializeWidgetColors ();
+ initializeWidgetFonts ();
+}
+
+void initializeDisplay () {
+ windowCallback = new Callback (this, "windowProc", 3);
+ windowProc = windowCallback.getAddress ();
+ if (windowProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ drawCallback = new Callback (this, "drawProc", 2);
+ drawProc = drawCallback.getAddress ();
+ if (drawProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ workCallback = new Callback (this, "workProc", 1);
+ workProc = workCallback.getAddress ();
+ if (workProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ inputCallback = new Callback (this, "inputProc", 4);
+ inputProc = inputCallback.getAddress ();
+ if (inputProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ timerCallback = new Callback (this, "timerProc", 3);
+ timerProc = timerCallback.getAddress ();
+ if (timerProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+
+ pulse = OS.PtAppCreatePulse (app_context, -1);
+ input = OS.PtAppAddInput (app_context, pulse, inputProc, 0);
+ int [] args = {
+ OS.Pt_ARG_REGION_OPAQUE, 0, ~0,
+ OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,
+ OS.Pt_ARG_REGION_SENSE, OS.Ph_EV_TIMER, ~0,
+ };
+ OS.PtSetParentWidget (0);
+ timerHandle = OS.PtCreateWidget (OS.PtRegion (), 0, args.length / 3, args);
+ if (timerHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.PtRealizeWidget (timerHandle);
+}
+
+void initializeWidgetClasses () {
+ int [] args = {OS.Pt_SET_DRAW_F, drawProc, 0};
+ int [] buffer = {
+ OS.PtCreateWidgetClass (OS.PtButton (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtList (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtLabel (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtWindow (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtToggleButton (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtComboBox (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtText (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtMultiText (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtScrollbar (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtScrollContainer (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtScrollArea (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtContainer (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtProgress (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtPanelGroup (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtPane (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtTree (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtSlider (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtSeparator (), 0, args.length / 3, args), 0, 0,
+ };
+ ClassesPtr = OS.malloc (buffer.length * 4);
+ OS.memmove (ClassesPtr, buffer, buffer.length * 4);
+ PtButton = ClassesPtr;
+ PtList = ClassesPtr + 12;
+ PtLabel = ClassesPtr + 24;
+ PtWindow = ClassesPtr + 36;
+ PtToggleButton = ClassesPtr + 48;
+ PtComboBox = ClassesPtr + 60;
+ PtText = ClassesPtr + 72;
+ PtMultiText = ClassesPtr + 84;
+ PtScrollbar = ClassesPtr + 96;
+ PtScrollContainer = ClassesPtr + 108;
+ PtScrollArea = ClassesPtr + 120;
+ PtContainer = ClassesPtr + 132;
+ PtProgress = ClassesPtr + 144;
+ PtPanelGroup = ClassesPtr + 156;
+ PtPane = ClassesPtr + 168;
+ PtTree = ClassesPtr + 180;
+ PtSlider = ClassesPtr + 192;
+ PtSeparator = ClassesPtr + 204;
+}
+
+void initializeWidgetColors () {
+ OS.PtSetParentWidget (0);
+ int shellHandle = OS.PtCreateWidget (OS.PtWindow (), 0, 0, null);
+ int [] args = {
+ 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];
+ OS.PtDestroyWidget (shellHandle);
+}
+
+void initializeWidgetFonts () {
+ OS.PtSetParentWidget (0);
+ int shellHandle = OS.PtCreateWidget (OS.PtWindow (), 0, 0, null);
+ int listHandle = OS.PtCreateWidget (OS.PtList (), shellHandle, 0, null);
+ int [] args = {OS.Pt_ARG_LIST_FONT, 0, 0};
+ OS.PtGetResources (listHandle, args.length / 3, args);
+ int count = OS.strlen (args [1]);
+ LIST_FONT = new byte [count + 1];
+ OS.memmove (LIST_FONT, args [1], count);
+ int textHandle = OS.PtCreateWidget (OS.PtText (), shellHandle, 0, null);
+ args = new int [] {OS.Pt_ARG_TEXT_FONT, 0, 0};
+ OS.PtGetResources (textHandle, args.length / 3, args);
+ count = OS.strlen (args [1]);
+ TEXT_FONT = new byte [count + 1];
+ OS.memmove (TEXT_FONT, args [1], count);
+ OS.PtDestroyWidget (shellHandle);
+}
+
+int inputProc (int data, int rcvid, int message, int size) {
+ if (embedded) {
+ runDeferredEvents ();
+ runAsyncMessages ();
+ }
+ return OS.Pt_CONTINUE;
+}
+
+public int internal_new_GC (GCData data) {
+ int phGC = OS.PgCreateGC(0); // NOTE: PgCreateGC ignores the parameter
+ if (phGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+
+ data.device = this;
+ data.rid = OS.Ph_DEV_RID;
+ return phGC;
+}
+
+public void internal_dispose_GC (int phGC, GCData data) {
+ OS.PgDestroyGC(phGC);
+}
+
+boolean isValidThread () {
+ return thread == Thread.currentThread ();
+}
+
+public Object getData (String key) {
+ checkDevice ();
+ if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (keys == null) return null;
+ for (int i=0; i<keys.length; i++) {
+ if (keys [i].equals (key)) return values [i];
+ }
+ return null;
+}
+
+public Object getData () {
+ checkDevice ();
+ return data;
+}
+static boolean isValidClass (Class clazz) {
+ String name = clazz.getName ();
+ int index = name.lastIndexOf ('.');
+ return name.substring (0, index + 1).equals (PACKAGE_NAME);
+}
+
+void postEvent (Event event) {
+ /*
+ * Place the event at the end of the event queue.
+ * This code is always called in the Display's
+ * thread so it must be re-enterant but does not
+ * need to be synchronized.
+ */
+ if (eventQueue == null) eventQueue = new Event [4];
+ int index = 0;
+ int length = eventQueue.length;
+ while (index < length) {
+ if (eventQueue [index] == null) break;
+ index++;
+ }
+ if (index == length) {
+ Event [] newQueue = new Event [length + 4];
+ System.arraycopy (eventQueue, 0, newQueue, 0, length);
+ eventQueue = newQueue;
+ }
+ eventQueue [index] = event;
+ if (embedded) wake ();
+}
+
+public boolean readAndDispatch () {
+ checkDevice ();
+ idle = false;
+ int id = OS.PtAppAddWorkProc (app_context, workProc, 0);
+ OS.PtAppProcessEvent (app_context);
+ OS.PtAppRemoveWorkProc (app_context, id);
+ if (!idle) {
+ runDeferredEvents ();
+ return true;
+ }
+ return runAsyncMessages ();
+}
+
+synchronized void register () {
+ for (int i=0; i<Displays.length; i++) {
+ if (Displays [i] == null) {
+ Displays [i] = this;
+ return;
+ }
+ }
+ Display [] newDisplays = new Display [Displays.length + 4];
+ System.arraycopy (Displays, 0, newDisplays, 0, Displays.length);
+ newDisplays [Displays.length] = this;
+ Displays = newDisplays;
+}
+
+protected void release () {
+ super.release ();
+
+ /* Release shells */
+ Shell [] shells = WidgetTable.shells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (!shell.isDisposed ()) {
+ if (this == shell.getDisplay ()) shell.dispose ();
+ }
+ }
+ while (readAndDispatch ()) {};
+
+ /* Run dispose list */
+ if (disposeList != null) {
+ for (int i=0; i<disposeList.length; i++) {
+ if (disposeList [i] != null) disposeList [i].run ();
+ }
+ }
+ disposeList = null;
+
+ /* Release synchronizer */
+ synchronizer.releaseSynchronizer ();
+ synchronizer = null;
+
+ releaseDisplay ();
+}
+
+void releaseDisplay () {
+
+ OS.PtDestroyWidget (timerHandle);
+
+ /* Free the classes array */
+ OS.free (ClassesPtr);
+
+ /* Free pulses and input proc */
+ 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]);
+ }
+ }
+ timers = null;
+ timerList = null;
+ timerProc = 0;
+ timerCallback.dispose ();
+ timerCallback = null;
+
+ /* Free callbacks */
+ drawCallback.dispose();
+ drawCallback = null;
+ workCallback.dispose();
+ workCallback = null;
+ inputCallback.dispose();
+ inputCallback = null;
+
+ /* Release references */
+ thread = null;
+ data = null;
+ keys = null;
+ values = null;
+}
+
+boolean runAsyncMessages () {
+ return synchronizer.runAsyncMessages ();
+}
+
+boolean runDeferredEvents () {
+ /*
+ * Run deferred events. This code is always
+ * called in the Display's thread so it must
+ * be re-enterant need not be synchronized.
+ */
+ while (eventQueue != null) {
+
+ /* Take an event off the queue */
+ Event event = eventQueue [0];
+ if (event == null) break;
+ int length = eventQueue.length;
+ System.arraycopy (eventQueue, 1, eventQueue, 0, --length);
+ eventQueue [length] = null;
+
+ /* Run the event */
+ Widget widget = event.widget;
+ if (widget != null && !widget.isDisposed ()) {
+ Widget item = event.item;
+ if (item == null || !item.isDisposed ()) {
+ widget.notifyListeners (event.type, event);
+ }
+ }
+
+ /*
+ * At this point, the event queue could
+ * be null due to a recursive invokation
+ * when running the event.
+ */
+ }
+
+ /* Clear the queue */
+ eventQueue = null;
+ return true;
+}
+
+public void setData (String key, Object value) {
+ checkDevice ();
+ if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ /* Remove the key/value pair */
+ if (value == null) {
+ if (keys == null) return;
+ int index = 0;
+ while (index < keys.length && !keys [index].equals (key)) index++;
+ if (index == keys.length) return;
+ if (keys.length == 1) {
+ keys = null;
+ values = null;
+ } else {
+ String [] newKeys = new String [keys.length - 1];
+ Object [] newValues = new Object [values.length - 1];
+ System.arraycopy (keys, 0, newKeys, 0, index);
+ System.arraycopy (keys, index + 1, newKeys, index, newKeys.length - index);
+ System.arraycopy (values, 0, newValues, 0, index);
+ System.arraycopy (values, index + 1, newValues, index, newValues.length - index);
+ keys = newKeys;
+ values = newValues;
+ }
+ return;
+ }
+
+ /* Add the key/value pair */
+ if (keys == null) {
+ keys = new String [] {key};
+ values = new Object [] {value};
+ return;
+ }
+ for (int i=0; i<keys.length; i++) {
+ if (keys [i].equals (key)) {
+ values [i] = value;
+ return;
+ }
+ }
+ String [] newKeys = new String [keys.length + 1];
+ Object [] newValues = new Object [values.length + 1];
+ System.arraycopy (keys, 0, newKeys, 0, keys.length);
+ System.arraycopy (values, 0, newValues, 0, values.length);
+ newKeys [keys.length] = key;
+ newValues [values.length] = value;
+ keys = newKeys;
+ values = newValues;
+}
+
+public void setData (Object data) {
+ checkDevice ();
+ this.data = data;
+}
+
+public void setSynchronizer (Synchronizer synchronizer) {
+ checkDevice ();
+ if (synchronizer == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (this.synchronizer != null) {
+ this.synchronizer.runAsyncMessages();
+ }
+ this.synchronizer = synchronizer;
+}
+
+public boolean sleep () {
+ checkDevice ();
+ OS.PtAppProcessEvent (app_context);
+ runDeferredEvents ();
+ return true;
+}
+
+public void syncExec (Runnable runnable) {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ synchronizer.syncExec (runnable);
+}
+
+public void timerExec (int milliseconds, Runnable runnable) {
+ checkDevice ();
+ if (timerList == null) timerList = new Runnable [4];
+ if (timers == null) timers = new int [4];
+ int index = 0;
+ while (index < timerList.length) {
+ if (timerList [index] == null) break;
+ index++;
+ }
+ if (index == timerList.length) {
+ Runnable [] newTimerList = new Runnable [timerList.length + 4];
+ System.arraycopy (timerList, 0, newTimerList, 0, timerList.length);
+ timerList = newTimerList;
+ int [] newTimers = new int [timers.length + 4];
+ System.arraycopy (timers, 0, newTimers, 0, timers.length);
+ timers = newTimers;
+ }
+ int [] args = {OS.Pt_ARG_TIMER_INITIAL, milliseconds, 0};
+ int handle = OS.PtCreateWidget (OS.PtTimer (), timerHandle, args.length / 3, args);
+ OS.PtRealizeWidget (handle);
+ if (handle != 0) {
+ OS.PtAddCallback (handle, OS.Pt_CB_TIMER_ACTIVATE, timerProc, index);
+ timerList [index] = runnable;
+ timers [index] = handle;
+ }
+
+}
+int timerProc (int handle, int index, int info) {
+ if (timerList == null) return 0;
+ if (0 <= index && index < timerList.length) {
+ Runnable runnable = timerList [index];
+ timerList [index] = null;
+ OS.PtDestroyWidget (timers [index]);
+ timers [index] = 0;
+ if (runnable != null) runnable.run ();
+ }
+ return 0;
+}
+
+static int translateKey (int key) {
+ for (int i=0; i<KeyTable.length; i++) {
+ if (KeyTable [i] [0] == key) return KeyTable [i] [1];
+ }
+ return 0;
+}
+
+static int untranslateKey (int key) {
+ for (int i=0; i<KeyTable.length; i++) {
+ if (KeyTable [i] [1] == key) return KeyTable [i] [0];
+ }
+ return 0;
+}
+
+public void update() {
+ checkDevice ();
+ Shell[] shells = WidgetTable.shells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (!shell.isDisposed () && this == shell.getDisplay ()) {
+ shell.update ();
+ }
+ }
+}
+
+public void wake () {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+// int flags = OS.PtEnter (0);
+ OS.PtAppPulseTrigger (app_context, pulse);
+// if (flags >= 0) OS.PtLeave (flags);
+}
+
+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);
+}
+
+int workProc (int data) {
+ idle = true;
+ return OS.Pt_CONTINUE;
+}
+
+}
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
new file mode 100755
index 0000000000..d456c137b4
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java
@@ -0,0 +1,125 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+public /*final*/ class FileDialog extends Dialog {
+ String [] filterNames = new String [0];
+ String [] filterExtensions = new String [0];
+ String filterPath = "", fileName = "";
+ static final String FILTER = "*";
+
+public FileDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+
+public FileDialog (Shell parent, int style) {
+ super (parent, style);
+}
+
+public String getFileName () {
+ return fileName;
+}
+
+public String [] getFileNames () {
+ return new String [] {fileName};
+}
+
+public String [] getFilterExtensions () {
+ return filterExtensions;
+}
+
+public String [] getFilterNames () {
+ return filterNames;
+}
+
+public String getFilterPath () {
+ return filterPath;
+}
+
+public String open () {
+ int parentHandle = 0;
+ if (parent != null) parentHandle = parent.shellHandle;
+ byte [] title = null;
+ if (this.title != null) title = Converter.wcsToMbcs (null, this.title, true);
+ byte [] root_dir = null;
+ if (filterPath != null) {
+ root_dir = Converter.wcsToMbcs (null, filterPath, true);
+ }
+
+ /* Compute the filter */
+ String mask = FILTER;
+ /*
+ * Photon does not support filter names.
+ */
+ if (filterNames == null) filterNames = new String [0];
+ /*
+ * Photon supports only one filter with multiple patterns
+ * separated by commas.
+ */
+ if (filterExtensions == null) filterExtensions = new String [0];
+ if (filterExtensions.length > 0) {
+ String comma = ",";
+ mask = comma;
+ for (int i=0; i<filterExtensions.length; i++) {
+ String ext = filterExtensions [i];
+ int length = ext.length();
+ int end, start = 0;
+ do {
+ int index = end = ext.indexOf(';', start);
+ if (end < 0) end = length;
+ String subExt = ext.substring(start, end).trim();
+ if (subExt.length() > 0) {
+ subExt += comma;
+ if (mask.indexOf(comma + subExt) == -1) mask += subExt;
+ }
+ start = end + 1;
+ } while (end < length);
+ }
+ mask = mask.substring(1, Math.max(1, mask.length() - 1));
+ }
+ byte [] file_spec = Converter.wcsToMbcs (null, mask, true);
+
+ int flags = OS.Pt_FSR_NO_FCHECK;
+ PtFileSelectionInfo_t info = new PtFileSelectionInfo_t ();
+ OS.PtFileSelection (parentHandle, null, title, root_dir, file_spec, null, null, null, info, flags);
+ if (info.ret == OS.Pt_FSDIALOG_BTN2) return null;
+ int length = 0;
+ while (length < info.path.length && info.path [length] != 0) length++;
+ byte [] path = new byte [length];
+ System.arraycopy (info.path, 0, path, 0, length);
+ String fullPath = new String (Converter.mbcsToWcs (null, path));
+ length = fullPath.length ();
+ if (length != 0) {
+ int index = length - 1;
+ while (index >= 0 && (fullPath.charAt (index) != '/')) --index;
+ fileName = fullPath.substring (index + 1, length);
+ filterPath = fullPath.substring (0, index);
+ }
+ return fullPath;
+}
+
+public void setFileName (String string) {
+ fileName = string;
+}
+
+public void setFilterExtensions (String [] extensions) {
+ filterExtensions = extensions;
+}
+
+public void setFilterNames (String [] names) {
+ filterNames = names;
+}
+
+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
new file mode 100755
index 0000000000..6402e9c2e4
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java
@@ -0,0 +1,59 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+public /*final*/ class FontDialog extends Dialog {
+ FontData fontData;
+public FontDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+public FontDialog (Shell parent, int style) {
+ super (parent, style);
+}
+public FontData getFontData() {
+ return fontData;
+}
+public FontData open () {
+ int parentHandle = 0;
+ if (parent != null) parentHandle = parent.shellHandle;
+ byte [] title = null;
+ if (this.title != null) title = Converter.wcsToMbcs (null, this.title, true);
+
+ byte[] font = null;
+ if (fontData != null) {
+ if (fontData.stem != null) {
+ font = fontData.stem;
+ } else {
+ byte[] description = Converter.wcsToMbcs(null, fontData.getName(), true);
+ int osStyle = 0, style = fontData.getStyle();
+ if ((style & SWT.BOLD) != 0) osStyle |= OS.PF_STYLE_BOLD;
+ if ((style & SWT.ITALIC) != 0) osStyle |= OS.PF_STYLE_ITALIC;
+ int size = fontData.getHeight();
+ font = OS.PfGenerateFontName(description, osStyle, size, new byte[OS.MAX_FONT_TAG]);
+ }
+ fontData = null;
+ }
+
+ int fontPtr = OS.PtFontSelection (parentHandle, null, title, font, -1, OS.PHFONT_ALL_FONTS | OS.PFFONT_DONT_SHOW_LEGACY, null);
+
+ if (fontPtr != 0) {
+ int length = OS.strlen(fontPtr);
+ font = new byte[length];
+ OS.memmove(font, fontPtr, length);
+ fontData = FontData.photon_new(font);
+ }
+ return fontData;
+}
+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
new file mode 100755
index 0000000000..7f5022c5cf
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java
@@ -0,0 +1,122 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public /*final*/ class Group extends Composite {
+
+public Group (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+ /*
+ * Even though it is legal to create this widget
+ * with scroll bars, they serve no useful purpose
+ * because they do not automatically scroll the
+ * widget's client area. The fix is to clear
+ * the SWT style.
+ */
+ return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Point titleSize = getTitleSize();
+ Point size;
+ if (layout != null) {
+ size = layout.computeSize (this, wHint, hHint, changed);
+ } else {
+ size = minimumSize ();
+ }
+ int width = size.x; int height = size.y;
+ if (width == 0) width = DEFAULT_WIDTH;
+ if (height == 0) height = DEFAULT_HEIGHT;
+ if (wHint != SWT.DEFAULT) width = wHint;
+ if (hHint != SWT.DEFAULT) height = hHint;
+ Rectangle trim = computeTrim (0, 0, width, height);
+ width = Math.max (trim.width, titleSize.x + 6);
+ height = trim.height + titleSize.y;
+ return new Point (width, height);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int clazz = display.PtPane;
+ int parentHandle = parent.handle;
+ int [] args = {
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+public String getText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_TITLE, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] == 0) return "";
+ int length = OS.strlen (args [1]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, args [1], length);
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ return new String (unicode);
+}
+
+Point getTitleSize() {
+ int width = 0, height = 0;
+ int [] args = {
+ OS.Pt_ARG_TITLE, 0, 0,
+ OS.Pt_ARG_TITLE_FONT, 0, 0,
+ OS.Pt_ARG_CONTAINER_FLAGS, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ if ((OS.Pt_ARG_CONTAINER_FLAGS & OS.Pt_SHOW_TITLE) != 0) {
+ PhRect_t rect = new PhRect_t();
+ if (args [1] != 0) {
+ int length = OS.strlen (args [1]);
+ OS.PfExtentText(rect, null, args [4], args [1], length);
+ }
+ int inset = 4;
+ width = inset + rect.lr_x - rect.ul_x + 1;
+ height = inset + rect.lr_y - rect.ul_y + 1;
+ }
+ return new Point(width, height);
+}
+
+int processPaint (int damage) {
+ OS.PtSuperClassDraw (OS.PtPane (), handle, damage);
+ sendPaintEvent (damage);
+ return OS.Pt_CONTINUE;
+}
+
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int flags = OS.Pt_SHOW_TITLE | OS.Pt_ETCH_TITLE_AREA | OS.Pt_GRADIENT_TITLE_AREA;
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int [] args = {
+ OS.Pt_ARG_TITLE, ptr, 0,
+ OS.Pt_ARG_CONTAINER_FLAGS, string.length () == 0 ? 0 : flags, flags,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ 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
new file mode 100755
index 0000000000..0c2e37f0b6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Header.java
@@ -0,0 +1,336 @@
+package org.eclipse.swt.widgets;
+
+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
+ * label. Each item is identified by an index and can be resized.
+ */
+class Header extends Canvas {
+ private static final int DEFAULT_WIDTH = 64; // used in computeSize if width could not be calculated
+ private static final int DEFAULT_HEIGHT = 64; // used in computeSize if height could not be calculated
+ private static final int VERTICAL_MARGIN = 4; // space added to the height of the header label
+ private static final int TEXT_Y_OFFSET = 2; // space between the header label and the lower header boundary
+ private static final int DEFAULT_ITEM_WIDTH = 9; // default width of a header item
+ private static final int TEXT_MARGIN = 6; // space in front and behind header text
+ private static final int SHADOW_WIDTH = 2; // width of the right side header shadow
+/**
+ * Create a Header widget as a child of 'parent'.
+ * @param parent - the parent of the new instance
+ */
+Header(Table parent) {
+ super(parent, SWT.NO_REDRAW_RESIZE | SWT.NO_FOCUS);
+
+ addListener(SWT.Paint, new Listener() {
+ public void handleEvent(Event event) {paint(event);}
+ });
+ setHeaderHeight();
+}
+/**
+ * Answer the size of the receiver needed to display all items.
+ */
+public Point computeSize(int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int width = 0;
+ int height = 0;
+
+ for (int i = 0; i < getItemCount(); i++) {
+ width += getBounds(i).width;
+ if (height == 0) {
+ height = getBounds(i).height;
+ }
+ }
+ if (width == 0) {
+ width = DEFAULT_WIDTH;
+ }
+ if (height == 0) {
+ height = DEFAULT_HEIGHT;
+ }
+ if (wHint != SWT.DEFAULT) {
+ width = wHint;
+ }
+ if (hHint != SWT.DEFAULT) {
+ height = hHint;
+ }
+ return new Point(width, height);
+}
+/**
+ * Draw the bright shadow on the upper and left sides of a header item.
+ * @param gc - GC to draw on
+ * @param itemIndex - specifies the item to draw
+ */
+void drawHighlightShadow(GC gc, int itemIndex) {
+ Rectangle bounds = getBounds(itemIndex);
+ Color oldForeground = getForeground();
+
+ gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
+ // draw top horizontal line
+ gc.drawLine(bounds.x, bounds.y, bounds.x + bounds.width - 1, bounds.y);
+ // draw left vertical line
+ gc.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height - 1);
+ gc.setForeground(oldForeground);
+}
+/**
+ * Draw the dark shadow on the lower and right side of a header item.
+ * @param gc - GC to draw on
+ * @param itemIndex - specifies the item to draw
+ */
+void drawLowlightShadows(GC gc, int itemIndex) {
+ Rectangle bounds = getBounds(itemIndex);
+ Point bottomShadowStart = new Point(bounds.x + 1, bounds.height - 2);
+ Point bottomShadowStop = new Point(bottomShadowStart.x + bounds.width - 2, bottomShadowStart.y);
+ Point rightShadowStart = null;
+ Point rightShadowStop = null;
+ Display display = getDisplay();
+ Color oldForeground = getForeground();
+
+ // light inner shadow
+ gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
+ gc.drawLine(
+ bottomShadowStart.x, bottomShadowStart.y,
+ bottomShadowStop.x, bottomShadowStop.y);
+ if(itemIndex != TableColumn.FILL) {
+ rightShadowStart = new Point(bounds.x + bounds.width - 2, bounds.y + 1);
+ rightShadowStop = new Point(rightShadowStart.x, bounds.height - 2);
+ gc.drawLine(
+ rightShadowStart.x, rightShadowStart.y,
+ rightShadowStop.x, rightShadowStop.y);
+ }
+ // dark outer shadow
+ bottomShadowStart.x--;
+ bottomShadowStart.y++;
+ bottomShadowStop.y++;
+ gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
+ gc.drawLine(
+ bottomShadowStart.x, bottomShadowStart.y,
+ bottomShadowStop.x, bottomShadowStop.y);
+ if(itemIndex != TableColumn.FILL) {
+ rightShadowStart.x++;
+ rightShadowStart.y--;
+ rightShadowStop.y++;
+ rightShadowStop.x++;
+ gc.drawLine(
+ rightShadowStart.x, rightShadowStart.y,
+ rightShadowStop.x, rightShadowStop.y);
+ }
+ gc.setForeground(oldForeground);
+}
+/**
+ * Draw the item text of the item identified by 'itemIndex'.
+ * @param gc - GC to draw on
+ * @param itemIndex - specifies the item to draw
+ */
+void drawText(GC gc, int itemIndex) {
+ String label = getText(gc, itemIndex);
+ Point textExtent;
+ Rectangle bounds = getBounds(itemIndex);
+ int yPosition;
+ int xPosition = 0;
+ int alignment;
+
+ if (label != null) {
+ alignment = ((Table) getParent()).internalGetColumn(itemIndex).getAlignment();
+ textExtent = gc.stringExtent(label);
+ yPosition = bounds.height - textExtent.y - TEXT_Y_OFFSET;
+
+ if ((alignment & SWT.CENTER) != 0) {
+ xPosition = (bounds.width - textExtent.x) / 2;
+ }
+ else
+ if ((alignment & SWT.RIGHT) != 0) {
+ xPosition = bounds.width - textExtent.x - TEXT_MARGIN;
+ }
+ xPosition = Math.max(TEXT_MARGIN, xPosition);
+ xPosition += bounds.x;
+ gc.drawString(label, xPosition, yPosition);
+ }
+}
+/**
+ * Answer the bounding rectangle of the item identified by 'itemIndex'.
+ * @param itemIndex - specifies the item whose bounding rectangle
+ * should be returned.
+ * @return the bouding rectangle of the item identified by 'itemIndex'.
+ */
+Rectangle getBounds(int itemIndex) {
+ Rectangle bounds = null;
+ int itemCount = getItemCount();
+ Table parent = (Table) getParent();
+
+ if (itemIndex >= 0 && itemIndex < itemCount) {
+ bounds = parent.internalGetColumn(itemIndex).getBounds();
+ bounds.y = 0;
+ bounds.height = getBounds().height;
+ }
+ else
+ if (itemIndex == TableColumn.FILL) {
+ if (itemCount > 0) {
+ bounds = parent.internalGetColumn(itemCount - 1).getBounds();
+ bounds.x += bounds.width;
+ }
+ else {
+ bounds = new Rectangle(0, 0, 0, 0);
+ }
+ bounds.width = Math.max(0, getBounds().width - bounds.x);
+ bounds.y = 0;
+ bounds.height = getBounds().height;
+ }
+ return bounds;
+}
+/**
+ * Answer the number of items in the receiver.
+ */
+int getItemCount() {
+ return ((Table) getParent()).internalGetColumnCount();
+}
+/**
+ * Answer the maximum label width that fits into the item identified by
+ * 'itemIndex'.
+ */
+int getMaxLabelWidth(int itemIndex) {
+ return getBounds(itemIndex).width - 2 * TEXT_MARGIN;
+}
+/**
+ * Answer the width required to display the complete label of the header
+ * item at position 'index'.
+ * @param index - position of the header item whose preferred width should
+ * be returned.
+ */
+int getPreferredWidth(int index) {
+ Table parent = (Table) getParent();
+ String text = getText(index);
+ int headerWidth = 0;
+
+ if (text != null) {
+ headerWidth = parent.getTextWidth(text) + 2 * TEXT_MARGIN + 1;
+ }
+ return headerWidth;
+}
+/**
+ * Answer the label of the item identified by 'itemIndex'.
+ */
+String getText(int itemIndex) {
+ String itemLabel = null;
+
+ if (itemIndex >= 0 && itemIndex < getItemCount()) {
+ itemLabel = ((Table) getParent()).internalGetColumn(itemIndex).getText();
+ }
+ return itemLabel;
+}
+/**
+ * Answer the text that is going to be drawn in the header item
+ * identified by 'itemIndex'. This may be truncated to fit the item
+ * width.
+ * @param gc - GC to use for measuring the label width.
+ * @param itemIndex - specifies the item whose label should be returned.
+ */
+String getText(GC gc, int itemIndex) {
+ String label = getText(itemIndex);
+ int maxWidth;
+
+ if (label != null) {
+ maxWidth = getMaxLabelWidth(itemIndex);
+ label = ((Table) getParent()).trimItemText(label, maxWidth, gc);
+ }
+ return label;
+}
+/**
+ * Draw the header item identified by 'itemIndex'.
+ * @param gc - GC to draw on
+ * @param itemIndex - item that should be drawn
+ */
+void paint(GC gc, int itemIndex) {
+ Rectangle bounds = getBounds(itemIndex);
+
+ // draw header background
+ gc.fillRectangle(bounds.x, bounds.y + 1, bounds.width, bounds.height - 3);
+ if (itemIndex != TableColumn.FILL) {
+ drawText(gc, itemIndex);
+ }
+ drawHighlightShadow(gc, itemIndex);
+ drawLowlightShadows(gc, itemIndex);
+}
+/**
+ * Draw all header items.
+ * @param event - Paint event triggering the drawing operation.
+ */
+void paint(Event event) {
+ int labelCount = getItemCount();
+
+ for (int i = 0; i < labelCount; i++) {
+ paint(event.gc, i);
+ }
+ paint(event.gc, TableColumn.FILL); // paint empty fill item behind last item
+}
+/**
+ * Redraw the item identified by 'itemIndex'.
+ * @param itemIndex - specifies the header item that should be redrawn
+ */
+void redraw(int itemIndex) {
+ Rectangle bounds = getBounds(itemIndex);
+
+ if (bounds != null) {
+ redraw(bounds.x, 0, bounds.width, bounds.height, false);
+ }
+}
+
+/**
+ * Set a new font. Recalculate the header height and redraw the header.
+ */
+public void setFont(Font font) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (font == null || font.equals(getFont()) == true) {
+ return;
+ }
+ super.setFont(font);
+ setHeaderHeight();
+ redraw();
+}
+/**
+ * Calculate and store the height of the receiver.
+ */
+void setHeaderHeight() {
+ GC gc = new GC(this);
+ Rectangle bounds = getBounds();
+
+ bounds.height = gc.stringExtent("aString").y + VERTICAL_MARGIN;
+ setBounds(bounds);
+ gc.dispose();
+}
+/**
+ * The width of the header item at position 'itemIndex' is about to change.
+ * Adjust the width of the header. Scroll and redraw all header items
+ * starting behind the item identified by 'itemIndex'.
+ * @param itemIndex - specifies the item after which the redraw
+ * should begin.
+ * @param widthDiff - the width change of the item.
+ * > 0 = item width increased. < 0 = item width decreased
+ */
+void widthChange(int itemIndex, int widthDiff) {
+ Rectangle bounds = getBounds(itemIndex);
+ Rectangle headerBounds = getBounds();
+
+ if (bounds != null) {
+ if (itemIndex != TableColumn.FILL) { // ignore the fill column header item - there's nothing to redraw anyway
+ scroll(
+ bounds.x + bounds.width + widthDiff, 0, // destination x, y
+ bounds.x + bounds.width, 0, // source x, y
+ headerBounds.width + widthDiff, headerBounds.height, false);
+ redraw(bounds.x, 0, bounds.width, bounds.height, false);
+ }
+ }
+ headerBounds.width += widthDiff;
+ setBounds(headerBounds);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java
new file mode 100755
index 0000000000..ac5f1acd86
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java
@@ -0,0 +1,231 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public class Label extends Control {
+ Image image;
+
+public Label (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+static int checkStyle (int style) {
+ if ((style & SWT.SEPARATOR) != 0) return style;
+ return checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
+}
+
+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) {
+ if ((style & SWT.HORIZONTAL) != 0) {
+ width += DEFAULT_WIDTH; height += 3;
+ } else {
+ width += 3; height += DEFAULT_HEIGHT;
+ }
+ if (wHint != SWT.DEFAULT) width = wHint + (border * 2);
+ if (hHint != SWT.DEFAULT) height = hHint + (border * 2);
+ 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;
+ if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ 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;
+ }
+ return new Point (width, height);
+}
+
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int parentHandle = parent.handle;
+
+ if ((style & SWT.SEPARATOR) != 0) {
+ int clazz = display.PtSeparator;
+ int orientation = (style & SWT.HORIZONTAL) != 0 ? OS.Pt_SEP_HORIZONTAL : OS.Pt_SEP_VERTICAL;
+ int type = OS.Pt_ETCHED_IN;
+ if ((style & (SWT.SHADOW_OUT)) != 0) type = OS.Pt_ETCHED_OUT;
+ int [] args = {
+ OS.Pt_ARG_SEP_FLAGS, orientation, OS.Pt_SEP_VERTICAL | OS.Pt_SEP_HORIZONTAL,
+ OS.Pt_ARG_SEP_TYPE, type, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ return;
+ }
+
+ int clazz = display.PtLabel;
+ int alignment = OS.Pt_LEFT;
+ if ((style & SWT.CENTER) != 0) alignment = OS.Pt_CENTER;
+ if ((style & SWT.RIGHT) != 0) alignment = OS.Pt_RIGHT;
+ int [] args = {
+ OS.Pt_ARG_HORIZONTAL_ALIGNMENT, alignment, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+public int getAlignment () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) != 0) return 0;
+ if ((style & SWT.LEFT) != 0) return SWT.LEFT;
+ if ((style & SWT.CENTER) != 0) return SWT.CENTER;
+ if ((style & SWT.RIGHT) != 0) return SWT.RIGHT;
+ return SWT.LEFT;
+}
+
+public Image getImage () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return image;
+}
+
+String getNameText () {
+ return getText ();
+}
+
+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);
+}
+
+int processPaint (int damage) {
+ int clazz = OS.PtLabel ();
+ if ((style & SWT.SEPARATOR) != 0) clazz = OS.PtSeparator ();
+ OS.PtSuperClassDraw (clazz, handle, damage);
+ return super.processPaint (damage);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ image = null;
+}
+
+public void setAlignment (int alignment) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return;
+ style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+ style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+ int [] args = {OS.Pt_ARG_HORIZONTAL_ALIGNMENT, OS.Pt_LEFT, 0};
+ if ((style & SWT.CENTER) != 0) args [1] = OS.Pt_CENTER;
+ if ((style & SWT.RIGHT) != 0) args [1] = OS.Pt_RIGHT;
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public boolean setFocus () {
+ return false;
+}
+
+public void setImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ this.image = image;
+ int imageHandle = 0;
+ if (image != null) imageHandle = copyPhImage (image.handle);
+ int [] args = {
+ OS.Pt_ARG_LABEL_IMAGE, imageHandle, 0,
+ OS.Pt_ARG_LABEL_TYPE, OS.Pt_IMAGE, 0
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ if (imageHandle != 0) OS.free (imageHandle);
+}
+
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ char [] text = new char [string.length ()];
+ string.getChars (0, text.length, text, 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];
+ j--;
+ }
+ }
+ while (j < text.length) text [j++] = 0;
+ byte [] buffer = Converter.wcsToMbcs (null, text, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int ptr2 = 0;
+ if (mnemonic != 0) {
+ byte [] buffer2 = Converter.wcsToMbcs (null, new char []{mnemonic}, true);
+ ptr2 = OS.malloc (buffer2.length);
+ OS.memmove (ptr2, buffer2, buffer2.length);
+ }
+ int [] args = {
+ OS.Pt_ARG_TEXT_STRING, ptr, 0,
+ OS.Pt_ARG_LABEL_TYPE, OS.Pt_Z_STRING, 0,
+ OS.Pt_ARG_ACCEL_KEY, ptr2, 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ OS.free (ptr);
+ 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
new file mode 100755
index 0000000000..5fc15bfb72
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
@@ -0,0 +1,589 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public /*final*/ class List extends Scrollable {
+
+public List (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
+}
+
+public void add (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ OS.PtListAddItems (handle, new int [] {ptr}, 1, 0);
+ OS.free (ptr);
+}
+
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+public void add (String string, int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (index == -1) error (SWT.ERROR_INVALID_RANGE);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int result = OS.PtListAddItems (handle, new int [] {ptr}, 1, index + 1);
+ OS.free (ptr);
+ if (result != 0) {
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (0 <= index && index <= args [1]) error (SWT.ERROR_ITEM_NOT_ADDED);
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ /**
+ * Feature in Photon - The preferred width calculated by
+ * PtWidgetPreferredSize is the current width.
+ */
+ PhDim_t dim = new PhDim_t();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
+ OS.PtWidgetPreferredSize(handle, dim);
+ int width = 0, height = dim.h;
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
+ OS.Pt_ARG_ITEMS, 0, 0,
+ OS.Pt_ARG_LIST_FONT, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ PhRect_t rect = new PhRect_t();
+ int [] items = new int [1];
+ for (int i = 0; i < args [1]; i++) {
+ OS.memmove (items, args [4] + (i * 4), 4);
+ int length = OS.strlen (items [0]);
+ OS.PfExtentText(rect, null, args [7], items [0], length);
+ width = Math.max(width, rect.lr_x - rect.ul_x + 1);
+ }
+ rect = new PhRect_t ();
+ PhArea_t area = new PhArea_t ();
+ rect.lr_x = (short) (width + 1);
+ OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
+ width = area.size_w;
+ if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ rect = new PhRect_t ();
+ area = new PhArea_t ();
+ rect.lr_x = (short) (wHint - 1);
+ rect.lr_y = (short) (hHint - 1);
+ OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
+ ScrollBar scroll;
+ if (wHint != SWT.DEFAULT) {
+ width = area.size_w;
+ if ((scroll = getVerticalBar()) != null)
+ width += scroll.getSize().x;
+ }
+ if (hHint != SWT.DEFAULT) {
+ height = area.size_h;
+ if ((scroll = getHorizontalBar()) != null)
+ height += scroll.getSize().y;
+ }
+ }
+ return new Point(width, height);
+}
+
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int clazz = display.PtList;
+ int parentHandle = parent.handle;
+ int mode = OS.Pt_SELECTION_MODE_SINGLE | OS.Pt_SELECTION_MODE_AUTO;
+ if ((style & SWT.MULTI) != 0) {
+ if ((style & SWT.SIMPLE) != 0) {
+ mode = OS.Pt_SELECTION_MODE_MULTIPLE | OS.Pt_SELECTION_MODE_NOCLEAR
+ | OS.Pt_SELECTION_MODE_TOGGLE | OS.Pt_SELECTION_MODE_NOMOVE;
+ } else {
+ mode = OS.Pt_SELECTION_MODE_MULTIPLE | OS.Pt_SELECTION_MODE_AUTO;
+ }
+ }
+ mode |= OS.Pt_SELECTION_MODE_NOFOCUS;
+ int [] args = {
+ 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,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ createScrollBars();
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.LIST_FONT;
+}
+
+public void deselect (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (index < 0) return;
+ OS.PtListUnselectPos (handle, index + 1);
+}
+
+public void deselect (int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (start > end) return;
+ if ((style & SWT.SINGLE) != 0) {
+ int [] args = new int [] {OS.Pt_ARG_LIST_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) deselect (index);
+ return;
+ }
+ for (int i=start; i<end; i++) {
+ OS.PtListUnselectPos (handle, i + 1);
+ }
+}
+
+public void deselect (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);
+ if (indices.length == 0) return;
+ for (int i=0; i<indices.length; i++) {
+ int index = indices [i];
+ if (index != -1) {
+ OS.PtListUnselectPos (handle, index + 1);
+ }
+ }
+}
+
+public void deselectAll () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ for (int i=0; i<count; i++) {
+ OS.PtListUnselectPos (handle, i + 1);
+ }
+}
+
+public int getFocusIndex () {
+ return getSelectionIndex ();
+}
+
+public String getItem (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
+ OS.Pt_ARG_ITEMS, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 <= index && index < args [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ int [] items = new int [1];
+ OS.memmove (items, args [4] + (index * 4), 4);
+ int length = OS.strlen (items [0]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, items [0], length);
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ return new String (unicode);
+}
+
+public int getItemCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getItemHeight () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_TOTAL_HEIGHT, 0, 0,
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
+ OS.Pt_ARG_LIST_FONT, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [4] == 0) {
+ int ptr = OS.malloc(1);
+ PhRect_t rect = new PhRect_t ();
+ OS.PfExtentText(rect, null, args [7], ptr, 1);
+ OS.free(ptr);
+ int inset = 4;
+ return inset + (rect.lr_y - rect.ul_y + 1);
+ }
+ return args [1] / args [4];
+}
+
+public String [] getItems () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
+ OS.Pt_ARG_ITEMS, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ int [] items = new int [args [1]];
+ OS.memmove (items, args [4], args [1] * 4);
+ String [] result = new String [args [1]];
+ for (int i=0; i<args [1]; i++) {
+ int length = OS.strlen (items [i]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, items [i], length);
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ result [i] = new String (unicode);
+ }
+ return result;
+
+}
+
+public String [] getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] indices = getSelectionIndices ();
+ String [] result = new String [indices.length];
+ for (int i=0; i<indices.length; i++) {
+ result [i] = getItem (indices [i]);
+ }
+ return result;
+}
+
+public int getSelectionCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_LIST_SEL_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getSelectionIndex () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,
+ OS.Pt_ARG_SELECTION_INDEXES, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] == 0) return -1;
+ short [] buffer = new short [1];
+ OS.memmove (buffer, args [4], 2);
+ return buffer [0] - 1;
+}
+
+public int [] getSelectionIndices () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,
+ OS.Pt_ARG_SELECTION_INDEXES, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ short [] indices = new short [args [1]];
+ OS.memmove (indices, args [4], args [1] * 2);
+ int [] result = new int [args [1]];
+ for (int i=0; i<args [1]; i++) {
+ result [i] = indices [i] - 1;
+ }
+ return result;
+}
+
+public int getTopIndex () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_TOP_ITEM_POS, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_SELECTION, windowProc, SWT.Selection);
+ OS.PtAddCallback (handle, OS.Pt_CB_ACTIVATE, windowProc, SWT.DefaultSelection);
+}
+
+public int indexOf (String string) {
+ if (!isValidThread ()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error(SWT.ERROR_WIDGET_DISPOSED);
+ return indexOf (string, 0);
+}
+
+public int indexOf (String string, int start) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ // NOT DONE - start is ignored
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ return OS.PtListItemPos(handle, buffer) - 1;
+}
+
+public boolean isSelected (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,
+ OS.Pt_ARG_SELECTION_INDEXES, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ short [] buffer = new short [1];
+ for (int i=0; i<args [1]; i++) {
+ OS.memmove (buffer, args [4] + (i * 2), 2);
+ if (buffer [0] == index + 1) return true;
+ }
+ return false;
+}
+
+int processDefaultSelection (int info) {
+ if (info == 0) return OS.Pt_END;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.cbdata == 0) return OS.Pt_END;
+ int[] click_count = new int [1];
+ OS.memmove(click_count, cbinfo.cbdata, 4);
+ if (click_count [0] > 1) postEvent (SWT.DefaultSelection);
+ return OS.Pt_CONTINUE;
+}
+
+int processPaint (int damage) {
+ OS.PtSuperClassDraw (OS.PtList (), handle, damage);
+ return super.processPaint (damage);
+}
+
+int processSelection (int info) {
+ postEvent (SWT.Selection);
+ return OS.Pt_CONTINUE;
+}
+
+public void remove (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 <= index && index < args [1])) error (SWT.ERROR_INVALID_RANGE);
+ int result = OS.PtListDeleteItemPos (handle, 1, index + 1);
+ if (result != 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
+}
+
+public void remove (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int index = indexOf (string, 0);
+ if (index == -1) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ remove (index);
+}
+
+public void remove (int [] indices) {
+ 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
+}
+
+
+public void remove (int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 < start && start <= end && end < args [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ int count = end - start + 1;
+ int result = OS.PtListDeleteItemPos (handle, count, start + 1);
+ if (result != 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
+}
+
+public void removeAll () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ OS.PtListDeleteAllItems (handle);
+}
+
+
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+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;
+ 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);
+ }
+ OS.PtListGotoPos (handle, start + 1);
+}
+
+public void select (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);
+ if (indices.length == 0) return;
+ for (int i=0; i<indices.length; i++) {
+ if (indices [i] >= 0) {
+ OS.PtListSelectPos (handle, indices [i] + 1);
+ }
+ }
+ OS.PtListGotoPos (handle, indices [0] + 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);
+}
+
+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};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ for (int i=0; i<count; i++) {
+ OS.PtListSelectPos (handle, i + 1);
+ }
+}
+
+public void setItem (int index, String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 <= index && index < args [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ OS.PtListReplaceItemPos (handle, new int [] {ptr}, 1, index + 1);
+ OS.free (ptr);
+}
+
+public void setItems (String [] items) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+ OS.PtListDeleteAllItems (handle);
+ int[] itemsPtr = new int [items.length];
+ for (int i=0; i<itemsPtr.length; i++) {
+ byte [] buffer = Converter.wcsToMbcs (null, items [i], true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ itemsPtr [i] = ptr;
+ }
+ OS.PtListAddItems (handle, itemsPtr, itemsPtr.length, 0);
+ for (int i=0; i<itemsPtr.length; i++) {
+ OS.free (itemsPtr [i]);
+ }
+}
+
+public void setSelection (int start, int end) {
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ select (start, end);
+}
+
+public void setSelection (int index) {
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ select (index);
+}
+
+public void setSelection(int[] indices) {
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ select (indices);
+}
+
+public void setSelection (String [] items) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ for (int i=items.length-1; i>=0; --i) {
+ int index = 0;
+ String string = items [i];
+ if (string != null) {
+ while ((index = indexOf (string, index)) != -1) {
+ select (index);
+ if (((style & SWT.SINGLE) != 0) && isSelected (index)) return;
+ index++;
+ }
+ }
+ }
+ if ((style & SWT.SINGLE) != 0) deselectAll ();
+}
+
+public void setTopIndex (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_TOP_ITEM_POS, index + 1, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void showSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,
+ OS.Pt_ARG_SELECTION_INDEXES, 0, 0,
+ OS.Pt_ARG_TOP_ITEM_POS, 0, 0,
+ OS.Pt_ARG_VISIBLE_COUNT, 0, 0,
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] == 0) return;
+ short [] buffer = new short [1];
+ OS.memmove (buffer, args [4], 2);
+ int index = buffer [0] - 1;
+ int topIndex = args [7] - 1, visibleCount = args [10], count = args [13];
+ int bottomIndex = Math.min (topIndex + visibleCount - 1, count);
+ if ((topIndex <= index) && (index <= bottomIndex)) return;
+ int lastIndex = Math.max (1, count - visibleCount + 1);
+ int newTop = Math.min (Math.max (index - (visibleCount / 2), 1), lastIndex);
+ args = new int [] {OS.Pt_ARG_TOP_ITEM_POS, newTop, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+}
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
new file mode 100755
index 0000000000..929031a615
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java
@@ -0,0 +1,338 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public class Menu extends Widget {
+ int x, y;
+ boolean hasLocation;
+ Decorations parent;
+ MenuItem cascade;
+
+public Menu (Control parent) {
+ this (checkNull (parent).getShell (), SWT.POP_UP);
+}
+
+public Menu (Decorations parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget (0);
+}
+
+public Menu (Menu parentMenu) {
+ this (checkNull (parentMenu).parent, SWT.DROP_DOWN);
+}
+
+public Menu (MenuItem parentItem) {
+ this (checkNull (parentItem).parent);
+}
+
+static Control checkNull (Control control) {
+ if (control == null) error (SWT.ERROR_NULL_ARGUMENT);
+ return control;
+}
+
+static Menu checkNull (Menu menu) {
+ if (menu == null) error (SWT.ERROR_NULL_ARGUMENT);
+ return menu;
+}
+
+static MenuItem checkNull (MenuItem item) {
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ return item;
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.POP_UP, SWT.BAR, SWT.DROP_DOWN, 0, 0, 0);
+}
+
+public void addHelpListener (HelpListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Help, typedListener);
+}
+
+public void addMenuListener (MenuListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Hide,typedListener);
+ addListener (SWT.Show,typedListener);
+}
+
+void createHandle (int index) {
+ int parentHandle = parent.topHandle ();
+ if ((style & SWT.BAR) != 0) {
+ int [] args = {
+ OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
+ OS.Pt_ARG_FLAGS, OS.Pt_DELAY_REALIZE, OS.Pt_DELAY_REALIZE,
+ };
+ handle = OS.PtCreateWidget (OS.PtMenuBar (), parentHandle, args.length / 3, args);
+ } else {
+ handle = OS.PtCreateWidget (OS.PtMenu (), parentHandle, 0, null);
+ }
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+void createWidget (int index) {
+ super.createWidget (index);
+ parent.add (this);
+}
+
+public MenuItem getDefaultItem () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE - NOT NEEDED
+ return null;
+}
+
+public Display getDisplay () {
+ Decorations parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.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;
+}
+
+public int getItemCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int count = 0;
+ int child = OS.PtWidgetChildBack (handle);
+ if (child != 0 && (style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);
+ while (child != 0) {
+ child = OS.PtWidgetBrotherInFront (child);
+ count++;
+ }
+ return count;
+}
+
+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);
+ }
+ return items [index];
+}
+
+public MenuItem [] getItems () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int count = 0;
+ int child = OS.PtWidgetChildBack (handle);
+ if (child != 0 && (style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);
+ while (child != 0) {
+ child = OS.PtWidgetBrotherInFront (child);
+ count++;
+ }
+ MenuItem [] items = new MenuItem [count];
+ int i = 0, j = 0;
+ child = OS.PtWidgetChildBack (handle);
+ if (child != 0 && (style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);
+ while (i < count) {
+ Widget widget = WidgetTable.get (child);
+ if (widget != null && widget instanceof MenuItem) {
+ items [j++] = (MenuItem) widget;
+ }
+ i++;
+ child = OS.PtWidgetBrotherInFront (child);
+ }
+ if (i == j) return items;
+ MenuItem [] newItems = new MenuItem [j];
+ System.arraycopy (items, 0, newItems, 0, j);
+ return newItems;
+}
+
+String getNameText () {
+ String result = "";
+ MenuItem [] items = getItems ();
+ int length = items.length;
+ if (length > 0) {
+ for (int i=0; i<length-1; i++) {
+ result = result + items [i].getNameText() + ", ";
+ }
+ result = result + items [length-1].getNameText ();
+ }
+ return result;
+}
+
+public Decorations getParent () {
+ return parent;
+}
+
+public MenuItem getParentItem () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return cascade;
+}
+
+public Menu getParentMenu () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (cascade != null) return cascade.parent;
+ return null;
+}
+
+public Shell getShell () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getShell ();
+}
+
+public boolean getVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return true;
+}
+
+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);
+}
+
+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;
+ }
+ return -1;
+}
+
+public boolean isEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Menu parentMenu = getParentMenu ();
+ if (parentMenu == null) return getEnabled ();
+ return getEnabled () && parentMenu.isEnabled ();
+}
+
+public boolean isVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getVisible ();
+}
+
+int processHide (int info) {
+ 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);
+ if ((style & SWT.BAR) != 0 && this == parent.menuBar) {
+ parent.setMenuBar (null);
+ }
+}
+
+void releaseWidget () {
+ MenuItem [] items = getItems ();
+ for (int i=0; i<items.length; i++) {
+ MenuItem item = items [i];
+ if (!item.isDisposed ()) {
+ item.releaseWidget ();
+ item.releaseHandle ();
+ }
+ }
+ super.releaseWidget ();
+ if (parent != null) parent.remove (this);
+ parent = null;
+
+}
+
+public void removeHelpListener (HelpListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Help, listener);
+}
+
+public void removeMenuListener (MenuListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Hide, listener);
+ eventTable.unhook (SWT.Show, 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
+}
+
+public void setEnabled (boolean enabled) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {
+ OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_BLOCKED, OS.Pt_BLOCKED,
+ OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_GHOST, OS.Pt_GHOST,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setLocation (int x, int y) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ this.x = x; this.y = y;
+ hasLocation = true;
+}
+
+public void setVisible (boolean visible) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.POP_UP) == 0) return;
+ if (visible) {
+ PhPoint_t pt = new PhPoint_t ();
+ pt.x = (short) x;
+ pt.y = (short) y;
+ if (!hasLocation) {
+ int ig = OS.PhInputGroup (0);
+ PhCursorInfo_t info = new PhCursorInfo_t ();
+ OS.PhQueryCursor ((short) ig, info);
+ pt.x = info.last_press_x;
+ pt.y = info.last_press_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 (handle, args.length / 3, args);
+ OS.free (ptr);
+ 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
new file mode 100755
index 0000000000..e014e1f8b0
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java
@@ -0,0 +1,371 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public class MenuItem extends Item {
+ Menu parent, menu;
+
+public MenuItem (Menu parent, int style) {
+ this (parent, style, parent.getItemCount());
+}
+
+public MenuItem (Menu parent, int style, int index) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget (index);
+}
+
+public void addArmListener (ArmListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Arm, typedListener);
+}
+
+public void addHelpListener (HelpListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Help, typedListener);
+}
+
+public void addSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.PUSH, SWT.CHECK, SWT.RADIO, SWT.SEPARATOR, SWT.CASCADE, 0);
+}
+
+void createHandle (int index) {
+ int count = parent.getItemCount();
+ if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
+ int parentHandle = parent.handle;
+ if ((style & SWT.SEPARATOR) != 0) {
+ 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);
+ } else {
+ handle = OS.PtCreateWidget (OS.PtMenuButton (), parentHandle, 0, null);
+ }
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ if (index != count) {
+ int i = 0;
+ int child = OS.PtWidgetChildBack (parentHandle);
+ /*
+ * Feature in Photon. Menu bars have an extra widget which
+ * is the parent of all menu items. PtValidParent() can not be
+ * used, since it does not return that widget.
+ */
+ if (child != 0 && (parent.style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);
+ while (i != index && child != 0) {
+ child = OS.PtWidgetBrotherInFront (child);
+ i++;
+ }
+ OS.PtWidgetInsert (topHandle (), child, 1);
+ }
+ 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;
+}
+
+public Display getDisplay () {
+ Menu parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.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;
+}
+
+public Menu getMenu () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return menu;
+}
+
+String getNameText () {
+ if ((style & SWT.SEPARATOR) != 0) return "|";
+ return super.getNameText ();
+}
+
+public Menu getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
+
+public boolean getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
+ int [] args = {OS.Pt_ARG_FLAGS, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return (args [1] & OS.Pt_SET) != 0;
+}
+
+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_ACTIVATE, windowProc, SWT.Selection);
+}
+
+public boolean isEnabled () {
+ return getEnabled () && parent.isEnabled ();
+}
+
+int processSelection (int info) {
+ if ((style & SWT.CASCADE) != 0) {
+ int [] args = {OS.Pt_ARG_BUTTON_TYPE, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if ((args [1] & (OS.Pt_MENU_RIGHT | OS.Pt_MENU_DOWN)) != 0) {
+ return OS.Pt_CONTINUE;
+ }
+ }
+ postEvent (SWT.Selection);
+ return OS.Pt_CONTINUE;
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ if (menu != null) menu.dispose ();
+ menu = null;
+// parent.destroyItem (this);
+}
+
+void releaseWidget () {
+ if (menu != null) {
+ menu.releaseWidget ();
+ menu.releaseHandle ();
+ }
+ menu = null;
+ super.releaseWidget ();
+// if (accelerator != 0) {
+// parent.destroyAcceleratorTable ();
+// }
+// accelerator = 0;
+// Decorations shell = parent.parent;
+// shell.remove (this);
+ 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);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Arm, listener);
+}
+
+public void removeHelpListener (HelpListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Help, listener);
+}
+
+public void removeSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+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);
+// }
+}
+
+public void setEnabled (boolean enabled) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {
+ OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_BLOCKED, OS.Pt_BLOCKED,
+ OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_GHOST, OS.Pt_GHOST,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ super.setImage (image);
+
+ //NOT DONE - The OS has support
+}
+
+public void setMenu (Menu menu) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.CASCADE) == 0) {
+ error (SWT.ERROR_MENUITEM_NOT_CASCADE);
+ }
+ if (menu != null) {
+ if ((menu.style & SWT.DROP_DOWN) == 0) {
+ error (SWT.ERROR_MENU_NOT_DROP_DOWN);
+ }
+ if (menu.parent != parent.parent) {
+ error (SWT.ERROR_INVALID_PARENT);
+ }
+ }
+ Menu oldMenu = this.menu;
+ if (oldMenu == menu) return;
+ 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};
+ 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};
+ 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);
+ }
+}
+
+public void setSelection (boolean selected) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
+ int [] args = {OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ super.setText (string);
+ char [] text = new char [string.length ()];
+ string.getChars (0, text.length, text, 0);
+ boolean accel = false;
+ int i=0, j=0;
+ char mnemonic=0;
+ while (i < text.length) {
+ if (text [i] == '\t') {accel = true; break;};
+ if ((text [j++] = text [i++]) == Mnemonic) {
+ if (i == text.length) {continue;}
+ if (text [i] == Mnemonic) {i++; continue;}
+ if (mnemonic == 0) mnemonic = text [i];
+ j--;
+ }
+ }
+ byte [] buffer2;
+ 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];
+ }
+ 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 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);
+ }
+ int [] args = {
+ OS.Pt_ARG_TEXT_STRING, ptr, 0,
+ OS.Pt_ARG_ACCEL_KEY, ptr3, 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ OS.free (ptr);
+ OS.free (ptr3);
+ /*
+ * Bug on Photon. When a the text is set on a menu
+ * item that is realized, the menu item does not resize
+ * to show the new text. The fix is to force the item
+ * to recalculate the size.
+ */
+ 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
new file mode 100755
index 0000000000..97348244e3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java
@@ -0,0 +1,99 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+public /*final*/ class MessageBox extends Dialog {
+ String message = "";
+public MessageBox (Shell parent) {
+ this (parent, SWT.OK | SWT.ICON_INFORMATION | SWT.APPLICATION_MODAL);
+}
+public MessageBox (Shell parent, int style) {
+ super (parent, checkStyle (style));
+}
+static int checkStyle (int style) {
+ if ((style & (SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL)) == 0) style |= SWT.APPLICATION_MODAL;
+ int mask = (SWT.YES | SWT.NO | SWT.OK | SWT.CANCEL | SWT.ABORT | SWT.RETRY | SWT.IGNORE);
+ int bits = style & mask;
+ if (bits == SWT.OK || bits == SWT.CANCEL || bits == (SWT.OK | SWT.CANCEL)) return style;
+ if (bits == SWT.YES || bits == SWT.NO || bits == (SWT.YES | SWT.NO) || bits == (SWT.YES | SWT.NO | SWT.CANCEL)) return style;
+ if (bits == (SWT.RETRY | SWT.CANCEL) || bits == (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) return style;
+ style = (style & ~mask) | SWT.OK;
+ return style;
+}
+public String getMessage () {
+ return message;
+}
+public int open () {
+ String[] buttons = null;
+ if ((style & SWT.OK) == SWT.OK) buttons = new String[]{"&Ok"};
+ if ((style & (SWT.OK | SWT.CANCEL)) == (SWT.OK | SWT.CANCEL)) buttons = new String[]{"&Ok", "&Cancel"};
+ if ((style & (SWT.YES | SWT.NO)) == (SWT.YES | SWT.NO)) buttons = new String[]{"&Yes", "&No"};
+ if ((style & (SWT.YES | SWT.NO | SWT.CANCEL)) == (SWT.YES | SWT.NO | SWT.CANCEL)) buttons = new String[]{"&Yes", "&No", "&Cancel"};
+ if ((style & (SWT.RETRY | SWT.CANCEL)) == (SWT.RETRY | SWT.CANCEL)) buttons = new String[]{"&Retry", "&Cancel"};
+ if ((style & (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) == (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) buttons = new String[]{"&Abort", "&Retry", "&Ignore"};
+ if (buttons == null) buttons = new String[]{"&Ok"};
+
+ int phImage = 0;
+// int iconBits = 0;
+// if ((style & SWT.ICON_ERROR) != 0) iconBits = OS.MB_ICONERROR;
+// if ((style & SWT.ICON_INFORMATION) != 0) iconBits = OS.MB_ICONINFORMATION;
+// if ((style & SWT.ICON_QUESTION) != 0) iconBits = OS.MB_ICONQUESTION;
+// if ((style & SWT.ICON_WARNING) != 0) iconBits = OS.MB_ICONWARNING;
+// if ((style & SWT.ICON_WORKING) != 0) iconBits = OS.MB_ICONINFORMATION;
+
+ int parentHandle = 0;
+ if (parent != null) parentHandle = parent.shellHandle;
+
+ byte [] title = null;
+ if (this.title != null) title = Converter.wcsToMbcs (null, this.title, true);
+ byte [] message = null;
+ if (this.message != null) message = Converter.wcsToMbcs (null, this.message, true);
+
+ int[] buttonsPtr = new int [buttons.length];
+ for (int i=0; i<buttons.length; i++) {
+ byte[] text = Converter.wcsToMbcs (null, buttons [i], true);
+ int textPtr = OS.malloc (text.length);
+ OS.memmove (textPtr, text, text.length);
+ buttonsPtr [i] = textPtr;
+ }
+
+ int button = OS.PtAlert (parentHandle, null, title, phImage, message, null, buttons.length, buttonsPtr, null, 0, buttons.length, OS.Pt_MODAL);
+
+ for (int i=0; i<buttons.length; i++) {
+ OS.free (buttonsPtr [i]);
+ }
+
+ if ((style & (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) == (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) {
+ if (button == 1) return SWT.ABORT;
+ if (button == 2) return SWT.RETRY;
+ return SWT.IGNORE;
+ }
+ if ((style & (SWT.RETRY | SWT.CANCEL)) == (SWT.RETRY | SWT.CANCEL)) {
+ return (button == 1) ? SWT.RETRY : SWT.CANCEL;
+ }
+ if ((style & (SWT.YES | SWT.NO | SWT.CANCEL)) == (SWT.YES | SWT.NO | SWT.CANCEL)) {
+ if (button == 1) return SWT.YES;
+ if (button == 2) return SWT.NO;
+ return SWT.CANCEL;
+ }
+ if ((style & (SWT.YES | SWT.NO)) == (SWT.YES | SWT.NO)) {
+ return (button == 1) ? SWT.YES : SWT.NO;
+ }
+ if ((style & (SWT.OK | SWT.CANCEL)) == (SWT.OK | SWT.CANCEL)) {
+ return (button == 1) ? SWT.OK : SWT.CANCEL;
+ }
+ if ((style & SWT.OK) == SWT.OK && button == 1) return SWT.OK;
+ return SWT.CANCEL;
+}
+public void setMessage (String string) {
+ message = string;
+}
+}
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
new file mode 100755
index 0000000000..0e9b4579fc
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java
@@ -0,0 +1,121 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public class ProgressBar extends Control {
+
+public ProgressBar (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+
+/*
+* Not done - check Windows
+*/
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int width = wHint, height = hHint;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ if (width == SWT.DEFAULT) {
+ width = 64;
+// width = getMaximum() - getMinimum() + 1;
+ }
+ if (height == SWT.DEFAULT) height = 15;
+ } else {
+ if (height == SWT.DEFAULT) {
+ height = 64;
+// height = getMaximum() - getMinimum() + 1;
+ }
+ if (width == SWT.DEFAULT) width = 15;
+ }
+ PhRect_t rect = new PhRect_t ();
+ PhArea_t area = new PhArea_t ();
+ rect.lr_x = (short) (width - 1);
+ rect.lr_y = (short) (height - 1);
+ OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
+ width = area.size_w;
+ height = area.size_h;
+ return new Point (width, height);
+}
+
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int clazz = display.PtProgress;
+ int parentHandle = parent.handle;
+ int [] args = {
+// OS.Pt_ARG_GAUGE_FLAGS, OS.Pt_GAUGE_LIVE, OS.Pt_GAUGE_LIVE,
+ OS.Pt_ARG_ORIENTATION, (style & SWT.HORIZONTAL) != 0 ? OS.Pt_HORIZONTAL : OS.Pt_VERTICAL, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+int processPaint (int damage) {
+ OS.PtSuperClassDraw (OS.PtProgress (), handle, damage);
+ return super.processPaint (damage);
+}
+
+public int getMaximum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getMinimum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_GAUGE_VALUE, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public void setMaximum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int minimum = getMinimum();
+ if (0 <= minimum && minimum < value) {
+ int [] args = {OS.Pt_ARG_MAXIMUM, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+ }
+}
+
+public void setMinimum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int maximum = getMaximum();
+ if (0 <= value && value < maximum) {
+ int [] args = {OS.Pt_ARG_MINIMUM, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+ }
+}
+
+public void setSelection (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 0) return;
+ int [] args = {OS.Pt_ARG_GAUGE_VALUE, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+} \ 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
new file mode 100755
index 0000000000..2f97a08506
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java
@@ -0,0 +1,225 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public /*final*/ class Sash extends Control {
+ boolean dragging;
+ int startX, startY, lastX, lastY;
+
+public Sash (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+
+public void addSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+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.HORIZONTAL) != 0) {
+ width += DEFAULT_WIDTH; height += 3;
+ } else {
+ width += 3; height += DEFAULT_HEIGHT;
+ }
+ if (wHint != SWT.DEFAULT) width = wHint + (border * 2);
+ if (hHint != SWT.DEFAULT) height = hHint + (border * 2);
+ return new Point (width, height);
+}
+
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int clazz = display.PtContainer;
+ int parentHandle = parent.handle;
+ int cursor = ((style & SWT.HORIZONTAL) != 0) ? OS.Ph_CURSOR_DRAG_VERTICAL : OS.Ph_CURSOR_DRAG_HORIZONTAL;
+ int [] args = {
+ OS.Pt_ARG_CURSOR_TYPE, cursor, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+void drawBand (int x, int y, int width, int height) {
+ if (parent == null) return;
+ if (parent.isDisposed ()) return;
+ int parentHandle = parent.handle;
+ if (!OS.PtWidgetIsRealized (parentHandle)) return;
+ int phGC = OS.PgCreateGC (0); // NOTE: PgCreateGC ignores the parameter
+ if (phGC == 0) return;
+ int [] args = {OS.Pt_ARG_COLOR, 0, 0, OS.Pt_ARG_FILL_COLOR, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int foreground = args [1];
+ int background = args [4];
+ int color = foreground ^ ~background;
+ int prevContext = OS.PgSetGC (phGC);
+ OS.PgSetRegion (OS.PtWidgetRid (parentHandle));
+ OS.PgSetDrawMode (OS.Pg_DRAWMODE_XOR);
+ OS.PgSetFillColor (color);
+ OS.PgDrawIRect (x, y, x + width - 1, y + height - 1, OS.Pg_DRAW_FILL);
+ OS.PgSetGC (prevContext);
+ OS.PgDestroyGC (phGC);
+}
+
+int processMouse (int info) {
+ int result = super.processMouse (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);
+ 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) return result;
+
+ int x = pe.pos_x + ev.translation_x;
+ int y = pe.pos_y + ev.translation_y;
+ PhArea_t area = new PhArea_t();
+ OS.PtWidgetArea (handle, area);
+ Event event = new Event ();
+ int width = event.width = area.size_w;
+ int height = event.height = area.size_h;
+ switch (ev.type) {
+ case OS.Ph_EV_BUT_PRESS:
+ PhRect_t rect = new PhRect_t ();
+ PhPoint_t pos = new PhPoint_t();
+ pos.x = pe.pos_x;
+ pos.y = pe.pos_y;
+ 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);
+ 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 */
+ startX = x;
+ startY = y;
+ lastX = area.pos_x;
+ lastY = area.pos_y;
+
+ /* The event must be sent because doit flag is used */
+ event.x = lastX; event.y = lastY;
+ event.detail = SWT.DRAG;
+
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the selection
+ * event. If this happens, end the processing of the
+ * Windows message by returning zero as the result of
+ * the window proc.
+ */
+ sendEvent (SWT.Selection, event);
+ if (isDisposed ()) return OS.Pt_END;
+
+ /* Draw the banding rectangle */
+ if (event.doit) {
+ dragging = true;
+ menuShell ().bringToTop ();
+ OS.PtFlush ();
+ drawBand (lastX = event.x, lastY = event.y, width, height);
+ }
+ break;
+ case OS.Ph_EV_BUT_RELEASE:
+ if (ev.subtype != OS.Ph_EV_RELEASE_PHANTOM) {
+ return result;
+ }
+ /* Compute the banding rectangle */
+ if (!dragging) return result;
+ dragging = false;
+
+ /* The event must be sent because doit flag is used */
+ event.x = lastX; event.y = lastY;
+ drawBand (lastX, lastY, width, height);
+ sendEvent (SWT.Selection, event);
+ // widget could be disposed at this point
+ break;
+ case OS.Ph_EV_PTR_MOTION_BUTTON:
+ case OS.Ph_EV_PTR_MOTION_NOBUTTON:
+ case OS.Ph_EV_DRAG:
+ if (ev.subtype != OS.Ph_EV_DRAG_MOTION_EVENT) {
+ return result;
+ }
+ if (!dragging) return result;
+
+ /* 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;
+ int newX = lastX, newY = lastY;
+ if ((style & SWT.VERTICAL) != 0) {
+ newX = Math.min (Math.max (0, x - startX), clientWidth - width);
+ } else {
+ newY = Math.min (Math.max (0, y - startY), clientHeight - height);
+ }
+ if ((newX == lastX) && (newY == lastY)) return result;
+ drawBand (lastX, lastY, width, height);
+
+ /* The event must be sent because doit flag is used */
+ event.x = newX; event.y = newY;
+ event.detail = SWT.DRAG;
+
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the selection
+ * event. If this happens, end the processing of the
+ * Windows message by returning zero as the result of
+ * the window proc.
+ */
+ sendEvent (SWT.Selection, event);
+ if (isDisposed ()) return OS.Pt_END;
+
+ /* Draw the banding rectangle */
+ if (event.doit) {
+ lastX = event.x; lastY = event.y;
+ OS.PtFlush ();
+ drawBand (lastX, lastY, width, height);
+ }
+ break;
+ }
+ return result;
+}
+
+int processPaint (int damage) {
+ OS.PtSuperClassDraw (OS.PtContainer (), handle, damage);
+ sendPaintEvent (damage);
+ return OS.Pt_CONTINUE;
+}
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, 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
new file mode 100755
index 0000000000..96820ad7b6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java
@@ -0,0 +1,167 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public /*final*/ class Scale extends Control {
+
+
+public Scale (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ PhDim_t dim = new PhDim_t();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
+ OS.PtWidgetPreferredSize(handle, dim);
+ int width = dim.w * 7; int height = dim.h;
+ if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ 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;
+ }
+ return new Point (width, height);
+}
+
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int clazz = display.PtSlider;
+ int parentHandle = parent.handle;
+ int [] args = {
+ 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_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+public int getIncrement () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getMaximum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getMinimum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getPageIncrement () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_SCROLL_POSITION, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+void hookEvents () {
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_SLIDER_MOVE, windowProc, SWT.Selection);
+}
+
+int processPaint (int damage) {
+ OS.PtSuperClassDraw (OS.PtSlider (), handle, damage);
+ return super.processPaint (damage);
+}
+
+int processSelection (int info) {
+ if (info == 0) return OS.Pt_CONTINUE;
+ sendEvent(SWT.Selection);
+ return OS.Pt_CONTINUE;
+}
+
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+public void setIncrement (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_INCREMENT, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setMaximum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MAXIMUM, value - 1, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setMinimum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MINIMUM, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setPageIncrement (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PAGE_INCREMENT, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setSelection (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_SCROLL_POSITION, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java
new file mode 100755
index 0000000000..3b810a2ab2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java
@@ -0,0 +1,306 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public class ScrollBar extends Widget {
+ Scrollable parent;
+
+ScrollBar (Scrollable parent, int style, int handle) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ this.handle = handle;
+ createWidget (0);
+}
+
+ScrollBar (Scrollable parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget (0);
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+
+public void addSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+void createHandle (int index) {
+ if (handle != 0) return;
+ int parentHandle = parent.scrolledHandle;
+ int [] args = {
+ 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_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 () {
+ Scrollable parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.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;
+}
+
+public int getIncrement () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getMinimum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getMaximum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getPageIncrement () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public Scrollable getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
+
+public int getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_SCROLL_POSITION, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public Point getSize () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return new Point (args [1], args [4]);
+}
+
+public int getThumb () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_SLIDER_SIZE, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public boolean getVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle = topHandle ();
+ int [] args = {OS.Pt_ARG_FLAGS, 0, 0};
+ OS.PtGetResources (topHandle, args.length / 3, args);
+ return (args [1] & OS.Pt_DELAY_REALIZE) == 0;
+}
+
+void hookEvents () {
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_SCROLL_MOVE, windowProc, SWT.Selection);
+}
+
+public boolean isEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getEnabled () && parent.isEnabled ();
+}
+
+public boolean isVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return OS.PtWidgetIsRealized (handle);
+}
+
+int processSelection (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;
+ PtScrollbarCallback_t cb = new PtScrollbarCallback_t ();
+ OS.memmove (cb, cbinfo.cbdata, PtScrollbarCallback_t.sizeof);
+ Event event = new Event ();
+ switch (cb.action) {
+ case OS.Pt_SCROLL_DRAGGED:
+ event.detail = SWT.DRAG;
+ break;
+ case OS.Pt_SCROLL_TO_MIN:
+ event.detail = SWT.HOME;
+ break;
+ case OS.Pt_SCROLL_TO_MAX:
+ event.detail = SWT.END;
+ break;
+ case OS.Pt_SCROLL_INCREMENT:
+ event.detail = SWT.ARROW_DOWN;
+ break;
+ case OS.Pt_SCROLL_DECREMENT :
+ event.detail = SWT.ARROW_UP;
+ break;
+ case OS.Pt_SCROLL_PAGE_DECREMENT:
+ event.detail = SWT.PAGE_UP;
+ break;
+ case OS.Pt_SCROLL_PAGE_INCREMENT:
+ event.detail = SWT.PAGE_DOWN;
+ break;
+ }
+ sendEvent(SWT.Selection, event);
+ return OS.Pt_CONTINUE;
+}
+
+public void removeSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+void setBounds (int x, int y, int width, int height) {
+ PhArea_t area = new PhArea_t ();
+ area.pos_x = (short) x;
+ area.pos_y = (short) y;
+ 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 = {OS.Pt_ARG_AREA, ptr, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+ OS.free (ptr);
+}
+
+public void setEnabled (boolean enabled) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {
+ OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_BLOCKED, OS.Pt_BLOCKED,
+ OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_GHOST, OS.Pt_GHOST,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+public void setIncrement (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_INCREMENT, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setMaximum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MAXIMUM, value - 1, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setMinimum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MINIMUM, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setPageIncrement (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PAGE_INCREMENT, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setSelection (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_SCROLL_POSITION, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setThumb (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_SLIDER_SIZE, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (selection < 0) return;
+ if (minimum < 0) return;
+ if (maximum < 0) return;
+ if (thumb < 1) return;
+ if (maximum - minimum - thumb < 0) return;
+ if (increment < 1) return;
+ if (pageIncrement < 1) return;
+ int [] args = {
+ OS.Pt_ARG_SCROLL_POSITION, selection, 0,
+ OS.Pt_ARG_INCREMENT, increment, 0,
+ OS.Pt_ARG_PAGE_INCREMENT, pageIncrement, 0,
+ OS.Pt_ARG_SLIDER_SIZE, thumb, 0,
+ OS.Pt_ARG_MINIMUM, minimum, 0,
+ OS.Pt_ARG_MAXIMUM, maximum - 1, 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setVisible (boolean visible) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {
+ OS.Pt_ARG_FLAGS, visible ? 0 : OS.Pt_DELAY_REALIZE, OS.Pt_DELAY_REALIZE,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ if (visible) {
+ sendEvent (SWT.Show);
+ OS.PtRealizeWidget (handle);
+ parent.resizeClientArea ();
+ } else {
+ OS.PtUnrealizeWidget (handle);
+ parent.resizeClientArea ();
+ sendEvent(SWT.Hide);
+ }
+}
+
+}
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
new file mode 100755
index 0000000000..ac2121a3de
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java
@@ -0,0 +1,120 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public abstract class Scrollable extends Control {
+ int scrolledHandle;
+ ScrollBar horizontalBar, verticalBar;
+
+Scrollable () {
+ /* Do nothing */
+}
+
+public Scrollable (Composite parent, int style) {
+ super (parent, style);
+}
+
+void createScrollBars () {
+ /* Search the handle to find the scroll bars */
+ int child = OS.PtWidgetChildFront (handle);
+ while (child != 0) {
+ if (OS.PtWidgetClass (child) == OS.PtScrollbar ()) {
+ int [] args = {OS.Pt_ARG_ORIENTATION, 0, 0};
+ OS.PtGetResources (child, args.length / 3, args);
+ switch (args [1]) {
+ case OS.Pt_HORIZONTAL:
+ horizontalBar = new ScrollBar (this, SWT.HORIZONTAL, child);
+ break;
+ case OS.Pt_VERTICAL:
+ verticalBar = new ScrollBar (this, SWT.VERTICAL, child);
+ break;
+ }
+ }
+ child = OS.PtWidgetBrotherBehind (child);
+ }
+}
+
+void deregister () {
+ super.deregister ();
+ if (scrolledHandle != 0) WidgetTable.remove (scrolledHandle);
+}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ PhRect_t rect = new PhRect_t ();
+ PhArea_t area = new PhArea_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);
+ OS.PtSetAreaFromWidgetCanvas (scrolledHandle != 0 ? scrolledHandle : handle, rect, area);
+ if (horizontalBar != null && horizontalBar.getVisible ()) {
+ Point size = horizontalBar.getSize ();
+ area.size_h += size.y;
+ }
+ if (verticalBar != null && verticalBar.getVisible ()) {
+ Point size = verticalBar.getSize ();
+ area.size_w += size.x;
+ }
+ return new Rectangle (area.pos_x, area.pos_y, area.size_w, area.size_h);
+}
+
+public Rectangle getClientArea () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ PhRect_t rect = new PhRect_t ();
+ int vParent = OS.PtValidParent (handle, OS.PtContainer ());
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
+ OS.PtCalcCanvas (vParent, rect);
+ int width = rect.lr_x - rect.ul_x + 1;
+ int height = rect.lr_y - rect.ul_y + 1;
+ return new Rectangle (0, 0, width, height);
+}
+
+public ScrollBar getHorizontalBar () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return horizontalBar;
+}
+
+public ScrollBar getVerticalBar () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return verticalBar;
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ scrolledHandle = 0;
+}
+
+void resizeClientArea () {
+ /* Do nothing */
+}
+
+void releaseWidget () {
+ if (horizontalBar != null) horizontalBar.releaseWidget ();
+ if (verticalBar != null) verticalBar.releaseWidget ();
+ horizontalBar = verticalBar = null;
+ super.releaseWidget ();
+}
+
+void register () {
+ super.register ();
+ if (scrolledHandle != 0) WidgetTable.put (scrolledHandle, this);
+}
+
+int topHandle () {
+ if (scrolledHandle == 0) return handle;
+ return scrolledHandle;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItem.java
new file mode 100755
index 0000000000..7b590263a7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItem.java
@@ -0,0 +1,320 @@
+package org.eclipse.swt.widgets;
+
+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.
+ */
+abstract class SelectableItem extends Item {
+ protected static final int CHECKBOX_PADDING = 1; // Space behind check box, before item image or text
+
+ private SelectableItemWidget parent; // parent widget of the receiver
+ private boolean isSelected = false; // item selection state
+ private boolean isChecked = false; // item checked state. Can be one of checked and unchecked
+ private boolean isGrayed = false; // item grayed state. The gray state is combined with the
+ // checked state to create gray checked and gray unchecked.
+/**
+ * Create a new instance of the receiver.
+ * @param parent - widget the receiver is created in
+ * @param style - widget style. see Widget class for details
+ */
+SelectableItem(SelectableItemWidget parent, int style) {
+ super(parent, style);
+ setParent(parent);
+ addListener(SWT.Dispose, new Listener() {
+ public void handleEvent(Event event) {disposeItem();}});
+}
+/**
+ * Subclasses should free resources here
+ */
+void disposeItem() {
+ setParent(null);
+}
+/**
+ * Draw the check box of the receiver at 'position' using 'gc'.
+ * @param gc - GC to draw on.
+ * @param destinationPosition - position on the GC to draw at.
+ * @return Answer the position where drawing stopped.
+ */
+Point drawCheckbox(GC gc, Point position) {
+ SelectableItemWidget parent = getSelectableParent();
+ Image image;
+ Point imageExtent;
+ Rectangle imageBounds;
+ int imageOffset;
+ int xInset;
+ int yInset;
+
+ if (getGrayed() == true) {
+ image = parent.getGrayUncheckedImage();
+ }
+ else {
+ image = parent.getUncheckedImage();
+ }
+ if (image != null) {
+ imageExtent = parent.getCheckBoxExtent();
+ imageOffset = (parent.getItemHeight() - imageExtent.y) / 2;
+ gc.drawImage(image, position.x, position.y + imageOffset);
+ if (getChecked() == true) {
+ image = parent.getCheckMarkImage();
+ imageBounds = image.getBounds();
+ xInset = (imageExtent.x - imageBounds.width) / 2;
+ yInset = (imageExtent.y - imageBounds.height) / 2;
+ gc.drawImage(image, position.x + xInset, position.y + imageOffset + yInset);
+ }
+ position.x += imageExtent.x;
+ }
+ position.x += CHECKBOX_PADDING; // leave extra space behind check box
+ return position;
+}
+void drawInsertMark(GC gc, Point position) {
+ SelectableItemWidget parent = getSelectableParent();
+ Point selectionExtent = getSelectionExtent();
+ final int markerWidth = getInsertMarkWidth();
+ int insertMarkYOffset = 0;
+
+ if (selectionExtent == null) {
+ return;
+ }
+ if (parent.isInsertAfter()) {
+ insertMarkYOffset = selectionExtent.y - markerWidth;
+ }
+ gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ gc.fillRectangle(position.x, position.y + insertMarkYOffset, selectionExtent.x, markerWidth);
+ gc.setBackground(parent.getBackground());
+}
+/**
+ * Answer the bounding rectangle of the item check box.
+ * All points within this rectangle hit the check box.
+ */
+Rectangle getCheckboxBounds() {
+ SelectableItemWidget parent = getSelectableParent();
+ Point checkBoxExtent;
+ int redrawPosition;
+ Rectangle checkboxBounds = new Rectangle(0, 0, 0, 0);
+
+ if (isCheckable() == true) {
+ checkboxBounds.x = getCheckboxXPosition();
+ redrawPosition = parent.getRedrawY(this);
+ if (redrawPosition != -1) {
+ checkboxBounds.y = redrawPosition;
+ }
+ checkBoxExtent = parent.getCheckBoxExtent();
+ checkboxBounds.width = checkBoxExtent.x;
+ checkboxBounds.height = checkBoxExtent.y;
+ checkboxBounds.y += (parent.getItemHeight() - checkBoxExtent.y) / 2;
+ }
+ return checkboxBounds;
+}
+/**
+ * Answer the x position of the item check box
+ */
+abstract int getCheckboxXPosition();
+/**
+ * Return whether or not the receiver is checked.
+ * Always return false if the parent of the receiver does not
+ * have the CHECK style.
+ */
+public boolean getChecked() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ boolean checked = false;
+
+ if (isCheckable() == true) {
+ checked = isChecked;
+ }
+ return checked;
+}
+/**
+ * Answer the display of the receiver's parent widget.
+ */
+public Display getDisplay() {
+ SelectableItemWidget parent = getSelectableParent();
+
+ if (parent == null) {
+ error(SWT.ERROR_WIDGET_DISPOSED);
+ }
+ return parent.getDisplay();
+}
+
+/**
+ * Gets the grayed state.
+ * <p>
+ * @return the item grayed state.
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ */
+public boolean getGrayed () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ boolean grayed = false;
+
+ if (isCheckable() == true) {
+ grayed = isGrayed;
+ }
+ return grayed;
+}
+/**
+ * Return the width in pixels of the line drawn to indicate the
+ * drop insert position during a drag and drop operation.
+ */
+int getInsertMarkWidth() {
+ return 2;
+}
+/**
+ * Answer the parent widget of the receiver.
+ */
+SelectableItemWidget getSelectableParent() {
+ return parent;
+}
+/**
+ * Answer the background color to use for drawing the
+ * selection rectangle.
+ */
+Color getSelectionBackgroundColor() {
+ Display display = getSelectableParent().getDisplay();
+
+ return display.getSystemColor(SWT.COLOR_LIST_SELECTION);
+}
+/**
+ * Return the size of the rectangle drawn to indicate the
+ * selected state of the receiver.
+ */
+abstract Point getSelectionExtent();
+/**
+ * Answer the foreground color to use for drawing the
+ * selection rectangle.
+ */
+Color getSelectionForegroundColor() {
+ Display display = getSelectableParent().getDisplay();
+
+ return display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);
+}
+/**
+ * Return the x position of the selection rectangle
+ */
+abstract int getSelectionX();
+/**
+ * Answer whether 'posiiton' is inside the item check box.
+ * @return
+ * true - item check box hit
+ * false - item check box not hit
+ */
+boolean isCheckHit(Point position) {
+ boolean isCheckHit = false;
+
+ if (isCheckable() == true) {
+ isCheckHit = getCheckboxBounds().contains(position);
+ }
+ return isCheckHit;
+}
+/**
+ * Return whether or not the receiver has a check box and can
+ * be checked.
+ */
+boolean isCheckable() {
+ return (getSelectableParent().getStyle() & SWT.CHECK) != 0;
+}
+/**
+ * Answer whether the receiver is selected.
+ * @return
+ * true - the receiver is selected
+ * false - the receiver is not selected
+ */
+boolean isSelected() {
+ return isSelected;
+}
+/**
+ * Redraw the insert mark
+ * @param yPosition - y position in the receiver's client area
+ * where the item should be drawn.
+ */
+void redrawInsertMark(int yPosition) {
+ SelectableItemWidget parent = getSelectableParent();
+ Point selectionExtent = getSelectionExtent();
+ int redrawHeight = getInsertMarkWidth();
+
+ if (selectionExtent != null) {
+ parent.redraw(getSelectionX(), yPosition, selectionExtent.x, redrawHeight, false);
+ parent.redraw(getSelectionX(), yPosition + selectionExtent.y - redrawHeight, selectionExtent.x, redrawHeight, false);
+ }
+}
+/**
+ * Redraw the selection
+ * @param yPosition - y position in the receiver's client area
+ * where the item should be drawn.
+ */
+void redrawSelection(int yPosition) {
+ SelectableItemWidget parent = getSelectableParent();
+ Point selectionExtent = getSelectionExtent();
+
+ if (selectionExtent != null) {
+ parent.redraw(getSelectionX(), yPosition, selectionExtent.x, selectionExtent.y, false);
+ }
+}
+/**
+ * Set the checked state to 'checked' if the parent of the
+ * receiver has the CHECK style.
+ */
+public void setChecked(boolean checked) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItemWidget parent = getSelectableParent();
+ Rectangle redrawRectangle = getCheckboxBounds();
+
+ if (isCheckable() == true && isChecked != checked) {
+ isChecked = checked;
+ parent.redraw(
+ redrawRectangle.x, redrawRectangle.y,
+ redrawRectangle.width, redrawRectangle.height, false);
+ }
+}
+
+/**
+ * Sets the grayed state.
+ * <p>
+ * @param grayed the new grayed state.
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ */
+public void setGrayed (boolean grayed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItemWidget parent = getSelectableParent();
+ Rectangle redrawRectangle = getCheckboxBounds();
+
+ if (isCheckable() == true && isGrayed != grayed) {
+ isGrayed = grayed;
+ parent.redraw(
+ redrawRectangle.x, redrawRectangle.y,
+ redrawRectangle.width, redrawRectangle.height, false);
+ }
+}
+
+/**
+ * Set the receiver's parent widget to 'parent'.
+ */
+void setParent(SelectableItemWidget parent) {
+ this.parent = parent;
+}
+/**
+ * Set whether the receiver is selected.
+ * @param selected - true=the receiver is selected
+ * false=the receiver is not selected
+ */
+void setSelected(boolean selected) {
+ isSelected = selected;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItemWidget.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItemWidget.java
new file mode 100755
index 0000000000..0eda6178f2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItemWidget.java
@@ -0,0 +1,2027 @@
+package org.eclipse.swt.widgets;
+
+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
+ * type Item. It provides a framework for scrolling and
+ * handles the screen refresh required when adding and
+ * removing items.
+ */
+abstract class SelectableItemWidget extends Composite {
+ private static final int DEFAULT_WIDTH = 64; // used in computeSize if width could not be calculated
+ private static final int DEFAULT_HEIGHT = 64; // used in computeSize if height could not be calculated
+ private static final int HORIZONTAL_SCROLL_INCREMENT = 5; // number of pixel the tree is moved
+ // during horizontal line scrolling
+ private static ImageData UncheckedImageData; // deselected check box image data. used to create an image at run time
+ private static ImageData GrayUncheckedImageData; // grayed deselected check box image data. used to create an image at run time
+ private static ImageData CheckMarkImageData; // check mark image data for check box. used to create an image at run time
+ static {
+ initializeImageData();
+ }
+
+ private int topIndex = 0; // index of the first visible item
+ private int itemHeight = 0; // height of a table item
+ private Point itemImageExtent = null; // size of the item images. Null unless an image is set for any item
+ private int textHeight = -1;
+ private int contentWidth = 0; // width of the widget data (ie. table rows/tree items)
+ private int horizontalOffset = 0;
+ private Vector selectedItems; // indices of the selected items
+ private SelectableItem lastSelectedItem; // item that was selected last
+ private SelectableItem lastFocusItem; // item that had the focus last. Always equals lastSelectedItem
+ // for mouse selection but may differ for keyboard selection
+ private SelectableItem insertItem; // item that draws the insert marker to indicate the drop location in a drag and drop operation
+ private boolean isInsertAfter; // indicates where the insert marker is rendered, at the top or bottom of 'insertItem'
+ private boolean isCtrlSelection = false; // the most recently selected item was
+ // selected using the Ctrl modifier key
+ private boolean isRemovingAll = false; // true=all items are removed. Used to optimize screen updates and to control item selection on dispose.
+ private boolean hasFocus; // workaround for 1FMITIE
+ private Image uncheckedImage; // deselected check box
+ private Image grayUncheckedImage; // grayed check box
+ private Image checkMarkImage; // check mark for selected check box
+ private Point checkBoxExtent = null; // width, height of the item check box
+ private Listener listener; // event listener used for all events. Events are dispatched
+ // to handler methods in handleEvents(Event)
+ private int drawCount = 0; // used to reimplement setRedraw(boolean)
+/**
+ * Create a new instance of ScrollableItemWidget.
+ * @param parent - the parent window of the new instance
+ * @param style - window style for the new instance
+ */
+SelectableItemWidget(Composite parent, int style) {
+ super(parent, style | SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_REDRAW_RESIZE);
+ initialize();
+}
+/**
+ * The SelectableItem 'item' has been added to the tree.
+ * Calculate the vertical scroll bar.
+ * Update the screen to display the new item.
+ * @param item - item that has been added to the receiver.
+ */
+void addedItem(SelectableItem item, int index) {
+ calculateVerticalScrollbar();
+ if (getLastFocus() == null) { // if no item has the focus
+ setLastFocus(item, true); // set focus to new (must be first) item
+ }
+}
+/**
+ * The SelectableItem 'item' is about to be added to the tree.
+ * @param item - item that is about to be added to the receiver.
+ */
+void addingItem(SelectableItem item, int index) {
+ if (index >= 0 && index <= getBottomIndex()) {
+ scrollVerticalAddingItem(index);
+ }
+}
+/**
+ * Set the scroll range of the horizontal scroll bar.
+ * Resize the scroll bar if the scroll range maximum
+ * has changed.
+ */
+void calculateHorizontalScrollbar() {
+ int newMaximum = getContentWidth();
+ ScrollBar horizontalBar = getHorizontalBar();
+
+ if (horizontalBar.getMaximum() != newMaximum) {
+ // The call to setMaximum is ignored if newMaximum is 0.
+ // Therefore we can not rely on getMaximum to subsequently return the number of
+ // items in the receiver. We always have to use getVisibleItemCount().
+ // Never rely on getMaximum to return what you set. It may not accept the
+ // value you set. Even if you use a valid value now the implementation may change
+ // later. That's what caused 1FRLOSG.
+ horizontalBar.setMaximum(newMaximum);
+ if (getVerticalBar().getVisible() == false) { // remove these lines
+ horizontalBar.setMaximum(newMaximum); // when PR 1FIG5CG
+ } // is fixed
+ resizeHorizontalScrollbar();
+ }
+}
+/**
+ * Calculate the height of items in the receiver.
+ * Only the image height is calculated if an item height
+ * has already been calculated. Do nothing if both the item
+ * height and the image height have already been calculated
+ */
+void calculateItemHeight(SelectableItem item) {
+ GC gc;
+ String itemText;
+ int itemHeight = -1;
+
+ if (itemImageExtent != null && textHeight != -1) {
+ return;
+ }
+ itemText = item.getText();
+ if (itemText != null && textHeight == -1) {
+ gc = new GC(this);
+ itemHeight = gc.stringExtent(itemText).y;
+ textHeight = itemHeight;
+ gc.dispose();
+ }
+ if (itemImageExtent == null) {
+ itemImageExtent = getImageExtent(item);
+ if (itemImageExtent != null) {
+ if (itemImageExtent.y > textHeight) {
+ itemHeight = itemImageExtent.y;
+ }
+ else {
+ itemHeight = textHeight;
+ }
+ }
+ }
+ itemHeight += getItemPadding(); // make sure that there is empty space below the image/text
+ if (itemHeight > getItemHeight()) { // only set new item height if it's higher because new,
+ setItemHeight(itemHeight); // smaller item height may not include an icon
+ }
+}
+/**
+ * Calculate the range of items that need to be selected given
+ * the clicked item identified by 'hitItemIndex'
+ * @param hitItemIndex - item that was clicked and that the new
+ * selection range will be based on. This index is relative to
+ * the top index.
+ */
+int [] calculateShiftSelectionRange(int hitItemIndex) {
+ int selectionRange[] = new int[] {-1, -1};
+ SelectableItem closestItem = null;
+ SelectableItem selectedItem;
+ Enumeration selectedItems = getSelectionVector().elements();
+
+ while (selectedItems.hasMoreElements() == true) {
+ selectedItem = (SelectableItem) selectedItems.nextElement();
+ if (closestItem == null) {
+ closestItem = selectedItem;
+ }
+ else
+ if (Math.abs(hitItemIndex - getVisibleIndex(selectedItem)) <
+ Math.abs(hitItemIndex - getVisibleIndex(closestItem))) {
+ closestItem = selectedItem;
+ }
+ }
+ if (closestItem == null) { // no item selected
+ closestItem = getLastSelection(); // item selected last may still have the focus
+ }
+ if (closestItem != null) {
+ selectionRange[0] = getVisibleIndex(closestItem);
+ selectionRange[1] = hitItemIndex;
+ }
+ return selectionRange;
+}
+/**
+ * Set the scroll range of the vertical scroll bar.
+ * Resize the scroll bar if the scroll range maximum
+ * has changed.
+ */
+void calculateVerticalScrollbar() {
+ int newMaximum = getVisibleItemCount();
+ ScrollBar verticalBar = getVerticalBar();
+
+ // The call to setMaximum is ignored if newMaximum is 0.
+ // Therefore we can not rely on getMaximum to subsequently return the number of
+ // items in the receiver. We always have to use getVisibleItemCount().
+ // Never rely on getMaximum to return what you set. It may not accept the
+ // value you set. Even if you use a valid value now the implementation may change
+ // later. That's what caused 1FRLOSG.
+ verticalBar.setMaximum(newMaximum);
+ if (getHorizontalBar().getVisible() == false) { // remove these lines
+ verticalBar.setMaximum(newMaximum); // when PR 1FIG5CG
+ } // is fixed
+ resizeVerticalScrollbar();
+}
+
+/**
+ * Answer the size of the receiver needed to display all items.
+ * The length of the longest item in the receiver is used for the
+ * width.
+ */
+public Point computeSize(int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int width = getContentWidth();
+ int height = getItemCount() * getItemHeight();
+ int style = getStyle();
+ int scrollBarWidth = computeTrim(0, 0, 0, 0).width;
+
+ if (width == 0) {
+ width = DEFAULT_WIDTH;
+ }
+ if (height == 0) {
+ height = DEFAULT_HEIGHT;
+ }
+ if (wHint != SWT.DEFAULT) {
+ width = wHint;
+ }
+ if (hHint != SWT.DEFAULT) {
+ height = hHint;
+ }
+ if ((getStyle() & SWT.V_SCROLL) != 0) {
+ width += scrollBarWidth;
+ }
+ if ((getStyle() & SWT.H_SCROLL) != 0) {
+ height += scrollBarWidth;
+ }
+ return new Point(width, height);
+}
+/**
+ * Do a ctrl+shift selection meaning the ctrl and shift keys
+ * were pressed when the mouse click on an item occurred.
+ * If an already selected item was clicked the focus is moved to
+ * that item.
+ * If the previous selection was a ctrl or ctrl+shift selection
+ * the range between the last selected item and the clicked item
+ * is selected.
+ * Otherwise a regular shift selection is performed.
+ * @param hitItem - specifies the clicked item
+ * @param hitItemIndex - specifies the index of the clicked item
+ * relative to the first item.
+ */
+void ctrlShiftSelect(SelectableItem hitItem, int hitItemIndex) {
+ int fromIndex = -1;
+ int toIndex = -1;
+ int lastSelectionIndex = -1;
+ int selectionRange[];
+ SelectableItem lastSelection = getLastSelection();
+
+ if (lastSelection != null) {
+ lastSelectionIndex = getVisibleIndex(lastSelection);
+ }
+ if ((getSelectionVector().contains(hitItem) == true) && // clicked an already selected item?
+ (hitItemIndex != lastSelectionIndex)) { // and click was not on last selected item?
+ setLastSelection(hitItem, true); // set last selection which also sets the focus
+ }
+ else
+ if (isCtrlSelection() == true) { // was last selection ctrl/ctrl+shift selection?
+ fromIndex = lastSelectionIndex; // select from last selection
+ toIndex = hitItemIndex;
+ }
+ else { // clicked outside existing selection range
+ selectionRange = calculateShiftSelectionRange(hitItemIndex);
+ fromIndex = selectionRange[0];
+ toIndex = selectionRange[1];
+ }
+ if (fromIndex != -1 && toIndex != -1) {
+ selectRange(fromIndex, toIndex);
+ }
+}
+/**
+ * Deselect 'item'.
+ * @param item - item that should be deselected
+ */
+void deselect(SelectableItem item) {
+ Vector selectedItems = getSelectionVector();
+
+ if ((item != null) && (item.isSelected() == true)) {
+ item.setSelected(false);
+ redrawSelection(item);
+ selectedItems.removeElement(item);
+ }
+}
+/**
+ * Deselect all item except 'keepSelected'.
+ * @param keepSelected - item that should remain selected
+ */
+void deselectAllExcept(SelectableItem keepSelected) {
+ Vector selectedItems = getSelectionVector();
+ Vector deselectedItems = new Vector(selectedItems.size());
+ Enumeration elements = selectedItems.elements();
+ SelectableItem item;
+
+ // deselect and repaint previously selected items
+ while (elements.hasMoreElements() == true) {
+ item = (SelectableItem) elements.nextElement();
+ if (item.isSelected() == true && item != keepSelected) {
+ item.setSelected(false);
+ // always redraw the selection, even if item is redrawn again
+ // in setLastSelection. Fixes 1G0GQ8W
+ redrawSelection(item);
+ deselectedItems.addElement(item);
+ }
+ }
+ elements = deselectedItems.elements();
+ while (elements.hasMoreElements() == true) {
+ item = (SelectableItem) elements.nextElement();
+ selectedItems.removeElement(item);
+ }
+ setLastSelection(keepSelected, false);
+}
+/**
+ * Deselect all items except those in 'keepSelected'.
+ * @param keepSelected - items that should remain selected
+ */
+void deselectAllExcept(Vector keepSelected) {
+ Vector selectedItems = getSelectionVector();
+ Vector deselectedItems = new Vector(selectedItems.size());
+ Enumeration elements = selectedItems.elements();
+ SelectableItem item;
+
+ // deselect and repaint previously selected items
+ while (elements.hasMoreElements() == true) {
+ item = (SelectableItem) elements.nextElement();
+ if (item.isSelected() == true && keepSelected.contains(item) == false) {
+ item.setSelected(false);
+ // always redraw the selection, even if item is redrawn again
+ // in setLastSelection. Fixes 1G0GQ8W
+ redrawSelection(item);
+ deselectedItems.addElement(item);
+ }
+ }
+ elements = deselectedItems.elements();
+ while (elements.hasMoreElements() == true) {
+ item = (SelectableItem) elements.nextElement();
+ selectedItems.removeElement(item);
+ }
+ if (keepSelected.size() > 0) {
+ setLastSelection((SelectableItem) keepSelected.firstElement(), false);
+ }
+}
+/**
+ * Deselect 'item'. Notify listeners.
+ * @param item - item that should be deselected
+ */
+void deselectNotify(SelectableItem item) {
+ Event event = new Event();
+
+ if (item.isSelected() == true) {
+ deselect(item);
+ setLastSelection(item, true);
+ update(); // looks better when event notification takes long to return
+ }
+ event.item = item;
+ notifyListeners(SWT.Selection, event);
+}
+/**
+ * Deselect all items starting at and including 'fromIndex'
+ * stopping at and including 'toIndex'.
+ * @param fromIndex - index relative to the first item where
+ * deselection should start. Deselecion includes 'fromIndex'.
+ * @param toIndex - index relative to the first item where
+ * deselection should stop. Deselecion includes 'toIndex'.
+ */
+void deselectRange(int fromIndex, int toIndex) {
+ if (fromIndex > toIndex) {
+ for (int i = toIndex; i <= fromIndex; i++) {
+ deselect(getVisibleItem(i));
+ }
+ }
+ else
+ if (fromIndex < toIndex) {
+ for (int i = toIndex; i >= fromIndex; i--) {
+ deselect(getVisibleItem(i));
+ }
+ }
+ setLastSelection(getVisibleItem(fromIndex), true);
+}
+/**
+ * Modifier Key Action
+ * None Remove old selection, move selection down one item
+ * Ctrl Keep old selection, move input focus down one item
+ * Shift Extend selection by one item.
+ * Modifier Key is ignored when receiver has single selection style.
+ * @param keyMask - the modifier key that was pressed
+ */
+void doArrowDown(int keyMask) {
+ SelectableItem lastFocus = getLastFocus();
+ SelectableItem newFocus;
+ int focusItemIndex = getVisibleIndex(lastFocus);
+
+ if (focusItemIndex < (getVisibleItemCount() - 1)) { // - 1 because indices are 0 based
+ focusItemIndex++;
+ newFocus = getVisibleItem(focusItemIndex);
+ if (keyMask == SWT.CTRL && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.SHIFT && isMultiSelect() == true) {
+ shiftSelect(newFocus, focusItemIndex);
+ }
+ else {
+ deselectAllExcept(newFocus);
+ selectNotify(newFocus);
+ }
+ }
+}
+/**
+ * Modifier Key Action
+ * None Scroll receiver to the left
+ * Ctrl See None above
+ * Shift See None above
+ * @param keyMask - the modifier key that was pressed
+ */
+void doArrowLeft(int keyMask) {
+ ScrollBar horizontalBar = getHorizontalBar();
+ int scrollSelection = horizontalBar.getSelection();
+ int scrollAmount;
+
+ if (horizontalBar.getVisible() == false) {
+ return;
+ }
+ scrollAmount = Math.min(HORIZONTAL_SCROLL_INCREMENT, scrollSelection);
+ horizontalBar.setSelection(scrollSelection - scrollAmount);
+ setHorizontalOffset(horizontalBar.getSelection() * -1);
+}
+/**
+ * Modifier Key Action
+ * None Scroll receiver to the right
+ * Ctrl See None above
+ * Shift See None above
+ * @param keyMask - the modifier key that was pressed
+ */
+void doArrowRight(int keyMask) {
+ ScrollBar horizontalBar = getHorizontalBar();
+ int scrollSelection = horizontalBar.getSelection();
+ int scrollAmount;
+
+ if (horizontalBar.getVisible() == false) {
+ return;
+ }
+ scrollAmount = Math.min( // scroll by the smaller of
+ HORIZONTAL_SCROLL_INCREMENT, // the scroll increment
+ horizontalBar.getMaximum() // and the remaining scroll range
+ - horizontalBar.getPageIncrement()
+ - scrollSelection);
+ horizontalBar.setSelection(scrollSelection + scrollAmount);
+ setHorizontalOffset(horizontalBar.getSelection() * -1);
+}
+/**
+ * Modifier Key Action
+ * None Remove old selection, move selection up one item
+ * Ctrl Keep old selection, move input focus up one item
+ * Shift Extend selection by one item.
+ * Modifier Key is ignored when receiver has single selection style.
+ * @param keyMask - the modifier key that was pressed
+ */
+void doArrowUp(int keyMask) {
+ SelectableItem lastFocus = getLastFocus();
+ SelectableItem newFocus;
+ int focusItemIndex = getVisibleIndex(lastFocus);
+
+ if (focusItemIndex > 0) {
+ focusItemIndex--;
+ newFocus = getVisibleItem(focusItemIndex);
+ if (keyMask == SWT.CTRL && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.SHIFT && isMultiSelect() == true) {
+ shiftSelect(newFocus, focusItemIndex);
+ }
+ else {
+ deselectAllExcept(newFocus);
+ selectNotify(newFocus);
+ }
+ }
+}
+/**
+ * Perform a selection operation on the item check box.
+ * @param item - the item that was clicked
+ */
+void doCheckItem(SelectableItem item) {
+ Event event = new Event();
+
+ item.setChecked(!item.getChecked());
+ event.item = item;
+ event.detail = SWT.CHECK;
+ notifyListeners(SWT.Selection, event);
+}
+/**
+ * Free resources.
+ */
+void doDispose() {
+ setRemovingAll(true);
+ getSelectionVector().removeAllElements();
+ lastFocusItem = null;
+ lastSelectedItem = null;
+ if (uncheckedImage != null) {
+ uncheckedImage.dispose();
+ }
+ if (grayUncheckedImage != null) {
+ grayUncheckedImage.dispose();
+ }
+ if (checkMarkImage != null) {
+ checkMarkImage.dispose();
+ }
+}
+/**
+ * Modifier Key Action
+ * None Remove old selection, move selection to the
+ * last item
+ * Ctrl Keep old selection, move input focus to the
+ * last item
+ * Shift Extend selection to the last item.
+ * Modifier Key is ignored when receiver has single selection style.
+ * @param keyMask - the modifier key that was pressed
+ */
+void doEnd(int keyMask) {
+ SelectableItem lastFocus = getLastFocus();
+ SelectableItem newFocus;
+ int focusItemIndex = getVisibleIndex(lastFocus);
+ int lastItemIndex = getVisibleItemCount() - 1; // - 1 because indices are 0 based
+
+ if (focusItemIndex < lastItemIndex) {
+ newFocus = getVisibleItem(lastItemIndex);
+ if (keyMask == SWT.CTRL && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.SHIFT && isMultiSelect() == true) {
+ shiftSelect(newFocus, lastItemIndex);
+ }
+ else {
+ deselectAllExcept(newFocus);
+ selectNotify(newFocus);
+ }
+ }
+}
+/**
+ * Modifier Key Action
+ * None Remove old selection, move selection to the
+ * first item
+ * Ctrl Keep old selection, move input focus to the
+ * first item
+ * Shift Extend selection to the first item.
+ * Modifier Key is ignored when receiver has single selection style.
+ * @param keyMask - the modifier key that was pressed
+ */
+void doHome(int keyMask) {
+ SelectableItem lastFocus = getLastFocus();
+ SelectableItem newFocus;
+ int firstItemIndex = 0;
+
+ if (getVisibleIndex(lastFocus) > firstItemIndex) {
+ newFocus = getVisibleItem(firstItemIndex);
+ if (keyMask == SWT.CTRL && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.SHIFT && isMultiSelect() == true) {
+ shiftSelect(newFocus, firstItemIndex);
+ }
+ else {
+ deselectAllExcept(newFocus);
+ selectNotify(newFocus);
+ }
+ }
+}
+/**
+ * Perform a mouse select action according to the key state
+ * mask in 'eventStateMask'.
+ * Key state mask is ignored when receiver has the single selection
+ * style.
+ * @param item - the item that was clicked
+ * @param itemIndex - the index of the clicked item relative
+ * to the first item of the receiver
+ * @param eventStateMask - the key state mask of the mouse event
+ * @param button - the mouse button that was pressed
+ */
+void doMouseSelect(SelectableItem item, int itemIndex, int eventStateMask, int button) {
+ if (((eventStateMask & SWT.CTRL) != 0) &&
+ ((eventStateMask & SWT.SHIFT) != 0) &&
+ (isMultiSelect() == true)) {
+ if (getSelectionVector().size() == 0) { // no old selection?
+ selectNotify(item); // do standard CTRL selection
+ }
+ else {
+ ctrlShiftSelect(item, itemIndex);
+ }
+ setCtrlSelection(true);
+ }
+ else
+ if (((eventStateMask & SWT.SHIFT) != 0) && (isMultiSelect() == true)) {
+ shiftSelect(item, itemIndex);
+ setCtrlSelection(false);
+ }
+ else
+ if (((eventStateMask & SWT.CTRL) != 0) && (isMultiSelect() == true)) {
+ toggleSelectionNotify(item);
+ setCtrlSelection(true);
+ }
+ else
+ if (button != 3 || item.isSelected() == false) {
+ // only select the item (and deselect all others) if the mouse click is
+ // not a button 3 click or if a previously unselected item was clicked.
+ // Fixes 1G97L65
+ deselectAllExcept(item);
+ selectNotify(item);
+ setCtrlSelection(false);
+ }
+}
+/**
+ * Modifier Key Action
+ * None Remove old selection, move selection one page down
+ * Ctrl Keep old selection, move input focus one page down
+ * Shift Extend selection one page down
+ * One page is the number of items that can be displayed in the
+ * receiver's canvas without truncating the last item.
+ * The selection is set to the last item if there is no full page
+ * of items left.
+ * Modifier Key is ignored when receiver has single selection style.
+ * @param keyMask - the modifier key that was pressed
+ */
+void doPageDown(int keyMask) {
+ SelectableItem newFocus;
+ int focusItemIndex = getVisibleIndex(getLastFocus());
+ int lastItemIndex = getVisibleItemCount() - 1; // - 1 because indices are 0 based
+ int visibleItemCount;
+
+ if (focusItemIndex < lastItemIndex) {
+ visibleItemCount = getItemCountWhole();
+ focusItemIndex = Math.min(
+ lastItemIndex,
+ focusItemIndex + (visibleItemCount - 1));
+ newFocus = getVisibleItem(focusItemIndex);
+ if (newFocus == null) {
+ return;
+ }
+ if (keyMask == SWT.CTRL && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.SHIFT && isMultiSelect() == true) {
+ shiftSelect(newFocus, focusItemIndex);
+ }
+ else {
+ deselectAllExcept(newFocus);
+ selectNotify(newFocus);
+ }
+ }
+}
+/**
+ * Modifier Key Action
+ * None Remove old selection, move selection one page up
+ * Ctrl Keep old selection, move input focus one page up
+ * Shift Extend selection one page up
+ * One page is the number of items that can be displayed in the
+ * receiver's canvas without truncating the last item.
+ * The selection is set to the first item if there is no full page
+ * of items left.
+ * Modifier Key is ignored when receiver has single selection style.
+ * @param keyMask - the modifier key that was pressed
+ */
+void doPageUp(int keyMask) {
+ SelectableItem newFocus;
+ int focusItemIndex = getVisibleIndex(getLastFocus());
+ int visibleItemCount;
+
+ if (focusItemIndex > 0) {
+ visibleItemCount = getItemCountWhole();
+ focusItemIndex = Math.max(
+ 0,
+ focusItemIndex - (visibleItemCount - 1));
+ newFocus = getVisibleItem(focusItemIndex);
+ if (keyMask == SWT.CTRL && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.SHIFT && isMultiSelect() == true) {
+ shiftSelect(newFocus, focusItemIndex);
+ }
+ else {
+ deselectAllExcept(newFocus);
+ selectNotify(newFocus);
+ }
+ }
+}
+/**
+ * Modifier Key Action
+ * Ctrl Keep old selection, toggle selection of the item
+ * that has the input focus
+ * Shift Extend selection to the item that has the input
+ * focus
+ * Ctrl & Shift Set selection to the item that has input focus
+ * Do nothing if receiver has single selection style.
+ * @param keyMask - the modifier key that was pressed
+ */
+
+void doSpace(int keyMask) {
+ SelectableItem item = getLastFocus();
+ int itemIndex = getVisibleIndex(item);
+
+ if (keyMask == SWT.NULL && item.isSelected() == false) { // do simple space select in SINGLE and MULTI mode
+ deselectAllExcept(item);
+ selectNotify(item);
+ return;
+ }
+ if (isMultiSelect() == false || item == null) {
+ return;
+ }
+ if (keyMask == SWT.CTRL) {
+ toggleSelectionNotify(item);
+ }
+ else
+ if (((keyMask & SWT.CTRL) != 0) && ((keyMask & SWT.SHIFT) != 0)) {
+ deselectAllExcept(item);
+ selectNotify(item);
+ }
+ else
+ if (keyMask == SWT.SHIFT) {
+ shiftSelect(item, itemIndex);
+ }
+}
+/**
+ * Make sure that free space at the bottom of the receiver is
+ * occupied.
+ * There will be new space available below the last item when the
+ * receiver's height is increased. In this case the receiver
+ * is scrolled down to occupy the new space.if the top item is
+ * not the first item of the receiver.
+ */
+void claimBottomFreeSpace() {
+ int clientAreaItemCount = getItemCountWhole();
+ int topIndex = getTopIndex();
+ int newTopIndex;
+ int lastItemIndex = getVisibleItemCount() - topIndex;
+
+ if ((topIndex > 0) &&
+ (lastItemIndex > 0) &&
+ (lastItemIndex < clientAreaItemCount)) {
+ newTopIndex = Math.max(0, topIndex-(clientAreaItemCount-lastItemIndex));
+ setTopIndex(newTopIndex, true);
+ }
+}
+/**
+ * Make sure that free space at the right side of the receiver is
+ * occupied.
+ * There will be new space available at the right side of the receiver
+ * when the receiver's width is increased. In this case the receiver
+ * is scrolled to the right to occupy the new space.if possible.
+ */
+void claimRightFreeSpace() {
+ int clientAreaWidth = getClientArea().width;
+ int newHorizontalOffset = clientAreaWidth - getContentWidth();
+
+ if (newHorizontalOffset - getHorizontalOffset() > 0) { // item is no longer drawn past the right border of the client area
+ newHorizontalOffset = Math.min(0, newHorizontalOffset); // align the right end of the item with the right border of the
+ setHorizontalOffset(newHorizontalOffset); // client area (window is scrolled right)
+ }
+}
+/** Not used right now. Replace focusIn/focusOut with this method once
+ * Display.getFocusWindow returns the new focus window on FocusOut event
+ * (see 1FMITIE)
+ * The focus has moved in to or out of the receiver.
+ * Redraw the item selection to reflect the focus change.
+ * @param event - the focus change event
+ */
+void focusChange(Event event) {
+ Enumeration items = getSelectionVector().elements();
+ SelectableItem lastFocusItem = getLastFocus();
+ SelectableItem item;
+
+ while (items.hasMoreElements() == true) {
+ item = (SelectableItem) items.nextElement();
+ redrawSelection(item);
+ }
+ if (lastFocusItem != null) {
+ redrawSelection(lastFocusItem);
+ }
+}
+/**
+ * The focus has moved in to or out of the receiver.
+ * Redraw the item selection to reflect the focus change.
+ * @param event - the focus change event
+ */
+void focusIn(Event event) {
+ Enumeration items = getSelectionVector().elements();
+ SelectableItem lastFocusItem = getLastFocus();
+ SelectableItem item;
+
+ // Workaround for 1FMITIE
+ hasFocus = true;
+ while (items.hasMoreElements() == true) {
+ item = (SelectableItem) items.nextElement();
+ redrawSelection(item);
+ }
+ if (lastFocusItem != null) {
+ redrawSelection(lastFocusItem);
+ }
+ // Fix blank item on slow machines/VMs. Also fixes 1G0IFMZ.
+ update();
+}
+/**
+ * The focus has moved in to or out of the receiver.
+ * Redraw the item selection to reflect the focus change.
+ * @param event - the focus change event
+ */
+void focusOut(Event event) {
+ Enumeration items = getSelectionVector().elements();
+ SelectableItem lastFocusItem = getLastFocus();
+ SelectableItem item;
+
+ // Workaround for 1FMITIE
+ hasFocus = false;
+ while (items.hasMoreElements() == true) {
+ item = (SelectableItem) items.nextElement();
+ redrawSelection(item);
+ }
+ if (lastFocusItem != null) {
+ redrawSelection(lastFocusItem);
+ }
+ // Fix blank item on slow machines/VMs. Also fixes 1G0IFMZ.
+ update();
+}
+/**
+ * Answer the index of the last item position in the receiver's
+ * client area.
+ * @return 0-based index of the last item position in the tree's
+ * client area.
+ */
+int getBottomIndex() {
+ return getTopIndex() + getItemCountTruncated(getClientArea());
+}
+/**
+ * Answer the size of the check box image.
+ * The calculation is cached and assumes that the images for
+ * the checked and unchecked state are the same size.
+ */
+Point getCheckBoxExtent() {
+ Image checkedImage;
+ Rectangle imageBounds;
+
+ if (checkBoxExtent == null) {
+ checkedImage = getUncheckedImage();
+ if (checkedImage != null) {
+ imageBounds = checkedImage.getBounds();
+ checkBoxExtent = new Point(imageBounds.width, imageBounds.height);
+ }
+ else {
+ checkBoxExtent = new Point(0, 0);
+ }
+ }
+ return checkBoxExtent;
+}
+/**
+ * Answer the image for the selected check box
+ * Answer null if the image couldn't be loaded.
+ */
+Image getCheckMarkImage() {
+ InputStream resourceStream;
+
+ if (checkMarkImage == null) {
+ checkMarkImage = new Image(getDisplay(), CheckMarkImageData);
+ }
+ return checkMarkImage;
+}
+/**
+ * Answer the width of the receiver's content.
+ * Needs to be set by subclasses.
+ */
+int getContentWidth() {
+ return contentWidth;
+}
+/**
+ * Answer the horizontal drawing offset used for scrolling.
+ * This is < 0 if the receiver has been scrolled to the left,
+ * > 0 if the receiver has been scrolled to the right and 0
+ * if the receiver has not been scrolled.
+ */
+int getHorizontalOffset() {
+ return horizontalOffset;
+}
+
+/**
+ * Answer the size of item images. Calculated during the item
+ * height calculation.
+ */
+Point getImageExtent() {
+ return itemImageExtent;
+}
+/**
+ * Answer the image extent of 'item'. Overridden by subclasses.
+ */
+Point getImageExtent(SelectableItem item) {
+ Image image = item.getImage();
+ Rectangle imageBounds;
+ Point imageExtent = null;
+
+ if (image != null) {
+ imageBounds = image.getBounds();
+ imageExtent = new Point(imageBounds.width, imageBounds.height);
+ }
+ return imageExtent;
+}
+/**
+ * Answer the index of 'item' in the receiver.
+ */
+abstract int getIndex(SelectableItem item);
+/**
+ * Answer the first and last index of items that can be displayed in
+ * the area defined by 'clipRectangle'. This includes partial items.
+ * @return
+ * Array -
+ * First element is the index of the first item in 'clipRectangle'.
+ * Second element is the index of the last item in 'clipRectangle'.
+ */
+int[] getIndexRange(Rectangle clipRectangle) {
+ int visibleRange[] = new int[] {0, 0};
+
+ visibleRange[0] = clipRectangle.y / getItemHeight();
+ visibleRange[1] =
+ visibleRange[0] +
+ getItemCountTruncated(clipRectangle) - 1; // - 1 because item index is 0 based
+ return visibleRange;
+}
+/**
+ * Return the item that draws the marker indicating the insert location
+ * in a drag and drop operation
+ */
+SelectableItem getInsertItem() {
+ return insertItem;
+}
+/**
+ * Answer the number of items in the receiver.
+ */
+public abstract int getItemCount();
+/**
+ * Answer the number of items that can be displayed in 'rectangle'.
+ * The result includes partially visible items.
+ */
+int getItemCountTruncated(Rectangle rectangle) {
+ int itemHeight = getItemHeight();
+ int itemCount = 0;
+ int startIndex;
+
+ startIndex = rectangle.y / itemHeight;
+ itemCount = (int) Math.ceil(((float) rectangle.y + rectangle.height) / itemHeight)-startIndex;
+ return itemCount;
+}
+/**
+ * Answer the number of items that can be displayed in the client
+ * area of the receiver.
+ * The result only includes items that completely fit into the
+ * client area.
+ */
+int getItemCountWhole() {
+ return getClientArea().height / getItemHeight();
+}
+/**
+ * Answer the height of an item in the receiver.
+ * The item height is the greater of the item icon height and
+ * text height of the first item that has text or an image
+ * respectively.
+ * Calculate a default item height based on the font height if
+ * no item height has been calculated yet.
+ */
+public int getItemHeight() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ GC gc;
+ if (itemHeight == 0) {
+ gc = new GC(this);
+ itemHeight = gc.stringExtent("String").y + getItemPadding(); // initial item height=font height + item spacing
+ // use real font height here when available in SWT, instead of GC.textExtent
+ gc.dispose();
+ }
+ return itemHeight;
+}
+/**
+ * Answer the number of pixels that should be added to the item height.
+ */
+int getItemPadding() {
+ return 2 + getDisplay().textHighlightThickness;
+}
+/**
+ * Answer the item that most recently received the input focus.
+ */
+SelectableItem getLastFocus() {
+ return lastFocusItem;
+}
+/**
+ * Answer the item that was selected most recently.
+ */
+SelectableItem getLastSelection() {
+ return lastSelectedItem;
+}
+/**
+ * Answer the event listener used for all events. Events are
+ * dispatched to handler methods in handleEvents(Event).
+ * This scheme saves a lot of inner classes.
+ */
+Listener getListener() {
+ return listener;
+}
+/**
+ * Answer the y coordinate at which 'item' is drawn.
+ * @param item - SelectableItem for which the paint position
+ * should be returned
+ * @return the y coordinate at which 'item' is drawn.
+ * Return -1 if 'item' is not an item of the receiver
+ */
+int getRedrawY(SelectableItem item) {
+ int redrawIndex = getVisibleIndex(item);
+ int redrawY = -1;
+
+ if (redrawIndex != -1) {
+ redrawY = (redrawIndex - getTopIndex()) * getItemHeight();
+ }
+ return redrawY;
+}
+/**
+ * Answer the number of selected items in the receiver.
+ */
+public int getSelectionCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getSelectionVector().size();
+}
+/**
+ * Answer the selected items of the receiver.
+ * @return The selected items of the receiver stored in a Vector.
+ * Returned Vector is empty if no items are selected.
+ */
+Vector getSelectionVector() {
+ return selectedItems;
+}
+/**
+ * Answer the width of 'text' in pixel.
+ * Answer 0 if 'text' is null.
+ */
+int getTextWidth(String text) {
+ int textWidth = 0;
+ GC gc;
+
+ if (text != null) {
+ gc = new GC(this);
+ textWidth = gc.stringExtent(text).x;
+ gc.dispose();
+ }
+ return textWidth;
+}
+/**
+ * Answer the index of the first visible item in the receiver's
+ * client area.
+ * @return 0-based index of the first visible item in the
+ * receiver's client area.
+ */
+int getTopIndex() {
+ return topIndex;
+}
+/**
+ * Answer the image for the deselected check box.
+ */
+Image getUncheckedImage() {
+ InputStream resourceStream;
+
+ if (uncheckedImage == null) {
+ uncheckedImage = new Image(getDisplay(), UncheckedImageData);
+ }
+ return uncheckedImage;
+}
+
+/**
+ * Answer the image for the grayed eck box.
+ */
+Image getGrayUncheckedImage() {
+ InputStream resourceStream;
+
+ if (grayUncheckedImage == null) {
+ grayUncheckedImage = new Image(getDisplay(), GrayUncheckedImageData);
+ }
+ return grayUncheckedImage;
+}
+
+/**
+ * Answer the index of 'item' in the receiver.
+ * Answer -1 if the item is not visible.
+ * The returned index must refer to a visible item.
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. It only means that the item
+ * would be displayed if it is located inside the receiver's
+ * client area.
+ * Normally, every item of the receiver is visible.
+ */
+abstract int getVisibleIndex(SelectableItem item);
+/**
+ * Answer the SelectableItem located at 'itemIndex' in the
+ * receiver.
+ * @param itemIndex - location of the SelectableItem object
+ * to return
+ */
+abstract SelectableItem getVisibleItem(int itemIndex);
+/**
+ * Answer the number of visible items of the receiver.
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. It only means that the item
+ * would be displayed if it is located inside the receiver's
+ * client area.
+ * Normally every item of the receiver is visible.
+ */
+int getVisibleItemCount() {
+ return getItemCount();
+}
+/**
+ * Answer the y coordinate at which 'item' is drawn.
+ * @param item - SelectableItem for which the paint position
+ * should be returned
+ * @return the y coordinate at which 'item' is drawn.
+ * Return -1 if 'item' is null or outside the client area
+ */
+abstract int getVisibleRedrawY(SelectableItem item);
+/**
+ * Handle the events the receiver is listening to.
+ */
+void handleEvents(Event event) {
+ switch (event.type) {
+ case SWT.Dispose:
+ doDispose();
+ break;
+ case SWT.KeyDown:
+ keyDown(event);
+ break;
+ case SWT.Resize:
+ resize(event);
+ break;
+ case SWT.Selection:
+ if (event.widget == getVerticalBar()) {
+ scrollVertical(event);
+ }
+ else
+ if (event.widget == getHorizontalBar()) {
+ scrollHorizontal(event);
+ }
+ break;
+ case SWT.FocusOut:
+ focusOut(event);
+ break;
+ case SWT.FocusIn:
+ focusIn(event);
+ break;
+ }
+}
+
+
+
+/**
+ * Answer whether 'item' has the input focus.
+ */
+boolean hasFocus(SelectableItem item) {
+ return (isFocusControl() && item == getLastFocus());
+}
+/**
+ * Initialize the receiver. Add event listeners and set widget
+ * colors.
+ */
+void initialize() {
+ Display display = getDisplay();
+ ScrollBar horizontalBar = getHorizontalBar();
+ ScrollBar verticalBar = getVerticalBar();
+
+ // listener may be needed by overridden installListeners()
+ listener = new Listener() {
+ public void handleEvent(Event event) {handleEvents(event);}
+ };
+ setSelectionVector(new Vector());
+ installListeners();
+ calculateVerticalScrollbar();
+ calculateHorizontalScrollbar();
+ horizontalBar.setMinimum(0);
+ verticalBar.setMinimum(0);
+ horizontalBar.setIncrement(HORIZONTAL_SCROLL_INCREMENT);
+ setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
+ setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+}
+/**
+ * Initialize the ImageData used for the checked/unchecked images.
+ */
+static void initializeImageData() {
+ PaletteData uncheckedPalette = new PaletteData(
+ new RGB[] {new RGB(128, 128, 128), new RGB(255, 255, 255)});
+ PaletteData grayUncheckedPalette = new PaletteData(
+ new RGB[] {new RGB(128, 128, 128), new RGB(192, 192, 192)});
+ PaletteData checkMarkPalette = new PaletteData(
+ new RGB[] {new RGB(0, 0, 0), new RGB(252, 3, 251)});
+ byte[] checkbox = new byte[] {0, 0, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 0, 0};
+
+ // Each pixel is represented by one bit in the byte data.
+ // The bit references the palette position (0 or 1). Each pixel row of an image is padded to one byte.
+ // Arguments: width, height, depth, palette, scanline padding, data
+ UncheckedImageData = new ImageData(11, 11, 1, uncheckedPalette, 2, checkbox);
+ GrayUncheckedImageData = new ImageData(11, 11, 1, grayUncheckedPalette, 2, checkbox);
+ CheckMarkImageData = new ImageData(7, 7, 1, checkMarkPalette, 1, new byte[] {-4, -8, 112, 34, 6, -114, -34});
+ CheckMarkImageData.transparentPixel = 1;
+}
+/**
+ * Add event listeners to the tree widget and its scroll bars.
+ */
+void installListeners() {
+ Listener listener = getListener();
+
+ addListener(SWT.Dispose, listener);
+ addListener(SWT.Resize, listener);
+ addListener(SWT.KeyDown, listener);
+ addListener(SWT.FocusOut, listener);
+ addListener(SWT.FocusIn, listener);
+
+ getVerticalBar().addListener(SWT.Selection, listener);
+ getHorizontalBar().addListener(SWT.Selection, listener);
+}
+/**
+ * Answer whether the currently selected items were selected
+ * using the ctrl key.
+ */
+boolean isCtrlSelection() {
+ return isCtrlSelection;
+}
+/**
+ * Answer true if all items in the widget are disposed.
+ * Used to optimize item disposal. Prevents unnecessary screen
+ * updates.
+ */
+boolean isRemovingAll() {
+ return isRemovingAll;
+}
+/**
+ * Answer whether the receiver has the input focus.
+ * Workaround for 1FMITIE
+ */
+public boolean isFocusControl() {
+ return hasFocus;
+}
+/**
+ * Return whether the drop insert position is before or after the
+ * item set using motif_setInsertMark.
+ * @return
+ * true=insert position is after the insert item
+ * false=insert position is before the insert item
+ */
+boolean isInsertAfter() {
+ return isInsertAfter;
+}
+/**
+ * Answer whether the receiver has the MULTI selection style set.
+ * @return
+ * true = receiver is in multiple selection mode.
+ * false = receiver is in single selection mode.
+ */
+boolean isMultiSelect() {
+ return ((getStyle() & SWT.MULTI) != 0);
+}
+/**
+ * The item identified by 'changedItem' has changed.
+ * Calculate the item height based on the new item data (it might
+ * now have an image which could also be the first image in the
+ * receiver)
+ * Redraw the whole window if the item height has changed. Otherwise
+ * redraw only the changed item or part of it depending on the
+ * 'repaintStartX' and 'repaintWidth' parameters.
+ * @param changedItem - the item that has changed
+ * @param repaintStartX - x position of the item redraw.
+ * @param repaintWidth - width of the item redraw.
+ */
+void itemChanged(SelectableItem changedItem, int repaintStartX, int repaintWidth) {
+ int yPosition;
+ int itemHeight;
+ int oldItemHeight = getItemHeight();
+ Point oldImageExtent = getImageExtent();
+
+ calculateItemHeight(changedItem); // make sure that the item height is recalculated
+ // no redraw necessary if redraw width is 0 or item is not visible
+ if (repaintWidth == 0 || (yPosition = getVisibleRedrawY(changedItem)) == -1) {
+ return;
+ } // if changedItem is the first item with image.
+ itemHeight = getItemHeight();
+ if ((oldItemHeight == itemHeight) && // only redraw changed item if the item height and
+ (oldImageExtent == getImageExtent())) { // image size has not changed. The latter will only change once,
+ // from null to a value-so it's safe to test using !=
+ // redrawing outside the client area redraws the widget border on Motif.
+ // adjust the redraw width if necessary. Workaround for 1G4TQRW
+ repaintWidth = Math.min(repaintWidth, getClientArea().width - repaintStartX);
+ if (repaintWidth > 0) {
+ redraw(repaintStartX, yPosition, repaintWidth, itemHeight, true);
+ }
+ }
+ else {
+ redraw(); // redraw all items if the item height has changed
+ }
+}
+/**
+ * A key was pressed. Call the appropriate handler method.
+ * @param event - the key event
+ */
+void keyDown(Event event) {
+ boolean isCtrlSelection = isCtrlSelection();
+
+ if (event.stateMask != SWT.CTRL) {
+ isCtrlSelection = false;
+ }
+ switch (event.keyCode) {
+ case SWT.ARROW_UP:
+ doArrowUp(event.stateMask);
+ break;
+ case SWT.ARROW_DOWN:
+ doArrowDown(event.stateMask);
+ break;
+ case SWT.ARROW_LEFT:
+ doArrowLeft(event.stateMask);
+ break;
+ case SWT.ARROW_RIGHT:
+ doArrowRight(event.stateMask);
+ break;
+ case SWT.PAGE_UP:
+ doPageUp(event.stateMask);
+ break;
+ case SWT.PAGE_DOWN:
+ doPageDown(event.stateMask);
+ break;
+ case SWT.HOME:
+ doHome(event.stateMask);
+ break;
+ case SWT.END:
+ doEnd(event.stateMask);
+ break;
+ default: // no selection occurred, keep previous
+ isCtrlSelection = isCtrlSelection(); // selection type information
+ }
+ if (event.character == ' ') {
+ doSpace(event.stateMask);
+ isCtrlSelection = (event.stateMask == SWT.CTRL);
+ }
+ setCtrlSelection(isCtrlSelection);
+}
+/**
+ * Sets the drop insert item.
+ * The drop insert item has a visual hint to show where a dragged item
+ * will be inserted when dropped on the tree.
+ * <p>
+ * @param item the insert item
+ * @param after true places the insert mark below 'item'. false places
+ * the insert mark above 'item'.
+ */
+void motif_setInsertMark(SelectableItem item, boolean after) {
+ SelectableItem currentItem = getInsertItem();
+ int redrawY;
+
+ setInsertItem(item);
+ setInsertAfter(after);
+ if (currentItem != null) {
+ redrawY = getVisibleRedrawY(currentItem);
+ if (redrawY != -1) {
+ currentItem.redrawInsertMark(redrawY);
+ }
+ }
+ if (item != null) {
+ redrawY = getVisibleRedrawY(item);
+ if (redrawY != -1) {
+ item.redrawInsertMark(redrawY);
+ }
+ }
+}
+
+
+/**
+ * Overridden to implement setRedraw(). Redraw is ignored if setRedraw was
+ * set to false.
+ */
+public void redraw () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (drawCount == 0) {
+ super.redraw();
+ }
+}
+/**
+ * Overridden to implement setRedraw(). Redraw is ignored if setRedraw was
+ * set to false.
+ */
+public void redraw (int x, int y, int width, int height, boolean all) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (drawCount == 0) {
+ super.redraw(x, y, width, height, all);
+ }
+}
+
+/**
+ * Redraw the selection of 'item'
+ * @param item - SelectableItem that should have the selection redrawn.
+ */
+void redrawSelection(SelectableItem item) {
+ int redrawPosition = getVisibleRedrawY(item);
+
+ if (redrawPosition != -1) {
+ item.redrawSelection(redrawPosition);
+ }
+}
+/**
+ * 'item' has been removed from the receiver.
+ * Update the display and the scroll bars.
+ */
+void removedItem(SelectableItem item) {
+ claimBottomFreeSpace();
+ calculateVerticalScrollbar();
+ if (getItemCount() == 0) {
+ reset();
+ }
+}
+/**
+ * 'item' is about to be removed from the tree.
+ * Move the selection/input focus if 'item' is selected or has the
+ * input focus,
+ * @param item - item that is about to be removed from the tree.
+ */
+void removingItem(SelectableItem item) {
+ SelectableItem nextFocusItem = null;
+ int itemIndex = getVisibleIndex(item);
+ int itemCount = getVisibleItemCount();
+
+ // deselect item and remove from selection
+ if (item.isSelected() == true) {
+ getSelectionVector().removeElement(item);
+ }
+ if (item == getLastFocus() && itemCount > 1) {
+ // select previous item if removed item is bottom item
+ // otherwise select next item. Fixes 1GA6L85
+ if (itemIndex == itemCount - 1) {
+ nextFocusItem = getVisibleItem(itemIndex - 1);
+ }
+ else {
+ nextFocusItem = getVisibleItem(itemIndex + 1);
+ }
+ setLastFocus(nextFocusItem, true);
+ }
+ // ignore items below widget client area
+ if (itemIndex != -1 && itemIndex <= getBottomIndex()) {
+ scrollVerticalRemovedItem(itemIndex);
+ }
+}
+/**
+ * Reset state that is dependent on or calculated from the state
+ * of the receiver.
+ */
+void reset() {
+ setSelectionVector(new Vector());
+ setTopIndexNoScroll(0, true);
+ lastSelectedItem = null;
+ lastFocusItem = null;
+ resetItemData();
+}
+/**
+ * Reset state that is dependent on or calculated from the items
+ * of the receiver.
+ */
+void resetItemData() {
+ setHorizontalOffset(0);
+ setItemHeight(0);
+ itemImageExtent = null;
+ textHeight = -1;
+ claimRightFreeSpace();
+}
+/**
+ * The receiver has been resized. Update the scroll bars and
+ * make sure that new space is being occupied by items.
+ */
+void resize(Event event) {
+ int horizontalPageSize = getHorizontalBar().getPageIncrement();
+
+ resizeHorizontalScrollbar();
+ resizeVerticalScrollbar();
+ if (getClientArea().width > horizontalPageSize) { // window resized wider? - Do this check here
+ claimRightFreeSpace(); // because claimRightFreeSpace is called elsewhere.
+ }
+ claimBottomFreeSpace();
+}
+/**
+ * Display the horizontal scroll bar if items are drawn off
+ * screen. Update the page size.
+ */
+void resizeHorizontalScrollbar() {
+ ScrollBar horizontalBar = getHorizontalBar();
+ int clientAreaWidth = getClientArea().width;
+
+ if (clientAreaWidth < getContentWidth()) {
+ if (horizontalBar.getVisible() == false) {
+ horizontalBar.setVisible(true);
+ horizontalBar.setSelection(0);
+ }
+ }
+ else
+ if (horizontalBar.getVisible() == true) {
+ horizontalBar.setVisible(false);
+ }
+ horizontalBar.setThumb(clientAreaWidth);
+ horizontalBar.setPageIncrement(clientAreaWidth);
+}
+/**
+ * Display the vertical scroll bar if items are drawn off screen.
+ * Update the page size.
+ */
+void resizeVerticalScrollbar() {
+ int clientAreaItemCount = getItemCountWhole();
+ ScrollBar verticalBar = getVerticalBar();
+
+ if (clientAreaItemCount == 0) {
+ return;
+ }
+ if (clientAreaItemCount < getVisibleItemCount()) {
+ if (verticalBar.getVisible() == false) {
+ verticalBar.setVisible(true);
+ }
+ // Only set the page size to something smaller than the scroll
+ // range maximum. Otherwise the scroll selection will be reset.
+ verticalBar.setPageIncrement(clientAreaItemCount);
+ verticalBar.setThumb(clientAreaItemCount);
+ }
+ else
+ if (verticalBar.getVisible() == true) {
+ verticalBar.setVisible(false);
+ }
+}
+/**
+ * Scroll the rectangle specified by x, y, width, height to the destination
+ * position. Do nothing if redraw is set to false using setRedraw().
+ *
+ * @param destX - destination x position of the scrolled rectangle
+ * @param destY - destination y position of the scrolled rectangle
+ * @param x - x location of the upper left corner of the scroll rectangle
+ * @param y - y location of the upper left corner of the scroll rectangle
+ * @param width - width of the scroll rectangle
+ * @param height - height of the scroll rectangle
+ * @param all - not used. Used to be true=scroll children intersecting the
+ * scroll rectangle.
+ */
+void scroll(int destX, int destY, int x, int y, int width, int height, boolean all) {
+ if (drawCount == 0) {
+ update();
+ GC gc = new GC(this);
+ gc.copyArea(x, y, width, height, destX, destY);
+ gc.dispose();
+ }
+}
+/**
+ * Scroll horizontally by 'numPixel' pixel.
+ * @param numPixel - the number of pixel to scroll
+ * numPixel > 0 = scroll to left. numPixel < 0 = scroll to right
+ */
+abstract void scrollHorizontal(int numPixel);
+/**
+ * The position of the horizontal scroll bar has been modified
+ * by the user.
+ * Adjust the horizontal offset to trigger a horizontal scroll.
+ * @param event-the scroll event
+ */
+void scrollHorizontal(Event event) {
+ setHorizontalOffset(getHorizontalBar().getSelection() * -1);
+}
+/**
+ * Scroll 'item' into the receiver's client area if necessary.
+ * @param item - the item that should be scrolled.
+ */
+void scrollShowItem(SelectableItem item) {
+ int itemIndexFromTop = getIndex(item) - getTopIndex();
+ int clientAreaWholeItemCount = getItemCountWhole();
+ int scrollAmount = 0;
+
+ if (itemIndexFromTop >= clientAreaWholeItemCount) { // show item below visible items?
+ scrollAmount = itemIndexFromTop;
+ if (clientAreaWholeItemCount > 0) { // will be 0 if showItem is called and receiver hasn't been displayed yet
+ scrollAmount -= clientAreaWholeItemCount - 1;
+ }
+ }
+ else
+ if (itemIndexFromTop < 0) { // show item above visible items?
+ scrollAmount = itemIndexFromTop;
+ }
+ setTopIndex(getTopIndex() + scrollAmount, true);
+}
+/**
+ * Scroll vertically by 'scrollIndexCount' items.
+ * @param scrollIndexCount - the number of items to scroll.
+ * scrollIndexCount > 0 = scroll up. scrollIndexCount < 0 = scroll down
+ */
+abstract void scrollVertical(int scrollIndexCount);
+/**
+ * The position of the horizontal scroll bar has been modified
+ * by the user.
+ * Adjust the index of the top item to trigger a vertical scroll.
+ * @param event-the scroll event
+ */
+void scrollVertical(Event event) {
+ setTopIndex(getVerticalBar().getSelection(), false);
+}
+/**
+ * Scroll items down to make space for a new item added to
+ * the receiver at position 'index'.
+ * @param index - position at which space for one new item
+ * should be made. This index is relative to the first item
+ * of the receiver.
+ */
+void scrollVerticalAddingItem(int index) {
+ Rectangle clientArea = getClientArea();
+ int itemHeight = getItemHeight();
+ int sourceY = Math.max(0, (index - getTopIndex()) * itemHeight); // need to scroll in visible area
+
+ scroll(
+ 0, sourceY + itemHeight, // destination x, y
+ 0, sourceY, // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Scroll the items below the item at position 'index' up
+ * so that they cover the removed item.
+ * @param index - index of the removed item
+ */
+void scrollVerticalRemovedItem(int index) {
+ Rectangle clientArea = getClientArea();
+ int itemHeight = getItemHeight();
+ int destinationY = Math.max(0, (index - getTopIndex()) * itemHeight);
+
+ scroll(
+ 0, destinationY, // destination x, y
+ 0, destinationY + itemHeight, // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Select 'item' if it is not selected.
+ * @param item - item that should be selected
+ */
+void select(SelectableItem item) {
+ Vector selectedItems = getSelectionVector();
+
+ if (item != null && item.isSelected() == false && isRemovingAll() == false) {
+ item.setSelected(true);
+ redrawSelection(item);
+ selectedItems.addElement(item);
+ }
+}
+/**
+ * Select 'item' if it is not selected. Send a Selection event
+ * if the selection was changed.
+ * @param item - item that should be selected
+ */
+void selectNotify(SelectableItem item) {
+ Event event;
+
+ 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);
+ }
+}
+/**
+ * Select all items of the receiver starting at 'fromIndex'
+ * and including 'toIndex'.
+ */
+void selectRange(int fromIndex, int toIndex) {
+ if (fromIndex > toIndex) {
+ for (int i = fromIndex; i > toIndex; i--) {
+ select(getVisibleItem(i));
+ }
+ }
+ else {
+ for (int i = fromIndex; i < toIndex; i++) {
+ select(getVisibleItem(i));
+ }
+ }
+ selectNotify(getVisibleItem(toIndex)); // select last item, notifying listeners
+}
+/**
+ * Set the width of the receiver's contents to 'newWidth'.
+ * Content width is used to calculate the horizontal scrollbar.
+ */
+void setContentWidth(int newWidth) {
+ ScrollBar horizontalBar;
+ boolean scrollBarVisible;
+
+ if (contentWidth != newWidth) {
+ horizontalBar = getHorizontalBar();
+ scrollBarVisible = horizontalBar.getVisible();
+ contentWidth = newWidth;
+ calculateHorizontalScrollbar();
+ if (scrollBarVisible != horizontalBar.getVisible()) {
+ resizeVerticalScrollbar(); // the vertical scroll bar needs to be resized if the horizontal
+ } // scroll bar was hidden or made visible during recalculation
+ }
+}
+/**
+ * Set whether the currently selected items were selected using the
+ * ctrl key.
+ * @param isCtrlSelection -
+ * true = currently selected items were selected using the ctrl key.
+ * false = currently selected items were not selected using the
+ * ctrl key.
+ */
+void setCtrlSelection(boolean isCtrlSelection) {
+ this.isCtrlSelection = isCtrlSelection;
+}
+/**
+ * The font is changing. Reset the text height to force a
+ * recalculation during itemChanged().
+ */
+public void setFont(Font font) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ super.setFont(font);
+ textHeight = -1;
+}
+/**
+ * Set the horizontal drawing offset to 'offset'.
+ * Scroll the receiver's contents according to the offset change.
+ * @param offset - value < 0 = widget contents is drawn left of the client area.
+ */
+void setHorizontalOffset(int offset) {
+ int offsetChange = offset - horizontalOffset;
+
+ if (offsetChange != 0) {
+ scrollHorizontal(offsetChange);
+ horizontalOffset = offset;
+ }
+}
+
+/**
+ * Set whether the drop insert position is before or after the
+ * item set using motif_setInsertMark.
+ * @param after true=insert position is after the insert item
+ * false=insert position is before the insert item
+ */
+void setInsertAfter(boolean after) {
+ isInsertAfter = after;
+}
+
+/**
+ * Set the item that draws the marker indicating the insert location
+ * in a drag and drop operation.
+ * @param item the item that draws the insert marker
+ */
+void setInsertItem(SelectableItem item) {
+ insertItem = item;
+}
+/**
+ * Set the height of the receiver's items to 'height'.
+ */
+void setItemHeight(int height) {
+ itemHeight = height;
+}
+/**
+ * Set the item that most recently received the input focus
+ * to 'focusItem'. Redraw both, the item that lost focus
+ * and the one that received focus.
+ * @param focusItem - the item that most recently received
+ * the input focus
+ * @param showItem true=new focus item, if any, should be scrolled
+ * into view. false=don't scroll
+ */
+void setLastFocus(SelectableItem focusItem, boolean showItem) {
+ SelectableItem oldFocusItem = lastFocusItem;
+
+ if (focusItem != lastFocusItem) {
+ lastFocusItem = focusItem;
+ if (oldFocusItem != null) {
+ redrawSelection(oldFocusItem);
+ }
+ if (lastFocusItem != null && isFocusControl() == true) {
+ redrawSelection(lastFocusItem);
+ }
+ }
+ if (focusItem != null && showItem == true) {
+ showSelectableItem(focusItem);
+ }
+}
+/**
+ * Set the item that was selected most recently to 'selectedItem'.
+ * Set the input focus to that item.
+ * @param selectedItem - the item that was selected most recently
+ * @param showItem true=new focus item, if any, should be scrolled
+ * into view. false=don't scroll
+ */
+void setLastSelection(SelectableItem selectedItem, boolean showItem) {
+ if (selectedItem == null) { // always store the item selected last
+ return;
+ }
+ setLastFocus(selectedItem, showItem);
+ lastSelectedItem = selectedItem;
+}
+/**
+ * Sets the redraw flag.
+ * @param redraw -
+ * true = redraw and scroll operations are performed normally
+ * false = redraw and scroll operations are ignored
+ */
+public void setRedraw (boolean redraw) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (redraw) {
+ if (--drawCount == 0) redraw();
+ } else {
+ drawCount++;
+ }
+}
+/**
+ * Set whether all items in the widget are disposed.
+ * Used to optimize item disposal. Prevents unnecessary screen
+ * updates.
+ * @param removingAll
+ * true=all items are removed.
+ * false=normal state, no items or not all items are removed.
+ */
+void setRemovingAll(boolean removingAll) {
+ isRemovingAll = removingAll;
+}
+/**
+ * Select the items stored in 'selectionItems'.
+ * A SWT.Selection event is not going to be sent.
+ * @param selectionItems - Array containing the items that should
+ * be selected
+ */
+void setSelectableSelection(SelectableItem selectionItems[]) {
+ SelectableItem item = null;
+ int selectionCount = selectionItems.length;
+ Vector keepSelected;
+
+ if (isMultiSelect() == false && selectionCount > 1) {
+ selectionCount = 1;
+ }
+ keepSelected = new Vector(selectionItems.length);
+ for (int i = 0; i < selectionCount; i++) {
+ if (selectionItems[i] != null) {
+ keepSelected.addElement(selectionItems[i]);
+ }
+ }
+ deselectAllExcept(keepSelected);
+ // select in the same order as all the other selection and deslection methods.
+ // Otherwise setLastSelection repeatedly changes the lastSelectedItem for repeated
+ // selections of the items, causing flash.
+ for (int i = selectionCount - 1; i >= 0; i--) {
+ item = selectionItems[i];
+ if (item != null) {
+ select(item);
+ }
+ }
+ if (item != null) {
+ setLastSelection(item, true);
+ }
+}
+/**
+ * Set the vector used to store the selected items of the receiver
+ * to 'newVector'.
+ * @param newVector - the vector used to store the selected items
+ * of the receiver
+ */
+void setSelectionVector(Vector newVector) {
+ selectedItems = newVector;
+}
+/**
+ * Scroll the item at 'index' to the top.
+ * @param index - 0-based index of the first visible item in the
+ * receiver's client area.
+ * @param adjustScrollbar - true=set the position of the vertical
+ * scroll bar to the new top index.
+ * false=don't adjust the vertical scroll bar
+ */
+void setTopIndex(int index, boolean adjustScrollbar) {
+ int indexDiff = index-topIndex;
+
+ if (indexDiff != 0) {
+ scrollVertical(indexDiff);
+ setTopIndexNoScroll(index, adjustScrollbar);
+ }
+}
+/**
+ * Set the index of the first visible item in the receiver's client
+ * area to 'index'.
+ * @param index - 0-based index of the first visible item in the
+ * receiver's client area.
+ * @param adjustScrollbar - true=set the position of the vertical
+ * scroll bar to the new top index.
+ * false=don't adjust the vertical scroll bar
+ */
+void setTopIndexNoScroll(int index, boolean adjustScrollbar) {
+ topIndex = index;
+ if (adjustScrollbar == true) {
+ getVerticalBar().setSelection(index);
+ }
+}
+/**
+ * The shift key was pressed when the mouse click on an item
+ * occurred. Do a shift selection. If an already selected item was
+ * clicked the selection is expanded/reduced to that item
+ * @param hitItem - specifies the clicked item
+ * @param hitItemIndex - specifies the index of the clicked item
+ * relative to the first item.
+ */
+void shiftSelect(SelectableItem hitItem, int hitItemIndex) {
+ int fromIndex = -1;
+ int toIndex = -1;
+ int lastSelectionIndex = -1;
+ int selectionRange[];
+ SelectableItem lastSelection = getLastSelection();
+
+ if (lastSelection != null) {
+ lastSelectionIndex = getVisibleIndex(lastSelection);
+ }
+ if (isCtrlSelection() == true) { // was last selection ctrl selection?
+ deselectAllExcept(lastSelection);
+ fromIndex = lastSelectionIndex; // select from last selection
+ toIndex = hitItemIndex;
+ }
+ else
+ if (getSelectionVector().contains(hitItem) == true) { // clicked an item already selected?
+ deselectRange(hitItemIndex, lastSelectionIndex); // reduce selection
+ }
+ else { // clicked outside existing selection range
+ selectionRange = calculateShiftSelectionRange(hitItemIndex);
+ fromIndex = selectionRange[0];
+ toIndex = selectionRange[1];
+ }
+ if (hitItemIndex == lastSelectionIndex) { // was click on last selected item?
+ return;
+ }
+ if (fromIndex == -1 || toIndex == -1) { // are there previously selected items?
+ toggleSelectionNotify(hitItem); // do a single select.
+ }
+ else {
+ if (((lastSelectionIndex < fromIndex) && (hitItemIndex > fromIndex)) || // does selection reverse direction?
+ ((lastSelectionIndex > fromIndex) && (hitItemIndex < fromIndex))) {
+ deselectAllExcept((SelectableItem) null); // remove old selection
+ }
+ selectRange(fromIndex, toIndex);
+ }
+}
+/**
+ * Make 'item' visible by scrolling it into the receiver's client
+ * area if necessary.
+ * @param item - the item that should be made visible to the user.
+ */
+void showSelectableItem(SelectableItem item) {
+ if (item.getSelectableParent() != this) {
+ return;
+ }
+ scrollShowItem(item);
+ scrollShowItem(item); // second call makes sure that the item is still visible
+ // even if the first scroll caused the horizontal scroll
+ // to be displayed and the item to be hidden again.
+}
+/**
+ * Show the selection. If there is no selection or the
+ * selection is already visible, this method does nothing.
+ * If the selection is not visible, the top index of the
+ * widget is changed such that the selection becomes visible.
+ */
+public void showSelection() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector selection = getSelectionVector();
+ SelectableItem selectionItem;
+
+ if (selection.size() > 0) {
+ selectionItem = (SelectableItem) selection.firstElement();
+ showSelectableItem(selectionItem);
+ }
+}
+/**
+ * Sorts the specified range in the array.
+ *
+ * @param array the SelectableItem array to be sorted
+ * @param start the start index to sort
+ * @param end the last + 1 index to sort
+ */
+void sort(SelectableItem[] array, int start, int end) {
+ int middle = (start + end) / 2;
+ if (start + 1 < middle) sort(array, start, middle);
+ if (middle + 1 < end) sort(array, middle, end);
+ if (start + 1 >= end) return; // this case can only happen when this method is called by the user
+ if (getVisibleIndex(array[middle-1]) <= getVisibleIndex(array[middle])) return;
+ if (start + 2 == end) {
+ SelectableItem temp = array[start];
+ array[start] = array[middle];
+ array[middle] = temp;
+ return;
+ }
+ int i1 = start, i2 = middle, i3 = 0;
+ SelectableItem[] merge = new SelectableItem[end - start];
+ while (i1 < middle && i2 < end) {
+ merge[i3++] = getVisibleIndex(array[i1]) <= getVisibleIndex(array[i2]) ?
+ array[i1++] : array[i2++];
+ }
+ if (i1 < middle) System.arraycopy(array, i1, merge, i3, middle - i1);
+ System.arraycopy(merge, 0, array, start, i2 - start);
+}
+/**
+ * Toggle the selection of 'item'.
+ * @param item - item that should be selected/deselected
+ */
+void toggleSelectionNotify(SelectableItem item) {
+ if (item.isSelected() == true) {
+ deselectNotify(item);
+ }
+ else {
+ selectNotify(item);
+ }
+}
+} \ 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
new file mode 100755
index 0000000000..46decb71bd
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java
@@ -0,0 +1,541 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public class Shell extends Decorations {
+ int shellHandle;
+ Display display;
+ int modal, blockedList;
+
+public Shell () {
+ this ((Display) null);
+}
+
+public Shell (int style) {
+ this ((Display) null, style);
+}
+
+public Shell (Display display) {
+ this (display, SWT.CLOSE | SWT.TITLE | SWT.MIN | SWT.MAX | SWT.RESIZE);
+}
+
+public Shell (Display display, int style) {
+ this (display, null, style, 0);
+}
+
+Shell (Display display, Shell parent, int style, int handle) {
+ super ();
+ if (display == null) display = Display.getCurrent ();
+ if (display == null) display = Display.getDefault ();
+ if (!display.isValidThread ()) {
+ error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ }
+ this.style = checkStyle (style);
+ this.parent = parent;
+ this.display = display;
+ this.handle = handle;
+ createWidget (0);
+}
+
+public Shell (Shell parent) {
+ this (parent, SWT.TITLE | SWT.CLOSE | SWT.BORDER);
+}
+
+public Shell (Shell parent, int style) {
+ this (parent != null ? parent.getDisplay () : null, parent, style, 0);
+}
+
+public static Shell photon_new (Display display, int handle) {
+ return new Shell (display, null, SWT.NO_TRIM, handle);
+}
+
+public void addShellListener (ShellListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Close,typedListener);
+ addListener (SWT.Iconify,typedListener);
+ addListener (SWT.Deiconify,typedListener);
+ addListener (SWT.Activate, typedListener);
+ addListener (SWT.Deactivate, typedListener);
+}
+
+void bringToTop () {
+ OS.PtWidgetToFront (shellHandle);
+}
+
+void closeWidget () {
+ Event event = new Event ();
+ event.time = (int) System.currentTimeMillis ();
+ sendEvent (SWT.Close, event);
+ if (event.doit && !isDisposed ()) dispose ();
+}
+
+public void close () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ closeWidget ();
+}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_WINDOW_RENDER_FLAGS, 0, 0};
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ int flags = args [1];
+ int [] left = new int [1], top = new int [1];
+ int [] right = new int [1], bottom = new int [1];
+ OS.PtFrameSize (flags, 0, left, top, right, bottom);
+ int trimX = x - left [0];
+ int trimY = y - top [0];
+ 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];
+ }
+ return new Rectangle (trimX, trimY, trimWidth, trimHeight);
+}
+
+void createHandle (int index) {
+ 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);
+ if (shellHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ } else {
+ int parentHandle = 0;
+ if (parent != null) parentHandle = parent.topHandle ();
+ PhRect_t rect = new PhRect_t ();
+ OS.PhWindowQueryVisible (OS.Ph_QUERY_GRAPHICS, 0, 1, rect);
+ int width = (short) ((rect.lr_x - rect.ul_x + 1) * 5 / 8);
+ int height = (short) ((rect.lr_y - rect.ul_y + 1) * 5 / 8);
+ int decorations = 0;
+ int flags =
+ OS.Ph_WM_RENDER_MIN | OS.Ph_WM_RENDER_MAX | OS.Ph_WM_RENDER_RESIZE |
+ OS.Ph_WM_RENDER_BORDER | OS.Ph_WM_RENDER_MENU | OS.Ph_WM_RENDER_MIN |
+ OS.Ph_WM_RENDER_TITLE;
+ if ((style & SWT.NO_TRIM) == 0) {
+ if ((style & SWT.MIN) != 0) decorations |= OS.Ph_WM_RENDER_MIN;
+ if ((style & SWT.MAX) != 0) decorations |= OS.Ph_WM_RENDER_MAX;
+ if ((style & SWT.RESIZE) != 0) {
+ decorations |= OS.Ph_WM_RENDER_BORDER | OS.Ph_WM_RENDER_RESIZE;
+ }
+ if ((style & SWT.BORDER) != 0) decorations |= OS.Ph_WM_RENDER_BORDER;
+ if ((style & SWT.MENU) != 0) decorations |= OS.Ph_WM_RENDER_MENU;
+ if ((style & SWT.TITLE) != 0) decorations |= OS.Ph_WM_RENDER_TITLE;
+ }
+ int titlePtr = OS.malloc (1);
+ int [] args = {
+ OS.Pt_ARG_WIDTH, width, 0,
+ OS.Pt_ARG_HEIGHT, height, 0,
+ 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_FLAGS, OS.Pt_DELAY_REALIZE, OS.Pt_DELAY_REALIZE,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ OS.PtSetParentWidget (parentHandle);
+ shellHandle = OS.PtCreateWidget (OS.PtWindow (), parentHandle, args.length / 3, args);
+ OS.free (titlePtr);
+ if (shellHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ }
+ createScrolledHandle (shellHandle);
+ 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]);
+}
+
+void deregister () {
+ super.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);
+ return display;
+}
+
+public int getImeInputMode () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return 0;
+}
+
+public boolean isEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getEnabled ();
+}
+
+public Point getLocation () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE - shell location is 0,0 when queried before event loop
+ return super.getLocation ();
+}
+
+public boolean getMaximized () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //ONLY WORKS WHEN SET in setMaximized
+ int [] args = {OS.Pt_ARG_WINDOW_STATE, 0, OS.Ph_WM_STATE_ISMAX};
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ return (args [1] & OS.Ph_WM_STATE_ISMAX) != 0;
+}
+
+public boolean getMinimized () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //ONLY WORKS WHEN SET in setMinimized
+ int [] args = {OS.Pt_ARG_WINDOW_STATE, 0, OS.Ph_WM_STATE_ISHIDDEN};
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ return (args [1] & OS.Ph_WM_STATE_ISHIDDEN) != 0;
+}
+
+public Shell getShell () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return this;
+}
+
+public Shell [] getShells () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int count = 0;
+ Shell [] shells = display.getShells ();
+ for (int i=0; i<shells.length; i++) {
+ Control shell = shells [i];
+ do {
+ shell = shell.parent;
+ } while (shell != null && shell != this);
+ if (shell == this) count++;
+ }
+ int index = 0;
+ Shell [] result = new Shell [count];
+ for (int i=0; i<shells.length; i++) {
+ Control shell = shells [i];
+ do {
+ shell = shell.parent;
+ } while (shell != null && shell != this);
+ if (shell == this) {
+ result [index++] = shells [i];
+ }
+ }
+ return result;
+}
+
+public Point getSize () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {
+ OS.Pt_ARG_WINDOW_RENDER_FLAGS, 0, 0,
+ OS.Pt_ARG_WIDTH, 0, 0,
+ OS.Pt_ARG_HEIGHT, 0, 0,
+ };
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ int flags = args [1];
+ int [] left = new int [1], top = new int [1];
+ int [] right = new int [1], bottom = new int [1];
+ OS.PtFrameSize (flags, 0, left, top, right, bottom);
+ int width = args [4] + left [0] + right [0];
+ int height = args [7] + top [0] + bottom [0];
+ return new Point (width, height);
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ if (blockedList != 0) OS.PtUnblockWindows (blockedList);
+ blockedList = shellHandle = 0;
+}
+
+void realizeWidget() {
+ /* Do nothing */
+}
+
+public void removeShellListener (ShellListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Close, listener);
+ eventTable.unhook (SWT.Iconify,listener);
+ eventTable.unhook (SWT.Deiconify,listener);
+ eventTable.unhook (SWT.Activate, listener);
+ eventTable.unhook (SWT.Deactivate, listener);
+}
+
+void setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (OS.PtWidgetClass (shellHandle) != OS.PtWindow ()) {
+ super.setBounds (x, y, width, height, move, resize);
+ if (resize) resizeBounds (width, height);
+ return;
+ }
+ int [] args = {OS.Pt_ARG_WINDOW_RENDER_FLAGS, 0, 0};
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ int flags = args [1];
+ int [] left = new int [1], top = new int [1];
+ int [] right = new int [1], bottom = new int [1];
+ OS.PtFrameSize (flags, 0, left, top, right, bottom);
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (shellHandle, area);
+ int frameWidth = area.size_w + left [0] + right [0];
+ int frameHeight = area.size_h + top [0] + bottom [0];
+ if (!move) {
+ x = area.pos_x;
+ y = area.pos_y;
+ }
+ if (!resize) {
+ width = frameWidth;
+ height = frameHeight;
+ }
+ boolean sameOrigin = x == area.pos_x && y == area.pos_y;
+ boolean sameExtent = width == frameWidth && height == frameHeight;
+ area.pos_x = (short) x;
+ area.pos_y = (short) y;
+ area.size_w = (short) (Math.max (width - left [0] - right [0], 0));
+ area.size_h = (short) (Math.max (height - top [0] - bottom [0], 0));
+//TO DO - for some reason shell will move but won't resize after realize
+ 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 (shellHandle, args.length / 3, args);
+ OS.free (ptr);
+ /*
+ * Feature in Photon. The shell does not issue WM_SIZE
+ * event notificatoin until it is realized. The fix is
+ * to detect size changes and send the events.
+ */
+ if (!OS.PtWidgetIsRealized (shellHandle)) {
+ if (!sameOrigin & move) sendEvent (SWT.Move);
+ if (!sameExtent & resize) {
+ resizeBounds (width, height);
+ sendEvent (SWT.Resize);
+ }
+ }
+}
+
+public void setImage (Image image) {
+}
+
+public void setImeInputMode (int mode) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+
+public void setMaximized (boolean maximized) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (OS.PtWidgetIsRealized (shellHandle)) {
+ // RESTORE DOESN'T WORK
+ PhWindowEvent_t event = new PhWindowEvent_t ();
+ event.event_f = maximized ? OS.Ph_WM_MAX : OS.Ph_WM_RESTORE;
+ event.event_state = (short) (maximized ? OS.Ph_WM_EVSTATE_HIDE : OS.Ph_WM_EVSTATE_UNHIDE);
+ event.rid = OS.PtWidgetRid (shellHandle);
+ OS.PtForwardWindowEvent (event);
+ } else {
+ int bits = 0;
+ if (maximized) bits = OS.Ph_WM_STATE_ISMAX;
+ int [] args = {OS.Pt_ARG_WINDOW_STATE, bits, OS.Ph_WM_STATE_ISMAX};
+ OS.PtSetResources (shellHandle, args.length / 3, args);
+ }
+}
+
+public void setMenuBar (Menu menu) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (menuBar == menu) return;
+ if (menu != null) {
+ if ((menu.style & SWT.BAR) == 0) error (SWT.ERROR_MENU_NOT_BAR);
+ if (menu.parent != this) error (SWT.ERROR_INVALID_PARENT);
+ }
+ if (menuBar != null) {
+ int menuHandle = menuBar.handle;
+ int [] args = {
+ OS.Pt_ARG_FLAGS, OS.Pt_DELAY_REALIZE, OS.Pt_DELAY_REALIZE,
+ };
+ OS.PtSetResources (menuHandle, args.length / 3, args);
+ OS.PtUnrealizeWidget (menuBar.handle);
+ }
+ menuBar = 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 [] {
+ OS.Pt_ARG_WIDTH, width, 0,
+ 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;
+ }
+ 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();
+}
+
+public void setMinimized (boolean minimized) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (OS.PtWidgetIsRealized (shellHandle)) {
+ // RESTORE DOESN'T WORK
+ PhWindowEvent_t event = new PhWindowEvent_t ();
+ event.event_f = minimized ? OS.Ph_WM_HIDE : OS.Ph_WM_RESTORE;
+ event.event_state = (short) (minimized ? OS.Ph_WM_EVSTATE_HIDE : OS.Ph_WM_EVSTATE_UNHIDE);
+ event.rid = OS.PtWidgetRid (shellHandle);
+ OS.PtForwardWindowEvent (event);
+ } else {
+ int bits = 0;
+ if (minimized) bits = OS.Ph_WM_STATE_ISHIDDEN;
+ int [] args = {OS.Pt_ARG_WINDOW_STATE, bits, OS.Ph_WM_STATE_ISHIDDEN};
+ OS.PtSetResources (shellHandle, args.length / 3, args);
+ }
+}
+
+public void setModal (int modal) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ switch (modal) {
+ case SWT.MODELESS:
+ case SWT.PRIMARY_MODAL:
+ case SWT.APPLICATION_MODAL:
+ case SWT.SYSTEM_MODAL:
+ this.modal = modal;
+ break;
+ }
+}
+
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ text = string;
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int [] args = {OS.Pt_ARG_WINDOW_TITLE, ptr, 0};
+ OS.PtSetResources (shellHandle, args.length / 3, args);
+ OS.free (ptr);
+}
+
+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;
+ switch (modal) {
+ case SWT.PRIMARY_MODAL:
+ //NOT DONE: should not disable all windows
+ case SWT.APPLICATION_MODAL:
+ case SWT.SYSTEM_MODAL:
+ if (visible) {
+ blockedList = OS.PtBlockAllWindows (shellHandle, (short) 0, 0);
+ } else {
+ if (blockedList != 0) OS.PtUnblockWindows (blockedList);
+ blockedList = 0;
+ }
+ }
+ super.setVisible (visible);
+ OS.PtSyncWidget (shellHandle);
+ OS.PtFlush ();
+}
+
+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
new file mode 100755
index 0000000000..b21f1b5831
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java
@@ -0,0 +1,236 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public class Slider extends Control {
+
+public Slider (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+
+public void addSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ //NOT DONE - hard coding value to be the same as list's scrollbars
+ int width = 17, height = 100;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ width = 100; height = 17;
+ }
+ if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ 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;
+ }
+ return new Point (width, height);
+}
+
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int clazz = display.PtScrollbar;
+ int parentHandle = parent.handle;
+ int [] args = {
+ 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_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+public int getIncrement () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getMinimum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getMaximum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getPageIncrement () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_SCROLL_POSITION, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public Point getSize () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return new Point (args [1], args [4]);
+}
+
+public int getThumb () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_SLIDER_SIZE, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+void hookEvents () {
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_SCROLL_MOVE, windowProc, SWT.Selection);
+}
+int processPaint (int damage) {
+ OS.PtSuperClassDraw (OS.PtScrollbar (), handle, damage);
+ return super.processPaint (damage);
+}
+
+int processSelection (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;
+ PtScrollbarCallback_t cb = new PtScrollbarCallback_t ();
+ OS.memmove (cb, cbinfo.cbdata, PtScrollbarCallback_t.sizeof);
+ Event event = new Event ();
+ switch (cb.action) {
+ case OS.Pt_SCROLL_DRAGGED:
+ event.detail = SWT.DRAG;
+ break;
+ case OS.Pt_SCROLL_TO_MIN:
+ event.detail = SWT.HOME;
+ break;
+ case OS.Pt_SCROLL_TO_MAX:
+ event.detail = SWT.END;
+ break;
+ case OS.Pt_SCROLL_INCREMENT:
+ event.detail = SWT.ARROW_DOWN;
+ break;
+ case OS.Pt_SCROLL_DECREMENT :
+ event.detail = SWT.ARROW_UP;
+ break;
+ case OS.Pt_SCROLL_PAGE_DECREMENT:
+ event.detail = SWT.PAGE_UP;
+ break;
+ case OS.Pt_SCROLL_PAGE_INCREMENT:
+ event.detail = SWT.PAGE_DOWN;
+ break;
+ }
+ sendEvent(SWT.Selection, event);
+ return OS.Pt_CONTINUE;
+}
+
+public void removeSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+public void setIncrement (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_INCREMENT, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setMaximum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MAXIMUM, value - 1, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setMinimum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MINIMUM, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setPageIncrement (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PAGE_INCREMENT, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setSelection (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_SCROLL_POSITION, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setThumb (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_SLIDER_SIZE, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (selection < 0) return;
+ if (minimum < 0) return;
+ if (maximum < 0) return;
+ if (thumb < 1) return;
+ if (maximum - minimum - thumb < 0) return;
+ if (increment < 1) return;
+ if (pageIncrement < 1) return;
+ int [] args = {
+ OS.Pt_ARG_SCROLL_POSITION, selection, 0,
+ OS.Pt_ARG_INCREMENT, increment, 0,
+ OS.Pt_ARG_PAGE_INCREMENT, pageIncrement, 0,
+ OS.Pt_ARG_SLIDER_SIZE, thumb, 0,
+ OS.Pt_ARG_MINIMUM, minimum, 0,
+ OS.Pt_ARG_MAXIMUM, maximum - 1, 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/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java
new file mode 100755
index 0000000000..d69f35ad78
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java
@@ -0,0 +1,360 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+
+public /*final*/ class TabFolder extends Composite {
+ TabItem [] items;
+
+public TabFolder (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+ /*
+ * Even though it is legal to create this widget
+ * with scroll bars, they serve no useful purpose
+ * because they do not automatically scroll the
+ * widget's client area. The fix is to clear
+ * the SWT style.
+ */
+ return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
+}
+
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Selection,typedListener);
+ addListener(SWT.DefaultSelection,typedListener);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ PhDim_t dim = new PhDim_t();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
+ OS.PtWidgetPreferredSize(handle, dim);
+ int width = dim.w, height = dim.h;
+ Point size;
+ if (layout != null) {
+ size = layout.computeSize (this, wHint, hHint, changed);
+ } else {
+ size = minimumSize ();
+ }
+ if (size.x == 0) size.x = DEFAULT_WIDTH;
+ if (size.y == 0) size.y = DEFAULT_HEIGHT;
+ if (wHint != SWT.DEFAULT) size.x = wHint;
+ if (hHint != SWT.DEFAULT) size.y = hHint;
+ width = Math.max (width, size.x);
+ height = Math.max (height, size.y);
+ Rectangle trim = computeTrim (0, 0, width, height);
+ width = trim.width; height = trim.height;
+ return new Point (width, height);
+}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ PhDim_t dim = new PhDim_t();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
+ OS.PtWidgetPreferredSize(handle, dim);
+ int [] args = {
+ OS.Pt_ARG_MARGIN_BOTTOM, 0, 0, // 1
+ OS.Pt_ARG_MARGIN_TOP, 0, 0, // 4
+ OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 7
+ OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 10
+// OS.Pt_ARG_BASIC_FLAGS, 0, 0, // 13
+ };
+ OS.PtGetResources(handle, args.length / 3, args);
+ int trimX = x - args [10];
+ int trimY = y - (dim.h - args [1]);
+ int trimWidth = width + args [7] + args [10];
+ int trimHeight = height + dim.h;
+ return new Rectangle (trimX, trimY, trimWidth, trimHeight);
+}
+
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int clazz = display.PtPanelGroup;
+ int parentHandle = parent.handle;
+ int [] args = {
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+void createWidget (int index) {
+ super.createWidget (index);
+ items = new TabItem [4];
+}
+
+void createItem (TabItem item, int index) {
+ int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [2];
+ if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
+ if (count == items.length) {
+ TabItem [] newItems = new TabItem [items.length + 4];
+ System.arraycopy (items, 0, newItems, 0, items.length);
+ items = newItems;
+ }
+ int oldPtr = args [1];
+ int newPtr = OS.malloc ((count + 1) * 4);
+ if (newPtr == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ int offset = 0;
+ for (int i=0; i<count; i++) {
+ if (i == index) offset = 1;
+ int [] address = new int [1];
+ OS.memmove (address, oldPtr + (i * 4), 4);
+ int length = OS.strlen (address [0]);
+ int str = OS.malloc (length + 1);
+ if (str == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ OS.memmove (str, address [0], length + 1);
+ OS.memmove (newPtr + ((i + offset) * 4), new int [] {str}, 4);
+ }
+ int str = OS.malloc (1);
+ if (str == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ OS.memmove (newPtr + ((index) * 4), new int [] {str}, 4);
+ args = new int [] {OS.Pt_ARG_PG_PANEL_TITLES, newPtr, count + 1};
+ OS.PtSetResources (handle, args.length / 3, args);
+ for (int i=0; i<count+1; i++) {
+ int [] address = new int [1];
+ OS.memmove (address, newPtr + (i * 4), 4);
+ OS.free (address [0]);
+ }
+ OS.free (newPtr);
+ System.arraycopy (items, index, items, index + 1, count - index);
+ items [index] = item;
+}
+
+void destroyItem (TabItem item) {
+ int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [2];
+ int index = 0;
+ while (index < count) {
+ if (items [index] == item) break;
+ index++;
+ }
+ int oldPtr = args [1];
+ int newPtr = OS.malloc ((count - 1) * 4);
+ if (newPtr == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ int offset = 0;
+ for (int i=0; i<count; i++) {
+ if (i == index) {
+ offset = -1;
+ continue;
+ }
+ int [] address = new int [1];
+ OS.memmove (address, oldPtr + (i * 4), 4);
+ int length = OS.strlen (address [0]);
+ int str = OS.malloc (length + 1);
+ if (str == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ OS.memmove (str, address [0], length + 1);
+ OS.memmove (newPtr + ((i + offset) * 4), new int [] {str}, 4);
+ }
+ args = new int [] {OS.Pt_ARG_PG_PANEL_TITLES, newPtr, count - 1};
+ OS.PtSetResources (handle, args.length / 3, args);
+ for (int i=0; i<count-1; i++) {
+ int [] address = new int [1];
+ OS.memmove (address, newPtr + (i * 4), 4);
+ OS.free (address [0]);
+ }
+ OS.free (newPtr);
+ if (index != count) {
+ System.arraycopy (items, index + 1, items, index, --count - index);
+ }
+ items [count] = null;
+}
+
+public TabItem getItem (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 <= index && index < args [2])) error (SWT.ERROR_INVALID_RANGE);
+ return items [index];
+}
+
+public TabItem [] getItems () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ TabItem [] result = new TabItem [args [2]];
+ System.arraycopy (items, 0, result, 0, result.length);
+ return result;
+}
+
+public int getItemCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [2];
+}
+
+public TabItem [] getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int index = getSelectionIndex ();
+ if (index == -1) return new TabItem [0];
+ return new TabItem [] {items [index]};
+}
+
+public int getSelectionIndex () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PG_CURRENT_INDEX, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1] == OS.Pt_PG_INVALID ? -1 : args [1];
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_PG_PANEL_SWITCHING, windowProc, SWT.Selection);
+}
+
+public int indexOf (TabItem item) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int count = getItemCount ();
+ for (int i=0; i<count; i++) {
+ if (items [i] == item) return i;
+ }
+ return -1;
+}
+
+int processPaint (int damage) {
+ OS.PtSuperClassDraw (OS.PtPanelGroup (), handle, damage);
+ sendPaintEvent (damage);
+ return OS.Pt_CONTINUE;
+}
+
+int processResize (int info) {
+ int result = super.processResize (info);
+ int [] args = {OS.Pt_ARG_PG_CURRENT_INDEX, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int index = args [1];
+ if (index != OS.Pt_PG_INVALID) {
+ TabItem item = items [index];
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getClientArea ());
+ }
+ }
+ return result;
+}
+
+int processSelection (int info) {
+ if (info == 0) return OS.Pt_CONTINUE;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ short[] oldIndex = new short[1];
+ short[] newIndex = new short[1];
+ OS.memmove(oldIndex, cbinfo.cbdata + 8, 2);
+ OS.memmove(newIndex, cbinfo.cbdata + 10, 2);
+ int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [2];
+ Control oldControl = null;
+ int index = oldIndex [0];
+ TabItem oldItem = items [index];
+ if (0 <= index && index < count) oldControl = oldItem.control;
+ Control newControl = null;
+ index = newIndex [0];
+ TabItem newItem = items [index];
+ if (0 <= index && index < count) newControl = newItem.control;
+ if (oldControl != null) oldControl.setVisible (false);
+ if (newControl != null) {
+ newControl.setBounds (getClientArea ());
+ newControl.setVisible (true);
+ }
+ Event event = new Event ();
+ event.item = newItem;
+ postEvent (SWT.Selection, event);
+ return OS.Pt_CONTINUE;
+}
+
+void releaseWidget () {
+ int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [2];
+ for (int i=0; i<count; i++) {
+ TabItem item = items [i];
+ if (!item.isDisposed ()) item.releaseWidget ();
+ }
+ items = null;
+ super.releaseWidget ();
+}
+
+public void removeSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+public void setSelection (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PG_CURRENT_INDEX, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int oldIndex = args [1];
+ if (oldIndex != OS.Pt_PG_INVALID) {
+ TabItem item = items [oldIndex];
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ control.setVisible (false);
+ }
+ }
+ args = new int[]{OS.Pt_ARG_PG_CURRENT_INDEX, index, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+ args = new int[]{OS.Pt_ARG_PG_CURRENT_INDEX, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int newIndex = args [1];
+ if (newIndex != -1) {
+ TabItem item = items [newIndex];
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getClientArea ());
+ control.setVisible (true);
+ }
+ }
+}
+
+public void setSelection (TabItem [] items) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (items.length == 0) {
+ setSelection (-1);
+ return;
+ }
+ for (int i=items.length-1; i>=0; --i) {
+ int index = indexOf (items [i]);
+ if (index != -1) setSelection (index);
+ }
+}
+
+} \ 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
new file mode 100755
index 0000000000..e41dde1451
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabItem.java
@@ -0,0 +1,135 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public /*final*/ class TabItem extends Item {
+ TabFolder parent;
+ Control control;
+ String toolTipText;
+
+public TabItem (TabFolder parent, int style) {
+ this(parent, style, parent.getItemCount ());
+}
+
+public TabItem (TabFolder parent, int style, int index) {
+ super (parent, style);
+ this.parent = parent;
+ parent.createItem (this, index);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+public Control getControl () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return control;
+}
+
+public Display getDisplay () {
+ TabFolder parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
+public TabFolder getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
+
+public String getToolTipText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return toolTipText;
+}
+
+public boolean isDisposed () {
+ //NOT DONE - should have a handle or state flag
+ return parent == null;
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ parent.destroyItem (this);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ control = null;
+ parent = null;
+}
+
+public void setControl (Control control) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (control != null && control.parent != parent) {
+ error (SWT.ERROR_INVALID_PARENT);
+ }
+ Control oldControl = this.control, newControl = control;
+ this.control = control;
+ int index = parent.indexOf (this);
+ if (index != parent.getSelectionIndex ()) return;
+ if (newControl != null) {
+ newControl.setBounds (parent.getClientArea ());
+ newControl.setVisible (true);
+ }
+ if (oldControl != null) oldControl.setVisible (false);
+}
+
+public void setImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT SUPPORTED
+}
+
+public void setText (String text) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ super.setText (text);
+ int index = parent.indexOf (this);
+ int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
+ OS.PtGetResources (parent.handle, args.length / 3, args);
+ int count = args [2];
+ int oldPtr = args [1];
+ int newPtr = OS.malloc (count * 4);
+ for (int i=0; i<count; i++) {
+ int str;
+ if (i == index) {
+ byte [] buffer = Converter.wcsToMbcs (null, text);
+ str = OS.malloc (buffer.length + 1);
+ OS.memmove (str, buffer, buffer.length);
+ } else {
+ int [] address = new int [1];
+ OS.memmove (address, oldPtr + (i * 4), 4);
+ int length = OS.strlen (address [0]);
+ str = OS.malloc (length + 1);
+ OS.memmove (str, address [0], length + 1);
+ }
+ OS.memmove (newPtr + (i * 4), new int [] {str}, 4);
+ }
+ args = new int [] {OS.Pt_ARG_PG_PANEL_TITLES, newPtr, count};
+ OS.PtSetResources (parent.handle, args.length / 3, args);
+ for (int i=0; i<count; i++) {
+ int [] address = new int [1];
+ OS.memmove (address, newPtr + (i * 4), 4);
+ OS.free (address [0]);
+ }
+ OS.free (newPtr);
+}
+
+public void setToolTipText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ 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
new file mode 100755
index 0000000000..c0897e483c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Table.java
@@ -0,0 +1,2361 @@
+package org.eclipse.swt.widgets;
+
+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.
+ */
+public /*final*/ class Table extends SelectableItemWidget {
+ private static final int COLUMN_RESIZE_OFFSET = 7; // offset from the start and end of each
+ // column at which the resize cursor is displayed
+ // if the mouse is in the column header
+ static final String DOT_STRING = "..."; // used to indicate truncated item labels
+
+ private Header tableHeader;
+ private Control focusProxy; // used as a proxy to take focus in place of the table.
+ // The latter can't get focus because it has a child
+ // (the header widget). The header widget can't be used
+ // as a focus widget because it may be hidden.
+ private Vector items;
+ private Vector columns;
+ private boolean drawGridLines = false;
+ private boolean hasColumnFocus = false; // true if a column currently has focus
+ private boolean firstColumnImage = false; // true if any item in the first column has an image
+ private int columnResizeX; // last position of the cursor in a column resize operation
+ private Cursor columnResizeCursor; // cursor displayed when a column resize is in progress.
+ // Need to keep reference to the cursor in order to dispose it.
+ private boolean isColumnResizeCursor = false; // set to true if the column resize cursor is active
+ private TableColumn resizeColumn; // column that is currently being resized
+ private TableColumn fillColumn; // column used to fill up space that is not used
+ // by user defined columns
+ private TableColumn defaultColumn; // Default column that is created as soon as the table is created.
+ // Fix for 1FUSJY5
+ private int dotsWidth = -1; // width of the static String dots (see above)
+/**
+ * Create a new instance of Table.
+ * @param parent - the parent window of the new instance
+ * @param style - window style for the new instance
+ */
+public Table(Composite parent, int style) {
+ // use NO_MERGE_PAINTS to avoid flashing during column and widget resize redraw
+ super(parent, checkStyle(style| SWT.NO_MERGE_PAINTS));
+}
+/**
+ * Add 'column' to the receiver.
+ * @param column - new table column that should be added to
+ * the receiver
+ */
+void addColumn(TableColumn column) {
+ int index = column.getIndex();
+
+ getColumnVector().insertElementAt(column, index);
+ // has the column been inserted (vs. appended)?
+ if (index < getColumnCount() - 1) {
+ reindexColumns(index + 1);
+ }
+ // is there more than one user created column?
+ // There always is the data and visual of the default column
+ // so we don't need to create those for the first user column
+ if (getColumnCount() > 1) {
+ insertColumnData(column);
+ }
+ else { // first user created column
+ setContentWidth(0); // pretend it's ground zero for column resizings
+ redraw(); // redraw the table and header. The default column
+ getHeader().redraw(); // won't be drawn anymore, because there now is a user created table.
+ }
+ insertColumnVisual(column);
+}
+/**
+ * Add 'item' to the receiver.
+ * @param item - new table item that should be added to
+ * the receiver
+ * @param index - position the new item should be inserted at
+ */
+void addItem(TableItem item, int index) {
+ Vector items = getItemVector();
+
+ if (index < 0 || index > getItemCount()) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+ addingItem(item, index);
+ item.setIndex(index);
+ if (index < items.size()) {
+ for (int i = index; i < items.size(); i++) {
+ TableItem anItem = (TableItem) items.elementAt(i);
+ anItem.setIndex(anItem.getIndex() + 1);
+ }
+ items.insertElementAt(item, index);
+ }
+ else {
+ items.addElement(item);
+ }
+ addedItem(item, index);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*/
+public void addSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TypedListener typedListener;
+
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ typedListener = new TypedListener(listener);
+ addListener(SWT.Selection, typedListener);
+ addListener(SWT.DefaultSelection, typedListener);
+}
+static int checkStyle (int style) {
+ return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
+}
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+/**
+ * The width of 'column' is about to change.
+ * Adjust the position of all columns behind it.
+ */
+void columnChange(TableColumn column, Rectangle newBounds) {
+ Rectangle columnBounds = column.getBounds();
+ Rectangle clientArea = getClientArea();
+ int oldXPosition = columnBounds.x + columnBounds.width;
+ int newXPosition = newBounds.x + newBounds.width;
+ int widthChange = newBounds.width - columnBounds.width;
+ int headerHeight = getHeaderHeight();
+ int columnIndex = column.getIndex();
+
+ if (widthChange != 0) {
+ if (columnIndex != TableColumn.FILL) {
+ if (getLinesVisible() == true) {
+ oldXPosition -= getGridLineWidth(); // include vertical grid line when scrolling resized column.
+ newXPosition -= getGridLineWidth();
+ }
+ scroll( // physically move all following columns
+ newXPosition, headerHeight, // destination x, y
+ oldXPosition, headerHeight, // source x, y
+ clientArea.width, clientArea.height, true);
+ }
+ column.internalSetBounds(newBounds);
+ if (columnIndex != TableColumn.FILL) {
+ resetTableItems(columnIndex);
+ moveColumns(columnIndex + 1, widthChange); // logically move all following columns (set their bounds)
+ setContentWidth(getContentWidth() + widthChange); // set the width of the receiver's content
+ claimRightFreeSpace();
+ resizeRedraw(column, columnBounds.width, newBounds.width);
+ }
+ }
+ getHeader().widthChange(columnIndex, widthChange);
+}
+/**
+ * The mouse pointer was double clicked on the receiver.
+ * Handle the event according to the position of the mouse click
+ * and the modifier key that was pressed, if any.
+ * @param event - the mouse event
+ */
+void columnMouseDoubleClick(Event event) {
+ int itemHeight = getItemHeight();
+ int itemIndex;
+ TableItem hitItem;
+ TableColumn hitColumn = getColumnAtX(event.x);
+ Event columnDblClickEvent;
+
+ if (isFocusControl() == false) {
+ setFocus(); // focus proxy gets focus here because it's the first child of the receiver
+ }
+ if (hitColumn != null) {
+ itemIndex = (event.y - getHeaderHeight()) / itemHeight + getTopIndex();
+ hitItem = (TableItem) getVisibleItem(itemIndex);
+ if (hitItem != null &&
+ hitColumn.getIndex() == TableColumn.FIRST) {
+ if (hitItem.isSelectionHit(event.x) == true) {
+ columnDblClickEvent = new Event();
+ columnDblClickEvent.item = hitItem;
+ notifyListeners(SWT.DefaultSelection, columnDblClickEvent);
+ }
+ }
+ else {
+ deselectAll();
+ }
+ }
+}
+/**
+ * The mouse pointer was pressed down on the receiver.
+ * Handle the event according to the position of the mouse click
+ * and the modifier key that was pressed, if any.
+ * @param event - the mouse event
+ */
+void columnMouseDown(Event event) {
+ int itemHeight = getItemHeight();
+ int itemIndex;
+ TableItem hitItem;
+ TableColumn hitColumn = getColumnAtX(event.x);
+
+ if (isFocusControl() == false) {
+ setFocus(); // focus proxy gets focus here because it's the first child of the receiver
+ }
+ if (hitColumn != null) {
+ itemIndex = (event.y - getHeaderHeight()) / itemHeight + getTopIndex();
+ hitItem = (TableItem) getVisibleItem(itemIndex);
+ if (hitItem != null) {
+ if (hitItem.isSelectionHit(event.x) == true) {
+ doMouseSelect(hitItem, itemIndex, event.stateMask, event.button);
+ }
+ else
+ if (hitItem.isCheckHit(new Point(event.x, event.y)) == true) {
+ doCheckItem(hitItem);
+ }
+ }
+ else {
+ deselectAll();
+ }
+ }
+}
+/**
+ * The mouse pointer was moved over the receiver.
+ * Reset the column resize cursor if it was active.
+ * @param event - the mouse event
+ */
+void columnMouseMove(Event event) {
+ if (isColumnResizeStarted() == false) {
+ setColumnResizeCursor(false);
+ }
+}
+/**
+ * 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);
+ Point size = super.computeSize(wHint, hHint, changed);
+ Point headerSize;
+ GC gc;
+ final int WidthCalculationCount = Math.min(getItemCount(), 50); // calculate item width for the first couple of items only
+ TableItem item;
+ Image itemImage;
+ String itemText;
+ int width;
+ int newItemWidth = 0;
+
+ if (getHeaderVisible() == true) {
+ headerSize = getHeader().computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
+ size.y += headerSize.y;
+ }
+ if (getContentWidth() == 0 && WidthCalculationCount > 0) {
+ gc = new GC(this);
+ for (int i = 0; i < WidthCalculationCount; i++) {
+ item = getItem(i);
+ if (item == null) {
+ break; // no more items
+ }
+ itemImage = item.getImage();
+ itemText = item.getText();
+ width = 0;
+ if (itemImage != null) {
+ width += itemImage.getBounds().width;
+ }
+ if (itemText != null) {
+ width += gc.stringExtent(itemText).x;
+ }
+ newItemWidth = Math.max(newItemWidth, width);
+ }
+ if (newItemWidth > 0) {
+ size.x = newItemWidth;
+ }
+ gc.dispose();
+ }
+ return size;
+}
+/**
+ * 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
+ */
+public void deselect(int indices[]) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item = null;
+
+ if (indices == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ for (int i = 0; i < indices.length; i++) {
+ item = getVisibleItem(indices[i]);
+ if (item != null) {
+ deselect(item);
+ }
+ }
+ if (item != null) {
+ setLastSelection(item, false);
+ }
+}
+/**
+ * Deselect the item identified by 'index'.
+ * A SWT.Selection event will not be sent.
+ * @param index - index of the item to deselect
+ */
+public void deselect(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item = getVisibleItem(index);
+
+ if (item != null) {
+ deselect(item);
+ setLastSelection(item, false);
+ }
+}
+/**
+ * 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
+ */
+public void deselect(int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item = null;
+
+ for (int i=start; i<=end; i++) {
+ item = getVisibleItem(i);
+ if (item != null) {
+ deselect(item);
+ }
+ }
+ if (item != null) {
+ setLastSelection(item, false);
+ }
+}
+/**
+ * Deselect all items of the receiver.
+ */
+public void deselectAll() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ deselectAllExcept((SelectableItem) null);
+}
+/**
+ * Free resources.
+ */
+void doDispose() {
+ Vector items = getItemVector();
+
+ super.doDispose();
+ while (items.size() > 0) { // TableItem objects are removed from vector during dispose()
+ ((TableItem) items.lastElement()).dispose();
+ }
+ items = getColumnVector();
+ while (items.size() > 0) { // TableColumn objects are removed from vector during dispose()
+ ((TableColumn) items.lastElement()).dispose();
+ }
+ resizeColumn = null;
+ fillColumn = null;
+ defaultColumn = null;
+ if (columnResizeCursor != null) {
+ columnResizeCursor.dispose();
+ }
+}
+/**
+ * Draw a line tracking the current position of a column
+ * resize operation.
+ * @param xPosition - x coordinate to draw the line at
+ */
+void drawColumnResizeLine(int xPosition) {
+ GC gc = new GC(this);
+ int lineHeight = getClientArea().height;
+
+ redraw(getColumnResizeX(), 0, 1, lineHeight, false);
+ setColumnResizeX(xPosition);
+ gc.drawLine(xPosition, 0, xPosition, lineHeight);
+ gc.dispose();
+}
+/**
+ * Draw the grid lines for the receiver.
+ * @param event - Paint event triggering the drawing operation.
+ * @param drawColumns - The table columns for which the grid
+ * lines should be drawn.
+ */
+void drawGridLines(Event event, Enumeration drawColumns) {
+ GC gc = event.gc;
+ Color oldForeground = getForeground();
+ Rectangle columnBounds;
+ TableColumn column;
+ int lineWidth = getGridLineWidth();
+ int itemHeight = getItemHeight();
+ int headerHeight = getHeaderHeight();
+ int lineXPosition;
+ int lineYPosition = headerHeight + ((event.y-headerHeight) / itemHeight) * itemHeight;
+ int lineYStopPosition = event.y + event.height;
+
+ gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
+ // Draw the horizontal lines
+ if (itemHeight > 0) {
+ while (lineYPosition < lineYStopPosition) {
+ gc.drawLine(
+ event.x, lineYPosition + itemHeight - lineWidth,
+ event.x + event.width, lineYPosition + itemHeight - lineWidth);
+ lineYPosition += itemHeight;
+ }
+ }
+ // Draw the vertical lines at the right border of each column except the fill column
+ while (drawColumns.hasMoreElements() == true) {
+ column = (TableColumn) drawColumns.nextElement();
+ if (column.getIndex() != TableColumn.FILL) {
+ columnBounds = column.getBounds();
+ lineXPosition = columnBounds.x + columnBounds.width - lineWidth;
+ gc.drawLine(
+ lineXPosition, event.y,
+ lineXPosition, event.y + event.height);
+ }
+ }
+ gc.setForeground(oldForeground);
+}
+/**
+ * Draw a filled rectangle indicating the selection state of 'item'
+ * If 'item' is selected the rectangle will be filled with the
+ * selection background color. Otherwise the rectangle will be filled
+ * with the background color to remove selection.
+ * The selection color depends on whether the table widget has
+ * focus or not. See getSelectionBackgroundColor() for details.
+ * The rectangle is drawn in either the first column or in all columns
+ * for full row select.
+ * @param item - item for which the selection state should be drawn
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ * @param extent - extent of the selection rectangle.
+ */
+void drawSelection(TableItem item, GC gc, Point position, Point extent) {
+ if (item.isSelected() == true) {
+ gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));
+ }
+ gc.fillRectangle(position.x, position.y, extent.x, extent.y);
+ if (item.isSelected() == true) {
+ gc.setBackground(getBackground());
+ }
+}
+/**
+ * If the receiver has input focus draw a rectangle enclosing
+ * the label of 'item' to indicate the input focus.
+ * The rectangle is drawn in either the first column or in all columns
+ * for full row select.
+ * @param item - item for which the selection state should be drawn
+ * @param gc - GC to draw on.
+ */
+void drawSelectionFocus(TableItem item, GC gc) {
+ Point extent = item.getSelectionExtent();
+ Point position = new Point(
+ item.getImageStopX(TableColumn.FIRST) + getHorizontalOffset(),
+ getRedrawY(item));
+
+ gc.drawFocus(position.x, position.y, extent.x, extent.y);
+}
+
+/** Not used right now. Replace focusIn/focusOut with this method once
+ * Display.getFocusWindow returns the new focus window on FocusOut event
+ * The focus has moved in to or out of the receiver.
+ * Redraw the item selection to reflect the focus change.
+ * @param event - the focus change event
+ */
+void focusChange(Event event) {
+ TableColumn focusColumn = getColumnAtX(event.x);
+ Control focusWindow = getDisplay().getFocusControl();
+
+ if (focusWindow == getFocusWindow() &&
+ focusColumn != null &&
+ focusColumn.getIndex() == TableColumn.FIRST) {
+ hasColumnFocus = true;
+ }
+ else {
+ hasColumnFocus = false;
+ }
+ super.focusChange(event);
+ event.widget = this; // the ficus event is never sent to the table itself but only to the focus widget
+ notifyListeners(event.type, event); // make sure that listeners of the table get the focus event, too
+}
+/**
+ * The focus has moved in to or out of the receiver.
+ * @param event - the focus change event
+ */
+void focusIn(Event event) {
+ TableColumn focusColumn = getColumnAtX(event.x);
+
+ if (focusColumn != null &&
+ focusColumn.getIndex() == TableColumn.FIRST) {
+ hasColumnFocus = true;
+ }
+ super.focusIn(event);
+ event.widget = this; // the focus event is never sent to the table itself but only to the focus widget
+ notifyListeners(event.type, event); // make sure that listeners of the table get the focus event, too
+}
+/**
+ * The focus has moved in to or out of the receiver.
+ * @param event - the focus change event
+ */
+void focusOut(Event event) {
+ TableColumn focusColumn = getColumnAtX(event.x);
+
+ if (focusColumn != null &&
+ focusColumn.getIndex() == TableColumn.FIRST) {
+ hasColumnFocus = false;
+ }
+ super.focusOut(event);
+ event.widget = this; // the focus event is never sent to the table itself but only to the focus widget
+ notifyListeners(event.type, event); // make sure that listeners of the table get the focus event, too
+}
+/**
+ * Answer the TableColumn at 'index'.
+ */
+public TableColumn getColumn(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector columns = getColumnVector();
+
+ if (columns == null) error(SWT.ERROR_CANNOT_GET_ITEM);
+ if (index < 0 || index >= columns.size()) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+
+ return (TableColumn) columns.elementAt(index);
+}
+/**
+ * Return the column located at 'xPosition' in the widget.
+ * Return null if xPosition is outside the widget.
+ * @param xPosition - position of the desired column
+ */
+TableColumn getColumnAtX(int xPosition) {
+ Enumeration columns = internalGetColumnVector().elements();
+ TableColumn column;
+ TableColumn hitColumn = null;
+ Rectangle bounds;
+
+ while (columns.hasMoreElements() == true && hitColumn == null) {
+ column = (TableColumn) columns.nextElement();
+ bounds = column.getBounds();
+ if ((xPosition >= bounds.x) &&
+ (xPosition <= bounds.x + bounds.width)) {
+ hitColumn = column;
+ }
+ }
+ if (hitColumn == null) {
+ column = getFillColumn();
+ bounds = column.getBounds();
+ if ((xPosition >= bounds.x) &&
+ (xPosition <= bounds.x + bounds.width)) {
+ hitColumn = column;
+ }
+ }
+ return hitColumn;
+}
+/**
+ * Answer the number of columns in the receiver.
+ */
+public int getColumnCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector columns = getColumnVector();
+ int count = 0;
+
+ if (columns != null) {
+ count = columns.size();
+ }
+ return count;
+}
+/** Replace CURSOR_SIZEWE with real column resize cursor
+ * (no standard cursor-have to load from file)
+ * Answer the cursor displayed during a column resize
+ * operation.
+ * Lazy initialize the cursor since it may never be needed.
+ */
+Cursor getColumnResizeCursor() {
+ if (columnResizeCursor == null) {
+ columnResizeCursor = new Cursor(getDisplay(), SWT.CURSOR_SIZEWE);
+ }
+ return columnResizeCursor;
+}
+/**
+ * Answer the current position of the mouse cursor during
+ * a column resize operation.
+ */
+int getColumnResizeX() {
+ return columnResizeX;
+}
+/**
+ * Answer an Array containing all columns of receiver except
+ * the fill column to the right of all content columns.
+ */
+public TableColumn [] getColumns() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector columns = getColumnVector();
+ TableColumn columnArray[] = new TableColumn[columns.size()];
+
+ columns.copyInto(columnArray);
+ return columnArray;
+}
+/**
+ * Answer a Vector containing all columns of receiver except
+ * the fill column to the right of all content columns.
+ */
+Vector getColumnVector() {
+ return columns;
+}
+/**
+ * Return the default column that is created as soon as the table
+ * is created.
+ * Fix for 1FUSJY5
+ */
+TableColumn getDefaultColumn() {
+ return defaultColumn;
+}
+/**
+ * Answer the width of the replacement String used to indicate
+ * truncated items.
+ * Cached to speed up calculation of truncated items.
+ * @param gc - GC used to measure the width of the replacement
+ * String
+ */
+int getDotsWidth(GC gc) {
+ if (dotsWidth == -1) {
+ dotsWidth = gc.stringExtent(DOT_STRING).x;
+ }
+ return dotsWidth;
+}
+/**
+ * Answer the column used to occupy any space left to the
+ * right of all the user created columns.
+ */
+TableColumn getFillColumn() {
+ return fillColumn;
+}
+/**
+ * Answer the widget that is used to hold focus for the receiver.
+ * The receiver can not get focus itself because it has children.
+ */
+Control getFocusWindow() {
+ return focusProxy;
+}
+/**
+* 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
+*/
+public int getGridLineWidth () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return 1;
+}
+/**
+ * Answer the table header widget.
+ */
+Header getHeader() {
+ return tableHeader;
+}
+/**
+ * Answer the header height or 0 if the header is not visible.
+ */
+int getHeaderHeight() {
+ Header header = getHeader();
+ int height = 0;
+
+ if (header.getVisible() == true) {
+ height = header.getBounds().height;
+ }
+ return height;
+}
+/**
+ * Answer whether the header is visible.
+ * @return
+ * true = header is visible. false = header is not visible
+ */
+public boolean getHeaderVisible() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getHeader().getVisible();
+}
+/**
+ * Answer the image extent of 'item'. Use the image of any column.
+ */
+Point getImageExtent(SelectableItem item) {
+ Image image = null;
+ Rectangle imageBounds;
+ Point imageExtent = null;
+ int columnCount = internalGetColumnCount();
+
+ for (int i = 0; i < columnCount && image == null; i++) {
+ image = ((TableItem) item).getImage(i);
+ }
+ if (image != null) {
+ imageBounds = image.getBounds();
+ imageExtent = new Point(imageBounds.width, imageBounds.height);
+ }
+ return imageExtent;
+}
+/**
+ * Answer the index of 'item' in the receiver.
+ */
+int getIndex(SelectableItem item) {
+ int index = -1;
+
+ if (item != null && item.getSelectableParent() == this) {
+ index = ((TableItem) item).getIndex();
+ }
+ return index;
+}
+/**
+ * Answer the TableItem located at 'index' in the receiver.
+ * @param index - location of the TableItem object to return
+ */
+public TableItem getItem(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (!(0 <= index && index < getItemCount())) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+ return (TableItem) getVisibleItem(index);
+}
+
+/**
+ * Return the item at the specified position in the widget
+ * Return null if the position is outside the widget or in the header widget.
+ */
+public TableItem getItem(Point point) {
+ int headerHeight = getHeaderHeight();
+ TableColumn column = getColumnAtX(point.x);
+ TableItem item = null;
+
+ if (column != null && column.getIndex() != TableColumn.FILL && point.y - headerHeight > 0) {
+ int itemIndex = (point.y - headerHeight) / getItemHeight() + getTopIndex();
+ item = (TableItem) getVisibleItem(itemIndex);
+ if (item != null) {
+ Point itemSize = item.getItemExtent(column);
+ if (point.x - column.getBounds().x > itemSize.x) {
+ item = null;
+ }
+ }
+ }
+ return item;
+}
+/**
+ * Answer the number of items in the receiver.
+ */
+public int getItemCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getItemVector().size();
+}
+/**
+ * Answer the number of items that can be displayed in the
+ * client area of the receiver without truncating any items.
+ */
+int getItemCountWhole() {
+ int clientAreaHeight = Math.max(0, getClientArea().height - getHeaderHeight());
+
+ return clientAreaHeight / getItemHeight();
+}
+/**
+ * Answer the height of an item in the receiver.
+ * The item height is the greater of the item icon height and
+ * text height of the first item that has text or an image
+ * respectively.
+ * Calculate a default item height based on the font height if
+ * no item height has been calculated yet.
+ */
+public int getItemHeight() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getItemHeight();
+}
+/**
+ * Answer the number of pixels that should be added to the item height.
+ */
+int getItemPadding() {
+ return getGridLineWidth() + getDisplay().textHighlightThickness + 1;
+}
+/**
+ * Answer all items of the receiver as an Array.
+ */
+public TableItem [] getItems() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector items = getItemVector();
+ TableItem itemArray[] = new TableItem[items.size()];
+
+ items.copyInto(itemArray);
+ return itemArray;
+}
+/**
+ * Answer all items of the receiver.
+ */
+Vector getItemVector() {
+ return items;
+}
+/**
+ * Answer whether the receiver is drawing grid lines.
+ * @return
+ * true = receiver draws grid lines
+ * false = receiver does not draw grid lines
+ */
+public boolean getLinesVisible() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return drawGridLines;
+}
+/**
+ * Answer a Vector containing the columns that need repainting
+ * based on the 'paintArea'.
+ * @param paintArea - invalidated rectangle that needs repainting
+ */
+Vector getPaintColumns(Rectangle paintArea) {
+ Enumeration columns = internalGetColumnVector().elements();
+ Vector paintColumns = new Vector();
+ TableColumn column;
+ Rectangle columnBounds;
+ int paintAreaRightBorder = paintArea.x + paintArea.width;
+
+ while (columns.hasMoreElements() == true) {
+ column = (TableColumn) columns.nextElement();
+ columnBounds = column.getBounds();
+ if ((columnBounds.x + columnBounds.width >= paintArea.x) && // does the paintArea overlap the current column?
+ (columnBounds.x <= paintAreaRightBorder)) {
+ paintColumns.addElement(column);
+ }
+ }
+ return paintColumns;
+}
+/**
+ * Return the width of the widest item in the column identified by 'columnIndex'
+ * @param columnIndex - index of the column whose preferred width should be
+ * calculated
+ */
+int getPreferredColumnWidth(int columnIndex) {
+ Enumeration tableItems = getItemVector().elements();
+ TableItem tableItem;
+ int width = 0;
+ int headerWidth;
+
+ if (columnIndex != TableColumn.FILL) {
+ while (tableItems.hasMoreElements() == true) {
+ tableItem = (TableItem) tableItems.nextElement();
+ width = Math.max(width, tableItem.getPreferredWidth(columnIndex));
+ }
+ headerWidth = getHeader().getPreferredWidth(columnIndex);
+ if (width < headerWidth) {
+ width = headerWidth;
+ }
+ }
+ return width;
+}
+/**
+ * Answer the position in the receiver where 'item' is drawn
+ * @return the y coordinate at which 'item' is drawn.
+ * Return -1 if 'item' is not an item of the receiver
+ */
+int getRedrawY(SelectableItem item) {
+ int redrawY = super.getRedrawY(item);
+
+ if (redrawY != -1) {
+ redrawY += getHeaderHeight();
+ }
+ return redrawY;
+}
+/**
+ * Answer the column that is being resized or null if no
+ * resize operation is in progress.
+ */
+TableColumn getResizeColumn() {
+ return resizeColumn;
+}
+/**
+ * Return the positions at which the column identified by 'columnIndex'
+ * must be redrawn.
+ * These positions may be different for each item since each item may
+ * have a different label
+ * @param columnIndex - the column index
+ * @param columnWidth - width of the column
+ * @return the positions at which the column must be redrawn.
+ * Each item in the widget client area is represented by a slot in
+ * the array. The item at position 'topIndex' is the first item in
+ * the array.
+ */
+int [] getResizeRedrawX(int columnIndex, int columnWidth) {
+ int topIndex = getTopIndex();
+ int bottomIndex = getBottomIndex();
+ int resizeRedrawX[];
+ TableItem item;
+
+ bottomIndex = Math.min(bottomIndex, getItemCount());
+ resizeRedrawX = new int[bottomIndex-topIndex+1];
+ for (int i = topIndex; i < bottomIndex; i++) {
+ item = (TableItem) getVisibleItem(i);
+ resizeRedrawX[i-topIndex] = item.getDotStartX(columnIndex, columnWidth);
+ }
+ return resizeRedrawX;
+}
+/**
+ * Answer the selected items of the receiver.
+ * @return an Array of TableItems containing the selected items.
+ * An empty Array if no items are selected.
+ */
+public TableItem [] getSelection() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector selectionVector = getSelectionVector();
+ TableItem[] selectionArray = new TableItem[selectionVector.size()];
+
+ selectionVector.copyInto(selectionArray);
+ sort(selectionArray, 0, selectionArray.length);
+ return selectionArray;
+}
+
+/**
+ * Answer the number of selected items in the receiver.
+ */
+public int getSelectionCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getSelectionCount();
+}
+/**
+ * Answer the size of the full row selection rectangle for 'item'.
+ */
+Point getFullSelectionExtent(TableItem item) {
+ TableColumn lastColumn = (TableColumn) internalGetColumnVector().lastElement();
+ Point selectionExtent = null;
+ Rectangle columnBounds;
+ int xPosition = item.getImageStopX(TableColumn.FIRST);
+ int gridLineWidth = getGridLineWidth();
+
+ if (lastColumn != null) {
+ columnBounds = lastColumn.getBounds();
+ selectionExtent = new Point(
+ columnBounds.x - getHorizontalOffset() + columnBounds.width - xPosition - gridLineWidth,
+ getItemHeight());
+ if (getLinesVisible() == true) {
+ selectionExtent.y -= gridLineWidth;
+ }
+ }
+ return selectionExtent;
+}
+/**
+ * Answer the index of the first selected item of the receiver.
+ */
+public int getSelectionIndex() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int index = -1;
+
+ if (getSelectionCount() > 0) {
+ index = getIndex(getSelection()[0]);
+ }
+ return index;
+}
+/**
+ * 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.
+ */
+public int [] getSelectionIndices() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TableItem[] items = getSelection();
+ int indices[] = new int[items.length];
+
+ for (int i = 0; i < items.length; i++) {
+ indices[i] = getIndex(items[i]);
+ }
+ return indices;
+}
+/**
+ * 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.
+ */
+public int getTopIndex() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getTopIndex();
+}
+/**
+ * Answer the index of 'item' in the receiver.
+ * Answer -1 if the item is not visible.
+ * The returned index must refer to a visible item.
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. It only means that the item
+ * would be displayed if it is located inside the receiver's
+ * client area.
+ * Every item in a table widget should be visible.
+ */
+int getVisibleIndex(SelectableItem item) {
+ return getIndex(item);
+}
+/**
+ * Answer the SelectableItem located at 'itemIndex' in the receiver.
+ * @param itemIndex - location of the SelectableItem object to return
+ */
+SelectableItem getVisibleItem(int itemIndex) {
+ Vector items = getItemVector();
+ TableItem item = null;
+
+ if ((items != null) && (itemIndex >= 0) && (itemIndex < items.size())) {
+ item = (TableItem) items.elementAt(itemIndex);
+ }
+ return item;
+}
+/**
+ * Answer the y coordinate at which 'item' is drawn.
+ * @param item - SelectableItem for which the paint position
+ * should be returned
+ * @return the y coordinate at which 'item' is drawn.
+ * Return -1 if 'item' is null or outside the client area
+ */
+int getVisibleRedrawY(SelectableItem item) {
+ int redrawY = -1;
+ int index = getTopIndex();
+ int bottomIndex = getBottomIndex();
+
+ if (item == null) {
+ return redrawY;
+ }
+ while (index < bottomIndex && item.equals(getVisibleItem(index)) == false) {
+ index++;
+ }
+ if (index < bottomIndex) {
+ redrawY = getRedrawY(item);
+ }
+ return redrawY;
+}
+/**
+ * Handle the events the receiver is listening to.
+ */
+void handleEvents(Event event) {
+ switch (event.type) {
+ case SWT.MouseMove:
+ if (event.widget == tableHeader) {
+ headerMouseMove(event);
+ }
+ else {
+ columnMouseMove(event);
+ }
+ break;
+ case SWT.MouseDown:
+ if (event.widget == tableHeader) {
+ headerMouseDown(event);
+ }
+ else {
+ columnMouseDown(event);
+ }
+ break;
+ case SWT.MouseDoubleClick:
+ columnMouseDoubleClick(event);
+ break;
+ case SWT.MouseUp:
+ mouseUp(event);
+ break;
+ case SWT.Paint:
+ paint(event);
+ break;
+ default:
+ super.handleEvents(event);
+ }
+}
+/**
+ * Answer true if any item in the first column has an image.
+ * Answer false otherwise.
+ */
+boolean hasFirstColumnImage() {
+ return firstColumnImage;
+}
+/**
+ * Answer whether the receiver has the input focus.
+ */
+public boolean isFocusControl() {
+ return hasColumnFocus;
+}
+/**
+ * The mouse pointer was pressed down on the receiver's header
+ * widget. Start a column resize operation if apropriate.
+ * @param event - the mouse event that occured over the header
+ * widget
+ */
+void headerMouseDown(Event event) {
+ TableColumn column = getColumnAtX(event.x);
+
+ if (isColumnResize(event) == true) {
+ startColumnResize(event);
+ }
+ else
+ if (column != null) {
+ column.notifyListeners(SWT.Selection, new Event());
+ }
+}
+/**
+ * The mouse pointer was moved over the receiver's header widget.
+ * If a column is currently being resized a vertical line indicating
+ * the new position of the resized column is drawn.
+ * Otherwise, if no column resize operation is in progress, the
+ * column resize cursor is displayed when the mouse is near the border
+ * of a column.
+ */
+void headerMouseMove(Event event) {
+ if (isColumnResizeStarted() == false) { // only check whether cursor is in resize
+ setColumnResizeCursor(isColumnResize(event)); // area if no resize operation is in progress
+ }
+ else
+ if (event.x >= getResizeColumn().getBounds().x) {
+ drawColumnResizeLine(event.x);
+ update(); // looks better if resize line is drawn immediately
+ }
+}
+/**
+ * Answer the index of 'column' in the receiver or -1 if 'column'
+ * does not exist in the receiver.
+ */
+public int indexOf(TableColumn column) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (column == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ return internalGetColumnVector().indexOf(column);
+}
+/**
+ * Answer the index of 'item' in the receiver or -1 if 'item'
+ * does not exist in the receiver.
+ */
+public int indexOf(TableItem item) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (item == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ return getIndex(item);
+}
+/**
+ * Initialize the receiver. Create a header widget and an empty column.
+ */
+void initialize() {
+ columns = new Vector();
+ setItemVector(new Vector());
+ focusProxy = new Button(this, SWT.NULL);
+ focusProxy.setBounds(0, 0, 0, 0); // make the focus proxy invisible
+ tableHeader = new Header(this);
+ tableHeader.setVisible(false); // SWT table header is invisible by default, too
+ fillColumn = TableColumn.createFillColumn(this);
+ setColumnPosition(fillColumn);
+ defaultColumn = TableColumn.createDefaultColumn(this); // Create the default column. Fix for 1FUSJY5
+ super.initialize();
+}
+/**
+ * Insert the new column 'column' into the table data at position
+ * 'index'.
+ */
+void insertColumnData(TableColumn column) {
+ Enumeration tableItems = getItemVector().elements();
+ TableItem tableItem;
+
+ while (tableItems.hasMoreElements() == true ) {
+ tableItem = (TableItem) tableItems.nextElement();
+ tableItem.insertColumn(column);
+ }
+}
+/**
+ * Insert the new column 'column'.
+ * Set the position and move the following columns to the right.
+ */
+void insertColumnVisual(TableColumn column) {
+ Rectangle columnBounds = column.getBounds();
+ Rectangle previousColumnBounds;
+ int index = column.getIndex();
+
+ if (index > 0) {
+ previousColumnBounds = getColumn(index - 1).getBounds();
+ columnBounds.x = previousColumnBounds.x + previousColumnBounds.width;
+ }
+ else {
+ columnBounds.x = 0;
+ }
+ column.setBounds(columnBounds);
+ setColumnPosition(column);
+}
+/**
+ * Set event listeners for the receiver.
+ */
+void installListeners() {
+ Header tableHeader = getHeader();
+ Control focusWindow = getFocusWindow();
+ Listener listener = getListener();
+
+ super.installListeners();
+ tableHeader.addListener(SWT.MouseMove, listener);
+ tableHeader.addListener(SWT.MouseDown, listener);
+ tableHeader.addListener(SWT.MouseUp, listener);
+
+ // HACK: All we're really interested in is focus change and key down
+ // for the table itself. Doesn't work that way because setFocus sets
+ // focus to the first child of the receiver (which is our focus window)
+ removeListener(SWT.FocusOut, listener);
+ removeListener(SWT.FocusIn, listener);
+ focusWindow.addListener(SWT.FocusOut, listener);
+ focusWindow.addListener(SWT.FocusIn, listener);
+ focusWindow.addListener(SWT.KeyDown, listener);
+
+ addListener(SWT.MouseMove, listener);
+ addListener(SWT.MouseDown, listener);
+ addListener(SWT.MouseDoubleClick, listener);
+ addListener(SWT.MouseUp, listener);
+ addListener(SWT.Paint, listener);
+}
+/**
+ * Answer the TableColumn at 'index'.
+ * If the user has not created any columns the default column is
+ * returned if index is 0.
+ * Fix for 1FUSJY5
+ */
+TableColumn internalGetColumn(int index) {
+ Vector columns = internalGetColumnVector();
+
+ if (columns == null) error(SWT.ERROR_CANNOT_GET_ITEM);
+ if (index < 0 || index >= columns.size()) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+
+ return (TableColumn) columns.elementAt(index);
+
+}
+/**
+ * Answer the number of columns in the receiver.
+ * If the user has not created any columns, 1 is returned since there
+ * always is a default column.
+ * Fix for 1FUSJY5
+ */
+int internalGetColumnCount() {
+ Vector columns = internalGetColumnVector();
+ int count = 0;
+
+ if (columns != null) {
+ count = columns.size();
+ }
+ return count;
+}
+/**
+ * Return a Vector containing all columns of the receiver except
+ * the fill column to the right of all content columns.
+ * Return a Vector containing the default column if the user has
+ * not created any columns.
+ * Fix for 1FUSJY5
+ */
+Vector internalGetColumnVector() {
+ Vector internalColumnVector;
+ TableColumn defaultColumn;
+
+ if (columns.isEmpty() == false) {
+ internalColumnVector = columns;
+ }
+ else {
+ internalColumnVector = new Vector(1);
+ defaultColumn = getDefaultColumn();
+ if (defaultColumn != null) {
+ internalColumnVector.addElement(defaultColumn);
+ }
+ }
+ return internalColumnVector;
+}
+/**
+ * Answer whether the mouse pointer is at a position that can
+ * start a column resize operation. A column resize can be
+ * started if the mouse pointer is at either the left or right
+ * border of a column.
+ * @param event - mouse event specifying the location of the
+ * mouse pointer.
+ */
+boolean isColumnResize(Event event) {
+ TableColumn hotColumn = getColumnAtX(event.x);
+ Rectangle bounds = hotColumn.getBounds();
+ int hotColumnIndex = hotColumn.getIndex();
+ int columnX = event.x - bounds.x;
+ boolean isColumnResize = false;
+
+ if (columnX <= COLUMN_RESIZE_OFFSET && // mouse over left side of column? and
+ hotColumnIndex != TableColumn.FIRST) { // it's not the first column)
+ if (hotColumnIndex == TableColumn.FILL) {
+ hotColumn = (TableColumn) internalGetColumnVector().lastElement();
+ }
+ else {
+ hotColumn = internalGetColumn(hotColumnIndex - 1);
+ }
+ isColumnResize = hotColumn.getResizable(); // check whether left column can be resized
+ }
+ else
+ if (columnX >= bounds.width - COLUMN_RESIZE_OFFSET && // mouse over right side of column and
+ hotColumn != getFillColumn()) { // column is a real one (not the right hand fill column)?
+ isColumnResize = hotColumn.getResizable(); // check whether column under cursor can be resized
+ }
+ return isColumnResize;
+}
+/**
+ * Answer whether a column of the receiver is being resized.
+ */
+boolean isColumnResizeStarted() {
+ return (getResizeColumn() != null);
+}
+/**
+ * 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.
+ */
+public boolean isSelected(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TableItem item = getItem(index);
+
+ return (item != null && item.isSelected() == true);
+}
+/**
+ * 'changedItem' has changed. Update the default column width.
+ * @param changedItem - the item that has changed
+ */
+void itemChanged(SelectableItem changedItem, int repaintStartX, int repaintWidth) {
+ // call super.itemChanged first to make sure that table image size is
+ // calculated if necessary. Fixes 1FYPBBG.
+ super.itemChanged(changedItem, repaintStartX, repaintWidth);
+ // remember if any item ever had an image in the first column.
+ if (firstColumnImage == false && changedItem.getImage() != null) {
+ firstColumnImage = true;
+ }
+ setFirstColumnWidth((TableItem) changedItem);
+}
+/**
+ * A mouse button was released.
+ * Update the display if a column has been resized.
+ * @param event - the mouse event for the button up action
+ */
+void mouseUp(Event event) {
+ TableColumn resizeColumn = getResizeColumn();
+ Rectangle oldColumnBounds;
+ int resizeXPosition;
+ int widthChange;
+
+ if (isColumnResizeStarted() == true) {
+ oldColumnBounds = resizeColumn.getBounds();
+ resizeXPosition = getColumnResizeX();
+ widthChange = resizeXPosition - (oldColumnBounds.x + oldColumnBounds.width);
+ if (widthChange != 0) {
+ if (widthChange > 0) {
+ redraw(resizeXPosition, 0, 1, getClientArea().height, false); // remove resize line
+ update(); // to avoid cheese caused by scrolling the resize line
+ }
+ resizeColumn.setWidth(oldColumnBounds.width + widthChange);
+ }
+ setResizeColumn(null);
+ }
+}
+/**
+ * Adjust the position of all columns starting at 'startIndex'.
+ * @param startIndex - index at which the column move should begin
+ * If this is the index of the fill column all columns are moved,
+ * including the fill column
+ * @param moveDistance - distance that the columns should be moved.
+ * < 0 = columns are going to be moved left.
+ * > 0 = columns are going to be moved right.
+ */
+void moveColumns(int startIndex, int moveDistance) {
+ Vector columns = internalGetColumnVector();
+ TableColumn moveColumn;
+ Rectangle columnBounds;
+
+ if (startIndex == TableColumn.FILL) {
+ moveColumn = getFillColumn();
+ columnBounds = moveColumn.getBounds();
+ columnBounds.x += moveDistance;
+ moveColumn.setBounds(columnBounds);
+ startIndex = 0; // continue with first data column
+ }
+ for (int i = startIndex; i < columns.size(); i++) {
+ moveColumn = (TableColumn) columns.elementAt(i);
+ columnBounds = moveColumn.getBounds();
+ columnBounds.x += moveDistance;
+ moveColumn.setBounds(columnBounds);
+ }
+}
+/**
+ * Adjust the y position of all columns including the fill column.
+ */
+void moveColumnsVertical() {
+ Enumeration columns = internalGetColumnVector().elements();
+ TableColumn column;
+
+ setColumnPosition(getFillColumn());
+ while (columns.hasMoreElements() == true) {
+ column = (TableColumn) columns.nextElement();
+ setColumnPosition(column);
+ }
+}
+/**
+ * A paint event has occurred. Paint the invalidated items.
+ * @param event - paint event specifying the invalidated area.
+ */
+void paint(Event event) {
+ int visibleRange[];
+ int headerHeight = getHeaderHeight();
+ Vector paintColumns = getPaintColumns(event.getBounds());
+ TableItem focusItem = null;
+
+ if (paintColumns.size() > 0) {
+ event.y -= headerHeight;
+ visibleRange = getIndexRange(event.getBounds());
+ event.y += headerHeight;
+ // When the top index is > 0 and the receiver is resized
+ // higher so that the top index becomes 0 the invalidated
+ // rectangle doesn't start below the header widget but at
+ // y position 0. Subtraction of the header height (it is
+ // not above the receiver but on top) causes event.y and
+ // subsequently visibleRange[0] to be negative.
+ // Hack to prevent visibleRange[0] from becoming negative.
+ // Need to find out why the invalidated area starts at 0
+ // in the first place.
+ if (visibleRange[0] < 0) {
+ visibleRange[0] = 0;
+ }
+ //
+ visibleRange[1] = Math.min(visibleRange[1], getItemCount()-1-getTopIndex());
+ focusItem = paintItems(event, visibleRange[0], visibleRange[1], paintColumns);
+ }
+ if (getLinesVisible() == true) {
+ drawGridLines(event, paintColumns.elements());
+ }
+ if (focusItem != null) {
+ // draw focus on top of drawing grid lines so that focus rectangle
+ // is not obscured by grid. Fixes 1G5X20B
+ drawSelectionFocus(focusItem, event.gc);
+ }
+}
+
+/**
+ * Paint items of the receiver starting at index 'topPaintIndex' and
+ * ending at 'bottomPaintIndex'.
+ * @param event - holds the GC to draw on and the clipping rectangle
+ * @param topPaintIndex - index of the first item to draw
+ * @param bottomPaintIndex - index of the last item to draw
+ * @param paintColumns - the table columns that should be painted
+ * @return the item that has focus if it was among the rendered items.
+ * null if the focus item was not rendered or if no item has focus (ie.
+ * because the widget does not have focus)
+ */
+TableItem paintItems(Event event, int topPaintIndex, int bottomPaintIndex, Vector paintColumns) {
+ Enumeration columns;
+ TableColumn column;
+ TableItem paintItem;
+ TableItem focusItem = null;
+ Point selectionExtent;
+ Point selectionPosition;
+ int itemHeight = getItemHeight();
+
+ topPaintIndex += getTopIndex();
+ bottomPaintIndex += getTopIndex();
+ for (int i = topPaintIndex; i <= bottomPaintIndex; i++) {
+ paintItem = (TableItem) getVisibleItem(i);
+ selectionExtent = paintItem.getSelectionExtent();
+ if (selectionExtent != null) {
+ selectionPosition = new Point(paintItem.getSelectionX(), getRedrawY(paintItem));
+ drawSelection(paintItem, event.gc, selectionPosition, selectionExtent);
+ }
+ columns = paintColumns.elements();
+ while (columns.hasMoreElements() == true) {
+ column = (TableColumn) columns.nextElement();
+ paintSubItem(event, paintItem, column, i * itemHeight);
+ }
+ if (hasFocus(paintItem)) {
+ focusItem = paintItem;
+ }
+ }
+ return focusItem;
+}
+
+/**
+ * Paint the table item 'paintItem' in 'column' at y position
+ * 'paintYPosition' of the receiver.
+ * @param event - holds the GC to draw on and the clipping
+ * rectangle.
+ * @param paintItem - the item to draw
+ * @param column - column to draw 'paintItem' in
+ * @param paintYPosition - y position in the receiver to draw
+ * 'paintItem' at.
+ */
+void paintSubItem(Event event, TableItem paintItem, TableColumn column, int paintYPosition) {
+ Rectangle columnBounds = column.getBounds();
+ int gridLineWidth = getGridLineWidth();
+ int itemDrawStopX = columnBounds.x + columnBounds.width - gridLineWidth;
+ int clipX;
+
+ if (event.x + event.width > itemDrawStopX) { // does the invalidated area stretch past the current column's right border?
+ clipX = Math.max(columnBounds.x, event.x);
+ event.gc.setClipping( // clip the drawing area
+ clipX, event.y,
+ itemDrawStopX - clipX, event.height);
+ }
+ column.paint(paintItem, event.gc, paintYPosition);
+ if (event.x + event.width > itemDrawStopX) {
+ event.gc.setClipping(event.x, event.y, event.width, event.height); // restore original clip rectangle
+ }
+}
+/**
+ * Reindex all columns starting at 'startIndex'.
+ * Reindexing is necessary when a new column has been inserted.
+ */
+void reindexColumns(int startIndex) {
+ Vector columns = getColumnVector();
+ TableColumn column;
+
+ for (int i = startIndex; i < getColumnCount(); i++) {
+ column = (TableColumn) columns.elementAt(i);
+ column.setIndex(i);
+ }
+}
+/**
+ * Remove the items identified by the indices stored in
+ * 'indices' from the receiver.
+ * @param indices - indices of the items to dispose
+ */
+public void remove(int indices[]) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item;
+ int [] sortedIndices;
+ int last = -1;
+
+ if (indices == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ sortedIndices = new int[indices.length];
+ System.arraycopy (indices, 0, sortedIndices, 0, indices.length);
+ sort(sortedIndices); // sort indices in descending order
+ for (int i = 0; i < sortedIndices.length; i++) {
+ if (sortedIndices[i] != last) {
+ item = getVisibleItem(sortedIndices[i]);
+ if (item != null) {
+ item.dispose();
+ }
+ else {
+ error(SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+ last = sortedIndices[i];
+ }
+ }
+}
+/**
+ * Remove the item identified by 'index'.
+ * @param index - index of the item to dispose
+ */
+public void remove(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item = getVisibleItem(index);
+
+ if (item != null) {
+ item.dispose();
+ }
+ else {
+ error(SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+}
+/**
+ * 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
+ */
+public void remove(int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item;
+
+ for (int i = end; i >= start; i--) {
+ item = getVisibleItem(i);
+ if (item != null) {
+ item.dispose();
+ }
+ else {
+ error(SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+ }
+}
+/**
+ * Remove all items of the receiver.
+ */
+public void removeAll() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector items = getItemVector();
+
+ setRedraw(false);
+ setRemovingAll(true);
+ for (int i = 0; i < items.size(); i++) {
+ ((TableItem) items.elementAt(i)).dispose();
+ }
+ setItemVector(new Vector());
+ reset();
+ calculateVerticalScrollbar();
+ setRemovingAll(false);
+ setRedraw(true);
+}
+/**
+ * Remove 'column' from the receiver.
+ */
+void removeColumn(TableColumn column) {
+ TableColumn lastColumn;
+ int index = column.getIndex();
+ int columnWidth = column.getWidth();
+ int columnCount;
+
+ if (isRemovingAll() == true) {
+ getColumnVector().removeElementAt(index);
+ }
+ else {
+ getColumnVector().removeElementAt(index);
+ columnCount = getColumnCount();
+ // Never remove the data of the last user created column.
+ // SWT for Windows does the same.
+ if (columnCount > 0) {
+ removeColumnData(column);
+ }
+ removeColumnVisual(column);
+ if (index < columnCount) { // is there a column after the removed one?
+ reindexColumns(index);
+ }
+ // last user created column is about to be removed.
+ if (columnCount == 0) {
+ TableColumn defaultColumn = getDefaultColumn();
+ defaultColumn.pack(); // make sure the default column has the right size...
+ setColumnPosition(defaultColumn); // ...and is at the right position
+ }
+ // Fixes for 1G1L0UT
+ // Reduce the content width by the width of the removed column
+ setContentWidth(getContentWidth() - columnWidth);
+ // claim free space
+ claimRightFreeSpace();
+ //
+ }
+}
+/**
+ * Remove the column 'column' from the table data.
+ */
+void removeColumnData(TableColumn column) {
+ Enumeration tableItems = getItemVector().elements();
+ TableItem tableItem;
+
+ while (tableItems.hasMoreElements() == true ) {
+ tableItem = (TableItem) tableItems.nextElement();
+ tableItem.removeColumn(column);
+ }
+}
+/**
+ * Remove the column 'column'.
+ * Set the position of the following columns.
+ */
+void removeColumnVisual(TableColumn column) {
+ int columnWidth = column.getWidth();
+
+ // move following columns to the left
+ moveColumns(column.getIndex() + 1, columnWidth * -1);
+ redraw();
+ getHeader().redraw();
+}
+/**
+ * Remove 'item' from the receiver.
+ * @param item - item that should be removed from the receiver
+ */
+void removeItem(TableItem item) {
+ Vector items = getItemVector();
+ int index = items.indexOf(item);
+
+ if (index != -1) {
+ if (isRemovingAll() == false) {
+ removingItem(item);
+ }
+ items.removeElementAt(index);
+ for (int i = index; i < items.size(); i++) {
+ TableItem anItem = (TableItem) items.elementAt(i);
+ anItem.setIndex(anItem.getIndex() - 1);
+ }
+ if (isRemovingAll() == false) {
+ removedItem(item);
+ }
+ }
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+*/
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ removeListener(SWT.Selection, listener);
+ removeListener(SWT.DefaultSelection, listener);
+}
+/**
+ * Reset cached data of column at 'columnIndex' for the items of the receiver.
+ * @param columnIndex - index of the column for which the item data should be
+ * reset.
+ */
+void resetTableItems(int columnIndex) {
+ Enumeration tableItems = getItemVector().elements();
+ TableItem tableItem;
+
+ while (tableItems.hasMoreElements() == true ) {
+ tableItem = (TableItem) tableItems.nextElement();
+ tableItem.reset(columnIndex);
+ }
+}
+/**
+ * The receiver has been resized. Resize the fill column
+ * and the header widget.
+ */
+void resize(Event event) {
+ TableColumn fillColumn = getFillColumn();
+ Rectangle fillColumnBounds;
+
+ super.resize(event);
+ // the x position may change in super.resize.
+ // get the column bounds after calling super.resize. Fixes 1G7ALGG
+ fillColumnBounds = fillColumn.getBounds();
+ fillColumnBounds.width = Math.max(0, getClientArea().width - getContentWidth());
+ fillColumn.setBounds(fillColumnBounds);
+ resizeHeader();
+}
+/**
+ * Resize the header widget to occupy the whole width of the
+ * receiver.
+ */
+void resizeHeader() {
+ Header tableHeader = getHeader();
+ Point size = tableHeader.getSize();
+
+ size.x = Math.max(getContentWidth(), getClientArea().width);
+ tableHeader.setSize(size);
+}
+/**
+ * Redraw 'column' after its width has been changed.
+ * @param column - column whose width has changed.
+ * @param oldColumnWidth - column width before resize
+ * @param oldColumnWidth - column width after resize
+ */
+void resizeRedraw(TableColumn column, int oldColumnWidth, int newColumnWidth) {
+ Rectangle columnBounds = column.getBounds();
+ int columnIndex = column.getIndex();
+ int oldRedrawStartX[] = getResizeRedrawX(columnIndex, oldColumnWidth);
+ int newRedrawStartX[] = getResizeRedrawX(columnIndex, newColumnWidth);
+ int itemHeight = getItemHeight();
+ int widthChange = newColumnWidth - oldColumnWidth;
+ int topIndex = getTopIndex();
+
+ for (int i = 0; i < newRedrawStartX.length; i++) {
+ if (newRedrawStartX[i] != oldRedrawStartX[i]) {
+ if (widthChange > 0) {
+ newRedrawStartX[i] = oldRedrawStartX[i];
+ }
+ redraw(
+ columnBounds.x + newRedrawStartX[i], columnBounds.y + itemHeight * (i + topIndex),
+ columnBounds.width - newRedrawStartX[i], itemHeight, false);
+ }
+ }
+}
+/**
+ * Scroll horizontally by 'numPixel' pixel.
+ * @param numPixel - the number of pixel to scroll
+ * < 0 = columns are going to be moved left.
+ * > 0 = columns are going to be moved right.
+ */
+void scrollHorizontal(int numPixel) {
+ Rectangle clientArea = getClientArea();
+
+ scroll(
+ numPixel, 0, // destination x, y
+ 0, 0, // source x, y
+ clientArea.width, clientArea.height, true);
+ getHeader().scroll(
+ numPixel, 0, // destination x, y
+ 0, 0, // source x, y
+ clientArea.width, clientArea.height, true);
+ moveColumns(TableColumn.FILL, numPixel);
+}
+/**
+ * Scroll vertically by 'scrollIndexCount' items.
+ * @param scrollIndexCount - the number of items to scroll.
+ * scrollIndexCount > 0 = scroll up. scrollIndexCount < 0 = scroll down
+ */
+void scrollVertical(int scrollIndexCount) {
+ int scrollAmount = scrollIndexCount * getItemHeight();
+ int headerHeight = getHeaderHeight();
+ int destY;
+ int sourceY;
+ boolean scrollUp = scrollIndexCount < 0;
+ Rectangle clientArea = getClientArea();
+
+ if (scrollIndexCount == 0) {
+ return;
+ }
+ if (scrollUp == true) {
+ destY = headerHeight - scrollAmount;
+ sourceY = headerHeight;
+ }
+ else {
+ destY = headerHeight;
+ sourceY = destY + scrollAmount;
+ }
+ scroll(
+ 0, destY, // destination x, y
+ 0, sourceY, // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Scroll items down to make space for a new item added to
+ * the receiver at position 'index'.
+ * @param index - position at which space for one new item
+ * should be made. This index is relative to the first item
+ * of the receiver.
+ */
+void scrollVerticalAddingItem(int index) {
+ int itemHeight = getItemHeight();
+ int sourceY = getHeaderHeight();
+ Rectangle clientArea = getClientArea();
+
+ if (index >= getTopIndex()) {
+ sourceY += (index-getTopIndex()) * itemHeight;
+ }
+ scroll(
+ 0, sourceY + itemHeight, // destination x, y
+ 0, sourceY, // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Scroll the items below the item at position 'index' up
+ * so that they cover the removed item.
+ * @param index - index of the removed item
+ */
+void scrollVerticalRemovedItem(int index) {
+ int itemHeight = getItemHeight();
+ int headerHeight = getHeaderHeight();
+ int destY;
+ Rectangle clientArea = getClientArea();
+
+ destY = Math.max(headerHeight, headerHeight + (index - getTopIndex()) * itemHeight);
+ scroll(
+ 0, destY, // destination x, y
+ 0, destY + itemHeight, // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * 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
+ */
+public void select(int indices[]) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item = null;
+ int selectionCount;
+
+ if (indices == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ selectionCount = indices.length;
+ if (isMultiSelect() == false && selectionCount > 1) {
+ selectionCount = 1;
+ deselectAllExcept(getVisibleItem(indices[0]));
+ }
+ for (int i = selectionCount - 1; i >= 0; --i) {
+ item = getVisibleItem(indices[i]);
+ if (item != null) {
+ select(item);
+ }
+ }
+ if (item != null) {
+ setLastSelection(item, false);
+ }
+}
+/**
+ * Select the item identified by 'index'.
+ * A SWT.Selection event will not be sent.
+ * @param index - index of the item to select
+ */
+public void select(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item = getVisibleItem(index);
+
+ if (isMultiSelect() == false) {
+ deselectAllExcept(getVisibleItem(index));
+ }
+ if (item != null) {
+ select(item);
+ setLastSelection(item, false);
+ }
+}
+/**
+ * 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
+ */
+public void select(int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item = null;
+ int selectionCount = 1;
+
+ if (isMultiSelect() == false) {
+ if (start < 0 && end >= 0) {
+ start = 0;
+ }
+ end = start;
+ deselectAllExcept(getVisibleItem(end));
+ }
+ // select in the same order as all the other selection and deslection methods.
+ // Otherwise setLastSelection repeatedly changes the lastSelectedItem for repeated
+ // selections of the items, causing flash.
+ for (int i = end; i >= start; i--) {
+ item = getVisibleItem(i);
+ if (item != null) {
+ select(item);
+ }
+ }
+ if (item != null) {
+ setLastSelection(item, false);
+ }
+}
+/**
+ * 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.
+ */
+public void selectAll() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Enumeration items = getItemVector().elements();
+ TableItem item = null;
+
+ if (isMultiSelect() == false) {
+ return;
+ }
+ while (items.hasMoreElements() == true) {
+ item = (TableItem) items.nextElement();
+ select(item);
+ }
+ if (item != null) {
+ setLastSelection(item, false);
+ }
+}
+/**
+ * Set the y position of 'column'.
+ * @param column - the TableColumn that should be set to
+ * a new y position.
+ */
+void setColumnPosition(TableColumn column) {
+ Rectangle bounds = column.getBounds();
+
+ bounds.y = getHeaderHeight() - getTopIndex() * getItemHeight();
+ column.setBounds(bounds);
+}
+/**
+ * Change the cursor of the receiver.
+ * @param isColumnResizeCursor - indicates whether the column
+ * resize cursor or the regular cursor should be set.
+ */
+void setColumnResizeCursor(boolean isColumnResizeCursor) {
+ if (isColumnResizeCursor != this.isColumnResizeCursor) {
+ this.isColumnResizeCursor = isColumnResizeCursor;
+ if (isColumnResizeCursor == true) {
+ setCursor(getColumnResizeCursor());
+ }
+ else {
+ setCursor(null);
+ }
+ }
+}
+/**
+ * Set the current position of the resized column to 'xPosition'.
+ * @param xPosition - the current position of the resized column
+ */
+void setColumnResizeX(int xPosition) {
+ columnResizeX = xPosition;
+}
+/**
+ * Set the width of the receiver's contents to 'newWidth'.
+ * Content width is used to calculate the horizontal scrollbar.
+ */
+void setContentWidth(int newWidth) {
+ TableColumn fillColumn = getFillColumn();
+ Rectangle fillColumnBounds;
+ int widthDiff = newWidth - getContentWidth();
+
+ super.setContentWidth(newWidth);
+ if (fillColumn != null) {
+ fillColumnBounds = fillColumn.getBounds();
+ fillColumnBounds.x += widthDiff;
+ fillColumnBounds.width = Math.max(0, getClientArea().width - newWidth);
+ fillColumn.setBounds(fillColumnBounds);
+ }
+}
+/**
+ * Set the width of the first column to fit 'item' if it is longer than
+ * the current column width.
+ * Do nothing if the user has already set a width.
+ */
+void setFirstColumnWidth(TableItem item) {
+ int newWidth;
+ TableColumn column;
+
+ if (internalGetColumnCount() > 0) {
+ column = internalGetColumn(TableColumn.FIRST);
+ if (column.isDefaultWidth() == true) {
+ newWidth = Math.max(column.getWidth(), item.getPreferredWidth(TableColumn.FIRST));
+ column.setWidth(newWidth);
+ column.setDefaultWidth(true); // reset to true so that we know when the user has set
+ // the width instead of us setting a default width.
+ }
+ }
+}
+/**
+ * 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);
+ SelectableItem item;
+ int itemCount = getItemCount();
+
+ if (font == null || font.equals(getFont()) == true) {
+ return;
+ }
+ setRedraw(false); // disable redraw because itemChanged() triggers undesired redraw
+ resetItemData();
+ super.setFont(font);
+ for (int i = 0; i < itemCount; i++) {
+ itemChanged(getItem(i), 0, getClientArea().width);
+ }
+ setRedraw(true); // re-enable redraw
+ getHeader().setFont(font);
+}
+/**
+ * Set whether or not the header is visible.
+ * @param headerVisible -
+ * true = header is visible. false = header is not visible
+ */
+public void setHeaderVisible(boolean headerVisible) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (headerVisible != getHeaderVisible()) {
+ getHeader().setLocation(0, 0);
+ getHeader().setVisible(headerVisible);
+ // Windows resets scrolling so do we
+ setTopIndex(0, true);
+ moveColumnsVertical();
+ resizeVerticalScrollbar();
+ redraw();
+ }
+}
+/**
+ * Set the vector that stores the items of the receiver
+ * to 'newVector'.
+ * @param newVector - Vector to use for storing the items of
+ * the receiver.
+ */
+void setItemVector(Vector newVector) {
+ items = newVector;
+}
+/**
+ * Set whether the receiver is drawing grid lines to
+ * 'drawGridLines'.
+ * @param drawGridLines -
+ * true = receiver draws grid lines
+ * false = receiver does not draw grid lines
+ */
+public void setLinesVisible(boolean drawGridLines) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (this.drawGridLines != drawGridLines) {
+ this.drawGridLines = drawGridLines;
+ redraw();
+ }
+}
+/**
+ * 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);
+
+ super.setRedraw(redraw);
+ getHeader().setRedraw(redraw);
+}
+/**
+ * Set the column that is being resized to 'column'.
+ * @param column - the TableColumn that is being resized.
+ * A null value indicates that no column resize operation is
+ * in progress.
+ */
+void setResizeColumn(TableColumn column) {
+ resizeColumn = column;
+}
+/**
+* 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
+*/
+public void setSelection(int [] indices) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector keepSelected;
+
+ if (indices == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ keepSelected = new Vector(indices.length);
+ for (int i = 0; i < indices.length; i++) {
+ SelectableItem item = getVisibleItem(indices[i]);
+ if (item != null) {
+ keepSelected.addElement(item);
+ }
+ }
+ deselectAllExcept(keepSelected);
+ select(indices);
+}
+/**
+ * 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
+ */
+public void setSelection(TableItem selectionItems[]) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (selectionItems == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ setSelectableSelection(selectionItems);
+}
+/**
+ * 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
+ */
+public void setSelection(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ deselectAllExcept(getVisibleItem(index));
+ select(index);
+}
+/**
+ * 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
+ */
+public void setSelection(int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector keepSelected = new Vector(end - start + 1);
+
+ for (int i = start; i <= end; i++) {
+ SelectableItem item = getVisibleItem(i);
+ if (item != null) {
+ keepSelected.addElement(item);
+ }
+ }
+ deselectAllExcept(keepSelected);
+ select(start, end);
+}
+/**
+ * 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.
+ */
+public void setTopIndex(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int itemCount = getItemCount();
+ int itemCountWhole = getItemCountWhole();
+
+ if (index < 0 || itemCount == 0) {
+ return;
+ }
+ if (index >= itemCount) {
+ index = itemCount - itemCountWhole;
+ }
+ super.setTopIndex(index, true);
+}
+/**
+ * Set the index of the first visible item in the receiver's client
+ * area to 'index'.
+ * @param index - 0-based index of the first visible item in the
+ * receiver's client area.
+ * @param adjustScrollbar - true=set the position of the vertical
+ * scroll bar to the new top index.
+ * false=don't adjust the vertical scroll bar
+ */
+void setTopIndexNoScroll(int index, boolean adjustScrollbar) {
+ super.setTopIndexNoScroll(index, adjustScrollbar);
+ moveColumnsVertical();
+}
+/**
+ * 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.
+ */
+public void showItem(TableItem item) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (item == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ showSelectableItem(item);
+}
+/**
+ * Show the selection. If there is no selection or the
+ * selection is already visible, this method does nothing.
+ * If the selection is not visible, the top index of the
+ * widget is changed such that the selection becomes visible.
+ */
+public void showSelection() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ super.showSelection();
+}
+void sort (int [] items) {
+ /* Shell Sort from K&R, pg 108 */
+ int length = items.length;
+ for (int gap=length/2; gap>0; gap/=2) {
+ for (int i=gap; i<length; i++) {
+ for (int j=i-gap; j>=0; j-=gap) {
+ if (items [j] <= items [j + gap]) {
+ int swap = items [j];
+ items [j] = items [j + gap];
+ items [j + gap] = swap;
+ }
+ }
+ }
+ }
+}
+/**
+ * Start a column resize operation.
+ * @param event - the mouse event that occured over the header
+ * widget
+ */
+void startColumnResize(Event event) {
+ Vector columns = internalGetColumnVector();
+ TableColumn hitColumn = getColumnAtX(event.x);
+ Rectangle hitColumnBounds;
+ int hitIndex = hitColumn.getIndex();
+
+ if (hitColumn == getFillColumn()) { // clicked on the fill column?
+ hitColumn = (TableColumn) columns.lastElement(); // resize the last real column
+ }
+ else
+ if ((event.x - hitColumn.getBounds().x <= COLUMN_RESIZE_OFFSET) && // check if left side of a column was clicked
+ (hitIndex > 0)) {
+ hitColumn = (TableColumn) columns.elementAt(hitIndex - 1); // resize the preceding column
+ }
+ hitColumnBounds = hitColumn.getBounds();
+ setColumnResizeX(hitColumnBounds.x + hitColumnBounds.width);
+ setResizeColumn(hitColumn);
+}
+/**
+ * Return 'text' after it has been checked to be no longer than 'maxWidth'
+ * when drawn on 'gc'.
+ * If it is too long it will be truncated up to the last character.
+ * @param text - the String that should be checked for length
+ * @param maxWidth - maximum width of 'text'
+ * @param gc - GC to use for String measurement
+ */
+String trimItemText(String text, int maxWidth, GC gc) {
+ int textWidth;
+ int dotsWidth;
+
+ if (text != null && text.length() > 1) {
+ textWidth = gc.stringExtent(text).x;
+ if (textWidth >= maxWidth) {
+ dotsWidth = getDotsWidth(gc);
+ while (textWidth + dotsWidth >= maxWidth && text.length() > 1) {
+ text = text.substring(0, text.length() - 1); // chop off one character at the end
+ textWidth = gc.stringExtent(text).x;
+ }
+ text = text.concat(Table.DOT_STRING);
+ }
+ }
+ return text;
+}
+
+} \ 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
new file mode 100755
index 0000000000..55c9ba604c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableColumn.java
@@ -0,0 +1,461 @@
+package org.eclipse.swt.widgets;
+
+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.
+ */
+public /*final*/ class TableColumn extends Item {
+ static final int FIRST = 0; // index of the first column
+ static final int FILL = -1; // index that identifies the column used to
+ // fill space not used by other columns.
+ private static final int DEFAULT_WIDTH = 10;
+
+ private Table parent;
+ private int index; // 0-based column index
+ private Rectangle bounds = new Rectangle(0, 0, 0, 0);
+ private boolean isDefaultWidth = true;
+ private boolean resize = true;
+/**
+ * Create a new TableColumn without adding it to the parent.
+ * Currently used to create fill columns and default columns.
+ * @see createFillColumn
+ * @see createDefaultColumn
+ * @param parent - Table widget the new instance will be a child of.
+ */
+TableColumn(Table parent) {
+ super(parent, SWT.NULL);
+ this.parent = parent;
+}
+/**
+ * Create a new instance of TableColumn and append it to the existing
+ * columns in 'parent'.
+ * @param parent - Table widget the new instance will be a child of.
+ * @param syle - style of the new TableColumn
+ */
+public TableColumn(Table parent, int style) {
+ this(parent, style, checkNull(parent).getColumnCount());
+}
+/**
+ * Create a new instance of TableColumn at position 'index' in the Table
+ * identified by 'parent'.
+ * @param parent - Table widget the new instance will be a child of.
+ * @param index - position in the 'parent' at which the new instance will
+ * be located relative to the other columns.
+ * @param syle - style of the new TableColumn
+ */
+public TableColumn(Table parent, int style, int index) {
+ super(parent, checkStyle (style), index);
+
+ this.parent = parent;
+ if (index < 0 || index > parent.getColumnCount()) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+ setIndex(index);
+ parent.addColumn(this);
+ setWidth(DEFAULT_WIDTH);
+ setDefaultWidth(true);
+ addListener(SWT.Dispose, new Listener() {
+ public void handleEvent(Event event) {disposeColumn();}
+ });
+}
+/**
+* Adds the listener to 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
+*/
+public void addControlListener(ControlListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Resize,typedListener);
+ addListener (SWT.Move,typedListener);
+}
+/**
+* Adds the listener to 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
+*/
+public void addSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+/**
+ * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'table' is null.
+ * Otherwise return 'table'
+ */
+static Table checkNull(Table table) {
+ if (table == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return table;
+}
+static int checkStyle (int style) {
+ return checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
+}
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+/**
+ * Create a new instance of TableColumn that acts as a default column
+ * if the user does not create a TableColumn.
+ * @param parent - Table widget the new instance will be a child of.
+ */
+static TableColumn createDefaultColumn(Table parent) {
+ TableColumn defaultColumn = new TableColumn(parent);
+
+ defaultColumn.setIndex(FIRST);
+ defaultColumn.setWidth(DEFAULT_WIDTH);
+ defaultColumn.setDefaultWidth(true);
+ return defaultColumn;
+}
+/**
+ * Create a new instance of TableColumn that acts as the rightmost
+ * fill column in a Table. The new object is not added to the parent
+ * like a regular column is.
+ * @param parent - Table widget the new instance will be a child of.
+ */
+static TableColumn createFillColumn(Table parent) {
+ TableColumn fillColumn = new TableColumn(parent);
+
+ fillColumn.setIndex(FILL);
+ return fillColumn;
+}
+/**
+ * Remove the receiver from its parent
+ */
+void disposeColumn() {
+ getParent().removeColumn(this);
+}
+/**
+* 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
+*/
+public int getAlignment () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.LEFT) != 0) return SWT.LEFT;
+ if ((style & SWT.CENTER) != 0) return SWT.CENTER;
+ if ((style & SWT.RIGHT) != 0) return SWT.RIGHT;
+ return SWT.LEFT;
+}
+
+/**
+ * Answer the bounding rectangle of the receiver.
+ */
+Rectangle getBounds() {
+ return new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height); // copy the object to prevent changes
+}
+/**
+ * Gets the Display.
+ */
+public Display getDisplay() {
+ if (parent == null) { // access parent field directly to prevent endless recursion
+ error(SWT.ERROR_WIDGET_DISPOSED);
+ }
+ return parent.getDisplay();
+}
+/**
+ * Answer the index of the receiver. Specifies the position of the
+ * receiver relative to other columns in the parent.
+ */
+int getIndex() {
+ return index;
+}
+/**
+ * Answer the parent widget of the receiver.
+ */
+public Table getParent() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ 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
+*/
+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
+*/
+public int getWidth () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getBounds().width;
+}
+/**
+ * Set the colun bounds.
+ */
+void internalSetBounds(Rectangle newBounds) {
+ bounds = newBounds;
+}
+/**
+ * Answer whether the column has a default width or if a width has been
+ * set by the user.
+ * @return
+ * true=column width is a default width set internally
+ * false=column width has been set by the user.
+ */
+boolean isDefaultWidth() {
+ return isDefaultWidth;
+}
+/**
+* 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
+*/
+public void pack() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Table parent = getParent();
+ int index = parent.indexOf(this);
+
+ if (getIndex() != TableColumn.FILL && index != -1) {
+ setWidth(parent.getPreferredColumnWidth(index));
+ }
+}
+/**
+ * Draw the 'item' at 'yPosition' in the receiver column.
+ * @param item - TableItem that should be drawn.
+ * @param gc - GC to draw on
+ * @param yPosition - y position to draw at in the column.
+ */
+void paint(TableItem item, GC gc, int yPosition) {
+ Rectangle bounds = getBounds();
+ Point paintPosition = new Point(bounds.x, bounds.y + yPosition);
+
+ item.paint(gc, paintPosition, this);
+}
+/**
+* Removes the listener.
+* <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
+*/
+public void removeControlListener (ControlListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Move, listener);
+ eventTable.unhook (SWT.Resize, listener);
+}
+/**
+* Removes the listener.
+* <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
+*/
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error(SWT.ERROR_WIDGET_DISPOSED);
+
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ removeListener(SWT.Selection, listener);
+ removeListener(SWT.DefaultSelection, listener);
+}
+/**
+* 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
+*/
+public void setAlignment(int alignment) {
+ if (!isValidThread ()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error(SWT.ERROR_WIDGET_DISPOSED);
+ int index = getIndex();
+
+ if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) != 0 && index != 0) { // ignore calls for the first column to match Windows behavior
+ style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+ style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+ getParent().getHeader().redraw(index);
+ }
+}
+/**
+ * Set the bounding rectangle of the receiver to 'newBounds'.
+ * Notify the table widget if the column width changes.
+ * @param newBounds - the new bounding rectangle of the receiver,
+ * consisting of x, y, width, height
+ */
+void setBounds(Rectangle newBounds) {
+ if (newBounds.width != bounds.width) {
+ if (isDefaultWidth() == true) {
+ setDefaultWidth(false);
+ }
+ getParent().columnChange(this, newBounds);
+ }
+ else {
+ // columnChange causes update (via scroll) which may flush redraw
+ // based on old bounds. Setting bounds after notifying table fixes 1GABZR5
+ // Table sets column bounds at appropriate time when called above with
+ // width change. Only set bounds when table was not called. Fixes 1GCGDPB
+ bounds = newBounds;
+ }
+}
+/**
+ * Set whether the column has a default width or if a width has been
+ * set by the user.
+ * @param isDefaultWidth
+ * true=column width is a default width set internally
+ * false=column width has been set by the user
+ */
+void setDefaultWidth(boolean isDefaultWidth) {
+ this.isDefaultWidth = isDefaultWidth;
+}
+/**
+ * Set the index of the receiver to 'newIndex'. The index specifies the
+ * position of the receiver relative to other columns in the parent.
+ */
+void setIndex(int newIndex) {
+ this.index = newIndex;
+}
+/**
+* Sets the 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
+*/
+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);
+ int index = getIndex();
+
+ if (newText == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (index != FILL && (text == null || text.equals(newText) == false)) {
+ super.setText(newText);
+ getParent().getHeader().redraw(index);
+ }
+}
+/**
+* Sets the width.
+* <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
+*/
+public void setWidth(int width) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Table parent = getParent();
+ Rectangle bounds = getBounds();
+ int oldWidth = bounds.width;
+ int redrawX;
+
+ if (width != oldWidth) {
+ redrawX = bounds.x;
+ bounds.width = width;
+ setBounds(bounds);
+ // redraw at old column position if column was resized wider.
+ // fixes focus rectangle.
+ redrawX += Math.min(width, oldWidth);
+ parent.redraw(
+ redrawX - 2, 0,
+ 2, parent.getClientArea().height, false); // redraw 2 pixels wide to redraw item focus rectangle and grid line
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableItem.java
new file mode 100755
index 0000000000..6919d84766
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableItem.java
@@ -0,0 +1,1032 @@
+package org.eclipse.swt.widgets;
+
+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
+ * that represents an item in a table.
+ * Table items can consist of multiple columns called sub items.
+ */
+public /*final*/ class TableItem extends SelectableItem {
+ private static final int FIRST_COLUMN_IMAGE_INDENT = 2; // Space in front of image - first column only
+ private static final int FIRST_COLUMN_TEXT_INDENT = 4; // Space in front of text - first column only
+ private static final int TEXT_INDENT_NO_IMAGE = 2; // Space in front of item text when no item in the column has an image - first column only
+ private static final int TEXT_INDENT = 6; // Space in front of item text - all other columns
+ private static final int SELECTION_PADDING = 6; // Space behind text in a selected item
+
+ private Vector dataLabels = new Vector(); // Original text set by the user. Items that don't
+ // have a label are represented by a null slot
+ private String[] trimmedLabels = new String[0]; // Text that is actually displayed, may be trimmed
+ // to fit the column
+ private Vector images = new Vector(); // Item images. Items that don't have an image
+ // are represented by a null slot
+ private Point selectionExtent; // Size of the rectangle drawn to indicate a
+ // selected item.
+ private int imageIndent = 0; // the factor by which the item image and check box, if any,
+ // are indented. The multiplier is the image width.
+ private int index; // index of the item in the parent widget
+/**
+ * Create a table item in the table widget 'parent'. Append the new
+ * item to the existing items in 'parent'.
+ * @param parent - table widget the new item is added to.
+ * @param style - widget style. See Widget class for details
+ */
+public TableItem(Table parent, int style) {
+ this(parent, style, checkNull(parent).getItemCount());
+}
+/**
+ * Create a table item in the table widget 'parent'. Add the new
+ * item at position 'index' to the existing items in 'parent'.
+ * @param parent - table widget the new item is added to.
+ * @param style - widget style. See Widget class for details
+ * @param index - position the new item is inserted at in 'parent'
+ */
+public TableItem(Table parent, int style, int index) {
+ super(parent, style);
+ parent.addItem(this, index);
+}
+/**
+ * Calculate the size of the rectangle drawn to indicate a selected
+ * item. This is also used to draw the selection focus rectangle.
+ * The selection extent is calculated for the first column only (the
+ * only column the selection is drawn in).
+ */
+void calculateSelectionExtent() {
+ Table parent = getParent();
+ TableColumn column = parent.internalGetColumn(TableColumn.FIRST);
+ GC gc = new GC(parent);
+ String trimmedText = getText(gc, column);
+ int gridLineWidth = parent.getGridLineWidth();
+
+ if (trimmedText != null) {
+ selectionExtent = new Point(gc.stringExtent(trimmedText).x, parent.getItemHeight());
+ selectionExtent.x += getTextIndent(TableColumn.FIRST) + SELECTION_PADDING;
+ selectionExtent.x = Math.min(
+ selectionExtent.x, column.getWidth() - getImageStopX(column.getIndex()) - gridLineWidth);
+ if (parent.getLinesVisible() == true) {
+ selectionExtent.y -= gridLineWidth;
+ }
+ }
+ gc.dispose();
+}
+/**
+ * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'table' is null.
+ * Otherwise return 'table'
+ */
+static Table checkNull(Table table) {
+ if (table == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return table;
+}
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+/**
+ * The receiver is destroyed. Remove it from its parent widget.
+ */
+void disposeItem() {
+ getParent().removeItem(this);
+ dataLabels = null;
+ trimmedLabels = null;
+ images = null;
+ selectionExtent = null;
+ super.disposeItem();
+}
+/**
+ * Draw the image of the receiver for column 'index' at
+ * 'destinationPosition' using 'gc'.
+ * Stretch/shrink the image to the fixed image size of the receiver's
+ * parent.
+ * @param gc - GC to draw on.
+ * @param destinationPosition - position on the GC to draw at.
+ * @param index - index of the image to draw
+ * @return Answer the position where drawing stopped.
+ */
+Point drawImage(GC gc, Point destinationPosition, int index) {
+ Table parent = getParent();
+ Image image = getImage(index);
+ Rectangle sourceImageBounds;
+ Point destinationImageExtent = parent.getImageExtent();
+
+ if (image != null) {
+ sourceImageBounds = image.getBounds();
+ // full row select would obscure transparent images in all but the first column
+ // so always clear the image area in this case. Fixes 1FYNITC
+ if ((parent.getStyle() & SWT.FULL_SELECTION) != 0 && index != TableColumn.FIRST) {
+ gc.fillRectangle(
+ destinationPosition.x, destinationPosition.y,
+ destinationImageExtent.x, destinationImageExtent.y);
+ }
+ gc.drawImage(
+ image, 0, 0, // source x, y
+ sourceImageBounds.width, sourceImageBounds.height, // source width, height
+ destinationPosition.x, destinationPosition.y, // destination x, y
+ destinationImageExtent.x, destinationImageExtent.y); // destination width, height
+ }
+ if (((index == TableColumn.FIRST && // always add the image width for the first column
+ parent.hasFirstColumnImage() == true) || // if any item in the first column has an image
+ (index != TableColumn.FIRST && // add the image width if it's not the first column
+ image != null)) && // only when the item actually has an image
+ destinationImageExtent != null) {
+ destinationPosition.x += destinationImageExtent.x;
+ }
+ return destinationPosition;
+}
+/**
+ * Draw the label of the receiver for column 'index' at 'position'
+ * using 'gc'.
+ * The background color is set to the selection background color if
+ * the item is selected and the text is drawn for the first column.
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ * @param index - specifies which subitem text to draw
+ */
+void drawText(String label, GC gc, Point position, int index) {
+ Table parent = getParent();
+ boolean drawSelection;
+ int textOffset;
+ int textHeight;
+
+ if (label != null) {
+ drawSelection = (index == TableColumn.FIRST || (parent.getStyle() & SWT.FULL_SELECTION) != 0);
+ if (isSelected() == true && drawSelection == true) {
+ gc.setBackground(getSelectionBackgroundColor());
+ gc.setForeground(getSelectionForegroundColor());
+ }
+ textHeight = gc.stringExtent(label).y;
+ textOffset = (parent.getItemHeight() - textHeight) / 2; // vertically center the text
+ gc.drawString(label, position.x, position.y + textOffset);
+ if (isSelected() == true && drawSelection == true) {
+ gc.setBackground(parent.getBackground());
+ gc.setForeground(parent.getForeground());
+ }
+ }
+}
+
+/**
+* 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
+*/
+public Rectangle getBounds(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Rectangle itemBounds;
+ Rectangle columnBounds;
+ Rectangle checkboxBounds;
+ Table parent = getParent();
+ TableColumn column;
+ int itemIndex = parent.indexOf(this);
+ int itemHeight = parent.getItemHeight();
+ int gridLineWidth = parent.getGridLineWidth();
+ int itemYPos;
+
+ if (itemIndex == -1 || index < 0 || index >= parent.internalGetColumnCount()) {
+ itemBounds = new Rectangle(0, 0, 0, 0);
+ }
+ else {
+ column = parent.internalGetColumn(index);
+ columnBounds = column.getBounds();
+ itemYPos = columnBounds.y + itemHeight * itemIndex;
+ itemBounds = new Rectangle(
+ columnBounds.x, itemYPos,
+ columnBounds.width - gridLineWidth, itemHeight - gridLineWidth);
+ if (index == TableColumn.FIRST) {
+ if (isCheckable() == true) {
+ checkboxBounds = getCheckboxBounds();
+ itemBounds.x += checkboxBounds.x + checkboxBounds.width + CHECKBOX_PADDING; // add checkbox start, width and space behind checkbox
+ itemBounds.width -= itemBounds.x;
+ }
+ else {
+ itemBounds.x += getImageIndentPixel();
+ }
+ }
+ }
+ return itemBounds;
+}
+/**
+ * Return whether or not the receiver is checked.
+ * Always return false if the parent of the receiver does not
+ * have the CHECK style.
+ */
+public boolean getChecked() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getChecked();
+}
+/**
+ * Answer the x position of the item check box
+ */
+int getCheckboxXPosition() {
+ return getImageIndentPixel();
+}
+/**
+ * Answer the item labels set by the user.
+ * These may not be the same as those drawn on the screen. The latter
+ * may be trimmed to fit the column. Items that don't have a label are
+ * represented by a null slot in the vector.
+ * @return Vector - the item labels set by the user.
+ */
+Vector getDataLabels() {
+ return dataLabels;
+}
+/**
+ * Answer the display of the receiver's parent widget.
+ */
+public Display getDisplay() {
+ return super.getDisplay();
+}
+/**
+ * Return the position at which the string starts that is used
+ * to indicate a truncated item text.
+ * @param columnIndex - index of the column for which the position of
+ * the truncation replacement should be calculated
+ * @param columnWidth - width of the column for which the position of
+ * the truncation replacement should be calculated
+ * @return -1 when the item text is not truncated
+ */
+int getDotStartX(int columnIndex, int columnWidth) {
+ GC gc;
+ Table parent = getParent();
+ String label = getText(columnIndex);
+ int dotStartX = -1;
+ int maxWidth;
+
+ if (label != null) {
+ gc = new GC(parent);
+ maxWidth = getMaxTextWidth(columnIndex, columnWidth);
+ label = parent.trimItemText(label, maxWidth, gc);
+ if (label.endsWith(Table.DOT_STRING) == true) {
+ dotStartX = gc.stringExtent(label).x - parent.getDotsWidth(gc);
+ // add indents, margins and image width
+ dotStartX += getImageStopX(columnIndex);
+ dotStartX += getTextIndent(columnIndex);
+ }
+ gc.dispose();
+ }
+ return dotStartX;
+}
+/**
+ * Gets the grayed state.
+ * <p>
+ * @return the item grayed state.
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ */
+public boolean getGrayed() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ 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);
+
+ return getImage(0);
+}
+/**
+ * Answer 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
+ */
+public Image getImage(int columnIndex) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Image image = null;
+ Vector images = getImages();
+ int itemIndex = getParent().indexOf(this);
+
+ if (itemIndex != -1 && columnIndex >= 0 && columnIndex < images.size()) {
+ image = (Image) images.elementAt(columnIndex);
+ }
+ return image;
+}
+/**
+* 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
+*/
+public Rectangle getImageBounds(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Table parent = getParent();
+ int itemIndex = parent.indexOf (this);
+ int imageWidth = 0;
+ Point imageExtent = parent.getImageExtent();
+ Rectangle checkboxBounds;
+ Rectangle imageBounds = getBounds(index);
+
+ if (itemIndex == -1) {
+ imageBounds = new Rectangle(0, 0, 0, 0);
+ }
+ else
+ if (imageExtent != null) {
+ if (index == TableColumn.FIRST || getImage(index) != null) {
+ imageWidth = imageExtent.x;
+ }
+ }
+ imageBounds.width = imageWidth;
+ return imageBounds;
+}
+/**
+* Gets the image indent.
+* <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
+*/
+public int getImageIndent() {
+ if (isValidThread() == false) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (isValidWidget() == false) error(SWT.ERROR_WIDGET_DISPOSED);
+ int index = getParent().indexOf(this);
+
+ if (index == -1) {
+ return 0;
+ }
+ return imageIndent;
+}
+/**
+ * Answer the number of pixels the image in the first column is
+ * indented. Calculation starts at the column start and counts
+ * all pixels except the check box.
+ */
+int getImageIndentPixel() {
+ int indentPixel = FIRST_COLUMN_IMAGE_INDENT;
+ Point imageExtent = getParent().getImageExtent();
+
+ if (imageExtent != null) {
+ indentPixel += imageExtent.x * getImageIndent();
+ }
+ return indentPixel;
+}
+/**
+ * Answer the item images set by the user. Items that don't have an
+ * image are represented by a null slot in the vector.
+ */
+Vector getImages() {
+ return images;
+}
+/**
+ * Calculate the x coordinate where the item image of column
+ * 'columnIndex' stops.
+ * @param columnIndex - the column for which the stop position of the
+ * image should be calculated.
+ */
+int getImageStopX(int columnIndex) {
+ int imageStopX = 0;
+ Table parent = getParent();
+ Rectangle checkboxBounds;
+
+ if (columnIndex == TableColumn.FIRST) {
+ if (isCheckable() == true) {
+ checkboxBounds = getCheckboxBounds();
+ imageStopX += checkboxBounds.x + checkboxBounds.width + CHECKBOX_PADDING;
+ }
+ else {
+ imageStopX = getImageIndentPixel();
+ }
+ }
+ if (((columnIndex == TableColumn.FIRST && // always add the image width for the first column
+ parent.hasFirstColumnImage() == true) || // if any item in the first column has an image
+ (columnIndex != TableColumn.FIRST && // add the image width if it's not the first column
+ getImage(columnIndex) != null)) && // only when the item actually has an image
+ parent.getImageExtent() != null) {
+ imageStopX += parent.getImageExtent().x;
+ }
+ return imageStopX;
+}
+/**
+ * Return the index of the item in its parent widget.
+ */
+int getIndex() {
+ return index;
+}
+/**
+ * Return the item extent in the specified column
+ * The extent includes the actual width of the item including checkbox,
+ * image and text.
+ */
+Point getItemExtent(TableColumn column) {
+ Table parent = getParent();
+ int columnIndex = column.getIndex();
+ Point extent = new Point(getImageStopX(columnIndex), parent.getItemHeight() - parent.getGridLineWidth());
+ GC gc = new GC(parent);
+ String trimmedText = getText(gc, column);
+
+ if (trimmedText != null && trimmedText.length() > 0) {
+ extent.x += gc.stringExtent(trimmedText).x + getTextIndent(columnIndex);
+ }
+ if (columnIndex == TableColumn.FIRST) {
+ extent.x += SELECTION_PADDING;
+ }
+ gc.dispose();
+ return extent;
+}
+/**
+ * Answer the maximum width in pixel of the text that fits in the
+ * column identified by 'columnIndex' without trimming the text.
+ * @param columnIndex - the column for which the maximum text width
+ * should be calculated.
+ * @param columnWidth - width of the column 'columnIndex'
+ */
+int getMaxTextWidth(int columnIndex, int columnWidth) {
+ int itemWidth = getImageStopX(columnIndex) + getTextIndent(columnIndex) * 2;
+
+ return columnWidth - itemWidth;
+}
+/**
+ * Answer the parent widget of the receiver.
+ */
+public Table getParent() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return (Table) super.getSelectableParent();
+}
+/**
+ * Answer the width of the item required to display the complete contents.
+ */
+int getPreferredWidth(int index) {
+ int size = getImageStopX(index);
+ String text = getText(index);
+
+ if (text != null) {
+ size += getParent().getTextWidth(text) + getTextIndent(index) * 2 + 1;
+ }
+ return size;
+}
+/**
+ * Return the size of the rectangle drawn to indicate a selected item.
+ * This is also used to draw the selection focus rectangle and drop
+ * insert marker.
+ * Implements SelectableItem#getSelectionExtent
+ */
+Point getSelectionExtent() {
+ Table parent = getParent();
+ Point extent;
+
+ if ((parent.getStyle() & SWT.FULL_SELECTION) == 0) { // regular, first column, selection?
+ if (selectionExtent == null) {
+ calculateSelectionExtent();
+ }
+ extent = selectionExtent;
+ }
+ else {
+ extent = parent.getFullSelectionExtent(this);
+ }
+ return extent;
+}
+/**
+ * Return the x position of the selection rectangle
+ * Implements SelectableItem#getSelectionX
+ */
+int getSelectionX() {
+ return getImageStopX(TableColumn.FIRST) + getParent().getHorizontalOffset();
+}
+/**
+ * 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);
+
+ 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.
+ */
+public String getText(int columnIndex) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int itemIndex = getParent().indexOf(this);
+ Vector labels = getDataLabels();
+ String label = null;
+
+ if (itemIndex == -1) {
+ error(SWT.ERROR_CANNOT_GET_TEXT);
+ }
+ if (columnIndex >= 0 && columnIndex < labels.size()) {
+ label = (String) labels.elementAt(columnIndex);
+ }
+ if (label == null) {
+ label = ""; // label vector is initialized with null instead of empty Strings
+ }
+ return label;
+}
+/**
+ * Answer the text that is going to be drawn in 'column'. This
+ * text may be a trimmed copy of the original text set by the
+ * user if it doesn't fit into the column. In that case the last
+ * characters are replaced with Table.DOT_STRING.
+ * A cached copy of the trimmed text is returned if available.
+ * @param gc - GC to use for measuring the text extent
+ * @param column - TableColumn for which the text should be returned
+ */
+String getText(GC gc, TableColumn column) {
+ int columnIndex = column.getIndex();
+ String label = getTrimmedText(columnIndex);
+ int maxWidth;
+
+ if (label == null) {
+ maxWidth = getMaxTextWidth(columnIndex, column.getWidth());
+ label = getParent().trimItemText(getText(columnIndex), maxWidth, gc);
+ }
+ return label;
+}
+/**
+ * Answer the indent of the text in column 'columnIndex' in pixel.
+ * This indent is used in front of and behind the item text.
+ * @param columnIndex - specifies the column for which the indent
+ * should be calculated.
+ */
+int getTextIndent(int columnIndex) {
+ int textIndent;
+
+ if (columnIndex == TableColumn.FIRST) {
+ if (getParent().hasFirstColumnImage() == false) {
+ textIndent = TEXT_INDENT_NO_IMAGE;
+ }
+ else {
+ textIndent = FIRST_COLUMN_TEXT_INDENT;
+ }
+ }
+ else {
+ textIndent = TEXT_INDENT;
+ }
+ return textIndent;
+}
+/**
+ * Answer the cached trimmed text for column 'columnIndex'.
+ * Answer null if it hasn't been calculated yet.
+ * @param columnIndex - specifies the column for which the
+ * trimmed text should be answered.
+ */
+String getTrimmedText(int columnIndex) {
+ String label = null;
+ String labels[] = getTrimmedTexts();
+
+ if (columnIndex < labels.length) {
+ label = labels[columnIndex];
+ }
+ return label;
+}
+/**
+ * Answer an array of cached trimmed labels.
+ */
+String [] getTrimmedTexts() {
+ return trimmedLabels;
+}
+/**
+ * Ensure that the image and label vectors have at least
+ * 'newSize' number of elements.
+ */
+void growVectors(int newSize) {
+ Vector images = getImages();
+ Vector labels = getDataLabels();
+
+ if (newSize > images.size()){
+ images.setSize(newSize);
+ }
+ if (newSize > labels.size()){
+ labels.setSize(newSize);
+ }
+}
+/**
+ * Insert 'column' into the receiver.
+ */
+void insertColumn(TableColumn column) {
+ Vector data = getDataLabels();
+ Vector images = getImages();
+ String stringData[];
+ Image imageData[];
+ int index = column.getIndex();
+
+ if (index < data.size()) {
+ data.insertElementAt(null, index);
+ }
+ else {
+ data.addElement(null);
+ }
+ stringData = new String[data.size()];
+ data.copyInto(stringData);
+ setText(stringData);
+
+ if (index < images.size()) {
+ images.insertElementAt(null, index);
+ }
+ else {
+ images.addElement(null);
+ }
+ imageData = new Image[images.size()];
+ images.copyInto(imageData);
+ setImage(imageData);
+}
+/**
+ * Sets the image at an index.
+ * <p>
+ * @param image the new image (or null)
+ *
+ * @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+ * when called from the wrong thread
+ * @exception SWTError(ERROR_WIDGET_DISPOSED)
+ * when the widget has been disposed
+ */
+void internalSetImage(int columnIndex, Image image) {
+ Vector images = getImages();
+ boolean imageWasNull = false;
+ Table parent = getParent();
+
+ if (columnIndex >= 0 &&
+ columnIndex < parent.internalGetColumnCount()) {
+ if (columnIndex >= images.size()) {
+ growVectors(columnIndex + 1);
+ }
+ if (((Image) images.elementAt(columnIndex)) == null && image != null) {
+ imageWasNull = true;
+ }
+ images.setElementAt(image, columnIndex);
+ reset(columnIndex); // new image may cause text to no longer fit in the column
+ notifyImageChanged(columnIndex, imageWasNull);
+ }
+}
+/**
+* Sets the widget text.
+* <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
+*
+*/
+void internalSetText(int columnIndex, String string) {
+ Vector labels = getDataLabels();
+ Table parent = getParent();
+ String oldText;
+
+ if (columnIndex >= 0 &&
+ columnIndex < parent.internalGetColumnCount()) {
+ if (columnIndex >= labels.size()) {
+ growVectors(columnIndex + 1);
+ }
+ oldText = (String) labels.elementAt(columnIndex);
+ if (string.equals(oldText) == false) {
+ labels.setElementAt(string, columnIndex);
+ reset(columnIndex);
+ notifyTextChanged(columnIndex, oldText == null);
+ }
+ }
+}
+/**
+ * Answer whether the click at 'xPosition' on the receiver is a
+ * selection click.
+ * A selection click occurred when the click was behind the image
+ * and before the end of the item text.
+ * @return
+ * true - 'xPosition' is a selection click.
+ * false - otherwise
+ */
+boolean isSelectionHit(int xPosition) {
+ int itemStopX = getImageStopX(TableColumn.FIRST);
+ Point selectionExtent = getSelectionExtent();
+
+ if (selectionExtent != null) {
+ itemStopX += selectionExtent.x;
+ }
+ return (xPosition > getCheckboxBounds().x + getCheckboxBounds().width) && (xPosition <= itemStopX);
+}
+/**
+ * The image for the column identified by 'columnIndex' has changed.
+ * Notify the parent widget and supply redraw coordinates, if possible.
+ * @param columnIndex - index of the column that has a new image.
+ */
+void notifyImageChanged(int columnIndex, boolean imageWasNull) {
+ Table parent = getParent();
+ Rectangle changedColumnBounds;
+ int redrawStartX = 0;
+ int redrawWidth = 0;
+ int columnCount = parent.internalGetColumnCount();
+
+ if (columnIndex >= 0 && columnIndex < columnCount && parent.getVisibleRedrawY(this) != -1) {
+ changedColumnBounds = parent.internalGetColumn(columnIndex).getBounds();
+ redrawStartX = Math.max(0, getImageBounds(columnIndex).x);
+ if (parent.getImageExtent() != null && imageWasNull == false) {
+ redrawWidth = getImageStopX(columnIndex);
+ }
+ else {
+ redrawWidth = changedColumnBounds.width;
+ }
+ redrawWidth += changedColumnBounds.x - redrawStartX;
+ }
+ parent.itemChanged(this, redrawStartX, redrawWidth);
+}
+
+/**
+ * The label for the column identified by 'columnIndex' has changed.
+ * Notify the parent widget and supply redraw coordinates, if possible.
+ * @param columnIndex - index of the column that has a new label.
+ */
+void notifyTextChanged(int columnIndex, boolean textWasNull) {
+ Table parent = getParent();
+ String text;
+ Rectangle columnBounds;
+ int redrawStartX = 0;
+ int redrawWidth = 0;
+ int columnCount = parent.internalGetColumnCount();
+
+ if (columnIndex >= 0 && columnIndex < columnCount && parent.getVisibleRedrawY(this) != -1) {
+ text = (String) getDataLabels().elementAt(columnIndex);
+ columnBounds = parent.internalGetColumn(columnIndex).getBounds();
+ redrawStartX = columnBounds.x;
+ if (getImage(columnIndex) != null) {
+ redrawStartX += getImageStopX(columnIndex);
+ }
+ redrawStartX = Math.max(0, redrawStartX);
+ // don't redraw if text changed from null to empty string
+ if (textWasNull == false || text.length() > 0) {
+ redrawWidth = columnBounds.x + columnBounds.width - redrawStartX;
+ }
+ }
+ parent.itemChanged(this, redrawStartX, redrawWidth);
+}
+/**
+ * Draw the receiver at 'paintPosition' in the column identified by
+ * 'columnIndex' using 'gc'.
+ * @param gc - GC to use for drawing
+ * @param paintPosition - position where the receiver should be drawing.
+ * @param column - the column to draw in
+ */
+void paint(GC gc, Point paintPosition, TableColumn column) {
+ int columnIndex = column.getIndex();
+ String label = getText(gc, column);
+ String oldLabel = getTrimmedText(columnIndex);
+
+ if (label != null && label.equals(oldLabel) == false) {
+ setTrimmedText(label, columnIndex);
+ selectionExtent = null; // force a recalculation next time the selection extent is needed
+ }
+ if (columnIndex == TableColumn.FIRST) {
+ paintPosition.x += getImageIndentPixel();
+ if (isCheckable() == true) {
+ paintPosition = drawCheckbox(gc, paintPosition);
+ }
+ }
+ paintPosition = drawImage(gc, paintPosition, columnIndex);
+ paintPosition.x += getTextIndent(columnIndex);
+ drawText(label, gc, paintPosition, columnIndex);
+}
+/**
+ * Remove 'column' from the receiver.
+ */
+void removeColumn(TableColumn column) {
+ Vector data = getDataLabels();
+ Vector images = getImages();
+ String stringData[];
+ Image imageData[];
+ int index = column.getIndex();
+
+ if (index < data.size()) {
+ data.removeElementAt(index);
+ stringData = new String[data.size()];
+ data.copyInto(stringData);
+ setText(stringData);
+ }
+ if (index < images.size()) {
+ images.removeElementAt(index);
+ imageData = new Image[images.size()];
+ images.copyInto(imageData);
+ setImage(imageData);
+ }
+}
+/**
+ * Reset the cached trimmed label for the sub item identified by
+ * 'index'.
+ * @param index - index of the label that should be reset.
+ */
+void reset(int index) {
+ String trimmedLabels[] = getTrimmedTexts();
+
+ if (index >= 0 && index < trimmedLabels.length) {
+ trimmedLabels[index] = null;
+ }
+ if (index == TableColumn.FIRST) {
+ selectionExtent = null;
+ }
+}
+/**
+* Warning: API under construction.
+*/
+public void setImage(Image [] images) {
+ if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);
+
+ if (images == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (getParent().indexOf(this) == -1) {
+ return;
+ }
+ for (int i = 0; i < images.length; i++) {
+ internalSetImage(i, images[i]);
+ }
+}
+/**
+ * Sets the image at an index.
+ * <p>
+ * @param image the new image (or null)
+ *
+ * @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+ * when called from the wrong thread
+ * @exception SWTError(ERROR_WIDGET_DISPOSED)
+ * when the widget has been disposed
+ */
+public void setImage(int columnIndex, Image image) {
+ if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);
+
+ if (getParent().indexOf(this) != -1) {
+ internalSetImage(columnIndex, image);
+ }
+}
+/**
+ * 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);
+
+ 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
+*/
+public void setImageIndent(int indent) {
+ if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);
+ Table parent = getParent();
+ TableColumn column;
+ int index = parent.indexOf(this);
+
+ if (index != -1 && indent >= 0 && indent != imageIndent) {
+ imageIndent = indent;
+ column = parent.internalGetColumn(TableColumn.FIRST);
+ parent.redraw(
+ 0, parent.getRedrawY(this),
+ column.getWidth(), parent.getItemHeight(), false);
+ }
+}
+/**
+ * Warning: API under construction.
+ */
+public void setText(String [] strings) {
+ if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);
+
+ if (strings == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (getParent().indexOf(this) == -1) {
+ return;
+ }
+ for (int i = 0; i < strings.length; i++) {
+ String string = strings[i];
+ if (string != null) {
+ internalSetText(i, string);
+ }
+ }
+}
+/**
+* Sets the 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
+*/
+public void setText (int columnIndex, String string) {
+ if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);
+
+ if (string == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (getParent().indexOf(this) != -1) {
+ internalSetText(columnIndex, string);
+ }
+}
+/**
+ * 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);
+
+ if (text == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ setText(0, text);
+}
+/**
+ * Set the trimmed text of column 'columnIndex' to label. The trimmed
+ * text is the one that is displayed in a column. It may be shorter than
+ * the text originally set by the user via setText(...) to fit the
+ * column.
+ * @param label - the text label of column 'columnIndex'. May be trimmed
+ * to fit the column.
+ * @param columnIndex - specifies the column whose text label should be
+ * set.
+ */
+void setTrimmedText(String label, int columnIndex) {
+ String labels[] = getTrimmedTexts();
+
+ if (columnIndex < labels.length) {
+ labels[columnIndex] = label;
+ }
+}
+/**
+ * Set the checked state to 'checked' if the parent of the
+ * receiver has the CHECK style.
+ */
+public void setChecked(boolean checked) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ 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>
+ */
+public void setGrayed (boolean grayed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ super.setGrayed(grayed);
+}
+/**
+ * Set the index of this item in its parent widget to 'newIndex'.
+ */
+void setIndex(int newIndex) {
+ index = newIndex;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java
new file mode 100755
index 0000000000..407924fdc7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java
@@ -0,0 +1,619 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public class Text extends Scrollable {
+ char echoCharacter;
+ boolean ignoreChange;
+ String hiddenText;
+ int lastModifiedText;
+ PtTextCallback_t textVerify;
+
+ public static final int LIMIT;
+ public static final String DELIMITER;
+ /*
+ * These values can be different on different platforms.
+ * Therefore they are not initialized in the declaration
+ * to stop the compiler from inlining.
+ */
+ static {
+ LIMIT = 0x7FFFFFFF;
+ DELIMITER = "\n";
+ }
+
+public Text (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+ if ((style & SWT.SINGLE) != 0) style &= ~(SWT.H_SCROLL | SWT.V_SCROLL);
+ if ((style & (SWT.SINGLE | SWT.MULTI)) != 0) return style;
+ if ((style & (SWT.H_SCROLL | SWT.V_SCROLL)) != 0) {
+ return style | SWT.MULTI;
+ }
+ return style | SWT.SINGLE;
+}
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ PhDim_t dim = new PhDim_t ();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
+ OS.PtWidgetPreferredSize (handle, dim);
+ int width = dim.w, height = dim.h;
+ if ((style & SWT.MULTI) != 0) {
+ int child = OS.PtWidgetChildBack (handle);
+ OS.PtWidgetPreferredSize (child, dim);
+ width += dim.w - 1;
+ height += dim.h - 1;
+ }
+ if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ 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);
+ ScrollBar scroll;
+ if (wHint != SWT.DEFAULT) {
+ width = area.size_w;
+ if ((scroll = getVerticalBar ()) != null) width += scroll.getSize().x;
+ }
+ if (hHint != SWT.DEFAULT) {
+ height = area.size_h;
+ if ((scroll = getHorizontalBar ()) != null) height += scroll.getSize().y;
+ }
+ }
+ return new Point(width, height);
+}
+public void clearSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ OS.PtTextSetSelection (handle, new int [] {0}, new int [] {0});
+}
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int parentHandle = parent.handle;
+ 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, 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,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ return;
+ }
+ 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, 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,
+ OS.Pt_ARG_SCROLLBAR_X_DISPLAY, (style & SWT.H_SCROLL) != 0 ? OS.Pt_ALWAYS : OS.Pt_NEVER, 0,
+ OS.Pt_ARG_SCROLLBAR_Y_DISPLAY, (style & SWT.V_SCROLL) != 0 ? OS.Pt_ALWAYS : OS.Pt_NEVER, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ createScrollBars();
+}
+
+public void addModifyListener (ModifyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Modify, typedListener);
+}
+
+public void addSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+public void addVerifyListener (VerifyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Verify, typedListener);
+}
+
+public void append (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (null, string, false);
+ OS.PtTextModifyText (handle, 0, 0, -1, buffer, buffer.length);
+}
+
+public void copy () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ int [] start = new int [1], end = new int [1];
+ int length = OS.PtTextGetSelection (handle, start, end);
+ if (length <= 0) return;
+ int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ byte[] buffer = new byte[length + 1];
+ OS.memmove (buffer, args [1] + start [0], length);
+ int ig = OS.PhInputGroup (0);
+ OS.PhClipboardCopyString((short)ig, buffer);
+}
+
+public void cut () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ int [] start = new int [1], end = new int [1];
+ int length = OS.PtTextGetSelection (handle, start, end);
+ if (length <= 0) return;
+ int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ byte[] buffer = new byte[length + 1];
+ OS.memmove (buffer, args [1] + start [0], length);
+ int ig = OS.PhInputGroup (0);
+ OS.PhClipboardCopyString((short)ig, buffer);
+ buffer = new byte[0];
+ OS.PtTextModifyText (handle, start [0], end [0], start [0], buffer, buffer.length);
+}
+
+public int getCaretLineNumber () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE - NOT NEEDED
+ return 0;
+}
+
+public Point getCaretLocation () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE - NOT NEEDED
+ return null;
+}
+
+public int getCaretPosition () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getCharCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] == 0) return 0;
+ return OS.strlen (args [1]);
+}
+
+public boolean getDoubleClickEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE - NOT NEEDED
+ return false;
+}
+
+public char getEchoChar () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return echoCharacter;
+}
+
+public boolean getEditable () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_TEXT_FLAGS, 0, 0};
+ OS.PtGetResources(handle, args.length / 3, args);
+ return (args [1] & OS.Pt_EDITABLE) != 0;
+}
+
+public int getLineCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SINGLE) != 0) return 1;
+ int [] args = {OS.Pt_ARG_MULTITEXT_NUM_LINES, 0, 0};
+ OS.PtGetResources(handle, args.length / 3, args);
+ return args [1];
+}
+
+public String getLineDelimiter () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return "\n";
+}
+
+public int getLineHeight () {
+ if ((style & SWT.SINGLE) != 0) {
+ PhDim_t dim = new PhDim_t ();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
+ OS.PtWidgetPreferredSize (handle, dim);
+ PhRect_t extent = new PhRect_t ();
+ OS.PtWidgetExtent(handle, extent);
+ PhRect_t canvas = new PhRect_t ();
+ OS.PtWidgetCanvas (handle, canvas);
+ int topBorder = canvas.ul_y - extent.ul_y;
+ int bottomBorder = extent.lr_y - canvas.lr_y;
+ return dim.h - topBorder - bottomBorder;
+ }
+ int ptr = OS.malloc (20);
+ int [] args = {
+ OS.Pt_ARG_MULTITEXT_QUERY_LINE, ptr, 1,
+ OS.Pt_ARG_MULTITEXT_LINE_SPACING, 0, 0
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ int [] line = new int [1];
+ OS.memmove (line, args [1] + 8, 4);
+ PhRect_t extent = new PhRect_t ();
+ OS.memmove (extent, line [0] + 10, 8);
+ OS.free(ptr);
+ return extent.lr_y - extent.ul_y + 1 + args [4];
+}
+
+public Point getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (textVerify != null) {
+ return new Point (textVerify.start_pos, textVerify.end_pos);
+ }
+ int [] start = new int [1], end = new int [1];
+ OS.PtTextGetSelection (handle, start, end);
+ if (start [0] == -1) {
+ int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ start [0] = end [0] = args [1];
+ }
+ return new Point (start [0], end [0]);
+}
+
+public int getSelectionCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Point selection = getSelection ();
+ return selection.y - selection.x;
+}
+
+public String getSelectionText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ /*
+ * NOTE: The current implementation uses substring ()
+ * which can reference a potentially large character
+ * array.
+ */
+ Point selection = getSelection ();
+ return getText ().substring (selection.x, selection.y);
+}
+
+public int getTabs () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE - NOT NEEDED
+ return 0;
+}
+
+public String getText (int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ /*
+ * NOTE: The current implementation uses substring ()
+ * which can reference a potentially large character
+ * array.
+ */
+ //NOT DONE - use OS in SINGLE text
+ return getText ().substring (start, end + 1);
+}
+
+public String getText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (echoCharacter != '\0') return hiddenText;
+ int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] == 0) return "";
+ int length = OS.strlen (args [1]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, args [1], length);
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ return new String (unicode);
+}
+
+public int getTextLimit () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getTopIndex () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SINGLE) != 0) return 0;
+ int [] args = {OS.Pt_ARG_MULTITEXT_TOP_LINE, 0, 0};
+ OS.PtGetResources(handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getTopPixel () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ //NOT DONE - NOT NEEDED
+ return 0;
+}
+
+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);
+}
+
+public void insert (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (null, string, false);
+ int [] start = new int [1], end = new int [1];
+ OS.PtTextGetSelection (handle, start, end);
+ if (start [0] == -1) {
+ int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ start [0] = end [0] = args [1];
+ }
+ OS.PtTextModifyText (handle, start [0], end [0], start [0], buffer, buffer.length);
+}
+
+public void paste () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ int ig = OS.PhInputGroup (0);
+ int ptr = OS.PhClipboardPasteString((short)ig);
+ if (ptr == 0) return;
+ int length = OS.strlen (ptr);
+ int [] start = new int [1], end = new int [1];
+ OS.PtTextGetSelection (handle, start, end);
+ if (start [0] == -1) {
+ int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ start [0] = end [0] = args [1];
+ }
+ OS.PtTextModifyText (handle, start [0], end [0], end [0], ptr, length);
+ OS.free(ptr);
+}
+
+int processModify (int info) {
+ if (lastModifiedText != 0) {
+ OS.free (lastModifiedText);
+ lastModifiedText = 0;
+ }
+ if (!ignoreChange) sendEvent (SWT.Modify);
+ return OS.Pt_CONTINUE;
+}
+
+int processPaint (int damage) {
+ if ((style & SWT.SINGLE) != 0) {
+ OS.PtSuperClassDraw (OS.PtText (), handle, damage);
+ } else {
+ OS.PtSuperClassDraw (OS.PtMultiText (), handle, damage);
+ }
+ return super.processPaint (damage);
+}
+
+int processVerify (int info) {
+ if (lastModifiedText != 0) {
+ OS.free (lastModifiedText);
+ lastModifiedText = 0;
+ }
+ super.processVerify (info);
+ if (echoCharacter == '\0' && !hooks (SWT.Verify)) return 0;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ PtTextCallback_t textVerify = new PtTextCallback_t ();
+ OS.memmove (textVerify, cbinfo.cbdata, PtTextCallback_t.sizeof);
+ byte [] buffer = new byte [textVerify.length];
+ OS.memmove (buffer, textVerify.text, buffer.length);
+ String text = new String (Converter.mbcsToWcs (null, buffer));
+ String newText = text;
+ if (!ignoreChange) {
+ Event event = new Event ();
+ event.start = textVerify.start_pos;
+ event.end = textVerify.end_pos;
+ event.doit = textVerify.doit != 0;
+ event.text = text;
+ sendEvent (SWT.Verify, event);
+ newText = event.text;
+ textVerify.doit = (event.doit && newText != null) ? 1 : 0;
+ }
+ if (newText != null) {
+ if (echoCharacter != '\0' && (textVerify.doit != 0)) {
+ String prefix = hiddenText.substring (0, textVerify.start_pos);
+ String suffix = hiddenText.substring (textVerify.end_pos, hiddenText.length ());
+ hiddenText = prefix + newText + suffix;
+ char [] charBuffer = new char [newText.length ()];
+ for (int i=0; i<charBuffer.length; i++) {
+ charBuffer [i] = echoCharacter;
+ }
+ newText = new String (charBuffer);
+ }
+ if (newText != text) {
+ byte [] buffer2 = Converter.wcsToMbcs (null, newText, true);
+ int length = buffer2.length - 1;
+ if (length == textVerify.length) {
+ OS.memmove(textVerify.text, buffer2, length);
+ } else {
+ int ptr = OS.malloc (length);
+ OS.memmove (ptr, buffer2, buffer2.length);
+ textVerify.new_insert += length - textVerify.length;
+ textVerify.text = ptr;
+ textVerify.length = length;
+ lastModifiedText = ptr;
+ }
+ }
+ }
+ OS.memmove (cbinfo.cbdata, textVerify, PtTextCallback_t.sizeof);
+ textVerify = null;
+ return 0;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ if (lastModifiedText != 0) {
+ OS.free (lastModifiedText);
+ lastModifiedText = 0;
+ }
+}
+
+public void removeModifyListener (ModifyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Modify, listener);
+}
+
+public void removeSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+public void removeVerifyListener (VerifyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Verify, listener);
+}
+
+public void selectAll () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ OS.PtTextSetSelection (handle, new int [0], new int [] {-1});
+}
+
+public void setEchoChar (char echo) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (echoCharacter == echo) return;
+ String newText;
+ if (echo == 0) {
+ newText = hiddenText;
+ hiddenText = null;
+ } else {
+ newText = hiddenText = getText();
+ }
+ echoCharacter = echo;
+ Point selection = getSelection();
+ boolean oldValue = ignoreChange;
+ ignoreChange = true;
+ setText(newText);
+ setSelection(selection.x, selection.y);
+ ignoreChange = oldValue;
+}
+
+public void setDoubleClickEnabled (boolean doubleClick) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ //NOT DONE - NOT NEEDED
+}
+
+public void setEditable (boolean editable) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ style &= ~SWT.READ_ONLY;
+ if (!editable) style |= SWT.READ_ONLY;
+ int [] args = {OS.Pt_ARG_TEXT_FLAGS, editable ? OS.Pt_EDITABLE : 0, OS.Pt_EDITABLE};
+ OS.PtSetResources(handle, args.length / 3, args);
+}
+
+public void setSelection (int position) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_CURSOR_POSITION, position, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setSelection (Point selection) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setSelection (selection.x, selection.y);
+}
+
+public void setSelection (int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ OS.PtTextSetSelection (handle, new int [] {start}, new int [] {end});
+}
+
+public void setTabs (int tabs) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (tabs < 0) return;
+
+ //NOT DONE - NOT NEEDED
+}
+
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int [] args = {OS.Pt_ARG_TEXT_STRING, ptr, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+ OS.free (ptr);
+}
+
+public void setTextLimit (int limit) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
+ int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, limit, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setTopIndex (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SINGLE) != 0) return;
+ int [] args = {OS.Pt_ARG_MULTITEXT_TOP_LINE, index + 1, 0};
+ OS.PtSetResources(handle, args.length / 3, args);
+}
+
+public void showSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ //NOT DONE - NOT NEEDED
+}
+
+} \ No newline at end of file
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
new file mode 100755
index 0000000000..5b61c7394e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java
@@ -0,0 +1,155 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public /*final*/ class ToolBar extends Composite {
+ int itemCount;
+ ToolItem [] items;
+
+public ToolBar (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+static int checkStyle (int style) {
+ /*
+ * Even though it is legal to create this widget
+ * with scroll bars, they serve no useful purpose
+ * because they do not automatically scroll the
+ * widget's client area. The fix is to clear
+ * the SWT style.
+ */
+ return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+// if (layout != null) return super.computeSize (wHint, hHint, changed);
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ PhDim_t dim = new PhDim_t();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
+ OS.PtWidgetPreferredSize(handle, dim);
+ int width = dim.w, height = dim.h;
+ if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ 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;
+ }
+ return new Point(width, height);
+}
+
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int parentHandle = parent.handle;
+
+ int [] args = {
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (OS.PtToolbar (), parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+void createItem (ToolItem item, int index) {
+ if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_INVALID_RANGE);
+ if (itemCount == items.length) {
+ ToolItem [] newItems = new ToolItem [itemCount + 4];
+ System.arraycopy (items, 0, newItems, 0, items.length);
+ items = newItems;
+ }
+ item.createWidget (index);
+ System.arraycopy (items, index, items, index + 1, itemCount++ - index);
+ items [index] = item;
+}
+
+void createWidget (int index) {
+ super.createWidget (index);
+ items = new ToolItem [4];
+ itemCount = 0;
+}
+
+void destroyItem (ToolItem item) {
+ int index = 0;
+ while (index < itemCount) {
+ if (items [index] == item) break;
+ index++;
+ }
+ if (index == itemCount) return;
+ System.arraycopy (items, index + 1, items, index, --itemCount - index);
+ items [itemCount] = null;
+}
+
+public int getItemCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return itemCount;
+}
+
+public ToolItem [] getItems () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ ToolItem [] result = new ToolItem [itemCount];
+ System.arraycopy (items, 0, result, 0, itemCount);
+ return result;
+}
+
+public ToolItem getItem (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int count = itemCount;
+ if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
+ return items [index];
+}
+
+public ToolItem getItem (Point pt) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ ToolItem [] items = getItems ();
+ for (int i=0; i<items.length; i++) {
+ Rectangle rect = items [i].getBounds ();
+ if (rect.contains (pt)) return items [i];
+ }
+ return null;
+}
+
+public int getRowCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return 1;
+}
+
+public int indexOf (ToolItem item) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int count = itemCount;
+ for (int i=0; i<count; i++) {
+ if (items [i] == item) return i;
+ }
+ return -1;
+}
+
+void releaseWidget () {
+ for (int i=0; i<items.length; i++) {
+ ToolItem item = items [i];
+ if (item != null && !item.isDisposed ()) {
+ item.releaseWidget ();
+ }
+ }
+ 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
new file mode 100755
index 0000000000..d8e1d10127
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java
@@ -0,0 +1,325 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public /*final*/ class ToolItem extends Item {
+ ToolBar parent;
+ Control control;
+ String toolTipText;
+ Image hotImage, disabledImage;
+
+public ToolItem (ToolBar parent, int style) {
+ this(parent, style, parent.getItemCount ());
+}
+
+public ToolItem (ToolBar parent, int style, int index) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ parent.createItem (this, index);
+}
+
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.PUSH, SWT.CHECK, SWT.RADIO, SWT.SEPARATOR, SWT.DROP_DOWN, 0);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+void createHandle (int index) {
+ int count = parent.getItemCount();
+ if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
+ int parentHandle = parent.handle;
+
+ if ((style & SWT.SEPARATOR) != 0) {
+ int [] args = {
+// OS.Pt_ARG_SEP_FLAGS, OS.Pt_SEP_VERTICAL, OS.Pt_SEP_VERTICAL | OS.Pt_SEP_HORIZONTAL,
+// OS.Pt_ARG_SEP_TYPE, OS.Pt_NOLINE, 0,
+ OS.Pt_ARG_WIDTH, 2, 0,
+ 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 {
+ boolean rightAligned = (parent.style & SWT.RIGHT) != 0;
+ boolean toggle = (style & (SWT.CHECK | SWT.RADIO)) != 0;
+ int [] args = {
+ 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);
+ }
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ if (index != count) {
+ int i = 0;
+ int child = OS.PtWidgetChildBack (parentHandle);
+ /*
+ * Feature in Photon. Tool bars have an extra widget which
+ * is the parent of all tool items. PtValidParent() can not be
+ * used, since it does not return that widget.
+ */
+ if (child != 0) child = OS.PtWidgetChildBack (child);
+ while (i != index && child != 0) {
+ child = OS.PtWidgetBrotherInFront (child);
+ i++;
+ }
+ OS.PtWidgetInsert (topHandle (), child, 1);
+ }
+ if (OS.PtWidgetIsRealized (parentHandle)) {
+ OS.PtRealizeWidget (topHandle ());
+ }
+}
+
+public Rectangle getBounds () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (handle, area);
+ return new Rectangle (area.pos_x, area.pos_y, area.size_w, area.size_h);
+}
+
+public Control getControl () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return control;
+}
+
+public Image getDisabledImage () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return disabledImage;
+}
+
+public Display getDisplay () {
+ ToolBar parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.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;
+}
+
+public Image getHotImage () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return hotImage;
+}
+
+public ToolBar getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
+
+public boolean getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
+ int [] args = {OS.Pt_ARG_FLAGS, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return (args [1] & OS.Pt_SET) != 0;
+}
+
+public String getToolTipText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return toolTipText;
+}
+
+public int getWidth () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_WIDTH, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_ACTIVATE, windowProc, SWT.Selection);
+}
+
+public boolean isEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getEnabled () && parent.isEnabled ();
+}
+
+int processSelection (int info) {
+ if ((style & SWT.RADIO) != 0) {
+ setSelection (true);
+ ToolItem [] items = parent.getItems ();
+ int index = 0;
+ while (index < items.length && items [index] != this) index++;
+ ToolItem item;
+ int i = index;
+ while (--i >= 0 && ((item = items [i]).style & SWT.RADIO) != 0) {
+ item.setSelection (false);
+ }
+ i = index;
+ while (++i < items.length && ((item = items [i]).style & SWT.RADIO) != 0) {
+ item.setSelection (false);
+ }
+ }
+ postEvent (SWT.Selection);
+ return OS.Pt_CONTINUE;
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ parent.destroyItem (this);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ parent = null;
+ control = null;
+ hotImage = null;
+ disabledImage = null;
+}
+
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+public void setControl (Control control) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (control != null && control.parent != parent) {
+ error (SWT.ERROR_INVALID_PARENT);
+ }
+ if ((style & SWT.SEPARATOR) == 0) return;
+ Control oldControl = this.control;
+ this.control = control;
+ if (oldControl != null) {
+ OS.PtReParentWidget(oldControl.handle, parent.handle);
+ }
+ if (control != null && !control.isDisposed ()) {
+ OS.PtReParentWidget(control.handle, handle);
+ control.setBounds (getBounds ());
+ }
+}
+
+public void setDisabledImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ disabledImage = image;
+}
+
+public void setEnabled (boolean enabled) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {
+ OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_BLOCKED, OS.Pt_BLOCKED,
+ OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_GHOST, OS.Pt_GHOST,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setHotImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ hotImage = image;
+}
+
+public void setImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ int imageHandle = 0;
+ int type = OS.Pt_Z_STRING;
+ if (image != null) {
+ imageHandle = copyPhImage (image.handle);
+ int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] != 0 && OS.strlen (args [1]) > 0) type = OS.Pt_TEXT_IMAGE;
+ else type = OS.Pt_IMAGE;
+ }
+ int [] args = {
+ OS.Pt_ARG_LABEL_IMAGE, imageHandle, 0,
+ OS.Pt_ARG_LABEL_TYPE, type, 0
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ if (imageHandle != 0) OS.free (imageHandle);
+}
+
+public void setSelection (boolean selected) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
+ int [] args = {OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ super.setText (string);
+ int ptr = 0;
+ int type = OS.Pt_IMAGE;
+ if (string != null) {
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ 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);
+ if (args [1] != 0) type = OS.Pt_TEXT_IMAGE;
+ else type = OS.Pt_Z_STRING;
+ }
+ int [] args = {
+ OS.Pt_ARG_TEXT_STRING, ptr, 0,
+ OS.Pt_ARG_LABEL_TYPE, type, 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ if (ptr != 0) OS.free (ptr);
+}
+
+public void setToolTipText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ toolTipText = string;
+}
+
+public void setWidth (int width) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) == 0) return;
+ if (width < 0) return;
+ int [] args = {OS.Pt_ARG_WIDTH, width, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+ if (control != null && !control.isDisposed ()) {
+ 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
new file mode 100755
index 0000000000..13657ad4b0
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java
@@ -0,0 +1,115 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+
+public /*final*/ class Tracker extends Widget {
+ Composite parent;
+ Display display;
+ boolean tracking, stippled;
+ Rectangle [] rectangles = new Rectangle [0];
+
+public Tracker (Display display, int style) {
+ if (display == null) display = Display.getCurrent ();
+ if (display == null) display = Display.getDefault ();
+ if (!display.isValidThread ()) {
+ error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ }
+ this.style = style;
+ this.display = display;
+}
+
+public Tracker (Composite parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ this.display = parent.getDisplay ();
+}
+public void addControlListener(ControlListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Move,typedListener);
+}
+public void close () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ tracking = false;
+}
+public Display getDisplay () {
+ return display;
+}
+
+public Rectangle [] getRectangles () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return rectangles;
+}
+public boolean getStippled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return stippled;
+}
+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 [] args = {
+ OS.Pt_ARG_WIDTH, 200 /*width*/, 0,
+ OS.Pt_ARG_HEIGHT, 200 /*height*/, 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.PtSetParentWidget (0);
+ int handle = OS.PtCreateWidget (OS.PtRegion (), 0, args.length / 3, args);
+ OS.PtRealizeWidget (handle);
+ 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);
+ }
+ 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;
+}
+public void removeControlListener (ControlListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Move, listener);
+}
+public void setRectangles (Rectangle [] rectangles) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (rectangles == null) error (SWT.ERROR_NULL_ARGUMENT);
+ this.rectangles = rectangles;
+}
+public void setStippled (boolean stippled) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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
new file mode 100755
index 0000000000..463f425b91
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tree.java
@@ -0,0 +1,1469 @@
+package org.eclipse.swt.widgets;
+
+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.
+ */
+public /*final*/ class Tree extends SelectableItemWidget {
+ // These constants are used internally for item hit test on mouse click
+ private static final int ActionNone = 0; // The mouse event was not handled
+ private static final int ActionExpandCollapse = 1; // Do an expand/collapse
+ private static final int ActionSelect = 2; // Select the item
+ private static final int ActionCheck = 3; // Toggle checked state of the item
+ private static ImageData CollapsedImageData; // collapsed sub tree image data. used to create an image at run time
+ private static ImageData ExpandedImageData; // expanded sub tree image data. used to create an image at run time
+ static {
+ initializeImageData();
+ }
+
+ private TreeRoots root;
+ private TreeItem expandingItem;
+
+ private Image collapsedImage;
+ private Image expandedImage;
+
+ // The following fields are needed for painting tree items
+ final Color CONNECTOR_LINE_COLOR; // Color constant used during painting. Can't keep this in TreeItem
+ // because we only need one instance per tree widget/display and can't
+ // have it static. Initialized in c'tor and freed in dispose();
+ Rectangle hierarchyIndicatorRect = null; // bounding rectangle of the hierarchy indication image (plus/minus)
+
+/**
+ * Create a new instance of the receiver with 'parent'
+ * as its parent widget.
+ */
+public Tree(Composite parent, int style) {
+ super(parent, checkStyle (style));
+ CONNECTOR_LINE_COLOR = new Color(getDisplay(), 170, 170, 170); // Light gray;
+}
+/**
+ * Add 'item' to the list of root items.
+ * @param 'item' - the tree item that should be added as a root.
+ * @param index - position that 'item' will be inserted at
+ * in the receiver.
+ */
+void addItem(TreeItem item, int index) {
+ if (index < 0 || index > getItemCount()) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+ getRoot().add(item, index);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+*/
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TypedListener typedListener;
+
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ typedListener = new TypedListener(listener);
+ addListener(SWT.Selection, typedListener);
+ addListener(SWT.DefaultSelection, typedListener);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+*/
+public void addTreeListener(TreeListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TypedListener typedListener;
+
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ typedListener = new TypedListener(listener);
+ addListener(SWT.Expand, typedListener);
+ addListener(SWT.Collapse, typedListener);
+}
+/**
+ * The SelectableItem 'item' has been added to the tree.
+ * Prevent screen updates when 'item' is inserted due to an
+ * expand operation.
+ * @param item - item that has been added to the receiver.
+ */
+void addedItem(SelectableItem item, int index) {
+ super.addedItem(item, index);
+ redrawAfterModify(item, index); // redraw plus/minus image, hierarchy lines
+}
+/**
+ * Answer the y position of both the first child of 'item' and
+ * the item following the last child of 'item'.
+ * Used to scroll items on expand/collapse.
+ * @param item - TreeItem to use for calculating the y boundary
+ * of child items.
+ * @return Array - first element is the position of the first
+ * child of 'item'. Second element is the position of the item
+ * following the last child of 'item'.
+ * Both elements are -1 if 'item' is not a child of the receiver.
+ */
+int[] calculateChildrenYPos(TreeItem item) {
+ int itemIndex = item.getVisibleIndex();
+ int itemCount = item.getVisibleItemCount();
+ int itemHeight = getItemHeight();
+ int yPos;
+ int[] yPosition = new int[] {-1, -1};
+
+ if (itemIndex != -1) {
+ itemIndex -= getTopIndex();
+ yPos = (itemIndex + itemCount + 1) * itemHeight; // y position of the item following
+ // the last child of 'item'
+ yPosition = new int[] {yPos - (itemCount * itemHeight), yPos};
+ }
+ return yPosition;
+}
+/**
+ * Calculate the widest of the children of 'item'.
+ * Items that are off screen and that may be scrolled into view are
+ * included in the calculation.
+ * @param item - the tree item that was expanded
+ */
+void calculateWidestExpandingItem(TreeItem item) {
+ int itemIndex = item.getVisibleIndex();
+ int newMaximumItemWidth = getContentWidth();
+ int stopIndex = itemIndex + item.getVisibleItemCount();
+
+ for (int i = itemIndex + 1; i <= stopIndex; i++) {
+ newMaximumItemWidth = Math.max(newMaximumItemWidth, getContentWidth(i));
+ }
+ setContentWidth(newMaximumItemWidth);
+}
+/**
+ * Calculate the width of new items as they are scrolled into view.
+ * Precondition:
+ * topIndex has already been set to the new index.
+ * @param topIndexDifference - difference between old and new top
+ * index.
+ */
+void calculateWidestScrolledItem(int topIndexDifference) {
+ int visibleItemCount = getItemCountTruncated(getClientArea());
+ int newMaximumItemWidth = getContentWidth();
+ int topIndex = getTopIndex();
+ int stopIndex = topIndex;
+
+ if (topIndexDifference < 0) { // scrolled up?
+ if (Math.abs(topIndexDifference) > visibleItemCount) { // scrolled down more than one page (via quick thumb dragging)?
+ topIndexDifference = visibleItemCount * -1;
+ }
+ for (int i = stopIndex - topIndexDifference; i >= stopIndex; i--) { // check item width from old top index up to new one
+ newMaximumItemWidth = Math.max(newMaximumItemWidth, getContentWidth(i));
+ }
+ }
+ else
+ if (topIndexDifference > 0) { // scrolled down?
+ if (topIndexDifference > visibleItemCount) { // scrolled down more than one page (via quick thumb dragging)?
+ topIndexDifference = visibleItemCount;
+ }
+ stopIndex += visibleItemCount;
+ for (int i = stopIndex - topIndexDifference; i < stopIndex; i++) {
+ newMaximumItemWidth = Math.max(newMaximumItemWidth, getContentWidth(i));
+ }
+ }
+ setContentWidth(newMaximumItemWidth);
+}
+/**
+ * Calculate the maximum item width of all displayed items.
+ */
+void calculateWidestShowingItem() {
+ TreeItem visibleItem;
+ int newMaximumItemWidth = 0;
+ int bottomIndex = getBottomIndex();
+ int paintStopX;
+
+ // add one to the loop end index because otherwise an item covered
+ // by the horizontal scroll bar would not be taken into acount and
+ // may become visible after this calculation. We're in trouble if
+ // that item is wider than the client area.
+ if (getHorizontalBar().getVisible() == true) {
+ bottomIndex++;
+ }
+ for (int i = getTopIndex(); i < bottomIndex; i++) {
+ visibleItem = getRoot().getVisibleItem(i);
+ if (visibleItem != null) {
+ paintStopX = visibleItem.getPaintStopX();
+ newMaximumItemWidth = Math.max(newMaximumItemWidth, paintStopX);
+ }
+ }
+ setContentWidth(newMaximumItemWidth);
+}
+static int checkStyle (int style) {
+ return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
+}
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+/**
+ * Collapse the tree item identified by 'item' if it is not
+ * already collapsed. Move the selection to the parent item
+ * if one of the collapsed items is currently selected.
+ * @param item - item that should be collapsed.
+ * @param notifyListeners -
+ * true=a Collapse event is sent
+ * false=no event is sent
+ */
+void collapse(TreeItem item, boolean notifyListeners) {
+ Event event;
+ int itemIndex;
+
+ if (item.getExpanded() == false) {
+ return;
+ }
+ collapseNoRedraw(item);
+ itemIndex = item.getVisibleIndex();
+ if (itemIndex != -1) { // if the item's parent is not collapsed (and the item is thus visible) do the screen updates
+ item.redrawExpanded(itemIndex - getTopIndex());
+ showSelectableItem(item);
+ calculateVerticalScrollbar();
+ calculateWidestShowingItem();
+ claimRightFreeSpace();
+ claimBottomFreeSpace();
+ }
+ if (notifyListeners == true) {
+ event = new Event();
+ event.item = item;
+ notifyListeners(SWT.Collapse, event);
+ }
+}
+
+/**
+ * Collapse the tree item identified by 'item' if it is not
+ * already collapsed. Move the selection to the parent item
+ * if one of the collapsed items is currently selected.
+ * This method is used to hide the children if an item is deleted.
+ * certain redraw and scroll operations are not needed for this
+ * case.
+ * @param item - item that should be collapsed.
+ */
+void collapseNoRedraw(TreeItem item) {
+ int itemIndex;
+
+ if (item.getExpanded() == false) {
+ return;
+ }
+ if (isSelectedItemCollapsing(item) == true) {
+ deselectAllExcept(item);
+ selectNotify(item);
+ update(); // call update to make sure that new selection is
+ // drawn before items are collapsed (looks better)
+ }
+ scrollForCollapse(item);
+ item.internalSetExpanded(false);
+}
+
+/**
+ * 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);
+ Point size = super.computeSize(wHint, hHint, changed);
+ GC gc;
+ final int WidthCalculationCount = 50; // calculate item width for the first couple of items only
+ TreeRoots root = getRoot();
+ TreeItem item;
+ Image itemImage;
+ String itemText;
+ int width;
+ int newItemWidth = 0;
+
+ if (getContentWidth() == 0 && getItemCount() > 0) {
+ gc = new GC(this);
+ for (int i = 0; i < WidthCalculationCount; i++) {
+ item = root.getVisibleItem(i);
+ if (item == null) {
+ break; // no more items
+ }
+ itemImage = item.getImage();
+ itemText = item.getText();
+ width = 0;
+ if (itemImage != null) {
+ width += itemImage.getBounds().width;
+ }
+ if (itemText != null) {
+ width += gc.stringExtent(itemText).x;
+ }
+ newItemWidth = Math.max(newItemWidth, width);
+ }
+ if (newItemWidth > 0) {
+ size.x = newItemWidth;
+ }
+ gc.dispose();
+ }
+ return size;
+}
+/**
+ * Deselect all items of the receiver.
+ */
+public void deselectAll() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ getRoot().deselectAll();
+ getSelectionVector().removeAllElements();
+ redraw();
+}
+/**
+ * Modifier Key Action
+ * None Collapse the selected item if expanded. Select
+ * parent item if selected item is already
+ * collapsed and if it's not the root item.
+ * Ctrl super.doArrowLeft(int);
+ * Shift see None above
+ * @param keyMask - the modifier key that was pressed
+ */
+void doArrowLeft(int keyMask) {
+ TreeItem focusItem = (TreeItem) getLastFocus();
+ TreeItem parentItem;
+
+ if (focusItem == null) {
+ return;
+ }
+ if (keyMask == SWT.CTRL) {
+ super.doArrowLeft(keyMask);
+ }
+ else
+ if (focusItem.getExpanded() == true) { // collapse if expanded
+ collapse(focusItem, true);
+ }
+ else
+ if (focusItem.isRoot() == false) { // go to the parent if there is one
+ parentItem = focusItem.getParentItem();
+ deselectAllExcept(parentItem);
+ selectNotify(parentItem);
+ }
+}
+/**
+ * Modifier Key Action
+ * None Expand selected item if collapsed. Select
+ * first child item if selected item is
+ * already expanded and there is a child item.
+ * Ctrl super.doArrowRight(keyMask);
+ * Shift see None above
+ * @param keyMask - the modifier key that was pressed
+ */
+void doArrowRight(int keyMask) {
+ TreeItem focusItem = (TreeItem) getLastFocus();
+ TreeItem childItem;
+
+ if (focusItem == null) {
+ return;
+ }
+ if (keyMask == SWT.CTRL) {
+ super.doArrowRight(keyMask);
+ }
+ else
+ if (focusItem.isLeaf() == false) {
+ if (focusItem.getExpanded() == false) { // expand if collapsed
+ expand(focusItem, true);
+ }
+ else { // go to the first child if there is one
+ childItem = focusItem.getItems()[0];
+ deselectAllExcept(childItem);
+ selectNotify(childItem);
+ }
+ }
+}
+/**
+ * Expand the selected item and all of its children.
+ */
+void doAsterix() {
+ expandAll((TreeItem) getLastFocus());
+}
+/**
+ * Free resources.
+ */
+void doDispose() {
+ super.doDispose();
+ if (collapsedImage != null) {
+ collapsedImage.dispose();
+ }
+ if (expandedImage != null) {
+ expandedImage.dispose();
+ }
+ getRoot().dispose();
+ CONNECTOR_LINE_COLOR.dispose();
+ resetHierarchyIndicatorRect();
+}
+/**
+ * Collapse the selected item if it is expanded.
+ */
+void doMinus() {
+ TreeItem selectedItem = (TreeItem) getLastFocus();
+
+ if (selectedItem != null) {
+ collapse(selectedItem, true);
+ }
+}
+/**
+ * Expand the selected item if it is collapsed and if it
+ * has children.
+ */
+void doPlus() {
+ TreeItem selectedItem = (TreeItem) getLastFocus();
+
+ if (selectedItem != null && selectedItem.isLeaf() == false) {
+ expand(selectedItem, true);
+ }
+}
+/**
+ * Expand the tree item identified by 'item' if it is not already
+ * expanded. Scroll the expanded items into view.
+ * @param item - item that should be expanded
+ * @param notifyListeners -
+ * true=an Expand event is sent
+ * false=no event is sent
+ */
+void expand(TreeItem item, boolean notifyListeners) {
+ Event event = new Event();
+ int indexFromTop;
+ boolean nestedExpand = expandingItem != null;
+
+ if (item.getExpanded() == true) {
+ return;
+ }
+ if (nestedExpand == false) {
+ setExpandingItem(item);
+ }
+ scrollForExpand(item);
+ item.internalSetExpanded(true);
+ if (notifyListeners == true) {
+ event.item = item;
+ notifyListeners(SWT.Expand, event);
+ }
+ // redraw hierarchy image
+ item.redrawExpanded(item.getVisibleIndex() - getTopIndex());
+ calculateVerticalScrollbar();
+ if (nestedExpand == false && isVisible() == true) {
+ // Save the index here because showSelectableItem may change it
+ indexFromTop = item.getVisibleIndex() - getTopIndex();
+ showSelectableItem(item); // make expanded item visible. Could be invisible if the expand was caused by a key press.
+ calculateWidestExpandingItem(item);
+ scrollExpandedItemsIntoView(item);
+ }
+ if (nestedExpand == false) {
+ setExpandingItem(null);
+ }
+}
+/**
+ * Expand 'item' and all its children.
+ */
+void expandAll(TreeItem item) {
+ TreeItem items[];
+
+ if (item != null && item.isLeaf() == false) {
+ expand(item, true);
+ update();
+ items = item.getItems();
+ for (int i = 0; i < items.length; i++) {
+ expandAll(items[i]);
+ }
+ }
+}
+/**
+ * Answer the image that is used as a hierarchy indicator
+ * for a collapsed hierarchy.
+ */
+Image getCollapsedImage() {
+ if (collapsedImage == null) {
+ collapsedImage = new Image(getDisplay(), CollapsedImageData);
+ }
+ return collapsedImage;
+}
+/**
+ * Answer the width of the item identified by 'itemIndex'.
+ */
+int getContentWidth(int itemIndex) {
+ TreeItem item = getRoot().getVisibleItem(itemIndex);
+ int paintStopX = 0;
+
+ if (item != null) {
+ paintStopX = item.getPaintStopX();
+ }
+ return paintStopX;
+}
+/**
+ * Answer the image that is used as a hierarchy indicator
+ * for an expanded hierarchy.
+ */
+Image getExpandedImage() {
+ if (expandedImage == null) {
+ expandedImage = new Image(getDisplay(), ExpandedImageData);
+ }
+ return expandedImage;
+}
+/**
+ * Answer the rectangle enclosing the hierarchy indicator of a tree item.
+ *
+ * Note:
+ * Assumes that the hierarchy indicators for expanded and
+ * collapsed state are the same size.
+ * @return
+ * The rectangle enclosing the hierarchy indicator.
+ */
+Rectangle getHierarchyIndicatorRect() {
+ int itemHeight = getItemHeight();
+ Image hierarchyImage;
+ Rectangle imageBounds;
+
+ if (hierarchyIndicatorRect == null && itemHeight != -1) {
+ hierarchyImage = getCollapsedImage();
+ if (hierarchyImage != null) {
+ imageBounds = hierarchyImage.getBounds();
+ }
+ else {
+ imageBounds = new Rectangle(0, 0, 0, 0);
+ }
+ hierarchyIndicatorRect = new Rectangle(
+ 0,
+ (itemHeight - imageBounds.height) / 2 + (itemHeight - imageBounds.height) % 2,
+ imageBounds.width,
+ imageBounds.height);
+ }
+ return hierarchyIndicatorRect;
+}
+/**
+ * Answer the index of 'item' in the receiver.
+ */
+int getIndex(SelectableItem item) {
+ int index = -1;
+
+ if (item != null) {
+ index = ((TreeItem) item).getGlobalIndex();
+ }
+ return index;
+}
+/**
+ * Answer the number of root items.
+ */
+public int getItemCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ 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.
+ */
+public int getItemHeight() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getItemHeight();
+}
+/**
+ * Answer the root items of the receiver as an Array.
+ */
+public TreeItem [] getItems() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TreeItem childrenArray[] = new TreeItem[getItemCount()];
+
+ getRoot().getChildren().copyInto(childrenArray);
+ return childrenArray;
+}
+/**
+ * Answer the number of sub items of 'item' that do not fit in the
+ * tree client area.
+ */
+int getOffScreenItemCount(TreeItem item) {
+ int itemIndexFromTop = item.getVisibleIndex() - getTopIndex();
+ int spaceRemaining = getItemCountWhole()-(itemIndexFromTop+1);
+ int expandedItemCount = item.getVisibleItemCount();
+
+ return expandedItemCount - spaceRemaining;
+}
+/**
+ * Answer the parent item of the receiver.
+ * This is null because the Tree widget does not have a parent item.
+ */
+public TreeItem getParentItem() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return null;
+}
+/**
+ * Answer the object that holds the root items of the receiver.
+ */
+TreeRoots getRoot() {
+ return root;
+}
+/**
+ * Answer the selected tree items.
+ * @return an Array of DrawnTreeItems containing the selected items.
+ * An empty Array if no items are selected.
+ */
+public TreeItem [] getSelection() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector selectionVector = getSelectionVector();
+ TreeItem[] selectionArray = new TreeItem[selectionVector.size()];
+
+ selectionVector.copyInto(selectionArray);
+ sort(selectionArray, 0, selectionArray.length);
+ return selectionArray;
+}
+/**
+ * Answer the index of 'item' in the receiver.
+ * Answer -1 if the item is not visible.
+ * The returned index must refer to a visible item.
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. It only means that the item
+ * would be displayed if it is located inside the receiver's
+ * client area.
+ * Collapsed items are not visible.
+ */
+int getVisibleIndex(SelectableItem item) {
+ int index = -1;
+
+ if (item != null) {
+ index = ((AbstractTreeItem) item).getVisibleIndex();
+ }
+ return index;
+}
+/**
+ * Answer the SelectableItem located at 'itemIndex'
+ * in the receiver.
+ * @param itemIndex - location of the SelectableItem
+ * object to return
+ */
+SelectableItem getVisibleItem(int itemIndex) {
+ return getRoot().getVisibleItem(itemIndex);
+}
+/**
+ * Answer the number of visible items of the receiver.
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. It only means that the item
+ * would be displayed if it is located inside the receiver's
+ * client area.
+ * Collapsed items are not visible.
+ */
+int getVisibleItemCount() {
+ return getRoot().getVisibleItemCount();
+}
+/**
+ * Answer the y coordinate at which 'item' is drawn.
+ * @param item - SelectableItem for which the paint position
+ * should be returned
+ * @return the y coordinate at which 'item' is drawn.
+ * Return -1 if 'item' is null or outside the client area
+ */
+int getVisibleRedrawY(SelectableItem item) {
+ int redrawY = getRedrawY(item);
+
+ if (redrawY < 0 || redrawY > getClientArea().height) {
+ redrawY = -1;
+ }
+ return redrawY;
+}
+/**
+ * Handle the events the receiver is listening to.
+ */
+void handleEvents(Event event) {
+ switch (event.type) {
+ case SWT.Paint:
+ paint(event);
+ break;
+ case SWT.MouseDown:
+ mouseDown(event);
+ break;
+ case SWT.MouseDoubleClick:
+ mouseDoubleClick(event);
+ break;
+ default:
+ super.handleEvents(event);
+ }
+}
+/**
+ * Initialize the receiver.
+ */
+void initialize() {
+ resetRoot(); // has to be at very top because super class uses
+ // functionality that relies on the TreeRoots object
+ super.initialize();
+}
+/**
+ * Initialize the ImageData used for the expanded/collapsed images.
+ */
+static void initializeImageData() {
+ PaletteData fourBit = new PaletteData(
+ new RGB[] {new RGB(0, 0, 0), new RGB (128, 0, 0), new RGB (0, 128, 0), new RGB (128, 128, 0), new RGB (0, 0, 128), new RGB (128, 0, 128), new RGB (0, 128, 128), new RGB (128, 128, 128), new RGB (192, 192, 192), new RGB (255, 0, 0), new RGB (0, 255, 0), new RGB (255, 255, 0), new RGB (0, 0, 255), new RGB (255, 0, 255), new RGB (0, 255, 255), new RGB (255, 255, 255)});
+
+ CollapsedImageData = new ImageData(
+ 9, 9, 4, // width, height, depth
+ fourBit, 4,
+ new byte[] {119, 119, 119, 119, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, 15, -1, 112, 0, 0, 0, 127, -1, 15, -1, 112, 0, 0, 0, 127, 0, 0, 15, 112, 0, 0, 0, 127, -1, 15, -1, 112, 0, 0, 0, 127, -1, 15, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 119, 119, 119, 119, 112, 0, 0, 0});
+ CollapsedImageData.transparentPixel = 15; // use white for transparency
+ ExpandedImageData = new ImageData(
+ 9, 9, 4, // width, height, depth
+ fourBit, 4,
+ new byte[] {119, 119, 119, 119, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, 0, 0, 15, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 119, 119, 119, 119, 112, 0, 0, 0});
+ ExpandedImageData.transparentPixel = 15; // use white for transparency
+}
+/**
+ * Set event listeners for the receiver.
+ */
+void installListeners() {
+ Listener listener = getListener();
+
+ super.installListeners();
+ addListener(SWT.Paint, listener);
+ addListener(SWT.MouseDown, listener);
+ addListener(SWT.MouseDoubleClick, listener);
+}
+/**
+ * Answer whether the receiver is currently expanding a sub tree
+ * with 'item' in it.
+ * Used for performance optimizations.
+ */
+boolean isExpandingItem(SelectableItem item) {
+ TreeItem parentItem;
+
+ if (expandingItem == null || item == null || (item instanceof TreeItem) == false) {
+ return false;
+ }
+ parentItem = ((TreeItem) item).getParentItem();
+ return (parentItem == expandingItem || isExpandingItem(parentItem));
+}
+/**
+ * Answer whether the children of 'collapsingItem' contain
+ * at least one selected item.
+ */
+boolean isSelectedItemCollapsing(TreeItem collapsingItem) {
+ Enumeration selection = getSelectionVector().elements();
+ TreeItem item;
+ int selectedItemIndex;
+ int collapsingItemIndex = collapsingItem.getVisibleIndex();
+ int lastCollapsedItemIndex = collapsingItemIndex + collapsingItem.getVisibleItemCount();
+
+ if (collapsingItemIndex == -1) { // is the collapsing item in a collapsed subtree?
+ return false; // then neither it nor its children are selected
+ }
+ while (selection.hasMoreElements() == true) {
+ item = (TreeItem) selection.nextElement();
+ selectedItemIndex = item.getVisibleIndex();
+ if ((selectedItemIndex > collapsingItemIndex) &&
+ (selectedItemIndex <= lastCollapsedItemIndex)) {
+ return true;
+ }
+ }
+ return false;
+}
+/**
+ * Test whether the mouse click specified by 'event' was a
+ * valid selection or expand/collapse click.
+ * @return
+ * One of ActionExpandCollapse, ActionSelect, ActionNone, ActionCheck
+ * specifying the action to be taken on the click.
+ */
+int itemAction(TreeItem item, int x, int y) {
+ int action = ActionNone;
+ int itemHeight = getItemHeight();
+ int offsetX;
+ int offsetY;
+ Point offsetPoint;
+
+ if (item != null) {
+ offsetX = x - item.getPaintStartX();
+ offsetY = y - itemHeight * (y / itemHeight);
+ offsetPoint = new Point(offsetX, offsetY);
+ if ((item.isLeaf() == false) &&
+ (getHierarchyIndicatorRect().contains(offsetPoint) == true)) {
+ action |= ActionExpandCollapse;
+ }
+ else
+ if (item.isSelectionHit(offsetPoint) == true) {
+ action |= ActionSelect;
+ }
+ else
+ if (item.isCheckHit(new Point(x, y)) == true) {
+ action |= ActionCheck;
+ }
+ }
+ return action;
+}
+/**
+ * The table item 'changedItem' has changed. Redraw the whole
+ * item in that column. Include the text in the redraw because
+ * an image set to null requires a redraw of the whole item anyway.
+ */
+void itemChanged(SelectableItem changedItem, int repaintStartX, int repaintWidth) {
+ int oldItemHeight = getItemHeight();
+ Point oldImageExtent = getImageExtent();
+
+ if (isExpandingItem(changedItem) == false) {
+ super.itemChanged(changedItem, repaintStartX, repaintWidth);
+ }
+ else {
+ calculateItemHeight(changedItem);
+ }
+ if ((oldItemHeight != getItemHeight()) || // only reset items if the item height or
+ (oldImageExtent != getImageExtent())) { // image size has changed. The latter will only change once,
+ // from null to a value-so it's safe to test using !=
+ getRoot().reset(); // reset cached data of all items in the receiver
+ resetHierarchyIndicatorRect();
+ redraw(); // redraw all items if the image extent has changed. Fixes 1FRIHPZ
+ }
+ else {
+ ((AbstractTreeItem) changedItem).reset(); // reset the item that has changed when the tree item
+ // height has not changed (otherwise the item caches old data)
+ // Fixes 1FF6B42
+ }
+ if (repaintWidth != 0) {
+ calculateWidestShowingItem();
+ claimRightFreeSpace(); // otherwise scroll bar may be reset, but not horizontal offset
+ // Fixes 1G4SBJ3
+ }
+}
+/**
+ * A key was pressed.
+ * Call the appropriate key handler method.
+ * @param event - the key event
+ */
+void keyDown(Event event) {
+ super.keyDown(event);
+ switch (event.character) {
+ case '+':
+ doPlus();
+ break;
+ case '-':
+ doMinus();
+ break;
+ case '*':
+ doAsterix();
+ break;
+ }
+}
+
+/**
+ * A mouse double clicked occurred over the receiver.
+ * Expand/collapse the clicked item. Do nothing if no item was clicked.
+ */
+void mouseDoubleClick(Event event) {
+ int hitItemIndex = event.y / getItemHeight();
+ TreeItem hitItem = getRoot().getVisibleItem(hitItemIndex + getTopIndex());
+ Event newEvent;
+
+ if (hitItem == null) {
+ 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) {
+ if (hitItem.getExpanded() == true) {
+ collapse(hitItem, true);
+ }
+ else {
+ expand(hitItem, true);
+ }
+ }
+}
+/**
+ * The mouse pointer was pressed down on the receiver.
+ * Handle the event according to the position of the mouse click.
+ */
+void mouseDown(Event event) {
+ int hitItemIndex;
+ TreeItem hitItem;
+ SelectableItem selectionItem = getLastSelection();
+ int itemAction;
+
+ if (event.button != 1) { // only react to button one clicks.
+ return;
+ }
+ hitItemIndex = event.y / getItemHeight();
+ hitItem = getRoot().getVisibleItem(hitItemIndex + getTopIndex());
+ if (hitItem == null) {
+ return;
+ }
+ switch (itemAction = itemAction(hitItem, event.x, event.y)) {
+ case ActionExpandCollapse:
+ if (hitItem.getExpanded() == true) {
+ collapse(hitItem, true);
+ }
+ else {
+ expand(hitItem, true);
+ }
+ break;
+ case ActionSelect:
+ doMouseSelect(hitItem, hitItemIndex + getTopIndex(), event.stateMask, event.button);
+ break;
+ case ActionCheck:
+ doCheckItem(hitItem);
+ break;
+ }
+ if (itemAction != ActionSelect && selectionItem == null) {
+ selectionItem = getRoot().getVisibleItem(getTopIndex()); // select the top item if no item was selected before
+ selectNotify(selectionItem);
+ }
+}
+/**
+ * A paint event has occurred. Display the invalidated items.
+ * @param event - expose event specifying the invalidated area.
+ */
+void paint(Event event) {
+ int visibleRange[] = getIndexRange(event.getBounds());
+
+ paintItems(event.gc, visibleRange[0], visibleRange[1] + 1); // + 1 to paint the vertical line
+ // connection the last item we really
+ // want to paint with the item after that.
+}
+/**
+ * Paint tree items on 'gc' starting at index 'topPaintIndex' and
+ * stopping at 'bottomPaintIndex'.
+ * @param gc - GC to draw tree items on.
+ * @param topPaintIndex - index of the first item to draw
+ * @param bottomPaintIndex - index of the last item to draw
+ */
+void paintItems(GC gc, int topPaintIndex, int bottomPaintIndex) {
+ TreeItem visibleItem;
+ int itemHeight = getItemHeight();
+
+ for (int i = topPaintIndex; i <= bottomPaintIndex; i++) {
+ visibleItem = getRoot().getVisibleItem(i + getTopIndex());
+ if (visibleItem != null) {
+ visibleItem.paint(gc, i * itemHeight);
+ }
+ }
+}
+/**
+ * 'item' has been added to or removed from the receiver.
+ * Repaint part of the tree to update the vertical hierarchy
+ * connectors and hierarchy image.
+ * @param modifiedItem - the added/removed item
+ * @param modifiedIndex - index of the added/removed item
+ */
+void redrawAfterModify(SelectableItem modifiedItem, int modifiedIndex) {
+ int redrawStartY;
+ int redrawStopY;
+ int itemChildIndex = ((TreeItem) modifiedItem).getIndex();
+ int topIndex = getTopIndex();
+ int itemHeight = getItemHeight();
+ int redrawItemIndex;
+ int itemCount;
+ AbstractTreeItem parentItem = ((TreeItem) modifiedItem).getParentItem();
+ AbstractTreeItem redrawItem = null;
+
+ if (redrawParentItem(modifiedItem) == false) {
+ return;
+ }
+ if (parentItem == null) { // a root item is added/removed
+ parentItem = getRoot();
+ }
+ itemCount = parentItem.getItemCount();
+ // redraw hierarchy decorations of preceeding item if the last item at a tree
+ // level was added/removed
+ // otherwise, if the first item was removed, redraw the parent to update hierarchy icon
+ if (itemChildIndex > 0) { // more than one item left at this tree level
+ // added/removed last item at this tree level? have to test >=.
+ // when removing last item, item index is outside itemCount
+ if (itemChildIndex >= itemCount - 1) {
+ redrawItem = (AbstractTreeItem) parentItem.getChildren().elementAt(itemChildIndex - 1);
+ }
+ }
+ else
+ if (getVisibleItemCount() > 0 && itemCount < 2) { // last item at this level removed/first item added?
+ redrawItem = parentItem; // redraw parent item to update hierarchy icon
+ }
+ if (redrawItem != null) {
+ redrawItemIndex = redrawItem.getVisibleIndex();
+ if (modifiedIndex == -1) {
+ modifiedIndex = redrawItemIndex + 1;
+ }
+ redrawStartY = (redrawItemIndex - topIndex) * itemHeight;
+ redrawStopY = (modifiedIndex - topIndex) * itemHeight;
+ redraw(
+ 0,
+ redrawStartY,
+ redrawItem.getCheckboxXPosition(), // only redraw up to and including hierarchy icon to avoid flashing
+ redrawStopY - redrawStartY, false);
+ }
+ if (modifiedIndex == 0) { // added/removed first item ?
+ redraw(0, 0, getClientArea().width, getItemHeight() * 2, false);// redraw new first two items to
+ // fix vertical hierarchy line
+ }
+}
+
+/**
+ * Determine if part of the tree hierarchy needs to be redrawn.
+ * The hierarchy icon of the parent item of 'item' needs to be redrawn if
+ * 'item' is added as the first child or removed as the last child.
+ * Hierarchy lines need to be redrawn if 'item' is the last in a series of
+ * children.
+ * @param item - tree item that is added or removed.
+ * @return true=tree hierarchy needs to be redrawn. false=no redraw necessary
+ */
+boolean redrawParentItem(SelectableItem item) {
+ TreeItem parentItem = ((TreeItem) item).getParentItem();
+ TreeItem parentItem2;
+ boolean redraw = false;
+
+ // determine if only the hierarchy icon needs to be redrawn
+ if (parentItem != null) {
+ parentItem2 = parentItem.getParentItem();
+ if ((parentItem2 == null || parentItem2.getExpanded() == true) && parentItem.getChildren().size() < 2) {
+ redraw = true;
+ }
+ }
+ // redraw is only neccessary when the receiver is not currently
+ // expanding 'item' or a parent item or if the parent item is expanded
+ // or if the hierarchy icon of the parent item needs to be redrawn
+ if (isExpandingItem(item) == false && parentItem == null || parentItem.getExpanded() == true || redraw == true) {
+ redraw = true;
+ }
+ else {
+ redraw = false;
+ }
+ return redraw;
+}
+
+/**
+ * Remove all items of the receiver.
+ */
+public void removeAll() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ setRedraw(false);
+ getRoot().dispose();
+ resetRoot();
+ reset();
+ calculateWidestShowingItem();
+ calculateVerticalScrollbar();
+ setRedraw(true);
+}
+/**
+ * Remove 'item' from the receiver.
+ * @param item - tree item that should be removed from the
+ * receiver-must be a root item.
+ */
+void removeItem(TreeItem item) {
+ getRoot().removeItem(item);
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+*/
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ removeListener (SWT.Selection, listener);
+ removeListener (SWT.DefaultSelection, listener);
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+*/
+public void removeTreeListener(TreeListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ removeListener (SWT.Expand, listener);
+ removeListener (SWT.Collapse, listener);
+}
+/**
+ * 'item' has been removed from the receiver.
+ * Recalculate the content width.
+ */
+void removedItem(SelectableItem item) {
+ if (isExpandingItem(item) == false) {
+ super.removedItem(item);
+ }
+ calculateWidestShowingItem();
+ claimRightFreeSpace();
+}
+/**
+ * Notification that 'item' is about to be removed from the tree.
+ * Update the item selection if neccessary.
+ * @param item - item that is about to be removed from the tree.
+ */
+void removingItem(SelectableItem item) {
+ Vector selection = getSelectionVector();
+ TreeItem parentItem = ((TreeItem) item).getParentItem();
+ TreeItem newSelectionItem = null;
+ boolean isLastSelected = (selection.size() == 1) && (selection.elementAt(0) == item);
+ int itemIndex = getVisibleIndex(item);
+
+ if (isLastSelected == true) {
+ // try selecting the following item
+ newSelectionItem = (TreeItem) getVisibleItem(itemIndex + 1);
+ if (newSelectionItem == null || newSelectionItem.getParentItem() != parentItem) {
+ // select parent item if there is no item following the removed
+ // one on the same tree level
+ newSelectionItem = parentItem;
+ }
+ if (newSelectionItem != null) {
+ selectNotify(newSelectionItem);
+ }
+ }
+ super.removingItem(item);
+ if (isExpandingItem(item) == false) {
+ // redraw plus/minus image, hierarchy lines,
+ // redrawing here assumes that no update happens between now and
+ // after the item has actually been removed. Otherwise this call
+ // would need to be in removedItem and we would need to store the
+ // "itemIndex" here to redraw correctly.
+ redrawAfterModify(item, itemIndex);
+ }
+}
+/**
+ * Reset the rectangle enclosing the hierarchy indicator to null.
+ * Forces a recalculation next time getHierarchyIndicatorRect is called.
+ */
+void resetHierarchyIndicatorRect() {
+ hierarchyIndicatorRect = null;
+}
+/**
+ * Reset state that is dependent on or calculated from the items
+ * of the receiver.
+ */
+void resetItemData() {
+ setContentWidth(0);
+ resetHierarchyIndicatorRect();
+ super.resetItemData();
+}
+/**
+ * Reset the object holding the root items of the receiver.
+ */
+void resetRoot() {
+ root = new TreeRoots(this);
+}
+/**
+ * The receiver has been resized. Recalculate the content width.
+ */
+void resize(Event event) {
+ int oldItemCount = getVerticalBar().getPageIncrement();
+
+ super.resize(event);
+ if (getItemCountWhole() > oldItemCount) { // window resized higher?
+ calculateWidestShowingItem(); // recalculate widest item since a longer item may be visible now
+ }
+}
+/**
+ * Display as many expanded tree items as possible.
+ * Scroll the last expanded child to the bottom if all expanded
+ * children can be displayed.
+ * Otherwise scroll the expanded item to the top.
+ * @param item - the tree item that was expanded
+ */
+void scrollExpandedItemsIntoView(TreeItem item) {
+ int itemCountOffScreen = getOffScreenItemCount(item);
+ int newTopIndex = getTopIndex() + itemCountOffScreen;
+
+ if (itemCountOffScreen > 0) {
+ newTopIndex = Math.min(item.getVisibleIndex(), newTopIndex); // make sure the expanded item is never scrolled out of view
+ setTopIndex(newTopIndex, true);
+ }
+}
+/**
+ * Scroll the items following the children of 'collapsedItem'
+ * below 'collapsedItem' to cover the collapsed children.
+ * @param collapsedItem - item that has been collapsed
+ */
+void scrollForCollapse(TreeItem collapsedItem) {
+ Rectangle clientArea = getClientArea();
+ int topIndex = getTopIndex();
+ int itemCount = collapsedItem.getVisibleItemCount();
+ int scrollYPositions[] = calculateChildrenYPos(collapsedItem);
+
+ if (scrollYPositions[0] == -1 && scrollYPositions[1] == -1) {
+ return;
+ }
+ if (topIndex + getItemCountWhole() == getVisibleItemCount() && itemCount < topIndex) {
+ // scroll from top if last item is at bottom and will stay at
+ // bottom after collapse. Avoids flash caused by too much bit
+ // blitting (which force update and thus premature redraw)
+ int height = scrollYPositions[1] - scrollYPositions[0];
+ scroll(
+ 0, 0, // destination x, y
+ 0, -height, // source x, y
+ clientArea.width, scrollYPositions[0]+height, true);
+ setTopIndexNoScroll(topIndex - itemCount, true);
+ }
+ else {
+ scroll(
+ 0, scrollYPositions[0], // destination x, y
+ 0, scrollYPositions[1], // source x, y
+ clientArea.width, clientArea.height - scrollYPositions[0], true);
+ }
+}
+/**
+ * Scroll the items following 'expandedItem' down to make
+ * space for the children of 'expandedItem'.
+ * @param expandedItem - item that has been expanded.
+ */
+void scrollForExpand(TreeItem expandedItem) {
+ int scrollYPositions[];
+ Rectangle clientArea = getClientArea();
+
+ expandedItem.internalSetExpanded(true);
+ scrollYPositions = calculateChildrenYPos(expandedItem);
+ expandedItem.internalSetExpanded(false);
+ if (scrollYPositions[0] == -1 && scrollYPositions[1] == -1) {
+ return;
+ }
+ scroll(
+ 0, scrollYPositions[1], // destination x, y
+ 0, scrollYPositions[0], // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Scroll horizontally by 'numPixel' pixel.
+ * @param numPixel - the number of pixel to scroll
+ * < 0 = columns are going to be moved left.
+ * > 0 = columns are going to be moved right.
+ */
+void scrollHorizontal(int numPixel) {
+ Rectangle clientArea = getClientArea();
+
+ scroll(
+ numPixel, 0, // destination x, y
+ 0, 0, // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Scroll vertically by 'scrollIndexCount' items.
+ * @param scrollIndexCount - the number of items to scroll.
+ * scrollIndexCount > 0 = scroll up. scrollIndexCount < 0 = scroll down
+ */
+void scrollVertical(int scrollIndexCount) {
+ Rectangle clientArea = getClientArea();
+
+ scroll(
+ 0, 0, // destination x, y
+ 0, scrollIndexCount * getItemHeight(), // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * 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.
+ */
+public void selectAll() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector selection = getSelectionVector();
+
+ if (isMultiSelect() == true) {
+ selection = getRoot().selectAll(selection);
+ setSelectionVector(selection);
+ }
+}
+/**
+ * Set the item that is currently being expanded to 'item'.
+ * Used for performance optimizations.
+ */
+void setExpandingItem(TreeItem item) {
+ expandingItem = item;
+}
+/**
+ * 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);
+ Stack children = new Stack(); // traverse the tree depth first
+ Enumeration elements;
+ AbstractTreeItem item;
+
+ if (font != null && font.equals(getFont()) == true) {
+ return;
+ }
+ setRedraw(false); // disable redraw because itemChanged() triggers undesired redraw
+ resetItemData();
+ super.setFont(font);
+
+ // Call itemChanged for all tree items
+ elements = getRoot().getChildren().elements();
+ while (elements.hasMoreElements() == true) {
+ children.push(elements.nextElement());
+ }
+ while (children.empty() == false) {
+ item = (AbstractTreeItem) children.pop();
+ itemChanged(item, 0, getClientArea().width);
+ elements = item.getChildren().elements();
+ while (elements.hasMoreElements() == true) {
+ children.push(elements.nextElement());
+ }
+ }
+ setRedraw(true); // re-enable redraw
+}
+/**
+ * Display a mark indicating the point at which an item will be inserted.
+ * The drop insert item has a visual hint to show where a dragged item
+ * will be inserted when dropped on the tree.
+ * <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'.
+ */
+public void setInsertMark(TreeItem item, boolean before){
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ motif_setInsertMark(item, !before);
+}
+/**
+ * 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
+ */
+public void setSelection(TreeItem selectionItems[]) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (selectionItems == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ setSelectableSelection(selectionItems);
+}
+/**
+ * Set the index of the first visible item in the tree client area
+ * to 'index'.
+ * Scroll the new top item to the top of the tree.
+ * @param index - 0-based index of the first visible item in the
+ * tree's client area.
+ * @param adjustScrollbar -
+ * true = the vertical scroll bar is set to reflect the new top index.
+ * false = the vertical scroll bar position is not modified.
+ */
+void setTopIndex(int index, boolean adjustScrollbar) {
+ int indexDiff = index-getTopIndex();
+
+ super.setTopIndex(index, adjustScrollbar);
+ calculateWidestScrolledItem(indexDiff);
+}
+/**
+ * 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.
+ */
+public void showItem(TreeItem item) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (item == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ showSelectableItem(item);
+}
+/**
+ * Make 'item' visible by expanding its parent items and scrolling
+ * it into the receiver's client area if necessary.
+ * An SWT.Expand event is going to be sent for every parent item
+ * that is expanded to make 'item' visible.
+ * @param item - the item that should be made visible to the
+ * user.
+ */
+void showSelectableItem(SelectableItem item) {
+ if (item.getSelectableParent() != this) {
+ return;
+ }
+ if (((TreeItem) item).isVisible() == false) {
+ ((TreeItem) item).makeVisible();
+ }
+ super.showSelectableItem(item);
+}
+/**
+ * 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.
+ */
+public TreeItem getItem(Point point) {
+ int itemHeight;
+ int hitItemIndex;
+ TreeItem hitItem;
+
+ if (getClientArea().contains(point) == false) {
+ return null;
+ }
+ itemHeight = getItemHeight();
+ hitItemIndex = point.y / itemHeight;
+ hitItem = getRoot().getVisibleItem(hitItemIndex + getTopIndex());
+ if (hitItem != null) {
+ point.x -= hitItem.getPaintStartX();
+ point.y -= itemHeight * hitItemIndex;
+ if (hitItem.isSelectionHit(point) == false) {
+ hitItem = null;
+ }
+ }
+ return hitItem;
+}
+/**
+ * Answer the number of selected items in the receiver.
+ */
+public int getSelectionCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return 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.
+ */
+public void showSelection() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ super.showSelection();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeItem.java
new file mode 100755
index 0000000000..cb0aba6a89
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeItem.java
@@ -0,0 +1,1146 @@
+package org.eclipse.swt.widgets;
+
+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..
+ * A description of the cached data follows:
+ *
+ * | 1 || 5 |
+ * | 2 | | 6 |
+ * |3 7|
+ * _____ | 4 |f| |8
+ * | | ____
+ * | - | ===== {image} root 9
+ * |_____| |
+ * |b|c| |d|
+ * | e |
+ *
+ * Widths are measured between vertical lines.
+ *
+ * Cached item rendering data:
+ * 1 = getDecorationsWidth
+ * 2 = getHierarchyIndicatorRect
+ * 3 = getPaintStartX
+ * 4 = getItemConnectorWidth
+ * 5 = getItemWidth
+ * 6 = getSelectionWidth
+ * 7 = getPaintStopX
+ * 8 - getTextXPos
+ * 9 = getTextYPosition
+ *
+ * Rendering constants:
+ * 4 = DEFAULT_ITEM_CONNECTOR_WIDTH, used when no image is set in the tree.
+ * Otherwise it is the image width.
+ * b = IMAGE_PADDING
+ * c = TEXT_INDENT
+ * d = SELECTION_PADDING
+ * e = ITEM_NOIMAGE_OFFSET
+ * f = ITEM_CONNECTOR_PADDING;
+
+ */
+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
+ // line width is half the image width.
+ private static final int ITEM_CONNECTOR_PADDING = 2; // Added to the calculated item connector width
+ private static final int IMAGE_PADDING = 3; // Space behind bitmap
+ private static final int ITEM_NOIMAGE_OFFSET = 8; // Offset added to the calculated paint position where
+ // an item starts drawing. To be used when no item
+ // image has been set. Otherwise children would start
+ // drawing at the end of the horizontal item connector
+ // of their parent.
+ private static final int ROOT_INDENT = 5; // Indent of root items
+ private static final int SELECTION_PADDING = 2; // Space behind text
+ private static final int TEXT_INDENT = 2; // Identation of the item label
+
+ // basic item info
+ private TreeItem parentItem;
+ private int index; // index in the parent item
+
+ // geometrical item info
+ private int paintStartX = -1; // X coordinate of the upper-left corner of the
+ // receivers bounding rectangle
+ private Point itemExtent; // Size of the item (image + label)
+ private Point imageExtent; // original size of the item image
+ private int textYPosition = -1; // Centered y position of the item text
+/**
+ * Create a root item and add it to the tree widget identified
+ * by 'parent'.
+ * @param parent - Tree widget the receiver is added to
+ * @param swtStyle - widget style. see Widget class for details
+ */
+public TreeItem(Tree parent, int swtStyle) {
+ this(parent, swtStyle, checkNull(parent).getItemCount());
+}
+/**
+ * Create a root item and add it to the tree widget identified
+ * by 'parent'.
+ * @param parent - Tree widget the receiver is added to.
+ * @param swtStyle - widget style. see Widget class for details
+ * @param position - position in 'parentItem' the receiver will
+ * be inserted at
+ */
+public TreeItem(Tree parent, int swtStyle, int position) {
+ super(parent, swtStyle);
+ parent.addItem(this, position);
+}
+/**
+ * Create a root item with 'parentItem' as the parent item.
+ * @param parentItem - the parent item of the receiver
+ * @param swtStyle - widget style. see Widget class for details
+ */
+public TreeItem(TreeItem parentItem, int swtStyle) {
+ this(parentItem, swtStyle, checkNull(parentItem).getItemCount());
+}
+/**
+ * Create a root item with 'parentItem' as the parent item.
+ * @param parentItem - the parent item of the receiver
+ * @param swtStyle - widget style. see Widget class for details
+ * @param position - position in 'parentItem' the receiver will
+ * be inserted at
+ */
+public TreeItem(TreeItem parentItem, int swtStyle, int position) {
+ super(checkNull(parentItem).getParent(), swtStyle);
+ setParentItem(parentItem);
+ parentItem.add(this, position);
+}
+/**
+ * Calculate the number of expanded children.
+ * Recurse up in the tree to the root item.
+ */
+void calculateVisibleItemCount() {
+ Vector children;
+ TreeItem child;
+ int visibleItemCount = 0;
+
+ // check isExpanded field directly for performance
+ if (internalGetExpanded() == true) {
+ children = getChildren();
+ visibleItemCount = children.size();
+ for (int i = 0; i < children.size(); i++) {
+ child = (TreeItem) children.elementAt(i);
+ visibleItemCount += child.getVisibleItemCount();
+ }
+ }
+ setVisibleItemCount(visibleItemCount);
+ calculateVisibleItemCountParent();
+}
+/**
+ * Calculate the number of expanded children for the parent item
+ * of this item.
+ */
+void calculateVisibleItemCountParent() {
+ TreeItem parentItem = getParentItem();
+
+ if (parentItem != null) {
+ parentItem.calculateVisibleItemCount();
+ }
+ else {
+ getParent().getRoot().calculateVisibleItemCount();
+ }
+}
+/**
+ * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'tree' is null.
+ * Otherwise return 'tree'
+ */
+static Tree checkNull(Tree tree) {
+ if (tree == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return tree;
+}
+/**
+ * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'item' is null.
+ * Otherwise return 'item'
+ */
+static TreeItem checkNull(TreeItem item) {
+ if (item == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return item;
+}
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+/**
+ * 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'.
+ *
+ * Note:
+ * Assumes that the hierarchy indicators for the expanded and
+ * collapsed state are the same size.
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ * @return position to continue drawing
+ */
+Point drawHierarchyIndicator(GC gc, Point position) {
+ Tree parent = getParent();
+ Image hierarchyImage;
+ Rectangle indicatorRectangle = parent.getHierarchyIndicatorRect();
+ int x = position.x;
+ int y = position.y;
+ int yCenter = y + parent.getItemHeight() / 2;
+ Point connectorLinePosition;
+
+ if (isLeaf() == false) {
+ if (getExpanded() == true) {
+ hierarchyImage = parent.getExpandedImage();
+ }
+ else {
+ hierarchyImage = parent.getCollapsedImage();
+ }
+ if (hierarchyImage != null) {
+ gc.drawImage(hierarchyImage, x + indicatorRectangle.x, y + indicatorRectangle.y);
+ }
+ connectorLinePosition = new Point(x + indicatorRectangle.width, yCenter);
+ }
+ else {
+ connectorLinePosition = new Point(
+ x + indicatorRectangle.width / 2
+ + indicatorRectangle.width % 2, yCenter); // % 2 in order to not start the next hierarchy
+ // component at the middle of the icon but after.
+ }
+ return connectorLinePosition;
+}
+/**
+ * Draw a horizontal line connecting the item image (or label
+ * if there is no image) to the vertical line connecting to
+ * the parent.
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ * @return position to continue drawing
+ */
+Point drawHorizontalItemConnector(GC gc, Point position) {
+ int itemConnectorEndPos = position.x + getItemConnectorWidth() - 1; // -1 because the position of the last pixel needs to be calculated
+
+ gc.drawLine(position.x, position.y, itemConnectorEndPos, position.y);
+ return new Point(itemConnectorEndPos + 1, position.y); // + 1 in order to resume drawing after line not on end of line
+}
+/**
+ * Display the item image at 'position' using 'gc'.
+ * @param gc - GC to draw on
+ * @param position - position on the GC to draw at
+ * @return position to continue drawing
+ */
+Point drawImage(GC gc, Point destinationPosition) {
+ Tree parent = getParent();
+ Image image = getImage();
+ Point sourceImageExtent;
+ Point destinationImageExtent = parent.getImageExtent();
+ int yCenter;
+
+ if (image != null) {
+ sourceImageExtent = getImageExtent();
+ yCenter = (parent.getItemHeight() - destinationImageExtent.y) / 2;
+ gc.drawImage(
+ image,
+ 0, 0, // source x, y
+ sourceImageExtent.x, sourceImageExtent.y, // source width, height
+ destinationPosition.x, destinationPosition.y + yCenter, // destination x, y
+ destinationImageExtent.x, destinationImageExtent.y); // destination width, height
+ }
+ if (destinationImageExtent != null) {
+ destinationPosition.x += destinationImageExtent.x + IMAGE_PADDING;
+ }
+ return destinationPosition;
+}
+/**
+ * Draw a filled rectangle indicating the item selection state
+ * The rectangle will be filled with the selection color if the
+ * receiver is selected. Otherwise the rectangle will be filled
+ * in the background color to remove the selection.
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ */
+void drawSelection(GC gc, Point position) {
+ Tree parent = getParent();
+ Point selectionExtent = getSelectionExtent();
+
+ if (selectionExtent == null) {
+ return;
+ }
+ if (isSelected() == true) {
+ gc.setBackground(getSelectionBackgroundColor());
+ }
+ gc.fillRectangle(position.x, position.y, selectionExtent.x, selectionExtent.y);
+ if (isSelected() == true) {
+ gc.setBackground(parent.getBackground());
+ }
+}
+/**
+ * Draw a rectangle enclosing the item label. The rectangle
+ * indicates that the receiver was selected last and that it has
+ * the input focus.
+ * The rectangle will only be drawn if the receiver is selected.
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ */
+void drawSelectionFocus(GC gc, Point position) {
+ Point selectionExtent = getSelectionExtent();
+
+ if (selectionExtent == null) {
+ return;
+ }
+ if (getParent().hasFocus(this) == true) {
+ gc.drawFocus(
+ position.x, position.y,
+ selectionExtent.x, selectionExtent.y);
+ }
+}
+/**
+ * Draw the item label at 'position' using 'gc'.
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ */
+void drawText(GC gc, Point position) {
+ Tree parent = getParent();
+ String text = getText();
+
+ if (text != null) {
+ if (isSelected() == true) {
+ gc.setBackground(getSelectionBackgroundColor());
+ gc.setForeground(getSelectionForegroundColor());
+ }
+ gc.drawString(text, position.x, position.y);
+ if (isSelected() == true) {
+ gc.setBackground(parent.getBackground());
+ gc.setForeground(parent.getForeground());
+ }
+ }
+}
+/**
+ * Draw a vertical line connecting the horizontal connector line
+ * with that of the previous item.
+ * Called recursively to draw the lines on all tree levels.
+ * @param gc - GC to draw on.
+ * @param yPosition - y position of the upper side of the
+ * receiver's bounding box.
+ * @param isFirstChild - method is called to draw a vertical
+ * line for the first child. Leave room for the hierarchy icon.
+ */
+void drawVerticalItemConnector(GC gc, int yPosition, boolean isFirstChild) {
+ Tree parent = getParent();
+ TreeItem nextDrawItem = getParentItem();
+ AbstractTreeItem parentItem = nextDrawItem;
+ Rectangle indicatorRectangle = parent.getHierarchyIndicatorRect();
+ int itemHeight = parent.getItemHeight();
+ int itemHeightDiv2 = itemHeight / 2 + itemHeight % 2;
+ int indicatorHeightDiv2 = indicatorRectangle.height / 2 + indicatorRectangle.height % 2;
+ int lineX = getPaintStartX() + indicatorRectangle.width / 2;
+ int lineStartY = yPosition - itemHeightDiv2;
+ int lineEndY = yPosition + itemHeightDiv2;
+
+ if (parentItem == null) {
+ parentItem = parent.getRoot();
+ }
+ if (getIndex() != parentItem.getItemCount()-1) { // if item is not the last child
+ if (isFirstChild == true) {
+ lineStartY += indicatorHeightDiv2; // leave space for the hierarchy image
+ }
+ gc.drawLine(lineX, lineStartY, lineX, lineEndY);
+ }
+
+ if (nextDrawItem != null) {
+ nextDrawItem.drawVerticalItemConnector(gc, yPosition, false);
+ }
+}
+/**
+ * Draw a vertical line connecting the horizontal connector line
+ * with that of the previous item.
+ * Do this on all tree levels up to the root level.
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ * @return position to continue drawing
+ */
+Point drawVerticalItemConnector(GC gc, Point position) {
+ Tree parent = getParent();
+ TreeItem parentItem = getParentItem();
+ Rectangle indicatorRectangle = parent.getHierarchyIndicatorRect();
+ int itemHeight = parent.getItemHeight();
+ int itemHeightDiv2 = itemHeight / 2 + itemHeight % 2;
+ int indicatorHeightDiv2 = indicatorRectangle.height / 2 + indicatorRectangle.height % 2;
+ int lineX = position.x + indicatorRectangle.width / 2;
+ int lineStartY = position.y - itemHeightDiv2;
+ int lineEndY = position.y + itemHeightDiv2 - itemHeight % 2;
+ TreeItem predecessor;
+ boolean isFirstChild = false;
+
+ if (isRoot() == true) {
+ if (getIndex() == 0) {
+ return position; // first root, don't draw vertical line
+ }
+ }
+ else
+ if (getIndex() == 0) { // if item is first child
+ lineStartY += itemHeightDiv2;
+ isFirstChild = true;
+ }
+ predecessor = getPredecessor();
+ if (predecessor != null && predecessor.isLeaf() == false) {
+ lineStartY += indicatorHeightDiv2; // leave space for the hierarchy image
+ }
+ if (isLeaf() == false) {
+ lineEndY -= indicatorHeightDiv2;
+ }
+ gc.drawLine(lineX, lineStartY, lineX, lineEndY);
+ if (parentItem != null) {
+ parentItem.drawVerticalItemConnector(gc, position.y, isFirstChild);
+ }
+ return position;
+}
+
+/**
+ * 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>
+ */
+public Rectangle getBounds() {
+ if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);
+ Tree parent = getParent();
+ Point extent = getItemExtent();
+ int x = getTextXPos() - TEXT_INDENT;
+
+ return new Rectangle(x, parent.getRedrawY(this), extent.x - (x - getItemStartX()), extent.y);
+}
+
+/**
+ * Answer the x position of the item check box
+ */
+int getCheckboxXPosition() {
+ return getPaintStartX() + getDecorationsWidth();
+}
+/**
+ * Answer the combined width of the hierarchy indicator and
+ * the horizontal item connector line.
+ */
+int getDecorationsWidth() {
+ int indicatorWidth = getParent().getHierarchyIndicatorRect().width;
+ int width = indicatorWidth + getItemConnectorWidth();
+
+ if (isLeaf() == true) {
+ width -= indicatorWidth / 2;
+ }
+ return width;
+}
+/**
+ * Answer the index of the receiver relative to the first root
+ * item.
+ * @return
+ * The index of the receiver relative to the first root item.
+ */
+int getGlobalIndex() {
+ int globalItemIndex = getIndex();
+ AbstractTreeItem item = null;
+
+ if (isRoot() == false) {
+ item = getParentItem();
+ globalItemIndex++; // adjust for 0-based non-root items
+ }
+ else {
+ item = getParent().getRoot();
+ }
+
+ globalItemIndex += item.getVisibleIndex(getIndex());
+ return globalItemIndex;
+}
+/**
+ * Answer the original size of the image of the receiver.
+ */
+Point getImageExtent() {
+ Image image = getImage();
+ Rectangle imageBounds;
+
+ if (imageExtent == null && image != null) {
+ imageBounds = image.getBounds();
+ imageExtent = new Point(imageBounds.width, imageBounds.height);
+ }
+ return imageExtent;
+}
+/**
+ * Answer the receiver's index into its parent's list of children
+ */
+int getIndex() {
+ return index;
+}
+/**
+ * Answer the width of the horizontal item connector line.
+ */
+int getItemConnectorWidth() {
+ Tree parent = getParent();
+ Point imageExtent = parent.getImageExtent();
+ int itemConnectorWidth;
+ int indicatorWidth = parent.getHierarchyIndicatorRect().width;
+
+ if (imageExtent != null) {
+ itemConnectorWidth = imageExtent.x / 2 + ITEM_CONNECTOR_PADDING;
+ }
+ else {
+ itemConnectorWidth = DEFAULT_ITEM_CONNECTOR_WIDTH;
+ }
+ if (isLeaf() == false) { // has children = has hierarchy indicator = shorter connector
+ itemConnectorWidth -= indicatorWidth / 2;
+ }
+ return itemConnectorWidth;
+}
+/**
+ * Return the number of children.
+ */
+public int getItemCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getItemCount();
+}
+/**
+ * Answer the size of the receiver as displayed on the screen.
+ */
+Point getItemExtent() {
+ Tree parent;
+ Point imageExtent;
+ String text;
+ int itemWidth;
+
+ if (itemExtent == null) {
+ parent = getParent();
+ imageExtent = parent.getImageExtent();
+ text = getText();
+ itemWidth = SELECTION_PADDING;
+ if (text != null) {
+ itemWidth += parent.getTextWidth(text) + TEXT_INDENT;
+ }
+ if (imageExtent != null) {
+ itemWidth += imageExtent.x + IMAGE_PADDING;
+ }
+ itemExtent = new Point(itemWidth, parent.getItemHeight());
+ }
+ return itemExtent;
+}
+/**
+ * Answer the x position at which painting of the receiver's
+ * contents (ie. image, text) can begin.
+ */
+int getItemStartX() {
+ int itemStartX = getPaintStartX() + getDecorationsWidth();
+
+ if (isCheckable() == true) {
+ itemStartX += getCheckboxBounds().width + CHECKBOX_PADDING;
+ }
+ return itemStartX;
+}
+/**
+ * Answer the child items of the receiver as an Array.
+ */
+public TreeItem [] getItems() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TreeItem childrenArray[] = new TreeItem[getItemCount()];
+
+ getChildren().copyInto(childrenArray);
+ return childrenArray;
+}
+/**
+ * Answer the x position where the receiver is drawn.
+ */
+int getPaintStartX() {
+ Tree parent = getParent();
+ Point imageExtent;
+ TreeItem parentItem;
+
+ if (paintStartX == -1) {
+ if (isRoot() == true) {
+ paintStartX = ROOT_INDENT;
+ }
+ else {
+ parentItem = getParentItem();
+ // subtract parent.getHorizontalOffset() to calculate the cached start
+ // position independent of the horizontal scroll offset. Fixes 1G1L7EU.
+ paintStartX = parentItem.getPaintStartX()
+ - parent.getHorizontalOffset()
+ + parentItem.getDecorationsWidth()
+ - parent.getHierarchyIndicatorRect().width / 2;
+ imageExtent = parent.getImageExtent();
+ if (imageExtent != null) {
+ paintStartX += imageExtent.x / 2;
+ }
+ else {
+ paintStartX += ITEM_NOIMAGE_OFFSET;
+ }
+ }
+ }
+ return paintStartX + parent.getHorizontalOffset();
+}
+/**
+ * Answer the pixel at which the receiver stops drawing.
+ */
+int getPaintStopX() {
+ return (getItemStartX() + getItemExtent().x - getParent().getHorizontalOffset());
+}
+/**
+ * Answer the parent widget of the receiver.
+ */
+public Tree getParent() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return (Tree) super.getSelectableParent();
+}
+/**
+ * Answer the parent item of the receiver or null if the
+ * receiver is a root.
+ */
+public TreeItem getParentItem() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return parentItem;
+}
+/**
+ * Answer the item that directly precedes the receiver.
+ * Answer null if this is the first item in a hierarchy level
+ * or if there are expanded children in the previous item.
+ */
+TreeItem getPredecessor() {
+ AbstractTreeItem parentItem = getParentItem();
+ Vector children;
+ int previousIndex = getIndex() - 1;
+ TreeItem previousItem = null;
+
+ if (parentItem == null) {
+ parentItem = getParent().getRoot();
+ }
+ if (previousIndex >= 0) {
+ children = parentItem.getChildren();
+ previousItem = (TreeItem) children.elementAt(previousIndex);
+ if (previousItem.isLeaf() == false && previousItem.getExpanded() == true) {
+ previousItem = null; // no immediate predecessor because there are expanded children
+ }
+ }
+ return previousItem;
+}
+/**
+ * Answer the size of the rectangle drawn to indicate the
+ * selected state of the receiver.
+ * This is also used to draw the selection focus rectangle.
+ */
+Point getSelectionExtent() {
+ Point selectionExtent = getItemExtent();
+ Point imageExtent = getParent().getImageExtent();
+ int x = selectionExtent.x;
+
+ if (imageExtent != null) {
+ x -= imageExtent.x + IMAGE_PADDING;
+ }
+ return new Point(x, selectionExtent.y);
+}
+/**
+ * Return the x position of the selection rectangle
+ */
+int getSelectionX() {
+ return getTextXPos() - TEXT_INDENT;
+}
+/**
+ * Answer the x position where the receiver draws the item text.
+ * This position is relative to the item start position.
+ */
+int getTextXPos() {
+ Point imageExtent = getParent().getImageExtent();
+ int textXPos = getItemStartX() + TEXT_INDENT;
+
+ if (imageExtent != null) {
+ textXPos += imageExtent.x + IMAGE_PADDING;
+ }
+ return textXPos;
+}
+/**
+ * Answer the y position of the receiver's text.
+ * @param
+ * gc - GC to use for calculating the text y position
+ */
+int getTextYPosition(GC gc) {
+ String text;
+
+ if (textYPosition == -1) {
+ text = getText();
+ if (text != null) {
+ textYPosition = (getParent().getItemHeight() - gc.stringExtent(text).y) / 2;
+ }
+ else {
+ textYPosition = 0;
+ }
+ }
+ return textYPosition;
+}
+/**
+ * Answer the index of the receiver relative to the first root
+ * item.
+ * If 'anIndex' is the index of the expanded item 'anItem'
+ * then the following expressions are true:
+ * 'anItem == theRoot.getVisibleItem(anIndex)' and
+ * 'anIndex == anItem.getVisibleIndex()'
+ * @return
+ * The index of the receiver relative to the first root item.
+ * Answer -1 if the receiver is not visible (because the parent
+ * is collapsed).
+ */
+int getVisibleIndex() {
+ int visibleItemIndex = getIndex();
+ AbstractTreeItem item = null;
+
+ if (isRoot() == false) {
+ if (isVisible() == false) {
+ return -1;
+ }
+ item = getParentItem();
+ visibleItemIndex++; // adjust for 0-based non-root items
+ }
+ else {
+ item = getParent().getRoot();
+ }
+
+ visibleItemIndex += item.getVisibleIndex(getIndex());
+ return visibleItemIndex;
+}
+/**
+ * Answer the index of the child item identified by 'childIndex'
+ * relative to the first root item.
+ */
+int getVisibleIndex(int childIndex) {
+ Enumeration children = getChildren().elements();
+ TreeItem child;
+ int visibleItemIndex = getIndex();
+
+ if (isRoot() == false) {
+ visibleItemIndex++; // adjust for 0-based non-root items
+ }
+
+ while (children.hasMoreElements() == true) {
+ child = (TreeItem) children.nextElement();
+ if (child.getIndex() == childIndex) {
+ if (isRoot() == false) {
+ visibleItemIndex += getParentItem().getVisibleIndex(getIndex());
+ }
+ else {
+ visibleItemIndex += getParent().getRoot().getVisibleIndex(getIndex());
+ }
+ break;
+ }
+ visibleItemIndex += child.getVisibleItemCount();
+ }
+ return visibleItemIndex;
+}
+/**
+ * Answer the item at 'searchIndex' relativ to the receiver.
+ * When this method is called for the root item, 'searchIndex'
+ * represents the global index into all items of the tree.
+ * searchIndex=0 returns the receiver.
+ * searchIndex=1 returns the first visible child.
+ * Note: searchIndex must be >= 0
+ *
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. Visible here means that all
+ * the parents of the item are expanded. An item is only
+ * visible on screen if it is within the widget client area.
+ */
+TreeItem getVisibleItem(int searchIndex) {
+ TreeItem child;
+ TreeItem foundItem = null;
+ Enumeration children = getChildren().elements();
+
+ if (searchIndex == 0) {
+ return this;
+ }
+ else
+ if (getExpanded() == false) { // trying to find a child when this item isn't expanded ?
+ return null;
+ }
+
+ // Search for expanded items first. Count all subitems in the process.
+ while (children.hasMoreElements() == true && foundItem == null) {
+ child = (TreeItem) children.nextElement();
+ searchIndex--;
+ if (child.getExpanded() == true) {
+ searchIndex -= child.getVisibleItemCount(); // count children of all expanded items
+ }
+ if (searchIndex <= 0) { // is searched item past child ?
+ // add back children of current item (that's what we want to search)
+ foundItem = child.getVisibleItem(searchIndex + child.getVisibleItemCount());
+ }
+ }
+
+ return foundItem;
+}
+/**
+ * Answer whether 'item' is a child, direct or indirect, of the receiver.
+ * It is an indirect child if it is a child of one of the receiver's children.
+ */
+boolean isChild(TreeItem item) {
+ Vector children = getChildren();
+ TreeItem child;
+
+ if (children.contains(item) == true) {
+ return true;
+ }
+ for (int i = 0; i < children.size(); i++) {
+ child = (TreeItem) children.elementAt(i);
+ if (child.isChild(item) == true) {
+ return true;
+ }
+ }
+ return false;
+}
+/**
+ * Answer whether the receiver is a root item.
+ * The receiver is a root item when it does not have a parent item.
+ * @return
+ * true - the receiver is a root item.
+ * false - the receiver is not a root item.
+ */
+boolean isRoot() {
+ return (getParentItem() == null);
+}
+/**
+ * Answer whether the click at 'position' on the receiver is a selection
+ * click.
+ * @param position - location of the mouse click relative to the
+ * upper left corner of the receiver.
+ * @return true - receiver was clicked.
+ * false - receiver was not clicked.
+ */
+boolean isSelectionHit(Point position) {
+ Point itemExtent = getItemExtent();
+
+ if (itemExtent == null) { // neither image nor text have been set
+ return false;
+ }
+ return (new Rectangle(
+ getItemStartX() - getPaintStartX(), 0,
+ itemExtent.x, itemExtent.y)).contains(position);
+}
+/**
+ * Answer whether the receiver is visible
+ * An item is visible when its parent item is visible and
+ * expanded. Root items are always visible.
+ *
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. Visible here means that all
+ * the parents of the item are expanded. An item is only
+ * visible on screen if it is within the receiver's parent's
+ * client area.
+ * @return
+ * true - the receiver is visible
+ * false - the receiver is not visible
+ */
+boolean isVisible() {
+ boolean isVisible = true;
+ TreeItem parentItem = getParentItem();
+
+ if (isRoot() == false) {
+ isVisible = parentItem.getExpanded();
+ if (isVisible == true) {
+ isVisible = parentItem.isVisible();
+ }
+ }
+ return isVisible;
+}
+/**
+ * Make this item visible by expanding its parent item.
+ */
+void makeVisible() {
+ TreeItem parentItem = getParentItem();
+
+ if (isVisible() == false && parentItem != null) {
+ getParent().expand(parentItem, true); // have to call Tree.expand directly in order to trigger Expand event
+ parentItem.makeVisible();
+ }
+}
+/**
+ * Draw the receiver at 'yPosition' in the client area of the parent.
+ * @param gc - GC to draw on.
+ * @param yPosition - y coordinate where the receiver should draw at.
+ */
+void paint(GC gc, int yPosition) {
+ Tree parent = getParent();
+ Point paintPosition = new Point(getPaintStartX(), yPosition);
+
+ if (isVisible() == false) {
+ return;
+ }
+ gc.setForeground(parent.CONNECTOR_LINE_COLOR);
+ paintPosition = drawVerticalItemConnector(gc, paintPosition);
+ paintPosition = drawHierarchyIndicator(gc, paintPosition);
+ paintPosition = drawHorizontalItemConnector(gc, paintPosition);
+ gc.setForeground(parent.getForeground());
+ // paint the rest
+ if (isCheckable() == true) {
+ paintPosition = drawCheckbox(gc, new Point(paintPosition.x, yPosition));
+ }
+ paintPosition = drawImage(gc, new Point(paintPosition.x, yPosition));
+ drawSelection(gc, paintPosition);
+ if (this == parent.getInsertItem()) {
+ drawInsertMark(gc, paintPosition);
+ }
+ drawText(gc, new Point(getTextXPos(), paintPosition.y + getTextYPosition(gc)));
+ drawSelectionFocus(gc, paintPosition);
+}
+/**
+ * Update the display to reflect the expanded state of the
+ * receiver.
+ * @param itemIndex - index position in the receiver's client
+ * area where should be drawn.
+ */
+void redrawExpanded(int itemIndex) {
+ Tree parent = getParent();
+ int indicatorWidth = parent.getHierarchyIndicatorRect().width;
+ int itemHeight = parent.getItemHeight();
+
+ parent.redraw(
+ getPaintStartX(), itemIndex * itemHeight,
+ indicatorWidth, itemHeight, false);
+}
+/**
+ * Reset cached size and position data.
+ */
+void reset() {
+ super.reset();
+ setImageExtent(null);
+ setItemExtent(null);
+ setPaintStartX(-1);
+ setTextYPosition(-1);
+}
+/**
+ * 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
+ */
+public void setExpanded(boolean expand) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (isLeaf() == false && expand == true) {
+ getParent().expand(this, false);
+ }
+ else {
+ getParent().collapse(this, false);
+ }
+}
+/**
+ * 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);
+ Tree parent = getParent();
+ Image oldImage = getImage();
+ boolean isSameImage;
+ int imageWidth = 0;
+ int redrawX = 0;
+
+ super.setImage(newImage);
+ if (newImage != null && oldImage != null) {
+ isSameImage = newImage.equals(oldImage);
+ }
+ else {
+ isSameImage = newImage == oldImage;
+ }
+ if (isSameImage == false) {
+ if (parent.getVisibleRedrawY(this) != -1) {
+ if (parent.getImageExtent() != null) {
+ imageWidth = parent.getImageExtent().x;
+ }
+ else
+ if (newImage != null) {
+ imageWidth = newImage.getBounds().x;
+ }
+ redrawX = getItemStartX();
+ }
+ parent.itemChanged(this, redrawX, imageWidth);
+ }
+}
+/**
+ * Set the size of the original image of the receiver to 'imageExtent'.
+ */
+void setImageExtent(Point imageExtent) {
+ this.imageExtent = imageExtent;
+}
+/**
+ * Set the index of the receiver to 'index'.
+ * This index is used to reference children in their parent.
+ */
+void setIndex(int index) {
+ this.index = index;
+}
+/**
+ * Set the size of the receiver to 'extent'.
+ */
+void setItemExtent(Point extent) {
+ itemExtent = extent;
+}
+/**
+ * Set the x position where the receiver is drawn to 'startX'.
+ * @param startX - the x position where the receiver is drawn
+ */
+void setPaintStartX(int startX) {
+ paintStartX = startX;
+}
+/**
+ * Set the parent item of the receiver to 'parentItem'.
+ * @param parentItem - the receiver's parent item.
+ * Receiver is a root if this is null.
+ */
+void setParentItem(TreeItem parentItem) {
+ this.parentItem = parentItem;
+}
+/**
+ * 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.
+ */
+public void setText(String newText) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Tree parent = getParent();
+ String oldText = getText();
+ int redrawX = 0;
+ int redrawWidth = 0;
+
+ if (newText == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ super.setText(newText);
+ if (newText.equals(oldText) == false) {
+ if (parent.getVisibleRedrawY(this) != -1) {
+ redrawX = getTextXPos();
+ redrawWidth = parent.getClientArea().width - redrawX;
+ }
+ parent.itemChanged(this, redrawX, redrawWidth);
+ }
+}
+/**
+ * Set the y position of the receiver's text to 'yPosition'.
+ */
+void setTextYPosition(int yPosition) {
+ textYPosition = yPosition;
+}
+/**
+ * Destroy all children of the receiver
+ * Collapsing the item speeds up deleting the children.
+ */
+void disposeItem() {
+ Tree parent = getParent();
+
+ // 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
+ if (parent.isRemovingAll() == false) {
+ parent.collapseNoRedraw(this);
+ }
+ super.disposeItem();
+}
+/**
+ * Return whether or not the receiver is checked.
+ * Always return false if the parent of the receiver does not
+ * have the CHECK style.
+ */
+public boolean getChecked() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ 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>
+ */
+public boolean getGrayed() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getGrayed();
+}
+/**
+ * Set the checked state to 'checked' if the parent of the
+ * receiver has the CHECK style.
+ */
+public void setChecked(boolean checked) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ 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>
+ */
+public void setGrayed (boolean grayed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ super.setGrayed(grayed);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeRoots.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeRoots.java
new file mode 100755
index 0000000000..c9e4dea7ab
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeRoots.java
@@ -0,0 +1,157 @@
+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
+ */
+
+/**
+ * This class is used to store tree root items.
+ * Instances of this class are never displayed.
+ */
+class TreeRoots extends AbstractTreeItem {
+/**
+ * Create a tree item that holds one or more root items
+ * @param parent - Tree widget the receiver belongs to
+ */
+TreeRoots(Tree parent) {
+ super(parent, 0);
+ initialize();
+}
+/**
+ * Calculate the number of expanded children.
+ * Recurse up in the tree to the root item.
+ */
+void calculateVisibleItemCount() {
+ Vector children = getChildren();
+ TreeItem child;
+ int visibleItemCount = children.size();
+
+ for (int i = 0; i < children.size(); i++) {
+ child = (TreeItem) children.elementAt(i);
+ visibleItemCount += child.getVisibleItemCount();
+ }
+ setVisibleItemCount(visibleItemCount);
+}
+/**
+ * Calculate the number of expanded children for the parent item
+ * of this item.
+ */
+void calculateVisibleItemCountParent() {}
+/**
+ * Destroy all children of the receiver
+ */
+void disposeItem() {
+ 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();
+ parent.setRemovingAll(false);
+}
+/**
+ * Answer the x position of the item check box
+ */
+int getCheckboxXPosition() {
+ return 0;
+}
+/**
+ * Implements SelectableItem#getSelectionExtent
+ * Should never be called since objects of this type are never
+ * rendered
+ */
+Point getSelectionExtent() {
+ return new Point(0, 0);
+}
+/**
+ * Implements SelectableItem#getSelectionX
+ * Should never be called since objects of this type are never
+ * rendered
+ */
+int getSelectionX() {
+ return 0;
+}
+/**
+ * Always answer -1 to indicate that the receiver is not visible.
+ */
+int getVisibleIndex() {
+ return -1;
+}
+/**
+ * Answer the index of the child item identified by 'childIndex'
+ * relative to the first root item.
+ */
+int getVisibleIndex(int childIndex) {
+ Enumeration children = getChildren().elements();
+ TreeItem child;
+ int globalItemIndex = 0;
+
+ while (children.hasMoreElements() == true) {
+ child = (TreeItem) children.nextElement();
+ if (child.getIndex() == childIndex) {
+ break;
+ }
+ globalItemIndex += child.getVisibleItemCount();
+ }
+ return globalItemIndex;
+}
+/**
+ * Answer the item at 'searchIndex' relativ to the receiver.
+ * When this method is called for the root item, 'searchIndex'
+ * represents the global index into all items of the tree.
+ * searchIndex=0 returns the receiver.
+ * searchIndex=1 returns the first visible child.
+ * Note: searchIndex must be >= 0
+ *
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. Visible here means that all
+ * the parents of the item are expanded. An item is only
+ * visible on screen if it is within the widget client area.
+ */
+TreeItem getVisibleItem(int searchIndex) {
+ TreeItem child;
+ TreeItem foundItem = null;
+ Enumeration children = getChildren().elements();
+
+ searchIndex++; // skip this fake root item
+
+ // Search for expanded items first. Count all subitems in the process.
+ while (children.hasMoreElements() == true && foundItem == null) {
+ child = (TreeItem) children.nextElement();
+ searchIndex--;
+ if (child.internalGetExpanded() == true) {
+ searchIndex -= child.getVisibleItemCount(); // count children of all expanded items
+ }
+ if (searchIndex <= 0) { // is searched item past child ?
+ // add back children of current item (that's what we want to search)
+ foundItem = child.getVisibleItem(searchIndex + child.getVisibleItemCount());
+ }
+ }
+ return foundItem;
+}
+/**
+ * Initialize the receiver
+ */
+void initialize() {
+ internalSetExpanded(true);
+}
+
+/**
+ * Select the receiver and all children
+ */
+Vector selectAll(Vector selectedItems) {
+ Enumeration children = getChildren().elements();
+ AbstractTreeItem treeItem;
+
+ while (children.hasMoreElements() == true) {
+ treeItem = (AbstractTreeItem) children.nextElement();
+ selectedItems = treeItem.selectAll(selectedItems);
+ }
+ return selectedItems;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java
new file mode 100755
index 0000000000..7f80b5e68d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java
@@ -0,0 +1,441 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+import java.util.EventListener;
+
+public abstract class Widget {
+ public int handle;
+ int style;
+ EventTable eventTable;
+ Object data;
+ String [] keys;
+ Object [] values;
+
+ static final int DEFAULT_WIDTH = 64;
+ static final int DEFAULT_HEIGHT = 64;
+
+ static final char Mnemonic = '&';
+
+Widget () {
+ /* Do nothing */
+}
+
+public Widget (Widget parent, int style) {
+ checkSubclass ();
+ checkParent (parent);
+ this.style = style;
+}
+
+static int checkBits (int style, int int0, int int1, int int2, int int3, int int4, int int5) {
+ int mask = int0 | int1 | int2 | int3 | int4 | int5;
+ if ((style & mask) == 0) style |= int0;
+ if ((style & int0) != 0) style = (style & ~mask) | int0;
+ if ((style & int1) != 0) style = (style & ~mask) | int1;
+ if ((style & int2) != 0) style = (style & ~mask) | int2;
+ if ((style & int3) != 0) style = (style & ~mask) | int3;
+ if ((style & int4) != 0) style = (style & ~mask) | int4;
+ if ((style & int5) != 0) style = (style & ~mask) | int5;
+ return style;
+}
+
+void checkParent (Widget parent) {
+ if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+protected void checkWidget () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+
+int copyPhImage(int image) {
+ if (image == 0) return 0;
+ int imageHandle = OS.PiDuplicateImage (image, 0);
+ /* Bug in Photon - The image returned by PiDuplicateImage
+ has the same mask_bm as the original image.
+ */
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove (phImage, imageHandle, PhImage_t.sizeof);
+ if (phImage.mask_bm != 0) {
+ int length = phImage.mask_bpl * phImage.size_h;
+ int ptr = OS.malloc (length);
+ OS.memmove(ptr, phImage.mask_bm, length);
+ phImage.mask_bm = ptr;
+ OS.memmove (imageHandle, phImage, PhImage_t.sizeof);
+ }
+ return imageHandle;
+}
+
+public void addListener (int eventType, Listener handler) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) eventTable = new EventTable ();
+ eventTable.hook (eventType, handler);
+}
+
+public void addDisposeListener (DisposeListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Dispose, typedListener);
+}
+
+void createHandle (int index) {
+ /* Do nothing */
+}
+
+void createWidget (int index) {
+ createHandle (index);
+ hookEvents ();
+ register ();
+}
+
+void deregister () {
+ if (handle == 0) return;
+ WidgetTable.remove (handle);
+}
+
+void destroyWidget () {
+ int topHandle = topHandle ();
+ releaseHandle ();
+ if (topHandle != 0) {
+ OS.PtDestroyWidget (topHandle);
+ }
+}
+
+public void dispose () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ releaseChild ();
+ releaseWidget ();
+ destroyWidget ();
+}
+
+static void error (int code) {
+ SWT.error(code);
+}
+
+public Object getData () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return data;
+}
+
+public Object getData (String key) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (keys == null) return null;
+ for (int i=0; i<keys.length; i++) {
+ if (keys [i].equals (key)) return values [i];
+ }
+ return null;
+}
+
+public abstract Display getDisplay ();
+
+String getName () {
+ String string = getClass ().getName ();
+ int index = string.length ();
+ while (--index > 0 && string.charAt (index) != '.');
+ return string.substring (index + 1, string.length ());
+}
+
+String getNameText () {
+ return "";
+}
+
+public int getStyle () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return style;
+}
+
+boolean hooks (int eventType) {
+ if (eventTable == null) return false;
+ return eventTable.hooks (eventType);
+}
+
+void hookEvents () {
+ /* Do nothing */
+}
+
+public boolean isDisposed () {
+ return handle == 0;
+}
+
+boolean isValidSubclass () {
+ return Display.isValidClass (getClass ());
+}
+
+protected boolean isListening (int eventType) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return hooks (eventType);
+}
+
+boolean isValidThread () {
+ return getDisplay ().isValidThread ();
+}
+
+boolean isValidWidget () {
+ return true /*handle != 0*/;
+}
+
+public void notifyListeners (int eventType, Event event) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ event.type = eventType;
+ event.widget = this;
+ eventTable.sendEvent (event);
+}
+
+void postEvent (int eventType) {
+ if (eventTable == null) return;
+ postEvent (eventType, new Event ());
+}
+
+void postEvent (int eventType, Event event) {
+ if (eventTable == null) return;
+ event.type = eventType;
+ event.widget = this;
+ if (event.time == 0) {
+ event.time = (int) System.currentTimeMillis ();
+ }
+ getDisplay ().postEvent (event);
+}
+
+int processDefaultSelection (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processFocusIn (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processFocusOut (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processHide (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processKey (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processEvent (int data, int info) {
+ switch (data) {
+// case SWT.Arm: return processArm (info);
+// case SWT.Dispose: return processDispose (info);
+ case SWT.DefaultSelection: return processDefaultSelection (info);
+ case SWT.FocusIn: return processFocusIn (info);
+ case SWT.FocusOut: return processFocusOut (info);
+// case SWT.Help: return processHelp (info);
+ case SWT.Hide: return processHide (info);
+ case SWT.KeyDown:
+ case SWT.KeyUp: return processKey (info);
+ case SWT.Modify: return processModify (info);
+ case SWT.MouseDown:
+ case SWT.MouseMove:
+ case SWT.MouseUp: return processMouse (info);
+ case SWT.MouseEnter: return processMouseEnter (info);
+// case SWT.MouseExit: return processMouseOut (info);
+ case SWT.Move: return processMove (info);
+// case SWT.Paint: return processPaint (info);
+ case SWT.Resize: return processResize (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;
+}
+
+int processModify (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processMouse (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processMouseEnter (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processMove (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processPaint (int damage) {
+ return OS.Pt_CONTINUE;
+}
+
+int processResize (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processShow (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processShellResize (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processSelection (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processVerify (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+void releaseChild () {
+ /* Do nothing */
+}
+
+void register () {
+ if (handle == 0) return;
+ WidgetTable.put (handle, this);
+}
+
+void releaseHandle () {
+ handle = 0;
+// state |= DISPOSED;
+}
+
+void releaseWidget () {
+ sendEvent (SWT.Dispose);
+// state |= DISPOSED;
+ eventTable = null;
+ data = null;
+}
+
+public void removeListener (int eventType, Listener handler) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (eventType, handler);
+}
+
+protected void removeListener (int eventType, EventListener handler) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (eventType, handler);
+}
+
+public void removeDisposeListener (DisposeListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Dispose, listener);
+}
+
+void sendEvent (int eventType) {
+ if (eventTable == null) return;
+ sendEvent (eventType, new Event ());
+}
+
+void sendEvent (int eventType, Event event) {
+ if (eventTable == null) return;
+ event.widget = this;
+ event.type = eventType;
+ if (event.time == 0) {
+ event.time = (int) System.currentTimeMillis ();
+ }
+ eventTable.sendEvent (event);
+}
+
+public void setData (Object data) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ this.data = data;
+}
+
+public void setData (String key, Object value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ /* Remove the key/value pair */
+ if (value == null) {
+ if (keys == null) return;
+ int index = 0;
+ while (index < keys.length && !keys [index].equals (key)) index++;
+ if (index == keys.length) return;
+ if (keys.length == 1) {
+ keys = null;
+ values = null;
+ } else {
+ String [] newKeys = new String [keys.length - 1];
+ Object [] newValues = new Object [values.length - 1];
+ System.arraycopy (keys, 0, newKeys, 0, index);
+ System.arraycopy (keys, index + 1, newKeys, index, newKeys.length - index);
+ System.arraycopy (values, 0, newValues, 0, index);
+ System.arraycopy (values, index + 1, newValues, index, newValues.length - index);
+ keys = newKeys;
+ values = newValues;
+ }
+ return;
+ }
+
+ /* Add the key/value pair */
+ if (keys == null) {
+ keys = new String [] {key};
+ values = new Object [] {value};
+ return;
+ }
+ for (int i=0; i<keys.length; i++) {
+ if (keys [i].equals (key)) {
+ values [i] = value;
+ return;
+ }
+ }
+ String [] newKeys = new String [keys.length + 1];
+ Object [] newValues = new Object [values.length + 1];
+ System.arraycopy (keys, 0, newKeys, 0, keys.length);
+ System.arraycopy (values, 0, newValues, 0, values.length);
+ newKeys [keys.length] = key;
+ newValues [values.length] = value;
+ keys = newKeys;
+ values = newValues;
+}
+
+public String toString () {
+ String string = "*Disposed*";
+ if (!isDisposed ()) {
+ string = "*Wrong Thread*";
+ if (isValidThread ()) string = getNameText ();
+ }
+ return getName () + " {" + string + "}";
+}
+
+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
new file mode 100755
index 0000000000..570e5b3c78
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/WidgetTable.java
@@ -0,0 +1,101 @@
+package org.eclipse.swt.widgets;
+
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+
+class WidgetTable {
+ static int FreeSlot = 0;
+ static int GrowSize = 1024;
+ static int [] IndexTable = new int [GrowSize];
+ static Widget [] WidgetTable = new Widget [GrowSize];
+ static int ArgPtr = OS.malloc (4);
+ static int [] ArgBuffer = new int [1];
+ static int [] SetArgs = new int [] {OS.Pt_ARG_USER_DATA, ArgPtr, 4};
+ static int [] GetArgs = new int [] {OS.Pt_ARG_USER_DATA, 0, 0};
+ static {
+ for (int i=0; i<GrowSize-1; i++) IndexTable [i] = i + 1;
+ IndexTable [GrowSize - 1] = -1;
+ }
+public static synchronized Widget get (int handle) {
+ if (handle == 0) return null;
+ GetArgs [1] = 0;
+ OS.PtGetResources (handle, GetArgs.length / 3, GetArgs);
+ if (GetArgs [1] == 0) return null;
+ OS.memmove (ArgBuffer, GetArgs [1], 4);
+ if (ArgBuffer [0] == 0) return null;
+ int index = ArgBuffer [0] - 1;
+ if (0 <= index && index < WidgetTable.length) return WidgetTable [index];
+ return null;
+}
+public synchronized static void put(int handle, Widget widget) {
+ if (handle == 0) return;
+ if (FreeSlot == -1) {
+ int length = (FreeSlot = IndexTable.length) + GrowSize;
+ int[] newIndexTable = new int[length];
+ Widget[] newWidgetTable = new Widget [length];
+ System.arraycopy (IndexTable, 0, newIndexTable, 0, FreeSlot);
+ System.arraycopy (WidgetTable, 0, newWidgetTable, 0, FreeSlot);
+ for (int i = FreeSlot; i < length - 1; i++) {
+ newIndexTable[i] = i + 1;
+ }
+ newIndexTable[length - 1] = -1;
+ IndexTable = newIndexTable;
+ WidgetTable = newWidgetTable;
+ }
+ ArgBuffer [0] = FreeSlot + 1;
+ OS.memmove (ArgPtr, ArgBuffer, 4);
+ OS.PtSetResources (handle, SetArgs.length / 3, SetArgs);
+ int oldSlot = FreeSlot;
+ FreeSlot = IndexTable[oldSlot];
+ IndexTable [oldSlot] = -2;
+ WidgetTable [oldSlot] = widget;
+}
+public static synchronized Widget remove (int handle) {
+ if (handle == 0) return null;
+ GetArgs [1] = 0;
+ OS.PtGetResources (handle, GetArgs.length / 3, GetArgs);
+ if (GetArgs [1] == 0) return null;
+ OS.memmove (ArgBuffer, GetArgs [1], 4);
+ if (ArgBuffer [0] == 0) return null;
+ int index = ArgBuffer [1] - 1;
+ Widget widget = null;
+ if (0 <= index && index < WidgetTable.length) {
+ widget = WidgetTable [index];
+ WidgetTable [index] = null;
+ IndexTable [index] = FreeSlot;
+ FreeSlot = index;
+ ArgBuffer [0] = 0;
+ OS.memmove (ArgPtr, ArgBuffer, 4);
+ OS.PtSetResources (handle, SetArgs.length / 3, SetArgs);
+ }
+ return widget;
+}
+public static synchronized Shell [] shells () {
+ int length = 0;
+ for (int i=0; i<WidgetTable.length; i++) {
+ Widget widget = WidgetTable [i];
+ if (widget != null && widget instanceof Shell) length++;
+ }
+ int index = 0;
+ Shell [] result = new Shell [length];
+ for (int i=0; i<WidgetTable.length; i++) {
+ Widget widget = WidgetTable [i];
+ if (widget != null && widget instanceof Shell) {
+ result [index++] = (Shell) widget;
+ }
+ }
+ return result;
+}
+public static synchronized int size () {
+ int size = 0;
+ for (int i=0; i<WidgetTable.length; i++) {
+ if (WidgetTable [i] != null) size++;
+ }
+ return size;
+}
+}