summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Color.java202
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java372
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java568
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/DeviceData.java30
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java308
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java422
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java152
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java3430
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GCData.java42
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java1326
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Region.java298
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/Converter.java92
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java884
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java220
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java526
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java106
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java1348
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java1248
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java2988
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java440
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/DirectoryDialog.java122
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java2778
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java258
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java168
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java252
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java610
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java1180
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java768
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java1046
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java222
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java242
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java632
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java328
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java654
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java248
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java1678
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java444
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java890
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabItem.java264
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java1460
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java606
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java1106
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java1210
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java1580
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/WidgetTable.java212
45 files changed, 16980 insertions, 16980 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Color.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Color.java
index e2c0de95a9..cf558e9838 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Color.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Color.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+
/**
* Instances of this class manage the operating system resources that
* implement SWT's RGB color model. To create a color you can either
@@ -22,22 +22,22 @@ import org.eclipse.swt.*;
*
* @see RGB
*/
-public final class Color {
-
- /**
- * the handle to the OS color resource
- * (Warning: This field is platform dependent)
+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
+ public int handle;
+
+ /**
+ * the device where this color was created
*/
- Device device;
-
-Color() {
-}
-
+ Device device;
+
+Color() {
+}
+
/**
* Constructs a new instance of this class given a device and the
* desired red, green and blue values expressed as ints in the range
@@ -62,13 +62,13 @@ Color() {
*
* @see #dispose
*/
-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, 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);
+}
+
/**
* Constructs a new instance of this class given a device and an
* <code>RGB</code> describing the desired red, green and blue values.
@@ -91,28 +91,28 @@ public Color (Device device, int red, int green, int blue) {
*
* @see #dispose
*/
-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 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);
+}
+
/**
* Disposes of the operating system resources associated with
* the color. Applications must dispose of all colors which
* they allocate.
*/
-public void dispose() {
- if (handle == -1) return;
- if (device.isDisposed()) return;
-
- handle = -1;
- if (device.tracking) device.dispose_Object(this);
- device = null;
-}
-
+public void dispose() {
+ if (handle == -1) return;
+ if (device.isDisposed()) return;
+
+ handle = -1;
+ if (device.tracking) device.dispose_Object(this);
+ device = null;
+}
+
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -123,13 +123,13 @@ public void dispose() {
*
* @see #hashCode
*/
-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 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);
+}
+
/**
* Returns the amount of blue in the color, from 0 to 255.
*
@@ -139,11 +139,11 @@ public boolean equals (Object object) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getBlue () {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return handle & 0xFF;
-}
-
+public int getBlue () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return handle & 0xFF;
+}
+
/**
* Returns the amount of green in the color, from 0 to 255.
*
@@ -153,11 +153,11 @@ public int getBlue () {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getGreen () {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return (handle & 0xFF00) >> 8;
-}
-
+public int getGreen () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return (handle & 0xFF00) >> 8;
+}
+
/**
* Returns the amount of red in the color, from 0 to 255.
*
@@ -167,11 +167,11 @@ public int getGreen () {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getRed () {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return (handle & 0xFF0000) >> 16;
-}
-
+public int getRed () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return (handle & 0xFF0000) >> 16;
+}
+
/**
* Returns an <code>RGB</code> representing the receiver.
*
@@ -179,11 +179,11 @@ public int getRed () {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public RGB getRGB () {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return new RGB((handle & 0xFF0000) >> 16, (handle & 0xFF00) >> 8, handle & 0xFF);
-}
-
+public RGB getRGB () {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return new RGB((handle & 0xFF0000) >> 16, (handle & 0xFF00) >> 8, handle & 0xFF);
+}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -194,18 +194,18 @@ public RGB getRGB () {
*
* @see #equals
*/
-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 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);
+}
+
/**
* Returns <code>true</code> if the color has been disposed,
* and <code>false</code> otherwise.
@@ -216,26 +216,26 @@ void init(Device device, int red, int green, int blue) {
*
* @return <code>true</code> when the color is disposed and <code>false</code> otherwise
*/
-public boolean isDisposed() {
- return handle == -1;
-}
-
+public boolean isDisposed() {
+ return handle == -1;
+}
+
/**
* Returns a string containing a concise, human-readable
* description of the receiver.
*
* @return a string representation of the receiver
*/
-public String toString () {
- if (isDisposed()) return "Color {*DISPOSED*}";
- 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;
-}
+public String toString () {
+ if (isDisposed()) return "Color {*DISPOSED*}";
+ 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;
+}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java
index f03104f83c..870119152a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java
@@ -1,15 +1,15 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
/**
* Instances of this class manage operating system resources that
* specify the appearance of the on-screen pointer. To create a
@@ -34,28 +34,28 @@ import org.eclipse.swt.*;
* Note: Only one of the above styles may be specified.
* </p>
*/
-public final class Cursor {
-
- /**
- * the type to the OS cursor resource
- * (Warning: This field is platform dependent)
+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 type;
+
+ /**
+ * the handle to the OS cursor resource
+ * (Warning: This field is platform dependent)
*/
- public int bitmap;
-
- /**
- * the device where this cursor was created
+ public int bitmap;
+
+ /**
+ * the device where this cursor was created
*/
- Device device;
-
-Cursor() {
-}
-
+ Device device;
+
+Cursor() {
+}
+
/**
* Constructs a new cursor given a device and a style
* constant describing the desired cursor appearance.
@@ -97,40 +97,40 @@ Cursor() {
* @see SWT#CURSOR_NO
* @see SWT#CURSOR_HAND
*/
-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);
- }
- if (type == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- if (device.tracking) device.new_Object(this);
-}
-
+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);
+ }
+ if (type == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ if (device.tracking) device.new_Object(this);
+}
+
/**
* Constructs a new cursor given a device, image and mask
* data describing the desired cursor appearance, and the x
@@ -163,105 +163,105 @@ public Cursor(Device device, int style) {
* <li>ERROR_NO_HANDLES - if a handle could not be obtained for cursor creation</li>
* </ul>
*/
-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;
- if (source == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (mask == null) {
- if (source.getTransparencyType() != SWT.TRANSPARENCY_MASK) {
- SWT.error(SWT.ERROR_NULL_ARGUMENT);
- }
- mask = source.getTransparencyMask();
- }
- /* Check the bounds. Mask must be the same size as source */
- if (mask.width != source.width || mask.height != source.height) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- /* Check color depths */
- if (mask.depth != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (source.depth != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- /* Check the hotspots */
- if (hotspotX >= source.width || hotspotX < 0 ||
- hotspotY >= source.height || hotspotY < 0) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- type = OS.Ph_CURSOR_BITMAP;
-
- short w = (short)source.width;
- short h = (short)source.height;
- ImageData mask1 = new ImageData(w, h, 1, source.palette);
- ImageData mask2 = new ImageData(w, h, 1, mask.palette);
- for (int y=0; y<h; y++) {
- for (int x=0; x<w; x++) {
- int mask1_pixel, src_pixel = source.getPixel(x, y);
- int mask2_pixel, mask_pixel = mask.getPixel(x, y);
- if (src_pixel == 0 && mask_pixel == 0) {
- // BLACK
- mask1_pixel = 0;
- mask2_pixel = 1;
- } else if (src_pixel == 0 && mask_pixel == 1) {
- // WHITE - cursor color
- mask1_pixel = 1;
- mask2_pixel = 0;
- } else if (src_pixel == 1 && mask_pixel == 0) {
- // SCREEN
- mask1_pixel = 0;
- mask2_pixel = 0;
- } else {
- /*
- * Feature in Photon. It is not possible to have
- * the reverse screen case using the Photon support.
- * Reverse screen will be the same as screen.
- */
- // REVERSE SCREEN -> SCREEN
- mask1_pixel = 0;
- mask2_pixel = 0;
- }
- mask1.setPixel(x, y, mask1_pixel);
- mask2.setPixel(x, y, mask2_pixel);
- }
- }
-
- PhCursorDef_t cursor = new PhCursorDef_t();
- cursor.size1_x = w;
- cursor.size1_y = h;
- cursor.offset1_x = (short)-hotspotX;
- cursor.offset1_y = (short)-hotspotY;
- cursor.bytesperline1 = (byte)mask1.bytesPerLine;
- cursor.color1 = OS.Ph_CURSOR_DEFAULT_COLOR;
- cursor.size2_x = w;
- cursor.size2_y = h;
- cursor.offset2_x = (short)-hotspotX;
- cursor.offset2_y = (short)-hotspotY;
- cursor.bytesperline2 = (byte)mask2.bytesPerLine;
- cursor.color2 = 0x000000;
- int mask1Size = cursor.bytesperline1 * cursor.size1_y;
- int mask2Size = cursor.bytesperline2 * cursor.size2_y;
- bitmap = OS.malloc(PhCursorDef_t.sizeof + mask1Size + mask2Size);
- if (bitmap == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- OS.memmove(bitmap, cursor, PhCursorDef_t.sizeof);
- OS.memmove(bitmap + PhCursorDef_t.sizeof, mask1.data, mask1Size);
- OS.memmove(bitmap + PhCursorDef_t.sizeof + mask1Size, mask2.data, mask2Size);
- if (device.tracking) device.new_Object(this);
-}
-
+public 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;
+ if (source == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (mask == null) {
+ if (source.getTransparencyType() != SWT.TRANSPARENCY_MASK) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ mask = source.getTransparencyMask();
+ }
+ /* Check the bounds. Mask must be the same size as source */
+ if (mask.width != source.width || mask.height != source.height) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ /* Check color depths */
+ if (mask.depth != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (source.depth != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ /* Check the hotspots */
+ if (hotspotX >= source.width || hotspotX < 0 ||
+ hotspotY >= source.height || hotspotY < 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ type = OS.Ph_CURSOR_BITMAP;
+
+ short w = (short)source.width;
+ short h = (short)source.height;
+ ImageData mask1 = new ImageData(w, h, 1, source.palette);
+ ImageData mask2 = new ImageData(w, h, 1, mask.palette);
+ for (int y=0; y<h; y++) {
+ for (int x=0; x<w; x++) {
+ int mask1_pixel, src_pixel = source.getPixel(x, y);
+ int mask2_pixel, mask_pixel = mask.getPixel(x, y);
+ if (src_pixel == 0 && mask_pixel == 0) {
+ // BLACK
+ mask1_pixel = 0;
+ mask2_pixel = 1;
+ } else if (src_pixel == 0 && mask_pixel == 1) {
+ // WHITE - cursor color
+ mask1_pixel = 1;
+ mask2_pixel = 0;
+ } else if (src_pixel == 1 && mask_pixel == 0) {
+ // SCREEN
+ mask1_pixel = 0;
+ mask2_pixel = 0;
+ } else {
+ /*
+ * Feature in Photon. It is not possible to have
+ * the reverse screen case using the Photon support.
+ * Reverse screen will be the same as screen.
+ */
+ // REVERSE SCREEN -> SCREEN
+ mask1_pixel = 0;
+ mask2_pixel = 0;
+ }
+ mask1.setPixel(x, y, mask1_pixel);
+ mask2.setPixel(x, y, mask2_pixel);
+ }
+ }
+
+ PhCursorDef_t cursor = new PhCursorDef_t();
+ cursor.size1_x = w;
+ cursor.size1_y = h;
+ cursor.offset1_x = (short)-hotspotX;
+ cursor.offset1_y = (short)-hotspotY;
+ cursor.bytesperline1 = (byte)mask1.bytesPerLine;
+ cursor.color1 = OS.Ph_CURSOR_DEFAULT_COLOR;
+ cursor.size2_x = w;
+ cursor.size2_y = h;
+ cursor.offset2_x = (short)-hotspotX;
+ cursor.offset2_y = (short)-hotspotY;
+ cursor.bytesperline2 = (byte)mask2.bytesPerLine;
+ cursor.color2 = 0x000000;
+ int mask1Size = cursor.bytesperline1 * cursor.size1_y;
+ int mask2Size = cursor.bytesperline2 * cursor.size2_y;
+ bitmap = OS.malloc(PhCursorDef_t.sizeof + mask1Size + mask2Size);
+ if (bitmap == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ OS.memmove(bitmap, cursor, PhCursorDef_t.sizeof);
+ OS.memmove(bitmap + PhCursorDef_t.sizeof, mask1.data, mask1Size);
+ OS.memmove(bitmap + PhCursorDef_t.sizeof + mask1Size, mask2.data, mask2Size);
+ if (device.tracking) device.new_Object(this);
+}
+
/**
* Disposes of the operating system resources associated with
* the cursor. Applications must dispose of all cursors which
* they allocate.
*/
-public void dispose () {
- if (type == 0) return;
- if (device.isDisposed()) return;
- if (type == OS.Ph_CURSOR_BITMAP && bitmap != 0) {
- OS.free(bitmap);
- }
- type = bitmap = 0;
- if (device.tracking) device.dispose_Object(this);
- device = null;
-}
-
+public void dispose () {
+ if (type == 0) return;
+ if (device.isDisposed()) return;
+ if (type == OS.Ph_CURSOR_BITMAP && bitmap != 0) {
+ OS.free(bitmap);
+ }
+ type = bitmap = 0;
+ if (device.tracking) device.dispose_Object(this);
+ device = null;
+}
+
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -272,14 +272,14 @@ public void dispose () {
*
* @see #hashCode
*/
-public boolean equals (Object object) {
- if (object == this) return true;
- if (!(object instanceof Cursor)) return false;
- Cursor cursor = (Cursor) object;
- return device == cursor.device && type == cursor.type &&
- bitmap == cursor.bitmap;
-}
-
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof Cursor)) return false;
+ Cursor cursor = (Cursor) object;
+ return device == cursor.device && type == cursor.type &&
+ bitmap == cursor.bitmap;
+}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -290,10 +290,10 @@ public boolean equals (Object object) {
*
* @see #equals
*/
-public int hashCode () {
- return bitmap ^ type;
-}
-
+public int hashCode () {
+ return bitmap ^ type;
+}
+
/**
* Returns <code>true</code> if the cursor has been disposed,
* and <code>false</code> otherwise.
@@ -304,28 +304,28 @@ public int hashCode () {
*
* @return <code>true</code> when the cursor is disposed and <code>false</code> otherwise
*/
-public boolean isDisposed() {
- return type == 0;
-}
-
-public static Cursor photon_new(Device device, int type, int bitmap) {
- if (device == null) device = Device.getDevice();
- Cursor cursor = new Cursor();
- cursor.type = type;
- cursor.bitmap = bitmap;
- cursor.device = device;
- return cursor;
-}
-
+public boolean isDisposed() {
+ return type == 0;
+}
+
+public static Cursor photon_new(Device device, int type, int bitmap) {
+ if (device == null) device = Device.getDevice();
+ Cursor cursor = new Cursor();
+ cursor.type = type;
+ cursor.bitmap = bitmap;
+ cursor.device = device;
+ return cursor;
+}
+
/**
* Returns a string containing a concise, human-readable
* description of the receiver.
*
* @return a string representation of the receiver
*/
-public String toString () {
- if (isDisposed()) return "Cursor {*DISPOSED*}";
- return "Cursor {" + type + "," + bitmap + "}";
-}
-
+public String toString () {
+ if (isDisposed()) return "Cursor {*DISPOSED*}";
+ return "Cursor {" + type + "," + bitmap + "}";
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java
index f1b87c1626..45deeb28af 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java
@@ -1,62 +1,62 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+
/**
* This class is the abstract superclass of all device objects,
* such as the Display device and the Printer device. Devices
* can have a graphics context (GC) created for them, and they
* can be drawn on by sending messages to the associated GC.
*/
-public abstract class Device implements Drawable {
-
- /* Debugging */
- public static boolean DEBUG;
- boolean debug = DEBUG;
- boolean tracking = DEBUG;
- Error [] errors;
- Object [] objects;
-
- boolean disposed;
-
- byte[] systemFont;
-
- /*
- * TEMPORARY CODE. When a graphics object is
- * created and the device parameter is null,
- * the current Display is used. This presents
- * a problem because SWT graphics does not
- * reference classes in SWT widgets. The correct
- * fix is to remove this feature. Unfortunately,
- * too many application programs rely on this
- * feature.
- *
- * This code will be removed in the future.
- */
- protected static Device CurrentDevice;
- protected static Runnable DeviceFinder;
- static {
- try {
- Class.forName ("org.eclipse.swt.widgets.Display");
- } catch (Throwable e) {}
- }
-
-static Device getDevice () {
- if (DeviceFinder != null) DeviceFinder.run();
- Device device = CurrentDevice;
- CurrentDevice = null;
- return device;
-}
-
+public abstract class Device implements Drawable {
+
+ /* Debugging */
+ public static boolean DEBUG;
+ boolean debug = DEBUG;
+ boolean tracking = DEBUG;
+ Error [] errors;
+ Object [] objects;
+
+ boolean disposed;
+
+ byte[] systemFont;
+
+ /*
+ * TEMPORARY CODE. When a graphics object is
+ * created and the device parameter is null,
+ * the current Display is used. This presents
+ * a problem because SWT graphics does not
+ * reference classes in SWT widgets. The correct
+ * fix is to remove this feature. Unfortunately,
+ * too many application programs rely on this
+ * feature.
+ *
+ * This code will be removed in the future.
+ */
+ protected static Device CurrentDevice;
+ protected static Runnable DeviceFinder;
+ static {
+ try {
+ Class.forName ("org.eclipse.swt.widgets.Display");
+ } catch (Throwable e) {}
+ }
+
+static Device getDevice () {
+ if (DeviceFinder != null) DeviceFinder.run();
+ Device device = CurrentDevice;
+ CurrentDevice = null;
+ return device;
+}
+
/**
* Constructs a new instance of this class.
* <p>
@@ -69,32 +69,32 @@ static Device getDevice () {
* @see #init
* @see DeviceData
*/
-public Device(DeviceData data) {
- if (data != null) {
- debug = data.debug;
- tracking = data.tracking;
- }
- create (data);
- init ();
- if (tracking) {
- errors = new Error [128];
- objects = new Object [128];
- }
-
- /* Initialize the system font slot */
- systemFont = getSystemFont ().handle;
-}
-
-protected void checkDevice () {
- if (disposed) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
-}
-
-protected void create (DeviceData data) {
-}
-
-protected void destroy () {
-}
-
+public Device(DeviceData data) {
+ if (data != null) {
+ debug = data.debug;
+ tracking = data.tracking;
+ }
+ create (data);
+ init ();
+ if (tracking) {
+ errors = new Error [128];
+ objects = new Object [128];
+ }
+
+ /* Initialize the system font slot */
+ systemFont = getSystemFont ().handle;
+}
+
+protected void checkDevice () {
+ if (disposed) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
+}
+
+protected void create (DeviceData data) {
+}
+
+protected void destroy () {
+}
+
/**
* Disposes of the operating system resources associated with
* the receiver. After this method has been invoked, the receiver
@@ -105,28 +105,28 @@ protected void destroy () {
* @see #destroy
* @see #checkDevice
*/
-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 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;
+ }
+ }
+}
+
/**
* Returns a rectangle describing the receiver's size and location.
*
@@ -136,15 +136,15 @@ void dispose_Object (Object object) {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Rectangle getBounds () {
- checkDevice ();
- PhRect_t rect = new PhRect_t ();
- OS.PhWindowQueryVisible (OS.Ph_QUERY_CONSOLE, 0, OS.PhInputGroup (0), 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 getBounds () {
+ checkDevice ();
+ PhRect_t rect = new PhRect_t ();
+ OS.PhWindowQueryVisible (OS.Ph_QUERY_CONSOLE, 0, OS.PhInputGroup (0), 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);
+}
+
/**
* Returns a rectangle which describes the area of the
* receiver which is capable of displaying data.
@@ -157,15 +157,15 @@ public Rectangle getBounds () {
*
* @see #getBounds
*/
-public Rectangle getClientArea () {
- checkDevice ();
- PhRect_t rect = new PhRect_t ();
- OS.PhWindowQueryVisible (OS.Ph_QUERY_WORKSPACE, 0, OS.PhInputGroup (0), 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 () {
+ checkDevice ();
+ PhRect_t rect = new PhRect_t ();
+ OS.PhWindowQueryVisible (OS.Ph_QUERY_WORKSPACE, 0, OS.PhInputGroup (0), 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);
+}
+
/**
* Returns the bit depth of the screen, which is the number of
* bits it takes to represent the number of unique colors that
@@ -178,15 +178,15 @@ public Rectangle getClientArea () {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getDepth () {
- checkDevice ();
- PgDisplaySettings_t settings = new PgDisplaySettings_t ();
- OS.PgGetVideoMode (settings);
- PgVideoModeInfo_t mode_info = new PgVideoModeInfo_t ();
- OS.PgGetVideoModeInfo ((short) settings.mode, mode_info);
- return mode_info.bits_per_pixel;
-}
-
+public int getDepth () {
+ checkDevice ();
+ PgDisplaySettings_t settings = new PgDisplaySettings_t ();
+ OS.PgGetVideoMode (settings);
+ PgVideoModeInfo_t mode_info = new PgVideoModeInfo_t ();
+ OS.PgGetVideoModeInfo ((short) settings.mode, mode_info);
+ return mode_info.bits_per_pixel;
+}
+
/**
* Returns a <code>DeviceData</code> based on the receiver.
* Modifications made to this <code>DeviceData</code> will not
@@ -200,29 +200,29 @@ public int getDepth () {
*
* @see DeviceData
*/
-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 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;
+}
+
/**
* Returns a point whose x coordinate is the horizontal
* dots per inch of the display, and whose y coordinate
@@ -234,12 +234,12 @@ public DeviceData getDeviceData () {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Point getDPI () {
- checkDevice ();
- //NOT DONE
- return new Point (96, 96);
-}
-
+public Point getDPI () {
+ checkDevice ();
+ //NOT DONE
+ return new Point (96, 96);
+}
+
/**
* Returns <code>FontData</code> objects which describe
* the fonts that match the given arguments. If the
@@ -253,66 +253,66 @@ public Point getDPI () {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public FontData [] getFontList (String faceName, boolean scalable) {
- checkDevice ();
- int flags = OS.PHFONT_FIXED | OS.PHFONT_PROP | OS.PHFONT_DONT_SHOW_LEGACY;
- flags |= scalable ? OS.PHFONT_SCALABLE : OS.PHFONT_BITMAP;
- int nfonts = OS.PfQueryFonts(OS.PHFONT_ALL_SYMBOLS, flags, 0, 0);
- if (nfonts <= 0) return new FontData[0];
- int list_ptr = OS.malloc(nfonts * FontDetails.sizeof);
- nfonts = OS.PfQueryFonts(OS.PHFONT_ALL_SYMBOLS, 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);
- char[] chars = Converter.mbcsToWcs(null, details.desc);
- int index = 0;
- while (index < chars.length) {
- if (chars[index] == 0) break;
- index++;
- }
- String name = new String(chars, 0, index);
- if (faceName == null || Compatibility.equalsIgnoreCase(faceName, 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 FontData [] getFontList (String faceName, boolean scalable) {
+ checkDevice ();
+ int flags = OS.PHFONT_FIXED | OS.PHFONT_PROP | OS.PHFONT_DONT_SHOW_LEGACY;
+ flags |= scalable ? OS.PHFONT_SCALABLE : OS.PHFONT_BITMAP;
+ int nfonts = OS.PfQueryFonts(OS.PHFONT_ALL_SYMBOLS, flags, 0, 0);
+ if (nfonts <= 0) return new FontData[0];
+ int list_ptr = OS.malloc(nfonts * FontDetails.sizeof);
+ nfonts = OS.PfQueryFonts(OS.PHFONT_ALL_SYMBOLS, 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);
+ char[] chars = Converter.mbcsToWcs(null, details.desc);
+ int index = 0;
+ while (index < chars.length) {
+ if (chars[index] == 0) break;
+ index++;
+ }
+ String name = new String(chars, 0, index);
+ if (faceName == null || Compatibility.equalsIgnoreCase(faceName, 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;
+}
+
/**
* Returns the matching standard color for the given
* constant, which should be one of the color constants
@@ -331,30 +331,30 @@ public FontData [] getFontList (String faceName, boolean scalable) {
*
* @see SWT
*/
-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 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);
+}
+
/**
* Returns a reasonable font for applications to use.
* On some platforms, this will match the "default font"
@@ -375,11 +375,11 @@ public Color getSystemColor (int id) {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Font getSystemFont () {
- checkDevice ();
- return Font.photon_new (this, systemFont);
-}
-
+public Font getSystemFont () {
+ checkDevice ();
+ return Font.photon_new (this, systemFont);
+}
+
/**
* Returns <code>true</code> if the underlying window system prints out
* warning messages on the console, and <code>setWarnings</code>
@@ -391,14 +391,14 @@ public Font getSystemFont () {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public boolean getWarnings () {
- checkDevice ();
- return false;
-}
-
-protected void init () {
-}
-
+public boolean getWarnings () {
+ checkDevice ();
+ return false;
+}
+
+protected void init () {
+}
+
/**
* Invokes platform specific functionality to allocate a new GC handle.
* <p>
@@ -414,8 +414,8 @@ protected void init () {
*
* @private
*/
-public abstract int internal_new_GC (GCData data);
-
+public abstract int internal_new_GC (GCData data);
+
/**
* Invokes platform specific functionality to dispose a GC handle.
* <p>
@@ -431,8 +431,8 @@ public abstract int internal_new_GC (GCData data);
*
* @private
*/
-public abstract void internal_dispose_GC (int handle, GCData data);
-
+public abstract void internal_dispose_GC (int handle, GCData data);
+
/**
* Returns <code>true</code> if the device has been disposed,
* and <code>false</code> otherwise.
@@ -443,31 +443,31 @@ public abstract void internal_dispose_GC (int handle, GCData data);
*
* @return <code>true</code> when the device is disposed and <code>false</code> otherwise
*/
-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 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 () {
+}
+
/**
* If the underlying window system supports printing warning messages
* to the console, setting warnings to <code>true</code> prevents these
@@ -480,8 +480,8 @@ protected void release () {
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setWarnings (boolean warnings) {
- checkDevice ();
-}
-
+public void setWarnings (boolean warnings) {
+ checkDevice ();
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/DeviceData.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/DeviceData.java
index 06e99bb30c..d36b10ff4a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/DeviceData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/DeviceData.java
@@ -1,19 +1,19 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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;
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java
index c5923cca91..c2ce18ab7c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
/**
* Instances of this class manage operating system resources that
* define how text looks when it is displayed. Fonts may be constructed
@@ -24,22 +24,22 @@ import org.eclipse.swt.*;
*
* @see FontData
*/
-public final class Font {
-
- /**
- * the handle to the OS font resource
- * (Warning: This field is platform dependent)
+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
+ public byte[] handle;
+
+ /**
+ * the device where this font was created
*/
- Device device;
-
-Font() {
-}
-
+ Device device;
+
+Font() {
+}
+
/**
* Constructs a new font given a device and font data
* which describes the desired font's appearance.
@@ -58,44 +58,44 @@ Font() {
* <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li>
* </ul>
*/
-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);
-}
-
-/**
- * Constructs a new font given a device and font datas
- * which describes the desired font's appearance.
- * <p>
- * You must dispose the font when it is no longer required.
- * </p>
- *
- * @param device the device to create the font on
- * @param fds the array of FontData that describes the desired font (must not be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
- * <li>ERROR_NULL_ARGUMENT - if the fds argument is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the length of fds is zero</li>
- * <li>ERROR_NULL_ARGUMENT - if any fd in the array is null</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li>
- * </ul>
- */
-public Font(Device device, FontData[] fds) {
- if (device == null) device = Device.getDevice();
- if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (fds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (fds.length == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- FontData fd = fds[0];
- 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, 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);
+}
+
+/**
+ * Constructs a new font given a device and font datas
+ * which describes the desired font's appearance.
+ * <p>
+ * You must dispose the font when it is no longer required.
+ * </p>
+ *
+ * @param device the device to create the font on
+ * @param fds the array of FontData that describes the desired font (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * <li>ERROR_NULL_ARGUMENT - if the fds argument is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the length of fds is zero</li>
+ * <li>ERROR_NULL_ARGUMENT - if any fd in the array is null</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li>
+ * </ul>
+ */
+public Font(Device device, FontData[] fds) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (fds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (fds.length == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ FontData fd = fds[0];
+ 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);
+}
/**
* Constructs a new font given a device, a font name,
* the height of the desired font in points, and a font
@@ -118,28 +118,28 @@ public Font(Device device, FontData[] fds) {
* <li>ERROR_NO_HANDLES - if a font could not be created from the given arguments</li>
* </ul>
*/
-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 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);
+}
+
/**
* Disposes of the operating system resources associated with
* the font. Applications must dispose of all fonts which
* they allocate.
*/
-public void dispose() {
- if (handle == null) return;
- if (device.isDisposed()) return;
-
- handle = null;
- if (device.tracking) device.dispose_Object(this);
- device = null;
-}
-
+public void dispose() {
+ if (handle == null) return;
+ if (device.isDisposed()) return;
+
+ handle = null;
+ if (device.tracking) device.dispose_Object(this);
+ device = null;
+}
+
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -150,20 +150,20 @@ public void dispose() {
*
* @see #hashCode
*/
-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<h.length; i++) {
- if (handle[i] != h[i]) return false;
- if (handle[i] == 0) break;
- }
- return true;
-}
-
+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<h.length; i++) {
+ if (handle[i] != h[i]) return false;
+ if (handle[i] == 0) break;
+ }
+ return true;
+}
+
/**
* Returns an array of <code>FontData</code>s representing the receiver.
* On Windows, only one FontData will be returned per font. On X however,
@@ -176,11 +176,11 @@ public boolean equals(Object object) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public FontData[] getFontData() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return new FontData[]{new FontData(handle)};
-}
-
+public FontData[] getFontData() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return new FontData[]{new FontData(handle)};
+}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -191,11 +191,11 @@ public FontData[] getFontData() {
*
* @see #equals
*/
-public int hashCode () {
- if (handle == null) return 0;
- return handle.hashCode();
-}
-
+public int hashCode () {
+ if (handle == null) return 0;
+ return handle.hashCode();
+}
+
/**
* Returns <code>true</code> if the font has been disposed,
* and <code>false</code> otherwise.
@@ -206,61 +206,61 @@ public int hashCode () {
*
* @return <code>true</code> when the font is disposed and <code>false</code> otherwise
*/
-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_INVALID_ARGUMENT);
- this.device = device;
- if (stem != null) {
- handle = stem;
- } else {
- byte[] description = 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) {
- byte[] defaultFont = device.systemFont;
- int fontID = OS.PfDecomposeStemToID(defaultFont);
- if (fontID != 0) {
- int desc = OS.PfFontDescription(fontID);
- int length = OS.strlen(desc);
- byte[] defaultFontName = new byte[length + 1];
- OS.memmove(defaultFontName, desc, length);
- OS.PfFreeFont(fontID);
- handle = OS.PfGenerateFontName(defaultFontName, osStyle, height, buffer);
- }
- if (handle == null) handle = defaultFont;
- }
- }
- if (handle == null)SWT.error(SWT.ERROR_NO_HANDLES);
-}
-
-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;
-}
-
+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_INVALID_ARGUMENT);
+ this.device = device;
+ if (stem != null) {
+ handle = stem;
+ } else {
+ byte[] description = 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) {
+ byte[] defaultFont = device.systemFont;
+ int fontID = OS.PfDecomposeStemToID(defaultFont);
+ if (fontID != 0) {
+ int desc = OS.PfFontDescription(fontID);
+ int length = OS.strlen(desc);
+ byte[] defaultFontName = new byte[length + 1];
+ OS.memmove(defaultFontName, desc, length);
+ OS.PfFreeFont(fontID);
+ handle = OS.PfGenerateFontName(defaultFontName, osStyle, height, buffer);
+ }
+ if (handle == null) handle = defaultFont;
+ }
+ }
+ if (handle == null)SWT.error(SWT.ERROR_NO_HANDLES);
+}
+
+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;
+}
+
/**
* Returns a string containing a concise, human-readable
* description of the receiver.
*
* @return a string representation of the receiver
*/
-public String toString () {
- if (isDisposed()) return "Font {*DISPOSED*}";
- int index = 0;
- while (index < handle.length) {
- if (handle[index] == 0) break;
- index++;
- }
- String text = new String(handle, 0, index);
- return "Font {" + text + "}";
-}
-
+public String toString () {
+ if (isDisposed()) return "Font {*DISPOSED*}";
+ int index = 0;
+ while (index < handle.length) {
+ if (handle[index] == 0) break;
+ index++;
+ }
+ String text = new String(handle, 0, index);
+ return "Font {" + text + "}";
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java
index 70731d5e22..807a35987f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
/**
* Instances of this class describe operating system fonts.
* Only the public API of this type is platform independent.
@@ -36,64 +36,64 @@ import org.eclipse.swt.*;
*
* @see Font
*/
-public final class FontData {
-
- /**
- * the font name
- * (Warning: This field is platform dependent)
+public final class FontData {
+
+ /**
+ * the font name
+ * (Warning: This field is platform dependent)
*/
- public String name;
-
+ public String name;
+
/**
* The height of the font data in points
* (Warning: This field is platform dependent)
*/
- public int height;
-
- /**
- * the font style
- * (Warning: This field is platform dependent)
+ public int height;
+
+ /**
+ * the font style
+ * (Warning: This field is platform dependent)
*/
- public int style;
-
- /**
- * A Photon stem
- * (Warning: This field is platform dependent)
+ public int style;
+
+ /**
+ * A Photon stem
+ * (Warning: This field is platform dependent)
*/
- public byte[] stem;
-
- /**
- * The locales of the font
- * (Warning: These fields are platform dependent)
+ public byte[] stem;
+
+ /**
+ * The locales of the font
+ * (Warning: These fields are platform dependent)
*/
- String lang, country, variant;
-
-FontData(byte[] stem) {
- this.stem = stem;
- int fontID = OS.PfDecomposeStemToID(stem);
- if (fontID != 0) {
- int desc = OS.PfFontDescription(fontID);
- int size = OS.PfFontSize(fontID);
- int flags = OS.PfFontFlags(fontID);
- int length = OS.strlen(desc);
- byte[] buffer = new byte[length];
- OS.memmove(buffer, desc, length);
- name = new String(Converter.mbcsToWcs(null, buffer));
- height = size;
- style = SWT.NORMAL;
- if ((flags & OS.PF_STYLE_BOLD) != 0) style |= SWT.BOLD;
- if ((flags & OS.PF_STYLE_ITALIC) != 0) style |= SWT.ITALIC;
- OS.PfFreeFont(fontID);
- }
-}
-
+ String lang, country, variant;
+
+FontData(byte[] stem) {
+ this.stem = stem;
+ int fontID = OS.PfDecomposeStemToID(stem);
+ if (fontID != 0) {
+ int desc = OS.PfFontDescription(fontID);
+ int size = OS.PfFontSize(fontID);
+ int flags = OS.PfFontFlags(fontID);
+ int length = OS.strlen(desc);
+ byte[] buffer = new byte[length];
+ OS.memmove(buffer, desc, length);
+ name = new String(Converter.mbcsToWcs(null, buffer));
+ height = size;
+ style = SWT.NORMAL;
+ if ((flags & OS.PF_STYLE_BOLD) != 0) style |= SWT.BOLD;
+ if ((flags & OS.PF_STYLE_ITALIC) != 0) style |= SWT.ITALIC;
+ OS.PfFreeFont(fontID);
+ }
+}
+
/**
* Constructs a new un-initialized font data.
*/
-public FontData() {
- this("", 12, SWT.NORMAL);
-}
-
+public FontData() {
+ this("", 12, SWT.NORMAL);
+}
+
/**
* Constructs a new FontData given a string representation
* in the form generated by the <code>FontData.toString</code>
@@ -113,61 +113,61 @@ public FontData() {
*
* @see #toString
*/
-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);
- try {
- if (Integer.parseInt(version1) != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- } 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);
- 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 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);
+ try {
+ if (Integer.parseInt(version1) != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ } 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);
+ 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;
+ }
+}
+
/**
* Constructs a new font data given a font name,
* the height of the desired font in points,
@@ -182,12 +182,12 @@ public FontData(String string) {
* <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
* </ul>
*/
-public FontData(String name, int height, int style) {
- setName(name);
- setHeight(height);
- setStyle(style);
-}
-
+public FontData(String name, int height, int style) {
+ setName(name);
+ setHeight(height);
+ setStyle(style);
+}
+
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -198,13 +198,13 @@ public FontData(String name, int height, int style) {
*
* @see #hashCode
*/
-public boolean equals (Object object) {
- if (object == this) return true;
- if (!(object instanceof FontData)) return false;
- FontData data = (FontData)object;
- return name.equals(data.name) && height == data.height && style == data.style;
-}
-
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof FontData)) return false;
+ FontData data = (FontData)object;
+ return name.equals(data.name) && height == data.height && style == data.style;
+}
+
/**
* Returns the height of the receiver in points.
*
@@ -212,10 +212,10 @@ public boolean equals (Object object) {
*
* @see #setHeight
*/
-public int getHeight() {
- return height;
-}
-
+public int getHeight() {
+ return height;
+}
+
/**
* Returns the name of the receiver.
* On platforms that support font foundries, the return value will
@@ -225,10 +225,10 @@ public int getHeight() {
*
* @see #setName
*/
-public String getName() {
- return name;
-}
-
+public String getName() {
+ return name;
+}
+
/**
* Returns the style of the receiver which is a bitwise OR of
* one or more of the <code>SWT</code> constants NORMAL, BOLD
@@ -238,10 +238,10 @@ public String getName() {
*
* @see #setStyle
*/
-public int getStyle() {
- return style;
-}
-
+public int getStyle() {
+ return style;
+}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -252,10 +252,10 @@ public int getStyle() {
*
* @see #equals
*/
-public int hashCode () {
- return name.hashCode() ^ height ^ style;
-}
-
+public int hashCode () {
+ return name.hashCode() ^ height ^ style;
+}
+
/**
* Sets the height of the receiver. The parameter is
* specified in terms of points, where a point is one
@@ -269,12 +269,12 @@ public int hashCode () {
*
* @see #getHeight
*/
-public void setHeight(int height) {
- if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- this.height = height;
- this.stem = null;
-}
-
+public void setHeight(int height) {
+ if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ this.height = height;
+ this.stem = null;
+}
+
/**
* Sets the name of the receiver.
* <p>
@@ -300,49 +300,49 @@ public void setHeight(int height) {
*
* @see #getName
*/
-public void setName(String name) {
- if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- this.name = name;
- this.stem = null;
-}
-
-/**
- * Sets the locale of the receiver.
- * <p>
- * The locale determines which platform character set this
- * font is going to use. Widgets and graphics operations that
- * use this font will convert UNICODE strings to the platform
- * character set of the specified locale.
- * </p>
- * <p>
- * On platforms which there are multiple character sets for a
- * given language/country locale, the variant portion of the
- * locale will determine the character set.
- * </p>
- *
- * @param locale the <code>String</code> representing a Locale object
- * @see java.util.Locale#toString
+public void setName(String name) {
+ if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.name = name;
+ this.stem = null;
+}
+
+/**
+ * Sets the locale of the receiver.
+ * <p>
+ * The locale determines which platform character set this
+ * font is going to use. Widgets and graphics operations that
+ * use this font will convert UNICODE strings to the platform
+ * character set of the specified locale.
+ * </p>
+ * <p>
+ * On platforms which there are multiple character sets for a
+ * given language/country locale, the variant portion of the
+ * locale will determine the character set.
+ * </p>
+ *
+ * @param locale the <code>String</code> representing a Locale object
+ * @see java.util.Locale#toString
*/
-public void setLocale(String locale) {
- lang = country = variant = null;
- if (locale != null) {
- char sep = '_';
- int length = locale.length();
- int firstSep, secondSep;
-
- firstSep = locale.indexOf(sep);
- if (firstSep == -1) {
- firstSep = secondSep = length;
- } else {
- secondSep = locale.indexOf(sep, firstSep + 1);
- if (secondSep == -1) secondSep = length;
- }
- if (firstSep > 0) lang = locale.substring(0, firstSep);
- if (secondSep > firstSep + 1) country = locale.substring(firstSep + 1, secondSep);
- if (length > secondSep + 1) variant = locale.substring(secondSep + 1);
- }
-}
-
+public void setLocale(String locale) {
+ lang = country = variant = null;
+ if (locale != null) {
+ char sep = '_';
+ int length = locale.length();
+ int firstSep, secondSep;
+
+ firstSep = locale.indexOf(sep);
+ if (firstSep == -1) {
+ firstSep = secondSep = length;
+ } else {
+ secondSep = locale.indexOf(sep, firstSep + 1);
+ if (secondSep == -1) secondSep = length;
+ }
+ if (firstSep > 0) lang = locale.substring(0, firstSep);
+ if (secondSep > firstSep + 1) country = locale.substring(firstSep + 1, secondSep);
+ if (length > secondSep + 1) variant = locale.substring(secondSep + 1);
+ }
+}
+
/**
* Sets the style of the receiver to the argument which must
* be a bitwise OR of one or more of the <code>SWT</code>
@@ -352,11 +352,11 @@ public void setLocale(String locale) {
*
* @see #getStyle
*/
-public void setStyle(int style) {
- this.style = style;
- this.stem = null;
-}
-
+public void setStyle(int style) {
+ this.style = style;
+ this.stem = null;
+}
+
/**
* Returns a string representation of the receiver which is suitable
* for constructing an equivalent instance using the
@@ -366,21 +366,21 @@ public void setStyle(int style) {
*
* @see FontData
*/
-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);
-}
-
+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);
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java
index e51fb26cca..2f031d852a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+
/**
* Instances of this class provide measurement information
* about fonts including ascent, descent, height, leading
@@ -18,18 +18,18 @@ import org.eclipse.swt.internal.photon.*;
*
* @see GC#getFontMetrics
*/
-public final class FontMetrics {
-
+public final class FontMetrics {
+
/**
* On Windows, handle is a Win32 TEXTMETRIC struct
* On Photon, handle is a Photon FontQueryInfo struct
* (Warning: This field is platform dependent)
*/
- public FontQueryInfo handle;
-
-FontMetrics() {
-}
-
+ public FontQueryInfo handle;
+
+FontMetrics() {
+}
+
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -40,33 +40,33 @@ FontMetrics() {
*
* @see #hashCode
*/
-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.desc.length - 1; i >= 0; i--) {
- if (handle.desc[i] != info.desc[i]) return false;
- }
- for (int i = handle.font.length - 1; i >= 0; i--) {
- if (handle.font[i] != info.font[i]) return false;
- }
- return true;
- }
- return false;
-}
-
+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.desc.length - 1; i >= 0; i--) {
+ if (handle.desc[i] != info.desc[i]) return false;
+ }
+ for (int i = handle.font.length - 1; i >= 0; i--) {
+ if (handle.font[i] != info.font[i]) return false;
+ }
+ return true;
+ }
+ return false;
+}
+
/**
* Returns the ascent of the font described by the receiver. A
* font's <em>ascent</em> is the distance from the baseline to the
@@ -75,21 +75,21 @@ public boolean equals (Object object) {
*
* @return the ascent of the font
*/
-public int getAscent() {
- return -handle.ascender;
-}
-
+public int getAscent() {
+ return -handle.ascender;
+}
+
/**
* Returns the average character width, measured in pixels,
* of the font described by the receiver.
*
* @return the average character width of the font
*/
-public int getAverageCharWidth() {
- if ((handle.style & OS.PHFONT_INFO_FIXED) != 0) return handle.width;
- return handle.width / 3;
-}
-
+public int getAverageCharWidth() {
+ if ((handle.style & OS.PHFONT_INFO_FIXED) != 0) return handle.width;
+ return handle.width / 3;
+}
+
/**
* Returns the descent of the font described by the receiver. A
* font's <em>descent</em> is the distance from the baseline to the
@@ -98,10 +98,10 @@ public int getAverageCharWidth() {
*
* @return the descent of the font
*/
-public int getDescent() {
- return handle.descender;
-}
-
+public int getDescent() {
+ return handle.descender;
+}
+
/**
* Returns the height of the font described by the receiver,
* measured in pixels. A font's <em>height</em> is the sum of
@@ -113,10 +113,10 @@ public int getDescent() {
* @see #getDescent
* @see #getLeading
*/
-public int getHeight() {
- return -handle.ascender + handle.descender;
-}
-
+public int getHeight() {
+ return -handle.ascender + handle.descender;
+}
+
/**
* Returns the leading area of the font described by the
* receiver. A font's <em>leading area</em> is the space
@@ -124,10 +124,10 @@ public int getHeight() {
*
* @return the leading space of the font
*/
-public int getLeading() {
- return 0;
-}
-
+public int getLeading() {
+ return 0;
+}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -138,17 +138,17 @@ public int getLeading() {
*
* @see #equals
*/
-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;
-}
+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;
+}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java
index f49d994520..50b6168d27 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
/**
* Class <code>GC</code> is where all of the drawing capabilities that are
* supported by SWT are located. Instances are used to draw on either an
@@ -25,41 +25,41 @@ import org.eclipse.swt.*;
*
* @see org.eclipse.swt.events.PaintEvent
*/
-public final class GC {
+public final class GC {
/**
* the handle to the OS device context
* (Warning: This field is platform dependent)
*/
- public int handle;
-
- Drawable drawable;
- GCData data;
-
- int dirtyBits;
-
- 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;
-
- static final int DIRTY_BACKGROUND = 1 << 0;
- static final int DIRTY_FOREGROUND = 1 << 1;
- static final int DIRTY_CLIPPING = 1 << 2;
- static final int DIRTY_FONT = 1 << 3;
- static final int DIRTY_LINESTYLE = 1 << 4;
- static final int DIRTY_LINEWIDTH = 1 << 5;
- static final int DIRTY_XORMODE = 1 << 6;
-
-GC() {
-}
-
+ public int handle;
+
+ Drawable drawable;
+ GCData data;
+
+ int dirtyBits;
+
+ 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;
+
+ static final int DIRTY_BACKGROUND = 1 << 0;
+ static final int DIRTY_FOREGROUND = 1 << 1;
+ static final int DIRTY_CLIPPING = 1 << 2;
+ static final int DIRTY_FONT = 1 << 3;
+ static final int DIRTY_LINESTYLE = 1 << 4;
+ static final int DIRTY_LINEWIDTH = 1 << 5;
+ static final int DIRTY_XORMODE = 1 << 6;
+
+GC() {
+}
+
/**
* Constructs a new instance of this class which has been
* configured to draw on the specified drawable. Sets the
@@ -81,23 +81,23 @@ GC() {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li>
* </ul>
*/
-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 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);
+ }
+}
+
/**
* Copies a rectangular area of the receiver at the specified
* position into the image, which must be of type <code>SWT.BITMAP</code>.
@@ -113,67 +113,67 @@ public GC(Drawable drawable) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void copyArea(Image image, int x, int y) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (image.type != SWT.BITMAP || image.isDisposed()) 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);
- int prevContext = 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);
- OS.PhDCSetCurrent(prevContext);
- 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(Image image, int x, int y) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (image.type != SWT.BITMAP || image.isDisposed()) 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);
+ int prevContext = 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);
+ OS.PhDCSetCurrent(prevContext);
+ 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);
+ }
+}
+
/**
* Copies a rectangular area of the receiver at the source
* position onto the receiver at the destination position.
@@ -189,165 +189,165 @@ public void copyArea(Image image, int x, int y) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void copyArea(int x, int y, int width, int height, int destX, int destY) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (width == 0 || height == 0) return;
- int deltaX = destX - x, deltaY = destY - y;
- if (deltaX == 0 && deltaY == 0) return;
-
- 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);
- int prevContext = 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);
- OS.PhDCSetCurrent(prevContext);
- 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) {
- 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;
- int child_clip = getClipping(widget, data.topWidget, true, true, null);
- if (clipRects == 0 && child_clip == 0) {
- OS.PtBlit(widget, rect, delta);
- } else {
- int srcTile = OS.PhGetTile();
- OS.memmove(srcTile, rect, PhRect_t.sizeof);
- int clip = child_clip;
- if (clipRects != 0) {
- clip = OS.PhRectsToTiles(clipRects, data.clipRectsCount);
- if (child_clip != 0) {
- short[] unused = new short[1];
- int newClip = OS.PhIntersectTilings(clip, child_clip, unused);
- OS.PhFreeTiles(child_clip);
- OS.PhFreeTiles(clip);
- clip = newClip;
- }
- }
- OS.PtClippedBlit(widget, srcTile, delta, clip);
- OS.PhFreeTiles(clip);
- }
- }
- } finally {
- if (flags >= 0) OS.PtLeave(flags);
- }
-}
-
+public void copyArea(int x, int y, int width, int height, int destX, int destY) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (width == 0 || height == 0) return;
+ int deltaX = destX - x, deltaY = destY - y;
+ if (deltaX == 0 && deltaY == 0) return;
+
+ 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);
+ int prevContext = 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);
+ OS.PhDCSetCurrent(prevContext);
+ 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) {
+ 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;
+ int child_clip = getClipping(widget, data.topWidget, true, true, null);
+ if (clipRects == 0 && child_clip == 0) {
+ OS.PtBlit(widget, rect, delta);
+ } else {
+ int srcTile = OS.PhGetTile();
+ OS.memmove(srcTile, rect, PhRect_t.sizeof);
+ int clip = child_clip;
+ if (clipRects != 0) {
+ clip = OS.PhRectsToTiles(clipRects, data.clipRectsCount);
+ if (child_clip != 0) {
+ short[] unused = new short[1];
+ int newClip = OS.PhIntersectTilings(clip, child_clip, unused);
+ OS.PhFreeTiles(child_clip);
+ OS.PhFreeTiles(clip);
+ clip = newClip;
+ }
+ }
+ OS.PtClippedBlit(widget, srcTile, delta, clip);
+ OS.PhFreeTiles(clip);
+ }
+ }
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
/**
* Disposes of the operating system resources associated with
* the graphics context. Applications must dispose of all GCs
* which they allocate.
*/
-public void dispose() {
- int flags = OS.PtEnter(0);
- try {
- if (handle == 0) return;
- if (data.device.isDisposed()) return;
-
- int clipRects = data.clipRects;
- if (clipRects != 0) {
- OS.free(clipRects);
- data.clipRects = data.clipRectsCount = 0;
- }
- Image image = data.image;
- if (image != null) {
- flushImage();
- /* Regenerate the mask if necessary */
- if (image.transparentPixel != -1) {
- PhImage_t phImage = new PhImage_t ();
- OS.memmove(phImage, image.handle, PhImage_t.sizeof);
- if (phImage.mask_bm == 0) {
- createMask(image.handle, phImage.type, image.transparentPixel);
- }
- }
- 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 dispose() {
+ int flags = OS.PtEnter(0);
+ try {
+ if (handle == 0) return;
+ if (data.device.isDisposed()) return;
+
+ int clipRects = data.clipRects;
+ if (clipRects != 0) {
+ OS.free(clipRects);
+ data.clipRects = data.clipRectsCount = 0;
+ }
+ Image image = data.image;
+ if (image != null) {
+ flushImage();
+ /* Regenerate the mask if necessary */
+ if (image.transparentPixel != -1) {
+ PhImage_t phImage = new PhImage_t ();
+ OS.memmove(phImage, image.handle, PhImage_t.sizeof);
+ if (phImage.mask_bm == 0) {
+ createMask(image.handle, phImage.type, image.transparentPixel);
+ }
+ }
+ 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);
+ }
+}
+
/**
* Draws the outline of a circular or elliptical arc
* within the specified rectangular area.
@@ -380,65 +380,65 @@ public void dispose() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawArc (int x, int y, int width, int height, int startAngle, int endAngle) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (width < 0) {
- x = x + width;
- width = -width;
- }
- if (height < 0) {
- y = y + height;
- height = -height;
- }
- if (width == 0 || height == 0 || endAngle == 0) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- if (startAngle > 0) {
- if (endAngle > 0) {
- //No need to modify start angle.
- 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);
-
- 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 drawArc (int x, int y, int width, int height, int startAngle, int endAngle) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ if (width == 0 || height == 0 || endAngle == 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (startAngle > 0) {
+ if (endAngle > 0) {
+ //No need to modify start angle.
+ 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);
+
+ 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);
+ }
+}
+
/**
* Draws a rectangle, based on the specified arguments, which has
* the appearance of the platform's <em>focus rectangle</em> if the
@@ -456,23 +456,23 @@ public void drawArc (int x, int y, int width, int height, int startAngle, int en
*
* @see #drawRectangle
*/
-public void drawFocus (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- int flags = OS.PtEnter(0);
- try {
- int prevContext = setGC();
- setGCClipping();
- if (width < 0) width -= width;
- if (height < 0) height -= height;
- OS.PgSetStrokeColor(0x9098F8);
- OS.PgDrawIRect(x, y, x + width - 1, y + height - 1, OS.Pg_DRAW_STROKE);
- OS.PgSetStrokeColor(data.foreground);
- unsetGC(prevContext);
- } finally {
- if (flags >= 0) OS.PtLeave(flags);
- }
-}
-
+public void drawFocus (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ if (width < 0) width -= width;
+ if (height < 0) height -= height;
+ OS.PgSetStrokeColor(0x9098F8);
+ OS.PgDrawIRect(x, y, x + width - 1, y + height - 1, OS.Pg_DRAW_STROKE);
+ OS.PgSetStrokeColor(data.foreground);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
/**
* Draws the given image in the receiver at the specified
* coordinates.
@@ -492,379 +492,379 @@ public void drawFocus (int x, int y, int width, int height) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawImage(Image image, int x, int y) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (image.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true);
-}
-
-/**
- * Copies a rectangular area from the source image into a (potentially
- * different sized) rectangular area in the receiver. If the source
- * and destination areas are of differing sizes, then the source
- * area will be stretched or shrunk to fit the destination area
- * as it is copied. The copy fails if any part of the source rectangle
- * lies outside the bounds of the source image, or if any of the width
- * or height arguments are negative.
- *
- * @param image the source image
- * @param srcX the x coordinate in the source image to copy from
- * @param srcY the y coordinate in the source image to copy from
- * @param srcWidth the width in pixels to copy from the source
- * @param srcHeight the height in pixels to copy from the source
- * @param destX the x coordinate in the destination to copy to
- * @param destY the y coordinate in the destination to copy to
- * @param destWidth the width in pixels of the destination rectangle
- * @param destHeight the height in pixels of the destination rectangle
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the image is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * <li>ERROR_INVALID_ARGUMENT - if any of the width or height arguments are negative.
- * <li>ERROR_INVALID_ARGUMENT - if the source rectangle is not contained within the bounds of the source image</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+public void drawImage(Image image, int x, int y) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (image.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true);
+}
+
+/**
+ * Copies a rectangular area from the source image into a (potentially
+ * different sized) rectangular area in the receiver. If the source
+ * and destination areas are of differing sizes, then the source
+ * area will be stretched or shrunk to fit the destination area
+ * as it is copied. The copy fails if any part of the source rectangle
+ * lies outside the bounds of the source image, or if any of the width
+ * or height arguments are negative.
+ *
+ * @param image the source image
+ * @param srcX the x coordinate in the source image to copy from
+ * @param srcY the y coordinate in the source image to copy from
+ * @param srcWidth the width in pixels to copy from the source
+ * @param srcHeight the height in pixels to copy from the source
+ * @param destX the x coordinate in the destination to copy to
+ * @param destY the y coordinate in the destination to copy to
+ * @param destWidth the width in pixels of the destination rectangle
+ * @param destHeight the height in pixels of the destination rectangle
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the image is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * <li>ERROR_INVALID_ARGUMENT - if any of the width or height arguments are negative.
+ * <li>ERROR_INVALID_ARGUMENT - if the source rectangle is not contained within the bounds of the source image</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
-public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (srcWidth == 0 || srcHeight == 0 || destWidth == 0 || destHeight == 0) return;
- if (srcX < 0 || srcY < 0 || srcWidth < 0 || srcHeight < 0 || destWidth < 0 || destHeight < 0) {
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- }
- if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- if (image.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false);
-}
-void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) {
- int flags = OS.PtEnter(0);
- try {
- if (image.memGC != null) image.memGC.flushImage();
- int drawImage = image.handle;
- 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);
- }
- int prevContext = 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);
- OS.PhDCSetCurrent(prevContext);
-
- 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);
- }
- prevContext = 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.PhDCSetCurrent(prevContext);
- 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) {
- OS.free(palettePtr);
- OS.free(alphaPtr);
- Image.destroyImage(memImage);
- SWT.error(SWT.ERROR_NO_HANDLES);
- }
- mc = OS.PmMemCreateMC(alphaImage, scale, trans);
- if (mc == 0) {
- OS.free(palettePtr);
- OS.free(alphaPtr);
- Image.destroyImage(alphaImage);
- Image.destroyImage(memImage);
- SWT.error(SWT.ERROR_NO_HANDLES);
- }
- prevContext = 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.PhDCSetCurrent(prevContext);
- OS.free(palettePtr);
-
- /* Transfer the image to the scaled image alpha data*/
- PhImage_t phAlphaImage = new PhImage_t();
- OS.memmove(phAlphaImage, alphaImage, PhImage_t.sizeof);
- alpha.src_alpha_map_bpl = (short)phAlphaImage.bpl;
- alpha.src_alpha_map_dim_w = (short)phAlphaImage.bpl;
- alpha.src_alpha_map_dim_h = (short)phAlphaImage.size_h;
- alpha.src_alpha_map_map = phAlphaImage.image;
-
- /* Release the temporary image but not the image data */
- phAlphaImage.image = 0;
- phAlphaImage.bpl = 0;
- phAlphaImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
- OS.memmove(alphaImage, phAlphaImage, PhImage_t.sizeof);
- OS.PhReleaseImage(alphaImage);
- OS.free(alphaImage);
- }
-
- OS.memmove(alphaPtr, alpha, PgAlpha_t.sizeof);
- phMemImage.alpha = alphaPtr;
- OS.memmove(memImage, phMemImage, PhImage_t.sizeof);
- }
- return memImage;
-}
-
+public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (srcWidth == 0 || srcHeight == 0 || destWidth == 0 || destHeight == 0) return;
+ if (srcX < 0 || srcY < 0 || srcWidth < 0 || srcHeight < 0 || destWidth < 0 || destHeight < 0) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (image.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false);
+}
+void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) {
+ int flags = OS.PtEnter(0);
+ try {
+ if (image.memGC != null) image.memGC.flushImage();
+ int drawImage = image.handle;
+ 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);
+ }
+ int prevContext = 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);
+ OS.PhDCSetCurrent(prevContext);
+
+ 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);
+ }
+ prevContext = 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.PhDCSetCurrent(prevContext);
+ 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) {
+ OS.free(palettePtr);
+ OS.free(alphaPtr);
+ Image.destroyImage(memImage);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ mc = OS.PmMemCreateMC(alphaImage, scale, trans);
+ if (mc == 0) {
+ OS.free(palettePtr);
+ OS.free(alphaPtr);
+ Image.destroyImage(alphaImage);
+ Image.destroyImage(memImage);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ prevContext = 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.PhDCSetCurrent(prevContext);
+ OS.free(palettePtr);
+
+ /* Transfer the image to the scaled image alpha data*/
+ PhImage_t phAlphaImage = new PhImage_t();
+ OS.memmove(phAlphaImage, alphaImage, PhImage_t.sizeof);
+ alpha.src_alpha_map_bpl = (short)phAlphaImage.bpl;
+ alpha.src_alpha_map_dim_w = (short)phAlphaImage.bpl;
+ alpha.src_alpha_map_dim_h = (short)phAlphaImage.size_h;
+ alpha.src_alpha_map_map = phAlphaImage.image;
+
+ /* Release the temporary image but not the image data */
+ phAlphaImage.image = 0;
+ phAlphaImage.bpl = 0;
+ phAlphaImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
+ OS.memmove(alphaImage, phAlphaImage, PhImage_t.sizeof);
+ OS.PhReleaseImage(alphaImage);
+ OS.free(alphaImage);
+ }
+
+ OS.memmove(alphaPtr, alpha, PgAlpha_t.sizeof);
+ phMemImage.alpha = alphaPtr;
+ OS.memmove(memImage, phMemImage, PhImage_t.sizeof);
+ }
+ return memImage;
+}
+
/**
* Draws a line, using the foreground color, between the points
* (<code>x1</code>, <code>y1</code>) and (<code>x2</code>, <code>y2</code>).
@@ -878,19 +878,19 @@ static int scaleImage(Image image, PhImage_t phImage, int srcX, int srcY, int sr
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawLine (int x1, int y1, int x2, int y2) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- int flags = OS.PtEnter(0);
- try {
- int prevContext = setGC();
- setGCClipping();
- OS.PgDrawILine(x1, y1, x2, y2);
- unsetGC(prevContext);
- } finally {
- if (flags >= 0) OS.PtLeave(flags);
- }
-}
-
+public void drawLine (int x1, int y1, int x2, int y2) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawILine(x1, y1, x2, y2);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
/**
* Draws the outline of an oval, using the foreground color,
* within the specified rectangular area.
@@ -912,25 +912,25 @@ public void drawLine (int x1, int y1, int x2, int y2) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawOval (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- PhPoint_t center = new PhPoint_t();
- center.x = (short)x; center.y = (short)y;
- PhPoint_t radii = new PhPoint_t();
- // 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 drawOval (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ PhPoint_t center = new PhPoint_t();
+ center.x = (short)x; center.y = (short)y;
+ PhPoint_t radii = new PhPoint_t();
+ // 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);
+ }
+}
+
/**
* Draws the closed polygon which is defined by the specified array
* of integer coordinates, using the receiver's foreground color. The array
@@ -948,26 +948,26 @@ public void drawOval (int x, int y, int width, int height) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawPolygon(int[] pointArray) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
-
- short[] points = new short[pointArray.length];
- 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 drawPolygon(int[] pointArray) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+
+ short[] points = new short[pointArray.length];
+ 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);
+ }
+}
+
/**
* Draws the polyline which is defined by the specified array
* of integer coordinates, using the receiver's foreground color. The array
@@ -985,26 +985,26 @@ public void drawPolygon(int[] pointArray) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawPolyline(int[] pointArray) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
-
- short[] points = new short[pointArray.length];
- for (int i = pointArray.length - 1; i >= 0; i--) {
- points[i] = (short)pointArray[i];
- }
-
- int flags = OS.PtEnter(0);
- try {
- int prevContext = setGC();
- setGCClipping();
- OS.PgDrawPolygon(points, pointArray.length / 2, new PhPoint_t(), OS.Pg_DRAW_STROKE);
- unsetGC(prevContext);
- } finally {
- if (flags >= 0) OS.PtLeave(flags);
- }
-}
-
+public void drawPolyline(int[] pointArray) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+
+ short[] points = new short[pointArray.length];
+ for (int i = pointArray.length - 1; i >= 0; i--) {
+ points[i] = (short)pointArray[i];
+ }
+
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawPolygon(points, pointArray.length / 2, new PhPoint_t(), OS.Pg_DRAW_STROKE);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
/**
* Draws the outline of the rectangle specified by the arguments,
* using the receiver's foreground color. The left and right edges
@@ -1020,20 +1020,20 @@ public void drawPolyline(int[] pointArray) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawRectangle (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- int flags = OS.PtEnter(0);
- try {
- int prevContext = setGC();
- 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 (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ 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);
+ }
+}
+
/**
* Draws the outline of the specified rectangle, using the receiver's
* foreground color. The left and right edges of the rectangle are at
@@ -1050,11 +1050,11 @@ public void drawRectangle (int x, int y, int width, int height) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-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 drawRectangle (Rectangle rect) {
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ drawRectangle (rect.x, rect.y, rect.width, rect.height);
+}
+
/**
* Draws the outline of the round-cornered rectangle specified by
* the arguments, using the receiver's foreground color. The left and
@@ -1074,26 +1074,26 @@ public void drawRectangle (Rectangle rect) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- PhRect_t rect = new PhRect_t();
- rect.ul_x = (short)x; rect.ul_y = (short)y;
- // Don't subtract one, so that the bottom/right edges are drawn
- 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 drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ PhRect_t rect = new PhRect_t();
+ rect.ul_x = (short)x; rect.ul_y = (short)y;
+ // Don't subtract one, so that the bottom/right edges are drawn
+ 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);
+ }
+}
+
/**
* Draws the given string, using the receiver's current font and
* foreground color. No tab expansion or carriage return processing
@@ -1112,10 +1112,10 @@ public void drawRoundRectangle (int x, int y, int width, int height, int arcWidt
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawString (String string, int x, int y) {
- drawString(string, x, y, false);
-}
-
+public void drawString (String string, int x, int y) {
+ drawString(string, x, y, false);
+}
+
/**
* Draws the given string, using the receiver's current font and
* foreground color. No tab expansion or carriage return processing
@@ -1136,25 +1136,25 @@ public void drawString (String string, int x, int y) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawString (String string, int x, int y, boolean isTransparent) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
-
- int drawFlags = OS.Pg_TEXT_LEFT | OS.Pg_TEXT_TOP;
- 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 drawString (String string, int x, int y, boolean isTransparent) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+
+ int drawFlags = OS.Pg_TEXT_LEFT | OS.Pg_TEXT_TOP;
+ 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);
+ }
+}
+
/**
* Draws the given string, using the receiver's current font and
* foreground color. Tab expansion and carriage return processing
@@ -1173,10 +1173,10 @@ public void drawString (String string, int x, int y, boolean isTransparent) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawText (String string, int x, int y) {
- drawText(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
-}
-
+public void drawText (String string, int x, int y) {
+ drawText(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
+}
+
/**
* Draws the given string, using the receiver's current font and
* foreground color. Tab expansion and carriage return processing
@@ -1197,136 +1197,136 @@ public void drawText (String string, int x, int y) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void drawText (String string, int x, int y, boolean isTransparent) {
- int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB;
- if (isTransparent) flags |= SWT.DRAW_TRANSPARENT;
- drawText(string, x, y, flags);
-}
-
-/**
- * Draws the given string, using the receiver's current font and
- * foreground color. Tab expansion, line delimiter and mnemonic
- * processing are performed according to the specified flags. If
- * <code>flags</code> includes <code>DRAW_TRANSPARENT</code>,
- * then the background of the rectangular area where the text is being
- * drawn will not be modified, otherwise it will be filled with the
- * receiver's background color.
- * <p>
- * The parameter <code>flags</code> may be a combination of:
- * <dl>
- * <dt><b>DRAW_DELIMITER</b></dt>
- * <dd>draw multiple lines</dd>
- * <dt><b>DRAW_TAB</b></dt>
- * <dd>expand tabs</dd>
- * <dt><b>DRAW_MNEMONIC</b></dt>
- * <dd>underline the mnemonic character</dd>
- * <dt><b>DRAW_TRANSPARENT</b></dt>
- * <dd>transparent background</dd>
- * </dl>
- * </p>
- *
- * @param string the string to be drawn
- * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
- * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
- * @param flags the flags specifing how to process the text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+public void drawText (String string, int x, int y, boolean isTransparent) {
+ int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB;
+ if (isTransparent) flags |= SWT.DRAW_TRANSPARENT;
+ drawText(string, x, y, flags);
+}
+
+/**
+ * Draws the given string, using the receiver's current font and
+ * foreground color. Tab expansion, line delimiter and mnemonic
+ * processing are performed according to the specified flags. If
+ * <code>flags</code> includes <code>DRAW_TRANSPARENT</code>,
+ * then the background of the rectangular area where the text is being
+ * drawn will not be modified, otherwise it will be filled with the
+ * receiver's background color.
+ * <p>
+ * The parameter <code>flags</code> may be a combination of:
+ * <dl>
+ * <dt><b>DRAW_DELIMITER</b></dt>
+ * <dd>draw multiple lines</dd>
+ * <dt><b>DRAW_TAB</b></dt>
+ * <dd>expand tabs</dd>
+ * <dt><b>DRAW_MNEMONIC</b></dt>
+ * <dd>underline the mnemonic character</dd>
+ * <dt><b>DRAW_TRANSPARENT</b></dt>
+ * <dd>transparent background</dd>
+ * </dl>
+ * </p>
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param flags the flags specifing how to process the text
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
-public void drawText (String string, int x, int y, int flags) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if ((flags & ~SWT.DRAW_TRANSPARENT) == 0) {
- drawString(string, x, y, (flags & SWT.DRAW_TRANSPARENT) != 0);
- } else {
- drawText(string, x, y, flags, true);
- }
-}
-
-Point drawText(String text, int x, int y, int flags, boolean draw) {
- /* NOT DONE - inline code for performance */
-
- int length = text.length();
- char[] buffer = new char[length];
- text.getChars(0, length, buffer, 0);
-
- /* NOT DONE - tabstops */
- int spaceWidth = stringExtent(" ").x;
- int tabWidth = spaceWidth *8 + 1;
-
- boolean transparent = (flags & SWT.DRAW_TRANSPARENT) != 0;
- int mnemonic = -1;
- int start = 0, i = 0, j = 0;
- int initialX = x, initialY = y;
- int maxX = x, maxY = y;
- while (i < length) {
- char c = buffer[j] = buffer[i];
- switch (c) {
- case '\t': {
- if ((flags & SWT.DRAW_TAB) == 0) break;
- String string = new String(buffer, start, j - start);
- if (draw) drawString(string, x, y, transparent);
- Point extent = stringExtent(string);
- x += extent.x + tabWidth;
- maxX = Math.max(x, maxX);
- maxY = Math.max(y + extent.y, maxY);
- start = j + 1;
- break;
- }
- case '\n': {
- if ((flags & SWT.DRAW_DELIMITER) == 0) break;
- String string = new String(buffer, start, j - start);
- if (draw) drawString(string, x, y, transparent);
- Point extent = stringExtent(string);
- maxX = Math.max(x + extent.x, maxX);
- x = initialX;
- y += extent.y;
- maxY = Math.max(y, maxY);
- start = j + 1;
- break;
- }
- case '&': {
- if ((flags & SWT.DRAW_MNEMONIC) == 0) break;
- if (i + 1 == length) break;
- if (buffer[i + 1] == '&') {i++; break;}
- if (mnemonic == -1) {
- mnemonic = i + 1;
- String string = new String(buffer, start, j - start);
- if (draw) drawString(string, x, y, transparent);
- Point extent = stringExtent(string);
- x += extent.x;
- start = mnemonic;
- string = new String(buffer, start, 1);
- if (draw) drawString(string, x, y, transparent);
- extent = stringExtent(string);
- int underlineY = y + extent.y - 1;
- if (draw) drawLine(x, underlineY, x + extent.x, underlineY);
- x += extent.x;
- maxX = Math.max(x, maxX);
- maxY = Math.max(y + extent.y, maxY);
- start = j + 1;
- }
- j--;
- break;
- }
- }
- j++;
- i++;
- }
- if (start != j) {
- String string = new String(buffer, start, j - start);
- if (draw) drawString(string, x, y, transparent);
- Point extent = stringExtent(string);
- maxX = Math.max(x + extent.x, maxX);
- maxY = Math.max(y + extent.y, maxY);
- }
- return new Point(maxX - initialX, maxY - initialY);
-}
-
+public void drawText (String string, int x, int y, int flags) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if ((flags & ~SWT.DRAW_TRANSPARENT) == 0) {
+ drawString(string, x, y, (flags & SWT.DRAW_TRANSPARENT) != 0);
+ } else {
+ drawText(string, x, y, flags, true);
+ }
+}
+
+Point drawText(String text, int x, int y, int flags, boolean draw) {
+ /* NOT DONE - inline code for performance */
+
+ int length = text.length();
+ char[] buffer = new char[length];
+ text.getChars(0, length, buffer, 0);
+
+ /* NOT DONE - tabstops */
+ int spaceWidth = stringExtent(" ").x;
+ int tabWidth = spaceWidth *8 + 1;
+
+ boolean transparent = (flags & SWT.DRAW_TRANSPARENT) != 0;
+ int mnemonic = -1;
+ int start = 0, i = 0, j = 0;
+ int initialX = x, initialY = y;
+ int maxX = x, maxY = y;
+ while (i < length) {
+ char c = buffer[j] = buffer[i];
+ switch (c) {
+ case '\t': {
+ if ((flags & SWT.DRAW_TAB) == 0) break;
+ String string = new String(buffer, start, j - start);
+ if (draw) drawString(string, x, y, transparent);
+ Point extent = stringExtent(string);
+ x += extent.x + tabWidth;
+ maxX = Math.max(x, maxX);
+ maxY = Math.max(y + extent.y, maxY);
+ start = j + 1;
+ break;
+ }
+ case '\n': {
+ if ((flags & SWT.DRAW_DELIMITER) == 0) break;
+ String string = new String(buffer, start, j - start);
+ if (draw) drawString(string, x, y, transparent);
+ Point extent = stringExtent(string);
+ maxX = Math.max(x + extent.x, maxX);
+ x = initialX;
+ y += extent.y;
+ maxY = Math.max(y, maxY);
+ start = j + 1;
+ break;
+ }
+ case '&': {
+ if ((flags & SWT.DRAW_MNEMONIC) == 0) break;
+ if (i + 1 == length) break;
+ if (buffer[i + 1] == '&') {i++; break;}
+ if (mnemonic == -1) {
+ mnemonic = i + 1;
+ String string = new String(buffer, start, j - start);
+ if (draw) drawString(string, x, y, transparent);
+ Point extent = stringExtent(string);
+ x += extent.x;
+ start = mnemonic;
+ string = new String(buffer, start, 1);
+ if (draw) drawString(string, x, y, transparent);
+ extent = stringExtent(string);
+ int underlineY = y + extent.y - 1;
+ if (draw) drawLine(x, underlineY, x + extent.x, underlineY);
+ x += extent.x;
+ maxX = Math.max(x, maxX);
+ maxY = Math.max(y + extent.y, maxY);
+ start = j + 1;
+ }
+ j--;
+ break;
+ }
+ }
+ j++;
+ i++;
+ }
+ if (start != j) {
+ String string = new String(buffer, start, j - start);
+ if (draw) drawString(string, x, y, transparent);
+ Point extent = stringExtent(string);
+ maxX = Math.max(x + extent.x, maxX);
+ maxY = Math.max(y + extent.y, maxY);
+ }
+ return new Point(maxX - initialX, maxY - initialY);
+}
+
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -1337,10 +1337,10 @@ Point drawText(String text, int x, int y, int flags, boolean draw) {
*
* @see #hashCode
*/
-public boolean equals (Object object) {
- return (object == this) || ((object instanceof GC) && (handle == ((GC)object).handle));
-}
-
+public boolean equals (Object object) {
+ return (object == this) || ((object instanceof GC) && (handle == ((GC)object).handle));
+}
+
/**
* Fills the interior of a circular or elliptical arc within
* the specified rectangular area, with the receiver's background
@@ -1376,123 +1376,123 @@ public boolean equals (Object object) {
*
* @see #drawArc
*/
-public void fillArc (int x, int y, int width, int height, int startAngle, int endAngle) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (width < 0) {
- x = x + width;
- width = -width;
- }
- if (height < 0) {
- y = y + height;
- height = -height;
- }
- if (width == 0 || height == 0 || endAngle == 0) {
- SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- }
- if (startAngle > 0) {
- if (endAngle > 0) {
- //No need to modify start angle.
- 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);
-
- 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);
- }
-}
-
-/**
- * Fills the interior of the specified rectangle with a gradient
- * sweeping from left to right or top to bottom progressing
- * from the receiver's foreground color to its background color.
- *
- * @param x the x coordinate of the rectangle to be filled
- * @param y the y coordinate of the rectangle to be filled
- * @param width the width of the rectangle to be filled, may be negative
- * (inverts direction of gradient if horizontal)
- * @param height the height of the rectangle to be filled, may be negative
- * (inverts direction of gradient if vertical)
- * @param vertical if true sweeps from top to bottom, else
- * sweeps from left to right
- *
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
- *
- * @see #drawRectangle
+public void fillArc (int x, int y, int width, int height, int startAngle, int endAngle) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ if (width == 0 || height == 0 || endAngle == 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (startAngle > 0) {
+ if (endAngle > 0) {
+ //No need to modify start angle.
+ 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);
+
+ 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);
+ }
+}
+
+/**
+ * Fills the interior of the specified rectangle with a gradient
+ * sweeping from left to right or top to bottom progressing
+ * from the receiver's foreground color to its background color.
+ *
+ * @param x the x coordinate of the rectangle to be filled
+ * @param y the y coordinate of the rectangle to be filled
+ * @param width the width of the rectangle to be filled, may be negative
+ * (inverts direction of gradient if horizontal)
+ * @param height the height of the rectangle to be filled, may be negative
+ * (inverts direction of gradient if vertical)
+ * @param vertical if true sweeps from top to bottom, else
+ * sweeps from left to right
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRectangle
*/
-public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if ((width == 0) || (height == 0)) return;
- int fromColor = data.foreground;
- int toColor = data.background;
- boolean swapColors = false;
- if (width < 0) {
- x += width; width = -width;
- if (! vertical) swapColors = true;
- }
- if (height < 0) {
- y += height; height = -height;
- if (vertical) swapColors = true;
- }
- if (swapColors) {
- final int t = toColor;
- toColor = fromColor;
- fromColor = t;
- }
- PhPoint_t upperLeft = new PhPoint_t();
- upperLeft.x = (short)x;
- upperLeft.y = (short)y;
- PhPoint_t lowerRight = new PhPoint_t();
- lowerRight.x = (short)(x + width - 1);
- lowerRight.y = (short)(y + height - 1);
- int flags = OS.PtEnter(0);
- try {
- int prevContext = setGC();
- setGCClipping();
- OS.PgDrawGradient(upperLeft, lowerRight,
- vertical ? OS.Pg_GRAD_VERTICAL : OS.Pg_GRAD_HORIZONTAL, OS.Pg_GRAD_LINEAR,
- vertical ? height : width, fromColor, toColor, 0, 0, 0, null);
- unsetGC(prevContext);
- } finally {
- if (flags >= 0) OS.PtLeave(flags);
- }
-}
-
+public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if ((width == 0) || (height == 0)) return;
+ int fromColor = data.foreground;
+ int toColor = data.background;
+ boolean swapColors = false;
+ if (width < 0) {
+ x += width; width = -width;
+ if (! vertical) swapColors = true;
+ }
+ if (height < 0) {
+ y += height; height = -height;
+ if (vertical) swapColors = true;
+ }
+ if (swapColors) {
+ final int t = toColor;
+ toColor = fromColor;
+ fromColor = t;
+ }
+ PhPoint_t upperLeft = new PhPoint_t();
+ upperLeft.x = (short)x;
+ upperLeft.y = (short)y;
+ PhPoint_t lowerRight = new PhPoint_t();
+ lowerRight.x = (short)(x + width - 1);
+ lowerRight.y = (short)(y + height - 1);
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawGradient(upperLeft, lowerRight,
+ vertical ? OS.Pg_GRAD_VERTICAL : OS.Pg_GRAD_HORIZONTAL, OS.Pg_GRAD_LINEAR,
+ vertical ? height : width, fromColor, toColor, 0, 0, 0, null);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
/**
* Fills the interior of an oval, within the specified
* rectangular area, with the receiver's background
@@ -1509,25 +1509,25 @@ public void fillGradientRectangle(int x, int y, int width, int height, boolean v
*
* @see #drawOval
*/
-public void fillOval (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- PhPoint_t center = new PhPoint_t();
- center.x = (short)x; center.y = (short)y;
- PhPoint_t radii = new PhPoint_t();
- radii.x = (short)(x + width);
- radii.y = (short)(y + height);
-
- 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 fillOval (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ PhPoint_t center = new PhPoint_t();
+ center.x = (short)x; center.y = (short)y;
+ PhPoint_t radii = new PhPoint_t();
+ radii.x = (short)(x + width);
+ radii.y = (short)(y + height);
+
+ 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);
+ }
+}
+
/**
* Fills the interior of the closed polygon which is defined by the
* specified array of integer coordinates, using the receiver's
@@ -1547,26 +1547,26 @@ public void fillOval (int x, int y, int width, int height) {
*
* @see #drawPolygon
*/
-public void fillPolygon(int[] pointArray) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
-
- short[] points = new short[pointArray.length];
- 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 fillPolygon(int[] pointArray) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+
+ short[] points = new short[pointArray.length];
+ 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);
+ }
+}
+
/**
* Fills the interior of the rectangle specified by the arguments,
* using the receiver's background color.
@@ -1582,20 +1582,20 @@ public void fillPolygon(int[] pointArray) {
*
* @see #drawRectangle
*/
-public void fillRectangle (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (width == 0 || height == 0) return;
- int flags = OS.PtEnter(0);
- try {
- 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 (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (width == 0 || height == 0) return;
+ int flags = OS.PtEnter(0);
+ try {
+ 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);
+ }
+}
+
/**
* Fills the interior of the specified rectangle, using the receiver's
* background color.
@@ -1611,11 +1611,11 @@ public void fillRectangle (int x, int y, int width, int height) {
*
* @see #drawRectangle
*/
-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 fillRectangle (Rectangle rect) {
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ fillRectangle (rect.x, rect.y, rect.width, rect.height);
+}
+
/**
* Fills the interior of the round-cornered rectangle specified by
* the arguments, using the receiver's background color.
@@ -1633,37 +1633,37 @@ public void fillRectangle (Rectangle rect) {
*
* @see #drawRoundRectangle
*/
-public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- PhRect_t rect = new PhRect_t();
- rect.ul_x = (short)x; rect.ul_y = (short)y;
- rect.lr_x = (short)(x + width - 1); rect.lr_y = (short)(y + height - 1);
- 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);
- }
-}
-
-/**
- * Force outstanding drawing commands to be processed.
+public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ PhRect_t rect = new PhRect_t();
+ rect.ul_x = (short)x; rect.ul_y = (short)y;
+ rect.lr_x = (short)(x + width - 1); rect.lr_y = (short)(y + height - 1);
+ 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);
+ }
+}
+
+/**
+ * Force outstanding drawing commands to be processed.
*/
-void flushImage () {
- Image image = data.image;
- if (image == null) return;
- int prevContext = OS.PmMemStart(handle);
- OS.PmMemFlush(handle, image.handle);
- OS.PmMemStop(handle);
- OS.PhDCSetCurrent(prevContext);
-}
-
+void flushImage () {
+ Image image = data.image;
+ if (image == null) return;
+ int prevContext = OS.PmMemStart(handle);
+ OS.PmMemFlush(handle, image.handle);
+ OS.PmMemStop(handle);
+ OS.PhDCSetCurrent(prevContext);
+}
+
/**
* Returns the <em>advance width</em> of the specified character in
* the font which is currently selected into the receiver.
@@ -1679,10 +1679,10 @@ void flushImage () {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getAdvanceWidth(char ch) {
- return getCharWidth(ch);
-}
-
+public int getAdvanceWidth(char ch) {
+ return getCharWidth(ch);
+}
+
/**
* Returns the background color.
*
@@ -1692,11 +1692,11 @@ public int getAdvanceWidth(char ch) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Color getBackground() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return Color.photon_new(data.device, data.background);
-}
-
+public Color getBackground() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return Color.photon_new(data.device, data.background);
+}
+
/**
* Returns the width of the specified character in the font
* selected into the receiver.
@@ -1713,13 +1713,13 @@ public Color getBackground() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getCharWidth(char ch) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- String string = new String(new char[] {ch});
- Point point = stringExtent(string);
- return point.x;
-}
-
+public int getCharWidth(char ch) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ String string = new String(new char[] {ch});
+ Point point = stringExtent(string);
+ return point.x;
+}
+
/**
* Returns the bounding rectangle of the receiver's clipping
* region. If no clipping region is set, the return value
@@ -1732,48 +1732,48 @@ public int getCharWidth(char ch) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Rectangle getClipping() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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 * PhRect_t.sizeof));
- }
- 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 Rectangle getClipping() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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 * PhRect_t.sizeof));
+ }
+ 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);
+ }
+}
+
/**
* Sets the region managed by the argument to the current
* clipping region of the receiver.
@@ -1787,40 +1787,40 @@ public Rectangle getClipping() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void getClipping (Region region) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (region == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
- int flags = OS.PtEnter(0);
- try {
- 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 void getClipping (Region region) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (region == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ int flags = OS.PtEnter(0);
+ try {
+ 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);
+ }
+}
+
/**
* Returns the font currently being used by the receiver
* to draw and measure text.
@@ -1831,11 +1831,11 @@ public void getClipping (Region region) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Font getFont () {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return Font.photon_new(data.device, data.font);
-}
-
+public Font getFont () {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return Font.photon_new(data.device, data.font);
+}
+
/**
* Returns a FontMetrics which contains information
* about the font currently being used by the receiver
@@ -1847,13 +1847,13 @@ public Font getFont () {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public FontMetrics getFontMetrics() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- FontQueryInfo info = new FontQueryInfo();
- OS.PfQueryFontInfo(data.font, info);
- return FontMetrics.photon_new(info);
-}
-
+public FontMetrics getFontMetrics() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ FontQueryInfo info = new FontQueryInfo();
+ OS.PfQueryFontInfo(data.font, info);
+ return FontMetrics.photon_new(info);
+}
+
/**
* Returns the receiver's foreground color.
*
@@ -1863,11 +1863,11 @@ public FontMetrics getFontMetrics() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Color getForeground() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return Color.photon_new(data.device, data.foreground);
-}
-
+public Color getForeground() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return Color.photon_new(data.device, data.foreground);
+}
+
/**
* Returns the receiver's line style, which will be one
* of the constants <code>SWT.LINE_SOLID</code>, <code>SWT.LINE_DASH</code>,
@@ -1880,11 +1880,11 @@ public Color getForeground() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getLineStyle() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return data.lineStyle;
-}
-
+public int getLineStyle() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return data.lineStyle;
+}
+
/**
* Returns the width that will be used when drawing lines
* for all of the figure drawing operations (that is,
@@ -1897,11 +1897,11 @@ public int getLineStyle() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public int getLineWidth() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return data.lineWidth;
-}
-
+public int getLineWidth() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return data.lineWidth;
+}
+
/**
* Returns <code>true</code> if this GC is drawing in the mode
* where the resulting color in the destination is the
@@ -1916,11 +1916,11 @@ public int getLineWidth() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public boolean getXORMode() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return data.xorMode;
-}
-
+public boolean getXORMode() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return data.xorMode;
+}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -1935,44 +1935,44 @@ public boolean getXORMode() {
*
* @see #equals
*/
-public int hashCode () {
- return handle;
-}
-
-void init(Drawable drawable, GCData data, int context) {
- if (data.foreground == -1) data.foreground = DefaultFore;
- if (data.background == -1) data.background = DefaultBack;
- if (data.font == null) data.font = data.device.systemFont;
- dirtyBits = DIRTY_FOREGROUND | DIRTY_BACKGROUND | DIRTY_FONT;
-
- Image image = data.image;
- if (image != null) {
- image.memGC = this;
- int prevContext = OS.PmMemStart(context);
- OS.PgSetDrawBufferSize(DrawBufferSize);
- OS.PmMemStop(context);
- OS.PhDCSetCurrent(prevContext);
-
- /*
- * 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 int hashCode () {
+ return handle;
+}
+
+void init(Drawable drawable, GCData data, int context) {
+ if (data.foreground == -1) data.foreground = DefaultFore;
+ if (data.background == -1) data.background = DefaultBack;
+ if (data.font == null) data.font = data.device.systemFont;
+ dirtyBits = DIRTY_FOREGROUND | DIRTY_BACKGROUND | DIRTY_FONT;
+
+ Image image = data.image;
+ if (image != null) {
+ image.memGC = this;
+ int prevContext = OS.PmMemStart(context);
+ OS.PgSetDrawBufferSize(DrawBufferSize);
+ OS.PmMemStop(context);
+ OS.PhDCSetCurrent(prevContext);
+
+ /*
+ * 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;
+}
+
/**
* Returns <code>true</code> if the receiver has a clipping
* region set into it, and <code>false</code> otherwise.
@@ -1987,11 +1987,11 @@ void init(Drawable drawable, GCData data, int context) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public boolean isClipped() {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- return data.clipRects != 0;
-}
-
+public boolean isClipped() {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ return data.clipRects != 0;
+}
+
/**
* Returns <code>true</code> if the GC has been disposed,
* and <code>false</code> otherwise.
@@ -2002,10 +2002,10 @@ public boolean isClipped() {
*
* @return <code>true</code> when the GC is disposed and <code>false</code> otherwise
*/
-public boolean isDisposed() {
- return handle == 0;
-}
-
+public boolean isDisposed() {
+ return handle == 0;
+}
+
/**
* Sets the background color. The background color is used
* for fill operations and as the background color when text
@@ -2021,14 +2021,14 @@ public boolean isDisposed() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setBackground (Color color) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- data.background = color.handle;
- dirtyBits |= DIRTY_BACKGROUND;
-}
-
+public void setBackground (Color color) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ data.background = color.handle;
+ dirtyBits |= DIRTY_BACKGROUND;
+}
+
/**
* Sets the area of the receiver which can be changed
* by drawing operations to the rectangular area specified
@@ -2043,32 +2043,32 @@ public void setBackground (Color color) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setClipping (int x, int y, int width, int height) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (width < 0) {
- x = x + width;
- width = -width;
- }
- if (height < 0) {
- y = y + height;
- height = -height;
- }
- 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);
- data.clipRects = clipRects;
- data.clipRectsCount = clipRectsCount;
- dirtyBits |= DIRTY_CLIPPING;
-}
-
+public void setClipping (int x, int y, int width, int height) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ 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);
+ data.clipRects = clipRects;
+ data.clipRectsCount = clipRectsCount;
+ dirtyBits |= DIRTY_CLIPPING;
+}
+
/**
* Sets the area of the receiver which can be changed
* by drawing operations to the rectangular area specified
@@ -2080,19 +2080,19 @@ public void setClipping (int x, int y, int width, int height) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setClipping (Rectangle rect) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (rect == null) {
- int clipRects = data.clipRects;
- if (clipRects != 0)
- OS.free(clipRects);
- data.clipRects = data.clipRectsCount = 0;
- dirtyBits |= DIRTY_CLIPPING;
- } else {
- setClipping (rect.x, rect.y, rect.width, rect.height);
- }
-}
-
+public void setClipping (Rectangle rect) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (rect == null) {
+ int clipRects = data.clipRects;
+ if (clipRects != 0)
+ OS.free(clipRects);
+ data.clipRects = data.clipRectsCount = 0;
+ dirtyBits |= DIRTY_CLIPPING;
+ } else {
+ setClipping (rect.x, rect.y, rect.width, rect.height);
+ }
+}
+
/**
* Sets the area of the receiver which can be changed
* by drawing operations to the region specified
@@ -2104,27 +2104,27 @@ public void setClipping (Rectangle rect) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setClipping (Region region) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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];
- }
- data.clipRects = clipRects;
- data.clipRectsCount = clipRectsCount;
- dirtyBits |= DIRTY_CLIPPING;
-}
-
+public void setClipping (Region region) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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];
+ }
+ data.clipRects = clipRects;
+ data.clipRectsCount = clipRectsCount;
+ dirtyBits |= DIRTY_CLIPPING;
+}
+
/**
* Sets the font which will be used by the receiver
* to draw and measure text to the argument. If the
@@ -2140,13 +2140,13 @@ public void setClipping (Region region) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setFont (Font font) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (font != null && font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- data.font = font == null ? data.device.systemFont : font.handle;
- dirtyBits |= DIRTY_FONT;
-}
-
+public void setFont (Font font) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (font != null && font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ data.font = font == null ? data.device.systemFont : font.handle;
+ dirtyBits |= DIRTY_FONT;
+}
+
/**
* Sets the foreground color. The foreground color is used
* for drawing operations including when text is drawn.
@@ -2161,14 +2161,14 @@ public void setFont (Font font) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setForeground (Color color) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- data.foreground = color.handle;
- dirtyBits |= DIRTY_FOREGROUND;
-}
-
+public void setForeground (Color color) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ data.foreground = color.handle;
+ dirtyBits |= DIRTY_FOREGROUND;
+}
+
/**
* Sets the receiver's line style to the argument, which must be one
* of the constants <code>SWT.LINE_SOLID</code>, <code>SWT.LINE_DASH</code>,
@@ -2181,23 +2181,23 @@ public void setForeground (Color color) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setLineStyle(int lineStyle) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- switch (lineStyle) {
- case SWT.LINE_SOLID:
- case SWT.LINE_DASH:
- case SWT.LINE_DOT:
- case SWT.LINE_DASHDOT:
- case SWT.LINE_DASHDOTDOT:
- break;
- default:
- SWT.error (SWT.ERROR_INVALID_ARGUMENT);
- return;
- }
- data.lineStyle = lineStyle;
- dirtyBits |= DIRTY_LINESTYLE;
-}
-
+public void setLineStyle(int lineStyle) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ switch (lineStyle) {
+ case SWT.LINE_SOLID:
+ case SWT.LINE_DASH:
+ case SWT.LINE_DOT:
+ case SWT.LINE_DASHDOT:
+ case SWT.LINE_DASHDOTDOT:
+ break;
+ default:
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ return;
+ }
+ data.lineStyle = lineStyle;
+ dirtyBits |= DIRTY_LINESTYLE;
+}
+
/**
* Sets the width that will be used when drawing lines
* for all of the figure drawing operations (that is,
@@ -2210,158 +2210,158 @@ public void setLineStyle(int lineStyle) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setLineWidth(int lineWidth) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- data.lineWidth = lineWidth;
- dirtyBits |= DIRTY_LINEWIDTH;
-}
-
-int setGC() {
- int result = 0;
- if (data.image != null) result = OS.PmMemStart(handle);
- else if (data.rid == OS.Ph_DEV_RID || data.widget != 0) result = OS.PgSetGC(handle);
- else return result;
-
- if (dirtyBits != 0) {
- if ((dirtyBits & DIRTY_BACKGROUND) != 0) {
- OS.PgSetFillColor(data.background);
- }
- if ((dirtyBits & DIRTY_FOREGROUND) != 0) {
- int foreColor = data.foreground;
- OS.PgSetStrokeColor(foreColor);
- OS.PgSetTextColor(foreColor);
- }
- if ((dirtyBits & DIRTY_FONT) != 0) {
- OS.PfLoadMetrics(data.font);
- OS.PgSetFont(data.font);
- }
- if ((dirtyBits & DIRTY_CLIPPING) != 0) {
- OS.PgSetMultiClip(data.clipRectsCount, data.clipRects);
- }
- if ((dirtyBits & DIRTY_LINESTYLE) != 0) {
- byte[] dashList = null;
- switch (data.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;
- }
- OS.PgSetStrokeDash(dashList, dashList.length, 0x10000);
- }
- if ((dirtyBits & DIRTY_LINEWIDTH) != 0) {
- OS.PgSetStrokeWidth(data.lineWidth);
- }
- if ((dirtyBits & DIRTY_XORMODE) != 0) {
- if (data.xorMode) OS.PgSetDrawMode(OS.Pg_DRAWMODE_XOR);
- else OS.PgSetDrawMode(OS.Pg_DRAWMODE_OPAQUE);
- }
- dirtyBits = 0;
- }
- return result;
-}
-
-void setGCClipping() {
- int rid = data.rid;
- int widget = data.widget;
- 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 */
- OS.PgSetMultiClip(data.clipRectsCount, data.clipRects);
-
- if (widget == 0) return;
-
- int clip_tile = getClipping(widget, data.topWidget, true, true, null);
- int[] clip_rects_count = new int[1];
- int clip_rects = OS.PhTilesToRects(clip_tile, clip_rects_count);
- OS.PhFreeTiles(clip_tile);
- if (clip_rects_count[0] == 0) {
- clip_rects_count[0] = 1;
- OS.free(clip_rects);
- clip_rects = OS.malloc(PhRect_t.sizeof);
- }
- OS.PgSetClipping((short)clip_rects_count[0], clip_rects);
- OS.free(clip_rects);
-}
-
-int getClipping(int widget, int topWidget, boolean clipChildren, boolean clipSiblings, int[] child_tiles) {
- int child_tile = 0;
- int widget_tile = OS.PhGetTile(); // NOTE: PhGetTile native initializes the tile
-
- PhRect_t rect = new PhRect_t ();
- int args [] = {OS.Pt_ARG_FLAGS, 0, 0, OS.Pt_ARG_BASIC_FLAGS, 0, 0};
-
- /* Get the rectangle of all siblings in front of the widget */
- if (clipSiblings && OS.PtWidgetClass(topWidget) != OS.PtWindow()) {
- int temp_widget = topWidget;
- while ((temp_widget = OS.PtWidgetBrotherInFront(temp_widget)) != 0) {
- if (OS.PtWidgetIsRealized(temp_widget)) {
- int tile = OS.PhGetTile();
- if (child_tile == 0) child_tile = tile;
- else child_tile = OS.PhAddMergeTiles(tile, child_tile, null);
- OS.PtWidgetExtent(temp_widget, tile); // NOTE: tile->rect
- args [1] = args [4] = 0;
- OS.PtGetResources(temp_widget, args.length / 3, args);
- if ((args [1] & OS.Pt_HIGHLIGHTED) != 0) {
- int basic_flags = args [4];
- OS.memmove(rect, tile, PhRect_t.sizeof);
- if ((basic_flags & OS.Pt_TOP_ETCH) != 0) rect.ul_y++;
- if ((basic_flags & OS.Pt_BOTTOM_ETCH) != 0) rect.lr_y--;
- if ((basic_flags & OS.Pt_RIGHT_ETCH) != 0) rect.ul_x++;
- if ((basic_flags & OS.Pt_LEFT_ETCH) != 0) rect.lr_x--;
- OS.memmove(tile, rect, PhRect_t.sizeof);
- }
- }
- }
- /* Translate the siblings rectangles to the widget's coordinates */
- OS.PtWidgetCanvas(topWidget, widget_tile); // NOTE: widget_tile->rect
- OS.PhDeTranslateTiles(child_tile, widget_tile); // NOTE: widget_tile->rect.ul
- }
-
- /* Get the rectangle of the widget's children */
- if (clipChildren) {
- int temp_widget = OS.PtWidgetChildBack(widget);
- while (temp_widget != 0) {
- if (OS.PtWidgetIsRealized(temp_widget)) {
- int tile = OS.PhGetTile();
- if (child_tile == 0) child_tile = tile;
- else child_tile = OS.PhAddMergeTiles(tile, child_tile, null);
- OS.PtWidgetExtent(temp_widget, tile); // NOTE: tile->rect
- args [1] = args [4] = 0;
- OS.PtGetResources(temp_widget, args.length / 3, args);
- if ((args [1] & OS.Pt_HIGHLIGHTED) != 0) {
- int basic_flags = args [4];
- OS.memmove(rect, tile, PhRect_t.sizeof);
- if ((basic_flags & OS.Pt_TOP_ETCH) != 0) rect.ul_y++;
- if ((basic_flags & OS.Pt_BOTTOM_ETCH) != 0) rect.lr_y--;
- if ((basic_flags & OS.Pt_RIGHT_ETCH) != 0) rect.ul_x++;
- if ((basic_flags & OS.Pt_LEFT_ETCH) != 0) rect.lr_x--;
- OS.memmove(tile, rect, PhRect_t.sizeof);
- }
- }
- temp_widget = OS.PtWidgetBrotherInFront(temp_widget);
- }
- }
-
- /* Get the widget's rectangle */
- OS.PtWidgetCanvas(widget, widget_tile); // NOTE: widget_tile->rect
- OS.PhDeTranslateTiles(widget_tile, widget_tile); // NOTE: widget_tile->rect.ul
-
-
- /* Clip the widget's rectangle from the child/siblings rectangle's */
- if (child_tile != 0) {
- if (child_tiles != null) {
- child_tiles[0] = OS.PhIntersectTilings(widget_tile, child_tile, new short[1]);
- }
- int clip_tile = OS.PhClipTilings(widget_tile, child_tile, null);
- OS.PhFreeTiles(child_tile);
- return clip_tile;
- }
- return widget_tile;
-}
-
+public void setLineWidth(int lineWidth) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ data.lineWidth = lineWidth;
+ dirtyBits |= DIRTY_LINEWIDTH;
+}
+
+int setGC() {
+ int result = 0;
+ if (data.image != null) result = OS.PmMemStart(handle);
+ else if (data.rid == OS.Ph_DEV_RID || data.widget != 0) result = OS.PgSetGC(handle);
+ else return result;
+
+ if (dirtyBits != 0) {
+ if ((dirtyBits & DIRTY_BACKGROUND) != 0) {
+ OS.PgSetFillColor(data.background);
+ }
+ if ((dirtyBits & DIRTY_FOREGROUND) != 0) {
+ int foreColor = data.foreground;
+ OS.PgSetStrokeColor(foreColor);
+ OS.PgSetTextColor(foreColor);
+ }
+ if ((dirtyBits & DIRTY_FONT) != 0) {
+ OS.PfLoadMetrics(data.font);
+ OS.PgSetFont(data.font);
+ }
+ if ((dirtyBits & DIRTY_CLIPPING) != 0) {
+ OS.PgSetMultiClip(data.clipRectsCount, data.clipRects);
+ }
+ if ((dirtyBits & DIRTY_LINESTYLE) != 0) {
+ byte[] dashList = null;
+ switch (data.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;
+ }
+ OS.PgSetStrokeDash(dashList, dashList.length, 0x10000);
+ }
+ if ((dirtyBits & DIRTY_LINEWIDTH) != 0) {
+ OS.PgSetStrokeWidth(data.lineWidth);
+ }
+ if ((dirtyBits & DIRTY_XORMODE) != 0) {
+ if (data.xorMode) OS.PgSetDrawMode(OS.Pg_DRAWMODE_XOR);
+ else OS.PgSetDrawMode(OS.Pg_DRAWMODE_OPAQUE);
+ }
+ dirtyBits = 0;
+ }
+ return result;
+}
+
+void setGCClipping() {
+ int rid = data.rid;
+ int widget = data.widget;
+ 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 */
+ OS.PgSetMultiClip(data.clipRectsCount, data.clipRects);
+
+ if (widget == 0) return;
+
+ int clip_tile = getClipping(widget, data.topWidget, true, true, null);
+ int[] clip_rects_count = new int[1];
+ int clip_rects = OS.PhTilesToRects(clip_tile, clip_rects_count);
+ OS.PhFreeTiles(clip_tile);
+ if (clip_rects_count[0] == 0) {
+ clip_rects_count[0] = 1;
+ OS.free(clip_rects);
+ clip_rects = OS.malloc(PhRect_t.sizeof);
+ }
+ OS.PgSetClipping((short)clip_rects_count[0], clip_rects);
+ OS.free(clip_rects);
+}
+
+int getClipping(int widget, int topWidget, boolean clipChildren, boolean clipSiblings, int[] child_tiles) {
+ int child_tile = 0;
+ int widget_tile = OS.PhGetTile(); // NOTE: PhGetTile native initializes the tile
+
+ PhRect_t rect = new PhRect_t ();
+ int args [] = {OS.Pt_ARG_FLAGS, 0, 0, OS.Pt_ARG_BASIC_FLAGS, 0, 0};
+
+ /* Get the rectangle of all siblings in front of the widget */
+ if (clipSiblings && OS.PtWidgetClass(topWidget) != OS.PtWindow()) {
+ int temp_widget = topWidget;
+ while ((temp_widget = OS.PtWidgetBrotherInFront(temp_widget)) != 0) {
+ if (OS.PtWidgetIsRealized(temp_widget)) {
+ int tile = OS.PhGetTile();
+ if (child_tile == 0) child_tile = tile;
+ else child_tile = OS.PhAddMergeTiles(tile, child_tile, null);
+ OS.PtWidgetExtent(temp_widget, tile); // NOTE: tile->rect
+ args [1] = args [4] = 0;
+ OS.PtGetResources(temp_widget, args.length / 3, args);
+ if ((args [1] & OS.Pt_HIGHLIGHTED) != 0) {
+ int basic_flags = args [4];
+ OS.memmove(rect, tile, PhRect_t.sizeof);
+ if ((basic_flags & OS.Pt_TOP_ETCH) != 0) rect.ul_y++;
+ if ((basic_flags & OS.Pt_BOTTOM_ETCH) != 0) rect.lr_y--;
+ if ((basic_flags & OS.Pt_RIGHT_ETCH) != 0) rect.ul_x++;
+ if ((basic_flags & OS.Pt_LEFT_ETCH) != 0) rect.lr_x--;
+ OS.memmove(tile, rect, PhRect_t.sizeof);
+ }
+ }
+ }
+ /* Translate the siblings rectangles to the widget's coordinates */
+ OS.PtWidgetCanvas(topWidget, widget_tile); // NOTE: widget_tile->rect
+ OS.PhDeTranslateTiles(child_tile, widget_tile); // NOTE: widget_tile->rect.ul
+ }
+
+ /* Get the rectangle of the widget's children */
+ if (clipChildren) {
+ int temp_widget = OS.PtWidgetChildBack(widget);
+ while (temp_widget != 0) {
+ if (OS.PtWidgetIsRealized(temp_widget)) {
+ int tile = OS.PhGetTile();
+ if (child_tile == 0) child_tile = tile;
+ else child_tile = OS.PhAddMergeTiles(tile, child_tile, null);
+ OS.PtWidgetExtent(temp_widget, tile); // NOTE: tile->rect
+ args [1] = args [4] = 0;
+ OS.PtGetResources(temp_widget, args.length / 3, args);
+ if ((args [1] & OS.Pt_HIGHLIGHTED) != 0) {
+ int basic_flags = args [4];
+ OS.memmove(rect, tile, PhRect_t.sizeof);
+ if ((basic_flags & OS.Pt_TOP_ETCH) != 0) rect.ul_y++;
+ if ((basic_flags & OS.Pt_BOTTOM_ETCH) != 0) rect.lr_y--;
+ if ((basic_flags & OS.Pt_RIGHT_ETCH) != 0) rect.ul_x++;
+ if ((basic_flags & OS.Pt_LEFT_ETCH) != 0) rect.lr_x--;
+ OS.memmove(tile, rect, PhRect_t.sizeof);
+ }
+ }
+ temp_widget = OS.PtWidgetBrotherInFront(temp_widget);
+ }
+ }
+
+ /* Get the widget's rectangle */
+ OS.PtWidgetCanvas(widget, widget_tile); // NOTE: widget_tile->rect
+ OS.PhDeTranslateTiles(widget_tile, widget_tile); // NOTE: widget_tile->rect.ul
+
+
+ /* Clip the widget's rectangle from the child/siblings rectangle's */
+ if (child_tile != 0) {
+ if (child_tiles != null) {
+ child_tiles[0] = OS.PhIntersectTilings(widget_tile, child_tile, new short[1]);
+ }
+ int clip_tile = OS.PhClipTilings(widget_tile, child_tile, null);
+ OS.PhFreeTiles(child_tile);
+ return clip_tile;
+ }
+ return widget_tile;
+}
+
/**
* If the argument is <code>true</code>, puts the receiver
* in a drawing mode where the resulting color in the destination
@@ -2376,12 +2376,12 @@ int getClipping(int widget, int topWidget, boolean clipChildren, boolean clipSib
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void setXORMode(boolean xor) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- data.xorMode = xor;
- dirtyBits |= DIRTY_XORMODE;
-}
-
+public void setXORMode(boolean xor) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ data.xorMode = xor;
+ dirtyBits |= DIRTY_XORMODE;
+}
+
/**
* Returns the extent of the given string. No tab
* expansion or carriage return processing will be performed.
@@ -2401,28 +2401,28 @@ public void setXORMode(boolean xor) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Point stringExtent(String string) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- PhRect_t rect = new PhRect_t();
- int size = string.length();
- 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;
- if (size == 0) width = 0;
- else width = rect.lr_x - (rect.ul_x < 0 ? rect.ul_x : 0) + 1;
- int height = rect.lr_y - rect.ul_y + 1;
- return new Point(width, height);
-}
-
+public Point stringExtent(String string) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ PhRect_t rect = new PhRect_t();
+ int size = string.length();
+ 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;
+ if (size == 0) width = 0;
+ else width = rect.lr_x - (rect.ul_x < 0 ? rect.ul_x : 0) + 1;
+ int height = rect.lr_y - rect.ul_y + 1;
+ return new Point(width, height);
+}
+
/**
* Returns the extent of the given string. Tab expansion and
* carriage return processing are performed.
@@ -2442,79 +2442,79 @@ public Point stringExtent(String string) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Point textExtent(String string) {
- return textExtent(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
-}
-
-/**
- * Returns the extent of the given string. Tab expansion, line
- * delimiter and mnemonic processing are performed according to
- * the specified flags, which can be a combination of:
- * <dl>
- * <dt><b>DRAW_DELIMITER</b></dt>
- * <dd>draw multiple lines</dd>
- * <dt><b>DRAW_TAB</b></dt>
- * <dd>expand tabs</dd>
- * <dt><b>DRAW_MNEMONIC</b></dt>
- * <dd>underline the mnemonic character</dd>
- * <dt><b>DRAW_TRANSPARENT</b></dt>
- * <dd>transparent background</dd>
- * </dl>
- * <p>
- * The <em>extent</em> of a string is the width and height of
- * the rectangular area it would cover if drawn in a particular
- * font (in this case, the current font in the receiver).
- * </p>
- *
- * @param string the string to measure
- * @param flags the flags specifing how to process the text
- * @return a point containing the extent of the string
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+public Point textExtent(String string) {
+ return textExtent(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
+}
+
+/**
+ * Returns the extent of the given string. Tab expansion, line
+ * delimiter and mnemonic processing are performed according to
+ * the specified flags, which can be a combination of:
+ * <dl>
+ * <dt><b>DRAW_DELIMITER</b></dt>
+ * <dd>draw multiple lines</dd>
+ * <dt><b>DRAW_TAB</b></dt>
+ * <dd>expand tabs</dd>
+ * <dt><b>DRAW_MNEMONIC</b></dt>
+ * <dd>underline the mnemonic character</dd>
+ * <dt><b>DRAW_TRANSPARENT</b></dt>
+ * <dd>transparent background</dd>
+ * </dl>
+ * <p>
+ * The <em>extent</em> of a string is the width and height of
+ * the rectangular area it would cover if drawn in a particular
+ * font (in this case, the current font in the receiver).
+ * </p>
+ *
+ * @param string the string to measure
+ * @param flags the flags specifing how to process the text
+ * @return a point containing the extent of the string
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
-public Point textExtent(String string, int flags) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if ((flags & ~SWT.DRAW_TRANSPARENT) == 0) {
- return stringExtent(string);
- } else {
- return drawText(string, 0, 0, flags, false);
- }
-}
-
+public Point textExtent(String string, int flags) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if ((flags & ~SWT.DRAW_TRANSPARENT) == 0) {
+ return stringExtent(string);
+ } else {
+ return drawText(string, 0, 0, flags, false);
+ }
+}
+
/**
* Returns a string containing a concise, human-readable
* description of the receiver.
*
* @return a string representation of the receiver
*/
-public String toString () {
- if (isDisposed()) return "GC {*DISPOSED*}";
- return "GC {" + handle + "}";
-}
-
-void unsetGC(int prevContext) {
- Image image = data.image;
- if (image != null) {
-// OS.PmMemFlush(handle, image.handle);
- OS.PmMemStop(handle);
- OS.PhDCSetCurrent(prevContext);
- } 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;
-}
-
+public String toString () {
+ if (isDisposed()) return "GC {*DISPOSED*}";
+ return "GC {" + handle + "}";
+}
+
+void unsetGC(int prevContext) {
+ Image image = data.image;
+ if (image != null) {
+// OS.PmMemFlush(handle, image.handle);
+ OS.PmMemStop(handle);
+ OS.PhDCSetCurrent(prevContext);
+ } 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;
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GCData.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GCData.java
index 30fb1135fd..0073e5acb8 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GCData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GCData.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+
/**
* Instances of this class are descriptions of GCs in terms
* of unallocated platform-specific data fields.
@@ -21,17 +21,17 @@ import org.eclipse.swt.*;
*
* @private
*/
-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;
+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;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java
index fceee38aa1..6e0e7d5b5e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import java.io.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import java.io.*;
+
/**
* Instances of this class are graphics which have been prepared
* for display on a specific device. That is, they are ready
@@ -58,46 +58,46 @@ import java.io.*;
* @see ImageData
* @see ImageLoader
*/
-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 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 type;
+
+ /**
+ * the OS resource of the image
+ * (Warning: This field is platform dependent)
*/
- public int handle;
-
- /**
- * the device where this image was created
+ public int handle;
+
+ /**
+ * the device where this image was created
*/
- Device device;
-
- /**
- * specifies the transparent pixel
- * (Warning: This field is platform dependent)
+ 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)
+ 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)
+ GC memGC;
+
+ /**
+ * specifies the default scanline padding
+ * (Warning: This field is platform dependent)
*/
- static final int DEFAULT_SCANLINE_PAD = 4;
-
-Image () {
-}
-
+ static final int DEFAULT_SCANLINE_PAD = 4;
+
+Image () {
+}
+
/**
* Constructs an empty instance of this class with the
* specified width and height. The result may be drawn upon
@@ -128,13 +128,13 @@ Image () {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
* </ul>
*/
-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, 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);
+}
+
/**
* Constructs a new instance of this class based on the
* provided image, with an appearance that varies depending
@@ -166,125 +166,125 @@ public Image(Device device, int width, int height) {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
* </ul>
*/
-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);
- if (srcImage.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- switch (flag) {
- case SWT.IMAGE_COPY:
- case SWT.IMAGE_DISABLE:
- this.type = srcImage.type;
- int srcHandle = srcImage.handle;
- int newHandle = OS.PiDuplicateImage (srcHandle, 0);
- if (newHandle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- if (flag == SWT.IMAGE_COPY) {
- /*
- * Bug in Photon. The image returned by PiDuplicateImage might
- * have the same mask_bm/alpha as the original image. The fix
- * is to detect this case and copy mask_bm/alpha if necessary.
- */
- PhImage_t phImage = new PhImage_t();
- OS.memmove (phImage, srcHandle, PhImage_t.sizeof);
- PhImage_t newPhImage = new PhImage_t();
- OS.memmove(newPhImage, newHandle, PhImage_t.sizeof);
- if (newPhImage.mask_bm != 0 && phImage.mask_bm == newPhImage.mask_bm) {
- int length = newPhImage.mask_bpl * newPhImage.size_h;
- int ptr = OS.malloc(length);
- OS.memmove(ptr, newPhImage.mask_bm, length);
- newPhImage.mask_bm = ptr;
- }
- if (newPhImage.alpha != 0 && phImage.alpha == newPhImage.alpha) {
- 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_bpl * alpha.src_alpha_map_dim_h;
- int ptr = OS.malloc(length);
- OS.memmove(ptr, alpha.src_alpha_map_map, length);
- alpha.src_alpha_map_map = ptr;
- }
- int ptr = OS.malloc(PgAlpha_t.sizeof);
- OS.memmove(ptr, alpha, PgAlpha_t.sizeof);
- newPhImage.alpha = ptr;
- }
- OS.memmove(newHandle, newPhImage, PhImage_t.sizeof);
- transparentPixel = srcImage.transparentPixel;
- } else {
- PhImage_t phImage = new PhImage_t();
- OS.PhMakeGhostBitmap(newHandle);
- OS.memmove (phImage, newHandle, 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 (newHandle, phImage, PhImage_t.sizeof);
- }
- handle = newHandle;
- 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, 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);
+ if (srcImage.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ switch (flag) {
+ case SWT.IMAGE_COPY:
+ case SWT.IMAGE_DISABLE:
+ this.type = srcImage.type;
+ int srcHandle = srcImage.handle;
+ int newHandle = OS.PiDuplicateImage (srcHandle, 0);
+ if (newHandle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ if (flag == SWT.IMAGE_COPY) {
+ /*
+ * Bug in Photon. The image returned by PiDuplicateImage might
+ * have the same mask_bm/alpha as the original image. The fix
+ * is to detect this case and copy mask_bm/alpha if necessary.
+ */
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove (phImage, srcHandle, PhImage_t.sizeof);
+ PhImage_t newPhImage = new PhImage_t();
+ OS.memmove(newPhImage, newHandle, PhImage_t.sizeof);
+ if (newPhImage.mask_bm != 0 && phImage.mask_bm == newPhImage.mask_bm) {
+ int length = newPhImage.mask_bpl * newPhImage.size_h;
+ int ptr = OS.malloc(length);
+ OS.memmove(ptr, newPhImage.mask_bm, length);
+ newPhImage.mask_bm = ptr;
+ }
+ if (newPhImage.alpha != 0 && phImage.alpha == newPhImage.alpha) {
+ 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_bpl * alpha.src_alpha_map_dim_h;
+ int ptr = OS.malloc(length);
+ OS.memmove(ptr, alpha.src_alpha_map_map, length);
+ alpha.src_alpha_map_map = ptr;
+ }
+ int ptr = OS.malloc(PgAlpha_t.sizeof);
+ OS.memmove(ptr, alpha, PgAlpha_t.sizeof);
+ newPhImage.alpha = ptr;
+ }
+ OS.memmove(newHandle, newPhImage, PhImage_t.sizeof);
+ transparentPixel = srcImage.transparentPixel;
+ } else {
+ PhImage_t phImage = new PhImage_t();
+ OS.PhMakeGhostBitmap(newHandle);
+ OS.memmove (phImage, newHandle, 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 (newHandle, phImage, PhImage_t.sizeof);
+ }
+ handle = newHandle;
+ 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);
+ }
+}
+
/**
* Constructs an empty instance of this class with the
* width and height of the specified rectangle. The result
@@ -315,14 +315,14 @@ public Image(Device device, Image srcImage, int flag) {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
* </ul>
*/
-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, 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);
+}
+
/**
* Constructs an instance of this class from the given
* <code>ImageData</code>.
@@ -338,13 +338,13 @@ public Image(Device device, Rectangle bounds) {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
* </ul>
*/
-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 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);
+}
+
/**
* Constructs an instance of this class, whose type is
* <code>SWT.ICON</code>, from the two given <code>ImageData</code>
@@ -374,22 +374,22 @@ public Image(Device device, ImageData data) {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
* </ul>
*/
-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, 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);
+}
+
/**
* Constructs an instance of this class by loading its representation
* from the specified input stream. Throws an error if an error
@@ -422,13 +422,13 @@ public Image(Device device, ImageData source, ImageData mask) {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
* </ul>
*/
-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, 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);
+}
+
/**
* Constructs an instance of this class by loading its representation
* from the file with the specified name. Throws an error if an error
@@ -454,28 +454,28 @@ public Image (Device device, InputStream stream) {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
* </ul>
*/
-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 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);
+}
+
/**
* Disposes of the operating system resources associated with
* the image. Applications must dispose of all images which
* they allocate.
*/
-public void dispose () {
- if (handle == 0) return;
- if (device.isDisposed()) return;
- destroyImage(handle);
- handle = 0;
- memGC = null;
- if (device.tracking) device.dispose_Object(this);
- device = null;
-}
-
+public void dispose () {
+ if (handle == 0) return;
+ if (device.isDisposed()) return;
+ destroyImage(handle);
+ handle = 0;
+ memGC = null;
+ if (device.tracking) device.dispose_Object(this);
+ device = null;
+}
+
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -486,13 +486,13 @@ public void dispose () {
*
* @see #hashCode
*/
-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 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;
+}
+
/**
* Returns the color to which to map the transparent pixel, or null if
* the receiver has no transparent pixel.
@@ -511,43 +511,43 @@ public boolean equals (Object object) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public Color getBackground() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- 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 Color getBackground() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ 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);
+}
+
/**
* Returns the bounds of the receiver. The rectangle will always
* have x and y values of 0, and the width and height of the
@@ -560,13 +560,13 @@ public Color getBackground() {
* <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
* </ul>
*/
-public Rectangle getBounds() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- PhImage_t image = new PhImage_t();
- OS.memmove(image, handle, PhImage_t.sizeof);
- return new Rectangle(0, 0, image.size_w, image.size_h);
-}
-
+public Rectangle getBounds() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ PhImage_t image = new PhImage_t();
+ OS.memmove(image, handle, PhImage_t.sizeof);
+ return new Rectangle(0, 0, image.size_w, image.size_h);
+}
+
/**
* Returns an <code>ImageData</code> based on the receiver
* Modifications made to this <code>ImageData</code> will not
@@ -581,85 +581,85 @@ public Rectangle getBounds() {
*
* @see ImageData
*/
-public ImageData getImageData() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- PhImage_t phImage = new PhImage_t();
- OS.memmove(phImage, handle, PhImage_t.sizeof);
- int depth = 0;
- 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 ImageData getImageData() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove(phImage, handle, PhImage_t.sizeof);
+ int depth = 0;
+ 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;
+}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -670,211 +670,211 @@ public ImageData getImageData() {
*
* @see #equals
*/
-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;
-
- /*
- * Feature in Photon. Photon does not support 2-bit depth images and
- * memory contexts can not be created on 1 & 4-bit depth images. The
- * fix is to create 8-bit depth images instead.
- */
- if (i.depth == 1 || i.depth == 2 || i.depth == 4) {
- ImageData img = new ImageData(i.width, i.height, 8, i.palette);
- ImageData.blit(ImageData.BLIT_SRC,
- i.data, i.depth, i.bytesPerLine, img.getByteOrder(), 0, 0, i.width, i.height, null, null, null,
- ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
- img.data, img.depth, img.bytesPerLine, img.getByteOrder(), 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 {
- final PaletteData palette = i.palette;
- final int redMask = palette.redMask;
- final int greenMask = palette.greenMask;
- final int blueMask = palette.blueMask;
- int newDepth = i.depth;
- int newOrder = ImageData.MSB_FIRST;
- PaletteData newPalette = null;
-
- switch (i.depth) {
- case 8:
- newDepth = 16;
- newOrder = ImageData.LSB_FIRST;
- newPalette = new PaletteData(0xF800, 0x7E0, 0x1F);
- type = OS.Pg_IMAGE_DIRECT_565;
- break;
- case 16:
- newOrder = ImageData.LSB_FIRST;
- 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, newDepth, newPalette);
- ImageData.blit(ImageData.BLIT_SRC,
- i.data, i.depth, i.bytesPerLine, i.getByteOrder(), 0, 0, i.width, i.height, redMask, greenMask, blueMask,
- ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
- img.data, img.depth, img.bytesPerLine, newOrder, 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_bpl = (short)i.width;
- alpha.src_alpha_map_dim_w = (short)i.width;
- alpha.src_alpha_map_dim_h = (short)i.height;
- alpha.src_alpha_map_map = ptr;
- }
- 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 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;
+
+ /*
+ * Feature in Photon. Photon does not support 2-bit depth images and
+ * memory contexts can not be created on 1 & 4-bit depth images. The
+ * fix is to create 8-bit depth images instead.
+ */
+ if (i.depth == 1 || i.depth == 2 || i.depth == 4) {
+ ImageData img = new ImageData(i.width, i.height, 8, i.palette);
+ ImageData.blit(ImageData.BLIT_SRC,
+ i.data, i.depth, i.bytesPerLine, img.getByteOrder(), 0, 0, i.width, i.height, null, null, null,
+ ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
+ img.data, img.depth, img.bytesPerLine, img.getByteOrder(), 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 {
+ final PaletteData palette = i.palette;
+ final int redMask = palette.redMask;
+ final int greenMask = palette.greenMask;
+ final int blueMask = palette.blueMask;
+ int newDepth = i.depth;
+ int newOrder = ImageData.MSB_FIRST;
+ PaletteData newPalette = null;
+
+ switch (i.depth) {
+ case 8:
+ newDepth = 16;
+ newOrder = ImageData.LSB_FIRST;
+ newPalette = new PaletteData(0xF800, 0x7E0, 0x1F);
+ type = OS.Pg_IMAGE_DIRECT_565;
+ break;
+ case 16:
+ newOrder = ImageData.LSB_FIRST;
+ 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, newDepth, newPalette);
+ ImageData.blit(ImageData.BLIT_SRC,
+ i.data, i.depth, i.bytesPerLine, i.getByteOrder(), 0, 0, i.width, i.height, redMask, greenMask, blueMask,
+ ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
+ img.data, img.depth, img.bytesPerLine, newOrder, 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_bpl = (short)i.width;
+ alpha.src_alpha_map_dim_w = (short)i.width;
+ alpha.src_alpha_map_dim_h = (short)i.height;
+ alpha.src_alpha_map_map = ptr;
+ }
+ 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;
+}
+
/**
* Invokes platform specific functionality to allocate a new GC handle.
* <p>
@@ -890,30 +890,30 @@ void init(Device device, ImageData i) {
*
* @private
*/
-public int internal_new_GC (GCData data) {
- if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- /*
- * Create a new GC that can draw into the image.
- * Only supported for bitmaps.
- */
- 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 int internal_new_GC (GCData data) {
+ if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ /*
+ * Create a new GC that can draw into the image.
+ * Only supported for bitmaps.
+ */
+ 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;
+}
+
/**
* Invokes platform specific functionality to dispose a GC handle.
* <p>
@@ -929,10 +929,10 @@ public int internal_new_GC (GCData data) {
*
* @private
*/
-public void internal_dispose_GC (int pmMC, GCData data) {
- OS.PmMemReleaseMC(pmMC);
-}
-
+public void internal_dispose_GC (int pmMC, GCData data) {
+ OS.PmMemReleaseMC(pmMC);
+}
+
/**
* Returns <code>true</code> if the image has been disposed,
* and <code>false</code> otherwise.
@@ -943,86 +943,86 @@ public void internal_dispose_GC (int pmMC, GCData data) {
*
* @return <code>true</code> when the image is disposed and <code>false</code> otherwise
*/
-public boolean isDisposed() {
- return handle == 0;
-}
-
-/**
- * Sets the color to which to map the transparent pixel.
- * <p>
- * There are certain uses of <code>Images</code> that do not support
- * transparency (for example, setting an image into a button or label).
- * In these cases, it may be desired to simulate transparency by using
- * the background color of the widget to paint the transparent pixels
- * of the image. This method specifies the color that will be used in
- * these cases. For example:
- * <pre>
- * Button b = new Button();
- * image.setBackground(b.getBackground());>
- * b.setImage(image);
- * </pre>
- * </p><p>
- * The image may be modified by this operation (in effect, the
- * transparent regions may be filled with the supplied color). Hence
- * this operation is not reversible and it is not legal to call
- * this function twice or with a null argument.
- * </p><p>
- * This method has no effect if the receiver does not have a transparent
- * pixel value.
- * </p>
- *
- * @param color the color to use when a transparent pixel is specified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the color is null</li>
- * <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
- * </ul>
+public boolean isDisposed() {
+ return handle == 0;
+}
+
+/**
+ * Sets the color to which to map the transparent pixel.
+ * <p>
+ * There are certain uses of <code>Images</code> that do not support
+ * transparency (for example, setting an image into a button or label).
+ * In these cases, it may be desired to simulate transparency by using
+ * the background color of the widget to paint the transparent pixels
+ * of the image. This method specifies the color that will be used in
+ * these cases. For example:
+ * <pre>
+ * Button b = new Button();
+ * image.setBackground(b.getBackground());>
+ * b.setImage(image);
+ * </pre>
+ * </p><p>
+ * The image may be modified by this operation (in effect, the
+ * transparent regions may be filled with the supplied color). Hence
+ * this operation is not reversible and it is not legal to call
+ * this function twice or with a null argument.
+ * </p><p>
+ * This method has no effect if the receiver does not have a transparent
+ * pixel value.
+ * </p>
+ *
+ * @param color the color to use when a transparent pixel is specified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the color is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
*/
-public void setBackground(Color color) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (transparentPixel == -1) return;
-
- PhImage_t phImage = new PhImage_t();
- OS.memmove(phImage, handle, PhImage_t.sizeof);
- int phPalette = phImage.palette;
- 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;
-}
-
+public void setBackground(Color color) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (transparentPixel == -1) return;
+
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove(phImage, handle, PhImage_t.sizeof);
+ int phPalette = phImage.palette;
+ 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;
+}
+
/**
* Returns a string containing a concise, human-readable
* description of the receiver.
*
* @return a string representation of the receiver
*/
-public String toString () {
- if (isDisposed()) return "Image {*DISPOSED*}";
- return "Image {" + handle + "}";
-}
-
+public String toString () {
+ if (isDisposed()) return "Image {*DISPOSED*}";
+ return "Image {" + handle + "}";
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Region.java
index e0a506ba93..8b95059741 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Region.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Region.java
@@ -1,15 +1,15 @@
-package org.eclipse.swt.graphics;
-
-/*
+package org.eclipse.swt.graphics;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
/**
* Instances of this class represent areas of an x-y coordinate
* system that are aggregates of the areas covered by a number
@@ -20,16 +20,16 @@ import org.eclipse.swt.*;
* when those instances are no longer required.
* </p>
*/
-public final class Region {
-
- /**
- * the OS resource for the region
- * (Warning: This field is platform dependent)
+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 int handle;
+
+ static int EMPTY_REGION = -1;
+
/**
* Constructs a new empty region.
*
@@ -37,14 +37,14 @@ public final class Region {
* <li>ERROR_NO_HANDLES if a handle could not be obtained for region creation</li>
* </ul>
*/
-public Region () {
- handle = EMPTY_REGION;
-}
-Region(int handle) {
- this.handle = handle;
-}
-
-
+public Region () {
+ handle = EMPTY_REGION;
+}
+Region(int handle) {
+ this.handle = handle;
+}
+
+
/**
* Adds the given rectangle to the collection of rectangles
* the receiver maintains to describe its area.
@@ -59,22 +59,22 @@ Region(int handle) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void add (Rectangle rect) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (handle == 0) return;
- int tile_ptr = OS.PhGetTile();
- PhTile_t tile = new PhTile_t();
- 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 (Rectangle rect) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (handle == 0) return;
+ int tile_ptr = OS.PhGetTile();
+ PhTile_t tile = new PhTile_t();
+ 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);
+}
+
/**
* Adds all of the rectangles which make up the area covered
* by the argument to the collection of rectangles the receiver
@@ -90,17 +90,17 @@ public void add (Rectangle rect) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public void add (Region region) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if (handle == 0) return;
- if (region.handle == EMPTY_REGION) return;
- int copy = OS.PhCopyTiles(region.handle);
- if (handle == EMPTY_REGION) handle = copy;
- else handle = OS.PhAddMergeTiles (handle, copy, null);
-}
-
+public void add (Region region) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (handle == 0) return;
+ if (region.handle == EMPTY_REGION) return;
+ int copy = OS.PhCopyTiles(region.handle);
+ if (handle == EMPTY_REGION) handle = copy;
+ else handle = OS.PhAddMergeTiles (handle, copy, null);
+}
+
/**
* Returns <code>true</code> if the point specified by the
* arguments is inside the area specified by the receiver,
@@ -114,21 +114,21 @@ public void add (Region region) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public boolean contains (int x, int y) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (handle == 0 || handle == EMPTY_REGION) return false;
- int tile_ptr = OS.PhGetTile();
- PhTile_t tile = new PhTile_t();
- 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 (int x, int y) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle == 0 || handle == EMPTY_REGION) return false;
+ int tile_ptr = OS.PhGetTile();
+ PhTile_t tile = new PhTile_t();
+ 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;
+}
+
/**
* Returns <code>true</code> if the given point is inside the
* area specified by the receiver, and <code>false</code>
@@ -144,22 +144,22 @@ public boolean contains (int x, int y) {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public boolean contains (Point pt) {
- if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
- return contains(pt.x, pt.y);
-}
-
+public boolean contains (Point pt) {
+ if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return contains(pt.x, pt.y);
+}
+
/**
* Disposes of the operating system resources associated with
* the region. Applications must dispose of all regions which
* they allocate.
*/
-public void dispose () {
- if (handle == 0) return;
- if (handle != EMPTY_REGION) OS.PhFreeTiles (handle);
- handle = 0;
-}
-
+public void dispose () {
+ if (handle == 0) return;
+ if (handle != EMPTY_REGION) OS.PhFreeTiles (handle);
+ handle = 0;
+}
+
/**
* Compares the argument to the receiver, and returns true
* if they represent the <em>same</em> object using a class
@@ -170,13 +170,13 @@ public void dispose () {
*
* @see #hashCode
*/
-public boolean equals (Object object) {
- if (this == object) return true;
- if (!(object instanceof Region)) return false;
- Region region = (Region)object;
- return handle == region.handle;
-}
-
+public boolean equals (Object object) {
+ if (this == object) return true;
+ if (!(object instanceof Region)) return false;
+ Region region = (Region)object;
+ return handle == region.handle;
+}
+
/**
* Returns a rectangle which represents the rectangular
* union of the collection of rectangles the receiver
@@ -190,26 +190,26 @@ public boolean equals (Object object) {
*
* @see Rectangle#union
*/
-public Rectangle getBounds() {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (handle == 0 || handle == EMPTY_REGION) return new Rectangle(0, 0, 0, 0);
- PhTile_t tile = new PhTile_t();
- int temp_tile;
- 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 Rectangle getBounds() {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle == 0 || handle == EMPTY_REGION) return new Rectangle(0, 0, 0, 0);
+ PhTile_t tile = new PhTile_t();
+ int temp_tile;
+ 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);
+}
+
/**
* Returns an integer hash code for the receiver. Any two
* objects which return <code>true</code> when passed to
@@ -220,10 +220,10 @@ public Rectangle getBounds() {
*
* @see #equals
*/
-public int hashCode () {
- return handle;
-}
-
+public int hashCode () {
+ return handle;
+}
+
/**
* Returns <code>true</code> if the rectangle described by the
* arguments intersects with any of the rectangles the receiver
@@ -241,23 +241,23 @@ public int hashCode () {
*
* @see Rectangle#intersects
*/
-public boolean intersects (int x, int y, int width, int height) {
- if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (handle == 0 || handle == EMPTY_REGION) return false;
- int tile_ptr = OS.PhGetTile();
- PhTile_t tile = new PhTile_t();
- 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 (int x, int y, int width, int height) {
+ if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (handle == 0 || handle == EMPTY_REGION) return false;
+ int tile_ptr = OS.PhGetTile();
+ PhTile_t tile = new PhTile_t();
+ 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;
+}
+
/**
* Returns <code>true</code> if the given rectangle intersects
* with any of the rectangles the receiver mainains to describe
@@ -275,11 +275,11 @@ public boolean intersects (int x, int y, int width, int height) {
*
* @see Rectangle#intersects
*/
-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 intersects (Rectangle rect) {
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return intersects(rect.x, rect.y, rect.width, rect.height);
+}
+
/**
* Returns <code>true</code> if the region has been disposed,
* and <code>false</code> otherwise.
@@ -290,10 +290,10 @@ public boolean intersects (Rectangle rect) {
*
* @return <code>true</code> when the region is disposed, and <code>false</code> otherwise
*/
-public boolean isDisposed() {
- return handle == 0;
-}
-
+public boolean isDisposed() {
+ return handle == 0;
+}
+
/**
* Returns <code>true</code> if the receiver does not cover any
* area in the (x, y) coordinate plane, and <code>false</code> if
@@ -305,23 +305,23 @@ public boolean isDisposed() {
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
* </ul>
*/
-public boolean isEmpty () {
- return getBounds().isEmpty();
-
-}
-
-public static Region photon_new(int handle) {
- return new Region(handle);
-}
-
+public boolean isEmpty () {
+ return getBounds().isEmpty();
+
+}
+
+public static Region photon_new(int handle) {
+ return new Region(handle);
+}
+
/**
* Returns a string containing a concise, human-readable
* description of the receiver.
*
* @return a string representation of the receiver
*/
-public String toString () {
- if (isDisposed()) return "Region {*DISPOSED*}";
- return "Region {" + handle + "}";
-}
+public String toString () {
+ if (isDisposed()) return "Region {*DISPOSED*}";
+ return "Region {" + handle + "}";
+}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/Converter.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/Converter.java
index aa6c11ddd1..920f0849d8 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/Converter.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/Converter.java
@@ -1,14 +1,14 @@
-package org.eclipse.swt.internal;
-
-import java.io.UnsupportedEncodingException;
-
-/*
+package org.eclipse.swt.internal;
+
+import java.io.UnsupportedEncodingException;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
/**
* This class implements the conversions between unicode characters
* and the <em>platform supported</em> representation for characters.
@@ -17,47 +17,47 @@ import java.io.UnsupportedEncodingException;
* encoding will be converted to an arbitrary platform specific character.
* </p>
*/
-
-public final class Converter {
- public static final byte [] NullByteArray = new byte [1];
- public static final byte [] EmptyByteArray = new byte [0];
- public static final char [] EmptyCharArray = new char [0];
+
+public final class Converter {
+ public static final byte [] NullByteArray = new byte [1];
+ public static final byte [] EmptyByteArray = new byte [0];
+ public static final char [] EmptyCharArray = new char [0];
/**
* Returns the default code page for the platform where the
* application is currently running.
*
* @return the default code page
*/
-public static String defaultCodePage () {
- return "UTF8";
-}
-public static char [] mbcsToWcs (String codePage, byte [] buffer) {
- try {
- return new String (buffer, defaultCodePage ()).toCharArray ();
- } catch (UnsupportedEncodingException e) {
- return EmptyCharArray;
- }
-}
-public static byte [] wcsToMbcs (String codePage, String string, boolean terminate) {
- try {
- if (!terminate) return string.getBytes (defaultCodePage ());
- byte [] buffer1 = string.getBytes (defaultCodePage ());
- byte [] buffer2 = new byte [buffer1.length + 1];
- System.arraycopy (buffer1, 0, buffer2, 0, buffer1.length);
- return buffer2;
- } catch (UnsupportedEncodingException e) {
- return terminate ? NullByteArray : EmptyByteArray;
- }
-}
-public static byte [] wcsToMbcs (String codePage, char [] buffer, boolean terminate) {
- try {
- if (!terminate) return new String (buffer).getBytes (defaultCodePage ());
- byte [] buffer1 = new String (buffer).getBytes (defaultCodePage ());
- byte [] buffer2 = new byte [buffer1.length + 1];
- System.arraycopy (buffer1, 0, buffer2, 0, buffer1.length);
- return buffer2;
- } catch (UnsupportedEncodingException e) {
- return terminate ? NullByteArray : EmptyByteArray;
- }
-}
-}
+public static String defaultCodePage () {
+ return "UTF8";
+}
+public static char [] mbcsToWcs (String codePage, byte [] buffer) {
+ try {
+ return new String (buffer, defaultCodePage ()).toCharArray ();
+ } catch (UnsupportedEncodingException e) {
+ return EmptyCharArray;
+ }
+}
+public static byte [] wcsToMbcs (String codePage, String string, boolean terminate) {
+ try {
+ if (!terminate) return string.getBytes (defaultCodePage ());
+ byte [] buffer1 = string.getBytes (defaultCodePage ());
+ byte [] buffer2 = new byte [buffer1.length + 1];
+ System.arraycopy (buffer1, 0, buffer2, 0, buffer1.length);
+ return buffer2;
+ } catch (UnsupportedEncodingException e) {
+ return terminate ? NullByteArray : EmptyByteArray;
+ }
+}
+public static byte [] wcsToMbcs (String codePage, char [] buffer, boolean terminate) {
+ try {
+ if (!terminate) return new String (buffer).getBytes (defaultCodePage ());
+ byte [] buffer1 = new String (buffer).getBytes (defaultCodePage ());
+ byte [] buffer2 = new byte [buffer1.length + 1];
+ System.arraycopy (buffer1, 0, buffer2, 0, buffer1.length);
+ return buffer2;
+ } catch (UnsupportedEncodingException e) {
+ return terminate ? NullByteArray : EmptyByteArray;
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java
index 9cce3f3ad4..2497daa884 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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.*;
+
/**
* Instances of this class represent a selectable user interface object that
* issues notification when pressed and released.
@@ -36,9 +36,9 @@ import org.eclipse.swt.events.*;
* within the SWT implementation.
* </p>
*/
-public class Button extends Control {
- Image image;
-
+public class Button extends Control {
+ Image image;
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -75,24 +75,24 @@ public class Button extends Control {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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 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;
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the control is selected, by sending
@@ -117,151 +117,151 @@ static int checkStyle (int style) {
* @see #removeSelectionListener
* @see SelectionEvent
*/
-public void addSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
-void click () {
- int rid = OS.PtWidgetRid (handle);
- if (rid == 0) return;
- PhEvent_t event = new PhEvent_t ();
- event.emitter_rid = rid;
- event.emitter_handle = handle;
- event.collector_rid = rid;
- event.collector_handle = handle;
- event.flags = OS.Ph_EVENT_DIRECT;
- event.processing_flags = OS.Ph_FAKE_EVENT;
- event.type = OS.Ph_EV_BUT_PRESS;
- event.num_rects = 1;
- PhPointerEvent_t pe = new PhPointerEvent_t ();
- pe.click_count = 1;
- pe.buttons = OS.Ph_BUTTON_SELECT;
- PhRect_t rect = new PhRect_t ();
- int ptr = OS.malloc (PhEvent_t.sizeof + PhPointerEvent_t.sizeof + PhRect_t.sizeof);
- OS.memmove (ptr, event, PhEvent_t.sizeof);
- OS.memmove (ptr + PhEvent_t.sizeof, rect, PhRect_t.sizeof);
- OS.memmove (ptr + PhEvent_t.sizeof + PhRect_t.sizeof, pe, PhPointerEvent_t.sizeof);
- OS.PtSendEventToWidget (handle, ptr);
- OS.PtFlush ();
- event.type = OS.Ph_EV_BUT_RELEASE;
- event.subtype = OS.Ph_EV_RELEASE_REAL;
- OS.memmove (ptr, event, PhEvent_t.sizeof);
- OS.memmove (ptr + PhEvent_t.sizeof, rect, PhRect_t.sizeof);
- OS.memmove (ptr + PhEvent_t.sizeof + PhRect_t.sizeof, pe, PhPointerEvent_t.sizeof);
- OS.PtSendEventToWidget (handle, ptr);
- OS.free (ptr);
-}
-
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget();
- 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) {
- int [] args = {
- OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 1
- OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 4
- OS.Pt_ARG_MARGIN_TOP, 0, 0, // 7
- OS.Pt_ARG_MARGIN_BOTTOM, 0, 0, // 10
-// OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 13
-// OS.Pt_ARG_MARGIN_HEIGHT, 0, 0, // 16
- };
- OS.PtGetResources (handle, args.length / 3, args);
- PhArea_t area = new PhArea_t ();
- area.size_w = (short) wHint;
- area.size_h = (short) hHint;
-
- /*
- * This code is intentionally commented. Bug compatible with Windows.
- */
-// PhRect_t rect = new PhRect_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 + /*(args [13] * 2)*/ + args [1] + args [4];
- }
- if (hHint != SWT.DEFAULT) {
- height = area.size_h + /*(args [16] * 2)*/ + args [7] + args [10];
- }
- }
- return new Point (width, height);
-}
-
-void createHandle (int index) {
- state |= HANDLE;
- Display display = getDisplay ();
- int parentHandle = parent.parentingHandle ();
-
- /* ARROW button */
- if ((style & SWT.ARROW) != 0) {
- int [] args = {
- OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
- 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_FILL_COLOR, display.WIDGET_BACKGROUND, 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);
-}
-
-void drawWidget (int widget, int damage) {
- super.drawWidget (widget, damage);
- if ((style & SWT.ARROW) != 0) {
- 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);
- }
-}
-
+public void addSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+void click () {
+ int rid = OS.PtWidgetRid (handle);
+ if (rid == 0) return;
+ PhEvent_t event = new PhEvent_t ();
+ event.emitter_rid = rid;
+ event.emitter_handle = handle;
+ event.collector_rid = rid;
+ event.collector_handle = handle;
+ event.flags = OS.Ph_EVENT_DIRECT;
+ event.processing_flags = OS.Ph_FAKE_EVENT;
+ event.type = OS.Ph_EV_BUT_PRESS;
+ event.num_rects = 1;
+ PhPointerEvent_t pe = new PhPointerEvent_t ();
+ pe.click_count = 1;
+ pe.buttons = OS.Ph_BUTTON_SELECT;
+ PhRect_t rect = new PhRect_t ();
+ int ptr = OS.malloc (PhEvent_t.sizeof + PhPointerEvent_t.sizeof + PhRect_t.sizeof);
+ OS.memmove (ptr, event, PhEvent_t.sizeof);
+ OS.memmove (ptr + PhEvent_t.sizeof, rect, PhRect_t.sizeof);
+ OS.memmove (ptr + PhEvent_t.sizeof + PhRect_t.sizeof, pe, PhPointerEvent_t.sizeof);
+ OS.PtSendEventToWidget (handle, ptr);
+ OS.PtFlush ();
+ event.type = OS.Ph_EV_BUT_RELEASE;
+ event.subtype = OS.Ph_EV_RELEASE_REAL;
+ OS.memmove (ptr, event, PhEvent_t.sizeof);
+ OS.memmove (ptr + PhEvent_t.sizeof, rect, PhRect_t.sizeof);
+ OS.memmove (ptr + PhEvent_t.sizeof + PhRect_t.sizeof, pe, PhPointerEvent_t.sizeof);
+ OS.PtSendEventToWidget (handle, ptr);
+ OS.free (ptr);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget();
+ 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) {
+ int [] args = {
+ OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 1
+ OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 4
+ OS.Pt_ARG_MARGIN_TOP, 0, 0, // 7
+ OS.Pt_ARG_MARGIN_BOTTOM, 0, 0, // 10
+// OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 13
+// OS.Pt_ARG_MARGIN_HEIGHT, 0, 0, // 16
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ PhArea_t area = new PhArea_t ();
+ area.size_w = (short) wHint;
+ area.size_h = (short) hHint;
+
+ /*
+ * This code is intentionally commented. Bug compatible with Windows.
+ */
+// PhRect_t rect = new PhRect_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 + /*(args [13] * 2)*/ + args [1] + args [4];
+ }
+ if (hHint != SWT.DEFAULT) {
+ height = area.size_h + /*(args [16] * 2)*/ + args [7] + args [10];
+ }
+ }
+ return new Point (width, height);
+}
+
+void createHandle (int index) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int parentHandle = parent.parentingHandle ();
+
+ /* ARROW button */
+ if ((style & SWT.ARROW) != 0) {
+ int [] args = {
+ OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
+ 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_FILL_COLOR, display.WIDGET_BACKGROUND, 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);
+}
+
+void drawWidget (int widget, int damage) {
+ super.drawWidget (widget, damage);
+ if ((style & SWT.ARROW) != 0) {
+ 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);
+ }
+}
+
/**
* Returns a value which describes the position of the
* text or image in the receiver. The value will be one of
@@ -278,28 +278,28 @@ void drawWidget (int widget, int damage) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getAlignment () {
- checkWidget();
- 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;
-}
-
-boolean getDefault () {
- if ((style & SWT.PUSH) == 0) return false;
- int [] args = {OS.Pt_ARG_BEVEL_CONTRAST, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1] == 100;
-}
-
+public int getAlignment () {
+ checkWidget();
+ 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;
+}
+
+boolean getDefault () {
+ if ((style & SWT.PUSH) == 0) return false;
+ int [] args = {OS.Pt_ARG_BEVEL_CONTRAST, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1] == 100;
+}
+
/**
* Returns the receiver's image if it has one, or null
* if it does not.
@@ -311,11 +311,11 @@ boolean getDefault () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Image getImage () {
- checkWidget();
- return image;
-}
-
+public Image getImage () {
+ checkWidget();
+ return image;
+}
+
/**
* Returns <code>true</code> if the receiver is selected,
* and false otherwise.
@@ -332,16 +332,16 @@ public Image getImage () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getSelection () {
- checkWidget();
- if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
- return (OS.PtWidgetFlags (handle) & OS.Pt_SET) != 0;
-}
-
-String getNameText () {
- return getText ();
-}
-
+public boolean getSelection () {
+ checkWidget();
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
+ return (OS.PtWidgetFlags (handle) & OS.Pt_SET) != 0;
+}
+
+String getNameText () {
+ return getText ();
+}
+
/**
* Returns the receiver's text, which will be an empty
* string if it has never been set.
@@ -353,95 +353,95 @@ String getNameText () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public String getText () {
- checkWidget();
- 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, OS.Pt_CB_ACTIVATE);
-}
-
-int hotkeyProc (int widget, int data, int info) {
- if (setFocus ()) click ();
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_ACTIVATE (int widget, int info) {
- if ((style & SWT.RADIO) != 0) {
- if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
- selectRadio ();
- }
- }
- postEvent (SWT.Selection);
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_GOT_FOCUS (int widget, int info) {
- int result = super.Pt_CB_GOT_FOCUS (widget, info);
- // widget could be disposed at this point
- if (handle == 0) return result;
- if ((style & SWT.PUSH) == 0) return result;
- getShell ().setDefaultButton (this, false);
- return result;
-}
-
-int Pt_CB_LOST_FOCUS (int widget, int info) {
- int result = super.Pt_CB_LOST_FOCUS (widget, info);
- // widget could be disposed at this point
- if (handle == 0) return result;
- if ((style & SWT.PUSH) == 0) return result;
- if (getDefault ()) {
- getShell ().setDefaultButton (null, false);
- }
- return result;
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- image = null;
-}
-
+public String getText () {
+ checkWidget();
+ 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, OS.Pt_CB_ACTIVATE);
+}
+
+int hotkeyProc (int widget, int data, int info) {
+ if (setFocus ()) click ();
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_ACTIVATE (int widget, int info) {
+ if ((style & SWT.RADIO) != 0) {
+ if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
+ selectRadio ();
+ }
+ }
+ postEvent (SWT.Selection);
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_GOT_FOCUS (int widget, int info) {
+ int result = super.Pt_CB_GOT_FOCUS (widget, info);
+ // widget could be disposed at this point
+ if (handle == 0) return result;
+ if ((style & SWT.PUSH) == 0) return result;
+ getShell ().setDefaultButton (this, false);
+ return result;
+}
+
+int Pt_CB_LOST_FOCUS (int widget, int info) {
+ int result = super.Pt_CB_LOST_FOCUS (widget, info);
+ // widget could be disposed at this point
+ if (handle == 0) return result;
+ if ((style & SWT.PUSH) == 0) return result;
+ if (getDefault ()) {
+ getShell ().setDefaultButton (null, false);
+ }
+ return result;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ image = null;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the control is selected.
@@ -459,39 +459,39 @@ void releaseWidget () {
* @see SelectionListener
* @see #addSelectionListener
*/
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
-void selectRadio () {
- /*
- * This code is intentionally commented. When two groups
- * of radio buttons with the same parent are separated by
- * another control, the correct behavior should be that
- * the two groups act independently. This is consistent
- * with radio tool and menu items. The commented code
- * implements this behavior.
- */
-// int index = 0;
-// Control [] children = parent._getChildren ();
-// while (index < children.length && children [index] != this) index++;
-// int i = index - 1;
-// while (i >= 0 && children [i].setRadioSelection (false)) --i;
-// int j = index + 1;
-// while (j < children.length && children [j].setRadioSelection (false)) j++;
-// setSelection (true);
- Control [] children = parent._getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (this != child) child.setRadioSelection (false);
- }
- setSelection (true);
-}
-
+public void removeSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+void selectRadio () {
+ /*
+ * This code is intentionally commented. When two groups
+ * of radio buttons with the same parent are separated by
+ * another control, the correct behavior should be that
+ * the two groups act independently. This is consistent
+ * with radio tool and menu items. The commented code
+ * implements this behavior.
+ */
+// int index = 0;
+// Control [] children = parent._getChildren ();
+// while (index < children.length && children [index] != this) index++;
+// int i = index - 1;
+// while (i >= 0 && children [i].setRadioSelection (false)) --i;
+// int j = index + 1;
+// while (j < children.length && children [j].setRadioSelection (false)) j++;
+// setSelection (true);
+ Control [] children = parent._getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (this != child) child.setRadioSelection (false);
+ }
+ setSelection (true);
+}
+
/**
* Controls how text, images and arrows will be displayed
* in the receiver. The argument should be one of
@@ -508,39 +508,39 @@ void selectRadio () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setAlignment (int alignment) {
- checkWidget();
- 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 align = OS.Pt_LEFT;
- if ((style & SWT.CENTER) != 0) align = OS.Pt_CENTER;
- if ((style & SWT.RIGHT) != 0) align = OS.Pt_RIGHT;
- OS.PtSetResource (handle, OS.Pt_ARG_HORIZONTAL_ALIGNMENT, align, 0);
-}
-
-void setDefault (boolean value) {
- if ((style & SWT.PUSH) == 0) return;
- if (getShell ().parent == null) return;
- OS.PtSetResource (handle, OS.Pt_ARG_BEVEL_CONTRAST, value ? 100 : 20, 0);
-}
-
-boolean setRadioSelection (boolean value) {
- if ((style & SWT.RADIO) == 0) return false;
- if (getSelection () != value) {
- setSelection (value);
- postEvent (SWT.Selection);
- }
- return true;
-}
-
+public void setAlignment (int alignment) {
+ checkWidget();
+ 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 align = OS.Pt_LEFT;
+ if ((style & SWT.CENTER) != 0) align = OS.Pt_CENTER;
+ if ((style & SWT.RIGHT) != 0) align = OS.Pt_RIGHT;
+ OS.PtSetResource (handle, OS.Pt_ARG_HORIZONTAL_ALIGNMENT, align, 0);
+}
+
+void setDefault (boolean value) {
+ if ((style & SWT.PUSH) == 0) return;
+ if (getShell ().parent == null) return;
+ OS.PtSetResource (handle, OS.Pt_ARG_BEVEL_CONTRAST, value ? 100 : 20, 0);
+}
+
+boolean setRadioSelection (boolean value) {
+ if ((style & SWT.RADIO) == 0) return false;
+ if (getSelection () != value) {
+ setSelection (value);
+ postEvent (SWT.Selection);
+ }
+ return true;
+}
+
/**
* Sets the selection state of the receiver, if it is of type <code>CHECK</code>,
* <code>RADIO</code>, or <code>TOGGLE</code>.
@@ -557,12 +557,12 @@ boolean setRadioSelection (boolean value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (boolean selected) {
- checkWidget();
- if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
- OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET);
-}
-
+public void setSelection (boolean selected) {
+ checkWidget();
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
+ OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET);
+}
+
/**
* Sets the receiver's image to the argument, which may be
* null indicating that no image should be displayed.
@@ -577,23 +577,23 @@ public void setSelection (boolean selected) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setImage (Image image) {
- checkWidget();
- if ((style & SWT.ARROW) != 0) return;
- this.image = image;
- int imageHandle = 0;
- if (image != null) {
- if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- imageHandle = copyPhImage (image.handle);
- }
- 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 setImage (Image image) {
+ checkWidget();
+ if ((style & SWT.ARROW) != 0) return;
+ this.image = image;
+ int imageHandle = 0;
+ if (image != null) {
+ if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ imageHandle = copyPhImage (image.handle);
+ }
+ 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);
+}
+
/**
* Sets the receiver's text.
* <p>
@@ -611,52 +611,52 @@ public void setImage (Image image) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setText (String string) {
- checkWidget();
- 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);
- }
- replaceMnemonic (mnemonic, true, true);
- 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);
-}
-
-int traversalCode (int key_sym, PhKeyEvent_t ke) {
- int code = super.traversalCode (key_sym , ke);
- code |= SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_MNEMONIC;
- return code;
-}
-
-int widgetClass () {
- if ((style & (SWT.CHECK | SWT.RADIO)) != 0) return OS.PtToggleButton ();
- return OS.PtButton ();
-}
-
-}
+public void setText (String string) {
+ checkWidget();
+ 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);
+ }
+ replaceMnemonic (mnemonic, true, true);
+ 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);
+}
+
+int traversalCode (int key_sym, PhKeyEvent_t ke) {
+ int code = super.traversalCode (key_sym , ke);
+ code |= SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_MNEMONIC;
+ return code;
+}
+
+int widgetClass () {
+ if ((style & (SWT.CHECK | SWT.RADIO)) != 0) return OS.PtToggleButton ();
+ return OS.PtButton ();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java
index a79a25705e..faecdea2b4 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java
@@ -1,15 +1,15 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class provide a surface for drawing
* arbitrary graphics.
@@ -29,13 +29,13 @@ import org.eclipse.swt.graphics.*;
*
* @see Composite
*/
-public class Canvas extends Composite {
- Caret caret;
-
-Canvas () {
- /* Do nothing */
-}
-
+public class Canvas extends Composite {
+ Caret caret;
+
+Canvas () {
+ /* Do nothing */
+}
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -64,10 +64,10 @@ Canvas () {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Canvas (Composite parent, int style) {
- super (parent, style);
-}
-
+public Canvas (Composite parent, int style) {
+ super (parent, style);
+}
+
/**
* Returns the caret.
* <p>
@@ -86,53 +86,53 @@ public Canvas (Composite parent, int style) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Caret getCaret () {
- checkWidget();
- return caret;
-}
-
-int Pt_CB_GOT_FOCUS (int widget, int info) {
- int result = super.Pt_CB_GOT_FOCUS (widget, info);
- if (caret != null) caret.setFocus ();
- return result;
-}
-
-int Pt_CB_LOST_FOCUS (int widget, int info) {
- int result = super.Pt_CB_LOST_FOCUS (widget, info);
- if (caret != null) caret.killFocus ();
- return result;
-}
-
-int drawProc (int widget, int damage) {
- boolean isFocus = caret != null && caret.isFocusCaret ();
- if (isFocus) caret.killFocus ();
- int result = super.drawProc (widget, damage);
- if (isFocus) caret.setFocus ();
- return result;
-}
-
-public void redraw () {
- checkWidget();
- boolean isFocus = caret != null && caret.isFocusCaret ();
- if (isFocus) caret.killFocus ();
- super.redraw ();
- if (isFocus) caret.setFocus ();
-}
-
-public void redraw (int x, int y, int width, int height, boolean all) {
- checkWidget();
- boolean isFocus = caret != null && caret.isFocusCaret ();
- if (isFocus) caret.killFocus ();
- super.redraw (x, y, width, height, all);
- if (isFocus) caret.setFocus ();
-}
-
-void releaseWidget () {
- if (caret != null) caret.releaseResources ();
- caret = null;
- super.releaseWidget();
-}
-
+public Caret getCaret () {
+ checkWidget();
+ return caret;
+}
+
+int Pt_CB_GOT_FOCUS (int widget, int info) {
+ int result = super.Pt_CB_GOT_FOCUS (widget, info);
+ if (caret != null) caret.setFocus ();
+ return result;
+}
+
+int Pt_CB_LOST_FOCUS (int widget, int info) {
+ int result = super.Pt_CB_LOST_FOCUS (widget, info);
+ if (caret != null) caret.killFocus ();
+ return result;
+}
+
+int drawProc (int widget, int damage) {
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ int result = super.drawProc (widget, damage);
+ if (isFocus) caret.setFocus ();
+ return result;
+}
+
+public void redraw () {
+ checkWidget();
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ super.redraw ();
+ if (isFocus) caret.setFocus ();
+}
+
+public void redraw (int x, int y, int width, int height, boolean all) {
+ checkWidget();
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ super.redraw (x, y, width, height, all);
+ if (isFocus) caret.setFocus ();
+}
+
+void releaseWidget () {
+ if (caret != null) caret.releaseResources ();
+ caret = null;
+ super.releaseWidget();
+}
+
/**
* Scrolls a rectangular area of the receiver by first copying
* the source area to the destination and then causing the area
@@ -155,29 +155,29 @@ void releaseWidget () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) {
- checkWidget();
- if (width <= 0 || height <= 0) return;
- int deltaX = destX - x, deltaY = destY - y;
- if (deltaX == 0 && deltaY == 0) return;
- if (!isVisible ()) return;
- boolean isFocus = caret != null && caret.isFocusCaret ();
- if (isFocus) caret.killFocus ();
- GC gc = new GC (this);
- gc.copyArea (x, y, width, height, destX, destY);
- gc.dispose ();
- if (isFocus) caret.setFocus ();
-}
-
-int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
- checkWidget();
- boolean isFocus = caret != null && caret.isFocusCaret ();
- if (isFocus) caret.killFocus ();
- int result = super.setBounds (x, y, width, height, move, resize, events);
- if (isFocus) caret.setFocus ();
- return result;
-}
-
+public void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) {
+ checkWidget();
+ if (width <= 0 || height <= 0) return;
+ int deltaX = destX - x, deltaY = destY - y;
+ if (deltaX == 0 && deltaY == 0) return;
+ if (!isVisible ()) return;
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ GC gc = new GC (this);
+ gc.copyArea (x, y, width, height, destX, destY);
+ gc.dispose ();
+ if (isFocus) caret.setFocus ();
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
+ checkWidget();
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ int result = super.setBounds (x, y, width, height, move, resize, events);
+ if (isFocus) caret.setFocus ();
+ return result;
+}
+
/**
* Sets the receiver's caret.
* <p>
@@ -198,23 +198,23 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setCaret (Caret caret) {
- checkWidget();
- Caret newCaret = caret;
- Caret oldCaret = this.caret;
- this.caret = newCaret;
- if (isFocusControl ()) {
- if (oldCaret != null) oldCaret.killFocus ();
- if (newCaret != null) {
- if (newCaret.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- newCaret.setFocus ();
- }
- }
-}
-
-public void setFont (Font font) {
- checkWidget();
- super.setFont (font);
- if (caret != null) caret.setFont (font);
-}
-}
+public void setCaret (Caret caret) {
+ checkWidget();
+ Caret newCaret = caret;
+ Caret oldCaret = this.caret;
+ this.caret = newCaret;
+ if (isFocusControl ()) {
+ if (oldCaret != null) oldCaret.killFocus ();
+ if (newCaret != null) {
+ if (newCaret.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ newCaret.setFocus ();
+ }
+ }
+}
+
+public void setFont (Font font) {
+ checkWidget();
+ super.setFont (font);
+ if (caret != null) caret.setFont (font);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java
index 25d5a1a2f1..42bb7fdd31 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class provide an i-beam that is typically used
* as the insertion point for text.
@@ -25,14 +25,14 @@ import org.eclipse.swt.graphics.*;
* within the SWT implementation.
* </p>
*/
-public class Caret extends Widget {
- Canvas parent;
- int x, y, width, height;
- boolean isVisible, isShowing;
- int blinkRate = 0;
- Image image;
- Font font;
-
+public class Caret extends Widget {
+ Canvas parent;
+ int x, y, width, height;
+ boolean isVisible, isShowing;
+ int blinkRate = 0;
+ Image image;
+ Font font;
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -61,53 +61,53 @@ public class Caret extends Widget {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-// 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 prevContext = OS.PgSetGC (phGC);
- OS.PgSetRegion (OS.PtWidgetRid (handle));
- OS.PgSetDrawMode (OS.Pg_DRAWMODE_XOR);
- OS.PgSetFillColor (0xFFFFFF);
- int nWidth = width, nHeight = height;
- if (image != null) {
- Rectangle rect = image.getBounds ();
- nWidth = rect.width;
- nHeight = rect.height;
- }
- if (nWidth <= 0) nWidth = 2;
- OS.PgDrawIRect (x, y, x + nWidth - 1, y + nHeight - 1, OS.Pg_DRAW_FILL);
- OS.PgSetGC (prevContext);
- OS.PgDestroyGC (phGC);
- return true;
-}
-
+// 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 prevContext = OS.PgSetGC (phGC);
+ OS.PgSetRegion (OS.PtWidgetRid (handle));
+ OS.PgSetDrawMode (OS.Pg_DRAWMODE_XOR);
+ OS.PgSetFillColor (0xFFFFFF);
+ int nWidth = width, nHeight = height;
+ if (image != null) {
+ Rectangle rect = image.getBounds ();
+ nWidth = rect.width;
+ nHeight = rect.height;
+ }
+ if (nWidth <= 0) nWidth = 2;
+ OS.PgDrawIRect (x, y, x + nWidth - 1, y + nHeight - 1, OS.Pg_DRAW_FILL);
+ OS.PgSetGC (prevContext);
+ OS.PgDestroyGC (phGC);
+ return true;
+}
+
/**
* Returns a rectangle describing the receiver's size and location
* relative to its parent (or its display if its parent is null).
@@ -119,21 +119,21 @@ boolean drawCaret () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Rectangle getBounds () {
- checkWidget();
- if (image != null) {
- Rectangle rect = image.getBounds ();
- return new Rectangle (x, y, rect.width, rect.height);
- }
- return new Rectangle (x, y, width, height);
-}
-
-public Display getDisplay () {
- Composite parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-
+public Rectangle getBounds () {
+ checkWidget();
+ if (image != null) {
+ Rectangle rect = image.getBounds ();
+ return new Rectangle (x, y, rect.width, rect.height);
+ }
+ return new Rectangle (x, y, width, height);
+}
+
+public Display getDisplay () {
+ Composite parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
/**
* Returns the font that the receiver will use to paint textual information.
*
@@ -144,12 +144,12 @@ public Display getDisplay () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Font getFont () {
- checkWidget();
- if (font != null) return font;
- return parent.getFont ();
-}
-
+public Font getFont () {
+ checkWidget();
+ if (font != null) return font;
+ return parent.getFont ();
+}
+
/**
* Returns the image that the receiver will use to paint the caret.
*
@@ -160,11 +160,11 @@ public Font getFont () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Image getImage () {
- checkWidget();
- return image;
-}
-
+public Image getImage () {
+ checkWidget();
+ return image;
+}
+
/**
* Returns a point describing the receiver's location relative
* to its parent (or its display if its parent is null).
@@ -176,11 +176,11 @@ public Image getImage () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Point getLocation () {
- checkWidget();
- return new Point (x, y);
-}
-
+public Point getLocation () {
+ checkWidget();
+ return new Point (x, y);
+}
+
/**
* Returns the receiver's parent, which must be a <code>Canvas</code>.
*
@@ -191,11 +191,11 @@ public Point getLocation () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Canvas getParent () {
- checkWidget();
- return parent;
-}
-
+public Canvas getParent () {
+ checkWidget();
+ return parent;
+}
+
/**
* Returns a point describing the receiver's size.
*
@@ -206,15 +206,15 @@ public Canvas getParent () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Point getSize () {
- checkWidget();
- if (image != null) {
- Rectangle rect = image.getBounds ();
- return new Point (rect.width, rect.height);
- }
- return new Point (width, height);
-}
-
+public Point getSize () {
+ checkWidget();
+ if (image != null) {
+ Rectangle rect = image.getBounds ();
+ return new Point (rect.width, rect.height);
+ }
+ return new Point (width, height);
+}
+
/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.
@@ -232,65 +232,65 @@ public Point getSize () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getVisible () {
- checkWidget();
- return isVisible;
-}
-
-boolean hideCaret () {
- if (!isShowing) return true;
- isShowing = false;
- return drawCaret ();
-}
-
-/**
- * Returns <code>true</code> if the receiver is visible and all
- * of the receiver's ancestors are visible and <code>false</code>
- * otherwise.
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getVisible
+public boolean getVisible () {
+ checkWidget();
+ return isVisible;
+}
+
+boolean hideCaret () {
+ if (!isShowing) return true;
+ isShowing = false;
+ return drawCaret ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
*/
-public boolean isVisible () {
- checkWidget();
- return isVisible && parent.isVisible () && parent.hasFocus ();
-}
-
-boolean isFocusCaret () {
-// Display display = getDisplay ();
-// return this == display.currentCaret;
- return parent.hasFocus ();
-}
-
-void killFocus () {
-// Display display = getDisplay ();
-// if (display.currentCaret != this) return;
-// display.setCurrentCaret (null);
- if (isVisible) hideCaret ();
-}
-
-void releaseChild () {
- super.releaseChild ();
- if (this == parent.getCaret ()) parent.setCaret (null);
-}
-
-void releaseWidget () {
- super.releaseWidget ();
-// Display display = getDisplay ();
-// if (display.currentCaret == this) {
- hideCaret ();
-// display.setCurrentCaret (null);
-// }
- parent = null;
- image = null;
-}
-
+public boolean isVisible () {
+ checkWidget();
+ return isVisible && parent.isVisible () && parent.hasFocus ();
+}
+
+boolean isFocusCaret () {
+// Display display = getDisplay ();
+// return this == display.currentCaret;
+ return parent.hasFocus ();
+}
+
+void killFocus () {
+// Display display = getDisplay ();
+// if (display.currentCaret != this) return;
+// display.setCurrentCaret (null);
+ if (isVisible) hideCaret ();
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ if (this == parent.getCaret ()) parent.setCaret (null);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+// Display display = getDisplay ();
+// if (display.currentCaret == this) {
+ hideCaret ();
+// display.setCurrentCaret (null);
+// }
+ parent = null;
+ image = null;
+}
+
/**
* Sets the receiver's size and location to the rectangular
* area specified by the arguments. The <code>x</code> and
@@ -307,42 +307,42 @@ void releaseWidget () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setBounds (int x, int y, int width, int height) {
- checkWidget();
- if (this.x == x && this.y == y && this.width == width && this.height == height) return;
- boolean isFocus = isFocusCaret ();
- if (isFocus) hideCaret ();
- this.x = x; this.y = y;
- this.width = width; this.height = height;
- if (isFocus) showCaret ();
-}
-
-/**
- * Sets the receiver's size and location to the rectangular
- * area specified by the argument. The <code>x</code> and
- * <code>y</code> fields of the rectangle are relative to
- * the receiver's parent (or its display if its parent is null).
- *
- * @param rect the new bounds for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setBounds (Rectangle rect) {
- checkWidget();
- if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
- setBounds (rect.x, rect.y, rect.width, rect.height);
-}
-
-void setFocus () {
-// Display display = getDisplay ();
-// if (display.currentCaret == this) return;
-// display.setCurrentCaret (this);
- if (isVisible) showCaret ();
-}
-
+public void setBounds (int x, int y, int width, int height) {
+ checkWidget();
+ if (this.x == x && this.y == y && this.width == width && this.height == height) return;
+ boolean isFocus = isFocusCaret ();
+ if (isFocus) hideCaret ();
+ this.x = x; this.y = y;
+ this.width = width; this.height = height;
+ if (isFocus) showCaret ();
+}
+
+/**
+ * Sets the receiver's size and location to the rectangular
+ * area specified by the argument. The <code>x</code> and
+ * <code>y</code> fields of the rectangle are relative to
+ * the receiver's parent (or its display if its parent is null).
+ *
+ * @param rect the new bounds for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setBounds (Rectangle rect) {
+ checkWidget();
+ if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setBounds (rect.x, rect.y, rect.width, rect.height);
+}
+
+void setFocus () {
+// Display display = getDisplay ();
+// if (display.currentCaret == this) return;
+// display.setCurrentCaret (this);
+ if (isVisible) showCaret ();
+}
+
/**
* Sets the font that the receiver will use to paint textual information
* to the font specified by the argument, or to the default font for that
@@ -358,14 +358,14 @@ void setFocus () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setFont (Font font) {
- checkWidget();
- if (font != null && font.isDisposed ()) {
- error (SWT.ERROR_INVALID_ARGUMENT);
- }
- this.font = font;
-}
-
+public void setFont (Font font) {
+ checkWidget();
+ if (font != null && font.isDisposed ()) {
+ error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ this.font = font;
+}
+
/**
* Sets the image that the receiver will use to paint the caret
* to the image specified by the argument, or to the default
@@ -381,17 +381,17 @@ public void setFont (Font font) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setImage (Image image) {
- checkWidget();
- if (image != null && image.isDisposed ()) {
- error (SWT.ERROR_INVALID_ARGUMENT);
- }
- boolean isFocus = isFocusCaret ();
- if (isFocus) hideCaret ();
- this.image = image;
- if (isFocus) showCaret ();
-}
-
+public void setImage (Image image) {
+ checkWidget();
+ if (image != null && image.isDisposed ()) {
+ error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ boolean isFocus = isFocusCaret ();
+ if (isFocus) hideCaret ();
+ this.image = image;
+ if (isFocus) showCaret ();
+}
+
/**
* Sets the receiver's location to the point specified by
* the arguments which are relative to the receiver's
@@ -405,11 +405,11 @@ public void setImage (Image image) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setLocation (int x, int y) {
- checkWidget();
- setBounds (x, y, width, height);
-}
-
+public void setLocation (int x, int y) {
+ checkWidget();
+ setBounds (x, y, width, height);
+}
+
/**
* Sets the receiver's location to the point specified by
* the argument which is relative to the receiver's
@@ -422,12 +422,12 @@ public void setLocation (int x, int y) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setLocation (Point location) {
- checkWidget();
- if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
- setLocation (location.x, location.y);
-}
-
+public void setLocation (Point location) {
+ checkWidget();
+ if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setLocation (location.x, location.y);
+}
+
/**
* Sets the receiver's size to the point specified by the arguments.
*
@@ -439,11 +439,11 @@ public void setLocation (Point location) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSize (int width, int height) {
- checkWidget();
- setBounds (x, y, width, height);
-}
-
+public void setSize (int width, int height) {
+ checkWidget();
+ setBounds (x, y, width, height);
+}
+
/**
* Sets the receiver's size to the point specified by the argument.
*
@@ -458,12 +458,12 @@ public void setSize (int width, int height) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSize (Point size) {
- checkWidget();
- if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
- setSize (size.x, size.y);
-}
-
+public void setSize (Point size) {
+ checkWidget();
+ if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setSize (size.x, size.y);
+}
+
/**
* Marks the receiver as visible if the argument is <code>true</code>,
* and marks it invisible otherwise.
@@ -480,21 +480,21 @@ public void setSize (Point size) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setVisible (boolean visible) {
- checkWidget();
- if (visible == isVisible) return;
- isVisible = visible;
- if (!isFocusCaret ()) return;
- if (isVisible) {
- showCaret ();
- } else {
- hideCaret ();
- }
-}
-
-boolean showCaret () {
- if (isShowing) return true;
- isShowing = true;
- return drawCaret ();
-}
-}
+public void setVisible (boolean visible) {
+ checkWidget();
+ if (visible == isVisible) return;
+ isVisible = visible;
+ if (!isFocusCaret ()) return;
+ if (isVisible) {
+ showCaret ();
+ } else {
+ hideCaret ();
+ }
+}
+
+boolean showCaret () {
+ if (isShowing) return true;
+ isShowing = true;
+ return drawCaret ();
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java
index 948990b97a..53812e51b8 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class allow the user to select a color
* from a predefined set of available colors.
@@ -26,9 +26,9 @@ import org.eclipse.swt.graphics.*;
* within the SWT implementation.
* </p>
*/
-public class ColorDialog extends Dialog {
- RGB rgb;
-
+public class ColorDialog extends Dialog {
+ RGB rgb;
+
/**
* Constructs a new instance of this class given only its parent.
*
@@ -46,10 +46,10 @@ public class ColorDialog extends Dialog {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public ColorDialog (Shell parent) {
- this (parent, SWT.PRIMARY_MODAL);
-}
-
+public ColorDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -78,11 +78,11 @@ public ColorDialog (Shell parent) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public ColorDialog (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
-
+public ColorDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
+
/**
* Returns the currently selected color in the receiver.
*
@@ -90,10 +90,10 @@ public ColorDialog (Shell parent, int style) {
*
* @see PaletteData#getRGBs
*/
-public RGB getRGB () {
- return rgb;
-}
-
+public RGB getRGB () {
+ return rgb;
+}
+
/**
* Makes the receiver visible and brings it to the front
* of the display.
@@ -107,27 +107,27 @@ public RGB getRGB () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public RGB open () {
- int parentHandle = 0;
- if (parent != null && OS.PtWidgetIsRealized(parent.shellHandle)) {
- 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 RGB open () {
+ int parentHandle = 0;
+ if (parent != null && OS.PtWidgetIsRealized(parent.shellHandle)) {
+ 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;
+}
+
/**
* Returns the receiver's selected color to be the argument.
*
@@ -137,8 +137,8 @@ public RGB open () {
*
* @see PaletteData#getRGBs
*/
-public void setRGB (RGB rgb) {
- this.rgb = rgb;
-}
-
-}
+public void setRGB (RGB rgb) {
+ this.rgb = rgb;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java
index b2d0abd4b1..3cc13465d0 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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.*;
+
/**
* Instances of this class are controls that allow the user
* to choose an item from a list of items, or optionally
@@ -49,22 +49,22 @@ import org.eclipse.swt.events.*;
*
* @see List
*/
-public class Combo extends Composite {
- /**
- * the operating system limit for the number of characters
- * that the text field in an instance of this class can hold
- */
- public static final int LIMIT;
-
- /*
- * 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;
- }
-
+public class Combo extends Composite {
+ /**
+ * the operating system limit for the number of characters
+ * that the text field in an instance of this class can hold
+ */
+ public static final int LIMIT;
+
+ /*
+ * 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;
+ }
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -95,124 +95,124 @@ public class Combo extends Composite {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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) {
- checkWidget();
- //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 textWidget = OS.PtWidgetChildBack(handle);
- OS.PtWidgetPreferredSize(textWidget, dim);
- height += dim.h;
- PhRect_t rect = new PhRect_t ();
- PhArea_t area = new PhArea_t ();
- OS.PtSetAreaFromWidgetCanvas (textWidget, rect, area);
- width += area.size_w;
-
- /* Calculate maximum text width */
- int [] args = new int [] {
- OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0, // 1
- OS.Pt_ARG_ITEMS, 0, 0, // 4
- OS.Pt_ARG_TEXT_FONT, 0, 0, // 7
- OS.Pt_ARG_TEXT_STRING, 0, 0, // 10
- };
- OS.PtGetResources (handle, args.length / 3, args);
- int maxWidth = 0;
- rect = new PhRect_t();
- int str = args [10];
- int font = args [7];
- if (str != 0) {
- int length = OS.strlen (str);
- if (length > 0) {
- OS.PfExtentText(rect, null, font, str, length);
- maxWidth = Math.max(maxWidth, rect.lr_x - rect.ul_x + 1);
- }
- }
- int count = args [1];
- int [] buffer = new int [1];
- for (int i = 0; i < count; i++) {
- OS.memmove (buffer, args [4] + (i * 4), 4);
- str = buffer [0];
- int length = OS.strlen (str);
- if (length > 0) {
- OS.PfExtentText(rect, null, font, str, length);
- maxWidth = Math.max(maxWidth, rect.lr_x - rect.ul_x + 1);
- }
- }
- if (maxWidth == 0) maxWidth = DEFAULT_WIDTH;
- int [] args1 = new int [] {
- OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 1
- OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 4
- OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 7
- };
- OS.PtGetResources (textWidget, args1.length / 3, args1);
- maxWidth += args1 [1] + args1 [4] + args1 [7];
-
- 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) {
- state |= HANDLE;
- Display display = getDisplay ();
- int clazz = display.PtComboBox;
- int parentHandle = parent.parentingHandle ();
- 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 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) {
+ checkWidget();
+ //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 textWidget = OS.PtWidgetChildBack(handle);
+ OS.PtWidgetPreferredSize(textWidget, dim);
+ height += dim.h;
+ PhRect_t rect = new PhRect_t ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtSetAreaFromWidgetCanvas (textWidget, rect, area);
+ width += area.size_w;
+
+ /* Calculate maximum text width */
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0, // 1
+ OS.Pt_ARG_ITEMS, 0, 0, // 4
+ OS.Pt_ARG_TEXT_FONT, 0, 0, // 7
+ OS.Pt_ARG_TEXT_STRING, 0, 0, // 10
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ int maxWidth = 0;
+ rect = new PhRect_t();
+ int str = args [10];
+ int font = args [7];
+ if (str != 0) {
+ int length = OS.strlen (str);
+ if (length > 0) {
+ OS.PfExtentText(rect, null, font, str, length);
+ maxWidth = Math.max(maxWidth, rect.lr_x - rect.ul_x + 1);
+ }
+ }
+ int count = args [1];
+ int [] buffer = new int [1];
+ for (int i = 0; i < count; i++) {
+ OS.memmove (buffer, args [4] + (i * 4), 4);
+ str = buffer [0];
+ int length = OS.strlen (str);
+ if (length > 0) {
+ OS.PfExtentText(rect, null, font, str, length);
+ maxWidth = Math.max(maxWidth, rect.lr_x - rect.ul_x + 1);
+ }
+ }
+ if (maxWidth == 0) maxWidth = DEFAULT_WIDTH;
+ int [] args1 = new int [] {
+ OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 1
+ OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 4
+ OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 7
+ };
+ OS.PtGetResources (textWidget, args1.length / 3, args1);
+ maxWidth += args1 [1] + args1 [4] + args1 [7];
+
+ 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) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int clazz = display.PtComboBox;
+ int parentHandle = parent.parentingHandle ();
+ 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);
+}
+
/**
* Deselects the item at the given zero-relative index in the receiver's
* list. If the item at the index was already deselected, it remains
@@ -225,19 +225,19 @@ void createHandle (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void deselect (int index) {
- checkWidget();
- 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 deselect (int index) {
+ checkWidget();
+ 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);
+ }
+}
+
/**
* Deselects all selected items in the receiver's list.
* <p>
@@ -252,15 +252,15 @@ public void deselect (int index) {
*
* @see #clearSelection
*/
-public void deselectAll () {
- checkWidget();
- 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 deselectAll () {
+ checkWidget();
+ 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);
+}
+
/**
* Adds the argument to the end of the receiver's list.
*
@@ -279,16 +279,16 @@ public void deselectAll () {
*
* @see #add(String,int)
*/
-public void add (String string) {
- checkWidget();
- 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) {
+ checkWidget();
+ 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);
+}
+
/**
* Adds the argument to the receiver's list at the given
* zero-relative index.
@@ -315,23 +315,23 @@ public void add (String string) {
*
* @see #add(String)
*/
-public void add (String string, int index) {
- checkWidget();
- 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 add (String string, int index) {
+ checkWidget();
+ 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);
+ }
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver's text is modified, by sending
@@ -351,13 +351,13 @@ public void add (String string, int index) {
* @see ModifyListener
* @see #removeModifyListener
*/
-public void addModifyListener (ModifyListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Modify, typedListener);
-}
-
+public void addModifyListener (ModifyListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Modify, typedListener);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver's selection changes, by sending
@@ -382,18 +382,18 @@ public void addModifyListener (ModifyListener listener) {
* @see #removeSelectionListener
* @see SelectionEvent
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- 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 addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ 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);
+}
+
/**
* Sets the selection in the receiver's text field to an empty
* selection starting just before the first character. If the
@@ -411,92 +411,92 @@ protected void checkSubclass () {
*
* @see #deselectAll
*/
-public void clearSelection () {
- checkWidget();
- OS.PtTextSetSelection (handle, new int [] {0}, new int [] {0});
-}
-
-
-/**
- * Copies the selected text.
- * <p>
- * The current selection is copied to the clipboard.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.1
- */
-public void copy () {
- checkWidget();
- 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);
-}
-
-/**
- * Cuts the selected text.
- * <p>
- * The current selection is first copied to the
- * clipboard and then deleted from the widget.
- * </p>
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.1
- */
-public void cut () {
- checkWidget();
- 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);
-}
-
-byte [] defaultFont () {
- Display display = getDisplay ();
- return display.TEXT_FONT;
-}
-
-void deregister () {
- super.deregister ();
- int child = OS.PtWidgetChildBack (handle);
- WidgetTable.remove (child);
-}
-
-int focusHandle () {
-
- /*
- * Fetuare in Photon. The combo box does not receive
- * Pt_CB_GOT_FOCUS and Pt_CB_LOST_FOCUS callbacks itself.
- * Only the internal PtText receives them. The fix is to
- * add these callbacks in the internal PtText.
- */
- return OS.PtWidgetChildBack (handle);
-}
-
+public void clearSelection () {
+ checkWidget();
+ OS.PtTextSetSelection (handle, new int [] {0}, new int [] {0});
+}
+
+
+/**
+ * Copies the selected text.
+ * <p>
+ * The current selection is copied to the clipboard.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.1
+ */
+public void copy () {
+ checkWidget();
+ 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);
+}
+
+/**
+ * Cuts the selected text.
+ * <p>
+ * The current selection is first copied to the
+ * clipboard and then deleted from the widget.
+ * </p>
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.1
+ */
+public void cut () {
+ checkWidget();
+ 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);
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.TEXT_FONT;
+}
+
+void deregister () {
+ super.deregister ();
+ int child = OS.PtWidgetChildBack (handle);
+ WidgetTable.remove (child);
+}
+
+int focusHandle () {
+
+ /*
+ * Fetuare in Photon. The combo box does not receive
+ * Pt_CB_GOT_FOCUS and Pt_CB_LOST_FOCUS callbacks itself.
+ * Only the internal PtText receives them. The fix is to
+ * add these callbacks in the internal PtText.
+ */
+ return OS.PtWidgetChildBack (handle);
+}
+
/**
* Returns the item at the given, zero-relative index in the
* receiver's list. Throws an exception if the index is out
@@ -516,25 +516,25 @@ int focusHandle () {
* <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public String getItem (int index) {
- checkWidget();
- 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 String getItem (int index) {
+ checkWidget();
+ 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);
+}
+
/**
* Returns the number of items contained in the receiver's list.
*
@@ -548,13 +548,13 @@ public String getItem (int index) {
* <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public int getItemCount () {
- checkWidget();
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getItemCount () {
+ checkWidget();
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the height of the area which would be used to
* display <em>one</em> of the items in the receiver's list.
@@ -569,12 +569,12 @@ public int getItemCount () {
* <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public int getItemHeight () {
- checkWidget();
- //NOT DONE - NOT NEEDED
- return 0;
-}
-
+public int getItemHeight () {
+ checkWidget();
+ //NOT DONE - NOT NEEDED
+ return 0;
+}
+
/**
* Returns an array of <code>String</code>s which are the items
* in the receiver's list.
@@ -594,30 +594,30 @@ public int getItemHeight () {
* <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public String [] getItems () {
- checkWidget();
- 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;
-}
-
-String getNameText () {
- return getText ();
-}
-
+public String [] getItems () {
+ checkWidget();
+ 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;
+}
+
+String getNameText () {
+ return getText ();
+}
+
/**
* Returns a <code>Point</code> whose x coordinate is the start
* of the selection in the receiver's text field, and whose y
@@ -632,28 +632,28 @@ String getNameText () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Point getSelection () {
- checkWidget();
- 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 Point getSelection () {
+ checkWidget();
+ 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]);
+}
+
/**
* Returns the zero-relative index of the item which is currently
* selected in the receiver's list, or -1 if no item is selected.
@@ -665,19 +665,19 @@ public Point getSelection () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getSelectionIndex () {
- checkWidget();
- 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 getSelectionIndex () {
+ checkWidget();
+ 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;
+}
+
/**
* Returns a string containing a copy of the contents of the
* receiver's text field.
@@ -689,18 +689,18 @@ public int getSelectionIndex () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public String getText () {
- checkWidget();
- 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 String getText () {
+ checkWidget();
+ 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);
+}
+
/**
* Returns the height of the receivers's text field.
*
@@ -714,19 +714,19 @@ public String getText () {
* <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public int getTextHeight () {
- checkWidget();
- //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 getTextHeight () {
+ checkWidget();
+ //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;
+}
+
/**
* Returns the maximum number of characters that the receiver's
* text field is capable of holding. If this has not been changed
@@ -740,24 +740,24 @@ public int getTextHeight () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getTextLimit () {
- checkWidget();
- int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
-boolean hasFocus () {
- return OS.PtIsFocused (handle) != 0;
-}
-
-void hookEvents () {
- super.hookEvents ();
- int windowProc = getDisplay ().windowProc;
- OS.PtAddCallback (handle, OS.Pt_CB_SELECTION, windowProc, OS.Pt_CB_SELECTION);
- OS.PtAddCallback (handle, OS.Pt_CB_TEXT_CHANGED, windowProc, OS.Pt_CB_TEXT_CHANGED);
-}
-
+public int getTextLimit () {
+ checkWidget();
+ int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+boolean hasFocus () {
+ return OS.PtIsFocused (handle) != 0;
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_SELECTION, windowProc, OS.Pt_CB_SELECTION);
+ OS.PtAddCallback (handle, OS.Pt_CB_TEXT_CHANGED, windowProc, OS.Pt_CB_TEXT_CHANGED);
+}
+
/**
* Searches the receiver's list starting at the first item
* (index 0) until an item is found that is equal to the
@@ -775,12 +775,12 @@ void hookEvents () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int indexOf (String string) {
- checkWidget();
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- return OS.PtListItemPos (handle, buffer) - 1;
-}
-
+public int indexOf (String string) {
+ checkWidget();
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ return OS.PtListItemPos (handle, buffer) - 1;
+}
+
/**
* Searches the receiver's list starting at the given,
* zero-relative index until an item is found that is equal
@@ -799,80 +799,80 @@ public int indexOf (String string) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int indexOf (String string, int start) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (start == 0) return indexOf(string);
- 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 count = args [1];
- if (!(0 <= start && start < count)) return -1;
- int [] item = new int [1];
- for (int index=start; index<count; index++) {
- OS.memmove (item, args [4] + (index * 4), 4);
- int length = OS.strlen (item [0]);
- byte [] buffer = new byte [length];
- OS.memmove (buffer, item [0], length);
- if (string.equals(new String (Converter.mbcsToWcs (null, buffer)))) return index;
- }
- return -1;
-}
-
-/**
- * Pastes text from clipboard.
- * <p>
- * The selected text is deleted from the widget
- * and new text inserted from the clipboard.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.1
- */
-public void paste () {
- checkWidget();
- 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 Pt_CB_SELECTION (int widget, 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;
-}
-
-int Pt_CB_TEXT_CHANGED (int widget, int info) {
- sendEvent (SWT.Modify);
- return OS.Pt_CONTINUE;
-}
-
-void register () {
- super.register ();
- int child = OS.PtWidgetChildBack (handle);
- WidgetTable.put (child, this);
-}
-
+public int indexOf (String string, int start) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (start == 0) return indexOf(string);
+ 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 count = args [1];
+ if (!(0 <= start && start < count)) return -1;
+ int [] item = new int [1];
+ for (int index=start; index<count; index++) {
+ OS.memmove (item, args [4] + (index * 4), 4);
+ int length = OS.strlen (item [0]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, item [0], length);
+ if (string.equals(new String (Converter.mbcsToWcs (null, buffer)))) return index;
+ }
+ return -1;
+}
+
+/**
+ * Pastes text from clipboard.
+ * <p>
+ * The selected text is deleted from the widget
+ * and new text inserted from the clipboard.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.1
+ */
+public void paste () {
+ checkWidget();
+ 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 Pt_CB_SELECTION (int widget, 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;
+}
+
+int Pt_CB_TEXT_CHANGED (int widget, int info) {
+ sendEvent (SWT.Modify);
+ return OS.Pt_CONTINUE;
+}
+
+void register () {
+ super.register ();
+ int child = OS.PtWidgetChildBack (handle);
+ WidgetTable.put (child, this);
+}
+
/**
* Removes the items from the receiver's list which are
* between the given zero-relative start and end
@@ -892,21 +892,21 @@ void register () {
* <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public void remove (int start, int end) {
- checkWidget();
- 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);
- if ((style & SWT.READ_ONLY) !=0) {
- if (args [1] == count) OS.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, 0, 0);
- }
-}
-
+public void remove (int start, int end) {
+ checkWidget();
+ 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);
+ if ((style & SWT.READ_ONLY) !=0) {
+ if (args [1] == count) OS.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, 0, 0);
+ }
+}
+
/**
* Removes the item from the receiver's list at the given
* zero-relative index.
@@ -924,18 +924,18 @@ public void remove (int start, int end) {
* <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public void remove (int index) {
- checkWidget();
- 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);
- if ((style & SWT.READ_ONLY) !=0) {
- if (args [1] == 1) OS.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, 0, 0);
- }
-}
-
+public void remove (int index) {
+ checkWidget();
+ 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);
+ if ((style & SWT.READ_ONLY) !=0) {
+ if (args [1] == 1) OS.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, 0, 0);
+ }
+}
+
/**
* Searches the receiver's list starting at the first item
* until an item is found that is equal to the argument,
@@ -955,13 +955,13 @@ public void remove (int index) {
* <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public void remove (String string) {
- checkWidget();
- int index = indexOf (string, 0);
- if (index == -1) error (SWT.ERROR_ITEM_NOT_REMOVED);
- remove (index);
-}
-
+public void remove (String string) {
+ checkWidget();
+ int index = indexOf (string, 0);
+ if (index == -1) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ remove (index);
+}
+
/**
* Removes all of the items from the receiver's list.
* <p>
@@ -970,13 +970,13 @@ public void remove (String string) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void removeAll () {
- checkWidget();
- OS.PtListDeleteAllItems (handle);
- OS.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, 0, 0);
- sendEvent (SWT.Modify);
-}
-
+public void removeAll () {
+ checkWidget();
+ OS.PtListDeleteAllItems (handle);
+ OS.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, 0, 0);
+ sendEvent (SWT.Modify);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver's text is modified.
@@ -994,13 +994,13 @@ public void removeAll () {
* @see ModifyListener
* @see #addModifyListener
*/
-public void removeModifyListener (ModifyListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Modify, listener);
-}
-
+public void removeModifyListener (ModifyListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Modify, listener);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver's selection changes.
@@ -1018,14 +1018,14 @@ public void removeModifyListener (ModifyListener listener) {
* @see SelectionListener
* @see #addSelectionListener
*/
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
+public void removeSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
/**
* Selects the item at the given zero-relative index in the receiver's
* list. If the item at the index was already selected, it remains
@@ -1038,18 +1038,18 @@ public void removeSelectionListener (SelectionListener listener) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void select (int index) {
- checkWidget();
- if (index < 0) return;
- OS.PtSetResource (handle, OS.Pt_ARG_CBOX_SELECTION_ITEM, index + 1, 0);
-}
-
-int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
- checkWidget();
- int newHeight = (resize && (style & SWT.DROP_DOWN) != 0) ? getTextHeight() : height;
- return super.setBounds (x, y, width, newHeight, move, resize, events);
-}
-
+public void select (int index) {
+ checkWidget();
+ if (index < 0) return;
+ OS.PtSetResource (handle, OS.Pt_ARG_CBOX_SELECTION_ITEM, index + 1, 0);
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
+ checkWidget();
+ int newHeight = (resize && (style & SWT.DROP_DOWN) != 0) ? getTextHeight() : height;
+ return super.setBounds (x, y, width, newHeight, move, resize, events);
+}
+
/**
* Sets the text of the item in the receiver's list at the given
* zero-relative index to the string argument. This is equivalent
@@ -1071,21 +1071,21 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
* <li>ERROR_ITEM_NOT_ADDED - if the add operation fails because of an operating system failure</li>
* </ul>
*/
-public void setItem (int index, String string) {
- checkWidget();
- if (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 setItem (int index, String string) {
+ checkWidget();
+ 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);
+}
+
/**
* Sets the receiver's list to be the given array of items.
*
@@ -1099,25 +1099,25 @@ public void setItem (int index, String string) {
* <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public void setItems (String [] items) {
- checkWidget();
- 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]);
- }
- OS.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, 0, 0);
- sendEvent (SWT.Modify);
-}
-
+public void setItems (String [] items) {
+ checkWidget();
+ 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]);
+ }
+ OS.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, 0, 0);
+ sendEvent (SWT.Modify);
+}
+
/**
* Sets the selection in the receiver's text field to the
* range specified by the argument whose x coordinate is the
@@ -1134,12 +1134,12 @@ public void setItems (String [] items) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (Point selection) {
- checkWidget();
- if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
- OS.PtTextSetSelection (handle, new int [] {selection.x}, new int [] {selection.y});
-}
-
+public void setSelection (Point selection) {
+ checkWidget();
+ if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
+ OS.PtTextSetSelection (handle, new int [] {selection.x}, new int [] {selection.y});
+}
+
/**
* Sets the contents of the receiver's text field to the
* given string.
@@ -1161,25 +1161,25 @@ public void setSelection (Point selection) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setText (String string) {
- checkWidget();
- 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) {
- OS.PtSetResource (handle, OS.Pt_ARG_CBOX_SELECTION_ITEM, index, 0);
- sendEvent (SWT.Modify);
- }
- return;
- }
- int ptr = OS.malloc (buffer.length);
- OS.memmove (ptr, buffer, buffer.length);
- OS.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, ptr, 0);
- OS.free (ptr);
- sendEvent (SWT.Modify);
-}
-
+public void setText (String string) {
+ checkWidget();
+ 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) {
+ OS.PtSetResource (handle, OS.Pt_ARG_CBOX_SELECTION_ITEM, index, 0);
+ sendEvent (SWT.Modify);
+ }
+ return;
+ }
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ OS.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, ptr, 0);
+ OS.free (ptr);
+ sendEvent (SWT.Modify);
+}
+
/**
* Sets the maximum number of characters that the receiver's
* text field is capable of holding to be the argument.
@@ -1194,36 +1194,36 @@ public void setText (String string) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setTextLimit (int limit) {
- checkWidget();
- if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
- OS.PtSetResource (handle, OS.Pt_ARG_MAX_LENGTH, limit, 0);
-}
-
-int traversalCode (int key_sym, PhKeyEvent_t ke) {
- int code = super.traversalCode (key_sym, ke);
- if (key_sym == OS.Pk_Up || key_sym == OS.Pk_Down) {
- code &= ~(SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS);
- }
- if ((style & SWT.READ_ONLY) == 0) {
- if (key_sym == OS.Pk_Up || key_sym == OS.Pk_Down) {
- code &= ~(SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS);
- }
- }
- return code;
-}
-
-boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
- boolean translated = super.translateTraversal (key_sym, phEvent);
- if (!translated && key_sym == OS.Pk_Return) {
- postEvent (SWT.DefaultSelection);
- return false;
- }
- return translated;
-}
-
-int widgetClass () {
- return OS.PtComboBox ();
-}
-
-}
+public void setTextLimit (int limit) {
+ checkWidget();
+ if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
+ OS.PtSetResource (handle, OS.Pt_ARG_MAX_LENGTH, limit, 0);
+}
+
+int traversalCode (int key_sym, PhKeyEvent_t ke) {
+ int code = super.traversalCode (key_sym, ke);
+ if (key_sym == OS.Pk_Up || key_sym == OS.Pk_Down) {
+ code &= ~(SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS);
+ }
+ if ((style & SWT.READ_ONLY) == 0) {
+ if (key_sym == OS.Pk_Up || key_sym == OS.Pk_Down) {
+ code &= ~(SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS);
+ }
+ }
+ return code;
+}
+
+boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
+ boolean translated = super.translateTraversal (key_sym, phEvent);
+ if (!translated && key_sym == OS.Pk_Return) {
+ postEvent (SWT.DefaultSelection);
+ return false;
+ }
+ return translated;
+}
+
+int widgetClass () {
+ return OS.PtComboBox ();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java
index b6cb8bd11b..ab5bec1586 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class are controls which are capable
* of containing other controls.
@@ -34,15 +34,15 @@ import org.eclipse.swt.graphics.*;
*
* @see Canvas
*/
-public class Composite extends Scrollable {
- Layout layout;
- Control [] tabList;
- int cornerHandle;
-
-Composite () {
- /* Do nothing */
-}
-
+public class Composite extends Scrollable {
+ Layout layout;
+ Control [] tabList;
+ int cornerHandle;
+
+Composite () {
+ /* Do nothing */
+}
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -73,288 +73,288 @@ Composite () {
* @see SWT#NO_RADIO_GROUP
* @see Widget#getStyle
*/
-public Composite (Composite parent, int style) {
- super (parent, style);
-}
-
-Control [] _getChildren () {
- int count = 0;
- int parentHandle = parentingHandle ();
- int child = OS.PtWidgetChildFront (parentHandle);
- while (child != 0) {
- child = OS.PtWidgetBrotherBehind (child);
- count++;
- }
- Control [] children = new Control [count];
- int i = 0, j = 0;
- child = OS.PtWidgetChildFront (parentHandle);
- 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;
-}
-
-Control [] _getTabList () {
- if (tabList == null) return tabList;
- int count = 0;
- for (int i=0; i<tabList.length; i++) {
- if (!tabList [i].isDisposed ()) count++;
- }
- if (count == tabList.length) return tabList;
- Control [] newList = new Control [count];
- int index = 0;
- for (int i=0; i<tabList.length; i++) {
- if (!tabList [i].isDisposed ()) {
- newList [index++] = tabList [i];
- }
- }
- tabList = newList;
- return tabList;
-}
-
-protected void checkSubclass () {
- /* Do nothing - Subclassing is allowed */
-}
-
-Control [] computeTabList () {
- Control result [] = super.computeTabList ();
- if (result.length == 0) return result;
- Control [] list = tabList != null ? _getTabList () : _getChildren ();
- for (int i=0; i<list.length; i++) {
- Control child = list [i];
- Control [] childList = child.computeTabList ();
- if (childList.length != 0) {
- Control [] newResult = new Control [result.length + childList.length];
- System.arraycopy (result, 0, newResult, 0, result.length);
- System.arraycopy (childList, 0, newResult, result.length, childList.length);
- result = newResult;
- }
- }
- return result;
-}
-
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget();
- 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) {
- state |= HANDLE | GRAB | CANVAS;
- int parentHandle = parent.parentingHandle ();
- 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);
- }
-}
-
-byte [] defaultFont () {
- Display display = getDisplay ();
- return display.TITLE_FONT;
-}
-
-void createScrolledHandle (int parentHandle) {
- int etches = OS.Pt_ALL_ETCHES | OS.Pt_ALL_OUTLINES;
- int [] args = new int [] {
- OS.Pt_ARG_FLAGS, hasBorder () ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
- OS.Pt_ARG_BASIC_FLAGS, hasBorder () ? etches : 0, etches,
- OS.Pt_ARG_CONTAINER_FLAGS, 0, OS.Pt_ENABLE_CUA | OS.Pt_ENABLE_CUA_ARROWS,
- OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,
- OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
- };
- scrolledHandle = OS.PtCreateWidget (OS.PtContainer (), parentHandle, args.length / 3, args);
- if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
- Display display = getDisplay ();
- if ((style & SWT.H_SCROLL) != 0 && (style & SWT.V_SCROLL) != 0) {
- etches = OS.Pt_TOP_OUTLINE | OS.Pt_LEFT_OUTLINE;
- args = new int [] {
- OS.Pt_ARG_FLAGS, OS.Pt_HIGHLIGHTED, OS.Pt_HIGHLIGHTED,
- OS.Pt_ARG_BASIC_FLAGS, etches, etches,
- OS.Pt_ARG_WIDTH, display.SCROLLBAR_WIDTH, 0,
- OS.Pt_ARG_HEIGHT, display.SCROLLBAR_HEIGHT, 0,
- OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
- };
- cornerHandle = OS.PtCreateWidget (OS.PtContainer (), scrolledHandle, args.length / 3, args);
- }
- int clazz = display.PtContainer;
- args = new int [] {
- OS.Pt_ARG_FLAGS, OS.Pt_SELECTABLE | OS.Pt_SELECT_NOREDRAW, OS.Pt_SELECTABLE | OS.Pt_SELECT_NOREDRAW,
- OS.Pt_ARG_CONTAINER_FLAGS, 0, OS.Pt_ENABLE_CUA | OS.Pt_ENABLE_CUA_ARROWS,
- OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
- };
- handle = OS.PtCreateWidget (clazz, scrolledHandle, args.length / 3, args);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- createScrollBars ();
-}
-
-void drawWidget (int widget, int damage) {
- if ((state & CANVAS) != 0) {
- if ((style & SWT.NO_BACKGROUND) == 0) {
-
- /* Get the clipping tiles for children and siblings */
- int clip_tile = getClipping (handle, topHandle (), true, true);
-
- /* Translate the clipping to the current GC coordinates */
- short [] abs_x = new short [1], abs_y = new short [1];
- OS.PtGetAbsPosition (handle, abs_x, abs_y);
- short [] dis_abs_x = new short [1], dis_abs_y = new short [1];
- OS.PtGetAbsPosition (OS.PtFindDisjoint (handle), dis_abs_x, dis_abs_y);
- PhPoint_t delta = new PhPoint_t ();
- delta.x = (short) (abs_x [0] - dis_abs_x [0]);
- delta.y = (short) (abs_y [0] - dis_abs_y [0]);
- OS.PhTranslateTiles(clip_tile, delta);
-
- /* Set the clipping */
- int[] clip_rects_count = new int [1];
- int clip_rects = OS.PhTilesToRects (clip_tile, clip_rects_count);
- OS.PhFreeTiles (clip_tile);
- if (clip_rects_count [0] == 0) {
- clip_rects_count [0] = 1;
- OS.free (clip_rects);
- clip_rects = OS.malloc (PhRect_t.sizeof);
- }
- OS.PgSetMultiClip (clip_rects_count[0], clip_rects);
- OS.free (clip_rects);
-
- /* Draw the widget */
- super.drawWidget (widget, damage);
-
- /* Reset the clipping */
- OS.PgSetMultiClip (0, 0);
- }
- } else {
- super.drawWidget (widget, damage);
- }
-}
-
-
-public boolean forceFocus () {
- checkWidget();
- if ((state & CANVAS) == 0) return super.forceFocus ();
- /*
- * Bug in Photon. PtContainerGiveFocus() is supposed to give
- * focus to the widget even if the widget's Pt_GET_FOCUS flag
- * is not set. This does not happen when the widget is a
- * PtContainer. The fix is to set the flag before calling it.
- */
- int flags = OS.PtWidgetFlags (handle);
- OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, OS.Pt_GETS_FOCUS, OS.Pt_GETS_FOCUS);
- boolean result = super.forceFocus ();
- OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, flags, OS.Pt_GETS_FOCUS);
- return result;
-}
-
-public Rectangle getClientArea () {
- checkWidget();
- if (scrolledHandle == 0) return super.getClientArea ();
- PhArea_t area = new PhArea_t ();
- OS.PtWidgetArea (handle, area);
- return new Rectangle (area.pos_x, area.pos_y, area.size_w, area.size_h);
-}
-
-int getClipping(int widget, int topWidget, boolean clipChildren, boolean clipSiblings) {
- int child_tile = 0;
- int widget_tile = OS.PhGetTile(); // NOTE: PhGetTile native initializes the tile
-
- PhRect_t rect = new PhRect_t ();
- int args [] = {OS.Pt_ARG_FLAGS, 0, 0, OS.Pt_ARG_BASIC_FLAGS, 0, 0};
-
- /* Get the rectangle of all siblings in front of the widget */
- if (clipSiblings && OS.PtWidgetClass(topWidget) != OS.PtWindow()) {
- int temp_widget = topWidget;
- while ((temp_widget = OS.PtWidgetBrotherInFront(temp_widget)) != 0) {
- if (OS.PtWidgetIsRealized(temp_widget)) {
- int tile = OS.PhGetTile();
- if (child_tile == 0) child_tile = tile;
- else child_tile = OS.PhAddMergeTiles(tile, child_tile, null);
- OS.PtWidgetExtent(temp_widget, tile); // NOTE: tile->rect
- args [1] = args [4] = 0;
- OS.PtGetResources(temp_widget, args.length / 3, args);
- if ((args [1] & OS.Pt_HIGHLIGHTED) != 0) {
- int basic_flags = args [4];
- OS.memmove(rect, tile, PhRect_t.sizeof);
- if ((basic_flags & OS.Pt_TOP_ETCH) != 0) rect.ul_y++;
- if ((basic_flags & OS.Pt_BOTTOM_ETCH) != 0) rect.lr_y--;
- if ((basic_flags & OS.Pt_RIGHT_ETCH) != 0) rect.ul_x++;
- if ((basic_flags & OS.Pt_LEFT_ETCH) != 0) rect.lr_x--;
- OS.memmove(tile, rect, PhRect_t.sizeof);
- }
- }
- }
- /* Translate the siblings rectangles to the widget's coordinates */
- OS.PtWidgetCanvas(topWidget, widget_tile); // NOTE: widget_tile->rect
- OS.PhDeTranslateTiles(child_tile, widget_tile); // NOTE: widget_tile->rect.ul
- }
-
- /* Get the rectangle of the widget's children */
- if (clipChildren) {
- int temp_widget = OS.PtWidgetChildBack(widget);
- while (temp_widget != 0) {
- if (OS.PtWidgetIsRealized(temp_widget)) {
- int tile = OS.PhGetTile();
- if (child_tile == 0) child_tile = tile;
- else child_tile = OS.PhAddMergeTiles(tile, child_tile, null);
- OS.PtWidgetExtent(temp_widget, tile); // NOTE: tile->rect
- args [1] = args [4] = 0;
- OS.PtGetResources(temp_widget, args.length / 3, args);
- if ((args [1] & OS.Pt_HIGHLIGHTED) != 0) {
- int basic_flags = args [4];
- OS.memmove(rect, tile, PhRect_t.sizeof);
- if ((basic_flags & OS.Pt_TOP_ETCH) != 0) rect.ul_y++;
- if ((basic_flags & OS.Pt_BOTTOM_ETCH) != 0) rect.lr_y--;
- if ((basic_flags & OS.Pt_RIGHT_ETCH) != 0) rect.ul_x++;
- if ((basic_flags & OS.Pt_LEFT_ETCH) != 0) rect.lr_x--;
- OS.memmove(tile, rect, PhRect_t.sizeof);
- }
- }
- temp_widget = OS.PtWidgetBrotherInFront(temp_widget);
- }
- }
-
- /* Get the widget's rectangle */
- OS.PtWidgetCanvas(widget, widget_tile); // NOTE: widget_tile->rect
- OS.PhDeTranslateTiles(widget_tile, widget_tile); // NOTE: widget_tile->rect.ul
-
- /* Clip the widget's rectangle from the child/siblings rectangle's */
- if (child_tile != 0) {
- int clip_tile = OS.PhClipTilings(widget_tile, child_tile, null);
- OS.PhFreeTiles(child_tile);
- return clip_tile;
- }
- return widget_tile;
-}
-
+public Composite (Composite parent, int style) {
+ super (parent, style);
+}
+
+Control [] _getChildren () {
+ int count = 0;
+ int parentHandle = parentingHandle ();
+ int child = OS.PtWidgetChildFront (parentHandle);
+ while (child != 0) {
+ child = OS.PtWidgetBrotherBehind (child);
+ count++;
+ }
+ Control [] children = new Control [count];
+ int i = 0, j = 0;
+ child = OS.PtWidgetChildFront (parentHandle);
+ 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;
+}
+
+Control [] _getTabList () {
+ if (tabList == null) return tabList;
+ int count = 0;
+ for (int i=0; i<tabList.length; i++) {
+ if (!tabList [i].isDisposed ()) count++;
+ }
+ if (count == tabList.length) return tabList;
+ Control [] newList = new Control [count];
+ int index = 0;
+ for (int i=0; i<tabList.length; i++) {
+ if (!tabList [i].isDisposed ()) {
+ newList [index++] = tabList [i];
+ }
+ }
+ tabList = newList;
+ return tabList;
+}
+
+protected void checkSubclass () {
+ /* Do nothing - Subclassing is allowed */
+}
+
+Control [] computeTabList () {
+ Control result [] = super.computeTabList ();
+ if (result.length == 0) return result;
+ Control [] list = tabList != null ? _getTabList () : _getChildren ();
+ for (int i=0; i<list.length; i++) {
+ Control child = list [i];
+ Control [] childList = child.computeTabList ();
+ if (childList.length != 0) {
+ Control [] newResult = new Control [result.length + childList.length];
+ System.arraycopy (result, 0, newResult, 0, result.length);
+ System.arraycopy (childList, 0, newResult, result.length, childList.length);
+ result = newResult;
+ }
+ }
+ return result;
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget();
+ 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) {
+ state |= HANDLE | GRAB | CANVAS;
+ int parentHandle = parent.parentingHandle ();
+ 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);
+ }
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.TITLE_FONT;
+}
+
+void createScrolledHandle (int parentHandle) {
+ int etches = OS.Pt_ALL_ETCHES | OS.Pt_ALL_OUTLINES;
+ int [] args = new int [] {
+ OS.Pt_ARG_FLAGS, hasBorder () ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
+ OS.Pt_ARG_BASIC_FLAGS, hasBorder () ? etches : 0, etches,
+ OS.Pt_ARG_CONTAINER_FLAGS, 0, OS.Pt_ENABLE_CUA | OS.Pt_ENABLE_CUA_ARROWS,
+ OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ scrolledHandle = OS.PtCreateWidget (OS.PtContainer (), parentHandle, args.length / 3, args);
+ if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ Display display = getDisplay ();
+ if ((style & SWT.H_SCROLL) != 0 && (style & SWT.V_SCROLL) != 0) {
+ etches = OS.Pt_TOP_OUTLINE | OS.Pt_LEFT_OUTLINE;
+ args = new int [] {
+ OS.Pt_ARG_FLAGS, OS.Pt_HIGHLIGHTED, OS.Pt_HIGHLIGHTED,
+ OS.Pt_ARG_BASIC_FLAGS, etches, etches,
+ OS.Pt_ARG_WIDTH, display.SCROLLBAR_WIDTH, 0,
+ OS.Pt_ARG_HEIGHT, display.SCROLLBAR_HEIGHT, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ cornerHandle = OS.PtCreateWidget (OS.PtContainer (), scrolledHandle, args.length / 3, args);
+ }
+ int clazz = display.PtContainer;
+ args = new int [] {
+ OS.Pt_ARG_FLAGS, OS.Pt_SELECTABLE | OS.Pt_SELECT_NOREDRAW, OS.Pt_SELECTABLE | OS.Pt_SELECT_NOREDRAW,
+ OS.Pt_ARG_CONTAINER_FLAGS, 0, OS.Pt_ENABLE_CUA | OS.Pt_ENABLE_CUA_ARROWS,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, scrolledHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ createScrollBars ();
+}
+
+void drawWidget (int widget, int damage) {
+ if ((state & CANVAS) != 0) {
+ if ((style & SWT.NO_BACKGROUND) == 0) {
+
+ /* Get the clipping tiles for children and siblings */
+ int clip_tile = getClipping (handle, topHandle (), true, true);
+
+ /* Translate the clipping to the current GC coordinates */
+ short [] abs_x = new short [1], abs_y = new short [1];
+ OS.PtGetAbsPosition (handle, abs_x, abs_y);
+ short [] dis_abs_x = new short [1], dis_abs_y = new short [1];
+ OS.PtGetAbsPosition (OS.PtFindDisjoint (handle), dis_abs_x, dis_abs_y);
+ PhPoint_t delta = new PhPoint_t ();
+ delta.x = (short) (abs_x [0] - dis_abs_x [0]);
+ delta.y = (short) (abs_y [0] - dis_abs_y [0]);
+ OS.PhTranslateTiles(clip_tile, delta);
+
+ /* Set the clipping */
+ int[] clip_rects_count = new int [1];
+ int clip_rects = OS.PhTilesToRects (clip_tile, clip_rects_count);
+ OS.PhFreeTiles (clip_tile);
+ if (clip_rects_count [0] == 0) {
+ clip_rects_count [0] = 1;
+ OS.free (clip_rects);
+ clip_rects = OS.malloc (PhRect_t.sizeof);
+ }
+ OS.PgSetMultiClip (clip_rects_count[0], clip_rects);
+ OS.free (clip_rects);
+
+ /* Draw the widget */
+ super.drawWidget (widget, damage);
+
+ /* Reset the clipping */
+ OS.PgSetMultiClip (0, 0);
+ }
+ } else {
+ super.drawWidget (widget, damage);
+ }
+}
+
+
+public boolean forceFocus () {
+ checkWidget();
+ if ((state & CANVAS) == 0) return super.forceFocus ();
+ /*
+ * Bug in Photon. PtContainerGiveFocus() is supposed to give
+ * focus to the widget even if the widget's Pt_GET_FOCUS flag
+ * is not set. This does not happen when the widget is a
+ * PtContainer. The fix is to set the flag before calling it.
+ */
+ int flags = OS.PtWidgetFlags (handle);
+ OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, OS.Pt_GETS_FOCUS, OS.Pt_GETS_FOCUS);
+ boolean result = super.forceFocus ();
+ OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, flags, OS.Pt_GETS_FOCUS);
+ return result;
+}
+
+public Rectangle getClientArea () {
+ checkWidget();
+ if (scrolledHandle == 0) return super.getClientArea ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (handle, area);
+ return new Rectangle (area.pos_x, area.pos_y, area.size_w, area.size_h);
+}
+
+int getClipping(int widget, int topWidget, boolean clipChildren, boolean clipSiblings) {
+ int child_tile = 0;
+ int widget_tile = OS.PhGetTile(); // NOTE: PhGetTile native initializes the tile
+
+ PhRect_t rect = new PhRect_t ();
+ int args [] = {OS.Pt_ARG_FLAGS, 0, 0, OS.Pt_ARG_BASIC_FLAGS, 0, 0};
+
+ /* Get the rectangle of all siblings in front of the widget */
+ if (clipSiblings && OS.PtWidgetClass(topWidget) != OS.PtWindow()) {
+ int temp_widget = topWidget;
+ while ((temp_widget = OS.PtWidgetBrotherInFront(temp_widget)) != 0) {
+ if (OS.PtWidgetIsRealized(temp_widget)) {
+ int tile = OS.PhGetTile();
+ if (child_tile == 0) child_tile = tile;
+ else child_tile = OS.PhAddMergeTiles(tile, child_tile, null);
+ OS.PtWidgetExtent(temp_widget, tile); // NOTE: tile->rect
+ args [1] = args [4] = 0;
+ OS.PtGetResources(temp_widget, args.length / 3, args);
+ if ((args [1] & OS.Pt_HIGHLIGHTED) != 0) {
+ int basic_flags = args [4];
+ OS.memmove(rect, tile, PhRect_t.sizeof);
+ if ((basic_flags & OS.Pt_TOP_ETCH) != 0) rect.ul_y++;
+ if ((basic_flags & OS.Pt_BOTTOM_ETCH) != 0) rect.lr_y--;
+ if ((basic_flags & OS.Pt_RIGHT_ETCH) != 0) rect.ul_x++;
+ if ((basic_flags & OS.Pt_LEFT_ETCH) != 0) rect.lr_x--;
+ OS.memmove(tile, rect, PhRect_t.sizeof);
+ }
+ }
+ }
+ /* Translate the siblings rectangles to the widget's coordinates */
+ OS.PtWidgetCanvas(topWidget, widget_tile); // NOTE: widget_tile->rect
+ OS.PhDeTranslateTiles(child_tile, widget_tile); // NOTE: widget_tile->rect.ul
+ }
+
+ /* Get the rectangle of the widget's children */
+ if (clipChildren) {
+ int temp_widget = OS.PtWidgetChildBack(widget);
+ while (temp_widget != 0) {
+ if (OS.PtWidgetIsRealized(temp_widget)) {
+ int tile = OS.PhGetTile();
+ if (child_tile == 0) child_tile = tile;
+ else child_tile = OS.PhAddMergeTiles(tile, child_tile, null);
+ OS.PtWidgetExtent(temp_widget, tile); // NOTE: tile->rect
+ args [1] = args [4] = 0;
+ OS.PtGetResources(temp_widget, args.length / 3, args);
+ if ((args [1] & OS.Pt_HIGHLIGHTED) != 0) {
+ int basic_flags = args [4];
+ OS.memmove(rect, tile, PhRect_t.sizeof);
+ if ((basic_flags & OS.Pt_TOP_ETCH) != 0) rect.ul_y++;
+ if ((basic_flags & OS.Pt_BOTTOM_ETCH) != 0) rect.lr_y--;
+ if ((basic_flags & OS.Pt_RIGHT_ETCH) != 0) rect.ul_x++;
+ if ((basic_flags & OS.Pt_LEFT_ETCH) != 0) rect.lr_x--;
+ OS.memmove(tile, rect, PhRect_t.sizeof);
+ }
+ }
+ temp_widget = OS.PtWidgetBrotherInFront(temp_widget);
+ }
+ }
+
+ /* Get the widget's rectangle */
+ OS.PtWidgetCanvas(widget, widget_tile); // NOTE: widget_tile->rect
+ OS.PhDeTranslateTiles(widget_tile, widget_tile); // NOTE: widget_tile->rect.ul
+
+ /* Clip the widget's rectangle from the child/siblings rectangle's */
+ if (child_tile != 0) {
+ int clip_tile = OS.PhClipTilings(widget_tile, child_tile, null);
+ OS.PhFreeTiles(child_tile);
+ return clip_tile;
+ }
+ return widget_tile;
+}
+
/**
* Returns an array containing the receiver's children.
* <p>
@@ -370,22 +370,22 @@ int getClipping(int widget, int topWidget, boolean clipChildren, boolean clipSib
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Control [] getChildren () {
- checkWidget();
- return _getChildren ();
-}
-
-int getChildrenCount () {
- int count = 0;
- int parentHandle = parentingHandle ();
- int child = OS.PtWidgetChildFront (parentHandle);
- while (child != 0) {
- child = OS.PtWidgetBrotherBehind (child);
- count++;
- }
- return count;
-}
-
+public Control [] getChildren () {
+ checkWidget();
+ return _getChildren ();
+}
+
+int getChildrenCount () {
+ int count = 0;
+ int parentHandle = parentingHandle ();
+ int child = OS.PtWidgetChildFront (parentHandle);
+ while (child != 0) {
+ child = OS.PtWidgetBrotherBehind (child);
+ count++;
+ }
+ return count;
+}
+
/**
* Returns layout which is associated with the receiver, or
* null if one has not been set.
@@ -397,55 +397,55 @@ int getChildrenCount () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Layout getLayout () {
- checkWidget();
- return layout;
-}
-
-boolean hasBorder () {
- return (style & SWT.BORDER) != 0;
-}
-
-boolean hasFocus () {
- return OS.PtIsFocused (handle) == 2;
-}
-
-boolean hooksKeys () {
- return hooks (SWT.KeyDown) || hooks (SWT.KeyUp);
-}
-
-/**
- * Gets the last specified tabbing order for the control.
- *
- * @return tabList the ordered list of controls representing the tab order
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setTabList
+public Layout getLayout () {
+ checkWidget();
+ return layout;
+}
+
+boolean hasBorder () {
+ return (style & SWT.BORDER) != 0;
+}
+
+boolean hasFocus () {
+ return OS.PtIsFocused (handle) == 2;
+}
+
+boolean hooksKeys () {
+ return hooks (SWT.KeyDown) || hooks (SWT.KeyUp);
+}
+
+/**
+ * Gets the last specified tabbing order for the control.
+ *
+ * @return tabList the ordered list of controls representing the tab order
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setTabList
*/
-public Control [] getTabList () {
- checkWidget ();
- Control [] tabList = _getTabList ();
- if (tabList == null) {
- int count = 0;
- Control [] list =_getChildren ();
- for (int i=0; i<list.length; i++) {
- if (list [i].isTabGroup ()) count++;
- }
- tabList = new Control [count];
- int index = 0;
- for (int i=0; i<list.length; i++) {
- if (list [i].isTabGroup ()) {
- tabList [index++] = list [i];
- }
- }
- }
- return tabList;
-}
-
+public Control [] getTabList () {
+ checkWidget ();
+ Control [] tabList = _getTabList ();
+ if (tabList == null) {
+ int count = 0;
+ Control [] list =_getChildren ();
+ for (int i=0; i<list.length; i++) {
+ if (list [i].isTabGroup ()) count++;
+ }
+ tabList = new Control [count];
+ int index = 0;
+ for (int i=0; i<list.length; i++) {
+ if (list [i].isTabGroup ()) {
+ tabList [index++] = list [i];
+ }
+ }
+ }
+ return tabList;
+}
+
/**
* If the receiver has a layout, asks the layout to <em>lay out</em>
* (that is, set the size and location of) the receiver's children.
@@ -459,26 +459,26 @@ public Control [] getTabList () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void layout () {
- checkWidget();
- 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);
-}
-
-void moveToBack (int child) {
- OS.PtWidgetToBack (child);
-}
-
+public void layout () {
+ checkWidget();
+ 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);
+}
+
+void moveToBack (int child) {
+ OS.PtWidgetToBack (child);
+}
+
/**
* If the receiver has a layout, asks the layout to <em>lay out</em>
* (that is, set the size and location of) the receiver's children.
@@ -496,187 +496,187 @@ void moveToBack (int child) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void layout (boolean changed) {
- checkWidget();
- if (layout == null) return;
- int count = getChildrenCount ();
- if (count == 0) return;
- layout.layout (this, changed);
-}
-
-int parentingHandle () {
- return handle;
-}
-
-int Ph_EV_BUT_PRESS (int widget, int info) {
- int result = super.Ph_EV_BUT_PRESS (widget, info);
- if (result != OS.Pt_CONTINUE)return result;
- if ((state & CANVAS) != 0) {
- /* Set focus for a CANVAS with no children */
- if ((style & SWT.NO_FOCUS) == 0 && OS.PtWidgetChildFront (handle) == 0) {
- if (info == 0) return OS.Pt_END;
- PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
- OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
- if (cbinfo.event == 0) return OS.Pt_END;
- PhEvent_t ev = new PhEvent_t ();
- OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
- int data = OS.PhGetData (cbinfo.event);
- if (data == 0) return OS.Pt_END;
- PhPointerEvent_t pe = new PhPointerEvent_t ();
- OS.memmove (pe, data, PhPointerEvent_t.sizeof);
- if (pe.buttons == OS.Ph_BUTTON_SELECT) setFocus ();
- }
- }
- return result;
-}
-
-int Pt_CB_OUTBOUND (int widget, int info) {
- if ((state & CANVAS) != 0) {
- if (info == 0) return OS.Pt_END;
- PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
- OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
- if (cbinfo.event == 0) return OS.Pt_END;
- PhEvent_t ev = new PhEvent_t ();
- OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
- 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);
-
- /* Grab pointer */
- 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 (0);
- int flags = OS.Ph_DRAG_KEY_MOTION | OS.Ph_DRAG_TRACK | OS.Ph_TRACK_DRAG;
- OS.PhInitDrag (rid, flags, rect, null, input_group, null, null, null, pos, null);
-
- /* Post drag detect event */
- postEvent (SWT.DragDetect);
- }
- return OS.Pt_CONTINUE;
-}
-
-void releaseChildren () {
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (!child.isDisposed ()) child.releaseResources ();
- }
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- cornerHandle = 0;
-}
-
-void releaseWidget () {
- releaseChildren ();
- super.releaseWidget ();
- layout = null;
- tabList = null;
-}
-
-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]);
-}
-
-void resizeClientArea (int width, int height) {
- if (scrolledHandle == 0) return;
-
- /* Calculate the insets */
- int [] args = {
- OS.Pt_ARG_BASIC_FLAGS, 0, 0,
- OS.Pt_ARG_BEVEL_WIDTH, 0, 0,
- };
- OS.PtGetResources (scrolledHandle, args.length / 3, args);
- int flags = args [1];
- int bevel = args [4];
- int top = 0, left = 0, right = 0, bottom = 0;
- if ((flags & OS.Pt_TOP_ETCH) != 0) top++;
- if ((flags & OS.Pt_TOP_OUTLINE) != 0) top++;
- if ((flags & OS.Pt_TOP_INLINE) != 0) top++;
- if ((flags & OS.Pt_TOP_BEVEL) != 0) top += bevel;
- if ((flags & OS.Pt_BOTTOM_ETCH) != 0) bottom++;
- if ((flags & OS.Pt_BOTTOM_OUTLINE) != 0) bottom++;
- if ((flags & OS.Pt_BOTTOM_INLINE) != 0) bottom++;
- if ((flags & OS.Pt_BOTTOM_BEVEL) != 0) bottom += bevel;
- if ((flags & OS.Pt_RIGHT_ETCH) != 0) right++;
- if ((flags & OS.Pt_RIGHT_OUTLINE) != 0) right++;
- if ((flags & OS.Pt_RIGHT_INLINE) != 0) right++;
- if ((flags & OS.Pt_RIGHT_BEVEL) != 0) right += bevel;
- if ((flags & OS.Pt_LEFT_ETCH) != 0) left++;
- if ((flags & OS.Pt_LEFT_OUTLINE) != 0) left++;
- if ((flags & OS.Pt_LEFT_INLINE) != 0) left++;
- if ((flags & OS.Pt_LEFT_BEVEL) != 0) left += bevel;
-
- int clientWidth = width - (left + right);
- int clientHeight = height - (top + bottom);
-
- int vBarWidth = 0, hBarHeight = 0;
- boolean isVisibleHBar = horizontalBar != null && horizontalBar.getVisible ();
- boolean isVisibleVBar = verticalBar != null && verticalBar.getVisible ();
- if (isVisibleHBar) {
- args = new int [] {OS.Pt_ARG_HEIGHT, 0, 0};
- OS.PtGetResources (horizontalBar.handle, args.length / 3, args);
- clientHeight -= (hBarHeight = args [1]);
- }
- if (isVisibleVBar) {
- args = new int [] {OS.Pt_ARG_WIDTH, 0, 0};
- OS.PtGetResources (verticalBar.handle, args.length / 3, args);
- clientWidth -= (vBarWidth = args [1]);
- }
- if (isVisibleHBar) {
- horizontalBar.setBounds (0, clientHeight, clientWidth, hBarHeight);
- }
- if (isVisibleVBar) {
- verticalBar.setBounds (clientWidth, 0, vBarWidth, clientHeight);
- }
- args = new int [] {
- OS.Pt_ARG_WIDTH, Math.max (clientWidth, 0), 0,
- OS.Pt_ARG_HEIGHT, Math.max (clientHeight, 0), 0,
- };
- OS.PtSetResources (handle, args.length / 3, args);
- if (cornerHandle != 0) {
- PhPoint_t pt = new PhPoint_t ();
- pt.x = (short) clientWidth;
- pt.y = (short) clientHeight;
- int ptr = OS.malloc (PhPoint_t.sizeof);
- OS.memmove (ptr, pt, PhPoint_t.sizeof);
- OS.PtSetResource (cornerHandle, OS.Pt_ARG_POS, ptr, 0);
- OS.free (ptr);
- }
-}
-
-int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
- int result = super.setBounds (x, y, width, height, move, resize, false);
- if ((result & MOVED) != 0) {
- if (events) sendEvent (SWT.Move);
- }
- if ((result & RESIZED) != 0) {
- resizeClientArea (width, height);
- if (events) sendEvent (SWT.Resize);
- if (layout != null) layout (false);
- }
- return result;
-}
-
-public boolean setFocus () {
- checkWidget();
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (child.getVisible () && child.setFocus ()) return true;
- }
- return super.setFocus ();
-}
-
+public void layout (boolean changed) {
+ checkWidget();
+ if (layout == null) return;
+ int count = getChildrenCount ();
+ if (count == 0) return;
+ layout.layout (this, changed);
+}
+
+int parentingHandle () {
+ return handle;
+}
+
+int Ph_EV_BUT_PRESS (int widget, int info) {
+ int result = super.Ph_EV_BUT_PRESS (widget, info);
+ if (result != OS.Pt_CONTINUE)return result;
+ if ((state & CANVAS) != 0) {
+ /* Set focus for a CANVAS with no children */
+ if ((style & SWT.NO_FOCUS) == 0 && OS.PtWidgetChildFront (handle) == 0) {
+ if (info == 0) return OS.Pt_END;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.event == 0) return OS.Pt_END;
+ PhEvent_t ev = new PhEvent_t ();
+ OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
+ int data = OS.PhGetData (cbinfo.event);
+ if (data == 0) return OS.Pt_END;
+ PhPointerEvent_t pe = new PhPointerEvent_t ();
+ OS.memmove (pe, data, PhPointerEvent_t.sizeof);
+ if (pe.buttons == OS.Ph_BUTTON_SELECT) setFocus ();
+ }
+ }
+ return result;
+}
+
+int Pt_CB_OUTBOUND (int widget, int info) {
+ if ((state & CANVAS) != 0) {
+ if (info == 0) return OS.Pt_END;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.event == 0) return OS.Pt_END;
+ PhEvent_t ev = new PhEvent_t ();
+ OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
+ 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);
+
+ /* Grab pointer */
+ 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 (0);
+ int flags = OS.Ph_DRAG_KEY_MOTION | OS.Ph_DRAG_TRACK | OS.Ph_TRACK_DRAG;
+ OS.PhInitDrag (rid, flags, rect, null, input_group, null, null, null, pos, null);
+
+ /* Post drag detect event */
+ postEvent (SWT.DragDetect);
+ }
+ return OS.Pt_CONTINUE;
+}
+
+void releaseChildren () {
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (!child.isDisposed ()) child.releaseResources ();
+ }
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ cornerHandle = 0;
+}
+
+void releaseWidget () {
+ releaseChildren ();
+ super.releaseWidget ();
+ layout = null;
+ tabList = null;
+}
+
+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]);
+}
+
+void resizeClientArea (int width, int height) {
+ if (scrolledHandle == 0) return;
+
+ /* Calculate the insets */
+ int [] args = {
+ OS.Pt_ARG_BASIC_FLAGS, 0, 0,
+ OS.Pt_ARG_BEVEL_WIDTH, 0, 0,
+ };
+ OS.PtGetResources (scrolledHandle, args.length / 3, args);
+ int flags = args [1];
+ int bevel = args [4];
+ int top = 0, left = 0, right = 0, bottom = 0;
+ if ((flags & OS.Pt_TOP_ETCH) != 0) top++;
+ if ((flags & OS.Pt_TOP_OUTLINE) != 0) top++;
+ if ((flags & OS.Pt_TOP_INLINE) != 0) top++;
+ if ((flags & OS.Pt_TOP_BEVEL) != 0) top += bevel;
+ if ((flags & OS.Pt_BOTTOM_ETCH) != 0) bottom++;
+ if ((flags & OS.Pt_BOTTOM_OUTLINE) != 0) bottom++;
+ if ((flags & OS.Pt_BOTTOM_INLINE) != 0) bottom++;
+ if ((flags & OS.Pt_BOTTOM_BEVEL) != 0) bottom += bevel;
+ if ((flags & OS.Pt_RIGHT_ETCH) != 0) right++;
+ if ((flags & OS.Pt_RIGHT_OUTLINE) != 0) right++;
+ if ((flags & OS.Pt_RIGHT_INLINE) != 0) right++;
+ if ((flags & OS.Pt_RIGHT_BEVEL) != 0) right += bevel;
+ if ((flags & OS.Pt_LEFT_ETCH) != 0) left++;
+ if ((flags & OS.Pt_LEFT_OUTLINE) != 0) left++;
+ if ((flags & OS.Pt_LEFT_INLINE) != 0) left++;
+ if ((flags & OS.Pt_LEFT_BEVEL) != 0) left += bevel;
+
+ int clientWidth = width - (left + right);
+ int clientHeight = height - (top + bottom);
+
+ int vBarWidth = 0, hBarHeight = 0;
+ boolean isVisibleHBar = horizontalBar != null && horizontalBar.getVisible ();
+ boolean isVisibleVBar = verticalBar != null && verticalBar.getVisible ();
+ if (isVisibleHBar) {
+ args = new int [] {OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (horizontalBar.handle, args.length / 3, args);
+ clientHeight -= (hBarHeight = args [1]);
+ }
+ if (isVisibleVBar) {
+ args = new int [] {OS.Pt_ARG_WIDTH, 0, 0};
+ OS.PtGetResources (verticalBar.handle, args.length / 3, args);
+ clientWidth -= (vBarWidth = args [1]);
+ }
+ if (isVisibleHBar) {
+ horizontalBar.setBounds (0, clientHeight, clientWidth, hBarHeight);
+ }
+ if (isVisibleVBar) {
+ verticalBar.setBounds (clientWidth, 0, vBarWidth, clientHeight);
+ }
+ args = new int [] {
+ OS.Pt_ARG_WIDTH, Math.max (clientWidth, 0), 0,
+ OS.Pt_ARG_HEIGHT, Math.max (clientHeight, 0), 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ if (cornerHandle != 0) {
+ PhPoint_t pt = new PhPoint_t ();
+ pt.x = (short) clientWidth;
+ pt.y = (short) clientHeight;
+ int ptr = OS.malloc (PhPoint_t.sizeof);
+ OS.memmove (ptr, pt, PhPoint_t.sizeof);
+ OS.PtSetResource (cornerHandle, OS.Pt_ARG_POS, ptr, 0);
+ OS.free (ptr);
+ }
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
+ int result = super.setBounds (x, y, width, height, move, resize, false);
+ if ((result & MOVED) != 0) {
+ if (events) sendEvent (SWT.Move);
+ }
+ if ((result & RESIZED) != 0) {
+ resizeClientArea (width, height);
+ if (events) sendEvent (SWT.Resize);
+ if (layout != null) layout (false);
+ }
+ return result;
+}
+
+public boolean setFocus () {
+ checkWidget();
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child.getVisible () && child.setFocus ()) return true;
+ }
+ return super.setFocus ();
+}
+
/**
* Sets the layout which is associated with the receiver to be
* the argument which may be null.
@@ -688,38 +688,38 @@ public boolean setFocus () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setLayout (Layout layout) {
- checkWidget();
- this.layout = layout;
-}
-
-boolean setTabGroupFocus () {
- if (isTabItem ()) return setTabItemFocus ();
- if ((style & SWT.NO_FOCUS) == 0) {
- boolean takeFocus = true;
- if ((state & CANVAS) != 0) takeFocus = hooksKeys ();
- if (takeFocus && setTabItemFocus ()) return true;
- }
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (child.isTabItem () && child.setTabItemFocus ()) return true;
- }
- return false;
-}
-
-boolean setTabItemFocus () {
- if ((style & SWT.NO_FOCUS) == 0) {
- boolean takeFocus = true;
- if ((state & CANVAS) != 0) takeFocus = hooksKeys ();
- if (takeFocus) {
- if (!isShowing ()) return false;
- if (forceFocus ()) return true;
- }
- }
- return super.setTabItemFocus ();
-}
-
+public void setLayout (Layout layout) {
+ checkWidget();
+ this.layout = layout;
+}
+
+boolean setTabGroupFocus () {
+ if (isTabItem ()) return setTabItemFocus ();
+ if ((style & SWT.NO_FOCUS) == 0) {
+ boolean takeFocus = true;
+ if ((state & CANVAS) != 0) takeFocus = hooksKeys ();
+ if (takeFocus && setTabItemFocus ()) return true;
+ }
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child.isTabItem () && child.setTabItemFocus ()) return true;
+ }
+ return false;
+}
+
+boolean setTabItemFocus () {
+ if ((style & SWT.NO_FOCUS) == 0) {
+ boolean takeFocus = true;
+ if ((state & CANVAS) != 0) takeFocus = hooksKeys ();
+ if (takeFocus) {
+ if (!isShowing ()) return false;
+ if (forceFocus ()) return true;
+ }
+ }
+ return super.setTabItemFocus ();
+}
+
/**
* Sets the tabbing order for the specified controls to
* match the order that they occur in the argument list.
@@ -735,29 +735,29 @@ boolean setTabItemFocus () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setTabList (Control [] tabList) {
- checkWidget ();
- if (tabList == null) error (SWT.ERROR_NULL_ARGUMENT);
- for (int i=0; i<tabList.length; i++) {
- Control control = tabList [i];
- if (control == null) error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.parent != this) error (SWT.ERROR_INVALID_PARENT);
- }
- this.tabList = tabList;
-}
-
-int traversalCode (int key_sym, PhKeyEvent_t ke) {
- if ((state & CANVAS) != 0) {
- if ((style & SWT.NO_FOCUS) != 0) return 0;
- if (hooksKeys ()) return 0;
- }
- return super.traversalCode (key_sym, ke);
-}
-
-int widgetClass () {
- if ((state & CANVAS) != 0) return OS.PtContainer ();
- return super.widgetClass ();
-}
-
-}
+public void setTabList (Control [] tabList) {
+ checkWidget ();
+ if (tabList == null) error (SWT.ERROR_NULL_ARGUMENT);
+ for (int i=0; i<tabList.length; i++) {
+ Control control = tabList [i];
+ if (control == null) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (control.parent != this) error (SWT.ERROR_INVALID_PARENT);
+ }
+ this.tabList = tabList;
+}
+
+int traversalCode (int key_sym, PhKeyEvent_t ke) {
+ if ((state & CANVAS) != 0) {
+ if ((style & SWT.NO_FOCUS) != 0) return 0;
+ if (hooksKeys ()) return 0;
+ }
+ return super.traversalCode (key_sym, ke);
+}
+
+int widgetClass () {
+ if ((state & CANVAS) != 0) return OS.PtContainer ();
+ return super.widgetClass ();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java
index 0b5a13bdda..fc43a091c5 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.accessibility.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.accessibility.*;
+
/**
* Control is the abstract superclass of all windowed user interface classes.
* <p>
@@ -28,18 +28,18 @@ import org.eclipse.swt.accessibility.*;
* within the SWT implementation.
* </p>
*/
-public abstract class Control extends Widget implements Drawable {
- Composite parent;
- Menu menu;
- Object layoutData;
- String toolTipText;
- int toolTipHandle;
- Accessible accessible;
-
-Control () {
- /* Do nothing */
-}
-
+public abstract class Control extends Widget implements Drawable {
+ Composite parent;
+ Menu menu;
+ Object layoutData;
+ String toolTipText;
+ int toolTipHandle;
+ Accessible accessible;
+
+Control () {
+ /* Do nothing */
+}
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -68,12 +68,12 @@ Control () {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Control (Composite parent, int style) {
- super (parent, style);
- this.parent = parent;
- createWidget (0);
-}
-
+public Control (Composite parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ createWidget (0);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the control is moved or resized, by sending
@@ -93,14 +93,14 @@ public Control (Composite parent, int style) {
* @see ControlListener
* @see #removeControlListener
*/
-public void addControlListener(ControlListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Resize,typedListener);
- addListener (SWT.Move,typedListener);
-}
-
+public void addControlListener(ControlListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Resize,typedListener);
+ addListener (SWT.Move,typedListener);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the control gains or loses focus, by sending
@@ -120,14 +120,14 @@ public void addControlListener(ControlListener listener) {
* @see FocusListener
* @see #removeFocusListener
*/
-public void addFocusListener (FocusListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.FocusIn,typedListener);
- addListener (SWT.FocusOut,typedListener);
-}
-
+public void addFocusListener (FocusListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.FocusIn,typedListener);
+ addListener (SWT.FocusOut,typedListener);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when help events are generated for the control,
@@ -147,13 +147,13 @@ public void addFocusListener (FocusListener listener) {
* @see HelpListener
* @see #removeHelpListener
*/
-public void addHelpListener (HelpListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Help, typedListener);
-}
-
+public void addHelpListener (HelpListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Help, typedListener);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when keys are pressed and released on the system keyboard, by sending
@@ -173,14 +173,14 @@ public void addHelpListener (HelpListener listener) {
* @see KeyListener
* @see #removeKeyListener
*/
-public void addKeyListener (KeyListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.KeyUp,typedListener);
- addListener (SWT.KeyDown,typedListener);
-}
-
+public void addKeyListener (KeyListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.KeyUp,typedListener);
+ addListener (SWT.KeyDown,typedListener);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when mouse buttons are pressed and released, by sending
@@ -200,15 +200,15 @@ public void addKeyListener (KeyListener listener) {
* @see MouseListener
* @see #removeMouseListener
*/
-public void addMouseListener (MouseListener listener) {
- checkWidget();
- 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 addMouseListener (MouseListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.MouseDown,typedListener);
+ addListener (SWT.MouseUp,typedListener);
+ addListener (SWT.MouseDoubleClick,typedListener);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the mouse passes or hovers over controls, by sending
@@ -228,15 +228,15 @@ public void addMouseListener (MouseListener listener) {
* @see MouseTrackListener
* @see #removeMouseTrackListener
*/
-public void addMouseTrackListener (MouseTrackListener listener) {
- checkWidget();
- 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 addMouseTrackListener (MouseTrackListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.MouseEnter,typedListener);
+ addListener (SWT.MouseExit,typedListener);
+ addListener (SWT.MouseHover,typedListener);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the mouse moves, by sending it one of the
@@ -256,13 +256,13 @@ public void addMouseTrackListener (MouseTrackListener listener) {
* @see MouseMoveListener
* @see #removeMouseMoveListener
*/
-public void addMouseMoveListener (MouseMoveListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.MouseMove,typedListener);
-}
-
+public void addMouseMoveListener (MouseMoveListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.MouseMove,typedListener);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver needs to be painted, by sending it
@@ -282,13 +282,13 @@ public void addMouseMoveListener (MouseMoveListener listener) {
* @see PaintListener
* @see #removePaintListener
*/
-public void addPaintListener (PaintListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Paint,typedListener);
-}
-
+public void addPaintListener (PaintListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Paint,typedListener);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when traversal events occur, by sending it
@@ -308,13 +308,13 @@ public void addPaintListener (PaintListener listener) {
* @see TraverseListener
* @see #removeTraverseListener
*/
-public void addTraverseListener (TraverseListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Traverse,typedListener);
-}
-
+public void addTraverseListener (TraverseListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Traverse,typedListener);
+}
+
/**
* Forces the receiver to have the <em>keyboard focus</em>, causing
* all keyboard events to be delivered to it.
@@ -328,23 +328,23 @@ public void addTraverseListener (TraverseListener listener) {
*
* @see #setFocus
*/
-public boolean forceFocus () {
- checkWidget();
- /*
- * Bug in Photon. Photon will stop sending key
- * events, if a menu is up and focus is given to
- * a widget by calling PtContainerGiveFocus(). The
- * fix is to detect when a menu is up and avoid
- * calling this function.
- */
- Shell shell = getShell ();
- if (shell.activeMenu != null) return false;
- int shellHandle = shell.shellHandle;
- OS.PtWindowToFront (shellHandle);
- OS.PtContainerGiveFocus (handle, null);
- return hasFocus ();
-}
-
+public boolean forceFocus () {
+ checkWidget();
+ /*
+ * Bug in Photon. Photon will stop sending key
+ * events, if a menu is up and focus is given to
+ * a widget by calling PtContainerGiveFocus(). The
+ * fix is to detect when a menu is up and avoid
+ * calling this function.
+ */
+ Shell shell = getShell ();
+ if (shell.activeMenu != null) return false;
+ int shellHandle = shell.shellHandle;
+ OS.PtWindowToFront (shellHandle);
+ OS.PtContainerGiveFocus (handle, null);
+ return hasFocus ();
+}
+
/**
* Returns the preferred size of the receiver.
* <p>
@@ -372,10 +372,10 @@ public boolean forceFocus () {
* @see #pack
* @see "computeTrim, getClientArea for controls that implement them"
*/
-public Point computeSize (int wHint, int hHint) {
- return computeSize (wHint, hHint, true);
-}
-
+public Point computeSize (int wHint, int hHint) {
+ return computeSize (wHint, hHint, true);
+}
+
/**
* Returns the preferred size of the receiver.
* <p>
@@ -410,133 +410,133 @@ public Point computeSize (int wHint, int hHint) {
* @see #pack
* @see "computeTrim, getClientArea for controls that implement them"
*/
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget();
- 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);
-}
-
-Control computeTabGroup () {
- if (isTabGroup ()) return this;
- return parent.computeTabGroup ();
-}
-
-Control computeTabRoot () {
- Control [] tabList = parent._getTabList ();
- if (tabList != null) {
- int index = 0;
- while (index < tabList.length) {
- if (tabList [index] == this) break;
- index++;
- }
- if (index == tabList.length) {
- if (isTabGroup ()) return this;
- }
- }
- return parent.computeTabRoot ();
-}
-
-Control [] computeTabList () {
- if (isTabGroup ()) {
- if (getVisible () && getEnabled ()) {
- return new Control [] {this};
- }
- }
- return new Control [0];
-}
-
-void createWidget (int index) {
- checkOrientation (parent);
- super.createWidget (index);
- setZOrder ();
- realizeWidget ();
- setDefaultFont ();
-}
-
-int defaultBackground () {
- Display display = getDisplay ();
- return display.WIDGET_BACKGROUND;
-}
-
-byte [] defaultFont () {
- Display display = getDisplay ();
- return display.TEXT_FONT;
-}
-
-int defaultForeground () {
- Display display = getDisplay ();
- return display.WIDGET_FOREGROUND;
-}
-
-int drawProc (int widget, int damage) {
- drawWidget (widget, damage);
- if (!hooks(SWT.Paint) && !filters (SWT.Paint)) return OS.Pt_CONTINUE;
-
- /* 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);
- boolean noMerge = (style & SWT.NO_MERGE_PAINTS) != 0 && (state & CANVAS) != 0;
- if (tile.next != 0 && noMerge) {
- while (tile.next != 0) {
- OS.memmove (tile, tile.next, PhTile_t.sizeof);
- if (tile.rect_ul_x != tile.rect_lr_x || tile.rect_ul_y != tile.rect_lr_y) {
- Event event = new Event ();
- event.x = tile.rect_ul_x;
- event.y = tile.rect_ul_y;
- event.width = tile.rect_lr_x - tile.rect_ul_x + 1;
- event.height = tile.rect_lr_y - tile.rect_ul_y + 1;
- GC gc = event.gc = new GC (this);
- gc.setClipping (event.x, event.y, event.width, event.height);
- sendEvent (SWT.Paint, event);
- if (isDisposed ()) break;
- gc.dispose ();
- event.gc = null;
- }
- }
- } else {
- if (tile.rect_ul_x != tile.rect_lr_x || tile.rect_ul_y != tile.rect_lr_y) {
- Event event = new Event ();
- event.x = tile.rect_ul_x;
- event.y = tile.rect_ul_y;
- event.width = tile.rect_lr_x - tile.rect_ul_x + 1;
- event.height = tile.rect_lr_y - tile.rect_ul_y + 1;
- Region region = Region.photon_new (tile.next);
- GC gc = event.gc = new GC (this);
- gc.setClipping (region);
- sendEvent (SWT.Paint, event);
- gc.dispose ();
- event.gc = null;
- }
- }
- OS.PhFreeTiles (damage);
- return OS.Pt_CONTINUE;
-}
-
-void drawWidget (int widget, int damage) {
- int widgetClass = widgetClass ();
- if (widgetClass != 0) OS.PtSuperClassDraw (widgetClass, handle, damage);
-}
-
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget();
+ 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);
+}
+
+Control computeTabGroup () {
+ if (isTabGroup ()) return this;
+ return parent.computeTabGroup ();
+}
+
+Control computeTabRoot () {
+ Control [] tabList = parent._getTabList ();
+ if (tabList != null) {
+ int index = 0;
+ while (index < tabList.length) {
+ if (tabList [index] == this) break;
+ index++;
+ }
+ if (index == tabList.length) {
+ if (isTabGroup ()) return this;
+ }
+ }
+ return parent.computeTabRoot ();
+}
+
+Control [] computeTabList () {
+ if (isTabGroup ()) {
+ if (getVisible () && getEnabled ()) {
+ return new Control [] {this};
+ }
+ }
+ return new Control [0];
+}
+
+void createWidget (int index) {
+ checkOrientation (parent);
+ super.createWidget (index);
+ setZOrder ();
+ realizeWidget ();
+ setDefaultFont ();
+}
+
+int defaultBackground () {
+ Display display = getDisplay ();
+ return display.WIDGET_BACKGROUND;
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.TEXT_FONT;
+}
+
+int defaultForeground () {
+ Display display = getDisplay ();
+ return display.WIDGET_FOREGROUND;
+}
+
+int drawProc (int widget, int damage) {
+ drawWidget (widget, damage);
+ if (!hooks(SWT.Paint) && !filters (SWT.Paint)) return OS.Pt_CONTINUE;
+
+ /* 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);
+ boolean noMerge = (style & SWT.NO_MERGE_PAINTS) != 0 && (state & CANVAS) != 0;
+ if (tile.next != 0 && noMerge) {
+ while (tile.next != 0) {
+ OS.memmove (tile, tile.next, PhTile_t.sizeof);
+ if (tile.rect_ul_x != tile.rect_lr_x || tile.rect_ul_y != tile.rect_lr_y) {
+ Event event = new Event ();
+ event.x = tile.rect_ul_x;
+ event.y = tile.rect_ul_y;
+ event.width = tile.rect_lr_x - tile.rect_ul_x + 1;
+ event.height = tile.rect_lr_y - tile.rect_ul_y + 1;
+ GC gc = event.gc = new GC (this);
+ gc.setClipping (event.x, event.y, event.width, event.height);
+ sendEvent (SWT.Paint, event);
+ if (isDisposed ()) break;
+ gc.dispose ();
+ event.gc = null;
+ }
+ }
+ } else {
+ if (tile.rect_ul_x != tile.rect_lr_x || tile.rect_ul_y != tile.rect_lr_y) {
+ Event event = new Event ();
+ event.x = tile.rect_ul_x;
+ event.y = tile.rect_ul_y;
+ event.width = tile.rect_lr_x - tile.rect_ul_x + 1;
+ event.height = tile.rect_lr_y - tile.rect_ul_y + 1;
+ Region region = Region.photon_new (tile.next);
+ GC gc = event.gc = new GC (this);
+ gc.setClipping (region);
+ sendEvent (SWT.Paint, event);
+ gc.dispose ();
+ event.gc = null;
+ }
+ }
+ OS.PhFreeTiles (damage);
+ return OS.Pt_CONTINUE;
+}
+
+void drawWidget (int widget, int damage) {
+ int widgetClass = widgetClass ();
+ if (widgetClass != 0) OS.PtSuperClassDraw (widgetClass, handle, damage);
+}
+
/**
* Returns the accessible object for the receiver.
* If this is the first time this object is requested,
@@ -554,14 +554,14 @@ void drawWidget (int widget, int damage) {
*
* @since 2.0
*/
-public Accessible getAccessible () {
- checkWidget ();
- if (accessible == null) {
- accessible = Accessible.internal_new_Accessible (this);
- }
- return accessible;
-}
-
+public Accessible getAccessible () {
+ checkWidget ();
+ if (accessible == null) {
+ accessible = Accessible.internal_new_Accessible (this);
+ }
+ return accessible;
+}
+
/**
* Returns the receiver's background color.
*
@@ -572,13 +572,13 @@ public Accessible getAccessible () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Color getBackground () {
- checkWidget();
- int [] args = {OS.Pt_ARG_FILL_COLOR, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return Color.photon_new (getDisplay (), args [1]);
-}
-
+public Color getBackground () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_FILL_COLOR, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return Color.photon_new (getDisplay (), args [1]);
+}
+
/**
* Returns the font that the receiver will use to paint textual information.
*
@@ -589,30 +589,30 @@ public Color getBackground () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Font getFont () {
- checkWidget();
- int [] args = {
- OS.Pt_ARG_TEXT_FONT, 0, 0,
- OS.Pt_ARG_LIST_FONT, 0, 0,
- OS.Pt_ARG_TITLE_FONT, 0, 0,
- OS.Pt_ARG_GAUGE_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) ptr = args [11];
- 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 Font getFont () {
+ checkWidget();
+ int [] args = {
+ OS.Pt_ARG_TEXT_FONT, 0, 0,
+ OS.Pt_ARG_LIST_FONT, 0, 0,
+ OS.Pt_ARG_TITLE_FONT, 0, 0,
+ OS.Pt_ARG_GAUGE_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) ptr = args [11];
+ 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);
+}
+
/**
* Returns the foreground color that the receiver will use to draw.
*
@@ -623,13 +623,13 @@ public Font getFont () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Color getForeground () {
- checkWidget();
- int [] args = {OS.Pt_ARG_COLOR, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return Color.photon_new (getDisplay (), args [1]);
-}
-
+public Color getForeground () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_COLOR, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return Color.photon_new (getDisplay (), args [1]);
+}
+
/**
* Returns the receiver's border width.
*
@@ -640,25 +640,25 @@ public Color getForeground () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getBorderWidth () {
- checkWidget();
- int topHandle = topHandle ();
- int [] args = {
- OS.Pt_ARG_BASIC_FLAGS, 0, 0,
- OS.Pt_ARG_FLAGS, 0, 0,
-// OS.Pt_ARG_BEVEL_WIDTH, 0, 0,
- };
- OS.PtGetResources (topHandle, args.length / 3, args);
- if ((args [4] & OS.Pt_HIGHLIGHTED) == 0) return 0;
- int border = 0;
- int flags = args [1];
- if ((flags & OS.Pt_ALL_ETCHES) != 0) border++;
- if ((flags & OS.Pt_ALL_OUTLINES) != 0) border++;
- if ((flags & OS.Pt_ALL_INLINES) != 0) border++;
-// if ((flags & OS.Pt_ALL_BEVELS) != 0) border += args [7];
- return border;
-}
-
+public int getBorderWidth () {
+ checkWidget();
+ int topHandle = topHandle ();
+ int [] args = {
+ OS.Pt_ARG_BASIC_FLAGS, 0, 0,
+ OS.Pt_ARG_FLAGS, 0, 0,
+// OS.Pt_ARG_BEVEL_WIDTH, 0, 0,
+ };
+ OS.PtGetResources (topHandle, args.length / 3, args);
+ if ((args [4] & OS.Pt_HIGHLIGHTED) == 0) return 0;
+ int border = 0;
+ int flags = args [1];
+ if ((flags & OS.Pt_ALL_ETCHES) != 0) border++;
+ if ((flags & OS.Pt_ALL_OUTLINES) != 0) border++;
+ if ((flags & OS.Pt_ALL_INLINES) != 0) border++;
+// if ((flags & OS.Pt_ALL_BEVELS) != 0) border += args [7];
+ return border;
+}
+
/**
* Returns a rectangle describing the receiver's size and location
* relative to its parent (or its display if its parent is null).
@@ -670,14 +670,14 @@ public int getBorderWidth () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Rectangle getBounds () {
- checkWidget();
- 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 Rectangle getBounds () {
+ checkWidget();
+ 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);
+}
+
/**
* Returns the display that the receiver was created on.
*
@@ -688,12 +688,12 @@ public Rectangle getBounds () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Display getDisplay () {
- Composite parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-
+public Display getDisplay () {
+ Composite parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
/**
* Returns <code>true</code> if the receiver is enabled, and
* <code>false</code> otherwise. A disabled control is typically
@@ -707,12 +707,12 @@ public Display getDisplay () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getEnabled () {
- checkWidget ();
- int topHandle = topHandle ();
- return (OS.PtWidgetFlags (topHandle) & OS.Pt_BLOCKED) == 0;
-}
-
+public boolean getEnabled () {
+ checkWidget ();
+ int topHandle = topHandle ();
+ return (OS.PtWidgetFlags (topHandle) & OS.Pt_BLOCKED) == 0;
+}
+
/**
* Returns layout data which is associated with the receiver.
*
@@ -723,11 +723,11 @@ public boolean getEnabled () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Object getLayoutData () {
- checkWidget();
- return layoutData;
-}
-
+public Object getLayoutData () {
+ checkWidget();
+ return layoutData;
+}
+
/**
* Returns a point describing the receiver's location relative
* to its parent (or its display if its parent is null).
@@ -739,14 +739,14 @@ public Object getLayoutData () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Point getLocation () {
- checkWidget();
- int topHandle = topHandle ();
- PhArea_t area = new PhArea_t ();
- OS.PtWidgetArea (topHandle, area);
- return new Point (area.pos_x, area.pos_y);
-}
-
+public Point getLocation () {
+ checkWidget();
+ int topHandle = topHandle ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (topHandle, area);
+ return new Point (area.pos_x, area.pos_y);
+}
+
/**
* Returns the receiver's pop up menu if it has one, or null
* if it does not. All controls may optionally have a pop up
@@ -762,11 +762,11 @@ public Point getLocation () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Menu getMenu () {
- checkWidget();
- return menu;
-}
-
+public Menu getMenu () {
+ checkWidget();
+ return menu;
+}
+
/**
* Returns the receiver's parent, which must be a <code>Composite</code>
* or null when the receiver is a shell that was created with null or
@@ -779,28 +779,28 @@ public Menu getMenu () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Composite getParent () {
- checkWidget();
- return parent;
-}
-
-Control [] getPath () {
- int count = 0;
- Shell shell = getShell ();
- Control control = this;
- while (control != shell) {
- count++;
- control = control.parent;
- }
- control = this;
- Control [] result = new Control [count];
- while (control != shell) {
- result [--count] = control;
- control = control.parent;
- }
- return result;
-}
-
+public Composite getParent () {
+ checkWidget();
+ return parent;
+}
+
+Control [] getPath () {
+ int count = 0;
+ Shell shell = getShell ();
+ Control control = this;
+ while (control != shell) {
+ count++;
+ control = control.parent;
+ }
+ control = this;
+ Control [] result = new Control [count];
+ while (control != shell) {
+ result [--count] = control;
+ control = control.parent;
+ }
+ return result;
+}
+
/**
* Returns a point describing the receiver's size. The
* x coordinate of the result is the width of the receiver.
@@ -814,14 +814,14 @@ Control [] getPath () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Point getSize () {
- checkWidget();
- int topHandle = topHandle ();
- PhArea_t area = new PhArea_t ();
- OS.PtWidgetArea (topHandle, area);
- return new Point (area.size_w, area.size_h);
-}
-
+public Point getSize () {
+ checkWidget();
+ int topHandle = topHandle ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (topHandle, area);
+ return new Point (area.size_w, area.size_h);
+}
+
/**
* Returns the receiver's tool tip text, or null if it has
* not been set.
@@ -833,11 +833,11 @@ public Point getSize () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public String getToolTipText () {
- checkWidget();
- return toolTipText;
-}
-
+public String getToolTipText () {
+ checkWidget();
+ return toolTipText;
+}
+
/**
* Returns the receiver's shell. For all controls other than
* shells, this simply returns the control's nearest ancestor
@@ -853,11 +853,11 @@ public String getToolTipText () {
*
* @see #getParent
*/
-public Shell getShell () {
- checkWidget();
- return parent.getShell ();
-}
-
+public Shell getShell () {
+ checkWidget();
+ return parent.getShell ();
+}
+
/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.
@@ -875,36 +875,36 @@ public Shell getShell () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getVisible () {
- checkWidget ();
- int topHandle = topHandle ();
- return (OS.PtWidgetFlags (topHandle) & OS.Pt_DELAY_REALIZE) == 0;
-}
-
-boolean hasFocus () {
- return OS.PtIsFocused (handle) != 0;
-}
-
-void hookEvents () {
- int windowProc = getDisplay ().windowProc;
- int focusHandle = focusHandle ();
- OS.PtAddFilterCallback (handle, OS.Ph_EV_KEY, windowProc, OS.Ph_EV_KEY);
- OS.PtAddEventHandler (handle, OS.Ph_EV_BUT_PRESS, windowProc, OS.Ph_EV_BUT_PRESS);
- OS.PtAddEventHandler (handle, OS.Ph_EV_BUT_RELEASE, windowProc, OS.Ph_EV_BUT_RELEASE);
- OS.PtAddEventHandler (handle, OS.Ph_EV_PTR_MOTION, windowProc, OS.Ph_EV_PTR_MOTION);
- OS.PtAddEventHandler (handle, OS.Ph_EV_BOUNDARY, windowProc, OS.Ph_EV_BOUNDARY);
- if ((state & GRAB) != 0) {
- OS.PtAddEventHandler (handle, OS.Ph_EV_DRAG, windowProc, OS.Ph_EV_DRAG);
- OS.PtAddCallback (handle, OS.Pt_CB_OUTBOUND, windowProc, OS.Pt_CB_OUTBOUND);
- }
- OS.PtAddCallback (focusHandle, OS.Pt_CB_GOT_FOCUS, windowProc, OS.Pt_CB_GOT_FOCUS);
- OS.PtAddCallback (focusHandle, OS.Pt_CB_LOST_FOCUS, windowProc, OS.Pt_CB_LOST_FOCUS);
-}
-
-int focusHandle () {
- return handle;
-}
-
+public boolean getVisible () {
+ checkWidget ();
+ int topHandle = topHandle ();
+ return (OS.PtWidgetFlags (topHandle) & OS.Pt_DELAY_REALIZE) == 0;
+}
+
+boolean hasFocus () {
+ return OS.PtIsFocused (handle) != 0;
+}
+
+void hookEvents () {
+ int windowProc = getDisplay ().windowProc;
+ int focusHandle = focusHandle ();
+ OS.PtAddFilterCallback (handle, OS.Ph_EV_KEY, windowProc, OS.Ph_EV_KEY);
+ OS.PtAddEventHandler (handle, OS.Ph_EV_BUT_PRESS, windowProc, OS.Ph_EV_BUT_PRESS);
+ OS.PtAddEventHandler (handle, OS.Ph_EV_BUT_RELEASE, windowProc, OS.Ph_EV_BUT_RELEASE);
+ OS.PtAddEventHandler (handle, OS.Ph_EV_PTR_MOTION, windowProc, OS.Ph_EV_PTR_MOTION);
+ OS.PtAddEventHandler (handle, OS.Ph_EV_BOUNDARY, windowProc, OS.Ph_EV_BOUNDARY);
+ if ((state & GRAB) != 0) {
+ OS.PtAddEventHandler (handle, OS.Ph_EV_DRAG, windowProc, OS.Ph_EV_DRAG);
+ OS.PtAddCallback (handle, OS.Pt_CB_OUTBOUND, windowProc, OS.Pt_CB_OUTBOUND);
+ }
+ OS.PtAddCallback (focusHandle, OS.Pt_CB_GOT_FOCUS, windowProc, OS.Pt_CB_GOT_FOCUS);
+ OS.PtAddCallback (focusHandle, OS.Pt_CB_LOST_FOCUS, windowProc, OS.Pt_CB_LOST_FOCUS);
+}
+
+int focusHandle () {
+ return handle;
+}
+
/**
* Invokes platform specific functionality to allocate a new GC handle.
* <p>
@@ -920,22 +920,22 @@ int focusHandle () {
*
* @private
*/
-public int internal_new_GC (GCData data) {
- checkWidget();
- 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 int internal_new_GC (GCData data) {
+ checkWidget();
+ 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;
+}
+
/**
* Invokes platform specific functionality to dispose a GC handle.
* <p>
@@ -951,40 +951,40 @@ public int internal_new_GC (GCData data) {
*
* @private
*/
-public void internal_dispose_GC (int phGC, GCData data) {
- checkWidget ();
- OS.PgDestroyGC(phGC);
-}
-
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
- */
-public boolean isEnabled () {
- checkWidget();
- return getEnabled () && parent.isEnabled ();
-}
-
-public boolean isFocusAncestor () {
- Display display = getDisplay ();
- Control control = display.getFocusControl ();
- while (control != null && control != this) {
- control = control.parent;
- }
- return control == this;
-}
-
+public void internal_dispose_GC (int phGC, GCData data) {
+ checkWidget ();
+ OS.PgDestroyGC(phGC);
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
+ */
+public boolean isEnabled () {
+ checkWidget();
+ return getEnabled () && parent.isEnabled ();
+}
+
+public boolean isFocusAncestor () {
+ Display display = getDisplay ();
+ Control control = display.getFocusControl ();
+ while (control != null && control != this) {
+ control = control.parent;
+ }
+ return control == this;
+}
+
/**
* Returns <code>true</code> if the receiver has the user-interface
* focus, and <code>false</code> otherwise.
@@ -996,11 +996,11 @@ public boolean isFocusAncestor () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean isFocusControl () {
- checkWidget();
- return hasFocus ();
-}
-
+public boolean isFocusControl () {
+ checkWidget();
+ return hasFocus ();
+}
+
/**
* Returns <code>true</code> if the underlying operating
* system supports this reparenting, otherwise <code>false</code>
@@ -1012,83 +1012,83 @@ public boolean isFocusControl () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean isReparentable () {
- checkWidget();
- return false;
-}
-
-boolean isShowing () {
- /*
- * This is not complete. Need to check if the
- * widget is obscurred by a parent or sibling.
- */
- if (!isVisible ()) return false;
- Control control = this;
- while (control != null) {
- Point size = control.getSize ();
- if (size.x == 0 || size.y == 0) {
- return false;
- }
- control = control.parent;
- }
- return true;
- /*
- * Check to see if current damage is included.
- */
-// if (!OS.IsWindowVisible (handle)) return false;
-// int flags = OS.DCX_CACHE | OS.DCX_CLIPCHILDREN | OS.DCX_CLIPSIBLINGS;
-// int hDC = OS.GetDCEx (handle, 0, flags);
-// int result = OS.GetClipBox (hDC, new RECT ());
-// OS.ReleaseDC (handle, hDC);
-// return result != OS.NULLREGION;
-}
-
-boolean isTabGroup () {
- Control [] tabList = parent._getTabList ();
- if (tabList != null) {
- for (int i=0; i<tabList.length; i++) {
- if (tabList [i] == this) return true;
- }
- }
- int code = traversalCode (0, null);
- if ((code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0) return false;
- return (code & (SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT)) != 0;
-}
-
-boolean isTabItem () {
- Control [] tabList = parent._getTabList ();
- if (tabList != null) {
- for (int i=0; i<tabList.length; i++) {
- if (tabList [i] == this) return false;
- }
- }
- int code = traversalCode (0, null);
- return (code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0;
-}
-
-/**
- * Returns <code>true</code> if the receiver is visible and all
- * of the receiver's ancestors are visible and <code>false</code>
- * otherwise.
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getVisible
- */
-public boolean isVisible () {
- checkWidget();
- return OS.PtWidgetIsRealized (handle);
-}
-
-Decorations menuShell () {
- return parent.menuShell ();
-}
-
+public boolean isReparentable () {
+ checkWidget();
+ return false;
+}
+
+boolean isShowing () {
+ /*
+ * This is not complete. Need to check if the
+ * widget is obscurred by a parent or sibling.
+ */
+ if (!isVisible ()) return false;
+ Control control = this;
+ while (control != null) {
+ Point size = control.getSize ();
+ if (size.x == 0 || size.y == 0) {
+ return false;
+ }
+ control = control.parent;
+ }
+ return true;
+ /*
+ * Check to see if current damage is included.
+ */
+// if (!OS.IsWindowVisible (handle)) return false;
+// int flags = OS.DCX_CACHE | OS.DCX_CLIPCHILDREN | OS.DCX_CLIPSIBLINGS;
+// int hDC = OS.GetDCEx (handle, 0, flags);
+// int result = OS.GetClipBox (hDC, new RECT ());
+// OS.ReleaseDC (handle, hDC);
+// return result != OS.NULLREGION;
+}
+
+boolean isTabGroup () {
+ Control [] tabList = parent._getTabList ();
+ if (tabList != null) {
+ for (int i=0; i<tabList.length; i++) {
+ if (tabList [i] == this) return true;
+ }
+ }
+ int code = traversalCode (0, null);
+ if ((code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0) return false;
+ return (code & (SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT)) != 0;
+}
+
+boolean isTabItem () {
+ Control [] tabList = parent._getTabList ();
+ if (tabList != null) {
+ for (int i=0; i<tabList.length; i++) {
+ if (tabList [i] == this) return false;
+ }
+ }
+ int code = traversalCode (0, null);
+ return (code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
+ */
+public boolean isVisible () {
+ checkWidget();
+ return OS.PtWidgetIsRealized (handle);
+}
+
+Decorations menuShell () {
+ return parent.menuShell ();
+}
+
/**
* Moves the receiver above the specified control in the
* drawing order. If the argument is null, then the receiver
@@ -1106,20 +1106,20 @@ Decorations menuShell () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void moveAbove (Control control) {
- checkWidget();
- int topHandle1 = topHandle ();
- if (control == null) {
- OS.PtWidgetToFront (topHandle1);
- OS.PtWindowToFront (topHandle1);
- return;
- }
- if (control.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if (parent != control.parent) return;
- int topHandle2 = control.topHandle ();
- OS.PtWidgetInsert (topHandle1, topHandle2, 0);
-}
-
+public void moveAbove (Control control) {
+ checkWidget();
+ int topHandle1 = topHandle ();
+ if (control == null) {
+ OS.PtWidgetToFront (topHandle1);
+ OS.PtWindowToFront (topHandle1);
+ return;
+ }
+ if (control.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if (parent != control.parent) return;
+ int topHandle2 = control.topHandle ();
+ OS.PtWidgetInsert (topHandle1, topHandle2, 0);
+}
+
/**
* Moves the receiver below the specified control in the
* drawing order. If the argument is null, then the receiver
@@ -1137,20 +1137,20 @@ public void moveAbove (Control control) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void moveBelow (Control control) {
- checkWidget();
- int topHandle1 = topHandle ();
- if (control == null) {
- if (parent != null) parent.moveToBack (topHandle1);
- OS.PtWindowToBack (topHandle1);
- return;
- }
- if (control.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if (parent != control.parent) return;
- int topHandle2 = control.topHandle ();
- OS.PtWidgetInsert (topHandle1, topHandle2, 1);
-}
-
+public void moveBelow (Control control) {
+ checkWidget();
+ int topHandle1 = topHandle ();
+ if (control == null) {
+ if (parent != null) parent.moveToBack (topHandle1);
+ OS.PtWindowToBack (topHandle1);
+ return;
+ }
+ if (control.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if (parent != control.parent) return;
+ int topHandle2 = control.topHandle ();
+ OS.PtWidgetInsert (topHandle1, topHandle2, 1);
+}
+
/**
* Causes the receiver to be resized to its preferred size.
* For a composite, this involves computing the preferred size
@@ -1163,11 +1163,11 @@ public void moveBelow (Control control) {
*
* @see #computeSize
*/
-public void pack () {
- checkWidget();
- pack (true);
-}
-
+public void pack () {
+ checkWidget();
+ pack (true);
+}
+
/**
* Causes the receiver to be resized to its preferred size.
* For a composite, this involves computing the preferred size
@@ -1187,346 +1187,346 @@ public void pack () {
*
* @see #computeSize
*/
-public void pack (boolean changed) {
- checkWidget();
- setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed));
-}
-
-int Ph_EV_BOUNDARY (int widget, 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;
- PhPointerEvent_t pe = new PhPointerEvent_t ();
- OS.memmove (pe, data, PhPointerEvent_t.sizeof);
- Event event = new Event ();
- event.time = ev.timestamp;
- setMouseState (event, pe, ev);
- switch ((int) 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;
- case OS.Ph_EV_PTR_STEADY:
- postEvent (SWT.MouseHover, event);
- destroyToolTip (toolTipHandle);
- toolTipHandle = createToolTip (toolTipText, handle, getFont ().handle);
- break;
- case OS.Ph_EV_PTR_UNSTEADY:
- destroyToolTip (toolTipHandle);
- toolTipHandle = 0;
- break;
- }
- return OS.Pt_END;
-}
-
-int Ph_EV_BUT_PRESS (int widget, 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);
- if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
- return OS.Pt_CONTINUE;
- }
- ev.processing_flags |= OS.Ph_CONSUMED;
- OS.memmove (cbinfo.event, ev, 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);
- Event event = new Event ();
- event.time = ev.timestamp;
- setMouseState (event, pe, ev);
- postEvent (SWT.MouseDown, event);
- if (pe.click_count == 2) {
- Event clickEvent = new Event ();
- clickEvent.time = event.time;
- clickEvent.x = event.x;
- clickEvent.y = event.y;
- clickEvent.button = event.button;
- clickEvent.stateMask = event.stateMask;
- postEvent (SWT.MouseDoubleClick, clickEvent);
- }
- if (event.button == 3) {
- if (menu != null && !menu.isDisposed ()) {
- Display display = getDisplay ();
- display.runDeferredEvents ();
- menu.setVisible (true);
- }
- }
- /*
- * It is possible that the shell may be
- * disposed at this point. If this happens
- * don't send the activate and deactivate
- * events.
- */
- Shell shell = getShell ();
- if (!shell.isDisposed ()) {
- shell.setActiveControl (this);
- }
- return OS.Pt_CONTINUE;
-}
-
-int Ph_EV_BUT_RELEASE (int widget, 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);
- if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
- return OS.Pt_CONTINUE;
- }
- ev.processing_flags |= OS.Ph_CONSUMED;
- OS.memmove (cbinfo.event, ev, PhEvent_t.sizeof);
- if (ev.subtype != OS.Ph_EV_RELEASE_PHANTOM) {
- return OS.Pt_CONTINUE;
- }
- 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 event = new Event ();
- event.time = ev.timestamp;
- setMouseState (event, pe, ev);
- postEvent (SWT.MouseUp, event);
- return OS.Pt_CONTINUE;
-}
-
-int Ph_EV_DRAG (int widget, 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);
- if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
- return OS.Pt_CONTINUE;
- }
- if (ev.subtype != OS.Ph_EV_DRAG_MOTION_EVENT) {
- return OS.Pt_CONTINUE;
- }
- 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 event = new Event ();
- event.time = ev.timestamp;
- setMouseState (event, pe, ev);
- postEvent (SWT.MouseMove, event);
- return OS.Pt_CONTINUE;
-}
-
-int Ph_EV_KEY (int widget, int info) {
- if (!hasFocus ()) return OS.Pt_PROCESS;
- if (info == 0) return OS.Pt_PROCESS;
- PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
- OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
- if (cbinfo.event == 0) return OS.Pt_PROCESS;
- PhEvent_t ev = new PhEvent_t ();
- OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
- if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
- return OS.Pt_PROCESS;
- }
- int data = OS.PhGetData (cbinfo.event);
- if (data == 0) return OS.Pt_PROCESS;
- PhKeyEvent_t ke = new PhKeyEvent_t ();
- OS.memmove (ke, data, PhKeyEvent_t.sizeof);
-
- /*
- * 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 OS.Pt_PROCESS;
- }
-
- /* Ignore repeating modifier keys */
- 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:
- return OS.Pt_PROCESS;
- }
- }
- }
-
- /* Determine event type */
- int type = SWT.KeyUp;
- if ((ke.key_flags & (OS.Pk_KF_Key_Down | OS.Pk_KF_Key_Repeat)) != 0) {
- type = SWT.KeyDown;
- }
-
- /* Determine if this is a traverse event */
- if (type == SWT.KeyDown) {
- /*
- * Fetuare in Photon. The key_sym value is not valid when Ctrl
- * or Alt is pressed. The fix is to detect this case and try to
- * use the key_cap value.
- */
- int key = ke.key_sym;
- if ((ke.key_flags & OS.Pk_KF_Sym_Valid) == 0) {
- key = 0;
- if ((ke.key_flags & OS.Pk_KF_Cap_Valid) != 0) {
- if (ke.key_cap == OS.Pk_Tab && (ke.key_mods & OS.Pk_KM_Ctrl) != 0) {
- key = OS.Pk_Tab;
- }
- }
- }
-
- switch (key) {
- case OS.Pk_Escape:
- case OS.Pk_Return:
- case OS.Pk_KP_Tab:
- case OS.Pk_Tab:
- case OS.Pk_Up:
- case OS.Pk_Down:
- case OS.Pk_Left:
- case OS.Pk_Right:
- case OS.Pk_Pg_Up:
- case OS.Pk_Pg_Down: {
- if (key != OS.Pk_Return) {
- ev.processing_flags |= OS.Ph_NOT_CUAKEY;
- OS.memmove (cbinfo.event, ev, PhEvent_t.sizeof);
- }
- if (translateTraversal (key, ke)) {
- ev.processing_flags |= OS.Ph_CONSUMED;
- OS.memmove (cbinfo.event, ev, PhEvent_t.sizeof);
- return OS.Pt_PROCESS;
- }
- // widget could be disposed at this point
- if (isDisposed ()) return OS.Pt_PROCESS;
- }
- }
- }
-
- Event event = new Event ();
- event.time = ev.timestamp;
- setKeyState (event, ke);
- Display display = getDisplay ();
- if (type == SWT.KeyDown) {
- display.lastKey = event.keyCode;
- display.lastAscii = event.character;
- } else {
- if (event.keyCode == 0) event.keyCode = display.lastKey;
- if (event.character == 0) event.character = (char) display.lastAscii;
- }
- postEvent (type, event);
- return OS.Pt_PROCESS;
-}
-
-int Ph_EV_PTR_MOTION (int widget, 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);
- if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
- return OS.Pt_CONTINUE;
- }
- ev.processing_flags |= OS.Ph_CONSUMED;
- OS.memmove (cbinfo.event, ev, PhEvent_t.sizeof);
- if (ev.type == OS.Ph_EV_PTR_MOTION_BUTTON) {
- if ((state & CANVAS) != 0) return OS.Pt_CONTINUE;
- }
- 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 event = new Event ();
- event.time = ev.timestamp;
- setMouseState (event, pe, ev);
- postEvent (SWT.MouseMove, event);
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_GOT_FOCUS (int widget, int info) {
- Shell shell = getShell ();
- sendEvent (SWT.FocusIn);
- if (isDisposed ()) return OS.Pt_CONTINUE;
-
- /*
- * It is possible that the shell may be
- * disposed at this point. If this happens
- * don't send the activate and deactivate
- * events.
- */
- if (!shell.isDisposed ()) {
- shell.setActiveControl (this);
- }
-
- /*
- * Feature in Photon. Cannot return Pt_END
- * or the text widget will not take focus.
- */
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_LOST_FOCUS (int widget, int info) {
- Shell shell = getShell ();
- sendEvent (SWT.FocusOut);
- if (isDisposed ()) return OS.Pt_CONTINUE;
-
- /*
- * It is possible that the shell may be
- * disposed at this point. If this happens
- * don't send the activate and deactivate
- * events.
- */
- if (!shell.isDisposed ()) {
- Display display = shell.getDisplay ();
- Control control = display.getFocusControl ();
- if (control == null || shell != control.getShell () ) {
- shell.setActiveControl (null);
- }
- }
-
- /*
- * Feature in Photon. Cannot return Pt_END
- * or the text widget will not take focus.
- */
- return OS.Pt_CONTINUE;
-}
-
-void realizeWidget() {
- int parentHandle = parent.handle;
- if (OS.PtWidgetIsRealized (parentHandle)) {
- OS.PtRealizeWidget (topHandle ());
- }
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- if (toolTipHandle != 0) destroyToolTip (toolTipHandle);
- toolTipHandle = 0;
- if (menu != null && !menu.isDisposed ()) {
- menu.dispose ();
- }
- menu = null;
- parent = null;
- layoutData = null;
-}
-
+public void pack (boolean changed) {
+ checkWidget();
+ setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed));
+}
+
+int Ph_EV_BOUNDARY (int widget, 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;
+ PhPointerEvent_t pe = new PhPointerEvent_t ();
+ OS.memmove (pe, data, PhPointerEvent_t.sizeof);
+ Event event = new Event ();
+ event.time = ev.timestamp;
+ setMouseState (event, pe, ev);
+ switch ((int) 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;
+ case OS.Ph_EV_PTR_STEADY:
+ postEvent (SWT.MouseHover, event);
+ destroyToolTip (toolTipHandle);
+ toolTipHandle = createToolTip (toolTipText, handle, getFont ().handle);
+ break;
+ case OS.Ph_EV_PTR_UNSTEADY:
+ destroyToolTip (toolTipHandle);
+ toolTipHandle = 0;
+ break;
+ }
+ return OS.Pt_END;
+}
+
+int Ph_EV_BUT_PRESS (int widget, 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);
+ if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
+ return OS.Pt_CONTINUE;
+ }
+ ev.processing_flags |= OS.Ph_CONSUMED;
+ OS.memmove (cbinfo.event, ev, 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);
+ Event event = new Event ();
+ event.time = ev.timestamp;
+ setMouseState (event, pe, ev);
+ postEvent (SWT.MouseDown, event);
+ if (pe.click_count == 2) {
+ Event clickEvent = new Event ();
+ clickEvent.time = event.time;
+ clickEvent.x = event.x;
+ clickEvent.y = event.y;
+ clickEvent.button = event.button;
+ clickEvent.stateMask = event.stateMask;
+ postEvent (SWT.MouseDoubleClick, clickEvent);
+ }
+ if (event.button == 3) {
+ if (menu != null && !menu.isDisposed ()) {
+ Display display = getDisplay ();
+ display.runDeferredEvents ();
+ menu.setVisible (true);
+ }
+ }
+ /*
+ * It is possible that the shell may be
+ * disposed at this point. If this happens
+ * don't send the activate and deactivate
+ * events.
+ */
+ Shell shell = getShell ();
+ if (!shell.isDisposed ()) {
+ shell.setActiveControl (this);
+ }
+ return OS.Pt_CONTINUE;
+}
+
+int Ph_EV_BUT_RELEASE (int widget, 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);
+ if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
+ return OS.Pt_CONTINUE;
+ }
+ ev.processing_flags |= OS.Ph_CONSUMED;
+ OS.memmove (cbinfo.event, ev, PhEvent_t.sizeof);
+ if (ev.subtype != OS.Ph_EV_RELEASE_PHANTOM) {
+ return OS.Pt_CONTINUE;
+ }
+ 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 event = new Event ();
+ event.time = ev.timestamp;
+ setMouseState (event, pe, ev);
+ postEvent (SWT.MouseUp, event);
+ return OS.Pt_CONTINUE;
+}
+
+int Ph_EV_DRAG (int widget, 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);
+ if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
+ return OS.Pt_CONTINUE;
+ }
+ if (ev.subtype != OS.Ph_EV_DRAG_MOTION_EVENT) {
+ return OS.Pt_CONTINUE;
+ }
+ 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 event = new Event ();
+ event.time = ev.timestamp;
+ setMouseState (event, pe, ev);
+ postEvent (SWT.MouseMove, event);
+ return OS.Pt_CONTINUE;
+}
+
+int Ph_EV_KEY (int widget, int info) {
+ if (!hasFocus ()) return OS.Pt_PROCESS;
+ if (info == 0) return OS.Pt_PROCESS;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.event == 0) return OS.Pt_PROCESS;
+ PhEvent_t ev = new PhEvent_t ();
+ OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
+ if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
+ return OS.Pt_PROCESS;
+ }
+ int data = OS.PhGetData (cbinfo.event);
+ if (data == 0) return OS.Pt_PROCESS;
+ PhKeyEvent_t ke = new PhKeyEvent_t ();
+ OS.memmove (ke, data, PhKeyEvent_t.sizeof);
+
+ /*
+ * 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 OS.Pt_PROCESS;
+ }
+
+ /* Ignore repeating modifier keys */
+ 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:
+ return OS.Pt_PROCESS;
+ }
+ }
+ }
+
+ /* Determine event type */
+ int type = SWT.KeyUp;
+ if ((ke.key_flags & (OS.Pk_KF_Key_Down | OS.Pk_KF_Key_Repeat)) != 0) {
+ type = SWT.KeyDown;
+ }
+
+ /* Determine if this is a traverse event */
+ if (type == SWT.KeyDown) {
+ /*
+ * Fetuare in Photon. The key_sym value is not valid when Ctrl
+ * or Alt is pressed. The fix is to detect this case and try to
+ * use the key_cap value.
+ */
+ int key = ke.key_sym;
+ if ((ke.key_flags & OS.Pk_KF_Sym_Valid) == 0) {
+ key = 0;
+ if ((ke.key_flags & OS.Pk_KF_Cap_Valid) != 0) {
+ if (ke.key_cap == OS.Pk_Tab && (ke.key_mods & OS.Pk_KM_Ctrl) != 0) {
+ key = OS.Pk_Tab;
+ }
+ }
+ }
+
+ switch (key) {
+ case OS.Pk_Escape:
+ case OS.Pk_Return:
+ case OS.Pk_KP_Tab:
+ case OS.Pk_Tab:
+ case OS.Pk_Up:
+ case OS.Pk_Down:
+ case OS.Pk_Left:
+ case OS.Pk_Right:
+ case OS.Pk_Pg_Up:
+ case OS.Pk_Pg_Down: {
+ if (key != OS.Pk_Return) {
+ ev.processing_flags |= OS.Ph_NOT_CUAKEY;
+ OS.memmove (cbinfo.event, ev, PhEvent_t.sizeof);
+ }
+ if (translateTraversal (key, ke)) {
+ ev.processing_flags |= OS.Ph_CONSUMED;
+ OS.memmove (cbinfo.event, ev, PhEvent_t.sizeof);
+ return OS.Pt_PROCESS;
+ }
+ // widget could be disposed at this point
+ if (isDisposed ()) return OS.Pt_PROCESS;
+ }
+ }
+ }
+
+ Event event = new Event ();
+ event.time = ev.timestamp;
+ setKeyState (event, ke);
+ Display display = getDisplay ();
+ if (type == SWT.KeyDown) {
+ display.lastKey = event.keyCode;
+ display.lastAscii = event.character;
+ } else {
+ if (event.keyCode == 0) event.keyCode = display.lastKey;
+ if (event.character == 0) event.character = (char) display.lastAscii;
+ }
+ postEvent (type, event);
+ return OS.Pt_PROCESS;
+}
+
+int Ph_EV_PTR_MOTION (int widget, 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);
+ if ((ev.processing_flags & OS.Ph_FAKE_EVENT) != 0) {
+ return OS.Pt_CONTINUE;
+ }
+ ev.processing_flags |= OS.Ph_CONSUMED;
+ OS.memmove (cbinfo.event, ev, PhEvent_t.sizeof);
+ if (ev.type == OS.Ph_EV_PTR_MOTION_BUTTON) {
+ if ((state & CANVAS) != 0) return OS.Pt_CONTINUE;
+ }
+ 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 event = new Event ();
+ event.time = ev.timestamp;
+ setMouseState (event, pe, ev);
+ postEvent (SWT.MouseMove, event);
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_GOT_FOCUS (int widget, int info) {
+ Shell shell = getShell ();
+ sendEvent (SWT.FocusIn);
+ if (isDisposed ()) return OS.Pt_CONTINUE;
+
+ /*
+ * It is possible that the shell may be
+ * disposed at this point. If this happens
+ * don't send the activate and deactivate
+ * events.
+ */
+ if (!shell.isDisposed ()) {
+ shell.setActiveControl (this);
+ }
+
+ /*
+ * Feature in Photon. Cannot return Pt_END
+ * or the text widget will not take focus.
+ */
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_LOST_FOCUS (int widget, int info) {
+ Shell shell = getShell ();
+ sendEvent (SWT.FocusOut);
+ if (isDisposed ()) return OS.Pt_CONTINUE;
+
+ /*
+ * It is possible that the shell may be
+ * disposed at this point. If this happens
+ * don't send the activate and deactivate
+ * events.
+ */
+ if (!shell.isDisposed ()) {
+ Display display = shell.getDisplay ();
+ Control control = display.getFocusControl ();
+ if (control == null || shell != control.getShell () ) {
+ shell.setActiveControl (null);
+ }
+ }
+
+ /*
+ * Feature in Photon. Cannot return Pt_END
+ * or the text widget will not take focus.
+ */
+ return OS.Pt_CONTINUE;
+}
+
+void realizeWidget() {
+ int parentHandle = parent.handle;
+ if (OS.PtWidgetIsRealized (parentHandle)) {
+ OS.PtRealizeWidget (topHandle ());
+ }
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ if (toolTipHandle != 0) destroyToolTip (toolTipHandle);
+ toolTipHandle = 0;
+ if (menu != null && !menu.isDisposed ()) {
+ menu.dispose ();
+ }
+ menu = null;
+ parent = null;
+ layoutData = null;
+}
+
/**
* Causes the entire bounds of the receiver to be marked
* as needing to be redrawn. The next time a paint request
@@ -1539,11 +1539,11 @@ void releaseWidget () {
*
* @see #update
*/
-public void redraw () {
- checkWidget();
- OS.PtDamageWidget (handle);
-}
-
+public void redraw () {
+ checkWidget();
+ OS.PtDamageWidget (handle);
+}
+
/**
* Causes the rectangular area of the receiver specified by
* the arguments to be marked as needing to be redrawn.
@@ -1567,17 +1567,17 @@ public void redraw () {
*
* @see #update
*/
-public void redraw (int x, int y, int width, int height, boolean allChildren) {
- checkWidget ();
- if (width <= 0 || height <= 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);
- OS.PtDamageExtent (handle, rect);
-}
-
+public void redraw (int x, int y, int width, int height, boolean allChildren) {
+ checkWidget ();
+ if (width <= 0 || height <= 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);
+ OS.PtDamageExtent (handle, rect);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the control is moved or resized.
@@ -1595,14 +1595,14 @@ public void redraw (int x, int y, int width, int height, boolean allChildren) {
* @see ControlListener
* @see #addControlListener
*/
-public void removeControlListener (ControlListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Move, listener);
- eventTable.unhook (SWT.Resize, listener);
-}
-
+public void removeControlListener (ControlListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Move, listener);
+ eventTable.unhook (SWT.Resize, listener);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the control gains or loses focus.
@@ -1620,14 +1620,14 @@ public void removeControlListener (ControlListener listener) {
* @see FocusListener
* @see #addFocusListener
*/
-public void removeFocusListener(FocusListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.FocusIn, listener);
- eventTable.unhook (SWT.FocusOut, listener);
-}
-
+public void removeFocusListener(FocusListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.FocusIn, listener);
+ eventTable.unhook (SWT.FocusOut, listener);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the help events are generated for the control.
@@ -1645,13 +1645,13 @@ public void removeFocusListener(FocusListener listener) {
* @see HelpListener
* @see #addHelpListener
*/
-public void removeHelpListener (HelpListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Help, listener);
-}
-
+public void removeHelpListener (HelpListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Help, listener);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when keys are pressed and released on the system keyboard.
@@ -1669,14 +1669,14 @@ public void removeHelpListener (HelpListener listener) {
* @see KeyListener
* @see #addKeyListener
*/
-public void removeKeyListener(KeyListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.KeyUp, listener);
- eventTable.unhook (SWT.KeyDown, listener);
-}
-
+public void removeKeyListener(KeyListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.KeyUp, listener);
+ eventTable.unhook (SWT.KeyDown, listener);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the mouse passes or hovers over controls.
@@ -1694,15 +1694,15 @@ public void removeKeyListener(KeyListener listener) {
* @see MouseTrackListener
* @see #addMouseTrackListener
*/
-public void removeMouseTrackListener(MouseTrackListener listener) {
- checkWidget();
- 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 removeMouseTrackListener(MouseTrackListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.MouseEnter, listener);
+ eventTable.unhook (SWT.MouseExit, listener);
+ eventTable.unhook (SWT.MouseHover, listener);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when mouse buttons are pressed and released.
@@ -1720,15 +1720,15 @@ public void removeMouseTrackListener(MouseTrackListener listener) {
* @see MouseListener
* @see #addMouseListener
*/
-public void removeMouseListener (MouseListener listener) {
- checkWidget();
- 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 removeMouseListener (MouseListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.MouseDown, listener);
+ eventTable.unhook (SWT.MouseUp, listener);
+ eventTable.unhook (SWT.MouseDoubleClick, listener);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the mouse moves.
@@ -1746,13 +1746,13 @@ public void removeMouseListener (MouseListener listener) {
* @see MouseMoveListener
* @see #addMouseMoveListener
*/
-public void removeMouseMoveListener(MouseMoveListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.MouseMove, listener);
-}
-
+public void removeMouseMoveListener(MouseMoveListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.MouseMove, listener);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver needs to be painted.
@@ -1770,13 +1770,13 @@ public void removeMouseMoveListener(MouseMoveListener listener) {
* @see PaintListener
* @see #addPaintListener
*/
-public void removePaintListener(PaintListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook(SWT.Paint, listener);
-}
-
+public void removePaintListener(PaintListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook(SWT.Paint, listener);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when traversal events occur.
@@ -1794,65 +1794,65 @@ public void removePaintListener(PaintListener listener) {
* @see TraverseListener
* @see #addTraverseListener
*/
-public void removeTraverseListener(TraverseListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Traverse, listener);
-}
-
-int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
- int topHandle = topHandle ();
- PhArea_t area = new PhArea_t ();
- OS.PtWidgetArea (topHandle, area);
- width = Math.max (width, 0);
- height = Math.max (height, 0);
- boolean sameOrigin = x == area.pos_x && y == area.pos_y;
- boolean sameExtent = width == area.size_w && height == area.size_h;
- if (move && resize) {
- if (sameOrigin && sameExtent) return 0;
- area.pos_x = (short) x;
- area.pos_y = (short) y;
- area.size_w = (short) width;
- area.size_h = (short) height;
- int ptr = OS.malloc (PhArea_t.sizeof);
- OS.memmove (ptr, area, PhArea_t.sizeof);
- OS.PtSetResource (topHandle, OS.Pt_ARG_AREA, ptr, 0);
- OS.free (ptr);
- } else {
- if (move) {
- if (sameOrigin) return 0;
- 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);
- OS.PtSetResource (topHandle, OS.Pt_ARG_POS, ptr, 0);
- OS.free (ptr);
- } else if (resize) {
- if (sameExtent) return 0;
- int [] args = {
- OS.Pt_ARG_WIDTH, width, 0,
- OS.Pt_ARG_HEIGHT, height, 0,
- };
- OS.PtSetResources (topHandle, args.length / 3, args);
- }
- }
- if (!OS.PtWidgetIsRealized (topHandle)) {
- OS.PtExtentWidgetFamily (topHandle);
- }
- int result = 0;
- if (move && !sameOrigin) {
- sendEvent (SWT.Move);
- result |= MOVED;
- }
- if (resize && !sameExtent) {
- sendEvent (SWT.Resize);
- result |= RESIZED;
- }
- return result;
-}
-
+public void removeTraverseListener(TraverseListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Traverse, listener);
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
+ int topHandle = topHandle ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (topHandle, area);
+ width = Math.max (width, 0);
+ height = Math.max (height, 0);
+ boolean sameOrigin = x == area.pos_x && y == area.pos_y;
+ boolean sameExtent = width == area.size_w && height == area.size_h;
+ if (move && resize) {
+ if (sameOrigin && sameExtent) return 0;
+ area.pos_x = (short) x;
+ area.pos_y = (short) y;
+ area.size_w = (short) width;
+ area.size_h = (short) height;
+ int ptr = OS.malloc (PhArea_t.sizeof);
+ OS.memmove (ptr, area, PhArea_t.sizeof);
+ OS.PtSetResource (topHandle, OS.Pt_ARG_AREA, ptr, 0);
+ OS.free (ptr);
+ } else {
+ if (move) {
+ if (sameOrigin) return 0;
+ 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);
+ OS.PtSetResource (topHandle, OS.Pt_ARG_POS, ptr, 0);
+ OS.free (ptr);
+ } else if (resize) {
+ if (sameExtent) return 0;
+ int [] args = {
+ OS.Pt_ARG_WIDTH, width, 0,
+ OS.Pt_ARG_HEIGHT, height, 0,
+ };
+ OS.PtSetResources (topHandle, args.length / 3, args);
+ }
+ }
+ if (!OS.PtWidgetIsRealized (topHandle)) {
+ OS.PtExtentWidgetFamily (topHandle);
+ }
+ int result = 0;
+ if (move && !sameOrigin) {
+ sendEvent (SWT.Move);
+ result |= MOVED;
+ }
+ if (resize && !sameExtent) {
+ sendEvent (SWT.Resize);
+ result |= RESIZED;
+ }
+ return result;
+}
+
/**
* Sets the receiver's size and location to the rectangular
* area specified by the arguments. The <code>x</code> and
@@ -1874,11 +1874,11 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setBounds (int x, int y, int width, int height) {
- checkWidget();
- setBounds (x, y, width, height, true, true, true);
-}
-
+public void setBounds (int x, int y, int width, int height) {
+ checkWidget();
+ setBounds (x, y, width, height, true, true, true);
+}
+
/**
* Sets the receiver's size and location to the rectangular
* area specified by the argument. The <code>x</code> and
@@ -1897,11 +1897,11 @@ public void setBounds (int x, int y, int width, int height) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setBounds (Rectangle rect) {
- if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
- setBounds (rect.x, rect.y, rect.width, rect.height);
-}
-
+public void setBounds (Rectangle rect) {
+ if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setBounds (rect.x, rect.y, rect.width, rect.height);
+}
+
/**
* If the argument is <code>true</code>, causes the receiver to have
* all mouse events delivered to it until the method is called with
@@ -1914,10 +1914,10 @@ public void setBounds (Rectangle rect) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setCapture (boolean capture) {
- checkWidget();
-}
-
+public void setCapture (boolean capture) {
+ checkWidget();
+}
+
/**
* Sets the receiver's cursor to the cursor specified by the
* argument, or to the default cursor for that kind of control
@@ -1937,33 +1937,33 @@ public void setCapture (boolean capture) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setCursor (Cursor cursor) {
- checkWidget();
- int type = OS.Ph_CURSOR_INHERIT;
- int bitmap = 0;
- if (cursor != null) {
- if (cursor.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- type = cursor.type;
- bitmap = cursor.bitmap;
- }
- int [] args = new int []{
- OS.Pt_ARG_CURSOR_TYPE, type, 0,
- OS.Pt_ARG_BITMAP_CURSOR, bitmap, 0,
- };
- OS.PtSetResources (handle, args.length / 3, args);
-
- /*
- * Bug in Photon. For some reason, the widget cursor will
- * not change, when the new cursor is a bitmap cursor, if
- * the flag Ph_CURSOR_NO_INHERIT is reset. The fix is to reset
- * this flag after changing the cursor type to Ph_CURSOR_BITMAP.
- */
- if (type == OS.Ph_CURSOR_BITMAP) {
- type &= ~OS.Ph_CURSOR_NO_INHERIT;
- OS.PtSetResource (handle, OS.Pt_ARG_CURSOR_TYPE, type, 0);
- }
-}
-
+public void setCursor (Cursor cursor) {
+ checkWidget();
+ int type = OS.Ph_CURSOR_INHERIT;
+ int bitmap = 0;
+ if (cursor != null) {
+ if (cursor.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ type = cursor.type;
+ bitmap = cursor.bitmap;
+ }
+ int [] args = new int []{
+ OS.Pt_ARG_CURSOR_TYPE, type, 0,
+ OS.Pt_ARG_BITMAP_CURSOR, bitmap, 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+
+ /*
+ * Bug in Photon. For some reason, the widget cursor will
+ * not change, when the new cursor is a bitmap cursor, if
+ * the flag Ph_CURSOR_NO_INHERIT is reset. The fix is to reset
+ * this flag after changing the cursor type to Ph_CURSOR_BITMAP.
+ */
+ if (type == OS.Ph_CURSOR_BITMAP) {
+ type &= ~OS.Ph_CURSOR_NO_INHERIT;
+ OS.PtSetResource (handle, OS.Pt_ARG_CURSOR_TYPE, type, 0);
+ }
+}
+
/**
* Enables the receiver if the argument is <code>true</code>,
* and disables it otherwise. A disabled control is typically
@@ -1977,13 +1977,13 @@ public void setCursor (Cursor cursor) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setEnabled (boolean enabled) {
- checkWidget ();
- int topHandle = topHandle ();
- int flags = enabled ? 0 : OS.Pt_BLOCKED | OS.Pt_GHOST;
- OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
-}
-
+public void setEnabled (boolean enabled) {
+ checkWidget ();
+ int topHandle = topHandle ();
+ int flags = enabled ? 0 : OS.Pt_BLOCKED | OS.Pt_GHOST;
+ OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
+}
+
/**
* Causes the receiver to have the <em>keyboard focus</em>,
* such that all keyboard events will be delivered to it.
@@ -1997,11 +1997,11 @@ public void setEnabled (boolean enabled) {
*
* @see #forceFocus
*/
-public boolean setFocus () {
- checkWidget();
- return forceFocus ();
-}
-
+public boolean setFocus () {
+ checkWidget();
+ return forceFocus ();
+}
+
/**
* Sets the receiver's background color to the color specified
* by the argument, or to the default system color for the control
@@ -2017,27 +2017,27 @@ public boolean setFocus () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setBackground (Color color) {
- checkWidget();
- int pixel;
- if (color == null) {
- pixel = defaultBackground ();
- } else {
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- pixel = color.handle;
- }
- setBackgroundPixel (pixel);
-}
-
-void setBackgroundPixel (int pixel) {
- OS.PtSetResource (handle, OS.Pt_ARG_FILL_COLOR, pixel, 0);
-}
-
-void setDefaultFont () {
- Display display = getDisplay ();
- if (display.defaultFont != null) setFont (defaultFont ());
-}
-
+public void setBackground (Color color) {
+ checkWidget();
+ int pixel;
+ if (color == null) {
+ pixel = defaultBackground ();
+ } else {
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ pixel = color.handle;
+ }
+ setBackgroundPixel (pixel);
+}
+
+void setBackgroundPixel (int pixel) {
+ OS.PtSetResource (handle, OS.Pt_ARG_FILL_COLOR, pixel, 0);
+}
+
+void setDefaultFont () {
+ Display display = getDisplay ();
+ if (display.defaultFont != null) setFont (defaultFont ());
+}
+
/**
* Sets the font that the receiver will use to paint textual information
* to the font specified by the argument, or to the default font for that
@@ -2053,35 +2053,35 @@ void setDefaultFont () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setFont (Font font) {
- checkWidget();
- byte[] buffer;
- if (font != null) {
- if (font.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- buffer = font.handle;
- } else {
- buffer = defaultFont ();
- }
- setFont (buffer);
-}
-
-void setFont (byte [] font) {
- int ptr = OS.malloc (font.length);
- OS.memmove (ptr, font, font.length);
- setFont (ptr);
- OS.free (ptr);
-}
-
-void setFont (int font) {
- int [] args = {
- OS.Pt_ARG_TEXT_FONT, font, 0,
- OS.Pt_ARG_LIST_FONT, font, 0,
- OS.Pt_ARG_TITLE_FONT, font, 0,
- OS.Pt_ARG_GAUGE_FONT, font, 0,
- };
- OS.PtSetResources (handle, args.length / 3, args);
-}
-
+public void setFont (Font font) {
+ checkWidget();
+ byte[] buffer;
+ if (font != null) {
+ if (font.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ buffer = font.handle;
+ } else {
+ buffer = defaultFont ();
+ }
+ setFont (buffer);
+}
+
+void setFont (byte [] font) {
+ int ptr = OS.malloc (font.length);
+ OS.memmove (ptr, font, font.length);
+ setFont (ptr);
+ OS.free (ptr);
+}
+
+void setFont (int font) {
+ int [] args = {
+ OS.Pt_ARG_TEXT_FONT, font, 0,
+ OS.Pt_ARG_LIST_FONT, font, 0,
+ OS.Pt_ARG_TITLE_FONT, font, 0,
+ OS.Pt_ARG_GAUGE_FONT, font, 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
/**
* Sets the receiver's foreground color to the color specified
* by the argument, or to the default system color for the control
@@ -2097,22 +2097,22 @@ void setFont (int font) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setForeground (Color color) {
- checkWidget();
- int pixel;
- if (color == null) {
- pixel = defaultForeground ();
- } else {
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- pixel = color.handle;
- }
- setForegroundPixel (pixel);
-}
-
-void setForegroundPixel (int pixel) {
- OS.PtSetResource (handle, OS.Pt_ARG_COLOR, pixel, 0);
-}
-
+public void setForeground (Color color) {
+ checkWidget();
+ int pixel;
+ if (color == null) {
+ pixel = defaultForeground ();
+ } else {
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ pixel = color.handle;
+ }
+ setForegroundPixel (pixel);
+}
+
+void setForegroundPixel (int pixel) {
+ OS.PtSetResource (handle, OS.Pt_ARG_COLOR, pixel, 0);
+}
+
/**
* Sets the layout data associated with the receiver to the argument.
*
@@ -2123,11 +2123,11 @@ void setForegroundPixel (int pixel) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setLayoutData (Object layoutData) {
- checkWidget();
- this.layoutData = layoutData;
-}
-
+public void setLayoutData (Object layoutData) {
+ checkWidget();
+ this.layoutData = layoutData;
+}
+
/**
* Sets the receiver's location to the point specified by
* the arguments which are relative to the receiver's
@@ -2141,11 +2141,11 @@ public void setLayoutData (Object layoutData) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setLocation (int x, int y) {
- checkWidget();
- setBounds (x, y, 0, 0, true, false, true);
-}
-
+public void setLocation (int x, int y) {
+ checkWidget();
+ setBounds (x, y, 0, 0, true, false, true);
+}
+
/**
* Sets the receiver's location to the point specified by
* the argument which is relative to the receiver's
@@ -2158,12 +2158,12 @@ public void setLocation (int x, int y) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setLocation (Point location) {
- checkWidget();
- if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
- setLocation (location.x, location.y);
-}
-
+public void setLocation (Point location) {
+ checkWidget();
+ if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setLocation (location.x, location.y);
+}
+
/**
* Sets the receiver's pop up menu to the argument.
* All controls may optionally have a pop up
@@ -2184,17 +2184,17 @@ public void setLocation (Point location) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMenu (Menu menu) {
- checkWidget();
- int flags = 0;
- if (menu != null) {
- if (menu.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- flags = OS.Pt_MENUABLE;
- }
- OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, flags, OS.Pt_ALL_BUTTONS | OS.Pt_MENUABLE);
- this.menu = menu;
-}
-
+public void setMenu (Menu menu) {
+ checkWidget();
+ int flags = 0;
+ if (menu != null) {
+ if (menu.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ flags = OS.Pt_MENUABLE;
+ }
+ OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, flags, OS.Pt_ALL_BUTTONS | OS.Pt_MENUABLE);
+ this.menu = menu;
+}
+
/**
* Changes the parent of the widget to be the one provided if
* the underlying operating system supports this feature.
@@ -2211,12 +2211,12 @@ public void setMenu (Menu menu) {
* <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
* </ul>
*/
-public boolean setParent (Composite parent) {
- checkWidget();
- if (parent.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- return false;
-}
-
+public boolean setParent (Composite parent) {
+ checkWidget();
+ if (parent.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ return false;
+}
+
/**
* Sets the receiver's size to the point specified by the argument.
* <p>
@@ -2236,25 +2236,25 @@ public boolean setParent (Composite parent) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSize (Point size) {
- checkWidget();
- if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
- setSize (size.x, size.y);
-}
-
-boolean setTabGroupFocus () {
- return setTabItemFocus ();
-}
-
-boolean setTabItemFocus () {
- if (!isShowing ()) return false;
- return setFocus ();
-}
-
-boolean setRadioSelection (boolean value) {
- return false;
-}
-
+public void setSize (Point size) {
+ checkWidget();
+ if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setSize (size.x, size.y);
+}
+
+boolean setTabGroupFocus () {
+ return setTabItemFocus ();
+}
+
+boolean setTabItemFocus () {
+ if (!isShowing ()) return false;
+ return setFocus ();
+}
+
+boolean setRadioSelection (boolean value) {
+ return false;
+}
+
/**
* If the argument is <code>false</code>, causes subsequent drawing
* operations in the receiver to be ignored. No drawing of any kind
@@ -2277,14 +2277,14 @@ boolean setRadioSelection (boolean value) {
* @see #redraw
* @see #update
*/
-public void setRedraw (boolean redraw) {
- checkWidget();
- if (redraw) {
- OS.PtContainerRelease (handle);
- } else {
- OS.PtContainerHold (handle);
- }
-}
+public void setRedraw (boolean redraw) {
+ checkWidget();
+ if (redraw) {
+ OS.PtContainerRelease (handle);
+ } else {
+ OS.PtContainerHold (handle);
+ }
+}
/**
* Sets the receiver's size to the point specified by the arguments.
* <p>
@@ -2301,11 +2301,11 @@ public void setRedraw (boolean redraw) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSize (int width, int height) {
- checkWidget();
- setBounds (0, 0, width, height, false, true, true);
-}
-
+public void setSize (int width, int height) {
+ checkWidget();
+ setBounds (0, 0, width, height, false, true, true);
+}
+
/**
* Marks the receiver as visible if the argument is <code>true</code>,
* and marks it invisible otherwise.
@@ -2322,22 +2322,22 @@ public void setSize (int width, int height) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setVisible (boolean visible) {
- checkWidget ();
- int topHandle = topHandle ();
- int flags = visible ? 0 : OS.Pt_DELAY_REALIZE;
- OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_DELAY_REALIZE);
- if (parent != null && !OS.PtWidgetIsRealized (parent.handle)) return;
- if (visible == OS.PtWidgetIsRealized (topHandle)) return;
- if (visible) {
- sendEvent (SWT.Show);
- OS.PtRealizeWidget (topHandle);
- } else {
- OS.PtUnrealizeWidget (topHandle);
- sendEvent(SWT.Hide);
- }
-}
-
+public void setVisible (boolean visible) {
+ checkWidget ();
+ int topHandle = topHandle ();
+ int flags = visible ? 0 : OS.Pt_DELAY_REALIZE;
+ OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_DELAY_REALIZE);
+ if (parent != null && !OS.PtWidgetIsRealized (parent.handle)) return;
+ if (visible == OS.PtWidgetIsRealized (topHandle)) return;
+ if (visible) {
+ sendEvent (SWT.Show);
+ OS.PtRealizeWidget (topHandle);
+ } else {
+ OS.PtUnrealizeWidget (topHandle);
+ sendEvent(SWT.Hide);
+ }
+}
+
/**
* Sets the receiver's tool tip text to the argument, which
* may be null indicating that no tool tip text should be shown.
@@ -2349,38 +2349,38 @@ public void setVisible (boolean visible) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setToolTipText (String string) {
- checkWidget();
- toolTipText = string;
-}
-
-void setZOrder() {
- if (parent != null) parent.moveToBack (topHandle ());
-}
-
-void sort (int [] items) {
- /* Shell Sort from K&R, pg 108 */
- int length = items.length;
- for (int gap=length/2; gap>0; gap/=2) {
- for (int i=gap; i<length; i++) {
- for (int j=i-gap; j>=0; j-=gap) {
- if (items [j] <= items [j + gap]) {
- int swap = items [j];
- items [j] = items [j + gap];
- items [j + gap] = swap;
- }
- }
- }
- }
-}
-
-public Point toControl (int x, int y) {
- checkWidget();
- short [] position_x = new short [1], position_y = new short [1];
- OS.PtGetAbsPosition (handle, position_x, position_y);
- return new Point (x - position_x [0], y - position_y [0]);
-}
-
+public void setToolTipText (String string) {
+ checkWidget();
+ toolTipText = string;
+}
+
+void setZOrder() {
+ if (parent != null) parent.moveToBack (topHandle ());
+}
+
+void sort (int [] items) {
+ /* Shell Sort from K&R, pg 108 */
+ int length = items.length;
+ for (int gap=length/2; gap>0; gap/=2) {
+ for (int i=gap; i<length; i++) {
+ for (int j=i-gap; j>=0; j-=gap) {
+ if (items [j] <= items [j + gap]) {
+ int swap = items [j];
+ items [j] = items [j + gap];
+ items [j + gap] = swap;
+ }
+ }
+ }
+ }
+}
+
+public Point toControl (int x, int y) {
+ checkWidget();
+ short [] position_x = new short [1], position_y = new short [1];
+ OS.PtGetAbsPosition (handle, position_x, position_y);
+ return new Point (x - position_x [0], y - position_y [0]);
+}
+
/**
* Returns a point which is the result of converting the
* argument, which is specified in display relative coordinates,
@@ -2396,19 +2396,19 @@ public Point toControl (int x, int y) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Point toControl (Point point) {
- checkWidget();
- if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- return toControl (point.x, point.y);
-}
-
-public Point toDisplay (int x, int y) {
- checkWidget();
- short [] position_x = new short [1], position_y = new short [1];
- OS.PtGetAbsPosition (handle, position_x, position_y);
- return new Point (x + position_x [0], y + position_y [0]);
-}
-
+public Point toControl (Point point) {
+ checkWidget();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ return toControl (point.x, point.y);
+}
+
+public Point toDisplay (int x, int y) {
+ checkWidget();
+ short [] position_x = new short [1], position_y = new short [1];
+ OS.PtGetAbsPosition (handle, position_x, position_y);
+ return new Point (x + position_x [0], y + position_y [0]);
+}
+
/**
* Returns a point which is the result of converting the
* argument, which is specified in coordinates relative to
@@ -2424,103 +2424,103 @@ public Point toDisplay (int x, int y) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Point toDisplay (Point point) {
- checkWidget();
- if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- return toDisplay (point.x, point.y);
-}
-
-boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
- int detail = SWT.TRAVERSE_NONE;
- int code = traversalCode (key_sym, phEvent);
- boolean all = false;
- switch (key_sym) {
- case OS.Pk_Escape: {
- all = true;
- detail = SWT.TRAVERSE_ESCAPE;
- break;
- }
- case OS.Pk_Return: {
- all = true;
- detail = SWT.TRAVERSE_RETURN;
- break;
- }
- case OS.Pk_Tab:
- case OS.Pk_KP_Tab: {
- boolean next = (phEvent.key_mods & OS.Pk_KM_Shift) == 0;
- detail = next ? SWT.TRAVERSE_TAB_NEXT : SWT.TRAVERSE_TAB_PREVIOUS;
- break;
- }
- case OS.Pk_Up:
- case OS.Pk_Left: {
- detail = SWT.TRAVERSE_ARROW_PREVIOUS;
- break;
- }
- case OS.Pk_Down:
- case OS.Pk_Right: {
- detail = SWT.TRAVERSE_ARROW_NEXT;
- break;
- }
- case OS.Pk_Pg_Down:
- case OS.Pk_Pg_Up: {
- all = true;
- if ((phEvent.key_mods & OS.Pk_KM_Ctrl) == 0) return false;
- detail = key_sym == OS.Pk_Pg_Down ? SWT.TRAVERSE_PAGE_NEXT : SWT.TRAVERSE_PAGE_PREVIOUS;
- break;
- }
- default:
- return false;
- }
- Event event = new Event ();
- event.doit = (code & detail) != 0 || (phEvent.key_mods & OS.Pk_KM_Ctrl) != 0;
- event.detail = detail;
- setKeyState (event, phEvent);
- Shell shell = getShell ();
- Control control = this;
- do {
- if (control.traverse (event)) return true;
- if (!event.doit && control.hooks (SWT.Traverse)) {
- return false;
- }
- if (control == shell) return false;
- control = control.parent;
- } while (all && control != null);
- return false;
-}
-
-int traversalCode (int key_sym, PhKeyEvent_t ke) {
-// if ((OS.PtWidgetFlags (handle) & OS.Pt_GETS_FOCUS) == 0) return 0;
- int code = SWT.TRAVERSE_RETURN | SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS;
- Shell shell = getShell ();
- if (shell.parent != null) code |= SWT.TRAVERSE_ESCAPE;
- return code;
-}
-
-boolean traverse (Event event) {
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in the traverse
- * event. If this happens, return true to stop further
- * event processing.
- */
- sendEvent (SWT.Traverse, event);
- if (isDisposed ()) return false;
- if (!event.doit) return false;
- switch (event.detail) {
- case SWT.TRAVERSE_NONE: return true;
- case SWT.TRAVERSE_ESCAPE: return traverseEscape ();
- case SWT.TRAVERSE_RETURN: return traverseReturn ();
- case SWT.TRAVERSE_TAB_NEXT: return traverseGroup (true);
- case SWT.TRAVERSE_TAB_PREVIOUS: return traverseGroup (false);
- case SWT.TRAVERSE_ARROW_NEXT: return traverseItem (true);
- case SWT.TRAVERSE_ARROW_PREVIOUS: return traverseItem (false);
- case SWT.TRAVERSE_MNEMONIC: return traverseMnemonic (event.character);
- case SWT.TRAVERSE_PAGE_NEXT: return traversePage (true);
- case SWT.TRAVERSE_PAGE_PREVIOUS: return traversePage (false);
- }
- return false;
-}
-
+public Point toDisplay (Point point) {
+ checkWidget();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ return toDisplay (point.x, point.y);
+}
+
+boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
+ int detail = SWT.TRAVERSE_NONE;
+ int code = traversalCode (key_sym, phEvent);
+ boolean all = false;
+ switch (key_sym) {
+ case OS.Pk_Escape: {
+ all = true;
+ detail = SWT.TRAVERSE_ESCAPE;
+ break;
+ }
+ case OS.Pk_Return: {
+ all = true;
+ detail = SWT.TRAVERSE_RETURN;
+ break;
+ }
+ case OS.Pk_Tab:
+ case OS.Pk_KP_Tab: {
+ boolean next = (phEvent.key_mods & OS.Pk_KM_Shift) == 0;
+ detail = next ? SWT.TRAVERSE_TAB_NEXT : SWT.TRAVERSE_TAB_PREVIOUS;
+ break;
+ }
+ case OS.Pk_Up:
+ case OS.Pk_Left: {
+ detail = SWT.TRAVERSE_ARROW_PREVIOUS;
+ break;
+ }
+ case OS.Pk_Down:
+ case OS.Pk_Right: {
+ detail = SWT.TRAVERSE_ARROW_NEXT;
+ break;
+ }
+ case OS.Pk_Pg_Down:
+ case OS.Pk_Pg_Up: {
+ all = true;
+ if ((phEvent.key_mods & OS.Pk_KM_Ctrl) == 0) return false;
+ detail = key_sym == OS.Pk_Pg_Down ? SWT.TRAVERSE_PAGE_NEXT : SWT.TRAVERSE_PAGE_PREVIOUS;
+ break;
+ }
+ default:
+ return false;
+ }
+ Event event = new Event ();
+ event.doit = (code & detail) != 0 || (phEvent.key_mods & OS.Pk_KM_Ctrl) != 0;
+ event.detail = detail;
+ setKeyState (event, phEvent);
+ Shell shell = getShell ();
+ Control control = this;
+ do {
+ if (control.traverse (event)) return true;
+ if (!event.doit && control.hooks (SWT.Traverse)) {
+ return false;
+ }
+ if (control == shell) return false;
+ control = control.parent;
+ } while (all && control != null);
+ return false;
+}
+
+int traversalCode (int key_sym, PhKeyEvent_t ke) {
+// if ((OS.PtWidgetFlags (handle) & OS.Pt_GETS_FOCUS) == 0) return 0;
+ int code = SWT.TRAVERSE_RETURN | SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS;
+ Shell shell = getShell ();
+ if (shell.parent != null) code |= SWT.TRAVERSE_ESCAPE;
+ return code;
+}
+
+boolean traverse (Event event) {
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the traverse
+ * event. If this happens, return true to stop further
+ * event processing.
+ */
+ sendEvent (SWT.Traverse, event);
+ if (isDisposed ()) return false;
+ if (!event.doit) return false;
+ switch (event.detail) {
+ case SWT.TRAVERSE_NONE: return true;
+ case SWT.TRAVERSE_ESCAPE: return traverseEscape ();
+ case SWT.TRAVERSE_RETURN: return traverseReturn ();
+ case SWT.TRAVERSE_TAB_NEXT: return traverseGroup (true);
+ case SWT.TRAVERSE_TAB_PREVIOUS: return traverseGroup (false);
+ case SWT.TRAVERSE_ARROW_NEXT: return traverseItem (true);
+ case SWT.TRAVERSE_ARROW_PREVIOUS: return traverseItem (false);
+ case SWT.TRAVERSE_MNEMONIC: return traverseMnemonic (event.character);
+ case SWT.TRAVERSE_PAGE_NEXT: return traversePage (true);
+ case SWT.TRAVERSE_PAGE_PREVIOUS: return traversePage (false);
+ }
+ return false;
+}
+
/**
* Based on the argument, perform one of the expected platform
* traversal action. The argument should be one of the constants:
@@ -2536,84 +2536,84 @@ boolean traverse (Event event) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean traverse (int traversal) {
- checkWidget ();
- if (!isFocusControl () && !setFocus ()) return false;
- Event event = new Event ();
- event.doit = true;
- event.detail = traversal;
- return traverse (event);
-}
-
-boolean traverseEscape () {
- return false;
-}
-
-boolean traverseGroup (boolean next) {
- Control root = computeTabRoot ();
- Control group = computeTabGroup ();
- Control [] list = root.computeTabList ();
- int length = list.length;
- int index = 0;
- while (index < length) {
- if (list [index] == group) break;
- index++;
- }
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in focus in
- * or out events. Ensure that a disposed widget is
- * not accessed.
- */
- if (index == length) return false;
- int start = index, offset = (next) ? 1 : -1;
- while ((index = ((index + offset + length) % length)) != start) {
- Control control = list [index];
- if (!control.isDisposed () && control.setTabGroupFocus ()) {
- if (!isDisposed () && !isFocusControl ()) return true;
- }
- }
- if (group.isDisposed ()) return false;
- return group.setTabGroupFocus ();
-}
-
-boolean traverseItem (boolean next) {
- Control [] children = parent._getChildren ();
- int length = children.length;
- int index = 0;
- while (index < length) {
- if (children [index] == this) break;
- index++;
- }
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in focus in
- * or out events. Ensure that a disposed widget is
- * not accessed.
- */
- int start = index, offset = (next) ? 1 : -1;
- while ((index = (index + offset + length) % length) != start) {
- Control child = children [index];
- if (!child.isDisposed () && child.isTabItem ()) {
- if (child.setTabItemFocus ()) return true;
- }
- }
- return false;
-}
-
-boolean traversePage (boolean next) {
- return false;
-}
-
-boolean traverseMnemonic (char key) {
-// return mnemonicHit (key);
- return false;
-}
-
-boolean traverseReturn () {
- return false;
-}
-
+public boolean traverse (int traversal) {
+ checkWidget ();
+ if (!isFocusControl () && !setFocus ()) return false;
+ Event event = new Event ();
+ event.doit = true;
+ event.detail = traversal;
+ return traverse (event);
+}
+
+boolean traverseEscape () {
+ return false;
+}
+
+boolean traverseGroup (boolean next) {
+ Control root = computeTabRoot ();
+ Control group = computeTabGroup ();
+ Control [] list = root.computeTabList ();
+ int length = list.length;
+ int index = 0;
+ while (index < length) {
+ if (list [index] == group) break;
+ index++;
+ }
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in focus in
+ * or out events. Ensure that a disposed widget is
+ * not accessed.
+ */
+ if (index == length) return false;
+ int start = index, offset = (next) ? 1 : -1;
+ while ((index = ((index + offset + length) % length)) != start) {
+ Control control = list [index];
+ if (!control.isDisposed () && control.setTabGroupFocus ()) {
+ if (!isDisposed () && !isFocusControl ()) return true;
+ }
+ }
+ if (group.isDisposed ()) return false;
+ return group.setTabGroupFocus ();
+}
+
+boolean traverseItem (boolean next) {
+ Control [] children = parent._getChildren ();
+ int length = children.length;
+ int index = 0;
+ while (index < length) {
+ if (children [index] == this) break;
+ index++;
+ }
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in focus in
+ * or out events. Ensure that a disposed widget is
+ * not accessed.
+ */
+ int start = index, offset = (next) ? 1 : -1;
+ while ((index = (index + offset + length) % length) != start) {
+ Control child = children [index];
+ if (!child.isDisposed () && child.isTabItem ()) {
+ if (child.setTabItemFocus ()) return true;
+ }
+ }
+ return false;
+}
+
+boolean traversePage (boolean next) {
+ return false;
+}
+
+boolean traverseMnemonic (char key) {
+// return mnemonicHit (key);
+ return false;
+}
+
+boolean traverseReturn () {
+ return false;
+}
+
/**
* Forces all outstanding paint requests for the widget tree
* to be processed before this method returns.
@@ -2625,13 +2625,13 @@ boolean traverseReturn () {
*
* @see #redraw
*/
-public void update () {
- checkWidget();
- OS.PtFlush ();
-}
-
-int widgetClass () {
- return 0;
-}
-
-}
+public void update () {
+ checkWidget();
+ OS.PtFlush ();
+}
+
+int widgetClass () {
+ return 0;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java
index 2f20d0b075..ad0f29dac4 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class provide the appearance and
* behavior of <code>Shells</code>, but are not top
@@ -83,17 +83,17 @@ import org.eclipse.swt.graphics.*;
* @see Shell
* @see SWT
*/
-public class Decorations extends Canvas {
- Menu menuBar;
- Menu [] menus;
- String text = "";
- Image image;
- Button defaultButton, saveDefault;
-
-Decorations () {
- /* Do nothing */
-}
-
+public class Decorations extends Canvas {
+ Menu menuBar;
+ Menu [] menus;
+ String text = "";
+ Image image;
+ Button defaultButton, saveDefault;
+
+Decorations () {
+ /* Do nothing */
+}
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -132,46 +132,46 @@ Decorations () {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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);
-}
-
-Control computeTabGroup () {
- return this;
-}
-
-Control computeTabRoot () {
- return this;
-}
-
+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);
+}
+
+Control computeTabGroup () {
+ return this;
+}
+
+Control computeTabRoot () {
+ return this;
+}
+
/**
* Returns the receiver's default button if one had
* previously been set, otherwise returns null.
@@ -185,11 +185,11 @@ Control computeTabRoot () {
*
* @see #setDefaultButton
*/
-public Button getDefaultButton () {
- checkWidget();
- return defaultButton;
-}
-
+public Button getDefaultButton () {
+ checkWidget();
+ return defaultButton;
+}
+
/**
* Returns the receiver's image if it had previously been
* set using <code>setImage()</code>. The image is typically
@@ -211,11 +211,11 @@ public Button getDefaultButton () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Image getImage () {
- checkWidget();
- return image;
-}
-
+public Image getImage () {
+ checkWidget();
+ return image;
+}
+
/**
* Returns <code>true</code> if the receiver is currently
* maximized, and false otherwise.
@@ -230,11 +230,11 @@ public Image getImage () {
*
* @see #setMaximized
*/
-public boolean getMaximized () {
- checkWidget();
- return false;
-}
-
+public boolean getMaximized () {
+ checkWidget();
+ return false;
+}
+
/**
* Returns <code>true</code> if the receiver is currently
* minimized, and false otherwise.
@@ -249,11 +249,11 @@ public boolean getMaximized () {
*
* @see #setMinimized
*/
-public boolean getMinimized () {
- checkWidget();
- return false;
-}
-
+public boolean getMinimized () {
+ checkWidget();
+ return false;
+}
+
/**
* Returns the receiver's menu bar if one had previously
* been set, otherwise returns null.
@@ -265,15 +265,15 @@ public boolean getMinimized () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Menu getMenuBar () {
- checkWidget();
- return menuBar;
-}
-
-String getNameText () {
- return getText ();
-}
-
+public Menu getMenuBar () {
+ checkWidget();
+ return menuBar;
+}
+
+String getNameText () {
+ return getText ();
+}
+
/**
* Returns the receiver's text, which is the string that the
* window manager will typically display as the receiver's
@@ -287,76 +287,76 @@ String getNameText () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public String getText () {
- checkWidget();
- return text;
-}
-
-boolean hasBorder () {
- return false;
-}
-
-boolean isTabGroup () {
- return true;
-}
-
-boolean isTabItem () {
- 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.releaseResources ();
- }
- }
- menuBar = null;
- menus = null;
- image = null;
- super.releaseWidget ();
- defaultButton = saveDefault = null;
- text = null;
-}
-
-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) {
- int menuHeight = 0;
- if (menuBar != null) {
- PhDim_t dim = new PhDim_t ();
- int menuHandle = menuBar.handle;
- if (!OS.PtWidgetIsRealized (menuHandle)) {
- OS.PtExtentWidgetFamily (menuHandle);
- }
- OS.PtWidgetPreferredSize (menuHandle, dim);
- menuHeight = dim.h;
- OS.PtSetResource (menuHandle, OS.Pt_ARG_HEIGHT, menuHeight, 0);
- height = height - menuHeight;
- }
- PhArea_t area = new PhArea_t ();
- area.pos_y = (short) menuHeight;
- area.size_w = (short) Math.max (width, 0);
- area.size_h = (short) Math.max (height ,0);
- int ptr = OS.malloc (PhArea_t.sizeof);
- OS.memmove (ptr, area, PhArea_t.sizeof);
- OS.PtSetResource (scrolledHandle, OS.Pt_ARG_AREA, ptr, 0);
- OS.free (ptr);
- resizeClientArea (width, height);
-}
-
+public String getText () {
+ checkWidget();
+ return text;
+}
+
+boolean hasBorder () {
+ return false;
+}
+
+boolean isTabGroup () {
+ return true;
+}
+
+boolean isTabItem () {
+ 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.releaseResources ();
+ }
+ }
+ menuBar = null;
+ menus = null;
+ image = null;
+ super.releaseWidget ();
+ defaultButton = saveDefault = null;
+ text = null;
+}
+
+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) {
+ int menuHeight = 0;
+ if (menuBar != null) {
+ PhDim_t dim = new PhDim_t ();
+ int menuHandle = menuBar.handle;
+ if (!OS.PtWidgetIsRealized (menuHandle)) {
+ OS.PtExtentWidgetFamily (menuHandle);
+ }
+ OS.PtWidgetPreferredSize (menuHandle, dim);
+ menuHeight = dim.h;
+ OS.PtSetResource (menuHandle, OS.Pt_ARG_HEIGHT, menuHeight, 0);
+ height = height - menuHeight;
+ }
+ PhArea_t area = new PhArea_t ();
+ area.pos_y = (short) menuHeight;
+ area.size_w = (short) Math.max (width, 0);
+ area.size_h = (short) Math.max (height ,0);
+ int ptr = OS.malloc (PhArea_t.sizeof);
+ OS.memmove (ptr, area, PhArea_t.sizeof);
+ OS.PtSetResource (scrolledHandle, OS.Pt_ARG_AREA, ptr, 0);
+ OS.free (ptr);
+ resizeClientArea (width, height);
+}
+
/**
* If the argument is not null, sets the receiver's default
* button to the argument, and if the argument is null, sets
@@ -377,32 +377,32 @@ void resizeBounds (int width, int height) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setDefaultButton (Button button) {
- checkWidget();
- setDefaultButton (button, true);
-}
-void setDefaultButton (Button button, boolean save) {
- if (button == null) {
- if (defaultButton == saveDefault) {
- if (save) saveDefault = null;
- return;
- }
- } else {
- if (button.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if ((button.style & SWT.PUSH) == 0) return;
- if (button == defaultButton) return;
- }
- if (defaultButton != null) {
- if (!defaultButton.isDisposed ()) defaultButton.setDefault (false);
- }
- if ((defaultButton = button) == null) defaultButton = saveDefault;
- if (defaultButton != null) {
- if (!defaultButton.isDisposed ()) defaultButton.setDefault (true);
- }
- if (save) saveDefault = defaultButton;
- if (saveDefault != null && saveDefault.isDisposed ()) saveDefault = null;
-}
-
+public void setDefaultButton (Button button) {
+ checkWidget();
+ setDefaultButton (button, true);
+}
+void setDefaultButton (Button button, boolean save) {
+ if (button == null) {
+ if (defaultButton == saveDefault) {
+ if (save) saveDefault = null;
+ return;
+ }
+ } else {
+ if (button.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if ((button.style & SWT.PUSH) == 0) return;
+ if (button == defaultButton) return;
+ }
+ if (defaultButton != null) {
+ if (!defaultButton.isDisposed ()) defaultButton.setDefault (false);
+ }
+ if ((defaultButton = button) == null) defaultButton = saveDefault;
+ if (defaultButton != null) {
+ if (!defaultButton.isDisposed ()) defaultButton.setDefault (true);
+ }
+ if (save) saveDefault = defaultButton;
+ if (saveDefault != null && saveDefault.isDisposed ()) saveDefault = null;
+}
+
/**
* Sets the receiver's image to the argument, which may
* be null. The image is typically displayed by the window
@@ -420,12 +420,12 @@ void setDefaultButton (Button button, boolean save) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setImage (Image image) {
- checkWidget();
- if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- this.image = image;
-}
-
+public void setImage (Image image) {
+ checkWidget();
+ if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ this.image = image;
+}
+
/**
* Sets the maximized state of the receiver.
* If the argument is <code>true</code> causes the receiver
@@ -449,10 +449,10 @@ public void setImage (Image image) {
*
* @see #setMinimized
*/
-public void setMaximized (boolean maximized) {
- checkWidget();
-}
-
+public void setMaximized (boolean maximized) {
+ checkWidget();
+}
+
/**
* Sets the receiver's menu bar to the argument, which
* may be null.
@@ -468,12 +468,12 @@ public void setMaximized (boolean maximized) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMenuBar (Menu menu) {
- checkWidget();
- if (menu != null && menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- //NOT DONE
-}
-
+public void setMenuBar (Menu menu) {
+ checkWidget();
+ if (menu != null && menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ //NOT DONE
+}
+
/**
* Sets the minimized stated of the receiver.
* If the argument is <code>true</code> causes the receiver
@@ -497,10 +497,10 @@ public void setMenuBar (Menu menu) {
*
* @see #setMaximized
*/
-public void setMinimized (boolean minimized) {
- checkWidget();
-}
-
+public void setMinimized (boolean minimized) {
+ checkWidget();
+}
+
/**
* Sets the receiver's text, which is the string that the
* window manager will typically display as the receiver's
@@ -516,17 +516,17 @@ public void setMinimized (boolean minimized) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- text = string;
-}
-
-boolean traverseReturn () {
- if (defaultButton == null || defaultButton.isDisposed ()) return false;
- if (!defaultButton.isVisible () || !defaultButton.isEnabled ()) return false;
- defaultButton.click ();
- return true;
-}
-
-}
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ text = string;
+}
+
+boolean traverseReturn () {
+ if (defaultButton == null || defaultButton.isDisposed ()) return false;
+ if (!defaultButton.isVisible () || !defaultButton.isEnabled ()) return false;
+ defaultButton.click ();
+ return true;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/DirectoryDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/DirectoryDialog.java
index 5f085a4e02..0b38ff26e8 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/DirectoryDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/DirectoryDialog.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
/**
* Instances of this class allow the user to navigate
* the file system and select a directory.
@@ -19,9 +19,9 @@ import org.eclipse.swt.*;
* within the SWT implementation.
* </p>
*/
-public class DirectoryDialog extends Dialog {
- String message = "", filterPath = "";
-
+public class DirectoryDialog extends Dialog {
+ String message = "", filterPath = "";
+
/**
* Constructs a new instance of this class given only its
* parent.
@@ -44,10 +44,10 @@ public class DirectoryDialog extends Dialog {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public DirectoryDialog (Shell parent) {
- this (parent, SWT.PRIMARY_MODAL);
-}
-
+public DirectoryDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -78,21 +78,21 @@ public DirectoryDialog (Shell parent) {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public DirectoryDialog (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
-
+public DirectoryDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
+
/**
* Returns the path which the dialog will use to filter
* the directories it shows.
*
* @return the filter path
*/
-public String getFilterPath () {
- return filterPath;
-}
-
+public String getFilterPath () {
+ return filterPath;
+}
+
/**
* Returns the dialog's message, which is a description of
* the purpose for which it was opened. This message will be
@@ -100,10 +100,10 @@ public String getFilterPath () {
*
* @return the message
*/
-public String getMessage () {
- return message;
-}
-
+public String getMessage () {
+ return message;
+}
+
/**
* Makes the dialog visible and brings it to the front
* of the display.
@@ -116,29 +116,29 @@ public String getMessage () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
* </ul>
*/
-public String open () {
- int parentHandle = 0;
- if (parent != null && OS.PtWidgetIsRealized(parent.shellHandle)) {
- 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 String open () {
+ int parentHandle = 0;
+ if (parent != null && OS.PtWidgetIsRealized(parent.shellHandle)) {
+ 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));
+}
+
/**
* Sets the path which the dialog will use to filter
* the directories it shows to the argument, which may be
@@ -146,10 +146,10 @@ public String open () {
*
* @param string the filter path
*/
-public void setFilterPath (String string) {
- filterPath = string;
-}
-
+public void setFilterPath (String string) {
+ filterPath = string;
+}
+
/**
* Sets the dialog's message, which is a description of
* the purpose for which it was opened. This message will be
@@ -157,8 +157,8 @@ public void setFilterPath (String string) {
*
* @param string the message
*/
-public void setMessage (String string) {
- message = string;
-}
-
+public void setMessage (String string) {
+ message = string;
+}
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java
index 84f07e30f6..9dfa89d378 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class are responsible for managing the
* connection between SWT and the underlying operating
@@ -87,200 +87,200 @@ import org.eclipse.swt.graphics.*;
* @see #sleep
* @see #dispose
*/
-public class Display extends Device {
-
+public class Display extends Device {
+
/* TEMPORARY CODE FOR EMULATED TABLE */
- 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;
- EventTable eventTable, filterTable;
-
- /* Events Dispatching and Callback */
- Callback windowCallback, drawCallback, workCallback, inputCallback, hotkeyCallback;
- int windowProc, drawProc, workProc, inputProc, hotkeyProc, input, pulse;
- boolean idle;
-
- /* Sync/Async Widget Communication */
- Synchronizer synchronizer = new Synchronizer (this);
- Thread thread;
-
- /* Display Shutdown */
- Runnable [] disposeList;
-
- /* Timers */
- int [] timerIds;
- 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 Keys */
- {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},
-
- /* Virtual and Ascii Keys */
- {OS.Pk_BackSpace, SWT.BS},
- {OS.Pk_Return, SWT.CR},
- {OS.Pk_Delete, SWT.DEL},
- {OS.Pk_Escape, SWT.ESC},
- {OS.Pk_Cancel, SWT.ESC},
- {OS.Pk_Linefeed, SWT.LF},
- {OS.Pk_Tab, SWT.TAB},
- {OS.Pk_KP_Tab, SWT.TAB},
-
- /* 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 Keys */
- /*
- {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 */
- int ClassesPtr;
- int PtButton;
- int PtList;
- int PtLabel;
- int PtWindow;
- int PtToggleButton;
- int PtComboBox;
- int PtText;
- int PtMultiText;
- int PtScrollbar;
- int PtScrollContainer;
- int PtScrollArea;
- int PtContainer;
- int PtProgress;
- int PtPanelGroup;
- int PtPane;
- int PtSlider;
- int PtSeparator;
- int PtToolbar;
-
- /* 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;
- int INFO_FOREGROUND, INFO_BACKGROUND, TEXT_FOREGROUND, TEXT_BACKGROUND;
-
- /* Fonts */
- byte [] defaultFont;
- byte [] TEXT_FONT, LIST_FONT, TITLE_FONT, GAUGE_FONT, GROUP_FONT;
-
- /* Images */
- int nullImage;
-
- /* ScrollBars */
- int SCROLLBAR_WIDTH;
- int SCROLLBAR_HEIGHT;
- int SCROLLBAR_VERTICAL_BASIC_FLAGS;
- int SCROLLBAR_HORIZONTAL_BASIC_FLAGS;
-
- /* 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;
-
- /*
- * TEMPORARY CODE. Install the runnable that
- * gets the current display. This code will
- * be removed in the future.
- */
- static {
- DeviceFinder = new Runnable () {
- public void run () {
- Device device = getCurrent ();
- if (device == null) {
- device = getDefault ();
- }
- setDevice (device);
- }
- };
- }
-
-/*
-* TEMPORARY CODE.
-*/
-static void setDevice (Device device) {
- CurrentDevice = device;
-}
-
+ 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;
+ EventTable eventTable, filterTable;
+
+ /* Events Dispatching and Callback */
+ Callback windowCallback, drawCallback, workCallback, inputCallback, hotkeyCallback;
+ int windowProc, drawProc, workProc, inputProc, hotkeyProc, input, pulse;
+ boolean idle;
+
+ /* Sync/Async Widget Communication */
+ Synchronizer synchronizer = new Synchronizer (this);
+ Thread thread;
+
+ /* Display Shutdown */
+ Runnable [] disposeList;
+
+ /* Timers */
+ int [] timerIds;
+ 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 Keys */
+ {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},
+
+ /* Virtual and Ascii Keys */
+ {OS.Pk_BackSpace, SWT.BS},
+ {OS.Pk_Return, SWT.CR},
+ {OS.Pk_Delete, SWT.DEL},
+ {OS.Pk_Escape, SWT.ESC},
+ {OS.Pk_Cancel, SWT.ESC},
+ {OS.Pk_Linefeed, SWT.LF},
+ {OS.Pk_Tab, SWT.TAB},
+ {OS.Pk_KP_Tab, SWT.TAB},
+
+ /* 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 Keys */
+ /*
+ {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 */
+ int ClassesPtr;
+ int PtButton;
+ int PtList;
+ int PtLabel;
+ int PtWindow;
+ int PtToggleButton;
+ int PtComboBox;
+ int PtText;
+ int PtMultiText;
+ int PtScrollbar;
+ int PtScrollContainer;
+ int PtScrollArea;
+ int PtContainer;
+ int PtProgress;
+ int PtPanelGroup;
+ int PtPane;
+ int PtSlider;
+ int PtSeparator;
+ int PtToolbar;
+
+ /* 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;
+ int INFO_FOREGROUND, INFO_BACKGROUND, TEXT_FOREGROUND, TEXT_BACKGROUND;
+
+ /* Fonts */
+ byte [] defaultFont;
+ byte [] TEXT_FONT, LIST_FONT, TITLE_FONT, GAUGE_FONT, GROUP_FONT;
+
+ /* Images */
+ int nullImage;
+
+ /* ScrollBars */
+ int SCROLLBAR_WIDTH;
+ int SCROLLBAR_HEIGHT;
+ int SCROLLBAR_VERTICAL_BASIC_FLAGS;
+ int SCROLLBAR_HORIZONTAL_BASIC_FLAGS;
+
+ /* 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;
+
+ /*
+ * TEMPORARY CODE. Install the runnable that
+ * gets the current display. This code will
+ * be removed in the future.
+ */
+ static {
+ DeviceFinder = new Runnable () {
+ public void run () {
+ Device device = getCurrent ();
+ if (device == null) {
+ device = getDefault ();
+ }
+ setDevice (device);
+ }
+ };
+ }
+
+/*
+* TEMPORARY CODE.
+*/
+static void setDevice (Device device) {
+ CurrentDevice = device;
+}
+
/**
* Constructs a new instance of this class.
* <p>
@@ -300,71 +300,71 @@ static void setDevice (Device device) {
* @see Widget#checkSubclass
* @see Shell
*/
-public Display () {
- this (null);
-}
-
-public Display (DeviceData data) {
- super (data);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notifed when an event of the given type occurs anywhere
- * in SWT. When the event does occur, the listener is notified
- * by sending it the <code>handleEvent()</code> message.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #removeFilter
- * @see #removeListener
- *
- * @since 2.1
- */
-void addFilter (int eventType, Listener listener) {
- checkDevice ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (filterTable == null) filterTable = new EventTable ();
- filterTable.hook (eventType, listener);
-}
-
-/**
- * Adds the listener to the collection of listeners who will
- * be notifed when an event of the given type occurs. When the
- * event does occur in the display, the listener is notified by
- * sending it the <code>handleEvent()</code> message.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #removeListener
- *
- * @since 2.0
+public Display () {
+ this (null);
+}
+
+public Display (DeviceData data) {
+ super (data);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notifed when an event of the given type occurs anywhere
+ * in SWT. When the event does occur, the listener is notified
+ * by sending it the <code>handleEvent()</code> message.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see #removeFilter
+ * @see #removeListener
+ *
+ * @since 2.1
+ */
+void addFilter (int eventType, Listener listener) {
+ checkDevice ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (filterTable == null) filterTable = new EventTable ();
+ filterTable.hook (eventType, listener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notifed when an event of the given type occurs. When the
+ * event does occur in the display, the listener is notified by
+ * sending it the <code>handleEvent()</code> message.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see #removeListener
+ *
+ * @since 2.0
*/
-public void addListener (int eventType, Listener listener) {
- checkDevice ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) eventTable = new EventTable ();
- eventTable.hook (eventType, listener);
-}
-
+public void addListener (int eventType, Listener listener) {
+ checkDevice ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) eventTable = new EventTable ();
+ eventTable.hook (eventType, listener);
+}
+
/**
* Causes the <code>run()</code> method of the runnable to
* be invoked by the user-interface thread at the next
@@ -376,112 +376,112 @@ public void addListener (int eventType, Listener listener) {
*
* @see #syncExec
*/
-public void asyncExec (Runnable runnable) {
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
- synchronizer.asyncExec (runnable);
-}
-
+public void asyncExec (Runnable runnable) {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ synchronizer.asyncExec (runnable);
+}
+
/**
* Causes the system hardware to emit a short sound
* (if it supports this capability).
*/
-public void beep () {
- checkDevice ();
- OS.PtBeep ();
-}
-
-protected void checkDevice () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
-}
-
-static synchronized void checkDisplay (Thread thread) {
- for (int i=0; i<Displays.length; i++) {
- if (Displays [i] != null && Displays [i].thread == thread) {
- SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS);
- }
- }
-}
-
-protected void checkSubclass () {
- if (!isValidClass (getClass ())) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-/**
- * Requests that the connection between SWT and the underlying
- * operating system be closed.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #dispose
- *
- * @since 2.0
+public void beep () {
+ checkDevice ();
+ OS.PtBeep ();
+}
+
+protected void checkDevice () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+}
+
+static synchronized void checkDisplay (Thread thread) {
+ for (int i=0; i<Displays.length; i++) {
+ if (Displays [i] != null && Displays [i].thread == thread) {
+ SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ }
+ }
+}
+
+protected void checkSubclass () {
+ if (!isValidClass (getClass ())) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+/**
+ * Requests that the connection between SWT and the underlying
+ * operating system be closed.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #dispose
+ *
+ * @since 2.0
*/
-public void close () {
- checkDevice ();
- Event event = new Event ();
- sendEvent (SWT.Close, event);
- if (event.doit) dispose ();
-}
-
-String convertToLf (String text) {
- int length = text.length ();
- if (length == 0) return text;
-
- /* Check for an LF or CR/LF. Assume the rest of the string
- * is formated that way. This will not work if the string
- * contains mixed delimiters. */
- int i = text.indexOf ('\n', 0);
- if (i == -1 || i == 0) return text;
- if (text.charAt (i - 1) != '\r') return text;
-
- /* The string is formatted with CR/LF.
- * Create a new string with the LF line delimiter. */
- i = 0;
- StringBuffer result = new StringBuffer ();
- while (i < length) {
- int j = text.indexOf ('\r', i);
- if (j == -1) j = length;
- String s = text.substring (i, j);
- result.append (s);
- i = j + 2;
- result.append ('\n');
- }
- return result.toString ();
-}
-
-protected void create (DeviceData data) {
- checkSubclass ();
- checkDisplay (thread = Thread.currentThread ());
- 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 close () {
+ checkDevice ();
+ Event event = new Event ();
+ sendEvent (SWT.Close, event);
+ if (event.doit) dispose ();
+}
+
+String convertToLf (String text) {
+ int length = text.length ();
+ if (length == 0) return text;
+
+ /* Check for an LF or CR/LF. Assume the rest of the string
+ * is formated that way. This will not work if the string
+ * contains mixed delimiters. */
+ int i = text.indexOf ('\n', 0);
+ if (i == -1 || i == 0) return text;
+ if (text.charAt (i - 1) != '\r') return text;
+
+ /* The string is formatted with CR/LF.
+ * Create a new string with the LF line delimiter. */
+ i = 0;
+ StringBuffer result = new StringBuffer ();
+ while (i < length) {
+ int j = text.indexOf ('\r', i);
+ if (j == -1) j = length;
+ String s = text.substring (i, j);
+ result.append (s);
+ i = j + 2;
+ result.append ('\n');
+ }
+ return result.toString ();
+}
+
+protected void create (DeviceData data) {
+ checkSubclass ();
+ checkDisplay (thread = Thread.currentThread ());
+ 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 ???
+}
+
/**
* Causes the <code>run()</code> method of the runnable to
* be invoked by the user-interface thread just before the
@@ -489,40 +489,40 @@ void destroyDisplay () {
*
* @param runnable code to run at dispose time.
*/
-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) {
- /*
- * Feature in Photon. On QNX 6.2, if a widget is damaged, PtBlit() will
- * call its draw function before blitting pixels. This is not wrong
- * but it is unwanted, since the callback might happen in a thread other
- * than the display thread. The fix is to detect that the callback happened
- * in the wrong thread and return right away.
- */
- //TEMPORARY CODE
- if (thread != Thread.currentThread()) return 0;
- Widget widget = WidgetTable.get (handle);
- if (widget == null) return 0;
- return widget.drawProc (handle, damage);
-}
-
-void error (int code) {
- SWT.error(code);
-}
-
+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) {
+ /*
+ * Feature in Photon. On QNX 6.2, if a widget is damaged, PtBlit() will
+ * call its draw function before blitting pixels. This is not wrong
+ * but it is unwanted, since the callback might happen in a thread other
+ * than the display thread. The fix is to detect that the callback happened
+ * in the wrong thread and return right away.
+ */
+ //TEMPORARY CODE
+ if (thread != Thread.currentThread()) return 0;
+ Widget widget = WidgetTable.get (handle);
+ if (widget == null) return 0;
+ return widget.drawProc (handle, damage);
+}
+
+void error (int code) {
+ SWT.error(code);
+}
+
/**
* Returns the display which the given thread is the
* user-interface thread for, or null if the given thread
@@ -531,26 +531,26 @@ void error (int code) {
* @param thread the user-interface thread
* @return the display for the given thread
*/
-public static synchronized Display findDisplay (Thread thread) {
- for (int i=0; i<Displays.length; i++) {
- Display display = Displays [i];
- if (display != null && display.thread == thread) {
- return display;
- }
- }
- return null;
-}
-
-boolean filterEvent (Event event) {
- if (filterTable != null) filterTable.sendEvent (event);
- return false;
-}
-
-boolean filters (int eventType) {
- if (filterTable == null) return false;
- return filterTable.hooks (eventType);
-}
-
+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;
+}
+
+boolean filterEvent (Event event) {
+ if (filterTable != null) filterTable.sendEvent (event);
+ return false;
+}
+
+boolean filters (int eventType) {
+ if (filterTable == null) return false;
+ return filterTable.hooks (eventType);
+}
+
/**
* Given the operating system handle for a widget, returns
* the instance of the <code>Widget</code> subclass which
@@ -564,11 +564,11 @@ boolean filters (int eventType) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Widget findWidget (int handle) {
- checkDevice ();
- return WidgetTable.get (handle);
-}
-
+public Widget findWidget (int handle) {
+ checkDevice ();
+ return WidgetTable.get (handle);
+}
+
/**
* Returns the currently active <code>Shell</code>, or null
* if no shell belonging to the currently running application
@@ -580,19 +580,19 @@ public Widget findWidget (int handle) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-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 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;
+}
+
/**
* Returns the control which the on-screen pointer is currently
* over top of, or null if it is not currently over one of the
@@ -604,41 +604,41 @@ public Shell getActiveShell () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-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 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;
+}
+
/**
* Returns the location of the on-screen pointer relative
* to the top left corner of the screen.
@@ -649,14 +649,14 @@ public Control getCursorControl () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-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 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);
+}
+
/**
* Returns the display which the currently running thread is
* the user-interface thread for, or null if the currently
@@ -664,15 +664,15 @@ public Point getCursorLocation () {
*
* @return the current display
*/
-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 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;
+}
+
/**
* Returns the default display. One is created (making the
* thread that invokes this method its user-interface thread)
@@ -680,11 +680,11 @@ public static synchronized Display getCurrent () {
*
* @return the default display
*/
-public static synchronized Display getDefault () {
- if (Default == null) Default = new Display ();
- return Default;
-}
-
+public static synchronized Display getDefault () {
+ if (Default == null) Default = new Display ();
+ return Default;
+}
+
/**
* On platforms which support it, sets the application name
* to be the argument. On Motif, for example, this can be used
@@ -692,15 +692,15 @@ public static synchronized Display getDefault () {
*
* @param name the new app name
*/
-public static void setAppName (String name) {
- /* Do nothing */
-}
-
-public int getDismissalAlignment () {
- checkDevice ();
- return SWT.RIGHT;
-}
-
+public static void setAppName (String name) {
+ /* Do nothing */
+}
+
+public int getDismissalAlignment () {
+ checkDevice ();
+ return SWT.RIGHT;
+}
+
/**
* Returns the longest duration, in milliseconds, between
* two mouse button clicks that will be considered a
@@ -712,12 +712,12 @@ public int getDismissalAlignment () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getDoubleClickTime () {
- checkDevice ();
- //NOT DONE
- return 250;
-}
-
+public int getDoubleClickTime () {
+ checkDevice ();
+ //NOT DONE
+ return 250;
+}
+
/**
* Returns the control which currently has keyboard focus,
* or null if keyboard events are not currently going to
@@ -730,27 +730,27 @@ public int getDoubleClickTime () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-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;
-}
-
-int getLastEventTime () {
- return (int) System.currentTimeMillis ();
-}
-
+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;
+}
+
+int getLastEventTime () {
+ return (int) System.currentTimeMillis ();
+}
+
/**
* Returns the maximum allowed depth of icons on this display.
* On some platforms, this may be different than the actual
@@ -762,10 +762,10 @@ int getLastEventTime () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getIconDepth () {
- return getDepth ();
-}
-
+public int getIconDepth () {
+ return getDepth ();
+}
+
/**
* Returns an array containing all shells which have not been
* disposed and have the receiver as their display.
@@ -776,34 +776,34 @@ public int getIconDepth () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-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 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;
+}
+
/**
* Returns the matching standard color for the given
* constant, which should be one of the color constants
@@ -822,35 +822,35 @@ public Shell [] getShells () {
*
* @see SWT
*/
-public Color getSystemColor (int id) {
- checkDevice ();
- int color = 0x000000;
- switch (id) {
- case SWT.COLOR_INFO_FOREGROUND: color = INFO_FOREGROUND; break;
- case SWT.COLOR_INFO_BACKGROUND: color = INFO_BACKGROUND; break;
- case SWT.COLOR_TITLE_FOREGROUND: color = 0xFFFFFF; break;
- case SWT.COLOR_TITLE_BACKGROUND: color = 0x5281D5; break;
- case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: color = 0x74A3FF; break;
- case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: color = 0x000000; break;
- case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: color = 0xABBBD3; break;
- case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: color = 0xCDDDFF; break;
- case SWT.COLOR_WIDGET_DARK_SHADOW: color = WIDGET_DARK_SHADOW; break;
- case SWT.COLOR_WIDGET_NORMAL_SHADOW: color = WIDGET_NORMAL_SHADOW; break;
- case SWT.COLOR_WIDGET_LIGHT_SHADOW: color = WIDGET_LIGHT_SHADOW; break;
- 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 Color getSystemColor (int id) {
+ checkDevice ();
+ int color = 0x000000;
+ switch (id) {
+ case SWT.COLOR_INFO_FOREGROUND: color = INFO_FOREGROUND; break;
+ case SWT.COLOR_INFO_BACKGROUND: color = INFO_BACKGROUND; break;
+ case SWT.COLOR_TITLE_FOREGROUND: color = 0xFFFFFF; break;
+ case SWT.COLOR_TITLE_BACKGROUND: color = 0x5281D5; break;
+ case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: color = 0x74A3FF; break;
+ case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: color = 0x000000; break;
+ case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: color = 0xABBBD3; break;
+ case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: color = 0xCDDDFF; break;
+ case SWT.COLOR_WIDGET_DARK_SHADOW: color = WIDGET_DARK_SHADOW; break;
+ case SWT.COLOR_WIDGET_NORMAL_SHADOW: color = WIDGET_NORMAL_SHADOW; break;
+ case SWT.COLOR_WIDGET_LIGHT_SHADOW: color = WIDGET_LIGHT_SHADOW; break;
+ 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);
+}
+
/**
* Returns a reasonable font for applications to use.
* On some platforms, this will match the "default font"
@@ -871,12 +871,12 @@ public Color getSystemColor (int id) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Font getSystemFont () {
- checkDevice ();
- byte [] font = defaultFont != null ? defaultFont : TEXT_FONT;
- return Font.photon_new (this, font);
-}
-
+public Font getSystemFont () {
+ checkDevice ();
+ byte [] font = defaultFont != null ? defaultFont : TEXT_FONT;
+ return Font.photon_new (this, font);
+}
+
/**
* Returns the thread that has invoked <code>syncExec</code>
* or null if no such runnable is currently being invoked by
@@ -888,263 +888,263 @@ public Font getSystemFont () {
*
* @return the receiver's sync-interface thread
*/
-public Thread getSyncThread () {
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
- return synchronizer.syncThread;
-}
-
+public Thread getSyncThread () {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ return synchronizer.syncThread;
+}
+
/**
* Returns the user-interface thread for the receiver.
*
* @return the receiver's user-interface thread
*/
-public Thread getThread () {
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
- return thread;
-}
-
-int hotkeyProc (int handle, int data, int info) {
- Widget widget = WidgetTable.get (handle);
- if (widget == null) return OS.Pt_CONTINUE;
- return widget.hotkeyProc (handle, data, info);
-}
-
-protected void init () {
- super.init ();
- initializeDisplay ();
- initializeWidgetClasses ();
- initializeWidgetColors ();
- initializeWidgetFonts ();
- initializeScrollbars ();
- initializeImages ();
-}
-
-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);
- hotkeyCallback = new Callback (this, "hotkeyProc", 3);
- hotkeyProc = hotkeyCallback.getAddress ();
- if (hotkeyProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
-
- pulse = OS.PtAppCreatePulse (app_context, -1);
- input = OS.PtAppAddInput (app_context, pulse, inputProc, 0);
- 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 initializeScrollbars () {
- OS.PtSetParentWidget (0);
- int shellHandle = OS.PtCreateWidget (OS.PtWindow (), 0, 0, null);
- int textHandle = OS.PtCreateWidget (OS.PtMultiText (), shellHandle, 0, null);
- int child = OS.PtWidgetChildFront (textHandle);
- while (child != 0) {
- if (OS.PtWidgetClass (child) == OS.PtScrollbar ()) {
- int [] args = new int [] {
- OS.Pt_ARG_ORIENTATION, 0, 0,
- OS.Pt_ARG_WIDTH, 0, 0,
- OS.Pt_ARG_HEIGHT, 0, 0,
- OS.Pt_ARG_BASIC_FLAGS, 0, 0,
- };
- OS.PtGetResources (child, args.length / 3, args);
- switch (args [1]) {
- case OS.Pt_HORIZONTAL:
- SCROLLBAR_HEIGHT = args [7];
- SCROLLBAR_HORIZONTAL_BASIC_FLAGS = args [10];
- break;
- case OS.Pt_VERTICAL:
- SCROLLBAR_WIDTH = args [4];
- SCROLLBAR_VERTICAL_BASIC_FLAGS = args [10];
- break;
- }
- }
- child = OS.PtWidgetBrotherBehind (child);
- }
- OS.PtDestroyWidget (shellHandle);
-}
-
-void initializeWidgetClasses () {
- int [] args = {OS.Pt_SET_DRAW_F, drawProc, 0};
- int [] buffer = {
- 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.PtSlider (), 0, args.length / 3, args), 0, 0,
- OS.PtCreateWidgetClass (OS.PtSeparator (), 0, args.length / 3, args), 0, 0,
- OS.PtCreateWidgetClass (OS.PtToolbar (), 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;
- PtSlider = ClassesPtr + 180;
- PtSeparator = ClassesPtr + 192;
- PtToolbar = ClassesPtr + 204;
-}
-
-void initializeWidgetColors () {
- OS.PtSetParentWidget (0);
- int [] args = {
- OS.Pt_ARG_WINDOW_STATE, OS.Ph_WM_STATE_ISHIDDEN, ~0,
- };
- int shellHandle = OS.PtCreateWidget (OS.PtWindow (), 0, args.length / 3, args);
- args = new int [] {
- OS.Pt_ARG_COLOR, 0, 0,
- OS.Pt_ARG_FILL_COLOR, 0, 0,
- };
- OS.PtGetResources (shellHandle, args.length / 3, args);
- WIDGET_FOREGROUND = args [1];
- WIDGET_BACKGROUND = args [4];
-
- int listHandle = 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.PtGetResources (listHandle, args.length / 3, args);
- LIST_FOREGROUND = args [1];
- LIST_BACKGROUND = args [4];
- LIST_SELECTION = args [7];
- LIST_SELECTION_TEXT = args [10];
-
- int textHandle = OS.PtCreateWidget (OS.PtText (), shellHandle, 0, null);
- args = new int [] {
- OS.Pt_ARG_COLOR, 0, 0,
- OS.Pt_ARG_FILL_COLOR, 0, 0,
- };
- OS.PtGetResources (textHandle, args.length / 3, args);
- TEXT_FOREGROUND = args [1];
- TEXT_BACKGROUND = args [4];
-
- /*
- * Feature in Photon. The values of Pt_ARG_DARK_BEVEL_COLOR and
- * Pt_ARG_LIGHT_BEVEL_COLOR are not initialized until the widget
- * is realized. The fix is to realize the shell without displaying
- * it.
- */
- int buttonHandle = OS.PtCreateWidget (OS.PtButton (), shellHandle, 0, null);
- OS.PtRealizeWidget(shellHandle);
- args = new int [] {
- OS.Pt_ARG_OUTLINE_COLOR, 0, 0,
- OS.Pt_ARG_OUTLINE_COLOR, 0, 0,
- OS.Pt_ARG_DARK_BEVEL_COLOR, 0, 0,
- OS.Pt_ARG_BEVEL_COLOR, 0, 0,
- OS.Pt_ARG_LIGHT_BEVEL_COLOR, 0, 0,
- OS.Pt_ARG_BALLOON_COLOR, 0, 0,
- OS.Pt_ARG_BALLOON_FILL_COLOR, 0, 0,
- };
- OS.PtGetResources (buttonHandle, args.length / 3, args);
- WIDGET_BORDER = args [1];
- WIDGET_DARK_SHADOW = args [4];
- WIDGET_NORMAL_SHADOW = args [7];
- WIDGET_LIGHT_SHADOW = args [10];
- WIDGET_HIGHLIGHT_SHADOW = args [13];
- INFO_FOREGROUND = args [16];
- INFO_BACKGROUND = args [19];
-
- OS.PtDestroyWidget (shellHandle);
-}
-
-void initializeWidgetFonts () {
- String property = System.getProperty ("swt.system.font");
- if (property != null) {
- defaultFont = Converter.wcsToMbcs (null, property, true);
- TEXT_FONT = LIST_FONT = GAUGE_FONT = TITLE_FONT = defaultFont;
- GROUP_FONT = Converter.wcsToMbcs (null, property + "b", true);
- return;
- }
- OS.PtSetParentWidget (0);
-
- int shellHandle = OS.PtCreateWidget (OS.PtWindow (), 0, 0, null);
- int [] args = new int [] {OS.Pt_ARG_TITLE_FONT, 0, 0};
- OS.PtGetResources (shellHandle, args.length / 3, args);
- int length = OS.strlen (args [1]);
- GROUP_FONT = TITLE_FONT = new byte [length + 1];
- OS.memmove (TITLE_FONT, args [1], length);
-
- int listHandle = OS.PtCreateWidget (OS.PtList (), shellHandle, 0, null);
- args = new int [] {OS.Pt_ARG_LIST_FONT, 0, 0};
- OS.PtGetResources (listHandle, args.length / 3, args);
- length = OS.strlen (args [1]);
- LIST_FONT = new byte [length + 1];
- OS.memmove (LIST_FONT, args [1], length);
-
- 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);
- length = OS.strlen (args [1]);
- TEXT_FONT = new byte [length + 1];
- OS.memmove (TEXT_FONT, args [1], length);
-
- int scrollHandle = OS.PtCreateWidget (OS.PtScrollbar (), shellHandle, 0, null);
- args = new int [] {OS.Pt_ARG_GAUGE_FONT, 0, 0};
- OS.PtGetResources (scrollHandle, args.length / 3, args);
- length = OS.strlen (args [1]);
- GAUGE_FONT = new byte [length + 1];
- OS.memmove (GAUGE_FONT, args [1], length);
-
- OS.PtDestroyWidget (shellHandle);
-}
-
-void initializeImages () {
- nullImage = OS.PhCreateImage (null, (short) 1, (short) 1, OS.Pg_IMAGE_DIRECT_888, 0, 0, 0);
- if (nullImage == 0) SWT.error (SWT.ERROR_NO_HANDLES);
-}
-
-int inputProc (int data, int rcvid, int message, int size) {
- if (embedded) {
- runDeferredEvents ();
- runAsyncMessages ();
- }
- return OS.Pt_CONTINUE;
-}
-
+public Thread getThread () {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ return thread;
+}
+
+int hotkeyProc (int handle, int data, int info) {
+ Widget widget = WidgetTable.get (handle);
+ if (widget == null) return OS.Pt_CONTINUE;
+ return widget.hotkeyProc (handle, data, info);
+}
+
+protected void init () {
+ super.init ();
+ initializeDisplay ();
+ initializeWidgetClasses ();
+ initializeWidgetColors ();
+ initializeWidgetFonts ();
+ initializeScrollbars ();
+ initializeImages ();
+}
+
+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);
+ hotkeyCallback = new Callback (this, "hotkeyProc", 3);
+ hotkeyProc = hotkeyCallback.getAddress ();
+ if (hotkeyProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+
+ pulse = OS.PtAppCreatePulse (app_context, -1);
+ input = OS.PtAppAddInput (app_context, pulse, inputProc, 0);
+ 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 initializeScrollbars () {
+ OS.PtSetParentWidget (0);
+ int shellHandle = OS.PtCreateWidget (OS.PtWindow (), 0, 0, null);
+ int textHandle = OS.PtCreateWidget (OS.PtMultiText (), shellHandle, 0, null);
+ int child = OS.PtWidgetChildFront (textHandle);
+ while (child != 0) {
+ if (OS.PtWidgetClass (child) == OS.PtScrollbar ()) {
+ int [] args = new int [] {
+ OS.Pt_ARG_ORIENTATION, 0, 0,
+ OS.Pt_ARG_WIDTH, 0, 0,
+ OS.Pt_ARG_HEIGHT, 0, 0,
+ OS.Pt_ARG_BASIC_FLAGS, 0, 0,
+ };
+ OS.PtGetResources (child, args.length / 3, args);
+ switch (args [1]) {
+ case OS.Pt_HORIZONTAL:
+ SCROLLBAR_HEIGHT = args [7];
+ SCROLLBAR_HORIZONTAL_BASIC_FLAGS = args [10];
+ break;
+ case OS.Pt_VERTICAL:
+ SCROLLBAR_WIDTH = args [4];
+ SCROLLBAR_VERTICAL_BASIC_FLAGS = args [10];
+ break;
+ }
+ }
+ child = OS.PtWidgetBrotherBehind (child);
+ }
+ OS.PtDestroyWidget (shellHandle);
+}
+
+void initializeWidgetClasses () {
+ int [] args = {OS.Pt_SET_DRAW_F, drawProc, 0};
+ int [] buffer = {
+ 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.PtSlider (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtSeparator (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtToolbar (), 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;
+ PtSlider = ClassesPtr + 180;
+ PtSeparator = ClassesPtr + 192;
+ PtToolbar = ClassesPtr + 204;
+}
+
+void initializeWidgetColors () {
+ OS.PtSetParentWidget (0);
+ int [] args = {
+ OS.Pt_ARG_WINDOW_STATE, OS.Ph_WM_STATE_ISHIDDEN, ~0,
+ };
+ int shellHandle = OS.PtCreateWidget (OS.PtWindow (), 0, args.length / 3, args);
+ args = new int [] {
+ OS.Pt_ARG_COLOR, 0, 0,
+ OS.Pt_ARG_FILL_COLOR, 0, 0,
+ };
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ WIDGET_FOREGROUND = args [1];
+ WIDGET_BACKGROUND = args [4];
+
+ int listHandle = 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.PtGetResources (listHandle, args.length / 3, args);
+ LIST_FOREGROUND = args [1];
+ LIST_BACKGROUND = args [4];
+ LIST_SELECTION = args [7];
+ LIST_SELECTION_TEXT = args [10];
+
+ int textHandle = OS.PtCreateWidget (OS.PtText (), shellHandle, 0, null);
+ args = new int [] {
+ OS.Pt_ARG_COLOR, 0, 0,
+ OS.Pt_ARG_FILL_COLOR, 0, 0,
+ };
+ OS.PtGetResources (textHandle, args.length / 3, args);
+ TEXT_FOREGROUND = args [1];
+ TEXT_BACKGROUND = args [4];
+
+ /*
+ * Feature in Photon. The values of Pt_ARG_DARK_BEVEL_COLOR and
+ * Pt_ARG_LIGHT_BEVEL_COLOR are not initialized until the widget
+ * is realized. The fix is to realize the shell without displaying
+ * it.
+ */
+ int buttonHandle = OS.PtCreateWidget (OS.PtButton (), shellHandle, 0, null);
+ OS.PtRealizeWidget(shellHandle);
+ args = new int [] {
+ OS.Pt_ARG_OUTLINE_COLOR, 0, 0,
+ OS.Pt_ARG_OUTLINE_COLOR, 0, 0,
+ OS.Pt_ARG_DARK_BEVEL_COLOR, 0, 0,
+ OS.Pt_ARG_BEVEL_COLOR, 0, 0,
+ OS.Pt_ARG_LIGHT_BEVEL_COLOR, 0, 0,
+ OS.Pt_ARG_BALLOON_COLOR, 0, 0,
+ OS.Pt_ARG_BALLOON_FILL_COLOR, 0, 0,
+ };
+ OS.PtGetResources (buttonHandle, args.length / 3, args);
+ WIDGET_BORDER = args [1];
+ WIDGET_DARK_SHADOW = args [4];
+ WIDGET_NORMAL_SHADOW = args [7];
+ WIDGET_LIGHT_SHADOW = args [10];
+ WIDGET_HIGHLIGHT_SHADOW = args [13];
+ INFO_FOREGROUND = args [16];
+ INFO_BACKGROUND = args [19];
+
+ OS.PtDestroyWidget (shellHandle);
+}
+
+void initializeWidgetFonts () {
+ String property = System.getProperty ("swt.system.font");
+ if (property != null) {
+ defaultFont = Converter.wcsToMbcs (null, property, true);
+ TEXT_FONT = LIST_FONT = GAUGE_FONT = TITLE_FONT = defaultFont;
+ GROUP_FONT = Converter.wcsToMbcs (null, property + "b", true);
+ return;
+ }
+ OS.PtSetParentWidget (0);
+
+ int shellHandle = OS.PtCreateWidget (OS.PtWindow (), 0, 0, null);
+ int [] args = new int [] {OS.Pt_ARG_TITLE_FONT, 0, 0};
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ int length = OS.strlen (args [1]);
+ GROUP_FONT = TITLE_FONT = new byte [length + 1];
+ OS.memmove (TITLE_FONT, args [1], length);
+
+ int listHandle = OS.PtCreateWidget (OS.PtList (), shellHandle, 0, null);
+ args = new int [] {OS.Pt_ARG_LIST_FONT, 0, 0};
+ OS.PtGetResources (listHandle, args.length / 3, args);
+ length = OS.strlen (args [1]);
+ LIST_FONT = new byte [length + 1];
+ OS.memmove (LIST_FONT, args [1], length);
+
+ 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);
+ length = OS.strlen (args [1]);
+ TEXT_FONT = new byte [length + 1];
+ OS.memmove (TEXT_FONT, args [1], length);
+
+ int scrollHandle = OS.PtCreateWidget (OS.PtScrollbar (), shellHandle, 0, null);
+ args = new int [] {OS.Pt_ARG_GAUGE_FONT, 0, 0};
+ OS.PtGetResources (scrollHandle, args.length / 3, args);
+ length = OS.strlen (args [1]);
+ GAUGE_FONT = new byte [length + 1];
+ OS.memmove (GAUGE_FONT, args [1], length);
+
+ OS.PtDestroyWidget (shellHandle);
+}
+
+void initializeImages () {
+ nullImage = OS.PhCreateImage (null, (short) 1, (short) 1, OS.Pg_IMAGE_DIRECT_888, 0, 0, 0);
+ if (nullImage == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+}
+
+int inputProc (int data, int rcvid, int message, int size) {
+ if (embedded) {
+ runDeferredEvents ();
+ runAsyncMessages ();
+ }
+ return OS.Pt_CONTINUE;
+}
+
/**
* Invokes platform specific functionality to allocate a new GC handle.
* <p>
@@ -1160,16 +1160,16 @@ int inputProc (int data, int rcvid, int message, int size) {
*
* @private
*/
-public int internal_new_GC (GCData data) {
- if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
- int phGC = OS.PgCreateGC(0); // NOTE: PgCreateGC ignores the parameter
- if (phGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
-
- data.device = this;
- data.rid = OS.Ph_DEV_RID;
- return phGC;
-}
-
+public int internal_new_GC (GCData data) {
+ if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
+ int phGC = OS.PgCreateGC(0); // NOTE: PgCreateGC ignores the parameter
+ if (phGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+
+ data.device = this;
+ data.rid = OS.Ph_DEV_RID;
+ return phGC;
+}
+
/**
* Invokes platform specific functionality to dispose a GC handle.
* <p>
@@ -1185,14 +1185,14 @@ public int internal_new_GC (GCData data) {
*
* @private
*/
-public void internal_dispose_GC (int phGC, GCData data) {
- OS.PgDestroyGC(phGC);
-}
-
-boolean isValidThread () {
- return thread == Thread.currentThread ();
-}
-
+public void internal_dispose_GC (int phGC, GCData data) {
+ OS.PgDestroyGC(phGC);
+}
+
+boolean isValidThread () {
+ return thread == Thread.currentThread ();
+}
+
/**
* Returns the application defined property of the receiver
* with the specified name, or null if it has not been set.
@@ -1217,16 +1217,16 @@ boolean isValidThread () {
* @see #setData
* @see #disposeExec
*/
-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 (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;
+}
+
/**
* Returns the application defined, display specific data
* associated with the receiver, or null if it has not been
@@ -1249,39 +1249,39 @@ public Object getData (String key) {
* @see #setData
* @see #disposeExec
*/
-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 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 ();
+}
+
/**
* Reads an event from the operating system's event queue,
* dispatches it appropriately, and returns <code>true</code>
@@ -1304,244 +1304,244 @@ void postEvent (Event event) {
* @see #sleep
* @see #wake
*/
-public boolean readAndDispatch () {
- checkDevice ();
- idle = false;
- OS.PtRelease ();
- OS.PtHold ();
- int id = OS.PtAppAddWorkProc (app_context, workProc, 0);
- OS.PtAppProcessEvent (app_context);
- OS.PtAppRemoveWorkProc (app_context, id);
- boolean result = true;
- if (idle) {
- result = runAsyncMessages ();
- } else {
- runDeferredEvents ();
- }
- OS.PtRelease ();
- OS.PtHold ();
- return result;
-}
-
-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 () {
- sendEvent (SWT.Dispose, new Event ());
- 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 ()) {};
- if (disposeList != null) {
- for (int i=0; i<disposeList.length; i++) {
- if (disposeList [i] != null) disposeList [i].run ();
- }
- }
- disposeList = null;
- synchronizer.releaseSynchronizer ();
- synchronizer = null;
- releaseDisplay ();
- super.release ();
-}
-
-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 timers */
- if (timerIds != null) {
- for (int i=0; i<timerIds.length; i++) {
- if (timerIds [i] != 0) OS.PtDestroyWidget (timerIds [i]);
- }
- }
- timerIds = null;
- timerList = null;
- timerProc = 0;
- timerCallback.dispose ();
- timerCallback = null;
-
- /* Free the window proc */
- windowCallback.dispose ();
- windowCallback = null;
-
- /* Free callbacks */
- drawCallback.dispose();
- drawCallback = null;
- workCallback.dispose();
- workCallback = null;
- inputCallback.dispose();
- inputCallback = null;
- hotkeyCallback.dispose();
- hotkeyCallback = null;
-
- if (nullImage != 0) {
- PhImage_t phImage = new PhImage_t();
- OS.memmove(phImage, nullImage, PhImage_t.sizeof);
- phImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
- OS.memmove(nullImage, phImage, PhImage_t.sizeof);
- OS.PhReleaseImage(nullImage);
- OS.free(nullImage);
- nullImage = 0;
- }
-
- /* Release references */
- thread = null;
- data = null;
- keys = null;
- values = null;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notifed when an event of the given type occurs anywhere in SWT.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should no longer be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #addFilter
- * @see #addListener
- *
- * @since 2.1
- */
-void removeFilter (int eventType, Listener listener) {
- checkDevice ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (filterTable == null) return;
- filterTable.unhook (eventType, listener);
- if (filterTable.size () == 0) filterTable = null;
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notifed when an event of the given type occurs.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should no longer be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #addListener
- *
- * @since 2.0
+public boolean readAndDispatch () {
+ checkDevice ();
+ idle = false;
+ OS.PtRelease ();
+ OS.PtHold ();
+ int id = OS.PtAppAddWorkProc (app_context, workProc, 0);
+ OS.PtAppProcessEvent (app_context);
+ OS.PtAppRemoveWorkProc (app_context, id);
+ boolean result = true;
+ if (idle) {
+ result = runAsyncMessages ();
+ } else {
+ runDeferredEvents ();
+ }
+ OS.PtRelease ();
+ OS.PtHold ();
+ return result;
+}
+
+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 () {
+ sendEvent (SWT.Dispose, new Event ());
+ 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 ()) {};
+ if (disposeList != null) {
+ for (int i=0; i<disposeList.length; i++) {
+ if (disposeList [i] != null) disposeList [i].run ();
+ }
+ }
+ disposeList = null;
+ synchronizer.releaseSynchronizer ();
+ synchronizer = null;
+ releaseDisplay ();
+ super.release ();
+}
+
+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 timers */
+ if (timerIds != null) {
+ for (int i=0; i<timerIds.length; i++) {
+ if (timerIds [i] != 0) OS.PtDestroyWidget (timerIds [i]);
+ }
+ }
+ timerIds = null;
+ timerList = null;
+ timerProc = 0;
+ timerCallback.dispose ();
+ timerCallback = null;
+
+ /* Free the window proc */
+ windowCallback.dispose ();
+ windowCallback = null;
+
+ /* Free callbacks */
+ drawCallback.dispose();
+ drawCallback = null;
+ workCallback.dispose();
+ workCallback = null;
+ inputCallback.dispose();
+ inputCallback = null;
+ hotkeyCallback.dispose();
+ hotkeyCallback = null;
+
+ if (nullImage != 0) {
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove(phImage, nullImage, PhImage_t.sizeof);
+ phImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
+ OS.memmove(nullImage, phImage, PhImage_t.sizeof);
+ OS.PhReleaseImage(nullImage);
+ OS.free(nullImage);
+ nullImage = 0;
+ }
+
+ /* Release references */
+ thread = null;
+ data = null;
+ keys = null;
+ values = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notifed when an event of the given type occurs anywhere in SWT.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should no longer be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see #addFilter
+ * @see #addListener
+ *
+ * @since 2.1
*/
-public void removeListener (int eventType, Listener listener) {
- checkDevice ();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (eventType, listener);
-}
-
-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 but 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.sendEvent (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;
-}
-
-void sendEvent (int eventType, Event event) {
- if (eventTable == null && filterTable == null) {
- return;
- }
- if (event == null) event = new Event ();
- event.display = this;
- event.type = eventType;
- if (event.time == 0) event.time = getLastEventTime ();
- if (!filterEvent (event)) {
- if (eventTable != null) eventTable.sendEvent (event);
- }
-}
-
-public void setCursorLocation (int x, int y) {
- checkDevice ();
- OS.PhMoveCursorAbs (OS.PhInputGroup (0), x, y);
-}
-
-/**
- * Sets the location of the on-screen pointer relative to the top left corner
- * of the screen. <b>Note: It is typically considered bad practice for a
- * program to move the on-screen pointer location.</b>
- *
- * @param point new position
- * @since 2.0
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * <li>ERROR_NULL_ARGUMENT - if the point is null
- * </ul>
+void removeFilter (int eventType, Listener listener) {
+ checkDevice ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (filterTable == null) return;
+ filterTable.unhook (eventType, listener);
+ if (filterTable.size () == 0) filterTable = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notifed when an event of the given type occurs.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should no longer be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see #addListener
+ *
+ * @since 2.0
+ */
+public void removeListener (int eventType, Listener listener) {
+ checkDevice ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (eventType, listener);
+}
+
+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 but 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.sendEvent (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;
+}
+
+void sendEvent (int eventType, Event event) {
+ if (eventTable == null && filterTable == null) {
+ return;
+ }
+ if (event == null) event = new Event ();
+ event.display = this;
+ event.type = eventType;
+ if (event.time == 0) event.time = getLastEventTime ();
+ if (!filterEvent (event)) {
+ if (eventTable != null) eventTable.sendEvent (event);
+ }
+}
+
+public void setCursorLocation (int x, int y) {
+ checkDevice ();
+ OS.PhMoveCursorAbs (OS.PhInputGroup (0), x, y);
+}
+
+/**
+ * Sets the location of the on-screen pointer relative to the top left corner
+ * of the screen. <b>Note: It is typically considered bad practice for a
+ * program to move the on-screen pointer location.</b>
+ *
+ * @param point new position
+ * @since 2.0
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null
+ * </ul>
*/
-public void setCursorLocation (Point point) {
- checkDevice ();
- if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- setCursorLocation (point.x, point.y);
-}
-
+public void setCursorLocation (Point point) {
+ checkDevice ();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setCursorLocation (point.x, point.y);
+}
+
/**
* Sets the application defined property of the receiver
* with the specified name to the given argument.
@@ -1566,54 +1566,54 @@ public void setCursorLocation (Point point) {
* @see #setData
* @see #disposeExec
*/
-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 (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;
+}
+
/**
* Sets the application defined, display specific data
* associated with the receiver, to the argument.
@@ -1636,11 +1636,11 @@ public void setData (String key, Object value) {
* @see #getData
* @see #disposeExec
*/
-public void setData (Object data) {
- checkDevice ();
- this.data = data;
-}
-
+public void setData (Object data) {
+ checkDevice ();
+ this.data = data;
+}
+
/**
* Sets the synchronizer used by the display to be
* the argument, which can not be null.
@@ -1654,15 +1654,15 @@ public void setData (Object data) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSynchronizer (Synchronizer synchronizer) {
- checkDevice ();
- if (synchronizer == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (this.synchronizer != null) {
- this.synchronizer.runAsyncMessages();
- }
- this.synchronizer = synchronizer;
-}
-
+public void setSynchronizer (Synchronizer synchronizer) {
+ checkDevice ();
+ if (synchronizer == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (this.synchronizer != null) {
+ this.synchronizer.runAsyncMessages();
+ }
+ this.synchronizer = synchronizer;
+}
+
/**
* Causes the user-interface thread to <em>sleep</em> (that is,
* to be put in a state where it does not consume CPU cycles)
@@ -1676,15 +1676,15 @@ public void setSynchronizer (Synchronizer synchronizer) {
*
* @see #wake
*/
-public boolean sleep () {
- checkDevice ();
- OS.PtHold ();
- OS.PtAppProcessEvent (app_context);
- runDeferredEvents ();
- OS.PtRelease ();
- return true;
-}
-
+public boolean sleep () {
+ checkDevice ();
+ OS.PtHold ();
+ OS.PtAppProcessEvent (app_context);
+ runDeferredEvents ();
+ OS.PtRelease ();
+ return true;
+}
+
/**
* Causes the <code>run()</code> method of the runnable to
* be invoked by the user-interface thread at the next
@@ -1699,20 +1699,20 @@ public boolean sleep () {
*
* @see #asyncExec
*/
-public void syncExec (Runnable runnable) {
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
- synchronizer.syncExec (runnable);
-}
-
-int textWidth (String string, byte[] font) {
- if (string.length () == 0) return 0;
- byte [] textBuffer = Converter.wcsToMbcs (null, string, false);
- PhRect_t rect = new PhRect_t ();
- OS.PfExtentText(rect, null, font, textBuffer, textBuffer.length);
- if (rect.lr_x == rect.ul_x) return 0;
- return rect.lr_x - rect.ul_x + 1;
-}
-
+public void syncExec (Runnable runnable) {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ synchronizer.syncExec (runnable);
+}
+
+int textWidth (String string, byte[] font) {
+ if (string.length () == 0) return 0;
+ byte [] textBuffer = Converter.wcsToMbcs (null, string, false);
+ PhRect_t rect = new PhRect_t ();
+ OS.PfExtentText(rect, null, font, textBuffer, textBuffer.length);
+ if (rect.lr_x == rect.ul_x) return 0;
+ return rect.lr_x - rect.ul_x + 1;
+}
+
/**
* Causes the <code>run()</code> method of the runnable to
* be invoked by the user-interface thread after the specified
@@ -1731,91 +1731,91 @@ int textWidth (String string, byte[] font) {
*
* @see #asyncExec
*/
-public void timerExec (int milliseconds, Runnable runnable) {
- checkDevice ();
- if (runnable == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (timerList == null) timerList = new Runnable [4];
- if (timerIds == null) timerIds = new int [4];
- int index = 0;
- while (index < timerList.length) {
- if (timerList [index] == runnable) break;
- index++;
- }
- if (index != timerList.length) {
- OS.PtDestroyWidget (timerIds [index]);
- timerList [index] = null;
- timerIds [index] = 0;
- if (milliseconds < 0) return;
- } else {
- if (milliseconds < 0) return;
- 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 [] newTimerIds = new int [timerIds.length + 4];
- System.arraycopy (timerIds, 0, newTimerIds, 0, timerIds.length);
- timerIds = newTimerIds;
- }
- }
- int [] args = {OS.Pt_ARG_TIMER_INITIAL, milliseconds, 0};
- int timerId = OS.PtCreateWidget (OS.PtTimer (), timerHandle, args.length / 3, args);
- if (timerId != 0) {
- OS.PtRealizeWidget (timerId);
- OS.PtAddCallback (timerId, OS.Pt_CB_TIMER_ACTIVATE, timerProc, index);
- timerIds [index] = timerId;
- timerList [index] = runnable;
- }
-}
-
-int timerProc (int handle, int index, int info) {
- if (timerList == null) return 0;
- if (0 <= index && index < timerList.length) {
- int timerId = timerIds [index];
- Runnable runnable = timerList [index];
- timerList [index] = null;
- timerIds [index] = 0;
- if (runnable != null) runnable.run ();
- OS.PtDestroyWidget (timerId);
- }
- 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 timerExec (int milliseconds, Runnable runnable) {
+ checkDevice ();
+ if (runnable == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (timerList == null) timerList = new Runnable [4];
+ if (timerIds == null) timerIds = new int [4];
+ int index = 0;
+ while (index < timerList.length) {
+ if (timerList [index] == runnable) break;
+ index++;
+ }
+ if (index != timerList.length) {
+ OS.PtDestroyWidget (timerIds [index]);
+ timerList [index] = null;
+ timerIds [index] = 0;
+ if (milliseconds < 0) return;
+ } else {
+ if (milliseconds < 0) return;
+ 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 [] newTimerIds = new int [timerIds.length + 4];
+ System.arraycopy (timerIds, 0, newTimerIds, 0, timerIds.length);
+ timerIds = newTimerIds;
+ }
+ }
+ int [] args = {OS.Pt_ARG_TIMER_INITIAL, milliseconds, 0};
+ int timerId = OS.PtCreateWidget (OS.PtTimer (), timerHandle, args.length / 3, args);
+ if (timerId != 0) {
+ OS.PtRealizeWidget (timerId);
+ OS.PtAddCallback (timerId, OS.Pt_CB_TIMER_ACTIVATE, timerProc, index);
+ timerIds [index] = timerId;
+ timerList [index] = runnable;
+ }
+}
+
+int timerProc (int handle, int index, int info) {
+ if (timerList == null) return 0;
+ if (0 <= index && index < timerList.length) {
+ int timerId = timerIds [index];
+ Runnable runnable = timerList [index];
+ timerList [index] = null;
+ timerIds [index] = 0;
+ if (runnable != null) runnable.run ();
+ OS.PtDestroyWidget (timerId);
+ }
+ 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;
+}
+
/**
* Forces all outstanding paint requests for the display
* to be processed before this method returns.
*
* @see Control#update
*/
-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 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 ();
+ }
+ }
+}
+
/**
* If the receiver's user-interface thread was <code>sleep</code>'ing,
* causes it to be awakened and start running again. Note that this
@@ -1823,78 +1823,78 @@ public void update() {
*
* @see #sleep
*/
-public void wake () {
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
- if (!embedded && thread == Thread.currentThread ()) return;
-// 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.windowProc (handle, data, info);
-}
-
-int workProc (int data) {
- idle = true;
- return OS.Pt_CONTINUE;
-}
-
-String wrapText (String text, byte[] font, int width) {
- text = convertToLf (text);
- int length = text.length ();
- if (width <= 0 || length == 0 || length == 1) return text;
- StringBuffer result = new StringBuffer ();
- int lineStart = 0, lineEnd = 0;
- while (lineStart < length) {
- lineEnd = text.indexOf ('\n', lineStart);
- boolean noLf = lineEnd == -1;
- if (noLf) lineEnd = length;
- int nextStart = lineEnd + 1;
- while (lineEnd > lineStart + 1 && Compatibility.isWhitespace (text.charAt (lineEnd - 1))) {
- lineEnd--;
- }
- int wordStart = lineStart, wordEnd = lineStart;
- int i = lineStart;
- while (i < lineEnd) {
- int lastStart = wordStart, lastEnd = wordEnd;
- wordStart = i;
- while (i < lineEnd && !Compatibility.isWhitespace (text.charAt (i))) {
- i++;
- }
- wordEnd = i - 1;
- String line = text.substring (lineStart, wordEnd + 1);
- int lineWidth = textWidth (line, font);
- while (i < lineEnd && Compatibility.isWhitespace (text.charAt (i))) {
- i++;
- }
- if (lineWidth > width) {
- if (lastStart == wordStart) {
- while (wordStart < wordEnd) {
- line = text.substring (lineStart, wordStart + 1);
- lineWidth = textWidth (line, font);
- if (lineWidth >= width) break;
- wordStart++;
- }
- if (wordStart == lastStart) wordStart++;
- lastEnd = wordStart - 1;
- }
- line = text.substring (lineStart, lastEnd + 1);
- result.append (line); result.append ('\n');
- i = wordStart; lineStart = wordStart; wordEnd = wordStart;
- }
- }
- if (lineStart < lineEnd) {
- result.append (text.substring (lineStart, lineEnd));
- }
- if (!noLf) {
- result.append ('\n');
- }
- lineStart = nextStart;
- }
- return result.toString ();
-}
-
-}
+public void wake () {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ if (!embedded && thread == Thread.currentThread ()) return;
+// 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.windowProc (handle, data, info);
+}
+
+int workProc (int data) {
+ idle = true;
+ return OS.Pt_CONTINUE;
+}
+
+String wrapText (String text, byte[] font, int width) {
+ text = convertToLf (text);
+ int length = text.length ();
+ if (width <= 0 || length == 0 || length == 1) return text;
+ StringBuffer result = new StringBuffer ();
+ int lineStart = 0, lineEnd = 0;
+ while (lineStart < length) {
+ lineEnd = text.indexOf ('\n', lineStart);
+ boolean noLf = lineEnd == -1;
+ if (noLf) lineEnd = length;
+ int nextStart = lineEnd + 1;
+ while (lineEnd > lineStart + 1 && Compatibility.isWhitespace (text.charAt (lineEnd - 1))) {
+ lineEnd--;
+ }
+ int wordStart = lineStart, wordEnd = lineStart;
+ int i = lineStart;
+ while (i < lineEnd) {
+ int lastStart = wordStart, lastEnd = wordEnd;
+ wordStart = i;
+ while (i < lineEnd && !Compatibility.isWhitespace (text.charAt (i))) {
+ i++;
+ }
+ wordEnd = i - 1;
+ String line = text.substring (lineStart, wordEnd + 1);
+ int lineWidth = textWidth (line, font);
+ while (i < lineEnd && Compatibility.isWhitespace (text.charAt (i))) {
+ i++;
+ }
+ if (lineWidth > width) {
+ if (lastStart == wordStart) {
+ while (wordStart < wordEnd) {
+ line = text.substring (lineStart, wordStart + 1);
+ lineWidth = textWidth (line, font);
+ if (lineWidth >= width) break;
+ wordStart++;
+ }
+ if (wordStart == lastStart) wordStart++;
+ lastEnd = wordStart - 1;
+ }
+ line = text.substring (lineStart, lastEnd + 1);
+ result.append (line); result.append ('\n');
+ i = wordStart; lineStart = wordStart; wordEnd = wordStart;
+ }
+ }
+ if (lineStart < lineEnd) {
+ result.append (text.substring (lineStart, lineEnd));
+ }
+ if (!noLf) {
+ result.append ('\n');
+ }
+ lineStart = nextStart;
+ }
+ return result.toString ();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java
index 6aed157fae..9fa6ff6c4c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
/**
* Instances of this class allow the user to navigate
* the file system and select or enter a file name.
@@ -25,12 +25,12 @@ import org.eclipse.swt.*;
* within the SWT implementation.
* </p>
*/
-public class FileDialog extends Dialog {
- String [] filterNames = new String [0];
- String [] filterExtensions = new String [0];
- String filterPath = "", fileName = "";
- static final String FILTER = "*";
-
+public class FileDialog extends Dialog {
+ String [] filterNames = new String [0];
+ String [] filterExtensions = new String [0];
+ String filterPath = "", fileName = "";
+ static final String FILTER = "*";
+
/**
* Constructs a new instance of this class given only its
* parent.
@@ -53,10 +53,10 @@ public class FileDialog extends Dialog {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public FileDialog (Shell parent) {
- this (parent, SWT.PRIMARY_MODAL);
-}
-
+public FileDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -87,11 +87,11 @@ public FileDialog (Shell parent) {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public FileDialog (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
-
+public FileDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
+
/**
* Returns the path of the first file that was
* selected in the dialog relative to the filter path,
@@ -99,10 +99,10 @@ public FileDialog (Shell parent, int style) {
*
* @return the relative path of the file
*/
-public String getFileName () {
- return fileName;
-}
-
+public String getFileName () {
+ return fileName;
+}
+
/**
* Returns the paths of all files that were selected
* in the dialog relative to the filter path, or null
@@ -110,30 +110,30 @@ public String getFileName () {
*
* @return the relative paths of the files
*/
-public String [] getFileNames () {
- return new String [] {fileName};
-}
-
+public String [] getFileNames () {
+ return new String [] {fileName};
+}
+
/**
* Returns the file extensions which the dialog will
* use to filter the files it shows.
*
* @return the file extensions filter
*/
-public String [] getFilterExtensions () {
- return filterExtensions;
-}
-
+public String [] getFilterExtensions () {
+ return filterExtensions;
+}
+
/**
* Returns the file names which the dialog will
* use to filter the files it shows.
*
* @return the file name filter
*/
-public String [] getFilterNames () {
- return filterNames;
-}
-
+public String [] getFilterNames () {
+ return filterNames;
+}
+
/**
* Returns the directory path that the dialog will use.
* File names in this path will appear in the dialog,
@@ -143,10 +143,10 @@ public String [] getFilterNames () {
*
* @see #setFilterExtensions
*/
-public String getFilterPath () {
- return filterPath;
-}
-
+public String getFilterPath () {
+ return filterPath;
+}
+
/**
* Makes the dialog visible and brings it to the front
* of the display.
@@ -159,73 +159,73 @@ public String getFilterPath () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
* </ul>
*/
-public String open () {
- int parentHandle = 0;
- if (parent != null && OS.PtWidgetIsRealized(parent.shellHandle)) {
- 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 {
- 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);
- byte [] btn1_text = null;
- if ((style & SWT.SAVE) != 0) {
- btn1_text = Converter.wcsToMbcs(null, SWT.getMessage("SWT_Save"), true);
- }
- int flags = OS.Pt_FSR_NO_FCHECK;
- PtFileSelectionInfo_t info = new PtFileSelectionInfo_t ();
- OS.PtFileSelection (parentHandle, null, title, root_dir, file_spec, btn1_text, 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 String open () {
+ int parentHandle = 0;
+ if (parent != null && OS.PtWidgetIsRealized(parent.shellHandle)) {
+ 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 {
+ 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);
+ byte [] btn1_text = null;
+ if ((style & SWT.SAVE) != 0) {
+ btn1_text = Converter.wcsToMbcs(null, SWT.getMessage("SWT_Save"), true);
+ }
+ int flags = OS.Pt_FSR_NO_FCHECK;
+ PtFileSelectionInfo_t info = new PtFileSelectionInfo_t ();
+ OS.PtFileSelection (parentHandle, null, title, root_dir, file_spec, btn1_text, 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;
+}
+
/**
* Set the initial filename which the dialog will
* select by default when opened to the argument,
@@ -234,10 +234,10 @@ public String open () {
*
* @param string the file name
*/
-public void setFileName (String string) {
- fileName = string;
-}
-
+public void setFileName (String string) {
+ fileName = string;
+}
+
/**
* Set the file extensions which the dialog will
* use to filter the files it shows to the argument,
@@ -245,10 +245,10 @@ public void setFileName (String string) {
*
* @param extensions the file extension filter
*/
-public void setFilterExtensions (String [] extensions) {
- filterExtensions = extensions;
-}
-
+public void setFilterExtensions (String [] extensions) {
+ filterExtensions = extensions;
+}
+
/**
* Sets the file names which the dialog will
* use to filter the files it shows to the argument,
@@ -256,10 +256,10 @@ public void setFilterExtensions (String [] extensions) {
*
* @param names the file name filter
*/
-public void setFilterNames (String [] names) {
- filterNames = names;
-}
-
+public void setFilterNames (String [] names) {
+ filterNames = names;
+}
+
/**
* Sets the directory path that the dialog will use
* to the argument, which may be null. File names in this
@@ -270,8 +270,8 @@ public void setFilterNames (String [] names) {
*
* @see #setFilterExtensions
*/
-public void setFilterPath (String string) {
- filterPath = string;
-}
-
-}
+public void setFilterPath (String string) {
+ filterPath = string;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java
index 71325916e7..91cc77e697 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class allow the user to select a font
* from all available fonts in the system.
@@ -20,9 +20,9 @@ import org.eclipse.swt.graphics.*;
* within the SWT implementation.
* </p>
*/
-public class FontDialog extends Dialog {
- FontData fontData;
- RGB rgb;
+public class FontDialog extends Dialog {
+ FontData fontData;
+ RGB rgb;
/**
* Constructs a new instance of this class given only its
* parent.
@@ -45,9 +45,9 @@ public class FontDialog extends Dialog {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public FontDialog (Shell parent) {
- this (parent, SWT.PRIMARY_MODAL);
-}
+public FontDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -78,29 +78,29 @@ public FontDialog (Shell parent) {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public FontDialog (Shell parent, int style) {
- super (parent, style);
- checkSubclass ();
-}
+public FontDialog (Shell parent, int style) {
+ super (parent, style);
+ checkSubclass ();
+}
/**
* Returns a FontData object describing the font that was
* selected in the dialog, or null if none is available.
*
* @return the FontData for the selected font, or null
*/
-public FontData getFontData() {
- return fontData;
-}
-/**
- * Returns the currently selected color in the receiver.
- *
- * @return the RGB value for the selected color, may be null
- *
- * @see PaletteData#getRGBs
- */
-public RGB getRGB () {
- return rgb;
-}
+public FontData getFontData() {
+ return fontData;
+}
+/**
+ * Returns the currently selected color in the receiver.
+ *
+ * @return the RGB value for the selected color, may be null
+ *
+ * @see PaletteData#getRGBs
+ */
+public RGB getRGB () {
+ return rgb;
+}
/**
* Makes the dialog visible and brings it to the front
* of the display.
@@ -113,40 +113,40 @@ public RGB getRGB () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
* </ul>
*/
-public FontData open () {
- int parentHandle = 0;
- if (parent != null && OS.PtWidgetIsRealized(parent.shellHandle)) {
- 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 flags = OS.PHFONT_ALL_FONTS | OS.PHFONT_DONT_SHOW_LEGACY;
- int fontPtr = OS.PtFontSelection (parentHandle, null, title, font, OS.PHFONT_ALL_SYMBOLS, flags, null);
-
- if (fontPtr != 0) {
- int length = OS.strlen (fontPtr);
- font = new byte [length + 1];
- OS.memmove (font, fontPtr, length);
- fontData = FontData.photon_new (font);
- }
- return fontData;
-}
+public FontData open () {
+ int parentHandle = 0;
+ if (parent != null && OS.PtWidgetIsRealized(parent.shellHandle)) {
+ 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 flags = OS.PHFONT_ALL_FONTS | OS.PHFONT_DONT_SHOW_LEGACY;
+ int fontPtr = OS.PtFontSelection (parentHandle, null, title, font, OS.PHFONT_ALL_SYMBOLS, flags, null);
+
+ if (fontPtr != 0) {
+ int length = OS.strlen (fontPtr);
+ font = new byte [length + 1];
+ OS.memmove (font, fontPtr, length);
+ fontData = FontData.photon_new (font);
+ }
+ return fontData;
+}
/**
* Sets a FontData object describing the font to be
* selected by default in the dialog, or null to let
@@ -154,19 +154,19 @@ public FontData open () {
*
* @param fontData the FontData to use initially, or null
*/
-public void setFontData (FontData fontData) {
- this.fontData = fontData;
-}
-/**
- * Returns the receiver's selected color to be the argument.
- *
- * @param rgb the new RGB value for the selected color, may be
- * null to let the platform to select a default when
- * open() is called
- *
- * @see PaletteData#getRGBs
- */
-public void setRGB (RGB rgb) {
- this.rgb = rgb;
-}
-}
+public void setFontData (FontData fontData) {
+ this.fontData = fontData;
+}
+/**
+ * Returns the receiver's selected color to be the argument.
+ *
+ * @param rgb the new RGB value for the selected color, may be
+ * null to let the platform to select a default when
+ * open() is called
+ *
+ * @see PaletteData#getRGBs
+ */
+public void setRGB (RGB rgb) {
+ this.rgb = rgb;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java
index 30b0acaeb4..034847dbf3 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class provide an etched border
* with an optional title.
@@ -32,8 +32,8 @@ import org.eclipse.swt.graphics.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class Group extends Composite {
-
+public class Group extends Composite {
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -66,63 +66,63 @@ public class Group extends Composite {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Group (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-static int checkStyle (int style) {
- style |= SWT.NO_FOCUS;
- /*
- * 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) {
- checkWidget();
- 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) {
- state |= HANDLE;
- Display display = getDisplay ();
- int clazz = display.PtContainer;
- int parentHandle = parent.parentingHandle ();
- 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);
-}
-
-byte [] defaultFont () {
- Display display = getDisplay ();
- return display.GROUP_FONT;
-}
-
+public Group (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+ style |= SWT.NO_FOCUS;
+ /*
+ * 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) {
+ checkWidget();
+ 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) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int clazz = display.PtContainer;
+ int parentHandle = parent.parentingHandle ();
+ 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);
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.GROUP_FONT;
+}
+
/**
* Returns the receiver's text, which is the string that the
* is used as the <em>title</em>. If the text has not previously
@@ -135,42 +135,42 @@ byte [] defaultFont () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public String getText () {
- checkWidget();
- 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();
- int str = args [1];
- if (str != 0) {
- int length = OS.strlen (str);
- if (length > 0) {
- OS.PfExtentText(rect, null, args [4], str, 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);
-}
-
+public String getText () {
+ checkWidget();
+ 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();
+ int str = args [1];
+ if (str != 0) {
+ int length = OS.strlen (str);
+ if (length > 0) {
+ OS.PfExtentText(rect, null, args [4], str, 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);
+}
+
/**
* Sets the receiver's text, which is the string that will
* be displayed as the receiver's <em>title</em>, to the argument,
@@ -186,23 +186,23 @@ Point getTitleSize() {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- int flags = OS.Pt_SHOW_TITLE | OS.Pt_ETCH_TITLE_AREA;
- byte [] buffer = Converter.wcsToMbcs (null, stripMnemonics (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);
-}
-
-int widgetClass () {
- return OS.PtContainer ();
-}
-
-}
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int flags = OS.Pt_SHOW_TITLE | OS.Pt_ETCH_TITLE_AREA;
+ byte [] buffer = Converter.wcsToMbcs (null, stripMnemonics (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);
+}
+
+int widgetClass () {
+ return OS.PtContainer ();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java
index 8967808c6c..18c43dc3f9 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class represent a non-selectable
* user interface object that displays a string or image.
@@ -34,10 +34,10 @@ import org.eclipse.swt.graphics.*;
* within the SWT implementation.
* </p>
*/
-public class Label extends Control {
- String text = "";
- Image image;
-
+public class Label extends Control {
+ String text = "";
+ Image image;
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -75,136 +75,136 @@ public class Label extends Control {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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) {
- checkWidget();
- if ((style & SWT.SEPARATOR) != 0) {
- int border = getBorderWidth ();
- int width = border * 2, height = border * 2;
- if ((style & SWT.HORIZONTAL) != 0) {
- width += DEFAULT_WIDTH; height += 3;
- } else {
- 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);
- }
-
- if ((style & SWT.WRAP) != 0) {
- int [] args = {
- OS.Pt_ARG_LABEL_TYPE, 0, 0, // 1
- OS.Pt_ARG_TEXT_FONT, 0, 0, // 4
- OS.Pt_ARG_LINE_SPACING, 0, 0, // 7
- OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 10
- OS.Pt_ARG_MARGIN_HEIGHT, 0, 0, // 13
- OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 16
- OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 19
- OS.Pt_ARG_MARGIN_TOP, 0, 0, // 22
- OS.Pt_ARG_MARGIN_BOTTOM, 0, 0, // 25
- };
- OS.PtGetResources (handle, args.length / 3, args);
- /* If we are wrapping text, calculate the height based on wHint. */
- if (args [1] == OS.Pt_Z_STRING) {
- int width = wHint, height = hHint;
- if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
- int length = OS.strlen (args [4]);
- byte [] font = new byte [length + 1];
- OS.memmove (font, args [4], length);
- String string = text;
- if (wHint != SWT.DEFAULT) {
- Display display = getDisplay ();
- string = display.wrapText (text, font, wHint);
- }
- byte [] buffer = Converter.wcsToMbcs (null, string, false);
- PhRect_t rect = new PhRect_t ();
- OS.PgExtentMultiText (rect, null, font, buffer, buffer.length, args [7]);
- if (wHint == SWT.DEFAULT) width = rect.lr_x - rect.ul_x + 1;
- if (hHint == SWT.DEFAULT) height = rect.lr_y - rect.ul_y + 1;
- }
- PhArea_t area = new PhArea_t ();
+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) {
+ checkWidget();
+ if ((style & SWT.SEPARATOR) != 0) {
+ int border = getBorderWidth ();
+ int width = border * 2, height = border * 2;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ width += DEFAULT_WIDTH; height += 3;
+ } else {
+ 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);
+ }
+
+ if ((style & SWT.WRAP) != 0) {
+ int [] args = {
+ OS.Pt_ARG_LABEL_TYPE, 0, 0, // 1
+ OS.Pt_ARG_TEXT_FONT, 0, 0, // 4
+ OS.Pt_ARG_LINE_SPACING, 0, 0, // 7
+ OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 10
+ OS.Pt_ARG_MARGIN_HEIGHT, 0, 0, // 13
+ OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 16
+ OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 19
+ OS.Pt_ARG_MARGIN_TOP, 0, 0, // 22
+ OS.Pt_ARG_MARGIN_BOTTOM, 0, 0, // 25
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ /* If we are wrapping text, calculate the height based on wHint. */
+ if (args [1] == OS.Pt_Z_STRING) {
+ int width = wHint, height = hHint;
+ if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
+ int length = OS.strlen (args [4]);
+ byte [] font = new byte [length + 1];
+ OS.memmove (font, args [4], length);
+ String string = text;
+ if (wHint != SWT.DEFAULT) {
+ Display display = getDisplay ();
+ string = display.wrapText (text, font, wHint);
+ }
+ byte [] buffer = Converter.wcsToMbcs (null, string, false);
+ PhRect_t rect = new PhRect_t ();
+ OS.PgExtentMultiText (rect, null, font, buffer, buffer.length, args [7]);
+ if (wHint == SWT.DEFAULT) width = rect.lr_x - rect.ul_x + 1;
+ if (hHint == SWT.DEFAULT) height = rect.lr_y - rect.ul_y + 1;
+ }
+ PhArea_t area = new PhArea_t ();
PhRect_t rect = new PhRect_t ();
- OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
- width += (area.size_w - 1) + (args [10] * 2) + args [16] + args [19];
- height += (area.size_h - 1) + (args [13] * 2) + args [22] + args [25];
- return new Point (width, height);
- }
- }
-
- PhDim_t dim = new PhDim_t();
- if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
- OS.PtWidgetPreferredSize(handle, dim);
- int width = dim.w, height = dim.h;
- if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
- int [] args = {
- OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 1
- OS.Pt_ARG_MARGIN_HEIGHT, 0, 0, // 4
- OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 7
- OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 10
- OS.Pt_ARG_MARGIN_TOP, 0, 0, // 13
- OS.Pt_ARG_MARGIN_BOTTOM, 0, 0, // 16
- };
- OS.PtGetResources (handle, args.length / 3, args);
- PhRect_t rect = new PhRect_t ();
- PhArea_t area = new PhArea_t ();
- rect.lr_x = (short) (wHint - 1);
- rect.lr_y = (short) (hHint - 1);
- OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
- if (wHint != SWT.DEFAULT) {
- width = area.size_w + (args [1] * 2) + args [7] + args [10];
- }
- if (hHint != SWT.DEFAULT) {
- height = area.size_h + (args [4] * 2) + args [13] + args [16];
- }
- }
- return new Point (width, height);
-}
-
-void createHandle (int index) {
- state |= HANDLE;
- Display display = getDisplay ();
- int parentHandle = parent.parentingHandle ();
-
- 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_FILL_COLOR, display.WIDGET_BACKGROUND, 0,
- OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
- };
- handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
- 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 verticalAlign = (style & SWT.WRAP) != 0 ? OS.Pt_TOP : OS.Pt_CENTER;
- boolean hasBorder = (style & SWT.BORDER) != 0;
- int [] args = {
- OS.Pt_ARG_FLAGS, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
- OS.Pt_ARG_HORIZONTAL_ALIGNMENT, alignment, 0,
- OS.Pt_ARG_VERTICAL_ALIGNMENT, verticalAlign, 0,
- OS.Pt_ARG_FILL_COLOR, display.WIDGET_BACKGROUND, 0,
- OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
- };
- handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
-}
-
+ OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
+ width += (area.size_w - 1) + (args [10] * 2) + args [16] + args [19];
+ height += (area.size_h - 1) + (args [13] * 2) + args [22] + args [25];
+ return new Point (width, height);
+ }
+ }
+
+ PhDim_t dim = new PhDim_t();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
+ OS.PtWidgetPreferredSize(handle, dim);
+ int width = dim.w, height = dim.h;
+ if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ int [] args = {
+ OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 1
+ OS.Pt_ARG_MARGIN_HEIGHT, 0, 0, // 4
+ OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 7
+ OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 10
+ OS.Pt_ARG_MARGIN_TOP, 0, 0, // 13
+ OS.Pt_ARG_MARGIN_BOTTOM, 0, 0, // 16
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ PhRect_t rect = new PhRect_t ();
+ PhArea_t area = new PhArea_t ();
+ rect.lr_x = (short) (wHint - 1);
+ rect.lr_y = (short) (hHint - 1);
+ OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
+ if (wHint != SWT.DEFAULT) {
+ width = area.size_w + (args [1] * 2) + args [7] + args [10];
+ }
+ if (hHint != SWT.DEFAULT) {
+ height = area.size_h + (args [4] * 2) + args [13] + args [16];
+ }
+ }
+ return new Point (width, height);
+}
+
+void createHandle (int index) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int parentHandle = parent.parentingHandle ();
+
+ 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_FILL_COLOR, display.WIDGET_BACKGROUND, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ 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 verticalAlign = (style & SWT.WRAP) != 0 ? OS.Pt_TOP : OS.Pt_CENTER;
+ boolean hasBorder = (style & SWT.BORDER) != 0;
+ int [] args = {
+ OS.Pt_ARG_FLAGS, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
+ OS.Pt_ARG_HORIZONTAL_ALIGNMENT, alignment, 0,
+ OS.Pt_ARG_VERTICAL_ALIGNMENT, verticalAlign, 0,
+ OS.Pt_ARG_FILL_COLOR, display.WIDGET_BACKGROUND, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
/**
* Returns a value which describes the position of the
* text or image in the receiver. The value will be one of
@@ -219,15 +219,15 @@ void createHandle (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getAlignment () {
- checkWidget();
- 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 int getAlignment () {
+ checkWidget();
+ 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;
+}
+
/**
* Returns the receiver's image if it has one, or null
* if it does not.
@@ -239,15 +239,15 @@ public int getAlignment () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Image getImage () {
- checkWidget();
- return image;
-}
-
-String getNameText () {
- return getText ();
-}
-
+public Image getImage () {
+ checkWidget();
+ return image;
+}
+
+String getNameText () {
+ return getText ();
+}
+
/**
* Returns the receiver's text, which will be an empty
* string if it has never been set or if the receiver is
@@ -260,36 +260,36 @@ String getNameText () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public String getText () {
- checkWidget();
- if ((style & SWT.SEPARATOR) != 0) return "";
- return text;
-}
-
-int hotkeyProc (int widget, int data, int info) {
- Composite control = this.parent;
- while (control != null) {
- Control [] children = control._getChildren ();
- int index = 0;
- while (index < children.length) {
- if (children [index] == this) break;
- index++;
- }
- index++;
- if (index < children.length) {
- if (children [index].setFocus ()) return OS.Pt_CONTINUE;
- }
- control = control.parent;
- }
- return OS.Pt_CONTINUE;
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- image = null;
- text = null;
-}
-
+public String getText () {
+ checkWidget();
+ if ((style & SWT.SEPARATOR) != 0) return "";
+ return text;
+}
+
+int hotkeyProc (int widget, int data, int info) {
+ Composite control = this.parent;
+ while (control != null) {
+ Control [] children = control._getChildren ();
+ int index = 0;
+ while (index < children.length) {
+ if (children [index] == this) break;
+ index++;
+ }
+ index++;
+ if (index < children.length) {
+ if (children [index].setFocus ()) return OS.Pt_CONTINUE;
+ }
+ control = control.parent;
+ }
+ return OS.Pt_CONTINUE;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ image = null;
+ text = null;
+}
+
/**
* Controls how text and images will be displayed in the receiver.
* The argument should be one of <code>LEFT</code>, <code>RIGHT</code>
@@ -303,34 +303,34 @@ void releaseWidget () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setAlignment (int alignment) {
- checkWidget();
- 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 align = OS.Pt_LEFT;
- if ((style & SWT.CENTER) != 0) align = OS.Pt_CENTER;
- if ((style & SWT.RIGHT) != 0) align = OS.Pt_RIGHT;
- OS.PtSetResource (handle, OS.Pt_ARG_HORIZONTAL_ALIGNMENT, align, 0);
-}
-
-int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
- int result = super.setBounds (x, y, width, height, move, resize, events);
- if ((result & RESIZED) != 0 && (style & SWT.WRAP) != 0) setText (text);
- return result;
-}
-
-public boolean setFocus () {
- checkWidget();
- return false;
-}
-
-public void setFont (Font font) {
- super.setFont (font);
- if ((style & SWT.WRAP) != 0) setText (text);
-}
-
+public void setAlignment (int alignment) {
+ checkWidget();
+ 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 align = OS.Pt_LEFT;
+ if ((style & SWT.CENTER) != 0) align = OS.Pt_CENTER;
+ if ((style & SWT.RIGHT) != 0) align = OS.Pt_RIGHT;
+ OS.PtSetResource (handle, OS.Pt_ARG_HORIZONTAL_ALIGNMENT, align, 0);
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
+ int result = super.setBounds (x, y, width, height, move, resize, events);
+ if ((result & RESIZED) != 0 && (style & SWT.WRAP) != 0) setText (text);
+ return result;
+}
+
+public boolean setFocus () {
+ checkWidget();
+ return false;
+}
+
+public void setFont (Font font) {
+ super.setFont (font);
+ if ((style & SWT.WRAP) != 0) setText (text);
+}
+
/**
* Sets the receiver's image to the argument, which may be
* null indicating that no image should be displayed.
@@ -345,23 +345,23 @@ public void setFont (Font font) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setImage (Image image) {
- checkWidget();
- if ((style & SWT.SEPARATOR) != 0) return;
- this.image = image;
- int imageHandle = 0;
- if (image != null) {
- if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- imageHandle = copyPhImage (image.handle);
- }
- 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 setImage (Image image) {
+ checkWidget();
+ if ((style & SWT.SEPARATOR) != 0) return;
+ this.image = image;
+ int imageHandle = 0;
+ if (image != null) {
+ if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ imageHandle = copyPhImage (image.handle);
+ }
+ 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);
+}
+
/**
* Sets the receiver's text.
* <p>
@@ -379,71 +379,71 @@ public void setImage (Image image) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if ((style & SWT.SEPARATOR) != 0) return;
- text = string;
- char [] unicode = new char [string.length ()];
- string.getChars (0, unicode.length, unicode, 0);
- int i=0, j=0;
- char mnemonic=0;
- while (i < unicode.length) {
- if ((unicode [j++] = unicode [i++]) == Mnemonic) {
- if (i == unicode.length) {continue;}
- if (unicode [i] == Mnemonic) {i++; continue;}
- if (mnemonic == 0) mnemonic = unicode [i];
- j--;
- }
- }
- while (j < unicode.length) unicode [j++] = 0;
- /* Wrap the text if necessary, and convert to mbcs. */
- byte [] buffer;
- if ((style & SWT.WRAP) != 0) {
- int [] args = {
- OS.Pt_ARG_TEXT_FONT, 0, 0, // 1
- OS.Pt_ARG_WIDTH, 0, 0, // 4
- OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 7
- OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 10
- OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 13
- };
- OS.PtGetResources (handle, args.length / 3, args);
- int length = OS.strlen (args [1]);
- byte [] font = new byte [length + 1];
- OS.memmove (font, args [1], length);
- int border = 0;
- if ((style & SWT.BORDER) != 0) border = 2;
- int width = args [4];
- width -= (args [7] * 2) + args [10] + args [13] + border * 2;
- Display display = getDisplay ();
- if (mnemonic != '\0') string = new String (unicode);
- string = display.wrapText (string, font, width);
- buffer = Converter.wcsToMbcs (null, string, true);
- } else {
- buffer = Converter.wcsToMbcs (null, unicode, true);
- }
- int ptr = OS.malloc (buffer.length);
- OS.memmove (ptr, buffer, buffer.length);
- int ptr2 = 0;
- if (mnemonic != 0) {
- byte [] buffer2 = Converter.wcsToMbcs (null, new char []{mnemonic}, true);
- ptr2 = OS.malloc (buffer2.length);
- OS.memmove (ptr2, buffer2, buffer2.length);
- }
- replaceMnemonic (mnemonic, true, true);
- 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);
-}
-
-int widgetClass () {
- if ((style & SWT.SEPARATOR) != 0) return OS.PtSeparator ();
- return OS.PtLabel ();
-}
-
-}
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ text = string;
+ char [] unicode = new char [string.length ()];
+ string.getChars (0, unicode.length, unicode, 0);
+ int i=0, j=0;
+ char mnemonic=0;
+ while (i < unicode.length) {
+ if ((unicode [j++] = unicode [i++]) == Mnemonic) {
+ if (i == unicode.length) {continue;}
+ if (unicode [i] == Mnemonic) {i++; continue;}
+ if (mnemonic == 0) mnemonic = unicode [i];
+ j--;
+ }
+ }
+ while (j < unicode.length) unicode [j++] = 0;
+ /* Wrap the text if necessary, and convert to mbcs. */
+ byte [] buffer;
+ if ((style & SWT.WRAP) != 0) {
+ int [] args = {
+ OS.Pt_ARG_TEXT_FONT, 0, 0, // 1
+ OS.Pt_ARG_WIDTH, 0, 0, // 4
+ OS.Pt_ARG_MARGIN_WIDTH, 0, 0, // 7
+ OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 10
+ OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 13
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ int length = OS.strlen (args [1]);
+ byte [] font = new byte [length + 1];
+ OS.memmove (font, args [1], length);
+ int border = 0;
+ if ((style & SWT.BORDER) != 0) border = 2;
+ int width = args [4];
+ width -= (args [7] * 2) + args [10] + args [13] + border * 2;
+ Display display = getDisplay ();
+ if (mnemonic != '\0') string = new String (unicode);
+ string = display.wrapText (string, font, width);
+ buffer = Converter.wcsToMbcs (null, string, true);
+ } else {
+ buffer = Converter.wcsToMbcs (null, unicode, true);
+ }
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int ptr2 = 0;
+ if (mnemonic != 0) {
+ byte [] buffer2 = Converter.wcsToMbcs (null, new char []{mnemonic}, true);
+ ptr2 = OS.malloc (buffer2.length);
+ OS.memmove (ptr2, buffer2, buffer2.length);
+ }
+ replaceMnemonic (mnemonic, true, true);
+ 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);
+}
+
+int widgetClass () {
+ if ((style & SWT.SEPARATOR) != 0) return OS.PtSeparator ();
+ return OS.PtLabel ();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
index f0a4ad9438..a47e159cfe 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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.*;
+
/**
* Instances of this class represent a selectable user interface
* object that displays a list of strings and issues notificiation
@@ -30,8 +30,8 @@ import org.eclipse.swt.events.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class List extends Scrollable {
-
+public class List extends Scrollable {
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -61,14 +61,14 @@ public class List extends Scrollable {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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 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);
+}
+
/**
* Adds the argument to the end of the receiver's list.
*
@@ -87,16 +87,16 @@ static int checkStyle (int style) {
*
* @see #add(String,int)
*/
-public void add (String string) {
- checkWidget();
- 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) {
+ checkWidget();
+ 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);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver's selection changes, by sending
@@ -121,14 +121,14 @@ public void add (String string) {
* @see #removeSelectionListener
* @see SelectionEvent
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
/**
* Adds the argument to the receiver's list at the given
* zero-relative index.
@@ -155,108 +155,108 @@ public void addSelectionListener(SelectionListener listener) {
*
* @see #add(String)
*/
-public void add (String string, int index) {
- checkWidget();
- 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) {
- checkWidget();
-
- int [] args = new int [] {
- OS.Pt_ARG_WIDTH, 0, 0,
- OS.Pt_ARG_HEIGHT, 0, 0,
- OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
- };
- OS.PtGetResources (handle, args.length / 3, args);
- int resizeFlags = OS.Pt_RESIZE_X_ALWAYS | OS.Pt_RESIZE_Y_ALWAYS;
- OS.PtSetResource (handle, OS.Pt_ARG_RESIZE_FLAGS, resizeFlags, OS.Pt_RESIZE_XY_BITS);
- if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
- PhDim_t dim = new PhDim_t ();
- OS.PtWidgetPreferredSize (handle, dim);
- int width = dim.w, height = dim.h;
- OS.PtSetResource (handle, OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS);
- OS.PtSetResources (handle, args.length / 3, args);
- if (args [7] <= 0) {
- width += DEFAULT_WIDTH;
- height += DEFAULT_HEIGHT;
- }
+public void add (String string, int index) {
+ checkWidget();
+ 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) {
+ checkWidget();
+
+ int [] args = new int [] {
+ OS.Pt_ARG_WIDTH, 0, 0,
+ OS.Pt_ARG_HEIGHT, 0, 0,
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ int resizeFlags = OS.Pt_RESIZE_X_ALWAYS | OS.Pt_RESIZE_Y_ALWAYS;
+ OS.PtSetResource (handle, OS.Pt_ARG_RESIZE_FLAGS, resizeFlags, OS.Pt_RESIZE_XY_BITS);
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
+ PhDim_t dim = new PhDim_t ();
+ OS.PtWidgetPreferredSize (handle, dim);
+ int width = dim.w, height = dim.h;
+ OS.PtSetResource (handle, OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS);
+ OS.PtSetResources (handle, args.length / 3, args);
+ if (args [7] <= 0) {
+ width += DEFAULT_WIDTH;
+ height += DEFAULT_HEIGHT;
+ }
- 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);
-}
-
-void createHandle (int index) {
- state |= HANDLE;
- Display display = getDisplay ();
- int clazz = display.PtList;
- int parentHandle = parent.parentingHandle ();
- 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;
- boolean hasBorder = (style & SWT.BORDER) != 0;
- int listFlags = OS.Pt_LIST_SCROLLBAR_ALWAYS | OS.Pt_LIST_SCROLLBAR_AS_REQUIRED;
- int [] args = {
- OS.Pt_ARG_FLAGS, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
- OS.Pt_ARG_SELECTION_MODE, mode, 0,
- OS.Pt_ARG_FLAGS, OS.Pt_SELECTABLE | OS.Pt_SELECT_NOREDRAW, OS.Pt_SELECTABLE | OS.Pt_SELECT_NOREDRAW,
- OS.Pt_ARG_LIST_FLAGS, (style & SWT.V_SCROLL) != 0 ? OS.Pt_LIST_SCROLLBAR_AS_REQUIRED : 0, listFlags,
- 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);
- createStandardScrollBars ();
-}
-
-int defaultBackground () {
- Display display = getDisplay ();
- return display.LIST_BACKGROUND;
-}
-
-byte [] defaultFont () {
- Display display = getDisplay ();
- return display.LIST_FONT;
-}
-
-int defaultForeground () {
- Display display = getDisplay ();
- return display.LIST_FOREGROUND;
-}
-
+ 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);
+}
+
+void createHandle (int index) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int clazz = display.PtList;
+ int parentHandle = parent.parentingHandle ();
+ 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;
+ boolean hasBorder = (style & SWT.BORDER) != 0;
+ int listFlags = OS.Pt_LIST_SCROLLBAR_ALWAYS | OS.Pt_LIST_SCROLLBAR_AS_REQUIRED;
+ int [] args = {
+ OS.Pt_ARG_FLAGS, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
+ OS.Pt_ARG_SELECTION_MODE, mode, 0,
+ OS.Pt_ARG_FLAGS, OS.Pt_SELECTABLE | OS.Pt_SELECT_NOREDRAW, OS.Pt_SELECTABLE | OS.Pt_SELECT_NOREDRAW,
+ OS.Pt_ARG_LIST_FLAGS, (style & SWT.V_SCROLL) != 0 ? OS.Pt_LIST_SCROLLBAR_AS_REQUIRED : 0, listFlags,
+ 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);
+ createStandardScrollBars ();
+}
+
+int defaultBackground () {
+ Display display = getDisplay ();
+ return display.LIST_BACKGROUND;
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.LIST_FONT;
+}
+
+int defaultForeground () {
+ Display display = getDisplay ();
+ return display.LIST_FOREGROUND;
+}
+
/**
* Deselects the item at the given zero-relative index in the receiver.
* If the item at the index was already deselected, it remains
@@ -269,12 +269,12 @@ int defaultForeground () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void deselect (int index) {
- checkWidget();
- if (index < 0) return;
- OS.PtListUnselectPos (handle, index + 1);
-}
-
+public void deselect (int index) {
+ checkWidget();
+ if (index < 0) return;
+ OS.PtListUnselectPos (handle, index + 1);
+}
+
/**
* Deselects the items at the given zero-relative indices in the receiver.
* If the item at the given zero-relative index in the receiver
@@ -290,22 +290,22 @@ public void deselect (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void deselect (int start, int end) {
- checkWidget();
- if (start > end) return;
- if ((style & SWT.SINGLE) != 0) {
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- int count = args [1];
- int index = Math.min (count - 1, end);
- if (index >= start) deselect (index);
- return;
- }
- for (int i=start; i<=end; i++) {
- OS.PtListUnselectPos (handle, i + 1);
- }
-}
-
+public void deselect (int start, int end) {
+ checkWidget();
+ if (start > end) return;
+ if ((style & SWT.SINGLE) != 0) {
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ int index = Math.min (count - 1, end);
+ if (index >= start) deselect (index);
+ return;
+ }
+ for (int i=start; i<=end; i++) {
+ OS.PtListUnselectPos (handle, i + 1);
+ }
+}
+
/**
* Deselects the items at the given zero-relative indices in the receiver.
* If the item at the given zero-relative index in the receiver
@@ -323,18 +323,18 @@ public void deselect (int start, int end) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void deselect (int [] indices) {
- checkWidget();
- 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 deselect (int [] indices) {
+ checkWidget();
+ 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);
+ }
+ }
+}
+
/**
* Deselects all selected items in the receiver.
*
@@ -343,16 +343,16 @@ public void deselect (int [] indices) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void deselectAll () {
- checkWidget();
- 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 void deselectAll () {
+ checkWidget();
+ 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);
+ }
+}
+
/**
* Returns the zero-relative index of the item which is currently
* has the focus in the receiver, or -1 if no item is has focus.
@@ -364,10 +364,10 @@ public void deselectAll () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getFocusIndex () {
- return getSelectionIndex ();
-}
-
+public int getFocusIndex () {
+ return getSelectionIndex ();
+}
+
/**
* Returns the item at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
@@ -386,25 +386,25 @@ public int getFocusIndex () {
* <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public String getItem (int index) {
- checkWidget();
- 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 String getItem (int index) {
+ checkWidget();
+ 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);
+}
+
/**
* Returns the number of items contained in the receiver.
*
@@ -418,13 +418,13 @@ public String getItem (int index) {
* <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public int getItemCount () {
- checkWidget();
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getItemCount () {
+ checkWidget();
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the height of the area which would be used to
* display <em>one</em> of the items in the tree.
@@ -439,25 +439,25 @@ public int getItemCount () {
* <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public int getItemHeight () {
- checkWidget();
- 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 int getItemHeight () {
+ checkWidget();
+ 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];
+}
+
/**
* Returns an array of <code>String</code>s which are the items
* in the receiver.
@@ -478,27 +478,27 @@ public int getItemHeight () {
* <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure while getting the item count</li>
* </ul>
*/
-public String [] getItems () {
- checkWidget();
- 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 [] getItems () {
+ checkWidget();
+ 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;
+
+}
+
/**
* Returns an array of <code>String</code>s that are currently
* selected in the receiver. An empty array indicates that no
@@ -519,16 +519,16 @@ public String [] getItems () {
* <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
* </ul>
*/
-public String [] getSelection () {
- checkWidget();
- 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 String [] getSelection () {
+ checkWidget();
+ int [] indices = getSelectionIndices ();
+ String [] result = new String [indices.length];
+ for (int i=0; i<indices.length; i++) {
+ result [i] = getItem (indices [i]);
+ }
+ return result;
+}
+
/**
* Returns the number of selected items contained in the receiver.
*
@@ -542,13 +542,13 @@ public String [] getSelection () {
* <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public int getSelectionCount () {
- checkWidget();
- int [] args = new int [] {OS.Pt_ARG_LIST_SEL_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getSelectionCount () {
+ checkWidget();
+ int [] args = new int [] {OS.Pt_ARG_LIST_SEL_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the zero-relative index of the item which is currently
* selected in the receiver, or -1 if no item is selected.
@@ -563,19 +563,19 @@ public int getSelectionCount () {
* <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public int getSelectionIndex () {
- checkWidget();
- 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 getSelectionIndex () {
+ checkWidget();
+ 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;
+}
+
/**
* Returns the zero-relative indices of the items which are currently
* selected in the receiver. The array is empty if no items are selected.
@@ -594,22 +594,22 @@ public int getSelectionIndex () {
* <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public int [] getSelectionIndices () {
- checkWidget();
- 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 [] getSelectionIndices () {
+ checkWidget();
+ 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;
+}
+
/**
* Returns the zero-relative index of the item which is currently
* at the top of the receiver. This index can change when items are
@@ -622,20 +622,20 @@ public int [] getSelectionIndices () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getTopIndex () {
- checkWidget();
- int [] args = new int [] {OS.Pt_ARG_TOP_ITEM_POS, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1] - 1;
-}
-
-void hookEvents () {
- super.hookEvents ();
- int windowProc = getDisplay ().windowProc;
- OS.PtAddCallback (handle, OS.Pt_CB_SELECTION, windowProc, OS.Pt_CB_SELECTION);
- OS.PtAddCallback (handle, OS.Pt_CB_ACTIVATE, windowProc, OS.Pt_CB_ACTIVATE);
-}
-
+public int getTopIndex () {
+ checkWidget();
+ int [] args = new int [] {OS.Pt_ARG_TOP_ITEM_POS, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1] - 1;
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_SELECTION, windowProc, OS.Pt_CB_SELECTION);
+ OS.PtAddCallback (handle, OS.Pt_CB_ACTIVATE, windowProc, OS.Pt_CB_ACTIVATE);
+}
+
/**
* Gets the index of an item.
* <p>
@@ -655,12 +655,12 @@ void hookEvents () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int indexOf (String string) {
- checkWidget();
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- return OS.PtListItemPos (handle, buffer) - 1;
-}
-
+public int indexOf (String string) {
+ checkWidget();
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ return OS.PtListItemPos (handle, buffer) - 1;
+}
+
/**
* Searches the receiver's list starting at the given,
* zero-relative index until an item is found that is equal
@@ -683,28 +683,28 @@ public int indexOf (String string) {
* <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
* </ul>
*/
-public int indexOf (String string, int start) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (start == 0) return indexOf(string);
- 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 count = args [1];
- if (!(0 <= start && start < count)) return -1;
- int [] item = new int [1];
- for (int index=start; index<count; index++) {
- OS.memmove (item, args [4] + (index * 4), 4);
- int length = OS.strlen (item [0]);
- byte [] buffer = new byte [length];
- OS.memmove (buffer, item [0], length);
- if (string.equals(new String (Converter.mbcsToWcs (null, buffer)))) return index;
- }
- return -1;
-}
-
+public int indexOf (String string, int start) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (start == 0) return indexOf(string);
+ 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 count = args [1];
+ if (!(0 <= start && start < count)) return -1;
+ int [] item = new int [1];
+ for (int index=start; index<count; index++) {
+ OS.memmove (item, args [4] + (index * 4), 4);
+ int length = OS.strlen (item [0]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, item [0], length);
+ if (string.equals(new String (Converter.mbcsToWcs (null, buffer)))) return index;
+ }
+ return -1;
+}
+
/**
* Returns <code>true</code> if the item is selected,
* and <code>false</code> otherwise. Indices out of
@@ -718,37 +718,37 @@ public int indexOf (String string, int start) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean isSelected (int index) {
- checkWidget();
- 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 Pt_CB_ACTIVATE (int widget, 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 Pt_CB_SELECTION (int widget, int info) {
- postEvent (SWT.Selection);
- return OS.Pt_CONTINUE;
-}
-
+public boolean isSelected (int index) {
+ checkWidget();
+ 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 Pt_CB_ACTIVATE (int widget, 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 Pt_CB_SELECTION (int widget, int info) {
+ postEvent (SWT.Selection);
+ return OS.Pt_CONTINUE;
+}
+
/**
* Removes the item from the receiver at the given
* zero-relative index.
@@ -766,15 +766,15 @@ int Pt_CB_SELECTION (int widget, int info) {
* <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public void remove (int index) {
- checkWidget();
- 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 (int index) {
+ checkWidget();
+ 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);
+}
+
/**
* Searches the receiver's list starting at the first item
* until an item is found that is equal to the argument,
@@ -794,13 +794,13 @@ public void remove (int index) {
* <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public void remove (String string) {
- checkWidget();
- int index = indexOf (string, 0);
- if (index == -1) error (SWT.ERROR_ITEM_NOT_REMOVED);
- remove (index);
-}
-
+public void remove (String string) {
+ checkWidget();
+ int index = indexOf (string, 0);
+ if (index == -1) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ remove (index);
+}
+
/**
* Removes the items from the receiver at the given
* zero-relative indices.
@@ -818,23 +818,23 @@ public void remove (String string) {
* <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public void remove (int [] indices) {
- checkWidget();
- if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
- int [] newIndices = new int [indices.length];
- System.arraycopy (indices, 0, newIndices, 0, indices.length);
- sort (newIndices);
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- int count = args [1];
- for (int i=0; i<newIndices.length; i++ ) {
- int index = newIndices [i];
- if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
- int result = OS.PtListDeleteItemPos (handle, 1, index + 1);
- if (result != 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
- }
-}
-
+public void remove (int [] indices) {
+ checkWidget();
+ if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int [] newIndices = new int [indices.length];
+ System.arraycopy (indices, 0, newIndices, 0, indices.length);
+ sort (newIndices);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ for (int i=0; i<newIndices.length; i++ ) {
+ int index = newIndices [i];
+ if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
+ int result = OS.PtListDeleteItemPos (handle, 1, index + 1);
+ if (result != 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+}
+
/**
* Removes the items from the receiver which are
* between the given zero-relative start and end
@@ -854,18 +854,18 @@ public void remove (int [] indices) {
* <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public void remove (int start, int end) {
- checkWidget();
- 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 start, int end) {
+ checkWidget();
+ 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);
+}
+
/**
* Removes all of the items from the receiver.
* <p>
@@ -874,11 +874,11 @@ public void remove (int start, int end) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void removeAll () {
- checkWidget();
- OS.PtListDeleteAllItems (handle);
-}
-
+public void removeAll () {
+ checkWidget();
+ OS.PtListDeleteAllItems (handle);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver's selection changes.
@@ -896,14 +896,14 @@ public void removeAll () {
* @see SelectionListener
* @see #addSelectionListener
*/
-public void removeSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
+public void removeSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
/**
* Selects the items at the given zero-relative indices in the receiver.
* If the item at the index was already selected, it remains
@@ -918,27 +918,27 @@ public void removeSelectionListener(SelectionListener listener) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void select (int start, int end) {
- checkWidget();
- if (start > end) return;
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- int count = args [1];
- if ((style & SWT.SINGLE) != 0) {
- int index = Math.min (count - 1, end);
- if (index >= start) select (index);
- return;
- }
- int gotoIndex = -1;
- for (int index=end; index>=start; index--) {
- if (0 <= index && index < count) {
- gotoIndex = index;
- OS.PtListSelectPos (handle, index + 1);
- }
- }
- if (gotoIndex != -1) OS.PtListGotoPos (handle, gotoIndex + 1);
-}
-
+public void select (int start, int end) {
+ checkWidget();
+ if (start > end) return;
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ if ((style & SWT.SINGLE) != 0) {
+ int index = Math.min (count - 1, end);
+ if (index >= start) select (index);
+ return;
+ }
+ int gotoIndex = -1;
+ for (int index=end; index>=start; index--) {
+ if (0 <= index && index < count) {
+ gotoIndex = index;
+ OS.PtListSelectPos (handle, index + 1);
+ }
+ }
+ if (gotoIndex != -1) OS.PtListGotoPos (handle, gotoIndex + 1);
+}
+
/**
* Selects the items at the given zero-relative indices in the receiver.
* If the item at the given zero-relative index in the receiver
@@ -956,24 +956,24 @@ public void select (int start, int end) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void select (int [] indices) {
- checkWidget();
- if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (indices.length == 0) return;
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- int count = args [1];
- int gotoIndex = -1;
- for (int i=0; i<indices.length; i++) {
- int index = indices [i];
- if (0 <= index && index < count) {
- gotoIndex = index;
- OS.PtListSelectPos (handle, index + 1);
- }
- }
- if (gotoIndex != -1) OS.PtListGotoPos (handle, gotoIndex + 1);
-}
-
+public void select (int [] indices) {
+ checkWidget();
+ if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (indices.length == 0) return;
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ int gotoIndex = -1;
+ for (int i=0; i<indices.length; i++) {
+ int index = indices [i];
+ if (0 <= index && index < count) {
+ gotoIndex = index;
+ OS.PtListSelectPos (handle, index + 1);
+ }
+ }
+ if (gotoIndex != -1) OS.PtListGotoPos (handle, gotoIndex + 1);
+}
+
/**
* Selects the item at the given zero-relative index in the receiver's
* list. If the item at the index was already selected, it remains
@@ -986,17 +986,17 @@ public void select (int [] indices) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void select (int index) {
- checkWidget();
- if (index < 0) return;
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- if (index < args [1]) {
- OS.PtListSelectPos (handle, index + 1);
- OS.PtListGotoPos (handle, index + 1);
- }
-}
-
+public void select (int index) {
+ checkWidget();
+ if (index < 0) return;
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (index < args [1]) {
+ OS.PtListSelectPos (handle, index + 1);
+ OS.PtListGotoPos (handle, index + 1);
+ }
+}
+
/**
* Selects all the items in the receiver.
*
@@ -1005,17 +1005,17 @@ public void select (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void selectAll () {
- checkWidget();
- if ((style & SWT.SINGLE) != 0) return;
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- int count = args [1];
- for (int i=0; i<count; i++) {
- OS.PtListSelectPos (handle, i + 1);
- }
-}
-
+public void selectAll () {
+ checkWidget();
+ if ((style & SWT.SINGLE) != 0) return;
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ for (int i=0; i<count; i++) {
+ OS.PtListSelectPos (handle, i + 1);
+ }
+}
+
/**
* Sets the text of the item in the receiver's list at the given
* zero-relative index to the string argument. This is equivalent
@@ -1037,21 +1037,21 @@ public void selectAll () {
* <li>ERROR_ITEM_NOT_ADDED - if the add operation fails because of an operating system failure</li>
* </ul>
*/
-public void setItem (int index, String string) {
- checkWidget();
- if (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 setItem (int index, String string) {
+ checkWidget();
+ 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);
+}
+
/**
* Sets the receiver's items to be the given array of items.
*
@@ -1065,23 +1065,23 @@ public void setItem (int index, String string) {
* <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public void setItems (String [] items) {
- checkWidget();
- 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 setItems (String [] items) {
+ checkWidget();
+ 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]);
+ }
+}
+
/**
* Selects the items at the given zero-relative indices in the receiver.
* The current selected if first cleared, then the new items are selected.
@@ -1097,11 +1097,11 @@ public void setItems (String [] items) {
* @see Table#deselectAll()
* @see Table#select(int,int)
*/
-public void setSelection (int start, int end) {
- if ((style & SWT.MULTI) != 0) deselectAll ();
- select (start, end);
-}
-
+public void setSelection (int start, int end) {
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ select (start, end);
+}
+
/**
* Selects the item at the given zero-relative index in the receiver.
* If the item at the index was already selected, it remains selected.
@@ -1117,11 +1117,11 @@ public void setSelection (int start, int end) {
* @see List#deselectAll()
* @see List#select(int)
*/
-public void setSelection (int index) {
- if ((style & SWT.MULTI) != 0) deselectAll ();
- select (index);
-}
-
+public void setSelection (int index) {
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ select (index);
+}
+
/**
* Selects the items at the given zero-relative indices in the receiver.
* The current selection is first cleared, then the new items are selected.
@@ -1139,11 +1139,11 @@ public void setSelection (int index) {
* @see List#deselectAll()
* @see List#select(int[])
*/
-public void setSelection(int[] indices) {
- deselectAll ();
- select (indices);
-}
-
+public void setSelection(int[] indices) {
+ deselectAll ();
+ select (indices);
+}
+
/**
* Sets the receiver's selection to be the given array of items.
* The current selected is first cleared, then the new items are
@@ -1162,24 +1162,24 @@ public void setSelection(int[] indices) {
* @see List#deselectAll()
* @see List#select(int)
*/
-public void setSelection (String [] items) {
- checkWidget();
- 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 setSelection (String [] items) {
+ checkWidget();
+ 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 ();
+}
+
/**
* Sets the zero-relative index of the item which is currently
* at the top of the receiver. This index can change when items
@@ -1192,11 +1192,11 @@ public void setSelection (String [] items) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setTopIndex (int index) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_TOP_ITEM_POS, index + 1, 0);
-}
-
+public void setTopIndex (int index) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_TOP_ITEM_POS, index + 1, 0);
+}
+
/**
* Shows the selection. If the selection is already showing in the receiver,
* this method simply returns. Otherwise, the items are scrolled until
@@ -1210,30 +1210,30 @@ public void setTopIndex (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void showSelection () {
- checkWidget();
- 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);
- OS.PtSetResource (handle, OS.Pt_ARG_TOP_ITEM_POS, newTop, 0);
-}
-
-int widgetClass () {
- return OS.PtList ();
-}
-
-}
+public void showSelection () {
+ checkWidget();
+ 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);
+ OS.PtSetResource (handle, OS.Pt_ARG_TOP_ITEM_POS, newTop, 0);
+}
+
+int widgetClass () {
+ return OS.PtList ();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java
index 9cb2a5ed01..64d93e7739 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class are user interface objects that contain
* menu items.
@@ -27,12 +27,12 @@ import org.eclipse.swt.graphics.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class Menu extends Widget {
- int x, y;
- boolean hasLocation;
- Decorations parent;
- MenuItem cascade, defaultItem;
-
+public class Menu extends Widget {
+ int x, y;
+ boolean hasLocation;
+ Decorations parent;
+ MenuItem cascade, defaultItem;
+
/**
* Constructs a new instance of this class given its parent,
* and sets the style for the instance so that the instance
@@ -52,10 +52,10 @@ public class Menu extends Widget {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Menu (Control parent) {
- this (checkNull (parent).getShell (), SWT.POP_UP);
-}
-
+public Menu (Control parent) {
+ this (checkNull (parent).getShell (), SWT.POP_UP);
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Decorations</code>) and a style value
@@ -87,12 +87,12 @@ public Menu (Control parent) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Menu (Decorations parent, int style) {
- super (parent, checkStyle (style));
- this.parent = parent;
- createWidget (0);
-}
-
+public Menu (Decorations parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget (0);
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Menu</code>) and sets the style
@@ -113,10 +113,10 @@ public Menu (Decorations parent, int style) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Menu (Menu parentMenu) {
- this (checkNull (parentMenu).parent, SWT.DROP_DOWN);
-}
-
+public Menu (Menu parentMenu) {
+ this (checkNull (parentMenu).parent, SWT.DROP_DOWN);
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>MenuItem</code>) and sets the style
@@ -137,29 +137,29 @@ public Menu (Menu parentMenu) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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 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);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when help events are generated for the control,
@@ -179,13 +179,13 @@ static int checkStyle (int style) {
* @see HelpListener
* @see #removeHelpListener
*/
-public void addHelpListener (HelpListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Help, typedListener);
-}
-
+public void addHelpListener (HelpListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Help, typedListener);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when menus are hidden or shown, by sending it
@@ -205,35 +205,35 @@ public void addHelpListener (HelpListener listener) {
* @see MenuListener
* @see #removeMenuListener
*/
-public void addMenuListener (MenuListener listener) {
- checkWidget();
- 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) {
- state |= HANDLE;
- 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) {
- checkOrientation (parent);
- super.createWidget (index);
- parent.add (this);
-}
-
+public void addMenuListener (MenuListener listener) {
+ checkWidget();
+ 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) {
+ state |= HANDLE;
+ 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) {
+ checkOrientation (parent);
+ super.createWidget (index);
+ parent.add (this);
+}
+
/**
* Returns the default menu item or null if none has
* been previously set.
@@ -246,17 +246,17 @@ void createWidget (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public MenuItem getDefaultItem () {
- checkWidget();
- return defaultItem;
-}
-
-public Display getDisplay () {
- Decorations parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-
+public MenuItem getDefaultItem () {
+ checkWidget();
+ return defaultItem;
+}
+
+public Display getDisplay () {
+ Decorations parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
/**
* Returns <code>true</code> if the receiver is enabled, and
* <code>false</code> otherwise. A disabled control is typically
@@ -270,12 +270,12 @@ public Display getDisplay () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getEnabled () {
- checkWidget ();
- int topHandle = topHandle ();
- return (OS.PtWidgetFlags (topHandle) & OS.Pt_BLOCKED) == 0;
-}
-
+public boolean getEnabled () {
+ checkWidget ();
+ int topHandle = topHandle ();
+ return (OS.PtWidgetFlags (topHandle) & OS.Pt_BLOCKED) == 0;
+}
+
/**
* Returns the number of items contained in the receiver.
*
@@ -286,18 +286,18 @@ public boolean getEnabled () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getItemCount () {
- checkWidget();
- 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 int getItemCount () {
+ checkWidget();
+ 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;
+}
+
/**
* Returns the item at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
@@ -313,23 +313,23 @@ public int getItemCount () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public MenuItem getItem (int index) {
- checkWidget();
- if (index < 0) error (SWT.ERROR_INVALID_RANGE);
- int i = 0;
- int child = OS.PtWidgetChildBack (handle);
- if (child != 0 && (style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);
- while (child != 0) {
- Widget widget = WidgetTable.get (child);
- if (widget != null && widget instanceof MenuItem) {
- if (i++ == index) return (MenuItem) widget;
- }
- child = OS.PtWidgetBrotherInFront (child);
- }
- error (SWT.ERROR_INVALID_RANGE);
- return null;
-}
-
+public MenuItem getItem (int index) {
+ checkWidget();
+ if (index < 0) error (SWT.ERROR_INVALID_RANGE);
+ int i = 0;
+ int child = OS.PtWidgetChildBack (handle);
+ if (child != 0 && (style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);
+ while (child != 0) {
+ Widget widget = WidgetTable.get (child);
+ if (widget != null && widget instanceof MenuItem) {
+ if (i++ == index) return (MenuItem) widget;
+ }
+ child = OS.PtWidgetBrotherInFront (child);
+ }
+ error (SWT.ERROR_INVALID_RANGE);
+ return null;
+}
+
/**
* Returns an array of <code>MenuItem</code>s which are the items
* in the receiver.
@@ -346,46 +346,46 @@ public MenuItem getItem (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public MenuItem [] getItems () {
- checkWidget();
- 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 MenuItem [] getItems () {
+ checkWidget();
+ 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;
+}
+
/**
* Returns the receiver's parent, which must be a <code>Decorations</code>.
*
@@ -396,11 +396,11 @@ String getNameText () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Decorations getParent () {
- checkWidget();
- return parent;
-}
-
+public Decorations getParent () {
+ checkWidget();
+ return parent;
+}
+
/**
* Returns the receiver's parent item, which must be a
* <code>MenuItem</code> or null when the receiver is a
@@ -413,11 +413,11 @@ public Decorations getParent () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public MenuItem getParentItem () {
- checkWidget();
- return cascade;
-}
-
+public MenuItem getParentItem () {
+ checkWidget();
+ return cascade;
+}
+
/**
* Returns the receiver's parent item, which must be a
* <code>Menu</code> or null when the receiver is a
@@ -430,12 +430,12 @@ public MenuItem getParentItem () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Menu getParentMenu () {
- checkWidget();
- if (cascade != null) return cascade.parent;
- return null;
-}
-
+public Menu getParentMenu () {
+ checkWidget();
+ if (cascade != null) return cascade.parent;
+ return null;
+}
+
/**
* Returns the receiver's shell. For all controls other than
* shells, this simply returns the control's nearest ancestor
@@ -451,11 +451,11 @@ public Menu getParentMenu () {
*
* @see #getParent
*/
-public Shell getShell () {
- checkWidget();
- return parent.getShell ();
-}
-
+public Shell getShell () {
+ checkWidget();
+ return parent.getShell ();
+}
+
/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.
@@ -473,17 +473,17 @@ public Shell getShell () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getVisible () {
- checkWidget();
- return OS.PtWidgetIsRealized (handle);
-}
-
-void hookEvents () {
- int windowProc = getDisplay ().windowProc;
- OS.PtAddCallback (handle, OS.Pt_CB_REALIZED, windowProc, OS.Pt_CB_REALIZED);
- OS.PtAddCallback (handle, OS.Pt_CB_UNREALIZED, windowProc, OS.Pt_CB_UNREALIZED);
-}
-
+public boolean getVisible () {
+ checkWidget();
+ return OS.PtWidgetIsRealized (handle);
+}
+
+void hookEvents () {
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_REALIZED, windowProc, OS.Pt_CB_REALIZED);
+ OS.PtAddCallback (handle, OS.Pt_CB_UNREALIZED, windowProc, OS.Pt_CB_UNREALIZED);
+}
+
/**
* Searches the receiver's list starting at the first item
* (index 0) until an item is found that is equal to the
@@ -501,112 +501,112 @@ void hookEvents () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int indexOf (MenuItem item) {
- checkWidget();
- if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- int i = 0;
- int child = OS.PtWidgetChildBack (handle);
- if (child != 0 && (style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);
- while (child != 0) {
- Widget widget = WidgetTable.get (child);
- if (item == widget) return i;
- if (widget != null && widget instanceof MenuItem) i++;
- child = OS.PtWidgetBrotherInFront (child);
- }
- return -1;
-}
-
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
+public int indexOf (MenuItem item) {
+ checkWidget();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int i = 0;
+ int child = OS.PtWidgetChildBack (handle);
+ if (child != 0 && (style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);
+ while (child != 0) {
+ Widget widget = WidgetTable.get (child);
+ if (item == widget) return i;
+ if (widget != null && widget instanceof MenuItem) i++;
+ child = OS.PtWidgetBrotherInFront (child);
+ }
+ return -1;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
*/
-public boolean isEnabled () {
- checkWidget();
- Menu parentMenu = getParentMenu ();
- if (parentMenu == null) return getEnabled ();
- return getEnabled () && parentMenu.isEnabled ();
-}
-
-/**
- * Returns <code>true</code> if the receiver is visible and all
- * of the receiver's ancestors are visible and <code>false</code>
- * otherwise.
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getVisible
+public boolean isEnabled () {
+ checkWidget();
+ Menu parentMenu = getParentMenu ();
+ if (parentMenu == null) return getEnabled ();
+ return getEnabled () && parentMenu.isEnabled ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
*/
-public boolean isVisible () {
- checkWidget();
- return getVisible ();
-}
-
-int Pt_CB_REALIZED (int widget, int info) {
- if ((style & SWT.BAR) == 0) {
- Shell shell = getShell ();
- shell.activeMenu = this;
- }
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_UNREALIZED (int widget, int info) {
- if (cascade != null) {
- OS.PtSetResource (handle, OS.Pt_ARG_MENU_FLAGS, 0, OS.Pt_MENU_CHILD);
- int shellHandle = parent.topHandle ();
- OS.PtReParentWidget (handle, shellHandle);
- }
- sendEvent (SWT.Hide);
- Shell shell = getShell ();
- if (shell.activeMenu == this) {
- shell.activeMenu = null;
- if (cascade != null) {
- Menu parent = cascade.parent;
- if (parent != null && (parent.style & SWT.BAR) == 0) {
- if (OS.PtWidgetIsRealized (parent.handle)) {
- shell.activeMenu = parent;
- }
- }
- }
- }
- 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.releaseResources ();
- }
- super.releaseWidget ();
- if (parent != null) parent.remove (this);
- parent = null;
- cascade = null;
-}
-
+public boolean isVisible () {
+ checkWidget();
+ return getVisible ();
+}
+
+int Pt_CB_REALIZED (int widget, int info) {
+ if ((style & SWT.BAR) == 0) {
+ Shell shell = getShell ();
+ shell.activeMenu = this;
+ }
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_UNREALIZED (int widget, int info) {
+ if (cascade != null) {
+ OS.PtSetResource (handle, OS.Pt_ARG_MENU_FLAGS, 0, OS.Pt_MENU_CHILD);
+ int shellHandle = parent.topHandle ();
+ OS.PtReParentWidget (handle, shellHandle);
+ }
+ sendEvent (SWT.Hide);
+ Shell shell = getShell ();
+ if (shell.activeMenu == this) {
+ shell.activeMenu = null;
+ if (cascade != null) {
+ Menu parent = cascade.parent;
+ if (parent != null && (parent.style & SWT.BAR) == 0) {
+ if (OS.PtWidgetIsRealized (parent.handle)) {
+ shell.activeMenu = parent;
+ }
+ }
+ }
+ }
+ 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.releaseResources ();
+ }
+ super.releaseWidget ();
+ if (parent != null) parent.remove (this);
+ parent = null;
+ cascade = null;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the help events are generated for the control.
@@ -624,13 +624,13 @@ void releaseWidget () {
* @see HelpListener
* @see #addHelpListener
*/
-public void removeHelpListener (HelpListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Help, listener);
-}
-
+public void removeHelpListener (HelpListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Help, listener);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the menu events are generated for the control.
@@ -648,14 +648,14 @@ public void removeHelpListener (HelpListener listener) {
* @see MenuListener
* @see #addMenuListener
*/
-public void removeMenuListener (MenuListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Hide, listener);
- eventTable.unhook (SWT.Show, listener);
-}
-
+public void removeMenuListener (MenuListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Hide, listener);
+ eventTable.unhook (SWT.Show, listener);
+}
+
/**
* Sets the default menu item to the argument or removes
* the default emphasis when the argument is <code>null</code>.
@@ -670,12 +670,12 @@ public void removeMenuListener (MenuListener listener) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setDefaultItem (MenuItem item) {
- checkWidget();
- if (item != null && item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- defaultItem = item;
-}
-
+public void setDefaultItem (MenuItem item) {
+ checkWidget();
+ if (item != null && item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ defaultItem = item;
+}
+
/**
* Enables the receiver if the argument is <code>true</code>,
* and disables it otherwise. A disabled control is typically
@@ -689,13 +689,13 @@ public void setDefaultItem (MenuItem item) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setEnabled (boolean enabled) {
- checkWidget ();
- int topHandle = topHandle ();
- int flags = enabled ? 0 : OS.Pt_BLOCKED | OS.Pt_GHOST;
- OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
-}
-
+public void setEnabled (boolean enabled) {
+ checkWidget ();
+ int topHandle = topHandle ();
+ int flags = enabled ? 0 : OS.Pt_BLOCKED | OS.Pt_GHOST;
+ OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
+}
+
/**
* Sets the receiver's location to the point specified by
* the arguments which are relative to the display.
@@ -712,19 +712,19 @@ public void setEnabled (boolean enabled) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setLocation (int x, int y) {
- checkWidget();
- this.x = x;
- this.y = y;
- hasLocation = true;
-}
-
-public void setLocation (Point location) {
- checkWidget();
- if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
- setLocation (location.x, location.y);
-}
-
+public void setLocation (int x, int y) {
+ checkWidget();
+ this.x = x;
+ this.y = y;
+ hasLocation = true;
+}
+
+public void setLocation (Point location) {
+ checkWidget();
+ if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setLocation (location.x, location.y);
+}
+
/**
* Marks the receiver as visible if the argument is <code>true</code>,
* and marks it invisible otherwise.
@@ -741,34 +741,34 @@ public void setLocation (Point location) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setVisible (boolean visible) {
- checkWidget();
- if ((style & SWT.POP_UP) == 0) return;
- if (visible == OS.PtWidgetIsRealized (handle)) return;
- if (visible) {
- sendEvent (SWT.Show);
- if (getItemCount () != 0) {
- 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);
- OS.PtSetResource (handle, OS.Pt_ARG_POS, ptr, 0);
- OS.free (ptr);
- OS.PtRealizeWidget (handle);
- } else {
- sendEvent (SWT.Hide);
- }
- } else {
- OS.PtUnrealizeWidget(handle);
- }
-}
-
-}
+public void setVisible (boolean visible) {
+ checkWidget();
+ if ((style & SWT.POP_UP) == 0) return;
+ if (visible == OS.PtWidgetIsRealized (handle)) return;
+ if (visible) {
+ sendEvent (SWT.Show);
+ if (getItemCount () != 0) {
+ 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);
+ OS.PtSetResource (handle, OS.Pt_ARG_POS, ptr, 0);
+ OS.free (ptr);
+ OS.PtRealizeWidget (handle);
+ } else {
+ sendEvent (SWT.Hide);
+ }
+ } else {
+ OS.PtUnrealizeWidget(handle);
+ }
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java
index b7dbf19f85..51b27d12c5 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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.*;
+
/**
* Instances of this class represent a selectable user interface object
* that issues notification when pressed and released.
@@ -29,10 +29,10 @@ import org.eclipse.swt.events.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class MenuItem extends Item {
- Menu parent, menu;
- int accelerator;
-
+public class MenuItem extends Item {
+ Menu parent, menu;
+ int accelerator;
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Menu</code>) and a style value
@@ -67,10 +67,10 @@ public class MenuItem extends Item {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public MenuItem (Menu parent, int style) {
- this (parent, style, parent.getItemCount());
-}
-
+public MenuItem (Menu parent, int style) {
+ this (parent, style, parent.getItemCount());
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>Menu</code>), a style value
@@ -106,27 +106,27 @@ public MenuItem (Menu parent, int style) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public MenuItem (Menu parent, int style, int index) {
- super (parent, checkStyle (style));
- this.parent = parent;
- createWidget (index);
-}
-
-void addAccelerator () {
- if (accelerator == 0) return;
- int keyMods = 0;
- if ((accelerator & SWT.ALT) != 0) keyMods |= OS.Pk_KM_Alt;
- if ((accelerator & SWT.SHIFT) != 0) keyMods |= OS.Pk_KM_Shift;
- if ((accelerator & SWT.CONTROL) != 0) keyMods |= OS.Pk_KM_Ctrl;
- int key = (accelerator & ~(SWT.ALT | SWT.SHIFT | SWT.CONTROL));
- Display display = getDisplay ();
- int keyCode = Display.untranslateKey (key);
- if (keyCode != 0) key = keyCode;
- else key = Character.toLowerCase ((char)key);
- Shell shell = parent.getShell ();
- OS.PtAddHotkeyHandler(shell.shellHandle, key, keyMods, (short)0, handle, display.hotkeyProc);
-}
-
+public MenuItem (Menu parent, int style, int index) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget (index);
+}
+
+void addAccelerator () {
+ if (accelerator == 0) return;
+ int keyMods = 0;
+ if ((accelerator & SWT.ALT) != 0) keyMods |= OS.Pk_KM_Alt;
+ if ((accelerator & SWT.SHIFT) != 0) keyMods |= OS.Pk_KM_Shift;
+ if ((accelerator & SWT.CONTROL) != 0) keyMods |= OS.Pk_KM_Ctrl;
+ int key = (accelerator & ~(SWT.ALT | SWT.SHIFT | SWT.CONTROL));
+ Display display = getDisplay ();
+ int keyCode = Display.untranslateKey (key);
+ if (keyCode != 0) key = keyCode;
+ else key = Character.toLowerCase ((char)key);
+ Shell shell = parent.getShell ();
+ OS.PtAddHotkeyHandler(shell.shellHandle, key, keyMods, (short)0, handle, display.hotkeyProc);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the arm events are generated for the control, by sending
@@ -146,13 +146,13 @@ void addAccelerator () {
* @see ArmListener
* @see #removeArmListener
*/
-public void addArmListener (ArmListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Arm, typedListener);
-}
-
+public void addArmListener (ArmListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Arm, typedListener);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the help events are generated for the control, by sending
@@ -172,13 +172,13 @@ public void addArmListener (ArmListener listener) {
* @see HelpListener
* @see #removeHelpListener
*/
-public void addHelpListener (HelpListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Help, typedListener);
-}
-
+public void addHelpListener (HelpListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Help, typedListener);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the control is selected, by sending
@@ -203,58 +203,58 @@ public void addHelpListener (HelpListener listener) {
* @see #removeSelectionListener
* @see SelectionEvent
*/
-public void addSelectionListener (SelectionListener listener) {
- checkWidget();
- 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) {
- state |= HANDLE;
- 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_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 ());
- }
-}
-
+public void addSelectionListener (SelectionListener listener) {
+ checkWidget();
+ 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) {
+ state |= HANDLE;
+ 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_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 ());
+ }
+}
+
/**
* Return the widget accelerator. An accelerator is the bit-wise
* OR of zero or more modifier masks and a key. Examples:
@@ -268,17 +268,17 @@ void createHandle (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getAccelerator () {
- checkWidget();
- return accelerator;
-}
-
-public Display getDisplay () {
- Menu parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-
+public int getAccelerator () {
+ checkWidget();
+ return accelerator;
+}
+
+public Display getDisplay () {
+ Menu parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
/**
* Returns <code>true</code> if the receiver is enabled, and
* <code>false</code> otherwise. A disabled control is typically
@@ -292,19 +292,19 @@ public Display getDisplay () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getEnabled () {
- checkWidget ();
- /*
- * Bug in Photon. The Pt_BLOCKED flag of a menu item is cleared
- * when its parent menu is realized. The fix is to remember
- * the menu item state and reset it when the menu item is
- * realized.
- */
-// int topHandle = topHandle ();
-// return (OS.PtWidgetFlags (topHandle) & OS.Pt_BLOCKED) == 0;
- return (state & DISABLED) == 0;
-}
-
+public boolean getEnabled () {
+ checkWidget ();
+ /*
+ * Bug in Photon. The Pt_BLOCKED flag of a menu item is cleared
+ * when its parent menu is realized. The fix is to remember
+ * the menu item state and reset it when the menu item is
+ * realized.
+ */
+// int topHandle = topHandle ();
+// return (OS.PtWidgetFlags (topHandle) & OS.Pt_BLOCKED) == 0;
+ return (state & DISABLED) == 0;
+}
+
/**
* Returns the receiver's cascade menu if it has one or null
* if it does not. Only <code>CASCADE</code> menu items can have
@@ -319,16 +319,16 @@ public boolean getEnabled () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Menu getMenu () {
- checkWidget();
- return menu;
-}
-
-String getNameText () {
- if ((style & SWT.SEPARATOR) != 0) return "|";
- return super.getNameText ();
-}
-
+public Menu getMenu () {
+ checkWidget();
+ return menu;
+}
+
+String getNameText () {
+ if ((style & SWT.SEPARATOR) != 0) return "|";
+ return super.getNameText ();
+}
+
/**
* Returns the receiver's parent, which must be a <code>Menu</code>.
*
@@ -339,11 +339,11 @@ String getNameText () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Menu getParent () {
- checkWidget();
- return parent;
-}
-
+public Menu getParent () {
+ checkWidget();
+ return parent;
+}
+
/**
* Returns <code>true</code> if the receiver is selected,
* and false otherwise.
@@ -358,120 +358,120 @@ public Menu getParent () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getSelection () {
- checkWidget();
- if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
- return (OS.PtWidgetFlags (handle) & 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, OS.Pt_CB_ARM);
- }
- OS.PtAddCallback (handle, OS.Pt_CB_ACTIVATE, windowProc, OS.Pt_CB_ACTIVATE);
- if ((parent.style & SWT.BAR) == 0) {
- OS.PtAddCallback (handle, OS.Pt_CB_REALIZED, windowProc, OS.Pt_CB_REALIZED);
- }
-}
-
-int hotkeyProc (int widget, int data, int info) {
- showMenu ();
- return OS.Pt_CONTINUE;
-}
-
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
+public boolean getSelection () {
+ checkWidget();
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
+ return (OS.PtWidgetFlags (handle) & 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, OS.Pt_CB_ARM);
+ }
+ OS.PtAddCallback (handle, OS.Pt_CB_ACTIVATE, windowProc, OS.Pt_CB_ACTIVATE);
+ if ((parent.style & SWT.BAR) == 0) {
+ OS.PtAddCallback (handle, OS.Pt_CB_REALIZED, windowProc, OS.Pt_CB_REALIZED);
+ }
+}
+
+int hotkeyProc (int widget, int data, int info) {
+ showMenu ();
+ return OS.Pt_CONTINUE;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
*/
-public boolean isEnabled () {
- return getEnabled () && parent.isEnabled ();
-}
-
-int Pt_CB_ACTIVATE (int widget, int info) {
- if ((style & SWT.CASCADE) != 0 && menu != null) {
- return OS.Pt_CONTINUE;
- }
- Event event = new Event ();
- if (info != 0) {
- PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
- OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
- if (cbinfo.event != 0) {
- PhEvent_t ev = new PhEvent_t ();
- OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
- int data = OS.PhGetData (cbinfo.event);
- if (data != 0) {
- switch (ev.type) {
- case OS.Ph_EV_KEY:
- PhKeyEvent_t ke = new PhKeyEvent_t ();
- OS.memmove (ke, data, PhKeyEvent_t.sizeof);
- setKeyState (event, ke);
- break;
- case OS.Ph_EV_BUT_PRESS:
- case OS.Ph_EV_BUT_RELEASE:
- PhPointerEvent_t pe = new PhPointerEvent_t ();
- OS.memmove (pe, data, PhPointerEvent_t.sizeof);
- setMouseState (event, pe, ev);
- break;
- }
- }
- }
- }
- if ((style & SWT.RADIO) != 0) {
- if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
- selectRadio ();
- }
- }
- postEvent (SWT.Selection, event);
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_ARM (int widget, int info) {
- postEvent (SWT.Arm);
- showMenu ();
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_REALIZED (int widget, int info) {
- /*
- * Bug in Photon. The Pt_BLOCKED flag of a menu item is cleared
- * when its parent menu is realized. The fix is to remember
- * the menu item state and reset it when the menu item is
- * realized.
- */
- int topHandle = topHandle ();
- int flags = (state & DISABLED) != 0 ? OS.Pt_BLOCKED | OS.Pt_GHOST : 0;
- OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
- return OS.Pt_CONTINUE;
-}
-
-void releaseChild () {
- super.releaseChild ();
- if (menu != null) menu.dispose ();
- menu = null;
-}
-
-void releaseWidget () {
- if (menu != null && !menu.isDisposed ()) menu.releaseResources ();
- menu = null;
- super.releaseWidget ();
- if (accelerator != 0) removeAccelerator ();
- accelerator = 0;
- parent = null;
-}
-
+public boolean isEnabled () {
+ return getEnabled () && parent.isEnabled ();
+}
+
+int Pt_CB_ACTIVATE (int widget, int info) {
+ if ((style & SWT.CASCADE) != 0 && menu != null) {
+ return OS.Pt_CONTINUE;
+ }
+ Event event = new Event ();
+ if (info != 0) {
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.event != 0) {
+ PhEvent_t ev = new PhEvent_t ();
+ OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
+ int data = OS.PhGetData (cbinfo.event);
+ if (data != 0) {
+ switch (ev.type) {
+ case OS.Ph_EV_KEY:
+ PhKeyEvent_t ke = new PhKeyEvent_t ();
+ OS.memmove (ke, data, PhKeyEvent_t.sizeof);
+ setKeyState (event, ke);
+ break;
+ case OS.Ph_EV_BUT_PRESS:
+ case OS.Ph_EV_BUT_RELEASE:
+ PhPointerEvent_t pe = new PhPointerEvent_t ();
+ OS.memmove (pe, data, PhPointerEvent_t.sizeof);
+ setMouseState (event, pe, ev);
+ break;
+ }
+ }
+ }
+ }
+ if ((style & SWT.RADIO) != 0) {
+ if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
+ selectRadio ();
+ }
+ }
+ postEvent (SWT.Selection, event);
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_ARM (int widget, int info) {
+ postEvent (SWT.Arm);
+ showMenu ();
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_REALIZED (int widget, int info) {
+ /*
+ * Bug in Photon. The Pt_BLOCKED flag of a menu item is cleared
+ * when its parent menu is realized. The fix is to remember
+ * the menu item state and reset it when the menu item is
+ * realized.
+ */
+ int topHandle = topHandle ();
+ int flags = (state & DISABLED) != 0 ? OS.Pt_BLOCKED | OS.Pt_GHOST : 0;
+ OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
+ return OS.Pt_CONTINUE;
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ if (menu != null) menu.dispose ();
+ menu = null;
+}
+
+void releaseWidget () {
+ if (menu != null && !menu.isDisposed ()) menu.releaseResources ();
+ menu = null;
+ super.releaseWidget ();
+ if (accelerator != 0) removeAccelerator ();
+ accelerator = 0;
+ parent = null;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the arm events are generated for the control.
@@ -489,13 +489,13 @@ void releaseWidget () {
* @see ArmListener
* @see #addArmListener
*/
-public void removeArmListener (ArmListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Arm, listener);
-}
-
+public void removeArmListener (ArmListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Arm, listener);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the help events are generated for the control.
@@ -513,28 +513,28 @@ public void removeArmListener (ArmListener listener) {
* @see HelpListener
* @see #addHelpListener
*/
-public void removeHelpListener (HelpListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Help, listener);
-}
-
-void removeAccelerator () {
- if (accelerator == 0) return;
- int keyMods = 0;
- if ((accelerator & SWT.ALT) != 0) keyMods |= OS.Pk_KM_Alt;
- if ((accelerator & SWT.SHIFT) != 0) keyMods |= OS.Pk_KM_Shift;
- if ((accelerator & SWT.CONTROL) != 0) keyMods |= OS.Pk_KM_Ctrl;
- int key = (accelerator & ~(SWT.ALT | SWT.SHIFT | SWT.CONTROL));
- Display display = getDisplay ();
- int keyCode = Display.untranslateKey (key);
- if (keyCode != 0) key = keyCode;
- else key = Character.toLowerCase ((char)key);
- Shell shell = parent.getShell ();
- OS.PtRemoveHotkeyHandler(shell.shellHandle, key, keyMods, (short)0, handle, display.hotkeyProc);
-}
-
+public void removeHelpListener (HelpListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Help, listener);
+}
+
+void removeAccelerator () {
+ if (accelerator == 0) return;
+ int keyMods = 0;
+ if ((accelerator & SWT.ALT) != 0) keyMods |= OS.Pk_KM_Alt;
+ if ((accelerator & SWT.SHIFT) != 0) keyMods |= OS.Pk_KM_Shift;
+ if ((accelerator & SWT.CONTROL) != 0) keyMods |= OS.Pk_KM_Ctrl;
+ int key = (accelerator & ~(SWT.ALT | SWT.SHIFT | SWT.CONTROL));
+ Display display = getDisplay ();
+ int keyCode = Display.untranslateKey (key);
+ if (keyCode != 0) key = keyCode;
+ else key = Character.toLowerCase ((char)key);
+ Shell shell = parent.getShell ();
+ OS.PtRemoveHotkeyHandler(shell.shellHandle, key, keyMods, (short)0, handle, display.hotkeyProc);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the control is selected.
@@ -552,25 +552,25 @@ void removeAccelerator () {
* @see SelectionListener
* @see #addSelectionListener
*/
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
-void selectRadio () {
- int index = 0;
- MenuItem [] items = parent.getItems ();
- while (index < items.length && items [index] != this) index++;
- int i = index - 1;
- while (i >= 0 && items [i].setRadioSelection (false)) --i;
- int j = index + 1;
- while (j < items.length && items [j].setRadioSelection (false)) j++;
- setSelection (true);
-}
-
+public void removeSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+void selectRadio () {
+ int index = 0;
+ MenuItem [] items = parent.getItems ();
+ while (index < items.length && items [index] != this) index++;
+ int i = index - 1;
+ while (i >= 0 && items [i].setRadioSelection (false)) --i;
+ int j = index + 1;
+ while (j < items.length && items [j].setRadioSelection (false)) j++;
+ setSelection (true);
+}
+
/**
* Sets the widget accelerator. An accelerator is the bit-wise
* OR of zero or more modifier masks and a key. Examples:
@@ -584,14 +584,14 @@ void selectRadio () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setAccelerator (int accelerator) {
- checkWidget();
- if (this.accelerator == accelerator) return;
- removeAccelerator ();
- this.accelerator = accelerator;
- addAccelerator ();
-}
-
+public void setAccelerator (int accelerator) {
+ checkWidget();
+ if (this.accelerator == accelerator) return;
+ removeAccelerator ();
+ this.accelerator = accelerator;
+ addAccelerator ();
+}
+
/**
* Enables the receiver if the argument is <code>true</code>,
* and disables it otherwise. A disabled control is typically
@@ -605,18 +605,18 @@ public void setAccelerator (int accelerator) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setEnabled (boolean enabled) {
- checkWidget ();
- if (enabled) {
- state &= ~DISABLED;
- } else {
- state |= DISABLED;
- }
- int topHandle = topHandle ();
- int flags = (state & DISABLED) != 0 ? OS.Pt_BLOCKED | OS.Pt_GHOST : 0;
- OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
-}
-
+public void setEnabled (boolean enabled) {
+ checkWidget ();
+ if (enabled) {
+ state &= ~DISABLED;
+ } else {
+ state |= DISABLED;
+ }
+ int topHandle = topHandle ();
+ int flags = (state & DISABLED) != 0 ? OS.Pt_BLOCKED | OS.Pt_GHOST : 0;
+ OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
+}
+
/**
* Sets the image the receiver will display to the argument.
* <p>
@@ -630,43 +630,43 @@ public void setEnabled (boolean enabled) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setImage (Image image) {
- checkWidget();
- if ((style & SWT.SEPARATOR) != 0) return;
- if (this.image == image) return;
- super.setImage (image);
- if ((style & (SWT.CHECK | SWT.RADIO)) != 0) return;
- int imageHandle = 0;
- int type = OS.Pt_Z_STRING;
- if (image != null) {
- imageHandle = copyPhImage (image.handle);
- if (text.length () != 0) type = OS.Pt_TEXT_IMAGE;
- else type = OS.Pt_IMAGE;
- } else {
- /*
- * Bug in Photon. Photon will segment fault, if Pt_ARG_LABEL_IMAGE
- * is set to NULL. This means that after setting an image into a
- * PtMenuButton, it can never be removed. The fix is to set it to
- * a small blank image.
- */
- Display display = getDisplay ();
- imageHandle = copyPhImage (display.nullImage);
- }
- 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);
- /*
- * 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.PtExtentWidgetFamily (parent.handle);
-}
-
+public void setImage (Image image) {
+ checkWidget();
+ if ((style & SWT.SEPARATOR) != 0) return;
+ if (this.image == image) return;
+ super.setImage (image);
+ if ((style & (SWT.CHECK | SWT.RADIO)) != 0) return;
+ int imageHandle = 0;
+ int type = OS.Pt_Z_STRING;
+ if (image != null) {
+ imageHandle = copyPhImage (image.handle);
+ if (text.length () != 0) type = OS.Pt_TEXT_IMAGE;
+ else type = OS.Pt_IMAGE;
+ } else {
+ /*
+ * Bug in Photon. Photon will segment fault, if Pt_ARG_LABEL_IMAGE
+ * is set to NULL. This means that after setting an image into a
+ * PtMenuButton, it can never be removed. The fix is to set it to
+ * a small blank image.
+ */
+ Display display = getDisplay ();
+ imageHandle = copyPhImage (display.nullImage);
+ }
+ 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);
+ /*
+ * 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.PtExtentWidgetFamily (parent.handle);
+}
+
/**
* Sets the receiver's pull down menu to the argument.
* Only <code>CASCADE</code> menu items can have a
@@ -687,45 +687,45 @@ public void setImage (Image image) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMenu (Menu menu) {
- checkWidget();
- if ((style & SWT.CASCADE) == 0) {
- error (SWT.ERROR_MENUITEM_NOT_CASCADE);
- }
- if (menu != null) {
- if (menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if ((menu.style & SWT.DROP_DOWN) == 0) {
- error (SWT.ERROR_MENU_NOT_DROP_DOWN);
- }
- 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;
- if ((parent.style & SWT.BAR) == 0) {
- OS.PtSetResource (handle, OS.Pt_ARG_BUTTON_TYPE, OS.Pt_MENU_TEXT, 0);
- }
- }
- if (menu != null) {
- menu.cascade = this;
- if ((parent.style & SWT.BAR) == 0) {
- OS.PtSetResource (handle, OS.Pt_ARG_BUTTON_TYPE, OS.Pt_MENU_RIGHT, 0);
- }
- }
-}
-
-boolean setRadioSelection (boolean value) {
- if ((style & SWT.RADIO) == 0) return false;
- if (getSelection () != value) {
- setSelection (value);
- postEvent (SWT.Selection);
- }
- return true;
-}
+public void setMenu (Menu menu) {
+ checkWidget();
+ if ((style & SWT.CASCADE) == 0) {
+ error (SWT.ERROR_MENUITEM_NOT_CASCADE);
+ }
+ if (menu != null) {
+ if (menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if ((menu.style & SWT.DROP_DOWN) == 0) {
+ error (SWT.ERROR_MENU_NOT_DROP_DOWN);
+ }
+ 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;
+ if ((parent.style & SWT.BAR) == 0) {
+ OS.PtSetResource (handle, OS.Pt_ARG_BUTTON_TYPE, OS.Pt_MENU_TEXT, 0);
+ }
+ }
+ if (menu != null) {
+ menu.cascade = this;
+ if ((parent.style & SWT.BAR) == 0) {
+ OS.PtSetResource (handle, OS.Pt_ARG_BUTTON_TYPE, OS.Pt_MENU_RIGHT, 0);
+ }
+ }
+}
+
+boolean setRadioSelection (boolean value) {
+ if ((style & SWT.RADIO) == 0) return false;
+ if (getSelection () != value) {
+ setSelection (value);
+ postEvent (SWT.Selection);
+ }
+ return true;
+}
/**
* Sets the selection state of the receiver.
* <p>
@@ -739,123 +739,123 @@ boolean setRadioSelection (boolean value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (boolean selected) {
- checkWidget();
- if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
- OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET);
-}
-
-public void setText (String string) {
- checkWidget();
- 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--;
- }
- }
- int keyMods = 0;
- byte [] buffer2 = new byte [1];
- if (accel && ++i < text.length) {
- int start = i;
-// while (i < text.length) {
-// if (text [i] == '+') {
-// String str = new String (text, start, i - start);
-// if (str.equals ("Ctrl")) keyMods |= OS.Pk_KM_Ctrl;
-// if (str.equals ("Shift")) keyMods |= OS.Pk_KM_Shift;
-// if (str.equals ("Alt")) keyMods |= OS.Pk_KM_Alt;
-// start = i + 1;
-// }
-// i++;
-// }
- if (start < text.length) {
- char [] accelText = new char [text.length - start];
- System.arraycopy (text, start, accelText, 0, accelText.length);
- buffer2 = Converter.wcsToMbcs (null, accelText, true);
- }
- }
- while (j < text.length) text [j++] = 0;
- byte [] buffer1 = Converter.wcsToMbcs (null, text, true);
- int ptr1 = OS.malloc (buffer1.length);
- OS.memmove (ptr1, buffer1, buffer1.length);
- int ptr2 = OS.malloc (buffer2.length);
- OS.memmove (ptr2, buffer2, buffer2.length);
- int ptr3 = 0;
- if (mnemonic != 0) {
- byte [] buffer3 = Converter.wcsToMbcs (null, new char []{mnemonic}, true);
- ptr3 = OS.malloc (buffer3.length);
- OS.memmove (ptr3, buffer3, buffer3.length);
- }
- if ((parent.style & SWT.BAR) != 0) {
- replaceMnemonic (mnemonic, false, true);
- }
- int type = OS.Pt_Z_STRING;
- if ((style & SWT.PUSH) != 0) {
- if (image != null) type = OS.Pt_TEXT_IMAGE;
- }
- int [] args = {
- OS.Pt_ARG_TEXT_STRING, ptr1, 0,
- OS.Pt_ARG_ACCEL_TEXT, ptr2, 0,
- OS.Pt_ARG_MODIFIER_KEYS, keyMods, keyMods,
- OS.Pt_ARG_ACCEL_KEY, ptr3, 0,
- OS.Pt_ARG_LABEL_TYPE, type, 0,
- };
- OS.PtSetResources (handle, args.length / 3, args);
- OS.free (ptr1);
- OS.free (ptr2);
- 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.PtExtentWidgetFamily (parent.handle);
-}
-
-void showMenu() {
- if (menu == null) return;
- int menuHandle = menu.handle;
- if (!OS.PtWidgetIsRealized (menuHandle)) {
- if ((parent.style & SWT.BAR) == 0) {
- OS.PtSetResource (menuHandle, OS.Pt_ARG_MENU_FLAGS, OS.Pt_MENU_CHILD, OS.Pt_MENU_CHILD);
- }
- OS.PtReParentWidget (menuHandle, handle);
-
- /*
- * Bug in Photon. PtPositionMenu does not position the menu
- * properly when the menu is a direct child a menu bar item.
- * The fix is to position the menu ourselfs.
- */
- if ((parent.style & SWT.BAR) != 0) {
- PhPoint_t pt = new PhPoint_t ();
- short [] x = new short [1], y = new short [1];
- OS.PtGetAbsPosition (handle, x, y);
- pt.x = x [0];
- pt.y = y [0];
- int [] args = {OS.Pt_ARG_HEIGHT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- pt.y += args [1];
- int ptr = OS.malloc (PhPoint_t.sizeof);
- OS.memmove (ptr, pt, PhPoint_t.sizeof);
- OS.PtSetResource (menuHandle, OS.Pt_ARG_POS, ptr, 0);
- OS.free (ptr);
- } else {
- OS.PtPositionMenu (menuHandle, null);
- }
-
- menu.sendEvent (SWT.Show);
- OS.PtRealizeWidget (menuHandle);
- }
-}
-
-}
+public void setSelection (boolean selected) {
+ checkWidget();
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
+ OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET);
+}
+
+public void setText (String string) {
+ checkWidget();
+ 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--;
+ }
+ }
+ int keyMods = 0;
+ byte [] buffer2 = new byte [1];
+ if (accel && ++i < text.length) {
+ int start = i;
+// while (i < text.length) {
+// if (text [i] == '+') {
+// String str = new String (text, start, i - start);
+// if (str.equals ("Ctrl")) keyMods |= OS.Pk_KM_Ctrl;
+// if (str.equals ("Shift")) keyMods |= OS.Pk_KM_Shift;
+// if (str.equals ("Alt")) keyMods |= OS.Pk_KM_Alt;
+// start = i + 1;
+// }
+// i++;
+// }
+ if (start < text.length) {
+ char [] accelText = new char [text.length - start];
+ System.arraycopy (text, start, accelText, 0, accelText.length);
+ buffer2 = Converter.wcsToMbcs (null, accelText, true);
+ }
+ }
+ while (j < text.length) text [j++] = 0;
+ byte [] buffer1 = Converter.wcsToMbcs (null, text, true);
+ int ptr1 = OS.malloc (buffer1.length);
+ OS.memmove (ptr1, buffer1, buffer1.length);
+ int ptr2 = OS.malloc (buffer2.length);
+ OS.memmove (ptr2, buffer2, buffer2.length);
+ int ptr3 = 0;
+ if (mnemonic != 0) {
+ byte [] buffer3 = Converter.wcsToMbcs (null, new char []{mnemonic}, true);
+ ptr3 = OS.malloc (buffer3.length);
+ OS.memmove (ptr3, buffer3, buffer3.length);
+ }
+ if ((parent.style & SWT.BAR) != 0) {
+ replaceMnemonic (mnemonic, false, true);
+ }
+ int type = OS.Pt_Z_STRING;
+ if ((style & SWT.PUSH) != 0) {
+ if (image != null) type = OS.Pt_TEXT_IMAGE;
+ }
+ int [] args = {
+ OS.Pt_ARG_TEXT_STRING, ptr1, 0,
+ OS.Pt_ARG_ACCEL_TEXT, ptr2, 0,
+ OS.Pt_ARG_MODIFIER_KEYS, keyMods, keyMods,
+ OS.Pt_ARG_ACCEL_KEY, ptr3, 0,
+ OS.Pt_ARG_LABEL_TYPE, type, 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ OS.free (ptr1);
+ OS.free (ptr2);
+ 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.PtExtentWidgetFamily (parent.handle);
+}
+
+void showMenu() {
+ if (menu == null) return;
+ int menuHandle = menu.handle;
+ if (!OS.PtWidgetIsRealized (menuHandle)) {
+ if ((parent.style & SWT.BAR) == 0) {
+ OS.PtSetResource (menuHandle, OS.Pt_ARG_MENU_FLAGS, OS.Pt_MENU_CHILD, OS.Pt_MENU_CHILD);
+ }
+ OS.PtReParentWidget (menuHandle, handle);
+
+ /*
+ * Bug in Photon. PtPositionMenu does not position the menu
+ * properly when the menu is a direct child a menu bar item.
+ * The fix is to position the menu ourselfs.
+ */
+ if ((parent.style & SWT.BAR) != 0) {
+ PhPoint_t pt = new PhPoint_t ();
+ short [] x = new short [1], y = new short [1];
+ OS.PtGetAbsPosition (handle, x, y);
+ pt.x = x [0];
+ pt.y = y [0];
+ int [] args = {OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ pt.y += args [1];
+ int ptr = OS.malloc (PhPoint_t.sizeof);
+ OS.memmove (ptr, pt, PhPoint_t.sizeof);
+ OS.PtSetResource (menuHandle, OS.Pt_ARG_POS, ptr, 0);
+ OS.free (ptr);
+ } else {
+ OS.PtPositionMenu (menuHandle, null);
+ }
+
+ menu.sendEvent (SWT.Show);
+ OS.PtRealizeWidget (menuHandle);
+ }
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java
index f4ab7480ec..08d09fadbd 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
/**
* Instances of this class are used used to inform or warn the user.
* <dl>
@@ -31,8 +31,8 @@ import org.eclipse.swt.*;
* within the SWT implementation.
* </p>
*/
-public class MessageBox extends Dialog {
- String message = "";
+public class MessageBox extends Dialog {
+ String message = "";
/**
* Constructs a new instance of this class given only its
* parent.
@@ -55,9 +55,9 @@ public class MessageBox extends Dialog {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public MessageBox (Shell parent) {
- this (parent, SWT.OK | SWT.ICON_INFORMATION | SWT.APPLICATION_MODAL);
-}
+public MessageBox (Shell parent) {
+ this (parent, SWT.OK | SWT.ICON_INFORMATION | SWT.APPLICATION_MODAL);
+}
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -88,20 +88,20 @@ public MessageBox (Shell parent) {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public MessageBox (Shell parent, int style) {
- super (parent, checkStyle (style));
- checkSubclass ();
-}
-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 MessageBox (Shell parent, int style) {
+ super (parent, checkStyle (style));
+ checkSubclass ();
+}
+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;
+}
/**
* Returns the dialog's message, which is a description of
* the purpose for which it was opened. This message will be
@@ -109,9 +109,9 @@ static int checkStyle (int style) {
*
* @return the message
*/
-public String getMessage () {
- return message;
-}
+public String getMessage () {
+ return message;
+}
/**
* Makes the dialog visible and brings it to the front
* of the display.
@@ -124,81 +124,81 @@ public String getMessage () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
* </ul>
*/
-public int open () {
- String[] buttons = null;
- if ((style & SWT.OK) == SWT.OK) {
- buttons = new String[]{SWT.getMessage ("SWT_OK")};
- }
- if ((style & (SWT.OK | SWT.CANCEL)) == (SWT.OK | SWT.CANCEL)) {
- buttons = new String[]{SWT.getMessage ("SWT_OK"), SWT.getMessage ("SWT_Cancel")};
- }
- if ((style & (SWT.YES | SWT.NO)) == (SWT.YES | SWT.NO)) {
- buttons = new String[]{SWT.getMessage ("SWT_Yes"), SWT.getMessage ("SWT_No")};
- }
- if ((style & (SWT.YES | SWT.NO | SWT.CANCEL)) == (SWT.YES | SWT.NO | SWT.CANCEL)){
- buttons = new String[]{SWT.getMessage ("SWT_Yes"), SWT.getMessage ("SWT_No"), SWT.getMessage ("SWT_Cancel")};
- }
- if ((style & (SWT.RETRY | SWT.CANCEL)) == (SWT.RETRY | SWT.CANCEL)) {
- buttons = new String[]{SWT.getMessage ("SWT_Retry"), SWT.getMessage ("SWT_Cancel")};
- }
- if ((style & (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) == (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) {
- buttons = new String[]{SWT.getMessage ("SWT_Abort"), SWT.getMessage ("SWT_Retry"), SWT.getMessage ("SWT_Cancel")};
- }
- if (buttons == null) buttons = new String[]{SWT.getMessage ("SWT_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 && OS.PtWidgetIsRealized(parent.shellHandle)) {
- 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 int open () {
+ String[] buttons = null;
+ if ((style & SWT.OK) == SWT.OK) {
+ buttons = new String[]{SWT.getMessage ("SWT_OK")};
+ }
+ if ((style & (SWT.OK | SWT.CANCEL)) == (SWT.OK | SWT.CANCEL)) {
+ buttons = new String[]{SWT.getMessage ("SWT_OK"), SWT.getMessage ("SWT_Cancel")};
+ }
+ if ((style & (SWT.YES | SWT.NO)) == (SWT.YES | SWT.NO)) {
+ buttons = new String[]{SWT.getMessage ("SWT_Yes"), SWT.getMessage ("SWT_No")};
+ }
+ if ((style & (SWT.YES | SWT.NO | SWT.CANCEL)) == (SWT.YES | SWT.NO | SWT.CANCEL)){
+ buttons = new String[]{SWT.getMessage ("SWT_Yes"), SWT.getMessage ("SWT_No"), SWT.getMessage ("SWT_Cancel")};
+ }
+ if ((style & (SWT.RETRY | SWT.CANCEL)) == (SWT.RETRY | SWT.CANCEL)) {
+ buttons = new String[]{SWT.getMessage ("SWT_Retry"), SWT.getMessage ("SWT_Cancel")};
+ }
+ if ((style & (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) == (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) {
+ buttons = new String[]{SWT.getMessage ("SWT_Abort"), SWT.getMessage ("SWT_Retry"), SWT.getMessage ("SWT_Cancel")};
+ }
+ if (buttons == null) buttons = new String[]{SWT.getMessage ("SWT_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 && OS.PtWidgetIsRealized(parent.shellHandle)) {
+ 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;
+}
/**
* Sets the dialog's message, which is a description of
* the purpose for which it was opened. This message will be
@@ -206,7 +206,7 @@ public int open () {
*
* @param string the message
*/
-public void setMessage (String string) {
- message = string;
-}
-}
+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
index f551480d3a..7cdfb3ca94 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of the receiver represent is an unselectable
* user interface object that is used to display progress,
@@ -28,8 +28,8 @@ import org.eclipse.swt.graphics.*;
* within the SWT implementation.
* </p>
*/
-public class ProgressBar extends Control {
-
+public class ProgressBar extends Control {
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -60,64 +60,64 @@ public class ProgressBar extends Control {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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) {
- checkWidget();
- 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) {
- state |= HANDLE;
- Display display = getDisplay ();
- int clazz = display.PtProgress;
- int parentHandle = parent.parentingHandle ();
- int gaugeFlags = (style & SWT.INDETERMINATE) != 0 ? OS.Pt_GAUGE_INDETERMINATE : 0;
- int [] args = {
- OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
- OS.Pt_ARG_GAUGE_FLAGS, gaugeFlags, OS.Pt_GAUGE_INDETERMINATE,
- 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);
-}
-
-byte [] defaultFont () {
- Display display = getDisplay ();
- return display.GAUGE_FONT;
-}
-
+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) {
+ checkWidget();
+ 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) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int clazz = display.PtProgress;
+ int parentHandle = parent.parentingHandle ();
+ int gaugeFlags = (style & SWT.INDETERMINATE) != 0 ? OS.Pt_GAUGE_INDETERMINATE : 0;
+ int [] args = {
+ OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
+ OS.Pt_ARG_GAUGE_FLAGS, gaugeFlags, OS.Pt_GAUGE_INDETERMINATE,
+ 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);
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.GAUGE_FONT;
+}
+
/**
* Returns the maximum value which the receiver will allow.
*
@@ -128,13 +128,13 @@ byte [] defaultFont () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getMaximum () {
- checkWidget();
- int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getMaximum () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the minimum value which the receiver will allow.
*
@@ -145,13 +145,13 @@ public int getMaximum () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getMinimum () {
- checkWidget();
- int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getMinimum () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the single <em>selection</em> that is the receiver's position.
*
@@ -162,13 +162,13 @@ public int getMinimum () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getSelection () {
- checkWidget();
- int [] args = {OS.Pt_ARG_GAUGE_VALUE, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getSelection () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_GAUGE_VALUE, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Sets the maximum value which the receiver will allow
* to be the argument which must be greater than or
@@ -181,14 +181,14 @@ public int getSelection () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMaximum (int value) {
- checkWidget();
- int minimum = getMinimum();
- if (0 <= minimum && minimum < value) {
- OS.PtSetResource (handle, OS.Pt_ARG_MAXIMUM, value, 0);
- }
-}
-
+public void setMaximum (int value) {
+ checkWidget();
+ int minimum = getMinimum();
+ if (0 <= minimum && minimum < value) {
+ OS.PtSetResource (handle, OS.Pt_ARG_MAXIMUM, value, 0);
+ }
+}
+
/**
* Sets the minimum value which the receiver will allow
* to be the argument which must be greater than or
@@ -201,14 +201,14 @@ public void setMaximum (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMinimum (int value) {
- checkWidget();
- int maximum = getMaximum();
- if (0 <= value && value < maximum) {
- OS.PtSetResource (handle, OS.Pt_ARG_MINIMUM, value, 0);
- }
-}
-
+public void setMinimum (int value) {
+ checkWidget();
+ int maximum = getMaximum();
+ if (0 <= value && value < maximum) {
+ OS.PtSetResource (handle, OS.Pt_ARG_MINIMUM, value, 0);
+ }
+}
+
/**
* Sets the single <em>selection</em> that is the receiver's
* position to the argument which must be greater than or equal
@@ -221,17 +221,17 @@ public void setMinimum (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_GAUGE_VALUE, value, 0);
-}
-
-int traversalCode (int key_sym, PhKeyEvent_t ke) {
- return 0;
-}
-
-int widgetClass () {
- return OS.PtProgress ();
-}
-
-}
+public void setSelection (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_GAUGE_VALUE, value, 0);
+}
+
+int traversalCode (int key_sym, PhKeyEvent_t ke) {
+ return 0;
+}
+
+int widgetClass () {
+ return OS.PtProgress ();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java
index 3039a4df6d..52be69a650 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
/**
* Instances of the receiver represent a selectable user interface object
* that allows the user to drag a rubber banded outline of the sash within
@@ -29,12 +29,12 @@ import org.eclipse.swt.events.*;
* within the SWT implementation.
* </p>
*/
-public class Sash extends Control {
- boolean dragging;
- int startX, startY, lastX, lastY;
- final static int INCREMENT = 1;
- final static int PAGE_INCREMENT = 9;
-
+public class Sash extends Control {
+ boolean dragging;
+ int startX, startY, lastX, lastY;
+ final static int INCREMENT = 1;
+ final static int PAGE_INCREMENT = 9;
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -64,10 +64,10 @@ public class Sash extends Control {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Sash (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
+public Sash (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the control is selected, by sending
@@ -93,220 +93,220 @@ public Sash (Composite parent, int style) {
* @see #removeSelectionListener
* @see SelectionEvent
*/
-public void addSelectionListener (SelectionListener listener) {
- checkWidget();
- 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) {
- checkWidget();
- 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) {
- state |= GRAB | HANDLE;
- Display display = getDisplay ();
- int clazz = display.PtContainer;
- int parentHandle = parent.parentingHandle ();
- int cursor = ((style & SWT.HORIZONTAL) != 0) ? OS.Ph_CURSOR_DRAG_VERTICAL : OS.Ph_CURSOR_DRAG_HORIZONTAL;
- int [] args = {
- OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
- 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);
-}
-
-byte [] defaultFont () {
- Display display = getDisplay ();
- return display.TITLE_FONT;
-}
-
-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 Ph_EV_BUT_PRESS (int widget, int info) {
- int result = super.Ph_EV_BUT_PRESS (widget, info);
- if (result != OS.Pt_CONTINUE)return result;
- processMouse (info);
- return result;
-}
-
-int Ph_EV_BUT_RELEASE (int widget, int info) {
- int result = super.Ph_EV_BUT_RELEASE (widget, info);
- if (result != OS.Pt_CONTINUE)return result;
- processMouse (info);
- return result;
-}
-
-int Ph_EV_DRAG (int widget, int info) {
- int result = super.Ph_EV_DRAG (widget, info);
- if (result != OS.Pt_CONTINUE)return result;
- processMouse (info);
- return result;
-}
-
-int Ph_EV_PTR_MOTION (int widget, int info) {
- int result = super.Ph_EV_PTR_MOTION (widget, info);
- if (result != OS.Pt_CONTINUE)return result;
- processMouse (info);
- return result;
-}
-
-void processMouse (int info) {
- PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
- OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
- PhEvent_t ev = new PhEvent_t ();
- OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
- int data = OS.PhGetData (cbinfo.event);
- PhPointerEvent_t pe = new PhPointerEvent_t ();
- OS.memmove (pe, data, PhPointerEvent_t.sizeof);
- if (pe.buttons != OS.Ph_BUTTON_SELECT) return;
-
- 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;
-
- /* 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;
- }
- /* Compute the banding rectangle */
- if (!dragging) return;
- 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;
- }
- if (!dragging) return;
-
- /* Compute the banding rectangle */
- x += area.pos_x;
- y += area.pos_y;
- Rectangle r = parent.getClientArea ();
- int clientWidth = r.width;
- int clientHeight = r.height;
- int newX = lastX, newY = lastY;
- if ((style & SWT.VERTICAL) != 0) {
- newX = Math.min (Math.max (0, x - startX), clientWidth - width);
- } else {
- newY = Math.min (Math.max (0, y - startY), clientHeight - height);
- }
- if ((newX == lastX) && (newY == lastY)) return;
- 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;
-
- /* Draw the banding rectangle */
- if (event.doit) {
- lastX = event.x; lastY = event.y;
- OS.PtFlush ();
- drawBand (lastX, lastY, width, height);
- }
- break;
- }
-}
-
+public void addSelectionListener (SelectionListener listener) {
+ checkWidget();
+ 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) {
+ checkWidget();
+ 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) {
+ state |= GRAB | HANDLE;
+ Display display = getDisplay ();
+ int clazz = display.PtContainer;
+ int parentHandle = parent.parentingHandle ();
+ int cursor = ((style & SWT.HORIZONTAL) != 0) ? OS.Ph_CURSOR_DRAG_VERTICAL : OS.Ph_CURSOR_DRAG_HORIZONTAL;
+ int [] args = {
+ OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
+ 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);
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.TITLE_FONT;
+}
+
+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 Ph_EV_BUT_PRESS (int widget, int info) {
+ int result = super.Ph_EV_BUT_PRESS (widget, info);
+ if (result != OS.Pt_CONTINUE)return result;
+ processMouse (info);
+ return result;
+}
+
+int Ph_EV_BUT_RELEASE (int widget, int info) {
+ int result = super.Ph_EV_BUT_RELEASE (widget, info);
+ if (result != OS.Pt_CONTINUE)return result;
+ processMouse (info);
+ return result;
+}
+
+int Ph_EV_DRAG (int widget, int info) {
+ int result = super.Ph_EV_DRAG (widget, info);
+ if (result != OS.Pt_CONTINUE)return result;
+ processMouse (info);
+ return result;
+}
+
+int Ph_EV_PTR_MOTION (int widget, int info) {
+ int result = super.Ph_EV_PTR_MOTION (widget, info);
+ if (result != OS.Pt_CONTINUE)return result;
+ processMouse (info);
+ return result;
+}
+
+void processMouse (int info) {
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ PhEvent_t ev = new PhEvent_t ();
+ OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
+ int data = OS.PhGetData (cbinfo.event);
+ PhPointerEvent_t pe = new PhPointerEvent_t ();
+ OS.memmove (pe, data, PhPointerEvent_t.sizeof);
+ if (pe.buttons != OS.Ph_BUTTON_SELECT) return;
+
+ 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;
+
+ /* 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;
+ }
+ /* Compute the banding rectangle */
+ if (!dragging) return;
+ 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;
+ }
+ if (!dragging) return;
+
+ /* Compute the banding rectangle */
+ x += area.pos_x;
+ y += area.pos_y;
+ Rectangle r = parent.getClientArea ();
+ int clientWidth = r.width;
+ int clientHeight = r.height;
+ int newX = lastX, newY = lastY;
+ if ((style & SWT.VERTICAL) != 0) {
+ newX = Math.min (Math.max (0, x - startX), clientWidth - width);
+ } else {
+ newY = Math.min (Math.max (0, y - startY), clientHeight - height);
+ }
+ if ((newX == lastX) && (newY == lastY)) return;
+ 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;
+
+ /* Draw the banding rectangle */
+ if (event.doit) {
+ lastX = event.x; lastY = event.y;
+ OS.PtFlush ();
+ drawBand (lastX, lastY, width, height);
+ }
+ break;
+ }
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the control is selected.
@@ -324,84 +324,84 @@ void processMouse (int info) {
* @see SelectionListener
* @see #addSelectionListener
*/
-public void removeSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
-int traversalCode (int key_sym, PhKeyEvent_t ke) {
- return 0;
-}
-
-boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
- boolean result = super.translateTraversal (key_sym, phEvent);
- if (!result) {
- switch (key_sym) {
- case OS.Pk_Left:
- case OS.Pk_Right:
- case OS.Pk_Up:
- case OS.Pk_Down:
-
- /* Calculate the new x or y position */
- if ((phEvent.button_state & OS.Ph_BUTTON_SELECT) != 0) return result;
- int step = (phEvent.key_mods & OS.Pk_KM_Ctrl) != 0 ? INCREMENT : PAGE_INCREMENT;
- int x = 0, y = 0;
- if ((style & SWT.VERTICAL) != 0) {
- if (key_sym == OS.Pk_Up || key_sym == OS.Pk_Down) break;
- x = key_sym == OS.Pk_Left ? -step : step;
- } else {
- if (key_sym == OS.Pk_Left || key_sym == OS.Pk_Right) break;
- y = key_sym == OS.Pk_Up ? -step : step;
- }
- PhArea_t area = new PhArea_t ();
- OS.PtWidgetArea (handle, area);
- x += area.pos_x;
- y += area.pos_y;
- int width = area.size_w;
- int height = area.size_h;
- Rectangle r = parent.getClientArea ();
- int clientWidth = r.width;
- int clientHeight = r.height;
- int newX = lastX, newY = lastY;
- if ((style & SWT.VERTICAL) != 0) {
- newX = Math.min (Math.max (0, x - startX), clientWidth - width);
- } else {
- newY = Math.min (Math.max (0, y - startY), clientHeight - height);
- }
- if (newX == lastX && newY == lastY) return result;
-
- /* The event must be sent because doit flag is used */
- Event event = new Event ();
- event.x = newX; event.y = newY;
- event.width = width; event.height = height;
-
- /*
- * 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 true;
- if (event.doit) {
- OS.PtWidgetArea (handle, area);
- int cursorX = area.size_w / 2, cursorY = area.size_h / 2;
- short [] absX = new short [1], absY = new short [1];
- OS.PtGetAbsPosition (handle, absX, absY);
- OS.PhMoveCursorAbs (OS.PhInputGroup (0), cursorX + absX [0], cursorY + absY [0]);
- }
- return result;
- }
- }
- return result;
-}
-
-int widgetClass () {
- return OS.PtContainer ();
-}
-
-}
+public void removeSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+int traversalCode (int key_sym, PhKeyEvent_t ke) {
+ return 0;
+}
+
+boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
+ boolean result = super.translateTraversal (key_sym, phEvent);
+ if (!result) {
+ switch (key_sym) {
+ case OS.Pk_Left:
+ case OS.Pk_Right:
+ case OS.Pk_Up:
+ case OS.Pk_Down:
+
+ /* Calculate the new x or y position */
+ if ((phEvent.button_state & OS.Ph_BUTTON_SELECT) != 0) return result;
+ int step = (phEvent.key_mods & OS.Pk_KM_Ctrl) != 0 ? INCREMENT : PAGE_INCREMENT;
+ int x = 0, y = 0;
+ if ((style & SWT.VERTICAL) != 0) {
+ if (key_sym == OS.Pk_Up || key_sym == OS.Pk_Down) break;
+ x = key_sym == OS.Pk_Left ? -step : step;
+ } else {
+ if (key_sym == OS.Pk_Left || key_sym == OS.Pk_Right) break;
+ y = key_sym == OS.Pk_Up ? -step : step;
+ }
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (handle, area);
+ x += area.pos_x;
+ y += area.pos_y;
+ int width = area.size_w;
+ int height = area.size_h;
+ Rectangle r = parent.getClientArea ();
+ int clientWidth = r.width;
+ int clientHeight = r.height;
+ int newX = lastX, newY = lastY;
+ if ((style & SWT.VERTICAL) != 0) {
+ newX = Math.min (Math.max (0, x - startX), clientWidth - width);
+ } else {
+ newY = Math.min (Math.max (0, y - startY), clientHeight - height);
+ }
+ if (newX == lastX && newY == lastY) return result;
+
+ /* The event must be sent because doit flag is used */
+ Event event = new Event ();
+ event.x = newX; event.y = newY;
+ event.width = width; event.height = height;
+
+ /*
+ * 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 true;
+ if (event.doit) {
+ OS.PtWidgetArea (handle, area);
+ int cursorX = area.size_w / 2, cursorY = area.size_h / 2;
+ short [] absX = new short [1], absY = new short [1];
+ OS.PtGetAbsPosition (handle, absX, absY);
+ OS.PhMoveCursorAbs (OS.PhInputGroup (0), cursorX + absX [0], cursorY + absY [0]);
+ }
+ return result;
+ }
+ }
+ return result;
+}
+
+int widgetClass () {
+ return OS.PtContainer ();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java
index b9065e6395..8a96ccf0d6 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
/**
* Instances of the receiver represent a selectable user
* interface object that present a range of continuous
@@ -30,9 +30,9 @@ import org.eclipse.swt.events.*;
* within the SWT implementation.
* </p>
*/
-public class Scale extends Control {
-
-
+public class Scale extends Control {
+
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -62,10 +62,10 @@ public class Scale extends Control {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Scale (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
+public Scale (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver's value changes, by sending
@@ -85,67 +85,67 @@ public Scale (Composite parent, int style) {
* @see SelectionListener
* @see #removeSelectionListener
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- 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) {
- checkWidget();
- PhDim_t dim = new PhDim_t();
- if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
- OS.PtWidgetPreferredSize(handle, dim);
- /*
- * Feature in Photon. The preferred size of PtSlider is only the
- * handle size. Add extra space for the rest.
- */
- int width, height;
- if ((style & SWT.HORIZONTAL) != 0) {
- width = dim.w * 7; height = dim.h * 2;
- } else {
- width = dim.w * 2; height = dim.h * 7;
- }
- 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) {
- state |= HANDLE;
- Display display = getDisplay ();
- int clazz = display.PtSlider;
- int parentHandle = parent.parentingHandle ();
- 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_FILL_COLOR, display.WIDGET_BACKGROUND, 0,
- OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
- };
- handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
-}
-
-byte [] defaultFont () {
- Display display = getDisplay ();
- return display.GAUGE_FONT;
-}
-
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ 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) {
+ checkWidget();
+ PhDim_t dim = new PhDim_t();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
+ OS.PtWidgetPreferredSize(handle, dim);
+ /*
+ * Feature in Photon. The preferred size of PtSlider is only the
+ * handle size. Add extra space for the rest.
+ */
+ int width, height;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ width = dim.w * 7; height = dim.h * 2;
+ } else {
+ width = dim.w * 2; height = dim.h * 7;
+ }
+ 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) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int clazz = display.PtSlider;
+ int parentHandle = parent.parentingHandle ();
+ 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_FILL_COLOR, display.WIDGET_BACKGROUND, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.GAUGE_FONT;
+}
+
/**
* Returns the amount that the receiver's value will be
* modified by when the up/down (or right/left) arrows
@@ -158,13 +158,13 @@ byte [] defaultFont () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getIncrement () {
- checkWidget();
- int [] args = {OS.Pt_ARG_INCREMENT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getIncrement () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the maximum value which the receiver will allow.
*
@@ -175,13 +175,13 @@ public int getIncrement () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getMaximum () {
- checkWidget();
- int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getMaximum () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the minimum value which the receiver will allow.
*
@@ -192,13 +192,13 @@ public int getMaximum () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getMinimum () {
- checkWidget();
- int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getMinimum () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the amount that the receiver's value will be
* modified by when the page increment/decrement areas
@@ -211,13 +211,13 @@ public int getMinimum () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getPageIncrement () {
- checkWidget();
- int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getPageIncrement () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the single <em>selection</em> that is the receiver's position.
*
@@ -228,25 +228,25 @@ public int getPageIncrement () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getSelection () {
- checkWidget();
- int [] args = {OS.Pt_ARG_GAUGE_VALUE, 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_SLIDER_MOVE, windowProc, OS.Pt_CB_SLIDER_MOVE);
-}
-
-int Pt_CB_SLIDER_MOVE (int widget, int info) {
- if (info == 0) return OS.Pt_CONTINUE;
- sendEvent(SWT.Selection);
- return OS.Pt_CONTINUE;
-}
-
+public int getSelection () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_GAUGE_VALUE, 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_SLIDER_MOVE, windowProc, OS.Pt_CB_SLIDER_MOVE);
+}
+
+int Pt_CB_SLIDER_MOVE (int widget, int info) {
+ if (info == 0) return OS.Pt_CONTINUE;
+ sendEvent(SWT.Selection);
+ return OS.Pt_CONTINUE;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver's value changes.
@@ -264,14 +264,14 @@ int Pt_CB_SLIDER_MOVE (int widget, int info) {
* @see SelectionListener
* @see #addSelectionListener
*/
-public void removeSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
+public void removeSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
/**
* Sets the amount that the receiver's value will be
* modified by when the up/down (or right/left) arrows
@@ -285,11 +285,11 @@ public void removeSelectionListener(SelectionListener listener) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setIncrement (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_INCREMENT, value, 0);
-}
-
+public void setIncrement (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_INCREMENT, value, 0);
+}
+
/**
* Sets the maximum value which the receiver will allow
* to be the argument which must be greater than or
@@ -302,11 +302,11 @@ public void setIncrement (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMaximum (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_MAXIMUM, value - 1, 0);
-}
-
+public void setMaximum (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_MAXIMUM, value - 1, 0);
+}
+
/**
* Sets the minimum value which the receiver will allow
* to be the argument which must be greater than or
@@ -319,11 +319,11 @@ public void setMaximum (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMinimum (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_MINIMUM, value, 0);
-}
-
+public void setMinimum (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_MINIMUM, value, 0);
+}
+
/**
* Sets the amount that the receiver's value will be
* modified by when the page increment/decrement areas
@@ -337,11 +337,11 @@ public void setMinimum (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setPageIncrement (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_PAGE_INCREMENT, value, 0);
-}
-
+public void setPageIncrement (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_PAGE_INCREMENT, value, 0);
+}
+
/**
* Sets the single <em>selection</em> that is the receiver's
* value to the argument which must be greater than or equal
@@ -354,13 +354,13 @@ public void setPageIncrement (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_GAUGE_VALUE, value, 0);
-}
-
-int widgetClass () {
- return OS.PtSlider ();
-}
-
-}
+public void setSelection (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_GAUGE_VALUE, value, 0);
+}
+
+int widgetClass () {
+ return OS.PtSlider ();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java
index ede7446d6f..9dcd537e80 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
/**
* Instances of this class are selectable user interface
* objects that represent a range of positive, numeric values.
@@ -75,27 +75,27 @@ import org.eclipse.swt.events.*;
* @see Scrollable#getHorizontalBar
* @see Scrollable#getVerticalBar
*/
-public class ScrollBar extends Widget {
- Scrollable parent;
-
-ScrollBar (Scrollable parent, int style, int handle) {
- super (parent, checkStyle (style));
- this.parent = parent;
- this.handle = handle;
- state |= 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 class ScrollBar extends Widget {
+ Scrollable parent;
+
+ScrollBar (Scrollable parent, int style, int handle) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ this.handle = handle;
+ state |= 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);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver's value changes, by sending
@@ -128,51 +128,51 @@ static int checkStyle (int style) {
* @see #removeSelectionListener
* @see SelectionEvent
*/
-public void addSelectionListener (SelectionListener listener) {
- checkWidget();
- 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) {
- state |= HANDLE;
- if (handle != 0) return;
- Display display = getDisplay ();
- int parentHandle = parent.scrolledHandle;
- int orientation, sizeArg, size, basicFlags;
- if ((style & SWT.HORIZONTAL) != 0) {
- orientation = OS.Pt_HORIZONTAL;
- sizeArg = OS.Pt_ARG_HEIGHT;
- size = display.SCROLLBAR_HEIGHT;
- basicFlags = display.SCROLLBAR_HORIZONTAL_BASIC_FLAGS;
- } else {
- orientation = OS.Pt_VERTICAL;
- sizeArg = OS.Pt_ARG_WIDTH;
- size = display.SCROLLBAR_WIDTH;
- basicFlags = display.SCROLLBAR_VERTICAL_BASIC_FLAGS;
- }
- int [] args = {
- sizeArg, size, 0,
- OS.Pt_ARG_MAXIMUM, 100, 0,
- OS.Pt_ARG_PAGE_INCREMENT, 10, 0,
- OS.Pt_ARG_SLIDER_SIZE, 10, 0,
- OS.Pt_ARG_BASIC_FLAGS, basicFlags, ~0,
- OS.Pt_ARG_ORIENTATION, orientation, 0,
- OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
- OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
- };
- handle = OS.PtCreateWidget (OS.PtScrollbar (), parentHandle, args.length / 3, args);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
-}
-
-public Display getDisplay () {
- Scrollable parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-
+public void addSelectionListener (SelectionListener listener) {
+ checkWidget();
+ 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) {
+ state |= HANDLE;
+ if (handle != 0) return;
+ Display display = getDisplay ();
+ int parentHandle = parent.scrolledHandle;
+ int orientation, sizeArg, size, basicFlags;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ orientation = OS.Pt_HORIZONTAL;
+ sizeArg = OS.Pt_ARG_HEIGHT;
+ size = display.SCROLLBAR_HEIGHT;
+ basicFlags = display.SCROLLBAR_HORIZONTAL_BASIC_FLAGS;
+ } else {
+ orientation = OS.Pt_VERTICAL;
+ sizeArg = OS.Pt_ARG_WIDTH;
+ size = display.SCROLLBAR_WIDTH;
+ basicFlags = display.SCROLLBAR_VERTICAL_BASIC_FLAGS;
+ }
+ int [] args = {
+ sizeArg, size, 0,
+ OS.Pt_ARG_MAXIMUM, 100, 0,
+ OS.Pt_ARG_PAGE_INCREMENT, 10, 0,
+ OS.Pt_ARG_SLIDER_SIZE, 10, 0,
+ OS.Pt_ARG_BASIC_FLAGS, basicFlags, ~0,
+ OS.Pt_ARG_ORIENTATION, orientation, 0,
+ OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (OS.PtScrollbar (), parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+public Display getDisplay () {
+ Scrollable parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
/**
* Returns <code>true</code> if the receiver is enabled, and
* <code>false</code> otherwise. A disabled control is typically
@@ -186,12 +186,12 @@ public Display getDisplay () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getEnabled () {
- checkWidget ();
- int topHandle = topHandle ();
- return (OS.PtWidgetFlags (topHandle) & OS.Pt_BLOCKED) == 0;
-}
-
+public boolean getEnabled () {
+ checkWidget ();
+ int topHandle = topHandle ();
+ return (OS.PtWidgetFlags (topHandle) & OS.Pt_BLOCKED) == 0;
+}
+
/**
* Returns the amount that the receiver's value will be
* modified by when the up/down (or right/left) arrows
@@ -204,13 +204,13 @@ public boolean getEnabled () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getIncrement () {
- checkWidget();
- int [] args = {OS.Pt_ARG_INCREMENT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getIncrement () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the minimum value which the receiver will allow.
*
@@ -221,13 +221,13 @@ public int getIncrement () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getMinimum () {
- checkWidget();
- int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getMinimum () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the maximum value which the receiver will allow.
*
@@ -238,13 +238,13 @@ public int getMinimum () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getMaximum () {
- checkWidget();
- int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getMaximum () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the amount that the receiver's value will be
* modified by when the page increment/decrement areas
@@ -257,13 +257,13 @@ public int getMaximum () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getPageIncrement () {
- checkWidget();
- int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getPageIncrement () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the receiver's parent, which must be scrollable.
*
@@ -274,11 +274,11 @@ public int getPageIncrement () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Scrollable getParent () {
- checkWidget();
- return parent;
-}
-
+public Scrollable getParent () {
+ checkWidget();
+ return parent;
+}
+
/**
* Returns the single <em>selection</em> that is the receiver's value.
*
@@ -289,33 +289,33 @@ public Scrollable getParent () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getSelection () {
- checkWidget();
- int [] args = {OS.Pt_ARG_GAUGE_VALUE, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
-/**
- * Returns a point describing the receiver's size. The
- * x coordinate of the result is the width of the receiver.
- * The y coordinate of the result is the height of the
- * receiver.
- *
- * @return the receiver's size
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public int getSelection () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_GAUGE_VALUE, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+/**
+ * Returns a point describing the receiver's size. The
+ * x coordinate of the result is the width of the receiver.
+ * The y coordinate of the result is the height of the
+ * receiver.
+ *
+ * @return the receiver's size
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public Point getSize () {
- checkWidget();
- 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 Point getSize () {
+ checkWidget();
+ 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]);
+}
+
/**
* Answers the size of the receiver's thumb relative to the
* difference between its maximum and minimum values.
@@ -329,13 +329,13 @@ public Point getSize () {
*
* @see ScrollBar
*/
-public int getThumb () {
- checkWidget();
- int [] args = {OS.Pt_ARG_SLIDER_SIZE, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getThumb () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_SLIDER_SIZE, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns <code>true</code> if the receiver is visible, and
* <code>false</code> otherwise.
@@ -353,91 +353,91 @@ public int getThumb () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getVisible () {
- checkWidget ();
- int topHandle = topHandle ();
- return (OS.PtWidgetFlags (topHandle) & OS.Pt_DELAY_REALIZE) == 0;
-}
-
-void hookEvents () {
- int windowProc = getDisplay ().windowProc;
- OS.PtAddCallback (handle, OS.Pt_CB_SCROLL_MOVE, windowProc, OS.Pt_CB_SCROLL_MOVE);
-}
-
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
+public boolean getVisible () {
+ checkWidget ();
+ int topHandle = topHandle ();
+ return (OS.PtWidgetFlags (topHandle) & OS.Pt_DELAY_REALIZE) == 0;
+}
+
+void hookEvents () {
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_SCROLL_MOVE, windowProc, OS.Pt_CB_SCROLL_MOVE);
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
*/
-public boolean isEnabled () {
- checkWidget();
- return getEnabled () && parent.isEnabled ();
-}
-
-/**
- * Returns <code>true</code> if the receiver is visible and all
- * of the receiver's ancestors are visible and <code>false</code>
- * otherwise.
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getVisible
+public boolean isEnabled () {
+ checkWidget();
+ return getEnabled () && parent.isEnabled ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
*/
-public boolean isVisible () {
- checkWidget();
- return OS.PtWidgetIsRealized (handle);
-}
-
-int Pt_CB_SCROLL_MOVE (int widget, 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 boolean isVisible () {
+ checkWidget();
+ return OS.PtWidgetIsRealized (handle);
+}
+
+int Pt_CB_SCROLL_MOVE (int widget, 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;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver's value changes.
@@ -455,26 +455,26 @@ int Pt_CB_SCROLL_MOVE (int widget, int info) {
* @see SelectionListener
* @see #addSelectionListener
*/
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget();
- 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);
- OS.PtSetResource (handle, OS.Pt_ARG_AREA, ptr, 0);
- OS.free (ptr);
-}
-
+public void removeSelectionListener (SelectionListener listener) {
+ checkWidget();
+ 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);
+ OS.PtSetResource (handle, OS.Pt_ARG_AREA, ptr, 0);
+ OS.free (ptr);
+}
+
/**
* Enables the receiver if the argument is <code>true</code>,
* and disables it otherwise. A disabled control is typically
@@ -488,12 +488,12 @@ void setBounds (int x, int y, int width, int height) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setEnabled (boolean enabled) {
- checkWidget ();
- int topHandle = topHandle ();
- int flags = enabled ? 0 : OS.Pt_BLOCKED | OS.Pt_GHOST;
- OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
-}
+public void setEnabled (boolean enabled) {
+ checkWidget ();
+ int topHandle = topHandle ();
+ int flags = enabled ? 0 : OS.Pt_BLOCKED | OS.Pt_GHOST;
+ OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
+}
/**
* Sets the amount that the receiver's value will be
* modified by when the up/down (or right/left) arrows
@@ -507,11 +507,11 @@ public void setEnabled (boolean enabled) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setIncrement (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_INCREMENT, value, 0);
-}
-
+public void setIncrement (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_INCREMENT, value, 0);
+}
+
/**
* Sets the maximum value which the receiver will allow
* to be the argument which must be greater than or
@@ -524,11 +524,11 @@ public void setIncrement (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMaximum (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_MAXIMUM, value - 1, 0);
-}
-
+public void setMaximum (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_MAXIMUM, value - 1, 0);
+}
+
/**
* Sets the minimum value which the receiver will allow
* to be the argument which must be greater than or
@@ -541,11 +541,11 @@ public void setMaximum (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMinimum (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_MINIMUM, value, 0);
-}
-
+public void setMinimum (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_MINIMUM, value, 0);
+}
+
/**
* Sets the amount that the receiver's value will be
* modified by when the page increment/decrement areas
@@ -559,11 +559,11 @@ public void setMinimum (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setPageIncrement (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_PAGE_INCREMENT, value, 0);
-}
-
+public void setPageIncrement (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_PAGE_INCREMENT, value, 0);
+}
+
/**
* Sets the single <em>selection</em> that is the receiver's
* value to the argument which must be greater than or equal
@@ -576,11 +576,11 @@ public void setPageIncrement (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_GAUGE_VALUE, value, 0);
-}
-
+public void setSelection (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_GAUGE_VALUE, value, 0);
+}
+
/**
* Sets the size of the receiver's thumb relative to the
* difference between its maximum and minimum values to the
@@ -595,11 +595,11 @@ public void setSelection (int value) {
*
* @see ScrollBar
*/
-public void setThumb (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_SLIDER_SIZE, value, 0);
-}
-
+public void setThumb (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_SLIDER_SIZE, value, 0);
+}
+
/**
* Sets the receiver's selection, minimum value, maximum
* value, thumb, increment and page increment all at once.
@@ -621,25 +621,25 @@ public void setThumb (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
- checkWidget();
- if (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_GAUGE_VALUE, 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 setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
+ checkWidget();
+ 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_GAUGE_VALUE, 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);
+}
+
/**
* Marks the receiver as visible if the argument is <code>true</code>,
* and marks it invisible otherwise.
@@ -656,23 +656,23 @@ public void setValues (int selection, int minimum, int maximum, int thumb, int i
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setVisible (boolean visible) {
- checkWidget ();
- int topHandle = topHandle ();
- int flags = visible ? 0 : OS.Pt_DELAY_REALIZE;
- OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_DELAY_REALIZE);
- if (OS.PtWidgetIsRealized (parent.handle)) {
- if (visible != OS.PtWidgetIsRealized (topHandle)) {
- if (visible) {
- sendEvent (SWT.Show);
- OS.PtRealizeWidget (topHandle);
- } else {
- OS.PtUnrealizeWidget (topHandle);
- sendEvent(SWT.Hide);
- }
- }
- }
- parent.resizeClientArea ();
-}
-
-}
+public void setVisible (boolean visible) {
+ checkWidget ();
+ int topHandle = topHandle ();
+ int flags = visible ? 0 : OS.Pt_DELAY_REALIZE;
+ OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_DELAY_REALIZE);
+ if (OS.PtWidgetIsRealized (parent.handle)) {
+ if (visible != OS.PtWidgetIsRealized (topHandle)) {
+ if (visible) {
+ sendEvent (SWT.Show);
+ OS.PtRealizeWidget (topHandle);
+ } else {
+ OS.PtUnrealizeWidget (topHandle);
+ sendEvent(SWT.Hide);
+ }
+ }
+ }
+ parent.resizeClientArea ();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java
index afae5b9b27..f0abe1bf35 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* This class is the abstract superclass of all classes which
* represent controls that have standard scroll bars.
@@ -25,14 +25,14 @@ import org.eclipse.swt.graphics.*;
* within the SWT implementation.
* </p>
*/
-public abstract class Scrollable extends Control {
- int scrolledHandle;
- ScrollBar horizontalBar, verticalBar;
-
-Scrollable () {
- /* Do nothing */
-}
-
+public abstract class Scrollable extends Control {
+ int scrolledHandle;
+ ScrollBar horizontalBar, verticalBar;
+
+Scrollable () {
+ /* Do nothing */
+}
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -62,39 +62,39 @@ Scrollable () {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Scrollable (Composite parent, int style) {
- super (parent, style);
-}
-
-void createStandardScrollBars () {
- /* 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:
- if ((style & SWT.H_SCROLL) != 0) {
- horizontalBar = new ScrollBar (this, SWT.HORIZONTAL, child);
- }
- break;
- case OS.Pt_VERTICAL:
- if ((style & SWT.V_SCROLL) != 0) {
- verticalBar = new ScrollBar (this, SWT.VERTICAL, child);
- }
- break;
- }
- }
- child = OS.PtWidgetBrotherBehind (child);
- }
-}
-
-void deregister () {
- super.deregister ();
- if (scrolledHandle != 0) WidgetTable.remove (scrolledHandle);
-}
-
+public Scrollable (Composite parent, int style) {
+ super (parent, style);
+}
+
+void createStandardScrollBars () {
+ /* 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:
+ if ((style & SWT.H_SCROLL) != 0) {
+ horizontalBar = new ScrollBar (this, SWT.HORIZONTAL, child);
+ }
+ break;
+ case OS.Pt_VERTICAL:
+ if ((style & SWT.V_SCROLL) != 0) {
+ verticalBar = new ScrollBar (this, SWT.VERTICAL, child);
+ }
+ break;
+ }
+ }
+ child = OS.PtWidgetBrotherBehind (child);
+ }
+}
+
+void deregister () {
+ super.deregister ();
+ if (scrolledHandle != 0) WidgetTable.remove (scrolledHandle);
+}
+
/**
* Given a desired <em>client area</em> for the receiver
* (as described by the arguments), returns the bounding
@@ -118,26 +118,26 @@ void deregister () {
*
* @see #getClientArea
*/
-public Rectangle computeTrim (int x, int y, int width, int height) {
- checkWidget();
- 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) {
- Point size = horizontalBar.getSize ();
- area.size_h += size.y;
- }
- if (verticalBar != null) {
- 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 computeTrim (int x, int y, int width, int height) {
+ checkWidget();
+ 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) {
+ Point size = horizontalBar.getSize ();
+ area.size_h += size.y;
+ }
+ if (verticalBar != null) {
+ Point size = verticalBar.getSize ();
+ area.size_w += size.x;
+ }
+ return new Rectangle (area.pos_x, area.pos_y, area.size_w, area.size_h);
+}
+
/**
* Returns a rectangle which describes the area of the
* receiver which is capable of displaying data (that is,
@@ -152,17 +152,17 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
*
* @see #computeTrim
*/
-public Rectangle getClientArea () {
- checkWidget();
- PhRect_t rect = new PhRect_t ();
- int validParent = OS.PtValidParent (handle, OS.PtContainer ());
- if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
- OS.PtCalcCanvas (validParent, 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 Rectangle getClientArea () {
+ checkWidget();
+ PhRect_t rect = new PhRect_t ();
+ int validParent = OS.PtValidParent (handle, OS.PtContainer ());
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
+ OS.PtCalcCanvas (validParent, 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);
+}
+
/**
* Returns the receiver's horizontal scroll bar if it has
* one, and null if it does not.
@@ -174,11 +174,11 @@ public Rectangle getClientArea () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public ScrollBar getHorizontalBar () {
- checkWidget();
- return horizontalBar;
-}
-
+public ScrollBar getHorizontalBar () {
+ checkWidget();
+ return horizontalBar;
+}
+
/**
* Returns the receiver's vertical scroll bar if it has
* one, and null if it does not.
@@ -190,40 +190,40 @@ public ScrollBar getHorizontalBar () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public ScrollBar getVerticalBar () {
- checkWidget();
- return verticalBar;
-}
-
-boolean isTabGroup () {
- if ((state & CANVAS) != 0) return true;
- return super.isTabGroup ();
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- scrolledHandle = 0;
-}
-
-void resizeClientArea () {
- /* Do nothing */
-}
-
-void releaseWidget () {
- if (horizontalBar != null) horizontalBar.releaseResources ();
- if (verticalBar != null) verticalBar.releaseResources ();
- 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;
-}
-
-}
+public ScrollBar getVerticalBar () {
+ checkWidget();
+ return verticalBar;
+}
+
+boolean isTabGroup () {
+ if ((state & CANVAS) != 0) return true;
+ return super.isTabGroup ();
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ scrolledHandle = 0;
+}
+
+void resizeClientArea () {
+ /* Do nothing */
+}
+
+void releaseWidget () {
+ if (horizontalBar != null) horizontalBar.releaseResources ();
+ if (verticalBar != null) verticalBar.releaseResources ();
+ 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/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java
index 5c880743c9..9c5fa115f1 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java
@@ -1,107 +1,107 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.*;
-
-/**
- * Instances of this class represent the "windows"
- * which the desktop or "window manager" is managing.
- * Instances that do not have a parent (that is, they
- * are built using the constructor, which takes a
- * <code>Display</code> as the argument) are described
- * as <em>top level</em> shells. Instances that do have
- * a parent are described as <em>secondary</em> or
- * <em>dialog</em> shells.
- * <p>
- * Instances are always displayed in one of the maximized,
- * minimized or normal states:
- * <ul>
- * <li>
- * When an instance is marked as <em>maximized</em>, the
- * window manager will typically resize it to fill the
- * entire visible area of the display, and the instance
- * is usually put in a state where it can not be resized
- * (even if it has style <code>RESIZE</code>) until it is
- * no longer maximized.
- * </li><li>
- * When an instance is in the <em>normal</em> state (neither
- * maximized or minimized), its appearance is controlled by
- * the style constants which were specified when it was created
- * and the restrictions of the window manager (see below).
- * </li><li>
- * When an instance has been marked as <em>minimized</em>,
- * its contents (client area) will usually not be visible,
- * and depending on the window manager, it may be
- * "iconified" (that is, replaced on the desktop by a small
- * simplified representation of itself), relocated to a
- * distinguished area of the screen, or hidden. Combinations
- * of these changes are also possible.
- * </li>
- * </ul>
- * </p>
- * <p>
- * Note: The styles supported by this class must be treated
- * as <em>HINT</em>s, since the window manager for the
- * desktop on which the instance is visible has ultimate
- * control over the appearance and behavior of decorations
- * and modality. For example, some window managers only
- * support resizable windows and will always assume the
- * RESIZE style, even if it is not set. In addition, if a
- * modality style is not supported, it is "upgraded" to a
- * more restrictive modality style that is supported. For
- * example, if <code>PRIMARY_MODAL</code> is not supported,
- * it would be upgraded to <code>APPLICATION_MODAL</code>.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE</dd>
- * <dd>APPLICATION_MODAL, MODELESS, PRIMARY_MODAL, SYSTEM_MODAL</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Activate, Close, Deactivate, Deiconify, Iconify</dd>
- * </dl>
- * Class <code>SWT</code> provides two "convenience constants"
- * for the most commonly required style combinations:
- * <dl>
- * <dt><code>SHELL_TRIM</code></dt>
- * <dd>
- * the result of combining the constants which are required
- * to produce a typical application top level shell: (that
- * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
- * </dd>
- * <dt><code>DIALOG_TRIM</code></dt>
- * <dd>
- * the result of combining the constants which are required
- * to produce a typical application dialog shell: (that
- * is, <code>TITLE | CLOSE | BORDER</code>)
- * </dd>
- * </dl>
- * </p>
- * <p>
- * Note: Only one of the styles APPLICATION_MODAL, MODELESS,
- * PRIMARY_MODAL and SYSTEM_MODAL may be specified.
- * </p><p>
- * IMPORTANT: This class is not intended to be subclassed.
- * </p>
- *
- * @see Decorations
- * @see SWT
+ * http://www.eclipse.org/legal/cpl-v10.html
*/
-public class Shell extends Decorations {
- int shellHandle;
- Display display;
- Menu activeMenu;
- int blockedList;
- Control lastActive;
-
+
+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.*;
+
+/**
+ * Instances of this class represent the "windows"
+ * which the desktop or "window manager" is managing.
+ * Instances that do not have a parent (that is, they
+ * are built using the constructor, which takes a
+ * <code>Display</code> as the argument) are described
+ * as <em>top level</em> shells. Instances that do have
+ * a parent are described as <em>secondary</em> or
+ * <em>dialog</em> shells.
+ * <p>
+ * Instances are always displayed in one of the maximized,
+ * minimized or normal states:
+ * <ul>
+ * <li>
+ * When an instance is marked as <em>maximized</em>, the
+ * window manager will typically resize it to fill the
+ * entire visible area of the display, and the instance
+ * is usually put in a state where it can not be resized
+ * (even if it has style <code>RESIZE</code>) until it is
+ * no longer maximized.
+ * </li><li>
+ * When an instance is in the <em>normal</em> state (neither
+ * maximized or minimized), its appearance is controlled by
+ * the style constants which were specified when it was created
+ * and the restrictions of the window manager (see below).
+ * </li><li>
+ * When an instance has been marked as <em>minimized</em>,
+ * its contents (client area) will usually not be visible,
+ * and depending on the window manager, it may be
+ * "iconified" (that is, replaced on the desktop by a small
+ * simplified representation of itself), relocated to a
+ * distinguished area of the screen, or hidden. Combinations
+ * of these changes are also possible.
+ * </li>
+ * </ul>
+ * </p>
+ * <p>
+ * Note: The styles supported by this class must be treated
+ * as <em>HINT</em>s, since the window manager for the
+ * desktop on which the instance is visible has ultimate
+ * control over the appearance and behavior of decorations
+ * and modality. For example, some window managers only
+ * support resizable windows and will always assume the
+ * RESIZE style, even if it is not set. In addition, if a
+ * modality style is not supported, it is "upgraded" to a
+ * more restrictive modality style that is supported. For
+ * example, if <code>PRIMARY_MODAL</code> is not supported,
+ * it would be upgraded to <code>APPLICATION_MODAL</code>.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE</dd>
+ * <dd>APPLICATION_MODAL, MODELESS, PRIMARY_MODAL, SYSTEM_MODAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Activate, Close, Deactivate, Deiconify, Iconify</dd>
+ * </dl>
+ * Class <code>SWT</code> provides two "convenience constants"
+ * for the most commonly required style combinations:
+ * <dl>
+ * <dt><code>SHELL_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application top level shell: (that
+ * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
+ * </dd>
+ * <dt><code>DIALOG_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application dialog shell: (that
+ * is, <code>TITLE | CLOSE | BORDER</code>)
+ * </dd>
+ * </dl>
+ * </p>
+ * <p>
+ * Note: Only one of the styles APPLICATION_MODAL, MODELESS,
+ * PRIMARY_MODAL and SYSTEM_MODAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is not intended to be subclassed.
+ * </p>
+ *
+ * @see Decorations
+ * @see SWT
+ */
+public class Shell extends Decorations {
+ int shellHandle;
+ Display display;
+ Menu activeMenu;
+ int blockedList;
+ Control lastActive;
+
/**
* Constructs a new instance of this class. This is equivalent
* to calling <code>Shell((Display) null)</code>.
@@ -111,10 +111,10 @@ public class Shell extends Decorations {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public Shell () {
- this ((Display) null);
-}
-
+public Shell () {
+ this ((Display) null);
+}
+
/**
* Constructs a new instance of this class given only the style
* value describing its behavior and appearance. This is equivalent
@@ -150,10 +150,10 @@ public Shell () {
* @see SWT#APPLICATION_MODAL
* @see SWT#SYSTEM_MODAL
*/
-public Shell (int style) {
- this ((Display) null, style);
-}
-
+public Shell (int style) {
+ this ((Display) null, style);
+}
+
/**
* Constructs a new instance of this class given only the display
* to create it on. It is created with style <code>SWT.SHELL_TRIM</code>.
@@ -173,10 +173,10 @@ public Shell (int style) {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public Shell (Display display) {
- this (display, SWT.CLOSE | SWT.TITLE | SWT.MIN | SWT.MAX | SWT.RESIZE);
-}
-
+public Shell (Display display) {
+ this (display, SWT.CLOSE | SWT.TITLE | SWT.MIN | SWT.MAX | SWT.RESIZE);
+}
+
/**
* Constructs a new instance of this class given the display
* to create it on and a style value describing its behavior
@@ -220,24 +220,24 @@ public Shell (Display display) {
* @see SWT#APPLICATION_MODAL
* @see SWT#SYSTEM_MODAL
*/
-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 (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);
+}
+
/**
* Constructs a new instance of this class given only its
* parent. It is created with style <code>SWT.DIALOG_TRIM</code>.
@@ -260,10 +260,10 @@ Shell (Display display, Shell parent, int style, int handle) {
* <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
* </ul>
*/
-public Shell (Shell parent) {
- this (parent, SWT.TITLE | SWT.CLOSE | SWT.BORDER);
-}
-
+public Shell (Shell parent) {
+ this (parent, SWT.TITLE | SWT.CLOSE | SWT.BORDER);
+}
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -306,14 +306,14 @@ public Shell (Shell parent) {
* @see SWT#APPLICATION_MODAL
* @see SWT#SYSTEM_MODAL
*/
-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 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);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when operations are performed on the receiver,
@@ -333,38 +333,38 @@ public static Shell photon_new (Display display, int handle) {
* @see ShellListener
* @see #removeShellListener
*/
-public void addShellListener (ShellListener listener) {
- checkWidget();
- 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);
-}
-
-static int checkStyle (int style) {
- style = Decorations.checkStyle (style);
- int mask = SWT.SYSTEM_MODAL | SWT.APPLICATION_MODAL | SWT.PRIMARY_MODAL;
- int bits = style & ~mask;
- if ((style & SWT.SYSTEM_MODAL) != 0) return bits | SWT.SYSTEM_MODAL;
- if ((style & SWT.APPLICATION_MODAL) != 0) return bits | SWT.APPLICATION_MODAL;
- if ((style & SWT.PRIMARY_MODAL) != 0) return bits | SWT.PRIMARY_MODAL;
- return bits;
-}
-
-void closeWidget () {
- Event event = new Event ();
- event.time = (int) System.currentTimeMillis ();
- sendEvent (SWT.Close, event);
- if (event.doit && !isDisposed ()) dispose ();
-}
-
+public void addShellListener (ShellListener listener) {
+ checkWidget();
+ 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);
+}
+
+static int checkStyle (int style) {
+ style = Decorations.checkStyle (style);
+ int mask = SWT.SYSTEM_MODAL | SWT.APPLICATION_MODAL | SWT.PRIMARY_MODAL;
+ int bits = style & ~mask;
+ if ((style & SWT.SYSTEM_MODAL) != 0) return bits | SWT.SYSTEM_MODAL;
+ if ((style & SWT.APPLICATION_MODAL) != 0) return bits | SWT.APPLICATION_MODAL;
+ if ((style & SWT.PRIMARY_MODAL) != 0) return bits | SWT.PRIMARY_MODAL;
+ return bits;
+}
+
+void closeWidget () {
+ Event event = new Event ();
+ event.time = (int) System.currentTimeMillis ();
+ sendEvent (SWT.Close, event);
+ if (event.doit && !isDisposed ()) dispose ();
+}
+
/**
* Requests that the window manager close the receiver in
* the same way it would be closed when the user clicks on
@@ -379,158 +379,158 @@ void closeWidget () {
*
* @see #dispose
*/
-public void close () {
- checkWidget();
- closeWidget ();
-}
-
-public Rectangle computeTrim (int x, int y, int width, int height) {
- checkWidget();
- 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) {
- PhDim_t dim = new PhDim_t ();
- int menuHandle = menuBar.handle;
- if (!OS.PtWidgetIsRealized (menuHandle)) {
- OS.PtExtentWidgetFamily (menuHandle);
- }
- OS.PtWidgetPreferredSize (menuHandle, dim);
- trimHeight += dim.h;
- trimY -= dim.h;
- }
- return new Rectangle (trimX, trimY, trimWidth, trimHeight);
-}
-
-void createHandle (int index) {
- state |= HANDLE | GRAB | CANVAS;
- if (handle != 0) {
- int clazz = display.PtContainer;
- int [] args = {
- OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,
- OS.Pt_ARG_CONTAINER_FLAGS, OS.Pt_HOTKEYS_FIRST, OS.Pt_HOTKEYS_FIRST,
- 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, OS.PhInputGroup (0), 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 notifyFlags =
- OS.Ph_WM_ICON | OS.Ph_WM_FOCUS |
- OS.Ph_WM_MOVE | OS.Ph_WM_RESIZE;
- int windowState = OS.Ph_WM_STATE_ISFOCUS;
- if ((style & SWT.ON_TOP) != 0) windowState = OS.Ph_WM_STATE_ISFRONT;
- int titlePtr = OS.malloc (1);
- int [] args = {
- OS.Pt_ARG_WIDTH, width, 0,
- 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, notifyFlags, notifyFlags,
- OS.Pt_ARG_WINDOW_STATE, windowState, ~0,
- OS.Pt_ARG_FLAGS, OS.Pt_DELAY_REALIZE, OS.Pt_DELAY_REALIZE,
- OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,
- OS.Pt_ARG_CONTAINER_FLAGS, OS.Pt_HOTKEYS_FIRST, OS.Pt_HOTKEYS_FIRST,
- 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);
- if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.RESIZE)) == 0) {
- int [] args = {
- OS.Pt_ARG_FLAGS, OS.Pt_HIGHLIGHTED, OS.Pt_HIGHLIGHTED,
- OS.Pt_ARG_BASIC_FLAGS, OS.Pt_ALL_OUTLINES, ~0,
- };
- OS.PtSetResources (scrolledHandle, args.length / 3, args);
- }
- int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
- OS.PtGetResources (shellHandle, args.length / 3, args);
- resizeBounds (args [1], args [4]);
-}
-
-void deregister () {
- super.deregister ();
- WidgetTable.remove (shellHandle);
-}
-
-/**
- * Moves the receiver to the top of the drawing order for
- * the display on which it was created (so that all other
- * shells on that display, which are not the receiver's
- * children will be drawn behind it) and forces the window
- * manager to make the shell active.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- * @see Control#moveAbove
- * @see Control#setFocus
- * @see Control#setVisible
- * @see Display#getActiveShell
- * @see Decorations#setDefaultButton
- * @see Shell#open
- * @see Shell#setActive
+public void close () {
+ checkWidget();
+ closeWidget ();
+}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ checkWidget();
+ 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) {
+ PhDim_t dim = new PhDim_t ();
+ int menuHandle = menuBar.handle;
+ if (!OS.PtWidgetIsRealized (menuHandle)) {
+ OS.PtExtentWidgetFamily (menuHandle);
+ }
+ OS.PtWidgetPreferredSize (menuHandle, dim);
+ trimHeight += dim.h;
+ trimY -= dim.h;
+ }
+ return new Rectangle (trimX, trimY, trimWidth, trimHeight);
+}
+
+void createHandle (int index) {
+ state |= HANDLE | GRAB | CANVAS;
+ if (handle != 0) {
+ int clazz = display.PtContainer;
+ int [] args = {
+ OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,
+ OS.Pt_ARG_CONTAINER_FLAGS, OS.Pt_HOTKEYS_FIRST, OS.Pt_HOTKEYS_FIRST,
+ 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, OS.PhInputGroup (0), 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 notifyFlags =
+ OS.Ph_WM_ICON | OS.Ph_WM_FOCUS |
+ OS.Ph_WM_MOVE | OS.Ph_WM_RESIZE;
+ int windowState = OS.Ph_WM_STATE_ISFOCUS;
+ if ((style & SWT.ON_TOP) != 0) windowState = OS.Ph_WM_STATE_ISFRONT;
+ int titlePtr = OS.malloc (1);
+ int [] args = {
+ OS.Pt_ARG_WIDTH, width, 0,
+ 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, notifyFlags, notifyFlags,
+ OS.Pt_ARG_WINDOW_STATE, windowState, ~0,
+ OS.Pt_ARG_FLAGS, OS.Pt_DELAY_REALIZE, OS.Pt_DELAY_REALIZE,
+ OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,
+ OS.Pt_ARG_CONTAINER_FLAGS, OS.Pt_HOTKEYS_FIRST, OS.Pt_HOTKEYS_FIRST,
+ 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);
+ if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.RESIZE)) == 0) {
+ int [] args = {
+ OS.Pt_ARG_FLAGS, OS.Pt_HIGHLIGHTED, OS.Pt_HIGHLIGHTED,
+ OS.Pt_ARG_BASIC_FLAGS, OS.Pt_ALL_OUTLINES, ~0,
+ };
+ OS.PtSetResources (scrolledHandle, args.length / 3, args);
+ }
+ int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ resizeBounds (args [1], args [4]);
+}
+
+void deregister () {
+ super.deregister ();
+ WidgetTable.remove (shellHandle);
+}
+
+/**
+ * Moves the receiver to the top of the drawing order for
+ * the display on which it was created (so that all other
+ * shells on that display, which are not the receiver's
+ * children will be drawn behind it) and forces the window
+ * manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton
+ * @see Shell#open
+ * @see Shell#setActive
*/
-public void forceActive () {
- checkWidget ();
- bringToTop ();
-}
-
-public Rectangle getBounds () {
- checkWidget();
- PhArea_t area = new PhArea_t ();
- OS.PtWidgetArea (shellHandle, area);
- int width = area.size_w, height = area.size_h;
- 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);
- width += left [0] + right [0];
- height += top [0] + bottom [0];
- return new Rectangle (area.pos_x, area.pos_y, width, height);
-}
-
-public Display getDisplay () {
- if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return display;
-}
-
+public void forceActive () {
+ checkWidget ();
+ bringToTop ();
+}
+
+public Rectangle getBounds () {
+ checkWidget();
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (shellHandle, area);
+ int width = area.size_w, height = area.size_h;
+ 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);
+ width += left [0] + right [0];
+ height += top [0] + bottom [0];
+ return new Rectangle (area.pos_x, area.pos_y, width, height);
+}
+
+public Display getDisplay () {
+ if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return display;
+}
+
/**
* Returns the receiver's input method editor mode. This
* will be the result of bitwise OR'ing together one or
@@ -548,45 +548,45 @@ public Display getDisplay () {
*
* @see SWT
*/
-public int getImeInputMode () {
- checkWidget();
- return 0;
-}
-
-public boolean isEnabled () {
- checkWidget();
- return getEnabled ();
-}
-
-public Point getLocation () {
- checkWidget();
- //NOT DONE - shell location is 0,0 when queried before event loop
- return super.getLocation ();
-}
-
-public boolean getMaximized () {
- checkWidget();
- int state = OS.PtWindowGetState (shellHandle);
- if (state != -1) return (state & (OS.Ph_WM_STATE_ISMAX | OS.Ph_WM_STATE_ISMAXING)) != 0;
- int [] args = {OS.Pt_ARG_WINDOW_STATE, 0, OS.Ph_WM_STATE_ISMAX};
- OS.PtGetResources (shellHandle, args.length / 3, args);
- return (args [1] & OS.Ph_WM_STATE_ISMAX) != 0;
-}
-
-public boolean getMinimized () {
- checkWidget();
- int state = OS.PtWindowGetState (shellHandle);
- if (state != -1) return (state & OS.Ph_WM_STATE_ISICONIFIED) != 0;
- int [] args = {OS.Pt_ARG_WINDOW_STATE, 0, OS.Ph_WM_STATE_ISICONIFIED};
- OS.PtGetResources (shellHandle, args.length / 3, args);
- return (args [1] & OS.Ph_WM_STATE_ISICONIFIED) != 0;
-}
-
-public Shell getShell () {
- checkWidget();
- return this;
-}
-
+public int getImeInputMode () {
+ checkWidget();
+ return 0;
+}
+
+public boolean isEnabled () {
+ checkWidget();
+ return getEnabled ();
+}
+
+public Point getLocation () {
+ checkWidget();
+ //NOT DONE - shell location is 0,0 when queried before event loop
+ return super.getLocation ();
+}
+
+public boolean getMaximized () {
+ checkWidget();
+ int state = OS.PtWindowGetState (shellHandle);
+ if (state != -1) return (state & (OS.Ph_WM_STATE_ISMAX | OS.Ph_WM_STATE_ISMAXING)) != 0;
+ int [] args = {OS.Pt_ARG_WINDOW_STATE, 0, OS.Ph_WM_STATE_ISMAX};
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ return (args [1] & OS.Ph_WM_STATE_ISMAX) != 0;
+}
+
+public boolean getMinimized () {
+ checkWidget();
+ int state = OS.PtWindowGetState (shellHandle);
+ if (state != -1) return (state & OS.Ph_WM_STATE_ISICONIFIED) != 0;
+ int [] args = {OS.Pt_ARG_WINDOW_STATE, 0, OS.Ph_WM_STATE_ISICONIFIED};
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ return (args [1] & OS.Ph_WM_STATE_ISICONIFIED) != 0;
+}
+
+public Shell getShell () {
+ checkWidget();
+ return this;
+}
+
/**
* Returns an array containing all shells which are
* descendents of the receiver.
@@ -598,182 +598,182 @@ public Shell getShell () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Shell [] getShells () {
- checkWidget();
- 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 () {
- checkWidget();
- 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 hookEvents () {
- super.hookEvents ();
- int windowProc = getDisplay ().windowProc;
- OS.PtAddCallback (shellHandle, OS.Pt_CB_WINDOW, windowProc, OS.Pt_CB_WINDOW);
- OS.PtAddCallback (shellHandle, OS.Pt_CB_RESIZE, windowProc, OS.Pt_CB_RESIZE);
-}
-
-int hotkeyProc (int w, int data, int info) {
- if (data != 0) {
- Widget widget = WidgetTable.get (data);
- if (widget instanceof MenuItem) {
- MenuItem item = (MenuItem) widget;
- if (item.isEnabled ()) item.Pt_CB_ACTIVATE (data, info);
- }
- }
- return OS.Pt_CONTINUE;
-}
-
-/**
- * Moves the receiver to the top of the drawing order for
- * the display on which it was created (so that all other
- * shells on that display, which are not the receiver's
- * children will be drawn behind it), marks it visible,
- * and sets focus to its default button (if it has one)
- * and asks the window manager to make the shell active.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Control#moveAbove
- * @see Control#setFocus
- * @see Control#setVisible
- * @see Display#getActiveShell
- * @see Decorations#setDefaultButton
- * @see Shell#setActive
- * @see Shell#forceActive
+public Shell [] getShells () {
+ checkWidget();
+ 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 () {
+ checkWidget();
+ 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 hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (shellHandle, OS.Pt_CB_WINDOW, windowProc, OS.Pt_CB_WINDOW);
+ OS.PtAddCallback (shellHandle, OS.Pt_CB_RESIZE, windowProc, OS.Pt_CB_RESIZE);
+}
+
+int hotkeyProc (int w, int data, int info) {
+ if (data != 0) {
+ Widget widget = WidgetTable.get (data);
+ if (widget instanceof MenuItem) {
+ MenuItem item = (MenuItem) widget;
+ if (item.isEnabled ()) item.Pt_CB_ACTIVATE (data, info);
+ }
+ }
+ return OS.Pt_CONTINUE;
+}
+
+/**
+ * Moves the receiver to the top of the drawing order for
+ * the display on which it was created (so that all other
+ * shells on that display, which are not the receiver's
+ * children will be drawn behind it), marks it visible,
+ * and sets focus to its default button (if it has one)
+ * and asks the window manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton
+ * @see Shell#setActive
+ * @see Shell#forceActive
*/
-public void open () {
- checkWidget();
- bringToTop ();
- setVisible (true);
- traverseGroup (true);
-}
-
-int Pt_CB_RESIZE (int widget, 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]);
- sendEvent(SWT.Resize);
- if (layout != null) layout (false);
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_WINDOW (int widget, 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 ((int) 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;
-}
-
-void register () {
- super.register ();
- WidgetTable.put (shellHandle, this);
-}
-
-void realizeWidget() {
- /* Do nothing */
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- shellHandle = 0;
-}
-
-void releaseShells () {
- Shell [] shells = getShells ();
- for (int i=0; i<shells.length; i++) {
- Shell shell = shells [i];
- if (!shell.isDisposed ()) {
- /*
- * Feature in Photon. A shell may have child shells that have been
- * temporarily reparented to NULL because they were shown without
- * showing the parent. In this case, Photon will not destroy the
- * child shells because they are not in the widget hierarchy.
- * The fix is to detect this case and destroy the shells.
- */
- if (shell.parent != null && OS.PtWidgetParent (shell.shellHandle) == 0) {
- shell.dispose ();
- } else {
- shell.releaseResources ();
- }
- }
- }
-}
-
-void releaseWidget () {
- releaseShells ();
- super.releaseWidget ();
- if (blockedList != 0) OS.PtUnblockWindows (blockedList);
- blockedList = 0;
- lastActive = null;
- display = null;
-}
-
+public void open () {
+ checkWidget();
+ bringToTop ();
+ setVisible (true);
+ traverseGroup (true);
+}
+
+int Pt_CB_RESIZE (int widget, 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]);
+ sendEvent(SWT.Resize);
+ if (layout != null) layout (false);
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_WINDOW (int widget, 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 ((int) 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;
+}
+
+void register () {
+ super.register ();
+ WidgetTable.put (shellHandle, this);
+}
+
+void realizeWidget() {
+ /* Do nothing */
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ shellHandle = 0;
+}
+
+void releaseShells () {
+ Shell [] shells = getShells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (!shell.isDisposed ()) {
+ /*
+ * Feature in Photon. A shell may have child shells that have been
+ * temporarily reparented to NULL because they were shown without
+ * showing the parent. In this case, Photon will not destroy the
+ * child shells because they are not in the widget hierarchy.
+ * The fix is to detect this case and destroy the shells.
+ */
+ if (shell.parent != null && OS.PtWidgetParent (shell.shellHandle) == 0) {
+ shell.dispose ();
+ } else {
+ shell.releaseResources ();
+ }
+ }
+ }
+}
+
+void releaseWidget () {
+ releaseShells ();
+ super.releaseWidget ();
+ if (blockedList != 0) OS.PtUnblockWindows (blockedList);
+ blockedList = 0;
+ lastActive = null;
+ display = null;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when operations are performed on the receiver.
@@ -791,158 +791,158 @@ void releaseWidget () {
* @see ShellListener
* @see #addShellListener
*/
-public void removeShellListener (ShellListener listener) {
- checkWidget();
- 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);
-}
-
-/**
- * Moves the receiver to the top of the drawing order for
- * the display on which it was created (so that all other
- * shells on that display, which are not the receiver's
- * children will be drawn behind it) and asks the window
- * manager to make the shell active.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- * @see Control#moveAbove
- * @see Control#setFocus
- * @see Control#setVisible
- * @see Display#getActiveShell
- * @see Decorations#setDefaultButton
- * @see Shell#open
- * @see Shell#setActive
+public void removeShellListener (ShellListener listener) {
+ checkWidget();
+ 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);
+}
+
+/**
+ * Moves the receiver to the top of the drawing order for
+ * the display on which it was created (so that all other
+ * shells on that display, which are not the receiver's
+ * children will be drawn behind it) and asks the window
+ * manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton
+ * @see Shell#open
+ * @see Shell#setActive
*/
-public void setActive () {
- checkWidget ();
- bringToTop ();
-}
-
-void setActiveControl (Control control) {
- if (control != null && control.isDisposed ()) control = null;
- if (lastActive != null && lastActive.isDisposed ()) lastActive = null;
- if (lastActive == control) return;
-
- /*
- * Compute the list of controls to be activated and
- * deactivated by finding the first common parent
- * control.
- */
- Control [] activate = (control == null) ? new Control[0] : control.getPath ();
- Control [] deactivate = (lastActive == null) ? new Control[0] : lastActive.getPath ();
- lastActive = control;
- int index = 0, length = Math.min (activate.length, deactivate.length);
- while (index < length) {
- if (activate [index] != deactivate [index]) break;
- index++;
- }
-
- /*
- * It is possible (but unlikely), that application
- * code could have destroyed some of the widgets. If
- * this happens, keep processing those widgets that
- * are not disposed.
- */
- for (int i=deactivate.length-1; i>=index; --i) {
- if (!deactivate [i].isDisposed ()) {
- deactivate [i].sendEvent (SWT.Deactivate);
- }
- }
- for (int i=activate.length-1; i>=index; --i) {
- if (!activate [i].isDisposed ()) {
- activate [i].sendEvent (SWT.Activate);
- }
- }
-}
-
-int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
- checkWidget();
- if (OS.PtWidgetClass (shellHandle) != OS.PtWindow ()) {
- int result = super.setBounds (x, y, width, height, move, resize, events);
- if ((result & RESIZED) != 0) resizeBounds (width, height);
- return result;
- }
-
- boolean isFocus = caret != null && caret.isFocusCaret ();
- if (isFocus) caret.killFocus ();
-
- if (resize) {
- /* Get the trimings */
- 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);
- width = Math.max (width - left [0] - right [0], 0);
- height = Math.max (height - top [0] - bottom [0], 0);
- }
-
- PhArea_t oldArea = new PhArea_t ();
- OS.PtWidgetArea (shellHandle, oldArea);
-
- if (move && resize) {
- PhArea_t area = new PhArea_t ();
- area.pos_x = (short) x;
- area.pos_y = (short) y;
- area.size_w = (short) width;
- area.size_h = (short) height;
- int ptr = OS.malloc (PhArea_t.sizeof);
- OS.memmove (ptr, area, PhArea_t.sizeof);
- OS.PtSetResource (shellHandle, OS.Pt_ARG_AREA, ptr, 0);
- 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);
- OS.PtSetResource (shellHandle, OS.Pt_ARG_POS, ptr, 0);
- OS.free (ptr);
- } else if (resize) {
- int [] args = {
- OS.Pt_ARG_WIDTH, width, 0,
- OS.Pt_ARG_HEIGHT, height, 0,
- };
- OS.PtSetResources (shellHandle, args.length / 3, args);
- }
- }
-
- /*
- * 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)) {
- PhArea_t newArea = new PhArea_t ();
- OS.PtWidgetArea (shellHandle, newArea);
- boolean sameOrigin = oldArea.pos_x == newArea.pos_x && oldArea.pos_y == newArea.pos_y;
- boolean sameExtent = oldArea.size_w == newArea.size_w && oldArea.size_h == newArea.size_h;
- if (!sameOrigin & move) sendEvent (SWT.Move);
- if (!sameExtent & resize) {
- resizeBounds (newArea.size_w, newArea.size_h);
- sendEvent(SWT.Resize);
- if (layout != null) layout (false);
- }
- }
-
- if (isFocus) caret.setFocus ();
-
- /* Always return 0 */
- return 0;
-}
-
+public void setActive () {
+ checkWidget ();
+ bringToTop ();
+}
+
+void setActiveControl (Control control) {
+ if (control != null && control.isDisposed ()) control = null;
+ if (lastActive != null && lastActive.isDisposed ()) lastActive = null;
+ if (lastActive == control) return;
+
+ /*
+ * Compute the list of controls to be activated and
+ * deactivated by finding the first common parent
+ * control.
+ */
+ Control [] activate = (control == null) ? new Control[0] : control.getPath ();
+ Control [] deactivate = (lastActive == null) ? new Control[0] : lastActive.getPath ();
+ lastActive = control;
+ int index = 0, length = Math.min (activate.length, deactivate.length);
+ while (index < length) {
+ if (activate [index] != deactivate [index]) break;
+ index++;
+ }
+
+ /*
+ * It is possible (but unlikely), that application
+ * code could have destroyed some of the widgets. If
+ * this happens, keep processing those widgets that
+ * are not disposed.
+ */
+ for (int i=deactivate.length-1; i>=index; --i) {
+ if (!deactivate [i].isDisposed ()) {
+ deactivate [i].sendEvent (SWT.Deactivate);
+ }
+ }
+ for (int i=activate.length-1; i>=index; --i) {
+ if (!activate [i].isDisposed ()) {
+ activate [i].sendEvent (SWT.Activate);
+ }
+ }
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
+ checkWidget();
+ if (OS.PtWidgetClass (shellHandle) != OS.PtWindow ()) {
+ int result = super.setBounds (x, y, width, height, move, resize, events);
+ if ((result & RESIZED) != 0) resizeBounds (width, height);
+ return result;
+ }
+
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+
+ if (resize) {
+ /* Get the trimings */
+ 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);
+ width = Math.max (width - left [0] - right [0], 0);
+ height = Math.max (height - top [0] - bottom [0], 0);
+ }
+
+ PhArea_t oldArea = new PhArea_t ();
+ OS.PtWidgetArea (shellHandle, oldArea);
+
+ if (move && resize) {
+ PhArea_t area = new PhArea_t ();
+ area.pos_x = (short) x;
+ area.pos_y = (short) y;
+ area.size_w = (short) width;
+ area.size_h = (short) height;
+ int ptr = OS.malloc (PhArea_t.sizeof);
+ OS.memmove (ptr, area, PhArea_t.sizeof);
+ OS.PtSetResource (shellHandle, OS.Pt_ARG_AREA, ptr, 0);
+ 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);
+ OS.PtSetResource (shellHandle, OS.Pt_ARG_POS, ptr, 0);
+ OS.free (ptr);
+ } else if (resize) {
+ int [] args = {
+ OS.Pt_ARG_WIDTH, width, 0,
+ OS.Pt_ARG_HEIGHT, height, 0,
+ };
+ OS.PtSetResources (shellHandle, args.length / 3, args);
+ }
+ }
+
+ /*
+ * 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)) {
+ PhArea_t newArea = new PhArea_t ();
+ OS.PtWidgetArea (shellHandle, newArea);
+ boolean sameOrigin = oldArea.pos_x == newArea.pos_x && oldArea.pos_y == newArea.pos_y;
+ boolean sameExtent = oldArea.size_w == newArea.size_w && oldArea.size_h == newArea.size_h;
+ if (!sameOrigin & move) sendEvent (SWT.Move);
+ if (!sameExtent & resize) {
+ resizeBounds (newArea.size_w, newArea.size_h);
+ sendEvent(SWT.Resize);
+ if (layout != null) layout (false);
+ }
+ }
+
+ if (isFocus) caret.setFocus ();
+
+ /* Always return 0 */
+ return 0;
+}
+
/**
* Sets the input method editor mode to the argument which
* should be the result of bitwise OR'ing together one or more
@@ -959,152 +959,152 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
*
* @see SWT
*/
-public void setImeInputMode (int mode) {
- checkWidget();
-}
-
-public void setMaximized (boolean maximized) {
- checkWidget();
- int bits = 0;
- if (maximized) bits = OS.Ph_WM_STATE_ISMAX;
- OS.PtSetResource (shellHandle, OS.Pt_ARG_WINDOW_STATE, bits, OS.Ph_WM_STATE_ISMAX);
- if (OS.PtWidgetIsRealized (shellHandle)) {
- PhWindowEvent_t event = new PhWindowEvent_t ();
- event.rid = OS.PtWidgetRid (shellHandle);
- event.event_f = maximized ? OS.Ph_WM_MAX : OS.Ph_WM_RESTORE;
- OS.PtForwardWindowEvent (event);
- }
-}
-
-public void setMenuBar (Menu menu) {
- checkWidget();
- 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;
- OS.PtSetResource (menuHandle, OS.Pt_ARG_FLAGS, OS.Pt_DELAY_REALIZE, OS.Pt_DELAY_REALIZE);
- 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];
- 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);
- OS.PtRealizeWidget (menuHandle);
- }
- resizeBounds (width, height);
-}
-
-public void setMinimized (boolean minimized) {
- checkWidget();
- int bits = 0;
- if (minimized) bits = OS.Ph_WM_STATE_ISICONIFIED;
- OS.PtSetResource (shellHandle, OS.Pt_ARG_WINDOW_STATE, bits, OS.Ph_WM_STATE_ISICONIFIED);
- if (OS.PtWidgetIsRealized (shellHandle)) {
- PhWindowEvent_t event = new PhWindowEvent_t ();
- event.rid = OS.PtWidgetRid (shellHandle);
- event.event_f = OS.Ph_WM_HIDE;
- event.event_state = (short) (minimized ? OS.Ph_WM_EVSTATE_HIDE : OS.Ph_WM_EVSTATE_UNHIDE);
- OS.PtForwardWindowEvent (event);
- }
-}
-
-public void setText (String string) {
- checkWidget();
- 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);
- OS.PtSetResource (shellHandle, OS.Pt_ARG_WINDOW_TITLE, ptr, 0);
- OS.free (ptr);
-}
-
-public void setVisible (boolean visible) {
- checkWidget();
- if (visible == OS.PtWidgetIsRealized (shellHandle)) return;
-
- /*
- * Feature in Photon. It is not possible to show a PtWindow
- * whose parent is not realized. The fix is to temporarily
- * reparent the child shell to NULL and then realize the child
- * shell.
- */
- if (parent != null) {
- Shell shell = parent.getShell ();
- int parentHandle = shell.shellHandle;
- if (!OS.PtWidgetIsRealized (parentHandle)) {
- OS.PtReParentWidget (shellHandle, visible ? OS.Pt_NO_PARENT : parentHandle);
- }
- }
-
- if (visible) {
- int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
- switch (style & mask) {
- case SWT.PRIMARY_MODAL:
- if (parent != null) {
- int parentHandle = parent.getShell ().shellHandle;
- blockedList = OS.PtBlockWindow (parentHandle, (short) 0, 0);
- }
- break;
- case SWT.APPLICATION_MODAL:
- case SWT.SYSTEM_MODAL:
- blockedList = OS.PtBlockAllWindows (shellHandle, (short) 0, 0);
- break;
- }
- } else {
- if (blockedList != 0) OS.PtUnblockWindows (blockedList);
- blockedList = 0;
- }
-
- int flags = visible ? 0 : OS.Pt_DELAY_REALIZE;
- OS.PtSetResource (shellHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_DELAY_REALIZE);
- if (visible) {
- sendEvent (SWT.Show);
- OS.PtRealizeWidget (shellHandle);
- } else {
- OS.PtUnrealizeWidget (shellHandle);
- sendEvent(SWT.Hide);
- }
-
- /*
- * Feature in Photon. When a shell is shown, it may have child
- * shells that have been temporarily reparented to NULL because
- * the child was shown before the parent. The fix is to reparent
- * the child shells back to the correct parent.
- */
- if (visible) {
- Shell [] shells = getShells ();
- for (int i=0; i<shells.length; i++) {
- int childHandle = shells [i].shellHandle;
- if (OS.PtWidgetParent (childHandle) == 0) {
- OS.PtReParentWidget (childHandle, shellHandle);
- }
- }
- }
-
- OS.PtSyncWidget (shellHandle);
- OS.PtFlush ();
-}
-
-int topHandle () {
- return shellHandle;
-}
-
-boolean traverseEscape () {
- if (parent == null) return false;
- if (!isVisible () || !isEnabled ()) return false;
- close ();
- return true;
-}
-
-}
+public void setImeInputMode (int mode) {
+ checkWidget();
+}
+
+public void setMaximized (boolean maximized) {
+ checkWidget();
+ int bits = 0;
+ if (maximized) bits = OS.Ph_WM_STATE_ISMAX;
+ OS.PtSetResource (shellHandle, OS.Pt_ARG_WINDOW_STATE, bits, OS.Ph_WM_STATE_ISMAX);
+ if (OS.PtWidgetIsRealized (shellHandle)) {
+ PhWindowEvent_t event = new PhWindowEvent_t ();
+ event.rid = OS.PtWidgetRid (shellHandle);
+ event.event_f = maximized ? OS.Ph_WM_MAX : OS.Ph_WM_RESTORE;
+ OS.PtForwardWindowEvent (event);
+ }
+}
+
+public void setMenuBar (Menu menu) {
+ checkWidget();
+ 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;
+ OS.PtSetResource (menuHandle, OS.Pt_ARG_FLAGS, OS.Pt_DELAY_REALIZE, OS.Pt_DELAY_REALIZE);
+ 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];
+ 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);
+ OS.PtRealizeWidget (menuHandle);
+ }
+ resizeBounds (width, height);
+}
+
+public void setMinimized (boolean minimized) {
+ checkWidget();
+ int bits = 0;
+ if (minimized) bits = OS.Ph_WM_STATE_ISICONIFIED;
+ OS.PtSetResource (shellHandle, OS.Pt_ARG_WINDOW_STATE, bits, OS.Ph_WM_STATE_ISICONIFIED);
+ if (OS.PtWidgetIsRealized (shellHandle)) {
+ PhWindowEvent_t event = new PhWindowEvent_t ();
+ event.rid = OS.PtWidgetRid (shellHandle);
+ event.event_f = OS.Ph_WM_HIDE;
+ event.event_state = (short) (minimized ? OS.Ph_WM_EVSTATE_HIDE : OS.Ph_WM_EVSTATE_UNHIDE);
+ OS.PtForwardWindowEvent (event);
+ }
+}
+
+public void setText (String string) {
+ checkWidget();
+ 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);
+ OS.PtSetResource (shellHandle, OS.Pt_ARG_WINDOW_TITLE, ptr, 0);
+ OS.free (ptr);
+}
+
+public void setVisible (boolean visible) {
+ checkWidget();
+ if (visible == OS.PtWidgetIsRealized (shellHandle)) return;
+
+ /*
+ * Feature in Photon. It is not possible to show a PtWindow
+ * whose parent is not realized. The fix is to temporarily
+ * reparent the child shell to NULL and then realize the child
+ * shell.
+ */
+ if (parent != null) {
+ Shell shell = parent.getShell ();
+ int parentHandle = shell.shellHandle;
+ if (!OS.PtWidgetIsRealized (parentHandle)) {
+ OS.PtReParentWidget (shellHandle, visible ? OS.Pt_NO_PARENT : parentHandle);
+ }
+ }
+
+ if (visible) {
+ int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
+ switch (style & mask) {
+ case SWT.PRIMARY_MODAL:
+ if (parent != null) {
+ int parentHandle = parent.getShell ().shellHandle;
+ blockedList = OS.PtBlockWindow (parentHandle, (short) 0, 0);
+ }
+ break;
+ case SWT.APPLICATION_MODAL:
+ case SWT.SYSTEM_MODAL:
+ blockedList = OS.PtBlockAllWindows (shellHandle, (short) 0, 0);
+ break;
+ }
+ } else {
+ if (blockedList != 0) OS.PtUnblockWindows (blockedList);
+ blockedList = 0;
+ }
+
+ int flags = visible ? 0 : OS.Pt_DELAY_REALIZE;
+ OS.PtSetResource (shellHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_DELAY_REALIZE);
+ if (visible) {
+ sendEvent (SWT.Show);
+ OS.PtRealizeWidget (shellHandle);
+ } else {
+ OS.PtUnrealizeWidget (shellHandle);
+ sendEvent(SWT.Hide);
+ }
+
+ /*
+ * Feature in Photon. When a shell is shown, it may have child
+ * shells that have been temporarily reparented to NULL because
+ * the child was shown before the parent. The fix is to reparent
+ * the child shells back to the correct parent.
+ */
+ if (visible) {
+ Shell [] shells = getShells ();
+ for (int i=0; i<shells.length; i++) {
+ int childHandle = shells [i].shellHandle;
+ if (OS.PtWidgetParent (childHandle) == 0) {
+ OS.PtReParentWidget (childHandle, shellHandle);
+ }
+ }
+ }
+
+ OS.PtSyncWidget (shellHandle);
+ OS.PtFlush ();
+}
+
+int topHandle () {
+ return shellHandle;
+}
+
+boolean traverseEscape () {
+ if (parent == null) return false;
+ if (!isVisible () || !isEnabled ()) return false;
+ close ();
+ return true;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java
index 023179468e..83cb3c16d4 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
/**
* Instances of this class are selectable user interface
* objects that represent a range of positive, numeric values.
@@ -60,8 +60,8 @@ import org.eclipse.swt.events.*;
*
* @see ScrollBar
*/
-public class Slider extends Control {
-
+public class Slider extends Control {
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -91,14 +91,14 @@ public class Slider extends Control {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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 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);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver's value changes, by sending
@@ -131,55 +131,55 @@ static int checkStyle (int style) {
* @see #removeSelectionListener
* @see SelectionEvent
*/
-public void addSelectionListener (SelectionListener listener) {
- checkWidget();
- 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) {
- checkWidget();
- Display display = getDisplay ();
- int border = getBorderWidth () * 2;
- int width = display.SCROLLBAR_WIDTH + border, height = width * 5;
- if ((style & SWT.HORIZONTAL) != 0) {
- height = display.SCROLLBAR_HEIGHT + border; width = height * 5;
- }
- 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) {
- state |= HANDLE;
- Display display = getDisplay ();
- int clazz = display.PtScrollbar;
- int parentHandle = parent.parentingHandle ();
- 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);
-}
-
-byte [] defaultFont () {
- Display display = getDisplay ();
- return display.GAUGE_FONT;
-}
-
+public void addSelectionListener (SelectionListener listener) {
+ checkWidget();
+ 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) {
+ checkWidget();
+ Display display = getDisplay ();
+ int border = getBorderWidth () * 2;
+ int width = display.SCROLLBAR_WIDTH + border, height = width * 5;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ height = display.SCROLLBAR_HEIGHT + border; width = height * 5;
+ }
+ 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) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int clazz = display.PtScrollbar;
+ int parentHandle = parent.parentingHandle ();
+ 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);
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.GAUGE_FONT;
+}
+
/**
* Returns the amount that the receiver's value will be
* modified by when the up/down (or right/left) arrows
@@ -192,13 +192,13 @@ byte [] defaultFont () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getIncrement () {
- checkWidget();
- int [] args = {OS.Pt_ARG_INCREMENT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getIncrement () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the minimum value which the receiver will allow.
*
@@ -209,13 +209,13 @@ public int getIncrement () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getMinimum () {
- checkWidget();
- int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getMinimum () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the maximum value which the receiver will allow.
*
@@ -226,13 +226,13 @@ public int getMinimum () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getMaximum () {
- checkWidget();
- int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getMaximum () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the amount that the receiver's value will be
* modified by when the page increment/decrement areas
@@ -245,13 +245,13 @@ public int getMaximum () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getPageIncrement () {
- checkWidget();
- int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getPageIncrement () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the single <em>selection</em> that is the receiver's value.
*
@@ -262,20 +262,20 @@ public int getPageIncrement () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getSelection () {
- checkWidget();
- int [] args = {OS.Pt_ARG_GAUGE_VALUE, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
-public Point getSize () {
- checkWidget();
- 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 getSelection () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_GAUGE_VALUE, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public Point getSize () {
+ checkWidget();
+ 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]);
+}
+
/**
* Returns the size of the receiver's thumb relative to the
* difference between its maximum and minimum values.
@@ -287,54 +287,54 @@ public Point getSize () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getThumb () {
- checkWidget();
- int [] args = {OS.Pt_ARG_SLIDER_SIZE, 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_SCROLL_MOVE, windowProc, OS.Pt_CB_SCROLL_MOVE);
-}
-
-int Pt_CB_SCROLL_MOVE (int widget, 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 int getThumb () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_SLIDER_SIZE, 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_SCROLL_MOVE, windowProc, OS.Pt_CB_SCROLL_MOVE);
+}
+
+int Pt_CB_SCROLL_MOVE (int widget, 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;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver's value changes.
@@ -352,14 +352,14 @@ int Pt_CB_SCROLL_MOVE (int widget, int info) {
* @see SelectionListener
* @see #addSelectionListener
*/
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
+public void removeSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
/**
* Sets the amount that the receiver's value will be
* modified by when the up/down (or right/left) arrows
@@ -373,11 +373,11 @@ public void removeSelectionListener (SelectionListener listener) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setIncrement (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_INCREMENT, value, 0);
-}
-
+public void setIncrement (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_INCREMENT, value, 0);
+}
+
/**
* Sets the maximum value which the receiver will allow
* to be the argument which must be greater than or
@@ -390,11 +390,11 @@ public void setIncrement (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMaximum (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_MAXIMUM, value - 1, 0);
-}
-
+public void setMaximum (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_MAXIMUM, value - 1, 0);
+}
+
/**
* Sets the minimum value which the receiver will allow
* to be the argument which must be greater than or
@@ -407,11 +407,11 @@ public void setMaximum (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setMinimum (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_MINIMUM, value, 0);
-}
-
+public void setMinimum (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_MINIMUM, value, 0);
+}
+
/**
* Sets the amount that the receiver's value will be
* modified by when the page increment/decrement areas
@@ -425,11 +425,11 @@ public void setMinimum (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setPageIncrement (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_PAGE_INCREMENT, value, 0);
-}
-
+public void setPageIncrement (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_PAGE_INCREMENT, value, 0);
+}
+
/**
* Sets the single <em>selection</em> that is the receiver's
* value to the argument which must be greater than or equal
@@ -442,11 +442,11 @@ public void setPageIncrement (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_GAUGE_VALUE, value, 0);
-}
-
+public void setSelection (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_GAUGE_VALUE, value, 0);
+}
+
/**
* Sets the size of the receiver's thumb relative to the
* difference between its maximum and minimum values to the
@@ -461,11 +461,11 @@ public void setSelection (int value) {
*
* @see ScrollBar
*/
-public void setThumb (int value) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_SLIDER_SIZE, value, 0);
-}
-
+public void setThumb (int value) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_SLIDER_SIZE, value, 0);
+}
+
/**
* Sets the receiver's selection, minimum value, maximum
* value, thumb, increment and page increment all at once.
@@ -487,27 +487,27 @@ public void setThumb (int value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
- checkWidget();
- if (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_GAUGE_VALUE, 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);
-}
-
-int widgetClass () {
- return OS.PtScrollbar ();
-}
-
-}
+public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
+ checkWidget();
+ 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_GAUGE_VALUE, 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);
+}
+
+int widgetClass () {
+ return OS.PtScrollbar ();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java
index df244433aa..83ff2e9b8f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
/**
* Instances of this class implement the notebook user interface
* metaphor. It allows the user to select a notebook page from
@@ -35,11 +35,11 @@ import org.eclipse.swt.events.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class TabFolder extends Composite {
- int parentingHandle;
- TabItem [] items;
- int itemCount, currentIndex = OS.Pt_PG_INVALID;
-
+public class TabFolder extends Composite {
+ int parentingHandle;
+ TabItem [] items;
+ int itemCount, currentIndex = OS.Pt_PG_INVALID;
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -68,21 +68,21 @@ public class TabFolder extends Composite {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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 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);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver's selection changes, by sending
@@ -107,169 +107,169 @@ static int checkStyle (int style) {
* @see #removeSelectionListener
* @see SelectionEvent
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- 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) {
- checkWidget();
- 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 (wHint, hHint, changed);
- }
- 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) {
- checkWidget();
- 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) {
- state |= HANDLE;
- Display display = getDisplay ();
- int parentHandle = parent.parentingHandle ();
- int [] args = {
- OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
- };
- parentingHandle = OS.PtCreateWidget (OS.PtContainer (), parentHandle, args.length / 3, args);
- if (parentingHandle == 0) error (SWT.ERROR_NO_HANDLES);
- int clazz = display.PtPanelGroup;
- args = new int []{
- OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
- };
- handle = OS.PtCreateWidget (clazz, parentingHandle, 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 count = itemCount;
- 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 [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- int oldPtr = args [1];
- int newPtr = OS.malloc ((count + 1) * 4);
- if (newPtr == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
- int j = 0;
- int [] str = new int [1];
- int [] address = new int [1];
- for (int i=0; i<=count; i++) {
- if (i == index) {
- str [0] = OS.malloc (1);
- } else {
- OS.memmove (address, oldPtr + (j++ * 4), 4);
- str [0] = OS.strdup (address [0]);
- }
- if (str [0] == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
- OS.memmove (newPtr + (i * 4), str, 4);
- }
- OS.PtSetResource (handle, OS.Pt_ARG_PG_PANEL_TITLES, newPtr, count + 1);
- for (int i=0; i<=count; i++) {
- 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;
- itemCount++;
-}
-
-void deregister () {
- super.deregister ();
- if (parentingHandle != 0) WidgetTable.remove (parentingHandle);
-}
-
-void destroyItem (TabItem item) {
- int count = itemCount;
- int index = 0;
- while (index < count) {
- if (items [index] == item) break;
- index++;
- }
- int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- int oldPtr = args [1];
- int newPtr = OS.malloc ((count - 1) * 4);
- if (newPtr == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
- int j = 0;
- int [] str = new int [1];
- int [] address = new int [1];
- for (int i=0; i<count; i++) {
- if (i == index) continue;
- OS.memmove (address, oldPtr + (i * 4), 4);
- str [0] = OS.strdup (address [0]);
- if (str [0] == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
- OS.memmove (newPtr + (j++ * 4), str, 4);
- }
- OS.PtSetResource (handle, OS.Pt_ARG_PG_PANEL_TITLES, newPtr, count - 1);
- for (int i=0; i<count-1; i++) {
- 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;
- itemCount--;
-}
-
-public Rectangle getClientArea () {
- checkWidget();
- PhArea_t area = new PhArea_t ();
- if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
- int clientHandle = OS.PtWidgetChildBack (handle);
- OS.PtWidgetArea (clientHandle, area);
- return new Rectangle (area.pos_x, area.pos_y, area.size_w, area.size_h);
-}
-
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ 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) {
+ checkWidget();
+ 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 (wHint, hHint, changed);
+ }
+ 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) {
+ checkWidget();
+ 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) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int parentHandle = parent.parentingHandle ();
+ int [] args = {
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ parentingHandle = OS.PtCreateWidget (OS.PtContainer (), parentHandle, args.length / 3, args);
+ if (parentingHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ int clazz = display.PtPanelGroup;
+ args = new int []{
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentingHandle, 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 count = itemCount;
+ 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 [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int oldPtr = args [1];
+ int newPtr = OS.malloc ((count + 1) * 4);
+ if (newPtr == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ int j = 0;
+ int [] str = new int [1];
+ int [] address = new int [1];
+ for (int i=0; i<=count; i++) {
+ if (i == index) {
+ str [0] = OS.malloc (1);
+ } else {
+ OS.memmove (address, oldPtr + (j++ * 4), 4);
+ str [0] = OS.strdup (address [0]);
+ }
+ if (str [0] == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ OS.memmove (newPtr + (i * 4), str, 4);
+ }
+ OS.PtSetResource (handle, OS.Pt_ARG_PG_PANEL_TITLES, newPtr, count + 1);
+ for (int i=0; i<=count; i++) {
+ 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;
+ itemCount++;
+}
+
+void deregister () {
+ super.deregister ();
+ if (parentingHandle != 0) WidgetTable.remove (parentingHandle);
+}
+
+void destroyItem (TabItem item) {
+ int count = itemCount;
+ int index = 0;
+ while (index < count) {
+ if (items [index] == item) break;
+ index++;
+ }
+ int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int oldPtr = args [1];
+ int newPtr = OS.malloc ((count - 1) * 4);
+ if (newPtr == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ int j = 0;
+ int [] str = new int [1];
+ int [] address = new int [1];
+ for (int i=0; i<count; i++) {
+ if (i == index) continue;
+ OS.memmove (address, oldPtr + (i * 4), 4);
+ str [0] = OS.strdup (address [0]);
+ if (str [0] == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ OS.memmove (newPtr + (j++ * 4), str, 4);
+ }
+ OS.PtSetResource (handle, OS.Pt_ARG_PG_PANEL_TITLES, newPtr, count - 1);
+ for (int i=0; i<count-1; i++) {
+ 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;
+ itemCount--;
+}
+
+public Rectangle getClientArea () {
+ checkWidget();
+ PhArea_t area = new PhArea_t ();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
+ int clientHandle = OS.PtWidgetChildBack (handle);
+ OS.PtWidgetArea (clientHandle, area);
+ return new Rectangle (area.pos_x, area.pos_y, area.size_w, area.size_h);
+}
+
/**
* Returns the item at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
@@ -285,12 +285,12 @@ public Rectangle getClientArea () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public TabItem getItem (int index) {
- checkWidget();
- if (!(0 <= index && index < itemCount)) error (SWT.ERROR_INVALID_RANGE);
- return items [index];
-}
-
+public TabItem getItem (int index) {
+ checkWidget();
+ if (!(0 <= index && index < itemCount)) error (SWT.ERROR_INVALID_RANGE);
+ return items [index];
+}
+
/**
* Returns an array of <code>TabItem</code>s which are the items
* in the receiver.
@@ -307,13 +307,13 @@ public TabItem getItem (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public TabItem [] getItems () {
- checkWidget();
- TabItem [] result = new TabItem [itemCount];
- System.arraycopy (items, 0, result, 0, result.length);
- return result;
-}
-
+public TabItem [] getItems () {
+ checkWidget();
+ TabItem [] result = new TabItem [itemCount];
+ System.arraycopy (items, 0, result, 0, result.length);
+ return result;
+}
+
/**
* Returns the number of items contained in the receiver.
*
@@ -324,11 +324,11 @@ public TabItem [] getItems () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getItemCount () {
- checkWidget();
- return itemCount;
-}
-
+public int getItemCount () {
+ checkWidget();
+ return itemCount;
+}
+
/**
* Returns an array of <code>TabItem</code>s that are currently
* selected in the receiver. An empty array indicates that no
@@ -345,13 +345,13 @@ public int getItemCount () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public TabItem [] getSelection () {
- checkWidget();
- int index = getSelectionIndex ();
- if (index == -1) return new TabItem [0];
- return new TabItem [] {items [index]};
-}
-
+public TabItem [] getSelection () {
+ checkWidget();
+ int index = getSelectionIndex ();
+ if (index == -1) return new TabItem [0];
+ return new TabItem [] {items [index]};
+}
+
/**
* Returns the zero-relative index of the item which is currently
* selected in the receiver, or -1 if no item is selected.
@@ -363,26 +363,26 @@ public TabItem [] getSelection () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getSelectionIndex () {
- checkWidget();
- int index;
- if (currentIndex != OS.Pt_PG_INVALID && !OS.PtWidgetIsRealized (handle)) {
- index = currentIndex;
- } else {
- int [] args = {OS.Pt_ARG_PG_CURRENT_INDEX, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- index = args [1];
- }
- return index == OS.Pt_PG_INVALID ? -1 : index;
-}
-
-void hookEvents () {
- super.hookEvents ();
- int windowProc = getDisplay ().windowProc;
- OS.PtAddCallback (handle, OS.Pt_CB_PG_PANEL_SWITCHING, windowProc, OS.Pt_CB_PG_PANEL_SWITCHING);
- OS.PtAddCallback (handle, OS.Pt_CB_REALIZED, windowProc, OS.Pt_CB_REALIZED);
-}
-
+public int getSelectionIndex () {
+ checkWidget();
+ int index;
+ if (currentIndex != OS.Pt_PG_INVALID && !OS.PtWidgetIsRealized (handle)) {
+ index = currentIndex;
+ } else {
+ int [] args = {OS.Pt_ARG_PG_CURRENT_INDEX, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ index = args [1];
+ }
+ return index == OS.Pt_PG_INVALID ? -1 : index;
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_PG_PANEL_SWITCHING, windowProc, OS.Pt_CB_PG_PANEL_SWITCHING);
+ OS.PtAddCallback (handle, OS.Pt_CB_REALIZED, windowProc, OS.Pt_CB_REALIZED);
+}
+
/**
* Searches the receiver's list starting at the first item
* (index 0) until an item is found that is equal to the
@@ -400,106 +400,106 @@ void hookEvents () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int indexOf (TabItem item) {
- checkWidget();
- if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- for (int i=0; i<itemCount; i++) {
- if (items [i] == item) return i;
- }
- return -1;
-}
-
-Point minimumSize (int wHint, int hHint, boolean flushCache) {
- Control [] children = _getChildren ();
- int width = 0, height = 0;
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- int index = 0;
- while (index < itemCount) {
- if (items [index].control == child) break;
- index++;
- }
- if (index == itemCount) {
- Rectangle rect = child.getBounds ();
- width = Math.max (width, rect.x + rect.width);
- height = Math.max (height, rect.y + rect.height);
- } else {
- Point size = child.computeSize (wHint, hHint, flushCache);
- width = Math.max (width, size.x);
- height = Math.max (height, size.y);
- }
- }
- return new Point (width, height);
-}
-
-void moveToBack (int child) {
- OS.PtWidgetInsert (child, handle, 0);
-}
-
-int parentingHandle () {
- return parentingHandle;
-}
-
-int Pt_CB_PG_PANEL_SWITCHING (int widget, 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);
- Control oldControl = null;
- int index = oldIndex [0];
- TabItem oldItem = items [index];
- if (0 <= index && index < itemCount) oldControl = oldItem.control;
- Control newControl = null;
- index = newIndex [0];
- TabItem newItem = items [index];
- if (0 <= index && index < itemCount) newControl = newItem.control;
- if (oldControl != null && !oldControl.isDisposed()) oldControl.setVisible (false);
- if (newControl != null && !newControl.isDisposed()) {
- newControl.setBounds (getClientArea ());
- newControl.setVisible (true);
- }
- Event event = new Event ();
- event.item = newItem;
- postEvent (SWT.Selection, event);
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_REALIZED (int widget, int info) {
- int result = super.Pt_CB_REALIZED (widget, info);
- if (currentIndex != OS.Pt_PG_INVALID) {
- if (info == 0) return OS.Pt_END;
- PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
- OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
- if (cbinfo.reason == OS.Pt_CB_REALIZED) {
- setSelection (currentIndex, false);
- currentIndex = OS.Pt_PG_INVALID;
- }
- }
- return result;
-}
-
-void register () {
- super.register ();
- if (parentingHandle != 0) WidgetTable.put (parentingHandle, this);
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- parentingHandle = 0;
-}
-
-void releaseWidget () {
- for (int i=0; i<itemCount; i++) {
- TabItem item = items [i];
- if (!item.isDisposed ()) item.releaseResources ();
- }
- items = null;
- super.releaseWidget ();
-}
-
+public int indexOf (TabItem item) {
+ checkWidget();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ for (int i=0; i<itemCount; i++) {
+ if (items [i] == item) return i;
+ }
+ return -1;
+}
+
+Point minimumSize (int wHint, int hHint, boolean flushCache) {
+ Control [] children = _getChildren ();
+ int width = 0, height = 0;
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ int index = 0;
+ while (index < itemCount) {
+ if (items [index].control == child) break;
+ index++;
+ }
+ if (index == itemCount) {
+ Rectangle rect = child.getBounds ();
+ width = Math.max (width, rect.x + rect.width);
+ height = Math.max (height, rect.y + rect.height);
+ } else {
+ Point size = child.computeSize (wHint, hHint, flushCache);
+ width = Math.max (width, size.x);
+ height = Math.max (height, size.y);
+ }
+ }
+ return new Point (width, height);
+}
+
+void moveToBack (int child) {
+ OS.PtWidgetInsert (child, handle, 0);
+}
+
+int parentingHandle () {
+ return parentingHandle;
+}
+
+int Pt_CB_PG_PANEL_SWITCHING (int widget, 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);
+ Control oldControl = null;
+ int index = oldIndex [0];
+ TabItem oldItem = items [index];
+ if (0 <= index && index < itemCount) oldControl = oldItem.control;
+ Control newControl = null;
+ index = newIndex [0];
+ TabItem newItem = items [index];
+ if (0 <= index && index < itemCount) newControl = newItem.control;
+ if (oldControl != null && !oldControl.isDisposed()) oldControl.setVisible (false);
+ if (newControl != null && !newControl.isDisposed()) {
+ newControl.setBounds (getClientArea ());
+ newControl.setVisible (true);
+ }
+ Event event = new Event ();
+ event.item = newItem;
+ postEvent (SWT.Selection, event);
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_REALIZED (int widget, int info) {
+ int result = super.Pt_CB_REALIZED (widget, info);
+ if (currentIndex != OS.Pt_PG_INVALID) {
+ if (info == 0) return OS.Pt_END;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.reason == OS.Pt_CB_REALIZED) {
+ setSelection (currentIndex, false);
+ currentIndex = OS.Pt_PG_INVALID;
+ }
+ }
+ return result;
+}
+
+void register () {
+ super.register ();
+ if (parentingHandle != 0) WidgetTable.put (parentingHandle, this);
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ parentingHandle = 0;
+}
+
+void releaseWidget () {
+ for (int i=0; i<itemCount; i++) {
+ TabItem item = items [i];
+ if (!item.isDisposed ()) item.releaseResources ();
+ }
+ items = null;
+ super.releaseWidget ();
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver's selection changes.
@@ -517,32 +517,32 @@ void releaseWidget () {
* @see SelectionListener
* @see #addSelectionListener
*/
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
-int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
- int result = super.setBounds (x, y, width, height, move, resize, events);
- if ((result & RESIZED) != 0) {
- int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
- OS.PtGetResources (parentingHandle, args.length / 3, args);
- OS.PtSetResources (handle, args.length / 3, args);
- int index = getSelectionIndex ();
- if (index != -1) {
- TabItem item = items [index];
- Control control = item.control;
- if (control != null && !control.isDisposed ()) {
- control.setBounds (getClientArea ());
- }
- }
- }
- return result;
-}
-
+public void removeSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
+ int result = super.setBounds (x, y, width, height, move, resize, events);
+ if ((result & RESIZED) != 0) {
+ int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (parentingHandle, args.length / 3, args);
+ OS.PtSetResources (handle, args.length / 3, args);
+ int index = getSelectionIndex ();
+ if (index != -1) {
+ TabItem item = items [index];
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getClientArea ());
+ }
+ }
+ }
+ return result;
+}
+
/**
* Selects the item at the given zero-relative index in the receiver.
* If the item at the index was already selected, it remains selected.
@@ -556,50 +556,50 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (int index) {
- checkWidget();
- setSelection (index, false);
-}
-
-void setSelection (int index, boolean notify) {
- 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);
- }
- }
- if (index == -1) index = OS.Pt_PG_INVALID;
- OS.PtSetResource (handle, OS.Pt_ARG_PG_CURRENT_INDEX, index, 0);
- args [1] = 0;
- OS.PtGetResources (handle, args.length / 3, args);
- int newIndex = args [1];
- /*
- * Bug in Photon. Pt_ARG_PG_CURRENT_INDEX cannot be set if
- * the widget is not realized. The fix is to remember the current
- * index and reset it when the widget is realized.
- */
- if (!OS.PtWidgetIsRealized (handle)) {
- newIndex = currentIndex = index;
- }
- if (newIndex != OS.Pt_PG_INVALID) {
- TabItem item = items [newIndex];
- Control control = item.control;
- if (control != null && !control.isDisposed ()) {
- control.setBounds (getClientArea ());
- control.setVisible (true);
- }
- if (notify) {
- Event event = new Event ();
- event.item = item;
- postEvent (SWT.Selection, event);
- }
- }
-}
-
+public void setSelection (int index) {
+ checkWidget();
+ setSelection (index, false);
+}
+
+void setSelection (int index, boolean notify) {
+ 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);
+ }
+ }
+ if (index == -1) index = OS.Pt_PG_INVALID;
+ OS.PtSetResource (handle, OS.Pt_ARG_PG_CURRENT_INDEX, index, 0);
+ args [1] = 0;
+ OS.PtGetResources (handle, args.length / 3, args);
+ int newIndex = args [1];
+ /*
+ * Bug in Photon. Pt_ARG_PG_CURRENT_INDEX cannot be set if
+ * the widget is not realized. The fix is to remember the current
+ * index and reset it when the widget is realized.
+ */
+ if (!OS.PtWidgetIsRealized (handle)) {
+ newIndex = currentIndex = index;
+ }
+ if (newIndex != OS.Pt_PG_INVALID) {
+ TabItem item = items [newIndex];
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getClientArea ());
+ control.setVisible (true);
+ }
+ if (notify) {
+ Event event = new Event ();
+ event.item = item;
+ postEvent (SWT.Selection, event);
+ }
+ }
+}
+
/**
* Sets the receiver's selection to be the given array of items.
* The current selected is first cleared, then the new items are
@@ -612,39 +612,39 @@ void setSelection (int index, boolean notify) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (TabItem [] items) {
- checkWidget();
- 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);
- }
-}
-
-boolean traversePage (boolean next) {
- int count = getItemCount ();
- if (count == 0) return false;
- int index = getSelectionIndex ();
- if (index == -1) {
- index = 0;
- } else {
- int offset = next ? 1 : -1;
- index = (index + offset + count) % count;
- }
- setSelection (index, true);
- return true;
-}
-
-int topHandle () {
- return parentingHandle;
-}
-
-int widgetClass () {
- return OS.PtPanelGroup ();
-}
-
-}
+public void setSelection (TabItem [] items) {
+ checkWidget();
+ 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);
+ }
+}
+
+boolean traversePage (boolean next) {
+ int count = getItemCount ();
+ if (count == 0) return false;
+ int index = getSelectionIndex ();
+ if (index == -1) {
+ index = 0;
+ } else {
+ int offset = next ? 1 : -1;
+ index = (index + offset + count) % count;
+ }
+ setSelection (index, true);
+ return true;
+}
+
+int topHandle () {
+ return parentingHandle;
+}
+
+int widgetClass () {
+ return OS.PtPanelGroup ();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabItem.java
index 3b4e125e97..0a9ffda9d3 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabItem.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class represent a selectable user interface object
* corresponding to a tab for a page in a tab folder.
@@ -25,11 +25,11 @@ import org.eclipse.swt.graphics.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class TabItem extends Item {
- TabFolder parent;
- Control control;
- String toolTipText;
-
+public class TabItem extends Item {
+ TabFolder parent;
+ Control control;
+ String toolTipText;
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>TabFolder</code>) and a style value
@@ -60,10 +60,10 @@ public class TabItem extends Item {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public TabItem (TabFolder parent, int style) {
- this(parent, style, parent.getItemCount ());
-}
-
+public TabItem (TabFolder parent, int style) {
+ this(parent, style, parent.getItemCount ());
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>TabFolder</code>), a style value
@@ -95,16 +95,16 @@ public TabItem (TabFolder parent, int style) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-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 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);
+}
+
/**
* Returns the control that is used to fill the client area of
* the tab folder when the user selects the tab item. If no
@@ -117,17 +117,17 @@ protected void checkSubclass () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Control getControl () {
- checkWidget();
- return control;
-}
-
-public Display getDisplay () {
- TabFolder parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-
+public Control getControl () {
+ checkWidget();
+ return control;
+}
+
+public Display getDisplay () {
+ TabFolder parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
/**
* Returns the receiver's parent, which must be a <code>TabFolder</code>.
*
@@ -138,11 +138,11 @@ public Display getDisplay () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public TabFolder getParent () {
- checkWidget();
- return parent;
-}
-
+public TabFolder getParent () {
+ checkWidget();
+ return parent;
+}
+
/**
* Returns the receiver's tool tip text, or null if it has
* not been set.
@@ -154,27 +154,27 @@ public TabFolder getParent () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public String getToolTipText () {
- checkWidget();
- return toolTipText;
-}
-
-void releaseChild () {
- super.releaseChild ();
- int index = parent.indexOf (this);
- if (index == parent.getSelectionIndex ()) {
- if (control != null) control.setVisible (false);
- }
- parent.destroyItem (this);
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- control = null;
- parent = null;
- toolTipText = null;
-}
-
+public String getToolTipText () {
+ checkWidget();
+ return toolTipText;
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ int index = parent.indexOf (this);
+ if (index == parent.getSelectionIndex ()) {
+ if (control != null) control.setVisible (false);
+ }
+ parent.destroyItem (this);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ control = null;
+ parent = null;
+ toolTipText = null;
+}
+
/**
* Sets the control that is used to fill the client area of
* the tab folder when the user selects the tab item.
@@ -190,65 +190,65 @@ void releaseWidget () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setControl (Control control) {
- checkWidget();
- if (control != null) {
- if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
- }
- if (this.control != null && this.control.isDisposed ()) {
- this.control = null;
- }
- Control oldControl = this.control, newControl = control;
- this.control = control;
- int index = parent.indexOf (this);
- if (index != parent.getSelectionIndex ()) {
- if (newControl != null) newControl.setVisible (false);
- return;
- }
- if (newControl != null) {
- newControl.setBounds (parent.getClientArea ());
- newControl.setVisible (true);
- }
- if (oldControl != null) oldControl.setVisible (false);
-}
-
-public void setImage (Image image) {
- checkWidget();
- //NOT SUPPORTED
-}
-
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- super.setText (string);
- 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);
- int [] str = new int [1];
- int [] address = new int [1];
- byte [] buffer = Converter.wcsToMbcs (null, stripMnemonics (string), true);
- for (int i=0; i<count; i++) {
- if (i == index) {
- str [0] = OS.malloc (buffer.length);
- OS.memmove (str [0], buffer, buffer.length);
- } else {
- OS.memmove (address, oldPtr + (i * 4), 4);
- str [0] = OS.strdup (address [0]);
- }
- OS.memmove (newPtr + (i * 4), str, 4);
- }
- OS.PtSetResource (parent.handle, OS.Pt_ARG_PG_PANEL_TITLES, newPtr, count);
- for (int i=0; i<count; i++) {
- OS.memmove (address, newPtr + (i * 4), 4);
- OS.free (address [0]);
- }
- OS.free (newPtr);
-}
-
+public void setControl (Control control) {
+ checkWidget();
+ if (control != null) {
+ if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
+ }
+ if (this.control != null && this.control.isDisposed ()) {
+ this.control = null;
+ }
+ Control oldControl = this.control, newControl = control;
+ this.control = control;
+ int index = parent.indexOf (this);
+ if (index != parent.getSelectionIndex ()) {
+ if (newControl != null) newControl.setVisible (false);
+ return;
+ }
+ if (newControl != null) {
+ newControl.setBounds (parent.getClientArea ());
+ newControl.setVisible (true);
+ }
+ if (oldControl != null) oldControl.setVisible (false);
+}
+
+public void setImage (Image image) {
+ checkWidget();
+ //NOT SUPPORTED
+}
+
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ super.setText (string);
+ 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);
+ int [] str = new int [1];
+ int [] address = new int [1];
+ byte [] buffer = Converter.wcsToMbcs (null, stripMnemonics (string), true);
+ for (int i=0; i<count; i++) {
+ if (i == index) {
+ str [0] = OS.malloc (buffer.length);
+ OS.memmove (str [0], buffer, buffer.length);
+ } else {
+ OS.memmove (address, oldPtr + (i * 4), 4);
+ str [0] = OS.strdup (address [0]);
+ }
+ OS.memmove (newPtr + (i * 4), str, 4);
+ }
+ OS.PtSetResource (parent.handle, OS.Pt_ARG_PG_PANEL_TITLES, newPtr, count);
+ for (int i=0; i<count; i++) {
+ OS.memmove (address, newPtr + (i * 4), 4);
+ OS.free (address [0]);
+ }
+ OS.free (newPtr);
+}
+
/**
* Sets the receiver's tool tip text to the argument, which
* may be null indicating that no tool tip text should be shown.
@@ -260,9 +260,9 @@ public void setText (String string) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setToolTipText (String string) {
- checkWidget();
- toolTipText = string;
-}
-
-}
+public void setToolTipText (String string) {
+ checkWidget();
+ toolTipText = string;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java
index e2d67ff41d..af858421d7 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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.*;
+
/**
* Instances of this class are selectable user interface
* objects that allow the user to enter and modify text.
@@ -29,25 +29,25 @@ import org.eclipse.swt.events.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class Text extends Scrollable {
- char echoCharacter;
- boolean ignoreChange;
- String hiddenText;
- int tabs, 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 class Text extends Scrollable {
+ char echoCharacter;
+ boolean ignoreChange;
+ String hiddenText;
+ int tabs, 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";
+ }
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -79,65 +79,65 @@ public class Text extends Scrollable {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Text (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-static int checkStyle (int style) {
- style = checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
- if ((style & SWT.SINGLE) != 0) style &= ~(SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP);
- if ((style & SWT.WRAP) != 0) style |= SWT.MULTI;
- 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) {
- checkWidget();
-
- int [] args = new int [] {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- boolean wrap = (style & SWT.WRAP) != 0;
- if (wrap) {
- if (wHint == SWT.DEFAULT) {
- OS.PtSetResource (handle, OS.Pt_ARG_MULTITEXT_WRAP_FLAGS, OS.Pt_EMT_NEWLINE, ~0);
- } else {
- OS.PtSetResource (handle, OS.Pt_ARG_WIDTH, wHint, 0);
- }
- }
- int resizeFlags = OS.Pt_RESIZE_X_ALWAYS | OS.Pt_RESIZE_Y_ALWAYS;
- OS.PtSetResource (handle, OS.Pt_ARG_RESIZE_FLAGS, resizeFlags, OS.Pt_RESIZE_XY_BITS);
- if ((style & SWT.MULTI) != 0 || !OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
- PhDim_t dim = new PhDim_t ();
- OS.PtWidgetPreferredSize (handle, dim);
- int width = dim.w, height = dim.h;
- OS.PtSetResource (handle, OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS);
- if (wrap) {
- if (wHint == SWT.DEFAULT) {
- int wrapFlags = OS.Pt_EMT_WORD | OS.Pt_EMT_CHAR | OS.Pt_EMT_NEWLINE;
- OS.PtSetResource (handle, OS.Pt_ARG_MULTITEXT_WRAP_FLAGS, wrapFlags, ~0);
- }
- }
- OS.PtSetResources (handle, args.length / 3, args);
-
- ScrollBar scroll;
- int scrollWidth = (scroll = getVerticalBar ()) != null ? scroll.getSize ().x : 0;
- int scrollHeight = (scroll = getHorizontalBar ()) != null ? scroll.getSize ().y : 0;
- width += scrollWidth;
- if (!wrap) height += scrollHeight;
-
- 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 + scrollWidth;
- if (hHint != SWT.DEFAULT) height = area.size_h + scrollHeight;
- }
- return new Point(width, height);
-}
+public Text (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+ style = checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
+ if ((style & SWT.SINGLE) != 0) style &= ~(SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP);
+ if ((style & SWT.WRAP) != 0) style |= SWT.MULTI;
+ 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) {
+ checkWidget();
+
+ int [] args = new int [] {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ boolean wrap = (style & SWT.WRAP) != 0;
+ if (wrap) {
+ if (wHint == SWT.DEFAULT) {
+ OS.PtSetResource (handle, OS.Pt_ARG_MULTITEXT_WRAP_FLAGS, OS.Pt_EMT_NEWLINE, ~0);
+ } else {
+ OS.PtSetResource (handle, OS.Pt_ARG_WIDTH, wHint, 0);
+ }
+ }
+ int resizeFlags = OS.Pt_RESIZE_X_ALWAYS | OS.Pt_RESIZE_Y_ALWAYS;
+ OS.PtSetResource (handle, OS.Pt_ARG_RESIZE_FLAGS, resizeFlags, OS.Pt_RESIZE_XY_BITS);
+ if ((style & SWT.MULTI) != 0 || !OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
+ PhDim_t dim = new PhDim_t ();
+ OS.PtWidgetPreferredSize (handle, dim);
+ int width = dim.w, height = dim.h;
+ OS.PtSetResource (handle, OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS);
+ if (wrap) {
+ if (wHint == SWT.DEFAULT) {
+ int wrapFlags = OS.Pt_EMT_WORD | OS.Pt_EMT_CHAR | OS.Pt_EMT_NEWLINE;
+ OS.PtSetResource (handle, OS.Pt_ARG_MULTITEXT_WRAP_FLAGS, wrapFlags, ~0);
+ }
+ }
+ OS.PtSetResources (handle, args.length / 3, args);
+
+ ScrollBar scroll;
+ int scrollWidth = (scroll = getVerticalBar ()) != null ? scroll.getSize ().x : 0;
+ int scrollHeight = (scroll = getHorizontalBar ()) != null ? scroll.getSize ().y : 0;
+ width += scrollWidth;
+ if (!wrap) height += scrollHeight;
+
+ 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 + scrollWidth;
+ if (hHint != SWT.DEFAULT) height = area.size_h + scrollHeight;
+ }
+ return new Point(width, height);
+}
/**
* Clears the selection.
*
@@ -146,56 +146,56 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void clearSelection () {
- checkWidget();
- int [] position = {0};
- if ((style & SWT.SINGLE) != 0) {
- int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- position [0] = args [1];
- }
- OS.PtTextSetSelection (handle, position, position);
-}
-void createHandle (int index) {
- state |= HANDLE;
- Display display = getDisplay ();
- int parentHandle = parent.parentingHandle ();
- boolean hasBorder = (style & SWT.BORDER) != 0;
- int textFlags = (style & SWT.READ_ONLY) != 0 ? 0 : OS.Pt_EDITABLE;
- if ((style & SWT.SINGLE) != 0) {
- int clazz = display.PtText;
- int [] args = {
- OS.Pt_ARG_FLAGS, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
- OS.Pt_ARG_FLAGS, OS.Pt_CALLBACKS_ACTIVE, OS.Pt_CALLBACKS_ACTIVE,
- OS.Pt_ARG_TEXT_FLAGS, textFlags, OS.Pt_EDITABLE,
- OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
- };
- 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, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
- OS.Pt_ARG_FLAGS, OS.Pt_CALLBACKS_ACTIVE, OS.Pt_CALLBACKS_ACTIVE,
- OS.Pt_ARG_TEXT_FLAGS, textFlags, OS.Pt_EDITABLE,
- OS.Pt_ARG_MULTITEXT_WRAP_FLAGS, wrapFlags, OS.Pt_EMT_WORD | OS.Pt_EMT_CHAR,
- 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);
- createStandardScrollBars ();
-}
-
-void createWidget (int index) {
- super.createWidget (index);
-// doubleClick = true;
- setTabStops (tabs = 8);
-}
-
+public void clearSelection () {
+ checkWidget();
+ int [] position = {0};
+ if ((style & SWT.SINGLE) != 0) {
+ int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ position [0] = args [1];
+ }
+ OS.PtTextSetSelection (handle, position, position);
+}
+void createHandle (int index) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int parentHandle = parent.parentingHandle ();
+ boolean hasBorder = (style & SWT.BORDER) != 0;
+ int textFlags = (style & SWT.READ_ONLY) != 0 ? 0 : OS.Pt_EDITABLE;
+ if ((style & SWT.SINGLE) != 0) {
+ int clazz = display.PtText;
+ int [] args = {
+ OS.Pt_ARG_FLAGS, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
+ OS.Pt_ARG_FLAGS, OS.Pt_CALLBACKS_ACTIVE, OS.Pt_CALLBACKS_ACTIVE,
+ OS.Pt_ARG_TEXT_FLAGS, textFlags, OS.Pt_EDITABLE,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ 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, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
+ OS.Pt_ARG_FLAGS, OS.Pt_CALLBACKS_ACTIVE, OS.Pt_CALLBACKS_ACTIVE,
+ OS.Pt_ARG_TEXT_FLAGS, textFlags, OS.Pt_EDITABLE,
+ OS.Pt_ARG_MULTITEXT_WRAP_FLAGS, wrapFlags, OS.Pt_EMT_WORD | OS.Pt_EMT_CHAR,
+ 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);
+ createStandardScrollBars ();
+}
+
+void createWidget (int index) {
+ super.createWidget (index);
+// doubleClick = true;
+ setTabStops (tabs = 8);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver's text is modified, by sending
@@ -215,13 +215,13 @@ void createWidget (int index) {
* @see ModifyListener
* @see #removeModifyListener
*/
-public void addModifyListener (ModifyListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Modify, typedListener);
-}
-
+public void addModifyListener (ModifyListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Modify, typedListener);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the control is selected, by sending
@@ -246,14 +246,14 @@ public void addModifyListener (ModifyListener listener) {
* @see #removeSelectionListener
* @see SelectionEvent
*/
-public void addSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
+public void addSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver's text is verified, by sending
@@ -273,13 +273,13 @@ public void addSelectionListener (SelectionListener listener) {
* @see VerifyListener
* @see #removeVerifyListener
*/
-public void addVerifyListener (VerifyListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Verify, typedListener);
-}
-
+public void addVerifyListener (VerifyListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Verify, typedListener);
+}
+
/**
* Appends a string.
* <p>
@@ -297,13 +297,13 @@ public void addVerifyListener (VerifyListener listener) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void append (String string) {
- checkWidget();
- 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 append (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (null, string, false);
+ OS.PtTextModifyText (handle, 0, 0, -1, buffer, buffer.length);
+}
+
/**
* Copies the selected text.
* <p>
@@ -315,19 +315,19 @@ public void append (String string) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void copy () {
- checkWidget();
- 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 copy () {
+ checkWidget();
+ 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);
+}
+
/**
* Cuts the selected text.
* <p>
@@ -343,46 +343,46 @@ public void copy () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void cut () {
- checkWidget();
- 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);
-}
-
-void deregister () {
- super.deregister ();
-
- /*
- * Bug in Photon. Even though the Pt_CB_GOT_FOCUS callback
- * is added to the multi-line text, the widget parameter
- * in the callback is a child of the multi-line text. The fix
- * is to register that child so that the lookup in the widget
- * table will find the muti-line text.
- */
- if ((style & SWT.MULTI) == 0) return;
- int child = OS.PtWidgetChildBack (handle);
- WidgetTable.remove (child);
-}
-
-int defaultBackground () {
- Display display = getDisplay ();
- return display.TEXT_BACKGROUND;
-}
-
-int defaultForeground () {
- Display display = getDisplay ();
- return display.TEXT_FOREGROUND;
-}
-
+public void cut () {
+ checkWidget();
+ 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);
+}
+
+void deregister () {
+ super.deregister ();
+
+ /*
+ * Bug in Photon. Even though the Pt_CB_GOT_FOCUS callback
+ * is added to the multi-line text, the widget parameter
+ * in the callback is a child of the multi-line text. The fix
+ * is to register that child so that the lookup in the widget
+ * table will find the muti-line text.
+ */
+ if ((style & SWT.MULTI) == 0) return;
+ int child = OS.PtWidgetChildBack (handle);
+ WidgetTable.remove (child);
+}
+
+int defaultBackground () {
+ Display display = getDisplay ();
+ return display.TEXT_BACKGROUND;
+}
+
+int defaultForeground () {
+ Display display = getDisplay ();
+ return display.TEXT_FOREGROUND;
+}
+
/**
* Gets the line number of the caret.
* <p>
@@ -399,12 +399,12 @@ int defaultForeground () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getCaretLineNumber () {
- checkWidget();
- //NOT DONE - NOT NEEDED
- return 0;
-}
-
+public int getCaretLineNumber () {
+ checkWidget();
+ //NOT DONE - NOT NEEDED
+ return 0;
+}
+
/**
* Gets the location the caret.
* <p>
@@ -418,12 +418,12 @@ public int getCaretLineNumber () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Point getCaretLocation () {
- checkWidget();
- //NOT DONE - NOT NEEDED
- return null;
-}
-
+public Point getCaretLocation () {
+ checkWidget();
+ //NOT DONE - NOT NEEDED
+ return null;
+}
+
/**
* Gets the position of the caret.
* <p>
@@ -437,13 +437,13 @@ public Point getCaretLocation () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getCaretPosition () {
- checkWidget();
- int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getCaretPosition () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Gets the number of characters.
*
@@ -454,14 +454,14 @@ public int getCaretPosition () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getCharCount () {
- checkWidget();
- 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 int getCharCount () {
+ checkWidget();
+ 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]);
+}
+
/**
* Gets the double click enabled flag.
* <p>
@@ -475,12 +475,12 @@ public int getCharCount () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getDoubleClickEnabled () {
- checkWidget();
- //NOT DONE - NOT NEEDED
- return false;
-}
-
+public boolean getDoubleClickEnabled () {
+ checkWidget();
+ //NOT DONE - NOT NEEDED
+ return false;
+}
+
/**
* Gets the echo character.
* <p>
@@ -494,11 +494,11 @@ public boolean getDoubleClickEnabled () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public char getEchoChar () {
- checkWidget();
- return echoCharacter;
-}
-
+public char getEchoChar () {
+ checkWidget();
+ return echoCharacter;
+}
+
/**
* Gets the editable state.
*
@@ -507,13 +507,13 @@ public char getEchoChar () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getEditable () {
- checkWidget();
- int [] args = {OS.Pt_ARG_TEXT_FLAGS, 0, 0};
- OS.PtGetResources(handle, args.length / 3, args);
- return (args [1] & OS.Pt_EDITABLE) != 0;
-}
-
+public boolean getEditable () {
+ checkWidget();
+ int [] args = {OS.Pt_ARG_TEXT_FLAGS, 0, 0};
+ OS.PtGetResources(handle, args.length / 3, args);
+ return (args [1] & OS.Pt_EDITABLE) != 0;
+}
+
/**
* Gets the number of lines.
*
@@ -524,14 +524,14 @@ public boolean getEditable () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getLineCount () {
- checkWidget();
- 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 int getLineCount () {
+ checkWidget();
+ 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];
+}
+
/**
* Gets the line delimiter.
*
@@ -542,11 +542,11 @@ public int getLineCount () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public String getLineDelimiter () {
- checkWidget();
- return "\n";
-}
-
+public String getLineDelimiter () {
+ checkWidget();
+ return "\n";
+}
+
/**
* Gets the height of a line.
*
@@ -557,39 +557,39 @@ public String getLineDelimiter () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getLineHeight () {
- checkWidget();
- 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];
-}
-
-String getNameText () {
- if ((style & SWT.SINGLE) != 0) return getText ();
- return getText (0, Math.min(getCharCount () - 1, 10));
-}
-
+public int getLineHeight () {
+ checkWidget();
+ 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];
+}
+
+String getNameText () {
+ if ((style & SWT.SINGLE) != 0) return getText ();
+ return getText (0, Math.min(getCharCount () - 1, 10));
+}
+
/**
* Gets the position of the selected text.
* <p>
@@ -605,21 +605,21 @@ String getNameText () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Point getSelection () {
- checkWidget();
- 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 Point getSelection () {
+ checkWidget();
+ 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]);
+}
+
/**
* Gets the number of selected characters.
*
@@ -630,12 +630,12 @@ public Point getSelection () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getSelectionCount () {
- checkWidget();
- Point selection = getSelection ();
- return selection.y - selection.x;
-}
-
+public int getSelectionCount () {
+ checkWidget();
+ Point selection = getSelection ();
+ return selection.y - selection.x;
+}
+
/**
* Gets the selected text.
*
@@ -646,17 +646,17 @@ public int getSelectionCount () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public String getSelectionText () {
- checkWidget();
- /*
- * 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 String getSelectionText () {
+ checkWidget();
+ /*
+ * NOTE: The current implementation uses substring ()
+ * which can reference a potentially large character
+ * array.
+ */
+ Point selection = getSelection ();
+ return getText ().substring (selection.x, selection.y);
+}
+
/**
* Gets the number of tabs.
* <p>
@@ -672,23 +672,23 @@ public String getSelectionText () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getTabs () {
- checkWidget();
- return tabs;
-}
-
-int getTabWidth (int tabs) {
- int [] args = new int [] {OS.Pt_ARG_TEXT_FONT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- PhRect_t rect = new PhRect_t ();
- int ptr = OS.malloc (1);
- OS.memmove (ptr, new byte [] {' '}, 1);
- OS.PfExtentText(rect, null, args [1], ptr, 1);
- OS.free (ptr);
- int width = rect.lr_x - rect.ul_x + 1;
- return width * tabs;
-}
-
+public int getTabs () {
+ checkWidget();
+ return tabs;
+}
+
+int getTabWidth (int tabs) {
+ int [] args = new int [] {OS.Pt_ARG_TEXT_FONT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ PhRect_t rect = new PhRect_t ();
+ int ptr = OS.malloc (1);
+ OS.memmove (ptr, new byte [] {' '}, 1);
+ OS.PfExtentText(rect, null, args [1], ptr, 1);
+ OS.free (ptr);
+ int width = rect.lr_x - rect.ul_x + 1;
+ return width * tabs;
+}
+
/**
* Gets a range of text.
* <p>
@@ -706,17 +706,17 @@ int getTabWidth (int tabs) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public String getText (int start, int end) {
- checkWidget();
- /*
- * 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 (int start, int end) {
+ checkWidget();
+ /*
+ * 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);
+}
+
/**
* Gets the widget text.
* <p>
@@ -730,19 +730,19 @@ public String getText (int start, int end) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public String getText () {
- checkWidget();
- 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 String getText () {
+ checkWidget();
+ 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);
+}
+
/**
* Returns the maximum number of characters that the receiver is capable of holding.
* <p>
@@ -757,13 +757,13 @@ public String getText () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getTextLimit () {
- checkWidget();
- int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getTextLimit () {
+ checkWidget();
+ int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the zero-relative index of the line which is currently
* at the top of the receiver.
@@ -778,14 +778,14 @@ public int getTextLimit () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getTopIndex () {
- checkWidget();
- if ((style & SWT.SINGLE) != 0) return 0;
- int [] args = {OS.Pt_ARG_MULTITEXT_TOP_LINE, 0, 0};
- OS.PtGetResources(handle, args.length / 3, args);
- return args [1] - 1;
-}
-
+public int getTopIndex () {
+ checkWidget();
+ if ((style & SWT.SINGLE) != 0) return 0;
+ int [] args = {OS.Pt_ARG_MULTITEXT_TOP_LINE, 0, 0};
+ OS.PtGetResources(handle, args.length / 3, args);
+ return args [1] - 1;
+}
+
/**
* Gets the top pixel.
* <p>
@@ -806,19 +806,19 @@ public int getTopIndex () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getTopPixel () {
- checkWidget();
- //NOT DONE - NOT NEEDED
- return 0;
-}
-
-void hookEvents () {
- super.hookEvents ();
- int windowProc = getDisplay ().windowProc;
- OS.PtAddCallback (handle, OS.Pt_CB_MODIFY_VERIFY, windowProc, OS.Pt_CB_MODIFY_VERIFY);
- OS.PtAddCallback (handle, OS.Pt_CB_TEXT_CHANGED, windowProc, OS.Pt_CB_TEXT_CHANGED);
-}
-
+public int getTopPixel () {
+ checkWidget();
+ //NOT DONE - NOT NEEDED
+ return 0;
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_MODIFY_VERIFY, windowProc, OS.Pt_CB_MODIFY_VERIFY);
+ OS.PtAddCallback (handle, OS.Pt_CB_TEXT_CHANGED, windowProc, OS.Pt_CB_TEXT_CHANGED);
+}
+
/**
* Inserts a string.
* <p>
@@ -832,20 +832,20 @@ void hookEvents () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void insert (String string) {
- checkWidget();
- 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 insert (String string) {
+ checkWidget();
+ 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);
+}
+
/**
* Pastes text from clipboard.
* <p>
@@ -858,136 +858,136 @@ public void insert (String string) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void paste () {
- checkWidget();
- 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 Pt_CB_GOT_FOCUS (int widget, int info) {
-
- /*
- * Bug in Photon. Even though the Pt_CB_GOT_FOCUS callback
- * is added to the multi-line text, the widget parameter
- * in the callback is a child of the multi-line text. The fix
- * is to register that child so that the lookup in the widget
- * table will find the muti-line text and avoid multiple
- * Pt_CB_LOST_FOCUS callbacks.
- */
- if ((style & SWT.MULTI) != 0) {
- if (widget != handle) return OS.Pt_CONTINUE;
- }
- return super.Pt_CB_GOT_FOCUS (widget, info);
-}
-
-int Pt_CB_MODIFY_VERIFY (int widget, int info) {
- if (lastModifiedText != 0) {
- OS.free (lastModifiedText);
- lastModifiedText = 0;
- }
- if (echoCharacter == '\0' && !hooks (SWT.Verify) && !filters (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;
- if (cbinfo.event != 0) {
- int data = OS.PhGetData (cbinfo.event);
- if (data != 0) {
- PhKeyEvent_t ke = new PhKeyEvent_t ();
- OS.memmove (ke, data, PhKeyEvent_t.sizeof);
- if ((ke.key_flags & (OS.Pk_KF_Key_Down | OS.Pk_KF_Key_Repeat)) != 0) {
- setKeyState (event, ke);
- }
- }
- }
- 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 OS.Pt_CONTINUE;
-}
-
-int Pt_CB_TEXT_CHANGED (int widget, int info) {
- if (lastModifiedText != 0) {
- OS.free (lastModifiedText);
- lastModifiedText = 0;
- }
- if (!ignoreChange) sendEvent (SWT.Modify);
- return OS.Pt_CONTINUE;
-}
-
-void register () {
- super.register ();
-
- /*
- * Bug in Photon. Even though the Pt_CB_GOT_FOCUS callback
- * is added to the multi-line text, the widget parameter
- * in the callback is a child of the multi-line text. The fix
- * is to register that child so that the lookup in the widget
- * table will find the muti-line text.
- */
- if ((style & SWT.MULTI) == 0) return;
- int child = OS.PtWidgetChildBack (handle);
- WidgetTable.put (child, this);
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- if (lastModifiedText != 0) OS.free (lastModifiedText);
- lastModifiedText = 0;
- hiddenText = null;
- textVerify = null;
-}
-
+public void paste () {
+ checkWidget();
+ 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 Pt_CB_GOT_FOCUS (int widget, int info) {
+
+ /*
+ * Bug in Photon. Even though the Pt_CB_GOT_FOCUS callback
+ * is added to the multi-line text, the widget parameter
+ * in the callback is a child of the multi-line text. The fix
+ * is to register that child so that the lookup in the widget
+ * table will find the muti-line text and avoid multiple
+ * Pt_CB_LOST_FOCUS callbacks.
+ */
+ if ((style & SWT.MULTI) != 0) {
+ if (widget != handle) return OS.Pt_CONTINUE;
+ }
+ return super.Pt_CB_GOT_FOCUS (widget, info);
+}
+
+int Pt_CB_MODIFY_VERIFY (int widget, int info) {
+ if (lastModifiedText != 0) {
+ OS.free (lastModifiedText);
+ lastModifiedText = 0;
+ }
+ if (echoCharacter == '\0' && !hooks (SWT.Verify) && !filters (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;
+ if (cbinfo.event != 0) {
+ int data = OS.PhGetData (cbinfo.event);
+ if (data != 0) {
+ PhKeyEvent_t ke = new PhKeyEvent_t ();
+ OS.memmove (ke, data, PhKeyEvent_t.sizeof);
+ if ((ke.key_flags & (OS.Pk_KF_Key_Down | OS.Pk_KF_Key_Repeat)) != 0) {
+ setKeyState (event, ke);
+ }
+ }
+ }
+ 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 OS.Pt_CONTINUE;
+}
+
+int Pt_CB_TEXT_CHANGED (int widget, int info) {
+ if (lastModifiedText != 0) {
+ OS.free (lastModifiedText);
+ lastModifiedText = 0;
+ }
+ if (!ignoreChange) sendEvent (SWT.Modify);
+ return OS.Pt_CONTINUE;
+}
+
+void register () {
+ super.register ();
+
+ /*
+ * Bug in Photon. Even though the Pt_CB_GOT_FOCUS callback
+ * is added to the multi-line text, the widget parameter
+ * in the callback is a child of the multi-line text. The fix
+ * is to register that child so that the lookup in the widget
+ * table will find the muti-line text.
+ */
+ if ((style & SWT.MULTI) == 0) return;
+ int child = OS.PtWidgetChildBack (handle);
+ WidgetTable.put (child, this);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ if (lastModifiedText != 0) OS.free (lastModifiedText);
+ lastModifiedText = 0;
+ hiddenText = null;
+ textVerify = null;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver's text is modified.
@@ -1005,13 +1005,13 @@ void releaseWidget () {
* @see ModifyListener
* @see #addModifyListener
*/
-public void removeModifyListener (ModifyListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Modify, listener);
-}
-
+public void removeModifyListener (ModifyListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Modify, listener);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the control is selected.
@@ -1029,14 +1029,14 @@ public void removeModifyListener (ModifyListener listener) {
* @see SelectionListener
* @see #addSelectionListener
*/
-public void removeSelectionListener (SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
+public void removeSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the control is verified.
@@ -1054,13 +1054,13 @@ public void removeSelectionListener (SelectionListener listener) {
* @see VerifyListener
* @see #addVerifyListener
*/
-public void removeVerifyListener (VerifyListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Verify, listener);
-}
-
+public void removeVerifyListener (VerifyListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Verify, listener);
+}
+
/**
* Selects all the text in the receiver.
*
@@ -1069,11 +1069,11 @@ public void removeVerifyListener (VerifyListener listener) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void selectAll () {
- checkWidget();
- OS.PtTextSetSelection (handle, new int [] {0}, new int [] {0x7FFFFFFF});
-}
-
+public void selectAll () {
+ checkWidget();
+ OS.PtTextSetSelection (handle, new int [] {0}, new int [] {0x7FFFFFFF});
+}
+
/**
* Sets the echo character.
* <p>
@@ -1094,25 +1094,25 @@ public void selectAll () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setEchoChar (char echo) {
- checkWidget();
- 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 setEchoChar (char echo) {
+ checkWidget();
+ 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;
+}
+
/**
* Sets the double click enabled flag.
* <p>
@@ -1128,11 +1128,11 @@ public void setEchoChar (char echo) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setDoubleClickEnabled (boolean doubleClick) {
- checkWidget();
- //NOT DONE - NOT NEEDED
-}
-
+public void setDoubleClickEnabled (boolean doubleClick) {
+ checkWidget();
+ //NOT DONE - NOT NEEDED
+}
+
/**
* Sets the editable state.
*
@@ -1143,19 +1143,19 @@ public void setDoubleClickEnabled (boolean doubleClick) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setEditable (boolean editable) {
- checkWidget();
- style &= ~SWT.READ_ONLY;
- if (!editable) style |= SWT.READ_ONLY;
- int flags = editable ? OS.Pt_EDITABLE : 0;
- OS.PtSetResource (handle, OS.Pt_ARG_TEXT_FLAGS, flags, OS.Pt_EDITABLE);
-}
-
-public void setFont (Font font) {
- super.setFont (font);
- setTabStops (tabs);
-}
-
+public void setEditable (boolean editable) {
+ checkWidget();
+ style &= ~SWT.READ_ONLY;
+ if (!editable) style |= SWT.READ_ONLY;
+ int flags = editable ? OS.Pt_EDITABLE : 0;
+ OS.PtSetResource (handle, OS.Pt_ARG_TEXT_FLAGS, flags, OS.Pt_EDITABLE);
+}
+
+public void setFont (Font font) {
+ super.setFont (font);
+ setTabStops (tabs);
+}
+
/**
* Sets the selection.
* <p>
@@ -1179,22 +1179,22 @@ public void setFont (Font font) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (int position) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_CURSOR_POSITION, position, 0);
-
- /*
- * Feature in Photon. On a single-line text, the selection is
- * not cleared when setting the cursor position. The fix is to
- * set the selection start and end values to the specified
- * position.
- */
- if ((style & SWT.SINGLE) != 0) {
- int [] selection = {position};
- OS.PtTextSetSelection (handle, selection, selection);
- }
-}
-
+public void setSelection (int position) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_CURSOR_POSITION, position, 0);
+
+ /*
+ * Feature in Photon. On a single-line text, the selection is
+ * not cleared when setting the cursor position. The fix is to
+ * set the selection start and end values to the specified
+ * position.
+ */
+ if ((style & SWT.SINGLE) != 0) {
+ int [] selection = {position};
+ OS.PtTextSetSelection (handle, selection, selection);
+ }
+}
+
/**
* Sets the selection.
* <p>
@@ -1221,12 +1221,12 @@ public void setSelection (int position) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (Point selection) {
- checkWidget();
- if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
- setSelection (selection.x, selection.y);
-}
-
+public void setSelection (Point selection) {
+ checkWidget();
+ if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setSelection (selection.x, selection.y);
+}
+
/**
* Sets the selection.
* <p>
@@ -1251,21 +1251,21 @@ public void setSelection (Point selection) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (int start, int end) {
- checkWidget();
- OS.PtTextSetSelection (handle, new int [] {start}, new int [] {end});
-
- /*
- * Feature in Photon. On a multi-line text, the caret position
- * is not changed with the selection start and end values are
- * the same. The fix is to detect this case and change the
- * cursor position.
- */
- if ((style & SWT.MULTI) != 0 && start == end) {
- OS.PtSetResource (handle, OS.Pt_ARG_CURSOR_POSITION, start, 0);
- }
-}
-
+public void setSelection (int start, int end) {
+ checkWidget();
+ OS.PtTextSetSelection (handle, new int [] {start}, new int [] {end});
+
+ /*
+ * Feature in Photon. On a multi-line text, the caret position
+ * is not changed with the selection start and end values are
+ * the same. The fix is to detect this case and change the
+ * cursor position.
+ */
+ if ((style & SWT.MULTI) != 0 && start == end) {
+ OS.PtSetResource (handle, OS.Pt_ARG_CURSOR_POSITION, start, 0);
+ }
+}
+
/**
* Sets the number of tabs.
* <p>
@@ -1282,21 +1282,21 @@ public void setSelection (int start, int end) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setTabs (int tabs) {
- checkWidget();
- if (tabs < 0) return;
- setTabStops (this.tabs = tabs);
-}
-
-void setTabStops (int tabs) {
- if ((style & SWT.SINGLE) != 0) return;
- int tabsWidth = getTabWidth (tabs);
- int ptr = OS.malloc (4);
- OS.memmove (ptr, new int [] {tabsWidth}, 4);
- OS.PtSetResource (handle, OS.Pt_ARG_MULTITEXT_TABS, ptr, 1);
- OS.free (ptr);
-}
-
+public void setTabs (int tabs) {
+ checkWidget();
+ if (tabs < 0) return;
+ setTabStops (this.tabs = tabs);
+}
+
+void setTabStops (int tabs) {
+ if ((style & SWT.SINGLE) != 0) return;
+ int tabsWidth = getTabWidth (tabs);
+ int ptr = OS.malloc (4);
+ OS.memmove (ptr, new int [] {tabsWidth}, 4);
+ OS.PtSetResource (handle, OS.Pt_ARG_MULTITEXT_TABS, ptr, 1);
+ OS.free (ptr);
+}
+
/**
* Sets the contents of the receiver to the given string. If the receiver has style
* SINGLE and the argument contains multiple lines of text, the result of this
@@ -1312,16 +1312,16 @@ void setTabStops (int tabs) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setText (String string) {
- checkWidget();
- 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.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, ptr, 0);
- OS.free (ptr);
-}
-
+public void setText (String string) {
+ checkWidget();
+ 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.PtSetResource (handle, OS.Pt_ARG_TEXT_STRING, ptr, 0);
+ OS.free (ptr);
+}
+
/**
* Sets the maximum number of characters that the receiver
* is capable of holding to be the argument.
@@ -1342,12 +1342,12 @@ public void setText (String string) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setTextLimit (int limit) {
- checkWidget();
- if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
- OS.PtSetResource (handle, OS.Pt_ARG_MAX_LENGTH, limit, 0);
-}
-
+public void setTextLimit (int limit) {
+ checkWidget();
+ if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
+ OS.PtSetResource (handle, OS.Pt_ARG_MAX_LENGTH, limit, 0);
+}
+
/**
* Sets the zero-relative index of the line which is currently
* at the top of the receiver. This index can change when lines
@@ -1360,12 +1360,12 @@ public void setTextLimit (int limit) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setTopIndex (int index) {
- checkWidget();
- if ((style & SWT.SINGLE) != 0) return;
- OS.PtSetResource (handle, OS.Pt_ARG_MULTITEXT_TOP_LINE, index + 1, 0);
-}
-
+public void setTopIndex (int index) {
+ checkWidget();
+ if ((style & SWT.SINGLE) != 0) return;
+ OS.PtSetResource (handle, OS.Pt_ARG_MULTITEXT_TOP_LINE, index + 1, 0);
+}
+
/**
* Shows the selection.
* <p>
@@ -1382,37 +1382,37 @@ public void setTopIndex (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void showSelection () {
- checkWidget();
- //NOT DONE - NOT NEEDED
-}
-
-int traversalCode (int key_sym, PhKeyEvent_t ke) {
- int code = super.traversalCode (key_sym, ke);
- if ((style & SWT.READ_ONLY) != 0) return code;
- if ((style & SWT.MULTI) != 0) {
- code &= ~SWT.TRAVERSE_RETURN;
- if (key_sym == OS.Pk_Tab && ke != null) {
- if ((ke.key_mods & OS.Pk_KM_Ctrl) == 0) {
- code &= ~(SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS);
- }
- }
- }
- return code;
-}
-
-boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
- boolean translated = super.translateTraversal (key_sym, phEvent);
- if ((style & SWT.SINGLE) != 0 && !translated && key_sym == OS.Pk_Return) {
- postEvent (SWT.DefaultSelection);
- return false;
- }
- return translated;
-}
-
-int widgetClass () {
- if ((style & SWT.SINGLE) != 0) return OS.PtText ();
- return OS.PtMultiText ();
-}
-
-}
+public void showSelection () {
+ checkWidget();
+ //NOT DONE - NOT NEEDED
+}
+
+int traversalCode (int key_sym, PhKeyEvent_t ke) {
+ int code = super.traversalCode (key_sym, ke);
+ if ((style & SWT.READ_ONLY) != 0) return code;
+ if ((style & SWT.MULTI) != 0) {
+ code &= ~SWT.TRAVERSE_RETURN;
+ if (key_sym == OS.Pk_Tab && ke != null) {
+ if ((ke.key_mods & OS.Pk_KM_Ctrl) == 0) {
+ code &= ~(SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS);
+ }
+ }
+ }
+ return code;
+}
+
+boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
+ boolean translated = super.translateTraversal (key_sym, phEvent);
+ if ((style & SWT.SINGLE) != 0 && !translated && key_sym == OS.Pk_Return) {
+ postEvent (SWT.DefaultSelection);
+ return false;
+ }
+ return translated;
+}
+
+int widgetClass () {
+ if ((style & SWT.SINGLE) != 0) return OS.PtText ();
+ return OS.PtMultiText ();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java
index 5ca0f9ee5a..9e2df2bba7 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java
@@ -1,16 +1,16 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
/**
* Instances of this class support the layout of selectable
* tool bar items.
@@ -34,12 +34,12 @@ import org.eclipse.swt.graphics.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class ToolBar extends Composite {
- int parentingHandle;
- int itemCount;
- ToolItem [] items;
- ToolItem lastFocus;
-
+public class ToolBar extends Composite {
+ int parentingHandle;
+ int itemCount;
+ ToolItem [] items;
+ ToolItem lastFocus;
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -72,128 +72,128 @@ public class ToolBar extends Composite {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public ToolBar (Composite parent, int style) {
- super (parent, checkStyle (style));
-
- /*
- * Ensure that either of HORIZONTAL or VERTICAL is set.
- * NOTE: HORIZONTAL and VERTICAL have the same values
- * as H_SCROLL and V_SCROLL so it is necessary to first
- * clear these bits to avoid scroll bars and then reset
- * the bits using the original style supplied by the
- * programmer.
- */
- if ((style & SWT.VERTICAL) != 0) {
- this.style |= SWT.VERTICAL;
- } else {
- this.style |= SWT.HORIZONTAL;
- }
- int orientation = (style & SWT.VERTICAL) == 0 ? OS.Pt_HORIZONTAL : OS.Pt_VERTICAL;
- OS.PtSetResource (handle, OS.Pt_ARG_ORIENTATION, orientation, 0);
-}
-
-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) {
- checkWidget();
- if (layout != null) {
- return super.computeSize (wHint, hHint, changed);
- }
- 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) {
- state |= HANDLE;
- Display display = getDisplay ();
- int parentHandle = parent.parentingHandle ();
- int [] args = {
- OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
- };
- parentingHandle = OS.PtCreateWidget (OS.PtContainer (), parentHandle, args.length / 3, args);
- if (parentingHandle == 0) error (SWT.ERROR_NO_HANDLES);
- args = new int [] {
- OS.Pt_ARG_FLAGS, (style & SWT.NO_FOCUS) != 0 ? 0 : OS.Pt_GETS_FOCUS, OS.Pt_GETS_FOCUS,
- OS.Pt_ARG_FLAGS, hasBorder () ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
- OS.Pt_ARG_TOOLBAR_FLAGS, 0, OS.Pt_TOOLBAR_DRAGGABLE | OS.Pt_TOOLBAR_END_SEPARATOR,
- OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
- };
- handle = OS.PtCreateWidget (display.PtToolbar, parentingHandle, args.length / 3, args);
- if ((style & SWT.FLAT) != 0) {
- OS.PtSetResource (handle, OS.Pt_ARG_BASIC_FLAGS, OS.Pt_FLAT_FILL, OS.Pt_FLAT_FILL);
- }
- 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 deregister () {
- super.deregister ();
- if (parentingHandle != 0) WidgetTable.remove (parentingHandle);
-}
-
-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 boolean forceFocus () {
- checkWidget();
- if (lastFocus != null && lastFocus.setFocus ()) return true;
- for (int i = 0; i < itemCount; i++) {
- ToolItem item = items [i];
- if (item.setFocus ()) return true;
- }
- return super.forceFocus ();
-}
-
+public ToolBar (Composite parent, int style) {
+ super (parent, checkStyle (style));
+
+ /*
+ * Ensure that either of HORIZONTAL or VERTICAL is set.
+ * NOTE: HORIZONTAL and VERTICAL have the same values
+ * as H_SCROLL and V_SCROLL so it is necessary to first
+ * clear these bits to avoid scroll bars and then reset
+ * the bits using the original style supplied by the
+ * programmer.
+ */
+ if ((style & SWT.VERTICAL) != 0) {
+ this.style |= SWT.VERTICAL;
+ } else {
+ this.style |= SWT.HORIZONTAL;
+ }
+ int orientation = (style & SWT.VERTICAL) == 0 ? OS.Pt_HORIZONTAL : OS.Pt_VERTICAL;
+ OS.PtSetResource (handle, OS.Pt_ARG_ORIENTATION, orientation, 0);
+}
+
+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) {
+ checkWidget();
+ if (layout != null) {
+ return super.computeSize (wHint, hHint, changed);
+ }
+ 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) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int parentHandle = parent.parentingHandle ();
+ int [] args = {
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ parentingHandle = OS.PtCreateWidget (OS.PtContainer (), parentHandle, args.length / 3, args);
+ if (parentingHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ args = new int [] {
+ OS.Pt_ARG_FLAGS, (style & SWT.NO_FOCUS) != 0 ? 0 : OS.Pt_GETS_FOCUS, OS.Pt_GETS_FOCUS,
+ OS.Pt_ARG_FLAGS, hasBorder () ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
+ OS.Pt_ARG_TOOLBAR_FLAGS, 0, OS.Pt_TOOLBAR_DRAGGABLE | OS.Pt_TOOLBAR_END_SEPARATOR,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (display.PtToolbar, parentingHandle, args.length / 3, args);
+ if ((style & SWT.FLAT) != 0) {
+ OS.PtSetResource (handle, OS.Pt_ARG_BASIC_FLAGS, OS.Pt_FLAT_FILL, OS.Pt_FLAT_FILL);
+ }
+ 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 deregister () {
+ super.deregister ();
+ if (parentingHandle != 0) WidgetTable.remove (parentingHandle);
+}
+
+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 boolean forceFocus () {
+ checkWidget();
+ if (lastFocus != null && lastFocus.setFocus ()) return true;
+ for (int i = 0; i < itemCount; i++) {
+ ToolItem item = items [i];
+ if (item.setFocus ()) return true;
+ }
+ return super.forceFocus ();
+}
+
/**
* Returns the number of items contained in the receiver.
*
@@ -204,11 +204,11 @@ public boolean forceFocus () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getItemCount () {
- checkWidget();
- return itemCount;
-}
-
+public int getItemCount () {
+ checkWidget();
+ return itemCount;
+}
+
/**
* Returns an array of <code>TabItem</code>s which are the items
* in the receiver.
@@ -225,13 +225,13 @@ public int getItemCount () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public ToolItem [] getItems () {
- checkWidget();
- ToolItem [] result = new ToolItem [itemCount];
- System.arraycopy (items, 0, result, 0, itemCount);
- return result;
-}
-
+public ToolItem [] getItems () {
+ checkWidget();
+ ToolItem [] result = new ToolItem [itemCount];
+ System.arraycopy (items, 0, result, 0, itemCount);
+ return result;
+}
+
/**
* Returns the item at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
@@ -247,13 +247,13 @@ public ToolItem [] getItems () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public ToolItem getItem (int index) {
- checkWidget();
- int count = itemCount;
- if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
- return items [index];
-}
-
+public ToolItem getItem (int index) {
+ checkWidget();
+ int count = itemCount;
+ if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
+ return items [index];
+}
+
/**
* Returns the item at the given point in the receiver
* or null if no such item exists. The point is in the
@@ -270,15 +270,15 @@ public ToolItem getItem (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public ToolItem getItem (Point pt) {
- checkWidget();
- for (int i=0; i<itemCount; i++) {
- Rectangle rect = items [i].getBounds ();
- if (rect.contains (pt)) return items [i];
- }
- return null;
-}
-
+public ToolItem getItem (Point pt) {
+ checkWidget();
+ for (int i=0; i<itemCount; i++) {
+ Rectangle rect = items [i].getBounds ();
+ if (rect.contains (pt)) return items [i];
+ }
+ return null;
+}
+
/**
* Returns the number of rows in the receiver. When
* the receiver has the <code>WRAP</code> style, the
@@ -292,19 +292,19 @@ public ToolItem getItem (Point pt) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getRowCount () {
- checkWidget();
- return 1;
-}
-
-boolean hasFocus () {
- for (int i=0; i<itemCount; i++) {
- ToolItem item = items [i];
- if (item.hasFocus ()) return true;
- }
- return super.hasFocus();
-}
-
+public int getRowCount () {
+ checkWidget();
+ return 1;
+}
+
+boolean hasFocus () {
+ for (int i=0; i<itemCount; i++) {
+ ToolItem item = items [i];
+ if (item.hasFocus ()) return true;
+ }
+ return super.hasFocus();
+}
+
/**
* Searches the receiver's list starting at the first item
* (index 0) until an item is found that is equal to the
@@ -323,130 +323,130 @@ boolean hasFocus () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int indexOf (ToolItem item) {
- checkWidget();
- if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- int count = itemCount;
- for (int i=0; i<count; i++) {
- if (items [i] == item) return i;
- }
- return -1;
-}
-
-void moveToBack (int child) {
- OS.PtWidgetInsert (child, handle, 0);
-}
-
-int parentingHandle () {
- return parentingHandle;
-}
-
-int Ph_EV_BOUNDARY (int widget, int info) {
- if (info == 0) return OS.Pt_END;
- PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
- OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
- if (cbinfo.event == 0) return OS.Pt_END;
- PhEvent_t ev = new PhEvent_t ();
- OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
- switch ((int) ev.subtype) {
- case OS.Ph_EV_PTR_ENTER_FROM_CHILD:
- case OS.Ph_EV_PTR_LEAVE_TO_CHILD:
- return OS.Pt_CONTINUE;
- }
- return super.Ph_EV_BOUNDARY (widget, info);
-}
-
-void register () {
- super.register ();
- if (parentingHandle != 0) WidgetTable.put (parentingHandle, this);
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- parentingHandle = 0;
-}
-
-void releaseWidget () {
- for (int i=0; i<items.length; i++) {
- ToolItem item = items [i];
- if (item != null && !item.isDisposed ()) item.releaseResources ();
- }
- items = null;
- super.releaseWidget ();
-}
-
-void setBackgroundPixel (int pixel) {
- super.setBackgroundPixel (pixel);
- for (int i = 0; i < itemCount; i++) {
- ToolItem item = items[i];
- item.setBackgroundPixel (pixel);
- }
-}
-
-int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
- int result = super.setBounds (x, y, width, height, move, resize, events);
- if ((result & RESIZED) != 0) {
- int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
- OS.PtGetResources (parentingHandle, args.length / 3, args);
- OS.PtSetResources (handle, args.length / 3, args);
- }
- return result;
-}
-
-void setFont (int font) {
- super.setFont (font);
- for (int i = 0; i < itemCount; i++) {
- ToolItem item = items[i];
- item.setFont (font);
- }
-}
-
-void setForegroundPixel (int pixel) {
- super.setForegroundPixel (pixel);
+public int indexOf (ToolItem item) {
+ checkWidget();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (item.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ int count = itemCount;
+ for (int i=0; i<count; i++) {
+ if (items [i] == item) return i;
+ }
+ return -1;
+}
+
+void moveToBack (int child) {
+ OS.PtWidgetInsert (child, handle, 0);
+}
+
+int parentingHandle () {
+ return parentingHandle;
+}
+
+int Ph_EV_BOUNDARY (int widget, int info) {
+ if (info == 0) return OS.Pt_END;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.event == 0) return OS.Pt_END;
+ PhEvent_t ev = new PhEvent_t ();
+ OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
+ switch ((int) ev.subtype) {
+ case OS.Ph_EV_PTR_ENTER_FROM_CHILD:
+ case OS.Ph_EV_PTR_LEAVE_TO_CHILD:
+ return OS.Pt_CONTINUE;
+ }
+ return super.Ph_EV_BOUNDARY (widget, info);
+}
+
+void register () {
+ super.register ();
+ if (parentingHandle != 0) WidgetTable.put (parentingHandle, this);
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ parentingHandle = 0;
+}
+
+void releaseWidget () {
+ for (int i=0; i<items.length; i++) {
+ ToolItem item = items [i];
+ if (item != null && !item.isDisposed ()) item.releaseResources ();
+ }
+ items = null;
+ super.releaseWidget ();
+}
+
+void setBackgroundPixel (int pixel) {
+ super.setBackgroundPixel (pixel);
+ for (int i = 0; i < itemCount; i++) {
+ ToolItem item = items[i];
+ item.setBackgroundPixel (pixel);
+ }
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize, boolean events) {
+ int result = super.setBounds (x, y, width, height, move, resize, events);
+ if ((result & RESIZED) != 0) {
+ int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (parentingHandle, args.length / 3, args);
+ OS.PtSetResources (handle, args.length / 3, args);
+ }
+ return result;
+}
+
+void setFont (int font) {
+ super.setFont (font);
+ for (int i = 0; i < itemCount; i++) {
+ ToolItem item = items[i];
+ item.setFont (font);
+ }
+}
+
+void setForegroundPixel (int pixel) {
+ super.setForegroundPixel (pixel);
for (int i = 0; i < itemCount; i++) {
ToolItem item = items[i];
item.setForegroundPixel (pixel);
- }
-}
-
-int topHandle () {
- return parentingHandle;
-}
-
-boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
- boolean result = super.translateTraversal (key_sym, phEvent);
- if (result) return result;
- boolean next = false;
- switch (key_sym) {
- case OS.Pk_Up:
- case OS.Pk_Left: next = false; break;
- case OS.Pk_Down:
- case OS.Pk_Right: next = true; break;
- default: return false;
- }
- int length = itemCount;
- int index = 0;
- while (index < length) {
- if (items [index].hasFocus ()) break;
- index++;
- }
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in focus in
- * or out events. Ensure that a disposed widget is
- * not accessed.
- */
- int start = index, offset = (next) ? 1 : -1;
- while ((index = (index + offset + length) % length) != start) {
- ToolItem item = items [index];
- if (item.setFocus ()) return false;
- }
- return false;
-}
-
-int widgetClass () {
- return OS.PtToolbar ();
-}
-
-}
+ }
+}
+
+int topHandle () {
+ return parentingHandle;
+}
+
+boolean translateTraversal (int key_sym, PhKeyEvent_t phEvent) {
+ boolean result = super.translateTraversal (key_sym, phEvent);
+ if (result) return result;
+ boolean next = false;
+ switch (key_sym) {
+ case OS.Pk_Up:
+ case OS.Pk_Left: next = false; break;
+ case OS.Pk_Down:
+ case OS.Pk_Right: next = true; break;
+ default: return false;
+ }
+ int length = itemCount;
+ int index = 0;
+ while (index < length) {
+ if (items [index].hasFocus ()) break;
+ index++;
+ }
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in focus in
+ * or out events. Ensure that a disposed widget is
+ * not accessed.
+ */
+ int start = index, offset = (next) ? 1 : -1;
+ while ((index = (index + offset + length) % length) != start) {
+ ToolItem item = items [index];
+ if (item.setFocus ()) return false;
+ }
+ return false;
+}
+
+int widgetClass () {
+ return OS.PtToolbar ();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java
index f5bbacca2a..0d204e2885 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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.*;
+
/**
* Instances of this class represent a selectable user interface object
* that represents a button in a tool bar.
@@ -29,14 +29,14 @@ import org.eclipse.swt.events.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class ToolItem extends Item {
- ToolBar parent;
- Control control;
- String toolTipText;
- int toolTipHandle;
- Image hotImage, disabledImage;
- int button, arrow;
-
+public class ToolItem extends Item {
+ ToolBar parent;
+ Control control;
+ String toolTipText;
+ int toolTipHandle;
+ Image hotImage, disabledImage;
+ int button, arrow;
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>ToolBar</code>) and a style value
@@ -71,10 +71,10 @@ public class ToolItem extends Item {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public ToolItem (ToolBar parent, int style) {
- this(parent, style, parent.getItemCount ());
-}
-
+public ToolItem (ToolBar parent, int style) {
+ this(parent, style, parent.getItemCount ());
+}
+
/**
* Constructs a new instance of this class given its parent
* (which must be a <code>ToolBar</code>), a style value
@@ -110,12 +110,12 @@ public ToolItem (ToolBar parent, int style) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public ToolItem (ToolBar parent, int style, int index) {
- super (parent, checkStyle (style));
- this.parent = parent;
- parent.createItem (this, index);
-}
-
+public ToolItem (ToolBar parent, int style, int index) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ parent.createItem (this, index);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the control is selected, by sending
@@ -141,134 +141,134 @@ public ToolItem (ToolBar parent, int style, int index) {
* @see #removeSelectionListener
* @see SelectionEvent
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- 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);
-}
-
-int createArrowImage () {
- short width = 5;
- short height = 4;
- int image = OS.PhCreateImage(null, width, height, OS.Pg_IMAGE_DIRECT_888, 0, 0, 0);
- if (image == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- PhDim_t dim = new PhDim_t();
- dim.w = width;
- dim.h = height;
- int mc = OS.PmMemCreateMC(image, dim, new PhPoint_t());
- if (mc == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- int prevContext = OS.PmMemStart(mc);
- OS.PgSetFillColor(0xFFFFFF);
- OS.PgDrawIRect(0, 0, width, height, OS.Pg_DRAW_FILL);
- OS.PgSetStrokeColor(0x000000);
- OS.PgSetFillColor(0x000000);
- short [] points = {(short)0, (short)1, (short)2, (short)3, (short)4, (short)1};
- OS.PgDrawPolygon(points, points.length / 2, new PhPoint_t(), OS.Pg_DRAW_FILL | OS.Pg_DRAW_STROKE | OS.Pg_CLOSED);
- OS.PmMemFlush(mc, image);
- OS.PmMemStop(mc);
- OS.PmMemReleaseMC(mc);
- OS.PhDCSetCurrent(prevContext);
- OS.PhMakeTransBitmap(image, 0xFFFFFF);
- return image;
-}
-
-void createHandle (int index) {
- state |= HANDLE;
- int count = parent.getItemCount();
- if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
- int parentHandle = parent.handle;
-
- 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);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- } else if ((style & SWT.DROP_DOWN) != 0) {
- int [] args = {
- OS.Pt_ARG_GROUP_ORIENTATION, OS.Pt_GROUP_HORIZONTAL, 0,
- OS.Pt_ARG_GROUP_FLAGS, OS.Pt_GROUP_EQUAL_SIZE_VERTICAL, OS.Pt_GROUP_EQUAL_SIZE_VERTICAL,
- };
- handle = OS.PtCreateWidget (OS.PtGroup (), parentHandle, args.length / 3, args);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- boolean rightAligned = (parent.style & SWT.RIGHT) != 0;
- args = new int [] {
- OS.Pt_ARG_LABEL_TYPE, 0, 0,
- OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
- OS.Pt_ARG_BALLOON_POSITION, rightAligned ? OS.Pt_BALLOON_RIGHT : OS.Pt_BALLOON_BOTTOM, 0,
- OS.Pt_ARG_BASIC_FLAGS, 0, OS.Pt_RIGHT_ETCH | OS.Pt_RIGHT_OUTLINE,
- };
- button = OS.PtCreateWidget (OS.PtButton (), handle, args.length / 3, args);
- if (button == 0) error (SWT.ERROR_NO_HANDLES);
- int arrowImage = createArrowImage ();
- args = new int [] {
- OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
- OS.Pt_ARG_LABEL_IMAGE, arrowImage, 0,
- OS.Pt_ARG_LABEL_TYPE, OS.Pt_IMAGE, 0,
- OS.Pt_ARG_MARGIN_WIDTH, 1, 0,
- OS.Pt_ARG_BASIC_FLAGS, 0, OS.Pt_LEFT_ETCH | OS.Pt_LEFT_OUTLINE,
- };
- arrow = OS.PtCreateWidget (OS.PtButton (), handle, args.length / 3, args);
- OS.free (arrowImage);
- if (arrow == 0) error (SWT.ERROR_NO_HANDLES);
- } else {
- boolean rightAligned = (parent.style & SWT.RIGHT) != 0;
- boolean toggle = (style & (SWT.CHECK | SWT.RADIO)) != 0;
- int [] args = {
- OS.Pt_ARG_LABEL_TYPE, 0, 0,
- OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
- 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 = button = 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 ());
- }
-}
-
-void createWidget (int index) {
- super.createWidget (index);
- setDefaultFont ();
-}
-
-void deregister () {
- super.deregister ();
- if ((style & SWT.DROP_DOWN) != 0) {
- WidgetTable.remove (button);
- WidgetTable.remove (arrow);
- }
-}
-
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ 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);
+}
+
+int createArrowImage () {
+ short width = 5;
+ short height = 4;
+ int image = OS.PhCreateImage(null, width, height, OS.Pg_IMAGE_DIRECT_888, 0, 0, 0);
+ if (image == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ PhDim_t dim = new PhDim_t();
+ dim.w = width;
+ dim.h = height;
+ int mc = OS.PmMemCreateMC(image, dim, new PhPoint_t());
+ if (mc == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ int prevContext = OS.PmMemStart(mc);
+ OS.PgSetFillColor(0xFFFFFF);
+ OS.PgDrawIRect(0, 0, width, height, OS.Pg_DRAW_FILL);
+ OS.PgSetStrokeColor(0x000000);
+ OS.PgSetFillColor(0x000000);
+ short [] points = {(short)0, (short)1, (short)2, (short)3, (short)4, (short)1};
+ OS.PgDrawPolygon(points, points.length / 2, new PhPoint_t(), OS.Pg_DRAW_FILL | OS.Pg_DRAW_STROKE | OS.Pg_CLOSED);
+ OS.PmMemFlush(mc, image);
+ OS.PmMemStop(mc);
+ OS.PmMemReleaseMC(mc);
+ OS.PhDCSetCurrent(prevContext);
+ OS.PhMakeTransBitmap(image, 0xFFFFFF);
+ return image;
+}
+
+void createHandle (int index) {
+ state |= HANDLE;
+ int count = parent.getItemCount();
+ if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
+ int parentHandle = parent.handle;
+
+ 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);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ } else if ((style & SWT.DROP_DOWN) != 0) {
+ int [] args = {
+ OS.Pt_ARG_GROUP_ORIENTATION, OS.Pt_GROUP_HORIZONTAL, 0,
+ OS.Pt_ARG_GROUP_FLAGS, OS.Pt_GROUP_EQUAL_SIZE_VERTICAL, OS.Pt_GROUP_EQUAL_SIZE_VERTICAL,
+ };
+ handle = OS.PtCreateWidget (OS.PtGroup (), parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ boolean rightAligned = (parent.style & SWT.RIGHT) != 0;
+ args = new int [] {
+ OS.Pt_ARG_LABEL_TYPE, 0, 0,
+ OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
+ OS.Pt_ARG_BALLOON_POSITION, rightAligned ? OS.Pt_BALLOON_RIGHT : OS.Pt_BALLOON_BOTTOM, 0,
+ OS.Pt_ARG_BASIC_FLAGS, 0, OS.Pt_RIGHT_ETCH | OS.Pt_RIGHT_OUTLINE,
+ };
+ button = OS.PtCreateWidget (OS.PtButton (), handle, args.length / 3, args);
+ if (button == 0) error (SWT.ERROR_NO_HANDLES);
+ int arrowImage = createArrowImage ();
+ args = new int [] {
+ OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
+ OS.Pt_ARG_LABEL_IMAGE, arrowImage, 0,
+ OS.Pt_ARG_LABEL_TYPE, OS.Pt_IMAGE, 0,
+ OS.Pt_ARG_MARGIN_WIDTH, 1, 0,
+ OS.Pt_ARG_BASIC_FLAGS, 0, OS.Pt_LEFT_ETCH | OS.Pt_LEFT_OUTLINE,
+ };
+ arrow = OS.PtCreateWidget (OS.PtButton (), handle, args.length / 3, args);
+ OS.free (arrowImage);
+ if (arrow == 0) error (SWT.ERROR_NO_HANDLES);
+ } else {
+ boolean rightAligned = (parent.style & SWT.RIGHT) != 0;
+ boolean toggle = (style & (SWT.CHECK | SWT.RADIO)) != 0;
+ int [] args = {
+ OS.Pt_ARG_LABEL_TYPE, 0, 0,
+ OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
+ 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 = button = 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 ());
+ }
+}
+
+void createWidget (int index) {
+ super.createWidget (index);
+ setDefaultFont ();
+}
+
+void deregister () {
+ super.deregister ();
+ if ((style & SWT.DROP_DOWN) != 0) {
+ WidgetTable.remove (button);
+ WidgetTable.remove (arrow);
+ }
+}
+
/**
* Returns a rectangle describing the receiver's size and location
* relative to its parent.
@@ -280,14 +280,14 @@ void deregister () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Rectangle getBounds () {
- checkWidget();
- 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 Rectangle getBounds () {
+ checkWidget();
+ 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);
+}
+
/**
* Returns the control that is used to fill the bounds of
* the item when the items is a <code>SEPARATOR</code>.
@@ -299,11 +299,11 @@ public Rectangle getBounds () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Control getControl () {
- checkWidget();
- return control;
-}
-
+public Control getControl () {
+ checkWidget();
+ return control;
+}
+
/**
* Returns the receiver's disabled image if it has one, or null
* if it does not.
@@ -318,17 +318,17 @@ public Control getControl () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Image getDisabledImage () {
- checkWidget();
- return disabledImage;
-}
-
-public Display getDisplay () {
- ToolBar parent = this.parent;
- if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
- return parent.getDisplay ();
-}
-
+public Image getDisabledImage () {
+ checkWidget();
+ return disabledImage;
+}
+
+public Display getDisplay () {
+ ToolBar parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
/**
* Returns <code>true</code> if the receiver is enabled, and
* <code>false</code> otherwise.
@@ -344,12 +344,12 @@ public Display getDisplay () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getEnabled () {
- checkWidget ();
- int topHandle = topHandle ();
- return (OS.PtWidgetFlags (topHandle) & OS.Pt_BLOCKED) == 0;
-}
-
+public boolean getEnabled () {
+ checkWidget ();
+ int topHandle = topHandle ();
+ return (OS.PtWidgetFlags (topHandle) & OS.Pt_BLOCKED) == 0;
+}
+
/**
* Returns the receiver's hot image if it has one, or null
* if it does not.
@@ -364,11 +364,11 @@ public boolean getEnabled () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public Image getHotImage () {
- checkWidget();
- return hotImage;
-}
-
+public Image getHotImage () {
+ checkWidget();
+ return hotImage;
+}
+
/**
* Returns the receiver's parent, which must be a <code>ToolBar</code>.
*
@@ -379,11 +379,11 @@ public Image getHotImage () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public ToolBar getParent () {
- checkWidget();
- return parent;
-}
-
+public ToolBar getParent () {
+ checkWidget();
+ return parent;
+}
+
/**
* Returns <code>true</code> if the receiver is selected,
* and false otherwise.
@@ -401,12 +401,12 @@ public ToolBar getParent () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getSelection () {
- checkWidget();
- if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
- return (OS.PtWidgetFlags (handle) & OS.Pt_SET) != 0;
-}
-
+public boolean getSelection () {
+ checkWidget();
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
+ return (OS.PtWidgetFlags (handle) & OS.Pt_SET) != 0;
+}
+
/**
* Returns the receiver's tool tip text, or null if it has not been set.
*
@@ -417,11 +417,11 @@ public boolean getSelection () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public String getToolTipText () {
- checkWidget();
- return toolTipText;
-}
-
+public String getToolTipText () {
+ checkWidget();
+ return toolTipText;
+}
+
/**
* Gets the width of the receiver.
*
@@ -432,130 +432,130 @@ public String getToolTipText () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getWidth () {
- checkWidget();
- int topHandle = topHandle ();
- int [] args = {OS.Pt_ARG_WIDTH, 0, 0};
- OS.PtGetResources (topHandle, args.length / 3, args);
- return args [1];
-}
-
-boolean hasFocus () {
- return OS.PtIsFocused (handle) != 0;
-}
-
-void hookEvents () {
- super.hookEvents ();
- if ((style & SWT.SEPARATOR) != 0) return;
- int windowProc = getDisplay ().windowProc;
- OS.PtAddEventHandler (handle, OS.Ph_EV_BOUNDARY, windowProc, OS.Ph_EV_BOUNDARY);
- OS.PtAddCallback (button, OS.Pt_CB_ACTIVATE, windowProc, OS.Pt_CB_ACTIVATE);
- if ((style & SWT.DROP_DOWN) != 0) {
- OS.PtAddCallback (arrow, OS.Pt_CB_ACTIVATE, windowProc, OS.Pt_CB_ACTIVATE);
- }
- OS.PtAddCallback (handle, OS.Pt_CB_LOST_FOCUS, windowProc, OS.Pt_CB_LOST_FOCUS);
-}
-
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * otherwise. A disabled control is typically not selectable from the
- * user interface and draws with an inactive or "grayed" look.
- *
- * @return the receiver's enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
+public int getWidth () {
+ checkWidget();
+ int topHandle = topHandle ();
+ int [] args = {OS.Pt_ARG_WIDTH, 0, 0};
+ OS.PtGetResources (topHandle, args.length / 3, args);
+ return args [1];
+}
+
+boolean hasFocus () {
+ return OS.PtIsFocused (handle) != 0;
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ if ((style & SWT.SEPARATOR) != 0) return;
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddEventHandler (handle, OS.Ph_EV_BOUNDARY, windowProc, OS.Ph_EV_BOUNDARY);
+ OS.PtAddCallback (button, OS.Pt_CB_ACTIVATE, windowProc, OS.Pt_CB_ACTIVATE);
+ if ((style & SWT.DROP_DOWN) != 0) {
+ OS.PtAddCallback (arrow, OS.Pt_CB_ACTIVATE, windowProc, OS.Pt_CB_ACTIVATE);
+ }
+ OS.PtAddCallback (handle, OS.Pt_CB_LOST_FOCUS, windowProc, OS.Pt_CB_LOST_FOCUS);
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getEnabled
*/
-public boolean isEnabled () {
- checkWidget();
- return getEnabled () && parent.isEnabled ();
-}
-
-int Ph_EV_BOUNDARY (int widget, int info) {
- if (info == 0) return OS.Pt_END;
- PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
- OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
- if (cbinfo.event == 0) return OS.Pt_END;
- PhEvent_t ev = new PhEvent_t ();
- OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
- switch ((int) ev.subtype) {
- case OS.Ph_EV_PTR_STEADY:
- int [] args = {OS.Pt_ARG_TEXT_FONT, 0, 0};
- OS.PtGetResources (button, args.length / 3, args);
- int length = OS.strlen (args [1]);
- byte [] font = new byte [length + 1];
- OS.memmove (font, args [1], length);
- destroyToolTip (toolTipHandle);
- toolTipHandle = createToolTip (toolTipText, button, font);
- break;
- case OS.Ph_EV_PTR_UNSTEADY:
- destroyToolTip (toolTipHandle);
- toolTipHandle = 0;
- break;
- }
- return OS.Pt_END;
-}
-
-int Pt_CB_ACTIVATE (int widget, int info) {
- Event event = new Event ();
- if (widget == arrow) {
- event.detail = SWT.ARROW;
- int topHandle = topHandle ();
- PhArea_t area = new PhArea_t ();
- OS.PtWidgetArea (topHandle, area);
- event.x = area.pos_x;
- event.y = area.pos_y + area.size_h;
- } else {
- if ((style & SWT.RADIO) != 0) {
- if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
- selectRadio ();
- }
- }
- }
- postEvent (SWT.Selection, event);
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_LOST_FOCUS (int widget, int info) {
- parent.lastFocus = this;
- return OS.Pt_CONTINUE;
-}
-
-void register () {
- super.register ();
- if ((style & SWT.DROP_DOWN) != 0) {
- WidgetTable.put (button, this);
- WidgetTable.put (arrow, this);
- }
-}
-
-void releaseChild () {
- super.releaseChild ();
- parent.destroyItem (this);
-}
-
-void releaseHandle () {
- super.releaseHandle ();
- arrow = button = 0;
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- if (toolTipHandle != 0) destroyToolTip (toolTipHandle);
- if (parent.lastFocus == this) parent.lastFocus = null;
- toolTipHandle = 0;
- parent = null;
- control = null;
- hotImage = null;
- disabledImage = null;
- toolTipText = null;
-}
-
+public boolean isEnabled () {
+ checkWidget();
+ return getEnabled () && parent.isEnabled ();
+}
+
+int Ph_EV_BOUNDARY (int widget, int info) {
+ if (info == 0) return OS.Pt_END;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.event == 0) return OS.Pt_END;
+ PhEvent_t ev = new PhEvent_t ();
+ OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
+ switch ((int) ev.subtype) {
+ case OS.Ph_EV_PTR_STEADY:
+ int [] args = {OS.Pt_ARG_TEXT_FONT, 0, 0};
+ OS.PtGetResources (button, args.length / 3, args);
+ int length = OS.strlen (args [1]);
+ byte [] font = new byte [length + 1];
+ OS.memmove (font, args [1], length);
+ destroyToolTip (toolTipHandle);
+ toolTipHandle = createToolTip (toolTipText, button, font);
+ break;
+ case OS.Ph_EV_PTR_UNSTEADY:
+ destroyToolTip (toolTipHandle);
+ toolTipHandle = 0;
+ break;
+ }
+ return OS.Pt_END;
+}
+
+int Pt_CB_ACTIVATE (int widget, int info) {
+ Event event = new Event ();
+ if (widget == arrow) {
+ event.detail = SWT.ARROW;
+ int topHandle = topHandle ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (topHandle, area);
+ event.x = area.pos_x;
+ event.y = area.pos_y + area.size_h;
+ } else {
+ if ((style & SWT.RADIO) != 0) {
+ if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
+ selectRadio ();
+ }
+ }
+ }
+ postEvent (SWT.Selection, event);
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_LOST_FOCUS (int widget, int info) {
+ parent.lastFocus = this;
+ return OS.Pt_CONTINUE;
+}
+
+void register () {
+ super.register ();
+ if ((style & SWT.DROP_DOWN) != 0) {
+ WidgetTable.put (button, this);
+ WidgetTable.put (arrow, this);
+ }
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ parent.destroyItem (this);
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ arrow = button = 0;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ if (toolTipHandle != 0) destroyToolTip (toolTipHandle);
+ if (parent.lastFocus == this) parent.lastFocus = null;
+ toolTipHandle = 0;
+ parent = null;
+ control = null;
+ hotImage = null;
+ disabledImage = null;
+ toolTipText = null;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the control is selected.
@@ -573,33 +573,33 @@ void releaseWidget () {
* @see SelectionListener
* @see #addSelectionListener
*/
-public void removeSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
-void selectRadio () {
- int index = 0;
- ToolItem [] items = parent.getItems ();
- while (index < items.length && items [index] != this) index++;
- int i = index - 1;
- while (i >= 0 && items [i].setRadioSelection (false)) --i;
- int j = index + 1;
- while (j < items.length && items [j].setRadioSelection (false)) j++;
- setSelection (true);
-}
-
-void setBackgroundPixel (int pixel) {
- OS.PtSetResource (handle, OS.Pt_ARG_FILL_COLOR, pixel, 0);
- if ((style & SWT.DROP_DOWN) != 0) {
- OS.PtSetResource (button, OS.Pt_ARG_FILL_COLOR, pixel, 0);
- OS.PtSetResource (arrow, OS.Pt_ARG_FILL_COLOR, pixel, 0);
- }
-}
-
+public void removeSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+void selectRadio () {
+ int index = 0;
+ ToolItem [] items = parent.getItems ();
+ while (index < items.length && items [index] != this) index++;
+ int i = index - 1;
+ while (i >= 0 && items [i].setRadioSelection (false)) --i;
+ int j = index + 1;
+ while (j < items.length && items [j].setRadioSelection (false)) j++;
+ setSelection (true);
+}
+
+void setBackgroundPixel (int pixel) {
+ OS.PtSetResource (handle, OS.Pt_ARG_FILL_COLOR, pixel, 0);
+ if ((style & SWT.DROP_DOWN) != 0) {
+ OS.PtSetResource (button, OS.Pt_ARG_FILL_COLOR, pixel, 0);
+ OS.PtSetResource (arrow, OS.Pt_ARG_FILL_COLOR, pixel, 0);
+ }
+}
+
/**
* Sets the control that is used to fill the bounds of
* the item when the items is a <code>SEPARATOR</code>.
@@ -615,29 +615,29 @@ void setBackgroundPixel (int pixel) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setControl (Control control) {
- checkWidget();
- if (control != null) {
- if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
- if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
- }
- if ((style & SWT.SEPARATOR) == 0) return;
- Control oldControl = this.control;
- this.control = control;
- if (oldControl != null) {
- OS.PtReParentWidget(oldControl.handle, parent.parentingHandle ());
- }
- if (control != null && !control.isDisposed ()) {
- OS.PtReParentWidget(control.handle, handle);
- control.setBounds (getBounds ());
- }
-}
-
-void setDefaultFont () {
- Display display = getDisplay ();
- if (display.defaultFont != null) setFont (parent.defaultFont ());
-}
-
+public void setControl (Control control) {
+ checkWidget();
+ if (control != null) {
+ if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+ if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
+ }
+ if ((style & SWT.SEPARATOR) == 0) return;
+ Control oldControl = this.control;
+ this.control = control;
+ if (oldControl != null) {
+ OS.PtReParentWidget(oldControl.handle, parent.parentingHandle ());
+ }
+ if (control != null && !control.isDisposed ()) {
+ OS.PtReParentWidget(control.handle, handle);
+ control.setBounds (getBounds ());
+ }
+}
+
+void setDefaultFont () {
+ Display display = getDisplay ();
+ if (display.defaultFont != null) setFont (parent.defaultFont ());
+}
+
/**
* Sets the receiver's disabled image to the argument, which may be
* null indicating that no disabled image should be displayed.
@@ -655,13 +655,13 @@ void setDefaultFont () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setDisabledImage (Image image) {
- checkWidget();
- if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if ((style & SWT.SEPARATOR) != 0) return;
- disabledImage = image;
-}
-
+public void setDisabledImage (Image image) {
+ checkWidget();
+ if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ disabledImage = image;
+}
+
/**
* Enables the receiver if the argument is <code>true</code>,
* and disables it otherwise.
@@ -678,62 +678,62 @@ public void setDisabledImage (Image image) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setEnabled (boolean enabled) {
- checkWidget ();
- int topHandle = topHandle ();
- int flags = enabled ? 0 : OS.Pt_BLOCKED | OS.Pt_GHOST;
- OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
- if ((style & SWT.DROP_DOWN) != 0) {
- OS.PtSetResource (button, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
- OS.PtSetResource (arrow, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
- }
-}
-
-boolean setFocus () {
- if ((style & SWT.SEPARATOR) != 0) return false;
- int focusHandle = (style & SWT.DROP_DOWN) != 0 ? button : handle;
- /*
- * Bug in Photon. Photon will stop sending key
- * events, if a menu is up and focus is given to
- * a widget by calling PtContainerGiveFocus(). The
- * fix is to detect when a menu is up and avoid
- * calling this function.
- */
- Shell shell = parent.getShell ();
- if (shell.activeMenu != null) return false;
- OS.PtContainerGiveFocus (focusHandle, null);
- return OS.PtIsFocused(focusHandle) != 0;
-}
-
-void setFont (byte [] font) {
- int ptr = OS.malloc (font.length);
- OS.memmove (ptr, font, font.length);
- setFont (ptr);
- OS.free (ptr);
-}
-
-void setFont (int font) {
- int [] args = {
- OS.Pt_ARG_TEXT_FONT, font, 0,
- OS.Pt_ARG_LIST_FONT, font, 0,
- OS.Pt_ARG_TITLE_FONT, font, 0,
- OS.Pt_ARG_GAUGE_FONT, font, 0,
- };
- OS.PtSetResources (handle, args.length / 3, args);
- if ((style & SWT.DROP_DOWN) != 0) {
- OS.PtSetResources (button, args.length / 3, args);
- OS.PtSetResources (arrow, args.length / 3, args);
- }
-}
-
-void setForegroundPixel (int pixel) {
- OS.PtSetResource (handle, OS.Pt_ARG_COLOR, pixel, 0);
- if ((style & SWT.DROP_DOWN) != 0) {
- OS.PtSetResource (button, OS.Pt_ARG_COLOR, pixel, 0);
- OS.PtSetResource (arrow, OS.Pt_ARG_COLOR, pixel, 0);
- }
-}
-
+public void setEnabled (boolean enabled) {
+ checkWidget ();
+ int topHandle = topHandle ();
+ int flags = enabled ? 0 : OS.Pt_BLOCKED | OS.Pt_GHOST;
+ OS.PtSetResource (topHandle, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
+ if ((style & SWT.DROP_DOWN) != 0) {
+ OS.PtSetResource (button, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
+ OS.PtSetResource (arrow, OS.Pt_ARG_FLAGS, flags, OS.Pt_BLOCKED | OS.Pt_GHOST);
+ }
+}
+
+boolean setFocus () {
+ if ((style & SWT.SEPARATOR) != 0) return false;
+ int focusHandle = (style & SWT.DROP_DOWN) != 0 ? button : handle;
+ /*
+ * Bug in Photon. Photon will stop sending key
+ * events, if a menu is up and focus is given to
+ * a widget by calling PtContainerGiveFocus(). The
+ * fix is to detect when a menu is up and avoid
+ * calling this function.
+ */
+ Shell shell = parent.getShell ();
+ if (shell.activeMenu != null) return false;
+ OS.PtContainerGiveFocus (focusHandle, null);
+ return OS.PtIsFocused(focusHandle) != 0;
+}
+
+void setFont (byte [] font) {
+ int ptr = OS.malloc (font.length);
+ OS.memmove (ptr, font, font.length);
+ setFont (ptr);
+ OS.free (ptr);
+}
+
+void setFont (int font) {
+ int [] args = {
+ OS.Pt_ARG_TEXT_FONT, font, 0,
+ OS.Pt_ARG_LIST_FONT, font, 0,
+ OS.Pt_ARG_TITLE_FONT, font, 0,
+ OS.Pt_ARG_GAUGE_FONT, font, 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ if ((style & SWT.DROP_DOWN) != 0) {
+ OS.PtSetResources (button, args.length / 3, args);
+ OS.PtSetResources (arrow, args.length / 3, args);
+ }
+}
+
+void setForegroundPixel (int pixel) {
+ OS.PtSetResource (handle, OS.Pt_ARG_COLOR, pixel, 0);
+ if ((style & SWT.DROP_DOWN) != 0) {
+ OS.PtSetResource (button, OS.Pt_ARG_COLOR, pixel, 0);
+ OS.PtSetResource (arrow, OS.Pt_ARG_COLOR, pixel, 0);
+ }
+}
+
/**
* Sets the receiver's hot image to the argument, which may be
* null indicating that no hot image should be displayed.
@@ -751,62 +751,62 @@ void setForegroundPixel (int pixel) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setHotImage (Image image) {
- checkWidget();
- if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if ((style & SWT.SEPARATOR) != 0) return;
-
- /* TEMPORARY CODE: remove when when FLAT tool bars are implemented */
- if ((parent.style & SWT.FLAT) != 0) setImage (image);
-
- hotImage = image;
-}
-
-public void setImage (Image image) {
- checkWidget();
- if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if ((style & SWT.SEPARATOR) != 0) return;
- super.setImage (image);
-
- /* TEMPORARY CODE: remove when when FLAT tool bars are implemented */
- if ((parent.style & SWT.FLAT) != 0 && hotImage != null) return;
-
- int imageHandle = 0;
- int type = OS.Pt_Z_STRING;
- if (image != null) {
- imageHandle = copyPhImage (image.handle);
- if(text.length() != 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 (button, args.length / 3, args);
- if (imageHandle != 0) OS.free (imageHandle);
-
- /*
- * Bug on Photon. When a the text/image is set on a
- * DROP_DOWN item that is realized, the item does not resize
- * to show the new text/image. The fix is to force the item
- * to recalculate the size.
- */
- if ((style & SWT.DROP_DOWN) != 0) {
- if (OS.PtWidgetIsRealized (handle)) {
- OS.PtExtentWidget (handle);
- }
- }
-}
-
-boolean setRadioSelection (boolean value) {
- if ((style & SWT.RADIO) == 0) return false;
- if (getSelection () != value) {
- setSelection (value);
- postEvent (SWT.Selection);
- }
- return true;
-}
-
+public void setHotImage (Image image) {
+ checkWidget();
+ if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+
+ /* TEMPORARY CODE: remove when when FLAT tool bars are implemented */
+ if ((parent.style & SWT.FLAT) != 0) setImage (image);
+
+ hotImage = image;
+}
+
+public void setImage (Image image) {
+ checkWidget();
+ if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ super.setImage (image);
+
+ /* TEMPORARY CODE: remove when when FLAT tool bars are implemented */
+ if ((parent.style & SWT.FLAT) != 0 && hotImage != null) return;
+
+ int imageHandle = 0;
+ int type = OS.Pt_Z_STRING;
+ if (image != null) {
+ imageHandle = copyPhImage (image.handle);
+ if(text.length() != 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 (button, args.length / 3, args);
+ if (imageHandle != 0) OS.free (imageHandle);
+
+ /*
+ * Bug on Photon. When a the text/image is set on a
+ * DROP_DOWN item that is realized, the item does not resize
+ * to show the new text/image. The fix is to force the item
+ * to recalculate the size.
+ */
+ if ((style & SWT.DROP_DOWN) != 0) {
+ if (OS.PtWidgetIsRealized (handle)) {
+ OS.PtExtentWidget (handle);
+ }
+ }
+}
+
+boolean setRadioSelection (boolean value) {
+ if ((style & SWT.RADIO) == 0) return false;
+ if (getSelection () != value) {
+ setSelection (value);
+ postEvent (SWT.Selection);
+ }
+ return true;
+}
+
/**
* Sets the selection state of the receiver.
* <p>
@@ -822,42 +822,42 @@ boolean setRadioSelection (boolean value) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setSelection (boolean selected) {
- checkWidget();
- if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
- OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET);
-}
-
-public void setText (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if ((style & SWT.SEPARATOR) != 0) return;
- super.setText (string);
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- int ptr = OS.malloc (buffer.length);
- OS.memmove (ptr, buffer, buffer.length);
- int type = OS.Pt_Z_STRING;
- if (image != null) type = OS.Pt_TEXT_IMAGE;
- int [] args = {
- OS.Pt_ARG_TEXT_STRING, ptr, 0,
- OS.Pt_ARG_LABEL_TYPE, type, 0,
- };
- OS.PtSetResources (button, args.length / 3, args);
- if (ptr != 0) OS.free (ptr);
-
- /*
- * Bug on Photon. When a the text/image is set on a
- * DROP_DOWN item that is realized, the item does not resize
- * to show the new text/image. The fix is to force the item
- * to recalculate the size.
- */
- if ((style & SWT.DROP_DOWN) != 0) {
- if (OS.PtWidgetIsRealized (handle)) {
- OS.PtExtentWidget (handle);
- }
- }
-}
-
+public void setSelection (boolean selected) {
+ checkWidget();
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
+ OS.PtSetResource (handle, OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET);
+}
+
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ super.setText (string);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int type = OS.Pt_Z_STRING;
+ if (image != null) type = OS.Pt_TEXT_IMAGE;
+ int [] args = {
+ OS.Pt_ARG_TEXT_STRING, ptr, 0,
+ OS.Pt_ARG_LABEL_TYPE, type, 0,
+ };
+ OS.PtSetResources (button, args.length / 3, args);
+ if (ptr != 0) OS.free (ptr);
+
+ /*
+ * Bug on Photon. When a the text/image is set on a
+ * DROP_DOWN item that is realized, the item does not resize
+ * to show the new text/image. The fix is to force the item
+ * to recalculate the size.
+ */
+ if ((style & SWT.DROP_DOWN) != 0) {
+ if (OS.PtWidgetIsRealized (handle)) {
+ OS.PtExtentWidget (handle);
+ }
+ }
+}
+
/**
* Sets the receiver's tool tip text to the argument, which
* may be null indicating that no tool tip text should be shown.
@@ -869,11 +869,11 @@ public void setText (String string) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setToolTipText (String string) {
- checkWidget();
- toolTipText = string;
-}
-
+public void setToolTipText (String string) {
+ checkWidget();
+ toolTipText = string;
+}
+
/**
* Sets the width of the receiver.
*
@@ -884,14 +884,14 @@ public void setToolTipText (String string) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setWidth (int width) {
- checkWidget();
- if ((style & SWT.SEPARATOR) == 0) return;
- if (width < 0) return;
- int topHandle = topHandle ();
- OS.PtSetResource (topHandle, OS.Pt_ARG_WIDTH, width, 0);
- if (control != null && !control.isDisposed ()) {
- control.setBounds (getBounds ());
- }
-}
-}
+public void setWidth (int width) {
+ checkWidget();
+ if ((style & SWT.SEPARATOR) == 0) return;
+ if (width < 0) return;
+ int topHandle = topHandle ();
+ OS.PtSetResource (topHandle, OS.Pt_ARG_WIDTH, width, 0);
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getBounds ());
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java
index c9d24acbf3..5778890e61 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java
@@ -1,50 +1,50 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-
-/**
- * Instances of this class implement rubber banding rectangles that are
- * drawn onto a parent <code>Composite</code> or <code>Display</code>.
- * These rectangles can be specified to respond to mouse and key events
- * by either moving or resizing themselves accordingly. Trackers are
- * typically used to represent window geometries in a lightweight manner.
- *
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>LEFT, RIGHT, UP, DOWN, RESIZE</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Move, Resize</dd>
- * </dl>
- * <p>
- * Note: Rectangle move behavior is assumed unless RESIZE is specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- */
-public class Tracker extends Widget {
- Composite parent;
- Display display;
- boolean tracking, stippled;
- Rectangle [] rectangles, proportions;
- int resizeCursor, clientCursor, clientBitmap;
- int cursorOrientation = SWT.NONE;
-
- /*
- * The following values mirror step sizes on Windows
- */
- final static int STEPSIZE_SMALL = 1;
- final static int STEPSIZE_LARGE = 9;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class implement rubber banding rectangles that are
+ * drawn onto a parent <code>Composite</code> or <code>Display</code>.
+ * These rectangles can be specified to respond to mouse and key events
+ * by either moving or resizing themselves accordingly. Trackers are
+ * typically used to represent window geometries in a lightweight manner.
+ *
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>LEFT, RIGHT, UP, DOWN, RESIZE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Move, Resize</dd>
+ * </dl>
+ * <p>
+ * Note: Rectangle move behavior is assumed unless RESIZE is specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+public class Tracker extends Widget {
+ Composite parent;
+ Display display;
+ boolean tracking, stippled;
+ Rectangle [] rectangles, proportions;
+ int resizeCursor, clientCursor, clientBitmap;
+ int cursorOrientation = SWT.NONE;
+
+ /*
+ * The following values mirror step sizes on Windows
+ */
+ final static int STEPSIZE_SMALL = 1;
+ final static int STEPSIZE_LARGE = 9;
+
/**
* Constructs a new instance of this class given the display
* to create it on and a style value describing its behavior
@@ -79,16 +79,16 @@ public class Tracker extends Widget {
* @see SWT#UP
* @see SWT#DOWN
*/
-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 = checkStyle (style);
- this.display = display;
-}
-
+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 = checkStyle (style);
+ this.display = display;
+}
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -121,12 +121,12 @@ public Tracker (Display display, int style) {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public Tracker (Composite parent, int style) {
- super (parent, checkStyle (style));
- this.parent = parent;
- display = parent.getDisplay ();
-}
-
+public Tracker (Composite parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ display = parent.getDisplay ();
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the control is moved or resized, by sending
@@ -146,212 +146,212 @@ public Tracker (Composite parent, int style) {
* @see ControlListener
* @see #removeControlListener
*/
-public void addControlListener(ControlListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Move,typedListener);
-}
-
-Point adjustMoveCursor () {
- Rectangle bounds = computeBounds ();
- int newX = bounds.x + bounds.width / 2;
- int newY = bounds.y;
- /*
- * Convert to screen coordinates iff needed
- */
- if (parent != null) {
- short [] x = new short [1], y = new short [1];
- OS.PtGetAbsPosition (parent.handle, x, y);
- newX += x [0];
- newY += y [0];
- }
- OS.PhMoveCursorAbs(OS.PhInputGroup (0), newX, newY);
- return new Point (newX, newY);
-}
-
-Point adjustResizeCursor () {
- int newX, newY;
- Rectangle bounds = computeBounds ();
-
- if ((cursorOrientation & SWT.LEFT) != 0) {
- newX = bounds.x;
- } else if ((cursorOrientation & SWT.RIGHT) != 0) {
- newX = bounds.x + bounds.width;
- } else {
- newX = bounds.x + bounds.width / 2;
- }
-
- if ((cursorOrientation & SWT.UP) != 0) {
- newY = bounds.y;
- } else if ((cursorOrientation & SWT.DOWN) != 0) {
- newY = bounds.y + bounds.height;
- } else {
- newY = bounds.y + bounds.height / 2;
- }
-
- /*
- * Convert to screen coordinates iff needed
- */
- if (parent != null) {
- short [] x = new short [1], y = new short [1];
- OS.PtGetAbsPosition (parent.handle, x, y);
- newX += x [0];
- newY += y [0];
- }
- OS.PhMoveCursorAbs(OS.PhInputGroup (0), newX, newY);
-
- /*
- * If the client has not provided a custom cursor then determine
- * the appropriate resize cursor.
- */
- if (clientCursor == 0) {
- int newCursor = 0;
- switch (cursorOrientation) {
- case SWT.UP:
- newCursor = OS.Ph_CURSOR_DRAG_TOP;
- break;
- case SWT.DOWN:
- newCursor = OS.Ph_CURSOR_DRAG_BOTTOM;
- break;
- case SWT.LEFT:
- newCursor = OS.Ph_CURSOR_DRAG_LEFT;
- break;
- case SWT.RIGHT:
- newCursor = OS.Ph_CURSOR_DRAG_RIGHT;
- break;
- case SWT.LEFT | SWT.UP:
- newCursor = OS.Ph_CURSOR_DRAG_TL;
- break;
- case SWT.RIGHT | SWT.DOWN:
- newCursor = OS.Ph_CURSOR_DRAG_BR;
- break;
- case SWT.LEFT | SWT.DOWN:
- newCursor = OS.Ph_CURSOR_DRAG_BL;
- break;
- case SWT.RIGHT | SWT.UP:
- newCursor = OS.Ph_CURSOR_DRAG_TR;
- break;
- default:
- newCursor = OS.Ph_CURSOR_MOVE;
- break;
- }
- resizeCursor = newCursor;
- }
-
- return new Point (newX, newY);
-}
-
-static int checkStyle (int style) {
- if ((style & (SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN)) == 0) {
- style |= SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN;
- }
- return style;
-}
-
-/**
- * Stops displaying the tracker rectangles. Note that this is not considered
- * to be a cancelation by the user.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void close () {
- checkWidget();
- tracking = false;
-}
-
-Rectangle computeBounds () {
- int xMin = rectangles [0].x;
- int yMin = rectangles [0].y;
- int xMax = rectangles [0].x + rectangles [0].width;
- int yMax = rectangles [0].y + rectangles [0].height;
-
- for (int i = 1; i < rectangles.length; i++) {
- if (rectangles [i].x < xMin) xMin = rectangles [i].x;
- if (rectangles [i].y < yMin) yMin = rectangles [i].y;
- int rectRight = rectangles [i].x + rectangles [i].width;
- if (rectRight > xMax) xMax = rectRight;
- int rectBottom = rectangles [i].y + rectangles [i].height;
- if (rectBottom > yMax) yMax = rectBottom;
- }
-
- return new Rectangle (xMin, yMin, xMax - xMin, yMax - yMin);
-}
-
-Rectangle [] computeProportions (Rectangle [] rects) {
- Rectangle [] result = new Rectangle [rects.length];
- Rectangle bounds = computeBounds ();
- for (int i = 0; i < rects.length; i++) {
- result[i] = new Rectangle (
- (rects[i].x - bounds.x) * 100 / bounds.width,
- (rects[i].y - bounds.y) * 100 / bounds.height,
- rects[i].width * 100 / bounds.width,
- rects[i].height * 100 / bounds.height);
- }
- return result;
-}
-
-void drawRectangles (Rectangle [] rects) {
- if (parent != null) {
- if (parent.isDisposed ()) return;
- parent.getShell ().update ();
- } else {
- display.update ();
- }
- int rid = OS.Ph_DEV_RID;
- if (parent != null) rid = OS.PtWidgetRid (parent.handle);
-
- int phGC = OS.PgCreateGC (0);
- if (phGC == 0) return;
- int prevContext = OS.PgSetGC (phGC);
- OS.PgSetRegion (rid);
- OS.PgSetDrawMode (OS.Pg_DRAWMODE_XOR);
- OS.PgSetFillColor (0xffffff);
-
- int bandWidth = 0;
- if (stippled) {
- bandWidth = 2;
- OS.PgSetFillTransPat (OS.Pg_PAT_HALF);
- }
- for (int i=0; i<rects.length; i++) {
- Rectangle r = rects [i];
- int x1 = r.x;
- int y1 = r.y;
- int x2 = r.x + r.width;
- int y2 = r.y + r.height;
- OS.PgDrawIRect(x1, y1, x2, y1 + bandWidth, OS.Pg_DRAW_FILL);
- OS.PgDrawIRect(x1, y1 + bandWidth + 1, x1 + bandWidth, y2 - bandWidth - 1, OS.Pg_DRAW_FILL);
- OS.PgDrawIRect(x2 - bandWidth, y1 + bandWidth + 1, x2, y2 - bandWidth - 1, OS.Pg_DRAW_FILL);
- OS.PgDrawIRect(x1, y2 - bandWidth, x2, y2, OS.Pg_DRAW_FILL);
- }
- OS.PgSetGC (prevContext);
- OS.PgDestroyGC (phGC);
-}
-
-public Display getDisplay () {
- return display;
-}
-
-/**
- * Returns the bounds that are being drawn, expressed relative to the parent
- * widget. If the parent is a <code>Display</code> then these are screen
- * coordinates.
- *
- * @return the bounds of the Rectangles being drawn
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
+public void addControlListener(ControlListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Move,typedListener);
+}
+
+Point adjustMoveCursor () {
+ Rectangle bounds = computeBounds ();
+ int newX = bounds.x + bounds.width / 2;
+ int newY = bounds.y;
+ /*
+ * Convert to screen coordinates iff needed
+ */
+ if (parent != null) {
+ short [] x = new short [1], y = new short [1];
+ OS.PtGetAbsPosition (parent.handle, x, y);
+ newX += x [0];
+ newY += y [0];
+ }
+ OS.PhMoveCursorAbs(OS.PhInputGroup (0), newX, newY);
+ return new Point (newX, newY);
+}
+
+Point adjustResizeCursor () {
+ int newX, newY;
+ Rectangle bounds = computeBounds ();
+
+ if ((cursorOrientation & SWT.LEFT) != 0) {
+ newX = bounds.x;
+ } else if ((cursorOrientation & SWT.RIGHT) != 0) {
+ newX = bounds.x + bounds.width;
+ } else {
+ newX = bounds.x + bounds.width / 2;
+ }
+
+ if ((cursorOrientation & SWT.UP) != 0) {
+ newY = bounds.y;
+ } else if ((cursorOrientation & SWT.DOWN) != 0) {
+ newY = bounds.y + bounds.height;
+ } else {
+ newY = bounds.y + bounds.height / 2;
+ }
+
+ /*
+ * Convert to screen coordinates iff needed
+ */
+ if (parent != null) {
+ short [] x = new short [1], y = new short [1];
+ OS.PtGetAbsPosition (parent.handle, x, y);
+ newX += x [0];
+ newY += y [0];
+ }
+ OS.PhMoveCursorAbs(OS.PhInputGroup (0), newX, newY);
+
+ /*
+ * If the client has not provided a custom cursor then determine
+ * the appropriate resize cursor.
+ */
+ if (clientCursor == 0) {
+ int newCursor = 0;
+ switch (cursorOrientation) {
+ case SWT.UP:
+ newCursor = OS.Ph_CURSOR_DRAG_TOP;
+ break;
+ case SWT.DOWN:
+ newCursor = OS.Ph_CURSOR_DRAG_BOTTOM;
+ break;
+ case SWT.LEFT:
+ newCursor = OS.Ph_CURSOR_DRAG_LEFT;
+ break;
+ case SWT.RIGHT:
+ newCursor = OS.Ph_CURSOR_DRAG_RIGHT;
+ break;
+ case SWT.LEFT | SWT.UP:
+ newCursor = OS.Ph_CURSOR_DRAG_TL;
+ break;
+ case SWT.RIGHT | SWT.DOWN:
+ newCursor = OS.Ph_CURSOR_DRAG_BR;
+ break;
+ case SWT.LEFT | SWT.DOWN:
+ newCursor = OS.Ph_CURSOR_DRAG_BL;
+ break;
+ case SWT.RIGHT | SWT.UP:
+ newCursor = OS.Ph_CURSOR_DRAG_TR;
+ break;
+ default:
+ newCursor = OS.Ph_CURSOR_MOVE;
+ break;
+ }
+ resizeCursor = newCursor;
+ }
+
+ return new Point (newX, newY);
+}
+
+static int checkStyle (int style) {
+ if ((style & (SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN)) == 0) {
+ style |= SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN;
+ }
+ return style;
+}
+
+/**
+ * Stops displaying the tracker rectangles. Note that this is not considered
+ * to be a cancelation by the user.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void close () {
+ checkWidget();
+ tracking = false;
+}
+
+Rectangle computeBounds () {
+ int xMin = rectangles [0].x;
+ int yMin = rectangles [0].y;
+ int xMax = rectangles [0].x + rectangles [0].width;
+ int yMax = rectangles [0].y + rectangles [0].height;
+
+ for (int i = 1; i < rectangles.length; i++) {
+ if (rectangles [i].x < xMin) xMin = rectangles [i].x;
+ if (rectangles [i].y < yMin) yMin = rectangles [i].y;
+ int rectRight = rectangles [i].x + rectangles [i].width;
+ if (rectRight > xMax) xMax = rectRight;
+ int rectBottom = rectangles [i].y + rectangles [i].height;
+ if (rectBottom > yMax) yMax = rectBottom;
+ }
+
+ return new Rectangle (xMin, yMin, xMax - xMin, yMax - yMin);
+}
+
+Rectangle [] computeProportions (Rectangle [] rects) {
+ Rectangle [] result = new Rectangle [rects.length];
+ Rectangle bounds = computeBounds ();
+ for (int i = 0; i < rects.length; i++) {
+ result[i] = new Rectangle (
+ (rects[i].x - bounds.x) * 100 / bounds.width,
+ (rects[i].y - bounds.y) * 100 / bounds.height,
+ rects[i].width * 100 / bounds.width,
+ rects[i].height * 100 / bounds.height);
+ }
+ return result;
+}
+
+void drawRectangles (Rectangle [] rects) {
+ if (parent != null) {
+ if (parent.isDisposed ()) return;
+ parent.getShell ().update ();
+ } else {
+ display.update ();
+ }
+ int rid = OS.Ph_DEV_RID;
+ if (parent != null) rid = OS.PtWidgetRid (parent.handle);
+
+ int phGC = OS.PgCreateGC (0);
+ if (phGC == 0) return;
+ int prevContext = OS.PgSetGC (phGC);
+ OS.PgSetRegion (rid);
+ OS.PgSetDrawMode (OS.Pg_DRAWMODE_XOR);
+ OS.PgSetFillColor (0xffffff);
+
+ int bandWidth = 0;
+ if (stippled) {
+ bandWidth = 2;
+ OS.PgSetFillTransPat (OS.Pg_PAT_HALF);
+ }
+ for (int i=0; i<rects.length; i++) {
+ Rectangle r = rects [i];
+ int x1 = r.x;
+ int y1 = r.y;
+ int x2 = r.x + r.width;
+ int y2 = r.y + r.height;
+ OS.PgDrawIRect(x1, y1, x2, y1 + bandWidth, OS.Pg_DRAW_FILL);
+ OS.PgDrawIRect(x1, y1 + bandWidth + 1, x1 + bandWidth, y2 - bandWidth - 1, OS.Pg_DRAW_FILL);
+ OS.PgDrawIRect(x2 - bandWidth, y1 + bandWidth + 1, x2, y2 - bandWidth - 1, OS.Pg_DRAW_FILL);
+ OS.PgDrawIRect(x1, y2 - bandWidth, x2, y2, OS.Pg_DRAW_FILL);
+ }
+ OS.PgSetGC (prevContext);
+ OS.PgDestroyGC (phGC);
+}
+
+public Display getDisplay () {
+ return display;
+}
+
+/**
+ * Returns the bounds that are being drawn, expressed relative to the parent
+ * widget. If the parent is a <code>Display</code> then these are screen
+ * coordinates.
+ *
+ * @return the bounds of the Rectangles being drawn
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
*/
-public Rectangle [] getRectangles () {
- checkWidget();
- return rectangles;
-}
-
+public Rectangle [] getRectangles () {
+ checkWidget();
+ return rectangles;
+}
+
/**
* Returns <code>true</code> if the rectangles are drawn with a stippled line, <code>false</code> otherwise.
*
@@ -362,230 +362,230 @@ public Rectangle [] getRectangles () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean getStippled () {
- checkWidget();
- return stippled;
-}
-
-void moveRectangles (int xChange, int yChange) {
- if (xChange < 0 && ((style & SWT.LEFT) == 0)) return;
- if (xChange > 0 && ((style & SWT.RIGHT) == 0)) return;
- if (yChange < 0 && ((style & SWT.UP) == 0)) return;
- if (yChange > 0 && ((style & SWT.DOWN) == 0)) return;
- Rectangle bounds = computeBounds ();
- bounds.x += xChange; bounds.y += yChange;
- for (int i = 0; i < rectangles.length; i++) {
- rectangles [i].x += xChange;
- rectangles [i].y += yChange;
- }
-}
-
-/**
- * Displays the Tracker rectangles for manipulation by the user. Returns when
- * the user has either finished manipulating the rectangles or has cancelled the
- * Tracker.
- *
- * @return <code>true</code> if the user did not cancel the Tracker, <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public boolean open () {
- checkWidget();
- if (rectangles == null) return false;
-
- int input_group = OS.PhInputGroup (0);
- PhCursorInfo_t info = new PhCursorInfo_t ();
- OS.PhQueryCursor ((short)input_group, info);
-
- if ((style & SWT.MENU) == 0) {
- /*
- * This code is intentionally commented. Tracking can happen through
- * the keyboard.
- */
-// if ((info.button_state & OS.Ph_BUTTON_SELECT) == 0) return false;
- }
-
- int region = 0;
- if (info.dragger == 0) {
- PhRect_t rect = new PhRect_t ();
- OS.PhWindowQueryVisible (OS.Ph_QUERY_CONSOLE, 0, OS.PhInputGroup (0), rect);
- int sense = OS.Ph_EV_DRAG | OS.Ph_EV_KEY | OS.Ph_EV_BUT_PRESS |
- OS.Ph_EV_BUT_RELEASE | OS.Ph_EV_PTR_MOTION;
- int [] args = {
- OS.Pt_ARG_WIDTH, rect.lr_x - rect.ul_x + 1, 0,
- OS.Pt_ARG_HEIGHT, rect.lr_y - rect.ul_y + 1, 0,
- OS.Pt_ARG_REGION_OPAQUE, 0, ~0,
- OS.Pt_ARG_REGION_SENSE, sense, ~0,
- OS.Pt_ARG_REGION_FLAGS, OS.Ph_FORCE_BOUNDARY, OS.Ph_FORCE_BOUNDARY,
- OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,
- };
- region = OS.PtCreateWidget (OS.PtRegion (), OS.Pt_NO_PARENT, args.length / 3, args);
- OS.PtRealizeWidget (region);
-
- rect = new PhRect_t ();
- int rid = OS.PtWidgetRid (region);
- OS.PhInitDrag (rid, OS.Ph_DRAG_KEY_MOTION | OS.Ph_TRACK_DRAG, rect, null, input_group, null, null, null, null, null);
- }
-
- int oldX, oldY;
- int size = PhEvent_t.sizeof + 1024;
- int buffer = OS.malloc (size);
- PhEvent_t phEvent = new PhEvent_t ();
- Event event = new Event ();
- Point cursorPos;
-
- drawRectangles (rectangles);
- if ((style & SWT.MENU) == 0) {
- oldX = info.pos_x;
- oldY = info.pos_y;
- } else {
- if ((style & SWT.RESIZE) != 0) {
- cursorPos = adjustResizeCursor ();
- } else {
- cursorPos = adjustMoveCursor ();
- }
- oldX = cursorPos.x;
- oldY = cursorPos.y;
- }
-
- tracking = true;
- boolean cancelled = false;
- while (tracking && !cancelled) {
- if (parent != null && parent.isDisposed ()) break;
- int result = OS.PhEventNext (buffer, size);
- switch (result) {
- case OS.Ph_EVENT_MSG: break;
- case OS.Ph_RESIZE_MSG:
- size = OS.PhGetMsgSize (buffer);
- OS.free (buffer);
- buffer = OS.malloc (size);
- continue;
- }
- OS.memmove (phEvent, buffer, PhEvent_t.sizeof);
- if (phEvent.type == OS.Ph_EV_DRAG) {
- switch (phEvent.subtype) {
- case OS.Ph_EV_DRAG_MOTION_EVENT: {
- int data = OS.PhGetData (buffer);
- if (data == 0) break;
- PhPointerEvent_t pe = new PhPointerEvent_t ();
- OS.memmove (pe, data, PhPointerEvent_t.sizeof);
- int newX = pe.pos_x;
- int newY = pe.pos_y;
- if (newX != oldX || newY != oldY) {
- drawRectangles (rectangles);
- event.x = newX;
- event.y = newY;
- if ((style & SWT.RESIZE) != 0) {
- resizeRectangles (newX - oldX, newY - oldY);
- cursorPos = adjustResizeCursor ();
- newX = cursorPos.x; newY = cursorPos.y;
- sendEvent (SWT.Resize, event);
- } else {
- moveRectangles (newX - oldX, newY - oldY);
- sendEvent (SWT.Move, event);
- }
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in the move
- * event. If this happens, return false to indicate
- * that the tracking has failed.
- */
- if (isDisposed ()) return false;
- drawRectangles (rectangles);
- oldX = newX; oldY = newY;
- }
- break;
- }
- case OS.Ph_EV_DRAG_KEY_EVENT: {
- int data = OS.PhGetData (buffer);
- if (data == 0) break;
- PhKeyEvent_t ke = new PhKeyEvent_t ();
- OS.memmove (ke, data, PhKeyEvent_t.sizeof);
- if ((ke.key_flags & OS.Pk_KF_Sym_Valid) != 0) {
- int stepSize = (ke.key_mods & OS.Pk_KM_Ctrl) != 0 ? STEPSIZE_SMALL : STEPSIZE_LARGE;
- int xChange = 0, yChange = 0;
- switch (ke.key_sym) {
- case OS.Pk_Escape:
- cancelled = true;
- tracking = false;
- break;
- case OS.Pk_Return:
- tracking = false;
- break;
- case OS.Pk_Left:
- xChange = -stepSize;
- break;
- case OS.Pk_Right:
- xChange = stepSize;
- break;
- case OS.Pk_Up:
- yChange = -stepSize;
- break;
- case OS.Pk_Down:
- yChange = stepSize;
- break;
- }
- if (xChange != 0 || yChange != 0) {
- drawRectangles (rectangles);
- int newX = oldX + xChange;
- int newY = oldY + yChange;
- event.x = newX;
- event.y = newY;
- if ((style & SWT.RESIZE) != 0) {
- resizeRectangles (xChange, yChange);
- cursorPos = adjustResizeCursor ();
- sendEvent (SWT.Resize, event);
- } else {
- moveRectangles (xChange, yChange);
- cursorPos = adjustMoveCursor ();
- sendEvent (SWT.Move, event);
- }
- /*
- * It is possible (but unlikely) that application
- * code could have disposed the widget in the move
- * event. If this happens return false to indicate
- * that the tracking has failed.
- */
- if (isDisposed ()) return false;
- drawRectangles (rectangles);
- oldX = cursorPos.x; oldY = cursorPos.y;
- }
- }
- break;
- }
- case OS.Ph_EV_DRAG_COMPLETE: {
- tracking = false;
- break;
- }
- }
- if (phEvent.collector_handle != 0) {
- setCursor (phEvent.collector_handle);
- }
- /*
- * Don't dispatch mouse and key events in general, EXCEPT once this
- * tracker has finished its work.
- */
- if (tracking && !cancelled) continue;
-
- }
- OS.PtEventHandler (buffer);
- }
- drawRectangles (rectangles);
- tracking = false;
- if (region != 0) OS.PtDestroyWidget (region);
- return !cancelled;
-}
-
-void releaseWidget () {
- super.releaseWidget ();
- parent = null;
- display = null;
- rectangles = null;
-}
-
+public boolean getStippled () {
+ checkWidget();
+ return stippled;
+}
+
+void moveRectangles (int xChange, int yChange) {
+ if (xChange < 0 && ((style & SWT.LEFT) == 0)) return;
+ if (xChange > 0 && ((style & SWT.RIGHT) == 0)) return;
+ if (yChange < 0 && ((style & SWT.UP) == 0)) return;
+ if (yChange > 0 && ((style & SWT.DOWN) == 0)) return;
+ Rectangle bounds = computeBounds ();
+ bounds.x += xChange; bounds.y += yChange;
+ for (int i = 0; i < rectangles.length; i++) {
+ rectangles [i].x += xChange;
+ rectangles [i].y += yChange;
+ }
+}
+
+/**
+ * Displays the Tracker rectangles for manipulation by the user. Returns when
+ * the user has either finished manipulating the rectangles or has cancelled the
+ * Tracker.
+ *
+ * @return <code>true</code> if the user did not cancel the Tracker, <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean open () {
+ checkWidget();
+ if (rectangles == null) return false;
+
+ int input_group = OS.PhInputGroup (0);
+ PhCursorInfo_t info = new PhCursorInfo_t ();
+ OS.PhQueryCursor ((short)input_group, info);
+
+ if ((style & SWT.MENU) == 0) {
+ /*
+ * This code is intentionally commented. Tracking can happen through
+ * the keyboard.
+ */
+// if ((info.button_state & OS.Ph_BUTTON_SELECT) == 0) return false;
+ }
+
+ int region = 0;
+ if (info.dragger == 0) {
+ PhRect_t rect = new PhRect_t ();
+ OS.PhWindowQueryVisible (OS.Ph_QUERY_CONSOLE, 0, OS.PhInputGroup (0), rect);
+ int sense = OS.Ph_EV_DRAG | OS.Ph_EV_KEY | OS.Ph_EV_BUT_PRESS |
+ OS.Ph_EV_BUT_RELEASE | OS.Ph_EV_PTR_MOTION;
+ int [] args = {
+ OS.Pt_ARG_WIDTH, rect.lr_x - rect.ul_x + 1, 0,
+ OS.Pt_ARG_HEIGHT, rect.lr_y - rect.ul_y + 1, 0,
+ OS.Pt_ARG_REGION_OPAQUE, 0, ~0,
+ OS.Pt_ARG_REGION_SENSE, sense, ~0,
+ OS.Pt_ARG_REGION_FLAGS, OS.Ph_FORCE_BOUNDARY, OS.Ph_FORCE_BOUNDARY,
+ OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,
+ };
+ region = OS.PtCreateWidget (OS.PtRegion (), OS.Pt_NO_PARENT, args.length / 3, args);
+ OS.PtRealizeWidget (region);
+
+ rect = new PhRect_t ();
+ int rid = OS.PtWidgetRid (region);
+ OS.PhInitDrag (rid, OS.Ph_DRAG_KEY_MOTION | OS.Ph_TRACK_DRAG, rect, null, input_group, null, null, null, null, null);
+ }
+
+ int oldX, oldY;
+ int size = PhEvent_t.sizeof + 1024;
+ int buffer = OS.malloc (size);
+ PhEvent_t phEvent = new PhEvent_t ();
+ Event event = new Event ();
+ Point cursorPos;
+
+ drawRectangles (rectangles);
+ if ((style & SWT.MENU) == 0) {
+ oldX = info.pos_x;
+ oldY = info.pos_y;
+ } else {
+ if ((style & SWT.RESIZE) != 0) {
+ cursorPos = adjustResizeCursor ();
+ } else {
+ cursorPos = adjustMoveCursor ();
+ }
+ oldX = cursorPos.x;
+ oldY = cursorPos.y;
+ }
+
+ tracking = true;
+ boolean cancelled = false;
+ while (tracking && !cancelled) {
+ if (parent != null && parent.isDisposed ()) break;
+ int result = OS.PhEventNext (buffer, size);
+ switch (result) {
+ case OS.Ph_EVENT_MSG: break;
+ case OS.Ph_RESIZE_MSG:
+ size = OS.PhGetMsgSize (buffer);
+ OS.free (buffer);
+ buffer = OS.malloc (size);
+ continue;
+ }
+ OS.memmove (phEvent, buffer, PhEvent_t.sizeof);
+ if (phEvent.type == OS.Ph_EV_DRAG) {
+ switch (phEvent.subtype) {
+ case OS.Ph_EV_DRAG_MOTION_EVENT: {
+ int data = OS.PhGetData (buffer);
+ if (data == 0) break;
+ PhPointerEvent_t pe = new PhPointerEvent_t ();
+ OS.memmove (pe, data, PhPointerEvent_t.sizeof);
+ int newX = pe.pos_x;
+ int newY = pe.pos_y;
+ if (newX != oldX || newY != oldY) {
+ drawRectangles (rectangles);
+ event.x = newX;
+ event.y = newY;
+ if ((style & SWT.RESIZE) != 0) {
+ resizeRectangles (newX - oldX, newY - oldY);
+ cursorPos = adjustResizeCursor ();
+ newX = cursorPos.x; newY = cursorPos.y;
+ sendEvent (SWT.Resize, event);
+ } else {
+ moveRectangles (newX - oldX, newY - oldY);
+ sendEvent (SWT.Move, event);
+ }
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the move
+ * event. If this happens, return false to indicate
+ * that the tracking has failed.
+ */
+ if (isDisposed ()) return false;
+ drawRectangles (rectangles);
+ oldX = newX; oldY = newY;
+ }
+ break;
+ }
+ case OS.Ph_EV_DRAG_KEY_EVENT: {
+ int data = OS.PhGetData (buffer);
+ if (data == 0) break;
+ PhKeyEvent_t ke = new PhKeyEvent_t ();
+ OS.memmove (ke, data, PhKeyEvent_t.sizeof);
+ if ((ke.key_flags & OS.Pk_KF_Sym_Valid) != 0) {
+ int stepSize = (ke.key_mods & OS.Pk_KM_Ctrl) != 0 ? STEPSIZE_SMALL : STEPSIZE_LARGE;
+ int xChange = 0, yChange = 0;
+ switch (ke.key_sym) {
+ case OS.Pk_Escape:
+ cancelled = true;
+ tracking = false;
+ break;
+ case OS.Pk_Return:
+ tracking = false;
+ break;
+ case OS.Pk_Left:
+ xChange = -stepSize;
+ break;
+ case OS.Pk_Right:
+ xChange = stepSize;
+ break;
+ case OS.Pk_Up:
+ yChange = -stepSize;
+ break;
+ case OS.Pk_Down:
+ yChange = stepSize;
+ break;
+ }
+ if (xChange != 0 || yChange != 0) {
+ drawRectangles (rectangles);
+ int newX = oldX + xChange;
+ int newY = oldY + yChange;
+ event.x = newX;
+ event.y = newY;
+ if ((style & SWT.RESIZE) != 0) {
+ resizeRectangles (xChange, yChange);
+ cursorPos = adjustResizeCursor ();
+ sendEvent (SWT.Resize, event);
+ } else {
+ moveRectangles (xChange, yChange);
+ cursorPos = adjustMoveCursor ();
+ sendEvent (SWT.Move, event);
+ }
+ /*
+ * It is possible (but unlikely) that application
+ * code could have disposed the widget in the move
+ * event. If this happens return false to indicate
+ * that the tracking has failed.
+ */
+ if (isDisposed ()) return false;
+ drawRectangles (rectangles);
+ oldX = cursorPos.x; oldY = cursorPos.y;
+ }
+ }
+ break;
+ }
+ case OS.Ph_EV_DRAG_COMPLETE: {
+ tracking = false;
+ break;
+ }
+ }
+ if (phEvent.collector_handle != 0) {
+ setCursor (phEvent.collector_handle);
+ }
+ /*
+ * Don't dispatch mouse and key events in general, EXCEPT once this
+ * tracker has finished its work.
+ */
+ if (tracking && !cancelled) continue;
+
+ }
+ OS.PtEventHandler (buffer);
+ }
+ drawRectangles (rectangles);
+ tracking = false;
+ if (region != 0) OS.PtDestroyWidget (region);
+ return !cancelled;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ parent = null;
+ display = null;
+ rectangles = null;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the control is moved or resized.
@@ -603,109 +603,109 @@ void releaseWidget () {
* @see ControlListener
* @see #addControlListener
*/
-public void removeControlListener (ControlListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Move, listener);
-}
-
-void resizeRectangles (int xChange, int yChange) {
- /*
- * If the cursor orientation has not been set in the orientation of
- * this change then try to set it here.
- */
- if (xChange < 0 && ((style & SWT.LEFT) != 0) && ((cursorOrientation & SWT.RIGHT) == 0)) {
- cursorOrientation |= SWT.LEFT;
- } else if (xChange > 0 && ((style & SWT.RIGHT) != 0) && ((cursorOrientation & SWT.LEFT) == 0)) {
- cursorOrientation |= SWT.RIGHT;
- } else if (yChange < 0 && ((style & SWT.UP) != 0) && ((cursorOrientation & SWT.DOWN) == 0)) {
- cursorOrientation |= SWT.UP;
- } else if (yChange > 0 && ((style & SWT.DOWN) != 0) && ((cursorOrientation & SWT.UP) == 0)) {
- cursorOrientation |= SWT.DOWN;
- }
- Rectangle bounds = computeBounds ();
- if ((cursorOrientation & SWT.LEFT) != 0) {
- bounds.x += xChange;
- bounds.width -= xChange;
- } else if ((cursorOrientation & SWT.RIGHT) != 0) {
- bounds.width += xChange;
- }
- if ((cursorOrientation & SWT.UP) != 0) {
- bounds.y += yChange;
- bounds.height -= yChange;
- } else if ((cursorOrientation & SWT.DOWN) != 0) {
- bounds.height += yChange;
- }
- /*
- * The following are conditions under which the resize should not be applied
- */
- if (bounds.width < 0 || bounds.height < 0) return;
-
- Rectangle [] newRects = new Rectangle [rectangles.length];
- for (int i = 0; i < rectangles.length; i++) {
- Rectangle proportion = proportions[i];
- newRects[i] = new Rectangle (
- proportion.x * bounds.width / 100 + bounds.x,
- proportion.y * bounds.height / 100 + bounds.y,
- proportion.width * bounds.width / 100,
- proportion.height * bounds.height / 100);
- }
- rectangles = newRects;
-}
-
-/**
- * Sets the <code>Cursor</code> of the Tracker. If this cursor is <code>null</code>
- * then the cursor reverts to the default.
- *
- * @param newCursor the new <code>Cursor</code> to display
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setCursor (Cursor cursor) {
- checkWidget();
- int type = 0;
- int bitmap = 0;
- if (cursor != null) {
- if (cursor.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- type = cursor.type;
- bitmap = cursor.bitmap;
- }
- clientCursor = type;
- clientBitmap = bitmap;
-}
-
-void setCursor (int cursorHandle) {
- if (cursorHandle == 0) return;
- int type = 0;
- int bitmap = 0;
- if (clientCursor != 0) {
- type = clientCursor;
- bitmap = clientBitmap;
- } else if (resizeCursor != 0) {
- type = resizeCursor;
- }
- int [] args = new int []{
- OS.Pt_ARG_CURSOR_TYPE, type, 0,
- OS.Pt_ARG_BITMAP_CURSOR, bitmap, 0,
- };
- OS.PtSetResources (cursorHandle, args.length / 3, args);
-
- /*
- * Bug in Photon. For some reason, the widget cursor will
- * not change, when the new cursor is a bitmap cursor, if
- * the flag Ph_CURSOR_NO_INHERIT is reset. The fix is to reset
- * this flag after changing the cursor type to Ph_CURSOR_BITMAP.
- */
- if (type == OS.Ph_CURSOR_BITMAP) {
- type &= ~OS.Ph_CURSOR_NO_INHERIT;
- OS.PtSetResource (cursorHandle, OS.Pt_ARG_CURSOR_TYPE, type, 0);
- }
-}
-
+public void removeControlListener (ControlListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Move, listener);
+}
+
+void resizeRectangles (int xChange, int yChange) {
+ /*
+ * If the cursor orientation has not been set in the orientation of
+ * this change then try to set it here.
+ */
+ if (xChange < 0 && ((style & SWT.LEFT) != 0) && ((cursorOrientation & SWT.RIGHT) == 0)) {
+ cursorOrientation |= SWT.LEFT;
+ } else if (xChange > 0 && ((style & SWT.RIGHT) != 0) && ((cursorOrientation & SWT.LEFT) == 0)) {
+ cursorOrientation |= SWT.RIGHT;
+ } else if (yChange < 0 && ((style & SWT.UP) != 0) && ((cursorOrientation & SWT.DOWN) == 0)) {
+ cursorOrientation |= SWT.UP;
+ } else if (yChange > 0 && ((style & SWT.DOWN) != 0) && ((cursorOrientation & SWT.UP) == 0)) {
+ cursorOrientation |= SWT.DOWN;
+ }
+ Rectangle bounds = computeBounds ();
+ if ((cursorOrientation & SWT.LEFT) != 0) {
+ bounds.x += xChange;
+ bounds.width -= xChange;
+ } else if ((cursorOrientation & SWT.RIGHT) != 0) {
+ bounds.width += xChange;
+ }
+ if ((cursorOrientation & SWT.UP) != 0) {
+ bounds.y += yChange;
+ bounds.height -= yChange;
+ } else if ((cursorOrientation & SWT.DOWN) != 0) {
+ bounds.height += yChange;
+ }
+ /*
+ * The following are conditions under which the resize should not be applied
+ */
+ if (bounds.width < 0 || bounds.height < 0) return;
+
+ Rectangle [] newRects = new Rectangle [rectangles.length];
+ for (int i = 0; i < rectangles.length; i++) {
+ Rectangle proportion = proportions[i];
+ newRects[i] = new Rectangle (
+ proportion.x * bounds.width / 100 + bounds.x,
+ proportion.y * bounds.height / 100 + bounds.y,
+ proportion.width * bounds.width / 100,
+ proportion.height * bounds.height / 100);
+ }
+ rectangles = newRects;
+}
+
+/**
+ * Sets the <code>Cursor</code> of the Tracker. If this cursor is <code>null</code>
+ * then the cursor reverts to the default.
+ *
+ * @param newCursor the new <code>Cursor</code> to display
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setCursor (Cursor cursor) {
+ checkWidget();
+ int type = 0;
+ int bitmap = 0;
+ if (cursor != null) {
+ if (cursor.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ type = cursor.type;
+ bitmap = cursor.bitmap;
+ }
+ clientCursor = type;
+ clientBitmap = bitmap;
+}
+
+void setCursor (int cursorHandle) {
+ if (cursorHandle == 0) return;
+ int type = 0;
+ int bitmap = 0;
+ if (clientCursor != 0) {
+ type = clientCursor;
+ bitmap = clientBitmap;
+ } else if (resizeCursor != 0) {
+ type = resizeCursor;
+ }
+ int [] args = new int []{
+ OS.Pt_ARG_CURSOR_TYPE, type, 0,
+ OS.Pt_ARG_BITMAP_CURSOR, bitmap, 0,
+ };
+ OS.PtSetResources (cursorHandle, args.length / 3, args);
+
+ /*
+ * Bug in Photon. For some reason, the widget cursor will
+ * not change, when the new cursor is a bitmap cursor, if
+ * the flag Ph_CURSOR_NO_INHERIT is reset. The fix is to reset
+ * this flag after changing the cursor type to Ph_CURSOR_BITMAP.
+ */
+ if (type == OS.Ph_CURSOR_BITMAP) {
+ type &= ~OS.Ph_CURSOR_NO_INHERIT;
+ OS.PtSetResource (cursorHandle, OS.Pt_ARG_CURSOR_TYPE, type, 0);
+ }
+}
+
/**
* Specifies the rectangles that should be drawn, expressed relative to the parent
* widget. If the parent is a Display then these are screen coordinates.
@@ -717,13 +717,13 @@ void setCursor (int cursorHandle) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setRectangles (Rectangle [] rectangles) {
- checkWidget();
- if (rectangles == null) error (SWT.ERROR_NULL_ARGUMENT);
- this.rectangles = rectangles;
- proportions = computeProportions (rectangles);
-}
-
+public void setRectangles (Rectangle [] rectangles) {
+ checkWidget();
+ if (rectangles == null) error (SWT.ERROR_NULL_ARGUMENT);
+ this.rectangles = rectangles;
+ proportions = computeProportions (rectangles);
+}
+
/**
* Changes the appearance of the line used to draw the rectangles.
*
@@ -734,9 +734,9 @@ public void setRectangles (Rectangle [] rectangles) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setStippled (boolean stippled) {
- checkWidget();
- this.stippled = stippled;
-}
-
-}
+public void setStippled (boolean stippled) {
+ checkWidget();
+ this.stippled = stippled;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java
index b880163253..48e196d1d6 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java
@@ -1,17 +1,17 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+
/**
* This class is the abstract superclass of all user interface objects.
* Widgets are created, disposed and issue notification to listeners
@@ -38,40 +38,40 @@ import org.eclipse.swt.events.*;
*
* @see #checkSubclass
*/
-public abstract class Widget {
- public int handle;
- int style, state;
- EventTable eventTable;
- Object data;
- String [] keys;
- Object [] values;
-
- /* Global state flags */
-// static final int AUTOMATIC = 1 << 0;
-// static final int ACTIVE = 1 << 1;
- static final int GRAB = 1 << 2;
-// static final int MULTIEXPOSE = 1 << 3;
-// static final int RESIZEREDRAW = 1 << 4;
-// static final int WRAP = 1 << 5;
- static final int DISABLED = 1 << 6;
-// static final int HIDDEN = 1 << 7;
-// static final int FOREGROUND = 1 << 8;
-// static final int BACKGROUND = 1 << 9;
- static final int DISPOSED = 1 << 10;
- static final int HANDLE = 1 << 11;
- static final int CANVAS = 1 << 12;
- static final int MOVED = 1 << 13;
- static final int RESIZED = 1 << 14;
-
- static final int DEFAULT_WIDTH = 64;
- static final int DEFAULT_HEIGHT = 64;
-
- static final char Mnemonic = '&';
-
-Widget () {
- /* Do nothing */
-}
-
+public abstract class Widget {
+ public int handle;
+ int style, state;
+ EventTable eventTable;
+ Object data;
+ String [] keys;
+ Object [] values;
+
+ /* Global state flags */
+// static final int AUTOMATIC = 1 << 0;
+// static final int ACTIVE = 1 << 1;
+ static final int GRAB = 1 << 2;
+// static final int MULTIEXPOSE = 1 << 3;
+// static final int RESIZEREDRAW = 1 << 4;
+// static final int WRAP = 1 << 5;
+ static final int DISABLED = 1 << 6;
+// static final int HIDDEN = 1 << 7;
+// static final int FOREGROUND = 1 << 8;
+// static final int BACKGROUND = 1 << 9;
+ static final int DISPOSED = 1 << 10;
+ static final int HANDLE = 1 << 11;
+ static final int CANVAS = 1 << 12;
+ static final int MOVED = 1 << 13;
+ static final int RESIZED = 1 << 14;
+
+ static final int DEFAULT_WIDTH = 64;
+ static final int DEFAULT_HEIGHT = 64;
+
+ static final char Mnemonic = '&';
+
+Widget () {
+ /* Do nothing */
+}
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -100,156 +100,156 @@ Widget () {
* @see #checkSubclass
* @see #getStyle
*/
-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;
-}
-
-/**
- * Returns the provided string without mnemonic indicators.
- *
- * @param string the string to demangle
- */
-static String stripMnemonics (String string) {
- char [] text = new char [string.length ()];
- string.getChars (0, text.length, text, 0);
- int j = 0;
- for (int i = 0; i < text.length;) {
- if ((text[j++] = text[i++]) == Mnemonic) {
- if (i != text.length) {
- if (text[i] == Mnemonic) i++; else j--;
- }
- }
- }
- return new String(text, 0, j);
-}
-
-void checkOrientation (Widget parent) {
- style &= ~SWT.MIRRORED;
- if ((style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT)) == 0) {
- if (parent != null) {
- if ((parent.style & SWT.LEFT_TO_RIGHT) != 0) style |= SWT.LEFT_TO_RIGHT;
- if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) style |= SWT.RIGHT_TO_LEFT;
- }
- }
- style = checkBits (style, SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, 0, 0, 0, 0);
-}
-
-void checkParent (Widget parent) {
- if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (parent.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
-}
-
-/**
- * Checks that this class can be subclassed.
- * <p>
- * The SWT class library is intended to be subclassed
- * only at specific, controlled points (most notably,
- * <code>Composite</code> and <code>Canvas</code> when
- * implementing new widgets). This method enforces this
- * rule unless it is overridden.
- * </p><p>
- * <em>IMPORTANT:</em> By providing an implementation of this
- * method that allows a subclass of a class which does not
- * normally allow subclassing to be created, the implementer
- * agrees to be fully responsible for the fact that any such
- * subclass will likely fail between SWT releases and will be
- * strongly platform specific. No support is provided for
- * user-written classes which are implemented in this fashion.
- * </p><p>
- * The ability to subclass outside of the allowed SWT classes
- * is intended purely to enable those not on the SWT development
- * team to implement patches in order to get around specific
- * limitations in advance of when those limitations can be
- * addressed by the team. Subclassing should not be attempted
- * without an intimate and detailed understanding of the hierarchy.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- */
-protected void checkSubclass () {
- if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
-}
-
-/**
- * Throws an <code>SWTException</code> if the receiver can not
- * be accessed by the caller. This may include both checks on
- * the state of the receiver and more generally on the entire
- * execution context. This method <em>should</em> be called by
- * widget implementors to enforce the standard SWT invariants.
- * <p>
- * Currently, it is an error to invoke any method (other than
- * <code>isDisposed()</code>) on a widget that has had its
- * <code>dispose()</code> method called. It is also an error
- * to call widget methods from any thread that is different
- * from the thread that created the widget.
- * </p><p>
- * In future releases of SWT, there may be more or fewer error
- * checks and exceptions may be thrown for different reasons.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-protected void checkWidget () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (isDisposed ()) error (SWT.ERROR_WIDGET_DISPOSED);
-}
-
-int copyPhImage(int image) {
- if (image == 0) return 0;
- int newImage = OS.PiDuplicateImage (image, 0);
-
- /*
- * Bug in Photon. The image returned by PiDuplicateImage might
- * have the same mask_bm/alpha as the original image. The fix
- * is to detect this case and copy mask_bm/alpha if necessary.
- */
- PhImage_t phImage = new PhImage_t();
- OS.memmove (phImage, image, PhImage_t.sizeof);
- PhImage_t newPhImage = new PhImage_t();
- OS.memmove(newPhImage, newImage, PhImage_t.sizeof);
- if (newPhImage.mask_bm != 0 && phImage.mask_bm == newPhImage.mask_bm) {
- int length = newPhImage.mask_bpl * newPhImage.size_h;
- int ptr = OS.malloc(length);
- OS.memmove(ptr, newPhImage.mask_bm, length);
- newPhImage.mask_bm = ptr;
- }
- if (newPhImage.alpha != 0 && phImage.alpha == newPhImage.alpha) {
- 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_bpl * alpha.src_alpha_map_dim_h;
- int ptr = OS.malloc(length);
- OS.memmove(ptr, alpha.src_alpha_map_map, length);
- alpha.src_alpha_map_map = ptr;
- }
- int ptr = OS.malloc(PgAlpha_t.sizeof);
- OS.memmove(ptr, alpha, PgAlpha_t.sizeof);
- newPhImage.alpha = ptr;
- }
- OS.memmove(newImage, newPhImage, PhImage_t.sizeof);
- return newImage;
-}
-
+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;
+}
+
+/**
+ * Returns the provided string without mnemonic indicators.
+ *
+ * @param string the string to demangle
+ */
+static String stripMnemonics (String string) {
+ char [] text = new char [string.length ()];
+ string.getChars (0, text.length, text, 0);
+ int j = 0;
+ for (int i = 0; i < text.length;) {
+ if ((text[j++] = text[i++]) == Mnemonic) {
+ if (i != text.length) {
+ if (text[i] == Mnemonic) i++; else j--;
+ }
+ }
+ }
+ return new String(text, 0, j);
+}
+
+void checkOrientation (Widget parent) {
+ style &= ~SWT.MIRRORED;
+ if ((style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT)) == 0) {
+ if (parent != null) {
+ if ((parent.style & SWT.LEFT_TO_RIGHT) != 0) style |= SWT.LEFT_TO_RIGHT;
+ if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) style |= SWT.RIGHT_TO_LEFT;
+ }
+ }
+ style = checkBits (style, SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, 0, 0, 0, 0);
+}
+
+void checkParent (Widget parent) {
+ if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (parent.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+}
+
+/**
+ * Checks that this class can be subclassed.
+ * <p>
+ * The SWT class library is intended to be subclassed
+ * only at specific, controlled points (most notably,
+ * <code>Composite</code> and <code>Canvas</code> when
+ * implementing new widgets). This method enforces this
+ * rule unless it is overridden.
+ * </p><p>
+ * <em>IMPORTANT:</em> By providing an implementation of this
+ * method that allows a subclass of a class which does not
+ * normally allow subclassing to be created, the implementer
+ * agrees to be fully responsible for the fact that any such
+ * subclass will likely fail between SWT releases and will be
+ * strongly platform specific. No support is provided for
+ * user-written classes which are implemented in this fashion.
+ * </p><p>
+ * The ability to subclass outside of the allowed SWT classes
+ * is intended purely to enable those not on the SWT development
+ * team to implement patches in order to get around specific
+ * limitations in advance of when those limitations can be
+ * addressed by the team. Subclassing should not be attempted
+ * without an intimate and detailed understanding of the hierarchy.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+/**
+ * Throws an <code>SWTException</code> if the receiver can not
+ * be accessed by the caller. This may include both checks on
+ * the state of the receiver and more generally on the entire
+ * execution context. This method <em>should</em> be called by
+ * widget implementors to enforce the standard SWT invariants.
+ * <p>
+ * Currently, it is an error to invoke any method (other than
+ * <code>isDisposed()</code>) on a widget that has had its
+ * <code>dispose()</code> method called. It is also an error
+ * to call widget methods from any thread that is different
+ * from the thread that created the widget.
+ * </p><p>
+ * In future releases of SWT, there may be more or fewer error
+ * checks and exceptions may be thrown for different reasons.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+protected void checkWidget () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (isDisposed ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+
+int copyPhImage(int image) {
+ if (image == 0) return 0;
+ int newImage = OS.PiDuplicateImage (image, 0);
+
+ /*
+ * Bug in Photon. The image returned by PiDuplicateImage might
+ * have the same mask_bm/alpha as the original image. The fix
+ * is to detect this case and copy mask_bm/alpha if necessary.
+ */
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove (phImage, image, PhImage_t.sizeof);
+ PhImage_t newPhImage = new PhImage_t();
+ OS.memmove(newPhImage, newImage, PhImage_t.sizeof);
+ if (newPhImage.mask_bm != 0 && phImage.mask_bm == newPhImage.mask_bm) {
+ int length = newPhImage.mask_bpl * newPhImage.size_h;
+ int ptr = OS.malloc(length);
+ OS.memmove(ptr, newPhImage.mask_bm, length);
+ newPhImage.mask_bm = ptr;
+ }
+ if (newPhImage.alpha != 0 && phImage.alpha == newPhImage.alpha) {
+ 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_bpl * alpha.src_alpha_map_dim_h;
+ int ptr = OS.malloc(length);
+ OS.memmove(ptr, alpha.src_alpha_map_map, length);
+ alpha.src_alpha_map_map = ptr;
+ }
+ int ptr = OS.malloc(PgAlpha_t.sizeof);
+ OS.memmove(ptr, alpha, PgAlpha_t.sizeof);
+ newPhImage.alpha = ptr;
+ }
+ OS.memmove(newImage, newPhImage, PhImage_t.sizeof);
+ return newImage;
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notifed when an event of the given type occurs. When the
@@ -270,13 +270,13 @@ int copyPhImage(int image) {
* @see Listener
* @see #removeListener
*/
-public void addListener (int eventType, Listener handler) {
- checkWidget();
- if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) eventTable = new EventTable ();
- eventTable.hook (eventType, handler);
-}
-
+public void addListener (int eventType, Listener handler) {
+ checkWidget();
+ if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) eventTable = new EventTable ();
+ eventTable.hook (eventType, handler);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notifed when the widget is disposed. When the widget is
@@ -296,81 +296,81 @@ public void addListener (int eventType, Listener handler) {
* @see DisposeListener
* @see #removeDisposeListener
*/
-public void addDisposeListener (DisposeListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Dispose, typedListener);
-}
-
-void createHandle (int index) {
- /* Do nothing */
-}
-
-int createToolTip (String string, int handle, byte [] font) {
- if (string == null || string.length () == 0 || handle == 0) {
- return 0;
- }
-
- int shellHandle = OS.PtFindDisjoint (handle);
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- Display display = getDisplay ();
- int fill = display.INFO_BACKGROUND;
- int text_color = display.INFO_FOREGROUND;
- int toolTipHandle = OS.PtInflateBalloon (shellHandle, handle, OS.Pt_BALLOON_RIGHT, buffer, font, fill, text_color);
-
- /*
- * Feature in Photon. The position of the inflated balloon
- * is relative to the widget position and not to the cursor
- * position. The fix is to re-position the balloon.
- */
- int ig = OS.PhInputGroup (0);
- PhCursorInfo_t info = new PhCursorInfo_t ();
- OS.PhQueryCursor ((short)ig, info);
- short [] absX = new short [1], absY = new short [1];
- OS.PtGetAbsPosition (shellHandle, absX, absY);
- int x = info.pos_x - absX [0] + 16;
- int y = info.pos_y - absY [0] + 16;
- PhArea_t shellArea = new PhArea_t ();
- OS.PtWidgetArea (shellHandle, shellArea);
- PhArea_t toolTipArea = new PhArea_t ();
- OS.PtWidgetArea (toolTipHandle, toolTipArea);
- x = Math.max (0, Math.min (x, shellArea.size_w - toolTipArea.size_w));
- y = Math.max (0, Math.min (y, shellArea.size_h - toolTipArea.size_h));
- PhPoint_t pt = new PhPoint_t ();
- pt.x = (short) x;
- pt.y = (short) y;
- int ptr = OS.malloc (PhPoint_t.sizeof);
- OS.memmove (ptr, pt, PhPoint_t.sizeof);
- OS.PtSetResource (toolTipHandle, OS.Pt_ARG_POS, ptr, 0);
- OS.free (ptr);
-
- return toolTipHandle;
-}
-
-void createWidget (int index) {
- createHandle (index);
- hookEvents ();
- register ();
-}
-
-void deregister () {
- if (handle == 0) return;
- WidgetTable.remove (handle);
-}
-
-void destroyToolTip (int toolTipHandle) {
- if (toolTipHandle != 0) OS.PtDestroyWidget (toolTipHandle);
-}
-
-void destroyWidget () {
- int topHandle = topHandle ();
- releaseHandle ();
- if (topHandle != 0) {
- OS.PtDestroyWidget (topHandle);
- }
-}
-
+public void addDisposeListener (DisposeListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Dispose, typedListener);
+}
+
+void createHandle (int index) {
+ /* Do nothing */
+}
+
+int createToolTip (String string, int handle, byte [] font) {
+ if (string == null || string.length () == 0 || handle == 0) {
+ return 0;
+ }
+
+ int shellHandle = OS.PtFindDisjoint (handle);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ Display display = getDisplay ();
+ int fill = display.INFO_BACKGROUND;
+ int text_color = display.INFO_FOREGROUND;
+ int toolTipHandle = OS.PtInflateBalloon (shellHandle, handle, OS.Pt_BALLOON_RIGHT, buffer, font, fill, text_color);
+
+ /*
+ * Feature in Photon. The position of the inflated balloon
+ * is relative to the widget position and not to the cursor
+ * position. The fix is to re-position the balloon.
+ */
+ int ig = OS.PhInputGroup (0);
+ PhCursorInfo_t info = new PhCursorInfo_t ();
+ OS.PhQueryCursor ((short)ig, info);
+ short [] absX = new short [1], absY = new short [1];
+ OS.PtGetAbsPosition (shellHandle, absX, absY);
+ int x = info.pos_x - absX [0] + 16;
+ int y = info.pos_y - absY [0] + 16;
+ PhArea_t shellArea = new PhArea_t ();
+ OS.PtWidgetArea (shellHandle, shellArea);
+ PhArea_t toolTipArea = new PhArea_t ();
+ OS.PtWidgetArea (toolTipHandle, toolTipArea);
+ x = Math.max (0, Math.min (x, shellArea.size_w - toolTipArea.size_w));
+ y = Math.max (0, Math.min (y, shellArea.size_h - toolTipArea.size_h));
+ PhPoint_t pt = new PhPoint_t ();
+ pt.x = (short) x;
+ pt.y = (short) y;
+ int ptr = OS.malloc (PhPoint_t.sizeof);
+ OS.memmove (ptr, pt, PhPoint_t.sizeof);
+ OS.PtSetResource (toolTipHandle, OS.Pt_ARG_POS, ptr, 0);
+ OS.free (ptr);
+
+ return toolTipHandle;
+}
+
+void createWidget (int index) {
+ createHandle (index);
+ hookEvents ();
+ register ();
+}
+
+void deregister () {
+ if (handle == 0) return;
+ WidgetTable.remove (handle);
+}
+
+void destroyToolTip (int toolTipHandle) {
+ if (toolTipHandle != 0) OS.PtDestroyWidget (toolTipHandle);
+}
+
+void destroyWidget () {
+ int topHandle = topHandle ();
+ releaseHandle ();
+ if (topHandle != 0) {
+ OS.PtDestroyWidget (topHandle);
+ }
+}
+
/**
* Disposes of the operating system resources associated with
* the receiver and all its descendents. After this method has
@@ -394,31 +394,31 @@ void destroyWidget () {
* @see #removeDisposeListener
* @see #checkWidget
*/
-public void dispose () {
- /*
- * Note: It is valid to attempt to dispose a widget
- * more than once. If this happens, fail silently.
- */
- if (isDisposed()) return;
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- releaseChild ();
- releaseWidget ();
- destroyWidget ();
-}
-
-int drawProc (int widget, int damage) {
- return OS.Pt_CONTINUE;
-}
-
-static void error (int code) {
- SWT.error(code);
-}
-
-boolean filters (int eventType) {
- Display display = getDisplay ();
- return display.filters (eventType);
-}
-
+public void dispose () {
+ /*
+ * Note: It is valid to attempt to dispose a widget
+ * more than once. If this happens, fail silently.
+ */
+ if (isDisposed()) return;
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ releaseChild ();
+ releaseWidget ();
+ destroyWidget ();
+}
+
+int drawProc (int widget, int damage) {
+ return OS.Pt_CONTINUE;
+}
+
+static void error (int code) {
+ SWT.error(code);
+}
+
+boolean filters (int eventType) {
+ Display display = getDisplay ();
+ return display.filters (eventType);
+}
+
/**
* Returns the application defined widget data associated
* with the receiver, or null if it has not been set. The
@@ -441,11 +441,11 @@ boolean filters (int eventType) {
*
* @see #setData
*/
-public Object getData () {
- checkWidget();
- return data;
-}
-
+public Object getData () {
+ checkWidget();
+ return data;
+}
+
/**
* Returns the application defined property of the receiver
* with the specified name, or null if it has not been set.
@@ -470,16 +470,16 @@ public Object getData () {
*
* @see #setData
*/
-public Object getData (String key) {
- checkWidget();
- 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 (String key) {
+ checkWidget();
+ 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;
+}
+
/**
* Returns the <code>Display</code> that is associated with
* the receiver.
@@ -496,19 +496,19 @@ public Object getData (String key) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-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 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 "";
+}
+
/**
* Returns the receiver's style information.
* <p>
@@ -529,24 +529,24 @@ String getNameText () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getStyle () {
- checkWidget();
- return style;
-}
-
-boolean hooks (int eventType) {
- if (eventTable == null) return false;
- return eventTable.hooks (eventType);
-}
-
-int hotkeyProc (int widget, int data, int info) {
- return OS.Pt_CONTINUE;
-}
-
-void hookEvents () {
- /* Do nothing */
-}
-
+public int getStyle () {
+ checkWidget();
+ return style;
+}
+
+boolean hooks (int eventType) {
+ if (eventTable == null) return false;
+ return eventTable.hooks (eventType);
+}
+
+int hotkeyProc (int widget, int data, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+void hookEvents () {
+ /* Do nothing */
+}
+
/**
* Returns <code>true</code> if the widget has been disposed,
* and <code>false</code> otherwise.
@@ -558,25 +558,25 @@ void hookEvents () {
*
* @return <code>true</code> when the widget is disposed and <code>false</code> otherwise
*/
-public boolean isDisposed () {
- if (handle != 0) return false;
- if ((state & HANDLE) != 0) return true;
- return (state & DISPOSED) != 0;
-}
-
-boolean isValidSubclass () {
- return Display.isValidClass (getClass ());
-}
-
-protected boolean isListening (int eventType) {
- checkWidget();
- return hooks (eventType);
-}
-
-boolean isValidThread () {
- return getDisplay ().isValidThread ();
-}
-
+public boolean isDisposed () {
+ if (handle != 0) return false;
+ if ((state & HANDLE) != 0) return true;
+ return (state & DISPOSED) != 0;
+}
+
+boolean isValidSubclass () {
+ return Display.isValidClass (getClass ());
+}
+
+protected boolean isListening (int eventType) {
+ checkWidget();
+ return hooks (eventType);
+}
+
+boolean isValidThread () {
+ return getDisplay ().isValidThread ();
+}
+
/**
* Notifies all of the receiver's listeners for events
* of the given type that one such event has occurred by
@@ -593,136 +593,136 @@ boolean isValidThread () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void notifyListeners (int eventType, Event event) {
- checkWidget();
- if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
- sendEvent (eventType, event);
-}
-
-void postEvent (int eventType) {
- sendEvent (eventType, null, false);
-}
-
-void postEvent (int eventType, Event event) {
- sendEvent (eventType, event, false);
-}
-
-int Ph_EV_BOUNDARY (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Ph_EV_BUT_PRESS (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Ph_EV_BUT_RELEASE (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Ph_EV_DRAG (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Ph_EV_KEY (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Ph_EV_PTR_MOTION (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_ACTIVATE (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_ARM (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_GOT_FOCUS (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_LOST_FOCUS (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_MODIFY_VERIFY (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_OUTBOUND (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_PG_PANEL_SWITCHING (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_REALIZED (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_RESIZE (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_SCROLL_MOVE (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_SLIDER_MOVE (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_SELECTION (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_TEXT_CHANGED (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_TIMER_ACTIVATE (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_UNREALIZED (int widget, int info) {
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_WINDOW (int widget, 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 releaseResources () {
- releaseWidget ();
- releaseHandle ();
-}
-
-void releaseWidget () {
- sendEvent (SWT.Dispose);
- deregister ();
- eventTable = null;
- data = null;
- keys = null;
- values = null;
-}
-
+public void notifyListeners (int eventType, Event event) {
+ checkWidget();
+ if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
+ sendEvent (eventType, event);
+}
+
+void postEvent (int eventType) {
+ sendEvent (eventType, null, false);
+}
+
+void postEvent (int eventType, Event event) {
+ sendEvent (eventType, event, false);
+}
+
+int Ph_EV_BOUNDARY (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Ph_EV_BUT_PRESS (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Ph_EV_BUT_RELEASE (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Ph_EV_DRAG (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Ph_EV_KEY (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Ph_EV_PTR_MOTION (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_ACTIVATE (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_ARM (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_GOT_FOCUS (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_LOST_FOCUS (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_MODIFY_VERIFY (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_OUTBOUND (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_PG_PANEL_SWITCHING (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_REALIZED (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_RESIZE (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_SCROLL_MOVE (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_SLIDER_MOVE (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_SELECTION (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_TEXT_CHANGED (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_TIMER_ACTIVATE (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_UNREALIZED (int widget, int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_WINDOW (int widget, 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 releaseResources () {
+ releaseWidget ();
+ releaseHandle ();
+}
+
+void releaseWidget () {
+ sendEvent (SWT.Dispose);
+ deregister ();
+ eventTable = null;
+ data = null;
+ keys = null;
+ values = null;
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notifed when an event of the given type occurs.
@@ -741,44 +741,44 @@ void releaseWidget () {
* @see Listener
* @see #addListener
*/
-public void removeListener (int eventType, Listener handler) {
- checkWidget();
- if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (eventType, handler);
-}
-
-/**
- * Removes the listener from the collection of listeners who will
- * be notifed when an event of the given type occurs.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the SWT
- * public API. It is marked public only so that it can be shared
- * within the packages provided by SWT. It should never be
- * referenced from application code.
- * </p>
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should no longer be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #addListener
- */
-protected void removeListener (int eventType, SWTEventListener handler) {
- checkWidget();
- if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (eventType, handler);
-}
-
+public void removeListener (int eventType, Listener handler) {
+ checkWidget();
+ if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (eventType, handler);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notifed when an event of the given type occurs.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the SWT
+ * public API. It is marked public only so that it can be shared
+ * within the packages provided by SWT. It should never be
+ * referenced from application code.
+ * </p>
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should no longer be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see #addListener
+ */
+protected void removeListener (int eventType, SWTEventListener handler) {
+ checkWidget();
+ if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (eventType, handler);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notifed when the widget is disposed.
@@ -796,80 +796,80 @@ protected void removeListener (int eventType, SWTEventListener handler) {
* @see DisposeListener
* @see #addDisposeListener
*/
-public void removeDisposeListener (DisposeListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Dispose, listener);
-}
-
-void replaceMnemonic (int mnemonic, boolean normal, boolean alt) {
- Display display = getDisplay ();
- int [] args = {OS.Pt_ARG_ACCEL_KEY, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- if (args [1] != 0) {
- int length = OS.strlen (args [1]);
- if (length > 0) {
- byte [] buffer = new byte [length];
- OS.memmove (buffer, args [1], length);
- char [] accelText = Converter.mbcsToWcs (null, buffer);
- if (accelText.length > 0) {
- char key = Character.toLowerCase (accelText [0]);
- if (normal) {
- //TEMPORARY CODE
-// OS.PtRemoveHotkeyHandler (handle, key, 0, (short)0, SWT.Activate, display.windowProc);
- }
- if (alt) {
- OS.PtRemoveHotkeyHandler (handle, key, OS.Pk_KM_Alt, (short)0, handle, display.hotkeyProc);
- }
- }
- }
- }
- if (mnemonic == 0) return;
- char key = Character.toLowerCase ((char)mnemonic);
- if (normal) {
- //TEMPORARY CODE
-// OS.PtAddHotkeyHandler (handle, key, 0, (short)0, SWT.Activate, display.windowProc);
- }
- if (alt) {
- OS.PtAddHotkeyHandler (handle, key, OS.Pk_KM_Alt, (short)0, handle, display.hotkeyProc);
- }
-}
-
-void sendEvent (Event event) {
- Display display = event.display;
- if (!display.filterEvent (event)) {
- if (eventTable != null) eventTable.sendEvent (event);
- }
-}
-
-void sendEvent (int eventType) {
- sendEvent (eventType, null, true);
-}
-
-void sendEvent (int eventType, Event event) {
- sendEvent (eventType, event, true);
-}
-
-void sendEvent (int eventType, Event event, boolean send) {
- Display display = getDisplay ();
- if (eventTable == null && !display.filters (eventType)) {
- return;
- }
- if (event == null) event = new Event ();
- event.type = eventType;
- event.display = display;
- event.widget = this;
- if (event.time == 0) {
- event.time = display.getLastEventTime ();
- }
- if (send) {
- sendEvent (event);
- } else {
- display.postEvent (event);
- }
-}
-
+public void removeDisposeListener (DisposeListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Dispose, listener);
+}
+
+void replaceMnemonic (int mnemonic, boolean normal, boolean alt) {
+ Display display = getDisplay ();
+ int [] args = {OS.Pt_ARG_ACCEL_KEY, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] != 0) {
+ int length = OS.strlen (args [1]);
+ if (length > 0) {
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, args [1], length);
+ char [] accelText = Converter.mbcsToWcs (null, buffer);
+ if (accelText.length > 0) {
+ char key = Character.toLowerCase (accelText [0]);
+ if (normal) {
+ //TEMPORARY CODE
+// OS.PtRemoveHotkeyHandler (handle, key, 0, (short)0, SWT.Activate, display.windowProc);
+ }
+ if (alt) {
+ OS.PtRemoveHotkeyHandler (handle, key, OS.Pk_KM_Alt, (short)0, handle, display.hotkeyProc);
+ }
+ }
+ }
+ }
+ if (mnemonic == 0) return;
+ char key = Character.toLowerCase ((char)mnemonic);
+ if (normal) {
+ //TEMPORARY CODE
+// OS.PtAddHotkeyHandler (handle, key, 0, (short)0, SWT.Activate, display.windowProc);
+ }
+ if (alt) {
+ OS.PtAddHotkeyHandler (handle, key, OS.Pk_KM_Alt, (short)0, handle, display.hotkeyProc);
+ }
+}
+
+void sendEvent (Event event) {
+ Display display = event.display;
+ if (!display.filterEvent (event)) {
+ if (eventTable != null) eventTable.sendEvent (event);
+ }
+}
+
+void sendEvent (int eventType) {
+ sendEvent (eventType, null, true);
+}
+
+void sendEvent (int eventType, Event event) {
+ sendEvent (eventType, event, true);
+}
+
+void sendEvent (int eventType, Event event, boolean send) {
+ Display display = getDisplay ();
+ if (eventTable == null && !display.filters (eventType)) {
+ return;
+ }
+ if (event == null) event = new Event ();
+ event.type = eventType;
+ event.display = display;
+ event.widget = this;
+ if (event.time == 0) {
+ event.time = display.getLastEventTime ();
+ }
+ if (send) {
+ sendEvent (event);
+ } else {
+ display.postEvent (event);
+ }
+}
+
/**
* Sets the application defined widget data associated
* with the receiver to be the argument. The <em>widget
@@ -890,11 +890,11 @@ void sendEvent (int eventType, Event event, boolean send) {
* <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>
* </ul>
*/
-public void setData (Object data) {
- checkWidget();
- this.data = data;
-}
-
+public void setData (Object data) {
+ checkWidget();
+ this.data = data;
+}
+
/**
* Sets the application defined property of the receiver
* with the specified name to the given value.
@@ -919,185 +919,185 @@ public void setData (Object data) {
*
* @see #getData
*/
-public void setData (String key, Object value) {
- checkWidget();
- 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;
-}
-
-void setInputState(Event event, int key_mods, int button_state) {
- if ((key_mods & OS.Pk_KM_Alt) != 0) event.stateMask |= SWT.ALT;
- if ((key_mods & OS.Pk_KM_Shift) != 0) event.stateMask |= SWT.SHIFT;
- if ((key_mods & OS.Pk_KM_Ctrl) != 0) event.stateMask |= SWT.CONTROL;
- if ((button_state & OS.Ph_BUTTON_SELECT) != 0) event.stateMask |= SWT.BUTTON1;
- if ((button_state & OS.Ph_BUTTON_ADJUST) != 0) event.stateMask |= SWT.BUTTON2;
- if ((button_state & OS.Ph_BUTTON_MENU) != 0) event.stateMask |= SWT.BUTTON3;
-}
-
-void setKeyState(Event event, PhKeyEvent_t ke) {
- /*
- * Fetuare in Photon. The key_sym value is not valid when Ctrl
- * or Alt is pressed. The fix is to detect this case and try to
- * use the key_cap value.
- */
- int key = 0;
- if ((ke.key_flags & OS.Pk_KF_Sym_Valid) != 0) {
- key = ke.key_sym;
- } else if ((ke.key_flags & OS.Pk_KF_Cap_Valid) != 0) {
- if ((ke.key_flags & (OS.Pk_KF_Key_Down | OS.Pk_KF_Key_Repeat)) != 0) {
- key = ke.key_cap;
- if ((ke.key_mods & OS.Pk_KM_Ctrl) != 0) {
- if ('a' <= key && key <= 'z') key -= 'a' - 'A';
- if (64 <= key && key <= 95) key -= 64;
- }
- }
- }
- event.keyCode = Display.translateKey (key);
- switch (key) {
- case OS.Pk_BackSpace: event.character = '\b'; break;
- case OS.Pk_Linefeed: event.character = '\n'; break;
- case OS.Pk_Return: event.character = '\r'; break;
- case OS.Pk_Delete: event.character = 0x7F; break;
- case OS.Pk_Cancel:
- case OS.Pk_Escape: event.character = 0x1B; break;
- case OS.Pk_KP_Tab:
- case OS.Pk_Tab: event.character = '\t'; break;
-// case OS.Pk_Clear: event.character = 0xB; break;
-// case OS.Pk_Pause: event.character = 0x13; break;
-// case OS.Pk_Scroll_Lock: event.character = 0x14; break;
- default:
- if (event.keyCode == 0) event.character = (char) key;
- }
- setInputState(event, ke.key_mods, ke.button_state);
- switch (event.type) {
- case SWT.KeyDown:
- case SWT.Traverse:
- 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;
- break;
- case SWT.KeyUp:
- if (event.keyCode == SWT.ALT) event.stateMask |= SWT.ALT;
- if (event.keyCode == SWT.SHIFT) event.stateMask |= SWT.SHIFT;
- if (event.keyCode == SWT.CONTROL) event.stateMask |= SWT.CONTROL;
- break;
- }
-}
-
-void setMouseState(Event event, PhPointerEvent_t pe, PhEvent_t ev) {
- int buttons = pe.buttons;
- event.x = pe.pos_x + ev.translation_x;
- event.y = pe.pos_y + ev.translation_y;
- if (ev.type == OS.Ph_EV_BUT_PRESS || ev.type == OS.Ph_EV_BUT_RELEASE) {
- switch (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;
- }
- }
- setInputState(event, pe.key_mods, pe.button_state);
- switch (ev.type) {
- case OS.Ph_EV_BUT_PRESS:
- if (buttons == OS.Ph_BUTTON_SELECT) event.stateMask &= ~SWT.BUTTON1;
- if (buttons == OS.Ph_BUTTON_ADJUST) event.stateMask &= ~SWT.BUTTON2;
- if (buttons == OS.Ph_BUTTON_MENU) event.stateMask &= ~SWT.BUTTON3;
- break;
- case OS.Ph_EV_BUT_RELEASE:
- case OS.Ph_EV_DRAG:
- 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;
- break;
- }
-}
-
-int topHandle () {
- return handle;
-}
-
+public void setData (String key, Object value) {
+ checkWidget();
+ 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;
+}
+
+void setInputState(Event event, int key_mods, int button_state) {
+ if ((key_mods & OS.Pk_KM_Alt) != 0) event.stateMask |= SWT.ALT;
+ if ((key_mods & OS.Pk_KM_Shift) != 0) event.stateMask |= SWT.SHIFT;
+ if ((key_mods & OS.Pk_KM_Ctrl) != 0) event.stateMask |= SWT.CONTROL;
+ if ((button_state & OS.Ph_BUTTON_SELECT) != 0) event.stateMask |= SWT.BUTTON1;
+ if ((button_state & OS.Ph_BUTTON_ADJUST) != 0) event.stateMask |= SWT.BUTTON2;
+ if ((button_state & OS.Ph_BUTTON_MENU) != 0) event.stateMask |= SWT.BUTTON3;
+}
+
+void setKeyState(Event event, PhKeyEvent_t ke) {
+ /*
+ * Fetuare in Photon. The key_sym value is not valid when Ctrl
+ * or Alt is pressed. The fix is to detect this case and try to
+ * use the key_cap value.
+ */
+ int key = 0;
+ if ((ke.key_flags & OS.Pk_KF_Sym_Valid) != 0) {
+ key = ke.key_sym;
+ } else if ((ke.key_flags & OS.Pk_KF_Cap_Valid) != 0) {
+ if ((ke.key_flags & (OS.Pk_KF_Key_Down | OS.Pk_KF_Key_Repeat)) != 0) {
+ key = ke.key_cap;
+ if ((ke.key_mods & OS.Pk_KM_Ctrl) != 0) {
+ if ('a' <= key && key <= 'z') key -= 'a' - 'A';
+ if (64 <= key && key <= 95) key -= 64;
+ }
+ }
+ }
+ event.keyCode = Display.translateKey (key);
+ switch (key) {
+ case OS.Pk_BackSpace: event.character = '\b'; break;
+ case OS.Pk_Linefeed: event.character = '\n'; break;
+ case OS.Pk_Return: event.character = '\r'; break;
+ case OS.Pk_Delete: event.character = 0x7F; break;
+ case OS.Pk_Cancel:
+ case OS.Pk_Escape: event.character = 0x1B; break;
+ case OS.Pk_KP_Tab:
+ case OS.Pk_Tab: event.character = '\t'; break;
+// case OS.Pk_Clear: event.character = 0xB; break;
+// case OS.Pk_Pause: event.character = 0x13; break;
+// case OS.Pk_Scroll_Lock: event.character = 0x14; break;
+ default:
+ if (event.keyCode == 0) event.character = (char) key;
+ }
+ setInputState(event, ke.key_mods, ke.button_state);
+ switch (event.type) {
+ case SWT.KeyDown:
+ case SWT.Traverse:
+ 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;
+ break;
+ case SWT.KeyUp:
+ if (event.keyCode == SWT.ALT) event.stateMask |= SWT.ALT;
+ if (event.keyCode == SWT.SHIFT) event.stateMask |= SWT.SHIFT;
+ if (event.keyCode == SWT.CONTROL) event.stateMask |= SWT.CONTROL;
+ break;
+ }
+}
+
+void setMouseState(Event event, PhPointerEvent_t pe, PhEvent_t ev) {
+ int buttons = pe.buttons;
+ event.x = pe.pos_x + ev.translation_x;
+ event.y = pe.pos_y + ev.translation_y;
+ if (ev.type == OS.Ph_EV_BUT_PRESS || ev.type == OS.Ph_EV_BUT_RELEASE) {
+ switch (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;
+ }
+ }
+ setInputState(event, pe.key_mods, pe.button_state);
+ switch (ev.type) {
+ case OS.Ph_EV_BUT_PRESS:
+ if (buttons == OS.Ph_BUTTON_SELECT) event.stateMask &= ~SWT.BUTTON1;
+ if (buttons == OS.Ph_BUTTON_ADJUST) event.stateMask &= ~SWT.BUTTON2;
+ if (buttons == OS.Ph_BUTTON_MENU) event.stateMask &= ~SWT.BUTTON3;
+ break;
+ case OS.Ph_EV_BUT_RELEASE:
+ case OS.Ph_EV_DRAG:
+ 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;
+ break;
+ }
+}
+
+int topHandle () {
+ return handle;
+}
+
/**
* Returns a string containing a concise, human-readable
* description of the receiver.
*
* @return a string representation of the receiver
*/
-public String toString () {
- String string = "*Disposed*";
- if (!isDisposed ()) {
- string = "*Wrong Thread*";
- if (isValidThread ()) string = getNameText ();
- }
- return getName () + " {" + string + "}";
-}
-
-int windowProc (int handle, int data, int info) {
- switch (data) {
- case OS.Ph_EV_BOUNDARY: return Ph_EV_BOUNDARY (handle, info);
- case OS.Ph_EV_BUT_PRESS: return Ph_EV_BUT_PRESS (handle, info);
- case OS.Ph_EV_BUT_RELEASE: return Ph_EV_BUT_RELEASE (handle, info);
- case OS.Ph_EV_DRAG: return Ph_EV_DRAG (handle, info);
- case OS.Ph_EV_KEY: return Ph_EV_KEY (handle, info);
- case OS.Ph_EV_PTR_MOTION: return Ph_EV_PTR_MOTION (handle, info);
- case OS.Pt_CB_ACTIVATE: return Pt_CB_ACTIVATE (handle, info);
- case OS.Pt_CB_ARM: return Pt_CB_ARM (handle, info);
- case OS.Pt_CB_GOT_FOCUS: return Pt_CB_GOT_FOCUS (handle, info);
- case OS.Pt_CB_LOST_FOCUS: return Pt_CB_LOST_FOCUS (handle, info);
- case OS.Pt_CB_MODIFY_VERIFY: return Pt_CB_MODIFY_VERIFY (handle, info);
- case OS.Pt_CB_OUTBOUND: return Pt_CB_OUTBOUND (handle, info);
- case OS.Pt_CB_PG_PANEL_SWITCHING: return Pt_CB_PG_PANEL_SWITCHING (handle, info);
- case OS.Pt_CB_REALIZED: return Pt_CB_REALIZED (handle, info);
- case OS.Pt_CB_RESIZE: return Pt_CB_RESIZE (handle, info);
- case OS.Pt_CB_SCROLL_MOVE: return Pt_CB_SCROLL_MOVE (handle, info);
- case OS.Pt_CB_SLIDER_MOVE: return Pt_CB_SLIDER_MOVE (handle, info);
- case OS.Pt_CB_SELECTION: return Pt_CB_SELECTION (handle, info);
- case OS.Pt_CB_TEXT_CHANGED: return Pt_CB_TEXT_CHANGED (handle, info);
- case OS.Pt_CB_TIMER_ACTIVATE: return Pt_CB_TIMER_ACTIVATE (handle, info);
- case OS.Pt_CB_UNREALIZED: return Pt_CB_UNREALIZED (handle, info);
- case OS.Pt_CB_WINDOW: return Pt_CB_WINDOW (handle, info);
- }
- return OS.Pt_CONTINUE;
-}
-
-}
+public String toString () {
+ String string = "*Disposed*";
+ if (!isDisposed ()) {
+ string = "*Wrong Thread*";
+ if (isValidThread ()) string = getNameText ();
+ }
+ return getName () + " {" + string + "}";
+}
+
+int windowProc (int handle, int data, int info) {
+ switch (data) {
+ case OS.Ph_EV_BOUNDARY: return Ph_EV_BOUNDARY (handle, info);
+ case OS.Ph_EV_BUT_PRESS: return Ph_EV_BUT_PRESS (handle, info);
+ case OS.Ph_EV_BUT_RELEASE: return Ph_EV_BUT_RELEASE (handle, info);
+ case OS.Ph_EV_DRAG: return Ph_EV_DRAG (handle, info);
+ case OS.Ph_EV_KEY: return Ph_EV_KEY (handle, info);
+ case OS.Ph_EV_PTR_MOTION: return Ph_EV_PTR_MOTION (handle, info);
+ case OS.Pt_CB_ACTIVATE: return Pt_CB_ACTIVATE (handle, info);
+ case OS.Pt_CB_ARM: return Pt_CB_ARM (handle, info);
+ case OS.Pt_CB_GOT_FOCUS: return Pt_CB_GOT_FOCUS (handle, info);
+ case OS.Pt_CB_LOST_FOCUS: return Pt_CB_LOST_FOCUS (handle, info);
+ case OS.Pt_CB_MODIFY_VERIFY: return Pt_CB_MODIFY_VERIFY (handle, info);
+ case OS.Pt_CB_OUTBOUND: return Pt_CB_OUTBOUND (handle, info);
+ case OS.Pt_CB_PG_PANEL_SWITCHING: return Pt_CB_PG_PANEL_SWITCHING (handle, info);
+ case OS.Pt_CB_REALIZED: return Pt_CB_REALIZED (handle, info);
+ case OS.Pt_CB_RESIZE: return Pt_CB_RESIZE (handle, info);
+ case OS.Pt_CB_SCROLL_MOVE: return Pt_CB_SCROLL_MOVE (handle, info);
+ case OS.Pt_CB_SLIDER_MOVE: return Pt_CB_SLIDER_MOVE (handle, info);
+ case OS.Pt_CB_SELECTION: return Pt_CB_SELECTION (handle, info);
+ case OS.Pt_CB_TEXT_CHANGED: return Pt_CB_TEXT_CHANGED (handle, info);
+ case OS.Pt_CB_TIMER_ACTIVATE: return Pt_CB_TIMER_ACTIVATE (handle, info);
+ case OS.Pt_CB_UNREALIZED: return Pt_CB_UNREALIZED (handle, info);
+ case OS.Pt_CB_WINDOW: return Pt_CB_WINDOW (handle, info);
+ }
+ return OS.Pt_CONTINUE;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/WidgetTable.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/WidgetTable.java
index 7fdae475d0..a370d8cbdc 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/WidgetTable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/WidgetTable.java
@@ -1,109 +1,109 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-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 [] 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.PtSetResource (handle, OS.Pt_ARG_USER_DATA, ArgPtr, 4);
- 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 [0] - 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.PtSetResource (handle, OS.Pt_ARG_USER_DATA, ArgPtr, 4);
- }
- 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) {
- int j = 0;
- while (j < index) {
- if (result [j] == widget) break;
- j++;
- }
- if (j == index) result [index++] = (Shell) widget;
- }
- }
- if (index == length) return result;
- Shell [] newResult = new Shell [index];
- System.arraycopy (result, 0, newResult, 0, index);
- return newResult;
-}
-public static synchronized int size () {
- int size = 0;
- for (int i=0; i<WidgetTable.length; i++) {
- if (WidgetTable [i] != null) size++;
- }
- return size;
-}
-}
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+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 [] 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.PtSetResource (handle, OS.Pt_ARG_USER_DATA, ArgPtr, 4);
+ 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 [0] - 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.PtSetResource (handle, OS.Pt_ARG_USER_DATA, ArgPtr, 4);
+ }
+ 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) {
+ int j = 0;
+ while (j < index) {
+ if (result [j] == widget) break;
+ j++;
+ }
+ if (j == index) result [index++] = (Shell) widget;
+ }
+ }
+ if (index == length) return result;
+ Shell [] newResult = new Shell [index];
+ System.arraycopy (result, 0, newResult, 0, index);
+ return newResult;
+}
+public static synchronized int size () {
+ int size = 0;
+ for (int i=0; i<WidgetTable.length; i++) {
+ if (WidgetTable [i] != null) size++;
+ }
+ return size;
+}
+}